commit eed6460ad2d1e50dfd4d1600493a12c4287791b2 Author: simonzhangsz Date: Wed Mar 13 09:30:40 2024 +0800 2G ems initial diff --git a/include/Makefile.backup b/include/Makefile.backup new file mode 100644 index 0000000..d0f07c4 --- /dev/null +++ b/include/Makefile.backup @@ -0,0 +1,58 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Backup Function ## +## ## +## Created : Wei Liu 07/06/20 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + + +##-------------------------------------- +## +## Make backup +## +##-------------------------------------- +# backup +TIME_STR = ${shell date +%y%m%d_%H%M%S} +VER_STR = $(sed -n '/$(MODULE)_VERSION/'p ./src/include/$(MODULE).h | \ + awk -F '[{,}]' $(print $2 $3 $4 ) ) +BACK_PATH := ../../../r9_bak +BACK_PATH := $(BACK_PATH)/$(TYPE)/$(MODULE) +BACK_NAME = $(MODULE)_$(VER_STR)_$(TIME_STR).tgz +LS = ls -tl + +version: + @echo $(VER_STR) + +backfile ?= * + +ifeq "$(backfile)" "*" + backfile =$(wildcard $(BACK_PATH)/*.tgz) + CHECK_BACK_FILE =$(backfile) +else + CHECK_BACK_FILE =$(shell find $(BACK_PATH) -name $(backfile)) +endif + +bk: clean + @$(MKDIR) -p $(BACK_PATH) --mode=0777 + @echo Backuping $(MODULE)... $(BACK_PATH)/$(BACK_NAME) + @tar czvf $(BACK_PATH)/$(BACK_NAME) ./src ./ut ./doc ./Makefile + +lsbk: + @$(LS) $(BACK_PATH) + +rmbk: +ifneq "$(CHECK_BACK_FILE)" "" + @rm -rf $(BACK_PATH)/$(backfile) + @$(LS) $(BACK_PATH) +endif + +unzip: +ifneq "$(CHECK_BACK_FILE)" "" + @tar czvf $(BACK_PATH)/$(BACK_NAME) ./src ./ut ./doc ./Makefile + @tar zxvf $(BACK_PATH)/$(backfile) + @ls $(BACK_PATH) +endif + diff --git a/include/Makefile.cov b/include/Makefile.cov new file mode 100644 index 0000000..278a959 --- /dev/null +++ b/include/Makefile.cov @@ -0,0 +1,101 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Lcov Function ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/09 ## +## ## +##----------------------------------------------------------## + +##-------------------------------------- +## +## COVER define +## +##-------------------------------------- + +ifeq "$(COVER_NEED)" "yes" + +COVER := /usr/bin/lcov +GENHTML := /usr/bin/genhtml +GENDESC := /usr/bin/gendesc +GENPNG := /usr/bin/genpng + +##Depending on the presence of the GD.pm perl module, we can use the +##special option '--frames' for genhtml +USE_GENPNG := $(shell $(GENPNG) --help >/dev/null 2>/dev/null; echo $$?) + +ifeq ($(USE_GENPNG),0) + FRAMES := --frames +else + FRAMES := +endif + +##COV_SETFLAG := --zerocounters --path . -q --directory . +COV_SETFLAG := --zerocounters -q --directory ../obj +COV_SET := $(COVER) $(COV_SETFLAG) + +COVER_REPORT_PATH ?= $(UTDIR)/output + +INFO_FILE = $(COVER_REPORT_PATH)/$(MODULE).info +DSP_FILE = $(MODULE)_test_descriptions.txt + +COV_OUTSET = --capture --directory ../obj \ + --output-file $(INFO_FILE)\ + --test-name $(MODULE) -q \ + --base-directory ../ + +COV_HTMLSET= $(INFO_FILE) \ + --output-directory $(COVER_REPORT_PATH)\ + --title $(MODULE) \ + --show-details $(FRAMES) \ + --legend -q --num-spaces 4 +COV_OUTPUT = $(COVER) $(COV_OUTSET) + + +COV_DOC_PATH := /usr/local/include/cov + +endif + +##-------------------------------------- +## +## Make Test +## +##-------------------------------------- + +test: + @echo -e "\n================================Test start======================================\n" +ifeq "$(BUILD)" "exef" +ifeq "$(COVER_NEED)" "yes" + @$(MKDIR) -p $(COVER_REPORT_PATH) --mode=0777 + @cp -rf $(COV_DOC_PATH)/lcovrc $(COV_DOC_PATH)/lcov_html_header\ + $(COV_DOC_PATH)/lcov_html_foot /etc/ + @cp -rf /usr/local/include/cgprof/cgprof /usr/local/bin/cgprof + @$(COV_SET) + $(OUTFILE) + gprof $(OUTFILE) gmon.out -p | cgprof -Tps + @$(COV_OUTPUT) + @LANG=C $(GENHTML) $(COV_HTMLSET) + @echo + @echo -e "||---------------------------------------------------------------" + @echo -e "|| Test cover report generated on the paht $(COVER_REPORT_PATH). " + @echo -e "|| Point a web browser at index.html to see results. " + @echo -e "||---------------------------------------------------------------" +else + @echo "COVER_NEED: $(COVER_NEED)BUILD: $(BUILD) " + $(OUTFILE) +endif + @echo -e "\n================================Test End========================================\n" +else + @echo -e "||---------------------------------------------------------------" + @echo -e "|| This is not exef project! " + @echo -e "||---------------------------------------------------------------" + @echo "This is not exef project!" +endif + +cleanlcov: + @$(COV_SET) --reset + +retest: cleanlcov test + + diff --git a/include/Makefile.doxygen b/include/Makefile.doxygen new file mode 100644 index 0000000..7c4dd55 --- /dev/null +++ b/include/Makefile.doxygen @@ -0,0 +1,28 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Documentation Function ## +## ## +## Created : Wei Liu 07/06/30 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +VER_STR ?= 9.0 +DOXYGEN_DOC_PATH := /usr/local/include/doc + + +define PREPARE_DOXYGEN +sed 's/MODULE/$(MODULE)/g' $(1) | sed 's/VER_STR/$(VER_STR)/g' >> ./doc/doxygen.conf +endef + +define MAKE_DOC +@echo +@echo -e "Generate documnet of $(MODULE)\t\t\t Please Waiting..." +@$(call PREPARE_DOXYGEN, $(DOXYGEN_DOC_PATH)/doxygen.conf) +@doxygen ./doc/doxygen.conf +@cp -rf $(DOXYGEN_DOC_PATH)/view_chm.bat ./doc/html +@echo +@echo ==================================Doxygen End=================================== +endef + diff --git a/include/Makefile.indent b/include/Makefile.indent new file mode 100644 index 0000000..adf0a6a --- /dev/null +++ b/include/Makefile.indent @@ -0,0 +1,379 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Indenting fuction ## +## ## +## Created : Wei Liu 07/04/30 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##-------------------------------------- +## +## Make indenting program flags +## +##-------------------------------------- + +##-bad或--blank-lines-after-declarations  在声明区段后加上空白行。 +BAD_FLAG := +##-bad + +##-bap或--blank-lines-after-procedures  在程序后加上空白行。 +BAP_FLAG := +##-bap + +##-bbb或--blank-lines-after-block-comments  在注释区段後加上空白行。 +BBB_FLAG := +##-bbb + +##--break-before-boolean-operator bbo 较长的行,在逻辑运算符前分行 +BBO_FLAG := + +##-bc或--blank-lines-after-commas  在声明区段中,若出现逗号即换行。 +BC_FLAG := + +##-bl或--braces-after-if-line  if(或是else,for等等)与後面执行区段的"{"自成一行。 +BL_FLAG := -bl + +##-bli<缩排格数>或--brace-indent<缩排格数>  设置{}缩排的格数。 +BLI_FLAG := -bli4 + +##--braces-after-struct-decl-line bls 定义结构,"struct"和"{"分行 +BLS_FLAG := -bls + +##-br或--braces-on-if-line  if(或是else,for等等)与後面执行跛段的"{"自成一行。 +BR_FLAG := + +##-bs或--blank-before-sizeof  在sizeof之後空一格。 +BS_FLAG := + +##`-cbin' +##`--case-brace-indentationn' +##Indent braces after a case label N spaces. +CBI_FLAG := -cbi5 + +##-c<栏数>或--comment-indentation<栏数>  将注释置于程序码右侧指定的栏位。 +CW_FLAG := -c33 + +##-cd<栏数>或--declaration-comment-column<栏数>  将注释置于声明右侧指定的栏位。 +CD_FLAG := -cd33 + +##-cdb或--comment-delimiters-on-blank-lines  注释符号自成一行。 +CDB_FLAG := + +##-ce或--cuddle-else  将else置于"}"(if执行区段的结尾)之後。 +CE_FLAG := + +##-ci<缩排格数>或--continuation-indentation<缩排格数>  叙述过长而换行时,指定换行後缩排的格数。 +CI_FLAG := +##-ci4 + +##-cli<缩排格数>或--case-indentation-<缩排格数>  使用case时,switch缩排的格数。 +CLI_FLAG := -cli0 + +##-cp<栏数>或-else-endif-column<栏数>  将注释置于else与elseif叙述右侧定的栏位。 +CP_FLAG := -cp33 + +##-cs或--space-after-cast  在cast之後空一格。 +CS_FLAG := -cs + +##-d<缩排格数>或-line-comments-indentation<缩排格数>  针对不是放在程序码右侧的注释,设置其缩排格数。 +D_FLAG := +##-d0 + +##-di<栏数>或--declaration-indentation<栏数>  将声明区段的变量置于指定的栏位。 +DI_FLAG := +##-di4 + +##-fc1或--format-first-column-comments  针对放在每行最前端的注释,设置其格式。 +FC1_FLAG := -fc1 + + +##-fca或--format-all-comments  设置所有注释的格式。 +FCA_FLAG := + +##-gnu或--gnu-style  指定使用GNU的格式,此为预设值。 +GNU_FLAG := + +##-kr或--k-and-r-style  指定使用Kernighan&Ritchie的格式。 +KR_FLAG := + +##-orig或--original  使用Berkeley的格式。 +ORG_STYLE := + +##-i<格数>或--indent-level<格数>  设置缩排的格数。 +I_FLAG := -i4 + +##-ip<格数>或--parameter-indentation<格数>  设置参数的缩排格数。 +IP_FLAG := -ip4 + +##--line-length 75 l75 非注释行最长75 +LINE_FLAG := + +##`-lcn' +##`--comment-line-lengthn' +##Set maximum line length for comment formatting to n. +LCN_FLAG := + +##`-lps' +##`--leave-preprocessor-space' +##Leave space between `#' and preprocessor directive. +LPS_FLAG := + +##-lp或--continue-at-parentheses  叙述过长而换行,且叙述中包含了括号时,将括号中的每行起始栏位内容垂直对其排列。 +LP_FLAG := + +##--break-function-decl-args nbfda 关闭:函数的参数一个一行 +NBFDA_FLAG := -nbfda + +##-nbad或--no-blank-lines-after-declarations  在声明区段後不要加上空白行。 +NBAD_FLAG := + +##-nbap或--no-blank-lines-after-procedures  在程序後不要加上空白行。 +NBAP_FLAG := + +##-nbbb或--no-blank-lines-after-block-comments  在注释区段後不要加上空白行。 +NBBB_FLAG := + +##-nbc或--no-blank-lines-after-commas  在声明区段中,即使出现逗号,仍旧不要换行。 +NBC_FLAG := -nbc + +##-ncdb或--no-comment-delimiters-on-blank-lines  注释符号不要自成一行。 +NCBD_FLAG := -ncdb + +##--cuddle-do-while ncdw "do --- while"的"while"和其前面的"}"另起一行 +NCDW_FLAG := -ncdw + +##-nce或--dont-cuddle-else  不要将else置于"}"之後。 +NCE_FLAG := +##-nce + +##-ncs或--no-space-after-casts  不要在cast之後空一格。 +NCS_FLAG := + +##-nfc1或--dont-format-first-column-comments  不要格式化放在每行最前端的注释。 +NFC1_FLAG := + +##-nfca或--dont-format-comments  不要格式化任何的注释。 +NFCA_FLAG := -nfca + +##--honour-newlines hnl Prefer to break long lines at the position of newlines in the input +HNL_FLAG := -hnl + +##-nip或--no-parameter-indentation  参数不要缩排。 +NIP_FLAG := + +##-nlp或--dont-line-up-parentheses  叙述过长而换行,且叙述中包含了括号时,不用将括号中的每行起始栏位垂直对其排列。 +NLP_FLAG := + +##-npcs或--no-space-after-function-call-names  在调用的函数名称之後,不要加上空格。 +NPCS_FLAG := + +##-npro或--ignore-profile  不要读取indent的配置文件.indent.pro。 +NPRO_FLAG := -npro + +##-nprs或--space-after-procedure-calls  在"("后")"前不插入空格 。 +NPRS_FLAG := -nprs + +##-npsl或--dont-break-procedure-type  程序类型与程序名称放在同一行。 +NPSL_FLAG := -npsl + +##--space-after-for saf for后面有空格 +SAF_FLAG := -saf + +##--space-after-if sai if后面有空格 +SAI_FLAG := -sai + +##--space-after-while saw while后面有空格 +SAW_FLAG := -saw + +##-nsc或--dont-star-comments  注解左侧不要加上星号(*)。 +NSC_FLAG := -nsc + +##-nsob或--leave-optional-semicolon  不用处理多馀的空白行。 +NSOB_FLAG := + +##-nss或--dont-space-special-semicolon  若for或while区段仅有一行时,在分号前不加上空格。 +NSS_FLAG := -nss + +##-nv或--no-verbosity  不显示详细的信息。 +NV_FLAG := -nv + +##`-nut' +##`--no-tabs' +##Use spaces instead of tabs. +NUT_FLAG := +##-nut + +##-pcs或--space-after-procedure-calls  在调用的函数名称与"("之间加上空格。 +PCS_FLAG := -pcs + +##`-prs' +##`--space-after-parentheses' +##Put a space after every '(' and before every ')'. +PRS_FLAG := + +##`-pin' +##`--paren-indentationn' +##Specify the extra indentation per open parentheses '(' when a statement is broken. +PI_FLAG := +##-pi4 + +##-psl或--procnames-start-lines  程序类型置于程序名称的前一行。 +PSL_FLAG := + +##-sc或--start-left-side-of-comments  在每行注释左侧加上星号(*)。 +SC_FLAG := + +##-sob或--swallow-optional-blank-lines  删除多馀的空白行。 +SOB_FLAG := -sob + +## -sbin, --struct-brace-indentationn +## Indent braces of a struct, union or enum N spaces. +SBI_FLAGE := -sbi4 + +##-ss或--space-special-semicolon  若for或swile区段今有一行时,在分号前加上空格。 +SS_FLAG := -ss + +##-st或--standard-output  将结果显示在标准输出设备。 +ST_FLAG := + +##-T  数据类型名称缩排。 +T_FLAG := -T + +##-ts<格数>或--tab-size<格数>  设置tab的长度。 +TS_FLAG := -ts4 +##-ts4 + +##--use-tabs ut 使用tab来缩进 +UT_FLAG := -ut +##-ut + +##-v或--verbose  执行时显示详细的信息。 +V_FLAG := -v + + +##-version  显示版本信息。 +VER_FLAG := + + + + + +##未实现的风格: +##1,()与变量间加空格 (以实现) +##2, else 独立成行 +##3, 注释缩进 +##4,每个函数前加注释段 + +## indent flags +## -bad -bap -bbb -bbo -bl -bli4 -bls -bs -c33 -cd33 -ce -ci4 -cli0 +## -cp33 -cs -d0 -di4 -fc1 -hnl -i4 -ip4 -lp -nbc -ncdb -nbfda -ncdw +## -nfc1 -nfca -npro -npsl -nsc -nv -pcs -saf -sai -saw -sob -ss -T -ts4 -ut + +INDENT_FLAGS1 := $(GNU_FLAG) \ + $(KR_FLAG) \ + $(ORG_STYLE) \ + $(BAD_FLAG) \ + $(BAP_FLAG) \ + $(BBB_FLAG) \ + $(BBO_FLAG) \ + $(BC_FLAG) \ + $(BL_FLAG) \ + $(BLI_FLAG) \ + $(BLS_FLAG) \ + $(BR_FLAG) \ + $(BS_FLAG) \ + $(CBI_FLAG) \ + $(CW_FLAG) \ + $(CD_FLAG) \ + $(CDB_FLAG) \ + $(CE_FLAG) \ + $(CI_FLAG) \ + $(CLI_FLAG) \ + $(CP_FLAG) \ + $(CS_FLAG) \ + $(D_FLAG) \ + $(DI_FLAG) \ + $(FC1_FLAG) \ + $(FCA_FLAG) \ + $(HNL_FLAG) \ + $(I_FLAG) \ + $(IP_FLAG) \ + $(LINE_FLAG ) \ + $(LP_FLAG) \ + $(NBAD_FLAG) \ + $(NBAP_FLAG) \ + $(NBBB_FLAG) \ + $(NBC_FLAG) \ + $(NCBD_FLAG) \ + $(NBFDA_FLAG) \ + $(NCDW_FLAG) \ + $(NCE_FLAG) \ + $(NCS_FLAG) \ + $(NFC1_FLAG) \ + $(NFCA_FLAG) \ + $(NIP_FLAG) \ + $(NLP_FLAG) \ + $(NPCS_FLAG) \ + $(NPRO_FLAG) \ + $(NPRS_FLAG) \ + $(NPSL_FLAG) \ + $(NSC_FLAG) \ + $(NSOB_FLAG) \ + $(NSS_FLAG) \ + $(NV_FLAG) \ + $(PCS_FLAG) \ + $(PI_FLAG) \ + $(PSL_FLAG) \ + $(PRS_FLAG) \ + $(SAF_FLAG) \ + $(SAI_FLAG) \ + $(SAW_FLAG) \ + $(SBI_FLAGE) \ + $(SC_FLAG) \ + $(SOB_FLAG) \ + $(SS_FLAG) \ + $(ST_FLAG) \ + $(T_FLAG) \ + $(TS_FLAG) \ + $(UT_FLAG) \ + $(V_FLAG) \ + $(VER_FLAG) \ + $(NUT_FLAG) + +INDENT_FLAGS = -kr -i4 + + +##$(warning $(INDENT_FLAGS) $(1)) +##-------------------------------------- +## +## MAKE_INDENT template +## +##------------------------------------ + +define INDENT_FILE + +indent $(INDENT_FLAGS) $(1) + +endef + +define MAKE_INDENT +@echo +@echo "[Indent flags ]: $(INDENT_FLAGS)" +@echo "" +$(foreach file,$(1),$(call INDENT_FILE, $(file))) +@echo +@echo ===================================Indent End=================================== +endef + + + + + + + + + + + diff --git a/include/Makefile.rules b/include/Makefile.rules new file mode 100644 index 0000000..5f652cc --- /dev/null +++ b/include/Makefile.rules @@ -0,0 +1,350 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Rules ## +## ## +## Created : Wei Liu 07/03/07 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + + +UMAKE_VERSION := V2.0 + +##------------------------------------- +## +## Work Directory : /usr/local/include +## Default Target : all +## +##------------------------------------- +default: all +.PHONY: all clean rebuild test indent splint doc \ + dir config check bk lsbk rmbk unzip umakever usage\ + FORCE +.SUFFIXES: + +umakever: + @echo "Universal Makefile (UMake) Version: $(UMAKE_VERSION)" + +##-------------------------------------- +## +## Makefile CFG defination check +## +##-------------------------------------- + +ifeq "$(MODULE)" "" +$(error Please input the module name (MODULE = )in makefile. ) +endif + +ifeq "$(CFG)" "" +CFG=debug +$(warnning No configuration specified for CFG. Defaulting to $(MODULE) - debug. ) +endif + +ifeq "$(BUILD)" "" +BUILD=lib +$(warnning No configuration specified for BUILD. Defaulting to create lib$(MODULE).a. ) +endif + +ifeq "$(SRC_PATH)" "" +SRC_PATH=. +$(warnning No configuration specified for SRC_PATH. Defaulting to ./. ) +endif + +COVER_NEED ?= no +PLT_PATH ?= ../../plat +APP_PATH ?= ../../app +TYPE ?= plat + +##-------------------------------------- +## +## Gcc Flag for debug or release +## +##-------------------------------------- +CC := gcc +GCC_CFLAGS := -Wall -MM +AR_LINK := ar -r + +RELS_FLAGS_ADD += -DNDEBUG +RELEASE_CFLAGS += -g -Wall -I. $(RELS_FLAGS_ADD) +RELEASE_LINK_CFLAGS = -g $(RELS_FLAGS_ADD) -o +DEBUG_CFLAGS += -g -Wall -rdynamic -DDEBUG -I. $(DBUG_FLAGS_ADD) +DEBUG_LINK_CFLAGS = -g -rdynamic -DDEBUG -o + +ifeq "$(COVER_NEED)" "yes" +DEBUG_CFLAGS += -fprofile-arcs -ftest-coverage -pg +endif + +GCC_CFLAGS=$(DEBUG_CFLAGS) +GCC_LINK_CFLAGS=$(DEBUG_LINK_CFLAGS) + +##-------------------------------------- +## +## Project setting +## +##-------------------------------------- +OBJDIR:=./obj +LIBDIR:=./lib +UTDIR :=./ut +DOCDIR:=./doc +DIRBUILD=$(OBJDIR) + +ifeq "$(BUILD)" "lib" +BINDIR:=./bin +OUTFILE=$(LIBDIR)/lib$(MODULE).a +DIRNEED=$(UTDIR) $(DOCDIR) +DIRBUILD+=$(LIBDIR) +else +BINDIR:=. +OUTFILE=$(BINDIR)/$(MODULE) +DIRNEED= +DIRBUILD+=$(BINDIR) +endif + +##-------------------------------------- +## +## source , object and dependencies files +## +##-------------------------------------- + +SRC_SUBDIR := $(shell find $(SRC_PATH) -type d) + +vpath %.c $(SRC_SUBDIR) +vpath %.o $(OBJDIR) +vpath %.d $(OBJDIR) + +SRC_FULL_PATH = $(foreach dir,$(SRC_SUBDIR),$(wildcard $(dir)/*.c)) +SRC_FILES = $(foreach file, $(notdir $(SRC_FULL_PATH)) ,$(OBJDIR)/$(file)) +COMMON_OBJ = $(SRC_FILES:%.c=%.o) + +TEST_OBJ_PATH ?= ../../obj + +TEST_OBJ = $(foreach dir,$(TEST_OBJ_PATH),$(wildcard $(dir)/*.o)) + +OBJ=$(COMMON_OBJ) $(OBJ_ADD) +ALL_OBJ := $(OBJ) $(TEST_OBJ) + +##-------------------------------------- +## +## Lib setting +## +##-------------------------------------- + +ifeq "$(COVER_NEED)" "yes" +LIBCOVER=-lgcov +endif + +MODULE_PLT_LIB=$(foreach lib,$(PLT_LIB), -L$(PLT_PATH)/$(lib)/lib/ -l$(lib) ) +MODULE_PLT_LIB+=-lm + + +MODULE_APP_LIB=$(foreach lib,$(APP_LIB),-L$(APP_PATH)/$(lib)/lib -l$(lib)) + +ifneq (,$(findstring hlr,$(PLT_LIB))) +MODULE_APP_LIB= +##-L../app/ae/src/lib -lpubfunc +endif + +ifneq (,$(findstring auceir,$(PLT_LIB))) +MODULE_APP_LIB= +##-L../app/ae/src/lib -lpubfunc -L../usr/lib -la3a8 -ldl -lpopt +endif + +##-------------------------------------- +## +## Rules +## +##-------------------------------------- +CCFLAG_SWITCH ?= off +CC_COMPILE =$(CC) $(GCC_CFLAGS) -c $< -o $@ +CC_PRG_LINK=$(CC) $(GCC_LINK_CFLAGS) $(OUTFILE) $(ALL_OBJ) $(LIBCOVER) $(MODULE_APP_LIB) $(MODULE_PLT_LIB) $(LIB_ADD) +CC_LIB_LINK=$(AR_LINK) $(OUTFILE) $(ALL_OBJ) + +COMPILE=$(CC_COMPILE) +PRG_LINK=$(CC_PRG_LINK) +LIB_LINK=$(CC_LIB_LINK) + +ifeq "$(BUILD)" "exef" +LINK=$(PRG_LINK) +else +LINK=$(LIB_LINK) +endif + +# Build rules + +all: preproc start dir $(ALL_OBJ) #prtdebug + @echo Linking :$(OUTFILE) +ifeq "$(CCFLAG_SWITCH)" "off" + @$(LINK) +else + $(LINK) +endif + @$(POSTPROC_CMD) + @echo -e "\n================================================================================\n" + +sinclude $(DEPENDS) + +release : CC_COMPILE =$(CC) $(RELEASE_CFLAGS) -c $< -o $@ +release : CC_PRG_LINK=$(CC) $(RELEASE_LINK_CFLAGS) $(OUTFILE) $(ALL_OBJ) $(MODULE_APP_LIB) $(MODULE_PLT_LIB) $(LIB_ADD) +release : all + +##-------------------------------------- +## +## Make command to use for dependencies +## +##-------------------------------------- + +MAKE :=make +RM :=rm +MKDIR :=mkdir + +preproc: + @$(PREPROC_CMD) + +start: + @echo -e "\n================================================================================\n" + @echo "[Building Project]: $(notdir $(MODULE))" +ifeq "$(CCFLAG_SWITCH)" "off" + @echo "Show Gcc Flags switch = OFF" +endif + +prtdebug: + @echo "$(MODULE)-$(BUILD)[$(CFG)] build source file:" "$(SRC_FULL_PATH)" + @echo SRC_SUBDIR: $(SRC_SUBDIR) + @echo SRC_FULL_PATH : $(SRC_FULL_PATH) + @echo SRC_FILES : $(SRC_FILES) + @echo ALL_OBJ : $(ALL_OBJ) + @echo LIB:$(MODULE_PLT_LIB) + @echo PLT_LIB: $(PLT_LIB) + @echo CCFLAG_SWITCH :$(CCFLAG_SWITCH) + +config: dir + +dir: + @$(foreach dir,$(DIRNEED),$(MKDIR) -p $(DIRNEED) --mode=0777; ) + @$(foreach dir,$(DIRBUILD),$(MKDIR) -p $(dir) --mode=0777; ) + +##-------------------------------------- +## +## Make Rebuild and clean +## +##-------------------------------------- + +ifneq "$(PROJ)" "" +FRIEND_PROJ := $(shell ) +endif + +jumprebuild: +ifneq "$(PROJ)" "" + @cd $(FRIEND_PROJ); mak rebuild ; cd - +endif + +# Rebuild this project +rebuild: jumprebuild cleanall all + +# Clean this project and all dependencies +cleanall: clean + +# Clean this project +clean: + @echo -e "||--------------------------------------------------------------- " + @echo -e "|| Umake clean gcc , lcov, doxygen generated and temporary files. " + @echo -e "||--------------------------------------------------------------- " + @$(RM) -rf $(OBJDIR) $(OUTFILE) $(COVER_REPORT_PATH) ./doc/doxygen.conf ./doc/html ./doc/latex ./doc/rtf $(foreach dir,$(SRC_SUBDIR),$(dir)/*~) + + +##-------------------------------------- +## +## indent Makefile.indent +## +##-------------------------------------- +include Makefile.indent + +indent: + @chmod 777 $(SRC_FULL_PATH) + @echo ===================================Indent START================================= + @echo + @echo "[Indent source file ]: $(SRC_FULL_PATH)" + $(call MAKE_INDENT , $(SRC_FULL_PATH)) + +##-------------------------------------- +## +## splint makefile.splint +## +##-------------------------------------- +include Makefile.splint + +SPLINT_FLAG_SWITCH ?= off + +splint: + @chmod 777 $(SRC_FULL_PATH) + @echo =================================Splint START================================== + @echo +ifeq "$(SPLINT_FLAG_SWITCH)" "on" + @echo "[Splint flags ]: $(SPLINT_FLAGS)" +endif + @echo "[Lint Clean Project]: $(notdir $(MODULE))" + $(call MAKE_SPLINT, $(SRC_FULL_PATH)) + +##-------------------------------------- +## +## doc Makefile.doxygen +## +##-------------------------------------- +include Makefile.doxygen + +doc: + @chmod 777 $(SRC_FULL_PATH) + @echo ==================================Doxygen START================================= + @echo + $(call MAKE_DOC, $(SRC_FULL_PATH)) + + +##-------------------------------------- +## +## backup Makefile.backup +## +##-------------------------------------- +include Makefile.backup + +##-------------------------------------- +## +## cov Makefile.cov +## +##-------------------------------------- +include Makefile.cov + +##-------------------------------------- +## +## usage Makefile.usage +## +##-------------------------------------- +include Makefile.usage + +##-------------------------------------- +## +## Make dependencies +## +##-------------------------------------- + +$(OBJDIR)/%.d:%.c + @$(CC) $< -MM -MD -o $@ + +$(OBJDIR)/%.o:%.c + +ifeq "$(CCFLAG_SWITCH)" "off" + @echo -e "building: $(notdir $@) \t\t\t\t please wait ..." + @$(COMPILE) +else + $(COMPILE) +endif + +DEPENDS=$(COMMON_OBJ:.o=.d) + +##-------------------------------------- +## +## Make force +## +##-------------------------------------- +FORCE: + diff --git a/include/Makefile.rules.bak b/include/Makefile.rules.bak new file mode 100644 index 0000000..8774bc9 --- /dev/null +++ b/include/Makefile.rules.bak @@ -0,0 +1,352 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Rules ## +## ## +## Created : Wei Liu 07/03/07 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + + +UMAKE_VERSION := V2.0 + +##------------------------------------- +## +## Work Directory : /usr/local/include +## Default Target : all +## +##------------------------------------- +default: all +.PHONY: all clean rebuild test indent splint doc \ + dir config check bk lsbk rmbk unzip umakever usage\ + FORCE +.SUFFIXES: + +umakever: + @echo "Universal Makefile (UMake) Version: $(UMAKE_VERSION)" + +##-------------------------------------- +## +## Makefile CFG defination check +## +##-------------------------------------- + +ifeq "$(MODULE)" "" +$(error Please input the module name (MODULE = )in makefile. ) +endif + +ifeq "$(CFG)" "" +CFG=debug +$(warnning No configuration specified for CFG. Defaulting to $(MODULE) - debug. ) +endif + +ifeq "$(BUILD)" "" +BUILD=lib +$(warnning No configuration specified for BUILD. Defaulting to create lib$(MODULE).a. ) +endif + +ifeq "$(SRC_PATH)" "" +SRC_PATH=. +$(warnning No configuration specified for SRC_PATH. Defaulting to ./. ) +endif + +COVER_NEED ?= no +PLT_PATH ?= ../../plat +APP_PATH ?= ../../app +TYPE ?= plat + +##-------------------------------------- +## +## Gcc Flag for debug or release +## +##-------------------------------------- +#CC := arm-linux-gnueabi-gcc +CC := gcc +GCC_CFLAGS := -Wall -MM +#AR_LINK := arm-linux-gnueabi-ar -r +AR_LINK := ar -r +ARM_INCLUDE := /opt/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabi/usr/include +RELS_FLAGS_ADD += -DNDEBUG +RELEASE_CFLAGS += -g -I. -I$(ARM_INCLUDE) $(RELS_FLAGS_ADD) +RELEASE_LINK_CFLAGS = -g $(RELS_FLAGS_ADD) -o +DEBUG_CFLAGS += -g -rdynamic -finline-functions -DDEBUG -I. -I$(ARM_INCLUDE) $(DBUG_FLAGS_ADD) +DEBUG_LINK_CFLAGS = -g -rdynamic -DDEBUG -o + +ifeq "$(COVER_NEED)" "yes" +DEBUG_CFLAGS += -fprofile-arcs -ftest-coverage -pg +endif + +GCC_CFLAGS=$(DEBUG_CFLAGS) +GCC_LINK_CFLAGS=$(DEBUG_LINK_CFLAGS) + +##-------------------------------------- +## +## Project setting +## +##-------------------------------------- +OBJDIR:=./obj +LIBDIR:=./lib +UTDIR :=./ut +DOCDIR:=./doc +DIRBUILD=$(OBJDIR) + +ifeq "$(BUILD)" "lib" +BINDIR:=./bin +OUTFILE=$(LIBDIR)/lib$(MODULE).a +DIRNEED=$(UTDIR) $(DOCDIR) +DIRBUILD+=$(LIBDIR) +else +BINDIR:=. +OUTFILE=$(BINDIR)/$(MODULE) +DIRNEED= +DIRBUILD+=$(BINDIR) +endif + +##-------------------------------------- +## +## source , object and dependencies files +## +##-------------------------------------- + +SRC_SUBDIR := $(shell find $(SRC_PATH) -type d) + +vpath %.c $(SRC_SUBDIR) +vpath %.o $(OBJDIR) +vpath %.d $(OBJDIR) + +SRC_FULL_PATH = $(foreach dir,$(SRC_SUBDIR),$(wildcard $(dir)/*.c)) +SRC_FILES = $(foreach file, $(notdir $(SRC_FULL_PATH)) ,$(OBJDIR)/$(file)) +COMMON_OBJ = $(SRC_FILES:%.c=%.o) + +TEST_OBJ_PATH ?= ../../obj + +TEST_OBJ = $(foreach dir,$(TEST_OBJ_PATH),$(wildcard $(dir)/*.o)) + +OBJ=$(COMMON_OBJ) $(OBJ_ADD) +ALL_OBJ := $(OBJ) $(TEST_OBJ) + +##-------------------------------------- +## +## Lib setting +## +##-------------------------------------- + +ifeq "$(COVER_NEED)" "yes" +LIBCOVER=-lgcov +endif + +MODULE_PLT_LIB=$(foreach lib,$(PLT_LIB), -L$(PLT_PATH)/$(lib)/lib/ -l$(lib) ) +MODULE_PLT_LIB+=-lm + + +MODULE_APP_LIB=$(foreach lib,$(APP_LIB),-L$(APP_PATH)/$(lib)/lib -l$(lib)) + +ifneq (,$(findstring hlr,$(PLT_LIB))) +MODULE_APP_LIB= +##-L../app/ae/src/lib -lpubfunc +endif + +ifneq (,$(findstring auceir,$(PLT_LIB))) +MODULE_APP_LIB= +##-L../app/ae/src/lib -lpubfunc -L../usr/lib -la3a8 -ldl -lpopt +endif + +##-------------------------------------- +## +## Rules +## +##-------------------------------------- +CCFLAG_SWITCH ?= off +CC_COMPILE =$(CC) $(GCC_CFLAGS) -c $< -o $@ +CC_PRG_LINK=$(CC) $(GCC_LINK_CFLAGS) $(OUTFILE) $(ALL_OBJ) $(LIBCOVER) $(MODULE_APP_LIB) $(MODULE_PLT_LIB) $(LIB_ADD) +CC_LIB_LINK=$(AR_LINK) $(OUTFILE) $(ALL_OBJ) + +COMPILE=$(CC_COMPILE) +PRG_LINK=$(CC_PRG_LINK) +LIB_LINK=$(CC_LIB_LINK) + +ifeq "$(BUILD)" "exef" +LINK=$(PRG_LINK) +else +LINK=$(LIB_LINK) +endif + +# Build rules + +all: preproc start dir $(ALL_OBJ) #prtdebug + @echo Linking :$(OUTFILE) +ifeq "$(CCFLAG_SWITCH)" "off" + @$(LINK) +else + $(LINK) +endif + @$(POSTPROC_CMD) + @echo -e "\n================================================================================\n" + +sinclude $(DEPENDS) + +release : CC_COMPILE =$(CC) $(RELEASE_CFLAGS) -c $< -o $@ +release : CC_PRG_LINK=$(CC) $(RELEASE_LINK_CFLAGS) $(OUTFILE) $(ALL_OBJ) $(MODULE_APP_LIB) $(MODULE_PLT_LIB) $(LIB_ADD) +release : all + +##-------------------------------------- +## +## Make command to use for dependencies +## +##-------------------------------------- + +MAKE :=make +RM :=rm +MKDIR :=mkdir + +preproc: + @$(PREPROC_CMD) + +start: + @echo -e "\n================================================================================\n" + @echo "[Building Project]: $(notdir $(MODULE))" +ifeq "$(CCFLAG_SWITCH)" "off" + @echo "Show Gcc Flags switch = OFF" +endif + +prtdebug: + @echo "$(MODULE)-$(BUILD)[$(CFG)] build source file:" "$(SRC_FULL_PATH)" + @echo SRC_SUBDIR: $(SRC_SUBDIR) + @echo SRC_FULL_PATH : $(SRC_FULL_PATH) + @echo SRC_FILES : $(SRC_FILES) + @echo ALL_OBJ : $(ALL_OBJ) + @echo LIB:$(MODULE_PLT_LIB) + @echo PLT_LIB: $(PLT_LIB) + @echo CCFLAG_SWITCH :$(CCFLAG_SWITCH) + +config: dir + +dir: + @$(foreach dir,$(DIRNEED),$(MKDIR) -p $(DIRNEED) --mode=0777; ) + @$(foreach dir,$(DIRBUILD),$(MKDIR) -p $(dir) --mode=0777; ) + +##-------------------------------------- +## +## Make Rebuild and clean +## +##-------------------------------------- + +ifneq "$(PROJ)" "" +FRIEND_PROJ := $(shell ) +endif + +jumprebuild: +ifneq "$(PROJ)" "" + @cd $(FRIEND_PROJ); mak rebuild ; cd - +endif + +# Rebuild this project +rebuild: jumprebuild cleanall all + +# Clean this project and all dependencies +cleanall: clean + +# Clean this project +clean: + @echo -e "||--------------------------------------------------------------- " + @echo -e "|| Umake clean gcc , lcov, doxygen generated and temporary files. " + @echo -e "||--------------------------------------------------------------- " + @$(RM) -rf $(OBJDIR) $(OUTFILE) $(COVER_REPORT_PATH) ./doc/doxygen.conf ./doc/html ./doc/latex ./doc/rtf $(foreach dir,$(SRC_SUBDIR),$(dir)/*~) + + +##-------------------------------------- +## +## indent Makefile.indent +## +##-------------------------------------- +include Makefile.indent + +indent: + @chmod 777 $(SRC_FULL_PATH) + @echo ===================================Indent START================================= + @echo + @echo "[Indent source file ]: $(SRC_FULL_PATH)" + $(call MAKE_INDENT , $(SRC_FULL_PATH)) + +##-------------------------------------- +## +## splint makefile.splint +## +##-------------------------------------- +include Makefile.splint + +SPLINT_FLAG_SWITCH ?= off + +splint: + @chmod 777 $(SRC_FULL_PATH) + @echo =================================Splint START================================== + @echo +ifeq "$(SPLINT_FLAG_SWITCH)" "on" + @echo "[Splint flags ]: $(SPLINT_FLAGS)" +endif + @echo "[Lint Clean Project]: $(notdir $(MODULE))" + $(call MAKE_SPLINT, $(SRC_FULL_PATH)) + +##-------------------------------------- +## +## doc Makefile.doxygen +## +##-------------------------------------- +include Makefile.doxygen + +doc: + @chmod 777 $(SRC_FULL_PATH) + @echo ==================================Doxygen START================================= + @echo + $(call MAKE_DOC, $(SRC_FULL_PATH)) + + +##-------------------------------------- +## +## backup Makefile.backup +## +##-------------------------------------- +include Makefile.backup + +##-------------------------------------- +## +## cov Makefile.cov +## +##-------------------------------------- +include Makefile.cov + +##-------------------------------------- +## +## usage Makefile.usage +## +##-------------------------------------- +include Makefile.usage + +##-------------------------------------- +## +## Make dependencies +## +##-------------------------------------- + +$(OBJDIR)/%.d:%.c + @$(CC) $< -MM -MD -o $@ + +$(OBJDIR)/%.o:%.c + +ifeq "$(CCFLAG_SWITCH)" "off" + @echo -e "building: $(notdir $@) \t\t\t\t please wait ..." + @$(COMPILE) +else + $(COMPILE) +endif + +DEPENDS=$(COMMON_OBJ:.o=.d) + +##-------------------------------------- +## +## Make force +## +##-------------------------------------- +FORCE: + diff --git a/include/Makefile.splint b/include/Makefile.splint new file mode 100644 index 0000000..3c50c5c --- /dev/null +++ b/include/Makefile.splint @@ -0,0 +1,288 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile Splint Function ## +## ## +## Created : Wei Liu 07/05/20 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##-------------------------------------- +## +## Make splinting program flags +## +##-------------------------------------- + +##是否有提示信息 +SFLAG_HINTS := #-hints + +##是否用库信息代替头文件 +SFLAG_INCLUDE := +single-include +#+never-include + +##包含什么库 +SFLAG_LIB := +posixlib +##+nolib +nof -warnposix +##+unixlib +##+posixlib +#+nolib +nof -warnposix +##+nof +##+unixlib +##+which_lib + +## +SFLAG_DUMP := +##dump ./include/public.h ./include/pub_base.h ./include/includes.h +SFLAG_LOAD := +##+load /usr/share/splint/lib/unixstrict.lcd +##load ./include/public.h ./include/pub_base.h ./include/includes.h + +SFLAG_DIR := +##-I/work/r9/plat/public/src/include/splint +##-I/work/r9/plat/public/src/include/splint +##-I /usr/local/work/r9/plat/public/src/include/ + +##检查模式 +SFLAG_TYPE := -strict + +##略过的头文件 +SFLAG_SYS_HEADERS := +skip_sys_headers +SFLAG_ISO_HEADERS := +#+skip_iso_headers +SFLAG_POSIX_HEADERS := +##+skip_posix_headers + +##每个头文件只检查一次 +SFLAG_SINGLE_INCLUDE := +singleinclude + +##系统文件目录 +SFLAG_SYS_DIR := +##+sys-dirs /work/r9/plat/public/src/include/splint + +##函数参数有原型 +SFLAG_PROTO_PARAMNAME := -protoparamname + +##变量名是否为保留名 +SFLAG_UNDERSCORE := -isoreserved -isoreservedinternal + +## 在"/*"和"*/"中再次使用"/*"和"*/" +SFLAG_NESTCOMMENT := -nestcomment + +##允许未说明导出变量、函数和类型 +SFLAG_EXPORT_VAR := -exportvar +SFLAG_EXPORT_FCN := -exportfcn +SFLAG_EXPORT_TYPE := -exporttype +SFLAG_EXPORT_CONST := -exportconst + +##允许其他类型定义为BOOL型 +SFLAG_LIKELY_BOOL := -likelybool + +##两种类型相等 +SFLAG_CHAR_INT := +charint +SFLAG_BOOL_INT := +boolint + +##Report memory transfer errors for initializations to read-only string literals +SFLAG_READONLY_TRANS := -readonlytrans + +##A string literal is assigned to a char array that smaller than the string literal needs +SFLAG_STRING_SMALLER := -stringliteralsmaller + +##A variable declared outside a macro body starts with the macro-var-prefix +SFLAG_MACRO_PREFIX := -macrovarprefixexclude + +##Initializer does not define all elements of a declared array +SFLAG_INITAL_ELEMENT := -initallelements + +##类型匹配 +SFLAG_PARAM_TYPE := -type + +##Report modification errors in functions declared without a modifies clause +SFLAG_MODIFY := -modnomods + +##Use of a checked global in a function with no globals list +SFLAG_GLOBAL := -glob-noglobs + +##Use of internal state in function with no globals list +SFLAG_INTERNAL_GLOBS := -internal-globs-noglobs + +##Implicit checked qualifier on global variables and qualifier file static scope variables with no checking annotation +SFLAG_CHECK_GLOBAL := -imp-checkedstrict-globs -imp-checkedstrict_statics + +##Undocumented modification of a checked global variable in a function with no modifies clause +SFLAG_CHECK_GLOBAL_MODIFY := -mod-globs-nomods + +##Storage declared with observer may be modified through a call to an unconstrained function +SFLAG_OBSERVER_MODIFY := -mod-observer-uncon + +##忽略返回值 +SFLAG_IGNORE_RETVAL := -retval + +##while,if and for statement is not a block +SFLAG_WHILE_BLOCK := -whileblock +SFLAG_IF_BLOCK := -ifblock +SFLAG_FOR_BLOCK := -forblock + +##There is no finals else following an else if construct +SFLAG_ELSEIF_COMPLETE := -elseifcomplete + +##允许指针进行数学运算 +SFLAG_POINT_ARITH := -ptrarith -nullptrarith + +##An unconstrained function is called in a function body where modifications are checked. +SFLAG_UNCONSTRAIN_MODIFY := -mod-uncon-nomods + +##NO effect of unconstrained functions +SFLAG_EFFECT_UNCONSTRAIN := -no-effect-uncon + +##Type-mismatch in parameter corresponding to format code in a printflike or scanflike function +SFLAG_FORMAT-TYPE := -format-type + +##An actual parameter that is passed as a unique formal parameter is aliased by another parameter or global variable +SFLAG_ALIASING := -alias-unique -ret-alias#-may-alias-unique + +##Transfer Errors flag +SFLAG_STORAGE_TRANSFER := -onlytrans -temptrans -unqualified-trans -immediatetrans + +##Report errors for break statements inside a nested while, for or switch +SFLAG_DEEP_BREAK := -deep-break #-switch-switch-break -loop-loop-break + +##Storage has inconsistent states of alternate paths through a branch +SFLAG_INCONSISTENT_BRANCH := -branch-state + +##There is a non-empty case in a switch not followed by a break. +##Likely infinite loop is detected +##Likely infinite loop is detected. Loop test or body calls an unconstrained function that may produce an undetected modification +SFLAG_PROBLEMATIC_CTR := -case-break -infloops -infloopsuncon + +##An expression may be undefined because a sub-expression contains a call to an unconstrained function (no modifies clause) +##that may modify something that may be modified or used by another sub-expression +SFLAG_UNDEFINED_EVALORDER := -eval-order-uncon + +##Only storage transferred to an unqualified global or static reference. +##This may lead to a memory leak, since the new reference is not necessarily released +SFLAG_INITIALIZERS := -only-unq-global-trans + +##Primitive operation does not type check strictly +SFLAG_PRIMITIVE_OPERA := -strict-ops -bitwise-signed + +##Unused Declarations (未使用的声明) +SFLAG_DECLARARIONS := -field-use -fcnuse -param-use -typeuse -varuse -enummemuse + +##Function, variable, iterator or constant declared but never defined (未初始化) +SFLAG_COMPLETE_PRG := -decl-undef + +##A declaration is exported but not used outside this module or not appear in a header file +SFLAG_EXPORTS := -export-local -export-header + +##把warning输出到文件splint_warn中 +SFLAG_WARN_FILE := #+warning-stream splint_warn + +##把致命错误输出到文件splint_error中 +SFLAG_ERROR_FILE := #+error-stream splint_error + +##文件覆盖 +SFLAG_STREAM_OVERWRITE := -streamoverwrite + +##An abstract type defined in M.h (or specified in M.lcl) is accessible in M.c +SFLAG_ACCESS := -access-module + +##Function definition is in old style syntax. Standard prototype syntax is preferred. +SFLAG_ISO_CONFORMANCE := #-old-style + +##Use of function that may lead to buffer overflow +SFLAG_BUFFER := -bufferoverflowhigh + +##A function is declared without a parameter list prototype +SFLAG_FUNC_NOPARAM := -noparams + +##Operand of sizeof operator is a type +SFLAG_SIZEOF_TYPE := -sizeoftype + +##Storage derivable from a parameter, return value or global variable is not completely defined +SFLAG_COMP_DEF := -compdef + +##Behavior of an expression is unspecified or implementation-dependent +##because sub-expressions contain interfering side effects that may be evaluated in any order +SFLAG_EVAL_ORDER := -eval-order + +##try to recover code +SFLAG_TRY_TO_RECOVER := #+trytorecover + +##返回一个NULL指针 +SFLAG_NULL_RET := -nullret + +##A possibly null pointer is reachable from a parameter or global variable that is not declared using a /*@null@*/ annotation +SFLAG_NULL_STATE := -nullstate + +##The value of a location that may not be initialized on some execution path is used +SFLAG_USE_BEFORE_DEF := -usedef + +##编译时不知道参数类型 Format parameter is not known at compile-time 例如:sprintf(mgcpAsciTempBuf, msg) +SFLAG_FORMAT_CONST := -format-const + +##Argument to exit has implementation defined behavior. The only valid arguments to exit are EXIT_SUCCESS, EXIT_FAILURE and 0. +##An error is reported if Splint can determine statically that the argument to exit is not one of these +SFLAG_EXIT_ARG := -exitarg + +##An extern declaration is used inside a function body +SFLAG_EXTERN := -nested-extern + + + +SFLAG_OLD_STTLE := -oldstyle + + +SFLAG_SHIFT_NEG := -shiftnegative + + +SFLAG_PREPROC := -preproc + +##all splint flags + +SPLINT_FLAGS := $(SFLAG_LIB) $(SFLAG_TYPE) $(SFLAG_SYS_HEADERS) $(SFLAG_ISO_HEADERS)\ + $(SFLAG_POSIX_HEADERS) $(SFLAG_SINGLEINCLUDE) $(SFLAG_WARN)\ + $(SFLAG_UNDERSCORE) $(SFLAG_NESTCOMMENT) $(SFLAG_EVAL_ORDER)\ + $(SFLAG_PROTO_PARAMNAME) $(SFLAG_EXPORT_VAR) $(SFLAG_EXPORT_FCN)\ + $(SFLAG_EXPORT_TYPE) $(SFLAG_LIKELY_BOOL) $(SFLAG_CHAR_INT)\ + $(SFLAG_READONLY_TRANS) $(SFLAG_STRING_SMALLER) $(SFLAG_MACRO_PREFIX)\ + $(SFLAG_INITAL_ELEMENT) $(SFLAG_PARAM_TYPE) $(SFLAG_GLOBAL)\ + $(SFLAG_CHECK_GLOBAL) $(SFLAG_CHECK_GLOBAL_MODIFY) $(SFLAG_IGNORE_RETVAL)\ + $(SFLAG_INTERNAL_GLOBS) $(SFLAG_MODIFY) $(SFLAG_BOOL_INT)\ + $(SFLAG_WHILE_BLOCK) $(SFLAG_HINTS) $(SFLAG_IF_BLOCK) $(SFLAG_FOR_BLOCK)\ + $(SFLAG_POINT_ARITH) $(SFLAG_ELSEIF_COMPLETE) $(SFLAG_UNCONSTRAIN_MODIFY)\ + $(SFLAG_EFFECT_UNCONSTRAIN) $(SFLAG_OBSERVER_MODIFY)\ + $(SFLAG_FORMAT-TYPE) $(SFLAG_ALIASING) $(SFLAG_STORAGE_TRANSFER)\ + $(SFLAG_DEEP_BREAK) $(SFLAG_INCONSISTENT_BRANCH) $(SFLAG_PROBLEMATIC_CTR)\ + $(SFLAG_UNDEFINED_EVALORDER) $(SFLAG_INITIALIZERS) $(SFLAG_PRIMITIVE_OPERA)\ + $(SFLAG_DECLARARIONS) $(SFLAG_COMPLETE_PRG) $(SFLAG_EXPORTS) $(SFLAG_INCLUDE)\ + $(SFLAG_STREAM_OVERWRITE) $(SFLAG_WARN_FILE) $(SFLAG_ERROR_FILE)\ + $(SFLAG_ACCESS) $(SFLAG_ISO_CONFORMANCE) $(SFLAG_BUFFER) $(SFLAG_SIZEOF_TYPE)\ + $(SFLAG_COMP_DEF) $(SFLAG_FUNC_NOPARAM) $(SFLAG_TRY_TO_RECOVER)\ + $(SFLAG_EXPORT_CONST) $(SFLAG_DUMP) $(SFLAG_LOAD) $(SFLAG_NULL_RET)\ + $(SFLAG_NULL_STATE) $(SFLAG_USE_BEFORE_DEF) $(SFLAG_FORMAT_CONST)\ + $(SFLAG_EXIT_ARG) $(SFLAG_EXTERN) $(SFLAG_OLD_STTLE) $(SFLAG_DIR)\ + $(SFLAG_SHIFT_NEG) $(SFLAG_PREPROC) + +##-------------------------------------- +## +## MAKE_INDENT template +## +##------------------------------------ + +define SPLINT_FILE +@echo -e "Splinting: $(notdir $(1)) \t\t\t please wait ..." +@nohup splint $(SPLINT_FLAGS) $(1) | sed '$d' | sed '1,2d' |\ + sed '/Splint /d' | sed '/Finished /d' |\ + sed '/Cannot continue/d' + +endef + +##@echo $(SPLINT_FLAGS) +define MAKE_SPLINT +@echo + +$(foreach file,$(1),$(call SPLINT_FILE, $(file))) +@echo +@echo =======================================End====================================== +endef \ No newline at end of file diff --git a/include/Makefile.usage b/include/Makefile.usage new file mode 100644 index 0000000..579b49b --- /dev/null +++ b/include/Makefile.usage @@ -0,0 +1,36 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile usage ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/09 ## +## ## +##----------------------------------------------------------## + +##------------------------------------- +## +## Universal Makefile Usage +## +##------------------------------------- + +usage: + @echo "usage: [make ] = make all " + @echo "usage: [make all ] " + @echo "usage: [make clean ] " + @echo "usage: [make rebuild ] " + @echo "usage: [make test ] " + @echo "usage: [make indent ] " + @echo "usage: [make splint ] " + @echo "usage: [make prtdebug ] " + @echo "usage: [make dir ] " + @echo "usage: [make config ] = make dir now " + @echo "usage: [make check ] = not supported now " + @echo "usage: [make bk ] " + @echo "usage: [make lsbk ] " + @echo "usage: [make rmbk backfile=*/[filename]] " + @echo "usage: [make unzip backfile=[filename] ] " + @echo "usage: [make version ] " + @echo "usage: [make umakever ] " + + diff --git a/include/gtest/gtest-death-test.h b/include/gtest/gtest-death-test.h new file mode 100644 index 0000000..dc878ff --- /dev/null +++ b/include/gtest/gtest-death-test.h @@ -0,0 +1,343 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines the public API for death tests. It is +// #included by gtest.h so a user doesn't need to include this +// directly. +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ + +#include "gtest/internal/gtest-death-test-internal.h" + +namespace testing { + +// This flag controls the style of death tests. Valid values are "threadsafe", +// meaning that the death test child process will re-execute the test binary +// from the start, running only a single death test, or "fast", +// meaning that the child process will execute the test logic immediately +// after forking. +GTEST_DECLARE_string_(death_test_style); + +#if GTEST_HAS_DEATH_TEST + +namespace internal { + +// Returns a Boolean value indicating whether the caller is currently +// executing in the context of the death test child process. Tools such as +// Valgrind heap checkers may need this to modify their behavior in death +// tests. IMPORTANT: This is an internal utility. Using it may break the +// implementation of death tests. User code MUST NOT use it. +GTEST_API_ bool InDeathTestChild(); + +} // namespace internal + +// The following macros are useful for writing death tests. + +// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is +// executed: +// +// 1. It generates a warning if there is more than one active +// thread. This is because it's safe to fork() or clone() only +// when there is a single thread. +// +// 2. The parent process clone()s a sub-process and runs the death +// test in it; the sub-process exits with code 0 at the end of the +// death test, if it hasn't exited already. +// +// 3. The parent process waits for the sub-process to terminate. +// +// 4. The parent process checks the exit code and error message of +// the sub-process. +// +// Examples: +// +// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number"); +// for (int i = 0; i < 5; i++) { +// EXPECT_DEATH(server.ProcessRequest(i), +// "Invalid request .* in ProcessRequest()") +// << "Failed to die on request " << i; +// } +// +// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting"); +// +// bool KilledBySIGHUP(int exit_code) { +// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP; +// } +// +// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!"); +// +// On the regular expressions used in death tests: +// +// GOOGLETEST_CM0005 DO NOT DELETE +// On POSIX-compliant systems (*nix), we use the library, +// which uses the POSIX extended regex syntax. +// +// On other platforms (e.g. Windows or Mac), we only support a simple regex +// syntax implemented as part of Google Test. This limited +// implementation should be enough most of the time when writing +// death tests; though it lacks many features you can find in PCRE +// or POSIX extended regex syntax. For example, we don't support +// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and +// repetition count ("x{5,7}"), among others. +// +// Below is the syntax that we do support. We chose it to be a +// subset of both PCRE and POSIX extended regex, so it's easy to +// learn wherever you come from. In the following: 'A' denotes a +// literal character, period (.), or a single \\ escape sequence; +// 'x' and 'y' denote regular expressions; 'm' and 'n' are for +// natural numbers. +// +// c matches any literal character c +// \\d matches any decimal digit +// \\D matches any character that's not a decimal digit +// \\f matches \f +// \\n matches \n +// \\r matches \r +// \\s matches any ASCII whitespace, including \n +// \\S matches any character that's not a whitespace +// \\t matches \t +// \\v matches \v +// \\w matches any letter, _, or decimal digit +// \\W matches any character that \\w doesn't match +// \\c matches any literal character c, which must be a punctuation +// . matches any single character except \n +// A? matches 0 or 1 occurrences of A +// A* matches 0 or many occurrences of A +// A+ matches 1 or many occurrences of A +// ^ matches the beginning of a string (not that of each line) +// $ matches the end of a string (not that of each line) +// xy matches x followed by y +// +// If you accidentally use PCRE or POSIX extended regex features +// not implemented by us, you will get a run-time failure. In that +// case, please try to rewrite your regular expression within the +// above syntax. +// +// This implementation is *not* meant to be as highly tuned or robust +// as a compiled regex library, but should perform well enough for a +// death test, which already incurs significant overhead by launching +// a child process. +// +// Known caveats: +// +// A "threadsafe" style death test obtains the path to the test +// program from argv[0] and re-executes it in the sub-process. For +// simplicity, the current implementation doesn't search the PATH +// when launching the sub-process. This means that the user must +// invoke the test program via a path that contains at least one +// path separator (e.g. path/to/foo_test and +// /absolute/path/to/bar_test are fine, but foo_test is not). This +// is rarely a problem as people usually don't put the test binary +// directory in PATH. +// + +// Asserts that a given statement causes the program to exit, with an +// integer exit status that satisfies predicate, and emitting error output +// that matches regex. +# define ASSERT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) + +// Like ASSERT_EXIT, but continues on to successive tests in the +// test suite, if any: +# define EXPECT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) + +// Asserts that a given statement causes the program to exit, either by +// explicitly exiting with a nonzero exit code or being killed by a +// signal, and emitting error output that matches regex. +# define ASSERT_DEATH(statement, regex) \ + ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) + +// Like ASSERT_DEATH, but continues on to successive tests in the +// test suite, if any: +# define EXPECT_DEATH(statement, regex) \ + EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) + +// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: + +// Tests that an exit code describes a normal exit with a given exit code. +class GTEST_API_ ExitedWithCode { + public: + explicit ExitedWithCode(int exit_code); + bool operator()(int exit_status) const; + private: + // No implementation - assignment is unsupported. + void operator=(const ExitedWithCode& other); + + const int exit_code_; +}; + +# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +// Tests that an exit code describes an exit due to termination by a +// given signal. +// GOOGLETEST_CM0006 DO NOT DELETE +class GTEST_API_ KilledBySignal { + public: + explicit KilledBySignal(int signum); + bool operator()(int exit_status) const; + private: + const int signum_; +}; +# endif // !GTEST_OS_WINDOWS + +// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. +// The death testing framework causes this to have interesting semantics, +// since the sideeffects of the call are only visible in opt mode, and not +// in debug mode. +// +// In practice, this can be used to test functions that utilize the +// LOG(DFATAL) macro using the following style: +// +// int DieInDebugOr12(int* sideeffect) { +// if (sideeffect) { +// *sideeffect = 12; +// } +// LOG(DFATAL) << "death"; +// return 12; +// } +// +// TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) { +// int sideeffect = 0; +// // Only asserts in dbg. +// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death"); +// +// #ifdef NDEBUG +// // opt-mode has sideeffect visible. +// EXPECT_EQ(12, sideeffect); +// #else +// // dbg-mode no visible sideeffect. +// EXPECT_EQ(0, sideeffect); +// #endif +// } +// +// This will assert that DieInDebugReturn12InOpt() crashes in debug +// mode, usually due to a DCHECK or LOG(DFATAL), but returns the +// appropriate fallback value (12 in this case) in opt mode. If you +// need to test that a function has appropriate side-effects in opt +// mode, include assertions against the side-effects. A general +// pattern for this is: +// +// EXPECT_DEBUG_DEATH({ +// // Side-effects here will have an effect after this statement in +// // opt mode, but none in debug mode. +// EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); +// }, "death"); +// +# ifdef NDEBUG + +# define EXPECT_DEBUG_DEATH(statement, regex) \ + GTEST_EXECUTE_STATEMENT_(statement, regex) + +# define ASSERT_DEBUG_DEATH(statement, regex) \ + GTEST_EXECUTE_STATEMENT_(statement, regex) + +# else + +# define EXPECT_DEBUG_DEATH(statement, regex) \ + EXPECT_DEATH(statement, regex) + +# define ASSERT_DEBUG_DEATH(statement, regex) \ + ASSERT_DEATH(statement, regex) + +# endif // NDEBUG for EXPECT_DEBUG_DEATH +#endif // GTEST_HAS_DEATH_TEST + +// This macro is used for implementing macros such as +// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where +// death tests are not supported. Those macros must compile on such systems +// if and only if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters +// on systems that support death tests. This allows one to write such a macro on +// a system that does not support death tests and be sure that it will compile +// on a death-test supporting system. It is exposed publicly so that systems +// that have death-tests with stricter requirements than GTEST_HAS_DEATH_TEST +// can write their own equivalent of EXPECT_DEATH_IF_SUPPORTED and +// ASSERT_DEATH_IF_SUPPORTED. +// +// Parameters: +// statement - A statement that a macro such as EXPECT_DEATH would test +// for program termination. This macro has to make sure this +// statement is compiled but not executed, to ensure that +// EXPECT_DEATH_IF_SUPPORTED compiles with a certain +// parameter if and only if EXPECT_DEATH compiles with it. +// regex - A regex that a macro such as EXPECT_DEATH would use to test +// the output of statement. This parameter has to be +// compiled but not evaluated by this macro, to ensure that +// this macro only accepts expressions that a macro such as +// EXPECT_DEATH would accept. +// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED +// and a return statement for ASSERT_DEATH_IF_SUPPORTED. +// This ensures that ASSERT_DEATH_IF_SUPPORTED will not +// compile inside functions where ASSERT_DEATH doesn't +// compile. +// +// The branch that has an always false condition is used to ensure that +// statement and regex are compiled (and thus syntactically correct) but +// never executed. The unreachable code macro protects the terminator +// statement from generating an 'unreachable code' warning in case +// statement unconditionally returns or throws. The Message constructor at +// the end allows the syntax of streaming additional messages into the +// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. +# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_LOG_(WARNING) \ + << "Death tests are not supported on this platform.\n" \ + << "Statement '" #statement "' cannot be verified."; \ + } else if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::RE::PartialMatch(".*", (regex)); \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + terminator; \ + } else \ + ::testing::Message() + +// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and +// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if +// death tests are supported; otherwise they just issue a warning. This is +// useful when you are combining death test assertions with normal test +// assertions in one test. +#if GTEST_HAS_DEATH_TEST +# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + EXPECT_DEATH(statement, regex) +# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + ASSERT_DEATH(statement, regex) +#else +# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, ) +# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return) +#endif + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ diff --git a/include/gtest/gtest-matchers.h b/include/gtest/gtest-matchers.h new file mode 100644 index 0000000..9de6c2e --- /dev/null +++ b/include/gtest/gtest-matchers.h @@ -0,0 +1,750 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This file implements just enough of the matcher interface to allow +// EXPECT_DEATH and friends to accept a matcher argument. + +// IWYU pragma: private, include "testing/base/public/gunit.h" +// IWYU pragma: friend third_party/googletest/googlemock/.* +// IWYU pragma: friend third_party/googletest/googletest/.* + +#ifndef GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ +#define GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ + +#include +#include +#include +#include + +#include "gtest/gtest-printers.h" +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-port.h" + +// MSVC warning C5046 is new as of VS2017 version 15.8. +#if defined(_MSC_VER) && _MSC_VER >= 1915 +#define GTEST_MAYBE_5046_ 5046 +#else +#define GTEST_MAYBE_5046_ +#endif + +GTEST_DISABLE_MSC_WARNINGS_PUSH_( + 4251 GTEST_MAYBE_5046_ /* class A needs to have dll-interface to be used by + clients of class B */ + /* Symbol involving type with internal linkage not defined */) + +namespace testing { + +// To implement a matcher Foo for type T, define: +// 1. a class FooMatcherImpl that implements the +// MatcherInterface interface, and +// 2. a factory function that creates a Matcher object from a +// FooMatcherImpl*. +// +// The two-level delegation design makes it possible to allow a user +// to write "v" instead of "Eq(v)" where a Matcher is expected, which +// is impossible if we pass matchers by pointers. It also eases +// ownership management as Matcher objects can now be copied like +// plain values. + +// MatchResultListener is an abstract class. Its << operator can be +// used by a matcher to explain why a value matches or doesn't match. +// +class MatchResultListener { + public: + // Creates a listener object with the given underlying ostream. The + // listener does not own the ostream, and does not dereference it + // in the constructor or destructor. + explicit MatchResultListener(::std::ostream* os) : stream_(os) {} + virtual ~MatchResultListener() = 0; // Makes this class abstract. + + // Streams x to the underlying ostream; does nothing if the ostream + // is NULL. + template + MatchResultListener& operator<<(const T& x) { + if (stream_ != nullptr) *stream_ << x; + return *this; + } + + // Returns the underlying ostream. + ::std::ostream* stream() { return stream_; } + + // Returns true if and only if the listener is interested in an explanation + // of the match result. A matcher's MatchAndExplain() method can use + // this information to avoid generating the explanation when no one + // intends to hear it. + bool IsInterested() const { return stream_ != nullptr; } + + private: + ::std::ostream* const stream_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener); +}; + +inline MatchResultListener::~MatchResultListener() { +} + +// An instance of a subclass of this knows how to describe itself as a +// matcher. +class MatcherDescriberInterface { + public: + virtual ~MatcherDescriberInterface() {} + + // Describes this matcher to an ostream. The function should print + // a verb phrase that describes the property a value matching this + // matcher should have. The subject of the verb phrase is the value + // being matched. For example, the DescribeTo() method of the Gt(7) + // matcher prints "is greater than 7". + virtual void DescribeTo(::std::ostream* os) const = 0; + + // Describes the negation of this matcher to an ostream. For + // example, if the description of this matcher is "is greater than + // 7", the negated description could be "is not greater than 7". + // You are not required to override this when implementing + // MatcherInterface, but it is highly advised so that your matcher + // can produce good error messages. + virtual void DescribeNegationTo(::std::ostream* os) const { + *os << "not ("; + DescribeTo(os); + *os << ")"; + } +}; + +// The implementation of a matcher. +template +class MatcherInterface : public MatcherDescriberInterface { + public: + // Returns true if and only if the matcher matches x; also explains the + // match result to 'listener' if necessary (see the next paragraph), in + // the form of a non-restrictive relative clause ("which ...", + // "whose ...", etc) that describes x. For example, the + // MatchAndExplain() method of the Pointee(...) matcher should + // generate an explanation like "which points to ...". + // + // Implementations of MatchAndExplain() should add an explanation of + // the match result *if and only if* they can provide additional + // information that's not already present (or not obvious) in the + // print-out of x and the matcher's description. Whether the match + // succeeds is not a factor in deciding whether an explanation is + // needed, as sometimes the caller needs to print a failure message + // when the match succeeds (e.g. when the matcher is used inside + // Not()). + // + // For example, a "has at least 10 elements" matcher should explain + // what the actual element count is, regardless of the match result, + // as it is useful information to the reader; on the other hand, an + // "is empty" matcher probably only needs to explain what the actual + // size is when the match fails, as it's redundant to say that the + // size is 0 when the value is already known to be empty. + // + // You should override this method when defining a new matcher. + // + // It's the responsibility of the caller (Google Test) to guarantee + // that 'listener' is not NULL. This helps to simplify a matcher's + // implementation when it doesn't care about the performance, as it + // can talk to 'listener' without checking its validity first. + // However, in order to implement dummy listeners efficiently, + // listener->stream() may be NULL. + virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0; + + // Inherits these methods from MatcherDescriberInterface: + // virtual void DescribeTo(::std::ostream* os) const = 0; + // virtual void DescribeNegationTo(::std::ostream* os) const; +}; + +namespace internal { + +// Converts a MatcherInterface to a MatcherInterface. +template +class MatcherInterfaceAdapter : public MatcherInterface { + public: + explicit MatcherInterfaceAdapter(const MatcherInterface* impl) + : impl_(impl) {} + ~MatcherInterfaceAdapter() override { delete impl_; } + + void DescribeTo(::std::ostream* os) const override { impl_->DescribeTo(os); } + + void DescribeNegationTo(::std::ostream* os) const override { + impl_->DescribeNegationTo(os); + } + + bool MatchAndExplain(const T& x, + MatchResultListener* listener) const override { + return impl_->MatchAndExplain(x, listener); + } + + private: + const MatcherInterface* const impl_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(MatcherInterfaceAdapter); +}; + +struct AnyEq { + template + bool operator()(const A& a, const B& b) const { return a == b; } +}; +struct AnyNe { + template + bool operator()(const A& a, const B& b) const { return a != b; } +}; +struct AnyLt { + template + bool operator()(const A& a, const B& b) const { return a < b; } +}; +struct AnyGt { + template + bool operator()(const A& a, const B& b) const { return a > b; } +}; +struct AnyLe { + template + bool operator()(const A& a, const B& b) const { return a <= b; } +}; +struct AnyGe { + template + bool operator()(const A& a, const B& b) const { return a >= b; } +}; + +// A match result listener that ignores the explanation. +class DummyMatchResultListener : public MatchResultListener { + public: + DummyMatchResultListener() : MatchResultListener(nullptr) {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener); +}; + +// A match result listener that forwards the explanation to a given +// ostream. The difference between this and MatchResultListener is +// that the former is concrete. +class StreamMatchResultListener : public MatchResultListener { + public: + explicit StreamMatchResultListener(::std::ostream* os) + : MatchResultListener(os) {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener); +}; + +// An internal class for implementing Matcher, which will derive +// from it. We put functionalities common to all Matcher +// specializations here to avoid code duplication. +template +class MatcherBase { + public: + // Returns true if and only if the matcher matches x; also explains the + // match result to 'listener'. + bool MatchAndExplain(const T& x, MatchResultListener* listener) const { + return impl_->MatchAndExplain(x, listener); + } + + // Returns true if and only if this matcher matches x. + bool Matches(const T& x) const { + DummyMatchResultListener dummy; + return MatchAndExplain(x, &dummy); + } + + // Describes this matcher to an ostream. + void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } + + // Describes the negation of this matcher to an ostream. + void DescribeNegationTo(::std::ostream* os) const { + impl_->DescribeNegationTo(os); + } + + // Explains why x matches, or doesn't match, the matcher. + void ExplainMatchResultTo(const T& x, ::std::ostream* os) const { + StreamMatchResultListener listener(os); + MatchAndExplain(x, &listener); + } + + // Returns the describer for this matcher object; retains ownership + // of the describer, which is only guaranteed to be alive when + // this matcher object is alive. + const MatcherDescriberInterface* GetDescriber() const { + return impl_.get(); + } + + protected: + MatcherBase() {} + + // Constructs a matcher from its implementation. + explicit MatcherBase(const MatcherInterface* impl) : impl_(impl) {} + + template + explicit MatcherBase( + const MatcherInterface* impl, + typename std::enable_if::value>::type* = + nullptr) + : impl_(new internal::MatcherInterfaceAdapter(impl)) {} + + MatcherBase(const MatcherBase&) = default; + MatcherBase& operator=(const MatcherBase&) = default; + MatcherBase(MatcherBase&&) = default; + MatcherBase& operator=(MatcherBase&&) = default; + + virtual ~MatcherBase() {} + + private: + std::shared_ptr> impl_; +}; + +} // namespace internal + +// A Matcher is a copyable and IMMUTABLE (except by assignment) +// object that can check whether a value of type T matches. The +// implementation of Matcher is just a std::shared_ptr to const +// MatcherInterface. Don't inherit from Matcher! +template +class Matcher : public internal::MatcherBase { + public: + // Constructs a null matcher. Needed for storing Matcher objects in STL + // containers. A default-constructed matcher is not yet initialized. You + // cannot use it until a valid value has been assigned to it. + explicit Matcher() {} // NOLINT + + // Constructs a matcher from its implementation. + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + + template + explicit Matcher( + const MatcherInterface* impl, + typename std::enable_if::value>::type* = + nullptr) + : internal::MatcherBase(impl) {} + + // Implicit constructor here allows people to write + // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes + Matcher(T value); // NOLINT +}; + +// The following two specializations allow the user to write str +// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string +// matcher is expected. +template <> +class GTEST_API_ Matcher + : public internal::MatcherBase { + public: + Matcher() {} + + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + + // Allows the user to write str instead of Eq(str) sometimes, where + // str is a std::string object. + Matcher(const std::string& s); // NOLINT + + // Allows the user to write "foo" instead of Eq("foo") sometimes. + Matcher(const char* s); // NOLINT +}; + +template <> +class GTEST_API_ Matcher + : public internal::MatcherBase { + public: + Matcher() {} + + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + + // Allows the user to write str instead of Eq(str) sometimes, where + // str is a string object. + Matcher(const std::string& s); // NOLINT + + // Allows the user to write "foo" instead of Eq("foo") sometimes. + Matcher(const char* s); // NOLINT +}; + +#if GTEST_HAS_ABSL +// The following two specializations allow the user to write str +// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view +// matcher is expected. +template <> +class GTEST_API_ Matcher + : public internal::MatcherBase { + public: + Matcher() {} + + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + + // Allows the user to write str instead of Eq(str) sometimes, where + // str is a std::string object. + Matcher(const std::string& s); // NOLINT + + // Allows the user to write "foo" instead of Eq("foo") sometimes. + Matcher(const char* s); // NOLINT + + // Allows the user to pass absl::string_views directly. + Matcher(absl::string_view s); // NOLINT +}; + +template <> +class GTEST_API_ Matcher + : public internal::MatcherBase { + public: + Matcher() {} + + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + explicit Matcher(const MatcherInterface* impl) + : internal::MatcherBase(impl) {} + + // Allows the user to write str instead of Eq(str) sometimes, where + // str is a std::string object. + Matcher(const std::string& s); // NOLINT + + // Allows the user to write "foo" instead of Eq("foo") sometimes. + Matcher(const char* s); // NOLINT + + // Allows the user to pass absl::string_views directly. + Matcher(absl::string_view s); // NOLINT +}; +#endif // GTEST_HAS_ABSL + +// Prints a matcher in a human-readable format. +template +std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { + matcher.DescribeTo(&os); + return os; +} + +// The PolymorphicMatcher class template makes it easy to implement a +// polymorphic matcher (i.e. a matcher that can match values of more +// than one type, e.g. Eq(n) and NotNull()). +// +// To define a polymorphic matcher, a user should provide an Impl +// class that has a DescribeTo() method and a DescribeNegationTo() +// method, and define a member function (or member function template) +// +// bool MatchAndExplain(const Value& value, +// MatchResultListener* listener) const; +// +// See the definition of NotNull() for a complete example. +template +class PolymorphicMatcher { + public: + explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} + + // Returns a mutable reference to the underlying matcher + // implementation object. + Impl& mutable_impl() { return impl_; } + + // Returns an immutable reference to the underlying matcher + // implementation object. + const Impl& impl() const { return impl_; } + + template + operator Matcher() const { + return Matcher(new MonomorphicImpl(impl_)); + } + + private: + template + class MonomorphicImpl : public MatcherInterface { + public: + explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} + + virtual void DescribeTo(::std::ostream* os) const { impl_.DescribeTo(os); } + + virtual void DescribeNegationTo(::std::ostream* os) const { + impl_.DescribeNegationTo(os); + } + + virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { + return impl_.MatchAndExplain(x, listener); + } + + private: + const Impl impl_; + }; + + Impl impl_; +}; + +// Creates a matcher from its implementation. +// DEPRECATED: Especially in the generic code, prefer: +// Matcher(new MyMatcherImpl(...)); +// +// MakeMatcher may create a Matcher that accepts its argument by value, which +// leads to unnecessary copies & lack of support for non-copyable types. +template +inline Matcher MakeMatcher(const MatcherInterface* impl) { + return Matcher(impl); +} + +// Creates a polymorphic matcher from its implementation. This is +// easier to use than the PolymorphicMatcher constructor as it +// doesn't require you to explicitly write the template argument, e.g. +// +// MakePolymorphicMatcher(foo); +// vs +// PolymorphicMatcher(foo); +template +inline PolymorphicMatcher MakePolymorphicMatcher(const Impl& impl) { + return PolymorphicMatcher(impl); +} + +namespace internal { +// Implements a matcher that compares a given value with a +// pre-supplied value using one of the ==, <=, <, etc, operators. The +// two values being compared don't have to have the same type. +// +// The matcher defined here is polymorphic (for example, Eq(5) can be +// used to match an int, a short, a double, etc). Therefore we use +// a template type conversion operator in the implementation. +// +// The following template definition assumes that the Rhs parameter is +// a "bare" type (i.e. neither 'const T' nor 'T&'). +template +class ComparisonBase { + public: + explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} + template + operator Matcher() const { + return Matcher(new Impl(rhs_)); + } + + private: + template + static const T& Unwrap(const T& v) { return v; } + template + static const T& Unwrap(std::reference_wrapper v) { return v; } + + template + class Impl : public MatcherInterface { + public: + explicit Impl(const Rhs& rhs) : rhs_(rhs) {} + bool MatchAndExplain(Lhs lhs, + MatchResultListener* /* listener */) const override { + return Op()(lhs, Unwrap(rhs_)); + } + void DescribeTo(::std::ostream* os) const override { + *os << D::Desc() << " "; + UniversalPrint(Unwrap(rhs_), os); + } + void DescribeNegationTo(::std::ostream* os) const override { + *os << D::NegatedDesc() << " "; + UniversalPrint(Unwrap(rhs_), os); + } + + private: + Rhs rhs_; + }; + Rhs rhs_; +}; + +template +class EqMatcher : public ComparisonBase, Rhs, AnyEq> { + public: + explicit EqMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyEq>(rhs) { } + static const char* Desc() { return "is equal to"; } + static const char* NegatedDesc() { return "isn't equal to"; } +}; +template +class NeMatcher : public ComparisonBase, Rhs, AnyNe> { + public: + explicit NeMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyNe>(rhs) { } + static const char* Desc() { return "isn't equal to"; } + static const char* NegatedDesc() { return "is equal to"; } +}; +template +class LtMatcher : public ComparisonBase, Rhs, AnyLt> { + public: + explicit LtMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyLt>(rhs) { } + static const char* Desc() { return "is <"; } + static const char* NegatedDesc() { return "isn't <"; } +}; +template +class GtMatcher : public ComparisonBase, Rhs, AnyGt> { + public: + explicit GtMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyGt>(rhs) { } + static const char* Desc() { return "is >"; } + static const char* NegatedDesc() { return "isn't >"; } +}; +template +class LeMatcher : public ComparisonBase, Rhs, AnyLe> { + public: + explicit LeMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyLe>(rhs) { } + static const char* Desc() { return "is <="; } + static const char* NegatedDesc() { return "isn't <="; } +}; +template +class GeMatcher : public ComparisonBase, Rhs, AnyGe> { + public: + explicit GeMatcher(const Rhs& rhs) + : ComparisonBase, Rhs, AnyGe>(rhs) { } + static const char* Desc() { return "is >="; } + static const char* NegatedDesc() { return "isn't >="; } +}; + +// Implements polymorphic matchers MatchesRegex(regex) and +// ContainsRegex(regex), which can be used as a Matcher as long as +// T can be converted to a string. +class MatchesRegexMatcher { + public: + MatchesRegexMatcher(const RE* regex, bool full_match) + : regex_(regex), full_match_(full_match) {} + +#if GTEST_HAS_ABSL + bool MatchAndExplain(const absl::string_view& s, + MatchResultListener* listener) const { + return MatchAndExplain(std::string(s), listener); + } +#endif // GTEST_HAS_ABSL + + // Accepts pointer types, particularly: + // const char* + // char* + // const wchar_t* + // wchar_t* + template + bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { + return s != nullptr && MatchAndExplain(std::string(s), listener); + } + + // Matches anything that can convert to std::string. + // + // This is a template, not just a plain function with const std::string&, + // because absl::string_view has some interfering non-explicit constructors. + template + bool MatchAndExplain(const MatcheeStringType& s, + MatchResultListener* /* listener */) const { + const std::string& s2(s); + return full_match_ ? RE::FullMatch(s2, *regex_) + : RE::PartialMatch(s2, *regex_); + } + + void DescribeTo(::std::ostream* os) const { + *os << (full_match_ ? "matches" : "contains") << " regular expression "; + UniversalPrinter::Print(regex_->pattern(), os); + } + + void DescribeNegationTo(::std::ostream* os) const { + *os << "doesn't " << (full_match_ ? "match" : "contain") + << " regular expression "; + UniversalPrinter::Print(regex_->pattern(), os); + } + + private: + const std::shared_ptr regex_; + const bool full_match_; +}; +} // namespace internal + +// Matches a string that fully matches regular expression 'regex'. +// The matcher takes ownership of 'regex'. +inline PolymorphicMatcher MatchesRegex( + const internal::RE* regex) { + return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true)); +} +inline PolymorphicMatcher MatchesRegex( + const std::string& regex) { + return MatchesRegex(new internal::RE(regex)); +} + +// Matches a string that contains regular expression 'regex'. +// The matcher takes ownership of 'regex'. +inline PolymorphicMatcher ContainsRegex( + const internal::RE* regex) { + return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false)); +} +inline PolymorphicMatcher ContainsRegex( + const std::string& regex) { + return ContainsRegex(new internal::RE(regex)); +} + +// Creates a polymorphic matcher that matches anything equal to x. +// Note: if the parameter of Eq() were declared as const T&, Eq("foo") +// wouldn't compile. +template +inline internal::EqMatcher Eq(T x) { return internal::EqMatcher(x); } + +// Constructs a Matcher from a 'value' of type T. The constructed +// matcher matches any value that's equal to 'value'. +template +Matcher::Matcher(T value) { *this = Eq(value); } + +// Creates a monomorphic matcher that matches anything with type Lhs +// and equal to rhs. A user may need to use this instead of Eq(...) +// in order to resolve an overloading ambiguity. +// +// TypedEq(x) is just a convenient short-hand for Matcher(Eq(x)) +// or Matcher(x), but more readable than the latter. +// +// We could define similar monomorphic matchers for other comparison +// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do +// it yet as those are used much less than Eq() in practice. A user +// can always write Matcher(Lt(5)) to be explicit about the type, +// for example. +template +inline Matcher TypedEq(const Rhs& rhs) { return Eq(rhs); } + +// Creates a polymorphic matcher that matches anything >= x. +template +inline internal::GeMatcher Ge(Rhs x) { + return internal::GeMatcher(x); +} + +// Creates a polymorphic matcher that matches anything > x. +template +inline internal::GtMatcher Gt(Rhs x) { + return internal::GtMatcher(x); +} + +// Creates a polymorphic matcher that matches anything <= x. +template +inline internal::LeMatcher Le(Rhs x) { + return internal::LeMatcher(x); +} + +// Creates a polymorphic matcher that matches anything < x. +template +inline internal::LtMatcher Lt(Rhs x) { + return internal::LtMatcher(x); +} + +// Creates a polymorphic matcher that matches anything != x. +template +inline internal::NeMatcher Ne(Rhs x) { + return internal::NeMatcher(x); +} +} // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 5046 + +#endif // GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ diff --git a/include/gtest/gtest-message.h b/include/gtest/gtest-message.h new file mode 100644 index 0000000..4a80e11 --- /dev/null +++ b/include/gtest/gtest-message.h @@ -0,0 +1,218 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines the Message class. +// +// IMPORTANT NOTE: Due to limitation of the C++ language, we have to +// leave some internal implementation details in this header file. +// They are clearly marked by comments like this: +// +// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +// +// Such code is NOT meant to be used by a user directly, and is subject +// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user +// program! + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ +#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ + +#include +#include + +#include "gtest/internal/gtest-port.h" + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +// Ensures that there is at least one operator<< in the global namespace. +// See Message& operator<<(...) below for why. +void operator<<(const testing::internal::Secret&, int); + +namespace testing { + +// The Message class works like an ostream repeater. +// +// Typical usage: +// +// 1. You stream a bunch of values to a Message object. +// It will remember the text in a stringstream. +// 2. Then you stream the Message object to an ostream. +// This causes the text in the Message to be streamed +// to the ostream. +// +// For example; +// +// testing::Message foo; +// foo << 1 << " != " << 2; +// std::cout << foo; +// +// will print "1 != 2". +// +// Message is not intended to be inherited from. In particular, its +// destructor is not virtual. +// +// Note that stringstream behaves differently in gcc and in MSVC. You +// can stream a NULL char pointer to it in the former, but not in the +// latter (it causes an access violation if you do). The Message +// class hides this difference by treating a NULL char pointer as +// "(null)". +class GTEST_API_ Message { + private: + // The type of basic IO manipulators (endl, ends, and flush) for + // narrow streams. + typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&); + + public: + // Constructs an empty Message. + Message(); + + // Copy constructor. + Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT + *ss_ << msg.GetString(); + } + + // Constructs a Message from a C-string. + explicit Message(const char* str) : ss_(new ::std::stringstream) { + *ss_ << str; + } + + // Streams a non-pointer value to this object. + template + inline Message& operator <<(const T& val) { + // Some libraries overload << for STL containers. These + // overloads are defined in the global namespace instead of ::std. + // + // C++'s symbol lookup rule (i.e. Koenig lookup) says that these + // overloads are visible in either the std namespace or the global + // namespace, but not other namespaces, including the testing + // namespace which Google Test's Message class is in. + // + // To allow STL containers (and other types that has a << operator + // defined in the global namespace) to be used in Google Test + // assertions, testing::Message must access the custom << operator + // from the global namespace. With this using declaration, + // overloads of << defined in the global namespace and those + // visible via Koenig lookup are both exposed in this function. + using ::operator <<; + *ss_ << val; + return *this; + } + + // Streams a pointer value to this object. + // + // This function is an overload of the previous one. When you + // stream a pointer to a Message, this definition will be used as it + // is more specialized. (The C++ Standard, section + // [temp.func.order].) If you stream a non-pointer, then the + // previous definition will be used. + // + // The reason for this overload is that streaming a NULL pointer to + // ostream is undefined behavior. Depending on the compiler, you + // may get "0", "(nil)", "(null)", or an access violation. To + // ensure consistent result across compilers, we always treat NULL + // as "(null)". + template + inline Message& operator <<(T* const& pointer) { // NOLINT + if (pointer == nullptr) { + *ss_ << "(null)"; + } else { + *ss_ << pointer; + } + return *this; + } + + // Since the basic IO manipulators are overloaded for both narrow + // and wide streams, we have to provide this specialized definition + // of operator <<, even though its body is the same as the + // templatized version above. Without this definition, streaming + // endl or other basic IO manipulators to Message will confuse the + // compiler. + Message& operator <<(BasicNarrowIoManip val) { + *ss_ << val; + return *this; + } + + // Instead of 1/0, we want to see true/false for bool values. + Message& operator <<(bool b) { + return *this << (b ? "true" : "false"); + } + + // These two overloads allow streaming a wide C string to a Message + // using the UTF-8 encoding. + Message& operator <<(const wchar_t* wide_c_str); + Message& operator <<(wchar_t* wide_c_str); + +#if GTEST_HAS_STD_WSTRING + // Converts the given wide string to a narrow string using the UTF-8 + // encoding, and streams the result to this Message object. + Message& operator <<(const ::std::wstring& wstr); +#endif // GTEST_HAS_STD_WSTRING + + // Gets the text streamed to this object so far as an std::string. + // Each '\0' character in the buffer is replaced with "\\0". + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + std::string GetString() const; + + private: + // We'll hold the text streamed to this object here. + const std::unique_ptr< ::std::stringstream> ss_; + + // We declare (but don't implement) this to prevent the compiler + // from implementing the assignment operator. + void operator=(const Message&); +}; + +// Streams a Message to an ostream. +inline std::ostream& operator <<(std::ostream& os, const Message& sb) { + return os << sb.GetString(); +} + +namespace internal { + +// Converts a streamable value to an std::string. A NULL pointer is +// converted to "(null)". When the input value is a ::string, +// ::std::string, ::wstring, or ::std::wstring object, each NUL +// character in it is replaced with "\\0". +template +std::string StreamableToString(const T& streamable) { + return (Message() << streamable).GetString(); +} + +} // namespace internal +} // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ diff --git a/include/gtest/gtest-param-test.h b/include/gtest/gtest-param-test.h new file mode 100644 index 0000000..c2e6eae --- /dev/null +++ b/include/gtest/gtest-param-test.h @@ -0,0 +1,503 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Macros and functions for implementing parameterized tests +// in Google C++ Testing and Mocking Framework (Google Test) +// +// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// GOOGLETEST_CM0001 DO NOT DELETE +#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ + + +// Value-parameterized tests allow you to test your code with different +// parameters without writing multiple copies of the same test. +// +// Here is how you use value-parameterized tests: + +#if 0 + +// To write value-parameterized tests, first you should define a fixture +// class. It is usually derived from testing::TestWithParam (see below for +// another inheritance scheme that's sometimes useful in more complicated +// class hierarchies), where the type of your parameter values. +// TestWithParam is itself derived from testing::Test. T can be any +// copyable type. If it's a raw pointer, you are responsible for managing the +// lifespan of the pointed values. + +class FooTest : public ::testing::TestWithParam { + // You can implement all the usual class fixture members here. +}; + +// Then, use the TEST_P macro to define as many parameterized tests +// for this fixture as you want. The _P suffix is for "parameterized" +// or "pattern", whichever you prefer to think. + +TEST_P(FooTest, DoesBlah) { + // Inside a test, access the test parameter with the GetParam() method + // of the TestWithParam class: + EXPECT_TRUE(foo.Blah(GetParam())); + ... +} + +TEST_P(FooTest, HasBlahBlah) { + ... +} + +// Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test +// case with any set of parameters you want. Google Test defines a number +// of functions for generating test parameters. They return what we call +// (surprise!) parameter generators. Here is a summary of them, which +// are all in the testing namespace: +// +// +// Range(begin, end [, step]) - Yields values {begin, begin+step, +// begin+step+step, ...}. The values do not +// include end. step defaults to 1. +// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}. +// ValuesIn(container) - Yields values from a C-style array, an STL +// ValuesIn(begin,end) container, or an iterator range [begin, end). +// Bool() - Yields sequence {false, true}. +// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product +// for the math savvy) of the values generated +// by the N generators. +// +// For more details, see comments at the definitions of these functions below +// in this file. +// +// The following statement will instantiate tests from the FooTest test suite +// each with parameter values "meeny", "miny", and "moe". + +INSTANTIATE_TEST_SUITE_P(InstantiationName, + FooTest, + Values("meeny", "miny", "moe")); + +// To distinguish different instances of the pattern, (yes, you +// can instantiate it more than once) the first argument to the +// INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the +// actual test suite name. Remember to pick unique prefixes for different +// instantiations. The tests from the instantiation above will have +// these names: +// +// * InstantiationName/FooTest.DoesBlah/0 for "meeny" +// * InstantiationName/FooTest.DoesBlah/1 for "miny" +// * InstantiationName/FooTest.DoesBlah/2 for "moe" +// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny" +// * InstantiationName/FooTest.HasBlahBlah/1 for "miny" +// * InstantiationName/FooTest.HasBlahBlah/2 for "moe" +// +// You can use these names in --gtest_filter. +// +// This statement will instantiate all tests from FooTest again, each +// with parameter values "cat" and "dog": + +const char* pets[] = {"cat", "dog"}; +INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets)); + +// The tests from the instantiation above will have these names: +// +// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog" +// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog" +// +// Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests +// in the given test suite, whether their definitions come before or +// AFTER the INSTANTIATE_TEST_SUITE_P statement. +// +// Please also note that generator expressions (including parameters to the +// generators) are evaluated in InitGoogleTest(), after main() has started. +// This allows the user on one hand, to adjust generator parameters in order +// to dynamically determine a set of tests to run and on the other hand, +// give the user a chance to inspect the generated tests with Google Test +// reflection API before RUN_ALL_TESTS() is executed. +// +// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc +// for more examples. +// +// In the future, we plan to publish the API for defining new parameter +// generators. But for now this interface remains part of the internal +// implementation and is subject to change. +// +// +// A parameterized test fixture must be derived from testing::Test and from +// testing::WithParamInterface, where T is the type of the parameter +// values. Inheriting from TestWithParam satisfies that requirement because +// TestWithParam inherits from both Test and WithParamInterface. In more +// complicated hierarchies, however, it is occasionally useful to inherit +// separately from Test and WithParamInterface. For example: + +class BaseTest : public ::testing::Test { + // You can inherit all the usual members for a non-parameterized test + // fixture here. +}; + +class DerivedTest : public BaseTest, public ::testing::WithParamInterface { + // The usual test fixture members go here too. +}; + +TEST_F(BaseTest, HasFoo) { + // This is an ordinary non-parameterized test. +} + +TEST_P(DerivedTest, DoesBlah) { + // GetParam works just the same here as if you inherit from TestWithParam. + EXPECT_TRUE(foo.Blah(GetParam())); +} + +#endif // 0 + +#include +#include + +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-param-util.h" +#include "gtest/internal/gtest-port.h" + +namespace testing { + +// Functions producing parameter generators. +// +// Google Test uses these generators to produce parameters for value- +// parameterized tests. When a parameterized test suite is instantiated +// with a particular generator, Google Test creates and runs tests +// for each element in the sequence produced by the generator. +// +// In the following sample, tests from test suite FooTest are instantiated +// each three times with parameter values 3, 5, and 8: +// +// class FooTest : public TestWithParam { ... }; +// +// TEST_P(FooTest, TestThis) { +// } +// TEST_P(FooTest, TestThat) { +// } +// INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8)); +// + +// Range() returns generators providing sequences of values in a range. +// +// Synopsis: +// Range(start, end) +// - returns a generator producing a sequence of values {start, start+1, +// start+2, ..., }. +// Range(start, end, step) +// - returns a generator producing a sequence of values {start, start+step, +// start+step+step, ..., }. +// Notes: +// * The generated sequences never include end. For example, Range(1, 5) +// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2) +// returns a generator producing {1, 3, 5, 7}. +// * start and end must have the same type. That type may be any integral or +// floating-point type or a user defined type satisfying these conditions: +// * It must be assignable (have operator=() defined). +// * It must have operator+() (operator+(int-compatible type) for +// two-operand version). +// * It must have operator<() defined. +// Elements in the resulting sequences will also have that type. +// * Condition start < end must be satisfied in order for resulting sequences +// to contain any elements. +// +template +internal::ParamGenerator Range(T start, T end, IncrementT step) { + return internal::ParamGenerator( + new internal::RangeGenerator(start, end, step)); +} + +template +internal::ParamGenerator Range(T start, T end) { + return Range(start, end, 1); +} + +// ValuesIn() function allows generation of tests with parameters coming from +// a container. +// +// Synopsis: +// ValuesIn(const T (&array)[N]) +// - returns a generator producing sequences with elements from +// a C-style array. +// ValuesIn(const Container& container) +// - returns a generator producing sequences with elements from +// an STL-style container. +// ValuesIn(Iterator begin, Iterator end) +// - returns a generator producing sequences with elements from +// a range [begin, end) defined by a pair of STL-style iterators. These +// iterators can also be plain C pointers. +// +// Please note that ValuesIn copies the values from the containers +// passed in and keeps them to generate tests in RUN_ALL_TESTS(). +// +// Examples: +// +// This instantiates tests from test suite StringTest +// each with C-string values of "foo", "bar", and "baz": +// +// const char* strings[] = {"foo", "bar", "baz"}; +// INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings)); +// +// This instantiates tests from test suite StlStringTest +// each with STL strings with values "a" and "b": +// +// ::std::vector< ::std::string> GetParameterStrings() { +// ::std::vector< ::std::string> v; +// v.push_back("a"); +// v.push_back("b"); +// return v; +// } +// +// INSTANTIATE_TEST_SUITE_P(CharSequence, +// StlStringTest, +// ValuesIn(GetParameterStrings())); +// +// +// This will also instantiate tests from CharTest +// each with parameter values 'a' and 'b': +// +// ::std::list GetParameterChars() { +// ::std::list list; +// list.push_back('a'); +// list.push_back('b'); +// return list; +// } +// ::std::list l = GetParameterChars(); +// INSTANTIATE_TEST_SUITE_P(CharSequence2, +// CharTest, +// ValuesIn(l.begin(), l.end())); +// +template +internal::ParamGenerator< + typename std::iterator_traits::value_type> +ValuesIn(ForwardIterator begin, ForwardIterator end) { + typedef typename std::iterator_traits::value_type ParamType; + return internal::ParamGenerator( + new internal::ValuesInIteratorRangeGenerator(begin, end)); +} + +template +internal::ParamGenerator ValuesIn(const T (&array)[N]) { + return ValuesIn(array, array + N); +} + +template +internal::ParamGenerator ValuesIn( + const Container& container) { + return ValuesIn(container.begin(), container.end()); +} + +// Values() allows generating tests from explicitly specified list of +// parameters. +// +// Synopsis: +// Values(T v1, T v2, ..., T vN) +// - returns a generator producing sequences with elements v1, v2, ..., vN. +// +// For example, this instantiates tests from test suite BarTest each +// with values "one", "two", and "three": +// +// INSTANTIATE_TEST_SUITE_P(NumSequence, +// BarTest, +// Values("one", "two", "three")); +// +// This instantiates tests from test suite BazTest each with values 1, 2, 3.5. +// The exact type of values will depend on the type of parameter in BazTest. +// +// INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5)); +// +// +template +internal::ValueArray Values(T... v) { + return internal::ValueArray(std::move(v)...); +} + +// Bool() allows generating tests with parameters in a set of (false, true). +// +// Synopsis: +// Bool() +// - returns a generator producing sequences with elements {false, true}. +// +// It is useful when testing code that depends on Boolean flags. Combinations +// of multiple flags can be tested when several Bool()'s are combined using +// Combine() function. +// +// In the following example all tests in the test suite FlagDependentTest +// will be instantiated twice with parameters false and true. +// +// class FlagDependentTest : public testing::TestWithParam { +// virtual void SetUp() { +// external_flag = GetParam(); +// } +// } +// INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool()); +// +inline internal::ParamGenerator Bool() { + return Values(false, true); +} + +// Combine() allows the user to combine two or more sequences to produce +// values of a Cartesian product of those sequences' elements. +// +// Synopsis: +// Combine(gen1, gen2, ..., genN) +// - returns a generator producing sequences with elements coming from +// the Cartesian product of elements from the sequences generated by +// gen1, gen2, ..., genN. The sequence elements will have a type of +// std::tuple where T1, T2, ..., TN are the types +// of elements from sequences produces by gen1, gen2, ..., genN. +// +// Combine can have up to 10 arguments. +// +// Example: +// +// This will instantiate tests in test suite AnimalTest each one with +// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), +// tuple("dog", BLACK), and tuple("dog", WHITE): +// +// enum Color { BLACK, GRAY, WHITE }; +// class AnimalTest +// : public testing::TestWithParam > {...}; +// +// TEST_P(AnimalTest, AnimalLooksNice) {...} +// +// INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest, +// Combine(Values("cat", "dog"), +// Values(BLACK, WHITE))); +// +// This will instantiate tests in FlagDependentTest with all variations of two +// Boolean flags: +// +// class FlagDependentTest +// : public testing::TestWithParam > { +// virtual void SetUp() { +// // Assigns external_flag_1 and external_flag_2 values from the tuple. +// std::tie(external_flag_1, external_flag_2) = GetParam(); +// } +// }; +// +// TEST_P(FlagDependentTest, TestFeature1) { +// // Test your code using external_flag_1 and external_flag_2 here. +// } +// INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest, +// Combine(Bool(), Bool())); +// +template +internal::CartesianProductHolder Combine(const Generator&... g) { + return internal::CartesianProductHolder(g...); +} + +#define TEST_P(test_suite_name, test_name) \ + class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + : public test_suite_name { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ + virtual void TestBody(); \ + \ + private: \ + static int AddToRegistry() { \ + ::testing::UnitTest::GetInstance() \ + ->parameterized_test_registry() \ + .GetTestSuitePatternHolder( \ + #test_suite_name, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ + ->AddTestPattern( \ + GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \ + new ::testing::internal::TestMetaFactory()); \ + return 0; \ + } \ + static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name)); \ + }; \ + int GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name)::gtest_registering_dummy_ = \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \ + void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() + +// The last argument to INSTANTIATE_TEST_SUITE_P allows the user to specify +// generator and an optional function or functor that generates custom test name +// suffixes based on the test parameters. Such a function or functor should +// accept one argument of type testing::TestParamInfo, and +// return std::string. +// +// testing::PrintToStringParamName is a builtin test suffix generator that +// returns the value of testing::PrintToString(GetParam()). +// +// Note: test names must be non-empty, unique, and may only contain ASCII +// alphanumeric characters or underscore. Because PrintToString adds quotes +// to std::string and C strings, it won't work for these types. + +#define GTEST_EXPAND_(arg) arg +#define GTEST_GET_FIRST_(first, ...) first +#define GTEST_GET_SECOND_(first, second, ...) second + +#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \ + static ::testing::internal::ParamGenerator \ + gtest_##prefix##test_suite_name##_EvalGenerator_() { \ + return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ + } \ + static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo& info) { \ + if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))); \ + auto t = std::make_tuple(__VA_ARGS__); \ + static_assert(std::tuple_size::value <= 2, \ + "Too Many Args!"); \ + } \ + return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))))(info); \ + } \ + static int gtest_##prefix##test_suite_name##_dummy_ \ + GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::UnitTest::GetInstance() \ + ->parameterized_test_registry() \ + .GetTestSuitePatternHolder( \ + #test_suite_name, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ + ->AddTestSuiteInstantiation( \ + #prefix, >est_##prefix##test_suite_name##_EvalGenerator_, \ + >est_##prefix##test_suite_name##_EvalGenerateName_, \ + __FILE__, __LINE__) + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +#define INSTANTIATE_TEST_CASE_P \ + static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \ + ""); \ + INSTANTIATE_TEST_SUITE_P +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ diff --git a/include/gtest/gtest-printers.h b/include/gtest/gtest-printers.h new file mode 100644 index 0000000..56a0545 --- /dev/null +++ b/include/gtest/gtest-printers.h @@ -0,0 +1,928 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// Google Test - The Google C++ Testing and Mocking Framework +// +// This file implements a universal value printer that can print a +// value of any type T: +// +// void ::testing::internal::UniversalPrinter::Print(value, ostream_ptr); +// +// A user can teach this function how to print a class type T by +// defining either operator<<() or PrintTo() in the namespace that +// defines T. More specifically, the FIRST defined function in the +// following list will be used (assuming T is defined in namespace +// foo): +// +// 1. foo::PrintTo(const T&, ostream*) +// 2. operator<<(ostream&, const T&) defined in either foo or the +// global namespace. +// +// However if T is an STL-style container then it is printed element-wise +// unless foo::PrintTo(const T&, ostream*) is defined. Note that +// operator<<() is ignored for container types. +// +// If none of the above is defined, it will print the debug string of +// the value if it is a protocol buffer, or print the raw bytes in the +// value otherwise. +// +// To aid debugging: when T is a reference type, the address of the +// value is also printed; when T is a (const) char pointer, both the +// pointer value and the NUL-terminated string it points to are +// printed. +// +// We also provide some convenient wrappers: +// +// // Prints a value to a string. For a (const or not) char +// // pointer, the NUL-terminated string (but not the pointer) is +// // printed. +// std::string ::testing::PrintToString(const T& value); +// +// // Prints a value tersely: for a reference type, the referenced +// // value (but not the address) is printed; for a (const or not) char +// // pointer, the NUL-terminated string (but not the pointer) is +// // printed. +// void ::testing::internal::UniversalTersePrint(const T& value, ostream*); +// +// // Prints value using the type inferred by the compiler. The difference +// // from UniversalTersePrint() is that this function prints both the +// // pointer and the NUL-terminated string for a (const or not) char pointer. +// void ::testing::internal::UniversalPrint(const T& value, ostream*); +// +// // Prints the fields of a tuple tersely to a string vector, one +// // element for each field. Tuple support must be enabled in +// // gtest-port.h. +// std::vector UniversalTersePrintTupleFieldsToStrings( +// const Tuple& value); +// +// Known limitation: +// +// The print primitives print the elements of an STL-style container +// using the compiler-inferred type of *iter where iter is a +// const_iterator of the container. When const_iterator is an input +// iterator but not a forward iterator, this inferred type may not +// match value_type, and the print output may be incorrect. In +// practice, this is rarely a problem as for most containers +// const_iterator is a forward iterator. We'll fix this if there's an +// actual need for it. Note that this fix cannot rely on value_type +// being defined as many user-defined container types don't have +// value_type. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ + +#include +#include // NOLINT +#include +#include +#include +#include +#include +#include +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-port.h" + +#if GTEST_HAS_ABSL +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "absl/types/variant.h" +#endif // GTEST_HAS_ABSL + +namespace testing { + +// Definitions in the 'internal' and 'internal2' name spaces are +// subject to change without notice. DO NOT USE THEM IN USER CODE! +namespace internal2 { + +// Prints the given number of bytes in the given object to the given +// ostream. +GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes, + size_t count, + ::std::ostream* os); + +// For selecting which printer to use when a given type has neither << +// nor PrintTo(). +enum TypeKind { + kProtobuf, // a protobuf type + kConvertibleToInteger, // a type implicitly convertible to BiggestInt + // (e.g. a named or unnamed enum type) +#if GTEST_HAS_ABSL + kConvertibleToStringView, // a type implicitly convertible to + // absl::string_view +#endif + kOtherType // anything else +}; + +// TypeWithoutFormatter::PrintValue(value, os) is called +// by the universal printer to print a value of type T when neither +// operator<< nor PrintTo() is defined for T, where kTypeKind is the +// "kind" of T as defined by enum TypeKind. +template +class TypeWithoutFormatter { + public: + // This default version is called when kTypeKind is kOtherType. + static void PrintValue(const T& value, ::std::ostream* os) { + PrintBytesInObjectTo( + static_cast( + reinterpret_cast(std::addressof(value))), + sizeof(value), os); + } +}; + +// We print a protobuf using its ShortDebugString() when the string +// doesn't exceed this many characters; otherwise we print it using +// DebugString() for better readability. +const size_t kProtobufOneLinerMaxLength = 50; + +template +class TypeWithoutFormatter { + public: + static void PrintValue(const T& value, ::std::ostream* os) { + std::string pretty_str = value.ShortDebugString(); + if (pretty_str.length() > kProtobufOneLinerMaxLength) { + pretty_str = "\n" + value.DebugString(); + } + *os << ("<" + pretty_str + ">"); + } +}; + +template +class TypeWithoutFormatter { + public: + // Since T has no << operator or PrintTo() but can be implicitly + // converted to BiggestInt, we print it as a BiggestInt. + // + // Most likely T is an enum type (either named or unnamed), in which + // case printing it as an integer is the desired behavior. In case + // T is not an enum, printing it as an integer is the best we can do + // given that it has no user-defined printer. + static void PrintValue(const T& value, ::std::ostream* os) { + const internal::BiggestInt kBigInt = value; + *os << kBigInt; + } +}; + +#if GTEST_HAS_ABSL +template +class TypeWithoutFormatter { + public: + // Since T has neither operator<< nor PrintTo() but can be implicitly + // converted to absl::string_view, we print it as a absl::string_view. + // + // Note: the implementation is further below, as it depends on + // internal::PrintTo symbol which is defined later in the file. + static void PrintValue(const T& value, ::std::ostream* os); +}; +#endif + +// Prints the given value to the given ostream. If the value is a +// protocol message, its debug string is printed; if it's an enum or +// of a type implicitly convertible to BiggestInt, it's printed as an +// integer; otherwise the bytes in the value are printed. This is +// what UniversalPrinter::Print() does when it knows nothing about +// type T and T has neither << operator nor PrintTo(). +// +// A user can override this behavior for a class type Foo by defining +// a << operator in the namespace where Foo is defined. +// +// We put this operator in namespace 'internal2' instead of 'internal' +// to simplify the implementation, as much code in 'internal' needs to +// use << in STL, which would conflict with our own << were it defined +// in 'internal'. +// +// Note that this operator<< takes a generic std::basic_ostream type instead of the more restricted std::ostream. If +// we define it to take an std::ostream instead, we'll get an +// "ambiguous overloads" compiler error when trying to print a type +// Foo that supports streaming to std::basic_ostream, as the compiler cannot tell whether +// operator<<(std::ostream&, const T&) or +// operator<<(std::basic_stream, const Foo&) is more +// specific. +template +::std::basic_ostream& operator<<( + ::std::basic_ostream& os, const T& x) { + TypeWithoutFormatter::value + ? kProtobuf + : std::is_convertible< + const T&, internal::BiggestInt>::value + ? kConvertibleToInteger + : +#if GTEST_HAS_ABSL + std::is_convertible< + const T&, absl::string_view>::value + ? kConvertibleToStringView + : +#endif + kOtherType)>::PrintValue(x, &os); + return os; +} + +} // namespace internal2 +} // namespace testing + +// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up +// magic needed for implementing UniversalPrinter won't work. +namespace testing_internal { + +// Used to print a value that is not an STL-style container when the +// user doesn't define PrintTo() for it. +template +void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) { + // With the following statement, during unqualified name lookup, + // testing::internal2::operator<< appears as if it was declared in + // the nearest enclosing namespace that contains both + // ::testing_internal and ::testing::internal2, i.e. the global + // namespace. For more details, refer to the C++ Standard section + // 7.3.4-1 [namespace.udir]. This allows us to fall back onto + // testing::internal2::operator<< in case T doesn't come with a << + // operator. + // + // We cannot write 'using ::testing::internal2::operator<<;', which + // gcc 3.3 fails to compile due to a compiler bug. + using namespace ::testing::internal2; // NOLINT + + // Assuming T is defined in namespace foo, in the next statement, + // the compiler will consider all of: + // + // 1. foo::operator<< (thanks to Koenig look-up), + // 2. ::operator<< (as the current namespace is enclosed in ::), + // 3. testing::internal2::operator<< (thanks to the using statement above). + // + // The operator<< whose type matches T best will be picked. + // + // We deliberately allow #2 to be a candidate, as sometimes it's + // impossible to define #1 (e.g. when foo is ::std, defining + // anything in it is undefined behavior unless you are a compiler + // vendor.). + *os << value; +} + +} // namespace testing_internal + +namespace testing { +namespace internal { + +// FormatForComparison::Format(value) formats a +// value of type ToPrint that is an operand of a comparison assertion +// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in +// the comparison, and is used to help determine the best way to +// format the value. In particular, when the value is a C string +// (char pointer) and the other operand is an STL string object, we +// want to format the C string as a string, since we know it is +// compared by value with the string object. If the value is a char +// pointer but the other operand is not an STL string object, we don't +// know whether the pointer is supposed to point to a NUL-terminated +// string, and thus want to print it as a pointer to be safe. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +// The default case. +template +class FormatForComparison { + public: + static ::std::string Format(const ToPrint& value) { + return ::testing::PrintToString(value); + } +}; + +// Array. +template +class FormatForComparison { + public: + static ::std::string Format(const ToPrint* value) { + return FormatForComparison::Format(value); + } +}; + +// By default, print C string as pointers to be safe, as we don't know +// whether they actually point to a NUL-terminated string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ + template \ + class FormatForComparison { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(static_cast(value)); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t); + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ + +// If a C string is compared with an STL string object, we know it's meant +// to point to a NUL-terminated string, and thus can print it as a string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ + template <> \ + class FormatForComparison { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(value); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string); + +#if GTEST_HAS_STD_WSTRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); +#endif + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ + +// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) +// operand to be used in a failure message. The type (but not value) +// of the other operand may affect the format. This allows us to +// print a char* as a raw pointer when it is compared against another +// char* or void*, and print it as a C string when it is compared +// against an std::string object, for example. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +template +std::string FormatForComparisonFailureMessage( + const T1& value, const T2& /* other_operand */) { + return FormatForComparison::Format(value); +} + +// UniversalPrinter::Print(value, ostream_ptr) prints the given +// value to the given ostream. The caller must ensure that +// 'ostream_ptr' is not NULL, or the behavior is undefined. +// +// We define UniversalPrinter as a class template (as opposed to a +// function template), as we need to partially specialize it for +// reference types, which cannot be done with function templates. +template +class UniversalPrinter; + +template +void UniversalPrint(const T& value, ::std::ostream* os); + +enum DefaultPrinterType { + kPrintContainer, + kPrintPointer, + kPrintFunctionPointer, + kPrintOther, +}; +template struct WrapPrinterType {}; + +// Used to print an STL-style container when the user doesn't define +// a PrintTo() for it. +template +void DefaultPrintTo(WrapPrinterType /* dummy */, + const C& container, ::std::ostream* os) { + const size_t kMaxCount = 32; // The maximum number of elements to print. + *os << '{'; + size_t count = 0; + for (typename C::const_iterator it = container.begin(); + it != container.end(); ++it, ++count) { + if (count > 0) { + *os << ','; + if (count == kMaxCount) { // Enough has been printed. + *os << " ..."; + break; + } + } + *os << ' '; + // We cannot call PrintTo(*it, os) here as PrintTo() doesn't + // handle *it being a native array. + internal::UniversalPrint(*it, os); + } + + if (count > 0) { + *os << ' '; + } + *os << '}'; +} + +// Used to print a pointer that is neither a char pointer nor a member +// pointer, when the user doesn't define PrintTo() for it. (A member +// variable pointer or member function pointer doesn't really point to +// a location in the address space. Their representation is +// implementation-defined. Therefore they will be printed as raw +// bytes.) +template +void DefaultPrintTo(WrapPrinterType /* dummy */, + T* p, ::std::ostream* os) { + if (p == nullptr) { + *os << "NULL"; + } else { + // T is not a function type. We just call << to print p, + // relying on ADL to pick up user-defined << for their pointer + // types, if any. + *os << p; + } +} +template +void DefaultPrintTo(WrapPrinterType /* dummy */, + T* p, ::std::ostream* os) { + if (p == nullptr) { + *os << "NULL"; + } else { + // T is a function type, so '*os << p' doesn't do what we want + // (it just prints p as bool). We want to print p as a const + // void*. + *os << reinterpret_cast(p); + } +} + +// Used to print a non-container, non-pointer value when the user +// doesn't define PrintTo() for it. +template +void DefaultPrintTo(WrapPrinterType /* dummy */, + const T& value, ::std::ostream* os) { + ::testing_internal::DefaultPrintNonContainerTo(value, os); +} + +// Prints the given value using the << operator if it has one; +// otherwise prints the bytes in it. This is what +// UniversalPrinter::Print() does when PrintTo() is not specialized +// or overloaded for type T. +// +// A user can override this behavior for a class type Foo by defining +// an overload of PrintTo() in the namespace where Foo is defined. We +// give the user this option as sometimes defining a << operator for +// Foo is not desirable (e.g. the coding style may prevent doing it, +// or there is already a << operator but it doesn't do what the user +// wants). +template +void PrintTo(const T& value, ::std::ostream* os) { + // DefaultPrintTo() is overloaded. The type of its first argument + // determines which version will be picked. + // + // Note that we check for container types here, prior to we check + // for protocol message types in our operator<<. The rationale is: + // + // For protocol messages, we want to give people a chance to + // override Google Mock's format by defining a PrintTo() or + // operator<<. For STL containers, other formats can be + // incompatible with Google Mock's format for the container + // elements; therefore we check for container types here to ensure + // that our format is used. + // + // Note that MSVC and clang-cl do allow an implicit conversion from + // pointer-to-function to pointer-to-object, but clang-cl warns on it. + // So don't use ImplicitlyConvertible if it can be helped since it will + // cause this warning, and use a separate overload of DefaultPrintTo for + // function pointers so that the `*os << p` in the object pointer overload + // doesn't cause that warning either. + DefaultPrintTo( + WrapPrinterType < + (sizeof(IsContainerTest(0)) == sizeof(IsContainer)) && + !IsRecursiveContainer::value + ? kPrintContainer + : !std::is_pointer::value + ? kPrintOther + : std::is_function::type>::value + ? kPrintFunctionPointer + : kPrintPointer > (), + value, os); +} + +// The following list of PrintTo() overloads tells +// UniversalPrinter::Print() how to print standard types (built-in +// types, strings, plain arrays, and pointers). + +// Overloads for various char types. +GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os); +GTEST_API_ void PrintTo(signed char c, ::std::ostream* os); +inline void PrintTo(char c, ::std::ostream* os) { + // When printing a plain char, we always treat it as unsigned. This + // way, the output won't be affected by whether the compiler thinks + // char is signed or not. + PrintTo(static_cast(c), os); +} + +// Overloads for other simple built-in types. +inline void PrintTo(bool x, ::std::ostream* os) { + *os << (x ? "true" : "false"); +} + +// Overload for wchar_t type. +// Prints a wchar_t as a symbol if it is printable or as its internal +// code otherwise and also as its decimal code (except for L'\0'). +// The L'\0' char is printed as "L'\\0'". The decimal code is printed +// as signed integer when wchar_t is implemented by the compiler +// as a signed type and is printed as an unsigned integer when wchar_t +// is implemented as an unsigned type. +GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os); + +// Overloads for C strings. +GTEST_API_ void PrintTo(const char* s, ::std::ostream* os); +inline void PrintTo(char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} + +// signed/unsigned char is often used for representing binary data, so +// we print pointers to it as void* to be safe. +inline void PrintTo(const signed char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(signed char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(const unsigned char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(unsigned char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} + +// MSVC can be configured to define wchar_t as a typedef of unsigned +// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native +// type. When wchar_t is a typedef, defining an overload for const +// wchar_t* would cause unsigned short* be printed as a wide string, +// possibly causing invalid memory accesses. +#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) +// Overloads for wide C strings +GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os); +inline void PrintTo(wchar_t* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +#endif + +// Overload for C arrays. Multi-dimensional arrays are printed +// properly. + +// Prints the given number of elements in an array, without printing +// the curly braces. +template +void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { + UniversalPrint(a[0], os); + for (size_t i = 1; i != count; i++) { + *os << ", "; + UniversalPrint(a[i], os); + } +} + +// Overloads for ::std::string. +GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os); +inline void PrintTo(const ::std::string& s, ::std::ostream* os) { + PrintStringTo(s, os); +} + +// Overloads for ::std::wstring. +#if GTEST_HAS_STD_WSTRING +GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os); +inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { + PrintWideStringTo(s, os); +} +#endif // GTEST_HAS_STD_WSTRING + +#if GTEST_HAS_ABSL +// Overload for absl::string_view. +inline void PrintTo(absl::string_view sp, ::std::ostream* os) { + PrintTo(::std::string(sp), os); +} +#endif // GTEST_HAS_ABSL + +inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } + +template +void PrintTo(std::reference_wrapper ref, ::std::ostream* os) { + UniversalPrinter::Print(ref.get(), os); +} + +// Helper function for printing a tuple. T must be instantiated with +// a tuple type. +template +void PrintTupleTo(const T&, std::integral_constant, + ::std::ostream*) {} + +template +void PrintTupleTo(const T& t, std::integral_constant, + ::std::ostream* os) { + PrintTupleTo(t, std::integral_constant(), os); + GTEST_INTENTIONAL_CONST_COND_PUSH_() + if (I > 1) { + GTEST_INTENTIONAL_CONST_COND_POP_() + *os << ", "; + } + UniversalPrinter::type>::Print( + std::get(t), os); +} + +template +void PrintTo(const ::std::tuple& t, ::std::ostream* os) { + *os << "("; + PrintTupleTo(t, std::integral_constant(), os); + *os << ")"; +} + +// Overload for std::pair. +template +void PrintTo(const ::std::pair& value, ::std::ostream* os) { + *os << '('; + // We cannot use UniversalPrint(value.first, os) here, as T1 may be + // a reference type. The same for printing value.second. + UniversalPrinter::Print(value.first, os); + *os << ", "; + UniversalPrinter::Print(value.second, os); + *os << ')'; +} + +// Implements printing a non-reference type T by letting the compiler +// pick the right overload of PrintTo() for T. +template +class UniversalPrinter { + public: + // MSVC warns about adding const to a function type, so we want to + // disable the warning. + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180) + + // Note: we deliberately don't call this PrintTo(), as that name + // conflicts with ::testing::internal::PrintTo in the body of the + // function. + static void Print(const T& value, ::std::ostream* os) { + // By default, ::testing::internal::PrintTo() is used for printing + // the value. + // + // Thanks to Koenig look-up, if T is a class and has its own + // PrintTo() function defined in its namespace, that function will + // be visible here. Since it is more specific than the generic ones + // in ::testing::internal, it will be picked by the compiler in the + // following statement - exactly what we want. + PrintTo(value, os); + } + + GTEST_DISABLE_MSC_WARNINGS_POP_() +}; + +#if GTEST_HAS_ABSL + +// Printer for absl::optional + +template +class UniversalPrinter<::absl::optional> { + public: + static void Print(const ::absl::optional& value, ::std::ostream* os) { + *os << '('; + if (!value) { + *os << "nullopt"; + } else { + UniversalPrint(*value, os); + } + *os << ')'; + } +}; + +// Printer for absl::variant + +template +class UniversalPrinter<::absl::variant> { + public: + static void Print(const ::absl::variant& value, ::std::ostream* os) { + *os << '('; + absl::visit(Visitor{os}, value); + *os << ')'; + } + + private: + struct Visitor { + template + void operator()(const U& u) const { + *os << "'" << GetTypeName() << "' with value "; + UniversalPrint(u, os); + } + ::std::ostream* os; + }; +}; + +#endif // GTEST_HAS_ABSL + +// UniversalPrintArray(begin, len, os) prints an array of 'len' +// elements, starting at address 'begin'. +template +void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { + if (len == 0) { + *os << "{}"; + } else { + *os << "{ "; + const size_t kThreshold = 18; + const size_t kChunkSize = 8; + // If the array has more than kThreshold elements, we'll have to + // omit some details by printing only the first and the last + // kChunkSize elements. + if (len <= kThreshold) { + PrintRawArrayTo(begin, len, os); + } else { + PrintRawArrayTo(begin, kChunkSize, os); + *os << ", ..., "; + PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os); + } + *os << " }"; + } +} +// This overload prints a (const) char array compactly. +GTEST_API_ void UniversalPrintArray( + const char* begin, size_t len, ::std::ostream* os); + +// This overload prints a (const) wchar_t array compactly. +GTEST_API_ void UniversalPrintArray( + const wchar_t* begin, size_t len, ::std::ostream* os); + +// Implements printing an array type T[N]. +template +class UniversalPrinter { + public: + // Prints the given array, omitting some elements when there are too + // many. + static void Print(const T (&a)[N], ::std::ostream* os) { + UniversalPrintArray(a, N, os); + } +}; + +// Implements printing a reference type T&. +template +class UniversalPrinter { + public: + // MSVC warns about adding const to a function type, so we want to + // disable the warning. + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180) + + static void Print(const T& value, ::std::ostream* os) { + // Prints the address of the value. We use reinterpret_cast here + // as static_cast doesn't compile when T is a function type. + *os << "@" << reinterpret_cast(&value) << " "; + + // Then prints the value itself. + UniversalPrint(value, os); + } + + GTEST_DISABLE_MSC_WARNINGS_POP_() +}; + +// Prints a value tersely: for a reference type, the referenced value +// (but not the address) is printed; for a (const) char pointer, the +// NUL-terminated string (but not the pointer) is printed. + +template +class UniversalTersePrinter { + public: + static void Print(const T& value, ::std::ostream* os) { + UniversalPrint(value, os); + } +}; +template +class UniversalTersePrinter { + public: + static void Print(const T& value, ::std::ostream* os) { + UniversalPrint(value, os); + } +}; +template +class UniversalTersePrinter { + public: + static void Print(const T (&value)[N], ::std::ostream* os) { + UniversalPrinter::Print(value, os); + } +}; +template <> +class UniversalTersePrinter { + public: + static void Print(const char* str, ::std::ostream* os) { + if (str == nullptr) { + *os << "NULL"; + } else { + UniversalPrint(std::string(str), os); + } + } +}; +template <> +class UniversalTersePrinter { + public: + static void Print(char* str, ::std::ostream* os) { + UniversalTersePrinter::Print(str, os); + } +}; + +#if GTEST_HAS_STD_WSTRING +template <> +class UniversalTersePrinter { + public: + static void Print(const wchar_t* str, ::std::ostream* os) { + if (str == nullptr) { + *os << "NULL"; + } else { + UniversalPrint(::std::wstring(str), os); + } + } +}; +#endif + +template <> +class UniversalTersePrinter { + public: + static void Print(wchar_t* str, ::std::ostream* os) { + UniversalTersePrinter::Print(str, os); + } +}; + +template +void UniversalTersePrint(const T& value, ::std::ostream* os) { + UniversalTersePrinter::Print(value, os); +} + +// Prints a value using the type inferred by the compiler. The +// difference between this and UniversalTersePrint() is that for a +// (const) char pointer, this prints both the pointer and the +// NUL-terminated string. +template +void UniversalPrint(const T& value, ::std::ostream* os) { + // A workarond for the bug in VC++ 7.1 that prevents us from instantiating + // UniversalPrinter with T directly. + typedef T T1; + UniversalPrinter::Print(value, os); +} + +typedef ::std::vector< ::std::string> Strings; + + // Tersely prints the first N fields of a tuple to a string vector, + // one element for each field. +template +void TersePrintPrefixToStrings(const Tuple&, std::integral_constant, + Strings*) {} +template +void TersePrintPrefixToStrings(const Tuple& t, + std::integral_constant, + Strings* strings) { + TersePrintPrefixToStrings(t, std::integral_constant(), + strings); + ::std::stringstream ss; + UniversalTersePrint(std::get(t), &ss); + strings->push_back(ss.str()); +} + +// Prints the fields of a tuple tersely to a string vector, one +// element for each field. See the comment before +// UniversalTersePrint() for how we define "tersely". +template +Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { + Strings result; + TersePrintPrefixToStrings( + value, std::integral_constant::value>(), + &result); + return result; +} + +} // namespace internal + +#if GTEST_HAS_ABSL +namespace internal2 { +template +void TypeWithoutFormatter::PrintValue( + const T& value, ::std::ostream* os) { + internal::PrintTo(absl::string_view(value), os); +} +} // namespace internal2 +#endif + +template +::std::string PrintToString(const T& value) { + ::std::stringstream ss; + internal::UniversalTersePrinter::Print(value, &ss); + return ss.str(); +} + +} // namespace testing + +// Include any custom printer added by the local installation. +// We must include this header at the end to make sure it can use the +// declarations from this file. +#include "gtest/internal/custom/gtest-printers.h" + +#endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ diff --git a/include/gtest/gtest-spi.h b/include/gtest/gtest-spi.h new file mode 100644 index 0000000..aa38870 --- /dev/null +++ b/include/gtest/gtest-spi.h @@ -0,0 +1,238 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// Utilities for testing Google Test itself and code that uses Google Test +// (e.g. frameworks built on top of Google Test). + +// GOOGLETEST_CM0004 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_ +#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_ + +#include "gtest/gtest.h" + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +namespace testing { + +// This helper class can be used to mock out Google Test failure reporting +// so that we can test Google Test or code that builds on Google Test. +// +// An object of this class appends a TestPartResult object to the +// TestPartResultArray object given in the constructor whenever a Google Test +// failure is reported. It can either intercept only failures that are +// generated in the same thread that created this object or it can intercept +// all generated failures. The scope of this mock object can be controlled with +// the second argument to the two arguments constructor. +class GTEST_API_ ScopedFakeTestPartResultReporter + : public TestPartResultReporterInterface { + public: + // The two possible mocking modes of this object. + enum InterceptMode { + INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures. + INTERCEPT_ALL_THREADS // Intercepts all failures. + }; + + // The c'tor sets this object as the test part result reporter used + // by Google Test. The 'result' parameter specifies where to report the + // results. This reporter will only catch failures generated in the current + // thread. DEPRECATED + explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result); + + // Same as above, but you can choose the interception scope of this object. + ScopedFakeTestPartResultReporter(InterceptMode intercept_mode, + TestPartResultArray* result); + + // The d'tor restores the previous test part result reporter. + ~ScopedFakeTestPartResultReporter() override; + + // Appends the TestPartResult object to the TestPartResultArray + // received in the constructor. + // + // This method is from the TestPartResultReporterInterface + // interface. + void ReportTestPartResult(const TestPartResult& result) override; + + private: + void Init(); + + const InterceptMode intercept_mode_; + TestPartResultReporterInterface* old_reporter_; + TestPartResultArray* const result_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter); +}; + +namespace internal { + +// A helper class for implementing EXPECT_FATAL_FAILURE() and +// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given +// TestPartResultArray contains exactly one failure that has the given +// type and contains the given substring. If that's not the case, a +// non-fatal failure will be generated. +class GTEST_API_ SingleFailureChecker { + public: + // The constructor remembers the arguments. + SingleFailureChecker(const TestPartResultArray* results, + TestPartResult::Type type, const std::string& substr); + ~SingleFailureChecker(); + private: + const TestPartResultArray* const results_; + const TestPartResult::Type type_; + const std::string substr_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); +}; + +} // namespace internal + +} // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +// A set of macros for testing Google Test assertions or code that's expected +// to generate Google Test fatal failures. It verifies that the given +// statement will cause exactly one fatal Google Test failure with 'substr' +// being part of the failure message. +// +// There are two different versions of this macro. EXPECT_FATAL_FAILURE only +// affects and considers failures generated in the current thread and +// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. +// +// The verification of the assertion is done correctly even when the statement +// throws an exception or aborts the current function. +// +// Known restrictions: +// - 'statement' cannot reference local non-static variables or +// non-static members of the current object. +// - 'statement' cannot return a value. +// - You cannot stream a failure message to this macro. +// +// Note that even though the implementations of the following two +// macros are much alike, we cannot refactor them to use a common +// helper macro, due to some peculiarity in how the preprocessor +// works. The AcceptsMacroThatExpandsToUnprotectedComma test in +// gtest_unittest.cc will fail to compile if we do that. +#define EXPECT_FATAL_FAILURE(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper {\ + public:\ + static void Execute() { statement; }\ + };\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ + GTestExpectFatalFailureHelper::Execute();\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper {\ + public:\ + static void Execute() { statement; }\ + };\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ALL_THREADS, >est_failures);\ + GTestExpectFatalFailureHelper::Execute();\ + }\ + } while (::testing::internal::AlwaysFalse()) + +// A macro for testing Google Test assertions or code that's expected to +// generate Google Test non-fatal failures. It asserts that the given +// statement will cause exactly one non-fatal Google Test failure with 'substr' +// being part of the failure message. +// +// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only +// affects and considers failures generated in the current thread and +// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. +// +// 'statement' is allowed to reference local variables and members of +// the current object. +// +// The verification of the assertion is done correctly even when the statement +// throws an exception or aborts the current function. +// +// Known restrictions: +// - You cannot stream a failure message to this macro. +// +// Note that even though the implementations of the following two +// macros are much alike, we cannot refactor them to use a common +// helper macro, due to some peculiarity in how the preprocessor +// works. If we do that, the code won't compile when the user gives +// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that +// expands to code containing an unprotected comma. The +// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc +// catches that. +// +// For the same reason, we have to write +// if (::testing::internal::AlwaysTrue()) { statement; } +// instead of +// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) +// to avoid an MSVC warning on unreachable code. +#define EXPECT_NONFATAL_FAILURE(statement, substr) \ + do {\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ + (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ + if (::testing::internal::AlwaysTrue()) { statement; }\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do {\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ + (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ + >est_failures);\ + if (::testing::internal::AlwaysTrue()) { statement; }\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ diff --git a/include/gtest/gtest-test-part.h b/include/gtest/gtest-test-part.h new file mode 100644 index 0000000..05a7985 --- /dev/null +++ b/include/gtest/gtest-test-part.h @@ -0,0 +1,184 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ +#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ + +#include +#include +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +namespace testing { + +// A copyable object representing the result of a test part (i.e. an +// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()). +// +// Don't inherit from TestPartResult as its destructor is not virtual. +class GTEST_API_ TestPartResult { + public: + // The possible outcomes of a test part (i.e. an assertion or an + // explicit SUCCEED(), FAIL(), or ADD_FAILURE()). + enum Type { + kSuccess, // Succeeded. + kNonFatalFailure, // Failed but the test can continue. + kFatalFailure, // Failed and the test should be terminated. + kSkip // Skipped. + }; + + // C'tor. TestPartResult does NOT have a default constructor. + // Always use this constructor (with parameters) to create a + // TestPartResult object. + TestPartResult(Type a_type, const char* a_file_name, int a_line_number, + const char* a_message) + : type_(a_type), + file_name_(a_file_name == nullptr ? "" : a_file_name), + line_number_(a_line_number), + summary_(ExtractSummary(a_message)), + message_(a_message) {} + + // Gets the outcome of the test part. + Type type() const { return type_; } + + // Gets the name of the source file where the test part took place, or + // NULL if it's unknown. + const char* file_name() const { + return file_name_.empty() ? nullptr : file_name_.c_str(); + } + + // Gets the line in the source file where the test part took place, + // or -1 if it's unknown. + int line_number() const { return line_number_; } + + // Gets the summary of the failure message. + const char* summary() const { return summary_.c_str(); } + + // Gets the message associated with the test part. + const char* message() const { return message_.c_str(); } + + // Returns true if and only if the test part was skipped. + bool skipped() const { return type_ == kSkip; } + + // Returns true if and only if the test part passed. + bool passed() const { return type_ == kSuccess; } + + // Returns true if and only if the test part non-fatally failed. + bool nonfatally_failed() const { return type_ == kNonFatalFailure; } + + // Returns true if and only if the test part fatally failed. + bool fatally_failed() const { return type_ == kFatalFailure; } + + // Returns true if and only if the test part failed. + bool failed() const { return fatally_failed() || nonfatally_failed(); } + + private: + Type type_; + + // Gets the summary of the failure message by omitting the stack + // trace in it. + static std::string ExtractSummary(const char* message); + + // The name of the source file where the test part took place, or + // "" if the source file is unknown. + std::string file_name_; + // The line in the source file where the test part took place, or -1 + // if the line number is unknown. + int line_number_; + std::string summary_; // The test failure summary. + std::string message_; // The test failure message. +}; + +// Prints a TestPartResult object. +std::ostream& operator<<(std::ostream& os, const TestPartResult& result); + +// An array of TestPartResult objects. +// +// Don't inherit from TestPartResultArray as its destructor is not +// virtual. +class GTEST_API_ TestPartResultArray { + public: + TestPartResultArray() {} + + // Appends the given TestPartResult to the array. + void Append(const TestPartResult& result); + + // Returns the TestPartResult at the given index (0-based). + const TestPartResult& GetTestPartResult(int index) const; + + // Returns the number of TestPartResult objects in the array. + int size() const; + + private: + std::vector array_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray); +}; + +// This interface knows how to report a test part result. +class GTEST_API_ TestPartResultReporterInterface { + public: + virtual ~TestPartResultReporterInterface() {} + + virtual void ReportTestPartResult(const TestPartResult& result) = 0; +}; + +namespace internal { + +// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a +// statement generates new fatal failures. To do so it registers itself as the +// current test part result reporter. Besides checking if fatal failures were +// reported, it only delegates the reporting to the former result reporter. +// The original result reporter is restored in the destructor. +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +class GTEST_API_ HasNewFatalFailureHelper + : public TestPartResultReporterInterface { + public: + HasNewFatalFailureHelper(); + ~HasNewFatalFailureHelper() override; + void ReportTestPartResult(const TestPartResult& result) override; + bool has_new_fatal_failure() const { return has_new_fatal_failure_; } + private: + bool has_new_fatal_failure_; + TestPartResultReporterInterface* original_reporter_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper); +}; + +} // namespace internal + +} // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ diff --git a/include/gtest/gtest-typed-test.h b/include/gtest/gtest-typed-test.h new file mode 100644 index 0000000..095ce05 --- /dev/null +++ b/include/gtest/gtest-typed-test.h @@ -0,0 +1,330 @@ +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ + +// This header implements typed tests and type-parameterized tests. + +// Typed (aka type-driven) tests repeat the same test for types in a +// list. You must know which types you want to test with when writing +// typed tests. Here's how you do it: + +#if 0 + +// First, define a fixture class template. It should be parameterized +// by a type. Remember to derive it from testing::Test. +template +class FooTest : public testing::Test { + public: + ... + typedef std::list List; + static T shared_; + T value_; +}; + +// Next, associate a list of types with the test suite, which will be +// repeated for each type in the list. The typedef is necessary for +// the macro to parse correctly. +typedef testing::Types MyTypes; +TYPED_TEST_SUITE(FooTest, MyTypes); + +// If the type list contains only one type, you can write that type +// directly without Types<...>: +// TYPED_TEST_SUITE(FooTest, int); + +// Then, use TYPED_TEST() instead of TEST_F() to define as many typed +// tests for this test suite as you want. +TYPED_TEST(FooTest, DoesBlah) { + // Inside a test, refer to the special name TypeParam to get the type + // parameter. Since we are inside a derived class template, C++ requires + // us to visit the members of FooTest via 'this'. + TypeParam n = this->value_; + + // To visit static members of the fixture, add the TestFixture:: + // prefix. + n += TestFixture::shared_; + + // To refer to typedefs in the fixture, add the "typename + // TestFixture::" prefix. + typename TestFixture::List values; + values.push_back(n); + ... +} + +TYPED_TEST(FooTest, HasPropertyA) { ... } + +// TYPED_TEST_SUITE takes an optional third argument which allows to specify a +// class that generates custom test name suffixes based on the type. This should +// be a class which has a static template function GetName(int index) returning +// a string for each type. The provided integer index equals the index of the +// type in the provided type list. In many cases the index can be ignored. +// +// For example: +// class MyTypeNames { +// public: +// template +// static std::string GetName(int) { +// if (std::is_same()) return "char"; +// if (std::is_same()) return "int"; +// if (std::is_same()) return "unsignedInt"; +// } +// }; +// TYPED_TEST_SUITE(FooTest, MyTypes, MyTypeNames); + +#endif // 0 + +// Type-parameterized tests are abstract test patterns parameterized +// by a type. Compared with typed tests, type-parameterized tests +// allow you to define the test pattern without knowing what the type +// parameters are. The defined pattern can be instantiated with +// different types any number of times, in any number of translation +// units. +// +// If you are designing an interface or concept, you can define a +// suite of type-parameterized tests to verify properties that any +// valid implementation of the interface/concept should have. Then, +// each implementation can easily instantiate the test suite to verify +// that it conforms to the requirements, without having to write +// similar tests repeatedly. Here's an example: + +#if 0 + +// First, define a fixture class template. It should be parameterized +// by a type. Remember to derive it from testing::Test. +template +class FooTest : public testing::Test { + ... +}; + +// Next, declare that you will define a type-parameterized test suite +// (the _P suffix is for "parameterized" or "pattern", whichever you +// prefer): +TYPED_TEST_SUITE_P(FooTest); + +// Then, use TYPED_TEST_P() to define as many type-parameterized tests +// for this type-parameterized test suite as you want. +TYPED_TEST_P(FooTest, DoesBlah) { + // Inside a test, refer to TypeParam to get the type parameter. + TypeParam n = 0; + ... +} + +TYPED_TEST_P(FooTest, HasPropertyA) { ... } + +// Now the tricky part: you need to register all test patterns before +// you can instantiate them. The first argument of the macro is the +// test suite name; the rest are the names of the tests in this test +// case. +REGISTER_TYPED_TEST_SUITE_P(FooTest, + DoesBlah, HasPropertyA); + +// Finally, you are free to instantiate the pattern with the types you +// want. If you put the above code in a header file, you can #include +// it in multiple C++ source files and instantiate it multiple times. +// +// To distinguish different instances of the pattern, the first +// argument to the INSTANTIATE_* macro is a prefix that will be added +// to the actual test suite name. Remember to pick unique prefixes for +// different instances. +typedef testing::Types MyTypes; +INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); + +// If the type list contains only one type, you can write that type +// directly without Types<...>: +// INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int); +// +// Similar to the optional argument of TYPED_TEST_SUITE above, +// INSTANTIATE_TEST_SUITE_P takes an optional fourth argument which allows to +// generate custom names. +// INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes, MyTypeNames); + +#endif // 0 + +#include "gtest/internal/gtest-port.h" +#include "gtest/internal/gtest-type-util.h" + +// Implements typed tests. + +#if GTEST_HAS_TYPED_TEST + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the name of the typedef for the type parameters of the +// given test suite. +#define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_ + +// Expands to the name of the typedef for the NameGenerator, responsible for +// creating the suffixes of the name. +#define GTEST_NAME_GENERATOR_(TestSuiteName) \ + gtest_type_params_##TestSuiteName##_NameGenerator + +#define TYPED_TEST_SUITE(CaseName, Types, ...) \ + typedef ::testing::internal::TypeList::type GTEST_TYPE_PARAMS_( \ + CaseName); \ + typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \ + GTEST_NAME_GENERATOR_(CaseName) + +# define TYPED_TEST(CaseName, TestName) \ + template \ + class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ + : public CaseName { \ + private: \ + typedef CaseName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + virtual void TestBody(); \ + }; \ + static bool gtest_##CaseName##_##TestName##_registered_ \ + GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTest< \ + CaseName, \ + ::testing::internal::TemplateSel, \ + GTEST_TYPE_PARAMS_( \ + CaseName)>::Register("", \ + ::testing::internal::CodeLocation( \ + __FILE__, __LINE__), \ + #CaseName, #TestName, 0, \ + ::testing::internal::GenerateNames< \ + GTEST_NAME_GENERATOR_(CaseName), \ + GTEST_TYPE_PARAMS_(CaseName)>()); \ + template \ + void GTEST_TEST_CLASS_NAME_(CaseName, \ + TestName)::TestBody() + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +#define TYPED_TEST_CASE \ + static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \ + TYPED_TEST_SUITE +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +#endif // GTEST_HAS_TYPED_TEST + +// Implements type-parameterized tests. + +#if GTEST_HAS_TYPED_TEST_P + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the namespace name that the type-parameterized tests for +// the given type-parameterized test suite are defined in. The exact +// name of the namespace is subject to change without notice. +#define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_ + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the name of the variable used to remember the names of +// the defined tests in the given test suite. +#define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \ + gtest_typed_test_suite_p_state_##TestSuiteName##_ + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY. +// +// Expands to the name of the variable used to remember the names of +// the registered tests in the given test suite. +#define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \ + gtest_registered_test_names_##TestSuiteName##_ + +// The variables defined in the type-parameterized test macros are +// static as typically these macros are used in a .h file that can be +// #included in multiple translation units linked together. +#define TYPED_TEST_SUITE_P(SuiteName) \ + static ::testing::internal::TypedTestSuitePState \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName) + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +#define TYPED_TEST_CASE_P \ + static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), ""); \ + TYPED_TEST_SUITE_P +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +#define TYPED_TEST_P(SuiteName, TestName) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + template \ + class TestName : public SuiteName { \ + private: \ + typedef SuiteName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + virtual void TestBody(); \ + }; \ + static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ + __FILE__, __LINE__, #SuiteName, #TestName); \ + } \ + template \ + void GTEST_SUITE_NAMESPACE_( \ + SuiteName)::TestName::TestBody() + +#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \ + } \ + static const char* const GTEST_REGISTERED_TEST_NAMES_( \ + SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \ + __FILE__, __LINE__, #__VA_ARGS__) + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +#define REGISTER_TYPED_TEST_CASE_P \ + static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \ + ""); \ + REGISTER_TYPED_TEST_SUITE_P +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ + static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTestSuite< \ + SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ + ::testing::internal::TypeList::type>:: \ + Register(#Prefix, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), \ + >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \ + GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ + ::testing::internal::GenerateNames< \ + ::testing::internal::NameGeneratorSelector< \ + __VA_ARGS__>::type, \ + ::testing::internal::TypeList::type>()) + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +#define INSTANTIATE_TYPED_TEST_CASE_P \ + static_assert( \ + ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), ""); \ + INSTANTIATE_TYPED_TEST_SUITE_P +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +#endif // GTEST_HAS_TYPED_TEST_P + +#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h new file mode 100644 index 0000000..dbe5b1c --- /dev/null +++ b/include/gtest/gtest.h @@ -0,0 +1,2478 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines the public API for Google Test. It should be +// included by any test program that uses Google Test. +// +// IMPORTANT NOTE: Due to limitation of the C++ language, we have to +// leave some internal implementation details in this header file. +// They are clearly marked by comments like this: +// +// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +// +// Such code is NOT meant to be used by a user directly, and is subject +// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user +// program! +// +// Acknowledgment: Google Test borrowed the idea of automatic test +// registration from Barthelemy Dagenais' (barthelemy@prologique.com) +// easyUnit framework. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_H_ + +#include +#include +#include +#include +#include +#include + +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" +#include "gtest/gtest-death-test.h" +#include "gtest/gtest-matchers.h" +#include "gtest/gtest-message.h" +#include "gtest/gtest-param-test.h" +#include "gtest/gtest-printers.h" +#include "gtest/gtest_prod.h" +#include "gtest/gtest-test-part.h" +#include "gtest/gtest-typed-test.h" + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +namespace testing { + +// Silence C4100 (unreferenced formal parameter) and 4805 +// unsafe mix of type 'const int' and type 'const bool' +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4805) +# pragma warning(disable:4100) +#endif + + +// Declares the flags. + +// This flag temporary enables the disabled tests. +GTEST_DECLARE_bool_(also_run_disabled_tests); + +// This flag brings the debugger on an assertion failure. +GTEST_DECLARE_bool_(break_on_failure); + +// This flag controls whether Google Test catches all test-thrown exceptions +// and logs them as failures. +GTEST_DECLARE_bool_(catch_exceptions); + +// This flag enables using colors in terminal output. Available values are +// "yes" to enable colors, "no" (disable colors), or "auto" (the default) +// to let Google Test decide. +GTEST_DECLARE_string_(color); + +// This flag sets up the filter to select by name using a glob pattern +// the tests to run. If the filter is not given all tests are executed. +GTEST_DECLARE_string_(filter); + +// This flag controls whether Google Test installs a signal handler that dumps +// debugging information when fatal signals are raised. +GTEST_DECLARE_bool_(install_failure_signal_handler); + +// This flag causes the Google Test to list tests. None of the tests listed +// are actually run if the flag is provided. +GTEST_DECLARE_bool_(list_tests); + +// This flag controls whether Google Test emits a detailed XML report to a file +// in addition to its normal textual output. +GTEST_DECLARE_string_(output); + +// This flags control whether Google Test prints the elapsed time for each +// test. +GTEST_DECLARE_bool_(print_time); + +// This flags control whether Google Test prints UTF8 characters as text. +GTEST_DECLARE_bool_(print_utf8); + +// This flag specifies the random number seed. +GTEST_DECLARE_int32_(random_seed); + +// This flag sets how many times the tests are repeated. The default value +// is 1. If the value is -1 the tests are repeating forever. +GTEST_DECLARE_int32_(repeat); + +// This flag controls whether Google Test includes Google Test internal +// stack frames in failure stack traces. +GTEST_DECLARE_bool_(show_internal_stack_frames); + +// When this flag is specified, tests' order is randomized on every iteration. +GTEST_DECLARE_bool_(shuffle); + +// This flag specifies the maximum number of stack frames to be +// printed in a failure message. +GTEST_DECLARE_int32_(stack_trace_depth); + +// When this flag is specified, a failed assertion will throw an +// exception if exceptions are enabled, or exit the program with a +// non-zero code otherwise. For use with an external test framework. +GTEST_DECLARE_bool_(throw_on_failure); + +// When this flag is set with a "host:port" string, on supported +// platforms test results are streamed to the specified port on +// the specified host machine. +GTEST_DECLARE_string_(stream_result_to); + +#if GTEST_USE_OWN_FLAGFILE_FLAG_ +GTEST_DECLARE_string_(flagfile); +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ + +// The upper limit for valid stack trace depths. +const int kMaxStackTraceDepth = 100; + +namespace internal { + +class AssertHelper; +class DefaultGlobalTestPartResultReporter; +class ExecDeathTest; +class NoExecDeathTest; +class FinalSuccessChecker; +class GTestFlagSaver; +class StreamingListenerTest; +class TestResultAccessor; +class TestEventListenersAccessor; +class TestEventRepeater; +class UnitTestRecordPropertyTestHelper; +class WindowsDeathTest; +class FuchsiaDeathTest; +class UnitTestImpl* GetUnitTestImpl(); +void ReportFailureInUnknownLocation(TestPartResult::Type result_type, + const std::string& message); + +} // namespace internal + +// The friend relationship of some of these classes is cyclic. +// If we don't forward declare them the compiler might confuse the classes +// in friendship clauses with same named classes on the scope. +class Test; +class TestSuite; + +// Old API is still available but deprecated +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +using TestCase = TestSuite; +#endif +class TestInfo; +class UnitTest; + +// A class for indicating whether an assertion was successful. When +// the assertion wasn't successful, the AssertionResult object +// remembers a non-empty message that describes how it failed. +// +// To create an instance of this class, use one of the factory functions +// (AssertionSuccess() and AssertionFailure()). +// +// This class is useful for two purposes: +// 1. Defining predicate functions to be used with Boolean test assertions +// EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts +// 2. Defining predicate-format functions to be +// used with predicate assertions (ASSERT_PRED_FORMAT*, etc). +// +// For example, if you define IsEven predicate: +// +// testing::AssertionResult IsEven(int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess(); +// else +// return testing::AssertionFailure() << n << " is odd"; +// } +// +// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5))) +// will print the message +// +// Value of: IsEven(Fib(5)) +// Actual: false (5 is odd) +// Expected: true +// +// instead of a more opaque +// +// Value of: IsEven(Fib(5)) +// Actual: false +// Expected: true +// +// in case IsEven is a simple Boolean predicate. +// +// If you expect your predicate to be reused and want to support informative +// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up +// about half as often as positive ones in our tests), supply messages for +// both success and failure cases: +// +// testing::AssertionResult IsEven(int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess() << n << " is even"; +// else +// return testing::AssertionFailure() << n << " is odd"; +// } +// +// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print +// +// Value of: IsEven(Fib(6)) +// Actual: true (8 is even) +// Expected: false +// +// NB: Predicates that support negative Boolean assertions have reduced +// performance in positive ones so be careful not to use them in tests +// that have lots (tens of thousands) of positive Boolean assertions. +// +// To use this class with EXPECT_PRED_FORMAT assertions such as: +// +// // Verifies that Foo() returns an even number. +// EXPECT_PRED_FORMAT1(IsEven, Foo()); +// +// you need to define: +// +// testing::AssertionResult IsEven(const char* expr, int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess(); +// else +// return testing::AssertionFailure() +// << "Expected: " << expr << " is even\n Actual: it's " << n; +// } +// +// If Foo() returns 5, you will see the following message: +// +// Expected: Foo() is even +// Actual: it's 5 +// +class GTEST_API_ AssertionResult { + public: + // Copy constructor. + // Used in EXPECT_TRUE/FALSE(assertion_result). + AssertionResult(const AssertionResult& other); + +#if defined(_MSC_VER) && _MSC_VER < 1910 + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */) +#endif + + // Used in the EXPECT_TRUE/FALSE(bool_expression). + // + // T must be contextually convertible to bool. + // + // The second parameter prevents this overload from being considered if + // the argument is implicitly convertible to AssertionResult. In that case + // we want AssertionResult's copy constructor to be used. + template + explicit AssertionResult( + const T& success, + typename std::enable_if< + !std::is_convertible::value>::type* + /*enabler*/ + = nullptr) + : success_(success) {} + +#if defined(_MSC_VER) && _MSC_VER < 1910 + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + + // Assignment operator. + AssertionResult& operator=(AssertionResult other) { + swap(other); + return *this; + } + + // Returns true if and only if the assertion succeeded. + operator bool() const { return success_; } // NOLINT + + // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. + AssertionResult operator!() const; + + // Returns the text streamed into this AssertionResult. Test assertions + // use it when they fail (i.e., the predicate's outcome doesn't match the + // assertion's expectation). When nothing has been streamed into the + // object, returns an empty string. + const char* message() const { + return message_.get() != nullptr ? message_->c_str() : ""; + } + // Deprecated; please use message() instead. + const char* failure_message() const { return message(); } + + // Streams a custom failure message into this object. + template AssertionResult& operator<<(const T& value) { + AppendMessage(Message() << value); + return *this; + } + + // Allows streaming basic output manipulators such as endl or flush into + // this object. + AssertionResult& operator<<( + ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) { + AppendMessage(Message() << basic_manipulator); + return *this; + } + + private: + // Appends the contents of message to message_. + void AppendMessage(const Message& a_message) { + if (message_.get() == nullptr) message_.reset(new ::std::string); + message_->append(a_message.GetString().c_str()); + } + + // Swap the contents of this AssertionResult with other. + void swap(AssertionResult& other); + + // Stores result of the assertion predicate. + bool success_; + // Stores the message describing the condition in case the expectation + // construct is not satisfied with the predicate's outcome. + // Referenced via a pointer to avoid taking too much stack frame space + // with test assertions. + std::unique_ptr< ::std::string> message_; +}; + +// Makes a successful assertion result. +GTEST_API_ AssertionResult AssertionSuccess(); + +// Makes a failed assertion result. +GTEST_API_ AssertionResult AssertionFailure(); + +// Makes a failed assertion result with the given failure message. +// Deprecated; use AssertionFailure() << msg. +GTEST_API_ AssertionResult AssertionFailure(const Message& msg); + +} // namespace testing + +// Includes the auto-generated header that implements a family of generic +// predicate assertion macros. This include comes late because it relies on +// APIs declared above. +#include "gtest/gtest_pred_impl.h" + +namespace testing { + +// The abstract class that all tests inherit from. +// +// In Google Test, a unit test program contains one or many TestSuites, and +// each TestSuite contains one or many Tests. +// +// When you define a test using the TEST macro, you don't need to +// explicitly derive from Test - the TEST macro automatically does +// this for you. +// +// The only time you derive from Test is when defining a test fixture +// to be used in a TEST_F. For example: +// +// class FooTest : public testing::Test { +// protected: +// void SetUp() override { ... } +// void TearDown() override { ... } +// ... +// }; +// +// TEST_F(FooTest, Bar) { ... } +// TEST_F(FooTest, Baz) { ... } +// +// Test is not copyable. +class GTEST_API_ Test { + public: + friend class TestInfo; + + // The d'tor is virtual as we intend to inherit from Test. + virtual ~Test(); + + // Sets up the stuff shared by all tests in this test case. + // + // Google Test will call Foo::SetUpTestSuite() before running the first + // test in test case Foo. Hence a sub-class can define its own + // SetUpTestSuite() method to shadow the one defined in the super + // class. + // Failures that happen during SetUpTestSuite are logged but otherwise + // ignored. + static void SetUpTestSuite() {} + + // Tears down the stuff shared by all tests in this test suite. + // + // Google Test will call Foo::TearDownTestSuite() after running the last + // test in test case Foo. Hence a sub-class can define its own + // TearDownTestSuite() method to shadow the one defined in the super + // class. + // Failures that happen during TearDownTestSuite are logged but otherwise + // ignored. + static void TearDownTestSuite() {} + + // Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + static void TearDownTestCase() {} + static void SetUpTestCase() {} +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Returns true if and only if the current test has a fatal failure. + static bool HasFatalFailure(); + + // Returns true if and only if the current test has a non-fatal failure. + static bool HasNonfatalFailure(); + + // Returns true if and only if the current test was skipped. + static bool IsSkipped(); + + // Returns true if and only if the current test has a (either fatal or + // non-fatal) failure. + static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); } + + // Logs a property for the current test, test suite, or for the entire + // invocation of the test program when used outside of the context of a + // test suite. Only the last value for a given key is remembered. These + // are public static so they can be called from utility functions that are + // not members of the test fixture. Calls to RecordProperty made during + // lifespan of the test (from the moment its constructor starts to the + // moment its destructor finishes) will be output in XML as attributes of + // the element. Properties recorded from fixture's + // SetUpTestSuite or TearDownTestSuite are logged as attributes of the + // corresponding element. Calls to RecordProperty made in the + // global context (before or after invocation of RUN_ALL_TESTS and from + // SetUp/TearDown method of Environment objects registered with Google + // Test) will be output as attributes of the element. + static void RecordProperty(const std::string& key, const std::string& value); + static void RecordProperty(const std::string& key, int value); + + protected: + // Creates a Test object. + Test(); + + // Sets up the test fixture. + virtual void SetUp(); + + // Tears down the test fixture. + virtual void TearDown(); + + private: + // Returns true if and only if the current test has the same fixture class + // as the first test in the current test suite. + static bool HasSameFixtureClass(); + + // Runs the test after the test fixture has been set up. + // + // A sub-class must implement this to define the test logic. + // + // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM. + // Instead, use the TEST or TEST_F macro. + virtual void TestBody() = 0; + + // Sets up, executes, and tears down the test. + void Run(); + + // Deletes self. We deliberately pick an unusual name for this + // internal method to avoid clashing with names used in user TESTs. + void DeleteSelf_() { delete this; } + + const std::unique_ptr gtest_flag_saver_; + + // Often a user misspells SetUp() as Setup() and spends a long time + // wondering why it is never called by Google Test. The declaration of + // the following method is solely for catching such an error at + // compile time: + // + // - The return type is deliberately chosen to be not void, so it + // will be a conflict if void Setup() is declared in the user's + // test fixture. + // + // - This method is private, so it will be another compiler error + // if the method is called from the user's test fixture. + // + // DO NOT OVERRIDE THIS FUNCTION. + // + // If you see an error about overriding the following function or + // about it being private, you have mis-spelled SetUp() as Setup(). + struct Setup_should_be_spelled_SetUp {}; + virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; } + + // We disallow copying Tests. + GTEST_DISALLOW_COPY_AND_ASSIGN_(Test); +}; + +typedef internal::TimeInMillis TimeInMillis; + +// A copyable object representing a user specified test property which can be +// output as a key/value string pair. +// +// Don't inherit from TestProperty as its destructor is not virtual. +class TestProperty { + public: + // C'tor. TestProperty does NOT have a default constructor. + // Always use this constructor (with parameters) to create a + // TestProperty object. + TestProperty(const std::string& a_key, const std::string& a_value) : + key_(a_key), value_(a_value) { + } + + // Gets the user supplied key. + const char* key() const { + return key_.c_str(); + } + + // Gets the user supplied value. + const char* value() const { + return value_.c_str(); + } + + // Sets a new value, overriding the one supplied in the constructor. + void SetValue(const std::string& new_value) { + value_ = new_value; + } + + private: + // The key supplied by the user. + std::string key_; + // The value supplied by the user. + std::string value_; +}; + +// The result of a single Test. This includes a list of +// TestPartResults, a list of TestProperties, a count of how many +// death tests there are in the Test, and how much time it took to run +// the Test. +// +// TestResult is not copyable. +class GTEST_API_ TestResult { + public: + // Creates an empty TestResult. + TestResult(); + + // D'tor. Do not inherit from TestResult. + ~TestResult(); + + // Gets the number of all test parts. This is the sum of the number + // of successful test parts and the number of failed test parts. + int total_part_count() const; + + // Returns the number of the test properties. + int test_property_count() const; + + // Returns true if and only if the test passed (i.e. no test part failed). + bool Passed() const { return !Skipped() && !Failed(); } + + // Returns true if and only if the test was skipped. + bool Skipped() const; + + // Returns true if and only if the test failed. + bool Failed() const; + + // Returns true if and only if the test fatally failed. + bool HasFatalFailure() const; + + // Returns true if and only if the test has a non-fatal failure. + bool HasNonfatalFailure() const; + + // Returns the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const { return elapsed_time_; } + + // Gets the time of the test case start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp() const { return start_timestamp_; } + + // Returns the i-th test part result among all the results. i can range from 0 + // to total_part_count() - 1. If i is not in that range, aborts the program. + const TestPartResult& GetTestPartResult(int i) const; + + // Returns the i-th test property. i can range from 0 to + // test_property_count() - 1. If i is not in that range, aborts the + // program. + const TestProperty& GetTestProperty(int i) const; + + private: + friend class TestInfo; + friend class TestSuite; + friend class UnitTest; + friend class internal::DefaultGlobalTestPartResultReporter; + friend class internal::ExecDeathTest; + friend class internal::TestResultAccessor; + friend class internal::UnitTestImpl; + friend class internal::WindowsDeathTest; + friend class internal::FuchsiaDeathTest; + + // Gets the vector of TestPartResults. + const std::vector& test_part_results() const { + return test_part_results_; + } + + // Gets the vector of TestProperties. + const std::vector& test_properties() const { + return test_properties_; + } + + // Sets the start time. + void set_start_timestamp(TimeInMillis start) { start_timestamp_ = start; } + + // Sets the elapsed time. + void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; } + + // Adds a test property to the list. The property is validated and may add + // a non-fatal failure if invalid (e.g., if it conflicts with reserved + // key names). If a property is already recorded for the same key, the + // value will be updated, rather than storing multiple values for the same + // key. xml_element specifies the element for which the property is being + // recorded and is used for validation. + void RecordProperty(const std::string& xml_element, + const TestProperty& test_property); + + // Adds a failure if the key is a reserved attribute of Google Test + // testsuite tags. Returns true if the property is valid. + // FIXME: Validate attribute names are legal and human readable. + static bool ValidateTestProperty(const std::string& xml_element, + const TestProperty& test_property); + + // Adds a test part result to the list. + void AddTestPartResult(const TestPartResult& test_part_result); + + // Returns the death test count. + int death_test_count() const { return death_test_count_; } + + // Increments the death test count, returning the new count. + int increment_death_test_count() { return ++death_test_count_; } + + // Clears the test part results. + void ClearTestPartResults(); + + // Clears the object. + void Clear(); + + // Protects mutable state of the property vector and of owned + // properties, whose values may be updated. + internal::Mutex test_properites_mutex_; + + // The vector of TestPartResults + std::vector test_part_results_; + // The vector of TestProperties + std::vector test_properties_; + // Running count of death tests. + int death_test_count_; + // The start time, in milliseconds since UNIX Epoch. + TimeInMillis start_timestamp_; + // The elapsed time, in milliseconds. + TimeInMillis elapsed_time_; + + // We disallow copying TestResult. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult); +}; // class TestResult + +// A TestInfo object stores the following information about a test: +// +// Test suite name +// Test name +// Whether the test should be run +// A function pointer that creates the test object when invoked +// Test result +// +// The constructor of TestInfo registers itself with the UnitTest +// singleton such that the RUN_ALL_TESTS() macro knows which tests to +// run. +class GTEST_API_ TestInfo { + public: + // Destructs a TestInfo object. This function is not virtual, so + // don't inherit from TestInfo. + ~TestInfo(); + + // Returns the test suite name. + const char* test_suite_name() const { return test_suite_name_.c_str(); } + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + const char* test_case_name() const { return test_suite_name(); } +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Returns the test name. + const char* name() const { return name_.c_str(); } + + // Returns the name of the parameter type, or NULL if this is not a typed + // or a type-parameterized test. + const char* type_param() const { + if (type_param_.get() != nullptr) return type_param_->c_str(); + return nullptr; + } + + // Returns the text representation of the value parameter, or NULL if this + // is not a value-parameterized test. + const char* value_param() const { + if (value_param_.get() != nullptr) return value_param_->c_str(); + return nullptr; + } + + // Returns the file name where this test is defined. + const char* file() const { return location_.file.c_str(); } + + // Returns the line where this test is defined. + int line() const { return location_.line; } + + // Return true if this test should not be run because it's in another shard. + bool is_in_another_shard() const { return is_in_another_shard_; } + + // Returns true if this test should run, that is if the test is not + // disabled (or it is disabled but the also_run_disabled_tests flag has + // been specified) and its full name matches the user-specified filter. + // + // Google Test allows the user to filter the tests by their full names. + // The full name of a test Bar in test suite Foo is defined as + // "Foo.Bar". Only the tests that match the filter will run. + // + // A filter is a colon-separated list of glob (not regex) patterns, + // optionally followed by a '-' and a colon-separated list of + // negative patterns (tests to exclude). A test is run if it + // matches one of the positive patterns and does not match any of + // the negative patterns. + // + // For example, *A*:Foo.* is a filter that matches any string that + // contains the character 'A' or starts with "Foo.". + bool should_run() const { return should_run_; } + + // Returns true if and only if this test will appear in the XML report. + bool is_reportable() const { + // The XML report includes tests matching the filter, excluding those + // run in other shards. + return matches_filter_ && !is_in_another_shard_; + } + + // Returns the result of the test. + const TestResult* result() const { return &result_; } + + private: +#if GTEST_HAS_DEATH_TEST + friend class internal::DefaultDeathTestFactory; +#endif // GTEST_HAS_DEATH_TEST + friend class Test; + friend class TestSuite; + friend class internal::UnitTestImpl; + friend class internal::StreamingListenerTest; + friend TestInfo* internal::MakeAndRegisterTestInfo( + const char* test_suite_name, const char* name, const char* type_param, + const char* value_param, internal::CodeLocation code_location, + internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc, + internal::TearDownTestSuiteFunc tear_down_tc, + internal::TestFactoryBase* factory); + + // Constructs a TestInfo object. The newly constructed instance assumes + // ownership of the factory object. + TestInfo(const std::string& test_suite_name, const std::string& name, + const char* a_type_param, // NULL if not a type-parameterized test + const char* a_value_param, // NULL if not a value-parameterized test + internal::CodeLocation a_code_location, + internal::TypeId fixture_class_id, + internal::TestFactoryBase* factory); + + // Increments the number of death tests encountered in this test so + // far. + int increment_death_test_count() { + return result_.increment_death_test_count(); + } + + // Creates the test object, runs it, records its result, and then + // deletes it. + void Run(); + + static void ClearTestResult(TestInfo* test_info) { + test_info->result_.Clear(); + } + + // These fields are immutable properties of the test. + const std::string test_suite_name_; // test suite name + const std::string name_; // Test name + // Name of the parameter type, or NULL if this is not a typed or a + // type-parameterized test. + const std::unique_ptr type_param_; + // Text representation of the value parameter, or NULL if this is not a + // value-parameterized test. + const std::unique_ptr value_param_; + internal::CodeLocation location_; + const internal::TypeId fixture_class_id_; // ID of the test fixture class + bool should_run_; // True if and only if this test should run + bool is_disabled_; // True if and only if this test is disabled + bool matches_filter_; // True if this test matches the + // user-specified filter. + bool is_in_another_shard_; // Will be run in another shard. + internal::TestFactoryBase* const factory_; // The factory that creates + // the test object + + // This field is mutable and needs to be reset before running the + // test for the second time. + TestResult result_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); +}; + +// A test suite, which consists of a vector of TestInfos. +// +// TestSuite is not copyable. +class GTEST_API_ TestSuite { + public: + // Creates a TestSuite with the given name. + // + // TestSuite does NOT have a default constructor. Always use this + // constructor to create a TestSuite object. + // + // Arguments: + // + // name: name of the test suite + // a_type_param: the name of the test's type parameter, or NULL if + // this is not a type-parameterized test. + // set_up_tc: pointer to the function that sets up the test suite + // tear_down_tc: pointer to the function that tears down the test suite + TestSuite(const char* name, const char* a_type_param, + internal::SetUpTestSuiteFunc set_up_tc, + internal::TearDownTestSuiteFunc tear_down_tc); + + // Destructor of TestSuite. + virtual ~TestSuite(); + + // Gets the name of the TestSuite. + const char* name() const { return name_.c_str(); } + + // Returns the name of the parameter type, or NULL if this is not a + // type-parameterized test suite. + const char* type_param() const { + if (type_param_.get() != nullptr) return type_param_->c_str(); + return nullptr; + } + + // Returns true if any test in this test suite should run. + bool should_run() const { return should_run_; } + + // Gets the number of successful tests in this test suite. + int successful_test_count() const; + + // Gets the number of skipped tests in this test suite. + int skipped_test_count() const; + + // Gets the number of failed tests in this test suite. + int failed_test_count() const; + + // Gets the number of disabled tests that will be reported in the XML report. + int reportable_disabled_test_count() const; + + // Gets the number of disabled tests in this test suite. + int disabled_test_count() const; + + // Gets the number of tests to be printed in the XML report. + int reportable_test_count() const; + + // Get the number of tests in this test suite that should run. + int test_to_run_count() const; + + // Gets the number of all tests in this test suite. + int total_test_count() const; + + // Returns true if and only if the test suite passed. + bool Passed() const { return !Failed(); } + + // Returns true if and only if the test suite failed. + bool Failed() const { return failed_test_count() > 0; } + + // Returns the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const { return elapsed_time_; } + + // Gets the time of the test suite start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp() const { return start_timestamp_; } + + // Returns the i-th test among all the tests. i can range from 0 to + // total_test_count() - 1. If i is not in that range, returns NULL. + const TestInfo* GetTestInfo(int i) const; + + // Returns the TestResult that holds test properties recorded during + // execution of SetUpTestSuite and TearDownTestSuite. + const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; } + + private: + friend class Test; + friend class internal::UnitTestImpl; + + // Gets the (mutable) vector of TestInfos in this TestSuite. + std::vector& test_info_list() { return test_info_list_; } + + // Gets the (immutable) vector of TestInfos in this TestSuite. + const std::vector& test_info_list() const { + return test_info_list_; + } + + // Returns the i-th test among all the tests. i can range from 0 to + // total_test_count() - 1. If i is not in that range, returns NULL. + TestInfo* GetMutableTestInfo(int i); + + // Sets the should_run member. + void set_should_run(bool should) { should_run_ = should; } + + // Adds a TestInfo to this test suite. Will delete the TestInfo upon + // destruction of the TestSuite object. + void AddTestInfo(TestInfo * test_info); + + // Clears the results of all tests in this test suite. + void ClearResult(); + + // Clears the results of all tests in the given test suite. + static void ClearTestSuiteResult(TestSuite* test_suite) { + test_suite->ClearResult(); + } + + // Runs every test in this TestSuite. + void Run(); + + // Runs SetUpTestSuite() for this TestSuite. This wrapper is needed + // for catching exceptions thrown from SetUpTestSuite(). + void RunSetUpTestSuite() { + if (set_up_tc_ != nullptr) { + (*set_up_tc_)(); + } + } + + // Runs TearDownTestSuite() for this TestSuite. This wrapper is + // needed for catching exceptions thrown from TearDownTestSuite(). + void RunTearDownTestSuite() { + if (tear_down_tc_ != nullptr) { + (*tear_down_tc_)(); + } + } + + // Returns true if and only if test passed. + static bool TestPassed(const TestInfo* test_info) { + return test_info->should_run() && test_info->result()->Passed(); + } + + // Returns true if and only if test skipped. + static bool TestSkipped(const TestInfo* test_info) { + return test_info->should_run() && test_info->result()->Skipped(); + } + + // Returns true if and only if test failed. + static bool TestFailed(const TestInfo* test_info) { + return test_info->should_run() && test_info->result()->Failed(); + } + + // Returns true if and only if the test is disabled and will be reported in + // the XML report. + static bool TestReportableDisabled(const TestInfo* test_info) { + return test_info->is_reportable() && test_info->is_disabled_; + } + + // Returns true if and only if test is disabled. + static bool TestDisabled(const TestInfo* test_info) { + return test_info->is_disabled_; + } + + // Returns true if and only if this test will appear in the XML report. + static bool TestReportable(const TestInfo* test_info) { + return test_info->is_reportable(); + } + + // Returns true if the given test should run. + static bool ShouldRunTest(const TestInfo* test_info) { + return test_info->should_run(); + } + + // Shuffles the tests in this test suite. + void ShuffleTests(internal::Random* random); + + // Restores the test order to before the first shuffle. + void UnshuffleTests(); + + // Name of the test suite. + std::string name_; + // Name of the parameter type, or NULL if this is not a typed or a + // type-parameterized test. + const std::unique_ptr type_param_; + // The vector of TestInfos in their original order. It owns the + // elements in the vector. + std::vector test_info_list_; + // Provides a level of indirection for the test list to allow easy + // shuffling and restoring the test order. The i-th element in this + // vector is the index of the i-th test in the shuffled test list. + std::vector test_indices_; + // Pointer to the function that sets up the test suite. + internal::SetUpTestSuiteFunc set_up_tc_; + // Pointer to the function that tears down the test suite. + internal::TearDownTestSuiteFunc tear_down_tc_; + // True if and only if any test in this test suite should run. + bool should_run_; + // The start time, in milliseconds since UNIX Epoch. + TimeInMillis start_timestamp_; + // Elapsed time, in milliseconds. + TimeInMillis elapsed_time_; + // Holds test properties recorded during execution of SetUpTestSuite and + // TearDownTestSuite. + TestResult ad_hoc_test_result_; + + // We disallow copying TestSuites. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite); +}; + +// An Environment object is capable of setting up and tearing down an +// environment. You should subclass this to define your own +// environment(s). +// +// An Environment object does the set-up and tear-down in virtual +// methods SetUp() and TearDown() instead of the constructor and the +// destructor, as: +// +// 1. You cannot safely throw from a destructor. This is a problem +// as in some cases Google Test is used where exceptions are enabled, and +// we may want to implement ASSERT_* using exceptions where they are +// available. +// 2. You cannot use ASSERT_* directly in a constructor or +// destructor. +class Environment { + public: + // The d'tor is virtual as we need to subclass Environment. + virtual ~Environment() {} + + // Override this to define how to set up the environment. + virtual void SetUp() {} + + // Override this to define how to tear down the environment. + virtual void TearDown() {} + private: + // If you see an error about overriding the following function or + // about it being private, you have mis-spelled SetUp() as Setup(). + struct Setup_should_be_spelled_SetUp {}; + virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; } +}; + +#if GTEST_HAS_EXCEPTIONS + +// Exception which can be thrown from TestEventListener::OnTestPartResult. +class GTEST_API_ AssertionException + : public internal::GoogleTestFailureException { + public: + explicit AssertionException(const TestPartResult& result) + : GoogleTestFailureException(result) {} +}; + +#endif // GTEST_HAS_EXCEPTIONS + +// The interface for tracing execution of tests. The methods are organized in +// the order the corresponding events are fired. +class TestEventListener { + public: + virtual ~TestEventListener() {} + + // Fired before any test activity starts. + virtual void OnTestProgramStart(const UnitTest& unit_test) = 0; + + // Fired before each iteration of tests starts. There may be more than + // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration + // index, starting from 0. + virtual void OnTestIterationStart(const UnitTest& unit_test, + int iteration) = 0; + + // Fired before environment set-up for each iteration of tests starts. + virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0; + + // Fired after environment set-up for each iteration of tests ends. + virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0; + + // Fired before the test suite starts. + virtual void OnTestSuiteStart(const TestSuite& /*test_suite*/) {} + + // Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + virtual void OnTestCaseStart(const TestCase& /*test_case*/) {} +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Fired before the test starts. + virtual void OnTestStart(const TestInfo& test_info) = 0; + + // Fired after a failed assertion or a SUCCEED() invocation. + // If you want to throw an exception from this function to skip to the next + // TEST, it must be AssertionException defined above, or inherited from it. + virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0; + + // Fired after the test ends. + virtual void OnTestEnd(const TestInfo& test_info) = 0; + + // Fired after the test suite ends. + virtual void OnTestSuiteEnd(const TestSuite& /*test_suite*/) {} + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {} +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Fired before environment tear-down for each iteration of tests starts. + virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0; + + // Fired after environment tear-down for each iteration of tests ends. + virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0; + + // Fired after each iteration of tests finishes. + virtual void OnTestIterationEnd(const UnitTest& unit_test, + int iteration) = 0; + + // Fired after all test activities have ended. + virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0; +}; + +// The convenience class for users who need to override just one or two +// methods and are not concerned that a possible change to a signature of +// the methods they override will not be caught during the build. For +// comments about each method please see the definition of TestEventListener +// above. +class EmptyTestEventListener : public TestEventListener { + public: + void OnTestProgramStart(const UnitTest& /*unit_test*/) override {} + void OnTestIterationStart(const UnitTest& /*unit_test*/, + int /*iteration*/) override {} + void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {} + void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {} + void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {} +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + void OnTestCaseStart(const TestCase& /*test_case*/) override {} +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + void OnTestStart(const TestInfo& /*test_info*/) override {} + void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {} + void OnTestEnd(const TestInfo& /*test_info*/) override {} + void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {} +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + void OnTestCaseEnd(const TestCase& /*test_case*/) override {} +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {} + void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {} + void OnTestIterationEnd(const UnitTest& /*unit_test*/, + int /*iteration*/) override {} + void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {} +}; + +// TestEventListeners lets users add listeners to track events in Google Test. +class GTEST_API_ TestEventListeners { + public: + TestEventListeners(); + ~TestEventListeners(); + + // Appends an event listener to the end of the list. Google Test assumes + // the ownership of the listener (i.e. it will delete the listener when + // the test program finishes). + void Append(TestEventListener* listener); + + // Removes the given event listener from the list and returns it. It then + // becomes the caller's responsibility to delete the listener. Returns + // NULL if the listener is not found in the list. + TestEventListener* Release(TestEventListener* listener); + + // Returns the standard listener responsible for the default console + // output. Can be removed from the listeners list to shut down default + // console output. Note that removing this object from the listener list + // with Release transfers its ownership to the caller and makes this + // function return NULL the next time. + TestEventListener* default_result_printer() const { + return default_result_printer_; + } + + // Returns the standard listener responsible for the default XML output + // controlled by the --gtest_output=xml flag. Can be removed from the + // listeners list by users who want to shut down the default XML output + // controlled by this flag and substitute it with custom one. Note that + // removing this object from the listener list with Release transfers its + // ownership to the caller and makes this function return NULL the next + // time. + TestEventListener* default_xml_generator() const { + return default_xml_generator_; + } + + private: + friend class TestSuite; + friend class TestInfo; + friend class internal::DefaultGlobalTestPartResultReporter; + friend class internal::NoExecDeathTest; + friend class internal::TestEventListenersAccessor; + friend class internal::UnitTestImpl; + + // Returns repeater that broadcasts the TestEventListener events to all + // subscribers. + TestEventListener* repeater(); + + // Sets the default_result_printer attribute to the provided listener. + // The listener is also added to the listener list and previous + // default_result_printer is removed from it and deleted. The listener can + // also be NULL in which case it will not be added to the list. Does + // nothing if the previous and the current listener objects are the same. + void SetDefaultResultPrinter(TestEventListener* listener); + + // Sets the default_xml_generator attribute to the provided listener. The + // listener is also added to the listener list and previous + // default_xml_generator is removed from it and deleted. The listener can + // also be NULL in which case it will not be added to the list. Does + // nothing if the previous and the current listener objects are the same. + void SetDefaultXmlGenerator(TestEventListener* listener); + + // Controls whether events will be forwarded by the repeater to the + // listeners in the list. + bool EventForwardingEnabled() const; + void SuppressEventForwarding(); + + // The actual list of listeners. + internal::TestEventRepeater* repeater_; + // Listener responsible for the standard result output. + TestEventListener* default_result_printer_; + // Listener responsible for the creation of the XML output file. + TestEventListener* default_xml_generator_; + + // We disallow copying TestEventListeners. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners); +}; + +// A UnitTest consists of a vector of TestSuites. +// +// This is a singleton class. The only instance of UnitTest is +// created when UnitTest::GetInstance() is first called. This +// instance is never deleted. +// +// UnitTest is not copyable. +// +// This class is thread-safe as long as the methods are called +// according to their specification. +class GTEST_API_ UnitTest { + public: + // Gets the singleton UnitTest object. The first time this method + // is called, a UnitTest object is constructed and returned. + // Consecutive calls will return the same object. + static UnitTest* GetInstance(); + + // Runs all tests in this UnitTest object and prints the result. + // Returns 0 if successful, or 1 otherwise. + // + // This method can only be called from the main thread. + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + int Run() GTEST_MUST_USE_RESULT_; + + // Returns the working directory when the first TEST() or TEST_F() + // was executed. The UnitTest object owns the string. + const char* original_working_dir() const; + + // Returns the TestSuite object for the test that's currently running, + // or NULL if no test is running. + const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_); + +// Legacy API is still available but deprecated +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_); +#endif + + // Returns the TestInfo object for the test that's currently running, + // or NULL if no test is running. + const TestInfo* current_test_info() const + GTEST_LOCK_EXCLUDED_(mutex_); + + // Returns the random seed used at the start of the current test run. + int random_seed() const; + + // Returns the ParameterizedTestSuiteRegistry object used to keep track of + // value-parameterized tests and instantiate and register them. + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + internal::ParameterizedTestSuiteRegistry& parameterized_test_registry() + GTEST_LOCK_EXCLUDED_(mutex_); + + // Gets the number of successful test suites. + int successful_test_suite_count() const; + + // Gets the number of failed test suites. + int failed_test_suite_count() const; + + // Gets the number of all test suites. + int total_test_suite_count() const; + + // Gets the number of all test suites that contain at least one test + // that should run. + int test_suite_to_run_count() const; + + // Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + int successful_test_case_count() const; + int failed_test_case_count() const; + int total_test_case_count() const; + int test_case_to_run_count() const; +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Gets the number of successful tests. + int successful_test_count() const; + + // Gets the number of skipped tests. + int skipped_test_count() const; + + // Gets the number of failed tests. + int failed_test_count() const; + + // Gets the number of disabled tests that will be reported in the XML report. + int reportable_disabled_test_count() const; + + // Gets the number of disabled tests. + int disabled_test_count() const; + + // Gets the number of tests to be printed in the XML report. + int reportable_test_count() const; + + // Gets the number of all tests. + int total_test_count() const; + + // Gets the number of tests that should run. + int test_to_run_count() const; + + // Gets the time of the test program start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp() const; + + // Gets the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const; + + // Returns true if and only if the unit test passed (i.e. all test suites + // passed). + bool Passed() const; + + // Returns true if and only if the unit test failed (i.e. some test suite + // failed or something outside of all tests failed). + bool Failed() const; + + // Gets the i-th test suite among all the test suites. i can range from 0 to + // total_test_suite_count() - 1. If i is not in that range, returns NULL. + const TestSuite* GetTestSuite(int i) const; + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + const TestCase* GetTestCase(int i) const; +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + // Returns the TestResult containing information on test failures and + // properties logged outside of individual test suites. + const TestResult& ad_hoc_test_result() const; + + // Returns the list of event listeners that can be used to track events + // inside Google Test. + TestEventListeners& listeners(); + + private: + // Registers and returns a global test environment. When a test + // program is run, all global test environments will be set-up in + // the order they were registered. After all tests in the program + // have finished, all global test environments will be torn-down in + // the *reverse* order they were registered. + // + // The UnitTest object takes ownership of the given environment. + // + // This method can only be called from the main thread. + Environment* AddEnvironment(Environment* env); + + // Adds a TestPartResult to the current TestResult object. All + // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) + // eventually call this to report their results. The user code + // should use the assertion macros instead of calling this directly. + void AddTestPartResult(TestPartResult::Type result_type, + const char* file_name, + int line_number, + const std::string& message, + const std::string& os_stack_trace) + GTEST_LOCK_EXCLUDED_(mutex_); + + // Adds a TestProperty to the current TestResult object when invoked from + // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked + // from SetUpTestSuite or TearDownTestSuite, or to the global property set + // when invoked elsewhere. If the result already contains a property with + // the same key, the value will be updated. + void RecordProperty(const std::string& key, const std::string& value); + + // Gets the i-th test suite among all the test suites. i can range from 0 to + // total_test_suite_count() - 1. If i is not in that range, returns NULL. + TestSuite* GetMutableTestSuite(int i); + + // Accessors for the implementation object. + internal::UnitTestImpl* impl() { return impl_; } + const internal::UnitTestImpl* impl() const { return impl_; } + + // These classes and functions are friends as they need to access private + // members of UnitTest. + friend class ScopedTrace; + friend class Test; + friend class internal::AssertHelper; + friend class internal::StreamingListenerTest; + friend class internal::UnitTestRecordPropertyTestHelper; + friend Environment* AddGlobalTestEnvironment(Environment* env); + friend internal::UnitTestImpl* internal::GetUnitTestImpl(); + friend void internal::ReportFailureInUnknownLocation( + TestPartResult::Type result_type, + const std::string& message); + + // Creates an empty UnitTest. + UnitTest(); + + // D'tor + virtual ~UnitTest(); + + // Pushes a trace defined by SCOPED_TRACE() on to the per-thread + // Google Test trace stack. + void PushGTestTrace(const internal::TraceInfo& trace) + GTEST_LOCK_EXCLUDED_(mutex_); + + // Pops a trace from the per-thread Google Test trace stack. + void PopGTestTrace() + GTEST_LOCK_EXCLUDED_(mutex_); + + // Protects mutable state in *impl_. This is mutable as some const + // methods need to lock it too. + mutable internal::Mutex mutex_; + + // Opaque implementation object. This field is never changed once + // the object is constructed. We don't mark it as const here, as + // doing so will cause a warning in the constructor of UnitTest. + // Mutable state in *impl_ is protected by mutex_. + internal::UnitTestImpl* impl_; + + // We disallow copying UnitTest. + GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest); +}; + +// A convenient wrapper for adding an environment for the test +// program. +// +// You should call this before RUN_ALL_TESTS() is called, probably in +// main(). If you use gtest_main, you need to call this before main() +// starts for it to take effect. For example, you can define a global +// variable like this: +// +// testing::Environment* const foo_env = +// testing::AddGlobalTestEnvironment(new FooEnvironment); +// +// However, we strongly recommend you to write your own main() and +// call AddGlobalTestEnvironment() there, as relying on initialization +// of global variables makes the code harder to read and may cause +// problems when you register multiple environments from different +// translation units and the environments have dependencies among them +// (remember that the compiler doesn't guarantee the order in which +// global variables from different translation units are initialized). +inline Environment* AddGlobalTestEnvironment(Environment* env) { + return UnitTest::GetInstance()->AddEnvironment(env); +} + +// Initializes Google Test. This must be called before calling +// RUN_ALL_TESTS(). In particular, it parses a command line for the +// flags that Google Test recognizes. Whenever a Google Test flag is +// seen, it is removed from argv, and *argc is decremented. +// +// No value is returned. Instead, the Google Test flag variables are +// updated. +// +// Calling the function for the second time has no user-visible effect. +GTEST_API_ void InitGoogleTest(int* argc, char** argv); + +// This overloaded version can be used in Windows programs compiled in +// UNICODE mode. +GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv); + +// This overloaded version can be used on Arduino/embedded platforms where +// there is no argc/argv. +GTEST_API_ void InitGoogleTest(); + +namespace internal { + +// Separate the error generating code from the code path to reduce the stack +// frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers +// when calling EXPECT_* in a tight loop. +template +AssertionResult CmpHelperEQFailure(const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, const T2& rhs) { + return EqFailure(lhs_expression, + rhs_expression, + FormatForComparisonFailureMessage(lhs, rhs), + FormatForComparisonFailureMessage(rhs, lhs), + false); +} + +// This block of code defines operator==/!= +// to block lexical scope lookup. +// It prevents using invalid operator==/!= defined at namespace scope. +struct faketype {}; +inline bool operator==(faketype, faketype) { return true; } +inline bool operator!=(faketype, faketype) { return false; } + +// The helper function for {ASSERT|EXPECT}_EQ. +template +AssertionResult CmpHelperEQ(const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, + const T2& rhs) { + if (lhs == rhs) { + return AssertionSuccess(); + } + + return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs); +} + +// With this overloaded version, we allow anonymous enums to be used +// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums +// can be implicitly cast to BiggestInt. +GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression, + const char* rhs_expression, + BiggestInt lhs, + BiggestInt rhs); + +class EqHelper { + public: + // This templatized version is for the general case. + template < + typename T1, typename T2, + // Disable this overload for cases where one argument is a pointer + // and the other is the null pointer constant. + typename std::enable_if::value || + !std::is_pointer::value>::type* = nullptr> + static AssertionResult Compare(const char* lhs_expression, + const char* rhs_expression, const T1& lhs, + const T2& rhs) { + return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); + } + + // With this overloaded version, we allow anonymous enums to be used + // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous + // enums can be implicitly cast to BiggestInt. + // + // Even though its body looks the same as the above version, we + // cannot merge the two, as it will make anonymous enums unhappy. + static AssertionResult Compare(const char* lhs_expression, + const char* rhs_expression, + BiggestInt lhs, + BiggestInt rhs) { + return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); + } + + template + static AssertionResult Compare( + const char* lhs_expression, const char* rhs_expression, + // Handle cases where '0' is used as a null pointer literal. + std::nullptr_t /* lhs */, T* rhs) { + // We already know that 'lhs' is a null pointer. + return CmpHelperEQ(lhs_expression, rhs_expression, static_cast(nullptr), + rhs); + } +}; + +// Separate the error generating code from the code path to reduce the stack +// frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers +// when calling EXPECT_OP in a tight loop. +template +AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, + const T1& val1, const T2& val2, + const char* op) { + return AssertionFailure() + << "Expected: (" << expr1 << ") " << op << " (" << expr2 + << "), actual: " << FormatForComparisonFailureMessage(val1, val2) + << " vs " << FormatForComparisonFailureMessage(val2, val1); +} + +// A macro for implementing the helper functions needed to implement +// ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste +// of similar code. +// +// For each templatized helper function, we also define an overloaded +// version for BiggestInt in order to reduce code bloat and allow +// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled +// with gcc 4. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ +template \ +AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ + const T1& val1, const T2& val2) {\ + if (val1 op val2) {\ + return AssertionSuccess();\ + } else {\ + return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\ + }\ +}\ +GTEST_API_ AssertionResult CmpHelper##op_name(\ + const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) + +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +// Implements the helper function for {ASSERT|EXPECT}_NE +GTEST_IMPL_CMP_HELPER_(NE, !=); +// Implements the helper function for {ASSERT|EXPECT}_LE +GTEST_IMPL_CMP_HELPER_(LE, <=); +// Implements the helper function for {ASSERT|EXPECT}_LT +GTEST_IMPL_CMP_HELPER_(LT, <); +// Implements the helper function for {ASSERT|EXPECT}_GE +GTEST_IMPL_CMP_HELPER_(GE, >=); +// Implements the helper function for {ASSERT|EXPECT}_GT +GTEST_IMPL_CMP_HELPER_(GT, >); + +#undef GTEST_IMPL_CMP_HELPER_ + +// The helper function for {ASSERT|EXPECT}_STREQ. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + +// The helper function for {ASSERT|EXPECT}_STRCASEEQ. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + +// The helper function for {ASSERT|EXPECT}_STRNE. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + +// The helper function for {ASSERT|EXPECT}_STRCASENE. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + + +// Helper function for *_STREQ on wide strings. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, + const char* s2_expression, + const wchar_t* s1, + const wchar_t* s2); + +// Helper function for *_STRNE on wide strings. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const wchar_t* s1, + const wchar_t* s2); + +} // namespace internal + +// IsSubstring() and IsNotSubstring() are intended to be used as the +// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by +// themselves. They check whether needle is a substring of haystack +// (NULL is considered a substring of itself only), and return an +// appropriate error message when they fail. +// +// The {needle,haystack}_expr arguments are the stringified +// expressions that generated the two real arguments. +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack); +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack); +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack); + +#if GTEST_HAS_STD_WSTRING +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack); +#endif // GTEST_HAS_STD_WSTRING + +namespace internal { + +// Helper template function for comparing floating-points. +// +// Template parameter: +// +// RawType: the raw floating-point type (either float or double) +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +template +AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, + const char* rhs_expression, + RawType lhs_value, + RawType rhs_value) { + const FloatingPoint lhs(lhs_value), rhs(rhs_value); + + if (lhs.AlmostEquals(rhs)) { + return AssertionSuccess(); + } + + ::std::stringstream lhs_ss; + lhs_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << lhs_value; + + ::std::stringstream rhs_ss; + rhs_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << rhs_value; + + return EqFailure(lhs_expression, + rhs_expression, + StringStreamToString(&lhs_ss), + StringStreamToString(&rhs_ss), + false); +} + +// Helper function for implementing ASSERT_NEAR. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, + const char* expr2, + const char* abs_error_expr, + double val1, + double val2, + double abs_error); + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// A class that enables one to stream messages to assertion macros +class GTEST_API_ AssertHelper { + public: + // Constructor. + AssertHelper(TestPartResult::Type type, + const char* file, + int line, + const char* message); + ~AssertHelper(); + + // Message assignment is a semantic trick to enable assertion + // streaming; see the GTEST_MESSAGE_ macro below. + void operator=(const Message& message) const; + + private: + // We put our data in a struct so that the size of the AssertHelper class can + // be as small as possible. This is important because gcc is incapable of + // re-using stack space even for temporary variables, so every EXPECT_EQ + // reserves stack space for another AssertHelper. + struct AssertHelperData { + AssertHelperData(TestPartResult::Type t, + const char* srcfile, + int line_num, + const char* msg) + : type(t), file(srcfile), line(line_num), message(msg) { } + + TestPartResult::Type const type; + const char* const file; + int const line; + std::string const message; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData); + }; + + AssertHelperData* const data_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); +}; + +enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW }; + +GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color, + const char* fmt, + ...); + +} // namespace internal + +// The pure interface class that all value-parameterized tests inherit from. +// A value-parameterized class must inherit from both ::testing::Test and +// ::testing::WithParamInterface. In most cases that just means inheriting +// from ::testing::TestWithParam, but more complicated test hierarchies +// may need to inherit from Test and WithParamInterface at different levels. +// +// This interface has support for accessing the test parameter value via +// the GetParam() method. +// +// Use it with one of the parameter generator defining functions, like Range(), +// Values(), ValuesIn(), Bool(), and Combine(). +// +// class FooTest : public ::testing::TestWithParam { +// protected: +// FooTest() { +// // Can use GetParam() here. +// } +// ~FooTest() override { +// // Can use GetParam() here. +// } +// void SetUp() override { +// // Can use GetParam() here. +// } +// void TearDown override { +// // Can use GetParam() here. +// } +// }; +// TEST_P(FooTest, DoesBar) { +// // Can use GetParam() method here. +// Foo foo; +// ASSERT_TRUE(foo.DoesBar(GetParam())); +// } +// INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10)); + +template +class WithParamInterface { + public: + typedef T ParamType; + virtual ~WithParamInterface() {} + + // The current parameter value. Is also available in the test fixture's + // constructor. + static const ParamType& GetParam() { + GTEST_CHECK_(parameter_ != nullptr) + << "GetParam() can only be called inside a value-parameterized test " + << "-- did you intend to write TEST_P instead of TEST_F?"; + return *parameter_; + } + + private: + // Sets parameter value. The caller is responsible for making sure the value + // remains alive and unchanged throughout the current test. + static void SetParam(const ParamType* parameter) { + parameter_ = parameter; + } + + // Static value used for accessing parameter during a test lifetime. + static const ParamType* parameter_; + + // TestClass must be a subclass of WithParamInterface and Test. + template friend class internal::ParameterizedTestFactory; +}; + +template +const T* WithParamInterface::parameter_ = nullptr; + +// Most value-parameterized classes can ignore the existence of +// WithParamInterface, and can just inherit from ::testing::TestWithParam. + +template +class TestWithParam : public Test, public WithParamInterface { +}; + +// Macros for indicating success/failure in test code. + +// Skips test in runtime. +// Skipping test aborts current function. +// Skipped tests are neither successful nor failed. +#define GTEST_SKIP() GTEST_SKIP_("Skipped") + +// ADD_FAILURE unconditionally adds a failure to the current test. +// SUCCEED generates a success - it doesn't automatically make the +// current test successful, as a test is only successful when it has +// no failure. +// +// EXPECT_* verifies that a certain condition is satisfied. If not, +// it behaves like ADD_FAILURE. In particular: +// +// EXPECT_TRUE verifies that a Boolean condition is true. +// EXPECT_FALSE verifies that a Boolean condition is false. +// +// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except +// that they will also abort the current function on failure. People +// usually want the fail-fast behavior of FAIL and ASSERT_*, but those +// writing data-driven tests often find themselves using ADD_FAILURE +// and EXPECT_* more. + +// Generates a nonfatal failure with a generic message. +#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed") + +// Generates a nonfatal failure at the given source file location with +// a generic message. +#define ADD_FAILURE_AT(file, line) \ + GTEST_MESSAGE_AT_(file, line, "Failed", \ + ::testing::TestPartResult::kNonFatalFailure) + +// Generates a fatal failure with a generic message. +#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed") + +// Like GTEST_FAIL(), but at the given source file location. +#define GTEST_FAIL_AT(file, line) \ + GTEST_MESSAGE_AT_(file, line, "Failed", \ + ::testing::TestPartResult::kFatalFailure) + +// Define this macro to 1 to omit the definition of FAIL(), which is a +// generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_FAIL +# define FAIL() GTEST_FAIL() +#endif + +// Generates a success with a generic message. +#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded") + +// Define this macro to 1 to omit the definition of SUCCEED(), which +// is a generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_SUCCEED +# define SUCCEED() GTEST_SUCCEED() +#endif + +// Macros for testing exceptions. +// +// * {ASSERT|EXPECT}_THROW(statement, expected_exception): +// Tests that the statement throws the expected exception. +// * {ASSERT|EXPECT}_NO_THROW(statement): +// Tests that the statement doesn't throw any exception. +// * {ASSERT|EXPECT}_ANY_THROW(statement): +// Tests that the statement throws an exception. + +#define EXPECT_THROW(statement, expected_exception) \ + GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_) +#define EXPECT_NO_THROW(statement) \ + GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_) +#define EXPECT_ANY_THROW(statement) \ + GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_) +#define ASSERT_THROW(statement, expected_exception) \ + GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) +#define ASSERT_NO_THROW(statement) \ + GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) +#define ASSERT_ANY_THROW(statement) \ + GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) + +// Boolean assertions. Condition can be either a Boolean expression or an +// AssertionResult. For more information on how to use AssertionResult with +// these macros see comments on that class. +#define EXPECT_TRUE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ + GTEST_NONFATAL_FAILURE_) +#define EXPECT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ + GTEST_NONFATAL_FAILURE_) +#define ASSERT_TRUE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ + GTEST_FATAL_FAILURE_) +#define ASSERT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ + GTEST_FATAL_FAILURE_) + +// Macros for testing equalities and inequalities. +// +// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2 +// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 +// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 +// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 +// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 +// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 +// +// When they are not, Google Test prints both the tested expressions and +// their actual values. The values must be compatible built-in types, +// or you will get a compiler error. By "compatible" we mean that the +// values can be compared by the respective operator. +// +// Note: +// +// 1. It is possible to make a user-defined type work with +// {ASSERT|EXPECT}_??(), but that requires overloading the +// comparison operators and is thus discouraged by the Google C++ +// Usage Guide. Therefore, you are advised to use the +// {ASSERT|EXPECT}_TRUE() macro to assert that two objects are +// equal. +// +// 2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on +// pointers (in particular, C strings). Therefore, if you use it +// with two C strings, you are testing how their locations in memory +// are related, not how their content is related. To compare two C +// strings by content, use {ASSERT|EXPECT}_STR*(). +// +// 3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to +// {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you +// what the actual value is when it fails, and similarly for the +// other comparisons. +// +// 4. Do not depend on the order in which {ASSERT|EXPECT}_??() +// evaluate their arguments, which is undefined. +// +// 5. These macros evaluate their arguments exactly once. +// +// Examples: +// +// EXPECT_NE(Foo(), 5); +// EXPECT_EQ(a_pointer, NULL); +// ASSERT_LT(i, array_size); +// ASSERT_GT(records.size(), 0) << "There is no record left."; + +#define EXPECT_EQ(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) +#define EXPECT_NE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) +#define EXPECT_LE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) +#define EXPECT_LT(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) +#define EXPECT_GE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) +#define EXPECT_GT(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) + +#define GTEST_ASSERT_EQ(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) +#define GTEST_ASSERT_NE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) +#define GTEST_ASSERT_LE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) +#define GTEST_ASSERT_LT(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) +#define GTEST_ASSERT_GE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) +#define GTEST_ASSERT_GT(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) + +// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of +// ASSERT_XY(), which clashes with some users' own code. + +#if !GTEST_DONT_DEFINE_ASSERT_EQ +# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_NE +# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_LE +# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_LT +# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_GE +# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_GT +# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) +#endif + +// C-string Comparisons. All tests treat NULL and any non-NULL string +// as different. Two NULLs are equal. +// +// * {ASSERT|EXPECT}_STREQ(s1, s2): Tests that s1 == s2 +// * {ASSERT|EXPECT}_STRNE(s1, s2): Tests that s1 != s2 +// * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case +// * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case +// +// For wide or narrow string objects, you can use the +// {ASSERT|EXPECT}_??() macros. +// +// Don't depend on the order in which the arguments are evaluated, +// which is undefined. +// +// These macros evaluate their arguments exactly once. + +#define EXPECT_STREQ(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) +#define EXPECT_STRNE(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) +#define EXPECT_STRCASEEQ(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) +#define EXPECT_STRCASENE(s1, s2)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) + +#define ASSERT_STREQ(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) +#define ASSERT_STRNE(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) +#define ASSERT_STRCASEEQ(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) +#define ASSERT_STRCASENE(s1, s2)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) + +// Macros for comparing floating-point numbers. +// +// * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2): +// Tests that two float values are almost equal. +// * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2): +// Tests that two double values are almost equal. +// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): +// Tests that v1 and v2 are within the given distance to each other. +// +// Google Test uses ULP-based comparison to automatically pick a default +// error bound that is appropriate for the operands. See the +// FloatingPoint template class in gtest-internal.h if you are +// interested in the implementation details. + +#define EXPECT_FLOAT_EQ(val1, val2)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + val1, val2) + +#define EXPECT_DOUBLE_EQ(val1, val2)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + val1, val2) + +#define ASSERT_FLOAT_EQ(val1, val2)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + val1, val2) + +#define ASSERT_DOUBLE_EQ(val1, val2)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + val1, val2) + +#define EXPECT_NEAR(val1, val2, abs_error)\ + EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ + val1, val2, abs_error) + +#define ASSERT_NEAR(val1, val2, abs_error)\ + ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ + val1, val2, abs_error) + +// These predicate format functions work on floating-point values, and +// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. +// +// EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); + +// Asserts that val1 is less than, or almost equal to, val2. Fails +// otherwise. In particular, it fails if either val1 or val2 is NaN. +GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2, + float val1, float val2); +GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, + double val1, double val2); + + +#if GTEST_OS_WINDOWS + +// Macros that test for HRESULT failure and success, these are only useful +// on Windows, and rely on Windows SDK macros and APIs to compile. +// +// * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr) +// +// When expr unexpectedly fails or succeeds, Google Test prints the +// expected result and the actual result with both a human-readable +// string representation of the error, if available, as well as the +// hex result code. +# define EXPECT_HRESULT_SUCCEEDED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) + +# define ASSERT_HRESULT_SUCCEEDED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) + +# define EXPECT_HRESULT_FAILED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) + +# define ASSERT_HRESULT_FAILED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) + +#endif // GTEST_OS_WINDOWS + +// Macros that execute statement and check that it doesn't generate new fatal +// failures in the current thread. +// +// * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement); +// +// Examples: +// +// EXPECT_NO_FATAL_FAILURE(Process()); +// ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed"; +// +#define ASSERT_NO_FATAL_FAILURE(statement) \ + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_) +#define EXPECT_NO_FATAL_FAILURE(statement) \ + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) + +// Causes a trace (including the given source file path and line number, +// and the given message) to be included in every test failure message generated +// by code in the scope of the lifetime of an instance of this class. The effect +// is undone with the destruction of the instance. +// +// The message argument can be anything streamable to std::ostream. +// +// Example: +// testing::ScopedTrace trace("file.cc", 123, "message"); +// +class GTEST_API_ ScopedTrace { + public: + // The c'tor pushes the given source file location and message onto + // a trace stack maintained by Google Test. + + // Template version. Uses Message() to convert the values into strings. + // Slow, but flexible. + template + ScopedTrace(const char* file, int line, const T& message) { + PushTrace(file, line, (Message() << message).GetString()); + } + + // Optimize for some known types. + ScopedTrace(const char* file, int line, const char* message) { + PushTrace(file, line, message ? message : "(null)"); + } + + ScopedTrace(const char* file, int line, const std::string& message) { + PushTrace(file, line, message); + } + + // The d'tor pops the info pushed by the c'tor. + // + // Note that the d'tor is not virtual in order to be efficient. + // Don't inherit from ScopedTrace! + ~ScopedTrace(); + + private: + void PushTrace(const char* file, int line, std::string message); + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); +} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its + // c'tor and d'tor. Therefore it doesn't + // need to be used otherwise. + +// Causes a trace (including the source file path, the current line +// number, and the given message) to be included in every test failure +// message generated by code in the current scope. The effect is +// undone when the control leaves the current scope. +// +// The message argument can be anything streamable to std::ostream. +// +// In the implementation, we include the current line number as part +// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s +// to appear in the same block - as long as they are on different +// lines. +// +// Assuming that each thread maintains its own stack of traces. +// Therefore, a SCOPED_TRACE() would (correctly) only affect the +// assertions in its own thread. +#define SCOPED_TRACE(message) \ + ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ + __FILE__, __LINE__, (message)) + +// Compile-time assertion for type equality. +// StaticAssertTypeEq() compiles if and only if type1 and type2 +// are the same type. The value it returns is not interesting. +// +// Instead of making StaticAssertTypeEq a class template, we make it a +// function template that invokes a helper class template. This +// prevents a user from misusing StaticAssertTypeEq by +// defining objects of that type. +// +// CAVEAT: +// +// When used inside a method of a class template, +// StaticAssertTypeEq() is effective ONLY IF the method is +// instantiated. For example, given: +// +// template class Foo { +// public: +// void Bar() { testing::StaticAssertTypeEq(); } +// }; +// +// the code: +// +// void Test1() { Foo foo; } +// +// will NOT generate a compiler error, as Foo::Bar() is never +// actually instantiated. Instead, you need: +// +// void Test2() { Foo foo; foo.Bar(); } +// +// to cause a compiler error. +template +constexpr bool StaticAssertTypeEq() noexcept { + static_assert(std::is_same::value, + "type1 and type2 are not the same type"); + return true; +} + +// Defines a test. +// +// The first parameter is the name of the test suite, and the second +// parameter is the name of the test within the test suite. +// +// The convention is to end the test suite name with "Test". For +// example, a test suite for the Foo class can be named FooTest. +// +// Test code should appear between braces after an invocation of +// this macro. Example: +// +// TEST(FooTest, InitializesCorrectly) { +// Foo foo; +// EXPECT_TRUE(foo.StatusIsOK()); +// } + +// Note that we call GetTestTypeId() instead of GetTypeId< +// ::testing::Test>() here to get the type ID of testing::Test. This +// is to work around a suspected linker bug when using Google Test as +// a framework on Mac OS X. The bug causes GetTypeId< +// ::testing::Test>() to return different values depending on whether +// the call is from the Google Test framework itself or from user test +// code. GetTestTypeId() is guaranteed to always return the same +// value, as it always calls GetTypeId<>() from the Google Test +// framework. +#define GTEST_TEST(test_suite_name, test_name) \ + GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \ + ::testing::internal::GetTestTypeId()) + +// Define this macro to 1 to omit the definition of TEST(), which +// is a generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_TEST +#define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name) +#endif + +// Defines a test that uses a test fixture. +// +// The first parameter is the name of the test fixture class, which +// also doubles as the test suite name. The second parameter is the +// name of the test within the test suite. +// +// A test fixture class must be declared earlier. The user should put +// the test code between braces after using this macro. Example: +// +// class FooTest : public testing::Test { +// protected: +// void SetUp() override { b_.AddElement(3); } +// +// Foo a_; +// Foo b_; +// }; +// +// TEST_F(FooTest, InitializesCorrectly) { +// EXPECT_TRUE(a_.StatusIsOK()); +// } +// +// TEST_F(FooTest, ReturnsElementCountCorrectly) { +// EXPECT_EQ(a_.size(), 0); +// EXPECT_EQ(b_.size(), 1); +// } +// +// GOOGLETEST_CM0011 DO NOT DELETE +#define TEST_F(test_fixture, test_name)\ + GTEST_TEST_(test_fixture, test_name, test_fixture, \ + ::testing::internal::GetTypeId()) + +// Returns a path to temporary directory. +// Tries to determine an appropriate directory for the platform. +GTEST_API_ std::string TempDir(); + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +// Dynamically registers a test with the framework. +// +// This is an advanced API only to be used when the `TEST` macros are +// insufficient. The macros should be preferred when possible, as they avoid +// most of the complexity of calling this function. +// +// The `factory` argument is a factory callable (move-constructible) object or +// function pointer that creates a new instance of the Test object. It +// handles ownership to the caller. The signature of the callable is +// `Fixture*()`, where `Fixture` is the test fixture class for the test. All +// tests registered with the same `test_suite_name` must return the same +// fixture type. This is checked at runtime. +// +// The framework will infer the fixture class from the factory and will call +// the `SetUpTestSuite` and `TearDownTestSuite` for it. +// +// Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is +// undefined. +// +// Use case example: +// +// class MyFixture : public ::testing::Test { +// public: +// // All of these optional, just like in regular macro usage. +// static void SetUpTestSuite() { ... } +// static void TearDownTestSuite() { ... } +// void SetUp() override { ... } +// void TearDown() override { ... } +// }; +// +// class MyTest : public MyFixture { +// public: +// explicit MyTest(int data) : data_(data) {} +// void TestBody() override { ... } +// +// private: +// int data_; +// }; +// +// void RegisterMyTests(const std::vector& values) { +// for (int v : values) { +// ::testing::RegisterTest( +// "MyFixture", ("Test" + std::to_string(v)).c_str(), nullptr, +// std::to_string(v).c_str(), +// __FILE__, __LINE__, +// // Important to use the fixture type as the return type here. +// [=]() -> MyFixture* { return new MyTest(v); }); +// } +// } +// ... +// int main(int argc, char** argv) { +// std::vector values_to_test = LoadValuesFromConfig(); +// RegisterMyTests(values_to_test); +// ... +// return RUN_ALL_TESTS(); +// } +// +template +TestInfo* RegisterTest(const char* test_suite_name, const char* test_name, + const char* type_param, const char* value_param, + const char* file, int line, Factory factory) { + using TestT = typename std::remove_pointer::type; + + class FactoryImpl : public internal::TestFactoryBase { + public: + explicit FactoryImpl(Factory f) : factory_(std::move(f)) {} + Test* CreateTest() override { return factory_(); } + + private: + Factory factory_; + }; + + return internal::MakeAndRegisterTestInfo( + test_suite_name, test_name, type_param, value_param, + internal::CodeLocation(file, line), internal::GetTypeId(), + internal::SuiteApiResolver::GetSetUpCaseOrSuite(file, line), + internal::SuiteApiResolver::GetTearDownCaseOrSuite(file, line), + new FactoryImpl{std::move(factory)}); +} + +} // namespace testing + +// Use this function in main() to run all tests. It returns 0 if all +// tests are successful, or 1 otherwise. +// +// RUN_ALL_TESTS() should be invoked after the command line has been +// parsed by InitGoogleTest(). +// +// This function was formerly a macro; thus, it is in the global +// namespace and has an all-caps name. +int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_; + +inline int RUN_ALL_TESTS() { + return ::testing::UnitTest::GetInstance()->Run(); +} + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +#endif // GTEST_INCLUDE_GTEST_GTEST_H_ diff --git a/include/gtest/gtest_pred_impl.h b/include/gtest/gtest_pred_impl.h new file mode 100644 index 0000000..d514255 --- /dev/null +++ b/include/gtest/gtest_pred_impl.h @@ -0,0 +1,359 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This file is AUTOMATICALLY GENERATED on 01/02/2019 by command +// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! +// +// Implements a family of generic predicate assertion macros. +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ + +#include "gtest/gtest.h" + +namespace testing { + +// This header implements a family of generic predicate assertion +// macros: +// +// ASSERT_PRED_FORMAT1(pred_format, v1) +// ASSERT_PRED_FORMAT2(pred_format, v1, v2) +// ... +// +// where pred_format is a function or functor that takes n (in the +// case of ASSERT_PRED_FORMATn) values and their source expression +// text, and returns a testing::AssertionResult. See the definition +// of ASSERT_EQ in gtest.h for an example. +// +// If you don't care about formatting, you can use the more +// restrictive version: +// +// ASSERT_PRED1(pred, v1) +// ASSERT_PRED2(pred, v1, v2) +// ... +// +// where pred is an n-ary function or functor that returns bool, +// and the values v1, v2, ..., must support the << operator for +// streaming to std::ostream. +// +// We also define the EXPECT_* variations. +// +// For now we only support predicates whose arity is at most 5. +// Please email googletestframework@googlegroups.com if you need +// support for higher arities. + +// GTEST_ASSERT_ is the basic statement to which all of the assertions +// in this file reduce. Don't use this in your code. + +#define GTEST_ASSERT_(expression, on_failure) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar = (expression)) \ + ; \ + else \ + on_failure(gtest_ar.failure_message()) + + +// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use +// this in your code. +template +AssertionResult AssertPred1Helper(const char* pred_text, + const char* e1, + Pred pred, + const T1& v1) { + if (pred(v1)) return AssertionSuccess(); + + return AssertionFailure() + << pred_text << "(" << e1 << ") evaluates to false, where" + << "\n" + << e1 << " evaluates to " << ::testing::PrintToString(v1); +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1. +// Don't use this in your code. +#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, v1), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use +// this in your code. +#define GTEST_PRED1_(pred, v1, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \ + #v1, \ + pred, \ + v1), on_failure) + +// Unary predicate assertion macros. +#define EXPECT_PRED_FORMAT1(pred_format, v1) \ + GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED1(pred, v1) \ + GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT1(pred_format, v1) \ + GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED1(pred, v1) \ + GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use +// this in your code. +template +AssertionResult AssertPred2Helper(const char* pred_text, + const char* e1, + const char* e2, + Pred pred, + const T1& v1, + const T2& v2) { + if (pred(v1, v2)) return AssertionSuccess(); + + return AssertionFailure() + << pred_text << "(" << e1 << ", " << e2 + << ") evaluates to false, where" + << "\n" + << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n" + << e2 << " evaluates to " << ::testing::PrintToString(v2); +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2. +// Don't use this in your code. +#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use +// this in your code. +#define GTEST_PRED2_(pred, v1, v2, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \ + #v1, \ + #v2, \ + pred, \ + v1, \ + v2), on_failure) + +// Binary predicate assertion macros. +#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \ + GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED2(pred, v1, v2) \ + GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \ + GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED2(pred, v1, v2) \ + GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use +// this in your code. +template +AssertionResult AssertPred3Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3) { + if (pred(v1, v2, v3)) return AssertionSuccess(); + + return AssertionFailure() + << pred_text << "(" << e1 << ", " << e2 << ", " << e3 + << ") evaluates to false, where" + << "\n" + << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n" + << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n" + << e3 << " evaluates to " << ::testing::PrintToString(v3); +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3. +// Don't use this in your code. +#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use +// this in your code. +#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + pred, \ + v1, \ + v2, \ + v3), on_failure) + +// Ternary predicate assertion macros. +#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \ + GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED3(pred, v1, v2, v3) \ + GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \ + GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED3(pred, v1, v2, v3) \ + GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use +// this in your code. +template +AssertionResult AssertPred4Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + const char* e4, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3, + const T4& v4) { + if (pred(v1, v2, v3, v4)) return AssertionSuccess(); + + return AssertionFailure() + << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4 + << ") evaluates to false, where" + << "\n" + << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n" + << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n" + << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n" + << e4 << " evaluates to " << ::testing::PrintToString(v4); +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4. +// Don't use this in your code. +#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use +// this in your code. +#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + #v4, \ + pred, \ + v1, \ + v2, \ + v3, \ + v4), on_failure) + +// 4-ary predicate assertion macros. +#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \ + GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED4(pred, v1, v2, v3, v4) \ + GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \ + GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED4(pred, v1, v2, v3, v4) \ + GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use +// this in your code. +template +AssertionResult AssertPred5Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + const char* e4, + const char* e5, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3, + const T4& v4, + const T5& v5) { + if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess(); + + return AssertionFailure() + << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4 + << ", " << e5 << ") evaluates to false, where" + << "\n" + << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n" + << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n" + << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n" + << e4 << " evaluates to " << ::testing::PrintToString(v4) << "\n" + << e5 << " evaluates to " << ::testing::PrintToString(v5); +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5. +// Don't use this in your code. +#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use +// this in your code. +#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + #v4, \ + #v5, \ + pred, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5), on_failure) + +// 5-ary predicate assertion macros. +#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \ + GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \ + GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \ + GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \ + GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_) + + + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ diff --git a/include/gtest/gtest_prod.h b/include/gtest/gtest_prod.h new file mode 100644 index 0000000..e651671 --- /dev/null +++ b/include/gtest/gtest_prod.h @@ -0,0 +1,61 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// Google C++ Testing and Mocking Framework definitions useful in production code. +// GOOGLETEST_CM0003 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ + +// When you need to test the private or protected members of a class, +// use the FRIEND_TEST macro to declare your tests as friends of the +// class. For example: +// +// class MyClass { +// private: +// void PrivateMethod(); +// FRIEND_TEST(MyClassTest, PrivateMethodWorks); +// }; +// +// class MyClassTest : public testing::Test { +// // ... +// }; +// +// TEST_F(MyClassTest, PrivateMethodWorks) { +// // Can call MyClass::PrivateMethod() here. +// } +// +// Note: The test class must be in the same namespace as the class being tested. +// For example, putting MyClassTest in an anonymous namespace will not work. + +#define FRIEND_TEST(test_case_name, test_name)\ +friend class test_case_name##_##test_name##_Test + +#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ diff --git a/include/gtest/internal/custom/README.md b/include/gtest/internal/custom/README.md new file mode 100644 index 0000000..ff391fb --- /dev/null +++ b/include/gtest/internal/custom/README.md @@ -0,0 +1,56 @@ +# Customization Points + +The custom directory is an injection point for custom user configurations. + +## Header `gtest.h` + +### The following macros can be defined: + +* `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of + `OsStackTraceGetterInterface`. +* `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See + `testing::TempDir` for semantics and signature. + +## Header `gtest-port.h` + +The following macros can be defined: + +### Flag related macros: + +* `GTEST_FLAG(flag_name)` +* `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its + own flagfile flag parsing. +* `GTEST_DECLARE_bool_(name)` +* `GTEST_DECLARE_int32_(name)` +* `GTEST_DECLARE_string_(name)` +* `GTEST_DEFINE_bool_(name, default_val, doc)` +* `GTEST_DEFINE_int32_(name, default_val, doc)` +* `GTEST_DEFINE_string_(name, default_val, doc)` + +### Logging: + +* `GTEST_LOG_(severity)` +* `GTEST_CHECK_(condition)` +* Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. + +### Threading: + +* `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. +* `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` + are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` + and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` +* `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` +* `GTEST_LOCK_EXCLUDED_(locks)` + +### Underlying library support features + +* `GTEST_HAS_CXXABI_H_` + +### Exporting API symbols: + +* `GTEST_API_` - Specifier for exported symbols. + +## Header `gtest-printers.h` + +* See documentation at `gtest/gtest-printers.h` for details on how to define a + custom printer. diff --git a/include/gtest/internal/custom/gtest-port.h b/include/gtest/internal/custom/gtest-port.h new file mode 100644 index 0000000..cd85d95 --- /dev/null +++ b/include/gtest/internal/custom/gtest-port.h @@ -0,0 +1,37 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ diff --git a/include/gtest/internal/custom/gtest-printers.h b/include/gtest/internal/custom/gtest-printers.h new file mode 100644 index 0000000..eb4467a --- /dev/null +++ b/include/gtest/internal/custom/gtest-printers.h @@ -0,0 +1,42 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This file provides an injection point for custom printers in a local +// installation of gTest. +// It will be included from gtest-printers.h and the overrides in this file +// will be visible to everyone. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ diff --git a/include/gtest/internal/custom/gtest.h b/include/gtest/internal/custom/gtest.h new file mode 100644 index 0000000..4c8e07b --- /dev/null +++ b/include/gtest/internal/custom/gtest.h @@ -0,0 +1,37 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ diff --git a/include/gtest/internal/gtest-death-test-internal.h b/include/gtest/internal/gtest-death-test-internal.h new file mode 100644 index 0000000..68bd353 --- /dev/null +++ b/include/gtest/internal/gtest-death-test-internal.h @@ -0,0 +1,304 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines internal utilities needed for implementing +// death tests. They are subject to change without notice. +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ + +#include "gtest/gtest-matchers.h" +#include "gtest/internal/gtest-internal.h" + +#include +#include + +namespace testing { +namespace internal { + +GTEST_DECLARE_string_(internal_run_death_test); + +// Names of the flags (needed for parsing Google Test flags). +const char kDeathTestStyleFlag[] = "death_test_style"; +const char kDeathTestUseFork[] = "death_test_use_fork"; +const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; + +#if GTEST_HAS_DEATH_TEST + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +// DeathTest is a class that hides much of the complexity of the +// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method +// returns a concrete class that depends on the prevailing death test +// style, as defined by the --gtest_death_test_style and/or +// --gtest_internal_run_death_test flags. + +// In describing the results of death tests, these terms are used with +// the corresponding definitions: +// +// exit status: The integer exit information in the format specified +// by wait(2) +// exit code: The integer code passed to exit(3), _exit(2), or +// returned from main() +class GTEST_API_ DeathTest { + public: + // Create returns false if there was an error determining the + // appropriate action to take for the current death test; for example, + // if the gtest_death_test_style flag is set to an invalid value. + // The LastMessage method will return a more detailed message in that + // case. Otherwise, the DeathTest pointer pointed to by the "test" + // argument is set. If the death test should be skipped, the pointer + // is set to NULL; otherwise, it is set to the address of a new concrete + // DeathTest object that controls the execution of the current test. + static bool Create(const char* statement, Matcher matcher, + const char* file, int line, DeathTest** test); + DeathTest(); + virtual ~DeathTest() { } + + // A helper class that aborts a death test when it's deleted. + class ReturnSentinel { + public: + explicit ReturnSentinel(DeathTest* test) : test_(test) { } + ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); } + private: + DeathTest* const test_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel); + } GTEST_ATTRIBUTE_UNUSED_; + + // An enumeration of possible roles that may be taken when a death + // test is encountered. EXECUTE means that the death test logic should + // be executed immediately. OVERSEE means that the program should prepare + // the appropriate environment for a child process to execute the death + // test, then wait for it to complete. + enum TestRole { OVERSEE_TEST, EXECUTE_TEST }; + + // An enumeration of the three reasons that a test might be aborted. + enum AbortReason { + TEST_ENCOUNTERED_RETURN_STATEMENT, + TEST_THREW_EXCEPTION, + TEST_DID_NOT_DIE + }; + + // Assumes one of the above roles. + virtual TestRole AssumeRole() = 0; + + // Waits for the death test to finish and returns its status. + virtual int Wait() = 0; + + // Returns true if the death test passed; that is, the test process + // exited during the test, its exit status matches a user-supplied + // predicate, and its stderr output matches a user-supplied regular + // expression. + // The user-supplied predicate may be a macro expression rather + // than a function pointer or functor, or else Wait and Passed could + // be combined. + virtual bool Passed(bool exit_status_ok) = 0; + + // Signals that the death test did not die as expected. + virtual void Abort(AbortReason reason) = 0; + + // Returns a human-readable outcome message regarding the outcome of + // the last death test. + static const char* LastMessage(); + + static void set_last_death_test_message(const std::string& message); + + private: + // A string containing a description of the outcome of the last death test. + static std::string last_death_test_message_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest); +}; + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +// Factory interface for death tests. May be mocked out for testing. +class DeathTestFactory { + public: + virtual ~DeathTestFactory() { } + virtual bool Create(const char* statement, + Matcher matcher, const char* file, + int line, DeathTest** test) = 0; +}; + +// A concrete DeathTestFactory implementation for normal use. +class DefaultDeathTestFactory : public DeathTestFactory { + public: + bool Create(const char* statement, Matcher matcher, + const char* file, int line, DeathTest** test) override; +}; + +// Returns true if exit_status describes a process that was terminated +// by a signal, or exited normally with a nonzero exit code. +GTEST_API_ bool ExitedUnsuccessfully(int exit_status); + +// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads +// and interpreted as a regex (rather than an Eq matcher) for legacy +// compatibility. +inline Matcher MakeDeathTestMatcher( + ::testing::internal::RE regex) { + return ContainsRegex(regex.pattern()); +} +inline Matcher MakeDeathTestMatcher(const char* regex) { + return ContainsRegex(regex); +} +inline Matcher MakeDeathTestMatcher( + const ::std::string& regex) { + return ContainsRegex(regex); +} + +// If a Matcher is passed to EXPECT_DEATH (etc.), it's +// used directly. +inline Matcher MakeDeathTestMatcher( + Matcher matcher) { + return matcher; +} + +// Traps C++ exceptions escaping statement and reports them as test +// failures. Note that trapping SEH exceptions is not implemented here. +# if GTEST_HAS_EXCEPTIONS +# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } catch (const ::std::exception& gtest_exception) { \ + fprintf(\ + stderr, \ + "\n%s: Caught std::exception-derived exception escaping the " \ + "death test statement. Exception message: %s\n", \ + ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \ + gtest_exception.what()); \ + fflush(stderr); \ + death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ + } catch (...) { \ + death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ + } + +# else +# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) + +# endif + +// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*, +// ASSERT_EXIT*, and EXPECT_EXIT*. +#define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + ::testing::internal::DeathTest* gtest_dt; \ + if (!::testing::internal::DeathTest::Create( \ + #statement, \ + ::testing::internal::MakeDeathTestMatcher(regex_or_matcher), \ + __FILE__, __LINE__, >est_dt)) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ + } \ + if (gtest_dt != nullptr) { \ + std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \ + switch (gtest_dt->AssumeRole()) { \ + case ::testing::internal::DeathTest::OVERSEE_TEST: \ + if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ + } \ + break; \ + case ::testing::internal::DeathTest::EXECUTE_TEST: { \ + ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \ + gtest_dt); \ + GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \ + gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \ + break; \ + } \ + default: \ + break; \ + } \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__) \ + : fail(::testing::internal::DeathTest::LastMessage()) +// The symbol "fail" here expands to something into which a message +// can be streamed. + +// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in +// NDEBUG mode. In this case we need the statements to be executed and the macro +// must accept a streamed message even though the message is never printed. +// The regex object is not evaluated, but it is used to prevent "unused" +// warnings and to avoid an expression that doesn't compile in debug mode. +#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } else if (!::testing::internal::AlwaysTrue()) { \ + ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ + } else \ + ::testing::Message() + +// A class representing the parsed contents of the +// --gtest_internal_run_death_test flag, as it existed when +// RUN_ALL_TESTS was called. +class InternalRunDeathTestFlag { + public: + InternalRunDeathTestFlag(const std::string& a_file, + int a_line, + int an_index, + int a_write_fd) + : file_(a_file), line_(a_line), index_(an_index), + write_fd_(a_write_fd) {} + + ~InternalRunDeathTestFlag() { + if (write_fd_ >= 0) + posix::Close(write_fd_); + } + + const std::string& file() const { return file_; } + int line() const { return line_; } + int index() const { return index_; } + int write_fd() const { return write_fd_; } + + private: + std::string file_; + int line_; + int index_; + int write_fd_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag); +}; + +// Returns a newly created InternalRunDeathTestFlag object with fields +// initialized from the GTEST_FLAG(internal_run_death_test) flag if +// the flag is specified; otherwise returns NULL. +InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag(); + +#endif // GTEST_HAS_DEATH_TEST + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ diff --git a/include/gtest/internal/gtest-filepath.h b/include/gtest/internal/gtest-filepath.h new file mode 100644 index 0000000..c11b101 --- /dev/null +++ b/include/gtest/internal/gtest-filepath.h @@ -0,0 +1,211 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Google Test filepath utilities +// +// This header file declares classes and functions used internally by +// Google Test. They are subject to change without notice. +// +// This file is #included in gtest/internal/gtest-internal.h. +// Do not include this header file separately! + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ + +#include "gtest/internal/gtest-string.h" + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +namespace testing { +namespace internal { + +// FilePath - a class for file and directory pathname manipulation which +// handles platform-specific conventions (like the pathname separator). +// Used for helper functions for naming files in a directory for xml output. +// Except for Set methods, all methods are const or static, which provides an +// "immutable value object" -- useful for peace of mind. +// A FilePath with a value ending in a path separator ("like/this/") represents +// a directory, otherwise it is assumed to represent a file. In either case, +// it may or may not represent an actual file or directory in the file system. +// Names are NOT checked for syntax correctness -- no checking for illegal +// characters, malformed paths, etc. + +class GTEST_API_ FilePath { + public: + FilePath() : pathname_("") { } + FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { } + + explicit FilePath(const std::string& pathname) : pathname_(pathname) { + Normalize(); + } + + FilePath& operator=(const FilePath& rhs) { + Set(rhs); + return *this; + } + + void Set(const FilePath& rhs) { + pathname_ = rhs.pathname_; + } + + const std::string& string() const { return pathname_; } + const char* c_str() const { return pathname_.c_str(); } + + // Returns the current working directory, or "" if unsuccessful. + static FilePath GetCurrentDir(); + + // Given directory = "dir", base_name = "test", number = 0, + // extension = "xml", returns "dir/test.xml". If number is greater + // than zero (e.g., 12), returns "dir/test_12.xml". + // On Windows platform, uses \ as the separator rather than /. + static FilePath MakeFileName(const FilePath& directory, + const FilePath& base_name, + int number, + const char* extension); + + // Given directory = "dir", relative_path = "test.xml", + // returns "dir/test.xml". + // On Windows, uses \ as the separator rather than /. + static FilePath ConcatPaths(const FilePath& directory, + const FilePath& relative_path); + + // Returns a pathname for a file that does not currently exist. The pathname + // will be directory/base_name.extension or + // directory/base_name_.extension if directory/base_name.extension + // already exists. The number will be incremented until a pathname is found + // that does not already exist. + // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. + // There could be a race condition if two or more processes are calling this + // function at the same time -- they could both pick the same filename. + static FilePath GenerateUniqueFileName(const FilePath& directory, + const FilePath& base_name, + const char* extension); + + // Returns true if and only if the path is "". + bool IsEmpty() const { return pathname_.empty(); } + + // If input name has a trailing separator character, removes it and returns + // the name, otherwise return the name string unmodified. + // On Windows platform, uses \ as the separator, other platforms use /. + FilePath RemoveTrailingPathSeparator() const; + + // Returns a copy of the FilePath with the directory part removed. + // Example: FilePath("path/to/file").RemoveDirectoryName() returns + // FilePath("file"). If there is no directory part ("just_a_file"), it returns + // the FilePath unmodified. If there is no file part ("just_a_dir/") it + // returns an empty FilePath (""). + // On Windows platform, '\' is the path separator, otherwise it is '/'. + FilePath RemoveDirectoryName() const; + + // RemoveFileName returns the directory path with the filename removed. + // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". + // If the FilePath is "a_file" or "/a_file", RemoveFileName returns + // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does + // not have a file, like "just/a/dir/", it returns the FilePath unmodified. + // On Windows platform, '\' is the path separator, otherwise it is '/'. + FilePath RemoveFileName() const; + + // Returns a copy of the FilePath with the case-insensitive extension removed. + // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns + // FilePath("dir/file"). If a case-insensitive extension is not + // found, returns a copy of the original FilePath. + FilePath RemoveExtension(const char* extension) const; + + // Creates directories so that path exists. Returns true if successful or if + // the directories already exist; returns false if unable to create + // directories for any reason. Will also return false if the FilePath does + // not represent a directory (that is, it doesn't end with a path separator). + bool CreateDirectoriesRecursively() const; + + // Create the directory so that path exists. Returns true if successful or + // if the directory already exists; returns false if unable to create the + // directory for any reason, including if the parent directory does not + // exist. Not named "CreateDirectory" because that's a macro on Windows. + bool CreateFolder() const; + + // Returns true if FilePath describes something in the file-system, + // either a file, directory, or whatever, and that something exists. + bool FileOrDirectoryExists() const; + + // Returns true if pathname describes a directory in the file-system + // that exists. + bool DirectoryExists() const; + + // Returns true if FilePath ends with a path separator, which indicates that + // it is intended to represent a directory. Returns false otherwise. + // This does NOT check that a directory (or file) actually exists. + bool IsDirectory() const; + + // Returns true if pathname describes a root directory. (Windows has one + // root directory per disk drive.) + bool IsRootDirectory() const; + + // Returns true if pathname describes an absolute path. + bool IsAbsolutePath() const; + + private: + // Replaces multiple consecutive separators with a single separator. + // For example, "bar///foo" becomes "bar/foo". Does not eliminate other + // redundancies that might be in a pathname involving "." or "..". + // + // A pathname with multiple consecutive separators may occur either through + // user error or as a result of some scripts or APIs that generate a pathname + // with a trailing separator. On other platforms the same API or script + // may NOT generate a pathname with a trailing "/". Then elsewhere that + // pathname may have another "/" and pathname components added to it, + // without checking for the separator already being there. + // The script language and operating system may allow paths like "foo//bar" + // but some of the functions in FilePath will not handle that correctly. In + // particular, RemoveTrailingPathSeparator() only removes one separator, and + // it is called in CreateDirectoriesRecursively() assuming that it will change + // a pathname from directory syntax (trailing separator) to filename syntax. + // + // On Windows this method also replaces the alternate path separator '/' with + // the primary path separator '\\', so that for example "bar\\/\\foo" becomes + // "bar\\foo". + + void Normalize(); + + // Returns a pointer to the last occurence of a valid path separator in + // the FilePath. On Windows, for example, both '/' and '\' are valid path + // separators. Returns NULL if no path separator was found. + const char* FindLastPathSeparator() const; + + std::string pathname_; +}; // class FilePath + +} // namespace internal +} // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h new file mode 100644 index 0000000..94c816a --- /dev/null +++ b/include/gtest/internal/gtest-internal.h @@ -0,0 +1,1380 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file declares functions and macros used internally by +// Google Test. They are subject to change without notice. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ + +#include "gtest/internal/gtest-port.h" + +#if GTEST_OS_LINUX +# include +# include +# include +# include +#endif // GTEST_OS_LINUX + +#if GTEST_HAS_EXCEPTIONS +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gtest/gtest-message.h" +#include "gtest/internal/gtest-filepath.h" +#include "gtest/internal/gtest-string.h" +#include "gtest/internal/gtest-type-util.h" + +// Due to C++ preprocessor weirdness, we need double indirection to +// concatenate two tokens when one of them is __LINE__. Writing +// +// foo ## __LINE__ +// +// will result in the token foo__LINE__, instead of foo followed by +// the current line number. For more details, see +// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6 +#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar) +#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar + +// Stringifies its argument. +#define GTEST_STRINGIFY_(name) #name + +namespace proto2 { class Message; } + +namespace testing { + +// Forward declarations. + +class AssertionResult; // Result of an assertion. +class Message; // Represents a failure message. +class Test; // Represents a test. +class TestInfo; // Information about a test. +class TestPartResult; // Result of a test part. +class UnitTest; // A collection of test suites. + +template +::std::string PrintToString(const T& value); + +namespace internal { + +struct TraceInfo; // Information about a trace point. +class TestInfoImpl; // Opaque implementation of TestInfo +class UnitTestImpl; // Opaque implementation of UnitTest + +// The text used in failure messages to indicate the start of the +// stack trace. +GTEST_API_ extern const char kStackTraceMarker[]; + +// An IgnoredValue object can be implicitly constructed from ANY value. +class IgnoredValue { + struct Sink {}; + public: + // This constructor template allows any value to be implicitly + // converted to IgnoredValue. The object has no data member and + // doesn't try to remember anything about the argument. We + // deliberately omit the 'explicit' keyword in order to allow the + // conversion to be implicit. + // Disable the conversion if T already has a magical conversion operator. + // Otherwise we get ambiguity. + template ::value, + int>::type = 0> + IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit) +}; + +// Appends the user-supplied message to the Google-Test-generated message. +GTEST_API_ std::string AppendUserMessage( + const std::string& gtest_msg, const Message& user_msg); + +#if GTEST_HAS_EXCEPTIONS + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \ +/* an exported class was derived from a class that was not exported */) + +// This exception is thrown by (and only by) a failed Google Test +// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions +// are enabled). We derive it from std::runtime_error, which is for +// errors presumably detectable only at run time. Since +// std::runtime_error inherits from std::exception, many testing +// frameworks know how to extract and print the message inside it. +class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { + public: + explicit GoogleTestFailureException(const TestPartResult& failure); +}; + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4275 + +#endif // GTEST_HAS_EXCEPTIONS + +namespace edit_distance { +// Returns the optimal edits to go from 'left' to 'right'. +// All edits cost the same, with replace having lower priority than +// add/remove. +// Simple implementation of the Wagner-Fischer algorithm. +// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm +enum EditType { kMatch, kAdd, kRemove, kReplace }; +GTEST_API_ std::vector CalculateOptimalEdits( + const std::vector& left, const std::vector& right); + +// Same as above, but the input is represented as strings. +GTEST_API_ std::vector CalculateOptimalEdits( + const std::vector& left, + const std::vector& right); + +// Create a diff of the input strings in Unified diff format. +GTEST_API_ std::string CreateUnifiedDiff(const std::vector& left, + const std::vector& right, + size_t context = 2); + +} // namespace edit_distance + +// Calculate the diff between 'left' and 'right' and return it in unified diff +// format. +// If not null, stores in 'total_line_count' the total number of lines found +// in left + right. +GTEST_API_ std::string DiffStrings(const std::string& left, + const std::string& right, + size_t* total_line_count); + +// Constructs and returns the message for an equality assertion +// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. +// +// The first four parameters are the expressions used in the assertion +// and their values, as strings. For example, for ASSERT_EQ(foo, bar) +// where foo is 5 and bar is 6, we have: +// +// expected_expression: "foo" +// actual_expression: "bar" +// expected_value: "5" +// actual_value: "6" +// +// The ignoring_case parameter is true if and only if the assertion is a +// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will +// be inserted into the message. +GTEST_API_ AssertionResult EqFailure(const char* expected_expression, + const char* actual_expression, + const std::string& expected_value, + const std::string& actual_value, + bool ignoring_case); + +// Constructs a failure message for Boolean assertions such as EXPECT_TRUE. +GTEST_API_ std::string GetBoolAssertionFailureMessage( + const AssertionResult& assertion_result, + const char* expression_text, + const char* actual_predicate_value, + const char* expected_predicate_value); + +// This template class represents an IEEE floating-point number +// (either single-precision or double-precision, depending on the +// template parameters). +// +// The purpose of this class is to do more sophisticated number +// comparison. (Due to round-off error, etc, it's very unlikely that +// two floating-points will be equal exactly. Hence a naive +// comparison by the == operation often doesn't work.) +// +// Format of IEEE floating-point: +// +// The most-significant bit being the leftmost, an IEEE +// floating-point looks like +// +// sign_bit exponent_bits fraction_bits +// +// Here, sign_bit is a single bit that designates the sign of the +// number. +// +// For float, there are 8 exponent bits and 23 fraction bits. +// +// For double, there are 11 exponent bits and 52 fraction bits. +// +// More details can be found at +// http://en.wikipedia.org/wiki/IEEE_floating-point_standard. +// +// Template parameter: +// +// RawType: the raw floating-point type (either float or double) +template +class FloatingPoint { + public: + // Defines the unsigned integer type that has the same size as the + // floating point number. + typedef typename TypeWithSize::UInt Bits; + + // Constants. + + // # of bits in a number. + static const size_t kBitCount = 8*sizeof(RawType); + + // # of fraction bits in a number. + static const size_t kFractionBitCount = + std::numeric_limits::digits - 1; + + // # of exponent bits in a number. + static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount; + + // The mask for the sign bit. + static const Bits kSignBitMask = static_cast(1) << (kBitCount - 1); + + // The mask for the fraction bits. + static const Bits kFractionBitMask = + ~static_cast(0) >> (kExponentBitCount + 1); + + // The mask for the exponent bits. + static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask); + + // How many ULP's (Units in the Last Place) we want to tolerate when + // comparing two numbers. The larger the value, the more error we + // allow. A 0 value means that two numbers must be exactly the same + // to be considered equal. + // + // The maximum error of a single floating-point operation is 0.5 + // units in the last place. On Intel CPU's, all floating-point + // calculations are done with 80-bit precision, while double has 64 + // bits. Therefore, 4 should be enough for ordinary use. + // + // See the following article for more details on ULP: + // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ + static const size_t kMaxUlps = 4; + + // Constructs a FloatingPoint from a raw floating-point number. + // + // On an Intel CPU, passing a non-normalized NAN (Not a Number) + // around may change its bits, although the new value is guaranteed + // to be also a NAN. Therefore, don't expect this constructor to + // preserve the bits in x when x is a NAN. + explicit FloatingPoint(const RawType& x) { u_.value_ = x; } + + // Static methods + + // Reinterprets a bit pattern as a floating-point number. + // + // This function is needed to test the AlmostEquals() method. + static RawType ReinterpretBits(const Bits bits) { + FloatingPoint fp(0); + fp.u_.bits_ = bits; + return fp.u_.value_; + } + + // Returns the floating-point number that represent positive infinity. + static RawType Infinity() { + return ReinterpretBits(kExponentBitMask); + } + + // Returns the maximum representable finite floating-point number. + static RawType Max(); + + // Non-static methods + + // Returns the bits that represents this number. + const Bits &bits() const { return u_.bits_; } + + // Returns the exponent bits of this number. + Bits exponent_bits() const { return kExponentBitMask & u_.bits_; } + + // Returns the fraction bits of this number. + Bits fraction_bits() const { return kFractionBitMask & u_.bits_; } + + // Returns the sign bit of this number. + Bits sign_bit() const { return kSignBitMask & u_.bits_; } + + // Returns true if and only if this is NAN (not a number). + bool is_nan() const { + // It's a NAN if the exponent bits are all ones and the fraction + // bits are not entirely zeros. + return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0); + } + + // Returns true if and only if this number is at most kMaxUlps ULP's away + // from rhs. In particular, this function: + // + // - returns false if either number is (or both are) NAN. + // - treats really large numbers as almost equal to infinity. + // - thinks +0.0 and -0.0 are 0 DLP's apart. + bool AlmostEquals(const FloatingPoint& rhs) const { + // The IEEE standard says that any comparison operation involving + // a NAN must return false. + if (is_nan() || rhs.is_nan()) return false; + + return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) + <= kMaxUlps; + } + + private: + // The data type used to store the actual floating-point number. + union FloatingPointUnion { + RawType value_; // The raw floating-point number. + Bits bits_; // The bits that represent the number. + }; + + // Converts an integer from the sign-and-magnitude representation to + // the biased representation. More precisely, let N be 2 to the + // power of (kBitCount - 1), an integer x is represented by the + // unsigned number x + N. + // + // For instance, + // + // -N + 1 (the most negative number representable using + // sign-and-magnitude) is represented by 1; + // 0 is represented by N; and + // N - 1 (the biggest number representable using + // sign-and-magnitude) is represented by 2N - 1. + // + // Read http://en.wikipedia.org/wiki/Signed_number_representations + // for more details on signed number representations. + static Bits SignAndMagnitudeToBiased(const Bits &sam) { + if (kSignBitMask & sam) { + // sam represents a negative number. + return ~sam + 1; + } else { + // sam represents a positive number. + return kSignBitMask | sam; + } + } + + // Given two numbers in the sign-and-magnitude representation, + // returns the distance between them as an unsigned number. + static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1, + const Bits &sam2) { + const Bits biased1 = SignAndMagnitudeToBiased(sam1); + const Bits biased2 = SignAndMagnitudeToBiased(sam2); + return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1); + } + + FloatingPointUnion u_; +}; + +// We cannot use std::numeric_limits::max() as it clashes with the max() +// macro defined by . +template <> +inline float FloatingPoint::Max() { return FLT_MAX; } +template <> +inline double FloatingPoint::Max() { return DBL_MAX; } + +// Typedefs the instances of the FloatingPoint template class that we +// care to use. +typedef FloatingPoint Float; +typedef FloatingPoint Double; + +// In order to catch the mistake of putting tests that use different +// test fixture classes in the same test suite, we need to assign +// unique IDs to fixture classes and compare them. The TypeId type is +// used to hold such IDs. The user should treat TypeId as an opaque +// type: the only operation allowed on TypeId values is to compare +// them for equality using the == operator. +typedef const void* TypeId; + +template +class TypeIdHelper { + public: + // dummy_ must not have a const type. Otherwise an overly eager + // compiler (e.g. MSVC 7.1 & 8.0) may try to merge + // TypeIdHelper::dummy_ for different Ts as an "optimization". + static bool dummy_; +}; + +template +bool TypeIdHelper::dummy_ = false; + +// GetTypeId() returns the ID of type T. Different values will be +// returned for different types. Calling the function twice with the +// same type argument is guaranteed to return the same ID. +template +TypeId GetTypeId() { + // The compiler is required to allocate a different + // TypeIdHelper::dummy_ variable for each T used to instantiate + // the template. Therefore, the address of dummy_ is guaranteed to + // be unique. + return &(TypeIdHelper::dummy_); +} + +// Returns the type ID of ::testing::Test. Always call this instead +// of GetTypeId< ::testing::Test>() to get the type ID of +// ::testing::Test, as the latter may give the wrong result due to a +// suspected linker bug when compiling Google Test as a Mac OS X +// framework. +GTEST_API_ TypeId GetTestTypeId(); + +// Defines the abstract factory interface that creates instances +// of a Test object. +class TestFactoryBase { + public: + virtual ~TestFactoryBase() {} + + // Creates a test instance to run. The instance is both created and destroyed + // within TestInfoImpl::Run() + virtual Test* CreateTest() = 0; + + protected: + TestFactoryBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase); +}; + +// This class provides implementation of TeastFactoryBase interface. +// It is used in TEST and TEST_F macros. +template +class TestFactoryImpl : public TestFactoryBase { + public: + Test* CreateTest() override { return new TestClass; } +}; + +#if GTEST_OS_WINDOWS + +// Predicate-formatters for implementing the HRESULT checking macros +// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED} +// We pass a long instead of HRESULT to avoid causing an +// include dependency for the HRESULT type. +GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr, + long hr); // NOLINT +GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr, + long hr); // NOLINT + +#endif // GTEST_OS_WINDOWS + +// Types of SetUpTestSuite() and TearDownTestSuite() functions. +using SetUpTestSuiteFunc = void (*)(); +using TearDownTestSuiteFunc = void (*)(); + +struct CodeLocation { + CodeLocation(const std::string& a_file, int a_line) + : file(a_file), line(a_line) {} + + std::string file; + int line; +}; + +// Helper to identify which setup function for TestCase / TestSuite to call. +// Only one function is allowed, either TestCase or TestSute but not both. + +// Utility functions to help SuiteApiResolver +using SetUpTearDownSuiteFuncType = void (*)(); + +inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull( + SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) { + return a == def ? nullptr : a; +} + +template +// Note that SuiteApiResolver inherits from T because +// SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way +// SuiteApiResolver can access them. +struct SuiteApiResolver : T { + // testing::Test is only forward declared at this point. So we make it a + // dependend class for the compiler to be OK with it. + using Test = + typename std::conditional::type; + + static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite(const char* filename, + int line_num) { + SetUpTearDownSuiteFuncType test_case_fp = + GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase); + SetUpTearDownSuiteFuncType test_suite_fp = + GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite); + + GTEST_CHECK_(!test_case_fp || !test_suite_fp) + << "Test can not provide both SetUpTestSuite and SetUpTestCase, please " + "make sure there is only one present at " + << filename << ":" << line_num; + + return test_case_fp != nullptr ? test_case_fp : test_suite_fp; + } + + static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite(const char* filename, + int line_num) { + SetUpTearDownSuiteFuncType test_case_fp = + GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase); + SetUpTearDownSuiteFuncType test_suite_fp = + GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite); + + GTEST_CHECK_(!test_case_fp || !test_suite_fp) + << "Test can not provide both TearDownTestSuite and TearDownTestCase," + " please make sure there is only one present at" + << filename << ":" << line_num; + + return test_case_fp != nullptr ? test_case_fp : test_suite_fp; + } +}; + +// Creates a new TestInfo object and registers it with Google Test; +// returns the created object. +// +// Arguments: +// +// test_suite_name: name of the test suite +// name: name of the test +// type_param the name of the test's type parameter, or NULL if +// this is not a typed or a type-parameterized test. +// value_param text representation of the test's value parameter, +// or NULL if this is not a type-parameterized test. +// code_location: code location where the test is defined +// fixture_class_id: ID of the test fixture class +// set_up_tc: pointer to the function that sets up the test suite +// tear_down_tc: pointer to the function that tears down the test suite +// factory: pointer to the factory that creates a test object. +// The newly created TestInfo instance will assume +// ownership of the factory object. +GTEST_API_ TestInfo* MakeAndRegisterTestInfo( + const char* test_suite_name, const char* name, const char* type_param, + const char* value_param, CodeLocation code_location, + TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, + TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory); + +// If *pstr starts with the given prefix, modifies *pstr to be right +// past the prefix and returns true; otherwise leaves *pstr unchanged +// and returns false. None of pstr, *pstr, and prefix can be NULL. +GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr); + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +// State of the definition of a type-parameterized test suite. +class GTEST_API_ TypedTestSuitePState { + public: + TypedTestSuitePState() : registered_(false) {} + + // Adds the given test name to defined_test_names_ and return true + // if the test suite hasn't been registered; otherwise aborts the + // program. + bool AddTestName(const char* file, int line, const char* case_name, + const char* test_name) { + if (registered_) { + fprintf(stderr, + "%s Test %s must be defined before " + "REGISTER_TYPED_TEST_SUITE_P(%s, ...).\n", + FormatFileLocation(file, line).c_str(), test_name, case_name); + fflush(stderr); + posix::Abort(); + } + registered_tests_.insert( + ::std::make_pair(test_name, CodeLocation(file, line))); + return true; + } + + bool TestExists(const std::string& test_name) const { + return registered_tests_.count(test_name) > 0; + } + + const CodeLocation& GetCodeLocation(const std::string& test_name) const { + RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name); + GTEST_CHECK_(it != registered_tests_.end()); + return it->second; + } + + // Verifies that registered_tests match the test names in + // defined_test_names_; returns registered_tests if successful, or + // aborts the program otherwise. + const char* VerifyRegisteredTestNames( + const char* file, int line, const char* registered_tests); + + private: + typedef ::std::map RegisteredTestsMap; + + bool registered_; + RegisteredTestsMap registered_tests_; +}; + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +using TypedTestCasePState = TypedTestSuitePState; +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + +// Skips to the first non-space char after the first comma in 'str'; +// returns NULL if no comma is found in 'str'. +inline const char* SkipComma(const char* str) { + const char* comma = strchr(str, ','); + if (comma == nullptr) { + return nullptr; + } + while (IsSpace(*(++comma))) {} + return comma; +} + +// Returns the prefix of 'str' before the first comma in it; returns +// the entire string if it contains no comma. +inline std::string GetPrefixUntilComma(const char* str) { + const char* comma = strchr(str, ','); + return comma == nullptr ? str : std::string(str, comma); +} + +// Splits a given string on a given delimiter, populating a given +// vector with the fields. +void SplitString(const ::std::string& str, char delimiter, + ::std::vector< ::std::string>* dest); + +// The default argument to the template below for the case when the user does +// not provide a name generator. +struct DefaultNameGenerator { + template + static std::string GetName(int i) { + return StreamableToString(i); + } +}; + +template +struct NameGeneratorSelector { + typedef Provided type; +}; + +template +void GenerateNamesRecursively(Types0, std::vector*, int) {} + +template +void GenerateNamesRecursively(Types, std::vector* result, int i) { + result->push_back(NameGenerator::template GetName(i)); + GenerateNamesRecursively(typename Types::Tail(), result, + i + 1); +} + +template +std::vector GenerateNames() { + std::vector result; + GenerateNamesRecursively(Types(), &result, 0); + return result; +} + +// TypeParameterizedTest::Register() +// registers a list of type-parameterized tests with Google Test. The +// return value is insignificant - we just need to return something +// such that we can call this function in a namespace scope. +// +// Implementation note: The GTEST_TEMPLATE_ macro declares a template +// template parameter. It's defined in gtest-type-util.h. +template +class TypeParameterizedTest { + public: + // 'index' is the index of the test in the type list 'Types' + // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite, + // Types). Valid values for 'index' are [0, N - 1] where N is the + // length of Types. + static bool Register(const char* prefix, const CodeLocation& code_location, + const char* case_name, const char* test_names, int index, + const std::vector& type_names = + GenerateNames()) { + typedef typename Types::Head Type; + typedef Fixture FixtureClass; + typedef typename GTEST_BIND_(TestSel, Type) TestClass; + + // First, registers the first type-parameterized test in the type + // list. + MakeAndRegisterTestInfo( + (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + + "/" + type_names[static_cast(index)]) + .c_str(), + StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(), + GetTypeName().c_str(), + nullptr, // No value parameter. + code_location, GetTypeId(), + SuiteApiResolver::GetSetUpCaseOrSuite( + code_location.file.c_str(), code_location.line), + SuiteApiResolver::GetTearDownCaseOrSuite( + code_location.file.c_str(), code_location.line), + new TestFactoryImpl); + + // Next, recurses (at compile time) with the tail of the type list. + return TypeParameterizedTest::Register(prefix, + code_location, + case_name, + test_names, + index + 1, + type_names); + } +}; + +// The base case for the compile time recursion. +template +class TypeParameterizedTest { + public: + static bool Register(const char* /*prefix*/, const CodeLocation&, + const char* /*case_name*/, const char* /*test_names*/, + int /*index*/, + const std::vector& = + std::vector() /*type_names*/) { + return true; + } +}; + +// TypeParameterizedTestSuite::Register() +// registers *all combinations* of 'Tests' and 'Types' with Google +// Test. The return value is insignificant - we just need to return +// something such that we can call this function in a namespace scope. +template +class TypeParameterizedTestSuite { + public: + static bool Register(const char* prefix, CodeLocation code_location, + const TypedTestSuitePState* state, const char* case_name, + const char* test_names, + const std::vector& type_names = + GenerateNames()) { + std::string test_name = StripTrailingSpaces( + GetPrefixUntilComma(test_names)); + if (!state->TestExists(test_name)) { + fprintf(stderr, "Failed to get code location for test %s.%s at %s.", + case_name, test_name.c_str(), + FormatFileLocation(code_location.file.c_str(), + code_location.line).c_str()); + fflush(stderr); + posix::Abort(); + } + const CodeLocation& test_location = state->GetCodeLocation(test_name); + + typedef typename Tests::Head Head; + + // First, register the first test in 'Test' for each type in 'Types'. + TypeParameterizedTest::Register( + prefix, test_location, case_name, test_names, 0, type_names); + + // Next, recurses (at compile time) with the tail of the test list. + return TypeParameterizedTestSuite::Register(prefix, code_location, + state, case_name, + SkipComma(test_names), + type_names); + } +}; + +// The base case for the compile time recursion. +template +class TypeParameterizedTestSuite { + public: + static bool Register(const char* /*prefix*/, const CodeLocation&, + const TypedTestSuitePState* /*state*/, + const char* /*case_name*/, const char* /*test_names*/, + const std::vector& = + std::vector() /*type_names*/) { + return true; + } +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// Returns the current OS stack trace as an std::string. +// +// The maximum number of stack frames to be included is specified by +// the gtest_stack_trace_depth flag. The skip_count parameter +// specifies the number of top frames to be skipped, which doesn't +// count against the number of frames to be included. +// +// For example, if Foo() calls Bar(), which in turn calls +// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in +// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. +GTEST_API_ std::string GetCurrentOsStackTraceExceptTop( + UnitTest* unit_test, int skip_count); + +// Helpers for suppressing warnings on unreachable code or constant +// condition. + +// Always returns true. +GTEST_API_ bool AlwaysTrue(); + +// Always returns false. +inline bool AlwaysFalse() { return !AlwaysTrue(); } + +// Helper for suppressing false warning from Clang on a const char* +// variable declared in a conditional expression always being NULL in +// the else branch. +struct GTEST_API_ ConstCharPtr { + ConstCharPtr(const char* str) : value(str) {} + operator bool() const { return true; } + const char* value; +}; + +// A simple Linear Congruential Generator for generating random +// numbers with a uniform distribution. Unlike rand() and srand(), it +// doesn't use global state (and therefore can't interfere with user +// code). Unlike rand_r(), it's portable. An LCG isn't very random, +// but it's good enough for our purposes. +class GTEST_API_ Random { + public: + static const UInt32 kMaxRange = 1u << 31; + + explicit Random(UInt32 seed) : state_(seed) {} + + void Reseed(UInt32 seed) { state_ = seed; } + + // Generates a random number from [0, range). Crashes if 'range' is + // 0 or greater than kMaxRange. + UInt32 Generate(UInt32 range); + + private: + UInt32 state_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(Random); +}; + +// Turns const U&, U&, const U, and U all into U. +#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \ + typename std::remove_const::type>::type + +// IsAProtocolMessage::value is a compile-time bool constant that's +// true if and only if T is type proto2::Message or a subclass of it. +template +struct IsAProtocolMessage + : public bool_constant< + std::is_convertible::value> {}; + +// When the compiler sees expression IsContainerTest(0), if C is an +// STL-style container class, the first overload of IsContainerTest +// will be viable (since both C::iterator* and C::const_iterator* are +// valid types and NULL can be implicitly converted to them). It will +// be picked over the second overload as 'int' is a perfect match for +// the type of argument 0. If C::iterator or C::const_iterator is not +// a valid type, the first overload is not viable, and the second +// overload will be picked. Therefore, we can determine whether C is +// a container class by checking the type of IsContainerTest(0). +// The value of the expression is insignificant. +// +// In C++11 mode we check the existence of a const_iterator and that an +// iterator is properly implemented for the container. +// +// For pre-C++11 that we look for both C::iterator and C::const_iterator. +// The reason is that C++ injects the name of a class as a member of the +// class itself (e.g. you can refer to class iterator as either +// 'iterator' or 'iterator::iterator'). If we look for C::iterator +// only, for example, we would mistakenly think that a class named +// iterator is an STL container. +// +// Also note that the simpler approach of overloading +// IsContainerTest(typename C::const_iterator*) and +// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++. +typedef int IsContainer; +template ().begin()), + class = decltype(::std::declval().end()), + class = decltype(++::std::declval()), + class = decltype(*::std::declval()), + class = typename C::const_iterator> +IsContainer IsContainerTest(int /* dummy */) { + return 0; +} + +typedef char IsNotContainer; +template +IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; } + +// Trait to detect whether a type T is a hash table. +// The heuristic used is that the type contains an inner type `hasher` and does +// not contain an inner type `reverse_iterator`. +// If the container is iterable in reverse, then order might actually matter. +template +struct IsHashTable { + private: + template + static char test(typename U::hasher*, typename U::reverse_iterator*); + template + static int test(typename U::hasher*, ...); + template + static char test(...); + + public: + static const bool value = sizeof(test(nullptr, nullptr)) == sizeof(int); +}; + +template +const bool IsHashTable::value; + +template (0)) == sizeof(IsContainer)> +struct IsRecursiveContainerImpl; + +template +struct IsRecursiveContainerImpl : public std::false_type {}; + +// Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to +// obey the same inconsistencies as the IsContainerTest, namely check if +// something is a container is relying on only const_iterator in C++11 and +// is relying on both const_iterator and iterator otherwise +template +struct IsRecursiveContainerImpl { + using value_type = decltype(*std::declval()); + using type = + std::is_same::type>::type, + C>; +}; + +// IsRecursiveContainer is a unary compile-time predicate that +// evaluates whether C is a recursive container type. A recursive container +// type is a container type whose value_type is equal to the container type +// itself. An example for a recursive container type is +// boost::filesystem::path, whose iterator has a value_type that is equal to +// boost::filesystem::path. +template +struct IsRecursiveContainer : public IsRecursiveContainerImpl::type {}; + +// Utilities for native arrays. + +// ArrayEq() compares two k-dimensional native arrays using the +// elements' operator==, where k can be any integer >= 0. When k is +// 0, ArrayEq() degenerates into comparing a single pair of values. + +template +bool ArrayEq(const T* lhs, size_t size, const U* rhs); + +// This generic version is used when k is 0. +template +inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; } + +// This overload is used when k >= 1. +template +inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) { + return internal::ArrayEq(lhs, N, rhs); +} + +// This helper reduces code bloat. If we instead put its logic inside +// the previous ArrayEq() function, arrays with different sizes would +// lead to different copies of the template code. +template +bool ArrayEq(const T* lhs, size_t size, const U* rhs) { + for (size_t i = 0; i != size; i++) { + if (!internal::ArrayEq(lhs[i], rhs[i])) + return false; + } + return true; +} + +// Finds the first element in the iterator range [begin, end) that +// equals elem. Element may be a native array type itself. +template +Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) { + for (Iter it = begin; it != end; ++it) { + if (internal::ArrayEq(*it, elem)) + return it; + } + return end; +} + +// CopyArray() copies a k-dimensional native array using the elements' +// operator=, where k can be any integer >= 0. When k is 0, +// CopyArray() degenerates into copying a single value. + +template +void CopyArray(const T* from, size_t size, U* to); + +// This generic version is used when k is 0. +template +inline void CopyArray(const T& from, U* to) { *to = from; } + +// This overload is used when k >= 1. +template +inline void CopyArray(const T(&from)[N], U(*to)[N]) { + internal::CopyArray(from, N, *to); +} + +// This helper reduces code bloat. If we instead put its logic inside +// the previous CopyArray() function, arrays with different sizes +// would lead to different copies of the template code. +template +void CopyArray(const T* from, size_t size, U* to) { + for (size_t i = 0; i != size; i++) { + internal::CopyArray(from[i], to + i); + } +} + +// The relation between an NativeArray object (see below) and the +// native array it represents. +// We use 2 different structs to allow non-copyable types to be used, as long +// as RelationToSourceReference() is passed. +struct RelationToSourceReference {}; +struct RelationToSourceCopy {}; + +// Adapts a native array to a read-only STL-style container. Instead +// of the complete STL container concept, this adaptor only implements +// members useful for Google Mock's container matchers. New members +// should be added as needed. To simplify the implementation, we only +// support Element being a raw type (i.e. having no top-level const or +// reference modifier). It's the client's responsibility to satisfy +// this requirement. Element can be an array type itself (hence +// multi-dimensional arrays are supported). +template +class NativeArray { + public: + // STL-style container typedefs. + typedef Element value_type; + typedef Element* iterator; + typedef const Element* const_iterator; + + // Constructs from a native array. References the source. + NativeArray(const Element* array, size_t count, RelationToSourceReference) { + InitRef(array, count); + } + + // Constructs from a native array. Copies the source. + NativeArray(const Element* array, size_t count, RelationToSourceCopy) { + InitCopy(array, count); + } + + // Copy constructor. + NativeArray(const NativeArray& rhs) { + (this->*rhs.clone_)(rhs.array_, rhs.size_); + } + + ~NativeArray() { + if (clone_ != &NativeArray::InitRef) + delete[] array_; + } + + // STL-style container methods. + size_t size() const { return size_; } + const_iterator begin() const { return array_; } + const_iterator end() const { return array_ + size_; } + bool operator==(const NativeArray& rhs) const { + return size() == rhs.size() && + ArrayEq(begin(), size(), rhs.begin()); + } + + private: + static_assert(!std::is_const::value, "Type must not be const"); + static_assert(!std::is_reference::value, + "Type must not be a reference"); + + // Initializes this object with a copy of the input. + void InitCopy(const Element* array, size_t a_size) { + Element* const copy = new Element[a_size]; + CopyArray(array, a_size, copy); + array_ = copy; + size_ = a_size; + clone_ = &NativeArray::InitCopy; + } + + // Initializes this object with a reference of the input. + void InitRef(const Element* array, size_t a_size) { + array_ = array; + size_ = a_size; + clone_ = &NativeArray::InitRef; + } + + const Element* array_; + size_t size_; + void (NativeArray::*clone_)(const Element*, size_t); + + GTEST_DISALLOW_ASSIGN_(NativeArray); +}; + +// Backport of std::index_sequence. +template +struct IndexSequence { + using type = IndexSequence; +}; + +// Double the IndexSequence, and one if plus_one is true. +template +struct DoubleSequence; +template +struct DoubleSequence, sizeofT> { + using type = IndexSequence; +}; +template +struct DoubleSequence, sizeofT> { + using type = IndexSequence; +}; + +// Backport of std::make_index_sequence. +// It uses O(ln(N)) instantiation depth. +template +struct MakeIndexSequence + : DoubleSequence::type, + N / 2>::type {}; + +template <> +struct MakeIndexSequence<0> : IndexSequence<> {}; + +// FIXME: This implementation of ElemFromList is O(1) in instantiation depth, +// but it is O(N^2) in total instantiations. Not sure if this is the best +// tradeoff, as it will make it somewhat slow to compile. +template +struct ElemFromListImpl {}; + +template +struct ElemFromListImpl { + using type = T; +}; + +// Get the Nth element from T... +// It uses O(1) instantiation depth. +template +struct ElemFromList; + +template +struct ElemFromList, T...> + : ElemFromListImpl... {}; + +template +class FlatTuple; + +template +struct FlatTupleElemBase; + +template +struct FlatTupleElemBase, I> { + using value_type = + typename ElemFromList::type, + T...>::type; + FlatTupleElemBase() = default; + explicit FlatTupleElemBase(value_type t) : value(std::move(t)) {} + value_type value; +}; + +template +struct FlatTupleBase; + +template +struct FlatTupleBase, IndexSequence> + : FlatTupleElemBase, Idx>... { + using Indices = IndexSequence; + FlatTupleBase() = default; + explicit FlatTupleBase(T... t) + : FlatTupleElemBase, Idx>(std::move(t))... {} +}; + +// Analog to std::tuple but with different tradeoffs. +// This class minimizes the template instantiation depth, thus allowing more +// elements that std::tuple would. std::tuple has been seen to require an +// instantiation depth of more than 10x the number of elements in some +// implementations. +// FlatTuple and ElemFromList are not recursive and have a fixed depth +// regardless of T... +// MakeIndexSequence, on the other hand, it is recursive but with an +// instantiation depth of O(ln(N)). +template +class FlatTuple + : private FlatTupleBase, + typename MakeIndexSequence::type> { + using Indices = typename FlatTuple::FlatTupleBase::Indices; + + public: + FlatTuple() = default; + explicit FlatTuple(T... t) : FlatTuple::FlatTupleBase(std::move(t)...) {} + + template + const typename ElemFromList::type& Get() const { + return static_cast*>(this)->value; + } + + template + typename ElemFromList::type& Get() { + return static_cast*>(this)->value; + } +}; + +// Utility functions to be called with static_assert to induce deprecation +// warnings. +GTEST_INTERNAL_DEPRECATED( + "INSTANTIATE_TEST_CASE_P is deprecated, please use " + "INSTANTIATE_TEST_SUITE_P") +constexpr bool InstantiateTestCase_P_IsDeprecated() { return true; } + +GTEST_INTERNAL_DEPRECATED( + "TYPED_TEST_CASE_P is deprecated, please use " + "TYPED_TEST_SUITE_P") +constexpr bool TypedTestCase_P_IsDeprecated() { return true; } + +GTEST_INTERNAL_DEPRECATED( + "TYPED_TEST_CASE is deprecated, please use " + "TYPED_TEST_SUITE") +constexpr bool TypedTestCaseIsDeprecated() { return true; } + +GTEST_INTERNAL_DEPRECATED( + "REGISTER_TYPED_TEST_CASE_P is deprecated, please use " + "REGISTER_TYPED_TEST_SUITE_P") +constexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; } + +GTEST_INTERNAL_DEPRECATED( + "INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use " + "INSTANTIATE_TYPED_TEST_SUITE_P") +constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } + +} // namespace internal +} // namespace testing + +#define GTEST_MESSAGE_AT_(file, line, message, result_type) \ + ::testing::internal::AssertHelper(result_type, file, line, message) \ + = ::testing::Message() + +#define GTEST_MESSAGE_(message, result_type) \ + GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type) + +#define GTEST_FATAL_FAILURE_(message) \ + return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure) + +#define GTEST_NONFATAL_FAILURE_(message) \ + GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure) + +#define GTEST_SUCCESS_(message) \ + GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess) + +#define GTEST_SKIP_(message) \ + return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip) + +// Suppress MSVC warning 4072 (unreachable code) for the code following +// statement if it returns or throws (or doesn't return or throw in some +// situations). +#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \ + if (::testing::internal::AlwaysTrue()) { statement; } + +#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::ConstCharPtr gtest_msg = "") { \ + bool gtest_caught_expected = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (expected_exception const&) { \ + gtest_caught_expected = true; \ + } \ + catch (...) { \ + gtest_msg.value = \ + "Expected: " #statement " throws an exception of type " \ + #expected_exception ".\n Actual: it throws a different type."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + if (!gtest_caught_expected) { \ + gtest_msg.value = \ + "Expected: " #statement " throws an exception of type " \ + #expected_exception ".\n Actual: it throws nothing."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ + fail(gtest_msg.value) + +#define GTEST_TEST_NO_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (...) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ + fail("Expected: " #statement " doesn't throw an exception.\n" \ + " Actual: it throws.") + +#define GTEST_TEST_ANY_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + bool gtest_caught_any = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (...) { \ + gtest_caught_any = true; \ + } \ + if (!gtest_caught_any) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \ + fail("Expected: " #statement " throws an exception.\n" \ + " Actual: it doesn't.") + + +// Implements Boolean test assertions such as EXPECT_TRUE. expression can be +// either a boolean expression or an AssertionResult. text is a textual +// represenation of expression as it was passed into the EXPECT_TRUE. +#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar_ = \ + ::testing::AssertionResult(expression)) \ + ; \ + else \ + fail(::testing::internal::GetBoolAssertionFailureMessage(\ + gtest_ar_, text, #actual, #expected).c_str()) + +#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ + fail("Expected: " #statement " doesn't generate new fatal " \ + "failures in the current thread.\n" \ + " Actual: it does.") + +// Expands to the name of the class that implements the given test. +#define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + test_suite_name##_##test_name##_Test + +// Helper macro for defining tests. +#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \ + static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \ + "test_suite_name must not be empty"); \ + static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \ + "test_name must not be empty"); \ + class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + : public parent_class { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ + \ + private: \ + virtual void TestBody(); \ + static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \ + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name)); \ + }; \ + \ + ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name)::test_info_ = \ + ::testing::internal::MakeAndRegisterTestInfo( \ + #test_suite_name, #test_name, nullptr, nullptr, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \ + ::testing::internal::SuiteApiResolver< \ + parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \ + ::testing::internal::SuiteApiResolver< \ + parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \ + new ::testing::internal::TestFactoryImpl); \ + void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ diff --git a/include/gtest/internal/gtest-param-util.h b/include/gtest/internal/gtest-param-util.h new file mode 100644 index 0000000..9753399 --- /dev/null +++ b/include/gtest/internal/gtest-param-util.h @@ -0,0 +1,883 @@ +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// Type and function utilities for implementing parameterized tests. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-port.h" +#include "gtest/gtest-printers.h" + +namespace testing { +// Input to a parameterized test name generator, describing a test parameter. +// Consists of the parameter value and the integer parameter index. +template +struct TestParamInfo { + TestParamInfo(const ParamType& a_param, size_t an_index) : + param(a_param), + index(an_index) {} + ParamType param; + size_t index; +}; + +// A builtin parameterized test name generator which returns the result of +// testing::PrintToString. +struct PrintToStringParamName { + template + std::string operator()(const TestParamInfo& info) const { + return PrintToString(info.param); + } +}; + +namespace internal { + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// Utility Functions + +// Outputs a message explaining invalid registration of different +// fixture class for the same test suite. This may happen when +// TEST_P macro is used to define two tests with the same name +// but in different namespaces. +GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name, + CodeLocation code_location); + +template class ParamGeneratorInterface; +template class ParamGenerator; + +// Interface for iterating over elements provided by an implementation +// of ParamGeneratorInterface. +template +class ParamIteratorInterface { + public: + virtual ~ParamIteratorInterface() {} + // A pointer to the base generator instance. + // Used only for the purposes of iterator comparison + // to make sure that two iterators belong to the same generator. + virtual const ParamGeneratorInterface* BaseGenerator() const = 0; + // Advances iterator to point to the next element + // provided by the generator. The caller is responsible + // for not calling Advance() on an iterator equal to + // BaseGenerator()->End(). + virtual void Advance() = 0; + // Clones the iterator object. Used for implementing copy semantics + // of ParamIterator. + virtual ParamIteratorInterface* Clone() const = 0; + // Dereferences the current iterator and provides (read-only) access + // to the pointed value. It is the caller's responsibility not to call + // Current() on an iterator equal to BaseGenerator()->End(). + // Used for implementing ParamGenerator::operator*(). + virtual const T* Current() const = 0; + // Determines whether the given iterator and other point to the same + // element in the sequence generated by the generator. + // Used for implementing ParamGenerator::operator==(). + virtual bool Equals(const ParamIteratorInterface& other) const = 0; +}; + +// Class iterating over elements provided by an implementation of +// ParamGeneratorInterface. It wraps ParamIteratorInterface +// and implements the const forward iterator concept. +template +class ParamIterator { + public: + typedef T value_type; + typedef const T& reference; + typedef ptrdiff_t difference_type; + + // ParamIterator assumes ownership of the impl_ pointer. + ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {} + ParamIterator& operator=(const ParamIterator& other) { + if (this != &other) + impl_.reset(other.impl_->Clone()); + return *this; + } + + const T& operator*() const { return *impl_->Current(); } + const T* operator->() const { return impl_->Current(); } + // Prefix version of operator++. + ParamIterator& operator++() { + impl_->Advance(); + return *this; + } + // Postfix version of operator++. + ParamIterator operator++(int /*unused*/) { + ParamIteratorInterface* clone = impl_->Clone(); + impl_->Advance(); + return ParamIterator(clone); + } + bool operator==(const ParamIterator& other) const { + return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_); + } + bool operator!=(const ParamIterator& other) const { + return !(*this == other); + } + + private: + friend class ParamGenerator; + explicit ParamIterator(ParamIteratorInterface* impl) : impl_(impl) {} + std::unique_ptr > impl_; +}; + +// ParamGeneratorInterface is the binary interface to access generators +// defined in other translation units. +template +class ParamGeneratorInterface { + public: + typedef T ParamType; + + virtual ~ParamGeneratorInterface() {} + + // Generator interface definition + virtual ParamIteratorInterface* Begin() const = 0; + virtual ParamIteratorInterface* End() const = 0; +}; + +// Wraps ParamGeneratorInterface and provides general generator syntax +// compatible with the STL Container concept. +// This class implements copy initialization semantics and the contained +// ParamGeneratorInterface instance is shared among all copies +// of the original object. This is possible because that instance is immutable. +template +class ParamGenerator { + public: + typedef ParamIterator iterator; + + explicit ParamGenerator(ParamGeneratorInterface* impl) : impl_(impl) {} + ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {} + + ParamGenerator& operator=(const ParamGenerator& other) { + impl_ = other.impl_; + return *this; + } + + iterator begin() const { return iterator(impl_->Begin()); } + iterator end() const { return iterator(impl_->End()); } + + private: + std::shared_ptr > impl_; +}; + +// Generates values from a range of two comparable values. Can be used to +// generate sequences of user-defined types that implement operator+() and +// operator<(). +// This class is used in the Range() function. +template +class RangeGenerator : public ParamGeneratorInterface { + public: + RangeGenerator(T begin, T end, IncrementT step) + : begin_(begin), end_(end), + step_(step), end_index_(CalculateEndIndex(begin, end, step)) {} + ~RangeGenerator() override {} + + ParamIteratorInterface* Begin() const override { + return new Iterator(this, begin_, 0, step_); + } + ParamIteratorInterface* End() const override { + return new Iterator(this, end_, end_index_, step_); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, T value, int index, + IncrementT step) + : base_(base), value_(value), index_(index), step_(step) {} + ~Iterator() override {} + + const ParamGeneratorInterface* BaseGenerator() const override { + return base_; + } + void Advance() override { + value_ = static_cast(value_ + step_); + index_++; + } + ParamIteratorInterface* Clone() const override { + return new Iterator(*this); + } + const T* Current() const override { return &value_; } + bool Equals(const ParamIteratorInterface& other) const override { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const int other_index = + CheckedDowncastToActualType(&other)->index_; + return index_ == other_index; + } + + private: + Iterator(const Iterator& other) + : ParamIteratorInterface(), + base_(other.base_), value_(other.value_), index_(other.index_), + step_(other.step_) {} + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + T value_; + int index_; + const IncrementT step_; + }; // class RangeGenerator::Iterator + + static int CalculateEndIndex(const T& begin, + const T& end, + const IncrementT& step) { + int end_index = 0; + for (T i = begin; i < end; i = static_cast(i + step)) + end_index++; + return end_index; + } + + // No implementation - assignment is unsupported. + void operator=(const RangeGenerator& other); + + const T begin_; + const T end_; + const IncrementT step_; + // The index for the end() iterator. All the elements in the generated + // sequence are indexed (0-based) to aid iterator comparison. + const int end_index_; +}; // class RangeGenerator + + +// Generates values from a pair of STL-style iterators. Used in the +// ValuesIn() function. The elements are copied from the source range +// since the source can be located on the stack, and the generator +// is likely to persist beyond that stack frame. +template +class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface { + public: + template + ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) + : container_(begin, end) {} + ~ValuesInIteratorRangeGenerator() override {} + + ParamIteratorInterface* Begin() const override { + return new Iterator(this, container_.begin()); + } + ParamIteratorInterface* End() const override { + return new Iterator(this, container_.end()); + } + + private: + typedef typename ::std::vector ContainerType; + + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + typename ContainerType::const_iterator iterator) + : base_(base), iterator_(iterator) {} + ~Iterator() override {} + + const ParamGeneratorInterface* BaseGenerator() const override { + return base_; + } + void Advance() override { + ++iterator_; + value_.reset(); + } + ParamIteratorInterface* Clone() const override { + return new Iterator(*this); + } + // We need to use cached value referenced by iterator_ because *iterator_ + // can return a temporary object (and of type other then T), so just + // having "return &*iterator_;" doesn't work. + // value_ is updated here and not in Advance() because Advance() + // can advance iterator_ beyond the end of the range, and we cannot + // detect that fact. The client code, on the other hand, is + // responsible for not calling Current() on an out-of-range iterator. + const T* Current() const override { + if (value_.get() == nullptr) value_.reset(new T(*iterator_)); + return value_.get(); + } + bool Equals(const ParamIteratorInterface& other) const override { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + return iterator_ == + CheckedDowncastToActualType(&other)->iterator_; + } + + private: + Iterator(const Iterator& other) + // The explicit constructor call suppresses a false warning + // emitted by gcc when supplied with the -Wextra option. + : ParamIteratorInterface(), + base_(other.base_), + iterator_(other.iterator_) {} + + const ParamGeneratorInterface* const base_; + typename ContainerType::const_iterator iterator_; + // A cached value of *iterator_. We keep it here to allow access by + // pointer in the wrapping iterator's operator->(). + // value_ needs to be mutable to be accessed in Current(). + // Use of std::unique_ptr helps manage cached value's lifetime, + // which is bound by the lifespan of the iterator itself. + mutable std::unique_ptr value_; + }; // class ValuesInIteratorRangeGenerator::Iterator + + // No implementation - assignment is unsupported. + void operator=(const ValuesInIteratorRangeGenerator& other); + + const ContainerType container_; +}; // class ValuesInIteratorRangeGenerator + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Default parameterized test name generator, returns a string containing the +// integer test parameter index. +template +std::string DefaultParamName(const TestParamInfo& info) { + Message name_stream; + name_stream << info.index; + return name_stream.GetString(); +} + +template +void TestNotEmpty() { + static_assert(sizeof(T) == 0, "Empty arguments are not allowed."); +} +template +void TestNotEmpty(const T&) {} + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Stores a parameter value and later creates tests parameterized with that +// value. +template +class ParameterizedTestFactory : public TestFactoryBase { + public: + typedef typename TestClass::ParamType ParamType; + explicit ParameterizedTestFactory(ParamType parameter) : + parameter_(parameter) {} + Test* CreateTest() override { + TestClass::SetParam(¶meter_); + return new TestClass(); + } + + private: + const ParamType parameter_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// TestMetaFactoryBase is a base class for meta-factories that create +// test factories for passing into MakeAndRegisterTestInfo function. +template +class TestMetaFactoryBase { + public: + virtual ~TestMetaFactoryBase() {} + + virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0; +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// TestMetaFactory creates test factories for passing into +// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives +// ownership of test factory pointer, same factory object cannot be passed +// into that method twice. But ParameterizedTestSuiteInfo is going to call +// it for each Test/Parameter value combination. Thus it needs meta factory +// creator class. +template +class TestMetaFactory + : public TestMetaFactoryBase { + public: + using ParamType = typename TestSuite::ParamType; + + TestMetaFactory() {} + + TestFactoryBase* CreateTestFactory(ParamType parameter) override { + return new ParameterizedTestFactory(parameter); + } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestSuiteInfoBase is a generic interface +// to ParameterizedTestSuiteInfo classes. ParameterizedTestSuiteInfoBase +// accumulates test information provided by TEST_P macro invocations +// and generators provided by INSTANTIATE_TEST_SUITE_P macro invocations +// and uses that information to register all resulting test instances +// in RegisterTests method. The ParameterizeTestSuiteRegistry class holds +// a collection of pointers to the ParameterizedTestSuiteInfo objects +// and calls RegisterTests() on each of them when asked. +class ParameterizedTestSuiteInfoBase { + public: + virtual ~ParameterizedTestSuiteInfoBase() {} + + // Base part of test suite name for display purposes. + virtual const std::string& GetTestSuiteName() const = 0; + // Test case id to verify identity. + virtual TypeId GetTestSuiteTypeId() const = 0; + // UnitTest class invokes this method to register tests in this + // test suite right before running them in RUN_ALL_TESTS macro. + // This method should not be called more than once on any single + // instance of a ParameterizedTestSuiteInfoBase derived class. + virtual void RegisterTests() = 0; + + protected: + ParameterizedTestSuiteInfoBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestSuiteInfo accumulates tests obtained from TEST_P +// macro invocations for a particular test suite and generators +// obtained from INSTANTIATE_TEST_SUITE_P macro invocations for that +// test suite. It registers tests with all values generated by all +// generators when asked. +template +class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { + public: + // ParamType and GeneratorCreationFunc are private types but are required + // for declarations of public methods AddTestPattern() and + // AddTestSuiteInstantiation(). + using ParamType = typename TestSuite::ParamType; + // A function that returns an instance of appropriate generator type. + typedef ParamGenerator(GeneratorCreationFunc)(); + using ParamNameGeneratorFunc = std::string(const TestParamInfo&); + + explicit ParameterizedTestSuiteInfo(const char* name, + CodeLocation code_location) + : test_suite_name_(name), code_location_(code_location) {} + + // Test case base name for display purposes. + const std::string& GetTestSuiteName() const override { + return test_suite_name_; + } + // Test case id to verify identity. + TypeId GetTestSuiteTypeId() const override { return GetTypeId(); } + // TEST_P macro uses AddTestPattern() to record information + // about a single test in a LocalTestInfo structure. + // test_suite_name is the base name of the test suite (without invocation + // prefix). test_base_name is the name of an individual test without + // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is + // test suite base name and DoBar is test base name. + void AddTestPattern(const char* test_suite_name, const char* test_base_name, + TestMetaFactoryBase* meta_factory) { + tests_.push_back(std::shared_ptr( + new TestInfo(test_suite_name, test_base_name, meta_factory))); + } + // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information + // about a generator. + int AddTestSuiteInstantiation(const std::string& instantiation_name, + GeneratorCreationFunc* func, + ParamNameGeneratorFunc* name_func, + const char* file, int line) { + instantiations_.push_back( + InstantiationInfo(instantiation_name, func, name_func, file, line)); + return 0; // Return value used only to run this method in namespace scope. + } + // UnitTest class invokes this method to register tests in this test suite + // test suites right before running tests in RUN_ALL_TESTS macro. + // This method should not be called more than once on any single + // instance of a ParameterizedTestSuiteInfoBase derived class. + // UnitTest has a guard to prevent from calling this method more than once. + void RegisterTests() override { + for (typename TestInfoContainer::iterator test_it = tests_.begin(); + test_it != tests_.end(); ++test_it) { + std::shared_ptr test_info = *test_it; + for (typename InstantiationContainer::iterator gen_it = + instantiations_.begin(); gen_it != instantiations_.end(); + ++gen_it) { + const std::string& instantiation_name = gen_it->name; + ParamGenerator generator((*gen_it->generator)()); + ParamNameGeneratorFunc* name_func = gen_it->name_func; + const char* file = gen_it->file; + int line = gen_it->line; + + std::string test_suite_name; + if ( !instantiation_name.empty() ) + test_suite_name = instantiation_name + "/"; + test_suite_name += test_info->test_suite_base_name; + + size_t i = 0; + std::set test_param_names; + for (typename ParamGenerator::iterator param_it = + generator.begin(); + param_it != generator.end(); ++param_it, ++i) { + Message test_name_stream; + + std::string param_name = name_func( + TestParamInfo(*param_it, i)); + + GTEST_CHECK_(IsValidParamName(param_name)) + << "Parameterized test name '" << param_name + << "' is invalid, in " << file + << " line " << line << std::endl; + + GTEST_CHECK_(test_param_names.count(param_name) == 0) + << "Duplicate parameterized test name '" << param_name + << "', in " << file << " line " << line << std::endl; + + test_param_names.insert(param_name); + + if (!test_info->test_base_name.empty()) { + test_name_stream << test_info->test_base_name << "/"; + } + test_name_stream << param_name; + MakeAndRegisterTestInfo( + test_suite_name.c_str(), test_name_stream.GetString().c_str(), + nullptr, // No type parameter. + PrintToString(*param_it).c_str(), code_location_, + GetTestSuiteTypeId(), + SuiteApiResolver::GetSetUpCaseOrSuite(file, line), + SuiteApiResolver::GetTearDownCaseOrSuite(file, line), + test_info->test_meta_factory->CreateTestFactory(*param_it)); + } // for param_it + } // for gen_it + } // for test_it + } // RegisterTests + + private: + // LocalTestInfo structure keeps information about a single test registered + // with TEST_P macro. + struct TestInfo { + TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name, + TestMetaFactoryBase* a_test_meta_factory) + : test_suite_base_name(a_test_suite_base_name), + test_base_name(a_test_base_name), + test_meta_factory(a_test_meta_factory) {} + + const std::string test_suite_base_name; + const std::string test_base_name; + const std::unique_ptr > test_meta_factory; + }; + using TestInfoContainer = ::std::vector >; + // Records data received from INSTANTIATE_TEST_SUITE_P macros: + // + struct InstantiationInfo { + InstantiationInfo(const std::string &name_in, + GeneratorCreationFunc* generator_in, + ParamNameGeneratorFunc* name_func_in, + const char* file_in, + int line_in) + : name(name_in), + generator(generator_in), + name_func(name_func_in), + file(file_in), + line(line_in) {} + + std::string name; + GeneratorCreationFunc* generator; + ParamNameGeneratorFunc* name_func; + const char* file; + int line; + }; + typedef ::std::vector InstantiationContainer; + + static bool IsValidParamName(const std::string& name) { + // Check for empty string + if (name.empty()) + return false; + + // Check for invalid characters + for (std::string::size_type index = 0; index < name.size(); ++index) { + if (!isalnum(name[index]) && name[index] != '_') + return false; + } + + return true; + } + + const std::string test_suite_name_; + CodeLocation code_location_; + TestInfoContainer tests_; + InstantiationContainer instantiations_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo); +}; // class ParameterizedTestSuiteInfo + +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ +template +using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo; +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestSuiteRegistry contains a map of +// ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P +// and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding +// ParameterizedTestSuiteInfo descriptors. +class ParameterizedTestSuiteRegistry { + public: + ParameterizedTestSuiteRegistry() {} + ~ParameterizedTestSuiteRegistry() { + for (auto& test_suite_info : test_suite_infos_) { + delete test_suite_info; + } + } + + // Looks up or creates and returns a structure containing information about + // tests and instantiations of a particular test suite. + template + ParameterizedTestSuiteInfo* GetTestSuitePatternHolder( + const char* test_suite_name, CodeLocation code_location) { + ParameterizedTestSuiteInfo* typed_test_info = nullptr; + for (auto& test_suite_info : test_suite_infos_) { + if (test_suite_info->GetTestSuiteName() == test_suite_name) { + if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) { + // Complain about incorrect usage of Google Test facilities + // and terminate the program since we cannot guaranty correct + // test suite setup and tear-down in this case. + ReportInvalidTestSuiteType(test_suite_name, code_location); + posix::Abort(); + } else { + // At this point we are sure that the object we found is of the same + // type we are looking for, so we downcast it to that type + // without further checks. + typed_test_info = CheckedDowncastToActualType< + ParameterizedTestSuiteInfo >(test_suite_info); + } + break; + } + } + if (typed_test_info == nullptr) { + typed_test_info = new ParameterizedTestSuiteInfo( + test_suite_name, code_location); + test_suite_infos_.push_back(typed_test_info); + } + return typed_test_info; + } + void RegisterTests() { + for (auto& test_suite_info : test_suite_infos_) { + test_suite_info->RegisterTests(); + } + } +// Legacy API is deprecated but still available +#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + template + ParameterizedTestCaseInfo* GetTestCasePatternHolder( + const char* test_case_name, CodeLocation code_location) { + return GetTestSuitePatternHolder(test_case_name, code_location); + } + +#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ + + private: + using TestSuiteInfoContainer = ::std::vector; + + TestSuiteInfoContainer test_suite_infos_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry); +}; + +} // namespace internal + +// Forward declarations of ValuesIn(), which is implemented in +// include/gtest/gtest-param-test.h. +template +internal::ParamGenerator ValuesIn( + const Container& container); + +namespace internal { +// Used in the Values() function to provide polymorphic capabilities. + +template +class ValueArray { + public: + ValueArray(Ts... v) : v_{std::move(v)...} {} + + template + operator ParamGenerator() const { // NOLINT + return ValuesIn(MakeVector(MakeIndexSequence())); + } + + private: + template + std::vector MakeVector(IndexSequence) const { + return std::vector{static_cast(v_.template Get())...}; + } + + FlatTuple v_; +}; + +template +class CartesianProductGenerator + : public ParamGeneratorInterface<::std::tuple> { + public: + typedef ::std::tuple ParamType; + + CartesianProductGenerator(const std::tuple...>& g) + : generators_(g) {} + ~CartesianProductGenerator() override {} + + ParamIteratorInterface* Begin() const override { + return new Iterator(this, generators_, false); + } + ParamIteratorInterface* End() const override { + return new Iterator(this, generators_, true); + } + + private: + template + class IteratorImpl; + template + class IteratorImpl> + : public ParamIteratorInterface { + public: + IteratorImpl(const ParamGeneratorInterface* base, + const std::tuple...>& generators, bool is_end) + : base_(base), + begin_(std::get(generators).begin()...), + end_(std::get(generators).end()...), + current_(is_end ? end_ : begin_) { + ComputeCurrentValue(); + } + ~IteratorImpl() override {} + + const ParamGeneratorInterface* BaseGenerator() const override { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + void Advance() override { + assert(!AtEnd()); + // Advance the last iterator. + ++std::get(current_); + // if that reaches end, propagate that up. + AdvanceIfEnd(); + ComputeCurrentValue(); + } + ParamIteratorInterface* Clone() const override { + return new IteratorImpl(*this); + } + + const ParamType* Current() const override { return current_value_.get(); } + + bool Equals(const ParamIteratorInterface& other) const override { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const IteratorImpl* typed_other = + CheckedDowncastToActualType(&other); + + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + if (AtEnd() && typed_other->AtEnd()) return true; + + bool same = true; + bool dummy[] = { + (same = same && std::get(current_) == + std::get(typed_other->current_))...}; + (void)dummy; + return same; + } + + private: + template + void AdvanceIfEnd() { + if (std::get(current_) != std::get(end_)) return; + + bool last = ThisI == 0; + if (last) { + // We are done. Nothing else to propagate. + return; + } + + constexpr size_t NextI = ThisI - (ThisI != 0); + std::get(current_) = std::get(begin_); + ++std::get(current_); + AdvanceIfEnd(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = std::make_shared(*std::get(current_)...); + } + bool AtEnd() const { + bool at_end = false; + bool dummy[] = { + (at_end = at_end || std::get(current_) == std::get(end_))...}; + (void)dummy; + return at_end; + } + + const ParamGeneratorInterface* const base_; + std::tuple::iterator...> begin_; + std::tuple::iterator...> end_; + std::tuple::iterator...> current_; + std::shared_ptr current_value_; + }; + + using Iterator = IteratorImpl::type>; + + std::tuple...> generators_; +}; + +template +class CartesianProductHolder { + public: + CartesianProductHolder(const Gen&... g) : generators_(g...) {} + template + operator ParamGenerator<::std::tuple>() const { + return ParamGenerator<::std::tuple>( + new CartesianProductGenerator(generators_)); + } + + private: + std::tuple generators_; +}; + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ diff --git a/include/gtest/internal/gtest-port-arch.h b/include/gtest/internal/gtest-port-arch.h new file mode 100644 index 0000000..cece93d --- /dev/null +++ b/include/gtest/internal/gtest-port-arch.h @@ -0,0 +1,107 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines the GTEST_OS_* macro. +// It is separate from gtest-port.h so that custom/gtest-port.h can include it. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ + +// Determines the platform on which Google Test is compiled. +#ifdef __CYGWIN__ +# define GTEST_OS_CYGWIN 1 +# elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__) +# define GTEST_OS_WINDOWS_MINGW 1 +# define GTEST_OS_WINDOWS 1 +#elif defined _WIN32 +# define GTEST_OS_WINDOWS 1 +# ifdef _WIN32_WCE +# define GTEST_OS_WINDOWS_MOBILE 1 +# elif defined(WINAPI_FAMILY) +# include +# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# define GTEST_OS_WINDOWS_DESKTOP 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +# define GTEST_OS_WINDOWS_PHONE 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +# define GTEST_OS_WINDOWS_RT 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE) +# define GTEST_OS_WINDOWS_PHONE 1 +# define GTEST_OS_WINDOWS_TV_TITLE 1 +# else + // WINAPI_FAMILY defined but no known partition matched. + // Default to desktop. +# define GTEST_OS_WINDOWS_DESKTOP 1 +# endif +# else +# define GTEST_OS_WINDOWS_DESKTOP 1 +# endif // _WIN32_WCE +#elif defined __OS2__ +# define GTEST_OS_OS2 1 +#elif defined __APPLE__ +# define GTEST_OS_MAC 1 +# if TARGET_OS_IPHONE +# define GTEST_OS_IOS 1 +# endif +#elif defined __DragonFly__ +# define GTEST_OS_DRAGONFLY 1 +#elif defined __FreeBSD__ +# define GTEST_OS_FREEBSD 1 +#elif defined __Fuchsia__ +# define GTEST_OS_FUCHSIA 1 +#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__) +# define GTEST_OS_GNU_KFREEBSD 1 +#elif defined __linux__ +# define GTEST_OS_LINUX 1 +# if defined __ANDROID__ +# define GTEST_OS_LINUX_ANDROID 1 +# endif +#elif defined __MVS__ +# define GTEST_OS_ZOS 1 +#elif defined(__sun) && defined(__SVR4) +# define GTEST_OS_SOLARIS 1 +#elif defined(_AIX) +# define GTEST_OS_AIX 1 +#elif defined(__hpux) +# define GTEST_OS_HPUX 1 +#elif defined __native_client__ +# define GTEST_OS_NACL 1 +#elif defined __NetBSD__ +# define GTEST_OS_NETBSD 1 +#elif defined __OpenBSD__ +# define GTEST_OS_OPENBSD 1 +#elif defined __QNX__ +# define GTEST_OS_QNX 1 +#elif defined(__HAIKU__) +#define GTEST_OS_HAIKU 1 +#endif // __CYGWIN__ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h new file mode 100644 index 0000000..063fcb1 --- /dev/null +++ b/include/gtest/internal/gtest-port.h @@ -0,0 +1,2231 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Low-level types and utilities for porting Google Test to various +// platforms. All macros ending with _ and symbols defined in an +// internal namespace are subject to change without notice. Code +// outside Google Test MUST NOT USE THEM DIRECTLY. Macros that don't +// end with _ are part of Google Test's public API and can be used by +// code outside Google Test. +// +// This file is fundamental to Google Test. All other Google Test source +// files are expected to #include this. Therefore, it cannot #include +// any other Google Test header. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ + +// Environment-describing macros +// ----------------------------- +// +// Google Test can be used in many different environments. Macros in +// this section tell Google Test what kind of environment it is being +// used in, such that Google Test can provide environment-specific +// features and implementations. +// +// Google Test tries to automatically detect the properties of its +// environment, so users usually don't need to worry about these +// macros. However, the automatic detection is not perfect. +// Sometimes it's necessary for a user to define some of the following +// macros in the build script to override Google Test's decisions. +// +// If the user doesn't define a macro in the list, Google Test will +// provide a default definition. After this header is #included, all +// macros in this list will be defined to either 1 or 0. +// +// Notes to maintainers: +// - Each macro here is a user-tweakable knob; do not grow the list +// lightly. +// - Use #if to key off these macros. Don't use #ifdef or "#if +// defined(...)", which will not work as these macros are ALWAYS +// defined. +// +// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2) +// is/isn't available. +// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions +// are enabled. +// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular +// expressions are/aren't available. +// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that +// is/isn't available. +// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't +// enabled. +// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that +// std::wstring does/doesn't work (Google Test can +// be used where std::wstring is unavailable). +// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the +// compiler supports Microsoft's "Structured +// Exception Handling". +// GTEST_HAS_STREAM_REDIRECTION +// - Define it to 1/0 to indicate whether the +// platform supports I/O stream redirection using +// dup() and dup2(). +// GTEST_LINKED_AS_SHARED_LIBRARY +// - Define to 1 when compiling tests that use +// Google Test as a shared library (known as +// DLL on Windows). +// GTEST_CREATE_SHARED_LIBRARY +// - Define to 1 when compiling Google Test itself +// as a shared library. +// GTEST_DEFAULT_DEATH_TEST_STYLE +// - The default value of --gtest_death_test_style. +// The legacy default has been "fast" in the open +// source version since 2008. The recommended value +// is "threadsafe", and can be set in +// custom/gtest-port.h. + +// Platform-indicating macros +// -------------------------- +// +// Macros indicating the platform on which Google Test is being used +// (a macro is defined to 1 if compiled on the given platform; +// otherwise UNDEFINED -- it's never defined to 0.). Google Test +// defines these macros automatically. Code outside Google Test MUST +// NOT define them. +// +// GTEST_OS_AIX - IBM AIX +// GTEST_OS_CYGWIN - Cygwin +// GTEST_OS_DRAGONFLY - DragonFlyBSD +// GTEST_OS_FREEBSD - FreeBSD +// GTEST_OS_FUCHSIA - Fuchsia +// GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD +// GTEST_OS_HAIKU - Haiku +// GTEST_OS_HPUX - HP-UX +// GTEST_OS_LINUX - Linux +// GTEST_OS_LINUX_ANDROID - Google Android +// GTEST_OS_MAC - Mac OS X +// GTEST_OS_IOS - iOS +// GTEST_OS_NACL - Google Native Client (NaCl) +// GTEST_OS_NETBSD - NetBSD +// GTEST_OS_OPENBSD - OpenBSD +// GTEST_OS_OS2 - OS/2 +// GTEST_OS_QNX - QNX +// GTEST_OS_SOLARIS - Sun Solaris +// GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile) +// GTEST_OS_WINDOWS_DESKTOP - Windows Desktop +// GTEST_OS_WINDOWS_MINGW - MinGW +// GTEST_OS_WINDOWS_MOBILE - Windows Mobile +// GTEST_OS_WINDOWS_PHONE - Windows Phone +// GTEST_OS_WINDOWS_RT - Windows Store App/WinRT +// GTEST_OS_ZOS - z/OS +// +// Among the platforms, Cygwin, Linux, Mac OS X, and Windows have the +// most stable support. Since core members of the Google Test project +// don't have access to other platforms, support for them may be less +// stable. If you notice any problems on your platform, please notify +// googletestframework@googlegroups.com (patches for fixing them are +// even more welcome!). +// +// It is possible that none of the GTEST_OS_* macros are defined. + +// Feature-indicating macros +// ------------------------- +// +// Macros indicating which Google Test features are available (a macro +// is defined to 1 if the corresponding feature is supported; +// otherwise UNDEFINED -- it's never defined to 0.). Google Test +// defines these macros automatically. Code outside Google Test MUST +// NOT define them. +// +// These macros are public so that portable tests can be written. +// Such tests typically surround code using a feature with an #if +// which controls that code. For example: +// +// #if GTEST_HAS_DEATH_TEST +// EXPECT_DEATH(DoSomethingDeadly()); +// #endif +// +// GTEST_HAS_DEATH_TEST - death tests +// GTEST_HAS_TYPED_TEST - typed tests +// GTEST_HAS_TYPED_TEST_P - type-parameterized tests +// GTEST_IS_THREADSAFE - Google Test is thread-safe. +// GOOGLETEST_CM0007 DO NOT DELETE +// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with +// GTEST_HAS_POSIX_RE (see above) which users can +// define themselves. +// GTEST_USES_SIMPLE_RE - our own simple regex is used; +// the above RE\b(s) are mutually exclusive. + +// Misc public macros +// ------------------ +// +// GTEST_FLAG(flag_name) - references the variable corresponding to +// the given Google Test flag. + +// Internal utilities +// ------------------ +// +// The following macros and utilities are for Google Test's INTERNAL +// use only. Code outside Google Test MUST NOT USE THEM DIRECTLY. +// +// Macros for basic C++ coding: +// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. +// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a +// variable don't have to be used. +// GTEST_DISALLOW_ASSIGN_ - disables operator=. +// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=. +// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used. +// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is +// suppressed (constant conditional). +// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127 +// is suppressed. +// +// Synchronization: +// Mutex, MutexLock, ThreadLocal, GetThreadCount() +// - synchronization primitives. +// +// Regular expressions: +// RE - a simple regular expression class using the POSIX +// Extended Regular Expression syntax on UNIX-like platforms +// GOOGLETEST_CM0008 DO NOT DELETE +// or a reduced regular exception syntax on other +// platforms, including Windows. +// Logging: +// GTEST_LOG_() - logs messages at the specified severity level. +// LogToStderr() - directs all log messages to stderr. +// FlushInfoLog() - flushes informational log messages. +// +// Stdout and stderr capturing: +// CaptureStdout() - starts capturing stdout. +// GetCapturedStdout() - stops capturing stdout and returns the captured +// string. +// CaptureStderr() - starts capturing stderr. +// GetCapturedStderr() - stops capturing stderr and returns the captured +// string. +// +// Integer types: +// TypeWithSize - maps an integer to a int type. +// Int32, UInt32, Int64, UInt64, TimeInMillis +// - integers of known sizes. +// BiggestInt - the biggest signed integer type. +// +// Command-line utilities: +// GTEST_DECLARE_*() - declares a flag. +// GTEST_DEFINE_*() - defines a flag. +// GetInjectableArgvs() - returns the command line as a vector of strings. +// +// Environment variable utilities: +// GetEnv() - gets the value of an environment variable. +// BoolFromGTestEnv() - parses a bool environment variable. +// Int32FromGTestEnv() - parses an Int32 environment variable. +// StringFromGTestEnv() - parses a string environment variable. +// +// Deprecation warnings: +// GTEST_INTERNAL_DEPRECATED(message) - attribute marking a function as +// deprecated; calling a marked function +// should generate a compiler warning + +#include // for isspace, etc +#include // for ptrdiff_t +#include +#include +#include +#include +#include + +#ifndef _WIN32_WCE +# include +# include +#endif // !_WIN32_WCE + +#if defined __APPLE__ +# include +# include +#endif + +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include +#include +#include // NOLINT + +#include "gtest/internal/gtest-port-arch.h" +#include "gtest/internal/custom/gtest-port.h" + +#if !defined(GTEST_DEV_EMAIL_) +# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" +# define GTEST_FLAG_PREFIX_ "gtest_" +# define GTEST_FLAG_PREFIX_DASH_ "gtest-" +# define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" +# define GTEST_NAME_ "Google Test" +# define GTEST_PROJECT_URL_ "https://github.com/google/googletest/" +#endif // !defined(GTEST_DEV_EMAIL_) + +#if !defined(GTEST_INIT_GOOGLE_TEST_NAME_) +# define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest" +#endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_) + +// Determines the version of gcc that is used to compile this. +#ifdef __GNUC__ +// 40302 means version 4.3.2. +# define GTEST_GCC_VER_ \ + (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) +#endif // __GNUC__ + +// Macros for disabling Microsoft Visual C++ warnings. +// +// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385) +// /* code that triggers warnings C4800 and C4385 */ +// GTEST_DISABLE_MSC_WARNINGS_POP_() +#if defined(_MSC_VER) +# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ + __pragma(warning(push)) \ + __pragma(warning(disable: warnings)) +# define GTEST_DISABLE_MSC_WARNINGS_POP_() \ + __pragma(warning(pop)) +#else +// Not all compilers are MSVC +# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) +# define GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + +// Clang on Windows does not understand MSVC's pragma warning. +// We need clang-specific way to disable function deprecation warning. +#ifdef __clang__ +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") +#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + _Pragma("clang diagnostic pop") +#else +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + +// Brings in definitions for functions used in the testing::internal::posix +// namespace (read, write, close, chdir, isatty, stat). We do not currently +// use them on Windows Mobile. +#if GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS_MOBILE +# include +# include +# endif +// In order to avoid having to include , use forward declaration +#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) +// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two +// separate (equivalent) structs, instead of using typedef +typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; +#else +// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. +// This assumption is verified by +// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. +typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; +#endif +#else +// This assumes that non-Windows OSes provide unistd.h. For OSes where this +// is not the case, we need to include headers that provide the functions +// mentioned above. +# include +# include +#endif // GTEST_OS_WINDOWS + +#if GTEST_OS_LINUX_ANDROID +// Used to define __ANDROID_API__ matching the target NDK API level. +# include // NOLINT +#endif + +// Defines this to true if and only if Google Test can use POSIX regular +// expressions. +#ifndef GTEST_HAS_POSIX_RE +# if GTEST_OS_LINUX_ANDROID +// On Android, is only available starting with Gingerbread. +# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) +# else +# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) +# endif +#endif + +#if GTEST_USES_PCRE +// The appropriate headers have already been included. + +#elif GTEST_HAS_POSIX_RE + +// On some platforms, needs someone to define size_t, and +// won't compile otherwise. We can #include it here as we already +// included , which is guaranteed to define size_t through +// . +# include // NOLINT + +# define GTEST_USES_POSIX_RE 1 + +#elif GTEST_OS_WINDOWS + +// is not available on Windows. Use our own simple regex +// implementation instead. +# define GTEST_USES_SIMPLE_RE 1 + +#else + +// may not be available on this platform. Use our own +// simple regex implementation instead. +# define GTEST_USES_SIMPLE_RE 1 + +#endif // GTEST_USES_PCRE + +#ifndef GTEST_HAS_EXCEPTIONS +// The user didn't tell us whether exceptions are enabled, so we need +// to figure it out. +# if defined(_MSC_VER) && defined(_CPPUNWIND) +// MSVC defines _CPPUNWIND to 1 if and only if exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__BORLANDC__) +// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS +// macro to enable exceptions, so we'll do the same. +// Assumes that exceptions are enabled by default. +# ifndef _HAS_EXCEPTIONS +# define _HAS_EXCEPTIONS 1 +# endif // _HAS_EXCEPTIONS +# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS +# elif defined(__clang__) +// clang defines __EXCEPTIONS if and only if exceptions are enabled before clang +// 220714, but if and only if cleanups are enabled after that. In Obj-C++ files, +// there can be cleanups for ObjC exceptions which also need cleanups, even if +// C++ exceptions are disabled. clang has __has_feature(cxx_exceptions) which +// checks for C++ exceptions starting at clang r206352, but which checked for +// cleanups prior to that. To reliably check for C++ exception availability with +// clang, check for +// __EXCEPTIONS && __has_feature(cxx_exceptions). +# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) +# elif defined(__GNUC__) && __EXCEPTIONS +// gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__SUNPRO_CC) +// Sun Pro CC supports exceptions. However, there is no compile-time way of +// detecting whether they are enabled or not. Therefore, we assume that +// they are enabled unless the user tells us otherwise. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__IBMCPP__) && __EXCEPTIONS +// xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__HP_aCC) +// Exception handling is in effect by default in HP aCC compiler. It has to +// be turned of by +noeh compiler option if desired. +# define GTEST_HAS_EXCEPTIONS 1 +# else +// For other compilers, we assume exceptions are disabled to be +// conservative. +# define GTEST_HAS_EXCEPTIONS 0 +# endif // defined(_MSC_VER) || defined(__BORLANDC__) +#endif // GTEST_HAS_EXCEPTIONS + +#if !defined(GTEST_HAS_STD_STRING) +// Even though we don't use this macro any longer, we keep it in case +// some clients still depend on it. +# define GTEST_HAS_STD_STRING 1 +#elif !GTEST_HAS_STD_STRING +// The user told us that ::std::string isn't available. +# error "::std::string isn't available." +#endif // !defined(GTEST_HAS_STD_STRING) + +#ifndef GTEST_HAS_STD_WSTRING +// The user didn't tell us whether ::std::wstring is available, so we need +// to figure it out. +// Cygwin 1.7 and below doesn't support ::std::wstring. +// Solaris' libc++ doesn't support it either. Android has +// no support for it at least as recent as Froyo (2.2). +#define GTEST_HAS_STD_WSTRING \ + (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + GTEST_OS_HAIKU)) + +#endif // GTEST_HAS_STD_WSTRING + +// Determines whether RTTI is available. +#ifndef GTEST_HAS_RTTI +// The user didn't tell us whether RTTI is enabled, so we need to +// figure it out. + +# ifdef _MSC_VER + +#ifdef _CPPRTTI // MSVC defines this macro if and only if RTTI is enabled. +# define GTEST_HAS_RTTI 1 +# else +# define GTEST_HAS_RTTI 0 +# endif + +// Starting with version 4.3.2, gcc defines __GXX_RTTI if and only if RTTI is +// enabled. +# elif defined(__GNUC__) + +# ifdef __GXX_RTTI +// When building against STLport with the Android NDK and with +// -frtti -fno-exceptions, the build fails at link time with undefined +// references to __cxa_bad_typeid. Note sure if STL or toolchain bug, +// so disable RTTI when detected. +# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \ + !defined(__EXCEPTIONS) +# define GTEST_HAS_RTTI 0 +# else +# define GTEST_HAS_RTTI 1 +# endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS +# else +# define GTEST_HAS_RTTI 0 +# endif // __GXX_RTTI + +// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends +// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the +// first version with C++ support. +# elif defined(__clang__) + +# define GTEST_HAS_RTTI __has_feature(cxx_rtti) + +// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if +// both the typeid and dynamic_cast features are present. +# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900) + +# ifdef __RTTI_ALL__ +# define GTEST_HAS_RTTI 1 +# else +# define GTEST_HAS_RTTI 0 +# endif + +# else + +// For all other compilers, we assume RTTI is enabled. +# define GTEST_HAS_RTTI 1 + +# endif // _MSC_VER + +#endif // GTEST_HAS_RTTI + +// It's this header's responsibility to #include when RTTI +// is enabled. +#if GTEST_HAS_RTTI +# include +#endif + +// Determines whether Google Test can use the pthreads library. +#ifndef GTEST_HAS_PTHREAD +// The user didn't tell us explicitly, so we make reasonable assumptions about +// which platforms have pthreads support. +// +// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0 +// to your compiler flags. +#define GTEST_HAS_PTHREAD \ + (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \ + GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ + GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \ + GTEST_OS_HAIKU) +#endif // GTEST_HAS_PTHREAD + +#if GTEST_HAS_PTHREAD +// gtest-port.h guarantees to #include when GTEST_HAS_PTHREAD is +// true. +# include // NOLINT + +// For timespec and nanosleep, used below. +# include // NOLINT +#endif + +// Determines whether clone(2) is supported. +// Usually it will only be available on Linux, excluding +// Linux on the Itanium architecture. +// Also see http://linux.die.net/man/2/clone. +#ifndef GTEST_HAS_CLONE +// The user didn't tell us, so we need to figure it out. + +# if GTEST_OS_LINUX && !defined(__ia64__) +# if GTEST_OS_LINUX_ANDROID +// On Android, clone() became available at different API levels for each 32-bit +// architecture. +# if defined(__LP64__) || \ + (defined(__arm__) && __ANDROID_API__ >= 9) || \ + (defined(__mips__) && __ANDROID_API__ >= 12) || \ + (defined(__i386__) && __ANDROID_API__ >= 17) +# define GTEST_HAS_CLONE 1 +# else +# define GTEST_HAS_CLONE 0 +# endif +# else +# define GTEST_HAS_CLONE 1 +# endif +# else +# define GTEST_HAS_CLONE 0 +# endif // GTEST_OS_LINUX && !defined(__ia64__) + +#endif // GTEST_HAS_CLONE + +// Determines whether to support stream redirection. This is used to test +// output correctness and to implement death tests. +#ifndef GTEST_HAS_STREAM_REDIRECTION +// By default, we assume that stream redirection is supported on all +// platforms except known mobile ones. +# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT +# define GTEST_HAS_STREAM_REDIRECTION 0 +# else +# define GTEST_HAS_STREAM_REDIRECTION 1 +# endif // !GTEST_OS_WINDOWS_MOBILE +#endif // GTEST_HAS_STREAM_REDIRECTION + +// Determines whether to support death tests. +// pops up a dialog window that cannot be suppressed programmatically. +#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + (GTEST_OS_MAC && !GTEST_OS_IOS) || \ + (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW || \ + GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \ + GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ + GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU) +# define GTEST_HAS_DEATH_TEST 1 +#endif + +// Determines whether to support type-driven tests. + +// Typed tests need and variadic macros, which GCC, VC++ 8.0, +// Sun Pro CC, IBM Visual Age, and HP aCC support. +#if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \ + defined(__IBMCPP__) || defined(__HP_aCC) +# define GTEST_HAS_TYPED_TEST 1 +# define GTEST_HAS_TYPED_TEST_P 1 +#endif + +// Determines whether the system compiler uses UTF-16 for encoding wide strings. +#define GTEST_WIDE_STRING_USES_UTF16_ \ + (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2) + +// Determines whether test results can be streamed to a socket. +#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \ + GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD +# define GTEST_CAN_STREAM_RESULTS_ 1 +#endif + +// Defines some utility macros. + +// The GNU compiler emits a warning if nested "if" statements are followed by +// an "else" statement and braces are not used to explicitly disambiguate the +// "else" binding. This leads to problems with code like: +// +// if (gate) +// ASSERT_*(condition) << "Some message"; +// +// The "switch (0) case 0:" idiom is used to suppress this. +#ifdef __INTEL_COMPILER +# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ +#else +# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT +#endif + +// Use this annotation at the end of a struct/class definition to +// prevent the compiler from optimizing away instances that are never +// used. This is useful when all interesting logic happens inside the +// c'tor and / or d'tor. Example: +// +// struct Foo { +// Foo() { ... } +// } GTEST_ATTRIBUTE_UNUSED_; +// +// Also use it after a variable or parameter declaration to tell the +// compiler the variable/parameter does not have to be used. +#if defined(__GNUC__) && !defined(COMPILER_ICC) +# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +#elif defined(__clang__) +# if __has_attribute(unused) +# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +# endif +#endif +#ifndef GTEST_ATTRIBUTE_UNUSED_ +# define GTEST_ATTRIBUTE_UNUSED_ +#endif + +// Use this annotation before a function that takes a printf format string. +#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC) +# if defined(__MINGW_PRINTF_FORMAT) +// MinGW has two different printf implementations. Ensure the format macro +// matches the selected implementation. See +// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \ + first_to_check))) +# else +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((__format__(__printf__, string_index, first_to_check))) +# endif +#else +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) +#endif + + +// A macro to disallow operator= +// This should be used in the private: declarations for a class. +#define GTEST_DISALLOW_ASSIGN_(type) \ + void operator=(type const &) = delete + +// A macro to disallow copy constructor and operator= +// This should be used in the private: declarations for a class. +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ + type(type const &) = delete; \ + GTEST_DISALLOW_ASSIGN_(type) + +// Tell the compiler to warn about unused return values for functions declared +// with this macro. The macro should be used on function declarations +// following the argument list: +// +// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; +#if defined(__GNUC__) && !defined(COMPILER_ICC) +# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result)) +#else +# define GTEST_MUST_USE_RESULT_ +#endif // __GNUC__ && !COMPILER_ICC + +// MS C++ compiler emits warning when a conditional expression is compile time +// constant. In some contexts this warning is false positive and needs to be +// suppressed. Use the following two macros in such cases: +// +// GTEST_INTENTIONAL_CONST_COND_PUSH_() +// while (true) { +// GTEST_INTENTIONAL_CONST_COND_POP_() +// } +# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127) +# define GTEST_INTENTIONAL_CONST_COND_POP_() \ + GTEST_DISABLE_MSC_WARNINGS_POP_() + +// Determine whether the compiler supports Microsoft's Structured Exception +// Handling. This is supported by several Windows compilers but generally +// does not exist on any other system. +#ifndef GTEST_HAS_SEH +// The user didn't tell us, so we need to figure it out. + +# if defined(_MSC_VER) || defined(__BORLANDC__) +// These two compilers are known to support SEH. +# define GTEST_HAS_SEH 1 +# else +// Assume no SEH. +# define GTEST_HAS_SEH 0 +# endif + +#endif // GTEST_HAS_SEH + +#ifndef GTEST_IS_THREADSAFE + +#define GTEST_IS_THREADSAFE \ + (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \ + (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \ + GTEST_HAS_PTHREAD) + +#endif // GTEST_IS_THREADSAFE + +// GTEST_API_ qualifies all symbols that must be exported. The definitions below +// are guarded by #ifndef to give embedders a chance to define GTEST_API_ in +// gtest/internal/custom/gtest-port.h +#ifndef GTEST_API_ + +#ifdef _MSC_VER +# if GTEST_LINKED_AS_SHARED_LIBRARY +# define GTEST_API_ __declspec(dllimport) +# elif GTEST_CREATE_SHARED_LIBRARY +# define GTEST_API_ __declspec(dllexport) +# endif +#elif __GNUC__ >= 4 || defined(__clang__) +# define GTEST_API_ __attribute__((visibility ("default"))) +#endif // _MSC_VER + +#endif // GTEST_API_ + +#ifndef GTEST_API_ +# define GTEST_API_ +#endif // GTEST_API_ + +#ifndef GTEST_DEFAULT_DEATH_TEST_STYLE +# define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" +#endif // GTEST_DEFAULT_DEATH_TEST_STYLE + +#ifdef __GNUC__ +// Ask the compiler to never inline a given function. +# define GTEST_NO_INLINE_ __attribute__((noinline)) +#else +# define GTEST_NO_INLINE_ +#endif + +// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project. +#if !defined(GTEST_HAS_CXXABI_H_) +# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) +# define GTEST_HAS_CXXABI_H_ 1 +# else +# define GTEST_HAS_CXXABI_H_ 0 +# endif +#endif + +// A function level attribute to disable checking for use of uninitialized +// memory when built with MemorySanitizer. +#if defined(__clang__) +# if __has_feature(memory_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \ + __attribute__((no_sanitize_memory)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +# endif // __has_feature(memory_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +#endif // __clang__ + +// A function level attribute to disable AddressSanitizer instrumentation. +#if defined(__clang__) +# if __has_feature(address_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \ + __attribute__((no_sanitize_address)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +# endif // __has_feature(address_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +#endif // __clang__ + +// A function level attribute to disable HWAddressSanitizer instrumentation. +#if defined(__clang__) +# if __has_feature(hwaddress_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \ + __attribute__((no_sanitize("hwaddress"))) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ +# endif // __has_feature(hwaddress_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ +#endif // __clang__ + +// A function level attribute to disable ThreadSanitizer instrumentation. +#if defined(__clang__) +# if __has_feature(thread_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \ + __attribute__((no_sanitize_thread)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +# endif // __has_feature(thread_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +#endif // __clang__ + +namespace testing { + +class Message; + +// Legacy imports for backwards compatibility. +// New code should use std:: names directly. +using std::get; +using std::make_tuple; +using std::tuple; +using std::tuple_element; +using std::tuple_size; + +namespace internal { + +// A secret type that Google Test users don't know about. It has no +// definition on purpose. Therefore it's impossible to create a +// Secret object, which is what we want. +class Secret; + +// The GTEST_COMPILE_ASSERT_ is a legacy macro used to verify that a compile +// time expression is true (in new code, use static_assert instead). For +// example, you could use it to verify the size of a static array: +// +// GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES, +// names_incorrect_size); +// +// The second argument to the macro must be a valid C++ identifier. If the +// expression is false, compiler will issue an error containing this identifier. +#define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg) + +// Evaluates to the number of elements in 'array'. +#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0])) + +// A helper for suppressing warnings on constant condition. It just +// returns 'condition'. +GTEST_API_ bool IsTrue(bool condition); + +// Defines RE. + +#if GTEST_USES_PCRE +// if used, PCRE is injected by custom/gtest-port.h +#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE + +// A simple C++ wrapper for . It uses the POSIX Extended +// Regular Expression syntax. +class GTEST_API_ RE { + public: + // A copy constructor is required by the Standard to initialize object + // references from r-values. + RE(const RE& other) { Init(other.pattern()); } + + // Constructs an RE from a string. + RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT + + RE(const char* regex) { Init(regex); } // NOLINT + ~RE(); + + // Returns the string representation of the regex. + const char* pattern() const { return pattern_; } + + // FullMatch(str, re) returns true if and only if regular expression re + // matches the entire str. + // PartialMatch(str, re) returns true if and only if regular expression re + // matches a substring of str (including str itself). + static bool FullMatch(const ::std::string& str, const RE& re) { + return FullMatch(str.c_str(), re); + } + static bool PartialMatch(const ::std::string& str, const RE& re) { + return PartialMatch(str.c_str(), re); + } + + static bool FullMatch(const char* str, const RE& re); + static bool PartialMatch(const char* str, const RE& re); + + private: + void Init(const char* regex); + const char* pattern_; + bool is_valid_; + +# if GTEST_USES_POSIX_RE + + regex_t full_regex_; // For FullMatch(). + regex_t partial_regex_; // For PartialMatch(). + +# else // GTEST_USES_SIMPLE_RE + + const char* full_pattern_; // For FullMatch(); + +# endif + + GTEST_DISALLOW_ASSIGN_(RE); +}; + +#endif // GTEST_USES_PCRE + +// Formats a source file path and a line number as they would appear +// in an error message from the compiler used to compile this code. +GTEST_API_ ::std::string FormatFileLocation(const char* file, int line); + +// Formats a file location for compiler-independent XML output. +// Although this function is not platform dependent, we put it next to +// FormatFileLocation in order to contrast the two functions. +GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file, + int line); + +// Defines logging utilities: +// GTEST_LOG_(severity) - logs messages at the specified severity level. The +// message itself is streamed into the macro. +// LogToStderr() - directs all log messages to stderr. +// FlushInfoLog() - flushes informational log messages. + +enum GTestLogSeverity { + GTEST_INFO, + GTEST_WARNING, + GTEST_ERROR, + GTEST_FATAL +}; + +// Formats log entry severity, provides a stream object for streaming the +// log message, and terminates the message with a newline when going out of +// scope. +class GTEST_API_ GTestLog { + public: + GTestLog(GTestLogSeverity severity, const char* file, int line); + + // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program. + ~GTestLog(); + + ::std::ostream& GetStream() { return ::std::cerr; } + + private: + const GTestLogSeverity severity_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog); +}; + +#if !defined(GTEST_LOG_) + +# define GTEST_LOG_(severity) \ + ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \ + __FILE__, __LINE__).GetStream() + +inline void LogToStderr() {} +inline void FlushInfoLog() { fflush(nullptr); } + +#endif // !defined(GTEST_LOG_) + +#if !defined(GTEST_CHECK_) +// INTERNAL IMPLEMENTATION - DO NOT USE. +// +// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition +// is not satisfied. +// Synopsys: +// GTEST_CHECK_(boolean_condition); +// or +// GTEST_CHECK_(boolean_condition) << "Additional message"; +// +// This checks the condition and if the condition is not satisfied +// it prints message about the condition violation, including the +// condition itself, plus additional message streamed into it, if any, +// and then it aborts the program. It aborts the program irrespective of +// whether it is built in the debug mode or not. +# define GTEST_CHECK_(condition) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::IsTrue(condition)) \ + ; \ + else \ + GTEST_LOG_(FATAL) << "Condition " #condition " failed. " +#endif // !defined(GTEST_CHECK_) + +// An all-mode assert to verify that the given POSIX-style function +// call returns 0 (indicating success). Known limitation: this +// doesn't expand to a balanced 'if' statement, so enclose the macro +// in {} if you need to use it as the only statement in an 'if' +// branch. +#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \ + if (const int gtest_error = (posix_call)) \ + GTEST_LOG_(FATAL) << #posix_call << "failed with error " \ + << gtest_error + +// Transforms "T" into "const T&" according to standard reference collapsing +// rules (this is only needed as a backport for C++98 compilers that do not +// support reference collapsing). Specifically, it transforms: +// +// char ==> const char& +// const char ==> const char& +// char& ==> char& +// const char& ==> const char& +// +// Note that the non-const reference will not have "const" added. This is +// standard, and necessary so that "T" can always bind to "const T&". +template +struct ConstRef { typedef const T& type; }; +template +struct ConstRef { typedef T& type; }; + +// The argument T must depend on some template parameters. +#define GTEST_REFERENCE_TO_CONST_(T) \ + typename ::testing::internal::ConstRef::type + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Use ImplicitCast_ as a safe version of static_cast for upcasting in +// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a +// const Foo*). When you use ImplicitCast_, the compiler checks that +// the cast is safe. Such explicit ImplicitCast_s are necessary in +// surprisingly many situations where C++ demands an exact type match +// instead of an argument type convertable to a target type. +// +// The syntax for using ImplicitCast_ is the same as for static_cast: +// +// ImplicitCast_(expr) +// +// ImplicitCast_ would have been part of the C++ standard library, +// but the proposal was submitted too late. It will probably make +// its way into the language in the future. +// +// This relatively ugly name is intentional. It prevents clashes with +// similar functions users may have (e.g., implicit_cast). The internal +// namespace alone is not enough because the function can be found by ADL. +template +inline To ImplicitCast_(To x) { return x; } + +// When you upcast (that is, cast a pointer from type Foo to type +// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts +// always succeed. When you downcast (that is, cast a pointer from +// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because +// how do you know the pointer is really of type SubclassOfFoo? It +// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus, +// when you downcast, you should use this macro. In debug mode, we +// use dynamic_cast<> to double-check the downcast is legal (we die +// if it's not). In normal mode, we do the efficient static_cast<> +// instead. Thus, it's important to test in debug mode to make sure +// the cast is legal! +// This is the only place in the code we should use dynamic_cast<>. +// In particular, you SHOULDN'T be using dynamic_cast<> in order to +// do RTTI (eg code like this: +// if (dynamic_cast(foo)) HandleASubclass1Object(foo); +// if (dynamic_cast(foo)) HandleASubclass2Object(foo); +// You should design the code some other way not to need this. +// +// This relatively ugly name is intentional. It prevents clashes with +// similar functions users may have (e.g., down_cast). The internal +// namespace alone is not enough because the function can be found by ADL. +template // use like this: DownCast_(foo); +inline To DownCast_(From* f) { // so we only accept pointers + // Ensures that To is a sub-type of From *. This test is here only + // for compile-time type checking, and has no overhead in an + // optimized build at run-time, as it will be optimized away + // completely. + GTEST_INTENTIONAL_CONST_COND_PUSH_() + if (false) { + GTEST_INTENTIONAL_CONST_COND_POP_() + const To to = nullptr; + ::testing::internal::ImplicitCast_(to); + } + +#if GTEST_HAS_RTTI + // RTTI: debug mode only! + GTEST_CHECK_(f == nullptr || dynamic_cast(f) != nullptr); +#endif + return static_cast(f); +} + +// Downcasts the pointer of type Base to Derived. +// Derived must be a subclass of Base. The parameter MUST +// point to a class of type Derived, not any subclass of it. +// When RTTI is available, the function performs a runtime +// check to enforce this. +template +Derived* CheckedDowncastToActualType(Base* base) { +#if GTEST_HAS_RTTI + GTEST_CHECK_(typeid(*base) == typeid(Derived)); +#endif + +#if GTEST_HAS_DOWNCAST_ + return ::down_cast(base); +#elif GTEST_HAS_RTTI + return dynamic_cast(base); // NOLINT +#else + return static_cast(base); // Poor man's downcast. +#endif +} + +#if GTEST_HAS_STREAM_REDIRECTION + +// Defines the stderr capturer: +// CaptureStdout - starts capturing stdout. +// GetCapturedStdout - stops capturing stdout and returns the captured string. +// CaptureStderr - starts capturing stderr. +// GetCapturedStderr - stops capturing stderr and returns the captured string. +// +GTEST_API_ void CaptureStdout(); +GTEST_API_ std::string GetCapturedStdout(); +GTEST_API_ void CaptureStderr(); +GTEST_API_ std::string GetCapturedStderr(); + +#endif // GTEST_HAS_STREAM_REDIRECTION +// Returns the size (in bytes) of a file. +GTEST_API_ size_t GetFileSize(FILE* file); + +// Reads the entire content of a file as a string. +GTEST_API_ std::string ReadEntireFile(FILE* file); + +// All command line arguments. +GTEST_API_ std::vector GetArgvs(); + +#if GTEST_HAS_DEATH_TEST + +std::vector GetInjectableArgvs(); +// Deprecated: pass the args vector by value instead. +void SetInjectableArgvs(const std::vector* new_argvs); +void SetInjectableArgvs(const std::vector& new_argvs); +void ClearInjectableArgvs(); + +#endif // GTEST_HAS_DEATH_TEST + +// Defines synchronization primitives. +#if GTEST_IS_THREADSAFE +# if GTEST_HAS_PTHREAD +// Sleeps for (roughly) n milliseconds. This function is only for testing +// Google Test's own constructs. Don't use it in user tests, either +// directly or indirectly. +inline void SleepMilliseconds(int n) { + const timespec time = { + 0, // 0 seconds. + n * 1000L * 1000L, // And n ms. + }; + nanosleep(&time, nullptr); +} +# endif // GTEST_HAS_PTHREAD + +# if GTEST_HAS_NOTIFICATION_ +// Notification has already been imported into the namespace. +// Nothing to do here. + +# elif GTEST_HAS_PTHREAD +// Allows a controller thread to pause execution of newly created +// threads until notified. Instances of this class must be created +// and destroyed in the controller thread. +// +// This class is only for testing Google Test's own constructs. Do not +// use it in user tests, either directly or indirectly. +class Notification { + public: + Notification() : notified_(false) { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); + } + ~Notification() { + pthread_mutex_destroy(&mutex_); + } + + // Notifies all threads created with this notification to start. Must + // be called from the controller thread. + void Notify() { + pthread_mutex_lock(&mutex_); + notified_ = true; + pthread_mutex_unlock(&mutex_); + } + + // Blocks until the controller thread notifies. Must be called from a test + // thread. + void WaitForNotification() { + for (;;) { + pthread_mutex_lock(&mutex_); + const bool notified = notified_; + pthread_mutex_unlock(&mutex_); + if (notified) + break; + SleepMilliseconds(10); + } + } + + private: + pthread_mutex_t mutex_; + bool notified_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); +}; + +# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT + +GTEST_API_ void SleepMilliseconds(int n); + +// Provides leak-safe Windows kernel handle ownership. +// Used in death tests and in threading support. +class GTEST_API_ AutoHandle { + public: + // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to + // avoid including in this header file. Including is + // undesirable because it defines a lot of symbols and macros that tend to + // conflict with client code. This assumption is verified by + // WindowsTypesTest.HANDLEIsVoidStar. + typedef void* Handle; + AutoHandle(); + explicit AutoHandle(Handle handle); + + ~AutoHandle(); + + Handle Get() const; + void Reset(); + void Reset(Handle handle); + + private: + // Returns true if and only if the handle is a valid handle object that can be + // closed. + bool IsCloseable() const; + + Handle handle_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); +}; + +// Allows a controller thread to pause execution of newly created +// threads until notified. Instances of this class must be created +// and destroyed in the controller thread. +// +// This class is only for testing Google Test's own constructs. Do not +// use it in user tests, either directly or indirectly. +class GTEST_API_ Notification { + public: + Notification(); + void Notify(); + void WaitForNotification(); + + private: + AutoHandle event_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); +}; +# endif // GTEST_HAS_NOTIFICATION_ + +// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD +// defined, but we don't want to use MinGW's pthreads implementation, which +// has conformance problems with some versions of the POSIX standard. +# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW + +// As a C-function, ThreadFuncWithCLinkage cannot be templated itself. +// Consequently, it cannot select a correct instantiation of ThreadWithParam +// in order to call its Run(). Introducing ThreadWithParamBase as a +// non-templated base class for ThreadWithParam allows us to bypass this +// problem. +class ThreadWithParamBase { + public: + virtual ~ThreadWithParamBase() {} + virtual void Run() = 0; +}; + +// pthread_create() accepts a pointer to a function type with the C linkage. +// According to the Standard (7.5/1), function types with different linkages +// are different even if they are otherwise identical. Some compilers (for +// example, SunStudio) treat them as different types. Since class methods +// cannot be defined with C-linkage we need to define a free C-function to +// pass into pthread_create(). +extern "C" inline void* ThreadFuncWithCLinkage(void* thread) { + static_cast(thread)->Run(); + return nullptr; +} + +// Helper class for testing Google Test's multi-threading constructs. +// To use it, write: +// +// void ThreadFunc(int param) { /* Do things with param */ } +// Notification thread_can_start; +// ... +// // The thread_can_start parameter is optional; you can supply NULL. +// ThreadWithParam thread(&ThreadFunc, 5, &thread_can_start); +// thread_can_start.Notify(); +// +// These classes are only for testing Google Test's own constructs. Do +// not use them in user tests, either directly or indirectly. +template +class ThreadWithParam : public ThreadWithParamBase { + public: + typedef void UserThreadFunc(T); + + ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) + : func_(func), + param_(param), + thread_can_start_(thread_can_start), + finished_(false) { + ThreadWithParamBase* const base = this; + // The thread can be created only after all fields except thread_ + // have been initialized. + GTEST_CHECK_POSIX_SUCCESS_( + pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base)); + } + ~ThreadWithParam() override { Join(); } + + void Join() { + if (!finished_) { + GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr)); + finished_ = true; + } + } + + void Run() override { + if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification(); + func_(param_); + } + + private: + UserThreadFunc* const func_; // User-supplied thread function. + const T param_; // User-supplied parameter to the thread function. + // When non-NULL, used to block execution until the controller thread + // notifies. + Notification* const thread_can_start_; + bool finished_; // true if and only if we know that the thread function has + // finished. + pthread_t thread_; // The native thread object. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); +}; +# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || + // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ + +# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +// Mutex and ThreadLocal have already been imported into the namespace. +// Nothing to do here. + +# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT + +// Mutex implements mutex on Windows platforms. It is used in conjunction +// with class MutexLock: +// +// Mutex mutex; +// ... +// MutexLock lock(&mutex); // Acquires the mutex and releases it at the +// // end of the current scope. +// +// A static Mutex *must* be defined or declared using one of the following +// macros: +// GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex); +// GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); +// +// (A non-static Mutex is defined/declared in the usual way). +class GTEST_API_ Mutex { + public: + enum MutexType { kStatic = 0, kDynamic = 1 }; + // We rely on kStaticMutex being 0 as it is to what the linker initializes + // type_ in static mutexes. critical_section_ will be initialized lazily + // in ThreadSafeLazyInit(). + enum StaticConstructorSelector { kStaticMutex = 0 }; + + // This constructor intentionally does nothing. It relies on type_ being + // statically initialized to 0 (effectively setting it to kStatic) and on + // ThreadSafeLazyInit() to lazily initialize the rest of the members. + explicit Mutex(StaticConstructorSelector /*dummy*/) {} + + Mutex(); + ~Mutex(); + + void Lock(); + + void Unlock(); + + // Does nothing if the current thread holds the mutex. Otherwise, crashes + // with high probability. + void AssertHeld(); + + private: + // Initializes owner_thread_id_ and critical_section_ in static mutexes. + void ThreadSafeLazyInit(); + + // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503, + // we assume that 0 is an invalid value for thread IDs. + unsigned int owner_thread_id_; + + // For static mutexes, we rely on these members being initialized to zeros + // by the linker. + MutexType type_; + long critical_section_init_phase_; // NOLINT + GTEST_CRITICAL_SECTION* critical_section_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); +}; + +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::Mutex mutex + +# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex) + +// We cannot name this class MutexLock because the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. +class GTestMutexLock { + public: + explicit GTestMutexLock(Mutex* mutex) + : mutex_(mutex) { mutex_->Lock(); } + + ~GTestMutexLock() { mutex_->Unlock(); } + + private: + Mutex* const mutex_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); +}; + +typedef GTestMutexLock MutexLock; + +// Base class for ValueHolder. Allows a caller to hold and delete a value +// without knowing its type. +class ThreadLocalValueHolderBase { + public: + virtual ~ThreadLocalValueHolderBase() {} +}; + +// Provides a way for a thread to send notifications to a ThreadLocal +// regardless of its parameter type. +class ThreadLocalBase { + public: + // Creates a new ValueHolder object holding a default value passed to + // this ThreadLocal's constructor and returns it. It is the caller's + // responsibility not to call this when the ThreadLocal instance already + // has a value on the current thread. + virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0; + + protected: + ThreadLocalBase() {} + virtual ~ThreadLocalBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase); +}; + +// Maps a thread to a set of ThreadLocals that have values instantiated on that +// thread and notifies them when the thread exits. A ThreadLocal instance is +// expected to persist until all threads it has values on have terminated. +class GTEST_API_ ThreadLocalRegistry { + public: + // Registers thread_local_instance as having value on the current thread. + // Returns a value that can be used to identify the thread from other threads. + static ThreadLocalValueHolderBase* GetValueOnCurrentThread( + const ThreadLocalBase* thread_local_instance); + + // Invoked when a ThreadLocal instance is destroyed. + static void OnThreadLocalDestroyed( + const ThreadLocalBase* thread_local_instance); +}; + +class GTEST_API_ ThreadWithParamBase { + public: + void Join(); + + protected: + class Runnable { + public: + virtual ~Runnable() {} + virtual void Run() = 0; + }; + + ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start); + virtual ~ThreadWithParamBase(); + + private: + AutoHandle thread_; +}; + +// Helper class for testing Google Test's multi-threading constructs. +template +class ThreadWithParam : public ThreadWithParamBase { + public: + typedef void UserThreadFunc(T); + + ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) + : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) { + } + virtual ~ThreadWithParam() {} + + private: + class RunnableImpl : public Runnable { + public: + RunnableImpl(UserThreadFunc* func, T param) + : func_(func), + param_(param) { + } + virtual ~RunnableImpl() {} + virtual void Run() { + func_(param_); + } + + private: + UserThreadFunc* const func_; + const T param_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl); + }; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); +}; + +// Implements thread-local storage on Windows systems. +// +// // Thread 1 +// ThreadLocal tl(100); // 100 is the default value for each thread. +// +// // Thread 2 +// tl.set(150); // Changes the value for thread 2 only. +// EXPECT_EQ(150, tl.get()); +// +// // Thread 1 +// EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value. +// tl.set(200); +// EXPECT_EQ(200, tl.get()); +// +// The template type argument T must have a public copy constructor. +// In addition, the default ThreadLocal constructor requires T to have +// a public default constructor. +// +// The users of a TheadLocal instance have to make sure that all but one +// threads (including the main one) using that instance have exited before +// destroying it. Otherwise, the per-thread objects managed for them by the +// ThreadLocal instance are not guaranteed to be destroyed on all platforms. +// +// Google Test only uses global ThreadLocal objects. That means they +// will die after main() has returned. Therefore, no per-thread +// object managed by Google Test will be leaked as long as all threads +// using Google Test have exited when main() returns. +template +class ThreadLocal : public ThreadLocalBase { + public: + ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {} + explicit ThreadLocal(const T& value) + : default_factory_(new InstanceValueHolderFactory(value)) {} + + ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); } + + T* pointer() { return GetOrCreateValue(); } + const T* pointer() const { return GetOrCreateValue(); } + const T& get() const { return *pointer(); } + void set(const T& value) { *pointer() = value; } + + private: + // Holds a value of T. Can be deleted via its base class without the caller + // knowing the type of T. + class ValueHolder : public ThreadLocalValueHolderBase { + public: + ValueHolder() : value_() {} + explicit ValueHolder(const T& value) : value_(value) {} + + T* pointer() { return &value_; } + + private: + T value_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); + }; + + + T* GetOrCreateValue() const { + return static_cast( + ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer(); + } + + virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const { + return default_factory_->MakeNewHolder(); + } + + class ValueHolderFactory { + public: + ValueHolderFactory() {} + virtual ~ValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const = 0; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); + }; + + class DefaultValueHolderFactory : public ValueHolderFactory { + public: + DefaultValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); + }; + + class InstanceValueHolderFactory : public ValueHolderFactory { + public: + explicit InstanceValueHolderFactory(const T& value) : value_(value) {} + virtual ValueHolder* MakeNewHolder() const { + return new ValueHolder(value_); + } + + private: + const T value_; // The value for each thread. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); + }; + + std::unique_ptr default_factory_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); +}; + +# elif GTEST_HAS_PTHREAD + +// MutexBase and Mutex implement mutex on pthreads-based platforms. +class MutexBase { + public: + // Acquires this mutex. + void Lock() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_)); + owner_ = pthread_self(); + has_owner_ = true; + } + + // Releases this mutex. + void Unlock() { + // Since the lock is being released the owner_ field should no longer be + // considered valid. We don't protect writing to has_owner_ here, as it's + // the caller's responsibility to ensure that the current thread holds the + // mutex when this is called. + has_owner_ = false; + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_)); + } + + // Does nothing if the current thread holds the mutex. Otherwise, crashes + // with high probability. + void AssertHeld() const { + GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self())) + << "The current thread is not holding the mutex @" << this; + } + + // A static mutex may be used before main() is entered. It may even + // be used before the dynamic initialization stage. Therefore we + // must be able to initialize a static mutex object at link time. + // This means MutexBase has to be a POD and its member variables + // have to be public. + public: + pthread_mutex_t mutex_; // The underlying pthread mutex. + // has_owner_ indicates whether the owner_ field below contains a valid thread + // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All + // accesses to the owner_ field should be protected by a check of this field. + // An alternative might be to memset() owner_ to all zeros, but there's no + // guarantee that a zero'd pthread_t is necessarily invalid or even different + // from pthread_self(). + bool has_owner_; + pthread_t owner_; // The thread holding the mutex. +}; + +// Forward-declares a static mutex. +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::MutexBase mutex + +// Defines and statically (i.e. at link time) initializes a static mutex. +// The initialization list here does not explicitly initialize each field, +// instead relying on default initialization for the unspecified fields. In +// particular, the owner_ field (a pthread_t) is not explicitly initialized. +// This allows initialization to work whether pthread_t is a scalar or struct. +// The flag -Wmissing-field-initializers must not be specified for this to work. +#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0} + +// The Mutex class can only be used for mutexes created at runtime. It +// shares its API with MutexBase otherwise. +class Mutex : public MutexBase { + public: + Mutex() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); + has_owner_ = false; + } + ~Mutex() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); + } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); +}; + +// We cannot name this class MutexLock because the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. +class GTestMutexLock { + public: + explicit GTestMutexLock(MutexBase* mutex) + : mutex_(mutex) { mutex_->Lock(); } + + ~GTestMutexLock() { mutex_->Unlock(); } + + private: + MutexBase* const mutex_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); +}; + +typedef GTestMutexLock MutexLock; + +// Helpers for ThreadLocal. + +// pthread_key_create() requires DeleteThreadLocalValue() to have +// C-linkage. Therefore it cannot be templatized to access +// ThreadLocal. Hence the need for class +// ThreadLocalValueHolderBase. +class ThreadLocalValueHolderBase { + public: + virtual ~ThreadLocalValueHolderBase() {} +}; + +// Called by pthread to delete thread-local data stored by +// pthread_setspecific(). +extern "C" inline void DeleteThreadLocalValue(void* value_holder) { + delete static_cast(value_holder); +} + +// Implements thread-local storage on pthreads-based systems. +template +class GTEST_API_ ThreadLocal { + public: + ThreadLocal() + : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {} + explicit ThreadLocal(const T& value) + : key_(CreateKey()), + default_factory_(new InstanceValueHolderFactory(value)) {} + + ~ThreadLocal() { + // Destroys the managed object for the current thread, if any. + DeleteThreadLocalValue(pthread_getspecific(key_)); + + // Releases resources associated with the key. This will *not* + // delete managed objects for other threads. + GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_)); + } + + T* pointer() { return GetOrCreateValue(); } + const T* pointer() const { return GetOrCreateValue(); } + const T& get() const { return *pointer(); } + void set(const T& value) { *pointer() = value; } + + private: + // Holds a value of type T. + class ValueHolder : public ThreadLocalValueHolderBase { + public: + ValueHolder() : value_() {} + explicit ValueHolder(const T& value) : value_(value) {} + + T* pointer() { return &value_; } + + private: + T value_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); + }; + + static pthread_key_t CreateKey() { + pthread_key_t key; + // When a thread exits, DeleteThreadLocalValue() will be called on + // the object managed for that thread. + GTEST_CHECK_POSIX_SUCCESS_( + pthread_key_create(&key, &DeleteThreadLocalValue)); + return key; + } + + T* GetOrCreateValue() const { + ThreadLocalValueHolderBase* const holder = + static_cast(pthread_getspecific(key_)); + if (holder != nullptr) { + return CheckedDowncastToActualType(holder)->pointer(); + } + + ValueHolder* const new_holder = default_factory_->MakeNewHolder(); + ThreadLocalValueHolderBase* const holder_base = new_holder; + GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base)); + return new_holder->pointer(); + } + + class ValueHolderFactory { + public: + ValueHolderFactory() {} + virtual ~ValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const = 0; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); + }; + + class DefaultValueHolderFactory : public ValueHolderFactory { + public: + DefaultValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); + }; + + class InstanceValueHolderFactory : public ValueHolderFactory { + public: + explicit InstanceValueHolderFactory(const T& value) : value_(value) {} + virtual ValueHolder* MakeNewHolder() const { + return new ValueHolder(value_); + } + + private: + const T value_; // The value for each thread. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); + }; + + // A key pthreads uses for looking up per-thread values. + const pthread_key_t key_; + std::unique_ptr default_factory_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); +}; + +# endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ + +#else // GTEST_IS_THREADSAFE + +// A dummy implementation of synchronization primitives (mutex, lock, +// and thread-local variable). Necessary for compiling Google Test where +// mutex is not supported - using Google Test in multiple threads is not +// supported on such platforms. + +class Mutex { + public: + Mutex() {} + void Lock() {} + void Unlock() {} + void AssertHeld() const {} +}; + +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::Mutex mutex + +# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex + +// We cannot name this class MutexLock because the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. +class GTestMutexLock { + public: + explicit GTestMutexLock(Mutex*) {} // NOLINT +}; + +typedef GTestMutexLock MutexLock; + +template +class GTEST_API_ ThreadLocal { + public: + ThreadLocal() : value_() {} + explicit ThreadLocal(const T& value) : value_(value) {} + T* pointer() { return &value_; } + const T* pointer() const { return &value_; } + const T& get() const { return value_; } + void set(const T& value) { value_ = value; } + private: + T value_; +}; + +#endif // GTEST_IS_THREADSAFE + +// Returns the number of threads running in the process, or 0 to indicate that +// we cannot detect it. +GTEST_API_ size_t GetThreadCount(); + +template +using bool_constant = std::integral_constant; + +#if GTEST_OS_WINDOWS +# define GTEST_PATH_SEP_ "\\" +# define GTEST_HAS_ALT_PATH_SEP_ 1 +// The biggest signed integer type the compiler supports. +typedef __int64 BiggestInt; +#else +# define GTEST_PATH_SEP_ "/" +# define GTEST_HAS_ALT_PATH_SEP_ 0 +typedef long long BiggestInt; // NOLINT +#endif // GTEST_OS_WINDOWS + +// Utilities for char. + +// isspace(int ch) and friends accept an unsigned char or EOF. char +// may be signed, depending on the compiler (or compiler flags). +// Therefore we need to cast a char to unsigned char before calling +// isspace(), etc. + +inline bool IsAlpha(char ch) { + return isalpha(static_cast(ch)) != 0; +} +inline bool IsAlNum(char ch) { + return isalnum(static_cast(ch)) != 0; +} +inline bool IsDigit(char ch) { + return isdigit(static_cast(ch)) != 0; +} +inline bool IsLower(char ch) { + return islower(static_cast(ch)) != 0; +} +inline bool IsSpace(char ch) { + return isspace(static_cast(ch)) != 0; +} +inline bool IsUpper(char ch) { + return isupper(static_cast(ch)) != 0; +} +inline bool IsXDigit(char ch) { + return isxdigit(static_cast(ch)) != 0; +} +inline bool IsXDigit(wchar_t ch) { + const unsigned char low_byte = static_cast(ch); + return ch == low_byte && isxdigit(low_byte) != 0; +} + +inline char ToLower(char ch) { + return static_cast(tolower(static_cast(ch))); +} +inline char ToUpper(char ch) { + return static_cast(toupper(static_cast(ch))); +} + +inline std::string StripTrailingSpaces(std::string str) { + std::string::iterator it = str.end(); + while (it != str.begin() && IsSpace(*--it)) + it = str.erase(it); + return str; +} + +// The testing::internal::posix namespace holds wrappers for common +// POSIX functions. These wrappers hide the differences between +// Windows/MSVC and POSIX systems. Since some compilers define these +// standard functions as macros, the wrapper cannot have the same name +// as the wrapped function. + +namespace posix { + +// Functions with a different name on Windows. + +#if GTEST_OS_WINDOWS + +typedef struct _stat StatStruct; + +# ifdef __BORLANDC__ +inline int IsATTY(int fd) { return isatty(fd); } +inline int StrCaseCmp(const char* s1, const char* s2) { + return stricmp(s1, s2); +} +inline char* StrDup(const char* src) { return strdup(src); } +# else // !__BORLANDC__ +# if GTEST_OS_WINDOWS_MOBILE +inline int IsATTY(int /* fd */) { return 0; } +# else +inline int IsATTY(int fd) { return _isatty(fd); } +# endif // GTEST_OS_WINDOWS_MOBILE +inline int StrCaseCmp(const char* s1, const char* s2) { + return _stricmp(s1, s2); +} +inline char* StrDup(const char* src) { return _strdup(src); } +# endif // __BORLANDC__ + +# if GTEST_OS_WINDOWS_MOBILE +inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } +// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this +// time and thus not defined there. +# else +inline int FileNo(FILE* file) { return _fileno(file); } +inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); } +inline int RmDir(const char* dir) { return _rmdir(dir); } +inline bool IsDir(const StatStruct& st) { + return (_S_IFDIR & st.st_mode) != 0; +} +# endif // GTEST_OS_WINDOWS_MOBILE + +#else + +typedef struct stat StatStruct; + +inline int FileNo(FILE* file) { return fileno(file); } +inline int IsATTY(int fd) { return isatty(fd); } +inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } +inline int StrCaseCmp(const char* s1, const char* s2) { + return strcasecmp(s1, s2); +} +inline char* StrDup(const char* src) { return strdup(src); } +inline int RmDir(const char* dir) { return rmdir(dir); } +inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } + +#endif // GTEST_OS_WINDOWS + +// Functions deprecated by MSVC 8.0. + +GTEST_DISABLE_MSC_DEPRECATED_PUSH_() + +inline const char* StrNCpy(char* dest, const char* src, size_t n) { + return strncpy(dest, src, n); +} + +// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and +// StrError() aren't needed on Windows CE at this time and thus not +// defined there. + +#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +inline int ChDir(const char* dir) { return chdir(dir); } +#endif +inline FILE* FOpen(const char* path, const char* mode) { + return fopen(path, mode); +} +#if !GTEST_OS_WINDOWS_MOBILE +inline FILE *FReopen(const char* path, const char* mode, FILE* stream) { + return freopen(path, mode, stream); +} +inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } +#endif +inline int FClose(FILE* fp) { return fclose(fp); } +#if !GTEST_OS_WINDOWS_MOBILE +inline int Read(int fd, void* buf, unsigned int count) { + return static_cast(read(fd, buf, count)); +} +inline int Write(int fd, const void* buf, unsigned int count) { + return static_cast(write(fd, buf, count)); +} +inline int Close(int fd) { return close(fd); } +inline const char* StrError(int errnum) { return strerror(errnum); } +#endif +inline const char* GetEnv(const char* name) { +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT + // We are on Windows CE, which has no environment variables. + static_cast(name); // To prevent 'unused argument' warning. + return nullptr; +#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) + // Environment variables which we programmatically clear will be set to the + // empty string rather than unset (NULL). Handle that case. + const char* const env = getenv(name); + return (env != nullptr && env[0] != '\0') ? env : nullptr; +#else + return getenv(name); +#endif +} + +GTEST_DISABLE_MSC_DEPRECATED_POP_() + +#if GTEST_OS_WINDOWS_MOBILE +// Windows CE has no C library. The abort() function is used in +// several places in Google Test. This implementation provides a reasonable +// imitation of standard behaviour. +[[noreturn]] void Abort(); +#else +[[noreturn]] inline void Abort() { abort(); } +#endif // GTEST_OS_WINDOWS_MOBILE + +} // namespace posix + +// MSVC "deprecates" snprintf and issues warnings wherever it is used. In +// order to avoid these warnings, we need to use _snprintf or _snprintf_s on +// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate +// function in order to achieve that. We use macro definition here because +// snprintf is a variadic function. +#if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE +// MSVC 2005 and above support variadic macros. +# define GTEST_SNPRINTF_(buffer, size, format, ...) \ + _snprintf_s(buffer, size, size, format, __VA_ARGS__) +#elif defined(_MSC_VER) +// Windows CE does not define _snprintf_s +# define GTEST_SNPRINTF_ _snprintf +#else +# define GTEST_SNPRINTF_ snprintf +#endif + +// The maximum number a BiggestInt can represent. This definition +// works no matter BiggestInt is represented in one's complement or +// two's complement. +// +// We cannot rely on numeric_limits in STL, as __int64 and long long +// are not part of standard C++ and numeric_limits doesn't need to be +// defined for them. +const BiggestInt kMaxBiggestInt = + ~(static_cast(1) << (8*sizeof(BiggestInt) - 1)); + +// This template class serves as a compile-time function from size to +// type. It maps a size in bytes to a primitive type with that +// size. e.g. +// +// TypeWithSize<4>::UInt +// +// is typedef-ed to be unsigned int (unsigned integer made up of 4 +// bytes). +// +// Such functionality should belong to STL, but I cannot find it +// there. +// +// Google Test uses this class in the implementation of floating-point +// comparison. +// +// For now it only handles UInt (unsigned int) as that's all Google Test +// needs. Other types can be easily added in the future if need +// arises. +template +class TypeWithSize { + public: + // This prevents the user from using TypeWithSize with incorrect + // values of N. + typedef void UInt; +}; + +// The specialization for size 4. +template <> +class TypeWithSize<4> { + public: + // unsigned int has size 4 in both gcc and MSVC. + // + // As base/basictypes.h doesn't compile on Windows, we cannot use + // uint32, uint64, and etc here. + typedef int Int; + typedef unsigned int UInt; +}; + +// The specialization for size 8. +template <> +class TypeWithSize<8> { + public: +#if GTEST_OS_WINDOWS + typedef __int64 Int; + typedef unsigned __int64 UInt; +#else + typedef long long Int; // NOLINT + typedef unsigned long long UInt; // NOLINT +#endif // GTEST_OS_WINDOWS +}; + +// Integer types of known sizes. +typedef TypeWithSize<4>::Int Int32; +typedef TypeWithSize<4>::UInt UInt32; +typedef TypeWithSize<8>::Int Int64; +typedef TypeWithSize<8>::UInt UInt64; +typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds. + +// Utilities for command line flags and environment variables. + +// Macro for referencing flags. +#if !defined(GTEST_FLAG) +# define GTEST_FLAG(name) FLAGS_gtest_##name +#endif // !defined(GTEST_FLAG) + +#if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) +# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1 +#endif // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) + +#if !defined(GTEST_DECLARE_bool_) +# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver + +// Macros for declaring flags. +# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) +# define GTEST_DECLARE_int32_(name) \ + GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name) +# define GTEST_DECLARE_string_(name) \ + GTEST_API_ extern ::std::string GTEST_FLAG(name) + +// Macros for defining flags. +# define GTEST_DEFINE_bool_(name, default_val, doc) \ + GTEST_API_ bool GTEST_FLAG(name) = (default_val) +# define GTEST_DEFINE_int32_(name, default_val, doc) \ + GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val) +# define GTEST_DEFINE_string_(name, default_val, doc) \ + GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) + +#endif // !defined(GTEST_DECLARE_bool_) + +// Thread annotations +#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) +# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) +# define GTEST_LOCK_EXCLUDED_(locks) +#endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) + +// Parses 'str' for a 32-bit signed integer. If successful, writes the result +// to *value and returns true; otherwise leaves *value unchanged and returns +// false. +bool ParseInt32(const Message& src_text, const char* str, Int32* value); + +// Parses a bool/Int32/string from the environment variable +// corresponding to the given Google Test flag. +bool BoolFromGTestEnv(const char* flag, bool default_val); +GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val); +std::string OutputFlagAlsoCheckEnvVar(); +const char* StringFromGTestEnv(const char* flag, const char* default_val); + +} // namespace internal +} // namespace testing + +#if !defined(GTEST_INTERNAL_DEPRECATED) + +// Internal Macro to mark an API deprecated, for googletest usage only +// Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or +// GTEST_INTERNAL_DEPRECATED(message) myFunction(); Every usage of +// a deprecated entity will trigger a warning when compiled with +// `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler). +// For msvc /W3 option will need to be used +// Note that for 'other' compilers this macro evaluates to nothing to prevent +// compilations errors. +#if defined(_MSC_VER) +#define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message)) +#elif defined(__GNUC__) +#define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message))) +#else +#define GTEST_INTERNAL_DEPRECATED(message) +#endif + +#endif // !defined(GTEST_INTERNAL_DEPRECATED) + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ diff --git a/include/gtest/internal/gtest-string.h b/include/gtest/internal/gtest-string.h new file mode 100644 index 0000000..82aaa63 --- /dev/null +++ b/include/gtest/internal/gtest-string.h @@ -0,0 +1,171 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file declares the String class and functions used internally by +// Google Test. They are subject to change without notice. They should not used +// by code external to Google Test. +// +// This header file is #included by gtest-internal.h. +// It should not be #included by other files. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ + +#ifdef __BORLANDC__ +// string.h is not guaranteed to provide strcpy on C++ Builder. +# include +#endif + +#include +#include + +#include "gtest/internal/gtest-port.h" + +namespace testing { +namespace internal { + +// String - an abstract class holding static string utilities. +class GTEST_API_ String { + public: + // Static utility methods + + // Clones a 0-terminated C string, allocating memory using new. The + // caller is responsible for deleting the return value using + // delete[]. Returns the cloned string, or NULL if the input is + // NULL. + // + // This is different from strdup() in string.h, which allocates + // memory using malloc(). + static const char* CloneCString(const char* c_str); + +#if GTEST_OS_WINDOWS_MOBILE + // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be + // able to pass strings to Win32 APIs on CE we need to convert them + // to 'Unicode', UTF-16. + + // Creates a UTF-16 wide string from the given ANSI string, allocating + // memory using new. The caller is responsible for deleting the return + // value using delete[]. Returns the wide string, or NULL if the + // input is NULL. + // + // The wide string is created using the ANSI codepage (CP_ACP) to + // match the behaviour of the ANSI versions of Win32 calls and the + // C runtime. + static LPCWSTR AnsiToUtf16(const char* c_str); + + // Creates an ANSI string from the given wide string, allocating + // memory using new. The caller is responsible for deleting the return + // value using delete[]. Returns the ANSI string, or NULL if the + // input is NULL. + // + // The returned string is created using the ANSI codepage (CP_ACP) to + // match the behaviour of the ANSI versions of Win32 calls and the + // C runtime. + static const char* Utf16ToAnsi(LPCWSTR utf16_str); +#endif + + // Compares two C strings. Returns true if and only if they have the same + // content. + // + // Unlike strcmp(), this function can handle NULL argument(s). A + // NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool CStringEquals(const char* lhs, const char* rhs); + + // Converts a wide C string to a String using the UTF-8 encoding. + // NULL will be converted to "(null)". If an error occurred during + // the conversion, "(failed to convert from wide string)" is + // returned. + static std::string ShowWideCString(const wchar_t* wide_c_str); + + // Compares two wide C strings. Returns true if and only if they have the + // same content. + // + // Unlike wcscmp(), this function can handle NULL argument(s). A + // NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs); + + // Compares two C strings, ignoring case. Returns true if and only if + // they have the same content. + // + // Unlike strcasecmp(), this function can handle NULL argument(s). + // A NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool CaseInsensitiveCStringEquals(const char* lhs, + const char* rhs); + + // Compares two wide C strings, ignoring case. Returns true if and only if + // they have the same content. + // + // Unlike wcscasecmp(), this function can handle NULL argument(s). + // A NULL C string is considered different to any non-NULL wide C string, + // including the empty string. + // NB: The implementations on different platforms slightly differ. + // On windows, this method uses _wcsicmp which compares according to LC_CTYPE + // environment variable. On GNU platform this method uses wcscasecmp + // which compares according to LC_CTYPE category of the current locale. + // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the + // current locale. + static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs, + const wchar_t* rhs); + + // Returns true if and only if the given string ends with the given suffix, + // ignoring case. Any string is considered to end with an empty suffix. + static bool EndsWithCaseInsensitive( + const std::string& str, const std::string& suffix); + + // Formats an int value as "%02d". + static std::string FormatIntWidth2(int value); // "%02d" for width == 2 + + // Formats an int value as "%X". + static std::string FormatHexInt(int value); + + // Formats an int value as "%X". + static std::string FormatHexUInt32(UInt32 value); + + // Formats a byte as "%02X". + static std::string FormatByte(unsigned char value); + + private: + String(); // Not meant to be instantiated. +}; // class String + +// Gets the content of the stringstream's buffer as an std::string. Each '\0' +// character in the buffer is replaced with "\\0". +GTEST_API_ std::string StringStreamToString(::std::stringstream* stream); + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ diff --git a/include/gtest/internal/gtest-type-util.h b/include/gtest/internal/gtest-type-util.h new file mode 100644 index 0000000..3d7542d --- /dev/null +++ b/include/gtest/internal/gtest-type-util.h @@ -0,0 +1,3335 @@ +// This file was GENERATED by command: +// pump.py gtest-type-util.h.pump +// DO NOT EDIT BY HAND!!! + +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Type utilities needed for implementing typed and type-parameterized +// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently we support at most 50 types in a list, and at most 50 +// type-parameterized tests in one type-parameterized test suite. +// Please contact googletestframework@googlegroups.com if you need +// more. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ + +#include "gtest/internal/gtest-port.h" + +// #ifdef __GNUC__ is too general here. It is possible to use gcc without using +// libstdc++ (which is where cxxabi.h comes from). +# if GTEST_HAS_CXXABI_H_ +# include +# elif defined(__HP_aCC) +# include +# endif // GTEST_HASH_CXXABI_H_ + +namespace testing { +namespace internal { + +// Canonicalizes a given name with respect to the Standard C++ Library. +// This handles removing the inline namespace within `std` that is +// used by various standard libraries (e.g., `std::__1`). Names outside +// of namespace std are returned unmodified. +inline std::string CanonicalizeForStdLibVersioning(std::string s) { + static const char prefix[] = "std::__"; + if (s.compare(0, strlen(prefix), prefix) == 0) { + std::string::size_type end = s.find("::", strlen(prefix)); + if (end != s.npos) { + // Erase everything between the initial `std` and the second `::`. + s.erase(strlen("std"), end - strlen("std")); + } + } + return s; +} + +// GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. +template +std::string GetTypeName() { +# if GTEST_HAS_RTTI + + const char* const name = typeid(T).name(); +# if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC) + int status = 0; + // gcc's implementation of typeid(T).name() mangles the type name, + // so we have to demangle it. +# if GTEST_HAS_CXXABI_H_ + using abi::__cxa_demangle; +# endif // GTEST_HAS_CXXABI_H_ + char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status); + const std::string name_str(status == 0 ? readable_name : name); + free(readable_name); + return CanonicalizeForStdLibVersioning(name_str); +# else + return name; +# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC + +# else + + return ""; + +# endif // GTEST_HAS_RTTI +} + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// A unique type used as the default value for the arguments of class +// template Types. This allows us to simulate variadic templates +// (e.g. Types, Type, and etc), which C++ doesn't +// support directly. +struct None {}; + +// The following family of struct and struct templates are used to +// represent type lists. In particular, TypesN +// represents a type list with N types (T1, T2, ..., and TN) in it. +// Except for Types0, every struct in the family has two member types: +// Head for the first type in the list, and Tail for the rest of the +// list. + +// The empty type list. +struct Types0 {}; + +// Type lists of length 1, 2, 3, and so on. + +template +struct Types1 { + typedef T1 Head; + typedef Types0 Tail; +}; +template +struct Types2 { + typedef T1 Head; + typedef Types1 Tail; +}; + +template +struct Types3 { + typedef T1 Head; + typedef Types2 Tail; +}; + +template +struct Types4 { + typedef T1 Head; + typedef Types3 Tail; +}; + +template +struct Types5 { + typedef T1 Head; + typedef Types4 Tail; +}; + +template +struct Types6 { + typedef T1 Head; + typedef Types5 Tail; +}; + +template +struct Types7 { + typedef T1 Head; + typedef Types6 Tail; +}; + +template +struct Types8 { + typedef T1 Head; + typedef Types7 Tail; +}; + +template +struct Types9 { + typedef T1 Head; + typedef Types8 Tail; +}; + +template +struct Types10 { + typedef T1 Head; + typedef Types9 Tail; +}; + +template +struct Types11 { + typedef T1 Head; + typedef Types10 Tail; +}; + +template +struct Types12 { + typedef T1 Head; + typedef Types11 Tail; +}; + +template +struct Types13 { + typedef T1 Head; + typedef Types12 Tail; +}; + +template +struct Types14 { + typedef T1 Head; + typedef Types13 Tail; +}; + +template +struct Types15 { + typedef T1 Head; + typedef Types14 Tail; +}; + +template +struct Types16 { + typedef T1 Head; + typedef Types15 Tail; +}; + +template +struct Types17 { + typedef T1 Head; + typedef Types16 Tail; +}; + +template +struct Types18 { + typedef T1 Head; + typedef Types17 Tail; +}; + +template +struct Types19 { + typedef T1 Head; + typedef Types18 Tail; +}; + +template +struct Types20 { + typedef T1 Head; + typedef Types19 Tail; +}; + +template +struct Types21 { + typedef T1 Head; + typedef Types20 Tail; +}; + +template +struct Types22 { + typedef T1 Head; + typedef Types21 Tail; +}; + +template +struct Types23 { + typedef T1 Head; + typedef Types22 Tail; +}; + +template +struct Types24 { + typedef T1 Head; + typedef Types23 Tail; +}; + +template +struct Types25 { + typedef T1 Head; + typedef Types24 Tail; +}; + +template +struct Types26 { + typedef T1 Head; + typedef Types25 Tail; +}; + +template +struct Types27 { + typedef T1 Head; + typedef Types26 Tail; +}; + +template +struct Types28 { + typedef T1 Head; + typedef Types27 Tail; +}; + +template +struct Types29 { + typedef T1 Head; + typedef Types28 Tail; +}; + +template +struct Types30 { + typedef T1 Head; + typedef Types29 Tail; +}; + +template +struct Types31 { + typedef T1 Head; + typedef Types30 Tail; +}; + +template +struct Types32 { + typedef T1 Head; + typedef Types31 Tail; +}; + +template +struct Types33 { + typedef T1 Head; + typedef Types32 Tail; +}; + +template +struct Types34 { + typedef T1 Head; + typedef Types33 Tail; +}; + +template +struct Types35 { + typedef T1 Head; + typedef Types34 Tail; +}; + +template +struct Types36 { + typedef T1 Head; + typedef Types35 Tail; +}; + +template +struct Types37 { + typedef T1 Head; + typedef Types36 Tail; +}; + +template +struct Types38 { + typedef T1 Head; + typedef Types37 Tail; +}; + +template +struct Types39 { + typedef T1 Head; + typedef Types38 Tail; +}; + +template +struct Types40 { + typedef T1 Head; + typedef Types39 Tail; +}; + +template +struct Types41 { + typedef T1 Head; + typedef Types40 Tail; +}; + +template +struct Types42 { + typedef T1 Head; + typedef Types41 Tail; +}; + +template +struct Types43 { + typedef T1 Head; + typedef Types42 Tail; +}; + +template +struct Types44 { + typedef T1 Head; + typedef Types43 Tail; +}; + +template +struct Types45 { + typedef T1 Head; + typedef Types44 Tail; +}; + +template +struct Types46 { + typedef T1 Head; + typedef Types45 Tail; +}; + +template +struct Types47 { + typedef T1 Head; + typedef Types46 Tail; +}; + +template +struct Types48 { + typedef T1 Head; + typedef Types47 Tail; +}; + +template +struct Types49 { + typedef T1 Head; + typedef Types48 Tail; +}; + +template +struct Types50 { + typedef T1 Head; + typedef Types49 Tail; +}; + + +} // namespace internal + +// We don't want to require the users to write TypesN<...> directly, +// as that would require them to count the length. Types<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Types +// will appear as Types in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Types, and Google Test will translate +// that to TypesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Types template. +template +struct Types { + typedef internal::Types50 type; +}; + +template <> +struct Types { + typedef internal::Types0 type; +}; +template +struct Types { + typedef internal::Types1 type; +}; +template +struct Types { + typedef internal::Types2 type; +}; +template +struct Types { + typedef internal::Types3 type; +}; +template +struct Types { + typedef internal::Types4 type; +}; +template +struct Types { + typedef internal::Types5 type; +}; +template +struct Types { + typedef internal::Types6 type; +}; +template +struct Types { + typedef internal::Types7 type; +}; +template +struct Types { + typedef internal::Types8 type; +}; +template +struct Types { + typedef internal::Types9 type; +}; +template +struct Types { + typedef internal::Types10 type; +}; +template +struct Types { + typedef internal::Types11 type; +}; +template +struct Types { + typedef internal::Types12 type; +}; +template +struct Types { + typedef internal::Types13 type; +}; +template +struct Types { + typedef internal::Types14 type; +}; +template +struct Types { + typedef internal::Types15 type; +}; +template +struct Types { + typedef internal::Types16 type; +}; +template +struct Types { + typedef internal::Types17 type; +}; +template +struct Types { + typedef internal::Types18 type; +}; +template +struct Types { + typedef internal::Types19 type; +}; +template +struct Types { + typedef internal::Types20 type; +}; +template +struct Types { + typedef internal::Types21 type; +}; +template +struct Types { + typedef internal::Types22 type; +}; +template +struct Types { + typedef internal::Types23 type; +}; +template +struct Types { + typedef internal::Types24 type; +}; +template +struct Types { + typedef internal::Types25 type; +}; +template +struct Types { + typedef internal::Types26 type; +}; +template +struct Types { + typedef internal::Types27 type; +}; +template +struct Types { + typedef internal::Types28 type; +}; +template +struct Types { + typedef internal::Types29 type; +}; +template +struct Types { + typedef internal::Types30 type; +}; +template +struct Types { + typedef internal::Types31 type; +}; +template +struct Types { + typedef internal::Types32 type; +}; +template +struct Types { + typedef internal::Types33 type; +}; +template +struct Types { + typedef internal::Types34 type; +}; +template +struct Types { + typedef internal::Types35 type; +}; +template +struct Types { + typedef internal::Types36 type; +}; +template +struct Types { + typedef internal::Types37 type; +}; +template +struct Types { + typedef internal::Types38 type; +}; +template +struct Types { + typedef internal::Types39 type; +}; +template +struct Types { + typedef internal::Types40 type; +}; +template +struct Types { + typedef internal::Types41 type; +}; +template +struct Types { + typedef internal::Types42 type; +}; +template +struct Types { + typedef internal::Types43 type; +}; +template +struct Types { + typedef internal::Types44 type; +}; +template +struct Types { + typedef internal::Types45 type; +}; +template +struct Types { + typedef internal::Types46 type; +}; +template +struct Types { + typedef internal::Types47 type; +}; +template +struct Types { + typedef internal::Types48 type; +}; +template +struct Types { + typedef internal::Types49 type; +}; + +namespace internal { + +# define GTEST_TEMPLATE_ template class + +// The template "selector" struct TemplateSel is used to +// represent Tmpl, which must be a class template with one type +// parameter, as a type. TemplateSel::Bind::type is defined +// as the type Tmpl. This allows us to actually instantiate the +// template "selected" by TemplateSel. +// +// This trick is necessary for simulating typedef for class templates, +// which C++ doesn't support directly. +template +struct TemplateSel { + template + struct Bind { + typedef Tmpl type; + }; +}; + +# define GTEST_BIND_(TmplSel, T) \ + TmplSel::template Bind::type + +// A unique struct template used as the default value for the +// arguments of class template Templates. This allows us to simulate +// variadic templates (e.g. Templates, Templates, +// and etc), which C++ doesn't support directly. +template +struct NoneT {}; + +// The following family of struct and struct templates are used to +// represent template lists. In particular, TemplatesN represents a list of N templates (T1, T2, ..., and TN). Except +// for Templates0, every struct in the family has two member types: +// Head for the selector of the first template in the list, and Tail +// for the rest of the list. + +// The empty template list. +struct Templates0 {}; + +// Template lists of length 1, 2, 3, and so on. + +template +struct Templates1 { + typedef TemplateSel Head; + typedef Templates0 Tail; +}; +template +struct Templates2 { + typedef TemplateSel Head; + typedef Templates1 Tail; +}; + +template +struct Templates3 { + typedef TemplateSel Head; + typedef Templates2 Tail; +}; + +template +struct Templates4 { + typedef TemplateSel Head; + typedef Templates3 Tail; +}; + +template +struct Templates5 { + typedef TemplateSel Head; + typedef Templates4 Tail; +}; + +template +struct Templates6 { + typedef TemplateSel Head; + typedef Templates5 Tail; +}; + +template +struct Templates7 { + typedef TemplateSel Head; + typedef Templates6 Tail; +}; + +template +struct Templates8 { + typedef TemplateSel Head; + typedef Templates7 Tail; +}; + +template +struct Templates9 { + typedef TemplateSel Head; + typedef Templates8 Tail; +}; + +template +struct Templates10 { + typedef TemplateSel Head; + typedef Templates9 Tail; +}; + +template +struct Templates11 { + typedef TemplateSel Head; + typedef Templates10 Tail; +}; + +template +struct Templates12 { + typedef TemplateSel Head; + typedef Templates11 Tail; +}; + +template +struct Templates13 { + typedef TemplateSel Head; + typedef Templates12 Tail; +}; + +template +struct Templates14 { + typedef TemplateSel Head; + typedef Templates13 Tail; +}; + +template +struct Templates15 { + typedef TemplateSel Head; + typedef Templates14 Tail; +}; + +template +struct Templates16 { + typedef TemplateSel Head; + typedef Templates15 Tail; +}; + +template +struct Templates17 { + typedef TemplateSel Head; + typedef Templates16 Tail; +}; + +template +struct Templates18 { + typedef TemplateSel Head; + typedef Templates17 Tail; +}; + +template +struct Templates19 { + typedef TemplateSel Head; + typedef Templates18 Tail; +}; + +template +struct Templates20 { + typedef TemplateSel Head; + typedef Templates19 Tail; +}; + +template +struct Templates21 { + typedef TemplateSel Head; + typedef Templates20 Tail; +}; + +template +struct Templates22 { + typedef TemplateSel Head; + typedef Templates21 Tail; +}; + +template +struct Templates23 { + typedef TemplateSel Head; + typedef Templates22 Tail; +}; + +template +struct Templates24 { + typedef TemplateSel Head; + typedef Templates23 Tail; +}; + +template +struct Templates25 { + typedef TemplateSel Head; + typedef Templates24 Tail; +}; + +template +struct Templates26 { + typedef TemplateSel Head; + typedef Templates25 Tail; +}; + +template +struct Templates27 { + typedef TemplateSel Head; + typedef Templates26 Tail; +}; + +template +struct Templates28 { + typedef TemplateSel Head; + typedef Templates27 Tail; +}; + +template +struct Templates29 { + typedef TemplateSel Head; + typedef Templates28 Tail; +}; + +template +struct Templates30 { + typedef TemplateSel Head; + typedef Templates29 Tail; +}; + +template +struct Templates31 { + typedef TemplateSel Head; + typedef Templates30 Tail; +}; + +template +struct Templates32 { + typedef TemplateSel Head; + typedef Templates31 Tail; +}; + +template +struct Templates33 { + typedef TemplateSel Head; + typedef Templates32 Tail; +}; + +template +struct Templates34 { + typedef TemplateSel Head; + typedef Templates33 Tail; +}; + +template +struct Templates35 { + typedef TemplateSel Head; + typedef Templates34 Tail; +}; + +template +struct Templates36 { + typedef TemplateSel Head; + typedef Templates35 Tail; +}; + +template +struct Templates37 { + typedef TemplateSel Head; + typedef Templates36 Tail; +}; + +template +struct Templates38 { + typedef TemplateSel Head; + typedef Templates37 Tail; +}; + +template +struct Templates39 { + typedef TemplateSel Head; + typedef Templates38 Tail; +}; + +template +struct Templates40 { + typedef TemplateSel Head; + typedef Templates39 Tail; +}; + +template +struct Templates41 { + typedef TemplateSel Head; + typedef Templates40 Tail; +}; + +template +struct Templates42 { + typedef TemplateSel Head; + typedef Templates41 Tail; +}; + +template +struct Templates43 { + typedef TemplateSel Head; + typedef Templates42 Tail; +}; + +template +struct Templates44 { + typedef TemplateSel Head; + typedef Templates43 Tail; +}; + +template +struct Templates45 { + typedef TemplateSel Head; + typedef Templates44 Tail; +}; + +template +struct Templates46 { + typedef TemplateSel Head; + typedef Templates45 Tail; +}; + +template +struct Templates47 { + typedef TemplateSel Head; + typedef Templates46 Tail; +}; + +template +struct Templates48 { + typedef TemplateSel Head; + typedef Templates47 Tail; +}; + +template +struct Templates49 { + typedef TemplateSel Head; + typedef Templates48 Tail; +}; + +template +struct Templates50 { + typedef TemplateSel Head; + typedef Templates49 Tail; +}; + + +// We don't want to require the users to write TemplatesN<...> directly, +// as that would require them to count the length. Templates<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Templates +// will appear as Templates in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Templates, and Google Test will translate +// that to TemplatesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Templates template. +template +struct Templates { + typedef Templates50 type; +}; + +template <> +struct Templates { + typedef Templates0 type; +}; +template +struct Templates { + typedef Templates1 type; +}; +template +struct Templates { + typedef Templates2 type; +}; +template +struct Templates { + typedef Templates3 type; +}; +template +struct Templates { + typedef Templates4 type; +}; +template +struct Templates { + typedef Templates5 type; +}; +template +struct Templates { + typedef Templates6 type; +}; +template +struct Templates { + typedef Templates7 type; +}; +template +struct Templates { + typedef Templates8 type; +}; +template +struct Templates { + typedef Templates9 type; +}; +template +struct Templates { + typedef Templates10 type; +}; +template +struct Templates { + typedef Templates11 type; +}; +template +struct Templates { + typedef Templates12 type; +}; +template +struct Templates { + typedef Templates13 type; +}; +template +struct Templates { + typedef Templates14 type; +}; +template +struct Templates { + typedef Templates15 type; +}; +template +struct Templates { + typedef Templates16 type; +}; +template +struct Templates { + typedef Templates17 type; +}; +template +struct Templates { + typedef Templates18 type; +}; +template +struct Templates { + typedef Templates19 type; +}; +template +struct Templates { + typedef Templates20 type; +}; +template +struct Templates { + typedef Templates21 type; +}; +template +struct Templates { + typedef Templates22 type; +}; +template +struct Templates { + typedef Templates23 type; +}; +template +struct Templates { + typedef Templates24 type; +}; +template +struct Templates { + typedef Templates25 type; +}; +template +struct Templates { + typedef Templates26 type; +}; +template +struct Templates { + typedef Templates27 type; +}; +template +struct Templates { + typedef Templates28 type; +}; +template +struct Templates { + typedef Templates29 type; +}; +template +struct Templates { + typedef Templates30 type; +}; +template +struct Templates { + typedef Templates31 type; +}; +template +struct Templates { + typedef Templates32 type; +}; +template +struct Templates { + typedef Templates33 type; +}; +template +struct Templates { + typedef Templates34 type; +}; +template +struct Templates { + typedef Templates35 type; +}; +template +struct Templates { + typedef Templates36 type; +}; +template +struct Templates { + typedef Templates37 type; +}; +template +struct Templates { + typedef Templates38 type; +}; +template +struct Templates { + typedef Templates39 type; +}; +template +struct Templates { + typedef Templates40 type; +}; +template +struct Templates { + typedef Templates41 type; +}; +template +struct Templates { + typedef Templates42 type; +}; +template +struct Templates { + typedef Templates43 type; +}; +template +struct Templates { + typedef Templates44 type; +}; +template +struct Templates { + typedef Templates45 type; +}; +template +struct Templates { + typedef Templates46 type; +}; +template +struct Templates { + typedef Templates47 type; +}; +template +struct Templates { + typedef Templates48 type; +}; +template +struct Templates { + typedef Templates49 type; +}; + +// The TypeList template makes it possible to use either a single type +// or a Types<...> list in TYPED_TEST_SUITE() and +// INSTANTIATE_TYPED_TEST_SUITE_P(). + +template +struct TypeList { + typedef Types1 type; +}; + +template +struct TypeList > { + typedef typename Types::type type; +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ diff --git a/include/gtest/internal/gtest-type-util.h.pump b/include/gtest/internal/gtest-type-util.h.pump new file mode 100644 index 0000000..5e31b7b --- /dev/null +++ b/include/gtest/internal/gtest-type-util.h.pump @@ -0,0 +1,302 @@ +$$ -*- mode: c++; -*- +$var n = 50 $$ Maximum length of type lists we want to support. +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// Type utilities needed for implementing typed and type-parameterized +// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently we support at most $n types in a list, and at most $n +// type-parameterized tests in one type-parameterized test suite. +// Please contact googletestframework@googlegroups.com if you need +// more. + +// GOOGLETEST_CM0001 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ + +#include "gtest/internal/gtest-port.h" + +// #ifdef __GNUC__ is too general here. It is possible to use gcc without using +// libstdc++ (which is where cxxabi.h comes from). +# if GTEST_HAS_CXXABI_H_ +# include +# elif defined(__HP_aCC) +# include +# endif // GTEST_HASH_CXXABI_H_ + +namespace testing { +namespace internal { + +// Canonicalizes a given name with respect to the Standard C++ Library. +// This handles removing the inline namespace within `std` that is +// used by various standard libraries (e.g., `std::__1`). Names outside +// of namespace std are returned unmodified. +inline std::string CanonicalizeForStdLibVersioning(std::string s) { + static const char prefix[] = "std::__"; + if (s.compare(0, strlen(prefix), prefix) == 0) { + std::string::size_type end = s.find("::", strlen(prefix)); + if (end != s.npos) { + // Erase everything between the initial `std` and the second `::`. + s.erase(strlen("std"), end - strlen("std")); + } + } + return s; +} + +// GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. +template +std::string GetTypeName() { +# if GTEST_HAS_RTTI + + const char* const name = typeid(T).name(); +# if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC) + int status = 0; + // gcc's implementation of typeid(T).name() mangles the type name, + // so we have to demangle it. +# if GTEST_HAS_CXXABI_H_ + using abi::__cxa_demangle; +# endif // GTEST_HAS_CXXABI_H_ + char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status); + const std::string name_str(status == 0 ? readable_name : name); + free(readable_name); + return CanonicalizeForStdLibVersioning(name_str); +# else + return name; +# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC + +# else + + return ""; + +# endif // GTEST_HAS_RTTI +} + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// A unique type used as the default value for the arguments of class +// template Types. This allows us to simulate variadic templates +// (e.g. Types, Type, and etc), which C++ doesn't +// support directly. +struct None {}; + +// The following family of struct and struct templates are used to +// represent type lists. In particular, TypesN +// represents a type list with N types (T1, T2, ..., and TN) in it. +// Except for Types0, every struct in the family has two member types: +// Head for the first type in the list, and Tail for the rest of the +// list. + +// The empty type list. +struct Types0 {}; + +// Type lists of length 1, 2, 3, and so on. + +template +struct Types1 { + typedef T1 Head; + typedef Types0 Tail; +}; + +$range i 2..n + +$for i [[ +$range j 1..i +$range k 2..i +template <$for j, [[typename T$j]]> +struct Types$i { + typedef T1 Head; + typedef Types$(i-1)<$for k, [[T$k]]> Tail; +}; + + +]] + +} // namespace internal + +// We don't want to require the users to write TypesN<...> directly, +// as that would require them to count the length. Types<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Types +// will appear as Types in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Types, and Google Test will translate +// that to TypesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Types template. + +$range i 1..n +template <$for i, [[typename T$i = internal::None]]> +struct Types { + typedef internal::Types$n<$for i, [[T$i]]> type; +}; + +template <> +struct Types<$for i, [[internal::None]]> { + typedef internal::Types0 type; +}; + +$range i 1..n-1 +$for i [[ +$range j 1..i +$range k i+1..n +template <$for j, [[typename T$j]]> +struct Types<$for j, [[T$j]]$for k[[, internal::None]]> { + typedef internal::Types$i<$for j, [[T$j]]> type; +}; + +]] + +namespace internal { + +# define GTEST_TEMPLATE_ template class + +// The template "selector" struct TemplateSel is used to +// represent Tmpl, which must be a class template with one type +// parameter, as a type. TemplateSel::Bind::type is defined +// as the type Tmpl. This allows us to actually instantiate the +// template "selected" by TemplateSel. +// +// This trick is necessary for simulating typedef for class templates, +// which C++ doesn't support directly. +template +struct TemplateSel { + template + struct Bind { + typedef Tmpl type; + }; +}; + +# define GTEST_BIND_(TmplSel, T) \ + TmplSel::template Bind::type + +// A unique struct template used as the default value for the +// arguments of class template Templates. This allows us to simulate +// variadic templates (e.g. Templates, Templates, +// and etc), which C++ doesn't support directly. +template +struct NoneT {}; + +// The following family of struct and struct templates are used to +// represent template lists. In particular, TemplatesN represents a list of N templates (T1, T2, ..., and TN). Except +// for Templates0, every struct in the family has two member types: +// Head for the selector of the first template in the list, and Tail +// for the rest of the list. + +// The empty template list. +struct Templates0 {}; + +// Template lists of length 1, 2, 3, and so on. + +template +struct Templates1 { + typedef TemplateSel Head; + typedef Templates0 Tail; +}; + +$range i 2..n + +$for i [[ +$range j 1..i +$range k 2..i +template <$for j, [[GTEST_TEMPLATE_ T$j]]> +struct Templates$i { + typedef TemplateSel Head; + typedef Templates$(i-1)<$for k, [[T$k]]> Tail; +}; + + +]] + +// We don't want to require the users to write TemplatesN<...> directly, +// as that would require them to count the length. Templates<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Templates +// will appear as Templates in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Templates, and Google Test will translate +// that to TemplatesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Templates template. + +$range i 1..n +template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]> +struct Templates { + typedef Templates$n<$for i, [[T$i]]> type; +}; + +template <> +struct Templates<$for i, [[NoneT]]> { + typedef Templates0 type; +}; + +$range i 1..n-1 +$for i [[ +$range j 1..i +$range k i+1..n +template <$for j, [[GTEST_TEMPLATE_ T$j]]> +struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> { + typedef Templates$i<$for j, [[T$j]]> type; +}; + +]] + +// The TypeList template makes it possible to use either a single type +// or a Types<...> list in TYPED_TEST_SUITE() and +// INSTANTIATE_TYPED_TEST_SUITE_P(). + +template +struct TypeList { + typedef Types1 type; +}; + + +$range i 1..n +template <$for i, [[typename T$i]]> +struct TypeList > { + typedef typename Types<$for i, [[T$i]]>::type type; +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ diff --git a/include/hiredis/adapters/ae.h b/include/hiredis/adapters/ae.h new file mode 100644 index 0000000..660d82e --- /dev/null +++ b/include/hiredis/adapters/ae.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2010-2011, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __HIREDIS_AE_H__ +#define __HIREDIS_AE_H__ +#include +#include +#include "../hiredis.h" +#include "../async.h" + +typedef struct redisAeEvents { + redisAsyncContext *context; + aeEventLoop *loop; + int fd; + int reading, writing; +} redisAeEvents; + +static void redisAeReadEvent(aeEventLoop *el, int fd, void *privdata, int mask) { + ((void)el); ((void)fd); ((void)mask); + + redisAeEvents *e = (redisAeEvents*)privdata; + redisAsyncHandleRead(e->context); +} + +static void redisAeWriteEvent(aeEventLoop *el, int fd, void *privdata, int mask) { + ((void)el); ((void)fd); ((void)mask); + + redisAeEvents *e = (redisAeEvents*)privdata; + redisAsyncHandleWrite(e->context); +} + +static void redisAeAddRead(void *privdata) { + redisAeEvents *e = (redisAeEvents*)privdata; + aeEventLoop *loop = e->loop; + if (!e->reading) { + e->reading = 1; + aeCreateFileEvent(loop,e->fd,AE_READABLE,redisAeReadEvent,e); + } +} + +static void redisAeDelRead(void *privdata) { + redisAeEvents *e = (redisAeEvents*)privdata; + aeEventLoop *loop = e->loop; + if (e->reading) { + e->reading = 0; + aeDeleteFileEvent(loop,e->fd,AE_READABLE); + } +} + +static void redisAeAddWrite(void *privdata) { + redisAeEvents *e = (redisAeEvents*)privdata; + aeEventLoop *loop = e->loop; + if (!e->writing) { + e->writing = 1; + aeCreateFileEvent(loop,e->fd,AE_WRITABLE,redisAeWriteEvent,e); + } +} + +static void redisAeDelWrite(void *privdata) { + redisAeEvents *e = (redisAeEvents*)privdata; + aeEventLoop *loop = e->loop; + if (e->writing) { + e->writing = 0; + aeDeleteFileEvent(loop,e->fd,AE_WRITABLE); + } +} + +static void redisAeCleanup(void *privdata) { + redisAeEvents *e = (redisAeEvents*)privdata; + redisAeDelRead(privdata); + redisAeDelWrite(privdata); + hi_free(e); +} + +static int redisAeAttach(aeEventLoop *loop, redisAsyncContext *ac) { + redisContext *c = &(ac->c); + redisAeEvents *e; + + /* Nothing should be attached when something is already attached */ + if (ac->ev.data != NULL) + return REDIS_ERR; + + /* Create container for context and r/w events */ + e = (redisAeEvents*)hi_malloc(sizeof(*e)); + if (e == NULL) + return REDIS_ERR; + + e->context = ac; + e->loop = loop; + e->fd = c->fd; + e->reading = e->writing = 0; + + /* Register functions to start/stop listening for events */ + ac->ev.addRead = redisAeAddRead; + ac->ev.delRead = redisAeDelRead; + ac->ev.addWrite = redisAeAddWrite; + ac->ev.delWrite = redisAeDelWrite; + ac->ev.cleanup = redisAeCleanup; + ac->ev.data = e; + + return REDIS_OK; +} +#endif diff --git a/include/hiredis/adapters/glib.h b/include/hiredis/adapters/glib.h new file mode 100644 index 0000000..ad59dd1 --- /dev/null +++ b/include/hiredis/adapters/glib.h @@ -0,0 +1,156 @@ +#ifndef __HIREDIS_GLIB_H__ +#define __HIREDIS_GLIB_H__ + +#include + +#include "../hiredis.h" +#include "../async.h" + +typedef struct +{ + GSource source; + redisAsyncContext *ac; + GPollFD poll_fd; +} RedisSource; + +static void +redis_source_add_read (gpointer data) +{ + RedisSource *source = (RedisSource *)data; + g_return_if_fail(source); + source->poll_fd.events |= G_IO_IN; + g_main_context_wakeup(g_source_get_context((GSource *)data)); +} + +static void +redis_source_del_read (gpointer data) +{ + RedisSource *source = (RedisSource *)data; + g_return_if_fail(source); + source->poll_fd.events &= ~G_IO_IN; + g_main_context_wakeup(g_source_get_context((GSource *)data)); +} + +static void +redis_source_add_write (gpointer data) +{ + RedisSource *source = (RedisSource *)data; + g_return_if_fail(source); + source->poll_fd.events |= G_IO_OUT; + g_main_context_wakeup(g_source_get_context((GSource *)data)); +} + +static void +redis_source_del_write (gpointer data) +{ + RedisSource *source = (RedisSource *)data; + g_return_if_fail(source); + source->poll_fd.events &= ~G_IO_OUT; + g_main_context_wakeup(g_source_get_context((GSource *)data)); +} + +static void +redis_source_cleanup (gpointer data) +{ + RedisSource *source = (RedisSource *)data; + + g_return_if_fail(source); + + redis_source_del_read(source); + redis_source_del_write(source); + /* + * It is not our responsibility to remove ourself from the + * current main loop. However, we will remove the GPollFD. + */ + if (source->poll_fd.fd >= 0) { + g_source_remove_poll((GSource *)data, &source->poll_fd); + source->poll_fd.fd = -1; + } +} + +static gboolean +redis_source_prepare (GSource *source, + gint *timeout_) +{ + RedisSource *redis = (RedisSource *)source; + *timeout_ = -1; + return !!(redis->poll_fd.events & redis->poll_fd.revents); +} + +static gboolean +redis_source_check (GSource *source) +{ + RedisSource *redis = (RedisSource *)source; + return !!(redis->poll_fd.events & redis->poll_fd.revents); +} + +static gboolean +redis_source_dispatch (GSource *source, + GSourceFunc callback, + gpointer user_data) +{ + RedisSource *redis = (RedisSource *)source; + + if ((redis->poll_fd.revents & G_IO_OUT)) { + redisAsyncHandleWrite(redis->ac); + redis->poll_fd.revents &= ~G_IO_OUT; + } + + if ((redis->poll_fd.revents & G_IO_IN)) { + redisAsyncHandleRead(redis->ac); + redis->poll_fd.revents &= ~G_IO_IN; + } + + if (callback) { + return callback(user_data); + } + + return TRUE; +} + +static void +redis_source_finalize (GSource *source) +{ + RedisSource *redis = (RedisSource *)source; + + if (redis->poll_fd.fd >= 0) { + g_source_remove_poll(source, &redis->poll_fd); + redis->poll_fd.fd = -1; + } +} + +static GSource * +redis_source_new (redisAsyncContext *ac) +{ + static GSourceFuncs source_funcs = { + .prepare = redis_source_prepare, + .check = redis_source_check, + .dispatch = redis_source_dispatch, + .finalize = redis_source_finalize, + }; + redisContext *c = &ac->c; + RedisSource *source; + + g_return_val_if_fail(ac != NULL, NULL); + + source = (RedisSource *)g_source_new(&source_funcs, sizeof *source); + if (source == NULL) + return NULL; + + source->ac = ac; + source->poll_fd.fd = c->fd; + source->poll_fd.events = 0; + source->poll_fd.revents = 0; + g_source_add_poll((GSource *)source, &source->poll_fd); + + ac->ev.addRead = redis_source_add_read; + ac->ev.delRead = redis_source_del_read; + ac->ev.addWrite = redis_source_add_write; + ac->ev.delWrite = redis_source_del_write; + ac->ev.cleanup = redis_source_cleanup; + ac->ev.data = source; + + return (GSource *)source; +} + +#endif /* __HIREDIS_GLIB_H__ */ diff --git a/include/hiredis/adapters/ivykis.h b/include/hiredis/adapters/ivykis.h new file mode 100644 index 0000000..179f6ab --- /dev/null +++ b/include/hiredis/adapters/ivykis.h @@ -0,0 +1,84 @@ +#ifndef __HIREDIS_IVYKIS_H__ +#define __HIREDIS_IVYKIS_H__ +#include +#include "../hiredis.h" +#include "../async.h" + +typedef struct redisIvykisEvents { + redisAsyncContext *context; + struct iv_fd fd; +} redisIvykisEvents; + +static void redisIvykisReadEvent(void *arg) { + redisAsyncContext *context = (redisAsyncContext *)arg; + redisAsyncHandleRead(context); +} + +static void redisIvykisWriteEvent(void *arg) { + redisAsyncContext *context = (redisAsyncContext *)arg; + redisAsyncHandleWrite(context); +} + +static void redisIvykisAddRead(void *privdata) { + redisIvykisEvents *e = (redisIvykisEvents*)privdata; + iv_fd_set_handler_in(&e->fd, redisIvykisReadEvent); +} + +static void redisIvykisDelRead(void *privdata) { + redisIvykisEvents *e = (redisIvykisEvents*)privdata; + iv_fd_set_handler_in(&e->fd, NULL); +} + +static void redisIvykisAddWrite(void *privdata) { + redisIvykisEvents *e = (redisIvykisEvents*)privdata; + iv_fd_set_handler_out(&e->fd, redisIvykisWriteEvent); +} + +static void redisIvykisDelWrite(void *privdata) { + redisIvykisEvents *e = (redisIvykisEvents*)privdata; + iv_fd_set_handler_out(&e->fd, NULL); +} + +static void redisIvykisCleanup(void *privdata) { + redisIvykisEvents *e = (redisIvykisEvents*)privdata; + + iv_fd_unregister(&e->fd); + hi_free(e); +} + +static int redisIvykisAttach(redisAsyncContext *ac) { + redisContext *c = &(ac->c); + redisIvykisEvents *e; + + /* Nothing should be attached when something is already attached */ + if (ac->ev.data != NULL) + return REDIS_ERR; + + /* Create container for context and r/w events */ + e = (redisIvykisEvents*)hi_malloc(sizeof(*e)); + if (e == NULL) + return REDIS_ERR; + + e->context = ac; + + /* Register functions to start/stop listening for events */ + ac->ev.addRead = redisIvykisAddRead; + ac->ev.delRead = redisIvykisDelRead; + ac->ev.addWrite = redisIvykisAddWrite; + ac->ev.delWrite = redisIvykisDelWrite; + ac->ev.cleanup = redisIvykisCleanup; + ac->ev.data = e; + + /* Initialize and install read/write events */ + IV_FD_INIT(&e->fd); + e->fd.fd = c->fd; + e->fd.handler_in = redisIvykisReadEvent; + e->fd.handler_out = redisIvykisWriteEvent; + e->fd.handler_err = NULL; + e->fd.cookie = e->context; + + iv_fd_register(&e->fd); + + return REDIS_OK; +} +#endif diff --git a/include/hiredis/adapters/libev.h b/include/hiredis/adapters/libev.h new file mode 100644 index 0000000..6191543 --- /dev/null +++ b/include/hiredis/adapters/libev.h @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2010-2011, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __HIREDIS_LIBEV_H__ +#define __HIREDIS_LIBEV_H__ +#include +#include +#include +#include "../hiredis.h" +#include "../async.h" + +typedef struct redisLibevEvents { + redisAsyncContext *context; + struct ev_loop *loop; + int reading, writing; + ev_io rev, wev; + ev_timer timer; +} redisLibevEvents; + +static void redisLibevReadEvent(EV_P_ ev_io *watcher, int revents) { +#if EV_MULTIPLICITY + ((void)EV_A); +#endif + ((void)revents); + + redisLibevEvents *e = (redisLibevEvents*)watcher->data; + redisAsyncHandleRead(e->context); +} + +static void redisLibevWriteEvent(EV_P_ ev_io *watcher, int revents) { +#if EV_MULTIPLICITY + ((void)EV_A); +#endif + ((void)revents); + + redisLibevEvents *e = (redisLibevEvents*)watcher->data; + redisAsyncHandleWrite(e->context); +} + +static void redisLibevAddRead(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + if (!e->reading) { + e->reading = 1; + ev_io_start(EV_A_ &e->rev); + } +} + +static void redisLibevDelRead(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + if (e->reading) { + e->reading = 0; + ev_io_stop(EV_A_ &e->rev); + } +} + +static void redisLibevAddWrite(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + if (!e->writing) { + e->writing = 1; + ev_io_start(EV_A_ &e->wev); + } +} + +static void redisLibevDelWrite(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + if (e->writing) { + e->writing = 0; + ev_io_stop(EV_A_ &e->wev); + } +} + +static void redisLibevStopTimer(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + ev_timer_stop(EV_A_ &e->timer); +} + +static void redisLibevCleanup(void *privdata) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + redisLibevDelRead(privdata); + redisLibevDelWrite(privdata); + redisLibevStopTimer(privdata); + hi_free(e); +} + +static void redisLibevTimeout(EV_P_ ev_timer *timer, int revents) { + ((void)revents); + redisLibevEvents *e = (redisLibevEvents*)timer->data; + redisAsyncHandleTimeout(e->context); +} + +static void redisLibevSetTimeout(void *privdata, struct timeval tv) { + redisLibevEvents *e = (redisLibevEvents*)privdata; + struct ev_loop *loop = e->loop; + ((void)loop); + + if (!ev_is_active(&e->timer)) { + ev_init(&e->timer, redisLibevTimeout); + e->timer.data = e; + } + + e->timer.repeat = tv.tv_sec + tv.tv_usec / 1000000.00; + ev_timer_again(EV_A_ &e->timer); +} + +static int redisLibevAttach(EV_P_ redisAsyncContext *ac) { + redisContext *c = &(ac->c); + redisLibevEvents *e; + + /* Nothing should be attached when something is already attached */ + if (ac->ev.data != NULL) + return REDIS_ERR; + + /* Create container for context and r/w events */ + e = (redisLibevEvents*)hi_calloc(1, sizeof(*e)); + if (e == NULL) + return REDIS_ERR; + + e->context = ac; +#if EV_MULTIPLICITY + e->loop = EV_A; +#else + e->loop = NULL; +#endif + e->rev.data = e; + e->wev.data = e; + + /* Register functions to start/stop listening for events */ + ac->ev.addRead = redisLibevAddRead; + ac->ev.delRead = redisLibevDelRead; + ac->ev.addWrite = redisLibevAddWrite; + ac->ev.delWrite = redisLibevDelWrite; + ac->ev.cleanup = redisLibevCleanup; + ac->ev.scheduleTimer = redisLibevSetTimeout; + ac->ev.data = e; + + /* Initialize read/write events */ + ev_io_init(&e->rev,redisLibevReadEvent,c->fd,EV_READ); + ev_io_init(&e->wev,redisLibevWriteEvent,c->fd,EV_WRITE); + return REDIS_OK; +} + +#endif diff --git a/include/hiredis/adapters/libevent.h b/include/hiredis/adapters/libevent.h new file mode 100644 index 0000000..9150979 --- /dev/null +++ b/include/hiredis/adapters/libevent.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2010-2011, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __HIREDIS_LIBEVENT_H__ +#define __HIREDIS_LIBEVENT_H__ +#include +#include "../hiredis.h" +#include "../async.h" + +#define REDIS_LIBEVENT_DELETED 0x01 +#define REDIS_LIBEVENT_ENTERED 0x02 + +typedef struct redisLibeventEvents { + redisAsyncContext *context; + struct event *ev; + struct event_base *base; + struct timeval tv; + short flags; + short state; +} redisLibeventEvents; + +static void redisLibeventDestroy(redisLibeventEvents *e) { + hi_free(e); +} + +static void redisLibeventHandler(int fd, short event, void *arg) { + ((void)fd); + redisLibeventEvents *e = (redisLibeventEvents*)arg; + e->state |= REDIS_LIBEVENT_ENTERED; + + #define CHECK_DELETED() if (e->state & REDIS_LIBEVENT_DELETED) {\ + redisLibeventDestroy(e);\ + return; \ + } + + if ((event & EV_TIMEOUT) && (e->state & REDIS_LIBEVENT_DELETED) == 0) { + redisAsyncHandleTimeout(e->context); + CHECK_DELETED(); + } + + if ((event & EV_READ) && e->context && (e->state & REDIS_LIBEVENT_DELETED) == 0) { + redisAsyncHandleRead(e->context); + CHECK_DELETED(); + } + + if ((event & EV_WRITE) && e->context && (e->state & REDIS_LIBEVENT_DELETED) == 0) { + redisAsyncHandleWrite(e->context); + CHECK_DELETED(); + } + + e->state &= ~REDIS_LIBEVENT_ENTERED; + #undef CHECK_DELETED +} + +static void redisLibeventUpdate(void *privdata, short flag, int isRemove) { + redisLibeventEvents *e = (redisLibeventEvents *)privdata; + const struct timeval *tv = e->tv.tv_sec || e->tv.tv_usec ? &e->tv : NULL; + + if (isRemove) { + if ((e->flags & flag) == 0) { + return; + } else { + e->flags &= ~flag; + } + } else { + if (e->flags & flag) { + return; + } else { + e->flags |= flag; + } + } + + event_del(e->ev); + event_assign(e->ev, e->base, e->context->c.fd, e->flags | EV_PERSIST, + redisLibeventHandler, privdata); + event_add(e->ev, tv); +} + +static void redisLibeventAddRead(void *privdata) { + redisLibeventUpdate(privdata, EV_READ, 0); +} + +static void redisLibeventDelRead(void *privdata) { + redisLibeventUpdate(privdata, EV_READ, 1); +} + +static void redisLibeventAddWrite(void *privdata) { + redisLibeventUpdate(privdata, EV_WRITE, 0); +} + +static void redisLibeventDelWrite(void *privdata) { + redisLibeventUpdate(privdata, EV_WRITE, 1); +} + +static void redisLibeventCleanup(void *privdata) { + redisLibeventEvents *e = (redisLibeventEvents*)privdata; + if (!e) { + return; + } + event_del(e->ev); + event_free(e->ev); + e->ev = NULL; + + if (e->state & REDIS_LIBEVENT_ENTERED) { + e->state |= REDIS_LIBEVENT_DELETED; + } else { + redisLibeventDestroy(e); + } +} + +static void redisLibeventSetTimeout(void *privdata, struct timeval tv) { + redisLibeventEvents *e = (redisLibeventEvents *)privdata; + short flags = e->flags; + e->flags = 0; + e->tv = tv; + redisLibeventUpdate(e, flags, 0); +} + +static int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) { + redisContext *c = &(ac->c); + redisLibeventEvents *e; + + /* Nothing should be attached when something is already attached */ + if (ac->ev.data != NULL) + return REDIS_ERR; + + /* Create container for context and r/w events */ + e = (redisLibeventEvents*)hi_calloc(1, sizeof(*e)); + if (e == NULL) + return REDIS_ERR; + + e->context = ac; + + /* Register functions to start/stop listening for events */ + ac->ev.addRead = redisLibeventAddRead; + ac->ev.delRead = redisLibeventDelRead; + ac->ev.addWrite = redisLibeventAddWrite; + ac->ev.delWrite = redisLibeventDelWrite; + ac->ev.cleanup = redisLibeventCleanup; + ac->ev.scheduleTimer = redisLibeventSetTimeout; + ac->ev.data = e; + + /* Initialize and install read/write events */ + e->ev = event_new(base, c->fd, EV_READ | EV_WRITE, redisLibeventHandler, e); + e->base = base; + return REDIS_OK; +} +#endif diff --git a/include/hiredis/adapters/libuv.h b/include/hiredis/adapters/libuv.h new file mode 100644 index 0000000..c120b1b --- /dev/null +++ b/include/hiredis/adapters/libuv.h @@ -0,0 +1,117 @@ +#ifndef __HIREDIS_LIBUV_H__ +#define __HIREDIS_LIBUV_H__ +#include +#include +#include "../hiredis.h" +#include "../async.h" +#include + +typedef struct redisLibuvEvents { + redisAsyncContext* context; + uv_poll_t handle; + int events; +} redisLibuvEvents; + + +static void redisLibuvPoll(uv_poll_t* handle, int status, int events) { + redisLibuvEvents* p = (redisLibuvEvents*)handle->data; + int ev = (status ? p->events : events); + + if (p->context != NULL && (ev & UV_READABLE)) { + redisAsyncHandleRead(p->context); + } + if (p->context != NULL && (ev & UV_WRITABLE)) { + redisAsyncHandleWrite(p->context); + } +} + + +static void redisLibuvAddRead(void *privdata) { + redisLibuvEvents* p = (redisLibuvEvents*)privdata; + + p->events |= UV_READABLE; + + uv_poll_start(&p->handle, p->events, redisLibuvPoll); +} + + +static void redisLibuvDelRead(void *privdata) { + redisLibuvEvents* p = (redisLibuvEvents*)privdata; + + p->events &= ~UV_READABLE; + + if (p->events) { + uv_poll_start(&p->handle, p->events, redisLibuvPoll); + } else { + uv_poll_stop(&p->handle); + } +} + + +static void redisLibuvAddWrite(void *privdata) { + redisLibuvEvents* p = (redisLibuvEvents*)privdata; + + p->events |= UV_WRITABLE; + + uv_poll_start(&p->handle, p->events, redisLibuvPoll); +} + + +static void redisLibuvDelWrite(void *privdata) { + redisLibuvEvents* p = (redisLibuvEvents*)privdata; + + p->events &= ~UV_WRITABLE; + + if (p->events) { + uv_poll_start(&p->handle, p->events, redisLibuvPoll); + } else { + uv_poll_stop(&p->handle); + } +} + + +static void on_close(uv_handle_t* handle) { + redisLibuvEvents* p = (redisLibuvEvents*)handle->data; + + hi_free(p); +} + + +static void redisLibuvCleanup(void *privdata) { + redisLibuvEvents* p = (redisLibuvEvents*)privdata; + + p->context = NULL; // indicate that context might no longer exist + uv_close((uv_handle_t*)&p->handle, on_close); +} + + +static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) { + redisContext *c = &(ac->c); + + if (ac->ev.data != NULL) { + return REDIS_ERR; + } + + ac->ev.addRead = redisLibuvAddRead; + ac->ev.delRead = redisLibuvDelRead; + ac->ev.addWrite = redisLibuvAddWrite; + ac->ev.delWrite = redisLibuvDelWrite; + ac->ev.cleanup = redisLibuvCleanup; + + redisLibuvEvents* p = (redisLibuvEvents*)hi_malloc(sizeof(*p)); + if (p == NULL) + return REDIS_ERR; + + memset(p, 0, sizeof(*p)); + + if (uv_poll_init_socket(loop, &p->handle, c->fd) != 0) { + return REDIS_ERR; + } + + ac->ev.data = p; + p->handle.data = p; + p->context = ac; + + return REDIS_OK; +} +#endif diff --git a/include/hiredis/adapters/macosx.h b/include/hiredis/adapters/macosx.h new file mode 100644 index 0000000..3c87f1b --- /dev/null +++ b/include/hiredis/adapters/macosx.h @@ -0,0 +1,115 @@ +// +// Created by 袛屑懈褌褉懈泄 袘邪褏胁邪谢芯胁 on 13.07.15. +// Copyright (c) 2015 Dmitry Bakhvalov. All rights reserved. +// + +#ifndef __HIREDIS_MACOSX_H__ +#define __HIREDIS_MACOSX_H__ + +#include + +#include "../hiredis.h" +#include "../async.h" + +typedef struct { + redisAsyncContext *context; + CFSocketRef socketRef; + CFRunLoopSourceRef sourceRef; +} RedisRunLoop; + +static int freeRedisRunLoop(RedisRunLoop* redisRunLoop) { + if( redisRunLoop != NULL ) { + if( redisRunLoop->sourceRef != NULL ) { + CFRunLoopSourceInvalidate(redisRunLoop->sourceRef); + CFRelease(redisRunLoop->sourceRef); + } + if( redisRunLoop->socketRef != NULL ) { + CFSocketInvalidate(redisRunLoop->socketRef); + CFRelease(redisRunLoop->socketRef); + } + hi_free(redisRunLoop); + } + return REDIS_ERR; +} + +static void redisMacOSAddRead(void *privdata) { + RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata; + CFSocketEnableCallBacks(redisRunLoop->socketRef, kCFSocketReadCallBack); +} + +static void redisMacOSDelRead(void *privdata) { + RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata; + CFSocketDisableCallBacks(redisRunLoop->socketRef, kCFSocketReadCallBack); +} + +static void redisMacOSAddWrite(void *privdata) { + RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata; + CFSocketEnableCallBacks(redisRunLoop->socketRef, kCFSocketWriteCallBack); +} + +static void redisMacOSDelWrite(void *privdata) { + RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata; + CFSocketDisableCallBacks(redisRunLoop->socketRef, kCFSocketWriteCallBack); +} + +static void redisMacOSCleanup(void *privdata) { + RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata; + freeRedisRunLoop(redisRunLoop); +} + +static void redisMacOSAsyncCallback(CFSocketRef __unused s, CFSocketCallBackType callbackType, CFDataRef __unused address, const void __unused *data, void *info) { + redisAsyncContext* context = (redisAsyncContext*) info; + + switch (callbackType) { + case kCFSocketReadCallBack: + redisAsyncHandleRead(context); + break; + + case kCFSocketWriteCallBack: + redisAsyncHandleWrite(context); + break; + + default: + break; + } +} + +static int redisMacOSAttach(redisAsyncContext *redisAsyncCtx, CFRunLoopRef runLoop) { + redisContext *redisCtx = &(redisAsyncCtx->c); + + /* Nothing should be attached when something is already attached */ + if( redisAsyncCtx->ev.data != NULL ) return REDIS_ERR; + + RedisRunLoop* redisRunLoop = (RedisRunLoop*) hi_calloc(1, sizeof(RedisRunLoop)); + if (redisRunLoop == NULL) + return REDIS_ERR; + + /* Setup redis stuff */ + redisRunLoop->context = redisAsyncCtx; + + redisAsyncCtx->ev.addRead = redisMacOSAddRead; + redisAsyncCtx->ev.delRead = redisMacOSDelRead; + redisAsyncCtx->ev.addWrite = redisMacOSAddWrite; + redisAsyncCtx->ev.delWrite = redisMacOSDelWrite; + redisAsyncCtx->ev.cleanup = redisMacOSCleanup; + redisAsyncCtx->ev.data = redisRunLoop; + + /* Initialize and install read/write events */ + CFSocketContext socketCtx = { 0, redisAsyncCtx, NULL, NULL, NULL }; + + redisRunLoop->socketRef = CFSocketCreateWithNative(NULL, redisCtx->fd, + kCFSocketReadCallBack | kCFSocketWriteCallBack, + redisMacOSAsyncCallback, + &socketCtx); + if( !redisRunLoop->socketRef ) return freeRedisRunLoop(redisRunLoop); + + redisRunLoop->sourceRef = CFSocketCreateRunLoopSource(NULL, redisRunLoop->socketRef, 0); + if( !redisRunLoop->sourceRef ) return freeRedisRunLoop(redisRunLoop); + + CFRunLoopAddSource(runLoop, redisRunLoop->sourceRef, kCFRunLoopDefaultMode); + + return REDIS_OK; +} + +#endif + diff --git a/include/hiredis/adapters/qt.h b/include/hiredis/adapters/qt.h new file mode 100644 index 0000000..5cc02e6 --- /dev/null +++ b/include/hiredis/adapters/qt.h @@ -0,0 +1,135 @@ +/*- + * Copyright (C) 2014 Pietro Cerutti + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __HIREDIS_QT_H__ +#define __HIREDIS_QT_H__ +#include +#include "../async.h" + +static void RedisQtAddRead(void *); +static void RedisQtDelRead(void *); +static void RedisQtAddWrite(void *); +static void RedisQtDelWrite(void *); +static void RedisQtCleanup(void *); + +class RedisQtAdapter : public QObject { + + Q_OBJECT + + friend + void RedisQtAddRead(void * adapter) { + RedisQtAdapter * a = static_cast(adapter); + a->addRead(); + } + + friend + void RedisQtDelRead(void * adapter) { + RedisQtAdapter * a = static_cast(adapter); + a->delRead(); + } + + friend + void RedisQtAddWrite(void * adapter) { + RedisQtAdapter * a = static_cast(adapter); + a->addWrite(); + } + + friend + void RedisQtDelWrite(void * adapter) { + RedisQtAdapter * a = static_cast(adapter); + a->delWrite(); + } + + friend + void RedisQtCleanup(void * adapter) { + RedisQtAdapter * a = static_cast(adapter); + a->cleanup(); + } + + public: + RedisQtAdapter(QObject * parent = 0) + : QObject(parent), m_ctx(0), m_read(0), m_write(0) { } + + ~RedisQtAdapter() { + if (m_ctx != 0) { + m_ctx->ev.data = NULL; + } + } + + int setContext(redisAsyncContext * ac) { + if (ac->ev.data != NULL) { + return REDIS_ERR; + } + m_ctx = ac; + m_ctx->ev.data = this; + m_ctx->ev.addRead = RedisQtAddRead; + m_ctx->ev.delRead = RedisQtDelRead; + m_ctx->ev.addWrite = RedisQtAddWrite; + m_ctx->ev.delWrite = RedisQtDelWrite; + m_ctx->ev.cleanup = RedisQtCleanup; + return REDIS_OK; + } + + private: + void addRead() { + if (m_read) return; + m_read = new QSocketNotifier(m_ctx->c.fd, QSocketNotifier::Read, 0); + connect(m_read, SIGNAL(activated(int)), this, SLOT(read())); + } + + void delRead() { + if (!m_read) return; + delete m_read; + m_read = 0; + } + + void addWrite() { + if (m_write) return; + m_write = new QSocketNotifier(m_ctx->c.fd, QSocketNotifier::Write, 0); + connect(m_write, SIGNAL(activated(int)), this, SLOT(write())); + } + + void delWrite() { + if (!m_write) return; + delete m_write; + m_write = 0; + } + + void cleanup() { + delRead(); + delWrite(); + } + + private slots: + void read() { redisAsyncHandleRead(m_ctx); } + void write() { redisAsyncHandleWrite(m_ctx); } + + private: + redisAsyncContext * m_ctx; + QSocketNotifier * m_read; + QSocketNotifier * m_write; +}; + +#endif /* !__HIREDIS_QT_H__ */ diff --git a/include/hiredis/alloc.h b/include/hiredis/alloc.h new file mode 100644 index 0000000..34a05f4 --- /dev/null +++ b/include/hiredis/alloc.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020, Michael Grunder + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HIREDIS_ALLOC_H +#define HIREDIS_ALLOC_H + +#include /* for size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Structure pointing to our actually configured allocators */ +typedef struct hiredisAllocFuncs { + void *(*mallocFn)(size_t); + void *(*callocFn)(size_t,size_t); + void *(*reallocFn)(void*,size_t); + char *(*strdupFn)(const char*); + void (*freeFn)(void*); +} hiredisAllocFuncs; + +hiredisAllocFuncs hiredisSetAllocators(hiredisAllocFuncs *ha); +void hiredisResetAllocators(void); + +#ifndef _WIN32 + +/* Hiredis' configured allocator function pointer struct */ +extern hiredisAllocFuncs hiredisAllocFns; + +static inline void *hi_malloc(size_t size) { + return hiredisAllocFns.mallocFn(size); +} + +static inline void *hi_calloc(size_t nmemb, size_t size) { + return hiredisAllocFns.callocFn(nmemb, size); +} + +static inline void *hi_realloc(void *ptr, size_t size) { + return hiredisAllocFns.reallocFn(ptr, size); +} + +static inline char *hi_strdup(const char *str) { + return hiredisAllocFns.strdupFn(str); +} + +static inline void hi_free(void *ptr) { + hiredisAllocFns.freeFn(ptr); +} + +#else + +void *hi_malloc(size_t size); +void *hi_calloc(size_t nmemb, size_t size); +void *hi_realloc(void *ptr, size_t size); +char *hi_strdup(const char *str); +void hi_free(void *ptr); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HIREDIS_ALLOC_H */ diff --git a/include/hiredis/async.h b/include/hiredis/async.h new file mode 100644 index 0000000..b1d2cb2 --- /dev/null +++ b/include/hiredis/async.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2009-2011, Salvatore Sanfilippo + * Copyright (c) 2010-2011, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __HIREDIS_ASYNC_H +#define __HIREDIS_ASYNC_H +#include "hiredis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct redisAsyncContext; /* need forward declaration of redisAsyncContext */ +struct dict; /* dictionary header is included in async.c */ + +/* Reply callback prototype and container */ +typedef void (redisCallbackFn)(struct redisAsyncContext*, void*, void*); +typedef struct redisCallback { + struct redisCallback *next; /* simple singly linked list */ + redisCallbackFn *fn; + int pending_subs; + void *privdata; +} redisCallback; + +/* List of callbacks for either regular replies or pub/sub */ +typedef struct redisCallbackList { + redisCallback *head, *tail; +} redisCallbackList; + +/* Connection callback prototypes */ +typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status); +typedef void (redisConnectCallback)(const struct redisAsyncContext*, int status); +typedef void(redisTimerCallback)(void *timer, void *privdata); + +/* Context for an async connection to Redis */ +typedef struct redisAsyncContext { + /* Hold the regular context, so it can be realloc'ed. */ + redisContext c; + + /* Setup error flags so they can be used directly. */ + int err; + char *errstr; + + /* Not used by hiredis */ + void *data; + void (*dataCleanup)(void *privdata); + + /* Event library data and hooks */ + struct { + void *data; + + /* Hooks that are called when the library expects to start + * reading/writing. These functions should be idempotent. */ + void (*addRead)(void *privdata); + void (*delRead)(void *privdata); + void (*addWrite)(void *privdata); + void (*delWrite)(void *privdata); + void (*cleanup)(void *privdata); + void (*scheduleTimer)(void *privdata, struct timeval tv); + } ev; + + /* Called when either the connection is terminated due to an error or per + * user request. The status is set accordingly (REDIS_OK, REDIS_ERR). */ + redisDisconnectCallback *onDisconnect; + + /* Called when the first write event was received. */ + redisConnectCallback *onConnect; + + /* Regular command callbacks */ + redisCallbackList replies; + + /* Address used for connect() */ + struct sockaddr *saddr; + size_t addrlen; + + /* Subscription callbacks */ + struct { + redisCallbackList invalid; + struct dict *channels; + struct dict *patterns; + } sub; + + /* Any configured RESP3 PUSH handler */ + redisAsyncPushFn *push_cb; +} redisAsyncContext; + +/* Functions that proxy to hiredis */ +redisAsyncContext *redisAsyncConnectWithOptions(const redisOptions *options); +redisAsyncContext *redisAsyncConnect(const char *ip, int port); +redisAsyncContext *redisAsyncConnectBind(const char *ip, int port, const char *source_addr); +redisAsyncContext *redisAsyncConnectBindWithReuse(const char *ip, int port, + const char *source_addr); +redisAsyncContext *redisAsyncConnectUnix(const char *path); +int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn); +int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn); + +redisAsyncPushFn *redisAsyncSetPushCallback(redisAsyncContext *ac, redisAsyncPushFn *fn); +int redisAsyncSetTimeout(redisAsyncContext *ac, struct timeval tv); +void redisAsyncDisconnect(redisAsyncContext *ac); +void redisAsyncFree(redisAsyncContext *ac); + +/* Handle read/write events */ +void redisAsyncHandleRead(redisAsyncContext *ac); +void redisAsyncHandleWrite(redisAsyncContext *ac); +void redisAsyncHandleTimeout(redisAsyncContext *ac); +void redisAsyncRead(redisAsyncContext *ac); +void redisAsyncWrite(redisAsyncContext *ac); + +/* Command functions for an async context. Write the command to the + * output buffer and register the provided callback. */ +int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, va_list ap); +int redisAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, ...); +int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen); +int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *cmd, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/hiredis/hiredis.h b/include/hiredis/hiredis.h new file mode 100644 index 0000000..e77a88a --- /dev/null +++ b/include/hiredis/hiredis.h @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2009-2011, Salvatore Sanfilippo + * Copyright (c) 2010-2014, Pieter Noordhuis + * Copyright (c) 2015, Matt Stancliff , + * Jan-Erik Rediger + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __HIREDIS_H +#define __HIREDIS_H +#include "read.h" +#include /* for va_list */ +#ifndef _MSC_VER +#include /* for struct timeval */ +#else +struct timeval; /* forward declaration */ +typedef long long ssize_t; +#endif +#include /* uintXX_t, etc */ +#include "sds.h" /* for sds */ +#include "alloc.h" /* for allocation wrappers */ + +#define HIREDIS_MAJOR 1 +#define HIREDIS_MINOR 0 +#define HIREDIS_PATCH 1 +#define HIREDIS_SONAME 1.0.1-dev + +/* Connection type can be blocking or non-blocking and is set in the + * least significant bit of the flags field in redisContext. */ +#define REDIS_BLOCK 0x1 + +/* Connection may be disconnected before being free'd. The second bit + * in the flags field is set when the context is connected. */ +#define REDIS_CONNECTED 0x2 + +/* The async API might try to disconnect cleanly and flush the output + * buffer and read all subsequent replies before disconnecting. + * This flag means no new commands can come in and the connection + * should be terminated once all replies have been read. */ +#define REDIS_DISCONNECTING 0x4 + +/* Flag specific to the async API which means that the context should be clean + * up as soon as possible. */ +#define REDIS_FREEING 0x8 + +/* Flag that is set when an async callback is executed. */ +#define REDIS_IN_CALLBACK 0x10 + +/* Flag that is set when the async context has one or more subscriptions. */ +#define REDIS_SUBSCRIBED 0x20 + +/* Flag that is set when monitor mode is active */ +#define REDIS_MONITORING 0x40 + +/* Flag that is set when we should set SO_REUSEADDR before calling bind() */ +#define REDIS_REUSEADDR 0x80 + +/** + * Flag that indicates the user does not want the context to + * be automatically freed upon error + */ +#define REDIS_NO_AUTO_FREE 0x200 + +#define REDIS_KEEPALIVE_INTERVAL 15 /* seconds */ + +/* number of times we retry to connect in the case of EADDRNOTAVAIL and + * SO_REUSEADDR is being used. */ +#define REDIS_CONNECT_RETRIES 10 + +/* Forward declarations for structs defined elsewhere */ +struct redisAsyncContext; +struct redisContext; + +/* RESP3 push helpers and callback prototypes */ +#define redisIsPushReply(r) (((redisReply*)(r))->type == REDIS_REPLY_PUSH) +typedef void (redisPushFn)(void *, void *); +typedef void (redisAsyncPushFn)(struct redisAsyncContext *, void *); + +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the reply object returned by redisCommand() */ +typedef struct redisReply { + int type; /* REDIS_REPLY_* */ + long long integer; /* The integer when type is REDIS_REPLY_INTEGER */ + double dval; /* The double when type is REDIS_REPLY_DOUBLE */ + size_t len; /* Length of string */ + char *str; /* Used for REDIS_REPLY_ERROR, REDIS_REPLY_STRING + REDIS_REPLY_VERB, REDIS_REPLY_DOUBLE (in additional to dval), + and REDIS_REPLY_BIGNUM. */ + char vtype[4]; /* Used for REDIS_REPLY_VERB, contains the null + terminated 3 character content type, such as "txt". */ + size_t elements; /* number of elements, for REDIS_REPLY_ARRAY */ + struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */ +} redisReply; + +redisReader *redisReaderCreate(void); + +/* Function to free the reply objects hiredis returns by default. */ +void freeReplyObject(void *reply); + +/* Functions to format a command according to the protocol. */ +int redisvFormatCommand(char **target, const char *format, va_list ap); +int redisFormatCommand(char **target, const char *format, ...); +int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen); +int redisFormatSdsCommandArgv(sds *target, int argc, const char ** argv, const size_t *argvlen); +void redisFreeCommand(char *cmd); +void redisFreeSdsCommand(sds cmd); + +enum redisConnectionType { + REDIS_CONN_TCP, + REDIS_CONN_UNIX, + REDIS_CONN_USERFD +}; + +struct redisSsl; + +#define REDIS_OPT_NONBLOCK 0x01 +#define REDIS_OPT_REUSEADDR 0x02 + +/** + * Don't automatically free the async object on a connection failure, + * or other implicit conditions. Only free on an explicit call to disconnect() or free() + */ +#define REDIS_OPT_NOAUTOFREE 0x04 + +/* Don't automatically intercept and free RESP3 PUSH replies. */ +#define REDIS_OPT_NO_PUSH_AUTOFREE 0x08 + +/* In Unix systems a file descriptor is a regular signed int, with -1 + * representing an invalid descriptor. In Windows it is a SOCKET + * (32- or 64-bit unsigned integer depending on the architecture), where + * all bits set (~0) is INVALID_SOCKET. */ +#ifndef _WIN32 +typedef int redisFD; +#define REDIS_INVALID_FD -1 +#else +#ifdef _WIN64 +typedef unsigned long long redisFD; /* SOCKET = 64-bit UINT_PTR */ +#else +typedef unsigned long redisFD; /* SOCKET = 32-bit UINT_PTR */ +#endif +#define REDIS_INVALID_FD ((redisFD)(~0)) /* INVALID_SOCKET */ +#endif + +typedef struct { + /* + * the type of connection to use. This also indicates which + * `endpoint` member field to use + */ + int type; + /* bit field of REDIS_OPT_xxx */ + int options; + /* timeout value for connect operation. If NULL, no timeout is used */ + const struct timeval *connect_timeout; + /* timeout value for commands. If NULL, no timeout is used. This can be + * updated at runtime with redisSetTimeout/redisAsyncSetTimeout. */ + const struct timeval *command_timeout; + union { + /** use this field for tcp/ip connections */ + struct { + const char *source_addr; + const char *ip; + int port; + } tcp; + /** use this field for unix domain sockets */ + const char *unix_socket; + /** + * use this field to have hiredis operate an already-open + * file descriptor */ + redisFD fd; + } endpoint; + + /* Optional user defined data/destructor */ + void *privdata; + void (*free_privdata)(void *); + + /* A user defined PUSH message callback */ + redisPushFn *push_cb; + redisAsyncPushFn *async_push_cb; +} redisOptions; + +/** + * Helper macros to initialize options to their specified fields. + */ +#define REDIS_OPTIONS_SET_TCP(opts, ip_, port_) \ + (opts)->type = REDIS_CONN_TCP; \ + (opts)->endpoint.tcp.ip = ip_; \ + (opts)->endpoint.tcp.port = port_; + +#define REDIS_OPTIONS_SET_UNIX(opts, path) \ + (opts)->type = REDIS_CONN_UNIX; \ + (opts)->endpoint.unix_socket = path; + +#define REDIS_OPTIONS_SET_PRIVDATA(opts, data, dtor) \ + (opts)->privdata = data; \ + (opts)->free_privdata = dtor; \ + +typedef struct redisContextFuncs { + void (*free_privctx)(void *); + void (*async_read)(struct redisAsyncContext *); + void (*async_write)(struct redisAsyncContext *); + ssize_t (*read)(struct redisContext *, char *, size_t); + ssize_t (*write)(struct redisContext *); +} redisContextFuncs; + +/* Context for a connection to Redis */ +typedef struct redisContext { + const redisContextFuncs *funcs; /* Function table */ + + int err; /* Error flags, 0 when there is no error */ + char errstr[128]; /* String representation of error when applicable */ + redisFD fd; + int flags; + char *obuf; /* Write buffer */ + redisReader *reader; /* Protocol reader */ + + enum redisConnectionType connection_type; + struct timeval *connect_timeout; + struct timeval *command_timeout; + + struct { + char *host; + char *source_addr; + int port; + } tcp; + + struct { + char *path; + } unix_sock; + + /* For non-blocking connect */ + struct sockaddr *saddr; + size_t addrlen; + + /* Optional data and corresponding destructor users can use to provide + * context to a given redisContext. Not used by hiredis. */ + void *privdata; + void (*free_privdata)(void *); + + /* Internal context pointer presently used by hiredis to manage + * SSL connections. */ + void *privctx; + + /* An optional RESP3 PUSH handler */ + redisPushFn *push_cb; +} redisContext; + +redisContext *redisConnectWithOptions(const redisOptions *options); +redisContext *redisConnect(const char *ip, int port); +redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv); +redisContext *redisConnectNonBlock(const char *ip, int port); +redisContext *redisConnectBindNonBlock(const char *ip, int port, + const char *source_addr); +redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port, + const char *source_addr); +redisContext *redisConnectUnix(const char *path); +redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv); +redisContext *redisConnectUnixNonBlock(const char *path); +redisContext *redisConnectFd(redisFD fd); + +/** + * Reconnect the given context using the saved information. + * + * This re-uses the exact same connect options as in the initial connection. + * host, ip (or path), timeout and bind address are reused, + * flags are used unmodified from the existing context. + * + * Returns REDIS_OK on successful connect or REDIS_ERR otherwise. + */ +int redisReconnect(redisContext *c); + +redisPushFn *redisSetPushCallback(redisContext *c, redisPushFn *fn); +int redisSetTimeout(redisContext *c, const struct timeval tv); +int redisEnableKeepAlive(redisContext *c); +void redisFree(redisContext *c); +redisFD redisFreeKeepFd(redisContext *c); +int redisBufferRead(redisContext *c); +int redisBufferWrite(redisContext *c, int *done); + +/* In a blocking context, this function first checks if there are unconsumed + * replies to return and returns one if so. Otherwise, it flushes the output + * buffer to the socket and reads until it has a reply. In a non-blocking + * context, it will return unconsumed replies until there are no more. */ +int redisGetReply(redisContext *c, void **reply); +int redisGetReplyFromReader(redisContext *c, void **reply); + +/* Write a formatted command to the output buffer. Use these functions in blocking mode + * to get a pipeline of commands. */ +int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len); + +/* Write a command to the output buffer. Use these functions in blocking mode + * to get a pipeline of commands. */ +int redisvAppendCommand(redisContext *c, const char *format, va_list ap); +int redisAppendCommand(redisContext *c, const char *format, ...); +int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen); + +/* Issue a command to Redis. In a blocking context, it is identical to calling + * redisAppendCommand, followed by redisGetReply. The function will return + * NULL if there was an error in performing the request, otherwise it will + * return the reply. In a non-blocking context, it is identical to calling + * only redisAppendCommand and will always return NULL. */ +void *redisvCommand(redisContext *c, const char *format, va_list ap); +void *redisCommand(redisContext *c, const char *format, ...); +void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/hiredis/read.h b/include/hiredis/read.h new file mode 100644 index 0000000..2d74d77 --- /dev/null +++ b/include/hiredis/read.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2009-2011, Salvatore Sanfilippo + * Copyright (c) 2010-2011, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef __HIREDIS_READ_H +#define __HIREDIS_READ_H +#include /* for size_t */ + +#define REDIS_ERR -1 +#define REDIS_OK 0 + +/* When an error occurs, the err flag in a context is set to hold the type of + * error that occurred. REDIS_ERR_IO means there was an I/O error and you + * should use the "errno" variable to find out what is wrong. + * For other values, the "errstr" field will hold a description. */ +#define REDIS_ERR_IO 1 /* Error in read or write */ +#define REDIS_ERR_EOF 3 /* End of file */ +#define REDIS_ERR_PROTOCOL 4 /* Protocol error */ +#define REDIS_ERR_OOM 5 /* Out of memory */ +#define REDIS_ERR_TIMEOUT 6 /* Timed out */ +#define REDIS_ERR_OTHER 2 /* Everything else... */ + +#define REDIS_REPLY_STRING 1 +#define REDIS_REPLY_ARRAY 2 +#define REDIS_REPLY_INTEGER 3 +#define REDIS_REPLY_NIL 4 +#define REDIS_REPLY_STATUS 5 +#define REDIS_REPLY_ERROR 6 +#define REDIS_REPLY_DOUBLE 7 +#define REDIS_REPLY_BOOL 8 +#define REDIS_REPLY_MAP 9 +#define REDIS_REPLY_SET 10 +#define REDIS_REPLY_ATTR 11 +#define REDIS_REPLY_PUSH 12 +#define REDIS_REPLY_BIGNUM 13 +#define REDIS_REPLY_VERB 14 + +/* Default max unused reader buffer. */ +#define REDIS_READER_MAX_BUF (1024*16) + +/* Default multi-bulk element limit */ +#define REDIS_READER_MAX_ARRAY_ELEMENTS ((1LL<<32) - 1) + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct redisReadTask { + int type; + long long elements; /* number of elements in multibulk container */ + int idx; /* index in parent (array) object */ + void *obj; /* holds user-generated value for a read task */ + struct redisReadTask *parent; /* parent task */ + void *privdata; /* user-settable arbitrary field */ +} redisReadTask; + +typedef struct redisReplyObjectFunctions { + void *(*createString)(const redisReadTask*, char*, size_t); + void *(*createArray)(const redisReadTask*, size_t); + void *(*createInteger)(const redisReadTask*, long long); + void *(*createDouble)(const redisReadTask*, double, char*, size_t); + void *(*createNil)(const redisReadTask*); + void *(*createBool)(const redisReadTask*, int); + void (*freeObject)(void*); +} redisReplyObjectFunctions; + +typedef struct redisReader { + int err; /* Error flags, 0 when there is no error */ + char errstr[128]; /* String representation of error when applicable */ + + char *buf; /* Read buffer */ + size_t pos; /* Buffer cursor */ + size_t len; /* Buffer length */ + size_t maxbuf; /* Max length of unused buffer */ + long long maxelements; /* Max multi-bulk elements */ + + redisReadTask **task; + int tasks; + + int ridx; /* Index of current read task */ + void *reply; /* Temporary reply pointer */ + + redisReplyObjectFunctions *fn; + void *privdata; +} redisReader; + +/* Public API for the protocol parser. */ +redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn); +void redisReaderFree(redisReader *r); +int redisReaderFeed(redisReader *r, const char *buf, size_t len); +int redisReaderGetReply(redisReader *r, void **reply); + +#define redisReaderSetPrivdata(_r, _p) (int)(((redisReader*)(_r))->privdata = (_p)) +#define redisReaderGetObject(_r) (((redisReader*)(_r))->reply) +#define redisReaderGetError(_r) (((redisReader*)(_r))->errstr) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/hiredis/sds.h b/include/hiredis/sds.h new file mode 100644 index 0000000..eda8833 --- /dev/null +++ b/include/hiredis/sds.h @@ -0,0 +1,278 @@ +/* SDSLib 2.0 -- A C dynamic strings library + * + * Copyright (c) 2006-2015, Salvatore Sanfilippo + * Copyright (c) 2015, Oran Agra + * Copyright (c) 2015, Redis Labs, Inc + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Redis nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SDS_H +#define __SDS_H + +#define SDS_MAX_PREALLOC (1024*1024) +#ifdef _MSC_VER +#define __attribute__(x) +typedef long long ssize_t; +#define SSIZE_MAX (LLONG_MAX >> 1) +#endif + +#include +#include +#include + +typedef char *sds; + +/* Note: sdshdr5 is never used, we just access the flags byte directly. + * However is here to document the layout of type 5 SDS strings. */ +struct __attribute__ ((__packed__)) sdshdr5 { + unsigned char flags; /* 3 lsb of type, and 5 msb of string length */ + char buf[]; +}; +struct __attribute__ ((__packed__)) sdshdr8 { + uint8_t len; /* used */ + uint8_t alloc; /* excluding the header and null terminator */ + unsigned char flags; /* 3 lsb of type, 5 unused bits */ + char buf[]; +}; +struct __attribute__ ((__packed__)) sdshdr16 { + uint16_t len; /* used */ + uint16_t alloc; /* excluding the header and null terminator */ + unsigned char flags; /* 3 lsb of type, 5 unused bits */ + char buf[]; +}; +struct __attribute__ ((__packed__)) sdshdr32 { + uint32_t len; /* used */ + uint32_t alloc; /* excluding the header and null terminator */ + unsigned char flags; /* 3 lsb of type, 5 unused bits */ + char buf[]; +}; +struct __attribute__ ((__packed__)) sdshdr64 { + uint64_t len; /* used */ + uint64_t alloc; /* excluding the header and null terminator */ + unsigned char flags; /* 3 lsb of type, 5 unused bits */ + char buf[]; +}; + +#define SDS_TYPE_5 0 +#define SDS_TYPE_8 1 +#define SDS_TYPE_16 2 +#define SDS_TYPE_32 3 +#define SDS_TYPE_64 4 +#define SDS_TYPE_MASK 7 +#define SDS_TYPE_BITS 3 +#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T))); +#define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T)))) +#define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS) + +static inline size_t sdslen(const sds s) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: + return SDS_TYPE_5_LEN(flags); + case SDS_TYPE_8: + return SDS_HDR(8,s)->len; + case SDS_TYPE_16: + return SDS_HDR(16,s)->len; + case SDS_TYPE_32: + return SDS_HDR(32,s)->len; + case SDS_TYPE_64: + return SDS_HDR(64,s)->len; + } + return 0; +} + +static inline size_t sdsavail(const sds s) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: { + return 0; + } + case SDS_TYPE_8: { + SDS_HDR_VAR(8,s); + return sh->alloc - sh->len; + } + case SDS_TYPE_16: { + SDS_HDR_VAR(16,s); + return sh->alloc - sh->len; + } + case SDS_TYPE_32: { + SDS_HDR_VAR(32,s); + return sh->alloc - sh->len; + } + case SDS_TYPE_64: { + SDS_HDR_VAR(64,s); + return sh->alloc - sh->len; + } + } + return 0; +} + +static inline void sdssetlen(sds s, size_t newlen) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: + { + unsigned char *fp = ((unsigned char*)s)-1; + *fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS)); + } + break; + case SDS_TYPE_8: + SDS_HDR(8,s)->len = (uint8_t)newlen; + break; + case SDS_TYPE_16: + SDS_HDR(16,s)->len = (uint16_t)newlen; + break; + case SDS_TYPE_32: + SDS_HDR(32,s)->len = (uint32_t)newlen; + break; + case SDS_TYPE_64: + SDS_HDR(64,s)->len = (uint64_t)newlen; + break; + } +} + +static inline void sdsinclen(sds s, size_t inc) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: + { + unsigned char *fp = ((unsigned char*)s)-1; + unsigned char newlen = SDS_TYPE_5_LEN(flags)+(unsigned char)inc; + *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); + } + break; + case SDS_TYPE_8: + SDS_HDR(8,s)->len += (uint8_t)inc; + break; + case SDS_TYPE_16: + SDS_HDR(16,s)->len += (uint16_t)inc; + break; + case SDS_TYPE_32: + SDS_HDR(32,s)->len += (uint32_t)inc; + break; + case SDS_TYPE_64: + SDS_HDR(64,s)->len += (uint64_t)inc; + break; + } +} + +/* sdsalloc() = sdsavail() + sdslen() */ +static inline size_t sdsalloc(const sds s) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: + return SDS_TYPE_5_LEN(flags); + case SDS_TYPE_8: + return SDS_HDR(8,s)->alloc; + case SDS_TYPE_16: + return SDS_HDR(16,s)->alloc; + case SDS_TYPE_32: + return SDS_HDR(32,s)->alloc; + case SDS_TYPE_64: + return SDS_HDR(64,s)->alloc; + } + return 0; +} + +static inline void sdssetalloc(sds s, size_t newlen) { + unsigned char flags = s[-1]; + switch(flags&SDS_TYPE_MASK) { + case SDS_TYPE_5: + /* Nothing to do, this type has no total allocation info. */ + break; + case SDS_TYPE_8: + SDS_HDR(8,s)->alloc = (uint8_t)newlen; + break; + case SDS_TYPE_16: + SDS_HDR(16,s)->alloc = (uint16_t)newlen; + break; + case SDS_TYPE_32: + SDS_HDR(32,s)->alloc = (uint32_t)newlen; + break; + case SDS_TYPE_64: + SDS_HDR(64,s)->alloc = (uint64_t)newlen; + break; + } +} + +sds sdsnewlen(const void *init, size_t initlen); +sds sdsnew(const char *init); +sds sdsempty(void); +sds sdsdup(const sds s); +void sdsfree(sds s); +sds sdsgrowzero(sds s, size_t len); +sds sdscatlen(sds s, const void *t, size_t len); +sds sdscat(sds s, const char *t); +sds sdscatsds(sds s, const sds t); +sds sdscpylen(sds s, const char *t, size_t len); +sds sdscpy(sds s, const char *t); + +sds sdscatvprintf(sds s, const char *fmt, va_list ap); +#ifdef __GNUC__ +sds sdscatprintf(sds s, const char *fmt, ...) + __attribute__((format(printf, 2, 3))); +#else +sds sdscatprintf(sds s, const char *fmt, ...); +#endif + +sds sdscatfmt(sds s, char const *fmt, ...); +sds sdstrim(sds s, const char *cset); +int sdsrange(sds s, ssize_t start, ssize_t end); +void sdsupdatelen(sds s); +void sdsclear(sds s); +int sdscmp(const sds s1, const sds s2); +sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count); +void sdsfreesplitres(sds *tokens, int count); +void sdstolower(sds s); +void sdstoupper(sds s); +sds sdsfromlonglong(long long value); +sds sdscatrepr(sds s, const char *p, size_t len); +sds *sdssplitargs(const char *line, int *argc); +sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen); +sds sdsjoin(char **argv, int argc, char *sep); +sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen); + +/* Low level functions exposed to the user API */ +sds sdsMakeRoomFor(sds s, size_t addlen); +void sdsIncrLen(sds s, int incr); +sds sdsRemoveFreeSpace(sds s); +size_t sdsAllocSize(sds s); +void *sdsAllocPtr(sds s); + +/* Export the allocator used by SDS to the program using SDS. + * Sometimes the program SDS is linked to, may use a different set of + * allocators, but may want to allocate or free things that SDS will + * respectively free or allocate. */ +void *sds_malloc(size_t size); +void *sds_realloc(void *ptr, size_t size); +void sds_free(void *ptr); + +#ifdef REDIS_TEST +int sdsTest(int argc, char *argv[]); +#endif + +#endif diff --git a/include/nettle/aes.h b/include/nettle/aes.h new file mode 100644 index 0000000..5a0545c --- /dev/null +++ b/include/nettle/aes.h @@ -0,0 +1,177 @@ +/* aes.h + + The aes/rijndael block cipher. + + Copyright (C) 2001, 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_AES_H_INCLUDED +#define NETTLE_AES_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define aes_set_encrypt_key nettle_aes_set_encrypt_key +#define aes_set_decrypt_key nettle_aes_set_decrypt_key +#define aes_invert_key nettle_aes_invert_key +#define aes_encrypt nettle_aes_encrypt +#define aes_decrypt nettle_aes_decrypt +#define aes128_set_encrypt_key nettle_aes128_set_encrypt_key +#define aes128_set_decrypt_key nettle_aes128_set_decrypt_key +#define aes128_invert_key nettle_aes128_invert_key +#define aes128_encrypt nettle_aes128_encrypt +#define aes128_decrypt nettle_aes128_decrypt +#define aes192_set_encrypt_key nettle_aes192_set_encrypt_key +#define aes192_set_decrypt_key nettle_aes192_set_decrypt_key +#define aes192_invert_key nettle_aes192_invert_key +#define aes192_encrypt nettle_aes192_encrypt +#define aes192_decrypt nettle_aes192_decrypt +#define aes256_set_encrypt_key nettle_aes256_set_encrypt_key +#define aes256_set_decrypt_key nettle_aes256_set_decrypt_key +#define aes256_invert_key nettle_aes256_invert_key +#define aes256_encrypt nettle_aes256_encrypt +#define aes256_decrypt nettle_aes256_decrypt + +#define AES_BLOCK_SIZE 16 + +#define AES128_KEY_SIZE 16 +#define AES192_KEY_SIZE 24 +#define AES256_KEY_SIZE 32 +#define _AES128_ROUNDS 10 +#define _AES192_ROUNDS 12 +#define _AES256_ROUNDS 14 + +/* Variable key size between 128 and 256 bits. But the only valid + * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */ +#define AES_MIN_KEY_SIZE AES128_KEY_SIZE +#define AES_MAX_KEY_SIZE AES256_KEY_SIZE + +/* Older nettle-2.7 interface */ + +#define AES_KEY_SIZE 32 + +struct aes_ctx +{ + unsigned rounds; /* number of rounds to use for our key size */ + uint32_t keys[4*(_AES256_ROUNDS + 1)]; /* maximum size of key schedule */ +}; + +void +aes_set_encrypt_key(struct aes_ctx *ctx, + size_t length, const uint8_t *key); + +void +aes_set_decrypt_key(struct aes_ctx *ctx, + size_t length, const uint8_t *key); + +void +aes_invert_key(struct aes_ctx *dst, + const struct aes_ctx *src); + +void +aes_encrypt(const struct aes_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +aes_decrypt(const struct aes_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +struct aes128_ctx +{ + uint32_t keys[4 * (_AES128_ROUNDS + 1)]; +}; + +void +aes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key); +void +aes128_set_decrypt_key(struct aes128_ctx *ctx, const uint8_t *key); +void +aes128_invert_key(struct aes128_ctx *dst, + const struct aes128_ctx *src); +void +aes128_encrypt(const struct aes128_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +aes128_decrypt(const struct aes128_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +struct aes192_ctx +{ + uint32_t keys[4 * (_AES192_ROUNDS + 1)]; +}; + +void +aes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key); +void +aes192_set_decrypt_key(struct aes192_ctx *ctx, const uint8_t *key); +void +aes192_invert_key(struct aes192_ctx *dst, + const struct aes192_ctx *src); +void +aes192_encrypt(const struct aes192_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +aes192_decrypt(const struct aes192_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +struct aes256_ctx +{ + uint32_t keys[4 * (_AES256_ROUNDS + 1)]; +}; + +void +aes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key); +void +aes256_set_decrypt_key(struct aes256_ctx *ctx, const uint8_t *key); +void +aes256_invert_key(struct aes256_ctx *dst, + const struct aes256_ctx *src); +void +aes256_encrypt(const struct aes256_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +aes256_decrypt(const struct aes256_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_AES_H_INCLUDED */ diff --git a/include/nettle/arcfour.h b/include/nettle/arcfour.h new file mode 100644 index 0000000..804b9e4 --- /dev/null +++ b/include/nettle/arcfour.h @@ -0,0 +1,79 @@ +/* arcfour.h + + The arcfour/rc4 stream cipher. + + Copyright (C) 2001, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_ARCFOUR_H_INCLUDED +#define NETTLE_ARCFOUR_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define arcfour128_set_key nettle_arcfour128_set_key +#define arcfour_set_key nettle_arcfour_set_key +#define arcfour_crypt nettle_arcfour_crypt + +/* Minimum and maximum keysizes, and a reasonable default. In + * octets.*/ +#define ARCFOUR_MIN_KEY_SIZE 1 +#define ARCFOUR_MAX_KEY_SIZE 256 +#define ARCFOUR_KEY_SIZE 16 +#define ARCFOUR128_KEY_SIZE 16 + +struct arcfour_ctx +{ + uint8_t S[256]; + uint8_t i; + uint8_t j; +}; + +void +arcfour_set_key(struct arcfour_ctx *ctx, + size_t length, const uint8_t *key); + +void +arcfour128_set_key(struct arcfour_ctx *ctx, const uint8_t *key); + +void +arcfour_crypt(struct arcfour_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ARCFOUR_H_INCLUDED */ + diff --git a/include/nettle/arctwo.h b/include/nettle/arctwo.h new file mode 100644 index 0000000..1a9b8b3 --- /dev/null +++ b/include/nettle/arctwo.h @@ -0,0 +1,103 @@ +/* arctwo.h + + The arctwo/rfc2268 block cipher. + + Copyright (C) 2004 Simon Josefsson + Copyright (C) 2002, 2004, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_ARCTWO_H_INCLUDED +#define NETTLE_ARCTWO_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define arctwo_set_key nettle_arctwo_set_key +#define arctwo_set_key_ekb nettle_arctwo_set_key_ekb +#define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann +#define arctwo40_set_key nettle_arctwo40_set_key +#define arctwo64_set_key nettle_arctwo64_set_key +#define arctwo128_set_key nettle_arctwo128_set_key +#define arctwo128_set_key_gutmann nettle_arctwo128_set_key_gutmann +#define arctwo_encrypt nettle_arctwo_encrypt +#define arctwo_decrypt nettle_arctwo_decrypt + +#define ARCTWO_BLOCK_SIZE 8 + +/* Variable key size from 1 byte to 128 bytes. */ +#define ARCTWO_MIN_KEY_SIZE 1 +#define ARCTWO_MAX_KEY_SIZE 128 + +#define ARCTWO_KEY_SIZE 8 + +struct arctwo_ctx +{ + uint16_t S[64]; +}; + +/* Key expansion function that takes the "effective key bits", 1-1024, + as an explicit argument. 0 means maximum key bits. */ +void +arctwo_set_key_ekb (struct arctwo_ctx *ctx, + size_t length, const uint8_t * key, unsigned ekb); + +/* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */ +void +arctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key); +void +arctwo40_set_key (struct arctwo_ctx *ctx, const uint8_t *key); +void +arctwo64_set_key (struct arctwo_ctx *ctx, const uint8_t *key); +void +arctwo128_set_key (struct arctwo_ctx *ctx, const uint8_t *key); + +/* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */ +void +arctwo_set_key_gutmann (struct arctwo_ctx *ctx, + size_t length, const uint8_t *key); +void +arctwo128_set_key_gutmann (struct arctwo_ctx *ctx, + const uint8_t *key); + +void +arctwo_encrypt (struct arctwo_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); +void +arctwo_decrypt (struct arctwo_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ARCTWO_H_INCLUDED */ diff --git a/include/nettle/asn1.h b/include/nettle/asn1.h new file mode 100644 index 0000000..da2fbe5 --- /dev/null +++ b/include/nettle/asn1.h @@ -0,0 +1,152 @@ +/* asn1.h + + Limited support for ASN.1 DER decoding. + + Copyright (C) 2005 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_ASN1_H_INCLUDED +#define NETTLE_ASN1_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define asn1_der_iterator_first nettle_asn1_der_iterator_first +#define asn1_der_iterator_next nettle_asn1_der_iterator_next +#define asn1_der_decode_constructed nettle_asn1_der_decode_constructed +#define asn1_der_decode_constructed_last nettle_asn1_der_decode_constructed_last +#define asn1_der_decode_bitstring nettle_asn1_der_decode_bitstring +#define asn1_der_decode_bitstring_last nettle_asn1_der_decode_bitstring_last +#define asn1_der_get_uint32 nettle_asn1_der_get_uint32 +#define asn1_der_get_bignum nettle_asn1_der_get_bignum + + +/* enum asn1_type keeps the class number and the constructive in bits + 13-14, and the constructive flag in bit 12. The remaining 14 bits + are the tag (although currently, only tags in the range 0-30 are + supported). */ + +enum + { + ASN1_TYPE_CONSTRUCTED = 1 << 12, + + ASN1_CLASS_UNIVERSAL = 0, + ASN1_CLASS_APPLICATION = 1 << 13, + ASN1_CLASS_CONTEXT_SPECIFIC = 2 << 13, + ASN1_CLASS_PRIVATE = 3 << 13, + + ASN1_CLASS_MASK = 3 << 13, + ASN1_CLASS_SHIFT = 13, + }; + +enum asn1_type + { + ASN1_BOOLEAN = 1, + ASN1_INTEGER = 2, + ASN1_BITSTRING = 3, + ASN1_OCTETSTRING = 4, + ASN1_NULL = 5, + ASN1_IDENTIFIER = 6, + ASN1_REAL = 9, + ASN1_ENUMERATED = 10, + ASN1_UTF8STRING = 12, + ASN1_SEQUENCE = 16 | ASN1_TYPE_CONSTRUCTED, + ASN1_SET = 17 | ASN1_TYPE_CONSTRUCTED, + ASN1_PRINTABLESTRING = 19, + ASN1_TELETEXSTRING = 20, + ASN1_IA5STRING = 22, + ASN1_UTC = 23, + ASN1_UNIVERSALSTRING = 28, + ASN1_BMPSTRING = 30, + }; + +enum asn1_iterator_result + { + ASN1_ITERATOR_ERROR, + ASN1_ITERATOR_PRIMITIVE, + ASN1_ITERATOR_CONSTRUCTED, + ASN1_ITERATOR_END, + }; + +/* Parsing DER objects. */ +struct asn1_der_iterator +{ + size_t buffer_length; + const uint8_t *buffer; + + /* Next object to parse. */ + size_t pos; + + enum asn1_type type; + + /* Pointer to the current object */ + size_t length; + const uint8_t *data; +}; + +/* Initializes the iterator. */ +enum asn1_iterator_result +asn1_der_iterator_first(struct asn1_der_iterator *iterator, + size_t length, const uint8_t *input); + +enum asn1_iterator_result +asn1_der_iterator_next(struct asn1_der_iterator *iterator); + +/* Starts parsing of a constructed object. */ +enum asn1_iterator_result +asn1_der_decode_constructed(struct asn1_der_iterator *i, + struct asn1_der_iterator *contents); + +/* For the common case that we have a sequence at the end of the + object. Checks that the current object is the final one, and then + reinitializes the iterator to parse its ontents. */ +enum asn1_iterator_result +asn1_der_decode_constructed_last(struct asn1_der_iterator *i); + +enum asn1_iterator_result +asn1_der_decode_bitstring(struct asn1_der_iterator *i, + struct asn1_der_iterator *contents); + +enum asn1_iterator_result +asn1_der_decode_bitstring_last(struct asn1_der_iterator *i); + +/* All these functions return 1 on success, 0 on failure */ +int +asn1_der_get_uint32(struct asn1_der_iterator *i, + uint32_t *x); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ASN1_H_INCLUDED */ diff --git a/include/nettle/base16.h b/include/nettle/base16.h new file mode 100644 index 0000000..755e6ed --- /dev/null +++ b/include/nettle/base16.h @@ -0,0 +1,110 @@ +/* base16.h + + Hex encoding and decoding, following spki conventions (i.e. + allowing whitespace between digits). + + Copyright (C) 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_BASE16_H_INCLUDED +#define NETTLE_BASE16_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define base16_encode_single nettle_base16_encode_single +#define base16_encode_update nettle_base16_encode_update +#define base16_decode_init nettle_base16_decode_init +#define base16_decode_single nettle_base16_decode_single +#define base16_decode_update nettle_base16_decode_update +#define base16_decode_final nettle_base16_decode_final + +/* Base16 encoding */ + +/* Maximum length of output for base16_encode_update. */ +#define BASE16_ENCODE_LENGTH(length) ((length) * 2) + +/* Encodes a single byte. Always stores two digits in dst[0] and dst[1]. */ +void +base16_encode_single(char *dst, + uint8_t src); + +/* Always stores BASE16_ENCODE_LENGTH(length) digits in dst. */ +void +base16_encode_update(char *dst, + size_t length, + const uint8_t *src); + + +/* Base16 decoding */ + +/* Maximum length of output for base16_decode_update. */ +/* We have at most 4 buffered bits, and a total of (length + 1) * 4 bits. */ +#define BASE16_DECODE_LENGTH(length) (((length) + 1) / 2) + +struct base16_decode_ctx +{ + unsigned char word; /* Leftover bits */ + unsigned char bits; /* Number buffered bits */ +}; + +void +base16_decode_init(struct base16_decode_ctx *ctx); + +/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on + * errors. */ +int +base16_decode_single(struct base16_decode_ctx *ctx, + uint8_t *dst, + char src); + +/* Returns 1 on success, 0 on error. DST should point to an area of + * size at least BASE16_DECODE_LENGTH(length). The amount of data + * generated is returned in *DST_LENGTH. */ + +int +base16_decode_update(struct base16_decode_ctx *ctx, + size_t *dst_length, + uint8_t *dst, + size_t src_length, + const char *src); + +/* Returns 1 on success. */ +int +base16_decode_final(struct base16_decode_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_BASE16_H_INCLUDED */ diff --git a/include/nettle/base64.h b/include/nettle/base64.h new file mode 100644 index 0000000..8e69adb --- /dev/null +++ b/include/nettle/base64.h @@ -0,0 +1,172 @@ +/* base64.h + + Base-64 encoding and decoding. + + Copyright (C) 2002 Niels M枚ller, Dan Egnor + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_BASE64_H_INCLUDED +#define NETTLE_BASE64_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define base64_encode_init nettle_base64_encode_init +#define base64url_encode_init nettle_base64url_encode_init +#define base64_encode_single nettle_base64_encode_single +#define base64_encode_update nettle_base64_encode_update +#define base64_encode_final nettle_base64_encode_final +#define base64_encode_raw nettle_base64_encode_raw +#define base64_encode_group nettle_base64_encode_group +#define base64_decode_init nettle_base64_decode_init +#define base64url_decode_init nettle_base64url_decode_init +#define base64_decode_single nettle_base64_decode_single +#define base64_decode_update nettle_base64_decode_update +#define base64_decode_final nettle_base64_decode_final + +#define BASE64_BINARY_BLOCK_SIZE 3 +#define BASE64_TEXT_BLOCK_SIZE 4 + +/* Base64 encoding */ + +/* Maximum length of output for base64_encode_update. NOTE: Doesn't + * include any padding that base64_encode_final may add. */ +/* We have at most 4 buffered bits, and a total of (4 + length * 8) bits. */ +#define BASE64_ENCODE_LENGTH(length) (((length) * 8 + 4)/6) + +/* Maximum length of output generated by base64_encode_final. */ +#define BASE64_ENCODE_FINAL_LENGTH 3 + +/* Exact length of output generated by base64_encode_raw, including + * padding. */ +#define BASE64_ENCODE_RAW_LENGTH(length) ((((length) + 2)/3)*4) + +struct base64_encode_ctx +{ + const char *alphabet; /* Alphabet to use for encoding */ + unsigned short word; /* Leftover bits */ + unsigned char bits; /* Number of bits, always 0, 2, or 4. */ +}; + +/* Initialize encoding context for base-64 */ +void +base64_encode_init(struct base64_encode_ctx *ctx); + +/* Initialize encoding context for URL safe alphabet, RFC 4648. */ +void +base64url_encode_init(struct base64_encode_ctx *ctx); + +/* Encodes a single byte. Returns amount of output (always 1 or 2). */ +size_t +base64_encode_single(struct base64_encode_ctx *ctx, + char *dst, + uint8_t src); + +/* Returns the number of output characters. DST should point to an + * area of size at least BASE64_ENCODE_LENGTH(length). */ +size_t +base64_encode_update(struct base64_encode_ctx *ctx, + char *dst, + size_t length, + const uint8_t *src); + +/* DST should point to an area of size at least + * BASE64_ENCODE_FINAL_LENGTH */ +size_t +base64_encode_final(struct base64_encode_ctx *ctx, + char *dst); + +/* Lower level functions */ + +/* Encodes a string in one go, including any padding at the end. + * Generates exactly BASE64_ENCODE_RAW_LENGTH(length) bytes of output. + * Supports overlapped operation, if src <= dst. FIXME: Use of overlap + * is deprecated, if needed there should be a separate public fucntion + * to do that.*/ +void +base64_encode_raw(char *dst, size_t length, const uint8_t *src); + +void +base64_encode_group(char *dst, uint32_t group); + + +/* Base64 decoding */ + +/* Maximum length of output for base64_decode_update. */ +/* We have at most 6 buffered bits, and a total of (length + 1) * 6 bits. */ +#define BASE64_DECODE_LENGTH(length) ((((length) + 1) * 6) / 8) + +struct base64_decode_ctx +{ + const signed char *table; /* Decoding table */ + unsigned short word; /* Leftover bits */ + unsigned char bits; /* Number buffered bits */ + + /* Number of padding characters encountered */ + unsigned char padding; +}; + +/* Initialize decoding context for base-64 */ +void +base64_decode_init(struct base64_decode_ctx *ctx); + +/* Initialize encoding context for URL safe alphabet, RFC 4648. */ +void +base64url_decode_init(struct base64_decode_ctx *ctx); + +/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on + * errors. */ +int +base64_decode_single(struct base64_decode_ctx *ctx, + uint8_t *dst, + char src); + +/* Returns 1 on success, 0 on error. DST should point to an area of + * size at least BASE64_DECODE_LENGTH(length). The amount of data + * generated is returned in *DST_LENGTH. */ +int +base64_decode_update(struct base64_decode_ctx *ctx, + size_t *dst_length, + uint8_t *dst, + size_t src_length, + const char *src); + +/* Returns 1 on success. */ +int +base64_decode_final(struct base64_decode_ctx *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_BASE64_H_INCLUDED */ diff --git a/include/nettle/bignum.h b/include/nettle/bignum.h new file mode 100644 index 0000000..9afcd29 --- /dev/null +++ b/include/nettle/bignum.h @@ -0,0 +1,140 @@ +/* bignum.h + + Bignum operations that are missing from gmp. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_BIGNUM_H_INCLUDED +#define NETTLE_BIGNUM_H_INCLUDED + +#include "nettle-meta.h" + +#include "nettle-types.h" + +/* For NETTLE_USE_MINI_GMP */ +#include "version.h" + +#if NETTLE_USE_MINI_GMP +# include "mini-gmp.h" + +# define GMP_NUMB_MASK (~(mp_limb_t) 0) + +/* Function missing in older gmp versions, and checked for with ifdef */ +# define mpz_limbs_read mpz_limbs_read +/* Side-channel silent powm not available in mini-gmp. */ +# define mpz_powm_sec mpz_powm +#else +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Size needed for signed encoding, including extra sign byte if + * necessary. */ +size_t +nettle_mpz_sizeinbase_256_s(const mpz_t x); + +/* Size needed for unsigned encoding */ +size_t +nettle_mpz_sizeinbase_256_u(const mpz_t x); + +/* Writes an integer as length octets, using big endian byte order, + * and two's complement for negative numbers. */ +void +nettle_mpz_get_str_256(size_t length, uint8_t *s, const mpz_t x); + +/* Reads a big endian, two's complement, integer. */ +void +nettle_mpz_set_str_256_s(mpz_t x, + size_t length, const uint8_t *s); + +void +nettle_mpz_init_set_str_256_s(mpz_t x, + size_t length, const uint8_t *s); + +/* Similar, but for unsigned format. These function don't interpret + * the most significant bit as the sign. */ +void +nettle_mpz_set_str_256_u(mpz_t x, + size_t length, const uint8_t *s); + +void +nettle_mpz_init_set_str_256_u(mpz_t x, + size_t length, const uint8_t *s); + +/* Returns a uniformly distributed random number 0 <= x < 2^n */ +void +nettle_mpz_random_size(mpz_t x, + void *ctx, nettle_random_func *random, + unsigned bits); + +/* Returns a number x, almost uniformly random in the range + * 0 <= x < n. */ +void +nettle_mpz_random(mpz_t x, + void *ctx, nettle_random_func *random, + const mpz_t n); + +void +nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set, + void *ctx, nettle_random_func *random, + void *progress_ctx, nettle_progress_func *progress); + +void +_nettle_generate_pocklington_prime (mpz_t p, mpz_t r, + unsigned bits, int top_bits_set, + void *ctx, nettle_random_func *random, + const mpz_t p0, + const mpz_t q, + const mpz_t p0q); + +/* sexp parsing */ +struct sexp_iterator; + +/* If LIMIT is non-zero, the number must be at most LIMIT bits. + * Implies sexp_iterator_next. */ +int +nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i); + + +/* der parsing */ +struct asn1_der_iterator; + +int +nettle_asn1_der_get_bignum(struct asn1_der_iterator *iterator, + mpz_t x, unsigned max_bits); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_BIGNUM_H_INCLUDED */ diff --git a/include/nettle/blowfish.h b/include/nettle/blowfish.h new file mode 100644 index 0000000..bcdc7cb --- /dev/null +++ b/include/nettle/blowfish.h @@ -0,0 +1,89 @@ +/* blowfish.h + + Blowfish block cipher. + + Copyright (C) 2014 Niels M枚ller + Copyright (C) 1998, 2001 FSF, Ray Dassen, Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_BLOWFISH_H_INCLUDED +#define NETTLE_BLOWFISH_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define blowfish_set_key nettle_blowfish_set_key +#define blowfish128_set_key nettle_blowfish128_set_key +#define blowfish_encrypt nettle_blowfish_encrypt +#define blowfish_decrypt nettle_blowfish_decrypt + +#define BLOWFISH_BLOCK_SIZE 8 + +/* Variable key size between 64 and 448 bits. */ +#define BLOWFISH_MIN_KEY_SIZE 8 +#define BLOWFISH_MAX_KEY_SIZE 56 + +/* Default to 128 bits */ +#define BLOWFISH_KEY_SIZE 16 + +#define BLOWFISH128_KEY_SIZE 16 + +#define _BLOWFISH_ROUNDS 16 + +struct blowfish_ctx +{ + uint32_t s[4][256]; + uint32_t p[_BLOWFISH_ROUNDS+2]; +}; + +/* Returns 0 for weak keys, otherwise 1. */ +int +blowfish_set_key(struct blowfish_ctx *ctx, + size_t length, const uint8_t *key); +int +blowfish128_set_key(struct blowfish_ctx *ctx, const uint8_t *key); + +void +blowfish_encrypt(const struct blowfish_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +blowfish_decrypt(const struct blowfish_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_BLOWFISH_H_INCLUDED */ diff --git a/include/nettle/buffer.h b/include/nettle/buffer.h new file mode 100644 index 0000000..9cbcfb1 --- /dev/null +++ b/include/nettle/buffer.h @@ -0,0 +1,106 @@ +/* buffer.h + + A bare-bones string stream. + + Copyright (C) 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_BUFFER_H_INCLUDED +#define NETTLE_BUFFER_H_INCLUDED + +#include "realloc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct nettle_buffer +{ + uint8_t *contents; + /* Allocated size */ + size_t alloc; + + void *realloc_ctx; + nettle_realloc_func *realloc; + + /* Current size */ + size_t size; +}; + +/* Initializes a buffer that uses plain realloc */ +void +nettle_buffer_init(struct nettle_buffer *buffer); + +void +nettle_buffer_init_realloc(struct nettle_buffer *buffer, + void *realloc_ctx, + nettle_realloc_func *realloc); + +/* Initializes a buffer of fix size */ +void +nettle_buffer_init_size(struct nettle_buffer *buffer, + size_t length, uint8_t *space); + +void +nettle_buffer_clear(struct nettle_buffer *buffer); + +/* Resets the buffer, without freeing the buffer space. */ +void +nettle_buffer_reset(struct nettle_buffer *buffer); + +int +nettle_buffer_grow(struct nettle_buffer *buffer, + size_t length); + +#define NETTLE_BUFFER_PUTC(buffer, c) \ +( (((buffer)->size < (buffer)->alloc) || nettle_buffer_grow((buffer), 1)) \ + && ((buffer)->contents[(buffer)->size++] = (c), 1) ) + +int +nettle_buffer_write(struct nettle_buffer *buffer, + size_t length, const uint8_t *data); + +/* Like nettle_buffer_write, but instead of copying data to the + * buffer, it returns a pointer to the area where the caller can copy + * the data. The pointer is valid only until the next call that can + * reallocate the buffer. */ +uint8_t * +nettle_buffer_space(struct nettle_buffer *buffer, + size_t length); + +/* Copy the contents of SRC to the end of DST. */ +int +nettle_buffer_copy(struct nettle_buffer *dst, + const struct nettle_buffer *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_BUFFER_H_INCLUDED */ diff --git a/include/nettle/camellia.h b/include/nettle/camellia.h new file mode 100644 index 0000000..b035db3 --- /dev/null +++ b/include/nettle/camellia.h @@ -0,0 +1,143 @@ +/* camellia.h + + Copyright (C) 2006,2007 NTT + (Nippon Telegraph and Telephone Corporation). + + Copyright (C) 2010, 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CAMELLIA_H_INCLUDED +#define NETTLE_CAMELLIA_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define camellia128_set_encrypt_key nettle_camellia128_set_encrypt_key +#define camellia128_set_decrypt_key nettle_camellia_set_decrypt_key +#define camellia128_invert_key nettle_camellia128_invert_key +#define camellia128_crypt nettle_camellia128_crypt + +#define camellia192_set_encrypt_key nettle_camellia192_set_encrypt_key +#define camellia192_set_decrypt_key nettle_camellia192_set_decrypt_key + +#define camellia256_set_encrypt_key nettle_camellia256_set_encrypt_key +#define camellia256_set_decrypt_key nettle_camellia256_set_decrypt_key +#define camellia256_invert_key nettle_camellia256_invert_key +#define camellia256_crypt nettle_camellia256_crypt + + +#define CAMELLIA_BLOCK_SIZE 16 +/* Valid key sizes are 128, 192 or 256 bits (16, 24 or 32 bytes) */ +#define CAMELLIA128_KEY_SIZE 16 +#define CAMELLIA192_KEY_SIZE 24 +#define CAMELLIA256_KEY_SIZE 32 + +/* For 128-bit keys, there are 18 regular rounds, pre- and + post-whitening, and two FL and FLINV rounds, using a total of 26 + subkeys, each of 64 bit. For 192- and 256-bit keys, there are 6 + additional regular rounds and one additional FL and FLINV, using a + total of 34 subkeys. */ +/* The clever combination of subkeys imply one of the pre- and + post-whitening keys is folded with the round keys, so that subkey + #1 and the last one (#25 or #33) is not used. The result is that we + have only 24 or 32 subkeys at the end of key setup. */ + +#define _CAMELLIA128_NKEYS 24 +#define _CAMELLIA256_NKEYS 32 + +struct camellia128_ctx +{ + uint64_t keys[_CAMELLIA128_NKEYS]; +}; + +void +camellia128_set_encrypt_key(struct camellia128_ctx *ctx, + const uint8_t *key); + +void +camellia128_set_decrypt_key(struct camellia128_ctx *ctx, + const uint8_t *key); + +void +camellia128_invert_key(struct camellia128_ctx *dst, + const struct camellia128_ctx *src); + +void +camellia128_crypt(const struct camellia128_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +struct camellia256_ctx +{ + uint64_t keys[_CAMELLIA256_NKEYS]; +}; + +void +camellia256_set_encrypt_key(struct camellia256_ctx *ctx, + const uint8_t *key); + +void +camellia256_set_decrypt_key(struct camellia256_ctx *ctx, + const uint8_t *key); + +void +camellia256_invert_key(struct camellia256_ctx *dst, + const struct camellia256_ctx *src); + +void +camellia256_crypt(const struct camellia256_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +/* camellia192 is the same as camellia256, except for the key + schedule. */ +/* Slightly ugly with a #define on a struct tag, since it might cause + surprises if also used as a name of a variable. */ +#define camellia192_ctx camellia256_ctx + +void +camellia192_set_encrypt_key(struct camellia256_ctx *ctx, + const uint8_t *key); + +void +camellia192_set_decrypt_key(struct camellia256_ctx *ctx, + const uint8_t *key); + +#define camellia192_invert_key camellia256_invert_key +#define camellia192_crypt camellia256_crypt + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CAMELLIA_H_INCLUDED */ diff --git a/include/nettle/cast128.h b/include/nettle/cast128.h new file mode 100644 index 0000000..9d099ec --- /dev/null +++ b/include/nettle/cast128.h @@ -0,0 +1,86 @@ +/* cast128.h + + The CAST-128 block cipher. + + Copyright (C) 2001, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CAST128_H_INCLUDED +#define NETTLE_CAST128_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define cast5_set_key nettle_cast5_set_key +#define cast128_set_key nettle_cast128_set_key +#define cast128_encrypt nettle_cast128_encrypt +#define cast128_decrypt nettle_cast128_decrypt + +#define CAST128_BLOCK_SIZE 8 + +/* Variable key size between 40 and 128. */ +#define CAST5_MIN_KEY_SIZE 5 +#define CAST5_MAX_KEY_SIZE 16 + +#define CAST128_KEY_SIZE 16 + +struct cast128_ctx +{ + unsigned rounds; /* Number of rounds to use, 12 or 16 */ + /* Expanded key, rotations (5 bits only) and 32-bit masks. */ + unsigned char Kr[16]; + uint32_t Km[16]; +}; + +/* Using variable key size. */ +void +cast5_set_key(struct cast128_ctx *ctx, + size_t length, const uint8_t *key); + +void +cast128_set_key(struct cast128_ctx *ctx, const uint8_t *key); + +void +cast128_encrypt(const struct cast128_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +cast128_decrypt(const struct cast128_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CAST128_H_INCLUDED */ diff --git a/include/nettle/cbc.h b/include/nettle/cbc.h new file mode 100644 index 0000000..93b2e73 --- /dev/null +++ b/include/nettle/cbc.h @@ -0,0 +1,86 @@ +/* cbc.h + + Cipher block chaining mode. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CBC_H_INCLUDED +#define NETTLE_CBC_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define cbc_encrypt nettle_cbc_encrypt +#define cbc_decrypt nettle_cbc_decrypt + +void +cbc_encrypt(const void *ctx, nettle_cipher_func *f, + size_t block_size, uint8_t *iv, + size_t length, uint8_t *dst, + const uint8_t *src); + +void +cbc_decrypt(const void *ctx, nettle_cipher_func *f, + size_t block_size, uint8_t *iv, + size_t length, uint8_t *dst, + const uint8_t *src); + +#define CBC_CTX(type, size) \ +{ type ctx; uint8_t iv[size]; } + +#define CBC_SET_IV(ctx, data) \ +memcpy((ctx)->iv, (data), sizeof((ctx)->iv)) + +/* NOTE: Avoid using NULL, as we don't include anything defining it. */ +#define CBC_ENCRYPT(self, f, length, dst, src) \ + (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0)) \ + : cbc_encrypt((void *) &(self)->ctx, \ + (nettle_cipher_func *) (f), \ + sizeof((self)->iv), (self)->iv, \ + (length), (dst), (src))) + +#define CBC_DECRYPT(self, f, length, dst, src) \ + (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0)) \ + : cbc_decrypt((void *) &(self)->ctx, \ + (nettle_cipher_func *) (f), \ + sizeof((self)->iv), (self)->iv, \ + (length), (dst), (src))) + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CBC_H_INCLUDED */ diff --git a/include/nettle/ccm.h b/include/nettle/ccm.h new file mode 100644 index 0000000..0a742a5 --- /dev/null +++ b/include/nettle/ccm.h @@ -0,0 +1,302 @@ +/* ccm.h + + Counter with CBC-MAC mode, specified by NIST, + http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf + + Copyright (C) 2014 Exegin Technologies Limited + Copyright (C) 2014 Owen Kirby + + Contributed to GNU Nettle by Owen Kirby + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* NIST SP800-38C doesn't specify the particular formatting and + * counter generation algorithm for CCM, but it does include an + * example algorithm. This example has become the de-factor standard, + * and has been adopted by both the IETF and IEEE across a wide + * variety of protocols. + */ + +#ifndef NETTLE_CCM_H_INCLUDED +#define NETTLE_CCM_H_INCLUDED + +#include "aes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define ccm_set_nonce nettle_ccm_set_nonce +#define ccm_update nettle_ccm_update +#define ccm_encrypt nettle_ccm_encrypt +#define ccm_decrypt nettle_ccm_decrypt +#define ccm_digest nettle_ccm_digest +#define ccm_encrypt_message nettle_ccm_encrypt_message +#define ccm_decrypt_message nettle_ccm_decrypt_message + +#define ccm_aes128_set_key nettle_ccm_aes128_set_key +#define ccm_aes128_set_nonce nettle_ccm_aes128_set_nonce +#define ccm_aes128_update nettle_ccm_aes128_update +#define ccm_aes128_encrypt nettle_ccm_aes128_encrypt +#define ccm_aes128_decrypt nettle_ccm_aes128_decrypt +#define ccm_aes128_digest nettle_ccm_aes128_digest +#define ccm_aes128_encrypt_message nettle_ccm_aes128_encrypt_message +#define ccm_aes128_decrypt_message nettle_ccm_aes128_decrypt_message + +#define ccm_aes192_set_key nettle_ccm_aes192_set_key +#define ccm_aes192_set_nonce nettle_ccm_aes192_set_nonce +#define ccm_aes192_update nettle_ccm_aes192_update +#define ccm_aes192_encrypt nettle_ccm_aes192_encrypt +#define ccm_aes192_decrypt nettle_ccm_aes192_decrypt +#define ccm_aes192_digest nettle_ccm_aes192_digest +#define ccm_aes192_encrypt_message nettle_ccm_aes192_encrypt_message +#define ccm_aes192_decrypt_message nettle_ccm_aes192_decrypt_message + +#define ccm_aes256_set_key nettle_ccm_aes256_set_key +#define ccm_aes256_set_nonce nettle_ccm_aes256_set_nonce +#define ccm_aes256_update nettle_ccm_aes256_update +#define ccm_aes256_encrypt nettle_ccm_aes256_encrypt +#define ccm_aes256_decrypt nettle_ccm_aes256_decrypt +#define ccm_aes256_digest nettle_ccm_aes256_digest +#define ccm_aes256_encrypt_message nettle_ccm_aes256_encrypt_message +#define ccm_aes256_decrypt_message nettle_ccm_aes256_decrypt_message + +/* For CCM, the block size of the block cipher shall be 128 bits. */ +#define CCM_BLOCK_SIZE 16 +#define CCM_DIGEST_SIZE 16 +#define CCM_MIN_NONCE_SIZE 7 +#define CCM_MAX_NONCE_SIZE 14 + +/* Maximum cleartext message size, as a function of the nonce size N. + The length field is L octets, with L = 15 - N, and then the maximum + size M = 2^{8L} - 1. */ +#define CCM_MAX_MSG_SIZE(N) \ + ((sizeof(size_t) + (N) <= 15) \ + ? ~(size_t) 0 \ + : ((size_t) 1 << (8*(15 - N))) - 1) + +/* Per-message state */ +struct ccm_ctx { + union nettle_block16 ctr; /* Counter for CTR encryption. */ + union nettle_block16 tag; /* CBC-MAC message tag. */ + /* Length of data processed by the CBC-MAC modulus the block size */ + unsigned int blength; +}; + +/* + * CCM mode requires the adata and message lengths when building the IV, which + * prevents streaming processing and it incompatible with the AEAD API. + */ +void +ccm_set_nonce(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f, + size_t noncelen, const uint8_t *nonce, + size_t authlen, size_t msglen, size_t taglen); + +void +ccm_update(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f, + size_t length, const uint8_t *data); + +void +ccm_encrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_decrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_digest(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *digest); + +/* + * All-in-one encryption and decryption API: + * tlength = sizeof(digest) + * mlength = sizeof(cleartext) + * clength = sizeof(ciphertext) = mlength + tlength + * + * The ciphertext will contain the encrypted payload with the message digest + * appended to the end. + */ +void +ccm_encrypt_message(const void *cipher, nettle_cipher_func *f, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t clength, uint8_t *dst, const uint8_t *src); + +/* + * The decryption function will write the plaintext to dst and parse the digest + * from the final tlength bytes of the ciphertext. If the digest matched the + * value computed during decryption then this will return 1, or it will return + * 0 if the digest was invalid. + */ +int +ccm_decrypt_message(const void *cipher, nettle_cipher_func *f, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); + +/* CCM Mode with AES-128 */ +struct ccm_aes128_ctx { + struct ccm_ctx ccm; + struct aes128_ctx cipher; +}; + +void +ccm_aes128_set_key(struct ccm_aes128_ctx *ctx, const uint8_t *key); + +void +ccm_aes128_set_nonce(struct ccm_aes128_ctx *ctx, + size_t length, const uint8_t *nonce, + size_t authlen, size_t msglen, size_t taglen); + +void +ccm_aes128_update (struct ccm_aes128_ctx *ctx, + size_t length, const uint8_t *data); + +void +ccm_aes128_encrypt(struct ccm_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes128_decrypt(struct ccm_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes128_digest(struct ccm_aes128_ctx *ctx, + size_t length, uint8_t *digest); + +void +ccm_aes128_encrypt_message(struct ccm_aes128_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t clength, uint8_t *dst, const uint8_t *src); + +int +ccm_aes128_decrypt_message(struct ccm_aes128_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); + +struct ccm_aes192_ctx { + struct ccm_ctx ccm; + struct aes192_ctx cipher; +}; + +/* CCM Mode with AES-192 */ +void +ccm_aes192_set_key(struct ccm_aes192_ctx *ctx, const uint8_t *key); + +void +ccm_aes192_set_nonce(struct ccm_aes192_ctx *ctx, + size_t length, const uint8_t *nonce, + size_t authlen, size_t msglen, size_t taglen); + +void +ccm_aes192_update(struct ccm_aes192_ctx *ctx, + size_t length, const uint8_t *data); + +void +ccm_aes192_encrypt(struct ccm_aes192_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes192_decrypt(struct ccm_aes192_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes192_digest(struct ccm_aes192_ctx *ctx, + size_t length, uint8_t *digest); + +void +ccm_aes192_encrypt_message(struct ccm_aes192_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t clength, uint8_t *dst, const uint8_t *src); + +int +ccm_aes192_decrypt_message(struct ccm_aes192_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); + +/* CCM Mode with AES-256 */ +struct ccm_aes256_ctx { + struct ccm_ctx ccm; + struct aes256_ctx cipher; +}; + +void +ccm_aes256_set_key(struct ccm_aes256_ctx *ctx, const uint8_t *key); + +void +ccm_aes256_set_nonce(struct ccm_aes256_ctx *ctx, + size_t length, const uint8_t *nonce, + size_t authlen, size_t msglen, size_t taglen); + +void +ccm_aes256_update(struct ccm_aes256_ctx *ctx, + size_t length, const uint8_t *data); + +void +ccm_aes256_encrypt(struct ccm_aes256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes256_decrypt(struct ccm_aes256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +ccm_aes256_digest(struct ccm_aes256_ctx *ctx, + size_t length, uint8_t *digest); + +void +ccm_aes256_encrypt_message(struct ccm_aes256_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t clength, uint8_t *dst, const uint8_t *src); + +int +ccm_aes256_decrypt_message(struct ccm_aes256_ctx *ctx, + size_t nlength, const uint8_t *nonce, + size_t alength, const uint8_t *adata, + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CCM_H_INCLUDED */ diff --git a/include/nettle/cfb.h b/include/nettle/cfb.h new file mode 100644 index 0000000..16660df --- /dev/null +++ b/include/nettle/cfb.h @@ -0,0 +1,87 @@ +/* cfb.h + + Cipher feedback mode. + + Copyright (C) 2015, 2017 Dmitry Eremin-Solenikov + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CFB_H_INCLUDED +#define NETTLE_CFB_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define cfb_encrypt nettle_cfb_encrypt +#define cfb_decrypt nettle_cfb_decrypt + +void +cfb_encrypt(const void *ctx, nettle_cipher_func *f, + size_t block_size, uint8_t *iv, + size_t length, uint8_t *dst, + const uint8_t *src); + +void +cfb_decrypt(const void *ctx, nettle_cipher_func *f, + size_t block_size, uint8_t *iv, + size_t length, uint8_t *dst, + const uint8_t *src); + +#define CFB_CTX(type, size) \ +{ type ctx; uint8_t iv[size]; } + +#define CFB_SET_IV(ctx, data) \ +memcpy((ctx)->iv, (data), sizeof((ctx)->iv)) + +/* NOTE: Avoid using NULL, as we don't include anything defining it. */ +#define CFB_ENCRYPT(self, f, length, dst, src) \ + (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0)) \ + : cfb_encrypt((void *) &(self)->ctx, \ + (nettle_cipher_func *) (f), \ + sizeof((self)->iv), (self)->iv, \ + (length), (dst), (src))) + +#define CFB_DECRYPT(self, f, length, dst, src) \ + (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0)) \ + : cfb_decrypt((void *) &(self)->ctx, \ + (nettle_cipher_func *) (f), \ + sizeof((self)->iv), (self)->iv, \ + (length), (dst), (src))) + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CFB_H_INCLUDED */ diff --git a/include/nettle/chacha-poly1305.h b/include/nettle/chacha-poly1305.h new file mode 100644 index 0000000..ce40b77 --- /dev/null +++ b/include/nettle/chacha-poly1305.h @@ -0,0 +1,98 @@ +/* chacha-poly1305.h + + AEAD mechanism based on chacha and poly1305. + See draft-agl-tls-chacha20poly1305-04. + + Copyright (C) 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED +#define NETTLE_CHACHA_POLY1305_H_INCLUDED + +#include "chacha.h" +#include "poly1305.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define chacha_poly1305_set_key nettle_chacha_poly1305_set_key +#define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce +#define chacha_poly1305_update nettle_chacha_poly1305_update +#define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt +#define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt +#define chacha_poly1305_digest nettle_chacha_poly1305_digest + +#define CHACHA_POLY1305_BLOCK_SIZE 64 +/* FIXME: Any need for 128-bit variant? */ +#define CHACHA_POLY1305_KEY_SIZE 32 +#define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE +#define CHACHA_POLY1305_DIGEST_SIZE 16 + +struct chacha_poly1305_ctx +{ + struct chacha_ctx chacha; + struct poly1305_ctx poly1305; + union nettle_block16 s; + uint64_t auth_size; + uint64_t data_size; + /* poly1305 block */ + uint8_t block[POLY1305_BLOCK_SIZE]; + unsigned index; +}; + +void +chacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx, + const uint8_t *key); +void +chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx, + const uint8_t *nonce); + +void +chacha_poly1305_update (struct chacha_poly1305_ctx *ctx, + size_t length, const uint8_t *data); + +void +chacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +chacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +chacha_poly1305_digest (struct chacha_poly1305_ctx *ctx, + size_t length, uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CHACHA_POLY1305_H_INCLUDED */ diff --git a/include/nettle/chacha.h b/include/nettle/chacha.h new file mode 100644 index 0000000..3f08283 --- /dev/null +++ b/include/nettle/chacha.h @@ -0,0 +1,96 @@ +/* chacha.h + + The ChaCha stream cipher. + + Copyright (C) 2013 Joachim Str枚mbergson + Copyright (C) 2012 Simon Josefsson + Copyright (C) 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CHACHA_H_INCLUDED +#define NETTLE_CHACHA_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define chacha_set_key nettle_chacha_set_key +#define chacha_set_nonce nettle_chacha_set_nonce +#define chacha_set_nonce96 nettle_chacha_set_nonce96 +#define chacha_crypt nettle_chacha_crypt +#define _chacha_core _nettle_chacha_core + +/* Currently, only 256-bit keys are supported. */ +#define CHACHA_KEY_SIZE 32 +#define CHACHA_BLOCK_SIZE 64 +#define CHACHA_NONCE_SIZE 8 +#define CHACHA_NONCE96_SIZE 12 + +#define _CHACHA_STATE_LENGTH 16 + +struct chacha_ctx +{ + /* Indices 0-3 holds a constant (SIGMA or TAU). + Indices 4-11 holds the key. + Indices 12-13 holds the block counter. + Indices 14-15 holds the IV: + + This creates the state matrix: + C C C C + K K K K + K K K K + B B I I + */ + uint32_t state[_CHACHA_STATE_LENGTH]; +}; + +void +chacha_set_key(struct chacha_ctx *ctx, const uint8_t *key); + +void +chacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce); + +void +chacha_set_nonce96(struct chacha_ctx *ctx, const uint8_t *nonce); + +void +chacha_crypt(struct chacha_ctx *ctx, size_t length, + uint8_t *dst, const uint8_t *src); + +void +_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CHACHA_H_INCLUDED */ diff --git a/include/nettle/ctr.h b/include/nettle/ctr.h new file mode 100644 index 0000000..7dd06a2 --- /dev/null +++ b/include/nettle/ctr.h @@ -0,0 +1,71 @@ +/* ctr.h + + Counter mode, using an network byte order incremented counter, + matching the testcases of NIST 800-38A. + + Copyright (C) 2005 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CTR_H_INCLUDED +#define NETTLE_CTR_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define ctr_crypt nettle_ctr_crypt + +void +ctr_crypt(const void *ctx, nettle_cipher_func *f, + size_t block_size, uint8_t *ctr, + size_t length, uint8_t *dst, + const uint8_t *src); + +#define CTR_CTX(type, size) \ +{ type ctx; uint8_t ctr[size]; } + +#define CTR_SET_COUNTER(ctx, data) \ +memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr)) + +#define CTR_CRYPT(self, f, length, dst, src) \ + (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0)) \ + : ctr_crypt((void *) &(self)->ctx, \ + (nettle_cipher_func *) (f), \ + sizeof((self)->ctr), (self)->ctr, \ + (length), (dst), (src))) + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CTR_H_INCLUDED */ diff --git a/include/nettle/curve25519.h b/include/nettle/curve25519.h new file mode 100644 index 0000000..1dcd94d --- /dev/null +++ b/include/nettle/curve25519.h @@ -0,0 +1,60 @@ +/* curve25519.h + + Copyright (C) 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_CURVE25519_H +#define NETTLE_CURVE25519_H + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define curve25519_mul_g nettle_curve25519_mul_g +#define curve25519_mul nettle_curve25519_mul + +#define CURVE25519_SIZE 32 + +/* Indicates that curve25519_mul conforms to RFC 7748. */ +#define NETTLE_CURVE25519_RFC7748 1 + +void +curve25519_mul_g (uint8_t *q, const uint8_t *n); + +void +curve25519_mul (uint8_t *q, const uint8_t *n, const uint8_t *p); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_CURVE25519_H */ diff --git a/include/nettle/des-compat.h b/include/nettle/des-compat.h new file mode 100644 index 0000000..bda4e75 --- /dev/null +++ b/include/nettle/des-compat.h @@ -0,0 +1,162 @@ +/* des-compat.h + + The des block cipher, old libdes/openssl-style interface. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_DES_COMPAT_H_INCLUDED +#define NETTLE_DES_COMPAT_H_INCLUDED + +/* According to Assar, des_set_key, des_set_key_odd_parity, + * des_is_weak_key, plus the encryption functions (des_*_encrypt and + * des_cbc_cksum) would be a pretty useful subset. */ + +/* NOTE: This is quite experimental, and not all functions are + * implemented. Contributions, in particular test cases are welcome. */ + +#include "des.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* We use some name mangling, to avoid collisions with either other + * nettle functions or with libcrypto. */ + +#define des_ecb3_encrypt nettle_openssl_des_ecb3_encrypt +#define des_cbc_cksum nettle_openssl_des_cbc_cksum +#define des_ncbc_encrypt nettle_openssl_des_ncbc_encrypt +#define des_cbc_encrypt nettle_openssl_des_cbc_encrypt +#define des_ecb_encrypt nettle_openssl_des_ecb_encrypt +#define des_ede3_cbc_encrypt nettle_openssl_des_ede3_cbc_encrypt +#define des_set_odd_parity nettle_openssl_des_set_odd_parity +#define des_check_key nettle_openssl_des_check_key +#define des_key_sched nettle_openssl_des_key_sched +#define des_is_weak_key nettle_openssl_des_is_weak_key + +/* An extra alias */ +#undef des_set_key +#define des_set_key nettle_openssl_des_key_sched + +enum { DES_DECRYPT = 0, DES_ENCRYPT = 1 }; + +/* Types */ +typedef uint32_t DES_LONG; + +/* Note: Typedef:ed arrays should be avoided, but they're used here + * for compatibility. */ +typedef struct des_ctx des_key_schedule[1]; + +typedef uint8_t des_cblock[DES_BLOCK_SIZE]; +/* Note: The proper definition, + + typedef const uint8_t const_des_cblock[DES_BLOCK_SIZE]; + + would have worked, *if* all the prototypes had used arguments like + foo(const_des_cblock src, des_cblock dst), letting argument arrays + "decay" into pointers of type uint8_t * and const uint8_t *. + + But since openssl's prototypes use *pointers* const_des_cblock *src, + des_cblock *dst, this ends up in type conflicts, and the workaround + is to not use const at all. +*/ +#define const_des_cblock des_cblock + +/* Aliases */ +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +/* Global flag */ +extern int des_check_key; + +/* Prototypes */ + +/* Typing is a little confusing. Since both des_cblock and + des_key_schedule are typedef:ed arrays, it automatically decay to + a pointers. + + But the functions are declared taking pointers to des_cblock, i.e. + pointers to arrays. And on the other hand, they take plain + des_key_schedule arguments, which is equivalent to pointers to + struct des_ctx. */ +void +des_ecb3_encrypt(const_des_cblock *src, des_cblock *dst, + des_key_schedule k1, + des_key_schedule k2, + des_key_schedule k3, int enc); + +/* des_cbc_cksum in libdes returns a 32 bit integer, representing the + * latter half of the output block, using little endian byte order. */ +uint32_t +des_cbc_cksum(const uint8_t *src, des_cblock *dst, + long length, des_key_schedule ctx, + const_des_cblock *iv); + +/* NOTE: Doesn't update iv. */ +void +des_cbc_encrypt(const_des_cblock *src, des_cblock *dst, long length, + des_key_schedule ctx, const_des_cblock *iv, + int enc); + +/* Similar, but updates iv. */ +void +des_ncbc_encrypt(const_des_cblock *src, des_cblock *dst, long length, + des_key_schedule ctx, des_cblock *iv, + int enc); + +void +des_ecb_encrypt(const_des_cblock *src, des_cblock *dst, + des_key_schedule ctx, int enc); + +void +des_ede3_cbc_encrypt(const_des_cblock *src, des_cblock *dst, long length, + des_key_schedule k1, + des_key_schedule k2, + des_key_schedule k3, + des_cblock *iv, + int enc); + +int +des_set_odd_parity(des_cblock *key); + +int +des_key_sched(const_des_cblock *key, des_key_schedule ctx); + +int +des_is_weak_key(const_des_cblock *key); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_DES_COMPAT_H_INCLUDED */ diff --git a/include/nettle/des.h b/include/nettle/des.h new file mode 100644 index 0000000..f8f3fea --- /dev/null +++ b/include/nettle/des.h @@ -0,0 +1,120 @@ +/* des.h + + The des block cipher. And triple des. + + Copyright (C) 1992 Dana L. How + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `../lib/descore.README' for the complete copyright + * notice. + * + * Slightly edited by Niels M枚ller, 1997 + */ + +#ifndef NETTLE_DES_H_INCLUDED +#define NETTLE_DES_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Namespace mangling */ +#define des_set_key nettle_des_set_key +#define des_encrypt nettle_des_encrypt +#define des_decrypt nettle_des_decrypt +#define des_check_parity nettle_des_check_parity +#define des_fix_parity nettle_des_fix_parity +#define des3_set_key nettle_des3_set_key +#define des3_encrypt nettle_des3_encrypt +#define des3_decrypt nettle_des3_decrypt + +#define DES_KEY_SIZE 8 +#define DES_BLOCK_SIZE 8 + +/* Expanded key length */ +#define _DES_KEY_LENGTH 32 + +struct des_ctx +{ + uint32_t key[_DES_KEY_LENGTH]; +}; + +/* Returns 1 for good keys and 0 for weak keys. */ +int +des_set_key(struct des_ctx *ctx, const uint8_t *key); + +void +des_encrypt(const struct des_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +des_decrypt(const struct des_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +int +des_check_parity(size_t length, const uint8_t *key); + +void +des_fix_parity(size_t length, uint8_t *dst, + const uint8_t *src); + +#define DES3_KEY_SIZE 24 +#define DES3_BLOCK_SIZE DES_BLOCK_SIZE + +struct des3_ctx +{ + struct des_ctx des[3]; +}; + + +/* Returns 1 for good keys and 0 for weak keys. */ +int +des3_set_key(struct des3_ctx *ctx, const uint8_t *key); + +void +des3_encrypt(const struct des3_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +des3_decrypt(const struct des3_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_DES_H_INCLUDED */ diff --git a/include/nettle/dsa-compat.h b/include/nettle/dsa-compat.h new file mode 100644 index 0000000..4ec96ed --- /dev/null +++ b/include/nettle/dsa-compat.h @@ -0,0 +1,183 @@ +/* dsa-compat.h + + Old DSA publickey interface. + + Copyright (C) 2002, 2013, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_DSA_COMPAT_H_INCLUDED +#define NETTLE_DSA_COMPAT_H_INCLUDED + +#include "dsa.h" + +#include "sha1.h" +#include "sha2.h" + +/* Name mangling */ +#define dsa_public_key_init nettle_dsa_public_key_init +#define dsa_public_key_clear nettle_dsa_public_key_clear +#define dsa_private_key_init nettle_dsa_private_key_init +#define dsa_private_key_clear nettle_dsa_private_key_clear +#define dsa_sha1_sign nettle_dsa_sha1_sign +#define dsa_sha1_verify nettle_dsa_sha1_verify +#define dsa_sha256_sign nettle_dsa_sha256_sign +#define dsa_sha256_verify nettle_dsa_sha256_verify +#define dsa_sha1_sign_digest nettle_dsa_sha1_sign_digest +#define dsa_sha1_verify_digest nettle_dsa_sha1_verify_digest +#define dsa_sha256_sign_digest nettle_dsa_sha256_sign_digest +#define dsa_sha256_verify_digest nettle_dsa_sha256_verify_digest +#define dsa_compat_generate_keypair nettle_dsa_compat_generate_keypair + +/* Switch meaning of dsa_generate_keypair */ +#undef dsa_generate_keypair +#define dsa_generate_keypair nettle_dsa_compat_generate_keypair + +#ifdef __cplusplus +extern "C" { +#endif + +struct dsa_public_key +{ + /* Same as struct dsa_params, but can't use that struct here without + breaking backwards compatibility. Layout must be identical, since + this is cast to a struct dsa_param pointer for calling _dsa_sign + and _dsa_verify */ + mpz_t p; + mpz_t q; + mpz_t g; + + /* Public value */ + mpz_t y; +}; + +struct dsa_private_key +{ + /* Unlike an rsa public key, private key operations will need both + * the private and the public information. */ + mpz_t x; +}; + +/* Signing a message works as follows: + * + * Store the private key in a dsa_private_key struct. + * + * Initialize a hashing context, by callling + * sha1_init + * + * Hash the message by calling + * sha1_update + * + * Create the signature by calling + * dsa_sha1_sign + * + * The signature is represented as a struct dsa_signature. This call also + * resets the hashing context. + * + * When done with the key and signature, don't forget to call + * dsa_signature_clear. + */ + +/* Calls mpz_init to initialize bignum storage. */ +void +dsa_public_key_init(struct dsa_public_key *key); + +/* Calls mpz_clear to deallocate bignum storage. */ +void +dsa_public_key_clear(struct dsa_public_key *key); + + +/* Calls mpz_init to initialize bignum storage. */ +void +dsa_private_key_init(struct dsa_private_key *key); + +/* Calls mpz_clear to deallocate bignum storage. */ +void +dsa_private_key_clear(struct dsa_private_key *key); + +int +dsa_sha1_sign(const struct dsa_public_key *pub, + const struct dsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct sha1_ctx *hash, + struct dsa_signature *signature); + +int +dsa_sha256_sign(const struct dsa_public_key *pub, + const struct dsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct sha256_ctx *hash, + struct dsa_signature *signature); + +int +dsa_sha1_verify(const struct dsa_public_key *key, + struct sha1_ctx *hash, + const struct dsa_signature *signature); + +int +dsa_sha256_verify(const struct dsa_public_key *key, + struct sha256_ctx *hash, + const struct dsa_signature *signature); + +int +dsa_sha1_sign_digest(const struct dsa_public_key *pub, + const struct dsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, + struct dsa_signature *signature); +int +dsa_sha256_sign_digest(const struct dsa_public_key *pub, + const struct dsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, + struct dsa_signature *signature); + +int +dsa_sha1_verify_digest(const struct dsa_public_key *key, + const uint8_t *digest, + const struct dsa_signature *signature); + +int +dsa_sha256_verify_digest(const struct dsa_public_key *key, + const uint8_t *digest, + const struct dsa_signature *signature); + +/* Key generation */ +int +dsa_generate_keypair(struct dsa_public_key *pub, + struct dsa_private_key *key, + + void *random_ctx, nettle_random_func *random, + void *progress_ctx, nettle_progress_func *progress, + unsigned p_bits, unsigned q_bits); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_DSA_COMPAT_H_INCLUDED */ diff --git a/include/nettle/dsa.h b/include/nettle/dsa.h new file mode 100644 index 0000000..7aa982a --- /dev/null +++ b/include/nettle/dsa.h @@ -0,0 +1,216 @@ +/* dsa.h + + The DSA publickey algorithm. + + Copyright (C) 2002, 2013, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_DSA_H_INCLUDED +#define NETTLE_DSA_H_INCLUDED + +#include "nettle-types.h" +#include "bignum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define dsa_params_init nettle_dsa_params_init +#define dsa_params_clear nettle_dsa_params_clear +#define dsa_signature_init nettle_dsa_signature_init +#define dsa_signature_clear nettle_dsa_signature_clear +#define dsa_sign nettle_dsa_sign +#define dsa_verify nettle_dsa_verify +#define dsa_generate_params nettle_dsa_generate_params +#define dsa_generate_keypair nettle_dsa_generate_keypair +#define dsa_signature_from_sexp nettle_dsa_signature_from_sexp +#define dsa_keypair_to_sexp nettle_dsa_keypair_to_sexp +#define dsa_keypair_from_sexp_alist nettle_dsa_keypair_from_sexp_alist +#define dsa_sha1_keypair_from_sexp nettle_dsa_sha1_keypair_from_sexp +#define dsa_sha256_keypair_from_sexp nettle_dsa_sha256_keypair_from_sexp +#define dsa_params_from_der_iterator nettle_dsa_params_from_der_iterator +#define dsa_public_key_from_der_iterator nettle_dsa_public_key_from_der_iterator +#define dsa_openssl_private_key_from_der_iterator nettle_dsa_openssl_private_key_from_der_iterator +#define dsa_openssl_private_key_from_der nettle_openssl_provate_key_from_der +#define _dsa_hash _nettle_dsa_hash + +/* For FIPS approved parameters */ +#define DSA_SHA1_MIN_P_BITS 512 +#define DSA_SHA1_Q_OCTETS 20 +#define DSA_SHA1_Q_BITS 160 + +#define DSA_SHA256_MIN_P_BITS 1024 +#define DSA_SHA256_Q_OCTETS 32 +#define DSA_SHA256_Q_BITS 256 + +struct dsa_params +{ + /* Modulo */ + mpz_t p; + + /* Group order */ + mpz_t q; + + /* Generator */ + mpz_t g; +}; + +void +dsa_params_init (struct dsa_params *params); + +void +dsa_params_clear (struct dsa_params *params); + +struct dsa_signature +{ + mpz_t r; + mpz_t s; +}; + +/* Calls mpz_init to initialize bignum storage. */ +void +dsa_signature_init(struct dsa_signature *signature); + +/* Calls mpz_clear to deallocate bignum storage. */ +void +dsa_signature_clear(struct dsa_signature *signature); + +int +dsa_sign(const struct dsa_params *params, + const mpz_t x, + void *random_ctx, nettle_random_func *random, + size_t digest_size, + const uint8_t *digest, + struct dsa_signature *signature); + +int +dsa_verify(const struct dsa_params *params, + const mpz_t y, + size_t digest_size, + const uint8_t *digest, + const struct dsa_signature *signature); + + +/* Key generation */ + +int +dsa_generate_params(struct dsa_params *params, + void *random_ctx, nettle_random_func *random, + void *progress_ctx, nettle_progress_func *progress, + unsigned p_bits, unsigned q_bits); + +void +dsa_generate_keypair (const struct dsa_params *params, + mpz_t pub, mpz_t key, + void *random_ctx, nettle_random_func *random); + +/* Keys in sexp form. */ + +struct nettle_buffer; + +/* Generates a public-key expression if PRIV is NULL .*/ +int +dsa_keypair_to_sexp(struct nettle_buffer *buffer, + const char *algorithm_name, /* NULL means "dsa" */ + const struct dsa_params *params, + const mpz_t pub, + const mpz_t priv); + +struct sexp_iterator; + +int +dsa_signature_from_sexp(struct dsa_signature *rs, + struct sexp_iterator *i, + unsigned q_bits); + +int +dsa_keypair_from_sexp_alist(struct dsa_params *params, + mpz_t pub, + mpz_t priv, + unsigned p_max_bits, + unsigned q_bits, + struct sexp_iterator *i); + +/* If PRIV is NULL, expect a public-key expression. If PUB is NULL, + * expect a private key expression and ignore the parts not needed for + * the public key. */ +/* Keys must be initialized before calling this function, as usual. */ +int +dsa_sha1_keypair_from_sexp(struct dsa_params *params, + mpz_t pub, + mpz_t priv, + unsigned p_max_bits, + size_t length, const uint8_t *expr); + +int +dsa_sha256_keypair_from_sexp(struct dsa_params *params, + mpz_t pub, + mpz_t priv, + unsigned p_max_bits, + size_t length, const uint8_t *expr); + +/* Keys in X.509 andd OpenSSL format. */ +struct asn1_der_iterator; + +int +dsa_params_from_der_iterator(struct dsa_params *params, + unsigned max_bits, unsigned q_bits, + struct asn1_der_iterator *i); + +int +dsa_public_key_from_der_iterator(const struct dsa_params *params, + mpz_t pub, + struct asn1_der_iterator *i); + +int +dsa_openssl_private_key_from_der_iterator(struct dsa_params *params, + mpz_t pub, + mpz_t priv, + unsigned p_max_bits, + struct asn1_der_iterator *i); + +int +dsa_openssl_private_key_from_der(struct dsa_params *params, + mpz_t pub, + mpz_t priv, + unsigned p_max_bits, + size_t length, const uint8_t *data); + + +/* Internal functions. */ +void +_dsa_hash (mpz_t h, unsigned bit_size, + size_t length, const uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_DSA_H_INCLUDED */ diff --git a/include/nettle/eax.h b/include/nettle/eax.h new file mode 100644 index 0000000..e9747f3 --- /dev/null +++ b/include/nettle/eax.h @@ -0,0 +1,185 @@ +/* eax.h + + EAX mode, see http://www.cs.ucdavis.edu/~rogaway/papers/eax.pdf + + Copyright (C) 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_EAX_H_INCLUDED +#define NETTLE_EAX_H_INCLUDED + +#include "aes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define eax_set_key nettle_eax_set_key +#define eax_set_nonce nettle_eax_set_nonce +#define eax_update nettle_eax_update +#define eax_encrypt nettle_eax_encrypt +#define eax_decrypt nettle_eax_decrypt +#define eax_digest nettle_eax_digest + +#define eax_aes128_set_key nettle_eax_aes128_set_key +#define eax_aes128_set_nonce nettle_eax_aes128_set_nonce +#define eax_aes128_update nettle_eax_aes128_update +#define eax_aes128_encrypt nettle_eax_aes128_encrypt +#define eax_aes128_decrypt nettle_eax_aes128_decrypt +#define eax_aes128_digest nettle_eax_aes128_digest + +/* Restricted to block ciphers with 128 bit block size. FIXME: Reflect + this in naming? */ + +#define EAX_BLOCK_SIZE 16 +#define EAX_DIGEST_SIZE 16 +/* FIXME: Reasonable default? */ +#define EAX_IV_SIZE 16 + +/* Values independent of message and nonce */ +struct eax_key +{ + union nettle_block16 pad_block; + union nettle_block16 pad_partial; +}; + +struct eax_ctx +{ + union nettle_block16 omac_nonce; + union nettle_block16 omac_data; + union nettle_block16 omac_message; + union nettle_block16 ctr; +}; + +void +eax_set_key (struct eax_key *key, const void *cipher, nettle_cipher_func *f); + +void +eax_set_nonce (struct eax_ctx *eax, const struct eax_key *key, + const void *cipher, nettle_cipher_func *f, + size_t nonce_length, const uint8_t *nonce); + +void +eax_update (struct eax_ctx *eax, const struct eax_key *key, + const void *cipher, nettle_cipher_func *f, + size_t data_length, const uint8_t *data); + +void +eax_encrypt (struct eax_ctx *eax, const struct eax_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +eax_decrypt (struct eax_ctx *eax, const struct eax_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +eax_digest (struct eax_ctx *eax, const struct eax_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *digest); + +/* Put the cipher last, to get cipher-independent offsets for the EAX + * state. */ +#define EAX_CTX(type) \ + { struct eax_key key; struct eax_ctx eax; type cipher; } + +#define EAX_SET_KEY(ctx, set_key, encrypt, data) \ + do { \ + (set_key)(&(ctx)->cipher, (data)); \ + if (0) (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0); \ + eax_set_key (&(ctx)->key, &(ctx)->cipher, (nettle_cipher_func *) encrypt); \ + } while (0) + +#define EAX_SET_NONCE(ctx, encrypt, length, nonce) \ + (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : eax_set_nonce (&(ctx)->eax, &(ctx)->key, \ + &(ctx)->cipher, (nettle_cipher_func *) (encrypt), \ + (length), (nonce))) + +#define EAX_UPDATE(ctx, encrypt, length, data) \ + (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : eax_update (&(ctx)->eax, &(ctx)->key, \ + &(ctx)->cipher, (nettle_cipher_func *) (encrypt), \ + (length), (data))) + +#define EAX_ENCRYPT(ctx, encrypt, length, dst, src) \ + (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : eax_encrypt (&(ctx)->eax, &(ctx)->key, \ + &(ctx)->cipher, (nettle_cipher_func *) (encrypt), \ + (length), (dst), (src))) + +#define EAX_DECRYPT(ctx, encrypt, length, dst, src) \ + (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : eax_decrypt (&(ctx)->eax, &(ctx)->key, \ + &(ctx)->cipher, (nettle_cipher_func *) (encrypt), \ + (length), (dst), (src))) + +#define EAX_DIGEST(ctx, encrypt, length, digest) \ + (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : eax_digest (&(ctx)->eax, &(ctx)->key, \ + &(ctx)->cipher, (nettle_cipher_func *) (encrypt), \ + (length), (digest))) + +struct eax_aes128_ctx EAX_CTX(struct aes128_ctx); + +void +eax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key); + +void +eax_aes128_set_nonce(struct eax_aes128_ctx *ctx, + size_t length, const uint8_t *iv); + +void +eax_aes128_update(struct eax_aes128_ctx *ctx, + size_t length, const uint8_t *data); + +void +eax_aes128_encrypt(struct eax_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +eax_aes128_decrypt(struct eax_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +eax_aes128_digest(struct eax_aes128_ctx *ctx, size_t length, uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_EAX_H_INCLUDED */ diff --git a/include/nettle/ecc-curve.h b/include/nettle/ecc-curve.h new file mode 100644 index 0000000..c08479a --- /dev/null +++ b/include/nettle/ecc-curve.h @@ -0,0 +1,71 @@ +/* ecc-curve.h + + Copyright (C) 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */ + +#ifndef NETTLE_ECC_CURVE_H_INCLUDED +#define NETTLE_ECC_CURVE_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/* The contents of this struct is internal. */ +struct ecc_curve; + +/* FIXME: Rename with leading underscore. Due to ABI subtleties, + applications should not refer to these directly, but use the below + accessor functions. */ +extern const struct ecc_curve nettle_secp_192r1; +extern const struct ecc_curve nettle_secp_224r1; +extern const struct ecc_curve nettle_secp_256r1; +extern const struct ecc_curve nettle_secp_384r1; +extern const struct ecc_curve nettle_secp_521r1; + +#ifdef __GNUC__ +#define NETTLE_PURE __attribute__((pure)) +#else +#define NETTLE_PURE +#endif + +const struct ecc_curve * NETTLE_PURE nettle_get_secp_192r1(void); +const struct ecc_curve * NETTLE_PURE nettle_get_secp_224r1(void); +const struct ecc_curve * NETTLE_PURE nettle_get_secp_256r1(void); +const struct ecc_curve * NETTLE_PURE nettle_get_secp_384r1(void); +const struct ecc_curve * NETTLE_PURE nettle_get_secp_521r1(void); + +#undef NETTLE_PURE + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ECC_CURVE_H_INCLUDED */ diff --git a/include/nettle/ecc.h b/include/nettle/ecc.h new file mode 100644 index 0000000..93fc9e8 --- /dev/null +++ b/include/nettle/ecc.h @@ -0,0 +1,159 @@ +/* ecc.h + + Copyright (C) 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */ + +#ifndef NETTLE_ECC_H_INCLUDED +#define NETTLE_ECC_H_INCLUDED + +#include "nettle-types.h" +#include "bignum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define ecc_point_init nettle_ecc_point_init +#define ecc_point_clear nettle_ecc_point_clear +#define ecc_point_set nettle_ecc_point_set +#define ecc_point_get nettle_ecc_point_get +#define ecc_point_mul nettle_ecc_point_mul +#define ecc_point_mul_g nettle_ecc_point_mul_g +#define ecc_scalar_init nettle_ecc_scalar_init +#define ecc_scalar_clear nettle_ecc_scalar_clear +#define ecc_scalar_set nettle_ecc_scalar_set +#define ecc_scalar_get nettle_ecc_scalar_get +#define ecc_scalar_random nettle_ecc_scalar_random +#define ecc_point_mul nettle_ecc_point_mul +#define ecc_bit_size nettle_ecc_bit_size +#define ecc_size nettle_ecc_size +#define ecc_size_a nettle_ecc_size_a +#define ecc_size_j nettle_ecc_size_j + +struct ecc_curve; + +/* High level interface, for ECDSA, DH, etc */ + +/* Represents a point on the ECC curve */ +struct ecc_point +{ + const struct ecc_curve *ecc; + /* Allocated using the same allocation function as GMP. */ + mp_limb_t *p; +}; + +/* Represents a non-zero scalar, an element of Z_q^*, where q is the + group order of the curve. */ +struct ecc_scalar +{ + const struct ecc_curve *ecc; + /* Allocated using the same allocation function as GMP. */ + mp_limb_t *p; +}; + +void +ecc_point_init (struct ecc_point *p, const struct ecc_curve *ecc); +void +ecc_point_clear (struct ecc_point *p); + +/* Fails and returns zero if the point is not on the curve. */ +int +ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y); +void +ecc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y); + +void +ecc_scalar_init (struct ecc_scalar *s, const struct ecc_curve *ecc); +void +ecc_scalar_clear (struct ecc_scalar *s); + +/* Fails and returns zero if the scalar is not in the proper range. */ +int +ecc_scalar_set (struct ecc_scalar *s, const mpz_t z); +void +ecc_scalar_get (const struct ecc_scalar *s, mpz_t z); +/* Generates a random scalar, suitable as an ECDSA private key or a + ECDH exponent. */ +void +ecc_scalar_random (struct ecc_scalar *s, + void *random_ctx, nettle_random_func *random); + +/* Computes r = n p */ +void +ecc_point_mul (struct ecc_point *r, const struct ecc_scalar *n, + const struct ecc_point *p); + +/* Computes r = n g */ +void +ecc_point_mul_g (struct ecc_point *r, const struct ecc_scalar *n); + + +/* Low-level interface */ + +/* Points on a curve are represented as arrays of mp_limb_t, with + curve-specific representation. For the secp curves, we use Jacobian + coordinates (possibly in Montgomery form for mod multiplication). + For curve25519 we use homogeneous coordinates on an equivalent + Edwards curve. The suffix "_h" denotes this internal + representation. + + Since we use additive notation for the groups, the infinity point + on the curve is denoted 0. The infinity point can be represented + with x = y = 0 in affine coordinates, and Z = 0 in Jacobian + coordinates. However, note that most of the ECC functions do *not* + support infinity as an input or output. +*/ + +/* Returns the bit size of a single coordinate (and of the prime p). */ +unsigned +ecc_bit_size (const struct ecc_curve *ecc); + +/* Returns the size of a single coordinate. */ +mp_size_t +ecc_size (const struct ecc_curve *ecc); + +/* Size of a point, using affine coordinates x, y. */ +mp_size_t +ecc_size_a (const struct ecc_curve *ecc); + +/* Size of a point, using jacobian coordinates X, Y and Z. */ +mp_size_t +ecc_size_j (const struct ecc_curve *ecc); + +/* FIXME: Define a generic ecc_dup, ecc_add, for any type of curve. Do + they need to handle infinity points? */ + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ECC_H_INCLUDED */ diff --git a/include/nettle/ecdsa.h b/include/nettle/ecdsa.h new file mode 100644 index 0000000..693aca8 --- /dev/null +++ b/include/nettle/ecdsa.h @@ -0,0 +1,103 @@ +/* ecdsa.h + + Copyright (C) 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */ + +#ifndef NETTLE_ECDSA_H_INCLUDED +#define NETTLE_ECDSA_H_INCLUDED + +#include "ecc.h" +#include "dsa.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define ecdsa_sign nettle_ecdsa_sign +#define ecdsa_verify nettle_ecdsa_verify +#define ecdsa_generate_keypair nettle_ecdsa_generate_keypair +#define ecc_ecdsa_sign nettle_ecc_ecdsa_sign +#define ecc_ecdsa_sign_itch nettle_ecc_ecdsa_sign_itch +#define ecc_ecdsa_verify nettle_ecc_ecdsa_verify +#define ecc_ecdsa_verify_itch nettle_ecc_ecdsa_verify_itch + +/* High level ECDSA functions. + * + * A public key is represented as a struct ecc_point, and a private + * key as a struct ecc_scalar. FIXME: Introduce some aliases? */ +void +ecdsa_sign (const struct ecc_scalar *key, + void *random_ctx, nettle_random_func *random, + size_t digest_length, + const uint8_t *digest, + struct dsa_signature *signature); + +int +ecdsa_verify (const struct ecc_point *pub, + size_t length, const uint8_t *digest, + const struct dsa_signature *signature); + +void +ecdsa_generate_keypair (struct ecc_point *pub, + struct ecc_scalar *key, + void *random_ctx, nettle_random_func *random); + +/* Low-level ECDSA functions. */ +mp_size_t +ecc_ecdsa_sign_itch (const struct ecc_curve *ecc); + +void +ecc_ecdsa_sign (const struct ecc_curve *ecc, + const mp_limb_t *zp, + /* Random nonce, must be invertible mod ecc group + order. */ + const mp_limb_t *kp, + size_t length, const uint8_t *digest, + mp_limb_t *rp, mp_limb_t *sp, + mp_limb_t *scratch); + +mp_size_t +ecc_ecdsa_verify_itch (const struct ecc_curve *ecc); + +int +ecc_ecdsa_verify (const struct ecc_curve *ecc, + const mp_limb_t *pp, /* Public key */ + size_t length, const uint8_t *digest, + const mp_limb_t *rp, const mp_limb_t *sp, + mp_limb_t *scratch); + + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_ECDSA_H_INCLUDED */ diff --git a/include/nettle/eddsa.h b/include/nettle/eddsa.h new file mode 100644 index 0000000..49f1a02 --- /dev/null +++ b/include/nettle/eddsa.h @@ -0,0 +1,149 @@ +/* eddsa.h + + Copyright (C) 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_EDDSA_H +#define NETTLE_EDDSA_H + +#include "nettle-types.h" + +#include "bignum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define ed25519_sha512_set_private_key nettle_ed25519_sha512_set_private_key +#define ed25519_sha512_public_key nettle_ed25519_sha512_public_key +#define ed25519_sha512_sign nettle_ed25519_sha512_sign +#define ed25519_sha512_verify nettle_ed25519_sha512_verify + +#define _eddsa_compress _nettle_eddsa_compress +#define _eddsa_compress_itch _nettle_eddsa_compress_itch +#define _eddsa_decompress _nettle_eddsa_decompress +#define _eddsa_decompress_itch _nettle_eddsa_decompress_itch +#define _eddsa_hash _nettle_eddsa_hash +#define _eddsa_expand_key _nettle_eddsa_expand_key +#define _eddsa_sign _nettle_eddsa_sign +#define _eddsa_sign_itch _nettle_eddsa_sign_itch +#define _eddsa_verify _nettle_eddsa_verify +#define _eddsa_verify_itch _nettle_eddsa_verify_itch +#define _eddsa_public_key_itch _nettle_eddsa_public_key_itch +#define _eddsa_public_key _nettle_eddsa_public_key + +#define ED25519_KEY_SIZE 32 +#define ED25519_SIGNATURE_SIZE 64 + +void +ed25519_sha512_public_key (uint8_t *pub, const uint8_t *priv); + +void +ed25519_sha512_sign (const uint8_t *pub, + const uint8_t *priv, + size_t length, const uint8_t *msg, + uint8_t *signature); + +int +ed25519_sha512_verify (const uint8_t *pub, + size_t length, const uint8_t *msg, + const uint8_t *signature); + +/* Low-level internal functions */ + +struct ecc_curve; +struct ecc_modulo; + +mp_size_t +_eddsa_compress_itch (const struct ecc_curve *ecc); +void +_eddsa_compress (const struct ecc_curve *ecc, uint8_t *r, mp_limb_t *p, + mp_limb_t *scratch); + +mp_size_t +_eddsa_decompress_itch (const struct ecc_curve *ecc); +int +_eddsa_decompress (const struct ecc_curve *ecc, mp_limb_t *p, + const uint8_t *cp, + mp_limb_t *scratch); + +void +_eddsa_hash (const struct ecc_modulo *m, + mp_limb_t *rp, const uint8_t *digest); + +mp_size_t +_eddsa_sign_itch (const struct ecc_curve *ecc); + +void +_eddsa_sign (const struct ecc_curve *ecc, + const struct nettle_hash *H, + const uint8_t *pub, + void *ctx, + const mp_limb_t *k2, + size_t length, + const uint8_t *msg, + uint8_t *signature, + mp_limb_t *scratch); + +mp_size_t +_eddsa_verify_itch (const struct ecc_curve *ecc); + +int +_eddsa_verify (const struct ecc_curve *ecc, + const struct nettle_hash *H, + const uint8_t *pub, + const mp_limb_t *A, + void *ctx, + size_t length, + const uint8_t *msg, + const uint8_t *signature, + mp_limb_t *scratch); + +void +_eddsa_expand_key (const struct ecc_curve *ecc, + const struct nettle_hash *H, + void *ctx, + const uint8_t *key, + uint8_t *digest, + mp_limb_t *k2); + +mp_size_t +_eddsa_public_key_itch (const struct ecc_curve *ecc); + +void +_eddsa_public_key (const struct ecc_curve *ecc, + const mp_limb_t *k, uint8_t *pub, mp_limb_t *scratch); + + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_EDDSA_H */ diff --git a/include/nettle/gcm.h b/include/nettle/gcm.h new file mode 100644 index 0000000..766019a --- /dev/null +++ b/include/nettle/gcm.h @@ -0,0 +1,327 @@ +/* gcm.h + + Galois counter mode, specified by NIST, + http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf + + Copyright (C) 2011 Katholieke Universiteit Leuven + Copyright (C) 2011, 2014 Niels M枚ller + + Contributed by Nikos Mavrogiannopoulos + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_GCM_H_INCLUDED +#define NETTLE_GCM_H_INCLUDED + +#include "aes.h" +#include "camellia.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define gcm_set_key nettle_gcm_set_key +#define gcm_set_iv nettle_gcm_set_iv +#define gcm_update nettle_gcm_update +#define gcm_encrypt nettle_gcm_encrypt +#define gcm_decrypt nettle_gcm_decrypt +#define gcm_digest nettle_gcm_digest + +#define gcm_aes128_set_key nettle_gcm_aes128_set_key +#define gcm_aes128_set_iv nettle_gcm_aes128_set_iv +#define gcm_aes128_update nettle_gcm_aes128_update +#define gcm_aes128_encrypt nettle_gcm_aes128_encrypt +#define gcm_aes128_decrypt nettle_gcm_aes128_decrypt +#define gcm_aes128_digest nettle_gcm_aes128_digest + +#define gcm_aes192_set_key nettle_gcm_aes192_set_key +#define gcm_aes192_set_iv nettle_gcm_aes192_set_iv +#define gcm_aes192_update nettle_gcm_aes192_update +#define gcm_aes192_encrypt nettle_gcm_aes192_encrypt +#define gcm_aes192_decrypt nettle_gcm_aes192_decrypt +#define gcm_aes192_digest nettle_gcm_aes192_digest + +#define gcm_aes256_set_key nettle_gcm_aes256_set_key +#define gcm_aes256_set_iv nettle_gcm_aes256_set_iv +#define gcm_aes256_update nettle_gcm_aes256_update +#define gcm_aes256_encrypt nettle_gcm_aes256_encrypt +#define gcm_aes256_decrypt nettle_gcm_aes256_decrypt +#define gcm_aes256_digest nettle_gcm_aes256_digest + +#define gcm_aes_set_key nettle_gcm_aes_set_key +#define gcm_aes_set_iv nettle_gcm_aes_set_iv +#define gcm_aes_update nettle_gcm_aes_update +#define gcm_aes_encrypt nettle_gcm_aes_encrypt +#define gcm_aes_decrypt nettle_gcm_aes_decrypt +#define gcm_aes_digest nettle_gcm_aes_digest + +#define gcm_camellia128_set_key nettle_gcm_camellia128_set_key +#define gcm_camellia128_set_iv nettle_gcm_camellia128_set_iv +#define gcm_camellia128_update nettle_gcm_camellia128_update +#define gcm_camellia128_encrypt nettle_gcm_camellia128_encrypt +#define gcm_camellia128_decrypt nettle_gcm_camellia128_decrypt +#define gcm_camellia128_digest nettle_gcm_camellia128_digest + +#define gcm_camellia256_set_key nettle_gcm_camellia256_set_key +#define gcm_camellia256_set_iv nettle_gcm_camellia256_set_iv +#define gcm_camellia256_update nettle_gcm_camellia256_update +#define gcm_camellia256_encrypt nettle_gcm_camellia256_encrypt +#define gcm_camellia256_decrypt nettle_gcm_camellia256_decrypt +#define gcm_camellia256_digest nettle_gcm_camellia256_digest + +#define GCM_BLOCK_SIZE 16 +#define GCM_IV_SIZE (GCM_BLOCK_SIZE - 4) +#define GCM_DIGEST_SIZE 16 +#define GCM_TABLE_BITS 8 + +/* Hashing subkey */ +struct gcm_key +{ + union nettle_block16 h[1 << GCM_TABLE_BITS]; +}; + +/* Per-message state, depending on the iv */ +struct gcm_ctx { + /* Original counter block */ + union nettle_block16 iv; + /* Updated for each block. */ + union nettle_block16 ctr; + /* Hashing state */ + union nettle_block16 x; + uint64_t auth_size; + uint64_t data_size; +}; + +void +gcm_set_key(struct gcm_key *key, + const void *cipher, nettle_cipher_func *f); + +void +gcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key, + size_t length, const uint8_t *iv); + +void +gcm_update(struct gcm_ctx *ctx, const struct gcm_key *key, + size_t length, const uint8_t *data); + +void +gcm_encrypt(struct gcm_ctx *ctx, const struct gcm_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key, + const void *cipher, nettle_cipher_func *f, + size_t length, uint8_t *digest); + +/* Convenience macrology (not sure how useful it is) */ +/* All-in-one context, with hash subkey, message state, and cipher. */ +#define GCM_CTX(type) \ + { struct gcm_key key; struct gcm_ctx gcm; type cipher; } + +/* NOTE: Avoid using NULL, as we don't include anything defining it. */ +#define GCM_SET_KEY(ctx, set_key, encrypt, gcm_key) \ + do { \ + (set_key)(&(ctx)->cipher, (gcm_key)); \ + if (0) (encrypt)(&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0); \ + gcm_set_key(&(ctx)->key, &(ctx)->cipher, \ + (nettle_cipher_func *) (encrypt)); \ + } while (0) + +#define GCM_SET_IV(ctx, length, data) \ + gcm_set_iv(&(ctx)->gcm, &(ctx)->key, (length), (data)) + +#define GCM_UPDATE(ctx, length, data) \ + gcm_update(&(ctx)->gcm, &(ctx)->key, (length), (data)) + +#define GCM_ENCRYPT(ctx, encrypt, length, dst, src) \ + (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : gcm_encrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \ + (nettle_cipher_func *) (encrypt), \ + (length), (dst), (src))) + +#define GCM_DECRYPT(ctx, encrypt, length, dst, src) \ + (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : gcm_decrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \ + (nettle_cipher_func *) (encrypt), \ + (length), (dst), (src))) + +#define GCM_DIGEST(ctx, encrypt, length, digest) \ + (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \ + (uint8_t *) 0, (const uint8_t *) 0) \ + : gcm_digest(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \ + (nettle_cipher_func *) (encrypt), \ + (length), (digest))) + +struct gcm_aes128_ctx GCM_CTX(struct aes128_ctx); + +void +gcm_aes128_set_key(struct gcm_aes128_ctx *ctx, const uint8_t *key); + +/* FIXME: Define _update and _set_iv as some kind of aliaes, + there's nothing aes-specific. */ +void +gcm_aes128_update (struct gcm_aes128_ctx *ctx, + size_t length, const uint8_t *data); +void +gcm_aes128_set_iv (struct gcm_aes128_ctx *ctx, + size_t length, const uint8_t *iv); + +void +gcm_aes128_encrypt(struct gcm_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes128_decrypt(struct gcm_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes128_digest(struct gcm_aes128_ctx *ctx, + size_t length, uint8_t *digest); + +struct gcm_aes192_ctx GCM_CTX(struct aes192_ctx); + +void +gcm_aes192_set_key(struct gcm_aes192_ctx *ctx, const uint8_t *key); + +void +gcm_aes192_update (struct gcm_aes192_ctx *ctx, + size_t length, const uint8_t *data); +void +gcm_aes192_set_iv (struct gcm_aes192_ctx *ctx, + size_t length, const uint8_t *iv); + +void +gcm_aes192_encrypt(struct gcm_aes192_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes192_decrypt(struct gcm_aes192_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes192_digest(struct gcm_aes192_ctx *ctx, + size_t length, uint8_t *digest); + +struct gcm_aes256_ctx GCM_CTX(struct aes256_ctx); + +void +gcm_aes256_set_key(struct gcm_aes256_ctx *ctx, const uint8_t *key); + +void +gcm_aes256_update (struct gcm_aes256_ctx *ctx, + size_t length, const uint8_t *data); +void +gcm_aes256_set_iv (struct gcm_aes256_ctx *ctx, + size_t length, const uint8_t *iv); + +void +gcm_aes256_encrypt(struct gcm_aes256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes256_decrypt(struct gcm_aes256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes256_digest(struct gcm_aes256_ctx *ctx, + size_t length, uint8_t *digest); + +/* Old aes interface, for backwards compatibility */ +struct gcm_aes_ctx GCM_CTX(struct aes_ctx); + +void +gcm_aes_set_key(struct gcm_aes_ctx *ctx, + size_t length, const uint8_t *key); + +void +gcm_aes_set_iv(struct gcm_aes_ctx *ctx, + size_t length, const uint8_t *iv); + +void +gcm_aes_update(struct gcm_aes_ctx *ctx, + size_t length, const uint8_t *data); + +void +gcm_aes_encrypt(struct gcm_aes_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes_decrypt(struct gcm_aes_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); + +void +gcm_aes_digest(struct gcm_aes_ctx *ctx, size_t length, uint8_t *digest); + + +struct gcm_camellia128_ctx GCM_CTX(struct camellia128_ctx); + +void gcm_camellia128_set_key(struct gcm_camellia128_ctx *ctx, + const uint8_t *key); +void gcm_camellia128_set_iv(struct gcm_camellia128_ctx *ctx, + size_t length, const uint8_t *iv); +void gcm_camellia128_update(struct gcm_camellia128_ctx *ctx, + size_t length, const uint8_t *data); +void gcm_camellia128_encrypt(struct gcm_camellia128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); +void gcm_camellia128_decrypt(struct gcm_camellia128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); +void gcm_camellia128_digest(struct gcm_camellia128_ctx *ctx, + size_t length, uint8_t *digest); + + +struct gcm_camellia256_ctx GCM_CTX(struct camellia256_ctx); + +void gcm_camellia256_set_key(struct gcm_camellia256_ctx *ctx, + const uint8_t *key); +void gcm_camellia256_set_iv(struct gcm_camellia256_ctx *ctx, + size_t length, const uint8_t *iv); +void gcm_camellia256_update(struct gcm_camellia256_ctx *ctx, + size_t length, const uint8_t *data); +void gcm_camellia256_encrypt(struct gcm_camellia256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); +void gcm_camellia256_decrypt(struct gcm_camellia256_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src); +void gcm_camellia256_digest(struct gcm_camellia256_ctx *ctx, + size_t length, uint8_t *digest); + + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_GCM_H_INCLUDED */ diff --git a/include/nettle/gosthash94.h b/include/nettle/gosthash94.h new file mode 100644 index 0000000..8e9d49f --- /dev/null +++ b/include/nettle/gosthash94.h @@ -0,0 +1,98 @@ +/* gosthash94.h + + The GOST R 34.11-94 hash function, described in RFC 5831. + + Copyright (C) 2012 Nikos Mavrogiannopoulos, Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* Based on rhash gost.h. */ + +/* Copyright: 2009-2012 Aleksey Kravchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Ported to nettle by Nikos Mavrogiannopoulos. + */ + +#ifndef NETTLE_GOSTHASH94_H_INCLUDED +#define NETTLE_GOSTHASH94_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define gosthash94_init nettle_gosthash94_init +#define gosthash94_update nettle_gosthash94_update +#define gosthash94_digest nettle_gosthash94_digest + +#define GOSTHASH94_BLOCK_SIZE 32 +#define GOSTHASH94_DIGEST_SIZE 32 +/* For backwards compatibility */ +#define GOSTHASH94_DATA_SIZE GOSTHASH94_BLOCK_SIZE + +struct gosthash94_ctx +{ + uint32_t hash[8]; /* algorithm 256-bit state */ + uint32_t sum[8]; /* sum of processed message blocks */ + uint8_t message[GOSTHASH94_BLOCK_SIZE]; /* 256-bit buffer for leftovers */ + uint64_t length; /* number of processed bytes */ +}; + +void gosthash94_init(struct gosthash94_ctx *ctx); +void gosthash94_update(struct gosthash94_ctx *ctx, + size_t length, const uint8_t *msg); +void gosthash94_digest(struct gosthash94_ctx *ctx, + size_t length, uint8_t *result); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_GOSTHASH94_H_INCLUDED */ diff --git a/include/nettle/hkdf.h b/include/nettle/hkdf.h new file mode 100644 index 0000000..43b16ad --- /dev/null +++ b/include/nettle/hkdf.h @@ -0,0 +1,67 @@ +/* hkdf.h + + TLS PRF code (RFC-5246, RFC-2246). + + Copyright (C) 2017 Red Hat, Inc. + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_HKDF_H_INCLUDED +#define NETTLE_HKDF_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Namespace mangling */ +#define hkdf_extract nettle_hkdf_extract +#define hkdf_expand nettle_hkdf_expand + +void +hkdf_extract(void *mac_ctx, + nettle_hash_update_func *update, + nettle_hash_digest_func *digest, + size_t digest_size, + size_t secret_size, const uint8_t *secret, + uint8_t *dst); + +void +hkdf_expand(void *mac_ctx, + nettle_hash_update_func *update, + nettle_hash_digest_func *digest, + size_t digest_size, + size_t info_size, const uint8_t *info, + size_t length, uint8_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_HKDF_H_INCLUDED */ diff --git a/include/nettle/hmac.h b/include/nettle/hmac.h new file mode 100644 index 0000000..40a8e77 --- /dev/null +++ b/include/nettle/hmac.h @@ -0,0 +1,210 @@ +/* hmac.h + + HMAC message authentication code (RFC-2104). + + Copyright (C) 2001, 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_HMAC_H_INCLUDED +#define NETTLE_HMAC_H_INCLUDED + +#include "nettle-meta.h" + +#include "md5.h" +#include "ripemd160.h" +#include "sha1.h" +#include "sha2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Namespace mangling */ +#define hmac_set_key nettle_hmac_set_key +#define hmac_update nettle_hmac_update +#define hmac_digest nettle_hmac_digest +#define hmac_md5_set_key nettle_hmac_md5_set_key +#define hmac_md5_update nettle_hmac_md5_update +#define hmac_md5_digest nettle_hmac_md5_digest +#define hmac_ripemd160_set_key nettle_hmac_ripemd160_set_key +#define hmac_ripemd160_update nettle_hmac_ripemd160_update +#define hmac_ripemd160_digest nettle_hmac_ripemd160_digest +#define hmac_sha1_set_key nettle_hmac_sha1_set_key +#define hmac_sha1_update nettle_hmac_sha1_update +#define hmac_sha1_digest nettle_hmac_sha1_digest +#define hmac_sha224_set_key nettle_hmac_sha224_set_key +#define hmac_sha224_digest nettle_hmac_sha224_digest +#define hmac_sha256_set_key nettle_hmac_sha256_set_key +#define hmac_sha256_update nettle_hmac_sha256_update +#define hmac_sha256_digest nettle_hmac_sha256_digest +#define hmac_sha384_set_key nettle_hmac_sha384_set_key +#define hmac_sha384_digest nettle_hmac_sha384_digest +#define hmac_sha512_set_key nettle_hmac_sha512_set_key +#define hmac_sha512_update nettle_hmac_sha512_update +#define hmac_sha512_digest nettle_hmac_sha512_digest + +void +hmac_set_key(void *outer, void *inner, void *state, + const struct nettle_hash *hash, + size_t length, const uint8_t *key); + +/* This function is not strictly needed, it's s just the same as the + * hash update function. */ +void +hmac_update(void *state, + const struct nettle_hash *hash, + size_t length, const uint8_t *data); + +void +hmac_digest(const void *outer, const void *inner, void *state, + const struct nettle_hash *hash, + size_t length, uint8_t *digest); + + +#define HMAC_CTX(type) \ +{ type outer; type inner; type state; } + +#define HMAC_SET_KEY(ctx, hash, length, key) \ + hmac_set_key( &(ctx)->outer, &(ctx)->inner, &(ctx)->state, \ + (hash), (length), (key) ) + +#define HMAC_DIGEST(ctx, hash, length, digest) \ + hmac_digest( &(ctx)->outer, &(ctx)->inner, &(ctx)->state, \ + (hash), (length), (digest) ) + +/* HMAC using specific hash functions */ + +/* hmac-md5 */ +struct hmac_md5_ctx HMAC_CTX(struct md5_ctx); + +void +hmac_md5_set_key(struct hmac_md5_ctx *ctx, + size_t key_length, const uint8_t *key); + +void +hmac_md5_update(struct hmac_md5_ctx *ctx, + size_t length, const uint8_t *data); + +void +hmac_md5_digest(struct hmac_md5_ctx *ctx, + size_t length, uint8_t *digest); + + +/* hmac-ripemd160 */ +struct hmac_ripemd160_ctx HMAC_CTX(struct ripemd160_ctx); + +void +hmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx, + size_t key_length, const uint8_t *key); + +void +hmac_ripemd160_update(struct hmac_ripemd160_ctx *ctx, + size_t length, const uint8_t *data); + +void +hmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx, + size_t length, uint8_t *digest); + + +/* hmac-sha1 */ +struct hmac_sha1_ctx HMAC_CTX(struct sha1_ctx); + +void +hmac_sha1_set_key(struct hmac_sha1_ctx *ctx, + size_t key_length, const uint8_t *key); + +void +hmac_sha1_update(struct hmac_sha1_ctx *ctx, + size_t length, const uint8_t *data); + +void +hmac_sha1_digest(struct hmac_sha1_ctx *ctx, + size_t length, uint8_t *digest); + +/* hmac-sha256 */ +struct hmac_sha256_ctx HMAC_CTX(struct sha256_ctx); + +void +hmac_sha256_set_key(struct hmac_sha256_ctx *ctx, + size_t key_length, const uint8_t *key); + +void +hmac_sha256_update(struct hmac_sha256_ctx *ctx, + size_t length, const uint8_t *data); + +void +hmac_sha256_digest(struct hmac_sha256_ctx *ctx, + size_t length, uint8_t *digest); + +/* hmac-sha224 */ +#define hmac_sha224_ctx hmac_sha256_ctx + +void +hmac_sha224_set_key(struct hmac_sha224_ctx *ctx, + size_t key_length, const uint8_t *key); + +#define hmac_sha224_update nettle_hmac_sha256_update + +void +hmac_sha224_digest(struct hmac_sha224_ctx *ctx, + size_t length, uint8_t *digest); + +/* hmac-sha512 */ +struct hmac_sha512_ctx HMAC_CTX(struct sha512_ctx); + +void +hmac_sha512_set_key(struct hmac_sha512_ctx *ctx, + size_t key_length, const uint8_t *key); + +void +hmac_sha512_update(struct hmac_sha512_ctx *ctx, + size_t length, const uint8_t *data); + +void +hmac_sha512_digest(struct hmac_sha512_ctx *ctx, + size_t length, uint8_t *digest); + +/* hmac-sha384 */ +#define hmac_sha384_ctx hmac_sha512_ctx + +void +hmac_sha384_set_key(struct hmac_sha512_ctx *ctx, + size_t key_length, const uint8_t *key); + +#define hmac_sha384_update nettle_hmac_sha512_update + +void +hmac_sha384_digest(struct hmac_sha512_ctx *ctx, + size_t length, uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_HMAC_H_INCLUDED */ diff --git a/include/nettle/knuth-lfib.h b/include/nettle/knuth-lfib.h new file mode 100644 index 0000000..df0b495 --- /dev/null +++ b/include/nettle/knuth-lfib.h @@ -0,0 +1,80 @@ +/* knuth-lfib.h + + The "lagged fibonacci" pseudorandomness generator, described in + Knuth, TAoCP, 3.6 + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* NOTE: This generator is totally inappropriate for cryptographic + * applications. It is useful for generating deterministic but + * random-looking test data, and is used by the Nettle testsuite. */ +#ifndef NETTLE_KNUTH_LFIB_H_INCLUDED +#define NETTLE_KNUTH_LFIB_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Namespace mangling */ +#define knuth_lfib_init nettle_knuth_lfib_init +#define knuth_lfib_get nettle_knuth_lfib_get +#define knuth_lfib_get_array nettle_knuth_lfib_get_array +#define knuth_lfib_random nettle_knuth_lfib_random + +#define _KNUTH_LFIB_KK 100 + +struct knuth_lfib_ctx +{ + uint32_t x[_KNUTH_LFIB_KK]; + unsigned index; +}; + +void +knuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed); + +/* Get's a single number in the range 0 ... 2^30-1 */ +uint32_t +knuth_lfib_get(struct knuth_lfib_ctx *ctx); + +/* Get an array of numbers */ +void +knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, + size_t n, uint32_t *a); + +/* Get an array of octets. */ +void +knuth_lfib_random(struct knuth_lfib_ctx *ctx, + size_t n, uint8_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */ diff --git a/include/nettle/macros.h b/include/nettle/macros.h new file mode 100644 index 0000000..990d32e --- /dev/null +++ b/include/nettle/macros.h @@ -0,0 +1,245 @@ +/* macros.h + + Copyright (C) 2001, 2010 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MACROS_H_INCLUDED +#define NETTLE_MACROS_H_INCLUDED + +/* Reads a 64-bit integer, in network, big-endian, byte order */ +#define READ_UINT64(p) \ +( (((uint64_t) (p)[0]) << 56) \ + | (((uint64_t) (p)[1]) << 48) \ + | (((uint64_t) (p)[2]) << 40) \ + | (((uint64_t) (p)[3]) << 32) \ + | (((uint64_t) (p)[4]) << 24) \ + | (((uint64_t) (p)[5]) << 16) \ + | (((uint64_t) (p)[6]) << 8) \ + | ((uint64_t) (p)[7])) + +#define WRITE_UINT64(p, i) \ +do { \ + (p)[0] = ((i) >> 56) & 0xff; \ + (p)[1] = ((i) >> 48) & 0xff; \ + (p)[2] = ((i) >> 40) & 0xff; \ + (p)[3] = ((i) >> 32) & 0xff; \ + (p)[4] = ((i) >> 24) & 0xff; \ + (p)[5] = ((i) >> 16) & 0xff; \ + (p)[6] = ((i) >> 8) & 0xff; \ + (p)[7] = (i) & 0xff; \ +} while(0) + +/* Reads a 32-bit integer, in network, big-endian, byte order */ +#define READ_UINT32(p) \ +( (((uint32_t) (p)[0]) << 24) \ + | (((uint32_t) (p)[1]) << 16) \ + | (((uint32_t) (p)[2]) << 8) \ + | ((uint32_t) (p)[3])) + +#define WRITE_UINT32(p, i) \ +do { \ + (p)[0] = ((i) >> 24) & 0xff; \ + (p)[1] = ((i) >> 16) & 0xff; \ + (p)[2] = ((i) >> 8) & 0xff; \ + (p)[3] = (i) & 0xff; \ +} while(0) + +/* Analogous macros, for 24 and 16 bit numbers */ +#define READ_UINT24(p) \ +( (((uint32_t) (p)[0]) << 16) \ + | (((uint32_t) (p)[1]) << 8) \ + | ((uint32_t) (p)[2])) + +#define WRITE_UINT24(p, i) \ +do { \ + (p)[0] = ((i) >> 16) & 0xff; \ + (p)[1] = ((i) >> 8) & 0xff; \ + (p)[2] = (i) & 0xff; \ +} while(0) + +#define READ_UINT16(p) \ +( (((uint32_t) (p)[0]) << 8) \ + | ((uint32_t) (p)[1])) + +#define WRITE_UINT16(p, i) \ +do { \ + (p)[0] = ((i) >> 8) & 0xff; \ + (p)[1] = (i) & 0xff; \ +} while(0) + +/* And the other, little-endian, byteorder */ +#define LE_READ_UINT64(p) \ +( (((uint64_t) (p)[7]) << 56) \ + | (((uint64_t) (p)[6]) << 48) \ + | (((uint64_t) (p)[5]) << 40) \ + | (((uint64_t) (p)[4]) << 32) \ + | (((uint64_t) (p)[3]) << 24) \ + | (((uint64_t) (p)[2]) << 16) \ + | (((uint64_t) (p)[1]) << 8) \ + | ((uint64_t) (p)[0])) + +#define LE_WRITE_UINT64(p, i) \ +do { \ + (p)[7] = ((i) >> 56) & 0xff; \ + (p)[6] = ((i) >> 48) & 0xff; \ + (p)[5] = ((i) >> 40) & 0xff; \ + (p)[4] = ((i) >> 32) & 0xff; \ + (p)[3] = ((i) >> 24) & 0xff; \ + (p)[2] = ((i) >> 16) & 0xff; \ + (p)[1] = ((i) >> 8) & 0xff; \ + (p)[0] = (i) & 0xff; \ +} while (0) + +#define LE_READ_UINT32(p) \ +( (((uint32_t) (p)[3]) << 24) \ + | (((uint32_t) (p)[2]) << 16) \ + | (((uint32_t) (p)[1]) << 8) \ + | ((uint32_t) (p)[0])) + +#define LE_WRITE_UINT32(p, i) \ +do { \ + (p)[3] = ((i) >> 24) & 0xff; \ + (p)[2] = ((i) >> 16) & 0xff; \ + (p)[1] = ((i) >> 8) & 0xff; \ + (p)[0] = (i) & 0xff; \ +} while(0) + +/* Analogous macros, for 16 bit numbers */ +#define LE_READ_UINT16(p) \ + ( (((uint32_t) (p)[1]) << 8) \ + | ((uint32_t) (p)[0])) + +#define LE_WRITE_UINT16(p, i) \ + do { \ + (p)[1] = ((i) >> 8) & 0xff; \ + (p)[0] = (i) & 0xff; \ + } while(0) + +/* Macro to make it easier to loop over several blocks. */ +#define FOR_BLOCKS(length, dst, src, blocksize) \ + assert( !((length) % (blocksize))); \ + for (; (length); ((length) -= (blocksize), \ + (dst) += (blocksize), \ + (src) += (blocksize)) ) + +/* The masking of the right shift is needed to allow n == 0 (using + just 32 - n and 64 - n results in undefined behaviour). Most uses + of these macros use a constant and non-zero rotation count. */ +#define ROTL32(n,x) (((x)<<(n)) | ((x)>>((-(n)&31)))) + +#define ROTL64(n,x) (((x)<<(n)) | ((x)>>((-(n))&63))) + +/* Requires that size > 0 */ +#define INCREMENT(size, ctr) \ + do { \ + unsigned increment_i = (size) - 1; \ + if (++(ctr)[increment_i] == 0) \ + while (increment_i > 0 \ + && ++(ctr)[--increment_i] == 0 ) \ + ; \ + } while (0) + + +/* Helper macro for Merkle-Damg氓rd hash functions. Assumes the context + structs includes the following fields: + + uint8_t block[...]; // Buffer holding one block + unsigned int index; // Index into block +*/ + +/* Currently used by sha512 (and sha384) only. */ +#define MD_INCR(ctx) ((ctx)->count_high += !++(ctx)->count_low) + +/* Takes the compression function f as argument. NOTE: also clobbers + length and data. */ +#define MD_UPDATE(ctx, length, data, f, incr) \ + do { \ + if ((ctx)->index) \ + { \ + /* Try to fill partial block */ \ + unsigned __md_left = sizeof((ctx)->block) - (ctx)->index; \ + if ((length) < __md_left) \ + { \ + memcpy((ctx)->block + (ctx)->index, (data), (length)); \ + (ctx)->index += (length); \ + goto __md_done; /* Finished */ \ + } \ + else \ + { \ + memcpy((ctx)->block + (ctx)->index, (data), __md_left); \ + \ + f((ctx), (ctx)->block); \ + (incr); \ + \ + (data) += __md_left; \ + (length) -= __md_left; \ + } \ + } \ + while ((length) >= sizeof((ctx)->block)) \ + { \ + f((ctx), (data)); \ + (incr); \ + \ + (data) += sizeof((ctx)->block); \ + (length) -= sizeof((ctx)->block); \ + } \ + memcpy ((ctx)->block, (data), (length)); \ + (ctx)->index = (length); \ + __md_done: \ + ; \ + } while (0) + +/* Pads the block to a block boundary with the bit pattern 1 0*, + leaving size octets for the length field at the end. If needed, + compresses the block and starts a new one. */ +#define MD_PAD(ctx, size, f) \ + do { \ + unsigned __md_i; \ + __md_i = (ctx)->index; \ + \ + /* Set the first char of padding to 0x80. This is safe since there \ + is always at least one byte free */ \ + \ + assert(__md_i < sizeof((ctx)->block)); \ + (ctx)->block[__md_i++] = 0x80; \ + \ + if (__md_i > (sizeof((ctx)->block) - (size))) \ + { /* No room for length in this block. Process it and \ + pad with another one */ \ + memset((ctx)->block + __md_i, 0, sizeof((ctx)->block) - __md_i); \ + \ + f((ctx), (ctx)->block); \ + __md_i = 0; \ + } \ + memset((ctx)->block + __md_i, 0, \ + sizeof((ctx)->block) - (size) - __md_i); \ + \ + } while (0) + +#endif /* NETTLE_MACROS_H_INCLUDED */ diff --git a/include/nettle/md2.h b/include/nettle/md2.h new file mode 100644 index 0000000..560b2cb --- /dev/null +++ b/include/nettle/md2.h @@ -0,0 +1,79 @@ +/* md2.h + + The MD2 hash function, described in RFC 1319. + + Copyright (C) 2003 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MD2_H_INCLUDED +#define NETTLE_MD2_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define md2_init nettle_md2_init +#define md2_update nettle_md2_update +#define md2_digest nettle_md2_digest + +#define MD2_DIGEST_SIZE 16 +#define MD2_BLOCK_SIZE 16 +/* For backwards compatibility */ +#define MD2_DATA_SIZE MD2_BLOCK_SIZE + +struct md2_ctx +{ + uint8_t C[MD2_BLOCK_SIZE]; + uint8_t X[3 * MD2_BLOCK_SIZE]; + uint8_t block[MD2_BLOCK_SIZE]; /* Block buffer */ + unsigned index; /* Into buffer */ +}; + +void +md2_init(struct md2_ctx *ctx); + +void +md2_update(struct md2_ctx *ctx, + size_t length, + const uint8_t *data); + +void +md2_digest(struct md2_ctx *ctx, + size_t length, + uint8_t *digest); + + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MD2_H_INCLUDED */ diff --git a/include/nettle/md4.h b/include/nettle/md4.h new file mode 100644 index 0000000..f199a80 --- /dev/null +++ b/include/nettle/md4.h @@ -0,0 +1,83 @@ +/* md4.h + + The MD4 hash function, described in RFC 1320. + + Copyright (C) 2003 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MD4_H_INCLUDED +#define NETTLE_MD4_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define md4_init nettle_md4_init +#define md4_update nettle_md4_update +#define md4_digest nettle_md4_digest + +#define MD4_DIGEST_SIZE 16 +#define MD4_BLOCK_SIZE 64 +/* For backwards compatibility */ +#define MD4_DATA_SIZE MD4_BLOCK_SIZE + +/* Digest is kept internally as 4 32-bit words. */ +#define _MD4_DIGEST_LENGTH 4 + +/* FIXME: Identical to md5_ctx */ +struct md4_ctx +{ + uint32_t state[_MD4_DIGEST_LENGTH]; + uint64_t count; /* Block count */ + uint8_t block[MD4_BLOCK_SIZE]; /* Block buffer */ + unsigned index; /* Into buffer */ +}; + +void +md4_init(struct md4_ctx *ctx); + +void +md4_update(struct md4_ctx *ctx, + size_t length, + const uint8_t *data); + +void +md4_digest(struct md4_ctx *ctx, + size_t length, + uint8_t *digest); + + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MD4_H_INCLUDED */ diff --git a/include/nettle/md5-compat.h b/include/nettle/md5-compat.h new file mode 100644 index 0000000..fd30982 --- /dev/null +++ b/include/nettle/md5-compat.h @@ -0,0 +1,58 @@ +/* md5-compat.h + + The md5 hash function, RFC 1321-style interface. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MD5_COMPAT_H_INCLUDED +#define NETTLE_MD5_COMPAT_H_INCLUDED + +#include "md5.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define MD5Init nettle_MD5Init +#define MD5Update nettle_MD5Update +#define MD5Final nettle_MD5Final + +typedef struct md5_ctx MD5_CTX; + +void MD5Init(MD5_CTX *ctx); +void MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length); +void MD5Final(unsigned char *out, MD5_CTX *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MD5_COMPAT_H_INCLUDED */ diff --git a/include/nettle/md5.h b/include/nettle/md5.h new file mode 100644 index 0000000..040cf9d --- /dev/null +++ b/include/nettle/md5.h @@ -0,0 +1,86 @@ +/* md5.h + + The MD5 hash function, described in RFC 1321. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MD5_H_INCLUDED +#define NETTLE_MD5_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define md5_init nettle_md5_init +#define md5_update nettle_md5_update +#define md5_digest nettle_md5_digest + +#define MD5_DIGEST_SIZE 16 +#define MD5_BLOCK_SIZE 64 +/* For backwards compatibility */ +#define MD5_DATA_SIZE MD5_BLOCK_SIZE + +/* Digest is kept internally as 4 32-bit words. */ +#define _MD5_DIGEST_LENGTH 4 + +struct md5_ctx +{ + uint32_t state[_MD5_DIGEST_LENGTH]; + uint64_t count; /* Block count */ + uint8_t block[MD5_BLOCK_SIZE]; /* Block buffer */ + unsigned index; /* Into buffer */ +}; + +void +md5_init(struct md5_ctx *ctx); + +void +md5_update(struct md5_ctx *ctx, + size_t length, + const uint8_t *data); + +void +md5_digest(struct md5_ctx *ctx, + size_t length, + uint8_t *digest); + +/* Internal compression function. STATE points to 4 uint32_t words, + and DATA points to 64 bytes of input data, possibly unaligned. */ +void +_nettle_md5_compress(uint32_t *state, const uint8_t *data); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MD5_H_INCLUDED */ diff --git a/include/nettle/memops.h b/include/nettle/memops.h new file mode 100644 index 0000000..815d547 --- /dev/null +++ b/include/nettle/memops.h @@ -0,0 +1,57 @@ +/* memops.h + + Copyright (C) 2016 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_MEMOPS_H_INCLUDED +#define NETTLE_MEMOPS_H_INCLUDED + +#include "memxor.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define cnd_memcpy nettle_cnd_memcpy +#define memeql_sec nettle_memeql_sec + +int +memeql_sec (const void *a, const void *b, size_t n); + +/* Side-channel silent conditional memcpy. cnd must be 0 (nop) or 1 + (copy). */ +void +cnd_memcpy(int cnd, volatile void *dst, const volatile void *src, size_t n); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MEMOPS_H_INCLUDED */ diff --git a/include/nettle/memxor.h b/include/nettle/memxor.h new file mode 100644 index 0000000..b7bef09 --- /dev/null +++ b/include/nettle/memxor.h @@ -0,0 +1,25 @@ +/* memxor.h + * + */ + +#ifndef NETTLE_MEMXOR_H_INCLUDED +#define NETTLE_MEMXOR_H_INCLUDED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define memxor nettle_memxor +#define memxor3 nettle_memxor3 + +void *memxor(void *dst, const void *src, size_t n); +void *memxor3(void *dst, const void *a, const void *b, size_t n); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_MEMXOR_H_INCLUDED */ diff --git a/include/nettle/nettle-meta.h b/include/nettle/nettle-meta.h new file mode 100644 index 0000000..0d16a2b --- /dev/null +++ b/include/nettle/nettle-meta.h @@ -0,0 +1,277 @@ +/* nettle-meta.h + + Information about algorithms. + + Copyright (C) 2002, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_META_H_INCLUDED +#define NETTLE_META_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +struct nettle_cipher +{ + const char *name; + + unsigned context_size; + + /* Zero for stream ciphers */ + unsigned block_size; + + /* Suggested key size; other sizes are sometimes possible. */ + unsigned key_size; + + nettle_set_key_func *set_encrypt_key; + nettle_set_key_func *set_decrypt_key; + + nettle_cipher_func *encrypt; + nettle_cipher_func *decrypt; +}; + +/* FIXME: Rename with leading underscore, but keep current name (and + size!) for now, for ABI compatibility with nettle-3.1, soname + libnettle.so.6. */ +/* null-terminated list of ciphers implemented by this version of nettle */ +extern const struct nettle_cipher * const nettle_ciphers[]; + +const struct nettle_cipher * const * +#ifdef __GNUC__ +__attribute__((pure)) +#endif +nettle_get_ciphers (void); + +#define nettle_ciphers (nettle_get_ciphers()) + +extern const struct nettle_cipher nettle_aes128; +extern const struct nettle_cipher nettle_aes192; +extern const struct nettle_cipher nettle_aes256; + +extern const struct nettle_cipher nettle_camellia128; +extern const struct nettle_cipher nettle_camellia192; +extern const struct nettle_cipher nettle_camellia256; + +extern const struct nettle_cipher nettle_cast128; + +extern const struct nettle_cipher nettle_serpent128; +extern const struct nettle_cipher nettle_serpent192; +extern const struct nettle_cipher nettle_serpent256; + +extern const struct nettle_cipher nettle_twofish128; +extern const struct nettle_cipher nettle_twofish192; +extern const struct nettle_cipher nettle_twofish256; + +extern const struct nettle_cipher nettle_arctwo40; +extern const struct nettle_cipher nettle_arctwo64; +extern const struct nettle_cipher nettle_arctwo128; +extern const struct nettle_cipher nettle_arctwo_gutmann128; + +struct nettle_hash +{ + const char *name; + + /* Size of the context struct */ + unsigned context_size; + + /* Size of digests */ + unsigned digest_size; + + /* Internal block size */ + unsigned block_size; + + nettle_hash_init_func *init; + nettle_hash_update_func *update; + nettle_hash_digest_func *digest; +}; + +#define _NETTLE_HASH(name, NAME) { \ + #name, \ + sizeof(struct name##_ctx), \ + NAME##_DIGEST_SIZE, \ + NAME##_BLOCK_SIZE, \ + (nettle_hash_init_func *) name##_init, \ + (nettle_hash_update_func *) name##_update, \ + (nettle_hash_digest_func *) name##_digest \ +} + +/* FIXME: Rename with leading underscore, but keep current name (and + size!) for now, for ABI compatibility with nettle-3.1, soname + libnettle.so.6. */ +/* null-terminated list of digests implemented by this version of nettle */ +extern const struct nettle_hash * const nettle_hashes[]; + +const struct nettle_hash * const * +#ifdef __GNUC__ +__attribute__((pure)) +#endif +nettle_get_hashes (void); + +#define nettle_hashes (nettle_get_hashes()) + +const struct nettle_hash * +nettle_lookup_hash (const char *name); + +extern const struct nettle_hash nettle_md2; +extern const struct nettle_hash nettle_md4; +extern const struct nettle_hash nettle_md5; +extern const struct nettle_hash nettle_gosthash94; +extern const struct nettle_hash nettle_ripemd160; +extern const struct nettle_hash nettle_sha1; +extern const struct nettle_hash nettle_sha224; +extern const struct nettle_hash nettle_sha256; +extern const struct nettle_hash nettle_sha384; +extern const struct nettle_hash nettle_sha512; +extern const struct nettle_hash nettle_sha512_224; +extern const struct nettle_hash nettle_sha512_256; +extern const struct nettle_hash nettle_sha3_224; +extern const struct nettle_hash nettle_sha3_256; +extern const struct nettle_hash nettle_sha3_384; +extern const struct nettle_hash nettle_sha3_512; + +struct nettle_aead +{ + const char *name; + + unsigned context_size; + /* Block size for encrypt and decrypt. */ + unsigned block_size; + unsigned key_size; + unsigned nonce_size; + unsigned digest_size; + + nettle_set_key_func *set_encrypt_key; + nettle_set_key_func *set_decrypt_key; + nettle_set_key_func *set_nonce; + nettle_hash_update_func *update; + nettle_crypt_func *encrypt; + nettle_crypt_func *decrypt; + /* FIXME: Drop length argument? */ + nettle_hash_digest_func *digest; +}; + +/* FIXME: Rename with leading underscore, but keep current name (and + size!) for now, for ABI compatibility with nettle-3.1, soname + libnettle.so.6. */ +/* null-terminated list of aead constructions implemented by this + version of nettle */ +extern const struct nettle_aead * const nettle_aeads[]; + +const struct nettle_aead * const * +#ifdef __GNUC__ +__attribute__((pure)) +#endif +nettle_get_aeads (void); + +#define nettle_aeads (nettle_get_aeads()) + +extern const struct nettle_aead nettle_gcm_aes128; +extern const struct nettle_aead nettle_gcm_aes192; +extern const struct nettle_aead nettle_gcm_aes256; +extern const struct nettle_aead nettle_gcm_camellia128; +extern const struct nettle_aead nettle_gcm_camellia256; +extern const struct nettle_aead nettle_eax_aes128; +extern const struct nettle_aead nettle_chacha_poly1305; + +struct nettle_armor +{ + const char *name; + unsigned encode_context_size; + unsigned decode_context_size; + + unsigned encode_final_length; + + nettle_armor_init_func *encode_init; + nettle_armor_length_func *encode_length; + nettle_armor_encode_update_func *encode_update; + nettle_armor_encode_final_func *encode_final; + + nettle_armor_init_func *decode_init; + nettle_armor_length_func *decode_length; + nettle_armor_decode_update_func *decode_update; + nettle_armor_decode_final_func *decode_final; +}; + +#define _NETTLE_ARMOR(name, NAME) { \ + #name, \ + sizeof(struct name##_encode_ctx), \ + sizeof(struct name##_decode_ctx), \ + NAME##_ENCODE_FINAL_LENGTH, \ + (nettle_armor_init_func *) name##_encode_init, \ + (nettle_armor_length_func *) name##_encode_length, \ + (nettle_armor_encode_update_func *) name##_encode_update, \ + (nettle_armor_encode_final_func *) name##_encode_final, \ + (nettle_armor_init_func *) name##_decode_init, \ + (nettle_armor_length_func *) name##_decode_length, \ + (nettle_armor_decode_update_func *) name##_decode_update, \ + (nettle_armor_decode_final_func *) name##_decode_final, \ +} + +#define _NETTLE_ARMOR_0(name, NAME) { \ + #name, \ + 0, \ + sizeof(struct name##_decode_ctx), \ + NAME##_ENCODE_FINAL_LENGTH, \ + (nettle_armor_init_func *) name##_encode_init, \ + (nettle_armor_length_func *) name##_encode_length, \ + (nettle_armor_encode_update_func *) name##_encode_update, \ + (nettle_armor_encode_final_func *) name##_encode_final, \ + (nettle_armor_init_func *) name##_decode_init, \ + (nettle_armor_length_func *) name##_decode_length, \ + (nettle_armor_decode_update_func *) name##_decode_update, \ + (nettle_armor_decode_final_func *) name##_decode_final, \ +} + +/* FIXME: Rename with leading underscore, but keep current name (and + size!) for now, for ABI compatibility with nettle-3.1, soname + libnettle.so.6. */ +/* null-terminated list of armor schemes implemented by this version of nettle */ +extern const struct nettle_armor * const nettle_armors[]; + +const struct nettle_armor * const * +#ifdef __GNUC__ +__attribute__((pure)) +#endif +nettle_get_armors (void); + +#define nettle_armors (nettle_get_armors()) + +extern const struct nettle_armor nettle_base64; +extern const struct nettle_armor nettle_base64url; +extern const struct nettle_armor nettle_base16; + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_META_H_INCLUDED */ diff --git a/include/nettle/nettle-stdint.h b/include/nettle/nettle-stdint.h new file mode 100644 index 0000000..e09af32 --- /dev/null +++ b/include/nettle/nettle-stdint.h @@ -0,0 +1,286 @@ +#ifndef __NETTLE_STDINT_H +#define __NETTLE_STDINT_H 1 +#ifndef _GENERATED_STDINT_H +#define _GENERATED_STDINT_H " " +/* generated using gnu compiler gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 */ +#define _STDINT_HAVE_STDINT_H 1 + +/* ................... shortcircuit part ........................... */ + +#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H +#include +#else +#include + +/* .................... configured part ............................ */ + +/* whether we have a C99 compatible stdint header file */ +/* #undef _STDINT_HEADER_INTPTR */ +/* whether we have a C96 compatible inttypes header file */ +/* #undef _STDINT_HEADER_UINT32 */ +/* whether we have a BSD compatible inet types header */ +/* #undef _STDINT_HEADER_U_INT32 */ + +/* which 64bit typedef has been found */ +/* #undef _STDINT_HAVE_UINT64_T */ +/* #undef _STDINT_HAVE_U_INT64_T */ + +/* which type model has been detected */ +/* #undef _STDINT_CHAR_MODEL // skipped */ +/* #undef _STDINT_LONG_MODEL // skipped */ + +/* whether int_least types were detected */ +/* #undef _STDINT_HAVE_INT_LEAST32_T */ +/* whether int_fast types were detected */ +/* #undef _STDINT_HAVE_INT_FAST32_T */ +/* whether intmax_t type was detected */ +/* #undef _STDINT_HAVE_INTMAX_T */ + +/* .................... detections part ............................ */ + +/* whether we need to define bitspecific types from compiler base types */ +#ifndef _STDINT_HEADER_INTPTR +#ifndef _STDINT_HEADER_UINT32 +#ifndef _STDINT_HEADER_U_INT32 +#define _STDINT_NEED_INT_MODEL_T +#else +#define _STDINT_HAVE_U_INT_TYPES +#endif +#endif +#endif + +#ifdef _STDINT_HAVE_U_INT_TYPES +#undef _STDINT_NEED_INT_MODEL_T +#endif + +#ifdef _STDINT_CHAR_MODEL +#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124 +#ifndef _STDINT_BYTE_MODEL +#define _STDINT_BYTE_MODEL 12 +#endif +#endif +#endif + +#ifndef _STDINT_HAVE_INT_LEAST32_T +#define _STDINT_NEED_INT_LEAST_T +#endif + +#ifndef _STDINT_HAVE_INT_FAST32_T +#define _STDINT_NEED_INT_FAST_T +#endif + +#ifndef _STDINT_HEADER_INTPTR +#define _STDINT_NEED_INTPTR_T +#ifndef _STDINT_HAVE_INTMAX_T +#define _STDINT_NEED_INTMAX_T +#endif +#endif + + +/* .................... definition part ............................ */ + +/* some system headers have good uint64_t */ +#ifndef _HAVE_UINT64_T +#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T +#define _HAVE_UINT64_T +#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T +#define _HAVE_UINT64_T +typedef u_int64_t uint64_t; +#endif +#endif + +#ifndef _HAVE_UINT64_T +/* .. here are some common heuristics using compiler runtime specifics */ +#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L +#define _HAVE_UINT64_T +typedef long long int64_t; +typedef unsigned long long uint64_t; + +#elif !defined __STRICT_ANSI__ +#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ +#define _HAVE_UINT64_T +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__ +/* note: all ELF-systems seem to have loff-support which needs 64-bit */ +#if !defined _NO_LONGLONG +#define _HAVE_UINT64_T +typedef long long int64_t; +typedef unsigned long long uint64_t; +#endif + +#elif defined __alpha || (defined __mips && defined _ABIN32) +#if !defined _NO_LONGLONG +typedef long int64_t; +typedef unsigned long uint64_t; +#endif + /* compiler/cpu type to define int64_t */ +#endif +#endif +#endif + +#if defined _STDINT_HAVE_U_INT_TYPES +/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */ +typedef u_int8_t uint8_t; +typedef u_int16_t uint16_t; +typedef u_int32_t uint32_t; + +/* glibc compatibility */ +#ifndef __int8_t_defined +#define __int8_t_defined +#endif +#endif + +#ifdef _STDINT_NEED_INT_MODEL_T +/* we must guess all the basic types. Apart from byte-adressable system, */ +/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */ +/* (btw, those nibble-addressable systems are way off, or so we assume) */ + + +#if defined _STDINT_BYTE_MODEL +#if _STDINT_LONG_MODEL+0 == 242 +/* 2:4:2 = IP16 = a normal 16-bit system */ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +#ifndef __int8_t_defined +#define __int8_t_defined +typedef char int8_t; +typedef short int16_t; +typedef long int32_t; +#endif +#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444 +/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */ +/* 4:4:4 = ILP32 = a normal 32-bit system */ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#ifndef __int8_t_defined +#define __int8_t_defined +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +#endif +#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488 +/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */ +/* 4:8:8 = LP64 = a normal 64-bit system */ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#ifndef __int8_t_defined +#define __int8_t_defined +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +#endif +/* this system has a "long" of 64bit */ +#ifndef _HAVE_UINT64_T +#define _HAVE_UINT64_T +typedef unsigned long uint64_t; +typedef long int64_t; +#endif +#elif _STDINT_LONG_MODEL+0 == 448 +/* LLP64 a 64-bit system derived from a 32-bit system */ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#ifndef __int8_t_defined +#define __int8_t_defined +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +#endif +/* assuming the system has a "long long" */ +#ifndef _HAVE_UINT64_T +#define _HAVE_UINT64_T +typedef unsigned long long uint64_t; +typedef long long int64_t; +#endif +#else +#define _STDINT_NO_INT32_T +#endif +#else +#define _STDINT_NO_INT8_T +#define _STDINT_NO_INT32_T +#endif +#endif + +/* + * quote from SunOS-5.8 sys/inttypes.h: + * Use at your own risk. As of February 1996, the committee is squarely + * behind the fixed sized types; the "least" and "fast" types are still being + * discussed. The probability that the "fast" types may be removed before + * the standard is finalized is high enough that they are not currently + * implemented. + */ + +#if defined _STDINT_NEED_INT_LEAST_T +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +#ifdef _HAVE_UINT64_T +typedef int64_t int_least64_t; +#endif + +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +#ifdef _HAVE_UINT64_T +typedef uint64_t uint_least64_t; +#endif + /* least types */ +#endif + +#if defined _STDINT_NEED_INT_FAST_T +typedef int8_t int_fast8_t; +typedef int int_fast16_t; +typedef int32_t int_fast32_t; +#ifdef _HAVE_UINT64_T +typedef int64_t int_fast64_t; +#endif + +typedef uint8_t uint_fast8_t; +typedef unsigned uint_fast16_t; +typedef uint32_t uint_fast32_t; +#ifdef _HAVE_UINT64_T +typedef uint64_t uint_fast64_t; +#endif + /* fast types */ +#endif + +#ifdef _STDINT_NEED_INTMAX_T +#ifdef _HAVE_UINT64_T +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; +#else +typedef long intmax_t; +typedef unsigned long uintmax_t; +#endif +#endif + +#ifdef _STDINT_NEED_INTPTR_T +#ifndef __intptr_t_defined +#define __intptr_t_defined +/* we encourage using "long" to store pointer values, never use "int" ! */ +#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484 +typedef unsigned int uintptr_t; +typedef int intptr_t; +#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444 +typedef unsigned long uintptr_t; +typedef long intptr_t; +#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T +typedef uint64_t uintptr_t; +typedef int64_t intptr_t; +#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */ +typedef unsigned long uintptr_t; +typedef long intptr_t; +#endif +#endif +#endif + + /* shortcircuit*/ +#endif + /* once */ +#endif +#endif diff --git a/include/nettle/nettle-types.h b/include/nettle/nettle-types.h new file mode 100644 index 0000000..84c375d --- /dev/null +++ b/include/nettle/nettle-types.h @@ -0,0 +1,110 @@ +/* nettle-types.h + + Copyright (C) 2005, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_TYPES_H +#define NETTLE_TYPES_H + +/* For size_t */ +#include + +/* Pretend these types always exists. Nettle doesn't use them. */ +#define _STDINT_HAVE_INT_FAST32_T 1 +#include "nettle-stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* An aligned 16-byte block. */ +union nettle_block16 +{ + uint8_t b[16]; + unsigned long w[16 / sizeof(unsigned long)]; +}; + +/* Randomness. Used by key generation and dsa signature creation. */ +typedef void nettle_random_func(void *ctx, + size_t length, uint8_t *dst); + +/* Progress report function, mainly for key generation. */ +typedef void nettle_progress_func(void *ctx, int c); + +/* Realloc function, used by struct nettle_buffer. */ +typedef void *nettle_realloc_func(void *ctx, void *p, size_t length); + +/* Ciphers */ +typedef void nettle_set_key_func(void *ctx, const uint8_t *key); + +/* For block ciphers, const context. */ +typedef void nettle_cipher_func(const void *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + + +/* Uses a void * for cipher contexts. Used for crypt operations where + the internal state changes during the encryption. */ +typedef void nettle_crypt_func(void *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +/* Hash algorithms */ +typedef void nettle_hash_init_func(void *ctx); +typedef void nettle_hash_update_func(void *ctx, + size_t length, + const uint8_t *src); +typedef void nettle_hash_digest_func(void *ctx, + size_t length, uint8_t *dst); + +/* ASCII armor codecs. NOTE: Experimental and subject to change. */ + +typedef size_t nettle_armor_length_func(size_t length); +typedef void nettle_armor_init_func(void *ctx); + +typedef size_t nettle_armor_encode_update_func(void *ctx, + char *dst, + size_t src_length, + const uint8_t *src); + +typedef size_t nettle_armor_encode_final_func(void *ctx, char *dst); + +typedef int nettle_armor_decode_update_func(void *ctx, + size_t *dst_length, + uint8_t *dst, + size_t src_length, + const char *src); + +typedef int nettle_armor_decode_final_func(void *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_TYPES_H */ diff --git a/include/nettle/pbkdf2.h b/include/nettle/pbkdf2.h new file mode 100644 index 0000000..7b1c4c9 --- /dev/null +++ b/include/nettle/pbkdf2.h @@ -0,0 +1,85 @@ +/* pbkdf2.h + + PKCS #5 password-based key derivation function PBKDF2, see RFC 2898. + + Copyright (C) 2012 Simon Josefsson + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_PBKDF2_H_INCLUDED +#define NETTLE_PBKDF2_H_INCLUDED + +#include "nettle-meta.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Namespace mangling */ +#define pbkdf2 nettle_pbkdf2 +#define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1 +#define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256 + +void +pbkdf2 (void *mac_ctx, + nettle_hash_update_func *update, + nettle_hash_digest_func *digest, + size_t digest_size, unsigned iterations, + size_t salt_length, const uint8_t *salt, + size_t length, uint8_t *dst); + +#define PBKDF2(ctx, update, digest, digest_size, \ + iterations, salt_length, salt, length, dst) \ + (0 ? ((update)((ctx), 0, (uint8_t *) 0), \ + (digest)((ctx), 0, (uint8_t *) 0)) \ + : pbkdf2 ((ctx), \ + (nettle_hash_update_func *)(update), \ + (nettle_hash_digest_func *)(digest), \ + (digest_size), (iterations), \ + (salt_length), (salt), (length), (dst))) + +/* PBKDF2 with specific PRFs. */ + +void +pbkdf2_hmac_sha1 (size_t key_length, const uint8_t *key, + unsigned iterations, + size_t salt_length, const uint8_t *salt, + size_t length, uint8_t *dst); + +void +pbkdf2_hmac_sha256 (size_t key_length, const uint8_t *key, + unsigned iterations, + size_t salt_length, const uint8_t *salt, + size_t length, uint8_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_PBKDF2_H_INCLUDED */ diff --git a/include/nettle/pgp.h b/include/nettle/pgp.h new file mode 100644 index 0000000..4c2fd84 --- /dev/null +++ b/include/nettle/pgp.h @@ -0,0 +1,248 @@ +/* pgp.h + + PGP related functions. + + Copyright (C) 2001, 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_PGP_H_INCLUDED +#define NETTLE_PGP_H_INCLUDED + +#include + +#include "nettle-types.h" +#include "bignum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define pgp_put_uint32 nettle_pgp_put_uint32 +#define pgp_put_uint16 nettle_pgp_put_uint16 +#define pgp_put_mpi nettle_pgp_put_mpi +#define pgp_put_string nettle_pgp_put_string +#define pgp_put_length nettle_pgp_put_length +#define pgp_put_header nettle_pgp_put_header +#define pgp_put_header_length nettle_pgp_put_header_length +#define pgp_sub_packet_start nettle_pgp_sub_packet_start +#define pgp_put_sub_packet nettle_pgp_put_sub_packet +#define pgp_sub_packet_end nettle_pgp_sub_packet_end +#define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key +#define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature +#define pgp_put_userid nettle_pgp_put_userid +#define pgp_crc24 nettle_pgp_crc24 +#define pgp_armor nettle_pgp_armor + +struct nettle_buffer; +struct rsa_public_key; +struct rsa_private_key; +struct sha1_ctx; + +int +pgp_put_uint32(struct nettle_buffer *buffer, uint32_t i); + +int +pgp_put_uint16(struct nettle_buffer *buffer, unsigned i); + +int +pgp_put_mpi(struct nettle_buffer *buffer, const mpz_t x); + +int +pgp_put_string(struct nettle_buffer *buffer, + unsigned length, + const uint8_t *s); + +int +pgp_put_length(struct nettle_buffer *buffer, + unsigned length); + +int +pgp_put_header(struct nettle_buffer *buffer, + unsigned tag, unsigned length); + +void +pgp_put_header_length(struct nettle_buffer *buffer, + /* start of the header */ + unsigned start, + unsigned field_size); + +unsigned +pgp_sub_packet_start(struct nettle_buffer *buffer); + +int +pgp_put_sub_packet(struct nettle_buffer *buffer, + unsigned type, + unsigned length, + const uint8_t *data); + +void +pgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start); + +int +pgp_put_public_rsa_key(struct nettle_buffer *, + const struct rsa_public_key *key, + time_t timestamp); + +int +pgp_put_rsa_sha1_signature(struct nettle_buffer *buffer, + const struct rsa_private_key *key, + const uint8_t *keyid, + unsigned type, + struct sha1_ctx *hash); + +int +pgp_put_userid(struct nettle_buffer *buffer, + unsigned length, + const uint8_t *name); + +uint32_t +pgp_crc24(unsigned length, const uint8_t *data); + +int +pgp_armor(struct nettle_buffer *buffer, + const char *tag, + unsigned length, + const uint8_t *data); + +/* Values that can be passed to pgp_put_header when the size of the + * length field, but not the length itself, is known. Also the minimum length + * for the given field size. */ +enum pgp_lengths + { + PGP_LENGTH_ONE_OCTET = 0, + PGP_LENGTH_TWO_OCTETS = 192, + PGP_LENGTH_FOUR_OCTETS = 8384, + }; + +enum pgp_public_key_algorithm + { + PGP_RSA = 1, + PGP_RSA_ENCRYPT = 2, + PGP_RSA_SIGN = 3, + PGP_EL_GAMAL_ENCRYPT = 16, + PGP_DSA = 17, + PGP_EL_GAMAL = 20, + }; + +enum pgp_symmetric_algorithm + { + PGP_PLAINTEXT = 0, + PGP_IDEA = 1, + PGP_3DES = 2, + PGP_CAST5 = 3, + PGP_BLOWFISH = 4, + PGP_SAFER_SK = 5, + PGP_AES128 = 7, + PGP_AES192 = 8, + PGP_AES256 = 9, + }; + +enum pgp_compression_algorithm + { + PGP_UNCOMPRESSED = 0, + PGP_ZIP = 1, + PGP_ZLIB = 2, + }; + +enum pgp_hash_algorithm + { + PGP_MD5 = 1, + PGP_SHA1 = 2, + PGP_RIPEMD = 3, + PGP_MD2 = 5, + PGP_TIGER192 = 6, + PGP_HAVAL = 7, + }; + +enum pgp_tag + { + PGP_TAG_PUBLIC_SESSION_KEY = 1, + PGP_TAG_SIGNATURE = 2, + PGP_TAG_SYMMETRIC_SESSION_KEY = 3, + PGP_TAG_ONE_PASS_SIGNATURE = 4, + PGP_TAG_SECRET_KEY = 5, + PGP_TAG_PUBLIC_KEY = 6, + PGP_TAG_SECRET_SUBKEY = 7, + PGP_TAG_COMPRESSED = 8, + PGP_TAG_ENCRYPTED = 9, + PGP_TAG_MARKER = 10, + PGP_TAG_LITERAL = 11, + PGP_TAG_TRUST = 12, + PGP_TAG_USERID = 13, + PGP_TAG_PUBLIC_SUBKEY = 14, + }; + +enum pgp_signature_type + { + PGP_SIGN_BINARY = 0, + PGP_SIGN_TEXT = 1, + PGP_SIGN_STANDALONE = 2, + PGP_SIGN_CERTIFICATION = 0x10, + PGP_SIGN_CERTIFICATION_PERSONA = 0x11, + PGP_SIGN_CERTIFICATION_CASUAL = 0x12, + PGP_SIGN_CERTIFICATION_POSITIVE = 0x13, + PGP_SIGN_SUBKEY = 0x18, + PGP_SIGN_KEY = 0x1f, + PGP_SIGN_REVOCATION = 0x20, + PGP_SIGN_REVOCATION_SUBKEY = 0x28, + PGP_SIGN_REVOCATION_CERTIFICATE = 0x30, + PGP_SIGN_TIMESTAMP = 0x40, + }; + +enum pgp_subpacket_tag + { + PGP_SUBPACKET_CREATION_TIME = 2, + PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME = 3, + PGP_SUBPACKET_EXPORTABLE_CERTIFICATION = 4, + PGP_SUBPACKET_TRUST_SIGNATURE = 5, + PGP_SUBPACKET_REGULAR_EXPRESSION = 6, + PGP_SUBPACKET_REVOCABLE = 7, + PGP_SUBPACKET_KEY_EXPIRATION_TIME = 9, + PGP_SUBPACKET_PLACEHOLDER = 10 , + PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS = 11, + PGP_SUBPACKET_REVOCATION_KEY = 12, + PGP_SUBPACKET_ISSUER_KEY_ID = 16, + PGP_SUBPACKET_NOTATION_DATA = 20, + PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS = 21, + PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS = 22, + PGP_SUBPACKET_KEY_SERVER_PREFERENCES = 23, + PGP_SUBPACKET_PREFERRED_KEY_SERVER = 24, + PGP_SUBPACKET_PRIMARY_USER_ID = 25, + PGP_SUBPACKET_POLICY_URL = 26, + PGP_SUBPACKET_KEY_FLAGS = 27, + PGP_SUBPACKET_SIGNERS_USER_ID = 28, + PGP_SUBPACKET_REASON_FOR_REVOCATION = 29, + }; + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_PGP_H_INCLUDED */ diff --git a/include/nettle/pkcs1.h b/include/nettle/pkcs1.h new file mode 100644 index 0000000..70aa21f --- /dev/null +++ b/include/nettle/pkcs1.h @@ -0,0 +1,114 @@ +/* pkcs1.h + + PKCS1 embedding. + + Copyright (C) 2003 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_PKCS1_H_INCLUDED +#define NETTLE_PKCS1_H_INCLUDED + +#include "nettle-types.h" +#include "bignum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define _pkcs1_signature_prefix _nettle_pkcs1_signature_prefix +#define pkcs1_rsa_digest_encode nettle_pkcs1_rsa_digest_encode +#define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode +#define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest +#define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode +#define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest +#define pkcs1_rsa_sha256_encode nettle_pkcs1_rsa_sha256_encode +#define pkcs1_rsa_sha256_encode_digest nettle_pkcs1_rsa_sha256_encode_digest +#define pkcs1_rsa_sha512_encode nettle_pkcs1_rsa_sha512_encode +#define pkcs1_rsa_sha512_encode_digest nettle_pkcs1_rsa_sha512_encode_digest +#define pkcs1_encrypt nettle_pkcs1_encrypt +#define pkcs1_decrypt nettle_pkcs1_decrypt + +struct md5_ctx; +struct sha1_ctx; +struct sha256_ctx; +struct sha512_ctx; + +uint8_t * +_pkcs1_signature_prefix(unsigned key_size, + uint8_t *buffer, + unsigned id_size, + const uint8_t *id, + unsigned digest_size); + +int +pkcs1_encrypt (size_t key_size, + /* For padding */ + void *random_ctx, nettle_random_func *random, + size_t length, const uint8_t *message, + mpz_t m); + +int +pkcs1_decrypt (size_t key_size, + const mpz_t m, + size_t *length, uint8_t *message); + +int +pkcs1_rsa_digest_encode(mpz_t m, size_t key_size, + size_t di_length, const uint8_t *digest_info); + +int +pkcs1_rsa_md5_encode(mpz_t m, size_t length, struct md5_ctx *hash); + +int +pkcs1_rsa_md5_encode_digest(mpz_t m, size_t length, const uint8_t *digest); + +int +pkcs1_rsa_sha1_encode(mpz_t m, size_t length, struct sha1_ctx *hash); + +int +pkcs1_rsa_sha1_encode_digest(mpz_t m, size_t length, const uint8_t *digest); + +int +pkcs1_rsa_sha256_encode(mpz_t m, size_t length, struct sha256_ctx *hash); + +int +pkcs1_rsa_sha256_encode_digest(mpz_t m, size_t length, const uint8_t *digest); + +int +pkcs1_rsa_sha512_encode(mpz_t m, size_t length, struct sha512_ctx *hash); + +int +pkcs1_rsa_sha512_encode_digest(mpz_t m, size_t length, const uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_PKCS1_H_INCLUDED */ diff --git a/include/nettle/poly1305.h b/include/nettle/poly1305.h new file mode 100644 index 0000000..eadc405 --- /dev/null +++ b/include/nettle/poly1305.h @@ -0,0 +1,128 @@ +/* poly1305.h + + Poly1305 message authentication code. + + Copyright (C) 2013 Nikos Mavrogiannopoulos + Copyright (C) 2013, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_POLY1305_H_INCLUDED +#define NETTLE_POLY1305_H_INCLUDED + +#include "aes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define poly1305_set_key nettle_poly1305_set_key +#define poly1305_digest nettle_poly1305_digest +#define _poly1305_block _nettle_poly1305_block + +#define poly1305_aes_set_key nettle_poly1305_aes_set_key +#define poly1305_aes_set_nonce nettle_poly1305_aes_set_nonce +#define poly1305_aes_update nettle_poly1305_aes_update +#define poly1305_aes_digest nettle_poly1305_aes_digest + +/* Low level functions/macros for the poly1305 construction. */ + +#define POLY1305_DIGEST_SIZE 16 +#define POLY1305_BLOCK_SIZE 16 +#define POLY1305_KEY_SIZE 16 + +struct poly1305_ctx { + /* Key, 128-bit value and some cached multiples. */ + union + { + uint32_t r32[6]; + uint64_t r64[3]; + } r; + uint32_t s32[3]; + /* State, represented as words of 26, 32 or 64 bits, depending on + implementation. */ + /* High bits first, to maintain alignment. */ + uint32_t hh; + union + { + uint32_t h32[4]; + uint64_t h64[2]; + } h; +}; + +/* Low-level internal interface. */ +void poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[POLY1305_KEY_SIZE]); +/* Extracts digest, and adds it to s, the encrypted nonce. */ +void poly1305_digest (struct poly1305_ctx *ctx, union nettle_block16 *s); +/* Internal function. Process one block. */ +void _poly1305_block (struct poly1305_ctx *ctx, const uint8_t *m, + unsigned high); + +/* poly1305-aes */ + +#define POLY1305_AES_KEY_SIZE 32 +#define POLY1305_AES_DIGEST_SIZE 16 +#define POLY1305_AES_NONCE_SIZE 16 + +struct poly1305_aes_ctx +{ + /* Keep aes context last, to make it possible to use a general + poly1305_update if other variants are added. */ + struct poly1305_ctx pctx; + uint8_t block[POLY1305_BLOCK_SIZE]; + unsigned index; + uint8_t nonce[POLY1305_BLOCK_SIZE]; + struct aes128_ctx aes; +}; + +/* Also initialize the nonce to zero. */ +void +poly1305_aes_set_key (struct poly1305_aes_ctx *ctx, const uint8_t *key); + +/* Optional, if not used, messages get incrementing nonces starting + from zero. */ +void +poly1305_aes_set_nonce (struct poly1305_aes_ctx *ctx, + const uint8_t *nonce); + +/* Update is not aes-specific, but since this is the only implemented + variant, we need no more general poly1305_update. */ +void +poly1305_aes_update (struct poly1305_aes_ctx *ctx, size_t length, const uint8_t *data); + +/* Also increments the nonce */ +void +poly1305_aes_digest (struct poly1305_aes_ctx *ctx, + size_t length, uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_POLY1305_H_INCLUDED */ diff --git a/include/nettle/pss-mgf1.h b/include/nettle/pss-mgf1.h new file mode 100644 index 0000000..4a29c10 --- /dev/null +++ b/include/nettle/pss-mgf1.h @@ -0,0 +1,58 @@ +/* pss-mgf1.h + + PKCS#1 mask generation function 1, used in RSA-PSS (RFC-3447). + + Copyright (C) 2017 Daiki Ueno + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_PSS_MGF1_H_INCLUDED +#define NETTLE_PSS_MGF1_H_INCLUDED + +#include "nettle-meta.h" + +#include "sha1.h" +#include "sha2.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Namespace mangling */ +#define pss_mgf1 nettle_pss_mgf1 + +void +pss_mgf1(const void *seed, const struct nettle_hash *hash, + size_t length, uint8_t *mask); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_PSS_MGF1_H_INCLUDED */ diff --git a/include/nettle/pss.h b/include/nettle/pss.h new file mode 100644 index 0000000..7627cfe --- /dev/null +++ b/include/nettle/pss.h @@ -0,0 +1,65 @@ +/* pss.h + + PKCS#1 RSA-PSS (RFC-3447). + + Copyright (C) 2017 Daiki Ueno + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_PSS_H_INCLUDED +#define NETTLE_PSS_H_INCLUDED + +#include "nettle-types.h" +#include "bignum.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Namespace mangling */ +#define pss_encode_mgf1 nettle_pss_encode_mgf1 +#define pss_verify_mgf1 nettle_pss_verify_mgf1 + +int +pss_encode_mgf1(mpz_t m, size_t bits, + const struct nettle_hash *hash, + size_t salt_length, const uint8_t *salt, + const uint8_t *digest); + +int +pss_verify_mgf1(const mpz_t m, size_t bits, + const struct nettle_hash *hash, + size_t salt_length, + const uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_PSS_H_INCLUDED */ diff --git a/include/nettle/realloc.h b/include/nettle/realloc.h new file mode 100644 index 0000000..66d376f --- /dev/null +++ b/include/nettle/realloc.h @@ -0,0 +1,48 @@ +/* realloc.h + + Copyright (C) 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_REALLOC_H_INCLUDED +#define NETTLE_REALLOC_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +nettle_realloc_func nettle_realloc; +nettle_realloc_func nettle_xrealloc; + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_REALLOC_H_INCLUDED */ diff --git a/include/nettle/ripemd160.h b/include/nettle/ripemd160.h new file mode 100644 index 0000000..80d1d8a --- /dev/null +++ b/include/nettle/ripemd160.h @@ -0,0 +1,88 @@ +/* ripemd160.h + + RIPEMD-160 hash function. + + Copyright (C) 2011 Andres Mejia + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_RIPEMD160_H_INCLUDED +#define NETTLE_RIPEMD160_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#include "nettle-types.h" + +/* Name mangling */ +#define ripemd160_init nettle_ripemd160_init +#define ripemd160_update nettle_ripemd160_update +#define ripemd160_digest nettle_ripemd160_digest + +/* RIPEMD160 */ + +#define RIPEMD160_DIGEST_SIZE 20 +#define RIPEMD160_BLOCK_SIZE 64 +/* For backwards compatibility */ +#define RIPEMD160_DATA_SIZE RIPEMD160_BLOCK_SIZE + +/* Digest is kept internally as 5 32-bit words. */ +#define _RIPEMD160_DIGEST_LENGTH 5 + +struct ripemd160_ctx +{ + uint32_t state[_RIPEMD160_DIGEST_LENGTH]; + uint64_t count; /* 64-bit block count */ + uint8_t block[RIPEMD160_BLOCK_SIZE]; + unsigned int index; +}; + +void +ripemd160_init(struct ripemd160_ctx *ctx); + +void +ripemd160_update(struct ripemd160_ctx *ctx, + size_t length, + const uint8_t *data); + +void +ripemd160_digest(struct ripemd160_ctx *ctx, + size_t length, + uint8_t *digest); + +/* Internal compression function. STATE points to 5 uint32_t words, + and DATA points to 64 bytes of input data, possibly unaligned. */ +void +_nettle_ripemd160_compress(uint32_t *state, const uint8_t *data); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_RIPEMD160_H_INCLUDED */ diff --git a/include/nettle/rsa.h b/include/nettle/rsa.h new file mode 100644 index 0000000..0aac6a2 --- /dev/null +++ b/include/nettle/rsa.h @@ -0,0 +1,564 @@ +/* rsa.h + + The RSA publickey algorithm. + + Copyright (C) 2001, 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_RSA_H_INCLUDED +#define NETTLE_RSA_H_INCLUDED + +#include "nettle-types.h" +#include "bignum.h" + +#include "md5.h" +#include "sha1.h" +#include "sha2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define rsa_public_key_init nettle_rsa_public_key_init +#define rsa_public_key_clear nettle_rsa_public_key_clear +#define rsa_public_key_prepare nettle_rsa_public_key_prepare +#define rsa_private_key_init nettle_rsa_private_key_init +#define rsa_private_key_clear nettle_rsa_private_key_clear +#define rsa_private_key_prepare nettle_rsa_private_key_prepare +#define rsa_pkcs1_verify nettle_rsa_pkcs1_verify +#define rsa_pkcs1_sign nettle_rsa_pkcs1_sign +#define rsa_pkcs1_sign_tr nettle_rsa_pkcs1_sign_tr +#define rsa_md5_sign nettle_rsa_md5_sign +#define rsa_md5_sign_tr nettle_rsa_md5_sign_tr +#define rsa_md5_verify nettle_rsa_md5_verify +#define rsa_sha1_sign nettle_rsa_sha1_sign +#define rsa_sha1_sign_tr nettle_rsa_sha1_sign_tr +#define rsa_sha1_verify nettle_rsa_sha1_verify +#define rsa_sha256_sign nettle_rsa_sha256_sign +#define rsa_sha256_sign_tr nettle_rsa_sha256_sign_tr +#define rsa_sha256_verify nettle_rsa_sha256_verify +#define rsa_sha512_sign nettle_rsa_sha512_sign +#define rsa_sha512_sign_tr nettle_rsa_sha512_sign_tr +#define rsa_sha512_verify nettle_rsa_sha512_verify +#define rsa_md5_sign_digest nettle_rsa_md5_sign_digest +#define rsa_md5_sign_digest_tr nettle_rsa_md5_sign_digest_tr +#define rsa_md5_verify_digest nettle_rsa_md5_verify_digest +#define rsa_sha1_sign_digest nettle_rsa_sha1_sign_digest +#define rsa_sha1_sign_digest_tr nettle_rsa_sha1_sign_digest_tr +#define rsa_sha1_verify_digest nettle_rsa_sha1_verify_digest +#define rsa_sha256_sign_digest nettle_rsa_sha256_sign_digest +#define rsa_sha256_sign_digest_tr nettle_rsa_sha256_sign_digest_tr +#define rsa_sha256_verify_digest nettle_rsa_sha256_verify_digest +#define rsa_sha512_sign_digest nettle_rsa_sha512_sign_digest +#define rsa_sha512_sign_digest_tr nettle_rsa_sha512_sign_digest_tr +#define rsa_sha512_verify_digest nettle_rsa_sha512_verify_digest +#define rsa_pss_sha256_sign_digest_tr nettle_rsa_pss_sha256_sign_digest_tr +#define rsa_pss_sha256_verify_digest nettle_rsa_pss_sha256_verify_digest +#define rsa_pss_sha384_sign_digest_tr nettle_rsa_pss_sha384_sign_digest_tr +#define rsa_pss_sha384_verify_digest nettle_rsa_pss_sha384_verify_digest +#define rsa_pss_sha512_sign_digest_tr nettle_rsa_pss_sha512_sign_digest_tr +#define rsa_pss_sha512_verify_digest nettle_rsa_pss_sha512_verify_digest +#define rsa_encrypt nettle_rsa_encrypt +#define rsa_decrypt nettle_rsa_decrypt +#define rsa_decrypt_tr nettle_rsa_decrypt_tr +#define rsa_sec_decrypt nettle_rsa_sec_decrypt +#define rsa_compute_root nettle_rsa_compute_root +#define rsa_compute_root_tr nettle_rsa_compute_root_tr +#define rsa_generate_keypair nettle_rsa_generate_keypair +#define rsa_keypair_to_sexp nettle_rsa_keypair_to_sexp +#define rsa_keypair_from_sexp_alist nettle_rsa_keypair_from_sexp_alist +#define rsa_keypair_from_sexp nettle_rsa_keypair_from_sexp +#define rsa_public_key_from_der_iterator nettle_rsa_public_key_from_der_iterator +#define rsa_private_key_from_der_iterator nettle_rsa_private_key_from_der_iterator +#define rsa_keypair_from_der nettle_rsa_keypair_from_der +#define rsa_keypair_to_openpgp nettle_rsa_keypair_to_openpgp +#define _rsa_verify _nettle_rsa_verify +#define _rsa_verify_recover _nettle_rsa_verify_recover +#define _rsa_check_size _nettle_rsa_check_size +#define _rsa_blind _nettle_rsa_blind +#define _rsa_unblind _nettle_rsa_unblind + +/* This limit is somewhat arbitrary. Technically, the smallest modulo + which makes sense at all is 15 = 3*5, phi(15) = 8, size 4 bits. But + for ridiculously small keys, not all odd e are possible (e.g., for + 5 bits, the only possible modulo is 3*7 = 21, phi(21) = 12, and e = + 3 don't work). The smallest size that makes sense with pkcs#1, and + which allows RSA encryption of one byte messages, is 12 octets, 89 + bits. */ + +#define RSA_MINIMUM_N_OCTETS 12 +#define RSA_MINIMUM_N_BITS (8*RSA_MINIMUM_N_OCTETS - 7) + +struct rsa_public_key +{ + /* Size of the modulo, in octets. This is also the size of all + * signatures that are created or verified with this key. */ + size_t size; + + /* Modulo */ + mpz_t n; + + /* Public exponent */ + mpz_t e; +}; + +struct rsa_private_key +{ + size_t size; + + /* d is filled in by the key generation function; otherwise it's + * completely unused. */ + mpz_t d; + + /* The two factors */ + mpz_t p; mpz_t q; + + /* d % (p-1), i.e. a e = 1 (mod (p-1)) */ + mpz_t a; + + /* d % (q-1), i.e. b e = 1 (mod (q-1)) */ + mpz_t b; + + /* modular inverse of q , i.e. c q = 1 (mod p) */ + mpz_t c; +}; + +/* Signing a message works as follows: + * + * Store the private key in a rsa_private_key struct. + * + * Call rsa_private_key_prepare. This initializes the size attribute + * to the length of a signature. + * + * Initialize a hashing context, by callling + * md5_init + * + * Hash the message by calling + * md5_update + * + * Create the signature by calling + * rsa_md5_sign + * + * The signature is represented as a mpz_t bignum. This call also + * resets the hashing context. + * + * When done with the key and signature, don't forget to call + * mpz_clear. + */ + +/* Calls mpz_init to initialize bignum storage. */ +void +rsa_public_key_init(struct rsa_public_key *key); + +/* Calls mpz_clear to deallocate bignum storage. */ +void +rsa_public_key_clear(struct rsa_public_key *key); + +int +rsa_public_key_prepare(struct rsa_public_key *key); + +/* Calls mpz_init to initialize bignum storage. */ +void +rsa_private_key_init(struct rsa_private_key *key); + +/* Calls mpz_clear to deallocate bignum storage. */ +void +rsa_private_key_clear(struct rsa_private_key *key); + +int +rsa_private_key_prepare(struct rsa_private_key *key); + + +/* PKCS#1 style signatures */ +int +rsa_pkcs1_sign(const struct rsa_private_key *key, + size_t length, const uint8_t *digest_info, + mpz_t s); + +int +rsa_pkcs1_sign_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t length, const uint8_t *digest_info, + mpz_t s); +int +rsa_pkcs1_verify(const struct rsa_public_key *key, + size_t length, const uint8_t *digest_info, + const mpz_t signature); + +int +rsa_md5_sign(const struct rsa_private_key *key, + struct md5_ctx *hash, + mpz_t signature); + +int +rsa_md5_sign_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct md5_ctx *hash, mpz_t s); + + +int +rsa_md5_verify(const struct rsa_public_key *key, + struct md5_ctx *hash, + const mpz_t signature); + +int +rsa_sha1_sign(const struct rsa_private_key *key, + struct sha1_ctx *hash, + mpz_t signature); + +int +rsa_sha1_sign_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct sha1_ctx *hash, + mpz_t s); + +int +rsa_sha1_verify(const struct rsa_public_key *key, + struct sha1_ctx *hash, + const mpz_t signature); + +int +rsa_sha256_sign(const struct rsa_private_key *key, + struct sha256_ctx *hash, + mpz_t signature); + +int +rsa_sha256_sign_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct sha256_ctx *hash, + mpz_t s); + +int +rsa_sha256_verify(const struct rsa_public_key *key, + struct sha256_ctx *hash, + const mpz_t signature); + +int +rsa_sha512_sign(const struct rsa_private_key *key, + struct sha512_ctx *hash, + mpz_t signature); + +int +rsa_sha512_sign_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + struct sha512_ctx *hash, + mpz_t s); + +int +rsa_sha512_verify(const struct rsa_public_key *key, + struct sha512_ctx *hash, + const mpz_t signature); + +/* Variants taking the digest as argument. */ +int +rsa_md5_sign_digest(const struct rsa_private_key *key, + const uint8_t *digest, + mpz_t s); + +int +rsa_md5_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, mpz_t s); + +int +rsa_md5_verify_digest(const struct rsa_public_key *key, + const uint8_t *digest, + const mpz_t signature); + +int +rsa_sha1_sign_digest(const struct rsa_private_key *key, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha1_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha1_verify_digest(const struct rsa_public_key *key, + const uint8_t *digest, + const mpz_t signature); + +int +rsa_sha256_sign_digest(const struct rsa_private_key *key, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha256_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha256_verify_digest(const struct rsa_public_key *key, + const uint8_t *digest, + const mpz_t signature); + +int +rsa_sha512_sign_digest(const struct rsa_private_key *key, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha512_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + const uint8_t *digest, + mpz_t s); + +int +rsa_sha512_verify_digest(const struct rsa_public_key *key, + const uint8_t *digest, + const mpz_t signature); + +/* PSS style signatures */ +int +rsa_pss_sha256_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t salt_length, const uint8_t *salt, + const uint8_t *digest, + mpz_t s); + +int +rsa_pss_sha256_verify_digest(const struct rsa_public_key *key, + size_t salt_length, + const uint8_t *digest, + const mpz_t signature); + +int +rsa_pss_sha384_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t salt_length, const uint8_t *salt, + const uint8_t *digest, + mpz_t s); + +int +rsa_pss_sha384_verify_digest(const struct rsa_public_key *key, + size_t salt_length, + const uint8_t *digest, + const mpz_t signature); + +int +rsa_pss_sha512_sign_digest_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t salt_length, const uint8_t *salt, + const uint8_t *digest, + mpz_t s); + +int +rsa_pss_sha512_verify_digest(const struct rsa_public_key *key, + size_t salt_length, + const uint8_t *digest, + const mpz_t signature); + + +/* RSA encryption, using PKCS#1 */ +/* These functions uses the v1.5 padding. What should the v2 (OAEP) + * functions be called? */ + +/* Returns 1 on success, 0 on failure, which happens if the + * message is too long for the key. */ +int +rsa_encrypt(const struct rsa_public_key *key, + /* For padding */ + void *random_ctx, nettle_random_func *random, + size_t length, const uint8_t *cleartext, + mpz_t cipher); + +/* Message must point to a buffer of size *LENGTH. KEY->size is enough + * for all valid messages. On success, *LENGTH is updated to reflect + * the actual length of the message. Returns 1 on success, 0 on + * failure, which happens if decryption failed or if the message + * didn't fit. */ +int +rsa_decrypt(const struct rsa_private_key *key, + size_t *length, uint8_t *cleartext, + const mpz_t ciphertext); + +/* Timing-resistant version, using randomized RSA blinding. */ +int +rsa_decrypt_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t *length, uint8_t *message, + const mpz_t gibberish); + +/* like rsa_decrypt_tr but with additional side-channel resistance. + * NOTE: the length of the final message must be known in advance. */ +int +rsa_sec_decrypt(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + size_t length, uint8_t *message, + const mpz_t gibberish); + +/* Compute x, the e:th root of m. Calling it with x == m is allowed. */ +void +rsa_compute_root(const struct rsa_private_key *key, + mpz_t x, const mpz_t m); + +/* Safer variant, using RSA blinding, and checking the result after + CRT. */ +int +rsa_compute_root_tr(const struct rsa_public_key *pub, + const struct rsa_private_key *key, + void *random_ctx, nettle_random_func *random, + mpz_t x, const mpz_t m); + +/* Key generation */ + +/* Note that the key structs must be initialized first. */ +int +rsa_generate_keypair(struct rsa_public_key *pub, + struct rsa_private_key *key, + + void *random_ctx, nettle_random_func *random, + void *progress_ctx, nettle_progress_func *progress, + + /* Desired size of modulo, in bits */ + unsigned n_size, + + /* Desired size of public exponent, in bits. If + * zero, the passed in value pub->e is used. */ + unsigned e_size); + + +#define RSA_SIGN(key, algorithm, ctx, length, data, signature) ( \ + algorithm##_update(ctx, length, data), \ + rsa_##algorithm##_sign(key, ctx, signature) \ +) + +#define RSA_VERIFY(key, algorithm, ctx, length, data, signature) ( \ + algorithm##_update(ctx, length, data), \ + rsa_##algorithm##_verify(key, ctx, signature) \ +) + + +/* Keys in sexp form. */ + +struct nettle_buffer; + +/* Generates a public-key expression if PRIV is NULL .*/ +int +rsa_keypair_to_sexp(struct nettle_buffer *buffer, + const char *algorithm_name, /* NULL means "rsa" */ + const struct rsa_public_key *pub, + const struct rsa_private_key *priv); + +struct sexp_iterator; + +int +rsa_keypair_from_sexp_alist(struct rsa_public_key *pub, + struct rsa_private_key *priv, + unsigned limit, + struct sexp_iterator *i); + +/* If PRIV is NULL, expect a public-key expression. If PUB is NULL, + * expect a private key expression and ignore the parts not needed for + * the public key. */ +/* Keys must be initialized before calling this function, as usual. */ +int +rsa_keypair_from_sexp(struct rsa_public_key *pub, + struct rsa_private_key *priv, + unsigned limit, + size_t length, const uint8_t *expr); + + +/* Keys in PKCS#1 format. */ +struct asn1_der_iterator; + +int +rsa_public_key_from_der_iterator(struct rsa_public_key *pub, + unsigned limit, + struct asn1_der_iterator *i); + +int +rsa_private_key_from_der_iterator(struct rsa_public_key *pub, + struct rsa_private_key *priv, + unsigned limit, + struct asn1_der_iterator *i); + +/* For public keys, use PRIV == NULL */ +int +rsa_keypair_from_der(struct rsa_public_key *pub, + struct rsa_private_key *priv, + unsigned limit, + size_t length, const uint8_t *data); + +/* OpenPGP format. Experimental interface, subject to change. */ +int +rsa_keypair_to_openpgp(struct nettle_buffer *buffer, + const struct rsa_public_key *pub, + const struct rsa_private_key *priv, + /* A single user id. NUL-terminated utf8. */ + const char *userid); + +/* Internal functions. */ +int +_rsa_verify(const struct rsa_public_key *key, + const mpz_t m, + const mpz_t s); + +int +_rsa_verify_recover(const struct rsa_public_key *key, + mpz_t m, + const mpz_t s); + +size_t +_rsa_check_size(mpz_t n); + +/* _rsa_blind and _rsa_unblind are deprecated, unused in the library, + and will likely be removed with the next ABI break. */ +void +_rsa_blind (const struct rsa_public_key *pub, + void *random_ctx, nettle_random_func *random, + mpz_t c, mpz_t ri); +void +_rsa_unblind (const struct rsa_public_key *pub, mpz_t c, const mpz_t ri); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_RSA_H_INCLUDED */ diff --git a/include/nettle/salsa20.h b/include/nettle/salsa20.h new file mode 100644 index 0000000..4301988 --- /dev/null +++ b/include/nettle/salsa20.h @@ -0,0 +1,114 @@ +/* salsa20.h + + The Salsa20 stream cipher. + + Copyright (C) 2012 Simon Josefsson + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SALSA20_H_INCLUDED +#define NETTLE_SALSA20_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define salsa20_set_key nettle_salsa20_set_key +#define salsa20_128_set_key nettle_salsa20_128_set_key +#define salsa20_256_set_key nettle_salsa20_256_set_key +#define salsa20_set_nonce nettle_salsa20_set_nonce +#define salsa20_crypt nettle_salsa20_crypt +#define _salsa20_core _nettle_salsa20_core + +#define salsa20r12_crypt nettle_salsa20r12_crypt + +/* Alias for backwards compatibility */ +#define salsa20_set_iv nettle_salsa20_set_nonce + +/* In octets.*/ +#define SALSA20_128_KEY_SIZE 16 +#define SALSA20_256_KEY_SIZE 32 +#define SALSA20_BLOCK_SIZE 64 +#define SALSA20_NONCE_SIZE 8 +#define SALSA20_IV_SIZE SALSA20_NONCE_SIZE + +/* Aliases */ +#define SALSA20_MIN_KEY_SIZE 16 +#define SALSA20_MAX_KEY_SIZE 32 +#define SALSA20_KEY_SIZE 32 + +#define _SALSA20_INPUT_LENGTH 16 + +struct salsa20_ctx +{ + /* Indices 1-4 and 11-14 holds the key (two identical copies for the + shorter key size), indices 0, 5, 10, 15 are constant, indices 6, 7 + are the IV, and indices 8, 9 are the block counter: + + C K K K + K C I I + B B C K + K K K C + */ + uint32_t input[_SALSA20_INPUT_LENGTH]; +}; + +void +salsa20_128_set_key(struct salsa20_ctx *ctx, const uint8_t *key); +void +salsa20_256_set_key(struct salsa20_ctx *ctx, const uint8_t *key); + +void +salsa20_set_key(struct salsa20_ctx *ctx, + size_t length, const uint8_t *key); + +void +salsa20_set_nonce(struct salsa20_ctx *ctx, const uint8_t *nonce); + +void +salsa20_crypt(struct salsa20_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +void +salsa20r12_crypt(struct salsa20_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +void +_salsa20_core(uint32_t *dst, const uint32_t *src, unsigned rounds); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SALSA20_H_INCLUDED */ diff --git a/include/nettle/serpent.h b/include/nettle/serpent.h new file mode 100644 index 0000000..f1ab4b9 --- /dev/null +++ b/include/nettle/serpent.h @@ -0,0 +1,102 @@ +/* serpent.h + + The serpent block cipher. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* Serpent is a 128-bit block cipher that accepts a key size of 256 + * bits, designed by Ross Anderson, Eli Biham, and Lars Knudsen. See + * http://www.cl.cam.ac.uk/~rja14/serpent.html for details. + */ + +#ifndef NETTLE_SERPENT_H_INCLUDED +#define NETTLE_SERPENT_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define serpent_set_key nettle_serpent_set_key +#define serpent128_set_key nettle_serpent128_set_key +#define serpent192_set_key nettle_serpent192_set_key +#define serpent256_set_key nettle_serpent256_set_key +#define serpent_encrypt nettle_serpent_encrypt +#define serpent_decrypt nettle_serpent_decrypt + +#define SERPENT_BLOCK_SIZE 16 + +/* Other key lengths are possible, but the design of Serpent makes + * smaller key lengths quite pointless; they cheated with the AES + * requirements, using a 256-bit key length exclusively and just + * padding it out if the desired key length was less, so there really + * is no advantage to using key lengths less than 256 bits. */ +#define SERPENT_KEY_SIZE 32 + +/* Allow keys of size 128 <= bits <= 256 */ + +#define SERPENT_MIN_KEY_SIZE 16 +#define SERPENT_MAX_KEY_SIZE 32 + +#define SERPENT128_KEY_SIZE 16 +#define SERPENT192_KEY_SIZE 24 +#define SERPENT256_KEY_SIZE 32 + +struct serpent_ctx +{ + uint32_t keys[33][4]; /* key schedule */ +}; + +void +serpent_set_key(struct serpent_ctx *ctx, + size_t length, const uint8_t *key); +void +serpent128_set_key(struct serpent_ctx *ctx, const uint8_t *key); +void +serpent192_set_key(struct serpent_ctx *ctx, const uint8_t *key); +void +serpent256_set_key(struct serpent_ctx *ctx, const uint8_t *key); + +void +serpent_encrypt(const struct serpent_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +serpent_decrypt(const struct serpent_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SERPENT_H_INCLUDED */ diff --git a/include/nettle/sexp.h b/include/nettle/sexp.h new file mode 100644 index 0000000..f6b3df6 --- /dev/null +++ b/include/nettle/sexp.h @@ -0,0 +1,213 @@ +/* sexp.h + + Parsing s-expressions. + Copyright (C) 2002 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SEXP_H_INCLUDED +#define NETTLE_SEXP_H_INCLUDED + +#include +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define sexp_iterator_first nettle_sexp_iterator_first +#define sexp_transport_iterator_first nettle_sexp_transport_iterator_first +#define sexp_iterator_next nettle_sexp_iterator_next +#define sexp_iterator_enter_list nettle_sexp_iterator_enter_list +#define sexp_iterator_exit_list nettle_sexp_iterator_exit_list +#define sexp_iterator_subexpr nettle_sexp_iterator_subexpr +#define sexp_iterator_get_uint32 nettle_sexp_iterator_get_uint32 +#define sexp_iterator_check_type nettle_sexp_iterator_check_type +#define sexp_iterator_check_types nettle_sexp_iterator_check_types +#define sexp_iterator_assoc nettle_sexp_iterator_assoc +#define sexp_format nettle_sexp_format +#define sexp_vformat nettle_sexp_vformat +#define sexp_transport_format nettle_sexp_transport_format +#define sexp_transport_vformat nettle_sexp_transport_vformat +#define sexp_token_chars nettle_sexp_token_chars + +enum sexp_type + { SEXP_ATOM, SEXP_LIST, SEXP_END }; + +struct sexp_iterator +{ + size_t length; + const uint8_t *buffer; + + /* Points at the start of the current sub expression. */ + size_t start; + /* If type is SEXP_LIST, pos points at the start of the current + * element. Otherwise, it points at the end. */ + size_t pos; + unsigned level; + + enum sexp_type type; + + size_t display_length; + const uint8_t *display; + + size_t atom_length; + const uint8_t *atom; +}; + + +/* All these functions return 1 on success, 0 on failure */ + +/* Initializes the iterator. */ +int +sexp_iterator_first(struct sexp_iterator *iterator, + size_t length, const uint8_t *input); + +/* NOTE: Decodes the input string in place */ +int +sexp_transport_iterator_first(struct sexp_iterator *iterator, + size_t length, uint8_t *input); + +int +sexp_iterator_next(struct sexp_iterator *iterator); + +/* Current element must be a list. */ +int +sexp_iterator_enter_list(struct sexp_iterator *iterator); + +/* Skips the rest of the current list */ +int +sexp_iterator_exit_list(struct sexp_iterator *iterator); + +#if 0 +/* Skips out of as many lists as necessary to get back to the given + * level. */ +int +sexp_iterator_exit_lists(struct sexp_iterator *iterator, + unsigned level); +#endif + +/* Gets start and length of the current subexpression. Implies + * sexp_iterator_next. */ +const uint8_t * +sexp_iterator_subexpr(struct sexp_iterator *iterator, + size_t *length); + +int +sexp_iterator_get_uint32(struct sexp_iterator *iterator, + uint32_t *x); + + +/* Checks the type of the current expression, which should be a list + * + * ( ...) + */ +int +sexp_iterator_check_type(struct sexp_iterator *iterator, + const char *type); + +const char * +sexp_iterator_check_types(struct sexp_iterator *iterator, + unsigned ntypes, + const char * const *types); + +/* Current element must be a list. Looks up element of type + * + * (key rest...) + * + * For a matching key, the corresponding iterator is initialized + * pointing at the start of REST. + * + * On success, exits the current list. + */ +int +sexp_iterator_assoc(struct sexp_iterator *iterator, + unsigned nkeys, + const char * const *keys, + struct sexp_iterator *values); + + +/* Output functions. What is a reasonable API for this? It seems + * ugly to have to reimplement string streams. */ + +/* Declared for real in buffer.h */ +struct nettle_buffer; + +/* Returns the number of output characters, or 0 on out of memory. If + * buffer == NULL, just compute length. + * + * Format strings can contained matched parentheses, tokens ("foo" in + * the format string is formatted as "3:foo"), whitespace (which + * separates tokens but is otherwise ignored) and the following + * formatting specifiers: + * + * %s String represented as size_t length, const uint8_t *data. + * + * %t Optional display type, represented as + * size_t display_length, const uint8_t *display, + * display == NULL means no display type. + * + * %i Non-negative small integer, uint32_t. + * + * %b Non-negative bignum, mpz_t. + * + * %l Literal string (no length added), typically a balanced + * subexpression. Represented as size_t length, const uint8_t + * *data. + * + * %(, %) Allows insertion of unbalanced parenthesis. + * + * Modifiers: + * + * %0 For %s, %t and %l, says that there's no length argument, + * instead the string is NUL-terminated, and there's only one + * const uint8_t * argument. + */ + +size_t +sexp_format(struct nettle_buffer *buffer, + const char *format, ...); + +size_t +sexp_vformat(struct nettle_buffer *buffer, + const char *format, va_list args); + +size_t +sexp_transport_format(struct nettle_buffer *buffer, + const char *format, ...); + +size_t +sexp_transport_vformat(struct nettle_buffer *buffer, + const char *format, va_list args); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SEXP_H_INCLUDED */ diff --git a/include/nettle/sha.h b/include/nettle/sha.h new file mode 100644 index 0000000..7d4afde --- /dev/null +++ b/include/nettle/sha.h @@ -0,0 +1,42 @@ +/* sha.h + + This file is deprecated, and provided only for backwards + compatibility with earlier versions of Nettle. Please use sha1.h + and/or sha2.h instead. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SHA_H_INCLUDED +#define NETTLE_SHA_H_INCLUDED + +#include "sha1.h" +#include "sha2.h" + +#endif /* NETTLE_SHA_H_INCLUDED */ diff --git a/include/nettle/sha1.h b/include/nettle/sha1.h new file mode 100644 index 0000000..7500d0c --- /dev/null +++ b/include/nettle/sha1.h @@ -0,0 +1,88 @@ +/* sha1.h + + The sha1 hash function. + + Copyright (C) 2001, 2012 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SHA1_H_INCLUDED +#define NETTLE_SHA1_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define sha1_init nettle_sha1_init +#define sha1_update nettle_sha1_update +#define sha1_digest nettle_sha1_digest + +/* SHA1 */ + +#define SHA1_DIGEST_SIZE 20 +#define SHA1_BLOCK_SIZE 64 +/* For backwards compatibility */ +#define SHA1_DATA_SIZE SHA1_BLOCK_SIZE + +/* Digest is kept internally as 5 32-bit words. */ +#define _SHA1_DIGEST_LENGTH 5 + +struct sha1_ctx +{ + uint32_t state[_SHA1_DIGEST_LENGTH]; /* State variables */ + uint64_t count; /* 64-bit block count */ + uint8_t block[SHA1_BLOCK_SIZE]; /* SHA1 data buffer */ + unsigned int index; /* index into buffer */ +}; + +void +sha1_init(struct sha1_ctx *ctx); + +void +sha1_update(struct sha1_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha1_digest(struct sha1_ctx *ctx, + size_t length, + uint8_t *digest); + +/* Internal compression function. STATE points to 5 uint32_t words, + and DATA points to 64 bytes of input data, possibly unaligned. */ +void +_nettle_sha1_compress(uint32_t *state, const uint8_t *data); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SHA1_H_INCLUDED */ diff --git a/include/nettle/sha2.h b/include/nettle/sha2.h new file mode 100644 index 0000000..6537c0e --- /dev/null +++ b/include/nettle/sha2.h @@ -0,0 +1,206 @@ +/* sha2.h + + The sha2 family of hash functions. + + Copyright (C) 2001, 2012 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SHA2_H_INCLUDED +#define NETTLE_SHA2_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define sha224_init nettle_sha224_init +#define sha224_digest nettle_sha224_digest +#define sha256_init nettle_sha256_init +#define sha256_update nettle_sha256_update +#define sha256_digest nettle_sha256_digest +#define sha384_init nettle_sha384_init +#define sha384_digest nettle_sha384_digest +#define sha512_init nettle_sha512_init +#define sha512_update nettle_sha512_update +#define sha512_digest nettle_sha512_digest +#define sha512_224_init nettle_sha512_224_init +#define sha512_224_digest nettle_sha512_224_digest +#define sha512_256_init nettle_sha512_256_init +#define sha512_256_digest nettle_sha512_256_digest + +/* For backwards compatibility */ +#define SHA224_DATA_SIZE SHA256_BLOCK_SIZE +#define SHA256_DATA_SIZE SHA256_BLOCK_SIZE +#define SHA512_DATA_SIZE SHA512_BLOCK_SIZE +#define SHA384_DATA_SIZE SHA512_BLOCK_SIZE + +/* SHA256 */ + +#define SHA256_DIGEST_SIZE 32 +#define SHA256_BLOCK_SIZE 64 + +/* Digest is kept internally as 8 32-bit words. */ +#define _SHA256_DIGEST_LENGTH 8 + +struct sha256_ctx +{ + uint32_t state[_SHA256_DIGEST_LENGTH]; /* State variables */ + uint64_t count; /* 64-bit block count */ + uint8_t block[SHA256_BLOCK_SIZE]; /* SHA256 data buffer */ + unsigned int index; /* index into buffer */ +}; + +void +sha256_init(struct sha256_ctx *ctx); + +void +sha256_update(struct sha256_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha256_digest(struct sha256_ctx *ctx, + size_t length, + uint8_t *digest); + +/* Internal compression function. STATE points to 8 uint32_t words, + DATA points to 64 bytes of input data, possibly unaligned, and K + points to the table of constants. */ +void +_nettle_sha256_compress(uint32_t *state, const uint8_t *data, const uint32_t *k); + + +/* SHA224, a truncated SHA256 with different initial state. */ + +#define SHA224_DIGEST_SIZE 28 +#define SHA224_BLOCK_SIZE SHA256_BLOCK_SIZE +#define sha224_ctx sha256_ctx + +void +sha224_init(struct sha256_ctx *ctx); + +#define sha224_update nettle_sha256_update + +void +sha224_digest(struct sha256_ctx *ctx, + size_t length, + uint8_t *digest); + + +/* SHA512 */ + +#define SHA512_DIGEST_SIZE 64 +#define SHA512_BLOCK_SIZE 128 + +/* Digest is kept internally as 8 64-bit words. */ +#define _SHA512_DIGEST_LENGTH 8 + +struct sha512_ctx +{ + uint64_t state[_SHA512_DIGEST_LENGTH]; /* State variables */ + uint64_t count_low, count_high; /* 128-bit block count */ + uint8_t block[SHA512_BLOCK_SIZE]; /* SHA512 data buffer */ + unsigned int index; /* index into buffer */ +}; + +void +sha512_init(struct sha512_ctx *ctx); + +void +sha512_update(struct sha512_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha512_digest(struct sha512_ctx *ctx, + size_t length, + uint8_t *digest); + +/* Internal compression function. STATE points to 8 uint64_t words, + DATA points to 128 bytes of input data, possibly unaligned, and K + points to the table of constants. */ +void +_nettle_sha512_compress(uint64_t *state, const uint8_t *data, const uint64_t *k); + + +/* SHA384, a truncated SHA512 with different initial state. */ + +#define SHA384_DIGEST_SIZE 48 +#define SHA384_BLOCK_SIZE SHA512_BLOCK_SIZE +#define sha384_ctx sha512_ctx + +void +sha384_init(struct sha512_ctx *ctx); + +#define sha384_update nettle_sha512_update + +void +sha384_digest(struct sha512_ctx *ctx, + size_t length, + uint8_t *digest); + + +/* SHA512_224 and SHA512_256, two truncated versions of SHA512 + with different initial states. */ + +#define SHA512_224_DIGEST_SIZE 28 +#define SHA512_224_BLOCK_SIZE SHA512_BLOCK_SIZE +#define sha512_224_ctx sha512_ctx + +void +sha512_224_init(struct sha512_224_ctx *ctx); + +#define sha512_224_update nettle_sha512_update + +void +sha512_224_digest(struct sha512_224_ctx *ctx, + size_t length, + uint8_t *digest); + +#define SHA512_256_DIGEST_SIZE 32 +#define SHA512_256_BLOCK_SIZE SHA512_BLOCK_SIZE +#define sha512_256_ctx sha512_ctx + +void +sha512_256_init(struct sha512_256_ctx *ctx); + +#define sha512_256_update nettle_sha512_update + +void +sha512_256_digest(struct sha512_256_ctx *ctx, + size_t length, + uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SHA2_H_INCLUDED */ diff --git a/include/nettle/sha3.h b/include/nettle/sha3.h new file mode 100644 index 0000000..0c65537 --- /dev/null +++ b/include/nettle/sha3.h @@ -0,0 +1,193 @@ +/* sha3.h + + The sha3 hash function (aka Keccak). + + Copyright (C) 2012 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_SHA3_H_INCLUDED +#define NETTLE_SHA3_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define sha3_permute nettle_sha3_permute +#define _sha3_update _nettle_sha3_update +#define _sha3_pad _nettle_sha3_pad +#define sha3_224_init nettle_sha3_224_init +#define sha3_224_update nettle_sha3_224_update +#define sha3_224_digest nettle_sha3_224_digest +#define sha3_256_init nettle_sha3_256_init +#define sha3_256_update nettle_sha3_256_update +#define sha3_256_digest nettle_sha3_256_digest +#define sha3_384_init nettle_sha3_384_init +#define sha3_384_update nettle_sha3_384_update +#define sha3_384_digest nettle_sha3_384_digest +#define sha3_512_init nettle_sha3_512_init +#define sha3_512_update nettle_sha3_512_update +#define sha3_512_digest nettle_sha3_512_digest + +/* Indicates that SHA3 is the NIST FIPS 202 version. */ +#define NETTLE_SHA3_FIPS202 1 + +/* The sha3 state is a 5x5 matrix of 64-bit words. In the notation of + Keccak description, S[x,y] is element x + 5*y, so if x is + interpreted as the row index and y the column index, it is stored + in column-major order. */ +#define SHA3_STATE_LENGTH 25 + +/* The "width" is 1600 bits or 200 octets */ +struct sha3_state +{ + uint64_t a[SHA3_STATE_LENGTH]; +}; + +void +sha3_permute (struct sha3_state *state); + +unsigned +_sha3_update (struct sha3_state *state, + unsigned block_size, uint8_t *block, + unsigned pos, + size_t length, const uint8_t *data); +void +_sha3_pad (struct sha3_state *state, + unsigned block_size, uint8_t *block, unsigned pos); + +/* The "capacity" is set to 2*(digest size), 512 bits or 64 octets. + The "rate" is the width - capacity, or width - 2 * (digest + size). */ + +#define SHA3_224_DIGEST_SIZE 28 +#define SHA3_224_BLOCK_SIZE 144 + +#define SHA3_256_DIGEST_SIZE 32 +#define SHA3_256_BLOCK_SIZE 136 + +#define SHA3_384_DIGEST_SIZE 48 +#define SHA3_384_BLOCK_SIZE 104 + +#define SHA3_512_DIGEST_SIZE 64 +#define SHA3_512_BLOCK_SIZE 72 + +/* For backwards compatibility */ +#define SHA3_224_DATA_SIZE SHA3_224_BLOCK_SIZE +#define SHA3_256_DATA_SIZE SHA3_256_BLOCK_SIZE +#define SHA3_384_DATA_SIZE SHA3_384_BLOCK_SIZE +#define SHA3_512_DATA_SIZE SHA3_512_BLOCK_SIZE + +struct sha3_224_ctx +{ + struct sha3_state state; + unsigned index; + uint8_t block[SHA3_224_BLOCK_SIZE]; +}; + +void +sha3_224_init (struct sha3_224_ctx *ctx); + +void +sha3_224_update (struct sha3_224_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha3_224_digest(struct sha3_224_ctx *ctx, + size_t length, + uint8_t *digest); + +struct sha3_256_ctx +{ + struct sha3_state state; + unsigned index; + uint8_t block[SHA3_256_BLOCK_SIZE]; +}; + +void +sha3_256_init (struct sha3_256_ctx *ctx); + +void +sha3_256_update (struct sha3_256_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha3_256_digest(struct sha3_256_ctx *ctx, + size_t length, + uint8_t *digest); + +struct sha3_384_ctx +{ + struct sha3_state state; + unsigned index; + uint8_t block[SHA3_384_BLOCK_SIZE]; +}; + +void +sha3_384_init (struct sha3_384_ctx *ctx); + +void +sha3_384_update (struct sha3_384_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha3_384_digest(struct sha3_384_ctx *ctx, + size_t length, + uint8_t *digest); + +struct sha3_512_ctx +{ + struct sha3_state state; + unsigned index; + uint8_t block[SHA3_512_BLOCK_SIZE]; +}; + +void +sha3_512_init (struct sha3_512_ctx *ctx); + +void +sha3_512_update (struct sha3_512_ctx *ctx, + size_t length, + const uint8_t *data); + +void +sha3_512_digest(struct sha3_512_ctx *ctx, + size_t length, + uint8_t *digest); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_SHA3_H_INCLUDED */ diff --git a/include/nettle/twofish.h b/include/nettle/twofish.h new file mode 100644 index 0000000..1056e59 --- /dev/null +++ b/include/nettle/twofish.h @@ -0,0 +1,98 @@ +/* twofish.h + + The twofish block cipher. + + Copyright (C) 2001, 2014 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +/* + * Twofish is a 128-bit block cipher that accepts a variable-length + * key up to 256 bits, designed by Bruce Schneier and others. See + * http://www.counterpane.com/twofish.html for details. + */ + +#ifndef NETTLE_TWOFISH_H_INCLUDED +#define NETTLE_TWOFISH_H_INCLUDED + +#include "nettle-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define twofish_set_key nettle_twofish_set_key +#define twofish128_set_key nettle_twofish128_set_key +#define twofish192_set_key nettle_twofish192_set_key +#define twofish256_set_key nettle_twofish256_set_key +#define twofish_encrypt nettle_twofish_encrypt +#define twofish_decrypt nettle_twofish_decrypt + +#define TWOFISH_BLOCK_SIZE 16 + +/* Variable key size between 128 and 256 bits. But the only valid + * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */ +#define TWOFISH_MIN_KEY_SIZE 16 +#define TWOFISH_MAX_KEY_SIZE 32 + +#define TWOFISH_KEY_SIZE 32 +#define TWOFISH128_KEY_SIZE 16 +#define TWOFISH192_KEY_SIZE 24 +#define TWOFISH256_KEY_SIZE 32 + +struct twofish_ctx +{ + uint32_t keys[40]; + uint32_t s_box[4][256]; +}; + +void +twofish_set_key(struct twofish_ctx *ctx, + size_t length, const uint8_t *key); +void +twofish128_set_key(struct twofish_ctx *context, const uint8_t *key); +void +twofish192_set_key(struct twofish_ctx *context, const uint8_t *key); +void +twofish256_set_key(struct twofish_ctx *context, const uint8_t *key); + +void +twofish_encrypt(const struct twofish_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +twofish_decrypt(const struct twofish_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_TWOFISH_H_INCLUDED */ diff --git a/include/nettle/umac.h b/include/nettle/umac.h new file mode 100644 index 0000000..f4d3c7a --- /dev/null +++ b/include/nettle/umac.h @@ -0,0 +1,253 @@ +/* umac.h + + UMAC message authentication code (RFC-4418). + + Copyright (C) 2013 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_UMAC_H_INCLUDED +#define NETTLE_UMAC_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/* Namespace mangling */ +#define umac32_set_key nettle_umac32_set_key +#define umac64_set_key nettle_umac64_set_key +#define umac96_set_key nettle_umac96_set_key +#define umac128_set_key nettle_umac128_set_key +#define umac32_set_nonce nettle_umac32_set_nonce +#define umac64_set_nonce nettle_umac64_set_nonce +#define umac96_set_nonce nettle_umac96_set_nonce +#define umac128_set_nonce nettle_umac128_set_nonce +#define umac32_update nettle_umac32_update +#define umac64_update nettle_umac64_update +#define umac96_update nettle_umac96_update +#define umac128_update nettle_umac128_update +#define umac32_digest nettle_umac32_digest +#define umac64_digest nettle_umac64_digest +#define umac96_digest nettle_umac96_digest +#define umac128_digest nettle_umac128_digest +#define _umac_set_key _nettle_umac_set_key +#define _umac_nh _nettle_umac_nh +#define _umac_nh_n _nettle_umac_nh_n +#define _umac_poly64 _nettle_umac_poly64 +#define _umac_poly128 _nettle_umac_poly128 +#define _umac_l2_init _nettle_umac_l2_init +#define _umac_l2 _nettle_umac_l2 +#define _umac_l2_final _nettle_umac_l2_final +#define _umac_l3_init _nettle_umac_l3_init +#define _umac_l3 _nettle_umac_l3 + +#include "nettle-types.h" +#include "aes.h" + +#define UMAC_KEY_SIZE AES128_KEY_SIZE +#define UMAC32_DIGEST_SIZE 4 +#define UMAC64_DIGEST_SIZE 8 +#define UMAC96_DIGEST_SIZE 12 +#define UMAC128_DIGEST_SIZE 16 +#define UMAC_BLOCK_SIZE 1024 +#define UMAC_MIN_NONCE_SIZE 1 +#define UMAC_MAX_NONCE_SIZE AES_BLOCK_SIZE +/* For backwards compatibility */ +#define UMAC_DATA_SIZE UMAC_BLOCK_SIZE + +/* Subkeys and state for UMAC with tag size 32*n bits. */ +#define _UMAC_STATE(n) \ + uint32_t l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)]; \ + /* Keys in 32-bit pieces, high first */ \ + uint32_t l2_key[6*(n)]; \ + uint64_t l3_key1[8*(n)]; \ + uint32_t l3_key2[(n)]; \ + /* AES cipher for encrypting the nonce */ \ + struct aes128_ctx pdf_key; \ + /* The l2_state consists of 2*n uint64_t, for poly64 \ + and poly128 hashing, followed by n additional \ + uint64_t used as an input buffer. */ \ + uint64_t l2_state[3*(n)]; \ + /* Input to the pdf_key, zero-padded and low bits \ + cleared if appropriate. */ \ + uint8_t nonce[AES_BLOCK_SIZE]; \ + unsigned short nonce_length /* For incrementing */ + + /* Buffering */ +#define _UMAC_BUFFER \ + unsigned index; \ + /* Complete blocks processed */ \ + uint64_t count; \ + uint8_t block[UMAC_BLOCK_SIZE] + +#define _UMAC_NONCE_CACHED 0x80 + +struct umac32_ctx +{ + _UMAC_STATE(1); + /* Low bits and cache flag. */ + unsigned short nonce_low; + /* Previous padding block */ + uint32_t pad_cache[AES_BLOCK_SIZE / 4]; + _UMAC_BUFFER; +}; + +struct umac64_ctx +{ + _UMAC_STATE(2); + /* Low bit and cache flag. */ + unsigned short nonce_low; + /* Previous padding block */ + uint32_t pad_cache[AES_BLOCK_SIZE/4]; + _UMAC_BUFFER; +}; + +struct umac96_ctx +{ + _UMAC_STATE(3); + _UMAC_BUFFER; +}; + +struct umac128_ctx +{ + _UMAC_STATE(4); + _UMAC_BUFFER; +}; + +/* The _set_key function initialize the nonce to zero. */ +void +umac32_set_key (struct umac32_ctx *ctx, const uint8_t *key); +void +umac64_set_key (struct umac64_ctx *ctx, const uint8_t *key); +void +umac96_set_key (struct umac96_ctx *ctx, const uint8_t *key); +void +umac128_set_key (struct umac128_ctx *ctx, const uint8_t *key); + +/* Optional, if not used, messages get incrementing nonces starting from zero. */ +void +umac32_set_nonce (struct umac32_ctx *ctx, + size_t nonce_length, const uint8_t *nonce); +void +umac64_set_nonce (struct umac64_ctx *ctx, + size_t nonce_length, const uint8_t *nonce); +void +umac96_set_nonce (struct umac96_ctx *ctx, + size_t nonce_length, const uint8_t *nonce); +void +umac128_set_nonce (struct umac128_ctx *ctx, + size_t nonce_length, const uint8_t *nonce); + +void +umac32_update (struct umac32_ctx *ctx, + size_t length, const uint8_t *data); +void +umac64_update (struct umac64_ctx *ctx, + size_t length, const uint8_t *data); +void +umac96_update (struct umac96_ctx *ctx, + size_t length, const uint8_t *data); +void +umac128_update (struct umac128_ctx *ctx, + size_t length, const uint8_t *data); + +/* The _digest functions increment the nonce */ +void +umac32_digest (struct umac32_ctx *ctx, + size_t length, uint8_t *digest); +void +umac64_digest (struct umac64_ctx *ctx, + size_t length, uint8_t *digest); +void +umac96_digest (struct umac96_ctx *ctx, + size_t length, uint8_t *digest); +void +umac128_digest (struct umac128_ctx *ctx, + size_t length, uint8_t *digest); + + +/* Internal functions */ +#define UMAC_POLY64_BLOCKS 16384 + +#define UMAC_P64_OFFSET 59 +#define UMAC_P64 (- (uint64_t) UMAC_P64_OFFSET) + +#define UMAC_P128_OFFSET 159 +#define UMAC_P128_HI (~(uint64_t) 0) +#define UMAC_P128_LO (-(uint64_t) UMAC_P128_OFFSET) + +void +_umac_set_key (uint32_t *l1_key, uint32_t *l2_key, + uint64_t *l3_key1, uint32_t *l3_key2, + struct aes128_ctx *pad, const uint8_t *key, unsigned n); + +uint64_t +_umac_nh (const uint32_t *key, unsigned length, const uint8_t *msg); + +/* Equivalent to + + for (i = 0; i < n; i++) + out[i] = _umac_nh (key + 4*i, length, msg); + + but processing input only once. +*/ +void +_umac_nh_n (uint64_t *out, unsigned n, const uint32_t *key, + unsigned length, const uint8_t *msg); + +/* Returns y*k + m (mod p), including "marker" processing. Return + value is *not* in canonical representation, and must be normalized + before the output is used. */ +uint64_t +_umac_poly64 (uint32_t kh, uint32_t kl, uint64_t y, uint64_t m); + +void +_umac_poly128 (const uint32_t *k, uint64_t *y, uint64_t mh, uint64_t ml); + +void +_umac_l2_init (unsigned size, uint32_t *k); + +void +_umac_l2(const uint32_t *key, uint64_t *state, unsigned n, + uint64_t count, const uint64_t *m); + +void +_umac_l2_final(const uint32_t *key, uint64_t *state, unsigned n, + uint64_t count); + +void +_umac_l3_init (unsigned size, uint64_t *k); + +uint32_t +_umac_l3 (const uint64_t *key, const uint64_t *m); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_UMAC_H_INCLUDED */ diff --git a/include/nettle/version.h b/include/nettle/version.h new file mode 100644 index 0000000..b202049 --- /dev/null +++ b/include/nettle/version.h @@ -0,0 +1,64 @@ +/* version.h + + Information about library version. + + Copyright (C) 2015 Red Hat, Inc. + Copyright (C) 2015 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_VERSION_H_INCLUDED +#define NETTLE_VERSION_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/* Individual version numbers in decimal */ +#define NETTLE_VERSION_MAJOR 3 +#define NETTLE_VERSION_MINOR 4 + +#define NETTLE_USE_MINI_GMP 0 + +/* We need a preprocessor constant for GMP_NUMB_BITS, simply using + sizeof(mp_limb_t) * CHAR_BIT is not good enough. */ +#if NETTLE_USE_MINI_GMP +# define GMP_NUMB_BITS n/a +#endif + +int +nettle_version_major (void); + +int +nettle_version_minor (void); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_VERSION_H_INCLUDED */ diff --git a/include/nettle/yarrow.h b/include/nettle/yarrow.h new file mode 100644 index 0000000..808ac0a --- /dev/null +++ b/include/nettle/yarrow.h @@ -0,0 +1,145 @@ +/* yarrow.h + + The yarrow pseudo-randomness generator. + + Copyright (C) 2001 Niels M枚ller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#ifndef NETTLE_YARROW_H_INCLUDED +#define NETTLE_YARROW_H_INCLUDED + +#include "aes.h" +#include "sha2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Name mangling */ +#define yarrow256_init nettle_yarrow256_init +#define yarrow256_seed nettle_yarrow256_seed +#define yarrow256_update nettle_yarrow256_update +#define yarrow256_random nettle_yarrow256_random +#define yarrow256_is_seeded nettle_yarrow256_is_seeded +#define yarrow256_needed_sources nettle_yarrow256_needed_sources +#define yarrow256_fast_reseed nettle_yarrow256_fast_reseed +#define yarrow256_slow_reseed nettle_yarrow256_slow_reseed +#define yarrow_key_event_init nettle_yarrow_key_event_init +#define yarrow_key_event_estimate nettle_yarrow_key_event_estimate + +/* Obsolete alias for backwards compatibility. Will be deleted in some + later version. */ +#define yarrow256_force_reseed yarrow256_slow_reseed + +enum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 }; + +struct yarrow_source +{ + /* Indexed by yarrow_pool_id */ + uint32_t estimate[2]; + + /* The pool next sample should go to. */ + enum yarrow_pool_id next; +}; + + +#define YARROW256_SEED_FILE_SIZE (2 * AES_BLOCK_SIZE) + +/* Yarrow-256, based on SHA-256 and AES-256 */ +struct yarrow256_ctx +{ + /* Indexed by yarrow_pool_id */ + struct sha256_ctx pools[2]; + + int seeded; + + /* The current key and counter block */ + struct aes256_ctx key; + uint8_t counter[AES_BLOCK_SIZE]; + + /* The entropy sources */ + unsigned nsources; + struct yarrow_source *sources; +}; + +void +yarrow256_init(struct yarrow256_ctx *ctx, + unsigned nsources, + struct yarrow_source *sources); + +void +yarrow256_seed(struct yarrow256_ctx *ctx, + size_t length, + const uint8_t *seed_file); + +/* Returns 1 on reseed */ +int +yarrow256_update(struct yarrow256_ctx *ctx, + unsigned source, unsigned entropy, + size_t length, const uint8_t *data); + +void +yarrow256_random(struct yarrow256_ctx *ctx, size_t length, uint8_t *dst); + +int +yarrow256_is_seeded(struct yarrow256_ctx *ctx); + +unsigned +yarrow256_needed_sources(struct yarrow256_ctx *ctx); + +void +yarrow256_fast_reseed(struct yarrow256_ctx *ctx); + +void +yarrow256_slow_reseed(struct yarrow256_ctx *ctx); + + +/* Key event estimator */ +#define YARROW_KEY_EVENT_BUFFER 16 + +struct yarrow_key_event_ctx +{ + /* Counter for initial priming of the state */ + unsigned index; + unsigned chars[YARROW_KEY_EVENT_BUFFER]; + unsigned previous; +}; + +void +yarrow_key_event_init(struct yarrow_key_event_ctx *ctx); + +unsigned +yarrow_key_event_estimate(struct yarrow_key_event_ctx *ctx, + unsigned key, unsigned time); + +#ifdef __cplusplus +} +#endif + +#endif /* NETTLE_YARROW_H_INCLUDED */ diff --git a/include/zip.h b/include/zip.h new file mode 100644 index 0000000..a90776d --- /dev/null +++ b/include/zip.h @@ -0,0 +1,479 @@ +#ifndef _HAD_ZIP_H +#define _HAD_ZIP_H + +/* + zip.h -- exported declarations. + Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* fix autoindent */ +#endif +#endif + +#include + +#ifndef ZIP_EXTERN +#ifndef ZIP_STATIC +#ifdef _WIN32 +#define ZIP_EXTERN __declspec(dllimport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define ZIP_EXTERN __attribute__((visibility("default"))) +#else +#define ZIP_EXTERN +#endif +#else +#define ZIP_EXTERN +#endif +#endif + +#include +#include +#include + +/* flags for zip_open */ + +#define ZIP_CREATE 1 +#define ZIP_EXCL 2 +#define ZIP_CHECKCONS 4 +#define ZIP_TRUNCATE 8 +#define ZIP_RDONLY 16 + + +/* flags for zip_name_locate, zip_fopen, zip_stat, ... */ + +#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */ +#define ZIP_FL_NODIR 2u /* ignore directory component */ +#define ZIP_FL_COMPRESSED 4u /* read compressed data */ +#define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */ +#define ZIP_FL_RECOMPRESS 16u /* force recompression of data */ +#define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */ +#define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */ +#define ZIP_FL_ENC_RAW 64u /* get unmodified string */ +#define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */ +#define ZIP_FL_LOCAL 256u /* in local header */ +#define ZIP_FL_CENTRAL 512u /* in central directory */ +/* 1024u reserved for internal use */ +#define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */ +#define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */ +#define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */ + +/* archive global flags flags */ + +#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */ + + +/* create a new extra field */ + +#define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX +#define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX + + +/* libzip error codes */ + +#define ZIP_ER_OK 0 /* N No error */ +#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */ +#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */ +#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */ +#define ZIP_ER_SEEK 4 /* S Seek error */ +#define ZIP_ER_READ 5 /* S Read error */ +#define ZIP_ER_WRITE 6 /* S Write error */ +#define ZIP_ER_CRC 7 /* N CRC error */ +#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */ +#define ZIP_ER_NOENT 9 /* N No such file */ +#define ZIP_ER_EXISTS 10 /* N File already exists */ +#define ZIP_ER_OPEN 11 /* S Can't open file */ +#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */ +#define ZIP_ER_ZLIB 13 /* Z Zlib error */ +#define ZIP_ER_MEMORY 14 /* N Malloc failure */ +#define ZIP_ER_CHANGED 15 /* N Entry has been changed */ +#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */ +#define ZIP_ER_EOF 17 /* N Premature end of file */ +#define ZIP_ER_INVAL 18 /* N Invalid argument */ +#define ZIP_ER_NOZIP 19 /* N Not a zip archive */ +#define ZIP_ER_INTERNAL 20 /* N Internal error */ +#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */ +#define ZIP_ER_REMOVE 22 /* S Can't remove file */ +#define ZIP_ER_DELETED 23 /* N Entry has been deleted */ +#define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */ +#define ZIP_ER_RDONLY 25 /* N Read-only archive */ +#define ZIP_ER_NOPASSWD 26 /* N No password provided */ +#define ZIP_ER_WRONGPASSWD 27 /* N Wrong password provided */ +#define ZIP_ER_OPNOTSUPP 28 /* N Operation not supported */ +#define ZIP_ER_INUSE 29 /* N Resource still in use */ +#define ZIP_ER_TELL 30 /* S Tell error */ +#define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */ +#define ZIP_ER_CANCELLED 32 /* N Operation cancelled */ + +/* type of system error value */ + +#define ZIP_ET_NONE 0 /* sys_err unused */ +#define ZIP_ET_SYS 1 /* sys_err is errno */ +#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */ + +/* compression methods */ + +#define ZIP_CM_DEFAULT -1 /* better of deflate or store */ +#define ZIP_CM_STORE 0 /* stored (uncompressed) */ +#define ZIP_CM_SHRINK 1 /* shrunk */ +#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */ +#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */ +#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */ +#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */ +#define ZIP_CM_IMPLODE 6 /* imploded */ +/* 7 - Reserved for Tokenizing compression algorithm */ +#define ZIP_CM_DEFLATE 8 /* deflated */ +#define ZIP_CM_DEFLATE64 9 /* deflate64 */ +#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */ +/* 11 - Reserved by PKWARE */ +#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */ +/* 13 - Reserved by PKWARE */ +#define ZIP_CM_LZMA 14 /* LZMA (EFS) */ +/* 15-17 - Reserved by PKWARE */ +#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */ +#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */ +#define ZIP_CM_LZMA2 33 +#define ZIP_CM_XZ 95 /* XZ compressed data */ +#define ZIP_CM_JPEG 96 /* Compressed Jpeg data */ +#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */ +#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */ + +/* encryption methods */ + +#define ZIP_EM_NONE 0 /* not encrypted */ +#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */ +#if 0 /* Strong Encryption Header not parsed yet */ +#define ZIP_EM_DES 0x6601 /* strong encryption: DES */ +#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */ +#define ZIP_EM_3DES_168 0x6603 +#define ZIP_EM_3DES_112 0x6609 +#define ZIP_EM_PKZIP_AES_128 0x660e +#define ZIP_EM_PKZIP_AES_192 0x660f +#define ZIP_EM_PKZIP_AES_256 0x6610 +#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */ +#define ZIP_EM_RC4 0x6801 +#endif +#define ZIP_EM_AES_128 0x0101 /* Winzip AES encryption */ +#define ZIP_EM_AES_192 0x0102 +#define ZIP_EM_AES_256 0x0103 +#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */ + +#define ZIP_OPSYS_DOS 0x00u +#define ZIP_OPSYS_AMIGA 0x01u +#define ZIP_OPSYS_OPENVMS 0x02u +#define ZIP_OPSYS_UNIX 0x03u +#define ZIP_OPSYS_VM_CMS 0x04u +#define ZIP_OPSYS_ATARI_ST 0x05u +#define ZIP_OPSYS_OS_2 0x06u +#define ZIP_OPSYS_MACINTOSH 0x07u +#define ZIP_OPSYS_Z_SYSTEM 0x08u +#define ZIP_OPSYS_CPM 0x09u +#define ZIP_OPSYS_WINDOWS_NTFS 0x0au +#define ZIP_OPSYS_MVS 0x0bu +#define ZIP_OPSYS_VSE 0x0cu +#define ZIP_OPSYS_ACORN_RISC 0x0du +#define ZIP_OPSYS_VFAT 0x0eu +#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu +#define ZIP_OPSYS_BEOS 0x10u +#define ZIP_OPSYS_TANDEM 0x11u +#define ZIP_OPSYS_OS_400 0x12u +#define ZIP_OPSYS_OS_X 0x13u + +#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX + + +enum zip_source_cmd { + ZIP_SOURCE_OPEN, /* prepare for reading */ + ZIP_SOURCE_READ, /* read data */ + ZIP_SOURCE_CLOSE, /* reading is done */ + ZIP_SOURCE_STAT, /* get meta information */ + ZIP_SOURCE_ERROR, /* get error information */ + ZIP_SOURCE_FREE, /* cleanup and free resources */ + ZIP_SOURCE_SEEK, /* set position for reading */ + ZIP_SOURCE_TELL, /* get read position */ + ZIP_SOURCE_BEGIN_WRITE, /* prepare for writing */ + ZIP_SOURCE_COMMIT_WRITE, /* writing is done */ + ZIP_SOURCE_ROLLBACK_WRITE, /* discard written changes */ + ZIP_SOURCE_WRITE, /* write data */ + ZIP_SOURCE_SEEK_WRITE, /* set position for writing */ + ZIP_SOURCE_TELL_WRITE, /* get write position */ + ZIP_SOURCE_SUPPORTS, /* check whether source supports command */ + ZIP_SOURCE_REMOVE, /* remove file */ + ZIP_SOURCE_RESERVED_1, /* previously used internally */ + ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */ + ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */ + ZIP_SOURCE_GET_FILE_ATTRIBUTES /* get additional file attributes */ +}; +typedef enum zip_source_cmd zip_source_cmd_t; + +#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd) (((zip_int64_t)1) << (cmd)) + +/* clang-format off */ + +#define ZIP_SOURCE_SUPPORTS_READABLE (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_OPEN) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_READ) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_CLOSE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_STAT) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ERROR) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_FREE)) + +#define ZIP_SOURCE_SUPPORTS_SEEKABLE (ZIP_SOURCE_SUPPORTS_READABLE \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SUPPORTS)) + +#define ZIP_SOURCE_SUPPORTS_WRITABLE (ZIP_SOURCE_SUPPORTS_SEEKABLE \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_COMMIT_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ROLLBACK_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_REMOVE)) + +/* clang-format on */ + +/* for use by sources */ +struct zip_source_args_seek { + zip_int64_t offset; + int whence; +}; + +typedef struct zip_source_args_seek zip_source_args_seek_t; +#define ZIP_SOURCE_GET_ARGS(type, data, len, error) ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data)) + + +/* error information */ +/* use zip_error_*() to access */ +struct zip_error { + int zip_err; /* libzip error code (ZIP_ER_*) */ + int sys_err; /* copy of errno (E*) or zlib error code */ + char *_Nullable str; /* string representation or NULL */ +}; + +#define ZIP_STAT_NAME 0x0001u +#define ZIP_STAT_INDEX 0x0002u +#define ZIP_STAT_SIZE 0x0004u +#define ZIP_STAT_COMP_SIZE 0x0008u +#define ZIP_STAT_MTIME 0x0010u +#define ZIP_STAT_CRC 0x0020u +#define ZIP_STAT_COMP_METHOD 0x0040u +#define ZIP_STAT_ENCRYPTION_METHOD 0x0080u +#define ZIP_STAT_FLAGS 0x0100u + +struct zip_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *_Nullable name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; + +struct zip_buffer_fragment { + zip_uint8_t *_Nonnull data; + zip_uint64_t length; +}; + +struct zip_file_attributes { + zip_uint64_t valid; /* which fields have valid values */ + zip_uint8_t version; /* version of this struct, currently 1 */ + zip_uint8_t host_system; /* host system on which file was created */ + zip_uint8_t ascii; /* flag whether file is ASCII text */ + zip_uint8_t version_needed; /* minimum version needed to extract file */ + zip_uint32_t external_file_attributes; /* external file attributes (host-system specific) */ + zip_uint16_t general_purpose_bit_flags; /* general purpose big flags, only some bits are honored */ + zip_uint16_t general_purpose_bit_mask; /* which bits in general_purpose_bit_flags are valid */ +}; + +#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM 0x0001u +#define ZIP_FILE_ATTRIBUTES_ASCII 0x0002u +#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED 0x0004u +#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES 0x0008u +#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS 0x0010u + +struct zip; +struct zip_file; +struct zip_source; + +typedef struct zip zip_t; +typedef struct zip_error zip_error_t; +typedef struct zip_file zip_file_t; +typedef struct zip_file_attributes zip_file_attributes_t; +typedef struct zip_source zip_source_t; +typedef struct zip_stat zip_stat_t; +typedef struct zip_buffer_fragment zip_buffer_fragment_t; + +typedef zip_uint32_t zip_flags_t; + +typedef zip_int64_t (*zip_source_callback)(void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t); +typedef void (*zip_progress_callback)(zip_t *_Nonnull, double, void *_Nullable); +typedef int (*zip_cancel_callback)(zip_t *_Nonnull, void *_Nullable); + +#ifndef ZIP_DISABLE_DEPRECATED +typedef void (*zip_progress_callback_t)(double); +ZIP_EXTERN void zip_register_progress_callback(zip_t *_Nonnull, zip_progress_callback_t _Nullable); /* use zip_register_progress_callback_with_state */ + +ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull); /* use zip_file_add */ +ZIP_EXTERN zip_int64_t zip_add_dir(zip_t *_Nonnull, const char *_Nonnull); /* use zip_dir_add */ +ZIP_EXTERN const char *_Nullable zip_get_file_comment(zip_t *_Nonnull, zip_uint64_t, int *_Nullable, int); /* use zip_file_get_comment */ +ZIP_EXTERN int zip_get_num_files(zip_t *_Nonnull); /* use zip_get_num_entries instead */ +ZIP_EXTERN int zip_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull); /* use zip_file_rename */ +ZIP_EXTERN int zip_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull); /* use zip_file_replace */ +ZIP_EXTERN int zip_set_file_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, int); /* use zip_file_set_comment */ +ZIP_EXTERN int zip_error_get_sys_type(int); /* use zip_error_system_type */ +ZIP_EXTERN void zip_error_get(zip_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_get_error, zip_error_code_zip / zip_error_code_system */ +ZIP_EXTERN int zip_error_to_str(char *_Nonnull, zip_uint64_t, int, int); /* use zip_error_init_with_code / zip_error_strerror */ +ZIP_EXTERN void zip_file_error_get(zip_file_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_file_get_error, zip_error_code_zip / zip_error_code_system */ +#endif + +ZIP_EXTERN int zip_close(zip_t *_Nonnull); +ZIP_EXTERN int zip_delete(zip_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN void zip_discard(zip_t *_Nonnull); + +ZIP_EXTERN zip_error_t *_Nonnull zip_get_error(zip_t *_Nonnull); +ZIP_EXTERN void zip_error_clear(zip_t *_Nonnull); +ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull); +ZIP_EXTERN int zip_error_code_system(const zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_init_with_code(zip_error_t *_Nonnull, int); +ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int); +ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull); +ZIP_EXTERN int zip_error_system_type(const zip_error_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t); + +ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull); +ZIP_EXTERN zip_t *_Nullable zip_fdopen(int, int, int *_Nullable); +ZIP_EXTERN zip_int64_t zip_file_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t); +ZIP_EXTERN void zip_file_attributes_init(zip_file_attributes_t *_Nonnull); +ZIP_EXTERN void zip_file_error_clear(zip_file_t *_Nonnull); +ZIP_EXTERN int zip_file_extra_field_delete(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_extra_field_delete_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_extra_field_set(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *_Nullable, zip_uint16_t, zip_flags_t); +ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_uint16_t *_Nullable, zip_flags_t); +ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_flags_t); +ZIP_EXTERN const char *_Nullable zip_file_get_comment(zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t); +ZIP_EXTERN zip_error_t *_Nonnull zip_file_get_error(zip_file_t *_Nonnull); +ZIP_EXTERN int zip_file_get_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t *_Nullable, zip_uint32_t *_Nullable); +ZIP_EXTERN int zip_file_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN int zip_file_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t); +ZIP_EXTERN int zip_file_set_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_set_dostime(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_set_encryption(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, const char *_Nullable); +ZIP_EXTERN int zip_file_set_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t); +ZIP_EXTERN int zip_file_set_mtime(zip_t *_Nonnull, zip_uint64_t, time_t, zip_flags_t); +ZIP_EXTERN const char *_Nonnull zip_file_strerror(zip_file_t *_Nonnull); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_encrypted(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, const char *_Nullable); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable); +ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *_Nonnull); +ZIP_EXTERN const char *_Nullable zip_get_archive_comment(zip_t *_Nonnull, int *_Nullable, zip_flags_t); +ZIP_EXTERN int zip_get_archive_flag(zip_t *_Nonnull, zip_flags_t, zip_flags_t); +ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *_Nonnull, zip_flags_t); +ZIP_EXTERN const char *_Nonnull zip_libzip_version(void); +ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable); +ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable); +ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *_Nonnull, double, zip_progress_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); +ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t *_Nonnull, zip_cancel_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); +ZIP_EXTERN int zip_set_archive_comment(zip_t *_Nonnull, const char *_Nullable, zip_uint16_t); +ZIP_EXTERN int zip_set_archive_flag(zip_t *_Nonnull, zip_flags_t, int); +ZIP_EXTERN int zip_set_default_password(zip_t *_Nonnull, const char *_Nullable); +ZIP_EXTERN int zip_set_file_compression(zip_t *_Nonnull, zip_uint64_t, zip_int32_t, zip_uint32_t); +ZIP_EXTERN int zip_source_begin_write(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create(const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment(zip_t *_Nonnull, const zip_buffer_fragment_t *_Nonnull, zip_uint64_t, int); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_commit_write(zip_source_t *_Nonnull); +ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull); +ZIP_EXTERN zip_source_t *_Nullable zip_source_file(zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_filep(zip_t *_Nonnull, FILE *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create(FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_function(zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_function_create(zip_source_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_get_file_attributes(zip_source_t *_Nonnull, zip_file_attributes_t *_Nonnull); +ZIP_EXTERN int zip_source_is_deleted(zip_source_t *_Nonnull); +ZIP_EXTERN void zip_source_keep(zip_source_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t, ...); +ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t); +ZIP_EXTERN void zip_source_rollback_write(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset(zip_uint64_t, zip_uint64_t, void *_Nonnull, zip_uint64_t, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_seek_write(zip_source_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_tell(zip_source_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull); +#ifdef _WIN32 +ZIP_EXTERN zip_source_t *zip_source_win32a(zip_t *, const char *, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *zip_source_win32a_create(const char *, zip_uint64_t, zip_int64_t, zip_error_t *); +ZIP_EXTERN zip_source_t *zip_source_win32handle(zip_t *, void *, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *zip_source_win32handle_create(void *, zip_uint64_t, zip_int64_t, zip_error_t *); +ZIP_EXTERN zip_source_t *zip_source_win32w(zip_t *, const wchar_t *, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *zip_source_win32w_create(const wchar_t *, zip_uint64_t, zip_int64_t, zip_error_t *); +#endif +ZIP_EXTERN zip_int64_t zip_source_write(zip_source_t *_Nonnull, const void *_Nullable, zip_uint64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_zip(zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t); +ZIP_EXTERN int zip_stat(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, zip_stat_t *_Nonnull); +ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull); +ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull); +ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull); +ZIP_EXTERN int zip_unchange(zip_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN int zip_unchange_all(zip_t *_Nonnull); +ZIP_EXTERN int zip_unchange_archive(zip_t *_Nonnull); +ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress); +ZIP_EXTERN int zip_encryption_method_supported(zip_uint16_t method, int encode); + +#ifdef __cplusplus +} +#endif + +#endif /* _HAD_ZIP_H */ diff --git a/include/zipconf.h b/include/zipconf.h new file mode 100644 index 0000000..861595a --- /dev/null +++ b/include/zipconf.h @@ -0,0 +1,51 @@ +#ifndef _HAD_ZIPCONF_H +#define _HAD_ZIPCONF_H + +/* + zipconf.h -- platform specific include file + + This file was generated automatically by CMake + based on ../cmake-zipconf.h.in. + */ + +#define LIBZIP_VERSION "1.7.3" +#define LIBZIP_VERSION_MAJOR 1 +#define LIBZIP_VERSION_MINOR 7 +#define LIBZIP_VERSION_MICRO 3 + +/* #undef ZIP_STATIC */ + +#define _Nullable +#define _Nonnull + +#if !defined(__STDC_FORMAT_MACROS) +#define __STDC_FORMAT_MACROS 1 +#endif +#include + +typedef int8_t zip_int8_t; +typedef uint8_t zip_uint8_t; +typedef int16_t zip_int16_t; +typedef uint16_t zip_uint16_t; +typedef int32_t zip_int32_t; +typedef uint32_t zip_uint32_t; +typedef int64_t zip_int64_t; +typedef uint64_t zip_uint64_t; + +#define ZIP_INT8_MIN (-ZIP_INT8_MAX-1) +#define ZIP_INT8_MAX 0x7f +#define ZIP_UINT8_MAX 0xff + +#define ZIP_INT16_MIN (-ZIP_INT16_MAX-1) +#define ZIP_INT16_MAX 0x7fff +#define ZIP_UINT16_MAX 0xffff + +#define ZIP_INT32_MIN (-ZIP_INT32_MAX-1L) +#define ZIP_INT32_MAX 0x7fffffffL +#define ZIP_UINT32_MAX 0xffffffffLU + +#define ZIP_INT64_MIN (-ZIP_INT64_MAX-1LL) +#define ZIP_INT64_MAX 0x7fffffffffffffffLL +#define ZIP_UINT64_MAX 0xffffffffffffffffULL + +#endif /* zipconf.h */ diff --git a/omc/config/NR.conf b/omc/config/NR.conf new file mode 100644 index 0000000..0a27d88 --- /dev/null +++ b/omc/config/NR.conf @@ -0,0 +1,45 @@ +# NR.conf + +# The local mcc +MCC=262 + +# The local mnc +MNC=09 + +# The local tag +LOCAL_TADIG=FEAKE + +# The time to make NRTRDE Delivery Report and Error Report +MAKE_REPORT_TIME=23 + +# The max value of CallEventDuration of a CDR +CallEventDurationMax=6000 + +# The version of the NRTRDE Delivery report +ND_VERSION=1.0 + +# The version of the NRTRDE Error report +NE_VERSION=1.0 + +# The specificationVersionNumber of the NRTRDE file +NR_SVN=2 + +# The ReleaseVersionNumber of the NRTRDE file +NR_RVN=1 + +# The backup directory +NR_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_RECV_BAK/ +NR_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_SEND_BAK/ +ND_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_RECV_BAK/ +ND_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_SEND_BAK/ +NE_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_RECV_BAK/ +NE_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_SEND_BAK/ +LOCAL_CSV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/LOCAL_CSV/ + +# The source directory to send the file +SEND_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/SEND/ + +# The directory to receive the file +RECV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/RECV/ + + diff --git a/omc/config/cacert.pem b/omc/config/cacert.pem new file mode 100644 index 0000000..cb26195 --- /dev/null +++ b/omc/config/cacert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDbzCCAtigAwIBAgIJAJAlyiGqsbwfMA0GCSqGSIb3DQEBBQUAMIGCMQswCQYD +VQQGEwJDTjESMBAGA1UECBMJR3Vhbmdkb25nMREwDwYDVQQHEwhTaGVuemhlbjET +MBEGA1UEChMKYWx0b2JyaWRnZTENMAsGA1UECxMEYWNyZDEMMAoGA1UEAxMDb21j +MRowGAYJKoZIhvcNAQkBFgtvbWNAYWRjLmNvbTAeFw0xMDAzMDgxNDQ5MDZaFw0x +MTAzMDgxNDQ5MDZaMIGCMQswCQYDVQQGEwJDTjESMBAGA1UECBMJR3Vhbmdkb25n +MREwDwYDVQQHEwhTaGVuemhlbjETMBEGA1UEChMKYWx0b2JyaWRnZTENMAsGA1UE +CxMEYWNyZDEMMAoGA1UEAxMDb21jMRowGAYJKoZIhvcNAQkBFgtvbWNAYWRjLmNv +bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA6g1IlzFYAUv6obDUEN83Khc4 +uslMGhLUI53LYR1v7i+AXP6HmFLV6fZeepIVJu4vuXUFdNUcA3HNnkpr7mGgIqgV +6y6oBAEYnjd4R3ee+1qWySRrBs1m4Jk1CA1WsOCth9Uf0mIIbp+0+b2gIWln7voz +1ANW96pcyja6+d4vm7MCAwEAAaOB6jCB5zAdBgNVHQ4EFgQUyXKRouQM9uBWS2vL +tlFT1MnVy3wwgbcGA1UdIwSBrzCBrIAUyXKRouQM9uBWS2vLtlFT1MnVy3yhgYik +gYUwgYIxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2RvbmcxETAPBgNVBAcT +CFNoZW56aGVuMRMwEQYDVQQKEwphbHRvYnJpZGdlMQ0wCwYDVQQLEwRhY3JkMQww +CgYDVQQDEwNvbWMxGjAYBgkqhkiG9w0BCQEWC29tY0BhZGMuY29tggkAkCXKIaqx +vB8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAGSvHDqCW65Y9oClJA +R47ruaOAu37Sfr8Lw5GCIzK9TRtdc7qWxfppGN6QC7a55GpwLHU5hingbbGUXGCV +UKLepKF2jGcDLAWAAr4Rc3Ex36XtyfyDVKL+seeNeYgWLMNUNsrGEgEVpFrUbB5G +Syj5OZgpL6NQFgn/MxkAqQZ4kg== +-----END CERTIFICATE----- diff --git a/omc/config/chkDb.conf b/omc/config/chkDb.conf new file mode 100644 index 0000000..3d7b336 --- /dev/null +++ b/omc/config/chkDb.conf @@ -0,0 +1 @@ +dbStopMode=0 diff --git a/omc/config/client.crt b/omc/config/client.crt new file mode 100644 index 0000000..0d56981 --- /dev/null +++ b/omc/config/client.crt @@ -0,0 +1,61 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 1 (0x1) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=CN, ST=Guangdong, L=Shenzhen, O=altobridge, OU=acrd, CN=omc/emailAddress=omc@adc.com + Validity + Not Before: Mar 8 14:59:26 2010 GMT + Not After : Mar 8 14:59:26 2011 GMT + Subject: C=CN, ST=Guangdong, O=altobridge, OU=acrd, CN=ems/emailAddress=ems@adc.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (1024 bit) + Modulus (1024 bit): + 00:cb:00:82:2a:e2:a7:c7:bb:67:0d:f7:a5:2c:db: + 49:63:2c:35:c8:88:d6:9a:ac:14:be:7b:da:e7:c2: + d5:8a:5e:cb:89:9a:65:8f:e2:39:a3:28:b7:0f:17: + 9b:95:f1:96:5a:1d:01:ec:14:6c:77:e1:84:e8:c5: + 01:a6:88:e2:9d:84:13:b0:1c:cb:3e:8d:bd:34:cd: + 9d:a7:d5:60:f4:92:1c:a5:0f:e9:21:cc:75:e5:11: + 26:77:11:cb:f1:5b:86:9a:7f:ea:4a:5f:16:57:fd: + b2:97:1a:73:a2:66:76:dd:40:f0:18:3c:5b:cf:82: + 16:fc:7b:07:7f:7a:ec:ad:bd + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Netscape Comment: + OpenSSL Generated Certificate + X509v3 Subject Key Identifier: + BD:85:E6:7D:1C:1E:7C:DE:57:9A:F5:8A:E6:3F:07:B5:3A:47:F3:35 + X509v3 Authority Key Identifier: + keyid:C9:72:91:A2:E4:0C:F6:E0:56:4B:6B:CB:B6:51:53:D4:C9:D5:CB:7C + + Signature Algorithm: sha1WithRSAEncryption + 86:89:a0:02:4f:bd:2e:14:db:88:da:d6:87:f6:cb:f6:b4:82: + 41:81:c6:56:ca:3a:0b:44:78:71:ba:b0:f2:20:d6:34:53:69: + 0d:02:85:4b:e7:30:91:b6:e2:5e:67:75:37:db:25:03:c1:e3: + 45:95:db:9a:2c:0d:4d:cc:65:34:39:b3:ab:c3:b5:c0:a8:e8: + 08:12:9a:d3:a7:85:78:10:7b:0e:fb:ae:37:1c:e0:44:48:44: + af:d6:fd:91:e8:0a:50:96:d0:c1:c2:73:0a:12:04:65:20:92: + 94:dc:f8:32:66:4f:cc:a1:cf:73:d6:0a:ba:57:69:3c:1c:d8: + c5:7a +-----BEGIN CERTIFICATE----- +MIIC4zCCAkygAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UEBhMCQ04x +EjAQBgNVBAgTCUd1YW5nZG9uZzERMA8GA1UEBxMIU2hlbnpoZW4xEzARBgNVBAoT +CmFsdG9icmlkZ2UxDTALBgNVBAsTBGFjcmQxDDAKBgNVBAMTA29tYzEaMBgGCSqG +SIb3DQEJARYLb21jQGFkYy5jb20wHhcNMTAwMzA4MTQ1OTI2WhcNMTEwMzA4MTQ1 +OTI2WjBvMQswCQYDVQQGEwJDTjESMBAGA1UECBMJR3Vhbmdkb25nMRMwEQYDVQQK +EwphbHRvYnJpZGdlMQ0wCwYDVQQLEwRhY3JkMQwwCgYDVQQDEwNlbXMxGjAYBgkq +hkiG9w0BCQEWC2Vtc0BhZGMuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB +gQDLAIIq4qfHu2cN96Us20ljLDXIiNaarBS+e9rnwtWKXsuJmmWP4jmjKLcPF5uV +8ZZaHQHsFGx34YToxQGmiOKdhBOwHMs+jb00zZ2n1WD0khylD+khzHXlESZ3Ecvx +W4aaf+pKXxZX/bKXGnOiZnbdQPAYPFvPghb8ewd/euytvQIDAQABo3sweTAJBgNV +HRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZp +Y2F0ZTAdBgNVHQ4EFgQUvYXmfRwefN5XmvWK5j8HtTpH8zUwHwYDVR0jBBgwFoAU +yXKRouQM9uBWS2vLtlFT1MnVy3wwDQYJKoZIhvcNAQEFBQADgYEAhomgAk+9LhTb +iNrWh/bL9rSCQYHGVso6C0R4cbqw8iDWNFNpDQKFS+cwkbbiXmd1N9slA8HjRZXb +miwNTcxlNDmzq8O1wKjoCBKa06eFeBB7DvuuNxzgREhEr9b9kegKUJbQwcJzChIE +ZSCSlNz4MmZPzKHPc9YKuldpPBzYxXo= +-----END CERTIFICATE----- diff --git a/omc/config/client.csr b/omc/config/client.csr new file mode 100644 index 0000000..72cb224 --- /dev/null +++ b/omc/config/client.csr @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIB7TCCAVYCAQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2Rvbmcx +ETAPBgNVBAcTCFNoZW56aGVuMRMwEQYDVQQKEwphbHRvYnJpZGdlMQ0wCwYDVQQL +EwRhY3JkMQwwCgYDVQQDEwNlbXMxGjAYBgkqhkiG9w0BCQEWC2Vtc0BhZGMuY29t +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLAIIq4qfHu2cN96Us20ljLDXI +iNaarBS+e9rnwtWKXsuJmmWP4jmjKLcPF5uV8ZZaHQHsFGx34YToxQGmiOKdhBOw +HMs+jb00zZ2n1WD0khylD+khzHXlESZ3EcvxW4aaf+pKXxZX/bKXGnOiZnbdQPAY +PFvPghb8ewd/euytvQIDAQABoCowEQYJKoZIhvcNAQkCMQQTAmFiMBUGCSqGSIb3 +DQEJBzEIEwYxMjM0NTYwDQYJKoZIhvcNAQEFBQADgYEAxlbRm0fe6AqUdhOwwqOg +VOv9cGqxFxaix405a4fWk2B2d3SfY404ofOXtkDCuJfbfNuqwmM4ufgzc73xsQcD +S5353PYq97sPT9idzh4JmZpgKb6E0ROneIdhVMLCxGKl/9cjfdf2HRZW9ot4JW1c +k/83fO1CfniarbibAgpzI7M= +-----END CERTIFICATE REQUEST----- diff --git a/omc/config/client.key b/omc/config/client.key new file mode 100644 index 0000000..ba2e890 --- /dev/null +++ b/omc/config/client.key @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,91508CD91BBB28B6 + +mh66h7RXJGa/9Nj5u+QP5wlEd2E/rZDjd4f9NqhSs5PqHMc6GgtBSk8tfpsOXgBC +2LA1ONn9B7y7q42GgTaz9XpL2rABZqjY3VyG7GKt+L8UtVjVYPo/3sB1hzMdrLLK +wZrqJjiOdJRD7awbZ+w1vb0qKSs7KkU85jmrwzI0HXe4lMUNMYQbcU/m7FdsEBtr +YIT0QgafiU3Awi25v2BPsa49oJWLO9qnWrPG1m/V1x1yRXNIrrE455ULGcqruLHH +h1TLe5xlDSDUcb4oRR0GgVWGqKDD/XhY8njT0k87COwIb6Fn+mbsljT4TzDbHFoa +auTgmrikmlZhYlTnBzZ7GNZGa7byY3GAAwbgfVYXJ9CVFi1NwZgXVGuiMGCtgHqF +V90/A6kERS7/C3EsAttLlxrR2IKMfDUzz304ociDtik6OoyCLdjZermkUYddLDJs +PlLtZCmTphh6HCPvSK1li11Y+fkNe57fkKhABhVjy5SY3rmLACLttKXxVCfrpIi/ +4NAWm/366mCl3InDcl+65z6mS5sPT66p102WbSk8iUHzrmr5liGnt8GAT9CNqEoy +Vuc0M/9GckOS7Q4sk3FekJha85x7X9mt5xRlqy2x5aFvvh4aCDoACAcw4e4ckFMS +WM0wxqDJEavc7FDr1EpdtFxQZ0WZkzLcX2Y4MfsOFhrjsHSOBX2/zyxt+UMOPHtP +F+zjf67dia3chYg3E0GExHD7OjTt0BlfN8cUxN18ed4sTp1NkZ9KBxEpRVxRTPmu +hNsrr8qg6TCEncWcRU540zJuxH2g1JEmg7x6JCuqjlaxrnPuxaYL8g== +-----END RSA PRIVATE KEY----- diff --git a/omc/config/conv_prefix.conf b/omc/config/conv_prefix.conf new file mode 100644 index 0000000..559e81a Binary files /dev/null and b/omc/config/conv_prefix.conf differ diff --git a/omc/config/hosts b/omc/config/hosts new file mode 100644 index 0000000..0a47d90 --- /dev/null +++ b/omc/config/hosts @@ -0,0 +1,5 @@ +127.0.0.1 localhost.localdomain localhost +172.18.128.1 omc-0.iwv omc-0 +172.18.129.1 omc-1.iwv omc-1 +172.18.98.1 mss-0.iwv mss-0 +172.18.99.1 mss-1.iwv mss-1 diff --git a/omc/config/httpd-ssl.conf b/omc/config/httpd-ssl.conf new file mode 100644 index 0000000..8017d46 --- /dev/null +++ b/omc/config/httpd-ssl.conf @@ -0,0 +1,232 @@ +# +# This is the Apache server configuration file providing SSL support. +# It contains the configuration directives to instruct the server how to +# serve pages over an https connection. For detailing information about these +# directives see +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# + +# +# Pseudo Random Number Generator (PRNG): +# Configure one or more sources to seed the PRNG of the SSL library. +# The seed data should be of good random quality. +# WARNING! On some platforms /dev/random blocks if not enough entropy +# is available. This means you then cannot use the /dev/random device +# because it would lead to very long connection times (as long as +# it requires to make more entropy available). But usually those +# platforms additionally provide a /dev/urandom device which doesn't +# block. So, if available, use this one instead. Read the mod_ssl User +# Manual for more details. +# +#SSLRandomSeed startup file:/dev/random 512 +#SSLRandomSeed startup file:/dev/urandom 512 +#SSLRandomSeed connect file:/dev/random 512 +#SSLRandomSeed connect file:/dev/urandom 512 + + +# +# When we also provide SSL we have to listen to the +# standard HTTP port (see above) and to the HTTPS port +# +# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two +# Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443" +# +Listen 443 + +## +## SSL Global Context +## +## All SSL configuration in this context applies both to +## the main server and all SSL-enabled virtual hosts. +## + +# +# Some MIME-types for downloading Certificates and CRLs +# +AddType application/x-x509-ca-cert .crt +AddType application/x-pkcs7-crl .crl + +# Pass Phrase Dialog: +# Configure the pass phrase gathering process. +# The filtering dialog program (`builtin' is a internal +# terminal dialog) has to provide the pass phrase on stdout. +SSLPassPhraseDialog builtin + +# Inter-Process Session Cache: +# Configure the SSL Session Cache: First the mechanism +# to use and second the expiring timeout (in seconds). +#SSLSessionCache "dbm:/etc/httpd/logs/ssl_scache" +SSLSessionCache "shmcb:/etc/httpd/logs/ssl_scache(512000)" +SSLSessionCacheTimeout 300 + +# Semaphore: +# Configure the path to the mutual exclusion semaphore the +# SSL engine uses internally for inter-process synchronization. +SSLMutex "file:/etc/httpd/logs/ssl_mutex" + +## +## SSL Virtual Host Context +## + + + +# General setup for the virtual host +DocumentRoot "/usr/local/apache/htdocs" +ServerName www.example.com:443 +ServerAdmin you@example.com +ErrorLog "/etc/httpd/logs/error_log" +TransferLog "/etc/httpd/logs/access_log" + +# SSL Engine Switch: +# Enable/Disable SSL for this virtual host. +SSLEngine on + +# SSL Cipher Suite: +# List the ciphers that the client is permitted to negotiate. +# See the mod_ssl documentation for a complete list. +SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + +# Server Certificate: +# Point SSLCertificateFile at a PEM encoded certificate. If +# the certificate is encrypted, then you will be prompted for a +# pass phrase. Note that a kill -HUP will prompt again. Keep +# in mind that if you have both an RSA and a DSA certificate you +# can configure both in parallel (to also allow the use of DSA +# ciphers, etc.) +SSLCertificateFile "/etc/httpd/conf/server.crt" +#SSLCertificateFile "/etc/httpd/conf/server-dsa.crt" + +# Server Private Key: +# If the key is not combined with the certificate, use this +# directive to point at the key file. Keep in mind that if +# you've both a RSA and a DSA private key you can configure +# both in parallel (to also allow the use of DSA ciphers, etc.) +SSLCertificateKeyFile "/etc/httpd/conf/server.key" +#SSLCertificateKeyFile "/etc/httpd/conf/server-dsa.key" + +# Server Certificate Chain: +# Point SSLCertificateChainFile at a file containing the +# concatenation of PEM encoded CA certificates which form the +# certificate chain for the server certificate. Alternatively +# the referenced file can be the same as SSLCertificateFile +# when the CA certificates are directly appended to the server +# certificate for convinience. +#SSLCertificateChainFile "/etc/httpd/conf/server-ca.crt" + +# Certificate Authority (CA): +# Set the CA certificate verification path where to find CA +# certificates for client authentication or alternatively one +# huge file containing all of them (file must be PEM encoded) +# Note: Inside SSLCACertificatePath you need hash symlinks +# to point to the certificate files. Use the provided +# Makefile to update the hash symlinks after changes. +#SSLCACertificatePath "/etc/httpd/conf/ssl.crt" +SSLCACertificateFile "/etc/httpd/conf/cacert.pem" + +# Certificate Revocation Lists (CRL): +# Set the CA revocation path where to find CA CRLs for client +# authentication or alternatively one huge file containing all +# of them (file must be PEM encoded) +# Note: Inside SSLCARevocationPath you need hash symlinks +# to point to the certificate files. Use the provided +# Makefile to update the hash symlinks after changes. +#SSLCARevocationPath "/etc/httpd/conf/ssl.crl" +#SSLCARevocationFile "/etc/httpd/conf/ssl.crl/ca-bundle.crl" + +# Client Authentication (Type): +# Client certificate verification type and depth. Types are +# none, optional, require and optional_no_ca. Depth is a +# number which specifies how deeply to verify the certificate +# issuer chain before deciding the certificate is not valid. +SSLVerifyClient require +SSLVerifyDepth 1 + +# Access Control: +# With SSLRequire you can do per-directory access control based +# on arbitrary complex boolean expressions containing server +# variable checks and other lookup directives. The syntax is a +# mixture between C and Perl. See the mod_ssl documentation +# for more details. +# +#SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \ +# and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \ +# and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \ +# and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \ +# and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \ +# or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/ +# + +# SSL Engine Options: +# Set various options for the SSL engine. +# o FakeBasicAuth: +# Translate the client X.509 into a Basic Authorisation. This means that +# the standard Auth/DBMAuth methods can be used for access control. The +# user name is the `one line' version of the client's X.509 certificate. +# Note that no password is obtained from the user. Every entry in the user +# file needs this password: `xxj31ZMTZzkVA'. +# o ExportCertData: +# This exports two additional environment variables: SSL_CLIENT_CERT and +# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the +# server (always existing) and the client (only existing when client +# authentication is used). This can be used to import the certificates +# into CGI scripts. +# o StdEnvVars: +# This exports the standard SSL/TLS related `SSL_*' environment variables. +# Per default this exportation is switched off for performance reasons, +# because the extraction step is an expensive operation and is usually +# useless for serving static content. So one usually enables the +# exportation for CGI and SSI requests only. +# o StrictRequire: +# This denies access when "SSLRequireSSL" or "SSLRequire" applied even +# under a "Satisfy any" situation, i.e. when it applies access is denied +# and no other module can change it. +# o OptRenegotiate: +# This enables optimized SSL connection renegotiation handling when SSL +# directives are used in per-directory context. +#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + +# SSL Protocol Adjustments: +# The safe and default but still SSL/TLS standard compliant shutdown +# approach is that mod_ssl sends the close notify alert but doesn't wait for +# the close notify alert from client. When you need a different shutdown +# approach you can use one of the following variables: +# o ssl-unclean-shutdown: +# This forces an unclean shutdown when the connection is closed, i.e. no +# SSL close notify alert is send or allowed to received. This violates +# the SSL/TLS standard but is needed for some brain-dead browsers. Use +# this when you receive I/O errors because of the standard approach where +# mod_ssl sends the close notify alert. +# o ssl-accurate-shutdown: +# This forces an accurate shutdown when the connection is closed, i.e. a +# SSL close notify alert is send and mod_ssl waits for the close notify +# alert of the client. This is 100% SSL/TLS standard compliant, but in +# practice often causes hanging connections with brain-dead browsers. Use +# this only for browsers where you know that their SSL implementation +# works correctly. +# Notice: Most problems of broken clients are also related to the HTTP +# keep-alive facility, so you usually additionally want to disable +# keep-alive for those clients, too. Use variable "nokeepalive" for this. +# Similarly, one has to force some clients to use HTTP/1.0 to workaround +# their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and +# "force-response-1.0" for this. +BrowserMatch ".*MSIE.*" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + +# Per-Server Logging: +# The home of a custom SSL log file. Use this when you want a +# compact non-error SSL logfile on a virtual host basis. +CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/ssl_request_log 10M" \ + "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" + + +SSLProtocol TLSv1 diff --git a/omc/config/httpd.conf b/omc/config/httpd.conf new file mode 100644 index 0000000..e69de29 diff --git a/omc/config/httpd.conf_centos b/omc/config/httpd.conf_centos new file mode 100644 index 0000000..55ab729 --- /dev/null +++ b/omc/config/httpd.conf_centos @@ -0,0 +1,992 @@ +# +# This is the main Apache server configuration file. It contains the +# configuration directives that give the server its instructions. +# See for detailed information. +# In particular, see +# +# for a discussion of each configuration directive. +# +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# +# The configuration directives are grouped into three basic sections: +# 1. Directives that control the operation of the Apache server process as a +# whole (the 'global environment'). +# 2. Directives that define the parameters of the 'main' or 'default' server, +# which responds to requests that aren't handled by a virtual host. +# These directives also provide default values for the settings +# of all virtual hosts. +# 3. Settings for virtual hosts, which allow Web requests to be sent to +# different IP addresses or hostnames and have them handled by the +# same Apache server process. +# +# Configuration and logfile names: If the filenames you specify for many +# of the server's control files begin with "/" (or "drive:/" for Win32), the +# server will use that explicit path. If the filenames do *not* begin +# with "/", the value of ServerRoot is prepended -- so "logs/foo.log" +# with ServerRoot set to "/etc/httpd" will be interpreted by the +# server as "/etc/httpd/logs/foo.log". +# + +### Section 1: Global Environment +# +# The directives in this section affect the overall operation of Apache, +# such as the number of concurrent requests it can handle or where it +# can find its configuration files. +# + +# +# Don't give away too much information about all the subcomponents +# we are running. Comment out this line if you don't mind remote sites +# finding out what major optional modules you are running +ServerTokens OS + +# +# ServerRoot: The top of the directory tree under which the server's +# configuration, error, and log files are kept. +# +# NOTE! If you intend to place this on an NFS (or otherwise network) +# mounted filesystem then please read the LockFile documentation +# (available at ); +# you will save yourself a lot of trouble. +# +# Do NOT add a slash at the end of the directory path. +# +ServerRoot "/etc/httpd" + +# +# PidFile: The file in which the server should record its process +# identification number when it starts. +# +PidFile run/httpd.pid + +# +# Timeout: The number of seconds before receives and sends time out. +# +Timeout 300 + +# +# KeepAlive: Whether or not to allow persistent connections (more than +# one request per connection). Set to "Off" to deactivate. +# +KeepAlive On + +# +# MaxKeepAliveRequests: The maximum number of requests to allow +# during a persistent connection. Set to 0 to allow an unlimited amount. +# We recommend you leave this number high, for maximum performance. +# +MaxKeepAliveRequests 100 + +# +# KeepAliveTimeout: Number of seconds to wait for the next request from the +# same client on the same connection. +# +KeepAliveTimeout 15 + +## +## Server-Pool Size Regulation (MPM specific) +## + +# prefork MPM +# StartServers: number of server processes to start +# MinSpareServers: minimum number of server processes which are kept spare +# MaxSpareServers: maximum number of server processes which are kept spare +# ServerLimit: maximum value for MaxClients for the lifetime of the server +# MaxClients: maximum number of server processes allowed to start +# MaxRequestsPerChild: maximum number of requests a server process serves + +StartServers 8 +MinSpareServers 5 +MaxSpareServers 20 +ServerLimit 256 +MaxClients 256 +MaxRequestsPerChild 4000 + + +# worker MPM +# StartServers: initial number of server processes to start +# MaxClients: maximum number of simultaneous client connections +# MinSpareThreads: minimum number of worker threads which are kept spare +# MaxSpareThreads: maximum number of worker threads which are kept spare +# ThreadsPerChild: constant number of worker threads in each server process +# MaxRequestsPerChild: maximum number of requests a server process serves + +StartServers 2 +MaxClients 150 +MinSpareThreads 25 +MaxSpareThreads 75 +ThreadsPerChild 25 +MaxRequestsPerChild 0 + + +# +# Listen: Allows you to bind Apache to specific IP addresses and/or +# ports, in addition to the default. See also the +# directive. +# +# Change this to Listen on specific IP addresses as shown below to +# prevent Apache from glomming onto all bound IP addresses (0.0.0.0) +# +#Listen 12.34.56.78:80 +Listen 80 + +# +# Dynamic Shared Object (DSO) Support +# +# To be able to use the functionality of a module which was built as a DSO you +# have to place corresponding `LoadModule' lines at this location so the +# directives contained in it are actually available _before_ they are used. +# Statically compiled modules (those listed by `httpd -l') do not need +# to be loaded here. +# +# Example: +# LoadModule foo_module modules/mod_foo.so +# +LoadModule auth_basic_module modules/mod_auth_basic.so +LoadModule auth_digest_module modules/mod_auth_digest.so +LoadModule authn_file_module modules/mod_authn_file.so +LoadModule authn_alias_module modules/mod_authn_alias.so +LoadModule authn_anon_module modules/mod_authn_anon.so +LoadModule authn_dbm_module modules/mod_authn_dbm.so +LoadModule authn_default_module modules/mod_authn_default.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_user_module modules/mod_authz_user.so +LoadModule authz_owner_module modules/mod_authz_owner.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_dbm_module modules/mod_authz_dbm.so +LoadModule authz_default_module modules/mod_authz_default.so +LoadModule ldap_module modules/mod_ldap.so +LoadModule authnz_ldap_module modules/mod_authnz_ldap.so +LoadModule include_module modules/mod_include.so +LoadModule log_config_module modules/mod_log_config.so +LoadModule logio_module modules/mod_logio.so +LoadModule env_module modules/mod_env.so +LoadModule ext_filter_module modules/mod_ext_filter.so +LoadModule mime_magic_module modules/mod_mime_magic.so +LoadModule expires_module modules/mod_expires.so +LoadModule deflate_module modules/mod_deflate.so +LoadModule headers_module modules/mod_headers.so +LoadModule usertrack_module modules/mod_usertrack.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule mime_module modules/mod_mime.so +LoadModule dav_module modules/mod_dav.so +LoadModule status_module modules/mod_status.so +LoadModule autoindex_module modules/mod_autoindex.so +LoadModule info_module modules/mod_info.so +LoadModule dav_fs_module modules/mod_dav_fs.so +LoadModule vhost_alias_module modules/mod_vhost_alias.so +LoadModule negotiation_module modules/mod_negotiation.so +LoadModule dir_module modules/mod_dir.so +LoadModule actions_module modules/mod_actions.so +LoadModule speling_module modules/mod_speling.so +LoadModule userdir_module modules/mod_userdir.so +LoadModule alias_module modules/mod_alias.so +LoadModule rewrite_module modules/mod_rewrite.so +LoadModule proxy_module modules/mod_proxy.so +LoadModule proxy_balancer_module modules/mod_proxy_balancer.so +LoadModule proxy_ftp_module modules/mod_proxy_ftp.so +LoadModule proxy_http_module modules/mod_proxy_http.so +LoadModule proxy_connect_module modules/mod_proxy_connect.so +LoadModule cache_module modules/mod_cache.so +LoadModule suexec_module modules/mod_suexec.so +LoadModule disk_cache_module modules/mod_disk_cache.so +LoadModule file_cache_module modules/mod_file_cache.so +LoadModule mem_cache_module modules/mod_mem_cache.so +LoadModule cgi_module modules/mod_cgi.so +LoadModule version_module modules/mod_version.so + +# +# The following modules are not loaded by default: +# +#LoadModule cern_meta_module modules/mod_cern_meta.so +#LoadModule asis_module modules/mod_asis.so + +# +# Load config files from the config directory "/etc/httpd/conf.d". +# +Include conf.d/*.conf + +# +# ExtendedStatus controls whether Apache will generate "full" status +# information (ExtendedStatus On) or just basic information (ExtendedStatus +# Off) when the "server-status" handler is called. The default is Off. +# +#ExtendedStatus On + +# +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. +# +# User/Group: The name (or #number) of the user/group to run httpd as. +# . On SCO (ODT 3) use "User nouser" and "Group nogroup". +# . On HPUX you may not be able to use shared memory as nobody, and the +# suggested workaround is to create a user www and use that user. +# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET) +# when the value of (unsigned)Group is above 60000; +# don't use Group #-1 on these systems! +# +User www +Group omc + +### Section 2: 'Main' server configuration +# +# The directives in this section set up the values used by the 'main' +# server, which responds to any requests that aren't handled by a +# definition. These values also provide defaults for +# any containers you may define later in the file. +# +# All of these directives may appear inside containers, +# in which case these default settings will be overridden for the +# virtual host being defined. +# + +# +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. This address appears on some server-generated pages, such +# as error documents. e.g. admin@your-domain.com +# +ServerAdmin root@localhost + +# +# ServerName gives the name and port that the server uses to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# +# If this is not set to valid DNS name for your host, server-generated +# redirections will not work. See also the UseCanonicalName directive. +# +# If your host doesn't have a registered DNS name, enter its IP address here. +# You will have to access it by its address anyway, and this will make +# redirections work in a sensible way. +# +#ServerName www.example.com:80 + +# +# UseCanonicalName: Determines how Apache constructs self-referencing +# URLs and the SERVER_NAME and SERVER_PORT variables. +# When set "Off", Apache will use the Hostname and Port supplied +# by the client. When set "On", Apache will use the value of the +# ServerName directive. +# +UseCanonicalName Off + +# +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. +# +#DocumentRoot "/var/www/html" +DocumentRoot "/usr/local/apache/htdocs" + +# +# Each directory to which Apache has access can be configured with respect +# to which services and features are allowed and/or disabled in that +# directory (and its subdirectories). +# +# First, we configure the "default" to be a very restrictive set of +# features. +# + + Options FollowSymLinks + AllowOverride None + + +# +# Note that from this point forward you must specifically allow +# particular features to be enabled - so if something's not working as +# you might expect, make sure that you have specifically enabled it +# below. +# + +# +# This should be changed to whatever you set DocumentRoot to. +# + + +# +# Possible values for the Options directive are "None", "All", +# or any combination of: +# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews +# +# Note that "MultiViews" must be named *explicitly* --- "Options All" +# doesn't give it to you. +# +# The Options directive is both complicated and important. Please see +# http://httpd.apache.org/docs/2.2/mod/core.html#options +# for more information. +# + Options Indexes FollowSymLinks MultiViews + +# +# AllowOverride controls what directives may be placed in .htaccess files. +# It can be "All", "None", or any combination of the keywords: +# Options FileInfo AuthConfig Limit +# + AllowOverride None + +# +# Controls who can get stuff from this server. +# + Order allow,deny + Allow from all + + + +# +# UserDir: The name of the directory that is appended onto a user's home +# directory if a ~user request is received. +# +# The path to the end user account 'public_html' directory must be +# accessible to the webserver userid. This usually means that ~userid +# must have permissions of 711, ~userid/public_html must have permissions +# of 755, and documents contained therein must be world-readable. +# Otherwise, the client will only receive a "403 Forbidden" message. +# +# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden +# + + # + # UserDir is disabled by default since it can confirm the presence + # of a username on the system (depending on home directory + # permissions). + # + UserDir disable + + # + # To enable requests to /~user/ to serve the user's public_html + # directory, remove the "UserDir disable" line above, and uncomment + # the following line instead: + # + #UserDir public_html + + + +# +# Control access to UserDir directories. The following is an example +# for a site where these directories are restricted to read-only. +# +# +# AllowOverride FileInfo AuthConfig Limit +# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec +# +# Order allow,deny +# Allow from all +# +# +# Order deny,allow +# Deny from all +# +# + +# +# DirectoryIndex: sets the file that Apache will serve if a directory +# is requested. +# +# The index.html.var file (a type-map) is used to deliver content- +# negotiated documents. The MultiViews Option can be used for the +# same purpose, but it is much slower. +# +DirectoryIndex index.html index.html.var index.php + +# +# AccessFileName: The name of the file to look for in each directory +# for additional configuration directives. See also the AllowOverride +# directive. +# +AccessFileName .htaccess + +# +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. +# + + Order allow,deny + Deny from all + + +# +# TypesConfig describes where the mime.types file (or equivalent) is +# to be found. +# +TypesConfig /etc/mime.types + +# +# DefaultType is the default MIME type the server will use for a document +# if it cannot otherwise determine one, such as from filename extensions. +# If your server contains mostly text or HTML documents, "text/plain" is +# a good value. If most of your content is binary, such as applications +# or images, you may want to use "application/octet-stream" instead to +# keep browsers from trying to display binary files as though they are +# text. +# +DefaultType text/plain + +# +# The mod_mime_magic module allows the server to use various hints from the +# contents of the file itself to determine its type. The MIMEMagicFile +# directive tells the module where the hint definitions are located. +# + +# MIMEMagicFile /usr/share/magic.mime + MIMEMagicFile conf/magic + + +# +# HostnameLookups: Log the names of clients or just their IP addresses +# e.g., www.apache.org (on) or 204.62.129.132 (off). +# The default is off because it'd be overall better for the net if people +# had to knowingly turn this feature on, since enabling it means that +# each client request will result in AT LEAST one lookup request to the +# nameserver. +# +HostnameLookups Off + +# +# EnableMMAP: Control whether memory-mapping is used to deliver +# files (assuming that the underlying OS supports it). +# The default is on; turn this off if you serve from NFS-mounted +# filesystems. On some systems, turning it off (regardless of +# filesystem) can improve performance; for details, please see +# http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap +# +#EnableMMAP off + +# +# EnableSendfile: Control whether the sendfile kernel support is +# used to deliver files (assuming that the OS supports it). +# The default is on; turn this off if you serve from NFS-mounted +# filesystems. Please see +# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile +# +#EnableSendfile off + +# +# ErrorLog: The location of the error log file. +# If you do not specify an ErrorLog directive within a +# container, error messages relating to that virtual host will be +# logged here. If you *do* define an error logfile for a +# container, that host's errors will be logged there and not here. +# +ErrorLog logs/error_log + +# +# LogLevel: Control the number of messages logged to the error_log. +# Possible values include: debug, info, notice, warn, error, crit, +# alert, emerg. +# +LogLevel warn + +# +# The following directives define some format nicknames for use with +# a CustomLog directive (see below). +# +LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined +LogFormat "%h %l %u %t \"%r\" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this +# requires the mod_logio module to be loaded. +#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + +# +# The location and format of the access logfile (Common Logfile Format). +# If you do not define any access logfiles within a +# container, they will be logged here. Contrariwise, if you *do* +# define per- access logfiles, transactions will be +# logged therein and *not* in this file. +# +#CustomLog logs/access_log common + +# +# If you would like to have separate agent and referer logfiles, uncomment +# the following directives. +# +#CustomLog logs/referer_log referer +#CustomLog logs/agent_log agent + +# +# For a single logfile with access, agent, and referer information +# (Combined Logfile Format), use the following directive: +# +CustomLog logs/access_log combined + +# +# Optionally add a line containing the server version and virtual host +# name to server-generated pages (internal error documents, FTP directory +# listings, mod_status and mod_info output etc., but not CGI generated +# documents or custom error documents). +# Set to "EMail" to also include a mailto: link to the ServerAdmin. +# Set to one of: On | Off | EMail +# +ServerSignature On + +# +# Aliases: Add here as many aliases as you need (with no limit). The format is +# Alias fakename realname +# +# Note that if you include a trailing / on fakename then the server will +# require it to be present in the URL. So "/icons" isn't aliased in this +# example, only "/icons/". If the fakename is slash-terminated, then the +# realname must also be slash terminated, and if the fakename omits the +# trailing slash, the realname must also omit it. +# +# We include the /icons/ alias for FancyIndexed directory listings. If you +# do not use FancyIndexing, you may comment this out. +# +Alias /icons/ "/var/www/icons/" + + + Options Indexes MultiViews + AllowOverride None + Order allow,deny + Allow from all + + +# +# WebDAV module configuration section. +# + + # Location of the WebDAV lock database. + DAVLockDB /var/lib/dav/lockdb + + +# +# ScriptAlias: This controls which directories contain server scripts. +# ScriptAliases are essentially the same as Aliases, except that +# documents in the realname directory are treated as applications and +# run by the server when requested rather than as documents sent to the client. +# The same rules about trailing "/" apply to ScriptAlias directives as to +# Alias. +# +ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" + +# +# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased +# CGI directory exists, if you have that configured. +# + + AllowOverride None + Options None + Order allow,deny + Allow from all + + +# +# Redirect allows you to tell clients about documents which used to exist in +# your server's namespace, but do not anymore. This allows you to tell the +# clients where to look for the relocated document. +# Example: +# Redirect permanent /foo http://www.example.com/bar + +# +# Directives controlling the display of server-generated directory listings. +# + +# +# IndexOptions: Controls the appearance of server-generated directory +# listings. +# +IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable + +# +# AddIcon* directives tell the server which icon to show for different +# files or filename extensions. These are only displayed for +# FancyIndexed directories. +# +AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip + +AddIconByType (TXT,/icons/text.gif) text/* +AddIconByType (IMG,/icons/image2.gif) image/* +AddIconByType (SND,/icons/sound2.gif) audio/* +AddIconByType (VID,/icons/movie.gif) video/* + +AddIcon /icons/binary.gif .bin .exe +AddIcon /icons/binhex.gif .hqx +AddIcon /icons/tar.gif .tar +AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv +AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip +AddIcon /icons/a.gif .ps .ai .eps +AddIcon /icons/layout.gif .html .shtml .htm .pdf +AddIcon /icons/text.gif .txt +AddIcon /icons/c.gif .c +AddIcon /icons/p.gif .pl .py +AddIcon /icons/f.gif .for +AddIcon /icons/dvi.gif .dvi +AddIcon /icons/uuencoded.gif .uu +AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl +AddIcon /icons/tex.gif .tex +AddIcon /icons/bomb.gif core + +AddIcon /icons/back.gif .. +AddIcon /icons/hand.right.gif README +AddIcon /icons/folder.gif ^^DIRECTORY^^ +AddIcon /icons/blank.gif ^^BLANKICON^^ + +# +# DefaultIcon is which icon to show for files which do not have an icon +# explicitly set. +# +DefaultIcon /icons/unknown.gif + +# +# AddDescription allows you to place a short description after a file in +# server-generated indexes. These are only displayed for FancyIndexed +# directories. +# Format: AddDescription "description" filename +# +#AddDescription "GZIP compressed document" .gz +#AddDescription "tar archive" .tar +#AddDescription "GZIP compressed tar archive" .tgz + +# +# ReadmeName is the name of the README file the server will look for by +# default, and append to directory listings. +# +# HeaderName is the name of a file which should be prepended to +# directory indexes. +ReadmeName README.html +HeaderName HEADER.html + +# +# IndexIgnore is a set of filenames which directory indexing should ignore +# and not include in the listing. Shell-style wildcarding is permitted. +# +IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t + +# +# DefaultLanguage and AddLanguage allows you to specify the language of +# a document. You can then use content negotiation to give a browser a +# file in a language the user can understand. +# +# Specify a default language. This means that all data +# going out without a specific language tag (see below) will +# be marked with this one. You probably do NOT want to set +# this unless you are sure it is correct for all cases. +# +# * It is generally better to not mark a page as +# * being a certain language than marking it with the wrong +# * language! +# +# DefaultLanguage nl +# +# Note 1: The suffix does not have to be the same as the language +# keyword --- those with documents in Polish (whose net-standard +# language code is pl) may wish to use "AddLanguage pl .po" to +# avoid the ambiguity with the common suffix for perl scripts. +# +# Note 2: The example entries below illustrate that in some cases +# the two character 'Language' abbreviation is not identical to +# the two character 'Country' code for its country, +# E.g. 'Danmark/dk' versus 'Danish/da'. +# +# Note 3: In the case of 'ltz' we violate the RFC by using a three char +# specifier. There is 'work in progress' to fix this and get +# the reference data for rfc1766 cleaned up. +# +# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl) +# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de) +# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja) +# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn) +# Norwegian (no) - Polish (pl) - Portugese (pt) +# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv) +# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW) +# +AddLanguage ca .ca +AddLanguage cs .cz .cs +AddLanguage da .dk +AddLanguage de .de +AddLanguage el .el +AddLanguage en .en +AddLanguage eo .eo +AddLanguage es .es +AddLanguage et .et +AddLanguage fr .fr +AddLanguage he .he +AddLanguage hr .hr +AddLanguage it .it +AddLanguage ja .ja +AddLanguage ko .ko +AddLanguage ltz .ltz +AddLanguage nl .nl +AddLanguage nn .nn +AddLanguage no .no +AddLanguage pl .po +AddLanguage pt .pt +AddLanguage pt-BR .pt-br +AddLanguage ru .ru +AddLanguage sv .sv +AddLanguage zh-CN .zh-cn +AddLanguage zh-TW .zh-tw + +# +# LanguagePriority allows you to give precedence to some languages +# in case of a tie during content negotiation. +# +# Just list the languages in decreasing order of preference. We have +# more or less alphabetized them here. You probably want to change this. +# +LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW + +# +# ForceLanguagePriority allows you to serve a result page rather than +# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback) +# [in case no accepted languages matched the available variants] +# +ForceLanguagePriority Prefer Fallback + +# +# Specify a default charset for all content served; this enables +# interpretation of all content as UTF-8 by default. To use the +# default browser choice (ISO-8859-1), or to allow the META tags +# in HTML content to override this choice, comment out this +# directive: +# +#AddDefaultCharset UTF-8 + +# +# AddType allows you to add to or override the MIME configuration +# file mime.types for specific file types. +# +#AddType application/x-tar .tgz + +# +# AddEncoding allows you to have certain browsers uncompress +# information on the fly. Note: Not all browsers support this. +# Despite the name similarity, the following Add* directives have nothing +# to do with the FancyIndexing customization directives above. +# +#AddEncoding x-compress .Z +#AddEncoding x-gzip .gz .tgz + +# If the AddEncoding directives above are commented-out, then you +# probably should define those extensions to indicate media types: +# +AddType application/x-compress .Z +AddType application/x-gzip .gz .tgz + +# +# AddHandler allows you to map certain file extensions to "handlers": +# actions unrelated to filetype. These can be either built into the server +# or added with the Action directive (see below) +# +# To use CGI scripts outside of ScriptAliased directories: +# (You will also need to add "ExecCGI" to the "Options" directive.) +# +#AddHandler cgi-script .cgi + +# +# For files that include their own HTTP headers: +# +#AddHandler send-as-is asis + +# +# For type maps (negotiated resources): +# (This is enabled by default to allow the Apache "It Worked" page +# to be distributed in multiple languages.) +# +AddHandler type-map var + +# +# Filters allow you to process content before it is sent to the client. +# +# To parse .shtml files for server-side includes (SSI): +# (You will also need to add "Includes" to the "Options" directive.) +# +AddType text/html .shtml +AddOutputFilter INCLUDES .shtml + +# +# Action lets you define media types that will execute a script whenever +# a matching file is called. This eliminates the need for repeated URL +# pathnames for oft-used CGI file processors. +# Format: Action media/type /cgi-script/location +# Format: Action handler-name /cgi-script/location +# + +# +# Customizable error responses come in three flavors: +# 1) plain text 2) local redirects 3) external redirects +# +# Some examples: +#ErrorDocument 500 "The server made a boo boo." +#ErrorDocument 404 /missing.html +#ErrorDocument 404 "/cgi-bin/missing_handler.pl" +#ErrorDocument 402 http://www.example.com/subscription_info.html +# + +# +# Putting this all together, we can internationalize error responses. +# +# We use Alias to redirect any /error/HTTP_.html.var response to +# our collection of by-error message multi-language collections. We use +# includes to substitute the appropriate text. +# +# You can modify the messages' appearance without changing any of the +# default HTTP_.html.var files by adding the line: +# +# Alias /error/include/ "/your/include/path/" +# +# which allows you to create your own set of files by starting with the +# /var/www/error/include/ files and +# copying them to /your/include/path/, even on a per-VirtualHost basis. +# + +Alias /error/ "/var/www/error/" + + + + + AllowOverride None + Options IncludesNoExec + AddOutputFilter Includes html + AddHandler type-map var + Order allow,deny + Allow from all + LanguagePriority en es de fr + ForceLanguagePriority Prefer Fallback + + +# ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var +# ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var +# ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var +# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var +# ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var +# ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var +# ErrorDocument 410 /error/HTTP_GONE.html.var +# ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var +# ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var +# ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var +# ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var +# ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var +# ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var +# ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var +# ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var +# ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var +# ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var + + + + +# +# The following directives modify normal HTTP response behavior to +# handle known problems with browser implementations. +# +BrowserMatch "Mozilla/2" nokeepalive +BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0 +BrowserMatch "RealPlayer 4\.0" force-response-1.0 +BrowserMatch "Java/1\.0" force-response-1.0 +BrowserMatch "JDK/1\.0" force-response-1.0 + +# +# The following directive disables redirects on non-GET requests for +# a directory that does not include the trailing slash. This fixes a +# problem with Microsoft WebFolders which does not appropriately handle +# redirects for folders with DAV methods. +# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV. +# +BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully +BrowserMatch "MS FrontPage" redirect-carefully +BrowserMatch "^WebDrive" redirect-carefully +BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully +BrowserMatch "^gnome-vfs/1.0" redirect-carefully +BrowserMatch "^XML Spy" redirect-carefully +BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully + +# +# Allow server status reports generated by mod_status, +# with the URL of http://servername/server-status +# Change the ".example.com" to match your domain to enable. +# +# +# SetHandler server-status +# Order deny,allow +# Deny from all +# Allow from .example.com +# + +# +# Allow remote server configuration reports, with the URL of +# http://servername/server-info (requires that mod_info.c be loaded). +# Change the ".example.com" to match your domain to enable. +# +# +# SetHandler server-info +# Order deny,allow +# Deny from all +# Allow from .example.com +# + +# +# Proxy Server directives. Uncomment the following lines to +# enable the proxy server: +# +# +#ProxyRequests On +# +# +# Order deny,allow +# Deny from all +# Allow from .example.com +# + +# +# Enable/disable the handling of HTTP/1.1 "Via:" headers. +# ("Full" adds the server version; "Block" removes all outgoing Via: headers) +# Set to one of: Off | On | Full | Block +# +#ProxyVia On + +# +# To enable a cache of proxied content, uncomment the following lines. +# See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details. +# +# +# CacheEnable disk / +# CacheRoot "/var/cache/mod_proxy" +# +# + +# +# End of proxy directives. + +### Section 3: Virtual Hosts +# +# VirtualHost: If you want to maintain multiple domains/hostnames on your +# machine you can setup VirtualHost containers for them. Most configurations +# use only name-based virtual hosts so the server doesn't need to worry about +# IP addresses. This is indicated by the asterisks in the directives below. +# +# Please see the documentation at +# +# for further details before you try to setup virtual hosts. +# +# You may use the command line option '-S' to verify your virtual host +# configuration. + +# +# Use name-based virtual hosting. +# +#NameVirtualHost *:80 +# +# NOTE: NameVirtualHost cannot be used without a port specifier +# (e.g. :80) if mod_ssl is being used, due to the nature of the +# SSL protocol. +# + +# +# VirtualHost example: +# Almost any Apache directive may go into a VirtualHost container. +# The first VirtualHost section is used for requests without a known +# server name. +# +# +# ServerAdmin webmaster@dummy-host.example.com +# DocumentRoot /www/docs/dummy-host.example.com +# ServerName dummy-host.example.com +# ErrorLog logs/dummy-host.example.com-error_log +# CustomLog logs/dummy-host.example.com-access_log common +# diff --git a/omc/config/my.cnf b/omc/config/my.cnf new file mode 100644 index 0000000..579e3bf --- /dev/null +++ b/omc/config/my.cnf @@ -0,0 +1,90 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock +datadir = /usr/local/mysql +pid-file = /var/lib/mysql/mysqld.pid +log-error = /var/lib/mysql/mysqld.err +skip-locking +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 + +#set-variable = max_binlog_size=32M +#master=====================> + +server-id = 0 + +#slave====================> +master-host = omc-1 +master-user = administrator +master-password = "*86#ROtartsinim" +master-port = 3306 + +#master-connect-retry = 30 +#slave-read-timeout = 10 + +#replicate-do-table =*.* + + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_omc-0 b/omc/config/my.cnf_omc-0 new file mode 100644 index 0000000..9b169e1 --- /dev/null +++ b/omc/config/my.cnf_omc-0 @@ -0,0 +1,94 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +socket = /var/lib/mysql/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +socket = /var/lib/mysql/mysql.sock +skip-locking +slave-skip-errors = all +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=2M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#master=====================> +log-bin +binlog-do-db = mysql +binlog-do-db = CDR_DB +binlog-do-db = CSTA_DB + +server-id = 0 + +#slave====================> +master-host = omc-1 +master-user = administrator +master-password = "*86#ROtartsinim" +master-port = 3306 + +#master-connect-retry = 30 +#slave-read-timeout = 10 + +replicate-do-db = mysql +replicate-do-db = CDR_DB +replicate-do-db = CSTA_DB + +#replicate-do-table =*.* + + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_omc-0.ES b/omc/config/my.cnf_omc-0.ES new file mode 100644 index 0000000..c559971 --- /dev/null +++ b/omc/config/my.cnf_omc-0.ES @@ -0,0 +1,98 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock +datadir = /usr/local/mysql +pid-file = /var/lib/mysql/mysqld.pid +log-error = /var/lib/mysql/mysqld.err +skip-locking +slave-skip-errors = all +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=2M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#master=====================> +log-bin +binlog-do-db = mysql +binlog-do-db = CDR_DB +binlog-do-db = CSTA_DB + +server-id = 0 + +#slave====================> +master-host = omc-1 +master-user = administrator +master-password = "*86#ROtartsinim" +master-port = 3306 + +#master-connect-retry = 30 +#slave-read-timeout = 10 + +replicate-do-db = mysql +replicate-do-db = CDR_DB +replicate-do-db = CSTA_DB + +#replicate-do-table =*.* + + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_omc-1 b/omc/config/my.cnf_omc-1 new file mode 100644 index 0000000..4e40c1d --- /dev/null +++ b/omc/config/my.cnf_omc-1 @@ -0,0 +1,94 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +socket = /var/lib/mysql/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +socket = /var/lib/mysql/mysql.sock +skip-locking +slave-skip-errors = all +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=2M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#master=====================> +log-bin +binlog-do-db = mysql +binlog-do-db = CDR_DB +binlog-do-db = CSTA_DB + +server-id = 1 + +#slave====================> +master-host = omc-0 +master-user = administrator +master-password = "*86#ROtartsinim" +master-port = 3306 + +#master-connect-retry = 30 +#slave-read-timeout = 10 + +replicate-do-db = mysql +replicate-do-db = CDR_DB +replicate-do-db = CSTA_DB + +#replicate-do-table =*.* + + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_omc-1.ES b/omc/config/my.cnf_omc-1.ES new file mode 100644 index 0000000..e5fe549 --- /dev/null +++ b/omc/config/my.cnf_omc-1.ES @@ -0,0 +1,98 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +socket = /var/lib/mysql/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +socket = /var/lib/mysql/mysql.sock +datadir = /usr/local/mysql +pid-file = /var/lib/mysql/mysqld.pid +log-error = /var/lib/mysql/mysqld.err +skip-locking +slave-skip-errors = all +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=2M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#master=====================> +log-bin +binlog-do-db = mysql +binlog-do-db = CDR_DB +binlog-do-db = CSTA_DB + + +server-id = 1 + +#slave====================> +master-host = omc-0 +master-user = administrator +master-password = "*86#ROtartsinim" +master-port = 3306 + +#master-connect-retry = 30 +#slave-read-timeout = 10 + +replicate-do-db = mysql +replicate-do-db = CDR_DB +replicate-do-db = CSTA_DB + +#replicate-do-table =*.* + + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_single b/omc/config/my.cnf_single new file mode 100644 index 0000000..83d4d9d --- /dev/null +++ b/omc/config/my.cnf_single @@ -0,0 +1,72 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +socket = /var/lib/mysql/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +socket = /var/lib/mysql/mysql.sock +skip-locking +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=32M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#log-bin +#replicate-do-table =*.* + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/my.cnf_single.ES b/omc/config/my.cnf_single.ES new file mode 100644 index 0000000..8d938d6 --- /dev/null +++ b/omc/config/my.cnf_single.ES @@ -0,0 +1,77 @@ +# Example mysql config file for medium systems. +# +# This is for a system with little memory (32M - 64M) where MySQL plays +# a important part and systems up to 128M very MySQL is used together with +# other programs (like a web server) +# +# You can copy this file to +# /etc/mf.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /usr/local/mysql/var) or +# ~/.my.cnf to set user-specific options. +# +# One can in this file use all long options that the program supports. +# If you want to know which options a program support, run the program +# with --help option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3306 +#socket = /var/lib/mysql/mysql.sock +socket = /tmp/mysql.sock +datadir = /usr/local/mysql +pid-file = /var/lib/mysql/mysqld.pid +log-error = /var/lib/mysql/mysqld.err +skip-locking +set-variable = key_buffer=16M +set-variable = max_allowed_packet=16M +set-variable = table_cache=64 +set-variable = sort_buffer=512K +set-variable = net_buffer_length=8K +set-variable = myisam_sort_buffer_size=8M +set-variable = max_binlog_size=32M +set-variable = max_connections=256 +set-variable = wait_timeout=1800 +set-variable = interactive_timeout=1800 +#log-bin +#replicate-do-table =*.* + +# Uncomment the following if you are using BDB tables +#set-variable = bdb_cache_size=4M +#set-variable = bdb_max_lock=10000 + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + +[mysqldump] +quick +set-variable = max_allowed_packet=16M + +[mysql] +no-auto-rehash +#safe-updates # Remove the comment character if you are not familiar with SQL + +[isamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[myisamchk] +set-variable = key_buffer=20M +set-variable = sort_buffer=20M +set-variable = read_buffer=2M +set-variable = write_buffer=2M + +[mysqlhotcopy] +interactive-timeout diff --git a/omc/config/omc_db.conf b/omc/config/omc_db.conf new file mode 100644 index 0000000..3e1de57 --- /dev/null +++ b/omc/config/omc_db.conf @@ -0,0 +1,50 @@ +#omc_db.conf +#config file for database maintenance + +[backup] +#List the database that need to be backuped +#CDR_DB,CSTA_DB is not need to backup +#Format:database + +[clean] +#You can termly clean tables by defining condition according to +#Format:database,table,time field,timeout,max records +OMC_PUB,sysAlarmLog,alarmTime,7,10000 +OMC_PUB,sysOperLog,datetime,7,10000 +OMC_PUB,dbAlarm,alarmTime,7,5000 +PPS_DB,used_card_info,updated_date,1900,5000000 +BssOmcDb,OMCR_ALARMEVENT,EventTime,7,10000 +BssOmcDb,OMCR_BtsMeasurements,updateTime,7,10000 +BssOmcDb,OMCR_NETWORKEVENT,EventTime,7,10000 +[remove_log] +#You can termly remove log files by defining condition according to +#Format:path,keyword,timeout(unit:day) +/usr/local/mysql,-bin,2 +/usr/local/omc/bin/dual/cdr_data_proc,dat,1 +/usr/local/omc/bin/dual/cdr_io_proc,dat,1 +/usr/local/apache/logs,access_log,7 +/usr/local/apache/htdocs/db_backup/cdrsending,csv,7 +/usr/local/apache/htdocs/db_backup/cdr,csv,7 +/usr/local/apache/htdocs/db_backup/cdrsent,csv,7 +/usr/local/apache/htdocs/db_backup/cstasending,csv,7 +/usr/local/apache/htdocs/db_backup/csta,csv,7 +/usr/local/apache/htdocs/db_backup/cstasent,csv,7 +/usr/local/apache/htdocs/db_backup/subsData,csv,7 +/usr/local/apache/htdocs/db_backup/alarmLog,csv,7 +/usr/local/apache/htdocs/db_backup/operLog,csv,7 +/usr/local/apache/htdocs/db_backup/paramConf,csv,7 +/usr/local/omc/log,gz,7 +/usr/local/omc/log,log,7 +/usr/local/omc/log,dualsrv,7 +/var/log,tmp,7 +/var/log,log,7 +/var/log,messages,7 +/var/log,secure,7 +/usr/local/apache/htdocs/db_backup/nrtrde/LOCAL_CSV.cvs,7 +/usr/local/apache/htdocs/db_backup/nrtrde/ND_RECV_BAK,ND,7 +/usr/local/apache/htdocs/db_backup/nrtrde/ND_SEND_BAK,ND,7 +/usr/local/apache/htdocs/db_backup/nrtrde/NE_RECV_BAK,NE,7 +/usr/local/apache/htdocs/db_backup/nrtrde/NE_SEND_BAK,NE,7 +/usr/local/apache/htdocs/db_backup/nrtrde/NR_RECV_BAK,NR,7 +/usr/local/apache/htdocs/db_backup/nrtrde/NR_SEND_BAK,NR,7 + diff --git a/omc/config/omcd.conf b/omc/config/omcd.conf new file mode 100644 index 0000000..1ef7e25 --- /dev/null +++ b/omc/config/omcd.conf @@ -0,0 +1,20 @@ +### +#omcTypeNo: +# 0:WXC2 OMC +# 1:GMSC OMC +# 2:MSC OMC +# 3:HLR OMC +# 4:AUC OMC +# 5:SMS OMC +# 6:PPS OMC +# 7:BSS OMC +### +omcVersion=9.02.00 + +omcTypeNo=0 +omcSysNo=0 +omcSubSysNo=0 + + +#omc run mode 0:single omc 1:dual omc +omcRunMode=1 diff --git a/omc/config/omcd.conf_omc-0 b/omc/config/omcd.conf_omc-0 new file mode 100644 index 0000000..106dfb0 --- /dev/null +++ b/omc/config/omcd.conf_omc-0 @@ -0,0 +1,19 @@ +### +#omcTypeNo: +# 0:WXC2 OMC +# 1:GMSC OMC +# 2:MSC OMC +# 3:HLR OMC +# 4:AUC OMC +# 5:SMS OMC +# 6:PPS OMC +# 7:BSS OMC +### +omcVersion=9.02.00 + +omcTypeNo=0 +omcSysNo=0 +omcSubSysNo=0 + +#omc run mode 0:single omc 1:dual omc +omcRunMode=1 diff --git a/omc/config/omcd.conf_omc-1 b/omc/config/omcd.conf_omc-1 new file mode 100644 index 0000000..0946f83 --- /dev/null +++ b/omc/config/omcd.conf_omc-1 @@ -0,0 +1,19 @@ +### +#omcTypeNo: +# 0:WXC2 OMC +# 1:GMSC OMC +# 2:MSC OMC +# 3:HLR OMC +# 4:AUC OMC +# 5:SMS OMC +# 6:PPS OMC +# 7:BSS OMC +### +omcVersion=9.02.00 + +omcTypeNo=0 +omcSysNo=1 +omcSubSysNo=0 + +#omc run mode 0:single omc 1:dual omc +omcRunMode=1 diff --git a/omc/config/omcd.conf_single b/omc/config/omcd.conf_single new file mode 100644 index 0000000..03a66ed --- /dev/null +++ b/omc/config/omcd.conf_single @@ -0,0 +1,19 @@ +### +#omcTypeNo: +# 0:WXC2 OMC +# 1:GMSC OMC +# 2:MSC OMC +# 3:HLR OMC +# 4:AUC OMC +# 5:SMS OMC +# 6:PPS OMC +# 7:BSS OMC +### +omcVersion=9.02.00 + +omcTypeNo=0 +omcSysNo=0 +omcSubSysNo=0 + +#omc run mode 0:single omc 1:dual omc +omcRunMode=0 diff --git a/omc/config/php.ini b/omc/config/php.ini new file mode 100644 index 0000000..24e1582 --- /dev/null +++ b/omc/config/php.ini @@ -0,0 +1,1224 @@ +[PHP] + +;;;;;;;;;;;;;;;;;;; +; About php.ini ; +;;;;;;;;;;;;;;;;;;; +; This file controls many aspects of PHP's behavior. In order for PHP to +; read it, it must be named 'php.ini'. PHP looks for it in the current +; working directory, in the path designated by the environment variable +; PHPRC, and in the path that was defined in compile time (in that order). +; Under Windows, the compile-time path is the Windows directory. The +; path in which the php.ini file is looked for can be overridden using +; the -c argument in command line mode. +; +; The syntax of the file is extremely simple. Whitespace and Lines +; beginning with a semicolon are silently ignored (as you probably guessed). +; Section headers (e.g. [Foo]) are also silently ignored, even though +; they might mean something in the future. +; +; Directives are specified using the following syntax: +; directive = value +; Directive names are *case sensitive* - foo=bar is different from FOO=bar. +; +; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one +; of the INI constants (On, Off, True, False, Yes, No and None) or an expression +; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo"). +; +; Expressions in the INI file are limited to bitwise operators and parentheses: +; | bitwise OR +; & bitwise AND +; ~ bitwise NOT +; ! boolean NOT +; +; Boolean flags can be turned on using the values 1, On, True or Yes. +; They can be turned off using the values 0, Off, False or No. +; +; An empty string can be denoted by simply not writing anything after the equal +; sign, or by using the None keyword: +; +; foo = ; sets foo to an empty string +; foo = none ; sets foo to an empty string +; foo = "none" ; sets foo to the string 'none' +; +; If you use constants in your value, and these constants belong to a +; dynamically loaded extension (either a PHP extension or a Zend extension), +; you may only use these constants *after* the line that loads the extension. +; +; +;;;;;;;;;;;;;;;;;;; +; About this file ; +;;;;;;;;;;;;;;;;;;; +; This is the recommended, PHP 5-style version of the php.ini-dist file. It +; sets some non standard settings, that make PHP more efficient, more secure, +; and encourage cleaner coding. +; +; The price is that with these settings, PHP may be incompatible with some +; applications, and sometimes, more difficult to develop with. Using this +; file is warmly recommended for production sites. As all of the changes from +; the standard settings are thoroughly documented, you can go over each one, +; and decide whether you want to use it or not. +; +; For general information about the php.ini file, please consult the php.ini-dist +; file, included in your PHP distribution. +; +; This file is different from the php.ini-dist file in the fact that it features +; different values for several directives, in order to improve performance, while +; possibly breaking compatibility with the standard out-of-the-box behavior of +; PHP. Please make sure you read what's different, and modify your scripts +; accordingly, if you decide to use this file instead. +; +; - register_globals = Off [Security, Performance] +; Global variables are no longer registered for input data (POST, GET, cookies, +; environment and other server variables). Instead of using $foo, you must use +; you can use $_REQUEST["foo"] (includes any variable that arrives through the +; request, namely, POST, GET and cookie variables), or use one of the specific +; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending +; on where the input originates. Also, you can look at the +; import_request_variables() function. +; Note that register_globals is going to be depracated (i.e., turned off by +; default) in the next version of PHP, because it often leads to security bugs. +; Read http://php.net/manual/en/security.registerglobals.php for further +; information. +; - register_long_arrays = Off [Performance] +; Disables registration of the older (and deprecated) long predefined array +; variables ($HTTP_*_VARS). Instead, use the superglobals that were +; introduced in PHP 4.1.0 +; - display_errors = Off [Security] +; With this directive set to off, errors that occur during the execution of +; scripts will no longer be displayed as a part of the script output, and thus, +; will no longer be exposed to remote users. With some errors, the error message +; content may expose information about your script, web server, or database +; server that may be exploitable for hacking. Production sites should have this +; directive set to off. +; - log_errors = On [Security] +; This directive complements the above one. Any errors that occur during the +; execution of your script will be logged (typically, to your server's error log, +; but can be configured in several ways). Along with setting display_errors to off, +; this setup gives you the ability to fully understand what may have gone wrong, +; without exposing any sensitive information to remote users. +; - output_buffering = 4096 [Performance] +; Set a 4KB output buffer. Enabling output buffering typically results in less +; writes, and sometimes less packets sent on the wire, which can often lead to +; better performance. The gain this directive actually yields greatly depends +; on which Web server you're working with, and what kind of scripts you're using. +; - register_argc_argv = Off [Performance] +; Disables registration of the somewhat redundant $argv and $argc global +; variables. +; - magic_quotes_gpc = Off [Performance] +; Input data is no longer escaped with slashes so that it can be sent into +; SQL databases without further manipulation. Instead, you should use the +; function addslashes() on each input element you wish to send to a database. +; - variables_order = "GPCS" [Performance] +; The environment variables are not hashed into the $_ENV. To access +; environment variables, you can use getenv() instead. +; - error_reporting = E_ALL [Code Cleanliness, Security(?)] +; By default, PHP surpresses errors of type E_NOTICE. These error messages +; are emitted for non-critical errors, but that could be a symptom of a bigger +; problem. Most notably, this will cause error messages about the use +; of uninitialized variables to be displayed. +; - allow_call_time_pass_reference = Off [Code cleanliness] +; It's not possible to decide to force a variable to be passed by reference +; when calling a function. The PHP 4 style to do this is by making the +; function require the relevant argument by reference. + + +;;;;;;;;;;;;;;;;;;;; +; Language Options ; +;;;;;;;;;;;;;;;;;;;; + +; Enable the PHP scripting language engine under Apache. +engine = On + +; Enable compatibility mode with Zend Engine 1 (PHP 4.x) +zend.ze1_compatibility_mode = Off + +; Allow the tags are recognized. +; NOTE: Using short tags should be avoided when developing applications or +; libraries that are meant for redistribution, or deployment on PHP +; servers which are not under your control, because short tags may not +; be supported on the target server. For portable, redistributable code, +; be sure not to use short tags. +short_open_tag = On + +; Allow ASP-style <% %> tags. +asp_tags = Off + +; The number of significant digits displayed in floating point numbers. +precision = 14 + +; Enforce year 2000 compliance (will cause problems with non-compliant browsers) +y2k_compliance = On + +; Output buffering allows you to send header lines (including cookies) even +; after you send body content, at the price of slowing PHP's output layer a +; bit. You can enable output buffering during runtime by calling the output +; buffering functions. You can also enable output buffering for all files by +; setting this directive to On. If you wish to limit the size of the buffer +; to a certain size - you can use a maximum number of bytes instead of 'On', as +; a value for this directive (e.g., output_buffering=4096). +output_buffering = 128 + +; You can redirect all of the output of your scripts to a function. For +; example, if you set output_handler to "mb_output_handler", character +; encoding will be transparently converted to the specified encoding. +; Setting any output handler automatically turns on output buffering. +; Note: People who wrote portable scripts should not depend on this ini +; directive. Instead, explicitly set the output handler using ob_start(). +; Using this ini directive may cause problems unless you know what script +; is doing. +; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler" +; and you cannot use both "ob_gzhandler" and "zlib.output_compression". +; Note: output_handler must be empty if this is set 'On' !!!! +; Instead you must use zlib.output_handler. +;output_handler = + +; Transparent output compression using the zlib library +; Valid values for this option are 'off', 'on', or a specific buffer size +; to be used for compression (default is 4KB) +; Note: Resulting chunk size may vary due to nature of compression. PHP +; outputs chunks that are few hundreds bytes each as a result of +; compression. If you prefer a larger chunk size for better +; performance, enable output_buffering in addition. +; Note: You need to use zlib.output_handler instead of the standard +; output_handler, or otherwise the output will be corrupted. +zlib.output_compression = Off + +; You cannot specify additional output handlers if zlib.output_compression +; is activated here. This setting does the same as output_handler but in +; a different order. +;zlib.output_handler = + +; Implicit flush tells PHP to tell the output layer to flush itself +; automatically after every output block. This is equivalent to calling the +; PHP function flush() after each and every call to print() or echo() and each +; and every HTML block. Turning this option on has serious performance +; implications and is generally recommended for debugging purposes only. +implicit_flush = Off + +; The unserialize callback function will be called (with the undefined class' +; name as parameter), if the unserializer finds an undefined class +; which should be instantiated. +; A warning appears if the specified function is not defined, or if the +; function doesn't include/implement the missing class. +; So only set this entry, if you really want to implement such a +; callback-function. +unserialize_callback_func= + +; When floats & doubles are serialized store serialize_precision significant +; digits after the floating point. The default value ensures that when floats +; are decoded with unserialize, the data will remain the same. +serialize_precision = 100 + +; Whether to enable the ability to force arguments to be passed by reference +; at function call time. This method is deprecated and is likely to be +; unsupported in future versions of PHP/Zend. The encouraged method of +; specifying which arguments should be passed by reference is in the function +; declaration. You're encouraged to try and turn this option Off and make +; sure your scripts work properly with it in order to ensure they will work +; with future versions of the language (you will receive a warning each time +; you use this feature, and the argument will be passed by value instead of by +; reference). +allow_call_time_pass_reference = Off + +; +; Safe Mode +; +safe_mode = Off + +; By default, Safe Mode does a UID compare check when +; opening files. If you want to relax this to a GID compare, +; then turn on safe_mode_gid. +safe_mode_gid = Off + +; When safe_mode is on, UID/GID checks are bypassed when +; including files from this directory and its subdirectories. +; (directory must also be in include_path or full path must +; be used when including) +safe_mode_include_dir = + +; When safe_mode is on, only executables located in the safe_mode_exec_dir +; will be allowed to be executed via the exec family of functions. +safe_mode_exec_dir = + +; Setting certain environment variables may be a potential security breach. +; This directive contains a comma-delimited list of prefixes. In Safe Mode, +; the user may only alter environment variables whose names begin with the +; prefixes supplied here. By default, users will only be able to set +; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). +; +; Note: If this directive is empty, PHP will let the user modify ANY +; environment variable! +safe_mode_allowed_env_vars = PHP_ + +; This directive contains a comma-delimited list of environment variables that +; the end user won't be able to change using putenv(). These variables will be +; protected even if safe_mode_allowed_env_vars is set to allow to change them. +safe_mode_protected_env_vars = LD_LIBRARY_PATH + +; open_basedir, if set, limits all file operations to the defined directory +; and below. This directive makes most sense if used in a per-directory +; or per-virtualhost web server configuration file. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +;open_basedir = + +; This directive allows you to disable certain functions for security reasons. +; It receives a comma-delimited list of function names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +disable_functions = + +; This directive allows you to disable certain classes for security reasons. +; It receives a comma-delimited list of class names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +disable_classes = + +; Colors for Syntax Highlighting mode. Anything that's acceptable in +; would work. +highlight.string = #DD0000 +highlight.comment = #FF9900 +highlight.keyword = #007700 +highlight.bg = #FFFFFF +highlight.default = #0000BB +highlight.html = #000000 + +; If enabled, the request will be allowed to complete even if the user aborts +; the request. Consider enabling it if executing long request, which may end up +; being interrupted by the user or a browser timing out. +; ignore_user_abort = On + +; Determines the size of the realpath cache to be used by PHP. This value should +; be increased on systems where PHP opens many files to reflect the quantity of +; the file operations performed. +; realpath_cache_size=16k + +; Duration of time, in seconds for which to cache realpath information for a given +; file or directory. For systems with rarely changing files, consider increasing this +; value. +; realpath_cache_ttl=120 + +; +; Misc +; +; Decides whether PHP may expose the fact that it is installed on the server +; (e.g. by adding its signature to the Web server header). It is no security +; threat in any way, but it makes it possible to determine whether you use PHP +; on your server or not. +expose_php = On + + +;;;;;;;;;;;;;;;;;;; +; Resource Limits ; +;;;;;;;;;;;;;;;;;;; + +max_execution_time = 3600 ; Maximum execution time of each script, in seconds +max_input_time = 1024 ; Maximum amount of time each script may spend parsing request data +memory_limit = 256M ; Maximum amount of memory a script may consume + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Error handling and logging ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; error_reporting is a bit-field. Or each number up to get desired error +; reporting level +; E_ALL - All errors and warnings (doesn't include E_STRICT) +; E_ERROR - fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it's automatically initialized to an +; empty string) +; E_STRICT - run-time notices, enable to have PHP suggest changes +; to your code which will ensure the best interoperability +; and forward compatibility of your code +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; +; Examples: +; +; - Show all errors, except for notices and coding standards warnings +; +;error_reporting = E_ALL & ~E_NOTICE +; +; - Show all errors, except for notices +; +;error_reporting = E_ALL & ~E_NOTICE | E_STRICT +; +; - Show only errors +; +;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR +; +; - Show all errors, except coding standards warnings +; +error_reporting = E_ALL & ~E_NOTICE + +; Print out errors (as a part of the output). For production web sites, +; you're strongly encouraged to turn this feature off, and use error logging +; instead (see below). Keeping display_errors enabled on a production web site +; may reveal security information to end users, such as file paths on your Web +; server, your database schema or other information. +display_errors = On + +; Even when display_errors is on, errors that occur during PHP's startup +; sequence are not displayed. It's strongly recommended to keep +; display_startup_errors off, except for when debugging. +display_startup_errors = Off + +; Log errors into a log file (server-specific log, stderr, or error_log (below)) +; As stated above, you're strongly advised to use error logging in place of +; error displaying on production web sites. +log_errors = Off + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +log_errors_max_len = 1024 + +; Do not log repeated messages. Repeated errors must occur in same file on same +; line until ignore_repeated_source is set true. +ignore_repeated_errors = Off + +; Ignore source of message when ignoring repeated messages. When this setting +; is On you will not log errors with repeated messages from different files or +; sourcelines. +ignore_repeated_source = Off + +; If this parameter is set to Off, then memory leaks will not be shown (on +; stdout or in the log). This has only effect in a debug compile, and if +; error reporting includes E_WARNING in the allowed list +report_memleaks = On + +; Store the last error/warning message in $php_errormsg (boolean). +track_errors = Off + +; Disable the inclusion of HTML tags in error messages. +; Note: Never use this feature for production boxes. +;html_errors = Off + +; If html_errors is set On PHP produces clickable error messages that direct +; to a page describing the error or function causing the error in detail. +; You can download a copy of the PHP manual from http://www.php.net/docs.php +; and change docref_root to the base URL of your local copy including the +; leading '/'. You must also specify the file extension being used including +; the dot. +; Note: Never use this feature for production boxes. +;docref_root = "/phpmanual/" +;docref_ext = .html + +; String to output before an error message. +;error_prepend_string = "" + +; String to output after an error message. +;error_append_string = "" + +; Log errors to specified file. +;error_log = filename + +; Log errors to syslog (Event Log on NT, not valid in Windows 95). +;error_log = syslog + + +;;;;;;;;;;;;;;;;; +; Data Handling ; +;;;;;;;;;;;;;;;;; +; +; Note - track_vars is ALWAYS enabled as of PHP 4.0.3 + +; The separator used in PHP generated URLs to separate arguments. +; Default is "&". +;arg_separator.output = "&" + +; List of separator(s) used by PHP to parse input URLs into variables. +; Default is "&". +; NOTE: Every character in this directive is considered as separator! +;arg_separator.input = ";&" + +; This directive describes the order in which PHP registers GET, POST, Cookie, +; Environment and Built-in variables (G, P, C, E & S respectively, often +; referred to as EGPCS or GPC). Registration is done from left to right, newer +; values override older values. +variables_order = "EGPCS" + +; Whether or not to register the EGPCS variables as global variables. You may +; want to turn this off if you don't want to clutter your scripts' global scope +; with user data. This makes most sense when coupled with track_vars - in which +; case you can access all of the GPC variables through the $HTTP_*_VARS[], +; variables. +; +; You should do your best to write your scripts so that they do not require +; register_globals to be on; Using form variables as globals can easily lead +; to possible security problems, if the code is not very well thought of. +register_globals = On + +; Whether or not to register the old-style input arrays, HTTP_GET_VARS +; and friends. If you're not using them, it's recommended to turn them off, +; for performance reasons. +register_long_arrays = On + +; This directive tells PHP whether to declare the argv&argc variables (that +; would contain the GET information). If you don't use these variables, you +; should turn it off for increased performance. +register_argc_argv = On + +; When enabled, the SERVER and ENV variables are created when they're first +; used (Just In Time) instead of when the script starts. If these variables +; are not used within a script, having this directive on will result in a +; performance gain. The PHP directives register_globals, register_long_arrays, +; and register_argc_argv must be disabled for this directive to have any affect. +auto_globals_jit = On + +; Maximum size of POST data that PHP will accept. +post_max_size = 20M + +; Magic quotes +; + +; Magic quotes for incoming GET/POST/Cookie data. +magic_quotes_gpc = On + +; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. +magic_quotes_runtime = Off + +; Use Sybase-style magic quotes (escape ' with '' instead of \'). +magic_quotes_sybase = Off + +; Automatically add files before or after any PHP document. +auto_prepend_file = +auto_append_file = + +; As of 4.0b4, PHP always outputs a character encoding by default in +; the Content-type: header. To disable sending of the charset, simply +; set it to be empty. +; +; PHP's built-in default is text/html +default_mimetype = "text/html" +;default_charset = "iso-8859-1" + +; Always populate the $HTTP_RAW_POST_DATA variable. +;always_populate_raw_post_data = On + + +;;;;;;;;;;;;;;;;;;;;;;;;; +; Paths and Directories ; +;;;;;;;;;;;;;;;;;;;;;;;;; + +; UNIX: "/path1:/path2" +;include_path = ".:/php/includes" +; +; Windows: "\path1;\path2" +;include_path = ".;c:\php\includes" + +; The root of the PHP pages, used only if nonempty. +; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root +; if you are running php as a CGI under any web server (other than IIS) +; see documentation for security issues. The alternate is to use the +; cgi.force_redirect configuration below +doc_root = + +; The directory under which PHP opens the script using /~username used only +; if nonempty. +user_dir = + +; Directory in which the loadable extensions (modules) reside. +extension_dir = "/usr/lib/php/modules" + +; Whether or not to enable the dl() function. The dl() function does NOT work +; properly in multithreaded servers, such as IIS or Zeus, and is automatically +; disabled on them. +enable_dl = On + +; cgi.force_redirect is necessary to provide security running PHP as a CGI under +; most web servers. Left undefined, PHP turns this on by default. You can +; turn it off here AT YOUR OWN RISK +; **You CAN safely turn this off for IIS, in fact, you MUST.** +; cgi.force_redirect = 1 + +; if cgi.nph is enabled it will force cgi to always sent Status: 200 with +; every request. +; cgi.nph = 1 + +; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape +; (iPlanet) web servers, you MAY need to set an environment variable name that PHP +; will look for to know it is OK to continue execution. Setting this variable MAY +; cause security issues, KNOW WHAT YOU ARE DOING FIRST. +; cgi.redirect_status_env = ; + +; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate +; security tokens of the calling client. This allows IIS to define the +; security context that the request runs under. mod_fastcgi under Apache +; does not currently support this feature (03/17/2002) +; Set to 1 if running under IIS. Default is zero. +; fastcgi.impersonate = 1; + +; Disable logging through FastCGI connection +; fastcgi.log = 0 + +; cgi.rfc2616_headers configuration option tells PHP what type of headers to +; use when sending HTTP response code. If it's set 0 PHP sends Status: header that +; is supported by Apache. When this option is set to 1 PHP will send +; RFC2616 compliant header. +; Default is zero. +;cgi.rfc2616_headers = 0 + + +;;;;;;;;;;;;;;;; +; File Uploads ; +;;;;;;;;;;;;;;;; + +; Whether to allow HTTP file uploads. +file_uploads = On + +; Temporary directory for HTTP uploaded files (will use system default if not +; specified). +;upload_tmp_dir = + +; Maximum allowed size for uploaded files. +upload_max_filesize = 200M + + +;;;;;;;;;;;;;;;;;; +; Fopen wrappers ; +;;;;;;;;;;;;;;;;;; + +; Whether to allow the treatment of URLs (like http:// or ftp://) as files. +allow_url_fopen = On + +; Define the anonymous ftp password (your email address) +;from="john@doe.com" + +; Define the User-Agent string +; user_agent="PHP" + +; Default timeout for socket based streams (seconds) +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; auto_detect_line_endings = Off + + +;;;;;;;;;;;;;;;;;;;;;; +; Dynamic Extensions ; +;;;;;;;;;;;;;;;;;;;;;; +; +; If you wish to have an extension loaded automatically, use the following +; syntax: +; +; extension=modulename.extension +; +; For example: +; +; extension=msql.so +; + extension=ssh2.so +; Note that it should be the name of the module only; no directory information +; needs to go here. Specify the location of the extension with the +; extension_dir directive above. + + +;;;; +; Note: packaged extension modules are now loaded via the .ini files +; found in the directory /etc/php.d; these are loaded by default. +;;;; + + +;;;;;;;;;;;;;;;;;;; +; Module Settings ; +;;;;;;;;;;;;;;;;;;; + +[Date] +; Defines the default timezone used by the date functions +;date.timezone = + +[Syslog] +; Whether or not to define the various syslog variables (e.g. $LOG_PID, +; $LOG_CRON, etc.). Turning it off is a good idea performance-wise. In +; runtime, you can define these variables by calling define_syslog_variables(). +define_syslog_variables = Off + +[mail function] +; For Win32 only. +SMTP = localhost +smtp_port = 25 + +; For Win32 only. +;sendmail_from = me@example.com + +; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). +sendmail_path = /usr/sbin/sendmail -t -i + +; Force the addition of the specified parameters to be passed as extra parameters +; to the sendmail binary. These parameters will always replace the value of +; the 5th parameter to mail(), even in safe mode. +;mail.force_extra_parameters = + +[SQL] +sql.safe_mode = Off + +[ODBC] +;odbc.default_db = Not yet implemented +;odbc.default_user = Not yet implemented +;odbc.default_pw = Not yet implemented + +; Allow or prevent persistent links. +odbc.allow_persistent = On + +; Check that a connection is still valid before reuse. +odbc.check_persistent = On + +; Maximum number of persistent links. -1 means no limit. +odbc.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +odbc.max_links = -1 + +; Handling of LONG fields. Returns number of bytes to variables. 0 means +; passthru. +odbc.defaultlrl = 4096 + +; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. +; See the documentation on odbc_binmode and odbc_longreadlen for an explanation +; of uodbc.defaultlrl and uodbc.defaultbinmode +odbc.defaultbinmode = 1 + +[MySQL] +; Allow or prevent persistent links. +mysql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mysql.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +mysql.max_links = -1 + +; Default port number for mysql_connect(). If unset, mysql_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +mysql.default_port = + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +mysql.default_socket = +;mysql.default_socket = /tmp/mysql.sock + +; Default host for mysql_connect() (doesn't apply in safe mode). +mysql.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +mysql.default_user = + +; Default password for mysql_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +mysql.default_password = + +; Maximum time (in secondes) for connect timeout. -1 means no limit +mysql.connect_timeout = 60 + +; Trace mode. When trace_mode is active (=On), warnings for table/index scans and +; SQL-Errors will be displayed. +mysql.trace_mode = Off + +[MySQLi] + +; Maximum number of links. -1 means no limit. +mysqli.max_links = -1 + +; Default port number for mysqli_connect(). If unset, mysqli_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +mysqli.default_port = 3306 + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +mysqli.default_socket = + +; Default host for mysql_connect() (doesn't apply in safe mode). +mysqli.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +mysqli.default_user = + +; Default password for mysqli_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +mysqli.default_pw = + +; Allow or prevent reconnect +mysqli.reconnect = Off + +[mSQL] +; Allow or prevent persistent links. +msql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +msql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +msql.max_links = -1 + +[PostgresSQL] +; Allow or prevent persistent links. +pgsql.allow_persistent = On + +; Detect broken persistent links always with pg_pconnect(). +; Auto reset feature requires a little overheads. +pgsql.auto_reset_persistent = Off + +; Maximum number of persistent links. -1 means no limit. +pgsql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +pgsql.max_links = -1 + +; Ignore PostgreSQL backends Notice message or not. +; Notice message logging require a little overheads. +pgsql.ignore_notice = 0 + +; Log PostgreSQL backends Noitce message or not. +; Unless pgsql.ignore_notice=0, module cannot log notice message. +pgsql.log_notice = 0 + +[Sybase] +; Allow or prevent persistent links. +sybase.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybase.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybase.max_links = -1 + +;sybase.interface_file = "/usr/sybase/interfaces" + +; Minimum error severity to display. +sybase.min_error_severity = 10 + +; Minimum message severity to display. +sybase.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +; If on, this will cause PHP to automatically assign types to results according +; to their Sybase type, instead of treating them all as strings. This +; compatability mode will probably not stay around forever, so try applying +; whatever necessary changes to your code, and turn it off. +sybase.compatability_mode = Off + +[Sybase-CT] +; Allow or prevent persistent links. +sybct.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybct.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybct.max_links = -1 + +; Minimum server message severity to display. +sybct.min_server_severity = 10 + +; Minimum client message severity to display. +sybct.min_client_severity = 10 + +[bcmath] +; Number of decimal digits for all bcmath functions. +bcmath.scale = 0 + +[browscap] +;browscap = extra/browscap.ini + +[Informix] +; Default host for ifx_connect() (doesn't apply in safe mode). +ifx.default_host = + +; Default user for ifx_connect() (doesn't apply in safe mode). +ifx.default_user = + +; Default password for ifx_connect() (doesn't apply in safe mode). +ifx.default_password = + +; Allow or prevent persistent links. +ifx.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +ifx.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +ifx.max_links = -1 + +; If on, select statements return the contents of a text blob instead of its id. +ifx.textasvarchar = 0 + +; If on, select statements return the contents of a byte blob instead of its id. +ifx.byteasvarchar = 0 + +; Trailing blanks are stripped from fixed-length char columns. May help the +; life of Informix SE users. +ifx.charasvarchar = 0 + +; If on, the contents of text and byte blobs are dumped to a file instead of +; keeping them in memory. +ifx.blobinfile = 0 + +; NULL's are returned as empty strings, unless this is set to 1. In that case, +; NULL's are returned as string 'NULL'. +ifx.nullformat = 0 + +[Session] +; Handler used to store/retrieve data. +session.save_handler = files + +; Argument passed to save_handler. In the case of files, this is the path +; where data files are stored. Note: Windows users have to change this +; variable in order to use PHP's session functions. +; +; As of PHP 4.0.1, you can define the path as: +; +; session.save_path = "N;/path" +; +; where N is an integer. Instead of storing all the session files in +; /path, what this will do is use subdirectories N-levels deep, and +; store the session data in those directories. This is useful if you +; or your OS have problems with lots of files in one directory, and is +; a more efficient layout for servers that handle lots of sessions. +; +; NOTE 1: PHP will not create this directory structure automatically. +; You can use the script in the ext/session dir for that purpose. +; NOTE 2: See the section on garbage collection below if you choose to +; use subdirectories for session storage +; +; The file storage module creates files using mode 600 by default. +; You can change that by using +; +; session.save_path = "N;MODE;/path" +; +; where MODE is the octal representation of the mode. Note that this +; does not overwrite the process's umask. +;session.save_path = "/var/lib/php/session" +session.save_path = "/tmp" + +; Whether to use cookies. +session.use_cookies = 1 + +; This option enables administrators to make their users invulnerable to +; attacks which involve passing session ids in URLs; defaults to 0. +; session.use_only_cookies = 1 + +; Name of the session (used as cookie name). +session.name = PHPSESSID + +; Initialize session on request startup. +session.auto_start = 1 + +; Lifetime in seconds of cookie or, if 0, until browser is restarted. +session.cookie_lifetime = 0 + +; The path for which the cookie is valid. +session.cookie_path = / + +; The domain for which the cookie is valid. +session.cookie_domain = + +; Handler used to serialize data. php is the standard serializer of PHP. +session.serialize_handler = php + +; Define the probability that the 'garbage collection' process is started +; on every session initialization. +; The probability is calculated by using gc_probability/gc_divisor, +; e.g. 1/100 means there is a 1% chance that the GC process starts +; on each request. + +session.gc_probability = 20 +session.gc_divisor = 1000 + +; After this number of seconds, stored data will be seen as 'garbage' and +; cleaned up by the garbage collection process. +session.gc_maxlifetime = 1440 + +; NOTE: If you are using the subdirectory option for storing session files +; (see session.save_path above), then garbage collection does *not* +; happen automatically. You will need to do your own garbage +; collection through a shell script, cron entry, or some other method. +; For example, the following script would is the equivalent of +; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): +; cd /path/to/sessions; find -cmin +24 | xargs rm + +; PHP 4.2 and less have an undocumented feature/bug that allows you to +; to initialize a session variable in the global scope, albeit register_globals +; is disabled. PHP 4.3 and later will warn you, if this feature is used. +; You can disable the feature and the warning separately. At this time, +; the warning is only displayed, if bug_compat_42 is enabled. + +session.bug_compat_42 = 0 +session.bug_compat_warn = 1 + +; Check HTTP Referer to invalidate externally stored URLs containing ids. +; HTTP_REFERER has to contain this substring for the session to be +; considered as valid. +session.referer_check = + +; How many bytes to read from the file. +session.entropy_length = 0 + +; Specified here to create the session id. +session.entropy_file = + +;session.entropy_length = 16 + +;session.entropy_file = /dev/urandom + +; Set to {nocache,private,public,} to determine HTTP caching aspects +; or leave this empty to avoid sending anti-caching headers. +session.cache_limiter = nocache + +; Document expires after n minutes. +session.cache_expire = 180 + +; trans sid support is disabled by default. +; Use of trans sid may risk your users security. +; Use this option with caution. +; - User may send URL contains active session ID +; to other person via. email/irc/etc. +; - URL that contains active session ID may be stored +; in publically accessible computer. +; - User may access your site with the same session ID +; always using URL stored in browser's history or bookmarks. +session.use_trans_sid = 0 + +; Select a hash function +; 0: MD5 (128 bits) +; 1: SHA-1 (160 bits) +session.hash_function = 0 + +; Define how many bits are stored in each character when converting +; the binary hash data to something readable. +; +; 4 bits: 0-9, a-f +; 5 bits: 0-9, a-v +; 6 bits: 0-9, a-z, A-Z, "-", "," +session.hash_bits_per_character = 5 + +; The URL rewriter will look for URLs in a defined set of HTML tags. +; form/fieldset are special; if you include them here, the rewriter will +; add a hidden field with the info which is otherwise appended +; to URLs. If you want XHTML conformity, remove the form entry. +; Note that all valid entries require a "=", even if no value follows. +url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" + +[MSSQL] +; Allow or prevent persistent links. +mssql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mssql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +mssql.max_links = -1 + +; Minimum error severity to display. +mssql.min_error_severity = 10 + +; Minimum message severity to display. +mssql.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +mssql.compatability_mode = Off + +; Connect timeout +;mssql.connect_timeout = 5 + +; Query timeout +;mssql.timeout = 60 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textlimit = 4096 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textsize = 4096 + +; Limits the number of records in each batch. 0 = all records in one batch. +;mssql.batchsize = 0 + +; Specify how datetime and datetim4 columns are returned +; On => Returns data converted to SQL server settings +; Off => Returns values as YYYY-MM-DD hh:mm:ss +;mssql.datetimeconvert = On + +; Use NT authentication when connecting to the server +mssql.secure_connection = Off + +; Specify max number of processes. -1 = library default +; msdlib defaults to 25 +; FreeTDS defaults to 4096 +;mssql.max_procs = -1 + +; Specify client character set. +; If empty or not set the client charset from freetds.comf is used +; This is only used when compiled with FreeTDS +;mssql.charset = "ISO-8859-1" + +[Assertion] +; Assert(expr); active by default. +;assert.active = On + +; Issue a PHP warning for each failed assertion. +;assert.warning = On + +; Don't bail out by default. +;assert.bail = Off + +; User-function to be called if an assertion fails. +;assert.callback = 0 + +; Eval the expression with current error_reporting(). Set to true if you want +; error_reporting(0) around the eval(). +;assert.quiet_eval = 0 + +[Verisign Payflow Pro] +; Default Payflow Pro server. +pfpro.defaulthost = "test-payflow.verisign.com" + +; Default port to connect to. +pfpro.defaultport = 443 + +; Default timeout in seconds. +pfpro.defaulttimeout = 30 + +; Default proxy IP address (if required). +;pfpro.proxyaddress = + +; Default proxy port. +;pfpro.proxyport = + +; Default proxy logon. +;pfpro.proxylogon = + +; Default proxy password. +;pfpro.proxypassword = + +[COM] +; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs +;com.typelib_file = +; allow Distributed-COM calls +;com.allow_dcom = true +; autoregister constants of a components typlib on com_load() +;com.autoregister_typelib = true +; register constants casesensitive +;com.autoregister_casesensitive = false +; show warnings on duplicate constat registrations +;com.autoregister_verbose = true + +[mbstring] +; language for internal character representation. +;mbstring.language = Japanese + +; internal/script encoding. +; Some encoding cannot work as internal encoding. +; (e.g. SJIS, BIG5, ISO-2022-*) +;mbstring.internal_encoding = EUC-JP + +; http input encoding. +;mbstring.http_input = auto + +; http output encoding. mb_output_handler must be +; registered as output buffer to function +;mbstring.http_output = SJIS + +; enable automatic encoding translation according to +; mbstring.internal_encoding setting. Input chars are +; converted to internal encoding by setting this to On. +; Note: Do _not_ use automatic encoding translation for +; portable libs/applications. +;mbstring.encoding_translation = Off + +; automatic encoding detection order. +; auto means +;mbstring.detect_order = auto + +; substitute_character used when character cannot be converted +; one from another +;mbstring.substitute_character = none; + +; overload(replace) single byte functions by mbstring functions. +; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), +; etc. Possible values are 0,1,2,4 or combination of them. +; For example, 7 for overload everything. +; 0: No overload +; 1: Overload mail() function +; 2: Overload str*() functions +; 4: Overload ereg*() functions +;mbstring.func_overload = 0 + +; enable strict encoding detection. +;mbstring.strict_encoding = Off + +[FrontBase] +;fbsql.allow_persistent = On +;fbsql.autocommit = On +;fbsql.default_database = +;fbsql.default_database_password = +;fbsql.default_host = +;fbsql.default_password = +;fbsql.default_user = "_SYSTEM" +;fbsql.generate_warnings = Off +;fbsql.max_connections = 128 +;fbsql.max_links = 128 +;fbsql.max_persistent = -1 +;fbsql.max_results = 128 +;fbsql.batchSize = 1000 + +[gd] +; Tell the jpeg decode to libjpeg warnings and try to create +; a gd image. The warning will then be displayed as notices +; disabled by default +;gd.jpeg_ignore_warning = 0 + +[exif] +; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. +; With mbstring support this will automatically be converted into the encoding +; given by corresponding encode setting. When empty mbstring.internal_encoding +; is used. For the decode settings you can distinguish between motorola and +; intel byte order. A decode setting cannot be empty. +;exif.encode_unicode = ISO-8859-15 +;exif.decode_unicode_motorola = UCS-2BE +;exif.decode_unicode_intel = UCS-2LE +;exif.encode_jis = +;exif.decode_jis_motorola = JIS +;exif.decode_jis_intel = JIS + +[Tidy] +; The path to a default tidy configuration file to use when using tidy +;tidy.default_config = /usr/local/lib/php/default.tcfg + +; Should tidy clean and repair output automatically? +; WARNING: Do not use this option if you are generating non-html content +; such as dynamic images +tidy.clean_output = Off + +[soap] +; Enables or disables WSDL caching feature. +soap.wsdl_cache_enabled=1 +; Sets the directory name where SOAP extension will put cache files. +soap.wsdl_cache_dir="/tmp" +; (time to live) Sets the number of second while cached file will be used +; instead of original one. +soap.wsdl_cache_ttl=86400 + +; Local Variables: +; tab-width: 4 +; End: diff --git a/omc/config/php.ini_old_plat b/omc/config/php.ini_old_plat new file mode 100644 index 0000000..ba54fb5 --- /dev/null +++ b/omc/config/php.ini_old_plat @@ -0,0 +1,1223 @@ +[PHP] + +;;;;;;;;;;;;;;;;;;; +; About php.ini ; +;;;;;;;;;;;;;;;;;;; +; This file controls many aspects of PHP's behavior. In order for PHP to +; read it, it must be named 'php.ini'. PHP looks for it in the current +; working directory, in the path designated by the environment variable +; PHPRC, and in the path that was defined in compile time (in that order). +; Under Windows, the compile-time path is the Windows directory. The +; path in which the php.ini file is looked for can be overridden using +; the -c argument in command line mode. +; +; The syntax of the file is extremely simple. Whitespace and Lines +; beginning with a semicolon are silently ignored (as you probably guessed). +; Section headers (e.g. [Foo]) are also silently ignored, even though +; they might mean something in the future. +; +; Directives are specified using the following syntax: +; directive = value +; Directive names are *case sensitive* - foo=bar is different from FOO=bar. +; +; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one +; of the INI constants (On, Off, True, False, Yes, No and None) or an expression +; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo"). +; +; Expressions in the INI file are limited to bitwise operators and parentheses: +; | bitwise OR +; & bitwise AND +; ~ bitwise NOT +; ! boolean NOT +; +; Boolean flags can be turned on using the values 1, On, True or Yes. +; They can be turned off using the values 0, Off, False or No. +; +; An empty string can be denoted by simply not writing anything after the equal +; sign, or by using the None keyword: +; +; foo = ; sets foo to an empty string +; foo = none ; sets foo to an empty string +; foo = "none" ; sets foo to the string 'none' +; +; If you use constants in your value, and these constants belong to a +; dynamically loaded extension (either a PHP extension or a Zend extension), +; you may only use these constants *after* the line that loads the extension. +; +; +;;;;;;;;;;;;;;;;;;; +; About this file ; +;;;;;;;;;;;;;;;;;;; +; This is the recommended, PHP 5-style version of the php.ini-dist file. It +; sets some non standard settings, that make PHP more efficient, more secure, +; and encourage cleaner coding. +; +; The price is that with these settings, PHP may be incompatible with some +; applications, and sometimes, more difficult to develop with. Using this +; file is warmly recommended for production sites. As all of the changes from +; the standard settings are thoroughly documented, you can go over each one, +; and decide whether you want to use it or not. +; +; For general information about the php.ini file, please consult the php.ini-dist +; file, included in your PHP distribution. +; +; This file is different from the php.ini-dist file in the fact that it features +; different values for several directives, in order to improve performance, while +; possibly breaking compatibility with the standard out-of-the-box behavior of +; PHP. Please make sure you read what's different, and modify your scripts +; accordingly, if you decide to use this file instead. +; +; - register_globals = Off [Security, Performance] +; Global variables are no longer registered for input data (POST, GET, cookies, +; environment and other server variables). Instead of using $foo, you must use +; you can use $_REQUEST["foo"] (includes any variable that arrives through the +; request, namely, POST, GET and cookie variables), or use one of the specific +; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending +; on where the input originates. Also, you can look at the +; import_request_variables() function. +; Note that register_globals is going to be depracated (i.e., turned off by +; default) in the next version of PHP, because it often leads to security bugs. +; Read http://php.net/manual/en/security.registerglobals.php for further +; information. +; - register_long_arrays = Off [Performance] +; Disables registration of the older (and deprecated) long predefined array +; variables ($HTTP_*_VARS). Instead, use the superglobals that were +; introduced in PHP 4.1.0 +; - display_errors = Off [Security] +; With this directive set to off, errors that occur during the execution of +; scripts will no longer be displayed as a part of the script output, and thus, +; will no longer be exposed to remote users. With some errors, the error message +; content may expose information about your script, web server, or database +; server that may be exploitable for hacking. Production sites should have this +; directive set to off. +; - log_errors = On [Security] +; This directive complements the above one. Any errors that occur during the +; execution of your script will be logged (typically, to your server's error log, +; but can be configured in several ways). Along with setting display_errors to off, +; this setup gives you the ability to fully understand what may have gone wrong, +; without exposing any sensitive information to remote users. +; - output_buffering = 4096 [Performance] +; Set a 4KB output buffer. Enabling output buffering typically results in less +; writes, and sometimes less packets sent on the wire, which can often lead to +; better performance. The gain this directive actually yields greatly depends +; on which Web server you're working with, and what kind of scripts you're using. +; - register_argc_argv = Off [Performance] +; Disables registration of the somewhat redundant $argv and $argc global +; variables. +; - magic_quotes_gpc = Off [Performance] +; Input data is no longer escaped with slashes so that it can be sent into +; SQL databases without further manipulation. Instead, you should use the +; function addslashes() on each input element you wish to send to a database. +; - variables_order = "GPCS" [Performance] +; The environment variables are not hashed into the $_ENV. To access +; environment variables, you can use getenv() instead. +; - error_reporting = E_ALL [Code Cleanliness, Security(?)] +; By default, PHP surpresses errors of type E_NOTICE. These error messages +; are emitted for non-critical errors, but that could be a symptom of a bigger +; problem. Most notably, this will cause error messages about the use +; of uninitialized variables to be displayed. +; - allow_call_time_pass_reference = Off [Code cleanliness] +; It's not possible to decide to force a variable to be passed by reference +; when calling a function. The PHP 4 style to do this is by making the +; function require the relevant argument by reference. + + +;;;;;;;;;;;;;;;;;;;; +; Language Options ; +;;;;;;;;;;;;;;;;;;;; + +; Enable the PHP scripting language engine under Apache. +engine = On + +; Enable compatibility mode with Zend Engine 1 (PHP 4.x) +zend.ze1_compatibility_mode = Off + +; Allow the tags are recognized. +; NOTE: Using short tags should be avoided when developing applications or +; libraries that are meant for redistribution, or deployment on PHP +; servers which are not under your control, because short tags may not +; be supported on the target server. For portable, redistributable code, +; be sure not to use short tags. +short_open_tag = On + +; Allow ASP-style <% %> tags. +asp_tags = Off + +; The number of significant digits displayed in floating point numbers. +precision = 14 + +; Enforce year 2000 compliance (will cause problems with non-compliant browsers) +y2k_compliance = On + +; Output buffering allows you to send header lines (including cookies) even +; after you send body content, at the price of slowing PHP's output layer a +; bit. You can enable output buffering during runtime by calling the output +; buffering functions. You can also enable output buffering for all files by +; setting this directive to On. If you wish to limit the size of the buffer +; to a certain size - you can use a maximum number of bytes instead of 'On', as +; a value for this directive (e.g., output_buffering=4096). +output_buffering = 4096 + +; You can redirect all of the output of your scripts to a function. For +; example, if you set output_handler to "mb_output_handler", character +; encoding will be transparently converted to the specified encoding. +; Setting any output handler automatically turns on output buffering. +; Note: People who wrote portable scripts should not depend on this ini +; directive. Instead, explicitly set the output handler using ob_start(). +; Using this ini directive may cause problems unless you know what script +; is doing. +; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler" +; and you cannot use both "ob_gzhandler" and "zlib.output_compression". +; Note: output_handler must be empty if this is set 'On' !!!! +; Instead you must use zlib.output_handler. +;output_handler = + +; Transparent output compression using the zlib library +; Valid values for this option are 'off', 'on', or a specific buffer size +; to be used for compression (default is 4KB) +; Note: Resulting chunk size may vary due to nature of compression. PHP +; outputs chunks that are few hundreds bytes each as a result of +; compression. If you prefer a larger chunk size for better +; performance, enable output_buffering in addition. +; Note: You need to use zlib.output_handler instead of the standard +; output_handler, or otherwise the output will be corrupted. +zlib.output_compression = Off + +; You cannot specify additional output handlers if zlib.output_compression +; is activated here. This setting does the same as output_handler but in +; a different order. +;zlib.output_handler = + +; Implicit flush tells PHP to tell the output layer to flush itself +; automatically after every output block. This is equivalent to calling the +; PHP function flush() after each and every call to print() or echo() and each +; and every HTML block. Turning this option on has serious performance +; implications and is generally recommended for debugging purposes only. +implicit_flush = Off + +; The unserialize callback function will be called (with the undefined class' +; name as parameter), if the unserializer finds an undefined class +; which should be instantiated. +; A warning appears if the specified function is not defined, or if the +; function doesn't include/implement the missing class. +; So only set this entry, if you really want to implement such a +; callback-function. +unserialize_callback_func= + +; When floats & doubles are serialized store serialize_precision significant +; digits after the floating point. The default value ensures that when floats +; are decoded with unserialize, the data will remain the same. +serialize_precision = 100 + +; Whether to enable the ability to force arguments to be passed by reference +; at function call time. This method is deprecated and is likely to be +; unsupported in future versions of PHP/Zend. The encouraged method of +; specifying which arguments should be passed by reference is in the function +; declaration. You're encouraged to try and turn this option Off and make +; sure your scripts work properly with it in order to ensure they will work +; with future versions of the language (you will receive a warning each time +; you use this feature, and the argument will be passed by value instead of by +; reference). +allow_call_time_pass_reference = Off + +; +; Safe Mode +; +safe_mode = Off + +; By default, Safe Mode does a UID compare check when +; opening files. If you want to relax this to a GID compare, +; then turn on safe_mode_gid. +safe_mode_gid = Off + +; When safe_mode is on, UID/GID checks are bypassed when +; including files from this directory and its subdirectories. +; (directory must also be in include_path or full path must +; be used when including) +safe_mode_include_dir = + +; When safe_mode is on, only executables located in the safe_mode_exec_dir +; will be allowed to be executed via the exec family of functions. +safe_mode_exec_dir = + +; Setting certain environment variables may be a potential security breach. +; This directive contains a comma-delimited list of prefixes. In Safe Mode, +; the user may only alter environment variables whose names begin with the +; prefixes supplied here. By default, users will only be able to set +; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). +; +; Note: If this directive is empty, PHP will let the user modify ANY +; environment variable! +safe_mode_allowed_env_vars = PHP_ + +; This directive contains a comma-delimited list of environment variables that +; the end user won't be able to change using putenv(). These variables will be +; protected even if safe_mode_allowed_env_vars is set to allow to change them. +safe_mode_protected_env_vars = LD_LIBRARY_PATH + +; open_basedir, if set, limits all file operations to the defined directory +; and below. This directive makes most sense if used in a per-directory +; or per-virtualhost web server configuration file. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +;open_basedir = + +; This directive allows you to disable certain functions for security reasons. +; It receives a comma-delimited list of function names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +disable_functions = + +; This directive allows you to disable certain classes for security reasons. +; It receives a comma-delimited list of class names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +disable_classes = + +; Colors for Syntax Highlighting mode. Anything that's acceptable in +; would work. +highlight.string = #DD0000 +highlight.comment = #FF9900 +highlight.keyword = #007700 +highlight.bg = #FFFFFF +highlight.default = #0000BB +highlight.html = #000000 + +; If enabled, the request will be allowed to complete even if the user aborts +; the request. Consider enabling it if executing long request, which may end up +; being interrupted by the user or a browser timing out. +; ignore_user_abort = On + +; Determines the size of the realpath cache to be used by PHP. This value should +; be increased on systems where PHP opens many files to reflect the quantity of +; the file operations performed. +; realpath_cache_size=16k + +; Duration of time, in seconds for which to cache realpath information for a given +; file or directory. For systems with rarely changing files, consider increasing this +; value. +; realpath_cache_ttl=120 + +; +; Misc +; +; Decides whether PHP may expose the fact that it is installed on the server +; (e.g. by adding its signature to the Web server header). It is no security +; threat in any way, but it makes it possible to determine whether you use PHP +; on your server or not. +expose_php = On + + +;;;;;;;;;;;;;;;;;;; +; Resource Limits ; +;;;;;;;;;;;;;;;;;;; + +max_execution_time = 3600 ; Maximum execution time of each script, in seconds +max_input_time = 1024 ; Maximum amount of time each script may spend parsing request data +memory_limit = 20M ; Maximum amount of memory a script may consume + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Error handling and logging ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; error_reporting is a bit-field. Or each number up to get desired error +; reporting level +; E_ALL - All errors and warnings (doesn't include E_STRICT) +; E_ERROR - fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it's automatically initialized to an +; empty string) +; E_STRICT - run-time notices, enable to have PHP suggest changes +; to your code which will ensure the best interoperability +; and forward compatibility of your code +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; +; Examples: +; +; - Show all errors, except for notices and coding standards warnings +; +;error_reporting = E_ALL & ~E_NOTICE +; +; - Show all errors, except for notices +; +;error_reporting = E_ALL & ~E_NOTICE | E_STRICT +; +; - Show only errors +; +;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR +; +; - Show all errors, except coding standards warnings +; +error_reporting = E_ALL & ~E_NOTICE + +; Print out errors (as a part of the output). For production web sites, +; you're strongly encouraged to turn this feature off, and use error logging +; instead (see below). Keeping display_errors enabled on a production web site +; may reveal security information to end users, such as file paths on your Web +; server, your database schema or other information. +display_errors = On + +; Even when display_errors is on, errors that occur during PHP's startup +; sequence are not displayed. It's strongly recommended to keep +; display_startup_errors off, except for when debugging. +display_startup_errors = Off + +; Log errors into a log file (server-specific log, stderr, or error_log (below)) +; As stated above, you're strongly advised to use error logging in place of +; error displaying on production web sites. +log_errors = Off + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +log_errors_max_len = 1024 + +; Do not log repeated messages. Repeated errors must occur in same file on same +; line until ignore_repeated_source is set true. +ignore_repeated_errors = Off + +; Ignore source of message when ignoring repeated messages. When this setting +; is On you will not log errors with repeated messages from different files or +; sourcelines. +ignore_repeated_source = Off + +; If this parameter is set to Off, then memory leaks will not be shown (on +; stdout or in the log). This has only effect in a debug compile, and if +; error reporting includes E_WARNING in the allowed list +report_memleaks = On + +; Store the last error/warning message in $php_errormsg (boolean). +track_errors = Off + +; Disable the inclusion of HTML tags in error messages. +; Note: Never use this feature for production boxes. +;html_errors = Off + +; If html_errors is set On PHP produces clickable error messages that direct +; to a page describing the error or function causing the error in detail. +; You can download a copy of the PHP manual from http://www.php.net/docs.php +; and change docref_root to the base URL of your local copy including the +; leading '/'. You must also specify the file extension being used including +; the dot. +; Note: Never use this feature for production boxes. +;docref_root = "/phpmanual/" +;docref_ext = .html + +; String to output before an error message. +;error_prepend_string = "" + +; String to output after an error message. +;error_append_string = "" + +; Log errors to specified file. +;error_log = filename + +; Log errors to syslog (Event Log on NT, not valid in Windows 95). +;error_log = syslog + + +;;;;;;;;;;;;;;;;; +; Data Handling ; +;;;;;;;;;;;;;;;;; +; +; Note - track_vars is ALWAYS enabled as of PHP 4.0.3 + +; The separator used in PHP generated URLs to separate arguments. +; Default is "&". +;arg_separator.output = "&" + +; List of separator(s) used by PHP to parse input URLs into variables. +; Default is "&". +; NOTE: Every character in this directive is considered as separator! +;arg_separator.input = ";&" + +; This directive describes the order in which PHP registers GET, POST, Cookie, +; Environment and Built-in variables (G, P, C, E & S respectively, often +; referred to as EGPCS or GPC). Registration is done from left to right, newer +; values override older values. +variables_order = "EGPCS" + +; Whether or not to register the EGPCS variables as global variables. You may +; want to turn this off if you don't want to clutter your scripts' global scope +; with user data. This makes most sense when coupled with track_vars - in which +; case you can access all of the GPC variables through the $HTTP_*_VARS[], +; variables. +; +; You should do your best to write your scripts so that they do not require +; register_globals to be on; Using form variables as globals can easily lead +; to possible security problems, if the code is not very well thought of. +register_globals = On + +; Whether or not to register the old-style input arrays, HTTP_GET_VARS +; and friends. If you're not using them, it's recommended to turn them off, +; for performance reasons. +register_long_arrays = On + +; This directive tells PHP whether to declare the argv&argc variables (that +; would contain the GET information). If you don't use these variables, you +; should turn it off for increased performance. +register_argc_argv = On + +; When enabled, the SERVER and ENV variables are created when they're first +; used (Just In Time) instead of when the script starts. If these variables +; are not used within a script, having this directive on will result in a +; performance gain. The PHP directives register_globals, register_long_arrays, +; and register_argc_argv must be disabled for this directive to have any affect. +auto_globals_jit = On + +; Maximum size of POST data that PHP will accept. +post_max_size = 20M + +; Magic quotes +; + +; Magic quotes for incoming GET/POST/Cookie data. +magic_quotes_gpc = On + +; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. +magic_quotes_runtime = Off + +; Use Sybase-style magic quotes (escape ' with '' instead of \'). +magic_quotes_sybase = Off + +; Automatically add files before or after any PHP document. +auto_prepend_file = +auto_append_file = + +; As of 4.0b4, PHP always outputs a character encoding by default in +; the Content-type: header. To disable sending of the charset, simply +; set it to be empty. +; +; PHP's built-in default is text/html +default_mimetype = "text/html" +;default_charset = "iso-8859-1" + +; Always populate the $HTTP_RAW_POST_DATA variable. +;always_populate_raw_post_data = On + + +;;;;;;;;;;;;;;;;;;;;;;;;; +; Paths and Directories ; +;;;;;;;;;;;;;;;;;;;;;;;;; + +; UNIX: "/path1:/path2" +;include_path = ".:/php/includes" +; +; Windows: "\path1;\path2" +;include_path = ".;c:\php\includes" + +; The root of the PHP pages, used only if nonempty. +; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root +; if you are running php as a CGI under any web server (other than IIS) +; see documentation for security issues. The alternate is to use the +; cgi.force_redirect configuration below +doc_root = + +; The directory under which PHP opens the script using /~username used only +; if nonempty. +user_dir = + +; Directory in which the loadable extensions (modules) reside. +extension_dir = "/usr/lib/php/modules" + +; Whether or not to enable the dl() function. The dl() function does NOT work +; properly in multithreaded servers, such as IIS or Zeus, and is automatically +; disabled on them. +enable_dl = On + +; cgi.force_redirect is necessary to provide security running PHP as a CGI under +; most web servers. Left undefined, PHP turns this on by default. You can +; turn it off here AT YOUR OWN RISK +; **You CAN safely turn this off for IIS, in fact, you MUST.** +; cgi.force_redirect = 1 + +; if cgi.nph is enabled it will force cgi to always sent Status: 200 with +; every request. +; cgi.nph = 1 + +; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape +; (iPlanet) web servers, you MAY need to set an environment variable name that PHP +; will look for to know it is OK to continue execution. Setting this variable MAY +; cause security issues, KNOW WHAT YOU ARE DOING FIRST. +; cgi.redirect_status_env = ; + +; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate +; security tokens of the calling client. This allows IIS to define the +; security context that the request runs under. mod_fastcgi under Apache +; does not currently support this feature (03/17/2002) +; Set to 1 if running under IIS. Default is zero. +; fastcgi.impersonate = 1; + +; Disable logging through FastCGI connection +; fastcgi.log = 0 + +; cgi.rfc2616_headers configuration option tells PHP what type of headers to +; use when sending HTTP response code. If it's set 0 PHP sends Status: header that +; is supported by Apache. When this option is set to 1 PHP will send +; RFC2616 compliant header. +; Default is zero. +;cgi.rfc2616_headers = 0 + + +;;;;;;;;;;;;;;;; +; File Uploads ; +;;;;;;;;;;;;;;;; + +; Whether to allow HTTP file uploads. +file_uploads = On + +; Temporary directory for HTTP uploaded files (will use system default if not +; specified). +;upload_tmp_dir = + +; Maximum allowed size for uploaded files. +upload_max_filesize = 200M + + +;;;;;;;;;;;;;;;;;; +; Fopen wrappers ; +;;;;;;;;;;;;;;;;;; + +; Whether to allow the treatment of URLs (like http:// or ftp://) as files. +allow_url_fopen = On + +; Define the anonymous ftp password (your email address) +;from="john@doe.com" + +; Define the User-Agent string +; user_agent="PHP" + +; Default timeout for socket based streams (seconds) +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; auto_detect_line_endings = Off + + +;;;;;;;;;;;;;;;;;;;;;; +; Dynamic Extensions ; +;;;;;;;;;;;;;;;;;;;;;; +; +; If you wish to have an extension loaded automatically, use the following +; syntax: +; +; extension=modulename.extension +; +; For example: +; +; extension=msql.so +; +; Note that it should be the name of the module only; no directory information +; needs to go here. Specify the location of the extension with the +; extension_dir directive above. + + +;;;; +; Note: packaged extension modules are now loaded via the .ini files +; found in the directory /etc/php.d; these are loaded by default. +;;;; + + +;;;;;;;;;;;;;;;;;;; +; Module Settings ; +;;;;;;;;;;;;;;;;;;; + +[Date] +; Defines the default timezone used by the date functions +;date.timezone = + +[Syslog] +; Whether or not to define the various syslog variables (e.g. $LOG_PID, +; $LOG_CRON, etc.). Turning it off is a good idea performance-wise. In +; runtime, you can define these variables by calling define_syslog_variables(). +define_syslog_variables = Off + +[mail function] +; For Win32 only. +SMTP = localhost +smtp_port = 25 + +; For Win32 only. +;sendmail_from = me@example.com + +; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). +sendmail_path = /usr/sbin/sendmail -t -i + +; Force the addition of the specified parameters to be passed as extra parameters +; to the sendmail binary. These parameters will always replace the value of +; the 5th parameter to mail(), even in safe mode. +;mail.force_extra_parameters = + +[SQL] +sql.safe_mode = Off + +[ODBC] +;odbc.default_db = Not yet implemented +;odbc.default_user = Not yet implemented +;odbc.default_pw = Not yet implemented + +; Allow or prevent persistent links. +odbc.allow_persistent = On + +; Check that a connection is still valid before reuse. +odbc.check_persistent = On + +; Maximum number of persistent links. -1 means no limit. +odbc.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +odbc.max_links = -1 + +; Handling of LONG fields. Returns number of bytes to variables. 0 means +; passthru. +odbc.defaultlrl = 4096 + +; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. +; See the documentation on odbc_binmode and odbc_longreadlen for an explanation +; of uodbc.defaultlrl and uodbc.defaultbinmode +odbc.defaultbinmode = 1 + +[MySQL] +; Allow or prevent persistent links. +mysql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mysql.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +mysql.max_links = -1 + +; Default port number for mysql_connect(). If unset, mysql_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +mysql.default_port = + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +;mysql.default_socket = +mysql.default_socket = /tmp/mysql.sock + +; Default host for mysql_connect() (doesn't apply in safe mode). +mysql.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +mysql.default_user = + +; Default password for mysql_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +mysql.default_password = + +; Maximum time (in secondes) for connect timeout. -1 means no limit +mysql.connect_timeout = 60 + +; Trace mode. When trace_mode is active (=On), warnings for table/index scans and +; SQL-Errors will be displayed. +mysql.trace_mode = Off + +[MySQLi] + +; Maximum number of links. -1 means no limit. +mysqli.max_links = -1 + +; Default port number for mysqli_connect(). If unset, mysqli_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +mysqli.default_port = 3306 + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +mysqli.default_socket = + +; Default host for mysql_connect() (doesn't apply in safe mode). +mysqli.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +mysqli.default_user = + +; Default password for mysqli_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +mysqli.default_pw = + +; Allow or prevent reconnect +mysqli.reconnect = Off + +[mSQL] +; Allow or prevent persistent links. +msql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +msql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +msql.max_links = -1 + +[PostgresSQL] +; Allow or prevent persistent links. +pgsql.allow_persistent = On + +; Detect broken persistent links always with pg_pconnect(). +; Auto reset feature requires a little overheads. +pgsql.auto_reset_persistent = Off + +; Maximum number of persistent links. -1 means no limit. +pgsql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +pgsql.max_links = -1 + +; Ignore PostgreSQL backends Notice message or not. +; Notice message logging require a little overheads. +pgsql.ignore_notice = 0 + +; Log PostgreSQL backends Noitce message or not. +; Unless pgsql.ignore_notice=0, module cannot log notice message. +pgsql.log_notice = 0 + +[Sybase] +; Allow or prevent persistent links. +sybase.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybase.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybase.max_links = -1 + +;sybase.interface_file = "/usr/sybase/interfaces" + +; Minimum error severity to display. +sybase.min_error_severity = 10 + +; Minimum message severity to display. +sybase.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +; If on, this will cause PHP to automatically assign types to results according +; to their Sybase type, instead of treating them all as strings. This +; compatability mode will probably not stay around forever, so try applying +; whatever necessary changes to your code, and turn it off. +sybase.compatability_mode = Off + +[Sybase-CT] +; Allow or prevent persistent links. +sybct.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybct.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybct.max_links = -1 + +; Minimum server message severity to display. +sybct.min_server_severity = 10 + +; Minimum client message severity to display. +sybct.min_client_severity = 10 + +[bcmath] +; Number of decimal digits for all bcmath functions. +bcmath.scale = 0 + +[browscap] +;browscap = extra/browscap.ini + +[Informix] +; Default host for ifx_connect() (doesn't apply in safe mode). +ifx.default_host = + +; Default user for ifx_connect() (doesn't apply in safe mode). +ifx.default_user = + +; Default password for ifx_connect() (doesn't apply in safe mode). +ifx.default_password = + +; Allow or prevent persistent links. +ifx.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +ifx.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +ifx.max_links = -1 + +; If on, select statements return the contents of a text blob instead of its id. +ifx.textasvarchar = 0 + +; If on, select statements return the contents of a byte blob instead of its id. +ifx.byteasvarchar = 0 + +; Trailing blanks are stripped from fixed-length char columns. May help the +; life of Informix SE users. +ifx.charasvarchar = 0 + +; If on, the contents of text and byte blobs are dumped to a file instead of +; keeping them in memory. +ifx.blobinfile = 0 + +; NULL's are returned as empty strings, unless this is set to 1. In that case, +; NULL's are returned as string 'NULL'. +ifx.nullformat = 0 + +[Session] +; Handler used to store/retrieve data. +session.save_handler = files + +; Argument passed to save_handler. In the case of files, this is the path +; where data files are stored. Note: Windows users have to change this +; variable in order to use PHP's session functions. +; +; As of PHP 4.0.1, you can define the path as: +; +; session.save_path = "N;/path" +; +; where N is an integer. Instead of storing all the session files in +; /path, what this will do is use subdirectories N-levels deep, and +; store the session data in those directories. This is useful if you +; or your OS have problems with lots of files in one directory, and is +; a more efficient layout for servers that handle lots of sessions. +; +; NOTE 1: PHP will not create this directory structure automatically. +; You can use the script in the ext/session dir for that purpose. +; NOTE 2: See the section on garbage collection below if you choose to +; use subdirectories for session storage +; +; The file storage module creates files using mode 600 by default. +; You can change that by using +; +; session.save_path = "N;MODE;/path" +; +; where MODE is the octal representation of the mode. Note that this +; does not overwrite the process's umask. +;session.save_path = "/var/lib/php/session" +session.save_path = "/tmp" + +; Whether to use cookies. +session.use_cookies = 1 + +; This option enables administrators to make their users invulnerable to +; attacks which involve passing session ids in URLs; defaults to 0. +; session.use_only_cookies = 1 + +; Name of the session (used as cookie name). +session.name = PHPSESSID + +; Initialize session on request startup. +session.auto_start = 1 + +; Lifetime in seconds of cookie or, if 0, until browser is restarted. +session.cookie_lifetime = 0 + +; The path for which the cookie is valid. +session.cookie_path = / + +; The domain for which the cookie is valid. +session.cookie_domain = + +; Handler used to serialize data. php is the standard serializer of PHP. +session.serialize_handler = php + +; Define the probability that the 'garbage collection' process is started +; on every session initialization. +; The probability is calculated by using gc_probability/gc_divisor, +; e.g. 1/100 means there is a 1% chance that the GC process starts +; on each request. + +session.gc_probability = 20 +session.gc_divisor = 1000 + +; After this number of seconds, stored data will be seen as 'garbage' and +; cleaned up by the garbage collection process. +session.gc_maxlifetime = 1440 + +; NOTE: If you are using the subdirectory option for storing session files +; (see session.save_path above), then garbage collection does *not* +; happen automatically. You will need to do your own garbage +; collection through a shell script, cron entry, or some other method. +; For example, the following script would is the equivalent of +; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): +; cd /path/to/sessions; find -cmin +24 | xargs rm + +; PHP 4.2 and less have an undocumented feature/bug that allows you to +; to initialize a session variable in the global scope, albeit register_globals +; is disabled. PHP 4.3 and later will warn you, if this feature is used. +; You can disable the feature and the warning separately. At this time, +; the warning is only displayed, if bug_compat_42 is enabled. + +session.bug_compat_42 = 0 +session.bug_compat_warn = 1 + +; Check HTTP Referer to invalidate externally stored URLs containing ids. +; HTTP_REFERER has to contain this substring for the session to be +; considered as valid. +session.referer_check = + +; How many bytes to read from the file. +session.entropy_length = 0 + +; Specified here to create the session id. +session.entropy_file = + +;session.entropy_length = 16 + +;session.entropy_file = /dev/urandom + +; Set to {nocache,private,public,} to determine HTTP caching aspects +; or leave this empty to avoid sending anti-caching headers. +session.cache_limiter = nocache + +; Document expires after n minutes. +session.cache_expire = 180 + +; trans sid support is disabled by default. +; Use of trans sid may risk your users security. +; Use this option with caution. +; - User may send URL contains active session ID +; to other person via. email/irc/etc. +; - URL that contains active session ID may be stored +; in publically accessible computer. +; - User may access your site with the same session ID +; always using URL stored in browser's history or bookmarks. +session.use_trans_sid = 0 + +; Select a hash function +; 0: MD5 (128 bits) +; 1: SHA-1 (160 bits) +session.hash_function = 0 + +; Define how many bits are stored in each character when converting +; the binary hash data to something readable. +; +; 4 bits: 0-9, a-f +; 5 bits: 0-9, a-v +; 6 bits: 0-9, a-z, A-Z, "-", "," +session.hash_bits_per_character = 5 + +; The URL rewriter will look for URLs in a defined set of HTML tags. +; form/fieldset are special; if you include them here, the rewriter will +; add a hidden field with the info which is otherwise appended +; to URLs. If you want XHTML conformity, remove the form entry. +; Note that all valid entries require a "=", even if no value follows. +url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" + +[MSSQL] +; Allow or prevent persistent links. +mssql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mssql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +mssql.max_links = -1 + +; Minimum error severity to display. +mssql.min_error_severity = 10 + +; Minimum message severity to display. +mssql.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +mssql.compatability_mode = Off + +; Connect timeout +;mssql.connect_timeout = 5 + +; Query timeout +;mssql.timeout = 60 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textlimit = 4096 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textsize = 4096 + +; Limits the number of records in each batch. 0 = all records in one batch. +;mssql.batchsize = 0 + +; Specify how datetime and datetim4 columns are returned +; On => Returns data converted to SQL server settings +; Off => Returns values as YYYY-MM-DD hh:mm:ss +;mssql.datetimeconvert = On + +; Use NT authentication when connecting to the server +mssql.secure_connection = Off + +; Specify max number of processes. -1 = library default +; msdlib defaults to 25 +; FreeTDS defaults to 4096 +;mssql.max_procs = -1 + +; Specify client character set. +; If empty or not set the client charset from freetds.comf is used +; This is only used when compiled with FreeTDS +;mssql.charset = "ISO-8859-1" + +[Assertion] +; Assert(expr); active by default. +;assert.active = On + +; Issue a PHP warning for each failed assertion. +;assert.warning = On + +; Don't bail out by default. +;assert.bail = Off + +; User-function to be called if an assertion fails. +;assert.callback = 0 + +; Eval the expression with current error_reporting(). Set to true if you want +; error_reporting(0) around the eval(). +;assert.quiet_eval = 0 + +[Verisign Payflow Pro] +; Default Payflow Pro server. +pfpro.defaulthost = "test-payflow.verisign.com" + +; Default port to connect to. +pfpro.defaultport = 443 + +; Default timeout in seconds. +pfpro.defaulttimeout = 30 + +; Default proxy IP address (if required). +;pfpro.proxyaddress = + +; Default proxy port. +;pfpro.proxyport = + +; Default proxy logon. +;pfpro.proxylogon = + +; Default proxy password. +;pfpro.proxypassword = + +[COM] +; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs +;com.typelib_file = +; allow Distributed-COM calls +;com.allow_dcom = true +; autoregister constants of a components typlib on com_load() +;com.autoregister_typelib = true +; register constants casesensitive +;com.autoregister_casesensitive = false +; show warnings on duplicate constat registrations +;com.autoregister_verbose = true + +[mbstring] +; language for internal character representation. +;mbstring.language = Japanese + +; internal/script encoding. +; Some encoding cannot work as internal encoding. +; (e.g. SJIS, BIG5, ISO-2022-*) +;mbstring.internal_encoding = EUC-JP + +; http input encoding. +;mbstring.http_input = auto + +; http output encoding. mb_output_handler must be +; registered as output buffer to function +;mbstring.http_output = SJIS + +; enable automatic encoding translation according to +; mbstring.internal_encoding setting. Input chars are +; converted to internal encoding by setting this to On. +; Note: Do _not_ use automatic encoding translation for +; portable libs/applications. +;mbstring.encoding_translation = Off + +; automatic encoding detection order. +; auto means +;mbstring.detect_order = auto + +; substitute_character used when character cannot be converted +; one from another +;mbstring.substitute_character = none; + +; overload(replace) single byte functions by mbstring functions. +; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), +; etc. Possible values are 0,1,2,4 or combination of them. +; For example, 7 for overload everything. +; 0: No overload +; 1: Overload mail() function +; 2: Overload str*() functions +; 4: Overload ereg*() functions +;mbstring.func_overload = 0 + +; enable strict encoding detection. +;mbstring.strict_encoding = Off + +[FrontBase] +;fbsql.allow_persistent = On +;fbsql.autocommit = On +;fbsql.default_database = +;fbsql.default_database_password = +;fbsql.default_host = +;fbsql.default_password = +;fbsql.default_user = "_SYSTEM" +;fbsql.generate_warnings = Off +;fbsql.max_connections = 128 +;fbsql.max_links = 128 +;fbsql.max_persistent = -1 +;fbsql.max_results = 128 +;fbsql.batchSize = 1000 + +[gd] +; Tell the jpeg decode to libjpeg warnings and try to create +; a gd image. The warning will then be displayed as notices +; disabled by default +;gd.jpeg_ignore_warning = 0 + +[exif] +; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. +; With mbstring support this will automatically be converted into the encoding +; given by corresponding encode setting. When empty mbstring.internal_encoding +; is used. For the decode settings you can distinguish between motorola and +; intel byte order. A decode setting cannot be empty. +;exif.encode_unicode = ISO-8859-15 +;exif.decode_unicode_motorola = UCS-2BE +;exif.decode_unicode_intel = UCS-2LE +;exif.encode_jis = +;exif.decode_jis_motorola = JIS +;exif.decode_jis_intel = JIS + +[Tidy] +; The path to a default tidy configuration file to use when using tidy +;tidy.default_config = /usr/local/lib/php/default.tcfg + +; Should tidy clean and repair output automatically? +; WARNING: Do not use this option if you are generating non-html content +; such as dynamic images +tidy.clean_output = Off + +[soap] +; Enables or disables WSDL caching feature. +soap.wsdl_cache_enabled=1 +; Sets the directory name where SOAP extension will put cache files. +soap.wsdl_cache_dir="/tmp" +; (time to live) Sets the number of second while cached file will be used +; instead of original one. +soap.wsdl_cache_ttl=86400 + +; Local Variables: +; tab-width: 4 +; End: diff --git a/omc/config/profile b/omc/config/profile new file mode 100644 index 0000000..5571da1 --- /dev/null +++ b/omc/config/profile @@ -0,0 +1,48 @@ +# /etc/profile + +# System wide environment and startup programs, for login setup +# Functions and aliases go in /etc/bashrc + + +# Path manipulation +if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/sbin" ; then + PATH=/sbin:$PATH +fi + +if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/sbin" ; then + PATH=/usr/sbin:$PATH +fi + +if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/local/sbin" ; then + PATH=/usr/local/sbin:$PATH +fi + +if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then + PATH="$PATH:/usr/X11R6/bin" +fi + +# No core files by default +#ulimit -S -c 0 > /dev/null 2>&1 +ulimit -c unlimited + +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 + +export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC + +for i in /etc/profile.d/*.sh ; do + if [ -r $i ]; then + . $i + fi +done + +unset i +PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/etc/rc.d/init.d" diff --git a/omc/config/rsyncd.conf b/omc/config/rsyncd.conf new file mode 100644 index 0000000..283a113 --- /dev/null +++ b/omc/config/rsyncd.conf @@ -0,0 +1,15 @@ +uid=mysql +gid=mysql +use chroot=no +max connections=4 +pid file=/var/run/rsyncd.pid +lock file=/var/run/rsync.lock +log file=/var/log/rsyncd.log + +[data] +path=/usr/local/mysql/data/ +list=true + +[conf] +path=/usr/local/omc/bin/conf/ +list=true diff --git a/omc/config/server.conf b/omc/config/server.conf new file mode 100644 index 0000000..bbc8f32 --- /dev/null +++ b/omc/config/server.conf @@ -0,0 +1,31 @@ +[host] +omc_master = omc-0 +mysql_master = omc-0 + +omc_slave = omc-1 +mysql_slave = omc-1 + +[master_task] +#processor option +iptrans -d +paraComm -d +subsComm -d +logCollector -d +omcCleaner -d +smcli -d +cdrCollector -d +subsDataBackup -d +ftpSend -d +alarmAgent -d +nrtrde -d +sftpSend -d +cstaCollector -d +[slave_task] +iptrans -d +paraComm -d +subsComm -d +logCollector -d +omcCleaner -d +smcli -d +cdrCollector -d + diff --git a/omc/config/server.crt b/omc/config/server.crt new file mode 100644 index 0000000..404427b --- /dev/null +++ b/omc/config/server.crt @@ -0,0 +1,61 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 2 (0x2) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=CN, ST=Guangdong, L=Shenzhen, O=altobridge, OU=acrd, CN=omc/emailAddress=omc@adc.com + Validity + Not Before: Mar 8 15:10:28 2010 GMT + Not After : Mar 8 15:10:28 2011 GMT + Subject: C=CN, ST=Guangdong, O=altobridge, OU=acrd, CN=emsserver/emailAddress=ems@adc.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (1024 bit) + Modulus (1024 bit): + 00:d2:97:80:bc:58:94:01:44:2c:04:7a:60:7c:12: + 43:25:6c:60:3a:9f:b9:c2:09:f6:3d:63:34:07:45: + 40:3e:f9:45:3c:20:86:35:d7:89:77:22:73:f2:70: + cb:f7:7f:54:a0:16:d4:eb:b2:5c:f2:d1:95:ab:55: + 38:c6:30:46:c6:d0:76:02:0d:a7:e5:9f:49:3f:ee: + 0a:83:b0:9e:c1:61:78:2a:89:c1:67:93:c2:af:85: + 04:f5:61:ee:52:f1:e1:d0:1f:c7:22:80:54:91:1b: + 70:c4:bc:ad:f5:c7:17:a5:b1:cc:b5:71:1e:72:17: + aa:8a:50:37:b5:85:a0:f5:8b + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Netscape Comment: + OpenSSL Generated Certificate + X509v3 Subject Key Identifier: + 09:3E:B8:08:1E:EB:8F:33:B1:E9:F8:88:E6:5C:52:A9:21:9A:2B:D8 + X509v3 Authority Key Identifier: + keyid:C9:72:91:A2:E4:0C:F6:E0:56:4B:6B:CB:B6:51:53:D4:C9:D5:CB:7C + + Signature Algorithm: sha1WithRSAEncryption + 9f:62:1a:23:1b:36:7a:62:95:f5:bd:bc:d4:a7:32:29:37:8d: + 17:55:1a:51:0d:99:c8:93:96:a3:60:ba:b0:92:74:52:41:1f: + bd:dc:35:78:5e:92:ba:61:81:77:76:49:7f:66:73:72:f5:8f: + bc:99:ac:3c:93:da:17:72:8d:9d:9d:74:fd:87:aa:9b:91:4a: + 17:37:49:e2:71:58:1e:2d:ec:5b:ee:49:e7:3b:90:c3:88:76: + f5:59:e8:7e:7f:e7:d3:55:f7:96:a5:9b:04:b9:e2:38:65:b0: + 99:29:14:d1:f2:b9:26:29:74:a1:f5:64:67:84:38:53:b1:ce: + 9e:6d +-----BEGIN CERTIFICATE----- +MIIC6TCCAlKgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UEBhMCQ04x +EjAQBgNVBAgTCUd1YW5nZG9uZzERMA8GA1UEBxMIU2hlbnpoZW4xEzARBgNVBAoT +CmFsdG9icmlkZ2UxDTALBgNVBAsTBGFjcmQxDDAKBgNVBAMTA29tYzEaMBgGCSqG +SIb3DQEJARYLb21jQGFkYy5jb20wHhcNMTAwMzA4MTUxMDI4WhcNMTEwMzA4MTUx +MDI4WjB1MQswCQYDVQQGEwJDTjESMBAGA1UECBMJR3Vhbmdkb25nMRMwEQYDVQQK +EwphbHRvYnJpZGdlMQ0wCwYDVQQLEwRhY3JkMRIwEAYDVQQDEwllbXNzZXJ2ZXIx +GjAYBgkqhkiG9w0BCQEWC2Vtc0BhZGMuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN +ADCBiQKBgQDSl4C8WJQBRCwEemB8EkMlbGA6n7nCCfY9YzQHRUA++UU8IIY114l3 +InPycMv3f1SgFtTrslzy0ZWrVTjGMEbG0HYCDafln0k/7gqDsJ7BYXgqicFnk8Kv +hQT1Ye5S8eHQH8cigFSRG3DEvK31xxelscy1cR5yF6qKUDe1haD1iwIDAQABo3sw +eTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBD +ZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUCT64CB7rjzOx6fiI5lxSqSGaK9gwHwYDVR0j +BBgwFoAUyXKRouQM9uBWS2vLtlFT1MnVy3wwDQYJKoZIhvcNAQEFBQADgYEAn2Ia +Ixs2emKV9b281KcyKTeNF1UaUQ2ZyJOWo2C6sJJ0UkEfvdw1eF6SumGBd3ZJf2Zz +cvWPvJmsPJPaF3KNnZ10/Yeqm5FKFzdJ4nFYHi3sW+5J5zuQw4h29Vnofn/n01X3 +lqWbBLniOGWwmSkU0fK5Jil0ofVkZ4Q4U7HOnm0= +-----END CERTIFICATE----- diff --git a/omc/config/server.csr b/omc/config/server.csr new file mode 100644 index 0000000..5e3fc04 --- /dev/null +++ b/omc/config/server.csr @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIB8zCCAVwCAQAwgYgxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2Rvbmcx +ETAPBgNVBAcTCFNoZW56aGVuMRMwEQYDVQQKEwphbHRvYnJpZGdlMQ0wCwYDVQQL +EwRhY3JkMRIwEAYDVQQDEwllbXNzZXJ2ZXIxGjAYBgkqhkiG9w0BCQEWC2Vtc0Bh +ZGMuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDSl4C8WJQBRCwEemB8 +EkMlbGA6n7nCCfY9YzQHRUA++UU8IIY114l3InPycMv3f1SgFtTrslzy0ZWrVTjG +MEbG0HYCDafln0k/7gqDsJ7BYXgqicFnk8KvhQT1Ye5S8eHQH8cigFSRG3DEvK31 +xxelscy1cR5yF6qKUDe1haD1iwIDAQABoCowEQYJKoZIhvcNAQkCMQQTAmFiMBUG +CSqGSIb3DQEJBzEIEwYxMjM0NTYwDQYJKoZIhvcNAQEFBQADgYEAnL/xEe7QAk8B +QOdb5imoP9KpW/5rGXTpKxbdH7SiiyysE8Qre42cdSfd707JU93ei6vNEqgrv8wA +YTgWnvGRYmDzRFTCtX04CoRprVFhfuPtR0pFCT/aPfX+7oLfP9sS1Dy1dkK82Ivs +S6gf1/rCzhe4HtOPisbDwQtyv7RW6bg= +-----END CERTIFICATE REQUEST----- diff --git a/omc/config/server.key b/omc/config/server.key new file mode 100644 index 0000000..650e936 --- /dev/null +++ b/omc/config/server.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICWwIBAAKBgQDSl4C8WJQBRCwEemB8EkMlbGA6n7nCCfY9YzQHRUA++UU8IIY1 +14l3InPycMv3f1SgFtTrslzy0ZWrVTjGMEbG0HYCDafln0k/7gqDsJ7BYXgqicFn +k8KvhQT1Ye5S8eHQH8cigFSRG3DEvK31xxelscy1cR5yF6qKUDe1haD1iwIDAQAB +AoGAVZfoZiUmeuFHdsZ6otMVYYeMESfMa3Z7E/ZXNkFKXI4aOtcJVab2I2rob3iz +HjQtpCfDgMztBHB1Ab9QpRUIHpeFm5HFs8xv3rA1Z0ZRHjACaVd15ErbL/lO/w4u +e4Tp6CPM1I95kmTm2a32T5Q7AytfS3DJHUKFbGpINN4zUBECQQD3vJ5uDEn/djuw +igGQcQ0rN1kXNC2nx1ubZZEtLj8iymjD9BeMbBI/oAtf9mxmArpBXIMp2Deiy0/x +E2X2s7XpAkEA2Z21oLrMeWAF/4zzEr+lpod2hZ31+gSzKM24mIhvMXZd0W5C+HZe +rXD++WZvuRwnFs3zU95dezzAEZ2ztRlDUwJADKfiIBUYoqhTnE0wj0R3O8H0Fy9f +NbcFgwbJR9mY+BoHCBusKExNElsGubxJBV0WTsh/GuAk13gzeUlYaCX+IQJAKR4q +dl81SW3CVGHuf8lkZE3OMDsDgiUnMPuF+JQ25lKmMW8zCj1bcEwccUVQsNpH7IAn +jN5ELYfyBqIUlZBbbwJATpp3YTito8bYKyX6vTtuKRARSzxz7PY7lcwT5MiobIk+ +oHubU8eSARm9vDGqgZU4vFNcLjhTlTRuIynr4Gm4Pw== +-----END RSA PRIVATE KEY----- diff --git a/omc/config/snmp.conf b/omc/config/snmp.conf new file mode 100644 index 0000000..e83534c --- /dev/null +++ b/omc/config/snmp.conf @@ -0,0 +1,19 @@ +[version-3] +[engine-2] +engineType=0 +securityLevel=3 +userName=pierre +authPassword=maplesyrup +privacyPassword=maplesyrup +engineID=00000063000000A19BE2CAC5 +contextName= + +[engine-3] +engineType=1 +securityLevel=3 +userName=pierre +authPassword=maplesyrup +privacyPassword=maplesyrup +engineID=00000063000000A19BE2CAC5 +contextName= +contextEngineID= diff --git a/omc/plat/.copyarea.db b/omc/plat/.copyarea.db new file mode 100644 index 0000000..7bc0e0c --- /dev/null +++ b/omc/plat/.copyarea.db @@ -0,0 +1,29 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat +2 +19 +4:smpp|2|0|0|0|fc296eabbfa511dc866b001c23e19543|0 +4:isup|2|0|0|0|e6696767bfa411dc852a001c23e19543|0 +7:iptrans|2|0|0|0|d51966f0bfa411dc851a001c23e19543|0 +a:lost+found|2|0|0|0|63d949bbbfa011dc819a001c23e19543|0 +4:mtp3|2|0|0|0|49e96a03bfa511dc85a0001c23e19543|0 +4:xapp|2|0|0|0|3859703cbfa611dc86a4001c23e19543|0 +6:public|2|0|0|0|59696a6bbfa511dc85ad001c23e19543|0 +4:snmp|2|0|0|0|1e196f91bfa611dc868f001c23e19543|0 +4:isdn|2|0|0|0|fe87fa67808c11dd88a4001c23e19543|0 +6:haepub|2|0|0|0|ce8966c5bfa411dc8515001c23e19543|0 +3:sip|2|0|0|0|d437f94b808c11dd889f001c23e19543|0 +6:mgc_v2|2|0|0|0|7730c1eca0da11dd9cdb001c23e19543|0 +4:bicc|2|0|0|0|952644599a8511dd8b36001c23e19543|0 +4:mgcp|2|0|0|0|3cc969a9bfa511dc8595001c23e19543|0 +4:sccp|2|0|0|0|5e18819ac44711dc962e001c23e19543|0 +5:debug|2|0|0|0|c899669dbfa411dc8511001c23e19543|0 +4:tcap|2|0|0|0|2bd96fecbfa611dc869a001c23e19543|0 +3:mgc|2|0|0|0|30496955bfa511dc8589001c23e19543|0 +4:8ecp|2|0|0|0|a4d965b7bfa411dc84ed001c23e19543|0 +3:pal|2|0|0|0|731472cf6cf311dd91c7001c23e19543|0 +5:mgcv2|2|0|0|0|da0645189a8a11dd8b34001c23e19543|0 +4:m2ua|2|0|0|0|fb3967f0bfa411dc8544001c23e19543|0 +3:rtp|2|0|0|0|89b96bacbfa511dc85d9001c23e19543|0 +3:scf|2|0|0|0|f2996e6fbfa511dc8664001c23e19543|0 +3:aif|2|0|0|0|840d286ec9bd11dc8b49001c23e19543|0 diff --git a/omc/plat/8ecp/.copyarea.db b/omc/plat/8ecp/.copyarea.db new file mode 100644 index 0000000..2670287 --- /dev/null +++ b/omc/plat/8ecp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\8ecp +2 +5 +3:doc|2|0|0|0|a56965d3bfa411dc84ed001c23e19543|0 +2:ut|2|0|0|0|a99966cfbfa411dc84ed001c23e19543|0 +3:src|2|0|0|0|a6996627bfa411dc84ed001c23e19543|0 +8:Makefile|1|11d70a3d83e|b3e|1818c81f|a609660bbfa411dc84ed001c23e19543|0 +3:lib|2|0|0|0|a56965efbfa411dc84ed001c23e19543|0 diff --git a/omc/plat/8ecp/Makefile b/omc/plat/8ecp/Makefile new file mode 100644 index 0000000..e1f1687 --- /dev/null +++ b/omc/plat/8ecp/Makefile @@ -0,0 +1,96 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module Version : V1.4 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/06/18 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + + + +MODULE = 8ecp +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + +PLT_LIB = public debug iptrans snmp mtp3 +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules + diff --git a/omc/plat/8ecp/lib/lib8ecp.a b/omc/plat/8ecp/lib/lib8ecp.a new file mode 100644 index 0000000..8c6141e Binary files /dev/null and b/omc/plat/8ecp/lib/lib8ecp.a differ diff --git a/omc/plat/8ecp/obj/8ecp.o b/omc/plat/8ecp/obj/8ecp.o new file mode 100644 index 0000000..691c92c Binary files /dev/null and b/omc/plat/8ecp/obj/8ecp.o differ diff --git a/omc/plat/8ecp/obj/8ecp_debug.o b/omc/plat/8ecp/obj/8ecp_debug.o new file mode 100644 index 0000000..954e232 Binary files /dev/null and b/omc/plat/8ecp/obj/8ecp_debug.o differ diff --git a/omc/plat/8ecp/src/.copyarea.db b/omc/plat/8ecp/src/.copyarea.db new file mode 100644 index 0000000..ef0b6cc --- /dev/null +++ b/omc/plat/8ecp/src/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\8ecp\src +2 +3 +c:8ecp_debug.c|1|11d70a3d909|1e8c|adf63b13|a8696697bfa411dc84ed001c23e19543|0 +6:8ecp.c|1|11d70a3d957|201f|3c43c25e|a8f966b3bfa411dc84ed001c23e19543|0 +7:include|2|0|0|0|a6996643bfa411dc84ed001c23e19543|0 diff --git a/omc/plat/8ecp/src/8ecp.c b/omc/plat/8ecp/src/8ecp.c new file mode 100644 index 0000000..1c8f237 --- /dev/null +++ b/omc/plat/8ecp/src/8ecp.c @@ -0,0 +1,288 @@ +#include "./include/8ecp.h" +#include +#include +#include "./include/8ecp_debug.h" + +SAP_In_8ECP SAPIn8ECP; +//time_t t[_8KE1_NUM]; //save the time when the heartbeat message of a 8KE1 was received. +BYTE s_msg[128]; +Card_Struct card_struct[_8KE1_NUM]; +int _8ecp_bind (_8ECP_SAP * sap) +{ + if (SAPIn8ECP.inUse == InUse) + { + perror ("unable to bind a SAP, because the SAP is in use."); + return -1; + } + else //If bind successful, save the user name and the functions + { + SAPIn8ECP.inUse = InUse; + strcpy (SAPIn8ECP._8ecp_sap.name, (*sap).name); + SAPIn8ECP._8ecp_sap.update_mg_status = sap->update_mg_status; + SAPIn8ECP._8ecp_sap.update_trk_status = sap->update_trk_status; + return 0; + } +} +int _8ecp_unbind (BYTE sapIndex) +{ + if (sapIndex != 0) + { + perror ("unable to unbind the SAP, because the SAP is not in use"); + return -1; + } + else //If unbind successful, set the default value of SAPIn8ECP + { + SAPIn8ECP.inUse = NotInUse; + memset (SAPIn8ECP._8ecp_sap.name, 0, + strlen (SAPIn8ECP._8ecp_sap.name)); + SAPIn8ECP._8ecp_sap.update_mg_status = NULL; + SAPIn8ECP._8ecp_sap.update_trk_status = NULL; + return 0; + } +} + +int _8ecp_createMG(WORD mgNo, DWORD ip, BYTE cardNo) +{ + card_struct[cardNo].mgNo = mgNo; + card_struct[cardNo].ip = ip; + return 1; +} + + +int _8ecp_deleteMG(WORD mgNo, DWORD ip, BYTE cardNo) +{ + if(card_struct[cardNo].ip != ip) + { + printf("the ip is not correct, in 8ecp the ip of card %d is: %ld\n", cardNo, card_struct[cardNo].ip); + return 0; + } + if(card_struct[cardNo].mgNo != mgNo) + { + printf("the mgNo is not correct, in 8ecp the mgNo of card %d is: %d\n", cardNo, card_struct[cardNo].mgNo); + return 0; + } + card_struct[cardNo].ip = 0;; + card_struct[cardNo].mgNo = 0; + return 1; +} + + +/* +calcurate the IP address where the 8ECP PDU will be sent to +*/ +struct sockaddr_in getIP (WORD orgChnl) +{ + //char ip3, ip[16]; + //WORD mgNo; + BYTE cardNo; + struct sockaddr_in s; + /* ip3 = orgChnl / 256; //the ID of the 8KE1 + sprintf (ip, "172.18.%d.1", ip3); + */ + cardNo = orgChnl / 256; + memset (&s, 0, sizeof (struct sockaddr)); + s.sin_family = AF_INET; + s.sin_port = htons (PORT); + s.sin_addr.s_addr = card_struct[cardNo].ip; + bzero (&(s.sin_zero), 8); + return s; +} +void _8ecp_connect_chnl (WORD orgChnl, WORD dstChnl, BYTE ecDisable) +{ + //int i; + DWORD tempip; + _8ECP_PDU _8ecp_pdu; + message_list msg_list; + struct sockaddr_in sin_addr; + BYTE temstr[15]; + if (!SAPIn8ECP.inUse) + { + perror ("SAP is not bind!"); + return; + } + sin_addr = getIP (orgChnl); + memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU)); + _8ecp_pdu.CPC_IFA_Inf = 0x87; + if (ecDisable == 0) + _8ecp_pdu.type = 0; + else if (ecDisable == 1) + _8ecp_pdu.type = 06; + else + { + perror ("the value of ecDisable is error!"); + return; + } + _8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1 + _8ecp_pdu.dstModuleID = dstChnl / 256; + _8ecp_pdu.dstTimeSlotNo = dstChnl % 256; + msg_list.msgSrcPort = PORT; + msg_list.msgDstIP = sin_addr.sin_addr.s_addr; + tempip = ntohl(msg_list.msgDstIP); + msg_list.msgDstPort = PORT; + msg_list.msgLength = sizeof (_8ecp_pdu); + memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength); + memcpy(&temstr,&_8ecp_pdu, msg_list.msgLength); + log_procedure(0, temstr); //0:Send msg 1:recv msg + iptrPutMessage (msg_list); +} +void _8ecp_connect_dtmf (WORD orgChnl, WORD dstChnl, BYTE dtmfNo) +{ + struct sockaddr_in sin_addr; + //int i; + BYTE temstr[15]; + _8ECP_PDU _8ecp_pdu; + message_list msg_list; + if (!SAPIn8ECP.inUse) + { + perror ("SAP is not bind!"); + return; + } + sin_addr = getIP (orgChnl); + memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU)); + _8ecp_pdu.CPC_IFA_Inf = 0x87; + _8ecp_pdu.type = 03; + _8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1 + _8ecp_pdu.dstModuleID = dstChnl / 256; + _8ecp_pdu.dstTimeSlotNo = dstChnl % 256; + _8ecp_pdu.Value = dtmfNo; + msg_list.msgSrcPort = PORT; + msg_list.msgDstIP = sin_addr.sin_addr.s_addr; + msg_list.msgDstPort = PORT; + msg_list.msgLength = sizeof (_8ecp_pdu); + memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength); + memcpy(&temstr, &_8ecp_pdu, msg_list.msgLength); + log_procedure(0, temstr); + iptrPutMessage (msg_list); +} +void _8ecp_connect_tone (WORD orgChnl, WORD dstChnl, BYTE toneNo, WORD duration) +{ + struct sockaddr_in sin_addr; + //int i; + BYTE temstr[15]; + _8ECP_PDU _8ecp_pdu; + message_list msg_list; + sin_addr = getIP (orgChnl); + if (!SAPIn8ECP.inUse) + { + perror ("SAP is not bind!"); + return; + } + sin_addr = getIP (orgChnl); + memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU)); + _8ecp_pdu.CPC_IFA_Inf = 0x87; + _8ecp_pdu.type = 2; + _8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1 + _8ecp_pdu.dstModuleID = dstChnl / 256; + _8ecp_pdu.dstTimeSlotNo = dstChnl % 256; + _8ecp_pdu.Value = toneNo; + _8ecp_pdu.duration = duration; + msg_list.msgSrcPort = PORT; + msg_list.msgDstIP = sin_addr.sin_addr.s_addr; + msg_list.msgDstPort = PORT; + msg_list.msgLength = sizeof (_8ecp_pdu); + memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength); + memcpy(&temstr, &_8ecp_pdu, msg_list.msgLength); + log_procedure(0, temstr); + iptrPutMessage (msg_list); +} +void _8ecp_timer () +{ + + _8ecp_mon (); +} +int trap_proc (BYTE oid_len, DWORD * oid_ptr, BYTE * pdata, BYTE msg_len, + snmp_addr * addr) +{ + DWORD * oid_in; + WORD mgNo; + BYTE cardNo; + BYTE temstr[128]; + //int i, index; + //time_t now; + if(oid_ptr[10] != 1) + return 0; + if(oid_ptr[11] != 1) + return 0; + if(oid_ptr[12] != 4) + return 0; + + log_procedure(1, pdata); + + memset(&temstr, 0, sizeof(temstr)); + oid_in = oid_ptr + OID_Prefix; + cardNo = E1NumOnCSU * pdata[0] + pdata[1]; + mgNo = card_struct[cardNo].mgNo; + if ((SAPIn8ECP._8ecp_sap.update_mg_status == NULL)||(mgNo == 0)) + return 0; + else + SAPIn8ECP._8ecp_sap.update_mg_status (mgNo, 1); + if ((SAPIn8ECP._8ecp_sap.update_trk_status == NULL) || (mgNo ==0)) + return 0; + else + { + { + if(pdata[25]&0x01) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 0, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 0, 0); //trk on MG is nok + } + { + if(pdata[25]&0x02) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 1, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 1, 0); //trk on MG is nok + } + { + if(pdata[25]&0x04) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 2, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 2, 0); //trk on MG is nok + } + { + if(pdata[25]&0x08) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 3, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 3, 0); //trk on MG is nok + } + { + if(pdata[25]&0x10) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 4, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 4, 0); //trk on MG is nok + } + { + if(pdata[25]&0x20) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 5, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 5, 0); //trk on MG is nok + } + { + if(pdata[25]&0x40) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 6, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 6, 0); //trk on MG is nok + } + { + if(pdata[25]&0x80) + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 7, 1); //trk on MG is nok + else + SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 7, 0); //trk on MG is nok + } + } + return 0; +} +void _8ecp_init () +{ + printf ("8ECP init start!\n"); + SAPIn8ECP.inUse = NotInUse; + memset (SAPIn8ECP._8ecp_sap.name, 0, sizeof (SAPIn8ECP._8ecp_sap.name)); + SAPIn8ECP._8ecp_sap.update_mg_status = NULL; + SAPIn8ECP._8ecp_sap.update_trk_status = NULL; + //memset (&t, 0, sizeof (t)); + memset(&card_struct, 0, sizeof(Card_Struct)); + _8ecp_debug_set (); + inquire_trapmsg ((void *) trap_proc); //register, get heartbeat msg + printf ("8ECP init complete!\n"); +} + + diff --git a/omc/plat/8ecp/src/8ecp_debug.c b/omc/plat/8ecp/src/8ecp_debug.c new file mode 100644 index 0000000..da966f5 --- /dev/null +++ b/omc/plat/8ecp/src/8ecp_debug.c @@ -0,0 +1,352 @@ +#include "./include/8ecp.h" + +#define _8ECP_DEBUG_ID 20 +#define _8ECP_VER_DEBUG "R9V0_01p1" + + +BYTE _8ecp_asciin_buf[MAX_ASCIIIN_LEN]; +BYTE _8ecp_asciout_buf[MAX_ASCIIOUT_LEN]; +WORD monitor_flag; +BYTE _8ecp_sg_mon_flag[MAX_MG_NO]; +BYTE _8ecp_trk_mon_flag[MAX_TRK_NO]; +BYTE _8ecp_chl_mon_flag[MAX_CHL_NO]; + +BYTE tempstr[128]; +BYTE tempstr1[256]; +static BYTE log_help[] = {"8ECP Debug Monitor Help:\n\r\ +1.[help]\n\r\ +2.[log all/none]\n\r\ +3.[log error on/off]\n\r\ +4.[log mg -mg_no on/off]\n\r\ +5.[log trk -mg_no -trk_no on/off]\n\r\ +6.[log chl -mg_no -trk_no -chnl_no on/off]\n\r\n\r"}; + +static WORD disp_page[128]; +static BYTE *disp_ptr = (BYTE *) disp_page; + +static DWORD debug_status_id[20] = + {1,3,6,1,4,1,1373,1,1,2,3,1,2, _8ECP_DEBUG_ID + 2, 1}; +static BYTE debug_status = 1; + +static DWORD debug_name_id[20] = + {1,3,6,1,4,1,1373,1,1,2,3,1,2,_8ECP_DEBUG_ID + 2,2}; + +static DWORD debug_ascin_id[20] = + {1, 3, 6, 1, 4, 1, 1373, 1, 1, 2, 3, 1, 2, _8ECP_DEBUG_ID + 2, 3}; + +static DWORD debug_ascout_id[20] = + {1, 3, 6, 1, 4, 1, 1373, 1, 1, 2, 3, 1, 2, _8ECP_DEBUG_ID + 2, 4}; + +static DWORD debug_page_title[20] = + {1,3,6,1,4,1,1373,1,1,2,3,1,2,_8ECP_DEBUG_ID + 2,1,1}; + +static DWORD debug_page_line[20] = + {1,3,6,1,4,1,1373,1,1,2,3,1,2,_8ECP_DEBUG_ID + 2, 1,2,1}; + +static BYTE title1_p[] = +{ + " 8ECP Page\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Message Info\n\r\ +"}; + +BYTE _8ecp_disp_line(BYTE page, BYTE line) +{ + BYTE disp_length; + disp_length = 16; + disp_ptr = (BYTE *) disp_page; + switch (page) + { + case 1: + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + { + if(tempstr != NULL) + disp_ptr = (BYTE *)tempstr; + } + + break; + default: + disp_length = 0; + break; + } + return disp_length; +} + +void _8ecp_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + debug_page_line[PAGE_POINT] = page + 5; + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = _8ecp_disp_line(page, disp_line); + debug_page_line[LINE_POINT] = disp_line + 2; + debug_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + + +int _8ecp_asciout_proc (BYTE * out_ptr) +{ + int out_len; + out_len = strlen (out_ptr); + if (out_len + strlen (_8ecp_asciout_buf) > MAX_ASCIIOUT_LEN - 2) + { + strcpy (_8ecp_asciout_buf, out_ptr); + } + else + { + strcat (_8ecp_asciout_buf, out_ptr); + } + return 1; +} +int _8ecp_debug_set (void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + bzero(disp_page,128); + ptr = data; + bzero(_8ecp_sg_mon_flag,MAX_MG_NO); + bzero(_8ecp_trk_mon_flag,MAX_TRK_NO); + bzero(_8ecp_chl_mon_flag,MAX_CHL_NO); + bzero(tempstr, 40); + + debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(BASE_ID_LEN, debug_name_id, _8ECP_VER_DEBUG, 10); + debug_set_response (BASE_ID_LEN, debug_ascin_id, _8ecp_asciin_buf, 4096); + debug_set_response (BASE_ID_LEN, debug_ascout_id, _8ecp_asciout_buf, 4096); + + for (page = 1; page < 2; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + default: + break; + } + + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + _8ecp_disp_page(page); + } + return 1; +} + +void log_procedure(BYTE flag, BYTE* tempstr) +{ + int i; + if(flag == 0) + { + for(i = 0; i < 15; i ++) + sprintf(&tempstr1[3*i], " %02x",tempstr[i]); + } + else if(flag == 1) + { + for(i = 0; i < 41; i ++) + sprintf(&tempstr1[3*i], " %02x",tempstr[i]); + } + if(monitor_flag == MONITOR_ALL) + { + if(flag == 0) + { + _8ecp_asciout_proc("\33[32mSend:\33[0m"); + _8ecp_asciout_proc(tempstr1); + _8ecp_asciout_proc("\n"); + } + else if(flag == 1) + { + _8ecp_asciout_proc("\33[33mReceive:\33[0m"); + _8ecp_asciout_proc(tempstr1); + _8ecp_asciout_proc("\n"); + } + } + else + { + if(flag == 1) + { + for(i = 0; i < MAX_MG_NO; i ++) + { + if(_8ecp_sg_mon_flag[i] == 1) + { + if(tempstr[11] == i) + _8ecp_asciout_proc(tempstr); + } + } + for(i = 0; i < MAX_TRK_NO; i++) + { + if(_8ecp_trk_mon_flag[i] == 1) + if(tempstr[12] / 32 == i) + _8ecp_asciout_proc(tempstr); + } + for(i = 0; i < MAX_CHL_NO; i++) + { + if(_8ecp_chl_mon_flag[i] == 1) + if(tempstr[12] == i) + _8ecp_asciout_proc(tempstr); + } + } + } +} + + +void _8ecp_mon (void) +{ + WORD str_len; + BYTE * ascii_in_ptr = NULL; + BYTE * tmpStr; + DWORD mgNo = 0, trkNo = 0, chlNo = 0; + BYTE error_flag = 0; + if ((str_len = strlen (_8ecp_asciin_buf)) > 0) + { + ascii_in_ptr = _8ecp_asciin_buf + 1; + if (strcmp (ascii_in_ptr, "log all") == 0) + { + monitor_flag = MONITOR_ALL; + } + else if (strcmp (ascii_in_ptr, "log none") == 0) + { + monitor_flag = MONITOR_NONE; + } + else if (strcmp (ascii_in_ptr, "help") == 0) + { + _8ecp_asciout_proc (log_help); + } + else if (strcmp (ascii_in_ptr, "log error on") == 0) + { + monitor_flag = MONITOR_ERROR_ON; + } + else if (strcmp (ascii_in_ptr, "log error off") == 0) + { + monitor_flag = MONITOR_ERROR_OFF; + } + else if ((strstr (ascii_in_ptr, "log mg")) != NULL) + { + if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul (tmpStr + 1, NULL, 10); + if (mgNo >= 0 && mgNo <= 31) + { + if (strstr (ascii_in_ptr, "on") != NULL) + { + _8ecp_sg_mon_flag[mgNo] = 1; + } + else if (strstr (ascii_in_ptr, "off") != NULL) + { + _8ecp_sg_mon_flag[mgNo] = 0; + } + } + else + error_flag = 1; //the format of command is error + } + else + error_flag = 1; + } + else if (strstr (ascii_in_ptr, "log trk")) + { + if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul (tmpStr + 1, NULL, 10); + if (mgNo >= 0 && mgNo <= 31) + { + while (*++tmpStr != '\0') //get the next char '-' + { + if (*tmpStr == '-') + { + trkNo = strtoul (tmpStr + 1, NULL, 10); + if (trkNo >= 0 && trkNo <= 7) + { + if (strstr (tmpStr, "on") != NULL) + { + _8ecp_trk_mon_flag[mgNo * 8 + trkNo] = 1; + } + else if (strstr (tmpStr, "off") != NULL) + { + _8ecp_trk_mon_flag[mgNo * 8 + trkNo] = 0; + } + } + else + error_flag = 1; + break; + } + } + + } + else + error_flag = 1; + } + else + error_flag = 1; + } + else if (strstr (ascii_in_ptr, "log chl")) + { + if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul (tmpStr + 1, NULL, 10); + if (mgNo >= 0 && mgNo <= 31) + { + while (*++tmpStr != '\0') //get the next char '-' + { + if (*tmpStr == '-') + { + trkNo = strtoul (tmpStr + 1, NULL, 10); + if (trkNo >= 0 && trkNo <= 7) + { + while (*++tmpStr != '\0') //get the next char '-' + { + if (*tmpStr == '-') + { + chlNo = strtoul (tmpStr + 1, NULL, 10); + if (chlNo >= 0 && chlNo <= 31) + { + if (strstr (tmpStr, "on") != NULL) + { + _8ecp_chl_mon_flag[mgNo * 8 * 32 + chlNo] = 1; + } + + else if (strstr (tmpStr, "off") != NULL) + { + _8ecp_chl_mon_flag[mgNo * 8 * 32 + chlNo] = 0; + } + } + + else + error_flag = 1; + break; + } + } + break; + } + else + error_flag = 1; + } + } + } + else + error_flag = 1; + } + else + { + error_flag = 1; + } + } + else + error_flag = 1; + + if (error_flag == 0) + _8ecp_asciout_proc("Command OK!\n\r"); + else + _8ecp_asciout_proc("Command Error!\n\r"); + + strcpy (_8ecp_asciin_buf, "\0"); + } + +} diff --git a/omc/plat/8ecp/src/include/.copyarea.db b/omc/plat/8ecp/src/include/.copyarea.db new file mode 100644 index 0000000..fe3eb84 --- /dev/null +++ b/omc/plat/8ecp/src/include/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\8ecp\src\include +2 +2 +c:8ecp_debug.h|1|11d70a3da32|29d|7b16c4f9|a7c9667bbfa411dc84ed001c23e19543|0 +6:8ecp.h|1|11d70a3d9f3|db8|3029f304|a739665fbfa411dc84ed001c23e19543|0 diff --git a/omc/plat/8ecp/src/include/8ecp.h b/omc/plat/8ecp/src/include/8ecp.h new file mode 100644 index 0000000..150ee8d --- /dev/null +++ b/omc/plat/8ecp/src/include/8ecp.h @@ -0,0 +1,149 @@ +#ifndef _8ECP__H +#define _8ECP__H + +#include +#include +#include +#include +#include +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" +#include "../../../iptrans/src/include/iptrans.h" +#include "../../../snmp/src/include/snmp.h" +#include "../../../debug/src/include/debug.h" + +#include "./8ecp_debug.h" + +extern BYTE s_msg[128]; + +#ifndef _8ECP_MAX_USER_NAME_LEN +#define _8ECP_MAX_USER_NAME_LEN 100 +#endif + +#ifndef _8KE1_NUM +#define _8KE1_NUM 32 +#endif + +#ifndef MAX_DELAY +#define MAX_DELAY 1 //the max delay time of heartbeat message +#endif + + +#ifndef PORT +#define PORT 4950 +#endif + +#ifndef OID_Prefix +#define OID_Prefix 8 +#endif + +#ifndef InUSE +#define InUse 1 +#endif + +#ifndef NotInUse +#define NotInUse 0 +#endif + +#ifndef TrkStartIndex +#define TrkStartIndex 8 //the first index of trkno in the heartbeat msg +#endif + +#ifndef E1NumOnCSU +#define E1NumOnCSU 16 +#endif + +#ifndef _T_BYTE +#define _T_BYTE +typedef unsigned char BYTE; +#endif + +#ifndef _T_WORD +#define _T_WORD +typedef unsigned short WORD; +#endif + +#ifndef _T_DWORD +#define _T_DWORD +typedef unsigned int DWORD; +#endif + + +typedef struct _8ECP_SAP +{ +char name[_8ECP_MAX_USER_NAME_LEN]; + +//8ECP module will use these callback functions to update 8E1 MG and trunk status +//Return 0 if success, return -1 if failure +int (*update_mg_status)(BYTE mgNo, BYTE status); +int (*update_trk_status)(BYTE mgNo, BYTE trkNo, BYTE status); + +}_8ECP_SAP; + + +typedef struct _8ECP_PDU //the message send to IPTRANS +{ + BYTE reserved; + BYTE lenInd; + BYTE CPC_IFA_Inf; //fixed value 0x87 + BYTE dstRef[2]; + BYTE reserved1; + BYTE sourceRef[2]; + BYTE reserved2; + BYTE type; //00=connect time slot with echo + //01=connect ack + //02=connect tone + //03=connect DTMF + //04=connect group + //05=disconnect group + //06=connect time slot without echo + BYTE sourceTimeSlotNo; + BYTE dstModuleID; + BYTE dstTimeSlotNo; + BYTE Value; /*when type=02, + 0=tone#0, 1=tone#1, 2=tone#2, 3=tone#3, + 4=tone#4, 5=tone#5/,6=tone#6, 7=tone#7 + + when type=03 + 0=DTMF1, 1=DTMF2, 2=DTMF3, 3=DTMF4, + 4=DTMF5, 5=DTMF6, 6=DTMF7, 7=DTMF8, + 8=DTMF9, 9=DTMF0, 10=DTMF*, 11=DTMF# + + */ + + BYTE duration; + + +}_8ECP_PDU; + + +// the struct of SAP in 8ecp +typedef struct _SAP_In_8ECP +{ + BYTE inUse; + _8ECP_SAP _8ecp_sap; +}SAP_In_8ECP; + +// the struct of MG in 8ecp +typedef struct Card_Struct +{ +// WORD mgNo; + DWORD ip; + BYTE mgNo; +}Card_Struct; + + + +//8ecp interface +int _8ecp_bind(_8ECP_SAP *sap); +int _8ecp_unbind(BYTE sapIndex); + +int _8ecp_createMG(WORD mgNo, DWORD ip, BYTE cardNo); //create or update MG +int _8ecp_deleteMG(WORD mgNo, DWORD ip, BYTE cardNo); //delete MG + +void _8ecp_connect_chnl(WORD orgChnl, WORD dstChnl, BYTE ecDisable); //ecDisable:0/1=enable/disable echo canceller +void _8ecp_connect_dtmf(WORD orgChnl, WORD dstChnl, BYTE dtmfNo); +void _8ecp_connect_tone(WORD orgChnl, WORD dstChnl, BYTE toneNo, WORD duration); +void _8ecp_init(); //called in the main program during initialization stage +void _8ecp_timer(); //called every 10ms in the main program +#endif diff --git a/omc/plat/8ecp/src/include/8ecp_debug.h b/omc/plat/8ecp/src/include/8ecp_debug.h new file mode 100644 index 0000000..a6f93b2 --- /dev/null +++ b/omc/plat/8ecp/src/include/8ecp_debug.h @@ -0,0 +1,33 @@ +#ifndef _8ECP_DEBUG_H +#define _8ECP_DEBUG_H + +#define BASE_ID_LEN 15 +#define PAGE_POINT 14 +#define LINE_POINT 15 +#define MAX_ASCIIIN_LEN 4096 +#define MAX_ASCIIOUT_LEN 4096 +#define MONITOR_ERROR_OFF 3 +#define MONITOR_ERROR_ON 2 +#define MONITOR_ALL 1 +#define MONITOR_NONE 0 +#define MAX_MG_NO 32 +#define MAX_TRK_NO MAX_MG_NO * 8 +#define MAX_CHL_NO MAX_TRK_NO * 32 + +#ifndef _T_BYTE +#define _T_BYTE +typedef unsigned char BYTE; +#endif + +#ifndef _T_WORD +#define _T_WORD +typedef unsigned short WORD; +#endif + + + +int _8ecp_debug_set(void); +int _8ecp_asciout_proc(BYTE* out_ptr); +void _8ecp_mon(void); +void log_procedure(BYTE flag, BYTE* tempstr); +#endif diff --git a/omc/plat/aif/.copyarea.db b/omc/plat/aif/.copyarea.db new file mode 100644 index 0000000..c438c34 --- /dev/null +++ b/omc/plat/aif/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\aif +2 +5 +3:doc|2|0|0|0|5eb881a3c44711dc962f001c23e19543|0 +2:ut|2|0|0|0|624881bac44711dc9633001c23e19543|0 +3:src|2|0|0|0|598baa37051f11dd8b58001c23e19543|0 +8:Makefile|1|11d70a3daed|b57|6a82d06f|ab596627bfa411dc84f1001c23e19543|0 +3:lib|2|0|0|0|ab59660bbfa411dc84f1001c23e19543|0 diff --git a/omc/plat/aif/Makefile b/omc/plat/aif/Makefile new file mode 100644 index 0000000..e56b564 --- /dev/null +++ b/omc/plat/aif/Makefile @@ -0,0 +1,95 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module Version : V1.4 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/06/18 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + + + +MODULE = aif +TYPE = plat + +DBUG_FLAGS_ADD = -D_AIFG_DEBUG_ +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + +PLT_LIB = cunit public debug iptrans snmp mtp3 sccp +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../app + +OBJ_ADD = +TEST_OBJ_PATH = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = yes +COVER_REPORT_PATH = ./ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/aif/doc/.copyarea.db b/omc/plat/aif/doc/.copyarea.db new file mode 100644 index 0000000..7c2da95 --- /dev/null +++ b/omc/plat/aif/doc/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\aif\doc +2 +1 +10:release_note.txt|1|11d70a3dbb8|15b|92ef5818|6d988209c44711dc963f001c23e19543|0 diff --git a/omc/plat/aif/doc/release_note.txt b/omc/plat/aif/doc/release_note.txt new file mode 100644 index 0000000..8934476 --- /dev/null +++ b/omc/plat/aif/doc/release_note.txt @@ -0,0 +1,21 @@ +ACRD Software Module Release Notes + +Module Name: AIFG + +#---------------------------------------------- +[Version] + R9V0_05P2 +[Release Date] + 2008-1-8 +[Author] + Roy Jiang +[Changes] + Bug fixed: + 1.NA + Improvements: + 1.NA + New features: + 1.NA +[Remark] + 1.Initial Clearcase release +#---------------------------------------------- \ No newline at end of file diff --git a/omc/plat/aif/lib/libaif.a b/omc/plat/aif/lib/libaif.a new file mode 100644 index 0000000..8c09235 Binary files /dev/null and b/omc/plat/aif/lib/libaif.a differ diff --git a/omc/plat/aif/obj/aifg.o b/omc/plat/aif/obj/aifg.o new file mode 100644 index 0000000..ee0588c Binary files /dev/null and b/omc/plat/aif/obj/aifg.o differ diff --git a/omc/plat/aif/obj/aifg_csta.o b/omc/plat/aif/obj/aifg_csta.o new file mode 100644 index 0000000..c4b2c42 Binary files /dev/null and b/omc/plat/aif/obj/aifg_csta.o differ diff --git a/omc/plat/aif/obj/aifg_debug.o b/omc/plat/aif/obj/aifg_debug.o new file mode 100644 index 0000000..f93f0b4 Binary files /dev/null and b/omc/plat/aif/obj/aifg_debug.o differ diff --git a/omc/plat/aif/obj/aifg_ie.o b/omc/plat/aif/obj/aifg_ie.o new file mode 100644 index 0000000..7b4191c Binary files /dev/null and b/omc/plat/aif/obj/aifg_ie.o differ diff --git a/omc/plat/aif/obj/aifg_m.o b/omc/plat/aif/obj/aifg_m.o new file mode 100644 index 0000000..dcc526b Binary files /dev/null and b/omc/plat/aif/obj/aifg_m.o differ diff --git a/omc/plat/aif/obj/aifg_mpp.o b/omc/plat/aif/obj/aifg_mpp.o new file mode 100644 index 0000000..d0f5d0d Binary files /dev/null and b/omc/plat/aif/obj/aifg_mpp.o differ diff --git a/omc/plat/aif/src/.copyarea.db b/omc/plat/aif/src/.copyarea.db new file mode 100644 index 0000000..9a1ddc4 --- /dev/null +++ b/omc/plat/aif/src/.copyarea.db @@ -0,0 +1,11 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\aif\src +2 +7 +6:aifg.c|1|11d70a3dc93|1c81|3b10db20|adc96697bfa411dc84f1001c23e19543|0 +8:aifg_m.c|1|11d70a3dcd1|b6fe|6671c6c5|e0c481066cf311dd91a5001c23e19543|0 +b:aifg_csta.c|1|11d70a3dd8d|1bba|a93e11f0|6e8b63f2a4d211dd91b5001c23e19543|0 +9:aifg_ie.c|1|11d70a3dc54|13c03|30223d39|ad29667bbfa411dc84f1001c23e19543|0 +7:include|2|0|0|0|611881b1c44711dc9632001c23e19543|0 +c:aifg_debug.c|1|11d70a3dd1f|78cb|50dddc48|b45967cbbfa411dc84f1001c23e19543|0 +a:aifg_mpp.c|1|11d70a3dd4e|340f6|c3aecf7f|e154811e6cf311dd91a5001c23e19543|0 diff --git a/omc/plat/aif/src/aifg.c b/omc/plat/aif/src/aifg.c new file mode 100644 index 0000000..7f8f68d --- /dev/null +++ b/omc/plat/aif/src/aifg.c @@ -0,0 +1,265 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_if.c +Description: Interface of AIFG +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-12 + +History: +2007-3-6 v9.0.1 Create +*********************************************************************/ +#include "./include/aifg_var_ext.h" +#include "../../public/src/include/license_id.h" +/* +Name: aifg_bind +Purpose: Request to create a SAP in AIFG module. +Input: aifg_sap_type type: type of upper layer entity + int (*callback)(): pointer to call back function +Output: SAP id +*/ +int aifg_bind(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *)) +{ + //checking parameters + assert(type == AIFG_SAP_MSC || type == AIFG_SAP_BSC); + assert(callback != NULL); + assert(sap[type].enable == 0); + + if (wxc2_get_license(LIC_AIF) != 1) + return -1; + + sap[type].enable = 1; + sap[type].callback_func = callback; + + return (int)type; +} + +/* +Name: aifg_modify +Purpose: Request to modify the SAP parameter in AIFG module. +Input: aifg_sap_type type: type of upper layer entity + aifg_callback_func *callback: new callback functions, null if no need to modify +Output: None +*/ +void aifg_modify(int sapid, int (*callback)(aifg_indication, aifg_msg_pre_decoded*)) +{ + //checking parameters + assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC); + assert(sap[sapid].enable == 1); + + sap[sapid].enable = 1; + if(callback != NULL) + sap[sapid].callback_func = callback; + + return; +} + +/* +Name: aifg_set_running_mode +Purpose: Set the running mode of AIFG module. +Input: enum aifg_run_mode mode: running mode, 0 - single, 1 - dual + int alter_ip:IP address of the alternative server, hex format +Output: None +*/ +void aifg_set_running_mode(aifg_run_mode mode) +{ + assert(mode == AIFG_RUN_MODE_SINGLE || mode == AIFG_RUN_MODE_DUAL); + + dual_server.mode = mode; + + return; +} + +/* +Name: aifg_createCircuitGroup +Purpose: Request to create a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int dpc: DPC of the circuit group. + aifg_ni ni: NI of the circuit group. +Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module + whenever it request to send a message through this circuit group + AIFG_ERR_NO_RESOURCE: Create failed +*/ +int aifg_createCircuitGroup(int sapid, int dpc, aifg_ni ni, int tgid) +{ + int i; + + assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC); + assert(ni >= 0 && ni <= 3); + assert(dpc >= 0); + + if (sap[sapid].enable == 0) + goto ERR_PROC; + + //check if there is a existing CG with the same dpc and ni + for(i=0; i < AIFG_MAX_CG; i++){ + if(cg[i].enable == 1 && cg[i].dpc == dpc && cg[i].ni == ni) + return i; + } + + //create a new circuit group + i = 0; + while(cg[i].enable == 1) + i++; + + if(i >= AIFG_MAX_CG){ + aifg_event = AIFG_ERR_OUT_OF_RESOURCE; + goto ERR_PROC; + } + + cg[i].enable = 1; + cg[i].dpc = dpc; + cg[i].ni = ni; + cg[i].sapid = sapid; + cg[i].tgid = tgid; + + return i; + +ERR_PROC: + return -1; +} + +/* +Name: aifg_delCircuitGroup +Purpose: Request to delete a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int cgid: Circuit Group ID +Output: None +*/ +void aifg_delCircuitGroup(int sapid, int cgid) +{ + assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC); + assert(cgid >= 0 && cgid < AIFG_MAX_CG); + + cg[cgid].enable = 0; + cg[cgid].dpc = 0; + cg[cgid].ni = 0; + cg[cgid].sapid = 0; + cg[cgid].tgid = 0; + + return; +} + +/* +Name: aifg_modCircuitGroup +Purpose: Request to modify the parameter of a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int cgid: Circuit Group ID + int dpc: new DPC of the circuit group, -1 if no need to change. + enum aifg_ni: new NI of the circuit group, -1 if no need to change. +Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module + whenever it request to send a message through this circuit group +*/ +int aifg_modCircuitGroup(int sapid, int cgid, int dpc, int ni) +{ + assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC); + assert(cg[cgid].sapid == sapid); + assert(ni >= 0 && ni <= 3); + assert(dpc >= 0); + assert(cgid >= 0 && cgid < AIFG_MAX_CG); + + cg[cgid].enable = 1; + cg[cgid].dpc = dpc; + cg[cgid].ni = ni; + + return cgid; +} + +/* +Name: aifg_send +Purpose: Request to send a message through A-interface. +Input: int sapid: SAP ID of upper layer entity. + int cgid: Circuit Group ID + int u_port: process port of upper layer entity + aifg_msg *msg: content of assign request message +Output: 0 - succeed + -1 - failed, no free port available + -2 - failed, circuit group not ready +*/ +int aifg_send(int sapid, int cgid, int u_port, aifg_msg_t *msg) +{ + int protocol; + assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC); + assert(cgid >= 0 && cgid < AIFG_MAX_CG); + assert(msg != NULL); + + if (sap[sapid].enable == 0){ + aifg_event = AIFG_ERR_SAP_NOT_CREATED; + goto ERR_PROC; + } + + //check message protocol and pd + msg->app_port = u_port; + if(msg->id <= AIFG_MSG_ID_RP_SMMA){ + if(msg->id <= AIFG_MSG_ID_MM_INFO) + msg->pd = AIFG_PD_DTAP_MM; + else if(msg->id <= AIFG_MSG_ID_FACILITY) + msg->pd = AIFG_PD_DTAP_CC; + else if(msg->id <= AIFG_MSG_ID_RELEASE_CMP_SS) + msg->pd = AIFG_PD_DTAP_SS; + else if(msg->id <= AIFG_MSG_ID_RP_SMMA) + msg->pd = AIFG_PD_DTAP_SMS; + else + assert(0); + protocol = AIFG_MSG_DTAP; + } + else{ + if(msg->id <= AIFG_MSG_ID_HO_CAN_RESP) + msg->pd = AIFG_PD_BSSMAP_GLOBAL; + else if(msg->id <= AIFG_MSG_ID_LSA_INFO) + msg->pd = AIFG_PD_BSSMAP_DEDICATED; + else + assert(0); + protocol = AIFG_MSG_BSSMAP; + } + + if(msg->aif_port == -1 || msg->pd == AIFG_PD_BSSMAP_GLOBAL){ + if(msg->pd != AIFG_PD_BSSMAP_GLOBAL || msg->id == AIFG_MSG_ID_PAGING){ + if((msg->aif_port = aifg_port_assign(sapid, cgid, -1)) < 0){ + aifg_event = AIFG_ERR_ASSIGN_PORT_FAIL; + goto ERR_PROC; + } + aifg_pcb[msg->aif_port].upper_port = u_port; + aifg_pcb[msg->aif_port].trace_flag = msg->trace_flag; + } + else{ + msg->aif_port = -1; //no port need + aifg_send_udt(cgid, msg, NULL); //global BSSMAP message needs no aifg port, except paging + } + } + else if (aifg_pcb[msg->aif_port].stat == AIFG_PORT_TRANSACTION && aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_UNKNOW){ + if((msg->id == AIFG_MSG_ID_SETUP + && (aifg_pcb[msg->aif_port].ti_stat > 0 || aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_CC)) + || (msg->id == AIFG_MSG_ID_RP_DATA + && aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_SMS)) + { + //new transaction + int new_port = aifg_port_assign(sapid, cgid, -1); + if (new_port < 0){ + aifg_event = AIFG_ERR_ASSIGN_PORT_FAIL; + goto ERR_PROC; + } + aifg_pcb[new_port].upper_port = u_port; + aifg_pcb[new_port].link_id = aifg_pcb[msg->aif_port].link_id; + aifg_pcb[new_port].trace_flag = msg->trace_flag; + msg->aif_port = new_port; + } + } + + if(msg->aif_port != -1){ + if (aifg_pcb[msg->aif_port].stat == AIFG_PORT_IDLE){ + aifg_event = AIFG_ERR_MSG_SD_TO_IDLE_PORT; + goto ERR_PROC; + } + aifg_pcb[msg->aif_port].cgid = cgid; + aifg_port_proc(&aifg_pcb[msg->aif_port], msg, NULL); + } + + aifg_debug_print(msg->aif_port, AIFG_EVENT_RV_REQ, msg, 0); + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_debug_print(msg->aif_port, aifg_event, msg, u_port); + return AIFG_ERROR; +} diff --git a/omc/plat/aif/src/aifg_csta.c b/omc/plat/aif/src/aifg_csta.c new file mode 100644 index 0000000..e46f713 --- /dev/null +++ b/omc/plat/aif/src/aifg_csta.c @@ -0,0 +1,310 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_csta.c +Description: CSTA of AIFG +Version: v9.0.0 +Author: XH Chen +Create Date: 2008-3-12 + +History: +2007-3-6 v9.0.1 Create +*********************************************************************/ +#include "../../../plat/public/src/include/includes.h" +#include "../../../plat/snmp/src/include/snmp.h" +#include "./include/aifg_type_def.h" + +#define NO_EXIST 0 +#define EXIST 1 +#define OID_OFFSET 14 +#define AIF_10SEC 1000 +struct obj_view { + int entry_oidlen; + int column_oidlen; + int full_oidlen; + DWORD *entry; + DWORD *column; + DWORD *iid; /* Instance ID */ + BYTE csta_pos; + BYTE csta_len; +}; + +typedef void *(*lookup_level_1)(u32 *oid_1); +typedef void *(*lookup_level_2)(u32 oid_1, u32 *oid_2); +typedef int (*get_csta)(struct obj_view *view, u8 *pdata, u8 *vartype); + +struct tab_view{ + BYTE exist_flag; + BYTE entry_id; + BYTE level; /* Three level: 1, 2*/ + lookup_level_1 lookup_1; + lookup_level_2 lookup_2; + get_csta get_aif_csta; + u8 next_column[16]; + struct obj_view view; +}; + +#define AIF_OID {1,3,6,1,4,1,1373,2,3,2,6} +#define AIF_OIDLEN 11 + +typedef struct{ + unsigned long timestamp; + int msg_stat[AIFG_MAX_MESSAGE*2]; +}aifg_csta; + +BYTE aifCSTAInd; +aifg_csta aifCSTA[96]; +//DTAP:RR MM CC SS SMS; BSSMAP:Global Dedicated +const BYTE cstaLen[8] = {0, 2, 21, 31, 3, 4, 18, 36}; +const BYTE postion[8] = {0, 0, 4, 46, 108, 114, 122, 158}; + +extern int msg_statistics[AIFG_MAX_MESSAGE][2]; +u32 *findnext_quater(u32 *id); +int get_aif_csta(struct obj_view *view, BYTE *pdata, BYTE *vartype); +int aifg_get_resp(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype); +int aif_getnext_resp(u8 prev_oidlen, u32 *prev_oid, u8 *oidlen, u32 *oid, u8 *pdata, u8 *vartype); + +static struct tab_view aif_csta_table[8]={ + {NO_EXIST}, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, + { + EXIST, OID_OFFSET, 1, + (void *)findnext_quater, NULL, + get_aif_csta, + {1, 2, 0} + }, +}; + +void aifg_csta_init(void) +{ + DWORD aif_oid_prefix[20] = AIF_OID; + + inquire_getmsg(AIF_OIDLEN, aif_oid_prefix, aifg_get_resp); + inquire_getnextmsg(AIF_OIDLEN, aif_oid_prefix, aif_getnext_resp); + + memset(aifCSTA, 0, sizeof(aifCSTA)); +} + +void aifg_csta_proc(void) +{ + static int counter = 0; + static BYTE flag = 0; + struct tm *t; + unsigned long l_time; + + if(counter ++ >= AIF_10SEC) + { + l_time = time(NULL); + t = localtime(&l_time); + counter = 0; + + if(t->tm_min % 15 < 2) //per 15 min + { + if(flag == 0) + { + /* get csta index */ + aifCSTAInd = t->tm_hour * 4 + t->tm_min / 15; + /* copy the msg statistic to the csta buffer */ + memcpy(aifCSTA[aifCSTAInd].msg_stat, msg_statistics, sizeof(msg_statistics)); + aifCSTA[aifCSTAInd].timestamp = l_time; + /* clear msg statistic */ + memset(msg_statistics, 0, sizeof(msg_statistics)); + flag = 1; + } + } + else + flag = 0; + } +} + +u32 *findnext_quater(u32 *id) +{ + int csta_inst = aifCSTAInd; + + //CHECKME: to make sure it can run across 24 hours + if(csta_inst > 0) + csta_inst -= 1; + if(*id != csta_inst) + { + *id = csta_inst; + return id; + } + *id = 0; + return NULL; +} + +struct obj_view *gen_obj_view(struct tab_view *table, u32 *oid) +{ + struct obj_view *view = &table->view; + + view->entry = oid + table->entry_id; + view->entry_oidlen = table->entry_id + 1; + view->column =view->entry + 1; + view->column_oidlen = view->entry_oidlen + 1; + view->iid = view->column + 1; + view->full_oidlen = view->column_oidlen + table->level; + view->csta_pos = postion[oid[table->entry_id-1]]; + view->csta_len = cstaLen[oid[table->entry_id-1]]; + return view; +} + +struct tab_view *lookup_csta_table(BYTE oidlen, DWORD *oid) +{ + int index; + + if(oidlen < AIF_OIDLEN +2) + return NULL; + + index = oid[AIF_OIDLEN]; + if(index >= 8) + return NULL; + else if(aif_csta_table[index].exist_flag == 0) + return NULL; + else + return &aif_csta_table[index]; +} + +void aifg_encode_csta(BYTE *pData, BYTE pos, BYTE Len, aifg_csta *pCsta) +{ + unsigned long *pDW = (unsigned long *)pData; + int *pSrc = (int *)&pCsta->msg_stat[2]; + int *pDst = (int *)(pData + 4); + int i; + + pDW[0] = htonl(pCsta->timestamp); + + for(i = 0; i < Len*2; i++) + pDst[i] = htonl(pSrc[pos + i]); +} + +int get_aif_csta(struct obj_view *view, BYTE *pdata, BYTE *vartype) +{ + int dataLen = 0; + int csta_inst; + + if((csta_inst = view->iid[0]) >= 96) + return -1; + switch(*(view->column)) + { + case 1: + *((int *)pdata) = htonl(csta_inst); + *vartype = 0x02; + dataLen = 4; + break; + case 2: + if(aifCSTA[csta_inst].timestamp == 0) + return 0; + *vartype = 0x04; + aifg_encode_csta(pdata,view->csta_pos, view->csta_len, &aifCSTA[csta_inst]); + dataLen = (view->csta_len*sizeof(int)*2+4); + break; + } + return dataLen; +} + + +int aifg_get_resp(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype) +{ + struct tab_view *table; + struct obj_view *view; + + if((table = lookup_csta_table(oidlen, oid)) == NULL) + return -1; + view = gen_obj_view(table, oid); + if(oidlen != view->full_oidlen) + return -1; + if(*(view->entry) != 1) + return -1; + if(table->get_aif_csta == NULL) + return -1; + else + return table->get_aif_csta(view, pdata, vartype); +} + + +static int get_nextOid(u8 *oidlen, u32 *oid) +{ + struct tab_view *table; + struct obj_view *view; + + if((table = lookup_csta_table(*oidlen, oid)) == NULL) + return 0; + view = gen_obj_view(table, oid); + if(*oidlen < view->full_oidlen) + { + memset(&oid[*oidlen], 0, view->full_oidlen-*oidlen); + if(*oidlen < view->entry_oidlen) + *view->entry = 1; + if(*oidlen < view->column_oidlen) + *view->column = table->next_column[0]; + if(*oidlen == view->full_oidlen-1) + { + *oidlen = view->full_oidlen; + } + *oidlen = view->full_oidlen; + } + + for(; *(view->column) != 0; *(view->column) = table->next_column[*(view->column)]) + { + switch(table->level) + { + case 1: + if(table->lookup_1(view->iid) != NULL) + return 1; + break; + case 2: + break; + case 3: + break; + } + } + return 0; +} + +int aif_getnext_resp(u8 prev_oidlen, u32 *prev_oid, u8 *oidlen, u32 *oid, u8 *pdata, u8 *vartype) +{ + memcpy(oid, prev_oid, prev_oidlen*sizeof(u32)); + *oidlen = prev_oidlen; + + if(get_nextOid(oidlen, oid)) + { + return aifg_get_resp(*oidlen, oid, pdata, vartype); + } + else + return -1; +} + diff --git a/omc/plat/aif/src/aifg_debug.c b/omc/plat/aif/src/aifg_debug.c new file mode 100644 index 0000000..f7eef47 --- /dev/null +++ b/omc/plat/aif/src/aifg_debug.c @@ -0,0 +1,1296 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_debug.c +Description: Source file of debug submodule of AIFG +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-22 + +History: +2007-3-22 v9.0.0 Create +*********************************************************************/ +#include "./include/aifg_msg.h" +#include "./include/aifg_var_ext.h" +#include "../../debug/src/include/debug.h" + +static char help_info[] = "AIFG debug help:\r\n\ +log all Turn on all debug information\r\n\ +log none Turn off all information\r\n\ +log error on/off Turn on/off error information\r\n\ +log event on/off Turn on/off event information\r\n\ +list circuit group Print circuit group Table\r\n\ +list sap Print SAP information\r\n\ +list port Print opened port\r\n\ +list link Print opened link\r\n\ +wa port x Watch port x\r\n\ +wa link x Watch link x\r\n\ +msg stat Show message statistics\r\n\ +clear msg stat Clear message statistics\r\n\ +"; + +const char *msg_name[] = { + "TRANSPARENT DTAP MESSAGE", + "PAGING RESPONSE", + "RR HANDOVER COMMAND", + "IMSI DETACH INDICATION", + "LOCATION UPDATING ACCEPT", + "LOCATION UPDATING REJECT", + "LOCATION UPDATING REQUEST", + "AUTHENTICATION REJECT", + "AUTHENTICATION REQUEST", + "AUTHENTICATION RESPONSE", + "IDENTITY REQUEST", + "IDENTITY RESPONSE", + "TMSI REALLOCATION COMMAND", + "TMSI REALLOCATION COMPLETE", + "CM SERVICE ACCEPT", + "CM SERVICE REJECT", + "CM SERVICE ABORT", + "CM SERVICE REQUEST", + "CM SERVICE PROMPT", + "CM RE-ESTABLISHMENT REQUEST", + "ABORT", + "MM NULL", + "MM STATUS", + "MM INFORMATION", + "ALERTING", + "CALL CONFIRMED", + "CALL PROCEEDING", + "CONNECT", + "CONNECT ACK", + "EMERGENCY SETUP", + "PROGRESS", + "SETUP", + "MODIFY", + "MODIFY COMPLETE", + "MODIFY REJECT", + "USER INFORMATION", + "HOLD", + "HOLD ACK", + "HOLD REJECT", + "RETRIEVE", + "RETRIEVE ACK", + "RETRIEVE REJECT", + "DISCONNECT", + "RELEASE", + "RELEASE COMPLETE", + "CONGESTION CONTROL", + "NOTIFY", + "STATUS", + "STATUS ENQUIRY", + "START DTMF", + "STOP DTMF", + "STOP DTMF ACK", + "START DTMF ACK", + "START DTMF REJECT", + "FACILITY", + "FACILITY SS", + "REGISTER", + "RELEASE COMPLETED SS", + "RP-DATA", + "RP-ACK", + "RP-ERROR", + "RP-SMMA", + "BLOCK", + "BLOCKING ACK", + "UNBLOCK", + "UNBLOCKING ACK", + "CIRCUIT GROUP BLOCK", + "CIRCUIT GROUP BLOCK ACK", + "CIRCUIT GROUP UNBLOCK", + "CIRCUIT GROUP UNBLOCK ACK", + "RESOURCE REQUEST", + "RESOURCE INDICATION", + "RESET", + "RESET ACK", + "PAGING", + "OVERLOAD", + "RESET CIRCUIT", + "RESET CIRCUIT ACK", + "HANDOVER CANDIDATE ENQUIRE", + "HANDOVER CANDIDATE RESPONSE", + "ASSIGN REQUEST", + "ASSIGN COMPLETE", + "ASSIGN FAILURE", + "HANDOVER REQUEST", + "HANDOVER REQUIRED", + "HANDOVER REQUEST ACK", + "HANDOVER COMMAND", + "HANDOVER COMPLETE", + "HANDOVER SUCCEEDED", + "HANDOVER FAILURE", + "HANDOVER PERFORMED", + "HANDOVER REQUIRED REJECT", + "HANDOVER DETECT", + "CLEAR COMMAND", + "CLEAR COMPLETE", + "CLEAR REQUEST", + "SAPI 'N' REJECT", + "CONFUSION", + "SUSPEND", + "RESUME", + "LOCATION INFORMATION COMMAND", + "LOCATION INFORMATION REPORT", + "MSC INVOKE TRACE", + "BSC INVOKE TRACE", + "UNEQUIPPED CIRCUIT", + "CHANGE CIRCUIT", + "CHANGE CIRCUIT ACK", + "CIPHER MODE COMMAND", + "CLASSMARK UPDATE", + "CIPHER MODE COMPLETE", + "QUEUEING INDICATION", + "COMPLETE LAYER 3 INFORMATION", + "CLASSMARK REQUEST", + "CIPHER MODE REJECT", + "LOAD INDICATION", + "LSA INFORMATION", + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved + NULL,//reserved +}; + +const char *sap_name[] = { + "MSC", + "BSC" +}; + +const char *ni_name[] = { + "NATIONAL", + "NATIONAL SPARE", + "INTERNATIONAL", + "INTERNATIONAL SPARE", +}; + +static const char *normal = "\033[0m"; +static const char *red = "\033[0;31;40m"; +static const char *green = "\033[0;32;40m"; +static const char *yellow = "\033[0;33;40m"; +//static const char *blue = "\033[0;34;40m"; + +#define AIFG_DEBUG_MAX_LEN 8192 +static char debug_buf[AIFG_DEBUG_MAX_LEN]; +static char asc_in[256]; +static struct log_flag_t{ + BYTE all; + BYTE err; + BYTE evt; +}log_flag; + +int msg_statistics[AIFG_MAX_MESSAGE][2]; + +void aifg_parsecmd(); +char *sprint_msg_content(char *dst, BYTE *msg, int msg_len); + +void aifg_debug_init() +{ + char aifg_ver[] = "R9V0_05P2"; + DWORD ascout_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 4 }; + DWORD ascin_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 3 }; + DWORD status_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 1 }; + DWORD name_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 2 }; + BYTE debug_status = 1; + + debug_set_response (15, ascout_id, debug_buf, AIFG_DEBUG_MAX_LEN); + debug_set_response (15, ascin_id, asc_in, 1); + debug_set_response (15, status_id, &debug_status, 1); + debug_set_response (15, name_id, aifg_ver, strlen(aifg_ver)); + + memset(msg_statistics, 0, sizeof(msg_statistics)); +} + +void aifg_debug_timer() +{ + BYTE npage; + + if(strlen(asc_in) <= 1) + return; + + debug_buf[0] = '\0'; + npage = asc_in[0] - 1; + if(npage == 0){ + aifg_parsecmd(asc_in + 1); + asc_in[0] = '\0'; + return; + } + + switch (npage){ + default: + break; + } + asc_in[0] = '\0'; +} + +/* +Purpose: Print debug information +Input: aifg_event_code event: event code + void *msg: message pointer, will be convert to aifg_msg_t* or aifg_predecode_msg* + or SP_UiPriPara* according to different event + int o_info: other information, differ from event code +Outpur: none +*/ +void aifg_debug_print(int port, aifg_event_code event, void *msg, int o_info) +{ + char buffer[1024]; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if(log_flag.all != 1){ + if (port == -1 || aifg_pcb[port].trace_flag == 0) + { + if((event >= 1024) && (log_flag.evt != 1)) + goto FINISH; + else if (log_flag.err != 1) + goto FINISH; + } + } + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + sprintf ( timestr, "(%d:%d:%d.%ld):", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + switch(event){ + case AIFG_SUCCEED: + goto FINISH; + break; + case AIFG_ERROR: + sprintf(buffer, "%sUnknown error!%s\n",red, normal); + break; + //error + case AIFG_ERR_OUT_OF_RESOURCE: + sprintf(buffer, "%sAIFG ALARM: Out of resources!%s\n",red, normal); + break; + case AIFG_ERR_UNKNOW_MSG: + sprintf(buffer, "%sAIFG ERROR: Unknow message received!%s\n",red, normal); + break; + case AIFG_ERR_UNKNOW_IE: + sprintf(buffer, "%sAIFG ERROR: Unknow IE in received message!%s\n",red, normal); + break; + case AIFG_ERR_ERROR_MSG: + sprintf(buffer, "%sAIFG ERROR: Dameged message received!%s\n",red, normal); + break; + case AIFG_ERR_ERROR_IE: + sprintf(buffer, "%sERROR: Dameged IE in received message!%s\n",red, normal); + break; + case AIFG_ERR_UP_NOT_EXIST: + sprintf(buffer, "%sERROR: Can not find the request SAP for received message!%s\n",red, normal); + break; + case AIFG_ERR_NO_UD_IN_CR: + sprintf(buffer, "%sERROR: CR received without user data field%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_DT1: + sprintf(buffer, "%sERROR: Unexpected DT1 received!%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_UDT: + sprintf(buffer, "%sERROR: Unexpected UDT received!%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_PAGING_RESP: + sprintf(buffer, "%sERROR: Unexpected Paging Response received!%s\n",red, normal); + break; + case AIFG_ERR_INVALID_TI: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Invalid TI in message %s, link %d! %s\n", + red, + msg_name[pMsg->id], + o_info, + normal); + } + break; + case AIFG_ERR_MISS_MANDATORY: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Damaged message %s, missing mandatory! %s\n", + red, + msg_name[pMsg->id], + normal); + } + break; + case AIFG_ERR_MSG_RV_TO_IDLE_PORT: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Message %s received from link %d for IDLE port %d!%s\n", + red, + msg_name[pMsg->id], + aifg_pcb[pMsg->aif_port].link_id, + pMsg->aif_port, + normal); + } + break; + case AIFG_ERR_MSG_SD_TO_IDLE_PORT: + { + aifg_msg_t *pMsg = (aifg_msg_t *)msg; + sprintf(buffer, "%sERROR: Application send message %s to IDLE port %d!%s\n", + red, + msg_name[pMsg->id], + pMsg->aif_port, + normal); + } + break; + case AIFG_ERR_ASSIGN_PORT_FAIL: + sprintf(buffer, "%sERROR: Port assign failed, resource limited! Upper port %d %s\n",red, o_info, normal); + break; + case AIFG_ERR_SAP_NOT_CREATED: + sprintf(buffer, "%sERROR: Upper port %d send message refused, SAP not created!%s\n",red, o_info, normal); + break; + case AIFG_ERR_PORT_TIMER_OUT: + sprintf(buffer, "%sERROR: PORT %d Protocol time out! Start release transaction.%s\n",red, o_info, normal); + break; + case AIFG_ERR_CAN_NOT_FIND_TI: + sprintf(buffer, "%sERROR: PORT %d Can not find TI for the transaction! Transaction released.%s\n",red, o_info, normal); + break; + case AIFG_ERR_PAGING_NOT_RESP: + sprintf(buffer, "%sERROR: PORT %d Paging no response!.%s\n",red, o_info, normal); + break; + case AIFG_ERR_PORT_RELEASED: + { + char tmp_cause_string[64]; + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + + if (pMsg->cause == 0x09 || pMsg->cause == 0x0B) + goto FINISH; //normal release + else if (pMsg->cause == 0x66) + strcpy(tmp_cause_string, "Timer expired"); + else if (pMsg->cause == 0x6F) + strcpy(tmp_cause_string, "Protocol error"); + else + tmp_cause_string[0] = '\0'; + + sprintf(buffer, "%sERROR: Port %d, Cause: %d, %s, send release ind to app port %d %s\n", + red, + pMsg->aif_port, + pMsg->cause, + tmp_cause_string, + aifg_pcb[pMsg->aif_port].upper_port, + normal + ); + } + break; + + //event + case AIFG_EVENT_REDIR_MSG: + sprintf(buffer, "AIFG EVENT: Message directed to the other server!\n"); + break; + case AIFG_EVENT_LINK_RELEASE: + sprintf(buffer, "Link %d released!\n", o_info); + break; + case AIFG_EVENT_PORT_RELEASE: + sprintf(buffer, "Port %d released!\n", o_info); + break; + case AIFG_EVENT_RV_MSG: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + int msg_id = pMsg->id; + if (msg_id == AIFG_MSG_ID_L3_INFO) + msg_id = pMsg->msg.completeL3Info.l3msg.id; + + sprintf(buffer, "%sSCCP => AIFG: ID: %s, APP_PORT:%d, AIFG_PORT:%d, LINK_ID:%d%s\n", + green, + msg_name[msg_id], + aifg_pcb[pMsg->aif_port].upper_port, + pMsg->aif_port, + aifg_pcb[pMsg->aif_port].link_id, + normal + ); + } + break; + + case AIFG_EVENT_SD_MSG: + { + aifg_msg_t *pMsg = (aifg_msg_t *)msg; + sprintf(buffer, "%sAIFG => SCCP: ID: %s, APP_PORT:%d, AIFG_PORT:%d, LINK_ID:%d%s\n", + yellow, + msg_name[pMsg->id], + pMsg->app_port, + pMsg->aif_port, + aifg_pcb[pMsg->aif_port].link_id, + normal + ); + } + break; + default: + goto FINISH; + break; + } + aifg_log(strcat(timestr, buffer)); + +FINISH: + aifg_event = AIFG_SUCCEED; + return; +} + +void aifg_get_open_port(int flag) +{ + int i = 0, j = 0; + char tmp_buf[20]; + char buf[1024]; + buf[0] = '\0'; + + for (i=0; i < AIFG_MAX_PORT; i++){ + if(aifg_pcb[i].stat != 0){ + if(j % 16 == 0 && j != 0){ + aifg_log(buf); + buf[0] = '\0'; + } + sprintf(tmp_buf,"%d\t", i); + strcat(buf, tmp_buf); + j++; + } + } +} + +void aifg_get_open_link(int flag) +{ + int i = 0, j = 0; + char tmp_buf[20]; + char buf[1024]; + buf[0] = '\0'; + for (i = 0; i < SCCP_MAX_LINK; i++){ + if(link_info[i].en_flag != 0){ + if(j % 16 == 0 && j != 0){ + aifg_log(buf); + buf[0] = '\0'; + } + sprintf(tmp_buf,"%d\t", i); + strcat(buf, tmp_buf); + j++; + } + } +} + +void aifg_get_sap() +{ + char buf[1024]; + sprintf(buf, "Current opened SAP: \n"); + + if(sap[0].enable != 0) + strcat(buf, "MSC\t"); + if(sap[1].enable != 0) + strcat(buf, "BSC"); + + aifg_log(buf); + + return; +} + +void aifg_debug_get_cg() +{ + int i = 0; + char tmp_buf[20]; + char buf[1024]; + int flag = 0; + + sprintf(buf, "#\t\t SAP\t\t NI\t\t DPC\n"); + for (i = 0; i < AIFG_MAX_CG; i++){ + if(cg[i].enable != 0){ + sprintf(tmp_buf,"%03d\t\t", i); + strcat(buf, tmp_buf); + + if (cg[i].sapid == 0) + sprintf(tmp_buf,"MSC\t\t"); + else + sprintf(tmp_buf,"BSC\t\t"); + strcat(buf, tmp_buf); + + sprintf(tmp_buf,"%02d\t\t", cg[i].ni); + strcat(buf, tmp_buf); + + sprintf(tmp_buf,"%d\n", cg[i].dpc); + strcat(buf, tmp_buf); + + flag = 1; + } + } + if (flag == 0) + aifg_log("No Circuit Group enabled!"); + else + aifg_log(buf); + + return; +} + +void aifg_print_port_info(int i, int flag) +{ + char buf[1024]; + char imsi[32]; + + sprintf(buf, +"=======AIFG Port %d=======\r\n\ +stat: %d\r\n\ +sapid: %d\r\n\ +cgid: %d\r\n\ +linkid: %d\r\n\ +new_link: %d\r\r\ +app_port: \%d\r\n\ +timer: %d\r\n\ +ti: %d\r\n\ +ti_type: %d\r\n\ +ti_stat: %d\r\n\ +ho_stat: %d\r\n\ +app_ho_port: %d\r\n\ +rel_cause: %d\r\n\ +imsi: %s\r\n\ +pNextOpenPort: %d\r\n\ +pPrevOpenPort: %d\r\n\ +pNextPort: %d\r\n\ +pPrevPort: %d\r\n\ +==========================\n", + i, + aifg_pcb[i].stat, + aifg_pcb[i].sapid, + aifg_pcb[i].cgid, + aifg_pcb[i].link_id, + aifg_pcb[i].new_link, + aifg_pcb[i].upper_port, + aifg_pcb[i].timer, + aifg_pcb[i].ti, + aifg_pcb[i].ti_type, + aifg_pcb[i].ti_stat, + aifg_pcb[i].ho_stat, + aifg_pcb[i].app_ho_port, + aifg_pcb[i].rel_cause, + sprint_msg_content(imsi, aifg_pcb[i].imsi, aifg_pcb[i].imsi_len), + aifg_pcb[i].pNextOpenPort - aifg_pcb, + aifg_pcb[i].pPrevOpenPort - aifg_pcb, + aifg_pcb[i].pNextPort - aifg_pcb, + aifg_pcb[i].pPrevPort - aifg_pcb); + + if(flag == 0) + aifg_log(buf); + else + printf(buf); +} + +void aifg_print_link_info(int i, int flag){ + char buf[1024]; + + sprintf(buf, +"=======AIFG Link %d=======\r\n\ +en_flag: %d\r\n\ +sapid: %d\r\n\ +cur_port: \%d\r\n\ +ti_number: %d\r\n\ +==========================\n", + i, + link_info[i].en_flag, + link_info[i].sapid, + link_info[i].cur_port, + link_info[i].ti_number); + + if(flag == 0) + aifg_log(buf); + else + printf(buf); +} + +void aifg_print_msg_stat() +{ + char msg_str[32]; + char tmpbuf[1024]; + int i, j; + int max_name_length = 28; + + aifg_log("==========================AIFG Message Statistics==========================\r\n" + "Message \t\t Sent \t\t\t Received"); + + for(i=0; i < AIFG_MAX_MESSAGE; i++){ + if (msg_name[i] == NULL) + break; + + j = max_name_length - strlen(msg_name[i]); + sprintf(msg_str, "%s", msg_name[i]); + while(j-- > 0) + strcat(msg_str, " "); + + sprintf(tmpbuf, "%s\t %10d \t %10d", msg_str, msg_statistics[i][1], msg_statistics[i][0]); + aifg_log(tmpbuf); + } +} + +void aifg_parsecmd(char *cmdstr) +{ + if(strstr (cmdstr, "help") != NULL || strstr (cmdstr, "?") != NULL) + aifg_log(help_info); + else if(strstr (cmdstr, "log all") != NULL) + log_flag.all = 1; + else if(strstr (cmdstr, "log none") != NULL) + memset(&log_flag, 0, sizeof(log_flag)); + else if(strstr (cmdstr, "log event on") != NULL) + log_flag.evt = 1; + else if(strstr (cmdstr, "log event off") != NULL) + log_flag.evt = 0; + else if(strstr (cmdstr, "log error on") != NULL) + log_flag.err = 1; + else if(strstr (cmdstr, "log error off") != NULL) + log_flag.err = 0; + else if(strstr (cmdstr, "list port") != NULL) + aifg_get_open_port(0); + else if(strstr (cmdstr, "list link") != NULL) + aifg_get_open_link(0); + else if(strstr (cmdstr, "list sap") != NULL) + aifg_get_sap(); + else if(strstr (cmdstr, "list cg") != NULL) + aifg_debug_get_cg(); + else if(strstr (cmdstr, "wa port ") != NULL){ + int i = atoi(cmdstr+8); + if (i < AIFG_MAX_PORT) + aifg_print_port_info(i, 0); + } + else if(strstr (cmdstr, "wa link ") != NULL){ + int i = atoi(cmdstr+8); + if (i < SCCP_MAX_LINK) + aifg_print_link_info(i, 0); + } + else if (strstr (cmdstr, "clear msg stat") != NULL){ + memset(msg_statistics, 0, sizeof(msg_statistics)); + } + else if (strstr (cmdstr, "msg stat") != NULL){ + aifg_print_msg_stat(); + } + else{ + char tmp_buffer[100]; + sprintf(tmp_buffer, "%sInvalid Command!%s\n",red, normal); + aifg_log(tmp_buffer); + return; + } + + aifg_log("Command OK."); + return; +} + +void aifg_log(char *info) +{ + if(strlen(debug_buf) + strlen(info) > AIFG_DEBUG_MAX_LEN) + { +// aifgDebugFull = 1; + return; + } + + strncat(debug_buf, info, AIFG_DEBUG_MAX_LEN); + strcat(debug_buf, "\r\n"); + return; +} + +static u8 ascii[16] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, + 0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; +char *sprint_msg_content(char *dst, BYTE *msg, int msg_len) +{ + int i = 0; + int j = 0; + + j += 9; + for (i = 0; i < msg_len; i++) + { + dst[j++] = ascii[msg[i] >> 4]; + dst[j++] = ascii[msg[i] & 0x0f]; + dst[j++] = ' '; + + if(i % 15 == 0 && i != 0){ + memcpy(dst+j, "\n ", 9); + j += 10; + } + else if(i % 7 == 0 && i != 0){ + dst[j++] = ' '; + } + } + dst[j++] = '\n'; + dst[j] = '\0'; + + return dst; +} + +#if 0 +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_debug.c +Description: Source file of debug submodule of AIFG +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-22 + +History: +2007-3-22 v9.0.0 Create +*********************************************************************/ +#include "./include/aifg_msg.h" +#include "./include/aifg_var_ext.h" +#include "../../debug/src/include/debug.h" +#include "../../debug/src/include/debug_r9.h" + +static char help_info[] = "AIFG debug help:\r\n\ + log all Turn on all debug information\r\n\ + log none Turn off all information\r\n\ + log error on/off Turn on/off error information\r\n\ + list circuit group Print circuit group Table\r\n\ + list sap Print SAP information\r\n\ + list port Print opened port\r\n\ + list link Print opened link\r\n\ + wa port x Watch port x\r\n\ + wa link x Watch link x\r\n\ + "; + +const char *msg_name[] = { + "", + "PAGING RESPONSE", + "RR HANDOVER COMMAND", + "IMSI DETACH INDICATION", + "LOCATION UPDATING ACCEPT", + "LOCATION UPDATING REJECT", + "LOCATION UPDATING REQUEST", + "AUTHENTICATION REJECT", + "AUTHENTICATION REQUEST", + "AUTHENTICATION RESPONSE", + "IDENTITY REQUEST", + "IDENTITY RESPONSE", + "TMSI REALLOCATION COMMAND", + "TMSI REALLOCATION COMPLETE", + "CM SERVICE ACCEPT", + "CM SERVICE REJECT", + "CM SERVICE ABORT", + "CM SERVICE REQUEST", + "CM SERVICE PROMPT", + "CM RE-ESTABLISHMENT REQUEST", + "ABORT", + "MM NULL", + "MM STATUS", + "MM INFORMATION", + "ALERTING", + "CALL CONFIRMED", + "CALL PROCEEDING", + "CONNECT", + "CONNECT ACK", + "EMERGENCY SETUP", + "PROGRESS", + "SETUP", + "MODIFY", + "MODIFY COMPLETE", + "MODIFY REJECT", + "USER INFORMATION", + "HOLD", + "HOLD ACK", + "HOLD REJECT", + "RETRIEVE", + "RETRIEVE ACK", + "RETRIEVE REJECT", + "DISCONNECT", + "RELEASE", + "RELEASE COMPLETE", + "CONGESTION CONTROL", + "NOTIFY", + "STATUS", + "STATUS ENQUIRY", + "START DTMF", + "STOP DTMF", + "STOP DTMF ACK", + "START DTMF ACK", + "START DTMF REJECT", + "FACILITY", + "FACILITY SS", + "REGISTER", + "RELEASE COMPLETED SS", + "RP-DATA", + "RP-ACK", + "RP-ERROR", + "RP-SMMA", + "BLOCK", + "BLOCKING ACK", + "UNBLOCK", + "UNBLOCKING ACK", + "CIRCUIT GROUP BLOCK", + "CIRCUIT GROUP BLOCK ACK", + "CIRCUIT GROUP UNBLOCK", + "CIRCUIT GROUP UNBLOCK ACK", + "RESOURCE REQUEST", + "RESOURCE INDICATION", + "RESET", + "RESET ACK", + "PAGING", + "OVERLOAD", + "RESET CIRCUIT", + "RESET CIRCUIT ACK", + "HANDOVER CANDIDATE ENQUIRE", + "HANDOVER CANDIDATE RESPONSE", + "ASSIGN REQUEST", + "ASSIGN COMPLETE", + "ASSIGN FAILURE", + "HANDOVER REQUEST", + "HANDOVER REQUIRED", + "HANDOVER REQUEST ACK", + "HANDOVER COMMAND", + "HANDOVER COMPLETE", + "HANDOVER SUCCEEDED", + "HANDOVER FAILURE", + "HANDOVER PERFORMED", + "HANDOVER REQUIRED REJECT", + "HANDOVER DETECT", + "CLEAR COMMAND", + "CLEAR COMPLETE", + "CLEAR REQUEST", + "SAPI 'N' REJECT", + "CONFUSION", + "SUSPEND", + "RESUME", + "LOCATION INFORMATION COMMAND", + "LOCATION INFORMATION REPORT", + "MSC INVOKE TRACE", + "BSC INVOKE TRACE", + "UNEQUIPPED CIRCUIT", + "CHANGE CIRCUIT", + "CHANGE CIRCUIT ACK", + "CIPHER MODE COMMAND", + "CLASSMARK UPDATE", + "CIPHER MODE COMPLETE", + "QUEUEING INDICATION", + "COMPLETE LAYER 3 INFORMATION", + "CLASSMARK REQUEST", + "CIPHER MODE REJECT", + "LOAD INDICATION", + "LSA INFORMATION", + }; + +const char *sap_name[] = { + "MSC", + "BSC" + }; + +const char *ni_name[] = { + "NATIONAL", + "NATIONAL SPARE", + "INTERNATIONAL", + "INTERNATIONAL SPARE", + }; + +char aifg_ver[] = "R9V0_03A"; + +static const char *normal = "\033[0m"; +static const char *red = "\033[0;31;40m"; +static const char *green = "\033[0;32;40m"; +static const char *yellow = "\033[0;33;40m"; +static const char *blue = "\033[0;34;40m"; + +static char debug_buf[4096]; +static char new_debug_buf[4096]; +static char asc_in[256]; + +static int LOG_ERR_ID; +static int AIFG_DBEUG_SAPID; + +void aifg_parsecmd(); +char *sprint_msg_content(char *dst, BYTE *msg, int msg_len); +void aifg_debug_r9_init(); + +void aifg_debug_init() + { + DWORD status_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 1 }; + DWORD name_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 23, 2 }; + BYTE debug_status = 1; + + debug_set_response (15, status_id, &debug_status, 1); + debug_set_response (15, name_id, aifg_ver, strlen(aifg_ver)); + + aifg_debug_r9_init(); + } + +void aifg_debug_timer() + { + BYTE npage, nline; + + switch (npage){ + default: + break; + } + } + +/* +Purpose: Print debug information +Input: aifg_event_code event: event code +void *msg: message pointer, will be convert to aifg_msg_t* or aifg_predecode_msg* +or SP_UiPriPara* according to different event +int o_info: other information, differ from event code +Outpur: none +*/ +void aifg_debug_print(aifg_event_code event, void *msg, int o_info) + { + char buffer[1024]; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + sprintf ( timestr, "(%d:%d:%d.%ld):", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + switch(event){ + case AIFG_SUCCEED: + goto FINISH; + break; + case AIFG_ERROR: + sprintf(buffer, "%sUnknown error!%s\n",red, normal); + break; + //error + case AIFG_ERR_OUT_OF_RESOURCE: + sprintf(buffer, "%sAIFG ALARM: Out of resources!%s\n",red, normal); + break; + case AIFG_ERR_UNKNOW_MSG: + sprintf(buffer, "%sAIFG ERROR: Unknown message received!%s\n",red, normal); + break; + case AIFG_ERR_UNKNOW_IE: + sprintf(buffer, "%sAIFG ERROR: Unknown IE in received message!%s\n",red, normal); + break; + case AIFG_ERR_ERROR_MSG: + sprintf(buffer, "%sAIFG ERROR: Damaged message received!%s\n",red, normal); + break; + case AIFG_ERR_ERROR_IE: + sprintf(buffer, "%sERROR: Damaged IE in received message!%s\n",red, normal); + break; + case AIFG_ERR_UP_NOT_EXIST: + sprintf(buffer, "%sERROR: Can not find the request SAP for received message!%s\n",red, normal); + break; + case AIFG_ERR_NO_UD_IN_CR: + sprintf(buffer, "%sERROR: CR received without user data field%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_DT1: + sprintf(buffer, "%sERROR: Unexpected DT1 received!%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_UDT: + sprintf(buffer, "%sERROR: Unexpected UDT received!%s\n",red, normal); + break; + case AIFG_ERR_UNEXPECTED_PAGING_RESP: + sprintf(buffer, "%sERROR: Unexpected Paging Response received!%s\n",red, normal); + break; + case AIFG_ERR_INVALID_TI: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Invalid TI in message %s, link %d! %s\n", + red, + msg_name[pMsg->id], + o_info, + normal); + } + break; + case AIFG_ERR_MISS_MANDATORY: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Damaged message %s, missing mandatory! %s\n", + red, + msg_name[pMsg->id], + normal); + } + break; + case AIFG_ERR_MSG_RV_TO_IDLE_PORT: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sERROR: Message %s received from link %d for IDLE port %d!%s\n", + red, + msg_name[pMsg->id], + aifg_pcb[pMsg->aif_port].link_id, + pMsg->aif_port, + normal); + } + + break; + case AIFG_ERR_MSG_SD_TO_IDLE_PORT: + { + aifg_msg_t *pMsg = (aifg_msg_t *)msg; + sprintf(buffer, "%sERROR: Application send message %s to IDLE port %d!%s\n", + red, + msg_name[pMsg->id], + pMsg->aif_port, + normal); + } + + break; + + //event + case AIFG_EVENT_REDIR_MSG: + sprintf(buffer, "AIFG EVENT: Message directed to the other server!\n"); + break; + case AIFG_EVENT_LINK_RELEASE: + sprintf(buffer, "Link %d released!\n", o_info); + break; + case AIFG_EVENT_RV_MSG: + { + aifg_msg_pre_decoded *pMsg = (aifg_msg_pre_decoded *)msg; + sprintf(buffer, "%sSCCP => AIFG: ID: %s, APP_PORT:%d, AIFG_PORT:%d, LINK_ID:%d%s,\n", + green, + msg_name[pMsg->id], + aifg_pcb[pMsg->aif_port].upper_port, + pMsg->aif_port, + aifg_pcb[pMsg->aif_port].link_id, + normal + ); + } + break; + + case AIFG_EVENT_SD_MSG: + { + aifg_msg_t *pMsg = (aifg_msg_t *)msg; + sprintf(buffer, "%sAIFG => SCCP: ID: %s, APP_PORT:%d, AIFG_PORT:%d, LINK_ID:%d%s\n", + yellow, + msg_name[pMsg->id], + pMsg->app_port, + pMsg->aif_port, + aifg_pcb[pMsg->aif_port].link_id, + normal + ); + } + break; + default: + goto FINISH; + break; + } + debug_print_ascii(AIFG_DBEUG_SAPID, strcat(timestr, buffer)); + +FINISH: + aifg_event = AIFG_SUCCEED; + return; + } + +void aifg_print_error(int err_code) + { + + } + +char *aifg_get_open_port(int flag) + { + int i = 0, j = 0; + char tmp_buf[10]; + new_debug_buf[0] = '\0'; + while (i < AIFG_MAX_PORT){ + if(aifg_pcb[i].stat != 0){ + if(j % 16 == 15) + sprintf(tmp_buf,"\n%d\t", i); + else + sprintf(tmp_buf,"%d\t", i); + strcat(new_debug_buf, tmp_buf); + j++; + } + i++; + } + + // if(flag == 0) + // aifg_log(new_debug_buf); + + return new_debug_buf; + } + +char *aifg_get_open_link(int flag) + { + int i = 0, j = 0; + char tmp_buf[10]; + new_debug_buf[0] = '\0'; + while (i < SCCP_MAX_LINK){ + if(link_info[i].en_flag != 0){ + if(j % 16 == 15) + sprintf(tmp_buf,"\n%d\t", i); + else + sprintf(tmp_buf,"%d\t", i); + strcat(new_debug_buf, tmp_buf); + j++; + } + i++; + } + + // if(flag == 0) + // aifg_log(new_debug_buf); + + return new_debug_buf; + } + +char *aifg_print_port_info(int i, int flag) + { + char imsi[32]; + + sprintf(new_debug_buf, + "=======AIFG Port %d=======\r\n\ + stat: %d\r\n\ + sapid: %d\r\n\ + cgid: %d\r\n\ + linkid: %d\r\n\ + new_link: %d\r\r\ + app_port: \%d\r\n\ + timer: %d\r\n\ + ti: %d\r\n\ + ti_type: %d\r\n\ + ti_stat: %d\r\n\ + ho_stat: %d\r\n\ + app_ho_port: %d\r\n\ + rel_cause: %d\r\n\ + pNextOpenPort: %d\r\n\ + pPrevOpenPort: %d\r\n\ + pNextPort: %d\r\n\ + pPrevPort: %d\r\n\ + ==========================\n", + i, + aifg_pcb[i].stat, + aifg_pcb[i].sapid, + aifg_pcb[i].cgid, + aifg_pcb[i].link_id, + aifg_pcb[i].new_link, + aifg_pcb[i].upper_port, + aifg_pcb[i].timer, + aifg_pcb[i].ti, + aifg_pcb[i].ti_type, + aifg_pcb[i].ti_stat, + aifg_pcb[i].ho_stat, + aifg_pcb[i].app_ho_port, + aifg_pcb[i].rel_cause, + aifg_pcb[i].pNextOpenPort - aifg_pcb, + aifg_pcb[i].pPrevOpenPort - aifg_pcb, + aifg_pcb[i].pNextPort - aifg_pcb, + aifg_pcb[i].pPrevPort - aifg_pcb); + + // if(flag == 0) + // aifg_log(new_debug_buf); + + return new_debug_buf; + } + +char *aifg_print_link_info(int i, int flag){ + sprintf(new_debug_buf, + "=======AIFG Link %d=======\r\n\ + en_flag: %d\r\n\ + sapid: %d\r\n\ + cur_port: \%d\r\n\ + ti_number: %d\r\n\ + ti[0] port: %d\r\n\ + ti[1] port: %d\r\n\ + ti[2] port: %d\r\n\ + ti[3] port: %d\r\n\ + ti[4] port: %d\r\n\ + ti[5] port: %d\r\n\ + ti[6] port: %d\r\n\ + ti[7] port: %d\r\n\ + ti[8] port: %d\r\n\ + ti[9] port: %d\r\n\ + ti[10] port: %d\r\n\ + ti[11] port: %d\r\n\ + ti[12] port: %d\r\n\ + ti[13] port: %d\r\n\ + ti[14] port: %d\r\n\ + ti[15] port: %d\r\n\ + ==========================\n", + i, + link_info[i].en_flag, + link_info[i].sapid, + link_info[i].cur_port, + link_info[i].ti_number, + link_info[i].ti[0].port, + link_info[i].ti[1].port, + link_info[i].ti[2].port, + link_info[i].ti[3].port, + link_info[i].ti[4].port, + link_info[i].ti[5].port, + link_info[i].ti[6].port, + link_info[i].ti[7].port, + link_info[i].ti[8].port, + link_info[i].ti[9].port, + link_info[i].ti[10].port, + link_info[i].ti[11].port, + link_info[i].ti[12].port, + link_info[i].ti[13].port, + link_info[i].ti[14].port, + link_info[i].ti[15].port); + + //if(flag == 0) + // aifg_log(new_debug_buf); + + return new_debug_buf; + } + +char *aifg_print_cg() + { + int i; + char tmp_buf[256]; + sprintf(new_debug_buf, "Current enabled circuit group:\r\n"); + strcat(new_debug_buf, "CG_ID\t\tDPC\t\tNI\n"); + for (i=0; i < AIFG_MAX_CG; i++){ + if (cg[i].enable != 0){ + sprintf(tmp_buf, "%d\t\t%d\t\t%s\n", i, cg[i].dpc, ni_name[cg[i].ni]); + } + } + strcat(new_debug_buf, tmp_buf); + return new_debug_buf; + } +//DEBUG R9------------------------------------------------------------------------------------------------------------ +char *aifg_debug_help() + { + return help_info; + } + +static int watach_param_port; +static int watach_param_link; +char *aifg_debug_watch(int param_id, int value) + { + if (value < 0){ + sprintf(debug_buf, "Illegal parameter value!\n"); + return debug_buf; + } + + if (param_id == watach_param_port){ + return aifg_print_port_info(value, 1); + } + else if (param_id == watach_param_link){ + return aifg_print_link_info(value, 1); + } + else{ + assert(0); + return NULL; + } + } + +static int list_param_port; +static int list_param_link; +static int list_param_cg; +char *aifg_debug_list(int param_id, int value) + { + int i; + if (param_id == list_param_port){ + return aifg_get_open_port(1); + } + else if (param_id == list_param_link){ + return aifg_get_open_link(1); + } + else if (param_id == list_param_cg){ + return aifg_print_cg(); + } + else{ + assert(0); + return NULL; + } + } + +void aifg_debug_r9_init() + { + int cmdid, paramid; + AIFG_DBEUG_SAPID = debug_bind("AIF", "R9V03A"); + cmdid = debug_add_cmd(AIFG_DBEUG_SAPID, "help", aifg_debug_help); + + //cmd watch + cmdid = debug_add_cmd(AIFG_DBEUG_SAPID, "wa", aifg_debug_watch); + watach_param_port = debug_add_cmd_param(AIFG_DBEUG_SAPID, cmdid, "port"); + watach_param_link = debug_add_cmd_param(AIFG_DBEUG_SAPID, cmdid, "link"); + + //cmd list + cmdid = debug_add_cmd(AIFG_DBEUG_SAPID, "list", aifg_debug_list); + list_param_port = debug_add_cmd_param(AIFG_DBEUG_SAPID, cmdid, "port"); + list_param_link = debug_add_cmd_param(AIFG_DBEUG_SAPID, cmdid, "link"); + list_param_cg = debug_add_cmd_param(AIFG_DBEUG_SAPID, cmdid, "cg"); + + //add log + LOG_ERR_ID = debug_add_log(AIFG_DBEUG_SAPID, "error"); + } + +#endif diff --git a/omc/plat/aif/src/aifg_ie.c b/omc/plat/aif/src/aifg_ie.c new file mode 100644 index 0000000..f7fe169 --- /dev/null +++ b/omc/plat/aif/src/aifg_ie.c @@ -0,0 +1,2227 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_ie.h +Description: Implementation of IE encode/decode functions +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-21 + +History: +2007-3-21 v9.0.0 Create +*********************************************************************/ +#include "./include/aifg_var_ext.h" + +/* +Name: aifg_get_iei +Purpose:Convert local IE ID to protocol IEI +Input: aifg_msg_protocol protocol: BSSMAP or DTAP + aifg_pre_decoded_ie *pre_decoded: pre-decoded IE structure + aifg_ie *dst: pointer to a aifg_ie structure object in which the decoded message will be stored. +Output: Total length of decoded IE +*/ +int aifg_get_iei(int localId) +{ + switch(localId){ + case AIFG_IE_ID_BM_CIC: + return AIFG_IEI_BM_CIC; + break; + case AIFG_IE_ID_BM_CHANNELTYPE: + return AIFG_IEI_BM_CHANNELTYPE; + break; + case AIFG_IE_ID_BM_FORWARDIND: + return AIFG_IEI_BM_FORWARDIND; + break; + case AIFG_IE_ID_BM_RESOURCEAVAIL: + return AIFG_IEI_BM_RESOURCEAVAIL; + break; + case AIFG_IE_ID_BM_CAUSE: + return AIFG_IEI_BM_CAUSE; + break; + case AIFG_IE_ID_BM_CELLID: + return AIFG_IEI_BM_CELLID; + break; + case AIFG_IE_ID_BM_PRIORITY: + return AIFG_IEI_BM_PRIORITY; + break; + case AIFG_IE_ID_BM_L3HEADERINFO: + return AIFG_IEI_BM_L3HEADERINFO; + break; + case AIFG_IE_ID_BM_IMSI: + return AIFG_IEI_BM_IMSI; + break; + case AIFG_IE_ID_BM_TMSI: + return AIFG_IEI_BM_TMSI; + break; + case AIFG_IE_ID_BM_ENCRYPTINFO: + return AIFG_IEI_BM_ENCRYPTINFO; + break; + case AIFG_IE_ID_BM_PERIODICITY: + return AIFG_IEI_BM_PERIODICITY; + break; + case AIFG_IE_ID_BM_EXTRESOURCEIND: + return AIFG_IEI_BM_EXTRESOURCEIND; + break; + case AIFG_IE_ID_BM_MSNUM: + return AIFG_IEI_BM_MSNUM; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO2: + return AIFG_IEI_BM_CLASSMARKINFO2; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO3: + return AIFG_IEI_BM_CLASSMARKINFO3; + break; + case AIFG_IE_ID_BM_BANDUSED: + return AIFG_IEI_BM_BANDUSED; + break; + case AIFG_IE_ID_BM_RRCAUSE: + return AIFG_IEI_BM_RRCAUSE; + break; + case AIFG_IE_ID_BM_L3INFO: + return AIFG_IEI_BM_L3INFO; + break; + case AIFG_IE_ID_BM_DLCI: + return AIFG_IEI_BM_DLCI; + break; + case AIFG_IE_ID_BM_DTXFLAG: + return AIFG_IEI_BM_DTXFLAG; + break; + case AIFG_IE_ID_BM_CELLIDLIST: + return AIFG_IEI_BM_CELLIDLIST; + break; + case AIFG_IE_ID_BM_RESPREQ: + return AIFG_IEI_BM_RESPREQ; + break; + case AIFG_IE_ID_BM_RESOURCEINDMEHTOD: + return AIFG_IEI_BM_RESOURCEINDMEHTOD; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO1: + return AIFG_IEI_BM_CLASSMARKINFO1; + break; + case AIFG_IE_ID_BM_CICLIST: + return AIFG_IEI_BM_CICLIST; + break; + case AIFG_IE_ID_BM_DIGNOSTIC: + return AIFG_IEI_BM_DIGNOSTIC; + break; + case AIFG_IE_ID_BM_L3MSGCONTENT: + return AIFG_IEI_BM_L3MSGCONTENT; + break; + case AIFG_IE_ID_BM_CHOSENCHANNEL: + return AIFG_IEI_BM_CHOSENCHANNEL; + break; + case AIFG_IE_ID_BM_TOTALRESOURCE: + return AIFG_IEI_BM_TOTALRESOURCE; + break; + case AIFG_IE_ID_BM_CIPHERRESPMODE: + return AIFG_IEI_BM_CIPHERRESPMODE; + break; + case AIFG_IE_ID_BM_CHANNELNEEDED: + return AIFG_IEI_BM_CHANNELNEEDED; + break; + case AIFG_IE_ID_BM_TRACETYPE: + return AIFG_IEI_BM_TRACETYPE; + break; + case AIFG_IE_ID_BM_TRIGGERID: + return AIFG_IEI_BM_TRIGGERID; + break; + case AIFG_IE_ID_BM_TRACEREF: + return AIFG_IEI_BM_TRACEREF; + break; + case AIFG_IE_ID_BM_TRANSACTIONID: + return AIFG_IEI_BM_TRANSACTIONID; + break; + case AIFG_IE_ID_BM_MOBILEID: + return AIFG_IEI_BM_MOBILEID; + break; + case AIFG_IE_ID_BM_OMCID: + return AIFG_IEI_BM_OMCID; + break; + case AIFG_IE_ID_BM_CHOSENENCRYPT: + return AIFG_IEI_BM_CHOSENENCRYPT; + break; + case AIFG_IE_ID_BM_CIRCUITPOOL: + return AIFG_IEI_BM_CIRCUITPOOL; + break; + case AIFG_IE_ID_BM_CIRCUITPOOLLIST: + return AIFG_IEI_BM_CIRCUITPOOLLIST; + break; + case AIFG_IE_ID_BM_TIMEIND: + return AIFG_IEI_BM_TIMEIND; + break; + case AIFG_IE_ID_BM_RESOURCESITUATION: + return AIFG_IEI_BM_RESOURCESITUATION; + break; + case AIFG_IE_ID_BM_CURCHANNELTYPE1: + return AIFG_IEI_BM_CURCHANNELTYPE1; + break; + case AIFG_IE_ID_BM_QUEUEIND: + return AIFG_IEI_BM_QUEUEIND; + break; + case AIFG_IE_ID_BM_SPEECHVER: + return AIFG_IEI_BM_SPEECHVER; + break; + case AIFG_IE_ID_BM_ASSIGNREQUIREMENT: + return AIFG_IEI_BM_ASSIGNREQUIREMENT; + break; + case AIFG_IE_ID_BM_TALKERFLAG: + return AIFG_IEI_BM_TALKERFLAG; + break; + case AIFG_IE_ID_BM_CONNRELREQ: + return AIFG_IEI_BM_CONNRELREQ; + break; + case AIFG_IE_ID_BM_GROUPCALLREF: + return AIFG_IEI_BM_GROUPCALLREF; + break; + case AIFG_IE_ID_BM_EMLPP: + return AIFG_IEI_BM_EMLPP; + break; + case AIFG_IE_ID_BM_CFGEVOIND: + return AIFG_IEI_BM_CFGEVOIND; + break; + case AIFG_IE_ID_BM_BSSOLDTONEW: + return AIFG_IEI_BM_BSSOLDTONEW; + break; + case AIFG_IE_ID_BM_LSAID: + return AIFG_IEI_BM_LSAID; + break; + case AIFG_IE_ID_BM_LSAIDLIST: + return AIFG_IEI_BM_LSAIDLIST; + break; + case AIFG_IE_ID_BM_LSAINFO: + return AIFG_IEI_BM_LSAINFO; + break; + case AIFG_IE_ID_BM_LOCATIONINFO: + return AIFG_IEI_BM_LOCATIONINFO; + break; +/////////dtap////////// + //common + case AIFG_IE_ID_DT_LAI: + return AIFG_IEI_DT_LAI; + break; + case AIFG_IE_ID_DT_MOBILEID: + return AIFG_IEI_DT_MOBILEID; + break; + case AIFG_IE_ID_DT_MSCM3: + return AIFG_IEI_DT_MSCM3; + break; + case AIFG_IE_ID_DT_PRIORITYLEVEL: + return AIFG_IEI_DT_PRIORITYLEVEL; + break; + + //mm + case AIFG_IE_ID_DT_FULL_NWNAME: + return AIFG_IEI_DT_FULL_NWNAME; + break; + case AIFG_IE_ID_DT_SHORT_NWNAME: + return AIFG_IEI_DT_SHORT_NWNAME; + break; + case AIFG_IE_ID_DT_FLONPROCEED: + return AIFG_IEI_DT_FLONPROCEED; + break; + case AIFG_IE_ID_DT_TIMEZONE: + return AIFG_IEI_DT_TIMEZONE; + break; + case AIFG_IE_ID_DT_TZTIME: + return AIFG_IEI_DT_TZTIME; + break; + case AIFG_IE_ID_DT_CTS: + return AIFG_IEI_DT_CTS; + break; + case AIFG_IE_ID_DT_LSAID: + return AIFG_IEI_DT_LSAID; + break; + //cc + case AIFG_IE_ID_DT_AUXSTAT: + return AIFG_IEI_DT_AUXSTAT; + break; + case AIFG_IE_ID_DT_BEARERCAP: + return AIFG_IEI_DT_BEARERCAP; + break; + case AIFG_IE_ID_DT_CCCAP: + return AIFG_IEI_DT_CCCAP; + break; + case AIFG_IE_ID_DT_CALLEDBCD: + return AIFG_IEI_DT_CALLEDBCD; + break; + case AIFG_IE_ID_DT_CALLEDSUBADDR: + return AIFG_IEI_DT_CALLEDSUBADDR; + break; + case AIFG_IE_ID_DT_CALLERBCD: + return AIFG_IEI_DT_CALLERBCD; + break; + case AIFG_IE_ID_DT_CALLERSUBADDR: + return AIFG_IEI_DT_CALLERSUBADDR; + break; + case AIFG_IE_ID_DT_CAUSE: + return AIFG_IEI_DT_CAUSE; + break; + case AIFG_IE_ID_DT_CLIRSUP: + return AIFG_IEI_DT_CLIRSUP; + break; + case AIFG_IE_ID_DT_CLIRIVO: + return AIFG_IEI_DT_CLIRIVO; + break; + case AIFG_IE_ID_DT_CONNNUM: + return AIFG_IEI_DT_CONNNUM; + break; + case AIFG_IE_ID_DT_CONNSUBADDR: + return AIFG_IEI_DT_CONNSUBADDR; + break; + case AIFG_IE_ID_DT_FACILITY: + return AIFG_IEI_DT_FACILITY; + break; + case AIFG_IE_ID_DT_HIGHCOM: + return AIFG_IEI_DT_HIGHCOM; + break; + case AIFG_IE_ID_DT_KEYPAD: + return AIFG_IEI_DT_KEYPAD; + break; + case AIFG_IE_ID_DT_LOWCOM: + return AIFG_IEI_DT_LOWCOM; + break; + case AIFG_IE_ID_DT_MOREDATA: + return AIFG_IEI_DT_MOREDATA; + break; + case AIFG_IE_ID_DT_PROGIND: + return AIFG_IEI_DT_PROGIND; + break; + case AIFG_IE_ID_DT_REDIRBCD: + return AIFG_IEI_DT_REDIRBCD; + break; + case AIFG_IE_ID_DT_REDIRSUBADDR: + return AIFG_IEI_DT_REDIRSUBADDR; + break; + case AIFG_IE_ID_DT_REPEATIND: + return AIFG_IEI_DT_REPEATIND; + break; + case AIFG_IE_ID_DT_REVCALLDIR: + return AIFG_IEI_DT_REVCALLDIR; + break; + case AIFG_IE_ID_DT_SIGNAL: + return AIFG_IEI_DT_SIGNAL; + break; + case AIFG_IE_ID_DT_SSVER: + return AIFG_IEI_DT_SSVER; + break; + case AIFG_IE_ID_DT_USERUSER: + return AIFG_IEI_DT_USERUSER; + break; + case AIFG_IE_ID_DT_ALERTPATTERN://zhugq + return AIFG_IEI_DT_ALERTPATTERN; + break; + case AIFG_IE_ID_DT_RP_UD: + return AIFG_IEI_DT_RP_UD; + break; + case AIFG_IE_ID_DT_RP_CAUSE: + return AIFG_IEI_DT_RP_CAUSE; + break; + default: + assert(0); + return AIFG_ERROR; + break; + } +} + +//Information element process functions definition------------------------------------ +/* +Name: aifg_ie_decode +Purpose: Information element decode function +Input: aifg_msg_protocol protocol: BSSMAP or DTAP + aifg_pre_decoded_ie *pre_decoded: pre-decoded IE structure + aifg_ie *dst: pointer to a aifg_ie structure object in which the decoded message will be stored. +Output: Total length of decoded IE +*/ +int aifg_ie_decode(aifg_ie_ptr *pre_decoded, aifg_ie *dst) +{ + int i, j; + int ie_len = 0, offset = 0; + BYTE hi_lo_flag; + BYTE *src; + + memset(dst, 0, sizeof(aifg_ie)); + + //checking parameter + if (pre_decoded == NULL || pre_decoded->ptr == NULL || dst == NULL){ + assert(0); + goto ERR_PROC; + } + + src = pre_decoded->ptr; + hi_lo_flag = pre_decoded->hi_lo_flag; + dst->iei = pre_decoded->iei; + + switch(dst->iei){ + /*the usage of these IEs are uncertain yet + case AIFG_IE_ID_DT_CODESETEXT: + //TODO + break; + case AIFG_IE_ID_DT_SHIFT: + //TODO + break; + */ + case AIFG_IE_ID_DT_CLIRSUP: + //TODO + break; + case AIFG_IE_ID_DT_CLIRIVO: + //TODO + break; + case AIFG_IE_ID_DT_FACILITY: + dst->param.dt_facility.component_len = src[offset]; + ie_len = src[offset++]+1; + + memcpy(dst->param.dt_facility.component, src + offset, dst->param.dt_facility.component_len); +/* + ie_len = src[offset++]+1; + + if(src[offset] == 0xa1)//invoke + { + dst->param.dt_facility.components.invoke.tag = src[offset++]; + dst->param.dt_facility.components.invoke.len = src[offset++]; + + //invoke_id - M + dst->param.dt_facility.components.invoke.invoke_id.tag = src[offset++]; + assert(src[offset++] == 1); + dst->param.dt_facility.components.invoke.invoke_id.len = 1; + dst->param.dt_facility.components.invoke.invoke_id.id = src[offset++]; + + if(src[offset] == 0x80)//linked_id - O + { + dst->param.dt_facility.components.invoke.linked_id.flag = 1; + dst->param.dt_facility.components.invoke.linked_id.tag = src[offset++]; + assert(src[offset++] == 1); + dst->param.dt_facility.components.invoke.linked_id.len = 1; + dst->param.dt_facility.components.invoke.linked_id.id = src[offset++]; + i = 3; + } + + //operation code -M + dst->param.dt_facility.components.invoke.opCode.tag = src[offset++]; + dst->param.dt_facility.components.invoke.opCode.len = src[offset++]; + memcpy(dst->param.dt_facility.components.invoke.opCode.op,&src[offset],dst->param.dt_facility.components.invoke.opCode.len); + offset += dst->param.dt_facility.components.invoke.opCode.len; + + //parameters - O + j = dst->param.dt_facility.components.invoke.len - (3+i+2+dst->param.dt_facility.components.invoke.opCode.len); + assert(j == 1 || j == 0); + if(j == 1) + { + dst->param.dt_facility.components.invoke.param.flag = 1; + dst->param.dt_facility.components.invoke.param.param = src[offset++]; + } + } + //retrun result + if((offset < ie_len) && (src[offset] == 0xa2)) + { + dst->param.dt_facility.components.return_result.tag = src[offset++]; + dst->param.dt_facility.components.return_result.len = src[offset++]; + + //invoke_id - M + dst->param.dt_facility.components.return_result.invoke_id.tag = src[offset++]; + assert(src[offset++] == 1); + dst->param.dt_facility.components.return_result.invoke_id.len = 1; + dst->param.dt_facility.components.return_result.invoke_id.id = src[offset++]; + + //sequence - O + if(src[offset] == 0x30) + { + dst->param.dt_facility.components.return_result.sequence.flag = 1; + dst->param.dt_facility.components.return_result.sequence.tag = src[offset++]; + dst->param.dt_facility.components.return_result.sequence.len = src[offset++]; + } + + //operation code - O + if(src[offset] == 0x02) + { + dst->param.dt_facility.components.return_result.opCode.flag = 1; + dst->param.dt_facility.components.return_result.opCode.tag = src[offset++]; + dst->param.dt_facility.components.return_result.opCode.len = src[offset++]; + memcpy(dst->param.dt_facility.components.return_result.opCode.op,&src[offset] + ,dst->param.dt_facility.components.invoke.opCode.len); + offset += dst->param.dt_facility.components.return_result.opCode.len; + } + //parameters - O + j = dst->param.dt_facility.components.return_result.len - + (3+2+dst->param.dt_facility.components.return_result.opCode.len); + if(1 == dst->param.dt_facility.components.return_result.sequence.flag) + { + dst->param.dt_facility.components.return_result.param.flag = 1; + memcpy(&dst->param.dt_facility.components.return_result.param.param,&src[offset], + dst->param.dt_facility.components.return_result.sequence.len); + offset += dst->param.dt_facility.components.return_result.sequence.len; + } + else if(j == 1) + { + dst->param.dt_facility.components.return_result.param.flag = 1; + dst->param.dt_facility.components.return_result.param.param[0] = src[offset++]; + } + } + //return error + if((offset < ie_len) && (src[offset] == 0xa3)) + { + dst->param.dt_facility.components.return_error.tag = src[offset++]; + dst->param.dt_facility.components.return_error.len = src[offset++]; + + //invoke_id - M + dst->param.dt_facility.components.return_error.invoke_id.tag = src[offset++]; + assert(src[offset++] == 1); + dst->param.dt_facility.components.return_error.invoke_id.len = 1; + dst->param.dt_facility.components.return_error.invoke_id.id = src[offset++]; + + //error code -M + dst->param.dt_facility.components.return_error.error.tag = src[offset++]; + dst->param.dt_facility.components.return_error.error.len = src[offset++]; + memcpy(dst->param.dt_facility.components.return_error.error.er,&src[offset],dst->param.dt_facility.components.return_error.error.len); + offset += dst->param.dt_facility.components.return_error.error.len; + + //parameters - O + j = dst->param.dt_facility.components.return_error.len - (3+2+dst->param.dt_facility.components.return_error.error.len); + assert(j == 1 || j == 0); + if(j == 1) + { + dst->param.dt_facility.components.return_error.param.flag = 1; + dst->param.dt_facility.components.return_error.param.param = src[offset++]; + } + } + // reject + if((offset < ie_len) && (src[offset] == 0xa4)) + { + + dst->param.dt_facility.components.reject.tag = src[offset++]; + dst->param.dt_facility.components.reject.len = src[offset++]; + + //invoke_id - M + dst->param.dt_facility.components.reject.invoke_id.tag = src[offset++]; + assert(src[offset++] == 1); + dst->param.dt_facility.components.reject.invoke_id.len = 1; + dst->param.dt_facility.components.reject.invoke_id.id = src[offset++]; + + //problem code -M + dst->param.dt_facility.components.reject.problem.tag = src[offset++]; + dst->param.dt_facility.components.reject.problem.len = src[offset++]; + memcpy(dst->param.dt_facility.components.reject.problem.pro,&src[offset],dst->param.dt_facility.components.reject.problem.len); + offset += dst->param.dt_facility.components.reject.problem.len; + } +*/ + break; + case AIFG_IE_ID_DT_BEARERCAP: + ie_len = src[offset++] + 1; + //octet 3 + dst->param.dt_bc.channel_require = (src[offset] & 0x60) >> 5; + dst->param.dt_bc.coding_std = (src[offset] & 0x10) >> 4; + dst->param.dt_bc.trans_mode = (src[offset] & 0x08) >> 3; + dst->param.dt_bc.info_trans_cap= src[offset] & 0x07; + if((0 == dst->param.dt_bc.info_trans_cap)){ + if(0 == (src[offset++] & 0x80)){ + //extended - octet 3a optional + aifg_set_field(dst->param.dt_bc.coding, (src[offset] & 0x40) >> 6); + aifg_set_field(dst->param.dt_bc.speech_ver, src[offset] & 0x0F); + } + } + else{ + if((offset < ie_len) && (0 != dst->param.dt_bc.info_trans_cap)){ + //not speech + //octet 4 + offset++; + aifg_set_field(dst->param.dt_bc.compress, (src[offset] & 0x40) >> 6); + aifg_set_field(dst->param.dt_bc.structure, (src[offset] & 0x30) >> 4); + aifg_set_field(dst->param.dt_bc.dupl_mode, (src[offset] & 0x08) >> 3); + aifg_set_field(dst->param.dt_bc.confiure, (src[offset] & 0x04) >> 2); + aifg_set_field(dst->param.dt_bc.nirr, (src[offset] & 0x02) >> 1); + aifg_set_field(dst->param.dt_bc.establishment, src[offset++]&0x01); + + //octet 5 + aifg_set_field(dst->param.dt_bc.rate_adaption, (src[offset] & 0x18) >> 3); + aifg_set_field(dst->param.dt_bc.signal_protocol, src[offset] & 0x07); + if(0 == (src[offset++] & 0x80)){ + //extended - octet 5a optional + aifg_set_field(dst->param.dt_bc.o_itc, (src[offset] & 0x60) >> 5); + aifg_set_field(dst->param.dt_bc.o_rate_adaption, (src[offset] & 0x18) >> 3); + + if(0 == (src[offset++] & 0x80)){ + //extended - octet 5b optional + aifg_set_field(dst->param.dt_bc.hdr_nohdr, (src[offset] & 0x40) >> 6); + aifg_set_field(dst->param.dt_bc.multi_frame, (src[offset] & 0x20) >> 5); + aifg_set_field(dst->param.dt_bc.mode, (src[offset] & 0x10) >> 4); + aifg_set_field(dst->param.dt_bc.lli, (src[offset] & 0x08) >> 3); + aifg_set_field(dst->param.dt_bc.assign_or_e, (src[offset] & 0x04) >> 2); + aifg_set_field(dst->param.dt_bc.inb_neg, (src[offset++] & 0x02) >> 1); + } + } + + //octet 6 + aifg_set_field(dst->param.dt_bc.layer1_id, 1); + aifg_set_field(dst->param.dt_bc.user_info1_protocol, (src[offset] & 0x1E) >> 1); + aifg_set_field(dst->param.dt_bc.sync_async, src[offset++] & 0x01); + + //extended - octet 6a mandatory + aifg_set_field(dst->param.dt_bc.num_stop_bits, (src[offset] & 0x40) >> 6); + aifg_set_field(dst->param.dt_bc.negotiation, (src[offset] & 0x20) >> 5); + aifg_set_field(dst->param.dt_bc.num_data_bits, (src[offset] & 0x10) >> 4); + aifg_set_field(dst->param.dt_bc.user_rate, src[offset++] & 0x0F); + + //extended - octet 6b mandatory + aifg_set_field(dst->param.dt_bc.intermed_rate, (src[offset] & 0x60) >> 5); + aifg_set_field(dst->param.dt_bc.nic_on_tx, (src[offset] & 0x10) >> 4); + aifg_set_field(dst->param.dt_bc.nic_on_rx, (src[offset] & 0x08) >> 3); + aifg_set_field(dst->param.dt_bc.parity, src[offset++] & 0x07); + + //extended - octet 6c mandatory + aifg_set_field(dst->param.dt_bc.connection_element, (src[offset] & 0x60) >> 5); + aifg_set_field(dst->param.dt_bc.modem_type, src[offset] & 0x1F); + + if(0 == (src[offset++] & 0x80)){ + //extended - octet 6d optional + aifg_set_field(dst->param.dt_bc.o_modem_type, (src[offset] & 0x60) >> 5); + aifg_set_field(dst->param.dt_bc.fixed_nw_user_rate, src[offset] & 0x1F); + + if(0 == (src[offset++] & 0x80)){ + //extended - octet 6e optional + aifg_set_field(dst->param.dt_bc.acceptable_chennel_code, (src[offset] & 0xF8) >> 3); + aifg_set_field(dst->param.dt_bc.max_traffic_channel, src[offset] & 0x07); + + if(0 == (src[offset++] & 0x80)){ + //extended - octet 6f optional + aifg_set_field(dst->param.dt_bc.uimi, (src[offset] & 0x70) >> 4); + aifg_set_field(dst->param.dt_bc.wanted_air_if_user_rate, src[offset] & 0x0F); + } + } + } + + if(++offset < ie_len){ + //extended - octet 7 optional + aifg_set_field(dst->param.dt_bc.layer2_id, 2); + aifg_set_field(dst->param.dt_bc.user_info2_protocol, src[offset] & 0x1F); + } + } + } + break; + case AIFG_IE_ID_DT_CIPHERKEY: + if(hi_lo_flag == AIFG_LOW_BITS) //At low 4 bits + dst->param.dt_cipherKey.value = src[offset] & 0x0F; + else //At high 4 bits + dst->param.dt_cipherKey.value = (src[offset] & 0xF0) >> 4; + break; + case AIFG_IE_ID_DT_LAI: + dst->param.dt_lai.mcc[0] = src[offset] & 0x0F; + dst->param.dt_lai.mcc[1] = (src[offset++] & 0xF0) >> 4; + dst->param.dt_lai.mcc[2] = src[offset] & 0x0F; + dst->param.dt_lai.mnc[2] = (src[offset++] & 0xF0) >> 4; + dst->param.dt_lai.mnc[1] = (src[offset] & 0xF0) >> 4; + dst->param.dt_lai.mnc[0] = src[offset++] & 0x0F; + dst->param.dt_lai.LAC = (src[offset] << 8) | src[offset+1]; + break; + case AIFG_IE_ID_DT_MOBILEID: + MOBILE_ID: + ie_len = src[offset++] + 1; + dst->param.mobileId.type = src[offset] & 0x07; + dst->param.mobileId.odd_even_flag = (src[offset] & 0x08) >> 3; + i = 0; + if(dst->param.mobileId.type == 4)//TMSI + offset++; + else + dst->param.mobileId.id[i++] = (src[offset++] & 0xf0)>>4; + + while(offset < ie_len){ + dst->param.mobileId.id[i++] = src[offset] & 0x0F; + dst->param.mobileId.id[i++] = (src[offset] & 0xF0) >> 4; + offset++; + } + if(0 == dst->param.mobileId.odd_even_flag) + dst->param.mobileId.id_len = i-1; + else + dst->param.mobileId.id_len = i; + break; + case AIFG_IE_ID_DT_MSCM1: + CLASSMARK_TYPE_1: + dst->param.dt_cmInfo2.rev_level = (src[offset] & 0x60) >> 5; + dst->param.dt_cmInfo2.es_ind = (src[offset] & 0x10) >> 4; + dst->param.dt_cmInfo2.a5_1 = (src[offset] & 0x08) >> 3; + dst->param.dt_cmInfo2.rf_power_cap = src[offset] & 0x07; + break; + case AIFG_IE_ID_DT_MSCM2: + CLASSMARK_TYPE_2: + offset++; + dst->param.dt_cmInfo2.rev_level = (src[offset] & 0x60) >> 5; + dst->param.dt_cmInfo2.es_ind = (src[offset] & 0x10) >> 4; + dst->param.dt_cmInfo2.a5_1 = (src[offset] & 0x08) >> 3; + dst->param.dt_cmInfo2.rf_power_cap = src[offset++] & 0x07; + dst->param.dt_cmInfo2.ps_cap = (src[offset] & 0x40) >> 6; + dst->param.dt_cmInfo2.ss_screen_ind = (src[offset] & 0x30) >> 4; + dst->param.dt_cmInfo2.sm_cap = (src[offset] & 0x08) >> 3; + dst->param.dt_cmInfo2.vbs = (src[offset] & 0x04) >> 2; + dst->param.dt_cmInfo2.vgcs = (src[offset] & 0x02) >> 1; + dst->param.dt_cmInfo2.fc = src[offset++] & 0x01; + dst->param.dt_cmInfo2.cm3 = (src[offset] & 0x80) >> 7; + dst->param.dt_cmInfo2.lcsva_cap = (src[offset] & 0x20) >> 5; + dst->param.dt_cmInfo2.so_lsa = (src[offset] & 0x08) >> 3; + dst->param.dt_cmInfo2.cmsp = (src[offset] & 0x04) >> 2; + dst->param.dt_cmInfo2.a5_3= (src[offset] & 0x02) >> 1; + dst->param.dt_cmInfo2.a5_2= src[offset++] & 0x01; + break; + case AIFG_IE_ID_DT_MSCM3: + //Not implemented yet + CLASSMARK_TYPE_3: + break; + case AIFG_IE_ID_DT_GROUPREF: + GROUP_CALL_REF: + + i = src[offset++]; + i = (i << 8) | src[offset++]; + i = (i << 8) | src[offset++]; + i = (i << 3) | ((src[offset] & 0xE0) >> 5); + dst->param.dt_broadcastRef.binary_code = i; + dst->param.dt_broadcastRef.sf = (src[offset] & 0x10) >> 4; + dst->param.dt_broadcastRef.af = (src[offset] & 0x08) >> 3; + dst->param.dt_broadcastRef.call_priority = src[offset++] & 0x07; + dst->param.dt_broadcastRef.cipher_info = (src[offset] & 0xF0) >> 4; + break; + case AIFG_IE_ID_DT_PRIORITYLEVEL: + if(hi_lo_flag == AIFG_LOW_BITS) //At low 4 bits + dst->param.dt_priority.value = src[offset] & 0x07; + else //At high 4 bits + dst->param.dt_priority.value = (src[offset] & 0x70) >> 4; + break; + case AIFG_IE_ID_DT_AUTHRAND: + memcpy(dst->param.dt_authRAND.value, &(src[offset]), 16); + break; + case AIFG_IE_ID_DT_AUTHSRES: + memcpy(dst->param.dt_authSRES.value, &(src[offset]), 4); + break; + case AIFG_IE_ID_DT_CMTYPE: + if(hi_lo_flag == AIFG_LOW_BITS) //At low 4 bits + dst->param.dt_cmType.value = src[offset] & 0x0F; + else //At high 4 bits + dst->param.dt_cmType.value = (src[offset] & 0xF0) >> 4; + break; + case AIFG_IE_ID_DT_IDTYPE: + if(hi_lo_flag == AIFG_LOW_BITS) //At low 4 bits + dst->param.dt_idType.value = src[offset] & 0x07; + else //At high 4 bits + dst->param.dt_idType.value = (src[offset] & 0x70) >> 4; + break; + case AIFG_IE_ID_DT_LUTYPE: + if(hi_lo_flag == AIFG_LOW_BITS){ + //at low 4 bits + dst->param.dt_luType.fo_req = (src[offset] & 0x08) >> 3; + dst->param.dt_luType.lut = src[offset] & 0x03; + } + else{ + //at high 4 bits + dst->param.dt_luType.fo_req = (src[offset] & 0x80) >> 7; + dst->param.dt_luType.lut = (src[offset] & 0x30) >> 4; + } + break; + case AIFG_IE_ID_DT_FULL_NWNAME: + case AIFG_IE_ID_DT_SHORT_NWNAME: + ie_len = src[offset++] + 1; + dst->param.dt_nwName.code_scheme = (src[offset] & 0x70) >> 4; + dst->param.dt_nwName.add_ci = (src[offset] & 0x08) >> 4; + dst->param.dt_nwName.spare_num = src[offset++] & 0x07; + dst->param.dt_nwName.text_len = ie_len - offset; + memcpy(dst->param.dt_nwName.text, &(src[offset]), dst->param.dt_nwName.text_len); + break; + case AIFG_IE_ID_DT_REJCAUSE: + dst->param.dt_rejectCause.value = src[offset]; + break; + case AIFG_IE_ID_DT_FLONPROCEED: +// dst->param.dt_followOnProceed.value = 1; + break; + case AIFG_IE_ID_DT_TIMEZONE: + dst->param.dt_timeZone.value = src[offset]; + break; + case AIFG_IE_ID_DT_TZTIME: + dst->param.dt_tzTime.year = src[offset++]; + dst->param.dt_tzTime.month = src[offset++]; + dst->param.dt_tzTime.day = src[offset++]; + dst->param.dt_tzTime.hour = src[offset++]; + dst->param.dt_tzTime.minute = src[offset++]; + dst->param.dt_tzTime.second= src[offset++]; + dst->param.dt_tzTime.time_zone = src[offset++]; + break; + case AIFG_IE_ID_DT_CTS: +// dst->param.dt_CTSPermission.value = 1; + break; + case AIFG_IE_ID_DT_LSAID: + LSAID: + offset++; + dst->param.dt_lsaId.value[0] = src[offset++]; + dst->param.dt_lsaId.value[1] = src[offset++]; + dst->param.dt_lsaId.value[2] = src[offset++]; + break; + case AIFG_IE_ID_DT_AUXSTAT: + offset++; + dst->param.dt_auxStat.hold_stat = (src[offset] & 0x0C) >> 2; + dst->param.dt_auxStat.mpty_stat = src[offset] & 0x03; + break; + case AIFG_IE_ID_DT_CCCAP: + offset++; + dst->param.dt_ccCap.pcp = (src[offset] & 0x02) >> 1; + dst->param.dt_ccCap.dtmf = src[offset] & 0x01; + break; + case AIFG_IE_ID_DT_CALLSTAT: + dst->param.dt_callStat.coding_std = (src[offset] & 0xC0) >> 6; + dst->param.dt_callStat.value = src[offset] & 0x3F; + break; + case AIFG_IE_ID_DT_CALLEDBCD: + case AIFG_IE_ID_DT_CALLERBCD: + case AIFG_IE_ID_DT_CONNNUM: + case AIFG_IE_ID_DT_REDIRBCD: + ie_len = src[offset++] + 1; + dst->param.dt_callingNum.type = (src[offset] & 0x70) >> 4; + dst->param.dt_callingNum.num_plan= src[offset] & 0x0F; + if(0x00 == (src[offset++] & 0x80)){ + //ext == 0 + dst->param.dt_callingNum.presentation_ind.flag = 1; + dst->param.dt_callingNum.presentation_ind.value = (src[offset] & 0x60) >> 5; + dst->param.dt_callingNum.screen_ind.flag = 1; + dst->param.dt_callingNum.screen_ind.value = src[offset++] & 0x03; + } + i = 0; + while(offset < ie_len){ + int j; + assert(offset < 43); //43 is the max length + dst->param.dt_callingNum.number[i] = src[offset] & 0x0F; + if (dst->param.dt_callingNum.number[i] == 10 || dst->param.dt_callingNum.number[i] == 11){ + //convert '*' & '#' to the ISUP code standard + dst->param.dt_callingNum.number[i]++; + } + i++; + + j = (src[offset++] & 0xF0) >> 4; + if(j != 0x0F){ + dst->param.dt_callingNum.number[i] = j; + if (dst->param.dt_callingNum.number[i] == 10 || dst->param.dt_callingNum.number[i] == 11){ + //convert '*' & '#' to the ISUP code standard + dst->param.dt_callingNum.number[i]++; + } + i++; + } + } + dst->param.dt_callingNum.num_len = i; + break; + case AIFG_IE_ID_DT_CALLEDSUBADDR: + case AIFG_IE_ID_DT_CALLERSUBADDR: + case AIFG_IE_ID_DT_CONNSUBADDR: + case AIFG_IE_ID_DT_REDIRSUBADDR: + ie_len = src[offset++] + 1; + dst->param.dt_callingSubAddr.type = (src[offset] & 0x70) >> 4; + dst->param.dt_callingSubAddr.odd_even_ind = (src[offset++] & 0x08) >> 3; + dst->param.dt_callingSubAddr.info_len = ie_len - offset; + memcpy(dst->param.dt_callingSubAddr.info, &(src[offset]), dst->param.dt_callingSubAddr.info_len); + break; + case AIFG_IE_ID_DT_CAUSE: + ie_len = src[offset++] + 1; + dst->param.dt_cause.coding_std = (src[offset] & 0x60) >> 5; + dst->param.dt_cause.location = src[offset] & 0x0F; + if(0x00 == (src[offset++] & 0x80)){ + //ext == 0 + dst->param.dt_cause.recommendation.flag = 1; + dst->param.dt_cause.recommendation.value = src[offset++]; + } + dst->param.dt_cause.cause_value = src[offset++] & 0x7F; + dst->param.dt_cause.diag_len = ie_len - offset; + memcpy(dst->param.dt_cause.diagnostic, &(src[offset]), dst->param.dt_cause.diag_len); + break; + case AIFG_IE_ID_DT_CONGESTLEVEL: + if(hi_lo_flag == AIFG_LOW_BITS) //At low 4 bits + dst->param.dt_congestLevel.value = src[offset] & 0x0F; + else //At high 4 bits + dst->param.dt_congestLevel.value = (src[offset] & 0xF0) >> 4; + break; + case AIFG_IE_ID_DT_HIGHCOM: + ie_len = src[offset++] + 1; + if(offset < ie_len){ + aifg_set_field(dst->param.dt_hiComp.coding_std, (src[offset] & 0x60) >> 5); + aifg_set_field(dst->param.dt_hiComp.interpret, (src[offset] & 0x1C) >> 2); + aifg_set_field(dst->param.dt_hiComp.presentat_method, src[offset++] & 0x03); + aifg_set_field(dst->param.dt_hiComp.high_layer_id, src[offset]&0x7f); + if(0x00 == (src[offset++] & 0x80)){ + //ext == 0 + aifg_set_field(dst->param.dt_hiComp.ext_high_layer_id, src[offset]&0x7f); + } + } + break; + case AIFG_IE_ID_DT_KEYPAD: + dst->param.dt_keypad.value = src[offset] & 0x7F; + break; + case AIFG_IE_ID_DT_LOWCOM: + ie_len = src[offset++] + 1; + dst->param.dt_loComp.data_len = ie_len - offset; + memcpy(dst->param.dt_loComp.data, &(src[offset]), dst->param.dt_loComp.data_len); + break; + case AIFG_IE_ID_DT_MOREDATA: +// dst->param.dt_moreData.value = 1; + break; + case AIFG_IE_ID_DT_NOTIIND: + dst->param.dt_notificationInd.value = src[offset] & 0x7F; + break; + case AIFG_IE_ID_DT_PROGIND: + offset++; //skip length + dst->param.dt_progInd.coding_standard = (src[offset] & 0x60) >> 5; + dst->param.dt_progInd.location = src[offset++] & 0x0F; + dst->param.dt_progInd.desc = src[offset] & 0x7F; + break; + case AIFG_IE_ID_DT_REPEATIND: + if(hi_lo_flag == AIFG_LOW_BITS) + //low 4 bits + dst->param.dt_rpInd.value = src[offset] & 0x0F; + else + //high 4 bits + dst->param.dt_rpInd.value = (src[offset] & 0xF0) >> 4; + break; + case AIFG_IE_ID_DT_REVCALLDIR: +// dst->param.dt_revCallDir.value = 1; + break; + case AIFG_IE_ID_DT_SIGNAL: + dst->param.dt_signal.value = src[offset]; + break; + case AIFG_IE_ID_DT_SSVER: + ie_len = src[offset++] + 1; + dst->param.dt_ssVer.info_len = ie_len - offset; + memcpy(dst->param.dt_ssVer.info, &(src[offset]), dst->param.dt_ssVer.info_len); + break; + case AIFG_IE_ID_DT_USERUSER: + ie_len = src[offset++] + 1; + dst->param.dt_uu.pd = src[offset++]; + dst->param.dt_uu.info_len = ie_len - offset; + memcpy(dst->param.dt_uu.info, &(src[offset]), dst->param.dt_uu.info_len); + break; + case AIFG_IE_ID_DT_ALERTPATTERN: + offset++; + dst->param.dt_alertPattern.value = src[offset] & 0x0F; + break; + case AIFG_IE_ID_DT_RP_MO_ADDR: + case AIFG_IE_ID_DT_RP_MT_ADDR: + ie_len = src[offset++] + 1; + if (0 != ie_len){ + dst->param.dt_rpAddr.flag = 1; + dst->param.dt_rpAddr.number_type = (src[offset] & 0x70) >> 4; + dst->param.dt_rpAddr.number_plan = src[offset++] & 0x0F; + dst->param.dt_rpAddr.number_len = ie_len - offset; + memcpy(dst->param.dt_rpAddr.number, src+offset, dst->param.dt_rpAddr.number_len); + } + break; + case AIFG_IE_ID_DT_RP_UD: + dst->param.dt_rpUD.len = src[offset]; + ie_len = src[offset++] + 1 ; + memcpy(dst->param.dt_rpUD.content, src+offset, dst->param.dt_rpUD.len); + break; + case AIFG_IE_ID_DT_RP_CAUSE: + ie_len = src[offset++] + 1; + dst->param.dt_rpCause.cause = src[offset++] & 0x7F; + if(ie_len - offset > 0){ + dst->param.dt_rpCause.diag_len = ie_len - offset; + memcpy(dst->param.dt_rpCause.diagnostic, src+offset, dst->param.dt_rpCause.diag_len); + } + break ; + + //BSSMAP + case AIFG_IE_ID_BM_BSSOLDTONEW: + ie_len = src[offset++] + 1; + dst->param.bm_bssOldtoNew.len = ie_len - offset; + memcpy(dst->param.bm_bssOldtoNew.content, &(src[offset]), dst->param.bm_bssOldtoNew.len); + break; + case AIFG_IE_ID_BM_OMCID: + ie_len = src[offset++] + 1; + dst->param.bm_omcId.len = ie_len - offset; + memcpy(dst->param.bm_omcId.id, &(src[offset]), dst->param.bm_omcId.len); + break; + case AIFG_IE_ID_BM_CIC: + dst->param.bm_cic.pcm = (src[offset] << 3) | ((src[offset+1] & 0xE0) >> 5); + dst->param.bm_cic.timeslot = src[++offset] & 0x1F; + break; + case AIFG_IE_ID_BM_RESOURCEAVAIL: + i = 0; + while(i < 5){ + dst->param.bm_resrcAvail.full_rate_channel[i] = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_resrcAvail.half_rate_channel[i] = (src[offset] << 8) | src[offset+1]; + offset += 2; + i++; + } + break; + case AIFG_IE_ID_BM_CAUSE: + offset++; //skip length + dst->param.bm_cause.value = src[offset] & 0x7F; + if(0x80 == (src[offset] & 0x80)){ + //has ext value + aifg_set_field(dst->param.bm_cause.ext_value, src[++offset]); + } + break; + case AIFG_IE_ID_BM_CELLID: + offset++; //skip length + dst->param.bm_cellId.discriminator = src[offset++] & 0x0F; + switch(dst->param.bm_cellId.discriminator){ + case 0x00: //The whole Cell Global Identification, CGI, is used to identify the cell + dst->param.bm_cellId.mcc[0] = src[offset] & 0x0F; + dst->param.bm_cellId.mcc[1] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellId.mcc[2] = src[offset] & 0x0F; + dst->param.bm_cellId.mnc[2] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellId.mnc[1] = (src[offset] & 0xF0) >> 4; + dst->param.bm_cellId.mnc[0] = src[offset++]& 0x0F; + dst->param.bm_cellId.LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellId.CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + break; + case 0x01: //Location Area Code, LAC, and Cell Identity, CI, is used to identify the cell + dst->param.bm_cellId.LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellId.CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + break; + case 0x02: //Cell Identity, CI, is used to identify the cell + dst->param.bm_cellId.CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + break; + case 0x03: //No cell is associated with the transaction + break; + default: //Error IE + aifg_event = AIFG_ERR_ERROR_IE; + goto ERR_PROC; + break; + } + break; + case AIFG_IE_ID_BM_PRIORITY: + offset++; + dst->param.bm_priority.pci = (src[offset] & 0x40) >> 6; + dst->param.bm_priority.level = (src[offset] & 0x3C) >> 2; + dst->param.bm_priority.qa = (src[offset] & 0x02) >> 1; + dst->param.bm_priority.pvi = src[offset] & 0x01; + break; + case AIFG_IE_ID_BM_L3HEADERINFO: + offset++; + dst->param.bm_L3HeaderInfo.pd = src[offset++]; + dst->param.bm_L3HeaderInfo.ti = src[offset]; + break; + case AIFG_IE_ID_BM_IMSI: + case AIFG_IE_ID_BM_MOBILEID: + goto MOBILE_ID; //The same as Mobile ID of DTAP + break; + case AIFG_IE_ID_BM_TMSI: + offset++; //skip length + memcpy(dst->param.bm_tmsi.value, &(src[offset]), 4); + break; + case AIFG_IE_ID_BM_ENCRYPTINFO: + offset++; //skip length + dst->param.bm_encryptInfo.algorithm = src[offset++]; + if(dst->param.bm_encryptInfo.algorithm > 1){ + //at least one of the A5 encryption algorithms is permitted + memcpy(dst->param.bm_encryptInfo.key, &(src[offset]), 8); + } + break; + case AIFG_IE_ID_BM_CHANNELTYPE: + offset++; //skip length + dst->param.bm_channelType.speech_data_ind = src[offset++] & 0x0F; + dst->param.bm_channelType.channel_rate_type = src[offset++]; + if(0x01 == dst->param.bm_channelType.speech_data_ind){ + //Speech + j = 0; + do{ + i = src[offset] & 0x80; //ext flag + dst->param.bm_channelType.ext.speech.ver[j++] = src[offset++] & 0x7F; + }while(0x80 == i && j < 6); + dst->param.bm_channelType.ext.speech.len = j; + } + else if(0x02 == dst->param.bm_channelType.speech_data_ind){ + //data + dst->param.bm_channelType.ext.data_cfg.t_nt = src[offset] & 0x40 >> 6; + dst->param.bm_channelType.ext.data_cfg.rate = src[offset] & 0x3F; + if(0x80==(src[offset++]&0x80)) + aifg_set_field(dst->param.bm_channelType.ext.data_cfg.allowed_data_rate,src[offset] & 0x0F); + } + break; + case AIFG_IE_ID_BM_PERIODICITY: + dst->param.bm_periodicity.value = src[offset]; + break; + case AIFG_IE_ID_BM_EXTRESOURCEIND: + dst->param.bm_extResrcInd.sm = (src[offset] & 0x02) >> 1; + dst->param.bm_extResrcInd.tarr = src[offset] & 0x01; + break; + case AIFG_IE_ID_BM_MSNUM: + dst->param.bm_msNum.value = src[offset]; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO1: + goto CLASSMARK_TYPE_1; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO2: + goto CLASSMARK_TYPE_2; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO3: + goto CLASSMARK_TYPE_3; + break; + case AIFG_IE_ID_BM_BANDUSED: + dst->param.bm_bandUsed.value = src[offset]; + break; + case AIFG_IE_ID_BM_RRCAUSE: + dst->param.bm_rrCause.value = src[offset]; + break; + case AIFG_IE_ID_BM_L3INFO: + case AIFG_IE_ID_BM_L3MSGCONTENT: + //Nothing to do + break; + case AIFG_IE_ID_BM_DLCI: + dst->param.bm_dlci.value = src[offset]; + break; + case AIFG_IE_ID_BM_DTXFLAG: + dst->param.bm_dtx.value = src[offset]; + break; + case AIFG_IE_ID_BM_CELLIDLIST: + ie_len = src[offset++] + 2; + dst->param.bm_cellIdList.discriminator = src[offset++] & 0x0F; + i = 0; + while(offset < ie_len){ + switch(dst->param.bm_cellId.discriminator){ + case 0x00: //The whole Cell Global Identification, CGI, is used to identify the cell + dst->param.bm_cellIdList.cell_id[i].mcc[0] = src[offset] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].mcc[1] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mcc[2] = src[offset] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].mnc[2] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mnc[1] = (src[offset] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mnc[0] = src[offset++] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cell_id[i].CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cid_num=(ie_len-3)/7; + break; + case 0x01: //Location Area Code, LAC, and Cell Identity, CI, is used to identify the cell + dst->param.bm_cellIdList.cell_id[i].LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cell_id[i].CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cid_num=(ie_len-3)/4; + break; + case 0x02: //Cell Identity, CI, is used to identify the cell + dst->param.bm_cellIdList.cell_id[i].CI = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cid_num=(ie_len-3)/2; + break; + case 0x04: + dst->param.bm_cellIdList.cell_id[i].mcc[0] = src[offset] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].mcc[1] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mcc[2] = src[offset] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].mnc[2] = (src[offset++] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mnc[1] = (src[offset] & 0xF0) >> 4; + dst->param.bm_cellIdList.cell_id[i].mnc[0] = src[offset++] & 0x0F; + dst->param.bm_cellIdList.cell_id[i].LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cid_num=(ie_len-3)/5; + break; + case 0x05: + dst->param.bm_cellIdList.cell_id[i].LAC = (src[offset] << 8) | src[offset+1]; + offset += 2; + dst->param.bm_cellIdList.cid_num=(ie_len-3)/2; + break; + case 0x03: //No cell is associated with the transaction + //Should never get into this while loop, fatal error if the program gets here + assert(0); + break; + default: //Error IE + aifg_event = AIFG_ERR_ERROR_IE; + goto ERR_PROC; + break; + } + i++; + } + break; + case AIFG_IE_ID_BM_RESPREQ: +// dst->param.bm_respReq.value = 1; + break; + case AIFG_IE_ID_BM_RESOURCEINDMEHTOD: + dst->param.bm_resrcIndMethod.value = src[offset] & 0x0F; + break; + case AIFG_IE_ID_BM_CICLIST: + ie_len = src[offset++] + 1; + dst->param.bm_cicList.range = src[offset++]; + dst->param.bm_cicList.status.len = ie_len - offset; + memcpy(dst->param.bm_cicList.status.content, &(src[offset]), dst->param.bm_cicList.status.len); + break; + case AIFG_IE_ID_BM_DIGNOSTIC: + ie_len = src[offset++] + 1; + dst->param.bm_diagnostics.err_pointer = src[offset++]; + dst->param.bm_diagnostics.bit_pointer = src[offset++] & 0x0F; + dst->param.bm_diagnostics.err_msg.len = ie_len - offset; + memcpy(dst->param.bm_diagnostics.err_msg.msg, &(src[offset]), dst->param.bm_diagnostics.err_msg.len); + break; + case AIFG_IE_ID_BM_CHOSENCHANNEL: + dst->param.bm_chosenChannel.mode = (src[offset] & 0xF0) >> 4; + dst->param.bm_chosenChannel.channel = src[offset] & 0x0F; + break; + case AIFG_IE_ID_BM_TOTALRESOURCE: + dst->param.bm_totalResrc.full_rate_channel = (src[0] << 8) | src[1]; + dst->param.bm_totalResrc.half_rate_channel = (src[2] << 8) | src[3]; + break; + case AIFG_IE_ID_BM_CIPHERRESPMODE: + dst->param.bm_cipherRespMode.value = src[offset]; + break; + case AIFG_IE_ID_BM_CHANNELNEEDED: + dst->param.bm_channelNeeded.value = src[offset] & 0x03; + break; + case AIFG_IE_ID_BM_TRACETYPE: + dst->param.bm_traceType.value = src[offset]; + break; + case AIFG_IE_ID_BM_TRIGGERID: + ie_len = src[offset++] + 1; + dst->param.bm_triggerId.len = ie_len - offset; + memcpy(dst->param.bm_triggerId.content, &(src[offset]), dst->param.bm_triggerId.len); + break; + case AIFG_IE_ID_BM_TRACEREF: + dst->param.bm_traceRef.value = (src[0] << 8) | src[1]; + break; + case AIFG_IE_ID_BM_TRANSACTIONID: + ie_len = src[offset++] + 1; + dst->param.bm_transId.value = src[offset++]; + dst->param.bm_transId.value = (dst->param.bm_transId.value << 8) | src[offset]; + break; + case AIFG_IE_ID_BM_FORWARDIND: + dst->param.bm_fowardInd.value = src[offset] & 0x0F; + break; + case AIFG_IE_ID_BM_CHOSENENCRYPT: + dst->param.bm_chosenEncrypt.value = src[offset]; + break; + case AIFG_IE_ID_BM_CIRCUITPOOL: + dst->param.bm_circuitPool.value = src[offset]; + break; + case AIFG_IE_ID_BM_CIRCUITPOOLLIST: + ie_len = src[offset++] + 1; + dst->param.bm_circuitPoolList.num = ie_len - offset; + memcpy(dst->param.bm_circuitPoolList.circuit, &(src[offset]), + dst->param.bm_circuitPoolList.num); + break; + case AIFG_IE_ID_BM_TIMEIND: + dst->param.bm_timeId.value = src[offset]; + break; + case AIFG_IE_ID_BM_RESOURCESITUATION: + ie_len = src[offset++] + 1; + i = 0; + while(offset < ie_len){ + dst->param.bm_resrcSit.band[i].band_ind = (src[offset] & 0xF0) >> 4; + dst->param.bm_resrcSit.band[i].channel_type = src[offset++] & 0x0F; + dst->param.bm_resrcSit.band[i].channel_num = src[offset] & 0x7F; + if(0x80 == (src[offset] & 0x80)){ + //two octets + dst->param.bm_resrcSit.band[i].channel_num = + (dst->param.bm_resrcSit.band[i].channel_num << 8) | src[++offset]; + } + i++; + offset++; + } + dst->param.bm_resrcSit.band_num = i; + break; + case AIFG_IE_ID_BM_CURCHANNELTYPE1: + dst->param.bm_curChannelType1.channel_mode = (src[offset] & 0xF0) >> 4; + dst->param.bm_curChannelType1.channel = src[offset] & 0x0F; + break; + case AIFG_IE_ID_BM_QUEUEIND: + dst->param.bm_queuingInd.value = (src[offset] & 0x02) >> 1; + break; + case AIFG_IE_ID_BM_SPEECHVER: + dst->param.bm_speechVer.value = src[offset] & 0x7F; + break; + case AIFG_IE_ID_BM_ASSIGNREQUIREMENT: + dst->param.bm_assignReq.value = src[offset]; + break; + case AIFG_IE_ID_BM_TALKERFLAG: +// dst->param.bm_talkerFlag.value = 1; + break; + case AIFG_IE_ID_BM_CONNRELREQ: +// dst->param.bm_connRelReq.value = 1; + break; + case AIFG_IE_ID_BM_GROUPCALLREF: + offset++; + goto GROUP_CALL_REF; //The same as Group call refernce of DTAP + break; + case AIFG_IE_ID_BM_EMLPP: + dst->param.bm_eMLPP.value = src[offset] & 0x07; + break; + case AIFG_IE_ID_BM_CFGEVOIND: + dst->param.bm_cfgEvoInd.value = src[offset] & 0x0F; + break; + case AIFG_IE_ID_BM_LSAID: + goto LSAID; + break; + case AIFG_IE_ID_BM_LSAIDLIST: + ie_len = src[offset++] + 1; + dst->param.bm_lsaIdList.ep = src[offset++] & 0x01; + i = 0; + while(offset < ie_len){ + dst->param.bm_lsaIdList.list[i].id[0] = src[offset++]; + dst->param.bm_lsaIdList.list[i].id[1] = src[offset++]; + dst->param.bm_lsaIdList.list[i++].id[2] = src[offset++]; + } + dst->param.bm_lsaIdList.lsa_num = i; + break; + case AIFG_IE_ID_BM_LSAINFO: + ie_len = src[offset++] + 1; + dst->param.bm_lsaInfo.lsa_only= src[offset++] & 0x01; + i = 0; + while(offset < ie_len){ + dst->param.bm_lsaInfo.info[i].priority = src[offset++] & 0x0F; + dst->param.bm_lsaInfo.info[i].id[0] = src[offset++]; + dst->param.bm_lsaInfo.info[i].id[1] = src[offset++]; + dst->param.bm_lsaInfo.info[i++].id[2] = src[offset++]; + } + dst->param.bm_lsaInfo.lsa_num = i; + break; + case AIFG_IE_ID_BM_LOCATIONINFO: + ie_len = src[offset++] + 1; + dst->param.bm_locInfo.len = ie_len - offset; + memcpy(dst->param.bm_locInfo.info, &(src[offset]), dst->param.bm_locInfo.len); + break; + default: //Unknow IE + aifg_event = AIFG_ERR_UNKNOW_IE; + goto ERR_PROC; + break; + } + + return AIFG_SUCCEED; + +ERR_PROC: +// aifg_debug_print(aifg_event, (void*)src, NULL); + return AIFG_ERROR; +} + +/* +Name: aifg_ie_encode +Purpose: Information element encode function +Input: aifg_msg_protocol protocol: BSSMAP or DTAP + aifg_ie *src: pointer to a aifg_ie structure object in which the decoded message will be encoded. + BYTE *dst: pointer to the first byte of encode buffer + int m_o_flag: flag used when encode DTAP IEs that indicates whether the ie is mandatory or optional, + and if mandatory, the value part presents at high 4bits or low 4bits or not care. + 0 - BSSMAP IE or Mandatory DTAP IE, low bits or whole byte + 1 - Mandatory, high bits + 2 - Optional +Output: Total length of decoded IE +*/ +int aifg_ie_encode(aifg_msg_protocol protocol, int ie_id, ie_u *src, BYTE *dst, int m_o_flag) +{ + int i, j, k, offset = 0; + int length_position; + //checking parameter + if((protocol != AIFG_MSG_BSSMAP && protocol != AIFG_MSG_DTAP) + || src == NULL || dst == NULL) + { + assert(0); + goto ERR_PROC; + } + + switch(protocol){ + case AIFG_MSG_DTAP: + if(m_o_flag == 2){ + //Optional ie, iei must present + //convert program ie_id to protocol iei + dst[offset++] = aifg_get_iei(ie_id); + } + + switch(ie_id){ + case AIFG_IE_ID_DT_MOBILEID: + MOBILE_ID: + src->mobileId.odd_even_flag = src->mobileId.id_len & 0x01; //set odd/even flag + dst[offset++]=(src->mobileId.id_len/2)+1; + if (src->mobileId.type == 4)//TMSI + { + dst[offset++]= 0xf0|(src->mobileId.odd_even_flag<<3)|(src->mobileId.type); + i=0; + } + else + { + dst[offset++]=(src->mobileId.id[0]<<4)|(src->mobileId.odd_even_flag<<3)|(src->mobileId.type); + i=1; + } + + if(src->mobileId.odd_even_flag==0){ + while(imobileId.id_len-1){ + dst[offset++] = (src->mobileId.id[i+1]<<4)|src->mobileId.id[i]; + i += 2; + } + dst[offset++] = 0xf0|src->mobileId.id[i]; + } + else{ + while(imobileId.id_len){ + dst[offset++] = (src->mobileId.id[i+1]<<4)|src->mobileId.id[i]; + i += 2; + } + } + break; + case AIFG_IE_ID_DT_LAI: + dst[offset++] = (src->dt_lai.mcc[1] << 4) | src->dt_lai.mcc[0]; + dst[offset++] = (src->dt_lai.mnc[2] << 4) | src->dt_lai.mcc[2]; + dst[offset++] = (src->dt_lai.mnc[1] << 4) | src->dt_lai.mnc[0]; + dst[offset++] = src->dt_lai.LAC >> 8; + dst[offset++] = src->dt_lai.LAC; + break; + case AIFG_IE_ID_DT_CIPHERKEY: + case AIFG_IE_ID_DT_PRIORITYLEVEL: + case AIFG_IE_ID_DT_CMTYPE: + case AIFG_IE_ID_DT_IDTYPE: + case AIFG_IE_ID_DT_REPEATIND: + if(m_o_flag == 2){ + offset--; //the iei of this ie has only half-octet + dst[offset] = dst[offset] | src->dt_cipherKey.value; + offset++; + } + else if(m_o_flag == 0) + dst[offset] = src->dt_cipherKey.value; + else if(m_o_flag == 1){ + dst[offset] = (dst[offset] & 0x0F) | src->dt_cipherKey.value << 4; + offset++; + } + break; + case AIFG_IE_ID_DT_MSCM1: + dst[offset++] = (src->dt_cmInfo1.rev_level<<5)|(src->dt_cmInfo1.es_ind<<4)|(src->dt_cmInfo1.a5_1<<3)|(src->dt_cmInfo1.rf_power_cap); + break; + case AIFG_IE_ID_DT_MSCM2: + goto classmarkinfo2; + break; + case AIFG_IE_ID_DT_GROUPREF: + goto groupref; + break; +// case AIFG_IE_ID_DT_PRIORITYLEVEL: +// dst[offset++]=src->dt_priority.value;//iei half octet lost +// break; + case AIFG_IE_ID_DT_AUTHRAND: + memcpy(&dst[offset],src->dt_authRAND.value,16); + offset+=16; + break; + case AIFG_IE_ID_DT_AUTHSRES: + memcpy(&dst[offset],src->dt_authSRES.value,4); + offset+=4; + break; +// case AIFG_IE_ID_DT_CMTYPE: +// dst[offset++]=src->dt_cmType.value;//iei half octet lost +// break; +// case AIFG_IE_ID_DT_IDTYPE: +// dst[offset++]=src->dt_idType.value;//iei half octet lost +// break; + case AIFG_IE_ID_DT_LUTYPE://zhugq,in case of 'O' + if(m_o_flag == 2){ + offset--; //the iei of this ie has only half-octet + dst[offset] = dst[offset] | (src->dt_luType.fo_req<<3) | src->dt_luType.lut; + offset++; + } + else if(m_o_flag == 0) + dst[offset] = (src->dt_luType.fo_req<<3) | src->dt_luType.lut; + else if(m_o_flag == 1){ + dst[offset] = (dst[offset] & 0x0F) | (src->dt_luType.fo_req<<7) | src->dt_luType.lut<<4; + offset++; + } + break; + case AIFG_IE_ID_DT_FULL_NWNAME: + case AIFG_IE_ID_DT_SHORT_NWNAME: + length_position = offset++; + dst[offset++]=0x80|(src->dt_nwName.code_scheme<<4)|(src->dt_nwName.add_ci<<3)|(src->dt_nwName.spare_num); + memcpy(&dst[offset],src->dt_nwName.text,src->dt_nwName.text_len); + offset+=src->dt_nwName.text_len; + if(length_position == 1)//zhugq, in case of "M" + dst[1] = offset-2; + else + dst[0] = offset-1; + break; + case AIFG_IE_ID_DT_REJCAUSE: + dst[offset++]=src->dt_rejectCause.value; + break; + case AIFG_IE_ID_DT_FLONPROCEED://do nothing + break; + case AIFG_IE_ID_DT_TIMEZONE: + dst[offset++]=src->dt_timeZone.value; + break; + case AIFG_IE_ID_DT_TZTIME: + dst[offset++]=src->dt_tzTime.year; + dst[offset++]=src->dt_tzTime.month; + dst[offset++]=src->dt_tzTime.day; + dst[offset++]=src->dt_tzTime.hour; + dst[offset++]=src->dt_tzTime.minute; + dst[offset++]=src->dt_tzTime.second; + dst[offset++]=src->dt_tzTime.time_zone; + break; + case AIFG_IE_ID_DT_CTS://do nothing + break; + case AIFG_IE_ID_DT_LSAID: + dst[offset++]=3; + dst[offset++]=src->dt_lsaId.value[0]; + dst[offset++]=src->dt_lsaId.value[1]; + dst[offset++]=src->dt_lsaId.value[2]; + break; + case AIFG_IE_ID_DT_AUXSTAT: + dst[offset++]=1; + dst[offset++]=0x80|(src->dt_auxStat.hold_stat<<2)|src->dt_auxStat.mpty_stat; + break; + case AIFG_IE_ID_DT_BEARERCAP: + length_position=offset++; + if(1==src->dt_bc.coding.flag){ + //octet3 and 3a + dst[offset++]=(src->dt_bc.channel_require<<5) + |(src->dt_bc.coding_std<<4) + |(src->dt_bc.trans_mode<<3) + |src->dt_bc.info_trans_cap; + dst[offset++]=(src->dt_bc.coding.value<<6) + |src->dt_bc.speech_ver.value; + } + else{ + //octet3 without 3a + dst[offset++]=0x80|(src->dt_bc.channel_require<<5)|(src->dt_bc.coding_std<<4) + |(src->dt_bc.trans_mode<<3)|src->dt_bc.info_trans_cap; + + if(0!=src->dt_bc.info_trans_cap){ + ///////////octet4/////// + dst[offset++]=0x80|(src->dt_bc.compress.value<<6)|(src->dt_bc.structure.value<<4) + |(src->dt_bc.dupl_mode.value<<3)|(src->dt_bc.confiure.value<<2) + |(src->dt_bc.nirr.value<<1)|src->dt_bc.establishment.value; + + //////octet5 and 5a,5b/////// + if(1==src->dt_bc.o_itc.flag){//octet5`s ext==0 + dst[offset++]=(src->dt_bc.access_id.value<<5)|(src->dt_bc.rate_adaption.value<<3) + |src->dt_bc.signal_protocol.value;//octet5 with first bit "0" + if(1==src->dt_bc.hdr_nohdr.flag){//5a and 5b + dst[offset++]=(src->dt_bc.o_itc.value<<5)|(src->dt_bc.o_rate_adaption.value<<3); + dst[offset++]=0x80|(src->dt_bc.hdr_nohdr.value<<6)|(src->dt_bc.multi_frame.value<<5) + |(src->dt_bc.mode.value<<4)|(src->dt_bc.lli.value<<3) + |(src->dt_bc.assign_or_e.value<<2)|(src->dt_bc.inb_neg.value<<1);} + else//only 5a + dst[offset++]=0x80|(src->dt_bc.o_itc.value<<5)|(src->dt_bc.o_rate_adaption.value<<3); + } + + else//octet5`s ext==1 + dst[offset++]=0x80|(src->dt_bc.access_id.value<<5)|(src->dt_bc.rate_adaption.value<<3) + |src->dt_bc.signal_protocol.value;//octet5 with first bit "1" + + ///////octet6,6a,6b,6c///// + dst[offset++]=(src->dt_bc.layer1_id.value<<5)|(src->dt_bc.user_info1_protocol.value<<1) + |src->dt_bc.sync_async.value;//octet6 + dst[offset++]=(src->dt_bc.num_stop_bits.value<<6)|(src->dt_bc.negotiation.value<<5) + |(src->dt_bc.num_data_bits.value<<4)|src->dt_bc.user_rate.value;//6a + dst[offset++]=(src->dt_bc.intermed_rate.value<<5)|(src->dt_bc.nic_on_tx.value<<4) + |(src->dt_bc.nic_on_rx.value<<3)|src->dt_bc.parity.value;//6b + + if(1==src->dt_bc.o_modem_type.flag){//6c with first bit "0" + dst[offset++]=(src->dt_bc.connection_element.value<<5)|src->dt_bc.modem_type.value;//6c + /////octet6d,6e,6f,7////// + if(1==src->dt_bc.acceptable_chennel_code.flag){//6d with first bit "0" + dst[offset++]=(src->dt_bc.o_modem_type.value<<5)|src->dt_bc.fixed_nw_user_rate.value; + if(1==src->dt_bc.uimi.flag){//6e with first bit "0" + dst[offset++]=(src->dt_bc.acceptable_chennel_code.value<<3)|src->dt_bc.max_traffic_channel.value; + if(1==src->dt_bc.layer2_id.flag)//6f with first bit "0" + dst[offset++]=(src->dt_bc.uimi.value<<4)|src->dt_bc.wanted_air_if_user_rate.value; + else //6f with first bit "1" and 7 + dst[offset++]=0x80|(src->dt_bc.uimi.value<<4)|src->dt_bc.wanted_air_if_user_rate.value; + dst[offset++]=0x80|(src->dt_bc.layer2_id.value<<5)|src->dt_bc.user_info2_protocol.value;//7 + } + else //6e with first bit "1" + dst[offset++]=0x80|(src->dt_bc.acceptable_chennel_code.value<<3)|src->dt_bc.max_traffic_channel.value;} + else //6d with first bit "1" + dst[offset++]=0x80|(src->dt_bc.o_modem_type.value<<5)|src->dt_bc.fixed_nw_user_rate.value;} + else//6c with first bit "1" + dst[offset++]=0x80|(src->dt_bc.connection_element.value<<5)|src->dt_bc.modem_type.value;//6c with first bit "1" + + + } + } + if(length_position == 1)//zhugq,in case of "M" + dst[1]=offset-2; + else + dst[0]=offset-1; + break; + case AIFG_IE_ID_DT_CCCAP: + dst[offset++]=1; + dst[offset++]=(src->dt_ccCap.pcp<<1)|src->dt_ccCap.dtmf; + break; + case AIFG_IE_ID_DT_CALLSTAT: + dst[offset++]=(src->dt_callStat.coding_std<<6)|src->dt_callStat.value; + break; + case AIFG_IE_ID_DT_CALLEDBCD: + dst[offset++]=(src->dt_calledNum.num_len+1)/2+1; + dst[offset++]=0x80|(src->dt_calledNum.type<<4)|src->dt_calledNum.num_plan; + i=0; + while(i < src->dt_calledNum.num_len-1){ + dst[offset++]=(src->dt_calledNum.number[i+1]<<4)|src->dt_calledNum.number[i]; + i+=2; + } + if(1==(src->dt_calledNum.num_len%2)) + dst[offset++]=0xf0|src->dt_calledNum.number[i]; + break; + case AIFG_IE_ID_DT_CALLEDSUBADDR: + connsubaddr: + dst[offset++]=src->dt_calledSubAddr.info_len+1; + dst[offset++]=0x80|(src->dt_calledSubAddr.type<<4)|(src->dt_calledSubAddr.odd_even_ind<<3); + memcpy(&dst[offset],src->dt_calledSubAddr.info,src->dt_calledSubAddr.info_len); + offset+=src->dt_calledSubAddr.info_len; + break; + case AIFG_IE_ID_DT_CALLERBCD: + connnum: + length_position = offset++; + if(1==src->dt_callingNum.presentation_ind.flag){ + dst[offset++]=(src->dt_callingNum.type<<4)|src->dt_callingNum.num_plan; + dst[offset++]=0x80|(src->dt_callingNum.presentation_ind.value<<5)|src->dt_callingNum.screen_ind.value; + //dst[1]=(src->dt_callingNum.num_len+1)/2+2; + } + else{ + dst[offset++]=0x80|(src->dt_callingNum.type<<4)|src->dt_callingNum.num_plan; + //dst[1]=(src->dt_callingNum.num_len+1)/2+1; + } + i=0; + while(idt_callingNum.num_len-1){ + dst[offset++]=(src->dt_callingNum.number[i+1]<<4)|src->dt_callingNum.number[i]; + i+=2;} + if(1==src->dt_callingNum.num_len%2) + dst[offset++]=0xf0|src->dt_callingNum.number[i]; + if(length_position == 1)//zhugq,in case of "M" + dst[1] = offset-2; + else + dst[0] = offset-1; + break; + case AIFG_IE_ID_DT_CALLERSUBADDR: + goto connsubaddr; + break; + case AIFG_IE_ID_DT_CONNNUM: + goto connnum; + break; + case AIFG_IE_ID_DT_CONNSUBADDR: + goto connsubaddr; + break; + case AIFG_IE_ID_DT_REDIRBCD: + goto connnum; + break; + case AIFG_IE_ID_DT_REDIRSUBADDR: + goto connsubaddr; + break; + case AIFG_IE_ID_DT_CAUSE: + if(1==src->dt_cause.recommendation.flag){//octet3 and 3a + dst[offset++]=src->dt_cause.diag_len+3; + dst[offset++]=(src->dt_cause.coding_std<<5)|src->dt_cause.location; + dst[offset++]=0x80|src->dt_cause.recommendation.value;} + else{// octet3 + dst[offset++]=src->dt_cause.diag_len+2; + dst[offset++]=0x80|(src->dt_cause.coding_std<<5)|src->dt_cause.location; + } + dst[offset++]=0x80|src->dt_cause.cause_value; + memcpy(&dst[offset],src->dt_cause.diagnostic,src->dt_cause.diag_len); + offset+=src->dt_cause.diag_len; + break; + case AIFG_IE_ID_DT_CONGESTLEVEL: + dst[offset]=src->dt_congestLevel.value; + break; + case AIFG_IE_ID_DT_HIGHCOM: + length_position = offset++; + if(1==src->dt_hiComp.coding_std.flag){ + dst[offset++]=0x80|(src->dt_hiComp.coding_std.value<<5)//octet3 + |(src->dt_hiComp.interpret.value<<2)|src->dt_hiComp.presentat_method.value; + if(1==src->dt_hiComp.high_layer_id.flag){ + if(1==src->dt_hiComp.ext_high_layer_id.flag){ + dst[offset++]=src->dt_hiComp.high_layer_id.value; // 4 with first bit "0" + dst[offset++]=0x80|src->dt_hiComp.ext_high_layer_id.value;}// 4a + else + dst[offset++]=0x80|src->dt_hiComp.high_layer_id.value;}// 4 with first bit "1" + } + if(length_position == 1)//zhugq,in case of "M" + dst[1] = offset-2; + else + dst[0] = offset-1; + break; + case AIFG_IE_ID_DT_KEYPAD: + dst[offset++] = src->dt_keypad.value; + break; + case AIFG_IE_ID_DT_LOWCOM: + dst[offset++]=src->dt_loComp.data_len; + memcpy(&dst[offset],src->dt_loComp.data,src->dt_loComp.data_len); + offset+=src->dt_loComp.data_len; + break; + case AIFG_IE_ID_DT_MOREDATA://do nothing + break; + case AIFG_IE_ID_DT_NOTIIND: + dst[offset++]=0x80|src->dt_notificationInd.value; + break; + case AIFG_IE_ID_DT_PROGIND: + dst[offset++]=2; + dst[offset++]=0x80|(src->dt_progInd.coding_standard<<5)|src->dt_progInd.location; + dst[offset++]=0x80|src->dt_progInd.desc; + break; +// case AIFG_IE_ID_DT_REPEATIND: +// dst[offset++]=src->dt_rpInd.value;//iei half octet lost +// break; + case AIFG_IE_ID_DT_REVCALLDIR://do nothing + break; + case AIFG_IE_ID_DT_SIGNAL: + dst[offset++]=src->dt_signal.value; + break; + case AIFG_IE_ID_DT_SSVER: + dst[offset++]=src->dt_ssVer.info_len; + memcpy(&dst[offset],src->dt_ssVer.info,src->dt_ssVer.info_len); + offset+=src->dt_ssVer.info_len; + break; + case AIFG_IE_ID_DT_USERUSER: + dst[offset++]=src->dt_uu.info_len+1; + dst[offset++]=src->dt_uu.pd; + memcpy(&dst[offset],src->dt_uu.info,src->dt_uu.info_len); + offset+=src->dt_uu.info_len; + break; + case AIFG_IE_ID_DT_ALERTPATTERN: + dst[offset++]=1; + dst[offset++]=src->dt_alertPattern.value; + break; + + /*case AIFG_IE_ID_DT_CODESETEXT: + //to do + break; + case AIFG_IE_ID_DT_SHIFT: + //to do + break;*/ + case AIFG_IE_ID_DT_CLIRSUP: + //to do + break; + case AIFG_IE_ID_DT_CLIRIVO: + //to do + break; + case AIFG_IE_ID_DT_FACILITY: + dst[offset++] = src->dt_facility.component_len; + memcpy(dst+offset, src->dt_facility.component, src->dt_facility.component_len); + offset += src->dt_facility.component_len; + + /* + length_position = offset++; + if(src->dt_facility.components.invoke.tag == 0xa1) + { + dst[offset++] = src->dt_facility.components.invoke.tag; + dst[offset++] = src->dt_facility.components.invoke.len; + //invoke_id - M + dst[offset++] = src->dt_facility.components.invoke.invoke_id.tag; + dst[offset++] = src->dt_facility.components.invoke.invoke_id.len; + dst[offset++] = src->dt_facility.components.invoke.invoke_id.id; + //linked_id - O + if(1 == src->dt_facility.components.invoke.linked_id.flag) + { + dst[offset++] = src->dt_facility.components.invoke.linked_id.tag; + dst[offset++] = src->dt_facility.components.invoke.linked_id.len; + dst[offset++] = src->dt_facility.components.invoke.linked_id.id; + } + //operatin code - M + dst[offset++] = src->dt_facility.components.invoke.opCode.tag; + dst[offset++] = src->dt_facility.components.invoke.opCode.len; + memcpy(&dst[offset],src->dt_facility.components.invoke.opCode.op,src->dt_facility.components.invoke.opCode.len); + offset += src->dt_facility.components.invoke.opCode.len; + //parameters - O + if(1 == src->dt_facility.components.invoke.param.flag) + dst[offset++] = src->dt_facility.components.invoke.param.param; + } + if(src->dt_facility.components.return_result.tag == 0xa2) + { + dst[offset++] = src->dt_facility.components.return_result.tag; + dst[offset++] = src->dt_facility.components.return_result.len; + //invoke_id - M + dst[offset++] = src->dt_facility.components.return_result.invoke_id.tag; + dst[offset++] = src->dt_facility.components.return_result.invoke_id.len; + dst[offset++] = src->dt_facility.components.return_result.invoke_id.id; + //sequence - O + if(1 == src->dt_facility.components.return_result.sequence.flag) + { + dst[offset++] = src->dt_facility.components.return_result.sequence.tag; + dst[offset++] = src->dt_facility.components.return_result.sequence.len; + } + //operation code - O + if(1 == src->dt_facility.components.return_result.opCode.flag) + { + dst[offset++] = src->dt_facility.components.return_result.opCode.tag; + dst[offset++] = src->dt_facility.components.return_result.opCode.len; + memcpy(&dst[offset],src->dt_facility.components.return_result.opCode.op,src->dt_facility.components.return_result.opCode.len); + offset += src->dt_facility.components.return_result.opCode.len; + } + //parameters - O + if(1 == src->dt_facility.components.return_result.param.flag) + { + if(1 == src->dt_facility.components.return_result.sequence.flag) + { + memcpy(&dst[offset],src->dt_facility.components.return_result.param.param,src->dt_facility.components.return_result.sequence.len); + offset += src->dt_facility.components.return_result.sequence.len; + } + else + dst[offset++] = src->dt_facility.components.return_result.param.param[0]; + } + } + if(src->dt_facility.components.return_error.tag == 0xa3) + { + dst[offset++] = src->dt_facility.components.return_error.tag; + dst[offset++] = src->dt_facility.components.return_error.len; + //invoke_id - M + dst[offset++] = src->dt_facility.components.return_error.invoke_id.tag; + dst[offset++] = src->dt_facility.components.return_error.invoke_id.len; + dst[offset++] = src->dt_facility.components.return_error.invoke_id.id; + //error code - M + dst[offset++] = src->dt_facility.components.return_error.error.tag; + dst[offset++] = src->dt_facility.components.return_error.error.len; + memcpy(&dst[offset],src->dt_facility.components.return_error.error.er,src->dt_facility.components.return_error.error.len); + offset += src->dt_facility.components.return_error.error.len; + //parameters - O + if(1 == src->dt_facility.components.return_error.param.flag) + dst[offset++] = src->dt_facility.components.return_error.param.param; + } + if(src->dt_facility.components.reject.tag == 0xa4) + { + dst[offset++] = src->dt_facility.components.reject.tag; + dst[offset++] = src->dt_facility.components.reject.len; + //invoke_id - M + dst[offset++] = src->dt_facility.components.reject.invoke_id.tag; + dst[offset++] = src->dt_facility.components.reject.invoke_id.len; + dst[offset++] = src->dt_facility.components.reject.invoke_id.id; + //problem code - M + dst[offset++] = src->dt_facility.components.reject.problem.tag; + dst[offset++] = src->dt_facility.components.reject.problem.len; + memcpy(&dst[offset],src->dt_facility.components.reject.problem.pro,src->dt_facility.components.reject.problem.len); + offset += src->dt_facility.components.reject.problem.len; + } + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset-1; + else + dst[1] = offset-2; + */ + break; + case AIFG_IE_ID_DT_RP_MO_ADDR: + case AIFG_IE_ID_DT_RP_MT_ADDR: + if(src->dt_rpAddr.number_len == 0) + { + dst[offset] = 0; + offset++; + } + else + { + dst[offset++] = src->dt_rpAddr.number_len + 1; //length + dst[offset++] = 0x80 | src->dt_rpAddr.number_type | src->dt_rpAddr.number_plan; + if(src->dt_rpAddr.number_len > 0) + { + memcpy(dst+offset, src->dt_rpAddr.number, src->dt_rpAddr.number_len); + offset += src->dt_rpAddr.number_len; + } + } + break; + case AIFG_IE_ID_DT_RP_UD: + if (0 == m_o_flag){ + dst[offset++] = AIFG_IEI_DT_RP_UD; + } + dst[offset++] = src->dt_rpUD.len; + memcpy(dst+offset, src->dt_rpUD.content, src->dt_rpUD.len); + offset += src->dt_rpUD.len; + break; + case AIFG_IE_ID_DT_RP_CAUSE: + dst[offset++] = src->dt_rpCause.diag_len + 1; + dst[offset++] = src->dt_rpCause.cause; + if(src->dt_rpCause.diag_len > 0) + memcpy(dst+offset, src->dt_rpCause.diagnostic, src->dt_rpCause.diag_len); + break; + case AIFG_IE_ID_DT_CELLID: + //to do + break; + case AIFG_IE_ID_DT_MSCM3: + //to do + break; + case AIFG_IE_ID_DT_GROUPCIPHERKEY: + //to do + break; + + + } + break; +/////////////////////////////bssmap////////////////////////////////////////////////// + case AIFG_MSG_BSSMAP: + dst[offset++] = aifg_get_iei(ie_id); + switch(ie_id){ + case AIFG_IE_ID_BM_CIC: + dst[offset++] = src->bm_cic.pcm >> 3; + dst[offset] = src->bm_cic.pcm; + dst[offset] = (dst[offset] << 5) | (src->bm_cic.timeslot & 0x1F); + offset++; + break; + case AIFG_IE_ID_BM_RESOURCEAVAIL: + i = 0; + while(i < 5){ + dst[offset++] = src->bm_resrcAvail.full_rate_channel[i] >>8; + dst[offset++] = src->bm_resrcAvail.full_rate_channel[i] ; + dst[offset++] = src->bm_resrcAvail.half_rate_channel[i] >>8; + dst[offset++] = src->bm_resrcAvail.half_rate_channel[i] ; + i++; + } + break; + case AIFG_IE_ID_BM_CONNRELREQ: + //Nothing to do + break; + case AIFG_IE_ID_BM_CAUSE: + if(src->bm_cause.ext_value.flag == 1){ + dst[offset++] = 2; + dst[offset++] = src->bm_cause.value|0x80; + dst[offset++] = src->bm_cause.ext_value.value; + + } + else{ + dst[offset++] = 1; + dst[offset++] = src->bm_cause.value; + } + break; + case AIFG_IE_ID_BM_IMSI: + case AIFG_IE_ID_BM_MOBILEID: + goto MOBILE_ID; //The same as Mobile ID of DTAP + break; + case AIFG_IE_ID_BM_TMSI: + dst[offset++] = 4; //length + memcpy(&(dst[offset]), src->bm_tmsi.value, 4); + offset += 4; + break; + case AIFG_IE_ID_BM_MSNUM: + dst[offset++] = src->bm_msNum.value; + break; + case AIFG_IE_ID_BM_L3HEADERINFO: + dst[offset++] = 2; + dst[offset++] = src->bm_L3HeaderInfo.pd & 0x0F; + dst[offset++] = src->bm_L3HeaderInfo.ti & 0x0F; + break; + case AIFG_IE_ID_BM_ENCRYPTINFO: + length_position = offset++; //this byte is ie length which will be set later + dst[offset++] = src->bm_encryptInfo.algorithm; + if(src->bm_encryptInfo.algorithm > 1){ + //key + memcpy(&(dst[offset]), src->bm_encryptInfo.key, 8); + offset += 8; + } + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset-1; + else + dst[1] = offset-2; + break; + case AIFG_IE_ID_BM_CHANNELTYPE: + length_position = offset++; //skip length + dst[offset++] = src->bm_channelType.speech_data_ind; + dst[offset++] = src->bm_channelType.channel_rate_type; + switch(src->bm_channelType.speech_data_ind){ + case 0x01: //speech + i = 0; + while(i < src->bm_channelType.ext.speech.len){ + dst[offset++] = src->bm_channelType.ext.speech.ver[i++] | 0x80; + } + dst[offset-1] = src->bm_channelType.ext.speech.ver[i-1] & 0x7F; //set ext flag of last extended byte to 0 + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset-1; + else + dst[1] = offset-2; + break; + case 0x02: //data + dst[offset] = src->bm_channelType.ext.data_cfg.t_nt; + dst[offset] = (dst[offset] << 6) | src->bm_channelType.ext.data_cfg.rate; + if(1==src->bm_channelType.ext.data_cfg.allowed_data_rate.flag){ + dst[offset] = dst[offset] | 0x80; //set ext flag to 1 + offset++; + dst[offset] = src->bm_channelType.ext.data_cfg.allowed_data_rate.value; + } + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset; + else + dst[1] = offset-1; + break; + case 0x03: //signalling + + break; + } + break; + case AIFG_IE_ID_BM_PERIODICITY: + dst[offset++] = src->bm_periodicity.value; + break; + case AIFG_IE_ID_BM_EXTRESOURCEIND: + dst[offset] = src->bm_extResrcInd.sm & 0x01; + dst[offset] = (dst[offset] << 1) | (src->bm_extResrcInd.tarr & 0x01); + offset++; + break; + case AIFG_IE_ID_BM_TOTALRESOURCE: + dst[offset++] = src->bm_totalResrc.full_rate_channel >> 8; + dst[offset++] = src->bm_totalResrc.full_rate_channel ; + dst[offset++] = src->bm_totalResrc.half_rate_channel >> 8; + dst[offset++] = src->bm_totalResrc.half_rate_channel ; + break; + case AIFG_IE_ID_BM_LSAID: + dst[offset++] = 3; + dst[offset++] = src->bm_lsaId.value[0]; + dst[offset++] = src->bm_lsaId.value[1]; + dst[offset++] = src->bm_lsaId.value[2]; + break; + ////////////////////////// + case AIFG_IE_ID_BM_LSAIDLIST: + length_position = offset++; + dst[offset++]=src->bm_lsaIdList.ep; + i=0; + while (ibm_lsaIdList.lsa_num) + { + dst[offset++]=src->bm_lsaIdList.list[i].id[0]; + dst[offset++]=src->bm_lsaIdList.list[i].id[1]; + dst[offset++]=src->bm_lsaIdList.list[i].id[2]; + i++; + } + //in case of "M'' + dst[length_position]=src->bm_lsaIdList.lsa_num*3+1; + break; + case AIFG_IE_ID_BM_PRIORITY: + dst[offset++]=1; + dst[offset++]=(src->bm_priority.pci<<6)|(src->bm_priority.level<<2)|(src->bm_priority.qa<<1)|(src->bm_priority.pvi); + break; + case AIFG_IE_ID_BM_CELLID: + length_position = offset++; + dst[offset++]=src->bm_cellId.discriminator; + switch(src->bm_cellId.discriminator){ + case 0: + dst[offset++]=(src->bm_cellId.mcc[1]<<4)|src->bm_cellId.mcc[0]; + dst[offset++]=(src->bm_cellId.mnc[2]<<4)|src->bm_cellId.mcc[2]; + dst[offset++]=(src->bm_cellId.mnc[1]<<4)|src->bm_cellId.mnc[0]; + dst[offset++]=src->bm_cellId.LAC>>8; + dst[offset++]=src->bm_cellId.LAC; + dst[offset++]=src->bm_cellId.CI>>8; + dst[offset++]=src->bm_cellId.CI; + dst[length_position]=8;//zhugq,in case of "M" + break; + case 1: + dst[offset++]=src->bm_cellId.LAC>>8; + dst[offset++]=src->bm_cellId.LAC; + dst[offset++]=src->bm_cellId.CI>>8; + dst[offset++]=src->bm_cellId.CI; + dst[length_position]=5;//zhugq + break; + case 2: + dst[offset++]=src->bm_cellId.CI>>8; + dst[offset++]=src->bm_cellId.CI; + dst[length_position]=3;//zhugq + break; + default:break; + } + break; + case AIFG_IE_ID_BM_BANDUSED: + dst[offset++]=src->bm_bandUsed.value; + break; + case AIFG_IE_ID_BM_RRCAUSE: + dst[offset++]=src->bm_rrCause.value; + break; + case AIFG_IE_ID_BM_DLCI: + dst[offset++]=src->bm_dlci.value; + break; + case AIFG_IE_ID_BM_DTXFLAG: + dst[offset++]=src->bm_dtx.value; + break; + case AIFG_IE_ID_BM_RESPREQ://do nothing + break; + case AIFG_IE_ID_BM_RESOURCEINDMEHTOD: + dst[offset++]=src->bm_resrcIndMethod.value; + break; + case AIFG_IE_ID_BM_CICLIST: + dst[offset++]=src->bm_cicList.status.len+1; + dst[offset++]=src->bm_cicList.range; + memcpy(&dst[offset],src->bm_cicList.status.content,src->bm_cicList.status.len); + offset+=src->bm_cicList.status.len; + break; + case AIFG_IE_ID_BM_DIGNOSTIC: + dst[offset++]=src->bm_diagnostics.err_msg.len+2; + dst[offset++]=src->bm_diagnostics.err_pointer; + dst[offset++]=src->bm_diagnostics.bit_pointer; + memcpy(&dst[offset],src->bm_diagnostics.err_msg.msg,src->bm_diagnostics.err_msg.len); + offset+=src->bm_diagnostics.err_msg.len; + break; + case AIFG_IE_ID_BM_CHOSENCHANNEL: + dst[offset++]=(src->bm_chosenChannel.mode<<4)|src->bm_chosenChannel.channel; + break; + case AIFG_IE_ID_BM_CIPHERRESPMODE: + dst[offset++]=src->bm_cipherRespMode.value; + break; + case AIFG_IE_ID_BM_CHANNELNEEDED: + dst[offset++]=src->bm_channelNeeded.value; + break; + case AIFG_IE_ID_BM_TRACETYPE: + dst[offset++]=src->bm_traceType.value; + break; + case AIFG_IE_ID_BM_TRIGGERID: + dst[offset++]=src->bm_triggerId.len; + memcpy(&dst[offset],src->bm_triggerId.content,src->bm_triggerId.len); + offset+=src->bm_triggerId.len; + break; + case AIFG_IE_ID_BM_TRACEREF: + dst[offset++]=src->bm_traceRef.value>>8; + dst[offset++]=src->bm_traceRef.value; + break; + case AIFG_IE_ID_BM_TRANSACTIONID: + dst[offset++]=2; + dst[offset++]=src->bm_transId.value>>8; + dst[offset++]=src->bm_transId.value; + break; + case AIFG_IE_ID_BM_OMCID: + dst[offset++]=src->bm_omcId.len; + memcpy(&dst[offset],src->bm_omcId.id,src->bm_omcId.len); + offset+=src->bm_omcId.len; + break; + case AIFG_IE_ID_BM_FORWARDIND: + dst[offset++]=src->bm_fowardInd.value; + break; + case AIFG_IE_ID_BM_CHOSENENCRYPT: + dst[offset++]=src->bm_chosenEncrypt.value; + break; + case AIFG_IE_ID_BM_CIRCUITPOOL: + dst[offset++]=src->bm_circuitPool.value; + break; + case AIFG_IE_ID_BM_CIRCUITPOOLLIST: + dst[offset++]=src->bm_circuitPoolList.num; + memcpy(&dst[offset],src->bm_circuitPoolList.circuit,src->bm_circuitPoolList.num); + offset+=src->bm_circuitPoolList.num; + break; + case AIFG_IE_ID_BM_TIMEIND: + dst[offset++]=src->bm_timeId.value; + break; + case AIFG_IE_ID_BM_RESOURCESITUATION: + length_position = offset++; + i=0; + while(ibm_resrcSit.band_num){ + dst[offset++]=(src->bm_resrcSit.band[i].band_ind<<4)|src->bm_resrcSit.band[i].channel_type; + if(src->bm_resrcSit.band[i].channel_num>127){ + dst[offset++]=(src->bm_resrcSit.band[i].channel_num>>8)|0x80; + dst[offset++]=src->bm_resrcSit.band[i].channel_num;} + else + dst[offset++]=src->bm_resrcSit.band[i].channel_num; + i++;} + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset-1; + else + dst[1] = offset-2; + break; + case AIFG_IE_ID_BM_CURCHANNELTYPE1: + dst[offset++]=(src->bm_curChannelType1.channel_mode<<4)|src->bm_curChannelType1.channel; + break; + case AIFG_IE_ID_BM_QUEUEIND: + dst[offset++]=src->bm_queuingInd.value<<1; + break; + case AIFG_IE_ID_BM_SPEECHVER: + dst[offset++]=src->bm_speechVer.value; + break; + case AIFG_IE_ID_BM_ASSIGNREQUIREMENT: + dst[offset++]=src->bm_assignReq.value; + break; + case AIFG_IE_ID_BM_TALKERFLAG://do nothing + break; + case AIFG_IE_ID_BM_GROUPCALLREF: + dst[offset++]=5; + groupref: + dst[offset++]=src->bm_groupRef.binary_code>>19; + dst[offset++]=src->bm_groupRef.binary_code>>11; + dst[offset++]=src->bm_groupRef.binary_code>>3; + dst[offset]=((src->bm_groupRef.binary_code & 0x07)<<5)|(src->bm_groupRef.sf<<4); + dst[offset]=dst[offset]|(src->bm_groupRef.af<<3)|src->bm_groupRef.call_priority; + offset++; + dst[offset++]=src->bm_groupRef.cipher_info<<4; + break; + case AIFG_IE_ID_BM_EMLPP: + dst[offset++]=src->bm_eMLPP.value; + break; + case AIFG_IE_ID_BM_CFGEVOIND: + dst[offset++]=src->bm_cfgEvoInd.value; + break; + case AIFG_IE_ID_BM_BSSOLDTONEW: + dst[offset++]=src->bm_bssOldtoNew.len; + memcpy(&dst[offset],src->bm_bssOldtoNew.content,src->bm_bssOldtoNew.len); + offset+=src->bm_bssOldtoNew.len; + break; + case AIFG_IE_ID_BM_LSAINFO: + dst[offset++]=src->bm_lsaInfo.lsa_num*4+1; + dst[offset++]=src->bm_lsaInfo.lsa_only; + i=0; + while(ibm_lsaInfo.lsa_num) + { + dst[offset++]=src->bm_lsaInfo.info[i].priority; + dst[offset++]=src->bm_lsaInfo.info[i].id[0]; + dst[offset++]=src->bm_lsaInfo.info[i].id[1]; + dst[offset++]=src->bm_lsaInfo.info[i].id[2]; + i++;} + break; + case AIFG_IE_ID_BM_LOCATIONINFO: + dst[offset++]=src->bm_locInfo.len; + memcpy(&dst[offset],src->bm_locInfo.info,src->bm_locInfo.len); + offset+=src->bm_locInfo.len; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO2: + classmarkinfo2: + dst[offset++]=3; + i = (src->bm_cmInfo2.rev_level<<5) | (src->bm_cmInfo2.es_ind<<4); + i = i | (src->bm_cmInfo2.a5_1<<3) | src->bm_cmInfo2.rf_power_cap; + dst[offset++] = i; + j = (src->bm_cmInfo2.ps_cap<<6)|(src->bm_cmInfo2.ss_screen_ind<<4); + j = j|(src->bm_cmInfo2.sm_cap<<3)|(src->bm_cmInfo2.vbs<<2); + j = j|(src->bm_cmInfo2.vgcs<<1)|src->bm_cmInfo2.fc; + dst[offset++] = j; + k = (src->bm_cmInfo2.cm3<<7)|(src->bm_cmInfo2.lcsva_cap<<5); + k = k|(src->bm_cmInfo2.so_lsa<<3)|(src->bm_cmInfo2.cmsp<<2); + k = k|(src->bm_cmInfo2.a5_3<<1)|src->bm_cmInfo2.a5_2; + dst[offset++] = k; + break; + case AIFG_IE_ID_BM_CELLIDLIST: + length_position = offset++; + i=0; + dst[offset++]=src->bm_cellIdList.discriminator; + switch(src->bm_cellIdList.discriminator){ + case 0: + while(ibm_cellIdList.cid_num){ + dst[offset++]=(src->bm_cellIdList.cell_id[i].mcc[1]<<4)|src->bm_cellIdList.cell_id[i].mcc[0]; + dst[offset++]=(src->bm_cellIdList.cell_id[i].mnc[2]<<4)|src->bm_cellIdList.cell_id[i].mcc[2]; + dst[offset++]=(src->bm_cellIdList.cell_id[i].mnc[1]<<4)|src->bm_cellIdList.cell_id[i].mnc[0]; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC; + dst[offset++]=src->bm_cellIdList.cell_id[i].CI>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].CI; + i++;} + break; + case 1: + while(ibm_cellIdList.cid_num){ + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC; + dst[offset++]=src->bm_cellIdList.cell_id[i].CI>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].CI; + i++;} + break; + case 2: + while(ibm_cellIdList.cid_num){ + dst[offset++]=src->bm_cellIdList.cell_id[i].CI>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].CI; + i++;} + break; + case 4: + while(ibm_cellIdList.cid_num){ + dst[offset++]=(src->bm_cellIdList.cell_id[i].mcc[1]<<4)|src->bm_cellIdList.cell_id[i].mcc[0]; + dst[offset++]=(src->bm_cellIdList.cell_id[i].mnc[2]<<4)|src->bm_cellIdList.cell_id[i].mcc[2]; + dst[offset++]=(src->bm_cellIdList.cell_id[i].mnc[1]<<4)|src->bm_cellIdList.cell_id[i].mnc[0]; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC; + i++;} + break; + case 5: + while(ibm_cellIdList.cid_num){ + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC>>8; + dst[offset++]=src->bm_cellIdList.cell_id[i].LAC; + i++;} + break; + } + if(length_position == 0)//zhugq,in case of "M" + dst[0] = offset-1; + else + dst[1] = offset-2; + break; + case AIFG_IE_ID_BM_CLASSMARKINFO3: + //to do + break; + case AIFG_IE_ID_BM_L3INFO: + //to do + break; + case AIFG_IE_ID_BM_CLASSMARKINFO1: + //to do + break; + case AIFG_IE_ID_BM_L3MSGCONTENT: + //to do + break; + } + break; + + } + + return offset; + +ERR_PROC: + // aifg_debug_print(aifg_event, (void*)src, NULL); + return AIFG_ERROR; +} +//End of information element process functions definition------------------------------ + diff --git a/omc/plat/aif/src/aifg_m.c b/omc/plat/aif/src/aifg_m.c new file mode 100644 index 0000000..ceeda65 --- /dev/null +++ b/omc/plat/aif/src/aifg_m.c @@ -0,0 +1,1689 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_m.c +Description: FSM of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-12 + +History: +2007-3-12 v9.0.0 Create +*********************************************************************/ +//#include "aifg_mpp.h" +#include "./include/aifg_var_ext.h" +#include "./include/aifg.h" + +aifg_sap sap[AIFG_MAX_SAP]; +aifg_port aifg_pcb[AIFG_MAX_PORT]; +aifg_circuit_group cg[AIFG_MAX_CG]; +aifg_link_info link_info[SCCP_MAX_LINK]; +aifg_dual_server dual_server; +aifg_event_code aifg_event; +aifg_port *pOpenPort_h = NULL; //List head of opened port +aifg_port *pPagPort_h = NULL; //List head of paging port +aifg_port *pPagPort_t = NULL; //List tail of paging port + +static int paging_port_count = 0; //for protection + +extern inline void aifg_add_paging_port(aifg_port *p); +extern inline void aifg_del_paging_port(aifg_port *p); +extern void aifg_csta_init(); +extern void aifg_csta_proc(); + +enum REL_CAUSE{ + REL_CAUSE_CALL_CONTROL = 0x09, + REL_CAUSE_HO_SUCCESS = 0x0B, + REL_CAUSE_TIMER_EXPIRE = 0x66, + REL_CAUSE_PROTOCOL_ERR = 0x6F, + REL_CAUSE_TEMP_FAILURE = 0x29, +}; + +/* +Purpose:Init AIFG module. +Input: None +Output: None +*/ +void aifg_init() +{ + int memsize; + + memset(&sap, 0, sizeof(sap)); + memset(aifg_pcb, 0, sizeof(aifg_port)*AIFG_MAX_PORT); + memset(link_info, 0, sizeof(aifg_link_info)*SCCP_MAX_LINK); + + memsize = (sizeof(sap)+sizeof(aifg_port)*AIFG_MAX_PORT+sizeof(aifg_raw_msg)+sizeof(aifg_msg_pre_decoded) + + sizeof(dual_server) + sizeof(aifg_event) + sizeof(cg) + sizeof(aifg_link_info)*SCCP_MAX_LINK + + sizeof(SP_UiPriPara))/1024; + + printf("AIFG memory usage: %d KB\n", memsize); + + aifg_set_running_mode(AIFG_RUN_MODE_SINGLE); + + aifg_event = AIFG_SUCCEED; + + aifg_mpp_init(); + aifg_debug_init(); + aifg_csta_init(); + //for dual server test + aifg_set_running_mode(AIFG_RUN_MODE_DUAL); + + printf("AIFG init completed!\n"); +} + +/* +Purpose:10ms routing of AIFG module. +Input: None +Output: None +*/ +void aifg_proc() +{ + int i; + aifg_port *pPort; + + for (i = 0; i < MSG_PROC_EACH_TIME; i++){ + if(AIFG_PROC_FINISH == aifg_mpp_proc()) + break; + } + + //process opened port + i = 0; + pPort = pOpenPort_h; + while(pPort != NULL){ + aifg_port *pTmpPort = pPort; + pPort = pPort->pNextOpenPort; + + (pTmpPort->timer > 0 ) ? pTmpPort->timer-- : 0; + aifg_port_proc(pTmpPort, NULL, NULL); + + if(++i > AIFG_MAX_PORT) + break; + } + + //---------for protection--------------- + if(i > AIFG_MAX_PORT) + { + //memory corrupted, reset all ports + pOpenPort_h = NULL; + for(i = 0; i < AIFG_MAX_PORT; i++) + aifg_port_release(&aifg_pcb[i]); + } + //---------protection end--------------- + aifg_csta_proc(); + aifg_debug_timer(); +} + +//FSM--------------------------------------------------------------------------------------- +inline void aifg_send_release_ind(aifg_sap_type sapid, int app_port, int aif_port, int cause) +{ + rv_msg.id = AIFG_MSG_ID_RELEASE; + rv_msg.app_port = app_port; + rv_msg.aif_port = aif_port; + rv_msg.cause = cause; + sap[sapid].callback_func(AIFG_IND_RV_MSG, &rv_msg); + aifg_pcb[aif_port].app_rel_flag = 1; +} + +inline void aifg_reset_timer(int port, int value) +{ + aifg_pcb[port].timer = value; +} + +inline int aifg_get_cause_value(aifg_ie_ptr *cause) +{ + aifg_ie tmp_ie; + if(cause->ptr != NULL){ + aifg_ie_decode(cause, &tmp_ie); + if (tmp_ie.iei == AIFG_IE_ID_BM_CAUSE) + return tmp_ie.param.bm_cause.value; + else + return tmp_ie.param.dt_cause.cause_value; + } + else + return 0x1F; //unspecified +} + +enum RESET_STATE{ + RESET_INIT, + RESET_WAIT_RESET_COMPLETE, +}; +int reset_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + switch(p->ti_stat){ + case RESET_INIT: + if(AIFG_SAP_MSC == p->sapid) + p->timer = AIFG_TIMER_T2; + else + p->timer = AIFG_TIMER_T13; + p->ti_stat = RESET_WAIT_RESET_COMPLETE; + break; + case RESET_WAIT_RESET_COMPLETE: + //Send RESET_ACK + if(0 == p->timer){ + sd_msg.id = AIFG_MSG_ID_RESET_ACK; + aifg_send_udt(p->cgid, &sd_msg, NULL); + return AIFG_PROC_FINISH; + } + break; + default: + assert(0); + goto ERR_PROC; + break; + } + + return AIFG_PROC_CONTINUE; + +ERR_PROC: + //release the port + return AIFG_ERROR; +} + + +enum PAGING_STATE{ + PAGING_INIT, + PAGING_WAIT_RESP, + PAGING_REPAGING, +}; +int paging_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + switch(p->ti_stat){ + case PAGING_INIT: + { + //remember imsi or tmsi + if (upper_msg->msg.paging.tmsi.flag == 1){ + //TMSI, because the TMSI in paging is BCD coding and single byte coding in paging response + //so here BCD coded TMSI will be translated to single byte coding + int i = 0, j = 0; + while (i < 4){ + p->imsi[j++] = upper_msg->msg.paging.tmsi.value[i] & 0x0F; + p->imsi[j++] = (upper_msg->msg.paging.tmsi.value[i++] & 0xF0) >> 4; + } + p->imsi_len = j; + } + else{ + p->imsi_len = upper_msg->msg.paging.imsi.imsi_len; + memcpy(p->imsi, upper_msg->msg.paging.imsi.imsi, p->imsi_len); + } + aifg_send_udt(p->cgid, upper_msg, &p->sd_buffer); + + //add the port paging port list +// aifg_add_paging_port(p); + p->ti_stat = PAGING_WAIT_RESP; + p->timer = AIFG_TIMER_T3113; + } + break; + case PAGING_WAIT_RESP: + { + if((peer_msg != NULL && AIFG_MSG_ID_PAGING_RESP == peer_msg->msg.completeL3Info.l3msg.id)){ + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + return AIFG_PROC_FINISH; + } + else if(p->timer <= 0){ + aifg_debug_print(p-aifg_pcb, AIFG_ERR_PAGING_NOT_RESP, NULL, p-aifg_pcb); + goto ERR_PROC; + } + else if(0 == (p->timer % AIFG_TIMER_REPAGE)) + p->ti_stat = PAGING_REPAGING; + } + break; + case PAGING_REPAGING: + { + //Re-paging + PostSp(&p->sd_buffer); + p->ti_stat = PAGING_WAIT_RESP; + } + break; + default: + assert(0); + goto ERR_PROC; + break; + } + return AIFG_PROC_CONTINUE; + +ERR_PROC: + //remove this port from paging list + p->app_rel_flag = 1; //no need to release app +// aifg_del_paging_port(p); + return AIFG_ERROR; +} + +enum LU_STATE{ + LU_WAIT_RESPONSE, + LU_CLEAR, + LU_WAIT_CLEAR_CMP, +}; +int lu_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + if (peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_REQ){ + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.clearReq.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + p->ti_stat = LU_CLEAR; + p->timer = 0; + } + + switch(p->ti_stat) + { + case LU_WAIT_RESPONSE: + { + if(upper_msg != NULL){ + if(upper_msg->id == AIFG_MSG_ID_RELEASE){ + p->ti_stat = LU_CLEAR; + p->app_rel_flag = 1; + } + else{ + aifg_send_dt1(p->link_id, upper_msg, p->ti); + } + } + else if(peer_msg != NULL){ + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + } + } + break; + case LU_CLEAR: + { + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ti_stat = LU_WAIT_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + break; + case LU_WAIT_CLEAR_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP) + || p->timer <= 0){ + link_info[p->link_id].cleared = 1; + return AIFG_PROC_FINISH; + } + } + break; + default: + assert(0); + return AIFG_PROC_FINISH; + break; + } + + return AIFG_PROC_CONTINUE; +} + +enum HO_STATE{ + HO_IDLE, + HO_SETUP_NEW_LINK, + HO_EXECUTE, + HO_WAIT_COMPLETE, + HO_CLEAR_OLD_LINK, + HO_WAIT_OLD_CLEAR_CMP, + HO_CLEAR_NEW_LINK, + HO_WAIT_NEW_CLEAR_CMP, +}; +enum HO_RETURN{ + HO_PROCECCED, + HO_NOT_PROCECCED, +}; +int ho_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + int retVal = HO_PROCECCED; + + switch(p->ho_stat){ + case HO_IDLE: + { + if (peer_msg->id == AIFG_MSG_ID_HO_REQUIRED){ + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + p->app_ho_port = peer_msg->app_port; + p->ho_stat = HO_SETUP_NEW_LINK; + p->timer = AIFG_TIMER_TRANS_TIMEOUT; + } + else{ + assert(0); + retVal = HO_NOT_PROCECCED; + goto ERROR_PROC; + } + } + break; + case HO_SETUP_NEW_LINK: + { + if (upper_msg != NULL ){ + if (upper_msg->id == AIFG_MSG_ID_HO_REQUEST){ + p->new_link = aifg_send_cr(p->sapid, p->cgid, upper_msg); + aifg_add_link(p->new_link, p->sapid); + link_info[p->new_link].cur_port = p - aifg_pcb; + p->ho_stat = HO_EXECUTE; + p->timer = AIFG_TIMER_TRANS_TIMEOUT; + } + else if (upper_msg->id == AIFG_MSG_ID_HO_REQ_REJ){ + aifg_send_dt1(p->link_id, upper_msg, -1); + p->ho_stat = 0; + } + else + retVal = HO_NOT_PROCECCED; + } + else if(p->timer == 0) + goto ERROR_PROC; + else + retVal = HO_NOT_PROCECCED; + } + break; + case HO_EXECUTE: + { + if (upper_msg != NULL){ + switch(upper_msg->id) + { + case AIFG_MSG_ID_HO_CMD: + aifg_send_dt1(p->link_id, upper_msg, -1); + retVal = HO_PROCECCED; + p->ho_stat = HO_WAIT_COMPLETE; + p->timer = AIFG_TIMER_TRANS_TIMEOUT; + break; + default: + retVal = HO_NOT_PROCECCED; + break; + } + } + else if(peer_msg != NULL){ + switch(peer_msg->id) + { + case AIFG_MSG_ID_HO_FAIL: + //rollback to HO_SETUP_NEW_LINK + p->ho_stat = HO_SETUP_NEW_LINK; + //no break here + case AIFG_MSG_ID_HO_REQ_ACK: + case AIFG_MSG_ID_QUEUE_IND: + peer_msg->app_port = p->app_ho_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + default: + retVal = HO_NOT_PROCECCED; + break; + } + } + else if(p->timer == 0) + goto ERROR_PROC; + } + break; + case HO_WAIT_COMPLETE: + { + if(peer_msg != NULL){ + switch(peer_msg->id) + { + case AIFG_MSG_ID_HO_DETECT: + peer_msg->app_port = p->app_ho_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + case AIFG_MSG_ID_HO_CMP: + p->ho_stat = HO_CLEAR_OLD_LINK; + peer_msg->app_port = p->app_ho_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + case AIFG_MSG_ID_HO_FAIL: + p->ho_stat = HO_CLEAR_NEW_LINK; + peer_msg->app_port = p->app_ho_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + default: + retVal = HO_NOT_PROCECCED; + break; + } + } + else if(p->timer == 0) + goto ERROR_PROC; + else + retVal = HO_NOT_PROCECCED; + } + break; + case HO_CLEAR_OLD_LINK: + { + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_HO_SUCCESS; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ho_stat = HO_WAIT_OLD_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + break; + case HO_WAIT_OLD_CLEAR_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP)|| p->timer <= 0){ + int old_link = p->link_id; + aifg_pcb[link_info[old_link].cur_port].link_id = p->new_link; + if(link_info[old_link].ti_number > 0){ + //handover all transaction on the old link to the new link + int i = 0; + while(link_info[old_link].ti_number > 0 && i < AIFG_MAX_TI_PER_LINK){ + if(link_info[old_link].ti[TI_FOR_CC][i].en_flag == 1){ + aifg_pcb[link_info[old_link].ti[TI_FOR_CC][i].port].link_id = p->new_link; + link_info[old_link].ti_number--; + } + if(link_info[old_link].ti[TI_FOR_SMS][i].en_flag == 1){ + aifg_pcb[link_info[old_link].ti[TI_FOR_SMS][i].port].link_id = p->new_link; + link_info[old_link].ti_number--; + } + if(link_info[old_link].ti[TI_FOR_SS][i].en_flag == 1){ + aifg_pcb[link_info[old_link].ti[TI_FOR_SS][i].port].link_id = p->new_link; + link_info[old_link].ti_number--; + } + i++; + } + } + link_info[old_link].cleared = 1; + aifg_send_rlsd(old_link); + + p->ho_stat = 0; //Handover completed + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + } + break; + case HO_CLEAR_NEW_LINK: + { + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->new_link, &sd_msg, p->ti); + + p->ho_stat = HO_WAIT_NEW_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + break; + case HO_WAIT_NEW_CLEAR_CMP: + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP)|| p->timer <= 0){ + link_info[p->new_link].cleared = 1; + aifg_send_rlsd(p->new_link); + p->new_link = -1; + p->ho_stat = 0; //Handover failed + } + else + retVal = HO_NOT_PROCECCED; + break; + default: + assert(0); + goto ERROR_PROC; + break; + } + return retVal; + +ERROR_PROC: + p->ho_stat = 0; + return retVal; +} + +enum CC_STATE{ + CC_WAIT_SETUP, + CC_CONNECTING, + CC_CONNECTED, + CC_DISCONNECTING, + CC_WAIT_RELEASE, + CC_RELEASING, + CC_WAIT_RELEASE_CMP, + CC_RELEASE_CMP, + CC_CLEARING, + CC_WAIT_CLEAR_CMP, + CC_HANDOVER, +}; +int cc_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + if (peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_REQ){ + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.clearReq.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + p->ti_stat = CC_CLEARING; + p->timer = 0; + } + + switch(p->ti_stat) + { + case CC_WAIT_SETUP: + { + if(upper_msg != NULL){ + if (upper_msg->pd == AIFG_PD_DTAP_CC && p->ti == -1){ + //assign a new ti for the transaction + p->ti = aifg_get_ti(p->link_id, p-aifg_pcb, TI_FOR_CC); + if(p->ti == -1){ + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, REL_CAUSE_PROTOCOL_ERR); + p->rel_cause = REL_CAUSE_PROTOCOL_ERR; + p->ti_stat = CC_CLEARING; + + aifg_debug_print(p-aifg_pcb, AIFG_ERR_CAN_NOT_FIND_TI, NULL, p-aifg_pcb); + #ifdef _AIFG_DEBUG_ + assert(0); + #endif + } + } + switch(upper_msg->id){ + case AIFG_MSG_ID_SETUP: + p->ti_stat = CC_CONNECTING; + aifg_send_dt1(p->link_id, upper_msg, p->ti); + break; + case AIFG_MSG_ID_RELEASE: + p->rel_cause = upper_msg->msg.release.cause1.cause_value; + p->ti_stat = CC_RELEASING; + p->app_rel_flag = 1; + break; + default: + aifg_send_dt1(p->link_id, upper_msg, p->ti); + break; + } + } + else if(peer_msg != NULL){ + if(peer_msg->pd == AIFG_PD_DTAP_CC && p->ti == -1){ + p->ti = peer_msg->ti; + aifg_add_ti(p->link_id, p->ti, TI_FOR_CC, p-aifg_pcb); + } + switch(peer_msg->id){ + case AIFG_MSG_ID_DISCONNECT: + p->ti_stat = CC_RELEASING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.disconnect.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE: + p->ti_stat = CC_RELEASE_CMP; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.release.cause1); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE_CMP: + p->ti_stat = CC_CLEARING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.releaseComp.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_EMERGENCY_SETUP: + case AIFG_MSG_ID_SETUP: + p->ti_stat = CC_CONNECTING; + //no break here + default: + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + } + } + else if(p->timer == 0){ + p->rel_cause = REL_CAUSE_TIMER_EXPIRE; //protocol timeout + aifg_debug_print(p-aifg_pcb, AIFG_ERR_PORT_TIMER_OUT, NULL, p-aifg_pcb); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + p->ti_stat = CC_CLEARING; + } + + if (p->ti_stat != CC_WAIT_SETUP && p->ti_stat!=CC_RELEASE_CMP){ + //status changed + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + } + break; + case CC_CONNECTING: + { + if(upper_msg != NULL){ + switch(upper_msg->id){ + case AIFG_MSG_ID_CONNECT: + p->ti_stat = CC_CONNECTED; + aifg_send_dt1(p->link_id, upper_msg, p->ti); + break; + case AIFG_MSG_ID_RELEASE: + p->rel_cause = upper_msg->msg.release.cause1.cause_value; + if(upper_msg->msg.release.cause1.diag_len > 0){ + p->diag_len = upper_msg->msg.release.cause1.diag_len; + memcpy(p->diagnostic, upper_msg->msg.release.cause1.diagnostic, p->diag_len); + } + else + p->diag_len = 0; + p->ti_stat = CC_DISCONNECTING; + p->app_rel_flag = 1; + break; + default: + aifg_send_dt1(p->link_id, upper_msg, p->ti); + break; + } + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + else if(peer_msg != NULL){ + switch(peer_msg->id){ + case AIFG_MSG_ID_DISCONNECT: + p->ti_stat = CC_RELEASING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.disconnect.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE: + p->ti_stat = CC_RELEASE_CMP; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.release.cause1); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE_CMP: + p->ti_stat = CC_CLEARING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.releaseComp.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_CONNECT: + p->ti_stat = CC_CONNECTED; + //no break here + default: + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + } + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + else if(p->timer == 0){ + p->rel_cause = REL_CAUSE_TIMER_EXPIRE; //protocol timeout + aifg_debug_print(p-aifg_pcb, AIFG_ERR_PORT_TIMER_OUT, NULL, p-aifg_pcb); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + p->ti_stat = CC_RELEASE_CMP; + } + + if (p->ti_stat!=CC_CONNECTING && p->ti_stat!=CC_RELEASE_CMP){ + //status changed + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + } + break; + case CC_CONNECTED: + { + if(upper_msg != NULL){ + if(upper_msg->id == AIFG_MSG_ID_RELEASE){ + p->rel_cause = upper_msg->msg.release.cause1.cause_value; + if(upper_msg->msg.release.cause1.diag_len > 0){ + p->diag_len = upper_msg->msg.release.cause1.diag_len; + memcpy(p->diagnostic, upper_msg->msg.release.cause1.diagnostic, p->diag_len); + } + else + p->diag_len = 0; + p->ti_stat = CC_DISCONNECTING; + p->app_rel_flag = 1; + } + else + aifg_send_dt1(p->link_id, upper_msg, p->ti); + } + else if(peer_msg != NULL){ + switch(peer_msg->id){ + case AIFG_MSG_ID_DISCONNECT: + p->ti_stat = CC_RELEASING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.disconnect.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE: + p->ti_stat = CC_RELEASE_CMP; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.release.cause1); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + case AIFG_MSG_ID_RELEASE_CMP: + p->ti_stat = CC_CLEARING; + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.releaseComp.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + break; + default: + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + break; + } + } + } + break; + case CC_DISCONNECTING: + { + memset(&sd_msg.msg.disconnect, 0 ,sizeof(sd_msg.msg.disconnect)); + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_DTAP_CC; + sd_msg.id = AIFG_MSG_ID_DISCONNECT; + sd_msg.msg.disconnect.cause.flag = 1; + sd_msg.msg.disconnect.cause.coding_std = 3; + sd_msg.msg.disconnect.cause.location = 1; + sd_msg.msg.disconnect.cause.cause_value = p->rel_cause; + if(p->diag_len > 0) + memcpy(sd_msg.msg.disconnect.cause.diagnostic, p->diagnostic, p->diag_len); + sd_msg.msg.disconnect.cause.diag_len = p->diag_len; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + p->ti_stat = CC_WAIT_RELEASE; + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_RELEASE_TIMEOUT); + } + break; + case CC_WAIT_RELEASE: + { + if(peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_RELEASE){ + p->ti_stat = CC_RELEASE_CMP; + p->timer = AIFG_TIMER_WAIT_RELEASE_CMP; + } + else if(p->timer == 0){ + p->ti_stat = CC_RELEASING; + p->rel_cause = REL_CAUSE_TIMER_EXPIRE; + } + } + break; + case CC_RELEASE_CMP: + { + if (p->timer == 0){ + memset(&sd_msg.msg.releaseCmp, 0 ,sizeof(sd_msg.msg.releaseCmp)); + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_DTAP_CC; + sd_msg.id = AIFG_MSG_ID_RELEASE_CMP; + sd_msg.msg.releaseCmp.cause.flag = 1; + sd_msg.msg.releaseCmp.cause.coding_std = 3; + sd_msg.msg.releaseCmp.cause.location = 1; + sd_msg.msg.releaseCmp.cause.cause_value = p->rel_cause; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + p->ti_stat = CC_CLEARING; + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_WAIT_RELEASE_CMP); + } + } + break; + case CC_RELEASING: + { + memset(&sd_msg.msg.release, 0 ,sizeof(sd_msg.msg.release)); + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_DTAP_CC; + sd_msg.id = AIFG_MSG_ID_RELEASE; + sd_msg.msg.release.cause1.flag = 1; + sd_msg.msg.release.cause1.coding_std = 3; + sd_msg.msg.release.cause1.location = 1; + sd_msg.msg.release.cause1.cause_value = p->rel_cause; + + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + p->ti_stat = CC_WAIT_RELEASE_CMP; + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_RELEASE_TIMEOUT); + } + break; + case CC_WAIT_RELEASE_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_RELEASE_CMP) || p->timer == 0){ + p->ti_stat = CC_CLEARING; + aifg_reset_timer(p-aifg_pcb, 0); + } + } + break; + case CC_CLEARING: + { + if (p->timer <= 0){ + if(aifg_del_ti(p->link_id, p->ti, TI_FOR_CC) > 0) + return AIFG_PROC_FINISH; + else{ + //send clear command + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ti_stat = CC_WAIT_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + } + } + break; + case CC_WAIT_CLEAR_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP) + || p->timer <= 0){ + link_info[p->link_id].cleared = 1; + return AIFG_PROC_FINISH; + } + } + break; + default: + assert(0); + return AIFG_PROC_FINISH; + break; + } + + return AIFG_PROC_CONTINUE; +} + +enum SMS_STATE{ + SMS_RP_TRANS, + SMS_RELEASING, + SMS_CLEARING, + SMS_WAIT_CLEAR_CMP, +}; +int sms_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + if (peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_REQ){ + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.clearReq.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + p->ti_stat = SMS_CLEARING; + p->timer = 0; + } + + switch(p->ti_stat){ + case SMS_RP_TRANS: + { + if (upper_msg != NULL){ + if(upper_msg->id == AIFG_MSG_ID_RELEASE){ + p->ti_stat = SMS_RELEASING; + p->app_rel_flag = 1; + } + else{ + if (upper_msg->pd == AIFG_PD_DTAP_SMS && p->ti == -1){ + //assign a new ti for the transaction + p->ti = aifg_get_ti(p->link_id, p-aifg_pcb, TI_FOR_SMS); + if(p->ti == -1){ + aifg_debug_print(p-aifg_pcb, AIFG_ERR_CAN_NOT_FIND_TI, NULL, p-aifg_pcb); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, REL_CAUSE_PROTOCOL_ERR); + p->ti_stat = SMS_RELEASING; + + #ifdef _AIFG_DEBUG_ + assert(0); + #endif + } + } + aifg_send_dt1(p->link_id, upper_msg, p->ti); + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + } + else if(peer_msg != NULL){ + if(peer_msg->pd == AIFG_PD_DTAP_SMS && p->ti == -1){ + p->ti = peer_msg->ti; + aifg_add_ti(p->link_id, p->ti, TI_FOR_SMS, p-aifg_pcb); + } + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + else if(p->timer == 0){ + aifg_debug_print(p-aifg_pcb, AIFG_ERR_PORT_TIMER_OUT, NULL, p-aifg_pcb); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, REL_CAUSE_TIMER_EXPIRE); + p->ti_stat = SMS_RELEASING; + } + } + break; + case SMS_RELEASING: + { + if(aifg_del_ti(p->link_id, p->ti, TI_FOR_SMS) == 0 + && link_info[p->link_id].cur_port == p-aifg_pcb){ + p->ti_stat = SMS_CLEARING; + p->timer = AIFG_TIMER_WAIT_RELEASE_CMP; + } + else + return AIFG_PROC_FINISH; + } + break; + case SMS_CLEARING: + { + if (p->timer == 0){ + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ti_stat = SMS_WAIT_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + } + break; + case SMS_WAIT_CLEAR_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP) + || p->timer <= 0){ + link_info[p->link_id].cleared = 1; + return AIFG_PROC_FINISH; + } + } + break; + default: + assert(0); + return AIFG_PROC_FINISH; + break; + } + + return AIFG_PROC_CONTINUE; +} + +enum SS_STATE{ + SS_REGISTERING, + SS_CLEARING, + SS_WAIT_CLEAR_CMP, +}; +int ss_fsm(aifg_port *p, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + if (peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_REQ){ + p->rel_cause = aifg_get_cause_value(&peer_msg->msg.clearReq.cause); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, p->rel_cause); + + //clear request, BSC may encounter error + //send clear command without checking if there exist other transaction + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ti_stat = SS_WAIT_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + + switch(p->ti_stat){ + case SS_REGISTERING: + { + if(upper_msg != NULL){ + if(upper_msg->id == AIFG_MSG_ID_RELEASE_CMP_SS){ + p->ti_stat = SS_CLEARING; + p->app_rel_flag = 1; + } + aifg_send_dt1(p->link_id, upper_msg, p->ti); + } + else if(peer_msg != NULL){ + if (peer_msg->pd == AIFG_PD_DTAP_SS && p->ti == -1){ + p->ti = peer_msg->ti; + aifg_add_ti(p->link_id, p->ti, TI_FOR_SS, p-aifg_pcb); + } + peer_msg->app_port = p->upper_port; + sap[p->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + aifg_reset_timer(p-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + else if(p->timer <= 0){ + aifg_debug_print(p-aifg_pcb, AIFG_ERR_PORT_TIMER_OUT, NULL, p-aifg_pcb); + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, REL_CAUSE_TIMER_EXPIRE); + p->ti_stat = SS_CLEARING; + } + } + break; + case SS_CLEARING: + { + if(aifg_del_ti(p->link_id, p->ti, TI_FOR_SS) > 0) + return AIFG_PROC_FINISH; + else{ + memset(&sd_msg.msg.clearCmd, 0 ,sizeof(sd_msg.msg.clearCmd)); + sd_msg.aif_port = p - aifg_pcb; //for debug print + sd_msg.app_port = p->upper_port;//for debug print + sd_msg.pd = AIFG_PD_BSSMAP_DEDICATED; + sd_msg.id = AIFG_MSG_ID_CLR_CMD; + sd_msg.msg.clearCmd.cause.flag = 1; + sd_msg.msg.clearCmd.cause.ext_value.flag = 0; + sd_msg.msg.clearCmd.cause.value = REL_CAUSE_CALL_CONTROL; + sd_msg.msg.clearCmd.l3HeaderInfo.flag = 0; + aifg_send_dt1(p->link_id, &sd_msg, p->ti); + + p->ti_stat = SS_WAIT_CLEAR_CMP; + p->timer = AIFG_TIMER_CLEAR_TIMEOUT; + } + } + break; + case SS_WAIT_CLEAR_CMP: + { + if((peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_CLR_CMP) + || p->timer <= 0){ + link_info[p->link_id].cleared = 1; + return AIFG_PROC_FINISH; + } + } + break; + } + + return AIFG_PROC_CONTINUE; +} + +void aifg_port_proc(aifg_port *pPort, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg) +{ + switch(pPort->stat){ + case AIFG_PORT_INIT: //init + { + if(upper_msg != NULL){ + //the port is activate by upper app + switch(upper_msg->id){ + case AIFG_MSG_ID_PAGING: + assert(AIFG_SAP_MSC == pPort->sapid); //only MSC can send this message + pPort->stat = AIFG_PORT_PAGING; + paging_fsm(pPort, upper_msg, peer_msg); + break; + case AIFG_MSG_ID_SETUP: + pPort->ti_type = AIFG_TRANS_CC; + pPort->ti_stat = 0; + pPort->stat = AIFG_PORT_TRANSACTION; + pPort->timer = AIFG_TIMER_TRANS_TIMEOUT; + cc_fsm(pPort, upper_msg, peer_msg); + break; + case AIFG_MSG_ID_RP_DATA: + pPort->ti_type = AIFG_TRANS_SMS; + pPort->ti_stat = 0; + pPort->stat = AIFG_PORT_TRANSACTION; + pPort->timer = AIFG_TIMER_TRANS_TIMEOUT; + sms_fsm(pPort, upper_msg, peer_msg); + break; + case AIFG_MSG_ID_L3_INFO: + { + int link_id; + assert(AIFG_SAP_BSC == pPort->sapid); //only BSC can send this message + pPort->stat = AIFG_PORT_TRANSPARENT; + link_id = aifg_send_cr(pPort->sapid, pPort->cgid, upper_msg); + if(link_id < 0 || link_id > SCCP_MAX_LINK) + goto ERROR_PROC; + aifg_add_link(link_id, pPort->sapid); + pPort->link_id = link_id; + link_info[link_id].cur_port = pPort - aifg_pcb; + } + break; + default: + assert(0); + goto ERROR_PROC; + break; + } + } + else if(peer_msg != NULL){ + //the port is activate by peer app + switch(peer_msg->id){ + case AIFG_MSG_ID_RESET: + peer_msg->app_port = -1; + pPort->stat = AIFG_PORT_RESET; + break; + case AIFG_MSG_ID_L3_INFO: + peer_msg->app_port = -1; + pPort->stat = AIFG_PORT_TRANSACTION; + pPort->timer = AIFG_TIMER_TRANS_TIMEOUT; + pPort->ti = -1; + pPort->ti_stat = 0; + if(AIFG_MSG_ID_LU_REQUEST == peer_msg->msg.completeL3Info.l3msg.id) + pPort->ti_type = AIFG_TRANS_LU; + else if(AIFG_MSG_ID_IMSI_DETACH_IND == peer_msg->msg.completeL3Info.l3msg.id){ + pPort->ti_type = AIFG_TRANS_LU; + pPort->ti_stat = LU_CLEAR; + } + else if(AIFG_MSG_ID_CM_REQUEST == peer_msg->msg.completeL3Info.l3msg.id){ + switch(peer_msg->msg.completeL3Info.l3msg.msg.cmRequest.type.ptr[0] & 0x0F){ //cm service type + case 0x01: //MO Call + pPort->ti_type = AIFG_TRANS_CC; + break; + case 0x04: + pPort->ti_type = AIFG_TRANS_SMS; + break; + case 0x08: + pPort->ti_type = AIFG_TRANS_SS; + break; + default: + pPort->ti_type = AIFG_TRANS_UNKNOW; + break; + } + } + else{ + assert(0); + } + break; + case AIFG_MSG_ID_CM_REQUEST: //the app_port is set to last opened port for this message + pPort->stat = AIFG_PORT_TRANSACTION; + pPort->timer = AIFG_TIMER_TRANS_TIMEOUT; + pPort->ti = -1; + pPort->ti_stat = 0; + switch(peer_msg->msg.cmReq.type.ptr[0] & 0x0F){ //cm service type + case 0x01: //MO Call + pPort->ti_type = AIFG_TRANS_CC; + break; + case 0x04: + pPort->ti_type = AIFG_TRANS_SMS; + break; + case 0x08: + pPort->ti_type = AIFG_TRANS_SS; + break; + default: + pPort->ti_type = AIFG_TRANS_UNKNOW; + break; + } + break; + case AIFG_MSG_ID_HO_REQUEST: + peer_msg->app_port = -1; + pPort->stat = AIFG_PORT_TRANSPARENT; + break; + default: + assert(0); + //unexpected message + goto ERROR_PROC; + break; + } + rv_msg.trace_flag = 0; + sap[pPort->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + pPort->upper_port = peer_msg->app_port; //remember new assigned app port + if (rv_msg.trace_flag == 1) + aifg_pcb[rv_msg.aif_port].trace_flag = rv_msg.trace_flag; //app may enable trace by setting rv_msg.trace_flag + } + else{ + assert(0); + goto ERROR_PROC; + } + } + break; + case AIFG_PORT_TRANSACTION: + { + switch(pPort->ti_type){ + case AIFG_TRANS_LU: + { + int ret = lu_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret){ + pPort->stat = AIFG_PORT_FINISH; + } + else if(AIFG_ERROR == ret) + goto ERROR_PROC; + } + break; + case AIFG_TRANS_CC: + { + int ret = -1; + + /* + *when in handover state, we will first try ho_fsm + *if the ho_fsm return HO_PROCECCED, the process will end here + *else, we will continue to cc_fsm + */ + if(pPort->ho_stat != 0 || (peer_msg != NULL && peer_msg->id == AIFG_MSG_ID_HO_REQUIRED)){ + //perform handover, the ho_stat will be set to 0 when the handover is completed + if (HO_PROCECCED == ho_fsm(pPort, upper_msg, peer_msg)) + goto CC_FINISH; /*BEWARE: switch-case may break here*/ + } + + ret = cc_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret) + pPort->stat = AIFG_PORT_FINISH; + else if(AIFG_ERROR == ret) + goto ERROR_PROC; + } + CC_FINISH: + break; + case AIFG_TRANS_SS: + { + int ret = ss_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret) + pPort->stat = AIFG_PORT_FINISH; + else if(AIFG_ERROR == ret) + goto ERROR_PROC; + } + break; + case AIFG_TRANS_SMS: + { + int ret = sms_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret) + pPort->stat = AIFG_PORT_FINISH; + else if(AIFG_ERROR == ret) + goto ERROR_PROC; + } + break; + case AIFG_TRANS_UNKNOW: //for paging response + { + aifg_pd tmp_pd; + if(upper_msg != NULL) + tmp_pd = upper_msg->pd; + else if(peer_msg != NULL) + tmp_pd = peer_msg->pd; + else if(pPort->timer == 0) + goto ERROR_PROC; + else + break; //case AIFG_TRANS_UNKNOW may break here + + switch(tmp_pd) + { + case AIFG_PD_DTAP_CC: + pPort->ti_type = AIFG_TRANS_CC; + cc_fsm(pPort, upper_msg, peer_msg); + break; + case AIFG_PD_DTAP_SMS: + pPort->ti_type = AIFG_TRANS_SMS; + sms_fsm(pPort, upper_msg, peer_msg); + break; + case AIFG_PD_DTAP_SS: + pPort->ti_type = AIFG_TRANS_SS; + ss_fsm(pPort, upper_msg, peer_msg); + break; + default: + if (upper_msg != NULL){ + aifg_send_dt1(pPort->link_id, upper_msg, pPort->ti); + } + else{ + peer_msg->app_port = pPort->upper_port; + sap[pPort->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + } + break; + } + } + break; + default: + assert(0); + break; + } + } + break; + case AIFG_PORT_TRANSPARENT: + { + //transparent transfer + if(upper_msg != NULL){ + aifg_send_dt1(pPort->link_id, upper_msg, pPort->ti); + } + else if (peer_msg != NULL){ + peer_msg->app_port = pPort->upper_port; + sap[pPort->sapid].callback_func(AIFG_IND_RV_MSG, peer_msg); + } + } + break; + case AIFG_PORT_PAGING: //paging transaction + { + int ret = paging_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret){ + //assert(NULL != p->sd_buffer); + //free(p->sd_buffer); + pPort->stat = AIFG_PORT_TRANSACTION; + pPort->timer = AIFG_TIMER_TRANS_TIMEOUT; + pPort->ti_type = AIFG_TRANS_UNKNOW; + pPort->ti_stat = 0; + aifg_reset_timer(pPort-aifg_pcb, AIFG_TIMER_TRANS_TIMEOUT); + } + else if(AIFG_ERROR == ret){ + //assert(NULL != p->sd_buffer); + //free(p->sd_buffer); + goto ERROR_PROC; + } + } + break; + case AIFG_PORT_RESET: //reset transaction + { + int ret = reset_fsm(pPort, upper_msg, peer_msg); + if(AIFG_PROC_FINISH == ret) + pPort->stat = AIFG_PORT_FINISH; + else if(AIFG_ERROR == ret) + goto ERROR_PROC; + } + break; + case AIFG_PORT_FINISH: + if(pPort->link_id != -1 +// && link_info[pPort->link_id].ti_number <= 0 + && link_info[pPort->link_id].cleared == 1) + { + aifg_link_release(pPort->link_id); + } + else{ + if(pPort->link_id != -1 && link_info[pPort->link_id].cur_port == pPort - aifg_pcb) + link_info[pPort->link_id].cur_port = -1; + aifg_port_release(pPort); + } + break; + default: + assert(0); + goto ERROR_PROC; + break; + } + + return; + +ERROR_PROC: + if(pPort->link_id != -1 + && link_info[pPort->link_id].ti_number <= 1) //only one transaction or less +// && link_info[pPort->link_id].cleared == 1) + { + aifg_link_release(pPort->link_id); + } + else{ + if(link_info[pPort->link_id].cur_port == pPort - aifg_pcb) + link_info[pPort->link_id].cur_port = -1; + aifg_port_release(pPort); + } + return; +} + +//end of FSM--------------------------------------------------------------------------------- + +/* +Purpose:assign a free port and init +Input: int sapid: SAP ID + int linkid: Link ID +Output: int: Port number, -1 if no port available +*/ +int start_pos = 0; //start position +inline int aifg_port_assign(int sapid, int cgid, int linkid) +{ + int i = start_pos; + int end_pos = start_pos - 1; + if (end_pos < 0){ + end_pos = AIFG_MAX_PORT -1 ; + } + + while(i != end_pos){ + if(aifg_pcb[i].stat == AIFG_PORT_IDLE){ + aifg_pcb[i].sapid = sapid; + aifg_pcb[i].cgid = cgid; + aifg_pcb[i].link_id = linkid; + aifg_pcb[i].upper_port = -1; //not assigned yet + aifg_pcb[i].stat = AIFG_PORT_INIT; + aifg_pcb[i].timer = 0; + aifg_pcb[i].pNextPort = aifg_pcb[i].pPrevPort = NULL; + aifg_pcb[i].ti = -1; //not assigned yet + aifg_pcb[i].ti_stat = 0; + aifg_pcb[i].ti_type = 0; + //aifg_pcb[i].sd_buffer = NULL; + + //add this port to opened port list + if(NULL == pOpenPort_h){ + //this is the first one + pOpenPort_h = &aifg_pcb[i]; + aifg_pcb[i].pNextOpenPort = NULL; + aifg_pcb[i].pPrevOpenPort = NULL; + } + else{ + //add to the head of the list + aifg_pcb[i].pNextOpenPort = pOpenPort_h; + aifg_pcb[i].pPrevOpenPort = NULL; + pOpenPort_h->pPrevOpenPort = &aifg_pcb[i]; + pOpenPort_h = &aifg_pcb[i]; + } + + //set next time start position + start_pos = i + 1; + if(start_pos >= AIFG_MAX_PORT) + start_pos = 0; + + return i; + } + if(++i >= AIFG_MAX_PORT) + i = 0; //restart from beginning + } + return -1; +} + +/* +Purpose:release a opened port +Input: int l_port: port number +Output: None +*/ +inline void aifg_port_release(aifg_port *p) +{ + if (p->stat == AIFG_PORT_IDLE) + return; + + if (p->upper_port != -1 && p->app_rel_flag == 0){ //release application if not released + aifg_send_release_ind(p->sapid, p->upper_port, p-aifg_pcb, REL_CAUSE_TEMP_FAILURE); + } + + //delete this port from the opened port list + if(NULL != p->pPrevOpenPort) + p->pPrevOpenPort->pNextOpenPort = p->pNextOpenPort; + else + pOpenPort_h = p->pNextOpenPort; + + if(NULL != p->pNextOpenPort) + p->pNextOpenPort->pPrevOpenPort = p->pPrevOpenPort; + + memset(p, 0, sizeof(*p)); + + aifg_debug_print(p-aifg_pcb, AIFG_EVENT_PORT_RELEASE, NULL, p-aifg_pcb); + + return; +} + +inline void aifg_link_release(int link_id) +{ + aifg_send_rlsd(link_id); + aifg_del_link(link_id); +} + +/* +Purpose: Get local port according to specific TI +Input: int ti: ti_value +int link_id: search port on which link +Output: int: local port number, -1 if not found +*/ +inline int aifg_ti2lport(int ti, int link_id, int pd) +{ + int ti_type; + assert(ti >=0 && ti < AIFG_MAX_TI_PER_LINK); + assert(link_id >=0 && link_id < SCCP_MAX_LINK); + + switch(pd) + { + case AIFG_PD_DTAP_CC: + ti_type = TI_FOR_CC; + break; + case AIFG_PD_DTAP_SMS: + ti_type = TI_FOR_SMS; + break; + case AIFG_PD_DTAP_SS: + ti_type = TI_FOR_SS; + break; + default: + assert(0); + } + + if(1 == link_info[link_id].ti[ti_type][ti].en_flag) + return link_info[link_id].ti[ti_type][ti].port; + + return -1; +} + +/* +Purpose:get the paging port according to the IMSI +Input: BYTE imsi_ptr: pointer to imsi buffer +Output: local port number, -1 if not found +*/ +inline int aifg_get_paging_port(int cgid, BYTE *imsi_ptr, int imsi_len) +{ + int retVal = -1; + aifg_port *pPort = pOpenPort_h; //pPagPort_h; + aifg_port *pTmpPort; + int i = 0; + + while (pPort != NULL){ + pTmpPort = pPort->pNextOpenPort; //pPort->pNextPort; + if(pPort->stat == AIFG_PORT_PAGING){ + if(memcmp(pPort->imsi, imsi_ptr, imsi_len) == 0){ + if (pPort->cgid == cgid){ + retVal = pPort-aifg_pcb; + // aifg_del_paging_port(pPort); + } + else{ + pPort->app_rel_flag = 1; + // aifg_del_paging_port(pPort); + aifg_port_release(pPort); + } + } + } + pPort = pTmpPort; + + if(++i > AIFG_MAX_PORT){ //for protection + break; + } + } + + return retVal; +} + +inline void aifg_add_paging_port(aifg_port *p) +{ + p->pPrevPort = NULL; + p->pNextPort = NULL; + + if (NULL == pPagPort_t){ + assert(pPagPort_h == NULL); //pointer to head should also be NULL + pPagPort_h = p; + pPagPort_t = p; + } + else{ + p->pPrevPort = pPagPort_t; + pPagPort_t->pNextPort = p; + pPagPort_t = p; + } + paging_port_count++; +} + +inline void aifg_del_paging_port(aifg_port *p) +{ + if(pPagPort_h == p) + pPagPort_h = p->pNextPort; //update list head + if(pPagPort_t == p) + pPagPort_t = p->pPrevPort; //update list tail + + if (p->pPrevPort != NULL){ + p->pPrevPort->pNextPort = p->pNextPort; + } + if (p->pNextPort != NULL){ + p->pNextPort->pPrevPort = p->pPrevPort; + } + p->pNextPort = NULL; + p->pPrevPort = NULL; + paging_port_count--; +} +//Circuit group & link management functions------------------------------------- +inline int aifg_get_cg(int dpc, int ni) +{ + int i = 0; + + while(i < AIFG_MAX_CG){ + if(cg[i].enable == 1 && cg[i].dpc == dpc && cg[i].ni == ni) + return i; + i++; + } + return -1; +} + +/* +Purpose: Get SCCP link info from its ID +Input: int sccp_link_id: ID of the connection +Output: aifg_link_info: SCCP link structure pointer +*/ +inline aifg_link_info *aifg_get_link_info(int linkid) +{ + assert(linkid < SCCP_MAX_LINK); + assert(link_info[linkid].en_flag == 1); + return &link_info[linkid]; +} + +/* +Purpose: Add a sccp link object to the link pool +Input: int linkid:ID of the link, assigned by SCCP module + int sapid: which sap manage this link + int status: next message is CC or DT1 +Output: int: result +*/ +inline int aifg_add_link(int linkid, int sapid) +{ + link_info[linkid].en_flag = 1; + link_info[linkid].ti_number = 0; + link_info[linkid].sapid = sapid; + link_info[linkid].cur_port = -1; + + return AIFG_SUCCEED; +} + +/* +Purpose: Delete specific connection from pool +Input: int sccp_link_id: ID of the connection +Output: int: result +*/ +inline int aifg_del_link(int link_id) +{ + int i = 0; + assert(link_id < SCCP_MAX_LINK); + + if(link_id > SCCP_MAX_LINK) + return AIFG_ERROR; + + //release ports belongs to this link, if any + while(link_info[link_id].ti_number > 0){ + if (1 == link_info[link_id].ti[TI_FOR_CC][i].en_flag){ + link_info[link_id].ti_number--; + aifg_port_release(&aifg_pcb[link_info[link_id].ti[TI_FOR_CC][i].port]); + } + if (1 == link_info[link_id].ti[TI_FOR_SMS][i].en_flag){ + link_info[link_id].ti_number--; + aifg_port_release(&aifg_pcb[link_info[link_id].ti[TI_FOR_SMS][i].port]); + } + if (1 == link_info[link_id].ti[TI_FOR_SS][i].en_flag){ + link_info[link_id].ti_number--; + aifg_port_release(&aifg_pcb[link_info[link_id].ti[TI_FOR_SS][i].port]); + } + + if (++i > AIFG_MAX_TI_PER_LINK) + break; + } + if(aifg_pcb[link_info[link_id].cur_port].ho_stat == 0) + aifg_port_release(&aifg_pcb[link_info[link_id].cur_port]); + + memset(&link_info[link_id], 0, sizeof(aifg_link_info)); + + return AIFG_SUCCEED; +} +//end of Circuit group & link management functions--------------------------------- + +//TI management function definition----------------------------------------------------- +/* +Purpose: get a new free TI of a link and add it +Input: int link_id: link ID + int port:port number of upper layer +Output: int: new assigned TI, -1 if not found +*/ +inline int aifg_get_ti(int link_id, int port, int ti_type) +{ + int i; + + assert(link_id < SCCP_MAX_LINK); + + for(i=0; i < 7; i++){ + if (0 == link_info[link_id].ti[ti_type][i].en_flag){ + aifg_add_ti(link_id, i, ti_type, port); + return i; + } + } + return -1; +} + +/* +Purpose: Add a new TI for a existed SCCP link +Input: int link_id: link ID of the TI + int ti: TI value + int port: port number of upper layer +Output: None +*/ +inline void aifg_add_ti(int link_id, int ti, int ti_type, int port) +{ + assert(ti <= AIFG_MAX_TI_PER_LINK); + assert(link_id < SCCP_MAX_LINK); + assert(ti_type < 3); + assert(link_info[link_id].ti[ti_type][ti].en_flag != 1); + + link_info[link_id].ti[ti_type][ti].en_flag = 1; + link_info[link_id].ti[ti_type][ti].port = port; + link_info[link_id].ti_number++; + + return; +} + +/* +Purpose: Delete a terminated TI +Input: int link_id: link ID of the TI + int ti: TI value + int ti_type: could be 1 of the 3: TI_FOR_CC, TI_FOR_SMS, TI_FOR_SS +Output: int: remaining TI number +*/ +inline int aifg_del_ti(int link_id, int ti, int ti_type) +{ + assert(ti <= AIFG_MAX_TI_PER_LINK); + assert(link_id < SCCP_MAX_LINK); + assert(ti_type < 3); + + if (ti >= 0 && link_info[link_id].ti[ti_type][ti].en_flag > 0){ + link_info[link_id].ti[ti_type][ti].en_flag = 0; + link_info[link_id].ti_number--; + } + + return link_info[link_id].ti_number; +} +//end of TI management function definition---------------------------------------------- + diff --git a/omc/plat/aif/src/aifg_mpp.c b/omc/plat/aif/src/aifg_mpp.c new file mode 100644 index 0000000..2dd4326 --- /dev/null +++ b/omc/plat/aif/src/aifg_mpp.c @@ -0,0 +1,7614 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_mpp.c +Description: Message process part of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-19 + +History: +2007-3-19 v9.0.0 Create +2007-7-1 v9.0.1 Apply new port process mechanism +*********************************************************************/ +#include "./include/aifg_msg.h" +#include "./include/aifg_var_ext.h" + +extern int msc_check_timeslot_avail(int tg_id); + +//global message structure definition +aifg_msg_t sd_msg; +aifg_msg_pre_decoded rv_msg; +SP_UiPriPara sccp_msg; + +int (*aifg_msg_rv_func_ptr[AIFG_MAX_MESSAGE])( + BYTE *src, + aifg_msg_pre_decoded *dst, + BYTE msg_len); +int (*aifg_msg_sd_func_ptr[AIFG_MAX_MESSAGE])( + aifg_msg_t *src, + BYTE *dst); + +enum{ + AIFG_PORT_NOT_NEED = -1, + UPPER_PROC = -1, + LOCAL_PROC = -2, +}; + +int aifg_check_timeslot_avail(int tg_id) +{ + return msc_check_timeslot_avail(tg_id); +} +//Message process function definition---------------------------------------------- +/* +Purpose:Convert protocol message type ot local message id +Input: int msg_type: protocol message type +Output: int: local message id +*/ +int aifg_msgtype_to_localid(aifg_pd pd, int msg_type) +{ + aifg_msg_protocol protocol = AIFG_MSG_BSSMAP; + + if (pd < AIFG_PD_BSSMAP_GLOBAL) + protocol = AIFG_MSG_DTAP; + + if(AIFG_MSG_DTAP == protocol){ + msg_type = msg_type & 0x3F; + switch(pd){ + case AIFG_PD_DTAP_MM: + switch(msg_type){ + //MM messages + case AIFG_MSG_T_IMSI_DETACH_IND: + return AIFG_MSG_ID_IMSI_DETACH_IND; + break; + case AIFG_MSG_T_LU_ACCEPT: + return AIFG_MSG_ID_LU_ACCEPT; + break; + case AIFG_MSG_T_LU_REQUEST: + return AIFG_MSG_ID_LU_REQUEST; + break; + case AIFG_MSG_T_AUTH_REQUEST: + return AIFG_MSG_ID_AUTH_REQUEST; + break; + case AIFG_MSG_T_AUTH_RESPONSE: + return AIFG_MSG_ID_AUTH_RESPONSE; + break; + case AIFG_MSG_T_CM_REEST_REQUEST: + return AIFG_MSG_ID_CM_REEST_REQUEST; + break; + case AIFG_MSG_T_LU_REJECT: + return AIFG_MSG_ID_LU_REJECT; + break; + case AIFG_MSG_T_CM_REJECT: + return AIFG_MSG_ID_CM_REJECT; + break; + case AIFG_MSG_T_ABORT: + return AIFG_MSG_ID_ABORT; + break; + case AIFG_MSG_T_MM_STATUS: + return AIFG_MSG_ID_MM_STATUS; + break; + case AIFG_MSG_T_CM_REQUEST: + return AIFG_MSG_ID_CM_REQUEST; + break; + case AIFG_MSG_T_ID_REQUEST: + return AIFG_MSG_ID_ID_REQUEST; + break; + case AIFG_MSG_T_ID_RESPONSE: + return AIFG_MSG_ID_ID_RESPONSE; + break; + case AIFG_MSG_T_TMSI_REALLOC_CMD: + return AIFG_MSG_ID_TMSI_REALLOC_CMD; + break; + case AIFG_MSG_T_AUTH_REJECT: + return AIFG_MSG_ID_AUTH_REJECT; + break; + case AIFG_MSG_T_CM_ACCEPT: + return AIFG_MSG_ID_CM_ACCEPT; + break; + case AIFG_MSG_T_CM_ABORT: + return AIFG_MSG_ID_CM_ABORT; + break; + case AIFG_MSG_T_TMSI_REALLOC_CMP: + return AIFG_MSG_ID_TMSI_REALLOC_CMP; + break; + case AIFG_MSG_T_MM_NULL: + return AIFG_MSG_ID_MM_NULL; + break; + case AIFG_MSG_T_MM_INFO: + return AIFG_MSG_ID_MM_INFO; + break; + default: + break; + } + break; + case AIFG_PD_DTAP_CC: //CC + switch(msg_type){ + case AIFG_MSG_T_PROGRESS: + return AIFG_MSG_ID_PROGRESS; + break; + case AIFG_MSG_T_MODIFY: + return AIFG_MSG_ID_MODIFY; + break; + case AIFG_MSG_T_MODIFY_CMP: + return AIFG_MSG_ID_MODIFY_CMP; + break; + case AIFG_MSG_T_MODIFY_REJECT: + return AIFG_MSG_ID_MODIFY_REJECT; + break; + case AIFG_MSG_T_USER_INFO: + return AIFG_MSG_ID_USER_INFO; + break; + case AIFG_MSG_T_DISCONNECT: + return AIFG_MSG_ID_DISCONNECT; + break; + case AIFG_MSG_T_HOLD_REJECT: + return AIFG_MSG_ID_HOLD_REJECT; + break; + case AIFG_MSG_T_RETRIEVE_REJECT: + return AIFG_MSG_ID_RETRIEVE_REJECT; + break; + case AIFG_MSG_T_START_DTMF_REJECT: + return AIFG_MSG_ID_START_DTMF_REJECT; + break; + case AIFG_MSG_T_FACILITY: + return AIFG_MSG_ID_FACILITY; + break; + case AIFG_MSG_T_CONGESTION_CTRL: + return AIFG_MSG_ID_CONGESTION_CTRL; + break; + case AIFG_MSG_T_NOTIFY: + return AIFG_MSG_ID_NOTIFY; + break; + case AIFG_MSG_T_START_DTMF: + return AIFG_MSG_ID_START_DTMF; + break; + case AIFG_MSG_T_START_DTMF_ACK: + return AIFG_MSG_ID_START_DTMF_ACK; + break; + case AIFG_MSG_T_STATUS: + return AIFG_MSG_ID_STATUS; + break; + case AIFG_MSG_T_ALERTING: + return AIFG_MSG_ID_ALERTING; + break; + case AIFG_MSG_T_CALL_CONFIRMED: + return AIFG_MSG_ID_CALL_CONFIRMED; + break; + case AIFG_MSG_T_CALL_PROCEEDING: + return AIFG_MSG_ID_CALL_PROCEEDING; + break; + case AIFG_MSG_T_CONNECT: + return AIFG_MSG_ID_CONNECT; + break; + case AIFG_MSG_T_EMERGENCY_SETUP: + return AIFG_MSG_ID_EMERGENCY_SETUP; + break; + case AIFG_MSG_T_RELEASE: + return AIFG_MSG_ID_RELEASE; + break; + case AIFG_MSG_T_RELEASE_CMP: + return AIFG_MSG_ID_RELEASE_CMP; + break; + case AIFG_MSG_T_SETUP: + return AIFG_MSG_ID_SETUP; + break; + case AIFG_MSG_T_CONNECT_ACK: + return AIFG_MSG_ID_CONNECT_ACK; + break; + case AIFG_MSG_T_HOLD: + return AIFG_MSG_ID_HOLD; + break; + case AIFG_MSG_T_HOLD_ACK: + return AIFG_MSG_ID_HOLD_ACK; + break; + case AIFG_MSG_T_RETRIEVE: + return AIFG_MSG_ID_RETRIEVE; + break; + case AIFG_MSG_T_RETRIEVE_ACK: + return AIFG_MSG_ID_RETRIEVE_ACK; + break; + case AIFG_MSG_T_STATUS_ENQ: + return AIFG_MSG_ID_STATUS_ENQ; + break; + case AIFG_MSG_T_STOP_DTMF: + return AIFG_MSG_ID_STOP_DTMF; + break; + case AIFG_MSG_T_STOP_DTMF_ACK: + return AIFG_MSG_ID_STOP_DTMF_ACK; + break; + default: + break; + } + break; + case AIFG_PD_DTAP_SMS: //SMS messages + switch(msg_type){ + case AIFG_MSG_T_RP_DATA_NW: + case AIFG_MSG_T_RP_DATA_MS: + return AIFG_MSG_ID_RP_DATA; + break; + case AIFG_MSG_T_RP_ACK_NW: + case AIFG_MSG_T_RP_ACK_MS: + return AIFG_MSG_ID_RP_ACK; + break; + case AIFG_MSG_T_RP_ERROR_NW: + case AIFG_MSG_T_RP_ERROR_MS: + return AIFG_MSG_ID_RP_ERROR; + break; + case AIFG_MSG_T_RP_SMMA: + return AIFG_MSG_ID_RP_SMMA; + break; + default: + break; + } + break; + case AIFG_PD_DTAP_SS: //SS messages + switch(msg_type){ + case AIFG_MSG_T_FACILITY_SS: + return AIFG_MSG_ID_FACILITY_SS; + break; + case AIFG_MSG_T_REGISTER: + return AIFG_MSG_ID_REGISTER; + break; + case AIFG_MSG_T_RELEASE_CMP_SS: + return AIFG_MSG_ID_RELEASE_CMP_SS; + break; + default: + break; + } + break; + default: + break; + } + } + else if(AIFG_MSG_BSSMAP == protocol){ + switch(msg_type){ + case AIFG_MSG_T_ASSIGN_REQ: + return AIFG_MSG_ID_ASSIGN_REQ; + case AIFG_MSG_T_ASSIGN_CMP: + return AIFG_MSG_ID_ASSIGN_CMP; + break; + case AIFG_MSG_T_ASSIGN_FAIL: + return AIFG_MSG_ID_ASSIGN_FAIL; + break; + case AIFG_MSG_T_BLOCK: + return AIFG_MSG_ID_BLOCK; + break; + case AIFG_MSG_T_BLOCK_ACK: + return AIFG_MSG_ID_BLOCK_ACK; + break; + case AIFG_MSG_T_UNBLOCK: + return AIFG_MSG_ID_UNBLOCK; + break; + case AIFG_MSG_T_UNBLOCK_ACK: + return AIFG_MSG_ID_UNBLOCK_ACK; + break; + case AIFG_MSG_T_HO_REQUEST: + return AIFG_MSG_ID_HO_REQUEST; + break; + case AIFG_MSG_T_HO_REQUIRED: + return AIFG_MSG_ID_HO_REQUIRED; + break; + case AIFG_MSG_T_HO_REQ_ACK: + return AIFG_MSG_ID_HO_REQ_ACK; + break; + case AIFG_MSG_T_HO_CMD: + return AIFG_MSG_ID_HO_CMD; + break; + case AIFG_MSG_T_HO_CMP: + return AIFG_MSG_ID_HO_CMP; + break; + case AIFG_MSG_T_HO_SUC: + return AIFG_MSG_ID_HO_SUC; + break; + case AIFG_MSG_T_HO_CAN_ENQ: + return AIFG_MSG_ID_HO_CAN_ENQ; + break; + case AIFG_MSG_T_HO_CAN_RESP: + return AIFG_MSG_ID_HO_CAN_RESP; + break; + case AIFG_MSG_T_HO_FAIL: + return AIFG_MSG_ID_HO_FAIL; + break; + case AIFG_MSG_T_RESRC_REQ: + return AIFG_MSG_ID_RESRC_REQ; + break; + case AIFG_MSG_T_RESRC_IND: + return AIFG_MSG_ID_RESRC_IND; + break; + case AIFG_MSG_T_PAGING: + return AIFG_MSG_ID_PAGING; + break; + case AIFG_MSG_T_CLR_REQ: + return AIFG_MSG_ID_CLR_REQ; + break; + case AIFG_MSG_T_CLR_CMD: + return AIFG_MSG_ID_CLR_CMD; + break; + case AIFG_MSG_T_CLR_CMP: + return AIFG_MSG_ID_CLR_CMP; + break; + case AIFG_MSG_T_RESET: + return AIFG_MSG_ID_RESET; + break; + case AIFG_MSG_T_RESET_ACK: + return AIFG_MSG_ID_RESET_ACK; + break; + case AIFG_MSG_T_HO_PERFORMED: + return AIFG_MSG_ID_HO_PERFORMED; + break; + case AIFG_MSG_T_OVERLOAD: + return AIFG_MSG_ID_OVERLOAD; + break; + case AIFG_MSG_T_MSC_INVK_TRACE: + return AIFG_MSG_ID_MSC_INVK_TRACE; + break; + case AIFG_MSG_T_BSC_INVK_TRACE: + return AIFG_MSG_ID_BSC_INVK_TRACE; + break; + case AIFG_MSG_T_CM_UPDATE: + return AIFG_MSG_ID_CM_UPDATE; + break;case AIFG_MSG_T_CIPHER_MODE_CMD: + return AIFG_MSG_ID_CIPHER_MODE_CMD; + break; + case AIFG_MSG_T_CIPHER_MODE_CMP: + return AIFG_MSG_ID_CIPHER_MODE_CMP; + break; + case AIFG_MSG_T_L3_INFO: + return AIFG_MSG_ID_L3_INFO; + break; + case AIFG_MSG_T_QUEUE_IND: + return AIFG_MSG_ID_QUEUE_IND; + break; + case AIFG_MSG_T_SAPI_REJ: + return AIFG_MSG_ID_SAPI_REJ; + break; + case AIFG_MSG_T_HO_REQ_REJ: + return AIFG_MSG_ID_HO_REQ_REJ; + break; + case AIFG_MSG_T_RESET_CC: + return AIFG_MSG_ID_RESET_CC; + break; + case AIFG_MSG_T_RESET_CC_ACK: + return AIFG_MSG_ID_RESET_CC_ACK; + break; + case AIFG_MSG_T_HO_DETECT: + return AIFG_MSG_ID_HO_DETECT; + break; + case AIFG_MSG_T_CC_GROUP_BLK: + return AIFG_MSG_ID_CC_GROUP_BLK; + break; + case AIFG_MSG_T_CC_GROUP_BLK_ACK: + return AIFG_MSG_ID_CC_GROUP_BLK_ACK; + break; + case AIFG_MSG_T_CC_GROUP_UNBLK: + return AIFG_MSG_ID_CC_GROUP_UNBLK; + break; + case AIFG_MSG_T_CC_GROUP_UNBLK_ACK: + return AIFG_MSG_ID_CC_GROUP_UNBLK_ACK; + break; + case AIFG_MSG_T_CONFUSION: + return AIFG_MSG_ID_CONFUSION; + break; + case AIFG_MSG_T_CM_REQUEST: + return AIFG_MSG_ID_CM_REQUEST; + break; + case AIFG_MSG_T_UNEQUIP_CC: + return AIFG_MSG_ID_UNEQUIP_CC; + break; + case AIFG_MSG_T_CIPHER_MODE_REJ: + return AIFG_MSG_ID_CIPHER_MODE_REJ; + break; + case AIFG_MSG_T_LOAD_IND: + return AIFG_MSG_ID_LOAD_IND; + break; + case AIFG_MSG_T_SUSPEND: + return AIFG_MSG_ID_SUSPEND; + break; + case AIFG_MSG_T_RESUME: + return AIFG_MSG_ID_RESUME; + break; + case AIFG_MSG_T_CHANGE_CC: + return AIFG_MSG_ID_CHANGE_CC; + break; + case AIFG_MSG_T_CHANGE_CC_ACK: + return AIFG_MSG_ID_CHANGE_CC_ACK; + break; + //case AIFG_MSG_T_LSA_INFO: + // return AIFG_MSG_ID_LSA_INFO; + //break; + case AIFG_MSG_T_LOC_INFO_CMD: + return AIFG_MSG_ID_LOC_INFO_CMD; + break; + case AIFG_MSG_T_LOC_INFO_RPT: + return AIFG_MSG_ID_LOC_INFO_RPT; + break; + default: + break; + } + } + + aifg_event = AIFG_ERR_UNKNOW_MSG; + return AIFG_ERROR; +} + +/* +Name: aifg_msg_proc +Purpose:Process received AIF message +Input: aifg_msg *src: Pointer to first byte of raw message +aifg_msg_pre_decoded *dst: target message structure +int sapid: SAP ID +Output: result +*/ +int aifg_msg_proc(BYTE *src, aifg_msg_pre_decoded *dst) +{ + int msg_len = 0, offset = 0; + int pd, ti; + aifg_msg_protocol protocol; + aifg_msg_type msg_type; + aifg_msg_id msg_id; + + assert(src != NULL); + assert(dst != NULL); + + memset(&dst->msg, 0, sizeof(dst->msg)); + + if ((protocol = src[0]) == 2){ + protocol = 0; //protocol=2, redirected BSSMAP message + } + + switch(protocol){ + case AIFG_MSG_DTAP: + msg_len = src[2] - 2; //skip pd/ti and msg type + pd = src[3] & 0x0F; + if(AIFG_PD_DTAP_MM != pd){ + ti = src[3] >> 4; + if(ti >= 8) + ti = ti & 0x07; //set ti flag to assigned by local + else + ti = ti | 0x08; //set ti flag to assigned by remote + } + else + ti = -1; //ti not present + + if(AIFG_PD_DTAP_SMS == pd){ + //get RP type + msg_type = src[4]; + msg_len = src[5]; + if(msg_type == AIFG_MSG_T_CP_DATA) + msg_id = aifg_msgtype_to_localid(pd, src[6]); + else{ + dst->id = AIFG_MSG_ID_IGNORED_MSG; //ignore CP-ACK, CP-ERROR + goto FINISH; + } + offset += 7; + } + else{ + msg_id = aifg_msgtype_to_localid(pd, src[4]); + offset += 5; + } + + if(AIFG_ERROR == msg_id) + goto ERR_PROC; + + break; + case AIFG_MSG_BSSMAP: + msg_len = src[1] - 1; //skip msg type + msg_id = aifg_msgtype_to_localid(AIFG_PD_BSSMAP_GLOBAL, src[2]); + if(AIFG_ERROR == msg_id) + goto ERR_PROC; + + if(msg_id <= AIFG_MSG_ID_HO_CAN_RESP) + pd = AIFG_PD_BSSMAP_GLOBAL; + else + pd = AIFG_PD_BSSMAP_DEDICATED; + + ti = -1; + offset += 3; + break; + default: + //Unknown message, ignore + aifg_debug_print(-1, AIFG_ERR_UNKNOW_MSG, NULL, 0); + goto ERR_PROC; + break; + } + if (msg_len < 0 || msg_len >= 256) + goto ERR_PROC; + + dst->id = msg_id; + dst->ti = ti; + dst->pd = pd; + + //predecode message + if(NULL != aifg_msg_rv_func_ptr[msg_id]){ + if(AIFG_SUCCEED != (aifg_msg_rv_func_ptr[msg_id])(&(src[offset]), dst, msg_len)){ + aifg_debug_print(-1, AIFG_ERR_ERROR_MSG, NULL, 0); + goto ERR_PROC; + } + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +void aifg_msg_redirect(SP_UiPriPara *msg) +{ + BYTE *pdata = NULL; + + if(AIFG_RUN_MODE_SINGLE == dual_server.mode) + return; + + if (msg->uUiPri == N_UNITDATA_IND) + pdata = msg->tPriUnion.tPriNUDataInd.tUD.aUserData; + else + pdata = msg->tPriUnion.tPriNConnInd.tUD.aUserData; + + if (pdata[0] == 0x02){ + return; //already redirected, discard + } + + aifg_debug_print(-1, AIFG_EVENT_REDIR_MSG, msg, 0); + pdata[0] = 0x02; //WXC2 system private BSSAP msg type, used for msg redirect + PostSp(msg); +} +//End of message process function definition----------------------------------------- + + + +//RV message process functions definition---------------------------------------------- +/* +Remark for all message encode functions +Input: BYTE *src: raw code of message to be processed +aifg_msg_pre_decoded *dst: target struct where the decoded information to be stored in +Output: int - result AIFG_SUCCEED / AIFG_ERROR, detailed info stored in aifg_event +*/ +//For embedded DTAP messages in BSSMAP message +int aifg_msg_decode_embeded_l3msg(BYTE *src, aifg_msg_predecode_l3msg *l3msg) +{ + int offset = 1; + + switch(src[offset++]){ //message type + case AIFG_MSG_T_CM_REQUEST: + l3msg->id = AIFG_MSG_ID_CM_REQUEST; + memset(&(l3msg->msg.cmRequest), 0, sizeof(l3msg->msg.cmRequest)); + + //CM service type + l3msg->msg.cmRequest.type.iei = AIFG_IE_ID_DT_CMTYPE; + l3msg->msg.cmRequest.type.ptr = src + offset; + l3msg->msg.cmRequest.type.hi_lo_flag = AIFG_LOW_BITS; + + //Ciphering key sequence number - M + l3msg->msg.cmRequest.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + l3msg->msg.cmRequest.cipherKeySeq.ptr = src + offset; + l3msg->msg.cmRequest.cipherKeySeq.hi_lo_flag = AIFG_HIGH_BITS; + offset++; + + //Mobile station classmark 2 - M + l3msg->msg.cmRequest.cm2.iei = AIFG_IE_ID_DT_MSCM2; + l3msg->msg.cmRequest.cm2.ptr = src + offset; + offset += src[offset] + 1; + + //Mobile identity - M + l3msg->msg.cmRequest.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + l3msg->msg.cmRequest.mobileId.ptr = src + offset; + offset += src[offset] + 1; + + //Priority + if((src[offset]&0xF0) == AIFG_IEI_DT_PRIORITYLEVEL){ + l3msg->msg.cmRequest.priority.iei = AIFG_IE_ID_DT_PRIORITYLEVEL; + l3msg->msg.cmRequest.priority.ptr = src + offset; + } + break; + + case AIFG_MSG_T_LU_REQUEST: + l3msg->id = AIFG_MSG_ID_LU_REQUEST; + memset(&(l3msg->msg.luRequest), 0, sizeof(l3msg->msg.luRequest)); + + //Location updating type - M + l3msg->msg.luRequest.type.iei = AIFG_IE_ID_DT_LUTYPE; + l3msg->msg.luRequest.type.ptr = src + offset; + l3msg->msg.luRequest.type.hi_lo_flag = AIFG_LOW_BITS; + + //Ciphering key sequence number - M + l3msg->msg.luRequest.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + l3msg->msg.luRequest.cipherKeySeq.ptr = src + offset; + l3msg->msg.luRequest.cipherKeySeq.hi_lo_flag = AIFG_HIGH_BITS; + offset++; + + //Location area identification - M + l3msg->msg.luRequest.lai.iei = AIFG_IE_ID_DT_LAI; + l3msg->msg.luRequest.lai.ptr = src + offset; + offset += 5; + + //Mobile station classmark 1 - M + l3msg->msg.luRequest.cm1.iei = AIFG_IE_ID_DT_MSCM1; + l3msg->msg.luRequest.cm1.ptr = src + offset; + offset++; + + //Mobile identity - M + l3msg->msg.luRequest.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + l3msg->msg.luRequest.mobileId.ptr = src + offset; + break; + + case AIFG_MSG_T_CM_REEST_REQUEST: + l3msg->id = AIFG_MSG_ID_CM_REEST_REQUEST; + memset(&(l3msg->msg.cmReEstReq), 0, sizeof(l3msg->msg.cmReEstReq)); + + //Ciphering key sequence number - M + l3msg->msg.cmReEstReq.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + l3msg->msg.cmReEstReq.cipherKeySeq.ptr = src + offset; + l3msg->msg.cmReEstReq.cipherKeySeq.hi_lo_flag = AIFG_LOW_BITS; + offset++; + + //Mobile station classmark 2 - M + l3msg->msg.cmReEstReq.cm2.iei = AIFG_IE_ID_DT_MSCM2; + l3msg->msg.cmReEstReq.cm2.ptr = src + offset; + offset += src[offset] + 1; + + //Mobile identity - M + l3msg->msg.cmReEstReq.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + l3msg->msg.cmReEstReq.mobileId.ptr = src + offset; + offset += src[offset] + 1; + + //Location area identification + if(src[offset] == AIFG_IEI_DT_LAI){ + offset++; //skip iei + l3msg->msg.cmReEstReq.lai.iei = AIFG_IE_ID_DT_LAI; + l3msg->msg.cmReEstReq.lai.ptr = src + offset; + } + break; + + case AIFG_MSG_T_PAGING_RESP: + l3msg->id = AIFG_MSG_ID_PAGING_RESP; + memset(&(l3msg->msg.pagingResp), 0, sizeof(l3msg->msg.pagingResp)); + + //Ciphering key sequence number - M + l3msg->msg.pagingResp.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + l3msg->msg.pagingResp.cipherKeySeq.ptr = src+offset; + l3msg->msg.pagingResp.cipherKeySeq.hi_lo_flag = AIFG_LOW_BITS; + offset++; + + //Mobile station classmark 2 - M + l3msg->msg.pagingResp.cm2.iei = AIFG_IE_ID_DT_MSCM2; + l3msg->msg.pagingResp.cm2.ptr = src + offset; + offset += src[offset] + 1; + + //Mobile identity - M + l3msg->msg.pagingResp.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + l3msg->msg.pagingResp.mobileId.ptr = src + offset; + offset += src[offset] + 1; + break; + + case AIFG_MSG_T_IMSI_DETACH_IND: + l3msg->id = AIFG_MSG_ID_IMSI_DETACH_IND; + memset(&(l3msg->msg.imsiDetachInd), 0, sizeof(l3msg->msg.imsiDetachInd)); + + //Mobile station classmark 1 - M + l3msg->msg.imsiDetachInd.cm1.iei = AIFG_IE_ID_DT_MSCM1; + l3msg->msg.imsiDetachInd.cm1.ptr = src + offset; + offset++; + + //Mobile identity - M + l3msg->msg.imsiDetachInd.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + l3msg->msg.imsiDetachInd.mobileId.ptr = src + offset; + break; + + case AIFG_MSG_T_RR_HO_CMD: + //TODO + break; + + default: + aifg_event = AIFG_ERR_ERROR_MSG; + goto ERR_PROC; + break; + } + + return AIFG_SUCCEED; + +ERR_PROC: + return AIFG_ERROR; +} + +//For assign request +int aifg_msg_rv_assignReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.assignReq), 0, sizeof(dst->msg.assignReq)); + + //channal type - M + if(src[offset] != AIFG_IEI_BM_CHANNELTYPE) + goto ERR_PROC; + offset++; + dst->msg.assignReq.channelType.iei = AIFG_IE_ID_BM_CHANNELTYPE; + dst->msg.assignReq.channelType.ptr = src+offset; + offset += src[offset] + 1; + + if(offset >= msg_len) goto FINISH; + + //L3 header information + if(src[offset] == AIFG_IEI_BM_L3HEADERINFO){ + offset++; + dst->msg.assignReq.l3HeaderInfo.iei = AIFG_IE_ID_BM_L3HEADERINFO; + dst->msg.assignReq.l3HeaderInfo.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //priority + if(src[offset] == AIFG_IEI_BM_PRIORITY){ + offset++; + dst->msg.assignReq.priority.iei = AIFG_IE_ID_BM_PRIORITY; + dst->msg.assignReq.priority.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //CIC + if(src[offset] == AIFG_IEI_BM_CIC){ + offset++; + dst->msg.assignReq.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.assignReq.cic.ptr = src+offset; + offset += 2; + if(offset >= msg_len) goto FINISH; + } + + //DTX flag + if(src[offset] == AIFG_IEI_BM_DTXFLAG){ + offset++; + dst->msg.assignReq.dtxFlag.iei = AIFG_IE_ID_BM_DTXFLAG; + dst->msg.assignReq.dtxFlag.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Interference Band To Be Used + if(src[offset] == AIFG_IEI_BM_BANDUSED){ + offset++; + dst->msg.assignReq.bandUsed.iei = AIFG_IE_ID_BM_BANDUSED; + dst->msg.assignReq.bandUsed.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Classmark Information 2 + if(src[offset] == AIFG_IEI_BM_CLASSMARKINFO2){ + offset++; + dst->msg.assignReq.cmInfo2.iei = AIFG_IE_ID_BM_CLASSMARKINFO2; + dst->msg.assignReq.cmInfo2.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Group Call Reference + if(src[offset] == AIFG_IEI_BM_GROUPCALLREF){ + offset++; + dst->msg.assignReq.groupRef.iei = AIFG_IE_ID_BM_GROUPCALLREF; + dst->msg.assignReq.groupRef.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Talker Flag + if(src[offset] == AIFG_IEI_BM_TALKERFLAG){ + dst->msg.assignReq.talkerFlag.iei = AIFG_IE_ID_BM_TALKERFLAG; + dst->msg.assignReq.talkerFlag.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Configuration Evolution Indication + if(src[offset] == AIFG_IEI_BM_CFGEVOIND){ + offset++; + dst->msg.assignReq.cfgEvoInd.iei = AIFG_IE_ID_BM_CFGEVOIND; + dst->msg.assignReq.cfgEvoInd.ptr = src+offset; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for assign complete +int aifg_msg_rv_assignComplete(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.assignComplete), 0, sizeof(dst->msg.assignComplete)); + + //RR cause + if(src[offset] == AIFG_IEI_BM_RRCAUSE){ + offset++; + dst->msg.assignComplete.rrcause.iei = AIFG_IE_ID_BM_RRCAUSE; + dst->msg.assignComplete.rrcause.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //CIC + if(src[offset] == AIFG_IEI_BM_CIC){ + offset++; + dst->msg.assignComplete.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.assignComplete.cic.ptr = src+offset; + offset += 2; + if(offset >= msg_len) goto FINISH; + } + + //Cell Identifier + if(src[offset] == AIFG_IEI_BM_CELLID){ + offset++; + dst->msg.assignComplete.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.assignComplete.cellId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Channel + if(src[offset] == AIFG_IEI_BM_CHOSENCHANNEL){ + offset++; + dst->msg.assignComplete.chosenChannel.iei = AIFG_IE_ID_BM_CHOSENCHANNEL; + dst->msg.assignComplete.chosenChannel.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Encryption Algorithm + if(src[offset] == AIFG_IEI_BM_CHOSENENCRYPT){ + offset++; + dst->msg.assignComplete.chosenEncrypt.iei = AIFG_IE_ID_BM_CHOSENENCRYPT; + dst->msg.assignComplete.chosenEncrypt.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOL){ + offset++; + dst->msg.assignComplete.circuitPool.iei = AIFG_IE_ID_BM_CIRCUITPOOL; + dst->msg.assignComplete.circuitPool.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Speech Version (Chosen) + if(src[offset] == AIFG_IEI_BM_SPEECHVER){ + offset++; + dst->msg.assignComplete.speechVer.iei = AIFG_IE_ID_BM_SPEECHVER; + dst->msg.assignComplete.speechVer.ptr = src+offset; + offset++; + } + if(offset >= msg_len) goto FINISH; + + //LSA Identifier + if(src[offset] == AIFG_IEI_BM_LSAID){ + offset++; + dst->msg.assignComplete.lsaId.iei = AIFG_IE_ID_BM_LSAID; + dst->msg.assignComplete.lsaId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; +} + +//for assign failure +int aifg_msg_rv_assignFailure(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.assignFailure), 0, sizeof(dst->msg.assignFailure)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.assignFailure.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.assignFailure.cause.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //RR cause + if(src[offset] == AIFG_IEI_BM_RRCAUSE){ + offset++; + dst->msg.assignFailure.rrcause.iei = AIFG_IE_ID_BM_RRCAUSE; + dst->msg.assignFailure.rrcause.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOL){ + offset++; + dst->msg.assignFailure.circuitPool.iei = AIFG_IE_ID_BM_CIRCUITPOOL; + dst->msg.assignFailure.circuitPool.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool List + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOLLIST){ + offset++; + dst->msg.assignFailure.circuitPoolList.iei = AIFG_IE_ID_BM_CIRCUITPOOLLIST; + dst->msg.assignFailure.circuitPoolList.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for block +int aifg_msg_rv_block(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.block), 0, sizeof(dst->msg.block)); + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.block.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.block.cic.ptr = src+offset; + offset += 2; + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.block.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.block.cause.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Connection Release Requested + if(src[offset] == AIFG_IEI_BM_CONNRELREQ){ + dst->msg.block.connectionRelReq.iei = AIFG_IE_ID_BM_CONNRELREQ; + dst->msg.block.connectionRelReq.ptr = src+offset; + offset++; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for block ack +int aifg_msg_rv_blockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//for unblock +int aifg_msg_rv_unBlock(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.blockAck), 0, sizeof(dst->msg.blockAck)); + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.unblock.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.unblock.cic.ptr = src+offset; + offset += 2; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for unblock ack +int aifg_msg_rv_unBlockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//for HANDOVER REQUEST +int aifg_msg_rv_HORequest(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HORequest), 0, sizeof(dst->msg.HORequest)); + + //channal type - M + if(src[offset] != AIFG_IEI_BM_CHANNELTYPE) + goto ERR_PROC; + offset++; + dst->msg.HORequest.channelType.iei = AIFG_IE_ID_BM_CHANNELTYPE; + dst->msg.HORequest.channelType.ptr = src+offset; + offset += src[offset] + 1; + + //Encryption Information - M + if(src[offset] != AIFG_IEI_BM_ENCRYPTINFO) + goto ERR_PROC; + offset++; + dst->msg.HORequest.encryptInfo.iei = AIFG_IE_ID_BM_ENCRYPTINFO; + dst->msg.HORequest.encryptInfo.ptr = src+offset; + offset += src[offset] + 1; + + //Classmark Information 1 - M + if(src[offset] == AIFG_IEI_BM_CLASSMARKINFO1){ + offset++; + dst->msg.HORequest.cmInfo1.iei = AIFG_IE_ID_BM_CLASSMARKINFO1; + dst->msg.HORequest.cmInfo1.ptr = src+offset; + offset++; + } + else if(src[offset] == AIFG_IEI_BM_CLASSMARKINFO2){ + offset++; + dst->msg.HORequest.cmInfo2.iei = AIFG_IE_ID_BM_CLASSMARKINFO2; + dst->msg.HORequest.cmInfo2.ptr = src+offset; + offset += src[offset] + 1; + } + else + goto ERR_PROC; + + //Cell Identifier (Serving) - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.HORequest.serving_cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HORequest.serving_cellId.ptr = src+offset; + offset += src[offset] + 1; + + //Priority + if(src[offset] == AIFG_IEI_BM_PRIORITY){ + offset++; + dst->msg.HORequest.priority.iei = AIFG_IE_ID_BM_PRIORITY; + dst->msg.HORequest.priority.ptr = src+offset; + offset += src[offset] + 1; + } + + //CIC + if(src[offset] == AIFG_IEI_BM_CIC){ + offset++; + dst->msg.HORequest.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.HORequest.cic.ptr = src+offset; + offset += 2; + } + + //Downlink DTX Flag + if(src[offset] == AIFG_IEI_BM_DTXFLAG){ + offset++; + dst->msg.HORequest.dtxFlag.iei = AIFG_IE_ID_BM_DTXFLAG; + dst->msg.HORequest.dtxFlag.ptr = src+offset; + offset++; + } + + //Cell Identifier (Target) - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.HORequest.target_cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HORequest.target_cellId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Interference Band To Be Used + if(src[offset] == AIFG_IEI_BM_BANDUSED){ + offset++; + dst->msg.HORequest.bandUsed.iei = AIFG_IE_ID_BM_BANDUSED; + dst->msg.HORequest.bandUsed.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Cause + if(src[offset] == AIFG_IEI_BM_CAUSE){ + offset++; + dst->msg.HORequest.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.HORequest.cause.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Classmark Information 3 + if(src[offset] == AIFG_IEI_BM_CLASSMARKINFO3){ + offset++; + dst->msg.HORequest.cmInfo3.iei = AIFG_IE_ID_BM_CLASSMARKINFO3; + dst->msg.HORequest.cmInfo3.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Current Channel type 1 + if(src[offset] == AIFG_IEI_BM_CURCHANNELTYPE1){ + offset++; + dst->msg.HORequest.curChanneltype1.iei = AIFG_IE_ID_BM_CURCHANNELTYPE1; + dst->msg.HORequest.curChanneltype1.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Speech Version (Used) + if(src[offset] == AIFG_IEI_BM_SPEECHVER){ + offset++; + dst->msg.HORequest.speechVer.iei = AIFG_IE_ID_BM_SPEECHVER; + dst->msg.HORequest.speechVer.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Group Call Reference + if(src[offset] == AIFG_IEI_BM_GROUPCALLREF){ + offset++; + dst->msg.HORequest.groupCallRef.iei = AIFG_IE_ID_BM_GROUPCALLREF; + dst->msg.HORequest.groupCallRef.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Talker Flag + if(src[offset] == AIFG_IEI_BM_TALKERFLAG){ + dst->msg.HORequest.talkerFlag.iei = AIFG_IE_ID_BM_TALKERFLAG; + dst->msg.HORequest.talkerFlag.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Configuration Evolution Indication + if(src[offset] == AIFG_IEI_BM_CFGEVOIND){ + offset++; + dst->msg.HORequest.cfgEvoInd.iei = AIFG_IE_ID_BM_CFGEVOIND; + dst->msg.HORequest.cfgEvoInd.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Encryption Algorithm (Serving) + if(src[offset] == AIFG_IEI_BM_CHOSENENCRYPT){ + offset++; + dst->msg.HORequest.chosenEncrypt.iei = AIFG_IE_ID_BM_CHOSENENCRYPT; + dst->msg.HORequest.chosenEncrypt.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Old BSS to New BSS Information + if(src[offset] == AIFG_IEI_BM_BSSOLDTONEW){ + offset++; + dst->msg.HORequest.oldBssToNew.iei = AIFG_IE_ID_BM_BSSOLDTONEW; + dst->msg.HORequest.oldBssToNew.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //LSA Information + if(src[offset] == AIFG_IEI_BM_LSAINFO){ + offset++; + dst->msg.HORequest.lsaInfo.iei = AIFG_IE_ID_BM_LSAINFO; + dst->msg.HORequest.lsaInfo.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + + +//for HANDOVER REQUIRED +int aifg_msg_rv_HORequired(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HORequired), 0, sizeof(dst->msg.HORequired)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.HORequired.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.HORequired.cause.ptr = src+offset; + offset += src[offset] + 1; + + + //Response Request + if(src[offset] == AIFG_IEI_BM_RESPREQ){ + dst->msg.HORequired.respReq.iei = AIFG_IE_ID_BM_RESPREQ; + dst->msg.HORequired.respReq.ptr = src+offset; + offset++; + } + + //Cell Identifier List (Preferred) - M + if(src[offset] != AIFG_IEI_BM_CELLIDLIST) + goto ERR_PROC; + offset++; + dst->msg.HORequired.cellIdList.iei = AIFG_IE_ID_BM_CELLIDLIST; + dst->msg.HORequired.cellIdList.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Circuit Pool List + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOLLIST){ + offset++; + dst->msg.HORequired.circuitPoolList.iei = AIFG_IE_ID_BM_CIRCUITPOOLLIST; + dst->msg.HORequired.circuitPoolList.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Current Channel type 1 + if(src[offset] == AIFG_IEI_BM_CURCHANNELTYPE1){ + offset++; + dst->msg.HORequired.curChannelType1.iei = AIFG_IE_ID_BM_CURCHANNELTYPE1; + dst->msg.HORequired.curChannelType1.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Speech Version (Used) + if(src[offset] == AIFG_IEI_BM_SPEECHVER){ + offset++; + dst->msg.HORequired.speechVer.iei = AIFG_IE_ID_BM_SPEECHVER; + dst->msg.HORequired.speechVer.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Queueing Indicator + if(src[offset] == AIFG_IEI_BM_QUEUEIND){ + offset++; + dst->msg.HORequired.queInd.iei = AIFG_IE_ID_BM_QUEUEIND; + dst->msg.HORequired.queInd.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Old BSS to New BSS Information + if(src[offset] == AIFG_IEI_BM_BSSOLDTONEW){ + offset++; + dst->msg.HORequired.oldBssToNew.iei = AIFG_IE_ID_BM_BSSOLDTONEW; + dst->msg.HORequired.oldBssToNew.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for HANDOVER REQUEST ACK +int aifg_msg_rv_HORequestAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HORequestAck), 0, sizeof(dst->msg.HORequestAck)); + + //Layer 3 Information - M + if(src[offset] != AIFG_IEI_BM_L3INFO) + goto ERR_PROC; + offset++; + dst->msg.HORequestAck.l3Info.len = src[offset++]; + dst->msg.HORequestAck.l3Info.ptr = src + offset; + offset += src[offset] + 1; + + //Chosen Channel + if(src[offset] == AIFG_IEI_BM_CHOSENCHANNEL){ + offset++; + dst->msg.HORequestAck.chosenChannel.iei = AIFG_IE_ID_BM_CHOSENCHANNEL; + dst->msg.HORequestAck.chosenChannel.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Encryption Algorithm + if(src[offset] == AIFG_IEI_BM_CHOSENENCRYPT){ + offset++; + dst->msg.HORequestAck.chosenEncrypt.iei = AIFG_IE_ID_BM_CHOSENENCRYPT; + dst->msg.HORequestAck.chosenEncrypt.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOL){ + offset++; + dst->msg.HORequestAck.circuitPool.iei = AIFG_IE_ID_BM_CIRCUITPOOL; + dst->msg.HORequestAck.circuitPool.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Speech Version + if(src[offset] == AIFG_IEI_BM_SPEECHVER){ + offset++; + dst->msg.HORequestAck.speechVer.iei = AIFG_IE_ID_BM_SPEECHVER; + dst->msg.HORequestAck.speechVer.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //CIC + if(src[offset] == AIFG_IEI_BM_CIC){ + offset++; + dst->msg.HORequestAck.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.HORequestAck.cic.ptr = src+offset; + offset += 2; + if(offset >= msg_len) goto FINISH; + } + + //LSA Identifier + if(src[offset] == AIFG_IEI_BM_LSAID){ + offset++; + dst->msg.HORequestAck.lsaId.iei = AIFG_IE_ID_BM_LSAID; + dst->msg.HORequestAck.lsaId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for HANDOVER COMMAND +int aifg_msg_rv_HOCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOCmd), 0, sizeof(dst->msg.HOCmd)); + + //Layer 3 Information - M + if(src[offset] != AIFG_IEI_BM_L3INFO) + goto ERR_PROC; + offset++; + if(AIFG_ERROR == aifg_msg_decode_embeded_l3msg(&(src[offset+1]), &(dst->msg.HOCmd.l3msg))) + goto ERR_PROC; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Cell Identifier + if(src[offset] == AIFG_IEI_BM_CELLID){ + offset++; + dst->msg.HOCmd.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HOCmd.cellId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//for HANDOVER COMPLETE +int aifg_msg_rv_HOComplete(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOComplete), 0, sizeof(dst->msg.HOComplete)); + + //RR cause + if(src[offset] == AIFG_IEI_BM_RRCAUSE){ + offset++; + dst->msg.HOComplete.rrcause.iei = AIFG_IE_ID_BM_RRCAUSE; + dst->msg.HOComplete.rrcause.ptr = src+offset; + offset++; + } + + return AIFG_SUCCEED; +} + +//HANDOVER CANDIDATE ENQUIRE +int aifg_msg_rv_HOCandEnq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOCandEnq), 0, sizeof(dst->msg.HOCandEnq)); + + //Number Of Mss - M + if(src[offset] != AIFG_IEI_BM_MSNUM) + goto ERR_PROC; + offset++; + dst->msg.HOCandEnq.msNum.iei = AIFG_IE_ID_BM_MSNUM; + dst->msg.HOCandEnq.msNum.ptr = src+offset; + offset++; + + //Cell Identifier List - M + if(src[offset] != AIFG_IEI_BM_CELLIDLIST) + goto ERR_PROC; + offset++; + dst->msg.HOCandEnq.cellIdList.iei = AIFG_IE_ID_BM_CELLIDLIST; + dst->msg.HOCandEnq.cellIdList.ptr = src+offset; + offset += src[offset] + 1; + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.HOCandEnq.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HOCandEnq.cellId.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//HANDOVER CANDIDATE RESPONSE +int aifg_msg_rv_HOCandResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOCandResp), 0, sizeof(dst->msg.HOCandResp)); + + //Number Of Mss - M + if(src[offset] != AIFG_IEI_BM_MSNUM) + goto ERR_PROC; + offset++; + dst->msg.HOCandResp.msNum.iei = AIFG_IE_ID_BM_MSNUM; + dst->msg.HOCandResp.msNum.ptr = src+offset; + offset++; + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.HOCandResp.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HOCandResp.cellId.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//HANDOVER FAILURE +int aifg_msg_rv_HOFailure(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOFailure), 0, sizeof(dst->msg.HOFailure)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.HOFailure.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.HOFailure.cause.ptr = src+offset; + offset += src[offset] + 1; + + //RR cause + if(src[offset] == AIFG_IEI_BM_RRCAUSE){ + offset++; + dst->msg.HOFailure.rrcause.iei = AIFG_IE_ID_BM_RRCAUSE; + dst->msg.HOFailure.rrcause.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOL){ + offset++; + dst->msg.HOFailure.circuitPool.iei = AIFG_IE_ID_BM_CIRCUITPOOL; + dst->msg.HOFailure.circuitPool.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Circuit Pool List + if(src[offset] == AIFG_IEI_BM_CIRCUITPOOLLIST){ + offset++; + dst->msg.HOFailure.circuitPoolList.iei = AIFG_IE_ID_BM_CIRCUITPOOLLIST; + dst->msg.HOFailure.circuitPoolList.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//RESOURCE REQUEST +int aifg_msg_rv_resrcReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.resrcReq), 0, sizeof(dst->msg.resrcReq)); + + //Periodicity - M + if(src[offset] != AIFG_IEI_BM_PERIODICITY) + goto ERR_PROC; + offset++; + dst->msg.resrcReq.periodicity.iei = AIFG_IE_ID_BM_PERIODICITY; + dst->msg.resrcReq.periodicity.ptr = src+offset; + offset++; + + //Resource Indication Method - M + if(src[offset] != AIFG_IEI_BM_RESOURCEINDMEHTOD) + goto ERR_PROC; + offset++; + dst->msg.resrcReq.resrcIndMethod.iei = AIFG_IE_ID_BM_RESOURCEINDMEHTOD; + dst->msg.resrcReq.resrcIndMethod.ptr = src+offset; + offset++; + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.resrcReq.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.resrcReq.cellId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Extended Resource Indicator + if(src[offset] == AIFG_IEI_BM_EXTRESOURCEIND){ + offset++; + dst->msg.resrcReq.extResrcInd.iei = AIFG_IE_ID_BM_EXTRESOURCEIND; + dst->msg.resrcReq.extResrcInd.ptr = src+offset; + offset++; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//RESOURCE INDICATION +int aifg_msg_rv_resrcInd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.resrcInd), 0, sizeof(dst->msg.resrcInd)); + + //Resource Indication Method - M + if(src[offset] != AIFG_IEI_BM_RESOURCEINDMEHTOD) + goto ERR_PROC; + offset++; + dst->msg.resrcInd.resrcIndMethod.iei = AIFG_IE_ID_BM_RESOURCEINDMEHTOD; + dst->msg.resrcInd.resrcIndMethod.ptr = src+offset; + offset++; + + //Resource Available + if(src[offset] == AIFG_IEI_BM_RESOURCEAVAIL){ + offset++; + dst->msg.resrcInd.resrcAvail.iei = AIFG_IE_ID_BM_RESOURCEAVAIL; + dst->msg.resrcInd.resrcAvail.ptr = src+offset; + offset += 20; + } + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.resrcInd.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.resrcInd.cellId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Total Resource Accessible + if(src[offset] == AIFG_IEI_BM_TOTALRESOURCE){ + offset++; + dst->msg.resrcInd.totalResrc.iei = AIFG_IE_ID_BM_TOTALRESOURCE; + dst->msg.resrcInd.totalResrc.ptr = src+offset; + offset += 4; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//RESOURCE INDICATION +int aifg_msg_rv_paging(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.paging), 0, sizeof(dst->msg.paging)); + + //IMSI - M + if(src[offset] != AIFG_IEI_BM_IMSI) + goto ERR_PROC; + offset++; + dst->msg.paging.imsi.iei = AIFG_IE_ID_BM_IMSI; + dst->msg.paging.imsi.ptr = src+offset; + offset += src[offset] + 1; + + //TMSI + if(src[offset] == AIFG_IEI_BM_TMSI){ + offset++; + dst->msg.paging.tmsi.iei = AIFG_IE_ID_BM_TMSI; + dst->msg.paging.tmsi.ptr = src+offset; + offset += src[offset] + 1; + } + + //Cell Identifier List - M + if(src[offset] != AIFG_IEI_BM_CELLIDLIST) + goto ERR_PROC; + offset++; + dst->msg.paging.cellIdList.iei = AIFG_IE_ID_BM_CELLIDLIST; + dst->msg.paging.cellIdList.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Channel Needed + if(src[offset] == AIFG_IEI_BM_CHANNELNEEDED){ + offset++; + dst->msg.paging.channelNeeded.iei = AIFG_IE_ID_BM_CHANNELNEEDED; + dst->msg.paging.channelNeeded.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //eMLPP Priority + if(src[offset] == AIFG_IEI_BM_EMLPP){ + offset++; + dst->msg.paging.eMLPPpri.iei = AIFG_IE_ID_BM_EMLPP; + dst->msg.paging.eMLPPpri.ptr = src+offset; + offset++; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CLEAR REQUEST +int aifg_msg_rv_clearReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.clearReq), 0, sizeof(dst->msg.clearReq)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.clearReq.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.clearReq.cause.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CLEAR COMMAND +int aifg_msg_rv_clearCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.clearCmd), 0, sizeof(dst->msg.clearCmd)); + + //Layer 3 Header Information + if(src[offset] == AIFG_IEI_BM_L3HEADERINFO){ + offset++; + dst->msg.clearCmd.l3HeaderInfo.iei = AIFG_IE_ID_BM_L3HEADERINFO; + dst->msg.clearCmd.l3HeaderInfo.ptr = src+offset; + offset += src[offset] + 1; + } + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.clearCmd.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.clearCmd.cause.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CLEAR COMPLETE +int aifg_msg_rv_clearCmp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//RESET +int aifg_msg_rv_reset(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.reset), 0, sizeof(dst->msg.reset)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE){ + aifg_event = AIFG_ERR_ERROR_MSG; + goto ERR_PROC; + } + offset++; + dst->msg.reset.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.reset.cause.ptr = src+offset; + + return AIFG_SUCCEED; + +ERR_PROC: + return AIFG_ERROR; +} + +//RESET ACK +int aifg_msg_rv_resetAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//HANDOVER PERFORMED +int aifg_msg_rv_HOPerformed(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HOPerformed), 0, sizeof(dst->msg.HOPerformed)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.HOPerformed.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.HOPerformed.cause.ptr = src+offset; + offset += src[offset] + 1; + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.HOPerformed.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.HOPerformed.cellId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Chosen Channel + if(src[offset] == AIFG_IEI_BM_CHOSENCHANNEL){ + offset++; + dst->msg.HOPerformed.chosenChannel.iei = AIFG_IE_ID_BM_CHOSENCHANNEL; + dst->msg.HOPerformed.chosenChannel.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Encryption Algorithm + if(src[offset] == AIFG_IEI_BM_CHOSENENCRYPT){ + offset++; + dst->msg.HOPerformed.chosenEncrypt.iei = AIFG_IE_ID_BM_CHOSENENCRYPT; + dst->msg.HOPerformed.chosenEncrypt.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Speech Version + if(src[offset] == AIFG_IEI_BM_SPEECHVER){ + offset++; + dst->msg.HOPerformed.speechVer.iei = AIFG_IE_ID_BM_SPEECHVER; + dst->msg.HOPerformed.speechVer.ptr = src+offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //LSA Identifier + if(src[offset] == AIFG_IEI_BM_LSAID){ + offset++; + dst->msg.HOPerformed.lsaId.iei = AIFG_IE_ID_BM_LSAID; + dst->msg.HOPerformed.lsaId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//OVERLOAD +int aifg_msg_rv_overload(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.overload), 0, sizeof(dst->msg.overload)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.overload.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.overload.cause.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Cell Identifier + if(src[offset] == AIFG_IEI_BM_CELLID){ + offset++; + dst->msg.overload.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.overload.cellId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//MSC INVOKE TRACE +int aifg_msg_rv_mscTrace(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.mscTrace), 0, sizeof(dst->msg.mscTrace)); + + //Trace Type - M + if(src[offset] != AIFG_IEI_BM_TRACETYPE) + goto ERR_PROC; + offset++; + dst->msg.mscTrace.traceType.iei = AIFG_IE_ID_BM_TRACETYPE; + dst->msg.mscTrace.traceType.ptr = src+offset; + offset++; + + //Trigger ID + if(src[offset] == AIFG_IEI_BM_TRIGGERID){ + offset++; + dst->msg.mscTrace.triggerId.iei = AIFG_IE_ID_BM_TRIGGERID; + dst->msg.mscTrace.triggerId.ptr = src+offset; + offset += src[offset] + 1; + } + + //Trace Reference - M + if(src[offset] != AIFG_IEI_BM_TRACEREF) + goto ERR_PROC; + offset++; + dst->msg.mscTrace.traceRef.iei = AIFG_IE_ID_BM_TRACEREF; + dst->msg.mscTrace.traceRef.ptr = src+offset; + offset += 2; + if(offset >= msg_len) goto FINISH; + + //Transactionid + if(src[offset] == AIFG_IEI_BM_TRANSACTIONID){ + offset++; + dst->msg.mscTrace.transId.iei = AIFG_IE_ID_BM_TRANSACTIONID; + dst->msg.mscTrace.transId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Mobile Identity + if(src[offset] == AIFG_IEI_BM_MOBILEID){ + offset++; + dst->msg.mscTrace.mobileId.iei = AIFG_IE_ID_BM_MOBILEID; + dst->msg.mscTrace.mobileId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //OMCId + if(src[offset] == AIFG_IEI_BM_OMCID){ + offset++; + dst->msg.mscTrace.omcId.iei = AIFG_IE_ID_BM_OMCID; + dst->msg.mscTrace.omcId.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//BSC INVOKE TRACE +int aifg_msg_rv_bscTrace(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.bscTrace), 0, sizeof(dst->msg.bscTrace)); + + //Trace Type - M + if(src[offset] != AIFG_IEI_BM_TRACETYPE) + goto ERR_PROC; + offset++; + dst->msg.bscTrace.traceType.iei = AIFG_IE_ID_BM_TRACETYPE; + dst->msg.bscTrace.traceType.ptr = src+offset; + offset++; + + //Forward Indicator + if(src[offset] == AIFG_IEI_BM_FORWARDIND){ + offset++; + dst->msg.bscTrace.forwardInd.iei = AIFG_IE_ID_BM_FORWARDIND; + dst->msg.bscTrace.forwardInd.ptr = src+offset; + offset++; + } + + //Triggerid + if(src[offset] == AIFG_IEI_BM_TRIGGERID){ + offset++; + dst->msg.bscTrace.triggerId.iei = AIFG_IE_ID_BM_TRIGGERID; + dst->msg.bscTrace.triggerId.ptr = src+offset; + offset += src[offset] + 1; + } + + //Trace Reference - M + if(src[offset] != AIFG_IEI_BM_TRACEREF) + goto ERR_PROC; + offset++; + dst->msg.bscTrace.traceRef.iei = AIFG_IE_ID_BM_TRACEREF; + dst->msg.bscTrace.traceRef.ptr = src+offset; + offset += 2; + if(offset >= msg_len) goto FINISH; + + //Transactionid + if(src[offset] == AIFG_IEI_BM_TRANSACTIONID){ + offset++; + dst->msg.bscTrace.transId.iei = AIFG_IE_ID_BM_TRANSACTIONID; + dst->msg.bscTrace.transId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //OMCId + if(src[offset] == AIFG_IEI_BM_OMCID){ + offset++; + dst->msg.bscTrace.omcId.iei = AIFG_IE_ID_BM_OMCID; + dst->msg.bscTrace.omcId.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CLASSMARK UPDATE +int aifg_msg_rv_cmUpdate(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.cmUpdate), 0, sizeof(dst->msg.cmUpdate)); + + //Classmark Information 2 + if(src[offset] != AIFG_IEI_BM_CLASSMARKINFO2) + goto ERR_PROC; + offset++; + dst->msg.cmUpdate.cmInfo2.iei = AIFG_IE_ID_BM_CLASSMARKINFO2; + dst->msg.cmUpdate.cmInfo2.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Classmark Information 2 + if(src[offset] == AIFG_IEI_BM_CLASSMARKINFO3){ + offset++; + dst->msg.cmUpdate.cmInfo3.iei = AIFG_IE_ID_BM_CLASSMARKINFO3; + dst->msg.cmUpdate.cmInfo3.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CIPHER MODE COMMAND +int aifg_msg_rv_cipherModeCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.cipherModeCmd), 0, sizeof(dst->msg.cipherModeCmd)); + + //Layer 3 Header Information + if(src[offset] == AIFG_IEI_BM_L3HEADERINFO){ + offset++; + dst->msg.cipherModeCmd.l3HeaderInfo.iei = AIFG_IE_ID_BM_L3HEADERINFO; + dst->msg.cipherModeCmd.l3HeaderInfo.ptr = src+offset; + offset += src[offset] + 1; + } + + //Encryption Information - M + if(src[offset] != AIFG_IEI_BM_ENCRYPTINFO) + goto ERR_PROC; + offset++; + dst->msg.cipherModeCmd.encryptInfo.iei = AIFG_IE_ID_BM_ENCRYPTINFO; + dst->msg.cipherModeCmd.encryptInfo.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Cipher Response Mode + if(src[offset] == AIFG_IEI_BM_CIPHERRESPMODE){ + offset++; + dst->msg.cipherModeCmd.cipherRespMode.iei = AIFG_IE_ID_BM_CIPHERRESPMODE; + dst->msg.cipherModeCmd.cipherRespMode.ptr = src+offset; + offset++; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CIPHER MODE COMPLETE +int aifg_msg_rv_cipherModeComp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.cipherModeCmd), 0, sizeof(dst->msg.cipherModeCmd)); + + if(offset >= msg_len) goto FINISH; + + //Layer 3 Header Information + if(src[offset] == AIFG_IEI_BM_L3MSGCONTENT){ + offset++; + dst->msg.cipherModeComp.l3MsgCont.iei = AIFG_IE_ID_BM_L3MSGCONTENT; + dst->msg.cipherModeComp.l3MsgCont.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Chosen Encryption Algorithm + if(src[offset] == AIFG_IEI_BM_CHOSENENCRYPT){ + offset++; + dst->msg.cipherModeComp.chosenEncrypt.iei = AIFG_IE_ID_BM_CHOSENENCRYPT; + dst->msg.cipherModeComp.chosenEncrypt.ptr = src+offset; + offset++; + } + +FINISH: + return AIFG_SUCCEED; +} + +//COMPLETE LAYER 3 INFORMATION +int aifg_msg_rv_completeL3Info(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.completeL3Info), 0, sizeof(dst->msg.completeL3Info)); + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.completeL3Info.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.completeL3Info.cellId.ptr = src+offset; + offset += src[offset] + 1; + + //Layer 3 Information - M + if(src[offset] != AIFG_IEI_BM_L3INFO) + goto ERR_PROC; + offset++; + if(AIFG_ERROR == aifg_msg_decode_embeded_l3msg(&(src[offset+1]), &(dst->msg.completeL3Info.l3msg))) + goto ERR_PROC; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Chosen Channel + if(src[offset] == AIFG_IEI_BM_CHOSENCHANNEL){ + offset++; + dst->msg.completeL3Info.chosenChannel.iei = AIFG_IE_ID_BM_CHOSENCHANNEL; + dst->msg.completeL3Info.chosenChannel.ptr = src+offset; + offset++; + } + + //LSA Identifier List + if(src[offset] == AIFG_IEI_BM_LSAIDLIST){ + offset++; + dst->msg.completeL3Info.lsaIdList.iei = AIFG_IE_ID_BM_LSAIDLIST; + dst->msg.completeL3Info.lsaIdList.ptr = src+offset; + offset += src[offset] + 1; + } + + //Location Information + if(src[offset] == AIFG_IEI_BM_LOCATIONINFO){ + offset++; + dst->msg.completeL3Info.locInfo.iei = AIFG_IE_ID_BM_LOCATIONINFO; + dst->msg.completeL3Info.locInfo.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//SAPI "n" REJECT +int aifg_msg_rv_sapi_n_rej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.sapi_n_rej), 0, sizeof(dst->msg.sapi_n_rej)); + + //DLCI - M + if(src[offset] != AIFG_IEI_BM_DLCI) + goto ERR_PROC; + offset++; + dst->msg.sapi_n_rej.dlci.iei = AIFG_IE_ID_BM_DLCI; + dst->msg.sapi_n_rej.dlci.ptr = src+offset; + offset++; + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.sapi_n_rej.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.sapi_n_rej.cause.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//HANDOVER REQUIRED REJECT +int aifg_msg_rv_HORequiredRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.HORequiredRej), 0, sizeof(dst->msg.HORequiredRej)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.HORequiredRej.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.HORequiredRej.cause.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//RESET CIRCUIT +int aifg_msg_rv_resetCircuit(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.resetCircuit), 0, sizeof(dst->msg.resetCircuit)); + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.resetCircuit.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.resetCircuit.cic.ptr = src+offset; + offset += 2; + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.resetCircuit.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.resetCircuit.cause.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//RESET CIRCUIT ACK +int aifg_msg_rv_resetCircuitAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_ERROR; +} + +//CIRCUIT GROUP BLOCK +int aifg_msg_rv_ccGroupBlock(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.ccGroupBlock), 0, sizeof(dst->msg.ccGroupBlock)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.ccGroupBlock.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.ccGroupBlock.cause.ptr = src+offset; + offset += src[offset] + 1; + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.ccGroupBlock.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.ccGroupBlock.cic.ptr = src+offset; + offset += 2; + + //Circuit Identity Code List - M + if(src[offset] != AIFG_IEI_BM_CICLIST) + goto ERR_PROC; + offset++; + dst->msg.ccGroupBlock.cicList.iei = AIFG_IE_ID_BM_CICLIST; + dst->msg.ccGroupBlock.cicList.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CIRCUIT GROUP BLOCK ACK +int aifg_msg_rv_ccGroupBlockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//CIRCUIT GROUP UNBLOCK +int aifg_msg_rv_ccGroupUnblock(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.ccGroupUnblock), 0, sizeof(dst->msg.ccGroupUnblock)); + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.ccGroupUnblock.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.ccGroupUnblock.cic.ptr = src+offset; + offset += 2; + + //Circuit Identity Code List - M + if(src[offset] != AIFG_IEI_BM_CICLIST) + goto ERR_PROC; + offset++; + dst->msg.ccGroupUnblock.cicList.iei = AIFG_IE_ID_BM_CICLIST; + dst->msg.ccGroupUnblock.cicList.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//CIRCUIT GROUP BLOCK ACK +int aifg_msg_rv_ccGroupUnblockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + return AIFG_SUCCEED; +} + +//CONFUSION +int aifg_msg_rv_confusion(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.confusion), 0, sizeof(dst->msg.confusion)); + + //Cause - M + if(src[offset] != AIFG_IEI_BM_CAUSE) + goto ERR_PROC; + offset++; + dst->msg.confusion.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.confusion.cause.ptr = src+offset; + offset += src[offset] + 1; + + //Diagnostics + if(src[offset] != AIFG_IEI_BM_DIGNOSTIC) + goto ERR_PROC; + offset++; + dst->msg.confusion.diagnostics.iei = AIFG_IE_ID_BM_DIGNOSTIC; + dst->msg.confusion.diagnostics.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//UNEQUIPPED CIRCUIT +int aifg_msg_rv_unequippedCircuit(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.upequipCircuit), 0, sizeof(dst->msg.upequipCircuit)); + + //CIC - M + if(src[offset] != AIFG_IEI_BM_CIC) + goto ERR_PROC; + offset++; + dst->msg.upequipCircuit.cic.iei = AIFG_IE_ID_BM_CIC; + dst->msg.upequipCircuit.cic.ptr = src+offset; + offset += 2; + + //Circuit Identity Code List + if(src[offset] != AIFG_IEI_BM_CICLIST) + goto ERR_PROC; + offset++; + dst->msg.upequipCircuit.cicList.iei = AIFG_IE_ID_BM_CICLIST; + dst->msg.upequipCircuit.cicList.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//LOAD INDICATION +int aifg_msg_rv_loadInd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.loadInd), 0, sizeof(dst->msg.loadInd)); + + //Time Indication - M + if(src[offset] != AIFG_IEI_BM_TIMEIND) + goto ERR_PROC; + offset++; + dst->msg.loadInd.timeInd.iei = AIFG_IE_ID_BM_TIMEIND; + dst->msg.loadInd.timeInd.ptr = src+offset; + offset++; + + //Cell Identifier - M + if(src[offset] != AIFG_IEI_BM_CELLID) + goto ERR_PROC; + offset++; + dst->msg.loadInd.cellId.iei = AIFG_IE_ID_BM_CELLID; + dst->msg.loadInd.cellId.ptr = src+offset; + offset += src[offset] + 1; + + //Cell Identifier List - M + if(src[offset] != AIFG_IEI_BM_CELLIDLIST) + goto ERR_PROC; + offset++; + dst->msg.loadInd.cellIdList.iei = AIFG_IE_ID_BM_CELLIDLIST; + dst->msg.loadInd.cellIdList.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Resource Situation + if(src[offset] == AIFG_IEI_BM_RESOURCESITUATION){ + offset++; + dst->msg.loadInd.resrcSit.iei = AIFG_IE_ID_BM_RESOURCESITUATION; + dst->msg.loadInd.resrcSit.ptr = src+offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Cause + if(src[offset] == AIFG_IEI_BM_CAUSE){ + offset++; + dst->msg.loadInd.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.loadInd.cause.ptr = src+offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//SUSPEND +int aifg_msg_rv_suspend(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.suspend), 0, sizeof(dst->msg.suspend)); + + //DLCI - M + if(src[offset] != AIFG_IEI_BM_DLCI) + goto ERR_PROC; + offset++; + dst->msg.sapi_n_rej.dlci.iei = AIFG_IE_ID_BM_DLCI; + dst->msg.sapi_n_rej.dlci.ptr = src+offset; + offset++; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//LSA INFORMATION +int aifg_msg_rv_lsaInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.lsaInfo), 0, sizeof(dst->msg.lsaInfo)); + + //LSA Information + if(src[offset] != AIFG_IEI_BM_LSAINFO) + goto ERR_PROC; + offset++; + dst->msg.lsaInfo.lsaInfo.iei = AIFG_IE_ID_BM_LSAINFO; + dst->msg.lsaInfo.lsaInfo.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//Location Information Command +int aifg_msg_rv_locInfoCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.locInfoCmd), 0, sizeof(dst->msg.locInfoCmd)); + + //Location Information + if(src[offset] != AIFG_IEI_BM_LOCATIONINFO) + goto ERR_PROC; + offset++; + dst->msg.locInfoCmd.locInfo.iei = AIFG_IE_ID_BM_LOCATIONINFO; + dst->msg.locInfoCmd.locInfo.ptr = src+offset; + offset += src[offset] + 1; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//Location Information Report +int aifg_msg_rv_locInfoReport(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.locInfoReport), 0, sizeof(dst->msg.locInfoReport)); + + if(src[offset] == AIFG_IEI_BM_LOCATIONINFO){ + //Location Information + offset++; + dst->msg.locInfoReport.locInfo.iei = AIFG_IE_ID_BM_LOCATIONINFO; + dst->msg.locInfoReport.locInfo.ptr = src+offset; + offset += src[offset] + 1; + } + else if(src[offset] == AIFG_IEI_BM_CAUSE){ + //Cause + offset++; + dst->msg.confusion.cause.iei = AIFG_IE_ID_BM_CAUSE; + dst->msg.confusion.cause.ptr = src+offset; + offset += src[offset] + 1; + } + else + goto ERR_PROC; + + return AIFG_SUCCEED; + +ERR_PROC: + aifg_event = AIFG_ERR_ERROR_MSG; + return AIFG_ERROR; +} + +//Authentication request +int aifg_msg_rv_authReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.authReq), 0, sizeof(dst->msg.authReq)); + + //Ciphering key sequence number - M + dst->msg.authReq.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + dst->msg.authReq.cipherKeySeq.ptr = src+offset; + dst->msg.authReq.cipherKeySeq.hi_lo_flag = AIFG_LOW_BITS; + offset++; + + //Auth. parameter RAND - M + dst->msg.authReq.authParamRAND.iei = AIFG_IE_ID_DT_AUTHRAND; + dst->msg.authReq.authParamRAND.ptr = src+offset; + + return AIFG_SUCCEED; +} + +//Authentication response +int aifg_msg_rv_authResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.authResp), 0, sizeof(dst->msg.authResp)); + + //Auth. parameter SRES - M + dst->msg.authResp.authParamSRES.iei = AIFG_IE_ID_DT_AUTHSRES; + dst->msg.authResp.authParamSRES.ptr = src; + + return AIFG_SUCCEED; +} + +//CM service request +int aifg_msg_rv_cmReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.cmReq), 0, sizeof(dst->msg.cmReq)); + + //CM service type + dst->msg.cmReq.type.iei = AIFG_IE_ID_DT_CMTYPE; + dst->msg.cmReq.type.ptr = src + offset; + dst->msg.cmReq.type.hi_lo_flag = AIFG_LOW_BITS; + + //Ciphering key sequence number - M + dst->msg.cmReq.cipherKeySeq.iei = AIFG_IE_ID_DT_CIPHERKEY; + dst->msg.cmReq.cipherKeySeq.ptr = src + offset; + dst->msg.cmReq.cipherKeySeq.hi_lo_flag = AIFG_HIGH_BITS; + offset++; + + //Mobile station classmark 2 - M + dst->msg.cmReq.cm2.iei = AIFG_IE_ID_DT_MSCM2; + dst->msg.cmReq.cm2.ptr = src + offset; + offset += src[offset] + 1; + + //Mobile identity - M + dst->msg.cmReq.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + dst->msg.cmReq.mobileId.ptr = src + offset; + offset += src[offset] + 1; + + //Priority + if((src[offset]&0xF0) == AIFG_IEI_DT_PRIORITYLEVEL){ + dst->msg.cmReq.priority.iei = AIFG_IE_ID_DT_PRIORITYLEVEL; + dst->msg.cmReq.priority.ptr = src + offset; + } + return AIFG_SUCCEED; +} + +//CM service reject +int aifg_msg_rv_cmRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.cmRej), 0, sizeof(dst->msg.cmRej)); + + //Reject cause - M + dst->msg.cmRej.rejCause.iei = AIFG_IE_ID_DT_REJCAUSE; + dst->msg.cmRej.rejCause.ptr = src; + + return AIFG_SUCCEED; +} + +//Abort +//The same as CM service reject + +//Identity request +int aifg_msg_rv_idReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.idReq), 0, sizeof(dst->msg.idReq)); + + //CM service type + dst->msg.idReq.type.iei = AIFG_IE_ID_DT_IDTYPE; + dst->msg.idReq.type.ptr = src; + dst->msg.idReq.type.hi_lo_flag = AIFG_LOW_BITS; + + return AIFG_SUCCEED; +} + +//Identity response +int aifg_msg_rv_idResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.idResp), 0, sizeof(dst->msg.idResp)); + + //Mobile identity - M + dst->msg.idResp.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + dst->msg.idResp.mobileId.ptr = src; + + return AIFG_SUCCEED; +} + +//Location updating accept +int aifg_msg_rv_luAccept(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.luAccept), 0, sizeof(dst->msg.luAccept)); + + //Location area identification - M + dst->msg.luAccept.lai.iei = AIFG_IE_ID_DT_LAI; + dst->msg.luAccept.lai.ptr = src; + offset += 5; + if(offset >= msg_len) goto FINISH; + + //Mobile identity + if(src[offset] == AIFG_IEI_DT_MOBILEID){ + offset++; //skip iei + dst->msg.luAccept.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + dst->msg.luAccept.mobileId.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Follow on proceed + if(src[offset] == AIFG_IEI_DT_FLONPROCEED){ + dst->msg.luAccept.followOnProc.iei = AIFG_IE_ID_DT_FLONPROCEED; + dst->msg.luAccept.followOnProc.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //CTS permission + if(src[offset] == AIFG_IEI_DT_CTS){ + offset++; //skip iei + dst->msg.luAccept.ctsPerm.iei = AIFG_IE_ID_DT_CTS; + dst->msg.luAccept.ctsPerm.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Location updating reject +//The same as CM service reject + +//MM information +int aifg_msg_rv_mmInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.mmInfo), 0, sizeof(dst->msg.mmInfo)); + if(offset >= msg_len) goto FINISH; + + //Full name for network + if(src[offset] == AIFG_IEI_DT_FULL_NWNAME){ + offset++; //skip iei + dst->msg.mmInfo.fullNetworkName.iei = AIFG_IE_ID_DT_FULL_NWNAME; + dst->msg.mmInfo.fullNetworkName.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Short name for network + if(src[offset] == AIFG_IEI_DT_SHORT_NWNAME){ + offset++; //skip iei + dst->msg.mmInfo.shortNetworkName.iei = AIFG_IE_ID_DT_SHORT_NWNAME; + dst->msg.mmInfo.shortNetworkName.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Universal time zone + if(src[offset] == AIFG_IEI_DT_TIMEZONE){ + offset++; //skip iei + dst->msg.mmInfo.timeZone.iei = AIFG_IE_ID_DT_TIMEZONE; + dst->msg.mmInfo.timeZone.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Network time and time zone + if(src[offset] == AIFG_IEI_DT_TZTIME){ + offset++; //skip iei + dst->msg.mmInfo.timeZoneAndTime.iei = AIFG_IE_ID_DT_TZTIME; + dst->msg.mmInfo.timeZoneAndTime.ptr = src + offset; + offset += 7; + if(offset >= msg_len) goto FINISH; + } + + //LSA Identity + if(src[offset] == AIFG_IEI_DT_LSAID){ + offset++; //skip iei + dst->msg.mmInfo.lsaId.iei = AIFG_IE_ID_DT_LSAID; + dst->msg.mmInfo.lsaId.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//MM status +//The same as CM service reject + +//TMSI reallocation command +int aifg_msg_rv_tmsiRealloc(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.tmsiReallocCmd), 0, sizeof(dst->msg.tmsiReallocCmd)); + + //Location area identification - M + dst->msg.tmsiReallocCmd.lai.iei = AIFG_IE_ID_DT_LAI; + dst->msg.tmsiReallocCmd.lai.ptr = src + offset; + offset += 5; + + //Mobile identity - M + dst->msg.tmsiReallocCmd.mobileId.iei = AIFG_IE_ID_DT_MOBILEID; + dst->msg.tmsiReallocCmd.mobileId.ptr = src + offset; + + return AIFG_SUCCEED; +} + +//Alerting +int aifg_msg_rv_alert(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.alert), 0, sizeof(dst->msg.alert)); + if(offset >= msg_len) goto FINISH; + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.alert.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.alert.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Progress indicator + if(src[offset] == AIFG_IEI_DT_PROGIND){ + offset++; //Skip iei + dst->msg.alert.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.alert.progressInd.ptr = src + offset; + offset += 3; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.alert.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.alert.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.alert.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.alert.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Call confirmed +int aifg_msg_rv_callConfirm(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.callConfirm), 0, sizeof(dst->msg.callConfirm)); + if(offset >= msg_len) goto FINISH; + + //Repeat Indicator + if((src[offset] & 0xF0) == AIFG_IEI_DT_REPEATIND){ + dst->msg.callConfirm.reptInd.iei = AIFG_IE_ID_DT_REPEATIND; + dst->msg.callConfirm.reptInd.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 1 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.callConfirm.bearCap1.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.callConfirm.bearCap1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 2 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.callConfirm.bearCap2.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.callConfirm.bearCap2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.callConfirm.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.callConfirm.cause.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //CC Capabilities + if(src[offset] == AIFG_IEI_DT_CCCAP){ + offset++; //Skip iei + dst->msg.callConfirm.ccCap.iei = AIFG_IE_ID_DT_CCCAP; + dst->msg.callConfirm.ccCap.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Call proceeding +int aifg_msg_rv_callProceed(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.callProceed), 0, sizeof(dst->msg.callProceed)); + if(offset >= msg_len) goto FINISH; + + //Repeat Indicator + if((src[offset] & 0xF0) == AIFG_IEI_DT_REPEATIND){ + dst->msg.callProceed.reptInd.iei = AIFG_IE_ID_DT_REPEATIND; + dst->msg.callProceed.reptInd.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 1 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.callProceed.bearCap1.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.callProceed.bearCap1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 2 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.callProceed.bearCap2.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.callProceed.bearCap2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.callProceed.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.callProceed.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Progress indicator + if(src[offset] == AIFG_IEI_DT_PROGIND){ + offset++; //Skip iei + dst->msg.callProceed.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.callProceed.progressInd.ptr = src + offset; + offset += 3; + if(offset >= msg_len) goto FINISH; + } + + //Priority granted + if((src[offset] & 0xF0) == AIFG_IEI_DT_PRIORITYLEVEL){ + dst->msg.callProceed.priority.iei = AIFG_IE_ID_DT_PRIORITYLEVEL; + dst->msg.callProceed.priority.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Congestion control +int aifg_msg_rv_congestCtrl(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.congestCtrl), 0, sizeof(dst->msg.congestCtrl)); + + //Congestion level + dst->msg.congestCtrl.congestLev.iei = AIFG_IE_ID_DT_CONGESTLEVEL; + dst->msg.congestCtrl.congestLev.ptr = src + offset; + dst->msg.congestCtrl.congestLev.hi_lo_flag = AIFG_LOW_BITS; + offset++; + if(offset >= msg_len) goto FINISH; + + //Cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.congestCtrl.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.congestCtrl.cause.ptr = src + offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Connect +int aifg_msg_rv_connect(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.connect), 0, sizeof(dst->msg.connect)); + if(offset >= msg_len) goto FINISH; + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.connect.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.connect.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Progress indicator + if(src[offset] == AIFG_IEI_DT_PROGIND){ + offset++; //Skip iei + dst->msg.connect.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.connect.progressInd.ptr = src + offset; + offset += 3; + if(offset >= msg_len) goto FINISH; + } + + //Connected number + if(src[offset] == AIFG_IEI_DT_CONNNUM){ + offset++; //Skip iei + dst->msg.connect.connNum.iei = AIFG_IE_ID_DT_CONNNUM; + dst->msg.connect.connNum.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Connected subaddress + if(src[offset] == AIFG_IEI_DT_CONNSUBADDR){ + offset++; //Skip iei + dst->msg.connect.connSubaddr.iei = AIFG_IE_ID_DT_CONNSUBADDR; + dst->msg.connect.connSubaddr.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.connect.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.connect.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.connect.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.connect.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Disconnect +int aifg_msg_rv_disconnect(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.disconnect), 0, sizeof(dst->msg.disconnect)); + + //Cause + dst->msg.disconnect.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.disconnect.cause.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.disconnect.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.disconnect.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Progress indicator + if(src[offset] == AIFG_IEI_DT_PROGIND){ + offset++; //Skip iei + dst->msg.disconnect.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.disconnect.progressInd.ptr = src + offset; + offset += 3; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.disconnect.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.disconnect.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.disconnect.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.disconnect.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//EMERGENCY SETUP +int aifg_msg_rv_eSetup(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.eSetup), 0, sizeof(dst->msg.eSetup)); + if(offset >= msg_len) goto FINISH; + + //Bearer capability + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.eSetup.bearCap.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.eSetup.bearCap.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Facility +int aifg_msg_rv_facility(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.facility), 0, sizeof(dst->msg.facility)); + + //Facility - M + dst->msg.facility.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.facility.facility.ptr = src; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.facility.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.facility.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Hold Reject +int aifg_msg_rv_holdRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.holdRej), 0, sizeof(dst->msg.holdRej)); + + //Cause + dst->msg.holdRej.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.holdRej.cause.ptr = src; + + return AIFG_SUCCEED; +} + + +//Modify +int aifg_msg_rv_modify(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.modify), 0, sizeof(dst->msg.modify)); + + //Bearer capability - M + dst->msg.modify.bearCap.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.modify.bearCap.ptr = src + offset; + offset += src[offset] + 1; + + //Low layer comp. + if(src[offset] == AIFG_IEI_DT_LOWCOM){ + offset++; //Skip iei + dst->msg.modify.lowLComp.iei = AIFG_IE_ID_DT_LOWCOM; + dst->msg.modify.lowLComp.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //High layer comp. + if(src[offset] == AIFG_IEI_DT_HIGHCOM){ + offset++; //Skip iei + dst->msg.modify.highLComp.iei = AIFG_IE_ID_DT_HIGHCOM; + dst->msg.modify.highLComp.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Reverse call setup direction + if(src[offset] == AIFG_IEI_DT_REVCALLDIR){ + offset++; //Skip iei + dst->msg.modify.revCallSetDir.iei = AIFG_IE_ID_DT_REVCALLDIR; + dst->msg.modify.revCallSetDir.ptr = src; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Modify complete +//The same as modify + +//Modify reject +int aifg_msg_rv_modifyRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.modifyRej), 0, sizeof(dst->msg.modifyRej)); + + //Bearer capability - M + dst->msg.modifyRej.bearCap.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.modifyRej.bearCap.ptr = src + offset; + offset += src[offset] + 1; + + //Cause - M + dst->msg.modifyRej.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.modifyRej.cause.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //Low layer comp. + if(src[offset] == AIFG_IEI_DT_LOWCOM){ + offset++; //Skip iei + dst->msg.modifyRej.lowLComp.iei = AIFG_IE_ID_DT_LOWCOM; + dst->msg.modifyRej.lowLComp.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //High layer comp. + if(src[offset] == AIFG_IEI_DT_HIGHCOM){ + offset++; //Skip iei + dst->msg.modifyRej.highLComp.iei = AIFG_IE_ID_DT_HIGHCOM; + dst->msg.modifyRej.highLComp.ptr = src + offset; + offset += src[offset] + 1; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Notify +int aifg_msg_rv_notify(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.notify), 0, sizeof(dst->msg.notify)); + + //Notification indicator + dst->msg.notify.notifyInd.iei = AIFG_IE_ID_DT_NOTIIND; + dst->msg.notify.notifyInd.ptr = src; + + return AIFG_SUCCEED; +} + +//Progress +int aifg_msg_rv_progress(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.progress), 0, sizeof(dst->msg.progress)); + + //Progress indicator - M + dst->msg.progress.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.progress.progressInd.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.progress.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.progress.user_user.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Release +int aifg_msg_rv_release(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.release), 0, sizeof(dst->msg.release)); + if(offset >= msg_len) goto FINISH; + + //Cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.release.cause1.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.release.cause1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Second cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.release.cause2.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.release.cause2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.release.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.release.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.release.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.release.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.release.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.release.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Release complete +int aifg_msg_rv_releaseComp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.releaseComp), 0, sizeof(dst->msg.releaseComp)); + if(offset >= msg_len) goto FINISH; + + //Cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.releaseComp.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.releaseComp.cause.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.releaseComp.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.releaseComp.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.releaseComp.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.releaseComp.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.releaseComp.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.releaseComp.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Retrieve reject +//The same as Hold Reject + + +//Setup +int aifg_msg_rv_setup(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.setup), 0, sizeof(dst->msg.setup)); + if(offset >= msg_len) goto FINISH; + + //BC repeat indicator + if((src[offset] & 0xF0) == AIFG_IEI_DT_REPEATIND){ + dst->msg.setup.reptInd_bc.iei = AIFG_IE_ID_DT_REPEATIND; + dst->msg.setup.reptInd_bc.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 1 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.setup.bearCap1.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.setup.bearCap1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Bearer capability 2 + if(src[offset] == AIFG_IEI_DT_BEARERCAP){ + offset++; //Skip iei + dst->msg.setup.bearCap2.iei = AIFG_IE_ID_DT_BEARERCAP; + dst->msg.setup.bearCap2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.setup.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.setup.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Progress indicator + if(src[offset] == AIFG_IEI_DT_PROGIND){ + offset++; //Skip iei + dst->msg.setup.progressInd.iei = AIFG_IE_ID_DT_PROGIND; + dst->msg.setup.progressInd.ptr = src + offset; + offset += 3; + if(offset >= msg_len) goto FINISH; + } + + //Signal + if(src[offset] == AIFG_IEI_DT_SIGNAL){ + offset++; //Skip iei + dst->msg.setup.signal.iei = AIFG_IE_ID_DT_SIGNAL; + dst->msg.setup.signal.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Calling party BCD number + if(src[offset] == AIFG_IEI_DT_CALLERBCD){ + offset++; //Skip iei + dst->msg.setup.callingBCD.iei = AIFG_IE_ID_DT_CALLERBCD; + dst->msg.setup.callingBCD.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Calling party subaddress + if(src[offset] == AIFG_IEI_DT_CALLERSUBADDR){ + offset++; //Skip iei + dst->msg.setup.callingSubaddr.iei = AIFG_IE_ID_DT_CALLERSUBADDR; + dst->msg.setup.callingSubaddr.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Called party BCD number + if(src[offset] == AIFG_IEI_DT_CALLEDBCD){ + offset++; //Skip iei + dst->msg.setup.calledBCD.iei = AIFG_IE_ID_DT_CALLEDBCD; + dst->msg.setup.calledBCD.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Called party subaddress + if(src[offset] == AIFG_IEI_DT_CALLEDSUBADDR){ + offset++; //Skip iei + dst->msg.setup.calledSubaddr.iei = AIFG_IE_ID_DT_CALLEDSUBADDR; + dst->msg.setup.calledSubaddr.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Redirecting party BCD number + if(src[offset] == AIFG_IEI_DT_REDIRBCD){ + offset++; //Skip iei + dst->msg.setup.redirBCD.iei = AIFG_IE_ID_DT_REDIRBCD; + dst->msg.setup.redirBCD.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Redirecting party sub-address + if(src[offset] == AIFG_IEI_DT_REDIRSUBADDR){ + offset++; //Skip iei + dst->msg.setup.redirSubaddr.iei = AIFG_IE_ID_DT_REDIRSUBADDR; + dst->msg.setup.redirSubaddr.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //LLC repeat indicator + if((src[offset] & 0xF0) == AIFG_IEI_DT_REPEATIND){ + dst->msg.setup.reptInd_llc.iei = AIFG_IE_ID_DT_REPEATIND; + dst->msg.setup.reptInd_llc.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Low layer comp 1 + if(src[offset] == AIFG_IEI_DT_LOWCOM){ + offset++; //Skip iei + dst->msg.setup.lowLComp1.iei = AIFG_IE_ID_DT_LOWCOM; + dst->msg.setup.lowLComp1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Low layer comp 2 + if(src[offset] == AIFG_IEI_DT_LOWCOM){ + offset++; //Skip iei + dst->msg.setup.lowLComp2.iei = AIFG_IE_ID_DT_LOWCOM; + dst->msg.setup.lowLComp2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //HLC repeat indicator + if((src[offset] & 0xF0) == AIFG_IEI_DT_REPEATIND){ + dst->msg.setup.reptInd_hlc.iei = AIFG_IE_ID_DT_REPEATIND; + dst->msg.setup.reptInd_hlc.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //High layer comp 1 + if(src[offset] == AIFG_IEI_DT_HIGHCOM){ + offset++; //Skip iei + dst->msg.setup.highLComp1.iei = AIFG_IE_ID_DT_HIGHCOM; + dst->msg.setup.highLComp1.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //High layer comp 2 + if(src[offset] == AIFG_IEI_DT_HIGHCOM){ + offset++; //Skip iei + dst->msg.setup.highLComp2.iei = AIFG_IE_ID_DT_HIGHCOM; + dst->msg.setup.highLComp2.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //User-user + if(src[offset] == AIFG_IEI_DT_USERUSER){ + offset++; //Skip iei + dst->msg.setup.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.setup.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + } + + //Priority + if((src[offset] & 0xF0) == AIFG_IEI_DT_PRIORITYLEVEL){ + dst->msg.setup.priority.iei = AIFG_IE_ID_DT_PRIORITYLEVEL; + dst->msg.setup.priority.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + } + + //Alert + if(src[offset] == AIFG_IEI_DT_ALERTPATTERN){ + offset++; //Skip iei + dst->msg.setup.alert.iei = AIFG_IE_ID_DT_ALERTPATTERN; + dst->msg.setup.alert.ptr = src + offset; + offset += src[offset] + 1; + } + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.setup.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.setup.ssVer.ptr = src + offset; + offset += src[offset] + 1; + } + + //CLIR suppression + if(src[offset] == AIFG_IEI_DT_CLIRSUP){ + dst->msg.setup.clirSuppr.iei = AIFG_IE_ID_DT_CLIRSUP; + dst->msg.setup.clirSuppr.ptr = src + offset; + offset++; + } + + //CLIR invocation + if(src[offset] == AIFG_IEI_DT_CLIRIVO){ + dst->msg.setup.clirInvo.iei = AIFG_IE_ID_DT_CLIRIVO; + dst->msg.setup.clirInvo.ptr = src + offset; + offset++; + } + + //CC capabilities + if(src[offset] == AIFG_IEI_DT_CCCAP){ + dst->msg.setup.ccCap.iei = AIFG_IE_ID_DT_CCCAP; + dst->msg.setup.ccCap.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Start DTMF +int aifg_msg_rv_startDTMF(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.startDTMF), 0, sizeof(dst->msg.startDTMF)); + + //Keypad facility - M + dst->msg.startDTMF.keypadFacility.iei = AIFG_IE_ID_DT_KEYPAD; + dst->msg.startDTMF.keypadFacility.ptr = src + 1; //skip IEI + + return AIFG_SUCCEED; +} + +//Start DTMF Acknowledge +//The same as Start DTMF + +//Start DTMF reject +//The same as Hold Reject + +//Status +int aifg_msg_rv_status(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.status), 0, sizeof(dst->msg.status)); + + //Cause - M + dst->msg.status.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.status.cause.ptr = src + offset; + offset += src[offset] + 1; + + //Call state - M + dst->msg.status.callState.iei = AIFG_IE_ID_DT_CALLSTAT; + dst->msg.status.callState.ptr = src + offset; + offset++; + if(offset >= msg_len) goto FINISH; + + //Auxiliary states + if(src[offset] == AIFG_IEI_DT_AUXSTAT){ + offset++; //Skip iei + dst->msg.status.auxState.iei = AIFG_IE_ID_DT_AUXSTAT; + dst->msg.status.auxState.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//User information +int aifg_msg_rv_userInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.userInfo), 0, sizeof(dst->msg.userInfo)); + + //User-user - M + dst->msg.userInfo.user_user.iei = AIFG_IE_ID_DT_USERUSER; + dst->msg.userInfo.user_user.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) goto FINISH; + + //More data + if(src[offset] == AIFG_IEI_DT_MOREDATA){ + offset++; //Skip iei + dst->msg.userInfo.moreDate.iei = AIFG_IE_ID_DT_MOREDATA; + dst->msg.userInfo.moreDate.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//Facility SS +int aifg_msg_rv_facilitySS(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.facilitySS), 0, sizeof(dst->msg.facilitySS)); + + //Facility + dst->msg.facilitySS.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.facilitySS.facility.ptr = src; + + return AIFG_SUCCEED; +} + +//Release Complete SS +int aifg_msg_rv_releaseCompSS(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.releaseCompSS), 0, sizeof(dst->msg.releaseCompSS)); + + //Cause + if(src[offset] == AIFG_IEI_DT_CAUSE){ + offset++; //Skip iei + dst->msg.releaseCompSS.cause.iei = AIFG_IE_ID_DT_CAUSE; + dst->msg.releaseCompSS.cause.ptr = src + offset; + } + + //Facility + if(src[offset] == AIFG_IEI_DT_FACILITY){ + offset++; //Skip iei + dst->msg.releaseCompSS.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.releaseCompSS.facility.ptr = src + offset; + } + + return AIFG_SUCCEED; +} + +//Register +int aifg_msg_rv_register(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.registerSS), 0, sizeof(dst->msg.registerSS)); + + //Facility + if(src[offset] != AIFG_IEI_DT_FACILITY) + goto ERR_PROC; + + offset++; //Skip iei + dst->msg.registerSS.facility.iei = AIFG_IE_ID_DT_FACILITY; + dst->msg.registerSS.facility.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) + goto FINISH; + + + //SS version + if(src[offset] == AIFG_IEI_DT_SSVER){ + offset++; //Skip iei + dst->msg.registerSS.ssVer.iei = AIFG_IE_ID_DT_SSVER; + dst->msg.registerSS.ssVer.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; + +ERR_PROC: + aifg_debug_print(-1, AIFG_ERR_MISS_MANDATORY, dst, 0); + return AIFG_ERROR; +} + +//SMS +//RP DATA +int aifg_msg_rv_rp_data(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.rpData), 0, sizeof(dst->msg.rpData)); + + //reference + dst->msg.rpData.ref = src[offset++]; + + //RP-Originator Address + dst->msg.rpData.moAddr.iei = AIFG_IE_ID_DT_RP_MO_ADDR; + dst->msg.rpData.moAddr.ptr = src + offset; + offset += src[offset] + 1; + + //RP-Destination Address + dst->msg.rpData.mtAddr.iei = AIFG_IE_ID_DT_RP_MT_ADDR; + dst->msg.rpData.mtAddr.ptr = src + offset; + offset += src[offset] + 1; + + //RP-User Data + dst->msg.rpData.data.iei = AIFG_IE_ID_DT_RP_UD; + dst->msg.rpData.data.ptr = src + offset; + + return AIFG_SUCCEED; +} + +////RP SMMA +int aifg_msg_rv_rp_smma(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + memset(&(dst->msg.rpSMMA), 0, sizeof(dst->msg.rpSMMA)); + + //reference + dst->msg.rpSMMA.ref = src[0]; + return AIFG_SUCCEED; +} + +//RP ACK +int aifg_msg_rv_rp_ack(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.rpAck), 0, sizeof(dst->msg.rpAck)); + + //reference + dst->msg.rpAck.ref = src[offset++]; + if(offset >= msg_len) + goto FINISH; + + //RP-User Data + if(src[offset] == AIFG_IEI_DT_RP_UD){ + dst->msg.rpAck.data.iei = AIFG_IE_ID_DT_RP_UD; + dst->msg.rpAck.data.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//RP ERROR +int aifg_msg_rv_rp_error(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len) +{ + int offset = 0; + memset(&(dst->msg.rpError), 0, sizeof(dst->msg.rpError)); + + //reference + dst->msg.rpError.ref = src[offset++]; + + //RP-Cause + dst->msg.rpError.cause.iei = AIFG_IE_ID_DT_RP_CAUSE; + dst->msg.rpError.cause.ptr = src + offset; + offset += src[offset] + 1; + if(offset >= msg_len) + goto FINISH; + + //RP-User Data + if(src[offset] == AIFG_IEI_DT_RP_UD){ + dst->msg.rpError.data.iei = AIFG_IE_ID_DT_RP_UD; + dst->msg.rpError.data.ptr = src + offset; + } + +FINISH: + return AIFG_SUCCEED; +} + +//End of message decode function definition----------------------------------------- + +//Message encode functions definition----------------------------------------------- +//For embedded DTAP messages in BSSMAP message +int aifg_msg_encode_embeded_l3msg(aifg_msg_bm_l3msg *l3msg, BYTE *dst) +{ + int offset = 0; + + assert(l3msg != NULL && dst != NULL); + + switch(l3msg->id){ + case AIFG_MSG_ID_CM_REQUEST: + dst[offset++] = 0x05; //PD + dst[offset++] = AIFG_MSG_T_CM_REQUEST; + + //CM serviece type + assert(l3msg->msg.cmRequest.cmType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CMTYPE, + (ie_u *)&( l3msg->msg.cmRequest.cmType), dst+offset, AIFG_LOW_BITS); + + //ciphering kye sequence number + assert(l3msg->msg.cmRequest.cipherKey.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CIPHERKEY, + (ie_u *)&( l3msg->msg.cmRequest.cipherKey), dst+offset, AIFG_HIGH_BITS); + + //mobile station classmark2 + assert(l3msg->msg.cmRequest.cmInfo2.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MSCM2, + (ie_u *)&( l3msg->msg.cmRequest.cmInfo2), dst+offset, 0); + + //mobile identity + assert(l3msg->msg.cmRequest.mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&( l3msg->msg.cmRequest.mobileId), dst+offset, 0); + + //priority level + if(l3msg->msg.cmRequest.priority.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PRIORITYLEVEL, + (ie_u *)&( l3msg->msg.cmRequest.priority), dst+offset, 2); + } + break; + + case AIFG_MSG_ID_LU_REQUEST: + dst[offset++] = 0x05; //PD + dst[offset++] = AIFG_MSG_T_LU_REQUEST; + + //location updating type + assert(l3msg->msg.luRequest.luType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LUTYPE, + (ie_u *)&(l3msg->msg.luRequest.luType), dst+offset, 0); + + //ciphering key sequence + assert(l3msg->msg.luRequest.cipherKey.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CIPHERKEY, + (ie_u *)&(l3msg->msg.luRequest.cipherKey), dst+offset, 1); + + //location area identification + assert(l3msg->msg.luRequest.lai.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LAI, + (ie_u *)&(l3msg->msg.luRequest.lai), dst+offset, 0); + + //mobile station classmark1 + assert(l3msg->msg.luRequest.cmInfo1.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MSCM1, + (ie_u *)&(l3msg->msg.luRequest.cmInfo1), dst+offset, 0); + + //mobile identity + assert(l3msg->msg.luRequest.mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&(l3msg->msg.luRequest.mobileId), dst+offset, 0); + break; + + case AIFG_MSG_ID_CM_REEST_REQUEST: + dst[offset++] = 0x05; //PD + dst[offset++] = AIFG_MSG_T_CM_REEST_REQUEST; + + //ciphering key sequence number + assert(l3msg->msg.cmReEstReq.cipherKey.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CIPHERKEY, + (ie_u *)&(l3msg->msg.cmReEstReq.cipherKey), dst+offset, 0); + offset++; + + //mobile station classmark2 + assert(l3msg->msg.cmReEstReq.cmInfo2.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MSCM2, + (ie_u *)&(l3msg->msg.cmReEstReq.cmInfo2), dst+offset, 0); + + //mobile identity + assert(l3msg->msg.cmReEstReq.mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&(l3msg->msg.cmReEstReq.mobileId), dst+offset, 0); + + //location area identification + if(l3msg->msg.cmReEstReq.lai.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LAI, + (ie_u *)&(l3msg->msg.cmReEstReq.lai), dst+offset, 2); + } + break; + + case AIFG_MSG_ID_PAGING_RESP: + dst[offset++] = 0x06; //PD + dst[offset++] = AIFG_MSG_T_PAGING_RESP; + + //ciphering key sequence number + assert(l3msg->msg.pagingResp.cipherKey.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CIPHERKEY, + (ie_u *)&(l3msg->msg.pagingResp.cipherKey), dst+offset, 0); + offset++; + + //mobile station classmark2 + assert(l3msg->msg.pagingResp.cmInfo2.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MSCM2, + (ie_u *)&(l3msg->msg.pagingResp.cmInfo2), dst+offset, 0); + + //mobile identity + assert(l3msg->msg.pagingResp.mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&(l3msg->msg.pagingResp.mobileId), dst+offset, 0); + break; + + case AIFG_MSG_ID_IMSI_DETACH_IND: + dst[offset++] = 0x05; //PD + dst[offset++] = AIFG_MSG_T_IMSI_DETACH_IND; + + //mobile station classmark1 + assert(l3msg->msg.imsiDetachInd.cmInfo1.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MSCM1, + (ie_u *)&(l3msg->msg.imsiDetachInd.cmInfo1), dst+offset, 0); + + //mobile identity + assert(l3msg->msg.imsiDetachInd.mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&(l3msg->msg.imsiDetachInd.mobileId), dst+offset, 0); + break; + + case AIFG_MSG_ID_RR_HO_CMD: + //TODO + dst[offset++] = 0x06; //PD + break; + + default: + assert(0); + goto ERR_PROC; + } + + return offset; + +ERR_PROC: + return offset; +} + +//Assign request +int aifg_msg_sd_assignReq(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_assignReq *assignReq = &(src->msg.assignReq); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ASSIGN_REQ; + + //Channel type - M + assert(assignReq->channelType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHANNELTYPE, (ie_u*)&(assignReq->channelType), dst+offset, 0); + + //Layer 3 Header Information + if(assignReq->l3HeaderInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_L3HEADERINFO, (ie_u*)&(assignReq->l3HeaderInfo), dst+offset, 0); + } + + //Priority + if(assignReq->priority.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_PRIORITY, (ie_u*)&(assignReq->priority), dst+offset, 0); + } + + //CIC + if(assignReq->cic.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(assignReq->cic), dst+offset, 0); + } + + //Downlink DTX Flag + if(assignReq->dtxFlag.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DTXFLAG, (ie_u*)&(assignReq->dtxFlag), dst+offset, 0); + } + + //Interference Band To Be Used + if(assignReq->bandUsed.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_BANDUSED, (ie_u*)&(assignReq->bandUsed), dst+offset, 0); + } + + //Classmark Information 2 + if(assignReq->cm2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CLASSMARKINFO2, (ie_u*)&(assignReq->cm2), dst+offset, 0); + } + + //Group Call Reference + if(assignReq->groupRef.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_GROUPCALLREF, (ie_u*)&(assignReq->groupRef), dst+offset, 0); + } + + //Talker Flag + if(assignReq->talkerFlag.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_GROUPCALLREF, (ie_u*)&(assignReq->talkerFlag), dst+offset, 0); + } + + //Configuration Evolution Indication + if(assignReq->cfgEvoInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CFGEVOIND, (ie_u*)&(assignReq->cfgEvoInd), dst+offset, 0); + } + + return offset; +} + +//ASSIGNMENT COMPLETE +int aifg_msg_sd_assignComplete(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_assignComplete *assignComp = &(src->msg.assignComplete); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ASSIGN_CMP; + + //RR Cause + if(assignComp->rrCause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RRCAUSE, (ie_u*)&(assignComp->rrCause),dst+offset, 0); + } + + //CIC + if(assignComp->cic.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(assignComp->cic), dst+offset, 0); + } + + //Cell Identifier + if(assignComp->cellId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, (ie_u*)&(assignComp->cellId), dst+offset, 0); + } + + //Chosen Channel + if(assignComp->chosenChannel.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENCHANNEL, (ie_u*)&(assignComp->chosenChannel), dst+offset, 0); + } + + //Chosen Encryption Algorithm + if(assignComp->chosenEncrypt.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENENCRYPT, (ie_u*)&(assignComp->chosenEncrypt), dst+offset, 0); + } + + //Circuit Pool + if(assignComp->circuitPool.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOL, (ie_u*)&(assignComp->circuitPool), dst+offset, 0); + } + + //Speech Version (Chosen) + if(assignComp->speechVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_SPEECHVER, (ie_u*)&(assignComp->speechVer), dst+offset, 0); + } + + //LSA Identifier + if(assignComp->lsaId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAID, (ie_u*)&(assignComp->lsaId), dst+offset, 0); + } + + return offset; +} + +//ASSIGNMENT FAILURE +int aifg_msg_sd_assignFailure(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_assignFailure *assignFail = &(src->msg.assignFailure); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ASSIGN_FAIL; + + //Cause + assert(assignFail->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(assignFail->cause), dst+offset, 0); + + //RR Cause + if(assignFail->rrCause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RRCAUSE, (ie_u*)&(assignFail->rrCause),dst+offset, 0); + } + + //Circuit Pool + if(assignFail->circuitPool.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOL, (ie_u*)&(assignFail->circuitPool), dst+offset, 0); + } + + //Circuit Pool List + if(assignFail->circuitPoolList.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOLLIST, (ie_u*)&(assignFail->circuitPoolList), dst+offset, 0); + } + + return offset; +} + +//BLOCK +int aifg_msg_sd_block(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_block *block = &(src->msg.block); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_BLOCK; + + //CIC + assert(block->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(block->cic),dst+offset, 0); + + //Cause + assert(block->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(block->cause), dst+offset, 0); + + //Connection Release Requested + if(block->connRelReq.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CONNRELREQ, (ie_u*)&(block->connRelReq), dst+offset, 0); + } + + return offset; +} + +//BLOCKING ACKNOWLEDGE +int aifg_msg_sd_blockAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_blockAck *blockAck = &(src->msg.blockAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_BLOCK_ACK; + + //CIC + assert(blockAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(blockAck->cic),dst+offset, 0); + + return offset; +} + +//UNBLOCK +int aifg_msg_sd_unblock(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_unblock *unblock = &(src->msg.unblock); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_UNBLOCK; + + //CIC + assert(unblock->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(unblock->cic),dst+offset, 0); + + return offset; +} + +//UNBLOCK ACKNOWLEDGE +int aifg_msg_sd_unblockAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_unblockAck *unblockAck = &(src->msg.unblockAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_UNBLOCK_ACK; + + //CIC + assert(unblockAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(unblockAck->cic),dst+offset, 0); + + return offset; +} + +//HANDOVER REQUEST +int aifg_msg_sd_HORequest(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HORequest *HOReq = &(src->msg.HORequest); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_REQUEST; + + //CHANNEL TYPE + assert(HOReq->channelType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHANNELTYPE, (ie_u*)&(HOReq->channelType),dst+offset, 0); + + //Encryption Information + assert(HOReq->encryptInfo.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_ENCRYPTINFO, (ie_u*)&(HOReq->encryptInfo),dst+offset, 0); + + //Classmark information + if(HOReq->cmInfo.cm2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CLASSMARKINFO2, (ie_u*)&(HOReq->cmInfo.cm2),dst+offset, 0); + }else if(HOReq->cmInfo.cm1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CLASSMARKINFO1, (ie_u*)&(HOReq->cmInfo.cm1),dst+offset, 0); + }else{ + //should never runs to here + assert(0); + } + + //Cell Identifier (Serving) + assert(HOReq->servingCellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, (ie_u*)&(HOReq->servingCellId),dst+offset, 0); + + //Priority + if(HOReq->priority.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_PRIORITY, (ie_u*)&(HOReq->priority),dst+offset, 0); + } + + //Circuit Identity Code + if(HOReq->cic.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(HOReq->cic),dst+offset, 0); + } + + //Downlink DTX Flag + if(HOReq->dtxFlag.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DTXFLAG, (ie_u*)&(HOReq->dtxFlag),dst+offset, 0); + } + + //Cell Identifier (Target) + assert(HOReq->targetCellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, (ie_u*)&(HOReq->targetCellId),dst+offset, 0); + + //Interference Band To Be Used + if(HOReq->bandUsed.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_BANDUSED, (ie_u*)&(HOReq->bandUsed),dst+offset, 0); + } + + //Cause + if(HOReq->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(HOReq->cause),dst+offset, 0); + } + + //Classmark Information 3 + // if(HOReq->c.flag == 1){ + // offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(HOReq->cause),dst+offset, 0); + // } + + //Current Channel type 1 + if(HOReq->curChannelType1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CURCHANNELTYPE1, (ie_u*)&(HOReq->curChannelType1),dst+offset, 0); + } + + //Speech Version (Used) + if(HOReq->speechVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_SPEECHVER, (ie_u*)&(HOReq->speechVer),dst+offset, 0); + } + + //Group Call Reference + if(HOReq->gourpRef.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_GROUPCALLREF, (ie_u*)&(HOReq->gourpRef),dst+offset, 0); + } + + //Talker Flag + if(HOReq->talkerFlag.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TALKERFLAG, (ie_u*)&(HOReq->talkerFlag),dst+offset, 0); + } + + //Configuration Evolution Indication + if(HOReq->cfgEvoInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CFGEVOIND, (ie_u*)&(HOReq->cfgEvoInd),dst+offset, 0); + } + + //Chosen Encryption Algorithm (Serving) + if(HOReq->chosenEncrypt.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENENCRYPT, (ie_u*)&(HOReq->chosenEncrypt),dst+offset, 0); + } + + //Old BSS to New BSS Information + if(HOReq->bssOldtoNew.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_BSSOLDTONEW, (ie_u*)&(HOReq->bssOldtoNew),dst+offset, 0); + } + + //LSA Information + if(HOReq->lsaInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAINFO, (ie_u*)&(HOReq->lsaInfo),dst+offset, 0); + } + + return offset; +} + +//HANDOVER REQUIRED +int aifg_msg_sd_HORequired(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HORequired *HORequired = &(src->msg.HORequired); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_REQUIRED; + + //Cause + assert(HORequired->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(HORequired->cause),dst+offset, 0); + + //Response Request + if(HORequired->respReq.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RESPREQ, (ie_u*)&(HORequired->respReq),dst+offset, 0); + } + + //Cell Identifier List (Preferred) + assert(HORequired->prefer_cidList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLIDLIST, + (ie_u*)&(HORequired->prefer_cidList),dst+offset, 0); + + //Circuit Pool List + if(HORequired->circuitPoolList.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOLLIST, + (ie_u*)&(HORequired->circuitPoolList),dst+offset, 0); + } + + //Current Channel type 1 + if(HORequired->curChannelType1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CURCHANNELTYPE1, + (ie_u*)&(HORequired->curChannelType1),dst+offset, 0); + } + + //Speech Version (Used) + if(HORequired->speechVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_SPEECHVER, + (ie_u*)&(HORequired->speechVer),dst+offset, 0); + } + + //Queueing Indicator + if(HORequired->queuingInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_QUEUEIND, + (ie_u*)&(HORequired->queuingInd),dst+offset, 0); + } + + //Old BSS to New BSS Information + if(HORequired->bssOldtoNew.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_BSSOLDTONEW, + (ie_u*)&(HORequired->bssOldtoNew),dst+offset, 0); + } + + return offset; +} + +//HANDOVER REQUEST ACKNOWLEDGE +int aifg_msg_sd_HORequestAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HORequestAck *HOReqAck = &(src->msg.HORequestAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_REQ_ACK; + + //Layer 3 Information + dst[offset++] = AIFG_IEI_BM_L3INFO; + dst[offset++] = HOReqAck->l3Info.len; + memcpy(dst+offset, HOReqAck->l3Info.ptr, HOReqAck->l3Info.len); + offset += HOReqAck->l3Info.len; + + //Chosen Channel + if(HOReqAck->chosenChannel.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENCHANNEL, (ie_u*)&(HOReqAck->chosenChannel),dst+offset, 0); + } + + //Chosen Encryption Algorithm + if(HOReqAck->chosenEncrypt.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENENCRYPT, (ie_u*)&(HOReqAck->chosenEncrypt),dst+offset, 0); + } + + //Circuit Pool + if(HOReqAck->circuitPool.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOL, (ie_u*)&(HOReqAck->circuitPool),dst+offset, 0); + } + + //Speech Version (Chosen) + if(HOReqAck->speechVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_SPEECHVER, (ie_u*)&(HOReqAck->speechVer),dst+offset, 0); + } + + //Circuit Identity Code + if(HOReqAck->cic.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(HOReqAck->cic),dst+offset, 0); + } + + //LSA Identifier + if(HOReqAck->lsaId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAID, (ie_u*)&(HOReqAck->lsaId),dst+offset, 0); + } + + return offset; +} + +//HANDOVER COMMAND +int aifg_msg_sd_HOCmd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOCmd *HOCmd = &(src->msg.HOCmd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_CMD; + //Layer 3 Information + dst[offset++] = AIFG_IEI_BM_L3INFO; + dst[offset++] = HOCmd->l3Info.len; + memcpy(dst+offset, HOCmd->l3Info.ptr, HOCmd->l3Info.len); + offset += HOCmd->l3Info.len; + + //Cell Identifier + if(HOCmd->cellId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, (ie_u*)&(HOCmd->cellId),dst+offset, 0); + } + + return offset; +} + +//HANDOVER COMPLETE +int aifg_msg_sd_HOComplete(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOComplete *HOcomplete = &(src->msg.HOComplete); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_CMP; + + //RR Cause + if(HOcomplete->rrCause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RRCAUSE, (ie_u*)&(HOcomplete->rrCause),dst+offset, 0); + } + + return offset; +} + +//HANDOVER SUCCEEDED +int aifg_msg_sd_HOSucceed(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_HO_SUC; + + return offset; +} + +//HANDOVER CANDIDATE ENQUIRE +int aifg_msg_sd_HOCandEnq(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOCandidateEnq *HOCandEnq = &(src->msg.HOCandidateEnq); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_CAN_ENQ; + + //Number Of Mss + assert(HOCandEnq->msNum.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_MSNUM, + (ie_u*)&(HOCandEnq->msNum),dst+offset, 0); + + //Cell Identifier List + assert(HOCandEnq->cidList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLIDLIST, + (ie_u*)&(HOCandEnq->cidList),dst+offset, 0); + + //Cell Identifier + assert(HOCandEnq->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(HOCandEnq->cellId),dst+offset, 0); + + return offset; +} + +//HANDOVER CANDIDATE RESPONSE +int aifg_msg_sd_HOCandResp(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOCandidateResp *HOCandResp = &(src->msg.HOCandidateResp); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_CAN_RESP; + + //Number Of Mss + assert(HOCandResp->msNum.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_MSNUM, + (ie_u*)&(HOCandResp->msNum),dst+offset, 0); + + //Cell Identifier + assert(HOCandResp->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(HOCandResp->cellId),dst+offset, 0); + + return offset; +} + +//HANDOVER FAILURE +int aifg_msg_sd_HOFailure(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOFailure *HOFailure = &(src->msg.HOFailure); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_FAIL; + + //Cause + assert(HOFailure->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(HOFailure->cause), dst+offset, 0); + + //RR Cause + if(HOFailure->rrCause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RRCAUSE, + (ie_u*)&(HOFailure->rrCause),dst+offset, 0); + } + + //Circuit Pool + if(HOFailure->circuitPool.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOL, + (ie_u*)&(HOFailure->circuitPool), dst+offset, 0); + } + + //Circuit Pool List + if(HOFailure->circuitPoolList.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIRCUITPOOLLIST, + (ie_u*)&(HOFailure->circuitPoolList), dst+offset, 0); + } + + return offset; +} + +//RESOURCE REQUEST +int aifg_msg_sd_resrcReq(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_resrcReq *resrcReq = &(src->msg.resourceReq); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESRC_REQ; + + //Periodicity + assert(resrcReq->periodicity.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_PERIODICITY, + (ie_u*)&(resrcReq->periodicity), dst+offset, 0); + + //Resource Indication Method + assert(resrcReq->resrcIndMethod.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RESOURCEINDMEHTOD, + (ie_u*)&(resrcReq->resrcIndMethod),dst+offset, 0); + + //Cell Identifier + assert(resrcReq->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(resrcReq->cellId), dst+offset, 0); + + //Extended Resource Indicator + if(resrcReq->extResrcInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_EXTRESOURCEIND, + (ie_u*)&(resrcReq->extResrcInd), dst+offset, 0); + } + + return offset; +} + +//RESOURCE INDICATION +int aifg_msg_sd_resrcInd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_resrcInd *resrcInd = &(src->msg.resourceInd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESRC_IND; + + //Resource Indication Method + assert(resrcInd->resrcIndMethod.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RESOURCEINDMEHTOD, + (ie_u*)&(resrcInd->resrcIndMethod),dst+offset, 0); + + //Resource Available + if(resrcInd->resrcAvail.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RESOURCEAVAIL, + (ie_u*)&(resrcInd->resrcAvail), dst+offset, 0); + } + + //Cell Identifier + assert(resrcInd->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(resrcInd->cellId), dst+offset, 0); + + //Total Resource Accessible + if(resrcInd->totalResrc.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TOTALRESOURCE, + (ie_u*)&(resrcInd->totalResrc), dst+offset, 0); + } + + return offset; +} + +//PAGING +int aifg_msg_sd_paging(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_paging *paging = &(src->msg.paging); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_PAGING; + + //IMSI + assert(paging->imsi.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_IMSI, (ie_u*)&(paging->imsi),dst+offset, 0); + + //TMSI + if(paging->tmsi.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TMSI, + (ie_u*)&(paging->tmsi), dst+offset, 0); + } + + //Cell Identifier List + assert(paging->cidList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLIDLIST, + (ie_u*)&(paging->cidList), dst+offset, 0); + + //Channel Needed + if(paging->channelNeeded.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHANNELNEEDED, + (ie_u*)&(paging->channelNeeded), dst+offset, 0); + } + + //eMLPP Priority + if(paging->eMLPP.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_EMLPP, + (ie_u*)&(paging->eMLPP), dst+offset, 0); + } + + return offset; +} + +//CLEAR REQUEST +int aifg_msg_sd_clearReq(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_clearReq *clearReq = &(src->msg.clearReq); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CLR_REQ; + + //Cause + assert(clearReq->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(clearReq->cause),dst+offset, 0); + + return offset; +} + +//CLEAR COMMAND +int aifg_msg_sd_clearCmd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_clearCmd *clearCmd = &(src->msg.clearCmd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CLR_CMD; + + //Layer 3 Header Information + if(clearCmd->l3HeaderInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_L3HEADERINFO, + (ie_u*)&(clearCmd->l3HeaderInfo), dst+offset, 0); + } + + //Cause + assert(clearCmd->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(clearCmd->cause),dst+offset, 0); + + return offset; +} + +//CLEAR COMPLETE +int aifg_msg_sd_clearComplete(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_CLR_CMP; + + return offset; +} + +//RESET +int aifg_msg_sd_reset(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_reset *reset = &(src->msg.reset); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESET; + + //Cause + assert(reset->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(reset->cause),dst+offset, 0); + + return offset; +} + +//RESET ACKNOWLEDGE +int aifg_msg_sd_resetAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_RESET_ACK; + + return offset; +} + + +//HANDOVER PERFORMED +int aifg_msg_sd_HOPerformed(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOPerformed *HOPerformed = &(src->msg.HOPerformed); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_PERFORMED; + + //Cause + assert(HOPerformed->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(HOPerformed->cause),dst+offset, 0); + + //Cell Identifier + assert(HOPerformed->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(HOPerformed->cellId),dst+offset, 0); + + //Chosen Channel + if(HOPerformed->chosenChannel.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENCHANNEL, + (ie_u*)&(HOPerformed->chosenChannel), dst+offset, 0); + } + + //Chosen Encryption Algorithm + assert(HOPerformed->chosenEncrypt.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENENCRYPT, + (ie_u*)&(HOPerformed->chosenEncrypt), dst+offset, 0); + + //Speech Version (Chosen) + if(HOPerformed->speechVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_SPEECHVER, + (ie_u*)&(HOPerformed->speechVer), dst+offset, 0); + } + + //LSA Identifier + if(HOPerformed->lsaId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAID, + (ie_u*)&(HOPerformed->lsaId), dst+offset, 0); + } + + return offset; +} + +//OVERLOAD +int aifg_msg_sd_overload(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_overload *overload = &(src->msg.overload); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_OVERLOAD; + + //Cause + assert(overload->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(overload->cause),dst+offset, 0); + + //Cell Identifier + if(overload->cellId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(overload->cellId),dst+offset, 0); + } + + return offset; +} + +//MSC INVOKE TRACE +int aifg_msg_sd_mscTrace(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_mscInvokeTrace *mscTrace = &(src->msg.mscInvokeTrace); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MSC_INVK_TRACE; + + //Trace Type + assert(mscTrace->traceType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRACETYPE, + (ie_u*)&(mscTrace->traceType),dst+offset, 0); + + //Triggerid + if(mscTrace->tiggerId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRIGGERID, + (ie_u*)&(mscTrace->tiggerId),dst+offset, 0); + } + + //Trace Reference + assert(mscTrace->traceRef.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRACEREF, + (ie_u*)&(mscTrace->traceRef),dst+offset, 0); + + //Transactionid + if(mscTrace->transId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRANSACTIONID, + (ie_u*)&(mscTrace->transId),dst+offset, 0); + } + + //Mobile Identity + if(mscTrace->mobileId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_MOBILEID, + (ie_u*)&(mscTrace->mobileId),dst+offset, 0); + } + + //OMCId + if(mscTrace->omcId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_OMCID, + (ie_u*)&(mscTrace->omcId),dst+offset, 0); + } + + return offset; +} + +//BSS INVOKE TRACE +int aifg_msg_sd_bscTrace(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_bscInvokeTrace *bscTrace = &(src->msg.bscInvokeTrace); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_BSC_INVK_TRACE; + + //Trace Type + assert(bscTrace->traceType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRACETYPE, + (ie_u*)&(bscTrace->traceType),dst+offset, 0); + + //Forward Indicator + if(bscTrace->forwardInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_FORWARDIND, + (ie_u*)&(bscTrace->forwardInd),dst+offset, 0); + } + + //Triggerid + if(bscTrace->tiggerId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRIGGERID, + (ie_u*)&(bscTrace->tiggerId),dst+offset, 0); + } + + //Trace Reference + assert(bscTrace->traceRef.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRACEREF, + (ie_u*)&(bscTrace->traceRef),dst+offset, 0); + + //Transactionid + if(bscTrace->transId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TRANSACTIONID, + (ie_u*)&(bscTrace->transId),dst+offset, 0); + } + + //OMCId + if(bscTrace->omcId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_OMCID, + (ie_u*)&(bscTrace->omcId),dst+offset, 0); + } + + return offset; +} + +//CLASSMARK UPDATE +int aifg_msg_sd_cmUpdate(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_cmUpdate *cmUpdate = &(src->msg.cmUpdate); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CM_UPDATE; + + //Classmark Information Type 2 + assert(cmUpdate->cm2.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CLASSMARKINFO2, + (ie_u*)&(cmUpdate->cm2),dst+offset, 0); + + //Classmark Information Type 3 + // if(cmUpdate->forwardInd.flag == 1){ + // offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_FORWARDIND, + // (ie_u*)&(cmUpdate->forwardInd),dst+offset, 0); + // } + + return offset; +} + +//CIPHER MODE COMMAND +int aifg_msg_sd_cipherModeCmd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_cipherModeCmd *cipherModeCmd = &(src->msg.cipherModeCmd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CIPHER_MODE_CMD; + + //Layer 3 Header Information + if(cipherModeCmd->l3HeaderInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_L3HEADERINFO, + (ie_u*)&(cipherModeCmd->l3HeaderInfo),dst+offset, 0); + } + + //Encryption Information + assert(cipherModeCmd->encryptInfo.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_ENCRYPTINFO, + (ie_u*)&(cipherModeCmd->encryptInfo),dst+offset, 0); + + //Cipher Response Mode + if(cipherModeCmd->cipherRespMode.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIPHERRESPMODE, + (ie_u*)&(cipherModeCmd->cipherRespMode),dst+offset, 0); + } + + return offset; +} + +//CIPHER MODE COMPLETE +int aifg_msg_sd_cipherModeComplete(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_cipherModeComplete *cipherModeComplete = &(src->msg.cipherModeComplete); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CIPHER_MODE_CMP; + + //Layer 3 Message Contents + if(cipherModeComplete->l3Info.flag == 1){ + strncpy((char*)dst+offset, (const char*)cipherModeComplete->l3Info.ptr, cipherModeComplete->l3Info.len); + offset += cipherModeComplete->l3Info.len; + } + + //Chosen Encryption Algorithm + if(cipherModeComplete->chosenEncrypt.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENENCRYPT, + (ie_u*)&(cipherModeComplete->chosenEncrypt),dst+offset, 0); + } + + return offset; +} + +//COMPLETE LAYER 3 INFORMATION +int aifg_msg_sd_completeL3Info(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_completeL3Info *completeL3Info = &(src->msg.completeL3Info); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_L3_INFO; + + //Cell Identifier + assert(completeL3Info->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(completeL3Info->cellId),dst+offset, 0); + + //Layer 3 Information, transparent transfer + dst[offset++] = AIFG_IEI_BM_L3INFO; + dst[offset++] = completeL3Info->l3Info.len; + memcpy(dst+offset, completeL3Info->l3Info.ptr, completeL3Info->l3Info.len); + offset += completeL3Info->l3Info.len; + + /* + dst[offset++] = AIFG_IEI_BM_L3INFO; + offset++; //skip length + l3msg_len += aifg_msg_encode_embeded_l3msg(&completeL3Info->l3Info, dst+offset); + dst[offset-1] = l3msg_len; + offset += l3msg_len; + */ + + //Chosen Channel + if(completeL3Info->chosenChannel.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CHOSENCHANNEL, + (ie_u*)&(completeL3Info->chosenChannel), dst+offset, 0); + } + + //LSA Identifier List + if(completeL3Info->lsaIdList.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAIDLIST, + (ie_u*)&(completeL3Info->lsaIdList), dst+offset, 0); + } + + //Location Information + if(completeL3Info->locInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LOCATIONINFO, + (ie_u*)&(completeL3Info->locInfo), dst+offset, 0); + } + + return offset; +} + +//QUEUEING INDICATION +int aifg_msg_sd_queueInd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_QUEUE_IND; + + return offset; +} + +//SAPI "n" REJECT + +int aifg_msg_sd_sapi_n_rej(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_SAPI_n_Reject *SAPI_n_Reject = &(src->msg.SAPI_n_Reject); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_SAPI_REJ; + + //DLCI + assert(SAPI_n_Reject->dlci.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DLCI, + (ie_u*)&(SAPI_n_Reject->dlci),dst+offset, 0); + + //Cause + assert(SAPI_n_Reject->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(SAPI_n_Reject->cause),dst+offset, 0); + + return offset; +} + +//HANDOVER REQUIRED REJECT +int aifg_msg_sd_HORequiredRej(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_HOReject *HOReject = &(src->msg.HOReject); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HO_REQ_REJ; + + //Cause + assert(HOReject->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(HOReject->cause),dst+offset, 0); + + return offset; +} + +//RESET CIRCUIT +int aifg_msg_sd_resetCircuit(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_resetCircuit *resetCircuit = &(src->msg.resetCircuit); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESET_CC; + + //CIC + assert(resetCircuit->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(resetCircuit->cic),dst+offset, 0); + + //Cause + assert(resetCircuit->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(resetCircuit->cause),dst+offset, 0); + + return offset; +} + +//RESET CIRCUIT ACKNOWLEDGE +int aifg_msg_sd_resetCircuitAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_resetCircuitAck *resetCircuitAck = &(src->msg.resetCircuitAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESET_CC_ACK; + + //CIC + assert(resetCircuitAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(resetCircuitAck->cic),dst+offset, 0); + + return offset; +} + +//HANDOVER DETECT +int aifg_msg_sd_HODetect(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_HO_DETECT; + + return offset; +} + +//CIRCUIT GROUP BLOCK +int aifg_msg_sd_ccGrpBlk(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_circuitGrpBlk *circuitGrpBlk = &(src->msg.ccGroupBlock); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CC_GROUP_BLK; + + //Cause + assert(circuitGrpBlk->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(circuitGrpBlk->cause),dst+offset, 0); + + //CIC + assert(circuitGrpBlk->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(circuitGrpBlk->cic),dst+offset, 0); + + //Circuit Identity Code List + assert(circuitGrpBlk->cicList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CICLIST, + (ie_u*)&(circuitGrpBlk->cicList),dst+offset, 0); + + return offset; +} + +//CIRCUIT GROUP BLOCKING ACKNOWLEDGE +int aifg_msg_sd_ccGroupBlockAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_circuitGrpBlkAck *circuitGrpBlkAck = &(src->msg.ccGroupBlockAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CC_GROUP_BLK_ACK; + + //CIC + assert(circuitGrpBlkAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(circuitGrpBlkAck->cic),dst+offset, 0); + + //Circuit Identity Code List + assert(circuitGrpBlkAck->cicList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CICLIST, + (ie_u*)&(circuitGrpBlkAck->cicList),dst+offset, 0); + + return offset; +} + +//CIRCUIT GROUP UNBLOCK +int aifg_msg_sd_ccGroupUnblock(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_circuitGrpUnblk *circuitGrpUnblk = &(src->msg.ccGroupUnblock); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CC_GROUP_UNBLK; + + //CIC + assert(circuitGrpUnblk->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(circuitGrpUnblk->cic),dst+offset, 0); + + //Circuit Identity Code List + assert(circuitGrpUnblk->cicList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CICLIST, + (ie_u*)&(circuitGrpUnblk->cicList),dst+offset, 0); + + return offset; +} + +//CIRCUIT GROUP UNBLOCKING ACKNOWLEDGE +int aifg_msg_sd_ccGroupUnblockAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_circuitGrpUnblkAck *circuitGrpUnblkAck = &(src->msg.ccGroupUnblockAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CC_GROUP_UNBLK_ACK; + + //CIC + assert(circuitGrpUnblkAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(circuitGrpUnblkAck->cic),dst+offset, 0); + + //Circuit Identity Code List + assert(circuitGrpUnblkAck->cicList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CICLIST, + (ie_u*)&(circuitGrpUnblkAck->cicList),dst+offset, 0); + + return offset; +} + +//CONFUSION +int aifg_msg_sd_confusion(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_confusion *confusion = &(src->msg.confusion); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CONFUSION; + + //Cause + assert(confusion->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(confusion->cause),dst+offset, 0); + + //Diagnostics + assert(confusion->diagnostics.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DIGNOSTIC, + (ie_u*)&(confusion->diagnostics),dst+offset, 0); + + return offset; +} + +//CLASSMARK REQUEST +int aifg_msg_sd_classmarkReq(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + + dst[offset++] = AIFG_MSG_T_CLASSMARK_REQ; + + return offset; +} + +//UNEQUIPPED CIRCUIT +int aifg_msg_sd_unequippedCircuit(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_unequippedCircuit *unequippedCircuit = &(src->msg.unequippedCircuit); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_UNEQUIP_CC; + + //CIC + assert(unequippedCircuit->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, + (ie_u*)&(unequippedCircuit->cic),dst+offset, 0); + + //Circuit Identity Code List + if(unequippedCircuit->cicList.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CICLIST, + (ie_u*)&(unequippedCircuit->cicList),dst+offset, 0); + } + + return offset; +} + +//CIPHER MODE REJECT +int aifg_msg_sd_cipherModeRej(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_cipherModeReject *cipherModeReject = &(src->msg.cipherModeReject); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CIPHER_MODE_REJ; + + //Cause + assert(cipherModeReject->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(cipherModeReject->cause),dst+offset, 0); + + return offset; +} + +//LOAD INDICATION +int aifg_msg_sd_loadInd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_loadIndication *loadInd = &(src->msg.loadInd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_LOAD_IND; + + //Time Indication + assert(loadInd->timeInd.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_TIMEIND, + (ie_u*)&(loadInd->timeInd),dst+offset, 0); + + //Cell Identifier + assert(loadInd->cellId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLID, + (ie_u*)&(loadInd->cellId),dst+offset, 0); + + //Cell Identifier List(Target) + assert(loadInd->cidList.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CELLIDLIST, + (ie_u*)&(loadInd->cidList), dst+offset, 0); + + //Resource Situation + if(loadInd->resrcSit.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_RESOURCESITUATION, + (ie_u*)&(loadInd->resrcSit), dst+offset, 0); + } + + //Cause + if(loadInd->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(loadInd->cause),dst+offset, 0); + } + + return offset; +} + +//SUSPEND +int aifg_msg_sd_suspend(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_suspend *suspend = &(src->msg.suspend); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_SUSPEND; + + //DLCI + assert(suspend->dlci.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DLCI, (ie_u*)&(suspend->dlci),dst+offset, 0); + + return offset; +} + +//RESUME +int aifg_msg_sd_resume(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_resume *resume = &(src->msg.resume); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RESUME; + + //DLCI + assert(resume->dlci.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_DLCI, (ie_u*)&(resume->dlci),dst+offset, 0); + + return offset; +} + +//CHANGE CIRCUIT +int aifg_msg_sd_changeCircuit(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_changeCircuit *changeCircuit = &(src->msg.changeCircuit); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CHANGE_CC; + + //Cause + assert(changeCircuit->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, (ie_u*)&(changeCircuit->cause),dst+offset, 0); + + return offset; +} + +//CHANGE CIRCUIT ACKNOWLEDGE +int aifg_msg_sd_changeCircuitAck(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_changeCircuitAck *changeCircuitAck = &(src->msg.changeCircuitAck); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CHANGE_CC_ACK; + + //CIC + assert(changeCircuitAck->cic.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CIC, (ie_u*)&(changeCircuitAck->cic),dst+offset, 0); + + return offset; +} + +/* +//LSA INFORMATION +int aifg_msg_sd_lsaInfo(aifg_msg_t *src, BYTE *dst) +{ +int offset = 0; +aifg_msg_bm_lsaInfo *lsaInfo = &(src->msg.lsaInfo); + +assert(src != NULL && dst != NULL); + +dst[offset++] = AIFG_MSG_T_LSA_INFO; + +//LSA Information +assert(lsaInfo->lsaInfo.flag == 1); +offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LSAINFO, (ie_u*)&(lsaInfo->lsaInfo),dst+offset, 0); + +return offset; +} +*/ + +//Location Information Command +int aifg_msg_sd_locCmd(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_locCmd *locCmd = &(src->msg.locCmd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_LOC_INFO_CMD; + + //Location Information + assert(locCmd->locInfo.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LOCATIONINFO, + (ie_u*)&(locCmd->locInfo), dst+offset, 0); + + return offset; +} + +//Location Information Report +int aifg_msg_sd_locReport(aifg_msg_t *src, BYTE *dst) +{ + int offset = 0; + aifg_msg_bm_locReport *locReport = &(src->msg.locReport); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_LOC_INFO_RPT; + + //Location Information + if(locReport->locInfo.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_LOCATIONINFO, + (ie_u*)&(locReport->locInfo), dst+offset, 0); + } + else if(locReport->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_BSSMAP, AIFG_IE_ID_BM_CAUSE, + (ie_u*)&(locReport->cause), dst+offset, 0); + } + + else + assert(0); //should never runs to here + + return offset; +} + +//DTAP--------------------------------------------------------------------------------- +int aifg_msg_sd_luAccept(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_luAccept *luAccept = &(src->msg.luAccept); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_LU_ACCEPT; + + + //location area identification + assert(luAccept->lai.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LAI, + (ie_u *)&( luAccept->lai), dst+offset, 0); + + + //mobile identity + if(luAccept->mobileId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, + (ie_u *)&( luAccept->mobileId), dst+offset, 2); + } + + //follow on proceed + if(luAccept->followOnProceed.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FLONPROCEED, + (ie_u *)&( luAccept->followOnProceed), dst+offset, 2); + } + + //CTS permission + if(luAccept->CTSPermission.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CTS, + (ie_u *)&( luAccept->CTSPermission), dst+offset, 2); + } + + return offset; +} + +//CM service reject +int aifg_msg_sd_cmRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_cmReject *cmRej = &(src->msg.cmReject); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CM_REJECT; + + //reject cause + assert(cmRej->rejectCause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REJCAUSE, (ie_u *)&( cmRej->rejectCause), dst+offset, 0); + + return offset; +} + +//location updating reject +int aifg_msg_sd_luReject(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_luReject *luReject = &(src->msg.luReject); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_LU_REJECT; + + //reject cause + assert(luReject->rejectCause.flag== 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REJCAUSE, (ie_u *)&( luReject->rejectCause), dst+offset, 0); + + return offset; +} + +//abort +int aifg_msg_sd_abort(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_abort *abort = &(src->msg.abort); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ABORT; + + //reject cause + assert(abort->rejectCause.flag== 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REJCAUSE, (ie_u *)&( abort->rejectCause), dst+offset, 0); + + return offset; +} + +//MM status +int aifg_msg_sd_mmStatus(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_mmStatus *mmStatus = &(src->msg.mmStatus); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MM_STATUS; + + //reject cause + assert(mmStatus->rejectCause.flag== 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REJCAUSE, (ie_u *)&( mmStatus->rejectCause), dst+offset, 0); + + return offset; +} + +//authentication request +int aifg_msg_sd_authReq(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_authRequest *authRequest = &(src->msg.authRequest); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_AUTH_REQUEST; + + //ciphering key sequence number + assert(authRequest->cipherKey.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CIPHERKEY, (ie_u *)&( authRequest->cipherKey), dst+offset, 0); + offset++; + + //authentication parameter RAND + assert(authRequest->authRAND.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_AUTHRAND, (ie_u *)&( authRequest->authRAND), dst+offset, 0); + + return offset; +} + +//authentication response +int aifg_msg_sd_authResp(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_authResp *authResp = &(src->msg.authResp); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_AUTH_RESPONSE; + + //authentication parameter SRES + assert(authResp->authSRES.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_AUTHSRES, (ie_u *)&( authResp->authSRES), dst+offset, 0); + + return offset; +} + +//identity request +int aifg_msg_sd_idReq(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_idRequest *idRequest = &(src->msg.idRequest); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ID_REQUEST; + + //identity type + assert(idRequest->idType.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_IDTYPE, (ie_u *)&( idRequest->idType), dst+offset, 0); + offset++; + + return offset; +} + +//identity response +int aifg_msg_sd_idResp(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_idResp *idResp = &(src->msg.idResp); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ID_RESPONSE; + + //mobile identity + assert(idResp->mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, (ie_u *)&( idResp->mobileId), dst+offset, 0); + + return offset; +} + +//TMSI reallocation command +int aifg_msg_sd_tmsiReallocCmd(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_tmsiCmd *tmsiCmd = &(src->msg.tmsiCmd); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_TMSI_REALLOC_CMD; + + //location area identification + assert(tmsiCmd->lai.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LAI, (ie_u *)&(tmsiCmd->lai), dst+offset, 0); + + //mobile identity + assert(tmsiCmd->mobileId.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOBILEID, (ie_u *)&(tmsiCmd->mobileId), dst+offset, 0); + + return offset; +} + +//MM infomation +int aifg_msg_sd_mmInfo(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_mmInfo *mmInfo = &(src->msg.mmInfo); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MM_INFO; + + //full name of network + if(mmInfo->fullName.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FULL_NWNAME, + (ie_u *)&( mmInfo->fullName), dst+offset, 2); + } + + //short name of network + if(mmInfo->shortName.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_SHORT_NWNAME, + (ie_u *)&( mmInfo->shortName), dst+offset, 2); + } + + //time zone + if(mmInfo->timeZone.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_TIMEZONE, + (ie_u *)&( mmInfo->timeZone), dst+offset, 2); + } + + //timezone and time + if(mmInfo->tzTime.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_TZTIME, + (ie_u *)&( mmInfo->tzTime), dst+offset, 2); + } + + //LSA identifier + if(mmInfo->lsaId.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LSAID, + (ie_u *)&( mmInfo->lsaId), dst+offset, 2); + } + + return offset; +} + +//alerting +int aifg_msg_sd_alert(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_alert *alert = &(src->msg.alert); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_ALERTING; + + //facility + if(alert->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, (ie_u *)&( alert->facility), dst+offset, 2); + } + + //progress indicator + if(alert->progInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, (ie_u *)&( alert->progInd), dst+offset, 2); + } + + //user-user + if(alert->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, (ie_u *)&( alert->uu), dst+offset, 2); + } + + return offset; +} + +//call confirmed +int aifg_msg_sd_callConfirm(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_callConfirm *callConfirm = &(src->msg.callConfirm); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CALL_CONFIRMED; + + //repeat indicator + if(callConfirm->rpInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REPEATIND, (ie_u *)&( callConfirm->rpInd), dst+offset, 2); + } + + //bearer capability 1 + if(callConfirm->bc1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, (ie_u *)&( callConfirm->bc1), dst+offset, 2); + } + + //bearer capability 2 + if(callConfirm->bc2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, (ie_u *)&( callConfirm->bc2), dst+offset, 2); + } + + //cause + if(callConfirm->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, (ie_u *)&( callConfirm->cause), dst+offset, 2); + } + + //call control capability + if(callConfirm->ccCap.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CCCAP, (ie_u *)&( callConfirm->ccCap), dst+offset, 2); + } + + return offset; +} + +//call proceeding +int aifg_msg_sd_callProceed(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_callProceed *callProceed = &(src->msg.callProceed); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CALL_PROCEEDING; + + //repeat indicator + if(callProceed->rpInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REPEATIND, + (ie_u *)&( callProceed->rpInd), dst+offset, 2); + } + + //bearer capability 1 + if(callProceed->bc1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( callProceed->bc1), dst+offset, 2); + } + + //bearer capability 2 + if(callProceed->bc2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( callProceed->bc2), dst+offset, 2); + } + + //facility + if(callProceed->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( callProceed->facility), dst+offset, 2); + } + + //progress indicator + if(callProceed->progInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, + (ie_u *)&( callProceed->progInd), dst+offset, 2); + } + + //priority level + if(callProceed->priority.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PRIORITYLEVEL, + (ie_u *)&( callProceed->priority), dst+offset, 2); + } + + return offset; +} + +//connect +int aifg_msg_sd_connect(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_connect *connect = &(src->msg.connect); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CONNECT; + + //facility + if(connect->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( connect->facility), dst+offset, 2); + } + + //progress indicator + if(connect->progInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, + (ie_u *)&( connect->progInd), dst+offset, 2); + } + + //connected number + if(connect->connNum.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CONNNUM, + (ie_u *)&( connect->connNum), dst+offset, 2); + } + + //connected subaddress + if(connect->connSubAddr.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CONNSUBADDR, + (ie_u *)&( connect->connSubAddr), dst+offset, 2); + } + + //user-user + if(connect->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( connect->uu), dst+offset, 2); + } + + return offset; +} + +//emergency setup +int aifg_msg_sd_eSetup(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_eSetup *eSetup = &(src->msg.eSetup); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_EMERGENCY_SETUP; + + //bearer capability + if(eSetup->bc.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( eSetup->bc), dst+offset, 2); + } + + return offset; +} + +//progress +int aifg_msg_sd_progress(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_progress *progress = &(src->msg.progress); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_PROGRESS; + + //progress indicator + assert(progress->progInd.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, + (ie_u *)&( progress->progInd), dst+offset, 0); + + //user-user + if(progress->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( progress->uu), dst+offset, 2); + } + + return offset; +} + +//setup +int aifg_msg_sd_setup(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_setup *setup = &(src->msg.setup); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_SETUP; + + //BC repeat indicator + if(setup->bc_rpInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REPEATIND, + (ie_u *)&( setup->bc_rpInd), dst+offset, 2); + } + + //bearer capability 1 + if(setup->bc1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( setup->bc1), dst+offset, 2); + } + + //bearer capability 2 + if(setup->bc2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( setup->bc2), dst+offset, 2); + } + + //facility + if(setup->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( setup->facility), dst+offset, 2); + } + + //progress indicator + if(setup->progInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, + (ie_u *)&( setup->progInd), dst+offset, 2); + } + + //signal + if(setup->signal.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_SIGNAL, + (ie_u *)&( setup->signal), dst+offset, 2); + } + + //calling party BCD number + if(setup->callingNum.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CALLERBCD, + (ie_u *)&( setup->callingNum), dst+offset, 2); + } + + //calling party subaddr + if(setup->callingSubAddr.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CALLERSUBADDR, + (ie_u *)&( setup->callingSubAddr), dst+offset, 2); + } + + //called party BCD num + if(setup->calledNum.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CALLEDBCD, + (ie_u *)&( setup->calledNum), dst+offset, 2); + } + + //called party subaddr + if(setup->calledSubAddr.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CALLEDSUBADDR, + (ie_u *)&( setup->calledSubAddr), dst+offset, 2); + } + + //redirecting party BCD num + if(setup->redirNum.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REDIRBCD, + (ie_u *)&( setup->redirNum), dst+offset, 2); + } + + //redirecting party subaddr + if(setup->redirSubAddr.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REDIRSUBADDR, + (ie_u *)&( setup->redirSubAddr), dst+offset, 2); + } + + //LLC repeat indicator + if(setup->llc_rpInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REPEATIND, + (ie_u *)&( setup->llc_rpInd), dst+offset, 2); + } + + //low layer compatability 1 + if(setup->loComp1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LOWCOM, + (ie_u *)&( setup->loComp1), dst+offset, 2); + } + + //low layer compatability 2 + if(setup->loComp2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LOWCOM, + (ie_u *)&( setup->loComp2), dst+offset, 2); + } + + //HLC repeat indicator + if(setup->hlc_rpInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REPEATIND, + (ie_u *)&( setup->hlc_rpInd), dst+offset, 2); + } + + //high layer compatability 1 + if(setup->hiComp1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_HIGHCOM, + (ie_u *)&( setup->hiComp1), dst+offset, 2); + } + + //high layer compatability 2 + if(setup->hiComp2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_HIGHCOM, + (ie_u *)&( setup->hiComp2), dst+offset, 2); + } + + //user-user + if(setup->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( setup->uu), dst+offset, 2); + } + + //priority level + if(setup->priority.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PRIORITYLEVEL, + (ie_u *)&( setup->priority), dst+offset, 2); + } + + //alert pattern + if(setup->alertPattern.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_ALERTPATTERN, + (ie_u *)&( setup->alertPattern), dst+offset, 2); + } + + return offset; +} + +//modify +int aifg_msg_sd_modify(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_modify *modify = &(src->msg.modify); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MODIFY; + + //bearer capability + assert(modify->bc.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( modify->bc), dst+offset, 0); + + //low layer comp + if(modify->loComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LOWCOM, + (ie_u *)&( modify->loComp), dst+offset, 2); + } + + //high layer comp + if(modify->hiComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_HIGHCOM, + (ie_u *)&( modify->hiComp), dst+offset, 2); + } + + //reverse call setup direction + if(modify->revCallDir.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REVCALLDIR, + (ie_u *)&( modify->revCallDir), dst+offset, 2); + } + + return offset; +} + +//modify complete +int aifg_msg_sd_modifyCmp(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_modifyCmp *modifyCmp = &(src->msg.modifyCmp); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MODIFY_CMP; + + //bearer capability + assert(modifyCmp->bc.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( modifyCmp->bc), dst+offset, 0); + + //low layer comp + if(modifyCmp->loComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LOWCOM, + (ie_u *)&( modifyCmp->loComp), dst+offset, 2); + } + + //high layer comp + if(modifyCmp->hiComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_HIGHCOM, + (ie_u *)&( modifyCmp->hiComp), dst+offset, 2); + } + + //reverse call setup direction + if(modifyCmp->revCallDir.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_REVCALLDIR, + (ie_u *)&( modifyCmp->revCallDir), dst+offset, 2); + } + + return offset; +} + +//modify reject +int aifg_msg_sd_modifyRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_modifyRej *modifyRej = &(src->msg.modifyRej); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MODIFY_REJECT; + + //bearer capability + assert(modifyRej->bc.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_BEARERCAP, + (ie_u *)&( modifyRej->bc), dst+offset, 0); + + //cause + assert(modifyRej->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( modifyRej->cause), dst+offset, 0); + + //low layer comp + if(modifyRej->loComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_LOWCOM, + (ie_u *)&( modifyRej->loComp), dst+offset, 2); + } + + //high layer comp + if(modifyRej->hiComp.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_HIGHCOM, + (ie_u *)&( modifyRej->hiComp), dst+offset, 2); + } + + return offset; +} + +//user infomation +int aifg_msg_sd_userInfo(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_userInfo *userInfo = &(src->msg.userInfo); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_USER_INFO; + + //user-user + assert(userInfo->uu.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( userInfo->uu), dst+offset, 0); + + //more data + if(userInfo->moreData.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_MOREDATA, + (ie_u *)&( userInfo->moreData), dst+offset, 2); + } + + return offset; +} + +//hold reject +int aifg_msg_sd_holdRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_holdRej *holdRej = &(src->msg.holdRej); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HOLD_REJECT; + + //cause + assert(holdRej->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( holdRej->cause), dst+offset, 0); + + return offset; +} + +//retrieve reject +int aifg_msg_sd_retrieveRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_retrieveRej *retrieveRej = &(src->msg.retrieveRej); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RETRIEVE_REJECT; + + //cause + assert(retrieveRej->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( retrieveRej->cause), dst+offset, 0); + + return offset; +} + +//disconnect +int aifg_msg_sd_disconnect(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + aifg_msg_dt_disconnect *disconnect = &(src->msg.disconnect); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_DISCONNECT; + + //cause + assert(disconnect->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( disconnect->cause), dst+offset, 0); + + //facility + if(disconnect->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( disconnect->facility), dst+offset, 2); + } + + //progress indicator + if(disconnect->progInd.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_PROGIND, + (ie_u *)&( disconnect->progInd), dst+offset, 2); + } + + //user-user + if(disconnect->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( disconnect->uu), dst+offset, 2); + } + + //SS version + if(disconnect->ssVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_SSVER, + (ie_u *)&( disconnect->ssVer), dst+offset, 2); + } + + return offset; +} + +//release +int aifg_msg_sd_release(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_release *release = &(src->msg.release); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RELEASE; + + //cause 1 + if(release->cause1.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( release->cause1), dst+offset, 2); + } + + //cause 2 + if(release->cause2.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( release->cause2), dst+offset, 2); + } + + //facility + if(release->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( release->facility), dst+offset, 2); + } + + //user-user + if(release->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( release->uu), dst+offset, 2); + } + + return offset; +} + +//release complete +int aifg_msg_sd_releaseCmp(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_releaseCmp *releaseCmp = &(src->msg.releaseCmp); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RELEASE_CMP; + + //cause + if(releaseCmp->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( releaseCmp->cause), dst+offset, 2); + } + + //facility + if(releaseCmp->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( releaseCmp->facility), dst+offset, 2); + } + + //user-user + if(releaseCmp->uu.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_USERUSER, + (ie_u *)&( releaseCmp->uu), dst+offset, 2); + } + + return offset; +} + +//congestion control +int aifg_msg_sd_congestCtrl(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_congestCtrl *congestCtrl = &(src->msg.congestCtrl); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CONGESTION_CTRL; + + //congestion level + assert(congestCtrl->congestLevel.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CONGESTLEVEL, + (ie_u *)&( congestCtrl->congestLevel), dst+offset, 0); + offset++; + + //cause + if(congestCtrl->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( congestCtrl->cause), dst+offset, 2); + } + + return offset; +} + +//notify +int aifg_msg_sd_notify(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_notify *notify = &(src->msg.notify); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_NOTIFY; + + //notification indicator + assert(notify->notificationInd.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_NOTIIND, + (ie_u *)&( notify->notificationInd), dst+offset, 0); + + return offset; +} + +//status +int aifg_msg_sd_status(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_status *status = &(src->msg.status); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_STATUS; + + //cause + assert(status->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( status->cause), dst+offset, 0); + + //call state + assert(status->callStat.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CALLSTAT, + (ie_u *)&( status->callStat), dst+offset, 0); + + //auxiliary states + if(status->auxStat.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_AUXSTAT, + (ie_u *)&( status->auxStat), dst+offset, 2); + } + + return offset; +} + +//start DTMF +int aifg_msg_sd_startDTMF(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_startDTMF *startDTMF = &(src->msg.startDTMF); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_START_DTMF; + + //keypad facility + assert(startDTMF->keypad.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_KEYPAD, + (ie_u *)&( startDTMF->keypad), dst+offset, 2); + + return offset; +} + +//start DTMF acknowledge +int aifg_msg_sd_startDTMFAck(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_startDTMF_ack *startDTMF_ack = &(src->msg.startDTMF_ack); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_START_DTMF_ACK; + + //keypad facility + assert(startDTMF_ack->keypad.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_KEYPAD, + (ie_u *)&( startDTMF_ack->keypad), dst+offset, 2); + + return offset; +} + +//start DTMF reject +int aifg_msg_sd_startDTMFRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_startDTMF_rej *startDTMF_rej = &(src->msg.startDTMF_rej); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_START_DTMF_REJECT; + + //cause + assert(startDTMF_rej->cause.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, (ie_u *)&( startDTMF_rej->cause), dst+offset, 0); + + return offset; +} + +//facility +int aifg_msg_sd_facility(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_facility *facility = &(src->msg.facility); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_FACILITY; + + //facility + assert(facility->facility.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, (ie_u *)&( facility->facility), dst+offset, 0); + + return offset; +} + +//msg_encode with only 3 ies +//authentication reject +int aifg_msg_sd_authRej(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_AUTH_REJECT; + + return offset; +} + +//CM service accept +int aifg_msg_sd_cmAccept(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CM_ACCEPT; + + return offset; +} + +//CM service abort +int aifg_msg_sd_cmAbort(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CM_ABORT; + + return offset; +} + +//TMSI reallocation complete +int aifg_msg_sd_tmsiReallocCmp(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_TMSI_REALLOC_CMP; + + return offset; +} + +//MM null +int aifg_msg_sd_mmNull(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_MM_NULL; + + return offset; +} + +//connect acknowledge +int aifg_msg_sd_connectAck(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_CONNECT_ACK; + + return offset; +} + +//hold +int aifg_msg_sd_hold(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HOLD; + + return offset; +} + +//hold acknowledge +int aifg_msg_sd_holdAck(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_HOLD_ACK; + + return offset; +} + +//retrieve +int aifg_msg_sd_retrieve(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RETRIEVE; + + return offset; +} + +//retrieve acknowledge +int aifg_msg_sd_retrieveAck(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RETRIEVE_ACK; + + return offset; +} + +//status enquiry +int aifg_msg_sd_statusEnq(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_STATUS_ENQ; + + return offset; +} + +//stop DTMF +int aifg_msg_sd_stopDTMF(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_STOP_DTMF; + + return offset; +} + +//stop DTMF acknowledge +int aifg_msg_sd_stopDTMFAck(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_STOP_DTMF_ACK; + + return offset; +} + +//facility SS +int aifg_msg_sd_facilitySS(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_facilitySS *facilitySS = &(src->msg.facilitySS); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_FACILITY_SS; + + //facility, mandatory but has iei + assert(facilitySS->facility.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( facilitySS->facility), dst+offset, 0); + + return offset; +} + + +//register +int aifg_msg_sd_register(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_register *registerSS = &(src->msg.registerSS); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_REGISTER; + + //facility, mandatory but has iei + assert(registerSS->facility.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( registerSS->facility), dst+offset, 2); + + //SS Version + if(registerSS->ssVer.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_SSVER, + (ie_u *)&( registerSS->ssVer), dst+offset, 2); + } + + return offset; +} + +//release complete SS +int aifg_msg_sd_releaseCompSS(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_releaseCompSS *releaseCompSS = &(src->msg.releaseCompSS); + + assert(src != NULL && dst != NULL); + + dst[offset++] = AIFG_MSG_T_RELEASE_CMP_SS; + + //Cause + if(releaseCompSS->cause.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_CAUSE, + (ie_u *)&( releaseCompSS->cause), dst+offset, 2); + } + + //facility + if(releaseCompSS->facility.flag == 1){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_FACILITY, + (ie_u *)&( releaseCompSS->facility), dst+offset, 2); + } + + return offset; +} + +//SMS +//RP DATA +int aifg_msg_sd_rp_data(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_rpData *rpData = &(src->msg.rpData); + + assert(src != NULL && dst != NULL); + + //CP header + dst[offset++] = AIFG_MSG_T_CP_DATA; + offset++; //skip length + + //RP header + dst[offset++] = AIFG_MSG_T_RP_DATA_NW; + dst[offset++] = src->msg.rpData.ref; + + //Originator address element + assert(rpData->moAddr.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_MO_ADDR, + (ie_u *)&( rpData->moAddr), dst+offset, 0); + + //Destination address element + assert(rpData->mtAddr.flag == 1); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_MT_ADDR, + (ie_u *)&( rpData->mtAddr), dst+offset, 0); + + //RP User data + assert(rpData->data.len > 0); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_UD, + (ie_u *)&( rpData->data), dst+offset, 1); + + dst[1] = offset - 2; + + return offset; +} + +//RP ACK +int aifg_msg_sd_rp_ack(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_rpAck *rpAck = &(src->msg.rpAck); + + assert(src != NULL && dst != NULL); + + //CP header + dst[offset++] = AIFG_MSG_T_CP_DATA; + offset++; //skip length + + //RP header + dst[offset++] = AIFG_MSG_T_RP_ACK_NW; + dst[offset++] = rpAck->ref; + + //RP User data + if(rpAck->data.len > 0){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_UD, + (ie_u *)&( rpAck->data), dst+offset, 2); + } + + dst[1] = offset - 2; + + return offset; +} + +//RP ERROR +int aifg_msg_sd_rp_error(aifg_msg_t* src, BYTE *dst) +{ + int offset = 0; + + aifg_msg_dt_rpError *rpErr = &(src->msg.rpError); + + assert(src != NULL && dst != NULL); + + //CP header + dst[offset++] = AIFG_MSG_T_CP_DATA; + offset++; //skip length + + //RP header + dst[offset++] = AIFG_MSG_T_RP_ERROR_NW; + dst[offset++] = rpErr->ref; + + //RP Cause + assert(1 == rpErr->cause.flag); + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_CAUSE, + (ie_u *)&( rpErr->cause), dst+offset, 0); + + //RP User data + if(rpErr->data.len > 0){ + offset += aifg_ie_encode(AIFG_MSG_DTAP, AIFG_IE_ID_DT_RP_UD, + (ie_u *)&( rpErr->data), dst+offset, 2); + } + + dst[1] = offset - 2; + + return offset; +} + +//End of message encode functions definition---------------------------------------- + +//Interface function of MPP submodule definition-------------------------------------- +/* +Name: aifg_mpp_init +Purpose:init MPP submodule +Input: None +Output: None +*/ +enum{AIFG_MSG_DECODE, AIFG_MSG_ENCODE}; +void aifg_mpp_init() +{ + //Init message decode function ptr array + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ASSIGN_REQ] = aifg_msg_rv_assignReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ASSIGN_CMP] = aifg_msg_rv_assignComplete; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ASSIGN_FAIL] = aifg_msg_rv_assignFailure; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_BLOCK] = aifg_msg_rv_block; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_BLOCK_ACK] = aifg_msg_rv_blockAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_UNBLOCK] = aifg_msg_rv_unBlock; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_UNBLOCK_ACK] = aifg_msg_rv_unBlockAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_REQUEST] = aifg_msg_rv_HORequest; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_REQUIRED] = aifg_msg_rv_HORequired; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_REQ_ACK] = aifg_msg_rv_HORequestAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_CMD] = aifg_msg_rv_HOCmd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_CMP] = aifg_msg_rv_HOComplete; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_SUC] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_CAN_ENQ] = aifg_msg_rv_HOCandEnq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_CAN_RESP] = aifg_msg_rv_HOCandResp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_FAIL] = aifg_msg_rv_HOFailure; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESRC_REQ] = aifg_msg_rv_resrcReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESRC_IND] = aifg_msg_rv_resrcInd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_PAGING] = aifg_msg_rv_paging; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CLR_REQ] = aifg_msg_rv_clearReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CLR_CMD] = aifg_msg_rv_clearCmd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CLR_CMP] = aifg_msg_rv_clearCmp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESET] = aifg_msg_rv_reset; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESET_ACK] = aifg_msg_rv_resetAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_PERFORMED] = aifg_msg_rv_HOPerformed; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_OVERLOAD] = aifg_msg_rv_overload; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MSC_INVK_TRACE] = aifg_msg_rv_mscTrace; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_BSC_INVK_TRACE] = aifg_msg_rv_bscTrace; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_UPDATE] = aifg_msg_rv_cmUpdate; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CIPHER_MODE_CMD] = aifg_msg_rv_cipherModeCmd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CIPHER_MODE_CMP] = aifg_msg_rv_cipherModeComp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_L3_INFO] = aifg_msg_rv_completeL3Info; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_QUEUE_IND] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_SAPI_REJ] = aifg_msg_rv_sapi_n_rej; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_REQ_REJ] = aifg_msg_rv_HORequiredRej; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESET_CC] = aifg_msg_rv_resetCircuit; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESET_CC_ACK] = aifg_msg_rv_resetCircuitAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HO_DETECT] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CC_GROUP_BLK] = aifg_msg_rv_ccGroupBlock; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CC_GROUP_BLK_ACK] = aifg_msg_rv_ccGroupBlockAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CC_GROUP_UNBLK] = aifg_msg_rv_ccGroupUnblock; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CC_GROUP_UNBLK_ACK] = aifg_msg_rv_ccGroupUnblockAck; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CONFUSION] = aifg_msg_rv_confusion; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_REQUEST] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_UNEQUIP_CC] = aifg_msg_rv_unequippedCircuit; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CIPHER_MODE_REJ] = aifg_msg_rv_clearReq; //the same as clear request + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LOAD_IND] = aifg_msg_rv_loadInd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_SUSPEND] = aifg_msg_rv_suspend; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RESUME] = aifg_msg_rv_suspend; //the same as suspend + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CHANGE_CC] = NULL; //not supported + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CHANGE_CC_ACK] = NULL; //not supported + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LSA_INFO] = NULL; //not supported + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LOC_INFO_CMD] = aifg_msg_rv_locInfoCmd; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LOC_INFO_RPT] = aifg_msg_rv_locInfoReport; + ////////dtap///////////// + //mm + aifg_msg_rv_func_ptr[AIFG_MSG_ID_AUTH_REJECT] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_AUTH_REQUEST] = aifg_msg_rv_authReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_AUTH_RESPONSE] = aifg_msg_rv_authResp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_REEST_REQUEST] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_ACCEPT] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_REJECT] = aifg_msg_rv_cmRej; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_ABORT] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ABORT] = aifg_msg_rv_cmRej;//the same as cm service reject + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CM_REQUEST] = aifg_msg_rv_cmReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ID_REQUEST] = aifg_msg_rv_idReq; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ID_RESPONSE] = aifg_msg_rv_idResp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_IMSI_DETACH_IND] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LU_ACCEPT] = aifg_msg_rv_luAccept; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LU_REQUEST] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_LU_REJECT] = aifg_msg_rv_cmRej;//the same as cm service reject + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MM_INFO] = aifg_msg_rv_mmInfo; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MM_STATUS] = aifg_msg_rv_cmRej;//The same as CM service reject + aifg_msg_rv_func_ptr[AIFG_MSG_ID_TMSI_REALLOC_CMD] = aifg_msg_rv_tmsiRealloc; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_TMSI_REALLOC_CMP] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MM_NULL] = NULL; + //cc + aifg_msg_rv_func_ptr[AIFG_MSG_ID_ALERTING] = aifg_msg_rv_alert; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CALL_CONFIRMED] = aifg_msg_rv_callConfirm; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CALL_PROCEEDING] = aifg_msg_rv_callProceed; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CONGESTION_CTRL] = aifg_msg_rv_congestCtrl; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CONNECT] = aifg_msg_rv_connect; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_CONNECT_ACK] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_DISCONNECT] = aifg_msg_rv_disconnect; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_EMERGENCY_SETUP] = aifg_msg_rv_eSetup; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_FACILITY] = aifg_msg_rv_facility; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HOLD] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HOLD_ACK] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_HOLD_REJECT] = aifg_msg_rv_holdRej; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MODIFY] = aifg_msg_rv_modify; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MODIFY_CMP] = aifg_msg_rv_modify;//the same as modify + aifg_msg_rv_func_ptr[AIFG_MSG_ID_MODIFY_REJECT] = aifg_msg_rv_modifyRej; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_NOTIFY] = aifg_msg_rv_notify; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_PROGRESS] = aifg_msg_rv_progress; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RELEASE] = aifg_msg_rv_release; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RELEASE_CMP] = aifg_msg_rv_releaseComp; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RETRIEVE] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RETRIEVE_ACK] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RETRIEVE_REJECT] = aifg_msg_rv_holdRej;//the same as hold reject + aifg_msg_rv_func_ptr[AIFG_MSG_ID_SETUP] = aifg_msg_rv_setup; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_START_DTMF] = aifg_msg_rv_startDTMF; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_START_DTMF_ACK] = aifg_msg_rv_startDTMF;//the same as stratDTMF + aifg_msg_rv_func_ptr[AIFG_MSG_ID_START_DTMF_REJECT] = aifg_msg_rv_holdRej;//the same as holdReject + aifg_msg_rv_func_ptr[AIFG_MSG_ID_STATUS] = aifg_msg_rv_status; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_STATUS_ENQ] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_STOP_DTMF] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_STOP_DTMF_ACK] = NULL; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_USER_INFO] = aifg_msg_rv_userInfo; + //ss + aifg_msg_rv_func_ptr[AIFG_MSG_ID_FACILITY_SS] = aifg_msg_rv_facilitySS; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RELEASE_CMP_SS] = aifg_msg_rv_releaseCompSS; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_REGISTER] = aifg_msg_rv_register; + //sms + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RP_DATA] = aifg_msg_rv_rp_data; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RP_SMMA] = aifg_msg_rv_rp_smma; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RP_ACK] = aifg_msg_rv_rp_ack; + aifg_msg_rv_func_ptr[AIFG_MSG_ID_RP_ERROR] = aifg_msg_rv_rp_error; + + //Init message encode function ptr array + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ASSIGN_REQ] = aifg_msg_sd_assignReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ASSIGN_CMP] = aifg_msg_sd_assignComplete; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ASSIGN_FAIL] = aifg_msg_sd_assignFailure; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_BLOCK] = aifg_msg_sd_block; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_BLOCK_ACK] = aifg_msg_sd_blockAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_UNBLOCK] = aifg_msg_sd_unblock; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_UNBLOCK_ACK] = aifg_msg_sd_unblockAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_REQUEST] = aifg_msg_sd_HORequest; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_REQUIRED] = aifg_msg_sd_HORequired; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_REQ_ACK] = aifg_msg_sd_HORequestAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_CMD] = aifg_msg_sd_HOCmd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_CMP] = aifg_msg_sd_HOComplete; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_SUC] = aifg_msg_sd_HOSucceed; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_CAN_ENQ] = aifg_msg_sd_HOCandEnq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_CAN_RESP] = aifg_msg_sd_HOCandResp; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_FAIL] = aifg_msg_sd_HOFailure; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESRC_REQ] = aifg_msg_sd_resrcReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESRC_IND] = aifg_msg_sd_resrcInd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_PAGING] = aifg_msg_sd_paging; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CLR_REQ] = aifg_msg_sd_clearReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CLR_CMD] = aifg_msg_sd_clearCmd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CLR_CMP] = aifg_msg_sd_clearComplete; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESET] = aifg_msg_sd_reset; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESET_ACK] = aifg_msg_sd_resetAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_PERFORMED] = aifg_msg_sd_HOPerformed; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_OVERLOAD] = aifg_msg_sd_overload; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MSC_INVK_TRACE] = aifg_msg_sd_mscTrace; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_BSC_INVK_TRACE] = aifg_msg_sd_bscTrace; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_UPDATE] = aifg_msg_sd_cmUpdate; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CIPHER_MODE_CMD] = aifg_msg_sd_cipherModeCmd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CIPHER_MODE_CMP] = aifg_msg_sd_cipherModeComplete; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_L3_INFO] = aifg_msg_sd_completeL3Info; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_QUEUE_IND] = aifg_msg_sd_queueInd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_SAPI_REJ] = aifg_msg_sd_sapi_n_rej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_REQ_REJ] = aifg_msg_sd_HORequiredRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESET_CC] = aifg_msg_sd_resetCircuit; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HO_DETECT] = aifg_msg_sd_HODetect; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CC_GROUP_BLK] = aifg_msg_sd_ccGrpBlk; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CC_GROUP_BLK_ACK] = aifg_msg_sd_ccGroupBlockAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CC_GROUP_UNBLK] = aifg_msg_sd_ccGroupUnblock; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CC_GROUP_UNBLK_ACK] = aifg_msg_sd_ccGroupUnblockAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CONFUSION] = aifg_msg_sd_confusion; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CLASSMARK_REQ] = aifg_msg_sd_classmarkReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_UNEQUIP_CC] = aifg_msg_sd_unequippedCircuit; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CIPHER_MODE_REJ] = aifg_msg_sd_cipherModeRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LOAD_IND] = aifg_msg_sd_loadInd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_SUSPEND] = aifg_msg_sd_suspend; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RESUME] = aifg_msg_sd_resume; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CHANGE_CC] = aifg_msg_sd_changeCircuit; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CHANGE_CC_ACK] = aifg_msg_sd_changeCircuitAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LSA_INFO] = NULL;//not supported + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LOC_INFO_CMD] = aifg_msg_sd_locCmd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LOC_INFO_RPT] = aifg_msg_sd_locReport; + ////////dtap///////////// + //mm + aifg_msg_sd_func_ptr[AIFG_MSG_ID_AUTH_REJECT] = aifg_msg_sd_authRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_AUTH_REQUEST] = aifg_msg_sd_authReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_REEST_REQUEST] = NULL; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_ACCEPT] = aifg_msg_sd_cmAccept; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_REJECT] = aifg_msg_sd_cmRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_ABORT] = aifg_msg_sd_cmAbort; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ABORT] = aifg_msg_sd_abort; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CM_REQUEST] = NULL; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ID_REQUEST] = aifg_msg_sd_idReq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ID_RESPONSE] = aifg_msg_sd_idResp; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_IMSI_DETACH_IND] = NULL; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LU_ACCEPT] = aifg_msg_sd_luAccept; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LU_REQUEST] = NULL; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_LU_REJECT] = aifg_msg_sd_luReject; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_TMSI_REALLOC_CMD] = aifg_msg_sd_tmsiReallocCmd; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_TMSI_REALLOC_CMP] = aifg_msg_sd_tmsiReallocCmp; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MM_NULL] = aifg_msg_sd_mmNull; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MM_STATUS] = aifg_msg_sd_mmStatus; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MM_INFO] = aifg_msg_sd_mmInfo; + //cc + aifg_msg_sd_func_ptr[AIFG_MSG_ID_ALERTING] = aifg_msg_sd_alert; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CALL_CONFIRMED] = aifg_msg_sd_callConfirm; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CALL_PROCEEDING] = aifg_msg_sd_callProceed; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CONGESTION_CTRL] = aifg_msg_sd_congestCtrl; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CONNECT] = aifg_msg_sd_connect; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_CONNECT_ACK] = aifg_msg_sd_connectAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_DISCONNECT] = aifg_msg_sd_disconnect; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_EMERGENCY_SETUP] = aifg_msg_sd_eSetup; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_FACILITY] = aifg_msg_sd_facility; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HOLD] = aifg_msg_sd_hold; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HOLD_ACK] = aifg_msg_sd_holdAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_HOLD_REJECT] = aifg_msg_sd_holdRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MODIFY] = aifg_msg_sd_modify; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MODIFY_CMP] = aifg_msg_sd_modifyCmp; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_MODIFY_REJECT] = aifg_msg_sd_modifyRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_NOTIFY] = aifg_msg_sd_notify; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_PROGRESS] = aifg_msg_sd_progress; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RELEASE] = aifg_msg_sd_release; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RELEASE_CMP] = aifg_msg_sd_releaseCmp; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RETRIEVE] = aifg_msg_sd_retrieve; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RETRIEVE_ACK] = aifg_msg_sd_retrieveAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RETRIEVE_REJECT] = aifg_msg_sd_retrieveRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_SETUP] = aifg_msg_sd_setup; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_START_DTMF] = aifg_msg_sd_startDTMF; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_START_DTMF_ACK] = aifg_msg_sd_startDTMFAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_START_DTMF_REJECT] = aifg_msg_sd_startDTMFRej; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_STATUS] = aifg_msg_sd_status; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_STATUS_ENQ] = aifg_msg_sd_statusEnq; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_STOP_DTMF] = aifg_msg_sd_stopDTMF; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_STOP_DTMF_ACK] = aifg_msg_sd_stopDTMFAck; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_USER_INFO] = aifg_msg_sd_userInfo; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_FACILITY_SS] = aifg_msg_sd_facilitySS; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_REGISTER] = aifg_msg_sd_register; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RELEASE_CMP_SS] = aifg_msg_sd_releaseCompSS; + //SMS + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RP_DATA] = aifg_msg_sd_rp_data; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RP_ERROR] = aifg_msg_sd_rp_error; + aifg_msg_sd_func_ptr[AIFG_MSG_ID_RP_ACK] = aifg_msg_sd_rp_ack; + + return; +} + +int aifg_mpp_proc() +{ + int tmp_sapid, tmp_cgid; + BYTE *raw_msg_ptr = NULL; + + //Read message from sccp + if(0 == SpSubmit(&sccp_msg, SCCP_SAP_AIFG)) + return AIFG_PROC_FINISH; + + switch(sccp_msg.uUiPri){ + case N_CONNECT_IND: //CR + tmp_cgid = aifg_get_cg(sccp_msg.tPriUnion.tPriNConnInd.OPC, sccp_msg.tPriUnion.tPriNConnInd.NetID); + if (tmp_cgid == -1) + goto FINISH; //can not find corresponding CG, discard + + if(0x04 != (sccp_msg.tPriUnion.tPriNConnInd.uOptFlag & 0x04)){ + aifg_debug_print(-1, AIFG_ERR_NO_UD_IN_CR, &sccp_msg, 0); //no user data, treat as error + goto FINISH; + } + + if(0 != link_info[sccp_msg.wConnId].en_flag) + goto FINISH; //duplicated CR, discard + + rv_msg.tg_id = cg[tmp_cgid].tgid; + raw_msg_ptr = sccp_msg.tPriUnion.tPriNConnInd.tUD.aUserData; + if(AIFG_MSG_T_L3_INFO == raw_msg_ptr[2]) + tmp_sapid = AIFG_SAP_MSC; + else if(AIFG_MSG_T_HO_REQUEST == raw_msg_ptr[2]) + tmp_sapid = AIFG_SAP_BSC; + else{ + aifg_event = AIFG_ERR_UNKNOW_MSG; + goto ERROR_PROC; + } + break; + + case N_CONNECT_CFM: //CC + if(0 == link_info[sccp_msg.wConnId].en_flag){ + aifg_debug_print(-1, AIFG_ERR_UNEXPECTED_CC, &sccp_msg, 0); + goto FINISH; + } + + if(0x04 == (sccp_msg.tPriUnion.tPriNConnCfm.uOptFlag & 0x04) + && sccp_msg.tPriUnion.tPriNConnCfm.tUD.uDataLen > 0){ + //has user data + raw_msg_ptr = sccp_msg.tPriUnion.tPriNConnCfm.tUD.aUserData; + tmp_sapid = link_info[sccp_msg.wConnId].sapid; + } + else + goto FINISH; + + break; + + case N_DATA_IND: //DT1 + if(0 == link_info[sccp_msg.wConnId].en_flag){ + aifg_debug_print(-1, AIFG_ERR_UNEXPECTED_DT1, &sccp_msg, 0); + goto FINISH; + } + + raw_msg_ptr = sccp_msg.tPriUnion.tPriNDataInd.tUD.aUserData; + tmp_sapid = link_info[sccp_msg.wConnId].sapid; + break; + + case N_UNITDATA_IND://UDT + tmp_cgid = aifg_get_cg(sccp_msg.tPriUnion.tPriNUDataInd.tCGA.DPC, sccp_msg.tPriUnion.tPriNUDataInd.tCGA.NetID); + rv_msg.tg_id = cg[tmp_cgid].tgid; + if (tmp_cgid == -1){ + //printf error here + goto FINISH; + } + raw_msg_ptr = sccp_msg.tPriUnion.tPriNUDataInd.tUD.aUserData; + tmp_sapid = cg[tmp_cgid].sapid; + break; + + case N_DISCONNECT_IND://RLSD or CREF + if(0 == link_info[sccp_msg.wConnId].en_flag){ + aifg_debug_print(-1, AIFG_ERR_UNEXPECTED_CC, &sccp_msg, 0); + goto FINISH; + } +/* + if(0x04 == (sccp_msg.tPriUnion.tPriNDisconnInd.uOptFlag & 0x04) + && sccp_msg.tPriUnion.tPriNDisconnInd.tUD.uDataLen > 0){ + //has user data + raw_msg_ptr = sccp_msg.tPriUnion.tPriNDisconnInd.tUD.aUserData; + tmp_sapid = link_info[sccp_msg.wConnId].sapid; + link_info[sccp_msg.wConnId].cleared = 1; + } + else +*/ goto FINISH; + break; + + default: + assert(0); //should never happen + goto FINISH; + break; + } + + if (sap[tmp_sapid].enable == 0) + goto FINISH; + + //decode the message and find its process port + if(AIFG_SAP_BSC == tmp_sapid && AIFG_MSG_DTAP == raw_msg_ptr[0]){ + //Transparently transfer of DTAP message at BSC side + rv_msg.id = AIFG_MSG_ID_TRANSPARENT_DTAP; + rv_msg.msg.dtap_msg.len = raw_msg_ptr[2]; + rv_msg.msg.dtap_msg.ptr = raw_msg_ptr + 3; //skip 3 bytes BSSAP header + rv_msg.aif_port = link_info[sccp_msg.wConnId].cur_port; + } + else{ + if(AIFG_SUCCEED != aifg_msg_proc(raw_msg_ptr, &rv_msg)) + goto ERROR_PROC; + + if (rv_msg.id == AIFG_MSG_ID_IGNORED_MSG){ + goto FINISH; + } + + //get local port for received msg + rv_msg.aif_port = -1; + rv_msg.app_port = -1; + switch(rv_msg.pd){ + case AIFG_PD_DTAP_MM: + switch(rv_msg.id){ + case AIFG_MSG_ID_CM_REQUEST: + if((rv_msg.aif_port = aifg_port_assign(tmp_sapid, -1, sccp_msg.wConnId)) < 0) + goto ERROR_PROC; + if(link_info[sccp_msg.wConnId].cur_port == -1 + || aifg_pcb[link_info[sccp_msg.wConnId].cur_port].upper_port == -1){ + int i, j, k; + k = 0; + for(i=0; i < 3; i++){ + for(j=0; j < AIFG_MAX_TI_PER_LINK; j++){ + if(link_info[sccp_msg.wConnId].ti[i][j].en_flag != 0 + && link_info[sccp_msg.wConnId].ti[i][j].port != -1 + && aifg_pcb[link_info[sccp_msg.wConnId].ti[i][j].port].upper_port != -1){ + rv_msg.app_port = aifg_pcb[link_info[sccp_msg.wConnId].ti[i][j].port].upper_port; + k = 1; + break; + } + } + if (k == 1) + break; + } + } + else + rv_msg.app_port = aifg_pcb[link_info[sccp_msg.wConnId].cur_port].upper_port; //hand message to current open port + + link_info[sccp_msg.wConnId].cur_port = rv_msg.aif_port; + break; + default: + rv_msg.aif_port = link_info[sccp_msg.wConnId].cur_port; + break; + } + break; + case AIFG_PD_DTAP_SMS: + //send back cp ack + sccp_msg.uUiPri = N_DATA_REQ; + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[2] = 2; //length + if (sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[3] > 0x80)//ti + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[3] = + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[3] & 0x7F; + else + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[3] = + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[3] | 0x80; + sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData[4] = 0x04; //msg type + sccp_msg.tPriUnion.tPriNDataReq.tUD.uDataLen = 5; + PostSp(&sccp_msg); + //no break here + case AIFG_PD_DTAP_CC: //These are transfered on connection oriented link + case AIFG_PD_DTAP_SS: + { + //find the corresponding local port and open it as current port + rv_msg.aif_port = aifg_ti2lport(rv_msg.ti, sccp_msg.wConnId, rv_msg.pd); + if (rv_msg.aif_port == -1){ + //try to use current opened port + if (link_info[sccp_msg.wConnId].cur_port != -1){ + rv_msg.aif_port = link_info[sccp_msg.wConnId].cur_port; + } + else{ + aifg_event = AIFG_ERR_INVALID_TI; + goto ERROR_PROC; + } + } + } + break; + case AIFG_PD_BSSMAP_DEDICATED: + { + switch(rv_msg.id){ + case AIFG_MSG_ID_L3_INFO: + { + switch(rv_msg.msg.completeL3Info.l3msg.id){ + case AIFG_MSG_ID_CM_REQUEST: + if(raw_msg_ptr[0] != 0x02) + { + aifg_ie tmp_ie; + if(aifg_ie_decode(&rv_msg.msg.completeL3Info.l3msg.msg.cmRequest.type, &tmp_ie) < 0) + goto ERROR_PROC; + + if(tmp_ie.param.dt_cmType.value == 1||tmp_ie.param.dt_cmType.value == 2) + { + if(aifg_check_timeslot_avail(rv_msg.tg_id)==0) + { + aifg_msg_redirect(&sccp_msg); + goto FINISH; + } + } + } + case AIFG_MSG_ID_CM_REEST_REQUEST: + { + //how to deal with this msg?? + } + //break; //treat this as normal service request (as following) msg temporarily + case AIFG_MSG_ID_IMSI_DETACH_IND: + case AIFG_MSG_ID_LU_REQUEST: + { + //service request msg, assign a new port for the following transaction + if((rv_msg.aif_port = aifg_port_assign(tmp_sapid, -1, sccp_msg.wConnId)) < 0) + goto ERROR_PROC; + } + break; + case AIFG_MSG_ID_PAGING_RESP: + { + //get the paging port + aifg_ie tmp_ie; + BYTE *imsi_ptr; + BYTE imsi_len; + aifg_ie_decode(&rv_msg.msg.completeL3Info.l3msg.msg.pagingResp.mobileId, &tmp_ie); + imsi_ptr = tmp_ie.param.mobileId.id; + imsi_len = tmp_ie.param.mobileId.id_len; + if(-1 == (rv_msg.aif_port = aifg_get_paging_port(tmp_cgid, imsi_ptr, imsi_len))){ + //not found, redirect + aifg_msg_redirect(&sccp_msg); + goto FINISH; + } + //found + aifg_pcb[rv_msg.aif_port].link_id = sccp_msg.wConnId; + assert(aifg_pcb[rv_msg.aif_port].stat == AIFG_PORT_PAGING); + } + break; + default: + break; + } + + //send back cc + SP_UiPriPara tmp_msg; + tmp_msg.uUiPri = N_CONNECT_RSP; + tmp_msg.wConnId = sccp_msg.wConnId; + tmp_msg.tPriUnion.tPriNConnRsp.uOptFlag = 0; + PostSp(&tmp_msg); + //enable this link + aifg_add_link(sccp_msg.wConnId, tmp_sapid); + } + break; + case AIFG_MSG_ID_HO_REQUEST: + { + //assign a new port for the transaction + if((rv_msg.aif_port = aifg_port_assign(tmp_sapid, -1, sccp_msg.wConnId)) < 0) + goto ERROR_PROC; + + //send back cc + SP_UiPriPara tmp_msg; + tmp_msg.uUiPri = N_CONNECT_RSP; + tmp_msg.wConnId = sccp_msg.wConnId; + tmp_msg.tPriUnion.tPriNConnRsp.uOptFlag = 0; + PostSp(&tmp_msg); + //enable this link + aifg_add_link(sccp_msg.wConnId, tmp_sapid); + } + break; + default: + rv_msg.aif_port = link_info[sccp_msg.wConnId].cur_port; + break; + } + } + break; + case AIFG_PD_BSSMAP_GLOBAL: + { + BYTE redirectFlag = 1; + + switch(rv_msg.id){ + case AIFG_MSG_ID_RESET: + { + if ((rv_msg.aif_port = aifg_port_assign(tmp_sapid, tmp_cgid, -1)) < 0) + goto ERROR_PROC; + rv_msg.app_port = UPPER_PROC; + } + break; + case AIFG_MSG_ID_RESET_CC: + { + SP_UiPriPara tmp_sccp_msg; + memset(&tmp_sccp_msg, 0, sizeof(tmp_sccp_msg)); + + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + + //send back reset cc ack + sd_msg.id = AIFG_MSG_ID_RESET_CC_ACK; + sd_msg.msg.resetCircuitAck.cic.flag = 1; + sd_msg.msg.resetCircuitAck.cic.pcm = + (rv_msg.msg.resetCircuit.cic.ptr[0] << 3) + | ((rv_msg.msg.resetCircuit.cic.ptr[1] & 0xE0) >> 5); + sd_msg.msg.resetCircuitAck.cic.timeslot = + rv_msg.msg.resetCircuit.cic.ptr[1] & 0x1F; + aifg_send_udt(tmp_cgid, &sd_msg, &tmp_sccp_msg); + } + break; + case AIFG_MSG_ID_BLOCK: + { + SP_UiPriPara tmp_sccp_msg; + memset(&tmp_sccp_msg, 0, sizeof(tmp_sccp_msg)); + + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + + //send back block ack + sd_msg.id = AIFG_MSG_ID_BLOCK_ACK; + sd_msg.msg.blockAck.cic.flag = 1; + sd_msg.msg.blockAck.cic.pcm = + (rv_msg.msg.block.cic.ptr[0] << 3) + | ((rv_msg.msg.block.cic.ptr[1] & 0xE0) >> 5); + sd_msg.msg.blockAck.cic.timeslot = rv_msg.msg.block.cic.ptr[1] & 0x1F; + aifg_send_udt(tmp_cgid, &sd_msg, &tmp_sccp_msg); + + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + } + break; + case AIFG_MSG_ID_UNBLOCK: + { + SP_UiPriPara tmp_sccp_msg; + memset(&tmp_sccp_msg, 0, sizeof(tmp_sccp_msg)); + + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + + //send back unblock ack + sd_msg.id = AIFG_MSG_ID_UNBLOCK_ACK; + sd_msg.msg.blockAck.cic.flag = 1; + sd_msg.msg.blockAck.cic.pcm = + (rv_msg.msg.block.cic.ptr[0] << 3) + | ((rv_msg.msg.block.cic.ptr[1] & 0xE0) >> 5); + sd_msg.msg.blockAck.cic.timeslot = rv_msg.msg.block.cic.ptr[1] & 0x1F; + aifg_send_udt(tmp_cgid, &sd_msg, &tmp_sccp_msg); + } + break; + case AIFG_MSG_ID_CC_GROUP_BLK: + { + aifg_ie tmp_ie; + SP_UiPriPara tmp_sccp_msg; + memset(&tmp_sccp_msg, 0, sizeof(tmp_sccp_msg)); + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + + //send back group block ack + sd_msg.id = AIFG_MSG_ID_CC_GROUP_BLK_ACK; + sd_msg.msg.ccGroupBlockAck.cic.flag = 1; + sd_msg.msg.ccGroupBlockAck.cic.pcm = (rv_msg.msg.ccGroupBlock.cic.ptr[0] << 3) + | ((rv_msg.msg.ccGroupBlock.cic.ptr[1] & 0xE0) >> 5); + sd_msg.msg.ccGroupBlockAck.cic.timeslot = rv_msg.msg.ccGroupBlock.cic.ptr[1] & 0x1F; + aifg_ie_decode(&rv_msg.msg.ccGroupBlock.cicList, &tmp_ie); + memcpy(&sd_msg.msg.ccGroupBlockAck.cicList, &tmp_ie.param.bm_cicList, sizeof(tmp_ie.param.bm_cicList)); + aifg_send_udt(tmp_cgid, &sd_msg, &tmp_sccp_msg); + } + break; + case AIFG_MSG_ID_CC_GROUP_UNBLK: + { + aifg_ie tmp_ie; + SP_UiPriPara tmp_sccp_msg; + memset(&tmp_sccp_msg, 0, sizeof(tmp_sccp_msg)); + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + + //send back group unblock ack + sd_msg.id = AIFG_MSG_ID_CC_GROUP_UNBLK_ACK; + sd_msg.msg.ccGroupUnblockAck.cic.flag = 1; + sd_msg.msg.ccGroupUnblockAck.cic.pcm = (rv_msg.msg.ccGroupUnblock.cic.ptr[0] << 3) + | ((rv_msg.msg.ccGroupUnblock.cic.ptr[1] & 0xE0) >> 5); + sd_msg.msg.ccGroupUnblockAck.cic.timeslot = rv_msg.msg.ccGroupUnblock.cic.ptr[1] & 0x1F; + aifg_ie_decode(&rv_msg.msg.ccGroupUnblock.cicList, &tmp_ie); + memcpy(&sd_msg.msg.ccGroupUnblockAck.cicList, &tmp_ie.param.bm_cicList, sizeof(tmp_ie.param.bm_cicList)); + aifg_send_udt(tmp_cgid, &sd_msg, &tmp_sccp_msg); + } + break; + case AIFG_MSG_ID_RESET_ACK: + case AIFG_MSG_ID_RESET_CC_ACK: + case AIFG_MSG_ID_BLOCK_ACK: + case AIFG_MSG_ID_UNBLOCK_ACK: + case AIFG_MSG_ID_CC_GROUP_BLK_ACK: + case AIFG_MSG_ID_CC_GROUP_UNBLK_ACK: + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = LOCAL_PROC; + break; + default: + redirectFlag = 0; //no need to redirect to other server + rv_msg.aif_port = AIFG_PORT_NOT_NEED; + rv_msg.app_port = UPPER_PROC; + break; + } + + if (redirectFlag){ + //redirect to the other server + aifg_msg_redirect(&sccp_msg); + } + + //deliver to upper layer application, currently global BSSMAP procedure does not activate a AIFG port + if(LOCAL_PROC != rv_msg.app_port){ + rv_msg.trace_flag = 0; + sap[tmp_sapid].callback_func(AIFG_IND_RV_MSG, &rv_msg); + if (rv_msg.trace_flag == 1) + aifg_pcb[rv_msg.aif_port].trace_flag = rv_msg.trace_flag; //app may enable trace by setting rv_msg.trace_flag + aifg_pcb[rv_msg.aif_port].upper_port = rv_msg.app_port; //record app port if new assigned + aifg_debug_print(rv_msg.aif_port, AIFG_EVENT_SD_IND, &rv_msg, 0); + } + } + break; + default: + aifg_event = AIFG_ERR_UNKNOW_MSG; + goto FINISH; + break; + } + } + aifg_debug_print(rv_msg.aif_port, AIFG_EVENT_RV_MSG, &rv_msg, 0); + + //call port process + if(AIFG_PORT_NOT_NEED != rv_msg.aif_port){ + if (aifg_pcb[rv_msg.aif_port].stat == AIFG_PORT_IDLE){ + aifg_debug_print(rv_msg.aif_port, AIFG_ERR_MSG_RV_TO_IDLE_PORT, &rv_msg, 0); + goto ERROR_PROC; + } + aifg_port_proc(&aifg_pcb[rv_msg.aif_port], NULL, &rv_msg); + + if(sccp_msg.uUiPri == N_CONNECT_IND || sccp_msg.uUiPri == N_DATA_IND) + link_info[aifg_pcb[rv_msg.aif_port].link_id].cur_port = rv_msg.aif_port; + } + +FINISH: + if (sccp_msg.uUiPri == N_DISCONNECT_IND) + aifg_del_link(sccp_msg.wConnId); //release the link + + msg_statistics[rv_msg.id][0]++; + if (rv_msg.id == AIFG_MSG_ID_L3_INFO) + msg_statistics[rv_msg.msg.completeL3Info.l3msg.id][0]++; + + return AIFG_PROC_CONTINUE; + +ERROR_PROC: + aifg_debug_print(rv_msg.aif_port, aifg_event, &rv_msg, sccp_msg.wConnId); + return AIFG_PROC_CONTINUE; +} + +//End of interface function definition----------------------------------------------- + +//SCCP SAP--------------------------------------------------------------------------- +void aifg_send_udt(int cgid, aifg_msg_t *msg, SP_UiPriPara *buf_ptr) +{ + int len = 0; + + aifg_debug_print(msg->aif_port, AIFG_EVENT_SD_MSG, msg, 0); + + if(NULL == buf_ptr) + buf_ptr = &sccp_msg; + + buf_ptr->tPriUnion.tPriNUDataReq.tUD.aUserData[len++] = AIFG_MSG_BSSMAP; //Protocol discriminator + + len++; //skip length + + if(aifg_msg_sd_func_ptr[msg->id] != NULL) + len += aifg_msg_sd_func_ptr[msg->id](msg, buf_ptr->tPriUnion.tPriNUDataReq.tUD.aUserData+len); + + buf_ptr->tPriUnion.tPriNUDataReq.tUD.aUserData[1] = len-2; //length + + buf_ptr->uUiPri = N_UNITDATA_REQ; + buf_ptr->uAnsiFlag = 0; + memset(&buf_ptr->tPriUnion.tPriNUDataReq.tCDA, 0, sizeof(buf_ptr->tPriUnion.tPriNUDataReq.tCDA)); + buf_ptr->tPriUnion.tPriNUDataReq.tUD.uDataLen = len; + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.DPC = cg[cgid].dpc; + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.NetID = cg[cgid].ni; + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.RI = 0x01; //route on SSN + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.GTI = 0x00; //no global tittle + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.SSN = 0xFE; //BSSAP + buf_ptr->tPriUnion.tPriNUDataReq.tCDA.ip = 0xFFFFFFFF; + + memset(&buf_ptr->tPriUnion.tPriNUDataReq.tCGA, 0, sizeof(buf_ptr->tPriUnion.tPriNUDataReq.tCGA)); + buf_ptr->tPriUnion.tPriNUDataReq.tCGA.NetID = cg[cgid].ni; + buf_ptr->tPriUnion.tPriNUDataReq.tCGA.RI = 0x01; //route on SSN + buf_ptr->tPriUnion.tPriNUDataReq.tCGA.GTI = 0x00; //no global tittle + buf_ptr->tPriUnion.tPriNUDataReq.tCGA.SSN = 0xFE; //BSSAP + + PostSp(buf_ptr); + msg_statistics[msg->id][1]++; + + return; +} + +//return new assigned link id +int aifg_send_cr(int sapid, int cgid, aifg_msg_t *msg) +{ + int len = 0; + BYTE *sd_buf = sccp_msg.tPriUnion.tPriNConnReq.tUD.aUserData; + + assert(msg->id == AIFG_MSG_ID_L3_INFO || msg->id == AIFG_MSG_ID_HO_REQUEST); + + aifg_debug_print(msg->aif_port, AIFG_EVENT_SD_MSG, msg, 0); + + sd_buf[len++] = AIFG_MSG_BSSMAP; //Protocol discriminator + sd_buf[len++] = 0; //skip length + + if(aifg_msg_sd_func_ptr[msg->id] != NULL) + sd_buf[1] = aifg_msg_sd_func_ptr[msg->id](msg, &(sd_buf[len])); + + len += sd_buf[1]; //length + + assert(len < SP_MAX_UD); + + sccp_msg.uUiPri = N_CONNECT_REQ; + sccp_msg.uAnsiFlag = 0; + memset(&sccp_msg.tPriUnion.tPriNConnReq.tCDA, 0, sizeof(sccp_msg.tPriUnion.tPriNConnReq.tCDA)); + sccp_msg.tPriUnion.tPriNConnReq.tCDA.DPC = cg[cgid].dpc; + sccp_msg.tPriUnion.tPriNConnReq.tCDA.NetID = cg[cgid].ni; + sccp_msg.tPriUnion.tPriNConnReq.tCDA.RI = 0x01; //route on SSN + sccp_msg.tPriUnion.tPriNConnReq.tCDA.GTI = 0x00; //no global tittle + sccp_msg.tPriUnion.tPriNConnReq.tCDA.SSN = 0xFE; //BSSAP + sccp_msg.tPriUnion.tPriNConnReq.tCDA.ip = 0xFFFFFFFF; + sccp_msg.tPriUnion.tPriNConnReq.uOptFlag = 0x08; + sccp_msg.tPriUnion.tPriNConnReq.tUD.uDataLen = len; + + PostSp(&sccp_msg); + msg_statistics[msg->id][1]++; + if (msg->id == AIFG_MSG_ID_L3_INFO){ + int msg_id = aifg_msgtype_to_localid(msg->msg.completeL3Info.l3Info.ptr[0], + msg->msg.completeL3Info.l3Info.ptr[1]); + msg_statistics[msg_id][1]++; + } + + return sccp_msg.wConnId; +} + +void aifg_send_dt1(int linkid, aifg_msg_t *msg, int ti) +{ + int len = 0; + BYTE *sd_buf = sccp_msg.tPriUnion.tPriNDataReq.tUD.aUserData; + + assert(msg->id != AIFG_MSG_ID_L3_INFO || msg->id != AIFG_MSG_ID_HO_REQUEST); + + aifg_debug_print(msg->aif_port, AIFG_EVENT_SD_MSG, msg, 0); + + if(AIFG_PD_BSSMAP_DEDICATED == msg->pd){ + sd_buf[len++] = AIFG_MSG_BSSMAP; //Protocol discriminator + sd_buf[len++] = 0; //skip length + + if(aifg_msg_sd_func_ptr[msg->id] != NULL) + sd_buf[1] = aifg_msg_sd_func_ptr[msg->id](msg, &(sd_buf[len])); + + len += sd_buf[1]; //length + msg_statistics[msg->id][1]++; + } + else if(msg->id != AIFG_MSG_ID_TRANSPARENT_DTAP){ + sd_buf[len++] = AIFG_MSG_DTAP; //Protocol discriminator + //DLCI + if (msg->pd == AIFG_PD_DTAP_SMS) + sd_buf[len++] = 0x03; + else + sd_buf[len++] = 0x00; + + sd_buf[len++] = 1; + + //TI and PD + if(ti != -1 && msg->pd != AIFG_PD_DTAP_MM) + sd_buf[len++] = msg->pd | (ti << 4); + else + sd_buf[len++] = msg->pd; + + if(aifg_msg_sd_func_ptr[msg->id] != NULL) + sd_buf[2] += aifg_msg_sd_func_ptr[msg->id](msg, &(sd_buf[len])); + + len += sd_buf[2] - 1; //length + msg_statistics[msg->id][1]++; + } + else{ + //transparently transfer of DTAP message at BSC side + len += msg->msg.dtap_msg.len; + memcpy(sd_buf, msg->msg.dtap_msg.ptr, msg->msg.dtap_msg.len); + msg_statistics[aifg_msgtype_to_localid(msg->pd, msg->msg.dtap_msg.ptr[1])][1]++; + } + + sccp_msg.uUiPri = N_DATA_REQ; + sccp_msg.wConnId = linkid; + sccp_msg.tPriUnion.tPriNDataReq.tUD.uDataLen = len; + + PostSp(&sccp_msg); +} + +void aifg_send_rlsd(int linkid) +{ + sccp_msg.wConnId = linkid; + sccp_msg.uUiPri = N_DISCONNECT_REQ; + sccp_msg.tPriUnion.tPriNDisconnReq.eREA = 0; + sccp_msg.tPriUnion.tPriNDisconnReq.uOptFlag = 0; + + aifg_debug_print(-1, AIFG_EVENT_LINK_RELEASE, NULL, sccp_msg.wConnId); + PostSp(&sccp_msg); +} +//End of SCCP SAP-------------------------------------------------------------------- + diff --git a/omc/plat/aif/src/include/.copyarea.db b/omc/plat/aif/src/include/.copyarea.db new file mode 100644 index 0000000..a3621e3 --- /dev/null +++ b/omc/plat/aif/src/include/.copyarea.db @@ -0,0 +1,11 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\aif\src\include +2 +7 +6:aifg.h|1|11d70a3de67|fe7|8b5f2301|b0296707bfa411dc84f1001c23e19543|0 +d:aifg_public.h|1|11d70a3dee4|39d|33cc0d9f|b159673fbfa411dc84f1001c23e19543|0 +9:aifg_ie.h|1|11d70a3df90|78f0|98f81cdb|b3196793bfa411dc84f1001c23e19543|0 +9:aifg_if.h|1|11d70a3df23|26a|5af7abd0|b1e9675bbfa411dc84f1001c23e19543|0 +a:aifg_msg.h|1|11d70a3deb5|aaac|6675a37b|853d2877c9bd11dc8b4a001c23e19543|0 +e:aifg_var_ext.h|1|11d70a3de29|93a|8f4d21bb|aef966ebbfa411dc84f1001c23e19543|0 +f:aifg_type_def.h|1|11d70a3df52|4492|b9916b|866d2878c9bd11dc8b4b001c23e19543|0 diff --git a/omc/plat/aif/src/include/aifg.h b/omc/plat/aif/src/include/aifg.h new file mode 100644 index 0000000..11c75c8 --- /dev/null +++ b/omc/plat/aif/src/include/aifg.h @@ -0,0 +1,118 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg.h +Description: API Definition of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-6 + +History: +2007-3-6 v9.0.0 Create +2007-7-7 v9.0.1 Remove Block/Unblock/Reset/Reset CC/Overload/HO Can. Enq. API, + replace with aifg_send +*********************************************************************/ +#ifndef _WXC2_AIFG_H +#define _WXC2_AIFG_H +#include "aifg_msg.h" + +/*******************************SAP Management**********************************/ +/* +Name: aifg_bind +Purpose: Request to create a SAP in AIFG module. +Input: aifg_sap_type type: type of upper layer entity + int opc:OPC of upper layer entity. + aifg_ni ni: NI of upper layer entity. +Output: SAP id +*/ +int aifg_bind(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *)); + +/* +Name: aifg_modify +Purpose: Request to modify the SAP parameter in AIFG module. +Input: aifg_sap_type type: type of upper layer entity + int opc: new OPC, -1 if no need to modify + aifg_ni ni:new NI, -1 if no need to modify + aifg_callback_func *callback: new callback functions, null if no need to modify +Output: none +*/ +void aifg_modify(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *)); + +/* +Name: aifg_set_running_mode +Purpose: Set the running mode of AIFG module. +Input: enum aifg_run_mode mode: running mode, 0 - single, 1 - dual + int alter_ip:IP address of the alternative server, hex format +Output: None +*/ +void aifg_set_running_mode(aifg_run_mode mode); + +/* +Name: aifg_createCircuitGroup +Purpose: Request to create a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int dpc: DPC of the circuit group. + aifg_ni ni: NI of the circuit group. +Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module + whenever it request to send a message through this circuit group + -1: Create failed +*/ +int aifg_createCircuitGroup(int sapid, int dpc, aifg_ni ni, int tgid); + +/* +Name: aifg_modCircuitGroup +Purpose: Request to modify the parameter of a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int cgid: Circuit Group ID + int dpc: new DPC of the circuit group, -1 if no need to change. + enum aifg_ni: new NI of the circuit group, -1 if no need to change. +Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module + whenever it request to send a message through this circuit group +*/ +int aifg_modCircuitGroup(int sapid, int cgid, int dpc, int ni); + +/* +Name: aifg_delCircuitGroup +Purpose: Request to delete a circuit group in AIFG module. +Input: int sapid: SAP ID of upper layer entity + int cgid: Circuit Group ID +Output: None +*/ +void aifg_delCircuitGroup(int sapid, int cgid); + +/* +Name: aifg_send +Purpose: Request to send a message through A-interface. +Input: int sapid: SAP ID of upper layer entity. + int cgid: Circuit Group ID + int u_port: process port of upper layer entity + aifg_msg *msg: content of assign request message +Output: 0 - succeed + -1 - failed + -2 - failed, circuit group not ready +*/ +int aifg_send(int sapid, int cgid, int u_port, aifg_msg_t *msg); + +/* +Name: aifg_paging +Purpose: Request to paging. +Input: int sapid: SAP ID of upper layer entity + int cgid: Circuit Group ID + int u_port: process port of upper layer entity + aifg_msg_bm_paging *msg: paging message +Output: 0 - succeed + -1 - failed + -2 - failed, circuit group not ready +*/ +int aifg_paging(int sapid, int cgid, int u_port, aifg_msg_t *msg); + +/* +Name: aifg_ie_decode +Purpose: Information element decode function +Input: aifg_msg_protocol protocol: BSSMAP or DTAP + aifg_pre_decoded_ie *pre_decoded: pre-decoded IE structure + aifg_ie *dst: pointer to a aifg_ie structure object in which the decoded message will be stored. +Output: Total length of decoded IE +*/ +int aifg_ie_decode(aifg_ie_ptr *pre_decoded, aifg_ie *dst); + +#endif diff --git a/omc/plat/aif/src/include/aifg_ie.h b/omc/plat/aif/src/include/aifg_ie.h new file mode 100644 index 0000000..5b7b409 --- /dev/null +++ b/omc/plat/aif/src/include/aifg_ie.h @@ -0,0 +1,1006 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_ie.h +Description: Definition of information element structure of A-I/F messages +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-21 + +History: +2007-3-21 v9.0.0 Create +*********************************************************************/ + +#ifndef _WXC2_AIFG_IE_H +#define _WXC2_AIFG_IE_H + +#include "aifg_public.h" + +#define MAX_IE_LEN 256 + +#define aifg_set_field(x, y) (x.flag = 1, x.value = y) +typedef struct _aifg_ie_field{ + BYTE flag; + BYTE value; +}aifg_ie_field; + +typedef enum{ + //For BSSMAP + AIFG_IE_ID_BM_CIC = 0x00, //CIC + AIFG_IE_ID_BM_RESOURCEAVAIL = 0x01, //Resource available + AIFG_IE_ID_BM_CAUSE = 0x02, //Cause + AIFG_IE_ID_BM_CELLID = 0x03, //Cell identifier + AIFG_IE_ID_BM_PRIORITY = 0x04, //Priority + AIFG_IE_ID_BM_L3HEADERINFO = 0x05, //Layer 3 header information + AIFG_IE_ID_BM_IMSI = 0x06, //IMSI + AIFG_IE_ID_BM_TMSI = 0x07, //TMSI + AIFG_IE_ID_BM_ENCRYPTINFO = 0x08, //Encrypt information + AIFG_IE_ID_BM_CHANNELTYPE = 0x09, //Channel type + AIFG_IE_ID_BM_PERIODICITY = 0x0A, //Periodicity + AIFG_IE_ID_BM_EXTRESOURCEIND = 0x0B, //Extended resource indicator + AIFG_IE_ID_BM_MSNUM = 0x0C, //Number of MSs + AIFG_IE_ID_BM_CLASSMARKINFO2 = 0x0D, //Classmark information type 2 + AIFG_IE_ID_BM_CLASSMARKINFO3 = 0x0E, //Classmark information type 3 + AIFG_IE_ID_BM_BANDUSED = 0x0F, //Band to be used + AIFG_IE_ID_BM_RRCAUSE = 0x10, //RR cause + AIFG_IE_ID_BM_L3INFO = 0x11, //Layer 3 information + AIFG_IE_ID_BM_DLCI = 0x12, //DLCI + AIFG_IE_ID_BM_DTXFLAG = 0x13, //DTC flag + AIFG_IE_ID_BM_CELLIDLIST = 0x14, //Cell identity list + AIFG_IE_ID_BM_RESPREQ = 0x15, //Response request + AIFG_IE_ID_BM_RESOURCEINDMEHTOD = 0x16, //Resource indication method + AIFG_IE_ID_BM_CLASSMARKINFO1 = 0x17, //Classmark information type 1 + AIFG_IE_ID_BM_CICLIST = 0x18, //CIC list + AIFG_IE_ID_BM_DIGNOSTIC = 0x19, //Dignostic + AIFG_IE_ID_BM_L3MSGCONTENT = 0x1A, //Layer 3 message content + AIFG_IE_ID_BM_CHOSENCHANNEL = 0x1B, //Chosen channel + AIFG_IE_ID_BM_TOTALRESOURCE = 0x1C, //Total resource accessiable + AIFG_IE_ID_BM_CIPHERRESPMODE = 0x1D, //Cipher response mode + AIFG_IE_ID_BM_CHANNELNEEDED = 0x1E, //Channel needed + AIFG_IE_ID_BM_TRACETYPE = 0x1F, //Trace type + AIFG_IE_ID_BM_TRIGGERID = 0x20, //Trigger ID + AIFG_IE_ID_BM_TRACEREF = 0x21, //Trace reference + AIFG_IE_ID_BM_TRANSACTIONID = 0x22, //Transaction ID + AIFG_IE_ID_BM_MOBILEID = 0x23, //Mobile identity + AIFG_IE_ID_BM_OMCID = 0x24, //OMC ID + AIFG_IE_ID_BM_FORWARDIND = 0x25, //Forward indication + AIFG_IE_ID_BM_CHOSENENCRYPT = 0x26, //Chosen encript algorithm + AIFG_IE_ID_BM_CIRCUITPOOL = 0x27, //Circuit pool + AIFG_IE_ID_BM_CIRCUITPOOLLIST = 0x28, //Circuit pool list + AIFG_IE_ID_BM_TIMEIND = 0x29, //Time indicator + AIFG_IE_ID_BM_RESOURCESITUATION = 0x2A, //Resource situation + AIFG_IE_ID_BM_CURCHANNELTYPE1 = 0x2B, //Current channel type 1 + AIFG_IE_ID_BM_QUEUEIND = 0x2C, //Queuing indicator + AIFG_IE_ID_BM_SPEECHVER = 0x2D, //Speech version + AIFG_IE_ID_BM_ASSIGNREQUIREMENT = 0x2E, //Assignment requirment + AIFG_IE_ID_BM_TALKERFLAG = 0x2F, //Talker flag + AIFG_IE_ID_BM_CONNRELREQ = 0x30, //Connection release request + AIFG_IE_ID_BM_GROUPCALLREF = 0x31, //Group call reference + AIFG_IE_ID_BM_EMLPP = 0x32, //eMLPP + AIFG_IE_ID_BM_CFGEVOIND = 0x33, //Configuration evolution indication + AIFG_IE_ID_BM_BSSOLDTONEW = 0x34, //Old BSS to new BSS + AIFG_IE_ID_BM_LSAID = 0x35, //LSA identity + AIFG_IE_ID_BM_LSAIDLIST = 0x36, //LSA identity list + AIFG_IE_ID_BM_LSAINFO = 0x37, //LSA information + AIFG_IE_ID_BM_LOCATIONINFO = 0x38, //Location information + + //For DTAP + //The iei defined below is program specific, it is not the iei of DTAP defined in GSM 04.08 + //The first byte of these iei is the type of the ie. 01-04 = type1 - type4, see 11.2.1.1.4, GSM 04.07 + //common + AIFG_IE_ID_DT_CELLID = 0x39, //Cell identity + AIFG_IE_ID_DT_CIPHERKEY = 0x3A, //Ciphering key sequence number + AIFG_IE_ID_DT_LAI = 0x3B, //location area identification + AIFG_IE_ID_DT_MOBILEID = 0x3C, //mobile identity + AIFG_IE_ID_DT_MSCM1 = 0x3D, //mobile station classmark 1 + AIFG_IE_ID_DT_MSCM2 = 0x3E, //mobile station classmark 2 + AIFG_IE_ID_DT_MSCM3 = 0x3F, //mobile station classmark 3 + AIFG_IE_ID_DT_GROUPREF = 0x40, //Descriptive group or broadcast call reference + AIFG_IE_ID_DT_GROUPCIPHERKEY = 0x41, //Group Cipher Key Number + AIFG_IE_ID_DT_PRIORITYLEVEL = 0x42, //Priority level + //MM + AIFG_IE_ID_DT_AUTHRAND = 0x43, //Authentication parameter RAND + AIFG_IE_ID_DT_AUTHSRES = 0x44, //Authentication parameter SRES + AIFG_IE_ID_DT_CMTYPE = 0x45, //CM service type + AIFG_IE_ID_DT_IDTYPE = 0x46, //Identity type + AIFG_IE_ID_DT_LUTYPE = 0x47, //Location update type + AIFG_IE_ID_DT_FULL_NWNAME = 0x48, //Full Network name + AIFG_IE_ID_DT_SHORT_NWNAME = 0x99, //Short Network name + AIFG_IE_ID_DT_REJCAUSE = 0x49, //Reject cause + AIFG_IE_ID_DT_FLONPROCEED = 0x4A, //Follow on proceed + AIFG_IE_ID_DT_TIMEZONE = 0x4B, //Time zone + AIFG_IE_ID_DT_TZTIME = 0x4C, //Time zone and time + AIFG_IE_ID_DT_CTS = 0x4D, //CTS permission + AIFG_IE_ID_DT_LSAID = 0x4E, //LSA identifier + //CC +// AIFG_IE_ID_DT_CODESETEXT = 0x4F, //Extention of codesets +// AIFG_IE_ID_DT_SHIFT = 0x50, //Locking and non-locking shift procedure + AIFG_IE_ID_DT_AUXSTAT = 0x51, //Auxiliary states + AIFG_IE_ID_DT_BEARERCAP = 0x52, //Bearer capability + AIFG_IE_ID_DT_CCCAP = 0x53, //Call control capability + AIFG_IE_ID_DT_CALLSTAT = 0x54, //Call state + AIFG_IE_ID_DT_CALLEDBCD = 0x55, //Called party BCD + AIFG_IE_ID_DT_CALLEDSUBADDR = 0x56, //Called party subaddress + AIFG_IE_ID_DT_CALLERBCD = 0x57, //Calling party BCD + AIFG_IE_ID_DT_CALLERSUBADDR = 0x58, //Calling party subaddress + AIFG_IE_ID_DT_CAUSE = 0x59, //Cause + AIFG_IE_ID_DT_CLIRSUP = 0x5A, //CLIR suppression + AIFG_IE_ID_DT_CLIRIVO = 0x5B, //CLIR invocation + AIFG_IE_ID_DT_CONGESTLEVEL = 0x5C, //Congestion level + AIFG_IE_ID_DT_CONNNUM = 0x5D, //Connected number + AIFG_IE_ID_DT_CONNSUBADDR = 0x5E, //Connected subaddress + AIFG_IE_ID_DT_FACILITY = 0x5F, //Facility + AIFG_IE_ID_DT_HIGHCOM = 0x60, //Higher layer compatibility + AIFG_IE_ID_DT_KEYPAD = 0x61, //Keypad facility + AIFG_IE_ID_DT_LOWCOM = 0x62, //Lower layer compatibility + AIFG_IE_ID_DT_MOREDATA = 0x63, //More data + AIFG_IE_ID_DT_NOTIIND = 0x64, //Notification indicator + AIFG_IE_ID_DT_PROGIND = 0x65, //Progress indicator + AIFG_IE_ID_DT_REDIRBCD = 0x66, //Redirecting party BCD + AIFG_IE_ID_DT_REDIRSUBADDR = 0x67, //Redirecting party subaddress + AIFG_IE_ID_DT_REPEATIND = 0x68, //Repeat indicator + AIFG_IE_ID_DT_REVCALLDIR = 0x69, //Reverse call setup direction + AIFG_IE_ID_DT_SIGNAL = 0x6A, //Signal + AIFG_IE_ID_DT_SSVER = 0x6B, //SS version indicator + AIFG_IE_ID_DT_USERUSER = 0x6C, //User-user + AIFG_IE_ID_DT_ALERTPATTERN = 0x6D, //Alert parttern + //SMS + AIFG_IE_ID_DT_RP_MO_ADDR = 0x6E, //Originator address element + AIFG_IE_ID_DT_RP_MT_ADDR = 0x6F, //Destination address element + AIFG_IE_ID_DT_RP_UD = 0x70, //RP-User data element + AIFG_IE_ID_DT_RP_CAUSE = 0x71, //RP-Cause element +}aifg_ie_id; + +/*******************************************DTAP*******************************************/ +//Broadcast Call Reference---------------------------------- +typedef struct _aifg_ie_dt_broadcastRef{ + BYTE flag; + int binary_code; //27 bit in total + BYTE sf; + BYTE af; + BYTE call_priority; + BYTE cipher_info; +}aifg_ie_dt_broadcastRef; +//---------------------------------------------------------- + +//Classmark Information Type 2------------------------------ +typedef struct _aifg_ie_dt_cmInfo2{ + BYTE flag; + BYTE rev_level; + BYTE es_ind; + BYTE a5_1; + BYTE rf_power_cap; + BYTE ps_cap; + BYTE ss_screen_ind; + BYTE sm_cap; + BYTE vbs; + BYTE vgcs; + BYTE fc; + BYTE cm3; + BYTE lcsva_cap; + BYTE so_lsa; + BYTE cmsp; + BYTE a5_3; + BYTE a5_2; +}aifg_ie_dt_cmInfo2; +//---------------------------------------------------------- + +//Classmark Information Type 2------------------------------ +typedef struct _aifg_ie_dt_cmInfo1{ + BYTE flag; + BYTE rev_level; + BYTE es_ind; + BYTE a5_1; + BYTE rf_power_cap; +}aifg_ie_dt_cmInfo1; +//---------------------------------------------------------- + +//Mobile ID------------------------------------------------- +typedef struct _aifg_ie_dt_mobileId{ + BYTE flag; + BYTE type; + BYTE odd_even_flag; + BYTE id[16]; + BYTE id_len; +}aifg_ie_mobileId; +//---------------------------------------------------------- + +//Location area identification------------------------------ +typedef struct _aifg_ie_dt_lai{ + BYTE flag; + BYTE mcc[3]; + BYTE mnc[3]; + int LAC; +}aifg_ie_dt_lai; +//---------------------------------------------------------- + +//Location updating type------------------------------------ +typedef struct _aifg_ie_dt_luType{ + BYTE flag; + BYTE fo_req; + BYTE lut; +}aifg_ie_dt_luType; +//---------------------------------------------------------- + +//Network name---------------------------------------------- +typedef struct _aifg_ie_dt_nwName{ + BYTE flag; + BYTE code_scheme; + BYTE add_ci; + BYTE spare_num; + BYTE text[MAX_IE_LEN]; + BYTE text_len; +}aifg_ie_dt_nwName; +//---------------------------------------------------------- + +//Time zone and time---------------------------------------- +typedef struct _aifg_ie_dt_tzTime{ + BYTE flag; + BYTE year; + BYTE month; + BYTE day; + BYTE hour; + BYTE minute; + BYTE second; + BYTE time_zone; +}aifg_ie_dt_tzTime; +//---------------------------------------------------------- + +//Progress indicator---------------------------------------- +typedef struct _aifg_ie_dt_progInd{ + BYTE flag; + BYTE coding_standard; + BYTE location; + BYTE desc; +}aifg_ie_dt_progInd; +//---------------------------------------------------------- + +//User-user------------------------------------------------- +typedef struct _aifg_ie_dt_uu{ + BYTE flag; + BYTE pd; + BYTE info[131]; + BYTE info_len; +}aifg_ie_dt_uu; +//---------------------------------------------------------- + +//Bearer capbility------------------------------------------ +typedef struct _aifg_ie_dt_bc{ + BYTE flag; + BYTE channel_require; + BYTE coding_std; + BYTE trans_mode; + BYTE info_trans_cap; + aifg_ie_field coding; + aifg_ie_field speech_ver; + aifg_ie_field compress; + aifg_ie_field structure; + aifg_ie_field dupl_mode; + aifg_ie_field confiure; + aifg_ie_field nirr; + aifg_ie_field establishment; + aifg_ie_field access_id; + aifg_ie_field rate_adaption; + aifg_ie_field signal_protocol; + aifg_ie_field o_itc; + aifg_ie_field o_rate_adaption; + aifg_ie_field hdr_nohdr; + aifg_ie_field multi_frame; + aifg_ie_field mode; + aifg_ie_field lli; + aifg_ie_field assign_or_e; + aifg_ie_field inb_neg; + aifg_ie_field layer1_id; + aifg_ie_field user_info1_protocol; + aifg_ie_field sync_async; + aifg_ie_field num_stop_bits; + aifg_ie_field negotiation; + aifg_ie_field num_data_bits; + aifg_ie_field user_rate; + aifg_ie_field intermed_rate; + aifg_ie_field nic_on_tx; + aifg_ie_field nic_on_rx; + aifg_ie_field parity; + aifg_ie_field connection_element; + aifg_ie_field modem_type; + aifg_ie_field o_modem_type; + aifg_ie_field fixed_nw_user_rate; + aifg_ie_field acceptable_chennel_code; + aifg_ie_field max_traffic_channel; + aifg_ie_field uimi; + aifg_ie_field wanted_air_if_user_rate; + aifg_ie_field layer2_id; + aifg_ie_field user_info2_protocol; +}aifg_ie_dt_bc; +//---------------------------------------------------------- + +//Facility-------------------------------------------------- +typedef struct _aifg_ie_dt_facility +{ + BYTE flag; + BYTE component[256]; + BYTE component_len; +/* struct{ + struct{ + BYTE tag; + BYTE len; + struct + { + BYTE flag; + BYTE param; + }param; + struct + { + BYTE tag; + BYTE len; + BYTE id; + }invoke_id; + struct + { BYTE flag; + BYTE tag; + BYTE len; + BYTE id; + }linked_id; + struct + { + BYTE tag; + BYTE len; + BYTE op[32]; + }opCode; + }invoke; + + struct{ + BYTE tag; + BYTE len; + struct + { BYTE flag; + BYTE param[32]; + }param; + struct + { + BYTE tag; + BYTE len; + BYTE id; + }invoke_id; + struct + { BYTE flag; + BYTE tag; + BYTE len; + }sequence; + struct + { BYTE flag; + BYTE tag; + BYTE len; + BYTE op[32]; + }opCode; + }return_result; + + struct{ + BYTE tag; + BYTE len; + struct + { + BYTE flag; + BYTE param; + }param; + struct + { + BYTE tag; + BYTE len; + BYTE id; + }invoke_id; + struct + { + BYTE tag; + BYTE len; + BYTE er[32]; + }error; + }return_error; + + struct{ + BYTE tag; + BYTE len; + struct + { + BYTE tag; + BYTE len; + BYTE id; + }invoke_id; + struct + { + BYTE tag; + BYTE len; + BYTE pro[32]; + }problem; + }reject; + }components; +*/ + +}aifg_ie_dt_facility; +//---------------------------------------------------------- + +//Cause----------------------------------------------------- +typedef struct _aifg_ie_dt_cause{ + BYTE flag; + BYTE coding_std; + BYTE location; + aifg_ie_field recommendation; + BYTE cause_value; + BYTE diagnostic[32]; + BYTE diag_len; +}aifg_ie_dt_cause; +//---------------------------------------------------------- + +//Call Control Capabilities--------------------------------- +typedef struct _aifg_ie_dt_ccCap{ + BYTE flag; + BYTE pcp; + BYTE dtmf; +}aifg_ie_dt_ccCap; +//---------------------------------------------------------- + +//Connected number------------------------------------------ +typedef struct _aifg_ie_dt_connNum{ + BYTE flag; + BYTE type; + BYTE num_plan; + aifg_ie_field presentation_ind; + aifg_ie_field screen_ind; + BYTE number[80]; + BYTE num_len; +}aifg_ie_dt_connNum; +//---------------------------------------------------------- + +//Calling number-------------------------------------------- +typedef aifg_ie_dt_connNum aifg_ie_dt_callingNum; +//---------------------------------------------------------- + +//Called number--------------------------------------------- +typedef aifg_ie_dt_connNum aifg_ie_dt_calledNum; +//---------------------------------------------------------- + +//Redirecting number---------------------------------------- +typedef aifg_ie_dt_connNum aifg_ie_dt_redirNum; +//---------------------------------------------------------- + +//Connected subaddress-------------------------------------- +typedef struct _aifg_ie_dt_connSubAddr{ + BYTE flag; + BYTE type; + BYTE odd_even_ind; + BYTE info[20]; + BYTE info_len; +}aifg_ie_dt_connSubAddr; +//---------------------------------------------------------- + +//Calling subaddress---------------------------------------- +typedef aifg_ie_dt_connSubAddr aifg_ie_dt_callingSubAddr; +//---------------------------------------------------------- + +//Called subaddress----------------------------------------- +typedef aifg_ie_dt_connSubAddr aifg_ie_dt_calledSubAddr; +//---------------------------------------------------------- + +//Redirecting subaddress------------------------------------ +typedef aifg_ie_dt_connSubAddr aifg_ie_dt_redirSubAddr; +//---------------------------------------------------------- + +//SS Version Indicator-------------------------------------- +typedef struct _aifg_ie_dt_ssVer{ + BYTE flag; + BYTE info[MAX_IE_LEN]; + BYTE info_len; +}aifg_ie_dt_ssVer; +//---------------------------------------------------------- + +//High layer compatibility---------------------------------- +typedef struct _aifg_ie_dt_hiComp{ + BYTE flag; + aifg_ie_field coding_std; + aifg_ie_field interpret; + aifg_ie_field presentat_method; + aifg_ie_field high_layer_id; + aifg_ie_field ext_high_layer_id; +}aifg_ie_dt_hiComp; +//---------------------------------------------------------- + +//low layer compatibility----------------------------------- +typedef struct _aifg_ie_dt_loComp{ + BYTE flag; + BYTE data[13]; + BYTE data_len; +}aifg_ie_dt_loComp; +//---------------------------------------------------------- + +//Auxiliary states------------------------------------------ +typedef struct _aifg_ie_dt_auxStat{ + BYTE flag; + BYTE hold_stat; + BYTE mpty_stat; +}aifg_ie_dt_auxStat; +//---------------------------------------------------------- + +//Call status----------------------------------------------- +typedef struct _aifg_ie_dt_callStat{ + BYTE flag; + BYTE coding_std; + BYTE value; +}aifg_ie_dt_callStat; +//---------------------------------------------------------- + +//Authenticataion RAND-------------------------------------- +typedef struct _aifg_ie_dt_authRAND{ + BYTE flag; + BYTE value[16]; +}aifg_ie_dt_authRAND; +//---------------------------------------------------------- + +//Authenticataion SRES-------------------------------------- +typedef struct _aifg_ie_dt_authSRES{ + BYTE flag; + BYTE value[4]; +}aifg_ie_dt_authSRES; +//---------------------------------------------------------- + +//LSA Identifier-------------------------------------------- +typedef struct _aifg_ie_dt_lsaId{ + BYTE flag; + BYTE value[3]; +}aifg_ie_dt_lsaId; +//---------------------------------------------------------- + +//Follow On Proceed----------------------------------------- +typedef struct _aifg_ie_dt_followOnProceed{ + BYTE flag; + BYTE value; +}aifg_ie_dt_followOnProceed; +//---------------------------------------------------------- + +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_CTSPermission; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_rejectCause; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_cmType; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_cipherKey; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_priority; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_idType; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_rpInd; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_congestLevel; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_notificationInd; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_signal; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_alertPattern; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_keypad; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_moreData; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_revCallDir; +typedef aifg_ie_dt_followOnProceed aifg_ie_dt_timeZone; + +//SMS +typedef struct{ + BYTE flag; + BYTE number_type; + BYTE number_plan; + BYTE number[18]; + BYTE number_len; +}aifg_ie_dt_rpAddr; + +typedef struct{ + BYTE len; + BYTE content[234]; +}aifg_ie_dt_rpUD; + +typedef struct{ + BYTE flag; + int cause; + BYTE diagnostic[234]; + BYTE diag_len; +}aifg_ie_dt_rpCause; + +/*******************************************BSSMAP*******************************************/ +//CIC------------------------------------------------------- +typedef struct _aifg_ie_bm_cic{ + BYTE flag; + int pcm; + int timeslot; +}aifg_ie_bm_cic; +//---------------------------------------------------------- + +//Resource available---------------------------------------- +typedef struct _aifg_ie_bm_resrcAvail{ + BYTE flag; + int full_rate_channel[5]; + int half_rate_channel[5]; +}aifg_ie_bm_resrcAvail; +//---------------------------------------------------------- + +//Cause----------------------------------------------------- +typedef struct _aifg_ie_bm_cause{ + BYTE flag; + BYTE value; + aifg_ie_field ext_value; +}aifg_ie_bm_cause; +//---------------------------------------------------------- + +//Cell Id--------------------------------------------------- +typedef struct _aifg_ie_bm_cellId{ + BYTE flag; + BYTE discriminator; + BYTE mcc[3]; + BYTE mnc[3]; + int LAC; + int CI; +}aifg_ie_bm_cellId; +//---------------------------------------------------------- + +//Priority-------------------------------------------------- +typedef struct _aifg_ie_bm_priority{ + BYTE flag; + BYTE pci; + BYTE level; + BYTE qa; + BYTE pvi; +}aifg_ie_bm_priority; +//---------------------------------------------------------- + +//Layer 3 Header Information-------------------------------- +typedef struct _aifg_ie_bm_L3HeaderInfo{ + BYTE flag; + BYTE pd; + BYTE ti; +}aifg_ie_bm_L3HeaderInfo; +//---------------------------------------------------------- + +//IMSI------------------------------------------------------ +typedef struct _aifg_ie_bm_imsi{ + BYTE flag; + BYTE type; + BYTE odd_even_flag; + BYTE imsi[16]; + BYTE imsi_len; +}aifg_ie_bm_imsi; +//---------------------------------------------------------- + +//Encrypt Information--------------------------------------- +typedef struct _aifg_ie_bm_encryptInfo{ + BYTE flag; + BYTE algorithm; + BYTE key[8]; +}aifg_ie_bm_encryptInfo; +//---------------------------------------------------------- + +//channel type---------------------------------------------- +typedef struct _aifg_ie_bm_channelType{ + BYTE flag; + BYTE speech_data_ind; + BYTE channel_rate_type; + union{ + struct { + BYTE len; + BYTE ver[6]; + }speech; + struct{ + BYTE t_nt; + BYTE rate; + aifg_ie_field allowed_data_rate; + }data_cfg; + }ext; +}aifg_ie_bm_channelType; +//---------------------------------------------------------- + +//Extended resource indicator------------------------------- +typedef struct _aifg_ie_bm_extResourceInd{ + BYTE flag; + BYTE sm; + BYTE tarr; +}aifg_ie_bm_extResourceInd; +//---------------------------------------------------------- + +//Classmark Information Type 2------------------------------ +typedef aifg_ie_dt_cmInfo2 aifg_ie_bm_cmInfo2; +//---------------------------------------------------------- + +//Layer 3 information and Layer 3 message content----------- +typedef struct _aifg_ie_bm_l3Info{ + void *l3_msg; //this void pointer should be converted to a pointer to aifg_msg after L3 message is decoded + BYTE len; +}aifg_ie_bm_l3Info; +//---------------------------------------------------------- + +//Cell identifier list-------------------------------------- +typedef struct _aifg_ie_bm_cidList{ + BYTE flag; + BYTE discriminator; + struct{ + BYTE mcc[3]; + BYTE mnc[3]; + int LAC; + int CI; + }cell_id[32]; + BYTE cid_num; +}aifg_ie_bm_cidList; +//---------------------------------------------------------- + +//Classmark Information Type 1------------------------------ +typedef aifg_ie_dt_cmInfo1 aifg_ie_bm_cmInfo1; +//---------------------------------------------------------- + +//CIC list-------------------------------------------------- +typedef struct _aifg_ie_bm_cicList{ + BYTE flag; + BYTE range; + struct{ + BYTE len; + BYTE content[32]; + }status; +}aifg_ie_bm_cicList; +//---------------------------------------------------------- + +//Diagnostics----------------------------------------------- +typedef struct _aifg_ie_bm_diagnostics{ + BYTE flag; + BYTE err_pointer; + BYTE bit_pointer; + struct{ + BYTE len; + BYTE msg[MAX_IE_LEN]; + }err_msg; +}aifg_ie_bm_diagnostics; +//---------------------------------------------------------- + +//Chosen channel-------------------------------------------- +typedef struct _aifg_ie_bm_chosenChannel{ + BYTE flag; + BYTE mode; + BYTE channel; +}aifg_ie_bm_chosenChannel; +//---------------------------------------------------------- + +//Total resource accessiable-------------------------------- +typedef struct _aifg_ie_bm_totalResrc{ + BYTE flag; + int full_rate_channel; + int half_rate_channel; +}aifg_ie_bm_totalResrc; +//---------------------------------------------------------- + +//Trigger ID------------------------------------------------ +typedef struct _aifg_ie_bm_triggerId{ + BYTE flag; + BYTE len; + BYTE content[20]; +}aifg_ie_bm_triggerId; +//---------------------------------------------------------- + +//Circuit pool list----------------------------------------- +typedef struct _aifg_ie_bm_circuitPoolList{ + BYTE flag; + BYTE circuit[MAX_IE_LEN]; + BYTE num; +}aifg_ie_bm_circuitPoolList; +//---------------------------------------------------------- + +//Resource situation---------------------------------------- +typedef struct _aifg_ie_bm_resrcSit{ + BYTE flag; + struct{ + BYTE band_ind; + BYTE channel_type; + int channel_num; + }band[7]; + BYTE band_num; +}aifg_ie_bm_resrcSit; +//---------------------------------------------------------- + +//Current channel type 1------------------------------------ +typedef struct _aifg_ie_bm_curChannelType1{ + BYTE flag; + BYTE channel_mode; + BYTE channel; +}aifg_ie_bm_curChannelType1; +//---------------------------------------------------------- + +//Group Call Reference-------------------------------------- +typedef aifg_ie_dt_broadcastRef aifg_ie_bm_groupRef; +//---------------------------------------------------------- + +//LSA identifier list--------------------------------------- +typedef struct _aifg_ie_bm_lsaIdList{ + BYTE flag; + BYTE ep; + struct{ + BYTE id[3]; + }list[64]; + BYTE lsa_num; +}aifg_ie_bm_lsaIdList; +//---------------------------------------------------------- + +//LSA information------------------------------------------- +typedef struct _aifg_ie_bm_lsaInfo{ + BYTE flag; + BYTE lsa_only; + BYTE lsa_num; + struct{ + BYTE priority; + BYTE id[3]; + }info[50]; +}aifg_ie_bm_lsaInfo; +//---------------------------------------------------------- + +//Location information-------------------------------------- +typedef struct _aifg_ie_bm_locInfo{ + BYTE flag; + BYTE info[MAX_IE_LEN]; + BYTE len; +}aifg_ie_bm_locInfo; +//---------------------------------------------------------- + +//OMC ID---------------------------------------------------- +typedef struct _aifg_ie_bm_omcId{ + BYTE flag; + BYTE id[20]; + BYTE len; +}aifg_ie_bm_omcId; +//---------------------------------------------------------- + +//Old BSS to New BSS information---------------------------- +typedef struct _aifg_ie_bm_bssOldtoNew{ + BYTE flag; + BYTE content[MAX_IE_LEN]; + BYTE len; +}aifg_ie_bm_bssOldtoNew; +//---------------------------------------------------------- + +//Trace reference------------------------------------------- +typedef struct _aifg_ie_bm_traceRef{ + BYTE flag; + int value; +}aifg_ie_bm_traceRef; +//---------------------------------------------------------- + +typedef aifg_ie_bm_traceRef aifg_ie_bm_transId; + +//TMSI----------------------------------------------------- +typedef struct _aifg_ie_bm_tmsi{ + BYTE flag; + BYTE value[4]; +}aifg_ie_bm_tmsi; +//---------------------------------------------------------- + +typedef aifg_ie_dt_lsaId aifg_ie_bm_lsaId; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_periodicity; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_msNum; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_bandUsed; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_rrCause; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_dlci; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_dtx; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_respReq; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_resrcIndMethod; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_cipherRespMode; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_channelNeeded; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_traceType; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_fowardInd; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_chosenEncrypt; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_circuitPool; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_timeId; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_speechVer; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_queuingInd; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_assignReq; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_talkerFlag; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_connRelReq; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_eMLPP; +typedef aifg_ie_dt_followOnProceed aifg_ie_bm_cfgEvoInd; + + +typedef union{ + //Common + aifg_ie_mobileId mobileId; + + //DTAP + aifg_ie_dt_broadcastRef dt_broadcastRef; + aifg_ie_dt_cmInfo1 dt_cmInfo1; + aifg_ie_dt_cmInfo2 dt_cmInfo2; + aifg_ie_dt_lai dt_lai; + aifg_ie_dt_luType dt_luType; + aifg_ie_dt_nwName dt_nwName; + aifg_ie_dt_tzTime dt_tzTime; + aifg_ie_dt_progInd dt_progInd; + aifg_ie_dt_uu dt_uu; + aifg_ie_dt_bc dt_bc; + aifg_ie_dt_cause dt_cause; + aifg_ie_dt_ccCap dt_ccCap; + aifg_ie_dt_connNum dt_connNum; + aifg_ie_dt_callingNum dt_callingNum; + aifg_ie_dt_calledNum dt_calledNum; + aifg_ie_dt_redirNum dt_redirNum; + aifg_ie_dt_connSubAddr dt_connSubAddr; + aifg_ie_dt_callingSubAddr dt_callingSubAddr; + aifg_ie_dt_calledSubAddr dt_calledSubAddr; + aifg_ie_dt_redirSubAddr dt_redirSubAddr; + aifg_ie_dt_ssVer dt_ssVer; + aifg_ie_dt_hiComp dt_hiComp; + aifg_ie_dt_loComp dt_loComp; + aifg_ie_dt_callStat dt_callStat; + aifg_ie_dt_auxStat dt_auxStat; + aifg_ie_dt_followOnProceed dt_followOnProceed; + aifg_ie_dt_CTSPermission dt_CTSPermission; + aifg_ie_dt_rejectCause dt_rejectCause; + aifg_ie_dt_cmType dt_cmType; + aifg_ie_dt_cipherKey dt_cipherKey; + aifg_ie_dt_priority dt_priority; + aifg_ie_dt_idType dt_idType; + aifg_ie_dt_rpInd dt_rpInd; + aifg_ie_dt_congestLevel dt_congestLevel; + aifg_ie_dt_notificationInd dt_notificationInd; + aifg_ie_dt_signal dt_signal; + aifg_ie_dt_alertPattern dt_alertPattern; + aifg_ie_dt_keypad dt_keypad; + aifg_ie_dt_moreData dt_moreData; + aifg_ie_dt_revCallDir dt_revCallDir; + aifg_ie_dt_timeZone dt_timeZone; + aifg_ie_dt_authRAND dt_authRAND; + aifg_ie_dt_authSRES dt_authSRES; + aifg_ie_dt_lsaId dt_lsaId; + aifg_ie_dt_facility dt_facility; + aifg_ie_dt_rpAddr dt_rpAddr; + aifg_ie_dt_rpUD dt_rpUD; + aifg_ie_dt_rpCause dt_rpCause; + + //BSSMAP + aifg_ie_bm_cic bm_cic; + aifg_ie_bm_resrcAvail bm_resrcAvail; + aifg_ie_bm_cause bm_cause; + aifg_ie_bm_cellId bm_cellId; + aifg_ie_bm_priority bm_priority; + aifg_ie_bm_L3HeaderInfo bm_L3HeaderInfo; + aifg_ie_bm_imsi bm_imsi; + aifg_ie_bm_encryptInfo bm_encryptInfo; + aifg_ie_bm_channelType bm_channelType; + aifg_ie_bm_extResourceInd bm_extResrcInd; + aifg_ie_bm_cmInfo2 bm_cmInfo2; + aifg_ie_bm_l3Info bm_l3Info; + aifg_ie_bm_cidList bm_cellIdList; + aifg_ie_bm_cicList bm_cicList; + aifg_ie_bm_diagnostics bm_diagnostics; + aifg_ie_bm_chosenChannel bm_chosenChannel; + aifg_ie_bm_totalResrc bm_totalResrc; + aifg_ie_bm_triggerId bm_triggerId; + aifg_ie_bm_circuitPoolList bm_circuitPoolList; + aifg_ie_bm_resrcSit bm_resrcSit; + aifg_ie_bm_curChannelType1 bm_curChannelType1; + aifg_ie_bm_groupRef bm_groupRef; + aifg_ie_bm_lsaIdList bm_lsaIdList; + aifg_ie_bm_lsaInfo bm_lsaInfo; + aifg_ie_bm_locInfo bm_locInfo; + aifg_ie_bm_omcId bm_omcId; + aifg_ie_bm_bssOldtoNew bm_bssOldtoNew; + aifg_ie_bm_periodicity bm_periodicity; + aifg_ie_bm_msNum bm_msNum; + aifg_ie_bm_bandUsed bm_bandUsed; + aifg_ie_bm_rrCause bm_rrCause; + aifg_ie_bm_dlci bm_dlci; + aifg_ie_bm_dtx bm_dtx; + aifg_ie_bm_respReq bm_respReq; + aifg_ie_bm_resrcIndMethod bm_resrcIndMethod; + aifg_ie_bm_cipherRespMode bm_cipherRespMode; + aifg_ie_bm_channelNeeded bm_channelNeeded; + aifg_ie_bm_traceType bm_traceType; + aifg_ie_bm_fowardInd bm_fowardInd; + aifg_ie_bm_chosenEncrypt bm_chosenEncrypt; + aifg_ie_bm_circuitPool bm_circuitPool; + aifg_ie_bm_timeId bm_timeId; + aifg_ie_bm_speechVer bm_speechVer; + aifg_ie_bm_queuingInd bm_queuingInd; + aifg_ie_bm_assignReq bm_assignReq; + aifg_ie_bm_talkerFlag bm_talkerFlag; + aifg_ie_bm_connRelReq bm_connRelReq; + aifg_ie_bm_eMLPP bm_eMLPP; + aifg_ie_bm_cfgEvoInd bm_cfgEvoInd; + aifg_ie_bm_traceRef bm_traceRef; + aifg_ie_bm_transId bm_transId; + aifg_ie_bm_tmsi bm_tmsi; + aifg_ie_bm_lsaId bm_lsaId; +}ie_u; + +typedef struct{ + int iei; + ie_u param; +}aifg_ie; + +#endif + diff --git a/omc/plat/aif/src/include/aifg_if.h b/omc/plat/aif/src/include/aifg_if.h new file mode 100644 index 0000000..19a4588 --- /dev/null +++ b/omc/plat/aif/src/include/aifg_if.h @@ -0,0 +1,31 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_if.h +Description: Interface declearation for wxc2main +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-14 + +History: +2007-3-14 v9.0.0 Create +*********************************************************************/ +#ifndef _WXC2_AIFG_IF_H +#define _WXC2_AIFG_IF_H + +/* +Name: aifg_init +Purpose: Init AIFG module. +Input: None +Output: None +*/ +void aifg_init(); + +/* +Name: aifg_init +Purpose: 10ms routing of AIFG module. +Input: None +Output: None +*/ +void aifg_proc(); + +#endif diff --git a/omc/plat/aif/src/include/aifg_msg.h b/omc/plat/aif/src/include/aifg_msg.h new file mode 100644 index 0000000..bb6a201 --- /dev/null +++ b/omc/plat/aif/src/include/aifg_msg.h @@ -0,0 +1,1636 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_msg.h +Description: Definition of message structure of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-6 + +History: +2007-3-6 v9.0.0 Create +*********************************************************************/ + +#ifndef _WXC2_AIFG_MSG_H +#define _WXC2_AIFG_MSG_H +#include "aifg_ie.h" + +#define AIFG_MAX_MSG_IE 24 + +/**********************************PUBLIC**********************************/ +//local message id +typedef enum { + //DTAP + AIFG_MSG_ID_TRANSPARENT_DTAP = 0x00, //TRANSPARENT Dtap message at BSC side + //RR + AIFG_MSG_ID_PAGING_RESP = 0x01, //Paging response + AIFG_MSG_ID_RR_HO_CMD = 0x02, //RR Handover command + //MM + AIFG_MSG_ID_IMSI_DETACH_IND = 0x03, //IMSI detach indication + AIFG_MSG_ID_LU_ACCEPT = 0x04, //Location updating accept + AIFG_MSG_ID_LU_REJECT = 0x05, //Location updating reject + AIFG_MSG_ID_LU_REQUEST = 0x06, //Location updating request + AIFG_MSG_ID_AUTH_REJECT = 0x07, //Authentication reject + AIFG_MSG_ID_AUTH_REQUEST = 0x08, //Authentication request + AIFG_MSG_ID_AUTH_RESPONSE = 0x09, //Authentication response + AIFG_MSG_ID_ID_REQUEST = 0x0A, //Identity request + AIFG_MSG_ID_ID_RESPONSE = 0x0B, //Identity response + AIFG_MSG_ID_TMSI_REALLOC_CMD = 0x0C, //TMSI reallocation command + AIFG_MSG_ID_TMSI_REALLOC_CMP = 0x0D, //TMSI reallocation complete + AIFG_MSG_ID_CM_ACCEPT = 0x0E, //CM service accept + AIFG_MSG_ID_CM_REJECT = 0x0F, //CM service reject + AIFG_MSG_ID_CM_ABORT = 0x10, //CM service abort + AIFG_MSG_ID_CM_REQUEST = 0x11, //CM service request + AIFG_MSG_ID_CM_PROMPT = 0x12, //CM service prompt + AIFG_MSG_ID_CM_REEST_REQUEST = 0x13, //CM re-establishment request + AIFG_MSG_ID_ABORT = 0x14, //Abort + AIFG_MSG_ID_MM_NULL = 0x15, //MM NULL + AIFG_MSG_ID_MM_STATUS = 0x16, //MM status + AIFG_MSG_ID_MM_INFO = 0x17, //MM information + //CC + AIFG_MSG_ID_ALERTING = 0x18, //Alerting + AIFG_MSG_ID_CALL_CONFIRMED = 0x19, //Call confirmed + AIFG_MSG_ID_CALL_PROCEEDING = 0x1A, //Call proceeding + AIFG_MSG_ID_CONNECT = 0x1B, //Connect + AIFG_MSG_ID_CONNECT_ACK = 0x1C, //Connect ack + AIFG_MSG_ID_EMERGENCY_SETUP = 0x1D, //Emergency setup + AIFG_MSG_ID_PROGRESS = 0x1E, //Progress + AIFG_MSG_ID_SETUP = 0x1F, //Setup + AIFG_MSG_ID_MODIFY = 0x20, //Modify + AIFG_MSG_ID_MODIFY_CMP = 0x21, //Modify complete + AIFG_MSG_ID_MODIFY_REJECT = 0x22, //Modify reject + AIFG_MSG_ID_USER_INFO = 0x23, //User information + AIFG_MSG_ID_HOLD = 0x24, //Hold + AIFG_MSG_ID_HOLD_ACK = 0x25, //Hold ack + AIFG_MSG_ID_HOLD_REJECT = 0x26, //Hold reject + AIFG_MSG_ID_RETRIEVE = 0x27, //Retrieve + AIFG_MSG_ID_RETRIEVE_ACK = 0x28, //Retrieve ack + AIFG_MSG_ID_RETRIEVE_REJECT = 0x29, //Retrieve reject + AIFG_MSG_ID_DISCONNECT = 0x2A, //Disconnect + AIFG_MSG_ID_RELEASE = 0x2B, //Release + AIFG_MSG_ID_RELEASE_CMP = 0x2C, //Release complete + AIFG_MSG_ID_CONGESTION_CTRL = 0x2D, //Congestion control + AIFG_MSG_ID_NOTIFY = 0x2E, //Notify + AIFG_MSG_ID_STATUS = 0x2F, //Status + AIFG_MSG_ID_STATUS_ENQ = 0x30, //Status enquiry + AIFG_MSG_ID_START_DTMF = 0x31, //Start DTMF + AIFG_MSG_ID_STOP_DTMF = 0x32, //Stop DTMF + AIFG_MSG_ID_STOP_DTMF_ACK = 0x33, //Stop DTMF ack + AIFG_MSG_ID_START_DTMF_ACK = 0x34, //Start DTMF ack + AIFG_MSG_ID_START_DTMF_REJECT = 0x35, //Start DTMF reject + AIFG_MSG_ID_FACILITY = 0x36, //Facility + //SS + AIFG_MSG_ID_FACILITY_SS = 0x37, //Facility SS + AIFG_MSG_ID_REGISTER = 0x38, //Register + AIFG_MSG_ID_RELEASE_CMP_SS = 0x39, //Release Completed SS + //SMS + AIFG_MSG_ID_RP_DATA = 0x3A, //RP-DATA + AIFG_MSG_ID_RP_ACK = 0x3B, //RP-ACK + AIFG_MSG_ID_RP_ERROR = 0x3C, //RP-ERROR + AIFG_MSG_ID_RP_SMMA = 0x3D, //RP-SMMA + //BSSMAP + //Global + AIFG_MSG_ID_BLOCK = 0x3E, //Block + AIFG_MSG_ID_BLOCK_ACK = 0x3F, //Blocking ack + AIFG_MSG_ID_UNBLOCK = 0x40, //Unblock + AIFG_MSG_ID_UNBLOCK_ACK = 0x41, //Unblocking ack + AIFG_MSG_ID_CC_GROUP_BLK = 0x42, //Circuit group block + AIFG_MSG_ID_CC_GROUP_BLK_ACK = 0x43, //Circuit group block ack + AIFG_MSG_ID_CC_GROUP_UNBLK = 0x44, //Circuit group unblock + AIFG_MSG_ID_CC_GROUP_UNBLK_ACK = 0x45, //Circuit group unblock ack + AIFG_MSG_ID_RESRC_REQ = 0x46, //Resource request + AIFG_MSG_ID_RESRC_IND = 0x47, //Resource indication + AIFG_MSG_ID_RESET = 0x48, //Reset + AIFG_MSG_ID_RESET_ACK = 0x49, //Reset ack + AIFG_MSG_ID_PAGING = 0x4A, //Paging + AIFG_MSG_ID_OVERLOAD = 0x4B, //Overload + AIFG_MSG_ID_RESET_CC = 0x4C, //Reset circuit + AIFG_MSG_ID_RESET_CC_ACK = 0x4D, //Reset circuit ack + AIFG_MSG_ID_HO_CAN_ENQ = 0x4E, //Handover candidate enquire + AIFG_MSG_ID_HO_CAN_RESP = 0x4F, //Handover candidate response + //Dedicated + AIFG_MSG_ID_ASSIGN_REQ = 0x50, //Assign request + AIFG_MSG_ID_ASSIGN_CMP = 0x51, //Assign complete + AIFG_MSG_ID_ASSIGN_FAIL = 0x52, //Assign failure + AIFG_MSG_ID_HO_REQUEST = 0x53, //Handover request + AIFG_MSG_ID_HO_REQUIRED = 0x54, //Handover required + AIFG_MSG_ID_HO_REQ_ACK = 0x55, //Handover request ack + AIFG_MSG_ID_HO_CMD = 0x56, //Handover command + AIFG_MSG_ID_HO_CMP = 0x57, //Handover complete + AIFG_MSG_ID_HO_SUC = 0x58, //Handover succeeded + AIFG_MSG_ID_HO_FAIL = 0x59, //Handover failure + AIFG_MSG_ID_HO_PERFORMED = 0x5A, //Handover performed + AIFG_MSG_ID_HO_REQ_REJ = 0x5B, //Handover required reject + AIFG_MSG_ID_HO_DETECT = 0x5C, //Handover detect + AIFG_MSG_ID_CLR_CMD = 0x5D, //Clear command + AIFG_MSG_ID_CLR_CMP = 0x5E, //Clear complete + AIFG_MSG_ID_CLR_REQ = 0x5F, //Clear request + AIFG_MSG_ID_SAPI_REJ = 0x60, //SAPI 'n' reject + AIFG_MSG_ID_CONFUSION = 0x61, //Confusion + AIFG_MSG_ID_SUSPEND = 0x62, //Suspend + AIFG_MSG_ID_RESUME = 0x63, //Resume + AIFG_MSG_ID_LOC_INFO_CMD = 0x64, //Location information command + AIFG_MSG_ID_LOC_INFO_RPT = 0x65, //Location information report + AIFG_MSG_ID_MSC_INVK_TRACE = 0x66, //MSC invoke trace + AIFG_MSG_ID_BSC_INVK_TRACE = 0x67, //BSC invoke trace + AIFG_MSG_ID_UNEQUIP_CC = 0x68, //Unequipped circuit + AIFG_MSG_ID_CHANGE_CC = 0x69, //Change circuit + AIFG_MSG_ID_CHANGE_CC_ACK = 0x6A, //Change circuit ack + AIFG_MSG_ID_CIPHER_MODE_CMD = 0x6B, //Cipher mode command + AIFG_MSG_ID_CM_UPDATE = 0x6C, //Classmark update + AIFG_MSG_ID_CIPHER_MODE_CMP = 0x6D, //Cipher mode complete + AIFG_MSG_ID_QUEUE_IND = 0x6E, //Queueing indication + AIFG_MSG_ID_L3_INFO = 0x6F, //Complete layer 3 information + AIFG_MSG_ID_CLASSMARK_REQ = 0x70, //Classmark request + AIFG_MSG_ID_CIPHER_MODE_REJ = 0x71, //Cipher mode reject + AIFG_MSG_ID_LOAD_IND = 0x72, //Load indication + AIFG_MSG_ID_LSA_INFO = 0x73, //LSA INFORMATION + AIFG_MSG_ID_IGNORED_MSG = 0xFF, //Ignored message, no need to process +}aifg_msg_id; + +typedef enum { + AIFG_MSG_DTAP = 1, + AIFG_MSG_BSSMAP = 0, +}aifg_msg_protocol; + +typedef enum { + //There are protocol defined, see GSM 04.08 + AIFG_PD_DTAP_MM = 0x05, + AIFG_PD_DTAP_CC = 0x03, + AIFG_PD_DTAP_SS = 0x0B, + AIFG_PD_DTAP_SMS = 0x09, + + //These are module defined + AIFG_PD_BSSMAP_GLOBAL = 0xF0, + AIFG_PD_BSSMAP_DEDICATED = 0xF1, +}aifg_pd; + +//Message struct for encode----------------------------------------------------- +//DTAP-------------------------------------------------------------------------- +typedef struct{ + aifg_ie_dt_lai lai; + aifg_ie_mobileId mobileId; + aifg_ie_dt_followOnProceed followOnProceed; + aifg_ie_dt_CTSPermission CTSPermission; +}aifg_msg_dt_luAccept; + +typedef struct{ + aifg_ie_dt_rejectCause rejectCause; +}aifg_msg_dt_cmReject; + +typedef aifg_msg_dt_cmReject aifg_msg_dt_luReject; + +typedef aifg_msg_dt_cmReject aifg_msg_dt_abort; + +typedef aifg_msg_dt_cmReject aifg_msg_dt_mmStatus; + +typedef struct{ + aifg_ie_dt_luType luType; + aifg_ie_dt_lai lai; + aifg_ie_dt_cipherKey cipherKey; + aifg_ie_mobileId mobileId; + aifg_ie_dt_cmInfo1 cmInfo1; +}aifg_msg_dt_LURequest; + +typedef struct{ + aifg_ie_dt_cipherKey cipherKey; + aifg_ie_dt_authRAND authRAND; +}aifg_msg_dt_authRequest; + +typedef struct{ + aifg_ie_dt_authSRES authSRES; +}aifg_msg_dt_authResp; + +typedef struct{ + aifg_ie_dt_idType idType; +}aifg_msg_dt_idRequest; + +typedef struct{ + aifg_ie_mobileId mobileId; +}aifg_msg_dt_idResp; + +typedef struct{ + aifg_ie_dt_cmInfo1 cmInfo1; + aifg_ie_mobileId mobileId; +}aifg_msg_dt_imsiDetachInd; + +typedef struct{ + aifg_ie_dt_lai lai; + aifg_ie_mobileId mobileId; +}aifg_msg_dt_tmsiCmd; + +typedef struct{ + aifg_ie_dt_cipherKey cipherKey; + aifg_ie_dt_cmInfo2 cmInfo2; + aifg_ie_mobileId mobileId; + aifg_ie_dt_lai lai; +}aifg_msg_dt_cmReEstReq; + +typedef struct{ + aifg_ie_dt_cmType cmType; + aifg_ie_dt_cipherKey cipherKey; + aifg_ie_dt_cmInfo2 cmInfo2; + aifg_ie_mobileId mobileId; + aifg_ie_dt_priority priority; +}aifg_msg_dt_cmRequest; + +typedef struct{ + aifg_ie_dt_nwName fullName; + aifg_ie_dt_nwName shortName; + aifg_ie_dt_timeZone timeZone; + aifg_ie_dt_tzTime tzTime; + aifg_ie_dt_lsaId lsaId; +}aifg_msg_dt_mmInfo; + +//cc +typedef struct{ + aifg_ie_dt_facility facility; + aifg_ie_dt_progInd progInd; + aifg_ie_dt_uu uu; +}aifg_msg_dt_alert; + +typedef struct{ + aifg_ie_dt_rpInd rpInd; + aifg_ie_dt_bc bc1; + aifg_ie_dt_bc bc2; + aifg_ie_dt_cause cause; + aifg_ie_dt_ccCap ccCap; +}aifg_msg_dt_callConfirm; + +typedef struct{ + aifg_ie_dt_rpInd rpInd; + aifg_ie_dt_bc bc1; + aifg_ie_dt_bc bc2; + aifg_ie_dt_facility facility; + aifg_ie_dt_progInd progInd; + aifg_ie_dt_priority priority; +}aifg_msg_dt_callProceed; + +typedef struct{ + aifg_ie_dt_facility facility; + aifg_ie_dt_progInd progInd; + aifg_ie_dt_connNum connNum; + aifg_ie_dt_connSubAddr connSubAddr; + aifg_ie_dt_uu uu; +}aifg_msg_dt_connect; + +typedef struct{ + aifg_ie_dt_bc bc; +}aifg_msg_dt_eSetup; + +typedef struct{ + aifg_ie_dt_progInd progInd; + aifg_ie_dt_uu uu; +}aifg_msg_dt_progress; + +typedef struct{ + aifg_ie_dt_rpInd bc_rpInd; + aifg_ie_dt_bc bc1; + aifg_ie_dt_bc bc2; + aifg_ie_dt_facility facility; + aifg_ie_dt_progInd progInd; + aifg_ie_dt_signal signal; + aifg_ie_dt_callingNum callingNum; + aifg_ie_dt_callingSubAddr callingSubAddr; + aifg_ie_dt_calledNum calledNum; + aifg_ie_dt_calledSubAddr calledSubAddr; + aifg_ie_dt_redirNum redirNum; + aifg_ie_dt_redirSubAddr redirSubAddr; + aifg_ie_dt_rpInd llc_rpInd; + aifg_ie_dt_loComp loComp1; + aifg_ie_dt_loComp loComp2; + aifg_ie_dt_rpInd hlc_rpInd; + aifg_ie_dt_hiComp hiComp1; + aifg_ie_dt_hiComp hiComp2; + aifg_ie_dt_uu uu; + aifg_ie_dt_priority priority; + aifg_ie_dt_alertPattern alertPattern; +}aifg_msg_dt_setup; + +typedef struct{ + aifg_ie_dt_bc bc; + aifg_ie_dt_loComp loComp; + aifg_ie_dt_hiComp hiComp; + aifg_ie_dt_revCallDir revCallDir; +}aifg_msg_dt_modify; + +typedef aifg_msg_dt_modify aifg_msg_dt_modifyCmp; + +typedef struct{ + aifg_ie_dt_bc bc; + aifg_ie_dt_cause cause; + aifg_ie_dt_loComp loComp; + aifg_ie_dt_hiComp hiComp; +}aifg_msg_dt_modifyRej; + +typedef struct{ + aifg_ie_dt_uu uu; + aifg_ie_dt_moreData moreData; +}aifg_msg_dt_userInfo; + +typedef struct{ + aifg_ie_dt_cause cause; +}aifg_msg_dt_holdRej; + +typedef aifg_msg_dt_holdRej aifg_msg_dt_retrieveRej; + +typedef struct{ + aifg_ie_dt_cause cause; + aifg_ie_dt_facility facility; + aifg_ie_dt_progInd progInd; + aifg_ie_dt_uu uu; + aifg_ie_dt_ssVer ssVer; +}aifg_msg_dt_disconnect; + +typedef struct{ + aifg_ie_dt_cause cause1; + aifg_ie_dt_cause cause2; + aifg_ie_dt_facility facility; + aifg_ie_dt_uu uu; +}aifg_msg_dt_release; + +typedef struct{ + aifg_ie_dt_cause cause; + aifg_ie_dt_facility facility; + aifg_ie_dt_uu uu; +}aifg_msg_dt_releaseCmp; + +typedef struct{ + aifg_ie_dt_congestLevel congestLevel; + aifg_ie_dt_cause cause; +}aifg_msg_dt_congestCtrl; + +typedef struct{ + aifg_ie_dt_notificationInd notificationInd; +}aifg_msg_dt_notify; + +typedef struct{ + aifg_ie_dt_cause cause; + aifg_ie_dt_callStat callStat; + aifg_ie_dt_auxStat auxStat; +}aifg_msg_dt_status; + +typedef struct{ + aifg_ie_dt_keypad keypad; +}aifg_msg_dt_startDTMF; + +typedef aifg_msg_dt_startDTMF aifg_msg_dt_startDTMF_ack; + +typedef aifg_msg_dt_holdRej aifg_msg_dt_startDTMF_rej; + +typedef struct{ + aifg_ie_dt_facility facility; +}aifg_msg_dt_facility; + +typedef struct{ + aifg_ie_dt_cipherKey cipherKey; + aifg_ie_dt_cmInfo2 cmInfo2; + aifg_ie_mobileId mobileId; +}aifg_msg_dt_pagingResp; + +typedef struct{ + aifg_ie_dt_cause cause; + aifg_ie_dt_facility facility; +}aifg_msg_dt_releaseCompSS; + +typedef struct{ + aifg_ie_dt_facility facility; + aifg_ie_dt_ssVer ssVer; +}aifg_msg_dt_register; + +typedef struct{ + aifg_ie_dt_facility facility; +}aifg_msg_dt_facilitySS; + +typedef struct{ + BYTE ref; + aifg_ie_dt_rpAddr moAddr; + aifg_ie_dt_rpAddr mtAddr; + aifg_ie_dt_rpUD data; +}aifg_msg_dt_rpData; + +typedef struct{ + BYTE ref; +}aifg_msg_dt_rpSMMA; + +typedef struct{ + BYTE ref; + aifg_ie_dt_rpUD data; +}aifg_msg_dt_rpAck; + +typedef struct{ + BYTE ref; + aifg_ie_dt_rpCause cause; + aifg_ie_dt_rpUD data; +}aifg_msg_dt_rpError; + +//BSSMAP---------------------------------------------------------------------- +typedef struct{ + BYTE id; //message id + union{ + aifg_msg_dt_LURequest luRequest; + aifg_msg_dt_cmRequest cmRequest; + aifg_msg_dt_cmReEstReq cmReEstReq; + aifg_msg_dt_imsiDetachInd imsiDetachInd; + aifg_msg_dt_pagingResp pagingResp; + }msg; +}aifg_msg_bm_l3msg; + +typedef struct { + aifg_ie_bm_channelType channelType; + aifg_ie_bm_L3HeaderInfo l3HeaderInfo; + aifg_ie_bm_priority priority; + aifg_ie_bm_cic cic; + aifg_ie_bm_dtx dtxFlag; + aifg_ie_bm_bandUsed bandUsed; + aifg_ie_bm_cmInfo2 cm2; + aifg_ie_bm_groupRef groupRef; + aifg_ie_bm_talkerFlag talkerFlag; + aifg_ie_bm_cfgEvoInd cfgEvoInd; +}aifg_msg_bm_assignReq; + +typedef struct { + aifg_ie_bm_rrCause rrCause; + aifg_ie_bm_cic cic; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_chosenChannel chosenChannel; + aifg_ie_bm_chosenEncrypt chosenEncrypt; + aifg_ie_bm_circuitPool circuitPool; + aifg_ie_bm_speechVer speechVer; + aifg_ie_bm_lsaId lsaId; +}aifg_msg_bm_assignComplete; + +typedef struct { + aifg_ie_bm_rrCause rrCause; + aifg_ie_bm_cause cause; + aifg_ie_bm_circuitPool circuitPool; + aifg_ie_bm_circuitPoolList circuitPoolList; +}aifg_msg_bm_assignFailure; + +typedef struct { + aifg_ie_bm_cic cic; + aifg_ie_bm_cause cause; + aifg_ie_bm_connRelReq connRelReq; +}aifg_msg_bm_block; + +typedef struct { + aifg_ie_bm_cic cic; +}aifg_msg_bm_blockAck; + +typedef aifg_msg_bm_blockAck aifg_msg_bm_unblock; + +typedef aifg_msg_bm_blockAck aifg_msg_bm_unblockAck; + +typedef struct { + aifg_ie_bm_channelType channelType; + aifg_ie_bm_encryptInfo encryptInfo; + union{ + BYTE ind; + aifg_ie_bm_cmInfo1 cm1; + aifg_ie_bm_cmInfo2 cm2; + }cmInfo; + aifg_ie_bm_cellId servingCellId; + aifg_ie_bm_priority priority; + aifg_ie_bm_cic cic; + aifg_ie_bm_dtx dtxFlag; + aifg_ie_bm_cellId targetCellId; + aifg_ie_bm_bandUsed bandUsed; + aifg_ie_bm_cause cause; +// aifg_ie_bm_cmInfo3 cm3; + aifg_ie_bm_curChannelType1 curChannelType1; + aifg_ie_bm_speechVer speechVer; + aifg_ie_bm_groupRef gourpRef; + aifg_ie_bm_talkerFlag talkerFlag; + aifg_ie_bm_cfgEvoInd cfgEvoInd; + aifg_ie_bm_chosenEncrypt chosenEncrypt; + aifg_ie_bm_bssOldtoNew bssOldtoNew; + aifg_ie_bm_lsaInfo lsaInfo; +}aifg_msg_bm_HORequest; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_respReq respReq; + aifg_ie_bm_cidList prefer_cidList; + aifg_ie_bm_circuitPoolList circuitPoolList; + aifg_ie_bm_curChannelType1 curChannelType1; + aifg_ie_bm_speechVer speechVer; + aifg_ie_bm_queuingInd queuingInd; + aifg_ie_bm_bssOldtoNew bssOldtoNew; +}aifg_msg_bm_HORequired; + +typedef struct { + struct{ + BYTE *ptr; + BYTE len; + }l3Info; + aifg_ie_bm_chosenChannel chosenChannel; + aifg_ie_bm_chosenEncrypt chosenEncrypt; + aifg_ie_bm_circuitPool circuitPool; + aifg_ie_bm_speechVer speechVer; + aifg_ie_bm_cic cic; + aifg_ie_bm_lsaId lsaId; +}aifg_msg_bm_HORequestAck; + +typedef struct { + struct{ + BYTE *ptr; + BYTE len; + }l3Info; + aifg_ie_bm_cellId cellId; +}aifg_msg_bm_HOCmd; + +typedef struct { + aifg_ie_bm_rrCause rrCause; +}aifg_msg_bm_HOComplete; + +typedef struct { + aifg_ie_bm_msNum msNum; + aifg_ie_bm_cidList cidList; + aifg_ie_bm_cellId cellId; +}aifg_msg_bm_HOCandidateEnq; + +typedef struct { + aifg_ie_bm_msNum msNum; + aifg_ie_bm_cellId cellId; +}aifg_msg_bm_HOCandidateResp; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_rrCause rrCause; + aifg_ie_bm_circuitPool circuitPool; + aifg_ie_bm_circuitPoolList circuitPoolList; +}aifg_msg_bm_HOFailure; + +typedef struct { + aifg_ie_bm_periodicity periodicity; + aifg_ie_bm_resrcIndMethod resrcIndMethod; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_extResourceInd extResrcInd; +}aifg_msg_bm_resrcReq; + +typedef struct { + aifg_ie_bm_resrcIndMethod resrcIndMethod; + aifg_ie_bm_resrcAvail resrcAvail; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_totalResrc totalResrc; +}aifg_msg_bm_resrcInd; + +typedef struct { + aifg_ie_bm_imsi imsi; + aifg_ie_bm_tmsi tmsi; + aifg_ie_bm_cidList cidList; + aifg_ie_bm_channelNeeded channelNeeded; + aifg_ie_bm_eMLPP eMLPP; +}aifg_msg_bm_paging; + +typedef struct { + aifg_ie_bm_cause cause; +}aifg_msg_bm_clearReq; + +typedef struct { + aifg_ie_bm_L3HeaderInfo l3HeaderInfo; + aifg_ie_bm_cause cause; +}aifg_msg_bm_clearCmd; + +typedef aifg_msg_bm_clearReq aifg_msg_bm_reset; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_chosenChannel chosenChannel; + aifg_ie_bm_chosenEncrypt chosenEncrypt; + aifg_ie_bm_speechVer speechVer; + aifg_ie_bm_lsaId lsaId; +}aifg_msg_bm_HOPerformed; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_cellId cellId; +}aifg_msg_bm_overload; + +typedef struct { + aifg_ie_bm_traceType traceType; + aifg_ie_bm_triggerId tiggerId; + aifg_ie_bm_traceRef traceRef; + aifg_ie_bm_transId transId; + aifg_ie_mobileId mobileId; + aifg_ie_bm_omcId omcId; +}aifg_msg_bm_mscInvokeTrace; + +typedef struct { + aifg_ie_bm_traceType traceType; + aifg_ie_bm_fowardInd forwardInd; + aifg_ie_bm_triggerId tiggerId; + aifg_ie_bm_traceRef traceRef; + aifg_ie_bm_transId transId; + aifg_ie_bm_omcId omcId; +}aifg_msg_bm_bscInvokeTrace; + +typedef struct { + aifg_ie_bm_cmInfo2 cm2; +// aifg_ie_bm_cmInfo3 cm3; +}aifg_msg_bm_cmUpdate; + +typedef struct { + aifg_ie_bm_L3HeaderInfo l3HeaderInfo; + aifg_ie_bm_encryptInfo encryptInfo; + aifg_ie_bm_cipherRespMode cipherRespMode; +}aifg_msg_bm_cipherModeCmd; + +typedef struct { + struct{ + BYTE flag; + BYTE *ptr; + BYTE len; + }l3Info; + aifg_ie_bm_chosenEncrypt chosenEncrypt; +}aifg_msg_bm_cipherModeComplete; + +typedef struct { + struct{ + BYTE *ptr; + BYTE len; + }l3Info; +// aifg_msg_bm_l3msg l3Info; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_chosenChannel chosenChannel; + aifg_ie_bm_lsaIdList lsaIdList; + aifg_ie_bm_locInfo locInfo; +}aifg_msg_bm_completeL3Info; + +typedef struct { + aifg_ie_bm_dlci dlci; + aifg_ie_bm_cause cause; +}aifg_msg_bm_SAPI_n_Reject; + +typedef aifg_msg_bm_clearReq aifg_msg_bm_HOReject; + +typedef struct { + aifg_ie_bm_cic cic; + aifg_ie_bm_cause cause; +}aifg_msg_bm_resetCircuit; + +typedef struct { + aifg_ie_bm_cic cic; +}aifg_msg_bm_resetCircuitAck; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_cic cic; + aifg_ie_bm_cicList cicList; +}aifg_msg_bm_circuitGrpBlk; + +typedef struct { + aifg_ie_bm_cic cic; + aifg_ie_bm_cicList cicList; +}aifg_msg_bm_circuitGrpBlkAck; + +typedef aifg_msg_bm_circuitGrpBlkAck aifg_msg_bm_circuitGrpUnblk; + +typedef aifg_msg_bm_circuitGrpBlkAck aifg_msg_bm_circuitGrpUnblkAck; + +typedef struct { + aifg_ie_bm_cause cause; + aifg_ie_bm_diagnostics diagnostics; +}aifg_msg_bm_confusion; + +typedef aifg_msg_bm_circuitGrpBlkAck aifg_msg_bm_unequippedCircuit; + +typedef aifg_msg_bm_clearReq aifg_msg_bm_cipherModeReject; + +typedef struct { + aifg_ie_bm_timeId timeInd; + aifg_ie_bm_cellId cellId; + aifg_ie_bm_cidList cidList; + aifg_ie_bm_resrcSit resrcSit; + aifg_ie_bm_cause cause; +}aifg_msg_bm_loadIndication; + +typedef struct { + aifg_ie_bm_dlci dlci; +}aifg_msg_bm_suspend; + +typedef aifg_msg_bm_suspend aifg_msg_bm_resume; + +typedef aifg_msg_bm_clearReq aifg_msg_bm_changeCircuit; + +typedef aifg_msg_bm_resetCircuitAck aifg_msg_bm_changeCircuitAck; + +typedef struct { + aifg_ie_bm_lsaInfo lsaInfo; +}aifg_msg_bm_lsaInfo; + +typedef struct { + aifg_ie_bm_locInfo locInfo; +}aifg_msg_bm_locCmd; + +typedef struct { + aifg_ie_bm_locInfo locInfo; + aifg_ie_bm_cause cause; +}aifg_msg_bm_locReport; + +typedef struct { + aifg_msg_id id; + aifg_pd pd; + int app_port; + int aif_port; + int trace_flag; //0 - off, 1 - on + union{ + //BSSMAP + aifg_msg_bm_assignReq assignReq; + aifg_msg_bm_assignComplete assignComplete; + aifg_msg_bm_assignFailure assignFailure; + aifg_msg_bm_block block; + aifg_msg_bm_blockAck blockAck; + aifg_msg_bm_unblock unblock; + aifg_msg_bm_unblockAck unblockAck; + aifg_msg_bm_HORequired HORequired; + aifg_msg_bm_HORequest HORequest; + aifg_msg_bm_HORequestAck HORequestAck; + aifg_msg_bm_HOCmd HOCmd; + aifg_msg_bm_HOComplete HOComplete; + aifg_msg_bm_HOCandidateEnq HOCandidateEnq; + aifg_msg_bm_HOCandidateResp HOCandidateResp; + aifg_msg_bm_HOFailure HOFailure; + aifg_msg_bm_HOPerformed HOPerformed; + aifg_msg_bm_HOReject HOReject; + aifg_msg_bm_resrcReq resourceReq; + aifg_msg_bm_resrcInd resourceInd; + aifg_msg_bm_paging paging; + aifg_msg_bm_clearReq clearReq; + aifg_msg_bm_clearCmd clearCmd; + aifg_msg_bm_reset reset; + aifg_msg_bm_overload overload; + aifg_msg_bm_mscInvokeTrace mscInvokeTrace; + aifg_msg_bm_bscInvokeTrace bscInvokeTrace; + aifg_msg_bm_cmUpdate cmUpdate; + aifg_msg_bm_cipherModeCmd cipherModeCmd; + aifg_msg_bm_cipherModeComplete cipherModeComplete; + aifg_msg_bm_cipherModeReject cipherModeReject; + aifg_msg_bm_completeL3Info completeL3Info; + aifg_msg_bm_SAPI_n_Reject SAPI_n_Reject; + aifg_msg_bm_resetCircuit resetCircuit; + aifg_msg_bm_resetCircuitAck resetCircuitAck; + aifg_msg_bm_circuitGrpBlk ccGroupBlock; + aifg_msg_bm_circuitGrpBlkAck ccGroupBlockAck; + aifg_msg_bm_circuitGrpUnblk ccGroupUnblock; + aifg_msg_bm_circuitGrpUnblkAck ccGroupUnblockAck; + aifg_msg_bm_confusion confusion; + aifg_msg_bm_unequippedCircuit unequippedCircuit; + aifg_msg_bm_loadIndication loadInd; + aifg_msg_bm_suspend suspend; + aifg_msg_bm_resume resume; + aifg_msg_bm_changeCircuit changeCircuit; + aifg_msg_bm_changeCircuitAck changeCircuitAck; + aifg_msg_bm_lsaInfo lsaInfo; + aifg_msg_bm_locCmd locCmd; + aifg_msg_bm_locReport locReport; + + //DTAP + aifg_msg_dt_luAccept luAccept; + aifg_msg_dt_cmReject cmReject; + aifg_msg_dt_luReject luReject; + aifg_msg_dt_abort abort; + aifg_msg_dt_mmStatus mmStatus; + aifg_msg_dt_LURequest luRequest; + aifg_msg_dt_authRequest authRequest; + aifg_msg_dt_authResp authResp; + aifg_msg_dt_idRequest idRequest; + aifg_msg_dt_idResp idResp; + aifg_msg_dt_imsiDetachInd IMSI_ind; + aifg_msg_dt_tmsiCmd tmsiCmd; + aifg_msg_dt_cmReEstReq cmReEst_Request; + aifg_msg_dt_cmRequest cmRequest; + aifg_msg_dt_mmInfo mmInfo; + aifg_msg_dt_alert alert; + aifg_msg_dt_callConfirm callConfirm; + aifg_msg_dt_callProceed callProceed; + aifg_msg_dt_connect connect; + aifg_msg_dt_eSetup eSetup; + aifg_msg_dt_progress progress; + aifg_msg_dt_setup setup; + aifg_msg_dt_modify modify; + aifg_msg_dt_modifyCmp modifyCmp; + aifg_msg_dt_modifyRej modifyRej; + aifg_msg_dt_userInfo userInfo; + aifg_msg_dt_holdRej holdRej; + aifg_msg_dt_retrieveRej retrieveRej; + aifg_msg_dt_disconnect disconnect; + aifg_msg_dt_release release; + aifg_msg_dt_releaseCmp releaseCmp; + aifg_msg_dt_congestCtrl congestCtrl; + aifg_msg_dt_notify notify; + aifg_msg_dt_status status; + aifg_msg_dt_startDTMF startDTMF; + aifg_msg_dt_startDTMF_ack startDTMF_ack; + aifg_msg_dt_startDTMF_rej startDTMF_rej; + aifg_msg_dt_facility facility; + aifg_msg_dt_facilitySS facilitySS; + aifg_msg_dt_register registerSS; + aifg_msg_dt_releaseCompSS releaseCompSS; + aifg_msg_dt_rpData rpData; + aifg_msg_dt_rpSMMA rpSMMA; + aifg_msg_dt_rpAck rpAck; + aifg_msg_dt_rpError rpError; + + //for transparently DTAP message transfer in BSC + struct { + BYTE *ptr; + BYTE len; + }dtap_msg; + }msg; +}aifg_msg_t; + +//Message struct for decode----------------------------------------------------- +enum{AIFG_LOW_BITS = 0, AIFG_HIGH_BITS}; + +typedef struct +{ + BYTE iei; + BYTE *ptr; + BYTE hi_lo_flag; +}aifg_ie_ptr; + +//DTAP------------------------------------- +typedef struct +{ + aifg_ie_ptr cipherKeySeq; + aifg_ie_ptr authParamRAND; +}aifg_msg_predecode_dt_authReq; + +typedef struct +{ + aifg_ie_ptr authParamSRES; +}aifg_msg_predecode_dt_authResp; + +typedef struct +{ + aifg_ie_ptr cipherKeySeq; + aifg_ie_ptr cm2; + aifg_ie_ptr mobileId; + aifg_ie_ptr lai; + aifg_ie_ptr id; +}aifg_msg_predecode_dt_cmReEstReq; + +typedef struct +{ + aifg_ie_ptr rejCause; +}aifg_msg_predecode_dt_cmRej; + +typedef struct +{ + aifg_ie_ptr rejCause; +}aifg_msg_predecode_dt_abort; + +typedef struct +{ + aifg_ie_ptr type; + aifg_ie_ptr cipherKeySeq; + aifg_ie_ptr cm2; + aifg_ie_ptr mobileId; + aifg_ie_ptr priority; +}aifg_msg_predecode_dt_cmReq; + +typedef struct +{ + aifg_ie_ptr type; +}aifg_msg_predecode_dt_idReq; + +typedef struct +{ + aifg_ie_ptr mobileId; +}aifg_msg_predecode_dt_idResp; + +typedef struct +{ + aifg_ie_ptr cm1; + aifg_ie_ptr mobileId; +}aifg_msg_predecode_dt_imsiDetachInd; + +typedef struct +{ + aifg_ie_ptr lai; + aifg_ie_ptr mobileId; + aifg_ie_ptr followOnProc; + aifg_ie_ptr ctsPerm; +}aifg_msg_predecode_dt_luAccept; + +typedef struct +{ + aifg_ie_ptr rejCause; +}aifg_msg_predecode_dt_luReject; + +typedef struct +{ + aifg_ie_ptr type; + aifg_ie_ptr cipherKeySeq; + aifg_ie_ptr lai; + aifg_ie_ptr cm1; + aifg_ie_ptr mobileId; +}aifg_msg_predecode_dt_LURequest; + +typedef struct +{ + aifg_ie_ptr fullNetworkName; + aifg_ie_ptr shortNetworkName; + aifg_ie_ptr timeZone; + aifg_ie_ptr timeZoneAndTime; + aifg_ie_ptr lsaId; +}aifg_msg_predecode_dt_mmInfo; + +typedef struct +{ + aifg_ie_ptr rejCause; +}aifg_msg_predecode_dt_mmStatus; + +typedef struct +{ + aifg_ie_ptr lai; + aifg_ie_ptr mobileId; +}aifg_msg_predecode_dt_tmsiReallocCmd; + +typedef struct +{ + aifg_ie_ptr facility; + aifg_ie_ptr progressInd; + aifg_ie_ptr user_user; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_alert; + +typedef struct +{ + aifg_ie_ptr reptInd; + aifg_ie_ptr bearCap1; + aifg_ie_ptr bearCap2; + aifg_ie_ptr cause; + aifg_ie_ptr ccCap; +}aifg_msg_predecode_dt_callConfirm; + +typedef struct +{ + aifg_ie_ptr reptInd; + aifg_ie_ptr bearCap1; + aifg_ie_ptr bearCap2; + aifg_ie_ptr facility; + aifg_ie_ptr progressInd; + aifg_ie_ptr priority; +}aifg_msg_predecode_dt_callProceed; + +typedef struct +{ + aifg_ie_ptr congestLev; + aifg_ie_ptr cause; +}aifg_msg_predecode_dt_congestCtrl; + +typedef struct +{ + aifg_ie_ptr facility; + aifg_ie_ptr progressInd; + aifg_ie_ptr connNum; + aifg_ie_ptr connSubaddr; + aifg_ie_ptr user_user; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_connect; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr facility; + aifg_ie_ptr progressInd; + aifg_ie_ptr user_user; + aifg_ie_ptr allowAct; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_disconnect; + +typedef struct +{ + aifg_ie_ptr bearCap; +}aifg_msg_predecode_dt_emergSetup; + +typedef struct +{ + aifg_ie_ptr facility; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_facility; + +typedef struct +{ + aifg_ie_ptr bearCap; + aifg_ie_ptr lowLComp; + aifg_ie_ptr highLComp; + aifg_ie_ptr revCallSetDir; +}aifg_msg_predecode_dt_modify; + +typedef aifg_msg_predecode_dt_modify aifg_msg_predecode_dt_modifyComp; + +typedef struct +{ + aifg_ie_ptr bearCap; + aifg_ie_ptr cause; + aifg_ie_ptr lowLComp; + aifg_ie_ptr highLComp; +}aifg_msg_predecode_dt_modifyRej; + +typedef struct +{ + aifg_ie_ptr progressInd; + aifg_ie_ptr user_user; +}aifg_msg_predecode_dt_progress; + +typedef struct +{ + aifg_ie_ptr cause1; + aifg_ie_ptr cause2; + aifg_ie_ptr facility; + aifg_ie_ptr user_user; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_release; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr facility; + aifg_ie_ptr user_user; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_releaseComp; + +typedef struct +{ + aifg_ie_ptr reptInd_bc; + aifg_ie_ptr bearCap1; + aifg_ie_ptr bearCap2; + aifg_ie_ptr facility; + aifg_ie_ptr progressInd; + aifg_ie_ptr signal; + aifg_ie_ptr callingBCD; + aifg_ie_ptr callingSubaddr; + aifg_ie_ptr calledBCD; + aifg_ie_ptr calledSubaddr; + aifg_ie_ptr redirBCD; + aifg_ie_ptr redirSubaddr; + aifg_ie_ptr reptInd_llc; + aifg_ie_ptr lowLComp1; + aifg_ie_ptr lowLComp2; + aifg_ie_ptr reptInd_hlc; + aifg_ie_ptr highLComp1; + aifg_ie_ptr highLComp2; + aifg_ie_ptr user_user; + aifg_ie_ptr priority; + aifg_ie_ptr alert; + aifg_ie_ptr ssVer; + aifg_ie_ptr clirSuppr; + aifg_ie_ptr clirInvo; + aifg_ie_ptr ccCap; +}aifg_msg_predecode_dt_setup; + +typedef struct +{ + aifg_ie_ptr keypadFacility; +}aifg_msg_predecode_dt_startDTMF; + +typedef aifg_msg_predecode_dt_startDTMF aifg_msg_predecode_dt_startDTMFAck; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr callState; + aifg_ie_ptr auxState; +}aifg_msg_predecode_dt_status; + +typedef struct +{ + aifg_ie_ptr user_user; + aifg_ie_ptr moreDate; +}aifg_msg_predecode_dt_userInfo; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_dt_holdRej; + +typedef aifg_msg_predecode_dt_holdRej aifg_msg_predecode_dt_retieveRej; +typedef aifg_msg_predecode_dt_holdRej aifg_msg_predecode_dt_startDTMFRej; + +typedef struct +{ + aifg_ie_ptr notifyInd; +}aifg_msg_predecode_dt_notify; + +typedef struct +{ + aifg_ie_ptr cipherKeySeq; + aifg_ie_ptr cm2; + aifg_ie_ptr mobileId; +}aifg_msg_predecode_dt_pagingResp; + +typedef struct +{ + aifg_ie_ptr facility; +}aifg_msg_predecode_dt_facilitySS; + +typedef struct +{ + aifg_ie_ptr facility; + aifg_ie_ptr ssVer; +}aifg_msg_predecode_dt_register; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr facility; +}aifg_msg_predecode_dt_releaseCompSS; + +typedef struct{ + BYTE ref; + aifg_ie_ptr moAddr; + aifg_ie_ptr mtAddr; + aifg_ie_ptr data; +}aifg_msg_predecode_dt_rpData; + +typedef struct{ + BYTE ref; +}aifg_msg_predecode_dt_rpSMMA; + +typedef struct{ + BYTE ref; + aifg_ie_ptr data; +}aifg_msg_predecode_dt_rpAck; + +typedef struct{ + BYTE ref; + aifg_ie_ptr cause; + aifg_ie_ptr data; +}aifg_msg_predecode_dt_rpError; + +//BSSMAP +typedef struct +{ + BYTE id; //message id + union{ + aifg_msg_predecode_dt_LURequest luRequest; + aifg_msg_predecode_dt_cmReq cmRequest; + aifg_msg_predecode_dt_cmReEstReq cmReEstReq; + aifg_msg_predecode_dt_imsiDetachInd imsiDetachInd; + aifg_msg_predecode_dt_pagingResp pagingResp; + }msg; +}aifg_msg_predecode_l3msg; + +typedef struct +{ + aifg_ie_ptr channelType; + aifg_ie_ptr l3HeaderInfo; + aifg_ie_ptr priority; + aifg_ie_ptr cic; + aifg_ie_ptr dtxFlag; + aifg_ie_ptr bandUsed; + aifg_ie_ptr cmInfo2; + aifg_ie_ptr groupRef; + aifg_ie_ptr talkerFlag; + aifg_ie_ptr cfgEvoInd; +}aifg_msg_predecode_bm_assignReq; + + typedef struct + { + aifg_ie_ptr rrcause; + aifg_ie_ptr cic; + aifg_ie_ptr cellId; + aifg_ie_ptr chosenChannel; + aifg_ie_ptr chosenEncrypt; + aifg_ie_ptr circuitPool; + aifg_ie_ptr speechVer; + aifg_ie_ptr lsaId; + }aifg_msg_predecode_bm_assignComp; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr rrcause; + aifg_ie_ptr circuitPool; + aifg_ie_ptr circuitPoolList; +}aifg_msg_predecode_bm_assignFail; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cause; + aifg_ie_ptr connectionRelReq; +}aifg_msg_predecode_bm_block; + +typedef struct +{ + aifg_ie_ptr cic; +}aifg_msg_predecode_bm_blockAck; + +typedef aifg_msg_predecode_bm_blockAck aifg_msg_predecode_bm_unBlock; + +typedef aifg_msg_predecode_bm_blockAck aifg_msg_predecode_bm_unBlockAck; + +typedef struct +{ + aifg_ie_ptr channelType; + aifg_ie_ptr encryptInfo; + aifg_ie_ptr cmInfo1; + aifg_ie_ptr cmInfo2; + aifg_ie_ptr serving_cellId; + aifg_ie_ptr priority; + aifg_ie_ptr cic; + aifg_ie_ptr dtxFlag; + aifg_ie_ptr target_cellId; + aifg_ie_ptr bandUsed; + aifg_ie_ptr cause; + aifg_ie_ptr cmInfo3; + aifg_ie_ptr curChanneltype1; + aifg_ie_ptr speechVer; + aifg_ie_ptr groupCallRef; + aifg_ie_ptr talkerFlag; + aifg_ie_ptr cfgEvoInd; + aifg_ie_ptr chosenEncrypt; + aifg_ie_ptr oldBssToNew; + aifg_ie_ptr lsaInfo; +}aifg_msg_predecode_bm_HORequest; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr respReq; + aifg_ie_ptr cellIdList; + aifg_ie_ptr circuitPoolList; + aifg_ie_ptr curChannelType1; + aifg_ie_ptr speechVer; + aifg_ie_ptr queInd; + aifg_ie_ptr oldBssToNew; +}aifg_msg_predecode_bm_HORequired; + +typedef struct +{ + struct{ + BYTE *ptr; + BYTE len; + }l3Info; + aifg_ie_ptr chosenChannel; + aifg_ie_ptr chosenEncrypt; + aifg_ie_ptr circuitPool; + aifg_ie_ptr speechVer; + aifg_ie_ptr cic; + aifg_ie_ptr lsaId; +}aifg_msg_predecode_bm_HORequestAck; + +typedef struct +{ + aifg_msg_predecode_l3msg l3msg; + aifg_ie_ptr cellId; +}aifg_msg_predecode_bm_HOCmd; + +typedef struct +{ + aifg_ie_ptr rrcause; +}aifg_msg_predecode_bm_HOComp; + + +typedef struct +{ + aifg_ie_ptr msNum; + aifg_ie_ptr cellIdList; + aifg_ie_ptr cellId; +}aifg_msg_predecode_bm_HOCandEnq; + +typedef struct +{ + aifg_ie_ptr msNum; + aifg_ie_ptr cellId; +}aifg_msg_predecode_bm_HOCandResp; + +typedef aifg_msg_predecode_bm_assignFail aifg_msg_predecode_bm_HOFail; + +typedef struct +{ + aifg_ie_ptr periodicity; + aifg_ie_ptr resrcIndMethod; + aifg_ie_ptr cellId; + aifg_ie_ptr extResrcInd; +}aifg_msg_predecode_bm_resrcReq; + +typedef struct +{ + aifg_ie_ptr resrcIndMethod; + aifg_ie_ptr resrcAvail; + aifg_ie_ptr cellId; + aifg_ie_ptr totalResrc; +}aifg_msg_predecode_bm_resrcInd; + +typedef struct +{ + aifg_ie_ptr imsi; + aifg_ie_ptr tmsi; + aifg_ie_ptr cellIdList; + aifg_ie_ptr channelNeeded; + aifg_ie_ptr eMLPPpri; +}aifg_msg_predecode_bm_paging; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_clearReq; + +typedef struct +{ + aifg_ie_ptr l3HeaderInfo; + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_clearCmd; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_reset; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr cellId; + aifg_ie_ptr chosenChannel; + aifg_ie_ptr chosenEncrypt; + aifg_ie_ptr speechVer; + aifg_ie_ptr lsaId; +}aifg_msg_predecode_bm_HOPreformed; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr cellId; +}aifg_msg_predecode_bm_overload; + +typedef struct +{ + aifg_ie_ptr traceType; + aifg_ie_ptr triggerId; + aifg_ie_ptr traceRef; + aifg_ie_ptr transId; + aifg_ie_ptr mobileId; + aifg_ie_ptr omcId; +}aifg_msg_predecode_bm_mscInvokeTrace; + +typedef struct +{ + aifg_ie_ptr traceType; + aifg_ie_ptr forwardInd; + aifg_ie_ptr triggerId; + aifg_ie_ptr traceRef; + aifg_ie_ptr transId; + aifg_ie_ptr omcId; +}aifg_msg_predecode_bm_bscInvokeTrace; + +typedef struct +{ + aifg_ie_ptr cmInfo2; + aifg_ie_ptr cmInfo3; +}aifg_msg_predecode_bm_cmUpdate; + +typedef struct +{ + aifg_ie_ptr l3HeaderInfo; + aifg_ie_ptr encryptInfo; + aifg_ie_ptr cipherRespMode; +}aifg_msg_predecode_bm_cipherModeCmd; + +typedef struct +{ + aifg_ie_ptr l3MsgCont; + aifg_ie_ptr chosenEncrypt; +}aifg_msg_predecode_bm_cipherModeComp; + +typedef struct +{ + aifg_ie_ptr cellId; + aifg_msg_predecode_l3msg l3msg; + aifg_ie_ptr chosenChannel; + aifg_ie_ptr lsaIdList; + aifg_ie_ptr locInfo; +}aifg_msg_predecode_bm_completeL3Info; + +typedef struct +{ + aifg_ie_ptr dlci; + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_sapi_n_rej; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_HORequiredRej; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_resetCircuit; + +typedef struct +{ + aifg_ie_ptr cic; +}aifg_msg_predecode_bm_resetCircuitAck; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr cic; + aifg_ie_ptr cicList; +}aifg_msg_predecode_bm_circuitGrpBlk; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cicList; +}aifg_msg_predecode_bm_circuitGrpBlkAck; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cicList; +}aifg_msg_predecode_bm_circuitGrpUnblk; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cicList; +}aifg_msg_predecode_bm_circuitGrpUnblkAck; + +typedef struct +{ + aifg_ie_ptr cause; + aifg_ie_ptr diagnostics; +}aifg_msg_predecode_bm_confusion; + +typedef struct +{ + aifg_ie_ptr cic; + aifg_ie_ptr cicList; +}aifg_msg_predecode_bm_unequipCircuit; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_cipherModeRej; + +typedef struct +{ + aifg_ie_ptr timeInd; + aifg_ie_ptr cellId; + aifg_ie_ptr cellIdList; + aifg_ie_ptr resrcSit; + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_loadInd; + +typedef struct +{ + aifg_ie_ptr dlci; +}aifg_msg_predecode_bm_suspend; + +typedef struct +{ + aifg_ie_ptr dlci; +}aifg_msg_predecode_bm_resume; + +typedef struct +{ + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_changeCircuit; + +typedef struct +{ + aifg_ie_ptr circuitId; +}aifg_msg_predecode_bm_changeCircuitAck; + +typedef struct +{ + aifg_ie_ptr lsaInfo; +}aifg_msg_predecode_bm_lsaInfo; + +typedef struct +{ + aifg_ie_ptr locInfo; +}aifg_msg_predecode_bm_locInfoCmd; + +typedef struct +{ + aifg_ie_ptr locInfo; + aifg_ie_ptr cause; +}aifg_msg_predecode_bm_locInfoRep; + + +typedef struct{ + aifg_msg_id id; + int ti; //ti of the message. used only in dtap message + aifg_pd pd; //Protocol discriminator + int aif_port; + int app_port; //port number of upper layer application + int cause; //for release indication + int trace_flag; //0 - off, 1 - on + int tg_id; //trunk group id + + union{ + //BSSMAP + aifg_msg_predecode_bm_assignReq assignReq; //assign request + aifg_msg_predecode_bm_assignComp assignComplete; //assign complete + aifg_msg_predecode_bm_assignFail assignFailure; //assign failure + aifg_msg_predecode_bm_block block; //block + aifg_msg_predecode_bm_blockAck blockAck; //block ack + aifg_msg_predecode_bm_unBlock unblock; //unblock + aifg_msg_predecode_bm_unBlockAck unBlockAck; //unblock ack + aifg_msg_predecode_bm_HORequest HORequest; //Handover request + aifg_msg_predecode_bm_HORequired HORequired; //HANDOVER REQUIRED + aifg_msg_predecode_bm_HORequestAck HORequestAck; //Handover request ack + aifg_msg_predecode_bm_HOCmd HOCmd; //HANDOVER COMMAND + aifg_msg_predecode_bm_HOComp HOComplete; //HANDOVER COMPLETE + aifg_msg_predecode_bm_HOCandEnq HOCandEnq; //HANDOVER CANDIDATE ENQUIRE + aifg_msg_predecode_bm_HOCandResp HOCandResp; //HANDOVER CANDIDATE RESPONSE + aifg_msg_predecode_bm_HOFail HOFailure; //HANDOVER FAILURE + aifg_msg_predecode_bm_resrcReq resrcReq; //RESOURCE REQUEST + aifg_msg_predecode_bm_resrcInd resrcInd; //RESOURCE INDICATION + aifg_msg_predecode_bm_paging paging; //PAGING + aifg_msg_predecode_bm_clearReq clearReq; //CLEAR REQUEST + aifg_msg_predecode_bm_clearCmd clearCmd; //CLEAR COMMAND + aifg_msg_predecode_bm_reset reset; //RESET + aifg_msg_predecode_bm_HOPreformed HOPerformed; //HANDOVER PERFORMED + aifg_msg_predecode_bm_overload overload; //OVERLOAD + aifg_msg_predecode_bm_mscInvokeTrace mscTrace; //MSC INVOKE TRACE + aifg_msg_predecode_bm_bscInvokeTrace bscTrace; //BSC INVOKE TRACE + aifg_msg_predecode_bm_cmUpdate cmUpdate; //CLASSMARK UPDATE + aifg_msg_predecode_bm_cipherModeCmd cipherModeCmd; //CIPHER MODE COMMAND + aifg_msg_predecode_bm_cipherModeComp cipherModeComp; //CIPHER MODE COMPLETE + aifg_msg_predecode_bm_completeL3Info completeL3Info; //COMPLETE LAYER 3 INFORMATION + aifg_msg_predecode_bm_sapi_n_rej sapi_n_rej; //SAPI "n" REJECT + aifg_msg_predecode_bm_HORequiredRej HORequiredRej; //HANDOVER REQUIRED REJECT + aifg_msg_predecode_bm_resetCircuit resetCircuit; //RESET CIRCUIT + aifg_msg_predecode_bm_resetCircuitAck resetCircuitAck; //RESET CIRCUIT ACK + aifg_msg_predecode_bm_circuitGrpBlk ccGroupBlock; //CIRCUIT GROUP BLOCK + aifg_msg_predecode_bm_circuitGrpBlkAck ccGroupBlockAck; //CIRCUIT GROUP BLOCK ACK + aifg_msg_predecode_bm_circuitGrpUnblk ccGroupUnblock; //CIRCUIT GROUP UNBLOCK + aifg_msg_predecode_bm_circuitGrpUnblkAck ccGroupUnblockAck; //CIRCUIT GROUP UNBLOCK ACK + aifg_msg_predecode_bm_confusion confusion; //CONFUSION + aifg_msg_predecode_bm_unequipCircuit upequipCircuit; //UNEQUIPPED CIRCUIT + aifg_msg_predecode_bm_cipherModeRej cipherModeRej; //CIPHER MODE REJECT + aifg_msg_predecode_bm_loadInd loadInd; //LOAD INDICATION + aifg_msg_predecode_bm_suspend suspend; //SUSPEND + aifg_msg_predecode_bm_resume resume; //RESUME + aifg_msg_predecode_bm_changeCircuit changeCC; //CHANGE CIRCUIT + aifg_msg_predecode_bm_changeCircuitAck changeCCAck; //CHANGE CIRCUIT ACK + aifg_msg_predecode_bm_lsaInfo lsaInfo; //LSA INFORMATION + aifg_msg_predecode_bm_locInfoCmd locInfoCmd; //Location Information Command + aifg_msg_predecode_bm_locInfoRep locInfoReport; //Location Information Report + + //DTAP + aifg_msg_predecode_dt_authReq authReq; //Authentication request + aifg_msg_predecode_dt_authResp authResp; //Authentication response + aifg_msg_predecode_dt_cmReEstReq cmReEstReq; //CM Re-establishment request + aifg_msg_predecode_dt_cmRej cmRej; //CM service reject + aifg_msg_predecode_dt_abort abort; //Abort + aifg_msg_predecode_dt_cmReq cmReq; //CM service request + aifg_msg_predecode_dt_idReq idReq; //Identity request + aifg_msg_predecode_dt_idResp idResp; //Identity response + aifg_msg_predecode_dt_imsiDetachInd imsiDetach; //IMSI detach indication + aifg_msg_predecode_dt_luAccept luAccept; //Location updating accept + aifg_msg_predecode_dt_luReject luReject; //Location updating reject + aifg_msg_predecode_dt_LURequest luRequest; //Location updating request + aifg_msg_predecode_dt_mmInfo mmInfo; //MM information + aifg_msg_predecode_dt_mmStatus mmStatus; //MM Status + aifg_msg_predecode_dt_tmsiReallocCmd tmsiReallocCmd; //TMSI reallocation command + aifg_msg_predecode_dt_alert alert; //Alert + aifg_msg_predecode_dt_callConfirm callConfirm; //Call confirmed + aifg_msg_predecode_dt_callProceed callProceed; //Call proceeding + aifg_msg_predecode_dt_congestCtrl congestCtrl; //Congestion control + aifg_msg_predecode_dt_connect connect; //Connect + aifg_msg_predecode_dt_disconnect disconnect; //Disconnect + aifg_msg_predecode_dt_emergSetup eSetup; //Emergency Setup + aifg_msg_predecode_dt_facility facility; //Facility + aifg_msg_predecode_dt_holdRej holdRej; //Hold Reject + aifg_msg_predecode_dt_modify modify; //Modify + aifg_msg_predecode_dt_modifyComp modifyComplete; //Modify complete + aifg_msg_predecode_dt_modifyRej modifyRej; //Modify Reject + aifg_msg_predecode_dt_notify notify; //Notify + aifg_msg_predecode_dt_progress progress; //Progress + aifg_msg_predecode_dt_release release; //Release + aifg_msg_predecode_dt_releaseComp releaseComp; //Release complete + aifg_msg_predecode_dt_retieveRej retrieveRej; //Retrieve Reject + aifg_msg_predecode_dt_setup setup; //Setup + aifg_msg_predecode_dt_startDTMF startDTMF; //Start DTMF + aifg_msg_predecode_dt_startDTMFAck startDTMFAck; //Start DTMF Ack + aifg_msg_predecode_dt_startDTMFRej startDTMFRej; //Start DTMF Rej + aifg_msg_predecode_dt_status status; //Status + aifg_msg_predecode_dt_userInfo userInfo; //User information + aifg_msg_predecode_dt_facilitySS facilitySS; //Facility SS + aifg_msg_predecode_dt_register registerSS; //Register + aifg_msg_predecode_dt_releaseCompSS releaseCompSS; //Release complete SS + aifg_msg_predecode_dt_rpData rpData; //RP DATA + aifg_msg_predecode_dt_rpSMMA rpSMMA; //RP SMMA + aifg_msg_predecode_dt_rpAck rpAck; //RP ACK + aifg_msg_predecode_dt_rpError rpError; //RP ERROR + + //for transparently DTAP message transfer in BSC + struct { + BYTE *ptr; + BYTE len; + }dtap_msg; + }msg; +}aifg_msg_pre_decoded; + +#endif + diff --git a/omc/plat/aif/src/include/aifg_public.h b/omc/plat/aif/src/include/aifg_public.h new file mode 100644 index 0000000..457a07e --- /dev/null +++ b/omc/plat/aif/src/include/aifg_public.h @@ -0,0 +1,43 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_public.h +Description: Public definition of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-6 + +History: +2007-3-6 v9.0.0 Create +*********************************************************************/ +#ifndef _WXC2_AIFG_PUBLIC_H +#define _WXC2_AIFG_PUBLIC_H + +//Common include +#include +#include +#include +#include "../../../public/src/include/public.h" + +typedef enum _aifg_sap_type{ + AIFG_SAP_MSC, + AIFG_SAP_BSC +}aifg_sap_type; + +typedef enum _aifg_ni{ + AIFG_NI_INTERNATIONAL, + AIFG_NI_INTERNATIONAL_SPARE, + AIFG_NI_NATIONAL, + AIFG_NI_NATIONAL_SPARE, +}aifg_ni; + +typedef enum _aifg_run_mode{ + AIFG_RUN_MODE_SINGLE = 0, + AIFG_RUN_MODE_DUAL, +}aifg_run_mode; + +typedef enum _aifg_indication{ + AIFG_IND_RV_MSG, +}aifg_indication; + +#endif + diff --git a/omc/plat/aif/src/include/aifg_type_def.h b/omc/plat/aif/src/include/aifg_type_def.h new file mode 100644 index 0000000..05d1536 --- /dev/null +++ b/omc/plat/aif/src/include/aifg_type_def.h @@ -0,0 +1,445 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_type_def.h +Description: Data structure definition of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-12 + +History: +2007-3-6 v9.0.12 Create +*********************************************************************/ +#ifndef _WXC2_AIFG_TYPE_DEF_H +#define _WXC2_AIFG_TYPE_DEF_H + +#include "aifg_public.h" +#include "aifg_msg.h" +#include "../../../sccp/src/include/scoc_if.h" + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#define SCCP_SAP_AIFG 3 + +#define AIFG_PROC_FINISH 1 +#define AIFG_PROC_CONTINUE 0 + +#define AIFG_MAX_CG 256 +#define AIFG_MAX_SAP 2 +#define MSG_PROC_EACH_TIME 64 +#define AIFG_MAX_PORT 8192 +#define AIFG_MAX_MSG_LENGTH 256 +#define AIFG_MAX_TI_PER_LINK 16 +#define AIFG_MAX_MESSAGE 128 +#define SCCP_MAX_LINK 8192 + +typedef struct{ + int port; + BYTE *data_ptr; +}aifg_raw_msg; + +enum {AIFG_CG_AVAILABLE, AIFG_CG_UNAVAILABLE}; +typedef struct{ + BYTE enable; + int (*callback_func)(aifg_indication, aifg_msg_pre_decoded *); +}aifg_sap; + +typedef struct{ + BYTE mode; +}aifg_dual_server; + +typedef enum{ + AIFG_CG_STATE_DOWN, + AIFG_CG_STATE_UP, +}aifg_cg_state; + +//port status definition +typedef enum { + AIFG_PORT_IDLE, + AIFG_PORT_INIT, + AIFG_PORT_PAGING, + AIFG_PORT_RESET, + AIFG_PORT_TRANSACTION, + AIFG_PORT_TRANSPARENT, + AIFG_PORT_RELEASE, + AIFG_PORT_FINISH, +}AIFG_PORT_STATE; + +typedef enum{ + AIFG_TRANS_UNKNOW = -1, + AIFG_TRANS_LU = 1, + AIFG_TRANS_CC = AIFG_PD_DTAP_CC, //3 + AIFG_TRANS_SMS = AIFG_PD_DTAP_SMS, //9 + AIFG_TRANS_SS = AIFG_PD_DTAP_SS, //11 +}AIFG_TRANS_TYPE; + +typedef struct aifg_port_t{ + aifg_sap_type sapid; //SAP id + BYTE cgid; //circuit group id + int link_id; //link id + int new_link; //for handover, new link id to which the call will be handover to + int upper_port; //process port of upper layer + AIFG_PORT_STATE stat; //port status + int timer; //process timer + struct aifg_port_t *pNextOpenPort; //pointer to the next port in the opened port list + struct aifg_port_t *pPrevOpenPort; //pointer to the previous port in the opened port list + struct aifg_port_t *pNextPort; //pointer to the next port of the same BSSMAP transaction, such as paging/block + struct aifg_port_t *pPrevPort; //pointer to the previous port of the same BSSMAP transaction, such as paging/block + char ti; //TI value, including the TI flag + AIFG_TRANS_TYPE ti_type; //Transaction type of this port (CC/SS/SMS) + BYTE ti_stat; //Transaction status + BYTE rel_cause; //release cause + BYTE diagnostic[32]; //diagnostic for release + BYTE diag_len; //diagnostic length + BYTE imsi[16]; //associated mobile IMSI + BYTE imsi_len; //associated mobile IMSI length + BYTE ho_stat; //handover status + int app_ho_port; //application handover process port + SP_UiPriPara sd_buffer; //send message buffer, used in case when message re-send is needed + + BYTE app_rel_flag; //flag to indicate whether app is released + BYTE trace_flag; //for debug trace +#ifdef _AIFG_DEBUG_ + unsigned int dead_timer; //for resource leak checking +#endif +}aifg_port; + +//timer definition, second +#define T1S_MULTIPLIER 100 +enum{ + AIFG_TIMER_T2 = 3 * T1S_MULTIPLIER, //Reset guard period at the MSC + AIFG_TIMER_T13 = 3 * T1S_MULTIPLIER, //Reset guard period at the BSS + AIFG_TIMER_T14 = 60 * T1S_MULTIPLIER, //Time to receive RESET ACKNOWLEDGE at the BSS + AIFG_TIMER_T16 = 60 * T1S_MULTIPLIER, //Time to receive RESET ACKNOWLEDGE at the MSC + AIFG_TIMER_T3113 = 15 * T1S_MULTIPLIER, //Time to receive PAGING RESPONSE at MSC + AIFG_TIMER_REPAGE = 8 * T1S_MULTIPLIER, //Time to resend PAGING REQUEST at MSC + + AIFG_TIMER_TRANS_TIMEOUT = 120 * T1S_MULTIPLIER, //120s + AIFG_TIMER_CLEAR_TIMEOUT = 10 * T1S_MULTIPLIER, //10s + AIFG_TIMER_RELEASE_TIMEOUT = 10 * T1S_MULTIPLIER, //10s + AIFG_TIMER_WAIT_RELEASE_CMP = 50 //500ms +}; + +typedef struct{ + BYTE enable; + int dpc; + aifg_ni ni; + BYTE sapid; //SAP which owns this CG + int tgid; //MSC trunk group id +}aifg_circuit_group; + +typedef struct{ + BYTE en_flag; + BYTE cleared; //if the link was cleared, all the ports belongs to it will be released + aifg_sap_type sapid; //SAP which owns this link + + int cur_port; //in MSC:current activated local port + //in BSC:current activated upper port, for no AIFG local port need at BSC side + BYTE ti_number; //number of current activated ti, used at MSC side + BYTE next_ti; //TI value for next network initiate transaction + struct{ + BYTE en_flag; + BYTE tio; + int port; //corresponding port number + }ti[3][AIFG_MAX_TI_PER_LINK]; //0-7 is assigned by network, 8-15 is assigned by mobile, used at MSC side + //totally 3 types of TI according to different SAP: CC, SMS or SS +}aifg_link_info; +enum TI_TYPE{ + TI_FOR_CC, + TI_FOR_SMS, + TI_FOR_SS, +}; + +typedef enum{ + AIFG_SUCCEED = 0, + AIFG_ERROR = -1, + + //Error definition 1 ~ 1023 + AIFG_ERR_OUT_OF_RESOURCE = 1, + AIFG_ERR_UNKNOW_MSG, + AIFG_ERR_UNKNOW_IE, + AIFG_ERR_ERROR_MSG, + AIFG_ERR_ERROR_IE, + AIFG_ERR_UP_NOT_EXIST, + AIFG_ERR_NO_UD_IN_CR, + AIFG_ERR_UNEXPECTED_DT1, + AIFG_ERR_UNEXPECTED_UDT, + AIFG_ERR_UNEXPECTED_CC, + AIFG_ERR_OVERLOAD, + AIFG_ERR_CG_NOT_READY, + AIFG_ERR_UNEXPECTED_PAGING_RESP, + AIFG_ERR_INVALID_TI, + AIFG_ERR_MISS_MANDATORY, + AIFG_ERR_MSG_RV_TO_IDLE_PORT, + AIFG_ERR_MSG_SD_TO_IDLE_PORT, + AIFG_ERR_ASSIGN_PORT_FAIL, + AIFG_ERR_SAP_NOT_CREATED, + AIFG_ERR_PORT_TIMER_OUT, + AIFG_ERR_CAN_NOT_FIND_TI, + AIFG_ERR_PAGING_NOT_RESP, + AIFG_ERR_PORT_RELEASED, + + //event definition 1024 ~ 2048 + AIFG_EVENT_SD_MSG = 1024, //Message sent to sccp + AIFG_EVENT_RV_MSG, //Message received from sccp + AIFG_EVENT_SD_IND, //Indication sent to upper app + AIFG_EVENT_RV_REQ, //Request received from upper app + AIFG_EVENT_REDIR_MSG, //Message redirected + AIFG_EVENT_CG_UP, //Circuit come up + AIFG_EVENT_LINK_RELEASE, //Link release + AIFG_EVENT_PORT_RELEASE, +}aifg_event_code; + +typedef enum{ + //DTAP + //RR + AIFG_MSG_T_PAGING_RESP = 0x27, //Paging response + AIFG_MSG_T_RR_HO_CMD = 0x2B, //RR Handover command + + //MM + AIFG_MSG_T_IMSI_DETACH_IND = 0x01, //IMSI detach indication + AIFG_MSG_T_LU_ACCEPT = 0x02, //Location updating accept + AIFG_MSG_T_LU_REJECT = 0x04, //Location updating reject + AIFG_MSG_T_LU_REQUEST = 0x08, //Location updating request + AIFG_MSG_T_AUTH_REJECT = 0x11, //Authentication reject + AIFG_MSG_T_AUTH_REQUEST = 0x12, //Authentication request + AIFG_MSG_T_AUTH_RESPONSE = 0x14, //Authentication response + AIFG_MSG_T_ID_REQUEST = 0x18, //Identity request + AIFG_MSG_T_ID_RESPONSE = 0x19, //Identity response + AIFG_MSG_T_TMSI_REALLOC_CMD = 0x1A, //TMSI reallocation command + AIFG_MSG_T_TMSI_REALLOC_CMP = 0x1B, //TMSI reallocation complete + AIFG_MSG_T_CM_ACCEPT = 0x21, //CM service accept + AIFG_MSG_T_CM_REJECT = 0x22, //CM service reject + AIFG_MSG_T_CM_ABORT = 0x23, //CM service abort + AIFG_MSG_T_CM_REQUEST = 0x24, //CM service request + AIFG_MSG_T_CM_PROMPT = 0x25, //CM service prompt + AIFG_MSG_T_CM_REEST_REQUEST = 0x28, //CM re-establishment request + AIFG_MSG_T_ABORT = 0x29, //Abort + AIFG_MSG_T_MM_NULL = 0x30, //MM NULL + AIFG_MSG_T_MM_STATUS = 0x31, //MM status + AIFG_MSG_T_MM_INFO = 0x32, //MM information + + //CC + AIFG_MSG_T_ALERTING = 0x01, //Alerting + AIFG_MSG_T_CALL_CONFIRMED = 0x08, //Call confirmed + AIFG_MSG_T_CALL_PROCEEDING = 0x02, //Call proceeding + AIFG_MSG_T_CONNECT = 0x07, //Connect + AIFG_MSG_T_CONNECT_ACK = 0x0F, //Connect ack + AIFG_MSG_T_EMERGENCY_SETUP = 0x0E, //Emergency setup + AIFG_MSG_T_PROGRESS = 0x03, //Progress + AIFG_MSG_T_SETUP = 0x05, //Setup + AIFG_MSG_T_MODIFY = 0x17, //Modify + AIFG_MSG_T_MODIFY_CMP = 0x1F, //Modify complete + AIFG_MSG_T_MODIFY_REJECT = 0x13, //Modify reject + AIFG_MSG_T_USER_INFO = 0x10, //User information + AIFG_MSG_T_HOLD = 0x18, //Hold + AIFG_MSG_T_HOLD_ACK = 0x19, //Hold ack + AIFG_MSG_T_HOLD_REJECT = 0x1A, //Hold reject + AIFG_MSG_T_RETRIEVE = 0x1C, //Retrieve + AIFG_MSG_T_RETRIEVE_ACK = 0x1D, //Retrieve ack + AIFG_MSG_T_RETRIEVE_REJECT = 0x1E, //Retrieve reject + AIFG_MSG_T_DISCONNECT = 0x25, //Disconnect + AIFG_MSG_T_RELEASE = 0x2D, //Release + AIFG_MSG_T_RELEASE_CMP = 0x2A, //Release complete + AIFG_MSG_T_CONGESTION_CTRL = 0x39, //Congestion control + AIFG_MSG_T_NOTIFY = 0x3E, //Notify + AIFG_MSG_T_STATUS = 0x3D, //Status + AIFG_MSG_T_STATUS_ENQ = 0x34, //Status enquiry + AIFG_MSG_T_START_DTMF = 0x35, //Start DTMF + AIFG_MSG_T_STOP_DTMF = 0x31, //Stop DTMF + AIFG_MSG_T_STOP_DTMF_ACK = 0x32, //Stop DTMF ack + AIFG_MSG_T_START_DTMF_ACK = 0x36, //Start DTMF ack + AIFG_MSG_T_START_DTMF_REJECT = 0x37, //Start DTMF reject + AIFG_MSG_T_FACILITY = 0x3A, //Facility + + //SMS + AIFG_MSG_T_CP_DATA = 0x01, //CP-DATA + AIFG_MSG_T_CP_ACK = 0x04, //CP-ACK + AIFG_MSG_T_CP_ERROR = 0x10, //CP-ERRPR + + AIFG_MSG_T_RP_DATA_MS = 0x00, //RP-DATA MS side + AIFG_MSG_T_RP_ACK_MS = 0x02, //RP-ACK MS side + AIFG_MSG_T_RP_ERROR_MS = 0x04, //RP-ERRPR MS side + AIFG_MSG_T_RP_SMMA = 0x06, //RP-SMMA MS side + AIFG_MSG_T_RP_DATA_NW = 0x01, //RP-DATA network side + AIFG_MSG_T_RP_ACK_NW = 0x03, //RP-ACK network side + AIFG_MSG_T_RP_ERROR_NW = 0x05, //RP-ERRPR network side + + //SS + AIFG_MSG_T_FACILITY_SS = 0x3A, //Facility SS + AIFG_MSG_T_REGISTER = 0x3B, //Register + AIFG_MSG_T_RELEASE_CMP_SS = 0x2A, //Release complete SS + + //BSSMAP + AIFG_MSG_T_ASSIGN_REQ = 0x01, //Assign request + AIFG_MSG_T_ASSIGN_CMP = 0x02, //Assign complete + AIFG_MSG_T_ASSIGN_FAIL = 0x03, //Assign failure + AIFG_MSG_T_HO_REQUEST = 0x10, //Handover request + AIFG_MSG_T_HO_REQUIRED = 0x11, //Handover required + AIFG_MSG_T_HO_REQ_ACK = 0x12, //Handover request ack + AIFG_MSG_T_HO_CMD = 0x13, //Handover command + AIFG_MSG_T_HO_CMP = 0x14, //Handover complete + AIFG_MSG_T_HO_SUC = 0x15, //Handover succeeded + AIFG_MSG_T_HO_FAIL = 0x16, //Handover failure + AIFG_MSG_T_HO_PERFORMED = 0x17, //Handover performed + AIFG_MSG_T_HO_CAN_ENQ = 0x18, //Handover candidate enquire + AIFG_MSG_T_HO_CAN_RESP = 0x19, //Handover candidate response + AIFG_MSG_T_HO_REQ_REJ = 0x1A, //Handover required reject + AIFG_MSG_T_HO_DETECT = 0x1B, //Handover detect + AIFG_MSG_T_CLR_CMD = 0x20, //Clear command + AIFG_MSG_T_CLR_CMP = 0x21, //Clear complete + AIFG_MSG_T_CLR_REQ = 0x22, //Clear request + AIFG_MSG_T_SAPI_REJ = 0x25, //SAPI 'n' reject + AIFG_MSG_T_CONFUSION = 0x26, //Confusion + AIFG_MSG_T_SUSPEND = 0x28, //Suspend + AIFG_MSG_T_RESUME = 0x29, //Resume + AIFG_MSG_T_LOC_INFO_CMD = 0x2A, //Location information command + AIFG_MSG_T_LOC_INFO_RPT = 0x2B, //Location information report + AIFG_MSG_T_RESET = 0x30, //Reset + AIFG_MSG_T_RESET_ACK = 0x31, //Reset ack + AIFG_MSG_T_OVERLOAD = 0x32, //Overload + AIFG_MSG_T_RESET_CC = 0x34, //Reset circuit + AIFG_MSG_T_RESET_CC_ACK = 0x35, //Reset circuit ack + AIFG_MSG_T_MSC_INVK_TRACE = 0x36, //MSC invoke trace + AIFG_MSG_T_BSC_INVK_TRACE = 0x37, //BSC invoke trace + AIFG_MSG_T_BLOCK = 0x40, //Block + AIFG_MSG_T_BLOCK_ACK = 0x41, //Blocking ack + AIFG_MSG_T_UNBLOCK = 0x42, //Unblock + AIFG_MSG_T_UNBLOCK_ACK = 0x43, //Unblocking ack + AIFG_MSG_T_CC_GROUP_BLK = 0x44, //Circuit group block + AIFG_MSG_T_CC_GROUP_BLK_ACK = 0x45, //Circuit group block ack + AIFG_MSG_T_CC_GROUP_UNBLK = 0x46, //Circuit group unblock + AIFG_MSG_T_CC_GROUP_UNBLK_ACK = 0x47, //Circuit group unblock ack + AIFG_MSG_T_UNEQUIP_CC = 0x48, //Unequipped circuit + AIFG_MSG_T_CHANGE_CC = 0x4E, //Change circuit + AIFG_MSG_T_CHANGE_CC_ACK = 0x4F, //Change circuit ack + AIFG_MSG_T_RESRC_REQ = 0x50, //Resource request + AIFG_MSG_T_RESRC_IND = 0x51, //Resource indication + AIFG_MSG_T_PAGING = 0x52, //Paging + AIFG_MSG_T_CIPHER_MODE_CMD = 0x53, //Cipher mode command + AIFG_MSG_T_CM_UPDATE = 0x54, //Classmark update + AIFG_MSG_T_CIPHER_MODE_CMP = 0x55, //Cipher mode complete + AIFG_MSG_T_QUEUE_IND = 0x56, //Queuing indication + AIFG_MSG_T_L3_INFO = 0x57, //Complete layer 3 information + AIFG_MSG_T_CLASSMARK_REQ = 0x58, //Classmark request + AIFG_MSG_T_CIPHER_MODE_REJ = 0x59, //Cipher mode reject + AIFG_MSG_T_LOAD_IND = 0x5A, //Load indication +}aifg_msg_type; + +typedef enum _aifg_iei_coding{ + //For BSSMAP + AIFG_IEI_BM_CIC = 0x01, //CIC + AIFG_IEI_BM_RESOURCEAVAIL = 0x03, //Resource available + AIFG_IEI_BM_CAUSE = 0x04, //Cause + AIFG_IEI_BM_CELLID = 0x05, //Cell identifier + AIFG_IEI_BM_PRIORITY = 0x06, //Priority + AIFG_IEI_BM_L3HEADERINFO = 0x07, //Layer 3 header information + AIFG_IEI_BM_IMSI = 0x08, //IMSI + AIFG_IEI_BM_TMSI = 0x09, //TMSI + AIFG_IEI_BM_ENCRYPTINFO = 0x0A, //Encrypt information + AIFG_IEI_BM_CHANNELTYPE = 0x0B, //Channel type + AIFG_IEI_BM_PERIODICITY = 0x0C, //Periodicity + AIFG_IEI_BM_EXTRESOURCEIND = 0x0D, //Extended resource indicator + AIFG_IEI_BM_MSNUM = 0x0E, //Number of MSs + AIFG_IEI_BM_CLASSMARKINFO2 = 0x12, //Classmark information type 2 + AIFG_IEI_BM_CLASSMARKINFO3 = 0x13, //Classmark information type 3 + AIFG_IEI_BM_BANDUSED = 0x14, //Band to be used + AIFG_IEI_BM_RRCAUSE = 0x15, //RR cause + AIFG_IEI_BM_L3INFO = 0x17, //Layer 3 information + AIFG_IEI_BM_DLCI = 0x18, //DLCI + AIFG_IEI_BM_DTXFLAG = 0x19, //DTC flag + AIFG_IEI_BM_CELLIDLIST = 0x1A, //Cell identity list + AIFG_IEI_BM_RESPREQ = 0x1B, //Response request + AIFG_IEI_BM_RESOURCEINDMEHTOD = 0x1C, //Resource indication method + AIFG_IEI_BM_CLASSMARKINFO1 = 0x1D, //Classmark information type 1 + AIFG_IEI_BM_CICLIST = 0x1E, //CIC list + AIFG_IEI_BM_DIGNOSTIC = 0x1F, //Dignostic + AIFG_IEI_BM_L3MSGCONTENT = 0x20, //Layer 3 message content + AIFG_IEI_BM_CHOSENCHANNEL = 0x21, //Chosen channel + AIFG_IEI_BM_TOTALRESOURCE = 0x22, //Total resource accessible + AIFG_IEI_BM_CIPHERRESPMODE = 0x23, //Cipher response mode + AIFG_IEI_BM_CHANNELNEEDED = 0x24, //Channel needed + AIFG_IEI_BM_TRACETYPE = 0x25, //Trace type + AIFG_IEI_BM_TRIGGERID = 0x26, //Trigger ID + AIFG_IEI_BM_TRACEREF = 0x27, //Trace reference + AIFG_IEI_BM_TRANSACTIONID = 0x28, //Transaction ID + AIFG_IEI_BM_MOBILEID = 0x29, //Mobile identity + AIFG_IEI_BM_OMCID = 0x2A, //OMC ID + AIFG_IEI_BM_FORWARDIND = 0x2B, //Forward indication + AIFG_IEI_BM_CHOSENENCRYPT = 0x2C, //Chosen encrypt algorithm + AIFG_IEI_BM_CIRCUITPOOL = 0x2D, //Circuit pool + AIFG_IEI_BM_CIRCUITPOOLLIST = 0x2E, //Circuit pool list + AIFG_IEI_BM_TIMEIND = 0x2F, //Time indicator + AIFG_IEI_BM_RESOURCESITUATION = 0x30, //Resource situation + AIFG_IEI_BM_CURCHANNELTYPE1 = 0x31, //Current channel type 1 + AIFG_IEI_BM_QUEUEIND = 0x32, //Queuing indicator + AIFG_IEI_BM_ASSIGNREQUIREMENT = 0x33, //Assignment requirement + AIFG_IEI_BM_TALKERFLAG = 0x34, //Talker flag + AIFG_IEI_BM_CONNRELREQ = 0x35, //Connection release request + AIFG_IEI_BM_GROUPCALLREF = 0x36, //Group call reference + AIFG_IEI_BM_EMLPP = 0x37, //eMLPP + AIFG_IEI_BM_CFGEVOIND = 0x38, //Configuration evolution indication + AIFG_IEI_BM_BSSOLDTONEW = 0x39, //Old BSS to new BSS + AIFG_IEI_BM_LSAID = 0x3A, //LSA identity + AIFG_IEI_BM_LSAIDLIST = 0x3B, //LSA identity list + AIFG_IEI_BM_LSAINFO = 0x3C, //LSA information + AIFG_IEI_BM_LOCATIONINFO = 0x3D, //Location information + AIFG_IEI_BM_SPEECHVER = 0x40, //Speech version + + //For DTAP + //common + AIFG_IEI_DT_LAI = 0x13, //location area identification + AIFG_IEI_DT_MOBILEID = 0x17, //mobile identity + AIFG_IEI_DT_MSCM3 = 0x20, //mobile station classmark 3 + //MM + AIFG_IEI_DT_FLONPROCEED = 0xa1, //Follow on proceed + AIFG_IEI_DT_CTS = 0xa2, //CTS permission + AIFG_IEI_DT_FULL_NWNAME = 0x43, //Full name for network + AIFG_IEI_DT_SHORT_NWNAME = 0x45, //Short name for network + AIFG_IEI_DT_TIMEZONE = 0x46, //Network time zone + AIFG_IEI_DT_TZTIME = 0x47, //Universal time and time zone + AIFG_IEI_DT_LSAID = 0x48, //LSA Identity + //CC + AIFG_IEI_DT_PRIORITYLEVEL = 0x80, //Priority Level + AIFG_IEI_DT_SHIFT = 0x90, //Locking and non-locking shift procedure + AIFG_IEI_DT_REPEATIND = 0xD0, //Repease indicator + AIFG_IEI_DT_MOREDATA = 0xA0, //More data + AIFG_IEI_DT_CLIRSUP = 0xA1, //CLIR Suppression + AIFG_IEI_DT_CLIRIVO = 0xA2, //CLIR Invocation + AIFG_IEI_DT_REVCALLDIR = 0xA3, //Reverse call setup direction + AIFG_IEI_DT_BEARERCAP = 0x04, //Bearer capability + AIFG_IEI_DT_CAUSE = 0x08, //Cause + AIFG_IEI_DT_CCCAP = 0x15, //Call Control Capabilities + AIFG_IEI_DT_FACILITY = 0x1C, //Facility + AIFG_IEI_DT_PROGIND = 0x1E, //Progress indicator + AIFG_IEI_DT_AUXSTAT = 0x24, //Auxiliary states + AIFG_IEI_DT_CALLEDBCD = 0x5E, //Called party BCD + AIFG_IEI_DT_CALLEDSUBADDR = 0x6D, //Called party subaddress + AIFG_IEI_DT_CALLERBCD = 0x5C, //Calling party BCD + AIFG_IEI_DT_CALLERSUBADDR = 0x5D, //Calling party subaddress + AIFG_IEI_DT_CONNNUM = 0x4C, //Connected number + AIFG_IEI_DT_CONNSUBADDR = 0x4D, //Connected subaddress + AIFG_IEI_DT_HIGHCOM = 0x7D, //Higher layer compatibility + AIFG_IEI_DT_KEYPAD = 0x2C, //Keypad facility + AIFG_IEI_DT_LOWCOM = 0x7C, //Lower layer compatibility + AIFG_IEI_DT_REDIRBCD = 0x74, //Redirecting party BCD + AIFG_IEI_DT_REDIRSUBADDR = 0x75, //Redirecting party subaddress + AIFG_IEI_DT_SIGNAL = 0x34, //Signal + AIFG_IEI_DT_SSVER = 0x7F, //SS version indicator + AIFG_IEI_DT_USERUSER = 0x7E, //User-user + AIFG_IEI_DT_ALERTPATTERN = 0x19, //Alert pattern + //SMS + AIFG_IEI_DT_RP_UD = 0x41, //RP User data + AIFG_IEI_DT_RP_CAUSE = 0x42, //RP Cause +}aifg_iei; + +#endif diff --git a/omc/plat/aif/src/include/aifg_var_ext.h b/omc/plat/aif/src/include/aifg_var_ext.h new file mode 100644 index 0000000..f013386 --- /dev/null +++ b/omc/plat/aif/src/include/aifg_var_ext.h @@ -0,0 +1,68 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_var_ext.h +Description: Public variant definition of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-12 + +History: +2007-3-6 v9.0.12 Create +*********************************************************************/ +#ifndef _WXC2_AIFG_VAR_EXT_H +#define _WXC2_AIFG_VAR_EXT_H +#include +#include "aifg_type_def.h" + +//Variant declaration +extern aifg_circuit_group cg[AIFG_MAX_CG]; +extern aifg_sap sap[AIFG_MAX_SAP]; +extern aifg_dual_server dual_server; +extern aifg_port aifg_pcb[AIFG_MAX_PORT]; +extern aifg_event_code aifg_event; +extern aifg_msg_t sd_msg; +aifg_msg_pre_decoded rv_msg; +extern int cur_port; //current processing port +extern aifg_link_info link_info[SCCP_MAX_LINK]; + +extern int msg_statistics[AIFG_MAX_MESSAGE][2]; + +int aifg_ie_encode(aifg_msg_protocol protocol, int ie_id, ie_u *src, BYTE *dst, int m_o_flag); +int aifg_ie_decode(aifg_ie_ptr *src, aifg_ie *dst); +int aifg_msgtype_to_localid(aifg_pd pd, int msg_type); + +int aifg_send_cr(int sapid, int cgid, aifg_msg_t *msg); +void aifg_send_dt1(int linkid, aifg_msg_t *msg, int ti); +void aifg_send_udt(int cgid, aifg_msg_t *msg, SP_UiPriPara *buf_ptr); + +void aifg_mpp_init(); +int aifg_mpp_proc(); + +void aifg_port_proc(aifg_port *pPort, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg); +inline int aifg_port_assign(int sapid, int cgid, int linkid); +inline void aifg_port_release(aifg_port *pPort); +inline int aifg_get_local_port(int u_port); +inline int aifg_get_paging_port(int cgid, BYTE *imsi_ptr, int imsi_len); +inline int aifg_ti2lport(int ti, int link_id, int pd); + +inline int aifg_get_link(int u_port); +inline int aifg_add_link(int linkid, int sapid); +inline int aifg_del_link(int sccp_link_id); +inline void aifg_link_release(int link_id); +inline aifg_link_info *aifg_get_link_info(int link_id); + +inline int aifg_get_cg(int dpc, int ni); + +inline void aifg_add_ti(int link_id, int ti, int ti_type, int port); +inline int aifg_get_ti(int link_id, int port, int ti_type); +inline int aifg_del_ti(int link_id, int ti, int ti_type); + +void aifg_send_rlsd(int linkid); + +void aifg_debug_init(); +void aifg_debug_timer(); +void aifg_debug_print(int port, aifg_event_code event, void *msg, int o_info); + +void aifg_log(char *info); +#endif + diff --git a/omc/plat/aif/ut/.copyarea.db b/omc/plat/aif/ut/.copyarea.db new file mode 100644 index 0000000..1b1791c --- /dev/null +++ b/omc/plat/aif/ut/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\aif\ut +2 +3 +8:makefile|1|11d70a3e0a9|2f4|19f1d7f0|b9a968abbfa411dc84f1001c23e19543|0 +b:aifg_test.c|1|11d70a3e07a|3d275|fa91da6e|b7e96873bfa411dc84f1001c23e19543|0 +b:aifg_main.c|1|11d70a3e02c|103|bf8d4d3c|b7496857bfa411dc84f1001c23e19543|0 diff --git a/omc/plat/aif/ut/aifg_main.c b/omc/plat/aif/ut/aifg_main.c new file mode 100644 index 0000000..6096297 --- /dev/null +++ b/omc/plat/aif/ut/aifg_main.c @@ -0,0 +1,23 @@ +/* +*Test program of AIFG module --by Roy Jiang +*/ +#include "../src/include/aifg.h" +#include "../src/include/aifg_if.h" + +void aifg_test(); + +int main() +{ + printf("Test of AIFG\n"); + + aifg_test(); + +#ifdef _WINDOWS_ + system("PAUSE"); +#endif + + return 0; +} + + + diff --git a/omc/plat/aif/ut/aifg_test.c b/omc/plat/aif/ut/aifg_test.c new file mode 100644 index 0000000..fe75159 --- /dev/null +++ b/omc/plat/aif/ut/aifg_test.c @@ -0,0 +1,7083 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: aifg_m.c +Description: Test case of AIFG module +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-3-12 +Remark: CUnit is used for manageing the test cases + +History: +2007-3-12 v9.0.0 Create +*********************************************************************/ +//Header files of CUnit +#ifdef _WINDOWS_ +#include "Basic.h" +#include "Console.h" +#include "Automated.h" +#else +#include "/usr/local/include/CUnit/Basic.h" +#include "/usr/local/include/CUnit/Console.h" +#include "/usr/local/include/CUnit/Automated.h" +#endif + +//Header files of AIFG module +#include "../src/include/aifg.h" +#include "../src/include/aifg_if.h" +#include "../src/include/aifg_var_ext.h" + +/* +All the test cases share the same return value: 0-fail, 1-success +*/ +#define TEST_FAIL 0 +#define TEST_SUCCESS 1 + +//function declearation +int aifg_code_test(); +int aifg_unit_test(); +//Message process functions declearation--------------------------------------------- +int aifg_msg_proc(BYTE *src, aifg_msg_pre_decoded *dst); +int aifg_msg_decode_assignReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_assignComplete(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_assignFailure(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_block(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_blockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HORequest(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HORequired(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HORequestAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOComplete(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOCandEnq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOCandResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOFailure(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_resrcReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_resrcInd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_paging(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_clearReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_clearCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HOPerformed(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_overload(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_mscTrace(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_bscTrace(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cmUpdate(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cipherModeCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cipherModeComp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_completeL3Info(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_sapi_n_rej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_HORequiredRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_resetCircuit(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_ccGroupBlock(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_ccGroupBlockAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_confusion(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_loadInd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_suspend(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_lsaInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_locInfoCmd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_locInfoReport(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_resetCircuitAck(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +/////////////dtap////////////////////// +int aifg_msg_decode_authReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_authResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cmReEstReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cmRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_cmReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_idReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_idResp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_imsiDetachInd(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_locAccept(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_locReq(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_mmInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_tmsiRealloc(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_alert(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_callConfirm(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_callProceed(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_congestCtrl(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_connect(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_disconnect(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_eSetup(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_facility(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_holdRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_modify(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_modifyRej(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_notify(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_progress(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_release(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_releaseComp(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_setup(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_startDTMF(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_status(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_decode_userInfo(BYTE *src, aifg_msg_pre_decoded *dst, BYTE msg_len); +int aifg_msg_sd_assignReq(aifg_msg_t * src, BYTE * dst); + +//Test entrance +void aifg_test() +{ + printf("\nStarting Code Test--------------------------------------------\n"); + aifg_code_test(); + printf("\nCode Test Completed-------------------------------------------\n"); + printf("\nStarting Unit Test--------------------------------------------\n"); + aifg_unit_test(); + printf("\nUnit Test Completed-------------------------------------------\n"); + return; +} + +aifg_msg_t bm_completeL3; +aifg_msg_t dt_cmAccept; +aifg_msg_t bm_clearReq; +aifg_msg_t bm_clearCmd; +aifg_msg_t bm_clearComplete; +aifg_msg_t bm_paging; +aifg_msg_t bm_setup; +aifg_msg_t rr_pagingResp; +aifg_msg_t dt_callCfm; + + +static BYTE src[][64]={//source with out iei +///////// BSSMAP //////////////////////// + {0x01,0x02}, //CIC + {0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x02,0x06,0x00,0x0b}, //resrouce available + {0x01,0x09} , //cause + {0x02,0x89,0x10}, //cause_extent + {0x08,0x00,0x13,0x42,0x05,0x00,0x02,0x00,0x11}, //cellId with discriminator==0x00 + {0x05,0x01,0x00,0x42,0x01,0x03}, //cellId with discriminator==0x01 + {0x03,0x02,0x00,0x22}, //cellId with discriminator==0x02 + {0x01,0x76}, //priority + {0X02,0X08,0X02}, //L3HeaderInfo + {0x04,0xf7,0x03,0x12,0x2a}, //tmsi redefintion,out of use + {0x01,0x01}, //encryptInfo with no encryption + {0x09,0x12,0x08,0x15,0x34,0x67,0xa2,0x8d,0x46,0x8f}, //encryption with A5 + {0X04,0X01,0X09,0X83,0X79}, //channelType with speech indicator + {0x04,0x02,0x0a,0xf5,0x07}, //channelType with data indicator + {0x02}, //extResourceInd + {0x03,0x7e,0x67,0x82}, //cmInfo2 + {0x04,0x05,0x21,0x3f,0x58,0xe1}, //l3Info + {0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05}, //cidList with discriminator==0x00 + {0x05,0x01,0x23,0x07,0x4f,0x39}, //cidList with discriminator==0x01 + {0x03,0x02,0x77,0x64}, //cidList with discriminator==0x02 + {0x06,0x04,0x4e,0x39,0x58,0x7c,0x0a}, //cidList with discriminator==0x04 + {0x03,0x05,0x21,0xf3}, //cidList with discriminator==0x05 + {0x04,0x32,0x12,0x8d,0x36}, //cicList + {0x04,0x03,0x0a,0x38,0x89}, //diagnostics + {0x56}, //chosenChannel + {0x84,0x62,0xf2,0x7e}, //totalResrc + {0x03,0x9d,0x20,0x81}, //triggerId + {0x02,0x31,0xf2}, //mobileId,type of identity==001(IMSI),odd/even indicator==0(even) + {0x05,0x01,0x02,0x03,0x04,0x05}, //circuitPoolList + {0x05,0x11,0x83,0x04,0x28,0x75}, //resrcSit,band1 with SDCCH,band2 with Full Rate TCH + {0x19}, //curChannelType1 with speech mode and Half rate TCH + {0x05,0x24,0x38,0x56,0x19,0x10}, //groupRef,sf(VGCS),af(required),call_priority(level4),cipher_info(key1) + {0x03,0x10,0x39,0xd2}, //lsaId + {0x07,0x01,0x22,0xe4,0x31,0x57,0x69,0x83}, //lsaIdList with Ep==1 + {0x09,0x00,0x00,0x36,0x85,0xef,0x03,0x47,0x87,0x42}, //lsaInfo + {0x03,0x15,0x49,0xf5}, //locInfo + {0x03,0x39,0xc4,0x08}, //omcId + {0X07, 0xdd,0X01,0X02,0xdd ,0X02,0X06,0X01},//bssOldtoNew,UNCOMPLETED !FIELD ELEMENT{ExtraInfo:prec=0,lcs=1;curChanType2:data14.5kb/s,SDCCH} + {0Xff}, //periodicity + {0Xfe}, //msNum + {0x09}, //bandUsed + {0X08}, //rrCouse + {0XC2}, //dlci,channel is SACCH + {0x01}, //dtx, MSC forbids the BSS to activate DTX in the downlink direction + {0X01}, //resrcIdMethod,method ii is selected + {0X00}, //cipherRespMode,IMEISV must not be included by the Mobile Station + {0X02}, //channelNeeded,TCH/F (Full rate) + {0xdd}, //traceType + {0x34,0x97}, //traceRef + {0x02,0x17,0x62}, //transId + {0x02}, //forwardInd,forward to subsequent BSS, and trace at MSC + {0X03}, //chosenEncrypt,GSM A5/2 + {0X10}, //circuitPool,Circuit pool number 16 + {0X11}, //timeInd,170s + {0X21}, //speechVer,GSM speech full rate version 3 + {0X02}, //queuingInd,it is recommended to allow queuing + {0X01}, //assignReq,Immediate + {0X06}, //eMLPP,call priority level B + {0x03}, //configInd,Modification is allowed and maximum number of TCH/F is 3 + {0X04,0X33,0X79,0X27,0X46}, //tmsi +///////////// DTAP /////////////////////////////////////////// + {0x10,0x34,0x78,0x69,0x20}, //broadcastRef,vbs,ackRequired,priority4,cipher NO.2 + {0x11}, //cmInfo1,Reserved for phase 1,"CECS"implemented in MS,A5/1 available,Class2 + {0x03,0x33,0x22,0x8d}, //cmInfo2 + {0x02,0x73,0xf2}, //mobileId,even flag,IMEISV + {0x78,0xf3,0x64,0x31,0x02}, //LocId + {0x09}, //luType,iei=0,Follow-on request pending,Periodic updating + {0x03,0x91,0x35,0x64}, //nwName,bit8 set to "0" in octet n,no add letters,UCS2 (16 bit) [72] + {0x07,0x04,0x12,0x0a,0x32,0x14,0xdd}, //tzTime + {0x02,0xc0,0x82}, //progInd,National standard,User,Destination address in non-PLMN/ISDN + {0x03,0x01,0x19,0x83}, //uu,OSI high layer protocols + {0x02,0x20,0x02}, //bc with info_trans_cap==0,only octet 3a is extend + {0x0d,0xa3,0xca,0x1a,0x00,0xe4,0x21,0x53,0x5b,0x60,0x21,0x5f,0x47,0xc6}, //bc with info_trans_cap!=0 + {0x04,0x47,0xdd,0x96,0x81}, //cause,National standard,international network,Number changed + {0x01,0x03}, //ccCap + {0x04,0x28,0xa3,0x89,0x37}, //connNum/callingNum/calledNum/redirNum + {0x03,0x88,0x50,0x43}, //connSubAddr/callingSubAddr/calledSubAddr/redirSubAddr + {0x01,0xdd}, //ssVer + {0x03,0xa8,0x6e,0xb4}, //hiComp + {0x02,0xdd,0xde}, //loComp + {0xc2}, //callStat + {0x01,0x86}, //auxStat + {0x03,0x11,0x22,0x33}, //lsaId + {0X02}, //rejectCause + {0X0B}, //cmType + {0X01}, //cipherKey + {0X05}, //priority + {0X03}, //idType + {0X0F}, //congestLevel + {0x80}, //notificationInd + {0x08}, //signal + {0X01,0X07}, //alertPattern + {0X0D}, //keypad + {0XDD}, //timeZone + {0X00,0X11,0X22,0X33,0X44,0X55,0X66,0X77,0X88,0X99,0XAA,0XBB,0XCC,0XDD,0XEE,0XFF}, //authRAND + {0X11,0X12,0X13,0X14}, //authSRES + {0X01}, //rpInd + {0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00}//facility +}; + +static aifg_ie dst; +static int len; +static aifg_msg_protocol protocol; +static aifg_ie_ptr ie; +static BYTE buffer[256]; +aifg_msg_predecode_l3msg predecode_l3msg; +aifg_msg_bm_l3msg l3Info; + +void test_aifg_ie_bm_cic() +{ + + //preconditon + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CIC; + ie.ptr=src[0]; + + + //test decode + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CIC,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(8,dst.param.bm_cic.pcm); + CU_ASSERT_EQUAL(2,dst.param.bm_cic.timeslot); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CIC,&(dst.param),buffer, 0); + //check encode result + CU_ASSERT_EQUAL(AIFG_IEI_BM_CIC,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&(buffer[1]),src[0],2)); + +} +void test_aifg_ie_bm_resrcAvail() +{ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_RESOURCEAVAIL; + ie.ptr=src[1]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_RESOURCEAVAIL,dst.iei); + //CU_ASSERT_EQUAL(21,len); + CU_ASSERT_EQUAL(9,dst.param.bm_resrcAvail.full_rate_channel[0]); + CU_ASSERT_EQUAL(259,dst.param.bm_resrcAvail.half_rate_channel[0]); + CU_ASSERT_EQUAL(9,dst.param.bm_resrcAvail.full_rate_channel[1]); + CU_ASSERT_EQUAL(259,dst.param.bm_resrcAvail.half_rate_channel[1]); + CU_ASSERT_EQUAL(9,dst.param.bm_resrcAvail.full_rate_channel[2]); + CU_ASSERT_EQUAL(259,dst.param.bm_resrcAvail.half_rate_channel[2]); + CU_ASSERT_EQUAL(9,dst.param.bm_resrcAvail.full_rate_channel[3]); + CU_ASSERT_EQUAL(259,dst.param.bm_resrcAvail.half_rate_channel[3]); + CU_ASSERT_EQUAL(518,dst.param.bm_resrcAvail.full_rate_channel[4]); + CU_ASSERT_EQUAL(11,dst.param.bm_resrcAvail.half_rate_channel[4]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_RESOURCEAVAIL,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_RESOURCEAVAIL,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[1],20)); +} +void test_aifg_ie_bm_cause(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CAUSE; + ie.ptr=src[2]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CAUSE,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(9,dst.param.bm_cause.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CAUSE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CAUSE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[2],2)); + + } + +void test_aifg_ie_bm_cause_ext() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CAUSE; + ie.ptr=src[3]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CAUSE,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(9,dst.param.bm_cause.value); + CU_ASSERT_EQUAL(1,dst.param.bm_cause.ext_value.flag); + CU_ASSERT_EQUAL(16,dst.param.bm_cause.ext_value.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CAUSE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CAUSE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[3],3)); + +} + +void test_aifg_ie_bm_cellId_00() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLID; + ie.ptr=src[4]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(0,dst.param.bm_cellId.discriminator); + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLID,dst.iei); + //CU_ASSERT_EQUAL(10,len); + CU_ASSERT_EQUAL(3,dst.param.bm_cellId.mcc[0]); + CU_ASSERT_EQUAL(1,dst.param.bm_cellId.mcc[1]); + CU_ASSERT_EQUAL(2,dst.param.bm_cellId.mcc[2]); + CU_ASSERT_EQUAL(4,dst.param.bm_cellId.mnc[2]); + CU_ASSERT_EQUAL(0,dst.param.bm_cellId.mnc[1]); + CU_ASSERT_EQUAL(5,dst.param.bm_cellId.mnc[0]); + CU_ASSERT_EQUAL(2,dst.param.bm_cellId.LAC); + CU_ASSERT_EQUAL(17,dst.param.bm_cellId.CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[4],9)); +} + +void test_aifg_ie_bm_cellId_01() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLID; + ie.ptr=src[5]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(1,dst.param.bm_cellId.discriminator); + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLID,dst.iei); + //CU_ASSERT_EQUAL(7,len); + CU_ASSERT_EQUAL(66,dst.param.bm_cellId.LAC); + CU_ASSERT_EQUAL(259,dst.param.bm_cellId.CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[5],6)); +} + +void test_aifg_ie_bm_cellId_02(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLID; + ie.ptr=src[6]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(2,dst.param.bm_cellId.discriminator); + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLID,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(34,dst.param.bm_cellId.CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[6],4)); + } +void test_aifg_ie_bm_priority(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_PRIORITY; + ie.ptr=src[7]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_PRIORITY,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(1,dst.param.bm_priority.pci); + CU_ASSERT_EQUAL(13,dst.param.bm_priority.level); + CU_ASSERT_EQUAL(1,dst.param.bm_priority.qa); + CU_ASSERT_EQUAL(0,dst.param.bm_priority.pvi); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_PRIORITY,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_PRIORITY,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[7],2)); + } +void test_aifg_ie_bm_L3HeaderInfo(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_L3HEADERINFO; + ie.ptr=src[8]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_L3HEADERINFO,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(8,dst.param.bm_L3HeaderInfo.pd); + CU_ASSERT_EQUAL(2,dst.param.bm_L3HeaderInfo.ti); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_L3HEADERINFO,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_L3HEADERINFO,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[8],3)); + } +/*void test_aifg_ie_bm_tmsi(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + iei=AIFG_IE_ID_BM_TMSI; + + //test + len=aifg_ie_decode(protocol,iei,src[9],&dst,hi_lo_flag); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TMSI,dst.iei); + CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0xf7,dst.param.bm_tmsi[0]); + CU_ASSERT_EQUAL(0x03,dst.param.bm_tmsi[1]); + CU_ASSERT_EQUAL(0x12,dst.param.bm_tmsi[2]); + CU_ASSERT_EQUAL(0x2a,dst.param.bm_tmsi[3]); + }*///redefinition +void test_aifg_ie_bm_encryptInfo_NOencryption(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_ENCRYPTINFO; + ie.ptr=src[10]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_ENCRYPTINFO,dst.iei); +//CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_encryptInfo.algorithm); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_ENCRYPTINFO,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_ENCRYPTINFO,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[10],2)); + + } +void test_aifg_ie_bm_encryptInfo_A5(){ + + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_ENCRYPTINFO; + ie.ptr=src[11]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_ENCRYPTINFO,dst.iei); + //CU_ASSERT_EQUAL(11,len); + CU_ASSERT_EQUAL(0x12,dst.param.bm_encryptInfo.algorithm); + CU_ASSERT_EQUAL(0x08,dst.param.bm_encryptInfo.key[0]); + CU_ASSERT_EQUAL(0x15,dst.param.bm_encryptInfo.key[1]); + CU_ASSERT_EQUAL(0x34,dst.param.bm_encryptInfo.key[2]); + CU_ASSERT_EQUAL(0x67,dst.param.bm_encryptInfo.key[3]); + CU_ASSERT_EQUAL(0xa2,dst.param.bm_encryptInfo.key[4]); + CU_ASSERT_EQUAL(0x8d,dst.param.bm_encryptInfo.key[5]); + CU_ASSERT_EQUAL(0x46,dst.param.bm_encryptInfo.key[6]); + CU_ASSERT_EQUAL(0x8f,dst.param.bm_encryptInfo.key[7]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_ENCRYPTINFO,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_ENCRYPTINFO,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[11],10)); + } + +void test_aifg_ie_bm_channelType_speech() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CHANNELTYPE; + ie.ptr=src[12]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CHANNELTYPE,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_channelType.speech_data_ind); + CU_ASSERT_EQUAL(0x09,dst.param.bm_channelType.channel_rate_type); + CU_ASSERT_EQUAL(0x03,dst.param.bm_channelType.ext.speech.ver[0]); + CU_ASSERT_EQUAL(0x79,dst.param.bm_channelType.ext.speech.ver[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CHANNELTYPE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CHANNELTYPE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[12],5)); +} + +void test_aifg_ie_bm_channelType_data() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CHANNELTYPE; + ie.ptr=src[13]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CHANNELTYPE,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x02,dst.param.bm_channelType.speech_data_ind); + CU_ASSERT_EQUAL(0x0a,dst.param.bm_channelType.channel_rate_type); + CU_ASSERT_EQUAL(0x01,dst.param.bm_channelType.ext.data_cfg.t_nt); + CU_ASSERT_EQUAL(0x35,dst.param.bm_channelType.ext.data_cfg.rate); + CU_ASSERT_EQUAL(0x07,dst.param.bm_channelType.ext.data_cfg.allowed_data_rate.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CHANNELTYPE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CHANNELTYPE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[13],5)); +} +void test_aifg_ie_bm_extResourceInd() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_EXTRESOURCEIND; + ie.ptr=src[14]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_EXTRESOURCEIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_extResrcInd.sm); + CU_ASSERT_EQUAL(0x00,dst.param.bm_extResrcInd.tarr); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_EXTRESOURCEIND,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_EXTRESOURCEIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[14],1)); +} +void test_aifg_ie_bm_cmInfo2() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CLASSMARKINFO2; + ie.ptr=src[15]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CLASSMARKINFO2,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x03,dst.param.bm_cmInfo2.rev_level); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.es_ind); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.a5_1); + CU_ASSERT_EQUAL(0x06,dst.param.bm_cmInfo2.rf_power_cap); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.ps_cap); + CU_ASSERT_EQUAL(0x02,dst.param.bm_cmInfo2.ss_screen_ind); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.sm_cap); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.vbs); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.vgcs); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.fc); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.cm3); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.lcsva_cap); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.so_lsa); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.cmsp); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.a5_3); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.a5_2); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CLASSMARKINFO2,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CLASSMARKINFO2,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[15],4)); +} + +/*void test_aifg_ie_bm_l3Info(){ //to resolve + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_L3INFO; + ie.ptr=src[16]; + //test + len=aifg_ie_decode(protocol,&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_L3INFO,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(AIFG_MSG_T_CM_ACCEPT,dst.param.bm_l3Info.l3_msg->type); + }*/ + +void test_aifg_ie_bm_cidList_00() //discriminator==0x00 +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLIDLIST; + ie.ptr=src[17]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLIDLIST,dst.iei); + //CU_ASSERT_EQUAL(10,len); + CU_ASSERT_EQUAL(0,dst.param.bm_cellIdList.discriminator); + CU_ASSERT_EQUAL(5,dst.param.bm_cellIdList.cell_id[0].mcc[0]); + CU_ASSERT_EQUAL(8,dst.param.bm_cellIdList.cell_id[0].mcc[1]); + CU_ASSERT_EQUAL(7,dst.param.bm_cellIdList.cell_id[0].mcc[2]); + CU_ASSERT_EQUAL(12,dst.param.bm_cellIdList.cell_id[0].mnc[0]); + CU_ASSERT_EQUAL(9,dst.param.bm_cellIdList.cell_id[0].mnc[1]); + CU_ASSERT_EQUAL(4,dst.param.bm_cellIdList.cell_id[0].mnc[2]); + CU_ASSERT_EQUAL(0x6724,dst.param.bm_cellIdList.cell_id[0].LAC); + CU_ASSERT_EQUAL(0x3d05,dst.param.bm_cellIdList.cell_id[0].CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[17],9)); +} + +void test_aifg_ie_bm_cidList_01()//discriminator==0x01 +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLIDLIST; + ie.ptr=src[18]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLIDLIST,dst.iei); + //CU_ASSERT_EQUAL(7,len); + CU_ASSERT_EQUAL(1,dst.param.bm_cellIdList.discriminator); + CU_ASSERT_EQUAL(0x2307,dst.param.bm_cellIdList.cell_id[0].LAC); + CU_ASSERT_EQUAL(0x4f39,dst.param.bm_cellIdList.cell_id[0].CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[18],6)); +} + +void test_aifg_ie_bm_cidList_02()//discriminator==0x02 +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLIDLIST; + ie.ptr=src[19]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLIDLIST,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(2,dst.param.bm_cellIdList.discriminator); + CU_ASSERT_EQUAL(0x7764,dst.param.bm_cellIdList.cell_id[0].CI); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[19],4)); +} + +void test_aifg_ie_bm_cidList_04() //discriminator==0x04 +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLIDLIST; + ie.ptr=src[20]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLIDLIST,dst.iei); + //CU_ASSERT_EQUAL(8,len); + CU_ASSERT_EQUAL(4,dst.param.bm_cellIdList.discriminator); + CU_ASSERT_EQUAL(14,dst.param.bm_cellIdList.cell_id[0].mcc[0]); + CU_ASSERT_EQUAL(4,dst.param.bm_cellIdList.cell_id[0].mcc[1]); + CU_ASSERT_EQUAL(9,dst.param.bm_cellIdList.cell_id[0].mcc[2]); + CU_ASSERT_EQUAL(3,dst.param.bm_cellIdList.cell_id[0].mnc[2]); + CU_ASSERT_EQUAL(5,dst.param.bm_cellIdList.cell_id[0].mnc[1]); + CU_ASSERT_EQUAL(8,dst.param.bm_cellIdList.cell_id[0].mnc[0]); + CU_ASSERT_EQUAL(0x7c0a,dst.param.bm_cellIdList.cell_id[0].LAC); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[20],7)); +} + +void test_aifg_ie_bm_cidList_05() //discriminator==0x05 +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CELLIDLIST; + ie.ptr=src[21]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CELLIDLIST,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(5,dst.param.bm_cellIdList.discriminator); + CU_ASSERT_EQUAL(0x21f3,dst.param.bm_cellIdList.cell_id[0].LAC); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CELLIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CELLIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[21],4)); +} + +void test_aifg_ie_bm_cicList() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CICLIST; + ie.ptr=src[22]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CICLIST,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x32,dst.param.bm_cicList.range); + CU_ASSERT_EQUAL(3,dst.param.bm_cicList.status.len); + CU_ASSERT_EQUAL(0x12,dst.param.bm_cicList.status.content[0]); + CU_ASSERT_EQUAL(0x8d,dst.param.bm_cicList.status.content[1]); + CU_ASSERT_EQUAL(0x36,dst.param.bm_cicList.status.content[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CICLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CICLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[22],5)); +} + +void test_aifg_ie_bm_diagnostics(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_DIGNOSTIC; + ie.ptr=src[23]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_DIGNOSTIC,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x03,dst.param.bm_diagnostics.err_pointer); + CU_ASSERT_EQUAL(0x0a,dst.param.bm_diagnostics.bit_pointer); + CU_ASSERT_EQUAL(2,dst.param.bm_diagnostics.err_msg.len); + CU_ASSERT_EQUAL(0x38,dst.param.bm_diagnostics.err_msg.msg[0]); + CU_ASSERT_EQUAL(0x89,dst.param.bm_diagnostics.err_msg.msg[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_DIGNOSTIC,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_DIGNOSTIC,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[23],5)); + } +void test_aifg_ie_bm_chosenChannel() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CHOSENCHANNEL; + ie.ptr=src[24]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CHOSENCHANNEL,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x05,dst.param.bm_chosenChannel.mode); + CU_ASSERT_EQUAL(0x06,dst.param.bm_chosenChannel.channel); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CHOSENCHANNEL,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CHOSENCHANNEL,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[24],1)); +} + +void test_aifg_ie_bm_totalResrc() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TOTALRESOURCE; + ie.ptr=src[25]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TOTALRESOURCE,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x8462,dst.param.bm_totalResrc.full_rate_channel); + CU_ASSERT_EQUAL(0xf27e,dst.param.bm_totalResrc.half_rate_channel); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TOTALRESOURCE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TOTALRESOURCE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[25],4)); +} + +void test_aifg_ie_bm_triggerId() +{ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TRIGGERID; + ie.ptr=src[26]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TRIGGERID,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(3,dst.param.bm_triggerId.len); + CU_ASSERT_EQUAL(0x9d,dst.param.bm_triggerId.content[0]); + CU_ASSERT_EQUAL(0x20,dst.param.bm_triggerId.content[1]); + CU_ASSERT_EQUAL(0x81,dst.param.bm_triggerId.content[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TRIGGERID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TRIGGERID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[26],4)); +} + +void test_aifg_ie_bm_mobileId(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_MOBILEID; + ie.ptr=src[27]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_MOBILEID,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(1,dst.param.mobileId.type); + CU_ASSERT_EQUAL(0,dst.param.mobileId.odd_even_flag); + CU_ASSERT_EQUAL(2,dst.param.mobileId.id_len); + CU_ASSERT_EQUAL(0x03,dst.param.mobileId.id[0]); + CU_ASSERT_EQUAL(0x02,dst.param.mobileId.id[1]); + CU_ASSERT_EQUAL(0x0f,dst.param.mobileId.id[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_MOBILEID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_MOBILEID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[27],3)); + } +void test_aifg_ie_bm_circuitPoolList(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CIRCUITPOOLLIST; + ie.ptr=src[28]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CIRCUITPOOLLIST,dst.iei); + //CU_ASSERT_EQUAL(7,len); + CU_ASSERT_EQUAL(5,dst.param.bm_circuitPoolList.num); + CU_ASSERT_EQUAL(0x01,dst.param.bm_circuitPoolList.circuit[0]); + CU_ASSERT_EQUAL(0x02,dst.param.bm_circuitPoolList.circuit[1]); + CU_ASSERT_EQUAL(0x03,dst.param.bm_circuitPoolList.circuit[2]); + CU_ASSERT_EQUAL(0x04,dst.param.bm_circuitPoolList.circuit[3]); + CU_ASSERT_EQUAL(0x05,dst.param.bm_circuitPoolList.circuit[4]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CIRCUITPOOLLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CIRCUITPOOLLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[28],6)); + + } +void test_aifg_ie_bm_resrcSit(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_RESOURCESITUATION; + ie.ptr=src[29]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_RESOURCESITUATION,dst.iei); + //CU_ASSERT_EQUAL(7,len); + CU_ASSERT_EQUAL(1,dst.param.bm_resrcSit.band[0].band_ind); + CU_ASSERT_EQUAL(1,dst.param.bm_resrcSit.band[0].channel_type); + CU_ASSERT_EQUAL(0x0304,dst.param.bm_resrcSit.band[0].channel_num); + CU_ASSERT_EQUAL(2,dst.param.bm_resrcSit.band[1].band_ind); + CU_ASSERT_EQUAL(8,dst.param.bm_resrcSit.band[1].channel_type); + CU_ASSERT_EQUAL(0x75,dst.param.bm_resrcSit.band[1].channel_num); + CU_ASSERT_EQUAL(2,dst.param.bm_resrcSit.band_num); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_RESOURCESITUATION,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_RESOURCESITUATION,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[29],6)); + } +void test_aifg_ie_bm_curChannelType1(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CURCHANNELTYPE1; + ie.ptr=src[30]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CURCHANNELTYPE1,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(1,dst.param.bm_curChannelType1.channel_mode); + CU_ASSERT_EQUAL(9,dst.param.bm_curChannelType1.channel); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CURCHANNELTYPE1,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CURCHANNELTYPE1,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[30],1)); + } +void test_aifg_ie_bm_groupRef(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_GROUPCALLREF; + ie.ptr=src[31]; + //test + len=aifg_ie_decode(&ie,&dst); + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_GROUPCALLREF,dst.iei); + //CU_ASSERT_EQUAL(7,len); + CU_ASSERT_EQUAL(0x121c2b0,dst.param.bm_groupRef.binary_code); + CU_ASSERT_EQUAL(1,dst.param.bm_groupRef.sf); + CU_ASSERT_EQUAL(1,dst.param.bm_groupRef.af); + CU_ASSERT_EQUAL(1,dst.param.bm_groupRef.call_priority); + CU_ASSERT_EQUAL(1,dst.param.bm_groupRef.cipher_info); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_GROUPCALLREF,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_GROUPCALLREF,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[31],6)); + } +void test_aifg_ie_bm_lsaId(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_LSAID; + ie.ptr=src[32]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_LSAID,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x10,dst.param.bm_lsaId.value[0]); + CU_ASSERT_EQUAL(0x39,dst.param.bm_lsaId.value[1]); + CU_ASSERT_EQUAL(0xd2,dst.param.bm_lsaId.value[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_LSAID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_LSAID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[32],4)); + } +void test_aifg_ie_bm_lsaIdList(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_LSAIDLIST; + ie.ptr=src[33]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_LSAIDLIST,dst.iei); + //CU_ASSERT_EQUAL(9,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_lsaIdList.ep); + CU_ASSERT_EQUAL(0x22,dst.param.bm_lsaIdList.list[0].id[0]); + CU_ASSERT_EQUAL(0xe4,dst.param.bm_lsaIdList.list[0].id[1]); + CU_ASSERT_EQUAL(0x31,dst.param.bm_lsaIdList.list[0].id[2]); + CU_ASSERT_EQUAL(0x57,dst.param.bm_lsaIdList.list[1].id[0]); + CU_ASSERT_EQUAL(0x69,dst.param.bm_lsaIdList.list[1].id[1]); + CU_ASSERT_EQUAL(0x83,dst.param.bm_lsaIdList.list[1].id[2]); + CU_ASSERT_EQUAL(2,dst.param.bm_lsaIdList.lsa_num); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_LSAIDLIST,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_LSAIDLIST,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[33],8)); + } +void test_aifg_ie_bm_lsaInfo(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_LSAINFO; + ie.ptr=src[34]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_LSAINFO,dst.iei); + //CU_ASSERT_EQUAL(11,len); + CU_ASSERT_EQUAL(0,dst.param.bm_lsaInfo.lsa_only); + CU_ASSERT_EQUAL(2,dst.param.bm_lsaInfo.lsa_num); + CU_ASSERT_EQUAL(0x00,dst.param.bm_lsaInfo.info[0].priority); + CU_ASSERT_EQUAL(0x36,dst.param.bm_lsaInfo.info[0].id[0]); + CU_ASSERT_EQUAL(0x85,dst.param.bm_lsaInfo.info[0].id[1]); + CU_ASSERT_EQUAL(0xef,dst.param.bm_lsaInfo.info[0].id[2]); + CU_ASSERT_EQUAL(0x03,dst.param.bm_lsaInfo.info[1].priority); + CU_ASSERT_EQUAL(0x47,dst.param.bm_lsaInfo.info[1].id[0]); + CU_ASSERT_EQUAL(0x87,dst.param.bm_lsaInfo.info[1].id[1]); + CU_ASSERT_EQUAL(0x42,dst.param.bm_lsaInfo.info[1].id[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_LSAINFO,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_LSAINFO,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[34],10)); + } +void test_aifg_ie_bm_locInfo(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_LOCATIONINFO; + ie.ptr=src[35]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_LOCATIONINFO,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(3,dst.param.bm_locInfo.len); + CU_ASSERT_EQUAL(0x15,dst.param.bm_locInfo.info[0]); + CU_ASSERT_EQUAL(0x49,dst.param.bm_locInfo.info[1]); + CU_ASSERT_EQUAL(0xf5,dst.param.bm_locInfo.info[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_LOCATIONINFO,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_LOCATIONINFO,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[35],4)); + } +void test_aifg_ie_bm_omcId(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_OMCID; + ie.ptr=src[36]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_OMCID,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(3,dst.param.bm_omcId.len); + CU_ASSERT_EQUAL(0x39,dst.param.bm_omcId.id[0]); + CU_ASSERT_EQUAL(0xc4,dst.param.bm_omcId.id[1]); + CU_ASSERT_EQUAL(0x08,dst.param.bm_omcId.id[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_OMCID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_OMCID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[36],4)); + } +void test_aifg_ie_bm_bssOldtoNew(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_BSSOLDTONEW; + ie.ptr=src[37]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_BSSOLDTONEW,dst.iei); + //CU_ASSERT_EQUAL(9,len); + CU_ASSERT_EQUAL(7,dst.param.bm_bssOldtoNew.len); + CU_ASSERT_EQUAL(0xdd,dst.param.bm_bssOldtoNew.content[0]); + CU_ASSERT_EQUAL(0x01,dst.param.bm_bssOldtoNew.content[1]); + CU_ASSERT_EQUAL(0x02,dst.param.bm_bssOldtoNew.content[2]); + CU_ASSERT_EQUAL(0xdd,dst.param.bm_bssOldtoNew.content[3]); + CU_ASSERT_EQUAL(0x02,dst.param.bm_bssOldtoNew.content[4]); + CU_ASSERT_EQUAL(0x06,dst.param.bm_bssOldtoNew.content[5]); + CU_ASSERT_EQUAL(0x01,dst.param.bm_bssOldtoNew.content[6]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_BSSOLDTONEW,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_BSSOLDTONEW,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[37],8)); + } +void test_aifg_ie_bm_periodicity(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_PERIODICITY; + ie.ptr=src[38]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_PERIODICITY,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(255,dst.param.bm_periodicity.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_PERIODICITY,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_PERIODICITY,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[38],1)); + } +void test_aifg_ie_bm_msNum(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_MSNUM; + ie.ptr=src[39]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_MSNUM,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(254,dst.param.bm_msNum.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_MSNUM,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_MSNUM,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[39],1)); + } +void test_aifg_ie_bm_bandUsed(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_BANDUSED; + ie.ptr=src[40]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_BANDUSED,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x09,dst.param.bm_bandUsed.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_BANDUSED,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_BANDUSED,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[40],1)); + } +void test_aifg_ie_bm_rrCause(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_RRCAUSE; + ie.ptr=src[41]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_RRCAUSE,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x08,dst.param.bm_rrCause.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_RRCAUSE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_RRCAUSE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[41],1)); + } +void test_aifg_ie_bm_dlci(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_DLCI; + ie.ptr=src[42]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_DLCI,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0xC2,dst.param.bm_dlci.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_DLCI,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_DLCI,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[42],1)); + } +void test_aifg_ie_bm_dtx(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_DTXFLAG; + ie.ptr=src[43]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_DTXFLAG,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_dtx.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_DTXFLAG,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_DTXFLAG,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[43],1)); + } +void test_aifg_ie_bm_resrcIndMethod(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_RESOURCEINDMEHTOD; + ie.ptr=src[44]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_RESOURCEINDMEHTOD,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_resrcIndMethod.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_RESOURCEINDMEHTOD,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_RESOURCEINDMEHTOD,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[44],1)); + } +void test_aifg_ie_bm_cipherRespMode(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CIPHERRESPMODE; + ie.ptr=src[45]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CIPHERRESPMODE,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cipherRespMode.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CIPHERRESPMODE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CIPHERRESPMODE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[45],1)); + } +void test_aifg_ie_bm_channelNeeded(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CHANNELNEEDED; + ie.ptr=src[46]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CHANNELNEEDED,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x02,dst.param.bm_channelNeeded.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CHANNELNEEDED,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CHANNELNEEDED,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[46],1)); + } +void test_aifg_ie_bm_traceType(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TRACETYPE; + ie.ptr=src[47]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TRACETYPE,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0xdd,dst.param.bm_traceType.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TRACETYPE,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TRACETYPE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[47],1)); + } +void test_aifg_ie_bm_traceRef(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TRACEREF; + ie.ptr=src[48]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TRACEREF,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(0x3497,dst.param.bm_traceRef.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TRACEREF,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TRACEREF,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[48],1)); + } +void test_aifg_ie_bm_transId(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TRANSACTIONID; + ie.ptr=src[49]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TRANSACTIONID,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(0x1762,dst.param.bm_transId.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TRANSACTIONID,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TRANSACTIONID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[49],3)); + } +void test_aifg_ie_bm_fowardInd(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_FORWARDIND; + ie.ptr=src[50]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_FORWARDIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x02,dst.param.bm_fowardInd.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_FORWARDIND,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_FORWARDIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[50],1)); + } +void test_aifg_ie_bm_chosenEncrypt(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CHOSENENCRYPT; + ie.ptr=src[51]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CHOSENENCRYPT,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x03,dst.param.bm_chosenEncrypt.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CHOSENENCRYPT,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CHOSENENCRYPT,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[51],1)); + } +void test_aifg_ie_bm_circuitPool(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CIRCUITPOOL; + ie.ptr=src[52]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CIRCUITPOOL,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x10,dst.param.bm_circuitPool.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CIRCUITPOOL,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CIRCUITPOOL,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[52],1)); + } +void test_aifg_ie_bm_timeInd(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TIMEIND; + ie.ptr=src[53]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TIMEIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x11,dst.param.bm_timeId.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TIMEIND,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TIMEIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[53],1)); + } +void test_aifg_ie_bm_speechVer(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_SPEECHVER; + ie.ptr=src[54]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_SPEECHVER,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x21,dst.param.bm_speechVer.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_SPEECHVER,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_SPEECHVER,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[54],1)); + } +void test_aifg_ie_bm_queuingInd(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_QUEUEIND; + ie.ptr=src[55]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_QUEUEIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(1,dst.param.bm_queuingInd.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_QUEUEIND,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_QUEUEIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[55],1)); + } +void test_aifg_ie_bm_assignReq(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_ASSIGNREQUIREMENT; + ie.ptr=src[56]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_ASSIGNREQUIREMENT,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(1,dst.param.bm_assignReq.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_ASSIGNREQUIREMENT,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_ASSIGNREQUIREMENT,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[56],1)); + } +void test_aifg_ie_bm_eMLPP(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_EMLPP; + ie.ptr=src[57]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_EMLPP,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(6,dst.param.bm_eMLPP.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_EMLPP,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_EMLPP,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[57],1)); + } +void test_aifg_ie_bm_configInd(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_CFGEVOIND; + ie.ptr=src[58]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_CFGEVOIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(3,dst.param.bm_cfgEvoInd.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_CFGEVOIND,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_CFGEVOIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[58],1)); + } +void test_aifg_ie_bm_tmsi(){ + //precondition + protocol=AIFG_MSG_BSSMAP; + ie.iei=AIFG_IE_ID_BM_TMSI; + ie.ptr=src[59]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_BM_TMSI,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x33,dst.param.bm_tmsi.value[0]); + CU_ASSERT_EQUAL(0x79,dst.param.bm_tmsi.value[1]); + CU_ASSERT_EQUAL(0x27,dst.param.bm_tmsi.value[2]); + CU_ASSERT_EQUAL(0x46,dst.param.bm_tmsi.value[3]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_BM_TMSI,&(dst.param),buffer, 0); + CU_ASSERT_EQUAL(AIFG_IEI_BM_TMSI,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[59],5)); + } + +///////////////////////// DTAP //////////////////////////////// + +void test_aifg_ie_dt_broadcastRef(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_GROUPREF; + ie.ptr=src[60]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_GROUPREF,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x81a3c3,dst.param.dt_broadcastRef.binary_code); + CU_ASSERT_EQUAL(0,dst.param.dt_broadcastRef.sf); + CU_ASSERT_EQUAL(1,dst.param.dt_broadcastRef.af); + CU_ASSERT_EQUAL(1,dst.param.dt_broadcastRef.call_priority); + CU_ASSERT_EQUAL(2,dst.param.dt_broadcastRef.cipher_info); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_GROUPREF,&(dst.param),buffer, 0); + // CU_ASSERT_EQUAL(AIFG_IEI_DT_GROUPREF,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[60],5)); + } +void test_aifg_ie_dt_cmInfo1(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_MSCM1; + ie.ptr=src[61]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_MSCM1,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0,dst.param.dt_cmInfo1.rev_level); + CU_ASSERT_EQUAL(1,dst.param.dt_cmInfo1.es_ind); + CU_ASSERT_EQUAL(0,dst.param.dt_cmInfo1.a5_1); + CU_ASSERT_EQUAL(1,dst.param.dt_cmInfo1.rf_power_cap); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_MSCM1,&(dst.param),buffer, 0); + // CU_ASSERT_EQUAL(AIFG_IEI_DT_MSCM1,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[61],1)); + + } +void test_aifg_ie_dt_cmInfo2(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_MSCM2; + ie.ptr=src[62]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_MSCM2,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.rev_level); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.es_ind); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.a5_1); + CU_ASSERT_EQUAL(0x03,dst.param.bm_cmInfo2.rf_power_cap); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.ps_cap); + CU_ASSERT_EQUAL(0x02,dst.param.bm_cmInfo2.ss_screen_ind); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.sm_cap); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.vbs); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.vgcs); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.fc); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.cm3); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.lcsva_cap); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.so_lsa); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.cmsp); + CU_ASSERT_EQUAL(0x00,dst.param.bm_cmInfo2.a5_3); + CU_ASSERT_EQUAL(0x01,dst.param.bm_cmInfo2.a5_2); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_MSCM2,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_MSCM2,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[62],4)); + } +void test_aifg_ie_dt_mobileId() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_MOBILEID; + ie.ptr=src[63]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_MOBILEID,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(0x03,dst.param.mobileId.type); + CU_ASSERT_EQUAL(0,dst.param.mobileId.odd_even_flag); + CU_ASSERT_EQUAL(0x02,dst.param.mobileId.id_len); + CU_ASSERT_EQUAL(0x07,dst.param.mobileId.id[0]); + CU_ASSERT_EQUAL(0x02,dst.param.mobileId.id[1]); + CU_ASSERT_EQUAL(0x0f,dst.param.mobileId.id[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_MOBILEID,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_MOBILEID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[63],3)); +} + +void test_aifg_ie_dt_lai() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_LAI; + ie.ptr=src[64]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_LAI,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(0x08,dst.param.dt_lai.mcc[0]); + CU_ASSERT_EQUAL(0x07,dst.param.dt_lai.mcc[1]); + CU_ASSERT_EQUAL(0x03,dst.param.dt_lai.mcc[2]); + CU_ASSERT_EQUAL(0x0f,dst.param.dt_lai.mnc[2]); + CU_ASSERT_EQUAL(0x06,dst.param.dt_lai.mnc[1]); + CU_ASSERT_EQUAL(0x04,dst.param.dt_lai.mnc[0]); + CU_ASSERT_EQUAL(0x3102,dst.param.dt_lai.LAC); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_LAI,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_LAI,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[64],5)); +} + +void test_aifg_ie_dt_luType(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_LUTYPE; + ie.ptr=src[65]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_LUTYPE,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(1,dst.param.dt_luType.fo_req); + CU_ASSERT_EQUAL(1,dst.param.dt_luType.lut); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_LUTYPE,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_LUTYPE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[65],1)); + } +void test_aifg_ie_dt_nwName(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_FULL_NWNAME; + ie.ptr=src[66]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_FULL_NWNAME,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(1,dst.param.dt_nwName.code_scheme); + CU_ASSERT_EQUAL(0,dst.param.dt_nwName.add_ci); + CU_ASSERT_EQUAL(1,dst.param.dt_nwName.spare_num); + CU_ASSERT_EQUAL(2,dst.param.dt_nwName.text_len); + CU_ASSERT_EQUAL(0x35,dst.param.dt_nwName.text[0]); + CU_ASSERT_EQUAL(0x64,dst.param.dt_nwName.text[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_FULL_NWNAME,&(dst.param),buffer, 2); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_NWNAME,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[66],4)); + } +void test_aifg_ie_dt_tzTime(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_TZTIME; + ie.ptr=src[67]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_TZTIME,dst.iei); + //CU_ASSERT_EQUAL(8,len); + CU_ASSERT_EQUAL(0x07,dst.param.dt_tzTime.year); + CU_ASSERT_EQUAL(0x04,dst.param.dt_tzTime.month); + CU_ASSERT_EQUAL(0x12,dst.param.dt_tzTime.day); + CU_ASSERT_EQUAL(0x0a,dst.param.dt_tzTime.hour); + CU_ASSERT_EQUAL(0x32,dst.param.dt_tzTime.minute); + CU_ASSERT_EQUAL(0x14,dst.param.dt_tzTime.second); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_tzTime.time_zone); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_TZTIME,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_TZTIME,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[67],7)); + } +void test_aifg_ie_dt_progInd(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_PROGIND; + ie.ptr=src[68]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_PROGIND,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_progInd.coding_standard); + CU_ASSERT_EQUAL(0x00,dst.param.dt_progInd.location); + CU_ASSERT_EQUAL(0x02,dst.param.dt_progInd.desc); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_PROGIND,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_PROGIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[68],3)); + } +void test_aifg_ie_dt_uu(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_USERUSER; + ie.ptr=src[69]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_USERUSER,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x01,dst.param.dt_uu.pd); + CU_ASSERT_EQUAL(2,dst.param.dt_uu.info_len); + CU_ASSERT_EQUAL(0x19,dst.param.dt_uu.info[0]); + CU_ASSERT_EQUAL(0x83,dst.param.dt_uu.info[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_USERUSER,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_USERUSER,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[69],4)); + } +void test_aifg_ie_dt_bc_0(){//info_trans_cap==0,only octet 3a is extend + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_BEARERCAP; + ie.ptr=src[70]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_BEARERCAP,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.channel_require); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.coding_std); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.trans_mode); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.info_trans_cap); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.coding.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.coding.flag); + CU_ASSERT_EQUAL(2,dst.param.dt_bc.speech_ver.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.speech_ver.flag); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_BEARERCAP,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_BEARERCAP,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[70],3)); +} + +void test_aifg_ie_dt_bc(){ + //precondition + memset(&dst,0,sizeof(dst)); + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_BEARERCAP; + ie.ptr=src[71]; + //test + + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_BEARERCAP,dst.iei); + //CU_ASSERT_EQUAL(15,len); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.channel_require); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.coding_std); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.trans_mode); + CU_ASSERT_EQUAL(3,dst.param.dt_bc.info_trans_cap); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.compress.flag);//test flag + CU_ASSERT_EQUAL(1,dst.param.dt_bc.compress.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.structure.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.dupl_mode.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.confiure.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.nirr.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.establishment.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.access_id.value); + CU_ASSERT_EQUAL(3,dst.param.dt_bc.rate_adaption.value); + CU_ASSERT_EQUAL(2,dst.param.dt_bc.signal_protocol.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.o_itc.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.o_rate_adaption.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.hdr_nohdr.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.multi_frame.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.mode.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.lli.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.assign_or_e.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.inb_neg.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.layer1_id.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.user_info1_protocol.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.sync_async.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.num_stop_bits.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.negotiation.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.num_data_bits.value); + CU_ASSERT_EQUAL(3,dst.param.dt_bc.user_rate.value); + CU_ASSERT_EQUAL(2,dst.param.dt_bc.intermed_rate.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.nic_on_tx.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.nic_on_rx.value); + CU_ASSERT_EQUAL(3,dst.param.dt_bc.parity.value); + CU_ASSERT_EQUAL(3,dst.param.dt_bc.connection_element.value); + CU_ASSERT_EQUAL(0,dst.param.dt_bc.modem_type.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.o_modem_type.value); + CU_ASSERT_EQUAL(1,dst.param.dt_bc.fixed_nw_user_rate.value); + CU_ASSERT_EQUAL(11,dst.param.dt_bc.acceptable_chennel_code.value); + CU_ASSERT_EQUAL(7,dst.param.dt_bc.max_traffic_channel.value); + CU_ASSERT_EQUAL(4,dst.param.dt_bc.uimi.value); + CU_ASSERT_EQUAL(7,dst.param.dt_bc.wanted_air_if_user_rate.value); + CU_ASSERT_EQUAL(2,dst.param.dt_bc.layer2_id.value); + CU_ASSERT_EQUAL(6,dst.param.dt_bc.user_info2_protocol.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_BEARERCAP,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_BEARERCAP,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[71],14)); + int n=1; + while(n<15){ + printf("%x ",buffer[n]); + n++; + } +} + +void test_aifg_ie_dt_cause(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CAUSE; + ie.ptr=src[72]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CAUSE,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(2,dst.param.dt_cause.coding_std); + CU_ASSERT_EQUAL(7,dst.param.dt_cause.location); + CU_ASSERT_EQUAL(1,dst.param.dt_cause.recommendation.flag); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_cause.recommendation.value); + CU_ASSERT_EQUAL(0x16,dst.param.dt_cause.cause_value); + CU_ASSERT_EQUAL(1,dst.param.dt_cause.diag_len); + CU_ASSERT_EQUAL(0x81,dst.param.dt_cause.diagnostic[0]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CAUSE,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_CAUSE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[72],5)); + } +void test_aifg_ie_dt_ccCap(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CCCAP; + ie.ptr=src[73]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CCCAP,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(1,dst.param.dt_ccCap.pcp); + CU_ASSERT_EQUAL(1,dst.param.dt_ccCap.dtmf); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CCCAP,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_CCCAP,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[73],2)); + } +void test_aifg_ie_dt_connNum(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CONNNUM; + ie.ptr=src[74]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CONNNUM,dst.iei); + //CU_ASSERT_EQUAL(6,len); + CU_ASSERT_EQUAL(2,dst.param.dt_connNum.type); + CU_ASSERT_EQUAL(1,dst.param.dt_connNum.presentation_ind.flag); + CU_ASSERT_EQUAL(1,dst.param.dt_connNum.presentation_ind.value); + CU_ASSERT_EQUAL(1,dst.param.dt_connNum.screen_ind.flag); + CU_ASSERT_EQUAL(3,dst.param.dt_connNum.screen_ind.value); + CU_ASSERT_EQUAL(8,dst.param.dt_connNum.num_plan); + CU_ASSERT_EQUAL(4,dst.param.dt_connNum.num_len); + CU_ASSERT_EQUAL(9,dst.param.dt_connNum.number[0]); + CU_ASSERT_EQUAL(8,dst.param.dt_connNum.number[1]); + CU_ASSERT_EQUAL(7,dst.param.dt_connNum.number[2]); + CU_ASSERT_EQUAL(3,dst.param.dt_connNum.number[3]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CONNNUM,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_CONNNUM,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[74],5)); + } +void test_aifg_ie_dt_connSubAddr(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CONNSUBADDR; + ie.ptr=src[75]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CONNSUBADDR,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0,dst.param.dt_connSubAddr.type); + CU_ASSERT_EQUAL(1,dst.param.dt_connSubAddr.odd_even_ind); + CU_ASSERT_EQUAL(2,dst.param.dt_connSubAddr.info_len); + CU_ASSERT_EQUAL(0x50,dst.param.dt_connSubAddr.info[0]); + CU_ASSERT_EQUAL(0x43,dst.param.dt_connSubAddr.info[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CONNSUBADDR,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_CONNSUBADDR,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[75],4)); +} +void test_aifg_ie_dt_ssVer(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_SSVER; + ie.ptr=src[76]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_SSVER,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(1,dst.param.dt_ssVer.info_len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_ssVer.info[0]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_SSVER,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_SSVER,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[76],2)); +} +void test_aifg_ie_dt_hiComp(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_HIGHCOM; + ie.ptr=src[77]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_HIGHCOM,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.coding_std.value); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.coding_std.flag); + CU_ASSERT_EQUAL(2,dst.param.dt_hiComp.interpret.value); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.interpret.flag); + CU_ASSERT_EQUAL(0,dst.param.dt_hiComp.presentat_method.value); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.presentat_method.flag); + CU_ASSERT_EQUAL(0x6e,dst.param.dt_hiComp.high_layer_id.value); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.high_layer_id.flag); + CU_ASSERT_EQUAL(0x34,dst.param.dt_hiComp.ext_high_layer_id.value); + CU_ASSERT_EQUAL(1,dst.param.dt_hiComp.ext_high_layer_id.flag); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_HIGHCOM,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_HIGHCOM,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[77],4)); +} +void test_aifg_ie_dt_loComp(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_LOWCOM; + ie.ptr=src[78]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_LOWCOM,dst.iei); + //CU_ASSERT_EQUAL(4,len); + CU_ASSERT_EQUAL(2,dst.param.dt_loComp.data_len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_loComp.data[0]); + CU_ASSERT_EQUAL(0xde,dst.param.dt_loComp.data[1]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_LOWCOM,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_LOWCOM,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[78],3)); +} +void test_aifg_ie_dt_callStat(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CALLSTAT; + ie.ptr=src[79]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CALLSTAT,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(3,dst.param.dt_callStat.coding_std); + CU_ASSERT_EQUAL(2,dst.param.dt_callStat.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CALLSTAT,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_CALLSTAT,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[79],1)); + } +void test_aifg_ie_dt_auxStat(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_AUXSTAT; + ie.ptr=src[80]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_AUXSTAT,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(1,dst.param.dt_auxStat.hold_stat); + CU_ASSERT_EQUAL(2,dst.param.dt_auxStat.mpty_stat); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_AUXSTAT,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_AUXSTAT,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[80],2)); + } +void test_aifg_ie_dt_lsaId(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_LSAID; + ie.ptr=src[81]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_LSAID,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x11,dst.param.dt_lsaId.value[0]); + CU_ASSERT_EQUAL(0x22,dst.param.dt_lsaId.value[1]); + CU_ASSERT_EQUAL(0x33,dst.param.dt_lsaId.value[2]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_LSAID,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_LSAID,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[81],4)); + } +void test_aifg_ie_dt_rejectCause(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_REJCAUSE; + ie.ptr=src[82]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_REJCAUSE,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_rejectCause.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_REJCAUSE,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_REJCAUSE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[82],1)); + } +void test_aifg_ie_dt_cmType(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CMTYPE; + ie.ptr=src[83]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CMTYPE,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x0B,dst.param.dt_cmType.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CMTYPE,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_CMTYPE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[83],1)); + } +void test_aifg_ie_dt_cipherKey(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CIPHERKEY; + ie.ptr=src[84]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CIPHERKEY,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x01,dst.param.dt_cipherKey.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CIPHERKEY,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_CIPHERKEY,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[84],1)); + } +void test_aifg_ie_dt_priority() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_PRIORITYLEVEL; + ie.ptr=src[85]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_PRIORITYLEVEL,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x05,dst.param.dt_priority.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_PRIORITYLEVEL,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_PRIORITYLEVEL,buffer[0]&0xF0); + CU_ASSERT_EQUAL(src[85][0],buffer[0]&0x0F); +} + +void test_aifg_ie_dt_idType() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_IDTYPE; + ie.ptr=src[86]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_IDTYPE,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x03,dst.param.dt_idType.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_IDTYPE,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_IDTYPE,buffer[0]); + CU_ASSERT_EQUAL(src[86][0],buffer[0]&0x0F); +} + +void test_aifg_ie_dt_congestLevel() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_CONGESTLEVEL; + ie.ptr=src[87]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_CONGESTLEVEL,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x0F,dst.param.dt_congestLevel.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_CONGESTLEVEL,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_CONGESTLEVEL,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[87],1)); +} + +void test_aifg_ie_dt_notificationInd() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_NOTIIND; + ie.ptr=src[88]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_NOTIIND,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x00,dst.param.dt_notificationInd.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_NOTIIND,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_NOTIIND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[88],1));} +void test_aifg_ie_dt_signal(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_SIGNAL; + ie.ptr=src[89]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_SIGNAL,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x08,dst.param.dt_signal.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_SIGNAL,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_SIGNAL,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[89],1)); +} + +void test_aifg_ie_dt_alertPattern(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_ALERTPATTERN; + ie.ptr=src[90]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_ALERTPATTERN,dst.iei); + //CU_ASSERT_EQUAL(3,len); + CU_ASSERT_EQUAL(0x07,dst.param.dt_alertPattern.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_ALERTPATTERN,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_ALERTPATTERN,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[90],2)); + } +void test_aifg_ie_dt_keypad(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_KEYPAD; + ie.ptr=src[91]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_KEYPAD,dst.iei); + //CU_ASSERT_EQUAL(2,len); + CU_ASSERT_EQUAL(0x0D,dst.param.dt_keypad.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_KEYPAD,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_KEYPAD,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[91],1)); + } +void test_aifg_ie_dt_timeZone(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_TIMEZONE; + ie.ptr=src[92]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_TIMEZONE,dst.iei); + //CU_ASSERT_EQUAL(2,len); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_TIMEZONE,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_TIMEZONE,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[92],1)); + } +void test_aifg_ie_dt_authRAND(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_AUTHRAND; + ie.ptr=src[93]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_AUTHRAND,dst.iei); + //CU_ASSERT_EQUAL(17,len); + CU_ASSERT_EQUAL(0x00,dst.param.dt_authRAND.value[0]); + CU_ASSERT_EQUAL(0x11,dst.param.dt_authRAND.value[1]); + CU_ASSERT_EQUAL(0x22,dst.param.dt_authRAND.value[2]); + CU_ASSERT_EQUAL(0x33,dst.param.dt_authRAND.value[3]); + CU_ASSERT_EQUAL(0x44,dst.param.dt_authRAND.value[4]); + CU_ASSERT_EQUAL(0x55,dst.param.dt_authRAND.value[5]); + CU_ASSERT_EQUAL(0x66,dst.param.dt_authRAND.value[6]); + CU_ASSERT_EQUAL(0x77,dst.param.dt_authRAND.value[7]); + CU_ASSERT_EQUAL(0x88,dst.param.dt_authRAND.value[8]); + CU_ASSERT_EQUAL(0x99,dst.param.dt_authRAND.value[9]); + CU_ASSERT_EQUAL(0xAA,dst.param.dt_authRAND.value[10]); + CU_ASSERT_EQUAL(0xBB,dst.param.dt_authRAND.value[11]); + CU_ASSERT_EQUAL(0xCC,dst.param.dt_authRAND.value[12]); + CU_ASSERT_EQUAL(0xDD,dst.param.dt_authRAND.value[13]); + CU_ASSERT_EQUAL(0xEE,dst.param.dt_authRAND.value[14]); + CU_ASSERT_EQUAL(0xFF,dst.param.dt_authRAND.value[15]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_AUTHRAND,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_AUTHRAND,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[93],16)); + + } + +void test_aifg_ie_dt_authSRES(){ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_AUTHSRES; + ie.ptr=src[94]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_AUTHSRES,dst.iei); + //CU_ASSERT_EQUAL(5,len); + CU_ASSERT_EQUAL(0x11,dst.param.dt_authSRES.value[0]); + CU_ASSERT_EQUAL(0x12,dst.param.dt_authSRES.value[1]); + CU_ASSERT_EQUAL(0x13,dst.param.dt_authSRES.value[2]); + CU_ASSERT_EQUAL(0x14,dst.param.dt_authSRES.value[3]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_AUTHSRES,&(dst.param),buffer, 0); +// CU_ASSERT_EQUAL(AIFG_IEI_DT_AUTHSRES,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[0],src[94],4)); +} + +void test_aifg_ie_dt_rpInd() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_REPEATIND; + ie.ptr=src[95]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_REPEATIND,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0x01,dst.param.dt_rpInd.value); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_REPEATIND,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_REPEATIND,buffer[0]&0xF0); + CU_ASSERT_EQUAL(src[95][0],buffer[0]&0x0F); +} + +void test_aifg_ie_dt_facility() +{ + //precondition + protocol=AIFG_MSG_DTAP; + ie.iei=AIFG_IE_ID_DT_FACILITY; + ie.ptr=src[96]; + //test + len=aifg_ie_decode(&ie,&dst); + + //check result + CU_ASSERT_EQUAL(AIFG_IE_ID_DT_FACILITY,dst.iei); + //CU_ASSERT_EQUAL(1,len); + CU_ASSERT_EQUAL(0xa1,dst.param.dt_facility.components.invoke.tag); + CU_ASSERT_EQUAL(0x0c,dst.param.dt_facility.components.invoke.len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.invoke.invoke_id.tag); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.invoke.invoke_id.len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.invoke.invoke_id.id); + CU_ASSERT_EQUAL(0x80,dst.param.dt_facility.components.invoke.linked_id.tag); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.invoke.linked_id.len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.invoke.linked_id.id); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.invoke.linked_id.flag); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.invoke.opCode.tag); + CU_ASSERT_EQUAL(0x03,dst.param.dt_facility.components.invoke.opCode.len); + CU_ASSERT_EQUAL(0x0a,dst.param.dt_facility.components.invoke.opCode.op[0]); + CU_ASSERT_EQUAL(0x0b,dst.param.dt_facility.components.invoke.opCode.op[1]); + CU_ASSERT_EQUAL(0x0c,dst.param.dt_facility.components.invoke.opCode.op[2]); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.invoke.param.param); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.invoke.param.flag); + + CU_ASSERT_EQUAL(0xa2,dst.param.dt_facility.components.return_result.tag); + CU_ASSERT_EQUAL(0x0d,dst.param.dt_facility.components.return_result.len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.return_result.invoke_id.tag); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.return_result.invoke_id.len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.return_result.invoke_id.id); + CU_ASSERT_EQUAL(0x30,dst.param.dt_facility.components.return_result.sequence.tag); + CU_ASSERT_EQUAL(0x04,dst.param.dt_facility.components.return_result.sequence.len); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.return_result.sequence.flag); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.return_result.opCode.tag); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.return_result.opCode.len); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.return_result.opCode.flag); + CU_ASSERT_EQUAL(0x0a,dst.param.dt_facility.components.return_result.opCode.op[0]); + CU_ASSERT_EQUAL(0x0b,dst.param.dt_facility.components.return_result.opCode.op[1]); + CU_ASSERT_EQUAL(0x11,dst.param.dt_facility.components.return_result.param.param[0]); + CU_ASSERT_EQUAL(0x22,dst.param.dt_facility.components.return_result.param.param[1]); + CU_ASSERT_EQUAL(0x33,dst.param.dt_facility.components.return_result.param.param[2]); + CU_ASSERT_EQUAL(0x44,dst.param.dt_facility.components.return_result.param.param[3]); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.return_result.param.flag); + + CU_ASSERT_EQUAL(0xa3,dst.param.dt_facility.components.return_error.tag); + CU_ASSERT_EQUAL(0x09,dst.param.dt_facility.components.return_error.len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.return_error.invoke_id.tag); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.return_error.invoke_id.len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.return_error.invoke_id.id); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.return_error.error.tag); + CU_ASSERT_EQUAL(0x03,dst.param.dt_facility.components.return_error.error.len); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.return_error.error.er[0]); + CU_ASSERT_EQUAL(0x09,dst.param.dt_facility.components.return_error.error.er[1]); + CU_ASSERT_EQUAL(0x0a,dst.param.dt_facility.components.return_error.error.er[2]); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.return_error.param.param); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.return_error.param.flag); + + CU_ASSERT_EQUAL(0xa4,dst.param.dt_facility.components.reject.tag); + CU_ASSERT_EQUAL(0x06,dst.param.dt_facility.components.reject.len); + CU_ASSERT_EQUAL(0x02,dst.param.dt_facility.components.reject.invoke_id.tag); + CU_ASSERT_EQUAL(0x01,dst.param.dt_facility.components.reject.invoke_id.len); + CU_ASSERT_EQUAL(0xdd,dst.param.dt_facility.components.reject.invoke_id.id); + CU_ASSERT_EQUAL(0x80,dst.param.dt_facility.components.reject.problem.tag); + CU_ASSERT_EQUAL(1,dst.param.dt_facility.components.reject.problem.len); + CU_ASSERT_EQUAL(0x00,dst.param.dt_facility.components.reject.problem.pro[0]); + //test encode + aifg_ie_encode(protocol,AIFG_IE_ID_DT_FACILITY,&(dst.param),buffer, 2); + CU_ASSERT_EQUAL(AIFG_IEI_DT_FACILITY,buffer[0]); + CU_ASSERT_EQUAL(0,memcmp(&buffer[1],src[96],49)); +} + +//////////////////////////////////////////msg test////////////////////////////////////////// + +aifg_msg_t structed_msg; +aifg_msg_pre_decoded predecoded; +int msg_len; +BYTE msgsrc[][256]= +{ + {0x00,0x0b,0x01,0x0B, 0x05, 0x01, 0x08, 0x91, 0x81, 0x05, 0x01, 0x00, 0x03},//0-assignReq + {0x00,0x1d,0x02,0x15,0x08,0x01,0x01,0x02,0x05,0x08,0x00,0x13,0x42,0x05,0x00, + 0x02,0x00,0x11,0x21,0x56,0x2c,0x03,0x2d,0x10,0x33,0x21,0x3b,0x03,0x10,0x39,0xd2},//1-assignComplete + {0x00,0x0f,0x03, 0x04,0x01,0x09, 0x15,0x08, 0x2d,0x10, 0x2e,0x05,0x01,0x02,0x03,0x04,0x05},//2-assignFailure + {0x00,0x08,0x40, 0x01,0x01,0x02, 0x04,0x01,0x09, 0x36,},//3-block + {0x00,0x04,0x41, 0x01,0x01,0x02},//4-blockAck + {0x00,0x04,0x42, 0x01,0x01,0x02},//5-unblock + {0x00,0x04,0x43, 0x01,0x01,0x02},//6-unblockAck + {0x00,0x25,0x11, 0x04,0x01,0x09, 0x1b, 0x1a,0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05, + 0x2e,0x05,0x01,0x02,0x03,0x04,0x05, 0x31,0x19, 0x33,0x21, 0x32,0x02, + 0x3a,0X07, 0xdd,0X01,0X02,0xdd ,0X02,0X06,0X01},//7-HORequired + {0x00,0x4c,0x10, 0x0b,0X04,0X01,0X09,0X83,0X79, 0x0a,0x01,0x01, + 0x12,0x03,0x33,0x22,0x8d, 0x05,0x03,0x02,0x00,0x22, 0x06,0x01,0x76, + 0x01,0x01,0x02, 0x19,0x01, 0x05,0x05,0x01,0x00,0x42,0x01,0x03, + 0x14,0x09, 0x04,0x01,0x09, 0x31,0x19, 0x33,0x21, 0x37,0x05,0x24,0x38,0x56,0x19,0x10, + 0x35, 0x39,0x03, 0x2c,0x03, 0X3a,0X07,0xdd,0X01,0X02,0xdd,0X02,0X06,0X01, + 0x3d,0x09,0x00,0x00,0x36,0x85,0xef,0x03,0x47,0x87,0x42},//8-HORequest + {0x00,0x14,0x12, 0x17,0x05,0x05,0x21,0x3f,0x58,0xe1, 0x21,0x56, 0x2c,0x03, 0x2d,0x10, 0x33,0x21, + 0x01,0x01,0x02, 0x3b,0x03,0x10,0x39,0xd2},//9-HORequestAck + {0x00,0x0d,0x13, 0x17,0x05,0x05,0x21,0x3f,0x58,0xe1, 0x05,0x03,0x02,0x00,0x22},//10-HOCmd + {0x00,0x03,0x14, 0x15,0x08},//11-HOComplete + {0x00,0x12,0x18, 0x0e,0xfe, 0x1a,0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05, 0x05,0x03,0x02,0x00,0x22},//12-HOCandidtateEnq + {0x00,0x08,0x19, 0x0e,0xfe, 0x05,0x03,0x02,0x00,0x22},//13-HOCandidateResp + {0x00,0x0f,0x16, 0x04,0x01,0x09, 0x15,0x08, 0x2d,0x10, 0x2e,0x05,0x01,0x02,0x03,0x04,0x05},//14-HOFailure + {0x00,0x14,0x17, 0x04,0x01,0x09, 0x05,0x03,0x02,0x00,0x22, 0x21,0x56, 0x2c,0x03, + 0x33,0x21, 0x3b,0x03,0x10,0x39,0xd2}, //15-HOPerformed + {0x00,0x04,0x1a, 0x04,0x01,0x09},//16-HOReject + {0x00,0x01,0x15},//17-HOSucceed + {0x00,0x01,0x1b},//18-HODetect + {0x00,0x0c,0x50, 0x0c,0xff, 0x1c,0x01, 0x05,0x03,0x02,0x00,0x22,0x0d,0x02},//19-resrcReq + {0x00,0x22,0x51, 0x1c,0x01, 0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x02,0x06,0x00,0x0b, + 0x05,0x03,0x02,0x00,0x22, 0x22,0x84,0x62,0xf2,0x7e},//20-resrcInd + {0x00,0x20,0x52, 0x08,0x08,0x49,0x06,0x20,0x12,0x75,0x21,0x07,0x94, 0x09,0X04,0X33,0X79,0X27,0X46, + 0x1a,0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05, 0x24,0x02, 0x38,0x06},//21-paging + {0x00,0x04,0x22, 0x04,0x01,0x09},//22-clearReq + {0x00,0x08,0x20, 0x07,0X02,0X08,0X02, 0x04,0x01,0x09},//23-clearCmd + {0x00,0x04,0x30, 0x04,0x01,0x09},//24-reset + {0x00,0x09,0x32, 0x04,0x01,0x09, 0x05,0x03,0x02,0x00,0x22},//25-overload + {0x00,0x18,0x36, 0x25,0xdd, 0x26,0x03,0x9d,0x20,0x81, 0x27,0x34,0x97, + 0x28,0x02,0x17,0x62, 0x29,0x02,0x31,0xf2, 0x2a,0x03,0x39,0xc4,0x08},//26-mscInvokeTrace + {0x00,0x16,0x37, 0x25,0xdd, 0x2b,0x02, 0x26,0x03,0x9d,0x20,0x81, + 0x27,0x34,0x97, 0x28,0x02,0x17,0x62, 0x2a,0x03,0x39,0xc4,0x08},//27-bscInvokeTrace + {0x00,0x06,0x54, 0x12,0x03,0x7e,0x67,0x82},//28-cmUpdate + {0x00,0x0a,0x53, 0x07,0X02,0X08,0X02, 0x0a,0x01,0x01, 0x23,0x00},//29-cipherModeCmd + {0x00,0x03,0x55, 0x2c,0x03},//30-cipherModeComplete + {0x00,0x04,0x59, 0x04,0x01,0x09},// 31-cipherModeRej + {0x00,0x1d,0x57, 0x05,0x03,0x02,0x00,0x22, 0x17,0x0B,0x05,0x24, 0xb1, 0x03,0x33,0x22,0x8d, 0x02,0x73,0xf2, 0x85, //cm request + 0x21,0x56, 0x3c,0x07,0x01,0x22,0xe4,0x31,0x57,0x69,0x83, 0x3e,0x03,0x15,0x49,0xf5},//32-completeL3Info + {0x00,0x06,0x25, 0x18,0xc2, 0x04,0x01,0x09},//33-sapi_n_rej + {0x00,0x07,0x34, 0x01,0x01,0x02, 0x04,0x01,0x09},//34-resetCircuit + {0x00,0x04,0x35, 0x01,0x01,0x02},//35-resetCircuitAck + {0x00,0x0d,0x44, 0x04,0x01,0x09, 0x01,0x01,0x02, 0x1e,0x04,0x32,0x12,0x8d,0x36},//36-circuitGrpBlk + {0x00,0x0a,0x45, 0x01,0x01,0x02, 0x1e,0x04,0x32,0x12,0x8d,0x36},//37-circuitGrpBlkAck + {0x00,0x0a,0x46, 0x01,0x01,0x02, 0x1e,0x04,0x32,0x12,0x8d,0x36},//38-circuitGrpUnblk + {0x00,0x0a,0x47, 0x01,0x01,0x02, 0x1e,0x04,0x32,0x12,0x8d,0x36},//39-circuitGrpUnblkAck + {0x00,0x0a,0x26, 0x04,0x01,0x09, 0x1f,0x04,0x03,0x0a,0x38,0x89},//40-confusion + {0x00,0x0a,0x48, 0x01,0x01,0x02, 0x1e,0x04,0x32,0x12,0x8d,0x36},//41-unequippedCircuit + {0x00,0x1d,0x5a, 0x2f,0x11, 0x05,0x03,0x02,0x00,0x22, 0x1a,0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05, + 0x30,0x05,0x11,0x83,0x04,0x28,0x75, 0x04,0x02,0x89,0x03},//42-loadIndication + {0x00,0x03,0x28, 0x18,0xc2},//43-suspend + {0x00,0x03,0x29, 0x18,0xc2},//44-suspend + {0x00,0x04,0x4e, 0x04,0x01,0x09},//45-changeCircuit + {0x00,0x04,0x4f, 0x01,0x01,0x02},//46-changeCircuitAck + {0x00,0x06,0x2a, 0x3e,0x03,0x15,0x49,0xf5},//47-locCmd + {0x00,0x06,0x2b, 0x3e,0x03,0x15,0x49,0xf5},//48-locReport + {0x00,0x01,0x31},//49-resetAck + {0x00,0x01,0x21},//50-clearComplete + {0x00,0x01,0x56},//51-queueInd + {0x00,0x01,0x58},//52-cmRequest + +////////////dtap............................................... + + {0x01,0x00,0x0d,0x05,0x02, 0x78,0xf3,0x64,0x31,0x02, 0x17,0x02,0x73,0xf2, 0xa1, 0xa2},//53-luAccept + {0x01,0x00,0x03,0x05,0x22, 0x02},//54-cmReject + {0x01,0x00,0x03,0x05,0x04, 0x02},//55-luReject + {0x01,0x00,0x03,0x05,0x29, 0x02},//56-abort + {0x01,0x00,0x03,0x05,0x31, 0x02},//57-mmStatus + {0x05,0x08, 0x19, 0x78,0xf3,0x64,0x31,0x02, 0x11, 0x02,0x73,0xf2},//58-LURequest + {0x01,0x00,0x13,0x05,0x12, 0x01, 0X00,0X11,0X22,0X33,0X44,0X55,0X66,0X77,0X88,0X99,0XAA,0XBB,0XCC,0XDD,0XEE,0XFF},//59-authRequest + {0x01,0x00,0x06,0x05,0x14, 0X11,0X12,0X13,0X14},//60-authResp + {0x01,0x00,0x03,0x05,0x18, 0x03},//61-idRequest + {0x01,0x00,0x05,0x05,0x19, 0x02,0x73,0xf2},//62-idResp + {0x05,0x01, 0x11, 0x02,0x73,0xf2},//63-imsiDetachInd + {0x01,0x00,0x0a,0x05,0x1a, 0x78,0xf3,0x64,0x31,0x02, 0x02,0x73,0xf2},//64-tmsiCmd + {0x05,0x28, 0x01, 0x03,0x33,0x22,0x8d, 0x02,0x73,0xf2, 0x13,0x78,0xf3,0x64,0x31,0x02},//65-cmReEst_request + {0x05,0x24, 0x01, 0x03,0x33,0x22,0x8d, 0x02,0x73,0xf2, 0x85},//66-cmRequest + {0x01,0x00,0x1b,0x05,0x32, 0x43,0x03,0x91,0x35,0x64, 0x45,0x03,0x91,0x35,0x64, 0x46,0xdd, + 0x47,0x07,0x04,0x12,0x0a,0x32,0x14,0xdd, 0x48,0x03,0x11,0x22,0x33},//67-mmInfo + {0x01,0x00,0x03d,0x03,0x01, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x1e,0x02,0xc0,0x82, 0x7e,0x03,0x01,0x19,0x83},//68-alert + {0x01,0x00,0x1f,0x03,0x08, 0xd1, 0x04,0x02,0x20,0x02, 0x04,0x0d,0xa3,0xca,0x1a,0x00,0xe4,0x21,0x53,0x5b,0x60,0x21,0x5f,0x47,0xc6, + 0x08,0x04,0x47,0xdd,0x96,0x81, 0x15,0x01,0x03},//69-callConfirm + {0x01,0x00,0x42,0x03,0x02, 0xd1, 0x04,0x02,0x20,0x02, 0x04,0x02,0x20,0x02, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x1e,0x02,0xc0,0x82, 0x85},//70-callProceed + {0x01,0x00,0x48,0x03,0x07, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x1e,0x02,0xc0,0x82, 0x4c,0x04,0x28,0xa3,0x89,0x37, 0x4d,0x03,0x88,0x50,0x43, 0x7e,0x03,0x01,0x19,0x83},//71-connect + {0x01,0x00,0x06,0x03,0x0e, 0x04,0x02,0x20,0x02},//72-eSetup + {0x01,0x00,0x0a,0x03,0x03, 0x02,0xc0,0x82, 0x7e,0x03,0x01,0x19,0x83},//73-progress + {0x01,0x00,0x81,0x03,0x05, 0xd1, 0x04,0x02,0x20,0x02, 0x04,0x02,0x20,0x02, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x1e,0x02,0xc0,0x82, 0x34,0x08, 0x5c,0x04,0x28,0xa3,0x89,0x37, 0x5d,0x03,0x88,0x50,0x43, + 0x5e,0x04,0x88,0xa3,0x89,0x37, 0x6d,0x03,0x88,0x50,0x43, 0x74,0x04,0x28,0xa3,0x89,0x37, + 0x75,0x03,0x88,0x50,0x43, 0xd1, 0x7c,0x02,0xdd,0xde, 0x7c,0x02,0xdd,0xde, 0xd1, 0x7d,0x03,0xa8,0x6e,0xb4, + 0x7d,0x03,0xa8,0x6e,0xb4, 0x7e,0x03,0x01,0x19,0x83, 0x85, 0x19,0x01,0x02},//74-setup + {0x01,0x00,0x0f,0x03,0x17, 0x02,0x20,0x02, 0x7c,0x02,0xdd,0xde, 0x7d,0x03,0xa8,0x6e,0xb4, 0xa3},//75-modify + {0x01,0x00,0x0f,0x03,0x1f, 0x02,0x20,0x02, 0x7c,0x02,0xdd,0xde, 0x7d,0x03,0xa8,0x6e,0xb4, 0xa3},//76-modifyCmp + {0x01,0x00,0x013,0x03,0x13, 0x02,0x20,0x02, 0x04,0x47,0xdd,0x96,0x81, 0x7c,0x02,0xdd,0xde, 0x7d,0x03,0xa8,0x6e,0xb4},//77-modifyRej + {0x01,0x00,0x07,0x03,0x10, 0x03,0x01,0x19,0x83, 0xa0},//78-userInfo + {0x01,0x00,0x07,0x03,0x1a, 0x04,0x47,0xdd,0x96,0x81},//79-holdRej + {0x01,0x00,0x07,0x03,0x1e, 0x04,0x47,0xdd,0x96,0x81},//80-retrieveRej + {0x01,0x00,0x42,0x03,0x25, 0x04,0x47,0xdd,0x96,0x81, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x1e,0x02,0xc0,0x82, 0x7e,0x03,0x01,0x19,0x83},//81-disconnect + {0x01,0x00,0x45,0x03,0x2d, 0x08,0x04,0x47,0xdd,0x96,0x81, 0x08,0x04,0x47,0xdd,0x96,0x81, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x7e,0x03,0x01,0x19,0x83},//82-release + {0x01,0x00,0x3f,0x03,0x2a, 0x08,0x04,0x47,0xdd,0x96,0x81, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x7e,0x03,0x01,0x19,0x83},//83-releaseCmp + {0x01,0x00,0x09,0x03,0x39, 0x0f, 0x08,0x04,0x47,0xdd,0x96,0x81},//84-congestCtrl + {0x01,0x00,0x03,0x03,0x3e, 0x80},//85-notify + {0x01,0x00,0x0b,0x03,0x3d, 0x04,0x47,0xdd,0x96,0x81, 0xc2, 0x24,0x01,0x86},//86-status + {0x01,0x00,0x03,0x03,0x35, 0x0d},//87-startDTMF + {0x01,0x00,0x03,0x03,0x36, 0x0d},//88-startDTMF_ack + {0x01,0x00,0x07,0x03,0x37, 0x04,0x47,0xdd,0x96,0x81},//89-startDTMF_rej + {0x01,0x00,0x02,0x03,0x0f},//90-connectAck + {0x01,0x00,0x02,0x03,0x18},//91-hold + {0x01,0x00,0x02,0x03,0x19},//92-holdAck + {0x01,0x00,0x02,0x03,0x1c},//93-retrieve + {0x01,0x00,0x02,0x03,0x1d},//94-retrieveAck + {0x01,0x00,0x02,0x03,0x34},//95-statusEnq + {0x01,0x00,0x02,0x03,0x31},//96-stopDTMF + {0x01,0x00,0x02,0x03,0x32},//97-stopDTMF_ack + {0x01,0x00,0x33,0x03,0x3a, + 0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00},//98-facility + {0x01,0x00,0x41,0x03,0x25, 0x04,0x47,0xdd,0x96,0x81, + 0x1c,0x30,0xa1,0x0c,0x02,0x01,0xdd,0x80,0x01,0xdd,0x02,0x03,0x0a,0x0b,0x0c,0xdd, + 0xa2,0x0d,0x02,0x01,0xdd,0x30,0x04,0x02,0x02,0x0a,0x0b,0x11,0x22,0x33,0x44, + 0xa3,0x09,0x02,0x01,0xdd,0x02,0x03,0x01,0x09,0x0a,0xdd, + 0xa4,0x06,0x02,0x01,0xdd,0x80,0x01,0x00, + 0x7e,0x03,0x01,0x19,0x83, 0x7f,0x01,0xdd},//99-disconnect_mobileToNet + {0x00,0x1d,0x57, 0x05,0x03,0x02,0x00,0x22, 0x17,0x10,0x06,0x27, 0x02, 0x03,0x23,0x18,0x01, 0x08,0x49,0x06,0x20,0x12,0x75,0x21,0x07,0x94, //paging response + 0x21,0x56, 0x3c,0x07,0x01,0x22,0xe4,0x31,0x57,0x69,0x83, 0x3e,0x03,0x15,0x49,0xf5},//100-completeL3Info-paing response +}; + + +//bssmap.................................................. + +void test_aifg_msg_assignReq() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[0], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ASSIGN_REQ; + //channel type + aifg_ie_decode(&(predecoded.msg.assignReq.channelType),&dst); + memcpy(&(structed_msg.msg.assignReq.channelType),&(dst.param.bm_channelType), sizeof(dst.param.bm_channelType)); + structed_msg.msg.assignReq.channelType.flag = 1; + //cic + aifg_ie_decode(&(predecoded.msg.assignReq.cic),&dst); + memcpy(&(structed_msg.msg.assignReq.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.assignReq.cic.flag = 1; + + msg_len = aifg_msg_sd_assignReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 11); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[0][2], msg_len)); + +} + + +void test_aifg_msg_assignComplete() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[1], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ASSIGN_CMP; + //cellId + aifg_ie_decode(&(predecoded.msg.assignComplete.cellId),&dst); + memcpy(&(structed_msg.msg.assignComplete.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.assignComplete.cellId.flag = 1; + //chosen channel + aifg_ie_decode(&(predecoded.msg.assignComplete.chosenChannel),&dst); + memcpy(&(structed_msg.msg.assignComplete.chosenChannel),&(dst.param.bm_chosenChannel), sizeof(dst.param.bm_chosenChannel)); + structed_msg.msg.assignComplete.chosenChannel.flag = 1; + //chosen encrypt + aifg_ie_decode(&(predecoded.msg.assignComplete.chosenEncrypt),&dst); + memcpy(&(structed_msg.msg.assignComplete.chosenEncrypt),&(dst.param.bm_chosenEncrypt), sizeof(dst.param.bm_chosenEncrypt)); + structed_msg.msg.assignComplete.chosenEncrypt.flag = 1; + //cic + aifg_ie_decode(&(predecoded.msg.assignComplete.cic),&dst); + memcpy(&(structed_msg.msg.assignComplete.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.assignComplete.cic.flag = 1; + //circuit pool + aifg_ie_decode(&(predecoded.msg.assignComplete.circuitPool),&dst); + memcpy(&(structed_msg.msg.assignComplete.circuitPool),&(dst.param.bm_circuitPool), sizeof(dst.param.bm_circuitPool)); + structed_msg.msg.assignComplete.circuitPool.flag = 1; + //LSA id + aifg_ie_decode(&(predecoded.msg.assignComplete.lsaId),&dst); + memcpy(&(structed_msg.msg.assignComplete.lsaId),&(dst.param.bm_lsaId), sizeof(dst.param.bm_lsaId)); + structed_msg.msg.assignComplete.lsaId.flag = 1; + //rr cause + aifg_ie_decode(&(predecoded.msg.assignComplete.rrcause),&dst); + memcpy(&(structed_msg.msg.assignComplete.rrCause),&(dst.param.bm_rrCause), sizeof(dst.param.bm_rrCause)); + structed_msg.msg.assignComplete.rrCause.flag = 1; + //speech version + aifg_ie_decode(&(predecoded.msg.assignComplete.speechVer),&dst); + memcpy(&(structed_msg.msg.assignComplete.speechVer),&(dst.param.bm_speechVer), sizeof(dst.param.bm_speechVer)); + structed_msg.msg.assignComplete.speechVer.flag = 1; + + msg_len = aifg_msg_sd_assignComplete(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 29); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[1][2], msg_len)); + +} + + +void test_aifg_msg_assignFailure() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[2], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ASSIGN_FAIL; + + //cause + aifg_ie_decode(&(predecoded.msg.assignFailure.cause),&dst); + memcpy(&(structed_msg.msg.assignFailure.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.assignFailure.cause.flag= 1; + + //RR cause + aifg_ie_decode(&(predecoded.msg.assignFailure.rrcause),&dst); + memcpy(&(structed_msg.msg.assignFailure.rrCause),&(dst.param.bm_rrCause), sizeof(dst.param.bm_rrCause)); + structed_msg.msg.assignFailure.rrCause.flag= 1; + + //circuit pool + aifg_ie_decode(&(predecoded.msg.assignFailure.circuitPool),&dst); + memcpy(&(structed_msg.msg.assignFailure.circuitPool),&(dst.param.bm_circuitPool), sizeof(dst.param.bm_circuitPool)); + structed_msg.msg.assignFailure.circuitPool.flag= 1; + + //circuit pool list + aifg_ie_decode(&(predecoded.msg.assignFailure.circuitPoolList),&dst); + memcpy(&(structed_msg.msg.assignFailure.circuitPoolList),&(dst.param.bm_circuitPoolList), sizeof(dst.param.bm_circuitPoolList)); + structed_msg.msg.assignFailure.circuitPoolList.flag= 1; + + msg_len = aifg_msg_sd_assignFailure(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 15); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[2][2], msg_len)); +} + + +void test_aifg_msg_block() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[3], &predecoded); + + structed_msg.id = AIFG_MSG_ID_BLOCK; + + //circuit identity code + aifg_ie_decode(&(predecoded.msg.block.cic),&dst); + memcpy(&(structed_msg.msg.block.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.block.cic.flag= 1; + + //cause + aifg_ie_decode(&(predecoded.msg.block.cause),&dst); + memcpy(&(structed_msg.msg.block.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.block.cause.flag= 1; + + //connection release requested + aifg_ie_decode(&(predecoded.msg.block.connectionRelReq),&dst); + memcpy(&(structed_msg.msg.block.connRelReq),&(dst.param.bm_connRelReq), sizeof(dst.param.bm_connRelReq)); + structed_msg.msg.block.connRelReq.flag= 1; + + msg_len = aifg_msg_sd_block(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 8); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[3][2], msg_len)); +} + + +void test_aifg_msg_blockAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[4], &predecoded); + + structed_msg.id = AIFG_MSG_ID_BLOCK_ACK; + //circuit identity code + aifg_ie_decode(&(predecoded.msg.blockAck.cic),&dst); + memcpy(&(structed_msg.msg.blockAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.blockAck.cic.flag= 1; + + + msg_len = aifg_msg_sd_blockAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[4][2], msg_len)); + +} + + +void test_aifg_msg_unblock() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[5], &predecoded); + + structed_msg.id = AIFG_MSG_ID_UNBLOCK; + //circuit identity code + aifg_ie_decode(&(predecoded.msg.unblock.cic),&dst); + memcpy(&(structed_msg.msg.unblock.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.unblock.cic.flag= 1; + + + msg_len = aifg_msg_sd_unblock(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[5][2], msg_len)); + +} + + +void test_aifg_msg_unblockAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[6], &predecoded); + + structed_msg.id = AIFG_MSG_ID_UNBLOCK_ACK; + //circuit identity code + aifg_ie_decode(&(predecoded.msg.unBlockAck.cic),&dst); + memcpy(&(structed_msg.msg.unblockAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.unblockAck.cic.flag= 1; + + msg_len = aifg_msg_sd_unblockAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[6][2], msg_len)); +} + +void test_aifg_msg_HORequired() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[7], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_REQUIRED; + //cause + aifg_ie_decode(&(predecoded.msg.HORequired.cause),&dst); + memcpy(&(structed_msg.msg.HORequired.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.HORequired.cause.flag= 1; + //response request + aifg_ie_decode(&(predecoded.msg.HORequired.respReq),&dst); + memcpy(&(structed_msg.msg.HORequired.respReq),&(dst.param.bm_respReq), sizeof(dst.param.bm_respReq)); + structed_msg.msg.HORequired.respReq.flag= 1; + //cell identifier list + aifg_ie_decode(&(predecoded.msg.HORequired.cellIdList),&dst); + memcpy(&(structed_msg.msg.HORequired.prefer_cidList),&(dst.param.bm_cellIdList), sizeof(dst.param.bm_cellIdList)); + structed_msg.msg.HORequired.prefer_cidList.flag= 1; + //circuit pool list + aifg_ie_decode(&(predecoded.msg.HORequired.circuitPoolList),&dst); + memcpy(&(structed_msg.msg.HORequired.circuitPoolList),&(dst.param.bm_circuitPoolList), sizeof(dst.param.bm_circuitPoolList)); + structed_msg.msg.HORequired.circuitPoolList.flag= 1; + //current channel type 1 + aifg_ie_decode(&(predecoded.msg.HORequired.curChannelType1),&dst); + memcpy(&(structed_msg.msg.HORequired.curChannelType1),&(dst.param.bm_curChannelType1), sizeof(dst.param.bm_curChannelType1)); + structed_msg.msg.HORequired.curChannelType1.flag= 1; + //speech verssion + aifg_ie_decode(&(predecoded.msg.HORequired.speechVer),&dst); + memcpy(&(structed_msg.msg.HORequired.speechVer),&(dst.param.bm_speechVer), sizeof(dst.param.bm_speechVer)); + structed_msg.msg.HORequired.speechVer.flag= 1; + //queueing indicator + aifg_ie_decode(&(predecoded.msg.HORequired.queInd),&dst); + memcpy(&(structed_msg.msg.HORequired.queuingInd),&(dst.param.bm_queuingInd), sizeof(dst.param.bm_queuingInd)); + structed_msg.msg.HORequired.queuingInd.flag= 1; + //old bss to new bss infomation + aifg_ie_decode(&(predecoded.msg.HORequired.oldBssToNew),&dst); + memcpy(&(structed_msg.msg.HORequired.bssOldtoNew),&(dst.param.bm_bssOldtoNew), sizeof(dst.param.bm_bssOldtoNew)); + structed_msg.msg.HORequired.bssOldtoNew.flag= 1; + + msg_len = aifg_msg_sd_HORequired(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 37); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[7][2], msg_len)); +} + +/* +void test_aifg_msg_HORequest() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[8], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_REQUEST; + //channel type + aifg_ie_decode(&(predecoded.msg.HORequest.channelType),&dst); + memcpy(&(structed_msg.msg.HORequest.channelType),&(dst.param.bm_channelType), sizeof(dst.param.bm_channelType)); + structed_msg.msg.HORequest.channelType.flag= 1; + //encryption infomation + aifg_ie_decode(&(predecoded.msg.HORequest.encryptInfo),&dst); + memcpy(&(structed_msg.msg.HORequest.encryptInfo),&(dst.param.bm_encryptInfo), sizeof(dst.param.bm_encryptInfo)); + structed_msg.msg.HORequest.encryptInfo.flag= 1; + //classmark 2 + aifg_ie_decode(&(predecoded.msg.HORequest.cmInfo2),&dst); + memcpy(&(structed_msg.msg.HORequest.cmInfo.cm2),&(dst.param.bm_cmInfo2), sizeof(dst.param.bm_cmInfo2)); + structed_msg.msg.HORequest.cmInfo.cm2.flag= 1; + //cell identifier (serving) + aifg_ie_decode(&(predecoded.msg.HORequest.serving_cellId),&dst); + memcpy(&(structed_msg.msg.HORequest.servingCellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HORequest.servingCellId.flag= 1; + //priority + aifg_ie_decode(&(predecoded.msg.HORequest.priority),&dst); + memcpy(&(structed_msg.msg.HORequest.priority),&(dst.param.bm_priority), sizeof(dst.param.bm_priority)); + structed_msg.msg.HORequest.priority.flag= 1; + //circuit identity code + aifg_ie_decode(&(predecoded.msg.HORequest.cic),&dst); + memcpy(&(structed_msg.msg.HORequest.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.HORequest.cic.flag= 1; + //dtx flag + aifg_ie_decode(&(predecoded.msg.HORequest.dtxFlag),&dst); + memcpy(&(structed_msg.msg.HORequest.dtxFlag),&(dst.param.bm_dtx), sizeof(dst.param.bm_dtx)); + structed_msg.msg.HORequest.dtxFlag.flag= 1; + //cell identifier (target) + aifg_ie_decode(&(predecoded.msg.HORequest.target_cellId),&dst); + memcpy(&(structed_msg.msg.HORequest.targetCellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HORequest.targetCellId.flag= 1; + //band to be used + aifg_ie_decode(&(predecoded.msg.HORequest.bandUsed),&dst); + memcpy(&(structed_msg.msg.HORequest.bandUsed),&(dst.param.bm_bandUsed), sizeof(dst.param.bm_bandUsed)); + structed_msg.msg.HORequest.bandUsed.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.HORequest.cause),&dst); + memcpy(&(structed_msg.msg.HORequest.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.HORequest.cause.flag= 1; + //current channel type 1 + aifg_ie_decode(&(predecoded.msg.HORequest.curChanneltype1),&dst); + memcpy(&(structed_msg.msg.HORequest.curChannelType1),&(dst.param.bm_curChannelType1), sizeof(dst.param.bm_curChannelType1)); + structed_msg.msg.HORequest.curChannelType1.flag= 1; + //speech version + aifg_ie_decode(&(predecoded.msg.HORequest.speechVer),&dst); + memcpy(&(structed_msg.msg.HORequest.speechVer),&(dst.param.bm_speechVer), sizeof(dst.param.bm_speechVer)); + structed_msg.msg.HORequest.speechVer.flag= 1; + //group call reference + aifg_ie_decode(&(predecoded.msg.HORequest.groupCallRef),&dst); + memcpy(&(structed_msg.msg.HORequest.gourpRef),&(dst.param.bm_groupRef), sizeof(dst.param.bm_groupRef)); + structed_msg.msg.HORequest.gourpRef.flag= 1; + //talker flag + aifg_ie_decode(&(predecoded.msg.HORequest.talkerFlag),&dst); + memcpy(&(structed_msg.msg.HORequest.talkerFlag),&(dst.param.bm_talkerFlag), sizeof(dst.param.bm_talkerFlag)); + structed_msg.msg.HORequest.talkerFlag.flag= 1; + //configuration evolution indication + aifg_ie_decode(&(predecoded.msg.HORequest.cfgEvoInd),&dst); + memcpy(&(structed_msg.msg.HORequest.cfgEvoInd),&(dst.param.bm_cfgEvoInd), sizeof(dst.param.bm_cfgEvoInd)); + structed_msg.msg.HORequest.cfgEvoInd.flag= 1; + //chosen encryption algnorithm + aifg_ie_decode(&(predecoded.msg.HORequest.chosenEncrypt),&dst); + memcpy(&(structed_msg.msg.HORequest.chosenEncrypt),&(dst.param.bm_chosenEncrypt), sizeof(dst.param.bm_chosenEncrypt)); + structed_msg.msg.HORequest.chosenEncrypt.flag= 1; + //old bss to new bss + aifg_ie_decode(&(predecoded.msg.HORequest.oldBssToNew),&dst); + memcpy(&(structed_msg.msg.HORequest.bssOldtoNew),&(dst.param.bm_bssOldtoNew), sizeof(dst.param.bm_bssOldtoNew)); + structed_msg.msg.HORequest.bssOldtoNew.flag= 1; + //LSA infomation + aifg_ie_decode(&(predecoded.msg.HORequest.lsaInfo),&dst); + memcpy(&(structed_msg.msg.HORequest.lsaInfo),&(dst.param.bm_lsaInfo), sizeof(dst.param.bm_lsaInfo)); + structed_msg.msg.HORequest.lsaInfo.flag= 1; + + msg_len = aifg_msg_sd_HORequest(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 76); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[8][2], msg_len)); + +} + +void test_aifg_msg_HORequestAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[9], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_REQ_ACK; + //layer 3 infomation +// aifg_ie_decode(&(predecoded.msg.HORequestAck.l3Info),&dst); +// memcpy(&(structed_msg.msg.HORequestAck.l3Info),&(dst.param.bm_l3Info), sizeof(dst.param.bm_l3Info)); +// structed_msg.msg.HORequestAck.l3Info.flag= 1; + //chosen channel + aifg_ie_decode(&(predecoded.msg.HORequestAck.chosenChannel),&dst); + memcpy(&(structed_msg.msg.HORequestAck.chosenChannel),&(dst.param.bm_chosenChannel), sizeof(dst.param.bm_chosenChannel)); + structed_msg.msg.HORequestAck.chosenChannel.flag= 1; + //chosen encryption algnorithm + aifg_ie_decode(&(predecoded.msg.HORequestAck.chosenEncrypt),&dst); + memcpy(&(structed_msg.msg.HORequestAck.chosenEncrypt),&(dst.param.bm_chosenEncrypt), sizeof(dst.param.bm_chosenEncrypt)); + structed_msg.msg.HORequestAck.chosenEncrypt.flag= 1; + //circuit pool + aifg_ie_decode(&(predecoded.msg.HORequestAck.circuitPool),&dst); + memcpy(&(structed_msg.msg.HORequestAck.circuitPool),&(dst.param.bm_circuitPool), sizeof(dst.param.bm_circuitPool)); + structed_msg.msg.HORequestAck.circuitPool.flag= 1; + //speech version + aifg_ie_decode(&(predecoded.msg.HORequestAck.speechVer),&dst); + memcpy(&(structed_msg.msg.HORequestAck.speechVer),&(dst.param.bm_speechVer), sizeof(dst.param.bm_speechVer)); + structed_msg.msg.HORequestAck.speechVer.flag= 1; + //circuit identity code + aifg_ie_decode(&(predecoded.msg.HORequestAck.cic),&dst); + memcpy(&(structed_msg.msg.HORequestAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.HORequestAck.cic.flag= 1; + //LSA identity + aifg_ie_decode(&(predecoded.msg.HORequestAck.lsaId),&dst); + memcpy(&(structed_msg.msg.HORequestAck.lsaId),&(dst.param.bm_lsaId), sizeof(dst.param.bm_lsaId)); + structed_msg.msg.HORequestAck.lsaId.flag= 1; + + + msg_len = aifg_msg_sd_HORequestAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 17); + CU_ASSERT_EQUAL(0, memcmp(&buffer[1], &msgsrc[9][10], msg_len-1)); + +} + +void test_aifg_msg_HOCmd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[10], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_CMD; + + //l3Info not be test + + //cell identifier + aifg_ie_decode(&(predecoded.msg.HOCmd.cellId),&dst); + memcpy(&(structed_msg.msg.HOCmd.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HOCmd.cellId.flag= 1; + + + msg_len = aifg_msg_sd_HOCmd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 6); + CU_ASSERT_EQUAL(0, memcmp(&buffer[1], &msgsrc[10][10], msg_len-1)); + +} + + +void test_aifg_msg_HOComplete() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[11], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_CMP; + + + //RR cause + aifg_ie_decode(&(predecoded.msg.HOComplete.rrcause),&dst); + memcpy(&(structed_msg.msg.HOComplete.rrCause),&(dst.param.bm_rrCause), sizeof(dst.param.bm_rrCause)); + structed_msg.msg.HOComplete.rrCause.flag= 1; + + + msg_len = aifg_msg_sd_HOComplete(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 3); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[11][2], msg_len)); + +} +*/ +void test_aifg_msg_HOCandidateEnq() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[12], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_CAN_ENQ; + + + //number of mss + aifg_ie_decode(&(predecoded.msg.HOCandEnq.msNum),&dst); + memcpy(&(structed_msg.msg.HOCandidateEnq.msNum),&(dst.param.bm_msNum), sizeof(dst.param.bm_msNum)); + structed_msg.msg.HOCandidateEnq.msNum.flag= 1; + //cell identifier list + aifg_ie_decode(&(predecoded.msg.HOCandEnq.cellIdList),&dst); + memcpy(&(structed_msg.msg.HOCandidateEnq.cidList),&(dst.param.bm_cellIdList), sizeof(dst.param.bm_cellIdList)); + structed_msg.msg.HOCandidateEnq.cidList.flag= 1; + //cell identifier + aifg_ie_decode(&(predecoded.msg.HOCandEnq.cellId),&dst); + memcpy(&(structed_msg.msg.HOCandidateEnq.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HOCandidateEnq.cellId.flag= 1; + + msg_len = aifg_msg_sd_HOCandEnq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 18); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[12][2], msg_len)); + +} + + +void test_aifg_msg_HOCandidateResp() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[13], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_CAN_RESP; + + + //number of mss + aifg_ie_decode(&(predecoded.msg.HOCandResp.msNum),&dst); + memcpy(&(structed_msg.msg.HOCandidateResp.msNum),&(dst.param.bm_msNum), sizeof(dst.param.bm_msNum)); + structed_msg.msg.HOCandidateResp.msNum.flag= 1; + + //cell identifier + aifg_ie_decode(&(predecoded.msg.HOCandResp.cellId),&dst); + memcpy(&(structed_msg.msg.HOCandidateResp.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HOCandidateResp.cellId.flag= 1; + + msg_len = aifg_msg_sd_HOCandResp(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 8); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[13][2], msg_len)); + +} + + +void test_aifg_msg_HOFailure() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[14], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_FAIL; + + + //cause + aifg_ie_decode(&(predecoded.msg.HOFailure.cause),&dst); + memcpy(&(structed_msg.msg.HOFailure.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.HOFailure.cause.flag= 1; + //RR cause + aifg_ie_decode(&(predecoded.msg.HOFailure.rrcause),&dst); + memcpy(&(structed_msg.msg.HOFailure.rrCause),&(dst.param.bm_rrCause), sizeof(dst.param.bm_rrCause)); + structed_msg.msg.HOFailure.rrCause.flag= 1; + //circuit pool + aifg_ie_decode(&(predecoded.msg.HOFailure.circuitPool),&dst); + memcpy(&(structed_msg.msg.HOFailure.circuitPool),&(dst.param.bm_circuitPool), sizeof(dst.param.bm_circuitPool)); + structed_msg.msg.HOFailure.circuitPool.flag= 1; + //circuit pool list + aifg_ie_decode(&(predecoded.msg.HOFailure.circuitPoolList),&dst); + memcpy(&(structed_msg.msg.HOFailure.circuitPoolList),&(dst.param.bm_circuitPoolList), sizeof(dst.param.bm_circuitPoolList)); + structed_msg.msg.HOFailure.circuitPoolList.flag= 1; + + + msg_len = aifg_msg_sd_HOFailure(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 15); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[14][2], msg_len)); + +} + + +void test_aifg_msg_HOPerformed() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[15], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_PERFORMED; + + + //cause + aifg_ie_decode(&(predecoded.msg.HOPerformed.cause),&dst); + memcpy(&(structed_msg.msg.HOPerformed.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.HOPerformed.cause.flag= 1; + //cell identifier + aifg_ie_decode(&(predecoded.msg.HOPerformed.cellId),&dst); + memcpy(&(structed_msg.msg.HOPerformed.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.HOPerformed.cellId.flag= 1; + //chosen channel + aifg_ie_decode(&(predecoded.msg.HOPerformed.chosenChannel),&dst); + memcpy(&(structed_msg.msg.HOPerformed.chosenChannel),&(dst.param.bm_chosenChannel), sizeof(dst.param.bm_chosenChannel)); + structed_msg.msg.HOPerformed.chosenChannel.flag= 1; + //chosen encryption algnorithm + aifg_ie_decode(&(predecoded.msg.HOPerformed.chosenEncrypt),&dst); + memcpy(&(structed_msg.msg.HOPerformed.chosenEncrypt),&(dst.param.bm_chosenEncrypt), sizeof(dst.param.bm_chosenEncrypt)); + structed_msg.msg.HOPerformed.chosenEncrypt.flag= 1; + //speech version + aifg_ie_decode(&(predecoded.msg.HOPerformed.speechVer),&dst); + memcpy(&(structed_msg.msg.HOPerformed.speechVer),&(dst.param.bm_speechVer), sizeof(dst.param.bm_speechVer)); + structed_msg.msg.HOPerformed.speechVer.flag= 1; + //LSA identifier + aifg_ie_decode(&(predecoded.msg.HOPerformed.lsaId),&dst); + memcpy(&(structed_msg.msg.HOPerformed.lsaId),&(dst.param.bm_lsaId), sizeof(dst.param.bm_lsaId)); + structed_msg.msg.HOPerformed.lsaId.flag= 1; + + msg_len = aifg_msg_sd_HOPerformed(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 20); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[15][2], msg_len)); + +} + + +void test_aifg_msg_HOReject() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[16], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_REQ_REJ; + + + //cause + aifg_ie_decode(&(predecoded.msg.HORequiredRej.cause),&dst); + memcpy(&(structed_msg.msg.HOReject.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.HOReject.cause.flag= 1; + + + msg_len = aifg_msg_sd_HORequiredRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[16][2], msg_len)); + +} + + +void test_aifg_msg_HOSucceed() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[17], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_SUC; + + msg_len = aifg_msg_sd_HOSucceed(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[17][2], msg_len)); + +} + + +void test_aifg_msg_HODetect() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[18], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HO_DETECT; + + + msg_len = aifg_msg_sd_HODetect(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[18][2], msg_len)); + +} + + + +void test_aifg_msg_resrcReq() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[19], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESRC_REQ; + + + //periodicity + aifg_ie_decode(&(predecoded.msg.resrcReq.periodicity),&dst); + memcpy(&(structed_msg.msg.resourceReq.periodicity),&(dst.param.bm_periodicity), sizeof(dst.param.bm_periodicity)); + structed_msg.msg.resourceReq.periodicity.flag= 1; + //resource indication method + aifg_ie_decode(&(predecoded.msg.resrcReq.resrcIndMethod),&dst); + memcpy(&(structed_msg.msg.resourceReq.resrcIndMethod),&(dst.param.bm_resrcIndMethod), sizeof(dst.param.bm_resrcIndMethod)); + structed_msg.msg.resourceReq.resrcIndMethod.flag= 1; + //cell identifier + aifg_ie_decode(&(predecoded.msg.resrcReq.cellId),&dst); + memcpy(&(structed_msg.msg.resourceReq.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.resourceReq.cellId.flag= 1; + //extend resource indicator + aifg_ie_decode(&(predecoded.msg.resrcReq.extResrcInd),&dst); + memcpy(&(structed_msg.msg.resourceReq.extResrcInd),&(dst.param.bm_extResrcInd), sizeof(dst.param.bm_extResrcInd)); + structed_msg.msg.resourceReq.extResrcInd.flag= 1; + + + msg_len = aifg_msg_sd_resrcReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 12); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[19][2], msg_len)); + +} + + +void test_aifg_msg_resrcInd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[20], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESRC_IND; + + //resource indication method + aifg_ie_decode(&(predecoded.msg.resrcInd.resrcIndMethod),&dst); + memcpy(&(structed_msg.msg.resourceInd.resrcIndMethod),&(dst.param.bm_resrcIndMethod), sizeof(dst.param.bm_resrcIndMethod)); + structed_msg.msg.resourceInd.resrcIndMethod.flag= 1; + + //resource available + aifg_ie_decode(&(predecoded.msg.resrcInd.resrcAvail),&dst); + memcpy(&(structed_msg.msg.resourceInd.resrcAvail),&(dst.param.bm_resrcAvail), sizeof(dst.param.bm_resrcAvail)); + structed_msg.msg.resourceInd.resrcAvail.flag= 1; + + //cell identifier + aifg_ie_decode(&(predecoded.msg.resrcInd.cellId),&dst); + memcpy(&(structed_msg.msg.resourceInd.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.resourceInd.cellId.flag= 1; + + //total resource accessable + aifg_ie_decode(&(predecoded.msg.resrcInd.totalResrc),&dst); + memcpy(&(structed_msg.msg.resourceInd.totalResrc),&(dst.param.bm_totalResrc), sizeof(dst.param.bm_totalResrc)); + structed_msg.msg.resourceInd.totalResrc.flag= 1; + + msg_len = aifg_msg_sd_resrcInd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 34); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[20][2], msg_len)); +} + + +void test_aifg_msg_paging() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[21], &predecoded); + + structed_msg.id = AIFG_MSG_ID_PAGING; + + //imsi + aifg_ie_decode(&(predecoded.msg.paging.imsi),&dst); + memcpy(&(structed_msg.msg.paging.imsi),&(dst.param.bm_imsi), sizeof(dst.param.bm_imsi)); + structed_msg.msg.paging.imsi.flag= 1; + + //tmsi + aifg_ie_decode(&(predecoded.msg.paging.tmsi),&dst); + memcpy(&(structed_msg.msg.paging.tmsi),&(dst.param.bm_tmsi), sizeof(dst.param.bm_tmsi)); + structed_msg.msg.paging.tmsi.flag= 1; + + //cell identifier list + aifg_ie_decode(&(predecoded.msg.paging.cellIdList),&dst); + memcpy(&(structed_msg.msg.paging.cidList),&(dst.param.bm_cellIdList), sizeof(dst.param.bm_cellIdList)); + structed_msg.msg.paging.cidList.flag= 1; + + //channel needed + aifg_ie_decode(&(predecoded.msg.paging.channelNeeded),&dst); + memcpy(&(structed_msg.msg.paging.channelNeeded),&(dst.param.bm_channelNeeded), sizeof(dst.param.bm_channelNeeded)); + structed_msg.msg.paging.channelNeeded.flag= 1; + + //eMLPP priority + aifg_ie_decode(&(predecoded.msg.paging.eMLPPpri),&dst); + memcpy(&(structed_msg.msg.paging.eMLPP),&(dst.param.bm_eMLPP), sizeof(dst.param.bm_eMLPP)); + structed_msg.msg.paging.eMLPP.flag= 1; + + msg_len = aifg_msg_sd_paging(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 31); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[21][2], msg_len)); + + //for unit test + memcpy(&bm_paging, &structed_msg, sizeof(structed_msg)); +} + + +void test_aifg_msg_clearReq() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[22], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CLR_REQ; + + + //cause + aifg_ie_decode(&(predecoded.msg.clearReq.cause),&dst); + memcpy(&(structed_msg.msg.clearReq.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.clearReq.cause.flag= 1; + + + msg_len = aifg_msg_sd_clearReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[22][2], msg_len)); + + //for unit test use + memcpy(&bm_clearReq, &structed_msg, sizeof(structed_msg)); +} + + +void test_aifg_msg_clearCmd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[23], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CLR_CMD; + + + //layer 3 header infomation + aifg_ie_decode(&(predecoded.msg.clearCmd.l3HeaderInfo),&dst); + memcpy(&(structed_msg.msg.clearCmd.l3HeaderInfo),&(dst.param.bm_L3HeaderInfo), sizeof(dst.param.bm_L3HeaderInfo)); + structed_msg.msg.clearCmd.l3HeaderInfo.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.clearCmd.cause),&dst); + memcpy(&(structed_msg.msg.clearCmd.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.clearCmd.cause.flag= 1; + + msg_len = aifg_msg_sd_clearCmd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 8); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[23][2], msg_len)); + + //for unit test use + memcpy(&bm_clearCmd, &structed_msg, sizeof(structed_msg)); +} + + +void test_aifg_msg_reset() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[24], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESET; + + + //cause + aifg_ie_decode(&(predecoded.msg.reset.cause),&dst); + memcpy(&(structed_msg.msg.reset.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.reset.cause.flag= 1; + + msg_len = aifg_msg_sd_reset(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[24][2], msg_len)); + +} + +void test_aifg_msg_overload() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[25], &predecoded); + + structed_msg.id = AIFG_MSG_ID_OVERLOAD; + + + //cause + aifg_ie_decode(&(predecoded.msg.overload.cause),&dst); + memcpy(&(structed_msg.msg.overload.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.overload.cause.flag= 1; + //cell identifier + aifg_ie_decode(&(predecoded.msg.overload.cellId),&dst); + memcpy(&(structed_msg.msg.overload.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.overload.cellId.flag= 1; + + msg_len = aifg_msg_sd_overload(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 9); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[25][2], msg_len)); + +} + +void test_aifg_msg_mscInvokeTrace() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[26], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MSC_INVK_TRACE; + + //trace type + aifg_ie_decode(&(predecoded.msg.mscTrace.traceType),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.traceType),&(dst.param.bm_traceType), sizeof(dst.param.bm_traceType)); + structed_msg.msg.mscInvokeTrace.traceType.flag= 1; + //triggerid + aifg_ie_decode(&(predecoded.msg.mscTrace.triggerId),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.tiggerId),&(dst.param.bm_triggerId), sizeof(dst.param.bm_triggerId)); + structed_msg.msg.mscInvokeTrace.tiggerId.flag= 1; + //trace reference + aifg_ie_decode(&(predecoded.msg.mscTrace.traceRef),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.traceRef),&(dst.param.bm_traceRef), sizeof(dst.param.bm_traceRef)); + structed_msg.msg.mscInvokeTrace.traceRef.flag= 1; + //transactionid + aifg_ie_decode(&(predecoded.msg.mscTrace.transId),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.transId),&(dst.param.bm_transId), sizeof(dst.param.bm_transId)); + structed_msg.msg.mscInvokeTrace.transId.flag= 1; + //mobile identity + aifg_ie_decode(&(predecoded.msg.mscTrace.mobileId),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + structed_msg.msg.mscInvokeTrace.mobileId.flag= 1; + //OMCId + aifg_ie_decode(&(predecoded.msg.mscTrace.omcId),&dst); + memcpy(&(structed_msg.msg.mscInvokeTrace.omcId),&(dst.param.bm_omcId), sizeof(dst.param.bm_omcId)); + structed_msg.msg.mscInvokeTrace.omcId.flag= 1; + + msg_len = aifg_msg_sd_mscTrace(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 24); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[26][2], msg_len)); +} + +void test_aifg_msg_bscInvokeTrace() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[27], &predecoded); + + structed_msg.id = AIFG_MSG_ID_BSC_INVK_TRACE; + + //trace type + aifg_ie_decode(&(predecoded.msg.bscTrace.traceType),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.traceType),&(dst.param.bm_traceType), sizeof(dst.param.bm_traceType)); + structed_msg.msg.bscInvokeTrace.traceType.flag= 1; + //triggerid + aifg_ie_decode(&(predecoded.msg.bscTrace.triggerId),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.tiggerId),&(dst.param.bm_triggerId), sizeof(dst.param.bm_triggerId)); + structed_msg.msg.bscInvokeTrace.tiggerId.flag= 1; + //trace reference + aifg_ie_decode(&(predecoded.msg.bscTrace.traceRef),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.traceRef),&(dst.param.bm_traceRef), sizeof(dst.param.bm_traceRef)); + structed_msg.msg.bscInvokeTrace.traceRef.flag= 1; + //transactionid + aifg_ie_decode(&(predecoded.msg.bscTrace.transId),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.transId),&(dst.param.bm_transId), sizeof(dst.param.bm_transId)); + structed_msg.msg.bscInvokeTrace.transId.flag= 1; + //forward indicator + aifg_ie_decode(&(predecoded.msg.bscTrace.forwardInd),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.forwardInd),&(dst.param.bm_fowardInd), sizeof(dst.param.bm_fowardInd)); + structed_msg.msg.bscInvokeTrace.forwardInd.flag= 1; + //OMCId + aifg_ie_decode(&(predecoded.msg.bscTrace.omcId),&dst); + memcpy(&(structed_msg.msg.bscInvokeTrace.omcId),&(dst.param.bm_omcId), sizeof(dst.param.bm_omcId)); + structed_msg.msg.bscInvokeTrace.omcId.flag= 1; + + msg_len = aifg_msg_sd_bscTrace(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 22); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[27][2], msg_len)); +} + + +void test_aifg_msg_cmUpdate() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[28], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CM_UPDATE; + + //classmark information type 2 + aifg_ie_decode(&(predecoded.msg.cmUpdate.cmInfo2),&dst); + memcpy(&(structed_msg.msg.cmUpdate.cm2),&(dst.param.bm_cmInfo2), sizeof(dst.param.bm_cmInfo2)); + structed_msg.msg.cmUpdate.cm2.flag= 1; + //classmark information type 3 not be tested + + msg_len = aifg_msg_sd_cmUpdate(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[28][2], msg_len)); +} + + +void test_aifg_msg_cipherModeCmd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[29], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CIPHER_MODE_CMD; + + //layer 3 header infomation + aifg_ie_decode(&(predecoded.msg.cipherModeCmd.l3HeaderInfo),&dst); + memcpy(&(structed_msg.msg.cipherModeCmd.l3HeaderInfo),&(dst.param.bm_L3HeaderInfo), sizeof(dst.param.bm_L3HeaderInfo)); + structed_msg.msg.cipherModeCmd.l3HeaderInfo.flag= 1; + //encryption information + aifg_ie_decode(&(predecoded.msg.cipherModeCmd.encryptInfo),&dst); + memcpy(&(structed_msg.msg.cipherModeCmd.encryptInfo),&(dst.param.bm_encryptInfo), sizeof(dst.param.bm_encryptInfo)); + structed_msg.msg.cipherModeCmd.encryptInfo.flag= 1; + //cipher response mode + aifg_ie_decode(&(predecoded.msg.cipherModeCmd.cipherRespMode),&dst); + memcpy(&(structed_msg.msg.cipherModeCmd.cipherRespMode),&(dst.param.bm_cipherRespMode), sizeof(dst.param.bm_cipherRespMode)); + structed_msg.msg.cipherModeCmd.cipherRespMode.flag= 1; + + msg_len = aifg_msg_sd_cipherModeCmd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[29][2], msg_len)); +} + + +void test_aifg_msg_cipherModeComplete() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[30], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CIPHER_MODE_CMP; + + + //layer 3 message contents not be tested because not done in the ie_decode&ie_encode + + //chosen encryption algorithm + aifg_ie_decode(&(predecoded.msg.cipherModeComp.chosenEncrypt),&dst); + memcpy(&(structed_msg.msg.cipherModeComplete.chosenEncrypt),&(dst.param.bm_chosenEncrypt), sizeof(dst.param.bm_chosenEncrypt)); + structed_msg.msg.cipherModeComplete.chosenEncrypt.flag= 1; + + + msg_len = aifg_msg_sd_cipherModeComplete(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 3); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[30][2], msg_len)); + +} + + +void test_aifg_msg_cipherModeReject() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[31], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CIPHER_MODE_REJ; + + + //cause + aifg_ie_decode(&(predecoded.msg.cipherModeRej.cause),&dst); + memcpy(&(structed_msg.msg.cipherModeReject.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.cipherModeReject.cause.flag= 1; + + + msg_len = aifg_msg_sd_cipherModeRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[31][2], msg_len)); + +} + +void test_aifg_msg_completeL3Info() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + memset(&l3Info,0,sizeof(l3Info)); + + //test + aifg_msg_proc(msgsrc[32], &predecoded); + + structed_msg.id = AIFG_MSG_ID_L3_INFO; + + //cell identifier + aifg_ie_decode(&(predecoded.msg.completeL3Info.cellId),&dst); + memcpy(&(structed_msg.msg.completeL3Info.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.completeL3Info.cellId.flag= 1; + + //layer 3 infomation + //CM service type + structed_msg.msg.completeL3Info.l3Info.ptr = &msgsrc[32][10]; + structed_msg.msg.completeL3Info.l3Info.len = 11; +/* + l3Info.id = AIFG_MSG_ID_CM_REQUEST; + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.cmRequest.type),&dst); + memcpy(&(l3Info.msg.cmRequest.cmType),&(dst.param.dt_cmType), sizeof(dst.param.dt_cmType)); + l3Info.msg.cmRequest.cmType.flag= 1; + + //ciphering key sequence number + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.cmRequest.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.cmRequest.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.cmRequest.cipherKey.flag= 1; + //mobile station classmark 2 + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.cmRequest.cm2),&dst); + memcpy(&(l3Info.msg.cmRequest.cmInfo2),&(dst.param.dt_cmInfo2), sizeof(dst.param.dt_cmInfo2)); + l3Info.msg.cmRequest.cmInfo2.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.cmRequest.mobileId),&dst); + memcpy(&(l3Info.msg.cmRequest.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.cmRequest.mobileId.flag= 1; + + //priority level + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.cmRequest.priority),&dst); + memcpy(&(l3Info.msg.cmRequest.priority),&(dst.param.dt_priority), sizeof(dst.param.dt_priority)); + l3Info.msg.cmRequest.priority.flag= 1; + + memcpy(&(structed_msg.msg.completeL3Info.l3Info), &l3Info, sizeof(l3Info)); +*/ + + //chosen channel + aifg_ie_decode(&(predecoded.msg.completeL3Info.chosenChannel),&dst); + memcpy(&(structed_msg.msg.completeL3Info.chosenChannel),&(dst.param.bm_chosenChannel), sizeof(dst.param.bm_chosenChannel)); + structed_msg.msg.completeL3Info.chosenChannel.flag= 1; + + //LSA identity list + aifg_ie_decode(&(predecoded.msg.completeL3Info.lsaIdList),&dst); + memcpy(&(structed_msg.msg.completeL3Info.lsaIdList),&(dst.param.bm_lsaIdList), sizeof(dst.param.bm_lsaIdList)); + structed_msg.msg.completeL3Info.lsaIdList.flag= 1; + + //location information + aifg_ie_decode(&(predecoded.msg.completeL3Info.locInfo),&dst); + memcpy(&(structed_msg.msg.completeL3Info.locInfo),&(dst.param.bm_locInfo), sizeof(dst.param.bm_locInfo)); + structed_msg.msg.completeL3Info.locInfo.flag= 1; + + msg_len = aifg_msg_sd_completeL3Info(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 35); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[32][2],35)); + + //for unit test use + memcpy(&bm_completeL3, &structed_msg, sizeof(structed_msg)); +} + + +void test_aifg_msg_SAPI_n_Reject() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[33], &predecoded); + + structed_msg.id = AIFG_MSG_ID_SAPI_REJ; + + + //dlci + aifg_ie_decode(&(predecoded.msg.sapi_n_rej.dlci),&dst); + memcpy(&(structed_msg.msg.SAPI_n_Reject.dlci),&(dst.param.bm_dlci), sizeof(dst.param.bm_dlci)); + structed_msg.msg.SAPI_n_Reject.dlci.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.sapi_n_rej.cause),&dst); + memcpy(&(structed_msg.msg.SAPI_n_Reject.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.SAPI_n_Reject.cause.flag= 1; + + + + msg_len = aifg_msg_sd_sapi_n_rej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[33][2], msg_len)); + +} + +void test_aifg_msg_resetCircuit() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[34], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESET_CC; + + + //circuit identifier code + aifg_ie_decode(&(predecoded.msg.resetCircuit.cic),&dst); + memcpy(&(structed_msg.msg.resetCircuit.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.resetCircuit.cic.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.resetCircuit.cause),&dst); + memcpy(&(structed_msg.msg.resetCircuit.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.resetCircuit.cause.flag= 1; + + + msg_len = aifg_msg_sd_resetCircuit(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 7); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[34][2], msg_len)); + +} + + +void test_aifg_msg_resetCircuitAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[35], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESET_CC_ACK; + + //circuit identifier code + aifg_ie_decode(&(predecoded.msg.resetCircuitAck.cic),&dst); + memcpy(&(structed_msg.msg.resetCircuitAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.resetCircuitAck.cic.flag= 1; + + msg_len = aifg_msg_sd_resetCircuitAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[35][2], msg_len)); +} + + +void test_aifg_msg_circuitGrpBlk() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[36], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CC_GROUP_BLK; + + //cause + aifg_ie_decode(&(predecoded.msg.ccGroupBlock.cause),&dst); + memcpy(&(structed_msg.msg.ccGroupBlock.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.ccGroupBlock.cause.flag= 1; + + //cic + aifg_ie_decode(&(predecoded.msg.ccGroupBlock.cic),&dst); + memcpy(&(structed_msg.msg.ccGroupBlock.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.ccGroupBlock.cic.flag= 1; + + //cic list + aifg_ie_decode(&(predecoded.msg.ccGroupBlock.cicList),&dst); + memcpy(&(structed_msg.msg.ccGroupBlock.cicList),&(dst.param.bm_cicList), sizeof(dst.param.bm_cicList)); + structed_msg.msg.ccGroupBlock.cicList.flag= 1; + + msg_len = aifg_msg_sd_ccGrpBlk(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,13); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[36][2], msg_len)); +} + +void test_aifg_msg_circuitGrpBlkAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[37], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CC_GROUP_BLK_ACK; + + + //cic + aifg_ie_decode(&(predecoded.msg.ccGroupBlockAck.cic),&dst); + memcpy(&(structed_msg.msg.ccGroupBlockAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.ccGroupBlockAck.cic.flag= 1; + + //cic list + aifg_ie_decode(&(predecoded.msg.ccGroupBlockAck.cicList),&dst); + memcpy(&(structed_msg.msg.ccGroupBlockAck.cicList),&(dst.param.bm_cicList), sizeof(dst.param.bm_cicList)); + structed_msg.msg.ccGroupBlockAck.cicList.flag= 1; + + msg_len = aifg_msg_sd_ccGroupBlockAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[37][2], msg_len)); + +} + +void test_aifg_msg_circuitGrpUnblk() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[38], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CC_GROUP_UNBLK; + + + //cic + aifg_ie_decode(&(predecoded.msg.ccGroupUnblock.cic),&dst); + memcpy(&(structed_msg.msg.ccGroupUnblock.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.ccGroupUnblock.cic.flag= 1; + + //cic list + aifg_ie_decode(&(predecoded.msg.ccGroupUnblock.cicList),&dst); + memcpy(&(structed_msg.msg.ccGroupUnblock.cicList),&(dst.param.bm_cicList), sizeof(dst.param.bm_cicList)); + structed_msg.msg.ccGroupUnblock.cicList.flag= 1; + + msg_len = aifg_msg_sd_ccGroupUnblock(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[38][2], msg_len)); + +} + +void test_aifg_msg_circuitGrpUnblkAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[39], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CC_GROUP_UNBLK_ACK; + + + //cic + aifg_ie_decode(&(predecoded.msg.ccGroupUnblockAck.cic),&dst); + memcpy(&(structed_msg.msg.ccGroupUnblockAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.ccGroupUnblockAck.cic.flag= 1; + + //cic list + aifg_ie_decode(&(predecoded.msg.ccGroupUnblockAck.cicList),&dst); + memcpy(&(structed_msg.msg.ccGroupUnblockAck.cicList),&(dst.param.bm_cicList), sizeof(dst.param.bm_cicList)); + structed_msg.msg.ccGroupUnblockAck.cicList.flag= 1; + + msg_len = aifg_msg_sd_ccGroupUnblockAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[39][2], msg_len)); + +} + +void test_aifg_msg_confusion() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[40], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CONFUSION; + + + //cause + aifg_ie_decode(&(predecoded.msg.confusion.cause),&dst); + memcpy(&(structed_msg.msg.confusion.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.confusion.cause.flag= 1; + + //diagnostics + aifg_ie_decode(&(predecoded.msg.confusion.diagnostics),&dst); + memcpy(&(structed_msg.msg.confusion.diagnostics),&(dst.param.bm_diagnostics), sizeof(dst.param.bm_diagnostics)); + structed_msg.msg.confusion.diagnostics.flag= 1; + + msg_len = aifg_msg_sd_confusion(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[40][2], msg_len)); + +} + +void test_aifg_msg_unequippedCircuit() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[41], &predecoded); + + structed_msg.id = AIFG_MSG_ID_UNEQUIP_CC; + + + //cic + aifg_ie_decode(&(predecoded.msg.upequipCircuit.cic),&dst); + memcpy(&(structed_msg.msg.unequippedCircuit.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.unequippedCircuit.cic.flag= 1; + + //cic list + aifg_ie_decode(&(predecoded.msg.upequipCircuit.cicList),&dst); + memcpy(&(structed_msg.msg.unequippedCircuit.cicList),&(dst.param.bm_cicList), sizeof(dst.param.bm_cicList)); + structed_msg.msg.unequippedCircuit.cicList.flag= 1; + + msg_len = aifg_msg_sd_unequippedCircuit(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[41][2], msg_len)); + +} + +void test_aifg_msg_loadIndication() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[42], &predecoded); + + structed_msg.id = AIFG_MSG_ID_LOAD_IND; + + + //time indication + aifg_ie_decode(&(predecoded.msg.loadInd.timeInd),&dst); + memcpy(&(structed_msg.msg.loadInd.timeInd),&(dst.param.bm_timeId), sizeof(dst.param.bm_timeId)); + structed_msg.msg.loadInd.timeInd.flag= 1; + //cell identity + aifg_ie_decode(&(predecoded.msg.loadInd.cellId),&dst); + memcpy(&(structed_msg.msg.loadInd.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.loadInd.cellId.flag= 1; + //cell identity list + aifg_ie_decode(&(predecoded.msg.loadInd.cellIdList),&dst); + memcpy(&(structed_msg.msg.loadInd.cidList),&(dst.param.bm_cellIdList), sizeof(dst.param.bm_cellIdList)); + structed_msg.msg.loadInd.cidList.flag= 1; + //resource situation + aifg_ie_decode(&(predecoded.msg.loadInd.resrcSit),&dst); + memcpy(&(structed_msg.msg.loadInd.resrcSit),&(dst.param.bm_resrcSit), sizeof(dst.param.bm_resrcSit)); + structed_msg.msg.loadInd.resrcSit.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.loadInd.cause),&dst); + memcpy(&(structed_msg.msg.loadInd.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.loadInd.cause.flag= 1; + + + msg_len = aifg_msg_sd_loadInd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,29); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[42][2], msg_len)); + +} + +void test_aifg_msg_suspend() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[43], &predecoded); + + structed_msg.id = AIFG_MSG_ID_SUSPEND; + + + //dlci + aifg_ie_decode(&(predecoded.msg.suspend.dlci),&dst); + memcpy(&(structed_msg.msg.suspend.dlci),&(dst.param.bm_dlci), sizeof(dst.param.bm_dlci)); + structed_msg.msg.suspend.dlci.flag= 1; + + + msg_len = aifg_msg_sd_suspend(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,3); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[43][2], msg_len)); + +} + +void test_aifg_msg_resume() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[44], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESUME; + + + //dlci + aifg_ie_decode(&(predecoded.msg.resume.dlci),&dst); + memcpy(&(structed_msg.msg.resume.dlci),&(dst.param.bm_dlci), sizeof(dst.param.bm_dlci)); + structed_msg.msg.resume.dlci.flag= 1; + + + msg_len = aifg_msg_sd_resume(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,3); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[44][2], msg_len)); + +} + +void test_aifg_msg_changeCircuit() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[45], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CHANGE_CC; + + + //cause + aifg_ie_decode(&(predecoded.msg.changeCC.cause),&dst); + memcpy(&(structed_msg.msg.changeCircuit.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.changeCircuit.cause.flag= 1; + + + msg_len = aifg_msg_sd_changeCircuit(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[45][2], msg_len)); + +} + +void test_aifg_msg_changeCCAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[46], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CHANGE_CC_ACK; + + + //cic + aifg_ie_decode(&(predecoded.msg.changeCCAck.circuitId),&dst); + memcpy(&(structed_msg.msg.changeCircuitAck.cic),&(dst.param.bm_cic), sizeof(dst.param.bm_cic)); + structed_msg.msg.changeCircuitAck.cic.flag= 1; + + + msg_len = aifg_msg_sd_changeCircuitAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[46][2], msg_len)); + +} + +void test_aifg_msg_locCmd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[47], &predecoded); + + structed_msg.id = AIFG_MSG_ID_LOC_INFO_CMD; + + + //location information + aifg_ie_decode(&(predecoded.msg.locInfoCmd.locInfo),&dst); + memcpy(&(structed_msg.msg.locCmd.locInfo),&(dst.param.bm_locInfo), sizeof(dst.param.bm_locInfo)); + structed_msg.msg.locCmd.locInfo.flag= 1; + + + msg_len = aifg_msg_sd_locCmd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[47][2], msg_len)); + +} + +void test_aifg_msg_locReport() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[48], &predecoded); + + structed_msg.id = AIFG_MSG_ID_LOC_INFO_RPT; + + + //location information + aifg_ie_decode(&(predecoded.msg.locInfoReport.locInfo),&dst); + memcpy(&(structed_msg.msg.locReport.locInfo),&(dst.param.bm_locInfo), sizeof(dst.param.bm_locInfo)); + structed_msg.msg.locReport.locInfo.flag= 1; + + /*/cause + aifg_ie_decode(&(predecoded.msg.locInfoReport.cause),&dst); + memcpy(&(structed_msg.msg.locReport.cause),&(dst.param.bm_cause), sizeof(dst.param.bm_cause)); + structed_msg.msg.locReport.cause.flag= 1;*/ + + msg_len = aifg_msg_sd_locReport(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[48][2], msg_len)); + +} + +void test_aifg_msg_resetAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[49], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RESET_ACK; + + msg_len = aifg_msg_sd_resetAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[49][2], msg_len)); + +} + +void test_aifg_msg_clearComplete() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[50], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CLR_CMP; + + msg_len = aifg_msg_sd_clearComplete(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[50][2], msg_len)); + +} + +void test_aifg_msg_queueInd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[51], &predecoded); + + structed_msg.id = AIFG_MSG_ID_QUEUE_IND; + + msg_len = aifg_msg_sd_queueInd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[51][2], msg_len)); + +} + +void test_aifg_msg_cmkRequest() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[52], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CLASSMARK_REQ; + + msg_len = aifg_msg_sd_classmarkReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[52][2], msg_len)); + +} + +///////////////dtap msg //////////////////////////////////////////////////////////// +void test_aifg_msg_luAccept() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[53], &predecoded); + + structed_msg.id = AIFG_MSG_ID_LU_ACCEPT; + + //location area identification + aifg_ie_decode(&(predecoded.msg.luAccept.lai),&dst); + memcpy(&(structed_msg.msg.luAccept.lai),&(dst.param.dt_lai), sizeof(dst.param.dt_lai)); + structed_msg.msg.luAccept.lai.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecoded.msg.luAccept.mobileId),&dst); + memcpy(&(structed_msg.msg.luAccept.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + structed_msg.msg.luAccept.mobileId.flag= 1; + + //follow on proceed + aifg_ie_decode(&(predecoded.msg.luAccept.followOnProc),&dst); + memcpy(&(structed_msg.msg.luAccept.followOnProceed),&(dst.param.dt_followOnProceed), sizeof(dst.param.dt_followOnProceed)); + structed_msg.msg.luAccept.followOnProceed.flag= 1; + + //CTS permission + aifg_ie_decode(&(predecoded.msg.luAccept.ctsPerm),&dst); + memcpy(&(structed_msg.msg.luAccept.CTSPermission),&(dst.param.dt_CTSPermission), sizeof(dst.param.dt_CTSPermission)); + structed_msg.msg.luAccept.CTSPermission.flag= 1; + + msg_len = aifg_msg_sd_luAccept(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,12); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[53][4], msg_len)); +} + +void test_aifg_msg_cmReject() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[54], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CM_REJECT; + + + //reject cause + aifg_ie_decode(&(predecoded.msg.cmRej.rejCause),&dst); + memcpy(&(structed_msg.msg.cmReject.rejectCause),&(dst.param.dt_rejectCause), sizeof(dst.param.dt_rejectCause)); + structed_msg.msg.cmReject.rejectCause.flag= 1; + + + msg_len = aifg_msg_sd_cmRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[54][4], msg_len)); + +} + +void test_aifg_msg_luReject() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[55], &predecoded); + + structed_msg.id = AIFG_MSG_ID_LU_REJECT; + + //reject cause + aifg_ie_decode(&(predecoded.msg.luReject.rejCause),&dst); + memcpy(&(structed_msg.msg.luReject.rejectCause),&(dst.param.dt_rejectCause), sizeof(dst.param.dt_rejectCause)); + structed_msg.msg.luReject.rejectCause.flag= 1; + + msg_len = aifg_msg_sd_luReject(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[55][4], msg_len)); +} + +void test_aifg_msg_abort() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[56], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ABORT; + + + //reject cause + aifg_ie_decode(&(predecoded.msg.abort.rejCause),&dst); + memcpy(&(structed_msg.msg.abort.rejectCause),&(dst.param.dt_rejectCause), sizeof(dst.param.dt_rejectCause)); + structed_msg.msg.abort.rejectCause.flag= 1; + + + msg_len = aifg_msg_sd_abort(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[56][4], msg_len)); + +} + +void test_aifg_msg_mmStatus() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[57], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MM_STATUS; + + + //reject cause + aifg_ie_decode(&(predecoded.msg.mmStatus.rejCause),&dst); + memcpy(&(structed_msg.msg.mmStatus.rejectCause),&(dst.param.dt_rejectCause), sizeof(dst.param.dt_rejectCause)); + structed_msg.msg.mmStatus.rejectCause.flag= 1; + + + msg_len = aifg_msg_sd_mmStatus(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[57][4], msg_len)); + +} + +void test_aifg_msg_luRequest() +{ + memset(&l3Info,0,sizeof(l3Info)); + memset(&predecode_l3msg,0,sizeof(predecode_l3msg)); + + //test + aifg_msg_decode_embeded_l3msg(msgsrc[58], &predecode_l3msg); + + l3Info.id = AIFG_MSG_ID_LU_REQUEST; + + //location updating type + aifg_ie_decode(&(predecode_l3msg.msg.luRequest.type),&dst); + memcpy(&(l3Info.msg.luRequest.luType),&(dst.param.dt_luType), sizeof(dst.param.dt_luType)); + l3Info.msg.luRequest.luType.flag= 1; + + //ciphering key sequence number + aifg_ie_decode(&(predecode_l3msg.msg.luRequest.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.luRequest.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.luRequest.cipherKey.flag= 1; + + //location area identification + aifg_ie_decode(&(predecode_l3msg.msg.luRequest.lai),&dst); + memcpy(&(l3Info.msg.luRequest.lai),&(dst.param.dt_lai), sizeof(dst.param.dt_lai)); + l3Info.msg.luRequest.lai.flag= 1; + + //mobile station classmark 1 + aifg_ie_decode(&(predecode_l3msg.msg.luRequest.cm1),&dst); + memcpy(&(l3Info.msg.luRequest.cmInfo1),&(dst.param.dt_cmInfo1), sizeof(dst.param.dt_cmInfo1)); + l3Info.msg.luRequest.cmInfo1.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecode_l3msg.msg.luRequest.mobileId),&dst); + memcpy(&(l3Info.msg.luRequest.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.luRequest.mobileId.flag= 1; + + msg_len = aifg_msg_encode_embeded_l3msg(&l3Info, buffer); + CU_ASSERT_EQUAL(msg_len,12); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[58][0], msg_len)); +} + + +void test_aifg_msg_authRequest () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[59], &predecoded); + + structed_msg.id = AIFG_MSG_ID_AUTH_REQUEST; + + //ciphering key sequence number + aifg_ie_decode(&(predecoded.msg.authReq.cipherKeySeq),&dst); + memcpy(&(structed_msg.msg.authRequest.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + structed_msg.msg.authRequest.cipherKey.flag= 1; + + //authentication parameter RAND + aifg_ie_decode(&(predecoded.msg.authReq.authParamRAND),&dst); + memcpy(&(structed_msg.msg.authRequest.authRAND),&(dst.param.dt_authRAND), sizeof(dst.param.dt_authRAND)); + structed_msg.msg.authRequest.authRAND.flag= 1; + + msg_len = aifg_msg_sd_authReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,18); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[59][4], msg_len)); +} + +void test_aifg_msg_authResp () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[60], &predecoded); + + structed_msg.id = AIFG_MSG_ID_AUTH_RESPONSE; + + + //authentication parameter SRES + aifg_ie_decode(&(predecoded.msg.authResp.authParamSRES),&dst); + memcpy(&(structed_msg.msg.authResp.authSRES),&(dst.param.dt_authSRES), sizeof(dst.param.dt_authSRES)); + structed_msg.msg.authResp.authSRES.flag= 1; + + msg_len = aifg_msg_sd_authResp(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,5); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[60][4], msg_len)); + +} + +void test_aifg_msg_idRequest () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[61], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ID_REQUEST; + + + //identity type + aifg_ie_decode(&(predecoded.msg.idReq.type),&dst); + memcpy(&(structed_msg.msg.idRequest.idType),&(dst.param.dt_idType), sizeof(dst.param.dt_idType)); + structed_msg.msg.idRequest.idType.flag= 1; + + msg_len = aifg_msg_sd_idReq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[61][4], msg_len)); + +} + +void test_aifg_msg_idResp () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[62], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ID_RESPONSE; + + + //mobile identity + aifg_ie_decode(&(predecoded.msg.idResp.mobileId),&dst); + memcpy(&(structed_msg.msg.idResp.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + structed_msg.msg.idResp.mobileId.flag= 1; + + msg_len = aifg_msg_sd_idResp(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,4); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[62][4], msg_len)); + +} + +void test_aifg_msg_imsiDetachInd () +{ + memset(&l3Info,0,sizeof(l3Info)); + memset(&predecode_l3msg,0,sizeof(predecode_l3msg)); + + //test + aifg_msg_decode_embeded_l3msg(msgsrc[63], &predecode_l3msg); + + l3Info.id = AIFG_MSG_ID_IMSI_DETACH_IND; + + //mobile station classmark 1 + aifg_ie_decode(&(predecode_l3msg.msg.imsiDetachInd.cm1),&dst); + memcpy(&(l3Info.msg.imsiDetachInd.cmInfo1),&(dst.param.dt_cmInfo1), sizeof(dst.param.dt_cmInfo1)); + l3Info.msg.imsiDetachInd.cmInfo1.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecode_l3msg.msg.imsiDetachInd.mobileId),&dst); + memcpy(&(l3Info.msg.imsiDetachInd.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.imsiDetachInd.mobileId.flag= 1; + + msg_len = aifg_msg_encode_embeded_l3msg(&l3Info, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[63][0], msg_len)); +} + +void test_aifg_msg_tmsiCmd() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[64], &predecoded); + + structed_msg.id = AIFG_MSG_ID_TMSI_REALLOC_CMD; + + //location area identification + aifg_ie_decode(&(predecoded.msg.tmsiReallocCmd.lai),&dst); + memcpy(&(structed_msg.msg.tmsiCmd.lai),&(dst.param.dt_lai), sizeof(dst.param.dt_lai)); + structed_msg.msg.tmsiCmd.lai.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecoded.msg.tmsiReallocCmd.mobileId),&dst); + memcpy(&(structed_msg.msg.tmsiCmd.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + structed_msg.msg.tmsiCmd.mobileId.flag= 1; + + msg_len = aifg_msg_sd_tmsiReallocCmd(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,9); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[64][4], msg_len)); +} + +void test_aifg_msg_cmReEst_Request () +{ + memset(&l3Info,0,sizeof(l3Info)); + memset(&predecode_l3msg,0,sizeof(predecode_l3msg)); + + //test + aifg_msg_decode_embeded_l3msg(msgsrc[65], &predecode_l3msg); + + l3Info.id = AIFG_MSG_ID_CM_REEST_REQUEST; + + //ciphering key sequence number + aifg_ie_decode(&(predecode_l3msg.msg.cmReEstReq.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.cmReEstReq.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.cmReEstReq.cipherKey.flag= 1; + + //mobile station classmark 2 + aifg_ie_decode(&(predecode_l3msg.msg.cmReEstReq.cm2),&dst); + memcpy(&(l3Info.msg.cmReEstReq.cmInfo2),&(dst.param.dt_cmInfo2), sizeof(dst.param.dt_cmInfo2)); + l3Info.msg.cmReEstReq.cmInfo2.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecode_l3msg.msg.cmReEstReq.mobileId),&dst); + memcpy(&(l3Info.msg.cmReEstReq.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.cmReEstReq.mobileId.flag= 1; + + //location area identification + aifg_ie_decode(&(predecode_l3msg.msg.cmReEstReq.lai),&dst); + memcpy(&(l3Info.msg.cmReEstReq.lai),&(dst.param.dt_lai), sizeof(dst.param.dt_lai)); + l3Info.msg.cmReEstReq.lai.flag= 1; + + msg_len = aifg_msg_encode_embeded_l3msg(&l3Info, buffer); + CU_ASSERT_EQUAL(msg_len,16); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[65][0], msg_len)); + +} + +void test_aifg_msg_cmRequest() +{ + memset(&l3Info,0,sizeof(l3Info)); + memset(&predecode_l3msg,0,sizeof(predecode_l3msg)); + + //test + aifg_msg_decode_embeded_l3msg(msgsrc[66], &predecode_l3msg); + + l3Info.id = AIFG_MSG_ID_CM_REQUEST; + + //CM service type + aifg_ie_decode(&(predecode_l3msg.msg.cmRequest.type),&dst); + memcpy(&(l3Info.msg.cmRequest.cmType),&(dst.param.dt_cmType), sizeof(dst.param.dt_cmType)); + l3Info.msg.cmRequest.cmType.flag= 1; + + //ciphering key sequence number + aifg_ie_decode(&(predecode_l3msg.msg.cmRequest.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.cmRequest.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.cmRequest.cipherKey.flag= 1; + //mobile station classmark 2 + aifg_ie_decode(&(predecode_l3msg.msg.cmRequest.cm2),&dst); + memcpy(&(l3Info.msg.cmRequest.cmInfo2),&(dst.param.dt_cmInfo2), sizeof(dst.param.dt_cmInfo2)); + l3Info.msg.cmRequest.cmInfo2.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecode_l3msg.msg.cmRequest.mobileId),&dst); + memcpy(&(l3Info.msg.cmRequest.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.cmRequest.mobileId.flag= 1; + + //priority level + aifg_ie_decode(&(predecode_l3msg.msg.cmRequest.priority),&dst); + memcpy(&(l3Info.msg.cmRequest.priority),&(dst.param.dt_priority), sizeof(dst.param.dt_priority)); + l3Info.msg.cmRequest.priority.flag= 1; + + msg_len = aifg_msg_encode_embeded_l3msg(&l3Info, buffer); + CU_ASSERT_EQUAL(msg_len,11); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[66][0], msg_len)); +} + +void test_aifg_msg_mmInfo () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[67], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MM_INFO; + + //full name for network + aifg_ie_decode(&(predecoded.msg.mmInfo.fullNetworkName),&dst); + memcpy(&(structed_msg.msg.mmInfo.fullName),&(dst.param.dt_nwName), sizeof(dst.param.dt_nwName)); + structed_msg.msg.mmInfo.fullName.flag= 1; + + //short name for network + aifg_ie_decode(&(predecoded.msg.mmInfo.shortNetworkName),&dst); + memcpy(&(structed_msg.msg.mmInfo.shortName),&(dst.param.dt_nwName), sizeof(dst.param.dt_nwName)); + structed_msg.msg.mmInfo.shortName.flag= 1; + + //time zone + aifg_ie_decode(&(predecoded.msg.mmInfo.timeZone),&dst); + memcpy(&(structed_msg.msg.mmInfo.timeZone),&(dst.param.dt_timeZone), sizeof(dst.param.dt_timeZone)); + structed_msg.msg.mmInfo.timeZone.flag= 1; + + //time zone and time + aifg_ie_decode(&(predecoded.msg.mmInfo.timeZoneAndTime),&dst); + memcpy(&(structed_msg.msg.mmInfo.tzTime),&(dst.param.dt_tzTime), sizeof(dst.param.dt_tzTime)); + structed_msg.msg.mmInfo.tzTime.flag= 1; + + //LSA identifier + aifg_ie_decode(&(predecoded.msg.mmInfo.lsaId),&dst); + memcpy(&(structed_msg.msg.mmInfo.lsaId),&(dst.param.dt_lsaId), sizeof(dst.param.dt_lsaId)); + structed_msg.msg.mmInfo.lsaId.flag= 1; + + msg_len = aifg_msg_sd_mmInfo(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,26); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[67][4], msg_len)); +} + +void test_aifg_msg_alert () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[68], &predecoded); + + structed_msg.id = AIFG_MSG_ID_ALERTING; + + //facility ..........dt_facility not done + aifg_ie_decode(&(predecoded.msg.alert.facility),&dst); + memcpy(&(structed_msg.msg.alert.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.alert.facility.flag= 1; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.alert.progressInd),&dst); + memcpy(&(structed_msg.msg.alert.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.alert.progInd.flag= 1; + //user-user + aifg_ie_decode(&(predecoded.msg.alert.user_user),&dst); + memcpy(&(structed_msg.msg.alert.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.alert.uu.flag= 1; + + + msg_len = aifg_msg_sd_alert(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,60); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[68][4], msg_len)); + +} + +void test_aifg_msg_callConfirm () +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[69], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CALL_CONFIRMED; + + //repeat indicator + aifg_ie_decode(&(predecoded.msg.callConfirm.reptInd),&dst); + memcpy(&(structed_msg.msg.callConfirm.rpInd),&(dst.param.dt_rpInd), sizeof(dst.param.dt_rpInd)); + structed_msg.msg.callConfirm.rpInd.flag= 1; + + //bearer capability 1 + aifg_ie_decode(&(predecoded.msg.callConfirm.bearCap1),&dst); + memcpy(&(structed_msg.msg.callConfirm.bc1),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.callConfirm.bc1.flag= 1; + + //bearer capability 2 + aifg_ie_decode(&(predecoded.msg.callConfirm.bearCap2),&dst); + memcpy(&(structed_msg.msg.callConfirm.bc2),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.callConfirm.bc2.flag= 1; + + //cause + aifg_ie_decode(&(predecoded.msg.callConfirm.cause),&dst); + memcpy(&(structed_msg.msg.callConfirm.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.callConfirm.cause.flag= 1; + + //call control capabilities + aifg_ie_decode(&(predecoded.msg.callConfirm.ccCap),&dst); + memcpy(&(structed_msg.msg.callConfirm.ccCap),&(dst.param.dt_ccCap), sizeof(dst.param.dt_ccCap)); + structed_msg.msg.callConfirm.ccCap.flag= 1; + + msg_len = aifg_msg_sd_callConfirm(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,30); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[69][4], msg_len)); +} + +void test_aifg_msg_callProceed() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[70], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CALL_PROCEEDING; + + + //repeat indicator + aifg_ie_decode(&(predecoded.msg.callProceed.reptInd),&dst); + memcpy(&(structed_msg.msg.callProceed.rpInd),&(dst.param.dt_rpInd), sizeof(dst.param.dt_rpInd)); + structed_msg.msg.callProceed.rpInd.flag= 1; + //bearer capability 1 + aifg_ie_decode(&(predecoded.msg.callProceed.bearCap1),&dst); + memcpy(&(structed_msg.msg.callProceed.bc1),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.callProceed.bc1.flag= 1; + //bearer capability 2 + aifg_ie_decode(&(predecoded.msg.callProceed.bearCap2),&dst); + memcpy(&(structed_msg.msg.callProceed.bc2),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.callProceed.bc2.flag= 1; + + //test facility + aifg_ie_decode(&(predecoded.msg.callProceed.facility),&dst); + memcpy(&(structed_msg.msg.callProceed.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.callProceed.facility.flag= 1; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.callProceed.progressInd),&dst); + memcpy(&(structed_msg.msg.callProceed.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.callProceed.progInd.flag= 1; + //priority level + aifg_ie_decode(&(predecoded.msg.callProceed.priority),&dst); + memcpy(&(structed_msg.msg.callProceed.priority),&(dst.param.dt_priority), sizeof(dst.param.dt_priority)); + structed_msg.msg.callProceed.priority.flag= 1; + + + msg_len = aifg_msg_sd_callProceed(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,65); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[70][4], msg_len)); + +} + +void test_aifg_msg_connect() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[71], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CONNECT; + + + // test facility + aifg_ie_decode(&(predecoded.msg.connect.facility),&dst); + memcpy(&(structed_msg.msg.connect.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.connect.facility.flag= 1; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.connect.progressInd),&dst); + memcpy(&(structed_msg.msg.connect.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.connect.progInd.flag= 1; + //connected number + aifg_ie_decode(&(predecoded.msg.connect.connNum),&dst); + memcpy(&(structed_msg.msg.connect.connNum),&(dst.param.dt_connNum), sizeof(dst.param.dt_connNum)); + structed_msg.msg.connect.connNum.flag= 1; + //connected subaddress + aifg_ie_decode(&(predecoded.msg.connect.connSubaddr),&dst); + memcpy(&(structed_msg.msg.connect.connSubAddr),&(dst.param.dt_connSubAddr), sizeof(dst.param.dt_connSubAddr)); + structed_msg.msg.connect.connSubAddr.flag= 1; + //user-user + aifg_ie_decode(&(predecoded.msg.connect.user_user),&dst); + memcpy(&(structed_msg.msg.connect.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.connect.uu.flag= 1; + + msg_len = aifg_msg_sd_connect(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x47); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[71][4], msg_len)); + +} + +void test_aifg_msg_eSetup() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[72], &predecoded); + + structed_msg.id = AIFG_MSG_ID_EMERGENCY_SETUP; + + //bearer capability + aifg_ie_decode(&(predecoded.msg.eSetup.bearCap),&dst); + memcpy(&(structed_msg.msg.eSetup.bc),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.eSetup.bc.flag= 1; + + msg_len = aifg_msg_sd_eSetup(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,5); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[72][4], msg_len)); + +} + +void test_aifg_msg_progress() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[73], &predecoded); + + structed_msg.id = AIFG_MSG_ID_PROGRESS; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.progress.progressInd),&dst); + memcpy(&(structed_msg.msg.progress.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.progress.progInd.flag= 1; + //user-user + aifg_ie_decode(&(predecoded.msg.progress.user_user),&dst); + memcpy(&(structed_msg.msg.progress.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.progress.uu.flag= 1; + + + msg_len = aifg_msg_sd_progress(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,9); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[73][4], msg_len)); + +} + +void test_aifg_msg_setup() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[74], &predecoded); + + structed_msg.id = AIFG_MSG_ID_SETUP; + + //BC repeat indicator + aifg_ie_decode(&(predecoded.msg.setup.reptInd_bc),&dst); + memcpy(&(structed_msg.msg.setup.bc_rpInd),&(dst.param.dt_rpInd), sizeof(dst.param.dt_rpInd)); + structed_msg.msg.setup.bc_rpInd.flag= 1; + + //bearer capability 1 + aifg_ie_decode(&(predecoded.msg.setup.bearCap1),&dst); + memcpy(&(structed_msg.msg.setup.bc1),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.setup.bc1.flag= 1; + //bearer capability 2 + aifg_ie_decode(&(predecoded.msg.setup.bearCap2),&dst); + memcpy(&(structed_msg.msg.setup.bc2),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.setup.bc2.flag= 1; + + //test facility + aifg_ie_decode(&(predecoded.msg.setup.facility),&dst); + memcpy(&(structed_msg.msg.setup.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.setup.facility.flag= 1; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.setup.progressInd),&dst); + memcpy(&(structed_msg.msg.setup.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.setup.progInd.flag= 1; + //signal + aifg_ie_decode(&(predecoded.msg.setup.signal),&dst); + memcpy(&(structed_msg.msg.setup.signal),&(dst.param.dt_signal), sizeof(dst.param.dt_signal)); + structed_msg.msg.setup.signal.flag= 1; + //calling party BCD number + aifg_ie_decode(&(predecoded.msg.setup.callingBCD),&dst); + memcpy(&(structed_msg.msg.setup.callingNum),&(dst.param.dt_callingNum), sizeof(dst.param.dt_callingNum)); + structed_msg.msg.setup.callingNum.flag= 1; + //calling party subaddress + aifg_ie_decode(&(predecoded.msg.setup.callingSubaddr),&dst); + memcpy(&(structed_msg.msg.setup.callingSubAddr),&(dst.param.dt_callingSubAddr), sizeof(dst.param.dt_callingSubAddr)); + structed_msg.msg.setup.callingSubAddr.flag= 1; + //called party BCD number + aifg_ie_decode(&(predecoded.msg.setup.calledBCD),&dst); + memcpy(&(structed_msg.msg.setup.calledNum),&(dst.param.dt_calledNum), sizeof(dst.param.dt_calledNum)); + structed_msg.msg.setup.calledNum.flag= 1; + //called party subaddress + aifg_ie_decode(&(predecoded.msg.setup.calledSubaddr),&dst); + memcpy(&(structed_msg.msg.setup.calledSubAddr),&(dst.param.dt_calledSubAddr), sizeof(dst.param.dt_calledSubAddr)); + structed_msg.msg.setup.calledSubAddr.flag= 1; + //redirecting party BCD + aifg_ie_decode(&(predecoded.msg.setup.redirBCD),&dst); + memcpy(&(structed_msg.msg.setup.redirNum),&(dst.param.dt_redirNum), sizeof(dst.param.dt_redirNum)); + structed_msg.msg.setup.redirNum.flag= 1; + //redirecting party subaddr + aifg_ie_decode(&(predecoded.msg.setup.redirSubaddr),&dst); + memcpy(&(structed_msg.msg.setup.redirSubAddr),&(dst.param.dt_redirSubAddr), sizeof(dst.param.dt_redirSubAddr)); + structed_msg.msg.setup.redirSubAddr.flag= 1; + //LLC repeat indicator + aifg_ie_decode(&(predecoded.msg.setup.reptInd_llc),&dst); + memcpy(&(structed_msg.msg.setup.llc_rpInd),&(dst.param.dt_rpInd), sizeof(dst.param.dt_rpInd)); + structed_msg.msg.setup.llc_rpInd.flag= 1; + //low layer compatibility 1 + aifg_ie_decode(&(predecoded.msg.setup.lowLComp1),&dst); + memcpy(&(structed_msg.msg.setup.loComp1),&(dst.param.dt_loComp), sizeof(dst.param.dt_loComp)); + structed_msg.msg.setup.loComp1.flag= 1; + //low layer compatibility 2 + aifg_ie_decode(&(predecoded.msg.setup.lowLComp2),&dst); + memcpy(&(structed_msg.msg.setup.loComp2),&(dst.param.dt_loComp), sizeof(dst.param.dt_loComp)); + structed_msg.msg.setup.loComp2.flag= 1; + //HLC repeat indicator + aifg_ie_decode(&(predecoded.msg.setup.reptInd_hlc),&dst); + memcpy(&(structed_msg.msg.setup.hlc_rpInd),&(dst.param.dt_rpInd), sizeof(dst.param.dt_rpInd)); + structed_msg.msg.setup.hlc_rpInd.flag= 1; + //high layer compatibility 1 + aifg_ie_decode(&(predecoded.msg.setup.highLComp1),&dst); + memcpy(&(structed_msg.msg.setup.hiComp1),&(dst.param.dt_hiComp), sizeof(dst.param.dt_hiComp)); + structed_msg.msg.setup.hiComp1.flag= 1; + //high layer compatibility 2 + aifg_ie_decode(&(predecoded.msg.setup.highLComp2),&dst); + memcpy(&(structed_msg.msg.setup.hiComp2),&(dst.param.dt_hiComp), sizeof(dst.param.dt_hiComp)); + structed_msg.msg.setup.hiComp2.flag= 1; + //user-user + aifg_ie_decode(&(predecoded.msg.setup.user_user),&dst); + memcpy(&(structed_msg.msg.setup.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.setup.uu.flag= 1; + //priority + aifg_ie_decode(&(predecoded.msg.setup.priority),&dst); + memcpy(&(structed_msg.msg.setup.priority),&(dst.param.dt_priority), sizeof(dst.param.dt_priority)); + structed_msg.msg.setup.priority.flag= 1; + //alert + aifg_ie_decode(&(predecoded.msg.setup.alert),&dst); + memcpy(&(structed_msg.msg.setup.alertPattern),&(dst.param.dt_alertPattern), sizeof(dst.param.dt_alertPattern)); + structed_msg.msg.setup.alertPattern.flag= 1; + + + msg_len = aifg_msg_sd_setup(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x80); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[74][4], msg_len)); + + //for unit test + memcpy(&bm_setup, &structed_msg, sizeof(structed_msg)); +} + +void test_aifg_msg_modify() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[75], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MODIFY; + + //bearer capability + aifg_ie_decode(&(predecoded.msg.modify.bearCap),&dst); + memcpy(&(structed_msg.msg.modify.bc),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.modify.bc.flag= 1; + //low layer compatibility + aifg_ie_decode(&(predecoded.msg.modify.lowLComp),&dst); + memcpy(&(structed_msg.msg.modify.loComp),&(dst.param.dt_loComp), sizeof(dst.param.dt_loComp)); + structed_msg.msg.modify.loComp.flag= 1; + //high layer compatibility + aifg_ie_decode(&(predecoded.msg.modify.highLComp),&dst); + memcpy(&(structed_msg.msg.modify.hiComp),&(dst.param.dt_hiComp), sizeof(dst.param.dt_hiComp)); + structed_msg.msg.modify.hiComp.flag= 1; + //reverse call setup direction + aifg_ie_decode(&(predecoded.msg.modify.revCallSetDir),&dst); + memcpy(&(structed_msg.msg.modify.revCallDir),&(dst.param.dt_revCallDir), sizeof(dst.param.dt_revCallDir)); + structed_msg.msg.modify.revCallDir.flag= 1; + + + msg_len = aifg_msg_sd_modify(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,14); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[75][4], msg_len)); + +} + +void test_aifg_msg_modifyCmp() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[76], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MODIFY_CMP; + + //bearer capability + aifg_ie_decode(&(predecoded.msg.modifyComplete.bearCap),&dst); + memcpy(&(structed_msg.msg.modifyCmp.bc),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.modifyCmp.bc.flag= 1; + //low layer compatibility + aifg_ie_decode(&(predecoded.msg.modifyComplete.lowLComp),&dst); + memcpy(&(structed_msg.msg.modifyCmp.loComp),&(dst.param.dt_loComp), sizeof(dst.param.dt_loComp)); + structed_msg.msg.modifyCmp.loComp.flag= 1; + //high layer compatibility + aifg_ie_decode(&(predecoded.msg.modifyComplete.highLComp),&dst); + memcpy(&(structed_msg.msg.modifyCmp.hiComp),&(dst.param.dt_hiComp), sizeof(dst.param.dt_hiComp)); + structed_msg.msg.modifyCmp.hiComp.flag= 1; + //reverse call setup direction + aifg_ie_decode(&(predecoded.msg.modifyComplete.revCallSetDir),&dst); + memcpy(&(structed_msg.msg.modifyCmp.revCallDir),&(dst.param.dt_revCallDir), sizeof(dst.param.dt_revCallDir)); + structed_msg.msg.modifyCmp.revCallDir.flag= 1; + + + msg_len = aifg_msg_sd_modifyCmp(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,14); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[76][4], msg_len)); + +} + +void test_aifg_msg_modifyRej() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[77], &predecoded); + + structed_msg.id = AIFG_MSG_ID_MODIFY_REJECT; + + //bearer capability + aifg_ie_decode(&(predecoded.msg.modifyRej.bearCap),&dst); + memcpy(&(structed_msg.msg.modifyRej.bc),&(dst.param.dt_bc), sizeof(dst.param.dt_bc)); + structed_msg.msg.modifyRej.bc.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.modifyRej.cause),&dst); + memcpy(&(structed_msg.msg.modifyRej.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.modifyRej.cause.flag= 1; + //low layer compatibility + aifg_ie_decode(&(predecoded.msg.modifyRej.lowLComp),&dst); + memcpy(&(structed_msg.msg.modifyRej.loComp),&(dst.param.dt_loComp), sizeof(dst.param.dt_loComp)); + structed_msg.msg.modifyRej.loComp.flag= 1; + //high layer compatibility + aifg_ie_decode(&(predecoded.msg.modifyRej.highLComp),&dst); + memcpy(&(structed_msg.msg.modifyRej.hiComp),&(dst.param.dt_hiComp), sizeof(dst.param.dt_hiComp)); + structed_msg.msg.modifyRej.hiComp.flag= 1; + + + msg_len = aifg_msg_sd_modifyRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,18); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[77][4], msg_len)); + +} + + +void test_aifg_msg_userInfo() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[78], &predecoded); + + structed_msg.id = AIFG_MSG_ID_USER_INFO; + + //user-user + aifg_ie_decode(&(predecoded.msg.userInfo.user_user),&dst); + memcpy(&(structed_msg.msg.userInfo.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.userInfo.uu.flag= 1; + //more data + aifg_ie_decode(&(predecoded.msg.userInfo.moreDate),&dst); + memcpy(&(structed_msg.msg.userInfo.moreData),&(dst.param.dt_moreData), sizeof(dst.param.dt_moreData)); + structed_msg.msg.userInfo.moreData.flag= 1; + + + msg_len = aifg_msg_sd_userInfo(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[78][4], msg_len)); + +} + +void test_aifg_msg_holdRej() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[79], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HOLD_REJECT; + + //cause + aifg_ie_decode(&(predecoded.msg.holdRej.cause),&dst); + memcpy(&(structed_msg.msg.holdRej.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.holdRej.cause.flag= 1; + + + msg_len = aifg_msg_sd_holdRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[79][4], msg_len)); + +} + +void test_aifg_msg_retrieveRej() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[80], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RETRIEVE_REJECT; + + //cause + aifg_ie_decode(&(predecoded.msg.retrieveRej.cause),&dst); + memcpy(&(structed_msg.msg.retrieveRej.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.retrieveRej.cause.flag= 1; + + + msg_len = aifg_msg_sd_retrieveRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[80][4], msg_len)); + +} + +void test_aifg_msg_disconnect() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[81], &predecoded); + + structed_msg.id = AIFG_MSG_ID_DISCONNECT; + + //cause + aifg_ie_decode(&(predecoded.msg.disconnect.cause),&dst); + memcpy(&(structed_msg.msg.disconnect.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.disconnect.cause.flag= 1; + + // test facility + aifg_ie_decode(&(predecoded.msg.disconnect.facility),&dst); + memcpy(&(structed_msg.msg.disconnect.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.disconnect.facility.flag= 1; + + //progress indicator + aifg_ie_decode(&(predecoded.msg.disconnect.progressInd),&dst); + memcpy(&(structed_msg.msg.disconnect.progInd),&(dst.param.dt_progInd), sizeof(dst.param.dt_progInd)); + structed_msg.msg.disconnect.progInd.flag= 1; + //user-user + aifg_ie_decode(&(predecoded.msg.disconnect.user_user),&dst); + memcpy(&(structed_msg.msg.disconnect.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.disconnect.uu.flag= 1; + + + msg_len = aifg_msg_sd_disconnect(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x41); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[81][4], msg_len)); + +} + +void test_aifg_msg_release() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[82], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RELEASE; + + //cause 1 + aifg_ie_decode(&(predecoded.msg.release.cause1),&dst); + memcpy(&(structed_msg.msg.release.cause1),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.release.cause1.flag= 1; + //cause 2 + aifg_ie_decode(&(predecoded.msg.release.cause2),&dst); + memcpy(&(structed_msg.msg.release.cause2),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.release.cause2.flag= 1; + + // test facility + aifg_ie_decode(&(predecoded.msg.release.facility),&dst); + memcpy(&(structed_msg.msg.release.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.release.facility.flag= 1; + + //user-user + aifg_ie_decode(&(predecoded.msg.release.user_user),&dst); + memcpy(&(structed_msg.msg.release.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.release.uu.flag= 1; + + + msg_len = aifg_msg_sd_release(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x44); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[82][4], msg_len)); + +} + +void test_aifg_msg_releaseCmp() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[83], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RELEASE_CMP; + + //cause + aifg_ie_decode(&(predecoded.msg.releaseComp.cause),&dst); + memcpy(&(structed_msg.msg.releaseCmp.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.releaseCmp.cause.flag= 1; + + //test facility + aifg_ie_decode(&(predecoded.msg.releaseComp.facility),&dst); + memcpy(&(structed_msg.msg.releaseCmp.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.releaseCmp.facility.flag= 1; + + //user-user + aifg_ie_decode(&(predecoded.msg.releaseComp.user_user),&dst); + memcpy(&(structed_msg.msg.releaseCmp.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.releaseCmp.uu.flag= 1; + + + msg_len = aifg_msg_sd_releaseCmp(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x3e); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[83][4], msg_len)); + +} + +void test_aifg_msg_congestCtrl() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[84], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CONGESTION_CTRL; + + //congestion level + aifg_ie_decode(&(predecoded.msg.congestCtrl.congestLev),&dst); + memcpy(&(structed_msg.msg.congestCtrl.congestLevel),&(dst.param.dt_congestLevel), sizeof(dst.param.dt_congestLevel)); + structed_msg.msg.congestCtrl.congestLevel.flag= 1; + //cause + aifg_ie_decode(&(predecoded.msg.congestCtrl.cause),&dst); + memcpy(&(structed_msg.msg.congestCtrl.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.congestCtrl.cause.flag= 1; + + msg_len = aifg_msg_sd_congestCtrl(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,8); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[84][4], msg_len)); + +} + +void test_aifg_msg_notify() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[85], &predecoded); + + structed_msg.id = AIFG_MSG_ID_NOTIFY; + + //notification indicator + aifg_ie_decode(&(predecoded.msg.notify.notifyInd),&dst); + memcpy(&(structed_msg.msg.notify.notificationInd),&(dst.param.dt_notificationInd), sizeof(dst.param.dt_notificationInd)); + structed_msg.msg.notify.notificationInd.flag= 1; + + + msg_len = aifg_msg_sd_notify(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[85][4], msg_len)); + +} + +void test_aifg_msg_status() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[86], &predecoded); + + structed_msg.id = AIFG_MSG_ID_STATUS; + + //cause + aifg_ie_decode(&(predecoded.msg.status.cause),&dst); + memcpy(&(structed_msg.msg.status.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.status.cause.flag= 1; + //call state + aifg_ie_decode(&(predecoded.msg.status.callState),&dst); + memcpy(&(structed_msg.msg.status.callStat),&(dst.param.dt_callStat), sizeof(dst.param.dt_callStat)); + structed_msg.msg.status.callStat.flag= 1; + //auxiliary states + aifg_ie_decode(&(predecoded.msg.status.auxState),&dst); + memcpy(&(structed_msg.msg.status.auxStat),&(dst.param.dt_auxStat), sizeof(dst.param.dt_auxStat)); + structed_msg.msg.status.auxStat.flag= 1; + + + msg_len = aifg_msg_sd_status(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,10); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[86][4], msg_len)); + +} + +void test_aifg_msg_startDTMF() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[87], &predecoded); + + structed_msg.id = AIFG_MSG_ID_START_DTMF; + + //keypad facility + aifg_ie_decode(&(predecoded.msg.startDTMF.keypadFacility),&dst); + memcpy(&(structed_msg.msg.startDTMF.keypad),&(dst.param.dt_keypad), sizeof(dst.param.dt_keypad)); + structed_msg.msg.startDTMF.keypad.flag= 1; + + + msg_len = aifg_msg_sd_startDTMF(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[87][4], msg_len)); + +} + +void test_aifg_msg_startDTMF_ack() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[88], &predecoded); + + structed_msg.id = AIFG_MSG_ID_START_DTMF_ACK; + + //keypad facility + aifg_ie_decode(&(predecoded.msg.startDTMFAck.keypadFacility),&dst); + memcpy(&(structed_msg.msg.startDTMF_ack.keypad),&(dst.param.dt_keypad), sizeof(dst.param.dt_keypad)); + structed_msg.msg.startDTMF_ack.keypad.flag= 1; + + + msg_len = aifg_msg_sd_startDTMFAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,2); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[88][4], msg_len)); + +} + +void test_aifg_msg_startDTMF_rej() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[89], &predecoded); + + structed_msg.id = AIFG_MSG_ID_START_DTMF_REJECT; + + //cause + aifg_ie_decode(&(predecoded.msg.startDTMFRej.cause),&dst); + memcpy(&(structed_msg.msg.startDTMF_rej.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.startDTMF_rej.cause.flag= 1; + + + msg_len = aifg_msg_sd_startDTMFRej(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,6); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[89][4], msg_len)); + +} + + +//////////////////////////////// + +void test_aifg_msg_connectAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[90], &predecoded); + + structed_msg.id = AIFG_MSG_ID_CONNECT_ACK; + + + msg_len = aifg_msg_sd_connectAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[90][4], msg_len)); + +} + +void test_aifg_msg_hold() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[91], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HOLD; + + + msg_len = aifg_msg_sd_hold(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[91][4], msg_len)); + +} + +void test_aifg_msg_holdAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[92], &predecoded); + + structed_msg.id = AIFG_MSG_ID_HOLD_ACK; + + + msg_len = aifg_msg_sd_holdAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[92][4], msg_len)); + +} + +void test_aifg_msg_retrieve() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[93], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RETRIEVE; + + + msg_len = aifg_msg_sd_retrieve(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[93][4], msg_len)); + +} + +void test_aifg_msg_retrieveAck() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[94], &predecoded); + + structed_msg.id = AIFG_MSG_ID_RETRIEVE_ACK; + + + msg_len = aifg_msg_sd_retrieveAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[94][4], msg_len)); + +} + +void test_aifg_msg_statusEnq() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[95], &predecoded); + + structed_msg.id = AIFG_MSG_ID_STATUS_ENQ; + + + msg_len = aifg_msg_sd_statusEnq(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[95][4], msg_len)); + +} + +void test_aifg_msg_stopDTMF() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[96], &predecoded); + + structed_msg.id = AIFG_MSG_ID_STOP_DTMF; + + + msg_len = aifg_msg_sd_stopDTMF(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[96][4], msg_len)); + +} + +void test_aifg_msg_stopDTMF_ack() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[97], &predecoded); + + structed_msg.id = AIFG_MSG_ID_STOP_DTMF_ACK; + + + msg_len = aifg_msg_sd_stopDTMFAck(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,1); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[97][4], msg_len)); + +} + +void test_aifg_msg_facility() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + + //test + aifg_msg_proc(msgsrc[98], &predecoded); + + structed_msg.id = AIFG_MSG_ID_FACILITY; + + //facility + aifg_ie_decode(&(predecoded.msg.facility.facility),&dst); + memcpy(&(structed_msg.msg.facility.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.facility.facility.flag= 1; + + msg_len = aifg_msg_sd_facility(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x32); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[98][4], msg_len)); + +} + + +void test_aifg_msg_disconnect_mobileToNet() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + + //test + aifg_msg_proc(msgsrc[99], &predecoded); + + structed_msg.id = AIFG_MSG_ID_DISCONNECT; + + //cause + aifg_ie_decode(&(predecoded.msg.disconnect.cause),&dst); + memcpy(&(structed_msg.msg.disconnect.cause),&(dst.param.dt_cause), sizeof(dst.param.dt_cause)); + structed_msg.msg.disconnect.cause.flag= 1; + + //facility + aifg_ie_decode(&(predecoded.msg.disconnect.facility),&dst); + memcpy(&(structed_msg.msg.disconnect.facility),&(dst.param.dt_facility), sizeof(dst.param.dt_facility)); + structed_msg.msg.disconnect.facility.flag= 1; + + //user-user + aifg_ie_decode(&(predecoded.msg.disconnect.user_user),&dst); + memcpy(&(structed_msg.msg.disconnect.uu),&(dst.param.dt_uu), sizeof(dst.param.dt_uu)); + structed_msg.msg.disconnect.uu.flag= 1; + + //SS version + aifg_ie_decode(&(predecoded.msg.disconnect.ssVer),&dst); + memcpy(&(structed_msg.msg.disconnect.ssVer),&(dst.param.dt_ssVer), sizeof(dst.param.dt_ssVer)); + structed_msg.msg.disconnect.ssVer.flag= 1; + + msg_len = aifg_msg_sd_disconnect(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len,0x40); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[99][4], msg_len)); +} +/* +void test_aifg_msg_pagingResp() +{ + memset(&l3Info,0,sizeof(l3Info)); + memset(&predecode_l3msg,0,sizeof(predecode_l3msg)); + + //test + aifg_msg_decode_embeded_l3msg(msgsrc[100], &predecode_l3msg); + + l3Info.id = AIFG_MSG_ID_PAGING_RESP; + + //ciphering key sequence number + aifg_ie_decode(&(predecode_l3msg.msg.pagingResp.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.pagingResp.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.pagingResp.cipherKey.flag= 1; + + //Mobile Station Classmark 2 + aifg_ie_decode(&(predecode_l3msg.msg.pagingResp.cm2),&dst); + memcpy(&l3Info.msg.pagingResp.cmInfo2,&dst.param.dt_cmInfo2, sizeof(dst.param.dt_cmInfo2)); + l3Info.msg.pagingResp.cmInfo2.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecode_l3msg.msg.pagingResp.mobileId),&dst); + memcpy(&(l3Info.msg.pagingResp.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.pagingResp.mobileId.flag= 1; + + msg_len = aifg_msg_encode_embeded_l3msg(&l3Info, buffer); + CU_ASSERT_EQUAL(msg_len,16); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[100][0], msg_len)); + + //for unit test + memcpy(&rr_pagingResp, &structed_msg, sizeof(structed_msg)); +} +*/ +void test_aifg_msg_pagingResp() +{ + memset(&structed_msg,0,sizeof(structed_msg)); + memset(&predecoded,0,sizeof(predecoded)); + memset(&l3Info,0,sizeof(l3Info)); + + //test + aifg_msg_proc(msgsrc[100], &predecoded); + + structed_msg.id = AIFG_MSG_ID_L3_INFO; + + //cell identifier + aifg_ie_decode(&(predecoded.msg.completeL3Info.cellId),&dst); + memcpy(&(structed_msg.msg.completeL3Info.cellId),&(dst.param.bm_cellId), sizeof(dst.param.bm_cellId)); + structed_msg.msg.completeL3Info.cellId.flag= 1; + + //layer 3 infomation + //Paging response + structed_msg.msg.completeL3Info.l3Info.ptr = &msgsrc[100][10]; + structed_msg.msg.completeL3Info.l3Info.len = 16; +/* l3Info.id = AIFG_MSG_ID_PAGING_RESP; + //ciphering key sequence number + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.pagingResp.cipherKeySeq),&dst); + memcpy(&(l3Info.msg.pagingResp.cipherKey),&(dst.param.dt_cipherKey), sizeof(dst.param.dt_cipherKey)); + l3Info.msg.pagingResp.cipherKey.flag= 1; + + //Mobile Station Classmark 2 + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.pagingResp.cm2),&dst); + memcpy(&l3Info.msg.pagingResp.cmInfo2,&dst.param.dt_cmInfo2, sizeof(dst.param.dt_cmInfo2)); + l3Info.msg.pagingResp.cmInfo2.flag= 1; + + //mobile identity + aifg_ie_decode(&(predecoded.msg.completeL3Info.l3msg.msg.pagingResp.mobileId),&dst); + memcpy(&(l3Info.msg.pagingResp.mobileId),&(dst.param.mobileId), sizeof(dst.param.mobileId)); + l3Info.msg.pagingResp.mobileId.flag= 1; + + memcpy(&(structed_msg.msg.completeL3Info.l3Info), &l3Info, sizeof(l3Info)); +*/ + //chosen channel + aifg_ie_decode(&(predecoded.msg.completeL3Info.chosenChannel),&dst); + memcpy(&(structed_msg.msg.completeL3Info.chosenChannel),&(dst.param.bm_chosenChannel), sizeof(dst.param.bm_chosenChannel)); + structed_msg.msg.completeL3Info.chosenChannel.flag= 1; + + //LSA identity list + aifg_ie_decode(&(predecoded.msg.completeL3Info.lsaIdList),&dst); + memcpy(&(structed_msg.msg.completeL3Info.lsaIdList),&(dst.param.bm_lsaIdList), sizeof(dst.param.bm_lsaIdList)); + structed_msg.msg.completeL3Info.lsaIdList.flag= 1; + + //location information + aifg_ie_decode(&(predecoded.msg.completeL3Info.locInfo),&dst); + memcpy(&(structed_msg.msg.completeL3Info.locInfo),&(dst.param.bm_locInfo), sizeof(dst.param.bm_locInfo)); + structed_msg.msg.completeL3Info.locInfo.flag= 1; + + msg_len = aifg_msg_sd_completeL3Info(&structed_msg, buffer); + CU_ASSERT_EQUAL(msg_len, 40); + CU_ASSERT_EQUAL(0, memcmp(buffer, &msgsrc[100][2],40)); + + //for unit test use + memcpy(&rr_pagingResp, &structed_msg, sizeof(structed_msg)); +} + + +//////////////////////////////////////////////////////////////////////////// +int aifg_code_test() +{ + CU_pSuite pSuite = NULL; + ie.hi_lo_flag=0; + + aifg_init(); + + /* initialize the CUnit test registry */ + if (CUE_SUCCESS != CU_initialize_registry()) + goto ERR_PROC; + + /* add static test suite to the registry */ + pSuite = CU_add_suite("Test ie encode/decode", NULL, NULL); + if (NULL == pSuite) { + CU_cleanup_registry(); + goto ERR_PROC; + } + + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cic,src={0x01,0x02}", test_aifg_ie_bm_cic)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_resrcAvail,src={0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x00,0x09,0x01,0x03,0x02,0x06,0x00,0x0b}", test_aifg_ie_bm_resrcAvail)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cause,src={0x01,0x09}", test_aifg_ie_bm_cause)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cause_ext,src={0x02,0x89,0x10}", test_aifg_ie_bm_cause_ext)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cellId_00,src={0x08,0x00,0x13,0x42,0x05,0x00,0x02,0x00,0x11}", test_aifg_ie_bm_cellId_00)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cellId_01,src={0x05,0x01,0x00,0x42,0x01,0x03}", test_aifg_ie_bm_cellId_01)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cellId_02,src={0x03,0x02,0x00,0x22}", test_aifg_ie_bm_cellId_02)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_priority,src={0x03,0x42,0x00,0x22}", test_aifg_ie_bm_priority)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_tsmi,src={0x04,0xf7,0x03,0x12,0x2a}", test_aifg_ie_bm_tmsi)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_encryptInfo_Noencryption,src={0x01,0x01}", test_aifg_ie_bm_encryptInfo_NOencryption)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_encryptInfo_A5,src={0x09,0x12,0x08,0x15,0x34,0x67,0xa2,0x8d,0x46,0x8f}", test_aifg_ie_bm_encryptInfo_A5)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_channelType_speech,src={0X04,0X01,0X09,0X83,0X79}", test_aifg_ie_bm_channelType_speech)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_channelType_data,src={0x04,0x02,0x0a,0xf5,0x07}", test_aifg_ie_bm_channelType_data)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_extResourceInd,src={0x02}", test_aifg_ie_bm_extResourceInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cmInfo2,src={0x03,0x7e,0x67,0x82}", test_aifg_ie_bm_cmInfo2)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ //to resolve + /*if (NULL == CU_add_test(pSuite, "aifg_ie_bm_l3Info,src={0x04,0x05,0x21,0x3f,0x58,0xe1}", test_aifg_ie_bm_l3Info)){ + CU_cleanup_registry(); + goto ERR_PROC; + }*/ + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cidList_00,src={0x08,0x00,0x85,0x47,0x9c,0x67,0x24,0x3d,0x05}", test_aifg_ie_bm_cidList_00)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cidList_01,src={0x05,0x01,0x23,0x07,0x4f,0x39}", test_aifg_ie_bm_cidList_01)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cidList_02,src={0x03,0x02,0x77,0x64}", test_aifg_ie_bm_cidList_02)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cidList_04,src={0x06,0x04,0x4e,0x39,0x58,0x7c,0x0a}", test_aifg_ie_bm_cidList_04)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cidList_05,src={0x03,0x05,0x21,0xf3}", test_aifg_ie_bm_cidList_05)){//<<<<<<<<<<<<<<<<<<<<<<<<<<<< + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cicList,src={0x04,0x32,0x12,0x8d,0x36}", test_aifg_ie_bm_cicList)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_diagnostics,src={0x04,0x03,0x0Fa,0x38,0x89}", test_aifg_ie_bm_diagnostics)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_chosenChannel,src={0x56}", test_aifg_ie_bm_chosenChannel)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_totalResrc,src={0x84,0x62,0xf2,0x7e}", test_aifg_ie_bm_totalResrc)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_triggerId,src={0x03,0x9d,0x20,0x81}", test_aifg_ie_bm_triggerId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_mobileId,src={0x02,0x31,0xf2}", test_aifg_ie_bm_mobileId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_circuitPoolList,src={0x05,0x01,0x02,0x03,0x04,0x05}", test_aifg_ie_bm_circuitPoolList)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_resrcSit,src={0x05,0x11,0x83,0x04,0x28,0x75}", test_aifg_ie_bm_resrcSit)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_curChannelType1,src={0x19}", test_aifg_ie_bm_curChannelType1)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_groupRef,src={0x05,0x24,0x38,0x56,0x19,0x10}", test_aifg_ie_bm_groupRef)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_lsaId,src={0x03,0x10,0x39,0xd2}", test_aifg_ie_bm_lsaId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_lsaIdList,src={0x07,0x01,0x22,0xe4,0x31,0x57,0x69,0x83}", test_aifg_ie_bm_lsaIdList)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_lsaInfo,src={0x09,0x00,0x00,0x36,0x85,0xef,0x03,0x47,0x87,0x42}", test_aifg_ie_bm_lsaInfo)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_locInfo,src={0x03,0x15,0x49,0xf5}", test_aifg_ie_bm_locInfo)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_omcId,src={0x03,0x39,0xc4,0x08}", test_aifg_ie_bm_omcId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_bssOldtoNew,src={0X07, ,0X01,0X02, ,0X02,0X06,0X01}", test_aifg_ie_bm_bssOldtoNew)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_periodicity,src={0Xff}", test_aifg_ie_bm_periodicity)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_msNum,src={0Xfe}", test_aifg_ie_bm_msNum)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_bandUsed,src={0x09}", test_aifg_ie_bm_bandUsed)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_rrCause,src={0X08}", test_aifg_ie_bm_rrCause)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_dlci,src={0XC2}", test_aifg_ie_bm_dlci)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_dtx,src={0x01}", test_aifg_ie_bm_dtx)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_resrcIndMethod,src={0X01}}", test_aifg_ie_bm_resrcIndMethod)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_cipherRespMode,src={0X00}", test_aifg_ie_bm_cipherRespMode)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_channelNeeded,src={0X02}", test_aifg_ie_bm_channelNeeded)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_traceType,src={0xdd}", test_aifg_ie_bm_traceType)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_traceRef,src={0x34,0x97}", test_aifg_ie_bm_traceRef)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_transId,src={0x02,0x17,0x62}", test_aifg_ie_bm_transId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_forwardInd,src={0x02}", test_aifg_ie_bm_fowardInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_chosenEncrypt,src={0X03}", test_aifg_ie_bm_chosenEncrypt)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_circuitPool,src={0X10}", test_aifg_ie_bm_circuitPool)){ + CU_cleanup_registry(); + goto ERR_PROC; + }/* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_timeInd,src={0X11}", test_aifg_ie_bm_timeInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_speechVer,src={0X21}", test_aifg_ie_bm_speechVer)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_queuingInd,src={0X02}", test_aifg_ie_bm_queuingInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_assignReq,src={0X01}", test_aifg_ie_bm_assignReq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_eMLPP,src={0X06}", test_aifg_ie_bm_eMLPP)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_configInd,src={0x03}", test_aifg_ie_bm_configInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_bm_tmsi,src={0X04,0X33,0X79,0X27,0X46}", test_aifg_ie_bm_tmsi)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + ////////////////////////TEST DTAP//////////////////////////////// + + /* add test cases to test suite */ + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_broadcastRef,src={0x10,0x34,0x78,0x69,0x20}", test_aifg_ie_dt_broadcastRef)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_cmInfo1,src={0x11}", test_aifg_ie_dt_cmInfo1)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_cmInfo2,src={0x03,0x33,0x22,0x8d}", test_aifg_ie_dt_cmInfo2)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_mobileId,src={0x02,0x73,0xf2}", test_aifg_ie_dt_mobileId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_lai,src={0x78,0xf3,0x64,0x31,0x02}", test_aifg_ie_dt_lai)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_luType,src={0x09}", test_aifg_ie_dt_luType)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_nwName,src={0x03,0x91,0x35,0x64}", test_aifg_ie_dt_nwName)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_tzTime,src={0x07,0x04,0x12,0x0a,0x32,0x14,0xdd}", test_aifg_ie_dt_tzTime)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_progInd,src={0x02,0xc0,0x82}", test_aifg_ie_dt_progInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_uu,src={0x03,0x01,0x19,0x83}", test_aifg_ie_dt_uu)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_bc_0,src={0x02,0x20,0x02}", test_aifg_ie_dt_bc_0)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_bc,src={0x13,0xa3,0xca,0x1a,0x00,0xe4,0x21,0x53,0x5b,0x60,0x21,0x5f,0x47,0xc6}", test_aifg_ie_dt_bc)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_cause,src={0x04,0x47,0xdd,0x96,0x81}", test_aifg_ie_dt_cause)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_ccCap,src={0x01,0x03}", test_aifg_ie_dt_ccCap)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_connNum,src={0x04,0x28,0xa3,0x89,0x37}", test_aifg_ie_dt_connNum)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_connSubAddr,src={0x03,0x88,0x50,0x43}", test_aifg_ie_dt_connSubAddr)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_ssVer,src={0x01,0xdd}", test_aifg_ie_dt_ssVer)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_hiComp,src={0x03,0xa8,0x6e,0xb4}", test_aifg_ie_dt_hiComp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_loComp,src={0x02,0xdd,0xde}", test_aifg_ie_dt_loComp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_callStat,src={0xc2}", test_aifg_ie_dt_callStat)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_auxStat,src={0x01,0x86}", test_aifg_ie_dt_auxStat)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_lsaId,src={0x03,0x11,0x22,0x33}", test_aifg_ie_dt_lsaId)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_rejectCause,src={0X02}", test_aifg_ie_dt_rejectCause)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_cmType,src={0X0B}", test_aifg_ie_dt_cmType)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_cipherKey,src={0X01}", test_aifg_ie_dt_cipherKey)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_priority,src={0X05}", test_aifg_ie_dt_priority)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_idType,src={0X03}", test_aifg_ie_dt_idType)){ + CU_cleanup_registry(); + goto ERR_PROC; + }if (NULL == CU_add_test(pSuite, "aifg_ie_dt_congestLevel,src={0X0F}", test_aifg_ie_dt_congestLevel)){ + CU_cleanup_registry(); + goto ERR_PROC; + }if (NULL == CU_add_test(pSuite, "aifg_ie_dt_notificationInd,src={0x80}", test_aifg_ie_dt_notificationInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + }if (NULL == CU_add_test(pSuite, "aifg_ie_dt_signal,src={0x08}", test_aifg_ie_dt_signal)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_alertPattern,src={0X01,0X07}", test_aifg_ie_dt_alertPattern)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_keypad,src={0X0D}", test_aifg_ie_dt_keypad)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_timeZone,src={0XDD}", test_aifg_ie_dt_timeZone)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_authRAND,src={0X00,0X11,0X22,0X33,0X44,0X55,0X66,0X77,0X88,0X99,0XAA,0XBB,0XCC,0XDD,0XEE,0XFF}", test_aifg_ie_dt_authRAND)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_authSRES,src={0X11,0X12,0X13,0X14}", test_aifg_ie_dt_authSRES)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_rpInd,src={0X01}", test_aifg_ie_dt_rpInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + if (NULL == CU_add_test(pSuite, "aifg_ie_dt_facility", test_aifg_ie_dt_facility)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + + //message decode/encode test + /* add static test suite to the registry */ + pSuite = CU_add_suite("Test message encode/decode", NULL, NULL); + if (NULL == pSuite) { + CU_cleanup_registry(); + goto ERR_PROC; + } + //assign request + if (NULL == CU_add_test(pSuite, "assign request", test_aifg_msg_assignReq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //assign complete + if (NULL == CU_add_test(pSuite, "assign complete", test_aifg_msg_assignComplete)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //assign failure + if (NULL == CU_add_test(pSuite, "assign failure", test_aifg_msg_assignFailure)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //block + if (NULL == CU_add_test(pSuite, "block", test_aifg_msg_block)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //blocking acknowledge +// if (NULL == CU_add_test(pSuite, "blocking acknowledge", test_aifg_msg_blockAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //unblock + if (NULL == CU_add_test(pSuite, "unblock", test_aifg_msg_unblock)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //unblock Ack +// if (NULL == CU_add_test(pSuite, "unblock acknowledge", test_aifg_msg_unblockAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //handover required + if (NULL == CU_add_test(pSuite, "handover required", test_aifg_msg_HORequired)){ + CU_cleanup_registry(); + goto ERR_PROC; + } +/* //handover request + if (NULL == CU_add_test(pSuite, "handover request", test_aifg_msg_HORequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover request ack + if (NULL == CU_add_test(pSuite, "handover request Ack", test_aifg_msg_HORequestAck)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover command + if (NULL == CU_add_test(pSuite, "handover command", test_aifg_msg_HOCmd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover complete + if (NULL == CU_add_test(pSuite, "handover complete", test_aifg_msg_HOComplete)){ + CU_cleanup_registry(); + goto ERR_PROC; + } +*/ //handover candidate enquire + if (NULL == CU_add_test(pSuite, "handover candidate enquire", test_aifg_msg_HOCandidateEnq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover candidate response + if (NULL == CU_add_test(pSuite, "handover candidate response", test_aifg_msg_HOCandidateResp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover failure + if (NULL == CU_add_test(pSuite, "handover failure", test_aifg_msg_HOFailure)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover performed + if (NULL == CU_add_test(pSuite, "handover performed", test_aifg_msg_HOPerformed)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover reject + if (NULL == CU_add_test(pSuite, "handover reject", test_aifg_msg_HOReject)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover succeed + if (NULL == CU_add_test(pSuite, "handover succeed", test_aifg_msg_HOSucceed)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //handover detect + if (NULL == CU_add_test(pSuite, "handover detect", test_aifg_msg_HODetect)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //resource request + if (NULL == CU_add_test(pSuite, "resource request", test_aifg_msg_resrcReq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //resource indication + if (NULL == CU_add_test(pSuite, "resource indication", test_aifg_msg_resrcInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //paging + if (NULL == CU_add_test(pSuite, "paging", test_aifg_msg_paging)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //clear request + if (NULL == CU_add_test(pSuite, "clear request", test_aifg_msg_clearReq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //clear command + if (NULL == CU_add_test(pSuite, "clear command", test_aifg_msg_clearCmd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //reset + if (NULL == CU_add_test(pSuite, "reset", test_aifg_msg_reset)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //overload + if (NULL == CU_add_test(pSuite, "overload", test_aifg_msg_overload)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //MSC invoke trace + if (NULL == CU_add_test(pSuite, "MSC invoke trace", test_aifg_msg_mscInvokeTrace)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //BSC invoke trace + if (NULL == CU_add_test(pSuite, "BSC invoke trace", test_aifg_msg_bscInvokeTrace)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //classmark update + if (NULL == CU_add_test(pSuite, "classmark update", test_aifg_msg_cmUpdate)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //cipher mode command + if (NULL == CU_add_test(pSuite, "cipher mode command", test_aifg_msg_cipherModeCmd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //cipher mode complete + if (NULL == CU_add_test(pSuite, "cipher mode complete", test_aifg_msg_cipherModeComplete)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //cipher mode reject + if (NULL == CU_add_test(pSuite, "cipher mode reject", test_aifg_msg_cipherModeReject)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //complete layer 3 information + if (NULL == CU_add_test(pSuite, "complete layer 3 information", test_aifg_msg_completeL3Info)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //SAPI_n_reject + if (NULL == CU_add_test(pSuite, "SAPI_n_Reject", test_aifg_msg_SAPI_n_Reject)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //reset circuit + if (NULL == CU_add_test(pSuite, "reset circuit", test_aifg_msg_resetCircuit)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //reset circuit Ack +// if (NULL == CU_add_test(pSuite, "reset circuit Ack", test_aifg_msg_resetCircuitAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //circuit group block + if (NULL == CU_add_test(pSuite, "circuit group block", test_aifg_msg_circuitGrpBlk)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //circuit group block Ack +// if (NULL == CU_add_test(pSuite, "circuit group block Ack", test_aifg_msg_circuitGrpBlkAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //circuit group unblock + if (NULL == CU_add_test(pSuite, "circuit group unblock", test_aifg_msg_circuitGrpUnblk)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //circuit group unblock Ack +// if (NULL == CU_add_test(pSuite, "circuit group unblock Ack", test_aifg_msg_circuitGrpUnblkAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //confusion + if (NULL == CU_add_test(pSuite, "confusion", test_aifg_msg_confusion)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //unequipped circuit + if (NULL == CU_add_test(pSuite, "unequipped circuit", test_aifg_msg_unequippedCircuit)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //load indication + if (NULL == CU_add_test(pSuite, "load indication", test_aifg_msg_loadIndication)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //suspend + if (NULL == CU_add_test(pSuite, "suspend", test_aifg_msg_suspend)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //resume + if (NULL == CU_add_test(pSuite, "resume", test_aifg_msg_resume)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //change circuit +// if (NULL == CU_add_test(pSuite, "change circuit", test_aifg_msg_changeCircuit)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //change circuit Ack +// if (NULL == CU_add_test(pSuite, "change circuit Ack", test_aifg_msg_changeCCAck)){ +// CU_cleanup_registry(); +// goto ERR_PROC; +// } + //location information command + if (NULL == CU_add_test(pSuite, "location information command", test_aifg_msg_locCmd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //location information report + if (NULL == CU_add_test(pSuite, "location information report", test_aifg_msg_locReport)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //reset Ack + if (NULL == CU_add_test(pSuite, "reset Ack", test_aifg_msg_resetAck)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //clear complete + if (NULL == CU_add_test(pSuite, "clear complete", test_aifg_msg_clearComplete)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //queuing indication + if (NULL == CU_add_test(pSuite, "queuing indication", test_aifg_msg_queueInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //classmark request + if (NULL == CU_add_test(pSuite, "classmark request", test_aifg_msg_cmkRequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + +//...................................dtap................................................................ + + //location updating accept + if (NULL == CU_add_test(pSuite, "location updating accept", test_aifg_msg_luAccept)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //classmark reject + if (NULL == CU_add_test(pSuite, "classmark reject", test_aifg_msg_cmReject)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + + //location updating reject + if (NULL == CU_add_test(pSuite, "locatin updating reject", test_aifg_msg_luAccept)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //abort + if (NULL == CU_add_test(pSuite, "abort", test_aifg_msg_abort)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //MM status + if (NULL == CU_add_test(pSuite, "MM status", test_aifg_msg_mmStatus)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //loaction updating request + if (NULL == CU_add_test(pSuite, "location updating request", test_aifg_msg_luRequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //authentication request + if (NULL == CU_add_test(pSuite, "authentication request", test_aifg_msg_authRequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //authentication response + if (NULL == CU_add_test(pSuite, "authentication response", test_aifg_msg_authResp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //identity request + if (NULL == CU_add_test(pSuite, "identity request", test_aifg_msg_idRequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //identity response + if (NULL == CU_add_test(pSuite, "identity response", test_aifg_msg_idResp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //IMSI detach indication + if (NULL == CU_add_test(pSuite, "IMSI detach indication", test_aifg_msg_imsiDetachInd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //TMSI command + if (NULL == CU_add_test(pSuite, "TMSI command", test_aifg_msg_tmsiCmd)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //CM re-establishment request + if (NULL == CU_add_test(pSuite, "CM re-establishment request", test_aifg_msg_cmReEst_Request)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //CM service request + if (NULL == CU_add_test(pSuite, "CM service request", test_aifg_msg_cmRequest)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //MM information + if (NULL == CU_add_test(pSuite, "MM information", test_aifg_msg_mmInfo)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //alerting + if (NULL == CU_add_test(pSuite, "alerting", test_aifg_msg_alert)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //call confirmed + if (NULL == CU_add_test(pSuite, "call confirmed", test_aifg_msg_callConfirm)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //call proceeding + if (NULL == CU_add_test(pSuite, "call proceeding", test_aifg_msg_callProceed)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //connect + if (NULL == CU_add_test(pSuite, "connect", test_aifg_msg_connect)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //emergency setup + if (NULL == CU_add_test(pSuite, "emergency setup", test_aifg_msg_eSetup)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //progress + if (NULL == CU_add_test(pSuite, "progress", test_aifg_msg_progress)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //setupu + if (NULL == CU_add_test(pSuite, "setup", test_aifg_msg_setup)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //modify + if (NULL == CU_add_test(pSuite, "modify", test_aifg_msg_modify)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //modify complete + if (NULL == CU_add_test(pSuite, "modify complete", test_aifg_msg_modifyCmp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //modify reject + if (NULL == CU_add_test(pSuite, "modify reject", test_aifg_msg_modifyRej)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //user information + if (NULL == CU_add_test(pSuite, "user information", test_aifg_msg_userInfo)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //hold reject + if (NULL == CU_add_test(pSuite, "hold reject", test_aifg_msg_holdRej)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //retrieve reject + if (NULL == CU_add_test(pSuite, "retrieve reject", test_aifg_msg_retrieveRej)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //disconnect + if (NULL == CU_add_test(pSuite, "disconnect", test_aifg_msg_disconnect)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //release + if (NULL == CU_add_test(pSuite, "release", test_aifg_msg_release)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //release complete + if (NULL == CU_add_test(pSuite, "release complete", test_aifg_msg_releaseCmp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //congestion control + if (NULL == CU_add_test(pSuite, "congestion control", test_aifg_msg_congestCtrl)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //notify + if (NULL == CU_add_test(pSuite, "notify", test_aifg_msg_notify)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //status + if (NULL == CU_add_test(pSuite, "status", test_aifg_msg_status)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //start DTMF + if (NULL == CU_add_test(pSuite, "start DTMF", test_aifg_msg_startDTMF)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //start DTMF acknowledge + if (NULL == CU_add_test(pSuite, "start DTMF acknowledge", test_aifg_msg_startDTMF_ack)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //start DTMF reject + if (NULL == CU_add_test(pSuite, "start DTMF reject", test_aifg_msg_startDTMF_rej)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //connect acknowledge + if (NULL == CU_add_test(pSuite, "connect acknowledge", test_aifg_msg_connectAck)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //hold + if (NULL == CU_add_test(pSuite, "hold", test_aifg_msg_hold)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //hold acknowledge + if (NULL == CU_add_test(pSuite, "hold acknowledge", test_aifg_msg_holdAck)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //retrieve + if (NULL == CU_add_test(pSuite, "retrieve", test_aifg_msg_retrieve)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //retrieve acknowledge + if (NULL == CU_add_test(pSuite, "retrieve acknowledge", test_aifg_msg_retrieveAck)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //status enquiry + if (NULL == CU_add_test(pSuite, "status enquiry", test_aifg_msg_statusEnq)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //stop DTMF + if (NULL == CU_add_test(pSuite, "stop DTMF", test_aifg_msg_stopDTMF)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //stop DTMF acknowledge + if (NULL == CU_add_test(pSuite, "stop DTMF acknowledge", test_aifg_msg_stopDTMF_ack)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //facility + if (NULL == CU_add_test(pSuite, "facility", test_aifg_msg_facility)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //disconnect(mobile station to network) + if (NULL == CU_add_test(pSuite, "disconnect_mobileToNet", test_aifg_msg_disconnect_mobileToNet)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + //paging response + if (NULL == CU_add_test(pSuite, "paging response", test_aifg_msg_pagingResp)){ + CU_cleanup_registry(); + goto ERR_PROC; + } + + /* Run all tests using the automated interface */ +// CU_basic_set_mode(CU_BRM_VERBOSE); +// CU_basic_run_tests(); + CU_automated_run_tests(); + CU_list_tests_to_file(); + /* Clean up registry and return */ + CU_cleanup_registry(); + return 1; + +ERR_PROC: + return 0; +} + +//Dynamic test---------------------------------------------------------------------- +//stub function definition +#define MSC_SPC 0 +#define BSC_SPC 1 +#define MSC_PORT 4321 +#define BSC_PORT 1234 +#define MSC_LINK 10 +#define BSC_LINK 20 + +int bsc_cg, msc_cg; +SP_UiPriPara msg_buffer[64]; +int pMsg_h = 0 ,pMsg_t = 0; +aifg_msg_pre_decoded aifg_msg; + +static u8 ascii[16] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, + 0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; +void HexToDisplay(u8 *from_hex, u8 from_len) +{ + int i = 0; + + for (i = 0; i < from_len; i++) + { + putchar(ascii[from_hex[i] >> 4]); + putchar(ascii[from_hex[i] & 0x0f]); + putchar(' '); + } + putchar('\n'); +} + +int PostSp ( SP_UiPriPara * pUiPriParam ) +{ + if(pMsg_h != ((pMsg_t+1) & 0x3F)){ + printf("\nSCCP SD:"); + switch(pUiPriParam->uUiPri){ + case N_UNITDATA_REQ: + if(pUiPriParam->tPriUnion.tPriNUDataReq.tCDA.DPC == BSC_SPC) + pUiPriParam->tPriUnion.tPriNUDataReq.tCGA.DPC = MSC_SPC; + else + pUiPriParam->tPriUnion.tPriNUDataReq.tCGA.DPC = BSC_SPC; + + msg_buffer[pMsg_t].uUiPri = N_UNITDATA_IND; + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNUDataInd.tCDA, + &pUiPriParam->tPriUnion.tPriNUDataReq.tCDA, + sizeof(pUiPriParam->tPriUnion.tPriNUDataReq.tCDA)); + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNUDataInd.tCGA, + &pUiPriParam->tPriUnion.tPriNUDataReq.tCGA, + sizeof(pUiPriParam->tPriUnion.tPriNUDataReq.tCGA)); + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNUDataInd.tUD, + &pUiPriParam->tPriUnion.tPriNUDataReq.tUD, + sizeof(pUiPriParam->tPriUnion.tPriNUDataReq.tUD)); + + printf("TYPE: UDT\n"); + printf("%d => %d\n", + pUiPriParam->tPriUnion.tPriNUDataInd.tCGA.DPC, + pUiPriParam->tPriUnion.tPriNUDataInd.tCDA.DPC); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNUDataReq.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNUDataReq.tUD.uDataLen); + break; + + case N_CONNECT_REQ: + if(MSC_SPC == pUiPriParam->tPriUnion.tPriNConnReq.tCDA.DPC){ + pUiPriParam->wConnId = BSC_LINK; + msg_buffer[pMsg_t].wConnId = MSC_LINK; + } + else{ + pUiPriParam->wConnId = MSC_LINK; + msg_buffer[pMsg_t].wConnId = BSC_LINK; + } + msg_buffer[pMsg_t].uUiPri = N_CONNECT_IND; + msg_buffer[pMsg_t].tPriUnion.tPriNConnInd.uOptFlag = 0x04; + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNConnInd.tCDA, + &pUiPriParam->tPriUnion.tPriNConnReq.tCDA, + sizeof(pUiPriParam->tPriUnion.tPriNConnReq.tCDA)); + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNConnInd.tUD, + &pUiPriParam->tPriUnion.tPriNConnReq.tUD, + sizeof(pUiPriParam->tPriUnion.tPriNUDataReq.tUD)); + + printf("TYPE: CR\n"); + printf("CDA: %d\n", pUiPriParam->tPriUnion.tPriNConnReq.tCDA.DPC); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNConnReq.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNConnReq.tUD.uDataLen); + break; + + case N_CONNECT_RSP: + if(pUiPriParam->wConnId == MSC_LINK) + msg_buffer[pMsg_t].wConnId = BSC_LINK; + else + msg_buffer[pMsg_t].wConnId = MSC_LINK; + + msg_buffer[pMsg_t].uUiPri = N_CONNECT_CFM; + + if(0x08 == pUiPriParam->tPriUnion.tPriNConnRsp.uOptFlag) + msg_buffer[pMsg_t].tPriUnion.tPriNConnCfm.uOptFlag = 0x04; + else + msg_buffer[pMsg_t].tPriUnion.tPriNConnCfm.uOptFlag = 0; + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNConnCfm.tUD, + &pUiPriParam->tPriUnion.tPriNConnRsp.tUD, + sizeof(pUiPriParam->tPriUnion.tPriNConnRsp.tUD)); + + printf("TYPE: CC\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNConnRsp.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNConnRsp.tUD.uDataLen); + break; + + case N_DISCONNECT_REQ: + if(pUiPriParam->wConnId == MSC_LINK) + msg_buffer[pMsg_t].wConnId = BSC_LINK; + else + msg_buffer[pMsg_t].wConnId = MSC_LINK; + msg_buffer[pMsg_t].uUiPri = N_DISCONNECT_IND; + printf("TYPE: RLSD\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + break; + + case N_DATA_REQ: + if(pUiPriParam->wConnId == MSC_LINK) + msg_buffer[pMsg_t].wConnId = BSC_LINK; + else + msg_buffer[pMsg_t].wConnId = MSC_LINK; + + msg_buffer[pMsg_t].uUiPri = N_DATA_IND; + memcpy(&msg_buffer[pMsg_t].tPriUnion.tPriNDataInd.tUD, + &pUiPriParam->tPriUnion.tPriNDataReq.tUD, + sizeof(pUiPriParam->tPriUnion.tPriNDataReq.tUD)); + + printf("TYPE: DT1\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNDataReq.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNDataReq.tUD.uDataLen); + break; + + default: + assert(0); + break; + } + + pMsg_t = ((pMsg_t + 1) & 0x3F); + } + + return 0; +} + +int SpSubmit ( SP_UiPriPara * pUiPriParam , BYTE uUlSapId ) +{ + if(pMsg_h != pMsg_t){ + memcpy(pUiPriParam, &msg_buffer[pMsg_h], sizeof(SP_UiPriPara)); + pMsg_h = ((pMsg_h + 1) & 0x3F); + + //print + printf("\nSCCP RV:"); + switch(pUiPriParam->uUiPri){ + case N_UNITDATA_IND: + printf("TYPE: UDT\n"); + printf("%d <= %d\n", + pUiPriParam->tPriUnion.tPriNUDataInd.tCDA.DPC, + pUiPriParam->tPriUnion.tPriNUDataInd.tCGA.DPC); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNUDataInd.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNUDataInd.tUD.uDataLen); + break; + + case N_CONNECT_IND: + printf("TYPE: CR\n"); + printf("CDA: %d\n", pUiPriParam->tPriUnion.tPriNConnInd.tCDA.DPC); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNConnInd.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNConnInd.tUD.uDataLen); + break; + + case N_CONNECT_CFM: + printf("TYPE: CC\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNConnCfm.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNConnCfm.tUD.uDataLen); + break; + + case N_DISCONNECT_IND: + printf("TYPE: RLC\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + break; + + case N_DATA_IND: + printf("TYPE: DT1\n"); + printf("LINK ID: %d\n", pUiPriParam->wConnId); + printf("CONTENT: "); + HexToDisplay(pUiPriParam->tPriUnion.tPriNDataInd.tUD.aUserData, + pUiPriParam->tPriUnion.tPriNDataInd.tUD.uDataLen); + break; + + default: + assert(0); + break; + } + + return 1; + } + return 0; +} + +int test_call_back_msc(aifg_indication ind, aifg_msg_pre_decoded *msg) +{ + printf("MSC call back called\n"); + memcpy(&aifg_msg, msg, sizeof(aifg_msg)); + + if(msg->port == -1){ + msg->port = MSC_PORT; + } + + return 1; +} + + +int test_call_back_bsc(aifg_indication ind, aifg_msg_pre_decoded *msg) +{ + printf("BSC call back called\n"); + memcpy(&aifg_msg, msg, sizeof(aifg_msg)); + + if(msg->port == -1){ + msg->port = BSC_PORT; + } + + return 1; +} + +//end of stub function definition + +int test_aifg_reset_proc() +{ + int i=0; + + //Precondition + printf("\nTest case: Creating and reseting circuit group\n"); + aifg_bind(AIFG_SAP_MSC, test_call_back_msc); + aifg_bind(AIFG_SAP_BSC, test_call_back_bsc); + msc_cg = aifg_createCircuitGroup(AIFG_SAP_MSC, BSC_SPC, AIFG_NI_INTERNATIONAL); + bsc_cg = aifg_createCircuitGroup(AIFG_SAP_BSC, MSC_SPC, AIFG_NI_INTERNATIONAL); + aifg_set_running_mode(AIFG_RUN_MODE_SINGLE, 0); + + //waiting reset completed + while(i++ < 6000){ + aifg_proc(); + } + + //Post condition + + printf("\nTest case: Creating and reseting circuit group completed!\n"); + return 1; +} + +int test_aifg_sccp_link_setup() +{ + int msc_status = 0; + int bsc_status = 0; + + printf("\nTest case: Sccp link setup and release\n"); + + while(1){ + switch(bsc_status){ + case 0: //send complete l3 information + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &bm_completeL3); + bsc_status++; + break; + + case 1: //wait cm accept + if(aifg_msg.type == AIFG_MSG_ID_CM_ACCEPT) + bsc_status++; + break; + + case 2: //send clear request + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &bm_clearReq); + bsc_status++; + break; + + case 3: //wait clear command + if(aifg_msg.type == AIFG_MSG_ID_CLR_CMD) + bsc_status++; + break; + + case 4: //send clear completed + bm_clearComplete.id = AIFG_MSG_ID_CLR_CMP; + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &bm_clearComplete); + bsc_status++; + break; + + default: + break; + } + + switch(msc_status){ + case 0: //wait complete l3 information + if(aifg_msg.type == AIFG_MSG_ID_L3_INFO) + msc_status++; + break; + + case 1: //send cm service accept + dt_cmAccept.id = AIFG_MSG_ID_CM_ACCEPT; + aifg_send(AIFG_SAP_MSC, msc_cg, MSC_PORT, &dt_cmAccept); + msc_status++; + break; + + case 2: //wait clear request + if(aifg_msg.type == AIFG_MSG_ID_CLR_REQ) + msc_status++; + break; + + case 3: //send clear command + aifg_send(AIFG_SAP_MSC, msc_cg, MSC_PORT, &bm_clearCmd); + msc_status++; + break; + + case 4: //wait clear completed + if(aifg_msg.type == AIFG_MSG_ID_CLR_CMP) + msc_status++; + break; + + default: + printf("Test case: Sccp link setup and release completed!\n"); + return 1; + break; + } + + aifg_proc(); + } + + return 0; +} + +int test_aifg_paging() +{ + int msc_status = 0; + int bsc_status = 0; + + printf("\nTest case: Paging procedure\n"); + + while(1){ + switch(msc_status){ + case 0: //send paging request + aifg_paging(AIFG_SAP_MSC, msc_cg, MSC_PORT, &bm_paging); + msc_status++; + break; + + case 1: //wait paging resp + if(aifg_msg.type == AIFG_MSG_ID_L3_INFO + && aifg_msg.msg.completeL3Info.l3msg.id == AIFG_MSG_ID_PAGING_RESP) + msc_status++; + break; + + case 2: //send setup + aifg_send(AIFG_SAP_MSC, msc_cg, MSC_PORT, &bm_setup); + msc_status++; + break; + + case 3: //wait call confirm + if(aifg_msg.type == AIFG_MSG_ID_CALL_CONFIRMED) + msc_status++; + break; + + case 4: //send clear command + aifg_send(AIFG_SAP_MSC, msc_cg, MSC_PORT, &bm_clearCmd); + msc_status++; + break; + + case 5: //wait clear completed + if(aifg_msg.type == AIFG_MSG_ID_CLR_CMP) + msc_status++; + break; + + default: + printf("Test case: Paging procedure completed!\n"); + return 1; + break; + } + + switch(bsc_status){ + case 0: //wait paging request + if(aifg_msg.type == AIFG_MSG_ID_PAGING){ + bsc_status++; + memset(&aifg_msg, 0, sizeof(aifg_msg)); + } + break; + + case 1: //wait a second paging request + if(aifg_msg.type == AIFG_MSG_ID_PAGING){ + bsc_status++; + } + break; + + case 2: //send paging response + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &rr_pagingResp); + bsc_status++; + break; + + case 3: //wait setup + if(aifg_msg.type == AIFG_MSG_ID_SETUP){ + bsc_status++; + } + break; + + case 4: //send call confirm + dt_callCfm.id = AIFG_MSG_ID_CALL_CONFIRMED; + dt_callCfm.msg.dtap_msg.ptr = msgsrc[69]; + dt_callCfm.msg.dtap_msg.len = 34; + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &dt_callCfm); + bsc_status++; + break; + + case 5: //wait clear cmd + if(aifg_msg.type == AIFG_MSG_ID_CLR_CMD) + bsc_status++; + break; + + case 6: //send clear complete + bm_clearComplete.id = AIFG_MSG_ID_CLR_CMP; + aifg_send(AIFG_SAP_BSC, bsc_cg, BSC_PORT, &bm_clearComplete); + bsc_status++; + break; + + default: + break; + } + + aifg_proc(); + } + + printf("\nTest case: Paging completed\n"); + return 0; +} + +int aifg_unit_test() +{ + int status = 0; + + //init + pMsg_h = pMsg_t = 0; + aifg_init(); + + while(1){ + switch(status){ + case 0: + //creat sap and circuit group + if(1 == test_aifg_reset_proc()) + status++; + break; + + case 1: + //setup up sccp link + if(1 == test_aifg_sccp_link_setup()) + status++; + break; + + + case 2: + //paging + if(1 == test_aifg_paging()) + status++; + break; + + default: + goto FINISH; + break; + } + } + +FINISH: + return 0; +} + diff --git a/omc/plat/aif/ut/makefile b/omc/plat/aif/ut/makefile new file mode 100644 index 0000000..f299966 --- /dev/null +++ b/omc/plat/aif/ut/makefile @@ -0,0 +1,40 @@ +#WXC2 R9.0 AIFG makefile +#Create by Roy Jiang +#2007-3-12 + +CC = gcc +CFLAG = -g -Wall -c #-fprofile-arcs -ftest-coverage + +AIFG_LIB_OBJ = aifg_m.o aifg.o aifg_mpp.o aifg_debug.o aifg_ie.o +AIFG_TST_OBJ = aifg_main.o aifg_test.o + +AIFG_LIB = -L../lib -laif +TEST_LIB = -L/usr/local/lib/CUnit -lcunit -lgcov + +aifg_main: $(AIFG_TST_OBJ) + $(CC) $(AIFG_TST_OBJ) -o test_main $(AIFG_LIB) $(TEST_LIB) + +aifg_main.o: aifg_main.c + $(CC) $(CFLAG) $< + +aifg_test.o: aifg_test.c + $(CC) $(CFLAG) $< + +aifg.o: aifg.c + $(CC) $(CFLAG) $< + +aifg_m.o: aifg_m.c + $(CC) $(CFLAG) $< + +aifg_mpp.o: aifg_mpp.c + $(CC) $(CFLAG) $< + +aifg_debug.o: aifg_debug.c + $(CC) $(CFLAG) $< + +aifg_ie.o: aifg_ie.c + $(CC) $(CFLAG) $< + +clean: + rm -f main *.o *.a *.xml *.gcov *.gcda *.gcno core test_main + diff --git a/omc/plat/bicc/.copyarea.db b/omc/plat/bicc/.copyarea.db new file mode 100644 index 0000000..1c553f9 --- /dev/null +++ b/omc/plat/bicc/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\bicc +2 +6 +3:doc|2|0|0|0|bb796660bfa411dc8505001c23e19543|0 +2:ut|2|0|0|0|c7696890bfa411dc8505001c23e19543|0 +3:src|2|0|0|0|96f644919a8511dd8b36001c23e19543|0 +7:src.old|2|0|0|0|95c644659a8511dd8b36001c23e19543|0 +8:Makefile|1|11d70a3e184|b31|3d53c002|bca96698bfa411dc8505001c23e19543|0 +3:lib|2|0|0|0|bc09667cbfa411dc8505001c23e19543|0 diff --git a/omc/plat/bicc/Makefile b/omc/plat/bicc/Makefile new file mode 100644 index 0000000..b2bd77f --- /dev/null +++ b/omc/plat/bicc/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module template : V1.6.3 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + +MODULE = bicc +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/bicc/lib/libbicc.a b/omc/plat/bicc/lib/libbicc.a new file mode 100644 index 0000000..13d4ca9 Binary files /dev/null and b/omc/plat/bicc/lib/libbicc.a differ diff --git a/omc/plat/bicc/obj/bicc_apm.o b/omc/plat/bicc/obj/bicc_apm.o new file mode 100644 index 0000000..be6daa3 Binary files /dev/null and b/omc/plat/bicc/obj/bicc_apm.o differ diff --git a/omc/plat/bicc/obj/bicc_debug.o b/omc/plat/bicc/obj/bicc_debug.o new file mode 100644 index 0000000..7b4be40 Binary files /dev/null and b/omc/plat/bicc/obj/bicc_debug.o differ diff --git a/omc/plat/bicc/obj/bicc_fsm.o b/omc/plat/bicc/obj/bicc_fsm.o new file mode 100644 index 0000000..8522979 Binary files /dev/null and b/omc/plat/bicc/obj/bicc_fsm.o differ diff --git a/omc/plat/bicc/obj/bicc_ipbcp.o b/omc/plat/bicc/obj/bicc_ipbcp.o new file mode 100644 index 0000000..6ccf356 Binary files /dev/null and b/omc/plat/bicc/obj/bicc_ipbcp.o differ diff --git a/omc/plat/bicc/obj/bicc_msg.o b/omc/plat/bicc/obj/bicc_msg.o new file mode 100644 index 0000000..e1911cf Binary files /dev/null and b/omc/plat/bicc/obj/bicc_msg.o differ diff --git a/omc/plat/bicc/obj/bicc_prm.o b/omc/plat/bicc/obj/bicc_prm.o new file mode 100644 index 0000000..4abcb9d Binary files /dev/null and b/omc/plat/bicc/obj/bicc_prm.o differ diff --git a/omc/plat/bicc/obj/biccif.o b/omc/plat/bicc/obj/biccif.o new file mode 100644 index 0000000..76bce92 Binary files /dev/null and b/omc/plat/bicc/obj/biccif.o differ diff --git a/omc/plat/bicc/src.old/.copyarea.db b/omc/plat/bicc/src.old/.copyarea.db new file mode 100644 index 0000000..bfd2712 --- /dev/null +++ b/omc/plat/bicc/src.old/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\bicc\src.old +2 +9 +a:bicc_prm.c|1|11d70a3e27e|33ed|1c8d9a4|e15481366cf311dd91a5001c23e19543|0 +a:bicc_fsm.c|1|11d70a3e433|f45c|d7758e91|5c364a229a8611dd8b36001c23e19543|0 +e:bicc_fsm.c.old|1|11d70a3e3f5|f45c|d7758e91|5b0649aa9a8611dd8b36001c23e19543|0 +a:bicc_msg.c|1|11d70a3e2fb|8563|a0fc75de|e1f481666cf311dd91a5001c23e19543|0 +a:bicc_apm.c|1|11d70a3e2ad|1363|b56b34ff|e1f4814e6cf311dd91a5001c23e19543|0 +7:include|2|0|0|0|c1696778bfa411dc8505001c23e19543|0 +c:bicc_debug.c|1|11d70a3e32a|54e6|55931a29|e294817e6cf311dd91a5001c23e19543|0 +8:biccif.c|1|11d70a3e3b6|800d|713cda1f|56e6486a9a8611dd8b36001c23e19543|0 +c:bicc_ipbcp.c|1|11d70a3e368|1e3d|81f3ff1f|e32481ae6cf311dd91a5001c23e19543|0 diff --git a/omc/plat/bicc/src.old/bicc_apm.c b/omc/plat/bicc/src.old/bicc_apm.c new file mode 100644 index 0000000..90039f9 --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_apm.c @@ -0,0 +1,206 @@ +#include +#include +#include "./include/q765_5e.h" + +void apm_decode_action(ActionInd_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_action(u8 *flw_ptr, const ActionInd_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_bncid(BncId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->len = length - 1; + memcpy(ptr->val, flw_ptr+1, ptr->len); +} + +u32 apm_encode_bncid(u8 *flw_ptr, const BncId_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + memcpy(flw_ptr+1, ptr->val, ptr->len); + return ptr->len + 1; +} + +void apm_decode_bncchr(BncChr_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_bncchr(u8 *flw_ptr, const BncChr_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_bcinfo(BcInfo_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->bctp.bvei = (flw_ptr[1] >> 6) & 0x01; + ptr->bctp.btcp_version = flw_ptr[1] & 0x1f; + ptr->bctp.tpei = (flw_ptr[2] >> 6) & 0x01; + ptr->bctp.tunnel_protocol = flw_ptr[2] & 0x3f; + ptr->bctp.ipbcp_len = length - 3; + memcpy(ptr->bctp.ipbcp_content, flw_ptr+3, ptr->bctp.ipbcp_len); +} + +u32 apm_encode_bcinfo(u8 *flw_ptr, const BcInfo_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = (ptr->bctp.bvei << 6) + (1 << 5) + ptr->bctp.btcp_version; + flw_ptr[2] = (ptr->bctp.tpei << 6) + ptr->bctp.tunnel_protocol; + memcpy(flw_ptr+3, ptr->bctp.ipbcp_content, ptr->bctp.ipbcp_len); + return ptr->bctp.ipbcp_len + 3; +} + +void apm_decode_bctunnel(BcTunnel_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_bctunnel(u8 *flw_ptr, const BcTunnel_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_signaltype(SignalType_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_signaltype(u8 *flw_ptr, const SignalType_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_duration(Duration_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = (flw_ptr[1] << 8) + flw_ptr[2]; +} + +u32 apm_encode_duration(u8 *flw_ptr, const Duration_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val >> 8; + flw_ptr[2] = ptr->val & 0xff; + return 3; +} + +void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length) +{ + const u8 *old_ptr = flw_ptr; + + while(flw_ptr+flw_ptr[1]+2-old_ptr <= length) + { + if(*flw_ptr == 0) + break; + switch(*flw_ptr) + { + case AP_ACTION: + apm_decode_action(&ptr->action, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BNCID: + apm_decode_bncid(&ptr->bnc_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BNCCHR: + apm_decode_bncchr(&ptr->bnc_chr, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BCINFO: + apm_decode_bcinfo(&ptr->bc_info, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BCTUNNEL: + apm_decode_bctunnel(&ptr->bc_tunnel, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_SIGNALTYPE: + apm_decode_signaltype(&ptr->signal_type, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_DURATION: + apm_decode_duration(&ptr->duration, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } +} + +u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr) +{ + u8 *old_ptr = flw_ptr; + + if(ptr->action.pres == 1) + { + flw_ptr[0] = AP_ACTION; + flw_ptr[1] = apm_encode_action(flw_ptr+2, &ptr->action); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bnc_id.pres == 1) + { + flw_ptr[0] = AP_BNCID; + flw_ptr[1] = apm_encode_bncid(flw_ptr+2, &ptr->bnc_id); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bnc_chr.pres == 1) + { + flw_ptr[0] = AP_BNCCHR; + flw_ptr[1] = apm_encode_bncchr(flw_ptr+2, &ptr->bnc_chr); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bc_info.pres == 1) + { + flw_ptr[0] = AP_BCINFO; + flw_ptr[1] = apm_encode_bcinfo(flw_ptr+2, &ptr->bc_info); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bc_tunnel.pres == 1) + { + flw_ptr[0] = AP_BCTUNNEL; + flw_ptr[1] = apm_encode_bctunnel(flw_ptr+2, &ptr->bc_tunnel); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->signal_type.pres == 1) + { + flw_ptr[0] = AP_SIGNALTYPE; + flw_ptr[1] = apm_encode_signaltype(flw_ptr+2, &ptr->signal_type); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->duration.pres == 1) + { + flw_ptr[0] = AP_DURATION; + flw_ptr[1] = apm_encode_duration(flw_ptr+2, &ptr->duration); + flw_ptr += flw_ptr[1] + 2; + } + return flw_ptr - old_ptr; +} + + diff --git a/omc/plat/bicc/src.old/bicc_debug.c b/omc/plat/bicc/src.old/bicc_debug.c new file mode 100644 index 0000000..9182253 --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_debug.c @@ -0,0 +1,882 @@ +#include "./include/var_ext.h" + +//static u32 bicc_object_id[BICC_PREOID_LEN] = {1,3,6,1,4,1,1373,1,3,2,2,6}; +//static u16 bicc_sub_page[BICC_DEBUG_PAGE] = {0}; +//static u8 bicc_ascii_in[BICC_ASCIN_LEN] = {0}; +//static u8 bicc_ascii_out[BICC_ASCOUT_LEN] = {0}; + +#define BICC_DEBUG_ID 17 +#define BICC_VER_DEBUG "R91V0_01" + +#define MONITOR_NONE 0x0000 +#define MONITOR_ERROR 0x0010 +#define MONITOR_ALL 0xffff + +#define TRACE_FLAG_ON 1 +#define TRACE_FLAG_OFF 0 + +u8 AsciInBuf[4096]; +u8 AsciOutBuf[4096]; +u8 AsciTempBuf[4096]; +WORD MonitorFg; +u8 info[1024]; + +static u8 log_help[] = { + "BICC debug Help:\n\r\ + \n\r\ + 1.help\n\r\ + 2.log all/none\n\r\ + 3.log error on/off\n\r\ + 4.list cg[-cgNo] \n\r\ + 5.list circuit[-circuitNo]\n\r\ + 6.list port[-portNo]\n\r\ + 7.list dmp\n\r\ + 8.trace on-portNo\n\r\ + 9.trace off[-portNo]\n\r\n\r\ +" +}; + +static WORD disp_page[10]; +static u8 *disp_ptr = (u8 *) disp_page; + +static DWORD debug_status_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1 +}; + +static BYTE debug_status = 1; + +static DWORD debug_name_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,2 +}; + +static DWORD debug_ascin_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,3 +}; + +static DWORD debug_ascout_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,4 +}; + +static DWORD debug_page_title[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,1 +}; + +static DWORD debug_page_line[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,2,1 +}; + +const static u8 BASE_ID_LEN = 15; +const static u8 PAGE_POINT = 14; +const static u8 LINE_POINT = 15; + +static u8 title1_p[] = +{ +" BICC Page 01 SAP Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +CG num\n\r" +}; + +static u8 title2_p[] = +{ +" BICC Page 02 CG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SAP id\n\r\ +NI\n\r\ +DPC\n\r" +}; + +static u8 title3_p[] = +{ +" BICC Page 03 CIrcuit Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +CG id\n\r\ +CIC range\n\r\ +HEAD CIC\n\r" +}; + +static u8 title4_p[] = +{ +" BICC Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +FSM State\n\r\ +CIC State\n\r" +}; + +static u8 debug_disp_line(u8 page, u8 line) +{ + u8 disp_length; + disp_length = 0; + disp_ptr = (u8 *) disp_page; + switch (page) + { +/* + case 1: // Page 1: sap Info + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + break; + case 1: + disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_enable; + disp_length = 16; + break; + case 2: + disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_cg_num; + disp_length = 16; + break; + default: + break; + } + break; + case 2: // Page 2: cg Info + //disp_page[page] = (disp_page[page]+1)%BICC_MAX_CG; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].used_flag); + disp_length = 16; + break; + case 2: //sap_id + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].sap_id); + disp_length = 16; + break; + case 3: //network_id + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.network_id); + disp_length = 16; + break; + case 4: //dpc + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.dpc); + disp_length = 16; + break; + default: + break; + } + break; + + case 3: // Page 3: circuit Info + //disp_page[page] = (disp_page[page]+1)%BICC_MAX_CIRCUIT; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 16; + break; + case 1: //cg_id + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].cg_id); + disp_length = 16; + break; + case 2: //cic_range + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.cic_range); + disp_length = 16; + break; + case 3: //head_cic + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.head_cic); + disp_length = 16; + break; + default: + break; + } + break; + + case 4: // Page 4: port Info + //disp_page[page] = (disp_page[page]+32)%BICC_MAX_PORT; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 16; + break; + case 1: //enable + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].used_flag); + disp_length = 16; + break; + case 2: //fsm_state + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].fsm_state); + disp_length = 16; + break; + case 3: //cic_state + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].cic_state); + disp_length = 16; + break; + default: + break; + } + break; +*/ + default: + disp_length = 0; + break; + } + + return disp_length; +} + +static void debug_disp_page(u8 page) +{ + u8 disp_line; + u8 disp_length; + + debug_page_line[PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = debug_disp_line(page, disp_line); + debug_page_line[LINE_POINT] = disp_line + 2; + debug_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +int bicc_debug_init(void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + + strcpy(AsciInBuf, "\0"); + strcpy(AsciOutBuf, "\0"); + MonitorFg = MONITOR_NONE; + bzero(disp_page, 20); + + ptr = data; + + debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(BASE_ID_LEN, debug_name_id, BICC_VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 4096); + + for (page = 1; page < 5; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + case 2: //page 2 + ptr = title2_p; + break; + case 3: //page 3 + ptr = title3_p; + break; + case 4: //page 4 + ptr = title4_p; + break; + default: + break; + } + + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + debug_disp_page(page); + } + + return 1; +} + +void bicc_asciout_proc(const char *fmt, ...) +{ + va_list ap; + char buf[1024]; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + if((strlen(AsciOutBuf) + strlen(buf)) < 4096) + strcat(AsciOutBuf, buf); + else + strcpy(AsciOutBuf, buf); + va_end(ap); +} + + +void bicc_debug_refresh(void) +{ +// int i; + #if 0 + for(i=0;i<16;i++) + { + Bicc_Data.debug_data.sap_enable[i] = BiccResource.sap_pond[i].used_flag; + Bicc_Data.debug_data.sap_cg_num[i] = BiccResource.sap_pond[i].cg_num; + } + #endif +} + + +#if 0 +void list_sap(WORD sapNo) +{ + //u8 sapinfo[1024]; + if(sapNo >= BICC_MAX_SAP) + return; + + sprintf(info,"\ +Enable:%d\n\r\ +cg num:%d\n\r", + BiccResource.sap_pond[sapNo].used_flag,BiccResource.sap_pond[sapNo].cg_num); + bicc_asciout_proc(info); +} + +void list_all_sap() +{ + int i; + sprintf(info, "Index CG(s)\n\r"); + bicc_asciout_proc(info); + for(i=0; i= PAL_MAX_CG) + return; + pcg = pal_cg_ptr(cgNo); + if(pcg == NULL) + return; + sprintf(info, "\ +Enable:%d\n\r\ +sap id:%d\n\r\ +circuit num:%d\n\r\ +variant_type:%d\n\r\ +priority:%d\n\r\ +network id:%d\n\r\ +opc:%ld\n\r\ +dpc:%ld\n\r\ +tg_id:%ld\n\r", + pcg->enable,pcg->sap_id,pcg->circuit_num,pcg->attrib.variant,pcg->attrib.priority,pcg->attrib.network_id,pcg->attrib.opc,pcg->attrib.dpc,pcg->attrib.tg_id); + bicc_asciout_proc(info); +} + +void list_all_cg() +{ + int i = 0; + const pal_cg_struct *pcg; + sprintf(info, "Index SAP Circuit(s) NetInd DPC OPC TG\n\r"); + bicc_asciout_proc(info); + for(i=0; ienable==0) + continue; + + if(pcg->attrib.protocol != PROTO_BICC) + continue; + sprintf(info, " %d %d %d %d %ld %ld %ld\n\r", i, pcg->sap_id, pcg->circuit_num, pcg->attrib.network_id, pcg->attrib.dpc, pcg->attrib.opc, pcg->attrib.tg_id); + bicc_asciout_proc(info); + } +} + + +void list_circuit(WORD circuitNo) +{ + const pal_circuit_struct *pcircuit; + if(circuitNo >= PAL_MAX_CIRCUIT) + return; + pcircuit = pal_circuit_ptr(circuitNo); + if(pcircuit == NULL) + return ; + + sprintf(info,"\ +Enable:%d\n\r\ +cg id:%d\n\r\ +head cic:%ld\n\r\ +cic range:%d\n\r\ +plat id:%d\n\r", + pcircuit->enable,pcircuit->cg_id,pcircuit->attrib.head_cic,pcircuit->attrib.cic_range,pcircuit->attrib.plat_id); + bicc_asciout_proc(info); +} + + +void list_all_circuit() +{ + int i = 0, j = 0; + const pal_circuit_struct *pcircuit; + const pal_cg_struct *pcg; +// for(i = 0; i < BICC_MAX_SAP; i ++) + //{ + sprintf(info, "Index CG PLAT CIC(s)\n\r"); + bicc_asciout_proc(info); + for(i=0; ienable == 0) + continue; + if(pcg->attrib.protocol != PROTO_BICC) + continue; + for(j = 0; jenable == 0 || pcircuit->cg_id != pcg->id) + continue; + sprintf(info, " %d %d %d %d (%ld~~%ld)\n\r", i, pcircuit->cg_id, pcircuit->attrib.plat_id, pcircuit->attrib.cic_range, pcircuit->attrib.head_cic, pcircuit->attrib.head_cic+pcircuit->attrib.cic_range); + bicc_asciout_proc(info); + + } + + } +} + +void list_port(WORD portNo) +{ + if(portNo>=BICC_MAX_PORT) + return; + sprintf(info,"\ +upper port:%ld\n\r\ +sprc_cmd:%x\n\r\ +primitive_cmd:%x\n\r\ +internal_cmd:%x\n\r\ +cic state{\n\r\ + call state:%d\n\r\ + suspend state:%d\n\r\ + block state:%d\n\r\ + }\n\r\ +fsm state{\n\r\ + cpc_state:%d\n\r\ + mgbs_state:%d\n\r\ + mgbr_state:%d\n\r\ + crs_state:%d\n\r\ + crr_state:%d\n\r\ + cgrs_state:%d\n\r\ + cgrr_state:%d\n\r\ + }\n\r", + Bicc_Data.port_data[portNo].su_proc_id,Bicc_Data.port_data[portNo].sprc_cmd, + Bicc_Data.port_data[portNo].primitive_cmd,Bicc_Data.port_data[portNo].internal_cmd, + Bicc_Data.port_data[portNo].cic_state.call_state,Bicc_Data.port_data[portNo].cic_state.sus_state, + Bicc_Data.port_data[portNo].cic_state.blo_state,Bicc_Data.port_data[portNo].fsm_state.cpc_state, + Bicc_Data.port_data[portNo].fsm_state.mgbs_state,Bicc_Data.port_data[portNo].fsm_state.mgbr_state, + Bicc_Data.port_data[portNo].fsm_state.crs_state,Bicc_Data.port_data[portNo].fsm_state.crr_state, + Bicc_Data.port_data[portNo].fsm_state.cgrs_state,Bicc_Data.port_data[portNo].fsm_state.cgrr_state); + bicc_asciout_proc(info); +} + +void list_busy_port() +{ + int i,j=0; + sprintf(info, "Index PortNo CallState\n\r"); + bicc_asciout_proc(info); + for(i=0;i 0) + { + in_page = AsciInBuf[0] - 1; + ascii_in_ptr = AsciInBuf + 1; + + if (in_page > 4) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + MonitorFg = MonitorFg | MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + MonitorFg = MonitorFg & (~MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + MonitorFg = MONITOR_ALL; + + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + MonitorFg = MONITOR_NONE; + + } + else if (strcmp(ascii_in_ptr,"help") == 0) + { + bicc_asciout_proc(log_help); + } + else if (isdigit(ascii_in_ptr[0])) + { + num = strtoul(ascii_in_ptr, NULL, 10); + disp_page[in_page] = num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, ">")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] += num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, "<"))!= NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] -= num; + debug_disp_page(in_page); + } + #if 0 + else if ((strstr (ascii_in_ptr, "list sap")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + sapNo = strtoul (tmpStr + 1, NULL, 10); + list_sap(sapNo); + } + else + { + list_all_sap(); + } + } +#endif + else if ((strstr (ascii_in_ptr,"list cg")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + // if((tmpStr = strsep(&&ascii_in_ptr, " \t")) != NULL) + { + cgNo = strtoul (tmpStr+1, NULL, 10); + // strsep(, " \t"); + list_cg(cgNo); + } + else + { + list_all_cg(); + } + } + else if ((strstr (ascii_in_ptr, "list circuit")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + circuitNo = strtoul (tmpStr + 1, NULL, 10); + list_circuit(circuitNo); + } + else + { + list_all_circuit(); + } + } + else if ((strstr (ascii_in_ptr, "list port")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul (tmpStr + 1, NULL, 10); + list_port(portNo); + } + else + { + list_busy_port(); + } + + } + else if((strstr (ascii_in_ptr, "list dmp")) != NULL) + { + list_dmp(); + } + else if((strstr(ascii_in_ptr, "trace on")) != NULL) + { + if((tmpStr = strstr(ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul(tmpStr + 1, NULL, 10); + //trace_port(portNo); + Bicc_Data.port_data[portNo].trace_flag = 1; + } + else + {} + } + else if ((strstr (ascii_in_ptr, "trace off")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul (tmpStr + 1, NULL, 10); + Bicc_Data.port_data[portNo].trace_flag = 0; + } + else + { + int i; + for(i=0; i= 4096) + sprintf(AsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(AsciTempBuf, "%s\n\r", msg); + bicc_asciout_proc(AsciTempBuf); + return 0; + } + + return -1; +} + +void display_bicc_msgtype(u8 msgtype, u32 cic) +{ + switch(msgtype) + { + case M_ACM: + bicc_asciout_proc("ACM:Address complete"); + break; + case M_ANM: + bicc_asciout_proc("ANM:Answer"); + break; + case M_BLO: + bicc_asciout_proc("BLO:Blocking"); + break; + case M_BLA: + bicc_asciout_proc("BLA:Blocking acknowledgement"); + break; + case M_CPG: + bicc_asciout_proc("CPG:Call progress"); + break; + case M_CGB: + bicc_asciout_proc("CGB:Circuit/CIC group blocking"); + break; + case M_CGBA: + bicc_asciout_proc("CGBA:Circuit/CIC group blocking acknowledgement"); + break; + case M_CQM: + bicc_asciout_proc("CQM:Circuit/CIC group query (national use)"); + break; + case M_CQR: + bicc_asciout_proc("CQR:Circuit/CIC group query response (national use)"); + break; + case M_GRS: + bicc_asciout_proc("GRS:Circuit/CIC group reset"); + break; + case M_GRA: + bicc_asciout_proc("GRA:Circuit/CIC group reset acknowledgement"); + break; + case M_CGU: + bicc_asciout_proc("CGU:Circuit/CIC group unblocking"); + break; + case M_CGUA: + bicc_asciout_proc("CGUA:Circuit/CIC group unblocking acknowledgement"); + break; + case M_CRG: + bicc_asciout_proc("CRG:Charge information (national use)"); + break; + case M_CFN: + bicc_asciout_proc("CFN:Confusion"); + break; + case M_CON: + bicc_asciout_proc("CON:Connect"); + break; + case M_COT: + bicc_asciout_proc("COT:Continuity"); + break; + case M_FAC: + bicc_asciout_proc("FAC:Facility "); + break; + case M_FAA: + bicc_asciout_proc("FAA:Facility accepted"); + break; + case M_FRJ: + bicc_asciout_proc("FRJ:Facility reject"); + break; + case M_FAR: + bicc_asciout_proc("FAR:Facility request"); + break; + case M_FOT: + bicc_asciout_proc("FOT:Forward transfer"); + break; + case M_IDR: + bicc_asciout_proc("IDR:Identification request"); + break; + case M_IRS: + bicc_asciout_proc("IRS:Identification response"); + break; + case M_INF: + bicc_asciout_proc("INF:Information (national use)"); + break; + case M_INR: + bicc_asciout_proc("INR:Information request (national use)"); + break; + case M_IAM: + bicc_asciout_proc("IAM:Initial address"); + break; + case M_NRM: + bicc_asciout_proc("NRM:Network resource management"); + break; + case M_REL: + bicc_asciout_proc("REL:Release"); + break; + case M_RLC: + bicc_asciout_proc("RLC:Release complete"); + break; + case M_RSC: + bicc_asciout_proc("RSC:Reset circuit/CIC"); + break; + case M_RES: + bicc_asciout_proc("RES:Resume"); + break; + case M_SGM: + bicc_asciout_proc("SGM:Segmentation"); + break; + case M_SAM: + bicc_asciout_proc("SAM:Subsequent address"); + break; + case M_SUS: + bicc_asciout_proc("SUS:Suspend"); + break; + case M_UBL: + bicc_asciout_proc("UBL:Unblocking"); + break; + case M_UBA: + bicc_asciout_proc("UBA:Unblocking acknowledgement"); + break; + case M_UCIC: + bicc_asciout_proc("UCIC:Unequipped CIC (national use)"); + break; + case M_APM: + bicc_asciout_proc("APM:Application Transport"); + break; + case M_USR: + bicc_asciout_proc("USR:User-to-user information"); + break; + default: + bicc_asciout_proc("Unknown message"); + + } + + bicc_asciout_proc("(message type=0x%x cic=%d)\r\n",msgtype,cic); +} + + +void monitor_bicc_msg(BYTE *msg,BYTE buf_len, BYTE flag, u32 cic, u32 portNo) +{ + BYTE i,temp_buf[1024]; + if(MonitorFg == MONITOR_ALL) + { + if(flag == 0) + bicc_asciout_proc("\33[33mReceive:\33[0m"); + else if(flag == 1) + bicc_asciout_proc("\33[32mSend:\33[0m"); + else if(flag == 2) + bicc_asciout_proc("\33[34mRedirect:\33[0m"); + display_bicc_msgtype(msg[0], cic); + + if(flag != 2) + { + for (i = 0; i < buf_len; i ++) + { + sprintf(&temp_buf[3*i]," %02x", msg[i]); + } + sprintf(&temp_buf[3*i],"\n\r"); + bicc_asciout_proc(temp_buf); + } + } + if(MonitorFg == MONITOR_NONE) + {} + if(Bicc_Data.port_data[portNo].trace_flag == 1) + { + if(flag == 0) + bicc_asciout_proc("\33[33mReceive:\33[0m"); + else if(flag == 1) + bicc_asciout_proc("\33[32mSend:\33[0m"); + else if(flag == 2) + bicc_asciout_proc("\33[34mRedirect:\33[0m"); + display_bicc_msgtype(msg[0], cic); + + if(flag != 2) + { + for (i = 0; i < buf_len; i ++) + { + sprintf(&temp_buf[3*i]," %02x", msg[i]); + } + sprintf(&temp_buf[3*i],"\n\r"); + bicc_asciout_proc(temp_buf); + } + } +} + diff --git a/omc/plat/bicc/src.old/bicc_fsm.c b/omc/plat/bicc/src.old/bicc_fsm.c new file mode 100644 index 0000000..944719e --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_fsm.c @@ -0,0 +1,2093 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "./include/biccif.h" +/**************CPCI*************************/ +#define CPCI_IDLE 0 +#define CPCI_WAIT_CONTINUITY 1 +#define CPCI_WAIT_ACM 2 +#define CPCI_WAIT_ANM 3 +#define CPCI_ANSWERED 4 +#define CPCI_SUSPENDED 5 +#define CPCI_WAIT_RLC 6 +#define CPCI_WAIT_REL_COMP 7 +#define CPCI_WAIT_RESET 8 +#define CPCI_WAIT_GROUP_RESET 9 + +/*************CPCO*************************/ +#define CPCO_IDLE 0 +#define CPCO_WAIT_CONTINUITY 1 +#define CPCO_WAIT_ACM 2 +#define CPCO_WAIT_ANM 3 +#define CPCO_ANSWERED 4 +#define CPCO_SUSPENDED 5 +#define CPCO_WAIT_RLC 6 +#define CPCO_WAIT_REL_COMP 7 +#define CPCO_WAIT_RESET 8 +#define CPCO_WAIT_GROUP_RESET 9 + +/********************************************/ +#define MGBS_IDLE 0 +#define MGBS_WAIT_CGBA 1 +#define MGBS_WAIT_CGUA 2 +/********************************************/ +#define MGBR_IDLE 0 +#define MGBR_WAIT_BLOCKING_RESP 1 +#define MGBR_WAIT_UNBLOCKING_RESP 2 +/********************************************/ +#define CRS_IDLE 0 +#define CRS_WAIT_REL 1 +/*******************************************/ +#define CRR_IDLE 0 +#define CRR_WAIT_RESPONSE 1 +#define CRR_RESET 2 +#define CRR_RESET_COMP 3 +/*******************************************/ +#define CGRS_IDLE 0 +#define CGRS_WAIT_GRA 1 +/*******************************************/ +#define CGRR_IDLE 0 +#define CGRR_WAIT_GROUP_RESET_COMP 1 +/********************************************/ +#define BLR_IDLE 0 +#define BLR_WAIT_BLOCKING_RESP 1 +#define BLR_REMOTE_LOCKED 2 +#define BLR_WAIT_UNBLOCKING_RESP 3 +/********************************************/ +#define BLS_IDLE 0 +#define BLS_WAIT_BLA 1 +#define BLS_LOCAL_LOCKED 2 +#define BLS_WAIT_UBA 3 +/*******************************************/ + + + +BiccData_struct Bicc_Data; +const BiccTimer_struct *TIMER_PTR = &Timer_Data; + + +extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +//extern BICC_Resource_pond BiccResource; +extern BiccMsg_union msg_union[BICC_MAX_PORT]; +extern u8 local_platid; + +extern void bicc_send_apm(u32 pid); +extern void bicc_log_err(const char *fmt, ...); +extern void bicc_send_res(u32 pid); +extern void bicc_send_sus(u32 pid); +extern void bicc_send_sam(u32 pid); +extern void bicc_send_rsc(u32 pid); +extern void bicc_send_rlc(u32 pid); +extern void bicc_send_rel(u32 pid); +extern void bicc_send_iam(u32 pid); +extern void bicc_send_con(u32 pid); +extern void bicc_send_gra(u32 pid); +extern void bicc_send_grs(u32 pid); +extern void bicc_send_cgua(u32 pid); +extern void bicc_send_cgu(u32 pid); +extern void bicc_send_cgba(u32 pid); +extern void bicc_send_cgb(u32 pid); +extern void bicc_send_cpg(u32 pid); +extern void bicc_send_anm(u32 pid); +extern void bicc_send_acm(u32 pid); +extern BOOL check_crs_waiting(u32 pid); +extern int check_outbound_route(BYTE nw, long dpc, BYTE sls); + + +void bicc_cpc_clear(u32 pid) +{ + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); +} + + +BOOL bicc_cgrs_func(u32 start_pid, u8 range) +{ + int i; + u32 pid; + + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_RESET; + + } + return 1; +} + +BOOL bicc_cgrsack_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_CIC_IDLE; + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); + + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state |= M_REMOTE_BLOCK; + else + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + //BiccResource.circuit_pond[start_pid/BICC_CIRCUIT_CIC].active_flag = 1; + return 1; +} + +BOOL bicc_cgrr_func(u32 start_pid, u8 range, RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + rs_ptr->range = range; + memset(rs_ptr->status, 0, 4); + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + if(Bicc_Data.port_data[pid].cic_state.blo_state & M_LOCAL_BLOCK) + { + if(Bicc_Data.port_data[pid].fsm_state.mgbs_state != MGBS_WAIT_CGUA) + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + } + } + return 1; +} + + +void bicc_set_cause(CauseInd_struct *cause_ptr, u8 val) +{ + cause_ptr->pres = 1; + cause_ptr->codingStd = 0; //CCITT standardized coding + cause_ptr->location = 5; //private network serving the remote user + cause_ptr->causeVal = val; +} + +void bicc_circuit_reset(u32 pid, const char *s) +{ + #ifdef BICC_DEBUG + bicc_log_err("BICC circuit reset!, %s\n", s); + #endif + + if(check_crs_waiting(pid)) + return; + Bicc_Data.port_data[pid].primitive_cmd = BICC_RESET_REQ; +} + + +BOOL bicc_localblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_LOCAL_BLOCK; + } + return 1; +} + +BOOL bicc_remoteblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_REMOTE_BLOCK; + } + return 1; +} + +BOOL bicc_cpcoblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + if(Bicc_Data.port_data[pid].cic_state.call_state == BICC_OUTGOING) + Bicc_Data.port_data[pid].internal_cmd = (BICC_CMD_BLO|BICC_SI_MGBR); + } + } + return 1; +} + +BOOL bicc_localunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0e; + } + return 1; +} + +BOOL bicc_remoteunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + return 1; +} + + +BOOL bicc_event_handle(u32 pid, BiccReadPrim_union *prm_ptr, u8 primitive, u8 eventType) +{ + BICC_EventHandle_struct *eh_ptr = NULL; + Pst pst; + u32 cic; + int circuit_id, offset, ret = -1; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + offset = pid % BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return BICC_CM_FAILED; + cic = pcircuit->attrib.head_cic + offset; + + pst.cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(pst.cg_id); + if(pcg == NULL) + return BICC_CM_FAILED; + if(pcg->attrib.protocol != PROTO_BICC) + return BICC_CM_FAILED; + pst.tg_id = pcg->attrib.tg_id; + pst.sp_proc_id = pid; + pst.su_proc_id = Bicc_Data.port_data[pid].su_proc_id; + pst.cic = cic; + pst.trace_flag = 0; + + eh_ptr = (BICC_EventHandle_struct *)pal_get_handler(pst.cg_id); + if(eh_ptr == NULL) + return BICC_CM_FAILED; + + switch(primitive) + { + case BICC_SETUP_IND: + if(eh_ptr->h_bicc_setup_ind != NULL) + { + ret = eh_ptr->h_bicc_setup_ind(&pst, prm_ptr); + if(pst.trace_flag == 1) + { + //BiccResource.port_pond[pid].trace_flag = 1; + Bicc_Data.port_data[pid].trace_flag = 1; + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 0, cic, pid); + } + } + else + bicc_log_err("Setup indicate handle is not registered.\n"); + if(ret != -1) + Bicc_Data.port_data[pid].su_proc_id = pst.su_proc_id; + break; + + case BICC_SETUP_CNF: + if(eventType == EN_CON) + { + if(eh_ptr->h_bicc_setup_con_cnf != NULL) + { + if(!eh_ptr->h_bicc_setup_con_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Setup confirm handle is not registered.\n"); + break; + + } + else + { + if(eh_ptr->h_bicc_setup_anm_cnf != NULL) + eh_ptr->h_bicc_setup_anm_cnf(&pst, prm_ptr); + else + bicc_log_err("Setup confirm handle is not registered.\n"); + } + + break; + + case BICC_ALERT_IND: + if(eh_ptr->h_bicc_alert_ind != NULL) + { + if(!eh_ptr->h_bicc_alert_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Alert indication handle is not registered.\n"); + break; + + case BICC_RELEASE_IND: + if(eh_ptr->h_bicc_release_ind != NULL) + { + if(!eh_ptr->h_bicc_release_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release indication is not registered.\n"); + break; + + case BICC_APM_IND: + if(eh_ptr->h_bicc_apm_ind != NULL) + { + if(!eh_ptr->h_bicc_apm_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("APM indication is not registered.\n"); + break; + + case BICC_RELEASE_CNF: + if(eh_ptr->h_bicc_release_cnf != NULL) + { + if(!eh_ptr->h_bicc_release_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release confirm is not registered.\n"); + break; + + case BICC_INFO_IND: + if(eh_ptr->h_bicc_info_ind != NULL) + { + if(!eh_ptr->h_bicc_info_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("info indication is not registered.\n"); + break; + + case BICC_SUSPEND_IND: + if(eh_ptr->h_bicc_suspend_ind != NULL) + { + if(!eh_ptr->h_bicc_suspend_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Suspend indication is not registered.\n"); + break; + + case BICC_RESUME_IND: + if(eh_ptr->h_bicc_resume_ind != NULL) + { + if(!eh_ptr->h_bicc_resume_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Resume indication is not registered.\n"); + break; + + case BICC_PROG_IND: + if(eh_ptr->h_bicc_prog_ind != NULL) + eh_ptr->h_bicc_prog_ind(&pst, prm_ptr); + else + bicc_log_err("Call progress indication handle is not registered.\n"); + break; + case BICC_RESET_IND: + if(eh_ptr->h_bicc_reset_ind != NULL) + eh_ptr->h_bicc_reset_ind(&pst, prm_ptr); + + else + bicc_log_err("Reset indicate handle is not registered.\n"); + break; + case BICC_RESET_CNF: + if(eh_ptr->h_bicc_reset_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_reset_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_reset_cnf(&pst, NULL); + } + else + bicc_log_err("Reset cnf handle is not registered.\n"); + break; + case BICC_FAILURE_IND: + if(eh_ptr->h_bicc_failure_ind != NULL) + eh_ptr->h_bicc_failure_ind(&pst, prm_ptr); + else + bicc_log_err("Failure indicate handle is not registered.\n"); + break; + case BICC_REATTEMPT_IND: + if(eh_ptr->h_bicc_reattempt_ind != NULL) + eh_ptr->h_bicc_reattempt_ind(&pst, prm_ptr); + else + bicc_log_err("Reattempt indicate handle is not registered.\n"); + break; + case BICC_BLOCK_IND: + if(eh_ptr->h_bicc_block_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_ind(&pst, NULL); + } + else + bicc_log_err("Block indicate handle is not registered.\n"); + break; + + case BICC_BLOCK_CNF: + if(eh_ptr->h_bicc_block_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_cnf(&pst, NULL); + } + else + bicc_log_err("Block confirm handle is not registered.\n"); + break; + case BICC_UNBLOCK_IND: + if(eh_ptr->h_bicc_unblock_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_ind(&pst, NULL); + } + else + bicc_log_err("Unblock indicate handle is not registered.\n"); + break; + case BICC_UNBLOCK_CNF: + if(eh_ptr->h_bicc_unblock_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_cnf(&pst, NULL); + } + else + bicc_log_err("Unblock confirm handle is not registered.\n"); + break; + default: + break; + } + return 1; +} + + +void bicc_dualseizure_func(u32 pid) +{ + int cg_id; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + pcircuit = pal_circuit_ptr(pid / BICC_CIRCUIT_CIC); + if(pcircuit == NULL) + return; + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL) + return; + if(pcg->attrib.priority == 0) + return; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, NULL, BICC_REATTEMPT_IND, EN_NONE); + bicc_cpc_clear(pid); + Bicc_Data.port_data[pid].cic_state.call_state = BICC_INCOMING; + port_ptr->sprc_cmd = M_IAM; +} + + +void bicc_cpci_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCI_IDLE: + if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].setup_ind.callingPtyCat.val != 0x0d) //test call? + { + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK) + port_ptr->cic_state.blo_state &= 0x01; //set remote unblocked + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + { + bicc_cpc_clear(pid); + return; + } + + } + if(bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_IND, EN_NONE)) + { + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + + } + else + { + bicc_circuit_reset(pid, "setup ind rejected"); + bicc_cpc_clear(pid); + return; + } + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd !=0 ) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_circuit_reset(pid, "unexpected message"); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CRR); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CGRR); + bicc_cpc_clear(pid); + return ; + } + + break; + case CPCI_WAIT_CONTINUITY: + break; + case CPCI_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_ALERT_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_acm(pid); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ANM; + } + else if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_con(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + tempTimer->t9 = TIMER_PTR->t9; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr ->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +/* else if(port_ptr->sprc_cmd == M_SAM) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_INFO_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + } +*/ + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBS)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_anm(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_PROG_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cpg(pid); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +#ifdef BICC_TOLERANT + // To avoid both side backoff // + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait anm"); + bicc_cpc_clear(pid); + return; + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + // break; + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x13); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + break; + + case CPCI_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_SUSPENDED: + if(port_ptr->primitive_cmd == BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state= CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_RLC: + if(port_ptr->sprc_cmd== M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_circuit_reset(pid, "t5 expired cpci wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + //if(cpc_ptr->crr_cmd == BICC_RESET_IND) + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid,&readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + } + +#endif + break; + case CPCI_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +inline void bicc_cpco_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCO_IDLE: + if(port_ptr->primitive_cmd== BICC_SETUP_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_iam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ACM; + } + else + bicc_cpc_clear(pid); + break; + case CPCO_WAIT_CONTINUITY: + break; + case CPCO_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_INFO_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + } + else if(port_ptr->sprc_cmd == M_ACM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + tempTimer->t9 = TIMER_PTR->t9; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_ALERT_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ANM; + } + else if(port_ptr->sprc_cmd == M_CON) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_CON); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +/* else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +*/ + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; //discard... + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + // fsm_ptr->timer_data.t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#ifdef BICC_REATTEMPT + else if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + bicc_dualseizure_func(pid); + } +#endif + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpco wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t7-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x12); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_PROG_IND, EN_NONE); + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + tempTimer->t9 = BICC_TIMER_STOP; + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#endif +#ifdef BICC_TOLERANT + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + break; + case CPCO_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid,&readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_SUSPENDED: + if(port_ptr->primitive_cmd== BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_RLC: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t5 = BICC_TIMER_STOP; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + // bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "t5 expired cpco wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_SETUP_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + tempTimer->user_t10 = 0; + + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + //bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + + break; + case CPCO_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +/********************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Sending */ +/********************************************************************/ +inline void bicc_mgbs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + { + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + tempTimer->t18 = 0; + tempTimer->t19 = 0; + } + return ; + } + switch(port_ptr->fsm_state.mgbs_state) + { + case MGBS_IDLE: + if(port_ptr->primitive_cmd == BICC_BLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_localblocking_func(pid, &writePrim_union[pid].cgb_req.rangeStatus); + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + tempTimer->t19 = TIMER_PTR->t19; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGBA; + } + else if(port_ptr->primitive_cmd == BICC_UNBLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + tempTimer->t21 = TIMER_PTR->t21; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGUA; + } + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + //discard + } + else if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + //discard + } + break; + case MGBS_WAIT_CGBA: + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_cnf.rangeStatus.range >= 32) + return; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_CNF, EN_GROUP); + } + + if(tempTimer->t18 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + } + if(tempTimer->t19 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t19 = TIMER_PTR->t19; //ignore first T19 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + + } + break; + case MGBS_WAIT_CGUA: + if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_cnf.rangeStatus.range >= 32) + return; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + bicc_localunblocking_func(pid, &readPrim_union[pid].cgu_cnf.rangeStatus); + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_CNF, EN_GROUP); + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + + if(tempTimer->t20 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + } + if(tempTimer->t21 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t21 = TIMER_PTR->t21; //ignore first T21 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + break; + default: + break; + } +} + +/************************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Reception */ +/************************************************************************/ +inline void bicc_mgbr_proc(u32 pid) +{ + + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + //BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + switch(port_ptr->fsm_state.mgbr_state) + { + case MGBR_IDLE: + if(port_ptr->sprc_cmd == M_CGB) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_ind.rangeStatus.range >= 32) + return; + bicc_cpcoblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_BLOCKING_RESP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_IND, EN_GROUP); + } + else if(port_ptr->sprc_cmd == M_CGU) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_ind.rangeStatus.range >= 32) + return; + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_IND, EN_GROUP); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_UNBLOCKING_RESP; + } + break; + case MGBR_WAIT_BLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgb_rsp, &readPrim_union[pid].cgb_ind, sizeof(BiccCgb_Ind)); + bicc_send_cgba(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + case MGBR_WAIT_UNBLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteunblocking_func(pid, &readPrim_union[pid].cgu_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgu_rsp, &readPrim_union[pid].cgu_ind, sizeof(BiccCgu_Ind)); + bicc_send_cgua(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Sending */ +/********************************************/ +BOOL check_crs_waiting(u32 pid) +{ + if(Bicc_Data.port_data[pid].fsm_state.crs_state == CRS_WAIT_REL) + return 1; + else + return 0; +} +inline void bicc_crs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.crs_state != CRS_IDLE) + { + port_ptr->fsm_state.crs_state = CRS_IDLE; + + tempTimer->t16 = 0; + } + return ; + } + switch(port_ptr->fsm_state.crs_state) + { + case CRS_IDLE: + if(port_ptr->primitive_cmd == BICC_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + + port_ptr->fsm_state.crs_state = CRS_WAIT_REL; + } + break; + case CRS_WAIT_REL: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + tempTimer->t16 = BICC_TIMER_STOP; + port_ptr->fsm_state.crs_state = CRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_NONE); + + } + + if(tempTimer->t16 -- == BICC_TIMER_EXPIRED) + { + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Reception */ +/********************************************/ +inline void bicc_crr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + + switch(port_ptr->fsm_state.crr_state) + { + case CRR_IDLE: + if(port_ptr->sprc_cmd == M_RSC) + { + port_ptr->sprc_cmd = 0; + + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + port_ptr->cic_state.call_state = BICC_INCOMING; + + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + port_ptr->fsm_state.crr_state = CRR_WAIT_RESPONSE; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + } + break; + case CRR_WAIT_RESPONSE: + //if((port_ptr->internal_cmd & 0x0F) == CMD_RESET_COMP) + // if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->internal_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + port_ptr->fsm_state.crr_state = CRR_IDLE; + } + break; + default: + break; + } +} + +/************************************************/ +/* Circuit Group Reset Sending */ +/************************************************/ +inline void bicc_cgrs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.cgrs_state != CGRS_IDLE) + { + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + + tempTimer->t22 = 0; + } + return ; + } + switch(port_ptr->fsm_state.cgrs_state) + { + case CGRS_IDLE: + if(port_ptr->primitive_cmd == BICC_GROUP_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRS); + bicc_cgrs_func(pid, writePrim_union[pid].grs_req.rangeStatus.range); + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; + } + break; + case CGRS_WAIT_GRA: + if(port_ptr->sprc_cmd == M_GRA) + { + port_ptr->sprc_cmd = 0; + tempTimer->t22 = BICC_TIMER_STOP; + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_GROUP); + bicc_cgrsack_func(pid, &readPrim_union[pid].grs_cnf.rangeStatus); + } + + if(tempTimer->t22 -- == BICC_TIMER_EXPIRED) + { + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + + } + break; + default: + break; + } +} + +/****************************************************/ +/* Circuit Group Reset Reception */ +/****************************************************/ +inline void bicc_cgrr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + switch(port_ptr->fsm_state.cgrr_state) + { + case CGRR_IDLE: + if(port_ptr->sprc_cmd == M_GRS) + { + port_ptr->sprc_cmd = 0; + if((readPrim_union[pid].grs_ind.rangeStatus.range >= 32)|| (readPrim_union[pid].grs_ind.rangeStatus.range == 0)) + return; + if(port_ptr->fsm_state.mgbr_state != MGBR_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRR); + bicc_cgrr_func(pid, readPrim_union[pid].grs_ind.rangeStatus.range, &msg_union[pid].gra.rangeStatus); + port_ptr->fsm_state.cgrr_state = CGRR_WAIT_GROUP_RESET_COMP; + } + break; + case CGRR_WAIT_GROUP_RESET_COMP: + memcpy(&writePrim_union[pid].grs_rsp.rangeStatus, &msg_union[pid].gra.rangeStatus, sizeof(RangeStatus_struct)); + bicc_send_gra(pid); + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cgrr_state = CGRR_IDLE; + break; + default: + break; + } +} + + + +BOOL bicc_check_blocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC- 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((Bicc_Data.port_data[i].cic_state.blo_state == 0) && (pcircuit->enable== 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_check_unblocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC - 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((pcircuit->enable== 1) && (Bicc_Data.port_data[i].cic_state.blo_state == 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_trunk_reachable(u32 cg_id) +{ + const pal_cg_struct *pcg; + pcg = pal_cg_ptr(cg_id); + if(pcg==NULL) + return 0; + if(check_outbound_route(pcg->attrib.network_id, (long)pcg->attrib.dpc, 0) >= 0) + return 1; + else + return 0; +} + diff --git a/omc/plat/bicc/src.old/bicc_fsm.c.old b/omc/plat/bicc/src.old/bicc_fsm.c.old new file mode 100644 index 0000000..944719e --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_fsm.c.old @@ -0,0 +1,2093 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "./include/biccif.h" +/**************CPCI*************************/ +#define CPCI_IDLE 0 +#define CPCI_WAIT_CONTINUITY 1 +#define CPCI_WAIT_ACM 2 +#define CPCI_WAIT_ANM 3 +#define CPCI_ANSWERED 4 +#define CPCI_SUSPENDED 5 +#define CPCI_WAIT_RLC 6 +#define CPCI_WAIT_REL_COMP 7 +#define CPCI_WAIT_RESET 8 +#define CPCI_WAIT_GROUP_RESET 9 + +/*************CPCO*************************/ +#define CPCO_IDLE 0 +#define CPCO_WAIT_CONTINUITY 1 +#define CPCO_WAIT_ACM 2 +#define CPCO_WAIT_ANM 3 +#define CPCO_ANSWERED 4 +#define CPCO_SUSPENDED 5 +#define CPCO_WAIT_RLC 6 +#define CPCO_WAIT_REL_COMP 7 +#define CPCO_WAIT_RESET 8 +#define CPCO_WAIT_GROUP_RESET 9 + +/********************************************/ +#define MGBS_IDLE 0 +#define MGBS_WAIT_CGBA 1 +#define MGBS_WAIT_CGUA 2 +/********************************************/ +#define MGBR_IDLE 0 +#define MGBR_WAIT_BLOCKING_RESP 1 +#define MGBR_WAIT_UNBLOCKING_RESP 2 +/********************************************/ +#define CRS_IDLE 0 +#define CRS_WAIT_REL 1 +/*******************************************/ +#define CRR_IDLE 0 +#define CRR_WAIT_RESPONSE 1 +#define CRR_RESET 2 +#define CRR_RESET_COMP 3 +/*******************************************/ +#define CGRS_IDLE 0 +#define CGRS_WAIT_GRA 1 +/*******************************************/ +#define CGRR_IDLE 0 +#define CGRR_WAIT_GROUP_RESET_COMP 1 +/********************************************/ +#define BLR_IDLE 0 +#define BLR_WAIT_BLOCKING_RESP 1 +#define BLR_REMOTE_LOCKED 2 +#define BLR_WAIT_UNBLOCKING_RESP 3 +/********************************************/ +#define BLS_IDLE 0 +#define BLS_WAIT_BLA 1 +#define BLS_LOCAL_LOCKED 2 +#define BLS_WAIT_UBA 3 +/*******************************************/ + + + +BiccData_struct Bicc_Data; +const BiccTimer_struct *TIMER_PTR = &Timer_Data; + + +extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +//extern BICC_Resource_pond BiccResource; +extern BiccMsg_union msg_union[BICC_MAX_PORT]; +extern u8 local_platid; + +extern void bicc_send_apm(u32 pid); +extern void bicc_log_err(const char *fmt, ...); +extern void bicc_send_res(u32 pid); +extern void bicc_send_sus(u32 pid); +extern void bicc_send_sam(u32 pid); +extern void bicc_send_rsc(u32 pid); +extern void bicc_send_rlc(u32 pid); +extern void bicc_send_rel(u32 pid); +extern void bicc_send_iam(u32 pid); +extern void bicc_send_con(u32 pid); +extern void bicc_send_gra(u32 pid); +extern void bicc_send_grs(u32 pid); +extern void bicc_send_cgua(u32 pid); +extern void bicc_send_cgu(u32 pid); +extern void bicc_send_cgba(u32 pid); +extern void bicc_send_cgb(u32 pid); +extern void bicc_send_cpg(u32 pid); +extern void bicc_send_anm(u32 pid); +extern void bicc_send_acm(u32 pid); +extern BOOL check_crs_waiting(u32 pid); +extern int check_outbound_route(BYTE nw, long dpc, BYTE sls); + + +void bicc_cpc_clear(u32 pid) +{ + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); +} + + +BOOL bicc_cgrs_func(u32 start_pid, u8 range) +{ + int i; + u32 pid; + + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_RESET; + + } + return 1; +} + +BOOL bicc_cgrsack_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_CIC_IDLE; + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); + + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state |= M_REMOTE_BLOCK; + else + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + //BiccResource.circuit_pond[start_pid/BICC_CIRCUIT_CIC].active_flag = 1; + return 1; +} + +BOOL bicc_cgrr_func(u32 start_pid, u8 range, RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + rs_ptr->range = range; + memset(rs_ptr->status, 0, 4); + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + if(Bicc_Data.port_data[pid].cic_state.blo_state & M_LOCAL_BLOCK) + { + if(Bicc_Data.port_data[pid].fsm_state.mgbs_state != MGBS_WAIT_CGUA) + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + } + } + return 1; +} + + +void bicc_set_cause(CauseInd_struct *cause_ptr, u8 val) +{ + cause_ptr->pres = 1; + cause_ptr->codingStd = 0; //CCITT standardized coding + cause_ptr->location = 5; //private network serving the remote user + cause_ptr->causeVal = val; +} + +void bicc_circuit_reset(u32 pid, const char *s) +{ + #ifdef BICC_DEBUG + bicc_log_err("BICC circuit reset!, %s\n", s); + #endif + + if(check_crs_waiting(pid)) + return; + Bicc_Data.port_data[pid].primitive_cmd = BICC_RESET_REQ; +} + + +BOOL bicc_localblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_LOCAL_BLOCK; + } + return 1; +} + +BOOL bicc_remoteblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_REMOTE_BLOCK; + } + return 1; +} + +BOOL bicc_cpcoblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + if(Bicc_Data.port_data[pid].cic_state.call_state == BICC_OUTGOING) + Bicc_Data.port_data[pid].internal_cmd = (BICC_CMD_BLO|BICC_SI_MGBR); + } + } + return 1; +} + +BOOL bicc_localunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0e; + } + return 1; +} + +BOOL bicc_remoteunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + return 1; +} + + +BOOL bicc_event_handle(u32 pid, BiccReadPrim_union *prm_ptr, u8 primitive, u8 eventType) +{ + BICC_EventHandle_struct *eh_ptr = NULL; + Pst pst; + u32 cic; + int circuit_id, offset, ret = -1; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + offset = pid % BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return BICC_CM_FAILED; + cic = pcircuit->attrib.head_cic + offset; + + pst.cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(pst.cg_id); + if(pcg == NULL) + return BICC_CM_FAILED; + if(pcg->attrib.protocol != PROTO_BICC) + return BICC_CM_FAILED; + pst.tg_id = pcg->attrib.tg_id; + pst.sp_proc_id = pid; + pst.su_proc_id = Bicc_Data.port_data[pid].su_proc_id; + pst.cic = cic; + pst.trace_flag = 0; + + eh_ptr = (BICC_EventHandle_struct *)pal_get_handler(pst.cg_id); + if(eh_ptr == NULL) + return BICC_CM_FAILED; + + switch(primitive) + { + case BICC_SETUP_IND: + if(eh_ptr->h_bicc_setup_ind != NULL) + { + ret = eh_ptr->h_bicc_setup_ind(&pst, prm_ptr); + if(pst.trace_flag == 1) + { + //BiccResource.port_pond[pid].trace_flag = 1; + Bicc_Data.port_data[pid].trace_flag = 1; + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 0, cic, pid); + } + } + else + bicc_log_err("Setup indicate handle is not registered.\n"); + if(ret != -1) + Bicc_Data.port_data[pid].su_proc_id = pst.su_proc_id; + break; + + case BICC_SETUP_CNF: + if(eventType == EN_CON) + { + if(eh_ptr->h_bicc_setup_con_cnf != NULL) + { + if(!eh_ptr->h_bicc_setup_con_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Setup confirm handle is not registered.\n"); + break; + + } + else + { + if(eh_ptr->h_bicc_setup_anm_cnf != NULL) + eh_ptr->h_bicc_setup_anm_cnf(&pst, prm_ptr); + else + bicc_log_err("Setup confirm handle is not registered.\n"); + } + + break; + + case BICC_ALERT_IND: + if(eh_ptr->h_bicc_alert_ind != NULL) + { + if(!eh_ptr->h_bicc_alert_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Alert indication handle is not registered.\n"); + break; + + case BICC_RELEASE_IND: + if(eh_ptr->h_bicc_release_ind != NULL) + { + if(!eh_ptr->h_bicc_release_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release indication is not registered.\n"); + break; + + case BICC_APM_IND: + if(eh_ptr->h_bicc_apm_ind != NULL) + { + if(!eh_ptr->h_bicc_apm_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("APM indication is not registered.\n"); + break; + + case BICC_RELEASE_CNF: + if(eh_ptr->h_bicc_release_cnf != NULL) + { + if(!eh_ptr->h_bicc_release_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release confirm is not registered.\n"); + break; + + case BICC_INFO_IND: + if(eh_ptr->h_bicc_info_ind != NULL) + { + if(!eh_ptr->h_bicc_info_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("info indication is not registered.\n"); + break; + + case BICC_SUSPEND_IND: + if(eh_ptr->h_bicc_suspend_ind != NULL) + { + if(!eh_ptr->h_bicc_suspend_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Suspend indication is not registered.\n"); + break; + + case BICC_RESUME_IND: + if(eh_ptr->h_bicc_resume_ind != NULL) + { + if(!eh_ptr->h_bicc_resume_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Resume indication is not registered.\n"); + break; + + case BICC_PROG_IND: + if(eh_ptr->h_bicc_prog_ind != NULL) + eh_ptr->h_bicc_prog_ind(&pst, prm_ptr); + else + bicc_log_err("Call progress indication handle is not registered.\n"); + break; + case BICC_RESET_IND: + if(eh_ptr->h_bicc_reset_ind != NULL) + eh_ptr->h_bicc_reset_ind(&pst, prm_ptr); + + else + bicc_log_err("Reset indicate handle is not registered.\n"); + break; + case BICC_RESET_CNF: + if(eh_ptr->h_bicc_reset_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_reset_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_reset_cnf(&pst, NULL); + } + else + bicc_log_err("Reset cnf handle is not registered.\n"); + break; + case BICC_FAILURE_IND: + if(eh_ptr->h_bicc_failure_ind != NULL) + eh_ptr->h_bicc_failure_ind(&pst, prm_ptr); + else + bicc_log_err("Failure indicate handle is not registered.\n"); + break; + case BICC_REATTEMPT_IND: + if(eh_ptr->h_bicc_reattempt_ind != NULL) + eh_ptr->h_bicc_reattempt_ind(&pst, prm_ptr); + else + bicc_log_err("Reattempt indicate handle is not registered.\n"); + break; + case BICC_BLOCK_IND: + if(eh_ptr->h_bicc_block_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_ind(&pst, NULL); + } + else + bicc_log_err("Block indicate handle is not registered.\n"); + break; + + case BICC_BLOCK_CNF: + if(eh_ptr->h_bicc_block_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_cnf(&pst, NULL); + } + else + bicc_log_err("Block confirm handle is not registered.\n"); + break; + case BICC_UNBLOCK_IND: + if(eh_ptr->h_bicc_unblock_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_ind(&pst, NULL); + } + else + bicc_log_err("Unblock indicate handle is not registered.\n"); + break; + case BICC_UNBLOCK_CNF: + if(eh_ptr->h_bicc_unblock_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_cnf(&pst, NULL); + } + else + bicc_log_err("Unblock confirm handle is not registered.\n"); + break; + default: + break; + } + return 1; +} + + +void bicc_dualseizure_func(u32 pid) +{ + int cg_id; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + pcircuit = pal_circuit_ptr(pid / BICC_CIRCUIT_CIC); + if(pcircuit == NULL) + return; + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL) + return; + if(pcg->attrib.priority == 0) + return; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, NULL, BICC_REATTEMPT_IND, EN_NONE); + bicc_cpc_clear(pid); + Bicc_Data.port_data[pid].cic_state.call_state = BICC_INCOMING; + port_ptr->sprc_cmd = M_IAM; +} + + +void bicc_cpci_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCI_IDLE: + if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].setup_ind.callingPtyCat.val != 0x0d) //test call? + { + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK) + port_ptr->cic_state.blo_state &= 0x01; //set remote unblocked + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + { + bicc_cpc_clear(pid); + return; + } + + } + if(bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_IND, EN_NONE)) + { + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + + } + else + { + bicc_circuit_reset(pid, "setup ind rejected"); + bicc_cpc_clear(pid); + return; + } + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd !=0 ) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_circuit_reset(pid, "unexpected message"); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CRR); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CGRR); + bicc_cpc_clear(pid); + return ; + } + + break; + case CPCI_WAIT_CONTINUITY: + break; + case CPCI_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_ALERT_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_acm(pid); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ANM; + } + else if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_con(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + tempTimer->t9 = TIMER_PTR->t9; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr ->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +/* else if(port_ptr->sprc_cmd == M_SAM) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_INFO_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + } +*/ + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBS)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_anm(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_PROG_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cpg(pid); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +#ifdef BICC_TOLERANT + // To avoid both side backoff // + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait anm"); + bicc_cpc_clear(pid); + return; + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + // break; + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x13); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + break; + + case CPCI_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_SUSPENDED: + if(port_ptr->primitive_cmd == BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state= CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_RLC: + if(port_ptr->sprc_cmd== M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_circuit_reset(pid, "t5 expired cpci wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + //if(cpc_ptr->crr_cmd == BICC_RESET_IND) + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid,&readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + } + +#endif + break; + case CPCI_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +inline void bicc_cpco_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCO_IDLE: + if(port_ptr->primitive_cmd== BICC_SETUP_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_iam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ACM; + } + else + bicc_cpc_clear(pid); + break; + case CPCO_WAIT_CONTINUITY: + break; + case CPCO_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_INFO_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + } + else if(port_ptr->sprc_cmd == M_ACM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + tempTimer->t9 = TIMER_PTR->t9; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_ALERT_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ANM; + } + else if(port_ptr->sprc_cmd == M_CON) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_CON); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +/* else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +*/ + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; //discard... + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + // fsm_ptr->timer_data.t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#ifdef BICC_REATTEMPT + else if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + bicc_dualseizure_func(pid); + } +#endif + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpco wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t7-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x12); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_PROG_IND, EN_NONE); + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + tempTimer->t9 = BICC_TIMER_STOP; + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#endif +#ifdef BICC_TOLERANT + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + break; + case CPCO_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid,&readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_SUSPENDED: + if(port_ptr->primitive_cmd== BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_RLC: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t5 = BICC_TIMER_STOP; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + // bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "t5 expired cpco wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_SETUP_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + tempTimer->user_t10 = 0; + + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + //bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + + break; + case CPCO_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +/********************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Sending */ +/********************************************************************/ +inline void bicc_mgbs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + { + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + tempTimer->t18 = 0; + tempTimer->t19 = 0; + } + return ; + } + switch(port_ptr->fsm_state.mgbs_state) + { + case MGBS_IDLE: + if(port_ptr->primitive_cmd == BICC_BLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_localblocking_func(pid, &writePrim_union[pid].cgb_req.rangeStatus); + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + tempTimer->t19 = TIMER_PTR->t19; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGBA; + } + else if(port_ptr->primitive_cmd == BICC_UNBLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + tempTimer->t21 = TIMER_PTR->t21; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGUA; + } + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + //discard + } + else if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + //discard + } + break; + case MGBS_WAIT_CGBA: + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_cnf.rangeStatus.range >= 32) + return; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_CNF, EN_GROUP); + } + + if(tempTimer->t18 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + } + if(tempTimer->t19 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t19 = TIMER_PTR->t19; //ignore first T19 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + + } + break; + case MGBS_WAIT_CGUA: + if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_cnf.rangeStatus.range >= 32) + return; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + bicc_localunblocking_func(pid, &readPrim_union[pid].cgu_cnf.rangeStatus); + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_CNF, EN_GROUP); + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + + if(tempTimer->t20 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + } + if(tempTimer->t21 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t21 = TIMER_PTR->t21; //ignore first T21 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + break; + default: + break; + } +} + +/************************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Reception */ +/************************************************************************/ +inline void bicc_mgbr_proc(u32 pid) +{ + + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + //BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + switch(port_ptr->fsm_state.mgbr_state) + { + case MGBR_IDLE: + if(port_ptr->sprc_cmd == M_CGB) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_ind.rangeStatus.range >= 32) + return; + bicc_cpcoblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_BLOCKING_RESP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_IND, EN_GROUP); + } + else if(port_ptr->sprc_cmd == M_CGU) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_ind.rangeStatus.range >= 32) + return; + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_IND, EN_GROUP); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_UNBLOCKING_RESP; + } + break; + case MGBR_WAIT_BLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgb_rsp, &readPrim_union[pid].cgb_ind, sizeof(BiccCgb_Ind)); + bicc_send_cgba(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + case MGBR_WAIT_UNBLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteunblocking_func(pid, &readPrim_union[pid].cgu_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgu_rsp, &readPrim_union[pid].cgu_ind, sizeof(BiccCgu_Ind)); + bicc_send_cgua(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Sending */ +/********************************************/ +BOOL check_crs_waiting(u32 pid) +{ + if(Bicc_Data.port_data[pid].fsm_state.crs_state == CRS_WAIT_REL) + return 1; + else + return 0; +} +inline void bicc_crs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.crs_state != CRS_IDLE) + { + port_ptr->fsm_state.crs_state = CRS_IDLE; + + tempTimer->t16 = 0; + } + return ; + } + switch(port_ptr->fsm_state.crs_state) + { + case CRS_IDLE: + if(port_ptr->primitive_cmd == BICC_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + + port_ptr->fsm_state.crs_state = CRS_WAIT_REL; + } + break; + case CRS_WAIT_REL: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + tempTimer->t16 = BICC_TIMER_STOP; + port_ptr->fsm_state.crs_state = CRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_NONE); + + } + + if(tempTimer->t16 -- == BICC_TIMER_EXPIRED) + { + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Reception */ +/********************************************/ +inline void bicc_crr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + + switch(port_ptr->fsm_state.crr_state) + { + case CRR_IDLE: + if(port_ptr->sprc_cmd == M_RSC) + { + port_ptr->sprc_cmd = 0; + + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + port_ptr->cic_state.call_state = BICC_INCOMING; + + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + port_ptr->fsm_state.crr_state = CRR_WAIT_RESPONSE; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + } + break; + case CRR_WAIT_RESPONSE: + //if((port_ptr->internal_cmd & 0x0F) == CMD_RESET_COMP) + // if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->internal_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + port_ptr->fsm_state.crr_state = CRR_IDLE; + } + break; + default: + break; + } +} + +/************************************************/ +/* Circuit Group Reset Sending */ +/************************************************/ +inline void bicc_cgrs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.cgrs_state != CGRS_IDLE) + { + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + + tempTimer->t22 = 0; + } + return ; + } + switch(port_ptr->fsm_state.cgrs_state) + { + case CGRS_IDLE: + if(port_ptr->primitive_cmd == BICC_GROUP_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRS); + bicc_cgrs_func(pid, writePrim_union[pid].grs_req.rangeStatus.range); + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; + } + break; + case CGRS_WAIT_GRA: + if(port_ptr->sprc_cmd == M_GRA) + { + port_ptr->sprc_cmd = 0; + tempTimer->t22 = BICC_TIMER_STOP; + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_GROUP); + bicc_cgrsack_func(pid, &readPrim_union[pid].grs_cnf.rangeStatus); + } + + if(tempTimer->t22 -- == BICC_TIMER_EXPIRED) + { + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + + } + break; + default: + break; + } +} + +/****************************************************/ +/* Circuit Group Reset Reception */ +/****************************************************/ +inline void bicc_cgrr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + switch(port_ptr->fsm_state.cgrr_state) + { + case CGRR_IDLE: + if(port_ptr->sprc_cmd == M_GRS) + { + port_ptr->sprc_cmd = 0; + if((readPrim_union[pid].grs_ind.rangeStatus.range >= 32)|| (readPrim_union[pid].grs_ind.rangeStatus.range == 0)) + return; + if(port_ptr->fsm_state.mgbr_state != MGBR_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRR); + bicc_cgrr_func(pid, readPrim_union[pid].grs_ind.rangeStatus.range, &msg_union[pid].gra.rangeStatus); + port_ptr->fsm_state.cgrr_state = CGRR_WAIT_GROUP_RESET_COMP; + } + break; + case CGRR_WAIT_GROUP_RESET_COMP: + memcpy(&writePrim_union[pid].grs_rsp.rangeStatus, &msg_union[pid].gra.rangeStatus, sizeof(RangeStatus_struct)); + bicc_send_gra(pid); + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cgrr_state = CGRR_IDLE; + break; + default: + break; + } +} + + + +BOOL bicc_check_blocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC- 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((Bicc_Data.port_data[i].cic_state.blo_state == 0) && (pcircuit->enable== 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_check_unblocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC - 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((pcircuit->enable== 1) && (Bicc_Data.port_data[i].cic_state.blo_state == 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_trunk_reachable(u32 cg_id) +{ + const pal_cg_struct *pcg; + pcg = pal_cg_ptr(cg_id); + if(pcg==NULL) + return 0; + if(check_outbound_route(pcg->attrib.network_id, (long)pcg->attrib.dpc, 0) >= 0) + return 1; + else + return 0; +} + diff --git a/omc/plat/bicc/src.old/bicc_ipbcp.c b/omc/plat/bicc/src.old/bicc_ipbcp.c new file mode 100644 index 0000000..a5de374 --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_ipbcp.c @@ -0,0 +1,362 @@ +#include +#include +#include "./include/ipbcp.h" + +int sdp_decode_orig(SdpOrig_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->username, token); + strcat(dst_ptr->username, "\0"); + break; + case 2: + sprintf(dst_ptr->session_id, token); + strcat(dst_ptr->session_id, "\0"); + break; + case 3: + sprintf(dst_ptr->version, token); + strcat(dst_ptr->version, "\0"); + break; + case 4: + sprintf(dst_ptr->network_type, token); + strcat(dst_ptr->network_type, "\0"); + break; + case 5: + sprintf(dst_ptr->address_type, token); + strcat(dst_ptr->address_type, "\0"); + break; + case 6: + sprintf(dst_ptr->address, token); + strcat(dst_ptr->address, "\0"); + break; + default: + return 0; + } + } + if(field_id != 6) + return 0; + else + return 1; +} + +int sdp_decode_conn(SdpConn_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->network_type, token); + strcat(dst_ptr->network_type, "\0"); + break; + case 2: + sprintf(dst_ptr->address_type, token); + strcat(dst_ptr->address_type, "\0"); + break; + case 3: + sprintf(dst_ptr->address, token); + strcat(dst_ptr->address, "\0"); + break; + default: + return 0; + } + } + if(field_id != 3) + return 0; + else + return 1; +} + +int sdp_decode_time(SdpTime_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->start, token); + strcat(dst_ptr->start, "\0"); + break; + case 2: + sprintf(dst_ptr->stop, token); + strcat(dst_ptr->stop, "\0"); + break; + default: + return 0; + } + } + if(field_id != 2) + return 0; + else + return 1; +} + +int sdp_decode_attrib(SdpAttrib_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + if(strstr(src_ptr, "ipbcp:") != src_ptr) + return 0; + src_ptr += strlen("ipbcp:"); + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->version, token); + strcat(dst_ptr->version, "\0"); + break; + case 2: + sprintf(dst_ptr->type, token); + strcat(dst_ptr->type, "\0"); + break; + default: + return 0; + } + } + if(field_id != 2) + return 0; + else + return 1; +} + +int sdp_decode_mediaAnn(SdpMediaAnn_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->media, token); + strcat(dst_ptr->media, "\0"); + break; + case 2: + sprintf(dst_ptr->port, token); + strcat(dst_ptr->port, "\0"); + break; + case 3: + sprintf(dst_ptr->transport, token); + strcat(dst_ptr->transport, "\0"); + strcpy(dst_ptr->fmt_list, src_ptr); + strcat(dst_ptr->fmt_list, "\0"); + break; + case 4: + // sprintf(dst_ptr->fmt_list, token); + break; + default: + break; + } + } + if(field_id < 4) + return 0; + else + return 1; +} + +int sdp_decode_mediaAtt(SdpMediaAtt_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + if(strstr(src_ptr, "rtpmap:") != src_ptr) + return 0; + src_ptr += strlen("rtpmap:"); + while((token = strsep(&src_ptr, " /")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->payload, token); + strcat(dst_ptr->payload, "\0"); + break; + case 2: + sprintf(dst_ptr->encoding_name, token); + strcat(dst_ptr->encoding_name, "\0"); + break; + case 3: + sprintf(dst_ptr->clock_rate, token); + strcat(dst_ptr->clock_rate, "\0"); + break; + case 4: +// sprintf(dst_ptr->p_time, token); + field_id --;//to avoid 4 fields + break; + default: + return 0; + } + } + if(field_id != 3) + return 0; + else + return 1; +} + + +int sdp_decode_ptime(char* p_time, char *src_ptr) +{ + char *token; + if((token = strstr(src_ptr, "ptime:")) == NULL) + return 0; + token = strtok(token, ":"); + token = strtok(NULL, ":"); +// p_time = token; +// if(strlen(token)<8) + if(token) + { + sprintf(p_time, token); + strcat(p_time, "\0"); + } + return 1; + +} + +int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr) +{ + char *token; + unsigned char field_id = 0; + char temp_ipbcp[200]; + char *temp_ptr; + + strncpy(temp_ipbcp, ptr, 200); + temp_ptr = temp_ipbcp; + memset(ipbcp_ptr, 0, sizeof(IPBCP_struct)); + while((token = strsep(&temp_ptr, "\r\n")) != NULL) + { + if(strlen(token) == 0) + continue; + switch(++field_id) + { + case 1: + if((token[0] != 'v') || (token[1] != '=')) + return 0; + sprintf(ipbcp_ptr->proto_ver, token+2); + strcat(ipbcp_ptr->proto_ver, "\0"); + break; + case 2: + if((token[0] != 'o') || (token[1] != '=')) + return 0; + if(!sdp_decode_orig(&ipbcp_ptr->orig, token+2)) + return 0; + break; + case 3: + if((token[0] != 's') || (token[1] != '=')) + return 0; + sprintf(ipbcp_ptr->session_name, token+2); + + strcat(ipbcp_ptr->session_name, "\0"); + break; + case 4: + if((token[0] != 'c') || (token[1] != '=')) + return 0; + if(!sdp_decode_conn(&ipbcp_ptr->conn_data, token+2)) + return 0; + break; + case 5: + if((token[0] != 't') || (token[1] != '=')) + return 0; + if(!sdp_decode_time(&ipbcp_ptr->time, token+2)) + return 0; + break; + case 6: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(!sdp_decode_attrib(&ipbcp_ptr->attrib, token+2)) + return 0; + break; + case 7: + if((token[0] != 'm') || (token[1] != '=')) + return 0; + if(!sdp_decode_mediaAnn(&ipbcp_ptr->m_ann, token+2)) + return 0; + break; + case 8: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(sdp_decode_mediaAtt(&ipbcp_ptr->m_att, token+2)) + // return 0; + ; + else if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2)) + return 0; + + break; + case 9: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2)) + return 0; + default: + break; + } + } + return 1; +} + +int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr) +{ + char tmp_buf[128]; + + sprintf(ptr, "v=%s\r\n", ipbcp_ptr->proto_ver); + + sprintf(tmp_buf, "o=%s %s %s %s %s %s\r\n", + ipbcp_ptr->orig.username, + ipbcp_ptr->orig.session_id, + ipbcp_ptr->orig.version, + ipbcp_ptr->orig.network_type, + ipbcp_ptr->orig.address_type, + ipbcp_ptr->orig.address); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "s=%s\r\n", ipbcp_ptr->session_name); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "c=%s %s %s\r\n", + ipbcp_ptr->conn_data.network_type, + ipbcp_ptr->conn_data.address_type, + ipbcp_ptr->conn_data.address); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "t=%s %s\r\n", ipbcp_ptr->time.start, ipbcp_ptr->time.stop); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "a=ipbcp:%s %s\r\n", ipbcp_ptr->attrib.version, ipbcp_ptr->attrib.type); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "m=%s %s %s %s\r\n", + ipbcp_ptr->m_ann.media, + ipbcp_ptr->m_ann.port, + ipbcp_ptr->m_ann.transport, + ipbcp_ptr->m_ann.fmt_list); + strcat(ptr, tmp_buf); + + if(strlen(ipbcp_ptr->m_att.payload) != 0) + { + sprintf(tmp_buf, "a=rtpmap:%s %s/%s\r\n", + ipbcp_ptr->m_att.payload, + ipbcp_ptr->m_att.encoding_name, + ipbcp_ptr->m_att.clock_rate); + strcat(ptr, tmp_buf); + } + //ipbcp_ptr->ptime[7]='\0'; + if((ipbcp_ptr->ptime[0] != '\0') && (strlen(ipbcp_ptr->ptime)<8)) + { + sprintf(tmp_buf, "a=ptime:%s\r\n", ipbcp_ptr->ptime); + strcat(ptr, tmp_buf); + } + return strlen(ptr); +} diff --git a/omc/plat/bicc/src.old/bicc_msg.c b/omc/plat/bicc/src.old/bicc_msg.c new file mode 100644 index 0000000..9ba7769 --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_msg.c @@ -0,0 +1,1285 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" + +BiccMsg_union msg_union[BICC_MAX_PORT]; +//static up_message_2 up_msg; +extern void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length); +extern u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr); +extern void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type); + +void bicc_decode_app(AppTrans_struct *ptr, const u8 *flw_ptr, u8 length) +{ + int i = 0; + + ptr->pres = 1; + ptr->aci[0] = flw_ptr[i]; + if((flw_ptr[i++] >> 7) == 0) + ptr->aci[1] = flw_ptr[i++]; + ptr->sni = (flw_ptr[i] >> 1) & 0x01; + ptr->rci = flw_ptr[i++] & 0x01; + ptr->si = (flw_ptr[i] >> 6) & 0x01; + ptr->segment = flw_ptr[i] & 0x3f; + if((flw_ptr[i++] >> 7) == 0) + ptr->slr = flw_ptr[i++] & 0x7f; + if(length > i) + apm_decode(&ptr->apm_info, flw_ptr+i, length-i); +} + +u32 bicc_encode_app(u8 *flw_ptr, const AppTrans_struct *ptr) +{ + int i = 0; + + flw_ptr[i++] = ptr->aci[0] | 0x80; +// if((ptr->aci[0] >> 7) == 0) +// flw_ptr[i++] = ptr->aci[1]; + flw_ptr[i++] = (ptr->sni << 1) + ptr->rci; + flw_ptr[i++] = ((ptr->si << 6) + ptr->segment) | 0x80; + return i + apm_encode(flw_ptr+i, &ptr->apm_info); +} + +void bicc_decode_backcall(BackCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val[0] = flw_ptr[0]; + ptr->val[1] = flw_ptr[1]; +} + +u32 bicc_encode_backcall(u8 *flw_ptr, const BackCallInd_struct *ptr) +{ + flw_ptr[0] = ptr->val[0]; + flw_ptr[1] = ptr->val[1]; + return 2; +} + +void bicc_decode_calledptynum(CalledPtyNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->inn = flw_ptr[1] >> 7; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_calledptynum(u8 *flw_ptr, const CalledPtyNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->inn << 7) + (ptr->npi << 4)) & 0xf0; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_callingptynum(CallingPtyNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->ni = flw_ptr[1] >> 7; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + ptr->si = flw_ptr[1] & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_callingptynum(u8 *flw_ptr, const CallingPtyNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = (ptr->ni << 7) + (ptr->npi << 4) + (ptr->apri << 2) + ptr->si; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_callingptycat(CallingPtyCat_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_callingptycat(u8 *flw_ptr, const CallingPtyCat_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + + +u32 bicc_encode_cause(u8 *flw_ptr, const CauseInd_struct *ptr) +{ + flw_ptr[0] = ((ptr->codingStd << 5) + ptr->location) & 0x7f; + flw_ptr[1] = 0x80 | ptr->causeVal; + return 2; +} + +void bicc_decode_cause(CauseInd_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->codingStd = (flw_ptr[0] >> 5) & 0x03; + ptr->location = flw_ptr[0] & 0x0f; + ptr->causeVal = flw_ptr[1] & 0x7f; +} + + +void bicc_decode_cicgrpspv(CicGrpSpv_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_cicgrpspv(u8 *flw_ptr, const CicGrpSpv_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_collectcallreq(CollectCallReq_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_collectcallreq(u8 *flw_ptr, const CollectCallReq_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_conftreat(ConfTreatInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_conftreat(u8 *flw_ptr, const ConfTreatInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_connnum(ConnNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + ptr->si = flw_ptr[1] & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_connnum(u8 *flw_ptr, const ConnNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2) + ptr->si) & 0x7f; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_genericnumber(GenericNumber_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 3) + return; + ptr->pres = 1; + ptr->nqi = flw_ptr[0]; + ptr->nai = flw_ptr[1] & 0x7f; + ptr->ni = flw_ptr[2] >> 7; + ptr->npi = (flw_ptr[2] >> 4) & 0x07; + ptr->apri = (flw_ptr[2] >> 2) & 0x03; + ptr->si = flw_ptr[2] & 0x03; + num_len = length - 3; + num_ptr = flw_ptr + 3; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[1] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +void bicc_decode_genericDigits(GenericDigits_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u8 num_len; + int i, j; + const u8 *num_ptr; + if(length < 3) + return; + ptr->pres = 1; + + ptr->typeOfDigits = flw_ptr[0] & 0x1f; + ptr->encodeScheme = flw_ptr[0] & 0xE0; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digits[j++] = num_ptr[i] & 0x0f; + ptr->digits[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 5) && (j > 0)) + j--; + ptr->numOfDigit = j; + +} + + + + +void bicc_decode_correlationid(CorrelationId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + bicc_decode_genericDigits(ptr, flw_ptr, length); +} + + +u32 bicc_encode_genericnumber(u8 *flw_ptr, const GenericNumber_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 3; + flw_ptr[0] = ptr->nqi; + flw_ptr[1] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[2] = (ptr->ni << 7) + (ptr->npi << 4) + (ptr->apri << 2) + ptr->si; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 3; +} + +u32 bicc_encode_genericDigits(u8 *flw_ptr, const GenericDigits_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + num_ptr = flw_ptr + 1; + flw_ptr[0] = (ptr->encodeScheme << 5) + ptr->typeOfDigits; + flw_ptr[1] = ptr->numOfDigit & 0xff; + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digits[j++] & 0x0f; + num_ptr[i] += ptr->digits[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; + +} + + +u32 bicc_encode_correlationid(u8 *flw_ptr, const CorrelationId_struct *ptr) +{ + return bicc_encode_genericDigits(flw_ptr, ptr); + +} + +void bicc_decode_eventinfo(EventInfo_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_eventinfo(u8 *flw_ptr, const EventInfo_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_fwdcall(FwdCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val[0] = flw_ptr[0]; + ptr->val[1] = flw_ptr[1]; +} + +u32 bicc_encode_fwdcall(u8 *flw_ptr, const FwdCallInd_struct *ptr) +{ + flw_ptr[0] = ptr->val[0]; + flw_ptr[1] = ptr->val[1]; + return 2; +} + + +void bicc_decode_natconn(NatConnInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_natconn(u8 *flw_ptr, const NatConnInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_origcallednum(OrigCalledNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_origcallednum(u8 *flw_ptr, const OrigCalledNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2)) & 0x7c; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_rangestatus(RangeStatus_struct *ptr, const u8 *flw_ptr, u8 length, u8 need_status) +{ + u8 status_len; + + ptr->pres = 1; + ptr->range = flw_ptr[0]; + if(need_status == 1) + { + status_len = (((flw_ptr[0]+1)&0x07) == 0)? ((flw_ptr[0]+1)>>3) : (((flw_ptr[0]+1)>>3) + 1); + memcpy(ptr->status, flw_ptr+1, status_len); + } +} + +u32 bicc_encode_rangestatus(u8 *flw_ptr, const RangeStatus_struct *ptr, u8 need_status) +{ + u8 status_len; + + flw_ptr[0] = ptr->range; + if(need_status == 1) + { + status_len = (((ptr->range+1)&0x07) == 0)? ((ptr->range+1)>>3) : (((ptr->range+1)>>3) + 1); + memcpy(flw_ptr+1, ptr->status, status_len); + } + else + status_len = 0; + return status_len + 1; +} + +void bicc_decode_redirgnum(RedirgNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +void bicc_decode_redirinfo(RedirInfo_struct *ptr, u8 *flw_ptr, u8 length) +{ + if(length <= 2) + return; + ptr->redInd = flw_ptr[0] & 0x07; + ptr->origRedirReason = (flw_ptr[0] >> 4) & 0x0f; + ptr->redirCounter = flw_ptr[1] & 0x07; + ptr->redirReason = (flw_ptr[1] >> 4) & 0x0f; +} + +u32 bicc_encode_redirgnum(u8 *flw_ptr, const RedirgNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2)) & 0x7c; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +u32 bicc_encode_redirinfo(u8 *flw_ptr, const RedirInfo_struct *ptr) +{ + flw_ptr[0] = (ptr->origRedirReason << 4) + ptr->redInd; + flw_ptr[1] = (ptr->redirReason << 4) + ptr->redirCounter; + return 2; +} + +void bicc_decode_scfid(ScfId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + bicc_decode_genericDigits(ptr, flw_ptr, length); +} + +u32 bicc_encode_scfid(u8 *flw_ptr, const ScfId_struct *ptr) +{ + return bicc_encode_genericDigits(flw_ptr, ptr); +} + +void bicc_decode_subseqnum(SubseqNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 1) + return; + ptr->pres = 1; + num_len = length - 1; + num_ptr = flw_ptr + 1; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_subseqnum(u8 *flw_ptr, const SubseqNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 1; + flw_ptr[0] = (ptr->numOfDigit & 0x01) << 7; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_susres(SusResInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_susres(u8 *flw_ptr, const SusResInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_transmedreq(TransMedReq_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_transmedreq(u8 *flw_ptr, const TransMedReq_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_utuind(UserToUserInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_utuind(u8 *flw_ptr, const UserToUserInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_utuinfo(UserToUserInfo_struct *ptr, const u8 *flw_ptr, u8 length) +{ + if((length == 0) || (length > 129)) + return; + ptr->pres = 1; + ptr->len = length; + memcpy(ptr->val, flw_ptr, length); +} + +u32 bicc_encode_utuinfo(u8 *flw_ptr, const UserToUserInfo_struct *ptr) +{ + memcpy(flw_ptr, ptr->val, ptr->len); + return ptr->len; +} + +void bicc_decode_calldiverinfo(CallDiverInfo_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->notifSubsOption = flw_ptr[0]&0x07; + ptr->redirReason = (flw_ptr[0]>>3)&0x0f; +} + +u32 bicc_encode_calldiverinfo(u8 *flw_ptr, const CallDiverInfo_struct *ptr) +{ + flw_ptr[0] = ((ptr->redirReason)<<3) + (ptr->notifSubsOption); + return 1; +} + +void bicc_decode_optBackCallInd(OptBackCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->inbandInfoInd = flw_ptr[0]&0x01; + ptr->callDiverOccurInd = flw_ptr[0]&0x02; + ptr->simpSegmInd = flw_ptr[0]&0x04; + ptr->mlppUserInd = flw_ptr[0]&0x08; +} + +u32 bicc_encode_optBackCallInd(u8 *flw_ptr, const OptBackCallInd_struct *ptr) +{ + flw_ptr[0] = (((ptr->mlppUserInd)<<3)+((ptr->simpSegmInd)<<2)+((ptr->callDiverOccurInd<<1))+(ptr->inbandInfoInd))&0x0f; + return 1; +} + +void bicc_send_acm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccAcm_struct *acm_ptr = &msg_union[pid].acm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_ACM); + *(flw_ptr++) = M_ACM; + flw_ptr += bicc_encode_backcall(flw_ptr, &acm_ptr->backCall); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(acm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &acm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &acm_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &acm_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->optBackCall.pres == 1) + { + flw_ptr[0] = P_OPTBACKCALLIND; + flw_ptr[1] = bicc_encode_optBackCallInd(flw_ptr+2, &acm_ptr->optBackCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &acm_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &acm_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_anm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccAnm_struct *anm_ptr = &msg_union[pid].anm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_ANM); + *(flw_ptr++) = M_ANM; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(anm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &anm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->backCall.pres == 1) + { + flw_ptr[0] = P_BACKCALLIND; + flw_ptr[1] = bicc_encode_backcall(flw_ptr+2, &anm_ptr->backCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &anm_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &anm_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &anm_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &anm_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_apm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccApm_struct *apm_ptr = &msg_union[pid].apm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_APM); + *(flw_ptr++) = M_APM; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(apm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &apm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cpg(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCpg_struct *cpg_ptr = &msg_union[pid].cpg; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CPG); + *(flw_ptr++) = M_CPG; + flw_ptr += bicc_encode_eventinfo(flw_ptr, &cpg_ptr->eventInfo); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(cpg_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &cpg_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->backCall.pres == 1) + { + flw_ptr[0] = P_BACKCALLIND; + flw_ptr[1] = bicc_encode_backcall(flw_ptr+2, &cpg_ptr->backCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->calldiver.pres == 1) + { + flw_ptr[0] = P_CALLDIVERINFO; + flw_ptr[1] = bicc_encode_calldiverinfo(flw_ptr+2, &cpg_ptr->calldiver); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &cpg_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &cpg_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &cpg_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &cpg_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &cpg_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgb(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgb_struct *cgb_ptr = &msg_union[pid].cgb; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGB); + *(flw_ptr++) = M_CGB; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgb_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgb_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgba(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgba_struct *cgba_ptr = &msg_union[pid].cgba; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGBA); + *(flw_ptr++) = M_CGBA; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgba_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgba_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgu(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgu_struct *cgu_ptr = &msg_union[pid].cgu; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGU); + *(flw_ptr++) = M_CGU; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgu_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgu_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgua(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgua_struct *cgua_ptr = &msg_union[pid].cgua; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGUA); + *(flw_ptr++) = M_CGUA; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgua_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgua_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_grs(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccGrs_struct *grs_ptr = &msg_union[pid].grs; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_GRS); + *(flw_ptr++) = M_GRS; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &grs_ptr->rangeStatus, 0); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_gra(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccGra_struct *gra_ptr = &msg_union[pid].gra; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_GRA); + *(flw_ptr++) = M_GRA; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &gra_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_con(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCon_struct *con_ptr = &msg_union[pid].con; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CON); + *(flw_ptr++) = M_CON; + flw_ptr += bicc_encode_backcall(flw_ptr, &con_ptr->backCall); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(con_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &con_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &con_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &con_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &con_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &con_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_iam(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccIam_struct *iam_ptr = &msg_union[pid].iam; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + u8 opt_pointer; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_IAM); + *(flw_ptr++) = M_IAM; + flw_ptr += bicc_encode_natconn(flw_ptr, &iam_ptr->natConn); + flw_ptr += bicc_encode_fwdcall(flw_ptr, &iam_ptr->fwdCall); + flw_ptr += bicc_encode_callingptycat(flw_ptr, &iam_ptr->callingPtyCat); + flw_ptr += bicc_encode_transmedreq(flw_ptr, &iam_ptr->transMedReq); + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_calledptynum(flw_ptr+1, &iam_ptr->calledPtyNum); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0] + 1; + if(iam_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &iam_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->callingPtyNum.pres == 1) + { + flw_ptr[0] = P_CALLINGPTYNUM; + flw_ptr[1] = bicc_encode_callingptynum(flw_ptr+2, &iam_ptr->callingPtyNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->collectCallReq.pres == 1) + { + flw_ptr[0] = P_COLLECTCALLREQ; + flw_ptr[1] = bicc_encode_collectcallreq(flw_ptr+2, &iam_ptr->collectCallReq); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &iam_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->correlationId.pres == 1) + { + flw_ptr[0] = P_CORRELATIONID; + flw_ptr[1] = bicc_encode_correlationid(flw_ptr+2, &iam_ptr->correlationId); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->origCalledNum.pres == 1) + { + flw_ptr[0] = P_ORIGCALLEDNUM; + flw_ptr[1] = bicc_encode_origcallednum(flw_ptr+2, &iam_ptr->origCalledNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->redirgNum.pres == 1) + { + flw_ptr[0] = P_REDIRGNUM; + flw_ptr[1] = bicc_encode_redirgnum(flw_ptr+2, &iam_ptr->redirgNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->redirInfo.pres == 1) + { + flw_ptr[0] = P_REDIRINFO; + flw_ptr[1] = bicc_encode_redirinfo(flw_ptr+2, &iam_ptr->redirInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->scfId.pres == 1) + { + flw_ptr[0] = P_SCFID; + flw_ptr[1] = bicc_encode_scfid(flw_ptr+2, &iam_ptr->scfId); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &iam_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &iam_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + + +void bicc_send_rel(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRel_struct *rel_ptr = &msg_union[pid].rel; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + u8 opt_pointer; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_REL); + *(flw_ptr++) = M_REL; + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_cause(flw_ptr+1, &rel_ptr->cause); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0] + 1; + if(rel_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &rel_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(rel_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &rel_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_rlc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRlc_struct *rlc_ptr = &msg_union[pid].rlc; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_RLC); + *(flw_ptr++) = M_RLC; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(rlc_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &rlc_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + + +void bicc_send_rsc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + + *(flw_ptr++) = M_RSC; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_res(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRes_struct *res_ptr = &msg_union[pid].res; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_RES); + *(flw_ptr++) = M_RES; + flw_ptr += bicc_encode_susres(flw_ptr, &res_ptr->susRes); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_sus(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccSus_struct *sus_ptr = &msg_union[pid].sus; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_SUS); + *(flw_ptr++) = M_SUS; + flw_ptr += bicc_encode_susres(flw_ptr, &sus_ptr->susRes); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_sam(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccSam_struct *sam_ptr = &msg_union[pid].sam; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_SAM); + *(flw_ptr++) = M_SAM; + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_subseqnum(flw_ptr+1, &sam_ptr->subseqNum); + flw_ptr += flw_ptr[0] + 1; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} diff --git a/omc/plat/bicc/src.old/bicc_prm.c b/omc/plat/bicc/src.old/bicc_prm.c new file mode 100644 index 0000000..1e1cb89 --- /dev/null +++ b/omc/plat/bicc/src.old/bicc_prm.c @@ -0,0 +1,244 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "./include/q1902_3e.h" +/**********************************************/ +/******* BICC Message&Primitive Mapping *******/ +/**********************************************/ +void app_msg2prm(AppTransM_struct *dst_ptr, AppTrans_struct *src_ptr) +{ + dst_ptr->pres = src_ptr->pres; + if(src_ptr->pres == 1) + { + memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct)); + dst_ptr->apm_info.sni = src_ptr->sni; + dst_ptr->apm_info.rci = src_ptr->rci; + } +} + +void app_prm2msg(AppTrans_struct *dst_ptr, AppTransM_struct *src_ptr) +{ + dst_ptr->pres = src_ptr->pres; + if(src_ptr->pres == 1) + { + dst_ptr->aci[0] = 0x00; + dst_ptr->aci[1] = 0x00; + dst_ptr->sni = src_ptr->apm_info.sni; + dst_ptr->rci = src_ptr->apm_info.rci; + dst_ptr->si = 0; //subsequent segment to first segment + dst_ptr->segment = 0; //final segment + dst_ptr->slr = 0; + memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct)); + } +} + +void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type) +{ + memset(prm_ptr, 0, sizeof(BiccReadPrim_union)); + switch(msg_type) + { + case M_ACM: + memcpy(&prm_ptr->alert_ind.backCall, &msg_ptr->acm.backCall, sizeof(BackCallInd_struct)); + app_msg2prm(&prm_ptr->alert_ind.app, &msg_ptr->acm.app); + memcpy(&prm_ptr->alert_ind.cause, &msg_ptr->acm.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->alert_ind.confTreat, &msg_ptr->acm.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->alert_ind.optBackCall, &msg_ptr->acm.optBackCall, sizeof(OptBackCallInd_struct)); + memcpy(&prm_ptr->alert_ind.utuInd, &msg_ptr->acm.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->alert_ind.utuInfo, &msg_ptr->acm.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_ANM: + app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->anm.app); + memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->anm.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->anm.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->anm.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->anm.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->anm.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_APM: + app_msg2prm(&prm_ptr->apm_ind.app, &msg_ptr->apm.app); + break; + case M_CPG: + memcpy(&prm_ptr->cpg_ind.eventInfo, &msg_ptr->cpg.eventInfo, sizeof(EventInfo_struct)); + app_msg2prm(&prm_ptr->cpg_ind.app, &msg_ptr->cpg.app); + memcpy(&prm_ptr->cpg_ind.backCall, &msg_ptr->cpg.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->cpg_ind.calldiver,&msg_ptr->cpg.calldiver, sizeof(BiccCpg_struct)); + memcpy(&prm_ptr->cpg_ind.cause, &msg_ptr->cpg.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->cpg_ind.confTreat, &msg_ptr->cpg.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->cpg_ind.connNum, &msg_ptr->cpg.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->cpg_ind.utuInd, &msg_ptr->cpg.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->cpg_ind.utuInfo, &msg_ptr->cpg.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_CGB: + memcpy(&prm_ptr->cgb_ind.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgb_ind.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGBA: + memcpy(&prm_ptr->cgb_cnf.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgb_cnf.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGU: + memcpy(&prm_ptr->cgu_ind.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgu_ind.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGUA: + memcpy(&prm_ptr->cgu_cnf.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgu_cnf.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRS: + memcpy(&prm_ptr->grs_ind.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRA: + memcpy(&prm_ptr->grs_cnf.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CON: + app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->con.app); + memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->con.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->con.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->con.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->con.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->con.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_IAM: + memcpy(&prm_ptr->setup_ind.natConn, &msg_ptr->iam.natConn, sizeof(NatConnInd_struct)); + memcpy(&prm_ptr->setup_ind.fwdCall, &msg_ptr->iam.fwdCall, sizeof(FwdCallInd_struct)); + memcpy(&prm_ptr->setup_ind.callingPtyCat, &msg_ptr->iam.callingPtyCat, sizeof(CallingPtyCat_struct)); + memcpy(&prm_ptr->setup_ind.transMedReq, &msg_ptr->iam.transMedReq, sizeof(TransMedReq_struct)); + memcpy(&prm_ptr->setup_ind.calledPtyNum, &msg_ptr->iam.calledPtyNum, sizeof(CalledPtyNum_struct)); + app_msg2prm(&prm_ptr->setup_ind.app, &msg_ptr->apm.app); + memcpy(&prm_ptr->setup_ind.callingPtyNum, &msg_ptr->iam.callingPtyNum, sizeof(CallingPtyNum_struct)); + memcpy(&prm_ptr->setup_ind.collectCallReq, &msg_ptr->iam.collectCallReq, sizeof(CollectCallReq_struct)); + memcpy(&prm_ptr->setup_ind.confTreat, &msg_ptr->iam.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_ind.correlationId, &msg_ptr->iam.correlationId, sizeof(CorrelationId_struct)); + memcpy(&prm_ptr->setup_ind.origCalledNum, &msg_ptr->iam.origCalledNum, sizeof(OrigCalledNum_struct)); + memcpy(&prm_ptr->setup_ind.redirgNum, &msg_ptr->iam.redirgNum, sizeof(RedirgNum_struct)); + memcpy(&prm_ptr->setup_ind.redirInfo, &msg_ptr->iam.redirInfo, sizeof(RedirInfo_struct)); + memcpy(&prm_ptr->setup_ind.scfId, &msg_ptr->iam.scfId, sizeof(ScfId_struct)); + memcpy(&prm_ptr->setup_ind.utuInd, &msg_ptr->iam.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_ind.utuInfo, &msg_ptr->iam.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_REL: + memcpy(&prm_ptr->rel_ind.cause, &msg_ptr->rel.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->rel_ind.utuInd, &msg_ptr->rel.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->rel_ind.utuInfo, &msg_ptr->rel.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_RLC: + memcpy(&prm_ptr->rel_cnf.cause, &msg_ptr->rlc.cause, sizeof(CauseInd_struct)); + break; + case M_RES: + memcpy(&prm_ptr->res_ind.susRes, &msg_ptr->res.susRes, sizeof(SusResInd_struct)); + break; + case M_SUS: + memcpy(&prm_ptr->sus_ind.susRes, &msg_ptr->sus.susRes, sizeof(SusResInd_struct)); + break; + case M_SAM: + memcpy(&prm_ptr->info_ind.subseqNum, &msg_ptr->sam.subseqNum, sizeof(SubseqNum_struct)); + break; + default: + break; + } +} + +void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type) +{ + memset(msg_ptr, 0, sizeof(BiccMsg_union)); + switch(msg_type) + { + case M_ACM: + memcpy(&msg_ptr->acm.backCall, &prm_ptr->alert_req.backCall, sizeof(BackCallInd_struct)); + app_prm2msg(&msg_ptr->acm.app, &prm_ptr->alert_req.app); + memcpy(&msg_ptr->acm.cause, &prm_ptr->alert_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->acm.confTreat, &prm_ptr->alert_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->acm.optBackCall, &prm_ptr->alert_req.optBackCall, sizeof(OptBackCallInd_struct)); + memcpy(&msg_ptr->acm.utuInd, &prm_ptr->alert_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->acm.utuInfo, &prm_ptr->alert_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_ANM: + app_prm2msg(&msg_ptr->anm.app, &prm_ptr->setup_rsp.app); + memcpy(&msg_ptr->anm.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->anm.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->anm.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->anm.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->anm.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_APM: + app_prm2msg(&msg_ptr->apm.app, &prm_ptr->apm_req.app); + break; + case M_CPG: + memcpy(&msg_ptr->cpg.eventInfo, &prm_ptr->cpg_req.eventInfo, sizeof(EventInfo_struct)); + app_prm2msg(&msg_ptr->cpg.app, &prm_ptr->cpg_req.app); + memcpy(&msg_ptr->cpg.backCall, &prm_ptr->cpg_req.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->cpg.calldiver, &prm_ptr->cpg_req.calldiver, sizeof(BiccCpg_struct)); + memcpy(&msg_ptr->cpg.cause, &prm_ptr->cpg_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->cpg.confTreat, &prm_ptr->cpg_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->cpg.connNum, &prm_ptr->cpg_req.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->cpg.utuInd, &prm_ptr->cpg_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->cpg.utuInfo, &prm_ptr->cpg_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_CGB: + memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_req.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGBA: + memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGU: + memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_req.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGUA: + memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRS: + memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRA: + memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CON: + app_prm2msg(&msg_ptr->con.app, &prm_ptr->setup_rsp.app); + memcpy(&msg_ptr->con.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->con.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->con.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->con.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->con.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_IAM: + memcpy(&msg_ptr->iam.natConn, &prm_ptr->setup_req.natConn, sizeof(NatConnInd_struct)); + memcpy(&msg_ptr->iam.fwdCall, &prm_ptr->setup_req.fwdCall, sizeof(FwdCallInd_struct)); + memcpy(&msg_ptr->iam.callingPtyCat, &prm_ptr->setup_req.callingPtyCat, sizeof(CallingPtyCat_struct)); + memcpy(&msg_ptr->iam.transMedReq, &prm_ptr->setup_req.transMedReq, sizeof(TransMedReq_struct)); + memcpy(&msg_ptr->iam.calledPtyNum, &prm_ptr->setup_req.calledPtyNum, sizeof(CalledPtyNum_struct)); + app_prm2msg(&msg_ptr->iam.app, &prm_ptr->setup_req.app); + memcpy(&msg_ptr->iam.callingPtyNum, &prm_ptr->setup_req.callingPtyNum, sizeof(CallingPtyNum_struct)); + memcpy(&msg_ptr->iam.collectCallReq, &prm_ptr->setup_req.collectCallReq, sizeof(CollectCallReq_struct)); + memcpy(&msg_ptr->iam.confTreat, &prm_ptr->setup_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->iam.correlationId, &prm_ptr->setup_req.correlationId, sizeof(CorrelationId_struct)); + memcpy(&msg_ptr->iam.origCalledNum, &prm_ptr->setup_req.origCalledNum, sizeof(OrigCalledNum_struct)); + memcpy(&msg_ptr->iam.redirgNum, &prm_ptr->setup_req.redirgNum, sizeof(RedirgNum_struct)); + memcpy(&msg_ptr->iam.redirInfo, &prm_ptr->setup_req.redirInfo, sizeof(RedirInfo_struct)); + memcpy(&msg_ptr->iam.scfId, &prm_ptr->setup_req.scfId, sizeof(ScfId_struct)); + memcpy(&msg_ptr->iam.utuInd, &prm_ptr->setup_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->iam.utuInfo, &prm_ptr->setup_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_REL: + memcpy(&msg_ptr->rel.cause, &prm_ptr->rel_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->rel.utuInd, &prm_ptr->rel_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->rel.utuInfo, &prm_ptr->rel_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_RLC: + memcpy(&msg_ptr->rlc.cause, &prm_ptr->rel_rsp.cause, sizeof(CauseInd_struct)); + break; + case M_RES: + memcpy(&msg_ptr->res.susRes, &prm_ptr->res_req.susRes, sizeof(SusResInd_struct)); + break; + case M_SUS: + memcpy(&msg_ptr->sus.susRes, &prm_ptr->sus_req.susRes, sizeof(SusResInd_struct)); + break; + case M_SAM: + memcpy(&msg_ptr->sam.subseqNum, &prm_ptr->info_req.subseqNum, sizeof(SubseqNum_struct)); + break; + default: + break; + } +} diff --git a/omc/plat/bicc/src.old/biccif.c b/omc/plat/bicc/src.old/biccif.c new file mode 100644 index 0000000..aaef225 --- /dev/null +++ b/omc/plat/bicc/src.old/biccif.c @@ -0,0 +1,1080 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "../../public/src/include/license_id.h" + +BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +u8 Bicc_Version[4] = BICC_VERSION; +u8 local_platid=0; +extern BiccData_struct Bicc_Data; +BiccTimer_struct Timer_Data; +up_message_2 r_mtp_msg; //message receive from mtp3 +extern BiccMsg_union msg_union[BICC_MAX_PORT]; + +//void bicc_cpio_proc(u32 pid); +int check_outbound_route(BYTE nw, long dpc, BYTE sls); +extern BOOL bicc_event_handle(u32 pid, const BiccReadPrim_union *prm_ptr, u8 primitive, u8 eventType); +extern void bicc_cpci_proc(u32 pid); +extern void bicc_cpco_proc(u32 pid); +extern void bicc_mgbs_proc(u32 pid); +extern void bicc_mgbr_proc(u32 pid); +extern void bicc_crs_proc(u32 pid); +extern BOOL check_crs_waiting(u32 pid); +extern void bicc_crr_proc(u32 pid); +extern void bicc_cgrs_proc(u32 pid); +extern void bicc_cgrr_proc(u32 pid); +extern void bicc_circuit_reset(u32 pid, const char *s); +extern void bicc_decode_backcall(BackCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_app(AppTrans_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_calledptynum(CalledPtyNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_callingptynum(CallingPtyNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_callingptycat(CallingPtyCat_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_cause(CauseInd_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_cicgrpspv(CicGrpSpv_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_collectcallreq(CollectCallReq_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_conftreat(ConfTreatInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_connnum(ConnNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_genericnumber(GenericNumber_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_genericDigits(GenericDigits_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_correlationid(CorrelationId_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_fwdcall(FwdCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_natconn(NatConnInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_origcallednum(OrigCalledNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_utuind(UserToUserInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_utuinfo(UserToUserInfo_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_eventinfo(EventInfo_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_rangestatus(RangeStatus_struct *ptr, const u8 *flw_ptr, u8 length, u8 need_status); +extern void bicc_decode_transmedreq(TransMedReq_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_redirgnum(RedirgNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_redirinfo(RedirInfo_struct *ptr, u8 *flw_ptr, u8 length); +extern void bicc_decode_scfid(ScfId_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_susres(SusResInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_subseqnum(SubseqNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_calldiverinfo(CallDiverInfo_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_optBackCallInd(OptBackCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type); +extern void bicc_log_err(const char *fmt, ...); +extern void bicc_send_apm(u32 pid); + +int BICC_active_dmp(u8 plat_id, u32 alter_id) +{ + if(plat_id >= 2) + return 0; + Bicc_Data.dmp_data.active = 1; + Bicc_Data.dmp_data.processor_id = local_platid; + Bicc_Data.dmp_data.remote_ip = alter_id; + return BICC_CM_OK; +} + +int BICC_deactive_dmp() +{ + Bicc_Data.dmp_data.active = 0; + Bicc_Data.dmp_data.remote_ip = 0; + Bicc_Data.dmp_data.processor_id = local_platid; + return BICC_CM_OK; +} + +void bicc_transmit_func(u32 remote_ip, up_message_2 *upmsg_ptr) //transmit message to remote ip +{ + upmsg_ptr->dest_ip = remote_ip; + //bicc_to_mtp3(upmsg_ptr); + bicc_redirect(upmsg_ptr); +} + +int getPidByCic(u32 *pid, u32 cg_id, u32 cic) +{ + const pal_circuit_struct *pcircuit = NULL; + if((pcircuit = pal_locate_circuit(cg_id, cic)) != NULL) + { + *pid = (pcircuit->id)*BICC_CIRCUIT_CIC + (cic - pcircuit->attrib.head_cic); + return 1; + } + bicc_log_err("can not get port by cic %d, cg %d [%s]\n", cic,cg_id,__FUNCTION__); + return 0; +} + +static int find_port_by_cic(u8 ni, u32 dpc, u32 opc, u32 cic_val, u32* pid) +{ + const pal_circuit_struct *pcircuit = NULL; + if((pcircuit = pal_ss7_find_circuit(ni, opc, dpc, cic_val)) != NULL) + { + *pid = pcircuit->id*BICC_CIRCUIT_CIC + (cic_val - pcircuit->attrib.head_cic); + return 1; + } + bicc_log_err("can not find port by cic %d dpc %d opc %d ni %d [%s]\n",cic_val,opc,dpc,ni,__FUNCTION__); + return 0; +} + + + +int BICC_mdsc_proc() //get the message form Lower Layer +{ + u32 sap_id, cg_id, circuit_id; + u32 cic_val; + u32 pid; + u8 *flw_ptr; //message flow pointer + u8 msg_type; + BICC_Port_struct *port_ptr; + BiccMsg_union *msg_ptr; + BiccDmp_struct *dmp_ptr = &Bicc_Data.dmp_data; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + if(bicc_GetMsg(&r_mtp_msg) == 0) + return 0; + + + cic_val = (r_mtp_msg.cic[3]<<24) + (r_mtp_msg.cic[2]<<16) + (r_mtp_msg.cic[1]<<8) + r_mtp_msg.cic[0]; + + if(!find_port_by_cic(r_mtp_msg.sio>>6, r_mtp_msg.dpc, r_mtp_msg.opc, cic_val, &pid)) + return 0; + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if((dmp_ptr->active == 1) && (pcircuit != NULL) && (pcircuit->attrib.plat_id != dmp_ptr->processor_id)) + { + bicc_transmit_func(dmp_ptr->remote_ip, &r_mtp_msg); + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 2, cic_val,pid); + return 1 ; + } + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL && pcg->enable == 0) + return 0; + sap_id = pcg->sap_id; + port_ptr = &Bicc_Data.port_data[pid]; + flw_ptr = r_mtp_msg.msgList; + msg_type = *(flw_ptr++); + msg_ptr = &msg_union[pid]; + memset(msg_ptr, 0, sizeof(BiccMsg_union)); + + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 0, cic_val, pid); + switch(msg_type) + { + case M_ACM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv acm at idle"); + break; + } + port_ptr->sprc_cmd = M_ACM; + bicc_decode_backcall(&msg_ptr->acm.backCall, flw_ptr); + flw_ptr += 2; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->acm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->acm.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->acm.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_OPTBACKCALLIND: + bicc_decode_optBackCallInd(&msg_ptr->acm.optBackCall,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->acm.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->acm.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + bicc_cpco_proc(pid); + break; + case M_ANM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv anm at idle"); + break; + } + port_ptr->sprc_cmd = M_ANM; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->anm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_BACKCALLIND: + bicc_decode_backcall(&msg_ptr->anm.backCall, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->anm.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->anm.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->anm.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->anm.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_APM: // APM is not sent to CPC, event handle function is called directly + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv apm at idle"); + return 0; + } + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->apm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_CPG: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv cpg at idle"); + break; + } + port_ptr->sprc_cmd = M_CPG; + bicc_decode_eventinfo(&msg_ptr->cpg.eventInfo, flw_ptr); + flw_ptr += 1; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->cpg.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_BACKCALLIND: + bicc_decode_backcall(&msg_ptr->cpg.backCall, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->cpg.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->cpg.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->cpg.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->cpg.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->cpg.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CALLDIVERINFO: + bicc_decode_calldiverinfo(&msg_ptr->cpg.calldiver, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_CGB: + port_ptr->sprc_cmd = M_CGB; + bicc_decode_cicgrpspv(&msg_ptr->cgb.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgb.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGBA: + port_ptr->sprc_cmd = M_CGBA; + bicc_decode_cicgrpspv(&msg_ptr->cgba.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgba.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGU: + port_ptr->sprc_cmd = M_CGU; + bicc_decode_cicgrpspv(&msg_ptr->cgu.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgu.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGUA: + port_ptr->sprc_cmd = M_CGUA; + bicc_decode_cicgrpspv(&msg_ptr->cgua.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgua.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_GRS: + port_ptr->sprc_cmd = M_GRS; + bicc_decode_rangestatus(&msg_ptr->grs.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 0); + break; + case M_GRA: + port_ptr->sprc_cmd = M_GRA; + bicc_decode_rangestatus(&msg_ptr->gra.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CON: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv con at idle"); + break; + } + port_ptr->sprc_cmd = M_CON; + bicc_decode_backcall(&msg_ptr->con.backCall, flw_ptr); + flw_ptr += 2; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->con.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->con.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->con.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->con.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->con.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_IAM: +#ifdef BICC_REATTEMPT + if(port_ptr->cic_state.call_state == BICC_INCOMING) + return 0; +#else + if(port_ptr->cic_state.call_state != BICC_CIC_IDLE) + return 0; +#endif + if(port_ptr->cic_state.call_state == BICC_TYPE_OUTGOING) + { + bicc_circuit_reset(pid, "recv iam at outgoing cic"); + break; + } +#ifdef BICC_REATTEMPT + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + port_ptr->cic_state.call_state = BICC_INCOMING; // mark the cic + } +#else + port_ptr->cic_state.call_state = BICC_INCOMING; // mark the cic +#endif + port_ptr->sprc_cmd = M_IAM; + bicc_decode_natconn(&msg_ptr->iam.natConn, flw_ptr); + flw_ptr += 1; + bicc_decode_fwdcall(&msg_ptr->iam.fwdCall, flw_ptr); + flw_ptr += 2; + bicc_decode_callingptycat(&msg_ptr->iam.callingPtyCat, flw_ptr); + flw_ptr += 1; + bicc_decode_transmedreq(&msg_ptr->iam.transMedReq, flw_ptr); + flw_ptr += 1; + bicc_decode_calledptynum(&msg_ptr->iam.calledPtyNum, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr)); + flw_ptr++; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->iam.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CALLINGPTYNUM: + bicc_decode_callingptynum(&msg_ptr->iam.callingPtyNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_COLLECTCALLREQ: + bicc_decode_collectcallreq(&msg_ptr->iam.collectCallReq, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->iam.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CORRELATIONID: + bicc_decode_correlationid(&msg_ptr->iam.correlationId, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_ORIGCALLEDNUM: + bicc_decode_origcallednum(&msg_ptr->iam.origCalledNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_REDIRGNUM: + bicc_decode_redirgnum(&msg_ptr->iam.redirgNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_REDIRINFO: + bicc_decode_redirinfo(&msg_ptr->iam.redirInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_SCFID: + bicc_decode_scfid(&msg_ptr->iam.scfId, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->iam.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->iam.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_REL: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + port_ptr->cic_state.call_state = BICC_INCOMING; + port_ptr->sprc_cmd = M_REL; + bicc_decode_cause(&msg_ptr->rel.cause, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr)); + flw_ptr++; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->iam.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->iam.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_RLC: + // if(Bicc_Data.port_data[pid].used_flag == 0) + // return 0; + if(check_crs_waiting(pid)) + port_ptr->sprc_cmd = M_RLC; + else + { + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + // port_ptr->cic_state.call_state = BICC_INCOMING; + break; + port_ptr->sprc_cmd = M_RLC; + } + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->rlc.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_RSC: + port_ptr->sprc_cmd = M_RSC; + break; + case M_RES: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv res at idle"); + break; + } + port_ptr->sprc_cmd = M_RES; + bicc_decode_susres(&msg_ptr->res.susRes, flw_ptr); + break; + case M_SUS: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv sus at idle"); + break; + } + port_ptr->sprc_cmd = M_SUS; + bicc_decode_susres(&msg_ptr->sus.susRes, flw_ptr); + break; + case M_SAM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv sam at idle"); + break; + } + port_ptr->sprc_cmd = M_SAM; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_SUBSEQNUM: + bicc_decode_subseqnum(&msg_ptr->sam.subseqNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + default: //unknow message type + break; + } + bicc_msg2prm(&readPrim_union[pid], &msg_union[pid], msg_type); + if(msg_type == M_GRS) + bicc_cgrr_proc(pid); + if(msg_type == M_GRA) + bicc_cgrs_proc(pid); + if(msg_type == M_APM) + bicc_event_handle(pid, &readPrim_union[pid], BICC_APM_IND, EN_NONE); + if(msg_type == M_IAM) + { + bicc_cpci_proc(pid); + Bicc_Data.port_data[pid].used_flag = 1; + } + return 1; + +} + +void BICC_msdc_proc(u32 pid, up_message_2 * upmsg_ptr) //send the message to Lower Layer +{ + u32 cg_id, circuit_id; + u32 cic_val; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit != NULL) + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL) + return; + if((cic_val = pcircuit->attrib.head_cic+ pid % BICC_CIRCUIT_CIC) > + (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range)) + { + bicc_log_err("No cic corresponds to pid.\n"); + return; + } + + + upmsg_ptr->dest_ip = 0xffffffff; + upmsg_ptr->dpc = pcg->attrib.dpc; + upmsg_ptr->opc = pcg->attrib.opc; + upmsg_ptr->cic[0] = cic_val & 0xff; + upmsg_ptr->cic[1] = (cic_val >> 8) & 0xff; + upmsg_ptr->cic[2] = (cic_val >> 16) & 0xff; + upmsg_ptr->cic[3] = (cic_val >> 24) & 0xff; + upmsg_ptr->sio = (pcg->attrib.network_id<<6) + BICC_SI; + + monitor_bicc_msg(Bicc_Data.port_data[pid].s_mtp_msg.msgList, Bicc_Data.port_data[pid].s_mtp_msg.len, 1, cic_val, pid); + bicc_to_mtp3(upmsg_ptr); +} + +int BICC_con_req(Pst *pst, BiccSetup_Req * ptr) +{ + + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SETUP_REQ; + port_ptr->used_flag = 1; + port_ptr->trace_flag = pst->trace_flag; + //if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + //{ + port_ptr->cic_state.call_state = BICC_OUTGOING; + memcpy(&writePrim_union[pst->sp_proc_id].setup_req, ptr, sizeof(BiccSetup_Req)); + } + else + { + + bicc_log_err("cic not idle,cic=%d, port = %d\n",pst->cic,pst->sp_proc_id); + return 0; + + } + + return 1; + +} + +int BICC_con_rsp(Pst *pst, BiccSetup_Rsp * ptr) +{ + + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SETUP_RSP; + + memcpy(&writePrim_union[pst->sp_proc_id].setup_rsp, ptr, sizeof(BiccSetup_Rsp)); + return 1; +} + + + +int BICC_rel_req(Pst *pst, BiccRel_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RELEASE_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].rel_req, ptr, sizeof(BiccRel_Req)); + return 1; +} + +int BICC_rel_rsp(Pst *pst, BiccRel_Rsp * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RELEASE_RSP; + + memcpy(&writePrim_union[pst->sp_proc_id].rel_rsp, ptr, sizeof(BiccRel_Rsp)); + return 1; +} + +int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_ALERT_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].alert_req, ptr, sizeof(BiccAlert_Req)); + bicc_cpci_proc(pst->sp_proc_id); + return 1; +} + +int BICC_info_req(Pst *pst, BiccInfo_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_INFO_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].info_req, ptr, sizeof(BiccInfo_Req)); + return 1; +} + +int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_PROG_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cpg_req, ptr, sizeof(BiccCpg_Req)); + return 1; +} + +int BICC_block_req(Pst *pst, BiccCgb_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_BLOCK_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cgb_req, ptr, sizeof(BiccCgb_Req)); + + return 1; + + +} + +int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESET_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cgb_req, ptr, sizeof(BiccCgb_Req)); + + return 1; + + + +} + +int BICC_resm_req(Pst *pst, BiccRes_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESUME_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].res_req, ptr, sizeof(BiccRes_Req)); + return 1; +} + +int BICC_apm_req(Pst *pst, BiccApm_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_APM_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].apm_req, ptr, sizeof(BiccApm_Req)); + bicc_send_apm(pst->sp_proc_id); + return 1; +} + +int BICC_sus_req(Pst *pst, BiccSus_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SUSPEND_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].sus_req, ptr, sizeof(BiccSus_Req)); + return 1; +} + + +int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr) +{ + BICC_Port_struct *port_ptr; + //if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + if(ptr!=NULL) + { + port_ptr->primitive_cmd = BICC_GROUP_RESET_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].grs_req, ptr, sizeof(BiccGrs_Req)); + bicc_cgrs_proc(pst->sp_proc_id); + + } + else + port_ptr->primitive_cmd = BICC_RESET_REQ; + +// memcpy(&writePrim_union[pst->sp_proc_id].grs_req, ptr, sizeof(BiccGrs_Req)); + + return 1; + +} + + +int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESET_RSP; + memcpy(&writePrim_union[pst->sp_proc_id].grs_rsp, ptr, sizeof(BiccGrs_Rsp)); + + return 1; +} + +void BICC_EMPTY_APM(ApmUser_struct *ptr) +{ + ptr->action.pres = 0; + ptr->bnc_id.pres = 0; + ptr->bnc_chr.pres = 0; + ptr->bc_info.pres = 0; + ptr->bc_tunnel.pres = 0; + ptr->signal_type.pres = 0; + ptr->duration.pres = 0; +} + +/* This function clear optional parameter flag */ +void BICC_EMPTY_OPTPAR(void *ptr, u8 prim) +{ + if((prim & 0xf0) == 0x00) //request + { + switch(prim) + { + case BICC_SETUP_REQ: + ((BiccSetup_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccSetup_Req *)ptr)->app.apm_info); + ((BiccSetup_Req *)ptr)->callingPtyNum.pres = 0; + ((BiccSetup_Req *)ptr)->collectCallReq.pres = 0; + ((BiccSetup_Req *)ptr)->confTreat.pres = 0; + ((BiccSetup_Req *)ptr)->correlationId.pres = 0; + ((BiccSetup_Req *)ptr)->origCalledNum.pres = 0; + ((BiccSetup_Req *)ptr)->redirgNum.pres = 0; + ((BiccSetup_Req *)ptr)->scfId.pres = 0; + ((BiccSetup_Req *)ptr)->utuInd.pres = 0; + ((BiccSetup_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_ALERT_REQ: + ((BiccAlert_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccAlert_Req *)ptr)->app.apm_info); + ((BiccAlert_Req *)ptr)->cause.pres = 0; + ((BiccAlert_Req *)ptr)->confTreat.pres = 0; + ((BiccAlert_Req *)ptr)->utuInd.pres = 0; + ((BiccAlert_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_APM_REQ: + ((BiccApm_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccApm_Req *)ptr)->app.apm_info); + break; + case BICC_PROG_REQ: + ((BiccCpg_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccCpg_Req *)ptr)->app.apm_info); + ((BiccCpg_Req *)ptr)->backCall.pres = 0; + ((BiccCpg_Req *)ptr)->cause.pres = 0; + ((BiccCpg_Req *)ptr)->confTreat.pres = 0; + ((BiccCpg_Req *)ptr)->connNum.pres = 0; + ((BiccCpg_Req *)ptr)->utuInd.pres = 0; + ((BiccCpg_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_RELEASE_REQ: + ((BiccRel_Req *)ptr)->utuInd.pres = 0; + ((BiccRel_Req *)ptr)->utuInfo.pres = 0; + break; + default: + break; + } + } + else if((prim & 0xf0) == 0x80) //response + { + switch(prim) + { + case BICC_SETUP_RSP: + ((BiccSetup_Rsp *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccSetup_Rsp *)ptr)->app.apm_info); + ((BiccSetup_Rsp *)ptr)->backCall.pres = 0; + ((BiccSetup_Rsp *)ptr)->confTreat.pres = 0; + ((BiccSetup_Rsp *)ptr)->connNum.pres = 0; + ((BiccSetup_Rsp *)ptr)->utuInd.pres = 0; + ((BiccSetup_Rsp *)ptr)->utuInfo.pres = 0; + break; + case BICC_RELEASE_RSP: + ((BiccRel_Rsp *)ptr)->cause.pres = 0; + break; + default: + break; + } + } +} + +void bicc_timer_init(int interval_ms) +{ + BiccTimer_struct *timer_ptr = &Timer_Data; + timer_ptr ->t1 = BICC_T1 * 1000 / interval_ms; + timer_ptr ->t5 = BICC_T5 * 1000 / interval_ms; + timer_ptr ->t7 = BICC_T7 * 1000 / interval_ms; + timer_ptr ->t8 = BICC_T8 * 1000 / interval_ms; + timer_ptr ->t9 = BICC_T9 * 1000 / interval_ms; + timer_ptr ->t12 = BICC_T12 * 1000 / interval_ms; + timer_ptr ->t13 = BICC_T13 * 1000 / interval_ms; + timer_ptr ->t14 = BICC_T14 * 1000 / interval_ms; + timer_ptr ->t15 = BICC_T15 * 1000 / interval_ms; + timer_ptr ->t16 = BICC_T16 * 1000 / interval_ms; + timer_ptr ->t17 = BICC_T17 * 1000 / interval_ms; + timer_ptr ->t18 = BICC_T18 * 1000 / interval_ms; + timer_ptr ->t19 = BICC_T19 * 1000 / interval_ms; + timer_ptr ->t20 = BICC_T20 * 1000 / interval_ms; + timer_ptr ->t21 = BICC_T21 * 1000 / interval_ms; + timer_ptr ->t22 = BICC_T22 * 1000 / interval_ms; + timer_ptr ->t23 = BICC_T23 * 1000 / interval_ms; + timer_ptr ->t28 = BICC_T28 * 1000 / interval_ms; + timer_ptr ->t33 = BICC_T33 * 1000 / interval_ms; + timer_ptr ->t34 = BICC_T34 * 1000 / interval_ms; + timer_ptr ->t35 = BICC_T35 * 1000 / interval_ms; + timer_ptr ->t40 = BICC_T40 * 1000 / interval_ms; + timer_ptr ->t41 = BICC_T41 * 1000 / interval_ms; + timer_ptr ->t42 = BICC_T42 * 1000 / interval_ms; + timer_ptr ->t43 = BICC_T43 * 1000 / interval_ms; + timer_ptr->user_t10 = BICC_USER_T10 * 1000 / interval_ms; + + +} + + +void BICC_init(int interval_ms,int local_id) +{ + u32 stack_size; + printf("Start BICC module init......\n"); + //memset(&BiccResource, 0, sizeof(BICC_Resource_pond)); + memset(&Bicc_Data, 0, sizeof(BiccData_struct)); + bicc_timer_init(interval_ms); + stack_size = sizeof(Bicc_Data); + bicc_debug_init(); + local_platid = local_id; + printf("BICC module init complete! Stack size: %ld bytes\n", stack_size); +} + + +void BICC_cpc_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + if(port_ptr->cic_state.call_state == BICC_INCOMING) + bicc_cpci_proc(pid); + else if(port_ptr->cic_state.call_state == BICC_OUTGOING) + bicc_cpco_proc(pid); + else + { +// if((port_ptr->fsm_state.cgrs_state == 0)&&(port_ptr->primitive_cmd == 0)) +// memset(&Bicc_Data.port_data[pid],0,sizeof(BICC_Port_struct)); + } +} + + +void BICC_csc_proc(u32 pid) +{ + bicc_mgbs_proc(pid); + bicc_mgbr_proc(pid); + bicc_crs_proc(pid); + bicc_crr_proc(pid); + bicc_cgrs_proc(pid); + bicc_cgrr_proc(pid); +// bicc_blr_proc(pid); +// bicc_bls_proc(pid); +} + +void BICC_timer() +{ + u32 i, j; + u32 offset, pid; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + for(i = 0; i < 64; i++) + { + if(BICC_mdsc_proc() == 0) + break; + } + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + pcircuit = pal_circuit_ptr(i); + + if((pcircuit !=NULL) && (pcircuit->enable)) + { + if((pcg = pal_cg_ptr(pcircuit->cg_id)) && (pcg->attrib.protocol == PROTO_BICC)) + { + offset = BICC_CIRCUIT_CIC * i; + for(j = 0; j < BICC_CIRCUIT_CIC; j++) + { + pid = offset + j; + BICC_cpc_proc(pid); + BICC_csc_proc(pid); + } + } + } + } + bicc_debug_timer(); + +} + diff --git a/omc/plat/bicc/src.old/include/.copyarea.db b/omc/plat/bicc/src.old/include/.copyarea.db new file mode 100644 index 0000000..3837c9e --- /dev/null +++ b/omc/plat/bicc/src.old/include/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\bicc\src.old\include +2 +8 +c:bicc_debug.h|1|11d70a3e55c|2d0|bc45c482|e454820e6cf311dd91a5001c23e19543|0 +7:ipbcp.h|1|11d70a3e4ee|5ec|3918ea7e|e3c481de6cf311dd91a5001c23e19543|0 +a:q1902_3e.h|1|11d70a3e4c0|2d50|c4a74e73|e32481c66cf311dd91a5001c23e19543|0 +8:biccif.h|1|11d70a3e636|32e4|3f0cf7b4|e584826e6cf311dd91a5001c23e19543|0 +5:inc.h|1|11d70a3e5ba|e57|566ed92f|e4f4823e6cf311dd91a5001c23e19543|0 +9:q765_5e.h|1|11d70a3e59a|82e|ee80601c|e45482266cf311dd91a5001c23e19543|0 +9:var_ext.h|1|11d70a3e5f8|15c|91ea711b|e4f482566cf311dd91a5001c23e19543|0 +8:define.h|1|11d70a3e53d|1e9|94808f37|e3c481f66cf311dd91a5001c23e19543|0 diff --git a/omc/plat/bicc/src.old/include/bicc_debug.h b/omc/plat/bicc/src.old/include/bicc_debug.h new file mode 100644 index 0000000..01fcba9 --- /dev/null +++ b/omc/plat/bicc/src.old/include/bicc_debug.h @@ -0,0 +1,25 @@ +#include "define.h" +#include "../../../debug/src/include/debug.h" + +#define LOG_ERR_FLAG 0x01 +#define LOG_BICC_FLAG 0x02 +#define LOG_MSG_FLAG 0x04 +#define LOG_TIME_FLAG 0x08 +#define LOG_DMP_FLAG 0x10 +#define LOG_ALL_FLAG 0x1f +#define LOG_FILE_FLAG 0x20 +/*******************************/ +#define MAX_OPR_LEN 16 +#define MAX_OBJ_LEN 32 +#define MAX_VALUE_LEN 32 +#define BICC_PREOID_LEN 12 +#define BICC_DEBUG_OID 17 +#define BICC_DEBUG_PAGE 10 +#define BICC_ASCIN_LEN 128 +#define BICC_ASCOUT_LEN 4096 + + +int bicc_debug_init(); +void bicc_debug_timer(); +void monitor_bicc_msg(u8 *msg,u8 buf_len, BYTE flag, u32 cic, u32 portNo); +void bicc_asciout_proc(const char *fmt, ...); diff --git a/omc/plat/bicc/src.old/include/biccif.h b/omc/plat/bicc/src.old/include/biccif.h new file mode 100644 index 0000000..a755dec --- /dev/null +++ b/omc/plat/bicc/src.old/include/biccif.h @@ -0,0 +1,417 @@ +#ifndef _BICCIF_H_ +#define _BICCIF_H_ + +#include "q765_5e.h" +#include "q1902_3e.h" +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../snmp/src/include/snmp.h" +//#include "../../../public/src/include/proto_pub.h" +#include "bicc_debug.h" +#include "../../../pal/pal.h" +/*********************************/ +/*** BICC Management Structure ***/ +/*********************************/ + +#define BICC_CM_OK 1 //command request success +#define BICC_CM_FAILED -1 //command request failed + +/************************************* +******BICC Resource Structure********* +*************************************/ +#define BICC_MAX_PORT 8192 +#define BICC_CG_CIRCUIT 32 +#define BICC_CIRCUIT_CIC 32 + + +/*** BICC Primitive Parameter Structure (different to q1902_3e) ***/ +typedef struct AppTransM_struct { //Application Transport Mechanism + u8 pres; + ApmUser_struct apm_info; +} AppTransM_struct; +/*********************************/ +/**** BICC Primitive Structure ***/ +/*********************************/ +typedef struct BiccSetup_Req { + NatConnInd_struct natConn;//F + FwdCallInd_struct fwdCall;//F + CallingPtyCat_struct callingPtyCat;//F + TransMedReq_struct transMedReq;//F + CalledPtyNum_struct calledPtyNum;//V + AppTransM_struct app; + CallingPtyNum_struct callingPtyNum; + CollectCallReq_struct collectCallReq; + ConfTreatInd_struct confTreat; + CorrelationId_struct correlationId; + OrigCalledNum_struct origCalledNum; + RedirgNum_struct redirgNum; + RedirInfo_struct redirInfo; + ScfId_struct scfId; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccSetup_Req, BiccSetup_Ind; + +typedef struct BiccSetup_Rsp { + AppTransM_struct app; + BackCallInd_struct backCall;//C: use it if no alert req is sent before + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccSetup_Rsp, BiccSetup_Cnf; + +typedef struct BiccAlert_Req { + BackCallInd_struct backCall;//F + AppTransM_struct app; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + OptBackCallInd_struct optBackCall; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAlert_Req, BiccAlert_Ind; + +typedef struct BiccInfo_Req { + SubseqNum_struct subseqNum;//V +} BiccInfo_Req, BiccInfo_Ind; + +typedef struct BiccApm_Req { + AppTransM_struct app; +} BiccApm_Req, BiccApm_Ind; + +typedef struct BiccCpg_Req { + EventInfo_struct eventInfo;//F + AppTransM_struct app; + BackCallInd_struct backCall; + CallDiverInfo_struct calldiver; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCpg_Req, BiccCpg_Ind; + +typedef struct BiccRel_Req { + CauseInd_struct cause;//V + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccRel_Req, BiccRel_Ind; + +typedef struct BiccRel_Rsp { + CauseInd_struct cause; +} BiccRel_Rsp, BiccRel_Cnf; + +typedef struct BiccRes_Req { + SusResInd_struct susRes;//F +} BiccRes_Req, BiccRes_Ind; + +typedef struct BiccSus_Req { + SusResInd_struct susRes;//F +} BiccSus_Req, BiccSus_Ind; + +typedef struct BiccCgb_Req { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_Req, BiccCgb_Ind; + +typedef struct BiccCgb_Rsp { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_Rsp, BiccCgb_Cnf; + +typedef struct BiccCgu_Req { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_Req, BiccCgu_Ind; + +typedef struct BiccCgu_Rsp { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_Rsp, BiccCgu_Cnf; + +typedef struct BiccGrs_Req { + RangeStatus_struct rangeStatus;//V +} BiccGrs_Req, BiccGrs_Ind; + +typedef struct BiccGrs_Rsp { + RangeStatus_struct rangeStatus;//V +} BiccGrs_Rsp, BiccGrs_Cnf; + + +typedef struct BiccSta_Req +{ + BiccMsg_struct biccMsg; +}BiccSta_Req; + +typedef struct BiccFac_Req +{ + FacInd_struct facInd; +}BiccFac_Req, BiccFac_Ind; + +typedef struct BiccFac_Rsp +{ + FacInd_struct facInd; +}BiccFac_Rsp, BiccFac_Cnf; + +typedef union BiccWritePrim_union { + BiccSetup_Req setup_req; + BiccSetup_Rsp setup_rsp; + BiccAlert_Req alert_req; + BiccInfo_Req info_req; + BiccApm_Req apm_req; + BiccCpg_Req cpg_req; + BiccRel_Req rel_req; + BiccRel_Rsp rel_rsp; + BiccRes_Req res_req; + BiccSus_Req sus_req; + BiccCgb_Req cgb_req;//only used in BICC module + BiccCgb_Rsp cgb_rsp;//only used in BICC module + BiccCgu_Req cgu_req;//only used in BICC module + BiccCgu_Rsp cgu_rsp;//only used in BICC module + BiccGrs_Req grs_req;//only used in BICC module + BiccGrs_Rsp grs_rsp;//only used in BICC module + BiccFac_Req fac_req; + BiccFac_Rsp fac_rsp; +} BiccWritePrim_union; + +typedef union BiccReadPrim_union { + BiccSetup_Ind setup_ind; + BiccSetup_Cnf setup_cnf; + BiccAlert_Ind alert_ind; + BiccInfo_Ind info_ind; + BiccApm_Ind apm_ind; + BiccCpg_Ind cpg_ind; + BiccRel_Ind rel_ind; + BiccRel_Cnf rel_cnf; + BiccRes_Ind res_ind; + BiccSus_Ind sus_ind; + BiccCgb_Ind cgb_ind;//only used in BICC module + BiccCgb_Cnf cgb_cnf;//only used in BICC module + BiccCgu_Ind cgu_ind;//only used in BICC module + BiccCgu_Cnf cgu_cnf;//only used in BICC module + BiccGrs_Ind grs_ind;//only used in BICC module + BiccGrs_Cnf grs_cnf;//only used in BICC module + BiccFac_Ind fac_ind; + BiccFac_Cnf fac_cnf; +} BiccReadPrim_union; + + +/********************************************/ +/****** BICC Internal Command *************/ +/********************************************/ +#define BICC_CMD_UNBLO 0x01 +#define BICC_CMD_BLO 0x02 +#define BICC_CMD_RESET 0x03 +#define BICC_CMD_RESET_COMP 0x04 + + +#define BICC_SI_CPCI 0x10 +#define BICC_SI_CPCO 0x20 +#define BICC_SI_BLS 0x30 +#define BICC_SI_BLR 0x40 +#define BICC_SI_MGBR 0x50 +#define BICC_SI_MGBS 0x60 +#define BICC_SI_CRS 0x70 +#define BICC_SI_CRR 0x80 +#define BICC_SI_CGRS 0x90 +#define BICC_SI_CGRR 0xA0 + +/********************************************/ +/****** BICC Event/Primitive Definition *****/ +/********************************************/ + +#define BICC_SETUP_REQ 0x01 //user-defined, first 4-digit:type of primitive second 4-digit:type of event +#define BICC_SETUP_IND 0x41 +#define BICC_SETUP_RSP 0x81 +#define BICC_SETUP_CNF 0xc1 +#define BICC_ALERT_REQ 0x02 +#define BICC_ALERT_IND 0x42 +#define BICC_INFO_REQ 0x03 +#define BICC_INFO_IND 0x43 +#define BICC_APM_REQ 0x04 +#define BICC_APM_IND 0x44 +#define BICC_PROG_REQ 0x05 +#define BICC_PROG_IND 0x45 +#define BICC_RELEASE_REQ 0x06 +#define BICC_RELEASE_IND 0x46 +#define BICC_RELEASE_RSP 0x86 +#define BICC_RELEASE_CNF 0xc6 +#define BICC_RESET_REQ 0x07 +#define BICC_RESET_IND 0x47 +#define BICC_RESET_CNF 0xc7 +#define BICC_RESET_RSP 0x87 +#define BICC_GROUP_RESET_REQ 0x17 + +#define BICC_BLOCK_REQ 0x08 +#define BICC_BLOCK_IND 0x48 +#define BICC_BLOCK_RSP 0x88 +#define BICC_BLOCK_CNF 0xc8 +#define BICC_UNBLOCK_REQ 0x09 +#define BICC_UNBLOCK_IND 0x49 +#define BICC_UNBLOCK_RSP 0x89 +#define BICC_UNBLOCK_CNF 0xc9 +#define BICC_SUSPEND_REQ 0x0a +#define BICC_SUSPEND_IND 0x4a +#define BICC_RESUME_REQ 0x0b +#define BICC_RESUME_IND 0x4b +#define BICC_REATTEMPT_IND 0x4c +#define BICC_FAILURE_IND 0x4f +#define BICC_FAC_REQ 0x0d +#define BICC_FAC_RSP 0x8d +#define BICC_FAC_IND 0x4d +#define BICC_FAC_CNF 0xcd +#define BICC_STA_IND 0x4e +#define BICC_STA_REQ 0x0e +#define BICC_MAINTENANCE_IND 0x44 // + +#define BICC_STOP_REQ 0xee +#define BICC_STOP_CNF 0xef + +typedef int f_bicc_setup_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_setup_anm_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_setup_con_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_release_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_release_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_alert_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_info_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_prog_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_suspend_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_resume_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reset_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reset_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_apm_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reattempt_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_failure_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_block_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_block_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_unblock_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_unblock_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); + +typedef struct bicc_eventhandle_struct +{ + f_bicc_setup_ind *h_bicc_setup_ind; + f_bicc_setup_anm_cnf *h_bicc_setup_anm_cnf; + f_bicc_setup_con_cnf *h_bicc_setup_con_cnf; + f_bicc_release_ind *h_bicc_release_ind; + f_bicc_release_cnf *h_bicc_release_cnf; + f_bicc_alert_ind *h_bicc_alert_ind; + f_bicc_info_ind *h_bicc_info_ind; + f_bicc_prog_ind *h_bicc_prog_ind; + f_bicc_suspend_ind *h_bicc_suspend_ind; + f_bicc_resume_ind *h_bicc_resume_ind; + f_bicc_block_ind *h_bicc_block_ind; + f_bicc_block_cnf *h_bicc_block_cnf; + f_bicc_unblock_ind *h_bicc_unblock_ind; + f_bicc_unblock_cnf *h_bicc_unblock_cnf; + f_bicc_reset_ind *h_bicc_reset_ind; + f_bicc_reset_cnf *h_bicc_reset_cnf; + f_bicc_apm_ind *h_bicc_apm_ind; + f_bicc_reattempt_ind *h_bicc_reattempt_ind; + f_bicc_failure_ind *h_bicc_failure_ind; + +}BICC_EventHandle_struct; + +typedef struct _bicc_sap_attrib_ +{ + BICC_EventHandle_struct event_handle; +}bicc_sap_sttrib_; + +typedef enum _BICC_network_id +{ + SI_INTERNATIONAL = 0, + SI_INTERNATIONAL_SPARE = 1, + SI_NATIONAL = 2, + SI_NATIONAL_SPARE = 3, + +}SI_Netwrok_ID; + +typedef struct bicc_cic_state +{ + u8 call_state; + u8 sus_state; //suspend state, remote hold? local hold? + u8 blo_state; //block state, remote block? local hold? +}BICC_CIC_state; + +typedef struct bicc_fsm_state +{ + u8 cpc_state; + u8 mgbs_state; + u8 mgbr_state; + u8 crs_state; + u8 crr_state; + u8 cgrs_state; + u8 cgrr_state; +}BICC_Fsm_state; + +typedef struct bicc_port_struct +{ + u8 used_flag; + u8 trace_flag; + u32 w_time; + u32 su_proc_id; + u8 sprc_cmd; + u8 primitive_cmd; + u8 internal_cmd; + BICC_Fsm_state fsm_state; + BICC_CIC_state cic_state; + up_message_2 s_mtp_msg; //message send to mtp3 +}BICC_Port_struct; + +extern up_message_2 r_mtp_msg; //message receive from mtp3 + +typedef struct BiccDmp_struct { + // If DMP is active, circuit 0-127 is according to proccessor 0, circuit 128-255 is accroding to proccessor 1 // + u8 active; + u8 processor_id; + u32 remote_ip; +} BiccDmp_struct; + + +/********************** +***upper layer interface*** +*********************** +*/ + +extern int BICC_con_req(Pst *pst, BiccSetup_Req *ptr); //iam //Connection establishment request +extern int BICC_con_rsp(Pst *pst, BiccSetup_Rsp *ptr); //anm,con //Connection establishment response +extern int BICC_rel_req(Pst *pst, BiccRel_Req *ptr); //Release request +extern int BICC_rel_rsp(Pst *pst, BiccRel_Rsp *ptr); //Release response +extern int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr); //alert +extern int BICC_info_req(Pst *pst, BiccInfo_Req *ptr); //sam +extern int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr); //progress +extern int BICC_apm_req(Pst *pst, BiccApm_Req *ptr); +extern int BICC_sus_req(Pst *pst, BiccSus_Req *ptr); //Call suspend request +extern int BICC_resm_req(Pst *pst, BiccRes_Req *ptr); //Call resume request +extern int BICC_block_req(Pst *pst, BiccCgb_Req *ptr); //block req +extern int BICC_block_rsp(Pst *pst, BiccCgb_Req *ptr); +extern int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr); //unblock req +extern int BICC_unblock_rsp(Pst *pst, BiccCgb_Req *ptr); +extern int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr); +extern int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr); //reset response + +extern void BICC_EMPTY_OPTPAR(void *ptr, u8 prim); + +extern BOOL bicc_trunk_reachable(u32 cg_id); +/***************************** +*** layer management interface*** +****************************** +*/ + +int BICC_active_dmp(u8 plat_id, u32 alter_id ); +int BICC_deactive_dmp(); + +/*********************** +*** lower layer interface*** +************************ +*/ +void BICC_msdc_proc(u32 pid, up_message_2 *upmsg_ptr); +int BICC_mdsc_proc(); + +/****************************** +*** system service interface*** +******************************* +*/ + +void BICC_init(int interval_ms, int local_id); +void BICC_timer(); + +#endif + diff --git a/omc/plat/bicc/src.old/include/define.h b/omc/plat/bicc/src.old/include/define.h new file mode 100644 index 0000000..63fc073 --- /dev/null +++ b/omc/plat/bicc/src.old/include/define.h @@ -0,0 +1,34 @@ +#ifndef _DEFINE_H_ +#define _DEFINE_H_ + +//typedef int BOOL; +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#define BICC_TOLERANT +#define BICC_REATTEMPT +#define BICC_DEBUG + +//Event +#define EN_NONE 0x00 +#define EN_ANM 0x01 +#define EN_CON 0x02 +#define EN_GROUP 0x03 + +#define M_LOCAL_BLOCK 0x01 +#define M_REMOTE_BLOCK 0x02 + +#endif + diff --git a/omc/plat/bicc/src.old/include/inc.h b/omc/plat/bicc/src.old/include/inc.h new file mode 100644 index 0000000..20d1c9c --- /dev/null +++ b/omc/plat/bicc/src.old/include/inc.h @@ -0,0 +1,162 @@ +#ifndef _INC_H +#define _INC_H + +#include +#include +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../snmp/src/include/snmp.h" +#include "biccif.h" + +#define BICC_VERSION {9, 0, 10, 0} +#define BICC_SCREEN_SIZE 32 + +#define BICC_TIMER_STOP 0 +#define BICC_TIMER_EXPIRED 1 +#define BICC_T1 15 +#define BICC_T5 300 +#define BICC_T7 30 +#define BICC_T8 10 +#define BICC_T9 120 +#define BICC_T12 15 +#define BICC_T13 300 +#define BICC_T14 15 +#define BICC_T15 300 +#define BICC_T16 15 +#define BICC_T17 300 +#define BICC_T18 15 +#define BICC_T19 300 +#define BICC_T20 15 +#define BICC_T21 300 +#define BICC_T22 15 +#define BICC_T23 300 +//#define BICC_T24 1 +//#define BICC_T25 1 +//#define BICC_T26 60 +//#define BICC_T27 240 +#define BICC_T28 10 +#define BICC_T33 12 +#define BICC_T34 2 +#define BICC_T35 15 +//#define BICC_T36 10 +//#define BICC_T37 2 +#define BICC_T40 10 +#define BICC_T41 10 +#define BICC_T42 5 +#define BICC_T43 5 +#define BICC_USER_T10 10//user defined timer,10s + + +#define BICC_CIC_IDLE 0 +#define BICC_INCOMING 1 +#define BICC_OUTGOING 2 +#define BICC_RESET 3 + + +#define BICC_TYPE_INCOMING 0 +#define BICC_TYPE_OUTGOING 1 +#define BICC_TYPE_BIDIRECT 2 + +#define BICC_ORIG_SUSPEND 0 //originating side suspend +#define BICC_TERM_SUSPEND 1 //terminating side suspend + + +typedef struct BiccTimer_struct +{ + int t1; + int t5; + int t7; + int t8; + int t9; + int t12; + int t13; + int t14; + int t15; + int t16; + int t17; + int t18; + int t19; + int t20; + int t21; + int t22; + int t23; + int t28; + int t33; + int t34; + int t35; + int t40; + int t41; + int t42; + int t43; + int user_t10; + +}BiccTimer_struct; + +typedef struct BiccMng_struct { + u8 state; + u32 lnk_id; + RangeStatus_struct rangeStatus; +} BiccMng_struct; + + +typedef struct BiccDebug_struct { + u32 flag; + u8 sap_enable[BICC_SCREEN_SIZE]; + u8 sap_cg_num[BICC_SCREEN_SIZE]; + + //u8 cg_enable[BICC_SCREEN_SIZE]; + //u8 network_id[BICC_SCREEN_SIZE]; + + // page 1 // + u8 cic_enable[BICC_SCREEN_SIZE]; + u8 cic_type[BICC_SCREEN_SIZE]; + u8 l_block[BICC_SCREEN_SIZE]; + u8 r_block[BICC_SCREEN_SIZE]; + // page 2 // + u8 cic_status[BICC_SCREEN_SIZE]; + u8 cpc_state[BICC_SCREEN_SIZE]; + u8 mgbs_state[BICC_SCREEN_SIZE]; + u8 mgbr_state[BICC_SCREEN_SIZE]; + u8 crs_state[BICC_SCREEN_SIZE]; + u8 crr_state[BICC_SCREEN_SIZE]; + u8 cgrs_state[BICC_SCREEN_SIZE]; + u8 cgrr_state[BICC_SCREEN_SIZE]; + // page 3 // + u8 sprc_command[BICC_SCREEN_SIZE]; + u8 mgbs_command[BICC_SCREEN_SIZE]; + u8 mgbr_command[BICC_SCREEN_SIZE]; + u8 crs_command[BICC_SCREEN_SIZE]; + u8 crr_command[BICC_SCREEN_SIZE]; + u8 cgrs_command[BICC_SCREEN_SIZE]; + u8 cgrr_command[BICC_SCREEN_SIZE]; + u8 prim_command[BICC_SCREEN_SIZE]; + // page 4 // + u8 mng_state; + u8 mng_lnk_id; +} BiccDebug_struct; + +typedef struct BiccData_struct +{ + BiccDebug_struct debug_data; + BiccMng_struct mng_data; + BiccDmp_struct dmp_data; + BiccTimer_struct timer_data[BICC_MAX_PORT]; + //BICC_Fsm_state fsm_data[BICC_MAX_PORT]; + BICC_Port_struct port_data[BICC_MAX_PORT]; + +}BiccData_struct; + +typedef struct stat_struct { +// u32 en_cic; + u32 lblo_cic; + u32 rblo_cic; +// u32 in_cic; +// u32 out_cic; +// u32 bi_cic; + u32 idle_call; + u32 in_call; + u32 out_call; + u32 lsus_cic; + u32 rsus_cic; +}stat_struct; +#endif + diff --git a/omc/plat/bicc/src.old/include/ipbcp.h b/omc/plat/bicc/src.old/include/ipbcp.h new file mode 100644 index 0000000..813b057 --- /dev/null +++ b/omc/plat/bicc/src.old/include/ipbcp.h @@ -0,0 +1,60 @@ +// Q.1970E; RFC 2327 // +#ifndef _IPBCP_H_ +#define _IPBCP_H_ + +typedef struct SdpOrig_struct { + char username[16]; + char session_id[16]; + char version[8]; + char network_type[8]; + char address_type[8]; + char address[16]; +} SdpOrig_struct; + +typedef struct SdpConn_struct { + char network_type[8]; + char address_type[8]; + char address[16]; +} SdpConn_struct; + +typedef struct SdpTime_struct { + char start[16]; //0 + char stop[16]; //0 +} SdpTime_struct; + +typedef struct SdpAttrib_struct { + char version[8]; //1 + char type[16]; //"Request"/"Accepted"/"Confused"/"Rejected" +} SdpAttrib_struct; + +typedef struct SdpMediaAnn_struct { + char media[16]; + char port[8]; + char transport[16]; + char fmt_list[128]; +} SdpMediaAnn_struct; + +// specify RTP dynamic payload types // +typedef struct SdpMediaAtt_struct { + char payload[8]; + char encoding_name[16]; + char clock_rate[8]; +// char p_time[8]; +} SdpMediaAtt_struct; + +typedef struct IPBCP_struct { + char proto_ver[8]; //Protocol version (M) + SdpOrig_struct orig; //Orign (M) + char session_name[16]; //Session name (M) + SdpConn_struct conn_data; //Connection data + SdpTime_struct time; //Time + SdpAttrib_struct attrib; //Session attribute + SdpMediaAnn_struct m_ann; //Media announcement (M) + SdpMediaAtt_struct m_att; //Media attributes + char ptime[8]; +} IPBCP_struct; + +extern int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr); +extern int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr); + +#endif diff --git a/omc/plat/bicc/src.old/include/q1902_3e.h b/omc/plat/bicc/src.old/include/q1902_3e.h new file mode 100644 index 0000000..16dc75a --- /dev/null +++ b/omc/plat/bicc/src.old/include/q1902_3e.h @@ -0,0 +1,456 @@ +#ifndef _q1902_3E_H_ +#define _q1902_3E_H_ +#include "define.h" +#include "q765_5e.h" +/******************************************/ +/******** BICC SIO (Q.1901E C.7.3) ********/ +/******************************************/ +#define BICC_SI 13 + +/******************************************/ +/* Message Type Codes (Q.1902-3E, page 5) */ +/******************************************/ +#define M_ACM 0x06//Address complete +#define M_ANM 0x09//Answer +#define M_APM 0x41//Application transport +#define M_BLO 0x13//Blocking +#define M_BLA 0x15//Blocking acknowledgement +#define M_CPG 0x2c//Call progress +#define M_CGB 0x18//Circuit/CIC group blocking +#define M_CGBA 0x1a//Circuit/CIC group blocking acknowledgement +#define M_CQM 0x2a//Circuit/CIC group query (national use) +#define M_CQR 0x2b//Circuit/CIC group query response (national use) +#define M_GRS 0x17//Circuit/CIC group reset +#define M_GRA 0x29//Circuit/CIC group reset acknowledgement +#define M_CGU 0x19//Circuit/CIC group unblocking +#define M_CGUA 0x1b//Circuit/CIC group unblocking acknowledgement +#define M_CRG 0x31//Charge information (national use) +#define M_CFN 0x2f//Confusion +#define M_CON 0x07//Connect +#define M_COT 0x05//Continuity +#define M_FAC 0x33//Facility +#define M_FAA 0x20//Facility accepted +#define M_FRJ 0x21//Facility reject +#define M_FAR 0x1f//Facility request +#define M_FOT 0x08//Forward transfer +#define M_IDR 0x36//Identification request +#define M_IRS 0x37//Identification response +#define M_INF 0x04//Information (national use) +#define M_INR 0x03//Information request (national use) +#define M_IAM 0x01//Initial address +#define M_LOP 0x40//Loop prevention +#define M_NRM 0x32//Network resource management +#define M_PRI 0x42//Pre-release information +#define M_REL 0x0c//Release +#define M_RLC 0x10//Release complete +#define M_RSC 0x12//Reset circuit/CIC +#define M_RES 0x0e//Resume +#define M_SGM 0x38//Segmentation +#define M_SAM 0x02//Subsequent address +#define M_SDM 0x43//Subsequent Directory Number (national use) +#define M_SUS 0x0d//Suspend +#define M_UBL 0x14//Unblocking +#define M_UBA 0x16//Unblocking acknowledgement +#define M_UCIC 0x2e//Unequipped CIC (national use) +#define M_USR 0x2d//User-to-user information + + +/*********************************************/ +/* Parameter Name Codes (Q.1902-3E, page 10) */ +/*********************************************/ +#define P_APPTRANS 0x78//Application transport +#define P_BACKCALLIND 0x11//Backward call indicators +#define P_CALLEDPTYNUM 0x04//Called party number +#define P_CALLINGPTYNUM 0x0a//Calling party number +#define P_CALLINGPTYCAT 0x09//Calling party's category +#define P_CAUSEIND 0x02//Cause indicators +#define P_CICGRPSPV 0x15//Circuit/CIC group supervision message type +#define P_COLLECTCALLREQ 0x79//Collect call request +#define P_CONFTREATIND 0x72//Conference treatment indicators +#define P_CONNNUM 0x21//Connected number +#define P_CORRELATIONID 0x65//Correlation id +#define P_EVENINFO 0x24//Event information +#define P_FACIND 0x18//Facility indicator +#define P_FWDCALLIND 0x07//Forward call indicators +#define P_NATCONNIND 0x06//Nature of connection indicators +#define P_ORIGCALLEDNUM 0x28//Original called number +#define P_RANGESTATUS 0x16//Range and status +#define P_REDIRGNUM 0x0b//Redirecting number +#define P_REDIRINFO 0x13//Redirection information +#define P_SCFID 0x66//SCF id +#define P_SUBSEQNUM 0x05//Subsequent number +#define P_SUSRESIND 0x22//Suspend/Resume indicators +#define P_TRANSMEDREQ 0x02//Transmission medium requirement +#define P_UTUIND 0x2a//User-to-user indicators +#define P_UTUINFO 0x20//User-to-user information +#define P_CALLDIVERINFO 0x36//Call diversion information +#define P_OPTBACKCALLIND 0x29//Optional backward call indicators + +/**********************************************/ +/* Parameter Structure (Q.1902-3E, section 6) */ +/**********************************************/ +#define MAX_BICC_DIGIT 32 +#define BICC_STATUS_LEN 32 +#define BICC_APP_LEN 200 +#define MAX_DIAGNOSTIC_LEN 32 + +typedef struct AppTrans_struct { + u8 pres; + u8 aci[2]; //Application context identifier + u8 :6; + u8 sni:1; //Send notification indicator + u8 rci:1; //Release call indicator + u16 :1; + u16 si:1; //Sequence indicator + u16 segment:6; //APM segmentation indicator + u16 :1; + u16 slr:7; //Segmentation local reference + // APM-user information (For APM'98-user application only) // + ApmUser_struct apm_info; +} AppTrans_struct; + +typedef struct BackCallInd_struct { + u8 pres; + u8 val[2]; +} BackCallInd_struct; + +typedef struct CalledPtyNum_struct { + u8 pres; + u8 nai; + u8 inn; + u8 npi; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} CalledPtyNum_struct; + +typedef struct CallingPtyNum_struct { + u8 pres; + u8 nai; + u8 ni; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} CallingPtyNum_struct; + +typedef struct CallingPtyCat_struct { + u8 pres; + u8 val; +} CallingPtyCat_struct; + +/* defined in Q.850E */ +typedef struct CauseInd_struct { + u8 pres; + u8 codingStd; + u8 location; + u8 causeVal; + //diagnostic +} CauseInd_struct; + +typedef struct CicGrpSpv_struct { + u8 pres; + u8 val; +} CicGrpSpv_struct; + +typedef struct CollectCallReq_struct { + u8 pres; + u8 val; +} CollectCallReq_struct; + +typedef struct ConfTreatInd_struct { + u8 pres; + u8 val; +} ConfTreatInd_struct; + +typedef struct ConnNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} ConnNum_struct; + +typedef struct EventInfo_struct { + u8 pres; + u8 val; +} EventInfo_struct; + +typedef struct FacInd_struct { + u8 pres; + u8 val; +} FacInd_struct; + +typedef struct FwdCallInd_struct { + u8 pres; + u8 val[2]; +} FwdCallInd_struct; + +typedef struct GenericNumber_struct { + u8 pres; + u8 nqi; //Number qualifier indicator + u8 nai; + u8 ni; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} GenericNumber_struct; + + +typedef struct GenericDigits_struct /* Generic Digits */ +{ + u8 pres; + u8 typeOfDigits; + u8 encodeScheme; + u8 numOfDigit; + u8* digits; +} GenericDigits_struct; + + +typedef GenericDigits_struct CorrelationId_struct; //R10 + +//typedef struct CorrelationId_struct { //R9 +// u8 pres; +// u8 digit[4]; //4 bytes +//}CorrelationId_struct; +typedef struct NatConnInd_struct { + u8 pres; + u8 val; +} NatConnInd_struct; + +typedef struct OrigCalledNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} OrigCalledNum_struct; + +typedef struct RangeStatus_struct { + u8 pres; + u8 range; + u8 status[BICC_STATUS_LEN]; +} RangeStatus_struct; + +typedef struct RedirgNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} RedirgNum_struct; + +typedef struct RedirInfo_struct{ + u8 pres; + u8 redInd; + u8 origRedirReason; + u8 redirCounter; + u8 redirReason; +}RedirInfo_struct; + +typedef GenericDigits_struct ScfId_struct; +/*typedef struct ScfId_struct { + u8 pres; + u8 nai; + u8 inn; + u8 npi; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +}ScfId_struct; +*/ +typedef struct SubseqNum_struct { + u8 pres; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} SubseqNum_struct; + +typedef struct SusResInd_struct { + u8 pres; + u8 val; +} SusResInd_struct; + +typedef struct TransMedReq_struct { + u8 pres; + u8 val; +} TransMedReq_struct; + +typedef struct UserToUserInd_struct { + u8 pres; + u8 val; +} UserToUserInd_struct; + +typedef struct UserToUserInfo_struct { + u8 pres; + u8 len; + u8 val[129]; +} UserToUserInfo_struct; + +typedef struct CallDiverInfo_struct +{ + u8 pres; + u8 notifSubsOption; + u8 redirReason; +}CallDiverInfo_struct; + +typedef struct OptBackCallInd_struct +{ + u8 pres; + u8 inbandInfoInd; + u8 callDiverOccurInd; + u8 simpSegmInd; + u8 mlppUserInd; +}OptBackCallInd_struct; +/********************************************/ +/* Message structure (Q.1902-3E, section 7) */ +/********************************************/ +typedef struct BiccAcm_struct { + BackCallInd_struct backCall;//F + AppTrans_struct app; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + OptBackCallInd_struct optBackCall; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAcm_struct; + +typedef struct BiccAnm_struct { + AppTrans_struct app; + BackCallInd_struct backCall; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAnm_struct; + +typedef struct BiccApm_struct { + AppTrans_struct app; +} BiccApm_struct; + +typedef struct BiccCpg_struct { + EventInfo_struct eventInfo;//F + AppTrans_struct app; + BackCallInd_struct backCall; + CallDiverInfo_struct calldiver; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCpg_struct; + +typedef struct BiccCgb_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_struct; + +typedef struct BiccCgba_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgba_struct; + +typedef struct BiccCgu_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_struct; + +typedef struct BiccCgua_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgua_struct; + +typedef struct BiccGrs_struct { + RangeStatus_struct rangeStatus;//V +} BiccGrs_struct; + +typedef struct BiccGra_struct { + RangeStatus_struct rangeStatus;//V +} BiccGra_struct; + +typedef struct BiccCon_struct { + BackCallInd_struct backCall;//F + AppTrans_struct app; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCon_struct; + +typedef struct BiccIam_struct { + NatConnInd_struct natConn;//F + FwdCallInd_struct fwdCall;//F + CallingPtyCat_struct callingPtyCat;//F + TransMedReq_struct transMedReq;//F + CalledPtyNum_struct calledPtyNum;//V + AppTrans_struct app; + CallingPtyNum_struct callingPtyNum; + CollectCallReq_struct collectCallReq; + ConfTreatInd_struct confTreat; + CorrelationId_struct correlationId; + OrigCalledNum_struct origCalledNum; + RedirgNum_struct redirgNum; + RedirInfo_struct redirInfo; + ScfId_struct scfId; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; + +} BiccIam_struct; + +typedef struct BiccRel_struct { + CauseInd_struct cause;//V + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccRel_struct; + +typedef struct BiccRlc_struct { + CauseInd_struct cause; +} BiccRlc_struct; + +typedef struct BiccRes_struct { + SusResInd_struct susRes;//F + //Optional +} BiccRes_struct; + +typedef struct BiccSus_struct { + SusResInd_struct susRes;//F + //Optional +} BiccSus_struct; + +typedef struct BiccSam_struct { + SubseqNum_struct subseqNum;//V + //Optional +} BiccSam_struct; + +typedef struct BiccMsg_struct +{ + +}BiccMsg_struct; + + +typedef union BiccMsg_union { + BiccAcm_struct acm; + BiccAnm_struct anm; + BiccApm_struct apm; + BiccCpg_struct cpg; + BiccCgb_struct cgb; + BiccCgba_struct cgba; + BiccCgu_struct cgu; + BiccCgua_struct cgua; + BiccGrs_struct grs; + BiccGra_struct gra; + BiccCon_struct con; + BiccIam_struct iam; + BiccRel_struct rel; + BiccRlc_struct rlc; + BiccRes_struct res; + BiccSus_struct sus; + BiccSam_struct sam; +} BiccMsg_union; + +#endif + diff --git a/omc/plat/bicc/src.old/include/q765_5e.h b/omc/plat/bicc/src.old/include/q765_5e.h new file mode 100644 index 0000000..b404cf0 --- /dev/null +++ b/omc/plat/bicc/src.old/include/q765_5e.h @@ -0,0 +1,100 @@ +#ifndef _q765_5E_H_ +#define _q765_5E_H_ +#include "define.h" + +#define AP_ACTION 0x01 +#define AP_BNCID 0x02 +#define AP_IWFADDR 0x03 +#define AP_CODECLIST 0x04 +#define AP_SINGLECODEC 0x05 +#define AP_BATCR 0x06 +#define AP_BNCCHR 0x07 +#define AP_BCINFO 0x08 +#define AP_BCTUNNEL 0x09 +#define AP_BCUI 0x0a +#define AP_SIGNAL 0x0b +#define AP_BRC 0x0c +#define AP_BRI 0x0d +#define AP_SIGNALTYPE 0x0e +#define AP_DURATION 0x0f + +/************************************************/ +/***** Encapsulated application information *****/ +/************************************************/ +typedef struct ActionInd_struct { + u8 pres; + u8 comp_info; + u8 val; +} ActionInd_struct; + +typedef struct BncId_struct { + u8 pres; + u8 comp_info; + u8 len; + u8 val[4]; +} BncId_struct; + +typedef struct IwfAddr_struct { + u8 pres; + //... +} IwfAddr_struct; + +typedef struct BncChr_struct { + u8 pres; + u8 comp_info; + u8 val; +} BncChr_struct; + +typedef struct BCTP_struct { + // BTCP (Q.1990) // + u8 :1; + u8 bvei:1; //BCTP Version Error Indicator + u8 :1; + u8 btcp_version:5; //BCTP Version Indicator + u8 :1; + u8 tpei:1; //Tunnelled Protocol Error Indicator + u8 tunnel_protocol:6; //Tunnelled Protocol Indicator + // IPBCP (Q.1970) // + u8 ipbcp_len; + u8 ipbcp_content[200]; +} BCTP_struct; + +typedef struct BcInfo_struct { + u8 pres; + u8 comp_info; + BCTP_struct bctp; +} BcInfo_struct; + +typedef struct BcTunnel_struct { + u8 pres; + u8 comp_info; + u8 val; +} BcTunnel_struct; + +typedef struct SignalType_struct { + u8 pres; + u8 comp_info; + u8 val; +} SignalType_struct; + +typedef struct Duration_struct { + u8 pres; + u8 comp_info; + u16 val; +} Duration_struct; + +typedef struct ApmUser_struct { + u8 :6; + u8 sni:1; //Send notification indicator + u8 rci:1; //Release call indicator + ActionInd_struct action; + BncId_struct bnc_id; + BncChr_struct bnc_chr; + BcInfo_struct bc_info; + BcTunnel_struct bc_tunnel; + SignalType_struct signal_type; + Duration_struct duration; +} ApmUser_struct; + +#endif + diff --git a/omc/plat/bicc/src.old/include/var_ext.h b/omc/plat/bicc/src.old/include/var_ext.h new file mode 100644 index 0000000..480534d --- /dev/null +++ b/omc/plat/bicc/src.old/include/var_ext.h @@ -0,0 +1,14 @@ +#ifndef _VAR_EXT_H_ +#define _VAR_EXT_H_ + +#include "define.h" +#include "biccif.h" +#include "inc.h" + + +extern u8 Bicc_Version[4]; +extern BiccData_struct Bicc_Data; +extern BiccTimer_struct Timer_Data; +extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +#endif diff --git a/omc/plat/bicc/src/.copyarea.db b/omc/plat/bicc/src/.copyarea.db new file mode 100644 index 0000000..fc7fc04 --- /dev/null +++ b/omc/plat/bicc/src/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\bicc\src +2 +8 +a:bicc_prm.c|1|11d70a3e7ec|33ed|1c8d9a4|5cd64a3a9a8611dd8b36001c23e19543|0 +a:bicc_fsm.c|1|11d70a3e740|f45c|d7758e91|5e064a9a9a8611dd8b36001c23e19543|0 +a:bicc_msg.c|1|11d70a3e7ad|8563|a0fc75de|5d764a6a9a8611dd8b36001c23e19543|0 +a:bicc_apm.c|1|11d70a3e6d3|1363|b56b34ff|5cd64a529a8611dd8b36001c23e19543|0 +7:include|2|0|0|0|b19bc6669b5711dd8e28001c23e19543|0 +c:bicc_debug.c|1|11d70a3e702|54e6|55931a29|5d764a829a8611dd8b36001c23e19543|0 +8:biccif.c|1|11d70a3e81b|800d|713cda1f|5ea64ae29a8611dd8b36001c23e19543|0 +c:bicc_ipbcp.c|1|11d70a3e76f|1e3d|81f3ff1f|5ea64aca9a8611dd8b36001c23e19543|0 diff --git a/omc/plat/bicc/src/bicc_apm.c b/omc/plat/bicc/src/bicc_apm.c new file mode 100644 index 0000000..90039f9 --- /dev/null +++ b/omc/plat/bicc/src/bicc_apm.c @@ -0,0 +1,206 @@ +#include +#include +#include "./include/q765_5e.h" + +void apm_decode_action(ActionInd_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_action(u8 *flw_ptr, const ActionInd_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_bncid(BncId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->len = length - 1; + memcpy(ptr->val, flw_ptr+1, ptr->len); +} + +u32 apm_encode_bncid(u8 *flw_ptr, const BncId_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + memcpy(flw_ptr+1, ptr->val, ptr->len); + return ptr->len + 1; +} + +void apm_decode_bncchr(BncChr_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_bncchr(u8 *flw_ptr, const BncChr_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_bcinfo(BcInfo_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->bctp.bvei = (flw_ptr[1] >> 6) & 0x01; + ptr->bctp.btcp_version = flw_ptr[1] & 0x1f; + ptr->bctp.tpei = (flw_ptr[2] >> 6) & 0x01; + ptr->bctp.tunnel_protocol = flw_ptr[2] & 0x3f; + ptr->bctp.ipbcp_len = length - 3; + memcpy(ptr->bctp.ipbcp_content, flw_ptr+3, ptr->bctp.ipbcp_len); +} + +u32 apm_encode_bcinfo(u8 *flw_ptr, const BcInfo_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = (ptr->bctp.bvei << 6) + (1 << 5) + ptr->bctp.btcp_version; + flw_ptr[2] = (ptr->bctp.tpei << 6) + ptr->bctp.tunnel_protocol; + memcpy(flw_ptr+3, ptr->bctp.ipbcp_content, ptr->bctp.ipbcp_len); + return ptr->bctp.ipbcp_len + 3; +} + +void apm_decode_bctunnel(BcTunnel_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_bctunnel(u8 *flw_ptr, const BcTunnel_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_signaltype(SignalType_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = flw_ptr[1]; +} + +u32 apm_encode_signaltype(u8 *flw_ptr, const SignalType_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val; + return 2; +} + +void apm_decode_duration(Duration_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->comp_info = flw_ptr[0]; + ptr->val = (flw_ptr[1] << 8) + flw_ptr[2]; +} + +u32 apm_encode_duration(u8 *flw_ptr, const Duration_struct *ptr) +{ + flw_ptr[0] = ptr->comp_info; + flw_ptr[1] = ptr->val >> 8; + flw_ptr[2] = ptr->val & 0xff; + return 3; +} + +void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length) +{ + const u8 *old_ptr = flw_ptr; + + while(flw_ptr+flw_ptr[1]+2-old_ptr <= length) + { + if(*flw_ptr == 0) + break; + switch(*flw_ptr) + { + case AP_ACTION: + apm_decode_action(&ptr->action, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BNCID: + apm_decode_bncid(&ptr->bnc_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BNCCHR: + apm_decode_bncchr(&ptr->bnc_chr, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BCINFO: + apm_decode_bcinfo(&ptr->bc_info, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_BCTUNNEL: + apm_decode_bctunnel(&ptr->bc_tunnel, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_SIGNALTYPE: + apm_decode_signaltype(&ptr->signal_type, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case AP_DURATION: + apm_decode_duration(&ptr->duration, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } +} + +u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr) +{ + u8 *old_ptr = flw_ptr; + + if(ptr->action.pres == 1) + { + flw_ptr[0] = AP_ACTION; + flw_ptr[1] = apm_encode_action(flw_ptr+2, &ptr->action); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bnc_id.pres == 1) + { + flw_ptr[0] = AP_BNCID; + flw_ptr[1] = apm_encode_bncid(flw_ptr+2, &ptr->bnc_id); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bnc_chr.pres == 1) + { + flw_ptr[0] = AP_BNCCHR; + flw_ptr[1] = apm_encode_bncchr(flw_ptr+2, &ptr->bnc_chr); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bc_info.pres == 1) + { + flw_ptr[0] = AP_BCINFO; + flw_ptr[1] = apm_encode_bcinfo(flw_ptr+2, &ptr->bc_info); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->bc_tunnel.pres == 1) + { + flw_ptr[0] = AP_BCTUNNEL; + flw_ptr[1] = apm_encode_bctunnel(flw_ptr+2, &ptr->bc_tunnel); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->signal_type.pres == 1) + { + flw_ptr[0] = AP_SIGNALTYPE; + flw_ptr[1] = apm_encode_signaltype(flw_ptr+2, &ptr->signal_type); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->duration.pres == 1) + { + flw_ptr[0] = AP_DURATION; + flw_ptr[1] = apm_encode_duration(flw_ptr+2, &ptr->duration); + flw_ptr += flw_ptr[1] + 2; + } + return flw_ptr - old_ptr; +} + + diff --git a/omc/plat/bicc/src/bicc_debug.c b/omc/plat/bicc/src/bicc_debug.c new file mode 100644 index 0000000..9182253 --- /dev/null +++ b/omc/plat/bicc/src/bicc_debug.c @@ -0,0 +1,882 @@ +#include "./include/var_ext.h" + +//static u32 bicc_object_id[BICC_PREOID_LEN] = {1,3,6,1,4,1,1373,1,3,2,2,6}; +//static u16 bicc_sub_page[BICC_DEBUG_PAGE] = {0}; +//static u8 bicc_ascii_in[BICC_ASCIN_LEN] = {0}; +//static u8 bicc_ascii_out[BICC_ASCOUT_LEN] = {0}; + +#define BICC_DEBUG_ID 17 +#define BICC_VER_DEBUG "R91V0_01" + +#define MONITOR_NONE 0x0000 +#define MONITOR_ERROR 0x0010 +#define MONITOR_ALL 0xffff + +#define TRACE_FLAG_ON 1 +#define TRACE_FLAG_OFF 0 + +u8 AsciInBuf[4096]; +u8 AsciOutBuf[4096]; +u8 AsciTempBuf[4096]; +WORD MonitorFg; +u8 info[1024]; + +static u8 log_help[] = { + "BICC debug Help:\n\r\ + \n\r\ + 1.help\n\r\ + 2.log all/none\n\r\ + 3.log error on/off\n\r\ + 4.list cg[-cgNo] \n\r\ + 5.list circuit[-circuitNo]\n\r\ + 6.list port[-portNo]\n\r\ + 7.list dmp\n\r\ + 8.trace on-portNo\n\r\ + 9.trace off[-portNo]\n\r\n\r\ +" +}; + +static WORD disp_page[10]; +static u8 *disp_ptr = (u8 *) disp_page; + +static DWORD debug_status_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1 +}; + +static BYTE debug_status = 1; + +static DWORD debug_name_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,2 +}; + +static DWORD debug_ascin_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,3 +}; + +static DWORD debug_ascout_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,4 +}; + +static DWORD debug_page_title[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,1 +}; + +static DWORD debug_page_line[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,2,1 +}; + +const static u8 BASE_ID_LEN = 15; +const static u8 PAGE_POINT = 14; +const static u8 LINE_POINT = 15; + +static u8 title1_p[] = +{ +" BICC Page 01 SAP Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +CG num\n\r" +}; + +static u8 title2_p[] = +{ +" BICC Page 02 CG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SAP id\n\r\ +NI\n\r\ +DPC\n\r" +}; + +static u8 title3_p[] = +{ +" BICC Page 03 CIrcuit Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +CG id\n\r\ +CIC range\n\r\ +HEAD CIC\n\r" +}; + +static u8 title4_p[] = +{ +" BICC Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +FSM State\n\r\ +CIC State\n\r" +}; + +static u8 debug_disp_line(u8 page, u8 line) +{ + u8 disp_length; + disp_length = 0; + disp_ptr = (u8 *) disp_page; + switch (page) + { +/* + case 1: // Page 1: sap Info + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + break; + case 1: + disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_enable; + disp_length = 16; + break; + case 2: + disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_cg_num; + disp_length = 16; + break; + default: + break; + } + break; + case 2: // Page 2: cg Info + //disp_page[page] = (disp_page[page]+1)%BICC_MAX_CG; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].used_flag); + disp_length = 16; + break; + case 2: //sap_id + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].sap_id); + disp_length = 16; + break; + case 3: //network_id + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.network_id); + disp_length = 16; + break; + case 4: //dpc + disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.dpc); + disp_length = 16; + break; + default: + break; + } + break; + + case 3: // Page 3: circuit Info + //disp_page[page] = (disp_page[page]+1)%BICC_MAX_CIRCUIT; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 16; + break; + case 1: //cg_id + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].cg_id); + disp_length = 16; + break; + case 2: //cic_range + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.cic_range); + disp_length = 16; + break; + case 3: //head_cic + disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.head_cic); + disp_length = 16; + break; + default: + break; + } + break; + + case 4: // Page 4: port Info + //disp_page[page] = (disp_page[page]+32)%BICC_MAX_PORT; + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 16; + break; + case 1: //enable + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].used_flag); + disp_length = 16; + break; + case 2: //fsm_state + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].fsm_state); + disp_length = 16; + break; + case 3: //cic_state + disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].cic_state); + disp_length = 16; + break; + default: + break; + } + break; +*/ + default: + disp_length = 0; + break; + } + + return disp_length; +} + +static void debug_disp_page(u8 page) +{ + u8 disp_line; + u8 disp_length; + + debug_page_line[PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = debug_disp_line(page, disp_line); + debug_page_line[LINE_POINT] = disp_line + 2; + debug_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +int bicc_debug_init(void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + + strcpy(AsciInBuf, "\0"); + strcpy(AsciOutBuf, "\0"); + MonitorFg = MONITOR_NONE; + bzero(disp_page, 20); + + ptr = data; + + debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(BASE_ID_LEN, debug_name_id, BICC_VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 4096); + + for (page = 1; page < 5; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + case 2: //page 2 + ptr = title2_p; + break; + case 3: //page 3 + ptr = title3_p; + break; + case 4: //page 4 + ptr = title4_p; + break; + default: + break; + } + + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + debug_disp_page(page); + } + + return 1; +} + +void bicc_asciout_proc(const char *fmt, ...) +{ + va_list ap; + char buf[1024]; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + if((strlen(AsciOutBuf) + strlen(buf)) < 4096) + strcat(AsciOutBuf, buf); + else + strcpy(AsciOutBuf, buf); + va_end(ap); +} + + +void bicc_debug_refresh(void) +{ +// int i; + #if 0 + for(i=0;i<16;i++) + { + Bicc_Data.debug_data.sap_enable[i] = BiccResource.sap_pond[i].used_flag; + Bicc_Data.debug_data.sap_cg_num[i] = BiccResource.sap_pond[i].cg_num; + } + #endif +} + + +#if 0 +void list_sap(WORD sapNo) +{ + //u8 sapinfo[1024]; + if(sapNo >= BICC_MAX_SAP) + return; + + sprintf(info,"\ +Enable:%d\n\r\ +cg num:%d\n\r", + BiccResource.sap_pond[sapNo].used_flag,BiccResource.sap_pond[sapNo].cg_num); + bicc_asciout_proc(info); +} + +void list_all_sap() +{ + int i; + sprintf(info, "Index CG(s)\n\r"); + bicc_asciout_proc(info); + for(i=0; i= PAL_MAX_CG) + return; + pcg = pal_cg_ptr(cgNo); + if(pcg == NULL) + return; + sprintf(info, "\ +Enable:%d\n\r\ +sap id:%d\n\r\ +circuit num:%d\n\r\ +variant_type:%d\n\r\ +priority:%d\n\r\ +network id:%d\n\r\ +opc:%ld\n\r\ +dpc:%ld\n\r\ +tg_id:%ld\n\r", + pcg->enable,pcg->sap_id,pcg->circuit_num,pcg->attrib.variant,pcg->attrib.priority,pcg->attrib.network_id,pcg->attrib.opc,pcg->attrib.dpc,pcg->attrib.tg_id); + bicc_asciout_proc(info); +} + +void list_all_cg() +{ + int i = 0; + const pal_cg_struct *pcg; + sprintf(info, "Index SAP Circuit(s) NetInd DPC OPC TG\n\r"); + bicc_asciout_proc(info); + for(i=0; ienable==0) + continue; + + if(pcg->attrib.protocol != PROTO_BICC) + continue; + sprintf(info, " %d %d %d %d %ld %ld %ld\n\r", i, pcg->sap_id, pcg->circuit_num, pcg->attrib.network_id, pcg->attrib.dpc, pcg->attrib.opc, pcg->attrib.tg_id); + bicc_asciout_proc(info); + } +} + + +void list_circuit(WORD circuitNo) +{ + const pal_circuit_struct *pcircuit; + if(circuitNo >= PAL_MAX_CIRCUIT) + return; + pcircuit = pal_circuit_ptr(circuitNo); + if(pcircuit == NULL) + return ; + + sprintf(info,"\ +Enable:%d\n\r\ +cg id:%d\n\r\ +head cic:%ld\n\r\ +cic range:%d\n\r\ +plat id:%d\n\r", + pcircuit->enable,pcircuit->cg_id,pcircuit->attrib.head_cic,pcircuit->attrib.cic_range,pcircuit->attrib.plat_id); + bicc_asciout_proc(info); +} + + +void list_all_circuit() +{ + int i = 0, j = 0; + const pal_circuit_struct *pcircuit; + const pal_cg_struct *pcg; +// for(i = 0; i < BICC_MAX_SAP; i ++) + //{ + sprintf(info, "Index CG PLAT CIC(s)\n\r"); + bicc_asciout_proc(info); + for(i=0; ienable == 0) + continue; + if(pcg->attrib.protocol != PROTO_BICC) + continue; + for(j = 0; jenable == 0 || pcircuit->cg_id != pcg->id) + continue; + sprintf(info, " %d %d %d %d (%ld~~%ld)\n\r", i, pcircuit->cg_id, pcircuit->attrib.plat_id, pcircuit->attrib.cic_range, pcircuit->attrib.head_cic, pcircuit->attrib.head_cic+pcircuit->attrib.cic_range); + bicc_asciout_proc(info); + + } + + } +} + +void list_port(WORD portNo) +{ + if(portNo>=BICC_MAX_PORT) + return; + sprintf(info,"\ +upper port:%ld\n\r\ +sprc_cmd:%x\n\r\ +primitive_cmd:%x\n\r\ +internal_cmd:%x\n\r\ +cic state{\n\r\ + call state:%d\n\r\ + suspend state:%d\n\r\ + block state:%d\n\r\ + }\n\r\ +fsm state{\n\r\ + cpc_state:%d\n\r\ + mgbs_state:%d\n\r\ + mgbr_state:%d\n\r\ + crs_state:%d\n\r\ + crr_state:%d\n\r\ + cgrs_state:%d\n\r\ + cgrr_state:%d\n\r\ + }\n\r", + Bicc_Data.port_data[portNo].su_proc_id,Bicc_Data.port_data[portNo].sprc_cmd, + Bicc_Data.port_data[portNo].primitive_cmd,Bicc_Data.port_data[portNo].internal_cmd, + Bicc_Data.port_data[portNo].cic_state.call_state,Bicc_Data.port_data[portNo].cic_state.sus_state, + Bicc_Data.port_data[portNo].cic_state.blo_state,Bicc_Data.port_data[portNo].fsm_state.cpc_state, + Bicc_Data.port_data[portNo].fsm_state.mgbs_state,Bicc_Data.port_data[portNo].fsm_state.mgbr_state, + Bicc_Data.port_data[portNo].fsm_state.crs_state,Bicc_Data.port_data[portNo].fsm_state.crr_state, + Bicc_Data.port_data[portNo].fsm_state.cgrs_state,Bicc_Data.port_data[portNo].fsm_state.cgrr_state); + bicc_asciout_proc(info); +} + +void list_busy_port() +{ + int i,j=0; + sprintf(info, "Index PortNo CallState\n\r"); + bicc_asciout_proc(info); + for(i=0;i 0) + { + in_page = AsciInBuf[0] - 1; + ascii_in_ptr = AsciInBuf + 1; + + if (in_page > 4) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + MonitorFg = MonitorFg | MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + MonitorFg = MonitorFg & (~MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + MonitorFg = MONITOR_ALL; + + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + MonitorFg = MONITOR_NONE; + + } + else if (strcmp(ascii_in_ptr,"help") == 0) + { + bicc_asciout_proc(log_help); + } + else if (isdigit(ascii_in_ptr[0])) + { + num = strtoul(ascii_in_ptr, NULL, 10); + disp_page[in_page] = num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, ">")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] += num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, "<"))!= NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] -= num; + debug_disp_page(in_page); + } + #if 0 + else if ((strstr (ascii_in_ptr, "list sap")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + sapNo = strtoul (tmpStr + 1, NULL, 10); + list_sap(sapNo); + } + else + { + list_all_sap(); + } + } +#endif + else if ((strstr (ascii_in_ptr,"list cg")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + // if((tmpStr = strsep(&&ascii_in_ptr, " \t")) != NULL) + { + cgNo = strtoul (tmpStr+1, NULL, 10); + // strsep(, " \t"); + list_cg(cgNo); + } + else + { + list_all_cg(); + } + } + else if ((strstr (ascii_in_ptr, "list circuit")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + circuitNo = strtoul (tmpStr + 1, NULL, 10); + list_circuit(circuitNo); + } + else + { + list_all_circuit(); + } + } + else if ((strstr (ascii_in_ptr, "list port")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul (tmpStr + 1, NULL, 10); + list_port(portNo); + } + else + { + list_busy_port(); + } + + } + else if((strstr (ascii_in_ptr, "list dmp")) != NULL) + { + list_dmp(); + } + else if((strstr(ascii_in_ptr, "trace on")) != NULL) + { + if((tmpStr = strstr(ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul(tmpStr + 1, NULL, 10); + //trace_port(portNo); + Bicc_Data.port_data[portNo].trace_flag = 1; + } + else + {} + } + else if ((strstr (ascii_in_ptr, "trace off")) != NULL) + { + if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL) + { + portNo = strtoul (tmpStr + 1, NULL, 10); + Bicc_Data.port_data[portNo].trace_flag = 0; + } + else + { + int i; + for(i=0; i= 4096) + sprintf(AsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(AsciTempBuf, "%s\n\r", msg); + bicc_asciout_proc(AsciTempBuf); + return 0; + } + + return -1; +} + +void display_bicc_msgtype(u8 msgtype, u32 cic) +{ + switch(msgtype) + { + case M_ACM: + bicc_asciout_proc("ACM:Address complete"); + break; + case M_ANM: + bicc_asciout_proc("ANM:Answer"); + break; + case M_BLO: + bicc_asciout_proc("BLO:Blocking"); + break; + case M_BLA: + bicc_asciout_proc("BLA:Blocking acknowledgement"); + break; + case M_CPG: + bicc_asciout_proc("CPG:Call progress"); + break; + case M_CGB: + bicc_asciout_proc("CGB:Circuit/CIC group blocking"); + break; + case M_CGBA: + bicc_asciout_proc("CGBA:Circuit/CIC group blocking acknowledgement"); + break; + case M_CQM: + bicc_asciout_proc("CQM:Circuit/CIC group query (national use)"); + break; + case M_CQR: + bicc_asciout_proc("CQR:Circuit/CIC group query response (national use)"); + break; + case M_GRS: + bicc_asciout_proc("GRS:Circuit/CIC group reset"); + break; + case M_GRA: + bicc_asciout_proc("GRA:Circuit/CIC group reset acknowledgement"); + break; + case M_CGU: + bicc_asciout_proc("CGU:Circuit/CIC group unblocking"); + break; + case M_CGUA: + bicc_asciout_proc("CGUA:Circuit/CIC group unblocking acknowledgement"); + break; + case M_CRG: + bicc_asciout_proc("CRG:Charge information (national use)"); + break; + case M_CFN: + bicc_asciout_proc("CFN:Confusion"); + break; + case M_CON: + bicc_asciout_proc("CON:Connect"); + break; + case M_COT: + bicc_asciout_proc("COT:Continuity"); + break; + case M_FAC: + bicc_asciout_proc("FAC:Facility "); + break; + case M_FAA: + bicc_asciout_proc("FAA:Facility accepted"); + break; + case M_FRJ: + bicc_asciout_proc("FRJ:Facility reject"); + break; + case M_FAR: + bicc_asciout_proc("FAR:Facility request"); + break; + case M_FOT: + bicc_asciout_proc("FOT:Forward transfer"); + break; + case M_IDR: + bicc_asciout_proc("IDR:Identification request"); + break; + case M_IRS: + bicc_asciout_proc("IRS:Identification response"); + break; + case M_INF: + bicc_asciout_proc("INF:Information (national use)"); + break; + case M_INR: + bicc_asciout_proc("INR:Information request (national use)"); + break; + case M_IAM: + bicc_asciout_proc("IAM:Initial address"); + break; + case M_NRM: + bicc_asciout_proc("NRM:Network resource management"); + break; + case M_REL: + bicc_asciout_proc("REL:Release"); + break; + case M_RLC: + bicc_asciout_proc("RLC:Release complete"); + break; + case M_RSC: + bicc_asciout_proc("RSC:Reset circuit/CIC"); + break; + case M_RES: + bicc_asciout_proc("RES:Resume"); + break; + case M_SGM: + bicc_asciout_proc("SGM:Segmentation"); + break; + case M_SAM: + bicc_asciout_proc("SAM:Subsequent address"); + break; + case M_SUS: + bicc_asciout_proc("SUS:Suspend"); + break; + case M_UBL: + bicc_asciout_proc("UBL:Unblocking"); + break; + case M_UBA: + bicc_asciout_proc("UBA:Unblocking acknowledgement"); + break; + case M_UCIC: + bicc_asciout_proc("UCIC:Unequipped CIC (national use)"); + break; + case M_APM: + bicc_asciout_proc("APM:Application Transport"); + break; + case M_USR: + bicc_asciout_proc("USR:User-to-user information"); + break; + default: + bicc_asciout_proc("Unknown message"); + + } + + bicc_asciout_proc("(message type=0x%x cic=%d)\r\n",msgtype,cic); +} + + +void monitor_bicc_msg(BYTE *msg,BYTE buf_len, BYTE flag, u32 cic, u32 portNo) +{ + BYTE i,temp_buf[1024]; + if(MonitorFg == MONITOR_ALL) + { + if(flag == 0) + bicc_asciout_proc("\33[33mReceive:\33[0m"); + else if(flag == 1) + bicc_asciout_proc("\33[32mSend:\33[0m"); + else if(flag == 2) + bicc_asciout_proc("\33[34mRedirect:\33[0m"); + display_bicc_msgtype(msg[0], cic); + + if(flag != 2) + { + for (i = 0; i < buf_len; i ++) + { + sprintf(&temp_buf[3*i]," %02x", msg[i]); + } + sprintf(&temp_buf[3*i],"\n\r"); + bicc_asciout_proc(temp_buf); + } + } + if(MonitorFg == MONITOR_NONE) + {} + if(Bicc_Data.port_data[portNo].trace_flag == 1) + { + if(flag == 0) + bicc_asciout_proc("\33[33mReceive:\33[0m"); + else if(flag == 1) + bicc_asciout_proc("\33[32mSend:\33[0m"); + else if(flag == 2) + bicc_asciout_proc("\33[34mRedirect:\33[0m"); + display_bicc_msgtype(msg[0], cic); + + if(flag != 2) + { + for (i = 0; i < buf_len; i ++) + { + sprintf(&temp_buf[3*i]," %02x", msg[i]); + } + sprintf(&temp_buf[3*i],"\n\r"); + bicc_asciout_proc(temp_buf); + } + } +} + diff --git a/omc/plat/bicc/src/bicc_fsm.c b/omc/plat/bicc/src/bicc_fsm.c new file mode 100644 index 0000000..944719e --- /dev/null +++ b/omc/plat/bicc/src/bicc_fsm.c @@ -0,0 +1,2093 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "./include/biccif.h" +/**************CPCI*************************/ +#define CPCI_IDLE 0 +#define CPCI_WAIT_CONTINUITY 1 +#define CPCI_WAIT_ACM 2 +#define CPCI_WAIT_ANM 3 +#define CPCI_ANSWERED 4 +#define CPCI_SUSPENDED 5 +#define CPCI_WAIT_RLC 6 +#define CPCI_WAIT_REL_COMP 7 +#define CPCI_WAIT_RESET 8 +#define CPCI_WAIT_GROUP_RESET 9 + +/*************CPCO*************************/ +#define CPCO_IDLE 0 +#define CPCO_WAIT_CONTINUITY 1 +#define CPCO_WAIT_ACM 2 +#define CPCO_WAIT_ANM 3 +#define CPCO_ANSWERED 4 +#define CPCO_SUSPENDED 5 +#define CPCO_WAIT_RLC 6 +#define CPCO_WAIT_REL_COMP 7 +#define CPCO_WAIT_RESET 8 +#define CPCO_WAIT_GROUP_RESET 9 + +/********************************************/ +#define MGBS_IDLE 0 +#define MGBS_WAIT_CGBA 1 +#define MGBS_WAIT_CGUA 2 +/********************************************/ +#define MGBR_IDLE 0 +#define MGBR_WAIT_BLOCKING_RESP 1 +#define MGBR_WAIT_UNBLOCKING_RESP 2 +/********************************************/ +#define CRS_IDLE 0 +#define CRS_WAIT_REL 1 +/*******************************************/ +#define CRR_IDLE 0 +#define CRR_WAIT_RESPONSE 1 +#define CRR_RESET 2 +#define CRR_RESET_COMP 3 +/*******************************************/ +#define CGRS_IDLE 0 +#define CGRS_WAIT_GRA 1 +/*******************************************/ +#define CGRR_IDLE 0 +#define CGRR_WAIT_GROUP_RESET_COMP 1 +/********************************************/ +#define BLR_IDLE 0 +#define BLR_WAIT_BLOCKING_RESP 1 +#define BLR_REMOTE_LOCKED 2 +#define BLR_WAIT_UNBLOCKING_RESP 3 +/********************************************/ +#define BLS_IDLE 0 +#define BLS_WAIT_BLA 1 +#define BLS_LOCAL_LOCKED 2 +#define BLS_WAIT_UBA 3 +/*******************************************/ + + + +BiccData_struct Bicc_Data; +const BiccTimer_struct *TIMER_PTR = &Timer_Data; + + +extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +//extern BICC_Resource_pond BiccResource; +extern BiccMsg_union msg_union[BICC_MAX_PORT]; +extern u8 local_platid; + +extern void bicc_send_apm(u32 pid); +extern void bicc_log_err(const char *fmt, ...); +extern void bicc_send_res(u32 pid); +extern void bicc_send_sus(u32 pid); +extern void bicc_send_sam(u32 pid); +extern void bicc_send_rsc(u32 pid); +extern void bicc_send_rlc(u32 pid); +extern void bicc_send_rel(u32 pid); +extern void bicc_send_iam(u32 pid); +extern void bicc_send_con(u32 pid); +extern void bicc_send_gra(u32 pid); +extern void bicc_send_grs(u32 pid); +extern void bicc_send_cgua(u32 pid); +extern void bicc_send_cgu(u32 pid); +extern void bicc_send_cgba(u32 pid); +extern void bicc_send_cgb(u32 pid); +extern void bicc_send_cpg(u32 pid); +extern void bicc_send_anm(u32 pid); +extern void bicc_send_acm(u32 pid); +extern BOOL check_crs_waiting(u32 pid); +extern int check_outbound_route(BYTE nw, long dpc, BYTE sls); + + +void bicc_cpc_clear(u32 pid) +{ + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); +} + + +BOOL bicc_cgrs_func(u32 start_pid, u8 range) +{ + int i; + u32 pid; + + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_RESET; + + } + return 1; +} + +BOOL bicc_cgrsack_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.call_state = BICC_CIC_IDLE; + memset(&Bicc_Data.port_data[pid], 0, sizeof(BICC_Port_struct)); + + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state |= M_REMOTE_BLOCK; + else + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + //BiccResource.circuit_pond[start_pid/BICC_CIRCUIT_CIC].active_flag = 1; + return 1; +} + +BOOL bicc_cgrr_func(u32 start_pid, u8 range, RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + rs_ptr->range = range; + memset(rs_ptr->status, 0, 4); + if(start_pid+range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + if(Bicc_Data.port_data[pid].cic_state.blo_state & M_LOCAL_BLOCK) + { + if(Bicc_Data.port_data[pid].fsm_state.mgbs_state != MGBS_WAIT_CGUA) + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + } + } + return 1; +} + + +void bicc_set_cause(CauseInd_struct *cause_ptr, u8 val) +{ + cause_ptr->pres = 1; + cause_ptr->codingStd = 0; //CCITT standardized coding + cause_ptr->location = 5; //private network serving the remote user + cause_ptr->causeVal = val; +} + +void bicc_circuit_reset(u32 pid, const char *s) +{ + #ifdef BICC_DEBUG + bicc_log_err("BICC circuit reset!, %s\n", s); + #endif + + if(check_crs_waiting(pid)) + return; + Bicc_Data.port_data[pid].primitive_cmd = BICC_RESET_REQ; +} + + +BOOL bicc_localblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_LOCAL_BLOCK; + } + return 1; +} + +BOOL bicc_remoteblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= M_REMOTE_BLOCK; + } + return 1; +} + +BOOL bicc_cpcoblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + if(Bicc_Data.port_data[pid].cic_state.call_state == BICC_OUTGOING) + Bicc_Data.port_data[pid].internal_cmd = (BICC_CMD_BLO|BICC_SI_MGBR); + } + } + return 1; +} + +BOOL bicc_localunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0e; + } + return 1; +} + +BOOL bicc_remoteunblocking_func(u32 start_pid, const RangeStatus_struct *rs_ptr) +{ + int i; + u32 pid; + + if(start_pid+rs_ptr->range >= BICC_MAX_PORT) + return 0; + for(i = 0; i <= rs_ptr->range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + Bicc_Data.port_data[pid].cic_state.blo_state &= 0x0d; + } + return 1; +} + + +BOOL bicc_event_handle(u32 pid, BiccReadPrim_union *prm_ptr, u8 primitive, u8 eventType) +{ + BICC_EventHandle_struct *eh_ptr = NULL; + Pst pst; + u32 cic; + int circuit_id, offset, ret = -1; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + offset = pid % BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return BICC_CM_FAILED; + cic = pcircuit->attrib.head_cic + offset; + + pst.cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(pst.cg_id); + if(pcg == NULL) + return BICC_CM_FAILED; + if(pcg->attrib.protocol != PROTO_BICC) + return BICC_CM_FAILED; + pst.tg_id = pcg->attrib.tg_id; + pst.sp_proc_id = pid; + pst.su_proc_id = Bicc_Data.port_data[pid].su_proc_id; + pst.cic = cic; + pst.trace_flag = 0; + + eh_ptr = (BICC_EventHandle_struct *)pal_get_handler(pst.cg_id); + if(eh_ptr == NULL) + return BICC_CM_FAILED; + + switch(primitive) + { + case BICC_SETUP_IND: + if(eh_ptr->h_bicc_setup_ind != NULL) + { + ret = eh_ptr->h_bicc_setup_ind(&pst, prm_ptr); + if(pst.trace_flag == 1) + { + //BiccResource.port_pond[pid].trace_flag = 1; + Bicc_Data.port_data[pid].trace_flag = 1; + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 0, cic, pid); + } + } + else + bicc_log_err("Setup indicate handle is not registered.\n"); + if(ret != -1) + Bicc_Data.port_data[pid].su_proc_id = pst.su_proc_id; + break; + + case BICC_SETUP_CNF: + if(eventType == EN_CON) + { + if(eh_ptr->h_bicc_setup_con_cnf != NULL) + { + if(!eh_ptr->h_bicc_setup_con_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Setup confirm handle is not registered.\n"); + break; + + } + else + { + if(eh_ptr->h_bicc_setup_anm_cnf != NULL) + eh_ptr->h_bicc_setup_anm_cnf(&pst, prm_ptr); + else + bicc_log_err("Setup confirm handle is not registered.\n"); + } + + break; + + case BICC_ALERT_IND: + if(eh_ptr->h_bicc_alert_ind != NULL) + { + if(!eh_ptr->h_bicc_alert_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Alert indication handle is not registered.\n"); + break; + + case BICC_RELEASE_IND: + if(eh_ptr->h_bicc_release_ind != NULL) + { + if(!eh_ptr->h_bicc_release_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release indication is not registered.\n"); + break; + + case BICC_APM_IND: + if(eh_ptr->h_bicc_apm_ind != NULL) + { + if(!eh_ptr->h_bicc_apm_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("APM indication is not registered.\n"); + break; + + case BICC_RELEASE_CNF: + if(eh_ptr->h_bicc_release_cnf != NULL) + { + if(!eh_ptr->h_bicc_release_cnf(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Release confirm is not registered.\n"); + break; + + case BICC_INFO_IND: + if(eh_ptr->h_bicc_info_ind != NULL) + { + if(!eh_ptr->h_bicc_info_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("info indication is not registered.\n"); + break; + + case BICC_SUSPEND_IND: + if(eh_ptr->h_bicc_suspend_ind != NULL) + { + if(!eh_ptr->h_bicc_suspend_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Suspend indication is not registered.\n"); + break; + + case BICC_RESUME_IND: + if(eh_ptr->h_bicc_resume_ind != NULL) + { + if(!eh_ptr->h_bicc_resume_ind(&pst, prm_ptr)) + return 0; + } + else + bicc_log_err("Resume indication is not registered.\n"); + break; + + case BICC_PROG_IND: + if(eh_ptr->h_bicc_prog_ind != NULL) + eh_ptr->h_bicc_prog_ind(&pst, prm_ptr); + else + bicc_log_err("Call progress indication handle is not registered.\n"); + break; + case BICC_RESET_IND: + if(eh_ptr->h_bicc_reset_ind != NULL) + eh_ptr->h_bicc_reset_ind(&pst, prm_ptr); + + else + bicc_log_err("Reset indicate handle is not registered.\n"); + break; + case BICC_RESET_CNF: + if(eh_ptr->h_bicc_reset_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_reset_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_reset_cnf(&pst, NULL); + } + else + bicc_log_err("Reset cnf handle is not registered.\n"); + break; + case BICC_FAILURE_IND: + if(eh_ptr->h_bicc_failure_ind != NULL) + eh_ptr->h_bicc_failure_ind(&pst, prm_ptr); + else + bicc_log_err("Failure indicate handle is not registered.\n"); + break; + case BICC_REATTEMPT_IND: + if(eh_ptr->h_bicc_reattempt_ind != NULL) + eh_ptr->h_bicc_reattempt_ind(&pst, prm_ptr); + else + bicc_log_err("Reattempt indicate handle is not registered.\n"); + break; + case BICC_BLOCK_IND: + if(eh_ptr->h_bicc_block_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_ind(&pst, NULL); + } + else + bicc_log_err("Block indicate handle is not registered.\n"); + break; + + case BICC_BLOCK_CNF: + if(eh_ptr->h_bicc_block_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_block_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_block_cnf(&pst, NULL); + } + else + bicc_log_err("Block confirm handle is not registered.\n"); + break; + case BICC_UNBLOCK_IND: + if(eh_ptr->h_bicc_unblock_ind != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_ind(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_ind(&pst, NULL); + } + else + bicc_log_err("Unblock indicate handle is not registered.\n"); + break; + case BICC_UNBLOCK_CNF: + if(eh_ptr->h_bicc_unblock_cnf != NULL) + { + if(eventType == EN_GROUP) + eh_ptr->h_bicc_unblock_cnf(&pst, prm_ptr); + else + eh_ptr->h_bicc_unblock_cnf(&pst, NULL); + } + else + bicc_log_err("Unblock confirm handle is not registered.\n"); + break; + default: + break; + } + return 1; +} + + +void bicc_dualseizure_func(u32 pid) +{ + int cg_id; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + pcircuit = pal_circuit_ptr(pid / BICC_CIRCUIT_CIC); + if(pcircuit == NULL) + return; + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL) + return; + if(pcg->attrib.priority == 0) + return; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, NULL, BICC_REATTEMPT_IND, EN_NONE); + bicc_cpc_clear(pid); + Bicc_Data.port_data[pid].cic_state.call_state = BICC_INCOMING; + port_ptr->sprc_cmd = M_IAM; +} + + +void bicc_cpci_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCI_IDLE: + if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].setup_ind.callingPtyCat.val != 0x0d) //test call? + { + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK) + port_ptr->cic_state.blo_state &= 0x01; //set remote unblocked + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + { + bicc_cpc_clear(pid); + return; + } + + } + if(bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_IND, EN_NONE)) + { + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + + } + else + { + bicc_circuit_reset(pid, "setup ind rejected"); + bicc_cpc_clear(pid); + return; + } + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->sprc_cmd !=0 ) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_circuit_reset(pid, "unexpected message"); + bicc_cpc_clear(pid); + return ; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CRR); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CGRR); + bicc_cpc_clear(pid); + return ; + } + + break; + case CPCI_WAIT_CONTINUITY: + break; + case CPCI_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_ALERT_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_acm(pid); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ANM; + } + else if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_con(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + tempTimer->t9 = TIMER_PTR->t9; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr ->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +/* else if(port_ptr->sprc_cmd == M_SAM) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_INFO_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + } +*/ + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CPCI); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBS)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_anm(pid); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_PROG_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cpg(pid); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } +#ifdef BICC_TOLERANT + // To avoid both side backoff // + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpci wait anm"); + bicc_cpc_clear(pid); + return; + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + // break; + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x13); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + break; + + case CPCI_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_SUSPENDED: + if(port_ptr->primitive_cmd == BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state= CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + + case CPCI_WAIT_RLC: + if(port_ptr->sprc_cmd== M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_circuit_reset(pid, "t5 expired cpci wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + //if(cpc_ptr->crr_cmd == BICC_RESET_IND) + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid,&readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + } + +#endif + break; + case CPCI_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCI); + bicc_cpc_clear(pid); + return; + } + break; + case CPCI_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +inline void bicc_cpco_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCO_IDLE: + if(port_ptr->primitive_cmd== BICC_SETUP_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_iam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ACM; + } + else + bicc_cpc_clear(pid); + break; + case CPCO_WAIT_CONTINUITY: + break; + case CPCO_WAIT_ACM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == BICC_INFO_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sam(pid); + tempTimer->t7 = TIMER_PTR->t7; + port_ptr->w_time = 0; + } + else if(port_ptr->sprc_cmd == M_ACM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + tempTimer->t9 = TIMER_PTR->t9; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_ALERT_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ANM; + } + else if(port_ptr->sprc_cmd == M_CON) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_CON); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +/* else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } +*/ + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; //discard... + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + // fsm_ptr->timer_data.t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t7 = BICC_TIMER_STOP; + + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#ifdef BICC_REATTEMPT + else if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + bicc_dualseizure_func(pid); + } +#endif + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_circuit_reset(pid, "unexpected message cpco wait acm"); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t7-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x12); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_BLO|BICC_SI_MGBR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t7 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_ANM: + if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SETUP_CNF, EN_ANM); + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_PROG_IND, EN_NONE); + } +#ifdef BICC_TOLERANT + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + port_ptr->w_time = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + tempTimer->t9 = BICC_TIMER_STOP; + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } +#endif +#ifdef BICC_TOLERANT + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } +#endif + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t9 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->t9-- == BICC_TIMER_EXPIRED) + { + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + break; + case CPCO_ANSWERED: + if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + port_ptr->cic_state.sus_state = BICC_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid,&readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + port_ptr->cic_state.sus_state = BICC_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_SUSPENDED: + if(port_ptr->primitive_cmd== BICC_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_res(pid); + if(port_ptr->cic_state.sus_state == BICC_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->primitive_cmd == BICC_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_sus(pid); + } + else if(port_ptr->primitive_cmd == BICC_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESUME_IND, EN_NONE); + if(port_ptr->cic_state.sus_state == BICC_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + tempTimer->user_t10 = TIMER_PTR->user_t10; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_FAILURE_IND, EN_NONE); + bicc_set_cause(&writePrim_union[pid].rel_req.cause, 0x10); //Normal call clearing + bicc_send_rel(pid); + tempTimer->t5 = TIMER_PTR->t5; + tempTimer->t1 = TIMER_PTR->t1; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + tempTimer->user_t10 = TIMER_PTR->user_t10; + + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_RLC: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t5 = BICC_TIMER_STOP; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + // bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_IND, EN_NONE); + bicc_send_rlc(pid); + } + else if(tempTimer->t1-- == BICC_TIMER_EXPIRED) + { + bicc_send_rel(pid); + tempTimer->t1 = TIMER_PTR->t1; + } + else if(tempTimer->t5-- == BICC_TIMER_EXPIRED) + { + tempTimer->t1 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "t5 expired cpco wait rlc"); + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_SETUP_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd= 0; + tempTimer->t5 = BICC_TIMER_STOP; + tempTimer->t1 = BICC_TIMER_STOP; + //The Ind must sent to CC because this Req is not by CC but BICC locally + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_IND, EN_NONE); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == BICC_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + tempTimer->user_t10 = 0; + + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRR)) + { + port_ptr->internal_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + //bicc_event_handle(pid, &readPrim_union[pid], BICC_RELEASE_CNF, EN_NONE); + bicc_send_rlc(pid); + bicc_cpc_clear(pid); + return; + } + + break; + case CPCO_WAIT_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + //port_ptr->fsm_state.cpc_state = BICC_RESET_RSP; + port_ptr->internal_cmd = (BICC_CMD_RESET_COMP|BICC_SI_CPCO); + bicc_cpc_clear(pid); + return; + } + else if(tempTimer->user_t10-- == BICC_TIMER_EXPIRED) + { + tempTimer->user_t10 = BICC_TIMER_STOP; + bicc_circuit_reset(pid, "user t10 expired cpco wait release complete"); + bicc_cpc_clear(pid); + return; + } + break; + case CPCO_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + bicc_cpc_clear(pid); + return; + } + break; + default: + break; + } +} + + +/********************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Sending */ +/********************************************************************/ +inline void bicc_mgbs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + { + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + tempTimer->t18 = 0; + tempTimer->t19 = 0; + } + return ; + } + switch(port_ptr->fsm_state.mgbs_state) + { + case MGBS_IDLE: + if(port_ptr->primitive_cmd == BICC_BLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_localblocking_func(pid, &writePrim_union[pid].cgb_req.rangeStatus); + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + tempTimer->t19 = TIMER_PTR->t19; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGBA; + } + else if(port_ptr->primitive_cmd == BICC_UNBLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + tempTimer->t21 = TIMER_PTR->t21; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGUA; + } + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + //discard + } + else if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + //discard + } + break; + case MGBS_WAIT_CGBA: + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_cnf.rangeStatus.range >= 32) + return; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_CNF, EN_GROUP); + } + + if(tempTimer->t18 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t18 = TIMER_PTR->t18; + } + if(tempTimer->t19 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t19 = TIMER_PTR->t19; //ignore first T19 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t18 = BICC_TIMER_STOP; + tempTimer->t19 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + + } + break; + case MGBS_WAIT_CGUA: + if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_cnf.rangeStatus.range >= 32) + return; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + bicc_localunblocking_func(pid, &readPrim_union[pid].cgu_cnf.rangeStatus); + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_CNF, EN_GROUP); + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + + if(tempTimer->t20 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgu(pid); + tempTimer->t20 = TIMER_PTR->t20; + } + if(tempTimer->t21 -- == BICC_TIMER_EXPIRED) + { + bicc_send_cgb(pid); + tempTimer->t21 = TIMER_PTR->t21; //ignore first T21 expired + } + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRS)) + { + port_ptr->internal_cmd = 0; + tempTimer->t20 = BICC_TIMER_STOP; + tempTimer->t21 = BICC_TIMER_STOP; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + } + break; + default: + break; + } +} + +/************************************************************************/ +/* Maintenance Oriented Circuit Group Blocking/Unbolcking Reception */ +/************************************************************************/ +inline void bicc_mgbr_proc(u32 pid) +{ + + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + //BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + switch(port_ptr->fsm_state.mgbr_state) + { + case MGBR_IDLE: + if(port_ptr->sprc_cmd == M_CGB) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgb_ind.rangeStatus.range >= 32) + return; + bicc_cpcoblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_BLOCKING_RESP; + bicc_event_handle(pid, &readPrim_union[pid], BICC_BLOCK_IND, EN_GROUP); + } + else if(port_ptr->sprc_cmd == M_CGU) + { + port_ptr->sprc_cmd = 0; + if(readPrim_union[pid].cgu_ind.rangeStatus.range >= 32) + return; + bicc_event_handle(pid, &readPrim_union[pid], BICC_UNBLOCK_IND, EN_GROUP); + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_UNBLOCKING_RESP; + } + break; + case MGBR_WAIT_BLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteblocking_func(pid, &readPrim_union[pid].cgb_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgb_rsp, &readPrim_union[pid].cgb_ind, sizeof(BiccCgb_Ind)); + bicc_send_cgba(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + case MGBR_WAIT_UNBLOCKING_RESP: + if(port_ptr->internal_cmd == (BICC_CMD_RESET|BICC_SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else + { + bicc_remoteunblocking_func(pid, &readPrim_union[pid].cgu_ind.rangeStatus); + memcpy(&writePrim_union[pid].cgu_rsp, &readPrim_union[pid].cgu_ind, sizeof(BiccCgu_Ind)); + bicc_send_cgua(pid); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Sending */ +/********************************************/ +BOOL check_crs_waiting(u32 pid) +{ + if(Bicc_Data.port_data[pid].fsm_state.crs_state == CRS_WAIT_REL) + return 1; + else + return 0; +} +inline void bicc_crs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.crs_state != CRS_IDLE) + { + port_ptr->fsm_state.crs_state = CRS_IDLE; + + tempTimer->t16 = 0; + } + return ; + } + switch(port_ptr->fsm_state.crs_state) + { + case CRS_IDLE: + if(port_ptr->primitive_cmd == BICC_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + + port_ptr->fsm_state.crs_state = CRS_WAIT_REL; + } + break; + case CRS_WAIT_REL: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + tempTimer->t16 = BICC_TIMER_STOP; + port_ptr->fsm_state.crs_state = CRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_NONE); + + } + + if(tempTimer->t16 -- == BICC_TIMER_EXPIRED) + { + bicc_send_rsc(pid); + tempTimer->t16 = TIMER_PTR->t16; + } + break; + default: + break; + } +} + +/********************************************/ +/* Circuit Reset Reception */ +/********************************************/ +inline void bicc_crr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + + switch(port_ptr->fsm_state.crr_state) + { + case CRR_IDLE: + if(port_ptr->sprc_cmd == M_RSC) + { + port_ptr->sprc_cmd = 0; + + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + port_ptr->cic_state.call_state = BICC_INCOMING; + + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) + port_ptr->cic_state.blo_state &= 0x0e; + port_ptr->cic_state.blo_state &= 0x0d; + port_ptr->fsm_state.crr_state = CRR_WAIT_RESPONSE; + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CRR); + + } + break; + case CRR_WAIT_RESPONSE: + //if((port_ptr->internal_cmd & 0x0F) == CMD_RESET_COMP) + // if(port_ptr->primitive_cmd == BICC_RESET_RSP) + { + port_ptr->internal_cmd = 0; + writePrim_union[pid].rel_rsp.cause.pres = 0; + bicc_send_rlc(pid); + port_ptr->fsm_state.crr_state = CRR_IDLE; + } + break; + default: + break; + } +} + +/************************************************/ +/* Circuit Group Reset Sending */ +/************************************************/ +inline void bicc_cgrs_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccTimer_struct *tempTimer = &Bicc_Data.timer_data[pid]; + u32 circuit_id; + const pal_circuit_struct *pcircuit = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ; + if(pcircuit->attrib.plat_id != local_platid ) + if(Bicc_Data.dmp_data.active == 1) + { + if(port_ptr->fsm_state.cgrs_state != CGRS_IDLE) + { + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + + tempTimer->t22 = 0; + } + return ; + } + switch(port_ptr->fsm_state.cgrs_state) + { + case CGRS_IDLE: + if(port_ptr->primitive_cmd == BICC_GROUP_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + if(port_ptr->fsm_state.mgbs_state != MGBS_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRS); + bicc_cgrs_func(pid, writePrim_union[pid].grs_req.rangeStatus.range); + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; + } + break; + case CGRS_WAIT_GRA: + if(port_ptr->sprc_cmd == M_GRA) + { + port_ptr->sprc_cmd = 0; + tempTimer->t22 = BICC_TIMER_STOP; + port_ptr->fsm_state.cgrs_state = CGRS_IDLE; + bicc_event_handle(pid, &readPrim_union[pid], BICC_RESET_CNF, EN_GROUP); + bicc_cgrsack_func(pid, &readPrim_union[pid].grs_cnf.rangeStatus); + } + + if(tempTimer->t22 -- == BICC_TIMER_EXPIRED) + { + bicc_send_grs(pid); + tempTimer->t22 = TIMER_PTR->t22; + + } + break; + default: + break; + } +} + +/****************************************************/ +/* Circuit Group Reset Reception */ +/****************************************************/ +inline void bicc_cgrr_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + + switch(port_ptr->fsm_state.cgrr_state) + { + case CGRR_IDLE: + if(port_ptr->sprc_cmd == M_GRS) + { + port_ptr->sprc_cmd = 0; + if((readPrim_union[pid].grs_ind.rangeStatus.range >= 32)|| (readPrim_union[pid].grs_ind.rangeStatus.range == 0)) + return; + if(port_ptr->fsm_state.mgbr_state != MGBR_IDLE) + port_ptr->internal_cmd = (BICC_CMD_RESET|BICC_SI_CGRR); + bicc_cgrr_func(pid, readPrim_union[pid].grs_ind.rangeStatus.range, &msg_union[pid].gra.rangeStatus); + port_ptr->fsm_state.cgrr_state = CGRR_WAIT_GROUP_RESET_COMP; + } + break; + case CGRR_WAIT_GROUP_RESET_COMP: + memcpy(&writePrim_union[pid].grs_rsp.rangeStatus, &msg_union[pid].gra.rangeStatus, sizeof(RangeStatus_struct)); + bicc_send_gra(pid); + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cgrr_state = CGRR_IDLE; + break; + default: + break; + } +} + + + +BOOL bicc_check_blocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC- 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((Bicc_Data.port_data[i].cic_state.blo_state == 0) && (pcircuit->enable== 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_check_unblocking(u32 circuit_id, RangeStatus_struct *rs_ptr) +{ + int i; + BOOL ret = 0; + const pal_circuit_struct *pcircuit = NULL; + + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit == NULL) + return ret; + memset(rs_ptr, 0, sizeof(RangeStatus_struct)); + rs_ptr->range = BICC_CIRCUIT_CIC - 1; + for(i = pcircuit->attrib.head_cic; i < (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range); i++) + { + if((pcircuit->enable== 1) && (Bicc_Data.port_data[i].cic_state.blo_state == 1)) + { + rs_ptr->status[i>>3]|= 0x01 << (i&0x07); + ret = 1; + } + } + return ret; +} + +BOOL bicc_trunk_reachable(u32 cg_id) +{ + const pal_cg_struct *pcg; + pcg = pal_cg_ptr(cg_id); + if(pcg==NULL) + return 0; + if(check_outbound_route(pcg->attrib.network_id, (long)pcg->attrib.dpc, 0) >= 0) + return 1; + else + return 0; +} + diff --git a/omc/plat/bicc/src/bicc_ipbcp.c b/omc/plat/bicc/src/bicc_ipbcp.c new file mode 100644 index 0000000..a5de374 --- /dev/null +++ b/omc/plat/bicc/src/bicc_ipbcp.c @@ -0,0 +1,362 @@ +#include +#include +#include "./include/ipbcp.h" + +int sdp_decode_orig(SdpOrig_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->username, token); + strcat(dst_ptr->username, "\0"); + break; + case 2: + sprintf(dst_ptr->session_id, token); + strcat(dst_ptr->session_id, "\0"); + break; + case 3: + sprintf(dst_ptr->version, token); + strcat(dst_ptr->version, "\0"); + break; + case 4: + sprintf(dst_ptr->network_type, token); + strcat(dst_ptr->network_type, "\0"); + break; + case 5: + sprintf(dst_ptr->address_type, token); + strcat(dst_ptr->address_type, "\0"); + break; + case 6: + sprintf(dst_ptr->address, token); + strcat(dst_ptr->address, "\0"); + break; + default: + return 0; + } + } + if(field_id != 6) + return 0; + else + return 1; +} + +int sdp_decode_conn(SdpConn_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->network_type, token); + strcat(dst_ptr->network_type, "\0"); + break; + case 2: + sprintf(dst_ptr->address_type, token); + strcat(dst_ptr->address_type, "\0"); + break; + case 3: + sprintf(dst_ptr->address, token); + strcat(dst_ptr->address, "\0"); + break; + default: + return 0; + } + } + if(field_id != 3) + return 0; + else + return 1; +} + +int sdp_decode_time(SdpTime_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->start, token); + strcat(dst_ptr->start, "\0"); + break; + case 2: + sprintf(dst_ptr->stop, token); + strcat(dst_ptr->stop, "\0"); + break; + default: + return 0; + } + } + if(field_id != 2) + return 0; + else + return 1; +} + +int sdp_decode_attrib(SdpAttrib_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + if(strstr(src_ptr, "ipbcp:") != src_ptr) + return 0; + src_ptr += strlen("ipbcp:"); + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->version, token); + strcat(dst_ptr->version, "\0"); + break; + case 2: + sprintf(dst_ptr->type, token); + strcat(dst_ptr->type, "\0"); + break; + default: + return 0; + } + } + if(field_id != 2) + return 0; + else + return 1; +} + +int sdp_decode_mediaAnn(SdpMediaAnn_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + while((token = strsep(&src_ptr, " ")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->media, token); + strcat(dst_ptr->media, "\0"); + break; + case 2: + sprintf(dst_ptr->port, token); + strcat(dst_ptr->port, "\0"); + break; + case 3: + sprintf(dst_ptr->transport, token); + strcat(dst_ptr->transport, "\0"); + strcpy(dst_ptr->fmt_list, src_ptr); + strcat(dst_ptr->fmt_list, "\0"); + break; + case 4: + // sprintf(dst_ptr->fmt_list, token); + break; + default: + break; + } + } + if(field_id < 4) + return 0; + else + return 1; +} + +int sdp_decode_mediaAtt(SdpMediaAtt_struct *dst_ptr, char *src_ptr) +{ + char *token; + unsigned char field_id = 0; + + if(strstr(src_ptr, "rtpmap:") != src_ptr) + return 0; + src_ptr += strlen("rtpmap:"); + while((token = strsep(&src_ptr, " /")) != NULL) + { + switch(++field_id) + { + case 1: + sprintf(dst_ptr->payload, token); + strcat(dst_ptr->payload, "\0"); + break; + case 2: + sprintf(dst_ptr->encoding_name, token); + strcat(dst_ptr->encoding_name, "\0"); + break; + case 3: + sprintf(dst_ptr->clock_rate, token); + strcat(dst_ptr->clock_rate, "\0"); + break; + case 4: +// sprintf(dst_ptr->p_time, token); + field_id --;//to avoid 4 fields + break; + default: + return 0; + } + } + if(field_id != 3) + return 0; + else + return 1; +} + + +int sdp_decode_ptime(char* p_time, char *src_ptr) +{ + char *token; + if((token = strstr(src_ptr, "ptime:")) == NULL) + return 0; + token = strtok(token, ":"); + token = strtok(NULL, ":"); +// p_time = token; +// if(strlen(token)<8) + if(token) + { + sprintf(p_time, token); + strcat(p_time, "\0"); + } + return 1; + +} + +int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr) +{ + char *token; + unsigned char field_id = 0; + char temp_ipbcp[200]; + char *temp_ptr; + + strncpy(temp_ipbcp, ptr, 200); + temp_ptr = temp_ipbcp; + memset(ipbcp_ptr, 0, sizeof(IPBCP_struct)); + while((token = strsep(&temp_ptr, "\r\n")) != NULL) + { + if(strlen(token) == 0) + continue; + switch(++field_id) + { + case 1: + if((token[0] != 'v') || (token[1] != '=')) + return 0; + sprintf(ipbcp_ptr->proto_ver, token+2); + strcat(ipbcp_ptr->proto_ver, "\0"); + break; + case 2: + if((token[0] != 'o') || (token[1] != '=')) + return 0; + if(!sdp_decode_orig(&ipbcp_ptr->orig, token+2)) + return 0; + break; + case 3: + if((token[0] != 's') || (token[1] != '=')) + return 0; + sprintf(ipbcp_ptr->session_name, token+2); + + strcat(ipbcp_ptr->session_name, "\0"); + break; + case 4: + if((token[0] != 'c') || (token[1] != '=')) + return 0; + if(!sdp_decode_conn(&ipbcp_ptr->conn_data, token+2)) + return 0; + break; + case 5: + if((token[0] != 't') || (token[1] != '=')) + return 0; + if(!sdp_decode_time(&ipbcp_ptr->time, token+2)) + return 0; + break; + case 6: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(!sdp_decode_attrib(&ipbcp_ptr->attrib, token+2)) + return 0; + break; + case 7: + if((token[0] != 'm') || (token[1] != '=')) + return 0; + if(!sdp_decode_mediaAnn(&ipbcp_ptr->m_ann, token+2)) + return 0; + break; + case 8: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(sdp_decode_mediaAtt(&ipbcp_ptr->m_att, token+2)) + // return 0; + ; + else if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2)) + return 0; + + break; + case 9: + if((token[0] != 'a') || (token[1] != '=')) + return 0; + if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2)) + return 0; + default: + break; + } + } + return 1; +} + +int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr) +{ + char tmp_buf[128]; + + sprintf(ptr, "v=%s\r\n", ipbcp_ptr->proto_ver); + + sprintf(tmp_buf, "o=%s %s %s %s %s %s\r\n", + ipbcp_ptr->orig.username, + ipbcp_ptr->orig.session_id, + ipbcp_ptr->orig.version, + ipbcp_ptr->orig.network_type, + ipbcp_ptr->orig.address_type, + ipbcp_ptr->orig.address); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "s=%s\r\n", ipbcp_ptr->session_name); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "c=%s %s %s\r\n", + ipbcp_ptr->conn_data.network_type, + ipbcp_ptr->conn_data.address_type, + ipbcp_ptr->conn_data.address); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "t=%s %s\r\n", ipbcp_ptr->time.start, ipbcp_ptr->time.stop); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "a=ipbcp:%s %s\r\n", ipbcp_ptr->attrib.version, ipbcp_ptr->attrib.type); + strcat(ptr, tmp_buf); + + sprintf(tmp_buf, "m=%s %s %s %s\r\n", + ipbcp_ptr->m_ann.media, + ipbcp_ptr->m_ann.port, + ipbcp_ptr->m_ann.transport, + ipbcp_ptr->m_ann.fmt_list); + strcat(ptr, tmp_buf); + + if(strlen(ipbcp_ptr->m_att.payload) != 0) + { + sprintf(tmp_buf, "a=rtpmap:%s %s/%s\r\n", + ipbcp_ptr->m_att.payload, + ipbcp_ptr->m_att.encoding_name, + ipbcp_ptr->m_att.clock_rate); + strcat(ptr, tmp_buf); + } + //ipbcp_ptr->ptime[7]='\0'; + if((ipbcp_ptr->ptime[0] != '\0') && (strlen(ipbcp_ptr->ptime)<8)) + { + sprintf(tmp_buf, "a=ptime:%s\r\n", ipbcp_ptr->ptime); + strcat(ptr, tmp_buf); + } + return strlen(ptr); +} diff --git a/omc/plat/bicc/src/bicc_msg.c b/omc/plat/bicc/src/bicc_msg.c new file mode 100644 index 0000000..9ba7769 --- /dev/null +++ b/omc/plat/bicc/src/bicc_msg.c @@ -0,0 +1,1285 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" + +BiccMsg_union msg_union[BICC_MAX_PORT]; +//static up_message_2 up_msg; +extern void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length); +extern u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr); +extern void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type); + +void bicc_decode_app(AppTrans_struct *ptr, const u8 *flw_ptr, u8 length) +{ + int i = 0; + + ptr->pres = 1; + ptr->aci[0] = flw_ptr[i]; + if((flw_ptr[i++] >> 7) == 0) + ptr->aci[1] = flw_ptr[i++]; + ptr->sni = (flw_ptr[i] >> 1) & 0x01; + ptr->rci = flw_ptr[i++] & 0x01; + ptr->si = (flw_ptr[i] >> 6) & 0x01; + ptr->segment = flw_ptr[i] & 0x3f; + if((flw_ptr[i++] >> 7) == 0) + ptr->slr = flw_ptr[i++] & 0x7f; + if(length > i) + apm_decode(&ptr->apm_info, flw_ptr+i, length-i); +} + +u32 bicc_encode_app(u8 *flw_ptr, const AppTrans_struct *ptr) +{ + int i = 0; + + flw_ptr[i++] = ptr->aci[0] | 0x80; +// if((ptr->aci[0] >> 7) == 0) +// flw_ptr[i++] = ptr->aci[1]; + flw_ptr[i++] = (ptr->sni << 1) + ptr->rci; + flw_ptr[i++] = ((ptr->si << 6) + ptr->segment) | 0x80; + return i + apm_encode(flw_ptr+i, &ptr->apm_info); +} + +void bicc_decode_backcall(BackCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val[0] = flw_ptr[0]; + ptr->val[1] = flw_ptr[1]; +} + +u32 bicc_encode_backcall(u8 *flw_ptr, const BackCallInd_struct *ptr) +{ + flw_ptr[0] = ptr->val[0]; + flw_ptr[1] = ptr->val[1]; + return 2; +} + +void bicc_decode_calledptynum(CalledPtyNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->inn = flw_ptr[1] >> 7; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_calledptynum(u8 *flw_ptr, const CalledPtyNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->inn << 7) + (ptr->npi << 4)) & 0xf0; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_callingptynum(CallingPtyNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->ni = flw_ptr[1] >> 7; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + ptr->si = flw_ptr[1] & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_callingptynum(u8 *flw_ptr, const CallingPtyNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = (ptr->ni << 7) + (ptr->npi << 4) + (ptr->apri << 2) + ptr->si; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_callingptycat(CallingPtyCat_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_callingptycat(u8 *flw_ptr, const CallingPtyCat_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + + +u32 bicc_encode_cause(u8 *flw_ptr, const CauseInd_struct *ptr) +{ + flw_ptr[0] = ((ptr->codingStd << 5) + ptr->location) & 0x7f; + flw_ptr[1] = 0x80 | ptr->causeVal; + return 2; +} + +void bicc_decode_cause(CauseInd_struct *ptr, const u8 *flw_ptr, u8 length) +{ + ptr->pres = 1; + ptr->codingStd = (flw_ptr[0] >> 5) & 0x03; + ptr->location = flw_ptr[0] & 0x0f; + ptr->causeVal = flw_ptr[1] & 0x7f; +} + + +void bicc_decode_cicgrpspv(CicGrpSpv_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_cicgrpspv(u8 *flw_ptr, const CicGrpSpv_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_collectcallreq(CollectCallReq_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_collectcallreq(u8 *flw_ptr, const CollectCallReq_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_conftreat(ConfTreatInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_conftreat(u8 *flw_ptr, const ConfTreatInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_connnum(ConnNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + ptr->si = flw_ptr[1] & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_connnum(u8 *flw_ptr, const ConnNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2) + ptr->si) & 0x7f; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_genericnumber(GenericNumber_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 3) + return; + ptr->pres = 1; + ptr->nqi = flw_ptr[0]; + ptr->nai = flw_ptr[1] & 0x7f; + ptr->ni = flw_ptr[2] >> 7; + ptr->npi = (flw_ptr[2] >> 4) & 0x07; + ptr->apri = (flw_ptr[2] >> 2) & 0x03; + ptr->si = flw_ptr[2] & 0x03; + num_len = length - 3; + num_ptr = flw_ptr + 3; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[1] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +void bicc_decode_genericDigits(GenericDigits_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u8 num_len; + int i, j; + const u8 *num_ptr; + if(length < 3) + return; + ptr->pres = 1; + + ptr->typeOfDigits = flw_ptr[0] & 0x1f; + ptr->encodeScheme = flw_ptr[0] & 0xE0; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digits[j++] = num_ptr[i] & 0x0f; + ptr->digits[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 5) && (j > 0)) + j--; + ptr->numOfDigit = j; + +} + + + + +void bicc_decode_correlationid(CorrelationId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + bicc_decode_genericDigits(ptr, flw_ptr, length); +} + + +u32 bicc_encode_genericnumber(u8 *flw_ptr, const GenericNumber_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 3; + flw_ptr[0] = ptr->nqi; + flw_ptr[1] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[2] = (ptr->ni << 7) + (ptr->npi << 4) + (ptr->apri << 2) + ptr->si; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 3; +} + +u32 bicc_encode_genericDigits(u8 *flw_ptr, const GenericDigits_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + num_ptr = flw_ptr + 1; + flw_ptr[0] = (ptr->encodeScheme << 5) + ptr->typeOfDigits; + flw_ptr[1] = ptr->numOfDigit & 0xff; + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digits[j++] & 0x0f; + num_ptr[i] += ptr->digits[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; + +} + + +u32 bicc_encode_correlationid(u8 *flw_ptr, const CorrelationId_struct *ptr) +{ + return bicc_encode_genericDigits(flw_ptr, ptr); + +} + +void bicc_decode_eventinfo(EventInfo_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_eventinfo(u8 *flw_ptr, const EventInfo_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_fwdcall(FwdCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val[0] = flw_ptr[0]; + ptr->val[1] = flw_ptr[1]; +} + +u32 bicc_encode_fwdcall(u8 *flw_ptr, const FwdCallInd_struct *ptr) +{ + flw_ptr[0] = ptr->val[0]; + flw_ptr[1] = ptr->val[1]; + return 2; +} + + +void bicc_decode_natconn(NatConnInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_natconn(u8 *flw_ptr, const NatConnInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_origcallednum(OrigCalledNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_origcallednum(u8 *flw_ptr, const OrigCalledNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2)) & 0x7c; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_rangestatus(RangeStatus_struct *ptr, const u8 *flw_ptr, u8 length, u8 need_status) +{ + u8 status_len; + + ptr->pres = 1; + ptr->range = flw_ptr[0]; + if(need_status == 1) + { + status_len = (((flw_ptr[0]+1)&0x07) == 0)? ((flw_ptr[0]+1)>>3) : (((flw_ptr[0]+1)>>3) + 1); + memcpy(ptr->status, flw_ptr+1, status_len); + } +} + +u32 bicc_encode_rangestatus(u8 *flw_ptr, const RangeStatus_struct *ptr, u8 need_status) +{ + u8 status_len; + + flw_ptr[0] = ptr->range; + if(need_status == 1) + { + status_len = (((ptr->range+1)&0x07) == 0)? ((ptr->range+1)>>3) : (((ptr->range+1)>>3) + 1); + memcpy(flw_ptr+1, ptr->status, status_len); + } + else + status_len = 0; + return status_len + 1; +} + +void bicc_decode_redirgnum(RedirgNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 2) + return; + ptr->pres = 1; + ptr->nai = flw_ptr[0] & 0x7f; + ptr->npi = (flw_ptr[1] >> 4) & 0x07; + ptr->apri = (flw_ptr[1] >> 2) & 0x03; + num_len = length - 2; + num_ptr = flw_ptr + 2; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +void bicc_decode_redirinfo(RedirInfo_struct *ptr, u8 *flw_ptr, u8 length) +{ + if(length <= 2) + return; + ptr->redInd = flw_ptr[0] & 0x07; + ptr->origRedirReason = (flw_ptr[0] >> 4) & 0x0f; + ptr->redirCounter = flw_ptr[1] & 0x07; + ptr->redirReason = (flw_ptr[1] >> 4) & 0x0f; +} + +u32 bicc_encode_redirgnum(u8 *flw_ptr, const RedirgNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 2; + flw_ptr[0] = (ptr->numOfDigit << 7) + ptr->nai; + flw_ptr[1] = ((ptr->npi << 4) + (ptr->apri << 2)) & 0x7c; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +u32 bicc_encode_redirinfo(u8 *flw_ptr, const RedirInfo_struct *ptr) +{ + flw_ptr[0] = (ptr->origRedirReason << 4) + ptr->redInd; + flw_ptr[1] = (ptr->redirReason << 4) + ptr->redirCounter; + return 2; +} + +void bicc_decode_scfid(ScfId_struct *ptr, const u8 *flw_ptr, u8 length) +{ + bicc_decode_genericDigits(ptr, flw_ptr, length); +} + +u32 bicc_encode_scfid(u8 *flw_ptr, const ScfId_struct *ptr) +{ + return bicc_encode_genericDigits(flw_ptr, ptr); +} + +void bicc_decode_subseqnum(SubseqNum_struct *ptr, const u8 *flw_ptr, u8 length) +{ + u32 i, j; + u8 num_len; + const u8 *num_ptr; + + if(length <= 1) + return; + ptr->pres = 1; + num_len = length - 1; + num_ptr = flw_ptr + 1; + for(i = 0, j = 0; i < num_len; i++) + { + ptr->digit[j++] = num_ptr[i] & 0x0f; + ptr->digit[j++] = num_ptr[i] >> 4; + } + if((flw_ptr[0] >> 7) && (j > 0)) + j--; + ptr->numOfDigit = j; +} + +u32 bicc_encode_subseqnum(u8 *flw_ptr, const SubseqNum_struct *ptr) +{ + u32 i, j; + u8 num_len; + u8 *num_ptr; + + num_len = ptr->numOfDigit/2 + (ptr->numOfDigit & 0x01); + num_ptr = flw_ptr + 1; + flw_ptr[0] = (ptr->numOfDigit & 0x01) << 7; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = ptr->digit[j++] & 0x0f; + num_ptr[i] += ptr->digit[j++] << 4; + } + if(ptr->numOfDigit & 0x01) + num_ptr[i] &= 0x0f; + return num_len + 2; +} + +void bicc_decode_susres(SusResInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_susres(u8 *flw_ptr, const SusResInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_transmedreq(TransMedReq_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_transmedreq(u8 *flw_ptr, const TransMedReq_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_utuind(UserToUserInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->val = *flw_ptr; +} + +u32 bicc_encode_utuind(u8 *flw_ptr, const UserToUserInd_struct *ptr) +{ + flw_ptr[0] = ptr->val; + return 1; +} + +void bicc_decode_utuinfo(UserToUserInfo_struct *ptr, const u8 *flw_ptr, u8 length) +{ + if((length == 0) || (length > 129)) + return; + ptr->pres = 1; + ptr->len = length; + memcpy(ptr->val, flw_ptr, length); +} + +u32 bicc_encode_utuinfo(u8 *flw_ptr, const UserToUserInfo_struct *ptr) +{ + memcpy(flw_ptr, ptr->val, ptr->len); + return ptr->len; +} + +void bicc_decode_calldiverinfo(CallDiverInfo_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->notifSubsOption = flw_ptr[0]&0x07; + ptr->redirReason = (flw_ptr[0]>>3)&0x0f; +} + +u32 bicc_encode_calldiverinfo(u8 *flw_ptr, const CallDiverInfo_struct *ptr) +{ + flw_ptr[0] = ((ptr->redirReason)<<3) + (ptr->notifSubsOption); + return 1; +} + +void bicc_decode_optBackCallInd(OptBackCallInd_struct *ptr, const u8 *flw_ptr) +{ + ptr->pres = 1; + ptr->inbandInfoInd = flw_ptr[0]&0x01; + ptr->callDiverOccurInd = flw_ptr[0]&0x02; + ptr->simpSegmInd = flw_ptr[0]&0x04; + ptr->mlppUserInd = flw_ptr[0]&0x08; +} + +u32 bicc_encode_optBackCallInd(u8 *flw_ptr, const OptBackCallInd_struct *ptr) +{ + flw_ptr[0] = (((ptr->mlppUserInd)<<3)+((ptr->simpSegmInd)<<2)+((ptr->callDiverOccurInd<<1))+(ptr->inbandInfoInd))&0x0f; + return 1; +} + +void bicc_send_acm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccAcm_struct *acm_ptr = &msg_union[pid].acm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_ACM); + *(flw_ptr++) = M_ACM; + flw_ptr += bicc_encode_backcall(flw_ptr, &acm_ptr->backCall); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(acm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &acm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &acm_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &acm_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->optBackCall.pres == 1) + { + flw_ptr[0] = P_OPTBACKCALLIND; + flw_ptr[1] = bicc_encode_optBackCallInd(flw_ptr+2, &acm_ptr->optBackCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &acm_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(acm_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &acm_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_anm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccAnm_struct *anm_ptr = &msg_union[pid].anm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_ANM); + *(flw_ptr++) = M_ANM; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(anm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &anm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->backCall.pres == 1) + { + flw_ptr[0] = P_BACKCALLIND; + flw_ptr[1] = bicc_encode_backcall(flw_ptr+2, &anm_ptr->backCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &anm_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &anm_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &anm_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(anm_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &anm_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_apm(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccApm_struct *apm_ptr = &msg_union[pid].apm; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_APM); + *(flw_ptr++) = M_APM; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(apm_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &apm_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cpg(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCpg_struct *cpg_ptr = &msg_union[pid].cpg; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CPG); + *(flw_ptr++) = M_CPG; + flw_ptr += bicc_encode_eventinfo(flw_ptr, &cpg_ptr->eventInfo); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(cpg_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &cpg_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->backCall.pres == 1) + { + flw_ptr[0] = P_BACKCALLIND; + flw_ptr[1] = bicc_encode_backcall(flw_ptr+2, &cpg_ptr->backCall); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->calldiver.pres == 1) + { + flw_ptr[0] = P_CALLDIVERINFO; + flw_ptr[1] = bicc_encode_calldiverinfo(flw_ptr+2, &cpg_ptr->calldiver); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &cpg_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &cpg_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &cpg_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &cpg_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(cpg_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &cpg_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgb(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgb_struct *cgb_ptr = &msg_union[pid].cgb; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGB); + *(flw_ptr++) = M_CGB; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgb_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgb_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgba(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgba_struct *cgba_ptr = &msg_union[pid].cgba; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGBA); + *(flw_ptr++) = M_CGBA; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgba_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgba_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgu(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgu_struct *cgu_ptr = &msg_union[pid].cgu; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGU); + *(flw_ptr++) = M_CGU; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgu_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgu_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_cgua(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCgua_struct *cgua_ptr = &msg_union[pid].cgua; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CGUA); + *(flw_ptr++) = M_CGUA; + flw_ptr += bicc_encode_cicgrpspv(flw_ptr, &cgua_ptr->cicGrpSpv); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &cgua_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_grs(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccGrs_struct *grs_ptr = &msg_union[pid].grs; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_GRS); + *(flw_ptr++) = M_GRS; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &grs_ptr->rangeStatus, 0); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_gra(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccGra_struct *gra_ptr = &msg_union[pid].gra; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_GRA); + *(flw_ptr++) = M_GRA; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = bicc_encode_rangestatus(flw_ptr+1, &gra_ptr->rangeStatus, 1); + flw_ptr += flw_ptr[0] + 1; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_con(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccCon_struct *con_ptr = &msg_union[pid].con; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_CON); + *(flw_ptr++) = M_CON; + flw_ptr += bicc_encode_backcall(flw_ptr, &con_ptr->backCall); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(con_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &con_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &con_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->connNum.pres == 1) + { + flw_ptr[0] = P_CONNNUM; + flw_ptr[1] = bicc_encode_connnum(flw_ptr+2, &con_ptr->connNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &con_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(con_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &con_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_iam(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccIam_struct *iam_ptr = &msg_union[pid].iam; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + u8 opt_pointer; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_IAM); + *(flw_ptr++) = M_IAM; + flw_ptr += bicc_encode_natconn(flw_ptr, &iam_ptr->natConn); + flw_ptr += bicc_encode_fwdcall(flw_ptr, &iam_ptr->fwdCall); + flw_ptr += bicc_encode_callingptycat(flw_ptr, &iam_ptr->callingPtyCat); + flw_ptr += bicc_encode_transmedreq(flw_ptr, &iam_ptr->transMedReq); + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_calledptynum(flw_ptr+1, &iam_ptr->calledPtyNum); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0] + 1; + if(iam_ptr->app.pres == 1) + { + flw_ptr[0] = P_APPTRANS; + flw_ptr[1] = bicc_encode_app(flw_ptr+2, &iam_ptr->app); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->callingPtyNum.pres == 1) + { + flw_ptr[0] = P_CALLINGPTYNUM; + flw_ptr[1] = bicc_encode_callingptynum(flw_ptr+2, &iam_ptr->callingPtyNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->collectCallReq.pres == 1) + { + flw_ptr[0] = P_COLLECTCALLREQ; + flw_ptr[1] = bicc_encode_collectcallreq(flw_ptr+2, &iam_ptr->collectCallReq); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->confTreat.pres == 1) + { + flw_ptr[0] = P_CONFTREATIND; + flw_ptr[1] = bicc_encode_conftreat(flw_ptr+2, &iam_ptr->confTreat); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->correlationId.pres == 1) + { + flw_ptr[0] = P_CORRELATIONID; + flw_ptr[1] = bicc_encode_correlationid(flw_ptr+2, &iam_ptr->correlationId); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->origCalledNum.pres == 1) + { + flw_ptr[0] = P_ORIGCALLEDNUM; + flw_ptr[1] = bicc_encode_origcallednum(flw_ptr+2, &iam_ptr->origCalledNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->redirgNum.pres == 1) + { + flw_ptr[0] = P_REDIRGNUM; + flw_ptr[1] = bicc_encode_redirgnum(flw_ptr+2, &iam_ptr->redirgNum); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->redirInfo.pres == 1) + { + flw_ptr[0] = P_REDIRINFO; + flw_ptr[1] = bicc_encode_redirinfo(flw_ptr+2, &iam_ptr->redirInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->scfId.pres == 1) + { + flw_ptr[0] = P_SCFID; + flw_ptr[1] = bicc_encode_scfid(flw_ptr+2, &iam_ptr->scfId); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &iam_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(iam_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &iam_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + + +void bicc_send_rel(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRel_struct *rel_ptr = &msg_union[pid].rel; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + u8 opt_pointer; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_REL); + *(flw_ptr++) = M_REL; + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_cause(flw_ptr+1, &rel_ptr->cause); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0] + 1; + if(rel_ptr->utuInd.pres == 1) + { + flw_ptr[0] = P_UTUIND; + flw_ptr[1] = bicc_encode_utuind(flw_ptr+2, &rel_ptr->utuInd); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(rel_ptr->utuInfo.pres == 1) + { + flw_ptr[0] = P_UTUINFO; + flw_ptr[1] = bicc_encode_utuinfo(flw_ptr+2, &rel_ptr->utuInfo); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_rlc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRlc_struct *rlc_ptr = &msg_union[pid].rlc; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_RLC); + *(flw_ptr++) = M_RLC; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(rlc_ptr->cause.pres == 1) + { + flw_ptr[0] = P_CAUSEIND; + flw_ptr[1] = bicc_encode_cause(flw_ptr+2, &rlc_ptr->cause); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = 1; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + + +void bicc_send_rsc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + + *(flw_ptr++) = M_RSC; + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_res(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccRes_struct *res_ptr = &msg_union[pid].res; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_RES); + *(flw_ptr++) = M_RES; + flw_ptr += bicc_encode_susres(flw_ptr, &res_ptr->susRes); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_sus(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccSus_struct *sus_ptr = &msg_union[pid].sus; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_SUS); + *(flw_ptr++) = M_SUS; + flw_ptr += bicc_encode_susres(flw_ptr, &sus_ptr->susRes); + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} + +void bicc_send_sam(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + BiccSam_struct *sam_ptr = &msg_union[pid].sam; + u8 *flw_ptr = port_ptr->s_mtp_msg.msgList; //message flow pointer + u8 *pointer_ptr; + + bicc_prm2msg(&msg_union[pid], &writePrim_union[pid], M_SAM); + *(flw_ptr++) = M_SAM; + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = bicc_encode_subseqnum(flw_ptr+1, &sam_ptr->subseqNum); + flw_ptr += flw_ptr[0] + 1; + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + port_ptr->s_mtp_msg.len = flw_ptr - port_ptr->s_mtp_msg.msgList; + BICC_msdc_proc(pid, &(port_ptr->s_mtp_msg)); +} diff --git a/omc/plat/bicc/src/bicc_prm.c b/omc/plat/bicc/src/bicc_prm.c new file mode 100644 index 0000000..1e1cb89 --- /dev/null +++ b/omc/plat/bicc/src/bicc_prm.c @@ -0,0 +1,244 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "./include/q1902_3e.h" +/**********************************************/ +/******* BICC Message&Primitive Mapping *******/ +/**********************************************/ +void app_msg2prm(AppTransM_struct *dst_ptr, AppTrans_struct *src_ptr) +{ + dst_ptr->pres = src_ptr->pres; + if(src_ptr->pres == 1) + { + memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct)); + dst_ptr->apm_info.sni = src_ptr->sni; + dst_ptr->apm_info.rci = src_ptr->rci; + } +} + +void app_prm2msg(AppTrans_struct *dst_ptr, AppTransM_struct *src_ptr) +{ + dst_ptr->pres = src_ptr->pres; + if(src_ptr->pres == 1) + { + dst_ptr->aci[0] = 0x00; + dst_ptr->aci[1] = 0x00; + dst_ptr->sni = src_ptr->apm_info.sni; + dst_ptr->rci = src_ptr->apm_info.rci; + dst_ptr->si = 0; //subsequent segment to first segment + dst_ptr->segment = 0; //final segment + dst_ptr->slr = 0; + memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct)); + } +} + +void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type) +{ + memset(prm_ptr, 0, sizeof(BiccReadPrim_union)); + switch(msg_type) + { + case M_ACM: + memcpy(&prm_ptr->alert_ind.backCall, &msg_ptr->acm.backCall, sizeof(BackCallInd_struct)); + app_msg2prm(&prm_ptr->alert_ind.app, &msg_ptr->acm.app); + memcpy(&prm_ptr->alert_ind.cause, &msg_ptr->acm.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->alert_ind.confTreat, &msg_ptr->acm.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->alert_ind.optBackCall, &msg_ptr->acm.optBackCall, sizeof(OptBackCallInd_struct)); + memcpy(&prm_ptr->alert_ind.utuInd, &msg_ptr->acm.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->alert_ind.utuInfo, &msg_ptr->acm.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_ANM: + app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->anm.app); + memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->anm.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->anm.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->anm.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->anm.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->anm.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_APM: + app_msg2prm(&prm_ptr->apm_ind.app, &msg_ptr->apm.app); + break; + case M_CPG: + memcpy(&prm_ptr->cpg_ind.eventInfo, &msg_ptr->cpg.eventInfo, sizeof(EventInfo_struct)); + app_msg2prm(&prm_ptr->cpg_ind.app, &msg_ptr->cpg.app); + memcpy(&prm_ptr->cpg_ind.backCall, &msg_ptr->cpg.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->cpg_ind.calldiver,&msg_ptr->cpg.calldiver, sizeof(BiccCpg_struct)); + memcpy(&prm_ptr->cpg_ind.cause, &msg_ptr->cpg.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->cpg_ind.confTreat, &msg_ptr->cpg.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->cpg_ind.connNum, &msg_ptr->cpg.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->cpg_ind.utuInd, &msg_ptr->cpg.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->cpg_ind.utuInfo, &msg_ptr->cpg.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_CGB: + memcpy(&prm_ptr->cgb_ind.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgb_ind.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGBA: + memcpy(&prm_ptr->cgb_cnf.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgb_cnf.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGU: + memcpy(&prm_ptr->cgu_ind.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgu_ind.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGUA: + memcpy(&prm_ptr->cgu_cnf.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&prm_ptr->cgu_cnf.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRS: + memcpy(&prm_ptr->grs_ind.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRA: + memcpy(&prm_ptr->grs_cnf.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CON: + app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->con.app); + memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->con.backCall, sizeof(BackCallInd_struct)); + memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->con.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->con.connNum, sizeof(ConnNum_struct)); + memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->con.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->con.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_IAM: + memcpy(&prm_ptr->setup_ind.natConn, &msg_ptr->iam.natConn, sizeof(NatConnInd_struct)); + memcpy(&prm_ptr->setup_ind.fwdCall, &msg_ptr->iam.fwdCall, sizeof(FwdCallInd_struct)); + memcpy(&prm_ptr->setup_ind.callingPtyCat, &msg_ptr->iam.callingPtyCat, sizeof(CallingPtyCat_struct)); + memcpy(&prm_ptr->setup_ind.transMedReq, &msg_ptr->iam.transMedReq, sizeof(TransMedReq_struct)); + memcpy(&prm_ptr->setup_ind.calledPtyNum, &msg_ptr->iam.calledPtyNum, sizeof(CalledPtyNum_struct)); + app_msg2prm(&prm_ptr->setup_ind.app, &msg_ptr->apm.app); + memcpy(&prm_ptr->setup_ind.callingPtyNum, &msg_ptr->iam.callingPtyNum, sizeof(CallingPtyNum_struct)); + memcpy(&prm_ptr->setup_ind.collectCallReq, &msg_ptr->iam.collectCallReq, sizeof(CollectCallReq_struct)); + memcpy(&prm_ptr->setup_ind.confTreat, &msg_ptr->iam.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&prm_ptr->setup_ind.correlationId, &msg_ptr->iam.correlationId, sizeof(CorrelationId_struct)); + memcpy(&prm_ptr->setup_ind.origCalledNum, &msg_ptr->iam.origCalledNum, sizeof(OrigCalledNum_struct)); + memcpy(&prm_ptr->setup_ind.redirgNum, &msg_ptr->iam.redirgNum, sizeof(RedirgNum_struct)); + memcpy(&prm_ptr->setup_ind.redirInfo, &msg_ptr->iam.redirInfo, sizeof(RedirInfo_struct)); + memcpy(&prm_ptr->setup_ind.scfId, &msg_ptr->iam.scfId, sizeof(ScfId_struct)); + memcpy(&prm_ptr->setup_ind.utuInd, &msg_ptr->iam.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->setup_ind.utuInfo, &msg_ptr->iam.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_REL: + memcpy(&prm_ptr->rel_ind.cause, &msg_ptr->rel.cause, sizeof(CauseInd_struct)); + memcpy(&prm_ptr->rel_ind.utuInd, &msg_ptr->rel.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&prm_ptr->rel_ind.utuInfo, &msg_ptr->rel.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_RLC: + memcpy(&prm_ptr->rel_cnf.cause, &msg_ptr->rlc.cause, sizeof(CauseInd_struct)); + break; + case M_RES: + memcpy(&prm_ptr->res_ind.susRes, &msg_ptr->res.susRes, sizeof(SusResInd_struct)); + break; + case M_SUS: + memcpy(&prm_ptr->sus_ind.susRes, &msg_ptr->sus.susRes, sizeof(SusResInd_struct)); + break; + case M_SAM: + memcpy(&prm_ptr->info_ind.subseqNum, &msg_ptr->sam.subseqNum, sizeof(SubseqNum_struct)); + break; + default: + break; + } +} + +void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type) +{ + memset(msg_ptr, 0, sizeof(BiccMsg_union)); + switch(msg_type) + { + case M_ACM: + memcpy(&msg_ptr->acm.backCall, &prm_ptr->alert_req.backCall, sizeof(BackCallInd_struct)); + app_prm2msg(&msg_ptr->acm.app, &prm_ptr->alert_req.app); + memcpy(&msg_ptr->acm.cause, &prm_ptr->alert_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->acm.confTreat, &prm_ptr->alert_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->acm.optBackCall, &prm_ptr->alert_req.optBackCall, sizeof(OptBackCallInd_struct)); + memcpy(&msg_ptr->acm.utuInd, &prm_ptr->alert_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->acm.utuInfo, &prm_ptr->alert_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_ANM: + app_prm2msg(&msg_ptr->anm.app, &prm_ptr->setup_rsp.app); + memcpy(&msg_ptr->anm.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->anm.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->anm.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->anm.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->anm.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_APM: + app_prm2msg(&msg_ptr->apm.app, &prm_ptr->apm_req.app); + break; + case M_CPG: + memcpy(&msg_ptr->cpg.eventInfo, &prm_ptr->cpg_req.eventInfo, sizeof(EventInfo_struct)); + app_prm2msg(&msg_ptr->cpg.app, &prm_ptr->cpg_req.app); + memcpy(&msg_ptr->cpg.backCall, &prm_ptr->cpg_req.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->cpg.calldiver, &prm_ptr->cpg_req.calldiver, sizeof(BiccCpg_struct)); + memcpy(&msg_ptr->cpg.cause, &prm_ptr->cpg_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->cpg.confTreat, &prm_ptr->cpg_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->cpg.connNum, &prm_ptr->cpg_req.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->cpg.utuInd, &prm_ptr->cpg_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->cpg.utuInfo, &prm_ptr->cpg_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_CGB: + memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_req.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGBA: + memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGU: + memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_req.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CGUA: + memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct)); + memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRS: + memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_req.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_GRA: + memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_rsp.rangeStatus, sizeof(RangeStatus_struct)); + break; + case M_CON: + app_prm2msg(&msg_ptr->con.app, &prm_ptr->setup_rsp.app); + memcpy(&msg_ptr->con.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct)); + memcpy(&msg_ptr->con.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->con.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct)); + memcpy(&msg_ptr->con.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->con.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_IAM: + memcpy(&msg_ptr->iam.natConn, &prm_ptr->setup_req.natConn, sizeof(NatConnInd_struct)); + memcpy(&msg_ptr->iam.fwdCall, &prm_ptr->setup_req.fwdCall, sizeof(FwdCallInd_struct)); + memcpy(&msg_ptr->iam.callingPtyCat, &prm_ptr->setup_req.callingPtyCat, sizeof(CallingPtyCat_struct)); + memcpy(&msg_ptr->iam.transMedReq, &prm_ptr->setup_req.transMedReq, sizeof(TransMedReq_struct)); + memcpy(&msg_ptr->iam.calledPtyNum, &prm_ptr->setup_req.calledPtyNum, sizeof(CalledPtyNum_struct)); + app_prm2msg(&msg_ptr->iam.app, &prm_ptr->setup_req.app); + memcpy(&msg_ptr->iam.callingPtyNum, &prm_ptr->setup_req.callingPtyNum, sizeof(CallingPtyNum_struct)); + memcpy(&msg_ptr->iam.collectCallReq, &prm_ptr->setup_req.collectCallReq, sizeof(CollectCallReq_struct)); + memcpy(&msg_ptr->iam.confTreat, &prm_ptr->setup_req.confTreat, sizeof(ConfTreatInd_struct)); + memcpy(&msg_ptr->iam.correlationId, &prm_ptr->setup_req.correlationId, sizeof(CorrelationId_struct)); + memcpy(&msg_ptr->iam.origCalledNum, &prm_ptr->setup_req.origCalledNum, sizeof(OrigCalledNum_struct)); + memcpy(&msg_ptr->iam.redirgNum, &prm_ptr->setup_req.redirgNum, sizeof(RedirgNum_struct)); + memcpy(&msg_ptr->iam.redirInfo, &prm_ptr->setup_req.redirInfo, sizeof(RedirInfo_struct)); + memcpy(&msg_ptr->iam.scfId, &prm_ptr->setup_req.scfId, sizeof(ScfId_struct)); + memcpy(&msg_ptr->iam.utuInd, &prm_ptr->setup_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->iam.utuInfo, &prm_ptr->setup_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_REL: + memcpy(&msg_ptr->rel.cause, &prm_ptr->rel_req.cause, sizeof(CauseInd_struct)); + memcpy(&msg_ptr->rel.utuInd, &prm_ptr->rel_req.utuInd, sizeof(UserToUserInd_struct)); + memcpy(&msg_ptr->rel.utuInfo, &prm_ptr->rel_req.utuInfo, sizeof(UserToUserInfo_struct)); + break; + case M_RLC: + memcpy(&msg_ptr->rlc.cause, &prm_ptr->rel_rsp.cause, sizeof(CauseInd_struct)); + break; + case M_RES: + memcpy(&msg_ptr->res.susRes, &prm_ptr->res_req.susRes, sizeof(SusResInd_struct)); + break; + case M_SUS: + memcpy(&msg_ptr->sus.susRes, &prm_ptr->sus_req.susRes, sizeof(SusResInd_struct)); + break; + case M_SAM: + memcpy(&msg_ptr->sam.subseqNum, &prm_ptr->info_req.subseqNum, sizeof(SubseqNum_struct)); + break; + default: + break; + } +} diff --git a/omc/plat/bicc/src/biccif.c b/omc/plat/bicc/src/biccif.c new file mode 100644 index 0000000..aaef225 --- /dev/null +++ b/omc/plat/bicc/src/biccif.c @@ -0,0 +1,1080 @@ +#include "./include/inc.h" +#include "./include/var_ext.h" +#include "../../public/src/include/license_id.h" + +BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +u8 Bicc_Version[4] = BICC_VERSION; +u8 local_platid=0; +extern BiccData_struct Bicc_Data; +BiccTimer_struct Timer_Data; +up_message_2 r_mtp_msg; //message receive from mtp3 +extern BiccMsg_union msg_union[BICC_MAX_PORT]; + +//void bicc_cpio_proc(u32 pid); +int check_outbound_route(BYTE nw, long dpc, BYTE sls); +extern BOOL bicc_event_handle(u32 pid, const BiccReadPrim_union *prm_ptr, u8 primitive, u8 eventType); +extern void bicc_cpci_proc(u32 pid); +extern void bicc_cpco_proc(u32 pid); +extern void bicc_mgbs_proc(u32 pid); +extern void bicc_mgbr_proc(u32 pid); +extern void bicc_crs_proc(u32 pid); +extern BOOL check_crs_waiting(u32 pid); +extern void bicc_crr_proc(u32 pid); +extern void bicc_cgrs_proc(u32 pid); +extern void bicc_cgrr_proc(u32 pid); +extern void bicc_circuit_reset(u32 pid, const char *s); +extern void bicc_decode_backcall(BackCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_app(AppTrans_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_calledptynum(CalledPtyNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_callingptynum(CallingPtyNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_callingptycat(CallingPtyCat_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_cause(CauseInd_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_cicgrpspv(CicGrpSpv_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_collectcallreq(CollectCallReq_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_conftreat(ConfTreatInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_connnum(ConnNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_genericnumber(GenericNumber_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_genericDigits(GenericDigits_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_correlationid(CorrelationId_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_fwdcall(FwdCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_natconn(NatConnInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_origcallednum(OrigCalledNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_utuind(UserToUserInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_utuinfo(UserToUserInfo_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_eventinfo(EventInfo_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_rangestatus(RangeStatus_struct *ptr, const u8 *flw_ptr, u8 length, u8 need_status); +extern void bicc_decode_transmedreq(TransMedReq_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_redirgnum(RedirgNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_redirinfo(RedirInfo_struct *ptr, u8 *flw_ptr, u8 length); +extern void bicc_decode_scfid(ScfId_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_susres(SusResInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_subseqnum(SubseqNum_struct *ptr, const u8 *flw_ptr, u8 length); +extern void bicc_decode_calldiverinfo(CallDiverInfo_struct *ptr, const u8 *flw_ptr); +extern void bicc_decode_optBackCallInd(OptBackCallInd_struct *ptr, const u8 *flw_ptr); +extern void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type); +extern void bicc_log_err(const char *fmt, ...); +extern void bicc_send_apm(u32 pid); + +int BICC_active_dmp(u8 plat_id, u32 alter_id) +{ + if(plat_id >= 2) + return 0; + Bicc_Data.dmp_data.active = 1; + Bicc_Data.dmp_data.processor_id = local_platid; + Bicc_Data.dmp_data.remote_ip = alter_id; + return BICC_CM_OK; +} + +int BICC_deactive_dmp() +{ + Bicc_Data.dmp_data.active = 0; + Bicc_Data.dmp_data.remote_ip = 0; + Bicc_Data.dmp_data.processor_id = local_platid; + return BICC_CM_OK; +} + +void bicc_transmit_func(u32 remote_ip, up_message_2 *upmsg_ptr) //transmit message to remote ip +{ + upmsg_ptr->dest_ip = remote_ip; + //bicc_to_mtp3(upmsg_ptr); + bicc_redirect(upmsg_ptr); +} + +int getPidByCic(u32 *pid, u32 cg_id, u32 cic) +{ + const pal_circuit_struct *pcircuit = NULL; + if((pcircuit = pal_locate_circuit(cg_id, cic)) != NULL) + { + *pid = (pcircuit->id)*BICC_CIRCUIT_CIC + (cic - pcircuit->attrib.head_cic); + return 1; + } + bicc_log_err("can not get port by cic %d, cg %d [%s]\n", cic,cg_id,__FUNCTION__); + return 0; +} + +static int find_port_by_cic(u8 ni, u32 dpc, u32 opc, u32 cic_val, u32* pid) +{ + const pal_circuit_struct *pcircuit = NULL; + if((pcircuit = pal_ss7_find_circuit(ni, opc, dpc, cic_val)) != NULL) + { + *pid = pcircuit->id*BICC_CIRCUIT_CIC + (cic_val - pcircuit->attrib.head_cic); + return 1; + } + bicc_log_err("can not find port by cic %d dpc %d opc %d ni %d [%s]\n",cic_val,opc,dpc,ni,__FUNCTION__); + return 0; +} + + + +int BICC_mdsc_proc() //get the message form Lower Layer +{ + u32 sap_id, cg_id, circuit_id; + u32 cic_val; + u32 pid; + u8 *flw_ptr; //message flow pointer + u8 msg_type; + BICC_Port_struct *port_ptr; + BiccMsg_union *msg_ptr; + BiccDmp_struct *dmp_ptr = &Bicc_Data.dmp_data; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + if(bicc_GetMsg(&r_mtp_msg) == 0) + return 0; + + + cic_val = (r_mtp_msg.cic[3]<<24) + (r_mtp_msg.cic[2]<<16) + (r_mtp_msg.cic[1]<<8) + r_mtp_msg.cic[0]; + + if(!find_port_by_cic(r_mtp_msg.sio>>6, r_mtp_msg.dpc, r_mtp_msg.opc, cic_val, &pid)) + return 0; + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if((dmp_ptr->active == 1) && (pcircuit != NULL) && (pcircuit->attrib.plat_id != dmp_ptr->processor_id)) + { + bicc_transmit_func(dmp_ptr->remote_ip, &r_mtp_msg); + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 2, cic_val,pid); + return 1 ; + } + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL && pcg->enable == 0) + return 0; + sap_id = pcg->sap_id; + port_ptr = &Bicc_Data.port_data[pid]; + flw_ptr = r_mtp_msg.msgList; + msg_type = *(flw_ptr++); + msg_ptr = &msg_union[pid]; + memset(msg_ptr, 0, sizeof(BiccMsg_union)); + + monitor_bicc_msg(r_mtp_msg.msgList, r_mtp_msg.len, 0, cic_val, pid); + switch(msg_type) + { + case M_ACM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv acm at idle"); + break; + } + port_ptr->sprc_cmd = M_ACM; + bicc_decode_backcall(&msg_ptr->acm.backCall, flw_ptr); + flw_ptr += 2; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->acm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->acm.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->acm.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_OPTBACKCALLIND: + bicc_decode_optBackCallInd(&msg_ptr->acm.optBackCall,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->acm.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->acm.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + bicc_cpco_proc(pid); + break; + case M_ANM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv anm at idle"); + break; + } + port_ptr->sprc_cmd = M_ANM; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->anm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_BACKCALLIND: + bicc_decode_backcall(&msg_ptr->anm.backCall, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->anm.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->anm.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->anm.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->anm.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_APM: // APM is not sent to CPC, event handle function is called directly + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv apm at idle"); + return 0; + } + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->apm.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_CPG: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv cpg at idle"); + break; + } + port_ptr->sprc_cmd = M_CPG; + bicc_decode_eventinfo(&msg_ptr->cpg.eventInfo, flw_ptr); + flw_ptr += 1; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->cpg.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_BACKCALLIND: + bicc_decode_backcall(&msg_ptr->cpg.backCall, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->cpg.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->cpg.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->cpg.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->cpg.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->cpg.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CALLDIVERINFO: + bicc_decode_calldiverinfo(&msg_ptr->cpg.calldiver, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_CGB: + port_ptr->sprc_cmd = M_CGB; + bicc_decode_cicgrpspv(&msg_ptr->cgb.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgb.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGBA: + port_ptr->sprc_cmd = M_CGBA; + bicc_decode_cicgrpspv(&msg_ptr->cgba.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgba.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGU: + port_ptr->sprc_cmd = M_CGU; + bicc_decode_cicgrpspv(&msg_ptr->cgu.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgu.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CGUA: + port_ptr->sprc_cmd = M_CGUA; + bicc_decode_cicgrpspv(&msg_ptr->cgua.cicGrpSpv, flw_ptr); + flw_ptr += 1; + bicc_decode_rangestatus(&msg_ptr->cgua.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_GRS: + port_ptr->sprc_cmd = M_GRS; + bicc_decode_rangestatus(&msg_ptr->grs.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 0); + break; + case M_GRA: + port_ptr->sprc_cmd = M_GRA; + bicc_decode_rangestatus(&msg_ptr->gra.rangeStatus, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr), 1); + break; + case M_CON: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv con at idle"); + break; + } + port_ptr->sprc_cmd = M_CON; + bicc_decode_backcall(&msg_ptr->con.backCall, flw_ptr); + flw_ptr += 2; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->con.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->con.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONNNUM: + bicc_decode_connnum(&msg_ptr->con.connNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->con.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->con.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_IAM: +#ifdef BICC_REATTEMPT + if(port_ptr->cic_state.call_state == BICC_INCOMING) + return 0; +#else + if(port_ptr->cic_state.call_state != BICC_CIC_IDLE) + return 0; +#endif + if(port_ptr->cic_state.call_state == BICC_TYPE_OUTGOING) + { + bicc_circuit_reset(pid, "recv iam at outgoing cic"); + break; + } +#ifdef BICC_REATTEMPT + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + port_ptr->cic_state.call_state = BICC_INCOMING; // mark the cic + } +#else + port_ptr->cic_state.call_state = BICC_INCOMING; // mark the cic +#endif + port_ptr->sprc_cmd = M_IAM; + bicc_decode_natconn(&msg_ptr->iam.natConn, flw_ptr); + flw_ptr += 1; + bicc_decode_fwdcall(&msg_ptr->iam.fwdCall, flw_ptr); + flw_ptr += 2; + bicc_decode_callingptycat(&msg_ptr->iam.callingPtyCat, flw_ptr); + flw_ptr += 1; + bicc_decode_transmedreq(&msg_ptr->iam.transMedReq, flw_ptr); + flw_ptr += 1; + bicc_decode_calledptynum(&msg_ptr->iam.calledPtyNum, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr)); + flw_ptr++; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_APPTRANS: + bicc_decode_app(&msg_ptr->iam.app, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CALLINGPTYNUM: + bicc_decode_callingptynum(&msg_ptr->iam.callingPtyNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_COLLECTCALLREQ: + bicc_decode_collectcallreq(&msg_ptr->iam.collectCallReq, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CONFTREATIND: + bicc_decode_conftreat(&msg_ptr->iam.confTreat, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_CORRELATIONID: + bicc_decode_correlationid(&msg_ptr->iam.correlationId, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_ORIGCALLEDNUM: + bicc_decode_origcallednum(&msg_ptr->iam.origCalledNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_REDIRGNUM: + bicc_decode_redirgnum(&msg_ptr->iam.redirgNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_REDIRINFO: + bicc_decode_redirinfo(&msg_ptr->iam.redirInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_SCFID: + bicc_decode_scfid(&msg_ptr->iam.scfId, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->iam.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->iam.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_REL: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + port_ptr->cic_state.call_state = BICC_INCOMING; + port_ptr->sprc_cmd = M_REL; + bicc_decode_cause(&msg_ptr->rel.cause, flw_ptr+*flw_ptr+1, *(flw_ptr + *flw_ptr)); + flw_ptr++; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_UTUIND: + bicc_decode_utuind(&msg_ptr->iam.utuInd, flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + break; + case P_UTUINFO: + bicc_decode_utuinfo(&msg_ptr->iam.utuInfo, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_RLC: + // if(Bicc_Data.port_data[pid].used_flag == 0) + // return 0; + if(check_crs_waiting(pid)) + port_ptr->sprc_cmd = M_RLC; + else + { + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + // port_ptr->cic_state.call_state = BICC_INCOMING; + break; + port_ptr->sprc_cmd = M_RLC; + } + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_CAUSEIND: + bicc_decode_cause(&msg_ptr->rlc.cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + case M_RSC: + port_ptr->sprc_cmd = M_RSC; + break; + case M_RES: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv res at idle"); + break; + } + port_ptr->sprc_cmd = M_RES; + bicc_decode_susres(&msg_ptr->res.susRes, flw_ptr); + break; + case M_SUS: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv sus at idle"); + break; + } + port_ptr->sprc_cmd = M_SUS; + bicc_decode_susres(&msg_ptr->sus.susRes, flw_ptr); + break; + case M_SAM: + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + bicc_circuit_reset(pid, "recv sam at idle"); + break; + } + port_ptr->sprc_cmd = M_SAM; + if(*flw_ptr == 0) + break; + flw_ptr += *flw_ptr; + while(flw_ptr+flw_ptr[1]+2-r_mtp_msg.msgList <= r_mtp_msg.len) + { + if(*flw_ptr == 0) //end of option parameter + break; + switch(*flw_ptr) + { + case P_SUBSEQNUM: + bicc_decode_subseqnum(&msg_ptr->sam.subseqNum, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + break; + default: //unknow message type + break; + } + bicc_msg2prm(&readPrim_union[pid], &msg_union[pid], msg_type); + if(msg_type == M_GRS) + bicc_cgrr_proc(pid); + if(msg_type == M_GRA) + bicc_cgrs_proc(pid); + if(msg_type == M_APM) + bicc_event_handle(pid, &readPrim_union[pid], BICC_APM_IND, EN_NONE); + if(msg_type == M_IAM) + { + bicc_cpci_proc(pid); + Bicc_Data.port_data[pid].used_flag = 1; + } + return 1; + +} + +void BICC_msdc_proc(u32 pid, up_message_2 * upmsg_ptr) //send the message to Lower Layer +{ + u32 cg_id, circuit_id; + u32 cic_val; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + + circuit_id = pid / BICC_CIRCUIT_CIC; + pcircuit = pal_circuit_ptr(circuit_id); + if(pcircuit != NULL) + cg_id = pcircuit->cg_id; + pcg = pal_cg_ptr(cg_id); + if(pcg == NULL) + return; + if((cic_val = pcircuit->attrib.head_cic+ pid % BICC_CIRCUIT_CIC) > + (pcircuit->attrib.head_cic + pcircuit->attrib.cic_range)) + { + bicc_log_err("No cic corresponds to pid.\n"); + return; + } + + + upmsg_ptr->dest_ip = 0xffffffff; + upmsg_ptr->dpc = pcg->attrib.dpc; + upmsg_ptr->opc = pcg->attrib.opc; + upmsg_ptr->cic[0] = cic_val & 0xff; + upmsg_ptr->cic[1] = (cic_val >> 8) & 0xff; + upmsg_ptr->cic[2] = (cic_val >> 16) & 0xff; + upmsg_ptr->cic[3] = (cic_val >> 24) & 0xff; + upmsg_ptr->sio = (pcg->attrib.network_id<<6) + BICC_SI; + + monitor_bicc_msg(Bicc_Data.port_data[pid].s_mtp_msg.msgList, Bicc_Data.port_data[pid].s_mtp_msg.len, 1, cic_val, pid); + bicc_to_mtp3(upmsg_ptr); +} + +int BICC_con_req(Pst *pst, BiccSetup_Req * ptr) +{ + + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + { + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SETUP_REQ; + port_ptr->used_flag = 1; + port_ptr->trace_flag = pst->trace_flag; + //if(port_ptr->cic_state.call_state == BICC_CIC_IDLE) + //{ + port_ptr->cic_state.call_state = BICC_OUTGOING; + memcpy(&writePrim_union[pst->sp_proc_id].setup_req, ptr, sizeof(BiccSetup_Req)); + } + else + { + + bicc_log_err("cic not idle,cic=%d, port = %d\n",pst->cic,pst->sp_proc_id); + return 0; + + } + + return 1; + +} + +int BICC_con_rsp(Pst *pst, BiccSetup_Rsp * ptr) +{ + + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SETUP_RSP; + + memcpy(&writePrim_union[pst->sp_proc_id].setup_rsp, ptr, sizeof(BiccSetup_Rsp)); + return 1; +} + + + +int BICC_rel_req(Pst *pst, BiccRel_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RELEASE_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].rel_req, ptr, sizeof(BiccRel_Req)); + return 1; +} + +int BICC_rel_rsp(Pst *pst, BiccRel_Rsp * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RELEASE_RSP; + + memcpy(&writePrim_union[pst->sp_proc_id].rel_rsp, ptr, sizeof(BiccRel_Rsp)); + return 1; +} + +int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_ALERT_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].alert_req, ptr, sizeof(BiccAlert_Req)); + bicc_cpci_proc(pst->sp_proc_id); + return 1; +} + +int BICC_info_req(Pst *pst, BiccInfo_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_INFO_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].info_req, ptr, sizeof(BiccInfo_Req)); + return 1; +} + +int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_PROG_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cpg_req, ptr, sizeof(BiccCpg_Req)); + return 1; +} + +int BICC_block_req(Pst *pst, BiccCgb_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_BLOCK_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cgb_req, ptr, sizeof(BiccCgb_Req)); + + return 1; + + +} + +int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESET_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].cgb_req, ptr, sizeof(BiccCgb_Req)); + + return 1; + + + +} + +int BICC_resm_req(Pst *pst, BiccRes_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESUME_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].res_req, ptr, sizeof(BiccRes_Req)); + return 1; +} + +int BICC_apm_req(Pst *pst, BiccApm_Req * ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_APM_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].apm_req, ptr, sizeof(BiccApm_Req)); + bicc_send_apm(pst->sp_proc_id); + return 1; +} + +int BICC_sus_req(Pst *pst, BiccSus_Req *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_SUSPEND_REQ; + + memcpy(&writePrim_union[pst->sp_proc_id].sus_req, ptr, sizeof(BiccSus_Req)); + return 1; +} + + +int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr) +{ + BICC_Port_struct *port_ptr; + //if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; + port_ptr->su_proc_id = pst->su_proc_id; + if(ptr!=NULL) + { + port_ptr->primitive_cmd = BICC_GROUP_RESET_REQ; + memcpy(&writePrim_union[pst->sp_proc_id].grs_req, ptr, sizeof(BiccGrs_Req)); + bicc_cgrs_proc(pst->sp_proc_id); + + } + else + port_ptr->primitive_cmd = BICC_RESET_REQ; + +// memcpy(&writePrim_union[pst->sp_proc_id].grs_req, ptr, sizeof(BiccGrs_Req)); + + return 1; + +} + + +int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr) +{ + BICC_Port_struct *port_ptr; + if(pst->sp_proc_id == 0) + if(!getPidByCic(&pst->sp_proc_id, pst->cg_id, pst->cic)) + return 0; + port_ptr = &Bicc_Data.port_data[pst->sp_proc_id]; +// port_ptr->su_proc_id = pst->su_proc_id; + port_ptr->primitive_cmd = BICC_RESET_RSP; + memcpy(&writePrim_union[pst->sp_proc_id].grs_rsp, ptr, sizeof(BiccGrs_Rsp)); + + return 1; +} + +void BICC_EMPTY_APM(ApmUser_struct *ptr) +{ + ptr->action.pres = 0; + ptr->bnc_id.pres = 0; + ptr->bnc_chr.pres = 0; + ptr->bc_info.pres = 0; + ptr->bc_tunnel.pres = 0; + ptr->signal_type.pres = 0; + ptr->duration.pres = 0; +} + +/* This function clear optional parameter flag */ +void BICC_EMPTY_OPTPAR(void *ptr, u8 prim) +{ + if((prim & 0xf0) == 0x00) //request + { + switch(prim) + { + case BICC_SETUP_REQ: + ((BiccSetup_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccSetup_Req *)ptr)->app.apm_info); + ((BiccSetup_Req *)ptr)->callingPtyNum.pres = 0; + ((BiccSetup_Req *)ptr)->collectCallReq.pres = 0; + ((BiccSetup_Req *)ptr)->confTreat.pres = 0; + ((BiccSetup_Req *)ptr)->correlationId.pres = 0; + ((BiccSetup_Req *)ptr)->origCalledNum.pres = 0; + ((BiccSetup_Req *)ptr)->redirgNum.pres = 0; + ((BiccSetup_Req *)ptr)->scfId.pres = 0; + ((BiccSetup_Req *)ptr)->utuInd.pres = 0; + ((BiccSetup_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_ALERT_REQ: + ((BiccAlert_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccAlert_Req *)ptr)->app.apm_info); + ((BiccAlert_Req *)ptr)->cause.pres = 0; + ((BiccAlert_Req *)ptr)->confTreat.pres = 0; + ((BiccAlert_Req *)ptr)->utuInd.pres = 0; + ((BiccAlert_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_APM_REQ: + ((BiccApm_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccApm_Req *)ptr)->app.apm_info); + break; + case BICC_PROG_REQ: + ((BiccCpg_Req *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccCpg_Req *)ptr)->app.apm_info); + ((BiccCpg_Req *)ptr)->backCall.pres = 0; + ((BiccCpg_Req *)ptr)->cause.pres = 0; + ((BiccCpg_Req *)ptr)->confTreat.pres = 0; + ((BiccCpg_Req *)ptr)->connNum.pres = 0; + ((BiccCpg_Req *)ptr)->utuInd.pres = 0; + ((BiccCpg_Req *)ptr)->utuInfo.pres = 0; + break; + case BICC_RELEASE_REQ: + ((BiccRel_Req *)ptr)->utuInd.pres = 0; + ((BiccRel_Req *)ptr)->utuInfo.pres = 0; + break; + default: + break; + } + } + else if((prim & 0xf0) == 0x80) //response + { + switch(prim) + { + case BICC_SETUP_RSP: + ((BiccSetup_Rsp *)ptr)->app.pres = 0; + BICC_EMPTY_APM(&((BiccSetup_Rsp *)ptr)->app.apm_info); + ((BiccSetup_Rsp *)ptr)->backCall.pres = 0; + ((BiccSetup_Rsp *)ptr)->confTreat.pres = 0; + ((BiccSetup_Rsp *)ptr)->connNum.pres = 0; + ((BiccSetup_Rsp *)ptr)->utuInd.pres = 0; + ((BiccSetup_Rsp *)ptr)->utuInfo.pres = 0; + break; + case BICC_RELEASE_RSP: + ((BiccRel_Rsp *)ptr)->cause.pres = 0; + break; + default: + break; + } + } +} + +void bicc_timer_init(int interval_ms) +{ + BiccTimer_struct *timer_ptr = &Timer_Data; + timer_ptr ->t1 = BICC_T1 * 1000 / interval_ms; + timer_ptr ->t5 = BICC_T5 * 1000 / interval_ms; + timer_ptr ->t7 = BICC_T7 * 1000 / interval_ms; + timer_ptr ->t8 = BICC_T8 * 1000 / interval_ms; + timer_ptr ->t9 = BICC_T9 * 1000 / interval_ms; + timer_ptr ->t12 = BICC_T12 * 1000 / interval_ms; + timer_ptr ->t13 = BICC_T13 * 1000 / interval_ms; + timer_ptr ->t14 = BICC_T14 * 1000 / interval_ms; + timer_ptr ->t15 = BICC_T15 * 1000 / interval_ms; + timer_ptr ->t16 = BICC_T16 * 1000 / interval_ms; + timer_ptr ->t17 = BICC_T17 * 1000 / interval_ms; + timer_ptr ->t18 = BICC_T18 * 1000 / interval_ms; + timer_ptr ->t19 = BICC_T19 * 1000 / interval_ms; + timer_ptr ->t20 = BICC_T20 * 1000 / interval_ms; + timer_ptr ->t21 = BICC_T21 * 1000 / interval_ms; + timer_ptr ->t22 = BICC_T22 * 1000 / interval_ms; + timer_ptr ->t23 = BICC_T23 * 1000 / interval_ms; + timer_ptr ->t28 = BICC_T28 * 1000 / interval_ms; + timer_ptr ->t33 = BICC_T33 * 1000 / interval_ms; + timer_ptr ->t34 = BICC_T34 * 1000 / interval_ms; + timer_ptr ->t35 = BICC_T35 * 1000 / interval_ms; + timer_ptr ->t40 = BICC_T40 * 1000 / interval_ms; + timer_ptr ->t41 = BICC_T41 * 1000 / interval_ms; + timer_ptr ->t42 = BICC_T42 * 1000 / interval_ms; + timer_ptr ->t43 = BICC_T43 * 1000 / interval_ms; + timer_ptr->user_t10 = BICC_USER_T10 * 1000 / interval_ms; + + +} + + +void BICC_init(int interval_ms,int local_id) +{ + u32 stack_size; + printf("Start BICC module init......\n"); + //memset(&BiccResource, 0, sizeof(BICC_Resource_pond)); + memset(&Bicc_Data, 0, sizeof(BiccData_struct)); + bicc_timer_init(interval_ms); + stack_size = sizeof(Bicc_Data); + bicc_debug_init(); + local_platid = local_id; + printf("BICC module init complete! Stack size: %ld bytes\n", stack_size); +} + + +void BICC_cpc_proc(u32 pid) +{ + BICC_Port_struct *port_ptr = &Bicc_Data.port_data[pid]; + if(port_ptr->cic_state.call_state == BICC_INCOMING) + bicc_cpci_proc(pid); + else if(port_ptr->cic_state.call_state == BICC_OUTGOING) + bicc_cpco_proc(pid); + else + { +// if((port_ptr->fsm_state.cgrs_state == 0)&&(port_ptr->primitive_cmd == 0)) +// memset(&Bicc_Data.port_data[pid],0,sizeof(BICC_Port_struct)); + } +} + + +void BICC_csc_proc(u32 pid) +{ + bicc_mgbs_proc(pid); + bicc_mgbr_proc(pid); + bicc_crs_proc(pid); + bicc_crr_proc(pid); + bicc_cgrs_proc(pid); + bicc_cgrr_proc(pid); +// bicc_blr_proc(pid); +// bicc_bls_proc(pid); +} + +void BICC_timer() +{ + u32 i, j; + u32 offset, pid; + const pal_circuit_struct *pcircuit = NULL; + const pal_cg_struct *pcg = NULL; + for(i = 0; i < 64; i++) + { + if(BICC_mdsc_proc() == 0) + break; + } + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + pcircuit = pal_circuit_ptr(i); + + if((pcircuit !=NULL) && (pcircuit->enable)) + { + if((pcg = pal_cg_ptr(pcircuit->cg_id)) && (pcg->attrib.protocol == PROTO_BICC)) + { + offset = BICC_CIRCUIT_CIC * i; + for(j = 0; j < BICC_CIRCUIT_CIC; j++) + { + pid = offset + j; + BICC_cpc_proc(pid); + BICC_csc_proc(pid); + } + } + } + } + bicc_debug_timer(); + +} + diff --git a/omc/plat/bicc/src/include/.copyarea.db b/omc/plat/bicc/src/include/.copyarea.db new file mode 100644 index 0000000..be529d5 --- /dev/null +++ b/omc/plat/bicc/src/include/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\bicc\src\include +2 +8 +7:ipbcp.h|1|11d70a3e9ef|5ec|3918ea7e|c54bc7539b5711dd8e28001c23e19543|0 +c:bicc_debug.h|1|11d70a3e8e6|2d0|bc45c482|c24bc6e39b5711dd8e28001c23e19543|0 +a:q1902_3e.h|1|11d70a3ea1e|2d50|c4a74e73|c67bc76f9b5711dd8e28001c23e19543|0 +5:inc.h|1|11d70a3e9c0|e57|566ed92f|c4abc7379b5711dd8e28001c23e19543|0 +8:biccif.h|1|11d70a3e972|32e4|3f0cf7b4|c37bc6ff9b5711dd8e28001c23e19543|0 +9:q765_5e.h|1|11d70a3ea4d|82e|ee80601c|c70bc78b9b5711dd8e28001c23e19543|0 +9:var_ext.h|1|11d70a3ea7c|15c|91ea711b|c7abc7a79b5711dd8e28001c23e19543|0 +8:define.h|1|11d70a3e991|1e9|94808f37|c41bc71b9b5711dd8e28001c23e19543|0 diff --git a/omc/plat/bicc/src/include/bicc_debug.h b/omc/plat/bicc/src/include/bicc_debug.h new file mode 100644 index 0000000..01fcba9 --- /dev/null +++ b/omc/plat/bicc/src/include/bicc_debug.h @@ -0,0 +1,25 @@ +#include "define.h" +#include "../../../debug/src/include/debug.h" + +#define LOG_ERR_FLAG 0x01 +#define LOG_BICC_FLAG 0x02 +#define LOG_MSG_FLAG 0x04 +#define LOG_TIME_FLAG 0x08 +#define LOG_DMP_FLAG 0x10 +#define LOG_ALL_FLAG 0x1f +#define LOG_FILE_FLAG 0x20 +/*******************************/ +#define MAX_OPR_LEN 16 +#define MAX_OBJ_LEN 32 +#define MAX_VALUE_LEN 32 +#define BICC_PREOID_LEN 12 +#define BICC_DEBUG_OID 17 +#define BICC_DEBUG_PAGE 10 +#define BICC_ASCIN_LEN 128 +#define BICC_ASCOUT_LEN 4096 + + +int bicc_debug_init(); +void bicc_debug_timer(); +void monitor_bicc_msg(u8 *msg,u8 buf_len, BYTE flag, u32 cic, u32 portNo); +void bicc_asciout_proc(const char *fmt, ...); diff --git a/omc/plat/bicc/src/include/biccif.h b/omc/plat/bicc/src/include/biccif.h new file mode 100644 index 0000000..a755dec --- /dev/null +++ b/omc/plat/bicc/src/include/biccif.h @@ -0,0 +1,417 @@ +#ifndef _BICCIF_H_ +#define _BICCIF_H_ + +#include "q765_5e.h" +#include "q1902_3e.h" +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../snmp/src/include/snmp.h" +//#include "../../../public/src/include/proto_pub.h" +#include "bicc_debug.h" +#include "../../../pal/pal.h" +/*********************************/ +/*** BICC Management Structure ***/ +/*********************************/ + +#define BICC_CM_OK 1 //command request success +#define BICC_CM_FAILED -1 //command request failed + +/************************************* +******BICC Resource Structure********* +*************************************/ +#define BICC_MAX_PORT 8192 +#define BICC_CG_CIRCUIT 32 +#define BICC_CIRCUIT_CIC 32 + + +/*** BICC Primitive Parameter Structure (different to q1902_3e) ***/ +typedef struct AppTransM_struct { //Application Transport Mechanism + u8 pres; + ApmUser_struct apm_info; +} AppTransM_struct; +/*********************************/ +/**** BICC Primitive Structure ***/ +/*********************************/ +typedef struct BiccSetup_Req { + NatConnInd_struct natConn;//F + FwdCallInd_struct fwdCall;//F + CallingPtyCat_struct callingPtyCat;//F + TransMedReq_struct transMedReq;//F + CalledPtyNum_struct calledPtyNum;//V + AppTransM_struct app; + CallingPtyNum_struct callingPtyNum; + CollectCallReq_struct collectCallReq; + ConfTreatInd_struct confTreat; + CorrelationId_struct correlationId; + OrigCalledNum_struct origCalledNum; + RedirgNum_struct redirgNum; + RedirInfo_struct redirInfo; + ScfId_struct scfId; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccSetup_Req, BiccSetup_Ind; + +typedef struct BiccSetup_Rsp { + AppTransM_struct app; + BackCallInd_struct backCall;//C: use it if no alert req is sent before + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccSetup_Rsp, BiccSetup_Cnf; + +typedef struct BiccAlert_Req { + BackCallInd_struct backCall;//F + AppTransM_struct app; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + OptBackCallInd_struct optBackCall; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAlert_Req, BiccAlert_Ind; + +typedef struct BiccInfo_Req { + SubseqNum_struct subseqNum;//V +} BiccInfo_Req, BiccInfo_Ind; + +typedef struct BiccApm_Req { + AppTransM_struct app; +} BiccApm_Req, BiccApm_Ind; + +typedef struct BiccCpg_Req { + EventInfo_struct eventInfo;//F + AppTransM_struct app; + BackCallInd_struct backCall; + CallDiverInfo_struct calldiver; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCpg_Req, BiccCpg_Ind; + +typedef struct BiccRel_Req { + CauseInd_struct cause;//V + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccRel_Req, BiccRel_Ind; + +typedef struct BiccRel_Rsp { + CauseInd_struct cause; +} BiccRel_Rsp, BiccRel_Cnf; + +typedef struct BiccRes_Req { + SusResInd_struct susRes;//F +} BiccRes_Req, BiccRes_Ind; + +typedef struct BiccSus_Req { + SusResInd_struct susRes;//F +} BiccSus_Req, BiccSus_Ind; + +typedef struct BiccCgb_Req { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_Req, BiccCgb_Ind; + +typedef struct BiccCgb_Rsp { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_Rsp, BiccCgb_Cnf; + +typedef struct BiccCgu_Req { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_Req, BiccCgu_Ind; + +typedef struct BiccCgu_Rsp { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_Rsp, BiccCgu_Cnf; + +typedef struct BiccGrs_Req { + RangeStatus_struct rangeStatus;//V +} BiccGrs_Req, BiccGrs_Ind; + +typedef struct BiccGrs_Rsp { + RangeStatus_struct rangeStatus;//V +} BiccGrs_Rsp, BiccGrs_Cnf; + + +typedef struct BiccSta_Req +{ + BiccMsg_struct biccMsg; +}BiccSta_Req; + +typedef struct BiccFac_Req +{ + FacInd_struct facInd; +}BiccFac_Req, BiccFac_Ind; + +typedef struct BiccFac_Rsp +{ + FacInd_struct facInd; +}BiccFac_Rsp, BiccFac_Cnf; + +typedef union BiccWritePrim_union { + BiccSetup_Req setup_req; + BiccSetup_Rsp setup_rsp; + BiccAlert_Req alert_req; + BiccInfo_Req info_req; + BiccApm_Req apm_req; + BiccCpg_Req cpg_req; + BiccRel_Req rel_req; + BiccRel_Rsp rel_rsp; + BiccRes_Req res_req; + BiccSus_Req sus_req; + BiccCgb_Req cgb_req;//only used in BICC module + BiccCgb_Rsp cgb_rsp;//only used in BICC module + BiccCgu_Req cgu_req;//only used in BICC module + BiccCgu_Rsp cgu_rsp;//only used in BICC module + BiccGrs_Req grs_req;//only used in BICC module + BiccGrs_Rsp grs_rsp;//only used in BICC module + BiccFac_Req fac_req; + BiccFac_Rsp fac_rsp; +} BiccWritePrim_union; + +typedef union BiccReadPrim_union { + BiccSetup_Ind setup_ind; + BiccSetup_Cnf setup_cnf; + BiccAlert_Ind alert_ind; + BiccInfo_Ind info_ind; + BiccApm_Ind apm_ind; + BiccCpg_Ind cpg_ind; + BiccRel_Ind rel_ind; + BiccRel_Cnf rel_cnf; + BiccRes_Ind res_ind; + BiccSus_Ind sus_ind; + BiccCgb_Ind cgb_ind;//only used in BICC module + BiccCgb_Cnf cgb_cnf;//only used in BICC module + BiccCgu_Ind cgu_ind;//only used in BICC module + BiccCgu_Cnf cgu_cnf;//only used in BICC module + BiccGrs_Ind grs_ind;//only used in BICC module + BiccGrs_Cnf grs_cnf;//only used in BICC module + BiccFac_Ind fac_ind; + BiccFac_Cnf fac_cnf; +} BiccReadPrim_union; + + +/********************************************/ +/****** BICC Internal Command *************/ +/********************************************/ +#define BICC_CMD_UNBLO 0x01 +#define BICC_CMD_BLO 0x02 +#define BICC_CMD_RESET 0x03 +#define BICC_CMD_RESET_COMP 0x04 + + +#define BICC_SI_CPCI 0x10 +#define BICC_SI_CPCO 0x20 +#define BICC_SI_BLS 0x30 +#define BICC_SI_BLR 0x40 +#define BICC_SI_MGBR 0x50 +#define BICC_SI_MGBS 0x60 +#define BICC_SI_CRS 0x70 +#define BICC_SI_CRR 0x80 +#define BICC_SI_CGRS 0x90 +#define BICC_SI_CGRR 0xA0 + +/********************************************/ +/****** BICC Event/Primitive Definition *****/ +/********************************************/ + +#define BICC_SETUP_REQ 0x01 //user-defined, first 4-digit:type of primitive second 4-digit:type of event +#define BICC_SETUP_IND 0x41 +#define BICC_SETUP_RSP 0x81 +#define BICC_SETUP_CNF 0xc1 +#define BICC_ALERT_REQ 0x02 +#define BICC_ALERT_IND 0x42 +#define BICC_INFO_REQ 0x03 +#define BICC_INFO_IND 0x43 +#define BICC_APM_REQ 0x04 +#define BICC_APM_IND 0x44 +#define BICC_PROG_REQ 0x05 +#define BICC_PROG_IND 0x45 +#define BICC_RELEASE_REQ 0x06 +#define BICC_RELEASE_IND 0x46 +#define BICC_RELEASE_RSP 0x86 +#define BICC_RELEASE_CNF 0xc6 +#define BICC_RESET_REQ 0x07 +#define BICC_RESET_IND 0x47 +#define BICC_RESET_CNF 0xc7 +#define BICC_RESET_RSP 0x87 +#define BICC_GROUP_RESET_REQ 0x17 + +#define BICC_BLOCK_REQ 0x08 +#define BICC_BLOCK_IND 0x48 +#define BICC_BLOCK_RSP 0x88 +#define BICC_BLOCK_CNF 0xc8 +#define BICC_UNBLOCK_REQ 0x09 +#define BICC_UNBLOCK_IND 0x49 +#define BICC_UNBLOCK_RSP 0x89 +#define BICC_UNBLOCK_CNF 0xc9 +#define BICC_SUSPEND_REQ 0x0a +#define BICC_SUSPEND_IND 0x4a +#define BICC_RESUME_REQ 0x0b +#define BICC_RESUME_IND 0x4b +#define BICC_REATTEMPT_IND 0x4c +#define BICC_FAILURE_IND 0x4f +#define BICC_FAC_REQ 0x0d +#define BICC_FAC_RSP 0x8d +#define BICC_FAC_IND 0x4d +#define BICC_FAC_CNF 0xcd +#define BICC_STA_IND 0x4e +#define BICC_STA_REQ 0x0e +#define BICC_MAINTENANCE_IND 0x44 // + +#define BICC_STOP_REQ 0xee +#define BICC_STOP_CNF 0xef + +typedef int f_bicc_setup_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_setup_anm_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_setup_con_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_release_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_release_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_alert_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_info_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_prog_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_suspend_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_resume_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reset_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reset_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_apm_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_reattempt_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_failure_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_block_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_block_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_unblock_ind(Pst *pst, const BiccReadPrim_union *prm_ptr); +typedef int f_bicc_unblock_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr); + +typedef struct bicc_eventhandle_struct +{ + f_bicc_setup_ind *h_bicc_setup_ind; + f_bicc_setup_anm_cnf *h_bicc_setup_anm_cnf; + f_bicc_setup_con_cnf *h_bicc_setup_con_cnf; + f_bicc_release_ind *h_bicc_release_ind; + f_bicc_release_cnf *h_bicc_release_cnf; + f_bicc_alert_ind *h_bicc_alert_ind; + f_bicc_info_ind *h_bicc_info_ind; + f_bicc_prog_ind *h_bicc_prog_ind; + f_bicc_suspend_ind *h_bicc_suspend_ind; + f_bicc_resume_ind *h_bicc_resume_ind; + f_bicc_block_ind *h_bicc_block_ind; + f_bicc_block_cnf *h_bicc_block_cnf; + f_bicc_unblock_ind *h_bicc_unblock_ind; + f_bicc_unblock_cnf *h_bicc_unblock_cnf; + f_bicc_reset_ind *h_bicc_reset_ind; + f_bicc_reset_cnf *h_bicc_reset_cnf; + f_bicc_apm_ind *h_bicc_apm_ind; + f_bicc_reattempt_ind *h_bicc_reattempt_ind; + f_bicc_failure_ind *h_bicc_failure_ind; + +}BICC_EventHandle_struct; + +typedef struct _bicc_sap_attrib_ +{ + BICC_EventHandle_struct event_handle; +}bicc_sap_sttrib_; + +typedef enum _BICC_network_id +{ + SI_INTERNATIONAL = 0, + SI_INTERNATIONAL_SPARE = 1, + SI_NATIONAL = 2, + SI_NATIONAL_SPARE = 3, + +}SI_Netwrok_ID; + +typedef struct bicc_cic_state +{ + u8 call_state; + u8 sus_state; //suspend state, remote hold? local hold? + u8 blo_state; //block state, remote block? local hold? +}BICC_CIC_state; + +typedef struct bicc_fsm_state +{ + u8 cpc_state; + u8 mgbs_state; + u8 mgbr_state; + u8 crs_state; + u8 crr_state; + u8 cgrs_state; + u8 cgrr_state; +}BICC_Fsm_state; + +typedef struct bicc_port_struct +{ + u8 used_flag; + u8 trace_flag; + u32 w_time; + u32 su_proc_id; + u8 sprc_cmd; + u8 primitive_cmd; + u8 internal_cmd; + BICC_Fsm_state fsm_state; + BICC_CIC_state cic_state; + up_message_2 s_mtp_msg; //message send to mtp3 +}BICC_Port_struct; + +extern up_message_2 r_mtp_msg; //message receive from mtp3 + +typedef struct BiccDmp_struct { + // If DMP is active, circuit 0-127 is according to proccessor 0, circuit 128-255 is accroding to proccessor 1 // + u8 active; + u8 processor_id; + u32 remote_ip; +} BiccDmp_struct; + + +/********************** +***upper layer interface*** +*********************** +*/ + +extern int BICC_con_req(Pst *pst, BiccSetup_Req *ptr); //iam //Connection establishment request +extern int BICC_con_rsp(Pst *pst, BiccSetup_Rsp *ptr); //anm,con //Connection establishment response +extern int BICC_rel_req(Pst *pst, BiccRel_Req *ptr); //Release request +extern int BICC_rel_rsp(Pst *pst, BiccRel_Rsp *ptr); //Release response +extern int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr); //alert +extern int BICC_info_req(Pst *pst, BiccInfo_Req *ptr); //sam +extern int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr); //progress +extern int BICC_apm_req(Pst *pst, BiccApm_Req *ptr); +extern int BICC_sus_req(Pst *pst, BiccSus_Req *ptr); //Call suspend request +extern int BICC_resm_req(Pst *pst, BiccRes_Req *ptr); //Call resume request +extern int BICC_block_req(Pst *pst, BiccCgb_Req *ptr); //block req +extern int BICC_block_rsp(Pst *pst, BiccCgb_Req *ptr); +extern int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr); //unblock req +extern int BICC_unblock_rsp(Pst *pst, BiccCgb_Req *ptr); +extern int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr); +extern int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr); //reset response + +extern void BICC_EMPTY_OPTPAR(void *ptr, u8 prim); + +extern BOOL bicc_trunk_reachable(u32 cg_id); +/***************************** +*** layer management interface*** +****************************** +*/ + +int BICC_active_dmp(u8 plat_id, u32 alter_id ); +int BICC_deactive_dmp(); + +/*********************** +*** lower layer interface*** +************************ +*/ +void BICC_msdc_proc(u32 pid, up_message_2 *upmsg_ptr); +int BICC_mdsc_proc(); + +/****************************** +*** system service interface*** +******************************* +*/ + +void BICC_init(int interval_ms, int local_id); +void BICC_timer(); + +#endif + diff --git a/omc/plat/bicc/src/include/define.h b/omc/plat/bicc/src/include/define.h new file mode 100644 index 0000000..63fc073 --- /dev/null +++ b/omc/plat/bicc/src/include/define.h @@ -0,0 +1,34 @@ +#ifndef _DEFINE_H_ +#define _DEFINE_H_ + +//typedef int BOOL; +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#define BICC_TOLERANT +#define BICC_REATTEMPT +#define BICC_DEBUG + +//Event +#define EN_NONE 0x00 +#define EN_ANM 0x01 +#define EN_CON 0x02 +#define EN_GROUP 0x03 + +#define M_LOCAL_BLOCK 0x01 +#define M_REMOTE_BLOCK 0x02 + +#endif + diff --git a/omc/plat/bicc/src/include/inc.h b/omc/plat/bicc/src/include/inc.h new file mode 100644 index 0000000..20d1c9c --- /dev/null +++ b/omc/plat/bicc/src/include/inc.h @@ -0,0 +1,162 @@ +#ifndef _INC_H +#define _INC_H + +#include +#include +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../snmp/src/include/snmp.h" +#include "biccif.h" + +#define BICC_VERSION {9, 0, 10, 0} +#define BICC_SCREEN_SIZE 32 + +#define BICC_TIMER_STOP 0 +#define BICC_TIMER_EXPIRED 1 +#define BICC_T1 15 +#define BICC_T5 300 +#define BICC_T7 30 +#define BICC_T8 10 +#define BICC_T9 120 +#define BICC_T12 15 +#define BICC_T13 300 +#define BICC_T14 15 +#define BICC_T15 300 +#define BICC_T16 15 +#define BICC_T17 300 +#define BICC_T18 15 +#define BICC_T19 300 +#define BICC_T20 15 +#define BICC_T21 300 +#define BICC_T22 15 +#define BICC_T23 300 +//#define BICC_T24 1 +//#define BICC_T25 1 +//#define BICC_T26 60 +//#define BICC_T27 240 +#define BICC_T28 10 +#define BICC_T33 12 +#define BICC_T34 2 +#define BICC_T35 15 +//#define BICC_T36 10 +//#define BICC_T37 2 +#define BICC_T40 10 +#define BICC_T41 10 +#define BICC_T42 5 +#define BICC_T43 5 +#define BICC_USER_T10 10//user defined timer,10s + + +#define BICC_CIC_IDLE 0 +#define BICC_INCOMING 1 +#define BICC_OUTGOING 2 +#define BICC_RESET 3 + + +#define BICC_TYPE_INCOMING 0 +#define BICC_TYPE_OUTGOING 1 +#define BICC_TYPE_BIDIRECT 2 + +#define BICC_ORIG_SUSPEND 0 //originating side suspend +#define BICC_TERM_SUSPEND 1 //terminating side suspend + + +typedef struct BiccTimer_struct +{ + int t1; + int t5; + int t7; + int t8; + int t9; + int t12; + int t13; + int t14; + int t15; + int t16; + int t17; + int t18; + int t19; + int t20; + int t21; + int t22; + int t23; + int t28; + int t33; + int t34; + int t35; + int t40; + int t41; + int t42; + int t43; + int user_t10; + +}BiccTimer_struct; + +typedef struct BiccMng_struct { + u8 state; + u32 lnk_id; + RangeStatus_struct rangeStatus; +} BiccMng_struct; + + +typedef struct BiccDebug_struct { + u32 flag; + u8 sap_enable[BICC_SCREEN_SIZE]; + u8 sap_cg_num[BICC_SCREEN_SIZE]; + + //u8 cg_enable[BICC_SCREEN_SIZE]; + //u8 network_id[BICC_SCREEN_SIZE]; + + // page 1 // + u8 cic_enable[BICC_SCREEN_SIZE]; + u8 cic_type[BICC_SCREEN_SIZE]; + u8 l_block[BICC_SCREEN_SIZE]; + u8 r_block[BICC_SCREEN_SIZE]; + // page 2 // + u8 cic_status[BICC_SCREEN_SIZE]; + u8 cpc_state[BICC_SCREEN_SIZE]; + u8 mgbs_state[BICC_SCREEN_SIZE]; + u8 mgbr_state[BICC_SCREEN_SIZE]; + u8 crs_state[BICC_SCREEN_SIZE]; + u8 crr_state[BICC_SCREEN_SIZE]; + u8 cgrs_state[BICC_SCREEN_SIZE]; + u8 cgrr_state[BICC_SCREEN_SIZE]; + // page 3 // + u8 sprc_command[BICC_SCREEN_SIZE]; + u8 mgbs_command[BICC_SCREEN_SIZE]; + u8 mgbr_command[BICC_SCREEN_SIZE]; + u8 crs_command[BICC_SCREEN_SIZE]; + u8 crr_command[BICC_SCREEN_SIZE]; + u8 cgrs_command[BICC_SCREEN_SIZE]; + u8 cgrr_command[BICC_SCREEN_SIZE]; + u8 prim_command[BICC_SCREEN_SIZE]; + // page 4 // + u8 mng_state; + u8 mng_lnk_id; +} BiccDebug_struct; + +typedef struct BiccData_struct +{ + BiccDebug_struct debug_data; + BiccMng_struct mng_data; + BiccDmp_struct dmp_data; + BiccTimer_struct timer_data[BICC_MAX_PORT]; + //BICC_Fsm_state fsm_data[BICC_MAX_PORT]; + BICC_Port_struct port_data[BICC_MAX_PORT]; + +}BiccData_struct; + +typedef struct stat_struct { +// u32 en_cic; + u32 lblo_cic; + u32 rblo_cic; +// u32 in_cic; +// u32 out_cic; +// u32 bi_cic; + u32 idle_call; + u32 in_call; + u32 out_call; + u32 lsus_cic; + u32 rsus_cic; +}stat_struct; +#endif + diff --git a/omc/plat/bicc/src/include/ipbcp.h b/omc/plat/bicc/src/include/ipbcp.h new file mode 100644 index 0000000..813b057 --- /dev/null +++ b/omc/plat/bicc/src/include/ipbcp.h @@ -0,0 +1,60 @@ +// Q.1970E; RFC 2327 // +#ifndef _IPBCP_H_ +#define _IPBCP_H_ + +typedef struct SdpOrig_struct { + char username[16]; + char session_id[16]; + char version[8]; + char network_type[8]; + char address_type[8]; + char address[16]; +} SdpOrig_struct; + +typedef struct SdpConn_struct { + char network_type[8]; + char address_type[8]; + char address[16]; +} SdpConn_struct; + +typedef struct SdpTime_struct { + char start[16]; //0 + char stop[16]; //0 +} SdpTime_struct; + +typedef struct SdpAttrib_struct { + char version[8]; //1 + char type[16]; //"Request"/"Accepted"/"Confused"/"Rejected" +} SdpAttrib_struct; + +typedef struct SdpMediaAnn_struct { + char media[16]; + char port[8]; + char transport[16]; + char fmt_list[128]; +} SdpMediaAnn_struct; + +// specify RTP dynamic payload types // +typedef struct SdpMediaAtt_struct { + char payload[8]; + char encoding_name[16]; + char clock_rate[8]; +// char p_time[8]; +} SdpMediaAtt_struct; + +typedef struct IPBCP_struct { + char proto_ver[8]; //Protocol version (M) + SdpOrig_struct orig; //Orign (M) + char session_name[16]; //Session name (M) + SdpConn_struct conn_data; //Connection data + SdpTime_struct time; //Time + SdpAttrib_struct attrib; //Session attribute + SdpMediaAnn_struct m_ann; //Media announcement (M) + SdpMediaAtt_struct m_att; //Media attributes + char ptime[8]; +} IPBCP_struct; + +extern int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr); +extern int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr); + +#endif diff --git a/omc/plat/bicc/src/include/q1902_3e.h b/omc/plat/bicc/src/include/q1902_3e.h new file mode 100644 index 0000000..16dc75a --- /dev/null +++ b/omc/plat/bicc/src/include/q1902_3e.h @@ -0,0 +1,456 @@ +#ifndef _q1902_3E_H_ +#define _q1902_3E_H_ +#include "define.h" +#include "q765_5e.h" +/******************************************/ +/******** BICC SIO (Q.1901E C.7.3) ********/ +/******************************************/ +#define BICC_SI 13 + +/******************************************/ +/* Message Type Codes (Q.1902-3E, page 5) */ +/******************************************/ +#define M_ACM 0x06//Address complete +#define M_ANM 0x09//Answer +#define M_APM 0x41//Application transport +#define M_BLO 0x13//Blocking +#define M_BLA 0x15//Blocking acknowledgement +#define M_CPG 0x2c//Call progress +#define M_CGB 0x18//Circuit/CIC group blocking +#define M_CGBA 0x1a//Circuit/CIC group blocking acknowledgement +#define M_CQM 0x2a//Circuit/CIC group query (national use) +#define M_CQR 0x2b//Circuit/CIC group query response (national use) +#define M_GRS 0x17//Circuit/CIC group reset +#define M_GRA 0x29//Circuit/CIC group reset acknowledgement +#define M_CGU 0x19//Circuit/CIC group unblocking +#define M_CGUA 0x1b//Circuit/CIC group unblocking acknowledgement +#define M_CRG 0x31//Charge information (national use) +#define M_CFN 0x2f//Confusion +#define M_CON 0x07//Connect +#define M_COT 0x05//Continuity +#define M_FAC 0x33//Facility +#define M_FAA 0x20//Facility accepted +#define M_FRJ 0x21//Facility reject +#define M_FAR 0x1f//Facility request +#define M_FOT 0x08//Forward transfer +#define M_IDR 0x36//Identification request +#define M_IRS 0x37//Identification response +#define M_INF 0x04//Information (national use) +#define M_INR 0x03//Information request (national use) +#define M_IAM 0x01//Initial address +#define M_LOP 0x40//Loop prevention +#define M_NRM 0x32//Network resource management +#define M_PRI 0x42//Pre-release information +#define M_REL 0x0c//Release +#define M_RLC 0x10//Release complete +#define M_RSC 0x12//Reset circuit/CIC +#define M_RES 0x0e//Resume +#define M_SGM 0x38//Segmentation +#define M_SAM 0x02//Subsequent address +#define M_SDM 0x43//Subsequent Directory Number (national use) +#define M_SUS 0x0d//Suspend +#define M_UBL 0x14//Unblocking +#define M_UBA 0x16//Unblocking acknowledgement +#define M_UCIC 0x2e//Unequipped CIC (national use) +#define M_USR 0x2d//User-to-user information + + +/*********************************************/ +/* Parameter Name Codes (Q.1902-3E, page 10) */ +/*********************************************/ +#define P_APPTRANS 0x78//Application transport +#define P_BACKCALLIND 0x11//Backward call indicators +#define P_CALLEDPTYNUM 0x04//Called party number +#define P_CALLINGPTYNUM 0x0a//Calling party number +#define P_CALLINGPTYCAT 0x09//Calling party's category +#define P_CAUSEIND 0x02//Cause indicators +#define P_CICGRPSPV 0x15//Circuit/CIC group supervision message type +#define P_COLLECTCALLREQ 0x79//Collect call request +#define P_CONFTREATIND 0x72//Conference treatment indicators +#define P_CONNNUM 0x21//Connected number +#define P_CORRELATIONID 0x65//Correlation id +#define P_EVENINFO 0x24//Event information +#define P_FACIND 0x18//Facility indicator +#define P_FWDCALLIND 0x07//Forward call indicators +#define P_NATCONNIND 0x06//Nature of connection indicators +#define P_ORIGCALLEDNUM 0x28//Original called number +#define P_RANGESTATUS 0x16//Range and status +#define P_REDIRGNUM 0x0b//Redirecting number +#define P_REDIRINFO 0x13//Redirection information +#define P_SCFID 0x66//SCF id +#define P_SUBSEQNUM 0x05//Subsequent number +#define P_SUSRESIND 0x22//Suspend/Resume indicators +#define P_TRANSMEDREQ 0x02//Transmission medium requirement +#define P_UTUIND 0x2a//User-to-user indicators +#define P_UTUINFO 0x20//User-to-user information +#define P_CALLDIVERINFO 0x36//Call diversion information +#define P_OPTBACKCALLIND 0x29//Optional backward call indicators + +/**********************************************/ +/* Parameter Structure (Q.1902-3E, section 6) */ +/**********************************************/ +#define MAX_BICC_DIGIT 32 +#define BICC_STATUS_LEN 32 +#define BICC_APP_LEN 200 +#define MAX_DIAGNOSTIC_LEN 32 + +typedef struct AppTrans_struct { + u8 pres; + u8 aci[2]; //Application context identifier + u8 :6; + u8 sni:1; //Send notification indicator + u8 rci:1; //Release call indicator + u16 :1; + u16 si:1; //Sequence indicator + u16 segment:6; //APM segmentation indicator + u16 :1; + u16 slr:7; //Segmentation local reference + // APM-user information (For APM'98-user application only) // + ApmUser_struct apm_info; +} AppTrans_struct; + +typedef struct BackCallInd_struct { + u8 pres; + u8 val[2]; +} BackCallInd_struct; + +typedef struct CalledPtyNum_struct { + u8 pres; + u8 nai; + u8 inn; + u8 npi; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} CalledPtyNum_struct; + +typedef struct CallingPtyNum_struct { + u8 pres; + u8 nai; + u8 ni; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} CallingPtyNum_struct; + +typedef struct CallingPtyCat_struct { + u8 pres; + u8 val; +} CallingPtyCat_struct; + +/* defined in Q.850E */ +typedef struct CauseInd_struct { + u8 pres; + u8 codingStd; + u8 location; + u8 causeVal; + //diagnostic +} CauseInd_struct; + +typedef struct CicGrpSpv_struct { + u8 pres; + u8 val; +} CicGrpSpv_struct; + +typedef struct CollectCallReq_struct { + u8 pres; + u8 val; +} CollectCallReq_struct; + +typedef struct ConfTreatInd_struct { + u8 pres; + u8 val; +} ConfTreatInd_struct; + +typedef struct ConnNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} ConnNum_struct; + +typedef struct EventInfo_struct { + u8 pres; + u8 val; +} EventInfo_struct; + +typedef struct FacInd_struct { + u8 pres; + u8 val; +} FacInd_struct; + +typedef struct FwdCallInd_struct { + u8 pres; + u8 val[2]; +} FwdCallInd_struct; + +typedef struct GenericNumber_struct { + u8 pres; + u8 nqi; //Number qualifier indicator + u8 nai; + u8 ni; + u8 npi; + u8 apri; + u8 si; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} GenericNumber_struct; + + +typedef struct GenericDigits_struct /* Generic Digits */ +{ + u8 pres; + u8 typeOfDigits; + u8 encodeScheme; + u8 numOfDigit; + u8* digits; +} GenericDigits_struct; + + +typedef GenericDigits_struct CorrelationId_struct; //R10 + +//typedef struct CorrelationId_struct { //R9 +// u8 pres; +// u8 digit[4]; //4 bytes +//}CorrelationId_struct; +typedef struct NatConnInd_struct { + u8 pres; + u8 val; +} NatConnInd_struct; + +typedef struct OrigCalledNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} OrigCalledNum_struct; + +typedef struct RangeStatus_struct { + u8 pres; + u8 range; + u8 status[BICC_STATUS_LEN]; +} RangeStatus_struct; + +typedef struct RedirgNum_struct { + u8 pres; + u8 nai; + u8 npi; + u8 apri; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} RedirgNum_struct; + +typedef struct RedirInfo_struct{ + u8 pres; + u8 redInd; + u8 origRedirReason; + u8 redirCounter; + u8 redirReason; +}RedirInfo_struct; + +typedef GenericDigits_struct ScfId_struct; +/*typedef struct ScfId_struct { + u8 pres; + u8 nai; + u8 inn; + u8 npi; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +}ScfId_struct; +*/ +typedef struct SubseqNum_struct { + u8 pres; + u8 numOfDigit; + u8 digit[MAX_BICC_DIGIT]; +} SubseqNum_struct; + +typedef struct SusResInd_struct { + u8 pres; + u8 val; +} SusResInd_struct; + +typedef struct TransMedReq_struct { + u8 pres; + u8 val; +} TransMedReq_struct; + +typedef struct UserToUserInd_struct { + u8 pres; + u8 val; +} UserToUserInd_struct; + +typedef struct UserToUserInfo_struct { + u8 pres; + u8 len; + u8 val[129]; +} UserToUserInfo_struct; + +typedef struct CallDiverInfo_struct +{ + u8 pres; + u8 notifSubsOption; + u8 redirReason; +}CallDiverInfo_struct; + +typedef struct OptBackCallInd_struct +{ + u8 pres; + u8 inbandInfoInd; + u8 callDiverOccurInd; + u8 simpSegmInd; + u8 mlppUserInd; +}OptBackCallInd_struct; +/********************************************/ +/* Message structure (Q.1902-3E, section 7) */ +/********************************************/ +typedef struct BiccAcm_struct { + BackCallInd_struct backCall;//F + AppTrans_struct app; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + OptBackCallInd_struct optBackCall; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAcm_struct; + +typedef struct BiccAnm_struct { + AppTrans_struct app; + BackCallInd_struct backCall; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccAnm_struct; + +typedef struct BiccApm_struct { + AppTrans_struct app; +} BiccApm_struct; + +typedef struct BiccCpg_struct { + EventInfo_struct eventInfo;//F + AppTrans_struct app; + BackCallInd_struct backCall; + CallDiverInfo_struct calldiver; + CauseInd_struct cause; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCpg_struct; + +typedef struct BiccCgb_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgb_struct; + +typedef struct BiccCgba_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgba_struct; + +typedef struct BiccCgu_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgu_struct; + +typedef struct BiccCgua_struct { + CicGrpSpv_struct cicGrpSpv;//F + RangeStatus_struct rangeStatus;//V +} BiccCgua_struct; + +typedef struct BiccGrs_struct { + RangeStatus_struct rangeStatus;//V +} BiccGrs_struct; + +typedef struct BiccGra_struct { + RangeStatus_struct rangeStatus;//V +} BiccGra_struct; + +typedef struct BiccCon_struct { + BackCallInd_struct backCall;//F + AppTrans_struct app; + ConfTreatInd_struct confTreat; + ConnNum_struct connNum; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccCon_struct; + +typedef struct BiccIam_struct { + NatConnInd_struct natConn;//F + FwdCallInd_struct fwdCall;//F + CallingPtyCat_struct callingPtyCat;//F + TransMedReq_struct transMedReq;//F + CalledPtyNum_struct calledPtyNum;//V + AppTrans_struct app; + CallingPtyNum_struct callingPtyNum; + CollectCallReq_struct collectCallReq; + ConfTreatInd_struct confTreat; + CorrelationId_struct correlationId; + OrigCalledNum_struct origCalledNum; + RedirgNum_struct redirgNum; + RedirInfo_struct redirInfo; + ScfId_struct scfId; + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; + +} BiccIam_struct; + +typedef struct BiccRel_struct { + CauseInd_struct cause;//V + UserToUserInd_struct utuInd; + UserToUserInfo_struct utuInfo; +} BiccRel_struct; + +typedef struct BiccRlc_struct { + CauseInd_struct cause; +} BiccRlc_struct; + +typedef struct BiccRes_struct { + SusResInd_struct susRes;//F + //Optional +} BiccRes_struct; + +typedef struct BiccSus_struct { + SusResInd_struct susRes;//F + //Optional +} BiccSus_struct; + +typedef struct BiccSam_struct { + SubseqNum_struct subseqNum;//V + //Optional +} BiccSam_struct; + +typedef struct BiccMsg_struct +{ + +}BiccMsg_struct; + + +typedef union BiccMsg_union { + BiccAcm_struct acm; + BiccAnm_struct anm; + BiccApm_struct apm; + BiccCpg_struct cpg; + BiccCgb_struct cgb; + BiccCgba_struct cgba; + BiccCgu_struct cgu; + BiccCgua_struct cgua; + BiccGrs_struct grs; + BiccGra_struct gra; + BiccCon_struct con; + BiccIam_struct iam; + BiccRel_struct rel; + BiccRlc_struct rlc; + BiccRes_struct res; + BiccSus_struct sus; + BiccSam_struct sam; +} BiccMsg_union; + +#endif + diff --git a/omc/plat/bicc/src/include/q765_5e.h b/omc/plat/bicc/src/include/q765_5e.h new file mode 100644 index 0000000..b404cf0 --- /dev/null +++ b/omc/plat/bicc/src/include/q765_5e.h @@ -0,0 +1,100 @@ +#ifndef _q765_5E_H_ +#define _q765_5E_H_ +#include "define.h" + +#define AP_ACTION 0x01 +#define AP_BNCID 0x02 +#define AP_IWFADDR 0x03 +#define AP_CODECLIST 0x04 +#define AP_SINGLECODEC 0x05 +#define AP_BATCR 0x06 +#define AP_BNCCHR 0x07 +#define AP_BCINFO 0x08 +#define AP_BCTUNNEL 0x09 +#define AP_BCUI 0x0a +#define AP_SIGNAL 0x0b +#define AP_BRC 0x0c +#define AP_BRI 0x0d +#define AP_SIGNALTYPE 0x0e +#define AP_DURATION 0x0f + +/************************************************/ +/***** Encapsulated application information *****/ +/************************************************/ +typedef struct ActionInd_struct { + u8 pres; + u8 comp_info; + u8 val; +} ActionInd_struct; + +typedef struct BncId_struct { + u8 pres; + u8 comp_info; + u8 len; + u8 val[4]; +} BncId_struct; + +typedef struct IwfAddr_struct { + u8 pres; + //... +} IwfAddr_struct; + +typedef struct BncChr_struct { + u8 pres; + u8 comp_info; + u8 val; +} BncChr_struct; + +typedef struct BCTP_struct { + // BTCP (Q.1990) // + u8 :1; + u8 bvei:1; //BCTP Version Error Indicator + u8 :1; + u8 btcp_version:5; //BCTP Version Indicator + u8 :1; + u8 tpei:1; //Tunnelled Protocol Error Indicator + u8 tunnel_protocol:6; //Tunnelled Protocol Indicator + // IPBCP (Q.1970) // + u8 ipbcp_len; + u8 ipbcp_content[200]; +} BCTP_struct; + +typedef struct BcInfo_struct { + u8 pres; + u8 comp_info; + BCTP_struct bctp; +} BcInfo_struct; + +typedef struct BcTunnel_struct { + u8 pres; + u8 comp_info; + u8 val; +} BcTunnel_struct; + +typedef struct SignalType_struct { + u8 pres; + u8 comp_info; + u8 val; +} SignalType_struct; + +typedef struct Duration_struct { + u8 pres; + u8 comp_info; + u16 val; +} Duration_struct; + +typedef struct ApmUser_struct { + u8 :6; + u8 sni:1; //Send notification indicator + u8 rci:1; //Release call indicator + ActionInd_struct action; + BncId_struct bnc_id; + BncChr_struct bnc_chr; + BcInfo_struct bc_info; + BcTunnel_struct bc_tunnel; + SignalType_struct signal_type; + Duration_struct duration; +} ApmUser_struct; + +#endif + diff --git a/omc/plat/bicc/src/include/var_ext.h b/omc/plat/bicc/src/include/var_ext.h new file mode 100644 index 0000000..480534d --- /dev/null +++ b/omc/plat/bicc/src/include/var_ext.h @@ -0,0 +1,14 @@ +#ifndef _VAR_EXT_H_ +#define _VAR_EXT_H_ + +#include "define.h" +#include "biccif.h" +#include "inc.h" + + +extern u8 Bicc_Version[4]; +extern BiccData_struct Bicc_Data; +extern BiccTimer_struct Timer_Data; +extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT]; +extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT]; +#endif diff --git a/omc/plat/debug/.copyarea.db b/omc/plat/debug/.copyarea.db new file mode 100644 index 0000000..b8730bc --- /dev/null +++ b/omc/plat/debug/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\debug +2 +5 +3:doc|2|0|0|0|c92966b9bfa411dc8511001c23e19543|0 +2:ut|2|0|0|0|ccc96799bfa411dc8511001c23e19543|0 +3:src|2|0|0|0|ca59670dbfa411dc8511001c23e19543|0 +8:Makefile|1|11d70a3eb18|b39|e7adc250|c9c966f1bfa411dc8511001c23e19543|0 +3:lib|2|0|0|0|c92966d5bfa411dc8511001c23e19543|0 diff --git a/omc/plat/debug/Makefile b/omc/plat/debug/Makefile new file mode 100644 index 0000000..5f7c859 --- /dev/null +++ b/omc/plat/debug/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module template : V1.6.3 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + +MODULE = debug +TYPE = plat + +DBUG_FLAGS_ADD = -DDEBUG +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/debug/lib/libdebug.a b/omc/plat/debug/lib/libdebug.a new file mode 100644 index 0000000..3415bc0 Binary files /dev/null and b/omc/plat/debug/lib/libdebug.a differ diff --git a/omc/plat/debug/obj/debug.o b/omc/plat/debug/obj/debug.o new file mode 100644 index 0000000..d8176ae Binary files /dev/null and b/omc/plat/debug/obj/debug.o differ diff --git a/omc/plat/debug/src/.copyarea.db b/omc/plat/debug/src/.copyarea.db new file mode 100644 index 0000000..427880c --- /dev/null +++ b/omc/plat/debug/src/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\debug\src +2 +2 +7:include|2|0|0|0|caf96745bfa411dc8511001c23e19543|0 +7:debug.c|1|11d70a3ec9e|8ae65|9fc7892a|e624829e6cf311dd91a5001c23e19543|0 diff --git a/omc/plat/debug/src/debug.c b/omc/plat/debug/src/debug.c new file mode 100644 index 0000000..965f9eb --- /dev/null +++ b/omc/plat/debug/src/debug.c @@ -0,0 +1,15649 @@ +/* +* ******************************************** +* debug.c * +* Author: Li Long * +* Verified by Liu Zhiguo 2003-04-21 * +* Verified by Wang Jian 2005-01-17 * +* Verified by liu Wei 2005-05-15 * +* 2005-05-15 * +* Function: * +* 1. Monitor other modules status; * +* 2. Use serial port; * +* 3. Use telnet; * +* 4. Use SNMP Agent set MIB tree * +* 5. SNMP sernior agent * +* 6. Custmor setting menu * +* ******************************************** +*/ + + +/* +printf("\033[1;33m Hello World. \033[0m \n"); + +颜色如下: +none = "\033[0m" +black = "\033[0;30m" +dark_gray = "\033[1;30m" +blue = "\033[0;34m" +light_blue = "\033[1;34m" +green = "\033[0;32m" +light_green -= "\033[1;32m" +cyan = "\033[0;36m" +light_cyan = "\033[1;36m" +red = "\033[0;31m" +light_red = "\033[1;31m" +purple = "\033[0;35m" +light_purple = "\033[1;35m" +brown = "\033[0;33m" +yellow = "\033[1;33m" +light_gray = "\033[0;37m" +white = "\033[1;37m" + + +字背景颜色范围: 40--49 字颜色: 30--39 + 40: 黑 30: 黑 + 41: 红 31: 红 + 42: 绿 32: 绿 + 43: 黄 33: 黄 + 44: 蓝 34: 蓝 + 45: 紫 35: 紫 + 46: 深绿 36: 深绿 + 47: 白色 37: 白色 +ANSI控制码: +QUOTE: + \033[0m 关闭所有属性 + \033[1m 设置高亮度 + \03[4m 下划线 + \033[5m 闪烁 + \033[7m 反显 + \033[8m 消隐 + \033[30m -- \033[37m 设置前景色 + \033[40m -- \033[47m 设置背景色 + \033[nA 光标上移n行 + \03[nB 光标下移n行 + \033[nC 光标右移n行 + \033[nD 光标左移n行 + \033[y;xH设置光标位置 + \033[2J 清屏 + \033[K 清除从光标到行尾的内容 + \033[s 保存光标位置 + \033[u 恢复光标位置 + \033[?25l 隐藏光标 + \33[?25h 显示光标 + + + +\033=\x1b +*/ + +#include "./include/debug.h" +#include "../../public/src/include/pub_log.h" +#include "../../public/src/include/pub_debug.h" + +// by simon at 23/9/25 +struct debug_shm_struct *debug_shm_ptr; + +/*@ignore@*/ +static char ascii[16] = + { + 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, + 0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46 + }; + +static char title_top[] = {0xc,0x1b,'[','H',0x1b,'[','2','J','\0'}; + +static char prompt_line25[] = {0x1b,'[','2','5','H',0x1b,'[','0','J','>','\0'}; + +static char max_access[7][32]={"invalid", "not-accessible", "accessible-for-notify", "read-only","read-write","read-create "," write-only"}; + +static char title1[TITLE_CHAR*DEBUG_MAX_PAGE] = "\0"; // show the menu page from conf file +char title1_show[TITLE_CHAR*DEBUG_MAX_PAGE] ="\0"; // show the menu page + +unsigned int com_port; +char recser_buf[SERIAL_BUF_LEN]; +int recserbuf_h; +int recserbuf_t; +char sendser_buf[SERIAL_BUF_LEN]; +int sendserbuf_h; +int sendserbuf_t; + +INSTANCE_ARR curr_instance_arr[256]; +char instance_eable_name[80]; +int temp_instance; +BYTE curr_module; +BYTE host_group=0; +debug_snmp_agent snmp_agent_packet; +debug_snmp_agent snmp_agent_packet1; +DWORD debug_mem_size; +DWORD debug_alloc_mem; + +BYTE remark_meet_lf=0; + +debug_shm_struct debug_shared_memory; + +DWORD heap_remark_index; +void *heap_remark_curr; +void *heap_remark; +char heap_work_buf[300*1024]; + +char curr_instance_value[256]; +char set_ins_value[256]; +BYTE none_instance=0; +BYTE set_str_len=0; +BYTE set_all=0; +char set_val_str[256] ; +BYTE SendTelnetFlag=0; +BYTE disp_main_flag; // display the main page +BYTE disp_sub_module_flag; // current module +BYTE disp_page_flag; // current page of each module +BYTE disp_main_page_num; //main page number +BYTE command_flag; // whether in command mode +BYTE first_page; +BYTE bind_num; +BYTE comp_disp[500]; +BYTE m_state; +BYTE m_state_sub_module; +WORD title_top_pt; +WORD title_pt; +WORD title_sub_module_pt; +WORD ascii_in_pt; +WORD space_counter; +WORD row_ptr,col_ptr; +int list_flag,list_start,list_end; +int show_all_value; +int show_type; +int show_expend; +int show_range; +int get_show_state; +int save_flag; +int show_empty=0; +int del_flag; +int expend_view=0; +int list_field=0; +int show_snmp_state; +int show_list; +int list_once; +BYTE set_after_get=0; +BYTE show_field=0; +DWORD list_field_arr[64]; +BYTE Module_Count_Index=0; +BYTE Init_Page=0; +BYTE send_char_flag=0; + +BYTE debug_agent_index; +BYTE snmp_agent_flag=0; // 0 idel 1 get 2 set + +BYTE *disp_ptr; +WORD disp_length;/* displaying length of each row */ +WORD disp_index; /* row number */ +WORD char_ptr; /* how many hex code in a row, < disp_length */ +WORD hex_state; /* the state in function disp_hex */ +BYTE cursor_p[8]; /* control characters as 'ESC[**;**H' */ + +WORD ascii_out_ph,ascii_out_pt; +static BYTE ascii_out_array[MAX_ASCII_LEN]; +static BYTE ascii_in_array[MAX_ASCII_LEN]; + +static BYTE debug_ascii_in_array[MAX_ASCII_LEN]; +static BYTE debug_ascii_out_array[MAX_ASCII_LEN]; +int debug_ascii_out_ph=0; +int debug_ascii_out_pt=0; + + + +BYTE list_msg[128]; + +static BYTE test_array[20]; +WORD t10s_flag; +WORD ascii_out_len; +DWORD debug_counter; +BYTE debug_heartbeat[8]; +char time_buf[64] = "\0"; +char hostip_buf[64] = "\0"; +char current_timer[64]="\0"; + + +BYTE bind_index; +BYTE get_state; +BYTE set_state; +DWORD set_val; + + +DWORD Local_IP; +DWORD Peer_IP[16]; +char Remote_Host_Name[16][64]; +char Remote_Host_IP[16][16]; +BYTE IP_Selected[16]; +BYTE ip_num; +BYTE ip_index; +snmp_pdu send_msgbuf,recv_msgbuf; +snmp_addr send_addr, recv_addr; +WORD t5s_flag; +WORD t100ms_flag; +mib_node_param *param_node; +char paraname[128]; +mib_node *temp_mib_node; +WORD mib_line_count; +mib_node temp_leaf_node; + + +DWORD root_oid[32] = {1,3,6,1,4,1}; //SNMPv2 +DWORD cur_oid[32] = {1,3,6,1,4,1,1373,1,3}; +BYTE root_oid_len = 6; +WORD treehost; +BYTE debug_remark_flag; +WORD debug_remark_ptr; + +/* by simon at 23/9/25 */ +mib_node *mib_root_node; +mib_node *mib_curr_node; +menu_node *menu_root_node; +menu_node *menu_curr_node; +mib_node mib_nodes[MIB_MAX_NODES]; + +char file_name[128]; +FILE *fp_prt; +long int timeuse, max_time; +struct timeval tv_start, tv_end; + +menu_node menu_nodes[MENU_MAX_NODES]; +mib_child_node mib_child_nodes[MIB_MAX_CHILD_NODES]; + +debug_snmp_agent debug_snmp_agent_buf[MAX_PACKET_NUM]; +/* end by simon */ + +struct _wxc2_debug_info wxc2_debuginfo; + +//mib_node *mib_root_node; +//mib_node *mib_curr_node; +WORD mib_node_index=0; +WORD menu_node_index=0; +WORD mib_child_node_index; +int mib_type_num; + +BYTE leaf_compute_field_num=0; +WORD mib_param_select_index; +WORD mib_param_input_index; +WORD mib_node_param_index; + +BYTE debug_cfg; //0: command status, 1: configure status +BYTE debug_log_all; // 0: log none , 1: log all +BYTE debug_log_error_on; //0: log error off, 1: log erro on +BYTE debug_module_num; //if in command status, debug_module_num shows which module's ascii in buf the command send to +BYTE debug_cfg_end; // 0: configure command not over, 1: configure command over +int debug_get_all_value; // 0: not get all value, or means how much children value have to get + +WORD gobal_module_index; +BYTE node_save_flag; +module_command_save_flag node_save_module; + +mib_subsys_module subsys_module[MIB_SUBSYS_MODULE_MAX_NUM]; +mib_host module_host[MIB_HOST_MAX_NUM]; +module_command_save_flag module_save_flag[MIB_SUBSYS_MODULE_MAX_NUM]; + + +mib_param_select mib_param_select_array[MIB_MAX_PARAM_SELECTS]; +mib_param_input mib_param_input_array[MIB_MAX_PARAM_INPUTS]; +mib_node_param mib_node_param_array[MIB_MAX_NODE_PARAMS]; + +mibfile_imports_data imports_data; +mibfile_module_data module_data; +mibfile_object_data object_data; +mibfile_type_data type_data; + +BYTE set_ok_once=0; + + +char *field_input_type[7]={"toDec high 0","KeepHex high 0","KeepHex low 0", + "KeepHex Low E","KeepHex Low F","ToAscii Low 0","KeepAscii Low F"}; + + +//add for compute field +BYTE compute_field_num; //for all compute +compute_field compute_field_arr[16]; //for all compute +compute_list compute_field_list[6]; //unit list +BYTE compute_list_num; //unit list//curr node compute_list_num=0 +char OID_name_str[5][65]; //unit read +DWORD OID_val[5][32]; //unit read +BYTE OID_index=0; //unit read +BYTE line_index; //unit read +BYTE print_line_index=0;; +BYTE compute_field_list_index; +compute_field compute_curr_unit; //unit read +BYTE read_syntax_nor_list=0; //unit read +BYTE compute_state=0; +WORD compute_curr_instance; +mib_node *temp_compute_node; +char temp_value[256][32]; +BYTE print_once=0; +//0 idle +//1 print once(list all once) +//2 print again +BYTE field_compute_state=0; +//field_compute_state +//0 idle +//1 find compute field +//2 translate [v] [l] +//3 list curr node self +//4 list "OID" +//5 list over +//6 translate [c] [p] +//7 translate over +//8 print over + +//end of define for compute field + + + +struct timeval tv_start_rt, tv_end_rt; +mib_node *agent_tmp_node; +menu_node *tmp_menu_node; + + +BYTE ShowRegister=0; +BYTE debug_busy_alarm=0; + + +static char switch_stat[][32] = {"off", "on"}; + +///////////////////////////////////declaration//////////////////////// +void debug_init_serial(); + +void debug_init_shm(); + +void debug_init_var(); + +void debug_ascii_in_cmd_handle(); + + + + +void debug_read_main_title(); + +void debug_change_title1(); + +void debug_module_page(int count); + +void debug_disp_hex(); + +void debug_set_para(); + + + + +int OBJECT_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD *last_node_oid); + + +int BEGIN_found(FILE *fp); + +int TYPE_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD +*last_node_oid); + +mib_node *IMPORTS_found(FILE *fp); + +int MODULE_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD +*last_node_oid); + +int Analyze_Leaf_Description(FILE * fp, mib_node * leaf_node); + +//int analyze_setTemplate(FILE *fp, mib_node *father_node_ptr); + +int MIB_create_tree(char *conf_dir, char *conf_file); + +//int MIB_create_leaves(char *conf_dir, char *sysConf_file, char *param_list_file); + +mib_child_node *create_mib_child_node(char *name, DWORD oid); + +mib_node *create_mib_node(char *name, BYTE oid_len, DWORD *oid, WORD total_instance); + + +mib_node *create_node(char *line, char *nod_name, int instance, mib_node *father_ptr, DWORD *last_node_oid); + +int register_node(mib_node *mib_node_ptr, DWORD *oid, BYTE oid_len); + +int register_child_node(mib_node *mib_node_ptr, mib_child_node *mib_child_node_ptr); + + + + +void debug_mmi_remark(); + + +void debug_mmi_log_status(); + +int debug_mmi_log(char *log_str); + +void debug_mmi_option(char *str); + +int debug_mmi_select_host(char *host_str); + + + +void show_node(mib_node *node_ptr,char *separation); + +int find_OID(int obj_num, char *sysConf_file_name, DWORD *OID); + + +void debug_mmi_view(); + + +void pick_name(char *str_ptr, char *word_ptr,char *temp_ch); + + +void debug_send_serial(); + +int debug_send_char(BYTE ch); + +void debug_read_serial(); + +int debug_read_char(); + +void debug_recv_cmd(); + + + +int debug_mmi_cd(char *path); + +int debug_mmi_contents(char *str); + +int debug_mmi_parent(); + +int debug_mmi_child(char *name); + +int debug_mmi_setins(char *ins); + +void debug_mmi_save(); + +void register_host(); + +int debug_mmi_pwd(); + +int debug_mmi_ip(char *ips); + +void debug_mmi_list(); + +void register_instance(); + +void debug_mmi_create(char *str); + +void debug_mmi_del(char *str); + +void debug_mmi_option(char *str); + +void debug_mmi_remark(); + +void debug_mmi_tree(mib_node *node_ptr,char *separation, BYTE node_levels); + +void debug_mmi_find_host(); + +int debug_mmi_show_host(); + +void debug_mmi_cmm_help(); + +void debug_mmi_cfg_help(); + +int debug_mmi_get(char *child_name); + +int debug_mmi_set(char *set_str); + +int debug_mmi_get_all(); + +int debug_snmp_get(BYTE oidlen,DWORD *oid,BYTE *data_ptr,BYTE *vartype); + +int debug_snmp_set(BYTE oidlen,DWORD *oid,BYTE *data_ptr,WORD data_len); + +void debug_snmp_get_rt(); + +void debug_snmp_set_rt(); + + +int default_value(DWORD *oid,BYTE oid_len,char *value);//,char *default_Value); + +int debug_mmi_select_host(char *host_str); + + + + + +void debug_set_currenttime(); + +void del_space(char *str,BYTE type); + +int read_line(FILE *fp, char *line_ptr); + +int read_begin(FILE *fp, char *stop_ch); + +int read_until(FILE *fp, char *data_ptr, char *stop_ch); + +int read_part(FILE *fp, char *data_ptr,char *start_ch, char *stop_ch); + +char *pick_first_word(char *str_ptr, char *word_ptr); + +int take_str(char *data_str, FILE *fp, char *data_ptr); + +void debug_color_out(int attr,int color,int bg,char *str); + +void help_cmm(int index,char *str1,char *str2); + +void formatstr(int len,char *str,BYTE type); + +void switchchar(char *out_text,BYTE num); + +void debug_ascii_out_proc(const char *str_ptr); + +DWORD my_pow(int x, int y); // y \u4E2A x \u76F8\u4E58 + +BYTE test_str(char *str,BYTE type); + +void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len); + +void strpcat(char *dest_str,DWORD *dest_p,const char *src_str); + +//void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len); + + +int create_menu_tree(char *conf_dir,char *menu_page,mib_node *sys_node); + +void debug_mmi_view(); + +void debug_mmi_mcd(char *str); + +void main_menu(char *str); + +int debug_send_string(const char *str_send); + + + + +BYTE create_compute_field(FILE * fp, mib_node * node_ptr, BYTE field_id,char *name); + +void translate_compute_field(); + +BYTE take_compute_value(char *str,char *temp_value); + +void compute_field_WatchDog(); + +void print_compute_field(); +extern inline char *StrToLower ( char *pStr ); +extern inline char *StrTrimCh ( char *pSrc , char cTrim ); + + + +//////////////////////////////////end of declaration////////////////// + + + + +void debug_netcap_start() +{ + char str[] = "net cap start"; + int i; + + NcStart(0,0); + for(i=0; i < MODULE_COUNT; i++) + { + if( (i !='n'-'a') && (debug_shm_ptr->module_d[i].ascii_in_set_flag == 1)) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,str); + } + } +} + +void debug_netcap_stop() +{ + char str[] = "net cap stop"; + int i; + + NcStop(); + for(i=0; i < MODULE_COUNT; i++) + { + if( (i !='n'-'a') && (debug_shm_ptr->module_d[i].ascii_in_set_flag == 1)) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,str); + } + } +} + + +////////////////////////////////////Intial//////////////////////////// +/* +* +* Fun: debug_read_conf +* +* Desc: debug read conf +* +* Ret: void +* +* File: debug.c +* +*/ +void debug_read_conf () +{ + char file_name[32]; + char *p, *q, line[512]; + BYTE conf_flag = 0; + FILE *fp_conf; + DIR *pdir; + + strcpy ( file_name, "./conf/debug.conf" ); + + wxc2_debuginfo.mmi_switch = 0; //off + + if( ( pdir = opendir ( MIB_FILES_DIR ) ) == NULL && errno == ENOENT ) + { + return; + } + else + { + + closedir ( pdir ); + if( ( fp_conf = fopen ( file_name, "rw" ) ) == NULL ) + { + printf ( "[debug] Error: cannot open debug conf_file: [%s].\r\n", file_name ); + return; + } + } + + while ( !feof ( fp_conf ) ) + { + if( fgets ( line, 256, fp_conf ) == NULL ) + { + break; + } + line[128] = '\0'; + p = line; + while ( *p == ' ' ) + p++; + if( ( q = strstr ( p, "//" ) ) != NULL ) + *q = '\0'; + if( strstr ( p, "System Type" ) ) + { + p = p + 11; + if( ( p = strchr ( p, '=' ) ) && ( q = strchr ( p, ';' ) ) ) + { + p++; + *q = '\0'; + + if( strstr ( p, "CDMA" ) ) + { + wxc2_debuginfo.sys_type = 1; + conf_flag |= 0x01; + } + else if( strstr ( p, "GSM" ) ) + { + wxc2_debuginfo.sys_type = 2; + conf_flag |= 0x01; + } + else if( strstr ( p, "SSW" ) ) + { + wxc2_debuginfo.sys_type = 3; + conf_flag |= 0x01; + } + } + + } + else if( strstr ( p, "MMI Switch" ) ) + { + p = p + 10; + if( ( p = strchr ( p, '=' ) ) && ( q = strchr ( p, ';' ) ) ) + { + p++; + *q = '\0'; + + if( strstr ( p, "ON" ) || strstr ( p, "On" ) || strstr ( p, "on" ) ) + { + wxc2_debuginfo.mmi_switch = 1; + conf_flag |= 0x02; + } + else if( strstr ( p, "off" ) || strstr ( p, "Off" ) || strstr ( p, "OFF" ) ) + { + wxc2_debuginfo.mmi_switch = 0; + conf_flag |= 0x02; + } + } + + } + + } + fclose ( fp_conf ); + if( conf_flag != 0x03 ) + { + printf ( "[debug] Error: debug conf_file ([%s])is incorrect .\r\n", file_name ); + return; + } + return; + +} + +/* +* +* Fun: debug_init +* +* Desc: debug intial function +* +* Ret: void +* +* File: debug.c +* +*/ +extern void WxcDump(int nSigno); + +void debug_init() +{ + + + int i,j; + char temp_str[64]; + char file_name[64]; + FILE *fp_conf; + mib_node *sys_base_node; + +// signal(SIGSEGV, &WxcDump); + NcInit(); + + //heap_remark=calloc(sizeof(char),1024*300); + heap_remark=heap_work_buf; + heap_remark_index=0; + heap_remark_curr=heap_remark; + + for(i=0;ih_addr_list)); + sprintf(hostip_buf,"\x1b[22;10Hlocal ip: %s\x1b[22;35Hhost name: %s",host_ip,hostname); + Local_IP = ((struct in_addr *)(*host->h_addr_list))->s_addr; + Peer_IP[0] = Local_IP; + for(i=1; i<16; i++) + { + Peer_IP[i] = 0; + IP_Selected[i] = 1; + } + } + } + + + debug_counter = 0; + show_all_value=0; + show_type=0; + show_expend=1; + show_range=0; + get_show_state=0; + show_list=1; + + + + show_snmp_state=0; + list_once=0; + for(i=0;i<=255;i++) + { + curr_instance_arr[i].ins=i; + curr_instance_arr[i].eable=0; + } + for(i=0;i<64;i++) + { + list_field_arr[i]=0xFF; + } + list_flag=list_start=list_end=0; + debug_get_all_value = 0; + debug_cfg = 0; + debug_cfg_end = 1; + debug_log_all = 0; + debug_log_error_on = 0; + debug_module_num = 13; + t10s_flag = 0; + t5s_flag=0; + t100ms_flag = 0; + get_state = 0; + set_state = 0; + ip_num=0; + ip_index=0; + set_val = 0; + param_node = NULL; + bind_num=0; + + debug_heartbeat[0] = 3; + debug_heartbeat[1] = 3; + debug_heartbeat[2] = 2; + debug_heartbeat[3] = 1; //status 1-normal 0-abnormal + debug_heartbeat[4] = 0; //module count + debug_heartbeat[5] = 0; //sub module status + debug_heartbeat[6] = 0; //sub module status + debug_heartbeat[7] = 0; + first_page=1; + disp_main_flag = 0; //--lw + disp_main_page_num = 0; + treehost=1; //--lw + disp_sub_module_flag = 13; + disp_page_flag = 0; + m_state = 0; + command_flag = 0; + ascii_out_len = 0; + strcpy(test_array,""); + ascii_in_pt = 1; + ascii_out_ph = 0; + ascii_out_pt = 0; + title_top_pt = 0; + cursor_p[0] = 0x1b; + cursor_p[1] = '['; + cursor_p[4] = ';'; + cursor_p[7] = 'H'; + memset(comp_disp,0x80,500); + for(i = 0;i < MODULE_COUNT;i ++) + { + strcpy(debug_shm_ptr->module_d[i].name,""); + strcpy(debug_shm_ptr->module_d[i].status,""); + strcpy(debug_shm_ptr->module_d[i].version,""); + debug_shm_ptr->module_d[i].maxpage = 0; + debug_shm_ptr->module_d[i].ascii_in_set_flag = 0; + debug_shm_ptr->module_d[i].ascii_out_set_flag = 0; + debug_shm_ptr->module_d[i].ascii_in = NULL; + debug_shm_ptr->module_d[i].ascii_out = NULL; + for(j = 0;j < PAGE_COUNT;j ++) + { + strcpy(debug_shm_ptr->module_d[i].page_d[j].title,title_top); + debug_shm_ptr->module_d[i].page_d[j].pointer_set_flag = 0; + for (k = 0;k < LINE_COUNT;k ++) + { + debug_shm_ptr->module_d[i].page_d[j].line_d[k].length = 0; + debug_shm_ptr->module_d[i].page_d[j].line_d[k].pt_vartype = 0; + debug_shm_ptr->module_d[i].page_d[j].line_d[k].pointer = NULL; + } + } + debug_shm_ptr->module_d[i].seqid_h = 0; + debug_shm_ptr->module_d[i].seqid_t = 0; + for (j = 0;j < DEBUG_SEQID_LEN;j ++) + strcpy(debug_shm_ptr->module_d[i].omc_outbuf[j],""); + } + debug_shm_ptr->TelnetSendData.telsend_datah = 0; + memset(debug_shm_ptr->TelnetSendData.telsend_data,0,sizeof(BYTE)*TELNET_SEND_BUF_LEN); + memset(debug_snmp_agent_buf,0,8*sizeof(debug_snmp_agent)); + memset(&snmp_agent_packet,0,sizeof(debug_snmp_agent)); +} + +////////////////////////////End of Intial/////////////////////////////// + + + + + +////////////////////////////////////Main///////////////////////////// +/* +* +* Fun: debug_rt +* +* Desc: debug main function +* +* Ret: void +* +* File: debug.c +* +*/ +void debug_rt() +{ + register int jj,kk; + int ii; + int otherAsciiOutLen=0; + int localAsciiOutLen=0; + struct debug_module_struct *module_ptr; + //int i; + + + if(Init_Page) + { + if( disp_sub_module_flag == ('n' - 'a') ) // in debug_module + { + + //receive the ascii out buffer of debug module + module_ptr = (struct debug_module_struct *) &debug_shm_ptr->module_d['n'-'a']; + if (module_ptr->ascii_out_set_flag == 1) + { + if (debug_ascii_out_ph < debug_ascii_out_pt) + otherAsciiOutLen = MAX_ASCII_LEN - 1 + debug_ascii_out_ph - debug_ascii_out_pt; + else + otherAsciiOutLen = debug_ascii_out_ph - debug_ascii_out_pt; + + if (ascii_out_ph < ascii_out_pt) + localAsciiOutLen = MAX_ASCII_LEN - 1 + ascii_out_ph - ascii_out_pt; + else + localAsciiOutLen = ascii_out_ph - ascii_out_pt; + if ((otherAsciiOutLen > 0) && (otherAsciiOutLen+localAsciiOutLen < MAX_ASCII_LEN)) + { + kk = ascii_out_ph; + for (jj = 0;jj < otherAsciiOutLen;jj ++) + { + ascii_out_array[kk] = *(module_ptr->ascii_out+debug_ascii_out_pt); + kk = (kk + 1) % MAX_ASCII_LEN; + debug_ascii_out_pt=(debug_ascii_out_pt+1) % MAX_ASCII_LEN; + } + ascii_out_ph = kk % MAX_ASCII_LEN; + } + else if((localAsciiOutLen+MAX_SEND_CHAR_NUM 0)) + { + kk = ascii_out_ph; + for (jj = 0;jj < MAX_SEND_CHAR_NUM;jj ++) + { + ascii_out_array[kk] = *(module_ptr->ascii_out+debug_ascii_out_pt); + kk = (kk + 1) % MAX_ASCII_LEN; + debug_ascii_out_pt=(debug_ascii_out_pt+1) % MAX_ASCII_LEN; + } + ascii_out_ph = kk % MAX_ASCII_LEN; + } + + } + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 15 + //a b c d e f g h i j k l m n o p q r s t u v w x y z + //a b c d e f g h i j k l m n o p r s t u v w y z + if(debug_cfg == 0 && Init_Page==2) // in debug cmm status, receive the ascii out buffer of all the other modules + { + for(ii=0;ii< MODULE_COUNT;ii++) + { + if(ii=='l'-'a' || ii=='a'-'a') + continue; + module_ptr = (struct debug_module_struct *) &debug_shm_ptr->module_d[ii]; + if (module_ptr->ascii_out_set_flag == 1) + { + otherAsciiOutLen=strlen(module_ptr->ascii_out)+strlen(module_ptr->name)+5; + if (disp_sub_module_flag != ii) + { + + if (ascii_out_ph < ascii_out_pt) + localAsciiOutLen = MAX_ASCII_LEN - 1 + ascii_out_ph - ascii_out_pt; + else + localAsciiOutLen = ascii_out_ph - ascii_out_pt; + if ((otherAsciiOutLen > (strlen(module_ptr->name)+5)) && (otherAsciiOutLen+localAsciiOutLen < MAX_ASCII_LEN)) + { + + ascii_out_array[ascii_out_ph] = '\r'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + ascii_out_array[ascii_out_ph] = '\n'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + ascii_out_array[ascii_out_ph] = '['; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + for (jj = 0;jj < strlen(module_ptr->name);jj ++) + { + ascii_out_array[ascii_out_ph] = module_ptr->name[jj]; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + } + ascii_out_array[ascii_out_ph] = ']'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + ascii_out_array[ascii_out_ph] = ':'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + ascii_out_array[ascii_out_ph] = '\r'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + ascii_out_array[ascii_out_ph] = '\n'; + ascii_out_ph = (ascii_out_ph + 1) % MAX_ASCII_LEN; + + kk = ascii_out_ph; + for (jj = 0;jj < otherAsciiOutLen;jj ++) + { + ascii_out_array[kk] = module_ptr->ascii_out[jj]; + module_ptr->ascii_out[jj] = '\0'; + kk = (kk + 1) % MAX_ASCII_LEN; + } + ascii_out_ph = kk % MAX_ASCII_LEN; + } + } + } + + } + } + } + else + { + for (ii = 0;ii < MODULE_COUNT;ii ++) // not in debug_module + { + module_ptr = (struct debug_module_struct *) &debug_shm_ptr->module_d[ii]; + if (module_ptr->ascii_out_set_flag == 1) + { + otherAsciiOutLen = strlen(module_ptr->ascii_out); + if (disp_sub_module_flag == ii) + { + if (ascii_out_ph < ascii_out_pt) + localAsciiOutLen = MAX_ASCII_LEN - 1 + ascii_out_ph - ascii_out_pt; + else + localAsciiOutLen = ascii_out_ph - ascii_out_pt; + if ((otherAsciiOutLen > 0) && (otherAsciiOutLen+localAsciiOutLen < MAX_ASCII_LEN)) + { + kk = ascii_out_ph; + for (jj = 0;jj < otherAsciiOutLen;jj ++) + { + ascii_out_array[kk] = module_ptr->ascii_out[jj]; + module_ptr->ascii_out[jj] = '\0'; + kk = (kk + 1) % MAX_ASCII_LEN; + } + ascii_out_ph = kk % MAX_ASCII_LEN; + } + } + if ((otherAsciiOutLen > 0) && (otherAsciiOutLen < DEBUG_OMCBUF_LEN-1)) + { + ii = module_ptr->seqid_h % DEBUG_SEQID_LEN; + strcpy(module_ptr->omc_outbuf[ii],module_ptr->ascii_out); + if (((module_ptr->seqid_h+1)%DEBUG_SEQID_LEN) == (module_ptr->seqid_t%DEBUG_SEQID_LEN)) + if (disp_sub_module_flag == ii) + module_ptr->seqid_t = (module_ptr->seqid_t+1) % DEBUG_MAX_SEQID; + module_ptr->seqid_h = (module_ptr->seqid_h+1) % DEBUG_MAX_SEQID; + for (jj = 0;jj < otherAsciiOutLen;jj ++) + module_ptr->ascii_out[jj] = '\0'; + } + } + } + } + } + //else + // debug_mmi_log("none"); + + + // in debug_module, in the configure state, not in command mode, and there is nothing to send by serial, there is nothing received, + if ( (disp_sub_module_flag == ('n'-'a')) && (debug_cfg > 0) && (command_flag == 0) && (ascii_out_ph == ascii_out_pt) && (sendserbuf_h == sendserbuf_t) && (recserbuf_h == recserbuf_t) && (debug_cfg_end == 1) ) + { + recser_buf[recserbuf_h] = 27; // set the debug module in command mode + recserbuf_h = (recserbuf_h + 1) % SERIAL_BUF_LEN; + + } + if((disp_main_flag==0) && (first_page==1) && (command_flag == 0) && (ascii_out_ph == ascii_out_pt) && (sendserbuf_h == sendserbuf_t) && (recserbuf_h == recserbuf_t) ) + { + recser_buf[recserbuf_h] ='n'; // set the debug module in command mode + recserbuf_h = (recserbuf_h + 1) % SERIAL_BUF_LEN; + first_page = 0; + } + debug_read_serial(); + + for (ii = 0;ii < MAX_SEND_CHAR_NUM ;ii ++) + { + debug_recv_cmd(); + if(send_char_flag) + { + send_char_flag=0; + break; + } + debug_module_page(ii); + } + + debug_send_serial(); + + if(disp_sub_module_flag == ('n'-'a')) + debug_ascii_in_cmd_handle(); // handle the ascii command of the debug module + for(ii = 0;ii < 20;ii ++) + test_array[ii] = test_array[ii] + 1; + if ((t10s_flag++) >= 500) + { + t10s_flag = 0; + debug_heartbeat[4] = debug_counter; + set_status(5,7,debug_heartbeat); + } + if( wxc2_debuginfo.mmi_switch ) + { + if((t100ms_flag++) >= 1)//20 ms + { + t100ms_flag=0; + if(get_show_state==0 && list_flag==0) + { + show_all_value=0; + show_type=0; + show_expend=1; + show_range=0; + show_empty=0; + show_snmp_state=0; + } + if(t5s_flag > 250) + t5s_flag=0; + else + t5s_flag++; + debug_get_agent(); + debug_set_agent(); + //if((field_compute_state>0) && print_once==1) + // compute_field_WatchDog(); + + debug_snmp_get_rt(); // get command state machine + + debug_snmp_set_rt(); // set command state machine + if(list_flag>0 ) //&& debug_cfg_end==0 && debug_cfg==1) + { + debug_mmi_list(); + } + if(debug_remark_flag>0) + debug_mmi_remark(); + } + } + +} +//////////////////////////////End of Main//////////////////////////////// + + + + + +////////////////////////////////////Shell/////////////////////////// +/* +* +* Fun: debug_ascii_in_cmd_handle +* +* Desc: handle the command in the debug_ascii_in_array and clear the debug_ascii_in_array +* +* Ret: REVOID +* +* File: debug.c +* +*/ +void debug_ascii_in_cmd_handle() +{ + BYTE cmd_valid, i; + char temp_str[256]=""; + BYTE index_len; + mib_node *find_node_ptr ; + /* + for(i=0;i<80;i++) + { + if(*(debug_ascii_in_array+i)!=' ') + for(j=i;j<80;j++) + debug_ascii_in_array[j]=debug_ascii_in_array[j+1]; + } + */ + if(snmp_agent_flag>0 && debug_cfg>0 && *debug_ascii_in_array!=0) + { + if(!debug_busy_alarm) + { + debug_ascii_out_proc("Busy : Busy now,Debug is working for ews now!\r\n"); + debug_ascii_in_array[0]='\0'; + } + debug_busy_alarm=1; + return; + }else if(snmp_agent_flag==0) + debug_busy_alarm=0; + StrToLower( debug_ascii_in_array +1 ); + if ( *debug_ascii_in_array) + { + cmd_valid = 1; + debug_ascii_in_array[79] = '\0'; + if(debug_cfg == 0) + { + if(debug_module_num != 13) + { + if(strncasecmp(debug_ascii_in_array+1, "DEBUG", 5) == 0) + { + debug_module_num= 13; + debug_shm_ptr->module_d[13].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[13].ascii_in+1, "help"); + debug_color_out(BRIGHT,WHITE,BLACK,"\r\nOK\r\n");/// + return; + } + else + { + i = debug_module_num; + if(debug_shm_ptr->module_d[i].ascii_in_set_flag != 1) + { + sprintf(temp_str, "The module %s did not register\r\nFail\r\n", debug_shm_ptr->module_d[i].name);/// + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return; + } + else + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,debug_ascii_in_array+1); + strcpy(temp_str,"OK!\r\n"); + debug_color_out(BRIGHT,WHITE,BLACK,temp_str); + strcpy(debug_ascii_in_array, ""); + } + return; + } + } + + for (i=0; i < MODULE_COUNT; i++) + { + if(debug_shm_ptr->module_d[i].ascii_in_set_flag == 1) + { + char module_name[10] , *chpos; + int len = strlen(debug_shm_ptr->module_d[i].name) ; + + + if( len == 0 || len > 8 ) + continue; + strcpy( module_name , debug_shm_ptr->module_d[i].name ); + StrToLower( module_name ); + if( strstr( debug_ascii_in_array+1, module_name ) != NULL ) + { + if( ( ( chpos = strstr( debug_ascii_in_array+1 , "log all" ) ) != NULL ) + ||( ( chpos = strstr( debug_ascii_in_array+1 , "log none" )) != NULL ) + ||( ( chpos = strstr( debug_ascii_in_array+1 , "log error" )) != NULL ) + ||( ( chpos = strstr( debug_ascii_in_array+1 , "log status" )) != NULL ) ) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,chpos ); + strcpy(temp_str,"OK!\r\n"); + debug_color_out(BRIGHT,WHITE,BLACK,temp_str); + cmd_valid = 5; + continue; + } + else + { + if(strlen(debug_ascii_in_array) > (2+strlen(debug_shm_ptr->module_d[i].name))) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,debug_ascii_in_array+2+strlen(debug_shm_ptr->module_d[i].name)); + strcpy(temp_str,"OK!\r\n"); + debug_color_out(BRIGHT,WHITE,BLACK,temp_str); + strcpy(debug_ascii_in_array, ""); + debug_module_num = 13; + } + else + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1, "help"); + strcpy(temp_str,"OK!\r\n"); + debug_color_out(BRIGHT,WHITE,BLACK,temp_str); + strcpy(debug_ascii_in_array, ""); + debug_module_num = i; + } + return; + } + } + } + } + if( cmd_valid == 5 ) + { + strcpy(debug_ascii_in_array, ""); + return; + } + if (strncasecmp(debug_ascii_in_array+1,"help",4) == 0) + { + debug_mmi_cmm_help(debug_ascii_in_array+5); + + } + else if (strncasecmp(debug_ascii_in_array+1,"log status",10) == 0) + { + debug_mmi_log_status(); + } + else if( strncasecmp(debug_ascii_in_array+ 1 , "net cap start" ,13) == 0) + { + int ip; + char tmpStr[512]; + + strcpy( tmpStr , debug_ascii_in_array+14); + StrTrimCh(tmpStr, ' '); + ip = inet_addr(tmpStr); + if( -1 == ip ) + { + sprintf(tmpStr , "invalid Ip Addr : %s ", debug_ascii_in_array+14); + debug_color_out(BRIGHT,RED,BLACK,tmpStr); + cmd_valid = 2; + } + NcSetIP(ip); + debug_netcap_start(); + debug_color_out(BRIGHT,RED,BLACK,"net cap start!\r\n"); + } + else if( strncasecmp(debug_ascii_in_array+ 1 , "ne tcap stop" ,12)== 0) + { + debug_netcap_stop(); + debug_color_out(BRIGHT,RED,BLACK,"net cap stop!\r\n"); + } + else if (strncasecmp(debug_ascii_in_array+1,"log ",4) == 0) + { + if( debug_mmi_log(debug_ascii_in_array+5) == 0) + cmd_valid = 2; + }else if(strncasecmp(debug_ascii_in_array+1, "cfg", 3) == 0) + { + if( !wxc2_debuginfo.mmi_switch ) + { + debug_ascii_out_proc("[debug] : The debug MMI is not configurated!\r\n"); + cmd_valid = 3; + } + else + { + strcpy(temp_str, "log none"); + debug_log_all = 0; + for (i=0; i < MODULE_COUNT; i++) + { + if( (i != 13) && (debug_shm_ptr->module_d[i].ascii_in_set_flag == 1)) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,temp_str); + } + } + debug_cfg = 1; + debug_cfg_end = 1; + debug_mmi_cfg_help(" "); + index_len=9; + find_node_ptr = search_mib_node(mib_root_node, cur_oid, index_len); + if(find_node_ptr) + mib_curr_node = find_node_ptr; + else + { + debug_ascii_out_proc("[debug] : The debug can not find the system node!\r\n"); + return; + } + } + } + else if(strncasecmp(debug_ascii_in_array+1, "menu", 4) == 0) + { + if( !wxc2_debuginfo.mmi_switch ) + { + debug_ascii_out_proc("[debug] : The debug MMI is not configurated!\r\n"); + cmd_valid = 3; + } + else + { + menu_curr_node=menu_root_node; + mib_curr_node=menu_curr_node->menu_oid_node; + main_menu(""); + debug_cfg = 2; + debug_cfg_end = 1 ; + } + } + + else + cmd_valid = 2;//Err + } + else if(debug_cfg == 1 ) + { + if (strncasecmp(debug_ascii_in_array+1,"contents",8) == 0) + { + debug_mmi_contents(debug_ascii_in_array+9); + } + else if (strncasecmp(debug_ascii_in_array+1,"parent",6) == 0) + { + debug_mmi_parent(); + } + else if (strncasecmp(debug_ascii_in_array+1,"quit",4) == 0) + { + debug_send_char('q'); + } + else if (strncasecmp(debug_ascii_in_array+1,"child ", 6) == 0) + { + debug_mmi_child(debug_ascii_in_array+7); + } + else if (strncasecmp(debug_ascii_in_array+1,"create", 6) == 0) + { + debug_mmi_create(debug_ascii_in_array+7); + } + else if (strncmp(debug_ascii_in_array+1,"delete",6) == 0) + { + debug_mmi_del(debug_ascii_in_array+7); + } + else if (strncasecmp(debug_ascii_in_array+1,"list", 4) == 0) + { + list_flag=1; + strcpy(list_msg,debug_ascii_in_array+5); + debug_cfg_end=0; + } + else if (strncasecmp(debug_ascii_in_array+1,"save",4) == 0) + { + save_flag=2; + debug_mmi_save(); + } + else if (strncasecmp(debug_ascii_in_array+1,"option ", 7) == 0) + { + debug_mmi_option(debug_ascii_in_array+8); + } + else if (strncasecmp(debug_ascii_in_array+1,"setins ", 7) == 0) + { + debug_mmi_setins(debug_ascii_in_array+8); + } + else if (strncasecmp(debug_ascii_in_array+1,"set", 3) == 0) + { + if(debug_mmi_set(debug_ascii_in_array+4) == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + else if (strncasecmp(debug_ascii_in_array+1,"get ", 4) == 0) + { + if(debug_mmi_get(debug_ascii_in_array+5) == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + else if (strncasecmp(debug_ascii_in_array+1,"get", 3) == 0) + { + if(debug_ascii_in_array[4] != '\0') + { + cmd_valid = 2; //fail + debug_cfg_end = 1; + } + else if(debug_mmi_get_all() == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + else if (strcmp(debug_ascii_in_array+1,"pwd") == 0) + { + debug_mmi_pwd(); + } + else if (strncasecmp(debug_ascii_in_array+1,"tree", 4) == 0) + { + /*BYTE node_layer; + if(isdigit(debug_ascii_in_array+5)) + node_layer=(BYTE)(debug_ascii_in_array+5); + */ + debug_mmi_tree(mib_curr_node, "{*}--", 3); + treehost=1; + } + else if (strncasecmp(debug_ascii_in_array+1,"cd", 2) == 0) + { + debug_mmi_cd(debug_ascii_in_array+3); + } + /*else if (strncasecmp(debug_ascii_in_array+1,"ip ", 3) == 0) + { + if( debug_mmi_ip(debug_ascii_in_array+4) == 0) + cmd_valid = 3; //Fail + }*/ + else if (strncasecmp(debug_ascii_in_array+1,"find host", 9) == 0) + { + debug_mmi_find_host(debug_ascii_in_array+10); + debug_mmi_show_host(); + } + else if (strncasecmp(debug_ascii_in_array+1,"show host", 9) == 0) + { + if( debug_mmi_show_host() ==0) + cmd_valid = 3; //Fail + } + else if (strncasecmp(debug_ascii_in_array+1,"select", 6) == 0) + { + if( debug_mmi_select_host(debug_ascii_in_array+7) ==0) + cmd_valid = 3; //Fail + else + debug_mmi_show_host(); + } + else if (strncasecmp(debug_ascii_in_array+1,"help",4) == 0) + { + debug_mmi_cfg_help(debug_ascii_in_array+5); + } + else if (strcmp(debug_ascii_in_array+1,"pwd") == 0) + { + debug_mmi_pwd(); + } + else if(strcmp(debug_ascii_in_array+1,"remark") == 0) + { + debug_remark_flag=1; + debug_cfg_end=0; + } + else if(strcmp(debug_ascii_in_array+1, "cmm")==0) + { + + debug_cfg = 0; + debug_cfg_end = 1; + debug_mmi_cmm_help(" "); + } + else + { + cmd_valid = 2; //Err + } + } + else if(debug_cfg==2) + { + if (strncasecmp(debug_ascii_in_array+1,"contents",8) == 0) + { + debug_mmi_view(); + //debug_cfg_end=1; + } + else if (strncasecmp(debug_ascii_in_array+1,"cd",2) == 0) + { + debug_mmi_mcd(debug_ascii_in_array+3); + debug_cfg_end=1; + } + else if(strcmp(debug_ascii_in_array+1,"remark") == 0) + { + debug_remark_flag=1; + debug_cfg_end=0; + } + else if (strncasecmp(debug_ascii_in_array+1,"child",5) == 0) + { + debug_mmi_mcd(debug_ascii_in_array+6); + debug_cfg_end=1; + } + else if (strncasecmp(debug_ascii_in_array+1,"quit",4) == 0) + { + debug_send_char('q'); + } + else if (strncasecmp(debug_ascii_in_array+1,"create", 6) == 0) + { + debug_mmi_create(debug_ascii_in_array+7); + } + else if (strncmp(debug_ascii_in_array+1,"delete",6) == 0) + { + debug_mmi_del(debug_ascii_in_array+7); + } + else if (strncasecmp(debug_ascii_in_array+1,"list", 4) == 0) + { + list_flag=1; + strcpy(list_msg,debug_ascii_in_array+5); + debug_cfg_end=0; + } + else if (strncasecmp(debug_ascii_in_array+1,"save",4) == 0) + { + save_flag=2; + debug_mmi_save(); + } + else if (strncasecmp(debug_ascii_in_array+1,"option ", 7) == 0) + { + debug_mmi_option(debug_ascii_in_array+8); + } + else if (strncasecmp(debug_ascii_in_array+1,"setins ", 7) == 0) + { + debug_mmi_setins(debug_ascii_in_array+8); + } + else if (strncasecmp(debug_ascii_in_array+1,"set", 3) == 0) + { + if(debug_mmi_set(debug_ascii_in_array+4) == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + else if (strncasecmp(debug_ascii_in_array+1,"get ", 4) == 0) + { + if(debug_mmi_get(debug_ascii_in_array+5) == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + else if (strncasecmp(debug_ascii_in_array+1,"get", 3) == 0) + { + if(debug_ascii_in_array[4] != '\0') + { + cmd_valid = 2; //fail + debug_cfg_end = 1; + } + else if(debug_mmi_get_all() == 0) + { + cmd_valid = 3; //fail + debug_cfg_end = 1; + } + else + { + debug_cfg_end = 0; + cmd_valid = 4; //wait + } + } + /*else if (strcmp(debug_ascii_in_array+1,"pwd") == 0) + { + debug_mmi_pwd(); + } + else if (strncasecmp(debug_ascii_in_array+1,"tree", 4) == 0) + { + BYTE node_layer; + if(isdigit(debug_ascii_in_array+5)) + node_layer=(BYTE)(debug_ascii_in_array+5); + + debug_mmi_tree(mib_curr_node, "{*}--", 3); + treehost=1; + } + */ + else if (strncasecmp(debug_ascii_in_array+1,"find host", 9) == 0) + { + debug_mmi_find_host(debug_ascii_in_array+10); + debug_mmi_show_host(); + } + else if (strncasecmp(debug_ascii_in_array+1,"show host", 9) == 0) + { + if( debug_mmi_show_host() ==0) + cmd_valid = 3; //Fail + } + else if (strncasecmp(debug_ascii_in_array+1,"select", 6) == 0) + { + if( debug_mmi_select_host(debug_ascii_in_array+7) ==0) + cmd_valid = 3; //Fail + else + debug_mmi_show_host(); + } + else if (strncasecmp(debug_ascii_in_array+1,"help",4) == 0) + { + main_menu(debug_ascii_in_array+5); + } + /* + else if(strcmp(debug_ascii_in_array+1,"remark") == 0) + { + debug_mmi_remark(); + }*/ + else if(strcmp(debug_ascii_in_array+1, "cmm")==0) + { + + debug_cfg = 0; + debug_cfg_end = 1; + debug_mmi_cmm_help(" "); + } + else + { + cmd_valid = 2; //Err + } + } + + if (cmd_valid == 1) + { + // debug_color_out(BRIGHT,WHITE,BLACK,"OK!\r\n"); + } + else if(cmd_valid == 3)//Fail + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : Command excute fail!\r\n"); + } + else if(cmd_valid == 2) + { + sprintf(temp_str, "Error : Incorrect command: %s\r\n",debug_ascii_in_array); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + } + strcpy(debug_ascii_in_array, ""); + } +} // end of debug_ascii_in_cmd_handle +///////////////////////////////End of Shell////////////////////////////// + + + + + +//////////////////////////////////buffer process///////////////////// +/* +* +* Fun: debug_ascii_out_porc +* +* Desc: store the string into the out buffer,print in the telnet or pc serial port +* +* Ret: REVOID + +* File: debug.c +* +*/ + +void debug_ascii_out_proc(const char *str_ptr) +{ + int str_len,local_len; + str_len=strlen(str_ptr); + if (debug_ascii_out_ph < debug_ascii_out_pt) + local_len = MAX_ASCII_LEN - 1 + debug_ascii_out_ph - debug_ascii_out_pt;/// + else + local_len = debug_ascii_out_ph - debug_ascii_out_pt; + if( str_len>0 && (local_len + str_len) < (MAX_ASCII_LEN)) + { + while((*(debug_ascii_out_array+debug_ascii_out_ph)=*str_ptr++)) + debug_ascii_out_ph=(debug_ascii_out_ph+1)%MAX_ASCII_LEN; + } +} // debug_ascii_out_proc + +/* +void debug_ascii_out_proc(char *str_ptr) +{ + if( (strlen(debug_ascii_out_array) + strlen(str_ptr)) < (MAX_ASCII_LEN)) + strcat(debug_ascii_out_array, str_ptr); +} // debug_ascii_out_proc +*/ +/////////////////////////////////End of buffer process/////////////////////// + + + + + + + +////////////////////////////////page 0////////////////////////////// +/* +* +* Fun: debug_change_title1 +* +* Desc: show module page form module_page.txt(page=0) +* +* Ret: REVOID +* File: debug.c +* +*/ +void debug_read_main_title() +{ + FILE *fp; + int i,j,k; + int row; + char *temp_ch; + char temp_str[256]; + char top[9]="\0",tail[6]="\0",/*add_help[6]="\0",*/add_menu[6]="\0"; + char title_row[MAX_ROW][MAX_COLUMN]; + + top[0] = 0xc; + top[1] = 0x1b; + top[2] = '['; + top[3] = 'H'; + top[4] = 0x1b; + top[5] = '['; + top[6] = '2'; + top[7] = 'J'; + top[8] = '\0'; + tail[0] = 0x1b; + tail[1] = '['; + tail[2] = '0'; + tail[3] = 'm'; + tail[4] = '%'; + tail[5] = '\0'; + + //page 0 + row = 0; + if ((fp = fopen("./conf/menu_page","r")) == NULL) + { + printf("[debug] Cannot open file [menu_page].\n"); + return; + } + for (i = 0;i < MAX_ROW; i++) + { + if (feof(fp)) + break; + temp_str[0] = '\0'; + fgets(temp_str,256,fp); + if (temp_str[0] == '$') + break; + temp_ch = strchr(temp_str,0xa); + if (temp_ch != NULL) + *temp_ch = '\0'; + strcpy(title_row[row++],temp_str); + } + fclose(fp); + strcpy(title1,top); + add_menu[0] = 0x1b; + add_menu[1] = '['; + for (i = 0;i < row;i ++) + { + for (j = 0;j < PAGE_MODULE_COUNT;j ++) + { + int alph_num = j; + if( j >=22 ) alph_num = j + 2; + if( j > 15 && j < 22 ) alph_num = j + 1; + sprintf(temp_str,"%c -- ",'a'+alph_num); + temp_ch = strstr(title_row[i],temp_str); + if (temp_ch != NULL) + { + temp_ch = temp_ch + strlen(temp_str); + for (k = 0;k < DEBUG_NAME_LEN - 1;k ++) + { + if (isalpha(temp_ch[k]) || isdigit(temp_ch[k])) + debug_shm_ptr->module_d[j].name[k] = temp_ch[k]; + else + break; + } + debug_shm_ptr->module_d[j].name[k] = '\0'; + } + } + if (i < 10) + { + add_menu[2] = i+'0'; + add_menu[3] = 'H'; + add_menu[4] = '\0'; + } + else + { + add_menu[2] = i/10+'0'; + add_menu[3] = i%10+'0'; + add_menu[4] = 'H'; + add_menu[5] = '\0'; + } + strcat(title1,add_menu); + strcat(title1,title_row[i]); + } + + //page 1 + row = 0; + memset(title_row,0,MAX_ROW*MAX_COLUMN); + if ((fp = fopen("./conf/menu_page2","r")) == NULL) + { + printf("[debug] Cannot open file [menu_page].\n"); + return; + } + for (i = 0;i < MAX_ROW; i++) + { + if (feof(fp)) + break; + temp_str[0] = '\0'; + fgets(temp_str,256,fp); + if (temp_str[0] == '$') + break; + temp_ch = strchr(temp_str,0xa); + if (temp_ch != NULL) + *temp_ch = '\0'; + strcpy(title_row[row++],temp_str); + } + fclose(fp); + strcpy(title1+TITLE_CHAR,top); + add_menu[0] = 0x1b; + add_menu[1] = '['; + for (i = 0;i < row;i ++) + { + for (j = 0;j < PAGE_MODULE_COUNT;j ++) + { + int alph_num = j; + if( j >=22 ) alph_num = j + 2; + if( j > 15 && j < 22 ) alph_num = j + 1; + sprintf(temp_str,"%c -- ",'a'+alph_num); + temp_ch = strstr(title_row[i],temp_str); + if (temp_ch != NULL) + { + temp_ch = temp_ch + strlen(temp_str); + for (k = 0;k < DEBUG_NAME_LEN - 1;k ++) + { + if (isalpha(temp_ch[k]) || isdigit(temp_ch[k])) + debug_shm_ptr->module_d[j+PAGE_MODULE_COUNT].name[k] = temp_ch[k]; + else + break; + } + debug_shm_ptr->module_d[j+PAGE_MODULE_COUNT].name[k] = '\0'; + } + } + if (i < 10) + { + add_menu[2] = i+'0'; + add_menu[3] = 'H'; + add_menu[4] = '\0'; + } + else + { + add_menu[2] = i/10+'0'; + add_menu[3] = i%10+'0'; + add_menu[4] = 'H'; + add_menu[5] = '\0'; + } + strcat(title1+TITLE_CHAR,add_menu); + strcat(title1+TITLE_CHAR,title_row[i]); + } +} + +/* +* +* Fun: debug_change_title1 +* +* Desc: Add String to module page(page=0) +* +* Ret: REVOID + +* File: debug.c +* +*/ +void debug_change_title1() +{ + char ch_tmp1[14]="\0"; + int i; + DWORD title_len; + char tail[6] = "\0"; + char menu_line[TITLE_CHAR] = "\0"; + + if(disp_main_page_num >=DEBUG_MAX_PAGE) + { + return; + } + title_len=strlen(title1+TITLE_CHAR*disp_main_page_num); + if (title_len < TITLE_CHAR) + strcpy(title1_show+TITLE_CHAR*disp_main_page_num,title1+TITLE_CHAR*disp_main_page_num); + + sprintf(menu_line,"\x1b[20;20H*** %s ***\x1b[16;4H\r\n",wxc2_debuginfo.wxc2_ver); + //In current page, press 'a--p' or 'A--P' to enter selected sub module",wxc2_debuginfo.wxc2_ver); + //sprintf(menu_line+strlen(menu_line),"\x1b[17;4HIn sub module, press '0--9' and 'a--f' to turn over pages"); + //sprintf(menu_line+strlen(menu_line),"\x1b[18;4HIn sub module, press 'x' or 'X' to return menu page"); + sprintf(menu_line+strlen(menu_line),"\x1b[24;25Hsystem start time:%s\x1b[25;1Hr -- refresh\x1b[22;60H%d/%d",time_buf,disp_main_page_num+1,DEBUG_MAX_PAGE); + tail[0] = 0x1b; + tail[1] = '['; + tail[2] = '0'; + tail[3] = 'm'; + tail[4] = '%'; + tail[5] = '\0'; + for (i = 0;i < PAGE_MODULE_COUNT;i ++) + { + if (debug_shm_ptr->module_d[i+disp_main_page_num*PAGE_MODULE_COUNT].status[0] == 1) + { + ch_tmp1[0] = 0x1b; + ch_tmp1[1] = '['; + if (i < PAGE_MODULE_COUNT/2) + { + ch_tmp1[2] = (i+5)/10 + '0'; + ch_tmp1[3] = (i+5)%10 + '0'; + } + else + { + ch_tmp1[2] = (i+5-PAGE_MODULE_COUNT/2)/10 + '0'; + ch_tmp1[3] = (i+5-PAGE_MODULE_COUNT/2)%10 + '0'; + } + ch_tmp1[4] = ';'; + if(i < PAGE_MODULE_COUNT/2) + ch_tmp1[5] = '2'; + else + ch_tmp1[5] = '5'; + ch_tmp1[6] = '6'; + ch_tmp1[7] = 'H'; + ch_tmp1[8] = '('; + ch_tmp1[9] = '\0'; + if ((title_len+strlen(ch_tmp1)) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,ch_tmp1); + if ((title_len+strlen(debug_shm_ptr->module_d[i+disp_main_page_num*PAGE_MODULE_COUNT].version)) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,debug_shm_ptr->module_d[i+disp_main_page_num*PAGE_MODULE_COUNT].version); + if ((title_len+1) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,")"); + } + } + if (title_len+strlen(hostip_buf) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,hostip_buf); + if (title_len+strlen(menu_line) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,menu_line); + if (title_len+strlen(tail) < TITLE_CHAR) + strpcat(title1_show+TITLE_CHAR*disp_main_page_num,&title_len,tail); + + title_pt = TITLE_CHAR*disp_main_page_num; + memset(current_timer,0,sizeof(current_timer)); +} +////////////////////////////End of Page 0////////////////////////////// + + + + + +////////////////////////////////Module Page///////////////////////// +int debug_set_response(BYTE oidlen,DWORD *oid,BYTE *data_ptr,WORD data_len) +{ + WORD temp_len; + BYTE temp_id,temp_page; + BYTE ch_m = 0x80; + WORD title_len = 0; + BYTE cancel_control[] = {0x1b,'[','0','m','%','\0'}; + + switch(oid[12]) + { + case 0: + break; + case 1: + break; + case 2: // configure + if (oid[13] > MODULE_COUNT+1 || oid[13] < 2) + return -1; + temp_id = oid[13] - 2; + if( debug_shm_ptr == NULL ) + { + // printf("Wanning : Debug is not init! Here register your module to debug share memery would fail!\r\n"); + // printf(" Please make assure that you function is need to inital debug or not!\r\n"); + return -1; + } + //printf("Module ID: %d regiseted! oid[14] :%ld\n", temp_id, oid[14]); + switch(oid[14]) + { + case 1: // status + if (data_len != 1) + return -1; + debug_shm_ptr->module_d[temp_id].status[0] = *data_ptr; + debug_counter += 1; + if (temp_id <= 7) + debug_heartbeat[5] |= (ch_m >> temp_id); + else + debug_heartbeat[6] |= (ch_m >> (temp_id - 8)); + ch_m = 0x80; + return 1; + break; + case 2: // module version + if (data_len > 20) + return -1; + memcpy(debug_shm_ptr->module_d[temp_id].version,data_ptr,data_len); + debug_shm_ptr->module_d[temp_id].version[data_len] = '\0'; + return strlen(debug_shm_ptr->module_d[temp_id].version); + break; + case 3: // ascii in buffer + debug_shm_ptr->module_d[temp_id].ascii_in = data_ptr; + debug_shm_ptr->module_d[temp_id].ascii_in_set_flag = 1; + return data_len; + break; + case 4: // ascii out buffer + ascii_out_len = (data_len < strlen(data_ptr))?data_len:strlen(data_ptr); + *(data_ptr+ascii_out_len) = '\0'; + debug_shm_ptr->module_d[temp_id].ascii_out = data_ptr; + debug_shm_ptr->module_d[temp_id].ascii_out_set_flag = 1; + return ascii_out_len; + break; + default: // display page 0 -- 15 + if (oid[14] > 20) + return -1; + temp_page = oid[14] - 5; + if (temp_page == 0) // do not fill page 0 + return -1; + switch(oid[15]) + { + case 0: + break; + case 1: // title + title_len = (data_len < strlen(data_ptr))?data_len:strlen(data_ptr); + if (title_len > TITLE_CHAR - 8) + break; + data_ptr[title_len] = '\0'; + strcpy(debug_shm_ptr->module_d[temp_id].page_d[temp_page].title,title_top); + strcat(debug_shm_ptr->module_d[temp_id].page_d[temp_page].title,data_ptr); + temp_len = strlen(debug_shm_ptr->module_d[temp_id].page_d[temp_page].title); + if (temp_len+strlen(cancel_control) < TITLE_CHAR) + debug_shm_ptr->module_d[temp_id].page_d[temp_page].title[temp_len] = '\0'; + if (temp_len+strlen(cancel_control) < TITLE_CHAR) + strcat(debug_shm_ptr->module_d[temp_id].page_d[temp_page].title,cancel_control); + return title_len; + break; + default: // line + if (oid[15] > MAX_ROW || oid[15] < 2) + return -1; + switch(oid[16]) + { + case 0: + break; + case 1: + debug_shm_ptr->module_d[temp_id].page_d[temp_page].line_d[oid[15]-2].pt_vartype = *data_ptr; + break; + case 2: + if (data_len <= 20) + debug_shm_ptr->module_d[temp_id].page_d[temp_page].line_d[oid[15]-2].length = data_len; + else + debug_shm_ptr->module_d[temp_id].page_d[temp_page].line_d[oid[15]-2].length = 20; + debug_shm_ptr->module_d[temp_id].page_d[temp_page].line_d[oid[15]-2].pointer = data_ptr; + debug_shm_ptr->module_d[temp_id].page_d[temp_page].pointer_set_flag = 1; + if (debug_shm_ptr->module_d[temp_id].maxpage < temp_page) + debug_shm_ptr->module_d[temp_id].maxpage = temp_page; + return data_len; + break; + default: + break; + } + break; + } + break; + } + break; + case 3: + break; + default: + break; + } + return -1; +} + + +/* +* +* Fun: debug_module_page +* +* Desc: set debug page(page>0) +* +* Ret: REVOID +* File: debug.c +* +*/ +void debug_module_page(int count) +{ + if (command_flag == 1) + return; + switch (disp_main_flag) + { + case 0: + switch(m_state) + { + case 0: + m_state = 1; + debug_change_title1(); + if(count>=1) + send_char_flag=1; + break; + case 1: + if (title1_show[title_pt] != '%') + { + if (debug_send_char(title1_show[title_pt])) + title_pt++; + } + else + { + debug_set_currenttime(); + SendTelnetFlag = 1; + send_char_flag=1; + } + break; + } + break; + case 1: // module flag + switch(m_state_sub_module) + { + case 0: + title_top_pt = 0; + m_state_sub_module = 1; + break; + case 1: + if (disp_page_flag == 0) + { + debug_send_string(title_top); + SendTelnetFlag = 1; + m_state_sub_module = 2; + ascii_out_ph = ascii_out_pt = 0; + send_char_flag=1; + } + else + { + m_state_sub_module = 3; + title_sub_module_pt = 0; + } + break; + case 2: // send page 0 + if (ascii_out_pt != ascii_out_ph) + { + debug_send_char(ascii_out_array[ascii_out_pt]); + ascii_out_pt = (ascii_out_pt + 1) % MAX_ASCII_LEN; + if (ascii_out_pt == ascii_out_ph) + SendTelnetFlag = 1; + } + else + send_char_flag=1; + break; + case 3: // title + if (disp_page_flag > debug_shm_ptr->module_d[disp_sub_module_flag].maxpage) + return; + if (debug_shm_ptr->module_d[disp_sub_module_flag].page_d[disp_page_flag].title[title_sub_module_pt] == '%') + { + SendTelnetFlag = 1; + m_state_sub_module = 4; + disp_index = 0; + memset(comp_disp,0xeb,500); + } + else if (debug_send_char(debug_shm_ptr->module_d[disp_sub_module_flag].page_d[disp_page_flag].title[title_sub_module_pt])) + title_sub_module_pt = (title_sub_module_pt+1)%TITLE_CHAR; + //if(count>=3) + // send_char_flag=1; + break; + case 4: + char_ptr = 0; + hex_state = 0; + disp_length = debug_shm_ptr->module_d[disp_sub_module_flag].page_d[disp_page_flag].line_d[disp_index].length; + if (debug_shm_ptr->module_d[disp_sub_module_flag].page_d[disp_page_flag].pointer_set_flag == 1) + m_state_sub_module = 5; + disp_ptr = debug_shm_ptr->module_d[disp_sub_module_flag].page_d[disp_page_flag].line_d[disp_index].pointer; + break; + case 5: + if (char_ptr == disp_length) + { + if (disp_index%3 == 0) + SendTelnetFlag = 1; + disp_index = (disp_index + 1) % 23; + m_state_sub_module = 4; + } + else + debug_disp_hex(); + break; + default: + break; + } + break; + default: + break; + } +} + +/* +* +* Fun: debug_disp_hex +* +* Desc: Set debug page show data as hex(page>0) +* +* Ret: REVOID +* File: debug.c +* +*/ +void debug_disp_hex() +{ + WORD r_no; + WORD i; + + switch(hex_state) + { + case 0: + r_no = disp_index*20 + char_ptr; + if (comp_disp[r_no] != disp_ptr[char_ptr]) + { + comp_disp[r_no] = disp_ptr[char_ptr]; + row_ptr = disp_index + 3; + col_ptr = char_ptr; + col_ptr = (col_ptr*3) + 20; + hex_state = 1; + } + else + char_ptr = char_ptr + 1; + break; + case 1: + cursor_p[2] = ascii[row_ptr/10]; + cursor_p[3] = ascii[row_ptr%10]; + cursor_p[5] = ascii[col_ptr/10]; + cursor_p[6] = ascii[col_ptr%10]; + space_counter = 0; + hex_state = 2; + break; + case 2: + if (space_counter == 8) + hex_state = 3; + else + { + if (sendserbuf_t != (sendserbuf_h + 1)) + { + debug_send_char(cursor_p[space_counter]); + space_counter = space_counter + 1; + } + } + break; + case 3: + i = disp_ptr[char_ptr]; + i = ascii[(i>>4)&0xf]; /* high bit */ + if (sendserbuf_t != (sendserbuf_h + 1)) + { + debug_send_char(i); + hex_state = 4; + } + break; + case 4: + i = disp_ptr[char_ptr]; + i = ascii[i&0xf]; + if (sendserbuf_t != (sendserbuf_h + 1)) + { + debug_send_char(i); + // SendTelnetFlag = 1; + char_ptr = char_ptr + 1; + hex_state = 0; + } + break; + default: + break; + } +} + + +void debug_set_para() +{ + DWORD object_id[20]={1,3,6,1,4,1,1373,1,3,2,3,1,2,15,1}; + BYTE data_ptr[TITLE_CHAR]; + int i,j; + BYTE agent_buf_arr[16]; + + /* object_id[0] = 1; + object_id[1] = 3; + object_id[2] = 6; + object_id[3] = 1; + object_id[4] = 4; + object_id[5] = 1; + object_id[6] = 1373; + object_id[7] = 1; + object_id[8] = 3; + object_id[9] = 2; + object_id[10] = 3; + object_id[11] = 1; //debug + object_id[12] = 2; //configuration + object_id[13] = 15; //debug module + object_id[14] = 1; + */ + data_ptr[0] = 1; + debug_set_response(13,object_id,data_ptr,1);//debug status + + object_id[14] = 2; + strcpy(data_ptr,DEBUG_VERSION); + debug_set_response(13,object_id,data_ptr,strlen(data_ptr));//debug name + + object_id[14] = 3; + debug_set_response(13,object_id,debug_ascii_in_array,1); + + object_id[14] = 4; + debug_set_response(13,object_id,debug_ascii_out_array,1); + + object_id[14] = 6; + object_id[15] = 1; + strcpy(data_ptr,"\tDebug\tPage 01\t\tmodule status\r\ + 1 2\r\ + M0 status\r\ + M1 status\r\ + M2 status\r\ + M3 status\r\ + M4 status\r\ + M5 status\r\ + M6 status\r\ + M7 status\r\ + M8 status\r\ + M9 status\r\ + M10 status\r\ + M11 status\r\ + M12 status\r\ + M13 status\r\ + M14 status\r\ + M15 status"); + debug_set_response(14,object_id,data_ptr,strlen(data_ptr));//debug title + + for (i = 0;i < MODULE_COUNT;i ++) + { + object_id[14] = 6; + object_id[15] = 2 + i; + object_id[16] = 2; + debug_set_response( 15 ,object_id,debug_shm_ptr->module_d[i].status,1);//debug page 0 line 1 + } + + object_id[14] = 7; + object_id[15] = 1; + strcpy(data_ptr,"\tDebug\tPage 02\t\tascii_in_flag\r\ + 1 2 3\r\ + current module\r\ + M0 ascii in flag\r\ + M1 ascii in flag\r\ + M2 ascii in flag\r\ + M3 ascii in flag\r\ + M4 ascii in flag\r\ + M5 ascii in flag\r\ + M6 ascii in flag\r\ + M7 ascii in flag\r\ + M8 ascii in flag\r\ + M9 ascii in flag\r\ + M10 ascii in flag\r\ + M11 ascii in flag\r\ + M12 ascii in flag\r\ + M13 ascii in flag\r\ + M14 ascii in flag\r\ + M15 ascii in flag"); + debug_set_response(14,object_id,data_ptr,strlen(data_ptr)); + + for (i = 0;i <= MODULE_COUNT;i ++) + { + object_id[14] = 7; + object_id[15] = i + 2; + object_id[16] = 2; + if (i==0) + debug_set_response(15,object_id,&disp_sub_module_flag,1); + else + debug_set_response(15,object_id,&debug_shm_ptr->module_d[i-1].ascii_in_set_flag,1); + } + object_id[14] = 8; + object_id[15] = 1; + strcpy(data_ptr,"\tDebug\tPage 03\t\tTest Page\r\ + 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\r\ + line1"); + debug_set_response(14,object_id,data_ptr,strlen(data_ptr));//debug page 1 line 1 title + + object_id[14] = 8; + object_id[15] = 2; + object_id[16] = 2; + debug_set_response(15,object_id,test_array,20);//debug page 2 line 1 title + /* + object_id[14] = 9; + object_id[15] = 1; + strcpy(data_ptr,"\tDebug\tPage 04\t\tascii_out_flag\r + 1 2 3\r + M0 ascii out flag\r + M1 ascii out flag\r + M2 ascii out flag\r + M3 ascii out flag\r + M4 ascii out flag\r + M5 ascii out flag\r + M6 ascii out flag\r + M7 ascii out flag\r + M8 ascii out flag\r + M9 ascii out flag\r + M10 ascii out flag\r + M11 ascii out flag\r + M12 ascii out flag\r + M13 ascii out flag\r + M14 ascii out flag\r + M15 ascii out flag"); + debug_set_response(14,object_id,data_ptr,strlen(data_ptr)); + + for (i = 0;i < MODULE_COUNT;i ++) + { + object_id[14] = 9; + object_id[15] = i + 2; + object_id[16] = 2; + debug_set_response(15,object_id,&debug_shm_ptr->module_d[i].ascii_out_set_flag,1); + } + */ + object_id[14] = 9; + object_id[15] = 1; + strcpy(data_ptr,"\tDebug\tPage 05\t\tdebug_snmp_agent_buf\r\ + 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\r\ + oid 10 \t\r\ + oid 11 \t\r\ + oid 12 \t\r\ + oid 13 \t\r\ + oid 14 \t\r\ + oid 15 \t\r\ + oid 16 \t\r\ + oid 17 \t\r\ + oid 18 \t\r\ + oid_len \t\r\ + cmm_state \t\r\ + result_state \t\r\ + totoal_instance\t\r\ + totoal_field \t\r\ + total_ip "); + /* + para0 in_type \t\r + para0selectid \t\r + total_select \t\r + paran in_type \t\r + paranselectid \t\r + total_select" + */ + debug_set_response(14,object_id,data_ptr,strlen(data_ptr)); + object_id[14]=9; + object_id[15]=2; + object_id[16]=2; + for(j=9;j<18;j++) + { + for(i=0;i<16;i++) + { + agent_buf_arr[i]=(BYTE)debug_snmp_agent_buf[i].oid[j]; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + } + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].oid_len; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].cmm_state; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].result_state; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].total_instance; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].total_field; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + for(i=0;i<16;i++) + { + agent_buf_arr[i]=debug_snmp_agent_buf[i].total_ip; + } + debug_set_response(15,object_id,agent_buf_arr,16); + object_id[15]++; + /* + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].total_field,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[0].input_type,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[0].curr_select_id,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[0].total_select ,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[1].input_type,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[1].curr_select_id,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[1].total_select ,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[debug_snmp_agent_buf[i].total_field-1].input_type,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[debug_snmp_agent_buf[i].total_field-1].curr_select_id,1); + object_id[15]++; + debug_set_response(15,object_id,&debug_snmp_agent_buf[i].param_field_arr[debug_snmp_agent_buf[i].total_field-1].total_select ,1); + object_id[15]++; + */ + +} + +/////////////////////////////End of Module Page/////////////////////////// + + + + + + +///////////////////////////////Create OID Tree////////////////////// +/* +* +* Fun: MIB_create_tree +* +* Desc: Create a new MIB tree in memory using the name of configure file which lists mib files +* +* Ret: 1: Successful; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int MIB_create_tree(char *conf_dir, char *conf_file) +{ + FILE *fp_conf, *fp_mib; + char *temp_ch; + char file_name[256], temp_str[256]; + int i; + BYTE line_count; + mib_type_num = 0; + mib_node_index = 0; + mib_child_node_index = 0; + mib_root_node = NULL; + mib_curr_node = NULL; + memset((BYTE *)mib_nodes, 0, sizeof(mib_node) * MIB_MAX_NODES); + memset((BYTE *)mib_child_nodes, 0, sizeof(mib_child_node) * MIB_MAX_CHILD_NODES); + + strcpy(file_name, ""); + strcpy(file_name, MIB_FILES_DIR); + strcat(file_name, MIB_WRITE_TREE); + remove(file_name); + + + for(i=0;ioid_len;index++) + { + last_node_oid[index] = father_node_ptr->oid[index]; + } + next_line_flag = 1; + state = 0; + break; + } + else + { + printf("[debug] There is error in IMPORTS part.line:%d.\r\n",mib_line_count); + return 0; + } + //} + //next_line_flag =0; + //state=0; + //break; + case 2: // except "MODULE-IDENTITY" + //temp_ch = strstr(temp_str,"MODULE-IDENTITY"); + //if(temp_ch != NULL) + // { + //*temp_ch = '\0'; + pick_name(temp_str, temp_str,temp_ch); // take the first word as a the name of this module-identity + if(strlen(temp_str) == 0) + { + printf("[debug] Error: There is no module name in the line [%s].line:%d.\r\n",temp_str,mib_line_count); + return 0; + } + //printf("module name [%s].\r\nmodule_found:\r\n",temp_str); + if(MODULE_found(temp_str, fp, father_node_ptr, last_node_oid) == 1) + { + next_line_flag = 1; + state = 0; + break; + } + else + { + printf("[debug] Error: There is error in MODULE-IDENTITY part.line:%d.\r\n",mib_line_count); + return 0; + } + // } + //next_line_flag = 0; + //state = 2; + //break; + case 3: // except "OBJECT-IDENTITY" + //temp_ch = strstr(temp_str,"OBJECT-IDENTITY"); + //if(temp_ch != NULL) + //{ + //*temp_ch = '\0'; + pick_name(temp_str, temp_str,temp_ch); // take the first word as a the name of this object-identity + if(strlen(temp_str) == 0) + { + printf("[debug] Error: There is no object name in the line [%s].line:%d.\r\n",temp_str,mib_line_count); + return 0; + } + if(OBJECT_found(temp_str, fp, father_node_ptr, last_node_oid) == 1) + { + next_line_flag = 1; + state = 0; + break; + } + else + { + printf("[debug] Error: There is error in OBJECT-IDENTITY part.line:%d.\r\n",mib_line_count); + return 0; + } + //} + //next_line_flag = 0; + //state = 3; + //break; + case 4: // except "OBJECT-TYPE" + //temp_ch = strstr(temp_str,"OBJECT-TYPE"); + //if(temp_ch != NULL) + //{ + //*temp_ch = '\0'; + pick_name(temp_str, temp_str,temp_ch); // take the first word as a the name of this object-type + if(strlen(temp_str) == 0) + { + printf("[debug] Error: There is no object-type name in the line [%s].line:%d.\r\n",temp_str,mib_line_count); + return 0; + } + + //printf("type_found(temp_str: %s\r\n",temp_str); + if(TYPE_found(temp_str, fp, father_node_ptr, last_node_oid) == 1) + { + next_line_flag = 1; + state = 0; + break; + } + else + { + printf("[debug] Error: There is error in OBJECT-TYPE part.line:%d.\r\n",mib_line_count); + return 0; + } + //} + //next_line_flag=0; + //state=4; + //break; + default: + next_line_flag=0; + state=0; + break; + } + } + printf("[debug] Error: There is not word [END].line:%d.\r\n",mib_line_count); + return 0; +} /* end of BEGIN_found */ + + +/* +* +* Fun: OBJECT_found +* +* Desc: Analyze the OBJECT part and collect data after the string "OBJECT-IDENTITY" was found +* +* Ret: 1: Successful; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int OBJECT_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD *last_node_oid) +{ + char temp_str[256]; + char temp_child_str[256]; + char *temp_ch; + DWORD size; + DWORD i; + BYTE find_module=0; + FILE *fp_conf; + char file_name[128]; + int state, next_line, found, index; + mib_node *node_ptr; + next_line=1; + state=1; + + + strcpy(file_name, ""); + strcpy(file_name, MIB_FILES_DIR); + strcat(file_name, MIB_WRITE_TREE ); + for(index=0;index<256;index++) + { + temp_str[index] = '\0'; + temp_child_str[index] = '\0'; + } + temp_ch = NULL; + + strcpy(object_data.name, ""); + object_data.ST = 0; + strcpy(object_data.DE, ""); + strcpy(object_data.RF, ""); + strcpy(object_data.father_name, ""); + strcpy(object_data.ID, ""); + + if(strlen(name) ==0) + { + printf("[debug] Error: Object name can not be NULL.line:%d.\r\n",mib_line_count); + return 0; + } + strcpy(object_data.name,name); + found=0; + + while(!feof(fp)) + { + if(next_line) + { + mib_line_count++; + if( read_line(fp,temp_str) == 0 ) + continue; + } + temp_ch = strchr(temp_str,'"'); // take the string between '"' and '"' into temp_child_str[] + if(temp_ch != NULL) + { + int index = 0; + while(temp_ch[index + 1] != '"') + { + temp_child_str[index] = temp_ch[index + 1]; + index++; + } + temp_child_str[index] = '\0'; + } + else + strcpy(temp_child_str, ""); + + switch(state) + { + case 1: // must be "STATUS" + temp_ch = strstr(temp_str, "STATUS"); + if(temp_ch != NULL) + { + if(strstr(temp_str, "current")) // fill the object_data.ST accroding to the word behind "STATUS" + { + object_data.ST = 1; + } + else + { + if(strstr(temp_str, "deprecated")) + { + object_data.ST = 2; + } + else + { + if(strstr(temp_str, "obsolete")) + { + object_data.ST = 3; + } + else + { + object_data.ST = 0; + printf("[debug] Error: Fail to collect the contents of STATUS.line:%d.\r\n",mib_line_count); + return 0; + } + } + } + found = 1; + next_line=1; + state=2; + break; + } + next_line = 1; + state = 1; + break; + case 2: // must be "DESCRIPTION" + temp_ch = strstr(temp_str,"DESCRIPTION"); + if(temp_ch != NULL) + { + take_str(temp_child_str, fp, temp_str); + if((temp_ch=strstr(temp_str,"[SubSystem_Module]"))) + { + strcpy(object_data.DE, temp_ch+18); + + find_module=1; + found = 2; + next_line=1; + state=3; + break; + + }else if(strlen(temp_str)) + { + strcpy(object_data.DE,temp_str); + found = 2; + next_line=1; + state=3; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of DESCRIPTION field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 1; + state = 2; + break; + case 3: // may be "REFERENCE" + temp_ch = strstr(temp_str,"REFERENCE"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, object_data.RF) ) // take the string between '"' and '"' after "REFERENCE " into object_data.RF[] + { + next_line = 1; + found = 3; + state=4; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of the REFERENCE field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line=0; + state = 4; + break; + case 4: // must be "::=" + temp_ch = strstr(temp_str,"::="); + if(temp_ch != NULL) + { + //printf("object_data.name: %s.\r\n",object_data.name); + if((node_ptr=create_node(temp_str, object_data.name, 0, father_node_ptr, last_node_oid)) ) // create the object nod + { + //show_node(father_node_ptr,"{ }--", 1); + //printf("\r\nmib_node_index: %d. node_name: %s.\r\n",mib_node_index, object_data.name); + if(find_module) + { + strcpy(subsys_module[gobal_module_index].name,object_data.name); + subsys_module[gobal_module_index].index=gobal_module_index; + node_ptr->module_index=gobal_module_index; + for(index=6;indexoid_len;index++) + subsys_module[gobal_module_index].oid[index-6]=node_ptr->oid[index]; + gobal_module_index++; + } + else + node_ptr->module_index=gobal_module_index-1; + if((fp_conf = fopen(file_name,"a+")) == NULL) + { + printf("[debug] Error: cannot open conf_file: [%s].\r\n",file_name); + return 0; + } + if(!strlen(object_data.DE)) + { + node_ptr->remark_ptr=NULL; + } + else + { + for(i=0;i0;i--) + if(temp_str2[i]==' ' || temp_str2[i]=='\t' || temp_str2[i]=='\n') + temp_str2[i]='\0'; + else + break; + strcpy(object_data.DE,temp_str2); + } + + size=strlen(object_data.DE); + memcpy(heap_remark_curr,object_data.DE,sizeof(char)*(size+1)); + node_ptr->remark_ptr=heap_remark_curr; + heap_remark_index+=size+1; + heap_remark_curr=heap_remark+heap_remark_index; + } + fprintf(fp_conf,"Remark: %s\r\n",node_ptr->remark_ptr); + fprintf(fp_conf,"\r\n\r\n"); + fclose(fp_conf); + return 1; + } + else + { + printf("[debug] Error: Fail to create the object nod: [%s].line:%d.\r\n",object_data.name,mib_line_count); + return 0; + } + } + default: + next_line = 1; + state = 1; + break; + } + } + + switch(found) + { + case 0: + printf("[debug] Error: Can not find STATUS field.line:%d.\r\n",mib_line_count); + break; + case 1: + printf("[debug] Error: Can not find DESCRIPTION field.line:%d.\r\n",mib_line_count); + break; + default: + printf("[debug] Error: Can not find ::= field.line:%d.\r\n",mib_line_count); + break; + } + return 0; +} /* end of OBJECT_found */ + + + + + +/* +* +* Fun: TYPE_found +* +* Desc: Analyze the TYPE part and collect data after the string "TYPE-IDENTITY" was found +* +* Ret: 1: Successful; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int TYPE_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD *last_node_oid) +{ + char temp_str[256]; + char temp_child_str[256]; + char *temp_ch; + int state, next_line, found, index; + FILE *fp_conf; + char file_name[128]; + char access_str[32]; + mib_node *node_ptr; + mib_node *leaf_node; + mib_child_node *mib_child_node_point; + mib_node_param *mib_node_param_point; + mib_param_select *mib_param_select_point; + WORD i; + BYTE j; + next_line=1; + state=1; + i=j=0; + for(index=0;index<256;index++) + { + temp_str[index] = '\0'; + temp_child_str[index] = '\0'; + } + temp_ch = NULL; + + strcpy(type_data.name, ""); + type_data.ST = 0; + strcpy(type_data.UP, ""); + type_data.MA = 0; + type_data.SY = 0; + strcpy(type_data.DE, ""); + type_data.total_instance = 0; + strcpy(type_data.RF, ""); + strcpy(type_data.father_name, ""); + strcpy(type_data.ID, ""); + + if(strlen(name) ==0) + { + printf("[debug] Error: Type name can not be NULL.line:%d.\r\n",mib_line_count); + return 0; + } + strcpy(type_data.name,name); + + found=0; + + while(!feof(fp)) + { + if(next_line) + { + mib_line_count++; + if( read_line(fp,temp_str) == 0 ) + continue; + + } + + temp_ch = strchr(temp_str,'"'); // take the string between '"' and '"' into temp_child_str[] + if(temp_ch != NULL) + { + int index = 0; + while(temp_ch[index + 1] != '"') + { + temp_child_str[index] = temp_ch[index + 1]; + index++; + } + temp_child_str[index] = '\0'; + } + else + strcpy(temp_child_str, ""); + //printf("t_f read_line: %s. temp_child_str: %s. state= %d\r\n",temp_str, temp_child_str, state); + //printf("state=%d\r\n",state); + switch(state) + { + case 1: // must be "SYNTAX" + temp_ch = strstr(temp_str,"SYNTAX"); + if(temp_ch != NULL) + { + // fill the type_data.SY accroding to the word behind "SYNTAX" + // 1: Integer32, 2: INTEGER, 3: OCTET STRING, + // 4: OBJECT IDENTIFIER, 5: BITS, 6: IpAddress, 7: Counter32, + // 8: Gauge32, 9: TimeTicks, 10: Opaque, 11: Counter64, + // 12: Unsigned32, 13:Conceptual Tables + if(strstr(temp_str, "Integer32")) + { + type_data.ST = 1; + } + else + { + if(strstr(temp_str, "INTEGER")) + { + type_data.SY = 2; + } + else + { + if(strstr(temp_str, "OCTET") && strstr(temp_str, " STRING")) + { + type_data.SY = 3; + } + else + { + if(strstr(temp_str, "OBJECT") && strstr(temp_str, " IDENTIFIER")) + { + type_data.SY = 4; + } + else + { + if(strstr(temp_str, "BITS")) + { + type_data.SY = 5; + } + else + { + if(strstr(temp_str, "IpAddress")) + { + type_data.SY = 6; + } + else + { + if(strstr(temp_str, "Counter32")) + { + type_data.SY = 7; + } + else + { + if(strstr(temp_str, "Gauge32")) + { + type_data.SY = 8; + } + else + { + if(strstr(temp_str, "TimeTicks") && strstr(temp_str, " STRING")) + { + type_data.SY = 9; + } + else + { + if(strstr(temp_str, "Opaque")) + { + type_data.SY = 10; + } + else + { + if(strstr(temp_str, "Counter64")) + { + type_data.SY = 11; + } + else + { + if(strstr(temp_str, "Unsigned32")) + { + type_data.SY = 12; + } + else + { + if(strstr(temp_str, "Conceptual") && strstr(temp_str, " Tables")) + { + type_data.SY = 13; + } + else + { + type_data.SY = 0; + printf("[debug] Error: Fail to collect the contents of SYNTAX field.line:%d.\r\n",mib_line_count); + return 0; + } + } + } + } + } + } + } + } + } + } + } + } + } + found = 1; + next_line=1; + state=2; + break; + } + next_line = 1; + state = 1; + break; + case 2: // may be "UnitsPart" + temp_ch = strstr(temp_str,"UnitsPart"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, type_data.UP) ) // take the string between '"' and '"' after "UnitsPart " into type_data.UP[] + { + next_line=1; + state=3; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of UnitsPart field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 0; + state = 3; + break; + case 3: // must be "MAX-ACCESS" + temp_ch = strstr(temp_str,"MAX-ACCESS"); + if(temp_ch != NULL) + { + // fill the type_data.MA accroding to the word behind "MAX-ACCESS" + // 0: invalid, 1: not-accessible, 2: accessible-for-notify, 3: read-only, 4: read-write, 5: read-create + if(strstr(temp_str, "not-accessible")) + { + type_data.MA = 1; + } + else + { + if(strstr(temp_str, "accessible-for-notify")) + { + type_data.MA = 2; + } + else + { + if(strstr(temp_str, "read-only")) + { + type_data.MA = 3; + } + else + { + if(strstr(temp_str, "read-write")) + { + type_data.MA = 4; + } + else + { + if(strstr(temp_str, "read-create")) + { + type_data.MA = 5; + } + else + { + if(strstr(temp_str, "write-only")) + { + type_data.MA = 6; + } + else + { + type_data.MA = 0; + printf("[debug] Error: Fail to collect the contents of MAX-ACCESS field.line:%d.\r\n",mib_line_count); + return 0; + } + } + } + } + } + } + found = 2; + next_line=1; + state = 4; + break; + } + next_line = 1; + state = 3; + break; + case 4: // must be "STATUS" + temp_ch = strstr(temp_str, "STATUS"); + if(temp_ch != NULL) + { + if(strstr(temp_str, "current")) // fill the type_data.ST accroding to the word behind "STATUS" + { + type_data.ST = 1; + } + else + { + if(strstr(temp_str, "deprecated")) + { + type_data.ST = 2; + } + else + { + if(strstr(temp_str, "obsolete")) + { + type_data.ST = 3; + } + else + { + type_data.ST = 0; + printf("[debug] Error: Fail to collect the contents of STATUS.line:%d.\r\n",mib_line_count); + return 0; + } + } + } + found = 3; + next_line=1; + state=5; + break; + } + next_line = 1; + state = 4; + break; + case 5: // must be "DESCRIPTION" + temp_ch = strstr(temp_str,"DESCRIPTION"); + if(temp_ch != NULL) + { + //printf("description: beginline:%d.\r\n",mib_line_count); + //if( take_str(temp_child_str, fp, type_data.DE) ) // take the string between '"' and '"' after "DESCRIPTION " into type_data.DE[] + //{ + /*int i=0; + // take the first word of Description into type_data.total_instance + while(type_data.DE[i] != 0xa) + { + temp_str[i] = type_data.DE[i]; + i++; + } + temp_str[i]='\0'; + type_data.total_instance = atoi(temp_str);*/ + // type_data.total_instance = 256; + //printf("description end: %s\r\n",type_data.DE); + if(!(strchr(temp_str,'"'))) + { + mib_line_count++; + read_line(fp,temp_str); + if(!(strchr(temp_str,'"'))) + { + printf("[debug] Error: There is no first quotes .line:%d.\r\n",mib_line_count); + return 0; + } + } + memset(&temp_leaf_node,0,sizeof(mib_node)); + leaf_compute_field_num=0; + if(!Analyze_Leaf_Description(fp, &temp_leaf_node)) + { + printf("[debug] Error: Fail to collect the contents of DESCRIPTION field.line:%d.\r\n",mib_line_count); + return 0; + } + mib_line_count++; + read_line(fp,temp_str); + if(!(strchr(temp_str,'"'))) + { + printf("[debug] Error: There is no second quotes.line:%d.\r\n",mib_line_count); + return 0; + } + found = 4; + next_line=1; + state=6; + break; + } + next_line = 1; + state = 5; + break; + case 6: // may be "REFERENCE" + temp_ch = strstr(temp_str,"REFERENCE"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, type_data.RF) ) // take the string between '"' and '"' after "REFERENCE" into type_data.RF + { + next_line = 1; + state=7; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of the REFERENCE field %d.line:%d.\r\n",module_data.RE_index,mib_line_count); + return 0; + } + } + next_line=0; + state = 7; + break; + case 7: // may be "INDEX" or "AUGMENTS" + temp_ch = strstr(temp_str,"INDEX"); + if(temp_ch != NULL) + { + // handle the line contenting "INDEX" + next_line = 1; + state = 8; + break; + } + else + { + temp_ch = strstr(temp_str,"AUGMENTS"); + if(temp_ch != NULL) + { + // handle the line contenting "AUGMENTS" + next_line = 1; + state = 8; + break; + } + else + { + next_line = 0; + state = 8; + break; + } + } + case 8: // must be "::=" + temp_ch = strstr(temp_str,"::="); + if(temp_ch != NULL) + { + //printf("type.::= begin: tmep_str: %s....type_data.name: %s\r\n",temp_str,type_data.name); + if( (node_ptr = create_node(temp_str, type_data.name, 0, father_node_ptr, last_node_oid)) ) // create the module node + { + mib_type_num++; + node_ptr->max_access = type_data.MA; + leaf_node=&temp_leaf_node; + node_ptr->module_index=gobal_module_index-1; + node_ptr->data_length=leaf_node->data_length; + node_ptr->total_instance=leaf_node->total_instance; + node_ptr->total_child_nodes=leaf_node->total_child_nodes; + node_ptr->enable_field_id=leaf_node->enable_field_id; + strncpy(node_ptr->init_value,leaf_node->init_value,leaf_node->data_length); + node_ptr->remark_ptr=leaf_node->remark_ptr; + for(index=0;indexchild_nodes[index]=leaf_node->child_nodes[index]; + } + if(node_save_flag==1) + { + module_save_flag[node_ptr->module_index].module_index=node_ptr->module_index; + module_save_flag[node_ptr->module_index].save_select_id=node_save_module.save_select_id; + module_save_flag[node_ptr->module_index].save_field_id=node_save_module.save_field_id; + for(i=0;i<32;i++) + module_save_flag[node_ptr->module_index].oid[i]=node_ptr->oid[i]; + module_save_flag[node_ptr->module_index].oid_len=node_ptr->oid_len; + node_save_flag=0; + if(node_ptr->max_access<4) + { + printf("[Debug] : The save command node can not right!Please check the MIB files!\r\n"); + exit(0); + } + } + + if(leaf_compute_field_num!=0) + for(i=0;iname); + fprintf(fp_conf,"Instance: %d\r\n",node_ptr->total_instance); + fprintf(fp_conf,"Length : %d\r\n",node_ptr->data_length); + fprintf(fp_conf,"Flag : %d\r\n",node_ptr->enable_field_id); + fprintf(fp_conf,"Default : %s\r\n",node_ptr->init_value); + fprintf(fp_conf,"Remark : %s\r\n",node_ptr->remark_ptr); + fprintf(fp_conf,"Field : total(%d)\r\n",node_ptr->total_child_nodes); + + switch(node_ptr->max_access) + { + case 1: + strcpy(access_str,"not-accessible"); + break; + case 2: + strcpy(access_str,"accessible-for-notify"); + break; + case 3: + strcpy(access_str,"read-only"); + break; + case 4: + strcpy(access_str,"read-write"); + break; + case 5: + strcpy(access_str,"read-create"); + break; + case 6: + strcpy(access_str,"write-only"); + break; + default: + strcpy(access_str,"access type error"); + break; + } + fprintf(fp_conf,"Access : %s",access_str); + for(i=0;itotal_child_nodes;i++) + { + mib_child_node_point=node_ptr->child_nodes[i]; + if(mib_child_node_point) + if(mib_child_node_point->child_ptr) + { + mib_node_param_point=(mib_node_param* )mib_child_node_point->child_ptr; + if(mib_node_param_point->select_total==0) + { + if(mib_node_param_point->input_ptr!=NULL) + fprintf(fp_conf,"[%d]%s\r\n {\r\n [u]%d.%d-%d.%d\r\n [u]input\r\n [v]%s\r\n }\r\n",mib_node_param_point->id+1,mib_node_param_point->name,mib_node_param_point->byte_begin,mib_node_param_point->bit_begin,mib_node_param_point->byte_end,mib_node_param_point->bit_end,field_input_type[mib_node_param_point->input_ptr->input_param_type]); + } + else + { + fprintf(fp_conf," [%d]%s\r\n {\r\n [u]%d.%d-%d.%d\r\n [u]select\r\n",mib_node_param_point->id+1,mib_node_param_point->name,mib_node_param_point->byte_begin,mib_node_param_point->bit_begin,mib_node_param_point->byte_end,mib_node_param_point->bit_end); + for(j=0;jselect_total;j++) + { + mib_param_select_point=mib_node_param_point->select_ptr[j]; + if(mib_param_select_point) + fprintf(fp_conf," [v]%d[opt]%s\r\n", mib_param_select_point->number,mib_param_select_point->description); + } + fprintf(fp_conf," }\r\n"); + } + } + } + fprintf(fp_conf,"\r\n\r\n"); + fclose(fp_conf); + return 1; + } + else + { + printf("[debug] Error: Fail to create the type nod: [%s].line:%d.\r\n",type_data.name,mib_line_count); + return 0; + } + } + next_line = 1; + state = 8; + break; + default: + next_line = 1; + state = 0; + break; + } + } + switch(found) + { + case 0: + printf("[debug] Error: Can not find SYNTAX field.line:%d.\r\n",mib_line_count); + break; + case 1: + printf("[debug] Error: Can not find MAX-ACCESS field.line:%d.\r\n",mib_line_count); + break; + case 2: + printf("[debug] Error: Can not find STATUS field.line:%d.\r\n",mib_line_count); + break; + case 3: + printf("[debug] Error: Can not find DESCRIPTION field.line:%d.\r\n",mib_line_count); + break; + default: + printf("[debug] Error: Can not find ::= field.line:%d.\r\n",mib_line_count); + break; + } + return 0; +} /* end of TYPE_found */ + + +/* +* +* Fun: IMPORTS_found +* +* Desc: Analyze the IMPORTS part and collect data after the string "IMPORTS" was found +* +* Ret: return the pointer to the father node if successful. If fail, return null pointer +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_node *IMPORTS_found(FILE *fp) +{ + char temp_str[256]; + char *temp_ch; + int index, found[3] = {0,0,0}; + mib_node *father_node_ptr; + + for(index=0;index<256;index++) + temp_str[index] = '\0'; + temp_ch = NULL; + + strcpy(imports_data.father_name, ""); + strcpy(imports_data.from_file, ""); + + while(!feof(fp)) + { + mib_line_count++; + if( read_line(fp,temp_str) == 0) + continue; + //printf("read_line: %s.\r\n",temp_str); + temp_ch = strchr(temp_str,','); // skip the line contents ',' + if(temp_ch == NULL) + { + temp_ch = strstr(temp_str, "FROM"); // except a line contents "FROM" and ';' + if(temp_ch != NULL) + { + found[1] = 1; + if(strchr(temp_str, ';') != NULL) // if the line contents ';', collect the word between "FROM " and ';' + { + index=0; + temp_ch = &temp_ch[5]; + pick_first_word(temp_ch, imports_data.from_file); + temp_ch = strchr(imports_data.from_file, ';'); + if (temp_ch != NULL) + *temp_ch = '\0'; + found[2] = 1; + //printf("from_file: %s.\r\n",imports_data.from_file); + if( strlen(imports_data.father_name) ==0 ) + { + printf("[debug] Error: Can't not find name of Father_nod in IMPORTS part.line:%d.\r\n",mib_line_count); + return NULL; + } + if(mib_node_index == 0) + { + father_node_ptr = create_mib_node(imports_data.father_name, root_oid_len, root_oid, 0); + mib_curr_node = mib_root_node = father_node_ptr; + //printf("the first nod [%s]. return\r\n", imports_data.father_name); + return father_node_ptr; + } + else + father_node_ptr = find_node(mib_root_node, imports_data.father_name, 0, NULL); + return father_node_ptr; + } + } + else // take the name of the father nod into imports_data.father_name[] + { + pick_first_word(temp_str, imports_data.father_name); + //printf("father name: %s.\r\n",imports_data.father_name); + found[0] = 1; + } + } + } + if(found[0]==0) + printf("[debug] Error: Can't not find name of Father_nod in IMPORTS part.line:%d.\r\n",mib_line_count); + else if(found[1] == 0) + printf("[debug] Error: Can't not find name of Import_from_file in IMPORTS part.line:%d.\r\n",mib_line_count); + else if(found[2] == 0) + printf("[debug] Error: Can't not find end sign ';' in IMPORTS part.line:%d.\r\n",mib_line_count); + return NULL; +} // end of IMPORTS_found + + +/* +* +* Fun: MODULE_found +* +* Desc: Analyze the MODULE part and collect data after the string "MODULE-IDENTITY" was found +* +* Ret: 1: Successful; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int MODULE_found(char *name, FILE *fp, mib_node *father_node_ptr, DWORD *last_node_oid) +{ + char temp_str[256]; + char temp_child_str[256]; + char *temp_ch; + int state, next_line, found, index; + WORD size; + mib_node *node_ptr; + if(strlen(name) ==0) + { + printf("[debug] Error: Module name can not be NULL.line:%d.\r\n",mib_line_count); + return 0; + } + strcpy(module_data.name,name); + found=0; + + next_line=1; + state=1; + strcpy(temp_str, ""); + strcpy(temp_child_str, ""); + temp_ch = NULL; + + strcpy(module_data.LU, ""); + strcpy(module_data.OR, ""); + strcpy(module_data.CI, ""); + strcpy(module_data.DE, ""); + for(index = 0; index < MIB_MODULE_REVISION_MAX_NUM; index++) + { + strcpy(module_data.RE[index], ""); + strcpy(module_data.RE_DE[index], ""); + } + module_data.RE_index = 0; + strcpy(module_data.father_name, ""); + strcpy(module_data.ID, ""); + + while(!feof(fp)) + { + if(next_line) + { + mib_line_count++; + if( read_line(fp,temp_str) == 0 ) + continue; + } + temp_ch = strchr(temp_str,'"'); // take the string between '"' and '"' into temp_child_str[] + if(temp_ch != NULL) + { + int index = 0; + while(temp_ch[index + 1] != '"') + { + temp_child_str[index] = temp_ch[index + 1]; + index++; + } + temp_child_str[index] = '\0'; + } + else + strcpy(temp_child_str, ""); + + //printf("module state [%d].\r\n", state); + switch(state) + { + case 1: // must be "LAST-UPDATED" + temp_ch = strstr(temp_str,"LAST-UPDATED"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.LU) ) // take the string between '"' and '"' after "LAST-UPDATED " into module_data.LA[] + { + //printf("module_data.LAST-UPDATED [%s].\r\n", module_data.LU); + found = 1; + next_line=1; + state=2; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of LAST-UPDATED field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 1; + state = 1; + break; + case 2: // must be "ORGANIZATION" + temp_ch = strstr(temp_str,"ORGANIZATION"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.OR) ) // take the string between '"' and '"' after "ORGANIZATION " into module_data.OR[] + { + //printf("module_data.ORGANIZATION [%s].\r\n", module_data.OR); + found= 2; + next_line=1; + state=3; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of ORGANIZATION field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 1; + state = 2; + break; + case 3: // must be "CONTACT-INFO" + temp_ch = strstr(temp_str,"CONTACT-INFO"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.CI) ) // take the string between '"' and '"' after "ORGANIZATION " into module_data.CI[] + { + //printf("module_data.CONTACT-INFO [%s].\r\n", module_data.CI); + found = 3; + next_line=1; + state=4; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of CONTACT-INFO field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 1; + state = 3; + break; + case 4: // must be "DESCRIPTION" + temp_ch = strstr(temp_str,"DESCRIPTION"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.DE) ) // take the string between '"' and '"' after "DESCRIPTION " into module_data.DE[] + { + //printf("module_data.DESCRIPTION [%s].\r\n", module_data.DE); + found = 4; + next_line=1; + state=5; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of DESCRIPTION field.line:%d.\r\n",mib_line_count); + return 0; + } + } + next_line = 1; + state = 4; + break; + case 5: // may be "REVISION" + temp_ch = strstr(temp_str,"REVISION"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.RE[module_data.RE_index]) ) // take the string between '"' and '"' after "REVISION " into module_data.RE[RE_index] + { + //printf("module_data.REVISION(index) [%s](%d).\r\n", module_data.RE[module_data.RE_index], module_data.RE_index); + next_line = 1; + found = 5; + state=6; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of the REVISION field %d.line:%d.\r\n",module_data.RE_index,mib_line_count); + return 0; + } + } + next_line=0; + state = 7; + break; + case 6: // must be "DESCRIPTION" which belong to the nearest "REVISION" + temp_ch = strstr(temp_str,"DESCRIPTION"); + if(temp_ch != NULL) + { + if( take_str(temp_child_str, fp, module_data.RE_DE[module_data.RE_index]) ) // take the string between '"' and '"' after "DESCRIPTION " into module_data.RE_DE[RE_index] + { + //printf("module_data.REVISION.DESCRIPTION(index) [%s](%d).\r\n", module_data.RE_DE[module_data.RE_index], module_data.RE_index); + module_data.RE_index = (module_data.RE_index + 1) % MIB_MODULE_REVISION_MAX_NUM; + next_line = 1; + found = 6; + state=5; + break; + } + else + { + printf("[debug] Error: Fail to collect the contents of DESCRIPTION field of the REVISION field: %d.line:%d.\r\n",module_data.RE_index,mib_line_count); + return 0; + } + } + next_line = 1; + state = 6; + break; + case 7: // must be "::=" + temp_ch = strstr(temp_str,"::="); + if(temp_ch != NULL) + { + //printf("entering create_node().line:%d.\r\n",mib_line_count); + if( (node_ptr=create_node(temp_str, module_data.name, 0, father_node_ptr, last_node_oid))) // create the module nod + { + if(!strlen(module_data.DE)) + { + node_ptr->remark_ptr=NULL; + return 1; + } + else + { + size=strlen(module_data.DE); + memcpy(heap_remark_curr,module_data.DE,sizeof(char)*(size+1)); + node_ptr->remark_ptr=heap_remark_curr; + heap_remark_index+=size+1; + heap_remark_curr=heap_remark+heap_remark_index; + } + return 1; + } + else + { + printf("[debug] Error: Fail to create the module nod: [%s].line:%d.\r\n",module_data.name,mib_line_count); + return 0; + } + } + default: + next_line = 1; + state = 0; + break; + } + } + switch(found) + { + case 0: + printf("[debug] Error: Can not find LAST-UPDATED field.line:%d.\r\n",mib_line_count); + break; + case 1: + printf("[debug] Error: Can not find ORGANIZATION field.line:%d.\r\n",mib_line_count); + break; + case 2: + printf("[debug] Error: Can not find CONTACT-INFO field.line:%d.\r\n",mib_line_count); + break; + case 3: + printf("[debug] Error: Can not find DESCRIPTION field.line:%d.\r\n",mib_line_count); + break; + case 5: + printf("[debug] Error: Can not find the DESCRIPTION of REVISION field.line:%d.\r\n",mib_line_count); + break; + default: + printf("[debug] Error: Can not find ::= field.line:%d.\r\n",mib_line_count); + break; + } + return 0; +} /* end of MODULE_found */ + + +/* +* +* Fun: Analyze_Description +* +* Desc: Analyze leaf node Description script in the mib script +* +* Ret: 0 err 1 successfull +* +* File: debug.c +* +*/ +int Analyze_Leaf_Description(FILE *fp, mib_node *leaf_node) +{ + BYTE unit_start_flag, + remark_start_flag, + select_start_flag, + field_start_flag, + new_line=0, + leaf_state, + field_state, + i, + j; + char instance_str[5], + default_str[256], + length_str[4], + data_arr[512], + temp_str[128], + *temp_ch, + *p; + WORD total_instance, + pos_arr[4], + length, + size; + mib_child_node *mib_child_node_ptr = NULL; + mib_param_select *mib_param_select_ptr = NULL; + mib_param_input *mib_param_input_ptr = NULL; + mib_node_param *mib_node_param_ptr = NULL; + + unit_start_flag=remark_start_flag=select_start_flag=field_start_flag=0; + leaf_node->enable_field_id=0xFF; + leaf_state=0; + field_state=0; + while(!feof(fp)) + { + if(leaf_state==10) + { + printf("[Debug] Error: Script error.The field segment error.Line: %d.\r\n", mib_line_count); + return 0; + } + if((leaf_state<=5 && field_start_flag==0) || ((remark_start_flag==1)&& leaf_state>=8)) + { + mib_line_count++; + memset(data_arr,0,512*sizeof(char)); + if( read_line(fp,data_arr) == 0 ) + continue; + + } + new_line=0; + switch (leaf_state) + { + case 0: + temp_ch = strstr(data_arr, "[Begin]"); + if(temp_ch != NULL) + leaf_state = 1; + else + leaf_state = 10; + break; + case 1: + temp_ch = strstr(data_arr, "Instance"); + if(temp_ch != NULL) + { + temp_ch+=8; + for(i=0;i MAX_TOTAL_INSTANCE) + { + printf + ("[Debug] Error: script error.The max instance number is %d.line:%d.\r\n", + MAX_TOTAL_INSTANCE, mib_line_count); + return 0; + } + leaf_node->total_instance = total_instance; + leaf_state = 2; + break; + } + } + leaf_state = 10; + break; + case 2: + temp_ch = strstr(data_arr, "Length"); + if(temp_ch != NULL) + { + temp_ch+=6; + for(i=0;i MAX_NODE_PACKET_LENGTH) + { + printf + ("[Debug] Error: script error.The max data length is %d. line:%d.\r\n", + MAX_NODE_PACKET_LENGTH, + mib_line_count); + return 0; + } + leaf_node->data_length = length; + leaf_state = 3; + break; + } + } + leaf_state = 10; + break; + case 3: + temp_ch = strstr(data_arr, "Default"); + if(temp_ch != NULL) + { + temp_ch+=7; + for(i=0;i 256 && (test_str(default_str,1))) + { + printf("[Debug] Error: script error.The max default value length is 256.Line: %d.\r\n", mib_line_count); + return 0; + } + memset(leaf_node->init_value,0,256*sizeof(char)); + AsciiToRbcd (leaf_node->init_value, default_str, strlen(default_str)); + leaf_node->init_value[leaf_node->data_length]='\0'; + leaf_state = 5; + break; + } + leaf_state=10; + break; + case 5: + temp_ch = strstr(data_arr, "Flag"); + if(temp_ch != NULL) + { + temp_ch+=4; + if((temp_ch=strstr(data_arr, "E")) ) + { + leaf_state=6; + break; + } + else if((temp_ch=strstr(data_arr, "S"))) + { + leaf_state=7; + break; + } + else leaf_state=10; + } + field_start_flag=1; + leaf_state=4; + break; + case 6: + temp_ch++; + if(*temp_ch=='\0') + { + printf("[Debug] Error: script error.The enable Flag format is not right.Line: %d.\r\n", mib_line_count); + return 0; + } + strcpy(temp_str,temp_ch); + leaf_node->enable_field_id=atoi(temp_ch)-1; + leaf_state=4; + break; + case 7: + temp_ch++; + i=0; + while(*(temp_ch+i)!='\0') + { + if(*(temp_ch+i)=='.') + break; + if(!isdigit(*(temp_ch+i))) + { + printf("[Debug] Error: script error.The save Flag format is not right.Line: %d.\r\n", mib_line_count); + return 0; + } + i++; + } + if(*(temp_ch+i)=='\0') + { + printf("[Debug] Error: script error.The save Flag format is not right.Line: %d.\r\n", mib_line_count); + return 0; + } + node_save_flag=1; + strncpy(temp_str,temp_ch,i); + temp_str[i]='\0'; + temp_ch=temp_ch+i+1; + node_save_module.save_field_id=atoi(temp_str); + strcpy(temp_str,temp_ch); + if(!(test_str(temp_str,0)) ) + { + printf("[Debug] Error: script error.The save Flag format is not right.Line: %d.\r\n", mib_line_count); + return 0; + } + node_save_module.save_select_id=atoi(temp_str); + leaf_state=4; + break; + case 4: + field_start_flag=0; + if(unit_start_flag==0) + { + temp_ch = strstr(data_arr, "Field"); + if(temp_ch != NULL) + { + temp_ch = strstr(data_arr, "["); + if(temp_ch != NULL) + { + field_state = 1; + } + else + { + field_state=0; + temp_ch=data_arr; + } + } + else + { + leaf_state = 10; + break; + } + unit_start_flag=1; + } + else if(field_state!=1 && (temp_ch=strstr(data_arr,"Remark"))!=NULL) + { + printf("[Debug] Error: The field is not over! line:%d.\r\n",mib_line_count); + return 0; + } + else + temp_ch=data_arr; + p=temp_ch; + while(*p != '\0') + { + if(field_state==13) + { + printf("[Debug] Error: Script error.The field segment error.Line: %d.\r\n", mib_line_count); + return 0; + } + if((strstr(p,"Remark")!=NULL) && (strstr(p,":"))!=NULL) + { + leaf_state=8; + break; + } + if(new_line==1) + break; + switch (field_state) + { + case 0: //idle + field_state = 1; + new_line=1; + break; + case 1: //meet the "[" + if(select_start_flag==1) + { + temp_ch=strstr(p,"}"); + if(temp_ch != NULL) + { + field_state=7; + break; + } + } + temp_ch = strstr(p, "["); + if(temp_ch != NULL) + { + p = temp_ch + 1; + if(isdigit(*p)) + { + field_state = 2; + break; + } + else if(*p == 'i' || *p == 'I') + { + field_state = 3; + break; + } + else if(*p == 'u' || *p == 'U') + { + field_state = 4; + break; + } + else if(*p == 'v' || *p == 'V') + { + field_state = 5; + break; + } + } + field_state = 13; + break; + case 2: //meet the "[num" + // p--; + i = strcspn(p, "]"); + if(i != 0) + { + strncpy(temp_str, p, i); + temp_str[i]='\0'; + del_space(temp_str,2); + if((test_str(temp_str,0)) && strlen(temp_str)<4) + { + p=p+i+1; + if(*p=='\0') + { + printf("[debug] : Script Error. There is no field name.Line: %d.\r\n", mib_line_count); + return 0; + } + if (mib_node_param_index >= MIB_MAX_NODE_PARAMS) + { + printf("[debug] : Script Error. There is no field have been alloced in the memery.Line: %d.\r\n", mib_line_count); + return 0; + } + mib_node_param_ptr = &mib_node_param_array[mib_node_param_index++]; + strcpy( mib_node_param_ptr->name, p); + if(atoi(temp_str)>0) + mib_node_param_ptr->id =(BYTE)(atoi(temp_str)-1); + else + { + printf("[Debug] : The field id start from 1!line:%d.\r\n",mib_line_count); + return 0; + } + //leaf_node->total_child_nodes++; + mib_node_param_ptr->parent_ptr=leaf_node; + if (!(mib_child_node_ptr = create_mib_child_node(mib_node_param_ptr->name, leaf_node->total_child_nodes))) + { + printf("[debug] Error: Faile to Create child nod.id:%s,name:%s.line:%d\r\n", temp_str,p,mib_line_count); + return 0; + } + if (!register_child_node(leaf_node, mib_child_node_ptr)) + { + printf("[debug] Error: Fail to register the child nod id:%s,name:%s..line:%d.\r\n",temp_str,p,mib_line_count); + return 0; + } + mib_child_node_ptr->child_ptr = mib_node_param_ptr; + + field_state=6; + new_line=1; + break; + } + } + field_state = 13; + break; + case 3: //meet the "[I" + p++; + i = strcspn(p, "]"); + if(i != 0) + { + strncpy(temp_str, p, i); + temp_str[i]='\0'; + p+=i+1; + i = 0; + while(temp_str[i] != '\0') + { + if(!isdigit(temp_str[i])) + break; + i++; + } + if(i == strlen(temp_str) && atoi(temp_str)<256) + { + j=atoi(temp_str)-1; + + } + else + { + printf("[debug] Error: The field id is not right.line:%d.\r\n",mib_line_count); + return 0; + } + if(*p!='\0') + strcpy(temp_str,p); + else + { + printf("[debug] Error: There field name is not right.line:%d.\r\n",mib_line_count); + return 0; + } + if(create_compute_field(fp,leaf_node,j,temp_str)==0) + { + field_state=13; + break; + } + field_state=1; + leaf_compute_field_num++; + new_line=1; + break; + } + field_state = 13; + break; + case 4: //meet the "[u" + temp_ch=strstr(data_arr, "[u]select"); + if(temp_ch!=NULL) + { + field_state = 8; + break; + } + temp_ch=strstr(data_arr, "[u]input"); + if(temp_ch!=NULL) + { + field_state = 9; + break; + } + temp_ch=strstr(data_arr,"]"); + if(temp_ch!=NULL) + if(isdigit(temp_ch[1])) + { + p=temp_ch; + field_state=10; + break; + } + field_state=13; + break; + case 5: //meet the "[v" + if(strncasecmp(mib_node_param_ptr->name,"Reserved",strlen("Reserved"))==0 && strcmp(p,"{")) + { + field_state=7; + break; + } + temp_ch=strstr(p,"]"); + if(temp_ch!=NULL) + { + if(isdigit(*(temp_ch+1))) + field_state=12; + else + field_state=11; + break; + } + field_state=13; + break; + case 6: //meet the "{" + temp_ch=strstr(p,"{"); + field_state=1; + new_line=1; + break; + case 7: //meet the "}" + temp_ch=strstr(p,"}"); + field_state=1; + new_line=1; + break; + case 8: //meet the "[u]select" + field_state=5; + new_line=1; + break; + case 9: //meet the "[u]input" + field_state=5; + new_line=1; + break; + case 10: //meet the "[u]00.0-10.0" + p++; + for(i=0,j=0;i<4;i++) + { + while(*p!='\0') + { + if(*(p+j)=='.' || *(p+j)=='-') + break; + j++; + } + strncpy(temp_str,p,j); + temp_str[j]='\0'; + pos_arr[i]=atoi(temp_str); + p+=j+1; + j=0; + } + + mib_node_param_ptr->byte_begin=pos_arr[0]; + mib_node_param_ptr->bit_begin=pos_arr[1]; + mib_node_param_ptr->byte_end=pos_arr[2]; + mib_node_param_ptr->bit_end=pos_arr[3]; + field_state=1; + new_line=1; + break; + case 11: //meet the "[v]keepHex-low-E" + if (mib_param_input_index >= MIB_MAX_PARAM_INPUTS) + { + printf("[debug] Error: There are not enough mib_param_inputs in the array.line:%d.\r\n",mib_line_count); + return 0; + } + mib_param_input_ptr = &mib_param_input_array[mib_param_input_index++]; + mib_node_param_ptr->input_ptr = mib_param_input_ptr; + strcpy(temp_str,data_arr); + if(strstr(temp_str, "toDec-high-0")) + { + mib_param_input_ptr->input_param_type = TODEC_HIGH_0; + } + else + { + if(strstr(temp_str, "keepHex-high-0")) + mib_param_input_ptr->input_param_type = KEEPHEX_HIGH_0; + else + { + if(strstr(temp_str, "keepHex-low-0")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_0; + else + { + if(strstr(temp_str, "keepHex-low-E")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_E; + else + { + if(strstr(temp_str, "keepHex-low-F")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_F; + else + { + if(strstr(temp_str, "toAscii-low-0")) + mib_param_input_ptr->input_param_type = TOASCII_LOW_0; + else + { + if(strstr(temp_str, "keepAsc-low-F")) + mib_param_input_ptr->input_param_type = KEEPASC_LOW_F; + else + { + printf("[debug] Error: There is not input param like %s.line:%d.\r\n",temp_str,mib_line_count); + return 0; + } + } + } + } + } + } + } + field_state=7; + new_line=1; + break; + case 12: //meet the "[v]1[opt]Spare" + mib_param_select_ptr = &mib_param_select_array[mib_param_select_index++]; + mib_node_param_ptr->select_ptr[mib_node_param_ptr->select_total++] = mib_param_select_ptr; + temp_ch=strtok(data_arr,"[]"); //'V' + temp_ch=strtok(NULL,"[]"); //'1' + for(i=0;inumber = (BYTE)atoi(temp_ch); + } + else + { + field_state=13; + break; + } + temp_ch=strtok(NULL,"[]"); //'opt' + temp_ch=strtok(NULL,"[]"); //'Spare' + if(temp_ch!=NULL) + strcpy(mib_param_select_ptr->description, temp_ch); + else + printf("[Debug] : There is no select option .line:%d.\r\n",mib_line_count); + select_start_flag=1; + field_state=1; + new_line=1; + break; + } + //if(*p!='\0') + // p++; + } + break; + case 8: + i=0; + if(remark_start_flag==0) + { + temp_ch = strstr(data_arr, "Remark"); + + if(temp_ch != NULL) + { + temp_ch+=6; + for(i=0;iremark_ptr=NULL; + leaf_state=1; + break; + } + else + strcpy(temp_str,temp_ch+i); + } + else + leaf_state=10; + } + else + { + if(strstr(data_arr,"[End]")==NULL) + strcpy(temp_str,data_arr); + else + { + remark_start_flag=0; + leaf_state=9; + break; + } + } + strcat(temp_str,"\n"); + /* + if(strlen(temp_str)>0) + { + for(i=strlen(temp_str)-1;i>0;i--) + { + if(temp_str[i]==' ' || temp_str[i]=='\n') + temp_str[i]='\0'; + else + break; + } + } + */ + size=strlen(temp_str); + if(remark_start_flag==1) + strcat(leaf_node->remark_ptr,temp_str); + else + memcpy(heap_remark_curr,temp_str,sizeof(char)*(size+1)); + if(remark_start_flag==0) + leaf_node->remark_ptr=heap_remark_curr; + heap_remark_index+=size+1; + heap_remark_curr=heap_remark+heap_remark_index; + remark_start_flag=1; + //strcpy(father_node_ptr->remark, temp_str); + break; + case 9: + temp_ch = strstr(data_arr, "[End]"); + if(temp_ch != NULL) + { + + return 1; + } + else + leaf_state = 10; + break; + } + } + return 1; +} + + + + +/* +* +* Fun: analyze_setTemplate +* +* Desc: analyze the text of the setTemplate field, create and register field nods to the father nod which father_nod_ptr points to +* +* Ret: successful: 1, fail: 0 +* +* Notes: Wang Jian add +* +* File: debug.c +* + +int analyze_setTemplate(FILE *fp, mib_node *father_node_ptr) +{ + char temp_str[1024*6], *temp_ch, stop_ch[32], temp_ch_2; + int state = 0,i; + DWORD size; + mib_child_node *mib_child_node_ptr = NULL; + mib_param_select *mib_param_select_ptr = NULL; + mib_param_input *mib_param_input_ptr = NULL; + mib_node_param *mib_node_param_ptr = NULL; + fpos_t pos_3; + + strcpy(stop_ch , "["); + while(!feof(fp)) + { + read_until(fp, temp_str, stop_ch); + if(mib_node_param_ptr) + { + if(temp_str[strlen(temp_str)-3]=='#' && temp_str[strlen(temp_str)-2]=='*' && temp_str[strlen(temp_str)-1]=='#') + { + father_node_ptr->enable_field_id=mib_node_param_ptr->id-1;//remember the param id + //remember the enable select id,no need ,default is 1 or 0 + } + if(temp_str[strlen(temp_str)-3]=='#' && temp_str[strlen(temp_str)-2]=='#' && temp_str[strlen(temp_str)-1]=='*') + {//remmember the param id and the save select id + module_save_flag[father_node_ptr->module_index].module_index=father_node_ptr->module_index; + module_save_flag[father_node_ptr->module_index].save_field_id=father_node_ptr->total_child_nodes; + //father_node_ptr->max_access=4; + module_save_flag[father_node_ptr->module_index].save_select_id=mib_node_param_ptr->select_total; + for(i=0;i<32;i++) + module_save_flag[father_node_ptr->module_index].oid[i]=father_node_ptr->oid[i]; + module_save_flag[father_node_ptr->module_index].oid_len=father_node_ptr->oid_len; + } + } + //printf("setTem state: %d , temp_str: %s\r\n",state,temp_str); + switch(state) + { + case 0: // name of the father node, not save, not null + strcpy(stop_ch , "]"); + state = 1; + break; + case 1: // find unit or remark + if( strstr(temp_str, "remark") != NULL ) + { + strcpy(stop_ch,";"); + state = 18; + } + else if( strstr(temp_str, "unit") != NULL ) + { + strcpy(stop_ch,"["); + state = 2; + } + else + { + printf("[debug] Error: Fail to find [unit] or [remark] in the setTemplate.\r\n"); + return 0; + } + break; + case 2: // apply a mib_node_param and fill its name + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the field name after the string [unit] in the setTemplate.\r\n"); + return 0; + } + if (mib_node_param_index >= MIB_MAX_NODE_PARAMS) + { + printf("[debug] Error: There are not enough mib_node_param in the array.\r\n"); + return 0; + } + mib_node_param_ptr = &mib_node_param_array[mib_node_param_index++]; + strcpy( mib_node_param_ptr->name, temp_str); + mib_node_param_ptr->id = (BYTE)(father_node_ptr->total_child_nodes+1); + mib_node_param_ptr->parent_ptr=father_node_ptr; + if (!(mib_child_node_ptr = create_mib_child_node(temp_str, father_node_ptr->total_child_nodes+1))) + { + printf("[debug] Error: Faile to Create child nod: [%s].\r\n", temp_str); + return 0; + } + if (!register_child_node(father_node_ptr, mib_child_node_ptr)) + { + printf("[debug] Error: Fail to register the child nod which named [%s].\r\n",temp_str); + return 0; + } + mib_child_node_ptr->child_ptr = mib_node_param_ptr; + + strcpy(stop_ch,"]"); + state = 3; + break; + case 3: + if( strstr(temp_str, "u") == NULL ) + { + printf("[debug] Error: Fail to find [%s] after [%s] in the setTemplate.\r\n", "u", "unit"); + return 0; + } + strcpy(stop_ch,"."); + state = 4; + break; + case 4: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the byte_begin in the setTemplate.\r\n"); + return 0; + } + mib_node_param_ptr->byte_begin = (BYTE)atoi(temp_str); + strcpy(stop_ch,"-"); + state = 5; + break; + case 5: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the bit_begin in the setTemplate.\r\n"); + return 0; + } + mib_node_param_ptr->bit_begin = (BYTE)atoi(temp_str); + strcpy(stop_ch,"."); + state = 6; + break; + case 6: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the byte_end in the setTemplate.\r\n"); + return 0; + } + mib_node_param_ptr->byte_end = (BYTE)atoi(temp_str); + strcpy(stop_ch,"["); + state = 7; + break; + case 7: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the bit_end in the setTemplate.\r\n"); + return 0; + } + mib_node_param_ptr->bit_end = (BYTE)atoi(temp_str); + strcpy(stop_ch,"]"); + state = 8; + break; + case 8: + if( strstr(temp_str, "u") == NULL ) + { + printf("[debug] Error: Fail to find [%s] after [%s] in the setTemplate.\r\n", "u", "u"); + return 0; + } + strcpy(stop_ch,"["); + state = 9; + break; + case 9: // meet "select" or "input" + if( strstr(temp_str, "select") != NULL ) + state = 10; + else + { + if( strstr(temp_str, "input") != NULL ) + { + state = 15; + } + else + { + printf("[debug] Error: Fail to find [%s] or [%s] in the setTemplate.\r\n", "select", "input"); + return 0; + } + } + strcpy(stop_ch,"]"); + break; + case 10: // "v" or "remark" or "unit" + if( strstr(temp_str, "v") != NULL ) + { + strcpy(stop_ch,"["); + state = 11; + } + else + { + if( strstr(temp_str, "unit") != NULL ) + { + strcpy(stop_ch,"["); + state = 2; + } + else + { + if( strstr(temp_str, "remark") != NULL ) + { + strcpy(stop_ch, ";"); + // may meet "[uint]" or a ';', so must handle the whole remark field and then find "[unit]" or ';' + state = 18; + } + else + { + printf("[debug] Error: Fail to find [%s] or [%s] or [%s] in the setTemplate.\r\n", "v", "unit", "remark"); + return 0; + } + } + } + break; + case 11: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the select number in the setTemplate.\r\n"); + return 0; + } + if(mib_param_select_index >= MIB_MAX_PARAM_SELECTS) + { + printf("[debug] Error: There are not enough mib_param_selects in the array.\r\n"); + return 0; + } + mib_param_select_ptr = &mib_param_select_array[mib_param_select_index++]; + mib_node_param_ptr->select_ptr[mib_node_param_ptr->select_total++] = mib_param_select_ptr; + mib_param_select_ptr->number = (BYTE)atoi(temp_str); + strcpy(stop_ch,"]"); + state = 12; + break; + case 12: + if( strstr(temp_str, "opt") == NULL ) + { + printf("[debug] Error: Fail to find [%s] after [%s] in the setTemplate.\r\n", "opt", "v"); + return 0; + } + strcpy(stop_ch,"["); + + fgetpos(fp, &pos_3); + while(!feof(fp)) + { + temp_ch_2 = fgetc(fp); + if(temp_ch_2 == '[') + { + strcpy(stop_ch,"["); + break; + } + else if(temp_ch_2 == ';') + { + strcpy(stop_ch,";"); + break; + } + } + fsetpos(fp, &pos_3); + + state = 13; + break; + case 13: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the description of the select option in the setTemplate.\r\n"); + return 0; + } + if( (temp_ch=strchr(temp_str, 0xd)) != NULL ) + *temp_ch = '\0'; + if( (temp_ch=strchr(temp_str, 0xa)) != NULL ) + *temp_ch = '\0'; + strcpy(mib_param_select_ptr->description, temp_str); + if(stop_ch =="[") + strcpy(stop_ch,"]"); + else + { + strcpy(stop_ch,";"); + return 1; + } + state = 10; + break; + case 15: // has meet "input" + if( strstr(temp_str, "v") == NULL ) + { + printf("[debug] Error: Fail to find [%s] after [%s] in the setTemplate.\r\n", "v", "input"); + return 0; + } + state = 16; + strcpy(stop_ch,"["); + break; + case 16: + if (mib_param_input_index >= MIB_MAX_PARAM_INPUTS) + { + printf("[debug] Error: There are not enough mib_param_inputs in the array.\r\n"); + return 0; + } + mib_param_input_ptr = &mib_param_input_array[mib_param_input_index++]; + mib_node_param_ptr->input_ptr = mib_param_input_ptr; + + if(strstr(temp_str, "toDec-high-0")) + { + mib_param_input_ptr->input_param_type = TODEC_HIGH_0; + } + else + { + if(strstr(temp_str, "keepHex-high-0")) + mib_param_input_ptr->input_param_type = KEEPHEX_HIGH_0; + else + { + if(strstr(temp_str, "keepHex-low-0")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_0; + else + { + if(strstr(temp_str, "keepHex-low-E")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_E; + else + { + if(strstr(temp_str, "keepHex-low-F")) + mib_param_input_ptr->input_param_type = KEEPHEX_LOW_F; + else + { + if(strstr(temp_str, "toAscii-low-0")) + mib_param_input_ptr->input_param_type = TOASCII_LOW_0; + else + { + if(strstr(temp_str, "keepAsc-low-F")) + mib_param_input_ptr->input_param_type = KEEPASC_LOW_F; + else + { + printf("[debug] Error: There is not input param like %s.\r\n",temp_str); + return 0; + } + } + } + } + } + } + } + strcpy(stop_ch,"]"); + state = 17; + break; + case 17: + if( strstr(temp_str, "unit") != NULL ) + { + strcpy(stop_ch,"["); + state = 2; + } + else + { + if( strstr(temp_str, "remark") != NULL ) + { + strcpy(stop_ch, ";"); + // may meet "[uint]" or a ';', so must handle the whole remark field and then find "[unit]" or ';' + state = 18; + } + else + { + printf("[debug] Error: Fail to find [%s] or [%s] in the setTemplate.\r\n", "unit", "remark"); + return 0; + } + } + break; + case 18: + if(strlen(temp_str) == 0) + { + father_node_ptr->remark_ptr=NULL; + return 1; + } + else + { + while((temp_ch = strstr(temp_str, "\n")) != NULL) + { + temp_ch[0] = ' '; + } + while((temp_ch = strstr(temp_str, "

")) != NULL) + { + temp_ch[0] = '\n'; + temp_ch[1] = ' '; + temp_ch[2] = ' '; + temp_ch[3] = '\r'; + temp_ch[4] = ' '; + temp_ch[5] = ' '; + temp_ch[6] = ' '; + temp_ch[7] = ' '; + } + while((temp_ch = strstr(temp_str, "
")) != NULL) + { + temp_ch[0] = ' '; + temp_ch[1] = ' '; + temp_ch[2] = ' '; + temp_ch[3] = ' '; + } + size=strlen(temp_str); + memcpy(heap_remark_curr,temp_str,sizeof(char)*(size+1)); + father_node_ptr->remark_ptr=heap_remark_curr; + heap_remark_index+=size+1; + heap_remark_curr=heap_remark+heap_remark_index; + //strcpy(father_node_ptr->remark, temp_str); + return 1; + } + } + } + printf("[debug] Error: There is an Error in the state %d in the setTemplate.\r\n", state); + return 0; +} // end of analyze_setTemplate + + +* +* Fun: MIB_create_leaves +* +* Desc: Create the leaves of the MIB tree in memory using the name of configure file which lists mib files +* +* Ret: 1: Successful; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* + +int MIB_create_leaves(char *conf_dir, char *sysConf_file, char *param_list_file) +{ + FILE *fp_list, *fp_param; + char ch, file_name[256], temp_str[256],out_text[32], temp_str_2[DEBUG_OMCBUF_LEN]; + DWORD OID[32]; + int obj_num, oid_len, state, index, Disable; + fpos_t pos_1, pos_2; + mib_node *grand_node_ptr, *father_node_ptr; + mib_child_node *mib_child_node_ptr; + int module_index,i; + char total_instance[4]; + + mib_node_param_index = 0; + mib_param_select_index = 0; + mib_param_input_index = 0; + + memset((BYTE *)mib_param_select_array, 0, sizeof(mib_param_select) * MIB_MAX_PARAM_SELECTS); + memset((BYTE *)mib_param_input_array, 0, sizeof(mib_param_input) * MIB_MAX_PARAM_INPUTS); + memset((BYTE *)mib_node_param_array, 0, sizeof(mib_node_param) * MIB_MAX_NODE_PARAMS); + grand_node_ptr = NULL; + father_node_ptr = NULL; + + strcpy(temp_str, ""); + strcpy(temp_str_2, ""); + + strcpy(file_name, ""); + strcpy(file_name, conf_dir); + strcat(file_name, param_list_file); + + if((fp_list = fopen(file_name, "r")) == NULL) + { + printf("[debug] Error: cannot open param_list_file: [%s].\n",file_name); + return 0; + } + + while(!feof(fp_list)) + { + strcpy(file_name, ""); + strcpy(file_name, conf_dir); + strcpy(temp_str, ""); + if( read_line(fp_list, temp_str) == 0) + continue; + + if(!( (strstr(temp_str, "OBJ_")) && (strstr(temp_str, "_paramConf.csv"))) ) + { + strcpy(temp_str, "OBJ_***_paramConf.csv"); + printf("[debug] Error: The name of a mib_param_file should like %s, the * presents digit. \nAnd we need the digit to find the OID prefix of this file.\n",temp_str); + fclose(fp_list); + return 0; + } + + for(index = 4; (index < 7) && (temp_str[index] != '_'); index++) + { + temp_str_2[index - 4] = temp_str[index]; + } + temp_str_2[index - 4] = '\0'; + i=0; + while(i256) + { + printf("the max init value long is 256!\r\n"); + printf(father_node_ptr->name); + strcpy(temp_str_2,""); + for(i=0;i<32;i++) + { + printf("%ld.",father_node_ptr->oid[i]); + strcat(temp_str_2,out_text); + } + printf("oid:%s\n",temp_str_2); + strcpy(temp_str_2,""); + printf("length:%d\n",strlen(temp_str)); + printf("OBJ_%d_param.cvs\r\nstring:",obj_num); + printf(temp_str); + return 0; + } + } + state++; + break; + case 14: + fgetpos(fp_param, &pos_1); + state++; + break; + case 19: + //printf("state: %d. ",state); + for(index=0;index<10;index++) + { + read_until(fp_param, temp_str, ";"); + OID[oid_len + index] = atoi(temp_str); + //printf("%ld. ",OID[oid_len + index]); + if(OID[oid_len + index] == 0) + break; + } + read_until(fp_param, temp_str, ";"); + read_until(fp_param, temp_str, "\n");//0x0a + if(Disable==0) // used + { + fgetpos(fp_param, &pos_2); + + fsetpos(fp_param, &pos_1); + if(fgetc(fp_param) != ';') + { + fsetpos(fp_param, &pos_1); + + father_node_ptr = search_mib_node(grand_node_ptr, OID, oid_len + index); + if( father_node_ptr == NULL ) + { + int length = oid_len + index; + printf("[debug] Error: can not find the father node whose oid is %d",(int)OID[0]); + for(index = 1; index < length; index ++) + printf(".%d",(int)OID[index]); + printf("\ngrand_father->name: %s, OID= %d",grand_node_ptr->name, (int)grand_node_ptr->oid[0]); + for(index = 1; index < grand_node_ptr->oid_len; index ++) + printf(".%d",(int)grand_node_ptr->oid[index]); + printf("\n"); + for(index=0; indextotal_child_nodes; index++) + { + mib_child_node_ptr=grand_node_ptr->child_nodes[index]; + if(mib_child_node_ptr) + printf("oid: %d, name: %s\n", (int)mib_child_node_ptr->oid,grand_node_ptr->child_nodes[index]->name); + } + fclose(fp_param); + fclose(fp_list); + return 0; + } + else + { + if(strlen(total_instance)) + father_node_ptr->total_instance=atoi(total_instance); + else + father_node_ptr->total_instance=0; + strcpy(father_node_ptr->init_value,curr_instance_value); + father_node_ptr->module_index=module_index; + if(analyze_setTemplate(fp_param, father_node_ptr) != 1) + { + printf("analyze_setTemplate2 fail.\n"); + fclose(fp_param); + fclose(fp_list); + return 0; + } + } + } + fsetpos(fp_param, &pos_2); + } + state = 0; + break; + default: + ch = fgetc(fp_param); + if( ch == ';' ) + state++; + break; + } + } + if(state == 0) + fclose(fp_param); + else + { + printf("[debug] Error: There is an error in the mib_param_file %s.\n", file_name); + fclose(fp_param); + fclose(fp_list); + return 0; + } + } + fclose(fp_list); + return 1; +}// end of MIB_create_leaves +*/ + + + + +/* +* +* Fun: create_node +* +* Desc: create and register node using the given parameters +* +* Ret: successful: 1, fail: 0 +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_node *create_node(char *line, char *nod_name, int instance, mib_node *father_ptr, DWORD *last_node_oid) +{ + mib_node *mib_node_ptr, *father_node_ptr; + mib_child_node *mib_child_node_ptr; + char *tmp_ch, father_name[64], id[32]; + DWORD ID_c=0, curr_oid[32]; + int index , curr_oid_len; + FILE *fp_conf; + char file_name[128]; + char space[32]="-> ";; + + strcpy(file_name, ""); + + strcpy(file_name, MIB_FILES_DIR); + strcat(file_name, MIB_WRITE_TREE ); + + if((fp_conf = fopen(file_name,"a+")) == NULL) + { + printf("[debug] Error: cannot open conf_file: [%s].\r\n",file_name); + return 0; + } + + strcpy(father_name, ""); + strcpy(id, ""); + //fprintf(fp_conf,"line = [%s], nod_name = [%s].\r\n",line , nod_name); + tmp_ch = strchr(line, '}'); // collect the father_name and nod's ID from the line + if(tmp_ch != NULL) + { + tmp_ch = strchr(line, '{'); + if(tmp_ch != NULL) + { + tmp_ch = &tmp_ch[1]; + tmp_ch = pick_first_word(tmp_ch, father_name); + if( strchr(father_name, '}') ) + { + printf("[debug] Error: There is not ID between '{' and '}' in line [%s].\r\n",line); + fclose(fp_conf); + return 0; + } + pick_first_word(tmp_ch, id); + tmp_ch = strchr(id, '}'); + if(tmp_ch != NULL) + *tmp_ch = '\0'; + if(strlen(id) == 0) + { + printf("[debug] Error: There is not ID between '{' and '}' in line [%s].\r\n",line); + fclose(fp_conf); + return 0; + } + ID_c = atol(id); + + } + else + { + printf("[debug] Error: Can not find a '{' as a beginning of a text.\r\n"); + fclose(fp_conf); + return NULL; + } + } + else + { + printf("[debug] Error: Can not find a '}' as an ending of a text.\r\n"); + fclose(fp_conf); + return NULL; + } + + father_node_ptr = find_node(father_ptr, father_name, 1, last_node_oid); + if(!father_node_ptr) + { + fprintf(fp_conf,"father_ptr->name: %s , father_name: %s\r\n",father_ptr->name,father_name); + printf("[debug] Error: Can not find the father nod which named [%s].\r\n",father_name); + fclose(fp_conf); + return NULL; + } + + for(index=0; index<32; index++) + curr_oid[index] = father_node_ptr->oid[index]; + curr_oid_len = father_node_ptr->oid_len; + + curr_oid[curr_oid_len++] = ID_c; + + if(!(mib_node_ptr = create_mib_node(nod_name, curr_oid_len, curr_oid, instance))) + { + printf("[debug] Error: Create nod: [%s] fail. mib_node_index = %d.\r\n", nod_name, mib_node_index); + fclose(fp_conf); + return 0; + } + + //mib_node_ptr->module_index=gobal_module_index-1; + + fprintf(fp_conf,"Create node: %s(OID: ",nod_name); + for(index=0;index "); + // this nod is not the first nod, must register it to its father nod and itself. + if (!(mib_child_node_ptr = create_mib_child_node(nod_name, ID_c))) + { + printf("[debug] Error: Create child nod: [%s] fail.\r\n", nod_name); + fclose(fp_conf); + return NULL; + } + + if (!register_child_node(father_node_ptr, mib_child_node_ptr)) + { + printf("[debug] Error: Can not register the child nod which named [%s].\r\n",nod_name); + fclose(fp_conf); + return NULL; + } + + //fprintf(fp_conf,"register the child nod [%s].father nod name [%s] father nod total_child_nodes [%d].\r\n",nod_name,father_node_ptr->name, father_node_ptr->total_child_nodes); + for(index = 0; index< father_node_ptr->total_child_nodes; index++) + { + mib_child_node_ptr=father_node_ptr->child_nodes[index]; + if(mib_child_node_ptr) + fprintf(fp_conf,"%s %s(%d)\r\n", space,father_node_ptr->child_nodes[index]->name,index); + } + + if (!register_node(mib_node_ptr, curr_oid, curr_oid_len)) + { + printf("[debug] Error: Can not register the nod which named [%s].\r\n",nod_name); + fclose(fp_conf); + return NULL; + } + memset(last_node_oid, 0, sizeof(DWORD) * 32); + for(index =0; index < mib_node_ptr->oid_len; index++) + last_node_oid[index] = mib_node_ptr->oid[index]; + fprintf(fp_conf,"\r\n\r\n"); + fclose(fp_conf); + return mib_node_ptr; +} // end of create_node + +/* +* +* Fun: create_mib_child_node +* +* Desc: create a mib_child_node +* +* Ret: return the mib_child_node pointer if successful, return null if fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_child_node *create_mib_child_node(char *name, DWORD oid) +{ + mib_child_node *mib_child_node_ptr; + + if (mib_child_node_index >= MIB_MAX_CHILD_NODES) + return NULL; + + mib_child_node_ptr = &mib_child_nodes[mib_child_node_index++]; + + strcpy(mib_child_node_ptr->name, name); + mib_child_node_ptr->oid = oid; + mib_child_node_ptr->child_ptr = NULL; + + return mib_child_node_ptr; +} // end of create_mib_child_node + + + +/* +* +* Fun: create_mib_node +* +* Desc: create a mib_node +* +* Ret: return the mib_node pointer if successful, return null if fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_node *create_mib_node(char *name, BYTE oid_len, DWORD *oid, WORD total_instance) +{ + mib_node *mib_node_ptr; + if (mib_node_index >= MIB_MAX_NODES) + return NULL; + + mib_node_ptr = &mib_nodes[mib_node_index++]; + /* + index=0xFF; + if(oid_len>9) + { + memcpy(temp_oid, oid, oid_len * sizeof(DWORD)); + max_len=0; + for(j=0;subsys_module[j].index!=0xFF;j++) + { + for(i=8;subsys_module[j].oid[i-6]!=0 && i<14;i++) + if(temp_oid[i]!=subsys_module[j].oid[i-6]) + break; + if(subsys_module[j].oid[i-6]==0 && i>max_len) + { + max_len=i; + index=j; + } + } + if(index!=0xFF) + mib_node_ptr->module_index=index; + } + */ + strcpy(mib_node_ptr->name, name); + mib_node_ptr->oid_len = oid_len; + memcpy(mib_node_ptr->oid, oid, oid_len * sizeof(DWORD)); + mib_node_ptr->total_instance = total_instance; + mib_node_ptr->curr_instance = 0; + mib_node_ptr->parent_ptr = NULL; + //mib_node_ptr->mib_proc = mib_proc; + + return mib_node_ptr; +} // end of create_mib_node + + + + +int register_node(mib_node *mib_node_ptr, DWORD *oid, BYTE oid_len) +{ + mib_node *node_ptr; + mib_child_node *child_node_ptr = NULL; + BYTE i, loop_times; + WORD child_index; + + if (oid_len <= mib_root_node->oid_len) + return 0; + if ((loop_times = oid_len - mib_root_node->oid_len) >= 20) + return 0; + + node_ptr = mib_root_node; + for (i = 0; i < loop_times; i++) + { + if ((child_index = find_child_index(node_ptr, oid[mib_root_node->oid_len + i], NULL, 0)) >= MIB_MAX_CHILD_NODES_PER_NODE) + return 0; + child_node_ptr = node_ptr->child_nodes[child_index]; + if(child_node_ptr) + if (i != (loop_times - 1)) + { + if (child_node_ptr->child_ptr == NULL) + return 0; + node_ptr = (mib_node *) child_node_ptr->child_ptr; + } + } + + child_node_ptr->child_ptr = mib_node_ptr; + mib_node_ptr->parent_ptr = node_ptr; + + return 1; +} + + +/* +* +* Fun: register_child_node +* +* Desc: register a child node to its father mib node +* +* Ret: return 1 if successful, return 0 if fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int register_child_node(mib_node *mib_node_ptr, mib_child_node *mib_child_node_ptr) +{ + char text_out[128]; + int index; + mib_child_node *tmp_child_node; + if (mib_node_ptr->total_child_nodes >= MIB_MAX_CHILD_NODES_PER_NODE) + { + printf("[Debug] Error: The total child is more then the max child number.%d,MAX:%d.\r\n",mib_node_ptr->total_child_nodes,MIB_MAX_CHILD_NODES_PER_NODE); + return 0; + } + if(!mib_child_node_ptr) + { + sprintf(text_out,"[Debug] : The child node is NULL! Father:%s,ID: %d\r\n",mib_node_ptr->name,mib_node_ptr->total_child_nodes); + TxtColor(BRIGHT,RED,BLACK,text_out); + printf(text_out); + return 0; + } + for (index = 0; index < mib_node_ptr->total_child_nodes; index++) + { + tmp_child_node = mib_node_ptr->child_nodes[index]; + if ( mib_child_node_ptr->oid <= tmp_child_node->oid ) + { + printf("[debug] Error: The oid have register or it is not written by ascending! Can not be Reisterted again\r\nLine: %d.\r\n", mib_line_count); + exit(1); + } + } + mib_node_ptr->child_nodes[mib_node_ptr->total_child_nodes] = mib_child_node_ptr; + mib_node_ptr->total_child_nodes++; + return 1; +}// end of register_child_node + +//////////////////////////////End of Create OID Tree////////////////////// + + + +void debug_mmi_remark() +{ + + //char out_char[16]; + char out_text[128]; + WORD out_len=0; + WORD i; + BYTE j,k,m; + BYTE line_count=0; + char ch; + switch(debug_remark_flag) + { + case 0: + return; + case 1: + if(mib_curr_node->remark_ptr==NULL) + { + debug_ascii_out_proc("Fail : Sorry,No Remark for the object!\r\n"); + return; + } + debug_ascii_out_proc("Remark : "); + for(i=0;*(mib_curr_node->remark_ptr+i);i++) + { + ch=mib_curr_node->remark_ptr[i]; + if(ch!='\n' && ch!='\t' && ch!=' ') + break; + } + if(!*(mib_curr_node->remark_ptr+i)) + { + debug_remark_flag=0; + debug_cfg_end=1; + return; + } + debug_remark_ptr=i; + debug_remark_flag=2; + debug_cfg_end=0; + remark_meet_lf=0; + break; + case 2: + if(debug_remark_ptr) + { + strcpy(out_text," "); + out_len=10; + } + else + { + strcpy(out_text," "); + out_len=3; + j=3; + } + if(remark_meet_lf) + { + j=3; + strcat(out_text," "); + out_len=13; + remark_meet_lf=0; + } + else if(debug_remark_ptr) + j=0; + i=debug_remark_ptr; + for(;*(mib_curr_node->remark_ptr+i)!='\0';i++) + { + ch=mib_curr_node->remark_ptr[i]; + if(ch!='\n' && ch!='\t') + { + *(out_text+out_len++)=ch; + j++; + } + if((ch=='\n' && i) || j==70) + { + if(ch!='\n') + { + while((ch=mib_curr_node->remark_ptr[i+1])) + { + if(ch==' ' || ch=='\t') + { + i++; + continue; + }else if(ch=='\n') + { + i++; + j=0; + continue; + } + else + break; + } + } + else + { + i++; + while((ch=*(mib_curr_node->remark_ptr+i))) + if(ch!=' ' || ch!='\n' || ch!='\t') + break; + else + i++; + if(*(mib_curr_node->remark_ptr+i)=='\0') + line_count=3; + i--; + } + + *(out_text+out_len++)='\r'; + *(out_text+out_len++)='\n'; + *(out_text+out_len)='\0'; + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); + line_count++; + if(j==70) + m=10; + else + { + m=13; + remark_meet_lf=1; + } + if(line_count==3) + { + debug_remark_ptr=(mib_curr_node->remark_ptr[i]=='\n')?(i+1):i; + if(*(mib_curr_node->remark_ptr+i)=='\0') + { + debug_remark_flag=0; + debug_remark_ptr=0; + remark_meet_lf=0; + debug_cfg_end=1; + } + return; + } + *out_text='\0'; + out_len=0; + for(k=0;kremark_ptr+i)=='\0' && j!=0 && line_count<3) + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); + if(!(out_text[out_len-1]=='\n' && out_text[out_len-2]=='\r')) + debug_ascii_out_proc("\r\n"); + debug_remark_flag=0; + debug_remark_ptr=0; + remark_meet_lf=0; + debug_cfg_end=1; + break; + } +} + + +void register_host() +{ + char file_name[48],temp_str[128],ch2[32],*p,*q,*m,ip[4],stop_ch[32]; + char temp_str2[32]; + FILE *fp; + BYTE i,j,state,group_index,member_index,max_group; + WORD module_index; + group_index=0; + member_index=0; + /* + strcpy(file_name, ""); + strcpy(file_name, MIB_FILES_DIR); + strcat(file_name, MIB_SYSTEM_CONFIG_FILE ); + */ + /* + if((fp = fopen(file_name, "r")) == NULL) + { + sprintf(temp_str, "Fail : cannot open system config file: [%s].\r\n",file_name); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return ; + } + strcpy(stop_ch," "); + module_index=0; + state=1; + while(!feof(fp)) + { + read_until(fp, temp_str,stop_ch); + if(strlen(temp_str)>64) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : The config file is not right format!\r\n"); + return ; + } + switch(state) + { + case 1: //get the module oid + for(i=0;i<=12;i++) //del the root_oid 6X2=1.3.6.1.4.1. + { + p=temp_str+i; + } + subsys_module[module_index].index=module_index; + i=0; + for(j=0;j<6;j++) + { + while(*(p+i)!='.' && *(p+i)!='\0') + { + oid[i]=*(p+i); + i++; + } + oid[i]='\0'; + subsys_module[module_index].oid[j]=atoi(oid); + if(*(p+i)=='\0') + break; + q=p+i+1; + p=q; + i=0; + } + state=2; + break; + case 2: //get the module name + strcpy(subsys_module[module_index].name,temp_str); + state=3; + break; + case 3://get the module obj_type_num + strcpy(subsys_module[module_index].obj_type_no,temp_str); + while((ch=fgetc(fp))!=0xa && ch!=EOF) + {} + if(ch==EOF) + break; + state=1; + module_index++; + break; + } + + } + fclose(fp); + */ + strcpy(file_name, ""); + strcpy(file_name, MIB_FILES_DIR); + strcat(file_name, MIB_SYSTEM_IP_LIST_FILE); + + if((fp = fopen(file_name, "r")) == NULL) + { + sprintf(temp_str, "Fail : cannot open system ip list file: [%s].\r\n",file_name); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return; + } + state=1; + module_index=0; + strcpy(stop_ch," "); + while(!feof(fp)) + { + read_line(fp, temp_str); + if(temp_str[0]=='/' && temp_str[1]=='/') + { + continue; + } + if(strlen(temp_str)==0) + continue; + else if(strlen(temp_str)>64) + { + printf("Error : The config file is not right format!\r\n"); + return ; + } + for(i=0;i=1) + { + for(j=i-1;j>0;j--) + { + if(temp_str[j]!=' ') + break; + } + } + strncpy(temp_str2,temp_str,j+1); + temp_str2[j+1]='\0'; + m=temp_str+i+1; + module_host[module_index].index=module_index; + strcpy(module_host[module_index].host_name,temp_str2); + for(i=0;i=1) + { + if(module_save_flag[curr_module].save_field_id==0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : The module do not contain save flag!\r\n"); + save_flag=0; + return; + } + if(mib_curr_node->module_index!=curr_module || save_flag==2) + { + if(debug_cfg==1) + temp_mib_node=mib_curr_node; + else if(debug_cfg==2) + { + tmp_menu_node=menu_curr_node; + temp_mib_node=mib_curr_node; + } + find_node_ptr=search_mib_node(mib_root_node,module_save_flag[curr_module].oid,module_save_flag[curr_module].oid_len); + if(find_node_ptr) + mib_curr_node=find_node_ptr; + mib_child_node_ptr=mib_curr_node->child_nodes[module_save_flag[curr_module].save_field_id-1]; + if(mib_child_node_ptr) + param_node = (mib_node_param *)mib_child_node_ptr->child_ptr; + else + printf("[Debug] : The child node is NULL. Father_node:%s,ID:%d.\r\n",mib_curr_node->name,module_save_flag[curr_module].save_field_id-1); + strcpy(temp_text,"#0."); + gcvt((double)(module_save_flag[curr_module].save_field_id),2,temp_text2); + strcat(temp_text,temp_text2); + strcat(temp_text,"="); + sprintf(temp_text2,"%X",param_node->select_ptr[module_save_flag[curr_module].save_select_id-1]->number); + //gcvt((double)param_node->select_ptr[module_save_flag[curr_module].save_select_id]->number,4,temp_text2); + strcat(temp_text,temp_text2); + if(save_flag==1) + save_flag=3; + else + save_flag=4; + debug_mmi_set(temp_text); + + } + } + else + debug_color_out(BRIGHT,RED,BLACK,"Fail : No change the data ,so not need to save!\r\n"); + debug_ascii_out_proc("Status : "); + sprintf(temp_text2,"Saving the module of %s,NOW!\r\n",subsys_module[curr_module].name); + debug_color_out(BRIGHT,CYAN,BLACK,temp_text2); + +} + + +///////////////////////////////Create Menu Tree////////////////////// +int create_menu_tree(char *conf_dir,char *menu_page,mib_node *sys_node) +{ + char *p,*q,temp_str1[256],file_name[64],temp_str2[64],temp_str3[64],oid[16]; + BYTE index1,index2,sys_group,group_type;//group_type:'/' is 0,'M' is 1,'m' afer '/' is 2 + WORD index3, line_count=0; + menu_node *menu_node_ptr; + menu_node *menu_father_node; + mib_node *mib_tmp_node; + BYTE father_id[16]; + FILE *fp; + DWORD full_oid[32]; + + mib_tmp_node=search_mib_node(mib_root_node,cur_oid,9); + strcpy(file_name, ""); + strcpy(file_name, conf_dir); + strcat(file_name, menu_page); + if((fp = fopen(file_name, "r")) == NULL) + { + printf("Error: cannot open menu tree file [%s].\n",file_name); + return 0; + } + while(!feof(fp)) + { + line_count++; + if( read_line(fp,temp_str1) == 0) + continue; + if(temp_str1[0]=='#') + continue; + for(index1=0;index1name,"WXC2"); + menu_node_ptr->father_ptr=NULL; + menu_node_ptr->menu_id[0]=0; + menu_node_ptr->id_len=0; + menu_node_ptr->sys_group=9; + for(index1=0;index1<10;index1++) + menu_node_ptr->oid[index1]=0; + menu_node_ptr->menu_oid_node=search_mib_node(mib_root_node,cur_oid,9); + menu_root_node=menu_father_node=menu_node_ptr; + father_id[0]=0; + break; + } + else + { + strcpy(temp_str2,p); + q=strtok(temp_str2,"."); + index2=0; + for(index2=0;index2<16;index2++) + { + father_id[index2]=0; + } + index2=0; + father_id[index2++]=atoi(q); + while((q=strtok(NULL,"."))) + { + if(q!=NULL && isdigit(*q)) + father_id[index2++]=atoi(q); + else if(*q!='\0') + break; + } + menu_father_node=search_menu_node(menu_root_node,father_id,index2);//(BYTE)((father_id-1)/2)); + if(!menu_father_node) + { + printf("[Debug] Error: Can not find menu father node,line:%d\n",line_count); + return 0; + } + p=q; + } + } + break; + case '(' : + p++; + if(isdigit(*(p))) + { + if(group_type==0) + { + *(p+1)='\0'; + sys_group=atoi(p); + group_type=1; + *p=';'; + } + else if(group_type==1) + { + temp_str2[0]=*p; + temp_str2[1]='\0'; + menu_node_ptr->sys_group=atoi(temp_str2); + if(menu_node_ptr->sys_group==0) + { + for(index1=0;index1name);index1++) + if(menu_node_ptr->name[index1]=='_') + break; + if(index1==strlen(menu_node_ptr->name)) + { + printf("[Debug] Error: The menu item sysgroup for '8kE1' format must be '8KE1_*',line:%d\n",line_count); + return 0; + } + } + p+=2; + } + + } + break; + case 'M': + case 'm': + menu_node_ptr=&menu_nodes[menu_node_index++]; + if(menu_father_node) + menu_node_ptr->father_ptr=menu_father_node; + else + { + printf("[Debug] Error:fail to create the menu tree,id %s,line:%d\n",temp_str3,line_count); + return 0; + } + if(index3child_node[index3]=menu_node_ptr; + index3++; + menu_father_node->total_menu_child=index3; + + } + else + { + printf("The child node is more than the max number!,line:%d\n",line_count); + return 0; + } + if(*(p+1)==':') + { + p+=2; + for(index1=0;*(p+index1)!='\0';index1++) + { + if(*(p+index1)==' ') + { + break; + } + } + } + if(index1==0) + { + printf("Format is not right,eg: 'M:13 name {1.2};',line:%d\n",line_count); + return 0; + } + strncpy(temp_str2,p,index1); + temp_str2[index1]='\0'; + for(index2=0;father_id[index2]!=0;index2++) + menu_node_ptr->menu_id[index2]=father_id[index2]; + menu_node_ptr->menu_id[index2]=strtoul(temp_str2, NULL, 10); + menu_node_ptr->id_len=index2+1; + if(group_type==1) + menu_node_ptr->sys_group=sys_group; + p+=index1-1; + break; + case '[': + q=p+1; + index1=0; + while(*p!=']' && *p!='\0') + { + p++; + index1++; + } + if(*p==']') + strncpy(menu_node_ptr->name,q,index1-1); + p++; + break; + case '{': + p++; + q=p; + while(*p!='}' && *p!='\0') + { + p++; + index1++; + } + if(*p=='}') + strncpy(oid,q,index1); + p=oid; + index2=0; + for(index1=0;index1<10;index1++) + menu_node_ptr->oid[index1]=0; + index1=0; + while(*p!=';') + { + if(isdigit(*(p+index1))) + { + index1++; + continue; + } + strncpy(temp_str2,p,index1); + temp_str2[index1]='\0'; + menu_node_ptr->oid[index2++]=strtoul(temp_str2, NULL, 10); + p+=index1+1; + index1=0; + } + for(index1=0;index1<9;index1++) + full_oid[index1]=cur_oid[index1]; + for(index1=9;index1<19 && menu_node_ptr->oid[index1-9]!=0;index1++) + full_oid[index1]=(DWORD)menu_node_ptr->oid[index1-9]; + menu_node_ptr->menu_oid_node=search_mib_node(mib_tmp_node,full_oid,index1); + if(!menu_node_ptr->menu_oid_node) + { + printf("[debug] : can not find mib node ,please check oid.menu_tree.txt,line:%d\r\n",line_count); + printf("oid: "); + for(index2=0;index2Press \"Esc\" then \"Enter\"<--\r\n"); +} // end of debug_mmi_cmm_help + + +/* +* +* Fun: debug_mmi_log_status +* +* Desc: display the log status +* +* Ret: REVOID +* +* File: debug.c +* +*/ +void debug_mmi_log_status() +{ + char temp_str[256]=""; + int i; + + if(debug_log_all == 1) + strcat(temp_str, " log all\r\n"); + else + strcat(temp_str, " log none \r\n"); + if(debug_log_error_on == 1) + strcat(temp_str, " log error on\r\n"); + else + strcat(temp_str, " log error off\r\n"); + debug_ascii_out_proc(temp_str); + + strcpy(temp_str, "lot status"); + for (i=0; i < MODULE_COUNT; i++) + { + if( (i != 13) && (debug_shm_ptr->module_d[i].ascii_in_set_flag == 1)) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,temp_str); + } + } +} // end of debug_mmi_log_status + +/* +* +* Fun: debug_mmi_log +* +* Desc: send the log command(log_str) to all the other modules +* +* Ret: 1: succeful, 0: fail +* +* File: debug.c +* +*/ +int debug_mmi_log(char *log_str) +{ + char temp_str[128]=""; + int i; + + if( strstr(log_str, "all") != NULL ) + { + strcpy(temp_str, "log all"); + debug_log_all = 1; + } + else if( strstr(log_str, "none") != NULL ) + { + strcpy(temp_str, "log none"); + debug_log_all = 0; + } + else if( strstr(log_str, "error on") != NULL ) + { + strcpy(temp_str, "log error on"); + debug_log_error_on = 1; + } + else if( strstr(log_str, "error off") != NULL ) + { + strcpy(temp_str, "log error off"); + debug_log_error_on = 0; + } + else + return 0; + + for(i=0; i < MODULE_COUNT; i++) + { + if( (i !='n'-'a') && (debug_shm_ptr->module_d[i].ascii_in_set_flag == 1)) + { + debug_shm_ptr->module_d[i].ascii_in[0] = 1; + strcpy(debug_shm_ptr->module_d[i].ascii_in+1,temp_str); + } + } + return 1; +} // end of debug_mmi_log +//////////////////////////////End of CMM Command///////////////////////// + + + + +///////////////////////////////Cfg OID Tree Command///////////////// + + +/* +* +* Fun: debug_mmi_cfg_help +* +* Desc: display the commands and their usage in the configure state +* +* Ret: RVOID +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +void debug_mmi_cfg_help(char *str) +{ + char out_text[128],*ch; + BYTE i; + for(i=0;i<80 && *(str+i)!='\0';i++) + { + if(*(str+i)!=' ') + break; + } + ch=str+i; + strcpy(out_text,ch); + if(*out_text!='\0') + { + if(strncasecmp(out_text,"help",4)==0) + { + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help \r\n"); + debug_ascii_out_proc(" Show the cfg main page\r\n"); + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help command\r\n"); + debug_ascii_out_proc(" Show the usage of the command\r\n"); + } + else if(strncasecmp(out_text,"cd",2)==0) + { + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd \r\n"); + debug_ascii_out_proc(" Enter the root node:enterprises oid=1.3.6.1.4.1\r\n"); + debug_ascii_out_proc(" Usage 2: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd //\r\n"); + debug_ascii_out_proc(" Enter our system node:wxc2 oid=1.3.6.1.4.1.1373.1.3\r\n"); + debug_ascii_out_proc(" Usage 3: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd ....\r\n"); + debug_ascii_out_proc(" Enter the above node untill up to the roor node,the layer to go back \r\n"); + debug_ascii_out_proc(" can control by the point number(layers=point number-1,the max point \r\n"); + debug_ascii_out_proc(" number is 8) behind the 'cd'. eg:'cd ..' enter the parent node \r\n"); + debug_ascii_out_proc(" Usage 4: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd ./XXX or ./name\r\n"); + debug_ascii_out_proc(" Enter the child node which id or name is xxx or name\r\n"); + debug_ascii_out_proc(" Usage 5: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd ./X.X.X\r\n"); + debug_ascii_out_proc(" Enter the descendant's node whose oid is x.x.x from the current oid\r\n"); + debug_ascii_out_proc(" Usage 6: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd ../X.X.X\r\n"); + debug_ascii_out_proc(" Enter the descendant's node whose oid is x.x.x from the parent oid\r\n"); + debug_ascii_out_proc(" Usage 7: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd module\r\n"); + debug_ascii_out_proc(" Enter the module's node \r\n"); + debug_ascii_out_proc(" Usage 8: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd -name\r\n"); + debug_ascii_out_proc(" Find the node as the name from the current node\r\n"); + debug_ascii_out_proc(" Usage 9: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd --name\r\n"); + debug_ascii_out_proc(" Find the node as the name from the root node \r\n"); + } + else if(strncasecmp(out_text,"get",3)==0) + { + help_cmm(1,"get or get *","Get and printf the current instance's value of the node\r\n"); + help_cmm(2,"get #XX","Get and printf the special instance's value of the node\r\n"); + help_cmm(3,"get *.X or get *.name","Get and printf the current instance's special field value of the node\r\n"); + help_cmm(4,"get #X.X or get #x.name","Get and printf the special instance's special field value of the node\r\n"); + } + else if(strncasecmp(out_text,"set",3)==0) + { + help_cmm(1,"set or set *","Set the current instance's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(2,"set #XX ","Set the special instance's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(3,"set *.X =X or set *.name=X ","Set the current instance's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(4,"set #X.X =X or set #x.name=X ","Set the special instance's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(5,"set #X =XXX","Set the special instance's whole value to given value of the node and open the isntance ,then printf\r\n"); + } + else if(strncasecmp(out_text,"create",3)==0) + { + help_cmm(1,"creat or create *","Create an instance with the min closed instance id and set it's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(2,"create #XX","Create the special instance,and set it's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(3,"create *.X =X or create *.name=X ","Create an instance's with the min closed instance id ,and set it's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(4,"create #X.X =X or create #x.name=X ","Create the special instance,and set it's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(5,"create #X =XXX","Create the special instance,and set is's whole value to given value of the node and open the isntance ,then printf\r\n"); + } + else if(strncasecmp(out_text,"delete",3)==0) + { + help_cmm(1,"delete ","Delete the current instance ,if it is opened,clost it.set the value to default value of the node\r\n"); + help_cmm(2,"delete #XX","Delete the special instance,if it is opened,clost it.set the value to default value of the node\r\n"); + } + else if(strncasecmp(out_text,"contents",3)==0) + { + help_cmm(1,"contents ","Show the information about the object .if it is parent node ,will print the name,the all child node.if it is leaf node ,will print the module,the read-write property,the type,the current instance(the mix id of the opened instance),the total instance,the all instance which are opened,and show the current isntance and all it's field .if it is parent node\r\n"); + } + else if(strncasecmp(out_text,"list",3)==0) + { + help_cmm(1,"list [-a]","the switch of show all the field and value of the instance include the 'NULL' and the closed instance,default:off\r\n"); + help_cmm(2,"list [-e]","the switch of show opened the instance,hide the field and it's value default:off\r\n"); + help_cmm(3,"list [-r]","the switch of show the field data range.default:off\r\n"); + help_cmm(4,"list [-t]","the switch of show input data type ,default:off\r\n"); + help_cmm(5,"list [-f[X XX X]]","the switch of show the special field list in the [ ] ,default:off\r\n"); + help_cmm(6,"list [X-XX]","the switch of show the instance range form x to xxx.default:off\r\n"); + } + else if(strncasecmp(out_text,"child",3)==0) + { + help_cmm(1,"child X","Enter the child node whose id is X\r\n"); + help_cmm(2,"child name","Enter the child node whose name is 'name'\r\n"); + } + else if(strncasecmp(out_text,"parent",3)==0) + { + help_cmm(1,"parent","Enter the parent node\r\n"); + } + else if(strncasecmp(out_text,"pwd",3)==0) + { + help_cmm(1,"pwd","Show the full path and the full oid\r\n"); + } + else if(strncasecmp(out_text,"remark",3)==0) + { + help_cmm(1,"remark","Show the description of the node\r\n"); + } + else if(strncasecmp(out_text,"option",3)==0) + { + help_cmm(1,"option X","Show the select option of the fied node whose id is x of leaf node \r\n"); + help_cmm(2,"option name","Show the select option of the fied node whose name is ''name' of leaf node \r\n"); + } + else if(strncasecmp(out_text,"save",3)==0) + { + help_cmm(1,"save","save the debug\r\n"); + } + else if(strncasecmp(out_text,"quit",3)==0) + { + help_cmm(1,"quit","Quit and save teh debug\r\n"); + } + else if(strncasecmp(out_text,"find host",3)==0) + { + help_cmm(1,"find host","Find all the host who have the object about the current node\r\n"); + } + else if(strncasecmp(out_text,"select",3)==0) + { + help_cmm(1,"select X","Select the host ip list,if been selected ,the set command would do effect on the host\r\n"); + } + else if(strncasecmp(out_text,"setinst",3)==0) + { + help_cmm(1,"setinst X","Set the current instance as the special number\r\n"); + } + else if(strncasecmp(out_text,"cmm",3)==0) + { + help_cmm(1,"cmm","Enter the debug cmm state\r\n"); + } + else if(strncasecmp(out_text,"addhost",3)==0) + {} + else if(strncasecmp(out_text,"delhost",3)==0) + {} + else if(strncasecmp(out_text,"tree",4)==0) + { + help_cmm(1,"tree","Print the three layer of the tree from the current node\r\n"); + } + else + { + sprintf(out_text,"Error : Sorry, No support this command %s!\r\n" ,ch); + debug_color_out(BRIGHT,RED,BLACK,out_text); + } + } + else + { + time_t tick_2; + char time_buf_2[64]= "\0", str_buf[128]="\0"; + tick_2 = time(NULL); + debug_ascii_out_proc("\033[2J\033[1;1H"); + snprintf(time_buf_2, sizeof(time_buf_2), "%.24s", ctime(&tick_2)); + sprintf(str_buf, " -----Start Time: %s----- \r\n", time_buf_2); + debug_color_out(BRIGHT,CYAN,WHITE,str_buf); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*************************\r\n");//80-20=60/2=30 + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*"); + debug_ascii_out_proc(" "); + debug_color_out(BRIGHT,WHITE,BLACK,"Configure Help Menu");//80-20=60/2=30 + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*\r\n"); + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*************************\r\n");//80-20=60/2=30 + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc("================================================================================\r\n"); + debug_ascii_out_proc("|help : show the configure command help or main cfg menu |\r\n"); + debug_ascii_out_proc("|contents : show the contents of the current object |\r\n"); + debug_ascii_out_proc("|parent : enter the parent object of the current object |\r\n"); + debug_ascii_out_proc("|child : entr the child object of the current object |\r\n"); + debug_ascii_out_proc("|cd : go to the object use name or oid or other control char |\r\n"); + debug_ascii_out_proc("|pwd : show the current object path from the root object |\r\n"); + debug_ascii_out_proc("|tree : show the object tree from the current object node |\r\n"); + //debug_ascii_out_proc("|setins : set the instance number of the current object |\r\n"); + //debug_ascii_out_proc("|find host : find the hosts in which the current node exist. |\r\n"); + //debug_ascii_out_proc("|show host : show the hosts in which the current node exist. |\r\n"); + debug_ascii_out_proc("|select : select the host which get and set command use. |\r\n"); + debug_ascii_out_proc("|get : get the value of a paticular parameter field |\r\n"); + debug_ascii_out_proc("|set : set the value of a paticular parameter field |\r\n"); + debug_ascii_out_proc("|create : create and set the intance value of a parameter field |\r\n"); + debug_ascii_out_proc("|delete : delete an opened instance of a parameter field |\r\n"); + debug_ascii_out_proc("|cmm : change to the state of command |\r\n"); + debug_ascii_out_proc("|quit : exit the debug telnet interview |\r\n"); + debug_ascii_out_proc("================================================================================\r\n"); + } +} // end of debug_mmi_cfg_help + + + + +/* +* +* Fun: debug_mmi_cd +* +* Desc: change to a mib_node by path +* +* Ret: return 1 if successful, return 0 if fail +* +* File: debug.c +* +*/ +int debug_mmi_cd(char *path) +{ + BYTE str_len, index, index_2, index_3; + mib_node *find_node_ptr; + mib_node_param *find_node_ptr2; + DWORD OID[32]; + char temp_str[128], path_name[128], *temp_ch,temp_str2[128]; + int temp; + int i; + strcpy(path_name, path); + temp_mib_node=mib_curr_node; + for(i=0;i!=strlen(path_name);i++) + { + if(*(path+i)!=' ') + break; + } + if(*(path_name+i)=='\0') + { + index_3=6; + temp_mib_node=mib_curr_node; + mib_curr_node= mib_root_node; + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_contents(""); + //find_node_ptr=find_node(mib_root_node,"MTP3",0,0); + //if(find_node_ptr!=NULL) + // mib_curr_node=find_node_ptr; + + return 1; + } + temp_ch=path_name+i; + strcpy(path_name,temp_ch); + strcpy(temp_str,path_name); + for(i=0;i3) + strcpy(path_name,temp_ch+2); + } + if(!isdigit(*temp_ch)) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input system number!\r\n"); + return 0; + } + host_group=atoi(temp_str2); + if(host_group>GROUP_NUM-1) + { + sprintf(temp_str2,"Error : Please input valid system id,the max is %d!\r\n",GROUP_NUM-1); + debug_color_out(BRIGHT,RED,BLACK,temp_str2); + return 0; + } + } + + + + + if (!(str_len = strlen(path_name))) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : The path you put is not right for current object!\r\n"); + return 0; + } + index=0; + while(path_name[index]==' ') + { + temp=index+1; + while(path_name[temp]!='\0') + { + path_name[temp-1]=path_name[temp]; + temp++; + } + path_name[temp-1]=path_name[temp]; + } + temp=0; + if(strncmp(path_name,"--",2)==0)//locate the para or node by name + { + temp=1;//find from the root node + } + else if(path_name[0]=='-') + { + temp=2;//find from the current node + } + if(temp>0) + { + if(strlen(path_name)>80) + debug_color_out(BRIGHT,RED,BLACK,"Error : no node have so long name!\r\n"); + if(temp==1) + { + mib_curr_node=mib_root_node; + strcpy(temp_str,path_name+2); + } + if(temp==2) + strcpy(temp_str,path_name+1); + find_node_ptr= find_node(mib_curr_node, temp_str, 0, NULL); + if(find_node_ptr!=NULL) + { + mib_curr_node=find_node_ptr; + if(mib_curr_node->total_instance) + { + list_once=0; + curr_module=mib_curr_node->module_index; + register_instance(); + } + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_contents(""); + return 1; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : There is no the special node of the name!\r\n"); + return 0; + } + } + index=0; + if(path_name[0]=='.' && path_name[1]=='.' && path_name[2]=='\0') + { + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_parent(); + return 1 ; + } + while(path_name[index]=='.') + index++; + if(index>2 && path_name[index]=='\0' && index<8 ) + { + for(index_2=1;index_2oid_len-1; + if(index_3<=6) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Have reached the root!\r\n"); + debug_mmi_contents(""); + return 0; + } + mib_curr_node= search_mib_node(mib_root_node, mib_curr_node->oid, index_3); + if(mib_curr_node==mib_root_node) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : Have reached the root node!\r\n"); + return 0; + } + + } + + if(mib_curr_node->total_instance) + { + list_once=0; + curr_module=mib_curr_node->module_index; + register_instance(); + //for(i=0;i<=255;i++) + // if(curr_instance_arr[i].eable==1) + // break; + // mib_curr_node->curr_instance=i; + //debug_mmi_get_all(); + } + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_contents(""); + return 1; + } + else if(index>8) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error,the max layer number you can go back is 8.\r\n"); + return 0; + } + + if(path_name[0]=='/' && path_name[1]=='/') + { + index_3=9; + mib_curr_node= search_mib_node(mib_root_node, cur_oid, index_3); + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_contents(""); + return 1; + } + + if( (path_name[0] != '.') && ( !isdigit(path_name[0]) ) ) // path is module_name + { + + index_2 = strlen(path_name); + for(index=0; indexoid[index]; + index_3 = mib_curr_node->oid_len - 1; + OID[index_3] = 0; + index = 3; + } + else if( (path_name[0]== '.') && (path_name[1] == '/') ) // path is ./oid, \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u4E0B\u67E5\u627Eoid\u6240\u5BF9\u5E94\u7684object + { + for(index=0; index<32; index++) + OID[index] = mib_curr_node->oid[index]; + index_3 = mib_curr_node->oid_len; + index = 2; + } + else + { + OID[0]=1; + OID[1]=3; + OID[2]=6; + OID[3]=1; + OID[4]=4; + OID[5]=1; + OID[6]=1373; + for(index=7; index<32; index++) + OID[index]=0; + index_3 = 7; + index = 0; + } + str_len = strlen(path_name); + for(index_2=0; indexparent_ptr; + if(find_node_ptr!=NULL) + { + if (find_node_ptr->total_instance) + { + if(strlen(path_name)>4) + mib_curr_node=find_node_ptr->parent_ptr; + debug_color_out(BRIGHT,RED,BLACK,"Error : Have reach the leaf node!\r\n"); + return 0; + } + else + mib_curr_node = (mib_node*)find_node_ptr2; + } + } + + if(mib_curr_node->total_instance) + { + list_once=0; + + curr_module=mib_curr_node->module_index; + register_instance(); + //for(i=0;i<=255;i++) + //{ + // if(curr_instance_arr[i].eable==1) + // break; + //} + //mib_curr_node->curr_instance=i; + //debug_mmi_get_all(); + } + //debug_ascii_out_proc("Current object changed to: "); + //debug_color_out(BRIGHT,YELLOW,BLACK,mib_curr_node->name); + //debug_ascii_out_proc("\r\n"); + if(curr_module!=mib_curr_node->module_index && save_flag==1) + debug_mmi_save(); + else + debug_mmi_contents(""); + return 1; +} // end of debug_mmi_cd + +/* +* +* Fun: debug_mmi_contents +* +* Desc: show the current mib_node's all information such as name, path, child nodes and so on +* +* Ret: 1: succeful, 0: fail +* +* File: debug.c +* +*/ +int debug_mmi_contents(char *str) +{ + WORD i,j; + DWORD k; + BYTE ascii_text[256*5]; + //char temp_str[64]; + mib_child_node *child_node_ptr; + mib_node *mib_tmp_node; + char ins_str[16],temp_str[128]; + BYTE max_group,ismodule; + + if(strlen(str)!=0) + { + for(i=0;itotal_child_nodes) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No contents in this object,no child,Please go back! \r\n"); + return 0; + } + debug_ascii_out_proc("Name : "); + sprintf(ascii_text,"%s",mib_curr_node->name); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc("Type : "); + if(mib_curr_node->total_instance) + { + debug_mmi_find_host(""); + } + if(mib_curr_node->total_instance) + { + debug_color_out(BRIGHT,YELLOW,BLACK,"Leaf node("); + debug_color_out(BRIGHT,YELLOW,BLACK,max_access[mib_curr_node->max_access]); + debug_color_out(BRIGHT,YELLOW,BLACK,")"); + } + else + debug_color_out(BRIGHT,YELLOW,BLACK,"Parent node"); + debug_ascii_out_proc("\r\n"); + + if(debug_cfg==1) + { + if(mib_curr_node->module_index!=0xFF) + { + max_group=subsys_module[mib_curr_node->module_index].max_group; + if(host_group<=max_group) + { + debug_ascii_out_proc("Module : "); + sprintf(temp_str,"%s-%d\r\n",subsys_module[mib_curr_node->module_index].name,host_group); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + } + else + { + debug_ascii_out_proc("Module : "); + sprintf(temp_str,"%s-0\r\n",subsys_module[mib_curr_node->module_index].name); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + sprintf(temp_str,"Error : the max system id is %d.\r\n",max_group); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + } + } + } + else if(debug_cfg==2) + { + if(menu_curr_node->sys_group==9) + { + debug_ascii_out_proc("Module : "); + for(i=0;imodule_index].name,i); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + } + debug_ascii_out_proc("\r\n"); + } + else + { + debug_ascii_out_proc("Module : "); + sprintf(temp_str,"%s-%d",subsys_module[mib_curr_node->module_index].name,menu_curr_node->sys_group); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + debug_ascii_out_proc("\r\n"); + } + + + } + + if(!mib_curr_node->total_instance) + { + debug_ascii_out_proc("Child : "); + sprintf(temp_str, "[%d]\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + max_group=0; + for (i = 0; i < mib_curr_node->total_child_nodes; i++) + { + child_node_ptr = mib_curr_node->child_nodes[i]; + if(!child_node_ptr) + continue; + mib_tmp_node=(mib_node*)child_node_ptr->child_ptr; + if(mib_tmp_node!=NULL) + { + max_group=subsys_module[mib_tmp_node->module_index].max_group; + } + if(strncmp(subsys_module[mib_tmp_node->module_index].name,mib_tmp_node->name,strlen(mib_tmp_node->name))==0) + ismodule=1; + else + ismodule=0; + if(ismodule==0 || max_group==0) + { + sprintf(temp_str, " |---(%ld) %s\r\n", child_node_ptr->oid,child_node_ptr->name); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + } + else + { + j=0; + while(max_group>0) + { + sprintf(temp_str, " |---(%ld) %s-%d\r\n", child_node_ptr->oid,child_node_ptr->name,j); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + j++; + if(j==max_group+1) + break; + } + } + } + } + else + { + if(list_once==0) + list_flag=1; + debug_cfg_end=0; + } + if(list_once==1) + { + + if (mib_curr_node->total_instance) + { + strcpy(ascii_text,""); + k=0; + for(i=0;i<=255;i++) + { + if(curr_instance_arr[i].eable==1) + { + sprintf(ins_str,"#%-3d ",i); + strpcat(ascii_text,&k,ins_str); + } + } + debug_ascii_out_proc("Instance: "); + strcpy(ins_str,""); + if(strlen(ascii_text)) + sprintf(ins_str, "#%-3d(%-3d): ", mib_curr_node->curr_instance,mib_curr_node->total_instance); + else + sprintf(ins_str, "None(%-3d): ", mib_curr_node->total_instance); + debug_color_out(BRIGHT,YELLOW,BLACK,ins_str); + //formatstr(10,ascii_text,1);//,(int)ceil(strlen(ascii_text)/70)+1); + debug_color_out(BRIGHT,BLUE,BLACK,ascii_text); + debug_ascii_out_proc("\r\n"); + if(strlen(ascii_text)) + { + none_instance=0; + } + else + none_instance=1; + if(none_instance==0) + { + if(mib_curr_node->max_access>=2 && mib_curr_node->max_access<=5) + { + IP_Selected[0]=1; + for(i=1;i<16;i++) + { + IP_Selected[i]=0; + } + debug_cfg_end=0; + debug_mmi_get_all(); + debug_cfg_end=0; + } + } + else + { + + strcpy(ascii_text,""); + debug_ascii_out_proc("Child : "); + sprintf(ascii_text, "[%d]\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + + for (i = 0; i < mib_curr_node->total_child_nodes; i++) + { + child_node_ptr = mib_curr_node->child_nodes[i]; + if(!child_node_ptr) + continue; + sprintf(ascii_text, " |---(%ld) %s\r\n",child_node_ptr->oid+1, child_node_ptr->name); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + } + debug_cfg_end=1; + } + } + } + + /* + if(!mib_curr_node->total_instance) + { + debug_ascii_out_proc("Command : Now,you can execute the commands include "); + debug_color_out(BRIGHT,YELLOW,BLACK,"\"cd ,child ,parent ,contnets ,pwd ,tree ,remark ,"); + } + else + { + debug_ascii_out_proc("Command : Now,you can execute the commands include "); + debug_color_out(BRIGHT,YELLOW,BLACK,"\"cd ,parent ,contnets ,pwd , tree ,get ,set ,list ,create ,del ,remark ,"); + } + if(save_flag==1) + debug_color_out(BRIGHT,YELLOW,BLACK,"save ,cmm ,q ,help .\"\r\n"); + else + debug_color_out(BRIGHT,YELLOW,BLACK,"cmm ,q ,help .\"\r\n"); + */ + return 1; +} +// end of debug_mmi_contents + + +/* +* +* Fun: debug_mmi_child +* +* Desc: change to the current mib_node's child node by the child node's name or id if it exists +* +* Ret: 1: succeful, 0: fail +* +* File: debug.c +* +*/ +int debug_mmi_child(char *name) +{ + BYTE str_len; + WORD child_index; + WORD oid=0; + mib_child_node *child_node_ptr; + + if (mib_curr_node->total_instance) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : The current object is a leaf node, can not change to its child node.\r\n"); + return 0; + } + + if (!(str_len = strlen(name))) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return 0; + } + + if (!mib_curr_node->total_child_nodes) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No child object for the current object\r\n"); + return 0; + } + + name[str_len] = '\0'; + + if (isdigit(name[0])) + { + oid = strtoul(name, NULL, 10); + child_index = find_child_index(mib_curr_node, oid, NULL, 0); + } + else + child_index = find_child_index(mib_curr_node, 0, name, 1); + + if (child_index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[child_index]; + if(child_node_ptr) + { + if (!child_node_ptr->child_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return 0; + } + mib_curr_node = (mib_node *)child_node_ptr->child_ptr; + //debug_ascii_out_proc("Current object changed to: "); + //debug_color_out(BRIGHT,YELLOW,BLACK,mib_curr_node->name); + //debug_ascii_out_proc("\r\n"); + debug_mmi_contents(""); + return 1; + } + } + + debug_color_out(BRIGHT,RED,BLACK,"Error : No such child object for the current object\r\n"); + return 0; +} // end of debug_mmi_child + +/* +* +* Fun: debug_mmi_parent +* +* Desc: changet to the current mib_node's parent node if it exists +* +* Ret: 1: succeful, 0: fail +* +* File: debug.c +* +*/ +int debug_mmi_parent() +{ + if (mib_curr_node->parent_ptr == NULL) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No parent object for the current object\r\n"); + return 0; + } + + mib_curr_node = (mib_node *) mib_curr_node->parent_ptr; + //debug_ascii_out_proc("Current object changed to: "); + //debug_color_out(BRIGHT,YELLOW,BLACK,mib_curr_node->name); + //debug_ascii_out_proc("\r\n"); + debug_mmi_contents(""); + return 1; +}// end of debug_mmi_parent + +/* +* +* Fun: debug_mmi_pwd +* +* Desc: show the current object path +* +* Ret: return 1 if successful, return 0 if fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int debug_mmi_pwd() +{ + mib_node *node_ptr; + mib_child_node *child_node_ptr = NULL; + BYTE i, loop_times, text_string[1024], text_oid[128]; + WORD child_index; + BYTE tem_str[30]; + BYTE ascii_text[DEBUG_OMCBUF_LEN],oid[16]; + //DWORD temp_oid[32]={1,3,6,1,4,1,1373,1,3,3,2,2,2,1,2,0}; + + + /*if(!ShowRegister) + { + for(i=0;i<16;i++) + { + printf("id:%d,Module name: %s,ascii_in: 0X%ld,ascii_out:0X%ld\r\n",i,debug_shm_ptr->module_d[i].name,&(debug_shm_ptr->module_d[i].ascii_in),&(debug_shm_ptr->module_d[i].ascii_out)); + } + ShowRegister=1; + } + */ + if ((loop_times = mib_curr_node->oid_len - mib_root_node->oid_len) >= 15) + { + sprintf(tem_str, "Object path error for the current object\r\n"); + TxtColor(BRIGHT,RED,BLACK,tem_str); + debug_ascii_out_proc(tem_str); + return 0; + } + sprintf(text_string,"%s(%ld)", mib_root_node->name,mib_root_node->oid[mib_root_node->oid_len-1]); + node_ptr = mib_root_node; + for (i = 0; i < loop_times; i++) + { + if ((child_index = find_child_index(node_ptr, mib_curr_node->oid[mib_root_node->oid_len + i], NULL, 0)) >= MIB_MAX_CHILD_NODES_PER_NODE) + { + sprintf(tem_str,"Object path error for the current object\r\n"); + TxtColor(BRIGHT,RED,BLACK,tem_str); + debug_ascii_out_proc(tem_str); + return 0; + } + child_node_ptr = node_ptr->child_nodes[child_index]; + if(child_node_ptr) + { + sprintf(text_oid, ".%s(%ld)", child_node_ptr->name, child_node_ptr->oid); + strcat(text_string, text_oid); + + if (i != (loop_times - 1)) + { + if (child_node_ptr->child_ptr == NULL) + { + debug_color_out(BRIGHT,RED,BLACK,"Object path error for the current object\r\n"); + return 0; + } + node_ptr = (mib_node *) child_node_ptr->child_ptr; + } + } + } + debug_ascii_out_proc("Path : "); + formatstr(10,text_string,0);//,(int)ceil(strlen(text_string)/70)+1); + debug_color_out(BRIGHT,YELLOW,BLACK,text_string); + debug_ascii_out_proc("\r\n"); + strcpy(ascii_text, "\0"); + for (i = 0; i < (mib_curr_node->oid_len - 1); i++) + { + sprintf(oid, "%ld.", mib_curr_node->oid[i]); + strcat(ascii_text, oid); + } + sprintf(oid, "%ld", mib_curr_node->oid[mib_curr_node->oid_len - 1]); + strcat(ascii_text, oid); + debug_ascii_out_proc("OID : "); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + debug_ascii_out_proc("\r\n"); + /* + for(i=0;i<32;i++) + snmp_agent_packet1.oid[i]=temp_oid[i]; + snmp_agent_packet1.oid_len=16; + snmp_agent_packet1.total_ip=1; + strcpy(snmp_agent_packet1.dst_ip[0],"172.18.144.1"); + snmp_agent_packet1.cmm_state=1; + snmp_agent_packet1.total_instance=255; + for(i=0;i=1 && node_levels<=8) + layer=node_levels; + else + { + layer=3; + debug_ascii_out_proc("the max layer number is eight!\r\n"); + } + */ + debug_ascii_out_proc("Layers : "); + sprintf(print_buf,"%d-%d\r\n",mib_curr_node->oid_len,mib_curr_node->oid_len+layer); + debug_color_out(BRIGHT,GREEN,BLACK,print_buf); + debug_ascii_out_proc("Host OID: "); + sprintf(print_buf,"%d",(int)mib_curr_node->oid[0]); + debug_color_out(BRIGHT,GREEN,BLACK,print_buf); + for(index=1; indexoid_len-1; index++) // ."id"."id"... + { + sprintf(print_buf, ".%d",(int)mib_curr_node->oid[index]); + TxtColor(BRIGHT,GREEN,BLACK,print_buf); + debug_ascii_out_proc(print_buf); + } + debug_ascii_out_proc("\r\n"); + } + treehost=0; + strcpy(separation2, separation); + length = strlen(separation2); + if(node_ptr == NULL) + { + debug_ascii_out_proc("\r\n"); + return; + } + for(index=0; indexname, (int)node_ptr->oid[node_ptr->oid_len-1]);//[][][]node name: "node name" + debug_color_out(BRIGHT,YELLOW,BLACK,print_buf); + if( node_ptr->total_child_nodes == 0 ) + return; + + if(node_ptr->total_instance != 0) + { + for(index = 0; index < (node_ptr->total_child_nodes); index++) + { + mib_node_param *mib_node_param_ptr; + mib_child_node_ptr=node_ptr->child_nodes[index]; + if(!mib_child_node_ptr) + continue; + mib_node_param_ptr = (mib_node_param *)mib_child_node_ptr->child_ptr; // id:"id",name: "name",byte_begin.bit_begin-byte_end.bit_end + sprintf(print_buf, "%s id:%d; %s; [%d.%d-%d.%d]\r\n", spaces, (int)mib_node_param_ptr->id+1, mib_node_param_ptr->name, (int)mib_node_param_ptr->byte_begin, (int)mib_node_param_ptr->bit_begin, (int)mib_node_param_ptr->byte_end, (int)mib_node_param_ptr->bit_end); + debug_color_out(BRIGHT,YELLOW,BLACK,print_buf); + } + return; + } + spaces[index-1]='-'; + spaces[index-2]='*'; + spaces[index-3]='-'; + spaces[index-4]='|'; + for(index = 0; index < node_ptr->total_child_nodes; index++) + { + mib_child_node_ptr=node_ptr->child_nodes[index]; + if(!mib_child_node_ptr) + continue; + sprintf(print_buf, "%s %s(%d)\r\n",spaces, mib_child_node_ptr->name,(int)mib_child_node_ptr->oid); + TxtColor(BRIGHT,YELLOW,BLACK,print_buf); + debug_ascii_out_proc(print_buf); + } + sprintf(print_buf,"{%d}--",(int)node_ptr->oid[node_ptr->oid_len-1]); + strcat(separation2, print_buf); + for(index = 0; index < node_ptr->total_child_nodes; index++) + { + mib_child_node_ptr=node_ptr->child_nodes[index]; + if(!mib_child_node_ptr) + continue; + child_node_ptr = mib_child_node_ptr->child_ptr; + debug_mmi_tree(child_node_ptr,separation2, layer-1); + } + debug_ascii_out_proc("\r\n"); +} // end of debug_mmi_tree + +void debug_mmi_create(char *str) +{ + //DWORD oid[20]; + BYTE i; + BYTE byte,bit; + char str_id[10]; + //char str_value[128]; + char temp_str[256]; + char *p; + int id; + //mib_node *temp_node; + save_flag=1; + strcpy(str_id,""); + //strcpy(str_value,""); + for(i=0;i!=strlen(str);i++) + { + if(*(str+i)!=' ') + break; + } + p=str+i; + strcpy(str,p); + if(str[0]=='\0') + { + if(mib_curr_node->enable_field_id==0xFF) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input the instance value for the special input type!\r\n"); + return ; + } + for(id=0;id<255;id++) + if(curr_instance_arr[id].eable==0) + { + curr_instance_arr[id].eable=1; + break; + } + byte=(id)/8; + bit=(id)%8; + mib_curr_node->enable_flag[byte]=mib_curr_node->enable_flag[byte] | (BYTE)my_pow(2,bit); + mib_curr_node->curr_instance=id; + debug_mmi_set("*"); + //debug_mmi_contents(""); + if(mib_curr_node->enable_flag[byte] & (BYTE)my_pow(2,bit)) + { + debug_ascii_out_proc("State : "); + sprintf(temp_str,"The %s #%d have been created successfully!\r\n",mib_curr_node->name,id); + debug_color_out(BRIGHT,CYAN,BLACK,temp_str); + } + return; + } + else if(str[0]=='#') + { + p=str+1; + strcpy(str,p); + for(i=0;ienable_field_id==0xFF) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input the value !\r\n"); + return ; + } + id=strtol(str_id,NULL,10); + if(id>mib_curr_node->total_instance-1) + { + sprintf(temp_str,"Error : The max instance id is %d\r\n",mib_curr_node->total_instance-1); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return; + } + /* + for(i=0;i0) + { + strncpy(str_id,str,i); + break; + } + } + + if(curr_instance_arr[id].eable==1) + { + debug_color_out(BRIGHT,RED,BLACK,"Erorr : the instance is not exist!please select another id!\r\n"); + return; + } + p=str+i; + strcpy(str_value,p); + + for(i=0;i96 && *(str_value+i)<103) || (*(str_value+i)>64 && *(str_value+i)<72))//other flag||0-f + ; + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please in put Value form 0-f!\r\n"); + return ; + } + } + //for(i=0;ioid_len;i++) + // oid[i]=mib_curr_node->oid[i]; + //oid[i+1]=id; + //temp_node=search_mib_node(mib_root_node, oid, i+1); + //if(!temp_node) + //{ + // mib_curr_node=temp_node; + */ + + if(curr_instance_arr[id].eable==1) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : The instance have exist!\r\n"); + return; + } + else + { + if(mib_curr_node->enable_field_id!=0xFF) + { + byte=(id)/8; + bit=(id)%8; + mib_curr_node->enable_flag[byte]=mib_curr_node->enable_flag[byte] | ((BYTE)my_pow(2,bit)); + } + curr_instance_arr[id].eable=1; + + } + temp_instance=mib_curr_node->curr_instance; + mib_curr_node->curr_instance=id; + + if(*(str+i)=='\0') + { + + debug_mmi_set("*"); + //debug_mmi_contents(""); + mib_curr_node->curr_instance=temp_instance; + if(curr_instance_arr[id].eable==1) + { + debug_ascii_out_proc("State : "); + sprintf(temp_str,"The %s #%d have been created successfully!\r\n",mib_curr_node->name,id); + debug_color_out(BRIGHT,CYAN,BLACK,temp_str); + } + return; + } + else if(*(str+i)=='=') + { + p=str+i+1; + strcpy(str,p); + if(strlen(str)>254) + { + str[255]='\0'; + } + strcpy(temp_str,"*="); + strcat(temp_str,str); + debug_mmi_set(temp_str); + //debug_mmi_contents(""); + mib_curr_node->curr_instance=temp_instance; + if(curr_instance_arr[id].eable==1) + { + debug_ascii_out_proc("State : "); + sprintf(temp_str,"The %s #%d have been created successfully!\r\n",mib_curr_node->name,id); + debug_color_out(BRIGHT,CYAN,BLACK,temp_str); + } + return; + } + else if(*(str+i)=='.') + { + p=str+i+1; + strcpy(str,p); + if(strlen(str)>254) + { + str[255]='\0'; + } + strcpy(temp_str,"*."); + strcat(temp_str,str); + debug_mmi_set(temp_str); + //debug_mmi_contents(""); + mib_curr_node->curr_instance=temp_instance; + if(curr_instance_arr[id].eable==1) + { + debug_ascii_out_proc("State : "); + sprintf(temp_str,"The %s #%d have been created successfully!\r\n",mib_curr_node->name,id); + debug_color_out(BRIGHT,CYAN,BLACK,temp_str); + } + return; + } + } + else + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!\r\n"); +} + +void debug_mmi_del(char *str) +{ + //DWORD oid[20]; + int i; + BYTE byte,bit; + char str_id[128]; + char str_value[128]; + char *p; + int id; + //mib_node *temp_node; + save_flag=1; + strcpy(str_id,""); + strcpy(str_value,""); + for(i=0;i!=strlen(str);i++) + { + if(*(str+i)!=' ') + break; + } + p=str+i; + strcpy(str,p); + if(str[0]!='\0' && str[0]!='#') + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input Error!\r\n"); + return; + } + + if(strlen(str)==0) + { + id=mib_curr_node->curr_instance; + } + else if(str[0]=='#') + { + p=str+1; + strcpy(str,p); + for(i=0;imib_curr_node->total_instance-1) + { + sprintf(str_value,"Error : The max instance id is %d\r\n",mib_curr_node->total_instance-1); + debug_color_out(BRIGHT,RED,BLACK,str_value); + return; + } + } + /* + for(i=0;i0) + { + strncpy(str_id,str,i); + break; + } + } + + if(curr_instance_arr[id].eable==1) + { + debug_color_out(BRIGHT,RED,BLACK,"Erorr : the instance is not exist!please select another id!\r\n"); + return; + } + p=str+i; + strcpy(str_value,p); + + for(i=0;i96 && *(str_value+i)<103) || (*(str_value+i)>64 && *(str_value+i)<72))//other flag||0-f + ; + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please in put Value form 0-f!\r\n"); + return ; + } + } + //for(i=0;ioid_len;i++) + // oid[i]=mib_curr_node->oid[i]; + //oid[i+1]=id; + //temp_node=search_mib_node(mib_root_node, oid, i+1); + //if(!temp_node) + //{ + // mib_curr_node=temp_node; + */ + + + + if(curr_instance_arr[id].eable!=0) + { + byte=(id)/8; + bit=(id)%8; + mib_curr_node->enable_flag[byte]=mib_curr_node->enable_flag[byte] & (~(BYTE)my_pow(2,bit)); + curr_instance_arr[id].eable=0; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : The instance is not exist!\r\n"); + return; + } + temp_instance=mib_curr_node->curr_instance; + mib_curr_node->curr_instance=id; + del_flag=1; + debug_mmi_set("*"); + // debug_mmi_contents(""); + if(temp_instance==id) + { + for(i=0;i<256;i++) + if(curr_instance_arr[i].eable==1) + { + temp_instance=i; + break; + } + } + mib_curr_node->curr_instance=temp_instance; + debug_ascii_out_proc("State : "); + sprintf(str_value,"The %s #%d have been deleted successfully!\r\n",mib_curr_node->name,id); + debug_color_out(BRIGHT,CYAN,BLACK,str_value); + return ; +} + + + +void debug_mmi_option(char *str) +{ + int select_id; + int child_index; + mib_child_node *child_node_ptr; + char out_text[80]; + int i=0; + if(!mib_curr_node->total_instance) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This is no a leaf node!\r\n"); + return ; + } + del_space(str,0); + if(isdigit(str[0])) + { + for(i=0;imib_curr_node->total_child_nodes+1 || select_id==0) + { + sprintf(out_text,"Error : The max field id is %d\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,RED,BLACK,out_text); + return; + } + select_id--; + child_index = find_child_index(mib_curr_node, select_id, NULL, 0); + } + else + child_index = find_child_index(mib_curr_node, 0, str, 1); + + + if (child_index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[child_index]; + if (!child_node_ptr->child_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return ; + } + + param_node = (mib_node_param *)child_node_ptr->child_ptr; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : There is no such child.\n"); + return ; + } + debug_ascii_out_proc("Option : "); + debug_color_out(BRIGHT,YELLOW,BLACK,param_node->name); + debug_ascii_out_proc("\r\n"); + + if(param_node->select_total == 0) + { + debug_ascii_out_proc("Fail : There is no description for the select option.\n"); + return ; + } + else + { + i=0; + while(iselect_total) + { + debug_ascii_out_proc(" "); + sprintf(out_text, "%-2d :%-18s ", param_node->select_ptr[i]->number, param_node->select_ptr[i]->description); + debug_color_out(BRIGHT,BLUE,BLACK,out_text); + i+=1; + if(iselect_total) + { + + sprintf(out_text, "%-2d :%-18s ", param_node->select_ptr[i]->number, param_node->select_ptr[i]->description); + debug_color_out(BRIGHT,BLUE,BLACK,out_text); + i+=1; + if(iselect_total) + { + sprintf(out_text, "%-2d :%-18s\r\n", param_node->select_ptr[i]->number, param_node->select_ptr[i]->description); + debug_color_out(BRIGHT,BLUE,BLACK,out_text); + i+=1; + } + } + } + if(param_node->select_total%3!=0) + debug_ascii_out_proc("\r\n"); + } + return; +} + +/* +* +* Fun: debug_mmi_ip +* +* Desc: set the hosts' ip which are used by get or set command +* +* Ret: return 1 if successful, return 0 if fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int debug_mmi_ip(char *ips) +{ + BYTE str_len, index, index_2, index_3, index_4; + char temp_str[32], ip[80]; + + strcpy(ip, ips); + printf("ips: %s\r\n", ip); + if (!(str_len = strlen(ip))) + { + debug_ascii_out_proc("Null IP strings.\r\n"); + return 0; + } + strcpy(temp_str, ""); + Peer_IP[0] = 0; + for(index_4=0, index_3=0, index_2=0, index=0; index <= str_len; index++) + { + if( (ip[index] != '.') && (ip[index] != ' ')) + { + temp_str[index_2] = ip[index]; + index_2++; + if(index_2 > 3) + break; + } + else + { + temp_str[index_2] = '\0'; + Peer_IP[index_3] += atoi(temp_str) * my_pow(256, index_4++); + index_2 = 0; + if(index_4 >= 4) + { + index_3++; + Peer_IP[index_3] = 0; + index_4 = 0; + if(index_3 >= 16) + break; + } + } + } + + if(index < str_len) + { + debug_ascii_out_proc("Wrong IP.\r\n"); + return 0; + } + + temp_str[index_2] = '\0'; + if(index_3<16) + Peer_IP[index_3++] += atoi(temp_str) * my_pow(256, index_4++); + if(index_3<16) + Peer_IP[index_3] = 0; + + for(index = 0; index<16; index++) + printf("peer_id[%d] = %lx ", index,Peer_IP[index]); + return 1; +} // end of debug_mmi_ip + + +void debug_mmi_find_host(char *str) +{ + BYTE index,i,j,find_all=0,find; + char temp_str1[64],temp_str2[64],temp_str3[64],*p; + + + for(i=0;imodule_index].name); + if(debug_cfg==2 && menu_curr_node!=NULL) + { + if(menu_curr_node->sys_group==9) + find_all=1; + else if(menu_curr_node->sys_group==0) + { + strcpy(temp_str2,menu_curr_node->name); + for(i=0;isys_group-1; + } + if(find_all==0) + { + strcat(temp_str1,"_"); + gcvt(host_group,1,temp_str2); + strcat(temp_str1,temp_str2); + } + i=0; + ip_num=0; + if(mib_curr_node->total_instance) + { + while(module_host[i].index!=0xFF) + { + find=!strncmp(module_host[i].host_name,temp_str1,strlen(temp_str1)); + if(find_all==2 && isdigit(module_host[i].host_name[strlen(temp_str1)])) + find=0; + if(find) + { + strcpy(Remote_Host_Name[ip_num],module_host[i].host_name); + IP_Selected[ip_num]=1; + strcpy(temp_str2,""); + strcpy(temp_str3,""); + for(j=0;j<4;j++) + { + + Peer_IP[ip_num] += module_host[i].host_ip[j] * my_pow(256, j); + gcvt((double)(module_host[i].host_ip[j]),3,temp_str2); + strcat(temp_str3,temp_str2); + strcat(temp_str3,"."); + } + temp_str3[strlen(temp_str3)-1]='\0'; + strcpy(Remote_Host_IP[ip_num],temp_str3); + ip_num++; + if(ip_num >= 16) + break; + + } + i++; + } + } + for(index=0;index<16;index++) + { + if(Peer_IP[index]!=0) + break; + } + if(list_once==1) + if(snmp_agent_flag==0) + if(index==16) + { + debug_color_out(BRIGHT,RED,BLACK,"Fial : Can not find the host!\r\n"); + return ; + } + + find_all=0; +} + +/* +* +* Fun: debug_mmi_show_host +* +* Desc: if the current node is a leaf node, show its hosts' name and ips +* +* Ret: 1: succeful, 0: fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int debug_mmi_show_host() +{ + int index; + char out_text[256]; + if( Remote_Host_Name[0]=="" && Remote_Host_IP[0]=="") + { + debug_color_out(BRIGHT,RED,BLACK,"Host : there is no host for the object!\r\n"); + return 0; + } + if (mib_curr_node->total_instance) + { + if(ip_num!=0) + debug_ascii_out_proc("Host : Count Host Name Host IP Selected\r\n"); + else + { + if(list_once==1) + debug_color_out(BRIGHT,RED,BLACK,"Host : can not show host because no host for the object!\r\n"); + } + for(index=0; index= index_2) + { + if(index_2!=0) + sprintf(temp_str, "Error : The select item must be less than %d.\r\n", index_2); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return 0; + } + IP_Selected[num]=1; + index_2=0; + temp_str[index_2] = '\0'; + } + } + } + return 1; +}// end of debug_mmi_select_host + + +/* +* +* Fun: debug_mmi_setins +* +* Desc: if the current node is a leaf node, set the current node's current instance number +* +* Ret: 1: succeful, 0: fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +int debug_mmi_setins(char *ins) +{ + BYTE str_len; + WORD instance; + BYTE ascii_text[128]; + + if (!(str_len = strlen(ins))) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such instance for the current object\r\n"); + return 0; + } + + if (!mib_curr_node->total_instance) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No instance for the current object\r\n"); + return 0; + } + + ins[str_len] = '\0'; + + instance = strtoul(ins, NULL, 10); + + if ( instance >= mib_curr_node->total_instance ) + { + sprintf(ascii_text, "Error : The instance value must less than the total instance: %d\r\n",mib_curr_node->total_instance); + debug_ascii_out_proc(ascii_text); + return 0; + } + + mib_curr_node->curr_instance = instance; + debug_ascii_out_proc("Current instance changed to:"); + sprintf(ascii_text,"%d\r\n", instance); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + + return 1; +} // end of debug_mmi_setins + + +////////////////////////////////End of Cfg OID Tree Command///////// + + + +////////////////////////////////MIB OID Operation////////////////// +//find the the child index on just given node +WORD find_child_index(mib_node *node_ptr, DWORD oid, char *name, BYTE type) +{ + WORD i; + mib_child_node *child_node_ptr; + + //printf("oid[%d], name [%s], type [%d], total_child: %d.\r\n",(int)oid, name,(int)type,node_ptr->total_child_nodes); + if (!node_ptr->total_child_nodes) + return 0xFFFF; + + for (i = 0; i < node_ptr->total_child_nodes; i++) + { + child_node_ptr = node_ptr->child_nodes[i]; + //printf("child_nod_ptr id [%d], name [%s]. para_name: [%s]\r\n", (int)child_node_ptr->oid, child_node_ptr->name, name); + if ( (!type) && (oid == child_node_ptr->oid) ) + { + return i; + } + else if (type && (!strncasecmp(child_node_ptr->name, name,strlen(child_node_ptr->name)))) + return i; + } + //printf("can't find the nod oid=%d.\r\n",(int)oid); + return 0xFFFF; +} + + +/* +* +* Fun: search_mib_node +* +* Desc: begin form the start_mib_node_ptr, search the node whose OID is equal to the oid +* +* Ret: the pionter which point to the node whose OID is equal to the oid , or the NULL pointer if fali +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_node *search_mib_node(mib_node *start_mib_node_ptr, DWORD *oid, BYTE oid_len) +{ + mib_node *node_ptr; + mib_child_node *child_node_ptr = NULL; + BYTE i, loop_times; + WORD child_index; + + if(start_mib_node_ptr == NULL) + { + printf("start_mib_node_ptr is NULL.\r\n"); + return NULL; + } + if (oid_len <= start_mib_node_ptr->oid_len) + return NULL; + if ((loop_times = oid_len - start_mib_node_ptr->oid_len) >= 15) + return NULL; + node_ptr = start_mib_node_ptr; + for (i = 0; i < loop_times; i++) + { + if ((child_index = find_child_index(node_ptr, oid[start_mib_node_ptr->oid_len + i], NULL, 0)) >= MIB_MAX_CHILD_NODES_PER_NODE) + return NULL; + child_node_ptr = node_ptr->child_nodes[child_index]; + if (i != (loop_times - 1)) + { + if (child_node_ptr->child_ptr == NULL) + return NULL; + node_ptr = (mib_node *) child_node_ptr->child_ptr; + } + } + return (mib_node *) child_node_ptr->child_ptr; +} // end of search_mib_node + + + +/* +* +* Fun: find_node +* +* Desc: find the node whose name is node_name from the start_node_ptr +* +* Ret: successful: the pointer to the node, fail: NULL +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +mib_node *find_node(mib_node *start_node_ptr, char *node_name, int find_type, DWORD *last_node_oid) +{ + int index, index_2; + mib_node *child_node_ptr; + mib_child_node *mib_child_node_ptr; + //printf("find_node begin: %s", start_node_ptr->name); + if(start_node_ptr == NULL) + return NULL; + //printf("nod_name: %s.\r\n",start_node_ptr->name); + if(!strcmp(start_node_ptr->name, node_name)) + { + if(find_type) + { + for(index_2=0; index_2 < start_node_ptr->oid_len-1; index_2++) + { + //printf("%ld.\r\n",start_node_ptr->oid[index_2]); + if(start_node_ptr->oid[index_2] != last_node_oid[index_2]) + break; + } + if(index_2 == (start_node_ptr->oid_len -1)) + return start_node_ptr; + } + else + return start_node_ptr; + } + if(start_node_ptr->total_child_nodes == 0) + return NULL; + if(!start_node_ptr->total_instance) + { + for(index = 0; index < start_node_ptr->total_child_nodes; index++) + { + //printf("child nod_name[%d]: %s.\r\n",index,start_node_ptr->child_nodes[index]->name); + mib_child_node_ptr=start_node_ptr->child_nodes[index]; + if(mib_child_node_ptr) + if( !(strcmp(mib_child_node_ptr->name, node_name)) ) + { + child_node_ptr = mib_child_node_ptr->child_ptr; + if(child_node_ptr!=NULL) + { + if(find_type) + { + for(index_2=0; index_2 < child_node_ptr->oid_len-1; index_2++) + { + if(child_node_ptr->oid[index_2] != last_node_oid[index_2]) + break; + } + if(index_2 == (child_node_ptr->oid_len -1)) + return child_node_ptr; + } + else + return child_node_ptr; + } + } + } + + for(index = 0; index < start_node_ptr->total_child_nodes; index++) + { + mib_child_node_ptr=start_node_ptr->child_nodes[index]; + if(mib_child_node_ptr) + { + child_node_ptr = find_node(mib_child_node_ptr->child_ptr, node_name, find_type, last_node_oid); + if( child_node_ptr != NULL) + { + if(find_type) + { + for(index_2=0; index_2oid_len-1; index_2++) + { + if(child_node_ptr->oid[index_2] != last_node_oid[index_2]) + break; + } + if(index_2 == (child_node_ptr->oid_len -1)) + return child_node_ptr; + } + else + return child_node_ptr; + } + } + } + } + return NULL; +} // end of find_node + +/* +** +* Fun: show_node +* +* Desc: show the mib_tree start from the node_ptr whit the separation as a class sign +* +* Ret: RETVOID +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +void show_node(mib_node *node_ptr,char *separation) +{ + int index, length; + mib_node *child_node_ptr; + char spaces[256], separation2[256]; + strcpy(separation2, separation); + length = strlen(separation2); + if(node_ptr == NULL) + { + printf("\r\n"); + return; + } + for(index=0; indexname, spaces, (int)node_ptr->oid[0]); + + for(index=1; indexoid_len; index++) + { + printf(".%d",(int)node_ptr->oid[index]); + } + } + else + printf("%snode name: %s\r\n%soid: %d",separation2, node_ptr->name, spaces, (int)node_ptr->oid[node_ptr->oid_len - 1]); + printf("\n"); + if( node_ptr->total_child_nodes == 0 ) + return; + else + { + printf("%schild nodes:\r\n",spaces); + } + if(node_ptr->total_instance != 0) + { + for(index = 0; index < (node_ptr->total_child_nodes); index++) + { + mib_node_param *mib_node_param_ptr; + + printf("%s oid: %d, name: %s\r\n",spaces, (int)node_ptr->child_nodes[index]->oid, node_ptr->child_nodes[index]->name); + + mib_node_param_ptr = (mib_node_param *)node_ptr->child_nodes[index]->child_ptr;//?? + + printf("%s id: %d, name: %s, %d . %d - %d . %d\r\n", spaces, (int)mib_node_param_ptr->id+1, mib_node_param_ptr->name, (int)mib_node_param_ptr->byte_begin, (int)mib_node_param_ptr->bit_begin, (int)mib_node_param_ptr->byte_end, (int)mib_node_param_ptr->bit_end ); + + if(mib_node_param_ptr->select_total != 0) + { + int index_s; + mib_param_select *mib_param_select_ptr; + + printf("%s selects: \r\n", spaces); + + for(index_s=0; index_s< mib_node_param_ptr->select_total; index_s++) + { + mib_param_select_ptr = mib_node_param_ptr->select_ptr[index_s]; + + printf("%s number: %d, opt: %s\r\n", spaces, (int)mib_param_select_ptr->number, mib_param_select_ptr->description); + } + } + if(mib_node_param_ptr->input_ptr != NULL) + { + mib_param_input *mib_param_input_ptr; + mib_param_input_ptr = mib_node_param_ptr->input_ptr; + printf("%s input:\r\n%s input_param_type: %d, input_string: %s\r\n", spaces, spaces, (int)mib_param_input_ptr->input_param_type, mib_param_input_ptr->input); + } + } + return; + } + + for(index = 0; index < node_ptr->total_child_nodes; index++) + printf("%s oid: %d, name: %s\r\n",spaces, (int)node_ptr->child_nodes[index]->oid, node_ptr->child_nodes[index]->name); + strcat(separation2, "{ }--"); + for(index = 0; index < node_ptr->total_child_nodes; index++) + { + child_node_ptr = node_ptr->child_nodes[index]->child_ptr; + show_node(child_node_ptr,separation2); + } + printf("\r\n"); +} // end of show_node + + +/* +* +* Fun: find_OID +* +* Desc: search the OID which number is obj_num in the sysConf_file, and store them to the *OID +* +* Ret: the length of the OID; 0: Fail +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ + +int find_OID(int obj_num, char *sysConf_file_name, DWORD *OID) +{ + char temp_str[256], stop_ch[32]; + int state = 0, find; + FILE *fp_sysConf; + + if((fp_sysConf = fopen(sysConf_file_name, "r")) == NULL) + { + printf("[debug] Error: cannot open param_sysConf_file: [%s].\r\n",sysConf_file_name); + return 0; + } + + strcpy(stop_ch,";"); + while( !feof(fp_sysConf) ) + { + read_until(fp_sysConf, temp_str, stop_ch); + + switch(state) + { + case 0: + if(strlen(temp_str) == 0) + { + printf("[debug] Error: Fail to get the object number in the sysConf_file.\r\n"); + fclose(fp_sysConf); + return 0; + } + if( obj_num == atoi(temp_str) ) + find = 1; + else + find = 0; + strcpy(stop_ch,";"); + state = 1; + break; + case 6: + if(find && (strlen(temp_str) != 0)) + { + int i, j, k, length=strlen(temp_str); + char temp_str_2[256]; + strcpy(temp_str_2, ""); + for(k=0; k<32; k++) + OID[k] = 0; + for(i=0,j=0,k=0 ; imenu_oid_node==mib_curr_node && menu_curr_node->total_menu_child) + { + debug_ascii_out_proc("Name : "); + sprintf(ascii_text,"%s",menu_curr_node->name); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc("Contents: "); + sprintf(ascii_text, "[%d]\r\n",menu_curr_node->total_menu_child); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + for (i = 0; i < menu_curr_node->total_menu_child; i++) + { + menu_tmp_node = menu_curr_node->child_node[i]; + if(menu_tmp_node!=NULL) + { + sprintf(ascii_text, " |---(%d) %s\r\n",menu_tmp_node->menu_id[menu_tmp_node->id_len-1], menu_tmp_node->name); + debug_color_out(BRIGHT,YELLOW,BLACK,ascii_text); + } + } + } + else + { + debug_mmi_contents(""); + } +} + +void debug_mmi_mcd(char *str) +{ + char input_str[32]; + int index;//,index1; + menu_node *menu_tmp_node; + mib_child_node *child_node_ptr; + mib_node *find_node_ptr; + DWORD temp_index; + DWORD OID[32]; + BYTE index_start,index_end; + + + if(mib_curr_node->total_instance && strstr(str,"..")==0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Have reached the leaf node!\r\n"); + return; + } + + + if(strlen(str)>32) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No need so long command!\r\n"); + return ; + } + + for(index_start=0;index_start0;index_start--) + { + if(*(str+index_end)!=' ') + break; + } + strncpy(input_str,str+index_start,index_end-index_start); + if(!strlen(input_str)) + { + menu_curr_node=menu_root_node; + if(menu_curr_node->menu_oid_node) + mib_curr_node=menu_curr_node->menu_oid_node; + list_once=0; + debug_mmi_view(); + return ; + } + if(input_str[0]=='.'&& input_str[1]=='.') + { + if(mib_curr_node!=menu_curr_node->menu_oid_node) + { + mib_curr_node=(mib_node*)mib_curr_node->parent_ptr; + } + else if(mib_curr_node==menu_curr_node->menu_oid_node) + { + menu_tmp_node=(menu_node *)menu_curr_node->father_ptr; + if(menu_tmp_node) + { + menu_curr_node=menu_tmp_node; + if(menu_curr_node->menu_oid_node) + { + mib_curr_node=menu_curr_node->menu_oid_node; + list_once=0; + } + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Have reach the 'WXC2' or no father node\r\n"); + return ; + } + } + } + else if(!isdigit(input_str[0]) || (isdigit(input_str[0]) && !isdigit(input_str[1]) && input_str[1]!='\0')) + { + if(mib_curr_node==menu_curr_node->menu_oid_node && menu_curr_node->total_menu_child) + { + for(index=0;indextotal_menu_child;index++) + { + if((menu_tmp_node=(menu_node*)menu_curr_node->child_node[index])) + if(strncasecmp(input_str,menu_tmp_node->name,strlen(menu_tmp_node->name))==0) + { + menu_curr_node=menu_tmp_node; + if(menu_curr_node->menu_oid_node) + mib_curr_node=menu_curr_node->menu_oid_node; + break; + } + } + if(index==menu_curr_node->total_menu_child) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No such object as the name or input error!\r\n"); + return ; + } + } + else + { + index = find_child_index(mib_curr_node, 0, input_str, 1); + + if (index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[index]; + if (!child_node_ptr->child_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return ; + } + else + mib_curr_node=child_node_ptr->child_ptr; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!\r\n"); + return ; + } + } + } + else if(isdigit(input_str[0])) + { + for(index=0;index4) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!\r\n"); + return ; + } + temp_index=atoi(input_str); + } + if(mib_curr_node==menu_curr_node->menu_oid_node && menu_curr_node->total_menu_child) + { + if(temp_index<=0 || temp_index>menu_curr_node->total_menu_child) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!\r\n"); + return ; + } + if(!menu_curr_node->total_menu_child || temp_index>menu_curr_node->total_menu_child) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No child menu item!\r\n"); + return ; + } + else if((menu_tmp_node=(menu_node*)menu_curr_node->child_node[temp_index-1])) + { + menu_curr_node=menu_tmp_node; + if(menu_curr_node->menu_oid_node) + mib_curr_node=menu_curr_node->menu_oid_node; + } + } + else + { + if(mib_curr_node->total_child_nodes) + { + OID[mib_curr_node->oid_len]=temp_index; + find_node_ptr =(mib_node*)search_mib_node(mib_curr_node, OID,mib_curr_node->oid_len+1); + //child_node_ptr=mib_curr_node->child_nodes[temp_index-1]; + if(!find_node_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No such child item!\r\n"); + return ; + } + else + { + mib_curr_node=find_node_ptr; + list_once=0; + } + //if(child_node_ptr->child_ptr) + // mib_curr_node=child_node_ptr->child_ptr; + //else + //{ + // debug_color_out(BRIGHT,RED,BLACK,"Error : No such child node!\r\n"); + // return ; + //} + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No child for current node!\r\n"); + return ; + } + } + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!\r\n"); + return ; + } + /* + for(index=0;index3) + { + field_compute_state=0; + read_syntax_nor_list=0; + line_index=0; + compute_state=0; + print_line_index=0; + } + */ + if(mib_curr_node==menu_curr_node->menu_oid_node && menu_curr_node->total_menu_child) + debug_mmi_view(); + else + { + if(menu_curr_node->menu_oid_node) + { + curr_module=mib_curr_node->module_index; + if(mib_curr_node->total_instance) + { + list_once=0; + curr_module=mib_curr_node->module_index; + register_instance(); + debug_mmi_contents(" "); + debug_cfg_end=0; + } + else + { + debug_mmi_contents(" "); + } + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No oid node match along with the menu item!\r\n"); + return ; + } + } + +} + +void main_menu(char *str) +{ + char out_text[128],*ch; + BYTE i; + for(i=0;i<80 && *(str+i)!='\0';i++) + { + if(*(str+i)!=' ') + break; + } + ch=str+i; + strcpy(out_text,ch); + if(*out_text!='\0') + { + if(strncasecmp(out_text,"help",4)==0) + { + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help \r\n"); + debug_ascii_out_proc(" Show the WXC2 configer menu page\r\n"); + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help command\r\n"); + debug_ascii_out_proc(" Show the usage of the command: contents,cd,child,parent,get,set,lsit,\r\n create,delete,remark,option,cmm,help\r\n"); + } + else if(strncasecmp(out_text,"cd",2)==0) + { + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd \r\n"); + debug_ascii_out_proc(" Enter the system main menu WXC2\r\n"); + debug_ascii_out_proc(" Usage 2: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd ..\r\n"); + debug_ascii_out_proc(" Enter the parent menu item \r\n"); + debug_ascii_out_proc(" Usage 3: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd name\r\n"); + debug_ascii_out_proc(" Enter the child menu item name as 'name'\r\n"); + debug_ascii_out_proc(" Usage 4: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"cd XX\r\n"); + debug_ascii_out_proc(" Enter the child menu item whose id is 'XX' \r\n"); + } + else if(strncasecmp(out_text,"get",3)==0) + { + help_cmm(1,"get or get *","Get and printf the current instance's value of the node\r\n"); + help_cmm(2,"get #XX","Get and printf the special instance's value of the node\r\n"); + help_cmm(3,"get *.X or get *.name","Get and printf the current instance's special field value of the node\r\n"); + help_cmm(4,"get #X.X or get #x.name","Get and printf the special instance's special field value of the node\r\n"); + } + else if(strncasecmp(out_text,"set",3)==0) + { + help_cmm(1,"set or set *","Set the current instance's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(2,"set #XX ","Set the special instance's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(3,"set *.X =X or set *.name=X ","Set the current instance's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(4,"set #X.X =X or set #x.name=X ","Set the special instance's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(5,"set #X =XXX","Set the special instance's whole value to given value of the node and open the isntance ,then printf\r\n"); + } + else if(strncasecmp(out_text,"create",3)==0) + { + help_cmm(1,"creat or create *","Create an instance with the min closed instance id and set it's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(2,"create #XX","Create the special instance,and set it's value to default value of the node and open the isntance ,then printf\r\n"); + help_cmm(3,"create *.X =X or create *.name=X ","Create an instance's with the min closed instance id ,and set it's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(4,"create #X.X =X or create #x.name=X ","Create the special instance,and set it's field value to given value of the node and open the isntance ,then printf\r\n"); + help_cmm(5,"create #X =XXX","Create the special instance,and set is's whole value to given value of the node and open the isntance ,then printf\r\n"); + } + else if(strncasecmp(out_text,"delete",3)==0) + { + help_cmm(1,"delete ","Delete the current instance ,if it is opened,clost it.set the value to default value of the node\r\n"); + help_cmm(2,"delete #XX","Delete the special instance,if it is opened,clost it.set the value to default value of the node\r\n"); + } + else if(strncasecmp(out_text,"contents",3)==0) + { + help_cmm(1,"contents ","Show the current menu item or the informat about the oid node\r\n"); + } + else if(strncasecmp(out_text,"list",3)==0) + { + help_cmm(1,"list [-a]","the switch of show all the field and value of the instance include the 'NULL' and the closed instance,default:off\r\n"); + help_cmm(2,"list [-e]","the switch of show opened the instance,hide the field and it's value default:off\r\n"); + help_cmm(3,"list [-r]","the switch of show the field data range.default:off\r\n"); + help_cmm(4,"list [-t]","the switch of show input data type ,default:off\r\n"); + help_cmm(5,"list [-f[X XX X]]","the switch of show the special field list in the [ ] ,default:off\r\n"); + help_cmm(6,"list [X-XX]","the switch of show the instance range form x to xxx.default:off\r\n"); + } + else if(strncasecmp(out_text,"child",3)==0) + { + help_cmm(1,"child X","Enter the child node whose id is X\r\n"); + help_cmm(2,"child name","Enter the child node whose name is 'name'\r\n"); + } + else if(strncasecmp(out_text,"parent",3)==0) + { + help_cmm(1,"parent","Enter the parent node\r\n"); + } + /* + else if(strncasecmp(out_text,"pwd",3)==0) + { + help_cmm(1,"pwd","Show the full path and the full oid\r\n"); + } + */ + else if(strncasecmp(out_text,"remark",3)==0) + { + help_cmm(1,"remark","Show the description of the node\r\n"); + } + else if(strncasecmp(out_text,"option",3)==0) + { + help_cmm(1,"option X","Show the select option of the fied node whose id is x of leaf node \r\n"); + help_cmm(2,"option name","Show the select option of the fied node whose name is ''name' of leaf node \r\n"); + } + else if(strncasecmp(out_text,"save",3)==0) + { + help_cmm(1,"save","save the debug\r\n"); + } + else if(strncasecmp(out_text,"find host",3)==0) + { + help_cmm(1,"find host","Find all the host who have the object about the current node\r\n"); + } + else if(strncasecmp(out_text,"select",3)==0) + { + help_cmm(1,"select X","Select the host ip list,if been selected ,the set command would do effect on the host\r\n"); + } + else if(strncasecmp(out_text,"setinst",3)==0) + { + help_cmm(1,"setinst X","Set the current instance as the special number\r\n"); + } + else if(strncasecmp(out_text,"cmm",3)==0) + { + help_cmm(1,"cmm","Enter the debug cmm state\r\n"); + } + /* + else if(strncasecmp(out_text,"addhost",3)==0) + {} + else if(strncasecmp(out_text,"delhost",3)==0) + {} + else if(strncasecmp(out_text,"tree",4)==0) + { + help_cmm(1,"tree","Print the menu three\r\n"); + } + */ + else + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No such Command!\r\n"); + return ; + } + } + else + { + time_t tick_2; + char time_buf_2[64]= "\0", str_buf[128]="\0"; + BYTE count=0; + tick_2 = time(NULL); + debug_ascii_out_proc("\033[2J\033[1;1H"); + snprintf(time_buf_2, sizeof(time_buf_2), "%.24s", ctime(&tick_2)); + sprintf(str_buf, " -----Start Time: %s----- \r\n", time_buf_2); + debug_color_out(BRIGHT,CYAN,WHITE,str_buf); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*************************\r\n");//80-20=60/2=30 + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*"); + debug_ascii_out_proc(" "); + debug_color_out(BRIGHT,WHITE,BLACK,"WXC2 System Configer Menu");//80-20=60/2=30 + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*\r\n"); + debug_ascii_out_proc(" "); + debug_ascii_out_proc("*************************\r\n");//80-20=60/2=30 + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc(" ============================================================================== \r\n"); + debug_ascii_out_proc(" | | | | | | \r\n"); + debug_ascii_out_proc(" "); + count=menu_root_node->total_menu_child; + for(i=0;ichild_node[i])->name); + debug_color_out(BRIGHT,YELLOW,GREEN,out_text); + debug_ascii_out_proc(" "); + } + debug_ascii_out_proc("\r\n\r\n\r\n\r\n"); + if(debug_cfg==2) + { + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help \r\n"); + debug_ascii_out_proc(" Show the WXC2 configer menu page\r\n"); + debug_ascii_out_proc(" Usage 1: "); + debug_color_out(BRIGHT,YELLOW,BLACK,"help command\r\n"); + debug_ascii_out_proc(" Show the usage of the command: contents,cd,child,parent,get,set,list,\r\n create,delete,remark,option,cmm,save,help\r\n"); + } + } +} // end of debug_mmi_cfg_help + + + +menu_node *search_menu_node(menu_node *start_menu_node_ptr, BYTE *menu_id, BYTE id_len) +{ + menu_node *node_ptr,*menu_node_ptr; + BYTE i, loop_times; + + + if(start_menu_node_ptr == NULL) + { + printf("start_menu_node_ptr is NULL.\r\n"); + return NULL; + } + if (id_len <= start_menu_node_ptr->id_len) + return NULL; + if ((loop_times = id_len - start_menu_node_ptr->id_len) >= 15) + return NULL; + node_ptr = start_menu_node_ptr; + for (i = 0; i < loop_times; i++) + { + menu_node_ptr= (menu_node*)node_ptr->child_node[menu_id[i]-1]; + if(menu_node_ptr) + node_ptr=menu_node_ptr; + else + { + printf("[debug] :Fail to search menu node!father node: %s,search_id:%d\n",node_ptr->name,menu_id[loop_times]); + return NULL; + } + } + return (menu_node *) node_ptr; +} // end of search_menu_node +//////////////////////////////End of CMM Menu Tree Command//////////// + + + + + + +///////////////////////////////snmp senior agnet///////////////// + +void debug_set_agent() +{ + DWORD oid[32]; + mib_child_node *child_node_ptr; + mib_node *find_node_ptr; + char *p,temp_str1[16],temp_str2[4]; + WORD ip[16][4]; + DWORD Set_IP[16],sum,sub_sum; + BYTE m; + param_field *tmp_param_field; + WORD i,j,k,child_index,index3,index,index2,index4,select_id; + WORD total_field; + if(snmp_agent_flag==0 && (get_state!=0 || set_state!=0)) + return ; + + + + for(i=0;itotal_instance) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=3; + return ; + } + agent_tmp_node=mib_curr_node; + mib_curr_node=find_node_ptr; + for(i=0;itotal_child_nodes;i++) + { + child_node_ptr=mib_curr_node->child_nodes[i]; + if(child_node_ptr) + { + param_node = (mib_node_param *)child_node_ptr->child_ptr; + tmp_param_field=&debug_snmp_agent_buf[debug_agent_index].param_field_arr[i]; + if(param_node->select_total!=0) + { + tmp_param_field->total_select=param_node->select_total; + for(index=0; indexselect_total; index++) + { + tmp_param_field->value_arr[index]=param_node->select_ptr[index]->number; + strcpy(tmp_param_field->value_arr_remark[index],param_node->select_ptr[index]->description); + } + tmp_param_field->input_type=0xFF; + } + else if(param_node->input_ptr!=NULL) + { + tmp_param_field->total_select=0; + tmp_param_field->input_type=param_node->input_ptr->input_param_type; + } + strcpy(tmp_param_field->name,param_node->name); + } + + } + + if(mib_curr_node->max_access ==0 || mib_curr_node->max_access ==1 || mib_curr_node->max_access ==3) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=6; + mib_curr_node=agent_tmp_node; + return ; + } + + if(snmp_agent_packet.oid[snmp_agent_packet.oid_len-1] >mib_curr_node->total_instance) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=5; + mib_curr_node=agent_tmp_node; + return ; + } + + mib_curr_node->curr_instance=snmp_agent_packet.oid[snmp_agent_packet.oid_len-1]; + + + + + //set the param + if(snmp_agent_packet.total_field!=mib_curr_node->total_child_nodes) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=7; + mib_curr_node=agent_tmp_node; + return ; + } + j=mib_curr_node->data_length; + for(i=0;iinit_value[i]; + } + + total_field=snmp_agent_packet.total_field; + //total_field=mib_curr_node->total_child_nodes; + for(child_index=0;child_indexchild_nodes[child_index]; + if (!child_node_ptr->child_ptr) + { + strcpy(temp_str1,"1"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + param_node = (mib_node_param *)child_node_ptr->child_ptr; + + if(param_node->select_total != 0) + { + select_id=atoi(snmp_agent_packet.param_field_arr[child_index].curr_input_value); + if(select_id>param_node->select_total) + { + strcpy(temp_str1,"2"); + sprintf(temp_str2,"%d",snmp_agent_packet.param_field_arr[child_index].curr_select_id); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + + } + else + { + j=select_id; + set_val=param_node->select_ptr[j]->number; + index3 = sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + } + } + else if(param_node->input_ptr != NULL) + { + strcpy(set_val_str,snmp_agent_packet.param_field_arr[child_index].curr_input_value); + switch(param_node->input_ptr->input_param_type)// ananlise + { + case 0: //toDec_high_0 //\u5224\u65AD\u8F93\u5165\u7684\u6570\u503C\u662F\u5426\u6709\u6548 + j = strlen(set_val_str); + for(i=0; ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin); + set_val = atol(set_val_str); + if(set_val > my_pow(2, j)) + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + } + break; + case 1: //keepHex_high_0 //\u5224\u65AD\u8F93\u5165\u7684\u6570\u503C\u5B57\u7B26\u4E32set_val_str\u662F\u5426\u6709\u6548, \u5982\u679C\u6709\u6548\u5219\u5C06\u9AD8\u4F4D\u8865\u6210\u5B57\u7B26'0'\uFF0C\u8865\u8DB3\u4F4D\u6570 + j = strlen(set_val_str); + for(i=0; i= 'A') && (set_val_str[i] <= 'F')) //is A to F + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u9AD8\u4F4D\u8865\u6210'0' + k = i-j; + for(j=i-1; (j-k)>=0 && j!=0 ; j--) + set_val_str[j]=set_val_str[j-k]; + set_val_str[i] = '\0'; + for(j=0; j= 'A') && (set_val_str[i] <= 'F')) //is A to F + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'0' + for(; j= 'A') && (set_val_str[i] < 'E')) //is A to D + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210E + for(; j= 'A') && (set_val_str[i] < 'F')) //is A to E + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'F' + for(; jbyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/8; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'0' + for(; jbyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/8; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + strcpy(temp_str1,"3"); + sprintf(temp_str2,"%d",child_index); + strcat(temp_str1,temp_str2); + j=atoi(temp_str1); + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=j; + mib_curr_node=agent_tmp_node; + return ; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'F' + for(; jinput_ptr->input_param_type)// set + { + case 0: //toDec_high_0 + index3 = sum = 0; + for(index=param_node->byte_end; index >=param_node->byte_begin; index--) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + index3++; + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + + } + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + } + break; + case 1: //keepHex_high_0 + case 2: //keepHex_low_0 + case 3: //keepHex_low_E + case 4: //keepHex_low_F + + index3 = index4 = sum = sub_sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + if((index3 == 0) && ( (index4+1) <= strlen(set_val_str) )) //\u53D6\u4E24\u4F4D\u5B57\u7B26 + { + set_val = 0; + if( isdigit(set_val_str[index4]) ) //\u6570\u5B57\u5B57\u7B26 + set_val += (set_val_str[index4++] - '0') * 16; + else // A \u81F3 E \u4E4B\u95F4 + set_val += (set_val_str[index4++] - 'A' + 10) * 16; + + if( isdigit(set_val_str[index4]) ) + set_val += set_val_str[index4++] - '0'; + else + set_val += set_val_str[index4++] - 'A' + 10; + } + + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + if(index3 == 8) + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + break; + case 5: //toAscii_low_0 + case 6: //keepAscii_low_F + + index3 = index4 = sum = sub_sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + if(index3 == 0) //\u53D6\u4E00\u4F4D\u5B57\u7B26 + set_val = set_val_str[index4++]; + + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + if(index3 == 8) + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + break; + } + } + + + } + j=recv_msgbuf.var[0].msglen; + + for(i=0;i15) + break; + } + for(i=0;i<=ip_num;i++) + { + Peer_IP[i]=Set_IP[i]; + IP_Selected[i]=1; + } + for(ip_index=0;ip_index<16;ip_index++) + { + if(IP_Selected[ip_index] != 1) + continue; + send_addr.remote_ip = Peer_IP[ip_index]; + break; + } + if(ip_index>=16) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=4; + mib_curr_node=agent_tmp_node; + return ; + } + } + else + debug_mmi_find_host(""); + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + + send_addr.broadcast = 0; + send_msgbuf.pdu_type = 0; + send_msgbuf.request_id = 0; + send_msgbuf.var_num = 1; + for(i=0; i<32; i++) + send_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + send_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + send_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = 1; + for(i=0; i<32; i++) + recv_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + recv_msgbuf.var[mib_curr_node->oid_len].oid[i] = (DWORD)mib_curr_node->curr_instance; + recv_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0; i<256; i++) + recv_msgbuf.var[0].msg[i] = 0; + + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + + snmp_agent_flag=2; + debug_snmp_agent_buf[debug_agent_index].cmm_state=3; + ip_index = 0; + set_state = 1; + debug_cfg_end = 0; + return ; +} + +void debug_get_agent() +{ + DWORD oid[32]; + mib_node *find_node_ptr; + char *p,temp_str1[16],temp_str2[4]; + WORD ip[16][4]; + DWORD Set_IP[16]; + BYTE m; + WORD i,j,k; + static BYTE t1s; + + if(snmp_agent_flag==0 && (get_state!=0 || set_state!=0)) + return ; + + if(bind_num>0 && snmp_agent_flag>0) + { + for(i=0;i50) + { + t1s=0; + bind_num=0; + get_state=0; + snmp_agent_flag=0; + for(i=0;icurr_instance+=bind_num-1; + + if(mib_curr_node->curr_instance==mib_curr_node->total_instance-1) + { + bind_num=0; + get_state=0; + snmp_agent_flag=0; + mib_curr_node->curr_instance=0; + mib_curr_node=agent_tmp_node; + return; + } + if(mib_curr_node->curr_instancetotal_instance-MAX_PACKET_NUM) + { + //mib_curr_node->curr_instance+=bind_num; + mib_curr_node->curr_instance++; + snmp_agent_flag=1; + for(i=0;icurr_instancetotal_instance-1) + { + mib_curr_node->curr_instance++; + bind_num=mib_curr_node->total_instance+1-mib_curr_node->curr_instance; + snmp_agent_flag=1; + for(i=0;icurr_instance=0; + mib_curr_node=agent_tmp_node; + return; + } + } + + + for(i=0;itotal_child_nodes; + if(mib_curr_node->max_access ==0 || mib_curr_node->max_access ==1) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=6; + mib_curr_node=agent_tmp_node; + return ; + } + + if(snmp_agent_packet.oid[snmp_agent_packet.oid_len-1]>mib_curr_node->total_instance) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=5; + mib_curr_node=agent_tmp_node; + return ; + } + if(mib_curr_node->total_instance==snmp_agent_packet.total_instance && mib_curr_node->total_instance>=MAX_PACKET_NUM ) + { + if(debug_agent_index==0 && !debug_snmp_agent_buf[debug_agent_index].oid[ debug_snmp_agent_buf[debug_agent_index].oid_len-1]) + { + bind_num=MAX_PACKET_NUM; + snmp_agent_flag=1; + mib_curr_node->curr_instance=0; + } + else + printf("Error : The debug SNMP Agent buffer is not start from 0,while getting all instance\r\n"); + } + else if(mib_curr_node->total_instance==snmp_agent_packet.total_instance && mib_curr_node->total_instancecurr_instance=0; + bind_num=mib_curr_node->total_instance; + snmp_agent_flag=1; + } + else + printf("Error : The debug SNMP Agent buffer is not start from 0,while getting all instance\r\n"); + } + else + { + bind_num=1; + snmp_agent_flag=1; + mib_curr_node->curr_instance=snmp_agent_packet.oid[snmp_agent_packet.oid_len-1]; + } + debug_get_all_value=mib_curr_node->total_child_nodes; + + //set the ip + if(snmp_agent_packet.total_ip) + { + for(i=0;i<16;i++) + { + Set_IP[i]=0; + IP_Selected[i]=0; + Peer_IP[i]=0; + } + ip_num=0; + for(m=0;m15) + break; + } + for(i=0;i<=ip_num;i++) + { + Peer_IP[i]=Set_IP[i]; + IP_Selected[i]=1; + } + for(ip_index=0;ip_index<16;ip_index++) + { + if(IP_Selected[ip_index] != 1) + continue; + send_addr.remote_ip = Peer_IP[ip_index]; + break; + } + if(ip_index>=16) + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=4; + mib_curr_node=agent_tmp_node; + return ; + } + } + else + debug_mmi_find_host(""); + + + +bind_set: + send_msgbuf.pdu_type = 0; + send_msgbuf.request_id = 0; + send_msgbuf.var_num = bind_num; + for(j=0;joid[i]; + send_msgbuf.var[j].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance+j; + send_msgbuf.var[j].oidlen = mib_curr_node->oid_len + 1; + } + + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + send_addr.broadcast = 0; + + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = bind_num; + for(j=0;joid[i]; + recv_msgbuf.var[j].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance+j; + recv_msgbuf.var[j].oidlen = mib_curr_node->oid_len + 1; + for(i=0; i<256; i++) + recv_msgbuf.var[j].msg[i] = 0; + } + + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + + get_state = 1; + debug_cfg_end = 0; + if(bind_num!=MAX_PACKET_NUM) + debug_snmp_agent_buf[debug_agent_index].cmm_state=3; + else + for(i=0;itotal_instance)) + { + debug_ascii_out_proc("Fail : There is no instance for the current object\r\n"); + debug_cfg_end=1; + return 0; + } + + if (mib_curr_node->max_access == 0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'INVALID'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + if (mib_curr_node->max_access == 1) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'NOT-ACCESSIBLE'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + if (mib_curr_node->max_access == 6 && snmp_agent_flag==0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'WRITE-ONLY'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + + if(mib_curr_node->total_child_nodes == 0) + { + strcpy(paraname, mib_curr_node->name); + } + else + { + debug_get_all_value = mib_curr_node->total_child_nodes; + if(mib_curr_node->total_child_nodes==1) + param_node = mib_curr_node->child_nodes[0]->child_ptr; + } + + if( (toupper(temp_str[0]) == 'R') && (toupper(temp_str[1]) == 'E') && (toupper(temp_str[2]) == 'S') && (toupper(temp_str[3]) == 'E') && (toupper(temp_str[4]) == 'R') && (toupper(temp_str[5]) == 'V') && (toupper(temp_str[6]) == 'E') && (toupper(temp_str[7]) == 'D') && (toupper(temp_str[8]) == '\0') ) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This node is Reserved. Can not get its value.\r\n"); + return 0; + } + + //if(print_once==0 && field_compute_state==5) + // print_once=2; + + + send_msgbuf.pdu_type = 0; + send_msgbuf.request_id = 0; + send_msgbuf.var_num = 1; + for(i=0; i<32; i++) + send_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + send_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + send_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0;ip_index=16) + { + debug_ascii_out_proc("Fail : There is not host ip available.\r\n"); + return 0; + } + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + send_addr.broadcast = 0; + + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = 1; + for(i=0; i<32; i++) + recv_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + recv_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + recv_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0; i<256; i++) + recv_msgbuf.var[0].msg[i] = 0; + + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + bind_num=1; + + ip_index = 0; + get_state = 1; + debug_cfg_end = 0; + for(i=0;i<256;i++) + { + if(curr_instance_arr[i].eable==1) + break; + } + if(i==256) + none_instance=1; + else + none_instance=0; + if(list_flag==0) + { + get_show_state=1; + //show_snmp_state=1; + show_all_value = 1; + } + + /* + if(show_snmp_state==1) + { + debug_ascii_out_proc("GetStatus:"); + debug_color_out(BRIGHT,CYAN,BLACK,"Waiting..."); + } + //sprintf(out_text, "1 %s = ", temp_str); + //debug_ascii_out_proc(out_text); + */ + return 1; +}// end of debug_mmi_get_all + + +/* +* +* Fun: debug_mmi_get +* +* Desc: handle the get command, if valid, start the debug_snmp_get_rt +* +* Ret: return 1 if successful, return 0 if fail +* +* File: debug.c +* +*/ +int debug_mmi_get(char *child_name) +{ + int i,ins; + WORD child_index; + mib_child_node *child_node_ptr; + char out_text[256], temp_str[256]; + char *p,str_ins_id[32]; + WORD oid=0; + + if (!(mib_curr_node->total_instance)) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : There is no instance for the current object\r\n"); + debug_cfg_end=1; + return 0; + } + if (!mib_curr_node->total_child_nodes) + { + debug_cfg_end=1; + debug_color_out(BRIGHT,RED,BLACK,"Fail : No child object for the current object\r\n"); + return 0; + } + + if (mib_curr_node->max_access == 0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'INVALID'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + if (mib_curr_node->max_access == 1) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'NOT-ACCESSIBLE'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + if (mib_curr_node->max_access == 6 && snmp_agent_flag==0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'WRITE-ONLY'. Can not get its value.\r\n"); + debug_cfg_end=1; + return 0; + } + for(i=0;i!=strlen(child_name);i++) + { + if(*(child_name+i)!=' ') + break; + } + p=child_name+i; + strcpy(child_name,p); + if(child_name[0]=='#')//get # + { + p=child_name+1; + strcpy(child_name,p); + for(i=0;icurr_instance; + if(ins>mib_curr_node->total_instance-1) + { + sprintf(temp_str,"Error : The max instance id is %d\r\n",mib_curr_node->total_instance-1); + debug_color_out(BRIGHT,RED,BLACK,temp_str); + return 0; + } + mib_curr_node->curr_instance=ins; + if(i==strlen(child_name)) //#3 + { + debug_get_all_value= mib_curr_node->total_child_nodes; + } + else + { + p=child_name+i+1; + strcpy(child_name,p); + if (isdigit(child_name[0])) //#3.2 + { + oid = strtoul(child_name, NULL, 10); + if(oid>0) + { + oid--; + child_index = find_child_index(mib_curr_node, oid, NULL, 0); + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : There is no such child.\n"); + return 0; + } + } + else //#3.ENABLE + child_index = find_child_index(mib_curr_node, 0, child_name, 1); + + if (child_index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[child_index]; + if (!child_node_ptr->child_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return 0; + } + debug_get_all_value= 301; + param_node = (mib_node_param *)child_node_ptr->child_ptr; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : There is no such child.\n"); + return 0; + } + strcpy(temp_str, param_node->name); + if( (toupper(temp_str[0]) == 'R') && (toupper(temp_str[1]) == 'E') && (toupper(temp_str[2]) == 'S') && (toupper(temp_str[3]) == 'E') && (toupper(temp_str[4]) == 'R') && (toupper(temp_str[5]) == 'V') && (toupper(temp_str[6]) == 'E') && (toupper(temp_str[7]) == 'D') && (toupper(temp_str[8]) == '\0') ) + { + sprintf(out_text, "Error : %s is Reserved. Can not get its value.\r\n", param_node->name); + debug_color_out(BRIGHT,RED,BLACK,out_text); + return 0; + } + } + } + else if(child_name[0]=='*' && child_name[1]=='\0') //get * + { + debug_mmi_get_all(); + return 1; + } + else if(strncmp(child_name,"*.",2)==0) //get *. + { + p=child_name+2; + strcpy(child_name,p); + + if (isdigit(child_name[0])) + { + oid = strtoul(child_name, NULL, 10); + if(oid>0) + { + oid--; + child_index = find_child_index(mib_curr_node, oid, NULL, 0); + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return 0; + } + } + else + child_index = find_child_index(mib_curr_node, 0, child_name, 1); + + if (child_index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[child_index]; + if (!child_node_ptr->child_ptr) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : No such child object for the current object\r\n"); + return 0; + } + debug_get_all_value= 301; + param_node = (mib_node_param *)child_node_ptr->child_ptr; + } + else + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : There is no such child.\n"); + return 0; + } + strcpy(temp_str, param_node->name); + if( (toupper(temp_str[0]) == 'R') && (toupper(temp_str[1]) == 'E') && (toupper(temp_str[2]) == 'S') && (toupper(temp_str[3]) == 'E') && (toupper(temp_str[4]) == 'R') && (toupper(temp_str[5]) == 'V') && (toupper(temp_str[6]) == 'E') && (toupper(temp_str[7]) == 'D') && (toupper(temp_str[8]) == '\0') ) + { + sprintf(out_text, "Error : %s is Reserved. Can not get its value.\r\n", param_node->name); + debug_color_out(BRIGHT,RED,BLACK,out_text); + return 0; + } + } + /* + if(debug_get_all_value==mib_curr_node->total_child_nodes) + if(print_once==0 && field_compute_state==5) + print_once=2; + */ + + send_msgbuf.pdu_type = 0; + send_msgbuf.request_id = 0; + send_msgbuf.var_num = 1; + for(i=0; i<32; i++) + send_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + send_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + send_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(ip_index=0;ip_index<16;ip_index++) + { + if(IP_Selected[ip_index] != 1) + continue; + send_addr.remote_ip = Peer_IP[ip_index]; + break; + } + if(ip_index>=16) + { + debug_ascii_out_proc("Fail : There is not host ip available.\r\n"); + return 0; + } + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + send_addr.broadcast = 0; + + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = 1; + for(i=0; i<32; i++) + recv_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + recv_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + recv_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0; i<256; i++) + recv_msgbuf.var[0].msg[i] = 0; + + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + bind_num=1; + + get_state = 1; + debug_cfg_end = 0; + for(i=0;i<256;i++) + { + if(curr_instance_arr[i].eable==1) + break; + } + if(i==256) + none_instance=1; + else + none_instance=0; + if(list_flag==0) + { + get_show_state=1; + //if(contents_state!=0) + // show_snmp_state=1; + show_all_value = 1; + } + /*if(show_snmp_state==1) + { + debug_ascii_out_proc("GetStatus:"); + debug_color_out(BRIGHT,CYAN,BLACK,"Waiting..."); + }*/ + // strcpy(paraname,child_node_ptr->name); + + return 1; +} // end of deubg_mmi_get + +/* +* +* Fun: debug_mmi_set +* +* Desc: handle the set command, if valid, full fill the value and start the debug_snmp_set_rt +* +* Ret: return 1 if successful, return 0 if fail +* +* File: debug.c +* +*/ +int debug_mmi_set(char *set_str) +{ + int i, j, k, ins; + BYTE str_len; + WORD child_index; + WORD oid=0; + mib_child_node *child_node_ptr; + char child_name[80], out_text[256], *temp_ch; + char str_ins_id[10]; + char p,q; + if(save_flag==0) + save_flag=1; + + if(strlen(set_str)>80) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : the string is too long !\r\n"); + return 0; + } + + strcpy(child_name, set_str); + for(i=0;i!=strlen(child_name);i++) + { + if(*(child_name+i)!=' ') + break; + } + if(*(child_name+i)=='\0') //set + { + strcpy(set_ins_value, curr_instance_value); + temp_instance=mib_curr_node->curr_instance; + strcpy(child_name,""); + set_all=1; + } + temp_ch=child_name+i; + strcpy(child_name,temp_ch); + if(child_name[0]=='#')//set # + { + temp_ch=child_name+1; + strcpy(child_name,temp_ch); + for(i=0;imib_curr_node->total_instance-1) + { + sprintf(out_text,"Error : The max instance id is %d\r\n",mib_curr_node->total_instance-1); + debug_color_out(BRIGHT,RED,BLACK,out_text); + return 0; + } + temp_instance=mib_curr_node->curr_instance; + mib_curr_node->curr_instance=ins; + + if(*(child_name+i)=='\0') //set #3 + { + //debug_get_all_value= mib_curr_node->total_child_nodes; + /* if(mib_curr_node->enable_field_id==0xFF) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input the value !\r\n"); + return 0; + } + */ + + + strcpy(set_ins_value, curr_instance_value); + strcpy(child_name,""); + set_all=1; + } + else if(*(child_name+i)=='=')//#3= + { + if(mib_curr_node->total_child_nodes==1) + { + temp_ch=child_name+i+1; + strcpy(out_text,"1="); + strcat(out_text,temp_ch); + strcpy(child_name,out_text); + strcpy(set_ins_value,""); + } + else + { + temp_ch=child_name+i+1; + if(temp_ch!=NULL) + { + strcpy(child_name,temp_ch); + for(i=0;icurr_instance; + if(child_name[1]=='\0') //* + { + /* + if(mib_curr_node->enable_field_id==0xFF) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input the value !\r\n"); + return 0 ; + } + */ + strcpy(set_ins_value, curr_instance_value); + strcpy(child_name,""); + set_all=1; + } + else if(child_name[1]=='=') //*= + { + if(mib_curr_node->total_child_nodes==1 && save_flag<3) + { + temp_ch=child_name+2; + strcpy(out_text,"1="); + strcat(out_text,temp_ch); + strcpy(child_name,out_text); + strcpy(set_ins_value,""); + } + else + { + if(child_name[2]!='\0') + temp_ch=child_name+2; + strcpy(child_name,temp_ch); + for(i=0;i=48 ))&& (!(*(set_ins_value+i)<=70 && *(set_ins_value+i)>=65)) && (!(*(set_ins_value+i)>=97 && *(set_ins_value+i)<=102))) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : please input 0-9 or a-f or A-F\r\n"); + return 0; + } + else if(isdigit(*(set_ins_value+i))) + { + out_text[i]=*(set_ins_value+i)-48; + } + else if((*(set_ins_value+i)<=70 && *(set_ins_value+i)>=65))//A-F + { + out_text[i]=*(set_ins_value+i)-55; + } + else if((*(set_ins_value+i)>=97 && *(set_ins_value+i)<=102))//a-f + { + out_text[i]=*(set_ins_value+i)-87; + } + } + //strncpy(set_ins_value,out_text,set_str_len); + i=0; + j=0; + k=0; + while(itotal_instance)) + { + debug_ascii_out_proc("Fail : There is no instance for the current object\r\n"); + return 0; + } + + if (!(str_len = strlen(child_name))) + { + debug_ascii_out_proc("Fail : No child name in the set command.\r\n"); + return 0; + } + + if (!mib_curr_node->total_child_nodes) + { + debug_ascii_out_proc("Fail : No child object for the current object\r\n"); + return 0; + } + + if (mib_curr_node->max_access == 0) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'INVALID'. Can not set its value.\r\n"); + return 0; + } + if (mib_curr_node->max_access == 1) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'NOT-ACCESSIBLE'. Can not set its value.\r\n"); + return 0; + } + if (mib_curr_node->max_access == 3) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS property is 'READ-ONLY'. Can not set its value.\r\n"); + return 0; + } + + child_name[str_len] = '\0'; + + if (isdigit(child_name[0])) + { + oid = strtoul(child_name, NULL, 10)-1; + child_index = find_child_index(mib_curr_node, oid, NULL, 0); + } + else + child_index = find_child_index(mib_curr_node, 0, child_name, 1); + + if (child_index < MIB_MAX_CHILD_NODES_PER_NODE) + { + child_node_ptr = mib_curr_node->child_nodes[child_index]; + if (!child_node_ptr->child_ptr) + { + debug_ascii_out_proc("Fail : No such child object for the current object\r\n"); + return 0; + } + param_node = (mib_node_param *)child_node_ptr->child_ptr; + if(param_node->select_total != 0) //\u5224\u65AD\u8F93\u5165\u7684\u6570\u503C\u662F\u5426\u6709\u6548\uFF0C\u662F\u5426\u5B58\u5728\u8BE5\u6570\u503C\u4EE3\u8868\u7684select\u9009\u9879 + { + if(set_val == -1) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : The select option value must be digit or a-f.\r\n"); + return 0; + } + + for(i=0; iselect_total; i++) + { + if(param_node->select_ptr[i]->number == set_val) + break; + } + if(i >= param_node->select_total) + { + sprintf( out_text, "Fail : The value %ld is not exist in the select options:\r\n", set_val); + debug_color_out(BRIGHT,RED,BLACK,out_text); + sprintf(out_text,"%d",param_node->id+1); + debug_mmi_option(out_text); + return 0; + } + } + if(param_node->input_ptr != NULL) + { + switch(param_node->input_ptr->input_param_type) + { + case 0: //toDec_high_0 //\u5224\u65AD\u8F93\u5165\u7684\u6570\u503C\u662F\u5426\u6709\u6548 + j = strlen(set_val_str); + for(i=0; i(param_node->byte_end-param_node->byte_begin+(param_node->bit_end-param_node->bit_begin+1)/8)) + { + sprintf( out_text, "Error : The value must be less than %d byte!\r\n",(param_node->byte_end-param_node->byte_begin+(param_node->bit_end-param_node->bit_begin+1)/8)); + debug_ascii_out_proc(out_text); + return 0; + } + */ + j =(param_node->byte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin); + set_val = atol(set_val_str); + if(set_val > my_pow(2, j)) + { + sprintf( out_text, "Error : The value must be less than %ld.\r\n", (my_pow(2,j)-1) ); + debug_ascii_out_proc(out_text); + return 0; + } + } + break; + case 1: //keepHex_high_0 //\u5224\u65AD\u8F93\u5165\u7684\u6570\u503C\u5B57\u7B26\u4E32set_val_str\u662F\u5426\u6709\u6548, \u5982\u679C\u6709\u6548\u5219\u5C06\u9AD8\u4F4D\u8865\u6210\u5B57\u7B26'0'\uFF0C\u8865\u8DB3\u4F4D\u6570 + j = strlen(set_val_str); + for(i=0; i= 'A') && (set_val_str[i] <= 'F')) //is A to F + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "Error : The length of the value string must be less than %d.\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u9AD8\u4F4D\u8865\u6210'0' + k = i-j; + for(j=i-1; (j-k)>=0 && j!=0; j--) + set_val_str[j]=set_val_str[j-k]; + set_val_str[i] = '\0'; + for(j=0; j= 'A') && (set_val_str[i] <= 'F')) //is A to F + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "The length of the value string must be less than %d.\r\nFAIL\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'0' + for(; j= 'A') && (set_val_str[i] < 'E')) //is A to D + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "The length of the value string must be less than %d.\r\nFail\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210E + for(; j= 'A') && (set_val_str[i] < 'F')) //is A to E + continue; + break; + } + if(ibyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/4; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "The length of the value string must be less than %d.\r\nFAIL\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'F' + for(; jbyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/8; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "The length of the AscII string must be less than %d.\r\nFAIL\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'0' + for(; jbyte_end * 8 + 1 + param_node->bit_end) - (param_node->byte_begin * 8 - param_node->bit_begin) )/8; + if(j > i) //\u5B57\u7B26\u4E32\u957F\u5EA6\u5927\u4E8E\u6240\u80FD\u5B58\u50A8\u7684\u4F4D\u6570\uFF0C\u5219\u63D0\u793A\u5E76\u9000\u51FA + { + sprintf(out_text, "The length of the AscII string must be less than %d.\r\nFAIL\r\n", i); + debug_ascii_out_proc(out_text); + return 0; + } + + //\u8F93\u5165\u6709\u6548\uFF0C\u5219\u5C06\u4F4E\u4F4D\u8865\u6210'F' + for(; jsys_group==9) + for(i=0;ioid[i]; + send_msgbuf.var[0].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance; + send_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0;i<16;i++) + { + if(IP_Selected[i] != 1) + continue; + send_addr.remote_ip = Peer_IP[i]; + break; + } + if(i>=16) + { + debug_ascii_out_proc("There is not host ip available.\r\n"); + return 0; + } + + + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + send_addr.broadcast = 0; + + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = 1; + for(i=0; i<32; i++) + recv_msgbuf.var[0].oid[i] = mib_curr_node->oid[i]; + recv_msgbuf.var[mib_curr_node->oid_len].oid[i] = (DWORD)mib_curr_node->curr_instance; + recv_msgbuf.var[0].oidlen = mib_curr_node->oid_len + 1; + + for(i=0; i<256; i++) + recv_msgbuf.var[0].msg[i] = 0; + + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + + ip_index = 0; + set_state = 1; + debug_cfg_end = 0; + + return 1; +} // end of debug_mmi_set + + + +/* +* +* Fun: debug_snmp_get_rt +* +* Desc: get the mib_node's value from the host by snmp, then analyze and show the value of its field's value +* +* Ret: RVOID +* +* Notes: Wang Jian add +* +* File debug.c +* +*/ +void debug_snmp_get_rt() +{ + int request_id=0, index,i; + char out_text[256]=""; + BYTE value_valid; + char type_str[31]; + char out_text1[128]; + char temp_str[32]; + char out_ins_text[256]; + BYTE ins_byte,field_id; + BYTE ins_bit; + BYTE byte,bit; + WORD curr_select_id; + mib_child_node *child_node_ptr; + param_field *tmp_param_field; + + + + + switch(get_state) + { + case 0: //idle + break; + case 1: //send local get request to local host + t5s_flag=0; + + if (mib_curr_node->max_access == 0) + { + //debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'INVALID'. Can not get its value.\r\n"); + get_state=0; + debug_cfg_end=1; + return ; + } + if (mib_curr_node->max_access == 1) + { + //debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'NOT-ACCESSIBLE'. Can not get its value.\r\n"); + get_state=0; + debug_cfg_end=1; + return ; + } + if (mib_curr_node->max_access == 6 && snmp_agent_flag==0) + { + //debug_color_out(BRIGHT,RED,BLACK,"Error : This leaf node's MAX-ACCESS is 'WRITE-ONLY'. Can not get its value.\r\n"); + get_state=0; + debug_cfg_end=1; + return ; + } + for(ip_index=0;ip_index=ip_num) + { + if(snmp_agent_flag==0) + debug_color_out(BRIGHT,RED,BLACK,"Fail : Can not get the value because there is not host ip available.\r\n"); + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=4; + mib_curr_node=agent_tmp_node; + } + ip_index = 0; + snmp_agent_flag=0; + debug_cfg_end = 1; + get_state = 0; + snmp_agent_flag=0; + debug_get_all_value = 0; + break; + } + + request_id = snmp_send(&send_msgbuf, &send_addr); + if(request_id == 0) + { + if(snmp_agent_flag==0) + { + sprintf(out_text, "Error : Fail to send snmp get request to the host: %s %s\r\n", Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + debug_ascii_out_proc(out_text); + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=9; + mib_curr_node=agent_tmp_node; + } + ip_index = 0; + snmp_agent_flag=0; + debug_cfg_end = 1; + get_state = 0; + snmp_agent_flag=0; + debug_get_all_value = 0; + } + else + { + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = request_id; + recv_addr.remote_ip = send_addr.remote_ip; + get_state = 2; + } + break; + case 2: //receive local get response + request_id = snmp_receive(&recv_msgbuf, &recv_addr); + if(request_id == 0) // not received + { + if(t5s_flag > 250) + { + if(snmp_agent_flag==0) + { + //if(list_once==1) + { + if(list_once==0) + { + mib_node_param *node_param_ptr; + debug_ascii_out_proc("Child : "); + sprintf(out_text, "[%d]\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); + for (i = 0; i < mib_curr_node->total_child_nodes; i++) + { + child_node_ptr = mib_curr_node->child_nodes[i]; + node_param_ptr=(mib_node_param *)child_node_ptr->child_ptr; + sprintf(out_text, " |---(%ld) %s\r\n",child_node_ptr->oid+1, node_param_ptr->name); + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); + } + } + sprintf(out_text, "Fail : Time out! Check the connection to Host:%s(%s)\r\n",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + debug_ascii_out_proc(out_text); + } + + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=1; + mib_curr_node=agent_tmp_node; + } + ip_index=0; + list_flag=0; + snmp_agent_flag=0; + list_start=list_end=0; + get_show_state=0; + debug_cfg_end = 1; + get_state = 0; + snmp_agent_flag=0; + debug_get_all_value = 0; + break; + } + else + break; + } + debug_cfg_end = 0; + get_state = 3; + break; + case 3: // received + //for look + if(snmp_agent_flag==0) + { + if(recv_msgbuf.error_status != 0) + { + //sprintf(out_text, "Fail : get value from the host: %s[%s]",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + switch(recv_msgbuf.error_status) + { + case 1: + strcat(out_text,"Error : TooBig\r\n"); + break; + case 5: + strcat(out_text,"Error : GenErr\r\n"); + break; + case 6: + strcat(out_text,"Error : NoAccessl\r\n"); + break; + case 7: + strcat(out_text,"Error : WrongType\r\n"); + break; + case 8: + strcat(out_text,"Error : WrongLength\r\n"); + break; + case 9: + strcat(out_text,"Error : WrongEncoding\r\n"); + break; + case 10: + strcat(out_text,"Error : WrongValue\r\n"); + break; + case 11: + strcat(out_text,"Error : NoCreation\r\n"); + break; + case 12: + strcat(out_text,"Error : inconsistentValue\r\n"); + break; + case 13: + strcat(out_text,"Error : resourceUnavailable\r\n"); + break; + case 14: + strcat(out_text,"Error : commitFailed\r\n"); + break; + case 15: + strcat(out_text,"Error : UndoFailed\r\n"); + break; + case 16: + strcat(out_text,"Error : AuthorizationError\r\n"); + break; + case 17: + strcat(out_text,"Error : NoWritable\r\n"); + break; + case 18: + strcat(out_text,"Error : inconsistentName\r\n"); + break; + default: + break; + } + if(snmp_agent_flag==0) + debug_color_out(BRIGHT,RED,BLACK,out_text); + ip_index=0; + snmp_agent_flag=0; + debug_cfg_end = 1; + get_state = 0; + snmp_agent_flag=0; + debug_get_all_value = 0; + break; + } + strcpy(out_ins_text,""); + if(get_show_state==1) + { + show_all_value=1; + show_type=0; + show_expend=1; + show_range=0; + } + } + + while(bind_indexname); + TxtColor(BRIGHT,YELLOW,BLACK,out_text1); + strcat(out_ins_text,out_text1); + if(!(none_instance==1 || show_empty==1)) + sprintf(out_text1,"#%-3d ",mib_curr_node->curr_instance+bind_index); + else + strcpy(out_text1,""); + + if(mib_curr_node->total_child_nodes>1 || show_expend==0) + strcat(out_text1,"\r\n"); + strcat(out_ins_text,out_text1); + + show_list=1; + } + + if(show_all_value==0 ) + { + if(mib_curr_node->total_child_nodes==1) + { + param_node=mib_curr_node->child_nodes[0]->child_ptr; + if(param_node!=NULL) + { + if(param_node->input_ptr!=NULL) + { + if(param_node->input_ptr->input_param_type==0) + index=1; + else + index=strncmp(mib_curr_node->init_value,recv_msgbuf.var[bind_index].msg,mib_curr_node->data_length); + } + } + } + else + index=strncmp(mib_curr_node->init_value,recv_msgbuf.var[bind_index].msg,mib_curr_node->data_length); + + if(mib_curr_node->enable_field_id!=0xFF) + { + param_node = mib_curr_node->child_nodes[mib_curr_node->enable_field_id]->child_ptr; + if(param_node->byte_begin==param_node->byte_end && param_node->bit_begin ==param_node->bit_end) + { + ins_byte=param_node->byte_begin; + ins_bit=param_node->bit_begin ; + if(recv_msgbuf.var[bind_index].msg[ins_byte] & (BYTE)my_pow(2,ins_bit)) + index=1; + else + index=0; + } + } + if(index) + { + byte=(mib_curr_node->curr_instance+bind_index)/8; + bit=(mib_curr_node->curr_instance+bind_index)%8; + mib_curr_node->enable_flag[byte]=mib_curr_node->enable_flag[byte] | (BYTE)my_pow(2,bit); + curr_instance_arr[mib_curr_node->curr_instance+bind_index].ins=mib_curr_node->curr_instance+bind_index; + curr_instance_arr[mib_curr_node->curr_instance+bind_index].eable=1; + } + else + { + byte=(mib_curr_node->curr_instance+bind_index)/8; + bit=(mib_curr_node->curr_instance+bind_index)%8; + mib_curr_node->enable_flag[byte]=mib_curr_node->enable_flag[byte] & (~(BYTE)my_pow(2,bit)); + curr_instance_arr[mib_curr_node->curr_instance+bind_index].ins=mib_curr_node->curr_instance+bind_index; + curr_instance_arr[mib_curr_node->curr_instance+bind_index].eable=0; + } + } + } + if(((bind_num==1 && debug_snmp_agent_buf[debug_agent_index].cmm_state==3 )|| (debug_snmp_agent_buf[bind_index].cmm_state ==3 && bind_num!=1)) && snmp_agent_flag==1) + { + show_list=1; + show_all_value=1; + show_expend=1; + debug_get_all_value=mib_curr_node->total_child_nodes; + } + + + if(show_list==1) + { + if(index!=0 || show_all_value==1) + { + if(snmp_agent_flag==0 && field_compute_state!=4) + debug_ascii_out_proc(out_ins_text); + if(show_expend==1) + { + + while(debug_get_all_value != 0 ) + { + debug_cfg_end = 0; + get_state = 3; + if(debug_get_all_value!=301) + { + param_node = mib_curr_node->child_nodes[mib_curr_node->total_child_nodes - debug_get_all_value]->child_ptr; + if(snmp_agent_flag==0) + if(show_field==1) + { + for(i=0;list_field_arr[i]!=0xFF && i<64;i++) + { + if(list_field_arr[i]==mib_curr_node->total_child_nodes - debug_get_all_value+1) + { + break; + } + } + if( list_field_arr[i]==0xFF || i==64) + { + debug_get_all_value--; + continue; + } + else if(list_field_arr[i]==mib_curr_node->total_child_nodes - debug_get_all_value+1) + { + ; + } + } + } + if(param_node == NULL) + {// not error but mib_curr_node has no child + int index2, index3; + DWORD sum; + int sub_sum, find_first, byte_begin, byte_end, bit_begin, bit_end; + find_first = 0; + strcpy(out_text, ""); + sub_sum=0; + index3 = 0; + sum = 0; + byte_begin = 0; + byte_end = recv_msgbuf.var[bind_index].msglen - 1; + bit_begin = 0; + bit_end = 7; + strcpy(out_text, "0x"); + for(index=byte_begin; index <= byte_end; index++) + { + if(index == byte_begin) //index--byte index + index2 = bit_begin; + else + index2 = 0; + for(; index2<8; index2++)//index2--bit index + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0)//get index bit + sub_sum += my_pow(2, index3); + index3++; + if( (index == byte_end) && (index2 == bit_end)) + { + switchchar(out_text,sub_sum & 0xF0); + switchchar(out_text,sub_sum & 0x0F); + } + if(index3==8) + { + switchchar(out_text,sub_sum & 0xF0); + switchchar(out_text,sub_sum & 0x0F); + index3 = 0; + } + } + } + if(strlen(out_text) == 2) + value_valid=0; + strcpy(type_str,"Hex"); + ip_index = 0; + debug_cfg_end = 1; + get_state = 0; + debug_get_all_value = 0; + break; + } + + else if((recv_msgbuf.var[bind_index].vartype == 2) || (recv_msgbuf.var[bind_index].vartype == 4)) //int or string + {// not error but mib_curr_node has children + + char temp_str[16]=""; + int index2, index3; + DWORD sum; + int sub_sum, find_first, index4; + find_first = 0; + strcpy(out_text, ""); + + if(param_node->input_ptr != NULL) + { + switch(param_node->input_ptr->input_param_type) + { + case 0: //toDec_high_0 + index3 = sum = 0; + for(index=param_node->byte_end; index >=param_node->byte_begin; index--) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sum += my_pow(2, index3); + index3++; + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + + } + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + } + sprintf(out_text, "%ld", sum); + strcpy(type_str,"toDec-hight-0"); + break; + case 1: //keepHex_high_0 + sub_sum=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + { + switchchar(out_text,sub_sum & 0xF0); + switchchar(out_text,sub_sum & 0x0F); + if(out_text[strlen(out_text)]=='0') + ; + value_valid=0; + break; + } + if(index3==8) + { + switchchar(out_text,sub_sum & 0xF0); + switchchar(out_text,sub_sum & 0x0F); + index3 = 0; + } + } + } + sprintf(out_text1,"%s ",out_text); + strcpy(out_text,out_text1); + strcpy(type_str,"keepHex-high-0"); + break; + case 2: //keepHex_low_0 + sub_sum=0; + index4=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + for(index=param_node->byte_begin; index <= param_node->byte_end ; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + if(index3==8) + { + switchchar(out_text,sub_sum & 0xF0); + if((sub_sum & 0xF0)==0x00 ) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x00) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + { + switchchar(out_text,sub_sum & 0x00); + if((sub_sum & 0xF0)==0x00 ) + { + if(strlen(out_text) == 1) + value_valid=0; + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x00) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + index3=0; + } + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + if(find_first == 1) + break; + } + strcpy(type_str,"keepHex-low-0"); + break; + case 3: //keepHex_low_E + sub_sum=0; + index4=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + for(index=param_node->byte_begin; index <= param_node->byte_end ; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + if(index3==8) + { + switchchar(out_text,sub_sum & 0xF0); + if((sub_sum & 0xF0)==0xE0 ) + { + if(strlen(out_text) == 1) + value_valid=0; + out_text[strlen(out_text)-1]='\0'; + + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x0E) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end) && param_node->bit_end!=7) + { + switchchar(out_text,sub_sum & 0xF0); + if((sub_sum & 0xF0)==0xE0 ) + { + out_text[strlen(out_text)]='\0'; + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x0E) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + index3=0; + } + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + if(find_first == 1) + break; + } + strcpy(type_str,"keepHex-low-E"); + //printf("The keephex_low_e:%s",out_text); + break; + case 4: //keepHex_low_F + sub_sum=0; + index4=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + { + switchchar(out_text,sub_sum & 0xF0); + if((sub_sum & 0xF0)==0xF0 ) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x0F) + { + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + index3=0; + } + if(index3==8) + { + switchchar(out_text,sub_sum & 0xF0); + if((sub_sum & 0xF0)==0xF0 ) + { + if(strlen(out_text) == 1) + value_valid=0; + out_text[strlen(out_text)-1]='\0'; + find_first = 1; + break; + } + switchchar(out_text,sub_sum & 0x0F); + if((sub_sum & 0x0F)==0x0F) + { + out_text[strlen(out_text)-1]='\0'; + + find_first = 1; + break; + } + index3 = 0; + } + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + if(find_first == 1) + break; + } + strcpy(type_str,"keepHex-low-F"); + break; + case 5: //toAscii_low_0 + sub_sum=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + strcpy(temp_str, ""); + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + { + if(sub_sum == '0') //\u4EE5 '0' \u7ED3\u5C3E + { + if(strlen(out_text) == 2) + value_valid=0; + find_first = 1; + break; + } + else + { + strcpy(temp_str, ""); + sprintf(temp_str, "%c", sub_sum); + strcat(out_text, temp_str); + } + break; + } + if(index3==8) + { + if(sub_sum == '0') //\u4EE5 0 \u7ED3\u5C3E + { + if(strlen(out_text) == 0) + value_valid=0; + find_first = 1; + break; + } + else + { + strcpy(temp_str, ""); + sprintf(temp_str, "%c", sub_sum); + strcat(out_text, temp_str); + } + index3 = 0; + } + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + if(find_first == 1) + break; + } + strcpy(type_str,"toAscii-low-0"); + break; + case 6: //keepAscii_low_F + sub_sum=0; + index3 = 0; + sum = 0; + strcpy(out_text, ""); + strcpy(temp_str, ""); + + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if(index3 == 0) + sub_sum = 0; + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sub_sum += my_pow(2, index3); + index3++; + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + { + if(sub_sum == 'F') //\u4EE5 'F' \u7ED3\u5C3E + { + if(strlen(out_text) == 2) + value_valid=0; + find_first = 1; + break; + } + else + { + strcpy(temp_str, ""); + sprintf(temp_str, "%c", sub_sum); + strcat(out_text, temp_str); + } + break; + } + if(index3==8) + { + if(sub_sum == 'F') //\u4EE5 'F' \u7ED3\u5C3E + { + if(strlen(out_text) == 0) + value_valid=0; + find_first = 1; + break; + } + else + { + strcpy(temp_str, ""); + sprintf(temp_str, "%c", sub_sum); + strcat(out_text, temp_str); + } + index3 = 0; + } + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + if(find_first == 1) + break; + } + strcpy(type_str,"toAscii-low-F"); + break; + default: + break; + } + param_node->input_ptr->input[0] = sum; + } + else if(param_node->select_total != 0) + { + index3 = sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((recv_msgbuf.var[bind_index].msg[index] & (BYTE)my_pow(2, index2)) != 0) + sum += my_pow(2, index3); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + strcpy(out_text, ""); + for(index=0; indexselect_total; index++) + { + if(param_node->select_ptr[index]->number == sum) + { + sprintf(out_text, "%ld (%s)", sum, param_node->select_ptr[index]->description); + curr_select_id=index; + } + } + if(strlen(out_text) == 0) + sprintf(out_text, "%ld (UNREGESTER VALUE)", sum); + } + else + sprintf(out_text, "%ld ", sum); + } + + + + del_space(out_text,1); + if(strncasecmp(param_node->name, "reserved", 8) == 0 ) + { + if(snmp_agent_flag==1) + { + field_id=mib_curr_node->total_child_nodes-debug_get_all_value; + tmp_param_field=&snmp_agent_packet.param_field_arr[field_id]; + strcpy(tmp_param_field->name,param_node->name); + } + } + else + { + + if(snmp_agent_flag==0 && field_compute_state!=4) + { + if(mib_curr_node->total_child_nodes==1) + sprintf(out_text1, " |---(%d) %s",param_node->id+1, param_node->name); + else + { + if(debug_get_all_value==301) + sprintf(out_text1, " |---(%d) %s",param_node->id+1, param_node->name); + else + sprintf(out_text1, " |---(%d) %s",1+mib_curr_node->total_child_nodes - debug_get_all_value, param_node->name); + } + + debug_color_out(BRIGHT,YELLOW,BLACK,out_text1); + + if(!(none_instance==1 && show_empty==1)) + { + if(!strlen(out_text)) + { + debug_ascii_out_proc(" = "); + debug_color_out(BRIGHT,BLUE,BLACK,"NULL "); + } + else + { + debug_ascii_out_proc(" = "); + debug_color_out(BRIGHT,BLUE,BLACK,out_text); + debug_ascii_out_proc(" "); + } + } + + if(param_node->input_ptr!=NULL) + { + if(show_type==1 ) + { + //debug_ascii_out_proc("Type : "); + debug_color_out(BRIGHT,YELLOW,BLACK,type_str); + } + } + if(show_range==1) + { + //debug_ascii_out_proc("Range : "); + sprintf(out_text, " [%d.%d - %d.%d]\r\n", param_node->byte_begin, param_node->bit_begin, param_node->byte_end, param_node->bit_end); + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); //for look + } + else + { + if( strncasecmp(param_node->name, "reserved", 8) != 0 ) + debug_ascii_out_proc("\r\n"); + } + + } + else if(snmp_agent_flag==1) + { + + field_id=mib_curr_node->total_child_nodes-debug_get_all_value; + tmp_param_field=&snmp_agent_packet.param_field_arr[field_id]; + if(param_node->select_total!=0) + { + + tmp_param_field->curr_select_id=curr_select_id; + for(index=0; indexselect_total; index++) + { + tmp_param_field->value_arr[index]=param_node->select_ptr[index]->number; + strcpy(tmp_param_field->value_arr_remark[index],param_node->select_ptr[index]->description); + } + tmp_param_field->total_select=param_node->select_total; + tmp_param_field->curr_input_value[0]='\0'; + tmp_param_field->input_type=0xFF; + } + else if(param_node->input_ptr!=NULL) + { + tmp_param_field->curr_select_id=0xFF; + for(index=0; indexvalue_arr[index]=0xFF; + strcpy(tmp_param_field->value_arr_remark[index],""); + } + tmp_param_field->total_select=0; + strcpy(tmp_param_field->curr_input_value,out_text); + tmp_param_field->input_type=param_node->input_ptr->input_param_type; + } + strcpy(tmp_param_field->name,param_node->name); + } + else if(field_compute_state==4 ) + { + if(param_node->select_total!=0) + { + sprintf(temp_str,"%d",param_node->select_ptr[curr_select_id]->number); + strcpy(compute_field_list[compute_field_list_index].field_val[mib_curr_node->curr_instance+bind_index-1],temp_str); + } + else if(param_node->input_ptr!=NULL) + { + strcpy(compute_field_list[compute_field_list_index].field_val[mib_curr_node->curr_instance+bind_index-1],out_text); + } + } + + } + + if(debug_get_all_value==301) + debug_get_all_value=1; + debug_get_all_value--; + + + } + + } + } + } + if(snmp_agent_flag==1) + { + + if(bind_num==1) + { + memcpy(&debug_snmp_agent_buf[debug_agent_index],&snmp_agent_packet,sizeof(debug_snmp_agent)); + debug_snmp_agent_buf[debug_agent_index].cmm_state=5; + debug_snmp_agent_buf[debug_agent_index].result_state=0; + } + else + { + memcpy(&debug_snmp_agent_buf[bind_index],&snmp_agent_packet,sizeof(debug_snmp_agent)); + debug_snmp_agent_buf[bind_index].cmm_state=5; + debug_snmp_agent_buf[bind_index].result_state=0; + debug_snmp_agent_buf[bind_index].oid[debug_snmp_agent_buf[bind_index].oid_len-1]=mib_curr_node->curr_instance+bind_index; + } + + } + bind_index++; + //printf("send ins %d ",mib_curr_node->curr_instance+bind_index); + if(bind_indextotal_child_nodes>4) + return; + } + if(snmp_agent_flag==0 && list_once==1) + { + if(recv_msgbuf.var[bind_index].vartype == 5) //NULL + { + debug_ascii_out_proc("Error : NULL\r\n"); + } + else if(recv_msgbuf.var[bind_index].vartype == 6) //Object identifier + { + debug_ascii_out_proc("Error : Object identifier wrong\r\n"); + } + else if(recv_msgbuf.var[bind_index].vartype == 0x80) //noSuchObject + { + debug_ascii_out_proc("Error : noSuchObject\r\n"); + } + else if(recv_msgbuf.var[bind_index].vartype == 0x81) //NoSuchInstance + { + debug_ascii_out_proc("Error : NoSuchInstance\r\n"); + } + else if(recv_msgbuf.var[bind_index].vartype == 0x82) //endOfMibView + { + debug_ascii_out_proc("Error : endOfMibView\r\n"); + } + } + //sprintf(out_text,"%d-%d ",debug_snmp_agent_buf[debug_agent_index].cmm_state,debug_snmp_agent_buf[debug_agent_index].result_state); + ip_index = 0; + if(list_flag==0) + debug_cfg_end=1; + if(((list_start>=list_end && list_flag) || !list_flag) && !snmp_agent_flag) + { + get_state=0; + bind_num=0; + bind_index=0; + } + if(snmp_agent_flag>0) + get_state=0; + if(snmp_agent_flag>0) + bind_index=0; + get_show_state=0; + //if(snmp_agent_flag==0) + // bind_num=0; + //snmp_agent_flag=0; + expend_view=0; + debug_get_all_value = 0; + t5s_flag=0; + break; + default: + debug_ascii_out_proc("\r\nError : no value for this node.\r\nFail\r\n"); + while(debug_get_all_value != 0) + { + param_node = mib_curr_node->child_nodes[mib_curr_node->total_child_nodes - debug_get_all_value]->child_ptr; + if( strncmp(param_node->name, "Reserved", 8) == 0 ) + { + sprintf(out_text, "%d Reserved.\r\n",1+mib_curr_node->total_child_nodes - debug_get_all_value); + debug_ascii_out_proc(out_text); + debug_get_all_value--; + } + else + break; + } + if(debug_get_all_value != 0) + { + param_node = mib_curr_node->child_nodes[mib_curr_node->total_child_nodes - debug_get_all_value]->child_ptr; + sprintf(out_text, "%d %s = ", 1+mib_curr_node->total_child_nodes - debug_get_all_value, param_node->name); + debug_get_all_value--; + debug_ascii_out_proc(out_text); + debug_cfg_end = 0; + get_state = 3; + } + else + { + ip_index =0; + debug_cfg_end = 1; + get_state = 0; + } + break; + } + +}//end of debug_snmp_get_rt + + + +/* +* +* Fun: debug_snmp_set_rt +* +* Desc: get the mib_node's value from the host by snmp, then analyze and replace the value of its field's value, then set back the mib_node's value to the host by snmp +* +* Ret: RVOID +* +* Notes: Wang Jian add +* +* File: debug.c +* +*/ +void debug_snmp_set_rt() +{ + int request_id=0, index; + char out_text[256]=""; + char out_text2[256]=""; + int ins_byte,ins_bit; + mib_node_param *temp_param; + int i; + + switch(set_state) + { + case 0: //idle + break; + case 1: //send the not null and selected ip in the Peer_IP[16] set request to local host + t5s_flag=0; + if(ip_index >= ip_num) + { + debug_cfg_end = 1; + set_state = 0; + ip_index = 0; + set_ok_once=0; + save_flag=0; + break; + } + if(Peer_IP[ip_index] == 0) + { + debug_cfg_end = 1; + set_state = 0; + if(snmp_agent_flag==0) + { + if(ip_index == 0 ) + debug_color_out(BRIGHT,RED,BLACK,"Error : There is not host ip available.\r\n"); + + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=4; + mib_curr_node=agent_tmp_node; + return ; + } + ip_index = 0; + break; + } + + if(IP_Selected[ip_index] == 1) + send_addr.remote_ip = Peer_IP[ip_index]; + else + { + for(; ip_index 250) + { + if(snmp_agent_flag==0) + { + if(save_flag>=3) + { + + //debug_ascii_out_proc("Status : "); + //sprintf(out_text,"Fail to save the module of %s,time out,please check the host\r\n",subsys_module[curr_module].name); + //debug_color_out(BRIGHT,CYAN,BLACK,out_text); + mib_curr_node=temp_mib_node; + sprintf(out_text, "Host : %s %s (State: Time out !)\r\n", Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + if(save_flag==3) + debug_mmi_contents(""); + if(debug_cfg==1) + mib_curr_node=temp_mib_node; + else if(debug_cfg==2) + { + menu_curr_node=tmp_menu_node; + mib_curr_node=temp_mib_node; + } + save_flag=0; + } + else + sprintf(out_text, "Host : %s %s (State: Time out !)\r\n", Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + debug_color_out(BRIGHT,RED,BLACK,out_text); + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=1; + mib_curr_node=agent_tmp_node; + snmp_agent_flag=0; + } + ip_index++; + debug_cfg_end = 0; + set_ok_once=0; + set_state = 1; + break; + } + else + break; + } + else //received + { + char byte_val1[16]; + if(snmp_agent_flag==0) + { + if(save_flag<3 || save_flag==4) + { + // debug_ascii_out_proc("OldValue: "); + for(index=0; indexbyte_begin, param_node->bit_begin, param_node->byte_end, param_node->bit_end); + //debug_color_out(BRIGHT,YELLOW,BLACK,out_text1);//for look + } + if(recv_msgbuf.error_status != 0) + { + if(snmp_agent_flag==0) + { + //sprintf(out_text, "Error : get value from the host: %s %s\r\n",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + //debug_color_out(BRIGHT,RED,BLACK,out_text); + switch(recv_msgbuf.error_status) + { + case 1: + debug_color_out(BRIGHT,RED,BLACK,"Error : TooBig\r\n"); + break; + case 5: + debug_color_out(BRIGHT,RED,BLACK,"Error : GenErr\r\n"); + break; + case 6: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoAccess\r\n"); + break; + case 7: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongType\r\n"); + break; + case 8: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongLength\r\n"); + break; + case 9: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongEncoding\r\n"); + break; + case 10: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongValue\r\n"); + break; + case 11: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoCreation\r\n"); + break; + case 12: + debug_color_out(BRIGHT,RED,BLACK,"Error : inconsistentValue\r\n"); + break; + case 13: + debug_color_out(BRIGHT,RED,BLACK,"Error : resourceUnavailable\r\n"); + break; + case 14: + debug_color_out(BRIGHT,RED,BLACK,"Error : commitFailed\r\n"); + break; + case 15: + debug_color_out(BRIGHT,RED,BLACK,"Error : UndoFailed\r\n"); + break; + case 16: + debug_color_out(BRIGHT,RED,BLACK,"Error : AuthorizationError\r\n"); + break; + case 17: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoWritable\r\n"); + break; + case 18: + debug_color_out(BRIGHT,RED,BLACK,"Error : inconsistentName\r\n"); + break; + default: + break; + } + ip_index++; + debug_cfg_end = 0; + set_state = 1; + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=9; + mib_curr_node=agent_tmp_node; + snmp_agent_flag=0; + } + break; + } + else if((recv_msgbuf.var[0].vartype == 2) || (recv_msgbuf.var[0].vartype == 4)) //int or string + { + char out_text[128]; + int index2, index3, index4; + DWORD sum; + int sub_sum; + //int child_index; + strcpy(out_text, ""); + if(debug_snmp_agent_buf[debug_agent_index].cmm_state==3 && snmp_agent_flag==2) + { + index2=mib_curr_node->data_length*2; + for(i=0;ienable_field_id!=0xFF) + { + param_node = (mib_node_param *)mib_curr_node->child_nodes[mib_curr_node->enable_field_id]->child_ptr; + + if(param_node->byte_begin==param_node->byte_end && param_node->bit_begin ==param_node->bit_end) + { + ins_byte=param_node->byte_begin; + ins_bit=param_node->bit_begin ; + if(del_flag==0) + { + recv_msgbuf.var[0].msg[ins_byte] =recv_msgbuf.var[0].msg[ins_byte] | (BYTE)my_pow(2,ins_bit); + } + else + { + recv_msgbuf.var[0].msg[ins_byte] =recv_msgbuf.var[0].msg[ins_byte] & (~(BYTE)my_pow(2,ins_bit)); + } + } + } + set_all=0; + } + else + { + temp_param=param_node; + + if(mib_curr_node->enable_field_id!=0xFF) + { + param_node = (mib_node_param *)mib_curr_node->child_nodes[mib_curr_node->enable_field_id]->child_ptr; + + if(param_node->byte_begin==param_node->byte_end && param_node->bit_begin ==param_node->bit_end) + { + ins_byte=param_node->byte_begin; + ins_bit=param_node->bit_begin ; + if(del_flag==0) + recv_msgbuf.var[0].msg[ins_byte] =recv_msgbuf.var[0].msg[ins_byte] | (BYTE)my_pow(2,ins_bit); + else + recv_msgbuf.var[0].msg[ins_byte] =recv_msgbuf.var[0].msg[ins_byte] & (~(BYTE)my_pow(2,ins_bit)); + } + } + param_node=temp_param; + if(param_node->select_total != 0) + { + index3 = sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + } + else if(param_node->input_ptr != NULL) + { + switch(param_node->input_ptr->input_param_type) + { + case 0: //toDec_high_0 + strcpy(out_text, ""); + index3 = sum = 0; + for(index=param_node->byte_end; index >=param_node->byte_begin; index--) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + index3++; + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + + } + if( (index == param_node->byte_begin) && (((param_node->byte_begin==param_node->byte_end)&& index2 == param_node->bit_end) || ((param_node->byte_begin!=param_node->byte_end)&& index2==7))) + break; + } + break; + case 1: //keepHex_high_0 + case 2: //keepHex_low_0 + case 3: //keepHex_low_E + case 4: //keepHex_low_F + strcpy(out_text, ""); + index3 = index4 = sum = sub_sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + if((index3 == 0) && ( (index4+1) <= strlen(set_val_str) )) //\u53D6\u4E24\u4F4D\u5B57\u7B26 + { + set_val = 0; + if( isdigit(set_val_str[index4]) ) //\u6570\u5B57\u5B57\u7B26 + set_val += (set_val_str[index4++] - '0') * 16; + else // A \u81F3 E \u4E4B\u95F4 + set_val += (set_val_str[index4++] - 'A' + 10) * 16; + + if( isdigit(set_val_str[index4]) ) + set_val += set_val_str[index4++] - '0'; + else + set_val += set_val_str[index4++] - 'A' + 10; + } + + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + if(index3 == 8) + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + break; + case 5: //toAscii_low_0 + case 6: //keepAscii_low_F + strcpy(out_text, ""); + index3 = index4 = sum = sub_sum = 0; + for(index=param_node->byte_begin; index <= param_node->byte_end; index++) + { + if(index == param_node->byte_begin) + index2 = param_node->bit_begin; + else + index2 = 0; + if(index3 == 0) //\u53D6\u4E00\u4F4D\u5B57\u7B26 + set_val = set_val_str[index4++]; + + for(; index2<8; index2++) + { + if((set_val & (BYTE)my_pow(2, index3)) == 0) + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] & (255 - my_pow(2, index2)); + else + recv_msgbuf.var[0].msg[index] = recv_msgbuf.var[0].msg[index] | my_pow(2, index2); + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + index3++; + if(index3 == 8) + index3 = 0; + } + if( (index == param_node->byte_end) && (index2 == param_node->bit_end)) + break; + } + break; + default: + if(snmp_agent_flag==0) + { + sprintf(out_text, "Get value (%s)\r\n", recv_msgbuf.var[0].msg); + debug_ascii_out_proc(out_text); + sprintf(out_text,"from the host: %s %s.\r\nBut can not parse the value type (%d).\r\n", Remote_Host_Name[ip_index], Remote_Host_IP[ip_index], recv_msgbuf.var[0].vartype); + debug_ascii_out_proc(out_text); + } + ip_index++; + debug_cfg_end = 0; + set_state = 1; + return; + } + } + } + } + // send set request + t5s_flag=0; + recv_msgbuf.pdu_type = 3; + recv_msgbuf.request_id = 0; + recv_addr.remote_ip = Peer_IP[ip_index]; + request_id = snmp_send(&recv_msgbuf, &recv_addr); + if(request_id == 0) + { + if(snmp_agent_flag==0) + { + sprintf(out_text, "Error : Fail to send snmp set request to the host: %s %s\r\n",Remote_Host_Name[ip_index],Remote_Host_IP[ip_index]); + debug_color_out(BRIGHT,RED,BLACK,out_text); + } + ip_index++; + debug_cfg_end = 0; + set_state =1; + } + else + { + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = request_id; + recv_addr.remote_ip = Peer_IP[ip_index]; + set_state = 3; + } + break; + } + else + { + if(snmp_agent_flag==0) + { + if(recv_msgbuf.var[0].vartype == 5) //NULL + { + debug_color_out(BRIGHT,RED,BLACK,"Error : NULL\r\n"); + } + else if(recv_msgbuf.var[0].vartype == 6) //Object identifier + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Object identifier wrong\r\n"); + } + else if(recv_msgbuf.var[0].vartype == 0x80) //noSuchObject + { + debug_color_out(BRIGHT,RED,BLACK,"Error : noSuchObject\r\n"); + } + else if(recv_msgbuf.var[0].vartype == 0x81) //NoSuchInstance + { + debug_color_out(BRIGHT,RED,BLACK,"Error : NoSuchInstance\r\n"); + } + else if(recv_msgbuf.var[0].vartype == 0x82) //endOfMibView + { + debug_color_out(BRIGHT,RED,BLACK,"Error : endOfMibView\r\n"); + } + if(save_flag>3) + { + if(debug_cfg==1) + mib_curr_node=temp_mib_node; + else if(debug_cfg==2) + { + menu_curr_node=tmp_menu_node; + mib_curr_node=temp_mib_node; + } + save_flag=0; + } + } + } + + } + debug_cfg_end = 0; + ip_index++; + set_state = 1; + break; + case 3: //receive set response + request_id = snmp_receive(&recv_msgbuf, &recv_addr); + + if(request_id == 0) // not received + { + if(t5s_flag > 250) + { + if(snmp_agent_flag==0) + { + sprintf(out_text, "Error : Time out to set value to the host: %s %s\r\n",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + debug_color_out(BRIGHT,RED,BLACK,out_text); + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=1; + mib_curr_node=agent_tmp_node; + snmp_agent_flag=0; + } + ip_index++; + set_ok_once=0; + debug_cfg_end = 0; + set_state = 1; + break; + } + else + break; + } + else //received + { + if(snmp_agent_flag==0) + { + char out_text1[256], byte_val1[16]; + //debug_ascii_out_proc("\rStatus : "); + //debug_color_out(BRIGHT,CYAN,BLACK,"Successful! \r\n"); + //debug_ascii_out_proc("SNMP MSG: "); + //sprintf(out_text1, "receive snmp response: error_status: %d, vartype: %d, msg_len: %d\r\n",recv_msgbuf.error_status, recv_msgbuf.var[0].vartype, recv_msgbuf.var[0].msglen); + //debug_color_out(BRIGHT,CYAN,BLACK,out_text1); + strcpy(out_text1,""); + for(index=0; indexbyte_begin, param_node->bit_begin, param_node->byte_end, param_node->bit_end); + //debug_color_out(BRIGHT,YELLOW,BLACK,out_text1);//for look + //debug_ascii_out_proc("\r\n"); + //} + //*/ + } + if(recv_msgbuf.error_status != 0) + { + if(snmp_agent_flag==0) + { + //sprintf(out_text, "Error : set value to the host: %s %s\r\n",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + //debug_color_out(BRIGHT,RED,BLACK,out_text); + switch(recv_msgbuf.error_status) + { + case 1: + debug_color_out(BRIGHT,RED,BLACK,"Error : TooBig\r\n"); + break; + case 5: + debug_color_out(BRIGHT,RED,BLACK,"Error : GenErr\r\n"); + break; + case 6: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoAccess\r\n"); + break; + case 7: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongType\r\n"); + break; + case 8: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongLength\r\n"); + break; + case 9: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongEncoding\r\n"); + break; + case 10: + debug_color_out(BRIGHT,RED,BLACK,"Error : WrongValue\r\n"); + break; + case 11: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoCreation\r\n"); + break; + case 12: + debug_color_out(BRIGHT,RED,BLACK,"Error : inconsistentValue\r\n"); + break; + case 13: + debug_color_out(BRIGHT,RED,BLACK,"Error : resourceUnavailable\r\n"); + break; + case 14: + debug_color_out(BRIGHT,RED,BLACK,"Error : commitFailed\r\n"); + break; + case 15: + debug_color_out(BRIGHT,RED,BLACK,"Error : UndoFailed\r\n"); + break; + case 16: + debug_color_out(BRIGHT,RED,BLACK,"Error : AuthorizationError\r\n"); + break; + case 17: + debug_color_out(BRIGHT,RED,BLACK,"Error : NoWritable\r\n"); + break; + case 18: + debug_color_out(BRIGHT,RED,BLACK,"Error : inconsistentName\r\n"); + break; + default: + break; + } + } + else + { + debug_snmp_agent_buf[debug_agent_index].cmm_state=4; + debug_snmp_agent_buf[debug_agent_index].result_state=9; + mib_curr_node=agent_tmp_node; + snmp_agent_flag=0; + } + } + else + { + if( save_flag==4) + { + debug_ascii_out_proc("Host : "); + sprintf(out_text, "%s %s (State: Successful!)\r\n",Remote_Host_Name[ip_index], Remote_Host_IP[ip_index]); + debug_color_out(BRIGHT,YELLOW,BLACK,out_text); + if(debug_cfg==1) + mib_curr_node=temp_mib_node; + else if(debug_cfg==2) + { + menu_curr_node=tmp_menu_node; + mib_curr_node=temp_mib_node; + } + + } + + } + } + debug_cfg_end = 0; + set_state = 1; + if(snmp_agent_flag==0) + { + if(save_flag>=3) + { + if(debug_cfg==1) + mib_curr_node=temp_mib_node; + else if(debug_cfg==2) + { + menu_curr_node=tmp_menu_node; + mib_curr_node=temp_mib_node; + } + if(save_flag==3 && ip_index==0) + debug_mmi_contents(""); + save_flag=5; + ip_index++; + break; + } + } + if(recv_msgbuf.error_status == 0) + { + if(snmp_agent_flag==2) + { + set_after_get=1; + debug_snmp_agent_buf[debug_agent_index].cmm_state=1; + debug_snmp_agent_buf[debug_agent_index].result_state=0; + snmp_agent_flag=1; + } + else + { + if(save_flag<3 && !set_ok_once) + { + get_state=3; + set_ok_once=1; + } + } + bind_num=1; + set_state=0; + debug_get_all_value = mib_curr_node->total_child_nodes; + } + if(del_flag==1) + debug_mmi_contents("*"); + del_flag=0; + ip_index++; + if(snmp_agent_flag==0) + set_state=1; + break; + + default: + ip_index=0; + debug_cfg_end = 1; + set_state = 0; + break; + } +}//end of debug_snmp_set_rt + +int debug_snmp_get(BYTE oidlen,DWORD *oid,BYTE *data_ptr,BYTE *vartype) +{//?? + DWORD ii; + BYTE temp_id; + struct debug_module_struct *module_ptr; + + switch(oid[12]) + { + case 0: + break; + case 1: + break; + case 2: // configure + if (oid[13] > MODULE_COUNT+1 || oid[13] < 2) + return -1; + temp_id = oid[13] - 2; + module_ptr = (struct debug_module_struct *) &debug_shm_ptr->module_d[temp_id]; + switch(oid[14]) + { + case 0: + break; + case 1: + data_ptr[0] = module_ptr->status[0]; + *vartype = 4; + return 1; + break; + case 2: + strcpy(data_ptr,module_ptr->version); + return strlen(module_ptr->version); + break; + case 3: // ascii in buffer + break; + case 4: // ascii out buffer + switch (oid[15]) + { + case 1: // get tail seq id + ii = u32tobcd(data_ptr,module_ptr->seqid_t); + *vartype = 4; + return ii; + break; + case 2: // get head seq id + ii = u32tobcd(data_ptr,module_ptr->seqid_h); + *vartype = 4; + return ii; + break; + case 3: // get out buffer + if (module_ptr->seqid_h < module_ptr->seqid_t) + { + ii = module_ptr->seqid_h + DEBUG_MAX_SEQID; + if (oid[16] >= ii || oid[16] < module_ptr->seqid_t) + return -1; + } + else + { + if (oid[16] >= module_ptr->seqid_h || oid[16] < module_ptr->seqid_t) + return -1; + } + ii = oid[16] % DEBUG_SEQID_LEN; + strcpy(data_ptr,module_ptr->omc_outbuf[ii]); + *vartype = 4; + return strlen(module_ptr->omc_outbuf[ii]); + break; + default: + break; + } + break; + default: + break; + } + break; + default: + break; + } + return -1; +} + +int debug_snmp_set(BYTE oidlen,DWORD *oid,BYTE *data_ptr,WORD data_len) +{ + BYTE temp_id; + + switch(oid[12]) + { + case 0: + break; + case 1: + break; + case 2: // configure + if (oid[13] > MODULE_COUNT+1 || oid[13] < 2) + return -1; + temp_id = oid[13] - 2; + if (oid[14] != 3) // not ascii in buffer + return -1; + if (data_len < 80) + { + if (debug_shm_ptr->module_d[temp_id].ascii_in_set_flag == 1) + { + debug_shm_ptr->module_d[temp_id].ascii_in[0] = disp_page_flag + 1; + memcpy(debug_shm_ptr->module_d[temp_id].ascii_in+1,data_ptr,data_len); + debug_shm_ptr->module_d[temp_id].ascii_in[data_len+1] = '\0'; + } + return data_len; + } + break; + default: + break; + } + return -1; +} + +void debug_mmi_list() +{ + int cur_b,cur_end,list_give_num; + char cur_c[64],temp[2],*p,arr[256],temp_str[256*5],*temp_ch; + char ins_str[16]; + int i,j; + DWORD k; + BYTE index; + mib_child_node *child_node_ptr; + if(strlen(list_msg)>96) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : No need so long string!\r\n"); + list_flag=0; + debug_cfg_end=1; + return; + } + switch(list_flag) + { + case 0: //idel + return; + case 1: + strcpy(arr,list_msg); + for(i=0;i!=strlen(arr);i++) + { + if(*(arr+i)!=' ') + break; + } + p=arr+i; + strcpy(arr,p); + list_give_num=0; + if(mib_curr_node->total_instance==0) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : This is not leaf node,so can't list the para and value.\r\n"); + list_flag=0; + debug_cfg_end=1; + return; + } + strcpy(temp,""); + p=temp; + if(strlen(arr)==0) + { + list_give_num=0; + } + while(strlen(arr)!=0) + { + for(i=0;i!=strlen(arr);i++) + { + if(*(arr+i)!=' ') + break; + } + p=arr+i; + strcpy(temp_str,""); + strcpy(temp_str,p); + strcpy(arr,temp_str); + i=0; + if(arr[0]!='-' && !isdigit(arr[0])) + { + debug_color_out(BRIGHT,RED,BLACK,"Fail : Format is not right!list [-a] [-e] [xxx-xxx].\r\n"); + list_flag=0; + debug_cfg_end=1; + return; + } + + else if(strncmp(arr,"-s",2)==0) //show get state,default hide + { + show_snmp_state=1; + p=arr+2; + strcpy(arr,p); + } + else if(strncmp(arr,"-a",2)==0) //show all include NULL,default hide + { + show_all_value=1; + p=arr+2; + strcpy(arr,p); + } + else if(strncmp(arr,"-f",2)==0) //show the special field + { + for(i=2;i=3) + { + sprintf(cur_c,"Error : Please input number between 1-%d!\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,RED,BLACK,cur_c); + list_flag=0; + debug_cfg_end=1; + return; + } + } + if(i!=0) + { + strncpy(cur_c,temp_ch,i); + list_field_arr[index]=atoi(cur_c); + if(list_field_arr[index]<1 || list_field_arr[index]>(mib_curr_node->total_child_nodes)) + { + sprintf(cur_c,"Error : Please input number between 1-%d!\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,RED,BLACK,cur_c); + list_flag=0; + debug_cfg_end=1; + return; + } + else + index++; + } + if(*(temp_ch+i)!='\0') + k+=i+1; + else + k+=i; + j=0; + } + } + + else if(strncmp(arr,"-r",2)==0) //show para arrange,default hide + { + show_range=1; + p=arr+2; + strcpy(arr,p); + } + + + else if(strncmp(arr,"-t",2)==0) //show para type,defualt hide + { + show_type=1; + p=arr+2; + strcpy(arr,p); + } + + else if(strncmp(arr,"-e",2)==0) //show without expand ,defualt expand + { + show_expend=0; + p=arr+2; + strcpy(arr,p); + } + else if(isdigit(arr[0]) || (arr[0]=='-' && isdigit(arr[1]))) + { + p=temp; + for(i=0;i<=strlen(arr);i++) + { + *p=arr[i]; + if(!isdigit(*p) && *p!='-') + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Please input number!format list:2-10\r\n"); + list_flag=0; + debug_cfg_end=1; + return; + } + if(*p=='-') + { + if(i>=1) + { + strncpy(cur_c,arr,i); + cur_b=strtoul(cur_c,NULL,10); + break; + } + else + { + cur_b=0; + break; + } + } + } + i++; + if(i==(strlen(arr)+2)) + cur_end=mib_curr_node->total_instance-1; + else + { + strcpy(cur_c,""); + for(;itotal_instance-1; + } + list_start=cur_b; + list_end=cur_end; + if(list_start>list_end) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Input error!Example:list -a -e 2-10!\r\n"); + list_flag=0; + debug_cfg_end=1; + return; + } + if(list_end>mib_curr_node->total_instance-1) + { + sprintf(cur_c,"Error : The max instance num is %d!\r\n",mib_curr_node->total_instance-1); + debug_color_out(BRIGHT,RED,BLACK,cur_c); + list_flag=0; + debug_cfg_end=1; + return; + } + list_flag=2; + debug_cfg_end=0; + break; + case 2: + //temp_instance=mib_curr_node->curr_instance; + if(list_start<=list_end) + { + mib_curr_node->curr_instance=(DWORD)list_start; + if(list_start+15<=list_end) + bind_num=16; + else + bind_num=list_end-list_start+1; + send_msgbuf.pdu_type = 0; + send_msgbuf.request_id = 0; + send_msgbuf.var_num =bind_num; + for(j=0;joid[i]; + send_msgbuf.var[j].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance+j; + send_msgbuf.var[j].oidlen = mib_curr_node->oid_len + 1; + } + for(ip_index=0;ip_index<16;ip_index++) + { + if(IP_Selected[ip_index] != 1) + continue; + send_addr.remote_ip = Peer_IP[ip_index]; + break; + } + if(ip_index>=16) + { + debug_ascii_out_proc("Fail : There is not host ip available.\r\n"); + return ; + } + send_addr.local_ip = Local_IP; + send_addr.remote_port = SNMP_PORT; + send_addr.local_port = DEBUG_SNMP_PORT; + send_addr.broadcast = 0; + recv_msgbuf.pdu_type = 2; + recv_msgbuf.request_id = 0; + recv_msgbuf.var_num = bind_num; + for(j=0;joid[i]; + recv_msgbuf.var[j].oid[mib_curr_node->oid_len] = (DWORD)mib_curr_node->curr_instance+j; + recv_msgbuf.var[j].oidlen = mib_curr_node->oid_len + 1; + for(i=0; i<256; i++) + recv_msgbuf.var[j].msg[i] = 0; + } + recv_addr.remote_ip = send_addr.remote_ip; + recv_addr.local_ip = Local_IP; + recv_addr.remote_port = SNMP_PORT; + recv_addr.local_port = DEBUG_SNMP_PORT; + recv_addr.broadcast = 0; + bind_index=0; + get_state=1; + debug_cfg_end = 0; + list_field=mib_curr_node->total_child_nodes; + list_start+=bind_num; + } + list_flag=3; + break; + case 3: + if(get_state==3 && bind_index=bind_num && bind_num!=0 && list_start=list_end+1) + { + + show_all_value=0; + show_type=0; + show_range=0; + show_field=0; + bind_num=1; + bind_index=0; + show_snmp_state=0; + show_expend=1; + debug_cfg_end=0; + /* + if(read_syntax_nor_list==0 && list_once==1) + { + list_start=0; + list_end=0; + list_flag=0; + compute_field_list_index++; + if(compute_field_list_index == compute_list_num && compute_field_list_index>0) + { + read_syntax_nor_list = 1; + field_compute_state=5; + mib_curr_node=temp_compute_node; + list_field=mib_curr_node->total_child_nodes; + debug_mmi_get_all(); + debug_cfg_end=0; + } + return; + } + */ + + + list_flag=4; + break; + } + if(t5s_flag> 250 && list_once==0) + { + list_flag=0; + list_start=0; + list_end=0; + debug_ascii_out_proc("Instance: "); + debug_color_out(BRIGHT,RED,BLACK,"Unknow Because can not get it value in time\r\n"); + strcpy(temp_str,""); + debug_ascii_out_proc("Child : "); + sprintf(temp_str, "[%d]\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + + for (i = 0; i < mib_curr_node->total_child_nodes; i++) + { + child_node_ptr = mib_curr_node->child_nodes[i]; + if(child_node_ptr) + sprintf(temp_str, " |---(%ld) %s\r\n",child_node_ptr->oid+1,child_node_ptr->name); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + } + debug_cfg_end=1; + } + break; + case 4: + if(list_once==0) + { + if(list_start>=list_end+1) + { + for(i=0;i<256;i++) + { + if(curr_instance_arr[i].eable==1) + break; + } + if(i==256) + { + //debug_color_out(BRIGHT,RED,BLACK,"Error : no instance was used!\r\n"); + none_instance=1; + } + else + none_instance=0; + mib_curr_node->curr_instance=i; + temp_instance=mib_curr_node->curr_instance; + } + } + else + mib_curr_node->curr_instance=temp_instance; + + if (mib_curr_node->total_instance) + { + strcpy(temp_str,""); + strcpy(ins_str,""); + k=0; + for(i=0;i<=255;i++) + { + if(curr_instance_arr[i].eable==1) + { + sprintf(ins_str,"#%-3d ",i); + strpcat(temp_str,&k,ins_str); + } + } + debug_ascii_out_proc("Instance: "); + strcpy(ins_str,""); + if(k) + sprintf(ins_str, "#%-3d(%-3d): ", mib_curr_node->curr_instance,mib_curr_node->total_instance); + else + sprintf(ins_str, "None(%-3d): ", mib_curr_node->total_instance); + debug_color_out(BRIGHT,YELLOW,BLACK,ins_str); + debug_color_out(BRIGHT,BLUE,BLACK,temp_str); + debug_ascii_out_proc("\r\n"); + if(k) + none_instance=0; + else + none_instance=1; + } + list_flag=0; + get_state=0; + debug_cfg_end=1; + + IP_Selected[0]=1; + for(i=1;i<16;i++) + IP_Selected[i]=0; + if(list_once==0) + { + if(none_instance==0) + { + if(mib_curr_node->max_access>=2 && mib_curr_node->max_access<=5) + { + + debug_mmi_get_all(); + debug_cfg_end=0; + } + } + else + { + + strcpy(temp_str,""); + debug_ascii_out_proc("Child : "); + sprintf(temp_str, "[%d]\r\n",mib_curr_node->total_child_nodes); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + + for (i = 0; i < mib_curr_node->total_child_nodes; i++) + { + child_node_ptr = mib_curr_node->child_nodes[i]; + sprintf(temp_str, " |---(%ld) %s\r\n",child_node_ptr->oid+1, child_node_ptr->name); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str); + } + debug_cfg_end=1; + + } + } + list_once=1; + list_start=0; + list_end=0; + list_flag=0; + break; + + } + return ; +} + + + +void register_instance() +{ + char ascii_text[32],byte_val1[8]; + int i,index; + if(mib_curr_node->total_instance) + { + memset(curr_instance_value,0,sizeof(char)); + //strncpy(curr_instance_value,mib_curr_node->init_value,mib_curr_node->data_length); + *curr_instance_value='\0'; + for(index=0; indexdata_length; index++) + { + if((mib_curr_node->init_value[index] & 0xF0)==0) + { + strcat(curr_instance_value,"0"); + sprintf(byte_val1,"%X",mib_curr_node->init_value[index]); + strcat(curr_instance_value,byte_val1); + } + else + { + sprintf(byte_val1, "%X", mib_curr_node->init_value[index]); + strcat(curr_instance_value,byte_val1); + } + } + gcvt((double)(mib_curr_node->total_instance-1),3,ascii_text); + strcpy(list_msg,""); + strcat(list_msg," -e "); + strcat(list_msg,"0"); + strcat(list_msg,"-"); + strcat(list_msg,ascii_text); + + + //default_value(mib_curr_node->oid,mib_curr_node->oid_len,curr_instance_value); + show_list=0; + for(i=0;i<=255;i++) + { + curr_instance_arr[i].eable=0; + } + debug_mmi_list(); + } +} + + + +//////////////////////////////End of Operation get-set/////////// + + + + +//////////////////////////////Data Send and recieve////////////// + +void debug_send_serial() +{ + //int n; + int i; + message_list iptr_msg; + + for (i = 0;i < MAX_SEND_CHAR_NUM ;i ++) + { + if (sendserbuf_t != sendserbuf_h) + { + //n = write(com_port,&sendser_buf[sendserbuf_t],1); + // if (n > -1) + // { + debug_shm_ptr->TelnetSendData.telsend_data[debug_shm_ptr->TelnetSendData.telsend_datah] = sendser_buf[sendserbuf_t]; + sendserbuf_t = (sendserbuf_t + 1) % SERIAL_BUF_LEN; + debug_shm_ptr->TelnetSendData.telsend_datah = (debug_shm_ptr->TelnetSendData.telsend_datah+1)%TELNET_SEND_BUF_LEN; + if (debug_shm_ptr->TelnetSendData.telsend_datah > 256) + // if (debug_shm_ptr->TelnetSendData.telsend_datah == 0) + SendTelnetFlag = 1; + // } + } + } + if (SendTelnetFlag == 1) + { + if (debug_shm_ptr->TelnetSendData.telsend_datah > 0) + { + iptr_msg.msgSrcPort = DEBUG_PORT; + iptr_msg.msgLength = debug_shm_ptr->TelnetSendData.telsend_datah; + memcpy(iptr_msg.msgContent,debug_shm_ptr->TelnetSendData.telsend_data,debug_shm_ptr->TelnetSendData.telsend_datah); + iptrPutMessage(iptr_msg); + memset(debug_shm_ptr->TelnetSendData.telsend_data,0,sizeof(BYTE)*TELNET_SEND_BUF_LEN); + debug_shm_ptr->TelnetSendData.telsend_datah = 0; + } + SendTelnetFlag = 0; + } +} + +int debug_send_char(BYTE ch) +{ + sendser_buf[sendserbuf_h] = ch; + sendserbuf_h = (sendserbuf_h + 1) % SERIAL_BUF_LEN; + return 1; +} + + +int debug_send_string(const char *str_send) +{ + int len,i; + i=0; + len=strlen(str_send); + if(sendserbuf_h+len>SERIAL_BUF_LEN && (sendserbuf_h+len)% SERIAL_BUF_LEN='a' && recser_buf[recserbuf_h]<='a'+MODULE_COUNT) + // send_char_flag=0; + recserbuf_h = (recserbuf_h + 1) % SERIAL_BUF_LEN; + } + } +} + +int debug_read_char() +{ + char sig; + + if (recserbuf_t == recserbuf_h) + return 0; + if (recserbuf_t != recserbuf_h) + { + sig = recser_buf[recserbuf_t]; + recserbuf_t = (recserbuf_t + 1) % SERIAL_BUF_LEN; + } + return sig; +} + + +void debug_recv_cmd() +{ + int i; + char pp; + int temp_page; + char pr_buf[30];//--lw + pp = debug_read_char(); + switch(pp) + { + case 0: + return; + case 113://"Q" + case 81: //'q' //--lw + { + first_page = 1; + disp_main_flag = 0; + if(debug_cfg) + debug_mmi_save(); + Init_Page=0; + mib_curr_node=mib_root_node; + menu_curr_node=menu_root_node; + debug_cfg=0; + debug_cfg_end=0; + debug_ascii_out_ph=debug_ascii_out_pt=0; + ascii_out_pt=ascii_out_ph=0; + /* + if(debug_cfg>0) + { + debug_send_char('C'); + debug_send_char('M'); + debug_send_char('M'); + debug_cfg=0; + } + */ + break; + } + } + switch (disp_main_flag) + { + case 0: // enter in menu page + if (isupper(pp)) // transfer the upper to lower + pp = tolower(pp); + if (pp == 'x') + { + m_state = 0; + disp_main_flag = 0; + } + //else if ((pp >= 'a') && (pp < 'a'+MODULE_COUNT)) + else if ((pp >= 'a') && ((pp <= 'a'+15 ) || (pp >= 17 + 'a' && pp <= 22 + 'a') || pp == 'y' || pp == 'z' ) ) //!=x !=q + { + disp_main_flag = 1; + debug_module_num= pp - 'a'; + disp_sub_module_flag = pp - 'a'; + if( disp_sub_module_flag >= PAGE_MODULE_COUNT ) + disp_sub_module_flag -= 2; + else if( disp_sub_module_flag > 16 && disp_sub_module_flag < 23 ) + disp_sub_module_flag--; + debug_module_num += disp_main_page_num*PAGE_MODULE_COUNT; + disp_sub_module_flag += disp_main_page_num*PAGE_MODULE_COUNT; + m_state_sub_module = 0; + disp_page_flag = 0; + command_flag = 0; + // title_top_pt = 0; + ascii_out_ph = ascii_out_pt = 0; + // strcpy(ascii_out_array,""); + // show the help info when enter in a new module + if(debug_shm_ptr != NULL) + if (debug_shm_ptr->module_d[disp_sub_module_flag].ascii_in_set_flag == 1) + { + debug_shm_ptr->module_d[disp_sub_module_flag].ascii_in[0] = disp_page_flag + 1; + strcpy(debug_shm_ptr->module_d[disp_sub_module_flag].ascii_in+1,"help"); + } + memset(current_timer,0,sizeof(current_timer)); + } + else if ((pp >= '1') && (pp <= '9')) + { + disp_main_page_num = pp - '1'; + if(disp_main_page_num >= DEBUG_MAX_PAGE) + disp_main_page_num = 0; + m_state = 0; + disp_main_flag = 0; + } + break; + case 1: // enter in module page + if (command_flag == 0) + { + if (isupper(pp)) // transfer the upper to lower + pp = tolower(pp); + if (pp == 'x') + { + disp_main_flag = 0; + m_state = 0; + disp_page_flag = 0; + } + else if ((pp >= '0') && (pp <= '9')) + { + temp_page = pp - '0'; + if ( (debug_shm_ptr->module_d[disp_sub_module_flag].page_d[temp_page].pointer_set_flag == 0) && (temp_page != 0)) + return; // invalid page + disp_page_flag = pp - '0'; + m_state_sub_module = 0; + // title_top_pt = 0; + } + else if ((pp >= 'a') && (pp <= 'f')) + { + temp_page = pp - 'a' + 0x0a; + if (debug_shm_ptr->module_d[disp_sub_module_flag].page_d[temp_page].pointer_set_flag == 0) + return; // invalid page + disp_page_flag = pp - 'a' + 0xa; + m_state_sub_module = 0; + // title_top_pt = 0; + } + else if (pp == 27) // ESC + { + //debug_clear_serial(); + if (disp_page_flag != 0) // not page 0 + { + for (i = 0;i < strlen(prompt_line25);i ++) + debug_send_char(prompt_line25[i]); + } + else + { + //debug_send_char(0xa);//--lw + //debug_send_char(0xd);//--lw + if(disp_sub_module_flag == ('n'-'a')) + { + if(debug_cfg == 0) //cmm status + { + if(debug_module_num == ('n'-'a')) + { + sprintf(pr_buf,"CMM>"); + Init_Page=2; + TxtColor(BRIGHT,WHITE,BLACK,pr_buf); + for(i=0;i<30;i++) + if(pr_buf[i]!='\0') + debug_send_char(pr_buf[i]); + else + break; + m_state_sub_module = 2; + } + else + { + sprintf(pr_buf,"%s>",debug_shm_ptr->module_d[debug_module_num].name); + TxtColor(BRIGHT,WHITE,BLACK,pr_buf); + for (i = 0;i < strlen(pr_buf);i ++) + debug_send_char(pr_buf[i]); + } + } + else if(debug_cfg ==1) //cfg status + { + sprintf(pr_buf,"CFG>"); + TxtColor(BRIGHT,WHITE,BLACK,pr_buf); + debug_send_string(pr_buf); + } + else if(debug_cfg==2) + { + sprintf(pr_buf,"MENU>"); + TxtColor(BRIGHT,WHITE,BLACK,pr_buf); + debug_send_string(pr_buf); + } + } + else + { + debug_send_string(debug_shm_ptr->module_d[disp_sub_module_flag].name); + debug_send_char('>'); + } + + } + ascii_in_array[0] = disp_page_flag + 1; + ascii_in_pt = 1; + command_flag = 1; + SendTelnetFlag = 1; + } + } + else // in command mode + { + switch (pp) + { + case 27: // ESC + //debug_send_char(0xa); + //debug_send_char(0xd); + command_flag = 0; + ascii_in_array[0] = disp_page_flag + 1; + ascii_in_pt = 1; + break; + case 8: // backspace + if (ascii_in_pt > 1) + ascii_in_pt -= 1; + debug_send_char(pp); + SendTelnetFlag = 1; + break; + case 10: // line feed + if (ascii_in_pt == 1) // empty + return; + break; + case 13: // return + if (ascii_in_pt == 1) // empty + return; + //debug_send_char(pp); + SendTelnetFlag = 1; + //if (disp_page_flag == 0) // display page 0 + // debug_send_char(10); // send line feed + ascii_in_array[ascii_in_pt] = '\0'; + if (debug_shm_ptr->module_d[disp_sub_module_flag].ascii_in_set_flag == 1) + strncpy(debug_shm_ptr->module_d[disp_sub_module_flag].ascii_in,ascii_in_array,80); + command_flag = 0; + ascii_in_pt = 0; + ascii_in_array[0] = '\0'; + break; + default: + ascii_in_array[ascii_in_pt++] = pp; + //debug_send_char(pp); + SendTelnetFlag = 1; + break; + } + } + break; + default: + disp_main_flag = 0; + break; + } +} + + + + +//////////////////////////////end of Data Send and recieve////////////// + +/////////////////////////////compute field//////////////////////////// + +/* +* +* [I]TG to Prefix +* { +* [v]OID="3.2.2.1.3" +* [l]OID.#.1 //for while +* [p]TG=(OID.*.1) //print +* } +* +* +* [I]Prefix to TG +* { +* [v]OID1="3.2.2.1.3" +* [v]OID2="3.2.2.1.4" +* [l]OID1.#.1 +* [l]OID2.#.1 +* [c](OID1.#.1)==(*) [p]prefix (#)=(OID2.#.1) //if +* } + */ +BYTE create_compute_field(FILE * fp, mib_node * node_ptr, BYTE field_id,char *name) +{ + char data_arr[256]; + + + compute_field_arr[compute_field_num].field_id = field_id; + strcpy(compute_field_arr[compute_field_num].name,name); + while(!feof(fp)) + { + mib_line_count++; + if(read_line(fp, data_arr) == 0) + continue; + del_space(data_arr, 2); + switch (data_arr[0]) + { + case '{': //"{" + break; + case '[': + if(data_arr[1] == 'c' || data_arr[1] == 'v' || data_arr[1] == 'p' || data_arr[1] == 'l') + { + if(strlen(data_arr) < 64) + strcpy(compute_field_arr[compute_field_num].syntax_str[compute_field_arr[compute_field_num].syntax_count], data_arr); + else + { + printf("[Debug] Error : Do not support so much line script for compute node.line:%d", mib_line_count); + return 0; + } + if(compute_field_arr[compute_field_num].syntax_count < 10) + compute_field_arr[compute_field_num].syntax_count++; + else + { + printf("[Debug] Error : Do not support so much line script for compute node.line:%d", mib_line_count); + return 0; + } + } + break; + case '}': + if(compute_field_num<16) + compute_field_num++; + else + return 0; + + return 1; + default: + printf("[Debug] Error : The mib compute field is not right.line:%d", mib_line_count); + return 0; + } + } + return 1; +} + +void translate_compute_field() +{ + char *p, *temp_ch, temp_str[32],temp_str1[64], line[64]; + DWORD oid[32]; + char cmp_value[2][32]; + char temp_value[32]; + BYTE i,j, value_index,read_next_line=1,index; + WORD curr_instance_index; + mib_node *find_list_node; + + if(field_compute_state == 1) + { + memset(OID_val, 0, 5 * 16 * sizeof(DWORD)); + memset(OID_name_str, 0, 5 * 32 * sizeof(char)); + line_index = 0; + OID_index=0; + compute_field_list_index=0; + compute_list_num=0; + compute_state = 0; + } + + if(read_syntax_nor_list>0) + { + while(line_index < compute_curr_unit.syntax_count && strlen(compute_curr_unit.syntax_str[line_index]) != 0) + { + if(!print_line_index) + field_compute_state=2; + else + field_compute_state=6; + if(read_syntax_nor_list == 0) + { + field_compute_state=3; + print_line_index=line_index; + return ; + } + if(read_next_line==1 && line_index 5) + { + printf("[Debug] Error: The max define oid number is 5.\r\n"); + return ; + } + temp_ch += 3; + p = strtok(temp_ch, "="); //variable name + strcpy(OID_name_str[OID_index], p); + p=strtok(NULL,"="); + strcpy(temp_str, p); + p = strtok(temp_str, "."); + for(i=0;i<9;i++) + OID_val[OID_index][i]=cur_oid[i]; + OID_val[OID_index][i++] = atoi(p); + while((p = strtok(NULL, "."))) + OID_val[OID_index][i++] = atoi(p); + OID_index++; + } + else if((temp_ch = strstr(line, "[l]")) != NULL) + { + compute_state = 2; + line_index--; + break; + } + else + { + printf("[Debug] Error: The compute filed script is error.\r\n"); + return ; + } + compute_state = 1; + break; + case 2: //[l] + if((temp_ch = strstr(line, "[l]")) != NULL) + { + temp_ch +=3; + /* + if(temp_ch[0] == '.' && temp_ch[1]=='#') + { + compute_field_list[compute_list_num].list_node = mib_curr_node; + strcpy(temp_str,temp_ch+3); + if(test_str(temp_str, 0) && atoi(temp_str) < MAX_SELECT_OPTION_NUM) + { + compute_field_list[compute_list_num].list_field_id = atoi(temp_str); + compute_list_num++; + break; + } + printf("[Debug] Error: The field id in [l] field is error.%s", temp_str); + return ; + } + else + */ + if((p=strtok(temp_ch,"."))!=NULL) + { + for(i = 0; i < OID_index && strlen(OID_name_str[i]) != 0; i++) + { + if(strcmp(OID_name_str[i], p) == 0) + break; + } + if(i == OID_index || strlen(OID_name_str[i]) == 0) + { + printf("[Debug] Error: Can not define the string:%s.\r\n", p); + return ; + } + for(j = 0; j < 32 && OID_val[i][j] != 0; j++) + { + oid[j] = OID_val[i][j]; + } + find_list_node=search_mib_node(mib_root_node,oid,j); + if(find_list_node!=NULL) + compute_field_list[compute_list_num].list_node = find_list_node; + else + { + printf("[Debug] Error: [l] field :no such mib node for the oid.\r\n"); + return ; + } + p=strtok(NULL,"."); + if(*p=='?') + { + if((p=strtok(NULL,"."))!=NULL) + { + if(test_str(p, 0) && atoi(p) < MAX_SELECT_OPTION_NUM) + { + compute_field_list[compute_list_num].list_field_id = atoi(p); + compute_list_num++; + break; + } + } + } + printf("[Debug] Error: [l] field is error.%s", temp_str); + return ; + } + } + else if((temp_ch = strstr(line, "[p]") )!= NULL) + { + read_syntax_nor_list = 0; + compute_state = 3; + line_index--; + break; + } + compute_state = 2; + break; + case 3: //[p] + if((temp_ch = strstr(line, "[p]")) != NULL && (strstr(line, "[c]")) == NULL) + { + temp_ch += 3; + for(i=0;temp_ch[i] != '\0';i++) + { + if(temp_ch[i] == '=') + break; + } + if(temp_ch[i] == '\0') + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + strncpy(temp_str, temp_ch, i); + temp_str[i] = '\0'; + if(strstr(temp_str,"(")) + { + for(i=0;temp_str[i] != '\0';i++) + { + if(temp_str[i] == '(') + break; + } + if(i == strlen(temp_str) && strstr(temp_str, ")") == NULL) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + strncpy(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_str, i); + compute_curr_unit.print_name_str[compute_curr_unit.print_count][i] = '\0'; + value_index = take_compute_value(temp_str + i,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcat(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_value); + } + else + strcpy(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_str); + temp_ch+=i+1; + for(i=0;temp_ch[i] != '\0';i++) + { + if(temp_ch[i] == '(') + break; + } + if(temp_ch[i] == '\0' && strstr(temp_ch, ")") == NULL) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + temp_ch += i; + value_index = take_compute_value(temp_ch,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcpy(compute_curr_unit.print_val_str[compute_curr_unit.print_count], temp_value); + compute_curr_unit.print_count++; + } + else if((temp_ch = strstr(line, "[c]") )!= NULL) + { + line_index--; + compute_state = 4; + break; + } + compute_state = 3; + break; + case 4: //[c] + if((temp_ch = strstr(line, "[c]")) != NULL && strstr(line, "==") != NULL && (strstr(line, "[p]")) != NULL) + { + + for(curr_instance_index=0;curr_instance_indextotal_instance;curr_instance_index++) + { + strcpy(temp_str1,line); + temp_ch = strstr(temp_str1, "[c]"); + compute_curr_instance=curr_instance_index; + temp_ch += 3; + p = strtok(temp_ch, "=["); + if(p[0] == '(' && p[strlen(p) - 1] == ')') + { + value_index = take_compute_value(p,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcpy(cmp_value[0], temp_value); + } + p = strtok(NULL, "=[");; + if(p[0] == '(' && p[strlen(p) - 1] == ')') + { + value_index = take_compute_value(p,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcpy(cmp_value[1], temp_value); + } + else + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(strcmp(cmp_value[0], cmp_value[1]) == 0) + { + strcpy(temp_str1,line); + if((temp_ch = strstr(temp_str1, "[p]")) != NULL) + { + + temp_ch += 3; + for(i=0;temp_ch[i] != '\0';i++) + { + if(temp_ch[i] == '=') + break; + } + if(temp_ch[i] == '\0') + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + strncpy(temp_str, temp_ch, i); + temp_str[i] = '\0'; + if(strstr(temp_str,"(")) + { + for(i=0;temp_str[i] != '\0';i++) + { + if(temp_str[i] == '(') + break; + } + if(i == strlen(temp_str) && strstr(temp_str, ")") == NULL) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + strncpy(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_str, i); + compute_curr_unit.print_name_str[compute_curr_unit.print_count][i] = '\0'; + value_index = take_compute_value(temp_str + i,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcat(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_value); + + } + else + strcpy(compute_curr_unit.print_name_str[compute_curr_unit.print_count], temp_str); + temp_ch+=i+1; + for(i=0;temp_ch[i] != '\0';i++) + { + if(temp_ch[i] == '(') + break; + } + if(temp_ch[i] == '\0' && strstr(temp_ch, ")") == NULL) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + temp_ch += i; + value_index = take_compute_value(temp_ch,temp_value); + if(value_index == 0) + { + printf("[Debug] Error: The field format is not right.\r\n"); + return ; + } + if(value_index == 1) + strcpy(compute_curr_unit.print_val_str[compute_curr_unit.print_count], temp_value); + compute_curr_unit.print_count++; + + } + else + { + printf("[Debug] Error: No '[p]' in the [c] line.\r\n"); + return ; + } + } + + } + compute_curr_instance=0; + } + else if((temp_ch = strstr(line, "[p]")) != NULL) + { + line_index--; + compute_state = 4; + break; + } + break; + } + } + line_index=print_line_index; + for(index=0;indexcurr_instance+bind_index); + value_index = 1; + return value_index; + } + else if(temp_str[0] == '#') + { + sprintf(temp_str,"%d",compute_curr_instance); + strcpy(temp_value, temp_str); + value_index =1; + return value_index; + } + else + /* + if(temp_str[0] == '.') + { + if(temp_str[2]=='.') + { + strcpy(temp_str1,temp_str); + if(*(temp_str1+1)=='\0' && atoi(temp_str1)==compute_field_list[0].list_field_id) + { + if(temp_str[1] == '#') + { + for(i = 0; i < mib_curr_node->total_instance; i++) + { + strcpy(temp_value[i], compute_field_list[0].field_val[i]); + } + value_index = mib_curr_node->total_instance; + return value_index; + } + else if(temp_str[1] == '*') + { + strcpy(temp_value[0], compute_field_list[0].field_val[mib_curr_node->curr_instance]); + value_index = 1; + return value_index; + } + } + } + } + else + */ + if((temp_ch = strstr(temp_str, "OID"))!=NULL) + { + if(isdigit(temp_ch[3])) + { + strncpy(temp_str1, temp_ch, 4); + temp_ch += 4; + } + else + { + strcpy(temp_str1,"OID"); + temp_ch += 3; + } + for(i = 0; i < OID_index; i++) + { + if(strcmp(OID_name_str[i], temp_str1) == 0) + break; + } + if(i == OID_index) + { + printf("[Debug] Error: Can not find the oid define.\r\n"); + return 0; + } + compute_list_index= i; + + if(temp_ch[0] == '.') + { + strcpy(temp_str1,temp_ch+3); + if(*(temp_str1+1)=='\0' && atoi(temp_str1)==compute_field_list[compute_list_index].list_field_id) + { + if(temp_ch[1] == '#') + { + strcpy(temp_value, compute_field_list[compute_list_index].field_val[compute_curr_instance]); + value_index = 1; + return value_index; + } + else if(temp_ch[1] == '*') + { + strcpy(temp_value, compute_field_list[compute_list_index].field_val[mib_curr_node->curr_instance+bind_index]); + value_index = 1; + return value_index; + } + } + + } + } + return 0; +} + +void compute_field_WatchDog() +{ + char temp_str[32]; + if(list_once==1 && read_syntax_nor_list == 0) + { + if(list_flag == 0 && get_state==0) + { + if(compute_field_list_index < compute_list_num) + { + field_compute_state=4; + mib_curr_node = compute_field_list[compute_field_list_index].list_node; + strcpy(list_msg,""); + //strcat(list_msg," -e "); + strcat(list_msg, "-f["); + sprintf(temp_str, "%d", compute_field_list[compute_field_list_index].list_field_id); + strcat(list_msg, temp_str); + strcat(list_msg, "] "); + strcat(list_msg,"0"); + strcat(list_msg,"-"); + gcvt((double)(mib_curr_node->total_instance-1),3,temp_str); + strcat(list_msg,temp_str); + list_flag=1; + show_list=0; + debug_mmi_list(); + } + } + } + +} + + +void print_compute_field() +{ + char out_text[256],temp_str[64]; + BYTE j,index,k,i=0; + if(list_once==1) + { + if(compute_field_list_index >= compute_list_num && compute_list_num>0) + { + for(index=0;indextotal_child_nodes==1) + { + strcpy(temp_str,""); + for(k=0;kname)+9;k++) + { + strcat(temp_str," "); + } + sprintf(out_text, "%s|---(%d) %s %d",temp_str,compute_field_arr[index].field_id+1, compute_field_arr[index].name,mib_curr_node->curr_instance); + } + else + sprintf(out_text, " |---(%d) %s %d",compute_field_arr[index].field_id+1, compute_field_arr[index].name,mib_curr_node->curr_instance); + debug_color_out(BRIGHT,CYAN,BLACK,out_text); + + if(compute_field_arr[index].print_count==1) + { + sprintf(out_text, " %s" ,compute_field_arr[index].print_name_str[0]); + debug_color_out(BRIGHT,CYAN,BLACK,out_text); + debug_ascii_out_proc(" = "); + if(strlen(compute_field_arr[index].print_val_str[0])) + sprintf(out_text, "%-8s",compute_field_arr[index].print_val_str[0]); + else + sprintf(out_text, "NULL "); + debug_color_out(BRIGHT,BLUE,BLACK,out_text); + debug_ascii_out_proc("\r\n"); + } + else + { + debug_ascii_out_proc("\r\n"); + for(j=0;j0) + compute_curr_unit.print_count=0; + } + } + field_compute_state=5; + print_once=0; + } + } + +} +/////////////////////////////////end of compute field///////////////////////// + +////////////////////////////////Other/////////////////////////////// +void debug_set_currenttime() +{ + u8 ii,jj; + char temp_timer[64]="\0"; + char send_buf[64]="\0"; + time_t tick; + + tick = time(NULL); + + sprintf(temp_timer,"\x1b[25;25Hcurrent time:%.24s",ctime(&tick)); + if (strlen(current_timer) == 0) // current timer is empty + { + for (jj = 0;jj < strlen(temp_timer);jj ++) + debug_send_char(temp_timer[jj]); + strcpy(current_timer,temp_timer); + return; + } + for (ii = 0;ii < strlen(temp_timer);ii ++) + { + if (temp_timer[ii] != current_timer[ii]) + { + sprintf(send_buf,"\x1b[25;%dH%c",25+ii-8,temp_timer[ii]); + for (jj = 0;jj < strlen(send_buf);jj ++) + debug_send_char(send_buf[jj]); + } + } + strcpy(current_timer,temp_timer); +} +/* +* +* Fun: del_space +* +* Desc: remove the spaces at the beginning of string +* +* Ret: string +* +* File: debug.c +* +*/ +void del_space(char *str,BYTE type) +{ + int i,j,k; + if(!strlen(str)) + return; + if(type==0) //del the ahead space + { + for(i=0;i0;i--) + { + if(str[i]!=' ') + { + break; + } + } + str[i+1]='\0'; + + }else if(type==2) //del all the space + { + for(i=0;i0;i--) + { + if(str[i]!=' ') + { + break; + } + } + str[i+1]='\0'; + + } + + +} + + + +/* +* +* Fun: read_line +* +* Desc: Read a line from file fp, remove the spaces in the beginning and in the end of the line, store it in line_ptr +* +* Ret: the length of line +* +* File: debug.c +* +*/ +int read_line(FILE *fp, char *line_ptr) +{ + char *temp_ch_ptr; + int index, index2, length; + + if(feof(fp)) + return 0; + strcpy(line_ptr, ""); + + fgets(line_ptr,512,fp); + temp_ch_ptr = strchr(line_ptr, 0xa); + if (temp_ch_ptr != NULL ) + *temp_ch_ptr = '\0'; + + + length = strlen(line_ptr); + for(index=0; index=0; index--) // cut off all spaces in the ending of the line + { + /* + if(!isprint(line_ptr[index])) + line_ptr[index] = '\0'; + else + { + if(line_ptr[index] == ' ' || line_ptr[index] == '\t') + line_ptr[index] = '\0'; + else + break; + } + */ + if(line_ptr[index] == ' ' || line_ptr[index] == '\t') + line_ptr[index] = '\0'; + else + break; + } + return strlen(line_ptr); +} /* end of read_line */ + + +/* +* +* Fun: read_begin +* +* Desc: read the fp, stop until meet the stop_ch +* +* Ret: the length of the stored string +* +* File: debug.c +* +*/ +int read_begin(FILE *fp, char *stop_ch) +{ + char ch; + int index = 0,i=0; + + while((ch=fgetc(fp)) != EOF) + { + if(stop_ch[i]!='\0') + { + if(ch==stop_ch[i]) + { + i++; + if(stop_ch[i]=='\0') + { + index-=i-1; + break; + } + } + else + i=0; + } + else + break; + if(index == 3072) + break; + } + + return index; +} // end of read_begin + + + +/* +* +* Fun: read_until +* +* Desc: read the fp, store the string to the data_ptr until meet the stop_ch +* +* Ret: the length of the stored string +* +* File: debug.c +* +*/ +int read_until(FILE *fp, char *data_ptr, char *stop_ch) +{ + char ch; + int index = 0,i=0; + while((ch=fgetc(fp)) != EOF) + { + if(stop_ch[i]!='\0') + { + if(ch==stop_ch[i]) + { + i++; + if(stop_ch[i]=='\0') + { + index-=i-1; + break; + } + } + else + i=0; + } + else + break; + data_ptr[index++] = ch; + if(index == 3072) + break; + } + data_ptr[index]= '\0'; + return index; +} // end of read_until + + + +/* +* +* Fun: read_part +* +* Desc: read the fp, store the string to from the start_ch to syop_ch +* +* Ret: the length of the stored string +* +* File: debug.c +* +*/ +int read_part(FILE *fp, char *data_ptr,char *start_ch, char *stop_ch) +{ + read_begin(fp,start_ch); + read_until(fp,data_ptr,stop_ch); + return strlen(data_ptr); +} // end of read_until + + +/* +* +* Fun: pick_first_word(char *str_ptr, char *word_ptr) +* +* Desc: pick out the first word into word_ptr from the str_ptr +* +* Ret: the char pionter which point to the ending of the first word in the string +* +* File: debug.c +* +*/ +char * pick_first_word(char *str_ptr, char *word_ptr) +{ + int index, index2, length; + length = strlen(str_ptr); + for(index = 0; index < length; index ++) + { + if(!isprint(str_ptr[index]))//find the first print char exclude spacebar + continue; + else + { + if(str_ptr[index] == ' ') + continue; + else + break; + } + } + for(index2=0; index <= length; index++, index2++) + { + if( (isprint(str_ptr[index])) && (str_ptr[index] != ' ')) + word_ptr[index2] = str_ptr[index]; + else + break; + } + word_ptr[index2] = '\0'; + return &str_ptr[index]; +} // end of pick_first_word + + +/* +* +* Fun: take_str +* +* Desc: copy the data_str to the data_ptr if data_str is not NULL, or find two '"' in the file fp and take string between the two '"' into data_ptr +* +* Ret: successful: 1, fail: 0 +* +* File: debug.c +* +*/ +int take_str(char *data_str, FILE *fp, char *data_ptr) +{ + char tmp_ch= '"'; + int index; + //printf("take_str begin:\r\n"); + if(strlen(data_str) != 0) + { + strcpy(data_ptr, data_str); + return 1; + } + else + { + while(( !feof(fp) ) && (fgetc(fp) != '"')) + ; + if(feof(fp)) + { + printf("[debug] Error: Can't find a [%c] as beginning of a text befor the End of file.\r\n",'"'); + return 0; + } + index = 0; + while( !feof(fp) ) + { + if( (tmp_ch = fgetc(fp)) != '"' ) + data_ptr[index++] = tmp_ch; + else + { + data_ptr[index] = '\0'; + //printf("take_str end: %s.\r\n",data_ptr); + return 1; + } + } + printf("[debug] Error: Can't find a [%c] as ending of a text before the End of file.\r\n",'"'); + return 0; + } + //printf("take_str end: %s.\r\n",data_ptr); +} // end of take_str; + +void debug_color_out(int attr,int color,int bg,char *str) +{ + int len=strlen(str); + char tmp_str[len+14]; + strcpy(tmp_str,str); + TxtColor(attr,color,bg,tmp_str); + debug_ascii_out_proc(tmp_str); +} + + +void help_cmm(int index,char *str1,char *str2) +{ + char temp_str[3]; + char temp_str1[64],temp_str2[1024]; + strcpy(temp_str1,str1); + strcpy(temp_str2,str2); + debug_ascii_out_proc("Usage "); + sprintf(temp_str,"%d : ",index); + debug_ascii_out_proc(temp_str); + debug_color_out(BRIGHT,YELLOW,BLACK,temp_str1); + debug_ascii_out_proc("\r\n"); + debug_ascii_out_proc(" "); + formatstr(10,temp_str2,0); + debug_ascii_out_proc(temp_str2); + debug_ascii_out_proc("\r\n"); +} + +void formatstr(int len,char *str,BYTE type) +{ + int i, index_1=0, index_2=0; + char temp_str1[1024],temp_str2[1024]; + char format_str[1024]; + char space[80]; + char *p; + int str_len; + double line_num; + if(type) + { + for(i=0;i1024) + { + debug_color_out(BRIGHT,RED,BLACK,"Error : Remark is too long !\r\n"); + return ; + } + p=str; + strcpy(format_str,""); + while(*p!='\0') + { + i=0; + while(i70 && str[i]<97) || str[i]>102)) + break; + } + if(i==strlen(str)) + return 1; + else + return 0; + } + else if(type==2) + { + for(i=0;i90 && str[i]<97) || str[i]>122)) + break; + } + if(i==strlen(str)) + return 1; + else + return 0; + } + else + return 0; +} + +void strpcat(char *dest_str,DWORD *dest_p,const char *src_str) +{ + while((*(dest_str+(*dest_p)++)=*src_str++)); + (*dest_p)--; +} + +void pick_name(char *str_ptr, char *word_ptr,char *temp_ch) +{ + int start_index,end_index,i; + char temp_str[512],*ch; + strcpy(temp_str,str_ptr); + start_index=end_index=i=0; + if(temp_ch!=NULL) + { + for(start_index=0;start_index0;end_index--) + if(*(word_ptr+end_index)!=' ' && *(word_ptr+end_index)!='\t') + break; + *(word_ptr+end_index+1)='\0'; + } +} + + +int get_my_address (struct in_addr *addr) +{ + struct ifreq req; + int sock; + + sock = socket(AF_INET, SOCK_DGRAM, 0); + strncpy (req.ifr_name, "eth0", IFNAMSIZ); + + if ( ioctl(sock, SIOCGIFADDR, &req) < 0 ) + { + printf("failed to ioctl: %s\n", strerror (errno)); + return 0; + } + + memcpy (addr, &((struct sockaddr_in *) &req.ifr_addr)->sin_addr, sizeof (struct in_addr)); + return 1; +} +/*@end@*/ + +////////////////////////////End of Other/////////////////////////// diff --git a/omc/plat/debug/src/include/.copyarea.db b/omc/plat/debug/src/include/.copyarea.db new file mode 100644 index 0000000..534d80d --- /dev/null +++ b/omc/plat/debug/src/include/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\debug\src\include +2 +2 +7:debug.h|1|11d70a3ed79|655|b1b7068c|e6b482ce6cf311dd91a5001c23e19543|0 +e:debug_struct.h|1|11d70a3ed4a|2b53|adf2b80f|e62482b66cf311dd91a5001c23e19543|0 diff --git a/omc/plat/debug/src/include/debug.h b/omc/plat/debug/src/include/debug.h new file mode 100644 index 0000000..cc312a5 --- /dev/null +++ b/omc/plat/debug/src/include/debug.h @@ -0,0 +1,64 @@ +/* Debug module strucutre head file */ +/* Written by Liu Wei 2005-05-10 */ +/* Version 4.0 */ +/* -------------------------------- */ + +#ifndef _DEBUG +#define _DEBUG + +#include "debug_struct.h" +#include "dirent.h" + +/* by simon at 23/9/25 +mib_node *mib_root_node; +mib_node *mib_curr_node; +menu_node *menu_root_node; +menu_node *menu_curr_node; +mib_node mib_nodes[MIB_MAX_NODES]; +*/ + +/* by simon at 23/9/25 +//for test + char file_name[128]; + FILE *fp_prt; + long int timeuse,max_time; + struct timeval tv_start, tv_end; +//for test +*/ + +/* by simon at 23/9/25 +menu_node menu_nodes[MENU_MAX_NODES]; +mib_child_node mib_child_nodes[MIB_MAX_CHILD_NODES]; + +debug_snmp_agent debug_snmp_agent_buf[MAX_PACKET_NUM]; + end by simon */ + +//////////////////////////////interface declaration//////////////////////// + +void debug_init(); + +void debug_rt(); + + +WORD find_child_index(mib_node *node_ptr, DWORD oid, char *name, BYTE type); + +mib_node *find_node(mib_node *start_node_ptr, char *node_name, int find_type, DWORD *last_node_oid); + +mib_node *search_mib_node(mib_node *start_mib_node_ptr, DWORD *oid, BYTE oid_len); + +int debug_set_response(unsigned char object_id_len,unsigned int *object_id,unsigned char *data,unsigned short data_len); + +int debug_get_response(unsigned char object_id_len,unsigned int *object_id,unsigned char *data,unsigned char *vartype); + +menu_node *search_menu_node(menu_node *start_menu_node_ptr, BYTE *menu_id, BYTE id_len); + +void Clear_Access_History(); + +void debug_set_agent(); + +void debug_get_agent(); + +int get_my_address (struct in_addr *addr); + +//////////////////////////////end of interface declaration//////////////////////// +#endif diff --git a/omc/plat/debug/src/include/debug_struct.h b/omc/plat/debug/src/include/debug_struct.h new file mode 100644 index 0000000..f16eb71 --- /dev/null +++ b/omc/plat/debug/src/include/debug_struct.h @@ -0,0 +1,375 @@ + /* Debug module strucutre head file */ +/* Written by Liu Zhiguo 2003-04-22 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#ifndef _DEBUG_STRUCT +#define _DEBUG_STRUCT + +#include "../../../public/src/include/pub_include.h" +#include "../../../iptrans/src/include/iptrans.h" +#include "../../../snmp/src/include/snmp.h" +#include "../../../snmp/src/include/heartbeat.h" + +//Module ID +//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 +//a b c d e f g h i j k l m n o p q r s t u v w x y z +//a b c d e f g h i j k l m n o p r s t u v w y z + +#define DEBUG_PORT 4965 +#define DEBUG_SNMP_PORT 4956 +#define SNMP_PORT 4957 +#define DEBUG_VERSION "R9V0_03" + +#define TELNET_SEND_BUF_LEN 1000 +#define SERIAL_BUF_LEN 2048 +#define DEBUG_MAX_PAGE 2 +#define PAGE_MODULE_COUNT 24 +#define MODULE_COUNT (PAGE_MODULE_COUNT*DEBUG_MAX_PAGE) +#define DEBUG_MAX_SEQID 0x7fffffff +#define DEBUG_SEQID_LEN 8 +#define DEBUG_OMCBUF_LEN 1024 +#define DEBUG_NAME_LEN 8 +#define PAGE_COUNT 24 +#define LINE_COUNT 23 +#define MAX_ROW 25 +#define MAX_COLUMN 80 +#define TITLE_CHAR 2048 +#define MAX_ASCII_LEN (1024*16) + +#define DEBUG_SHM_KEY 0xa0600000 +#define DEBUG_SHM_PERM 0664 + +#define MENU_TYPE 0 +#define OID_TYPE 1 + +// MIB wangjian add +#define MIB_LIST_FILE "mib_list_file.txt" +#define MIB_FILES_DIR "./conf/MIB_files/" +#define MIB_OMC_PUB_SYSCONF_FILE "OMC_PUB_sysConf.csv" +#define MIB_PARAM_LIST_FILE "mib_param_list_file.txt" +#define MIB_WRITE_TREE "mib_write_tree.txt" +#define MIB_SYSTEM_CONFIG_FILE "System_Config.txt" +#define MIB_SYSTEM_IP_LIST_FILE "System_IP_List.txt" +#define MENU_TREE_FILE "menu_tree.txt" + +#define MIB_MAX_CHILD_NODES_PER_NODE 256 +#define MIB_MAX_NODES 1536 +#define MIB_MAX_CHILD_NODES 1536 * 5 + +#define MIB_MAX_PARAM_SELECTS 1536 * 8 +#define MIB_MAX_PARAM_INPUTS 1536 * 8 +#define MIB_MAX_NODE_PARAMS 1536 * 4 +#define MAX_TOTAL_INSTANCE 2048 +#define MAX_NODE_PACKET_LENGTH 256 +#define MAX_SEND_CHAR_NUM 512 + +//#define MIB_OPER_TYPE_GET 1 +//#define MIB_OPER_TYPE_GET_ALL 2 +//#define MIB_OPER_TYPE_SET 3 +//#define MIB_OPER_TYPE_HELP 4 + +#define MIB_MODULE_REVISION_MAX_NUM 10 + +#define MIB_SUBSYS_MODULE_MAX_NUM 64 + +#define MIB_HOST_MAX_NUM 127 + +#define MIB_NODE_PARAM_MAX_LEN 64 +#define GROUP_NUM 2 +#define MEMBER_MAX_NUM 16 +#define MENU_MAX_NODES 640 + +#define TODEC_HIGH_0 0 +#define KEEPHEX_HIGH_0 1 +#define KEEPHEX_LOW_0 2 +#define KEEPHEX_LOW_E 3 +#define KEEPHEX_LOW_F 4 +#define TOASCII_LOW_0 5 +#define KEEPASC_LOW_F 6 + + +#define MAX_PACKET_NUM 16 +#define MAX_SELECT_OPTION_NUM 21 +#define MAX_OPTION_LENGTH 32 +#define MAX_HOST_IP 16 +#define MAX_PARAM_NUM 64 + +typedef struct CommandList +{ + char cmm[128]; + struct CommandList *nextcmm; +}cmmset,cmmrem; + +// MIB end + +typedef struct _DEBUG_TELNET_SEND_DATA +{ + int telsend_datah; + BYTE telsend_data[TELNET_SEND_BUF_LEN]; +}DEBUG_TELNET_SEND_DATA; + +struct debug_line +{ + BYTE pt_vartype; + WORD length; + BYTE *pointer; +}; + +struct debug_page +{ + BYTE pointer_set_flag; + char title[TITLE_CHAR]; + struct debug_line line_d[LINE_COUNT]; +}; + +typedef struct debug_module_struct +{ + char name[DEBUG_NAME_LEN]; + char status[2]; + char version[20]; + BYTE maxpage; + BYTE ascii_in_set_flag; + BYTE ascii_out_set_flag; + BYTE *ascii_in; + WORD ascii_in_len; + BYTE *ascii_out; + WORD ascii_out_len; + struct debug_page page_d[PAGE_COUNT]; + int seqid_h; // head sequence id for omc get + int seqid_t; // tail sequence id for omc get + BYTE omc_outbuf[DEBUG_SEQID_LEN][DEBUG_OMCBUF_LEN]; +} debug_module_struct; + +typedef struct debug_shm_struct +{ + debug_module_struct module_d[MODULE_COUNT]; + DEBUG_TELNET_SEND_DATA TelnetSendData; +} debug_shm_struct; + +// by simon at 23/9/25 +//struct debug_shm_struct *debug_shm_ptr; +//struct iptrans_shm *pIptransShm; + +// MIB wangjian add +typedef struct _mibfile_imports_data +{ + char father_name[64]; + char from_file[32]; +} mibfile_imports_data; + +typedef struct _mibfile_module_data +{ + char name[64]; // nod name + char LU[32]; // LAST-UPDATED + char OR[64]; // ORGANIZATION + char CI[128]; // CONTACT-INFO + char DE[1024]; // DESCRIPTION + char RE[MIB_MODULE_REVISION_MAX_NUM][32]; // REVISION + char RE_DE[MIB_MODULE_REVISION_MAX_NUM][1024]; // REVISION'S DESCRIPTION + int RE_index; // the number of RE and RE_DE + char father_name[64]; // father's name + char ID[32]; // child ID +} mibfile_module_data; + +typedef struct _mibfile_object_data +{ + char name[64]; // nod name + int ST; // STATUS: 1: current, 2: deprecated, 3: obsolete. 0: invalid + char DE[1024]; // DESCRIPTION + char RF[1024]; // ReferPart + char father_name[64]; // father's name + char ID[32]; // child ID +} mibfile_object_data; + +typedef struct _mibfile_type_data +{ + char name[64]; // nod name + int SY; // SYNTAX: 0:invalid. 1: Integer32, 2: INTEGER, 3: OCTET STRING, 4: OBJECT IDENTIFIER, 5: BITS, 6: IpAddress, 7: Counter32, + // 8: Gauge32, 9: TimeTicks, 10: Opaque, 11: Counter64, 12: Unsigned32, 13:Conceptual Tables + char UP[32]; // UnitsPart + BYTE MA; // MAX-ACCESS: 0: invalid, 1: not-accessible, 2: accessible-for-notify, 3: read-only, 4: read-write, 5: read-create 6: write-only + int ST; // STATUS + char DE[8192]; // DESCRIPTION + int total_instance; // total_instance + char RF[1024]; // ReferPart; + char father_name[64]; // father's name + char ID[32]; // child ID +} mibfile_type_data; + +//typedef int (*mib_call)(DWORD *oid, BYTE oid_len, char *name, char *value, BYTE oper_type); + +typedef struct _mib_child_node +{ + char name[64]; + DWORD oid; + void *child_ptr; +} mib_child_node; + +typedef struct _mib_node +{ + void *parent_ptr; + char name[32]; + BYTE oid_len; + DWORD oid[32]; + BYTE data_length; + BYTE module_index; + WORD total_instance; + WORD curr_instance; + WORD total_child_nodes; + BYTE enable_field_id; + BYTE enable_flag[32]; + BYTE access_history; + char init_value[256]; + //mib_call mib_proc; + char *remark_ptr; + //char remark[DEBUG_OMCBUF_LEN * 2]; + mib_child_node *child_nodes[MIB_MAX_CHILD_NODES_PER_NODE]; + BYTE max_access; // MAX-ACCESS: 0: invalid, 1: not-accessible, 2: accessible-for-notify, 3: read-only, 4: read-write, 5: read-create 6: write-only +}mib_node; + +typedef struct _menu_node +{ + void *father_ptr; + void *child_node[MENU_MAX_NODES]; + mib_node *menu_oid_node; + BYTE oid[23]; + BYTE id_len; + BYTE total_menu_child; + char name[32]; + BYTE menu_id[20]; + BYTE sys_group; +}menu_node; + +// MIB FIELD struct +typedef struct _mib_param_select +{ + WORD number; + char description[MIB_NODE_PARAM_MAX_LEN]; +} mib_param_select; + +typedef struct _instance_arr +{ + DWORD ins; + BYTE eable; +}INSTANCE_ARR; + +typedef struct _mib_param_input +{ + BYTE input_param_type; // 0: toDec_high_0 + // 1: keepHex_high_0 + // 2: keepHex_low_0 + // 3: keepHex_low_E + // 4: keepHex_low_F + // 5: toAscii_low_0 + // 6: keepAscii_low_F + char input[MIB_NODE_PARAM_MAX_LEN]; +} mib_param_input; + +typedef struct _mib_node_param +{ + void *parent_ptr; + char name[64]; + BYTE id; + BYTE byte_begin; + BYTE byte_end; + BYTE bit_begin; + BYTE bit_end; + mib_param_select *select_ptr[16]; + BYTE select_total; + BYTE select_value; + mib_param_input *input_ptr; +} mib_node_param; + + + + +typedef struct _mib_subsys_module +{ + BYTE index; + DWORD oid[8]; + char name[10]; + BYTE max_group; + //char obj_type_no[3]; +}mib_subsys_module; + +typedef struct _mib_host +{ + BYTE index; + BYTE group_index; + BYTE member_index; + char host_name[32]; + WORD host_ip[4]; +}mib_host; + +typedef struct _module_command_save_flag +{ + BYTE module_index; + DWORD oid[32]; + BYTE oid_len; + BYTE save_select_id; + BYTE save_field_id; +}module_command_save_flag; + + +typedef struct param_field +{ + char name[48]; //set fill in + char curr_input_value[32]; //set fill in + BYTE input_type; + BYTE curr_select_id; + BYTE total_select; + WORD value_arr[MAX_SELECT_OPTION_NUM]; + char value_arr_remark[MAX_SELECT_OPTION_NUM][MAX_OPTION_LENGTH]; +}param_field; + +typedef struct debug_snmp_agent_packet +{ + DWORD oid[32]; //set fill in + //0 idle 1 waitting get 2 waitting set 3 process 4 fail 5 success + BYTE cmm_state; //set fill in + //0 success 1 time out 2 buffer full 3 oid error 4 ip str error + //5 instance error 6 leaf node param forbidden 7 total field error + //8 no select option 9 snmp send error 1xx no child 2xx no select 3xx field input error + BYTE result_state; + BYTE agentClient; + BYTE oid_len; //set fill in + BYTE total_field; //set fill in + WORD total_instance; //set fill in + BYTE total_ip; //set fill in + char dst_ip[MAX_HOST_IP][15]; //set fill inxxx.xxx.xxx.xxx + param_field param_field_arr[MAX_PARAM_NUM]; + +}debug_snmp_agent; + +//MIB end + + + +typedef struct _comput_list +{ + BYTE list_field_id; + char field_val[256][32]; + mib_node *list_node; +}compute_list; + +typedef struct _compute_field +{ + char name[32]; + mib_node *compute_node; + BYTE field_id; + char syntax_str[10][64]; + BYTE syntax_count; + char print_val_str[128][32]; + char print_name_str[128][32]; + BYTE print_count; +}compute_field; + +typedef struct _wxc2_debug_info +{ + char wxc2_ver[32]; + BYTE sys_type; // cdma 1 gsm 2 gc_ssw 3 + BYTE mmi_switch; // on 1 0 off +}wxc2_debug_info; + +#endif diff --git a/omc/plat/debug/ut/.copyarea.db b/omc/plat/debug/ut/.copyarea.db new file mode 100644 index 0000000..d0251ac --- /dev/null +++ b/omc/plat/debug/ut/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\debug\ut +2 +1 +c:debug_test.c|1|11d70a3ee25|68b1|93f0cb41|cd5967b5bfa411dc8511001c23e19543|0 diff --git a/omc/plat/debug/ut/debug_test.c b/omc/plat/debug/ut/debug_test.c new file mode 100644 index 0000000..7731f30 --- /dev/null +++ b/omc/plat/debug/ut/debug_test.c @@ -0,0 +1,926 @@ + +/************************************************ + * debug_test.c + * Author: LiuWei + * Create: 2005-05-31 +************************************************/ + +#include "./include/debug.h" +#include "../../iptrans/src/include/iptrans.h" +#include "../../snmp/src/include/snmp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BUFLEN 1024 +#define MAX_RECV_NONE 20 +#define REC_NUM 50 + +char shellcode[] = "\x97\x97\x97\x97\x97\x97"; + +//add test line + +static struct itimerval itimer, old_itimer; +fd_set rset; +BYTE connect_flag = 0; +struct sockaddr_in sin_addr; +int flag = 1; +int sockfd; +char buffer[2048]; +int command_list_count; +BYTE recv_over = 0; +int addr_len = sizeof(struct sockaddr_in); +int len = 0; +BYTE recv_ten_times = 0; +BYTE test_style = 2; +BYTE test_snmp_mode = 0; +char oid_cmm_state[128]; +BYTE recv_none = 0; +//char file_name[128]; +FILE *fp_conf,*fp_agent; +struct timeval tv_start, tv_end; +long timeuse; +long max_time; +int i, j; +int time_vel; +int multi; +char data_arr[1024], multi_str[16]; +char command[1024]; +char oid_command[128]; + + +void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len); +void MMI_telnet(); +void MMI_telnet_send(char *str); +void MMI_auto_test(); +void MMI_telnet_recv(); +void Set_Timer(); +void On_Timer(); +void MMI_telnet_cmd(); +void debug_snmp_agent_test_input(); +void debug_snmp_agent_test_output(); +void debug_snmp_print(); +void MMI_File_Test(char *data_arr); + +void usage(char *p) +{ + printf("Usage: %s [ip] [-a atuo test] [-m manual test] [-n normal start] [-f script file]\n\n", p); + printf("\n"); + exit(0); +} + +void msg(char *msg) +{ + perror(msg); + exit(errno); +} + +u_int32_t get_ip(char *host) +{ + struct hostent *hp; + + if(!(hp = gethostbyname(host))) + { + fprintf(stderr, "cannot resolve %s\n", host); + return (0); + } + return (*(u_int32_t *) hp->h_addr_list[0]); +} + +int get_socket(char *target, int port) +{ + int sock; + u_int32_t ip; + + if(!(ip = get_ip(target))) + return (0); + + bzero(&sin_addr, sizeof(sin_addr)); + sin_addr.sin_family = AF_INET; + sin_addr.sin_port = htons(port); + sin_addr.sin_addr.s_addr = ip; + + if(!(sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) + msg("Get socket:"); + if(ioctl(sock, FIONBIO, &flag) == -1) + { + printf("Set nonblock:"); + close(sockfd); + exit(1); + } + if(connect(sock, (struct sockaddr *)&sin_addr, sizeof(sin_addr)) < 0) + if((errno != EWOULDBLOCK) && (errno != EINPROGRESS)) + msg("Connect:"); + return (sock); +} + +void send_wont(int sock, int option) +{ + char buf[3], *ptr = buf; + + *ptr++ = IAC; + *ptr++ = WONT; + *ptr++ = (unsigned char)option; + if(write(sock, buf, 3) < 0) + msg("write"); + return; +} + +void send_will(int sock, int option) +{ + char buf[3], *ptr = buf; + + *ptr++ = IAC; + *ptr++ = WILL; + *ptr++ = (unsigned char)option; + if(write(sock, buf, 3) < 0) + msg("write"); + return; +} + +void send_do(int sock, int option) +{ + char buf[3], *ptr = buf; + + *ptr++ = IAC; + *ptr++ = DO; + *ptr++ = (unsigned char)option; + if(write(sock, buf, 3) < 0) + msg("write"); + return; +} + +void send_env(int sock, char *name, char *value) +{ + char buf[BUFLEN], *ptr = buf; + + *ptr++ = IAC; + *ptr++ = SB; + *ptr++ = TELOPT_NEW_ENVIRON; + *ptr++ = TELQUAL_IS; + *ptr++ = NEW_ENV_VAR; + strncpy(ptr, name, BUFLEN - 20); + ptr += strlen(ptr); + *ptr++ = NEW_ENV_VALUE; + strncpy(ptr, value, (&buf[BUFLEN - 1] - ptr) - 1); + ptr += strlen(ptr); + *ptr++ = IAC; + *ptr++ = SE; + + if(write(sock, buf, (ptr - buf)) < 0) + msg("write"); + return; +} + +void do_negotiate(int sock) +{ + send_will(sock, TELOPT_ECHO); + send_wont(sock, TELOPT_TTYPE); + send_wont(sock, TELOPT_NAWS); + send_wont(sock, TELOPT_LFLOW); + send_wont(sock, TELOPT_LINEMODE); + send_wont(sock, TELOPT_XDISPLOC); + send_will(sock, TELOPT_LFLOW); + send_will(sock, TELOPT_LINEMODE); + send_wont(sock, TELOPT_OLD_ENVIRON); + send_will(sock, TELOPT_NEW_ENVIRON); + send_will(sock, TELOPT_BINARY); + send_env(sock, "TTYPROMPT", shellcode); + return; +} + +int main(int argc, char **argv) +{ + int c, port = DEBUG_PORT; + char host[36] = "172.18.234.231"; + + strcpy(command, ""); + strcpy(oid_command, ""); + strcpy(oid_cmm_state, ""); + if(argc < 2) + usage(argv[0]); + + tv_start.tv_sec = 0; + tv_start.tv_usec = 0; + tv_end.tv_sec = 0; + tv_end.tv_usec = 0; + + + + + //ioperm(0x378,3,1); + /* + strcpy(file_name, ""); + strcat(file_name, "debug_agent.txt"); + remove(file_name); + */ + + strcpy(file_name, ""); + strcat(file_name, "debug_test_time_log.txt"); + remove(file_name); + + if((fp_prt = fopen(file_name, "a+")) == NULL) + { + printf("[debug] Error: cannot open %s.\r\n", file_name); + return 0; + } + + + while((c = getopt(argc, argv, "famn")) != -1) + { + switch (c) + { + case 'f': // costumer test + printf("The Debug test control by command script!"); + test_style = 4; + break; + case 'a': // auto test + printf("The Debug Atuo Test!"); + test_style = 1; + break; + case 'm': // manually test + printf("The Debug manually Test!"); + test_style = 2; + break; + case 'n': // normal start + printf("The Debug Normal start!"); + test_style = 3; + break; + } + } + debug_init(1); + iptrMainInit(); + snmp_init(4957); + + if(!(sockfd = get_socket(host, port))) + exit(-1); + command_list_count = 0; + if(test_style == 4) + strcpy(command, ""); + strcpy(multi_str, ""); + strcpy(data_arr, ""); + strcpy(file_name, ""); + strcat(file_name, "debug_test_conf.txt"); + j = REC_NUM + 1; + if((fp_conf = fopen(file_name, "r")) == NULL) + { + printf("[debug] Error: cannot open %s.\r\n", file_name); + return 0; + } + + Set_Timer(); + while(1) + { + usleep(10); + } + +} + +void MMI_File_Test(char *data_arr) +{ + + for(i = 0; i < strlen(data_arr); i++) + if(data_arr[i] == ' ') + break; + if(i != strlen(data_arr)) + strncpy(multi_str, data_arr, i); + multi_str[i] = '\0'; + multi = strtoul(multi_str, NULL, 10); + for(; i < strlen(data_arr); i++) + { + if(data_arr[i] != ' ') + break; + } + strcpy(command, data_arr + i); + if(strncasecmp(command, "\\e", 2) == 0) + { + command[0] = 27; + command[1] = '\0'; + } + if(strcmp(command, oid_command) != 0) + { + strcpy(oid_command, command); + if(strcmp(command, "\e") == 0) + fprintf(fp_prt, "Command :\e\n"); + else + fprintf(fp_prt, "Command :%s \n", command); + } + + if(strcmp(command, "\e") != 0) + { + strcat(command, "\r\n"); + } + printf("%s", command); + MMI_telnet_send(command); + usleep(5); + + recv_over = 0; + usleep(time_vel); + +} + +void MMI_auto_test() +{ + + strcpy(command, ""); + switch (command_list_count) + { + case 0: + strcpy(command, "\e"); + multi = 1; + break; + case 1: + strcpy(command, "menu"); + multi = 5; + break; + case 2: + + strcpy(command, "contents"); + multi = 8; + break; + case 3: + strcpy(command, "cd 1"); + multi = 10; + break; + case 4: + strcpy(command, "cd 4"); + multi = 10; + break; + case 5: + strcpy(command, "list -a -f[2 4 10] -r -t"); + multi = 25; + break; + case 6: + strcpy(command, "get #0.1"); + multi = 15; + break; + case 7: + strcpy(command, "cmm"); + multi = 15; + break; + case 8: + strcpy(command, "\e"); + multi = 20; + break; + /* + case 9: + strcpy(command, "log all"); + multi = 150; + break; + case 10: + strcpy(command, "\e"); + multi = 10; + break; + case 11: + strcpy(command, "\e"); + multi = 10; + break; + case 12: + strcpy(command, "log none"); + multi = 15; + break; + case 13: + strcpy(command, "\e"); + multi = 15; + break; + case 14: + strcpy(command, "help"); + multi = 15; + break; + case 15: + strcpy(command, "\e"); + multi = 15; + break; + */ + default: + command_list_count = 0xfffe; + break; + } + command_list_count++; + if(command_list_count == 0xffff) + { + test_snmp_mode = 1; + printf("The command test over\r\n"); + printf("Test snmp senior interface......\r\n"); + return; + } + time_vel = multi * 500; + if(command_list_count != 0xffff && recv_over == 2) + { + + if(strcmp(command, oid_command) != 0) + { + strcpy(oid_command, command); + if(strcmp(command, "\e") == 0) + fprintf(fp_prt, "Command :\e"); + else + fprintf(fp_prt, "Command :%s ", command); + } + + if(strcmp(command, "\e") != 0) + { + strcat(command, "\r\n"); + } + MMI_telnet_send(command); + + usleep(5); + if(command_list_count > 0) + printf("%s", command); + recv_over = 0; + usleep(time_vel); + } + else + command_list_count--; +} + +void MMI_telnet_recv() +{ + + len = 0; + bzero(buffer, sizeof(buffer)); + + len = recvfrom(sockfd, buffer, sizeof(buffer), 0, + (struct sockaddr *)&sin_addr, &addr_len); + if(len > 0) + { + printf("%s", buffer); + recv_none = 0; + } + else + { + if(recv_none < MAX_RECV_NONE) + recv_none++; + else if(recv_over == 1) + recv_over = 2; + return; + } + if(strstr(buffer, "<--")) + { + recv_over = 1; + return; + } + if(strstr(buffer, "CMM>") || strstr(buffer, "CFG>") || + strstr(buffer, "MENU>") || recv_over == 1) + recv_over = 2; + return; +} + +void MMI_telnet_cmd() +{ + + + + if(ioctl(fileno(stdin), FIONBIO, &flag) == -1) + { + printf("Set stdin nonblock:"); + exit(1); + } + len = 0; + bzero(buffer, sizeof(buffer)); + strcpy(command, ""); + fgets(buffer, sizeof(buffer), stdin); + len = strlen(buffer); + if(!len) + return; + strcpy(command, buffer); + if(strcmp(command, oid_command) != 0) + { + strcpy(oid_command, command); + + if(strcmp(command, "\e") == 0) + fprintf(fp_prt, "Command :ESC"); + else + fprintf(fp_prt, "Command :%s ", command); + + } + usleep(5); + if(strstr(buffer, "\e\n")) + recv_over = 2; + if(strcmp(buffer, "\e\n") != 0) + { + buffer[strlen(buffer) - 1] = '\0'; + strcat(buffer, "\r\n"); + } + if(recv_over > 1) + { + if(sendto(sockfd, buffer, len, 0, (struct sockaddr *)&sin_addr, + addr_len) < 0) + msg("Send"); + recv_over = 0; + } +} + +void MMI_telnet_send(char *str) +{ + bzero(buffer, sizeof(buffer)); + strcpy(buffer, str); + len = strlen(buffer); + if(strlen(str)) + if(sendto(sockfd, buffer, len, 0, (struct sockaddr *)&sin_addr, + addr_len) < 0) + msg("Send"); +} + +void On_Timer() +{ + if(test_style == 1) + { + iptrans_timer(); + snmp_timer(); + outb(0xff, 0x378); + //timeuse = 0; + //gettimeofday(&tv_start, NULL); + debug_rt(); + /* + gettimeofday(&tv_end, NULL); + timeuse = + 1000000 * (tv_end.tv_sec - tv_start.tv_sec) - + tv_start.tv_usec + tv_end.tv_usec; + if(timeuse > max_time) + max_time = timeuse; + fprintf(fp_prt, + " debug_rt time used: %ld (u sec)<=%ld\r\n\r\n", + timeuse, max_time); + */ + outb(0x00, 0x378); + if(connect_flag == 0) + { + do_negotiate(sockfd); + MMI_telnet_recv(); + send_wont(sockfd, TELOPT_BINARY); + MMI_telnet_recv(); + FD_ZERO(&rset); + connect_flag = 1; + } + MMI_telnet_recv(); + if(!test_snmp_mode) + MMI_auto_test(); + else + { + debug_snmp_agent_test_input(); + debug_snmp_agent_test_output(); + debug_snmp_print(); + } + } + if(test_style == 2) + { + + iptrans_timer(); + snmp_timer(); + outb(0xff, 0x378); + //timeuse = 0; + //gettimeofday(&tv_start, NULL); + debug_rt(); + /* + gettimeofday(&tv_end, NULL); + timeuse = + 1000000 * (tv_end.tv_sec - tv_start.tv_sec) - + tv_start.tv_usec + tv_end.tv_usec; + if(timeuse > max_time) + max_time = timeuse; + fprintf(fp_prt, + " debug_rt time used: %ld (u sec)<=%ld\r\n\r\n", + timeuse, max_time); + */ + outb(0x00, 0x378); + if(connect_flag == 0) + { + do_negotiate(sockfd); + MMI_telnet_recv(); + send_wont(sockfd, TELOPT_BINARY); + MMI_telnet_recv(); + FD_ZERO(&rset); + connect_flag = 1; + } + MMI_telnet_recv(); + MMI_telnet_cmd(); + } + if(test_style == 3) + { + iptrans_timer(); + snmp_timer(); + + //timeuse = 0; + // gettimeofday(&tv_start, NULL); + //outb(0xff, 0x378); + debug_rt(); + //outb(0x00, 0x378); + /* + gettimeofday(&tv_end, NULL); + timeuse = + 1000000 * (tv_end.tv_sec - tv_start.tv_sec) - + tv_start.tv_usec + tv_end.tv_usec; + if(timeuse > max_time) + max_time = timeuse; + fprintf(fp_prt, + "debug_rt time used: %ld (u sec)<=%ld\r\n\r\n", + timeuse, max_time); + */ + + } + if(test_style == 4) + { + iptrans_timer(); + snmp_timer(); + + timeuse = 0; + gettimeofday(&tv_start, NULL); + outb(0xff, 0x378); + debug_rt(); + outb(0x00, 0x378); + + gettimeofday(&tv_end, NULL); + timeuse = + 1000000 * (tv_end.tv_sec - tv_start.tv_sec) - + tv_start.tv_usec + tv_end.tv_usec; + + if(timeuse > max_time) + max_time = timeuse; + if(timeuse>500) + fprintf(fp_prt, + " debug_rt time used: %ld (u sec)<=%ld\r\n\r\n", + timeuse, max_time); + + if(connect_flag == 0) + { + do_negotiate(sockfd); + MMI_telnet_recv(); + send_wont(sockfd, TELOPT_BINARY); + MMI_telnet_recv(); + FD_ZERO(&rset); + connect_flag = 1; + } + MMI_telnet_recv(); + if(recv_over == 2) + { + if(!feof(fp_conf)) + { + + fgets(data_arr, 1024, fp_conf); + if(data_arr[strlen(data_arr) - 1] == '\n') + data_arr[strlen(data_arr) - 1] = '\0'; + else + { + if(!feof(fp_conf)) + { + printf("Debug test conf file error!:%s\n",data_arr); + exit(0); + } + } + + if(!strlen(data_arr) ||(strstr(data_arr,"\\")) == data_arr + 0) + return; + MMI_File_Test(data_arr); + + } + else + { + if(j == 1) + test_style = 0; + else if(j > 0) + { + j--; + rewind(fp_conf); + } + } + } + } +} + +void Set_Timer() +{ + struct sigaction act; + + act.sa_handler = On_Timer; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + if(sigaction(SIGALRM, &act, NULL) < 0) + { + perror("Produce Sigaction"); + exit(1); + } + + itimer.it_interval.tv_sec = 0; + itimer.it_interval.tv_usec = 20 * 1000; + itimer.it_value.tv_sec = 0; + itimer.it_value.tv_usec = 20 * 1000; + + if(setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) + { + printf("Setting Timer error! \n"); + exit(1); + } +} + +void debug_snmp_agent_test_input() +{ + debug_snmp_agent snmp_agent_packet1; + DWORD temp_oid1[32] = + { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 3, 2, 2, 2, 1, 2 }; + DWORD temp_oid2[32] = + { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 3, 2, 2, 2, 1, 3 }; + WORD i,index; + + for(i=0;i3) + debug_snmp_agent_buf[i].cmm_state=6; + } + +} + + +void debug_snmp_print() +{ + char cmm_state_flag[128], result_state_flag[128], temp_str[32]; + WORD i, j; + + + strcpy(file_name, ""); + strcat(file_name, "debug_agent.txt"); + + if((fp_agent = fopen(file_name, "a+")) == NULL) + { + printf("[debug] Error: cannot open %s.\r\n", file_name); + return ; + } + + strcpy(cmm_state_flag, "cmm_state: "); + strcpy(result_state_flag, "result : "); + fprintf(fp_agent,"\r\nDebug snmp senior interface buffer: \r\n"); + fprintf(fp_agent,"index : "); + for(i = 0; i < 16; i++) + fprintf(fp_agent,"%3d ", i); + fprintf(fp_agent,"\r\n"); + for(i = 0; i < MAX_PACKET_NUM; i++) + if(debug_snmp_agent_buf[i].cmm_state != 0) + break; + //if(i == MAX_PACKET_NUM) + // return; + + for(i = 0; i < MAX_PACKET_NUM; i++) + { + sprintf(temp_str, "%3d ", debug_snmp_agent_buf[i].cmm_state); + strcat(cmm_state_flag, temp_str); + } + if(strcmp(oid_cmm_state, cmm_state_flag) != 0) + { + + strcpy(oid_cmm_state, cmm_state_flag); + fprintf(fp_agent,cmm_state_flag); + fprintf(fp_agent,"\r\n"); + for(i = 0; i < MAX_PACKET_NUM; i++) + { + sprintf(temp_str, "%3d ",debug_snmp_agent_buf[i].result_state); + strcat(result_state_flag, temp_str); + } + fprintf(fp_agent,result_state_flag); + + fprintf(fp_agent,"\r\n id OID OID_len Total field Total instance \r\n"); + for(i = 0; i < MAX_PACKET_NUM; i++) + { + strcpy(cmm_state_flag, ""); + sprintf(temp_str, "[%2d]: ", i); + strcat(cmm_state_flag, temp_str); + for(j = 0; j < 32 && debug_snmp_agent_buf[i].oid[j] != 0; + j++) + { + sprintf(temp_str, "%ld.", + debug_snmp_agent_buf[i].oid[j]); + strcat(cmm_state_flag, temp_str); + } + if(j < debug_snmp_agent_buf[i].oid_len - 1) + { + fprintf(fp_agent,"%ld.", debug_snmp_agent_buf[i].oid[j]); + } + sprintf(temp_str, " %d ", + debug_snmp_agent_buf[i].oid_len); + strcat(cmm_state_flag, temp_str); + fprintf(fp_agent,cmm_state_flag); + fprintf(fp_agent," %3d ", + debug_snmp_agent_buf[i].total_field); + fprintf(fp_agent," %3d \r\n", + debug_snmp_agent_buf[i].total_instance); + } + fprintf(fp_agent,"\r\n"); + } + fclose(fp_agent); +} + + + +/* +#define numFuncs 2 + + +typedef void ( *ptFuncDef )(); +ptFuncDef ptFuncArr[] = { &debug_mmi_list, &debug_snmp_get_rt,&debug_snmp_set_rt,&debug_ }; + +for ( i = 0; i < numFuncs; i++ ) +{ + gettimeofday( &start, NULL ); + ptFuncArr[i](); + gettimeofday( &end, NULL ); +} +*/ diff --git a/omc/plat/haepub/.copyarea.db b/omc/plat/haepub/.copyarea.db new file mode 100644 index 0000000..c35176b --- /dev/null +++ b/omc/plat/haepub/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\haepub +2 +5 +3:doc|2|0|0|0|cf2966e1bfa411dc8515001c23e19543|0 +2:ut|2|0|0|0|d47967f9bfa411dc8515001c23e19543|0 +3:src|2|0|0|0|d0596735bfa411dc8515001c23e19543|0 +8:Makefile|1|11d70a3eed1|b72|9d4ed28c|cfb96719bfa411dc8515001c23e19543|0 +3:lib|2|0|0|0|cf2966fdbfa411dc8515001c23e19543|0 diff --git a/omc/plat/haepub/Makefile b/omc/plat/haepub/Makefile new file mode 100644 index 0000000..ba6ca16 --- /dev/null +++ b/omc/plat/haepub/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module template : V1.6.3 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + +MODULE = haepub +TYPE = plat + +DBUG_FLAGS_ADD = -DDEBUG -D_MODIFY_AUC -D_MODIFY_EIR +RELS_FLAGS_ADD = -D_MODIFY_AUC -D_MODIFY_EIR + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/haepub/lib/libhaepub.a b/omc/plat/haepub/lib/libhaepub.a new file mode 100644 index 0000000..ef75969 Binary files /dev/null and b/omc/plat/haepub/lib/libhaepub.a differ diff --git a/omc/plat/haepub/obj/hae_function.o b/omc/plat/haepub/obj/hae_function.o new file mode 100644 index 0000000..dfbacd6 Binary files /dev/null and b/omc/plat/haepub/obj/hae_function.o differ diff --git a/omc/plat/haepub/obj/hae_param.o b/omc/plat/haepub/obj/hae_param.o new file mode 100644 index 0000000..6d71d77 Binary files /dev/null and b/omc/plat/haepub/obj/hae_param.o differ diff --git a/omc/plat/haepub/obj/hae_sync.o b/omc/plat/haepub/obj/hae_sync.o new file mode 100644 index 0000000..acd97c4 Binary files /dev/null and b/omc/plat/haepub/obj/hae_sync.o differ diff --git a/omc/plat/haepub/src/.copyarea.db b/omc/plat/haepub/src/.copyarea.db new file mode 100644 index 0000000..45c0938 --- /dev/null +++ b/omc/plat/haepub/src/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\haepub\src +2 +4 +b:hae_param.c|1|11d70a3efca|356|8538136a|d189676dbfa411dc8515001c23e19543|0 +7:include|2|0|0|0|d2b967a5bfa411dc8515001c23e19543|0 +a:hae_sync.c|1|11d8a87d154|626f|45494e00|4194c285afc111dd8a82001c23e19543|0 +e:hae_function.c|1|11d70a3ef9c|26c6|f9a0cde9|d0e96751bfa411dc8515001c23e19543|0 diff --git a/omc/plat/haepub/src/hae_function.c b/omc/plat/haepub/src/hae_function.c new file mode 100644 index 0000000..e39fbf6 --- /dev/null +++ b/omc/plat/haepub/src/hae_function.c @@ -0,0 +1,344 @@ +/* HAE public function c file */ +/* Written by Liu Zhiguo V1.0 */ +/* Time: 2003-07-31 */ +/* -------------------------- */ + +#include "./include/hae_include.h" + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from normal to anti sequence */ +/* 0460022157127001 --> 64002251177200f1 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi) +{ + u8 ii; + u8 aa,bb=0; + + for (ii = 1;ii <= IMSI_LEN*2;ii++) + { + if ((ii % 2) == 1) + bb = normal_imsi[ii/2] & 0x0f; + else + { + if (ii == IMSI_LEN * 2) + aa = 0x0f0; + else + aa = normal_imsi[ii/2] & 0x0f0; + anti_imsi[ii/2-1] = aa | bb; + } + } +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from anti to normal sequence */ +/* 64002251177200f1 --> 0460022157127001 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_imsi_aton(u8 *normal_imsi,u8 *anti_imsi) +{ // the IMSI must 15 digits + u8 ii; + u8 aa,bb=0; + + normal_imsi[0] = 0; + for (ii = 0;ii < IMSI_LEN*2;ii++) + { + if ((ii % 2) == 1) + { + aa = anti_imsi[ii/2] & 0x0f; + normal_imsi[ii/2] |= aa; + } + else + { + if (ii/2 != IMSI_LEN -1) + { + bb = anti_imsi[ii/2] & 0x0f0; + normal_imsi[ii/2+1] = bb; + } + } + } +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from normal to ascii string */ +/* 0460022157127001 --> "460022157127001" */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_imsi_ntos(u8 *str_imsi,u8 *normal_imsi) +{ + u8 len; + u8 ii,jj; + + str_imsi[0] = (normal_imsi[0] & 0x0f) + '0'; + len = 1; + for (ii = 1;ii < IMSI_LEN;ii ++) + { + jj = (normal_imsi[ii] >> 4) & 0x0f; + str_imsi[len++] = jj + '0'; + jj = normal_imsi[ii] & 0x0f; + str_imsi[len++] = jj + '0'; + } + str_imsi[len] = '\0'; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from ascii string to normal */ +/* "460022157127001" --> 0460022157127001 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_imsi_ston(u8 *normal_imsi,u8 *str_imsi) +{ + if (strlen(str_imsi) != IMSI_LEN*2-1) + return; + normal_imsi[0] = str_imsi[0] - '0'; + AsciiToBcd(normal_imsi+1,str_imsi+1,IMSI_LEN*2-2); +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from normal to anti sequence */ +/* 918675557127001EEE --> 08916857551700E1 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_isdn_ntoa(u8 *anti_isdn,u8 *normal_isdn) +{ + u8 ii; + u8 aa=0,bb=0; + u8 len; + + anti_isdn[1] = normal_isdn[0]; // nature of address and numbering plan indicator + len = 1; + for (ii = 1;ii < ISDN_LEN;ii ++) + { + if ((normal_isdn[ii] == 0xee) || (normal_isdn[ii] == 0xff)) + break; + else + { + aa = (normal_isdn[ii] & 0x0f0) >> 4; + bb = normal_isdn[ii] & 0x0f; + if (bb > 0x0c) + bb = 0x0f; + anti_isdn[ii+1] = (bb << 4) + aa; + len ++; + } + } + anti_isdn[0] = len; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from anti to normal sequence */ +/* 08916857551700E1 --> 918675557127001EEE */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_isdn_aton(u8 *normal_isdn,u8 *anti_isdn) +{ + u8 ii; + u8 aa=0,bb=0; + u8 isdn_len; + + isdn_len = anti_isdn[0]; + if (isdn_len > ISDN_LEN) + isdn_len = ISDN_LEN; + normal_isdn[0] = anti_isdn[1]; + for (ii = 1;ii < isdn_len;ii ++) + { + if ((anti_isdn[ii+1] & 0x0f) >= 0x0e) + break; + aa = (anti_isdn[ii+1] & 0x0f0) >> 4; + if (aa > 0x0c) + aa = 0x0e; + bb = anti_isdn[ii+1] & 0x0f; + normal_isdn[ii] = (bb << 4) + aa; + } + for (;ii < ISDN_LEN;ii ++) + normal_isdn[ii] = 0x0ee; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from normal to ascii string */ +/* 918675557127001EEE --> "8675557127001" */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_isdn_ntos(u8 *str_isdn,u8 *normal_isdn) +{ + u8 len = 0; + u8 ii,jj; + + for (ii = 1;ii < ISDN_LEN;ii ++) + { + jj = (normal_isdn[ii] >> 4) & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + jj = normal_isdn[ii] & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + } + str_isdn[len] = '\0'; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from ascii string to normal */ +/* "8675557127001" --> 918675557127001EEE */ +/* return value: 0--string has error; 1--success */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_isdn_ston(u8 *normal_isdn,u8 *str_isdn) +{ + u8 ii; + u8 len; + + len = strlen(str_isdn); + if (len > ISDN_LEN*2-2) + return 0; + if ((len % 2) == 1) // odd number + { + AsciiToBcd(normal_isdn+1,str_isdn,len-1); + ii = len/2 + 1; + normal_isdn[ii] = (str_isdn[len-1] - '0') << 4; + normal_isdn[ii] |= 0x0E; + } + else + { + AsciiToBcd(normal_isdn+1,str_isdn,len); + ii = len/2; + } + memset(normal_isdn+ii+1,0xEE,ISDN_LEN-ii-1); + normal_isdn[0] = 0x91; // default value + return 1; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* extract MAP primitive parameter */ +/* return value: 0--extract fail; 1--extract success */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_extract_param(struct MapOprSrv_struct *srv_ptr,struct MapOprData_struct *data_ptr) +{ + srv_ptr->port_id = data_ptr->port_id; + srv_ptr->dialogue_id = data_ptr->dialogue_id; + srv_ptr->invoke_id = data_ptr->invoke_id; + srv_ptr->message_type = data_ptr->message_type; + srv_ptr->message_flag = data_ptr->message_flag; + if (!(data_ptr->param_flag & 0x20)) // has not parameter + return 0; + return extract_mapparam(srv_ptr,data_ptr->message_type,data_ptr->message_flag,data_ptr->param_len,data_ptr->param); +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* build MAP primitive parameter */ +/* return value: 0--build fail; 1--build success */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_build_param(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr) +{ + u32 len; + u8 buf[4096]; + + data_ptr->port_id = srv_ptr->port_id; + data_ptr->dialogue_id = srv_ptr->dialogue_id; + data_ptr->invoke_id = srv_ptr->invoke_id; + data_ptr->message_type = srv_ptr->message_type; + data_ptr->message_flag = srv_ptr->message_flag; + data_ptr->param_flag = 0x1f; + len = build_mapparam(srv_ptr,buf); + if (len == 0 || len > MAX_MAPPOPR_LEN) + return 0; + data_ptr->param_len = len; + memcpy(data_ptr->param,buf,len); + data_ptr->param_flag |= 0x20; + return 1; +} + +u8 hae_build_param_v2(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr, u8 linked_id) +{ + u32 len; + u8 buf[4096]; + + data_ptr->port_id = srv_ptr->port_id; + data_ptr->dialogue_id = srv_ptr->dialogue_id; + data_ptr->invoke_id = srv_ptr->invoke_id; + data_ptr->message_type = srv_ptr->message_type; + data_ptr->message_flag = srv_ptr->message_flag; + data_ptr->linked_id = linked_id; + data_ptr->param_flag = 0x11f; + len = build_mapparam(srv_ptr,buf); + if (len == 0 || len > MAX_MAPPOPR_LEN) + return 0; + data_ptr->param_len = len; + memcpy(data_ptr->param,buf,len); + data_ptr->param_flag |= 0x20; + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* check if can send MAP common primitive */ +/* return value: 0--can not send; 1--can send */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_check_sendcom(u32 did) +{ + return map_check_sendcom(did); +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* check if can send MAP operation primitive */ +/* return value: 0--can not send; 1--can send */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_check_sendopr(u32 did) +{ + return map_check_sendopr(did); +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* get open from MAP provider */ +/* return value: 0--get fail; 1--get success */ +/* data_flow stores the message flow received from MAP provider */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_get_open(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 ssn) +{ + if (!map_get_open(data_flow,ssn)) + return 0; + if (!map_com_ftos(com_ptr,data_flow)) + return 0; + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* get common primitive from MAP provider */ +/* return value: 0--get fail; 1--get success */ +/* data_flow stores the message flow received from MAP provider */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_get_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u32 did) +{ + if (!map_get_comdata(data_flow,did)) + return 0; + if (!map_com_ftos(com_ptr,data_flow)) + return 0; + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* send common primitive to MAP provider */ +/* return value: 0--send fail; 1--send success */ +/* data_flow stores the message flow send to MAP provider */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_send_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 DelimiterFlag) +{ + map_com_stof(com_ptr,data_flow,DelimiterFlag); + return map_send_comdata(data_flow); +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* get operation primitive from MAP provider */ +/* return value: 0--get fail; 1--get success */ +/* data_flow stores the message flow get from MAP provider */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_get_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u32 did) +{ + if (!map_get_oprdata(data_flow,did)) + return 0; + if (!map_opr_ftos(opr_ptr,data_flow)) + return 0; + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* send operation primitive to MAP provider */ +/* return value: 0--send fail; 1--send success */ +/* data_flow stores the message flow send to MAP provider */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 hae_send_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u8 DelimiterFlag) +{ + map_opr_stof(opr_ptr,data_flow,DelimiterFlag); + return map_send_oprdata(data_flow); +} diff --git a/omc/plat/haepub/src/hae_param.c b/omc/plat/haepub/src/hae_param.c new file mode 100644 index 0000000..51719ff --- /dev/null +++ b/omc/plat/haepub/src/hae_param.c @@ -0,0 +1,51 @@ +/* HAE system parameter c file */ +/* Written by Liu Zhiguo V1.0 */ +/* Time: 2003-07-31 */ +/* ---------------------------- */ + +#include "./include/hae_include.h" + +static u32 hae_localip; // local ip address +static u32 hae_peerip; // peer ip address +static u32 hae_primomcip; // primary omc ip address +static u32 hae_secdomcip; // secondary omc ip address + +void hae_set_localip(u32 local_ip) +{ + hae_localip = local_ip; +} + +u32 hae_get_localip(void) +{ + return hae_localip; +} + +void hae_set_peerip(u32 peer_ip) +{ + hae_peerip = peer_ip; +} + +u32 hae_get_peerip(void) +{ + return hae_peerip; +} + +void hae_set_primomcip(u32 primomc_ip) +{ + hae_primomcip = primomc_ip; +} + +u32 hae_get_primomcip(void) +{ + return hae_primomcip; +} + +void hae_set_secdomcip(u32 secdomc_ip) +{ + hae_secdomcip = secdomc_ip; +} + +u32 hae_get_secdomcip(void) +{ + return hae_secdomcip; +} diff --git a/omc/plat/haepub/src/hae_sync.c b/omc/plat/haepub/src/hae_sync.c new file mode 100644 index 0000000..142f3fe --- /dev/null +++ b/omc/plat/haepub/src/hae_sync.c @@ -0,0 +1,895 @@ +/* HAE sync function c file */ +/* Written by Liu Zhiguo V1.0 */ +/* Time: 2003-08-08 */ +/* -------------------------- */ + +#include "./include/hae_include.h" + +#define PERIOD_SYNC_TIMEOUT 64 //16 +#define READ_ITEMS_PER_CYCLE 8 //The max readed items per cylce,must<32 +#define MAX_WAIT_TIMEOUT (READ_ITEMS_PER_CYCLE*3) +#define MAX_RAM_INIT_RETRY 4 + +const u32 HLR_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,3}; +const u32 AUC_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,4}; +const u32 EIR_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,8}; +static u32 HLR_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,3,2,7}; +static u32 AUC_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,4,2,7}; +static u32 EIR_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,8,2,7}; + +static u32 conf_oid[HAE_SYNC_MOD_NUM]={2,2,2}; +static u32 sync_ram_oid[HAE_SYNC_MOD_NUM]={7,7,7}; + +static u32 ramdata_pack_num[HAE_SYNC_MOD_NUM]={0,0,0}; //The Max packets of the Module +static void *ramshm_ptr[HAE_SYNC_MOD_NUM]={NULL,NULL,NULL}; //Restored the pointer of the subs shm. +static u8 master_flag[HAE_SYNC_MOD_NUM]={0,0,0}; //0/1=slave/master +static u8 switch_flag[HAE_SYNC_MOD_NUM]={0,0,0}; +static u8 period_flag[HAE_SYNC_MOD_NUM]={1,1,1}; +static int sent_pack_no[HAE_SYNC_MOD_NUM]={0,0,0}; +static int no_prd_sync[HAE_SYNC_MOD_NUM]={0,0,0}; // number of period sync +static u8 oid_prefix_len[HAE_SYNC_MOD_NUM]={0,0,0}; +static u32 read_start[HAE_SYNC_MOD_NUM]={0,0,0}; +static u32 recv_stand[HAE_SYNC_MOD_NUM]={0,0,0}; +static u32 recv_flag[HAE_SYNC_MOD_NUM]={0,0,0}; + +static u8 hae_data_ver[HAE_SYNC_MOD_NUM][3]={{0,0,0},{0,0,0},{0,0,0}}; + + +extern int hlr_realsync_proc(); +extern void hlr_send_psync_proc(); +extern void hlr_set_mastermode(); +extern void hlr_set_slavermode(); +extern int hlr_recv_psync_proc(u8 oid_len, u32 * oid, u8 * sync_data, u32 data_len, snmp_addr * addr_ptr); +extern void hlr_upgrade_subs_n_1(void *ptr, void *r_ptr, int file_size); +extern void hlr_upgrade_subs_n_2(void *ptr, void *r_ptr, int file_size); +extern int AucSyncNowMsgProc(BYTE OIDLen,DWORD *OID,BYTE *Pdata,u_short DataLen); +extern int EirSyncNowMsgProc(BYTE OIDLen,DWORD *OID,BYTE *Pdata,u_short DataLen); + +int get_weekday(char *wday_buf) +{ + struct tm *t,tt; + long curr_date; + + t=&tt; + curr_date=time((long *)0); + t=localtime(&curr_date); + if( t == NULL ) + { + assert(0 && "syscall: Locatime fail"); + exit(0); + } + sprintf(wday_buf,"%02d", t->tm_wday); + wday_buf[2]=0; + return t->tm_wday; +} + +void hae_init_sync(u8 fun_mod,u8 oid_len,u32 max_mem,u8 *data_ptr,void *shm_ptr) +{ + u8 i=0; + + oid_prefix_len[fun_mod] = oid_len; + + if((max_mem % HAE_PER_PACK_LEN)) + ramdata_pack_num[fun_mod] = max_mem/HAE_PER_PACK_LEN+1; + else + ramdata_pack_num[fun_mod] = max_mem/HAE_PER_PACK_LEN; + memcpy(&hae_data_ver[fun_mod],data_ptr,3); + for (i = 0;i < READ_ITEMS_PER_CYCLE;i ++) + recv_stand[fun_mod] |= (0x01<= 3) ? 1 : 0; +} + +int hae_set_period_flag(u8 fun_mod, u8 flag) +{ + if(fun_mod < HAE_SYNC_MOD_NUM) + { + period_flag[fun_mod] = flag & 0x01; + return 1; + } + return 0; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* Receive real time sync and periodic sync */ +/* Real time sync proc must be implemented by application */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_sync_msg_proc(u8 fun_mod) // hae sync message process +{ + int periodic_flag[HAE_SYNC_MOD_NUM]={0,0,0}; + void *ptr; + int i; + int instance=0,data_type; + snmp_pdu snmp_buf; + snmp_addr snmp_add; + var_list *varptr=NULL; + u32 master_ip = hae_get_localip(); + + switch(fun_mod) + { + case HLR_SYNC_MOD: + snmp_add.local_port = HLR_SYNC_UDPPORT; + break; + case AUC_SYNC_MOD: + snmp_add.local_port = AUC_SYNC_UDPPORT; + break; + case EIR_SYNC_MOD: + snmp_add.local_port = EIR_SYNC_UDPPORT; + break; + default: + return; + } + for(i = 0;i < ramdata_pack_num[fun_mod];i ++) + { + if (!snmp_receive(&snmp_buf,&snmp_add)) + break; + varptr = &snmp_buf.var[0]; + data_type = varptr->oid[12]; + switch(data_type) + { + case 2: + switch(varptr->oid[10]) + { + case 3://real sync message for HLR + hlr_realsync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add); + break; + case 4://Auc real sync message + #ifdef _MODIFY_AUC + AucSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen); + #endif + break; + case 8://Eir real sync message + #ifdef _MODIFY_EIR + EirSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen); + #endif + break; + } + break; +/* case 3: //real sync message for AUC/EIR + switch(fun_mod) + { + case AUC_SYNC_MOD: //Auc real sync message + #ifdef _MODIFY_AUC + AucSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen); + #endif + break; + case EIR_SYNC_MOD: //Eir real sync message + #ifdef _MODIFY_EIR + EirSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen); + #endif + break; + } + break; + case 6: //real sync message for HLR + hlr_realsync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add); + break;*/ + case 7 ://periodic sync message AUC EIR + if( fun_mod != HLR_SYNC_MOD ) + { + /* + master_ip = snmp_add.remote_ip; + periodic_flag[fun_mod] = 1; + instance = varptr->oid[13]; + if(instance >= ramdata_pack_num[fun_mod]) + continue; + if (varptr->msglen != HAE_PER_PACK_LEN) + continue; + + ptr = (void *) ramshm_ptr[fun_mod]; + memcpy(ptr+instance*HAE_PER_PACK_LEN,varptr->msg,HAE_PER_PACK_LEN); + */ + } + break; + case 9: //periodic sync message HLR + if( fun_mod == HLR_SYNC_MOD ) + { + master_ip = snmp_add.remote_ip; + periodic_flag[fun_mod] = 1; + //printf( "hlr recv periodic sync\n"); + hlr_recv_psync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add); + } + break; + } + } + + if (periodic_flag[fun_mod]) + { + if (master_flag[fun_mod] && master_ip < hae_get_localip()) + { + master_flag[fun_mod] = 0; + if( fun_mod == HLR_SYNC_MOD ) + { + //printf( "hlr set to slaver\n"); + hlr_set_slavermode(); + } + } + no_prd_sync[fun_mod] = 0; + } + else if(no_prd_sync[fun_mod]++ > PERIOD_SYNC_TIMEOUT) + { + master_flag[fun_mod] = 1; + if( fun_mod == HLR_SYNC_MOD ) + { + //printf( "hlr set to master\n"); + hlr_set_mastermode(); + } + } +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* Called by every applicatoin */ +/* Receive sync message(real and periodic), and */ +/* send periodic sync message if it acts as master server */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +void hae_syncdata_proc(u8 fun_mod) +{ + void *ptr; + snmp_pdu snmp_buf; + snmp_addr snmp_add; + var_list *varlist = NULL; + + //printf("psync proc\r\n"); + hae_sync_msg_proc(fun_mod); //receive sync message + if(!master_flag[fun_mod]) + return; + if((switch_flag[fun_mod]++) & 0x01) + return; + if(!period_flag[fun_mod]) + return; + //send periodic sync message + snmp_buf.pdu_type = 0x07; //trap + snmp_buf.var_num = 0x01; + varlist = snmp_buf.var; + varlist->oidlen = oid_prefix_len[fun_mod]+2+1; + varlist->vartype = 0x04; + switch(fun_mod) + { + case HLR_SYNC_MOD: + snmp_add.remote_port = HLR_SYNC_UDPPORT; + snmp_add.local_port = HLR_SYNC_UDPPORT; + memcpy(&varlist->oid,HLR_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32)); + break; + case AUC_SYNC_MOD: + snmp_add.remote_port = AUC_SYNC_UDPPORT; + snmp_add.local_port = AUC_SYNC_UDPPORT; + memcpy(&varlist->oid,AUC_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32)); + break; + case EIR_SYNC_MOD: + snmp_add.remote_port = EIR_SYNC_UDPPORT; + snmp_add.local_port = EIR_SYNC_UDPPORT; + memcpy(&varlist->oid,EIR_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32)); + break; + } + if( fun_mod == HLR_SYNC_MOD ) + { + hlr_send_psync_proc(); + //printf( "hlr send periodic sync\n"); + return ; + } + + snmp_add.remote_ip = hae_get_peerip(); + snmp_add.local_ip = hae_get_localip(); + snmp_add.broadcast = 0x00; + varlist->oid[oid_prefix_len[fun_mod]] = conf_oid[fun_mod]; //configuration + varlist->oid[oid_prefix_len[fun_mod]+1] = sync_ram_oid[fun_mod]; //sync ram + varlist->oid[13] = sent_pack_no[fun_mod]; //account_db + varlist->msglen = HAE_PER_PACK_LEN;//single packet,unit:KB + ptr = (void *)ramshm_ptr[fun_mod]; + memcpy(varlist->msg,ptr+sent_pack_no[fun_mod]*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN); + snmp_send(&snmp_buf,&snmp_add); + sent_pack_no[fun_mod] ++; + sent_pack_no[fun_mod] %= ramdata_pack_num[fun_mod]; +} + +int cmp_data_ver(u8 fun_mod,u8 *src_ptr) +{ + if(!memcmp(hae_data_ver[fun_mod],src_ptr,3)) + return 1; + return 0; +} + +/* The procedure is called back when peer data comes in SNMP GET RESP */ +int hae_load_from_peer_resp(u8 fun_mod,snmp_pdu *pdu,snmp_addr *addr) +{ + //static int LastInstance[HAE_SYNC_MOD_NUM]={0,0,0}; + int instance=0,tmp_val=0; + void *ptr; + + /* + if(LastInstance[fun_mod] && (LastInstance[fun_mod]+1) != (instance)){ + return 0; + } + LastInstance[fun_mod]=instance; + */ + if (pdu->var[0].oid[12] != 7) // do not ram data + return 0; + instance = pdu->var[0].oid[13]; //for init + if (instance >= ramdata_pack_num[fun_mod]) + return 0; + if (pdu->var[0].msglen != HAE_PER_PACK_LEN) + return 0; + tmp_val = instance - read_start[fun_mod]; + if (0 <= tmp_val && READ_ITEMS_PER_CYCLE > tmp_val) + recv_flag[fun_mod] |= (0x01 << tmp_val); + else + return 0; + ptr = (void *)ramshm_ptr[fun_mod]; + memcpy(ptr+instance*HAE_PER_PACK_LEN,pdu->var[0].msg,HAE_PER_PACK_LEN); + if (0 == instance) + {//check data version + if (!cmp_data_ver(fun_mod,(u8 *)ptr)) + { + memset((u8 *)ptr,0,HAE_PER_PACK_LEN); + return 0; // load fail + } + } + return 1; +} + +/* Use SNMP GET to load user data from peer server, and wait response */ +int hae_load_from_peer(u8 fun_mod) +{//calling during init procedure + snmp_pdu snmp_buf; + snmp_addr snmp_add; + var_list *varlist = NULL; + static int read_pack_no[HAE_SYNC_MOD_NUM]={0,0,0}; + static int read_state[HAE_SYNC_MOD_NUM]={0,0,0}; + static int try_times[HAE_SYNC_MOD_NUM]={0,0,0}; + static int reread_times[HAE_SYNC_MOD_NUM]={0,0,0}; + static u8 max_read_item[HAE_SYNC_MOD_NUM]={0,0,0}; +// int retval = _LOADING_DATA; + int i=0,oid_len=0; + + switch(read_state[fun_mod]) + { + case 0: //send request + if (read_pack_no[fun_mod] >= ramdata_pack_num[fun_mod]) + { //init over + read_state[fun_mod] = 0; + try_times[fun_mod] = 0; + reread_times[fun_mod] = 0; + read_pack_no[fun_mod] = 0; + return 2; // load success + } + snmp_buf.pdu_type = 0; // snmp get + snmp_buf.var_num = 0x01; +// snmp_add.remote_ip = PeerIp[fun_mod]; + snmp_add.remote_ip = hae_get_peerip(); + snmp_add.remote_port = HAE_AGENT_UDPPORT; + snmp_add.local_ip = hae_get_localip(); + snmp_add.local_port = HAE_AGENT_UDPPORT; + snmp_add.broadcast = 0x00; + varlist = &snmp_buf.var[0]; + switch(fun_mod) + { + case HLR_SYNC_MOD: + oid_len = sizeof(HLR_RAM_OID_PREFIX)/sizeof(u32); + memcpy(&varlist->oid,HLR_RAM_OID_PREFIX,oid_len*4); + break; + case AUC_SYNC_MOD: + oid_len=sizeof(AUC_RAM_OID_PREFIX)/sizeof(u32); + memcpy(&varlist->oid,AUC_RAM_OID_PREFIX,oid_len*4); + break; + case EIR_SYNC_MOD: + oid_len=sizeof(EIR_RAM_OID_PREFIX)/sizeof(u32); + memcpy(&varlist->oid,EIR_RAM_OID_PREFIX,oid_len*4); + break; + } + varlist->oidlen = oid_len+1; + varlist->vartype = 0x04; + varlist->msglen = 0; + if (ramdata_pack_num[fun_mod] >= (read_pack_no[fun_mod]+READ_ITEMS_PER_CYCLE)) + max_read_item[fun_mod] = READ_ITEMS_PER_CYCLE; + else + max_read_item[fun_mod] = ramdata_pack_num[fun_mod]-read_pack_no[fun_mod]; + read_start[fun_mod] = read_pack_no[fun_mod]; + for (i = 0;i < max_read_item[fun_mod];i ++) + { + recv_stand[fun_mod] |= (0x01<oid[oid_len] = read_pack_no[fun_mod] + i; + snmp_send(&snmp_buf,&snmp_add); + } + read_state[fun_mod] = 1; + try_times[fun_mod] = 0; + recv_flag[fun_mod] = 0; + break; + case 1: //wait response + if(recv_flag[fun_mod] == recv_stand[fun_mod]) + { + try_times[fun_mod] = 0; + read_state[fun_mod] = 0; + reread_times[fun_mod] = 0; + recv_flag[fun_mod] = 0; + recv_stand[fun_mod] = 0; + read_pack_no[fun_mod] += max_read_item[fun_mod]; + } + else if (try_times[fun_mod]++ >= MAX_WAIT_TIMEOUT*5) + { + read_state[fun_mod] = 0; + try_times[fun_mod] = 0; +// recv_flag[fun_mod] = 0; +// recv_stand[fun_mod] = 0; + if(reread_times[fun_mod]++ >= MAX_RAM_INIT_RETRY) + { + reread_times[fun_mod] = 0; + read_pack_no[fun_mod] = 0; + printf("Load data form peer timeout\n"); + return 0; + } + } + break; + default: + read_state[fun_mod] = 0; + break; + } + return 1; // load data +} + +/* The procedure is called when peer server request loading data */ +int hae_peerdata_resp(u8 fun_mod,u8 oidLen,u32 *oid,u8 *pdata,u8 *vartype) +{ // Response the Peer's reading request + u32 instance; + void *ptr; + + //instance = oid[13]; + instance = oid[oidLen-1]; + *vartype = 0x04; + if (instance >= ramdata_pack_num[fun_mod]) + return 0; + ptr = (void *)ramshm_ptr[fun_mod]; + memcpy(pdata,ptr+instance*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN); + return HAE_PER_PACK_LEN; +} + +int hae_load_from_local(u8 fun_mod,char *file_name) +{ + int i; + FILE *fp=NULL; + void *r_ptr; + void *ptr=(void *)ramshm_ptr[fun_mod]; + struct stat fileinfo; + + + if((fp = fopen(file_name, "r")) == NULL) + return 0; + if(fun_mod == HLR_SYNC_MOD) + { + stat(file_name, &fileinfo); + r_ptr = malloc(fileinfo.st_size); + if( r_ptr == NULL ) + { + assert(0 && "syscall: malloc fail"); + exit(0); + } + fread(r_ptr, fileinfo.st_size, 1, fp); +// if((hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0]) &&(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1])) +// { +// if(fileinfo.st_size <= ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN) +// memcpy(ptr, r_ptr, fileinfo.st_size); +// else +// memcpy(ptr, r_ptr, ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN); +// } +// if((hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0]) &&(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1])) +// if(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1]) +// { + if(fileinfo.st_size <= ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN) + memcpy(ptr+1024, r_ptr+1024, fileinfo.st_size-1024); + else + memcpy(ptr+1024, r_ptr+1024, ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN-1024); +// } +// else if(hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0]) +// { +// switch(hae_data_ver[HLR_SYNC_MOD][1] - ((u8 *)r_ptr)[1]) +// { +// case 1: +// hlr_upgrade_subs_n_1(ptr, r_ptr, fileinfo.st_size); +// break; +// case 2: +// hlr_upgrade_subs_n_2(ptr, r_ptr, fileinfo.st_size); +// break; +// default: +// printf("Failed to upgrade subscriber data\n"); +// break; +// } +// } + free(r_ptr); + } + else + { + for (i = 0;i < ramdata_pack_num[fun_mod];i ++) + { + fread(ptr+i*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN,1,fp); + // if(i == 0) + // {//check data version + // if(!cmp_data_ver(fun_mod,(u8 *)ptr)) + // { + // memset((u8 *)ptr,0,HAE_PER_PACK_LEN); + // fclose(fp); + // return 0; + // } + // } + } + } + fclose(fp); + return 2; // load success +} + +void hae_tftp_read_req(u16 portno,char *filename) +{ + int filename_len; + char readmode[20] = "octetoblksizeo1024"; + _msg_list ipmsg; + + filename_len = strlen(filename); + ipmsg.msgSrcPort = portno; + ipmsg.msgSrcIP = hae_get_localip(); + ipmsg.msgDstPort = 69; //TFTP_PORT; + ipmsg.msgDstIP = hae_get_primomcip(); + ipmsg.msgBroadcast = 0x00; + ipmsg.msgContent[0] = 0; + ipmsg.msgContent[1] = 1; //read request + memcpy(ipmsg.msgContent+2,filename,filename_len); + memcpy(ipmsg.msgContent+filename_len+3,readmode,18); + ipmsg.msgContent[filename_len+2] = 0; + ipmsg.msgContent[filename_len+8] = 0; + ipmsg.msgContent[filename_len+16] = 0; + ipmsg.msgContent[filename_len+21] = 0; + ipmsg.msgLength = filename_len+22; + iptrPutMessage(ipmsg); +} + +int hae_tftp_read_data(u8 fun_mod,u16 portno,u8 *databuf) +{ + static int readblocknum[HAE_SYNC_MOD_NUM] = {0}; + static int proc_len[HAE_SYNC_MOD_NUM] = {0}; + static int try_timer[HAE_SYNC_MOD_NUM] = {0}; + static int try_times[HAE_SYNC_MOD_NUM] = {0}; + static int tftp_read_port = 69; // TFTP port for OMC response + int ackblocknum; + int retval=0; + _msg_list ipmsg,ipack; + + if (iptrGetMessage(&ipmsg,portno)) + { + try_timer[fun_mod] = 0; + try_times[fun_mod] = 0; + switch (ipmsg.msgContent[1]) + { + case 3: // response + ackblocknum = ipmsg.msgContent[2]*256+ipmsg.msgContent[3]; + proc_len[fun_mod] += ipmsg.msgLength - 4; + if(ackblocknum == readblocknum[fun_mod]+1) + readblocknum[fun_mod] = ackblocknum; + else if(ackblocknum == 0) + { + if(readblocknum[fun_mod] == 0xffff) + readblocknum[fun_mod] = 0; + } + memcpy(databuf,ipmsg.msgContent,ipmsg.msgLength); //length + retval = ipmsg.msgLength; + // read next package + ipack.msgLength = 4; + ipack.msgContent[0] = 0x00; + ipack.msgContent[1] = 0x04; + ipack.msgContent[2] = ackblocknum >> 8; + ipack.msgContent[3] = ackblocknum; + ipack.msgSrcIP = hae_get_localip(); + ipack.msgSrcPort = TFTP_SRVC_PORT; + ipack.msgDstPort = ipmsg.msgSrcPort; + ipack.msgDstIP = hae_get_primomcip(); + iptrPutMessage(ipack); + tftp_read_port = ipmsg.msgSrcPort; + break; + case 6: // the first package response + proc_len[fun_mod] = 0; + readblocknum[fun_mod] = 0; + ipack.msgLength = 4; + ipack.msgContent[0] = 0x00; + ipack.msgContent[1] = 0x04; + ipack.msgContent[2] = readblocknum[fun_mod]>>8; + ipack.msgContent[3] = readblocknum[fun_mod]; + ipack.msgSrcIP = hae_get_localip(); + ipack.msgSrcPort = TFTP_SRVC_PORT; + ipack.msgDstPort = ipmsg.msgSrcPort; + ipack.msgDstIP = hae_get_primomcip(); + iptrPutMessage(ipack); + tftp_read_port = ipmsg.msgSrcPort; + break; + default: + printf("Error!\n"); + break; + } + } + else // do not receive response package + { + if (try_timer[fun_mod]++ > MAX_RAM_INIT_RETRY) + { + try_timer[fun_mod] = 0; + if (try_times[fun_mod]++ > MAX_RAM_INIT_RETRY) + return -1; + if (tftp_read_port == 69) // the request package is not response + return -1; + // resend the unreceived package + ipack.msgLength = 4; + ipack.msgContent[0] = 0x00; + ipack.msgContent[1] = 0x04; + ipack.msgContent[2] = readblocknum[fun_mod]>>8; + ipack.msgContent[3] = readblocknum[fun_mod]; + ipack.msgSrcIP = hae_get_localip(); + ipack.msgSrcPort = TFTP_SRVC_PORT; + ipack.msgDstPort = tftp_read_port; + ipack.msgDstIP = hae_get_primomcip(); + iptrPutMessage(ipack); + } + } + return retval; +} + +int hae_load_from_omc(u8 fun_mod) +{ + static int tftp_state[HAE_SYNC_MOD_NUM] = {0}; + void *ptr; + int blocknum = 0,length = 0; + char filename[18] = {0}; + u8 databuf[1024] = {0}; + u8 wday = 0,tmp_buf[3] = {0}; + + switch(tftp_state[fun_mod]) + { + case 0: + wday = (get_weekday(tmp_buf)+7-1) % 7; + switch(fun_mod) + { + case HLR_SYNC_MOD: + sprintf(filename,"hlr_backup%02d.dat",wday); + break; + case AUC_SYNC_MOD: + sprintf(filename,"auc_backup%02d.dat",wday); + break; + case EIR_SYNC_MOD: + sprintf(filename,"eir_backup%02d.dat",wday); + break; + } + hae_tftp_read_req(TFTP_SRVC_PORT,filename); + tftp_state[fun_mod] = 1; + break; + case 1: + length = hae_tftp_read_data(fun_mod,TFTP_SRVC_PORT,databuf); + if (length == -1) + { + printf("read from omc timeout\n"); + return 0; // load fail + } + else if(length >= 4) + { + blocknum = databuf[2] * 256 + databuf[3]; +// if(blocknum>=ramdata_pack_num[fun_mod]) +// continue; + ptr = (void *)ramshm_ptr[fun_mod]; + memcpy(ptr+(blocknum-1)*HAE_PER_PACK_LEN,databuf+4,length-4); //length is variable +// if (blocknum == 1) +// {//check data version +// if(!cmp_data_ver(fun_mod,(u8 *)ptr)) +// { +// memset((u8 *)ptr,0,HAE_PER_PACK_LEN); +// return 0; +// } +// } + if (blocknum == ramdata_pack_num[fun_mod]) + return 2; // load succcess + } + break; + default: + break; + } + return 1; // just load data +} + +int hae_tftp_write_req(int portno,char *filename) +{ + int retval=1,filename_len; + char writemode[20]="octetoblksizeo1024"; + _msg_list ipmsg; + + filename_len = strlen(filename); + + ipmsg.msgSrcPort = portno; + ipmsg.msgSrcIP = hae_get_localip(); + ipmsg.msgDstPort = 69; //TFTP_PORT; + ipmsg.msgDstIP = hae_get_primomcip(); + ipmsg.msgBroadcast = 0x00; + ipmsg.msgContent[0] = 0; + ipmsg.msgContent[1] = 2; //write request + memcpy(&ipmsg.msgContent[2],filename,filename_len); + memcpy(&ipmsg.msgContent[filename_len+3],writemode,18); + ipmsg.msgContent[filename_len+2] = 0; + ipmsg.msgContent[filename_len+8] = 0; + ipmsg.msgContent[filename_len+16] = 0; + ipmsg.msgContent[filename_len+21] = 0; + ipmsg.msgLength = filename_len+22; + iptrPutMessage(ipmsg); + return retval; +} + +int hae_tftp_write_data(u8 fun_mod) +{ + int retval = 0; + static int blocknum[HAE_SYNC_MOD_NUM]={1,1,1}; + static int ackblocknum[HAE_SYNC_MOD_NUM]={0,0,0}; + static int try_times[HAE_SYNC_MOD_NUM]={0,0,0}; + static int resend_times[HAE_SYNC_MOD_NUM]={0,0,0}; + _msg_list ipmsg,ipsend; + void *ptr = (void *)ramshm_ptr[fun_mod]; + + + if(iptrGetMessage(&ipmsg,TFTP_SRVC_PORT)) + { + if(ipmsg.msgContent[1] == 4) + { + ackblocknum[fun_mod] = ipmsg.msgContent[2]*256+ipmsg.msgContent[3]; + //printf("ack:%d, real:%d\n",ackblocknum[fun_mod],blocknum[fun_mod]); + if (ackblocknum[fun_mod] == blocknum[fun_mod]) + { + if (blocknum[fun_mod]++ >= ramdata_pack_num[fun_mod]) + { + blocknum[fun_mod] = 0; + ackblocknum[fun_mod] = 0; + try_times[fun_mod] = 0; + resend_times[fun_mod] = 0; + return 1; + } + } + } + else if (ipmsg.msgContent[1] == 5) + return -2; + else if (ipmsg.msgContent[1] == 6) + blocknum[fun_mod] = 1; + + ipsend.msgSrcIP = hae_get_localip(); + ipsend.msgSrcPort = TFTP_SRVC_PORT; + ipsend.msgDstPort = ipmsg.msgSrcPort; + ipsend.msgDstIP = ipmsg.msgSrcIP; + ipsend.msgLength = 4 + 1024; + ipsend.msgContent[0] = 0x00; + ipsend.msgContent[1] = 0x03; + ipsend.msgContent[2] = blocknum[fun_mod]>>8; + ipsend.msgContent[3] = blocknum[fun_mod]; + memcpy(&ipsend.msgContent[4],ptr+(blocknum[fun_mod]-1)*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN); + iptrPutMessage(ipsend); + resend_times[fun_mod] = 0; + } + else if(try_times[fun_mod]++ > MAX_WAIT_TIMEOUT) + { + + try_times[fun_mod]=0; + + if(resend_times[fun_mod]++ >= MAX_RAM_INIT_RETRY) + { + resend_times[fun_mod] = 0; + blocknum[fun_mod] = 0; + ackblocknum[fun_mod] = 0; + retval = -1; + } + else if( blocknum[fun_mod] ) + { + ipsend.msgSrcIP = hae_get_localip(); + ipsend.msgSrcPort = TFTP_SRVC_PORT; + ipsend.msgDstPort = ipmsg.msgSrcPort; + ipsend.msgDstIP = ipmsg.msgSrcIP; + ipsend.msgLength = 4 + 1024; + ipsend.msgContent[0] = 0x00; + ipsend.msgContent[1] = 0x03; + ipsend.msgContent[2] = blocknum[fun_mod]>>8; + ipsend.msgContent[3] = blocknum[fun_mod]; + memcpy(&ipsend.msgContent[4],ptr+(blocknum[fun_mod]-1)*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN); + iptrPutMessage(ipsend); + } + } + return retval; +} + +int hae_back_to_omc(u8 fun_mod) +{ + int retval = 0; + static int back_state[HAE_SYNC_MOD_NUM]={0}; + char filename[32]; + u8 tmp_buf[3]={0}; + + switch(fun_mod) + { + case HLR_SYNC_MOD: + sprintf(filename,"hlr_backup%02d.dat",get_weekday(tmp_buf)); + break; + case AUC_SYNC_MOD: + sprintf(filename,"auc_backup%02d.dat",get_weekday(tmp_buf)); + break; + case EIR_SYNC_MOD: + sprintf(filename,"eir_backup%02d.dat",get_weekday(tmp_buf)); + break; + } + switch(back_state[fun_mod]) + { + case 0: + if(hae_tftp_write_req(TFTP_SRVC_PORT,filename)) + back_state[fun_mod] = 1; + break; + case 1: + if((retval = hae_tftp_write_data(fun_mod))) + back_state[fun_mod] = 0; + break; + default: + break; + } + return retval; +} + + +int hae_get_syncpercent( u8 fun_mod , u8 oidLen, u32 *oid ) +{ + int instance=0; + int last_instance = ramdata_pack_num[fun_mod] - ramdata_pack_num[fun_mod]%READ_ITEMS_PER_CYCLE; + + if ( oidLen != 13 && oid[12] != 7) // do not ram data + return -1; + + instance = oid[oidLen-1]; + + if (instance >= ramdata_pack_num[fun_mod] || !last_instance) + return -1; + + instance = (instance*10000/last_instance) ; + instance = (instance > 9999) ? 0 : instance; + + return instance; +} + + + + diff --git a/omc/plat/haepub/src/include/.copyarea.db b/omc/plat/haepub/src/include/.copyarea.db new file mode 100644 index 0000000..f43d1e1 --- /dev/null +++ b/omc/plat/haepub/src/include/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\haepub\src\include +2 +2 +d:hae_include.h|1|11d70a3f0e4|45d|afa24a77|d34967c1bfa411dc8515001c23e19543|0 +e:hae_function.h|1|11d70a3f112|8e1|e1e411e0|d3e967ddbfa411dc8515001c23e19543|0 diff --git a/omc/plat/haepub/src/include/hae_function.h b/omc/plat/haepub/src/include/hae_function.h new file mode 100644 index 0000000..b6e85c0 --- /dev/null +++ b/omc/plat/haepub/src/include/hae_function.h @@ -0,0 +1,51 @@ +/* HAE public function head file */ +/* Written by Liu Zhiguo V1.0 */ +/* Time: 2003-07-31 */ +/* -------------------------- */ + +#ifndef _HAE_FUNCTION +#define _HAE_FUNCTION + +void hae_imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi); +void hae_imsi_aton(u8 *normal_imsi,u8 *anti_imsi); +void hae_imsi_ntos(u8 *str_imsi,u8 *normal_imsi); +void hae_imsi_ston(u8 *normal_imsi,u8 *str_imsi); +void hae_isdn_ntoa(u8 *anti_isdn,u8 *normal_isdn); +void hae_isdn_aton(u8 *normal_isdn,u8 *anti_isdn); +void hae_isdn_ntos(u8 *str_isdn,u8 *normal_isdn); +u8 hae_isdn_ston(u8 *normal_isdn,u8 *str_isdn); +u8 hae_extract_param(struct MapOprSrv_struct *srv_ptr,struct MapOprData_struct *data_ptr); +u8 hae_build_param(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr); +u8 hae_build_param_v2(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr, u8 linked_id); +u8 hae_check_sendcom(u32 did); +u8 hae_check_sendopr(u32 did); +u8 hae_get_open(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 ssn); +u8 hae_get_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u32 did); +u8 hae_send_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 DelimiterFlag); +u8 hae_get_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u32 did); +u8 hae_send_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u8 DelimiterFlag); + +void hae_set_localip(u32 local_ip); +u32 hae_get_localip(void); +void hae_set_peerip(u32 peer_ip); +u32 hae_get_peerip(void); +void hae_set_primomcip(u32 primomc_ip); +u32 hae_get_primomcip(void); +void hae_set_secdomcip(u32 secdomc_ip); +u32 hae_get_secdomcip(void); + +void hae_init_sync(u8 fun_mod,u8 oid_len,u32 max_mem,u8 *data_ptr,void *shm_ptr); +int hae_set_master_flag(u8 fun_mod,u8 MasterFlag); +int hae_get_master_flag(u8 fun_mod); +int hae_inspect_master(u8 fun_mod); +int hae_set_period_flag(u8 fun_mod, u8 flag); +void hae_syncdata_proc(u8 fun_mod); +int hae_load_from_peer_resp(u8 fun_mod,snmp_pdu *pdu,snmp_addr *addr); +int hae_load_from_peer(u8 fun_mod); +int hae_peerdata_resp(u8 fun_mod,u8 oidLen,u32 *oid,u8 *pdata,u8 *vartype); +int hae_load_from_local(u8 fun_mod,char *file_name); +int hae_load_from_omc(u8 fun_mod); +int hae_back_to_omc(u8 fun_mod); +int hae_get_syncpercent( u8 fun_mod , u8 oidLen, u32 *oid ); + +#endif diff --git a/omc/plat/haepub/src/include/hae_include.h b/omc/plat/haepub/src/include/hae_include.h new file mode 100644 index 0000000..6d6bc28 --- /dev/null +++ b/omc/plat/haepub/src/include/hae_include.h @@ -0,0 +1,37 @@ +/* Define used head file */ +/* Written by Liu Zhiguo V1.0 */ +/* Time: 2003-07-31 */ +/* ------------------------- */ + +#ifndef _HAE_INCLUDE +#define _HAE_INCLUDE + +#include "../../../../plat/public/src/include/pub_include.h" +#include "../../../../plat/snmp/src/include/snmp.h" +#include "../../../../plat/sccp/src/include/sccp.h" +#include "../../../../plat/tcap/src/include/tcap_public.h" +#include "../../../../plat/tcap/src/include/tcap_proc.h" +#include "../../../../plat/xapp/src/mapp/map_code.h" +#include "../../../../plat/xapp/src/mapp/map_acn.h" +#include "../../../../plat/xapp/src/ixap.h" +#include "../../../../plat/xapp/src/mapp/map_public.h" +#include "../../../../plat/xapp/src/conv_prefix.h" +#include "hae_function.h" + +#define HAE_AGENT_UDPPORT 4957 // agent udp port +#define HLR_SYNC_UDPPORT 4970 // UDP port for HLR sync process +#define AUC_SYNC_UDPPORT 4972 +#define EIR_SYNC_UDPPORT 4969 +#define TFTP_SRVC_PORT 4968 + +#define HAE_PER_PACK_LEN 1024 // one package length + +typedef enum HAE_SYNC_MOD_ENUM +{ + HLR_SYNC_MOD = 0, + AUC_SYNC_MOD, + EIR_SYNC_MOD, + HAE_SYNC_MOD_NUM, +} HAE_SYNC_MOD_ENUM; + +#endif diff --git a/omc/plat/iptrans/.copyarea.db b/omc/plat/iptrans/.copyarea.db new file mode 100644 index 0000000..0f6d2ed --- /dev/null +++ b/omc/plat/iptrans/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\iptrans +2 +5 +3:doc|2|0|0|0|d5b9670cbfa411dc851a001c23e19543|0 +2:ut|2|0|0|0|e53969e4bfa411dc851a001c23e19543|0 +3:src|2|0|0|0|d6e96760bfa411dc851a001c23e19543|0 +8:Makefile|1|11d70a3f1ce|b34|6c55c172|d6496744bfa411dc851a001c23e19543|0 +3:lib|2|0|0|0|d6496728bfa411dc851a001c23e19543|0 diff --git a/omc/plat/iptrans/Makefile b/omc/plat/iptrans/Makefile new file mode 100644 index 0000000..8f49e05 --- /dev/null +++ b/omc/plat/iptrans/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module template : V1.6.3 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + +MODULE = iptrans +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/iptrans/doc/iptrans_bak b/omc/plat/iptrans/doc/iptrans_bak new file mode 100644 index 0000000..aa66d91 Binary files /dev/null and b/omc/plat/iptrans/doc/iptrans_bak differ diff --git a/omc/plat/iptrans/generate_iptrans b/omc/plat/iptrans/generate_iptrans new file mode 100644 index 0000000..6ae9508 --- /dev/null +++ b/omc/plat/iptrans/generate_iptrans @@ -0,0 +1,3 @@ +#!/bin/bash +#gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -lcurses -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm +gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm diff --git a/omc/plat/iptrans/iptrans b/omc/plat/iptrans/iptrans new file mode 100644 index 0000000..017a0e3 Binary files /dev/null and b/omc/plat/iptrans/iptrans differ diff --git a/omc/plat/iptrans/iptrans_bak b/omc/plat/iptrans/iptrans_bak new file mode 100644 index 0000000..aa66d91 Binary files /dev/null and b/omc/plat/iptrans/iptrans_bak differ diff --git a/omc/plat/iptrans/lib/libiptrans.a b/omc/plat/iptrans/lib/libiptrans.a new file mode 100644 index 0000000..ca2bd86 Binary files /dev/null and b/omc/plat/iptrans/lib/libiptrans.a differ diff --git a/omc/plat/iptrans/obj/comfunc.o b/omc/plat/iptrans/obj/comfunc.o new file mode 100644 index 0000000..9fd17b4 Binary files /dev/null and b/omc/plat/iptrans/obj/comfunc.o differ diff --git a/omc/plat/iptrans/obj/daemon.o b/omc/plat/iptrans/obj/daemon.o new file mode 100644 index 0000000..877f990 Binary files /dev/null and b/omc/plat/iptrans/obj/daemon.o differ diff --git a/omc/plat/iptrans/obj/error.o b/omc/plat/iptrans/obj/error.o new file mode 100644 index 0000000..6560dd9 Binary files /dev/null and b/omc/plat/iptrans/obj/error.o differ diff --git a/omc/plat/iptrans/obj/errorlog.o b/omc/plat/iptrans/obj/errorlog.o new file mode 100644 index 0000000..4f683b3 Binary files /dev/null and b/omc/plat/iptrans/obj/errorlog.o differ diff --git a/omc/plat/iptrans/obj/ipcfunc.o b/omc/plat/iptrans/obj/ipcfunc.o new file mode 100644 index 0000000..d806a90 Binary files /dev/null and b/omc/plat/iptrans/obj/ipcfunc.o differ diff --git a/omc/plat/iptrans/obj/ipmsgfun.o b/omc/plat/iptrans/obj/ipmsgfun.o new file mode 100644 index 0000000..b1b5b10 Binary files /dev/null and b/omc/plat/iptrans/obj/ipmsgfun.o differ diff --git a/omc/plat/iptrans/obj/iptrans.o b/omc/plat/iptrans/obj/iptrans.o new file mode 100644 index 0000000..3cfc480 Binary files /dev/null and b/omc/plat/iptrans/obj/iptrans.o differ diff --git a/omc/plat/iptrans/obj/iptrmain.o b/omc/plat/iptrans/obj/iptrmain.o new file mode 100644 index 0000000..9fe40bb Binary files /dev/null and b/omc/plat/iptrans/obj/iptrmain.o differ diff --git a/omc/plat/iptrans/obj/mcast_join.o b/omc/plat/iptrans/obj/mcast_join.o new file mode 100644 index 0000000..a2d23ac Binary files /dev/null and b/omc/plat/iptrans/obj/mcast_join.o differ diff --git a/omc/plat/iptrans/obj/queuefunc.o b/omc/plat/iptrans/obj/queuefunc.o new file mode 100644 index 0000000..1371934 Binary files /dev/null and b/omc/plat/iptrans/obj/queuefunc.o differ diff --git a/omc/plat/iptrans/obj/readmsg.o b/omc/plat/iptrans/obj/readmsg.o new file mode 100644 index 0000000..a9df257 Binary files /dev/null and b/omc/plat/iptrans/obj/readmsg.o differ diff --git a/omc/plat/iptrans/obj/signal.o b/omc/plat/iptrans/obj/signal.o new file mode 100644 index 0000000..24ca8b7 Binary files /dev/null and b/omc/plat/iptrans/obj/signal.o differ diff --git a/omc/plat/iptrans/obj/simu_debug.o b/omc/plat/iptrans/obj/simu_debug.o new file mode 100644 index 0000000..6888e1c Binary files /dev/null and b/omc/plat/iptrans/obj/simu_debug.o differ diff --git a/omc/plat/iptrans/src/.copyarea.db b/omc/plat/iptrans/src/.copyarea.db new file mode 100644 index 0000000..6668a88 --- /dev/null +++ b/omc/plat/iptrans/src/.copyarea.db @@ -0,0 +1,18 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\iptrans\src +2 +e +8:signal.c|1|11d70a3f306|2ec|7d67e483|d8a967b4bfa411dc851a001c23e19543|0 +9:readmsg.c|1|11d70a3f364|1414|665f1dce|d9d967ecbfa411dc851a001c23e19543|0 +8:daemon.c|1|11d70a3f48d|5b1|2e908d67|dd796878bfa411dc851a001c23e19543|0 +b:queuefunc.c|1|11d70a3f3f1|aa7|40dd25f6|db096824bfa411dc851a001c23e19543|0 +7:include|2|0|0|0|de096894bfa411dc851a001c23e19543|0 +7:error.c|1|11d70a3f335|85b|6d837e1c|d94967d0bfa411dc851a001c23e19543|0 +9:comfunc.c|1|11d70a3f45e|615|c89ac934|dc39685cbfa411dc851a001c23e19543|0 +c:simu_debug.c|1|11d70a3f27a|117|6e58531e|d779677cbfa411dc851a001c23e19543|0 +a:iptrmain.c|1|11d70a3f393|7c0|23214b44|da796808bfa411dc851a001c23e19543|0 +a:ipmsgfun.c|1|11d70a3f539|59a|2821d3c2|e49969c8bfa411dc851a001c23e19543|0 +9:ipcfunc.c|1|11d70a3f2b8|847|be8b6e69|d8196798bfa411dc851a001c23e19543|0 +c:mcast_join.c|1|11d70a3f4db|5ef|492dc215|e3696990bfa411dc851a001c23e19543|0 +a:errorlog.c|1|11d70a3f4fa|9fe|37b70443|e3f969acbfa411dc851a001c23e19543|0 +9:iptrans.c|1|11d70a3f42f|c21e|27cb93c8|e6b482e66cf311dd91a5001c23e19543|0 diff --git a/omc/plat/iptrans/src/comfunc.c b/omc/plat/iptrans/src/comfunc.c new file mode 100644 index 0000000..2509d1a --- /dev/null +++ b/omc/plat/iptrans/src/comfunc.c @@ -0,0 +1,81 @@ +/* +** CVS: $Id: comfunc.c,v 1.3 2001/01/20 19:58:49 zhangsz Exp $ +** +** Title: comfunc.c +** Author: Zhang Shuzhong +** Date: 2000.07.03 +** +** Description: Functions of comunication for PACS WLL. +** +*/ + +#include "../../public/src/include/includes.h" + +/* +** passivesock - allocate & bind a server socket using TCP or UDP +*/ + +/*@ignore@*/ +int +passivesock( const char * transport, u_short portbase, int qlen) +{ +struct sockaddr_in sin; +int s, type; + + memset(& sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(portbase); + sin.sin_addr.s_addr = INADDR_ANY; + bzero(&(sin.sin_zero), 8); + + if ( strcmp(transport, "UDP") == 0) + type = SOCK_DGRAM; + else + type = SOCK_STREAM; + s = socket(AF_INET, type, 0); + if (s < 0) { + perror("socket"); + return -3; + } + if (bind(s, (struct sockaddr *) & sin, sizeof(sin)) < 0) { + perror("bind"); + close(s); + return -4; + } + + if (type == SOCK_STREAM && listen(s, qlen) < 0) { + perror("listen"); + close(s); + return -5; + } + return s; +} + +/* +** passiveUDP - create a passive socket for use in a UDP server +*/ + +int +passiveUDP(u_short portbase) +{ + return (passivesock("UDP", portbase, 0) ); +} + +const char * +Inet_ntoa(const long addr) +{ + struct sockaddr_in sin; + + sin.sin_addr.s_addr = addr; + return ((char *) inet_ntoa(sin.sin_addr) ); +} + +const long +Inet_pton(const char *sp) +{ + struct in_addr i_addr; + + inet_pton(AF_INET, sp, &i_addr); + return i_addr.s_addr; +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/daemon.c b/omc/plat/iptrans/src/daemon.c new file mode 100644 index 0000000..ff27012 --- /dev/null +++ b/omc/plat/iptrans/src/daemon.c @@ -0,0 +1,65 @@ +/* +** CVS: $Id: daemon.c,v 1.4 2001/01/11 04:03:57 zhangsz Exp $ +** daemon.c +** created at 2000/08/22 +** By Zhang Shuzhong. +** Functions of daemon process. +*/ +#include "./include/iptrans.h" +#include +#include + +#define MAXFD 64 + +/*@ignore@*/ +int +InitDaemon(void) +{ + pid_t pid; + + if ( (pid = fork()) < 0) + return FAILURE; + else if (pid != 0) + exit(0); /* parent goes bye-bye */ + /* child continues */ + setsid(); /* become session leader */ +// chdir("/"); /* change working direactory */ + umask(0); /* clear our file mode creation mask */ + return SUCCESS; +} + + +void +DaemonInit(const char *pname, int facility) +{ + int i; + pid_t pid; + + if ( (pid = fork()) < 0) /* parent terminates */ + err_sys("%s: %s: fork (%d)", + FILE_MACRO, FUNCTION_MACRO, LINE_MACRO); + else if (pid != 0) + exit(0); /* parent goes bye-bye */ + + /* 41st child continues */ + setsid(); /* become session leader */ + + signal(SIGHUP, SIG_IGN); + + if ( (pid = fork()) < 0) /* 1st child terminates */ + err_sys("%s: %s: fork (%d)", + FILE_MACRO, FUNCTION_MACRO, LINE_MACRO); + else if (pid != 0) + exit(0); /* 1st child goes bye-bye */ + + +// chdir("/"); /* change working directory */ + + umask(0); /* clear our file mode creation mask */ + + for (i = 0; i < MAXFD; i++) + close(i); + + openlog(pname, LOG_PID, facility); +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/error.c b/omc/plat/iptrans/src/error.c new file mode 100644 index 0000000..65670c6 --- /dev/null +++ b/omc/plat/iptrans/src/error.c @@ -0,0 +1,114 @@ +#include +#include /* for definition of errno */ +#include /* ANSI C header file */ +#include +#include "./include/iptrans.h" + +static void err_doit(int, const char *, va_list); + +char *pname = NULL; /* caller can set this from argv[0] */ + +/* +** Nonfatal error related to a system call. +** Print a message and return. +*/ + +/*@ignore@*/ +void +err_ret(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + err_doit(1, fmt, ap); + va_end(ap); + return; +} + +/* +** Fatal error related to a system call. +** Print a message and terminate. +*/ + +void +err_sys(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + err_doit(1, fmt, ap); + va_end(ap); + exit(1); +} + +/* +** Fatal error related to a system call. +** Print a message, dump core, and terminate. +*/ + +void +err_dump(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + err_doit(1, fmt, ap); + va_end(ap); + abort(); /* dump core and terminate */ + exit(1); /* shouldn't get here */ +} + +/* +** Nonfatal error unrelated to a system call. +** Print a message and return. +*/ + +void +err_msg(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + err_doit(0, fmt, ap); + va_end(ap); + return; +} + +/* +** Fatal error unrelated to a system call. +** Print a message and terminate. +*/ + +void +err_quit(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + err_doit(0, fmt, ap); + va_end(ap); + exit(1); +} + +/* +** Print a message and return to caller. +** Caller specifies "errnoflag". +*/ + +static void +err_doit(int errnoflag, const char *fmt, va_list ap) +{ + int errno_save; + char buf[MAXLINE]; + + errno_save = errno; /* value caller might want printed */ + vsprintf(buf, fmt, ap); + if (errnoflag) + sprintf(buf+strlen(buf), ": %s", strerror(errno_save)); + strcat(buf, "\n"); + fflush(stdout); /* in case stdout and stderr are the same */ + fputs(buf, stderr); + fflush(NULL); /* flushes all stdio output streams */ + return; +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/errorlog.c b/omc/plat/iptrans/src/errorlog.c new file mode 100644 index 0000000..3778645 --- /dev/null +++ b/omc/plat/iptrans/src/errorlog.c @@ -0,0 +1,131 @@ +/* Error routines for programs that can run as a daemon. */ + +#include /* for definition of errno */ +#include /* ANSI C header file */ +#include +#include "./include/iptrans.h" + +static void log_doit(int, int, const char *, va_list ap); + +int debug=1; /* caller must define and set this: + nonzero if interactive, zero if daemon */ + +int under_develop=1; /* caller must define and set this: + nonzero if under develop, zero if not */ + + +/*@ignore@*/ +/* Initialize syslog(), if running as daemon. */ +void +log_open(const char *ident, int option, int facility) +{ + if (debug == 0) + openlog(ident, option, facility); +} + +/* +** Nonfatal error related to a system call. +** Print a message with the system's errno value and return. +*/ + +void +log_ret(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_doit(1, LOG_ERR, fmt, ap); + va_end(ap); + return; +} + +/* +** Fatal error related to a system call. +** Print a message and terminate. +*/ + +void +log_sys(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_doit(1, LOG_ERR, fmt, ap); + va_end(ap); + exit(2); +} + +/* +** Nonfatal error unrelated to a system call. +** Print a message and return. +*/ + +void +log_msg(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_doit(0, LOG_ERR, fmt, ap); + va_end(ap); + return; +} + +/* +** Debug message unrelated to a system call. +** Print a message and return while . +*/ + +void +log_debug(const char *fmt, ...) +{ + va_list ap; + + if (!under_develop) return; + va_start(ap, fmt); + log_doit(0, LOG_ERR, fmt, ap); + va_end(ap); + return; +} + +/* +** Fatal error unrelated to a system call. +** Print a message and terminate. +*/ + +void +log_quit(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_doit(0, LOG_ERR, fmt, ap); + va_end(ap); + exit(2); +} + +/* +** Print a message and return to caller. +** Caller specifies "errnoflag" and "priority". +*/ + +static void +log_doit(int errnoflag, int priority, const char *fmt, va_list ap) +{ + int errno_save; + char buf[MAXLINE]; + + errno_save = errno; /* value caller might want printed */ + vsprintf(buf, fmt, ap); + if (errnoflag) + sprintf(buf+strlen(buf), ": %s", strerror(errno_save)); + strcat(buf, "\n"); + if (debug) { + fflush(stdout); + fputs(buf, stderr); + fflush(stderr); + } else + syslog(priority, buf); + return; +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/generate_iptrans b/omc/plat/iptrans/src/generate_iptrans new file mode 100644 index 0000000..056375c --- /dev/null +++ b/omc/plat/iptrans/src/generate_iptrans @@ -0,0 +1,3 @@ +#!/bin/bash + +gcc -o iptrans iptrmain.c -L../lib/ -liptrans -L../../debug/lib -ldebug -lcurses -L../../snmp/lib -lsnmp -L../../public/lib -lpublic -lm diff --git a/omc/plat/iptrans/src/include/.copyarea.db b/omc/plat/iptrans/src/include/.copyarea.db new file mode 100644 index 0000000..9718762 --- /dev/null +++ b/omc/plat/iptrans/src/include/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\iptrans\src\include +2 +8 +a:iptrfunc.h|1|11d70a3f6bf|7a|61ee278e|e1096920bfa411dc851a001c23e19543|0 +8:errlog.h|1|11d70a3f76b|538|fbdb8e2b|e2c96974bfa411dc851a001c23e19543|0 +8:dbsync.h|1|11d70a3f72c|39e|e3790e4e|e2396958bfa411dc851a001c23e19543|0 +7:debug.h|1|11d70a3f6ee|3d8|2f1d1a9c|e199693cbfa411dc851a001c23e19543|0 +9:iptrans.h|1|11d70a3f5c5|1ba8|babffb23|de0968b0bfa411dc851a001c23e19543|0 +a:function.h|1|11d70a3f671|d35|d1703d82|e0696904bfa411dc851a001c23e19543|0 +8:config.h|1|11d70a3f652|20a|3e469456|dfd968e8bfa411dc851a001c23e19543|0 +a:includes.h|1|11d70a3f604|39f|d85a1d82|df3968ccbfa411dc851a001c23e19543|0 diff --git a/omc/plat/iptrans/src/include/config.h b/omc/plat/iptrans/src/include/config.h new file mode 100644 index 0000000..ec8e6d2 --- /dev/null +++ b/omc/plat/iptrans/src/include/config.h @@ -0,0 +1,23 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** module name: config.h +** CVS $Id: config.h,v 1.2 2001/01/11 04:07:56 zhangsz Exp $ +** +** configuration of Prepaid System. +** +*/ + +#ifndef CONFIG__H +#define CONFIG__H + +#define HAVE_FUNCTION_MACRO 1 +#define HAVE_FILE_MACRO 1 +#define HAVE_TIME_MACRO 1 +#define HAVE_DATE_MACRO 1 +#define HAVE_LINE_MACRO 1 + +#endif /* endof CONFIG__H */ diff --git a/omc/plat/iptrans/src/include/dbsync.h b/omc/plat/iptrans/src/include/dbsync.h new file mode 100644 index 0000000..87b822e --- /dev/null +++ b/omc/plat/iptrans/src/include/dbsync.h @@ -0,0 +1,37 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** file name: dbsync.h +** CVS $Id: dbsync.h,v 1.2 2001/02/08 10:53:33 zhangsz Exp $ +** +** Defination for Database Synchronization (dbsync.c). +*/ + +#ifndef DBSYNC__H +#define DBSYNC__H + +#include "iptrans.h" + +#define DS_PORT_NO 4959 /* Prepaid service port */ +#define DS_PORT_ID DS_PORT_NO - PORT_BASE_NUM + +#define DS_SHM_KEY 0x80000000 +#define DS_SHM_PERM 0664 +#define DS_MSG_TYPE "D0" +#define DS_DBNAME_MAX_LEN 14 +#define DS_SQLSCRIPT_MAX_LEN MAX_CONTENT_LEN-DS_DBNAME_MAX_LEN-2 + +typedef struct _dbsync_msg { + char type[2]; + char db_name[DS_DBNAME_MAX_LEN]; + char sql_script[DS_SQLSCRIPT_MAX_LEN]; +} _dbsync_msg; + +typedef struct ds_shm { + char time_created[15]; +} ds_shm; + +#endif /* DBSYNC__H */ diff --git a/omc/plat/iptrans/src/include/debug.h b/omc/plat/iptrans/src/include/debug.h new file mode 100644 index 0000000..c14b2f5 --- /dev/null +++ b/omc/plat/iptrans/src/include/debug.h @@ -0,0 +1,53 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** file name: debug.h +** CVS $Id: debug.h,v 1.2 2001/01/20 19:58:49 zhangsz Exp $ +** +** The debug information defination. +** +*/ + +#ifndef DEBUG__H +#define DEBUG__H +#include "config.h" + +#define UNDER_DEVELOP 1 +#define DEBUG 1 + +/* If we have these macros, we can add additional info to the header. */ +#ifdef HAVE_FILE_MACRO +#define FILE_MACRO (__FILE__) +#else +#define FILE_MACRO ("") +#endif + +#ifdef HAVE_FUNCTION_MACRO +#define FUNCTION_MACRO (__FUNCTION__) +#else +#define FUNCTION_MACRO ("") +#endif + +#ifdef HAVE_DATE_MACRO +#define DATE_MACRO (__DATE__) +#else +#define DATE_MACRO ("") +#endif + +#ifdef HAVE_TIME_MACRO +#define TIME_MACRO (__TIME__) +#else +#define TIME_MACRO ("") +#endif + +#ifdef HAVE_LINE_MACRO +#define LINE_MACRO (__LINE__) +#else +#define LINE_MACRO ("") +#endif + +#endif /* DEBUG__H */ diff --git a/omc/plat/iptrans/src/include/errlog.h b/omc/plat/iptrans/src/include/errlog.h new file mode 100644 index 0000000..5e084bf --- /dev/null +++ b/omc/plat/iptrans/src/include/errlog.h @@ -0,0 +1,39 @@ +/* +** Error and log proccess functions header file, +** to be included *after* all standard system headers +** +** CVS: $Id: errlog.h,v 1.2 2001/01/11 04:03:57 zhangsz Exp $ +*/ + +#ifndef ERRLOG__H +#define ERRLOG__H + +#include /* required for some of our prototypes */ +#include /* for convenience */ +#include /* for convenience */ +#include /* for convenience */ +#include /* for convenience */ + + /* default file access permissions for new files */ +#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) + + /* default permissions for new directories */ +#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH) + +#define log_flag() \ + log_debug("%s: %s: %d", FILE_MACRO, FUNCTION_MACRO, LINE_MACRO) + +void err_dump(const char *, ...); /* {App misc_source} */ +void err_msg(const char *, ...); +void err_quit(const char *, ...); +void err_ret(const char *, ...); +void err_sys(const char *, ...); + +void log_debug(const char *, ...); /* {App misc_source} */ +void log_msg(const char *, ...); /* {App misc_source} */ +void log_open(const char *, int, int); +void log_quit(const char *, ...); +void log_sys(const char *, ...); +void log_ret(const char *, ...); + +#endif /* ERRLOG__H */ diff --git a/omc/plat/iptrans/src/include/function.h b/omc/plat/iptrans/src/include/function.h new file mode 100644 index 0000000..7a243af --- /dev/null +++ b/omc/plat/iptrans/src/include/function.h @@ -0,0 +1,127 @@ +/* +** CVS: $Id: function.h,v 1.6 2001/02/08 10:53:33 zhangsz Exp $ +** +** function.h +** Created at 2000/07/23 +** public domain code by Zhang Shuzhong +** +** Description: Header file of function definations. +*/ + +#ifndef FUNCTION__H +#define FUNCTION__H + +#define DisplayContent(buf, bcd_buf, nbytes) \ + BcdToAscii(buf, bcd_buf, 2 * nbytes); \ + FormatOutput(buf, 2*nbytes, 2, ' '); \ + log_debug("packets contains (%s):\n%s", FUNCTION_MACRO, buf); + +#define BzeroContent(content, length) \ + bzero(content+length, MAX_CONTENT_LEN-length); + +#define WriteOutBuffer WriteToOutBuffer + +#define WriteToOutBuffer(PROG_NAME, ip_semid, poutbuf, pbuf) \ + SemLock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \ + WriteMsg((in_buffer *) poutbuf, pbuf, OUT_LIST_NUM); \ + SemUnlock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \ + SemUnlock(PROG_NAME, ip_semid, SEM_NUM-1, 1, IPC_NOWAIT); + +#define ReadInBuffer ReadFromInBuffer + +#define ReadFromInBuffer(PROG_NAME, ip_semid, port_id, pinbuf, pbuf) \ + SemLock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \ + ReadMsg((in_buffer *) pinbuf, pbuf, IN_LIST_NUM); \ + SemUnlock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \ + +int InitDaemon(void); /* Initialize a daemon process */ + +void +SetTermSignal(struct termio *ptermio, void (*handler)(int)); + +/* Initialize a daemon process */ +void DaemonInit(const char *pname, int); + +/* passive a socket handler, from comfunc.c */ +int passivesock( const char * transport, u_short portbase, int qlen); + +/* passive a UDP socket handler, from comfunc.c */ +int passiveUDP(u_short portbase); + +/* Fill string 'c' into last area of 'str'. */ +void StringCat(char *str, char *c, int slen); + +int ByteLength(BYTE *bcd, int c); + +/* Cut string while match character c. */ +void StringCut(char *str, int c); + +void Bstr2Hstr(char *cptr); + +void bitstring(char *str, long byze, int biz, int strwid); + +/* Binary string convert to int. */ +unsigned int Bstr2Int(char *cptr); + +/* Hex string convert to int. */ +unsigned int Hstr2Int(char *cptr); + +/* Get current hour */ +int gethour(char * hour_buf); +int getweek(char * week_buf); + +/* Get current hour */ +int getmin(char * min_buf); + +/* Convert data from ASCII form to left-aligned compact BCD form. */ +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len); + +/* Convert data from left-aligned compact BCD form to ASCII form. */ +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len); + +/* Convert data from ASCII form to right-aligned compact BCD form. */ +void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len); + +const char * +getdaytime(char *daytime_buf); + +char *GetASCTime(char *timep); + +void * +ShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg); + +int +SemInit(char *prog_name, key_t key, int sem_num, int sem_flg); + +BOOL +SemLock(char *prog_name, int sem_id, int sem_num, + unsigned nsops, int sem_flg); + +BOOL +SemUnlock(char *prog_name, int sem_id, int sem_num, + unsigned nsops, int sem_flg); + +BOOL +ReadMsg(void *pbuf, void *pmsg, int max_num); + +BOOL +WriteMsg(void *pbuf, void *pmsg, int max_num); + +const char * +Inet_ntoa(const long addr); + +const long +Inet_pton(const char *sp); + +char * +FormatOutput(char *sp, size_t, int, int); + +void +ByteReverse(BYTE *p1, BYTE *p2, size_t size); +void +SafeFree(void *pmem); + +void +GetAsciiField(char *dest, BYTE *src, size_t n); + +#endif diff --git a/omc/plat/iptrans/src/include/includes.h b/omc/plat/iptrans/src/include/includes.h new file mode 100644 index 0000000..b342ed5 --- /dev/null +++ b/omc/plat/iptrans/src/include/includes.h @@ -0,0 +1,47 @@ +/* +** CVS $Id: includes.h,v 1.3 2001/02/08 10:53:33 zhangsz Exp $ +** includes.h +** Created at 2000-10-17 +** by Zhang SZ. +** Include all header files of PACS-WLL 2000 Project. +*/ + +#ifndef INCLUDES__H +#define INCLUDES__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "public.h" +#include "function.h" +#include "errlog.h" +#include "debug.h" + +#ifndef NO_CONFIG_H +#include "config.h" +#endif + +#endif /* INCLUDES__H */ + diff --git a/omc/plat/iptrans/src/include/iptrans.h b/omc/plat/iptrans/src/include/iptrans.h new file mode 100644 index 0000000..0eef4c7 --- /dev/null +++ b/omc/plat/iptrans/src/include/iptrans.h @@ -0,0 +1,201 @@ +/* +** +** +** file name: +** +** header file include by IP transceiver. +** defination of shared memory structure. +** +*/ + +#ifndef IPTRANS__H +#define IPTRANS__H + +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" +#include "../../../public/src/include/pub_fmt.h" +#include "errlog.h" +#include "debug.h" + +#ifndef NO_CONFIG_H +#include "config.h" +#endif + +#define IN_LIST_NUM 200 /* list number of in_buffer that + can store in the buffer space + */ +#define DS_LIST_NUM IN_LIST_NUM +#define OUT_LIST_NUM 1024 /* list number of out_buffer that + can store in the buffer space + */ +#define PORT_IN_NUM 24 /* number of in port defined */ +#define PORT_DS_NUM 1 /* number of port to database sync process */ +#define PORT_OUT_NUM 1 /* number of out port defined */ +#define PORT_NUM PORT_IN_NUM /* pre-defined port number */ + +/* Port service */ +#define PORT_BASE_NUM 4950 /* minimum port number */ +#define MAX_CONTENT_LEN 1514 + +/* IP transceiver shared memory ipc key and permission */ +#define IPTRANS_SHM_KEY 0x60000000 +#define IPTRANS_SHM_PERM 0777 +#define IPTRANS_DEBUG_SHM 0x61610000 +#define IPTRANS_DEBUG_PERM 0664 + +/* IP transceiver semaphore ipc key and permission */ +#define RELEASE 1 /* release semaphore */ +#define ACQUIRE -1 /* acquire semaphore */ +#define MAX_STATISTICS_SEG 96 + +#define _msg_list message_list +typedef struct message_list { + unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */ + u_short msgSrcPort; /* port of source host */ + unsigned int msgDstIP; //long msgDstIP; /* ip number of Destination host */ + u_short msgDstPort; /* port of Destination host */ + int msgBroadcast; /* message sent with broadcast mode, + 0(default)/1=no/yes. + */ + u_short msgLength; /* message's length */ + BYTE msgContent[MAX_CONTENT_LEN]; /* message of packet received */ +} message_list; + +typedef struct ds_msg { + unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */ + u_short msgSrcPort; /* port of source host */ + unsigned int msgDstIP; //long msgDstIP; /* ip number of Destination host */ + u_short msgDstPort; /* port of Destination host */ + int msgBroadcast; /* message sent with broadcast mode, + 0(default)/1=no/yes. + */ + u_short msgLength; /* message's length */ + char msgContent[MAX_CONTENT_LEN]; /* message of packet received */ +} db_msg; + +typedef struct ds_buffer { + u_short msgReadSub; /* subscript of array msgList for reader */ + u_short msgWriteSub; /* subscript of array msgList for writer */ + db_msg msgList[DS_LIST_NUM]; /* message list buffer */ +} ds_buffer; + +#define _in_buffer in_buffer +typedef struct in_buffer { + u_short msgReadSub; /* subscript of array msgList for reader */ + u_short msgWriteSub; /* subscript of array msgList for writer */ + message_list msgList[IN_LIST_NUM]; /* message list buffer */ +} in_buffer; + +#define _out_buffer out_buffer +typedef struct out_buffer { + u_short msgReadSub; /* subscript of array msgList for reader */ + u_short msgWriteSub; /* subscript of array msgList for writer */ + message_list msgList[OUT_LIST_NUM]; /* message list buffer */ +} out_buffer; + +#define _port_stat port_stat +typedef struct port_stat { + + short portStatus; /* port status: + 0=idle 1=normal -1=abnormal + */ + DWORD inPackets; /* number of packets received */ + DWORD inBytes; + DWORD outPackets; /* number of packets sent */ + DWORD outBytes; + DWORD errorPackets; /* number of error packets received */ +} port_stat; + +/* +#define _port_stat port_stat +typedef struct port_stat{ + port_stat_15m port_stat_static[PORT_NUM]; +}port_stat; +*/ + +typedef struct debug_info +{ + DWORD debug_status_id[20]; + BYTE debug_status; + DWORD debug_ascin_id[20]; + DWORD debug_ascout_id[20]; + DWORD debug_name_id[20]; + DWORD debug_page_title[20]; + DWORD debug_page_line[20]; + BYTE title0_p[1024]; + BYTE title1_p[1024]; + BYTE title2_p[1024]; + BYTE title3_p[1020]; + char iptr_asciin_buf[4096]; + char iptr_asciout_buf[4096]; + BYTE port_onoff[PORT_NUM]; + BYTE port_status[PORT_NUM]; //overflow + BYTE resettimer[4]; + DWORD logflag; + DWORD srclog; + DWORD dstlog; +}debug_info; + + +typedef struct port_configure +{ + BYTE port_config[PORT_NUM]; +}port_configure; + +typedef struct iptrans_cdr_rec +{ + DWORD inPackets; + DWORD inBytes; + DWORD outPackets; + DWORD outBytes; + DWORD errorPackets; +}iptrans_cdr_rec; + +typedef struct iptrans_cdr_period +{ + iptrans_cdr_rec cdr_record[PORT_NUM]; +}iptrans_cdr_period; + +typedef struct snmp_info +{ + BYTE process_conf; + BYTE version[3]; + //port_configure port_conf; + //PORT STATUS ; debug_info.port_status + iptrans_cdr_period iptrans_cdr[96]; +}snmp_info; + +#define _iptrans_shm iptrans_shm +typedef struct iptrans_shm { /* type defination of IP transceiver + shared memory + */ + in_buffer msgPortIn[PORT_NUM]; /* message in_buffer defination, + a port buffer attach only a + application module. + */ + out_buffer msgPortOut; + out_buffer msgPlatPortOut; +} iptrans_shm; + +typedef struct _iptrans_status +{ + port_stat msgPortStat[PORT_NUM]; + debug_info debug_msg; + snmp_info snmp_data; +}iptrans_status; + +int iptrans_init(); +void iptrans_timer(); +int iptrMainInit(); +int iptrGetMessage(message_list *msgGet, int port); +int iptrDirectRecvMsg(message_list *msgGet, u_short port); +int iptrPutMessage(message_list msgPut); +int iptrDirectSendMsg(message_list msgPut); +int iptrPlatPutMessage(message_list msgPut); +int set_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen); +int get_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD *vartype); +int trap_iptrans(BYTE oidlen, DWORD *oid_ptr, BYTE *msg_ptr, BYTE msg_len); +int CloseTcpConn(); +extern void *iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg); + +#endif /* IPTRANS__H */ diff --git a/omc/plat/iptrans/src/include/iptrfunc.h b/omc/plat/iptrans/src/include/iptrfunc.h new file mode 100644 index 0000000..398c992 --- /dev/null +++ b/omc/plat/iptrans/src/include/iptrfunc.h @@ -0,0 +1,9 @@ + +#ifndef _IPTR_FUNCTION +#define _IPTR_FUNCTION + +int init_iptrans(); +void iptr_timer_IRQ(); +void iptrans_close(); + +#endif diff --git a/omc/plat/iptrans/src/ipcfunc.c b/omc/plat/iptrans/src/ipcfunc.c new file mode 100644 index 0000000..a4f89e2 --- /dev/null +++ b/omc/plat/iptrans/src/ipcfunc.c @@ -0,0 +1,93 @@ +/* +** CVS $Id: ipcfunc.c,v 1.4 2001/01/20 19:58:49 zhangsz Exp $ +** +** ipcfunc.c +** created at 2000/12/20 +** by Zhang SZ +** +** IPC functions for PACS-WLL project. +** +*/ + +#include "./include/iptrans.h" + +/*@ignore@*/ +void * +iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg) +{ +void *retp; +char *func_name = "ShmInit"; + + shm_id = shmget(key, size, shmflg); + if (shm_id == -1) + { + log_sys("%s: %s: shmget(key: %x)", prog_name, func_name, key); + return NULL; + } + + retp = shmat(shm_id, (char *)0, 0); + if (retp == (void *) -1) + { + log_sys("%s: %s: shmat", prog_name, func_name); + return NULL; + } + + return retp; +} + +int +iptrSemInit(char *prog_name, key_t key, int sem_num, int sem_flg) +{ +int initarray[sem_num]; +int sem_id, retval, i; +char *func_name = "SemInit"; + + sem_id = semget(key, sem_num, sem_flg); + if (sem_id == -1) + log_sys("%s: %s: semget", prog_name, func_name); + for (i=0; i +#include "./include/iptrans.h" + +static iptrans_shm *IPTRANS_shm_ptr; +static int IPTRANS_shm_id; + +/*@ignore@*/ +int iptransCreate() +{ + IPTRANS_shm_ptr = (iptrans_shm *)ShmInit(IPTRANS_shm_id,"iptrans",IPTRANS_SHM_KEY, + sizeof(iptrans_shm),IPTRANS_SHM_PERM | IPC_CREAT); +} + +int GetMessage(message_list *msgGet,int port_in) +{ + int port; + port=port_in-PORT_BASE_NUM; + if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub != + IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub) + { + memcpy(msgGet, + &IPTRANS_shm_ptr->msgPortIn[port].msgList[IPTRANS_shm_ptr->msgPortIn[port].msgReadSub], + sizeof(struct message_list)); + IPTRANS_shm_ptr->msgPortIn[port].msgReadSub++; + if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM) + IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0; + return 1; + } + return 0; + +} + +int PutMessage(message_list msgPut) +{ + memcpy(&IPTRANS_shm_ptr->msgPortOut.msgList[IPTRANS_shm_ptr->msgPortOut.msgWriteSub], + &msgPut, sizeof(struct message_list)); + IPTRANS_shm_ptr->msgPortOut.msgWriteSub ++; + if(IPTRANS_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM) + IPTRANS_shm_ptr->msgPortOut.msgWriteSub=0; + return 0; +} + +int clearPort(int port_in) +{ + int port; + port=port_in-PORT_BASE_NUM; + IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0; + IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub=0; + return 1; +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/iptrans.c b/omc/plat/iptrans/src/iptrans.c new file mode 100644 index 0000000..7e52b13 --- /dev/null +++ b/omc/plat/iptrans/src/iptrans.c @@ -0,0 +1,1864 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** file name: iptrans.c +** CVS: $Id: iptrans.c,v 1.9 2001/02/09 08:53:43 zhangsz Exp $ +** +** Description: IP transceiver common module of PACS-WLL Project. +** +*/ +#include /* ANSI C header file */ +#include +#include +#include + +#include "../../debug/src/include/debug.h" +#include "./include/iptrans.h" +#include "./include/dbsync.h" + +/*@ignore@*/ +#define PROG_NAME "iptrans" +#define OID_IPTRANS 1 +#define IPTR_DEBUG_ID 0 +#define BASE_ID_LEN 15 +#define MAX_DEBUG_MESSAGES 1 +#define MAX_TELNET_TIME (10*100*3600) +#define MAX_MULTICAST_TIME (100*60*2000) //TWO MINUTES + +#define TELNET_PORT 15 + +#define TYPE_UDP 0 +#define TYPE_TCP 1 + +#define ACCESS_BUFFERED 0 +#define ACCESS_DIRECT 1 + +int port_convert_flag = 0; + +typedef struct _PORT_STATUS +{ + unsigned short portno; + int sockfd; + unsigned char type; /*0/1/2/=UDP/TCP/MULITICAST*/ + unsigned char capability; /*0-6*/ + unsigned char buffered; /*whether buffered or not*/ + int connfd; + DWORD peerip; + int peerport; + int recvcounter; + //int sendcounter; + unsigned char convert_flag; + unsigned short real_portno; +}PORT_STATUS; + +PORT_STATUS port_status[PORT_NUM]; +iptrans_status iptransInfo; + +extern int debug; /* defined in errorlog.c */ +extern int under_develop; /* defined in errorlog.c */ +static int iptrans_shm_id; +static int iptrans_sem_id; +static struct termio prev_termio; +static iptrans_shm *iptrans_shm_ptr; +static DWORD IPTRANS_OID_PREFIX[]={1,3,6,1,4,1,1373,1,3,2,2,1}; +static BYTE IPTRANS_VERSION[3]={0x08,0x03,0x01}; +static int nowPeriod,lstPeriod=0; +static DWORD startTime[96]; +static int sendcounter; +extern int errno; + +u_char warningFlag = 0x01; + + +socklen_t clilen; +struct sockaddr_in cliaddr; + +const BYTE IPTR_PAGE_POINT = 14; +const BYTE IPTR_LINE_POINT = 15; +static BYTE *disp_ptr ; + +static u_short parportadd = 0x37a; +static u_char iptr_led_bit = 2; +static int debug_messages=0; + +int SetAsciioutMsg(int flag, const char *fmt, ...); +static char *iptrGetASCTime(); +static char *iptrFormatOutput(); +/*----------------------------------------------------*/ +int GetRealPortID(unsigned short port) +{ + int retval = -1; + int loop; + + for(loop=0;loop msgPortIn[loop]; + pstat=(port_stat *) &iptransInfo.msgPortStat[loop]; + + if(port_status[loop].type == TYPE_TCP) + { + Receive_TCP(loop,pbuf,pstat); + continue; + } + + nbytes = recvfrom(port_status[loop].sockfd, &bcd_buf, MAX_CONTENT_LEN, + 0, (struct sockaddr *) &sin, &len); + if (nbytes < 0) { + continue; + } + port=loop+PORT_BASE_NUM; + msgbuf.msgSrcIP = sin.sin_addr.s_addr; + msgbuf.msgSrcPort = ntohs(sin.sin_port); + srcport = msgbuf.msgSrcPort-PORT_BASE_NUM; + msgbuf.msgDstPort = port; + msgbuf.msgLength = nbytes; + msgbuf.msgBroadcast = NO; + memcpy(msgbuf.msgContent,bcd_buf,nbytes); + + iptrSemLock(PROG_NAME, iptrans_sem_id, 1, 1, IPC_NOWAIT); + /* write to buffer and statistics of packets. */ + if(! iptrWriteMsg(pbuf,&msgbuf,list_num)) + { + iptransInfo.debug_msg.port_status[loop] ++; + //SendHeartbeat(); + continue; + } + pstat->portStatus = 1; + pstat->inPackets ++; + pstat->inBytes += nbytes; + + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[loop].inPackets ++; + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[loop].inBytes +=nbytes; + iptrSemUnlock(PROG_NAME, iptrans_sem_id, 1, 1, IPC_NOWAIT); + + +#if UNDER_DEVELOP + if(debug_messages>=MAX_DEBUG_MESSAGES) continue; + if(iptransInfo.debug_msg.logflag == 0x00) + continue; + if(iptransInfo.debug_msg.logflag != 0xffffffff) + { + if(iptransInfo.debug_msg.srclog !=0) + { + flag = iptransInfo.debug_msg.srclog; + if((flag>>srcport) !=0x01) + continue; + } + if(iptransInfo.debug_msg.dstlog !=0) + { + flag = iptransInfo.debug_msg.dstlog; + if((flag>>loop) !=0x01) + continue; + } + } + showlen = nbytes; + if(showlen>256) showlen = 256; + debug_messages++; + SetAsciioutMsg(1, + "Read Subscript: %03d Write Subscript: %03d Port: %d\r\n", + pbuf->msgReadSub, pbuf->msgWriteSub, msgbuf.msgSrcPort); + if (ds_flag == NO) { + BcdToAscii(buf, msgbuf.msgContent, 2*showlen); + iptrFormatOutput(buf, 2*showlen, 2, ' '); + } else { + memcpy(buf, msgbuf.msgContent, nbytes); + buf[nbytes] = 0; + } + SetAsciioutMsg(0,"Current time: %s\r\n", iptrGetASCTime(NULL)); + SetAsciioutMsg(0, + "got packet from %s %d #%d\r\n", + (char *)inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), i); + SetAsciioutMsg(0, + "packet is %d bytes (chars) long, contains:\r\n%s\r\n", nbytes, buf); + i++; +#endif + + } /* loop */ + +} +/* end of RecvMessage -------------------*/ + +int Receive_TCP(int port,in_buffer *pbuf,port_stat *pstat) +{ + int nbytes,len,i,j; + struct sockaddr_in sin; + message_list msgbuf; + + len = sizeof(struct sockaddr); + if(port_status[port].connfd<=0 ) return 0; + + nbytes = recvfrom(port_status[port].connfd, + msgbuf.msgContent, + MAX_CONTENT_LEN, + 0, + (struct sockaddr *) &sin, + &len); + if(nbytes<0){ + return 0; + } + if(nbytes==0){ + //if(errno==ENOTSOCK || errno==ENOTCONN) + { + CloseTcpConn(port); + } + return 0; + } +// fprintf(stderr,"connfd[%d]: Recv bytes:%d Client IP:%08x\n", +// port+BASE_PORT_NUM, nbytes,peerip[port]); + + msgbuf.msgSrcIP = sin.sin_addr.s_addr; + msgbuf.msgSrcPort = ntohs(sin.sin_port); + + msgbuf.msgDstPort = port+PORT_BASE_NUM; + msgbuf.msgLength = nbytes; + msgbuf.msgBroadcast = NO; + + iptrWriteMsg(pbuf, &msgbuf, IN_LIST_NUM); + pstat->portStatus = 1; + pstat->inPackets ++; + pstat->inBytes +=nbytes; + + if(strncasecmp(msgbuf.msgContent,"exit",4)==0) + CloseTcpConn(port); + else if(msgbuf.msgContent[0]=='q' || + msgbuf.msgContent[0] =='Q') + CloseTcpConn(port); + +#if UNDER_DEVELOP1 + msgbuf.msgContent[nbytes] = 0; + for(i=0;imsgPortOut; + else + pbuf = (out_buffer *)&iptrans_shm_ptr->msgPlatPortOut; + if(pbuf->msgReadSub == pbuf->msgWriteSub) continue; + else{ + iptrReadMsg(pbuf, (message_list *) &msgbuf, OUT_LIST_NUM); + port_id = msgbuf.msgSrcPort - PORT_BASE_NUM; + if (port_id<0 || port_id>=PORT_NUM) + { + if(port_convert_flag) + { + port_id = GetRealPortID(msgbuf.msgSrcPort); + if(port_id<0) + continue; + } + continue; + } + + sin.sin_addr.s_addr = msgbuf.msgDstIP; + sin.sin_port = htons(msgbuf.msgDstPort); + dstport = msgbuf.msgDstPort - PORT_BASE_NUM; + len = msgbuf.msgLength; + memcpy(bcd_buf, msgbuf.msgContent, len); + + broadcast_message = msgbuf.msgBroadcast; + if (broadcast_message) { + ret = setsockopt(port_status[port_id].sockfd, SOL_SOCKET, + SO_BROADCAST, + &broadcast_message, sizeof(broadcast_message)); + if (ret < 0) + log_ret("%s: %s: setsockopt", PROG_NAME, FUNCTION_MACRO); + } + if(port_status[port_id].type == TYPE_TCP) + { + if(port_status[port_id].connfd<=0) continue; + ret = send(port_status[port_id].connfd, + &msgbuf.msgContent, len, MSG_NOSIGNAL); + } + else + { + ret = sendto(port_status[port_id].sockfd, &bcd_buf, len, 0, + (struct sockaddr *)&sin, sizeof(sin)); + + } + if (ret < 0) { + iptransInfo.msgPortStat[port_id].portStatus = -1; + iptransInfo.msgPortStat[port_id].errorPackets ++; + } + else if (port_id >= 0 && port_id < PORT_NUM) { + iptransInfo.msgPortStat[port_id].outPackets ++; + sendlen = iptransInfo.msgPortStat[port_id].outBytes; + iptransInfo.msgPortStat[port_id].outBytes = sendlen + len; + + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[port_id].outPackets ++; + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[port_id].outBytes +=len; + } + +#if UNDER_DEVELOP + if(debug_messages>=MAX_DEBUG_MESSAGES) continue; + if(iptransInfo.debug_msg.logflag == 0x00000000) + continue; + if(iptransInfo.debug_msg.logflag != 0xffffffff) + { + if(iptransInfo.debug_msg.srclog !=0) + { + flag = iptransInfo.debug_msg.srclog; + if((flag>>port_id) !=0x01) + continue; + } + if(iptransInfo.debug_msg.dstlog !=0) + { + flag = iptransInfo.debug_msg.dstlog; + if((flag>>dstport) !=0x01) + continue; + } + } + showlen = len; + if(showlen>256) showlen = 256; + debug_messages++; + SetAsciioutMsg(1, + "Read Subscript: %d Write Subscript: %d Port: %d\r\n", + pbuf->msgReadSub, pbuf->msgWriteSub, msgbuf.msgSrcPort); + if (msgbuf.msgDstPort != DS_PORT_NO) { + BcdToAscii(buf, bcd_buf, 2*(showlen)); + iptrFormatOutput(buf, 2*showlen, 2, ' '); + } else + memcpy(buf, bcd_buf, showlen); + SetAsciioutMsg(0,"Current time: %s\r\n", iptrGetASCTime(NULL)); + SetAsciioutMsg(0,"Sent packet to %s %d #%d\r\n", + (char *)inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), i); + SetAsciioutMsg(0, + "packet is %d bytes long, contains:\r\n%s\r\n", len, buf); + i ++; +#endif + } + } /* loop */ +} + +/* end of SendMessage() ----------------------*/ + +int CloseTcpConn(int index){ + close(port_status[index].connfd); + port_status[index].connfd = -1; + port_status[index].peerip = 0; + port_status[index].peerport = 0; + return 1; +} + +int CloseAllMulticastPort() +{ + int i; + for(i=28;i msgPortIn[TELNET_PORT]; + iptrWriteMsg(pbuf, &ipmsg, IN_LIST_NUM); +} + +int TcpConnectCheck(int index) +{ + int timeout=20; + int connfdtmp=0;// + char welcome[128]={"Welcome to enter debug world! (^_^) \n\r"}; + char timeout_prompt[128]={"You have stayed too long\n\r telnet again please!\n\r"}; + + //if(port_status[index].connfd<=0 ) + { + memset(&cliaddr,0,(clilen=sizeof(struct sockaddr))); + connfdtmp = accept(port_status[index].sockfd, + //port_status[index].connfd = accept(port_status[index].sockfd, + (struct sockaddr *)&cliaddr,&clilen); + if(connfdtmp<=0) return 0;// + if(port_status[index].connfd>0)// + { + + sprintf(welcome, + "\n\rSorry! %s:%d has connected to the server\n\r", + (char *)inet_ntoa(cliaddr.sin_addr), + ntohs(cliaddr.sin_port)); + send(port_status[index].connfd,welcome,strlen(welcome),MSG_NOSIGNAL); + + sprintf(welcome, + "your connection is cut, bye bye!\n\r"); + send(port_status[index].connfd,welcome,strlen(welcome),MSG_NOSIGNAL); + + CloseTcpConn(index); + } +/* + if(port_status[index].connfd<=0){ + return 0; + } +*/ + port_status[index].connfd = connfdtmp; // + if(port_status[index].connfd>0) + { + port_status[index].peerip = cliaddr.sin_addr.s_addr; + port_status[index].peerport = ntohs(cliaddr.sin_port); + fcntl(port_status[index].connfd,F_SETFL,O_NONBLOCK); + if(setsockopt(port_status[index].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) !=0){ + fprintf(stderr,"set keepalive failed\n"); + } + if(setsockopt(port_status[index].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) !=0){ + fprintf(stderr,"set keepalive failed\n"); + } + send(port_status[index].connfd,welcome,strlen(welcome),MSG_NOSIGNAL); + if(index==TELNET_PORT) + PutEscToApp(); + } + } + + return 1; +} +/*--------------------------------------------*/ +int iptrDirectRecvMsg(message_list *msgbuf,unsigned short port) +{ + int index,len,nbytes; + BYTE bcd_buf[MAX_CONTENT_LEN]; + struct sockaddr_in sin; + port_stat *pstat; + + index = port - PORT_BASE_NUM; + if(index<0 || index>=PORT_NUM) + { + return -1; + } + + if(port_status[index].buffered == ACCESS_BUFFERED) + { + return iptrGetMessage(msgbuf,port); + } + + if(port_status[index].recvcounter++>128) + { + return -1; + } + + pstat = &iptransInfo.msgPortStat[index]; + len = sizeof(struct sockaddr); + + if(port_status[index].type == TYPE_TCP) + { + if(port_status[index].connfd<=0) return-1; + + nbytes = recvfrom(port_status[index].connfd, + msgbuf->msgContent, + MAX_CONTENT_LEN, + 0, + (struct sockaddr *) &sin, + &len); + if(nbytes<0){ + return nbytes; + } + if(nbytes==0){ + //if(errno==ENOTSOCK || errno==ENOTCONN) + { + CloseTcpConn(port); + } + return -1; + } + + msgbuf->msgSrcIP = sin.sin_addr.s_addr; + msgbuf->msgSrcPort = ntohs(sin.sin_port); + + msgbuf->msgDstPort = index+PORT_BASE_NUM; + msgbuf->msgLength = nbytes; + msgbuf->msgBroadcast = NO; + + pstat->portStatus = 1; + pstat->inPackets ++; + pstat->inBytes +=nbytes; + + if(strncasecmp(msgbuf->msgContent,"exit",4)==0) + CloseTcpConn(index); + else if(msgbuf->msgContent[0]=='q' || + msgbuf->msgContent[0] =='Q') + CloseTcpConn(index); + return nbytes; + }else{ + nbytes = recvfrom(port_status[index].sockfd, + msgbuf->msgContent, MAX_CONTENT_LEN, + 0, (struct sockaddr *) &sin, &len); + if (nbytes < 0) { + return nbytes; + } + msgbuf->msgSrcIP = sin.sin_addr.s_addr; + msgbuf->msgSrcPort = ntohs(sin.sin_port); + msgbuf->msgDstPort = port; + msgbuf->msgLength = nbytes; + msgbuf->msgBroadcast = NO; + + pstat->portStatus = 1; + pstat->inPackets ++; + pstat->inBytes += nbytes; + + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[index].inPackets ++; + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[index].inBytes +=nbytes; + return nbytes; + } + +} + +int iptrDirectSendMsg(message_list msgbuf) +{ + int len, port_id,ret,sendlen; + int broadcast_message=0; + struct sockaddr_in sin; + + if(sendcounter++>128) return 0; + + port_id = msgbuf.msgSrcPort - PORT_BASE_NUM; + if (port_id<0 || port_id>=PORT_NUM) + { + if(port_convert_flag) + { + port_id = GetRealPortID(msgbuf.msgSrcPort); + if(port_id<0) + return 0; + } + else + return 0; + } + + if(port_status[port_id].buffered == ACCESS_BUFFERED) + { + return iptrPutMessage(msgbuf); + } + + len = 0; + bzero(&sin.sin_zero, sizeof(sin.sin_zero)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = msgbuf.msgDstIP; + sin.sin_port = htons(msgbuf.msgDstPort); + len = msgbuf.msgLength; + broadcast_message = msgbuf.msgBroadcast; + + if (broadcast_message) { + ret = setsockopt(port_status[port_id].sockfd, SOL_SOCKET, + SO_BROADCAST, + &broadcast_message, sizeof(broadcast_message)); + if (ret < 0) + log_ret("%s: %s: setsockopt", PROG_NAME, FUNCTION_MACRO); + } + if(port_status[port_id].type == TYPE_TCP) + { + if(port_status[port_id].connfd<=0) return 0; + ret = send(port_status[port_id].connfd, + &msgbuf.msgContent, len, MSG_NOSIGNAL); + }else{ + ret = sendto(port_status[port_id].sockfd, msgbuf.msgContent, len, 0, + (struct sockaddr *)&sin, sizeof(sin)); + + } + if (ret < 0) { + iptransInfo.msgPortStat[port_id].portStatus = -1; + iptransInfo.msgPortStat[port_id].errorPackets ++; + } + else if (port_id >= 0 && port_id < PORT_NUM) { + iptransInfo.msgPortStat[port_id].outPackets ++; + sendlen = iptransInfo.msgPortStat[port_id].outBytes; + iptransInfo.msgPortStat[port_id].outBytes = sendlen + len; + + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[port_id].outPackets ++; + iptransInfo.snmp_data.iptrans_cdr[nowPeriod].cdr_record[port_id].outBytes +=len; + } + + return 1; +} + + +/*------------------------------------------------*/ +int iptrGetMessage(message_list *msgGet,int port_in) +{ + int port=0; + u_short readSub, writeSub; + in_buffer *pbuf; + port=port_in-PORT_BASE_NUM; + if(port<0 || port>=PORT_NUM) return 0; + + pbuf = &iptrans_shm_ptr->msgPortIn[port]; + readSub = pbuf->msgReadSub%IN_LIST_NUM; + writeSub = pbuf->msgWriteSub; + if(readSub == writeSub) return 0; + memcpy(msgGet, + &pbuf->msgList[readSub], + sizeof(struct message_list));//msgPut.msgLength+44); + pbuf->msgReadSub = (pbuf->msgReadSub+1) % IN_LIST_NUM; + return 1; + +} + +int iptrPutMessage(message_list msgPut) +{ + out_buffer *pbuf; + static int reflag=0; + + if(reflag == 1){ + iptransInfo.debug_msg.port_status[10] ++; + return 0; + } + reflag = 1; + pbuf = &iptrans_shm_ptr->msgPortOut; + + pbuf->msgWriteSub = (pbuf->msgWriteSub) % OUT_LIST_NUM; + memcpy(&pbuf->msgList[pbuf->msgWriteSub], + &msgPut, + sizeof(struct message_list));//msgPut.msgLength+44); + pbuf->msgWriteSub = (pbuf->msgWriteSub+1) % OUT_LIST_NUM; + reflag = 0; + return 1; +} + +int iptrPlatPutMessage(message_list msgPut) +{ + out_buffer *pbuf; + static int reflag = 0; + if(reflag == 1){ + iptransInfo.debug_msg.port_status[11] ++; + return 0; + } + reflag = 1; + pbuf = &iptrans_shm_ptr->msgPlatPortOut; + pbuf->msgWriteSub = (pbuf->msgWriteSub) % OUT_LIST_NUM; + + memcpy(&pbuf->msgList[pbuf->msgWriteSub], + &msgPut, + sizeof(struct message_list));//msgPut.msgLength+44); + pbuf->msgWriteSub = (pbuf->msgWriteSub+1) % OUT_LIST_NUM; + reflag = 0; + return 1; +} + +/*--------------------------------------------*/ +void iptrans_timer() +{ + int i; + static int count = 0; + struct timeval tmnow; + message_list msgbuf; + + debug_messages = 0; + sendcounter = 0; + + for(i=0;i=0){ + msgbuf.msgSrcPort = 4966; + iptrDirectSendMsg(msgbuf); + } +*/ + ReadAsciin(); + + if(count++==1000) + { + count = 0; + SendHeartbeat(); + + nowPeriod = GetNowPeriod(); + if(nowPeriod != lstPeriod) + { + gettimeofday(&tmnow,NULL); + startTime[nowPeriod] = tmnow.tv_sec; + lstPeriod = nowPeriod; + memset(&iptransInfo.snmp_data.iptrans_cdr[nowPeriod],0,PORT_NUM*20); + } + + } + +} + +int InitMulticastPort() +{ + int i,port; + struct sockaddr_in sin_addr; + char ip3,ip[16]; + + for(i=28;i0) + { + if((mcast_join(sock,(struct sockaddr *)&saddr,sizeof(struct sockaddr),NULL,0))<0) + { + fprintf(stderr,"mcast_join failed\n"); + return -7; + } + } + return sock; + } + + + +int init_monitor() +{ + BYTE page; + BYTE *ptr; + + iptransInfo.debug_msg.debug_status = 1; + iptransInfo.debug_msg.debug_status_id[0] =1; + iptransInfo.debug_msg.debug_status_id[1] = 3; + iptransInfo.debug_msg.debug_status_id[2] = 6; + iptransInfo.debug_msg.debug_status_id[3] = 1; + iptransInfo.debug_msg.debug_status_id[4] = 4; + iptransInfo.debug_msg.debug_status_id[5] = 1; + iptransInfo.debug_msg.debug_status_id[6] = 1373; + iptransInfo.debug_msg.debug_status_id[7] = 1; + iptransInfo.debug_msg.debug_status_id[8] = 1; + iptransInfo.debug_msg.debug_status_id[9] = 2; + iptransInfo.debug_msg.debug_status_id[10] = 3; + iptransInfo.debug_msg.debug_status_id[11] = 1; + iptransInfo.debug_msg.debug_status_id[12] = 2; + iptransInfo.debug_msg.debug_status_id[13] = 2; + iptransInfo.debug_msg.debug_status_id[14] = 1; + + iptransInfo.debug_msg.debug_name_id[0] =1; + iptransInfo.debug_msg.debug_name_id[1] = 3; + iptransInfo.debug_msg.debug_name_id[2] = 6; + iptransInfo.debug_msg.debug_name_id[3] = 1; + iptransInfo.debug_msg.debug_name_id[4] = 4; + iptransInfo.debug_msg.debug_name_id[5] = 1; + iptransInfo.debug_msg.debug_name_id[6] = 1373; + iptransInfo.debug_msg.debug_name_id[7] = 1; + iptransInfo.debug_msg.debug_name_id[8] = 1; + iptransInfo.debug_msg.debug_name_id[9] = 2; + iptransInfo.debug_msg.debug_name_id[10] = 3; + iptransInfo.debug_msg.debug_name_id[11] = 1; + iptransInfo.debug_msg.debug_name_id[12] = 2; + iptransInfo.debug_msg.debug_name_id[13] = 2; + iptransInfo.debug_msg.debug_name_id[14] = 2; + + iptransInfo.debug_msg.debug_ascin_id[0] =1; + iptransInfo.debug_msg.debug_ascin_id[1] = 3; + iptransInfo.debug_msg.debug_ascin_id[2] = 6; + iptransInfo.debug_msg.debug_ascin_id[3] = 1; + iptransInfo.debug_msg.debug_ascin_id[4] = 4; + iptransInfo.debug_msg.debug_ascin_id[5] = 1; + iptransInfo.debug_msg.debug_ascin_id[6] = 1373; + iptransInfo.debug_msg.debug_ascin_id[7] = 1; + iptransInfo.debug_msg.debug_ascin_id[8] = 1; + iptransInfo.debug_msg.debug_ascin_id[9] = 2; + iptransInfo.debug_msg.debug_ascin_id[10] = 3; + iptransInfo.debug_msg.debug_ascin_id[11] = 1; + iptransInfo.debug_msg.debug_ascin_id[12] = 2; + iptransInfo.debug_msg.debug_ascin_id[13] = 2; + iptransInfo.debug_msg.debug_ascin_id[14] = 3; + + iptransInfo.debug_msg.debug_ascout_id[0] =1; + iptransInfo.debug_msg.debug_ascout_id[1] = 3; + iptransInfo.debug_msg.debug_ascout_id[2] = 6; + iptransInfo.debug_msg.debug_ascout_id[3] = 1; + iptransInfo.debug_msg.debug_ascout_id[4] = 4; + iptransInfo.debug_msg.debug_ascout_id[5] = 1; + iptransInfo.debug_msg.debug_ascout_id[6] = 1373; + iptransInfo.debug_msg.debug_ascout_id[7] = 1; + iptransInfo.debug_msg.debug_ascout_id[8] = 1; + iptransInfo.debug_msg.debug_ascout_id[9] = 2; + iptransInfo.debug_msg.debug_ascout_id[10] = 3; + iptransInfo.debug_msg.debug_ascout_id[11] = 1; + iptransInfo.debug_msg.debug_ascout_id[12] = 2; + iptransInfo.debug_msg.debug_ascout_id[13] = 2; + iptransInfo.debug_msg.debug_ascout_id[14] = 4; + + iptransInfo.debug_msg.debug_page_title[0] =1; + iptransInfo.debug_msg.debug_page_title[1] = 3; + iptransInfo.debug_msg.debug_page_title[2] = 6; + iptransInfo.debug_msg.debug_page_title[3] = 1; + iptransInfo.debug_msg.debug_page_title[4] = 4; + iptransInfo.debug_msg.debug_page_title[5] = 1; + iptransInfo.debug_msg.debug_page_title[6] = 1373; + iptransInfo.debug_msg.debug_page_title[7] = 1; + iptransInfo.debug_msg.debug_page_title[8] = 1; + iptransInfo.debug_msg.debug_page_title[9] = 2; + iptransInfo.debug_msg.debug_page_title[10] = 3; + iptransInfo.debug_msg.debug_page_title[11] = 1; + iptransInfo.debug_msg.debug_page_title[12] = 2; + iptransInfo.debug_msg.debug_page_title[13] = 2; + iptransInfo.debug_msg.debug_page_title[14] = 5; + iptransInfo.debug_msg.debug_page_title[15] = 1; + + iptransInfo.debug_msg.debug_page_line[0] =1; + iptransInfo.debug_msg.debug_page_line[1] = 3; + iptransInfo.debug_msg.debug_page_line[2] = 6; + iptransInfo.debug_msg.debug_page_line[3] = 1; + iptransInfo.debug_msg.debug_page_line[4] = 4; + iptransInfo.debug_msg.debug_page_line[5] = 1; + iptransInfo.debug_msg.debug_page_line[6] = 1373; + iptransInfo.debug_msg.debug_page_line[7] = 1; + iptransInfo.debug_msg.debug_page_line[8] = 1; + iptransInfo.debug_msg.debug_page_line[9] = 2; + iptransInfo.debug_msg.debug_page_line[10] = 3; + iptransInfo.debug_msg.debug_page_line[11] = 1; + iptransInfo.debug_msg.debug_page_line[12] = 2; + iptransInfo.debug_msg.debug_page_line[13] = 2; + iptransInfo.debug_msg.debug_page_line[14] = 1; + iptransInfo.debug_msg.debug_page_line[15] = 2; + iptransInfo.debug_msg.debug_page_line[16] = 1; + +sprintf(iptransInfo.debug_msg.title1_p,"%s", + " IPTRANS Version R9V0_01 Page 01\n\r\ + Port state \r\n\ + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n\ + Port Status\r\n\ + 4950-4965\r\n\ + 4966-4981\r\n\ +\ + Port Overflow\r\n\ + 4950-4965\r\n\ + 4966-4981\r\n\ + "); + +sprintf(iptransInfo.debug_msg.title2_p,"%s", + " IPTRANS Version R9V0_01 Page 02\n\r\ + Flow Statistics (PORT 4950 - 4965)\r\n\ + PortNo Received Sent Error\r\n\ + Packets Bytes Pakcets Bytes Packets\r\n\ + 4950\r\n\ + 4951\r\n\ + 4952\r\n\ + 4953\r\n\ + 4954\r\n\ + 4955\r\n\ + 4956\r\n\ + 4957\r\n\ + 4958\r\n\ + 4959\r\n\ + 4960\r\n\ + 4961\r\n\ + 4962\r\n\ + 4963\r\n\ + 4964\r\n\ + 4965" +); + +sprintf(iptransInfo.debug_msg.title3_p,"%s", + " IPTRANS Version R9V0_01 Page 03\n\r\ + Flow Statistics (PORT 4966 - 4981)\r\n\ + PortNo Received Sent Error\r\n\ + Packets Bytes Pakcets Bytes Packets\r\n\ + 4966\r\n\ + 4967\r\n\ + 4968\r\n\ + 4969\r\n\ + 4970\r\n\ + 4971\r\n\ + 4972\r\n\ + 4973\r\n\ + 4974\r\n\ + 4975\r\n\ + 4976\r\n\ + 4977\r\n\ + 4978\r\n\ + 4979\r\n\ + 4980\r\n\ + 4981" +); + debug_set_response(BASE_ID_LEN,iptransInfo.debug_msg.debug_status_id,&iptransInfo.debug_msg.debug_status,1); + debug_set_response(BASE_ID_LEN,iptransInfo.debug_msg.debug_name_id,"R9V0_01",8);//module name + debug_set_response(BASE_ID_LEN,iptransInfo.debug_msg.debug_ascin_id,iptransInfo.debug_msg.iptr_asciin_buf,4096);//ascii in buf + debug_set_response(BASE_ID_LEN,iptransInfo.debug_msg.debug_ascout_id,iptransInfo.debug_msg.iptr_asciout_buf,4096);//ascii out buf + + for (page = 1; page < 4; page ++) + { + switch (page) + { + case 1: + ptr = iptransInfo.debug_msg.title1_p; + break; + case 2://page 1 + ptr = iptransInfo.debug_msg.title2_p; + break; + case 3://page 2; + ptr = iptransInfo.debug_msg.title3_p; + break; + default: + break; + } + iptransInfo.debug_msg.debug_page_title[IPTR_PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN+1,iptransInfo.debug_msg.debug_page_title,ptr,strlen(ptr)); + iptr_disp_page(page); + } + + return 1; +} + + +int iptr_disp_page(int page) +{ + BYTE disp_line; + BYTE disp_length; + + + iptransInfo.debug_msg.debug_page_line[IPTR_PAGE_POINT] = page + 5;//page + for (disp_line = 0; disp_line < 16; disp_line++) + { + disp_length = iptr_disp_line(page,disp_line); + iptransInfo.debug_msg.debug_page_line[IPTR_LINE_POINT] = disp_line + 5;//line + iptransInfo.debug_msg.debug_page_line[IPTR_LINE_POINT+1] = 2;//data pointer + debug_set_response(BASE_ID_LEN+2,iptransInfo.debug_msg.debug_page_line,disp_ptr,disp_length); + } + return 1; +} + + +int iptr_disp_line(int page, int line)//return display length,disp data ptr per line +{ + BYTE disp_length; + int loop; + + disp_length = 16; + + switch (page) + { + case 1: + switch(line) + { + case 0: + disp_ptr= (BYTE *)iptransInfo.debug_msg.port_onoff; + break; + case 1: + disp_ptr= (BYTE *)&iptransInfo.debug_msg.port_onoff[16]; + break; + case 2: + case 3: + disp_length = 0; + break; + case 4: + disp_ptr = (BYTE *)iptransInfo.debug_msg.port_status; + break; + case 5: + disp_ptr = (BYTE *)&iptransInfo.debug_msg.port_status[16]; + break; + default: + disp_length = 0; + break; + } + break; + case 2://page 2 + disp_ptr=(BYTE *) &iptransInfo.msgPortStat[line].inPackets; + disp_length =20; + break; + case 3://page 3 + disp_ptr=(BYTE *)&iptransInfo.msgPortStat[16+line].inPackets; + disp_length = 20; + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +int ReadAsciin() +{ + int pageno,len; + char cmd[1024]={""}; + + len = strlen(iptransInfo.debug_msg.iptr_asciin_buf); + if(len==0) + { + return 0; + } + pageno = iptransInfo.debug_msg.iptr_asciin_buf[0]; + memcpy(cmd,&iptransInfo.debug_msg.iptr_asciin_buf[1],len-1); + + DecodeAsciin(pageno-1,cmd); + + memset(iptransInfo.debug_msg.iptr_asciin_buf,0,64); + return 1; +} + +int DecodeAsciin(int pageno, char *cmd) +{ + int res,port,no; + int srcport, dstport; + DWORD flag=0x01; + + switch(pageno) + { + case 0: + if((res=strcasecmp(cmd,"HELP"))==0) + { + sprintf(iptransInfo.debug_msg.iptr_asciout_buf, +"log help page\r\n\ +help : help for this page\r\n\ +set on portno=n: set port capability (n=0-6)\r\n\ +log all/none : log all message received or sent\r\n\ +log error on : if overflowed, point out which port overflowed\r\n\ +log error off : no message put, even port overflowed\r\n\ +log src portno : log message sent from port of portno\r\n\ +log dst portno : log message received from port of portno\r\n\ +log src portno1 and dst portno2 : log message from portno1 to portno2\r\n\ +"); + break; + } + else if((res=strcasecmp("LOG ALL",cmd))==0) + { + iptransInfo.debug_msg.logflag = 0xffffffff; + break; + } + else if((res=strcasecmp("LOG none",cmd))==0) + { + iptransInfo.debug_msg.logflag = 0x00; + break; + } + else if(strstr(cmd,"and dst 49") && strstr(cmd,"log src 49")) + { + srcport = atoi(&cmd[8]); + dstport = atoi(&cmd[21]); + if(srcport>=PORT_BASE_NUM+PORT_NUM || + dstport>=PORT_BASE_NUM+PORT_NUM) + break; + if(srcport=PORT_BASE_NUM+PORT_NUM) + break; + flag = 0x01; + iptransInfo.debug_msg.srclog = (flag<<(srcport-PORT_BASE_NUM)); + iptransInfo.debug_msg.logflag = 0xfffffffe; + break; + } + else if(strstr(cmd,"log dst 49")) + { + iptransInfo.debug_msg.srclog = 0x00; + dstport = atoi(&cmd[8]); + if(dstport=PORT_BASE_NUM+PORT_NUM) + break; + flag = 0x01; + iptransInfo.debug_msg.dstlog = (flag<<(dstport-PORT_BASE_NUM)); + iptransInfo.debug_msg.logflag = 0xfffffffe; + } + else if(strstr(cmd,"log error off")) + { + warningFlag = 0x00; + } + else if(strstr(cmd,"log error on")) + { + warningFlag = 0x01; + } + else if(strstr(cmd,"set on 49")) + { + dstport = atoi(&cmd[7]); + if(dstport=PORT_BASE_NUM+PORT_NUM) + { + sprintf(iptransInfo.debug_msg.iptr_asciout_buf, + "error port number, should be : 4950-4972!"); + break; + } + dstport -=PORT_BASE_NUM; + no = atoi(&cmd[12]); + if(no>=6) no = 6; + if(dstport == TELNET_PORT && no == 0) + { + sprintf(iptransInfo.debug_msg.iptr_asciout_buf, + "The WXC2 debug port cann't be closed!"); + break; + } + port_status[dstport].capability = no; + iptransInfo.debug_msg.port_onoff[dstport] = no; + + iptrSaveParameter(); + } + else{ + sprintf(iptransInfo.debug_msg.iptr_asciout_buf, + "error comamnd!"); + } + break; + case 1: + break; + case 2: + case 3: + if(strcasecmp(cmd,"C")==0) + { + ClearStatistics(pageno); + break; + } + if(strstr(cmd,"C 49") || strstr(cmd,"c 49")) + { + port = atoi(&cmd[2]); + if(port>=PORT_BASE_NUM && porttm_hour * 4) + (tmnow->tm_min)/15; + return nowP; +} + +int iptrans_initshm() +{ + + iptrans_shm_ptr = (iptrans_shm *) iptrShmInit(iptrans_shm_id, PROG_NAME, + IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT); + + if( NULL == iptrans_shm_ptr ) + { + printf("iptrans share memory fail.\n"); + exit(0); + } + + + memset(iptrans_shm_ptr, 0, sizeof(iptrans_shm)); + + return 1; +} + +int ConfigurePort() +{ + char confile[]={"./conf/iptrans.conf"}; + char s[80],s1[80],work[80]; + int loop,priority,len,type,direct=0; + unsigned char conf_state = 0xFF; + unsigned short port, realport; + char *off; + FILE *fpConf; + + fpConf = fopen(confile,"rb"); + if(fpConf==NULL) + { + printf("%s not found!\n",confile); + for(loop=0;loopsa_family) + { + case AF_INET:{ + struct ip_mreq mreq; + struct ifreq ifreq; + memcpy(&mreq.imr_multiaddr, + &((struct sockaddr_in *)sa)->sin_addr, + sizeof(struct in_addr)); + if(ifindex>0){ + if(if_indextoname(ifindex,ifreq.ifr_name)==NULL){ + // errno=ENXIO; + return(-1); + } + goto doioctl; + } + else if(ifname !=NULL){ + strncpy(ifreq.ifr_name,ifname,IFNAMSIZ); + doioctl: + if(ioctl(sockfd,SIOCGIFADDR,&ifreq)<0) + return (-1); + memcpy(&mreq.imr_interface.s_addr, + &((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr, + sizeof(struct in_addr)); + return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP, + &mreq,sizeof(mreq))); + } + else + mreq.imr_interface.s_addr=htonl(INADDR_ANY);// inet_addr(name); +// setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_IF,&flag,sizeof(flag)); + return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP, + &mreq,sizeof(mreq))); + } + default: + // errno=EPROTONOSUPPORT; + return(-1); + } +} + +int +mcast_set_loop(int sockfd, int onoff) +{ + u_char flag; + flag=onoff; + return (setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_LOOP, + &flag,sizeof(flag))); +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/queuefunc.c b/omc/plat/iptrans/src/queuefunc.c new file mode 100644 index 0000000..5b45123 --- /dev/null +++ b/omc/plat/iptrans/src/queuefunc.c @@ -0,0 +1,133 @@ +/* +** CVS $Id: queuefunc.c,v 1.3 2001/02/08 10:53:33 zhangsz Exp $ +** +** filename: queuefunc.c +** created at 2000/12/29 +** by Zhang Shuzhong +** +** loop message queue operating functions. +** +*/ + +#include "./include/iptrans.h" + +extern u_char warningFlag; + +/*@ignore@*/ +/* Read a message from loop queue. */ +BOOL +iptrReadMsg(void *pbuf, void *pmsg, int max_num) +{ + in_buffer *p; + message_list *msg_ptr; + + p = (in_buffer *) pbuf; + msg_ptr = (message_list *) pmsg; +// memset(msg_ptr, EMPTY, sizeof(struct message_list)); + + /* + ** these are some messages not to be read + ** while subscript of read isn't equal to subscipt of write. + */ + if (p->msgReadSub == p->msgWriteSub) + return FAILURE; + + memcpy(msg_ptr, &p->msgList[p->msgReadSub], + p->msgList[p->msgReadSub].msgLength + 44); +/*message head length */ +// sizeof(struct message_list)); + /* + ** increase READ SUBSCRIPT after got a message, + ** set READ SUBSCRIPT to 0 while it equal to max_num. + */ + p->msgReadSub ++; + if (p->msgReadSub == max_num) + p->msgReadSub = 0; + return SUCCESS; +} + +/* Write a message to loop queue. */ +BOOL +iptrWriteMsg(void *pbuf, void *pmsg, int max_num) +{ + in_buffer *p; + message_list *msg_ptr; + int port; + p = (in_buffer *) pbuf; + msg_ptr = (message_list *) pmsg; + memcpy(&p->msgList[p->msgWriteSub], msg_ptr, + msg_ptr->msgLength + 44);//sizeof(struct message_list)); + + p->msgWriteSub ++; + + + /* + ** if write subscript more than max_num, + ** write subscript equal 0. + */ + if (p->msgWriteSub == max_num) + p->msgWriteSub = 0; + + /* + ** if message written successful, + ** Read subscript is same as Write subscript, + ** then Read subsrcipt add 1. + */ + if (p->msgReadSub == p->msgWriteSub) + { + (p->msgReadSub == max_num-1) ? + (p->msgReadSub = 0) : (p->msgReadSub ++); + if(warningFlag){ + port = msg_ptr->msgDstPort; + SetAsciioutMsg(1,"Warning! Port: %d overflowed!\r\n",port); + return 0; + } + } + return 1; +} + + +void +iptrByteRev(BYTE *pbuf, BYTE *p, size_t size) +{ + int i; + char ch; + + for (i=0; i> 4; + *pbuf <<= 4; + *pbuf &= ch; + } + memcpy(p, pbuf, size); +} + +void +iptrStrrev(char *sp) +{ + char ch; + ch = sp[0]; + sp[0] = sp[1]; + sp[1] = ch; +} + +void +iptrByteReverse(BYTE *pbuf, BYTE *p, size_t size) +{ + + int i; + char *sp=NULL, tmpbuf[3]; + + sp = (char *) malloc(4*size + 1); + bzero(p, size); + + for (i=0; i<2*size; i+=2) { + sprintf(tmpbuf, "%02x", *(pbuf++)); + tmpbuf[2]=0; + iptrStrrev(tmpbuf); + strncpy(sp+i, tmpbuf, 2); + } + AsciiToBcd(pbuf, sp, 4*size); + memcpy(p, pbuf, 2*size); + free(sp); +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/readmsg.c b/omc/plat/iptrans/src/readmsg.c new file mode 100644 index 0000000..5fa77df --- /dev/null +++ b/omc/plat/iptrans/src/readmsg.c @@ -0,0 +1,189 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** file name: iptrans.c +** CVS: $Id: iptrans.c,v 1.9 2001/02/09 08:53:43 zhangsz Exp $ +** +** Description: IP transceiver common module of PACS-WLL Project. +** +*/ + +#include "./include/iptrans.h" + +#define PROG_NAME "iptrans" + +extern int debug; /* defined in errorlog.c */ +extern int under_develop; /* defined in errorlog.c */ +static int iptrans_shm_id; +static int iptrans_sem_id; +static struct termio prev_termio; +static iptrans_shm *iptrans_shm_ptr; + +int GetMessage(message_list *msgGet,int port); +void PutMessage(message_list msgPut); + +/*@ignore@*/ +/* Set debug flag to control debug message print or not */ +void SetDebugFlag(void) +{ + debug = DEBUG; /* DEBUG defined in debug.h */ + under_develop = UNDER_DEVELOP; /* UNDER_DEVELOP defined in debug.h */ +} + +/* +** Handler of terminatation, +** process while received a signal from user. +*/ +static void Terminate(int sig) +{ +int retval, i; + + usleep(100000); + retval = (int) shmdt(0); + if (retval == -1) log_ret("%s: %s: shmdt", PROG_NAME, FUNCTION_MACRO); + retval = shmctl(iptrans_shm_id, IPC_RMID, NULL); + if (retval == -1) log_ret("%s: %s: shmctl", PROG_NAME, FUNCTION_MACRO); + retval = semctl(iptrans_sem_id, PORT_NUM, IPC_RMID, NULL); + if (retval == -1) log_ret("%s: %s: semctl", PROG_NAME, FUNCTION_MACRO); + exit(sig); +} + +int GetMessage(struct message_list *msgGet,int port) +{ + message_list msgSend; + if(iptrans_shm_ptr->msgPortIn[port].msgReadSub != iptrans_shm_ptr->msgPortIn[port].msgWriteSub) + { + memcpy(msgGet, + &iptrans_shm_ptr->msgPortIn[port].msgList[iptrans_shm_ptr->msgPortIn[port].msgReadSub], + sizeof(struct message_list)); + memcpy(&msgSend,msgGet,sizeof(struct message_list)); + PutMessage(msgSend); + fprintf(stderr,"Recv msg %d.\n",port+4951); + iptrans_shm_ptr->msgPortIn[port].msgReadSub ++; + if(iptrans_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM) + iptrans_shm_ptr->msgPortIn[port].msgReadSub =0; + /* +fprintf(stderr,"iptrans state:\n port=%d\n packet in=%ld out=%ld errors=%ld %ld\n", + port, + iptrans_shm_ptr->msgPortStat[port].inPackets, + iptrans_shm_ptr->msgPortStat[port].outPackets, + iptrans_shm_ptr->msgPortStat[port].errorInPackets, + iptrans_shm_ptr->msgPortStat[port].errorOutPackets); +*/ + return 1; + } + else + { + return 0; + } +} + +void PutMessage(struct message_list msgPut) +{ + memcpy(&iptrans_shm_ptr->msgPortOut.msgList[iptrans_shm_ptr->msgPortOut.msgWriteSub], + &msgPut,sizeof(struct message_list)); + + iptrans_shm_ptr->msgPortOut.msgWriteSub ++; + if(iptrans_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM) + iptrans_shm_ptr->msgPortOut.msgWriteSub=0; + +} + +void timer_IRQ() +{ + int i; + struct message_list msgList; + for(i=0;i<13;i++) + { + GetMessage(&msgList,i); + // PutMessage(msgList); + } + +} + + +void init_timer_interrupt(void) +{ + struct sigaction newact; + newact.sa_handler =timer_IRQ; + newact.sa_flags =0; + sigemptyset(&newact.sa_mask); + sigaction(SIGALRM,&newact,NULL); +} + +void setup_interval_timer(void) +{ + struct itimerval value; + value.it_interval.tv_sec =0; + value.it_interval.tv_usec =5*1000; + value.it_value =value.it_interval; + setitimer(ITIMER_REAL,&value,NULL); +} + +void init_timer() +{ + init_timer_interrupt(); + setup_interval_timer(); +} + +int +main(int argc, char *argv[]) +{ + +int err_flag = FALSE; +int test_mode = FALSE; +int ret; + SetDebugFlag(); + + /* + ** Get option from command line. + ** option 'd' is enable to run program with daemon mode. + */ + while ((ret = getopt(argc, argv, "dt")) != -1) + switch (ret) + { + case 'd': + /* Set daemon mode and open a syslog */ + DaemonInit(PROG_NAME, LOG_USER); + break; + case 't': + test_mode = TRUE; /* test mode: bind port 4950 to recvfrom */ + break; + case '?': + err_flag = TRUE; + } + if (err_flag) { + log_msg("Usage: %s -d -t \n", argv[0]); + log_msg(" -d with daemon mode"); + log_msg(" -t with test mode"); + exit(1); + } + + /* + ** Get shared memory block, + ** IPTRANS_SHM_KEY to be defined in iptrans.h. + */ + iptrans_shm_ptr = (iptrans_shm *) ShmInit(iptrans_shm_id, PROG_NAME, + IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT); + memset(iptrans_shm_ptr, 0, sizeof(iptrans_shm)); + + /* + ** Get semaphores ID used by shared memory block, + ** IPTRANS_SEM_KEY to be defined in iptrans.h. + */ + + SetTermSignal(&prev_termio, Terminate); + /* + ** Open socket handler for IP transceiver. + ** maxinum number is PORT_NUM. + */ + init_timer(); + while(1){ + usleep(1); + } + exit(0); +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/signal.c b/omc/plat/iptrans/src/signal.c new file mode 100644 index 0000000..dc92737 --- /dev/null +++ b/omc/plat/iptrans/src/signal.c @@ -0,0 +1,33 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** +** Written completely by Zhang Shuzhong at iCRD January, 2001 +** +** module name: signal.c +** CVS $Id: signal.c,v 1.2 2001/01/11 04:07:56 zhangsz Exp $ +** +** Signal functions +** +*/ + +#include "./include/iptrans.h" + +/* +** Set termination signal in a loop program, +** handler of function mostly deal with something, +** e.g. closing file handler, socket handler or free allocatied memory. +*/ +/*@ignore@*/ +void +SetTermSignal(struct termio *ptermio, void (*handler)(int)) +{ + ioctl(0, TCGETA, ptermio); + ptermio->c_cc[VINTR] = '\x03'; + ioctl(0, TCSETA, ptermio); + + signal(SIGINT, handler); + signal(SIGTERM, handler); +} +/*@end@*/ diff --git a/omc/plat/iptrans/src/simu_debug.c b/omc/plat/iptrans/src/simu_debug.c new file mode 100644 index 0000000..6dc082e --- /dev/null +++ b/omc/plat/iptrans/src/simu_debug.c @@ -0,0 +1,21 @@ +#include +#include +#include + +/*@ignore@*/ +int main() +{ + debug_init(); + init_iptrans(); + snmp_init(4957); +// heartbeat_init(0); + while(1) + { + debug_rt(); + snmp_timer(); + // heartbeat_timer(); + usleep(1); + } + return 1; +} +/*@end@*/ diff --git a/omc/plat/isdn/.copyarea.db b/omc/plat/isdn/.copyarea.db new file mode 100644 index 0000000..656fa72 --- /dev/null +++ b/omc/plat/isdn/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn +2 +5 +3:doc|2|0|0|0|7014726b6cf311dd91c7001c23e19543|0 +2:ut|2|0|0|0|715472936cf311dd91c7001c23e19543|0 +3:src|2|0|0|0|70b4727f6cf311dd91c7001c23e19543|0 +8:Makefile|1|11d70a47c2c|b31|b248c01f|f04486166cf311dd91a5001c23e19543|0 +3:lib|2|0|0|0|c2f385b6339611dd80a0001c23e19543|0 diff --git a/omc/plat/isdn/Makefile b/omc/plat/isdn/Makefile new file mode 100644 index 0000000..41bc709 --- /dev/null +++ b/omc/plat/isdn/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for module template : V1.6.3 ## +## ## +## Created : Wei Liu 07/04/11 ## +## Revision: [Last]Wei Liu 07/07/07 ## +## ## +##----------------------------------------------------------## + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +## MODULE= [Module Name] +## TYPE = app/plat => Module Type + +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ] +## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release] + +## BUILD = lib/exef => Output file format +## CFG = debug/release => Build Configuration + +## SRC_PATH = [Source file path] +## INC_PATH = [Include file path] +## APP_PATH = [App Module path] +## PLT_PATH = [Plat Module path] + +## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main +## APP_LIB = [Needed app lib for Link] => just for test or wxc2main +## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main + +## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \ +## 8ecp bicc smpp xapp tcap mtp3 m2ua \ +## snmp iptrans debug sccp public +## +## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas +## LIB_ADD e.g. = -liba3a8 -lm + +## OBJ_ADD = [Extend third party object files needed] +## TEST_OBJ_PATH = [module object files Path for test ] => just for test +##---------------------------------------------------------------------## + +MODULE = isdn +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/isdn/doc/.copyarea.db b/omc/plat/isdn/doc/.copyarea.db new file mode 100644 index 0000000..99b2e7d --- /dev/null +++ b/omc/plat/isdn/doc/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn\doc +2 +1 +11:D-500014-0-10.doc|1|11d70a47f58|14d200|803a9bd5|fb948a666cf311dd91a5001c23e19543|0 diff --git a/omc/plat/isdn/doc/D-500014-0-10.doc b/omc/plat/isdn/doc/D-500014-0-10.doc new file mode 100644 index 0000000..9973973 Binary files /dev/null and b/omc/plat/isdn/doc/D-500014-0-10.doc differ diff --git a/omc/plat/isdn/lib/libisdn.a b/omc/plat/isdn/lib/libisdn.a new file mode 100644 index 0000000..87e1441 Binary files /dev/null and b/omc/plat/isdn/lib/libisdn.a differ diff --git a/omc/plat/isdn/obj/isdn_debug.o b/omc/plat/isdn/obj/isdn_debug.o new file mode 100644 index 0000000..fb24694 Binary files /dev/null and b/omc/plat/isdn/obj/isdn_debug.o differ diff --git a/omc/plat/isdn/obj/isdn_fsm.o b/omc/plat/isdn/obj/isdn_fsm.o new file mode 100644 index 0000000..fdded68 Binary files /dev/null and b/omc/plat/isdn/obj/isdn_fsm.o differ diff --git a/omc/plat/isdn/obj/isdn_ie.o b/omc/plat/isdn/obj/isdn_ie.o new file mode 100644 index 0000000..4c12df2 Binary files /dev/null and b/omc/plat/isdn/obj/isdn_ie.o differ diff --git a/omc/plat/isdn/obj/isdn_msg.o b/omc/plat/isdn/obj/isdn_msg.o new file mode 100644 index 0000000..426d9d0 Binary files /dev/null and b/omc/plat/isdn/obj/isdn_msg.o differ diff --git a/omc/plat/isdn/obj/isdn_rm.o b/omc/plat/isdn/obj/isdn_rm.o new file mode 100644 index 0000000..1415706 Binary files /dev/null and b/omc/plat/isdn/obj/isdn_rm.o differ diff --git a/omc/plat/isdn/obj/isdn_uif.o b/omc/plat/isdn/obj/isdn_uif.o new file mode 100644 index 0000000..e75cf9d Binary files /dev/null and b/omc/plat/isdn/obj/isdn_uif.o differ diff --git a/omc/plat/isdn/src/.copyarea.db b/omc/plat/isdn/src/.copyarea.db new file mode 100644 index 0000000..2b7d5de --- /dev/null +++ b/omc/plat/isdn/src/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn\src +2 +8 +a:isdn_msg.c|1|11d70a4812c|15495|d5960b7|198230587faf11dd8601001c23e19543|0 +c:isdn_debug.c|1|11d70a48071|82b4|7e0a05de|5a7649929a8611dd8b36001c23e19543|0 +9:isdn_rm.c|1|11d70a4815b|3c8b|80917848|1a1230707faf11dd8601001c23e19543|0 +a:isdn_fsm.c|1|11d70a480af|141ee|fc89331e|b79480e9a3cb11dd8e69001c23e19543|0 +7:include|2|0|0|0|71e472a76cf311dd91c7001c23e19543|0 +a:isdn_uif.c|1|11d70a4818a|40ce|b90eb9a0|f20486a66cf311dd91a5001c23e19543|0 +8:Makefile|1|11d70a48013|32f|573eea1a|f2a486be6cf311dd91a5001c23e19543|0 +9:isdn_ie.c|1|11d70a480de|9b7a|b4e1c4e1|198230407faf11dd8601001c23e19543|0 diff --git a/omc/plat/isdn/src/Makefile b/omc/plat/isdn/src/Makefile new file mode 100644 index 0000000..ae09f91 --- /dev/null +++ b/omc/plat/isdn/src/Makefile @@ -0,0 +1,35 @@ +#Create by Chen Gengxin +#2008-03-03 +#WXC2 R9.0 ISDN makefile + +CC = gcc +CFLAG = -g -Wall -c #-fprofile-arcs -ftest-coverage + +ISDN_LIB_OBJ = isdn_msg.o isdn_fsm.o isdn_uif.o isdn_rm.o isdn_ie.o isdn_debug.o + +all: $(ISDN_LIB_OBJ) +# ar -r libfsm.a $(ISDN_LIB_OBJ) + +#test_sdl: $(ISDN_LIB_OBJ) +# $(cc) -o $@ $< ../kernel/sched.o +isdn_msg.o: isdn_msg.c ./include/isdn_msg.h ./include/isdn_ext.h ./include/isdn_const.h + $(CC) $(CFLAG) $< + +isdn_fsm.o: isdn_fsm.c + $(CC) $(CFLAG) $< + +isdn_uif.o: isdn_uif.c ./include/isdn_if.h + $(CC) $(CFLAG) $< + +isdn_rm.o: isdn_rm.c ./include/isdn_rm.h + $(CC) $(CFLAG) $< + +isdn_ie.o: isdn_ie.c ./include/isdn_ie.h + $(CC) $(CFLAG) $< + +isdn_debug.o: isdn_debug.c + $(CC) $(CFLAG) $< + +clean: + rm -f main *.o *.a *.xml *.gcov *.gcda *.gcno test_sdl core + diff --git a/omc/plat/isdn/src/include/.copyarea.db b/omc/plat/isdn/src/include/.copyarea.db new file mode 100644 index 0000000..a01bbf7 --- /dev/null +++ b/omc/plat/isdn/src/include/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn\src\include +2 +9 +9:isdn_ie.h|1|11d70a482b3|3a8f|91b37b51|1a1230887faf11dd8601001c23e19543|0 +c:isdn_debug.h|1|11d70a48245|738|b005fcf9|f2a486ee6cf311dd91a5001c23e19543|0 +c:isdn_const.h|1|11d70a48216|2634|d6a2e7c4|f2a486d66cf311dd91a5001c23e19543|0 +d:isdn_public.h|1|11d70a4837e|3c8|5a81eac|f474877e6cf311dd91a5001c23e19543|0 +a:isdn_inc.h|1|11d70a48310|38c|2455f480|f3d4874e6cf311dd91a5001c23e19543|0 +a:isdn_ext.h|1|11d70a48284|4d6|23607792|f34487066cf311dd91a5001c23e19543|0 +9:isdn_if.h|1|11d70a482e1|165d|31bc6c0e|f34487366cf311dd91a5001c23e19543|0 +a:isdn_msg.h|1|11d70a4834f|1e66|d2e1b4da|f3d487666cf311dd91a5001c23e19543|0 +9:isdn_rm.h|1|11d70a483ad|eaf|6da83cb0|f47487966cf311dd91a5001c23e19543|0 diff --git a/omc/plat/isdn/src/include/isdn_const.h b/omc/plat/isdn/src/include/isdn_const.h new file mode 100644 index 0000000..d5b91db --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_const.h @@ -0,0 +1,275 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_const.h +Description: ISDN const define +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-24 +History: + + +************************************************************/ + +#ifndef _ISDN_CONST_H +#define _ISDN_CONST_H + +//#define PROTO_ISDN 3 + +//user - network interface +#define NETWORK_SIDE 0 +#define USER_SIDE 1 + +#define ISDN_IP_PORT 4958 //4951 4953 + +//NFAS +#define NFAS_DISABLE 0x00 +#define NFAS_ENABLE 0x01 + +//priority +#define REATTEMPT 0x00 +#define DISCARD 0x01 + +//run_mode +#define ISDN_SINGLE_MODE 0x00 /* Single Plat */ +#define ISDN_DUAL_MODE 0x01 /* Dual Plat */ + +//call state +#define IDLE_FLAG 0x00 +#define CALLIN_FLAG 0x01 +#define CALLOUT_FLAG 0x02 +//timer_flag +#define DC_M_FLAG 0x04 +#define BC_M_FLAG 0x08 + +//ansi isdn maintenance state +//D-channel state +#define DS_MOOS 0x00 //In Service +#define DS_IS 0x01 //Maintenance Busy +#define DS_OOS 0x02 //Out Of Service +#define DS_STBY 0x04 //Standby +#define DS_WAIT 0x08 //Wait +#define DS_MB 0x10 //Manual Out Of Service +#define DS_INB 0x12 //Installation Busy +//B-channel state +#define IN_SERVICE 0x00 +#define MAINTENANCE_SERVICE 0x01 +#define OUT_OF_SERVICE 0x02 +//iua link state +#define LK_OOS 0x00 +#define LK_IS 0x01 + +/************************************************************ +ISDN message type +************************************************************/ +#define PROTOCOL_ISDN_LINK_MNG 0xFE +#define PROTOCOL_DISCR 0x08 //Q.931 Protocol discriminator +//Call establishment message +#define MSG_ALERT 0x01 //Alerting +#define MSG_CALL_PROC 0x02 //Call Proceeding +#define MSG_CONN 0x07 //Connect +#define MSG_CONNACK 0x0F //Connect Acknowledge +#define MSG_PROG 0x03 //Progress +#define MSG_SETUP 0x05 //Setup +#define MSG_SETUP_ACK 0x0D //Setup Acknowledge +//Call clearing message +#define MSG_DISC 0x45 //Disconnect +#define MSG_REL 0x4D //Release +#define MSG_REL_COMP 0x5A //Release Complete +#define MSG_RESTART 0x46 //Restart +#define MSG_REST_ACK 0x4E //Restart Acknowledge +//Miscellaneous message +#define MSG_INFORMATION 0x7B //Information +#define MSG_NOTI 0x6E //Notify +#define MSG_STATUS 0x7D //Status +#define MSG_STAT_ENQ 0x75 //Status Enquiry +#define MSG_FAC 0x62 //Facility (connectionless) + +//Maintenance message +#define M_PROTOCOL_DISCR 0x43 //Maintenance messages Protocol discriminator +#define MSG_SERVICE 0x0F //Service +#define MSG_SERVICE_ACK 0x07 //Service Acknowledge + + +/************************************************************ +ISDN information element identifier coding +************************************************************/ +//Single octet information elements +#define IE_SHIFT 0x01 //Shift +#define IE_MORE_DATA 0xA0 //More data +#define IE_SD_COMP 0xA1 //Send Complete +#define IE_RPT_IND 0xD2 //Repeat indicator +//Variable length information element +#define IE_BR_CAP 0x04 //Bearer capability +#define IE_CAUSE 0x08 //Cause +#define IE_CALL_ID 0x10 //Call identifier +#define IE_CALL_STAT 0x14 //Call state +#define IE_CHNL_ID 0x18 //Channel identification +#define IE_PRG_IND 0x1E //Progress indicator +#define IE_NT_SP_FAC 0x20 //Network-specific facilities +#define IE_NOTIFY_IND 0x27 //Notification indicator +#define IE_DISP 0x28 //Display +#define IE_DT_TIME 0x29 //Date/time +#define IE_KPD_FAC 0x2C //Keypad facility +#define IE_SIGN 0x34 //Signal +#define IE_CG_PTY_NUM 0x6C //Calling party number +#define IE_CG_PTY_ADDR 0x6D //Calling party subaddress +#define IE_CD_PTY_NUM 0x70 //Called party number +#define IE_CD_PTY_ADDR 0x71 //Called party subaddress +#define IE_TRAN_NT_SEL 0x78 //Transit network selection +#define IE_RESTART_IND 0x79 //Restart indicator +#define IE_LL_COMP 0x7C //Low layer compatibility +#define IE_HL_COMP 0x7D //High layer compatibility +#define IE_USR_USR 0x7E //User-user +//ansi +#define IE_CHG_STAT 0x01 //Change status +#define IE_FAC 0x1C //Facility +//#define IE_INFO_REQ 0x32 //Information request +//#define IE_ORG_CG_NUM 0x73 //Original called number +#define IE_REDIR_NUM 0x74 //Redirection number +//QSIG +#define IE_CONN_NUM 0x4C //Connected number +//Codeset 6 information element identifiers TO-DO + + +/************************************************************ +ISDN states exist in the user-network interface +************************************************************/ +#define NULL_STATE 0x00 +#define CALL_INIT_STATE 0x01 +#define OVERLAP_SD_STATE 0x02 +#define OUT_CALL_PROC_STATE 0x03 +#define CALL_DV_STATE 0x04 +#define CALL_PRE_STATE 0x06 +#define CALL_RV_STATE 0x07 +#define CONN_REQ_STATE 0x08 +#define IN_CALL_PROC_STATE 0x09 +#define ACTIVE_STATE 0x0A +#define DISC_REQ_STATE 0x0B +#define DISC_IND_STATE 0x0C +#define REL_REQ_STATE 0x13 +#define OVERLAP_RV_STATE 0x19 + +#define GLOBAL_NULL_STATE 0x00 +#define GLOBAL_RESTART_REQ_STATE 0x3D +#define GLOBAL_RESTART_STATE 0x3E +//ansi +#define SERVICE_IDLE 0x00 +#define WAIT_SERVICE_ACK 0x01 +#define RSP_SERVICE 0x02 + + + + +/************************************************************ +ISDN Event/Primitive Definition +************************************************************/ +//Primitive +#define ISDN_SETUP_REQ 0x11 +#define ISDN_SETUP_IND 0x21 +#define ISDN_SETUP_RSP 0x31 +#define ISDN_SETUP_CNF 0x41 + +#define ISDN_DISCONNECT_REQ 0x12 +#define ISDN_DISCONNECT_IND 0x22 +#define ISDN_RELEASE_REQ 0x32 +#define ISDN_RELEASE_IND 0x42 +#define ISDN_RELEASE_CNF 0x52 +#define ISDN_REJECT_REQ 0x62 + +#define ISDN_ALERT_REQ 0x13 +#define ISDN_ALERT_IND 0x23 +#define ISDN_INFO_REQ 0x33 +#define ISDN_INFO_IND 0x43 +#define ISDN_PROG_REQ 0x53 +#define ISDN_PROG_IND 0x63 +#define ISDN_SUSPEND_REQ 0x73 +#define ISDN_SUSPEND_IND 0x83 +#define ISDN_RESUME_REQ 0x93 +#define ISDN_RESUME_IND 0xa3 + +#define ISDN_PROC_REQ 0x14 +#define ISDN_PROC_IND 0x24 +#define ISDN_MORE_INFO_REQ 0x34 +#define ISDN_MORE_INFO_IND 0x44 +#define ISDN_NOTI_REQ 0x54 +#define ISDN_NOTI_IND 0x64 +#define ISDN_STAT_IND 0x74 +#define ISDN_SETUP_COMP_REQ 0x84 +#define ISDN_SETUP_COMP_IND 0x84 + +#define ISDN_TIMEOUT_IND 0x15 +#define ISDN_RESTART_REQ 0x25 +#define ISDN_M_RESTART_REQ 0x35 +#define ISDN_RESTART_CNF 0x45 +#define ISDN_REATTEMPT_IND 0x55 +//ansi +#define ISDN_SERVICE_REQ 0x16 +#define ISDN_SERVICE_IND 0x26 +#define ISDN_SERVICE_CNF 0x36 +#define ISDN_SERVICE_RSP 0x46 +#define ISDN_SER_TIMEOUT_IND 0x56 + + + +/************************************************************ +ISDN Cause Definition +************************************************************/ +#define CAUSE_UNASSIGNED 0x01 //unassigned (unallocated) number +#define CAUSE_NOROUTE_NET 0x02 //no route to specified transit network +#define CAUSE_NOROUTE_DES 0x03 //no route to destination +#define CAUSE_NORMAL 0x10 //normal call clearing +#define CAUSE_INVALID_NUM 0x1C //invalid number format(imcomplete number) +#define CAUSE_STAT_ENQ 0x1E //response to status enquiry +#define CAUSE_TEMP_FAIL 0X29 //temporary failure +#define CAUSE_INVALID_CR 0x51 //invalid call reference value +#define CAUSE_CALLID_INUSE 0x54 //call identity in use +#define CAUSE_M_IE_MISS 0x60 //mandatory information element is missing +#define CAUSE_MSG_NONEXI 0x61 //message type non-existent or not implemented +#define CAUSE_MSG_NOTCOMP_NOTIMPL 0x62 //message not compatible with call state or message type non-existent or not implemented +#define CAUSE_IE_NONEXI 0x63 //information element non-existent or not implemented +#define CAUSE_IE_INVALID 0x64 //invalid information element contents +#define CAUSE_MSG_NOTCOMP 0x65 //message not compatible with call state +#define CAUSE_TIMER_EXPIRY 0x66 //recovery on timer expiry + + +/************************************************************ +ISDN Timer Definition (Time Unit = 1s) +************************************************************/ +#define ISDN_T301 180 /* 180S */ +#define ISDN_T302 15 /* 15S */ +#define ISDN_T303 4 /* 4S */ +#define ISDN_T304 20 /* 20S */ +#define ISDN_T305 30 /* 30S */ +#define ISDN_T306 30 /* 30S */ +#define ISDN_T307 180 /* 180S */ +#define ISDN_T308 4 /* 4S */ +#define ISDN_T309 6 /* 6S*/ +#define ISDN_T310 10 /* 10S */ +#define ISDN_T312 6 /*T303+2S*/ +#define ISDN_T313 4 /* 4S */ +#define ISDN_T316 120 /* 120S */ +#define ISDN_T317 10 /* + +************************************************************/ +#ifndef _ISDN_DEBUG_H +#define _ISDN_DEBUG_H + +#include "isdn_rm.h" +#include "../../../pal/pal.h" +//#include "../../../debug/src/include/debug.h" + +/*Color Set */ +#define COL_WHITE 37 +#define COL_RED 31 +#define COL_YELLOW 33 +#define COL_GREEN 32 +#define COL_BLUE 34 +#define COL_BROWN 35 +#define COL_MEGEN 36 +#define COL_GRAY 38 +#define COL_HI_WHI 58 +#define COL_HI_RED 39 +#define COL_HI_YEL 52 +#define COL_HI_GRE 51 +#define COL_HI_BLU 53 +#define COL_HI_BRO 54 +#define COL_HI_MEG 55 +#define COL_BLACK 30 + +#define COL_ESC '\033' + +typedef struct _isdn_msg_csta //call statistics +{ + //receive and send + u32 rv_setup; + u32 sd_setup; + u32 rv_setupAck; + u32 sd_setupAck; + u32 rv_callProc; + u32 sd_callProc; + u32 rv_alert; + u32 sd_alert; + u32 rv_conn; + u32 sd_conn; + u32 rv_connAck; + u32 sd_connAck; + u32 rv_disc; + u32 sd_disc; + u32 rv_rel; + u32 sd_rel; + u32 rv_relComp; + u32 sd_relComp; + //redirect + u32 rd_setup; + u32 rd_setupAck; + u32 rd_callProc; + u32 rd_alert; + u32 rd_conn; + u32 rd_connAck; + u32 rd_disc; + u32 rd_rel; + u32 rd_relComp; +}ISDN_Msg_Csta; + + +int isdn_debug_init(void); +void isdn_debug_timer(void); +void isdn_log_err(u32 pid,const char *fmt, ...); +void isdn_trace_func(u32 pid,const char *fmt, ...); +void monitor_isdn_msg(u32 pid,u8 *head,IuaMsgStr *msg,u8 col); +void monitor_isdn_port(u32 call_ref,u32 port); +void isdn_msg_csta(u8 msgtype,u8 flag); + +#endif diff --git a/omc/plat/isdn/src/include/isdn_ext.h b/omc/plat/isdn/src/include/isdn_ext.h new file mode 100644 index 0000000..2cf6657 --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_ext.h @@ -0,0 +1,33 @@ +/*********************************************************** +File Name: isdn_ext.h +Description: Public variant definition of ISDN module +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-28 +************************************************************/ +#ifndef _ISDN_EXT_H +#define _ISDN_EXT_H + +#include "isdn_if.h" + +/************************************************************ +ISDN +************************************************************/ + + +IsdnMsgStr isdn_sd_msg, isdn_rv_msg; + +extern int isdn_init(u8 systemID, u32 interval_ms); +extern void isdn_timer(); +/*extern int isdn_bind_sap(ISDN_Sap_Attrib_ *attrib_p); +extern int isdn_modify_sap(u8 sap_id, ISDN_Sap_Attrib_ *attrib_ptr); +extern int isdn_unbind_sap(u8 sap_id); +extern int isdn_add_cg(u8 sap_id, Cg_Attrib_struct *attrib_ptr); +extern int isdn_modify_cg(u16 cg_id, Cg_Attrib_struct *attrib_ptr); +extern int isdn_remove_cg(u16 cg_id); +extern int isdn_add_circuit(u16 cg_id, Circuit_Attrib_struct *attrib_ptr); +extern int isdn_modify_circuit(u16 cg_id, u16 circuit_id, Circuit_Attrib_struct *attrib_ptr); +extern int isdn_remove_circuit(u16 cg_id, u16 circuit_id);*/ +extern int isdn_set_run_mode (u8 run_mode, u32 alter_ip); + +#endif diff --git a/omc/plat/isdn/src/include/isdn_ie.h b/omc/plat/isdn/src/include/isdn_ie.h new file mode 100644 index 0000000..0b0d95b --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_ie.h @@ -0,0 +1,491 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_ie.h +Description: ISDN information elements structure +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-17 +Remark: M:mandatory, O:optional +History: + + +************************************************************/ +#ifndef _ISDN_IE_H +#define _ISDN_IE_H + +#include "isdn_public.h" + + +/************************************************************ +ISDN information elements structure +************************************************************/ + +typedef struct _brCap_b4 //Bearer capability octets 4 +{ + u8 tran_mode; //Transfer mode M + u8 tran_rate; //Information transfer rate M + u8 rate_mul; //Rate multiplier O +}brCap_b4; +typedef struct _brCap_b5 //Bearer capability octets 5 +{ + u8 usr_layer1; //User information layer 1 protocol + u8 has_ext_a; // + u8 syn_asy; //Synch/asynch (0/1) + u8 neg; //Negot + u8 usr_rate; //User rate + u8 has_ext_b; // + u8 inter_rate; //Intermediate rate + u8 nic_tx; //NIC on Tx + u8 nic_rx; //NIC on Rx + u8 ctl_tx; //Flow control on Tx + u8 ctl_rx; //Flow control on Rx +// u8 ext_b; // + u8 hdr; //Hdr/no Hdr + u8 mul_fra; //Multiframe; + u8 mode; //Mode + u8 lli_neg; //LLI negot. + u8 assign; //Assignor/ee + u8 inband; //In-band neg. + u8 has_ext_c; // + u8 stop_bit; //Number of stop bits + u8 data_bit; //Number of data bits + u8 par; //Parity + u8 has_ext_d; + u8 du_mode; //Duplex Mode + u8 mod_type; //Modem type +}brCap_b5; +typedef struct _brCap_b7 //Bearer capability octets 7 +{ + u8 usr_layer3; //User information layer 3 protocol + u8 has_ext_a; // + u8 layer3_a; //Additional layer 3 protocol information (most significant bits) + u8 has_ext_b; // + u8 layer3_b; //Additional layer 3 protocol information (most significant bits) +}brCap_b7; +typedef struct _brCap //Bearer capability +{/*可能得把每个可选八比特放到一个结构体中,而一个八比特组需要在另外的地方处理成一个数组*/ + u8 pres; //element header + u32 ext_flag; //extension domain flag M + u8 code_stan; //Coding standard (00) M + u8 tran_cap; //Information transfer capability M + brCap_b4 b4; //octets 4 + brCap_b5 b5; //octets 5 group + u8 usr_layer2; //User information layer 2 protocol + u8 usr_layer3; //User information layer 3 protocol +// brCap_b7 b7; //octets 7 +}BrCap; + +typedef struct _callId //Call identity +{ + u8 pres; //element header + u8 call_id_len; + u8 call_id[8]; //Call identity(IA5) +}CallId; + +typedef struct _callStat //Call state +{ + u8 pres; //element header + u8 code_stan; //Coding standard + u8 stat_val; //Call state value/global interface state value(state value is coded in binary) +}CallStat; + +typedef struct _cdPtyNum //Called party number +{ + u8 pres; //element header + u8 num_type; //Type of number + u8 num_plan_id; //Numbering plan identification + u8 num_digit_len; + u8 num_digit[32]; //Number digits(IA5) +}CdPtyNum; + +typedef struct _cdPtyAddr //Called party subaddress +{ + u8 pres; //element header + u8 addr_type; //Type of subaddress + u8 odd_even; //Odd/even indicator + u8 addr_info_len; + u8 addr_info[20]; //Subaddress information +}CdPtyAddr; + +typedef struct _cgPtyNum_b3 +{ + u8 num_type; //Type of number + u8 num_plan_id; //Numbering plan identification + u8 has_ext_a; // + u8 pres_ind; //Presentation indicator + u8 screen_ind; //Screening indicator +}cgPtyNum_b3; +typedef struct _cgPtyNum //Calling party number +{ + u8 pres; //element header + u32 ext_flag; //extension domain flag M + cgPtyNum_b3 b3; + u8 num_digit_len; + u8 num_digit[32]; //Number digits(IA5) +}CgPtyNum, ConnNum; + +typedef struct _cgPtyAddr //Calling party subaddress +{ + u8 pres; //element header + u8 addr_type; //Type of subaddress + u8 odd_even; //Odd/even indicator + u8 addr_info_len; + u8 addr_info[20]; //subaddress information +}CgPtyAddr; + +typedef struct _cause_b3 +{ + u8 code_stan; //Coding standard + u8 loc; //Location + u8 has_ext_a; // + u8 rec; //Recommendation +}cause_b3; +typedef struct _cause_b5 //diagnostic +{ + u8 attrib_num; //attribute number +// u8 has_ext_a; + u8 rej_attrib; //rejected attribute + u8 has_ext_b; + u8 avail_attrib; //available attribute + //Call rejected diagnostic for cause number 21 TODO +}cause_b5; +typedef struct _causeStr //Cause +{ + u8 pres; //element header + u32 ext_flag; // + cause_b3 b3; //octet 3 + u8 cause_val; //Cause value + u8 dia_num; + cause_b5 dia[8]; //diagnostic +}CauseStr; + +typedef struct _chnlId_b3 //Channel identification octets 3 +{ + u8 int_id_pre; //Interface identifier present M + u8 int_type; //Interface type M + u8 pref_excl; //Preferable/Exclusive M + u8 chnl_ind; //D-channel indicator M + u8 info_chnl_sel; //Infomation channel selection M + + u8 int_id; //Interface identifier; + + u8 has_chnl; // 1:wiith 3.2 and 3.3, 0:without 3.2 nor 3.3 + u8 code_stan; //Coding standard + u8 num_map; //Number/Map + u8 chnl_type; //Channel type/Map element type + u8 chnl_num; //Channel number/Slot map ect +}chnlId_b3; +typedef struct _chnlId //Channel identification +{ + u8 pres; //element header + chnlId_b3 b3; //octets 3 +}ChnlId; + +typedef struct _conLev //Congestion level +{ + u8 pres; //element header + u8 con_lev; //Congestion level +}ConLev; + +typedef struct _dtTime //Date/time +{ + u8 pres; //element header + u8 ext_flag; + u8 year; + u8 month; + u8 day; //M + u8 hour; //O + u8 minute; // O + u8 second; //O +}DtTime; + +typedef struct _disp //Display +{ + u8 pres; //element header + u8 disp_info_len; + u8 disp_info[18]; //Display information(IA5) + + //ansi + u8 asso_info; //Associated information + u8 disp_type; //display type +}Disp; + +typedef struct _hLComp_b4 //High layer compatibility octets 4 +{ + u8 hl_ch_id; //High layer characteristies identification + u8 ex_hl_ch_id; //Extended high layer characteristics identification + u8 ex_vid_ch_id; //EXtended videotelephony characteristics identification +}hLComp_b4; +typedef struct _hLComp //High layer compatibility +{ + u8 pres; //element header + u8 code_stan; //Coding standard + u8 intpr; //Interpretation + u8 pre_meth; //Presentation method of protocol profile + hLComp_b4 b4; //octets 4 +}HLComp; + +typedef struct _kpdFac //Keypad facility +{ + u8 pres; //element header + u8 keyfac_info_len; + u8 key_fac_info[32];//Keypad facility information(IA5) +}KpdFac; + +typedef struct _lLComp_b3 //Low layer compatibility octets 3 +{ + u8 code_stan; //Coding standard M + u8 tran_cap; //Information transfer capability M + u8 has_ext_a; + u8 neg_ind; //Negot indicator O +}lLComp_b3; +typedef struct _lLComp_b4 //Low layer compatibility octets 4 +{ + u8 tran_mode; //Transfer mode + u8 tran_rate; //Information transfer rate + u8 rate_mul; //Rate multiplier +}lLComp_b4; +typedef struct _lLComp_b5 //Low layer compatibility octets 5 +{ + u8 layer1_id; //Layer 1 identifier + u8 usr_layer1; //User information layer 1 protocol + u8 has_ext_a; // + u8 syn_asy; //Synch./asynch. + u8 neg; //Negot. + u8 usr_rate; //User Rate + u8 has_ext_b; // + u8 inter_rate; //intermediate rate + u8 nic_tx; //NIC on Tx + u8 nic_rx; //NIC on Rx + u8 ctl_tx; //Flow control on Tx + u8 ctl_rx; //Flow control on Rx +// u8 ext_b; // + u8 hdr; //Hdr/no Hdr + u8 mul_fra; //Multiframe; + u8 mode; //Mode + u8 lli_neg; //LLI negot. + u8 assign; //Assignor/ee + u8 inband; //In-band negot. + u8 has_ext_c; // + u8 stop_bit; //Number of stop bits + u8 data_bit; //Number of data bits + u8 par; //Parity + u8 has_ext_d; + u8 du_mode; //Duplex Mode + u8 mod_type; //Modem type +}lLComp_b5; +typedef struct _lLComp_b6 //Low layer compatibility octets 6 +{ + u8 layer2_id; //layer 2 identifier + u8 usr_layer2; //User information layer 2 protocol + u8 mode; //Mode + u8 q933_use; //Q.933 use + u8 usr_layer2_info; //User specification layer 2 protocol information + u8 win_size; //Window size(k) +}lLComp_b6; +typedef struct _lLComp_b7 //Low layer compatibility octets 7 +{ + u8 layer3_id; //layer 3 identifier + u8 usr_layer3; //User information layer 3 protocol + + u8 usr_layer3_info; //Optional layer 3 protocol information + u8 mode; //Mode + u8 def_pac_size; //Default packet size + u8 pac_win_size; //Packet window size + u8 layer3_a; //Additional layer 3 protocol information (most significant bits) + u8 layer3_b; //Additional layer 3 protocol information (most significant bits) +}lLComp_b7; +typedef struct _lLComp //Low layer compatibility +{ + u8 pres; //element header + u32 ext_flag; + lLComp_b3 b3; //octets 3 M + lLComp_b4 b4; //octets 4 O + lLComp_b5 b5; //octets 5 + lLComp_b6 b6; //octets 6 + lLComp_b7 b7; //octets 7 + + //ansi TODO +}LLComp; + +typedef struct _ntSpFac_b3 //Network-specific facilities octets 3 +{ + u8 len_net_id; //Length of network identification M //不为0则含有下面两个比特组 + u8 net_id_type; //Type of network identification O + u8 net_id_plan; //Network identification plan + u8 net_id; //Network identification(IA5) ect +}ntSpFac_b3; +typedef struct _ntSpFac //Network-specific facilities +{ + u8 pres; //element header + ntSpFac_b3 b3; //octets 3 M + + u8 spec; //Network-specific facility specification M + //ansi + u8 fac_val; //Facility coding value + u8 ser_par; //Service parameters +}NtSpFac; + +typedef struct _notifyInd //Notification indicator +{ + u8 pres; //element header + u8 notify_descr; //Notification description + //ansi TODO +}NotifyInd; + +typedef struct _prgInd //Progress indicator +{ + u8 pres; //element header + u8 code_stan; //Coding standard + u8 loc; //Location + u8 prg_descr; //Progress description +}PrgInd; + +typedef struct _rptInd //Repeat indicator +{ + u8 pres; //element header +// u8 rpt_ind; //Repeat indication +}RptInd; + +typedef struct _restartInd //Restart indicator +{ + u8 pres; //element header + u8 clas; //class +}RestartInd; + +typedef struct _segMsg //Segmented message +{ + u8 pres; //element header + u8 seg_ind; //First segment indicator + u8 other_num; //Number of segments remaining + u8 seg_type; //Segmented message type +}SegMsg; + +typedef struct _sdComp //Sending complete +{ + u8 pres; //element header +// u8 sd_comp; //sending complete 常量 +}SdComp; + +typedef struct _sign //Signal +{ + u8 pres; //element header + u8 sign_val; //Signal value +}Sign; + +typedef struct _tranNtSel //Transit network selection +{ + u8 pres; //element header + u8 net_id_type; //Type of network identification + u8 net_id_plan; //Network identification plan + u8 net_id; //Network identification(IA5) ect +}TranNtSel; + +typedef struct _usrUsr //User-user +{ + u8 pres; //element header + u8 pro_discr; //Protocol discriminator + u8 usr_info_len; + u8 usr_info[258]; //User information +}UsrUsr; + + +//supplementary services ansi +typedef struct _fac //facility +{ + +}Fac; +/* the same to the CgPtyNum +typedef struct _connNum //connected number +{ +}ConnNum;*/ + +typedef struct _redirNum_b3 //redirection number octet 3 +{ + u8 num_type; //Type of number + u8 num_plan_id; //Numbering plan identification + + u8 org_num_stat; //Origin of number and presentation status + + u8 redir_rs; //Reason for redirection +}redirNum_b3; +typedef struct _redirNum //redirection number +{ + u8 pres; //element header + redirNum_b3 b3; //octet 3 + u8 num_digit_len; + u8 num_digit[32]; //Number digits(IA5) +}RedirNum; + +typedef struct _chgStat //change status +{ + u8 pres; //element header + u8 pref; //Preference + u8 new_stat; //New status +}ChgStat; + + +/************************************************************ +ISDN information elements functions interface +************************************************************/ +u8 itu_encode_br_cap(u8 *dst, BrCap *src); +int itu_decode_br_cap(BrCap *dst, u8 *src, u8 len); +u8 isdn_encode_br_cap(u8 *dst, BrCap *src); +int isdn_decode_br_cap(BrCap *dst, u8 *src, u8 len); +u8 isdn_encode_cause(u8 *dst, CauseStr *src); +int isdn_decode_cause(CauseStr *dst, u8 *src, u8 len); +u8 isdn_encode_call_id(u8 *dst, CallId *src); +int isdn_decode_call_id(CallId *dst, u8 *src, u8 len); +u8 isdn_encode_call_stat(u8 *dst, CallStat *src); +int isdn_decode_call_stat(CallStat *dst, u8 *src, u8 len); +u8 qsig_encode_chnl_id(u8 *dst, ChnlId *src); +int qsig_decode_chnl_id(ChnlId *dst, u8 *src, u8 len); +u8 isdn_encode_chnl_id(u8 *dst, ChnlId *src); +int isdn_decode_chnl_id(ChnlId *dst, u8 *src, u8 len); +u8 isdn_encode_prg_ind(u8 *dst, PrgInd *src); +int isdn_decode_prg_ind(PrgInd *dst, u8 *src, u8 len); +u8 ansi_encode_ntsp_fac(u8 *dst, NtSpFac *src); +int ansi_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len); +u8 isdn_encode_ntsp_fac(u8 *dst, NtSpFac *src); +int isdn_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len); +u8 ansi_encode_notify_ind(u8 *dst, NotifyInd *src); +int ansi_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len); +u8 isdn_encode_notify_ind(u8 *dst, NotifyInd *src); +int isdn_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len); +u8 isdn_encode_disp(u8 *dst, Disp *src); +int isdn_decode_disp(Disp *dst, u8 *src, u8 len); +u8 isdn_encode_dt_time(u8 *dst, DtTime *src); +int isdn_decode_dt_time(DtTime *dst, u8 *src, u8 len); +u8 isdn_encode_kpd_fac(u8 *dst, KpdFac *src); +int isdn_decode_kpd_fac(KpdFac *dst, u8 *src, u8 len); +u8 isdn_encode_sign(u8 *dst, Sign *src); +int isdn_decode_sign(Sign *dst, u8 *src, u8 len); +u8 isdn_encode_cg_num(u8 *dst, CgPtyNum *src); +int isdn_decode_cg_num(CgPtyNum *dst, u8 *src, u8 len); +u8 isdn_encode_cg_addr(u8 *dst, CgPtyAddr *src); +int isdn_decode_cg_addr(CgPtyAddr *dst, u8 *src, u8 len); +u8 isdn_encode_cd_num(u8 *dst, CdPtyNum *src); +int isdn_decode_cd_num(CdPtyNum *dst, u8 *src, u8 len); +u8 isdn_encode_cd_addr(u8 *dst, CdPtyAddr *src); +int isdn_decode_cd_addr(CdPtyAddr *dst, u8 *src, u8 len); +u8 isdn_encode_tran_sel(u8 *dst, TranNtSel *src); +int isdn_decode_tran_sel(TranNtSel *dst, u8 *src, u8 len); +u8 isdn_encode_restart_ind(u8 *dst, RestartInd *src); +int isdn_decode_restart_ind(RestartInd *dst, u8 *src, u8 len); +u8 isdn_encode_ll_comp(u8 *dst, LLComp *src); +int isdn_decode_ll_comp(LLComp *dst, u8 *src, u8 len); +u8 isdn_encode_hl_comp(u8 *dst, HLComp *src); +int isdn_decode_hl_comp(HLComp *dst, u8 *src, u8 len); +u8 isdn_encode_usr_usr(u8 *dst, UsrUsr *src); +int isdn_decode_usr_usr(UsrUsr *dst, u8 *src, u8 len); +//ansi +u8 ansi_encode_chg_stat(u8 *dst, ChgStat *src); +int ansi_decode_chg_stat(ChgStat *dst, u8 *src, u8 len); +u8 ansi_encode_redir_num(u8 *dst, RedirNum *src); +int ansi_decode_redir_num(RedirNum *dst, u8 *src, u8 len); +//QSIG +u8 qsig_encode_conn_num(u8 *dst, ConnNum *src); +int qsig_decode_conn_num(ConnNum *dst, u8 *src, u8 len); + + +#endif diff --git a/omc/plat/isdn/src/include/isdn_if.h b/omc/plat/isdn/src/include/isdn_if.h new file mode 100644 index 0000000..df37e5e --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_if.h @@ -0,0 +1,119 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_if.h +Description: ISDN interface declaration for wxc2main +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-17 +History: + + +************************************************************/ +#ifndef _ISDN_IF_H +#define _ISDN_IF_H + +#include "isdn_msg.h" +#include "isdn_inc.h" + + +/************************************************************ +ISDN Module parameter structure +************************************************************/ + +//Send to upper layer primitives, save data to structure +typedef int f_isdn_setup_ind(Pst *pst, IsdnSetup *ptr); //Setup indication +typedef int f_isdn_setup_cnf(Pst *pst, IsdnConn *ptr); //Setup confirm +typedef int f_isdn_proc_ind(Pst *pst, IsdnCallProc *ptr); //Proceeding indication +typedef int f_isdn_alert_ind(Pst *pst, IsdnAlert *ptr); //Alerting indication +typedef int f_isdn_disc_ind(Pst *pst, IsdnDisc *ptr); //Disconnect indication +typedef int f_isdn_rel_ind(Pst *pst, IsdnRel *ptr); //Release indication +typedef int f_isdn_rel_cnf(Pst *pst, IsdnRelComp *ptr); //Release confirm +typedef int f_isdn_rel_cnf_err(Pst *pst, IsdnRelComp *ptr); //Release confirm error +typedef int f_isdn_prog_ind(Pst *pst, IsdnProg *ptr); //Progress indication +typedef int f_isdn_info_ind(Pst *pst, IsdnInfo *ptr); //Info indication +typedef int f_isdn_minfo_ind(Pst *pst, IsdnSetupAck *ptr); //More info indication //IsdnSetupAck 或 IsdnInfo +typedef int f_isdn_noti_ind(Pst *pst, IsdnNoti *ptr); //Notify indication +typedef int f_isdn_stat_ind(Pst *pst, IsdnStatus *ptr); //Status indication +typedef int f_isdn_stat_ind_err(Pst *pst, IsdnStatus *ptr); //Status indication(error) +typedef int f_isdn_resu_ind(Pst *pst, IsdnResuRejReq *ptr); //Resume indication +typedef int f_isdn_rej_ind(Pst *pst, IsdnResuRejReq *ptr); //Reject indication +typedef int f_Isdn_susp_ind(Pst *pst, IsdnSusp *ptr); //Suspend indication +typedef int f_isdn_restart_req(Pst *pst, IsdnRestart *ptr); //Restart request +typedef int f_isdn_rest_cnf(Pst *pst, IsdnRestAck *ptr); //Restart confirm +typedef int f_isdn_timeout_ind(Pst *pst); //TIMEOUT +typedef int f_isdn_reattempt_ind(Pst *pst); //REATTEMPT +//ansi +typedef int f_isdn_service_ind(Pst *pst, IsdnService *ptr); //Service +typedef int f_isdn_service_cnf(Pst *pst, IsdnServAck *ptr); //Service Ack +typedef int f_isdn_ser_timeout_ind(Pst *pst); //Service TIMEOUT + +typedef struct _isdn_eventhandle_struct +{ + f_isdn_setup_ind *h_isdn_setup_ind; + f_isdn_setup_cnf *h_isdn_setup_cnf; + f_isdn_proc_ind *h_isdn_proc_ind; + f_isdn_alert_ind *h_isdn_alert_ind; + f_isdn_disc_ind *h_isdn_disc_ind; + f_isdn_rel_ind *h_isdn_rel_ind; + f_isdn_rel_cnf *h_isdn_rel_cnf; + f_isdn_rel_cnf_err *h_isdn_rel_cnf_err; + f_isdn_prog_ind *h_isdn_prog_ind; + f_isdn_info_ind *h_isdn_info_ind; + f_isdn_minfo_ind *h_isdn_minfo_ind; + f_isdn_noti_ind *h_isdn_noti_ind; + f_isdn_stat_ind *h_isdn_stat_ind; + f_isdn_stat_ind_err *h_isdn_stat_ind_err; + f_isdn_resu_ind *h_isdn_resu_ind; + f_isdn_rej_ind *h_isdn_rej_ind; +// f_isdn_susp_ind *h_isdn_susp_ind; + f_isdn_restart_req *h_isdn_restart_req; + f_isdn_rest_cnf *h_isdn_rest_cnf; + f_isdn_timeout_ind *h_isdn_timeout_ind; + f_isdn_reattempt_ind *h_isdn_reattempt_ind; + + //ansi + f_isdn_service_ind *h_isdn_service_ind; + f_isdn_service_cnf *h_isdn_service_cnf; + f_isdn_ser_timeout_ind *h_isdn_ser_timeout_ind; + +}ISDN_EventHandle_struct; + +typedef struct _isdn_sap_attrib_ +{ + ISDN_EventHandle_struct event_handle; +}ISDN_Sap_Attrib_; + + + +/************************************************************ +ISDN Module interface +************************************************************/ + +//Receive upper layer interface primitives +extern int isdn_setup_req(Pst *pst, IsdnSetup *ptr); //Setup request +extern int isdn_setup_resp(Pst *pst, IsdnConn *ptr); //Setup response +//extern int isdn_setup_comp_req(Pst *pst, IsdnConnAck *ptr); //Setup complete request +extern int isdn_call_proc_req(Pst *pst, IsdnCallProc *ptr); //Proceeding request +extern int isdn_alert_req(Pst *pst, IsdnAlert *ptr); //Alerting request +extern int isdn_disc_req(Pst *pst, IsdnDisc *ptr); //Disconnect request +extern int isdn_rel_req(Pst *pst, IsdnRel *ptr); //Release request +extern int isdn_rej_req(Pst *pst, IsdnRelComp *ptr); //Reject request +extern int isdn_prog_req(Pst *pst, IsdnProg *ptr); //Progress request +extern int isdn_info_req(Pst *pst, IsdnInfo *ptr); //Infomation request +extern int isdn_m_info_req(Pst *pst, IsdnSetupAck *ptr); //More Infomation request //IsdnSetupAck 或 IsdnInfo +extern int isdn_noti_req(Pst *pst, IsdnNoti *ptr); //Notify request +extern int isdn_rej_req(Pst *pst, IsdnRelComp *ptr); //Reject request +extern int isdn_resu_resp(Pst *pst, IsdnResuResp *ptr); //Resume response +extern int isdn_resu_rej_req(Pst *pst, IsdnResuRejReq *ptr); //Resume reject request +extern int isdn_susp_resp(Pst *pst, IsdnSusp *ptr); //Suspend response +extern int isdn_susp_rej_req(Pst *pst, IsdnSuspRejReq *ptr); //Suspend reject request +extern int isdn_restart_req(Pst *pst, IsdnRestart *ptr); //Restart request +extern int isdn_m_restart_req(Pst *pst, IsdnRestart *ptr); //Management restart request +extern int isdn_restart_cnf(Pst *pst, IsdnRestAck *ptr); //Restart confirm +extern int isdn_timeout(Pst *pst); //Time out +//ansi +extern int isdn_service_bc_req(Pst *pst, IsdnService *ptr); //maintenance B-channel SERVICE request +extern int isdn_service_bc_rsp(Pst *pst, IsdnServAck *ptr); //maintenance B-channel SERVICE response + + +#endif diff --git a/omc/plat/isdn/src/include/isdn_inc.h b/omc/plat/isdn/src/include/isdn_inc.h new file mode 100644 index 0000000..eb98034 --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_inc.h @@ -0,0 +1,27 @@ +/*********************************************************** +File Name: isdn_inc.h +Description: Public variant definition of ISDN module +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-28 +************************************************************/ +#ifndef _ISDN_INC_H +#define _ISDN_INC_H + +#include +#include "../../../public/src/include/license_id.h" +#include "../../../m2ua/src/include/m2ua.h" +//#include "../../../public/src/include/proto_pub.h" +#include "../../../iptrans/src/include/iptrans.h" +#include "../../../debug/src/include/debug.h" +#include "../../../pal/pal.h" +//#include "../../../../mss/msc/mng/param.h" + +/************************************************************ +ISDN +************************************************************/ + +extern int wxc2_get_license(int functionID); +extern int put_xua_msg(xua_up_msg_t *data_ptr); + +#endif diff --git a/omc/plat/isdn/src/include/isdn_msg.h b/omc/plat/isdn/src/include/isdn_msg.h new file mode 100644 index 0000000..52eec37 --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_msg.h @@ -0,0 +1,333 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_msg.h +Description: ISDN message structure or correlation +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-17 +Remark: M:mandatory, O:optional +History: + + +************************************************************/ +#ifndef _ISDN_MSG_H +#define _ISDN_MSG_H + +#include "isdn_const.h" +#include "isdn_ie.h" + + +/************************************************************ +ISDN mandatory information elements structure +************************************************************/ +typedef struct _msgMan //Message mandatory information elements +{ + u8 proto_Discr; //Protocol discriminator + u8 cr_len; //Length of call reference value(in octets) + u8 call_ref[2]; //Call reference value + u8 msg_type; //Message type +}MsgMan; + + +/************************************************************ +ISDN message structure +************************************************************/ + +typedef struct _isdnAlert //ALERTING +{ + ChnlId chnl_id; //Channel identification O/M + PrgInd prg_ind; //Progress indicator O + + BrCap br_cap; //Bearer capability O + Disp disp; //Display + Sign sign; //Signal + HLComp hl_comp; //High layer compatibility + + //ansi + Fac facility; //facility +}IsdnAlert; + +typedef struct _isdnCallProc //CALL PROCEEDING +{ + ChnlId chnl_id; //Channel identification O/M + + BrCap br_cap; //Bearer capability O + PrgInd prg_ind; //Progress indicator + Disp disp; //Display + HLComp hl_comp; //High layer compatibility +}IsdnCallProc; + +typedef struct _isdnConn //CONNECT +{ + ChnlId chnl_id; //Channel identification O/M + + BrCap br_cap; //Bearer capability O + PrgInd prg_ind; //Progress indicator + Disp disp; //Display + DtTime dt_time; //Date/time + Sign sign; //Signal + LLComp ll_comp; //Low layer compatibility + HLComp hl_comp; //High layer compatibility + //QSIG + ConnNum conn_num; //Connected number + //Connected subaddress +}IsdnConn; + +typedef struct _isdnConnAck //CONNECT ACKNOWLEDGE +{ + Disp disp; //Display O + Sign sign; //Signal +}IsdnConnAck; + +typedef struct _isdnDisc //DISCONNECT +{ + CauseStr cause; //Cause M + + PrgInd prg_ind; //Progress indicator O + Disp disp; //Display + Sign sign; //Signal +}IsdnDisc; + +typedef struct _isdnInfo //INFORMATION +{ + SdComp sd_comp; //Sending complete O + Disp disp; //Display + KpdFac kpd_fac; //Keypad facility + Sign sign; //Signal + CdPtyNum cd_pty_num; //Called party number +}IsdnInfo; + +typedef struct _isdnNoti //NOTIFY +{ + NotifyInd notify_ind; //Notification indicator M + Disp disp; //Display O + + BrCap br_cap; //Bearer capability O +}IsdnNoti; + +typedef struct _isdnProg //PROGRESS +{ + PrgInd prg_ind; //Progress indicator M + + BrCap br_cap; //Bearer capability O + CauseStr cause; //Cause O + Disp disp; //Display + HLComp hl_comp; //High layer compatibility + + //ansi + Fac facility; //facility +}IsdnProg; + +typedef struct _isdnRel //RELEASE +{ + CauseStr cause; //Cause O + + Disp disp; //Display + Sign sign; //Signal +}IsdnRel, IsdnRelComp; + +/*typedef struct _isdnRelComp //RELEASE COMPLETE +{ + CauseStr cause; //Cause O + Disp disp; //Display + Sign sign; //Signal +}IsdnRelComp; +*/ +typedef struct _isdnRestart //Restart +{ + ChnlId chnl_id; //Channel identification O + RestartInd restart_ind; //Restart indicator M + + Disp disp; //Display +}IsdnRestart, IsdnRestAck; + +typedef struct _isdnSetup //SETUP +{ + BrCap br_cap; //Bearer capability M + ChnlId chnl_id; //Channel identification O/M + PrgInd prg_ind; //Progress indicator + NtSpFac nt_sp_fac; //Network specific facilities + Disp disp; //Display + CgPtyNum cg_pty_num; //Calling party number + CdPtyNum cd_pty_num; //Called party number + TranNtSel tran_nt_sel; //Transit network selection + + SdComp sd_comp; //Sending complete O + RptInd rpt_ind; //Repeat indicator O + DtTime dt_time; //Date/time + KpdFac kpd_fac; //Keypad facility + Sign sign; //Signal + CgPtyAddr cg_pty_addr; //Calling party subaddress + CdPtyAddr cd_pty_addr; //Called party subaddress + LLComp ll_comp; //Low layer compatibility + HLComp hl_comp; //High layer compatibility + + //ansi + Fac facility; //facility + RedirNum redir_num; //Redirection number +// OrgCdNum org_cd_num; //original called number +}IsdnSetup; + +typedef struct _isdnSetupAck //SETUP ACKNOWLEDGE +{ + ChnlId chnl_id; //Channel identification O + PrgInd prg_ind; //Progress indicator + Disp disp; //Display + Sign sign; //Signal +}IsdnSetupAck; + +typedef struct _isdnStatus //STATUS +{ + CauseStr cause; //Cause M + CallStat call_stat; //Call state M + + Disp disp; //Display O +}IsdnStatus; + +typedef struct _isdnStatEnq //STATUS ENQUIRY +{ + Disp disp; //Display O +}IsdnStatEnq; + +typedef struct _isdnResuResp +{ + +}IsdnResuResp; + +typedef struct _isdnResuRejReq +{ + +}IsdnResuRejReq; + +typedef struct _isdnSusp +{ + +}IsdnSusp; + +typedef struct _isdnSuspRejReq +{ + +}IsdnSuspRejReq; + +typedef struct _isdnTimeout +{ + +}IsdnTimeout; + + +//ansi +typedef struct _isdnService //Service +{ + ChgStat chg_stat; //change status M + ChnlId chnl_id; //channel identification M +}IsdnService, IsdnServAck; + +typedef struct _isdnFac //Facility +{ + +}IsdnFac; + + + + +typedef struct _isdnMsgStr +{ + MsgMan msg_m; + + union + { + /*******Call establishment messages*******/ + IsdnAlert alert; //alerting + IsdnCallProc callProc; //Call proceeding + IsdnConn conn; //Connect + IsdnConnAck connAck; //Connect acknowledge + IsdnProg prog; //progress + IsdnSetup setup; //setup + IsdnSetupAck setupAck; //Setup acknowledge + + /*******Call information phase messages:*******/ + IsdnResuRejReq resuRejReq; //resume reject require + + /*******Call clearing messages:*******/ + IsdnDisc disc; //disconnect + IsdnRel rel; //release + IsdnRelComp relComp; //release complete + IsdnRestart restart; //restart + IsdnRestAck restAck; //restart Acknowledge + + /*******Miscellaneous messages:*******/ + IsdnInfo info; // + IsdnNoti noti; // + IsdnStatus status; // + IsdnStatEnq statEnq; // + + /*******Maintenance messages*******/ + IsdnService service; //service + IsdnServAck servAck; //service acknowledge + }msg_list; +}IsdnMsgStr; + + +typedef struct _IuaMsgStr +{ + u8 pad[25]; + u8 msg_class; /*xua msg type=0x05*/ + u8 e1_no; /* E1 number */ + u16 msg_length __attribute__((packed)); /* ISDN Message length */ + union + { + struct + { + u8 mtp3_ip; /* reserved */ + u8 opercode; /* 1=Out Of Service 5=In Service 6=Processor Outage*/ + u8 alarmcode; + }lkmsg; + struct + { + MsgMan msg_m; + u8 ie_content[IE_MAX_LEN]; /* information elements Content */ + }isdn_msg; /*isdn message content*/ + }msgcontent; +}IuaMsgStr; + + + +/************************************************************ +ISDN timer structure +************************************************************/ +typedef struct _isdnTimerStr //计数, 有几个十毫秒 +{ + u16 t301; + u16 t302; + u16 t303; + u16 t304; + u16 t305; + u16 t306; + u16 t307; + u16 t308; + u16 t309; + u16 t310; + u16 t312; + u16 t313; + u16 t316; + u16 t317; + u16 t321; + u16 t322; + + u16 t1s; + u16 t40s; + u16 t240s; + //ansi + u16 t3M1; +}IsdnTimerStr; + + +IsdnTimerStr isdn_timer_var; +IuaMsgStr iua_sd_msg, iua_rv_msg; + + + + + + +#endif diff --git a/omc/plat/isdn/src/include/isdn_public.h b/omc/plat/isdn/src/include/isdn_public.h new file mode 100644 index 0000000..806534b --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_public.h @@ -0,0 +1,56 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_public.h +Description: Redefine type byname +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-18 +History: + + +************************************************************/ + +#ifndef _ISDN_PUBLIC_H_ +#define _ISDN_PUBLIC_H_ + +#include +#include +#include +#include + +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#ifndef _T_BYTE +#define _T_BYTE +typedef unsigned char BYTE; +#endif + +#ifndef _T_WORD +#define _T_WORD +typedef unsigned short WORD; +#endif + +#ifndef _T_DWORD +#define _T_DWORD +typedef unsigned int DWORD; +#endif + +#define ISDN_CM_OK 1 //Command request success +#define ISDN_CM_FAILED 0 //Command request failed + +#endif + + diff --git a/omc/plat/isdn/src/include/isdn_rm.h b/omc/plat/isdn/src/include/isdn_rm.h new file mode 100644 index 0000000..61f15aa --- /dev/null +++ b/omc/plat/isdn/src/include/isdn_rm.h @@ -0,0 +1,151 @@ +/*********************************************************** +File Name: isdn_rm.h +Description: ISDN Resource Management declaration +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-1-23 +************************************************************/ +#ifndef _ISDN_RM_H +#define _ISDN_RM_H + +#include "isdn_if.h" +#include "isdn_inc.h" + +/************************************************************ +ISDN Resource structure +************************************************************/ +#define ISDN_MAX_SAP 16 +#define ISDN_MAX_CG 256 +#define ISDN_MAX_CIRCUIT 256 +#define ISDN_MAX_PORT 8192 +#define ISDN_CIRCUIT_CIC 32 +/* +typedef struct _isdn_cg_attrib_ +{ +// u8 variant_type; + u8 priority; //0:reattempt; 1:discard + u8 network_id; //Network identifier + u32 tg_id; +}ISDN_Cg_Attrib_; + +typedef struct _isdn_circuit_attrib_ +{ + u8 plat_id; + u8 cic_range; + u32 head_cic; + u32 circuit_id; +}ISDN_Circuit_Attrib_; + +typedef struct _isdn_sap_struct +{ + u8 enable; + ISDN_Sap_Attrib_ attrib; +}ISDN_Sap_struct; + +typedef struct _isdn_cg_struct +{ + u8 enable; + u8 sap_id; + u8 circuit_num; + u8 circuit_used[ISDN_MAX_CIRCUIT]; + Cg_Attrib_struct attrib; +}ISDN_Cg_struct; + +typedef struct _isdn_circuit_struct +{ + u8 enable; + u16 cg_id; + u8 user_network_if; + u8 interface_id; + u8 restart_clas; //restart indicator class + u8 lk3_status; + u8 lk2_status; + u8 dc_status; //ansi maintenance D-channel status + u8 heartbeat_time; + Circuit_Attrib_struct attrib; +}ISDN_Circuit_struct; +*/ + + +typedef struct _isdn_cic_state_ +{ + u8 call_state; + u8 maintenance_state; //ansi maintenance B-channel state blo_state +}ISDN_CIC_state_; + +typedef struct _isdn_fsm_state_ +{ + int cpc_state; + int m_state; //bls_state and blr_state + +}ISDN_Fsm_state_; + +typedef struct _isdn_link_struct +{ + u8 enable; +// u8 circuit_id; + u8 restart_clas; //restart indicator class + u8 lk3_status; + u8 lk2_status; + u8 dc_status; //ansi maintenance D-channel status + u16 plat_heartbeat_time; //to another plat + u16 link_heartbeat_time; //from iua +}ISDN_Link_struct; + +typedef struct _isdn_port_struct +{ + u8 enable; + + u16 call_ref; + u8 callout_fg; //最高位, 辨别是主叫发起的还是别叫发起的 + u16 timer_flag; + u32 w_time; + u32 su_proc_id; //for normal call + + u8 pre_send_msg; + u8 msg_cmd; + u8 primitive_cmd; + u8 g_pri_cmd; + u8 timeout_fg; //0:never timeout, 1:once timeout + u32 cic_val; + + ISDN_CIC_state_ cic_state; + ISDN_Fsm_state_ fsm_state; + + int trace_flag; +}ISDN_Port_struct; + +typedef struct _isdn_attrib_struct +{ + u8 systemID; + u8 isdn_run_mode; + u32 isdn_remote_ip; +}ISDN_Attrib_struct; + + +typedef struct _isdn_resource_pond +{ +// ISDN_Sap_struct sap_pond[ISDN_MAX_SAP]; +// ISDN_Cg_struct cg_pond[ISDN_MAX_CG]; +// ISDN_Circuit_struct circuit_pond[ISDN_MAX_CIRCUIT]; + ISDN_Link_struct link_pond[ISDN_MAX_CIRCUIT]; +// u8 e1_start; + ISDN_Port_struct port_pond[ISDN_MAX_PORT]; + ISDN_Attrib_struct attrib; +}ISDN_Resource_Pond; + +ISDN_Resource_Pond isdn_rs; + + + +/************************************************************ +ISDN Resource functions interface +************************************************************/ +u32 find_port_by_callref(u16 cref, u16 circuit_id); +extern int find_port_by_sap(Pst *pst); +extern u32 isdn_assign_port(u16 circuit_id); +extern u32 find_port_by_cic(u32 cic, u16 circuit_id); +extern int find_circuit_by_interfaceId(int cg_id, u8 interface_id); + + +#endif diff --git a/omc/plat/isdn/src/isdn_debug.c b/omc/plat/isdn/src/isdn_debug.c new file mode 100644 index 0000000..eb16750 --- /dev/null +++ b/omc/plat/isdn/src/isdn_debug.c @@ -0,0 +1,1373 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_debug.c +Description: ISDN Debug +Version: v9.1.0 +Author: Gengxin Chen +Create Date: 2008-5-27 +History: + + +************************************************************/ + +#include "./include/isdn_debug.h" + +#define DEBUG_ID 24 +#define VER_DEBUG "R9V1_01" +#define IS_PATCH 2 + +//#define PROTO_ISDN 3 +#define PAGE_NUM 5 +#define ISDN_MONITOR_NONE 0x0000 +#define ISDN_MONITOR_ERROR 0x0002 +#define ISDN_MONITOR_MSG 0x0004 +#define ISDN_MONITOR_FUNC 0x0008 +#define ISDN_MONITOR_STATE 0x8000 +#define ISDN_MONITOR_ALL 0x7fff + +static ISDN_Msg_Csta isdn_csta; +static u8 AsciInBuf[4096]; +static u8 AsciOutBuf[4096]; +static u8 AsciTempBuf[4096]; +static u16 MonitorIsdnFg; +static u8 info[4096]; +static int debug_link_id; + +static u8 log_help[] = { + "ISDN 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 \n\r\ + 3.[log state on/off] display state logs \n\r\ + 4.[list cg] display all cg (N/A)\n\r\ + 5.[list cg-x] display cg (N/A)\n\r\ + 6.[list circuit-x] display circuit->port (N/A)\n\r\n\r" +}; + + +static u16 disp_page[10]; +static u8 *disp_ptr = (u8 *) disp_page; + +static u32 debug_status_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,1 +}; + +static u8 debug_status = 1; + +static u32 debug_name_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,2 +}; + +static u32 debug_ascin_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,3 +}; + +static u32 debug_ascout_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,4 +}; + +static u32 debug_page_title[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,1,1 +}; + +static u32 debug_page_line[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,1,2,1 +}; + +const static u8 BASE_ID_LEN = 15; +const static u8 PAGE_POINT = 14; +const static u8 LINE_POINT = 15; + +static u8 title1_p[] = +{ + " ISDN Page 01 SAP Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SystemID\n\r\ +Run mode\n\r\ +Remote IP\n\r" +}; + +static u8 title2_p[] = +{ + " ISDN Page 02 CG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SAP_ID\n\r\ +Circuit_num\n\r\ +Variant\n\r\ +Priority\n\r\ +TG_ID\n\r\ +NFAS\n\r\ +PRI\n\r\ +BACKUP\n\r" +}; + +static u8 title3_p[] = +{ + " ISDN Page 03 Circuit Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +CG_ID\n\r\ +PLAT_ID\n\r\ +HEAD CIC\n\r\ +CIC RANGE\n\r\ +D-CHANNEL\n\r\ +LINK_ID\n\r\ +LK2_STATUS\n\r\ +LK3_STATUS\n\r\ +DC_STATUS\n\r" +}; + +static u8 title4_p[] = +{ + " ISDN Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +Fsm_state\n\r\ +CIC_state\n\r\ +SU_port\n\r\ +Timer_F\n\r\ +Time_W\n\r" +}; + +static u8 title5_p[] = +{ + " ISDN Page 05 Csta Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +RV-SD-SETUP\n\r\ +RV-SD-SETUPACK\n\r\ +RV-SD-CALLPROC\n\r\ +RV-SD-ALERT\n\r\ +RV-SD-CONN\n\r\ +RV-SD-CONNACK\n\r\ +RV-SD-DISC\n\r\ +RV-SD-REL\n\r\ +RV-SD-RELCOMP\n\r\ +RD-SETUP\n\r\ +RD-SETUPACK\n\r\ +RD-CALLPROC\n\r\ +RD-ALERT\n\r\ +RD-CONN\n\r\ +RD-CONNACK\n\r\ +RD-DISC\n\r\ +RD-REL\n\r\ +RD-RELCOMP\n\r" +}; + + +static void debug_setcol(int color); +static void debug_cancelcol(); + +static void isdn_asciout_proc(const char *fmt, ...) +{ + va_list ap; + char buf[4096]; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + if((strlen(AsciOutBuf) + strlen(buf)) < 4096) + strcat(AsciOutBuf, buf); + else + strcpy(AsciOutBuf, buf); + va_end(ap); +} + +static void list_sap(u8 sap_id) +{ + const pal_sap_struct *sap_ptr = pal_sap_ptr(sap_id); + if(sap_ptr == NULL) + { + printf("list sap err!sap_id = %d, can't find sap_ptr!\n", sap_id); + return; + } + + if(sap_id >= ISDN_MAX_SAP) + return; + sprintf(info,"\r\n\ + #ISDN SAP Info\r\n\ + Enable=%d\r\n\ + SystemID(%d)\r\n\ + Run mode(%d)\r\n\ + Remote IP(%lx)\r\n\ + ------------------\r\n", + sap_ptr->enable, + isdn_rs.attrib.systemID, + isdn_rs.attrib.isdn_run_mode, + isdn_rs.attrib.isdn_remote_ip); + isdn_asciout_proc(info); +} + +static void list_cg(u16 cg_id) +{ + const pal_cg_struct *cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + { + printf("list cg err!cg_id = %d, can't find cg_ptr!\n", cg_id); + return; + } + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + + if(cg_id >= ISDN_MAX_CG) + return; + sprintf(info,"\r\n\ + #ISDN CG- %d Info\r\n\ + enable:%d\r\n\ + sap_id:%d\r\n\ + circuit_num:%d\r\n\ + Attrib-->\r\n\ + variant_type(%d)\r\n\ + priority(%d)\r\n\ + tg_id(%ld)\r\n\ + NFAS(%d)\r\n\ + pri_link(%ld)\r\n\ + backup_link(%ld)\r\n\ + ---------------------\r\n", + cg_id, + cg_ptr->enable, + cg_ptr->sap_id, + cg_ptr->circuit_num, + cg_ptr->attrib.variant, + cg_ptr->attrib.priority, + cg_ptr->attrib.tg_id, + cg_ptr->attrib.nfas.flag, + cg_ptr->attrib.nfas.prim_link, + cg_ptr->attrib.nfas.backup_link + ); + isdn_asciout_proc(info); +} +static void list_all_cg(void) +{ + int i; + const pal_cg_struct *cg_ptr = NULL; + + isdn_asciout_proc("CgId\tSapId\tCircirtNum\tVariant\tPrior\tTgId\tNFAS\tPRI\tBackUp\r\n"); + for(i = 0; i < ISDN_MAX_CG; i++) + { + cg_ptr = pal_cg_ptr(i); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + + if(cg_ptr->enable == 0) + continue; + sprintf(info,"%d\t%d\t%d\t\t%d\t%d\t%ld\t%d\t%ld\t%ld\r\n", + i, + cg_ptr->sap_id, + cg_ptr->circuit_num, + cg_ptr->attrib.variant, + cg_ptr->attrib.priority, + cg_ptr->attrib.tg_id, + cg_ptr->attrib.nfas.flag, + cg_ptr->attrib.nfas.prim_link, + cg_ptr->attrib.nfas.backup_link); + isdn_asciout_proc(info); + } +} + +static void list_circuit(u16 circuit_id) +{ + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + { + printf("list circuit err!circuit_id = %d, can't find circuit_ptr!\n", circuit_id); + return; + } + if(circuit_id >= ISDN_MAX_CIRCUIT) + return; + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + return; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + sprintf(info,"\r\n\ + #ISDN Circuit-%d Info\r\n\ + enable:%d\r\n\ + cg_id:%d\r\n\ + Attrib->\r\n\ + plat_id(%d)\r\n\ + head_cic(%ld)\r\n\ + cic_range(%d)\r\n\ + d_channel(%d)\r\n\ + link_id(%ld)\r\n\ + lk2_status(%d)\r\n\ + lk3_status(%d)\r\n\ + dc_status(%d)\r\n\ + -------------------\r\n", + circuit_id, + circuit_ptr->enable, + circuit_ptr->cg_id, + circuit_ptr->attrib.plat_id, + circuit_ptr->attrib.head_cic, + circuit_ptr->attrib.cic_range, + circuit_ptr->attrib.d_chnl, + circuit_ptr->attrib.link_id, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk2_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk3_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].dc_status); + isdn_asciout_proc(info); +} +static void list_all_circuit() +{ + int i; + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = NULL; + + isdn_asciout_proc("CircuitId\tCgId\tPlatId\tHeatCic\tRange\tD_Chnl\tLinkId\tLk2Status\tLk3Status\tDcStatus\r\n"); + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + if(circuit_ptr->enable == 0) + continue; + + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + + sprintf(info,"%d\t\t%d\t%d\t%ld\t%d\t%d\t%ld\t%d\t\t%d\t\t%d\r\n", + i, + circuit_ptr->cg_id, + circuit_ptr->attrib.plat_id, + circuit_ptr->attrib.head_cic, + circuit_ptr->attrib.cic_range, + circuit_ptr->attrib.d_chnl, + circuit_ptr->attrib.link_id, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk2_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk3_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].dc_status); + isdn_asciout_proc(info); + } +} +static void list_all_circuit_by(u16 cg_id) +{ + int i; + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = NULL; + + isdn_asciout_proc("--->circuit:\r\n"); + isdn_asciout_proc("CircuitId\tCgId\tPlatId\tHeatCic\tRange\tD_Chnl\tLinkId\tLk2Status\tLk3Status\tDcStatus\r\n"); + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + if(circuit_ptr->enable == 0 && + circuit_ptr->cg_id != cg_id) + continue; + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + + sprintf(info,"%d\t\t%d\t%d\t%ld\t%d\t%d\t%ld\t%d\t\t%d\t\t%d\r\n", + i, + circuit_ptr->cg_id, + circuit_ptr->attrib.plat_id, + circuit_ptr->attrib.head_cic, + circuit_ptr->attrib.cic_range, + circuit_ptr->attrib.d_chnl, + circuit_ptr->attrib.link_id, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk2_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk3_status, + isdn_rs.link_pond[circuit_ptr->attrib.link_id].dc_status); + isdn_asciout_proc(info); + } +} + +static void list_port(u32 pid) +{ + if(pid >= ISDN_MAX_PORT) + return; + sprintf(info,"\r\n\ + #ISDN Port-%ld Info\r\n\ + enable:%d\r\n\ + su_proc_id:%ld\r\n\ + msg_cmd:%d\r\n\ + primitive_cmd:%d\r\n\ + ------------------------\r\n\ + call_state:%d\r\n\ + maintenance_state:%d\r\n\ + ------------------------\r\n\ + cpc_state:%d\r\n\ + m_state:%d\r\n\ + ------------------------\r\n", + pid, + isdn_rs.port_pond[pid].enable, + isdn_rs.port_pond[pid].su_proc_id, + isdn_rs.port_pond[pid].msg_cmd, + isdn_rs.port_pond[pid].primitive_cmd, + isdn_rs.port_pond[pid].cic_state.call_state, + isdn_rs.port_pond[pid].cic_state.maintenance_state, + isdn_rs.port_pond[pid].fsm_state.cpc_state, + isdn_rs.port_pond[pid].fsm_state.m_state); + isdn_asciout_proc(info); +} +static void list_all_port() +{ + int i, j = 0; + isdn_asciout_proc("index\tPort\tSuID\tcall_state\tmain_state\tcpc_state\tm_state\r\n"); + for(i = 0; i < ISDN_MAX_PORT; i++) + { + if(isdn_rs.port_pond[i].enable == 0) + continue; + sprintf(info,"%d\t%d\t%ld\t%d\t\t%d\t\t%d\t\t%d\r\n", + j++, + i, + isdn_rs.port_pond[i].su_proc_id, + isdn_rs.port_pond[i].cic_state.call_state, + isdn_rs.port_pond[i].cic_state.maintenance_state, + isdn_rs.port_pond[i].fsm_state.cpc_state, + isdn_rs.port_pond[i].fsm_state.m_state); + isdn_asciout_proc(info); + } +} +static void list_all_port_by(u16 circuit_id) +{ + int i,cic,pid; + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + { + printf("list all port by circuit_id err!circuit_id = %d, can't find circuit_ptr!\n", circuit_id); + return; + } + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + return; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + + pid = ISDN_CIRCUIT_CIC * circuit_id; + cic = circuit_ptr->attrib.head_cic; + + isdn_asciout_proc("-->port:\r\n"); + isdn_asciout_proc("CIC\tPort\tSuID\tcall_state\tmain_state\tcpc_state\tm_state\r\n"); + + for(i = 0; i < circuit_ptr->attrib.cic_range; i++) + { + isdn_asciout_proc("%d\t%d\t%d\t%d\t\t%d\t\t%d\t\t%d\r\n", + cic, + pid, + isdn_rs.port_pond[pid].su_proc_id, + isdn_rs.port_pond[pid].cic_state.call_state, + isdn_rs.port_pond[pid].cic_state.maintenance_state, + isdn_rs.port_pond[pid].fsm_state.cpc_state, + isdn_rs.port_pond[pid].fsm_state.m_state); + cic++; + pid++; + } +} + +static int list_cic(u8 link_id, u32 cic_val) +{ + int i,pid; + u32 head_cic; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + + if(circuit_ptr->enable == 0) + continue; + + if((cic_val < circuit_ptr->attrib.head_cic) || + ((cic_val - circuit_ptr->attrib.head_cic ) >= + circuit_ptr->attrib.cic_range)) + continue; + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + + if(cg_ptr->attrib.nfas.flag) + { + if(cg_ptr->attrib.nfas.prim_link != link_id && + cg_ptr->attrib.nfas.backup_link != link_id) + continue; + } + else + { + if(circuit_ptr->attrib.link_id != link_id) + continue; + } + + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + pid = ISDN_CIRCUIT_CIC * i + (cic_val - head_cic); + + list_sap(cg_ptr->sap_id); + list_cg(circuit_ptr->cg_id); + list_circuit(i); + list_port(pid); + + return 1; + } + sprintf(info, "illegal cic value! link_id=%d,cic=%ld\r\n", link_id, cic_val); + isdn_asciout_proc(info); + + return -1; +} + +static void debug_setcol(int color) +{ + isdn_asciout_proc("%c[%dm",COL_ESC , color); +} + +static void debug_cancelcol() +{ + isdn_asciout_proc("%c[m",COL_ESC); +} + +static u16 debug_disp_line(u8 page, u8 line) +{ + u16 disp_length; + + disp_length = 0; + disp_ptr = (u8 *)disp_page; + const pal_sap_struct *sap_ptr = pal_sap_ptr(disp_page[page]); + if(sap_ptr == NULL) + return ISDN_CM_FAILED; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(disp_page[page]); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + const pal_cg_struct *cg_ptr = pal_cg_ptr(disp_page[page]); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + + switch(page) + { + case 1: // Page 1: sap Info + switch(line) + { + case 0: + disp_ptr = (u8 *)&disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (u8 *)&(sap_ptr->enable); + disp_length = 1; + break; + case 2: //systemID + disp_ptr = (u8 *)&(isdn_rs.attrib.systemID); + disp_length = 1; + break; + case 3: //run_mode + disp_ptr = (u8 *)&(isdn_rs.attrib.isdn_run_mode); + disp_length = 1; + break; + case 4: //isdn_remote_ip + disp_ptr = (u8 *)&(isdn_rs.attrib.isdn_remote_ip); + disp_length = 4; + break; + default: + break; + } + break; + case 2: // Page 2: cg Info + switch(line) + { + case 0: + disp_ptr = (u8 *)&disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (u8 *)&(cg_ptr->enable); + disp_length = 1; + break; + case 2: //sap_id + disp_ptr = (u8 *)&(cg_ptr->sap_id); + disp_length = 1; + break; + case 3: //circuit_num + disp_ptr = (u8 *)&(cg_ptr->circuit_num); + disp_length = 1; + break; + case 4: //variant_type + disp_ptr = (u8 *)&(cg_ptr->attrib.variant); + disp_length = 1; + break; + case 5: //priority + disp_ptr = (u8 *)&(cg_ptr->attrib.priority); + disp_length = 1; + break; + case 6: //tg_id + disp_ptr = (u8 *)&(cg_ptr->attrib.tg_id); + disp_length = 4; + break; + case 7: //nfas + disp_ptr = (u8 *)&(cg_ptr->attrib.nfas.flag); + disp_length = 1; + break; + case 8: //pri + disp_ptr = (u8 *)&(cg_ptr->attrib.nfas.prim_link); + disp_length = 1; + break; + case 9: //backup + disp_ptr = (u8 *)&(cg_ptr->attrib.nfas.backup_link); + disp_length = 1; + break; + default: + break; + } + break; + case 3: // Page 3: circuit Info + switch(line) + { + case 0: + disp_ptr = (u8 *)&disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (u8 *)&(circuit_ptr->enable); + disp_length = 1; + break; + case 2: //cg_id + disp_ptr = (u8 *)&(circuit_ptr->cg_id); + disp_length = 2; + break; + case 3: //plat_id + disp_ptr = (u8 *)&(circuit_ptr->attrib.plat_id); + disp_length = 1; + break; + case 4: //head_cic + disp_ptr = (u8 *)&(circuit_ptr->attrib.head_cic); + disp_length = 4; + break; + case 5: //cic_range + disp_ptr = (u8 *)&(circuit_ptr->attrib.cic_range); + disp_length = 1; + break; + case 6: //d-channel + disp_ptr = (u8 *)&(circuit_ptr->attrib.d_chnl); + disp_length = 4; + break; + case 7: //link_id + disp_ptr = (u8 *)&(circuit_ptr->attrib.link_id); + disp_length = 1; + break; + case 8: //lk2_status + disp_ptr = (u8 *)&(isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk2_status); + disp_length = 1; + break; + case 9: //lk3_status + disp_ptr = (u8 *)&(isdn_rs.link_pond[circuit_ptr->attrib.link_id].lk3_status); + disp_length = 1; + break; + case 10: //dc_status + disp_ptr = (u8 *)&(isdn_rs.link_pond[circuit_ptr->attrib.link_id].dc_status); + disp_length = 1; + break; + default: + break; + } + break; + case 4: // Page 4: port Info + switch(line) + { + case 0: + disp_ptr = (u8 *)&disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].enable); + disp_length = 1; + break; + case 2: //fsm_state + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].fsm_state); + disp_length = 2; + break; + case 3: //cic_state + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].cic_state); + disp_length = 2; + break; + case 4: //su_proc_id + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].su_proc_id); + disp_length = 4; + break; + case 5: //timer_flag + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].timer_flag); + disp_length = 2; + break; + case 6: //w_time + disp_ptr = (u8 *)&(isdn_rs.port_pond[disp_page[page]].w_time); + disp_length = 4; + break; + default: + break; + } + break; + case 5: // Page 5: call statistics Info + switch(line) + { + //receive and send + case 0: + disp_ptr = (u8 *)&isdn_csta.rv_setup; + disp_length = 8; + break; + case 1: + disp_ptr = (u8 *)&isdn_csta.rv_setupAck; + disp_length = 8; + break; + case 2: + disp_ptr = (u8 *)&isdn_csta.rv_callProc; + disp_length = 8; + break; + case 3: + disp_ptr = (u8 *)&isdn_csta.rv_alert; + disp_length = 8; + break; + case 4: + disp_ptr = (u8 *)&isdn_csta.rv_conn; + disp_length = 8; + break; + case 5: + disp_ptr = (u8 *)&isdn_csta.rv_connAck; + disp_length = 8; + break; + case 6: + disp_ptr = (u8 *)&isdn_csta.rv_disc; + disp_length = 8; + break; + case 7: + disp_ptr = (u8 *)&isdn_csta.rv_rel; + disp_length = 8; + break; + case 8: + disp_ptr = (u8 *)&isdn_csta.rv_relComp; + disp_length = 8; + break; + //redirect + case 9: + disp_ptr = (u8 *)&isdn_csta.rd_setup; + disp_length = 4; + break; + case 10: + disp_ptr = (u8 *)&isdn_csta.rd_setupAck; + disp_length = 4; + break; + case 11: + disp_ptr = (u8 *)&isdn_csta.rd_callProc; + disp_length = 4; + break; + case 12: + disp_ptr = (u8 *)&isdn_csta.rd_alert; + disp_length = 4; + break; + case 13: + disp_ptr = (u8 *)&isdn_csta.rd_conn; + disp_length = 4; + break; + case 14: + disp_ptr = (u8 *)&isdn_csta.rd_connAck; + disp_length = 4; + break; + case 15: + disp_ptr = (u8 *)&isdn_csta.rd_disc; + disp_length = 4; + break; + case 16: + disp_ptr = (u8 *)&isdn_csta.rd_rel; + disp_length = 4; + break; + case 17: + disp_ptr = (u8 *)&isdn_csta.rd_relComp; + disp_length = 4; + break; + default: + break; + } + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +static void debug_disp_page(u8 page) +{ + u8 disp_line; + u16 disp_length; + + debug_page_line[PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = debug_disp_line(page, disp_line); + debug_page_line[LINE_POINT] = disp_line + 2; + debug_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +int isdn_debug_init(void) +{ + u8 page; + u8 data[10]; + u8 *ptr; + + strcpy(AsciInBuf, "\0"); + strcpy(AsciOutBuf, "\0"); + MonitorIsdnFg = ISDN_MONITOR_NONE; + bzero(disp_page, 20); + memset(&isdn_csta, 0, sizeof(ISDN_Msg_Csta)); + ptr = data; + + debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(BASE_ID_LEN, debug_name_id, VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 4096); + + for (page = 1; page <= PAGE_NUM; 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; + default: + break; + } + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + debug_disp_page(page); + } + return ISDN_CM_OK; +} + +void isdn_debug_timer(void) +{ + u8 in_page, err_fg = 0; + u8 *ascii_in_ptr = NULL; + u8 *str_start = NULL; + u16 str_len, num; + + if((str_len = strlen(AsciInBuf)) > 0) + { + in_page = AsciInBuf[0] - 1; + ascii_in_ptr = AsciInBuf + 1; + + if (in_page > PAGE_NUM) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + MonitorIsdnFg = MonitorIsdnFg | ISDN_MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + MonitorIsdnFg = MonitorIsdnFg & (~ISDN_MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + MonitorIsdnFg = ISDN_MONITOR_ALL; + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + MonitorIsdnFg = ISDN_MONITOR_NONE; + } + else if (strcmp(ascii_in_ptr,"log state on") == 0) + { + MonitorIsdnFg = MonitorIsdnFg | ISDN_MONITOR_STATE; + } + else if (strcmp(ascii_in_ptr,"log state off") == 0) + { + MonitorIsdnFg = MonitorIsdnFg & (~ISDN_MONITOR_STATE); + } + + else if (strcmp(ascii_in_ptr,"help") == 0) + { + isdn_asciout_proc(log_help); + isdn_asciout_proc("Ver.%sp%02d\r\n",VER_DEBUG,IS_PATCH); + } + else if (isdigit(ascii_in_ptr[0])) + { + num = strtoul(ascii_in_ptr, NULL, 10); + disp_page[in_page] = num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, ">")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] += num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, "<"))!= NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] -= num; + debug_disp_page(in_page); + } + else if (strcmp(ascii_in_ptr,"reset csta") == 0) + { + memset(&isdn_csta,0,sizeof(ISDN_Msg_Csta)); + } + else if (strcmp(ascii_in_ptr,"test color") == 0) + { + debug_setcol(COL_WHITE); + isdn_asciout_proc("COL_WHITE\n\r"); + debug_setcol(COL_RED); + isdn_asciout_proc("COL_RED\n\r"); + debug_setcol(COL_YELLOW); + isdn_asciout_proc("COL_YELLOW\n\r"); + debug_setcol(COL_GREEN); + isdn_asciout_proc("COL_GREEN\n\r"); + debug_setcol(COL_BLUE); + isdn_asciout_proc("COL_BLUE\n\r"); + debug_setcol(COL_BROWN); + isdn_asciout_proc("COL_BROWN\n\r"); + debug_setcol(COL_MEGEN); + isdn_asciout_proc("COL_MEGEN\n\r"); + debug_setcol(COL_GRAY); + isdn_asciout_proc("COL_GRAY\n\r"); + debug_setcol(COL_HI_WHI); + isdn_asciout_proc("COL_HI_WHI\n\r"); + debug_setcol(COL_HI_RED); + isdn_asciout_proc("COL_HI_RED\n\r"); + debug_setcol(COL_HI_YEL); + isdn_asciout_proc("COL_HI_YEL\n\r"); + debug_setcol(COL_HI_GRE); + isdn_asciout_proc("COL_HI_GRE\n\r"); + debug_setcol(COL_HI_BLU); + isdn_asciout_proc("COL_HI_BLU\n\r"); + debug_setcol(COL_HI_BRO); + isdn_asciout_proc("COL_HI_BRO\n\r"); + debug_setcol(COL_HI_MEG); + isdn_asciout_proc("COL_HI_MEG\n\r"); + debug_setcol(COL_BLACK); + isdn_asciout_proc("COL_BLACK\n\r"); + debug_cancelcol(); + } + else if (strstr(ascii_in_ptr, "reset port") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + if (num >= ISDN_MAX_PORT) + err_fg = 1; + else + { + memset(&(isdn_rs.port_pond[num]),0,sizeof(ISDN_Port_struct)); + } + } + } + else if (strstr(ascii_in_ptr, "set link_id") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "=")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + debug_link_id = num; + } + } + else if (strstr(ascii_in_ptr, "list sap") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_sap(num); + } + } + else if (strstr(ascii_in_ptr, "list cg") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_cg(num); + list_all_circuit_by(num); + } + else + list_all_cg(); + } + else if (strstr(ascii_in_ptr, "list circuit") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_circuit(num); + list_all_port_by(num); + } + else + list_all_circuit(); + } + else if (strstr(ascii_in_ptr, "list debug link") != NULL) + { + isdn_asciout_proc("debug_link_id = %d\n\r",debug_link_id); + } + else if (strstr(ascii_in_ptr, "list cic") != NULL) + { + if((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_cic(debug_link_id, num); + } + } + else if (strstr(ascii_in_ptr, "trace on") != NULL) + { + if((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + isdn_rs.port_pond[num].trace_flag = 1; + } + } + else if (strstr(ascii_in_ptr, "trace off") != NULL) + { + if((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + isdn_rs.port_pond[num].trace_flag = 0; + } + else + { + int i; + for(i = 0; i < ISDN_MAX_PORT; i++) + isdn_rs.port_pond[i].trace_flag = 0; + } + } + else + err_fg = 1; + + if (err_fg == 0) + isdn_asciout_proc("Command OK!\n\r"); + else + isdn_asciout_proc("Command Error!\n\r"); + + strcpy(AsciInBuf, "\0"); + } +} + +static void display_isdn_msgtype(u8 msgtype, u8 proto_discr) +{ + if(proto_discr == PROTOCOL_DISCR) + { + switch(msgtype) + { + case MSG_ALERT: + isdn_asciout_proc("Alerting"); + break; + case MSG_CALL_PROC: + isdn_asciout_proc("Call proceeding"); + break; + case MSG_CONN: + isdn_asciout_proc("Connect"); + break; + case MSG_CONNACK: + isdn_asciout_proc("Connect acknowledge"); + break; + case MSG_PROG: + isdn_asciout_proc("Progress"); + break; + case MSG_SETUP: + isdn_asciout_proc("Setup"); + break; + case MSG_SETUP_ACK: + isdn_asciout_proc("Setup acknowledge"); + break; + case MSG_DISC: + isdn_asciout_proc("Disconnect"); + break; + case MSG_REL: + isdn_asciout_proc("Release"); + break; + case MSG_REL_COMP: + isdn_asciout_proc("Release complete"); + break; + case MSG_RESTART: + isdn_asciout_proc("Restart"); + break; + case MSG_REST_ACK: + isdn_asciout_proc("Restart acknowledge"); + break; + case MSG_INFORMATION: + isdn_asciout_proc("Information"); + break; + case MSG_NOTI: + isdn_asciout_proc("Notify"); + break; + case MSG_STATUS: + isdn_asciout_proc("Status"); + break; + case MSG_STAT_ENQ: + isdn_asciout_proc("Status enquiry"); + break; + case MSG_FAC: + isdn_asciout_proc("Facility (connectionless)"); + break; + default: + isdn_asciout_proc("Unknown message"); + break; + } + } + else if(proto_discr == M_PROTOCOL_DISCR) + { + switch(msgtype) + { + case MSG_SERVICE: + isdn_asciout_proc("Service"); + break; + case MSG_SERVICE_ACK: + isdn_asciout_proc("Service acknowledge"); + break; + default: + isdn_asciout_proc("Unknown message"); + break; + } + } + isdn_asciout_proc("(message type=0x%x)\r\n",msgtype); +} + +void isdn_log_err(u32 pid,const char *fmt, ...) +{ + va_list ap; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if((MonitorIsdnFg & ISDN_MONITOR_ERROR) != ISDN_MONITOR_ERROR) + return; + + gettimeofday(&tv, &tz); + t = localtime(&tv.tv_sec); + sprintf(timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec); + + va_start(ap, fmt); + vsprintf(AsciTempBuf, fmt, ap); + debug_setcol(COL_RED); + isdn_asciout_proc("%s%s (pid=%d)", timestr, AsciTempBuf, pid); + debug_cancelcol(); + isdn_asciout_proc("\r\n"); + va_end(ap); +} + +void isdn_trace_func(u32 pid,const char *fmt, ...) +{ + va_list ap; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if (((MonitorIsdnFg & ISDN_MONITOR_FUNC) != ISDN_MONITOR_FUNC) || + (isdn_rs.port_pond[pid%ISDN_MAX_PORT].trace_flag != 1)) + return; + + gettimeofday(&tv, &tz); + t = localtime(&tv.tv_sec); + sprintf(timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + va_start(ap, fmt); + vsprintf(AsciTempBuf, fmt, ap); + debug_setcol(COL_YELLOW); + isdn_asciout_proc("%s%s (pid=%d)",timestr,AsciTempBuf,pid); + debug_cancelcol(); + isdn_asciout_proc("\r\n"); + va_end(ap); +} + +void monitor_isdn_msg(u32 pid,u8 *head,IuaMsgStr *msg,u8 col) +{ + int i, len; + u32 cic; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + int circuit_id = pid / ISDN_CIRCUIT_CIC; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + { + printf("monitor isdn msg err!pid=%ld, circuit_id = %d, can't find circuit_ptr!\n", pid, circuit_id); + return; + } + + if((MonitorIsdnFg & ISDN_MONITOR_MSG) != ISDN_MONITOR_MSG) + return; + + if(circuit_ptr->attrib.cic_range == 32) + cic = circuit_ptr->attrib.head_cic + (pid % ISDN_CIRCUIT_CIC); + else + + cic = circuit_ptr->attrib.head_cic + (pid % ISDN_CIRCUIT_CIC) - 1; + gettimeofday(&tv, &tz); + t = localtime(&tv.tv_sec); + sprintf(timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec); + + debug_setcol(col); + isdn_asciout_proc("%s%s ",timestr,head); + if(msg->msgcontent.isdn_msg.msg_m.call_ref[0] & 0x80) + isdn_asciout_proc("msg send to originating side\n\r"); + else + isdn_asciout_proc("msg send from originating side\n\r"); + display_isdn_msgtype(msg->msgcontent.isdn_msg.msg_m.msg_type, msg->msgcontent.isdn_msg.msg_m.proto_Discr); + isdn_asciout_proc("--cic=0x%04x,cref=0x%02x%02x,link=%d,proto=%d,pid=%d->\n\r", + cic, + msg->msgcontent.isdn_msg.msg_m.call_ref[0]&0x7F, + msg->msgcontent.isdn_msg.msg_m.call_ref[1], + msg->e1_no, + msg->msgcontent.isdn_msg.msg_m.proto_Discr, + pid); + len = msg->msg_length - 5; + debug_cancelcol(); + for (i = 0; i < len; i ++) + { + sprintf(&AsciTempBuf[3*i]," %02x", msg->msgcontent.isdn_msg.ie_content[i]); + } + sprintf(&AsciTempBuf[3*i],"\n\r"); + isdn_asciout_proc(AsciTempBuf); + return; +} + +void monitor_isdn_port(u32 call_ref,u32 port) +{ + if ((MonitorIsdnFg & ISDN_MONITOR_STATE) != ISDN_MONITOR_STATE) + return; + + isdn_asciout_proc("-->port:\r\n"); + isdn_asciout_proc("CallRef\tPort\tSuID\tcall_state\tmain_state\tcpc_state\tm_state\r\n"); + sprintf(info,"%lx\t%ld\t%ld\t%d\t\t%d\t\t%d\t\t%d\r\n", + call_ref, + port, + isdn_rs.port_pond[port].su_proc_id, + isdn_rs.port_pond[port].cic_state.call_state, + isdn_rs.port_pond[port].cic_state.maintenance_state, + isdn_rs.port_pond[port].fsm_state.cpc_state, + isdn_rs.port_pond[port].fsm_state.m_state); + isdn_asciout_proc(info); +} + +void isdn_msg_csta(u8 msgtype,u8 flag) +{ + switch(msgtype) + { + case MSG_ALERT: + if(flag==0) //receive + isdn_csta.rv_alert++; + else if(flag == 1) //send + isdn_csta.sd_alert++; + else //redirect + isdn_csta.rd_alert++; + break; + case MSG_CALL_PROC: + if(flag==0) //receive + isdn_csta.rv_callProc++; + else if(flag == 1) //send + isdn_csta.sd_callProc++; + else //redirect + isdn_csta.rd_callProc++; + break; + case MSG_CONN: + if(flag==0) //receive + isdn_csta.rv_conn++; + else if(flag == 1) //send + isdn_csta.sd_conn++; + else //redirect + isdn_csta.rd_conn++; + break; + case MSG_CONNACK: + if(flag==0) //receive + isdn_csta.rv_connAck++; + else if(flag == 1) //send + isdn_csta.sd_connAck++; + else //redirect + isdn_csta.rd_connAck++; + break; + case MSG_PROG: + break; + case MSG_SETUP: + if(flag==0) //receive + isdn_csta.rv_setup++; + else if(flag == 1) //send + isdn_csta.sd_setup++; + else //redirect + isdn_csta.rd_setup++; + break; + case MSG_SETUP_ACK: + if(flag==0) //receive + isdn_csta.rv_setupAck++; + else if(flag == 1) //send + isdn_csta.sd_setupAck++; + else //redirect + isdn_csta.rd_setupAck++; + break; + case MSG_DISC: + if(flag==0) //receive + isdn_csta.rv_disc++; + else if(flag == 1) //send + isdn_csta.sd_disc++; + else //redirect + isdn_csta.rd_disc++; + break; + case MSG_REL: + if(flag==0) //receive + isdn_csta.rv_rel++; + else if(flag == 1) //send + isdn_csta.sd_rel++; + else //redirect + isdn_csta.rd_rel++; + break; + case MSG_REL_COMP: + if(flag==0) //receive + isdn_csta.rv_relComp++; + else if(flag == 1) //send + isdn_csta.sd_relComp++; + else //redirect + isdn_csta.rd_relComp++; + break; + case MSG_RESTART: + break; + case MSG_REST_ACK: + break; + case MSG_INFORMATION: + break; + case MSG_NOTI: + break; + case MSG_STATUS: + break; + case MSG_STAT_ENQ: + break; + case MSG_FAC: + break; + default: + break; + } +} + diff --git a/omc/plat/isdn/src/isdn_fsm.c b/omc/plat/isdn/src/isdn_fsm.c new file mode 100644 index 0000000..979520c --- /dev/null +++ b/omc/plat/isdn/src/isdn_fsm.c @@ -0,0 +1,3124 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_fsm.c +Description: ISDN FSM +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ + +#include "./include/isdn_const.h" +#include "./include/isdn_rm.h" +#include "./include/isdn_debug.h" +#include "./include/isdn_ext.h" +#include "./include/isdn_inc.h" + + +#define USR 0x00 +#define LN 0x02 +#define TN 0x03 +#define RLN 0x04 +#define DF RLN +u8 cause_to_loc[128]={ + DF, LN, LN, LN, DF, DF, LN, LN, DF, DF, + DF, DF, DF, DF, DF, DF, USR,USR,RLN,RLN, + DF, USR,LN, DF, DF, RLN,LN, RLN,RLN,RLN, + LN, RLN,DF, DF, RLN,DF, DF, DF, USR,DF, + DF, RLN,RLN,LN, LN, DF, DF, USR,DF, DF, + RLN,DF, DF, DF, DF, RLN,DF, LN, LN, DF, + DF, DF, DF, LN, DF, LN, DF, DF, DF, RLN, + DF, DF, DF, DF, DF, DF, DF, DF, DF, DF, + DF, LN, DF, LN, LN, LN, LN, RLN,USR,DF, + DF, LN, DF, DF, DF, LN, LN, RLN,LN, RLN, + LN, LN, RLN,DF, DF, DF, DF, DF, DF, DF, + DF, RLN,DF, DF, DF, DF, DF, DF, DF, DF, + DF, DF, DF, DF, DF, DF, DF, DF +}; + +u16 cr_start[ISDN_MAX_CG] = {0}; +u8 cr_state[4096] = {0}; + +void isdn_cpc_proc(u32 pid); +int isdn_event_handle(u32 pid, u8 primitive);//, u8 eventType) +static int isdn_cc_nt(u32 pid); +static int isdn_cc_lt(u32 pid); +extern int isdn_send_msg(u32 pid, u8 msg_type); +extern int isdn_send_maintenance_msg(u32 pid, u8 msg_type); + + +/************************************************************* +Function: cr_sel +Description: according to port id, selection the idle call reference +Input: pid:port id, indicate the cic of the IUA link +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int cr_sel(u32 pid) +{ + u16 tmp_cr, i, byte_offset, circuit_id, cg_id; + u8 bit_offset, key; + const pal_circuit_struct *circuit_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + + cg_id = circuit_ptr->cg_id; + tmp_cr = (cr_start[cg_id] & 0x3FFF); + + for(i = 0; i < 0x3FFF; i++) + { + tmp_cr++; + tmp_cr &= 0x3FFF; + if(tmp_cr != 0) + { + tmp_cr = (tmp_cr | ((circuit_ptr->attrib.plat_id & 0x01) << 14)); + byte_offset = tmp_cr / 8; + bit_offset = tmp_cr % 8; + key = ((cr_state[byte_offset] >> bit_offset) & 0x01); + if(key == 0) + { + pPort->call_ref = (tmp_cr | 0x8000); //call_ref[pid] + cr_start[cg_id] = tmp_cr; + cr_state[byte_offset] = (cr_state[byte_offset] | (0x01 << bit_offset)); + return ISDN_CM_OK; + } + } + } + + return ISDN_CM_FAILED; +} + +/************************************************************* +Function: rel_cr +Description: release the call reference +Input: pid:port id +Return: ISDN_CM_OK:success +*************************************************************/ +int rel_cr(u32 pid) +{ + u16 tmp_cr, byte_offset; + u8 bit_offset; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + tmp_cr = (pPort->call_ref & 0x7FFF); + + if(pPort->call_ref & 0x8000) + { + byte_offset = tmp_cr / 8; + bit_offset = tmp_cr % 8; + cr_state[byte_offset] = (cr_state[byte_offset] ^ (0x01 << bit_offset)); + } + pPort->call_ref = 0; + pPort->callout_fg = 0; + //msg_cref[pid] = 0; + + return ISDN_CM_OK; +} + +/************************************************************* +Function: rel_B_chnl +Description: release B-channel link +Input: pid:port id +Return: ISDN_CM_OK:success +*************************************************************/ +int rel_B_chnl(u32 pid) +{ + u8 flag; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + flag = pPort->enable; + if (flag != 0) + { + pPort->enable = 0; + pPort->su_proc_id = 0; + pPort->cic_val = 0; + pPort->pre_send_msg = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_cpc_clear +Description: clearing the interrelated state of the call at call processing control +Output: pPort:port structure pointer +Return: NULL +*************************************************************/ +inline void isdn_cpc_clear(ISDN_Port_struct *pPort) +{ + pPort->timer_flag = 0; + pPort->cic_state.call_state = IDLE_FLAG; + pPort->fsm_state.cpc_state = NULL_STATE; +} + +/************************************************************* +Function: isdn_rel_proc +Description: release isdn module process, include rel_B_chnl() and rel_cr() +Input: pid:port id, cause:release reason value +Return: ISDN_CM_OK:success +*************************************************************/ +int isdn_rel_proc(u32 pid, u32 cause) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + isdn_event_handle(pid, ISDN_RELEASE_IND); + pPort->w_time = 0; + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return ISDN_CM_OK; +} + +/************************************************************* +Function: nr_proc +Description: processing nr, nr is the interval state identifier in the SDL diagrams +Input: pid:port id +Return: if LT side, successfully enter the state u19 + if NT side, successfully enter the state n19 +*************************************************************/ +int nr_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + pPort->w_time = 0; //start t308 + pPort->timeout_fg = 0; + isdn_send_msg(pid, MSG_REL); + return REL_REQ_STATE; +} + +/************************************************************* +Function: nd_proc +Description: processing nd, nd is the interval state identifier in the SDL diagrams +Input: pid:port id +Return: if LT side, successfully enter the state u12 + if NT side, successfully enter the state n11 +*************************************************************/ +int nd_proc(u32 pid) +{ + int circuit_id; + const pal_circuit_struct *circuit_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + { + isdn_log_err(pid, "nd_proc err!circuit_id %d can't find circuit_ptr", circuit_id); + return ISDN_CM_FAILED; + } + + /*disconnect B-channel*/ + pPort->w_time = 0; //stop all + isdn_event_handle(pid, ISDN_DISCONNECT_IND); + if(circuit_ptr->attrib.user_network_if) + return DISC_IND_STATE; + else + return DISC_REQ_STATE; +} + +/************************************************************* +Function: nc_proc +Description: processing nc, nc is the interval state identifier in the SDL diagrams +Input: pid:port id +Return: if LT side, successfully enter the state u11 + if NT side, successfully enter the state n12 +*************************************************************/ +int nc_proc(u32 pid) +{ + int circuit_id; + const pal_circuit_struct *circuit_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + { + isdn_log_err(pid, "nc_proc err!circuit_id %d can't find circuit_ptr", circuit_id); + return ISDN_CM_FAILED; + } + + /*disconnect B-channel*/ + pPort->w_time = 0; //stop all and start t305 + isdn_send_msg(pid, MSG_DISC); + if(circuit_ptr->attrib.user_network_if) + return DISC_REQ_STATE; + else + return DISC_IND_STATE; +} + +/************************************************************* +Function: isdn_set_cause +Description: set the reason value, and keep into cause_ptr +Input: val:reason value +Output: cause_ptr:cause structure pointer +Return: NULL +*************************************************************/ +void isdn_set_cause(CauseStr *cause_ptr, u8 val) +{ + cause_ptr->pres = 1; + cause_ptr->ext_flag = 0x0; + cause_ptr->b3.has_ext_a = 1; + cause_ptr->b3.code_stan = 0x0; //CCITT standardized coding + cause_ptr->b3.loc = cause_to_loc[val]; + cause_ptr->cause_val = val; +} + +/************************************************************* +Function: isdn_set_status +Description: set the call state, and keep into status_ptr +Input: state:call state, cause_val:reason value +Output: status_ptr:status structure pointer +Return: NULL +*************************************************************/ +void isdn_set_status(IsdnStatus *status_ptr, u8 state, u8 cause_val) +{ + isdn_set_cause(&status_ptr->cause, cause_val); + status_ptr->call_stat.code_stan = 0x0; + status_ptr->call_stat.stat_val = (state & 0x3F); +} + + +/************************************************************* +Function: n0_proc +Description: Null State, no call exists. + Handling the process and entering into next call state +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n0_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_SETUP_REQ) + { + pPort->primitive_cmd = 0; + if(cr_sel(pid) != 1) + { + isdn_log_err(pid, "cr_sel error!\r\n"); + return NULL_STATE; + } + isdn_send_msg(pid, MSG_SETUP); + pPort->timer_flag = CALLIN_FLAG; + pPort->w_time = 0; //start t303 + pPort->timeout_fg = 0; + return CALL_PRE_STATE; + } + else if(pPort->msg_cmd == MSG_SETUP) + { + pPort->msg_cmd = 0; + //pPort->call_ref = msg_cref[pid]; + isdn_event_handle(pid, ISDN_SETUP_IND); + return CALL_INIT_STATE; + } + //MSG_REL, MSG_REL_COMP, MSG_STATUS, and MSG_STAT_ENQ are doing in n0_ext_proc() + + return -1; +} + +/************************************************************* +Function: n1_proc +Description: Call initiated state, this state exists for an outgoing call + when the network has received a call establishment request + but has not yet responded. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n1_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_PROC_REQ) + { + pPort->primitive_cmd = 0; + /*Connect B-channel*/ + isdn_send_msg(pid, MSG_CALL_PROC); + return OUT_CALL_PROC_STATE; + } + else if(pPort->primitive_cmd == ISDN_MORE_INFO_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start t302 + /*Connect B-channel*/ + isdn_send_msg(pid, MSG_SETUP_ACK); + return OVERLAP_SD_STATE; + } + else if(pPort->primitive_cmd == ISDN_REJECT_REQ) + { + pPort->primitive_cmd = 0; + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + return NULL_STATE; + } + + return -1; +} + +/************************************************************* +Function: n2_proc +Description: Overlap sending state, this state exists for an outgoing call + when the network has acknowledged the call establishment request + and is prepared to receive additional call information (if any) + in overlap mode. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n2_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_PROC_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + isdn_send_msg(pid, MSG_CALL_PROC); + return OUT_CALL_PROC_STATE; + } + else if(pPort->msg_cmd == MSG_INFORMATION) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //start or restart t302 + isdn_event_handle(pid, ISDN_INFO_IND); + return OVERLAP_SD_STATE; + } + else if(pPort->primitive_cmd == ISDN_ALERT_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + isdn_send_msg(pid, MSG_ALERT); + return CALL_DV_STATE; + } + else if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + /* Connect Backwards B-channel Here */ + isdn_send_msg(pid, MSG_CONN); + return ACTIVE_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + isdn_send_msg(pid, MSG_PROG); + return OVERLAP_SD_STATE; + } + + return -1; +} + +/************************************************************* +Function: n3_proc +Description: Outgoing call proceeding state, this state exists for an outgoing call + when the network has sent acknowledgement that the network has received + all call information necessary to effect call establishment. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n3_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_ALERT_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_ALERT); + return CALL_DV_STATE; + } + else if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + /* Connect Backwards B-channel Here */ + isdn_send_msg(pid, MSG_CONN); + return ACTIVE_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_PROG); + return OUT_CALL_PROC_STATE; + } + + return -1; +} + +/************************************************************* +Function: n4_proc +Description: Call delivered state, this state exists for an outgoing call + when the network has indicated that remote user alerting + has been initiated. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n4_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + /* Connect Backwards B-channel Here */ + isdn_send_msg(pid, MSG_CONN); + return ACTIVE_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_PROG); + return CALL_DV_STATE; + } + + return -1; +} + +/************************************************************* +Function: n6_proc +Description: Call present state, this state exists for an incoming call + when the network has sent a call establishment request + but has not yet received a satisfactory response. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n6_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CALL_PROC) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 and start t310 + isdn_event_handle(pid, ISDN_PROC_IND); + return IN_CALL_PROC_STATE; + } + else if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 and start t301 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_RV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 + pPort->primitive_cmd = ISDN_SETUP_CNF; //msc does not provide ISDN_SETUP_COMP_REQ to isdn + isdn_event_handle(pid, ISDN_SETUP_CNF); + return CONN_REQ_STATE; + } + else if(pPort->msg_cmd == MSG_SETUP_ACK) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 and start t304 + isdn_event_handle(pid, ISDN_MORE_INFO_IND); + return OVERLAP_RV_STATE; + } + else if(pPort->msg_cmd == MSG_REL_COMP) //do it temporarily in isdn_comm_ctrl() + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 +// isdn_event_handle(pid, ISDN_REJ_IND); + rel_B_chnl(pid); + rel_cr(pid); + return NULL_STATE; + } + + return -1; +} + +/************************************************************* +Function: n7_proc +Description: Call received state, this state exists for an incoming call + when the network has received an indication that the user is alerting + but has not yet received an answer. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n7_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t301 + pPort->primitive_cmd = ISDN_SETUP_CNF; //msc does not provide ISDN_SETUP_COMP_REQ to isdn + isdn_event_handle(pid, ISDN_SETUP_CNF); + return CONN_REQ_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) //support U04_09 + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 + isdn_event_handle(pid, ISDN_PROG_IND); + return CALL_DV_STATE; + } + + return -1; +} + +/************************************************************* +Function: n8_proc +Description: Connect request state, this state exists for an incoming call + when the network has received an answer but the network has not yet + awarded the call. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n8_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_SETUP_COMP_REQ) + { + pPort->primitive_cmd = 0; + /* Connect Backwards B-channel Here */ + isdn_send_msg(pid, MSG_CONNACK); + return ACTIVE_STATE; + } + + return -1; +} + +/************************************************************* +Function: n9_proc +Description: Incoming call proceeding state, this state exists for an incoming call + when the network has received acknowledgement that the user has received + all call information necessary to effect call establishment. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n9_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 and start t301 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_RV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 + pPort->primitive_cmd = ISDN_SETUP_CNF; //msc does not provide ISDN_SETUP_COMP_REQ to isdn + isdn_event_handle(pid, ISDN_SETUP_CNF); + return CONN_REQ_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_PROG_IND); + return IN_CALL_PROC_STATE; + } + + return -1; +} + +/************************************************************* +Function: n10_proc +Description: Active state, this state exists for an incoming call + when the network has awarded the call to the called user, and + this state exists for an outgoing call when the network has indicated + that the remote user has answered the call. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n10_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CONNACK) + { + pPort->msg_cmd = 0; + return ACTIVE_STATE; + } + else if(pPort->msg_cmd == MSG_NOTI) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_NOTI_IND); + return ACTIVE_STATE; + } + else if(pPort->primitive_cmd == ISDN_NOTI_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_NOTI); + return ACTIVE_STATE; + } + + return -1; +} + +/************************************************************* +Function: n11_proc +Description: Disconnect request state, this state exists when the network has received + a request from the user to clear the end-to-end connection (if any). + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n11_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_RELEASE_REQ) + { + pPort->primitive_cmd = 0; + return nr_proc(pid); //REL_REQ_STATE; + } + else if(pPort->msg_cmd == MSG_REL) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop all + memcpy(&isdn_sd_msg.msg_list.relComp.cause, &isdn_rv_msg.msg_list.rel.cause, sizeof(CauseStr)); + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + + return -1; +} + +/************************************************************* +Function: n12_proc +Description: Disconnect indication state, this state exists when the network has + disconnected the end-to-end connection (if any) and has sent an + invitation to disconnect the user-network connection. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n12_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_DISC) + { + pPort->msg_cmd = 0; + memcpy(&isdn_sd_msg.msg_list.rel.cause, &isdn_rv_msg.msg_list.disc.cause, sizeof(CauseStr)); + return nr_proc(pid); //REL_REQ_STATE + } + else if(pPort->msg_cmd == MSG_REL) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t305 or t306 + memcpy(&isdn_sd_msg.msg_list.relComp.cause, &isdn_rv_msg.msg_list.rel.cause, sizeof(CauseStr)); +// isdn_event_handle(pid, ISDN_RELEASE_IND); + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + + return -1; +} + +/************************************************************* +Function: n19_proc +Description: Release request state, this state exists when the network has + requested the user to release and is waiting for a response. + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n19_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if((pPort->msg_cmd == MSG_REL_COMP) + || (pPort->msg_cmd == MSG_REL)) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t308 + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + else if(pPort->msg_cmd == MSG_STATUS) + { + pPort->msg_cmd = 0; + if(isdn_rv_msg.msg_list.status.call_stat.stat_val != 0) + return REL_REQ_STATE; + pPort->w_time = 0; //stop t308 + isdn_event_handle(pid, ISDN_STAT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + + return -1; +} + +/************************************************************* +Function: n25_proc +Description: Overlap receiving state, this state exists for an incoming call + when the network has received acknowledgement of the call + establishment request which permits the network to send + additional call information (if any) in the overlap mode + Handling the process and entering into next call state. +Input: pid:port id +Return: state value:success + -1:failed +*************************************************************/ +int n25_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_INFO_REQ) //ISDN_MORE_INFO_REQ + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start or restart t304 + isdn_send_msg(pid, MSG_INFORMATION); + return OVERLAP_RV_STATE; + } + else if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 and start t301 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_RV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 + pPort->primitive_cmd = ISDN_SETUP_CNF; //msc does not provide ISDN_SETUP_COMP_REQ to isdn + isdn_event_handle(pid, ISDN_SETUP_CNF); + return CONN_REQ_STATE; + } + else if(pPort->msg_cmd == MSG_CALL_PROC) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 and start t310 + isdn_event_handle(pid, ISDN_PROC_IND); + return IN_CALL_PROC_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_PROG_IND); + return OVERLAP_RV_STATE; + } + + return -1; +} + + +/*user side state processing*/ +int u0_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_SETUP_REQ) + { + pPort->primitive_cmd = 0; + if(cr_sel(pid) != 1) + { + isdn_log_err(pid, "cr_sel error!\r\n"); + return NULL_STATE; + } + isdn_send_msg(pid, MSG_SETUP); + pPort->timer_flag = CALLOUT_FLAG; + pPort->w_time = 0; //start t303 + pPort->timeout_fg = 0; + return CALL_INIT_STATE; + } + else if(pPort->msg_cmd == MSG_SETUP) + { + pPort->msg_cmd = 0; + //pPort->call_ref = msg_cref[pid]; + isdn_event_handle(pid, ISDN_SETUP_IND); + return CALL_PRE_STATE; + } + + return -1; +} + +int u1_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_SETUP_ACK) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 and start t304 + isdn_event_handle(pid, ISDN_MORE_INFO_IND); + return OVERLAP_SD_STATE; + } + else if(pPort->msg_cmd == MSG_CALL_PROC) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 and start t310 + isdn_event_handle(pid, ISDN_PROC_IND); + return OUT_CALL_PROC_STATE; + } + else if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_DV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 + isdn_event_handle(pid, ISDN_SETUP_CNF); + isdn_send_msg(pid, MSG_CONNACK); + return ACTIVE_STATE; + } + else if(pPort->msg_cmd == MSG_REL_COMP) //do it temporarily in isdn_comm_ctrl() + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t303 + //isdn_event_handle(pid, ISDN_REJ_IND); + rel_cr(pid); + return NULL_STATE; + } + + return -1; +} + +int u2_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CALL_PROC) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 and start t310 + isdn_event_handle(pid, ISDN_PROC_IND); + return OUT_CALL_PROC_STATE; + } + else if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_DV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 + isdn_event_handle(pid, ISDN_SETUP_CNF); + isdn_send_msg(pid, MSG_CONNACK); + return ACTIVE_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t304 + isdn_event_handle(pid, ISDN_PROG_IND); + return OVERLAP_SD_STATE; + } + else if(pPort->primitive_cmd == ISDN_INFO_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start or restart t304 + isdn_send_msg(pid, MSG_INFORMATION); + return OVERLAP_SD_STATE; + } + + return -1; +} + +int u3_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_ALERT) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 and start t301 + isdn_event_handle(pid, ISDN_ALERT_IND); + return CALL_DV_STATE; + } + else if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 + isdn_event_handle(pid, ISDN_SETUP_CNF); + isdn_send_msg(pid, MSG_CONNACK); + return ACTIVE_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 + isdn_event_handle(pid, ISDN_PROG_IND); + return OUT_CALL_PROC_STATE; + } + + return -1; +} + +int u4_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CONN) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_SETUP_CNF); + isdn_send_msg(pid, MSG_CONNACK); + return ACTIVE_STATE; + } + else if(pPort->msg_cmd == MSG_PROG) //support U04_09 + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t310 + isdn_event_handle(pid, ISDN_PROG_IND); + return CALL_DV_STATE; + } + + return -1; +} + +int u6_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_MORE_INFO_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start t302 + isdn_send_msg(pid, MSG_SETUP_ACK); + return OVERLAP_RV_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROC_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_CALL_PROC); + return IN_CALL_PROC_STATE; + } + else if(pPort->primitive_cmd == ISDN_ALERT_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_ALERT); + return CALL_RV_STATE; + } + else if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start t313 + isdn_send_msg(pid, MSG_CONN); + return CONN_REQ_STATE; + } + else if(pPort->primitive_cmd == ISDN_REJECT_REQ) + { + pPort->primitive_cmd = 0; + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + return NULL_STATE; + } + + return -1; +} + +int u7_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start t313 + isdn_send_msg(pid, MSG_CONN); + return CONN_REQ_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_PROG); + return CALL_DV_STATE; + } + + return -1; +} + +int u8_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_CONNACK) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t313 + isdn_event_handle(pid, ISDN_SETUP_COMP_IND); + return ACTIVE_STATE; + } + + return -1; +} + +int u9_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->primitive_cmd == ISDN_ALERT_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_ALERT); + return CALL_RV_STATE; + } + else if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //start t313 + isdn_send_msg(pid, MSG_CONN); + return CONN_REQ_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_PROG); + return IN_CALL_PROC_STATE; + } + + return -1; +} + +int u10_proc(u32 pid) //?? add by gengxin +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_NOTI) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_NOTI_IND); + return ACTIVE_STATE; + } + else if(pPort->primitive_cmd == ISDN_NOTI_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_NOTI); + return ACTIVE_STATE; + } + + return -1; +} + +int u11_proc(u32 pid) //0911 +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_DISC) + { + pPort->msg_cmd = 0; + memcpy(&isdn_sd_msg.msg_list.rel.cause, &isdn_rv_msg.msg_list.disc.cause, sizeof(CauseStr)); + return nr_proc(pid); + } + else if(pPort->msg_cmd == MSG_REL) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t305 + memcpy(&isdn_sd_msg.msg_list.relComp.cause, &isdn_rv_msg.msg_list.rel.cause, sizeof(CauseStr)); +// isdn_event_handle(pid, ISDN_RELEASE_IND); + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + + return -1; +} + +int u12_proc(u32 pid) //0911 +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_REL) + { + pPort->msg_cmd = 0; + memcpy(&isdn_sd_msg.msg_list.relComp.cause, &isdn_rv_msg.msg_list.rel.cause, sizeof(CauseStr)); +// isdn_event_handle(pid, ISDN_RELEASE_IND); + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + else if(pPort->primitive_cmd == ISDN_RELEASE_REQ) + { + pPort->primitive_cmd = 0; + return nr_proc(pid); + } + + return -1; +} + +int u19_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if((pPort->msg_cmd == MSG_REL_COMP) || + (pPort->msg_cmd == MSG_REL)) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_RELEASE_CNF); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + else if(pPort->msg_cmd == MSG_STATUS) + { + pPort->msg_cmd = 0; + if(isdn_rv_msg.msg_list.status.call_stat.stat_val != 0) + return REL_REQ_STATE; + isdn_event_handle(pid, ISDN_STAT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + + return -1; +} + +int u25_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_INFORMATION) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //start t302 + isdn_event_handle(pid, ISDN_INFO_IND); + return OVERLAP_RV_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROC_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + isdn_send_msg(pid, MSG_CALL_PROC); + return IN_CALL_PROC_STATE; + } + else if(pPort->primitive_cmd == ISDN_ALERT_REQ) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 + isdn_send_msg(pid, MSG_ALERT); + return CALL_RV_STATE; + } + else if(pPort->primitive_cmd == ISDN_SETUP_RSP) + { + pPort->primitive_cmd = 0; + pPort->w_time = 0; //stop t302 and start t313 + isdn_send_msg(pid, MSG_CONN); + return CONN_REQ_STATE; + } + else if(pPort->primitive_cmd == ISDN_PROG_REQ) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_PROG); + return OVERLAP_RV_STATE; + } + + return -1; +} + + +/* Global Call Reference Procedures */ +/************************************************************* +Function: trans_callref_sd_rest_req +Description: +Input: +Output: +Return: +*************************************************************/ +int trans_callref_sd_rest_req(u32 pid, u8 g_pri_cmd) //isdn_restart_req() +{ + int i, link_id, cic_range; + u16 circuit_id; + const pal_circuit_struct *circuit_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + + link_id = circuit_ptr->attrib.link_id; + cic_range = circuit_ptr->attrib.cic_range; + if(cic_range == 24) //T1 + cic_range++; + if(isdn_rs.link_pond[link_id].restart_clas == 0) //indicated channels + { + if(pPort->cic_val != 0) + { + pid = find_port_by_cic(pPort->cic_val, circuit_id); + pPort = &isdn_rs.port_pond[pid]; + if(g_pri_cmd == ISDN_RESTART_REQ) + { + pPort->g_pri_cmd = ISDN_RESTART_REQ; + isdn_cpc_proc(pid); + if(pPort->g_pri_cmd != 0 && pPort->g_pri_cmd != ISDN_RESTART_CNF) + { + isdn_trace_func(pid, "[waring]primitive cmd discard.(cmd=%d)\r\n", pPort->primitive_cmd); + pPort->g_pri_cmd = 0; + } + return circuit_ptr->attrib.cic_range; + } + else if(g_pri_cmd == ISDN_RESTART_CNF) + { + if(pPort->g_pri_cmd != g_pri_cmd) + { + pPort->g_pri_cmd = 0; + isdn_trace_func(pid, "[waring]primitive cmd is not ISDN_RESTART_CNF.(cmd=%d)\r\n", pPort->primitive_cmd); + return ISDN_CM_FAILED; + } + pPort->g_pri_cmd = 0; + return circuit_ptr->attrib.cic_range; + } + } + } + else if(isdn_rs.link_pond[link_id].restart_clas == 6) //single interface + { + for(i = 1; i < cic_range; i++) + { + pid = circuit_id * ISDN_CIRCUIT_CIC + i; + pPort = &isdn_rs.port_pond[pid]; + if(pPort->enable != 0) + { + if(g_pri_cmd == ISDN_RESTART_REQ) + { + pPort->g_pri_cmd = ISDN_RESTART_REQ; + isdn_cpc_proc(pid); + if(pPort->g_pri_cmd != 0 && pPort->g_pri_cmd != ISDN_RESTART_CNF) + { + isdn_trace_func(pid, "[waring]primitive cmd discard.(cmd=%d)\r\n", pPort->primitive_cmd); + pPort->g_pri_cmd = 0; + } + } + else if(g_pri_cmd == ISDN_RESTART_CNF) + { + if(pPort->g_pri_cmd != g_pri_cmd) + { + pPort->g_pri_cmd = 0; + isdn_trace_func(pid, "[waring]primitive cmd is not ISDN_RESTART_CNF.(cmd=%d)\r\n", pPort->primitive_cmd); + return ISDN_CM_FAILED; + } + pPort->g_pri_cmd = 0; + } + } + } +// isdn_rs.link_pond[link_id].restart_clas = 0; + return circuit_ptr->attrib.cic_range; + } + + return ISDN_CM_FAILED; +} + +static inline void restart_clear(u32 pid) +{ + int i, link_id, cic_range; + u16 circuit_id = pid / ISDN_CIRCUIT_CIC; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + if(circuit_ptr == NULL) + return; + + link_id = circuit_ptr->attrib.link_id; + cic_range = circuit_ptr->attrib.cic_range; + if(cic_range == 24) //T1 + cic_range++; + if(isdn_rs.link_pond[link_id].restart_clas == 0) //indicated channels + { + pid = find_port_by_cic(pPort->cic_val, circuit_id); + pPort->cic_val = 0; + rel_B_chnl(pid); + isdn_cpc_clear(pPort); + } + else + { + isdn_rs.link_pond[link_id].restart_clas = 0; + for(i = 1; i < cic_range; i++) + { + pid = circuit_id * ISDN_CIRCUIT_CIC + i; + pPort = &isdn_rs.port_pond[pid]; + if(pPort->enable != 0) + { + rel_B_chnl(pid); + isdn_cpc_clear(pPort); + } + } + } +} + +int rest0_proc(u32 pid, IsdnRestart *restart) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_RESTART) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //start t317 + memcpy(restart, &isdn_rv_msg.msg_list.restart, sizeof(IsdnRestart)); + trans_callref_sd_rest_req(pid, ISDN_RESTART_REQ); + return GLOBAL_RESTART_STATE; + } + else if(pPort->g_pri_cmd == ISDN_M_RESTART_REQ) + { + pPort->g_pri_cmd = 0; + pPort->timeout_fg = 0; + pPort->w_time = 0; //start t316 + isdn_send_msg(pid, MSG_RESTART); + trans_callref_sd_rest_req(pid, ISDN_RESTART_REQ); + return GLOBAL_RESTART_REQ_STATE; + } + + return -1; +} + +int rest1_proc(u32 pid) +{ + static int rest_resp_on = 0; //?? + static int rest_ack_on = 0; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->msg_cmd == MSG_REST_ACK) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t316 + if(rest_resp_on) + { + rest_resp_on = 0; + restart_clear(pid); + return GLOBAL_NULL_STATE; + } + else + rest_ack_on = 1; + } + else if(pPort->g_pri_cmd == ISDN_RESTART_CNF) + { + pPort->g_pri_cmd = 0; + if(rest_ack_on) + { + rest_ack_on = 0; + restart_clear(pid); + return GLOBAL_NULL_STATE; + } + else + rest_resp_on = 1; + } + else if(pPort->msg_cmd == MSG_RESTART) + { + pPort->msg_cmd = 0; + trans_callref_sd_rest_req(pid, ISDN_RESTART_REQ); + return GLOBAL_RESTART_STATE; + } + + return -1; +} + +int rest2_proc(u32 pid, IsdnRestart restart) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + if(pPort->g_pri_cmd == ISDN_RESTART_CNF) + { + pPort->g_pri_cmd = 0; + pPort->w_time = 0; + memcpy(&isdn_sd_msg.msg_list.restAck, (IsdnRestAck *)&restart, sizeof(IsdnRestAck)); + isdn_send_msg(pid, MSG_REST_ACK); + restart_clear(pid); + return GLOBAL_NULL_STATE; + } + else if(pPort->msg_cmd == MSG_RESTART) + { + pPort->msg_cmd = 0; + trans_callref_sd_rest_req(pid, ISDN_RESTART_REQ); + return GLOBAL_RESTART_STATE; + } + + return -1; +} + +void isdn_restart_ctrl(u32 pid) +{ + int num = 0; + static IsdnRestart restart; + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(pid / ISDN_CIRCUIT_CIC); + if(circuit_ptr == NULL) + return; + + switch(pPort->cic_state.call_state) + { + case CALLOUT_FLAG: + case CALLIN_FLAG: + case GLOBAL_NULL_STATE: + switch(rest0_proc(pid, &restart)) + { + case GLOBAL_RESTART_REQ_STATE: + pPort->cic_state.call_state = GLOBAL_RESTART_REQ_STATE; + break; + case GLOBAL_RESTART_STATE: + pPort->cic_state.call_state = GLOBAL_RESTART_STATE; + break; + default: + break; + } + break; + case GLOBAL_RESTART_REQ_STATE: + switch(rest1_proc(pid)) + { + case GLOBAL_NULL_STATE: + pPort->cic_state.call_state = GLOBAL_NULL_STATE; + break; + case GLOBAL_RESTART_STATE: + pPort->cic_state.call_state = GLOBAL_RESTART_STATE; + break; + default: + break; + } + break; + case GLOBAL_RESTART_STATE: + switch(rest2_proc(pid, restart)) + { + case GLOBAL_NULL_STATE: + pPort->cic_state.call_state = GLOBAL_NULL_STATE; + break; + case GLOBAL_RESTART_STATE: + pPort->cic_state.call_state = GLOBAL_RESTART_STATE; + break; + default: + break; + } + break; + default: + break; + } + +// printf("global state = 0x%02x\n",pPort->cic_state.call_state); + if(pPort->g_pri_cmd == ISDN_RESTART_REQ) + { + pPort->g_pri_cmd = 0; + if(pPort->cic_state.call_state == GLOBAL_RESTART_STATE) + memcpy(&isdn_sd_msg.msg_list.restAck, &isdn_rv_msg.msg_list.restart, sizeof(IsdnRestart)); + if((num = trans_callref_sd_rest_req(pid, ISDN_RESTART_CNF)) == circuit_ptr->attrib.cic_range) + pPort->g_pri_cmd = ISDN_RESTART_CNF; +// isdn_restart_ctrl(pid); + } + else if(pPort->g_pri_cmd != 0) + { + isdn_log_err(pid, "global g_pri_cmd = 0x%x\r\n", pPort->g_pri_cmd); + pPort->g_pri_cmd = 0; + } + + if(pPort->msg_cmd != 0) + { + isdn_log_err(pid, "global msg_cmd = 0x%x\r\n", pPort->msg_cmd); + pPort->msg_cmd = 0; + isdn_set_status(&isdn_sd_msg.msg_list.status, pPort->cic_state.call_state, CAUSE_INVALID_CR); //cause 81 + isdn_send_msg(pid, MSG_STATUS); + } + +} + + +/************************************************************* +Function: not_isdn_rel_st +Description: Handling state is isdn release state or not +Input: state:call state +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +static int not_isdn_rel_st(u8 state) +{ + if((state != NULL_STATE) && + (state != DISC_REQ_STATE) && + (state != DISC_IND_STATE) && + (state != REL_REQ_STATE)) + return ISDN_CM_OK; + else + return ISDN_CM_FAILED; +} + +/************************************************************* +Function: isdn_comm_ctrl +Description: ISDN Protocol Common Control +Input: pid:port id +Return: state value:success +*************************************************************/ +u8 isdn_comm_ctrl(u32 pid) +{ + u8 state, msg_cmd, pri_cmd, g_pri_cmd; + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(pid / ISDN_CIRCUIT_CIC); + if(circuit_ptr == NULL) + { + isdn_log_err(pid, "isdn_comm_ctrl err! circuit_id %d can't find circuit_ptr!\r\n",pid/ISDN_CIRCUIT_CIC); + return ISDN_CM_FAILED; + } + + state = pPort->fsm_state.cpc_state; + msg_cmd = pPort->msg_cmd; + pri_cmd = pPort->primitive_cmd; + g_pri_cmd = pPort->g_pri_cmd; + if(not_isdn_rel_st(state)) + { + if(msg_cmd == MSG_DISC) + { + pPort->msg_cmd = 0; + if(state != ACTIVE_STATE) + { + isdn_log_err(pid, "isdn_comm_ctrl err1!\r\n"); + } + return nd_proc(pid); + } + else if(pri_cmd == ISDN_DISCONNECT_REQ) + { + pPort->primitive_cmd = 0; + if(state != ACTIVE_STATE) + { + isdn_log_err(pid, "isdn_comm_ctrl err2!\r\n"); + } + return nc_proc(pid); + } + else if(pri_cmd == ISDN_RELEASE_REQ) + { + pPort->primitive_cmd = 0; + isdn_log_err(pid, "isdn_comm_ctrl err3, rv release req!\r\n"); + return nr_proc(pid); + } + else if(msg_cmd == MSG_REL) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop all + isdn_log_err(pid, "isdn_comm_ctrl err4, rv rel!\r\n"); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_B_chnl(pid); +// memcpy(&isdn_sd_msg.msg_list.relComp, &isdn_rv_msg.msg_list.rel, sizeof(IsdnRel)); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + } + + if((state != NULL_STATE) && (state != REL_REQ_STATE)) + { + if(msg_cmd == MSG_STATUS) + { + pPort->msg_cmd = 0; + if(isdn_rv_msg.msg_list.status.call_stat.stat_val == 0) + { + isdn_log_err(pid, "isdn_comm_ctrl err5, rv status with null state!\r\n"); + isdn_event_handle(pid, ISDN_STAT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + else if(isdn_rv_msg.msg_list.status.call_stat.stat_val != state) + { + isdn_log_err(pid, "isdn_comm_ctrl err5, rv status with no compatible state!\r\n"); + if(state == ACTIVE_STATE) + { + isdn_send_msg(pid, MSG_STAT_ENQ); + return ACTIVE_STATE; + } + isdn_set_cause(&isdn_rv_msg.msg_list.rel.cause, CAUSE_MSG_NOTCOMP_NOTIMPL); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_MSG_NOTCOMP_NOTIMPL); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_B_chnl(pid); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + //cs != 0 discard msg + } + else if(msg_cmd == MSG_REL_COMP) + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "isdn_comm_ctrl err6, rv rel comp!\r\n"); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + return NULL_STATE; + } + else if(msg_cmd == MSG_INFORMATION) + { + if(state != CALL_INIT_STATE && + state != CALL_PRE_STATE && + ((state != OVERLAP_RV_STATE && circuit_ptr->attrib.user_network_if == USER_SIDE) || + (state != OVERLAP_SD_STATE && circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_INFO_IND); + } + } + else if(pri_cmd == ISDN_INFO_REQ) + { + if(state != CALL_INIT_STATE && + state != CALL_PRE_STATE && + ((state != OVERLAP_SD_STATE && circuit_ptr->attrib.user_network_if == USER_SIDE) || + (state != OVERLAP_RV_STATE && circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + { + pPort->primitive_cmd = 0; + isdn_send_msg(pid, MSG_INFORMATION); + } + } + } + + if(msg_cmd == MSG_STAT_ENQ) + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "isdn_comm_ctrl err7, rv status enq!\r\n"); + isdn_set_status(&isdn_sd_msg.msg_list.status, state, CAUSE_STAT_ENQ); + isdn_send_msg(pid, MSG_STATUS); + } + + if(g_pri_cmd == ISDN_RESTART_REQ) //restart_request + { + pPort->g_pri_cmd = 0; + pPort->w_time = 0; + isdn_log_err(pid, "isdn_comm_ctrl err8, rv restart req!\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.rel.cause, CAUSE_TEMP_FAIL); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_cr(pid); + pPort->g_pri_cmd = ISDN_RESTART_CNF; +// isdn_event_handle(pid, ISDN_RESTART_CNF); //0411 + return NULL_STATE; + } + + /* DL Primitive -- Not Implemented Yet */ + return state; +} + +static void isdn_cpc_nt_proc(u32 pid) +/* +isdn状态机,包含n1 ...n25状态 +*/ +{ + int state; + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + + state = isdn_comm_ctrl(pid); + if(state == pPort->fsm_state.cpc_state) + { + switch(state) + { + case NULL_STATE: + switch(n0_proc(pid)) + { + case CALL_INIT_STATE: + state = CALL_INIT_STATE; + break; + case CALL_PRE_STATE: + state = CALL_PRE_STATE; + break; + default: + break; + } + break; + case CALL_INIT_STATE: + switch(n1_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case OVERLAP_SD_STATE: + state = OVERLAP_SD_STATE; + break; + case OUT_CALL_PROC_STATE: + state = OUT_CALL_PROC_STATE; + break; + default: + break; + } + break; + case OVERLAP_SD_STATE: + switch(n2_proc(pid)) + { + case OUT_CALL_PROC_STATE: + state = OUT_CALL_PROC_STATE; + break; + case CALL_DV_STATE: + state = CALL_DV_STATE; + break; + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case OUT_CALL_PROC_STATE: + switch(n3_proc(pid)) + { + case CALL_DV_STATE: + state = CALL_DV_STATE; + break; + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case CALL_DV_STATE: + switch(n4_proc(pid)) + { + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case CALL_PRE_STATE: + switch(n6_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + case IN_CALL_PROC_STATE: + state = IN_CALL_PROC_STATE; + break; + case OVERLAP_RV_STATE: + state = OVERLAP_RV_STATE; + break; + default: + break; + } + break; + case CALL_RV_STATE: + switch(n7_proc(pid)) + { + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + default: + break; + } + break; + case CONN_REQ_STATE: + switch(n8_proc(pid)) + { + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case IN_CALL_PROC_STATE: + switch(n9_proc(pid)) + { + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + default: + break; + } + break; + case ACTIVE_STATE: + switch(n10_proc(pid)) + { + case -1: + break; + default: + break; + } + break; + case DISC_REQ_STATE: + switch(n11_proc(pid)) + { + case REL_REQ_STATE: + state = REL_REQ_STATE; + break; + default: + break; + } + break; + case DISC_IND_STATE: + switch(n12_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case REL_REQ_STATE: + state = REL_REQ_STATE; + break; + default: + break; + } + break; + case REL_REQ_STATE: + switch(n19_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + default: + break; + } + break; + case OVERLAP_RV_STATE: + switch(n25_proc(pid)) + { + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + case IN_CALL_PROC_STATE: + state = IN_CALL_PROC_STATE; + break; + default: + break; + } + break; + + default: + break; + } + } + +// printf("nt state = 0x%02x\n",state); + pPort->fsm_state.cpc_state = state; + + isdn_cc_nt(pid); + + //unexpected message and send_isdn_msg(status) //u03-04 u03-05 u01-03 + if(pPort->msg_cmd != 0) + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "isdn_cpc_nt_proc, receive msg=0x02%x, not handle!\r\n"); + isdn_set_status(&isdn_sd_msg.msg_list.status, pPort->fsm_state.cpc_state, CAUSE_MSG_NOTCOMP); //cause 98 101 + isdn_send_msg(pid, MSG_STATUS); + } + + return; +} + +static void isdn_cpc_lt_proc(u32 pid) +{ + int state; + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + + state = isdn_comm_ctrl(pid); + if(state == pPort->fsm_state.cpc_state) + { + switch(state) + { + case NULL_STATE: + switch(u0_proc(pid)) + { + case CALL_INIT_STATE: + state = CALL_INIT_STATE; + break; + case CALL_PRE_STATE: + state = CALL_PRE_STATE; + default: + break; + } + break; + case CALL_INIT_STATE: + switch(u1_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case OVERLAP_SD_STATE: + state = OVERLAP_SD_STATE; + break; + case OUT_CALL_PROC_STATE: + state = OUT_CALL_PROC_STATE; + break; + case CALL_DV_STATE: + state = CALL_DV_STATE; + break; + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case OVERLAP_SD_STATE: + switch(u2_proc(pid)) + { + case OUT_CALL_PROC_STATE: + state = OUT_CALL_PROC_STATE; + break; + case CALL_DV_STATE: + state = CALL_DV_STATE; + break; + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case OUT_CALL_PROC_STATE: + switch(u3_proc(pid)) + { + case CALL_DV_STATE: + state = CALL_DV_STATE; + break; + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case CALL_DV_STATE: + switch(u4_proc(pid)) + { + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case CALL_PRE_STATE: + switch(u6_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + case IN_CALL_PROC_STATE: + state = IN_CALL_PROC_STATE; + break; + case OVERLAP_RV_STATE: + state = OVERLAP_RV_STATE; + break; + default: + break; + } + break; + case CALL_RV_STATE: + switch(u7_proc(pid)) + { + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + default: + break; + } + break; + case CONN_REQ_STATE: + switch(u8_proc(pid)) + { + case ACTIVE_STATE: + state = ACTIVE_STATE; + break; + default: + break; + } + break; + case IN_CALL_PROC_STATE: + switch(u9_proc(pid)) + { + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + default: + break; + } + break; + case ACTIVE_STATE: + switch(u10_proc(pid)) + { + case -1: + break; + default: + break; + } + break; + case DISC_REQ_STATE: + switch(u11_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case REL_REQ_STATE: + state = REL_REQ_STATE; + break; + default: + break; + } + break; + case DISC_IND_STATE: + switch(u12_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + case REL_REQ_STATE: + state = REL_REQ_STATE; + break; + default: + break; + } + break; + case REL_REQ_STATE: + switch(u19_proc(pid)) + { + case NULL_STATE: + state = NULL_STATE; + break; + default: + break; + } + break; + case OVERLAP_RV_STATE: + switch(u25_proc(pid)) + { + case CALL_RV_STATE: + state = CALL_RV_STATE; + break; + case CONN_REQ_STATE: + state = CONN_REQ_STATE; + break; + case IN_CALL_PROC_STATE: + state = IN_CALL_PROC_STATE; + break; + default: + break; + } + break; + default: + break; + } + } + +// printf("lt state = 0x%02x\n",state); + pPort->fsm_state.cpc_state = state; + + isdn_cc_lt(pid); + + //unexpected message and send_isdn_msg(status) //u03-04 u01-03 + if(pPort->msg_cmd != 0) + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "isdn_cpc_lt_proc, receive msg=0x02%x, not handle!\r\n"); + isdn_set_status(&isdn_sd_msg.msg_list.status, pPort->fsm_state.cpc_state, CAUSE_MSG_NOTCOMP); //cause 98 101 + isdn_send_msg(pid, MSG_STATUS); + } + + return; +} + +void isdn_cpc_proc(u32 pid) +{ + int circuit_id = pid / ISDN_CIRCUIT_CIC; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return; + + if(circuit_ptr->attrib.user_network_if) + isdn_cpc_lt_proc(pid); + else + isdn_cpc_nt_proc(pid); +} + +static int isdn_cc_nt(u32 pid) +{ + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + + switch(pPort->fsm_state.cpc_state) + { + case CONN_REQ_STATE: + if(pPort->primitive_cmd == ISDN_SETUP_CNF) //msc does not provide ISDN_SETUP_COMP_REQ to isdn + { + pPort->primitive_cmd = ISDN_SETUP_COMP_REQ; + isdn_cpc_nt_proc(pid); + } + break; + case DISC_REQ_STATE: + break; + default: + break; + } + if(pPort->primitive_cmd != 0) + { + pPort->primitive_cmd = 0; + isdn_log_err(pid, "isdn_cc_nt, primitive err!\r\n"); + return ISDN_CM_FAILED; + } + + return ISDN_CM_OK; +} + +static int isdn_cc_lt(u32 pid) +{ + ISDN_Port_struct *pPort = &(isdn_rs.port_pond[pid]); + + switch(pPort->fsm_state.cpc_state) + { + case DISC_IND_STATE: + break; + default: + break; + } + if(pPort->primitive_cmd != 0) + { + pPort->primitive_cmd = 0; + isdn_log_err(pid, "isdn_cc_lt, primitive err!\r\n"); + return ISDN_CM_FAILED; + } + + return ISDN_CM_OK; +} + +static void isdn_cpc_nt_timer(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + switch(pPort->fsm_state.cpc_state) + { + case OVERLAP_SD_STATE: +// if((++(pPort->w_time)) % (isdn_timer_var.t302) == 0) +// { +// pPort->w_time = 0; +// isdn_log_err(pid, "[timeout]: NT OVERLAP SD STATE\r\n"); +// isdn_event_handle(pid, ISDN_TIMEOUT_IND); +// } + break; + case CALL_PRE_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t303) == 0) + { + pPort->w_time = 0; + if(pPort->timeout_fg == 0) + { + pPort->timeout_fg = 1; + isdn_log_err(pid, "[timeout]:t303 NT CALL PRE STATE first timeout, resend SETUP\r\n"); + isdn_send_msg(pid, MSG_SETUP); + } + else + { + isdn_log_err(pid, "[timeout]:t303 NT CALL PRE STATE second timeout, clear call!\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_B_chnl(pid); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_TIMER_EXPIRY); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + break; + case CALL_RV_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t301) == 0) + { + pPort->w_time = 0; + isdn_log_err(pid, "[timeout]:t301 NT CALL RV STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case IN_CALL_PROC_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t310) == 0) + { + pPort->w_time = 0; + isdn_log_err(pid, "[timeout]:t310 NT IN CALL PROC STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case DISC_IND_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t305) == 0) + { + isdn_log_err(pid, "[timeout]:t305 NT DISC IND STATE\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + nr_proc(pid); + pPort->fsm_state.cpc_state = REL_REQ_STATE; + } + break; + case REL_REQ_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t308) == 0) + { + pPort->w_time = 0; + if(pPort->timeout_fg == 0) + { + pPort->timeout_fg = 1; + isdn_log_err(pid, "[timeout]:t308 NT REL REQ STATE first timeout, resend REL\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + isdn_send_msg(pid, MSG_REL); + } + else + { + isdn_log_err(pid, "[timeout]:t308 NT REL REQ STATE\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.relComp.cause, CAUSE_TIMER_EXPIRY); + isdn_event_handle(pid, ISDN_RELEASE_CNF); //error + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + break; + case OVERLAP_RV_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t304) == 0) + { + pPort->w_time = 0; + isdn_log_err(pid, "[timeout]:t304 NT OVERLAP RV STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + default: + break; + } + + return; +} + +static void isdn_cpc_lt_timer(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + switch(pPort->fsm_state.cpc_state) + { + case CALL_INIT_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t303) == 0) + { + pPort->w_time = 0; + if(pPort->timeout_fg == 0) + { + pPort->timeout_fg = 1; + isdn_log_err(pid, "[timeout]:t303 LT CALL INIT STATE, resend SETUP\r\n"); + isdn_send_msg(pid, MSG_SETUP); + } + else + { + isdn_log_err(pid, "[timeout]:t303 LT CALL INIT STATE, second timeout, clear call!\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + isdn_event_handle(pid, ISDN_RELEASE_IND); + rel_B_chnl(pid); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_TIMER_EXPIRY); + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + break; + case OVERLAP_SD_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t304) == 0) + { + pPort->w_time = 0; //stop t304 and start t305 + isdn_log_err(pid, "[timeout]:t304 LT OVERLAP SD STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case OUT_CALL_PROC_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t310) == 0) + { + pPort->w_time = 0; //stop t310 and start t305 + isdn_log_err(pid, "[timeout]:t310 LT OUT CALL PROC STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case CALL_DV_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t301) == 0) + { + pPort->w_time = 0; + isdn_log_err(pid, "[timeout]:t301 LT CALL DV STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case CONN_REQ_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t313) == 0) + { + pPort->w_time = 0; //stop t313 and start t305 + isdn_log_err(pid, "[timeout]:t313 LT CONN REQ STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + } + break; + case DISC_REQ_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t305) == 0) + { + isdn_log_err(pid, "[timeout]:t305 LT DISC REQ STATE\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + nr_proc(pid); + pPort->fsm_state.cpc_state = REL_REQ_STATE; + } + break; + case REL_REQ_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t308) == 0) + { + pPort->w_time = 0; + if(pPort->timeout_fg == 0) + { + pPort->timeout_fg = 1; + isdn_log_err(pid, "[timeout]:t308 LT REL REQ STATE, resend REL\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.rel.cause, CAUSE_TIMER_EXPIRY); + isdn_send_msg(pid, MSG_REL); + } + else + { + isdn_log_err(pid, "[timeout]:t308 LT REL REQ STATE\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.relComp.cause, CAUSE_TIMER_EXPIRY); + isdn_event_handle(pid, ISDN_RELEASE_CNF); //error + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + break; + case OVERLAP_RV_STATE: +// if((++(pPort->w_time)) % (isdn_timer_var.t302) == 0) +// { +// pPort->w_time = 0; +// isdn_log_err(pid, "[timeout]:t302 LT OVERLAP RV STATE\r\n"); +// isdn_event_handle(pid, ISDN_TIMEOUT_IND); +// } + break; + default: + break; + } + + return; +} + +void isdn_cpc_timer(u32 pid) +{ + int circuit_id = pid / ISDN_CIRCUIT_CIC; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return; + + if(!(isdn_rs.port_pond[pid].timer_flag & CALLIN_FLAG) && + !(isdn_rs.port_pond[pid].timer_flag & CALLOUT_FLAG)) + return; + if(circuit_ptr->attrib.user_network_if) + isdn_cpc_lt_timer(pid); + else + isdn_cpc_nt_timer(pid); +} + +void isdn_restart_timer(u32 pid) +{ + int circuit_id, i, link_id, cic_range; + const pal_circuit_struct *circuit_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return; + + link_id = circuit_ptr->attrib.link_id; + cic_range = circuit_ptr->attrib.cic_range; + if(cic_range == 24) //T1 + cic_range++; + switch(pPort->cic_state.call_state) + { + case GLOBAL_RESTART_REQ_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t316) == 0) + { + pPort->w_time = 0; + if(pPort->timeout_fg == 2) + { + if(isdn_rs.link_pond[link_id].restart_clas == 0) + { + pid = find_port_by_cic(pPort->cic_val, circuit_id); + isdn_log_err(pid, "[timeout]:t316 GLOBAL RESTART REQ STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + else + { + for(i = 1; i < cic_range; i++) + { + pid = circuit_id * ISDN_CIRCUIT_CIC + i; + pPort = &isdn_rs.port_pond[pid]; + if(pPort->cic_val != 0) + { + isdn_log_err(pid, "[timeout]:t316 GLOBAL RESTART REQ STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + } + } + else + { + pPort->timeout_fg++; + isdn_log_err(pid, "[timeout]:t316 GLOBAL RESTART REQ STATE, resend RESTART\r\n"); + isdn_send_msg(pid, MSG_RESTART); + } + } + break; + case GLOBAL_RESTART_STATE: + if((++(pPort->w_time)) % (isdn_timer_var.t317) == 0) + { + pPort->w_time = 0; + if(isdn_rs.link_pond[link_id].restart_clas == 0) + { + pid = find_port_by_cic(pPort->cic_val, circuit_id); + isdn_log_err(pid, "[timeout]:t317 GLOBAL RESTART STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + else + { + for(i = 1; i < cic_range; i++) + { + pid = circuit_id * ISDN_CIRCUIT_CIC + i; + pPort = &isdn_rs.port_pond[pid]; + if(pPort->cic_val != 0) + { + isdn_log_err(pid, "[timeout]:t317 GLOBAL RESTART STATE\r\n"); + isdn_event_handle(pid, ISDN_TIMEOUT_IND); + rel_B_chnl(pid); + rel_cr(pid); + isdn_cpc_clear(pPort); + } + } + } + } + break; + default: + break; + } +} + +int isdn_event_handle(u32 pid, u8 primitive) +/* +处理msc上层的状态机 +*/ +{ + int offset, circuit_id; + Pst pst; + ISDN_EventHandle_struct *event_handle = NULL; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + pst.sp_proc_id = pid; + pst.su_proc_id = isdn_rs.port_pond[pid].su_proc_id; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + offset = pid % ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + + if(circuit_ptr->attrib.cic_range == 32) + pst.cic = circuit_ptr->attrib.head_cic + offset; + else + pst.cic = circuit_ptr->attrib.head_cic + offset - 1; + pst.cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(pst.cg_id); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + + pst.tg_id = cg_ptr->attrib.tg_id; + event_handle = (ISDN_EventHandle_struct *)pal_get_handler(pst.cg_id); + if(event_handle == NULL) + return ISDN_CM_FAILED; + + switch(primitive) + { + case ISDN_SETUP_IND: + if(event_handle->h_isdn_setup_ind == NULL) + { + isdn_log_err(pid,"Setup indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_setup_ind\r\n"); + event_handle->h_isdn_setup_ind(&pst, &(isdn_rv_msg.msg_list.setup)); + isdn_rs.port_pond[pid].su_proc_id = pst.su_proc_id; + isdn_rs.port_pond[pid].trace_flag = pst.trace_flag; + break; + case ISDN_MORE_INFO_IND: + if(event_handle->h_isdn_minfo_ind == NULL) + { + isdn_log_err(pid,"More information indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_minfo_ind\r\n"); + event_handle->h_isdn_minfo_ind(&pst, &(isdn_rv_msg.msg_list.setupAck)); + break; + case ISDN_ALERT_IND: + if(event_handle->h_isdn_alert_ind == NULL) + { + isdn_log_err(pid,"Alert indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_alert_ind\r\n"); + event_handle->h_isdn_alert_ind(&pst, &(isdn_rv_msg.msg_list.alert)); + break; + case ISDN_SETUP_CNF: + if(event_handle->h_isdn_setup_cnf == NULL) + { + isdn_log_err(pid,"Setup confirm handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_setup_cnf\r\n"); + event_handle->h_isdn_setup_cnf(&pst, &(isdn_rv_msg.msg_list.conn)); + break; + case ISDN_RELEASE_IND: + if(event_handle->h_isdn_rel_ind == NULL) + { + isdn_log_err(pid,"Release indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_rel_ind\r\n"); + event_handle->h_isdn_rel_ind(&pst, &(isdn_rv_msg.msg_list.rel)); + break; + case ISDN_RELEASE_CNF: + if(event_handle->h_isdn_rel_cnf == NULL) + { + isdn_log_err(pid,"Release confirm handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_rel_cnf\r\n"); + event_handle->h_isdn_rel_cnf(&pst, &(isdn_rv_msg.msg_list.relComp)); + break; + case ISDN_STAT_IND: + if(event_handle->h_isdn_stat_ind == NULL) + { + isdn_log_err(pid,"Status indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_stat_ind\r\n"); + event_handle->h_isdn_stat_ind(&pst, &(isdn_rv_msg.msg_list.status)); + break; + case ISDN_RESTART_REQ: + if(event_handle->h_isdn_restart_req == NULL) + { + isdn_log_err(pid,"Restart request handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_restart_req\r\n"); + event_handle->h_isdn_restart_req(&pst, &(isdn_rv_msg.msg_list.restart)); + break; + case ISDN_RESTART_CNF: + if(event_handle->h_isdn_rest_cnf == NULL) + { + isdn_log_err(pid,"Restart confirm handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_rest_cnf\r\n"); + event_handle->h_isdn_rest_cnf(&pst, &(isdn_rv_msg.msg_list.restAck)); + break; + case ISDN_INFO_IND: + if(event_handle->h_isdn_info_ind == NULL) + { + isdn_log_err(pid,"Information indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_info_ind\r\n"); + event_handle->h_isdn_info_ind(&pst, &(isdn_rv_msg.msg_list.info)); + break; + case ISDN_PROG_IND: + if(event_handle->h_isdn_prog_ind == NULL) + { + isdn_log_err(pid,"Progress indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_prog_ind\r\n"); + event_handle->h_isdn_prog_ind(&pst, &(isdn_rv_msg.msg_list.prog)); + break; + case ISDN_NOTI_IND: + if(event_handle->h_isdn_noti_ind == NULL) + { + isdn_log_err(pid,"Notify indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_noti_ind\r\n"); + event_handle->h_isdn_noti_ind(&pst, &(isdn_rv_msg.msg_list.noti)); + break; + case ISDN_TIMEOUT_IND: + if(event_handle->h_isdn_timeout_ind == NULL) + { + isdn_log_err(pid,"Timeout indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_timeout_ind\r\n"); + event_handle->h_isdn_timeout_ind(&pst); + break; + case ISDN_REATTEMPT_IND: + if(event_handle->h_isdn_reattempt_ind == NULL) + { + isdn_log_err(pid,"Reattempt indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_reattempt_ind\r\n"); + event_handle->h_isdn_reattempt_ind(&pst); + break; + + case ISDN_PROC_IND: //msc does not handle +/* if(event_handle->h_isdn_proc_ind == NULL) + { + isdn_log_err(pid,"Call proceeding indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_proc_ind\r\n"); + event_handle->h_isdn_proc_ind(&pst, &(isdn_rv_msg.msg_list.callProc)); +*/ break; + case ISDN_SETUP_COMP_IND: + break; + case ISDN_DISCONNECT_IND: //msc does not handle + if(event_handle->h_isdn_disc_ind == NULL) + { + isdn_log_err(pid,"Disconnect indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_disc_ind\r\n"); + event_handle->h_isdn_disc_ind(&pst, &(isdn_rv_msg.msg_list.disc)); + break; + + case ISDN_SERVICE_IND: + if(event_handle->h_isdn_service_ind == NULL) + { + isdn_log_err(pid,"Service indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_service_ind\r\n"); + event_handle->h_isdn_service_ind(&pst, &(isdn_rv_msg.msg_list.service)); + isdn_rs.port_pond[pid].su_proc_id = pst.su_proc_id; + isdn_rs.port_pond[pid].trace_flag = pst.trace_flag; + break; + case ISDN_SERVICE_CNF: + if(event_handle->h_isdn_service_cnf == NULL) + { + isdn_log_err(pid,"Service confirm handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_service_cnf\r\n"); + event_handle->h_isdn_service_cnf(&pst, &(isdn_rv_msg.msg_list.servAck)); + break; + case ISDN_SER_TIMEOUT_IND: + if(event_handle->h_isdn_ser_timeout_ind == NULL) + { + isdn_log_err(pid,"Service timeout indication handle is not registered@%s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + isdn_trace_func(pid,"APP => function trace: isdn_ser_timeout_ind\r\n"); + event_handle->h_isdn_ser_timeout_ind(&pst); + break; + default: + break; + } + + return ISDN_CM_OK; +} + + +void stuff_encode_m(u32 pid, IsdnMsgStr *ptr, int type) +{ + ChgStat chg_stat; + ChnlId chnl_id; + + chg_stat.pres = 1; + chg_stat.pref = 1; + chg_stat.new_stat = isdn_rs.port_pond[pid].cic_state.maintenance_state; + chnl_id.pres = 1; + chnl_id.b3.int_id_pre = 1; + chnl_id.b3.int_type = 1; + chnl_id.b3.pref_excl = 1; + chnl_id.b3.chnl_ind = 1; + chnl_id.b3.info_chnl_sel = 1; + chnl_id.b3.int_id = pid / ISDN_CIRCUIT_CIC; + chnl_id.b3.has_chnl = 1; + chnl_id.b3.code_stan = 0; + chnl_id.b3.num_map = 0; + chnl_id.b3.chnl_type = 3; + chnl_id.b3.chnl_num = pid % ISDN_CIRCUIT_CIC; + if(type == MSG_SERVICE) + { + memcpy(&ptr->msg_list.service.chg_stat, &chg_stat, sizeof(ChgStat)); + memcpy(&ptr->msg_list.service.chnl_id, &chnl_id, sizeof(ChnlId)); + } + else if(type == MSG_SERVICE_ACK) + { + memcpy(&ptr->msg_list.servAck.chg_stat, &chg_stat, sizeof(ChgStat)); + memcpy(&ptr->msg_list.servAck.chnl_id, &chnl_id, sizeof(ChnlId)); + } +} + +//ansi isdn maintenance D-channel and B-channel +void service_dc_proc(u32 pid) +{ + int circuit_id, link_id, cg_id, ds_0, ds_1; + int far_status; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return; + + link_id = circuit_ptr->attrib.link_id; + cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + return; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + + ds_0 = cg_ptr->attrib.nfas.prim_link; + ds_1 = cg_ptr->attrib.nfas.backup_link; + far_status = isdn_rv_msg.msg_list.service.chg_stat.new_stat; + + if(cg_ptr->attrib.variant == VARIANT_ANSI) //ANSI + { + switch(pPort->fsm_state.m_state) + { + case SERVICE_IDLE: + if(pPort->g_pri_cmd == ISDN_SERVICE_REQ) + { + pPort->g_pri_cmd = 0; + isdn_rs.link_pond[link_id].dc_status = DS_WAIT; + pPort->w_time = 0; //start t321 + pPort->timer_flag |= DC_M_FLAG; + pPort->cic_state.maintenance_state = IN_SERVICE; + stuff_encode_m(pid, &isdn_sd_msg, MSG_SERVICE); + isdn_send_maintenance_msg(pid, MSG_SERVICE); + pPort->cic_state.maintenance_state = OUT_OF_SERVICE; + pPort->fsm_state.m_state = WAIT_SERVICE_ACK; + printf("service_dc_proc: wait service ack!\n"); + } + else if(pPort->msg_cmd == MSG_SERVICE) + { + pPort->msg_cmd = 0; + pPort->callout_fg = 1; + if(link_id == ds_0) + { + if((isdn_rs.link_pond[ds_1].dc_status != DS_IS) && + (isdn_rs.link_pond[link_id].lk3_status == LK_IS) && + (far_status == IN_SERVICE)) + { + isdn_rs.link_pond[link_id].dc_status = DS_IS; + pPort->cic_state.maintenance_state = IN_SERVICE; + stuff_encode_m(pid, &isdn_sd_msg, MSG_SERVICE_ACK); + isdn_send_maintenance_msg(pid, MSG_SERVICE_ACK); + pPort->fsm_state.m_state = SERVICE_IDLE; + } + } + else if(link_id == ds_1) + { + if(((isdn_rs.link_pond[ds_0].dc_status) == DS_OOS || + (isdn_rs.link_pond[ds_0].dc_status == DS_STBY)) && + (isdn_rs.link_pond[link_id].lk3_status == LK_IS) && + (far_status == IN_SERVICE)) + { + isdn_rs.link_pond[link_id].dc_status = DS_IS; + pPort->cic_state.maintenance_state = IN_SERVICE; + stuff_encode_m(pid, &isdn_sd_msg, MSG_SERVICE_ACK); + isdn_send_maintenance_msg(pid, MSG_SERVICE_ACK); + pPort->fsm_state.m_state = SERVICE_IDLE; + } + } + printf("service_dc_proc: receive service!\n"); + } + if(pPort->msg_cmd == MSG_SERVICE_ACK) //timeout t321 TODO + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t321 + if(far_status == IN_SERVICE) + { + isdn_rs.link_pond[link_id].dc_status = DS_IS; + pPort->cic_state.maintenance_state = IN_SERVICE; + } + else + { + isdn_rs.link_pond[link_id].dc_status = DS_STBY; + pPort->cic_state.maintenance_state = OUT_OF_SERVICE; + } + pPort->fsm_state.m_state = SERVICE_IDLE; + printf("service_dc_proc: receive service ack in service idle!\n"); + } + break; + case WAIT_SERVICE_ACK: + if(pPort->msg_cmd == MSG_SERVICE_ACK) + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t321 + if(far_status == IN_SERVICE) + { + isdn_rs.link_pond[link_id].dc_status = DS_IS; + pPort->cic_state.maintenance_state = IN_SERVICE; + } + else + { + isdn_rs.link_pond[link_id].dc_status = DS_STBY; + pPort->cic_state.maintenance_state = OUT_OF_SERVICE; + } + pPort->fsm_state.m_state = SERVICE_IDLE; + printf("service_dc_proc: receive service ack!and enter service idle state\n"); + } + else if(pPort->msg_cmd == MSG_SERVICE) //collision + { + if(!cg_ptr->attrib.priority) + { + pPort->w_time = 0; //stop t321 + pPort->fsm_state.m_state = SERVICE_IDLE; + service_dc_proc(pid); + printf("service_dc_proc: collision, and renew the state with service idle to receive msg!\n"); + } + else + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "service_dc_proc: discard receive msg!\r\n"); + return; + } + } + break; + case RSP_SERVICE: + break; + default: + break; + } + } + else //ITU + { + if(pPort->g_pri_cmd == ISDN_SERVICE_REQ) + { + pPort->g_pri_cmd = 0; + isdn_rs.link_pond[link_id].dc_status = DS_IS; + } + else if(isdn_rs.link_pond[link_id].lk3_status == LK_IS && isdn_rs.link_pond[link_id].dc_status != DS_IS) + { + isdn_rs.link_pond[link_id].dc_status = DS_STBY; + } + } + +// if(isdn_rs.link_pond[link_id].dc_status == DS_OOS && isdn_rs.link_pond[link_id].lk3_status == LK_IS) +// isdn_rs.link_pond[link_id].dc_status = DS_STBY; + + if(isdn_rs.link_pond[ds_0].dc_status == DS_IS && isdn_rs.link_pond[ds_1].dc_status == DS_IS) + isdn_rs.link_pond[ds_1].dc_status = DS_STBY; + else if(isdn_rs.link_pond[ds_0].dc_status == DS_STBY && isdn_rs.link_pond[ds_1].dc_status == DS_STBY) + isdn_rs.link_pond[ds_0].dc_status = DS_IS; + else if(isdn_rs.link_pond[ds_0].dc_status == DS_OOS && isdn_rs.link_pond[ds_1].dc_status == DS_STBY) + isdn_rs.link_pond[ds_1].dc_status = DS_IS; + else if(isdn_rs.link_pond[ds_0].dc_status == DS_STBY && isdn_rs.link_pond[ds_1].dc_status == DS_OOS) + isdn_rs.link_pond[ds_0].dc_status = DS_IS; + else if(isdn_rs.link_pond[ds_0].dc_status == DS_OOS && isdn_rs.link_pond[ds_1].dc_status == DS_OOS) + { + isdn_rs.link_pond[ds_0].dc_status = DS_MOOS; + isdn_rs.link_pond[ds_1].dc_status = DS_MOOS; + } + + return; +} + +void service_bc_proc(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(pid / ISDN_CIRCUIT_CIC); + if(circuit_ptr == NULL) + return; + + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + return; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + + switch(pPort->fsm_state.m_state) + { + case SERVICE_IDLE: + if(pPort->g_pri_cmd == ISDN_SERVICE_REQ) + { + pPort->g_pri_cmd = 0; + if(isdn_sd_msg.msg_list.service.chg_stat.new_stat != IN_SERVICE) + { + pPort->primitive_cmd = ISDN_RELEASE_REQ; + isdn_cpc_proc(pid); + } + pPort->w_time = 0; //start t3M1 + pPort->timer_flag |= BC_M_FLAG; + isdn_send_maintenance_msg(pid, MSG_SERVICE); + pPort->cic_state.maintenance_state = isdn_sd_msg.msg_list.service.chg_stat.new_stat; + pPort->fsm_state.m_state = WAIT_SERVICE_ACK; + printf("service_bc_proc: wait service ack!\n"); + } + else if(pPort->msg_cmd == MSG_SERVICE) + { + pPort->msg_cmd = 0; + pPort->callout_fg = 1; + pPort->cic_state.maintenance_state = isdn_rv_msg.msg_list.service.chg_stat.new_stat; + pPort->fsm_state.m_state = RSP_SERVICE; + printf("service_bc_proc: receive service!\n"); + isdn_event_handle(pid, ISDN_SERVICE_IND); //indicate + } + else if(pPort->msg_cmd == MSG_SERVICE_ACK) //timeout t3M1 + { + pPort->msg_cmd = 0; + pPort->w_time = 0; //stop t3M1 + pPort->cic_state.maintenance_state = isdn_rv_msg.msg_list.service.chg_stat.new_stat; + isdn_event_handle(pid, ISDN_SERVICE_CNF); //confirm + pPort->fsm_state.m_state = SERVICE_IDLE; + printf("service_bc_proc: receive service ack in service idle!\n"); + } + break; + case WAIT_SERVICE_ACK: + if(pPort->msg_cmd == MSG_SERVICE_ACK) + { + pPort->msg_cmd = 0; + isdn_event_handle(pid, ISDN_SERVICE_CNF); //confirm + pPort->fsm_state.m_state = SERVICE_IDLE; + printf("service_bc_proc: receive service ack!\n"); + } + if(pPort->msg_cmd == MSG_SERVICE) //接收service冲突 TODO + { + if(!cg_ptr->attrib.priority) + { + pPort->w_time = 0; + pPort->cic_state.maintenance_state = ((pPort->cic_state.maintenance_state & 0x1) | (pPort->cic_state.maintenance_state >> 1)) ^ 0x1; //run back initial + pPort->fsm_state.m_state = SERVICE_IDLE; + isdn_event_handle(pid, ISDN_REATTEMPT_IND); //indicate + service_bc_proc(pid); + printf("service_bc_proc: collision, and renew the state with service idle to receive msg!\n"); + } + else + { + pPort->msg_cmd = 0; + isdn_log_err(pid, "service_dc_proc: discard receive msg!\r\n"); + return; + } + } + break; + case RSP_SERVICE: + if(pPort->g_pri_cmd == ISDN_SERVICE_RSP) + { + pPort->g_pri_cmd = 0; + pPort->fsm_state.m_state = SERVICE_IDLE; + pPort->cic_state.maintenance_state = isdn_sd_msg.msg_list.servAck.chg_stat.new_stat; + isdn_send_maintenance_msg(pid, MSG_SERVICE_ACK); + printf("service_bc_proc: response service!\n"); + } + break; + default: + break; + } +} + +void service_dc_timer(u32 pid) +{ + int link_id; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(pid / ISDN_CIRCUIT_CIC); + if(circuit_ptr == NULL) + return; + + link_id = circuit_ptr->attrib.link_id; + switch(pPort->fsm_state.m_state) + { + case WAIT_SERVICE_ACK: + if((++(pPort->w_time)) % (isdn_timer_var.t321) == 0) + { + pPort->w_time = 0; //stop t3M1 + pPort->fsm_state.m_state = SERVICE_IDLE; + pPort->cic_state.maintenance_state = OUT_OF_SERVICE; + isdn_rs.link_pond[link_id].dc_status = DS_OOS; + isdn_log_err(pid, "service_dc_timer: t321 timeout!\r\n"); + } + break; + default: + break; + } +} + +void service_bc_timer(u32 pid) +{ + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + + switch(pPort->fsm_state.m_state) + { + case WAIT_SERVICE_ACK: + if((++(pPort->w_time)) % (isdn_timer_var.t3M1) == 0) + { + pPort->w_time = 0; //stop t3M1 + isdn_event_handle(pid, ISDN_SER_TIMEOUT_IND); + pPort->fsm_state.m_state = SERVICE_IDLE; + pPort->cic_state.maintenance_state = OUT_OF_SERVICE; + isdn_log_err(pid, "service_bc_timer: t3M1 timeout!\r\n"); + } + break; + default: + break; + } +} + +void maintenance_timer(u32 pid) +{ + if(isdn_rs.port_pond[pid].timer_flag & BC_M_FLAG) + service_bc_timer(pid); + if(isdn_rs.port_pond[pid].timer_flag & DC_M_FLAG) + service_dc_timer(pid); +} + diff --git a/omc/plat/isdn/src/isdn_ie.c b/omc/plat/isdn/src/isdn_ie.c new file mode 100644 index 0000000..6e64ba4 --- /dev/null +++ b/omc/plat/isdn/src/isdn_ie.c @@ -0,0 +1,1665 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_ie.c +Description: ISDN information elements +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ + +#include "./include/isdn_const.h" +#include "./include/isdn_msg.h" +#include "./include/isdn_ie.h" + + +u16 find_ie_para(u8 *start, u8 ie_type, u8 **target) +/* +*/ +{ + u16 offset = 0; + u8 ie_ind, len, ie_num = 0; + + while ((offset < IE_MAX_LEN) && (ie_num < IE_COUNT)) + { + ie_num++; + ie_ind = (((*start) >> 7) & 0x01); + if (ie_ind == 1) + len = 1; + else + len = (*(start + 1)) + 2; + + if ((*start) == ie_type) + { + (*target) = start; + return len; + } + else + { + if (ie_ind == 1) + { + offset++; + start++; + } + else + { + offset += len; + start += len; + } + } + } + + return 0; +} + +u8 IA5_to_Hex(u8 digit) +{ + if ((digit >= '0') && (digit <= '9')) + return (digit - '0'); + else if ((digit == '*') || (digit == 0x3A)) + return 0x0B; + else if ((digit == '#') || (digit == 0x3B)) + return 0x0C; + else + return 0xFF; +} + +u8 Hex_to_IA5(u8 digit) +{ + if (digit == 0x0B) + return ('*'); + else if (digit == 0x0C) + return ('#'); + else if (digit == 0x0A) + return ('0'); + else if (digit < 0x0A) + return ('0' + digit); + else + return 0xFF; +} + + +u8 itu_encode_br_cap(u8 *dst, BrCap *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->code_stan << 5) | (src->tran_cap); + dst[offset++] = 0x80 | (src->b4.tran_mode << 5) | (src->b4.tran_rate); + + if((src->b4.tran_rate & 0x1F) == 0x18) //Multirate octet4 and 4.1 + { + dst[offset++] = 0x80 | (src->b4.rate_mul); + } + + if(src->ext_flag & 0x01) //octet5 + { + dst[offset++] = (src->b5.has_ext_a << 7) | (0x1 << 5) | (src->b5.usr_layer1); + if(!src->b5.has_ext_a) //octet5 and 5a + { + dst[offset++] = (src->b5.has_ext_b << 7) | (src->b5.syn_asy << 6) | + (src->b5.neg << 5) | (src->b5.usr_rate); + + if(!src->b5.has_ext_b) //5b + { + if((src->b5.usr_layer1 & 0x1F) == 0x1) + { + dst[offset++] = (src->b5.has_ext_c << 7) | (src->b5.inter_rate << 5) | + (src->b5.nic_tx << 4) | (src->b5.nic_rx << 3) | + (src->b5.ctl_tx << 2) | (src->b5.ctl_rx <<1); + } + else if((src->b5.usr_layer1 & 0x1F) == 0x8) + { + dst[offset++] = (src->b5.has_ext_c << 7) | (src->b5.hdr << 6) | + (src->b5.mul_fra << 5) | (src->b5.mode << 4) | + (src->b5.lli_neg << 3) | (src->b5.assign << 2) | + (src->b5.inband << 1); + } + + if(!src->b5.has_ext_c) //5c + { + dst[offset++] = (src->b5.has_ext_d << 7) | (src->b5.stop_bit << 5) | + (src->b5.data_bit << 3) | (src->b5.par); + + if(!src->b5.has_ext_d) //5d + { + dst[offset++] = 0x80 | (src->b5.du_mode << 6) | (src->b5.mod_type); + } + } + } + } + } + + if(src->ext_flag & 0x02) //octet6 + { + dst[offset++] = 0x80 | (0x2 << 5) | (src->usr_layer2); + } + + if(src->ext_flag & 0x04) //octet7 + { + dst[offset++] = 0x80 | (0x3 << 5) | (src->usr_layer3); + } + + return offset; +} + +int itu_decode_br_cap(BrCap *dst, u8 *src, u8 len) // +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 13)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->code_stan = ((src[offset] & 0x60) >> 5); + dst->tran_cap = (src[offset++] & 0x1F); + + dst->b4.tran_mode = ((src[offset] & 0x60) >> 5); + dst->b4.tran_rate = (src[offset++] & 0x1F); + + if((dst->b4.tran_rate & 0x1F) == 0x18) //Multirate with 4.1 + { + dst->b4.rate_mul = (src[offset++] & 0x7F); + } + + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x1) //octet 5 + { + dst->ext_flag |= 0x01; + dst->b5.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b5.usr_layer1 = (src[offset++] & 0x1F); + if(!dst->b5.has_ext_a) //with 5a + { + dst->b5.has_ext_b = ((src[offset] & 0x80) >> 7); + dst->b5.syn_asy = ((src[offset] & 0x40) >> 6); + dst->b5.neg = ((src[offset] & 0x20) >> 5); + dst->b5.usr_rate = (src[offset++] & 0x1F); + if(!dst->b5.has_ext_b) //with 5b + { + dst->b5.has_ext_c = ((src[offset] & 0x80) >> 7); + if((dst->b5.usr_layer1 & 0x1F) == 0x1) //V.110/X.30 + { + dst->b5.inter_rate = ((src[offset] & 0x60) >> 5); + dst->b5.nic_tx = ((src[offset] & 0x10) >> 4); + dst->b5.nic_rx = ((src[offset] & 0x08) >> 3); + dst->b5.ctl_tx = ((src[offset] & 0x04) >> 2); + dst->b5.ctl_rx = ((src[offset++] & 0x02) >> 1); + } + else if((dst->b5.usr_layer1 & 0x1F) == 0x8) //V.120 + { + dst->b5.hdr = ((src[offset] & 0x40) >> 6); + dst->b5.mul_fra = ((src[offset] & 0x20) >> 5); + dst->b5.mode = ((src[offset] & 0x10) >> 4); + dst->b5.lli_neg = ((src[offset] & 0x08) >> 3); + dst->b5.assign = ((src[offset] & 0x04) >> 2); + dst->b5.inband =((src[offset++] & 0x02) >> 1); + } + + if(!dst->b5.has_ext_c) //with 5c + { + dst->b5.has_ext_d = ((src[offset] & 0x80) >> 7); + dst->b5.stop_bit = ((src[offset] & 0x60) >> 5); + dst->b5.data_bit = ((src[offset] & 0x18) >> 3); + dst->b5.par = (src[offset++] & 0x07); + + if(!dst->b5.has_ext_d) //with 5d + { + dst->b5.du_mode = ((src[offset] & 0x40) >> 6); + dst->b5.mod_type =(src[offset++] & 0x3F); + } + } + } + } + } + } + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x2) //octet 6 + { + dst->ext_flag |= 0x02; + dst->usr_layer2 = (src[offset++] & 0x1F); + } + } + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x3) //octet 7 + { + dst->ext_flag |= 0x04; + dst->usr_layer3 = (src[offset] & 0x1F); + } + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_br_cap(u8 *dst, BrCap *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->code_stan << 5) | (src->tran_cap); + dst[offset++] = 0x80 | (src->b4.tran_mode << 5) | (src->b4.tran_rate); + + if((src->b4.tran_rate & 0x1F) == 0x18) //Multirate octet4 and 4.1 + { + dst[offset++] = 0x80 | (src->b4.rate_mul); + } + + if(src->ext_flag & 0x01) //octet5 + { + dst[offset++] = (src->b5.has_ext_a << 7) | (0x1 << 5) | (src->b5.usr_layer1); + if((!src->b5.has_ext_a) && (src->b5.usr_layer1 == 0x1)) //with 5a when V.110/X.30 + { + dst[offset++] = 0x80 | (src->b5.usr_rate); + } + } + + return offset; +} + +int isdn_decode_br_cap(BrCap *dst, u8 *src, u8 len) // +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 5)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->code_stan = ((src[offset] & 0x60) >> 5); + dst->tran_cap = (src[offset++] & 0x1F); + + dst->b4.tran_mode = ((src[offset] & 0x60) >> 5); + dst->b4.tran_rate = (src[offset++] & 0x1F); + + if((dst->b4.tran_rate & 0x1F) == 0x18) //Multirate with 4.1 + { + dst->b4.rate_mul = (src[offset++] & 0x7F); + } + + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x1) //octet 5 + { + dst->ext_flag |= 0x01; + dst->b5.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b5.usr_layer1 = (src[offset++] & 0x1F); + if((!dst->b5.has_ext_a) && (dst->b5.usr_layer1 == 0x1)) //with 5a when V.110/X.30 + { + dst->b5.syn_asy = ((src[offset] & 0x40) >> 6); + dst->b5.neg = ((src[offset] & 0x20) >> 5); + dst->b5.usr_rate = (src[offset++] & 0x1F); + } + } + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_cause(u8 *dst, CauseStr *src) +{ + u8 offset = 0; + int i = 0; + dst[offset++] = (src->b3.has_ext_a << 7) | (src->b3.code_stan << 5) | (src->b3.loc); + if(!src->b3.has_ext_a) //with 3a + { + dst[offset++] = 0x80 | (src->b3.rec); + } + dst[offset++] = 0x80 | (src->cause_val); + if(src->ext_flag & 0x01) //octet 5 + { + for(i=0; idia_num; i++) + { + dst[offset++] = src->dia[i].attrib_num; + dst[offset++] = (src->dia[i].has_ext_b << 7) | (src->dia[i].rej_attrib); + if(!src->dia[i].has_ext_b) //with 5b + { + dst[offset++] = 0x80 | (src->dia[i].avail_attrib); + } + } + } + + return offset; +} + +int isdn_decode_cause(CauseStr *dst, u8 *src, u8 len) +{ + u8 offset = 0; + int i = 0; + dst->pres = 1; + if((len < 2) || (len > 30)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + dst->b3.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b3.code_stan = ((src[offset] & 0x60) >> 5); + dst->b3.loc = (src[offset++] & 0x0F); + if(!dst->b3.has_ext_a) //with 3a + { + dst->b3.rec = (src[offset++] & 0x7F); + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->cause_val = (src[offset++] & 0x7F); + if(offset < len) + { + dst->ext_flag |= 0x01; + while(offset < len && i < 8) + { +// dst->dia[i].has_ext_a = ((src[offset] & 0x80) >> 7); + dst->dia[i].attrib_num = (src[offset++] & 0x7F); + dst->dia[i].has_ext_b = ((src[offset] & 0x80) >> 7); + dst->dia[i].rej_attrib = (src[offset++] & 0x7F); + if(!dst->dia[i].has_ext_b) + dst->dia[i].avail_attrib = (src[offset++] & 0x7F); + i++; + } + dst->dia_num = i; + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_call_id(u8 *dst, CallId *src) +{ + u8 offset = 0; + + return offset; +} + +int isdn_decode_call_id(CallId *dst, u8 *src, u8 len) +{ +// u8 offset = 0; + dst->pres = 1; + + return ISDN_CM_OK; +} + +u8 isdn_encode_call_stat(u8 *dst, CallStat *src) +{ + u8 offset = 0; + dst[offset++] = (src->code_stan << 6) | (src->stat_val & 0x3F); + + return offset; +} + +int isdn_decode_call_stat(CallStat *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->code_stan = ((src[offset] & 0xC0) >> 6); + dst->stat_val = (src[offset++] & 0x3F); + + return ISDN_CM_OK; +} + +u8 qsig_encode_chnl_id(u8 *dst, ChnlId *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->b3.pref_excl << 3) | (src->b3.chnl_ind << 2) | (src->b3.info_chnl_sel); + + if(src->b3.has_chnl) + { + dst[offset++] = 0x80 | (src->b3.code_stan << 5) | (src->b3.num_map << 4) | (src->b3.chnl_type); //with 3.2 + dst[offset++] = 0x80 | (src->b3.chnl_num & 0x1F); //with 3.3 + } + + return offset; +} + +int qsig_decode_chnl_id(ChnlId *dst, u8 *src, u8 len) +{ + int i; + u8 offset = 0; + dst->pres = 1; + if((len < 1) || (len > 32)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.int_id_pre = ((src[offset] & 0x40) >> 6); + dst->b3.int_type = ((src[offset] & 0x20) >> 5); + dst->b3.pref_excl = ((src[offset] & 0x08) >> 3); + dst->b3.chnl_ind = ((src[offset] & 0x04) >> 2); + dst->b3.info_chnl_sel = (src[offset++] & 0x03); + if(dst->b3.int_id_pre || (!dst->b3.int_type)) //with 3.1 err + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + if((dst->b3.int_type & 0x1) && (offset < len)) //with 3.2 and 3.3 + { + dst->b3.has_chnl = 1; + dst->b3.code_stan = ((src[offset] & 0x60) >> 5); + dst->b3.num_map = ((src[offset] & 0x10) >> 4); + dst->b3.chnl_type = (src[offset++] & 0x0F); + if(dst->b3.num_map) + { + dst->b3.num_map = 0; + switch(len - offset) + { + case 4: //E1 + for(i = 0; i < 4; i++) + { + if(src[offset]) + { + switch(src[offset]) + { + case 0x01: + dst->b3.chnl_num = (3 - i) * 8 + 0; + break; + case 0x02: + dst->b3.chnl_num = (3 - i) * 8 + 1; + break; + case 0x04: + dst->b3.chnl_num = (3 - i) * 8 + 2; + break; + case 0x08: + dst->b3.chnl_num = (3 - i) * 8 + 3; + break; + case 0x10: + dst->b3.chnl_num = (3 - i) * 8 + 4; + break; + case 0x20: + dst->b3.chnl_num = (3 - i) * 8 + 5; + break; + case 0x40: + dst->b3.chnl_num = (3 - i) * 8 + 6; + break; + case 0x80: + dst->b3.chnl_num = (3 - i) * 8 + 7; + break; + default: + break; + } + } + offset++; + } + break; + case 3: //T1 + for(i = 0; i < 3; i++) + { + if(src[offset]) + { + switch(src[offset]) + { + case 0x01: + dst->b3.chnl_num = (2 - i) * 8 + 0; + break; + case 0x02: + dst->b3.chnl_num = (2 - i) * 8 + 1; + break; + case 0x04: + dst->b3.chnl_num = (2 - i) * 8 + 2; + break; + case 0x08: + dst->b3.chnl_num = (2 - i) * 8 + 3; + break; + case 0x10: + dst->b3.chnl_num = (2 - i) * 8 + 4; + break; + case 0x20: + dst->b3.chnl_num = (2 - i) * 8 + 5; + break; + case 0x40: + dst->b3.chnl_num = (2 - i) * 8 + 6; + break; + case 0x80: + dst->b3.chnl_num = (2 - i) * 8 + 7; + break; + default: + break; + } + } + offset++; + } + break; + case 1: + break; + default: + break; + } + } + else + dst->b3.chnl_num = (src[offset++] & 0x1F); + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_chnl_id(u8 *dst, ChnlId *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->b3.int_id_pre << 6) | (src->b3.int_type << 5) | + (src->b3.pref_excl << 3) | (src->b3.chnl_ind << 2) | (src->b3.info_chnl_sel); + if((src->b3.int_id_pre & 0x1) == 1) //with 3.1 + { + if((src->b3.int_type & 0x1) && (src->b3.has_chnl)) //with3.1, 3.2 and 3.3 + { + dst[offset++] = 0x80 | (src->b3.int_id); + dst[offset++] = 0x80 | (src->b3.code_stan << 5) | (src->b3.num_map << 4) | + (src->b3.chnl_type); + dst[offset++] = 0x80 | (src->b3.chnl_num & 0x1F); + } + else //without 3.2 and 3.3 but with 3.1 + { + dst[offset++] = 0x80 | (src->b3.int_id); + } + } + else //without 3.1 + { + if((src->b3.int_type & 0x1) && (src->b3.has_chnl)) //with 3.2 and 3.3 but without 3.1 + { + dst[offset++] = 0x80 | (src->b3.code_stan << 5) | (src->b3.num_map << 4) | + (src->b3.chnl_type); + dst[offset++] = 0x80 | (src->b3.chnl_num & 0x1F); + } + } + + return offset; +} + +int isdn_decode_chnl_id(ChnlId *dst, u8 *src, u8 len) +{ + int i; + u8 offset = 0; + dst->pres = 1; + if((len < 1) || (len > 32)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.int_id_pre = ((src[offset] & 0x40) >> 6); + dst->b3.int_type = ((src[offset] & 0x20) >> 5); + dst->b3.pref_excl = ((src[offset] & 0x08) >> 3); + dst->b3.chnl_ind = ((src[offset] & 0x04) >> 2); + dst->b3.info_chnl_sel = (src[offset++] & 0x03); + if((dst->b3.int_id_pre & 0x1) == 0x1) //with 3.1 + { + dst->b3.int_id = (src[offset++] & 0x7F); + } + if((dst->b3.int_type & 0x1) && (offset < len)) //with 3.2 and 3.3 + { + dst->b3.has_chnl = 1; + dst->b3.code_stan = ((src[offset] & 0x60) >> 5); + dst->b3.num_map = ((src[offset] & 0x10) >> 4); + dst->b3.chnl_type = (src[offset++] & 0x0F); + if(dst->b3.num_map) + { + dst->b3.num_map = 0; + switch(len - offset) + { + case 4: //E1 + for(i = 0; i < 4; i++) + { + if(src[offset]) + { + switch(src[offset]) + { + case 0x01: + dst->b3.chnl_num = (3 - i) * 8 + 0; + break; + case 0x02: + dst->b3.chnl_num = (3 - i) * 8 + 1; + break; + case 0x04: + dst->b3.chnl_num = (3 - i) * 8 + 2; + break; + case 0x08: + dst->b3.chnl_num = (3 - i) * 8 + 3; + break; + case 0x10: + dst->b3.chnl_num = (3 - i) * 8 + 4; + break; + case 0x20: + dst->b3.chnl_num = (3 - i) * 8 + 5; + break; + case 0x40: + dst->b3.chnl_num = (3 - i) * 8 + 6; + break; + case 0x80: + dst->b3.chnl_num = (3 - i) * 8 + 7; + break; + default: + break; + } + } + offset++; + } + break; + case 3: //T1 + for(i = 0; i < 3; i++) + { + if(src[offset]) + { + switch(src[offset]) + { + case 0x01: + dst->b3.chnl_num = (2 - i) * 8 + 0; + break; + case 0x02: + dst->b3.chnl_num = (2 - i) * 8 + 1; + break; + case 0x04: + dst->b3.chnl_num = (2 - i) * 8 + 2; + break; + case 0x08: + dst->b3.chnl_num = (2 - i) * 8 + 3; + break; + case 0x10: + dst->b3.chnl_num = (2 - i) * 8 + 4; + break; + case 0x20: + dst->b3.chnl_num = (2 - i) * 8 + 5; + break; + case 0x40: + dst->b3.chnl_num = (2 - i) * 8 + 6; + break; + case 0x80: + dst->b3.chnl_num = (2 - i) * 8 + 7; + break; + default: + break; + } + } + offset++; + } + break; + case 1: + break; + default: + break; + } + } + else + dst->b3.chnl_num = (src[offset++] & 0x1F); + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_prg_ind(u8 *dst, PrgInd *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->code_stan << 5) | (src->loc); + dst[offset++] = 0x80 | (src->prg_descr & 0x7F); + + return offset; +} + +int isdn_decode_prg_ind(PrgInd *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len != 2) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->code_stan = ((src[offset] & 0x60) >> 5); + dst->loc = (src[offset++] & 0x0F); + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->prg_descr = (src[offset++] & 0x7F); + + return ISDN_CM_OK; +} + +u8 ansi_encode_ntsp_fac(u8 *dst, NtSpFac *src) +{ + u8 offset = 0; + dst[offset++] = src->b3.len_net_id; + if((src->b3.len_net_id) != 0) //with 3.1 and 3.2 + { + dst[offset++] = 0x80 | (src->b3.net_id_type << 4) | (src->b3.net_id_plan); + dst[offset++] = 0x80 | (src->b3.net_id); + } + dst[offset++] = 0xE0 | (src->fac_val); + dst[offset++] = 0x80 | (src->ser_par); + + return offset; +} + +int ansi_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len < 2) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + dst->b3.len_net_id = (src[offset++] & 0xFF); + if((dst->b3.len_net_id) != 0) //with 3.1 and 3.2 + { + dst->b3.net_id_type = ((src[offset] & 0x70) >> 4); + dst->b3.net_id_plan = (src[offset++] & 0x0F); + + dst->b3.net_id = (src[offset++] & 0x7F); + } + dst->fac_val = (src[offset++] & 0x1F); + dst->ser_par = (src[offset++] & 0x7F); + + return ISDN_CM_OK; +} + +u8 isdn_encode_ntsp_fac(u8 *dst, NtSpFac *src) +{ + u8 offset = 0; + dst[offset++] = src->b3.len_net_id; + if((src->b3.len_net_id) != 0) //with 3.1 and 3.2 + { + dst[offset++] = 0x80 | (src->b3.net_id_type << 4) | (src->b3.net_id_plan); + dst[offset++] = 0x80 | (src->b3.net_id); + } + dst[offset++] = src->spec; + + return offset; +} + +int isdn_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len < 2) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + dst->b3.len_net_id = (src[offset++] & 0xFF); + if((dst->b3.len_net_id) != 0) //with 3.1 and 3.2 + { + dst->b3.net_id_type = ((src[offset] & 0x70) >> 4); + dst->b3.net_id_plan = (src[offset++] & 0x0F); + + dst->b3.net_id = (src[offset++] & 0x7F); + } + dst->spec = (src[offset++] & 0xFF); + + return ISDN_CM_OK; +} + +u8 ansi_encode_notify_ind(u8 *dst, NotifyInd *src) //TODO +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->notify_descr & 0x7F); + + return offset; +} + +int ansi_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len) //TODO +{ + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[0] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->notify_descr = (src[0] & 0x7F); + + return ISDN_CM_OK; +} + +u8 isdn_encode_notify_ind(u8 *dst, NotifyInd *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->notify_descr & 0x7F); + + return offset; +} + +int isdn_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len) +{ + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[0] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->notify_descr = (src[0] & 0x7F); + + return ISDN_CM_OK; +} + +u8 isdn_encode_disp(u8 *dst, Disp *src) +{ + u8 offset = 0; + memcpy(dst,src->disp_info,src->disp_info_len); + offset += src->disp_info_len; + + return offset; +} + +int isdn_decode_disp(Disp *dst, u8 *src, u8 len) +{ + dst->pres = 1; + if(len < 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(len > 18) + { + len = 18; + printf("len is truncated!\n"); + } + dst->disp_info_len = len; + memcpy(dst->disp_info, src, dst->disp_info_len); + + return ISDN_CM_OK; +} + +u8 isdn_encode_dt_time(u8 *dst, DtTime *src) +{ + u8 offset = 0; + dst[offset++] = src->year; + dst[offset++] = src->month; + dst[offset++] = src->day; + if(src->ext_flag & 0x01) //with octet 6, 7 and 8 + { + dst[offset++] = src->hour; + dst[offset++] = src->minute; + dst[offset++] = src->second; + } + + return offset; +} + +int isdn_decode_dt_time(DtTime *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 3) || (len > 6)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + dst->year = (src[offset++]); + dst->month = (src[offset++]); + dst->day = (src[offset++]); + if(offset < len) + { + dst->ext_flag |= 0x01; + dst->hour = (src[offset++]); + dst->minute = (src[offset++]); + dst->second = (src[offset++]); + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_kpd_fac(u8 *dst, KpdFac *src) +{ + u8 offset = 0; + int i = 0; +// memcpy(dst+offset, src->key_fac_info, src->keyfac_info_len); +// offset += src->keyfac_info_len; + while(i < src->keyfac_info_len) + { + dst[offset++] = Hex_to_IA5(src->key_fac_info[i]); + i++; + } + + return offset; +} + +int isdn_decode_kpd_fac(KpdFac *dst, u8 *src, u8 len) +{ + u8 offset = 0, digit; + int i = 0; + dst->pres = 1; + if((len < 1) || (len > 32)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } +// dst->keyfac_info_len = len; +// memcpy(dst->key_fac_info, src, dst->keyfac_info_len); + dst->keyfac_info_len = len - offset; + while((offset < len) && ((digit = IA5_to_Hex(src[offset])) < 0x0D)) + { + dst->key_fac_info[i] = digit; + offset++; + i++; + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_sign(u8 *dst, Sign *src) +{ + u8 offset = 0; + dst[offset++] = src->sign_val; + + return offset; +} + +int isdn_decode_sign(Sign *dst, u8 *src, u8 len) +{ + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->sign_val = (src[0]); + + return ISDN_CM_OK; +} + + +u8 isdn_encode_cg_num(u8 *dst, CgPtyNum *src) +{ + u8 offset = 0; + int i = 0; + dst[offset++] = (src->b3.has_ext_a << 7) | (src->b3.num_type << 4) | (src->b3.num_plan_id); + if(!src->b3.has_ext_a) //with 3a + { + dst[offset++] = 0x80 | (src->b3.pres_ind << 5) | (src->b3.screen_ind); + } + + if(src->ext_flag & 0x01) //octet 4 + { + while(i < src->num_digit_len) + { + dst[offset++] = Hex_to_IA5(src->num_digit[i]); + i++; + } + } + + return offset; +} + +int isdn_decode_cg_num(CgPtyNum *dst, u8 *src, u8 len) +{ + u8 offset = 0, digit; + int i = 0; + dst->pres = 1; + if((len < 1) || (len > 34)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b3.num_type = ((src[offset] & 0x70) >> 4); + dst->b3.num_plan_id = (src[offset++] & 0x0F); + if(!dst->b3.has_ext_a) //with 3a + { + dst->b3.pres_ind = ((src[offset] & 0x60) >> 5); + dst->b3.screen_ind = (src[offset++] & 0x03); + } + + if(offset < len) + { + dst->ext_flag |= 0x01; + dst->num_digit_len = len - offset; + while((offset < len) && ((digit = IA5_to_Hex(src[offset])) < 0x0D)) //octet 4 + { + dst->num_digit[i] = digit; + offset++; + i++; + } + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_cg_addr(u8 *dst, CgPtyAddr *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->addr_type << 4) | (src->odd_even << 3); + memcpy(dst+offset, src->addr_info, src->addr_info_len); + offset += src->addr_info_len; + + return offset; +} + +int isdn_decode_cg_addr(CgPtyAddr *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 21)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->addr_type = ((src[offset] & 0x70) >> 4); + dst->odd_even = ((src[offset++] & 0x08) >> 3); + dst->addr_info_len = len - 1; + memcpy(dst->addr_info, src+offset, dst->addr_info_len); + + return ISDN_CM_OK; +} + +u8 isdn_encode_cd_num(u8 *dst, CdPtyNum *src) +{ + u8 offset = 0; + int i = 0; + dst[offset++] = 0x80 | (src->num_type << 4) | (src->num_plan_id); + while(i < src->num_digit_len) + { + dst[offset++] = Hex_to_IA5(src->num_digit[i]); + i++; + } + + return offset; +} + +int isdn_decode_cd_num(CdPtyNum *dst, u8 *src, u8 len) +{ + u8 offset = 0, digit; + int i = 0; + dst->pres = 1; + if((len < 2) || (len > 33)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->num_type = ((src[offset] & 0x70) >> 4); + dst->num_plan_id = (src[offset++] & 0x0F); + dst->num_digit_len = len - offset; + while((offset < len) && ((digit = IA5_to_Hex(src[offset])) < 0x0D)) + { + dst->num_digit[i] = digit; + offset++; + i++; + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_cd_addr(u8 *dst, CdPtyAddr *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->addr_type << 4) | (src->odd_even); + memcpy(dst+offset, src->addr_info, src->addr_info_len); + offset += src->addr_info_len; + + return offset; +} + +int isdn_decode_cd_addr(CdPtyAddr *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 21)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->addr_type = ((src[offset] & 0x70) >> 4); + dst->odd_even = ((src[offset++] & 0x08) >> 3); + dst->addr_info_len = len - 1; + memcpy(dst->addr_info, src+offset, dst->addr_info_len); + + return ISDN_CM_OK; +} + +u8 isdn_encode_tran_sel(u8 *dst, TranNtSel *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->net_id_type << 4) | (src->net_id_plan); + dst[offset++] = src->net_id & 0x7F; + + return offset; +} + +int isdn_decode_tran_sel(TranNtSel *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len < 2) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->net_id_type = ((src[offset] & 0x70) >> 4); + dst->net_id_plan = (src[offset++] & 0x0F); + dst->net_id = (src[offset++] & 0x7F); + + return ISDN_CM_OK; +} + +u8 isdn_encode_restart_ind(u8 *dst, RestartInd *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->clas); + + return offset; +} + +int isdn_decode_restart_ind(RestartInd *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->clas = (src[offset++] & 0x07); + + return ISDN_CM_OK; +} + +u8 isdn_encode_ll_comp(u8 *dst, LLComp *src) +{ + u8 offset = 0; + dst[offset++] = (src->b3.has_ext_a << 7) | (src->b3.code_stan << 5) | (src->b3.tran_cap); + if(!src->b3.has_ext_a) //octet 3 with 3a + { + dst[offset++] = 0x80 | (src->b3.neg_ind << 6); + } + dst[offset++] = 0x80 | (src->b4.tran_mode << 5) | (src->b4.tran_rate); + if((src->b4.tran_rate & 0x1F) == 0x18) //with 4.1 multirate + { + dst[offset++] = 0x80 | (src->b4.rate_mul); + } + if(src->ext_flag & 0x01) //octet 5 + { + dst[offset++] = (src->b5.has_ext_a << 7) | (0x1 << 5) | (src->b5.usr_layer1); + if(!src->b5.has_ext_a) //with 5a + { + dst[offset++] = (src->b5.has_ext_b << 7) | (src->b5.syn_asy << 6) | + (src->b5.neg << 5) | (src->b5.usr_rate); + + if(!src->b5.has_ext_b) //with 5b + { + if((src->b5.usr_layer1 & 0xFF) == 0x1) + { + dst[offset++] = (src->b5.has_ext_c << 7) | (src->b5.inter_rate << 5) | + (src->b5.nic_tx << 4) | (src->b5.nic_rx << 3) | + (src->b5.ctl_tx << 2) | (src->b5.ctl_rx <<1); + } + else if((src->b5.usr_layer1 & 0xFF) == 0x8) + { + dst[offset++] = (src->b5.has_ext_c << 7) | (src->b5.hdr << 6) | + (src->b5.mul_fra << 5) | (src->b5.mode << 4) | + (src->b5.lli_neg << 3) | (src->b5.assign << 2) | + (src->b5.inband << 1); + } + + if(!src->b5.has_ext_c) //5c + { + dst[offset++] = (src->b5.has_ext_d << 7) | (src->b5.stop_bit << 5) | + (src->b5.data_bit << 3) | (src->b5.par); + + if(!src->b5.has_ext_d) //5d + { + dst[offset++] = 0x80 | (src->b5.du_mode << 6) | (src->b5.mod_type); + } + } + } + } + } + else if(src->ext_flag & 0x02) //octet 6 + { + if((src->b6.usr_layer2 & 0x1F) == 0x10) //with 6a for user specified layer 2 protocol + { + dst[offset++] = (0x2 << 5) | (src->b6.usr_layer2); + dst[offset++] = 0x80 | (src->b6.usr_layer2_info); + } + else if(((src->b6.usr_layer2 & 0x1F) == 0x02) || ((src->b6.usr_layer2 & 0x1F) == 0x06) || + ((src->b6.usr_layer2 & 0x1F) == 0x07) || ((src->b6.usr_layer2 & 0x1F) == 0x09) || + ((src->b6.usr_layer2 & 0x1F) == 0x0A) || ((src->b6.usr_layer2 & 0x1F) == 0x0B) || + ((src->b6.usr_layer2 & 0x1F) == 0x0D) || ((src->b6.usr_layer2 & 0x1F) == 0x0E) || + ((src->b6.usr_layer2 & 0x1F) == 0x11)) //with 6a and 6b HDLC elements + { + dst[offset++] = (0x2 << 5) | (src->b6.usr_layer2); + dst[offset++] = (src->b6.mode << 5) | (src->b6.q933_use); + dst[offset++] = 0x80 | (src->b6.win_size); + } + else + { + dst[offset++] = 0x80 | (0x2 << 5) | (src->b6.usr_layer2); + } + } + else if(src->ext_flag & 0x04) //octet 7 + { + if((src->b7.usr_layer3 & 0x1F) == 0x10) //with 7a for user specified layer 3 protocol + { + dst[offset++] = (0x3 << 5) | (src->b7.usr_layer3); + dst[offset++] = 0x80 | (src->b7.usr_layer3_info); + } + else if(((src->b7.usr_layer3 & 0x1F) == 0x6) || ((src->b7.usr_layer3 & 0x1F) == 0x7) || + ((src->b7.usr_layer3 & 0x1F) == 0x8)) //with 7a, 7b and 7c + { + dst[offset++] = (0x3 << 5) | (src->b7.usr_layer3); + dst[offset++] = (src->b7.mode); + dst[offset++] = (src->b7.def_pac_size); + dst[offset++] = 0x80 | (src->b7.pac_win_size); + } + else + { + dst[offset++] = 0x80 | (0x3 << 5) | (src->b7.usr_layer3); + } + } + + return offset; +} + +int isdn_decode_ll_comp(LLComp *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 16)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b3.code_stan = ((src[offset] & 0x60) >> 5); + dst->b3.tran_cap = (src[offset++] & 0x1F); + if(!dst->b3.has_ext_a) //with 3a + { + dst->b3.neg_ind = ((src[offset++] & 0x40) >> 6); + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->b4.tran_mode = ((src[offset] & 0x60) >> 5); + dst->b4.tran_rate = (src[offset++] & 0x1F); + if((dst->b4.tran_rate & 0x1F) == 0x18) //with 4.1 + { + dst->b4.rate_mul = (src[offset++] & 0x7F); + } + + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x1) //octet 5 + { + dst->ext_flag |= 0x01; + dst->b5.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b5.usr_layer1 = (src[offset++] & 0x1F); + if(!dst->b5.has_ext_a) //with 5a + { + dst->b5.has_ext_b = ((src[offset] & 0x80) >> 7); + dst->b5.syn_asy = ((src[offset] & 0x40) >> 6); + dst->b5.neg = ((src[offset] & 0x20) >> 5); + dst->b5.usr_rate = (src[offset++] & 0x1F); + if(!dst->b5.has_ext_b) //with 5b + { + dst->b5.has_ext_c = ((src[offset] & 0x80) >> 7); + if((dst->b5.usr_layer1 & 0x1F) == 0x1) //V.110/X.30 + { + dst->b5.inter_rate = ((src[offset] & 0x60) >> 5); + dst->b5.nic_tx = ((src[offset] & 0x10) >> 4); + dst->b5.nic_rx = ((src[offset] & 0x08) >> 3); + dst->b5.ctl_tx = ((src[offset] & 0x04) >> 2); + dst->b5.ctl_rx = ((src[offset++] & 0x02) >> 1); + } + else if((dst->b5.usr_layer1 & 0x1F) == 0x8) //V.120 + { + dst->b5.hdr = ((src[offset] & 0x40) >> 6); + dst->b5.mul_fra = ((src[offset] & 0x20) >> 5); + dst->b5.mode = ((src[offset] & 0x10) >> 4); + dst->b5.lli_neg = ((src[offset] & 0x08) >> 3); + dst->b5.assign = ((src[offset] & 0x04) >> 2); + dst->b5.inband =((src[offset++] & 0x02) >> 1); + } + + if(!dst->b5.has_ext_c) //with 5c + { + dst->b5.has_ext_d = ((src[offset] & 0x80) >> 7); + dst->b5.stop_bit = ((src[offset] & 0x60) >> 5); + dst->b5.data_bit = ((src[offset] & 0x18) >> 3); + dst->b5.par = (src[offset++] & 0x07); + + if(!dst->b5.has_ext_d) //with 5d + { + dst->b5.du_mode = ((src[offset] & 0x40) >> 6); + dst->b5.mod_type =(src[offset++] & 0x3F); + } + } + } + } + } + } + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x2) //octet 6 + { + dst->ext_flag |= 0x02; + dst->b6.usr_layer2 = (src[offset++] & 0x1F); + if((dst->b6.usr_layer2 & 0x1F) == 0x10) //with 6a for user specified layer 2 protocol + { + dst->b6.usr_layer2_info = (src[offset++] & 0x7F); + } + else if(((dst->b6.usr_layer2 & 0x1F) == 0x02) || ((dst->b6.usr_layer2 & 0x1F) == 0x06) || + ((dst->b6.usr_layer2 & 0x1F) == 0x07) || ((dst->b6.usr_layer2 & 0x1F) == 0x09) || + ((dst->b6.usr_layer2 & 0x1F) == 0x0A) || ((dst->b6.usr_layer2 & 0x1F) == 0x0B) || + ((dst->b6.usr_layer2 & 0x1F) == 0x0D) || ((dst->b6.usr_layer2 & 0x1F) == 0x0E) || + ((dst->b6.usr_layer2 & 0x1F) == 0x11)) //with 6a and 6b HDLC elements + { + dst->b6.mode = ((src[offset] & 0x60) >> 5); + dst->b6.q933_use = (src[offset++] & 0x03); + } + } + } + if(offset < len) //octet at offside + { + if(((src[offset] & 0x60) >> 5) == 0x3) //octet 7 + { + dst->ext_flag |= 0x04; + dst->b7.usr_layer3 = (src[offset] & 0x1F); + if((dst->b7.usr_layer3 & 0x1F) == 0x10) //with 7a for user specified layer 3 protocol + { + dst->b7.usr_layer3_info = (src[offset++] & 0x7F); + } + else if(((dst->b7.usr_layer3 & 0x1F) == 0x6) || ((dst->b7.usr_layer3 & 0x1F) == 0x7) || + ((dst->b7.usr_layer3 & 0x1F) == 0x8)) //with 7a, 7b and 7c + { + dst->b7.mode = ((src[offset++] & 0x60) >> 5); + dst->b7.def_pac_size = (src[offset++] & 0x0F); + dst->b7.pac_win_size = (src[offset++] & 0x7F); + } + } + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_hl_comp(u8 *dst, HLComp *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->code_stan << 5) | (src->intpr << 2) | (src->pre_meth); + if(((src->b4.hl_ch_id & 0x7F) == 0x5E) || ((src->b4.hl_ch_id & 0x7F) == 0x5F)) //with 4a maintenance or management + { + dst[offset++] = src->b4.hl_ch_id; + dst[offset++] = 0x80 | (src->b4.ex_hl_ch_id); + } + else if(((src->b4.hl_ch_id & 0x7F) >= 0x60) && ((src->b4.hl_ch_id & 0x7F) <= 0x6F)) //with 4a audio visual + { + dst[offset++] = src->b4.hl_ch_id; + dst[offset++] = 0x80 | (src->b4.ex_vid_ch_id); + } + else + { + dst[offset++] = 0x80 | (src->b4.hl_ch_id); + } + + return offset; +} + +int isdn_decode_hl_comp(HLComp *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 3)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[offset] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->code_stan = ((src[offset] & 0x60) >> 5); + dst->intpr = ((src[offset] & 0x1C) >> 2); + dst->pre_meth = (src[offset++] & 0x03); + dst->b4.hl_ch_id = (src[offset++] & 0x7F); + if(((dst->b4.hl_ch_id & 0x7F) == 0x5E) || ((dst->b4.hl_ch_id & 0x7F) == 0x5F)) //with 4a maintenance or management + { + dst->b4.ex_hl_ch_id = (src[offset++] & 0x7F); + } + else if(((dst->b4.hl_ch_id & 0x7F) >= 0x60) && ((dst->b4.hl_ch_id & 0x7F) <= 0x6F)) //with 4a audio visual + { + dst->b4.ex_vid_ch_id = (src[offset++] & 0x7F); + } + + return ISDN_CM_OK; +} + +u8 isdn_encode_usr_usr(u8 *dst, UsrUsr *src) +{ + u8 offset = 0; + dst[offset++] = src->pro_discr; + memcpy(dst+offset, src->usr_info, src->usr_info_len); + offset += src->usr_info_len; + + return offset; +} + +int isdn_decode_usr_usr(UsrUsr *dst, u8 *src, u8 len) +{ + u8 offset = 0; + dst->pres = 1; + if((len < 2) || (len > 129)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->pro_discr = (src[offset++] & 0xFF); + dst->usr_info_len = len - 1; + memcpy(dst->usr_info, src+offset, dst->usr_info_len); + + return ISDN_CM_OK; +} + + +//ie exist only in ansi +u8 ansi_encode_chg_stat(u8 *dst, ChgStat *src) +{ + u8 offset = 0; + dst[offset++] = 0x80 | (src->pref << 6) | (src->new_stat); + + return offset; +} + +int ansi_decode_chg_stat(ChgStat *dst, u8 *src, u8 len) +{ + dst->pres = 1; + if(len != 1) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + + if(!(src[0] & 0x80)) + { + printf("encode ie err!\n"); + return ISDN_CM_FAILED; + } + dst->pref = ((src[0] & 0x40) >> 6); + dst->new_stat = (src[0] & 0x07); + + return ISDN_CM_OK; +} + +u8 ansi_encode_redir_num(u8 *dst, RedirNum *src) +{ + u8 offset = 0; + int i = 0; + dst[offset++] = 0x80 | (src->b3.num_type << 4) | (src->b3.num_plan_id); + dst[offset++] = 0x80 | (src->b3.org_num_stat); // 3a + dst[offset++] = 0x80 | (src->b3.redir_rs); // 3b + + while(i < src->num_digit_len) + { + dst[offset++] = Hex_to_IA5(src->num_digit[i]); + i++; + } + + return offset; +} + +int ansi_decode_redir_num(RedirNum *dst, u8 *src, u8 len) +{ + u8 offset = 0, digit; + int i = 0; + dst->pres = 1; + if((len < 4) || (len > 35)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.num_type = ((src[offset] & 0x70) >> 4); + dst->b3.num_plan_id = (src[offset++] & 0x0F); + dst->b3.org_num_stat = (src[offset++] & 0x7F); // 3a + dst->b3.redir_rs= (src[offset++] & 0x0F); // 3b + + dst->num_digit_len = len - offset; + while((offset < len) && ((digit = IA5_to_Hex(src[offset])) < 0x0D)) //octet 4 + { + dst->num_digit[i] = digit; + offset++; + i++; + } + + return ISDN_CM_OK; +} + + +//QSIG +u8 qsig_encode_conn_num(u8 *dst, ConnNum *src) +{ + u8 offset = 0; + int i = 0; + dst[offset++] = (src->b3.has_ext_a << 7) | (src->b3.num_type << 4) | (src->b3.num_plan_id); + if(!src->b3.has_ext_a) //with 3a + { + dst[offset++] = 0x80 | (src->b3.pres_ind << 5) | (src->b3.screen_ind); + } + + if(src->ext_flag & 0x01) //octet 4 + { + while(i < src->num_digit_len) + { + dst[offset++] = Hex_to_IA5(src->num_digit[i]); + i++; + } + } + + return offset; +} + +int qsig_decode_conn_num(ConnNum *dst, u8 *src, u8 len) +{ + u8 offset = 0, digit; + int i = 0; + dst->pres = 1; + if((len < 1) || (len > 34)) + { + printf("len err!\n"); + return ISDN_CM_FAILED; + } + dst->b3.has_ext_a = ((src[offset] & 0x80) >> 7); + dst->b3.num_type = ((src[offset] & 0x70) >> 4); + dst->b3.num_plan_id = (src[offset++] & 0x0F); + if(!dst->b3.has_ext_a) //with 3a + { + dst->b3.pres_ind = ((src[offset] & 0x60) >> 5); + dst->b3.screen_ind = (src[offset++] & 0x03); + } + + if(offset < len) + { + dst->ext_flag |= 0x01; + dst->num_digit_len = len - offset; + while((offset < len) && ((digit = IA5_to_Hex(src[offset])) < 0x0D)) //octet 4 + { + dst->num_digit[i] = digit; + offset++; + i++; + } + } + + return ISDN_CM_OK; +} + diff --git a/omc/plat/isdn/src/isdn_msg.c b/omc/plat/isdn/src/isdn_msg.c new file mode 100644 index 0000000..a0059b1 --- /dev/null +++ b/omc/plat/isdn/src/isdn_msg.c @@ -0,0 +1,3439 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_rm.c +Description: ISDN Resource Management +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ +#include "./include/isdn_const.h" +#include "../../m2ua/src/include/m2ua_const.h" +#include "./include/isdn_rm.h" +#include "./include/isdn_debug.h" +#include "./include/isdn_ext.h" +#include "./include/isdn_inc.h" + + +extern void isdn_cpc_proc(u32 pid); +extern void service_bc_proc(u32 pid); +extern void service_dc_proc(u32 pid); +extern void isdn_restart_ctrl(u32 pid); +extern int isdn_rel_proc(u32 pid, u32 cause); +extern int rel_cr(u32 pid); +extern inline void isdn_cpc_clear(ISDN_Port_struct *pPort); +extern int isdn_event_handle(u32 pid, u8 primitive); +extern void isdn_set_cause(CauseStr *cause_ptr, u8 val); +extern void isdn_set_status(IsdnStatus *status_ptr, u8 state, u8 cause_val); +//msc +extern int msc_give_cic_value(u32 tg_id, int head_cic); + +static int isdn_encode_alert(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnAlert *ptr = &src->msg_list.alert; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + if(variant == VARIANT_QSIG) + flw_ptr[1] = qsig_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + else + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->hl_comp.pres == 1) + { + flw_ptr[0] = IE_HL_COMP; + flw_ptr[1] = isdn_encode_hl_comp(flw_ptr+2, &ptr->hl_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_alert(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnAlert *ptr = &dst->msg_list.alert; + u8 *flw_ptr = src; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_BR_CAP: + if(variant == VARIANT_ITU) + itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: + if(variant == VARIANT_QSIG) + qsig_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + else + isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_HL_COMP: + if(variant == VARIANT_ITU) + isdn_decode_hl_comp(&ptr->hl_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_call_proc(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnCallProc *ptr = &src->msg_list.callProc; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + } + + //if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + if(variant == VARIANT_QSIG) + flw_ptr[1] = qsig_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + else + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->hl_comp.pres == 1) + { + flw_ptr[0] = IE_HL_COMP; + flw_ptr[1] = isdn_encode_hl_comp(flw_ptr+2, &ptr->hl_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_call_proc(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnCallProc *ptr = &dst->msg_list.callProc; + u8 *flw_ptr = src; + u8 ie_m = 0; + int ret = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_BR_CAP: + if(variant == VARIANT_ITU) + itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: //M + if(variant == VARIANT_QSIG) + ret = qsig_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + else + ret = isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + if(!ret) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + if(variant == VARIANT_ITU) + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_HL_COMP: + if(variant == VARIANT_ITU) + isdn_decode_hl_comp(&ptr->hl_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_conn(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnConn *ptr = &src->msg_list.conn; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + if(variant == VARIANT_QSIG) + flw_ptr[1] = qsig_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + else + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->dt_time.pres == 1) + { + flw_ptr[0] = IE_DT_TIME; + flw_ptr[1] = isdn_encode_dt_time(flw_ptr+2, &ptr->dt_time); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->ll_comp.pres == 1) + { + flw_ptr[0] = IE_LL_COMP; + flw_ptr[1] = isdn_encode_ll_comp(flw_ptr+2, &ptr->ll_comp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->hl_comp.pres == 1) + { + flw_ptr[0] = IE_HL_COMP; + flw_ptr[1] = isdn_encode_hl_comp(flw_ptr+2, &ptr->hl_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + else if(variant == VARIANT_QSIG) + { + if(ptr->conn_num.pres == 1) + { + flw_ptr[0] = IE_CONN_NUM; + flw_ptr[1] = qsig_encode_conn_num(flw_ptr+2, &ptr->conn_num); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->ll_comp.pres == 1) + { + flw_ptr[0] = IE_LL_COMP; + flw_ptr[1] = isdn_encode_ll_comp(flw_ptr+2, &ptr->ll_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_conn(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnConn *ptr = &dst->msg_list.conn; + u8 *flw_ptr = src; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_BR_CAP: + if(variant == VARIANT_ITU) + itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: + if(variant == VARIANT_QSIG) + qsig_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + else + isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DT_TIME: + if(variant == VARIANT_ITU) + isdn_decode_dt_time(&ptr->dt_time, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CONN_NUM: + if(variant == VARIANT_QSIG) + qsig_decode_conn_num(&ptr->conn_num, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_LL_COMP: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + isdn_decode_ll_comp(&ptr->ll_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_HL_COMP: + if(variant == VARIANT_ITU) + isdn_decode_hl_comp(&ptr->hl_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_conn_ack(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnConnAck *ptr = &src->msg_list.connAck; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_conn_ack(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnConnAck *ptr = &dst->msg_list.connAck; + u8 *flw_ptr = src; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_prog(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnProg *ptr = &src->msg_list.prog; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->cause.pres == 1) + { + flw_ptr[0] = IE_CAUSE; + flw_ptr[1] = isdn_encode_cause(flw_ptr+2, &ptr->cause); + flw_ptr += flw_ptr[1] + 2; + } + + //Mandatory if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->hl_comp.pres == 1) + { + flw_ptr[0] = IE_HL_COMP; + flw_ptr[1] = isdn_encode_hl_comp(flw_ptr+2, &ptr->hl_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_prog(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnProg *ptr = &dst->msg_list.prog; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_BR_CAP: + if(variant == VARIANT_ITU) + itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CAUSE: + isdn_decode_cause(&ptr->cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: //M + if(!(isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]))) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_HL_COMP: + if(variant == VARIANT_ITU) + isdn_decode_hl_comp(&ptr->hl_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_setup(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnSetup *ptr = &src->msg_list.setup; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + { + if(ptr->sd_comp.pres == 1) + { + flw_ptr[0] = IE_SD_COMP; + flw_ptr += 1; + } + } + + if(variant == VARIANT_ITU) + { + if(ptr->rpt_ind.pres == 1) + { + flw_ptr[0] = IE_RPT_IND; + flw_ptr += 1; + } + } + + //Mandatory if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + if(variant == VARIANT_ITU) + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + else + flw_ptr[1] = isdn_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + //if(ptr->chnl_id.pres == 1) //user side is optional but network side is mandatory + { + flw_ptr[0] = IE_CHNL_ID; + if(variant == VARIANT_QSIG) + flw_ptr[1] = qsig_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + else + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + //Optional + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU || variant == VARIANT_ANSI) + { + if(ptr->nt_sp_fac.pres == 1) + { + flw_ptr[0] = IE_NT_SP_FAC; + flw_ptr[1] = isdn_encode_ntsp_fac(flw_ptr+2, &ptr->nt_sp_fac); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->dt_time.pres == 1) + { + flw_ptr[0] = IE_DT_TIME; + flw_ptr[1] = isdn_encode_dt_time(flw_ptr+2, &ptr->dt_time); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->kpd_fac.pres == 1) + { + flw_ptr[0] = IE_KPD_FAC; + flw_ptr[1] = isdn_encode_kpd_fac(flw_ptr+2, &ptr->kpd_fac); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->cg_pty_num.pres == 1) + { + flw_ptr[0] = IE_CG_PTY_NUM; + flw_ptr[1] = isdn_encode_cg_num(flw_ptr+2, &ptr->cg_pty_num); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + { + if(ptr->cg_pty_addr.pres == 1) + { + flw_ptr[0] = IE_CG_PTY_ADDR; + flw_ptr[1] = isdn_encode_cg_addr(flw_ptr+2, &ptr->cg_pty_addr); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->cd_pty_num.pres == 1) + { + flw_ptr[0] = IE_CD_PTY_NUM; + flw_ptr[1] = isdn_encode_cd_num(flw_ptr+2, &ptr->cd_pty_num); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + { + if(ptr->cd_pty_addr.pres == 1) + { + flw_ptr[0] = IE_CD_PTY_ADDR; + flw_ptr[1] = isdn_encode_cd_addr(flw_ptr+2, &ptr->cd_pty_addr); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(variant == VARIANT_ANSI) + { + if(ptr->redir_num.pres == 1) + { + flw_ptr[0] = IE_REDIR_NUM; + flw_ptr[1] = ansi_encode_redir_num(flw_ptr+2, &ptr->redir_num); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(variant == VARIANT_ITU || variant == VARIANT_ANSI) + { + if(ptr->tran_nt_sel.pres == 1) + { + flw_ptr[0] = IE_TRAN_NT_SEL; + flw_ptr[1] = isdn_encode_tran_sel(flw_ptr+2, &ptr->tran_nt_sel); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + { + if(ptr->ll_comp.pres == 1) + { + flw_ptr[0] = IE_LL_COMP; + flw_ptr[1] = isdn_encode_ll_comp(flw_ptr+2, &ptr->ll_comp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->hl_comp.pres == 1) + { + flw_ptr[0] = IE_HL_COMP; + flw_ptr[1] = isdn_encode_hl_comp(flw_ptr+2, &ptr->hl_comp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_setup(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnSetup *ptr = &dst->msg_list.setup; + u8 *flw_ptr = src; + u8 ie_m = 0; + int ret = 0; + int qsig_ie_m = 0; + + while(flw_ptr+1-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + if(qsig_ie_m != 2 && variant != VARIANT_ITU) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_SD_COMP: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + ptr->sd_comp.pres = 1; + flw_ptr += 1; + break; + case IE_RPT_IND: + if(variant == VARIANT_ITU) + ptr->rpt_ind.pres = 1; + flw_ptr += 1; + break; + case IE_BR_CAP: //M + if(!itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: //M + if(variant == VARIANT_QSIG) + ret = qsig_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + else + ret = isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + if(!ret) + { + printf("channel identification ie is err!\n"); + return 2; + } + qsig_ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_NT_SP_FAC: + if(variant == VARIANT_ITU || variant == VARIANT_ANSI) + isdn_decode_ntsp_fac(&ptr->nt_sp_fac, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DT_TIME: + if(variant == VARIANT_ITU) + isdn_decode_dt_time(&ptr->dt_time, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_KPD_FAC: + if(variant == VARIANT_ITU) + isdn_decode_kpd_fac(&ptr->kpd_fac, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CG_PTY_NUM: + isdn_decode_cg_num(&ptr->cg_pty_num, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CG_PTY_ADDR: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + isdn_decode_cg_addr(&ptr->cg_pty_addr, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CD_PTY_NUM: + ret = isdn_decode_cd_num(&ptr->cd_pty_num, flw_ptr+2, flw_ptr[1]); + if((!ret) && (variant != VARIANT_ITU)) + { + printf("called number ie is err!\n"); + return 2; + } + qsig_ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CD_PTY_ADDR: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + isdn_decode_cd_addr(&ptr->cd_pty_addr, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_REDIR_NUM: + if(variant == VARIANT_ANSI) + ansi_decode_redir_num(&ptr->redir_num, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_TRAN_NT_SEL: + if(variant == VARIANT_ITU || variant == VARIANT_ANSI) + isdn_decode_tran_sel(&ptr->tran_nt_sel, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_LL_COMP: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + isdn_decode_ll_comp(&ptr->ll_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_HL_COMP: + if(variant == VARIANT_ITU || variant == VARIANT_QSIG) + isdn_decode_hl_comp(&ptr->hl_comp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + if(qsig_ie_m != 2 && variant != VARIANT_ITU) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_setup_ack(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnSetupAck *ptr = &src->msg_list.setupAck; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + //if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + else if(variant == VARIANT_QSIG) + { + //if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = qsig_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + } + else + { + printf("encode: there isnot msg setup ack in ansi!\n"); + return -1; + } + + return flw_ptr - dst; +} + +int isdn_decode_setup_ack(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnSetupAck *ptr = &dst->msg_list.setupAck; + u8 *flw_ptr = src; + u8 ie_m = 0; + int ret; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CHNL_ID: //M + if(variant == VARIANT_QSIG) + ret = qsig_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + else + ret = isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + if(!ret) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + if(variant == VARIANT_ITU) + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_disc(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnDisc *ptr = &src->msg_list.disc; + u8 *flw_ptr = dst; + + //Mandatory if(ptr->cause.pres == 1) + { + flw_ptr[0] = IE_CAUSE; + flw_ptr[1] = isdn_encode_cause(flw_ptr+2, &ptr->cause); + flw_ptr += flw_ptr[1] + 2; + } + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->prg_ind.pres == 1) + { + flw_ptr[0] = IE_PRG_IND; + flw_ptr[1] = isdn_encode_prg_ind(flw_ptr+2, &ptr->prg_ind); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_disc(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnDisc *ptr = &dst->msg_list.disc; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CAUSE: + if(!isdn_decode_cause(&ptr->cause, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_PRG_IND: + if(variant == VARIANT_ITU) + isdn_decode_prg_ind(&ptr->prg_ind, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_rel(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnRel *ptr = &src->msg_list.rel; + u8 *flw_ptr = dst; + + //Optional +// if(ptr->cause.pres == 1) + { + flw_ptr[0] = IE_CAUSE; + flw_ptr[1] = isdn_encode_cause(flw_ptr+2, &ptr->cause); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_rel(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnRel *ptr = &dst->msg_list.rel; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CAUSE: + if(!isdn_decode_cause(&ptr->cause, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_rel_comp(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnRelComp *ptr = &src->msg_list.relComp; + u8 *flw_ptr = dst; + + //Optional + if(ptr->cause.pres == 1) + { + flw_ptr[0] = IE_CAUSE; + flw_ptr[1] = isdn_encode_cause(flw_ptr+2, &ptr->cause); + flw_ptr += flw_ptr[1] + 2; + } + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_rel_comp(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnRelComp *ptr = &dst->msg_list.relComp; + u8 *flw_ptr = src; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_CAUSE: + isdn_decode_cause(&ptr->cause, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_restart(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnRestart *ptr = &src->msg_list.restart; + u8 *flw_ptr = dst; + + //Optional + if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + } + + //Mandatory if(ptr->restart_ind.pres == 1) + { + flw_ptr[0] = IE_RESTART_IND; + flw_ptr[1] = isdn_encode_restart_ind(flw_ptr+2, &ptr->restart_ind); + flw_ptr += flw_ptr[1] + 2; + } + + return flw_ptr - dst; +} + +int isdn_decode_restart(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnRestart *ptr = &dst->msg_list.restart; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CHNL_ID: + isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_RESTART_IND: + if(!isdn_decode_restart_ind(&ptr->restart_ind, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_rest_ack(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnRestAck *ptr = &src->msg_list.restAck; + u8 *flw_ptr = dst; + + //Optional + if(ptr->chnl_id.pres == 1) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + } + + //Mandatory if(ptr->restart_ind.pres == 1) + { + flw_ptr[0] = IE_RESTART_IND; + flw_ptr[1] = isdn_encode_restart_ind(flw_ptr+2, &ptr->restart_ind); + flw_ptr += flw_ptr[1] + 2; + } + + return flw_ptr - dst; +} + +int isdn_decode_rest_ack(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnRestAck *ptr = &dst->msg_list.restAck; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CHNL_ID: + isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_RESTART_IND: + if(!isdn_decode_restart_ind(&ptr->restart_ind, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_info(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnInfo *ptr = &src->msg_list.info; + u8 *flw_ptr = dst; + + //Optional + if(ptr->sd_comp.pres == 1) + { + flw_ptr[0] = IE_SD_COMP; + flw_ptr += 1; + } + + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->kpd_fac.pres == 1) + { + flw_ptr[0] = IE_KPD_FAC; + flw_ptr[1] = isdn_encode_kpd_fac(flw_ptr+2, &ptr->kpd_fac); + flw_ptr += flw_ptr[1] + 2; + } + if(ptr->sign.pres == 1) + { + flw_ptr[0] = IE_SIGN; + flw_ptr[1] = isdn_encode_sign(flw_ptr+2, &ptr->sign); + flw_ptr += flw_ptr[1] + 2; + } + } + + if(ptr->cd_pty_num.pres == 1) + { + flw_ptr[0] = IE_CD_PTY_NUM; + flw_ptr[1] = isdn_encode_cd_num(flw_ptr+2, &ptr->cd_pty_num); + flw_ptr += flw_ptr[1] + 2; + } + + return flw_ptr - dst; +} + +int isdn_decode_info(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnInfo *ptr = &dst->msg_list.info; + u8 *flw_ptr = src; + + while(flw_ptr+1-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_SD_COMP: + ptr->sd_comp.pres = 1; + flw_ptr += 1; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_KPD_FAC: + if(variant == VARIANT_ITU) + isdn_decode_kpd_fac(&ptr->kpd_fac, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_SIGN: + if(variant == VARIANT_ITU) + isdn_decode_sign(&ptr->sign, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CD_PTY_NUM: + isdn_decode_cd_num(&ptr->cd_pty_num, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + +static int isdn_encode_noti(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnNoti *ptr = &src->msg_list.noti; + u8 *flw_ptr = dst; + + //Mandatory + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->br_cap.pres == 1) + { + flw_ptr[0] = IE_BR_CAP; + flw_ptr[1] = itu_encode_br_cap(flw_ptr+2, &ptr->br_cap); + flw_ptr += flw_ptr[1] + 2; + } + } + + //Mandatory if(ptr->notify_ind.pres == 1) + { + flw_ptr[0] = IE_NOTIFY_IND; + flw_ptr[1] = isdn_encode_notify_ind(flw_ptr+2, &ptr->notify_ind); + flw_ptr += flw_ptr[1] + 2; + } + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_noti(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnNoti *ptr = &dst->msg_list.noti; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_BR_CAP: + if(variant == VARIANT_ITU) + itu_decode_br_cap(&ptr->br_cap, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case IE_NOTIFY_IND: + if(!isdn_decode_notify_ind(&ptr->notify_ind, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 1) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_status(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnStatus *ptr = &src->msg_list.status; + u8 *flw_ptr = dst; + + //Mandatory if(ptr->cause.pres == 1) + { + flw_ptr[0] = IE_CAUSE; + flw_ptr[1] = isdn_encode_cause(flw_ptr+2, &ptr->cause); + flw_ptr += flw_ptr[1] + 2; + } + //if(ptr->call_stat.pres == 1) + { + flw_ptr[0] = IE_CALL_STAT; + flw_ptr[1] = isdn_encode_call_stat(flw_ptr+2, &ptr->call_stat); + flw_ptr += flw_ptr[1] + 2; + } + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_status(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnStatus *ptr = &dst->msg_list.status; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CAUSE: + if(!isdn_decode_cause(&ptr->cause, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CALL_STAT: + if(!isdn_decode_call_stat(&ptr->call_stat, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_stat_enq(u8 *dst, IsdnMsgStr *src, int variant) +{ + IsdnStatEnq *ptr = &src->msg_list.statEnq; + u8 *flw_ptr = dst; + + //Optional + if(variant == VARIANT_ITU) + { + if(ptr->disp.pres == 1) + { + flw_ptr[0] = IE_DISP; + flw_ptr[1] = isdn_encode_disp(flw_ptr+2, &ptr->disp); + flw_ptr += flw_ptr[1] + 2; + } + } + + return flw_ptr - dst; +} + +int isdn_decode_stat_enq(IsdnMsgStr *dst, u8 *src, int variant, u8 len) +{ + IsdnStatEnq *ptr = &dst->msg_list.statEnq; + u8 *flw_ptr = src; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + break; + } + switch(*flw_ptr) + { + case IE_DISP: + if(variant == VARIANT_ITU) + isdn_decode_disp(&ptr->disp, flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + + return ISDN_CM_OK; +} + + +//maintenance messages ansi +static int isdn_encode_service(u8 *dst, IsdnMsgStr *src) +{ + IsdnService *ptr = &src->msg_list.service; + u8 *flw_ptr = dst; + + //Mandatory if(ptr->chg_stat.pres) + { + flw_ptr[0] = IE_CHG_STAT; + flw_ptr[1] = ansi_encode_chg_stat(flw_ptr+2, &ptr->chg_stat); + flw_ptr += flw_ptr[1] + 2; + } + //if(ptr->chnl_id.pres) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + return flw_ptr - dst; +} + +int isdn_decode_service(IsdnMsgStr *dst, u8 *src, u8 len) +{ + IsdnService *ptr = &dst->msg_list.service; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CHG_STAT: + if(!ansi_decode_chg_stat(&ptr->chg_stat, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: + if(!isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + +static int isdn_encode_servAck(u8 *dst, IsdnMsgStr *src) +{ + IsdnServAck *ptr = &src->msg_list.servAck; + u8 *flw_ptr = dst; + + //Mandatory if(ptr->chg_stat.pres) + { + flw_ptr[0] = IE_CHG_STAT; + flw_ptr[1] = ansi_encode_chg_stat(flw_ptr+2, &ptr->chg_stat); + flw_ptr += flw_ptr[1] + 2; + } + //if(ptr->chnl_id.pres) + { + flw_ptr[0] = IE_CHNL_ID; + flw_ptr[1] = isdn_encode_chnl_id(flw_ptr+2, &ptr->chnl_id); + flw_ptr += flw_ptr[1] + 2; + } + + return flw_ptr - dst; +} + +int isdn_decode_servAck(IsdnMsgStr *dst, u8 *src, u8 len) +{ + IsdnServAck *ptr = &dst->msg_list.servAck; + u8 *flw_ptr = src; + u8 ie_m = 0; + + while(flw_ptr+2-src <= len) + { + if(*flw_ptr == 0) + { + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + break; + } + switch(*flw_ptr) + { + case IE_CHG_STAT: + if(!ansi_decode_chg_stat(&ptr->chg_stat, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + case IE_CHNL_ID: + if(!isdn_decode_chnl_id(&ptr->chnl_id, flw_ptr+2, flw_ptr[1])) + { + printf("mandatory ie is err!\n"); + return 2; + } + ie_m++; + flw_ptr += flw_ptr[1] + 2; + break; + default: + if(*flw_ptr >= 0x80) //single octet IE + flw_ptr += 1; + else + flw_ptr += flw_ptr[1] + 2; + break; + } + } + if(ie_m != 2) + { + printf("mandatory ie is absent!\n"); + return 3; + } + + return ISDN_CM_OK; +} + + +/************************************************************* +Function: itu_msg_encode +Description: encode ITU isdn message +Output: dst:preserving destination, src:source msg structure +Return: isdn msg length:success + ISDN_CM_FAILED:failed +*************************************************************/ +int itu_msg_encode(u8 *dst, IsdnMsgStr *src) //msg from isdn to iua +{ + switch(src->msg_m.msg_type) + { + // + case MSG_ALERT: + return isdn_encode_alert(dst, src, VARIANT_ITU); + case MSG_CALL_PROC: + return isdn_encode_call_proc(dst, src, VARIANT_ITU); + case MSG_CONN: + return isdn_encode_conn(dst, src, VARIANT_ITU); + case MSG_CONNACK: + return isdn_encode_conn_ack(dst, src, VARIANT_ITU); + case MSG_PROG: + return isdn_encode_prog(dst, src, VARIANT_ITU); + case MSG_SETUP: + return isdn_encode_setup(dst, src, VARIANT_ITU); + case MSG_SETUP_ACK: + return isdn_encode_setup_ack(dst, src, VARIANT_ITU); + // + case MSG_DISC: + return isdn_encode_disc(dst, src, VARIANT_ITU); + case MSG_REL: + return isdn_encode_rel(dst, src, VARIANT_ITU); + case MSG_REL_COMP: + return isdn_encode_rel_comp(dst, src, VARIANT_ITU); + case MSG_RESTART: + return isdn_encode_restart(dst, src, VARIANT_ITU); + case MSG_REST_ACK: + return isdn_encode_rest_ack(dst, src, VARIANT_ITU); + // + case MSG_INFORMATION: + return isdn_encode_info(dst, src, VARIANT_ITU); + case MSG_NOTI: + return isdn_encode_noti(dst, src, VARIANT_ITU); + case MSG_STATUS: + return isdn_encode_status(dst, src, VARIANT_ITU); + case MSG_STAT_ENQ: + return isdn_encode_stat_enq(dst, src, VARIANT_ITU); + default: + break; + } + + return -1; +} + +/************************************************************* +Function: itu_msg_decode +Description: decode ITU isdn message +Input: msgtype:msg type, len:msg length +Output: dst:preserving destination structure, src:source msg code stream +Return: ISDN_CM_OK:success + ISDN_CM_FAILED or 2 or 3:failed +*************************************************************/ +int itu_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, u8 len) //msg from iua to isdn +{ + u8 msg_clas, msg_type; + + msg_clas = (msgtype & 0x60) >> 5; + msg_type = (msgtype & 0x1F); + + switch(msg_clas) + { + case 0x0: // + switch(msg_type) + { + case (MSG_ALERT & 0x1F): + return isdn_decode_alert(dst, src, VARIANT_ITU, len); + case (MSG_CALL_PROC & 0x1F): + return isdn_decode_call_proc(dst, src, VARIANT_ITU, len); + case (MSG_CONN & 0x1F): + return isdn_decode_conn(dst, src, VARIANT_ITU, len); + case (MSG_CONNACK & 0x1F): + return isdn_decode_conn_ack(dst, src, VARIANT_ITU, len); + case (MSG_PROG & 0x1F): + return isdn_decode_prog(dst, src, VARIANT_ITU, len); + case (MSG_SETUP & 0x1F): + return isdn_decode_setup(dst, src, VARIANT_ITU, len); + case (MSG_SETUP_ACK & 0x1F): + return isdn_decode_setup_ack(dst, src, VARIANT_ITU, len); + default: + break; + } + break; + case 0x1: // + break; + case 0x2: // + switch(msg_type) + { + case (MSG_DISC & 0x1F): + return isdn_decode_disc(dst, src, VARIANT_ITU, len); + case (MSG_REL & 0x1F): + return isdn_decode_rel(dst, src, VARIANT_ITU, len); + case (MSG_REL_COMP & 0x1F): + return isdn_decode_rel_comp(dst, src, VARIANT_ITU, len); + case (MSG_RESTART & 0x1F): + return isdn_decode_restart(dst, src, VARIANT_ITU, len); + case (MSG_REST_ACK & 0x1F): + return isdn_decode_rest_ack(dst, src, VARIANT_ITU, len); + default: + break; + } + break; + case 0x3: // + switch(msg_type) + { + case (MSG_INFORMATION & 0x1F): + return isdn_decode_info(dst, src, VARIANT_ITU, len); + case (MSG_NOTI & 0x1F): + return isdn_decode_noti(dst, src, VARIANT_ITU, len); + case (MSG_STATUS & 0x1F): + return isdn_decode_status(dst, src, VARIANT_ITU, len); + case (MSG_STAT_ENQ & 0x1F): + return isdn_decode_stat_enq(dst, src, VARIANT_ITU, len); + default: + break; + } + break; + + default: + break; + } + + return ISDN_CM_FAILED; +} + +int ansi_msg_encode(u8 *dst, IsdnMsgStr *src) //msg from isdn to iua +{ + switch(src->msg_m.msg_type) + { + // + case MSG_ALERT: + return isdn_encode_alert(dst, src, VARIANT_ANSI); + case MSG_CALL_PROC: + return isdn_encode_call_proc(dst, src, VARIANT_ANSI); + case MSG_CONN: + return isdn_encode_conn(dst, src, VARIANT_ANSI); + case MSG_CONNACK: + return isdn_encode_conn_ack(dst, src, VARIANT_ANSI); + case MSG_PROG: + return isdn_encode_prog(dst, src, VARIANT_ANSI); + case MSG_SETUP: + return isdn_encode_setup(dst, src, VARIANT_ANSI); + // + case MSG_DISC: + return isdn_encode_disc(dst, src, VARIANT_ANSI); + case MSG_REL: + return isdn_encode_rel(dst, src, VARIANT_ANSI); + case MSG_REL_COMP: + return isdn_encode_rel_comp(dst, src, VARIANT_ANSI); + case MSG_RESTART: + return isdn_encode_restart(dst, src, VARIANT_ANSI); + case MSG_REST_ACK: + return isdn_encode_rest_ack(dst, src, VARIANT_ANSI); + // + case MSG_NOTI: + return isdn_encode_noti(dst, src, VARIANT_ANSI); + case MSG_STATUS: + return isdn_encode_status(dst, src, VARIANT_ANSI); + case MSG_STAT_ENQ: + return isdn_encode_stat_enq(dst, src, VARIANT_ANSI); + default: + break; + } + + return -1; +} + +int ansi_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, u8 len) //msg from iua to isdn +{ + u8 msg_clas, msg_type; + + msg_clas = (msgtype & 0x60) >> 5; + msg_type = (msgtype & 0x1F); + + switch(msg_clas) + { + case 0x0: // + switch(msg_type) + { + case (MSG_ALERT & 0x1F): + return isdn_decode_alert(dst, src, VARIANT_ANSI, len); + case (MSG_CALL_PROC & 0x1F): + return isdn_decode_call_proc(dst, src, VARIANT_ANSI, len); + case (MSG_CONN & 0x1F): + return isdn_decode_conn(dst, src, VARIANT_ANSI, len); + case (MSG_CONNACK & 0x1F): + return isdn_decode_conn_ack(dst, src, VARIANT_ANSI, len); + case (MSG_PROG & 0x1F): + return isdn_decode_prog(dst, src, VARIANT_ANSI, len); + case (MSG_SETUP & 0x1F): + return isdn_decode_setup(dst, src, VARIANT_ANSI, len); + default: + break; + } + break; + case 0x1: // + break; + case 0x2: // + switch(msg_type) + { + case (MSG_DISC & 0x1F): + return isdn_decode_disc(dst, src, VARIANT_ANSI, len); + case (MSG_REL & 0x1F): + return isdn_decode_rel(dst, src, VARIANT_ANSI, len); + case (MSG_REL_COMP & 0x1F): + return isdn_decode_rel_comp(dst, src, VARIANT_ANSI, len); + case (MSG_RESTART & 0x1F): + return isdn_decode_restart(dst, src, VARIANT_ANSI, len); + case (MSG_REST_ACK & 0x1F): + return isdn_decode_rest_ack(dst, src, VARIANT_ANSI, len); + default: + break; + } + break; + case 0x3: // + switch(msg_type) + { + case (MSG_NOTI & 0x1F): + return isdn_decode_noti(dst, src, VARIANT_ANSI, len); + case (MSG_STATUS & 0x1F): + return isdn_decode_status(dst, src, VARIANT_ANSI, len); + case (MSG_STAT_ENQ & 0x1F): + return isdn_decode_stat_enq(dst, src, VARIANT_ANSI, len); + default: + break; + } + break; + + default: + break; + } + + return ISDN_CM_FAILED; +} + +int qsig_msg_encode(u8 *dst, IsdnMsgStr *src) //msg from isdn to iua +{ + switch(src->msg_m.msg_type) + { + // + case MSG_ALERT: + return isdn_encode_alert(dst, src, VARIANT_QSIG); + case MSG_CALL_PROC: + return isdn_encode_call_proc(dst, src, VARIANT_QSIG); + case MSG_CONN: + return isdn_encode_conn(dst, src, VARIANT_QSIG); + case MSG_CONNACK: + return isdn_encode_conn_ack(dst, src, VARIANT_QSIG); + case MSG_PROG: + return isdn_encode_prog(dst, src, VARIANT_QSIG); + case MSG_SETUP: + return isdn_encode_setup(dst, src, VARIANT_QSIG); + case MSG_SETUP_ACK: + return isdn_encode_setup_ack(dst, src, VARIANT_QSIG); + // + case MSG_DISC: + return isdn_encode_disc(dst, src, VARIANT_QSIG); + case MSG_REL: + return isdn_encode_rel(dst, src, VARIANT_QSIG); + case MSG_REL_COMP: + return isdn_encode_rel_comp(dst, src, VARIANT_QSIG); + case MSG_RESTART: + return isdn_encode_restart(dst, src, VARIANT_QSIG); + case MSG_REST_ACK: + return isdn_encode_rest_ack(dst, src, VARIANT_QSIG); + // + case MSG_INFORMATION: + return isdn_encode_info(dst, src, VARIANT_QSIG); + case MSG_STATUS: + return isdn_encode_status(dst, src, VARIANT_QSIG); + case MSG_STAT_ENQ: + return isdn_encode_stat_enq(dst, src, VARIANT_QSIG); + default: + break; + } + + return -1; +} + +int qsig_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, u8 len) //msg from iua to isdn +{ + u8 msg_clas, msg_type; + + msg_clas = (msgtype & 0x60) >> 5; + msg_type = (msgtype & 0x1F); + + switch(msg_clas) + { + case 0x0: // + switch(msg_type) + { + case (MSG_ALERT & 0x1F): + return isdn_decode_alert(dst, src, VARIANT_QSIG, len); + case (MSG_CALL_PROC & 0x1F): + return isdn_decode_call_proc(dst, src, VARIANT_QSIG, len); + case (MSG_CONN & 0x1F): + return isdn_decode_conn(dst, src, VARIANT_QSIG, len); + case (MSG_CONNACK & 0x1F): + return isdn_decode_conn_ack(dst, src, VARIANT_QSIG, len); + case (MSG_PROG & 0x1F): + return isdn_decode_prog(dst, src, VARIANT_QSIG, len); + case (MSG_SETUP & 0x1F): + return isdn_decode_setup(dst, src, VARIANT_QSIG, len); + default: + break; + } + break; + case 0x1: // + break; + case 0x2: // + switch(msg_type) + { + case (MSG_DISC & 0x1F): + return isdn_decode_disc(dst, src, VARIANT_QSIG, len); + case (MSG_REL & 0x1F): + return isdn_decode_rel(dst, src, VARIANT_QSIG, len); + case (MSG_REL_COMP & 0x1F): + return isdn_decode_rel_comp(dst, src, VARIANT_QSIG, len); + case (MSG_RESTART & 0x1F): + return isdn_decode_restart(dst, src, VARIANT_QSIG, len); + case (MSG_REST_ACK & 0x1F): + return isdn_decode_rest_ack(dst, src, VARIANT_QSIG, len); + default: + break; + } + break; + case 0x3: // + switch(msg_type) + { + case (MSG_INFORMATION & 0x1F): + return isdn_decode_info(dst, src, VARIANT_QSIG, len); + case (MSG_STATUS & 0x1F): + return isdn_decode_status(dst, src, VARIANT_QSIG, len); + case (MSG_STAT_ENQ & 0x1F): + return isdn_decode_stat_enq(dst, src, VARIANT_QSIG, len); + default: + break; + } + break; + + default: + break; + } + + return ISDN_CM_FAILED; +} + + + +/************************************************************* +Function: maintenance_msg_encode +Description: encode ansi isdn maintenance message +Output: dst:preserving destination, src:source msg structure +Return: isdn msg length:success + ISDN_CM_FAILED:failed +*************************************************************/ +int maintenance_msg_encode(u8 *dst, IsdnMsgStr *src) //msg from isdn to iua +{ + switch(src->msg_m.msg_type) + { + case MSG_SERVICE: + return isdn_encode_service(dst, src); + case MSG_SERVICE_ACK: + return isdn_encode_servAck(dst, src); + default: + break; + } + + return -1; +} + +/************************************************************* +Function: maintenance_msg_decode +Description: decode ansi isdn maintenance message +Input: msgtype:msg type, len:msg length +Output: dst:preserving destination structure, src:source msg code stream +Return: ISDN_CM_OK:success + ISDN_CM_FAILED or 2 or 3:failed +*************************************************************/ +int maintenance_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, u8 len) //msg from iua to isdn +{ + switch(msgtype) + { + case MSG_SERVICE: + return isdn_decode_service(dst, src, len); + case MSG_SERVICE_ACK: + return isdn_decode_servAck(dst, src, len); + default: + break; + } + + return ISDN_CM_FAILED; +} + + +void isdn_send_heartbeat(int link_id) +{ + message_list msg_trans; + + memset(&msg_trans, 0, sizeof(message_list)); + msg_trans.msgSrcPort = ISDN_IP_PORT; + msg_trans.msgDstIP = isdn_rs.attrib.isdn_remote_ip; + msg_trans.msgDstPort = ISDN_IP_PORT; + msg_trans.msgLength = 3; + msg_trans.msgContent[0] = 1; //type + msg_trans.msgContent[1] = link_id; + msg_trans.msgContent[2] = isdn_rs.link_pond[link_id].dc_status; + + if(iptrPlatPutMessage(msg_trans) == 0) + isdn_log_err(0, "send heartbeat err!link id =%d, remote ip =%d, link status =%d \r\n", + link_id, isdn_rs.attrib.isdn_remote_ip, isdn_rs.link_pond[link_id].dc_status); +} +void isdn_redirect_send(IuaMsgStr *iua_src, int type) +{ + message_list msg_trans; + + memset(&msg_trans, 0, sizeof(message_list)); + msg_trans.msgSrcPort = ISDN_IP_PORT; + msg_trans.msgDstIP = isdn_rs.attrib.isdn_remote_ip; + msg_trans.msgDstPort = ISDN_IP_PORT; + msg_trans.msgLength = iua_src->msg_length + 5; + msg_trans.msgContent[0] = type; + memcpy(msg_trans.msgContent+1, &iua_src->msg_class, msg_trans.msgLength-1); + monitor_isdn_msg(0, "RD=>", iua_src, COL_BLUE); + if(iua_src->msgcontent.isdn_msg.msg_m.proto_Discr == PROTOCOL_DISCR) + isdn_msg_csta(iua_src->msgcontent.isdn_msg.msg_m.msg_type, 2); + if(iptrPlatPutMessage(msg_trans) == 0) + isdn_log_err(0, "redirect send err! msg type =0x%02x\r\n",iua_src->msgcontent.isdn_msg.msg_m.msg_type); +} + + +int isdn_msg_encode(u8 *dst, IsdnMsgStr *src, int variant) //msg from isdn to iua +{ + switch(variant) + { + case VARIANT_ITU: + return itu_msg_encode(dst, src); + case VARIANT_ANSI: + return ansi_msg_encode(dst, src); + case VARIANT_QSIG: + return qsig_msg_encode(dst, src); + default: + break; + } + + return -1; +} + +/************************************************************* +Function: isdn_msg_decode +Description: decode isdn message +Input: msgtype:msg type, len:msg length, variant:proto variant +Output: dst:preserving destination structure, src:source msg code stream +Return: ISDN_CM_OK:success + ISDN_CM_FAILED or 2 or 3:failed +*************************************************************/ +int isdn_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, int variant, u8 len) //msg from iua to isdn +{ + switch(variant) + { + case VARIANT_ITU: + return itu_msg_decode(dst, src, msgtype, len); + case VARIANT_ANSI: + return ansi_msg_decode(dst, src, msgtype, len); + case VARIANT_QSIG: + return qsig_msg_decode(dst, src, msgtype, len); + default: + break; + } + + return -1; +} + +/************************************************************* +Function: isdn_msdc_proc +Description: isdn Message Sending Control, msg from isdn to iua +Input: pid:port id +Output: iua_src:iua msg structure +Return: NULL +*************************************************************/ +void isdn_msdc_proc(u32 pid, IuaMsgStr *iua_src) +{ + int circuit_id, cg_id, ds_0, ds_1, d_chnl, i; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + circuit_id = pid /ISDN_CIRCUIT_CIC; + circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return; + + d_chnl = pid % ISDN_CIRCUIT_CIC; + cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + return; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return; + + ds_0 = cg_ptr->attrib.nfas.prim_link; + ds_1 = cg_ptr->attrib.nfas.backup_link; + + iua_src->msg_class = IUA_QPTM_MSG; + if((cg_ptr->attrib.nfas.flag == NFAS_ENABLE) && + (circuit_ptr->attrib.d_chnl != d_chnl)) + { + if(isdn_rs.link_pond[ds_0].dc_status == DS_IS) + { + iua_src->e1_no = ds_0; + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + if(circuit_ptr->cg_id != cg_id) + continue; + + if((circuit_ptr->attrib.link_id == ds_0) && + (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (isdn_rs.attrib.systemID != circuit_ptr->attrib.plat_id)) + { + monitor_isdn_msg(pid, "SD<=", iua_src, COL_WHITE); + isdn_redirect_send(iua_src, 2); //send to another plat + return; + } + } + } + else if(isdn_rs.link_pond[ds_1].dc_status == DS_IS) + { + iua_src->e1_no = ds_1; + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + if(circuit_ptr->cg_id != cg_id) + continue; + + if((circuit_ptr->attrib.link_id == ds_1) && + (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (isdn_rs.attrib.systemID != circuit_ptr->attrib.plat_id)) + { + monitor_isdn_msg(pid, "SD<=", iua_src, COL_WHITE); + isdn_redirect_send(iua_src, 2); //send to another plat + return; + } + } + } + else + { + isdn_log_err(pid, "no link is ds_is state!ds_0=%d, ds_0_status=%d, ds_1=%d, ds_1_status=%d\n", + ds_0, isdn_rs.link_pond[ds_0].dc_status, ds_1, isdn_rs.link_pond[ds_1].dc_status); + return; + } + } + else + iua_src->e1_no = circuit_ptr->attrib.link_id; + + monitor_isdn_msg(pid, "SD<=", iua_src, COL_WHITE); + iua_src->msg_length = htons(iua_src->msg_length); + if(iua_src->msgcontent.isdn_msg.msg_m.proto_Discr == PROTOCOL_DISCR) + isdn_msg_csta(iua_src->msgcontent.isdn_msg.msg_m.msg_type, 1); + if(put_xua_msg((xua_up_msg_t*)&iua_src->msg_class) == -1) + isdn_log_err(pid, "send msg to iua err!msg class=%d,msg type=0x%02x\r\n", + iua_src->msg_class, iua_src->msgcontent.isdn_msg.msg_m.msg_type); + else + isdn_rs.port_pond[pid].pre_send_msg = iua_src->msgcontent.isdn_msg.msg_m.msg_type; +} + +/************************************************************* +Function: isdn_send_msg +Description: isdn send msg to iua, include encode msg +Input: pid:port id, msg_type:msg type +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_send_msg(u32 pid, u8 msg_type) +{ + u16 call_ref; + u8 callout_fg; + int ret, variant; + IuaMsgStr *src = &iua_sd_msg; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + u8 *flw_ptr = src->msgcontent.isdn_msg.ie_content; //message flow pointer + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + memset(src, 0, sizeof(IuaMsgStr)); + call_ref = pPort->call_ref; + callout_fg = pPort->callout_fg; + circuit_ptr = pal_circuit_ptr(pid /ISDN_CIRCUIT_CIC); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + + variant = cg_ptr->attrib.variant; + + isdn_sd_msg.msg_m.proto_Discr = PROTOCOL_DISCR; + isdn_sd_msg.msg_m.cr_len = 2; + isdn_sd_msg.msg_m.call_ref[0] = ((call_ref & 0x7F00) >> 8) | (callout_fg << 7); //High + isdn_sd_msg.msg_m.call_ref[1] = (call_ref & 0xFF); //Low + isdn_sd_msg.msg_m.msg_type = msg_type; + + ret = isdn_msg_encode(flw_ptr, &isdn_sd_msg, variant); + if(ret == -1) + { + isdn_log_err(pid, "unknown msg encode, msg=0x%02x\r\n", msg_type); + return ISDN_CM_FAILED; + } + + memcpy(&src->msgcontent.isdn_msg.msg_m, &isdn_sd_msg.msg_m, sizeof(MsgMan)); + src->msg_length = ret + 0x0005; + isdn_msdc_proc(pid, src); + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_send_maintenance_msg +Description: isdn send ansi isdn maintenance msg to iua, include encode msg +Input: pid:port id, msg_type:msg type +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_send_maintenance_msg(u32 pid, u8 msg_type) +{ + u16 call_ref; + u8 callout_fg; + int ret; + IuaMsgStr *src = &iua_sd_msg; + ISDN_Port_struct *pPort = &isdn_rs.port_pond[pid]; + u8 *flw_ptr = src->msgcontent.isdn_msg.ie_content; //message flow pointer + + memset(src, 0, sizeof(IuaMsgStr)); + call_ref = pPort->call_ref; + callout_fg = pPort->callout_fg; + + isdn_sd_msg.msg_m.proto_Discr = M_PROTOCOL_DISCR; + isdn_sd_msg.msg_m.cr_len = 2; + isdn_sd_msg.msg_m.call_ref[0] = ((call_ref & 0x7F00) >> 8) | (callout_fg << 7); //High + isdn_sd_msg.msg_m.call_ref[1] = (call_ref & 0xFF); //Low + isdn_sd_msg.msg_m.msg_type = msg_type; + + ret = maintenance_msg_encode(flw_ptr, &isdn_sd_msg); + if(ret == -1) + { + isdn_log_err(pid, "unknown msg encode, msg=0x%02x\r\n", msg_type); + return ISDN_CM_FAILED; + } + + memcpy(&src->msgcontent.isdn_msg.msg_m, &isdn_sd_msg.msg_m, sizeof(MsgMan)); + src->msg_length = ret + 0x0005; + isdn_msdc_proc(pid, src); + + return ISDN_CM_OK; +} + + +/************************************************************* +Function: n0_ext_proc +Description: reinforce to receive abnormity msg at null state +Input: pid:port id, msg_type:msg type +Return: NULL +*************************************************************/ +static inline void n0_ext_proc(u32 pid, u8 msg_type) +{ + if(msg_type == MSG_REL_COMP) + { + isdn_log_err(pid, "receive rel_comp at null state , invalid call reference!\r\n"); + return; + } + else if(msg_type == MSG_STAT_ENQ) + { + isdn_set_status(&isdn_sd_msg.msg_list.status, 0, CAUSE_STAT_ENQ); + isdn_send_msg(pid, MSG_STATUS); + isdn_log_err(pid, "receive stat_enq at null state, response status msg!\r\n"); + return; + } + else if(msg_type == MSG_STATUS) + { + if(isdn_rv_msg.msg_list.status.call_stat.stat_val == 0) + { + isdn_log_err(pid, "receive status at null state, and indicate state value is 0!\r\n"); + return; + } + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_MSG_NOTCOMP); //cause 101 + } + else //unknown or unexpected msg + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_INVALID_CR); //cause 81, invalid call reference + isdn_send_msg(pid, MSG_REL_COMP); + isdn_log_err(pid, "invalid call reference!\r\n"); + return; +} + +/************************************************************* +Function: setup_abn_ie +Description: decode setup with abnormity information elements +Input: pid:port id, ret:decode result +Return: NULL +*************************************************************/ +static inline void setup_abn_ie(u32 pid, int ret) +{ + if(ret == 3) + { + isdn_log_err(pid, "setup mandatory information element is absent!\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_M_IE_MISS); + } + else if(ret == 2) + { + isdn_log_err(pid, "setup mandatory information element is err!\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_IE_INVALID); + } + isdn_send_msg(pid, MSG_REL_COMP); + rel_cr(pid); +} + +/************************************************************* +Function: isdn_mdsc_proc +Description: isdn Message Distribution Control, msg from iua to isdn +Input: NULL +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +static int isdn_mdsc_proc() +{ + u32 pid, cic, head_cic; + u16 cref = 0; + int msg_type, variant, cg_id, circuit_newId, link_id; + u8 global_flag; + int ret, len, i; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + u8 *flw_ptr; + + flw_ptr = iua_rv_msg.msgcontent.isdn_msg.ie_content; + len = iua_rv_msg.msg_length - 5; + + isdn_msg_csta(iua_rv_msg.msgcontent.isdn_msg.msg_m.msg_type, 0); + if(iua_rv_msg.msgcontent.isdn_msg.msg_m.cr_len != 2) + { + isdn_log_err(0, "call reference len is not 2!\r\n"); //dummy call reference + monitor_isdn_msg(0, "RV=>", &iua_rv_msg,COL_YELLOW); + return ISDN_CM_FAILED; + } + + link_id = iua_rv_msg.e1_no; + if((circuit_ptr = pal_isdn_find_circuit_of_link(link_id)) == NULL) + { + isdn_log_err(0, "mdsc: link_id %d is unknown link!\r\n", link_id); + monitor_isdn_msg(0, "RV=>", &iua_rv_msg,COL_YELLOW); + return ISDN_CM_FAILED; + } +// circuit_id = circuit_ptr->id; + cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) || + (cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + return ISDN_CM_FAILED; + + variant = cg_ptr->attrib.variant; + + cref = iua_rv_msg.msgcontent.isdn_msg.msg_m.call_ref[0]; + cref = (cref << 8) | (iua_rv_msg.msgcontent.isdn_msg.msg_m.call_ref[1]); + msg_type = iua_rv_msg.msgcontent.isdn_msg.msg_m.msg_type; + memset(&isdn_sd_msg, 0, sizeof(IsdnMsgStr)); + memset(&isdn_rv_msg, 0, sizeof(IsdnMsgStr)); + + if((cref & 0x7FFF) == 0) //Global call reference message + { + global_flag = 1; + pid = circuit_ptr->id * ISDN_CIRCUIT_CIC; + isdn_rs.port_pond[pid].call_ref = cref; + isdn_rs.port_pond[pid].callout_fg = ((cref >> 15) ^ 0x01); + if((msg_type != MSG_RESTART) && + (msg_type != MSG_REST_ACK) && + (msg_type != MSG_STATUS)) + { + isdn_log_err(0, "invalid call reference, cr = 0!\r\n"); + isdn_set_status(&isdn_sd_msg.msg_list.status, 0, CAUSE_INVALID_CR); //cause 81, state? + isdn_send_msg(pid, MSG_STATUS); + return ISDN_CM_FAILED; + } + else if(msg_type == MSG_STATUS) + { + isdn_log_err(0, "receive status in cr=0, reserved in current state!\r\n"); + return ISDN_CM_FAILED; + } + } + else + { + global_flag = 0; + if(cg_ptr->attrib.nfas.flag == NFAS_ENABLE) + { + if(isdn_rs.link_pond[link_id].dc_status != DS_IS) + { + isdn_log_err(0, "the link %d is not DS_IS state!\r\n", link_id); + return ISDN_CM_FAILED; + } + + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + if(circuit_ptr->cg_id != cg_id) + continue; + + if((circuit_ptr->enable) && + (pid = find_port_by_callref(cref, i))) + { +// circuit_id = i; + break; + } + } + if((pid == 0) && (msg_type != MSG_SETUP) && + (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID)) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + } + else + pid = find_port_by_callref(cref, circuit_ptr->id); + } + + memcpy(&isdn_rv_msg.msg_m, &iua_rv_msg.msgcontent.isdn_msg.msg_m, sizeof(MsgMan)); + ret = isdn_msg_decode(&isdn_rv_msg, flw_ptr, msg_type, variant, len); + if((pid == 0) && (global_flag == 0)) + { + if(msg_type != MSG_SETUP) //NULL STATE of other proc + { + isdn_log_err(0, "receice msg=0x%02x, when port id is 0!\r\n", msg_type); + pid = circuit_ptr->id * ISDN_CIRCUIT_CIC; + isdn_rs.port_pond[pid].call_ref = cref; + isdn_rs.port_pond[pid].callout_fg = ((cref >> 15) ^ 0x01); + n0_ext_proc(pid, msg_type); + return ISDN_CM_FAILED; + } + else if((cref & 0x8000) != 0) + { + isdn_log_err(0, "the call reference is not from the original call!\r\n"); + return ISDN_CM_FAILED; + } + //else goto setup to find port id + } + + if(ret == 0) + { + isdn_log_err(pid, "decode isdn msg is unknown! msg=0x%02x\r\n",msg_type); + isdn_set_status(&isdn_sd_msg.msg_list.status, isdn_rs.port_pond[pid].fsm_state.cpc_state, CAUSE_MSG_NOTCOMP_NOTIMPL); //cause 97 or 98 u01-04 + isdn_send_msg(pid, MSG_STATUS); + return ISDN_CM_FAILED; + } + else if(ret == -1) + { + isdn_log_err(pid, "unknown protocol discriminator! proto_discr=%d\r\n", iua_rv_msg.msgcontent.isdn_msg.msg_m.proto_Discr); + return ISDN_CM_FAILED; + } + + switch(msg_type) + { + case MSG_SETUP: + if(pid != 0) + { + isdn_log_err(0, "setup has reveived! pid=%d\r\n", pid); + return ISDN_CM_FAILED; + } + if(ret != 1) + { + pid = circuit_ptr->id * ISDN_CIRCUIT_CIC; + isdn_rs.port_pond[pid].call_ref = cref; + isdn_rs.port_pond[pid].callout_fg = ((cref >> 15) ^ 0x01); + setup_abn_ie(pid, ret); + return ISDN_CM_FAILED; + } + if(cg_ptr->attrib.nfas.flag) + { + if((isdn_rv_msg.msg_list.setup.chnl_id.pres) && + (isdn_rv_msg.msg_list.setup.chnl_id.b3.int_id_pre)) + { + if((circuit_newId = find_circuit_by_interfaceId(cg_id, isdn_rv_msg.msg_list.setup.chnl_id.b3.int_id)) == -1) + { + if(circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + else + { + isdn_log_err(0, "not find current circuit! circuit id=%d\r\n", circuit_ptr->id); + return ISDN_CM_FAILED; + } + } + else + { + circuit_ptr = pal_circuit_ptr(circuit_newId); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "receive setup err! circuit_id=%d, can't find circuit_ptr!\r\n", circuit_newId); + return ISDN_CM_FAILED; + } + if(circuit_ptr->cg_id != cg_id) + return ISDN_CM_FAILED; + } + } + else + { + isdn_log_err(0, "err!\n"); + return ISDN_CM_FAILED; + } + } + if((isdn_rv_msg.msg_list.setup.chnl_id.pres) && + (isdn_rv_msg.msg_list.setup.chnl_id.b3.int_type)) + { + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + cic = head_cic + isdn_rv_msg.msg_list.setup.chnl_id.b3.chnl_num; + if((cic < circuit_ptr->attrib.head_cic) || (cic - circuit_ptr->attrib.head_cic) >= (circuit_ptr->attrib.cic_range)) + { + pid = circuit_ptr->id * ISDN_CIRCUIT_CIC; + isdn_rs.port_pond[pid].call_ref = cref; + isdn_rs.port_pond[pid].callout_fg = ((cref >> 15) ^ 0x01); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_IE_INVALID); + isdn_send_msg(pid, MSG_REL_COMP); + isdn_log_err(0, "decode cic err!cic=0x%04x\r\n",cic); + return ISDN_CM_FAILED; + } + else //find pid by cic + { + pid = find_port_by_cic(cic, circuit_ptr->id); + if(isdn_rs.port_pond[pid].cic_state.maintenance_state != IN_SERVICE) + { + isdn_log_err(pid, "this cic is not in service in receive setup!\n"); + return ISDN_CM_FAILED; + } + if(isdn_rs.port_pond[pid].enable == 1) //priority + { + if(!cg_ptr->attrib.priority) + { + isdn_event_handle(pid, ISDN_REATTEMPT_IND); + rel_cr(pid); + isdn_cpc_clear(&isdn_rs.port_pond[pid]); + } + else + return ISDN_CM_FAILED; + } + } + } + if(pid == 0) //assign new pid + { + if(cg_ptr->attrib.nfas.flag) + { + if(!isdn_rv_msg.msg_list.setup.chnl_id.b3.int_id_pre) + { + cic = msc_give_cic_value(cg_ptr->attrib.tg_id, -1); + if((circuit_ptr = pal_locate_circuit(cg_id, cic)) == NULL) + { + isdn_log_err(0, "the assign cic is not found the adscription of circuit! cic=%, cg_id=%d\n",cic, cg_id); + return ISDN_CM_FAILED; + } + } + else + cic = msc_give_cic_value(cg_ptr->attrib.tg_id, circuit_ptr->attrib.head_cic); + } + else + cic = msc_give_cic_value(cg_ptr->attrib.tg_id, circuit_ptr->attrib.head_cic); + pid = find_port_by_cic(cic, circuit_ptr->id); + } + isdn_rs.port_pond[pid].call_ref = cref; + //msg_cref[pid] = cref; + if(circuit_ptr->attrib.user_network_if) + { + isdn_rs.port_pond[pid].timer_flag |= CALLIN_FLAG; + isdn_rs.port_pond[pid].cic_state.call_state = CALLIN_FLAG; + } + else + { + isdn_rs.port_pond[pid].timer_flag |= CALLOUT_FLAG; + isdn_rs.port_pond[pid].cic_state.call_state = CALLOUT_FLAG; + } + isdn_rs.port_pond[pid].callout_fg = 1; + isdn_rs.port_pond[pid].enable = 1; + break; + case MSG_DISC: + if(ret == 3) + { + isdn_log_err(pid, "disc mandatory information element is absent!\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.disc.cause, CAUSE_M_IE_MISS); + } + else if(ret == 2) + { + isdn_log_err(pid, "disc mandatory information element is err!\r\n"); + isdn_set_cause(&isdn_rv_msg.msg_list.disc.cause, CAUSE_IE_INVALID); + } + memcpy(&isdn_sd_msg.msg_list.rel.cause, &isdn_rv_msg.msg_list.disc.cause, sizeof(CauseStr)); + break; + case MSG_REL: + if(ret == 3) //u03-18 u00-13 u07-12 + { + isdn_log_err(pid, "rel mandatory information element is absent!\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_M_IE_MISS); + memcpy(&isdn_rv_msg, &isdn_sd_msg, sizeof(IsdnMsgStr)); + } + else if(ret == 2) //u03-19 u00-14 u07-13 + { + isdn_log_err(pid, "rel mandatory information element is err!\r\n"); + isdn_set_cause(&isdn_sd_msg.msg_list.relComp.cause, CAUSE_IE_INVALID); + memcpy(&isdn_rv_msg, &isdn_sd_msg, sizeof(IsdnMsgStr)); + } + else + memcpy(&isdn_sd_msg.msg_list.relComp.cause, &isdn_rv_msg.msg_list.rel.cause, sizeof(CauseStr)); + break; + case MSG_RESTART: + case MSG_REST_ACK: + if(msg_type == MSG_RESTART) + { + if(cg_ptr->attrib.nfas.flag) + { + if((isdn_rv_msg.msg_list.restart.chnl_id.pres) && + (isdn_rv_msg.msg_list.restart.chnl_id.b3.int_id_pre)) + { + if((circuit_newId = find_circuit_by_interfaceId(cg_id, isdn_rv_msg.msg_list.restart.chnl_id.b3.int_id)) == -1) + { + if(circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + else + { + isdn_log_err(0, "not find current circuit! circuit id=%d\r\n", circuit_ptr->id); + return ISDN_CM_FAILED; + } + } + else + { + circuit_ptr = pal_circuit_ptr(circuit_newId); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "receive restart err! circuit_id=%d, can't find circuit_ptr!\r\n", circuit_newId); + return ISDN_CM_FAILED; + } + if(circuit_ptr->cg_id != cg_id) + return ISDN_CM_FAILED; + } + } + else + { + isdn_log_err(0, "receive restart err!\n"); + return ISDN_CM_FAILED; + } + } + } + else + { + if(cg_ptr->attrib.nfas.flag) + { + if((isdn_rv_msg.msg_list.restAck.chnl_id.pres) && + (isdn_rv_msg.msg_list.restAck.chnl_id.b3.int_id_pre)) + { + if((circuit_newId = find_circuit_by_interfaceId(cg_id, isdn_rv_msg.msg_list.restAck.chnl_id.b3.int_id)) == -1) + { + if(circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + else + { + isdn_log_err(0, "not find current circuit! circuit id=%d\r\n", circuit_ptr->id); + return ISDN_CM_FAILED; + } + } + else + { + circuit_ptr = pal_circuit_ptr(circuit_newId); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "receive restart ack err! circuit_id=%d, can't find circuit_ptr!\r\n", circuit_newId); + return ISDN_CM_FAILED; + } + if(circuit_ptr->cg_id != cg_id) + return ISDN_CM_FAILED; + } + } + else + { + isdn_log_err(0, "receive restart ack err!\n"); + return ISDN_CM_FAILED; + } + } + } + pid = circuit_ptr->id * ISDN_CIRCUIT_CIC; + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + isdn_rs.port_pond[pid].callout_fg = ((cref >> 15) ^ 0x01); + isdn_rs.link_pond[circuit_ptr->attrib.link_id].restart_clas = isdn_rv_msg.msg_list.restart.restart_ind.clas; + if(isdn_rs.link_pond[circuit_ptr->attrib.link_id].restart_clas == 0) + isdn_rs.port_pond[pid].cic_val = head_cic + isdn_rv_msg.msg_list.restart.chnl_id.b3.chnl_num; + default: //other + if(ret == 3) + { + isdn_log_err(pid, "msg=0x%02x mandatory information element is absent!\r\n", msg_type); + isdn_set_status(&isdn_sd_msg.msg_list.status, isdn_rs.port_pond[pid].fsm_state.cpc_state, CAUSE_M_IE_MISS); + isdn_send_msg(pid, MSG_STATUS); + return ISDN_CM_FAILED; + } + else if(ret == 2) + { + isdn_log_err(pid, "msg=0x%02x mandatory information element is err!\r\n",msg_type); + isdn_set_status(&isdn_sd_msg.msg_list.status, isdn_rs.port_pond[pid].fsm_state.cpc_state, CAUSE_IE_INVALID); + isdn_send_msg(pid, MSG_STATUS); + return ISDN_CM_FAILED; + } + break; + } + + monitor_isdn_msg(pid, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_rs.port_pond[pid].msg_cmd = msg_type; + if(global_flag) + { + isdn_restart_ctrl(pid); + } + else if((isdn_rs.port_pond[pid].cic_state.call_state == CALLOUT_FLAG) || + (isdn_rs.port_pond[pid].cic_state.call_state == CALLIN_FLAG)) + { + isdn_cpc_proc(pid); + } + + if(isdn_rs.port_pond[pid].msg_cmd != 0) + { + isdn_log_err(pid, "ignore the message! msg_cmd=0x%x\r\n", isdn_rs.port_pond[pid].msg_cmd); + isdn_rs.port_pond[pid].msg_cmd = 0; + } + + return ISDN_CM_OK; +} + +static int isdn_m_mdsc_proc() +{ + u32 pid, cic, head_cic; + u16 cref = 0; + u8 msg_type, link_id; + int ret, len, cg_id, circuit_newId; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + u8 *flw_ptr; + flw_ptr = iua_rv_msg.msgcontent.isdn_msg.ie_content; + len = iua_rv_msg.msg_length - 5; + link_id = iua_rv_msg.e1_no; + + if((circuit_ptr = pal_isdn_find_circuit_of_link(link_id)) == NULL) + { + isdn_log_err(0, "m_mdsc: link_id %d is unknown link!\r\n", link_id); + monitor_isdn_msg(0, "RV=>", &iua_rv_msg,COL_YELLOW); + return ISDN_CM_FAILED; + } + cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) || + (cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + return ISDN_CM_FAILED; + + if(cg_ptr->attrib.variant != VARIANT_ANSI) + { + isdn_log_err(0, "variant type=%d, is not ansi!\r\n", cg_ptr->attrib.variant); + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + return ISDN_CM_FAILED; + } + if(iua_rv_msg.msgcontent.isdn_msg.msg_m.cr_len != 2) + { + isdn_log_err(0, "call reference len is not 2!)\n"); //dummy call reference + return ISDN_CM_FAILED; + } + cref = iua_rv_msg.msgcontent.isdn_msg.msg_m.call_ref[0]; + cref = (cref << 8) | (iua_rv_msg.msgcontent.isdn_msg.msg_m.call_ref[1]); + msg_type = iua_rv_msg.msgcontent.isdn_msg.msg_m.msg_type; + + memset(&isdn_sd_msg, 0, sizeof(IsdnMsgStr)); + memset(&isdn_rv_msg, 0, sizeof(IsdnMsgStr)); + if(cref & 0x7FFF) //NOT Global call reference message + { + isdn_log_err(pid, "Invalid global call reference, CR=0x%02x\r\n",cref); + return ISDN_CM_FAILED; + } + memcpy(&isdn_rv_msg.msg_m, &iua_rv_msg.msgcontent.isdn_msg.msg_m, sizeof(MsgMan)); + ret = maintenance_msg_decode(&isdn_rv_msg, flw_ptr, msg_type, len); + if(ret != 1) + { + isdn_log_err(0, "decode msg err!\r\n"); + return ISDN_CM_FAILED; + } + + switch(msg_type) + { + case MSG_SERVICE: + if((cref & 0x8000) != 0) + { + isdn_log_err(0, "the call reference of service is err!\r\n"); + return ISDN_CM_FAILED; + } + + if(cg_ptr->attrib.nfas.flag) + { + if((isdn_rv_msg.msg_list.service.chnl_id.pres) && + (isdn_rv_msg.msg_list.service.chnl_id.b3.int_id_pre)) + { + if((circuit_newId = find_circuit_by_interfaceId(cg_id, isdn_rv_msg.msg_list.service.chnl_id.b3.int_id)) == -1) + { + if(circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + else + { + isdn_log_err(0, "not find current circuit! circuit id=%d\r\n", circuit_ptr->id); + return ISDN_CM_FAILED; + } + } + else + { + circuit_ptr = pal_circuit_ptr(circuit_newId); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "receive SERVICE err! circuit_id=%d, can't find circuit_ptr!\r\n", circuit_newId); + return ISDN_CM_FAILED; + } + if(circuit_ptr->cg_id != cg_id) + return ISDN_CM_FAILED; + } + } + else + { + isdn_log_err(0, "err!\n"); + return ISDN_CM_FAILED; + } + } + + if((isdn_rv_msg.msg_list.service.chnl_id.pres) && + (isdn_rv_msg.msg_list.service.chnl_id.b3.int_type)) + { + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + if(isdn_rv_msg.msg_list.service.chnl_id.b3.has_chnl) + cic = head_cic + isdn_rv_msg.msg_list.service.chnl_id.b3.chnl_num; + else + { + if(circuit_ptr->attrib.cic_range == 24) // T1 + cic = circuit_ptr->attrib.head_cic + 23; + else + cic = circuit_ptr->attrib.head_cic; + } + } + else + { + isdn_log_err(0, "SERVICE does not include chnl_id ie(pres=%d), or chnl_id does not include cic(int_type=%d)!\r\n", + isdn_rv_msg.msg_list.service.chnl_id.pres, isdn_rv_msg.msg_list.service.chnl_id.b3.int_type); + return ISDN_CM_FAILED; + } + break; + case MSG_SERVICE_ACK: + if(cg_ptr->attrib.nfas.flag) + { + if((isdn_rv_msg.msg_list.servAck.chnl_id.pres) && + (isdn_rv_msg.msg_list.servAck.chnl_id.b3.int_id_pre)) + { + if((circuit_newId = find_circuit_by_interfaceId(cg_id, isdn_rv_msg.msg_list.servAck.chnl_id.b3.int_id)) == -1) + { + if(circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID) + { + monitor_isdn_msg(0, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_redirect_send(&iua_rv_msg, 3); //send to another plat + return ISDN_CM_FAILED; + } + else + { + isdn_log_err(0, "not find current circuit! circuit id=%d\r\n", circuit_ptr->id); + return ISDN_CM_FAILED; + } + } + else + { + circuit_ptr = pal_circuit_ptr(circuit_newId); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "receive SERVICE ACK err! circuit_id=%d, can't find circuit_ptr!\r\n", circuit_newId); + return ISDN_CM_FAILED; + } + if(circuit_ptr->cg_id != cg_id) + return ISDN_CM_FAILED; + } + } + else + { + isdn_log_err(0, "err!\n"); + return ISDN_CM_FAILED; + } + } + + if((isdn_rv_msg.msg_list.servAck.chnl_id.pres) && + (isdn_rv_msg.msg_list.servAck.chnl_id.b3.int_type)) + { + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + if(isdn_rv_msg.msg_list.servAck.chnl_id.b3.has_chnl) + cic = head_cic + isdn_rv_msg.msg_list.servAck.chnl_id.b3.chnl_num; + else + { + if(circuit_ptr->attrib.cic_range == 24) // T1 + cic = circuit_ptr->attrib.head_cic + 23; + else + cic = circuit_ptr->attrib.head_cic; + } + } + else + { + isdn_log_err(0, "SERVICE ACK does not include chnl_id ie(pres=%d), or chnl_id does not include cic(int_type=%d)!\r\n", + isdn_rv_msg.msg_list.servAck.chnl_id.pres, isdn_rv_msg.msg_list.servAck.chnl_id.b3.int_type); + return ISDN_CM_FAILED; + } + break; + default: + return ISDN_CM_FAILED; + } + + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + if((cic < circuit_ptr->attrib.head_cic) || + (cic - circuit_ptr->attrib.head_cic) >= (circuit_ptr->attrib.cic_range)) + { + isdn_log_err(0, "decode cic err!cic=0x04x\r\n", cic); + return ISDN_CM_FAILED; + } + else + { + pid = find_port_by_cic(cic, circuit_ptr->id); + if((circuit_ptr->attrib.d_chnl+head_cic) == cic) + isdn_rs.port_pond[pid].timer_flag |= DC_M_FLAG; + else + isdn_rs.port_pond[pid].timer_flag |= BC_M_FLAG; + } + + monitor_isdn_msg(pid, "RV=>", &iua_rv_msg, COL_YELLOW); + isdn_rs.port_pond[pid].msg_cmd = msg_type; + if(isdn_rs.port_pond[pid].timer_flag & DC_M_FLAG) + service_dc_proc(pid); + else if(isdn_rs.port_pond[pid].timer_flag & BC_M_FLAG) + service_bc_proc(pid); + + if(isdn_rs.port_pond[pid].msg_cmd != 0) + { + isdn_log_err(pid, "ignore the message! msg_cmd=%d\r\n", isdn_rs.port_pond[pid].msg_cmd); + isdn_rs.port_pond[pid].msg_cmd = 0; + } + + return ISDN_CM_OK; +} + + +/************************************************************* +Function: isdn_receive_msg +Description: isdn receive msg from iua +Input: NULL +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_receive_msg() +{ + u16 len; + int link_id; + xua_up_msg_t *src = 0; + + if((get_xua_msg(IUA_APP, &src)) <= 0) + { +// printf("isdn get iua err!\n"); + return ISDN_CM_FAILED; + } + memcpy(&iua_rv_msg.msg_class, src, sizeof(xua_up_msg_t)); + link_id = iua_rv_msg.e1_no; + if(iua_rv_msg.msg_class == IUA_MGMT_CMD) //heartbeat + { + if(iua_rv_msg.msgcontent.lkmsg.opercode == M2UA_LK_DOWN) + { + isdn_rs.link_pond[link_id].lk2_status = LK_OOS; //out of service + } + else if(iua_rv_msg.msgcontent.lkmsg.opercode == M2UA_LK_UP) + { + isdn_rs.link_pond[link_id].lk2_status = LK_IS; //in service + isdn_rs.link_pond[link_id].link_heartbeat_time = 0; + } + isdn_rs.link_pond[link_id].lk3_status = isdn_rs.link_pond[link_id].lk2_status; + return ISDN_CM_FAILED; + } + + len = ntohs(iua_rv_msg.msg_length); + iua_rv_msg.msg_length = len; + if((iua_rv_msg.msgcontent.isdn_msg.msg_m.proto_Discr == PROTOCOL_DISCR) && + (len > 4)) + { + isdn_mdsc_proc(); + return ISDN_CM_OK; + } + else if((iua_rv_msg.msgcontent.isdn_msg.msg_m.proto_Discr == M_PROTOCOL_DISCR) && + (len > 4)) + { + isdn_m_mdsc_proc(); + return ISDN_CM_OK; + } + + isdn_log_err(0, "there is not isdn msg!\r\n"); + return ISDN_CM_FAILED; +} + + +int isdn_redirect_receive() +{ + int type, link_id; + message_list msg_trans; + xua_up_msg_t iua_msg; + + if(iptrGetMessage(&msg_trans, ISDN_IP_PORT) == 0) + { +// isdn_log_err(0, "do not receive msg from another plat!\r\n"); + return ISDN_CM_FAILED; + } + if(msg_trans.msgSrcIP != isdn_rs.attrib.isdn_remote_ip) + { + isdn_log_err(0, "remote ip is not compatible!\r\n"); + return ISDN_CM_FAILED; + } + + type = msg_trans.msgContent[0]; + + switch(type) + { + case 1: //heartbeat + if(msg_trans.msgLength == 3) + { + link_id = msg_trans.msgContent[1]; + isdn_rs.link_pond[link_id].dc_status = msg_trans.msgContent[2]; + isdn_rs.link_pond[link_id].plat_heartbeat_time = isdn_timer_var.t1s; + return ISDN_CM_OK; + } + break; + case 2: //msg, don't decode msg, and send the msg to the other switch + if(msg_trans.msgLength > 5) + { + memcpy(&iua_msg, msg_trans.msgContent+1, msg_trans.msgLength-1); + put_xua_msg(&iua_msg); + return ISDN_CM_OK; + } + break; + case 3: //msg, need decode msg + if(msg_trans.msgLength > 5) + { + memcpy(&iua_rv_msg.msg_class, msg_trans.msgContent+1, msg_trans.msgLength-1); + iua_rv_msg.msg_length = ntohs(iua_rv_msg.msg_length); + if(iua_rv_msg.msgcontent.isdn_msg.msg_m.proto_Discr == PROTOCOL_DISCR) + { + isdn_mdsc_proc(); + return ISDN_CM_OK; + } + else if(iua_rv_msg.msgcontent.isdn_msg.msg_m.proto_Discr == M_PROTOCOL_DISCR) + { + isdn_m_mdsc_proc(); + return ISDN_CM_OK; + } + } + break; + default: + break; + } + + isdn_log_err(0, "redirect receive err!\n"); + return ISDN_CM_FAILED; +} + diff --git a/omc/plat/isdn/src/isdn_rm.c b/omc/plat/isdn/src/isdn_rm.c new file mode 100644 index 0000000..8b189d8 --- /dev/null +++ b/omc/plat/isdn/src/isdn_rm.c @@ -0,0 +1,515 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_rm.c +Description: ISDN Resource Management +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ +#include "./include/isdn_const.h" +#include "../../m2ua/src/include/m2ua_const.h" +#include "./include/isdn_rm.h" +#include "./include/isdn_debug.h" +#include "./include/isdn_ext.h" +#include "./include/isdn_inc.h" + +extern int isdn_receive_msg(); +extern int isdn_redirect_receive(); +extern void isdn_send_heartbeat(int link_id); +extern void isdn_cpc_timer(u32 pid); +extern void maintenance_timer(u32 pid); +extern void isdn_restart_timer(u32 pid); +extern void service_dc_proc(u32 pid); +extern void isdn_restart_ctrl(u32 pid); +extern int trans_callref_sd_rest_req(u32 pid, u8 g_pri_cmd); + +/************************************************************* +Function: timer_init +Description: initialize the timers of isdn +Input: interval_ms:time cycle +Return: NULL +*************************************************************/ +static void timer_init(u32 interval_ms) +{ + isdn_timer_var.t301 = ISDN_T301 * 1000 / interval_ms; + isdn_timer_var.t302 = ISDN_T302 * 1000 / interval_ms; + isdn_timer_var.t303 = ISDN_T303 * 1000 / interval_ms; + isdn_timer_var.t304 = ISDN_T304 * 1000 / interval_ms; + isdn_timer_var.t305 = ISDN_T305 * 1000 / interval_ms; + isdn_timer_var.t306 = ISDN_T306 * 1000 / interval_ms; + isdn_timer_var.t307 = ISDN_T307 * 1000 / interval_ms; + isdn_timer_var.t308 = ISDN_T308 * 1000 / interval_ms; + isdn_timer_var.t309 = ISDN_T309 * 1000 / interval_ms; + isdn_timer_var.t310 = ISDN_T310 * 1000 / interval_ms; + isdn_timer_var.t312 = ISDN_T312 * 1000 / interval_ms; + isdn_timer_var.t313 = ISDN_T313 * 1000 / interval_ms; + isdn_timer_var.t316 = ISDN_T316 * 1000 / interval_ms; + isdn_timer_var.t317 = ISDN_T317 * 1000 / interval_ms; + isdn_timer_var.t321 = ISDN_T321 * 1000 / interval_ms; + isdn_timer_var.t322 = ISDN_T322 * 1000 / interval_ms; + isdn_timer_var.t1s = ISDN_T1 * 1000 / interval_ms + 20; + isdn_timer_var.t3M1 = ISDN_T3M1 * 1000 / interval_ms; +} + +/************************************************************* +Function: isdn_init +Description: initialize the parameters of isdn +Input: systemID:plat id, interval_ms:time cycle +Return: ISDN_CM_OK:success +*************************************************************/ +int isdn_init(u8 systemID, u32 interval_ms) +{ + u32 stack_size; + if(interval_ms == 0) + interval_ms = 10; + printf("Start ISDN module init...\n"); + memset(&isdn_rs, 0, sizeof(ISDN_Resource_Pond)); + memset(&isdn_timer_var, 1, sizeof(IsdnTimerStr)); + memset(&isdn_rv_msg, 0, sizeof(IsdnMsgStr)); + memset(&isdn_sd_msg, 0, sizeof(IsdnMsgStr)); + memset(&iua_rv_msg, 0, sizeof(IuaMsgStr)); + memset(&iua_sd_msg, 0, sizeof(IuaMsgStr)); + timer_init(interval_ms); + isdn_rs.attrib.systemID = systemID; + isdn_rs.attrib.isdn_remote_ip = 0; + isdn_rs.attrib.isdn_run_mode = 0; + stack_size = sizeof(ISDN_Resource_Pond) + sizeof(IsdnTimerStr); + isdn_debug_init(); + printf("ISDN module init completed, stack size: %ld bytes\n", stack_size); + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_sd_link +Description: isdn send link command to iua +Input: iua_id:link number, opercode:link command parameter +Return: ISDN_CM_OK:success +*************************************************************/ +int isdn_sd_link(u8 link_id, u8 opercode) +{ + IuaMsgStr isdn_lk; + isdn_lk.msg_class = IUA_MGMT_CMD; + isdn_lk.e1_no = link_id; + isdn_lk.msg_length = htons(0x0003); + isdn_lk.msgcontent.lkmsg.opercode = opercode; + + put_xua_msg((xua_up_msg_t*)&isdn_lk.msg_class); + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_link_ctrl +Description: isdn link control +Input: NULL +Return: NULL +*************************************************************/ +void isdn_link_ctrl() +{ + int i, link_id; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //for timer //setup link + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + + if(circuit_ptr->enable == 0) + continue; + if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID)) + continue; + + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) || + (cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + continue; + + link_id = circuit_ptr->attrib.link_id; + if(cg_ptr->enable) + { + if(isdn_rs.link_pond[link_id].lk3_status == LK_OOS) + { + if(cg_ptr->attrib.nfas.flag) //nfas + { + if((cg_ptr->attrib.nfas.prim_link != link_id) && + (cg_ptr->attrib.nfas.backup_link != link_id)) + continue; + } + + isdn_sd_link(link_id, xUA_ENABLE_xUA_LINK); //enable + isdn_sd_link(link_id, M2UA_MTP3_CMD_ACTIVE_LK); //active + } + } + else //modify by 080821 + { + if(isdn_rs.link_pond[link_id].lk3_status == LK_IS) + { + if(cg_ptr->attrib.nfas.flag) + { + if((cg_ptr->attrib.nfas.prim_link != link_id) && + (cg_ptr->attrib.nfas.backup_link != link_id)) + continue; + } + isdn_sd_link(link_id, M2UA_MTP3_CMD_DEACTIVE_LK); + isdn_sd_link(link_id, xUA_STOP_xUA_LINK); + } + } + } + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //release link + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + +/* if(circuit_ptr->enable == 0) + { + continue; + }*/ + if(((isdn_rs.attrib.isdn_run_mode == ISDN_SINGLE_MODE) || + (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE && + circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID)) && + (circuit_ptr->enable == 1)) //modify by 080821 + continue; + + cg_ptr = pal_cg_ptr(circuit_ptr->cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) || + (cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + continue; + + link_id = circuit_ptr->attrib.link_id; + if(isdn_rs.link_pond[link_id].lk3_status == LK_IS) + { + if(cg_ptr->attrib.nfas.flag) + { + if((cg_ptr->attrib.nfas.prim_link != link_id) && + (cg_ptr->attrib.nfas.backup_link != link_id)) + continue; + } + isdn_sd_link(link_id, M2UA_MTP3_CMD_DEACTIVE_LK); + isdn_sd_link(link_id, xUA_STOP_xUA_LINK); + } + } +} + +void isdn_heartbeat_timer(int link_id) +{ + if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0) + { + isdn_rs.link_pond[link_id].plat_heartbeat_time--; + if(isdn_rs.link_pond[link_id].plat_heartbeat_time == 0) + { + isdn_rs.link_pond[link_id].dc_status = DS_OOS; + isdn_log_err(0, "link %d heartbeat timeout: another plat doesnot send link state!\r\n",link_id); + } + } +} + +/************************************************************* +Function: isdn_timer +Description: isdn task schedule, include isdn link control, isdn receive msg from iua and control the timer +Input: NULL +Return: NULL +*************************************************************/ +void isdn_timer() +{ + u16 i, j, chnl_j, cg_id; + u32 offset, pid; + int circuit_cic, link_id, ds_0, ds_1; + static int link_10s = 0; + const pal_circuit_struct *circuit_ptr = NULL; + const pal_cg_struct *cg_ptr = NULL; + + link_10s++; + if(link_10s % 600 == 0) // 6s + { + isdn_link_ctrl(); //setup link + link_10s = 0; + } + + for(i = 0; i < 64; i++) + { + if(isdn_receive_msg() == 0) + break; //no message in lower layer + if(isdn_redirect_receive() == 0) + break; //no message from another plat + } + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //for timer + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + + if(circuit_ptr->enable == 0) + continue; + if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID)) + continue; + + cg_id = circuit_ptr->cg_id; + cg_ptr = pal_cg_ptr(cg_id); + if(cg_ptr == NULL) + continue; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + continue; + if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) || + (cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE))) + continue; + + link_id = circuit_ptr->attrib.link_id; + isdn_rs.link_pond[link_id].link_heartbeat_time++; + if(isdn_rs.link_pond[link_id].link_heartbeat_time % LINK_MAX_TIME == 0) + { + isdn_rs.link_pond[link_id].lk3_status = isdn_rs.link_pond[link_id].lk2_status; + isdn_rs.link_pond[link_id].lk2_status = LK_OOS; + isdn_rs.link_pond[link_id].link_heartbeat_time = 0; + } + + circuit_cic = circuit_ptr->attrib.cic_range; + offset = ISDN_CIRCUIT_CIC * i; //ISDN_CIRCUIT_CIC + if(circuit_cic == 24) //T1 + { + if((trans_callref_sd_rest_req(offset+24, ISDN_RESTART_CNF)) == circuit_cic) + { + isdn_rs.port_pond[offset+24].g_pri_cmd = ISDN_RESTART_CNF; + isdn_restart_ctrl(offset+24); //restart control + } +// offset++; + } + else + { + if((trans_callref_sd_rest_req(offset, ISDN_RESTART_CNF)) == circuit_cic) + { + isdn_rs.port_pond[offset].g_pri_cmd = ISDN_RESTART_CNF; + isdn_restart_ctrl(offset); //restart control + } + } + for(j = 0; j < circuit_cic; j++) + { + chnl_j = j; + if(circuit_cic == 24) //T1 + chnl_j = j + 1; + pid = offset + chnl_j; + if(cg_ptr->attrib.nfas.flag) //NFAS + { + ds_0 = cg_ptr->attrib.nfas.prim_link; + ds_1 = cg_ptr->attrib.nfas.backup_link; + if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel + { + if(ds_0 == link_id) + { + if(isdn_rs.link_pond[link_id].lk3_status == LK_IS) + { + if((isdn_rs.link_pond[ds_0].dc_status == DS_MOOS) && + (isdn_rs.link_pond[ds_1].dc_status != DS_IS)) + isdn_rs.port_pond[pid].g_pri_cmd = ISDN_SERVICE_REQ; + } + else + isdn_rs.link_pond[link_id].dc_status = DS_OOS; + service_dc_proc(pid); + + if((link_10s % 100 == 0) && (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE)) //send heartbeat per 1 second + isdn_send_heartbeat(link_id); + if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0) + isdn_rs.link_pond[link_id].plat_heartbeat_time = 0; + } + else if(ds_1 == link_id) + { + if(isdn_rs.link_pond[link_id].lk3_status == LK_IS) + { + if((isdn_rs.link_pond[ds_1].dc_status == DS_MOOS) && + ((isdn_rs.link_pond[ds_0].dc_status == DS_OOS) || + (isdn_rs.link_pond[ds_0].dc_status == DS_STBY))) + isdn_rs.port_pond[pid].g_pri_cmd = ISDN_SERVICE_REQ; + } + else + isdn_rs.link_pond[link_id].dc_status = DS_OOS; + service_dc_proc(pid); + + if((link_10s % 100 == 0) && (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE)) //send heartbeat per 1 second + isdn_send_heartbeat(link_id); + if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0) + isdn_rs.link_pond[link_id].plat_heartbeat_time = 0; + } + } + } + else //associated signaling + { + if(isdn_rs.link_pond[link_id].lk3_status == LK_IS) + { + if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel + isdn_rs.link_pond[link_id].dc_status = DS_IS; + } + else + { + if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel + isdn_rs.link_pond[link_id].dc_status = DS_OOS; + } + } + + if(isdn_rs.port_pond[pid].enable) + isdn_cpc_timer(pid); + isdn_restart_timer(pid); + maintenance_timer(pid); + } + if(isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) + isdn_heartbeat_timer(i); + } + isdn_debug_timer(); + +} + +/************************************************************* +Function: isdn_assign_port +Description: isdn assign the port id +Input: e1no:link number +Return: port id:success + 0:failed +*************************************************************/ +u32 isdn_assign_port(u16 circuit_id) +{ + u8 i, chnl; + u32 e1nox32 = 0; + u32 portnum = 0; + + chnl = 32; + e1nox32 = circuit_id; + e1nox32 = (e1nox32 << 5); + + for(i = 0; i < 31; i++) + { + chnl = (chnl - i) & 0x1F; + if (((chnl & 0x1F) != 0) && (chnl != 16)) + { + portnum = e1nox32 + chnl; + if (isdn_rs.port_pond[portnum].enable == 0) + { + if(isdn_rs.port_pond[portnum].cic_state.maintenance_state != IN_SERVICE) + { + isdn_log_err(0, "this cic is not in service in assign port!\r\n"); + break; + } + isdn_rs.port_pond[portnum].enable = 1; + return portnum; + } + } + } + + return 0; +} + + +/************************************************************* +Function: find_port_by_callref +Description: find port id by the call referrence and link id +Input: cref:call referrence, circuit_id:circuit id +Return: port id:success + 0:failed +*************************************************************/ +u32 find_port_by_callref(u16 cref, u16 circuit_id) +{ + int i, circuit_cic, d_chnl=16; + u32 portnum = 0; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + + circuit_cic = circuit_ptr->attrib.cic_range; + if(circuit_cic == 24) //T1 + { + d_chnl = 24; + } + portnum = (circuit_id * ISDN_CIRCUIT_CIC) + 1; + + for (i = 1; i < circuit_cic; i++, portnum++) + { + if (i != d_chnl) + { + if(isdn_rs.port_pond[portnum].call_ref == cref) + return portnum; + } + } +// isdn_log_err(0, "find port by callref err!call_ref=%d, circuit_id=%d\r\n",cref, circuit_id); + + return 0; +} + +/************************************************************* +Function: find_port_by_cic +Description: find port id by the cic of one link +Input: cic:cic, circuit_id:circuit id +Return: port id:success +*************************************************************/ +u32 find_port_by_cic(u32 cic, u16 circuit_id) +{ + u32 head_cic; + const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id); + if(circuit_ptr == NULL) + return ISDN_CM_FAILED; + head_cic = circuit_ptr->attrib.head_cic; + if(circuit_ptr->attrib.cic_range == 24) + head_cic--; + + return ISDN_CIRCUIT_CIC * circuit_id + (cic - head_cic); +} + +int find_circuit_by_interfaceId(int cg_id, u8 interface_id) +{ + int i; + const pal_circuit_struct *circuit_ptr = NULL; + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) + { + circuit_ptr = pal_circuit_ptr(i); + if(circuit_ptr == NULL) + continue; + + if(circuit_ptr->enable == 0) + continue; + if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) && + (circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID)) + continue; + if(circuit_ptr->cg_id != cg_id) + continue; + + if((circuit_ptr->attrib.cic_range != 0) && (circuit_ptr->attrib.head_cic / circuit_ptr->attrib.cic_range) == interface_id) + return i; + } + isdn_log_err(0, "find circuit by interface id err!cg_id=%d, interface_id=%d\r\n",cg_id, interface_id); + + return -1; +} + +//d-channel status +int check_dc_status(u8 link_id) +{ + if(isdn_rs.link_pond[link_id].dc_status == DS_IS) + return ISDN_CM_OK; + else + return ISDN_CM_FAILED; +} + +int isdn_set_run_mode (u8 run_mode, u32 alter_ip) +{ + isdn_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__); + isdn_rs.attrib.isdn_run_mode = run_mode % 2; + isdn_rs.attrib.isdn_remote_ip = alter_ip; + return ISDN_CM_OK; +} + diff --git a/omc/plat/isdn/src/isdn_uif.c b/omc/plat/isdn/src/isdn_uif.c new file mode 100644 index 0000000..30fe730 --- /dev/null +++ b/omc/plat/isdn/src/isdn_uif.c @@ -0,0 +1,428 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_uif.c +Description: ISDN USER INTERFACE +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ + +#include "./include/isdn_const.h" +#include "./include/isdn_rm.h" +#include "./include/isdn_debug.h" +#include "./include/isdn_ext.h" +#include "./include/isdn_inc.h" + + +extern void isdn_cpc_proc(u32 pid); +extern void isdn_restart_ctrl(u32 pid); +extern void service_bc_proc(u32 pid); + + +/************************************************************* +Function: isdn_setup_req +Description: msc invokes the function to request setup +Output: pst:post structure pointer, ptr:isdn setup structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_setup_req(Pst *pst, IsdnSetup *ptr) +{ + const pal_circuit_struct *circuit_ptr = NULL; + circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic); + if(circuit_ptr == NULL) + { + isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_ptr->id); + isdn_rs.port_pond[pst->sp_proc_id].su_proc_id = pst->su_proc_id; + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_SETUP_REQ; + isdn_rs.port_pond[pst->sp_proc_id].trace_flag = pst->trace_flag; + isdn_rs.port_pond[pst->sp_proc_id].enable = 1; + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + + if(isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state != IDLE_FLAG) + { + isdn_log_err(pst->sp_proc_id, "call state is not idle, but is %d\n", isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state); + return ISDN_CM_FAILED; + } + memcpy(&(isdn_sd_msg.msg_list.setup), ptr, sizeof(IsdnSetup)); + if(circuit_ptr->attrib.user_network_if) + isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state = CALLOUT_FLAG; + else + isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state = CALLIN_FLAG; + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_m_info_req +Description: msc invokes the function to request more information +Output: pst:post structure pointer, ptr:isdn setup ack structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_m_info_req(Pst *pst, IsdnSetupAck *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_MORE_INFO_REQ; + memcpy(&(isdn_sd_msg.msg_list.setupAck), ptr, sizeof(IsdnSetupAck)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_call_proc_req +Description: msc invokes the function to request call proceeding +Output: pst:post structure pointer, ptr:isdn call proceeding structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_call_proc_req(Pst *pst, IsdnCallProc *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_PROC_REQ; + memcpy(&(isdn_sd_msg.msg_list.callProc), ptr, sizeof(IsdnCallProc)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_alert_req +Description: msc invokes the function to request alerting +Output: pst:post structure pointer, ptr:isdn alerting structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_alert_req(Pst *pst, IsdnAlert *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_ALERT_REQ; + memcpy(&(isdn_sd_msg.msg_list.alert), ptr, sizeof(IsdnAlert)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_setup_resp +Description: msc invokes the function to request setup response +Output: pst:post structure pointer, ptr:isdn connect structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_setup_resp(Pst *pst, IsdnConn *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_SETUP_RSP; + memcpy(&(isdn_sd_msg.msg_list.conn), ptr, sizeof(IsdnConn)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_disc_req +Description: msc invokes the function to request disconnect +Output: pst:post structure pointer, ptr:isdn disconnect structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_disc_req(Pst *pst, IsdnDisc *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_DISCONNECT_REQ; + memcpy(&(isdn_sd_msg.msg_list.disc), ptr, sizeof(IsdnDisc)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_rel_req +Description: msc invokes the function to request release +Output: pst:post structure pointer, ptr:isdn release structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_rel_req(Pst *pst, IsdnRel *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_RELEASE_REQ; + memcpy(&(isdn_sd_msg.msg_list.rel), ptr, sizeof(IsdnRel)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +int isdn_rej_req(Pst *pst, IsdnRelComp *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_REJECT_REQ; + memcpy(&(isdn_sd_msg.msg_list.relComp), ptr, sizeof(IsdnRelComp)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} +/************************************************************* +Function: isdn_info_req +Description: msc invokes the function to request information +Output: pst:post structure pointer, ptr:isdn information structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_info_req(Pst *pst, IsdnInfo *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_INFO_REQ; + memcpy(&(isdn_sd_msg.msg_list.info), ptr, sizeof(IsdnInfo)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_prog_req +Description: msc invokes the function to request progress +Output: pst:post structure pointer, ptr:isdn progress structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_prog_req(Pst *pst, IsdnProg *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_PROG_REQ; + memcpy(&(isdn_sd_msg.msg_list.prog), ptr, sizeof(IsdnProg)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_noti_req +Description: msc invokes the function to request notify +Output: pst:post structure pointer, ptr:isdn notify structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_noti_req(Pst * pst, IsdnNoti * ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_NOTI_REQ; + memcpy(&(isdn_sd_msg.msg_list.noti), ptr, sizeof(IsdnNoti)); + isdn_cpc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd); + isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISDN_CM_OK; +} + +/************************************************************* +Function: isdn_m_restart_req +Description: msc invokes the function to request management restart +Output: pst:post structure pointer, ptr:isdn restart structure pointer +Return: ISDN_CM_OK:success + ISDN_CM_FAILED:failed +*************************************************************/ +int isdn_m_restart_req(Pst *pst, IsdnRestart *ptr) //restart indicated channel +{ + u32 pid, link_id; + int circuit_id; + const pal_cg_struct *cg_ptr = NULL; + const pal_circuit_struct *circuit_ptr = NULL; + isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__); + cg_ptr = pal_cg_ptr(pst->cg_id); + if(cg_ptr == NULL) + return ISDN_CM_FAILED; + if(cg_ptr->attrib.protocol != PROTO_ISDN) + return ISDN_CM_FAILED; + circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic); + if(circuit_ptr == NULL) + { + isdn_log_err(0, "isdn_m_restart_req err!circuit_ptr cann't be found by vcg_id=%d,cic=%ld \r\n", pst->cg_id, pst->cic); + return ISDN_CM_FAILED; + } + circuit_id = circuit_ptr->id; + pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_id); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + memcpy(&(isdn_sd_msg.msg_list.restart), ptr, sizeof(IsdnRestart)); + pid = (circuit_id) * ISDN_CIRCUIT_CIC; + link_id = circuit_ptr->attrib.link_id; + if(ptr->restart_ind.clas == 0) + isdn_rs.port_pond[pid].cic_val = pst->cic; + else + isdn_rs.port_pond[pid].cic_val = 0; + isdn_rs.link_pond[link_id].restart_clas = ptr->restart_ind.clas; + isdn_rs.port_pond[pid].g_pri_cmd = ISDN_M_RESTART_REQ; + isdn_restart_ctrl(pid); + if(isdn_rs.port_pond[pid].g_pri_cmd != 0) + { + isdn_trace_func(pid, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd); + isdn_rs.port_pond[pid].g_pri_cmd = 0; + } + + return ISDN_CM_OK; +} + + +//ansi +int isdn_service_bc_req(Pst *pst, IsdnService *ptr) +{ + const pal_circuit_struct *circuit_ptr = NULL; + circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic); + if(circuit_ptr == NULL) + { + isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__); + return ISDN_CM_FAILED; + } + pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_ptr->id); + isdn_rs.port_pond[pst->sp_proc_id].su_proc_id = pst->su_proc_id; + isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = ISDN_SERVICE_REQ; + isdn_rs.port_pond[pst->sp_proc_id].trace_flag = pst->trace_flag; +// isdn_rs.port_pond[pst->sp_proc_id].enable = 1; + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + memcpy(&(isdn_sd_msg.msg_list.service), ptr, sizeof(IsdnService)); + service_bc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd); + isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = 0; + } + + return ISDN_CM_OK; +} + +int isdn_service_bc_rsp(Pst *pst, IsdnServAck *ptr) +{ + isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISDN_MAX_PORT) + { + isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id); + return ISDN_CM_FAILED; + } + isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = ISDN_SERVICE_RSP; + memcpy(&(isdn_sd_msg.msg_list.servAck), ptr, sizeof(IsdnServAck)); + service_bc_proc(pst->sp_proc_id); + if(isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd != 0) + { + isdn_trace_func(pst->sp_proc_id, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd); + isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = 0; + } + + return ISDN_CM_OK; +} + diff --git a/omc/plat/isdn/ut/.copyarea.db b/omc/plat/isdn/ut/.copyarea.db new file mode 100644 index 0000000..36c1e4f --- /dev/null +++ b/omc/plat/isdn/ut/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn\ut +2 +8 +4:code|2|0|0|0|728472bb6cf311dd91c7001c23e19543|0 +b:isdn_main.o|1|11d70a484f5|7e50|59745f11|f50487c66cf311dd91a5001c23e19543|0 +b:isdn_test.c|1|11d70a48523|216b|dcbb98cf|f50487de6cf311dd91a5001c23e19543|0 +e:test_main_0526|1|11d70a48978|1107e0|d62c06ae|f634883e6cf311dd91a5001c23e19543|0 +b:isdn_main.c|1|11d70a484c6|1c9e|7d7c103e|f47487ae6cf311dd91a5001c23e19543|0 +b:isdn_test.o|1|11d70a48562|6170|778d86b|f50487f66cf311dd91a5001c23e19543|0 +8:Makefile|1|11d70a48478|662|3881d1d6|f5a4880e6cf311dd91a5001c23e19543|0 +9:test_main|1|11d70a48765|111abe|15c9f66b|f5a488266cf311dd91a5001c23e19543|0 diff --git a/omc/plat/isdn/ut/Makefile b/omc/plat/isdn/ut/Makefile new file mode 100644 index 0000000..3baefce --- /dev/null +++ b/omc/plat/isdn/ut/Makefile @@ -0,0 +1,45 @@ +#Create by Chen Gengxin +#2008-03-03 +#WXC2 R9.0 ISDN makefile + +CC = gcc +CFLAG = -g -Wall -c #-fprofile-arcs -ftest-coverage + +ISDN_LIB_OBJ = ../src/isdn_msg.o ../src/isdn_fsm.o ../src/isdn_uif.o ../src/isdn_rm.o ../src/isdn_ie.o ../src/isdn_debug.o +ISDN_TST_OBJ = isdn_main.o isdn_test.o + +ISDN_LIB = -L../../isdn/lib -lisdn +PLAT_LIB = -L../../8ecp/lib -l8ecp -L../../aif/lib -laif -L../../bicc/lib -lbicc -L../../debug/lib -ldebug -L../../haepub/lib -lhaepub -L../../iptrans/lib -liptrans -L../../isup/lib -lisup -L../../m2ua/lib -lm2ua -L../../mgc/lib -lmgc -L../../mgcp/lib -lmgcp -L../../mtp3/lib -lmtp3 -L../../public/lib -lpublic -L../../rtp/lib -lrtp -L../../sccp/lib -lsccp -L../../scf/lib -lscf -L../../snmp/lib -lsnmp -L../../smpp/lib -lsmpp -L../../tcap/lib -ltcap -L../../xapp/lib -lxapp +MSS_LIB = -L../../../mss/aas/lib -laas -L../../../mss/ae/lib -lae -L../../../mss/hlr/lib -lhlr -L../../../mss/mnp/lib -lmnp -L../../../mss/msc/lib -lmsc -L../../../mss/ssf/lib -lssf -L../../../mss/vlr/lib -lvlr +TEST_LIB = -L/usr/local/lib/CUnit -lcunit -lgcov + +isdn_main: $(ISDN_TST_OBJ) + $(CC) $(ISDN_LIB_OBJ) $(ISDN_TST_OBJ) -o test_main $(ISDN_LIB) $(PLAT_LIB) -lm + +isdn_main.o: isdn_main.c + $(CC) $(CFLAG) $< + +isdn_test.o: isdn_test.c + $(CC) $(CFLAG) $< + +isdn_msg.o: isdn_msg.c + $(CC) $(CFLAG) $< + +isdn_fsm.o: isdn_fsm.c + $(CC) $(CFLAG) $< + +isdn_uif.o: isdn_uif.c + $(CC) $(CFLAG) $< + +isdn_rm.o: isdn_rm.c + $(CC) $(CFLAG) $< + +isdn_ie.o: isdn_ie.c + $(CC) $(CFLAG) $< + +isdn_debug.o: isdn_debug.c + $(CC) $(CFLAG) $< + +clean: + rm -f main *.o *.a *.xml *.gcov *.gcda *.gcno core test_main + diff --git a/omc/plat/isdn/ut/code/.copyarea.db b/omc/plat/isdn/ut/code/.copyarea.db new file mode 100644 index 0000000..c8561ad --- /dev/null +++ b/omc/plat/isdn/ut/code/.copyarea.db @@ -0,0 +1,26 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isdn\ut\code +2 +16 +c:rest1-0.Text|1|11d70a48ddd|5d0|2faa2cca|f9c489a66cf311dd91a5001c23e19543|0 +b:u01-10.Text|1|11d70a48f34|965|cb19d056|fb048a366cf311dd91a5001c23e19543|0 +b:u01-01.Text|1|11d70a48e89|5d6|afa72bf1|fa6489ee6cf311dd91a5001c23e19543|0 +c:iua data.txt|1|11d70a48b2e|278|eff3c271|f76488b66cf311dd91a5001c23e19543|0 +12:iua set up-bak.txt|1|11d70a48b8b|547|73515bce|f80488fe6cf311dd91a5001c23e19543|0 +b:u01-05.Text|1|11d70a48ef6|50f|e74d0810|fb048a1e6cf311dd91a5001c23e19543|0 +10:nt-2link-01.Text|1|11d70a48c76|df0|e778c5d2|f80489166cf311dd91a5001c23e19543|0 +12:ds-service-02.Text|1|11d70a48ac0|4e2|fbfd00c8|f6d488866cf311dd91a5001c23e19543|0 +c:rest2-0.Text|1|11d70a48e1b|5d2|4c12cdc|f9c489be6cf311dd91a5001c23e19543|0 +13:nt-incoming-01.Text|1|11d70a48cc4|8d9|b0dfb62b|f894892e6cf311dd91a5001c23e19543|0 +b:u01-03.Text|1|11d70a48eb7|a14|369def5a|fa648a066cf311dd91a5001c23e19543|0 +b:u03-13.Text|1|11d70a48f63|a30|9da8f644|fb048a4e6cf311dd91a5001c23e19543|0 +c:headfile.txt|1|11d70a48aef|42|528d118c|f6d4889e6cf311dd91a5001c23e19543|0 +9:data.Text|1|11d70a48a14|5e6|a94d1962|f63488566cf311dd91a5001c23e19543|0 +13:nt-outgoing-02.Text|1|11d70a48d9e|8db|3d86b62d|f934898e6cf311dd91a5001c23e19543|0 +13:nt-outgoing-01.Text|1|11d70a48d6f|8fe|f6f7be02|f894895e6cf311dd91a5001c23e19543|0 +f:iua set up.Text|1|11d70a48baa|8db|3d86b62d|f76488ce6cf311dd91a5001c23e19543|0 +12:ds-service-01.Text|1|11d70a48a82|4e2|51e00c9|f6d4886e6cf311dd91a5001c23e19543|0 +e:iua set up.txt|1|11d70a48be9|4a0|e1432fd4|f80488e66cf311dd91a5001c23e19543|0 +13:nt-incoming-02.Text|1|11d70a48d02|8da|ad7b5de|f89489466cf311dd91a5001c23e19543|0 +c:test-01.Text|1|11d70a48e4a|a7f|c1b10332|f9c489d66cf311dd91a5001c23e19543|0 +14:nt-outgoing-01-.Text|1|11d70a48d31|8f6|df78badc|f93489766cf311dd91a5001c23e19543|0 diff --git a/omc/plat/isdn/ut/code/data.Text b/omc/plat/isdn/ut/code/data.Text new file mode 100644 index 0000000..b89bdd7 --- /dev/null +++ b/omc/plat/isdn/ut/code/data.Text @@ -0,0 +1,69 @@ +Test 1 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; + +10 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 81 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 81 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 03 A1 +83 81 1E 02 83 88 ?? ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 4D ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; diff --git a/omc/plat/isdn/ut/code/ds-service-01.Text b/omc/plat/isdn/ut/code/ds-service-01.Text new file mode 100644 index 0000000..bc9e4a1 --- /dev/null +++ b/omc/plat/isdn/ut/code/ds-service-01.Text @@ -0,0 +1,33 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 00 00 0F 01 01 C0 +18 04 E9 80 83 90 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 80 00 07 01 01 C0 +18 04 E9 80 83 90 00 00; diff --git a/omc/plat/isdn/ut/code/ds-service-02.Text b/omc/plat/isdn/ut/code/ds-service-02.Text new file mode 100644 index 0000000..099d145 --- /dev/null +++ b/omc/plat/isdn/ut/code/ds-service-02.Text @@ -0,0 +1,33 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +00 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 00 00 0F 01 01 C0 +18 04 E9 80 83 90 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 80 00 07 01 01 C0 +18 04 E9 80 83 90 00 00; diff --git a/omc/plat/isdn/ut/code/headfile.txt b/omc/plat/isdn/ut/code/headfile.txt new file mode 100644 index 0000000..b1dcbd0 --- /dev/null +++ b/omc/plat/isdn/ut/code/headfile.txt @@ -0,0 +1,3 @@ +#define RE_IP 172.18.99.1 +#define RE_PORT 0 +#define LO_PORT 2904 \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/iua data.txt b/omc/plat/isdn/ut/code/iua data.txt new file mode 100644 index 0000000..cd73820 --- /dev/null +++ b/omc/plat/isdn/ut/code/iua data.txt @@ -0,0 +1,19 @@ +#include "headfile.txt" + +test 1 sctp +SCTP.Set remote_ip=RE_IP; +SCTP.Set remote_port=RE_PORT; +SCTP.Set local_port=LO_PORT; +SCTP.Set STREAM_ID=1 +50 SCTP.Set server + +0 SCTP.Send +01 00 05 01 00 00 00 20 //common message header(version,spare,message class,message type,message length(所有的长度)) +00 01 00 08 00 00 00 00 //iua message header(tag,length,interface id) +00 05 00 08 00 00 00 00 //iua message header(tag,length,DLCI) +00 0E 00 08 //iua message(tag,length(整条iua message的长度)) +FF 01 F0 02; //iua message(protocol data) + +1000 SCTP.Recv +?? //common message header + diff --git a/omc/plat/isdn/ut/code/iua set up-bak.txt b/omc/plat/isdn/ut/code/iua set up-bak.txt new file mode 100644 index 0000000..5d2c9d4 --- /dev/null +++ b/omc/plat/isdn/ut/code/iua set up-bak.txt @@ -0,0 +1,47 @@ +#include "headfile.txt" + +test 1 sctp +SCTP.Set remote_ip=RE_IP; +SCTP.Set remote_port=RE_PORT; +SCTP.Set local_port=LO_PORT; +SCTP.Set STREAM_ID=1 +500 SCTP.Set server + +1000 SCTP.Recv +01 00 03 01 00 00 00 10 //common message header(version,spare,message class,message type,message length) +00 11 00 08 ?? ?? ?? ??; //iua message(tag,length,content) + +0 SCTP.Send +01 00 03 04 00 00 00 08; //common message header + +1 SCTP.Send +01 00 00 01 00 00 00 10 //common message header +00 0D 00 08 00 01 00 02; //iua message + +1000 SCTP.FLTR +01 00 03 01 00 00 00 10 //common message header +00 11 00 08 ?? ?? ?? ??; //iua message + +1000 SCTP.Recv +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 +01 00 04 03 00 00 00 10 +00 0B 00 08 00 00 00 01; + +0 SCTP.Send +01 00 00 01 00 00 00 10 +00 0D 00 08 00 01 00 03; + +1000 SCTP.Recv +01 00 05 05 00 00 00 18 //common message header(version,spare,message class,message type,message length) +00 01 00 08 00 00 00 00 //iua message header(tag,length,interface id) +00 05 00 08 00 00 00 00; //iua message header(tag,length,DLCI) + +0 SCTP.Send +01 00 05 06 00 00 00 18 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00; + diff --git a/omc/plat/isdn/ut/code/iua set up.Text b/omc/plat/isdn/ut/code/iua set up.Text new file mode 100644 index 0000000..e210d6f --- /dev/null +++ b/omc/plat/isdn/ut/code/iua set up.Text @@ -0,0 +1,82 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 81 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 81 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 03 A1 +83 81 1E 02 83 88 ?? ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +100 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 4D 08 02 83 +90 00 00 00; + +100 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/iua set up.txt b/omc/plat/isdn/ut/code/iua set up.txt new file mode 100644 index 0000000..80f52fd --- /dev/null +++ b/omc/plat/isdn/ut/code/iua set up.txt @@ -0,0 +1,41 @@ +#include "headfile.txt" + +test 1 sctp +SCTP.Set remote_ip=RE_IP; +SCTP.Set local_port=LO_PORT; +SCTP.Set STREAM_ID=2 + +10000 SCTP.RECEIVE +01 00 03 01 00 00 00 10 //common message header(version,spare,message class,message type,message length) +00 11 00 08 ?? ?? ?? ??; //iua message(tag,length,content) + +0 SCTP.Send +01 00 03 04 00 00 00 08; //common message header + +1 SCTP.Send +01 00 00 01 00 00 00 10 //common message header +00 0D 00 08 00 01 00 02; //iua message + +1000 SCTP.Recv +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 +01 00 04 03 00 00 00 10 +00 0B 00 08 00 00 00 01; + +0 SCTP.Send +01 00 00 01 00 00 00 10 +00 0D 00 08 00 01 00 03; + +1000 SCTP.Recv +01 00 05 05 00 00 00 18 //common message header(version,spare,message class,message type,message length) +00 01 00 08 00 00 00 00 //iua message header(tag,length,interface id) +00 05 00 08 00 00 00 00; //iua message header(tag,length,DLCI) + +0 SCTP.Send +01 00 05 06 00 00 00 18 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00; + diff --git a/omc/plat/isdn/ut/code/nt-2link-01.Text b/omc/plat/isdn/ut/code/nt-2link-01.Text new file mode 100644 index 0000000..e3eb26e --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-2link-01.Text @@ -0,0 +1,151 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV +01 00 03 01 00 00 00 10 +00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND +01 00 03 04 00 00 00 08; +10 SCTP.SEND +01 00 00 01 00 00 00 10 +00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV +01 00 04 01 00 00 00 20 +00 0B 00 08 00 00 00 01 +00 01 00 08 00 00 00 00 //interface id +00 01 00 08 00 00 00 01; //interface id +10 SCTP.SEND +01 00 04 03 00 00 00 10 +00 0B 00 08 00 00 00 01; + +10 SCTP.SEND +01 00 00 01 00 00 00 10 +00 0D 00 08 00 01 00 03; +1000 SCTP.RECV +01 00 05 05 00 00 00 18 +00 01 00 08 00 00 00 00 //interface id +00 05 00 08 00 00 00 00; +1000 SCTP.RECV +01 00 05 05 00 00 00 18 +00 01 00 08 00 00 00 01 //interface id +00 05 00 08 00 00 00 00; +10 SCTP.SEND +01 00 05 06 00 00 00 18 +00 01 00 08 00 00 00 00 //interface id +00 05 00 08 00 00 00 00; +10 SCTP.SEND +01 00 05 06 00 00 00 18 +00 01 00 08 00 00 00 01 //interface id +00 05 00 08 00 00 00 00; + +test 1 + +10000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 00 00 0F 01 01 C0 +18 04 E9 80 83 90 00 00; +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +03 02 80 00 07 01 01 C0 +18 04 E9 80 83 90 00 00; + +test 2 + +20 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 26 +08 02 00 01 05 a1 04 03 +80 90 a3 18 04 E1 82 83 01 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0F +08 02 80 01 02 18 04 E9 82 +83 81 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 04 E9 82 +83 81 1E 02 83 88 ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +test 3 + +10 SCTP.SEND +01 00 05 0a 00 00 00 20 +00 01 00 08 00 00 00 00 //interface id +00 05 00 08 00 00 00 00 +00 0F 00 08 00 00 00 00; + +1000 SCTP.RECV +01 00 05 05 00 00 00 18 +00 01 00 08 00 00 00 00 //interface id +00 05 00 08 00 00 00 00; +10 SCTP.SEND +01 00 05 06 00 00 00 18 +00 01 00 08 00 00 00 00 //interface id +00 05 00 08 00 00 00 00; + +test 4 + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 01 //interface id +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 01 //interface id +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 01 //interface id +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +??; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/nt-incoming-01.Text b/omc/plat/isdn/ut/code/nt-incoming-01.Text new file mode 100644 index 0000000..f13544d --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-incoming-01.Text @@ -0,0 +1,82 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 00 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/nt-incoming-02.Text b/omc/plat/isdn/ut/code/nt-incoming-02.Text new file mode 100644 index 0000000..8bdbd50 --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-incoming-02.Text @@ -0,0 +1,82 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +1000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 45 08 02 83 +90 00 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 4D 08 02 83 +90 00 00 00; + +1000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/nt-outgoing-01-.Text b/omc/plat/isdn/ut/code/nt-outgoing-01-.Text new file mode 100644 index 0000000..77b3411 --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-outgoing-01-.Text @@ -0,0 +1,83 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 28 +08 02 00 01 05 a1 04 03 +80 90 A3 18 06 a1 96 00 01 00 01 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31; + +10000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 11 +08 02 80 01 02 18 03 A9 +83 01 01 00 81 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 03 A1 +83 00 00 00 81 1E 02 83 +88 ?? ?? ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/nt-outgoing-01.Text b/omc/plat/isdn/ut/code/nt-outgoing-01.Text new file mode 100644 index 0000000..6b1a064 --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-outgoing-01.Text @@ -0,0 +1,85 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 01 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 81 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 03 A9 +83 81 1E 02 83 88 ?? ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +??; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/nt-outgoing-02.Text b/omc/plat/isdn/ut/code/nt-outgoing-02.Text new file mode 100644 index 0000000..e210d6f --- /dev/null +++ b/omc/plat/isdn/ut/code/nt-outgoing-02.Text @@ -0,0 +1,82 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 81 +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 81 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 01 18 03 A1 +83 81 1E 02 83 88 ?? ??; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 80 01 07 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +100 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 4D 08 02 83 +90 00 00 00; + +100 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/rest1-0.Text b/omc/plat/isdn/ut/code/rest1-0.Text new file mode 100644 index 0000000..1a3fbc2 --- /dev/null +++ b/omc/plat/isdn/ut/code/rest1-0.Text @@ -0,0 +1,44 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +1000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 11 +08 02 00 00 46 18 03 A1 +83 XX 79 01 80 ?? ?? ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 11 +08 02 80 00 4E 18 03 A1 +83 XX 79 01 80 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/rest2-0.Text b/omc/plat/isdn/ut/code/rest2-0.Text new file mode 100644 index 0000000..9e20dc3 --- /dev/null +++ b/omc/plat/isdn/ut/code/rest2-0.Text @@ -0,0 +1,44 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 11 +08 02 00 00 46 18 03 A1 +83 XX 79 01 80 00 00 00; + +1000 SCTP.RECV +01 00 05 01 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 11 +08 02 80 00 4E 18 03 A1 +83 XX 79 01 80 ?? ?? ??; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/test-01.Text b/omc/plat/isdn/ut/code/test-01.Text new file mode 100644 index 0000000..a80b73b --- /dev/null +++ b/omc/plat/isdn/ut/code/test-01.Text @@ -0,0 +1,103 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +Test 1 +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 00 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; + +Test 2 +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 YY 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 10 +08 02 80 YY 7D 08 02 83 +E5 14 01 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/u01-01.Text b/omc/plat/isdn/ut/code/u01-01.Text new file mode 100644 index 0000000..11cd9f0 --- /dev/null +++ b/omc/plat/isdn/ut/code/u01-01.Text @@ -0,0 +1,47 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 4D 08 02 83 +90 00 00 00; + +1000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 00 01 5A 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +??; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/u01-03.Text b/omc/plat/isdn/ut/code/u01-03.Text new file mode 100644 index 0000000..7b45e3d --- /dev/null +++ b/omc/plat/isdn/ut/code/u01-03.Text @@ -0,0 +1,96 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 0F 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 10 +08 02 00 01 7D 08 02 83 +E5 14 01 ??; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 00 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/u01-05.Text b/omc/plat/isdn/ut/code/u01-05.Text new file mode 100644 index 0000000..63a4ec7 --- /dev/null +++ b/omc/plat/isdn/ut/code/u01-05.Text @@ -0,0 +1,36 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 10 +08 02 80 01 7D 08 02 83 +E5 14 01 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/u01-10.Text b/omc/plat/isdn/ut/code/u01-10.Text new file mode 100644 index 0000000..496145b --- /dev/null +++ b/omc/plat/isdn/ut/code/u01-10.Text @@ -0,0 +1,89 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +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 +08 00 01 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; + +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 00 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/code/u03-13.Text b/omc/plat/isdn/ut/code/u03-13.Text new file mode 100644 index 0000000..94123e4 --- /dev/null +++ b/omc/plat/isdn/ut/code/u03-13.Text @@ -0,0 +1,97 @@ +Test 0 +3 SCTP.SET <> "remote_ip=172.18.99.1"; +3 SCTP.SET <> "remote_port=0"; +3 SCTP.SET <> "local_port=9900"; +3 SCTP.SET <> "STREAM_ID=0"; +3 SCTP.SET <> "server"; +1000 SCTP.SET <> "wait_connect"; + +200 SCTP.RECV 01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??; +10 SCTP.SEND 01 00 03 04 00 00 00 08; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02; +3 SCTP.SET <> "STREAM_ID=1"; +1000 SCTP.RECV 01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00; +10 SCTP.SEND 01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01; +10 SCTP.SEND 01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03; +1000 SCTP.RECV 01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; +10 SCTP.SEND 01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 40 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 25 +08 02 00 01 05 a1 04 03 +80 90 a3 18 03 a1 83 XX +6c 07 00 80 35 31 30 30 +31 70 06 81 35 32 30 30 +31 00 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0E +08 02 80 01 02 18 03 A9 +83 XX 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 00 00 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 10 +08 02 00 00 7D 08 02 83 +D1 14 01 ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 2C +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 12 +08 02 80 01 01 18 03 A1 +83 XX 1E 02 83 88 00 00; + +20 SCTP.SEND +01 00 05 02 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 80 01 07 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 24 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 09 +08 02 00 01 0F 00 00 00; +30 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 45 08 02 83 +90 00 00 00; + +10000 SCTP.RECV +01 00 05 01 00 00 00 ?? +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 ?? +08 02 00 01 4D 08 02 83 +90 ?? ?? ??; + +10 SCTP.SEND +01 00 05 02 00 00 00 28 +00 01 00 08 00 00 00 00 +00 05 00 08 00 00 00 00 +00 0E 00 0D +08 02 80 01 5A 08 02 83 +90 00 00 00; \ No newline at end of file diff --git a/omc/plat/isdn/ut/isdn_main.c b/omc/plat/isdn/ut/isdn_main.c new file mode 100644 index 0000000..8cfa272 --- /dev/null +++ b/omc/plat/isdn/ut/isdn_main.c @@ -0,0 +1,323 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_main.c +Description: For isdn module test +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../src/include/isdn_rm.h" +#include "../src/include/isdn_ext.h" +#include "../src/include/isdn_inc.h" +#include "../../snmp/src/include/snmp.h" +#include "../../mtp3/src/include/mtp3.h" +#include "../../public/src/include/license_id.h" +#include "../../tcap/src/include/tcap_public.h" + +#define SYS_IT_INTERVAL_SEC 0 +#define SYS_IT_INTERVAL_USEC (20*1000) + +static char serialNumber[18]=""; +xua_up_msg_t iua_msg_src; +static int systemID=0,systemInited=0; +static int sys_timer10ms=0; +u8 ptemp[] = {0}; + +extern int test_len; + +extern void test_isdn_msg_encode(u8 type); +extern void test_isdn_msg_decode(u8 type); +extern void m2ua_init(BYTE system_id); +extern void msc_isdn_init(int *sap_id); +extern void cc_timer(); + +static void isdn_param_init(void) +{ +// ISDN_Sap_Attrib_ sap; + Cg_Attrib_struct cg; + Circuit_Attrib_struct trunk; + int sap_id,cg_id,trunk_id_0, trunk_id_1, trunk_id_2; + +// memset(&sap,0,sizeof(ISDN_Sap_Attrib_)); + memset(&cg,0,sizeof(Cg_Attrib_struct)); + memset(&trunk,0,sizeof(Circuit_Attrib_struct)); + +/* if((sap_id = isdn_bind_sap(&sap)) == -1) + { + printf("add sap error!\r\n"); + return; + }*/ + msc_isdn_init(&sap_id); + + + cg.network_id = 0; + cg.priority = 0; // 0:Reattempt ind / 1:Discard + cg.tg_id = 0; + + if((cg_id = isdn_add_cg(sap_id, &cg)) == -1) + { + printf("Failed to create isup trunk group socket\r\n"); + return; + } + + trunk.cic_range = 32; + trunk.head_cic = 0; + trunk.plat_id = CTRL_PLAT_0; + if((trunk_id_0 = isdn_add_circuit(cg_id, &trunk)) == -1) + { + printf("Failed to create isup trunk socket\r\n"); + return; + } + if((trunk_id_1 = isdn_add_circuit(cg_id, &trunk)) == -1) + { + printf("Failed to create isup trunk socket\r\n"); + return; + } + if((trunk_id_2 = isdn_add_circuit(cg_id, &trunk)) == -1) + { + printf("Failed to create isup trunk socket\r\n"); + return; + } + isdn_rs.cg_pond[cg_id].attrib.nfas_flag = 1; + isdn_rs.cg_pond[cg_id].attrib.variant_type = VARIANT_ANSI; + isdn_rs.cg_pond[cg_id].attrib.ds_ch[0] = trunk_id_0; + isdn_rs.cg_pond[cg_id].attrib.ds_ch[1] = trunk_id_1; + isdn_rs.circuit_pond[trunk_id_0].attrib.d_chnl = 16; + isdn_rs.circuit_pond[trunk_id_0].attrib.head_cic = 0; + isdn_rs.circuit_pond[trunk_id_0].attrib.cic_range =32; + isdn_rs.circuit_pond[trunk_id_0].attrib.plat_id = 0; + isdn_rs.circuit_pond[trunk_id_0].attrib.iua_id = 0; + isdn_rs.circuit_pond[trunk_id_0].user_network_if = USER_SIDE; //nt or lt + isdn_rs.circuit_pond[trunk_id_1].attrib.d_chnl = 16; + isdn_rs.circuit_pond[trunk_id_1].attrib.head_cic = 32; + isdn_rs.circuit_pond[trunk_id_1].attrib.cic_range =32; + isdn_rs.circuit_pond[trunk_id_1].attrib.plat_id = 0; + isdn_rs.circuit_pond[trunk_id_1].attrib.iua_id = 1; + isdn_rs.circuit_pond[trunk_id_1].user_network_if = USER_SIDE; //nt or lt + isdn_rs.circuit_pond[trunk_id_2].attrib.d_chnl = 16; + isdn_rs.circuit_pond[trunk_id_2].attrib.head_cic = 64; + isdn_rs.circuit_pond[trunk_id_2].attrib.cic_range =32; + isdn_rs.circuit_pond[trunk_id_2].attrib.plat_id = 0; + isdn_rs.circuit_pond[trunk_id_2].attrib.iua_id = 2; + isdn_rs.circuit_pond[trunk_id_2].user_network_if = USER_SIDE; //nt or lt + + printf("isdn init ok.\r\n"); +} + + +int wxc2_get_license(int functionID) +{ + return 1; +} + +static void sysTimer_IRQ() +{ + sys_timer10ms = 1; //test +} + + +static void SigactionSystem() +{ + struct sigaction action;//,actsegv; + + action.sa_handler = sysTimer_IRQ; + sigemptyset(&action.sa_mask); + action.sa_flags = SA_RESTART; + if(sigaction(SIGALRM, &action, NULL)<0) + { + printf("sigactin sigalarm failed\n"); + } +} + +static void sysDaemonInit() +{ + int i; + pid_t pid; + + + if ( (pid = fork()) < 0) /* parent terminates */ + printf("%s: %s: fork (%d)", + __FILE__, __FUNCTION__, __LINE__); + else if (pid != 0) + exit(0); /* parent goes bye-bye */ + + setsid(); // become session leader + + for (i = 0; i<3; i++) + close(i); +} + +static void moduleInit() +{ + printf("\n\n【R9 Platform Init】\n\n"); + + debug_init(); + heartbeat_init(0x0400); + iptrMainInit(); + snmp_init(4957); + m2ua_init(0); + mtp_shm_init(0x0400); + mtp3_init_serial(serialNumber); + + + + isdn_init(systemID,10); + + printf("\n\n【R9 Platform Init completed】\n\n"); + +} + +static void SetFSMTimer() +{ + struct itimerval *ptv, tv; + + ptv = (struct itimerval *) &tv; + ptv->it_interval.tv_sec = SYS_IT_INTERVAL_SEC; + ptv->it_interval.tv_usec = SYS_IT_INTERVAL_USEC; + ptv->it_value. tv_sec = SYS_IT_INTERVAL_SEC; + ptv->it_value.tv_usec = SYS_IT_INTERVAL_USEC; + setitimer(ITIMER_REAL, ptv, NULL); +} + +static void moduleProc() +{ + static int wait_sccp_normal_count = 0; + + iptrans_timer(); + snmp_timer(); + + + if(systemInited) + { + wait_sccp_normal_count=6001; + + heartbeat_timer(); + m2ua_timer(); + mtp3_proc(); + + isdn_timer(); + cc_timer(); +/* test_isdn_msg_decode(MSG_SETUP); + test_isdn_msg_encode(MSG_SETUP); + test_isdn_msg_decode(MSG_SETUP_ACK); + test_isdn_msg_encode(MSG_SETUP_ACK); + test_isdn_msg_decode(MSG_CALL_PROC); + test_isdn_msg_encode(MSG_CALL_PROC); + test_isdn_msg_decode(MSG_ALERT); + test_isdn_msg_encode(MSG_ALERT); + test_isdn_msg_decode(MSG_CONN); + test_isdn_msg_encode(MSG_CONN); + test_isdn_msg_decode(MSG_CONNACK); + test_isdn_msg_encode(MSG_CONNACK); + test_isdn_msg_decode(MSG_DISC); + test_isdn_msg_encode(MSG_DISC); + test_isdn_msg_decode(MSG_REL); + test_isdn_msg_encode(MSG_REL); + test_isdn_msg_decode(MSG_REL_COMP); + test_isdn_msg_encode(MSG_REL_COMP);*/ + } + + debug_rt(); +} + +int CStrToHex(u8 dst[], u8 *src) +{ + int i, len, offset=0; + + len = strlen(src); + while((len--) != 0) + { + if(*src >= '0' && *src <= '9') + ptemp[offset++] = *src - 0x30; + else if(*src >= 'A' && *src <= 'F') + ptemp[offset++] = *src - 'A' + 10; //*src - 0x37; + else if(*src >= 'a' && *src <= 'f') + ptemp[offset++] = *src - 'a' + 10; //*src - 0x57; + else + { + src++; + continue; + } +// printf("src=%x,ptemp=%x\n",*src,*(ptemp+offset-1)); + src++; + } + + test_len = offset/2; + for(i = 0; i < test_len; i++) + { + dst[i] = ((ptemp[2*i]) << 4) | (ptemp[2*i+1]); +// printf("set[%d]=0x%2x\n",i,dst[i]); + } +// printf("sizeof=%d,strlen=%d\n",sizeof(dst),strlen(dst)); + + return 1; +} + +static void isdn_set_val() +{ + iua_msg_src.msg_class = IUA_QPTM_MSG; + iua_msg_src.msg.iua.link = 0x10; + iua_msg_src.msg.iua.len = test_len; +} + +int main(int argc, char **argv) +{ + int retval, err_flag=0, daemon_flag=0, no_sync=0; + + while ((retval = getopt(argc, argv, "dt")) != -1) + { + switch (retval) { + case 'd': + daemon_flag = 1; + break; + case 't': + no_sync = 1; + break; + case '?': + err_flag = 1; + break; + } + } + if (err_flag) { + printf("Usage: %s [-d] \n", argv[0]); + printf(" -d with daemon mode\n"); + exit(1); + } + + if(daemon_flag) + sysDaemonInit(); + + moduleInit(); + + SigactionSystem(); + SetFSMTimer(); + + isdn_param_init(); +// isdn_set_val(); + + sys_timer10ms = 1; + + while(1) + { + if(sys_timer10ms) + { + sys_timer10ms = 0; + moduleProc(); + systemInited = 1; + } + if (sys_timer10ms == 0) + usleep(1); + } + + return 1; +} + diff --git a/omc/plat/isdn/ut/isdn_test.c b/omc/plat/isdn/ut/isdn_test.c new file mode 100644 index 0000000..275a59c --- /dev/null +++ b/omc/plat/isdn/ut/isdn_test.c @@ -0,0 +1,325 @@ +/*********************************************************** +Copyright (C), LGC Wireless. +File Name: isdn_test.c +Description: For isdn module test +Version: v9.0.0 +Author: Gengxin Chen +Create Date: 2008-2-19 +History: + + +************************************************************/ +#include "../src/include/isdn_rm.h" +#include "../src/include/isdn_ext.h" +#include "../src/include/isdn_inc.h" + + +#define CODE_SETUP "a1 04 03 80 90 a3 18 03 a1 83 81 6c 07 00 80 35 31 30 30 31 70 06 81 35 32 30 30 31" +#define CODE_CALL_PROC "18 03 A9 83 81" +#define CODE_ALERT "1E 02 83 88" +#define CODE_DISCONN "08 02 83 90" + +int test_len; +static int cc_state[8192] = {0}; + +extern int CStrToHex(u8 dst[], u8 *src); +extern int q931_msg_encode(u8 *dst, IsdnMsgStr *src); +extern int isdn_msg_decode(IsdnMsgStr *dst, u8 *src, u8 msgtype, u8 len); +extern void isdn_set_cause(CauseStr *cause_ptr, u8 val); + +void test_isdn_msg_encode(u8 type) +{ + int ret; + int i; + memset(&iua_sd_msg, 0, sizeof(IuaMsgStr)); + IuaMsgStr *dst = &iua_sd_msg; + u8 *flw_ptr = dst->msgcontent.isdn_msg.ie_content; //message flow pointer + + memcpy(&isdn_sd_msg, &isdn_rv_msg, sizeof(IsdnMsgStr)); + isdn_sd_msg.msg_m.msg_type = type; + ret = q931_msg_encode(flw_ptr, &isdn_sd_msg); + printf("ret=%d\n",ret); + for(i=0; isp_proc_id] = 1; + return 1; +} +int isdn_alert_ind(Pst *pst, IsdnAlert *ptr) +{ + return 1; +} +int isdn_setup_cnf(Pst *pst, IsdnConn *ptr) +{ + return 1; +} +int isdn_disc_ind(Pst *pst, IsdnDisc *ptr) +{ + IsdnRel src; + memset(&src, 0, sizeof(IsdnRel)); + + isdn_rel_req(pst, &src); + return 1; +} +int isdn_rel_ind(Pst *pst, IsdnRel *ptr) +{ + return 1; +} +int isdn_rel_cnf(Pst *pst, IsdnRelComp *ptr) +{ + return 1; +} +int isdn_stat_ind(Pst *pst, IsdnStatus *ptr) +{ + return 1; +} +void msc_isdn_init(int *sap_id) +{ + ISDN_Sap_Attrib_ sap; + memset(&sap,0,sizeof(ISDN_Sap_Attrib_)); + sap.event_handle.h_isdn_setup_ind = (f_isdn_setup_ind *)isdn_setup_ind; + sap.event_handle.h_isdn_alert_ind = (f_isdn_alert_ind *)isdn_alert_ind; + sap.event_handle.h_isdn_setup_cnf = (f_isdn_setup_cnf *)isdn_setup_cnf; + sap.event_handle.h_isdn_disc_ind = (f_isdn_disc_ind *)isdn_disc_ind; + sap.event_handle.h_isdn_rel_ind = (f_isdn_rel_ind *)isdn_rel_ind; + sap.event_handle.h_isdn_rel_cnf = (f_isdn_rel_cnf *)isdn_rel_cnf; + sap.event_handle.h_isdn_stat_ind = (f_isdn_stat_ind *)isdn_stat_ind; + + if((*sap_id = isdn_bind_sap(&sap)) == -1) + { + printf("add sap error!\r\n"); + return; + } +} + +void isdn_cc_fsm(u32 pid) +{ + int offset, circuit_id; + static int i = 0; + Pst pst; + IsdnMsgStr isdn_msg; + + memset(&isdn_msg, 0, sizeof(IsdnMsgStr)); + pst.sp_proc_id = pid; + pst.su_proc_id = isdn_rs.port_pond[pid].su_proc_id; + + circuit_id = pid / ISDN_CIRCUIT_CIC; + offset = pid % ISDN_CIRCUIT_CIC; + pst.cic = isdn_rs.circuit_pond[circuit_id].attrib.head_cic + offset; + pst.cg_id = isdn_rs.circuit_pond[circuit_id].cg_id; + pst.circuit_id = circuit_id; + + if((isdn_rs.port_pond[pid].cic_state.call_state == CALLOUT_FLAG && isdn_rs.circuit_pond[circuit_id].user_network_if == NETWORK_SIDE) || + (isdn_rs.port_pond[pid].cic_state.call_state == CALLIN_FLAG && isdn_rs.circuit_pond[circuit_id].user_network_if == USER_SIDE)) + { + switch(cc_state[pid]) + { + case 1: + cc_state[pid] = 2; + break; + case 2: + memcpy(&isdn_msg.msg_list.callProc.chnl_id, &isdn_rv_msg.msg_list.setup.chnl_id, sizeof(ChnlId)); +/* isdn_msg.msg_list.alert.prg_ind.pres = 1; + isdn_msg.msg_list.alert.prg_ind.code_stan = 0; + isdn_msg.msg_list.alert.prg_ind.loc = 3; + isdn_msg.msg_list.alert.prg_ind.prg_descr = 8; + isdn_alert_req(&pst, &isdn_msg.msg_list.alert);*/ + isdn_msg.msg_list.callProc.chnl_id.b3.pref_excl = 1; + isdn_call_proc_req(&pst, &isdn_msg.msg_list.callProc); + cc_state[pid] = 3; + break; + case 3: + cc_state[pid] = 4; + break; + case 4: + isdn_setup_resp(&pst, &isdn_msg.msg_list.conn); + cc_state[pid] = 5; + break; + case 5: + i++; + if(i % 150 == 0) + { + i = 0; + cc_state[pid] = 6; + } + break; + case 6: +// isdn_set_cause(&isdn_msg.msg_list.disc.cause, CAUSE_NORMAL); +// isdn_disc_req(&pst, &isdn_msg.msg_list.disc); + cc_state[pid] = 0; + break; + default: + break; + } + } + else if((isdn_rs.port_pond[pid].cic_state.call_state == CALLIN_FLAG && isdn_rs.circuit_pond[circuit_id].user_network_if == NETWORK_SIDE) || + (isdn_rs.port_pond[pid].cic_state.call_state == CALLOUT_FLAG && isdn_rs.circuit_pond[circuit_id].user_network_if == USER_SIDE)) + { + switch(cc_state[pid]) + { + case 1: + i++; + if(i % 400 == 0) + { + i = 0; +// cc_state[pid] = 2; + } + break; + case 2: +// isdn_set_cause(&isdn_msg.msg_list.disc.cause, CAUSE_NORMAL); +// isdn_disc_req(&pst, &isdn_msg.msg_list.disc); + memcpy(&isdn_msg.msg_list.restart.chnl_id, &isdn_sd_msg.msg_list.setup.chnl_id, sizeof(ChnlId)); + isdn_msg.msg_list.restart.restart_ind.pres = 1; + isdn_msg.msg_list.restart.restart_ind.clas = 0; + isdn_m_restart_req(&pst, &isdn_msg.msg_list.restart); + cc_state[pid] = 0; + break; + default: + break; + } + } +} + + +static int flag[256] = {0}; +void isdn_cc_setup_fsm(u16 circuit_id) +{ + static int i = 0; + Pst pst; + IsdnSetup setup; + u8 cg_digit[] = {5,1,0,0,1}; + u8 cd_digit[] = {5,2,0,0,1}; + + memset(&setup, 0, sizeof(IsdnSetup)); + if(!flag[circuit_id]) + { + flag[circuit_id] = 1; + pst.circuit_id = circuit_id; + pst.cg_id = isdn_rs.circuit_pond[circuit_id].cg_id; + pst.su_proc_id = 0; + + setup.sd_comp.pres = 1; + setup.br_cap.pres = 1; + setup.br_cap.ext_flag = 1; + setup.br_cap.code_stan = 0; + setup.br_cap.tran_cap = 0; + setup.br_cap.b4.tran_mode = 0; + setup.br_cap.b4.tran_rate = 0x10; + setup.br_cap.b5.usr_layer1 = 3; + setup.br_cap.b5.has_ext_a = 1; + setup.chnl_id.pres = 1; + setup.chnl_id.b3.int_id_pre = 0; + setup.chnl_id.b3.int_type = 1; + setup.chnl_id.b3.pref_excl = 0; + setup.chnl_id.b3.chnl_ind = 0; + setup.chnl_id.b3.info_chnl_sel = 1; + setup.chnl_id.b3.code_stan = 0; + setup.chnl_id.b3.num_map = 0; + setup.chnl_id.b3.chnl_type = 3; + setup.chnl_id.b3.chnl_num = 2; //CIC + setup.cg_pty_num.pres = 1; + setup.cg_pty_num.b3.num_type = 0; + setup.cg_pty_num.b3.num_plan_id = 0; + setup.cg_pty_num.b3.has_ext_a = 0; + setup.cg_pty_num.b3.pres_ind = 0; + setup.cg_pty_num.b3.screen_ind = 0; + setup.cg_pty_num.ext_flag = 1; + setup.cg_pty_num.num_digit_len = sizeof(cg_digit); + memcpy(&setup.cg_pty_num.num_digit, cg_digit, setup.cg_pty_num.num_digit_len); + setup.cd_pty_num.pres = 1; + setup.cd_pty_num.num_type = 0; + setup.cd_pty_num.num_plan_id = 1; + setup.cd_pty_num.num_digit_len = sizeof(cd_digit); + memcpy(&setup.cd_pty_num.num_digit, cd_digit, setup.cd_pty_num.num_digit_len); + + setup.rpt_ind.pres = 1; + setup.prg_ind.pres = 1; + setup.prg_ind.loc = 3; + setup.prg_ind.prg_descr = 8; + setup.nt_sp_fac.pres = 1; + setup.nt_sp_fac.b3.len_net_id = 2; + setup.nt_sp_fac.b3.net_id_type = 2; + setup.nt_sp_fac.b3.net_id_plan = 1; + setup.nt_sp_fac.b3.net_id = 2; //?? {2,0,5} + setup.nt_sp_fac.spec = 2; +// setup.disp.pres = 1; +// setup.disp.disp_info_len = + + pst.cic = isdn_rs.circuit_pond[circuit_id].attrib.head_cic + setup.chnl_id.b3.chnl_num; +// isdn_setup_req(&pst, &setup); +// cc_state[pst.sp_proc_id] = 1; + } + + if(++i == 700) //more calls + { + i = 0; + flag[circuit_id] = 0; + } +} + +void cc_timer() +{ + u16 i, j; + u32 offset, pid; + + for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //for timer + { + if(isdn_rs.circuit_pond[i].enable == 0) + continue; + if((isdn_rs.attrib.isdn_run_mode == 1) && + (isdn_rs.circuit_pond[i].attrib.plat_id != isdn_rs.attrib.systemID)) + continue; + + offset = ISDN_CIRCUIT_CIC * i; + for(j = 0; j < ISDN_CIRCUIT_CIC; j++) + { + pid = offset + j; + if(isdn_rs.port_pond[pid].enable == 1) + isdn_cc_fsm(pid); + } + if(isdn_rs.circuit_pond[i].lk3_status == LK_IS) + isdn_cc_setup_fsm(i); + } + +} + + + + diff --git a/omc/plat/isdn/ut/test_main b/omc/plat/isdn/ut/test_main new file mode 100644 index 0000000..aac539e Binary files /dev/null and b/omc/plat/isdn/ut/test_main differ diff --git a/omc/plat/isdn/ut/test_main_0526 b/omc/plat/isdn/ut/test_main_0526 new file mode 100644 index 0000000..d9e7585 Binary files /dev/null and b/omc/plat/isdn/ut/test_main_0526 differ diff --git a/omc/plat/isup/.copyarea.db b/omc/plat/isup/.copyarea.db new file mode 100644 index 0000000..b7af05a --- /dev/null +++ b/omc/plat/isup/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isup +2 +6 +3:doc|2|0|0|0|e6f9679fbfa411dc852a001c23e19543|0 +2:ut|2|0|0|0|f7a96a93bfa411dc852a001c23e19543|0 +3:bin|2|0|0|0|e6f96783bfa411dc852a001c23e19543|0 +3:src|2|0|0|0|829b4a3a15c111dd906e001c23e19543|0 +8:Makefile|1|11d70a3f817|b31|fedec032|ecf968b7bfa411dc852a001c23e19543|0 +3:lib|2|0|0|0|ec59689bbfa411dc852a001c23e19543|0 diff --git a/omc/plat/isup/Makefile b/omc/plat/isup/Makefile new file mode 100644 index 0000000..66a9c2a --- /dev/null +++ b/omc/plat/isup/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = isup +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/isup/doc/.copyarea.db b/omc/plat/isup/doc/.copyarea.db new file mode 100644 index 0000000..fdd1f8d --- /dev/null +++ b/omc/plat/isup/doc/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isup\doc +2 +8 +13:ISUP_R9V0_02P02.doc|1|11d70a3f9eb|e400|672095eb|eb296863bfa411dc852a001c23e19543|0 +12:ISUP_R9V0_02P1.doc|1|11d70a3f8e2|e400|17758061|e79967bbbfa411dc852a001c23e19543|0 +13:ISUP_R9V0_01P07.doc|1|11d70a3f9cc|ea00|37e7f07|ea896847bfa411dc852a001c23e19543|0 +13:ISUP_R9V0_02P07.doc|1|11d70a3f93f|e400|1e009948|e8c967f3bfa411dc852a001c23e19543|0 +15:ISUP_R9V0_02P03-6.doc|1|11d70a3fa1a|e400|470e985c|ebb9687fbfa411dc852a001c23e19543|0 +13:ISUP_R9V0_01P08.doc|1|11d70a3f98d|ec00|b00965b6|e9f9682bbfa411dc852a001c23e19543|0 +12:ISUP_R9V0_01P8.doc|1|11d70a3f910|ec00|b00965b6|e82967d7bfa411dc852a001c23e19543|0 +13:ISUP_R9V0_02P01.doc|1|11d70a3f96e|e400|17758061|e959680fbfa411dc852a001c23e19543|0 diff --git a/omc/plat/isup/doc/ISUP_R9V0_01P07.doc b/omc/plat/isup/doc/ISUP_R9V0_01P07.doc new file mode 100644 index 0000000..8d66d50 Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_01P07.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_01P08.doc b/omc/plat/isup/doc/ISUP_R9V0_01P08.doc new file mode 100644 index 0000000..8f39b2b Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_01P08.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_01P8.doc b/omc/plat/isup/doc/ISUP_R9V0_01P8.doc new file mode 100644 index 0000000..8f39b2b Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_01P8.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_02P01.doc b/omc/plat/isup/doc/ISUP_R9V0_02P01.doc new file mode 100644 index 0000000..f55aa91 Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_02P01.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_02P02.doc b/omc/plat/isup/doc/ISUP_R9V0_02P02.doc new file mode 100644 index 0000000..cda0ba8 Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_02P02.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_02P03-6.doc b/omc/plat/isup/doc/ISUP_R9V0_02P03-6.doc new file mode 100644 index 0000000..f64038d Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_02P03-6.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_02P07.doc b/omc/plat/isup/doc/ISUP_R9V0_02P07.doc new file mode 100644 index 0000000..1f8b8ce Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_02P07.doc differ diff --git a/omc/plat/isup/doc/ISUP_R9V0_02P1.doc b/omc/plat/isup/doc/ISUP_R9V0_02P1.doc new file mode 100644 index 0000000..f55aa91 Binary files /dev/null and b/omc/plat/isup/doc/ISUP_R9V0_02P1.doc differ diff --git a/omc/plat/isup/lib/libisup.a b/omc/plat/isup/lib/libisup.a new file mode 100644 index 0000000..ee96159 Binary files /dev/null and b/omc/plat/isup/lib/libisup.a differ diff --git a/omc/plat/isup/obj/isup_debug.o b/omc/plat/isup/obj/isup_debug.o new file mode 100644 index 0000000..7efd886 Binary files /dev/null and b/omc/plat/isup/obj/isup_debug.o differ diff --git a/omc/plat/isup/obj/isup_fsm.o b/omc/plat/isup/obj/isup_fsm.o new file mode 100644 index 0000000..cec9927 Binary files /dev/null and b/omc/plat/isup/obj/isup_fsm.o differ diff --git a/omc/plat/isup/obj/isup_if.o b/omc/plat/isup/obj/isup_if.o new file mode 100644 index 0000000..945f77f Binary files /dev/null and b/omc/plat/isup/obj/isup_if.o differ diff --git a/omc/plat/isup/obj/isup_msg.o b/omc/plat/isup/obj/isup_msg.o new file mode 100644 index 0000000..75e5061 Binary files /dev/null and b/omc/plat/isup/obj/isup_msg.o differ diff --git a/omc/plat/isup/obj/isup_transit.o b/omc/plat/isup/obj/isup_transit.o new file mode 100644 index 0000000..54a8218 Binary files /dev/null and b/omc/plat/isup/obj/isup_transit.o differ diff --git a/omc/plat/isup/src/.copyarea.db b/omc/plat/isup/src/.copyarea.db new file mode 100644 index 0000000..5b9f202 --- /dev/null +++ b/omc/plat/isup/src/.copyarea.db @@ -0,0 +1,11 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isup\src +2 +7 +a:isup_fsm.c|1|11d70a3fae5|1264d|fa4525ec|e75482fe6cf311dd91a5001c23e19543|0 +9:isup_if.c|1|11d70a3fb52|55f6|33d47e1a|e7e4832e6cf311dd91a5001c23e19543|0 +e:isup_transit.c|1|11d70a3fbc0|2345|d6885ad7|f55348be339011dd9fa7001c23e19543|0 +a:isup_msg.c|1|11d70a3fb23|2eece|4fa30b2f|577648829a8611dd8b36001c23e19543|0 +c:isup_debug.c|1|11d70a3fb81|8f72|f19e417|5776489a9a8611dd8b36001c23e19543|0 +7:include|2|0|0|0|f119697bbfa411dc852a001c23e19543|0 +b:vssver2.scc|1|11d70a3faa7|b3|2f83790|ee2968efbfa411dc852a001c23e19543|0 diff --git a/omc/plat/isup/src/include/.copyarea.db b/omc/plat/isup/src/include/.copyarea.db new file mode 100644 index 0000000..7def846 --- /dev/null +++ b/omc/plat/isup/src/include/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isup\src\include +2 +9 +a:isup_msg.h|1|11d70a3fd56|1202d|6bd5a464|ebc3458e339011dd9fa7001c23e19543|0 +a:isup_def.h|1|11d70a3fcf8|5ac|aeacc308|f41969ebbfa411dc852a001c23e19543|0 +5:inc.h|1|11d70a3fde2|1b0|471868a7|f6796a5bbfa411dc852a001c23e19543|0 +c:isup_const.h|1|11d70a3fcc9|308e|5c6fbe7a|eb23455e339011dd9fa7001c23e19543|0 +9:isup_if.h|1|11d70a3fc4c|135c|7cc1484c|e884835e6cf311dd91a5001c23e19543|0 +b:vssver2.scc|1|11d70a3fc7b|10e|b3c958d8|f24969b3bfa411dc852a001c23e19543|0 +d:isup_public.h|1|11d70a3fe01|307|cd4dd595|f7196a77bfa411dc852a001c23e19543|0 +c:isup_debug.h|1|11d70a3fd85|456|dc863523|f5e96a3fbfa411dc852a001c23e19543|0 +d:isup_struct.h|1|11d70a3fd17|9d8|d4ad8f4b|e88483766cf311dd91a5001c23e19543|0 diff --git a/omc/plat/isup/src/include/inc.h b/omc/plat/isup/src/include/inc.h new file mode 100644 index 0000000..dab4918 --- /dev/null +++ b/omc/plat/isup/src/include/inc.h @@ -0,0 +1,19 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ + +#ifndef _ISUPINC_H_ +#define _ISUPINC_H_ + +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../../plat/public/src/include/license_id.h" + +extern int wxc2_get_license(int functionID); + +#endif + + diff --git a/omc/plat/isup/src/include/isup_const.h b/omc/plat/isup/src/include/isup_const.h new file mode 100644 index 0000000..a984c0a --- /dev/null +++ b/omc/plat/isup/src/include/isup_const.h @@ -0,0 +1,274 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ +#ifndef _ISUPCONST_H_ +#define _ISUPCONST_H_ + +//Protocol discriminator +#define ISUP_SI 0x05 + + +//block +/************************************/ +#define M_LOCAL_BLOCK 0x01 +#define M_REMOTE_BLOCK 0x02 + +/************************************/ + +//SUS +/************************************/ +#define ISUP_ORIG_SUSPEND 0x01 +#define ISUP_TERM_SUSPEND 0x02 + +/************************************/ + +//call state +#define IDLE_FLAG 0x00 +#define CALLIN_FLAG 0x01 +#define CALLOUT_FLAG 0x02 +#define START_RESET 0xFF + + +//timer flag +/************************************/ +#define BLS_FLAG 0x04 +#define BLR_FLAG 0x08 +#define MGBS_FLAG 0x10 +#define MGBR_FLAG 0x20 +#define CRS_FLAG 0x40 +#define CRR_FLAG 0x80 +#define CGRS_FLAG 0x100 +#define CGRR_FLAG 0x200 +/************************************/ + +//state +/************************************/ +#define CPCI_IDLE 0 +#define CPCI_WAIT_CONTINUITY 1 +#define CPCI_WAIT_ACM 2 +#define CPCI_WAIT_ANM 3 +#define CPCI_ANSWERED 4 +#define CPCI_SUSPENDED 5 +#define CPCI_WAIT_RLC 6 +#define CPCI_WAIT_REL_COMP 7 +#define CPCI_WAIT_RESET 8 +#define CPCI_WAIT_GROUP_RESET 9 +/************************************/ +#define CPCO_IDLE 0 +#define CPCO_WAIT_CONTINUITY 1 +#define CPCO_WAIT_ACM 2 +#define CPCO_WAIT_ANM 3 +#define CPCO_ANSWERED 4 +#define CPCO_SUSPENDED 5 +#define CPCO_WAIT_RLC 6 +#define CPCO_WAIT_REL_COMP 7 +#define CPCO_WAIT_RESET 8 +#define CPCO_WAIT_GROUP_RESET 9 +/************************************/ +#define BLS_IDLE 0 +#define BLS_WAIT_BLA 1 +#define BLS_LOCAL_LOCKED 2 +#define BLS_WAIT_UBA 3 +/************************************/ +#define BLR_IDLE 0 +#define BLR_WAIT_BLOCKING_RESP 1 +#define BLR_REMOTE_LOCKED 2 +#define BLR_WAIT_UNBLOCKING_RESP 3 +/************************************/ +#define MGBS_IDLE 0 +#define MGBS_WAIT_CGBA 1 +#define MGBS_WAIT_CGUA 2 +/************************************/ +#define MGBR_IDLE 0 +#define MGBR_WAIT_BLOCKING_RESP 1 +#define MGBR_WAIT_UNBLOCKING_RESP 2 +/************************************/ +#define CRS_IDLE 0 +#define CRS_WAIT_REL 1 +/************************************/ +#define CRR_IDLE 0 +#define CRR_WAIT_RESPONSE 1 +/************************************/ +#define CGRS_IDLE 0 +#define CGRS_WAIT_GRA 1 +/************************************/ +#define CGRR_IDLE 0 +#define CGRR_WAIT_GROUP_RESET_COMP 1 +/************************************/ + + + + +//********************************************/ +//****** ISUP Internal Command +//********************************************/ +#define CMD_UNBLO 0x01 +#define CMD_BLO 0x02 +#define CMD_RESET 0x03 +#define CMD_RESET_COMP 0x04 + + +#define SI_CPCI 0x10 +#define SI_CPCO 0x20 +#define SI_BLS 0x30 +#define SI_BLR 0x40 +#define SI_MGBR 0x50 +#define SI_MGBS 0x60 +#define SI_CRS 0x70 +#define SI_CRR 0x80 +#define SI_CGRS 0x90 +#define SI_CGRR 0xA0 + + +/********************************************/ +/****** ISUP Event/Primitive Definition *****/ +/********************************************/ +//Primitive +#define ISUP_SETUP_REQ 0x11 +#define ISUP_SETUP_IND 0x21 +#define ISUP_SETUP_RSP 0x31 +#define ISUP_SETUP_CNF 0x41 + +#define ISUP_RELEASE_REQ 0x12 +#define ISUP_RELEASE_IND 0x22 +#define ISUP_RELEASE_RSP 0x32 +#define ISUP_RELEASE_CNF 0x42 + +#define ISUP_ALERT_REQ 0x13 +#define ISUP_ALERT_IND 0x23 +#define ISUP_INFO_REQ 0x33 +#define ISUP_INFO_IND 0x43 +#define ISUP_PROG_REQ 0x53 +#define ISUP_PROG_IND 0x63 +#define ISUP_SUSPEND_REQ 0x73 +#define ISUP_SUSPEND_IND 0x83 +#define ISUP_RESUME_REQ 0x93 +#define ISUP_RESUME_IND 0xa3 + +#define ISUP_BLOCK_REQ 0x14 +#define ISUP_BLOCK_IND 0x24 +#define ISUP_BLOCK_RSP 0x34 +#define ISUP_BLOCK_CNF 0x44 +#define ISUP_UNBLOCK_REQ 0x54 +#define ISUP_UNBLOCK_IND 0x64 +#define ISUP_UNBLOCK_RSP 0x74 +#define ISUP_UNBLOCK_CNF 0x84 +#define ISUP_RESET_REQ 0x94 +#define ISUP_RESET_IND 0xa4 +#define ISUP_RESET_RSP 0xb4 +#define ISUP_RESET_CNF 0xc4 + +#define ISUP_DATA_IND 0x0f + +#define ISUP_REATTEMPT_IND 0x1f +#define ISUP_FAILURE_IND 0x2f +#define ISUP_MAINTENANCE_IND 0x3f +#define ISUP_STARTRESET_IND 0x4f + +#define ISUP_STOP_REQ 0xef +#define ISUP_STOP_CNF 0xff + + + + + +//Event +#define EN_NONE 0x00 +#define EN_ANM 0x01 +#define EN_CON 0x02 +#define EN_GROUP 0x03 + +#define EN_CLEAR_BLR 0x04 + +#define EN_T5_TIMEOUT 0x10 +#define EN_T13_TIMEOUT 0x11 +#define EN_T15_TIMEOUT 0x12 +#define EN_T19_TIMEOUT 0x13 +#define EN_T21_TIMEOUT 0x14 + +/********************************************/ +/****** ISUP Timer Definition (s) *****/ +/********************************************/ +/* +T1 15-60 seconds When release message is sent At the receipt of release complete message Retransmit release message and start timer T1 +T2 3 minutes When controlling exchange receives suspend (user) message At the receipt of resume (user) message at controlling exchange Initiate release procedure +T3 2 minutes At receipt of overload message On expiry Initiate release procedure +T4 5-15 minutes At receipt of MTP-STATUS primitive with the cause "remote user unavailable" On expiry, or at receipt of user part available message (or any other) Send user part test message. Start T4 +T5 5-15 minutes When initial release message is sent At receipt of release complete message Send reset circuit message, alert maintenance personnel and remove the circuit from service, stop T1, start T17. Procedure continues until maintenance intervention occurs +T6 Covered in Q.118 When controlling exchange receives suspend (network) At the receipt of resume (network) message or release message Initiate release procedure +T7 20-30 seconds When the latest address message is sent When the condition for normal release of address and routing information is met (receipt of ACM, CON messages) Release all equipment and connection(Send release message) +T8 10-15 seconds When an exchange receives initial address message requiring continuity check on this circuit or indicates that continuity check has been performed on a previous circuit At receipt of continuity message Release all equipment and connection into the network(Send release message) +T9 Interval specifiedin Q.118 When national controlling or outgoing international exchange receives ACM At the receipt of answer Release connection send back release message +T10 4-6 seconds When last digit is received in interworking situations At the receipt of fresh information Send address complete message +T11 15-20 seconds When latest address message is received in interworking situations When ACM is sent Send address complete message +T12 15-60 seconds When blocking message is sent At receipt of blocking acknowledgement Retransmit blocking message and start T12 +T13 5-15 minutes When initial blocking message is sent At receipt of blocking acknowledgement Transmit blocking message and alert maintenance personnel, start T13, stop T12. Procedure continues until maintenance intervention occurs +T14 15-60 seconds When unblocking message is sent At receipt of unblocking acknowledgement Retransmit unblocking message and start T14 +T15 5-15 minutes When initial unblocking message is sent At receipt of unblocking acknowledgement Retransmit unblocking message alert maintenance personnel, start T15 and stop T14. Procedure continues until maintenance intervention occurs +T16 15-60 seconds When reset circuit message is sent not due to expiry of T5 At the receipt of the acknowledgement (RLC message) Retransmit reset circuit message and start T16 +T17 5-15 minutes When initial reset circuit messageis sent At the receipt of the acknowledgement Alert maintenance personnel, retransmit reset circuit message, start T17, stop T16. Procedure continues until maintenance intervention occurs +T18 15-60 seconds When group blocking message is sent At receipt of group blocking acknowledgement Retransmit group blocking message and start T18 +T19 5-15 minutes When initial group blocking message is sent At receipt of group blocking acknowledgement Retransmit group blocking message, alert maintenance personnel, start T19, stop T18. Procedure continues until maintenance intervention occurs +T20 15-60 seconds When group unblocking message is sent At receipt of group unblocking acknowledgement Retransmit group unblocking message and start T20 +T21 5-15 minutes When initial group unblocking message is sent At receipt of group unblocking acknowledgement Retransmit group unblocking message, alert maintenance personnel, start T21, stop T20. Procedure continues until maintenance intervention occurs +T22 15-60 seconds When circuit group reset message is sent At the receipt of the acknowledgement Retransmit circuit group reset message and start T22 +T23 5-15 minutes When initial circuit group reset message is sent At the receipt of the acknowledgement Alert maintenance personnel and start T23, retransmit circuit group reset message, stop T22. Procedure continues until maintenance intervention occurs +T24 < 2 seconds When check tone is sent At the receipt of backward check tone Send continuity message with failure indication and:a) start T25 if continuity check was asked in IAM and make automatic repeat attempt; orb) start T26 if continuity check was asked in CCR +T25 1-10 seconds When initial continuity check failure is detected - Send CCR message and repeat continuity check +T26 1-3 minutes When second or subsequent continuity check failure is detected - Send CCR message and repeat continuity check +T27 4 minutes When continuity check failure indication is received At receipt of continuity check request message Send reset circuit message. Start T16 and T17 +T28 10 seconds When send CQM At receipt of CQR Alert maintenance +T29 300-600 ms Congestion indication received when T29 not running - New congestion indication will be taken into account +T30 5-10 seconds Congestion indication received when T29 not running - Restore traffic by one step if not yet at full load and start T30 +T31 > 6 minutes Release of ISDN User Part signalling connection based on CO SCCP On expiry Call reference reusable +T32 3-5 seconds When response to request of end-to-end connection establishment is sent At receipt of first end?to-end message from the remote end End-to-end message allowed to be sent +T33 12-15 seconds When send INR On receipt of INF Release call, alert maintenance personnel +T34 2-4 seconds When indication of a segmented message is received on an IAM, ACM, CPG, ANM or CON message At receipt of a segmentation message Proceed with call +T35 15-20 seconds At receipt of the latest digit (< > ST) and before the minimum or fixed number of digits have been received At receipt of ST or when the minimum or fixed number of digits have been received Send release message (cause 28) +T36 10-15 seconds When transit or incoming international exchange receives continuity check request message At receipt of continuity or release message Release all equipment, send reset circuit message. Start T16 and T17 +T37 2-4 seconds When request for an echo control device is sent to another exchange On expiry or when an indication of a half echo control device being included/not included is known Half echo control device is included or enabled +T38 Interval specified in Q.118 When the incoming international exchange sends to the preceding exchange a suspend (network) message At receipt of resume (network) or release message Send release message (cause 102) +T39 Interval specified in Q.730 When an MCID request is sent At receipt of an MCID response Call continues +*/ +#define ISUP_T1 15 +#define ISUP_T5 300 +#define ISUP_T7 30 +#define ISUP_T8 10 +#define ISUP_T9 120 +#define ISUP_T12 15 +#define ISUP_T13 300 +#define ISUP_T14 15 +#define ISUP_T15 300 +#define ISUP_T16 15 +#define ISUP_T17 300 +#define ISUP_T18 15 +#define ISUP_T19 300 +#define ISUP_T20 15 +#define ISUP_T21 300 +#define ISUP_T22 15 +#define ISUP_T23 300 +#define ISUP_T24 1 +#define ISUP_T25 1 +#define ISUP_T26 60 +#define ISUP_T27 240 +#define ISUP_T34 2 +#define ISUP_T36 10 +#define ISUP_T37 2 + + +#endif + + + + + + + + + + + diff --git a/omc/plat/isup/src/include/isup_debug.h b/omc/plat/isup/src/include/isup_debug.h new file mode 100644 index 0000000..18d00f6 --- /dev/null +++ b/omc/plat/isup/src/include/isup_debug.h @@ -0,0 +1,45 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ + +#ifndef _ISUPDEBUG_H_ +#define _ISUPDEBUG_H_ + +#include "inc.h" +#include "../../../debug/src/include/debug.h" + +/*Color Set */ +#define COL_WHITE 37 +#define COL_RED 31 +#define COL_YELLOW 33 +#define COL_GREEN 32 +#define COL_BLUE 34 +#define COL_BROWN 35 +#define COL_MEGEN 36 +#define COL_GRAY 38 +#define COL_HI_WHI 58 +#define COL_HI_RED 39 +#define COL_HI_YEL 52 +#define COL_HI_GRE 51 +#define COL_HI_BLU 53 +#define COL_HI_BRO 54 +#define COL_HI_MEG 55 +#define COL_BLACK 30 + +#define COL_ESC '\033' + +int isup_debug_init(void); +void isup_debug_timer(void); +void isup_log_err(u32 pid,const char *fmt, ...); +void isup_trace_func(u32 pid,const char *fmt, ...); +void monitor_isup_msg(u32 pid,BYTE *head, up_message *msg,BYTE col); +void isup_msg_csta(u8 msgtype,u8 flag); +void monitor_port_state(u32 cic_val,u32 port); +void test_isup_msg(u8 type, u8 flag); + + +#endif diff --git a/omc/plat/isup/src/include/isup_def.h b/omc/plat/isup/src/include/isup_def.h new file mode 100644 index 0000000..cbd9e9f --- /dev/null +++ b/omc/plat/isup/src/include/isup_def.h @@ -0,0 +1,62 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ +#ifndef _ISUPDEF_H_ +#define _ISUPDEF_H_ + +extern ISUP_Resource_Pond isup_db; +extern ISUP_Timer_Struct isup_timer_var; +extern up_message isup_rv_msg,isup_sd_msg; +extern SiAllPdus isup_rv_pdus,isup_sd_pdus; + +/*-----isup_msg.c-------*/ +extern int isup_mdsc_proc(); +extern int isup_send_msg(u32 pid, u8 msg_type); + + +/*-----isup_fsm.c-------*/ +extern int isup_event_handle(u32 pid, u8 primitive, u8 eventType); + + +extern void isup_cpc_proc(u32 pid); +extern void isup_cpc_timer(u32 pid); + +extern void isup_cpci_proc(u32 pid); +extern void isup_cpci_timer(u32 pid); + +extern void isup_cpco_proc(u32 pid); +extern void isup_cpco_timer(u32 pid); + +extern void isup_csc_timer(u32 pid); + +extern void isup_bls_proc(u32 pid); +extern void isup_bls_timer(u32 pid); + +extern void isup_blr_proc(u32 pid); + + +extern void isup_mgbr_proc(u32 pid); + + +extern void isup_mgbs_proc(u32 pid); +extern void isup_mgbs_timer(u32 pid); + +extern void isup_crr_proc(u32 pid); + + +extern void isup_crs_proc(u32 pid); +extern void isup_crs_timer(u32 pid); + +extern void isup_cgrr_proc(u32 pid); + + +extern void isup_cgrs_proc(u32 pid); +extern void isup_cgrs_timer(u32 pid); + +extern u8 isup_check_crs_waiting(u32 pid); + +#endif diff --git a/omc/plat/isup/src/include/isup_if.h b/omc/plat/isup/src/include/isup_if.h new file mode 100644 index 0000000..39a3010 --- /dev/null +++ b/omc/plat/isup/src/include/isup_if.h @@ -0,0 +1,111 @@ +//========================================= +// +// +// Author: Zane Yi +// Date: 2007.02.01 +// +//========================================= +#ifndef _ISUPIF_H_ +#define _ISUPIF_H_ + +#include "../../../pal/pal.h" +#include "isup_const.h" +#include "isup_public.h" +#include "isup_msg.h" + +//***************************************************** +// ISUP Module parameter structure +//***************************************************** + +typedef int f_isup_setup_ind(Pst *pst, const SiPduIAM *ptr, u8 *raw_data, u8 len); +typedef int f_isup_setup_anm_cnf(Pst *pst, const SiPduANM *ptr_anm, u8 *raw_data, u8 len); +typedef int f_isup_setup_con_cnf(Pst *pst, const SiPduCON *ptr_con, u8 *raw_data, u8 len); +typedef int f_isup_release_ind(Pst *pst, const SiPduREL *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_release_cnf(Pst *pst, const SiPduRLC *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_alert_ind(Pst *pst, const SiPduACM *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_info_ind(Pst *pst, const SiPduSAM *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_prog_ind(Pst *pst, const SiPduCPG *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_suspend_ind(Pst *pst, const SiPduSUS *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_resume_ind(Pst *pst, const SiPduRES *ptr, u8 *raw_data, u8 len ); +typedef int f_isup_block_ind(Pst *pst, const SiPduCGB *ptr); +typedef int f_isup_block_cnf(Pst *pst, const SiPduCGBA *ptr); +typedef int f_isup_unblock_ind(Pst *pst, const SiPduCGU *ptr); +typedef int f_isup_unblock_cnf(Pst *pst, const SiPduCGUA *ptr); +typedef int f_isup_reset_ind(Pst *pst, const SiPduGRS *ptr); +typedef int f_isup_reset_cnf(Pst *pst, const SiPduGRA *ptr); +typedef int f_isup_local(Pst *pst); +typedef int f_isup_maintance_ind(Pst *pst,u8 eventType); +typedef int f_isup_data_ind(Pst *pst, u8 msgType, const SiAllPdus *ptr, u8 *raw_data, u8 len); + +typedef struct _eventhandle_struct +{ + f_isup_setup_ind *h_isup_setup_ind; + f_isup_setup_anm_cnf *h_isup_setup_anm_cnf; + f_isup_setup_con_cnf *h_isup_setup_con_cnf; + f_isup_release_ind *h_isup_release_ind; + f_isup_release_cnf *h_isup_release_cnf; + f_isup_alert_ind *h_isup_alert_ind; + f_isup_info_ind *h_isup_info_ind; + f_isup_prog_ind *h_isup_prog_ind; + f_isup_suspend_ind *h_isup_suspend_ind; + f_isup_resume_ind *h_isup_resume_ind; + f_isup_block_ind *h_isup_block_ind; + f_isup_block_cnf *h_isup_block_cnf; + f_isup_unblock_ind *h_isup_unblock_ind; + f_isup_unblock_cnf *h_isup_unblock_cnf; + f_isup_reset_ind *h_isup_reset_ind; + f_isup_reset_cnf *h_isup_reset_cnf; + f_isup_local *h_isup_reattempt_ind; + f_isup_local *h_isup_failure_ind; + f_isup_maintance_ind *h_isup_maintenance_ind; + f_isup_local *h_isup_startreset_ind; + f_isup_data_ind *h_isup_data_ind; +} EventHandle_struct; + +typedef struct _sap_attrib_struct +{ + EventHandle_struct event_handle; +}Sap_Attrib_struct; +//***************************************************** +// ISUP Module interface +//***************************************************** + +#define ISUP_CM_OK 1 /* Command request success */ +#define ISUP_CM_FAILED 0 /* Command request failed */ + +//Command +extern int isup_setup_req(Pst *pst, SiPduIAM *ptr, u8 *raw_data, u8 len); +extern int isup_setup_anm_rsp(Pst *pst, SiPduANM *ptr_anm, u8 *raw_data, u8 len); +extern int isup_setup_con_rsp(Pst *pst, SiPduCON *ptr_con, u8 *raw_data, u8 len); +extern int isup_release_req(Pst *pst, SiPduREL *ptr, u8 *raw_data, u8 len); +extern int isup_release_rsp(Pst *pst, SiPduRLC *ptr, u8 *raw_data, u8 len); +extern int isup_alert_req(Pst *pst, SiPduACM *ptr, u8 *raw_data, u8 len); +extern int isup_info_req(Pst *pst, SiPduSAM *ptr, u8 *raw_data, u8 len); +extern int isup_prog_req(Pst *pst, SiPduCPG *ptr, u8 *raw_data, u8 len); +extern int isup_suspend_req(Pst *pst, SiPduSUS *ptr, u8 *raw_data, u8 len); +extern int isup_resume_req(Pst *pst, SiPduRES *ptr, u8 *raw_data, u8 len); +extern int isup_block_req(Pst *pst, SiPduCGB *ptr ); +extern int isup_block_rsp(Pst *pst, SiPduCGBA *ptr); +extern int isup_unblock_req(Pst *pst, SiPduCGU *ptr ); +extern int isup_unblock_rsp(Pst *pst, SiPduCGUA *ptr); +extern int isup_reset_req(Pst *pst, SiPduGRS *ptr ); +extern int isup_reset_rsp(Pst *pst, SiPduGRA *ptr); +extern int isup_bls_stop_req(Pst *pst); +extern int isup_mgbs_stop_req(Pst *pst); +extern int isup_crs_stop_req(Pst *pst); +extern int isup_cgrs_stop_req(Pst *pst); +extern int isup_data_req(Pst *pst, u8 msgType, SiAllPdus *ptr, u8 *raw_data, u8 len); + +//run_mode +#define ISUP_SINGLE_MODE 0 /* Single Plat */ +#define ISUP_DUAL_MODE 1 /* DUAL Plat */ + +extern int isup_set_run_mode (u8 run_mode, u32 alter_ip); +extern int isup_inquire_cic (u16 cg_id, u32 cic);//return -1/0/1 L3 down/L4 failed/L4 normal + + +//system interface +extern void isup_init(u8 systemID, u32 interval_ms); +extern void isup_timer(); +#endif + diff --git a/omc/plat/isup/src/include/isup_msg.h b/omc/plat/isup/src/include/isup_msg.h new file mode 100644 index 0000000..47ab357 --- /dev/null +++ b/omc/plat/isup/src/include/isup_msg.h @@ -0,0 +1,1699 @@ +//========================================= +// +// +// Author: Zane Yi +// Date: 2007.02.01 +// +//========================================= +#ifndef _ISUPMSG_H_ +#define _ISUPMSG_H_ + +#include "isup_public.h" +#include "inc.h" + + +#define MAX_ISUP_MSG_LEN 256 +#define MAX_ISUP_DIGIT 32 +#define ISUP_STATUS_LEN 4 + +//**********************************************/ +//* Message Value +//**********************************************/ +#define TEST_CALL 0x0d//Test call + +//**********************************************/ +//* Message Type Codes +//**********************************************/ + +#define M_ACM 0x06//Address complete(6) +#define M_ANM 0x09//Answer(9) +#define M_APP 0x41//Application transport message(65) +#define M_BLO 0x13//Blocking(19) +#define M_BLA 0x15//Blocking acknowledgement(21) +#define M_CPG 0x2c//Call progress(44) +#define M_CGB 0x18//Circuit/CIC group blocking(24) +#define M_CGBA 0x1a//Circuit/CIC group blocking acknowledgement(26) +#define M_CQM 0x2a//Circuit/CIC group query (national use)(42) +#define M_CQR 0x2b//Circuit/CIC group query response (national use)(43) +#define M_GRS 0x17//Circuit/CIC group reset(23) +#define M_GRA 0x29//Circuit/CIC group reset acknowledgement(41) +#define M_CGU 0x19//Circuit/CIC group unblocking(25) +#define M_CGUA 0x1b//Circuit/CIC group unblocking acknowledgement(27) +#define M_CRG 0x31//Charge information (national use)(49) +#define M_CFN 0x2f//Confusion(47) +#define M_CON 0x07//Connect(7) +#define M_COT 0x05//Continuity(5) +#define M_FAC 0x33//Facility (51) +#define M_FAA 0x20//Facility accepted(32) +#define M_FRJ 0x21//Facility reject(33) +#define M_FAR 0x1f//Facility request(31) +#define M_FOT 0x08//Forward transfer(8) +#define M_IDR 0x36//Identification request(54) +#define M_IRS 0x37//Identification response(55) +#define M_INF 0x04//Information (national use)(4) +#define M_INR 0x03//Information request (national use)(3) +#define M_IAM 0x01//Initial address(1) +#define M_LPA 0x24//Loop Back Acknowledgement(36) +#define M_NRM 0x32//Network resource management(50) +#define M_OLM 0x30//Overload(48) +#define M_PAM 0x28//Pass-Along(40) +#define M_REL 0x0c//Release(12) +#define M_RLC 0x10//Release complete(16) +#define M_RSC 0x12//Reset circuit/CIC(18) +#define M_RES 0x0e//Resume(14) +#define M_SGM 0x38//Segmentation(56) +#define M_SAM 0x02//Subsequent address(2) +#define M_SUS 0x0d//Suspend(13) +#define M_UBL 0x14//Unblocking(20) +#define M_UBA 0x16//Unblocking acknowledgement(22) +#define M_UCIC 0x2e//Unequipped CIC (national use)(46) +#define M_UPA 0x35//User Part Available(53) +#define M_UPT 0x34//User Part Test(52) +#define M_USR 0x2d//User-to-user information(45) + +#define M_LOP 0x40//Loop Prevention(64) +#define M_PRI 0x42//Pre-release information message (66) + +#define M_CVR 0xeb//Circuit validation response +#define M_CVT 0xec//Circuit validation test + + +//#define M_ADDCOMP 0x06 /* Address complete */ +//#define M_ANSWER 0x09 /* Answer */ +//#define M_BLOCK 0x13 /* Blocking */ +//#define M_BLOCKACK 0x15 /* Blocking acknowledgement */ +//#define M_CALLMODCOMP 0x1d /* Call modification completed */ +//#define M_CALLMODREQ 0x1c /* Call modification request */ +//#define M_CALLMODREJ 0x1e /* Call modification reject */ +//#define M_CALLPROG 0x2c /* Call progress */ +//#define M_CIRGRPBLK 0x18 /* Circuit group blocking */ +//#define M_CIRGRPBLKACK 0x1a /* Circuit group blocking acknowledgement */ +//#define M_CIRGRPQRY 0x2a /* Circuit group query */ +//#define M_CIRGRPQRYRES 0x2b /* Circuit group query response */ +//#define M_CIRGRPRES 0x17 /* Circuit group reset */ +//#define M_CIRGRPRESACK 0x29 /* Circuit group reset acknowledgement */ +//#define M_CIRGRPUBLK 0x19 /* Circuit group unblocking */ +//#define M_CIRGRPUBLKACK 0x1b /* Circuit group unblocking acknowledgement */ +//#define M_CONFUSION 0x2f /* Confusion */ +//#define M_CONNCT 0x07 /* Connect */ +//#define M_CONTINUITY 0x05 /* Continuity */ +//#define M_CONTCHKREQ 0x11 /* Continuity Check Request */ +//#define M_DELREL 0x27 /* Delayed Release */ +//#define M_FACACC 0x20 /* Facility Accepted */ +//#define M_FACREJ 0x21 /* Facility Rejected */ +//#define M_FACREQ 0x1f /* Facility Request */ +//#define M_FWDTFER 0x08 /* Forward Transfer */ +//#define M_INFORMTN 0x04 /* Information */ +//#define M_INFOREQ 0x03 /* Information request */ +//#define M_INIADDR 0x01 /* Intial Address */ +//#define M_LOOPBCKACK 0x24 /* Loop back acknowledgement */ +//#define M_OVERLOAD 0x30 /* Overload */ +//#define M_PASSALNG 0x28 /* Pass-along */ +//#define M_RELSE 0x0c /* Release */ +//#define M_RELCOMP 0x10 /* Release complete */ +//#define M_RESCIR 0x12 /* Reset circuit */ +//#define M_RESUME 0x0e /* Resume */ +//#define M_SUBADDR 0x02 /* Subsequent address */ +//#define M_SUSPND 0x0d /* Suspend */ +//#define M_UNBLK 0x14 /* Unblocking */ +//#define M_UNBLKACK 0x16 /* Unblocking acknowledgement */ +//#define M_UNEQUIPCIC 0x2e /* Unequiped Cicuit Identification Code */ +//#define M_USR2USR 0x2d /* User to user */ +// +//#define M_CUGSELVALRSP 0x26 /* Clsd. usr. grp. sel. val. rsp. */ +//#define M_CUGSELVALREQ 0x25 /* Clsd. usr. grp. sel. val. req. */ +//#define M_CIRVALRSP 0xeb /* Circuit validation response */ +//#define M_CIRVALTEST 0xec /* Circuit validation test */ +//#define M_EXIT 0xed /* Exit */ +//#define M_FACINF 0x23 /* Facility information */ +//#define M_FACDEACT 0x22 /* Facility deactivation */ +//#define M_CIRRESERVE 0xea /* Circuit Reservation */ +//#define M_CIRRESACK 0xe9 /* Circuit Reservation Acknowledgement */ +//#define M_FACIL 0x33 /* Facility Message */ +//#define M_IDENTREQ 0x36 /* Identification Request Message */ +//#define M_IDENTRSP 0x37 /* Identification Response Message */ +//#define M_NETRESMGT 0x32 /* Network Resource Management Message */ +//#define M_USRPARTA 0x35 /* User Part Available Message */ +//#define M_USRPARTT 0x34 /* User Part Test Message */ +//#define M_MALCLLPRNT 0xff /* Malicious call print */ +//#define M_CHARGE 0x31 /* Charge Info */ +//#define M_COM 0xe0 /* Call Offering Message */ +//#define M_TRFFCHGE 0xfe /* Tariff Change */ +//#define M_CHARGEACK 0xfd /* Charge Acknowledge */ +// +//#define M_LOOPPRVNT 0x40 /* Loop Prevention */ +// +//#define M_GTCHRG 0xfd /* charging */ +//#define M_GTCHRGEXT 0xfa /* charging extended */ +//#define M_GTCHRGEXTACK 0xfb /* charging extended acknowledge */ +//#define M_GTHANGUP 0xfc /* hanging up of A-tln */ +//#define M_GTFACINF 0x23 /* Facility information */ +//#define M_GTUSRINF 0x24 /* user information */ +//#define M_GTNATMSG 0xff /* National message */ +// +//#define M_SEGMMSG 0x38 /* segmentation */ +// +//#define M_CALLCLEAR 0xfc /* Call Line Clear */ +//#define M_RINGSEND 0xff /* Ringing Send Message */ +//#define M_CHGNTT 0xfe /* charging message in NTT */ +// +//#define M_APPTRAN 0x41 /* Application transport message */ +//#define M_PRERELINF 0x42 /* Pre-release information message */ +// + +//**********************************************/ +//* Parameter names (Q.763) +//**********************************************/ +#define ME_ACCTPORT 0x03 /* Access transport */ +#define ME_AUTOCONGLVL 0x27 /* Automatic congestion level */ +#define ME_BACKCALLIND 0x11 /* Backward call indicators */ +#define ME_CALLMODIND 0x17 /* Call modification indicators */ +#define ME_CALREF 0x01 /* Call reference */ +#define ME_CALDPARTNUM 0x04 /* Called party's number */ +#define ME_CALGPARTNUM 0x0a /* Calling party number */ +#define ME_CALGPARTCAT 0x09 /* Calling party category */ +#define ME_CAUSIND 0x12 /* Cause indicator */ +#define ME_CGRPSUPMTYPIND 0x15 /* Circuit grp supervision msg. type */ +#define ME_CIRCSTEIND 0x26 /* Cicuit state indicator */ +#define ME_CLSDUGRPINTCDE 0x1a /* Closed user group interlock code */ +#define ME_CONNUMB 0x21 /* Connected number */ +#define ME_CONREQ 0x0d /* Connection request */ +#define ME_CONTIND 0x10 /* Continuity indicators */ +#define ME_ENDOP 0x00 /* End of optional parameters */ +#define ME_EVNTINFO 0x24 /* Event inforamtion */ +#define ME_FACIND 0x18 /* Facility indicator */ +#define ME_FWDCALLIND 0x07 /* Forward call indicator */ +#define ME_INFOIND 0x0f /* Information indicators */ +#define ME_INFOREQIND 0x0e /* Information request indicators */ +#define ME_NATCONIND 0x06 /* Nature of connection indicators */ +#define ME_OPBACKCALLIND 0x29 /* Optional backward call indicator */ +#define ME_OPFWDCALLIND 0x08 /* Optional foreward call indicator */ +#define ME_ORIGCALDNUM 0x28 /* Original Called Number */ +#define ME_RANGSTAT 0x16 /* Range and Status */ +#define ME_REDIRGNUM 0x0b /* Redirecting number */ +#define ME_REDIRINFO 0x13 /* Redirection information */ +#define ME_REDIRNUM 0x0c /* Redirection number */ +#define ME_SIGPTCDE 0x1e /* Signal point code */ +#define ME_SUBSEQNUM 0x05 /* Subsequent number */ +#define ME_SUSPRESIND 0x22 /* Suspend/Resume indicators */ +#define ME_TRANNETSEL 0x23 /* Transit network selection */ +#define ME_TRANSMEDREQ 0x02 /* Transmission medium requirement */ +#define ME_USRSERVINFO 0x1d /* User service information */ +#define ME_USR2USRIND 0x2a /* User to User indicators */ +#define ME_USR2USRINFO 0x20 /* User to User information */ + +#define ME_ACCDELINFO 0x2e /* access delivery information */ +#define ME_CLLDIVERS 0x36 /* call Diversion information */ +#define ME_CLLHISTORY 0x2d /* call history information */ +#define ME_ECHOCNTRL 0x37 /* echo control */ +#define ME_NOTIFINDC 0x2c /* generic notification */ +#define ME_GENNMB 0xc0 /* generic number */ +#define ME_MCIDREQ 0x3b /* MCID request indicators */ +#define ME_MCIDRSP 0x3c /* MCID response indicators */ +#define ME_MSGCOMP 0x38 /* message compatibility info */ +#define ME_MLPPPREC 0x3a /* MLPP precedence */ +#define ME_NETSPFAC 0x2f /* network specific facility */ +#define ME_ORISCCDE 0x2b /* originating ISC point code */ +#define ME_PARCOMPIN 0x39 /* parameter compatibility info */ +#define ME_PROPDLYCTR 0x31 /* propagation delay counter */ +#define ME_REDIRRESTR 0x40 /* redirection restriction */ +#define ME_REMOTOPER 0x32 /* remote operations */ +#define ME_SERVACT 0x33 /* service activation */ +#define ME_TRANSMEDPRM 0x3e /* Transmission media prime */ +#define ME_TRANSMEDUSD 0x35 /* Transmission media used */ +#define ME_USRSERVINFOPR 0x30 /* User service information prime */ +#define ME_LOCNMB 0x3f /* location number */ + +/* Information Element ID tags - ANSI or ANSI 92 specific */ + +#define ME_CHARGENUM 0xeb /* Charge number */ +#define ME_CGRPCHARIND 0xe5 /* Circuit group characteristic ind. */ +#define ME_CIRIDNAME 0xe8 /* Circuit ID name */ +#define ME_CIRVALRSPIND 0xe6 /* Circuit validation response ind. */ +#define ME_CLLI 0xe9 /* Common language location ind. */ +#define ME_ORGLINEINF 0xea /* Original line information */ +#define ME_OUTGTRKGRPNUM 0xe7 /* Outgoing trunk group number */ + +/* Information Element ID tags - ANSI specific */ + +#define ME_CLSDUGRPCHKRSP 0x1c /* Closed user group check response */ +#define ME_FACINFIND 0x19 /* Facility information indicator */ +#define ME_INDEX 0x1b /* Index */ + +/* Information Element ID tags - ANSI 92 specific */ +#define ME_BUSINESSGRP 0xc6 /* Business group */ +#define ME_CARRIERID 0xc5 /* Carrier Idenification */ +#define ME_CARSELINF 0xee /* Carrier Selection Information */ +#define ME_EGRESS 0xc3 /* Egress Service */ +#define ME_GENADDR 0xc0 /* Generic Adress */ +#define ME_GENDIGITS 0xc1 /* Generic Digits */ +#define ME_JURISINF 0xc4 /* Jurisdiction Information */ +#define ME_NETTRANS 0xef /* Network Transport */ +#define ME_NOTIFIND 0xe1 /* Notification Indicator */ +#define ME_SERVACTA 0xe2 /* Service Activation */ +#define ME_SPECPROCREQ 0xed /* Special Processing Request */ +#define ME_TRANSREQ 0xe3 /* Transaction Request */ +#define ME_SERVCODE 0xec /* service code indicator */ + +/* Information Element ID tags - ETSI specific */ + +#define ME_CALLTRNSFRNMB 0x45 /* Call Transfer Number */ +#define ME_CALLTRNSFRREF 0x43 /* Call Transfer Reference */ +#define ME_CCBSPARAM 0x4b /* CCBS Parameter */ +#define ME_LOOPPRVNTIND 0x44 /* Loop Prevention Indicator */ +#define ME_FREEPHIND 0x41 /* Free Phone Indicator */ +#define ME_USRTSRVINFO 0x34 /* User Teleservice Information */ + +/* Information Element code for ANSI 95 variant */ +#define ME_CIRASGNMAP 0x25 /* Circuit Assignment Map */ +#define ME_OPTRSERVICEINFO 0xc2 /* Operator Service Info */ + +/* Information Element code for ITU 97 variant */ +#define ME_CONFTRTIND 0x72 /* confrence treatment indicators */ +#define ME_UIDACTIONIND 0x74 /* UID action indicator */ +#define ME_DISPLAYINFO 0x73 /* display information */ +#define ME_BACKWARDGVNS 0x4d /* backward GVNS */ +#define ME_FORWARDGVNS 0x4c /* forward GVNS */ +#define ME_NETMGMTCONTROLS 0x5b /* n/w management controls */ +#define ME_CORRELATIONID 0x65 /* correlation Id */ +#define ME_CALLDIVTRTIND 0x6e /* call diversion trt ind */ +#define ME_CALLINNMB 0x6f /* call IN number */ +#define ME_CALLOFFERTRTIND 0x70 /* call offering trt ind */ +#define ME_SCFID 0x66 /* SCF Id */ +#define ME_UIDCAPIND 0x75 /* UID capability indicator */ +#define ME_COLLCALLREQ 0x79 /* collect call request */ +#define ME_CCSS 0x4b /* CCSS */ +#define MEI_CHRGINFODELAY 0x71 /* Charge information delay */ +#define ME_HOPCOUNTER 0x3d /* Hop counter */ + +/* Information Element code for ETSIV3 variant */ +#define ME_APPTRAN 0x78 /* application transport param */ + +/* Information Element code for UK specific */ +#define ME_NATFORCALIND 0xfe /* National Forward Call Indicators */ +#define ME_PRESNUM 0xfd /* Presentation Number */ +#define ME_LASDIVLINID 0xfc /* Last Diverting Line Identity */ +#define ME_PARTCLI 0xfb /* Partial CLI */ +#define ME_CALDSUBBASSERMAR 0xfa /* Called Subscribers Basic Service Marks */ +#define ME_CALGSUBBASSERMAR 0xf9 /* Calling Subscribers Basic Service Marks */ +#define ME_CALGSUBORIFACMAR 0xf8 /* Calling Subscribers Originating Facility Marks */ +#define ME_CALDSUBTERFACMAR 0xf7 /* Called Subscribers Terminating Facility Marks */ +#define ME_NATINFREQIND 0xf6 /* National Information Request Indicators */ +#define ME_NATINFIND 0xf5 /* National Information Indicators */ +#define ME_NATFORCALIND_LTL 0xf4 /* National Forward Call Indicators (Link by link) */ + + +//**********************************************/ +//* Parameter Structure (Q.763) +//**********************************************/ +typedef struct accDelInfo /* Access delivery information */ +{ + u8 pres; /* element header */ + u8 delInd; /* delivery indicator */ +} SiAccDelInfo; + +typedef struct accTrnspt /* Access transport */ +{ + u8 pres; /* element header */ + u8 infoLen; /*Information length*/ + u8 infoElmts[MAX_ISUP_MSG_LEN]; /* Information elements */ +} SiAccTrnspt; + +typedef struct autoCongLvl /* Automatic Congestion Level */ +{ + u8 pres; /* element header */ + u8 auCongLvl; /* auto congestion level */ +} SiAutoCongLvl; + +typedef struct bckCalInd /* Backward Call Indicators */ +{ + u8 pres; /* element header */ + u8 chrgInd; /* Charge Indicator */ + u8 cadPtyStatInd; /* called party status indicator */ + u8 cadPtyCatInd; /* called party category indicator */ + u8 end2EndMethInd; /* end to end method indicator */ + u8 intInd; /* interworking indicator */ + u8 end2EndInfoInd; /* end to end information indicator */ + u8 isdnUsrPrtInd; /* ISDN User Part indicator */ + u8 holdInd; /* holding indicator */ + u8 isdnAccInd; /* ISDN access indicator */ + u8 echoCtrlDevInd; /* echo control device indicator */ + u8 sccpMethInd; /* SCCP method indicator */ +} SiBckCalInd; + +typedef struct cllDiverInfo /* call Diversion information */ +{ + u8 pres; /* element header */ + u8 notSuscr; /* Notification subscribtion */ + u8 redirRsn; /* redirection reason */ +} SiCllDiverInfo; + +typedef struct propDly /* propagation delay */ /* call history information */ +{ + u8 pres; /* element header */ + u16 delayVal; /* delay value */ +} SiPropDly; + +typedef struct callRef /* Call Reference */ +{ + u8 pres; /* element header */ + u8 callId[3]; /* call identity */ + u16 pntCde; /* point code */ +} SiCallRef; + +typedef struct cdPtyNum /* Called Party Number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 numPlan; /* numbering plan */ + u8 innInd; /* internal network number indicator */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ +} SiCdPtyNum; + +typedef struct cgPtyNum /* Calling Party Number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 scrnInd; /* screen indicator */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 niInd; /* number incomplete indicator */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ +} SiCgPtyNum; + +typedef struct sicgPtyCat /* Calling Party Category */ +{ + u8 pres; /* element header */ + u8 cgPtyCat; /* calling party category */ +} SiCgPtyCat; + +typedef struct siCauseDgn /* Cause Indicator */ +{ + u8 pres; /* element header */ + u8 location; /* location */ + u8 cdeStand; /* coding standard */ + u8 causeVal; /* cause value */ + u8 length; /*diagnostics len*/ + u8 dgnVal[MAX_ISUP_MSG_LEN]; /* diagnostics */ +} SiCauseDgn; + +typedef struct cirGrpSupMTypInd /* Circuit Group Supervision Msg. Type Ind. */ +{ + u8 pres; /* element header */ + u8 typeInd; /* circuit group supervision msg. type ind. */ +} SiCirGrpSupMTypInd; + +typedef struct sicirStateInd /* Circuit State Indicators */ +{ + u8 pres; /* element header */ + u8 length; + u8 cirSteInd[32]; /* circuit state indicator. */ +} SiCirStateInd; + +typedef struct cugIntCode /* Closed User Group Interlock Code */ +{ + u8 pres; /* element header */ + u8 dig2; /* Digit 2 */ + u8 dig1; /* Digit 1 */ + u8 dig4; /* Digit 4 */ + u8 dig3; /* Digit 3 */ + u16 binCde; /* binary Code */ +} SiCugIntCode; + +typedef struct connectedNum /* Connected number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 scrnInd; /* screen indicator */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ + +} SiConnectedNum; + +typedef struct connReq /* Connection Request */ +{ + u8 pres; /* element header */ + u8 locRef[3]; /* local reference */ + u16 pntCde; /* point code */ + u8 protClass; /* protocol classs */ + u8 credit; /* credit */ +} SiConnReq; + +typedef struct sicontInd /* Continuity indicators */ +{ + u8 pres; /* element header */ + u8 contInd; /* continuity indicator */ +} SiContInd; + +typedef struct echoCtl /* echo control information */ +{ + u8 pres; /* element header */ + u8 outEchoRsp; /* outgoing echo control device response */ + u8 incEchoRsp; /* incoming echo control device response */ + u8 outEchoReq; /* outgoing echo control device request */ + u8 incEchoReq; /* incoming echo control device request */ +} SiEchoCtl; + +typedef struct siEndOp /* End of Optional Parameters */ +{ + u8 pres; /* element header */ + u8 nullVal; /* null value, if present */ +} SiEndOp; + +typedef struct evntInfo /* Event Information */ +{ + u8 pres; /* element header */ + u8 evntInd; /* event indicators */ + u8 evntPresResInd; /* event presentation restriction indicators*/ +} SiEvntInfo; + +typedef struct sifacInd /* Facility Indicators */ +{ + u8 pres; /* element header */ + u8 facInd; /* facility indicator */ +} SiFacInd; + +typedef struct fwdCallInd /* Forward Call Indicators */ +{ + u8 pres; /* element header */ + u8 natIntCallInd; /* National/International Call Indicator */ + u8 end2EndMethInd; /* end to end method indicator */ + u8 intInd; /* interworking indicator */ + u8 end2EndInfoInd; /* end to end information indicator */ + u8 isdnUsrPrtInd; /* ISDN User Part indicator */ + u8 isdnUsrPrtPrfInd; /* ISDN User Part preference indicator */ + u8 isdnAccInd; /* ISDN access indicator */ + u8 sccpMethInd; /* SCCP method indicator */ +} SiFwdCallInd; + +typedef struct sifreePhInd /* Freephone Indicator */ +{ + u8 pres; /* element header */ + u8 freePhInd; /* free phone indicator */ +} SiFreePhInd; + +typedef struct genDigits /* Generic Digits */ +{ + u8 pres; /* element header */ + u8 typeOfDigits; /* type of digits */ + u8 encodeScheme; /* encoding scheme */ + u8 length; /* length */ + u8 digits[MAX_ISUP_MSG_LEN]; /* digits */ +} SiGenDigits; + +typedef struct sinotifInd /* Notification Indicator */ +{ + u8 pres; /* element header */ + u8 notifInd; /* Notification Indicator */ +} SiNotifInd; + +typedef struct genNum /* Generic Number */ +{ + u8 pres; /* element header */ + u8 nmbQual; /* number qualifier */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 scrnInd; /* screen indicator */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 niInd; /* number incomplete indicator */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ + +} SiGenNum; + +typedef struct sihopCounter /* Hop counter */ +{ + u8 pres; /* element header */ + u8 hopCounter; /* presentation */ +} SiHopCounter; + +typedef struct infoInd /* Information Indicators */ +{ + u8 pres; /* element header */ + u8 cgPtyAddrRespInd; /* calling party address response ind. */ + u8 holdProvInd; /* hold provided indicator */ + u8 cgPtyCatRespInd; /* calling party category response ind. */ + u8 chrgInfoRespInd; /* charge information response indicator */ + u8 solInfoInd; /* solicitation information indicator */ + u8 spare; /* spare (insure we get second octet) */ +} SiInfoInd; + +typedef struct infoReqInd /* Information Request Indicators */ +{ + u8 pres; /* element header */ + u8 cgPtyAdReqInd; /* calling party address request ind. */ + u8 holdingInd; /* holding indicator */ + u8 cgPtyCatReqInd; /* calling party category request ind. */ + u8 chrgInfoReqInd; /* charge information request indicator */ + u8 malCaIdReqInd; /* malicious call id request indicator */ + u8 spare; /* spare (insure second octet...) */ +} SiInfoReqInd; + +typedef struct mcidRspInd /* MCID response indicators */ +{ + u8 pres; /* element header */ + u8 rspInd; /* mcid response indicators */ + u8 hldInd; /* hold indicators */ +} SiMcidRspInd; + +typedef struct mcidReqInd /* MCID request indicators */ +{ + u8 pres; /* element header */ + u8 reqInd; /* mcid request indicators */ + u8 hldInd; /* hold indicators */ +} SiMcidReqInd; + +typedef struct msgCompInfo /* message compatibility information */ +{ + u8 pres; /* element header */ + u8 tranXInd; /* transit exchange indicator */ + u8 relCllInd; /* release call indicator */ + u8 sndNotInd; /* send notification indicator */ + u8 dcrdMsgInd; /* discard message indicator */ + u8 passNotPoss; /* pass on not possible indicator */ + u8 bbNbIntwkI; /* broadband n/w interworking indicator */ + u8 tranXInd1; /* transit exchange indicator */ + u8 relCllInd1; /* release call indicator */ + u8 sndNotInd1; /* send notification indicator */ + u8 dcrdMsgInd1; /* discard message indicator */ + u8 passNotPoss1; /* pass on not possible indicator */ + u8 bbNbIntwkI1; /* broadband n/w interworking indicator */ +} SiMsgCompInfo; + +typedef struct mlppPrec /* MLPP precedence */ +{ + u8 pres; /* element header */ + u8 precdLvl; /* precedence level */ + u8 lfb; /* LFB */ + u8 frstDig; /* first digit */ + u8 scndDig; /* second digit */ + u8 thrdDig; /* third digit */ + u8 frthDig; /* fourth digit */ + u32 servDomain; /* service domain */ +} SiMlppPrec; + +typedef struct natConInd /* Nature of Connection Indicator */ +{ + u8 pres; /* element header */ + u8 satInd; /* Satellite Indicator */ + u8 contChkInd; /* continuity check indicator */ + u8 echoCntrlDevInd; /* echo control device indicator */ +} SiNatConInd; + +typedef struct netFacSpecFacil /* network specific facility */ +{ + u8 pres; /* element header */ + u8 length; + u8 netFac[MAX_ISUP_MSG_LEN]; /* network facility1 */ +} SiNetSpecFacil; + +typedef struct optBckCalInd /* Optional Backward Call Indicators */ +{ + u8 pres; /* element header */ + u8 inbndInfoInd; /* in-band information indicator */ + u8 caFwdMayOcc; /* call forwarding may occur indicator */ + u8 simpleSegmInd; /* Simple segmentation indicator */ + u8 mlppUserInd; /* MLPP User indicator */ +} SiOptBckCalInd; + +typedef struct opFwdCalInd /* Optional Forward Call Indicators */ +{ + u8 pres; /* element header */ + u8 clsdUGrpCaInd; /* closed user group call indicator */ + u8 simpleSegmInd; /* Simple segmentation indicator */ + u8 conLineIdReqInd; /* Connected line identity request ind */ +} SiOpFwdCalInd; + +typedef struct origCdNum /* Original Called Number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ + +} SiOrigCdNum; + +typedef struct sisigPointCode /* Signalling Point Code */ +{ + u8 pres; /* element header */ + u16 sigPointCode; /* signalling point code */ +} SiSigPointCode; + +typedef struct parmCompInfo /* parameter compatibility information */ +{ + u8 pres; /* element header */ + u8 length; + u8 content[MAX_ISUP_MSG_LEN]; /* content. */ + + //u8 upgrPar1; /* upgraded parm 1 */ + //u8 tranXInd1; /* transit exchange indicator */ + //u8 relCllInd1; /* release call indicator */ + //u8 sndNotInd1; /* send notification indicator */ + //u8 dcrdMsgInd1; /* discard message indicator */ + //u8 dcrdParInd1; /* discard parameter indicator */ + + //u8 pBbNbIntwkI1; /* broadband network interworking indicator */ + //u8* addInstInd1; /* additional instruction indicator */ + //u8 upgrPar2; /* upgraded parm 2 */ + //u8 tranXInd2; /* transit exchange indicator */ + //u8 relCllInd2; /* release call indicator */ + //u8 sndNotInd2; /* send notification indicator */ + //u8 dcrdMsgInd2; /* discard message indicator */ + //u8 dcrdParInd2; /* discard parameter indicator */ +} SiParmCompInfo; + +typedef struct rangStat /* Range and Status */ +{ + u8 pres; /* element header */ + u8 range; /* range */ + u8 status[ISUP_STATUS_LEN]; /* status */ +} SiRangStat; + +typedef struct rangNoStat /* Range and Status */ +{ + u8 pres; /* element header */ + u8 range; /* range */ +} SiRangNoStat; + +typedef struct redirInfo /* Redirection Information */ +{ + u8 pres; /* element header */ + u8 redirInd; /* redirection indicator */ + u8 origRedirReas; /* original redirection reason */ + u8 redirCnt; /* redirection count */ + u8 redirReas; /* redirection reason */ +} SiRedirInfo; + +typedef struct redirNum /* Redirecting Number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ +// u8 scrInd; /* screening indicator */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ + +} SiRedirNum; + +typedef struct redirRstr /* redirection restriction */ +{ + u8 pres; /* element header */ + u8 presRest; /* presentation restriction */ +} SiRedirRestr; + +typedef struct remotOper /* remote operations */ +{ + u8 pres; /* element header */ + u8 length; /* protocol profile */ + u8 content[MAX_ISUP_MSG_LEN]; /* components */ +} SiRemotOper; + +typedef struct siserviceAct /* Service Activation */ +{ + u8 pres; /* element header */ + u8 length; + u8 serviceAct[MAX_ISUP_MSG_LEN]; /* service activation */ +} SiServiceAct; + +typedef struct subNum /* Subsequent Number */ +{ + u8 pres; /* element header */ + u8 oddEven; /* odd or even */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ + +} SiSubNum; + +typedef struct sisusResInd /* Suspend/Resume indicators */ +{ + u8 pres; /* element header */ + u8 susResInd; /* suspend/resume indicators */ +} SiSusResInd; + +typedef struct tranNetSel /* Transit Network Selection */ +{ + u8 pres; /* element header */ + u8 netIdPln; /* network id plan */ + u8 typNetId; /* type of network identification */ + u8 oddEven; /* odd/even */ + u8 numOfDigit; + u8 netId[MAX_ISUP_DIGIT]; /* network identification */ +} SiTranNetSel; + +typedef struct txMedReq /* Transmission Medium Requirement */ +{ + u8 pres; /* element header */ + u8 trMedReq; /* tranmission medium requirement */ +} SiTxMedReq; + +typedef struct usrServInfo /* User Service Information */ +{ + u8 pres; /* element header */ + u8 length; + u8 content[MAX_ISUP_MSG_LEN]; /* content. */ + //u8 infoTranCap; /* information transfer capability */ + //u8 cdeStand; /* coding standard */ + //u8 infoTranRate0; /* information transfer rate */ + //u8 tranMode; /* transfer mode */ + //u8 establish; /* establishment */ + //u8 config; /* configuration */ + //u8 chanStruct; /* structure */ + //u8 infoTranRate1; /* information transfer rate */ + //u8 symmetry; /* symmetry */ + //u8 rateMultiplier; /* rate multiplier */ + //u8 usrInfLyr1Prot; /* usr information layer 1 protocol */ + //u8 lyr1Ident; /* layer 1 identity */ + //u8 usrRate; /* user rate */ + //u8 negot; /* negotiation */ + //u8 syncAsync; /* synchronous/asynchronous */ + //u8 flcOnRx; /* flow control on reception */ + //u8 flcOnTx; /* flow control on transmission */ + //u8 niClkOnRx; /* network independent clock on reception */ + //u8 niClkOnTx; /* network independent clock on transmission*/ + //u8 interRate; /* intermediate rate */ + //u8 inOutBandNeg; /* inband/outband negotiation */ + //u8 asgnrAsgne; /* assignor/assignee */ + //u8 logLnkNegot; /* logical link identifier negotiation */ + //u8 mode; /* mode of operation */ + //u8 multiFrm; /* multiple frame establishment support */ + //u8 hdrNohdr; /* rate adaption header/no header */ + //u8 parity; /* parity information */ + //u8 nmbDatBits; /* number of data bits excluding parity bit */ + //u8 nmbStpBits; /* number of stop bits */ + //u8 modemType; /* modem type */ + //u8 duplexMode; /* duplex mode */ + //u8 usrInfLyr2Prot; /* user information layer 2 protocol */ + //u8 lyr2Ident; /* layer 2 identity */ + //u8 usrInfLyr3Prot; /* user information layer 3 protocol */ + //u8 lyr3Ident; /* layer 3 identity */ +} SiUsrServInfo; + +typedef struct usrTSrvInfo /* User Teleservice Information */ +{ + u8 pres; /* element header */ + u8 length; + u8 content[MAX_ISUP_MSG_LEN]; /* content. */ + //u8 presMeth; /* presentation method */ + //u8 interp; /* interpretation indicator */ + //u8 codeStd; /* coding standard */ + //u8 highLyr; /* high layer characteristics id */ + //u8 extHighLyr; /* extended high layer chars id */ +} SiUsrTSrvInfo; + +typedef struct usr2UsrInd /* User to User indicators */ +{ + u8 pres; /* element header */ + u8 type; /* type */ + u8 serv1; /* service 1 */ + u8 serv2; /* service 2 */ + u8 serv3; /* service 3 */ + u8 spare; /* bit H (to be filled in both cases) */ +} SiUsr2UsrInd; + +typedef struct usr2UsrInfo /* User to user information */ +{ + u8 pres; /* element header */ + u8 length; + u8 info[MAX_ISUP_MSG_LEN]; /* user to user information */ +} SiUsr2UsrInfo; + +typedef struct sipassAlng /* Pass Along */ +{ + u8 pres; /* element header */ + u8 length; + u8 passAlng[MAX_ISUP_MSG_LEN]; /* pass along */ +} SiPassAlng; + +// (SS7_ITU97 || SS7_ETSIV3) +typedef struct confTrtInd /* conference treatment indicators */ +{ + u8 pres; /* element header */ + u8 confAcceptInd; /* conference acceptance indicators */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiConfTrtInd; + +typedef struct uidActionInd /* UID action indicator */ +{ + u8 pres; /* element header */ + u8 throughConnInstInd; /* Through connection instruction ind. */ + u8 t9InstInd; /* T9 instruction ind. */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiUidActionInd; + +typedef struct backGVNS /* backward GVNS */ +{ + u8 pres; /* element header */ + u8 termAccessInd; /* terminating access indicator */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiBackGVNS; + +typedef struct sidisplayInfo /* display information */ +{ + u8 pres; /* element header */ + u8 length; + u8 displayInfo[MAX_ISUP_MSG_LEN]; /* display information */ +} SiDisplayInfo; + +typedef struct forwardGVNS /* forward GVNS */ +{ + u8 pres; /* element header */ + u8 lenInd1; /* length indicator */ + u8 oddEven1; /* odd or even address signal */ + u8 numOfDigit1; + u8 digits1[8]; /* digits */ + u8 lenInd2; /* length indicator */ + u8 oddEven2; /* odd or even address signal */ + u8 numOfDigit2; + u8 digits2[16]; /* digits */ + u8 lenInd3; /* length indicator */ + u8 oddEven3; /* odd or even address signal */ + u8 numPlan; /* numbering plan */ + u8 natOfAddr; /* nature of address */ + u8 numOfDigit3; + u8 digits3[16]; /* digits */ +} SiForwardGVNS; + +typedef struct ccss /* CCSS */ +{ + u8 pres; /* element header */ + u8 ccssCallInd; /* CCSS call indicator */ +} SiCcss; + +typedef struct netMgmtControls /* network management controls */ +{ + u8 pres; /* element header */ + u8 tmpAltRoutInd; /* tmp alternative routing Ind. */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiNetMgmtControls; + +typedef struct cirAsgnMap /* circuit assignment map */ +{ + u8 pres; /* element header */ + u8 mapType; /* map type */ + u8 mapFormat[4]; /* map format */ +} SiCirAsgnMap; + +typedef struct sicorrelationId /* correlation Id */ +{ + u8 pres; /* element header */ + u8 length; + u8 correlationId[MAX_ISUP_MSG_LEN]; /* correlation Id */ +} SiCorrelationId; + +typedef struct callDivTrtInd /* call diversion treatment indicators */ +{ + u8 pres; /* element header */ + u8 callDivInd; /* call to be diverted indicator */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiCallDivTrtInd; + +typedef struct callInNmb /* call IN number */ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ +} SiCallInNmb; + +typedef struct callOfferTrtInd /* call offering treatment indicators */ +{ + u8 pres; /* element header */ + u8 callOfferInd; /* call to be offered indicator */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiCallOfferTrtInd; + +typedef struct siscfId /* SCF Id */ +{ + u8 pres; /* element header */ + u8 length; + u8 scfId[MAX_ISUP_MSG_LEN]; /* SCF Id */ +} SiScfId; + +typedef struct uidCapInd /* UID capability indicator */ +{ + u8 pres; /* element header */ + u8 throughConnInstInd; /* Through connection instruction ind. */ + u8 t9InstInd; /* T9 instruction ind. */ + u8 length; + u8 extInfo[MAX_ISUP_MSG_LEN]; /* Extension Info */ +} SiUidCapInd; + +typedef struct collCallReq /* collect call request */ +{ + u8 pres; /* element header */ + u8 collCallReqInd; /* collect call req. indicator */ +} SiCollCallReq; + +typedef struct naPaChgPID /* National Parameter ChgPID */ +{ + u8 pres; /* element header */ + u8 length; + u8 naPaChgPtyId[MAX_ISUP_MSG_LEN]; /* charged party identification */ +} SiNaPaChgPID; + +typedef struct callTRef /* Call Transfer Reference */ +{ + u8 pres; /* element header */ + u8 callTrnsfr; /* call transfer reference */ +} SiCallTRef; + +typedef struct loopPrvntInd /* loop prevention indicator */ +{ + u8 pres; /* element header */ + u8 loopPrvntType; /* loop prevention type */ + u8 loopPrvntRspInd; /* loop prevention response indicator */ +} SiLoopPrvntInd; + +typedef struct appTransParam /* application transport parameter */ +{ + u8 pres; /* element header */ + u8 appContextId; /* application context identifier */ + u8 atii; /* application transport inst. ind. */ + u8 apmSegInd; /* APM segmentation indicator */ + u8 seqInd; /* sequence indicator */ + u8 slr; /* segmentation local reference */ + u8 length; + u8 encapAppInfo[MAX_ISUP_MSG_LEN]; /* encapsulated application info */ +} SiAppTransParam; + + +/* Information Element code for UK specific */ +typedef struct natForCalInd /* National Forward Call Indicators */ +{ + u8 pres; /* element header */ + u8 cbi; /* CLI Blocking Indicator (CBI) */ + u8 ntaInd; /* Network translated address indicator */ +} SiNatForCalInd; + +typedef struct natForCalIndLbL /* National Forward Call Indicators (Link by link)*/ +{ + u8 pres; /* element header */ + u8 rci; /* Routing Control Indicator */ + u8 isi; /* Interconnect Specific Information */ +} SiNatForCalIndLbL; + +typedef struct presNum /* Presentation Number*/ +{ + u8 pres; /* element header */ + u8 natAddrInd; /* nature of addresss indicator */ + u8 oddEven; /* odd or even */ + u8 scrInd; /* screening indicator */ + u8 presRest; /* Address presentation restricted ind. */ + u8 numPlan; /* numbering plan */ + u8 pnp; /* Presentation Number Preference indicator */ + u8 numOfDigit; + u8 addrSig[MAX_ISUP_DIGIT]; /* Address Signal */ +}SiPresNum; + +//SiLasDivLinId==SiCgPtyNum /* Last Diverting Line Identity*/ + +typedef struct partCLI /* Partial CLI */ +{ + u8 pres; /* element header */ + u8 swichTypeD1; /* Type of Switch */ + u8 swichTypeD2; /* Type of Switch */ + u8 pnoIdD1; /* PNO Identity */ + u8 pnoIdD2; /* PNO Identity */ + u8 pnoIdD3; /* PNO Identity */ + u8 switchNumD1; /* Switch number */ + u8 switchNumD2; /* Switch number */ + u8 switchNumD3; /* Switch number */ + u8 agreement[5]; /* For bilateral agreement */ +}SiPartCLI; + +typedef struct caldSubBasSerMar /* Called Subscribers Basic Service Marks */ +{ + u8 pres; /* element header */ + u8 cbInd; /* Admin./Maintenance Call Barring Indicator */ + u8 subIcbInd; /* Subscriber Controlled Incoming Calls Barred (ICB) Indicator */ + u8 preIcbInd; /* Pre-arranged ICB Indicator */ + u8 permIcbInd; /* Permanent ICB Indicator */ + u8 tosInd; /* Temporary Out of Service (TOS) Indicator */ + u8 ICBExpInd; /* ICB Except for Operator Indicator */ + u8 caldSubFacInfInd; /* Called Subscriber Facility Information Indicator */ + u8 calgSubFacInfInd; /* Calling Subscriber Facility Information Indicator */ + u8 permOcbInd; /* Permanent Outgoing Calls Barred (OCB) Indicator */ + u8 ogLocCalBarInd; /* Outgoing Local Calls Barred Indicator */ + u8 ogNatCalBarInd; /* Outgoing National Calls Barred Indicator */ + u8 ogIntCalBarInd; /* Outgoing International Calls Barred Indicator */ + u8 opCalBarInd; /* Operator Calls Barred Indicator */ + u8 supFacCalBarInd; /* Supplementary Facility Calls Barred Indicator */ + u8 digMaskInd; /* Digit Masking Indicator */ + u8 calPreBarInd; /* Calls to Premium-phones Barred Indicator */ + u8 caldSubTarGp; /* Called Subscriber's Tariff Group */ +}SiCaldSubBasSerMar; + + +typedef struct calgSubBasSerMar /* Calling Subscribers Basic Service Marks */ +{ + u8 pres; /* element header */ + u8 cbInd; /* Admin./Maintenance Call Barring Indicator */ + u8 subIcbInd; /* Subscriber Controlled Incoming Calls Barred (ICB) Indicator */ + u8 preIcbInd; /* Pre-arranged ICB Indicator */ + u8 permIcbInd; /* Permanent ICB Indicator */ + u8 tosInd; /* Temporary Out of Service (TOS) Indicator */ + u8 ICBExpInd; /* ICB Except for Operator Indicator */ + u8 caldSubFacInfInd; /* Called Subscriber Facility Information Indicator */ + u8 calgSubFacInfInd; /* Calling Subscriber Facility Information Indicator */ + u8 permOcbInd; /* Permanent Outgoing Calls Barred (OCB) Indicator */ + u8 ogLocCalBarInd; /* Outgoing Local Calls Barred Indicator */ + u8 ogNatCalBarInd; /* Outgoing National Calls Barred Indicator */ + u8 ogIntCalBarInd; /* Outgoing International Calls Barred Indicator */ + u8 opCalBarInd; /* Operator Calls Barred Indicator */ + u8 supFacCalBarInd; /* Supplementary Facility Calls Barred Indicator */ + u8 digMaskInd; /* Digit Masking Indicator */ + u8 calPreBarInd; /* Calls to Premium-phones Barred Indicator */ + u8 calgSubTarGp; /* Calling Subscriber's Tariff Group */ + u8 opInd; /* Operator Indicator */ +}SiCalgSubBasSerMar; + + +typedef struct calgSubOrgFacMar /* Calling Subscribers Originating Facility Marks */ +{ + u8 pres; /* element header */ + u8 disSubInd; /* Disabled Subscriber Indicator */ + u8 attCOI; /* Attended Call Office Indicator */ + u8 adDurChgInd; /* Advise Duration and Charge (AD&C) Indicator */ + u8 PBXSubInd; /* PBX Subscriber Indicator */ +}SiCalgSubOrgFacMar; + + +typedef struct caldSubTermFacMar /* Called Subscribers Terminating Facility Marks */ +{ + u8 pres; /* element header */ + u8 sviInd; /*SVI Indicator */ + u8 cniInd; /* CNI Indicator */ + u8 pbxNigIntInd; /* PBX Night Interception Indicator */ + u8 calWaitInd; /* Call Waiting Indicator */ + u8 fixedDestSerInd; /* Fixed Destination Service Indicator */ +}SiCaldSubTermFacMar; + + +typedef struct natInfReqInd /* National Information Request Indicators */ +{ + u8 pres; /* element header */ + u8 calgSubBasSerMarReqInd; /* Calling Subscriber's Basic Service Marks request indicator */ + u8 caldSubBasSerMarReqInd; /* Called Subscriber’s Basic Service Marks request indicator */ + u8 calgSubOrgFacMarReqInd; /* Calling Subscriber's Originating Facility Marks request indicator */ + u8 caldSubTerFacMarReqInd; /* Called Subscriber's Terminating Facility Marks request indicator */ +}SiNatInfReqInd; + + +typedef struct natInfInd /* National Information Indicators */ +{ + u8 pres; /* element header */ + u8 calgSubBasSerMarRespInd; /* Calling Subscriber's Basic Service Marks response indicator */ + u8 caldSubBasSerMarRespInd; /* Called Subscriber’s Basic Service Marks response indicator */ + u8 calgSubOrgFacMarRespInd; /* Calling Subscriber's Originating Facility Marks response indicator */ + u8 caldSubTerFacMarRespInd; /* Called Subscriber's Terminating Facility Marks response indicator */ +}SiNatInfInd; + + +typedef struct sicirValRspInd /* Circuit validation response indicator */ +{ + u8 pres; /* element header */ + u8 cirValRspInd; /* Circuit validation response indicator */ +} SiCirValRspInd; + +typedef struct cirGrpCharInd /* Circuit group characteristic indicators */ +{ + u8 pres; /* element header */ + u8 cirGrpCarInd; /* circuit group carrier indicator */ + u8 dblSzCtrlInd; /* double seizing control indicator */ + u8 alarmCarInd; /* alarm carrier indicator */ + u8 contChkReqInd; /* continuity check requirements indicator */ +} SiCirGrpCharInd; + +typedef struct cirIdName /* Circuit ID Name */ +{ + u8 pres; /* element header */ + u8 trunkNumClli[26]; /* trunk number and clli code */ +} SiCirIdName; + +typedef struct clli /* Common Language Location Idenification */ +{ + u8 pres; /* element header */ + u8 clliCode[11]; /* clli codes */ +} SiCLLI; + + +//**********************************************/ +//* Message Structure (Q.763) +//**********************************************/ +typedef struct siPduACM /* Address Complete message */ +{ + SiBckCalInd bckCalInd; /* backward call indicators */ + SiOptBckCalInd optBckCalInd; /* optional backward call indicators */ + SiCallRef callRef; /* call reference */ + SiCauseDgn causeDgn; /* cause indicators */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiAccTrnspt accTrans; /* access transport */ + SiNotifInd notifInd1; /* notification indicator */ +// SiNotifInd notifIndR1; /* notification ind (repeated - ITU97/92) */ + SiTxMedReq txMedUsed; /* transmission medium used */ + SiEchoCtl echoControl; /* echo control */ + SiAccDelInfo accDelInfo; /* access delivery information */ + SiCdPtyNum redirNum; /* redirection number */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiCllDiverInfo cllDivr; /* call Diversion information */ + SiNetSpecFacil netFac; /* network specific facility */ + SiRemotOper remotOper; /* remote operations */ + SiServiceAct serviceAct; /* service activation */ + SiRedirRestr redirRstr; /* redirection restriction */ +// (SS7_ITU97 || SS7_ETSIV3) + SiConfTrtInd confTrtInd; /* confrence treatment indicators */ + SiUidActionInd uidActionInd; /* UID action indicator */ +//UK specific + SiCaldSubBasSerMar caldSubBasSerMar; + SiEndOp endOp; /* end of optional parameters */ +} SiPduACM; + +typedef struct siPduANM /* Answer */ +{ + SiBckCalInd bckCalInd; /* backward call indicators */ + SiOptBckCalInd optBckCalInd; /* optional backward call indicators */ + SiCallRef callRef; /* call reference */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiConnectedNum connNum; /* connected number */ + SiAccTrnspt accTrans; /* access transport */ + SiAccDelInfo accDelInfo; /* access delivery information */ + SiNotifInd notifInd1; /* notification indicator */ +// SiNotifInd notifIndR1; /* notification ind (repeated - ITU97/92) */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiPropDly cllHstry; /* call history information */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ + SiTxMedReq txMedUsed; /* transmission medium used */ + SiNetSpecFacil netFac; /* network specific facility */ + SiRemotOper remotOper; /* remote operations */ + SiCdPtyNum redirNum; /* redirection number */ + SiServiceAct serviceAct; /* service activation */ + SiEchoCtl echoControl; /* echo control */ + SiRedirRestr redirRstr; /* redirection restriction */ +// SS7_ITU97 + SiBackGVNS backGVNS; /* backward GVNS */ + SiDisplayInfo displayInfo; /* display information */ +//UK specific + SiCaldSubBasSerMar caldSubBasSerMar; + SiEndOp endOp; /* end of optional parameters */ +} SiPduANM; + +typedef struct siPduCPG /* Call Progress */ +{ + SiEvntInfo evntInfo; /* event information */ + SiCauseDgn causeDgn; /* cause indicators */ + SiCallRef callRef; /* call reference */ + SiBckCalInd bckCalInd; /* backward call indicators */ + SiOptBckCalInd optBckCalInd; /* optional backward call indicators */ + SiAccTrnspt accTrans; /* access transport */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ + SiNotifInd notifInd1; /* notification indicator */ +// SiNotifInd notifIndR1; /* notification ind (repeated - ITU97/92) */ + SiNetSpecFacil netFac; /* network specific facility */ + SiRemotOper remotOper; /* remote operations */ + SiTxMedReq txMedUsed; /* transmission medium used */ + SiAccDelInfo accDelInfo; /* access delivery information */ + SiCdPtyNum redirNum; /* redirection number */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiCllDiverInfo cllDivr; /* call Diversion information */ + SiServiceAct serviceAct; /* service activation */ + SiRedirRestr redirRstr; /* redirection restriction */ +// (SS7_ETSIV3 || SS7_ITU97) + SiCgPtyNum calTrnsNmb; /* Call Transfer Number */ + SiEchoCtl echoControl; /* echo control */ + SiConnectedNum connNum; /* connected number */ + SiBackGVNS backGVNS; /* backward GVNS */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ + SiPropDly cllHstry; /* call history information */ + SiConfTrtInd confTrtInd; /* confrence treatment indicators */ + SiUidActionInd uidActionInd; /* UID action indicator */ + //UK specific + SiCaldSubBasSerMar caldSubBasSerMar; + SiEndOp endOp; /* end of optional parameters */ +} SiPduCPG; + +typedef struct siPduCGB /* Circuit Group Blocking */ +{ + SiCirGrpSupMTypInd cgsmti; /* circuit grp. Supervision Msg. Type Ind. */ + SiRangStat rangStat; /* range and status */ +} SiPduCGB; + +typedef struct siPduCGBA /* Circuit Group Blocking Ack. */ +{ + SiCirGrpSupMTypInd cgsmti; /* circuit grp. Supervision Msg. Type Ind. */ + SiRangStat rangStat; /* range and status */ +} SiPduCGBA; + +typedef struct siPduCQM /* Circuit Group Query */ +{ + SiRangNoStat rangNoStat; /* range and status */ +} SiPduCQM; + +typedef struct siPduCQR /* Circuit Group Query Response */ +{ + SiRangNoStat rangNoStat; /* range and status */ + SiCirStateInd cirSteInd; /* Circuit State Indicators */ +} SiPduCQR; + +typedef struct siPduGRS /* Circuit Group Reset */ +{ + SiRangNoStat rangNoStat; /* range and status */ +} SiPduGRS; + +typedef struct siPduGRA /* Circuit Group Reset Acknowledgement */ +{ + SiRangStat rangStat; /* range and status */ +} SiPduGRA; + +typedef struct siPduCGU /* Circuit Group Unblocking */ +{ + SiCirGrpSupMTypInd cgsmti; /* circuit grp. supervision msg. type ind. */ + SiRangStat rangStat; /* range and status */ +} SiPduCGU; + +typedef struct siPduCGUA /* Circuit Group Unblocking Acknowledgement */ +{ + SiCirGrpSupMTypInd cgsmti; /* circuit grp. supervision msg. type ind. */ + SiRangStat rangStat; /* range and status */ +} SiPduCGUA; + +typedef struct siPduCFN /* Confusion */ +{ + SiCauseDgn causeDgn; /* cause indicators */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduCFN; + +typedef struct siPduCON /* Connect */ +{ + SiBckCalInd bckCalInd; /* backward call indicators */ + SiOptBckCalInd optBckCalInd; /* optional backward call indicators */ + SiConnectedNum connNum; /* connected number */ + SiCallRef callRef; /* call reference */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiAccTrnspt accTrans; /* access transport */ + SiNetSpecFacil netFac; /* network specific facility */ + SiNotifInd notifInd; /* notification indicator */ +// SiNotifInd notifIndR; /* notification ind (repeated - ITU97/92) */ + SiRemotOper remotOper; /* remote operations */ + SiTxMedReq txMedUsed; /* transmission medium used */ + SiEchoCtl echoControl; /* echo control */ + SiAccDelInfo accDelInfo; /* access delivery information */ + SiPropDly cllHstry; /* call history information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiCdPtyNum redirNum; /* redirection number */ + SiServiceAct serviceAct; /* service activation */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ + SiRedirRestr redirRstr; /* redirection restriction */ +// SS7_ITU97 + SiBackGVNS backGVNS; /* backward GVNS */ + SiConfTrtInd confTrtInd; /* confrence treatment indicators */ + //UK specific + SiCaldSubBasSerMar caldSubBasSerMar; + SiEndOp endOp; /* end of optional parameters */ +} SiPduCON; + +typedef struct siPduCOT /* Continuity */ +{ + SiContInd contInd; /* continuity indicator */ +} SiPduCOT; + +typedef struct siPduFAA /* Facility Accepted */ +{ + SiFacInd facInd; /* facility indicator */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicator */ + SiCallRef callRef; /* call reference */ + SiConnReq connReq; /* connection request */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduFAA; + +typedef struct siPduFRJ /* Facility Rejected */ +{ + SiFacInd facInd; /* facility indicator */ + SiCauseDgn causeDgn; /* cause indicator */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicator */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduFRJ; + +typedef struct siPduFAR /* Facility Request */ +{ + SiFacInd facInd; /* facility indicator */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicator */ + SiCallRef callRef; /* call reference */ + SiConnReq connReq; /* connection request */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduFAR; + +typedef struct siPduFOT /* Forward Transfer */ +{ + SiCallRef callRef; /* call reference */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduFOT; + +typedef struct siPduINF /* Information */ +{ + SiInfoInd infoInd; /* information indicators */ + SiCgPtyCat cgPtyCat; /* calling party category */ + SiCgPtyNum cgPtyNum; /* calling party number */ + SiCallRef callRef; /* call reference */ + SiConnReq connReq; /* connection request */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiNetSpecFacil netFac; /* network specific facility */ + //UK specific + SiNatInfInd natInfInd; + SiCaldSubBasSerMar caldSubBasSerMar; + SiCalgSubBasSerMar calgSubBasSerMar; + SiCalgSubOrgFacMar calgSubOrgFacMar; + SiCaldSubTermFacMar caldSubTermFacMar; + SiEndOp endOp; /* end of optional parameters */ +} SiPduINF; + +typedef struct siPduINR /* Information Request */ +{ + SiInfoReqInd infoReqInd; /* information request indicators */ + SiCallRef callRef; /* call reference */ + SiNetSpecFacil netFac; /* network specific facility */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + //UK specific + SiNatInfReqInd natInfReqInd; + SiEndOp endOp; /* end of optional parameters */ +} SiPduINR; + +typedef struct siPduIAM /* Initial Address */ +{ + SiNatConInd natConInd; /* Nature of connection indicators */ + SiFwdCallInd fwdCallInd; /* forward call indicators */ + SiCgPtyCat cgPtyCat; /* calling party category */ + SiTxMedReq txMedReq; /* transmission medium requirement */ + SiCdPtyNum cdPtyNum; /* called party number */ + SiTranNetSel tranNetSel; /* transit network selection */ + SiCallRef callRef; /* call reference */ + SiCgPtyNum cgPtyNum; /* calling party number */ + SiOpFwdCalInd opFwdCalInd; /* optional forward call indicators */ + SiRedirNum redirgNum; /* redirecting number */ + SiRedirInfo redirInfo; /* redirection information */ + SiCugIntCode cugIntCode; /* closed group interlock code */ + SiConnReq connReq; /* connection request */ + SiOrigCdNum origCdNum; /* original called number */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiAccTrnspt accTrans; /* access transport */ + SiUsrServInfo usrServInfo; /* user service info */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ + SiPropDly propDly; /* propagation delay counter */ + SiUsrServInfo usrServInfo1; /* user service info prime */ + SiNetSpecFacil netFac; /* network specific facility */ + SiGenDigits genDigits; /* generic digits */ +// SiGenDigits genDigitsR; /* generic digits (repeated -ANSI95,ITU97/92) */ + SiSigPointCode orgPteCde; /* originating ISC point code */ + SiUsrTSrvInfo usrTSrvInfo; /* user tele service info */ + SiRemotOper remotOper; /* remote operations */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiNotifInd notifInd; /* notification indicator */ +// SiNotifInd notifIndR; /* notification ind (repeated - ITU97/92) */ + SiServiceAct serviceAct; /* service activation */ + SiMlppPrec mlppPrec; /* MLPP precedence */ + SiTxMedReq txMedUsPr; /* Transmission medium requirement prime */ + SiCgPtyNum cgPtyNum1; /* location number or calling party number */ + +// SS7_ITU97 + SiForwardGVNS forwardGVNS; /* forward GVNS */ + SiCcss ccss; /* CCSS */ + SiNetMgmtControls netMgmtControls; /* network management controls */ + SiCirAsgnMap cirAsgnMap; /* circuit assignment map */ + SiCorrelationId correlationId;/* correlation Id */ + SiCallDivTrtInd callDivTrtInd;/* call diversion treatment indicators */ + SiCallInNmb callInNmb; /* call IN number */ + SiCallOfferTrtInd callOfferTrtInd;/* call offering treatment ind */ + SiConfTrtInd confTrtInd; /* confrence treatment indicators */ + SiScfId scfId; /* SCF Id */ + SiUidCapInd uidCapInd; /* UID capability indicator */ + SiEchoCtl echoControl; /* echo control */ + SiHopCounter hopCounter; /* hop counter */ + SiCollCallReq collCallReq; /* collect call request */ + //UK specific + SiNatForCalInd natForCalInd; + SiPresNum presNum; + SiCgPtyNum lasDivLinId; + SiPartCLI partCLI; + SiNatForCalIndLbL natForCalIndLbL; + SiEndOp endOp; /* end of optional parameters */ +} SiPduIAM; + +typedef struct siPduPAM /* Pass Along */ +{ + SiPassAlng passAlng; /* pass along */ +} SiPduPAM; + +typedef struct siPduREL /* Release */ +{ + SiCauseDgn causeDgn; /* cause indicators */ + SiRedirInfo redirInfo; /* redirection information */ + SiCdPtyNum redirNum; /* redirection number */ + SiAccTrnspt accTrans; /* access transport */ + SiSigPointCode sigPointCode; /* Signalling point code */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiAutoCongLvl auCongLvl; /* automatic congestion level */ + SiNetSpecFacil netFac; /* network specific facility */ + SiAccDelInfo accDelInfo; /* access delivery information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiRedirRestr redirRstr; /* redirection restriction */ + SiUsr2UsrInd usr2UsrInd; /* user to user indicators */ +// (SS7_ITU97 || SS7_ETSIV3) + SiDisplayInfo displayInfo; /* display information */ + SiRemotOper remotOper; /* remote operations */ + + + + SiEndOp endOp; /* end of optional parameters */ +} SiPduREL; + +typedef struct siPduRLC /* Release Complete */ +{ + SiCauseDgn causeDgn; /* cause indicators */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduRLC; + +typedef struct siPduRES /* Resume */ +{ + SiSusResInd suspResInd; /* Suspend/Resume indicators */ + SiCallRef callRef; /* call reference */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduRES; + +typedef struct siPduSAM /* Subsequent Address */ +{ + SiSubNum subNum; /* subsequent number */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduSAM; + +typedef struct siPduSUS /* Suspend */ +{ + SiSusResInd suspResInd; /* Suspend/Resume indicators */ + SiCallRef callRef; /* call reference */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduSUS; + +typedef struct siPduUSR /* User to User */ +{ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiAccTrnspt accTrans; /* access transport */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduUSR; + +typedef struct siPduFAC /* Facility Message */ +{ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiRemotOper remotOper; /* remote operations */ + SiServiceAct serviceAct; /* service activation */ +//(SS7_ETSI SS7_ITU97 || SS7_ETSIV3) + SiCgPtyNum calTrnsNmb; /* Call Transfer Number */ + SiAccTrnspt accTrans; /* access transport */ + SiNotifInd notifInd; /* notification indicator */ + + + SiEndOp endOp; /* end of optional parameters */ +} SiPduFAC; + +typedef struct siPduUPAT /* User Part Test/Available */ +{ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduUPAT; + +typedef struct siPduNRM /* Network Resource Mgt */ +{ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiTxMedReq txMedUsed; /* transmission medium used */ + SiEchoCtl echoControl; /* echo control */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduNRM; + +typedef struct siPduIDR /* Identification Request */ +{ + SiMcidReqInd mcidReq; /* MCID request indicators */ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduIDR; + +typedef struct siPduIRS /* Identification Response */ +{ + SiMcidRspInd mcidRsp; /* MCID response indicators */ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiCgPtyNum cgPtyNum; /* calling party number */ + SiAccTrnspt accTrans; /* access transport */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ +// ( SS7_ITU97 || SS7_ETSIV3) + SiNaPaChgPID naPaChgPID; /* National Parameter for charged party ID*/ + + SiEndOp endOp; /* end of optional parameters */ +} SiPduIRS; + +typedef struct siPduSGM /* segmentation Msg. */ +{ + SiAccTrnspt accTrans; /* access transport */ + SiUsr2UsrInfo usr2UsrInfo; /* user to user information */ + SiMsgCompInfo msgComp; /* message compatibility information */ + SiGenDigits genDigits; /* generic digits */ +// SiGenDigits genDigitsR; /* generic digits (repeated - ITU97/92) */ + SiNotifInd notifInd; /* notification indicator */ +// SiNotifInd notifIndR; /* notification ind (repeated - ITU97/92) */ + SiGenNum genNmb; /* generic number */ +// SiGenNum genNmbR; /* generic number (repeated - ITU97/92) */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduSGM; + +typedef struct siPduLOP /* loop prevention mesg. */ +{ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility info */ + SiCallTRef calTrnsfrRef; /* Call Transfer reference */ + SiLoopPrvntInd loopPrvntInd; /* loop prevention indicator */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduLOP; + +typedef struct siPduPRI /* Pre-release information mesg */ +{ + SiOptBckCalInd optBckCalInd; /* optional backward call indicators */ + SiOpFwdCalInd opFwdCalInd; /* optional forward call indicators */ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiAppTransParam appTransParam;/* application transport parameter */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduPRI; + +typedef struct siPduAPP /* Application transport message */ +{ + SiMsgCompInfo msgCom; /* message compatibility information */ + SiParmCompInfo parmCom; /* parameter compatibility information */ + SiAppTransParam appTransParam;/* application transport parameter */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduAPP; + +typedef struct siPduCVR /* Circuit validation response */ +{ + SiCirValRspInd valRspInd; /* circuit validation response indicator */ + SiCirGrpCharInd grpCharInd; /* circuit group characteristic indicators */ + SiCirIdName cirIdName; /* circuit identification name */ + SiCLLI clli; /* common language location identification */ + SiEndOp endOp; /* end of optional parameters */ +} SiPduCVR; + + +/* All Messages... */ +typedef struct siAllPdus /* All PDU Messages */ +{ + union + { + SiPduACM addrComp; /* Address Complete */ + SiPduANM answer; /* Answer */ + /* Blocking */ + /* Blocking ACK*/ + SiPduCPG caProg; /* Call Progress */ + SiPduCGB cirGrpBlk; /* Circuit Group Blocking */ + SiPduCGBA cirGrpBlkAck; /* Circuit Group Blocking Ack. */ + SiPduCQM cirGrpQry; /* Circuit Group Query */ + SiPduCQR cirGrpQryRes; /* Circuit Group Query Response */ + SiPduGRS cirGrpRes; /* Circuit Group Reset */ + SiPduGRA cirGrpResAck; /* Circuit Group Reset Ack. */ + SiPduCGU cirGrpUnblk; /* Circuit Group Unblocking */ + SiPduCGUA cirGrpUblkAck; /* Circuit Group Unblocking Ack. */ + /* Charge information */ + SiPduCFN confusion; /* Confusion */ + SiPduCON connect; /* Connect */ + SiPduCOT continuity; /* Continuity */ + /* Continuity check request */ + SiPduFAC facility; /* Facility Message. */ + SiPduFAA facAccept; /* Facility Accepted */ + SiPduFRJ facReject; /* Facility Rejected */ + SiPduFAR facRequest; /* Facility Request */ + SiPduFOT fwdTrans; /* Forward Transfer */ + SiPduIDR identReq; /* Identification Request Message. */ + SiPduIRS identRsp; /* Identification Response Message. */ + SiPduINF info; /* Information */ + SiPduINR infoReq; /* Information Request */ + SiPduIAM initAddr; /* Initial Address */ + /* Loop back ack */ + SiPduNRM netResMgt; /* Network Resource Management Message. */ + /* Overload */ + SiPduPAM passAlng; /* Pass Along */ + SiPduREL release; /* Release */ + SiPduRLC relComplete; /* Release Complete */ + /* Reset */ + SiPduRES resume; /* Resume */ + SiPduSGM segment; /* Simple Segmentation Message */ + SiPduSAM subAddr; /* Subsequent Address */ + SiPduSUS suspend; /* Suspend */ + /* Unblocking */ + /* Unblocking ACK */ + /* Unequipped CIC*/ + SiPduUPAT usrPrtAvTst; /* User Part Available/Test Message. */ + SiPduUSR usr2Usr; /* User to User */ + + SiPduPRI preRelease; /* Pre-release information mesg */ + SiPduAPP appTransport; /* Application transport message */ + SiPduLOP loopPrvnt; /* Loop Prevention Message */ + + SiPduCVR cirValRsp; /* Circuit Validation Response */ + /* Circuit Validation test */ + } m; +} SiAllPdus; + + + +#endif + diff --git a/omc/plat/isup/src/include/isup_public.h b/omc/plat/isup/src/include/isup_public.h new file mode 100644 index 0000000..4a7ec0e --- /dev/null +++ b/omc/plat/isup/src/include/isup_public.h @@ -0,0 +1,49 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ + +#ifndef _ISUP_PUBLIC_H_ +#define _ISUP_PUBLIC_H_ + +#include +#include +#include +#include + +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#ifndef _T_BYTE +#define _T_BYTE +typedef unsigned char BYTE; +#endif + +#ifndef _T_WORD +#define _T_WORD +typedef unsigned short WORD; +#endif + +#ifndef _T_DWORD +#define _T_DWORD +typedef unsigned int DWORD; +#endif + +#endif + + diff --git a/omc/plat/isup/src/include/isup_struct.h b/omc/plat/isup/src/include/isup_struct.h new file mode 100644 index 0000000..7e2b747 --- /dev/null +++ b/omc/plat/isup/src/include/isup_struct.h @@ -0,0 +1,138 @@ +/*========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*========================================*/ +#ifndef _ISUPSTRUCT_H_ +#define _ISUPSTRUCT_H_ + +#include "isup_if.h" + + +//***************************************************** +// ISUP Resource Structures +//***************************************************** +#define ISUP_MAX_SAP 16 +#define ISUP_MAX_CG 256 +#define ISUP_MAX_CIRCUIT 256 +#define ISUP_MAX_PORT 8192 //=ISUP_MAX_CIRCUIT*ISUP_CIRCUIT_CIC + +//#define ISUP_CG_CIRCUIT 32 +#define ISUP_CIRCUIT_CIC 32 + +//#define NAME_LEN 16 + +typedef struct _isup_cic_state +{ + u8 call_state; + u8 sus_state; + u8 blo_state; //bit0:local m-block flag bit1:remote block m-flag +} ISUP_CIC_state; + + +typedef struct _isup_fsm_state +{ + u8 cpc_state; + u8 blr_state; + u8 bls_state; + u8 mgbs_state; + u8 mgbr_state; + u8 crs_state; + u8 crr_state; + u8 cgrs_state; + u8 cgrr_state; +} ISUP_Fsm_state; + + +typedef struct _isup_port_struct +{ + u8 enable; + + u8 reset_flag; + + u8 gourp_range; + u8 status_field[ISUP_STATUS_LEN]; + + u8 re_cause; + u8 re_location; + u8 re_range; + u8 re_typeInd; + SiRangStat re_rangStat; + + u16 timer_flag; + + u32 w_time; + u32 su_proc_id; //for normal call + u32 sm_proc_id; //for maintenance + + u8 sprc_cmd; + u8 primitive_cmd; + u8 internal_cmd; + + ISUP_Fsm_state fsm_state; + ISUP_CIC_state cic_state; + + int trace_flag; +} ISUP_Port_struct; + + +typedef struct _isup_attrib_struct +{ + u8 systemID; + u8 isup_run_mode; + u32 isup_remote_ip; +} ISUP_Attrib_struct; + +typedef struct _isup_resource_pond +{ + ISUP_Port_struct port_pond[ISUP_MAX_PORT]; + ISUP_Attrib_struct attrib; +}ISUP_Resource_Pond; + + +typedef struct _isup_timer_struct { + int t1; + int t2; + int t3; + int t4; + int t5; + int t6; + int t7; + int t8; + int t9; + int t12; + int t13; + int t14; + int t15; + int t16; + int t17; + int t18; + int t19; + int t20; + int t21; + int t22; + int t23; + int t24; + int t25; + int t26; + int t27; + int t34; + int t36; + int t37; + int t38; +} ISUP_Timer_Struct; + + +typedef struct _isup_msg_csta { + u32 rv_iam; + u32 sd_iam; + u32 rv_acm; + u32 sd_acm; + u32 rv_rel; + u32 sd_rel; + u32 rv_rlc; + u32 sd_rlc; +} ISUP_Msg_Csta; +#endif diff --git a/omc/plat/isup/src/include/vssver2.scc b/omc/plat/isup/src/include/vssver2.scc new file mode 100644 index 0000000..fa9ab60 Binary files /dev/null and b/omc/plat/isup/src/include/vssver2.scc differ diff --git a/omc/plat/isup/src/isup_debug.c b/omc/plat/isup/src/isup_debug.c new file mode 100644 index 0000000..a0046ff --- /dev/null +++ b/omc/plat/isup/src/isup_debug.c @@ -0,0 +1,1586 @@ +/*************************************** +* Author: Zane Yi +* Date: 2007.02.01 +***************************************/ + +#include "./include/isup_debug.h" +#include "./include/isup_public.h" +#include "./include/isup_if.h" +#include "./include/isup_struct.h" +#include "./include/isup_def.h" +#include "./include/isup_const.h" + + +#define DEBUG_ID 22 +#define VER_DEBUG "R9V0_04" +#define IS_PATCH 3 + + + +#define PAGE_NUM 5 +#define MONITOR_NONE 0x0000 +#define MONITOR_ERROR 0x0002 +#define MONITOR_MSG 0x0004 +#define MONITOR_FUNC 0x0008 +#define MONITOR_STATE 0x8000 +#define MONITOR_ALL 0x7fff + +u8 isup_msg_test=0; + +static ISUP_Msg_Csta isup_csta; +static BYTE AsciInBuf[4096]; +static BYTE AsciOutBuf[4096]; +static BYTE AsciTempBuf[4096]; +static WORD MonitorFg; +static int debug_dpc,debug_opc,debug_ni; + + +static BYTE log_help[] = { + "ISUP 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 \n\r\ + 3.[log state on/off] display state logs \n\r\ + 4.[list cg] display all cg \n\r\ + 5.[list cg-x] display cg \n\r\ + 6.[list circuit-x] display circuit->port \n\r\n\r\ + 7.[list port-x] display port->port \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,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,DEBUG_ID + 2,2 +}; + +static DWORD debug_ascin_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,3 +}; + +static DWORD debug_ascout_id[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,4 +}; + +static DWORD debug_page_title[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,1,1 +}; + +static DWORD debug_page_line[20] = +{ + 1,3,6,1,4,1,1373,1,1,2,3,1,2,DEBUG_ID + 2,1,2,1 +}; + +const static BYTE BASE_ID_LEN = 15; +const static BYTE PAGE_POINT = 14; +const static BYTE LINE_POINT = 15; + +static BYTE title1_p[] = +{ + " ISUP Page 01 SAP Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SystemID\n\r\ +Run mode\n\r\ +Remote IP\n\r" +}; + +static BYTE title2_p[] = +{ + " ISUP Page 02 CG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +SAP_ID\n\r\ +Variant\n\r\ +Priority\n\r\ +NI\n\r\ +DPC\n\r\ +OPC\n\r\ +TG_ID\n\r" +}; + +static BYTE title3_p[] = +{ + " ISUP Page 03 CIC Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +CG_ID\n\r\ +PLAT_ID\n\r\ +CIC RANGE\n\r\ +HEAD CIC\n\r" +}; + +static BYTE title4_p[] = +{ + " ISUP Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Enable\n\r\ +Fsm_state\n\r\ +CIC_state\n\r\ +SU_port\n\r\ +Timer_F\n\r\ +Time_W\n\r" +}; + +static BYTE title5_p[] = +{ + " ISUP Page 05 Csta Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +RV-IAM\n\r\ +SD-IAM\n\r\ +RV-ACM\n\r\ +SD-ACM\n\r\ +RV-REL\n\r\ +SD-REL\n\r\ +RV-RLC\n\r\ +SD-RLC\n\r" +}; + + +static void debug_setcol(int color); +static void debug_cancelcol(); + +static void isup_asciout_proc(const char *fmt, ...) +{ + va_list ap; + char buf[4096]; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + if((strlen(AsciOutBuf) + strlen(buf)) < 4096) + strcat(AsciOutBuf, buf); + else + strcpy(AsciOutBuf, buf); + va_end(ap); +} + + +static void list_cg(u16 cg_id) +{ + const pal_cg_struct* cg_str; + + cg_str = pal_cg_ptr(cg_id); + if(cg_str == NULL) + return; + + isup_asciout_proc("\r\n\ + #ISUP CG Info\r\n\ + cg_id=%d\r\n\ + sap_id=%d\r\n\ + Attrib->\r\n\ + variant_type(%d)\r\n\ + priority(%d)\r\n\ + network_id(%d)\r\n\ + dpc(%d)\r\n\ + opc(%d)\r\n\ + tg_id(%d)\r\n\ + -------------------\r\n", + cg_id, + cg_str->sap_id, + cg_str->attrib.variant, + cg_str->attrib.priority, + cg_str->attrib.network_id, + cg_str->attrib.dpc, + cg_str->attrib.opc, + cg_str->attrib.tg_id + ); + return; +} +static void list_all_cg(void) +{ + int i; + const pal_cg_struct* cg_str; + + isup_asciout_proc("CgId\tSapId\tDPC\tOPC\tNI\tVariant\tPrior\tTgId\r\n"); + + for(i=0;ienable==0) + continue; + + if(cg_str->attrib.protocol!=1)//isup + continue; + + isup_asciout_proc("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", + i, + cg_str->sap_id, + cg_str->attrib.dpc, + cg_str->attrib.opc, + cg_str->attrib.network_id, + cg_str->attrib.variant, + cg_str->attrib.priority, + cg_str->attrib.tg_id + ); + } + return; +} +static void list_all_circuit(u16 cg_id) +{ + int i; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + cg_str = pal_cg_ptr(cg_id); + if(cg_str == NULL) + return; + + isup_asciout_proc("CgId\tSapId\tDPC\tOPC\tNI\tVariant\tPrior\tTgId\r\n"); + isup_asciout_proc("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", + cg_id, + cg_str->sap_id, + cg_str->attrib.dpc, + cg_str->attrib.opc, + cg_str->attrib.network_id, + cg_str->attrib.variant, + cg_str->attrib.priority, + cg_str->attrib.tg_id + ); + + + isup_asciout_proc("->circuit:\r\n"); + isup_asciout_proc("ID\tCgID\tPlatNo\tHeadCIC\tRange\tEnable\r\n"); + + for(i=0;ienable == 0 || + circuit_str->cg_id != cg_id) + continue; + isup_asciout_proc("%d\t%d\t%d\t%d\t%d\t%d\r\n", + i, + circuit_str->cg_id, + circuit_str->attrib.plat_id, + circuit_str->attrib.head_cic, + circuit_str->attrib.cic_range, + circuit_str->enable + ); + } + return; + +} +static void list_all_port(u16 circuit_id) +{ + int i,cic,port; + const pal_circuit_struct* circuit_str; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + return; + + port = ISUP_CIRCUIT_CIC*circuit_id; + cic = circuit_str->attrib.head_cic; + + isup_asciout_proc("Circuit\tCgID\tPlatNo\tHeadCIC\tRange\tEnable\r\n"); + isup_asciout_proc("%d\t%d\t%d\t%d\t%d\t%d\r\n", + circuit_id, + circuit_str->cg_id, + circuit_str->attrib.plat_id, + circuit_str->attrib.head_cic, + circuit_str->attrib.cic_range, + circuit_str->enable + ); + + isup_asciout_proc("->port:\r\n"); + isup_asciout_proc("CIC\tPort\tSuID\tcall\tsus\tblo\tcpc\tblr\tbls\tmgbs\tmgbr\tcrs\tcrr\tcgrs\tcgrr\r\n"); + + for(i=0;i\r\n\ + plat_id(%d)\r\n\ + head_cic(%d)\r\n\ + cic_range(%d)\r\n\ + -------------------\r\n", + circuit_id, + circuit_str->cg_id, + circuit_str->attrib.plat_id, + circuit_str->attrib.head_cic, + circuit_str->attrib.cic_range + ); + return; + +} + +static void list_port(u32 pid) +{ + int circuit_id; + const pal_circuit_struct* circuit_str; + + if(pid>=ISUP_MAX_PORT) + return; + + circuit_id = pid/ISUP_CIRCUIT_CIC; + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str ==NULL) + return; + list_cg(circuit_str->cg_id); + list_circuit(circuit_id); + + isup_asciout_proc("\r\n\ + #ISUP PORT Info\r\n\ + pid=%d\r\n\ + su_proc_id=%d\r\n\ + sm_proc_id=%d\r\n\ + ---------------\r\n\ + call_state=%d\r\n\ + sus_state=%d\r\n\ + blo_state=%d\r\n\ + ---------------\r\n\ + cpc_state=%d\r\n\ + blr_state=%d\r\n\ + bls_state=%d\r\n\ + mgbs_state=%d\r\n\ + mgbr_state=%d\r\n\ + crs_state=%d\r\n\ + crr_state=%d\r\n\ + cgrs_state=%d\r\n\ + cgrr_state=%d\r\n\ + -------------------\r\n", + pid, + isup_db.port_pond[pid].su_proc_id, + isup_db.port_pond[pid].sm_proc_id, + isup_db.port_pond[pid].cic_state.call_state, + isup_db.port_pond[pid].cic_state.sus_state, + isup_db.port_pond[pid].cic_state.blo_state, + isup_db.port_pond[pid].fsm_state.cpc_state, + isup_db.port_pond[pid].fsm_state.blr_state, + isup_db.port_pond[pid].fsm_state.bls_state, + isup_db.port_pond[pid].fsm_state.mgbs_state, + isup_db.port_pond[pid].fsm_state.mgbr_state, + isup_db.port_pond[pid].fsm_state.crs_state, + isup_db.port_pond[pid].fsm_state.crr_state, + isup_db.port_pond[pid].fsm_state.cgrs_state, + isup_db.port_pond[pid].fsm_state.cgrr_state + ); + return; + +} + +static int list_cic(u8 ni, u32 dpc, u32 opc, u32 cic) +{ + int pid; + const pal_circuit_struct* circuit_str; + + circuit_str = pal_ss7_find_circuit(ni, dpc, opc, cic); + if(circuit_str == NULL) + { + isup_asciout_proc("illegal cic value! ni=%d,dpc=%d,opc=%d,cic=%d\r\n",ni,opc,dpc,cic); + return -1; + } + + pid = ISUP_CIRCUIT_CIC*circuit_str->id + + (cic - circuit_str->attrib.head_cic); + + list_port(pid); + + return 1; + + +} + +static void debug_setcol(int color) +{ + isup_asciout_proc("%c[%dm",COL_ESC , color); +} + +static void debug_cancelcol() +{ + isup_asciout_proc("%c[m",COL_ESC); +} + +static BYTE debug_disp_line(BYTE page, BYTE line) +{ + BYTE disp_length; + + disp_length = 0; + disp_ptr = (BYTE *) disp_page; + + switch (page) + { + case 1: // Page 1: sap Info + disp_length = 0; + break; + case 2: // Page 2: cg Info + disp_length = 0; + break; + case 3: // Page 3: circuit Info + disp_length = 0; + break; + case 4: // Page 4: port Info + switch(line) + { + case 0: + disp_ptr = (BYTE *) &disp_page[page]; //Subpage + disp_length = 2; + break; + case 1: //enable + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].enable); + disp_length = 1; + break; + case 2: //fsm_state + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].fsm_state); + disp_length = 9; + break; + case 3: //cic_state + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].cic_state); + disp_length = 3; + break; + case 4: //su_proc_id + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].su_proc_id); + disp_length = 4; + break; + case 5: //timer_flag + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].timer_flag); + disp_length = 2; + break; + case 6: //w_time + disp_ptr = (BYTE *) &(isup_db.port_pond[disp_page[page]].w_time); + disp_length = 4; + break; + default: + break; + } + break; + case 5: // Page 5: csta Info + switch(line) + { + case 0: + disp_ptr = (BYTE *) &isup_csta.rv_iam; + disp_length = 4; + break; + case 1: + disp_ptr = (BYTE *) &isup_csta.sd_iam; + disp_length = 4; + break; + case 2: + disp_ptr = (BYTE *) &isup_csta.rv_acm; + disp_length = 4; + break; + case 3: + disp_ptr = (BYTE *) &isup_csta.sd_acm; + disp_length = 4; + break; + case 4: + disp_ptr = (BYTE *) &isup_csta.rv_rel; + disp_length = 4; + break; + case 5: + disp_ptr = (BYTE *) &isup_csta.sd_rel; + disp_length = 4; + break; + case 6: + disp_ptr = (BYTE *) &isup_csta.rv_rlc; + disp_length = 4; + break; + case 7: + disp_ptr = (BYTE *) &isup_csta.sd_rlc; + disp_length = 4; + break; + default: + break; + } + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +static void debug_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 = debug_disp_line(page, disp_line); + debug_page_line[LINE_POINT] = disp_line + 2; + debug_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +void test_isup_msg(u8 type, u8 flag) +{ + /* + int pid = 10,str_len; + if(!isup_msg_test) + return; + memset(&isup_sd_pdus,0,sizeof(SiAllPdus)); + switch(type) + { + case M_ACM: + { + SiPduACM data = { + {1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1},//SiBckCalInd,SiOptBckCalInd + {1,{1,1,1},0x0001},{1,1,1,1,1,{1}}, + {1,1,1,1,1,0},{1,1,1},{1,2,1,0},{1,1},{1,1}, + {1,1,1,1,1},{1,1},{1,1,1,1,1,3,1,2,3}, + {1,2,1,1},{1,1,1},{1,2,1,1},{1,2,1,1},{1,2,1,1}, + {1,1},{1,1,2,1,1},{1,1,1,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_ANM: + { + SiPduANM data = { + {1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,0x0001}, + {1,1,1,1,1,0},{1,1,1},{1,1,1,1,1,1,7,1,2,3,4,5,6,7},//SiUsr2UsrInd,SiUsr2UsrInfo,SiConnectedNum + {1,2,1,0},{1,1},{1,1},{1,3,1,1,1},{1,0x0001}, + {1,1,1,1,1,1,1,1,7,1,2,3,4,5,6,7},//SiGenNum + {1,1},{1,2,1,1},{1,2,1,1},{1,1,1,1,1,5,1,2,3,4,5}, + {1,2,1,1},{1,2,1,3,1},{1,1}, + {1,1,2,1,1},{1,2,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CPG: + { + SiPduCPG data = { + {1,1,1},{1,1,1,1,1,1},{1,1,1,1,0x0001}, + {1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1},//SiBckCalInd,SiOptBckCalInd + {1,3,1,1,1},{1,1,1,1,1,0},{1,1},{1,3,1,1,1},//SiNetSpecFacil + {1,3,1,1,1},{1,1},{1,1},{1,1,1,1,1,5,1,2,3,4,5},//SiCdPtyNum + {1,3,1,1,1},{1,2,1},{1,3,1,1,1},{1,1},//SiRedirRestr + {1,1,1,1,1,1,1,3,1,1,1},{1,1,1,1,1},{1,1,1,1,1,1,7,1,2,3,4,5,6,7},//SiConnectedNum + {1,1,2,1,1},{1,1,1,1,1,1,1,1,3,1,2,3},//SiGenNum + {1,0x0001},{1,1,2,1,1},{1,1,1,2,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CGB: + { + SiPduCGB data = {{1,1},{1,31,0xFF,0xFF,0xFF,0xFF}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CGBA: + { + SiPduCGBA data = {{1,1},{1,31,0xFF,0xFF,0xFF,0xFF}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CQM: + { + SiPduCQM data = {{1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CQR: + { + SiPduCQR data = {{1,1},{1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_GRS: + { + SiPduGRS data = {{1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_GRA: + { + SiPduGRA data = {{1,31,0xFF,0xFF,0xFF,0xFF}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CGU: + { + SiPduCGU data = {{1,1},{1,31,0xFF,0xFF,0xFF,0xFF}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CGUA: + { + SiPduCGUA data = {{1,1},{1,31,0xFF,0xFF,0xFF,0xFF}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CFN: + { + SiPduCFN data = {{1,1,1,1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_CON: + { + SiPduCON data = { + {1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1}, + {1,1,1,1,1,1,7,1,2,3,4,5,6,7},{1,1,1,1,0x0001}, + {1,1,1,1,1,0},{1,1,1},{1,3,1,1,1},{1,3,1,1,1},{1,1},//SiNotifInd + {1,3,1,1,1},{1,1},{1,1,1,1,1},{1,1},{1,0x0001},{1,3,1,1,1}, + {1,1,1,1,1,5,1,2,3,4,5},{1,3,1,1,1},//SiServiceAct + {1,1,1,1,1,1,1,1,7,1,2,3,4,5,6,7}, + {1,1},{1,1,2,1,1},{1,1,2,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_COT: + { + SiPduCOT data = {{1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_FAC: + { + SiPduFAC data = { + {1,1,1,1,1,1,1,0,0,0,0,0,0},{1,3,1,1,1},{1,3,1,1,1}, + {1,3,1,1,1},{1,1,1,1,1,1,1,3,1,1,1},{1,3,1,1,1},{1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_FAA: + { + SiPduFAA data = { + {1,1},{1,1,1,1,1,0},{1,1,1,1,0x0001},{1,1,1,1,0x0001,1,1},{1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_FRJ: + { + SiPduFRJ data = {{1,1},{1,1,1,1,2,1,1},{1,1,1,1,1,0}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_FAR: + { + SiPduFAR data = { + {1,1},{1,1,1,1,1,0},{1,1,1,1,0x0001},{1,1,1,1,0x0001,1,1},{1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_FOT: + { + SiPduFOT data = {{1,1,1,1,0x0001}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_IDR: + { + SiPduIDR data = { + {1,1,1},{1,1,1,1,1,1,1,0,0,0,0,0,0},{1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_IRS: + { + SiPduIRS data = { + {1,1,1},{1,1,1,1,1,1,1,0,0,0,0,0,0},{1,3,1,1,1}, + {1,1,1,1,1,1,1,3,1,1,1},{1,3,1,1,1},{1,1,1,1,1,1,1,1,3,1,2,3},//SiGenNum + {1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_INF: + { + SiPduINF data = { + {1,1,1,1,1,1,0},{1,1},{1,1,1,1,1,1,1,3,1,1,1},{1,1,1,1,0x0001}, + {1,1,1,1,0x0001,1,1},{1,3,1,1,1},{1,3,1,1,1}, + {1,1,1,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {1,1,1,1,1},{1,1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_INR: + { + SiPduINR data = {{1,1,1,1,1,1,0},{1,0,0,1,0x0001},{1,3,1,1,1},{1,3,1,1,1},{1,1,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_IAM: + { + SiPduIAM data = { + {1,1,1,1},{1,1,1,1,1,1,1,1,1},{1,1},{1,1}, + {1,1,1,1,1,1,1},{1,1,1,1,1,1},{0,0,0,0,0},//SiCallRef + {0,0,0,0,0,0,0,0,0},{0,0,0,0},{1,1,1,1,1,1,1},{1,1,1,1,1},//SiRedirInfo + {1,1,1,1,1,0x0001},{1,1,1,1,0x0001,1,1},{1,1,1,1,1,1,1},//SiOrigCdNum + {1,2,1,1},{1,3,1,1,1},{1,2,1,1},{1,1,1,1,1,0}, + {0,0,0,0,0,0,0,0,0,0},//SiGenNum + {0,0x0000},{0,0,0,0},{0,0,0,0},{0,0,0,0,0},//SiGenDigits + {1,0x0002},{1,2,1,1},{1,2,1,1},{1,2,1,1},{1,1},{1,2,1,1},//SiServiceAct + {1,1,1,1,1,1,1,0x00000001},{1,1},{0,0,0,0,0,0,0,0,0},//SiCgPtyNum + {1,2,1, + 3,1,2,3,0,0,0,0,0, + 2,1, + 3,1,2,3,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 3,1,1,1, + 3,1,2,3,0,0,0,0,0, + 0,0,0,0,0,0,0,0,}, + {1,1,},{1,1,2,1,1},{1,1,2,1,1,2},{1,2,1,1},{1,1,2,1,1},//SiCallDivTrtInd + {1,1,1,1,1,1,1},{1,1,2,1,1},{1,1,2,1,1},{1,2,1,1},{1,1,1,2,1,1}, + {1,1,1,1,1},{1,1},{1,1},{1,1,1,1,1},{1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1}, + {1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_NRM: + { + SiPduNRM data = { + {1,1,1,1,1,1,1,0,0,0,0,0,0},{1,3,1,1,1},{1,2},{1,1,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_PAM: + { + SiPduPAM data = {{1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_REL: + { + SiPduREL data = { + {1,1,1,1,2,1,1},{1,1,1,1,1},{1,1,1,1,1,3,1,2,3}, + {1,3,1,1,1},{1,0x0001},{1,3,1,1,1},{1,1},{1,3,1,1,1},//SiNetSpecFacil + {1,1},{1,3,1,1,1},{1,1},{1,1,1,1,1,0},{1,3,1,1,1},{1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_RLC: + { + SiPduRLC data = {{1,1,1,1,2,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_RES: + { + SiPduRES data = {{1,1},{1,1,1,1,0x0001}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_SGM: + { + SiPduSGM data = { + {1,3,1,1,1},{1,3,1,1,1},{1,1,1,1,1,1,1,0,0,0,0,0,0}, + {1,1,1,3,1,2,3},{1,1}, + {1,1,1,1,1,1,1,1,3,1,2,3} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_SAM: + { + SiPduSAM data = { + {1,1,3,1,1,1} + }; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_SUS: + { + SiPduSUS data = {{1,1},{1,1,1,1,0x0001}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_UPA: + { + SiPduUPAT data = {{1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_UPT: + { + SiPduUPAT data = {{1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_USR: + { + SiPduUSR data = {{1,3,1,1,1},{1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_LOP: + { + return; + } + case M_PRI: + { + SiPduPRI data = {{1,1,1,1,1},{1,1,1,1},{1,1,1,1,1,1,1,0,0,0,0,0,0}, + {1,3,1,1,1},{1,1,1,1,1,1,3,1,1,1}}; + str_len = sizeof(data); + memcpy(&isup_sd_pdus,&data,str_len); + break; + } + case M_UBL: + case M_UBA: + case M_UCIC: + case M_BLO: + case M_BLA: + case M_RSC: + case M_OLM: + case M_LPA: + case M_CRG: + if(flag) return; + break; + default: + return; + } + + if(flag) + { + if(memcmp(&isup_rv_pdus,&isup_sd_pdus,str_len)==0) + { + isup_asciout_proc("TEST CHECK PASS.\r\n"); + return; + } + isup_asciout_proc("TEST CHECK ERROR.\r\n"); + } + + isup_send_msg(pid,type); + */ + return; +} + +int isup_debug_init(void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + + strcpy(AsciInBuf, "\0"); + strcpy(AsciOutBuf, "\0"); + MonitorFg = MONITOR_NONE; + bzero(disp_page, 20); + memset(&isup_csta,0,sizeof(isup_csta)); + ptr = data; + + debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(BASE_ID_LEN, debug_name_id, VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 4096); + + for (page = 1; page <= PAGE_NUM; 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; + default: + break; + } + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + debug_disp_page(page); + } + return 1; +} + + +void isup_debug_timer(void) +{ + BYTE in_page, err_fg = 0; + BYTE *ascii_in_ptr = NULL; + BYTE *str_start = NULL; + WORD str_len; + WORD num; + + if ((str_len = strlen(AsciInBuf)) > 0) + { + in_page = AsciInBuf[0] - 1; + ascii_in_ptr = AsciInBuf + 1; + + if (in_page > PAGE_NUM) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + MonitorFg = MonitorFg | MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + MonitorFg = MonitorFg & (~MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + MonitorFg = MONITOR_ALL; + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + MonitorFg = MONITOR_NONE; + } + else if (strcmp(ascii_in_ptr,"log state on") == 0) + { + MonitorFg = MonitorFg | MONITOR_STATE; + } + else if (strcmp(ascii_in_ptr,"log state off") == 0) + { + MonitorFg = MonitorFg & (~MONITOR_STATE); + } + + else if (strcmp(ascii_in_ptr,"help") == 0) + { + isup_asciout_proc(log_help); + isup_asciout_proc("Ver.%sp%02d\r\n",VER_DEBUG,IS_PATCH); + } + else if (isdigit(ascii_in_ptr[0])) + { + num = strtoul(ascii_in_ptr, NULL, 10); + disp_page[in_page] = num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, ">")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] += num; + debug_disp_page(in_page); + } + else if ((str_start = strstr(ascii_in_ptr, "<"))!= NULL) + { + num = strtoul(str_start + 1, NULL, 10); + disp_page[in_page] -= num; + debug_disp_page(in_page); + } + else if (strcmp(ascii_in_ptr,"reset csta") == 0) + { + memset(&isup_csta,0,sizeof(isup_csta)); + } + else if (strcmp(ascii_in_ptr,"test color") == 0) + { + debug_setcol(COL_WHITE); + isup_asciout_proc("COL_WHITE\n\r"); + debug_setcol(COL_RED); + isup_asciout_proc("COL_RED\n\r"); + debug_setcol(COL_YELLOW); + isup_asciout_proc("COL_YELLOW\n\r"); + debug_setcol(COL_GREEN); + isup_asciout_proc("COL_GREEN\n\r"); + debug_setcol(COL_BLUE); + isup_asciout_proc("COL_BLUE\n\r"); + debug_setcol(COL_BROWN); + isup_asciout_proc("COL_BROWN\n\r"); + debug_setcol(COL_MEGEN); + isup_asciout_proc("COL_MEGEN\n\r"); + debug_setcol(COL_GRAY); + isup_asciout_proc("COL_GRAY\n\r"); + debug_setcol(COL_HI_WHI); + isup_asciout_proc("COL_HI_WHI\n\r"); + debug_setcol(COL_HI_RED); + isup_asciout_proc("COL_HI_RED\n\r"); + debug_setcol(COL_HI_YEL); + isup_asciout_proc("COL_HI_YEL\n\r"); + debug_setcol(COL_HI_GRE); + isup_asciout_proc("COL_HI_GRE\n\r"); + debug_setcol(COL_HI_BLU); + isup_asciout_proc("COL_HI_BLU\n\r"); + debug_setcol(COL_HI_BRO); + isup_asciout_proc("COL_HI_BRO\n\r"); + debug_setcol(COL_HI_MEG); + isup_asciout_proc("COL_HI_MEG\n\r"); + debug_setcol(COL_BLACK); + isup_asciout_proc("COL_BLACK\n\r"); + debug_cancelcol(); + } + else if (strstr(ascii_in_ptr, "reset port") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + if (num >= ISUP_MAX_PORT) + err_fg = 1; + else + { + memset(&(isup_db.port_pond[num]),0,sizeof(ISUP_Port_struct)); + } + } + } + else if (strstr(ascii_in_ptr, "set dpc") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "=")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + debug_dpc = num; + } + } + else if (strstr(ascii_in_ptr, "set opc") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "=")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + debug_opc = num; + } + } + else if (strstr(ascii_in_ptr, "set ni") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "=")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + debug_ni = num; + } + } + else if (strstr(ascii_in_ptr, "list cg") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_all_circuit(num); + } + else + list_all_cg(); + } + else if (strstr(ascii_in_ptr, "list circuit") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_all_port(num); + } + } + else if (strstr(ascii_in_ptr, "list port") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_port(num); + } + } + else if (strstr(ascii_in_ptr, "list debug spc") != NULL) + { + isup_asciout_proc("debug_dpc = %d,debug_opc = %d,debug_ni = %d\n\r",debug_dpc,debug_opc,debug_ni); + } + else if (strstr(ascii_in_ptr, "list cic") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + list_cic(debug_ni, debug_dpc, debug_opc, num); + } + } + else if (strcmp(ascii_in_ptr,"test start") == 0) + isup_msg_test = 1; + else if (strcmp(ascii_in_ptr,"test stop") == 0) + isup_msg_test = 0; + else if (strstr(ascii_in_ptr, "send") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + num = strtoul(str_start + 1, NULL, 10); + test_isup_msg(num,0); + } + } + else if (strcmp(ascii_in_ptr,"test debug") == 0) + { + up_message msg; + msg.len = 1; + msg.msgList[0] = 1; + monitor_isup_msg(0,"RV=>",&msg,COL_YELLOW); + isup_trace_func(0,"APP => function trace: isup_setup_ind\r\n"); + monitor_isup_msg(0,"SD=>",&msg,COL_YELLOW); + isup_trace_func(0,"APP => function trace: isup_setup_ind\r\n"); + isup_log_err(0,"Setup indicate handle is not registered@%s\r\n", __FUNCTION__); + } + else + err_fg = 1; + + if (err_fg == 0) + isup_asciout_proc("Command OK!\n\r"); + else + isup_asciout_proc("Command Error!\n\r"); + + strcpy(AsciInBuf, "\0"); + } +} + + +static void display_isup_msgtype(u8 msgtype) +{ + + switch(msgtype) + { + case M_ACM: + isup_asciout_proc("ACM:Address complete"); + break; + case M_ANM: + isup_asciout_proc("ANM:Answer"); + break; + case M_APP: + isup_asciout_proc("APP:Application transport message"); + break; + case M_BLO: + isup_asciout_proc("BLO:Blocking"); + break; + case M_BLA: + isup_asciout_proc("BLA:Blocking acknowledgement"); + break; + case M_CPG: + isup_asciout_proc("CPG:Call progress"); + break; + case M_CGB: + isup_asciout_proc("CGB:Circuit/CIC group blocking"); + break; + case M_CGBA: + isup_asciout_proc("CGBA:Circuit/CIC group blocking acknowledgement"); + break; + case M_CQM: + isup_asciout_proc("CQM:Circuit/CIC group query (national use)"); + break; + case M_CQR: + isup_asciout_proc("CQR:Circuit/CIC group query response (national use)"); + break; + case M_GRS: + isup_asciout_proc("GRS:Circuit/CIC group reset"); + break; + case M_GRA: + isup_asciout_proc("GRA:Circuit/CIC group reset acknowledgement"); + break; + case M_CGU: + isup_asciout_proc("CGU:Circuit/CIC group unblocking"); + break; + case M_CGUA: + isup_asciout_proc("CGUA:Circuit/CIC group unblocking acknowledgement"); + break; + case M_CRG: + isup_asciout_proc("CRG:Charge information (national use)"); + break; + case M_CFN: + isup_asciout_proc("CFN:Confusion"); + break; + case M_CON: + isup_asciout_proc("CON:Connect"); + break; + case M_COT: + isup_asciout_proc("COT:Continuity"); + break; + case M_FAC: + isup_asciout_proc("FAC:Facility "); + break; + case M_FAA: + isup_asciout_proc("FAA:Facility accepted"); + break; + case M_FRJ: + isup_asciout_proc("FRJ:Facility reject"); + break; + case M_FAR: + isup_asciout_proc("FAR:Facility request"); + break; + case M_FOT: + isup_asciout_proc("FOT:Forward transfer"); + break; + case M_IDR: + isup_asciout_proc("IDR:Identification request"); + break; + case M_IRS: + isup_asciout_proc("IRS:Identification response"); + break; + case M_INF: + isup_asciout_proc("INF:Information (national use)"); + break; + case M_INR: + isup_asciout_proc("INR:Information request (national use)"); + break; + case M_IAM: + isup_asciout_proc("IAM:Initial address"); + break; + case M_LPA: + isup_asciout_proc("LPA:Loop Back Acknowledgement"); + break; + case M_NRM: + isup_asciout_proc("NRM:Network resource management"); + break; + case M_OLM: + isup_asciout_proc("OLM:Overload"); + break; + case M_PAM: + isup_asciout_proc("PAM:Pass-Along"); + break; + case M_REL: + isup_asciout_proc("REL:Release"); + break; + case M_RLC: + isup_asciout_proc("RLC:Release complete"); + break; + case M_RSC: + isup_asciout_proc("RSC:Reset circuit/CIC"); + break; + case M_RES: + isup_asciout_proc("RES:Resume"); + break; + case M_SGM: + isup_asciout_proc("SGM:Segmentation"); + break; + case M_SAM: + isup_asciout_proc("SAM:Subsequent address"); + break; + case M_SUS: + isup_asciout_proc("SUS:Suspend"); + break; + case M_UBL: + isup_asciout_proc("UBL:Unblocking"); + break; + case M_UBA: + isup_asciout_proc("UBA:Unblocking acknowledgement"); + break; + case M_UCIC: + isup_asciout_proc("UCIC:Unequipped CIC (national use)"); + break; + case M_UPA: + isup_asciout_proc("UPA:User Part Available"); + break; + case M_UPT: + isup_asciout_proc("UPT:User Part Test"); + break; + case M_USR: + isup_asciout_proc("USR:User-to-user information"); + break; + case M_PRI: + isup_asciout_proc("PRI:Pre-release information message"); + break; + case M_CVR: + isup_asciout_proc("CVR:Circuit validation response"); + break; + case M_CVT: + isup_asciout_proc("CVT:Circuit validation test"); + break; + default: + isup_asciout_proc("Unknown message"); + } + isup_asciout_proc("(message type=0x%x)",msgtype); +} + +void isup_log_err(u32 pid,const char *fmt, ...) +{ + va_list ap; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if (((MonitorFg & MONITOR_ERROR) != MONITOR_ERROR) && + (isup_db.port_pond[pid%ISUP_MAX_PORT].trace_flag != 1)) + return; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + sprintf ( timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + va_start(ap, fmt); + vsprintf(AsciTempBuf, fmt, ap); + debug_setcol(COL_RED); + isup_asciout_proc("%s%s (pid=%d)",timestr,AsciTempBuf,pid); + debug_cancelcol(); + isup_asciout_proc("\r\n"); + va_end(ap); +} + +void isup_trace_func(u32 pid,const char *fmt, ...) +{ + va_list ap; + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if (((MonitorFg & MONITOR_FUNC) != MONITOR_FUNC) && + (isup_db.port_pond[pid%ISUP_MAX_PORT].trace_flag != 1)) + return; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + sprintf ( timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + va_start(ap, fmt); + vsprintf(AsciTempBuf, fmt, ap); + debug_setcol(COL_YELLOW); + isup_asciout_proc("%s%s (pid=%d)",timestr,AsciTempBuf,pid); + debug_cancelcol(); + isup_asciout_proc("\r\n"); + va_end(ap); +} + +void monitor_isup_msg(u32 pid,BYTE *head,up_message *msg,BYTE col) +{ + BYTE i; + + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[1024]; + + if (((MonitorFg & MONITOR_MSG) != MONITOR_MSG) && + (isup_db.port_pond[pid%ISUP_MAX_PORT].trace_flag != 1)) + return; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + sprintf ( timestr, "[%d:%d:%d.%ld]", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + + debug_setcol(col); + isup_asciout_proc("%s%s ",timestr,head); + display_isup_msgtype(msg->msgList[0]); + isup_asciout_proc("--cic=0x%x%x,dpc=%d,opc=%d,ni=%d,pid=%d->\n\r",msg->cic[1],msg->cic[0],msg->dpc,msg->opc,msg->sio>>6,pid); + debug_cancelcol(); + for (i = 0; i < msg->len; i ++) + { + sprintf(&AsciTempBuf[3*i]," %02x", msg->msgList[i]); + } + sprintf(&AsciTempBuf[3*i],"\n\r"); + isup_asciout_proc(AsciTempBuf); + return; +} + +void monitor_port_state(u32 cic_val,u32 port) +{ + if ((MonitorFg & MONITOR_STATE) != MONITOR_STATE) + return; + + isup_asciout_proc("->port:\r\n"); + isup_asciout_proc("CIC\tPort\tSuID\tcall\tsus\tblo\tcpc\tblr\tbls\tmgbs\tmgbr\tcrs\tcrr\tcgrs\tcgrr\r\n"); + isup_asciout_proc("%d\t%d\t%d(%d)\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", + cic_val, + port, + isup_db.port_pond[port].su_proc_id, + isup_db.port_pond[port].sm_proc_id, + isup_db.port_pond[port].cic_state.call_state, + isup_db.port_pond[port].cic_state.sus_state, + isup_db.port_pond[port].cic_state.blo_state, + isup_db.port_pond[port].fsm_state.cpc_state, + isup_db.port_pond[port].fsm_state.blr_state, + isup_db.port_pond[port].fsm_state.bls_state, + isup_db.port_pond[port].fsm_state.mgbs_state, + isup_db.port_pond[port].fsm_state.mgbr_state, + isup_db.port_pond[port].fsm_state.crs_state, + isup_db.port_pond[port].fsm_state.crr_state, + isup_db.port_pond[port].fsm_state.cgrs_state, + isup_db.port_pond[port].fsm_state.cgrr_state + ); +} + +void isup_msg_csta(u8 msgtype,u8 flag) +{ + + switch(msgtype) + { + case M_ACM: + if(flag==0) + isup_csta.rv_acm++; + else + isup_csta.sd_acm++; + break; + case M_ANM: + break; + case M_BLO: + break; + case M_BLA: + break; + case M_CPG: + break; + case M_CGB: + break; + case M_CGBA: + break; + case M_CQM: + break; + case M_CQR: + break; + case M_GRS: + break; + case M_GRA: + break; + case M_CGU: + break; + case M_CGUA: + break; + case M_CRG: + break; + case M_CFN: + break; + case M_CON: + break; + case M_COT: + break; + case M_FAC: + break; + case M_FAA: + break; + case M_FRJ: + break; + case M_FAR: + break; + case M_FOT: + break; + case M_IDR: + break; + case M_IRS: + break; + case M_INF: + break; + case M_INR: + break; + case M_IAM: + if(flag==0) + isup_csta.rv_iam++; + else + isup_csta.sd_iam++; + break; + case M_LPA: + break; + case M_NRM: + break; + case M_OLM: + break; + case M_PAM: + break; + case M_REL: + if(flag==0) + isup_csta.rv_rel++; + else + isup_csta.sd_rel++; + break; + case M_RLC: + if(flag==0) + isup_csta.rv_rlc++; + else + isup_csta.sd_rlc++; + break; + case M_RSC: + break; + case M_RES: + break; + case M_SGM: + break; + case M_SAM: + break; + case M_SUS: + break; + case M_UBL: + break; + case M_UBA: + break; + case M_UCIC: + break; + case M_UPA: + break; + case M_UPT: + break; + case M_USR: + break; + default: + break; + } +} + diff --git a/omc/plat/isup/src/isup_fsm.c b/omc/plat/isup/src/isup_fsm.c new file mode 100644 index 0000000..73b23e6 --- /dev/null +++ b/omc/plat/isup/src/isup_fsm.c @@ -0,0 +1,2602 @@ +//========================================= +// +// +// Author: Zane Yi +// Date: 2007.02.01 +// +//========================================= + +#include "./include/inc.h" +#include "./include/isup_if.h" +#include "./include/isup_struct.h" +#include "./include/isup_debug.h" +#include "./include/isup_def.h" +#include "./include/isup_const.h" +#include "./include/isup_msg.h" + +static void isup_cpc_clear(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + port_ptr->fsm_state.cpc_state = 0; + port_ptr->cic_state.call_state = IDLE_FLAG; + port_ptr->trace_flag = 0; + return; +} + +static void set_cause(SiCauseDgn *cause_ptr, u8 val, u8 location) +{ + cause_ptr->pres = 1; + cause_ptr->location = location; //(4)public network serving the remote user + cause_ptr->cdeStand = 0; //CCITT standardized coding + cause_ptr->causeVal = val; +} + +static int isup_cpcoblocking_func(u32 start_pid, const SiRangStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + if(isup_db.port_pond[pid].cic_state.call_state==CALLOUT_FLAG) + { + isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBR; + isup_cpc_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + } + } + return 1; +} + +static int isup_blrblocking_func(u32 start_pid, const SiRangStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBR; + isup_blr_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + } + return 1; +} + +static int isup_blrunblocking_func(u32 start_pid, const SiRangStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_MGBR; + isup_blr_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + } + return 1; +} + +static int isup_blsblocking_func(u32 start_pid, const SiRangStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBS; + isup_bls_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + } + return 1; +} + +static int isup_blsunblocking_func(u32 start_pid, const SiRangStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + { + isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_MGBS; + isup_bls_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + } + return 1; +} + +static int isup_cgrr_func(u32 start_pid, const SiRangNoStat *rs_ptr) +{ + int i,temp,range; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + memset(isup_db.port_pond[start_pid].status_field,0,ISUP_STATUS_LEN); + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + + if (isup_db.port_pond[pid].cic_state.blo_state & M_REMOTE_BLOCK) //Remotely blocked + { + isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_CGRR; + isup_blr_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + + if(isup_db.port_pond[pid].cic_state.blo_state & M_LOCAL_BLOCK) //Locally blocked + { + if(isup_db.port_pond[pid].fsm_state.mgbs_state != MGBS_WAIT_CGUA) + isup_db.port_pond[start_pid].status_field[i>>3] |= 0x01 << (i&0x07); + } + } + isup_db.port_pond[start_pid].gourp_range = range; + for(i = 0; i <= range; i++)//indeed! + { + pid = start_pid + i; + + isup_db.port_pond[pid].internal_cmd = CMD_RESET|SI_CGRR; + isup_cpc_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + return 1; +} + +static int isup_cgrs_func(u32 start_pid, u8 range, u8 flag) +{ + int i,temp; + u32 pid; + + temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; + range = temprange ? temp : rs_ptr->range; + + for(i = 0; i <= range; i++) + { + pid = start_pid + i; + if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) + isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_CGRS; + else + isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_CGRS; + isup_db.port_pond[pid].cic_state.call_state = IDLE_FLAG; + isup_blr_proc(pid); + isup_db.port_pond[pid].internal_cmd = 0; + } + return 1; +} + +static int get_priority(pid) +{ + int circuit_id; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + + circuit_id = pid/ISUP_CIRCUIT_CIC; + circuit_str = pal_circuit_ptr(circuit_id); + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + return -1; + + return cg_str->attrib.priority; +} + +int isup_event_handle(u32 pid, u8 primitive, u8 eventType) +{ + int offset,circuit_id; + Pst pst; + EventHandle_struct *event_handle; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + const pal_sap_struct* sap_str; + + pst.sp_proc_id = pid; + pst.su_proc_id = isup_db.port_pond[pid].su_proc_id; + + circuit_id = pid/ISUP_CIRCUIT_CIC; + offset = pid%ISUP_CIRCUIT_CIC; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return -1; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return -1; + } + sap_str = pal_sap_ptr(cg_str->sap_id); + if(sap_str == NULL) + { + isup_log_err(pid,"sap_str==NULL\r\n"); + return -1; + } + + pst.cic = circuit_str->attrib.head_cic + offset; + + pst.cg_id = circuit_str->cg_id; + pst.tg_id = cg_str->attrib.tg_id; + + event_handle = &(sap_str->attrib.event_handle); + + switch(primitive) + { + case ISUP_SETUP_IND: + { + if (event_handle->h_isup_setup_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_setup_ind\r\n"); + event_handle->h_isup_setup_ind(&pst, &isup_rv_pdus.m.initAddr, isup_rv_msg.msgList, isup_rv_msg.len); + isup_db.port_pond[pid].su_proc_id = pst.su_proc_id; + isup_db.port_pond[pid].trace_flag = pst.trace_flag; + } + else + isup_log_err(pid,"Setup indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_SETUP_CNF: + { + if(eventType == EN_CON) + { + if(event_handle->h_isup_setup_con_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_setup_ind\r\n"); + event_handle->h_isup_setup_con_cnf(&pst, &isup_rv_pdus.m.connect, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Setup confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + else + { + if(event_handle->h_isup_setup_anm_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_setup_anm_cnf\r\n"); + event_handle->h_isup_setup_anm_cnf(&pst, &isup_rv_pdus.m.answer, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Setup confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + } + case ISUP_RELEASE_IND: + { + if(event_handle->h_isup_release_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_release_ind\r\n"); + event_handle->h_isup_release_ind(&pst, &isup_rv_pdus.m.release, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Release indication handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_RELEASE_CNF: + { + if(event_handle->h_isup_release_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_release_cnf\r\n"); + event_handle->h_isup_release_cnf(&pst, &isup_rv_pdus.m.relComplete, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Release confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_ALERT_IND: + { + if(event_handle->h_isup_alert_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_alert_ind\r\n"); + event_handle->h_isup_alert_ind(&pst, &isup_rv_pdus.m.addrComp, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Alert indication handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_INFO_IND: + { + if(event_handle->h_isup_info_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_info_ind\r\n"); + event_handle->h_isup_info_ind(&pst, &isup_rv_pdus.m.subAddr, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Information indication handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_PROG_IND: + { + if(event_handle->h_isup_prog_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_prog_ind\r\n"); + event_handle->h_isup_prog_ind(&pst, &isup_rv_pdus.m.caProg, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Call progress indication handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_SUSPEND_IND: + { + if(event_handle->h_isup_suspend_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_suspend_ind\r\n"); + event_handle->h_isup_suspend_ind(&pst, &isup_rv_pdus.m.suspend, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Suspend indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_RESUME_IND: + { + if(event_handle->h_isup_resume_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_resume_ind\r\n"); + event_handle->h_isup_resume_ind(&pst, &isup_rv_pdus.m.resume, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Resume indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_REATTEMPT_IND: + { + if(event_handle->h_isup_reattempt_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_reattempt_ind\r\n"); + event_handle->h_isup_reattempt_ind(&pst); + } + else + isup_log_err(pid,"Reattempt indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_FAILURE_IND: + { + if(event_handle->h_isup_failure_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_failure_ind\r\n"); + event_handle->h_isup_failure_ind(&pst); + } + else + isup_log_err(pid,"Failure indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_MAINTENANCE_IND: + { + if(event_handle->h_isup_maintenance_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_maintenance_ind\r\n"); + switch(eventType) + { + case EN_NONE: + break; + case EN_T5_TIMEOUT: + pst.su_proc_id = isup_db.port_pond[pid].su_proc_id; + event_handle->h_isup_maintenance_ind(&pst,eventType); + default: + pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; + event_handle->h_isup_maintenance_ind(&pst,eventType); + break; + } + } + else + isup_log_err(pid,"Maintenance indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_STARTRESET_IND: + { + if(event_handle->h_isup_startreset_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_startreset_ind\r\n"); + event_handle->h_isup_startreset_ind(&pst); + } + else + isup_log_err(pid,"StartReset indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_DATA_IND: + { + if(event_handle->h_isup_data_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_data_ind\r\n"); + event_handle->h_isup_data_ind(&pst, eventType, &isup_rv_pdus, isup_rv_msg.msgList, isup_rv_msg.len); + } + else + isup_log_err(pid,"Data indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } +//M + case ISUP_BLOCK_IND: + { + if(event_handle->h_isup_block_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_block_ind\r\n"); + if(eventType == EN_GROUP) + event_handle->h_isup_block_ind(&pst, &isup_rv_pdus.m.cirGrpBlk); + else + event_handle->h_isup_block_ind(&pst, NULL); + } + else + isup_log_err(pid,"Block indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_BLOCK_CNF: + { + if(event_handle->h_isup_block_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_block_cnf\r\n"); + pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; + if(eventType == EN_GROUP) + event_handle->h_isup_block_cnf(&pst, &isup_rv_pdus.m.cirGrpBlkAck); + else + event_handle->h_isup_block_cnf(&pst, NULL); + } + else + isup_log_err(pid,"Block confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_UNBLOCK_IND: + { + if(event_handle->h_isup_unblock_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_unblock_ind\r\n"); + if(eventType == EN_GROUP) + event_handle->h_isup_unblock_ind(&pst, &isup_rv_pdus.m.cirGrpUnblk); + else + event_handle->h_isup_unblock_ind(&pst, NULL); + } + else + isup_log_err(pid,"Unblock indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_UNBLOCK_CNF: + { + if(event_handle->h_isup_unblock_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_unblock_cnf\r\n"); + pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; + if(eventType == EN_GROUP) + event_handle->h_isup_unblock_cnf(&pst, &isup_rv_pdus.m.cirGrpUblkAck); + else + event_handle->h_isup_unblock_cnf(&pst, NULL); + } + else + isup_log_err(pid,"Unblock confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + + case ISUP_RESET_IND: + { + if(event_handle->h_isup_reset_ind != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_reset_ind\r\n"); + if(eventType == EN_GROUP) + event_handle->h_isup_reset_ind(&pst, &isup_rv_pdus.m.cirGrpRes); + else + event_handle->h_isup_reset_ind(&pst, NULL); + } + else + isup_log_err(pid,"Reset indicate handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_RESET_CNF: + { + if(event_handle->h_isup_reset_cnf != NULL) + { + isup_trace_func(pid,"APP => function trace: isup_reset_cnf\r\n"); + pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; + if(eventType == EN_GROUP) + event_handle->h_isup_reset_cnf(&pst, &isup_rv_pdus.m.cirGrpResAck); + else + event_handle->h_isup_reset_cnf(&pst, NULL); + } + else + isup_log_err(pid,"Reset confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + case ISUP_STOP_CNF: + { +// if(event_handle->h_isup_stop_cnf != NULL) +// { + isup_trace_func(pid,"APP => function trace: isup_stop_cnf\r\n"); +// event_handle->h_isup_stop_cnf(&pst); +// } +// else +// isup_log_err(pid,"Stop confirm handle is not registered@%s\r\n", __FUNCTION__); + break; + } + default: + break; + } + return 1; +} + + +void isup_cpc_proc(u32 pid) +{ + u8 call_state; + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + call_state= port_ptr->cic_state.call_state; + + if(call_state==CALLOUT_FLAG) + isup_cpco_proc(pid); + else + isup_cpci_proc(pid); +} + +void isup_cpc_timer(u32 pid) +{ + u16 timer_flag; + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + timer_flag= port_ptr->timer_flag; + + if(timer_flag&CALLIN_FLAG) + isup_cpci_timer(pid); + else if(timer_flag&CALLOUT_FLAG) + isup_cpco_timer(pid); + return; +} + +void isup_cpci_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + int circuit_id,variant; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + circuit_id = pid/ISUP_CIRCUIT_CIC; + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return; + } + + variant = cg_str->attrib.variant; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCI_IDLE: + { + if(port_ptr->sprc_cmd == M_IAM) + { + port_ptr->sprc_cmd = 0; + if(isup_rv_pdus.m.initAddr.cgPtyCat.cgPtyCat!=TEST_CALL) + { + if (port_ptr->cic_state.blo_state & M_REMOTE_BLOCK) //Remotely blocked + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CPCI; + isup_blr_proc(pid); + port_ptr->internal_cmd = 0; + } + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) //Locally blocked + { + port_ptr->internal_cmd = CMD_BLO|SI_CPCI; + isup_bls_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + break; + } + } + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; + isup_event_handle(pid, ISUP_SETUP_IND, EN_NONE); + + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + isup_sd_pdus.m.relComplete.causeDgn.pres = 0; + isup_send_msg(pid,M_RLC); + isup_cpc_clear(pid); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + isup_log_err(pid,"Discard pid=%ld\r\n",pid); + isup_cpc_clear(pid); + } + else if(port_ptr->sprc_cmd != 0) //Unexpected message + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = CMD_RESET|SI_CPCI; + isup_crs_proc(pid); + port_ptr->internal_cmd = 0; + isup_log_err(pid,"unexpected message cpci idle pid=%ld\r\n",pid); + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_crr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { +// port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_cgrr_proc(pid); + isup_cpc_clear(pid); + } + break; + } + case CPCI_WAIT_CONTINUITY: + break; + case CPCI_WAIT_ACM: + { + if(port_ptr->primitive_cmd == ISUP_ALERT_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_ACM); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_ANM; + } + else if(port_ptr->primitive_cmd == ISUP_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_CON); + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_SAM) + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_INFO_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + port_ptr->internal_cmd = CMD_RESET|SI_CPCI; + isup_crs_proc(pid); + port_ptr->internal_cmd = 0; + isup_log_err(pid,"unexpected message cpci wait acm pid=%ld",pid); + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_STARTRESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } +// else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) +// { +// port_ptr->internal_cmd = 0; +// isup_cpc_clear(pid); +// isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); +// } + break; + } + case CPCI_WAIT_ANM: + { + if(port_ptr->primitive_cmd == ISUP_SETUP_RSP) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_ANM); + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == ISUP_PROG_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_CPG); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if((port_ptr->sprc_cmd == M_SUS) && (variant == VARIANT_UK)) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->re_cause = 0x6f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + } + case CPCI_ANSWERED: + { + if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.sus_state = ISUP_TERM_SUSPEND; + isup_send_msg(pid,M_SUS); + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == ISUP_PROG_REQ)//supplementary service + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_CPG); + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + port_ptr->cic_state.sus_state = ISUP_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; + isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_CPG) //supplementary service + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + } + case CPCI_SUSPENDED: + { + if(port_ptr->primitive_cmd == ISUP_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_RES); + if(port_ptr->cic_state.sus_state == ISUP_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + } + else if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_SUS); + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + if(port_ptr->cic_state.sus_state == ISUP_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; + isup_event_handle(pid, ISUP_RESUME_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + } + case CPCI_WAIT_RLC: + { + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + isup_sd_pdus.m.relComplete.causeDgn.pres = 0; + isup_send_msg(pid,M_RLC); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_crr_proc(pid); + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { +// port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + isup_cgrr_proc(pid); + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + } + break; + } + case CPCI_WAIT_REL_COMP: + { + if(port_ptr->primitive_cmd == ISUP_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_RLC); + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_crr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { +// port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_cgrr_proc(pid); + isup_cpc_clear(pid); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + } + case CPCI_WAIT_RESET: + { + if(port_ptr->primitive_cmd == ISUP_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_crr_proc(pid); + isup_cgrr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + } + break; + case CPCI_WAIT_GROUP_RESET: + { + if(port_ptr->primitive_cmd == ISUP_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; + isup_crr_proc(pid); + isup_cgrr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + } + default: + break; + } + return; +} + +void isup_cpci_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCI_WAIT_RLC: + { + if(++(port_ptr->w_time)%isup_timer_var.t1==0) + { + if(port_ptr->w_time%isup_timer_var.t5==0) + { + port_ptr->timer_flag &= ~(CALLIN_FLAG); + port_ptr->internal_cmd = CMD_RESET|SI_CPCI; + isup_crs_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T5_TIMEOUT); + return; + } + else + { + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + } + } + } + default: + break; + } + + return; +} +void isup_cpco_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + int circuit_id,variant; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + circuit_id = pid/ISUP_CIRCUIT_CIC; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return; + } + + variant = cg_str->attrib.variant; + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCO_IDLE: + if(port_ptr->primitive_cmd == ISUP_SETUP_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_IAM); + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ACM; + } + else + isup_cpc_clear(pid); + break; + case CPCO_WAIT_CONTINUITY: + break; + case CPCO_WAIT_ACM: + if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == ISUP_INFO_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_SAM); + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + } + else if(port_ptr->sprc_cmd == M_ACM) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_ANM; + isup_event_handle(pid, ISUP_ALERT_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_CON) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + isup_event_handle(pid, ISUP_SETUP_CNF, EN_CON); + } + else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + isup_event_handle(pid, ISUP_SETUP_CNF, EN_ANM); + } + else if(port_ptr->sprc_cmd == M_CPG) + { + isup_log_err(pid,"Discard M_CPG\r\n"); + port_ptr->sprc_cmd = 0; //discard... + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_IAM) + { + if(get_priority(pid)==0) //reattempt + { + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + + port_ptr->cic_state.call_state = CALLIN_FLAG; + isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); + isup_cpci_proc(pid); + break; + } + isup_log_err(pid,"Priority high,Discard IAM\r\n"); + port_ptr->sprc_cmd = 0; + } + else if(port_ptr->sprc_cmd != 0) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->internal_cmd = CMD_RESET|SI_CPCO; + isup_crs_proc(pid); + port_ptr->internal_cmd = 0; + isup_log_err(pid,"unexpected message cpco wait acm\r\n"); + isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); + isup_cpc_clear(pid); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_BLO) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag |= CALLOUT_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); + port_ptr->primitive_cmd = ISUP_RESET_RSP; + isup_cpc_proc(pid); + port_ptr->primitive_cmd = 0; + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + } + break; + case CPCO_WAIT_ANM: + if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->primitive_cmd = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + } + else if(port_ptr->sprc_cmd == M_ANM) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + isup_event_handle(pid, ISUP_SETUP_CNF,EN_ANM); + } + else if(port_ptr->sprc_cmd == M_CPG) + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if((port_ptr->sprc_cmd == M_SUS) && (variant == VARIANT_UK)) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= CALLIN_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x6f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + } + break; + case CPCO_ANSWERED: + if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_SUS); + port_ptr->cic_state.sus_state = ISUP_ORIG_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->primitive_cmd == ISUP_PROG_REQ)//supplementary service + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_CPG); + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + port_ptr->cic_state.sus_state = ISUP_TERM_SUSPEND; + port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; + isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_CPG) //supplementary service + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + } + break; + case CPCO_SUSPENDED: + if(port_ptr->primitive_cmd == ISUP_RESUME_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_RES); + if(port_ptr->cic_state.sus_state == ISUP_ORIG_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + } + else if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_SUS); + } + else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; + port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; + isup_send_msg(pid,M_REL); + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + } + else if(port_ptr->sprc_cmd == M_RES) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + if(port_ptr->cic_state.sus_state == ISUP_TERM_SUSPEND) + port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; + isup_event_handle(pid, ISUP_RESUME_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_SUS) + { + port_ptr->sprc_cmd = 0; + isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; + isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= (CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; + isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + + } + break; + case CPCO_WAIT_RLC: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_REL) + { + port_ptr->sprc_cmd = 0; + isup_sd_pdus.m.relComplete.causeDgn.pres = 0; + isup_send_msg(pid,M_RLC); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_crr_proc(pid); + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; +// port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_cgrr_proc(pid); + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->w_time = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); + } + break; + case CPCO_WAIT_REL_COMP: + if(port_ptr->primitive_cmd == ISUP_RELEASE_RSP) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_RLC); + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) + { + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_crr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; +// port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_cgrr_proc(pid); + isup_cpc_clear(pid); + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + case CPCO_WAIT_RESET: + if(port_ptr->primitive_cmd == ISUP_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_crr_proc(pid); + isup_cgrr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + case CPCO_WAIT_GROUP_RESET: + if(port_ptr->primitive_cmd == ISUP_RESET_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; + isup_crr_proc(pid); + isup_cgrr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + } + break; + default: + break; + } + return; +} + +void isup_cpco_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + + switch(port_ptr->fsm_state.cpc_state) + { + case CPCO_WAIT_ACM: + if(++(port_ptr->w_time)%isup_timer_var.t7==0) + { + port_ptr->w_time = 0; + port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; + port_ptr->re_cause = 0x1f; + port_ptr->re_location = 4; + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); + } + break; + case CPCO_WAIT_RLC: + if(++(port_ptr->w_time)%isup_timer_var.t1==0) + { + if(port_ptr->w_time%isup_timer_var.t5==0) + { + port_ptr->timer_flag &= ~(CALLOUT_FLAG); + port_ptr->internal_cmd = CMD_RESET|SI_CPCO; + isup_crs_proc(pid); + port_ptr->internal_cmd = 0; + isup_cpc_clear(pid); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T5_TIMEOUT); + } + else + { + set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); + isup_send_msg(pid,M_REL); + } + } + break; + default: + break; + } + return; +} + + +void isup_csc_timer(u32 pid) +{ + u16 timer_flag; + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + timer_flag= port_ptr->timer_flag; + + if(timer_flag&BLS_FLAG) + isup_bls_timer(pid); + + if(timer_flag&MGBS_FLAG) + isup_mgbs_timer(pid); + + if(timer_flag&CRS_FLAG) + isup_crs_timer(pid); + + if(timer_flag&CGRS_FLAG) + isup_cgrs_timer(pid); + return; +} + +void isup_bls_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.bls_state) + { + case BLS_IDLE: + { + if(port_ptr->primitive_cmd == ISUP_BLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; + + port_ptr->internal_cmd = CMD_BLO|SI_BLS; + isup_cpc_proc(pid); + port_ptr->internal_cmd = 0; + + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_BLO); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_BLA) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.bls_state = BLS_WAIT_UBA; + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_UBL); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; + port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; + } + break; + } + case BLS_WAIT_BLA: + { + if(port_ptr->sprc_cmd == M_BLA) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; + port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; + if(port_ptr->w_time>=isup_timer_var.t13) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + isup_event_handle(pid, ISUP_BLOCK_CNF, EN_NONE); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); + port_ptr->fsm_state.bls_state = BLS_IDLE; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || + port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); + port_ptr->fsm_state.bls_state = BLS_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; + port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; + if(port_ptr->w_time>=isup_timer_var.t13) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_CRR) || + port_ptr->internal_cmd == (CMD_BLO|SI_CPCI)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_BLO); + } + break; + } + case BLS_LOCAL_LOCKED: + { + if(port_ptr->sprc_cmd == M_UBA) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_BLO); + port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; + } + else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_UBL); + port_ptr->fsm_state.bls_state = BLS_WAIT_UBA; + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_CRR) || + port_ptr->internal_cmd == (CMD_BLO|SI_CPCI)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag |= BLS_FLAG; + port_ptr->w_time = 0; + isup_send_msg(pid,M_BLO); + port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || + port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); + port_ptr->fsm_state.bls_state = BLS_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); + port_ptr->fsm_state.bls_state = BLS_IDLE; + } + break; + } + case BLS_WAIT_UBA: + { + if(port_ptr->sprc_cmd == M_UBA) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); + port_ptr->fsm_state.bls_state = BLS_IDLE; + if(port_ptr->w_time>=isup_timer_var.t15) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + isup_event_handle(pid, ISUP_UNBLOCK_CNF, EN_NONE); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; + port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(BLS_FLAG); + port_ptr->w_time = 0; + port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; + port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; + } + break; + } + } + return; +} + +void isup_bls_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.bls_state) + { + case BLS_WAIT_BLA: + { + if(++(port_ptr->w_time)%isup_timer_var.t12==0) + { + if(port_ptr->w_timew_time%isup_timer_var.t13==0) + { + isup_send_msg(pid,M_BLO); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T13_TIMEOUT); + } + } + } + break; + case BLS_WAIT_UBA: + { + if(++(port_ptr->w_time)%isup_timer_var.t14==0) + { + if(port_ptr->w_timew_time%isup_timer_var.t15==0) + { + isup_send_msg(pid,M_UBL); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T15_TIMEOUT); + } + } + break; + } + } + return; +} + +void isup_blr_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + + switch(port_ptr->fsm_state.blr_state) + { + case BLR_IDLE: + { + if(port_ptr->sprc_cmd == M_BLO) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.blr_state = BLR_WAIT_BLOCKING_RESP; + port_ptr->internal_cmd = CMD_BLO|SI_BLR; + isup_cpc_proc(pid); + port_ptr->internal_cmd = 0; + isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); + } + else if(port_ptr->sprc_cmd == M_UBL) + { + port_ptr->sprc_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + isup_send_msg(pid,M_UBA); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + break; + } + case BLR_WAIT_BLOCKING_RESP: + { + if(port_ptr->primitive_cmd == ISUP_BLOCK_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + isup_send_msg(pid,M_BLA); + } + else if(port_ptr->sprc_cmd == M_UBL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.blr_state = BLR_WAIT_UNBLOCKING_RESP; + isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRR) || + port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || + port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_CLEAR_BLR); + } + break; + } + case BLR_REMOTE_LOCKED: + { + if(port_ptr->sprc_cmd == M_BLO) + { + port_ptr->sprc_cmd = 0; + isup_send_msg(pid,M_BLA); + } + else if(port_ptr->sprc_cmd == M_UBL) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.blr_state = BLR_WAIT_UNBLOCKING_RESP; + isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBR)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + } + else if((port_ptr->internal_cmd & 0x0F) == CMD_UNBLO) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_CLEAR_BLR); + } + break; + } + case BLR_WAIT_UNBLOCKING_RESP: + { + if(port_ptr->sprc_cmd == M_BLO) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.blr_state = BLR_WAIT_BLOCKING_RESP; + isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); + } + else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_RSP) + { + port_ptr->primitive_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + isup_send_msg(pid,M_UBA); + } + else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRR) || + port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRR)|| + port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBR)|| + port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); + port_ptr->fsm_state.blr_state = BLR_IDLE; + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + } + else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; + port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; + isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); + } + break; + } + } + return; +} + + +void isup_mgbr_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.mgbr_state) + { + case MGBR_IDLE: + if(port_ptr->sprc_cmd == M_CGB) + { + port_ptr->sprc_cmd = 0; + if((isup_rv_pdus.m.cirGrpBlk.rangStat.range > 0) && + (isup_rv_pdus.m.cirGrpBlk.rangStat.range <= 31)) + { + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_BLOCKING_RESP; + isup_cpcoblocking_func(pid,&isup_rv_pdus.m.cirGrpBlk.rangStat); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + isup_event_handle(pid, ISUP_BLOCK_IND, EN_GROUP); + } + } + else if(port_ptr->sprc_cmd == M_CGU) + { + port_ptr->sprc_cmd = 0; + if((isup_rv_pdus.m.cirGrpBlk.rangStat.range > 0) && + (isup_rv_pdus.m.cirGrpBlk.rangStat.range <= 31)) + { + port_ptr->fsm_state.mgbr_state = MGBR_WAIT_UNBLOCKING_RESP; + isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_GROUP); + } + } + break; + case MGBR_WAIT_BLOCKING_RESP: + if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else if(port_ptr->primitive_cmd == ISUP_BLOCK_RSP) + { + port_ptr->primitive_cmd = 0; + isup_send_msg(pid,M_CGBA); + isup_blrblocking_func(pid,&isup_sd_pdus.m.cirGrpBlkAck.rangStat); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + case MGBR_WAIT_UNBLOCKING_RESP: + if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_RSP) + { + port_ptr->primitive_cmd = 0; + isup_blrunblocking_func(pid,&isup_sd_pdus.m.cirGrpUblkAck.rangStat); + isup_send_msg(pid,M_CGUA); + port_ptr->fsm_state.mgbr_state = MGBR_IDLE; + } + break; + default: + break; + } + return; +} + + +void isup_mgbs_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.mgbs_state) + { + case MGBS_IDLE: + if(port_ptr->primitive_cmd ==ISUP_BLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + isup_blsblocking_func(pid,&isup_sd_pdus.m.cirGrpBlk.rangStat); + port_ptr->re_typeInd = isup_sd_pdus.m.cirGrpBlk.cgsmti.typeInd; + memcpy(&port_ptr->re_rangStat,&isup_sd_pdus.m.cirGrpBlk.rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGB); + port_ptr->timer_flag |= MGBS_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGBA; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->re_typeInd = isup_sd_pdus.m.cirGrpUnblk.cgsmti.typeInd; + memcpy(&port_ptr->re_rangStat,&isup_sd_pdus.m.cirGrpUnblk.rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGU); + port_ptr->timer_flag |= MGBS_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGUA; + } + else if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + isup_log_err(pid,"Discard M_CGBA\r\n"); + //discard + } + else if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + isup_log_err(pid,"Discard M_CGUA\r\n"); + //discard + } + break; + case MGBS_WAIT_CGBA: + if(port_ptr->sprc_cmd == M_CGBA) + { + port_ptr->sprc_cmd = 0; + if(port_ptr->w_time>=isup_timer_var.t19) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_BLOCK_CNF, EN_GROUP); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + else if (port_ptr->internal_cmd == (CMD_RESET|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + break; + case MGBS_WAIT_CGUA: + if(port_ptr->sprc_cmd == M_CGUA) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_blsunblocking_func(pid,&isup_rv_pdus.m.cirGrpUblkAck.rangStat); + if(port_ptr->w_time>=isup_timer_var.t21) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + isup_event_handle(pid, ISUP_UNBLOCK_CNF, EN_GROUP); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRS)) + { + port_ptr->internal_cmd = 0; + port_ptr->timer_flag &= ~(MGBS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.mgbs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + break; + default: + break; + } + return; + +} + +void isup_mgbs_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.mgbs_state) + { + case MGBS_WAIT_CGBA: + { + if(++(port_ptr->w_time)%isup_timer_var.t18==0) + { + if(port_ptr->w_timere_typeInd; + memcpy(&isup_sd_pdus.m.cirGrpBlk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGB); + } + else if(port_ptr->w_time%isup_timer_var.t19==0) + { + isup_sd_pdus.m.cirGrpBlk.cgsmti.typeInd = port_ptr->re_typeInd; + memcpy(&isup_sd_pdus.m.cirGrpBlk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGB); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T19_TIMEOUT); + } + } + break; + } + case MGBS_WAIT_CGUA: + { + if(++(port_ptr->w_time)%isup_timer_var.t20==0) + { + if(port_ptr->w_timere_typeInd; + memcpy(&isup_sd_pdus.m.cirGrpUnblk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGU); + } + else if(port_ptr->w_time%isup_timer_var.t21==0) + { + isup_sd_pdus.m.cirGrpUnblk.cgsmti.typeInd = port_ptr->re_typeInd; + memcpy(&isup_sd_pdus.m.cirGrpUnblk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); + isup_send_msg(pid,M_CGU); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T21_TIMEOUT); + } + } + break; + } + default: + break; + } + return; +} + + + +void isup_crs_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.crs_state) + { + case CRS_IDLE: + { + if((port_ptr->internal_cmd & 0x0F) == CMD_RESET || + port_ptr->primitive_cmd == ISUP_RESET_REQ) + { + port_ptr->fsm_state.crs_state = CRS_WAIT_REL; + port_ptr->timer_flag |= CRS_FLAG; + port_ptr->w_time = 0; + + if(port_ptr->primitive_cmd == ISUP_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->reset_flag = 2; + port_ptr->internal_cmd = CMD_RESET|SI_CRS; + isup_cpc_proc(pid); + port_ptr->internal_cmd = 0; + } + else + { + port_ptr->internal_cmd = 0; + port_ptr->reset_flag = 0; +// isup_event_handle(pid, ISUP_STARTRESET_IND, EN_NONE); + } + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_bls_proc(pid); + port_ptr->internal_cmd = 0; + } + + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_blr_proc(pid); + port_ptr->internal_cmd = 0; + } + + isup_send_msg(pid,M_RSC); + port_ptr->cic_state.call_state = START_RESET; + } + } + break; + case CRS_WAIT_REL: + if(port_ptr->sprc_cmd == M_RLC) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CRS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.crs_state = CRS_IDLE; + port_ptr->cic_state.call_state = IDLE_FLAG; + if(port_ptr->reset_flag == 2) + isup_event_handle(pid, ISUP_RESET_CNF, EN_NONE); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(CRS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.crs_state = CRS_IDLE; + port_ptr->cic_state.call_state = IDLE_FLAG; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + break; + default: + break; + } + return; +} + +void isup_crs_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + if(port_ptr->fsm_state.crs_state == CRS_WAIT_REL) + { + port_ptr->cic_state.call_state = START_RESET; + if(++(port_ptr->w_time)%isup_timer_var.t16==0) + { + if(port_ptr->w_timecic_state.blo_state & M_LOCAL_BLOCK)//Locally block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_bls_proc(pid); + port_ptr->internal_cmd = 0; + } + + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_blr_proc(pid); + port_ptr->internal_cmd = 0; + } + + isup_send_msg(pid,M_RSC); + } + else if(port_ptr->w_time%isup_timer_var.t17==0) + { + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_bls_proc(pid); + port_ptr->internal_cmd = 0; + } + + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; + isup_blr_proc(pid); + port_ptr->internal_cmd = 0; + } + + isup_send_msg(pid,M_RSC); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + } + } + return; +} + + +void isup_crr_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.crr_state) + { + case CRR_IDLE: + if(port_ptr->sprc_cmd == M_RSC) + { + port_ptr->sprc_cmd = 0; + port_ptr->fsm_state.crr_state = CRR_WAIT_RESPONSE; + + if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block + { + port_ptr->internal_cmd = CMD_BLO|SI_CRR; + isup_bls_proc(pid); + port_ptr->internal_cmd = 0; + } + + if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block + { + port_ptr->internal_cmd = CMD_UNBLO|SI_CRR; + isup_blr_proc(pid); + port_ptr->internal_cmd = 0; + } + + port_ptr->internal_cmd = CMD_RESET|SI_CRR; + isup_cpc_proc(pid); + port_ptr->internal_cmd = 0; + } + break; + case CRR_WAIT_RESPONSE: + if((port_ptr->internal_cmd & 0x0F) == CMD_RESET_COMP) + { + port_ptr->internal_cmd = 0; + port_ptr->fsm_state.crr_state = CRR_IDLE; + isup_sd_pdus.m.relComplete.causeDgn.pres = 0; + isup_send_msg(pid,M_RLC); + } + break; + default: + break; + } + return; +} + + + +void isup_cgrr_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.cgrr_state) + { + case CGRR_IDLE: + if(port_ptr->sprc_cmd == M_GRS) + { + port_ptr->sprc_cmd = 0; + if((isup_rv_pdus.m.cirGrpRes.rangNoStat.range > 0) && + (isup_rv_pdus.m.cirGrpRes.rangNoStat.range <= 31)) + { + port_ptr->fsm_state.cgrr_state = CGRR_WAIT_GROUP_RESET_COMP; + port_ptr->internal_cmd = CMD_RESET|SI_CGRR; + isup_mgbr_proc(pid); + port_ptr->internal_cmd = 0; + isup_cgrr_func(pid,&isup_rv_pdus.m.cirGrpRes.rangNoStat); + } + } + break; + case CGRR_WAIT_GROUP_RESET_COMP: + isup_sd_pdus.m.cirGrpResAck.rangStat.range = port_ptr->gourp_range; + memcpy(&isup_sd_pdus.m.cirGrpResAck.rangStat.status,port_ptr->status_field,ISUP_STATUS_LEN); + isup_send_msg(pid,M_GRA); + port_ptr->fsm_state.cgrr_state = CGRR_IDLE; + break; + default: + break; + } + return; +} +void isup_cgrs_proc(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + switch(port_ptr->fsm_state.cgrs_state) + { + case CGRS_IDLE: + if(port_ptr->primitive_cmd == ISUP_RESET_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; + + port_ptr->internal_cmd = CMD_RESET|SI_CGRS; + isup_mgbr_proc(pid); + port_ptr->internal_cmd = 0; + + isup_cgrs_func(pid,isup_sd_pdus.m.cirGrpRes.rangNoStat.range,1); + port_ptr->re_range = isup_sd_pdus.m.cirGrpRes.rangNoStat.range; + isup_send_msg(pid,M_GRS); + port_ptr->timer_flag |= CGRS_FLAG; + port_ptr->w_time = 0; + port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; + } + break; + case CGRS_WAIT_GRA: + if(port_ptr->sprc_cmd == M_GRA) + { + port_ptr->sprc_cmd = 0; + port_ptr->timer_flag &= ~(CGRS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cgrs_state = MGBS_IDLE; + isup_cgrsack_func(pid,&isup_rv_pdus.m.cirGrpResAck.rangStat); + if(port_ptr->w_time>=isup_timer_var.t23) + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + isup_event_handle(pid, ISUP_RESET_CNF, EN_GROUP); + } + else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) + { + port_ptr->primitive_cmd = 0; + port_ptr->timer_flag &= ~(CGRS_FLAG); + port_ptr->w_time = 0; + port_ptr->fsm_state.cgrs_state = MGBS_IDLE; + isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); + } + break; + default: + break; + } + return; +} + + +void isup_cgrs_timer(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + + if(port_ptr->fsm_state.cgrs_state == CGRS_WAIT_GRA) + { + if(++(port_ptr->w_time)%isup_timer_var.t22==0) + { + if(port_ptr->w_timere_range; + isup_send_msg(pid,M_GRS); + } + else if(port_ptr->w_time%isup_timer_var.t23==0) + { + isup_cgrs_func(pid,isup_sd_pdus.m.cirGrpRes.rangNoStat.range,0); + isup_sd_pdus.m.cirGrpRes.rangNoStat.range = port_ptr->re_range; + isup_send_msg(pid,M_GRS); + isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); + } + } + } + return; +} + + + +u8 isup_check_crs_waiting(u32 pid) +{ + ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; + if(port_ptr->fsm_state.crs_state == CRS_WAIT_REL) + return 1; + else + return 0; +} diff --git a/omc/plat/isup/src/isup_if.c b/omc/plat/isup/src/isup_if.c new file mode 100644 index 0000000..c49198c --- /dev/null +++ b/omc/plat/isup/src/isup_if.c @@ -0,0 +1,700 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ +#include "./include/inc.h" +#include "./include/isup_if.h" +#include "./include/isup_struct.h" +#include "./include/isup_debug.h" +#include "./include/isup_def.h" +#include "./include/isup_const.h" + +up_message isup_rv_msg,isup_sd_msg,isup_raw_msg; +SiAllPdus isup_rv_pdus,isup_sd_pdus; +ISUP_Timer_Struct isup_timer_var; +ISUP_Resource_Pond isup_db; + +extern int check_outbound_route(BYTE ni, long dpc, BYTE sls);//mtp3 interface + +static void timer_init(u32 interval_ms) +{ + memset(&isup_timer_var,0,sizeof(isup_timer_var)); + isup_timer_var.t1 = ISUP_T1*1000/interval_ms; + isup_timer_var.t5 = ISUP_T5*1000/interval_ms; + isup_timer_var.t7 = ISUP_T7*1000/interval_ms; + isup_timer_var.t8 = ISUP_T8*1000/interval_ms; + isup_timer_var.t9 = ISUP_T9*1000/interval_ms; + isup_timer_var.t12 = ISUP_T12*1000/interval_ms; + isup_timer_var.t13 = ISUP_T13*1000/interval_ms; + isup_timer_var.t14 = ISUP_T14*1000/interval_ms; + isup_timer_var.t15 = ISUP_T15*1000/interval_ms; + isup_timer_var.t16 = ISUP_T16*1000/interval_ms; + isup_timer_var.t17 = ISUP_T17*1000/interval_ms; + isup_timer_var.t18 = ISUP_T18*1000/interval_ms; + isup_timer_var.t19 = ISUP_T19*1000/interval_ms; + isup_timer_var.t20 = ISUP_T20*1000/interval_ms; + isup_timer_var.t21 = ISUP_T21*1000/interval_ms; + isup_timer_var.t22 = ISUP_T22*1000/interval_ms; + isup_timer_var.t23 = ISUP_T23*1000/interval_ms; + isup_timer_var.t24 = ISUP_T24*1000/interval_ms; + isup_timer_var.t25 = ISUP_T25*1000/interval_ms; + isup_timer_var.t26 = ISUP_T26*1000/interval_ms; + isup_timer_var.t27 = ISUP_T27*1000/interval_ms; + isup_timer_var.t34 = ISUP_T34*1000/interval_ms; + isup_timer_var.t37 = ISUP_T37*1000/interval_ms; +} + + +static int find_port_by_sap(Pst *pst) +{ + const pal_circuit_struct* circuit_str; + + circuit_str = pal_locate_circuit(pst->cg_id, pst->cic); + if(circuit_str == NULL) + { + isup_log_err(0,"illegal cic value! cg_id=%d,cic=%d\r\n",pst->cg_id,pst->cic); + return -1; + } + + if(isup_db.attrib.isup_run_mode == ISUP_DUAL_MODE && + circuit_str->attrib.plat_id != isup_db.attrib.systemID) + { + isup_log_err(0,"error!plat_id=%d,systemID=%d,run_mode=%d,cg_id=%d,cic=%d\r\n", + circuit_str->attrib.plat_id, + isup_db.attrib.systemID, + isup_db.attrib.isup_run_mode, + pst->cg_id, + pst->cic); + return -1; + } + + pst->sp_proc_id = ISUP_CIRCUIT_CIC*circuit_str->id + + (pst->cic - circuit_str->attrib.head_cic); + return 1; +} + + +//static void isup_check_L3status(void) +//{ +// int i; +// for (i = 0; i < ISUP_MAX_CG; i++) +// { +// if (isup_db.cg_pond[i].enable) +// { +// if (check_outbound_route((isup_db.cg_pond[i].attrib.network_id & 3), isup_db.cg_pond[i].attrib.dpc, 0) >= 0) +// { +// //L3 OK +// } +// else +// { +// //L3 Failed +// } +// } +// } +//} +void isup_init(u8 systemID, u32 interval_ms) +{ + u32 stack_size; + if (interval_ms==0) + interval_ms = 10; + printf("Start ISUP module init...\n"); + memset(&isup_db, 0, sizeof(ISUP_Resource_Pond)); + memset(&isup_timer_var, 1, sizeof(ISUP_Timer_Struct)); + memset(&isup_rv_msg, 0, sizeof(up_message)); + memset(&isup_sd_msg, 0, sizeof(up_message)); + memset(&isup_rv_pdus, 0, sizeof(SiAllPdus)); + memset(&isup_sd_pdus, 0, sizeof(SiAllPdus)); + timer_init(interval_ms); + isup_db.attrib.systemID = systemID; + isup_db.attrib.isup_remote_ip = 0; + isup_db.attrib.isup_run_mode = 0; + stack_size = sizeof(ISUP_Resource_Pond) + sizeof(ISUP_Timer_Struct); + isup_debug_init(); + printf("ISUP module init completed, stack size: %ld bytes\n", stack_size); +} + +void isup_timer() +{ + u16 i,j; + u32 offset, pid; + static DWORD cntT50ms = 0; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + if (++cntT50ms >= 5) + { // 50 mini seconds period + cntT50ms = 0; + isup_debug_timer(); +// isup_check_L3status(); + } + + for (i = 0; i <64; i++) + { + if (isup_mdsc_proc()==0) + break; //no message in lower layer + } + + for (i = 0; i enable==0) + continue; + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + continue; + if(cg_str->attrib.protocol!=1)//isup + continue; + + if(isup_db.attrib.isup_run_mode == ISUP_DUAL_MODE && + circuit_str->attrib.plat_id != isup_db.attrib.systemID) + continue; + + offset = ISUP_CIRCUIT_CIC*i; + for (j = 0; j function trace: %s\r\n", __FUNCTION__); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].su_proc_id = pst->su_proc_id; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_SETUP_REQ; + isup_db.port_pond[pst->sp_proc_id].trace_flag = pst->trace_flag; + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + + if(isup_db.port_pond[pst->sp_proc_id].cic_state.call_state == IDLE_FLAG) + { + isup_db.port_pond[pst->sp_proc_id].cic_state.call_state = CALLOUT_FLAG; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduIAM)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + return ISUP_CM_OK; + } + else + { + isup_log_err(pst->sp_proc_id,"Error,call_state=%d\r\n",isup_db.port_pond[pst->sp_proc_id].cic_state.call_state); + return ISUP_CM_FAILED; + } +} + +int isup_setup_anm_rsp(Pst *pst, SiPduANM *ptr_anm, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_SETUP_RSP; + memcpy(&isup_sd_pdus,ptr_anm,sizeof(SiPduANM)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_setup_con_rsp(Pst *pst, SiPduCON *ptr_con, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_SETUP_RSP; + memcpy(&isup_sd_pdus,ptr_con,sizeof(SiPduCON)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + + +int isup_release_req(Pst *pst, SiPduREL *ptr, u8 *raw_data, u8 len ) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_RELEASE_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduREL)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_release_rsp(Pst *pst, SiPduRLC *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_RELEASE_RSP; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduRLC)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_alert_req(Pst *pst, SiPduACM *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + return ISUP_CM_FAILED; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_ALERT_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduACM)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_info_req(Pst *pst, SiPduSAM *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + return ISUP_CM_FAILED; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_INFO_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduSAM)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_prog_req(Pst *pst, SiPduCPG *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + return ISUP_CM_FAILED; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_PROG_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduCPG)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_suspend_req(Pst *pst, SiPduSUS *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + return ISUP_CM_FAILED; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_SUSPEND_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduSUS)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_resume_req(Pst *pst, SiPduRES *ptr, u8 *raw_data, u8 len) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + return ISUP_CM_FAILED; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_RESUME_REQ; + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduRES)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +/*Maintenance*/ +int isup_block_req(Pst *pst, SiPduCGB *ptr ) +{ + if(find_port_by_sap(pst)==-1) + { + isup_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__); + return ISUP_CM_FAILED; + } + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + isup_db.port_pond[pst->sp_proc_id].sm_proc_id = pst->su_proc_id; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_BLOCK_REQ; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduCGB)); + isup_mgbs_proc(pst->sp_proc_id); + } + else + isup_bls_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_block_rsp(Pst *pst, SiPduCGBA *ptr) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_BLOCK_RSP; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduCGBA)); + isup_mgbr_proc(pst->sp_proc_id); + } + else + isup_blr_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_unblock_req(Pst *pst, SiPduCGU *ptr ) +{ + if(find_port_by_sap(pst)==-1) + { + isup_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__); + return ISUP_CM_FAILED; + } + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + isup_db.port_pond[pst->sp_proc_id].sm_proc_id = pst->su_proc_id; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_UNBLOCK_REQ; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduCGU)); + isup_mgbs_proc(pst->sp_proc_id); + } + else + isup_bls_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_unblock_rsp(Pst *pst, SiPduCGUA *ptr) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_UNBLOCK_RSP; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduCGUA)); + isup_mgbr_proc(pst->sp_proc_id); + } + else + isup_blr_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_reset_req(Pst *pst, SiPduGRS *ptr ) +{ + + if(find_port_by_sap(pst)==-1) + { + isup_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__); + return ISUP_CM_FAILED; + } + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + isup_db.port_pond[pst->sp_proc_id].sm_proc_id = pst->su_proc_id; + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_RESET_REQ; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduGRS)); + isup_cgrs_proc(pst->sp_proc_id); + } + else + isup_crs_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_reset_rsp(Pst *pst, SiPduGRA *ptr) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_RESET_RSP; + if(ptr != NULL) + { + memcpy(&isup_sd_pdus,ptr,sizeof(SiPduGRA)); + } + isup_cpc_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + + +int isup_bls_stop_req(Pst *pst) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id == 0 || pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_STOP_REQ; + isup_bls_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + + +int isup_mgbs_stop_req(Pst *pst) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_STOP_REQ; + isup_mgbs_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_crs_stop_req(Pst *pst) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_STOP_REQ; + isup_crs_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + +int isup_cgrs_stop_req(Pst *pst) +{ + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s\r\n", __FUNCTION__); + if(pst->sp_proc_id >= ISUP_MAX_PORT) + { + isup_log_err(0,"[Error] sp_proc_id == %d. ",pst->sp_proc_id); + return ISUP_CM_FAILED; + } + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = ISUP_STOP_REQ; + isup_cgrs_proc(pst->sp_proc_id); + if(isup_db.port_pond[pst->sp_proc_id].primitive_cmd != 0) + { + isup_trace_func(pst->sp_proc_id,"[waring]primitive cmd discard.(cmd=%d)",isup_db.port_pond[pst->sp_proc_id].primitive_cmd); + isup_db.port_pond[pst->sp_proc_id].primitive_cmd = 0; + } + + return ISUP_CM_OK; +} + + +int isup_data_req(Pst *pst, u8 msgType, SiAllPdus *ptr, u8 *raw_data, u8 len) +{ +// if(find_port_by_sap(pst)==-1) +// { +// isup_trace_func(0,"APP => function trace: %s(msgType=%d)\r\n", __FUNCTION__,msgType); +// return ISUP_CM_FAILED; +// } + isup_trace_func(pst->sp_proc_id,"APP => function trace: %s(msgType=%d)\r\n", __FUNCTION__,msgType); + memcpy(&isup_sd_pdus,ptr,sizeof(SiAllPdus)); + + memset(&isup_raw_msg,0,sizeof(up_message)); + isup_raw_msg.len = len; + memcpy(isup_raw_msg.msgList,raw_data,isup_raw_msg.len); + if(isup_send_msg(pst->sp_proc_id,msgType)==-1) + return ISUP_CM_FAILED; + else + return ISUP_CM_OK; +} + + + +int isup_set_run_mode (u8 run_mode, u32 alter_ip) +{ + isup_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__); + isup_db.attrib.isup_run_mode = run_mode % 2; + isup_db.attrib.isup_remote_ip = alter_ip; + return ISUP_CM_OK; +} + +int isup_inquire_cic (u16 cg_id, u32 cic) +{ + Pst pst; + const pal_cg_struct* cg_str; + + pst.cg_id = cg_id; + pst.cic = cic; + + cg_str = pal_cg_ptr(cg_id); + if(cg_str == NULL) + return -3; + + if (check_outbound_route((cg_str->attrib.network_id & 3), cg_str->attrib.dpc, 0) < 0) + return -1; + + if(find_port_by_sap(&pst)==-1) + return -2; + + if(isup_db.port_pond[pst.sp_proc_id].cic_state.call_state == IDLE_FLAG && + !(isup_db.port_pond[pst.sp_proc_id].cic_state.blo_state & M_REMOTE_BLOCK)) + return 1; + else + return 0; +} + + diff --git a/omc/plat/isup/src/isup_msg.c b/omc/plat/isup/src/isup_msg.c new file mode 100644 index 0000000..ee93851 --- /dev/null +++ b/omc/plat/isup/src/isup_msg.c @@ -0,0 +1,7879 @@ +/*=========================================*/ +/* */ +/* */ +/* Author: Zane Yi */ +/* Date: 2007.02.01 */ +/* */ +/*=========================================*/ +#include "./include/inc.h" +#include "./include/isup_if.h" +#include "./include/isup_struct.h" +#include "./include/isup_debug.h" +#include "./include/isup_def.h" +#include "./include/isup_const.h" + + +int siSelUnpkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length, u8 variant); +int siSelPkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type,u8 variant); +void isup_send_cvr(u32 pid); + +extern int isup_transit_msg(u8 *raw_dst, u8 *raw_add, u8 len_add, u8 *raw_org, u8 len_org, u8 variant); +extern u8 isup_msg_test; +extern up_message isup_raw_msg; + + +static int find_port_by_sp(u8 ni, u32 dpc, u32 opc, u32 cic, u32* pid) +{ + const pal_circuit_struct* circuit_str; + + circuit_str = pal_ss7_find_circuit(ni, dpc, opc, cic); + + if(circuit_str == NULL) + { + isup_log_err(0,"illegal cic value! ni=%d,dpc=%d,opc=%d,cic=%d\r\n",ni,opc,dpc,cic); + return -1; + } + + if(isup_db.attrib.isup_run_mode == ISUP_DUAL_MODE && + circuit_str->attrib.plat_id != isup_db.attrib.systemID) + *pid = 0xFFFFFFFF; + else + *pid = ISUP_CIRCUIT_CIC*circuit_str->id + + (cic - circuit_str->attrib.head_cic); + return 1; +} + +static void isup_transmit_func(u32 remote_ip, up_message *upmsg_ptr) +{ + if(isup_rv_msg.cic[1]&0xF0) + upmsg_ptr->cic[1] |= 0x80; + upmsg_ptr->dest_ip = remote_ip; + isup_redirect(upmsg_ptr); + return; +} + +int isup_mdsc_proc() +{ + int ret,circuit_id,cg_id,variant; + u32 pid,cic_val; + u8 msg_type; + u8 *flw_ptr; //message flow pointer + + ISUP_Port_struct *port_ptr; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + + memset(&isup_rv_msg,0,sizeof(isup_rv_msg)); + if(isup_GetMsg(&isup_rv_msg) == 0) + return 0; + + isup_msg_csta(isup_rv_msg.msgList[0],0); + + cic_val = ((isup_rv_msg.cic[1]&0x0F)<<8) + isup_rv_msg.cic[0]; + + if(find_port_by_sp(isup_rv_msg.sio >>6,isup_rv_msg.opc, isup_rv_msg.dpc, cic_val,&pid)==-1) + { + monitor_isup_msg(0,"RV=>",&isup_rv_msg,COL_YELLOW); + return -1; + } + if(pid >= ISUP_MAX_PORT) + { + monitor_isup_msg(0,"RV=>",&isup_rv_msg,COL_YELLOW); + if((isup_rv_msg.cic[1]&0x80) == 0) + { + isup_transmit_func(isup_db.attrib.isup_remote_ip, &isup_rv_msg); + } + else + { + isup_log_err(0,"isup_redirect discard.\r\n"); + } + return -1; + } + monitor_isup_msg(pid,"RV=>",&isup_rv_msg,COL_YELLOW); + port_ptr = &isup_db.port_pond[pid]; + + flw_ptr = isup_rv_msg.msgList; + msg_type = isup_rv_msg.msgList[0]; + flw_ptr++; + memset(&isup_rv_pdus,0,sizeof(isup_rv_pdus)); + + circuit_id = pid/ISUP_CIRCUIT_CIC; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return -1; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return -1; + } + + variant = cg_str->attrib.variant; + + ret = siSelUnpkFun(&isup_rv_pdus,flw_ptr,msg_type,isup_rv_msg.len-1,variant); + if(ret == -2) + { + isup_log_err(pid,"[variant:%d]decode nonsupport message,message type=0x%x\r\n",variant,msg_type); + return -1; + } + else if(ret == -1) + { + isup_log_err(pid,"[variant:%d]decode error,message type=0x%x\r\n",variant,msg_type); + return -1; + } + + if(isup_msg_test) + { + test_isup_msg(msg_type,1); + return 1; + } + + port_ptr->sprc_cmd = msg_type; + + switch(msg_type) + { + case M_ACM: + case M_ANM: + case M_CPG: + case M_CON: + case M_REL: + case M_SUS: + case M_RES: + case M_SAM: + case M_IAM: + case M_RLC: + if((msg_type==M_RLC)&&isup_check_crs_waiting(pid)) + { + isup_crs_proc(pid); + } + else + { + if(port_ptr->cic_state.call_state == START_RESET) + { + port_ptr->sprc_cmd = 0; + isup_log_err(pid,"Discard message, pid=%ld,call_state = Reset\r\n",pid); + } + else if(port_ptr->cic_state.call_state == CALLOUT_FLAG) + isup_cpco_proc(pid); + else + { + port_ptr->cic_state.call_state = CALLIN_FLAG; + isup_cpci_proc(pid); + } + } + break; + case M_BLO: + case M_UBL: + isup_blr_proc(pid); + break; + case M_BLA: + case M_UBA: + isup_bls_proc(pid); + break; + case M_CGB: + case M_CGU: + isup_mgbr_proc(pid); + break; + case M_CGBA: + case M_CGUA: + isup_mgbs_proc(pid); + break; + case M_GRS: + isup_cgrr_proc(pid); + break; + case M_GRA: + isup_cgrs_proc(pid); + break; + case M_RSC: + isup_crr_proc(pid); + break; + case M_UCIC: + isup_event_handle(pid, ISUP_DATA_IND,msg_type); + isup_log_err(pid,"Idle port=%d.\r\n",pid); + memset(port_ptr,0,sizeof(port_ptr)); + break; + case M_CVT: + port_ptr->sprc_cmd = 0; + isup_send_cvr(pid);//send resp + break; + default: + isup_event_handle(pid, ISUP_DATA_IND,msg_type); + port_ptr->sprc_cmd = 0; + break; + } + if(port_ptr->sprc_cmd != 0) + isup_log_err(pid,"ignore the message,message type=0x%x,cg_id=%d,circuit=%d,cic=%d,port=%d\r\n",msg_type,cg_id,circuit_id,cic_val,pid); + port_ptr->sprc_cmd = 0; + monitor_port_state(cic_val,pid); + return 1; +} + + +void isup_msdc_proc(u32 pid, up_message *upmsg_ptr) +{ + u32 circuit_id,offset; + u32 cic_val; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + up_message temp_ptr; + + circuit_id = pid/ISUP_CIRCUIT_CIC; + offset = pid%ISUP_CIRCUIT_CIC; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return; + } + + if(offset > circuit_str->attrib.cic_range) + { + isup_log_err(pid,"CIC out of range.(pid=%d)\n",pid); + return; + } + + cic_val = circuit_str->attrib.head_cic+offset; + + upmsg_ptr->dest_ip = 0xffffffff; + upmsg_ptr->dpc = cg_str->attrib.dpc; + upmsg_ptr->opc = cg_str->attrib.opc; + upmsg_ptr->cic[0] = cic_val & 0xff; + upmsg_ptr->cic[1] = (cic_val >> 8) & 0xff; + upmsg_ptr->sio = (cg_str->attrib.network_id << 6) | ISUP_SI; + + if(isup_raw_msg.msgList != NULL && isup_raw_msg.len > 1) + { + if(upmsg_ptr->msgList[0]==M_PAM) + { + upmsg_ptr->len = isup_raw_msg.len; + memcpy(upmsg_ptr->msgList,isup_raw_msg.msgList,MAX_SS7_MSG_LEN); + monitor_isup_msg(pid,"SD<=(pam)",upmsg_ptr,COL_WHITE); + } + else + { + memset(&temp_ptr,0,sizeof(up_message)); + temp_ptr.len = isup_transit_msg(temp_ptr.msgList,upmsg_ptr->msgList,upmsg_ptr->len,isup_raw_msg.msgList,isup_raw_msg.len,cg_str->attrib.variant); + if(temp_ptr.len) + { + upmsg_ptr->len = temp_ptr.len; + memcpy(upmsg_ptr->msgList,temp_ptr.msgList,MAX_SS7_MSG_LEN); + monitor_isup_msg(pid,"SD<=(t)",upmsg_ptr,COL_WHITE); + } + else + monitor_isup_msg(pid,"SD<=(f)",upmsg_ptr,COL_WHITE); + } + memset(&isup_raw_msg,0,sizeof(up_message)); + } + else + monitor_isup_msg(pid,"SD<=(i)",upmsg_ptr,COL_WHITE); + + isup_msg_csta(upmsg_ptr->msgList[0],1); + if(isup_to_mtp3(upmsg_ptr)<0) + isup_log_err(pid,"send to mtp3 failed.\r\n"); + return; +} + + +int isup_send_msg(u32 pid, u8 msg_type) +{ + int ret,circuit_id,variant; + const pal_circuit_struct* circuit_str; + const pal_cg_struct* cg_str; + up_message *upmsg_ptr = &isup_sd_msg; + + memset(&isup_sd_msg,0,sizeof(isup_sd_msg)); + + circuit_id = pid/ISUP_CIRCUIT_CIC; + + circuit_str = pal_circuit_ptr(circuit_id); + if(circuit_str == NULL) + { + isup_log_err(pid,"circuit_str==NULL\r\n"); + return -1; + } + + cg_str = pal_cg_ptr(circuit_str->cg_id); + if(cg_str == NULL) + { + isup_log_err(pid,"cg_str==NULL\r\n"); + return -1; + } + + variant = cg_str->attrib.variant; + + ret = siSelPkFun(&isup_sd_pdus,upmsg_ptr->msgList+1,msg_type,variant); + if(ret == -2) + { + isup_log_err(pid,"[variant:%d]encode nonsupport message failed,MSG=0x%x\r\n",variant,msg_type); + return -1; + } + else if(ret == -1) + { + isup_log_err(pid,"[variant:%d]encode error,message type=0x%x\r\n",variant,msg_type); + return -1; + } + upmsg_ptr->msgList[0] = msg_type; + upmsg_ptr->len = ret+1; + isup_msdc_proc(pid, upmsg_ptr); + return 1; +} + +/* unpacking functions for ISUP information elements */ +int siUnpkSiAccDelInfo (SiAccDelInfo *pAccDelInfo,u8 *mBuf, u8 length) +{ + pAccDelInfo->pres = 1; + pAccDelInfo->delInd = mBuf[0] & 0x01; + return 1; +} + + + + +int siUnpkAccTrnspt (SiAccTrnspt *pAccTrnspt,u8 *mBuf, u8 length) +{ + pAccTrnspt->pres = 1; + pAccTrnspt->infoLen = length; + memcpy(pAccTrnspt->infoElmts,mBuf,pAccTrnspt->infoLen); + return 1; +} + + + + +int siUnpkAutoCongLvl (SiAutoCongLvl *pAutoCongLvl,u8 *mBuf, u8 length) +{ + pAutoCongLvl->pres = 1; + pAutoCongLvl->auCongLvl = mBuf[0]; + return 1; +} + +int siUnpkBckCalInd (SiBckCalInd *pBckCalInd,u8 *mBuf, u8 length) +{ + pBckCalInd->pres = 1; + pBckCalInd->chrgInd = mBuf[0] & 0x03 ; + pBckCalInd->cadPtyStatInd = (mBuf[0]>>2) & 0x03; + pBckCalInd->cadPtyCatInd = (mBuf[0]>>4) & 0x03; + pBckCalInd->end2EndMethInd = (mBuf[0]>>6) & 0x03; + pBckCalInd->intInd = mBuf[1] & 0x01 ; + pBckCalInd->end2EndInfoInd = (mBuf[1]>>1) & 0x01; + pBckCalInd->isdnUsrPrtInd = (mBuf[1]>>2) & 0x01; + pBckCalInd->holdInd = (mBuf[1]>>3) & 0x01; + pBckCalInd->isdnAccInd = (mBuf[1]>>4) & 0x01; + pBckCalInd->echoCtrlDevInd = (mBuf[1]>>5) & 0x01; + pBckCalInd->sccpMethInd = (mBuf[1]>>6) & 0x03; + return 1; +} + + + + +int siUnpkSiCllDiverInfo (SiCllDiverInfo *pCllDivr,u8 *mBuf, u8 length) +{ + pCllDivr->pres = 1; + pCllDivr->notSuscr = mBuf[0] & 0x07; + pCllDivr->redirRsn = mBuf[0]>>3 &0x0F; + return 1; +} + +int siUnpkSiPropDly (SiPropDly *pPropDly,u8 *mBuf, u8 length) +{ + pPropDly->pres = 1; + pPropDly->delayVal = (mBuf[0]<<8) | mBuf[1]; + return 1; +} + +int siUnpkCallRef (SiCallRef *pCallRef,u8 *mBuf, u8 length) +{ + pCallRef->pres = 1; + pCallRef->callId[0] = mBuf[0]; + pCallRef->callId[1] = mBuf[1]; + pCallRef->callId[2] = mBuf[2]; + pCallRef->pntCde = mBuf[3]|((mBuf[4]&0x3F)<<8); + return 1; +} + +int siUnpkCdPtyNum (SiCdPtyNum *pCdPtyNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pCdPtyNum->pres = 1; + pCdPtyNum->natAddrInd = mBuf[0] & 0x07F; + pCdPtyNum->oddEven = (mBuf[0]>>7) & 0x01; + pCdPtyNum->numPlan = (mBuf[1]>>4) & 0x07; + pCdPtyNum->innInd = (mBuf[1]>>7) & 0x01; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pCdPtyNum->addrSig[j++] = num_ptr[i] & 0x0f; + pCdPtyNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pCdPtyNum->oddEven) && (j > 0)) + j--; + pCdPtyNum->numOfDigit = j; + + return 1; +} + + + +int siUnpkCgPtyNum (SiCgPtyNum *pCgPtyNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pCgPtyNum->pres = 1; + pCgPtyNum->natAddrInd = mBuf[0] & 0x7F; + pCgPtyNum->oddEven = (mBuf[0]>>7) & 0x01; + pCgPtyNum->scrnInd = mBuf[1] & 0x03; + pCgPtyNum->presRest = (mBuf[1]>>2) & 0x03; + pCgPtyNum->numPlan = (mBuf[1]>>4) & 0x07; + pCgPtyNum->niInd = (mBuf[1]>>7) & 0x01; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pCgPtyNum->addrSig[j++] = num_ptr[i] & 0x0f; + pCgPtyNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pCgPtyNum->oddEven) && (j > 0)) + j--; + pCgPtyNum->numOfDigit = j; + + return 1; +} + +int siUnpkCgPtyCat (SiCgPtyCat *pCgPtyCat,u8 *mBuf, u8 length) +{ + pCgPtyCat->pres = 1; + pCgPtyCat->cgPtyCat = mBuf[0]; + return 1; +} + + + +int siUnpkCauseDgn (SiCauseDgn *pCauseDgn,u8 *mBuf, u8 length) +{ + pCauseDgn->pres = 1; + pCauseDgn->location = mBuf[0]&0x0F; + pCauseDgn->cdeStand = (mBuf[0]>>5) &0x03; + + if((mBuf[0]&0x80)==0x80) + { + pCauseDgn->causeVal = mBuf[1]&0x7F; + if(length>2) + { + pCauseDgn->length = (length-2); + memcpy(pCauseDgn->dgnVal,mBuf+2,pCauseDgn->length); + } + } + else + { + pCauseDgn->causeVal = mBuf[2]&0x7F; + if(length>3) + { + pCauseDgn->length = (length-3); + memcpy(pCauseDgn->dgnVal,mBuf+3,pCauseDgn->length); + } + } + + return 1; +} + + + +int siUnpkCirGrpSupMTypInd (SiCirGrpSupMTypInd *pCgsmti,u8 *mBuf, u8 length) +{ + pCgsmti->pres = 1; + pCgsmti->typeInd = mBuf[0]&0x03; + return 1; +} + + + +int siUnpkCirStateInd (SiCirStateInd *pCirStateInd,u8 *mBuf, u8 length) +{ + pCirStateInd->pres = 1; + pCirStateInd->length = length; + memcpy(pCirStateInd->cirSteInd,mBuf,pCirStateInd->length); + return 1; +} + + + +int siUnpkCugIntCode (SiCugIntCode *pCugIntCode,u8 *mBuf, u8 length) +{ + pCugIntCode->pres = 1; + pCugIntCode->dig1 = (mBuf[0]>>4)&0x0F; + pCugIntCode->dig2 = (mBuf[0])&0x0F; + pCugIntCode->dig3 = (mBuf[1]>>4)&0x0F; + pCugIntCode->dig4 = (mBuf[1])&0x0F; + pCugIntCode->binCde = (mBuf[2]<<8)|mBuf[3]; + return 1; +} + +int siUnpkConnectedNum (SiConnectedNum *pConnectedNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pConnectedNum->pres = 1; + pConnectedNum->natAddrInd = mBuf[0] & 0x7F; + pConnectedNum->oddEven = (mBuf[0]>>7) & 0x01; + pConnectedNum->scrnInd = mBuf[1] & 0x03; + pConnectedNum->presRest = (mBuf[1]>>2) & 0x03; + pConnectedNum->numPlan = (mBuf[1]>>4) & 0x07; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pConnectedNum->addrSig[j++] = num_ptr[i] & 0x0f; + pConnectedNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pConnectedNum->oddEven) && (j > 0)) + j--; + pConnectedNum->numOfDigit = j; + + return 1; +} + +int siUnpkConnReq (SiConnReq *pConnReq,u8 *mBuf, u8 length) +{ + pConnReq->pres = 1; + pConnReq->locRef[0] = mBuf[0]; + pConnReq->locRef[1] = mBuf[1]; + pConnReq->locRef[2] = mBuf[2]; + pConnReq->pntCde = mBuf[3]|((mBuf[4]&0x3F)<<8); + pConnReq->protClass = mBuf[5]; + pConnReq->credit = mBuf[6]; + return 1; +} + +int siUnpkContInd (SiContInd *pContInd,u8 *mBuf, u8 length) +{ + pContInd->pres = 1; + pContInd->contInd = mBuf[0]&0x01; + return 1; +} + +int siUnpkSiEchoCtl (SiEchoCtl *pEchoCtl,u8 *mBuf, u8 length) +{ + pEchoCtl->pres = 1; + pEchoCtl->outEchoRsp = mBuf[0]&0x03; + pEchoCtl->incEchoRsp = (mBuf[0]>>2)&0x03; + pEchoCtl->outEchoReq = (mBuf[0]>>4)&0x03; + pEchoCtl->incEchoReq = (mBuf[0]>>6)&0x03; + return 1; +} + +int siUnpkEvntInfo (SiEvntInfo *pEvntInfo,u8 *mBuf, u8 length) +{ + pEvntInfo->pres = 1; + pEvntInfo->evntInd = mBuf[0]&0x7F; + pEvntInfo->evntPresResInd = mBuf[0]>>7&0x01; + return 1; +} + + + +int siUnpkFacInd (SiFacInd *pFacInd,u8 *mBuf, u8 length) +{ + pFacInd->pres = 1; + pFacInd->facInd = mBuf[0]; + return 1; +} + +int siUnpkFwdCallInd (SiFwdCallInd *pFwdCallInd,u8 *mBuf, u8 length) +{ + pFwdCallInd->pres = 1; + pFwdCallInd->natIntCallInd = mBuf[0] & 0x01; + pFwdCallInd->end2EndMethInd = mBuf[0]>>1 &0x03; + pFwdCallInd->intInd = mBuf[0]>>3 &0x01; + pFwdCallInd->end2EndInfoInd = mBuf[0]>>4 &0x01; + pFwdCallInd->isdnUsrPrtInd = mBuf[0]>>5 &0x01; + pFwdCallInd->isdnUsrPrtPrfInd = mBuf[0]>>6 &0x03; + pFwdCallInd->isdnAccInd = mBuf[1] &0x01; + pFwdCallInd->sccpMethInd = mBuf[1]>>1 &0x03; + return 1; +} + +int siUnpkFreePhParam (SiFreePhInd *pFreePhInd,u8 *mBuf, u8 length){return 1;}//reserved + +int siUnpkSiGenDigits (SiGenDigits *pGenDigits,u8 *mBuf, u8 length) +{ + pGenDigits->pres = 1; + pGenDigits->typeOfDigits = (mBuf[0]) & 0x1F; + pGenDigits->encodeScheme = (mBuf[0]>>5)&0x07; + pGenDigits->length = length-1; + memcpy(pGenDigits->digits, mBuf+1, pGenDigits->length); + return 1; +} + +int siUnpkNotifInd (SiNotifInd *pNotifInd,u8 *mBuf, u8 length) +{ + pNotifInd->pres = 1; + pNotifInd->notifInd = mBuf[0]; + return 1; +} + +int siUnpkSiGenNum (SiGenNum *pGenNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pGenNum->pres = 1; + pGenNum->nmbQual = mBuf[0]; + pGenNum->natAddrInd = mBuf[1] & 0x07F; + pGenNum->oddEven = (mBuf[1]>>7) & 0x01; + pGenNum->scrnInd = mBuf[2] & 0x03; + pGenNum->presRest = (mBuf[2]>>2) & 0x03; + pGenNum->numPlan = (mBuf[2]>>4) & 0x07; + pGenNum->niInd = (mBuf[2]>>7) & 0x01; + + num_ptr = mBuf+3; + for(i = 0, j = 0; i < length-3; i++) + { + pGenNum->addrSig[j++] = num_ptr[i] & 0x0f; + pGenNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pGenNum->oddEven) && (j > 0)) + j--; + pGenNum->numOfDigit = j; + + return 1; +} + +int siUnpkHopCounter (SiHopCounter *pHopCounter,u8 *mBuf, u8 length) +{ + pHopCounter->pres = 1; + pHopCounter->hopCounter = mBuf[0]&0x1F; + return 1; +} + +int siUnpkInfoInd (SiInfoInd *pInfoInd,u8 *mBuf, u8 length) +{ + pInfoInd->pres = 1; + pInfoInd->cgPtyAddrRespInd = mBuf[0] & 0x03; + pInfoInd->holdProvInd = mBuf[0]>>2 & 0x01; + pInfoInd->cgPtyCatRespInd = mBuf[0]>>5 & 0x01; + pInfoInd->chrgInfoRespInd = mBuf[0]>>6 & 0x01; + pInfoInd->solInfoInd = mBuf[0]>>7 & 0x01; + return 1; +} + +int siUnpkInfoReqInd (SiInfoReqInd *pInfoReqInd,u8 *mBuf, u8 length) +{ + pInfoReqInd->pres = 1; + pInfoReqInd->cgPtyAdReqInd = mBuf[0] & 0x01; + pInfoReqInd->holdingInd = mBuf[0]>>1 & 0x01; + pInfoReqInd->cgPtyCatReqInd = mBuf[0]>>3 & 0x01; + pInfoReqInd->chrgInfoReqInd = mBuf[0]>>4 & 0x01; + pInfoReqInd->malCaIdReqInd = mBuf[0]>>7 & 0x01; + return 1; +} + +int siUnpkSiMcidRspInd (SiMcidRspInd *pMcidRsp,u8 *mBuf, u8 length) +{ + pMcidRsp->pres = 1; + pMcidRsp->rspInd = mBuf[0]&0x01; + pMcidRsp->hldInd = (mBuf[0]>>1)&0x01; + return 1; +} + +int siUnpkSiMcidReqInd (SiMcidReqInd *pMcidReq,u8 *mBuf, u8 length) +{ + pMcidReq->pres = 1; + pMcidReq->reqInd = mBuf[0]&0x01; + pMcidReq->hldInd = (mBuf[0]>>1)&0x01; + return 1; +} + +int siUnpkSiMsgCompInfo (SiMsgCompInfo *pMsgCom,u8 *mBuf, u8 length) +{ + pMsgCom->pres = 1; + pMsgCom->tranXInd = mBuf[0]&0x01; + pMsgCom->relCllInd = (mBuf[0]>>1)&0x01; + pMsgCom->sndNotInd = (mBuf[0]>>2)&0x01; + pMsgCom->dcrdMsgInd = (mBuf[0]>>3)&0x01; + pMsgCom->passNotPoss = (mBuf[0]>>4)&0x01; + pMsgCom->bbNbIntwkI = (mBuf[0]>>5)&0x03; + return 1; +} + +int siUnpkSiMlppPrec (SiMlppPrec *pMlppPrec,u8 *mBuf, u8 length) +{ + pMlppPrec->pres = 1; + pMlppPrec->precdLvl = mBuf[0] & 0x0F; + pMlppPrec->lfb = (mBuf[0]>>5) & 0x03; + pMlppPrec->frstDig = (mBuf[1]>>4) & 0x0F; + pMlppPrec->scndDig = (mBuf[1]) & 0x0F; + pMlppPrec->thrdDig = (mBuf[2]>>4) & 0x0F; + pMlppPrec->frthDig = (mBuf[2]) & 0x0F; + pMlppPrec->servDomain = (mBuf[3]<<16)|(mBuf[4]<<8)|mBuf[5]; + return 1; +} + +int siUnpkNatConInd (SiNatConInd *pNatConInd,u8 *mBuf, u8 length) +{ + pNatConInd->pres = 1; + pNatConInd->satInd = mBuf[0] & 0x03; + pNatConInd->contChkInd = mBuf[0]>>2 & 0x03; + pNatConInd->echoCntrlDevInd = mBuf[0]>>4 & 0x01; + return 1; +} + +int siUnpkSiNetSpecFacil (SiNetSpecFacil *pNetFac,u8 *mBuf, u8 length) +{ + pNetFac->pres = 1; + pNetFac->length = length; + memcpy(pNetFac->netFac,mBuf,pNetFac->length); + return 1; +} + +int siUnpkOptBckCalInd (SiOptBckCalInd *pOptBckCalInd,u8 *mBuf, u8 length) +{ + pOptBckCalInd->pres = 1; + pOptBckCalInd->inbndInfoInd = mBuf[0]&0x01; + pOptBckCalInd->caFwdMayOcc = mBuf[0]>>1&0x01; + pOptBckCalInd->simpleSegmInd = mBuf[0]>>2&0x01; + pOptBckCalInd->mlppUserInd = mBuf[0]>>3&0x01; + return 1; +} + +int siUnpkOpFwdCalInd (SiOpFwdCalInd *pOpFwdCalInd,u8 *mBuf, u8 length) +{ + pOpFwdCalInd->pres = 1; + pOpFwdCalInd->clsdUGrpCaInd = mBuf[0]&0x03; + pOpFwdCalInd->simpleSegmInd = mBuf[0]>>2&0x01; + pOpFwdCalInd->conLineIdReqInd = mBuf[0]>>7&0x01; + return 1; +} + +int siUnpkOrigCdNum (SiOrigCdNum *pOrigCdNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pOrigCdNum->pres = 1; + pOrigCdNum->natAddrInd = mBuf[0] & 0x07F; + pOrigCdNum->oddEven = (mBuf[0]>>7) & 0x01; + pOrigCdNum->presRest = (mBuf[1]>>2) & 0x03; + pOrigCdNum->numPlan = (mBuf[1]>>4) & 0x07; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pOrigCdNum->addrSig[j++] = num_ptr[i] & 0x0f; + pOrigCdNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pOrigCdNum->oddEven) && (j > 0)) + j--; + pOrigCdNum->numOfDigit = j; + + return 1; +} + +int siUnpkSigPointCode (SiSigPointCode *pSigPointCode,u8 *mBuf, u8 length) +{ + pSigPointCode->pres = 1; + pSigPointCode->sigPointCode = ((mBuf[1]&0x3F)<<8)|mBuf[0]; + return 1; +} + +int siUnpkSiParmCompInfo (SiParmCompInfo *pParmCom,u8 *mBuf, u8 length) +{ + pParmCom->pres = 1; + pParmCom->length = length; + memcpy(pParmCom->content,mBuf,pParmCom->length); + return 1; +} + +int siUnpkRangStat (SiRangStat *pRangStat,u8 *mBuf, u8 length) +{ + int status_len; + pRangStat->pres = 1; + pRangStat->range = mBuf[0]; + + status_len = ((pRangStat->range&0x07) == 0)? (pRangStat->range>>3) : ((pRangStat->range>>3) + 1); + memcpy(pRangStat->status, mBuf+1, status_len%(ISUP_STATUS_LEN+1)); + if(length > 5) + pRangStat->range = 32; //error and Discard + return 1; +} + +int siUnpkRangNoStat (SiRangNoStat *pRangStat,u8 *mBuf, u8 length) +{ + pRangStat->pres = 1; + pRangStat->range = mBuf[0]; + return 1; +} + +int siUnpkRedirInfo (SiRedirInfo *pRedirInfo,u8 *mBuf, u8 length) +{ + pRedirInfo->pres = 1; + pRedirInfo->redirInd = mBuf[0]&0x07; + pRedirInfo->origRedirReas = mBuf[0]>>4&0x0F; + pRedirInfo->redirCnt = mBuf[1]&0x07; + pRedirInfo->redirReas = mBuf[1]>>4&0x0F; + return 1; +} + +int siUnpkRedirgNum (SiRedirNum *pRedirgNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pRedirgNum->pres = 1; + pRedirgNum->natAddrInd = mBuf[0] & 0x07F; + pRedirgNum->oddEven = (mBuf[0]>>7) & 0x01; + pRedirgNum->presRest = (mBuf[1]>>2) & 0x03; + pRedirgNum->numPlan = (mBuf[1]>>4) & 0x07; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pRedirgNum->addrSig[j++] = num_ptr[i] & 0x0f; + pRedirgNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pRedirgNum->oddEven) && (j > 0)) + j--; + pRedirgNum->numOfDigit = j; + + return 1; +} + +int siUnpkSiRedirRestr (SiRedirRestr *pRedirRstr,u8 *mBuf, u8 length) +{ + pRedirRstr->pres = 1; + pRedirRstr->presRest = mBuf[0]&0x03; + return 1; +} + +int siUnpkSiRemotOper (SiRemotOper *pRemotOper,u8 *mBuf, u8 length) +{ + pRemotOper->pres = 1; + pRemotOper->length = length; + memcpy(pRemotOper->content,mBuf,pRemotOper->length); + return 1; +} + +int siUnpkServiceAct (SiServiceAct *pServiceAct,u8 *mBuf, u8 length) +{ + pServiceAct->pres = 1; + pServiceAct->length = length; + memcpy(pServiceAct->serviceAct,mBuf,pServiceAct->length); + return 1; +} + +int siUnpkSubNum (SiSubNum *pSubNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pSubNum->pres = 1; + pSubNum->oddEven = (mBuf[0]>>7) & 0x01; + + num_ptr = mBuf+1; + for(i = 0, j = 0; i < length-1; i++) + { + pSubNum->addrSig[j++] = num_ptr[i] & 0x0f; + pSubNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pSubNum->oddEven) && (j > 0)) + j--; + pSubNum->numOfDigit = j; + + return 1; +} + +int siUnpkSusResInd (SiSusResInd *pSusResInd,u8 *mBuf, u8 length) +{ + pSusResInd->pres = 1; + pSusResInd->susResInd = mBuf[0]&0x01; + return 1; +} + +int siUnpkTranNetSel (SiTranNetSel *pTranNetSel,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pTranNetSel->pres = 1; + pTranNetSel->netIdPln = mBuf[0] & 0x0F; + pTranNetSel->typNetId = (mBuf[0]>>4) & 0x07; + pTranNetSel->oddEven = (mBuf[0]>>7) & 0x01; + + num_ptr = mBuf+1; + for(i = 0, j = 0; i < length-1; i++) + { + pTranNetSel->netId[j++] = num_ptr[i] & 0x0f; + pTranNetSel->netId[j++] = num_ptr[i] >> 4; + } + if((pTranNetSel->oddEven) && (j > 0)) + j--; + pTranNetSel->numOfDigit = j; + return 1; +} + +int siUnpkTxMedReq (SiTxMedReq *pTxMedReq,u8 *mBuf, u8 length) +{ + pTxMedReq->pres = 1; + pTxMedReq->trMedReq = mBuf[0]; + return 1; +} + +int siUnpkSiUsrServInfo (SiUsrServInfo *pUsrServInfo,u8 *mBuf, u8 length) +{ + pUsrServInfo->pres = 1; + pUsrServInfo->length = length; + memcpy(pUsrServInfo->content,mBuf,pUsrServInfo->length); + return 1; +} + +int siUnpkSiUsrTSrvInfo (SiUsrTSrvInfo *pUsrTSrvInfo,u8 *mBuf, u8 length) +{ + pUsrTSrvInfo->pres = 1; + pUsrTSrvInfo->length = length; + memcpy(pUsrTSrvInfo->content,mBuf,pUsrTSrvInfo->length); + return 1; +} + +int siUnpkUsr2UsrInd (SiUsr2UsrInd *pUsr2UsrInd,u8 *mBuf, u8 length) +{ + pUsr2UsrInd->pres = 1; + pUsr2UsrInd->type = mBuf[0]&0x01; + pUsr2UsrInd->serv1 = (mBuf[0]>>1)&0x03; + pUsr2UsrInd->serv2 = (mBuf[0]>>3)&0x03; + pUsr2UsrInd->serv3 = (mBuf[0]>>5)&0x03; + pUsr2UsrInd->spare = (mBuf[0]>>7)&0x01; + return 1; +} + +int siUnpkUsr2UsrInfo (SiUsr2UsrInfo *pUsr2UsrInfo,u8 *mBuf, u8 length) +{ + pUsr2UsrInfo->pres = 1; + pUsr2UsrInfo->length = length; + memcpy(pUsr2UsrInfo->info, mBuf, pUsr2UsrInfo->length); + return 1; +} + +int siUnpkPassAlng (SiPassAlng *pPassAlng,u8 *mBuf, u8 length) +{ + pPassAlng->pres = 1; + pPassAlng->length = length; + memcpy(pPassAlng->passAlng,mBuf,pPassAlng->length); + return 1; +} + +/* unpacking functions for ITU97/ETSIV3 Information Element */ +int siUnpkSiConfTrtInd (SiConfTrtInd *pConfTrtInd,u8 *mBuf, u8 length) +{ + pConfTrtInd->pres = 1; + pConfTrtInd->confAcceptInd = mBuf[0]&0x03; + if((mBuf[0]&0x80)!=0x80) + { + pConfTrtInd->length = length-1; + memcpy(pConfTrtInd->extInfo,mBuf+1,pConfTrtInd->length); + } + else + pConfTrtInd->length = 0; + return 1; +} + +int siUnpkUidActionInd (SiUidActionInd *pUidActionInd,u8 *mBuf, u8 length) +{ + pUidActionInd->pres = 1; + pUidActionInd->throughConnInstInd = mBuf[0]&0x01; + pUidActionInd->t9InstInd = (mBuf[0]>>1)&0x01; + if((mBuf[0]&0x80)!=0x80) + { + pUidActionInd->length = length-1; + memcpy(pUidActionInd->extInfo,mBuf+1,pUidActionInd->length); + } + else + pUidActionInd->length = 0; + return 1; +} + +int siUnpkBackGVNS (SiBackGVNS *pBackGVNS,u8 *mBuf, u8 length) +{ + pBackGVNS->pres = 1; + pBackGVNS->termAccessInd = mBuf[0]&0x03; + if((mBuf[0]&0x80)!=0x80) + { + pBackGVNS->length = length-1; + memcpy(pBackGVNS->extInfo,mBuf+1,pBackGVNS->length); + } + else + pBackGVNS->length = 0; + + return 1; +} + +int siUnpkDisplayInfo (SiDisplayInfo *pDisplayInfo,u8 *mBuf, u8 length) +{ + pDisplayInfo->pres = 1; + pDisplayInfo->length = length; + memcpy(pDisplayInfo->displayInfo,mBuf,pDisplayInfo->length); + return 1; +} + +int siUnpkForwardGVNS (SiForwardGVNS *pForwardGVNS,u8 *mBuf, u8 length) +{ + int i,j,point; + u8 *num_ptr; + + pForwardGVNS->pres = 1; + point = 0; + //Originating participating service provider + pForwardGVNS->lenInd1 = mBuf[point] & 0x0F; + if(pForwardGVNS->lenInd1 > 4) + pForwardGVNS->lenInd1 = 4; + pForwardGVNS->oddEven1 = (mBuf[point]>>7) & 0x01; + + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < pForwardGVNS->lenInd1; i++) + { + pForwardGVNS->digits1[j++] = num_ptr[i] & 0x0f; + pForwardGVNS->digits1[j++] = num_ptr[i] >> 4; + } + if((pForwardGVNS->oddEven1) && (j > 0)) + j--; + pForwardGVNS->numOfDigit1 = j; + if(pForwardGVNS->numOfDigit1 > 7) + pForwardGVNS->numOfDigit1 = 7; + point +=pForwardGVNS->lenInd1; + + //GVNS user group + pForwardGVNS->lenInd2 = mBuf[point] & 0x0F; + if(pForwardGVNS->lenInd2 > 8) + pForwardGVNS->lenInd2 = 8; + + pForwardGVNS->oddEven2 = (mBuf[point]>>7) & 0x01; + + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < pForwardGVNS->lenInd2; i++) + { + pForwardGVNS->digits2[j++] = num_ptr[i] & 0x0f; + pForwardGVNS->digits2[j++] = num_ptr[i] >> 4; + } + if((pForwardGVNS->oddEven2) && (j > 0)) + j--; + pForwardGVNS->numOfDigit2 = j; + point +=pForwardGVNS->lenInd2; + + //Terminating network routing number + pForwardGVNS->lenInd3 = mBuf[point] & 0x0F; + if(pForwardGVNS->lenInd3 > 9) + pForwardGVNS->lenInd3 = 9; + if(pForwardGVNS->lenInd3 == 0) + pForwardGVNS->lenInd3 = 1; + pForwardGVNS->numPlan = (mBuf[point]>>4) & 0x07; + pForwardGVNS->oddEven3 = (mBuf[point]>>7) & 0x01; + pForwardGVNS->natOfAddr = mBuf[++point] & 0x7f; + + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < pForwardGVNS->lenInd3-1; i++) + { + pForwardGVNS->digits3[j++] = num_ptr[i] & 0x0f; + pForwardGVNS->digits3[j++] = num_ptr[i] >> 4; + } + if((pForwardGVNS->oddEven3) && (j > 0)) + j--; + pForwardGVNS->numOfDigit3 = j; + return 1; +} +int siUnpkCcss (SiCcss *pCcss,u8 *mBuf, u8 length) +{ + pCcss->pres = 1; + pCcss->ccssCallInd = mBuf[0] & 0x01; + return 1; +} +int siUnpkNetMgmtControls (SiNetMgmtControls *pNetMgmtControls,u8 *mBuf, u8 length) +{ + pNetMgmtControls->pres = 1; + pNetMgmtControls->tmpAltRoutInd = mBuf[0] & 0x01; + if((mBuf[0]&0x80)!=0x80) + { + pNetMgmtControls->length = length-1; + memcpy(pNetMgmtControls->extInfo,mBuf+1,pNetMgmtControls->length); + } + else + pNetMgmtControls->length = 0; + return 1; +} +int siUnpkCirAsgnMap (SiCirAsgnMap *pCirAsgnMap,u8 *mBuf, u8 length) +{ + pCirAsgnMap->pres = 1; + pCirAsgnMap->mapType = mBuf[0] & 0x3f; + memcpy(pCirAsgnMap->mapFormat,mBuf+1,4); + return 1; + +} +int siUnpkCorrelationId (SiCorrelationId *pCorrelationId,u8 *mBuf, u8 length) +{ + pCorrelationId->pres = 1; + pCorrelationId->length = length; + memcpy(pCorrelationId->correlationId,mBuf,pCorrelationId->length); + return 1; +} +int siUnpkCallDivTrtInd (SiCallDivTrtInd *pCallDivTrtInd,u8 *mBuf, u8 length) +{ + pCallDivTrtInd->pres = 1; + pCallDivTrtInd->callDivInd = mBuf[0] & 0x03; + if((mBuf[0]&0x80)!=0x80) + { + pCallDivTrtInd->length = length-1; + memcpy(pCallDivTrtInd->extInfo,mBuf+1,pCallDivTrtInd->length); + } + else + pCallDivTrtInd->length = 0; + return 1; +} +int siUnpkCallInNmb (SiCallInNmb *pCallInNmb,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pCallInNmb->pres = 1; + pCallInNmb->natAddrInd = mBuf[0] & 0x07F; + pCallInNmb->oddEven = (mBuf[0]>>7) & 0x01; + pCallInNmb->presRest = (mBuf[1]>>2) & 0x03; + pCallInNmb->numPlan = (mBuf[1]>>4) & 0x07; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pCallInNmb->addrSig[j++] = num_ptr[i] & 0x0f; + pCallInNmb->addrSig[j++] = num_ptr[i] >> 4; + } + if((pCallInNmb->oddEven) && (j > 0)) + j--; + pCallInNmb->numOfDigit = j; + return 1; +} +int siUnpkCallOfferTrtInd (SiCallOfferTrtInd *pCallOfferTrtInd,u8 *mBuf, u8 length) +{ + pCallOfferTrtInd->pres = 1; + pCallOfferTrtInd->callOfferInd = mBuf[0] & 0x03; + if((mBuf[0]&0x80)!=0x80) + { + pCallOfferTrtInd->length = length-1; + memcpy(pCallOfferTrtInd->extInfo,mBuf+1,pCallOfferTrtInd->length); + } + else + pCallOfferTrtInd->length = 0; + return 1; +} +int siUnpkScfId (SiScfId *pScfId,u8 *mBuf, u8 length) +{ + pScfId->pres = 1; + pScfId->length = length; + memcpy(pScfId->scfId,mBuf,pScfId->length); + return 1; +} +int siUnpkUidCapInd (SiUidCapInd *pUidCapInd,u8 *mBuf, u8 length) +{ + pUidCapInd->pres = 1; + pUidCapInd->throughConnInstInd = mBuf[0]&0x01; + pUidCapInd->t9InstInd = (mBuf[0]>>1)&0x01; + if((mBuf[0]&0x80)!=0x80) + { + pUidCapInd->length = length-1; + memcpy(pUidCapInd->extInfo,mBuf+1,pUidCapInd->length); + } + else + pUidCapInd->length = 0; + return 1; +} + +int siUnpkCollCallReq (SiCollCallReq *pCollCallReq,u8 *mBuf, u8 length) +{ + pCollCallReq->pres = 1; + pCollCallReq->collCallReqInd = mBuf[0]&0x01; + return 1; +} +int siUnpkNaPaChgPID (SiNaPaChgPID *pNaPaChgPID,u8 *mBuf, u8 length) +{ + pNaPaChgPID->pres = 1; + pNaPaChgPID->length = length; + memcpy(pNaPaChgPID->naPaChgPtyId,mBuf,pNaPaChgPID->length); + return 1; +} +int siUnpkCallTRef (SiCallTRef *pCallTRef,u8 *mBuf, u8 length) +{ + pCallTRef->pres = 1; + pCallTRef->callTrnsfr = mBuf[0]; + return 1; + +} +int siUnpkLoopPrvntInd (SiLoopPrvntInd *pLoopPrvntInd,u8 *mBuf, u8 length) +{ + pLoopPrvntInd->pres = 1; + pLoopPrvntInd->loopPrvntType = mBuf[0]&0x01; + pLoopPrvntInd->loopPrvntRspInd = (mBuf[0]>>1)&0x03; + return 1; + +} +int siUnpkAppTransParam (SiAppTransParam *pAppTransParam,u8 *mBuf, u8 length) +{ + pAppTransParam->pres = 1; + pAppTransParam->appContextId = mBuf[0]&0x7f; + pAppTransParam->atii = mBuf[1]&0x03; + pAppTransParam->apmSegInd = mBuf[2]&0x3f; + pAppTransParam->seqInd = (mBuf[2]>>6)&0x01; + if((mBuf[2]&0x80)!=0x80) + { + pAppTransParam->slr = mBuf[3]&0x7f; + pAppTransParam->length = length-4; + memcpy(pAppTransParam->encapAppInfo,mBuf+4,pAppTransParam->length); + } + else + { + pAppTransParam->length = length-3; + memcpy(pAppTransParam->encapAppInfo,mBuf+3,pAppTransParam->length); + } + return 1; +} + + +/* unpacking functions for UK specific Information Element */ +int siUnpkSiNatForCalInd (SiNatForCalInd *pNatForCalInd,u8 *mBuf, u8 length) +{ + pNatForCalInd->pres = 1; + pNatForCalInd->cbi = mBuf[0]&0x01; + pNatForCalInd->ntaInd = (mBuf[0]>>1)&0x01; + return 1; +} + +int siUnpkSiNatForCalIndLbL (SiNatForCalIndLbL *pNatForCalIndLbL,u8 *mBuf, u8 length) +{ + pNatForCalIndLbL->pres = 1; + pNatForCalIndLbL->rci = mBuf[0]&0x0f; + if((mBuf[0]&0x80)!=0x80) + pNatForCalIndLbL->isi = mBuf[1]&0x0f; + else + pNatForCalIndLbL->isi = 0; + return 1; +} + +int siUnpkSiPresNum (SiPresNum *pPresNum,u8 *mBuf, u8 length) +{ + int i,j; + u8 *num_ptr; + + pPresNum->pres = 1; + pPresNum->natAddrInd = mBuf[0] & 0x7F; + pPresNum->oddEven = (mBuf[0]>>7) & 0x01; + pPresNum->scrInd = mBuf[1] & 0x03; + pPresNum->presRest = (mBuf[1]>>2) & 0x03; + pPresNum->numPlan = (mBuf[1]>>4) & 0x07; + pPresNum->pnp = (mBuf[1]>>7) & 0x01; + + num_ptr = mBuf+2; + for(i = 0, j = 0; i < length-2; i++) + { + pPresNum->addrSig[j++] = num_ptr[i] & 0x0f; + pPresNum->addrSig[j++] = num_ptr[i] >> 4; + } + if((pPresNum->oddEven) && (j > 0)) + j--; + pPresNum->numOfDigit = j; + + return 1; +} + + + +int siUnpkSiPartCLI (SiPartCLI *pPartCLI,u8 *mBuf, u8 length) +{ + pPartCLI->pres = 1; + pPartCLI->swichTypeD1 = mBuf[0] & 0x0F; + pPartCLI->swichTypeD2 = mBuf[0] >> 4; + pPartCLI->pnoIdD1 = mBuf[1] & 0x0F; + pPartCLI->pnoIdD2 = mBuf[1] >> 4; + pPartCLI->pnoIdD3 = mBuf[2] & 0x0F; + pPartCLI->switchNumD1 = mBuf[2] >> 4; + pPartCLI->switchNumD2 = mBuf[3] & 0x0F; + pPartCLI->switchNumD3 = mBuf[3] >> 4; + memcpy(pPartCLI->agreement,mBuf+4,5); + return 1; +} + +int siUnpkCaldSubBasSerMar (SiCaldSubBasSerMar *pCaldSubBasSerMar,u8 *mBuf, u8 length) +{ + pCaldSubBasSerMar->pres = 1; + pCaldSubBasSerMar->cbInd = mBuf[0] & 0x01 ; + pCaldSubBasSerMar->subIcbInd = (mBuf[0]>>1) & 0x01; + pCaldSubBasSerMar->preIcbInd = (mBuf[0]>>2) & 0x01; + pCaldSubBasSerMar->permIcbInd = (mBuf[0]>>3) & 0x01; + pCaldSubBasSerMar->tosInd = (mBuf[0]>>4) & 0x01; + pCaldSubBasSerMar->ICBExpInd = (mBuf[0]>>5) & 0x01; + pCaldSubBasSerMar->caldSubFacInfInd = (mBuf[0]>>6) & 0x01; + pCaldSubBasSerMar->calgSubFacInfInd = (mBuf[0]>>7) & 0x01; + pCaldSubBasSerMar->permOcbInd = mBuf[1] & 0x01 ; + pCaldSubBasSerMar->ogLocCalBarInd = (mBuf[1]>>1) & 0x01; + pCaldSubBasSerMar->ogNatCalBarInd = (mBuf[1]>>2) & 0x01; + pCaldSubBasSerMar->ogIntCalBarInd = (mBuf[1]>>3) & 0x01; + pCaldSubBasSerMar->opCalBarInd = (mBuf[1]>>4) & 0x01; + pCaldSubBasSerMar->supFacCalBarInd = (mBuf[1]>>5) & 0x01; + pCaldSubBasSerMar->digMaskInd = (mBuf[1]>>6) & 0x01; + pCaldSubBasSerMar->calPreBarInd = (mBuf[1]>>7) & 0x01; + pCaldSubBasSerMar->caldSubTarGp = mBuf[2] & 0x7F; + return 1; +} + +int siUnpkCalgSubBasSerMar (SiCalgSubBasSerMar *pCalgSubBasSerMar,u8 *mBuf, u8 length) +{ + pCalgSubBasSerMar->pres = 1; + pCalgSubBasSerMar->cbInd = mBuf[0] & 0x01 ; + pCalgSubBasSerMar->subIcbInd = (mBuf[0]>>1) & 0x01; + pCalgSubBasSerMar->preIcbInd = (mBuf[0]>>2) & 0x01; + pCalgSubBasSerMar->permIcbInd = (mBuf[0]>>3) & 0x01; + pCalgSubBasSerMar->tosInd = (mBuf[0]>>4) & 0x01; + pCalgSubBasSerMar->ICBExpInd = (mBuf[0]>>5) & 0x01; + pCalgSubBasSerMar->caldSubFacInfInd = (mBuf[0]>>6) & 0x01; + pCalgSubBasSerMar->calgSubFacInfInd = (mBuf[0]>>7) & 0x01; + pCalgSubBasSerMar->permOcbInd = mBuf[1] & 0x01 ; + pCalgSubBasSerMar->ogLocCalBarInd = (mBuf[1]>>1) & 0x01; + pCalgSubBasSerMar->ogNatCalBarInd = (mBuf[1]>>2) & 0x01; + pCalgSubBasSerMar->ogIntCalBarInd = (mBuf[1]>>3) & 0x01; + pCalgSubBasSerMar->opCalBarInd = (mBuf[1]>>4) & 0x01; + pCalgSubBasSerMar->supFacCalBarInd = (mBuf[1]>>5) & 0x01; + pCalgSubBasSerMar->digMaskInd = (mBuf[1]>>6) & 0x01; + pCalgSubBasSerMar->calPreBarInd = (mBuf[1]>>7) & 0x01; + pCalgSubBasSerMar->calgSubTarGp = mBuf[2] & 0x7F; + pCalgSubBasSerMar->opInd = (mBuf[2]>>7) & 0x01; + return 1; +} + +int siUnpkCalgSubOrgFacMar (SiCalgSubOrgFacMar *pCalgSubOrgFacMar,u8 *mBuf, u8 length) +{ + pCalgSubOrgFacMar->pres = 1; + pCalgSubOrgFacMar->disSubInd = mBuf[0] & 0x01 ; + pCalgSubOrgFacMar->attCOI = (mBuf[0]>>1) & 0x01; + pCalgSubOrgFacMar->adDurChgInd = (mBuf[0]>>2) & 0x01; + pCalgSubOrgFacMar->PBXSubInd = (mBuf[0]>>3) & 0x01; + return 1; +} + +int siUnpkCaldSubTermFacMar (SiCaldSubTermFacMar *pCaldSubTermFacMar,u8 *mBuf, u8 length) +{ + pCaldSubTermFacMar->pres = 1; + pCaldSubTermFacMar->sviInd = mBuf[0] & 0x01 ; + pCaldSubTermFacMar->cniInd = (mBuf[0]>>1) & 0x01; + pCaldSubTermFacMar->pbxNigIntInd = (mBuf[0]>>2) & 0x01; + pCaldSubTermFacMar->calWaitInd = (mBuf[0]>>3) & 0x01; + pCaldSubTermFacMar->fixedDestSerInd = (mBuf[0]>>4) & 0x01; + return 1; +} + +int siUnpkNatInfReqInd (SiNatInfReqInd *pNatInfReqInd,u8 *mBuf, u8 length) +{ + pNatInfReqInd->pres = 1; + pNatInfReqInd->calgSubBasSerMarReqInd = mBuf[0] & 0x01 ; + pNatInfReqInd->caldSubBasSerMarReqInd = (mBuf[0]>>1) & 0x01; + pNatInfReqInd->calgSubOrgFacMarReqInd = (mBuf[0]>>2) & 0x01; + pNatInfReqInd->caldSubTerFacMarReqInd = (mBuf[0]>>3) & 0x01; + return 1; +} + + +int siUnpkNatInfInd (SiNatInfInd *pNatInfInd,u8 *mBuf, u8 length) +{ + pNatInfInd->pres = 1; + pNatInfInd->calgSubBasSerMarRespInd = mBuf[0] & 0x01 ; + pNatInfInd->caldSubBasSerMarRespInd = (mBuf[0]>>1) & 0x01; + pNatInfInd->calgSubOrgFacMarRespInd = (mBuf[0]>>2) & 0x01; + pNatInfInd->caldSubTerFacMarRespInd = (mBuf[0]>>3) & 0x01; + return 1; +} + +int siUnpkCirValRspInd (SiCirValRspInd *pCirValRspInd,u8 *mBuf, u8 length) +{ + pCirValRspInd->pres = 1; + pCirValRspInd->cirValRspInd = mBuf[0] & 0x01 ; + return 1; +} + +int siUnpkCirGrpCharInd (SiCirGrpCharInd *pCirGrpCharInd,u8 *mBuf, u8 length) +{ + pCirGrpCharInd->pres = 1; + pCirGrpCharInd->cirGrpCarInd = mBuf[0] & 0x03 ; + pCirGrpCharInd->dblSzCtrlInd = (mBuf[0]>>2) & 0x03 ; + pCirGrpCharInd->alarmCarInd = (mBuf[0]>>4) & 0x03 ; + pCirGrpCharInd->contChkReqInd = (mBuf[0]>>6) & 0x03 ; + return 1; +} + +int siUnpkCirIdName (SiCirIdName *pCirIdName,u8 *mBuf, u8 length) +{ + int i; + pCirIdName->pres = 1; + + for(i=0;i<26;i++) + { + pCirIdName->trunkNumClli[i] = mBuf[i] & 0x7f ; + } + return 1; +} + +int siUnpkCLLI (SiCLLI *pCLLI,u8 *mBuf, u8 length) +{ + int i; + pCLLI->pres = 1; + + for(i=0;i<11;i++) + { + pCLLI->clliCode[i] = mBuf[i] & 0x7f ; + } + return 1; +} + +/* packing functions for ISUP information elements */ +int siPkSiAccDelInfo (SiAccDelInfo *pAccDelInfo,u8 *mBuf) +{ + mBuf[0] = pAccDelInfo->delInd &0x01; + return 1; +} + + +int siPkAccTrnspt (SiAccTrnspt *pAccTrnspt,u8 *mBuf) +{ + memcpy(mBuf,pAccTrnspt->infoElmts,pAccTrnspt->infoLen); + return pAccTrnspt->infoLen; +} + +int siPkAutoCongLvl (SiAutoCongLvl *pAutoCongLvl,u8 *mBuf) +{ + mBuf[0] = pAutoCongLvl->auCongLvl; + return 1; +} + +int siPkBckCalInd (SiBckCalInd *pBckCalInd,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pBckCalInd->chrgInd & 0x03; + mBuf[0] |= (pBckCalInd->cadPtyStatInd & 0x03) << 2; + mBuf[0] |= (pBckCalInd->cadPtyCatInd & 0x03) << 4; + mBuf[0] |= (pBckCalInd->end2EndMethInd & 0x03) << 6; + + mBuf[1] = 0; + mBuf[1] |= pBckCalInd->intInd & 0x01; + mBuf[1] |= (pBckCalInd->end2EndInfoInd & 0x01) << 1; + mBuf[1] |= (pBckCalInd->isdnUsrPrtInd & 0x01) << 2; + mBuf[1] |= (pBckCalInd->holdInd & 0x01) << 3; + mBuf[1] |= (pBckCalInd->isdnAccInd & 0x01) << 4; + mBuf[1] |= (pBckCalInd->echoCtrlDevInd & 0x01) << 5; + mBuf[1] |= (pBckCalInd->sccpMethInd & 0x03) << 6; + + return 2; +} + + + +int siPkSiCllDiverInfo (SiCllDiverInfo *pCllDivr,u8 *mBuf) +{ + mBuf[0] = pCllDivr->notSuscr&0x07; + mBuf[0] |= (pCllDivr->redirRsn & 0x0F) << 3; + return 1; +} + +int siPkSiPropDly (SiPropDly *pPropDly,u8 *mBuf) +{ + mBuf[0] = (pPropDly->delayVal>>8) & 0xFF; + mBuf[1] = pPropDly->delayVal & 0xFF; + return 2; +} + +int siPkCallRef (SiCallRef *pCallRef,u8 *mBuf) +{ + mBuf[0] = pCallRef->callId[0]; + mBuf[1] = pCallRef->callId[1]; + mBuf[2] = pCallRef->callId[2]; + mBuf[3] = pCallRef->pntCde & 0xFF; + mBuf[4] = (pCallRef->pntCde>>8) & 0x3F; + return 5; +} + +int siPkCdPtyNum (SiCdPtyNum *pCdPtyNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pCdPtyNum->numOfDigit/2 + (pCdPtyNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + + pCdPtyNum->oddEven = pCdPtyNum->numOfDigit & 0x01; + + mBuf[0] = pCdPtyNum->natAddrInd & 0x7F; + mBuf[0] |= (pCdPtyNum->oddEven & 0x01) <<7; + mBuf[1] = (pCdPtyNum->numPlan & 0x07) << 4; + mBuf[1] |= (pCdPtyNum->natAddrInd & 0x01) <<7; + + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pCdPtyNum->addrSig[j++] & 0x0f; + num_ptr[i] += pCdPtyNum->addrSig[j++] << 4; + } + + if(pCdPtyNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkCgPtyNum (SiCgPtyNum *pCgPtyNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pCgPtyNum->numOfDigit/2 + (pCgPtyNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + + pCgPtyNum->oddEven = pCgPtyNum->numOfDigit & 0x01; + + mBuf[0] = pCgPtyNum->natAddrInd & 0x7F; + mBuf[0] |= (pCgPtyNum->oddEven & 0x01) <<7; + mBuf[1] = pCgPtyNum->scrnInd & 0x03; + mBuf[1] |= (pCgPtyNum->presRest & 0x03) << 2; + mBuf[1] |= (pCgPtyNum->numPlan & 0x07) << 4; + mBuf[1] |= (pCgPtyNum->niInd & 0x01) <<7; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pCgPtyNum->addrSig[j++] & 0x0f; + num_ptr[i] += pCgPtyNum->addrSig[j++] << 4; + } + + if(pCgPtyNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkCgPtyCat (SiCgPtyCat *pCgPtyCat,u8 *mBuf) +{ + mBuf[0] = pCgPtyCat->cgPtyCat; + return 1; +} + +int siPkCauseDgn (SiCauseDgn *pCauseDgn,u8 *mBuf) +{ + mBuf[0] = 0x80; + mBuf[0] |= pCauseDgn->location&0x0F; + mBuf[0] |= (pCauseDgn->cdeStand & 0x03)<<5; + mBuf[1] = 0x80; + mBuf[1] |= pCauseDgn->causeVal&0x7F; + if(pCauseDgn->length != 0) + memcpy(mBuf+2,pCauseDgn->dgnVal,pCauseDgn->length); + return pCauseDgn->length+2; +} + +int siPkCirGrpSupMTypInd (SiCirGrpSupMTypInd *pCgsmti,u8 *mBuf) +{ + mBuf[0] = pCgsmti->typeInd&0x03; + return 1; +} + +int siPkCirStateInd (SiCirStateInd *pCirStateInd,u8 *mBuf) +{ + memcpy(mBuf,pCirStateInd->cirSteInd,pCirStateInd->length); + return pCirStateInd->length; +} + +int siPkCugIntCode (SiCugIntCode *pCugIntCode,u8 *mBuf) +{ + mBuf[0] = (pCugIntCode->dig1<<4)|(pCugIntCode->dig2&0x0F); + mBuf[1] = (pCugIntCode->dig3<<4)|(pCugIntCode->dig4&0x0F); + mBuf[2] = pCugIntCode->binCde>>8; + mBuf[3] = pCugIntCode->binCde & 0xFF; + return 4; +} + +int siPkConnectedNum (SiConnectedNum *pConnectedNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pConnectedNum->numOfDigit/2 + (pConnectedNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + + pConnectedNum->oddEven = pConnectedNum->numOfDigit & 0x01; + + mBuf[0] = pConnectedNum->natAddrInd & 0x7F; + mBuf[0] |= (pConnectedNum->oddEven & 0x01) <<7; + mBuf[1] = pConnectedNum->scrnInd & 0x03; + mBuf[1] |= (pConnectedNum->presRest & 0x03) << 2; + mBuf[1] |= (pConnectedNum->numPlan & 0x07) << 4; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pConnectedNum->addrSig[j++] & 0x0f; + num_ptr[i] += pConnectedNum->addrSig[j++] << 4; + } + + if(pConnectedNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkConnReq (SiConnReq *pConnReq,u8 *mBuf) +{ + mBuf[0] = pConnReq->locRef[0]; + mBuf[1] = pConnReq->locRef[1]; + mBuf[2] = pConnReq->locRef[2]; + mBuf[3] = pConnReq->pntCde & 0xFF; + mBuf[4] = (pConnReq->pntCde>>8) & 0x3F; + mBuf[5] = pConnReq->protClass; + mBuf[6] = pConnReq->credit; + return 7; +} + +int siPkContInd (SiContInd *pContInd,u8 *mBuf) +{ + mBuf[0] = pContInd->contInd&0x01; + return 1; +} + +int siPkSiEchoCtl (SiEchoCtl *pEchoCtl,u8 *mBuf) +{ + mBuf[0] = pEchoCtl->outEchoRsp & 0x03; + mBuf[0] |= (pEchoCtl->incEchoRsp & 0x03) << 2; + mBuf[0] |= (pEchoCtl->outEchoReq & 0x03) << 4; + mBuf[0] |= (pEchoCtl->incEchoReq & 0x03) << 6; + return 1; +} + +int siPkEvntInfo (SiEvntInfo *pEvntInfo,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pEvntInfo->evntInd & 0x7F; + mBuf[0] |= (pEvntInfo->evntPresResInd &0x01) << 7; + return 1; +} + + +int siPkFacInd (SiFacInd *pFacInd,u8 *mBuf) +{ + mBuf[0] = pFacInd->facInd; + return 1; +} + +int siPkFwdCallInd (SiFwdCallInd *pFwdCallInd,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pFwdCallInd->natIntCallInd & 0x01; + mBuf[0] |= (pFwdCallInd->end2EndMethInd &0x03) << 1; + mBuf[0] |= (pFwdCallInd->intInd &0x01) << 3; + mBuf[0] |= (pFwdCallInd->end2EndInfoInd &0x01) << 4; + mBuf[0] |= (pFwdCallInd->isdnUsrPrtInd &0x01) << 5; + mBuf[0] |= (pFwdCallInd->isdnUsrPrtPrfInd &0x03) << 6; + mBuf[1] |= pFwdCallInd->isdnAccInd &0x01; + mBuf[1] |= (pFwdCallInd->sccpMethInd &0x03) << 1; + return 2; +} + +int siPkFreePhParam (SiFreePhInd *pFreePhInd,u8 *mBuf){return 0;}//reserved + +int siPkSiGenDigits (SiGenDigits *pGenDigits,u8 *mBuf) +{ + mBuf[0] = pGenDigits->typeOfDigits & 0x1F; + mBuf[0] |= (pGenDigits->encodeScheme & 0x07)<<5; + memcpy(mBuf+1, pGenDigits->digits, pGenDigits->length); + return pGenDigits->length + 1; +} + +int siPkNotifInd (SiNotifInd *pNotifInd,u8 *mBuf) +{ + mBuf[0] = pNotifInd->notifInd; + return 1; +} + +int siPkSiGenNum (SiGenNum *pGenNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pGenNum->numOfDigit/2 + (pGenNum->numOfDigit & 0x01); + num_ptr = mBuf+3; + pGenNum->oddEven = pGenNum->numOfDigit & 0x01; + + mBuf[0] = pGenNum->nmbQual; + mBuf[1] = pGenNum->natAddrInd & 0x7F; + mBuf[1] |= (pGenNum->oddEven & 0x01) <<7; + mBuf[2] = pGenNum->scrnInd & 0x03; + mBuf[2] |= (pGenNum->presRest & 0x03) << 2; + mBuf[2] |= (pGenNum->numPlan & 0x07) << 4; + mBuf[2] |= (pGenNum->niInd & 0x01) <<7; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pGenNum->addrSig[j++] & 0x0f; + num_ptr[i] += pGenNum->addrSig[j++] << 4; + } + + if(pGenNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 3; +} + +int siPkHopCounter (SiHopCounter *pHopCounter,u8 *mBuf) +{ + mBuf[0] = pHopCounter->hopCounter&0x1F; + return 1; +} + +int siPkInfoInd (SiInfoInd *pInfoInd,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pInfoInd->cgPtyAddrRespInd & 0x03; + mBuf[0] |= (pInfoInd->holdProvInd& 0x01) <<2 ; + mBuf[0] |= (pInfoInd->cgPtyCatRespInd& 0x01) <<5 ; + mBuf[0] |= (pInfoInd->chrgInfoRespInd& 0x01) <<6 ; + mBuf[0] |= (pInfoInd->solInfoInd& 0x01) <<7; + mBuf[1] = 0; + return 2; +} + +int siPkInfoReqInd (SiInfoReqInd *pInfoReqInd,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pInfoReqInd->cgPtyAdReqInd & 0x01; + mBuf[0] |= (pInfoReqInd->holdingInd & 0x01) <<1; + mBuf[0] |= (pInfoReqInd->cgPtyCatReqInd& 0x01) <<3 ; + mBuf[0] |= (pInfoReqInd->chrgInfoReqInd& 0x01) <<4 ; + mBuf[0] |= (pInfoReqInd->malCaIdReqInd& 0x01)<<7; + mBuf[1] = 0; + return 2; +} + +int siPkSiMcidRspInd (SiMcidRspInd *pMcidRsp,u8 *mBuf) +{ + mBuf[0] = pMcidRsp->rspInd &0x01; + mBuf[0] |= (pMcidRsp->hldInd &0x01)<<1; + return 1; +} + +int siPkSiMcidReqInd (SiMcidReqInd *pMcidReq,u8 *mBuf) +{ + mBuf[0] = pMcidReq->reqInd &0x01; + mBuf[0] |= (pMcidReq->hldInd &0x01)<<1; + return 1; +} + +int siPkSiMsgCompInfo (SiMsgCompInfo *pMsgCom,u8 *mBuf) +{ + mBuf[0] = pMsgCom->tranXInd &0x01; + mBuf[0] |= (pMsgCom->relCllInd &0x01)<<1; + mBuf[0] |= (pMsgCom->sndNotInd &0x01)<<2; + mBuf[0] |= (pMsgCom->dcrdMsgInd &0x01)<<3; + mBuf[0] |= (pMsgCom->passNotPoss &0x01)<<4; + mBuf[0] |= (pMsgCom->bbNbIntwkI &0x03)<<5; + return 1; +} + +int siPkSiMlppPrec (SiMlppPrec *pMlppPrec,u8 *mBuf) +{ + mBuf[0] = pMlppPrec->precdLvl & 0x0F; + mBuf[0] |= (pMlppPrec->lfb & 0x03)<<5; + mBuf[1] = pMlppPrec->scndDig &0x0f; + mBuf[1] |= (pMlppPrec->frstDig & 0x0f)<<4; + mBuf[2] = pMlppPrec->frthDig &0x0f; + mBuf[2] |= (pMlppPrec->thrdDig & 0x0f)<<4; + mBuf[3] = (pMlppPrec->servDomain>>16) &0xFF; + mBuf[4] = (pMlppPrec->servDomain>>8) &0xFF; + mBuf[5] = pMlppPrec->servDomain &0xFF; + return 6; +} + +int siPkNatConInd (SiNatConInd *pNatConInd,u8 *mBuf) +{ + mBuf[0] = 0; + mBuf[0] |= pNatConInd->satInd & 0x03; + mBuf[0] |= (pNatConInd->contChkInd & 0x03) << 2; + mBuf[0] |= (pNatConInd->echoCntrlDevInd & 0x01) << 4; + return 1; +} + +int siPkSiNetSpecFacil (SiNetSpecFacil *pNetFac,u8 *mBuf) +{ + memcpy(mBuf,pNetFac->netFac,pNetFac->length); + return pNetFac->length; +} + +int siPkOptBckCalInd (SiOptBckCalInd *pOptBckCalInd,u8 *mBuf) +{ + mBuf[0] = pOptBckCalInd->inbndInfoInd & 0x01; + mBuf[0] |= (pOptBckCalInd->caFwdMayOcc & 0x01) << 1; + mBuf[0] |= (pOptBckCalInd->simpleSegmInd & 0x01) << 2; + mBuf[0] |= (pOptBckCalInd->mlppUserInd & 0x01) << 3; + return 1; +} + +int siPkOpFwdCalInd (SiOpFwdCalInd *pOpFwdCalInd,u8 *mBuf) +{ + + mBuf[0] = pOpFwdCalInd->clsdUGrpCaInd & 0x03; + mBuf[0] |= (pOpFwdCalInd->simpleSegmInd & 0x01) << 2; + mBuf[0] |= (pOpFwdCalInd->conLineIdReqInd & 0x01) << 7; + return 1; +} + +int siPkOrigCdNum (SiOrigCdNum *pOrigCdNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pOrigCdNum->numOfDigit/2 + (pOrigCdNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + pOrigCdNum->oddEven = pOrigCdNum->numOfDigit & 0x01; + + mBuf[0] = pOrigCdNum->natAddrInd & 0x7F; + mBuf[0] |= (pOrigCdNum->oddEven & 0x01) << 7; + mBuf[1] = (pOrigCdNum->presRest & 0x03) << 2; + mBuf[1] |= (pOrigCdNum->numPlan & 0x07) << 4; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pOrigCdNum->addrSig[j++] & 0x0f; + num_ptr[i] += pOrigCdNum->addrSig[j++] << 4; + } + + if(pOrigCdNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkSigPointCode (SiSigPointCode *pSigPointCode,u8 *mBuf) +{ + mBuf[0] = pSigPointCode->sigPointCode & 0xFF; + mBuf[1] = (pSigPointCode->sigPointCode>>8) & 0x3F; + return 2; +} + +int siPkSiParmCompInfo (SiParmCompInfo *pParmCom,u8 *mBuf) +{ + memcpy(mBuf,pParmCom->content,pParmCom->length); + return pParmCom->length; +} + +int siPkRangStat (SiRangStat *pRangStat,u8 *mBuf) +{ + int status_len; + mBuf[0] = pRangStat->range; + status_len = ((pRangStat->range&0x07) == 0)? (pRangStat->range>>3) : ((pRangStat->range>>3) + 1); + memcpy(mBuf+1, pRangStat->status, status_len); + return status_len+1; +} +int siPkRangNoStat (SiRangNoStat *pRangStat,u8 *mBuf) +{ + mBuf[0] = pRangStat->range; + return 1; +} + +int siPkRedirInfo (SiRedirInfo *pRedirInfo,u8 *mBuf) +{ + mBuf[0] = pRedirInfo->redirInd & 0x07; + mBuf[0] |= (pRedirInfo->origRedirReas & 0x0F) << 4; + mBuf[1] = pRedirInfo->redirCnt & 0x07; + mBuf[1] |= (pRedirInfo->redirReas & 0x0F) << 4; + return 2; +} + +int siPkRedirgNum (SiRedirNum *pRedirgNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pRedirgNum->numOfDigit/2 + (pRedirgNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + pRedirgNum->oddEven = pRedirgNum->numOfDigit & 0x01; + + mBuf[0] = pRedirgNum->natAddrInd & 0x7F; + mBuf[0] |= (pRedirgNum->oddEven & 0x01) << 7; + mBuf[1] = (pRedirgNum->presRest & 0x03) << 2; + mBuf[1] |= (pRedirgNum->numPlan & 0x07) << 4; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pRedirgNum->addrSig[j++] & 0x0f; + num_ptr[i] += pRedirgNum->addrSig[j++] << 4; + } + + if(pRedirgNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkSiRedirRestr (SiRedirRestr *pRedirRstr,u8 *mBuf) +{ + mBuf[0] = pRedirRstr->presRest & 0x03; + return 1; +} + +int siPkSiRemotOper (SiRemotOper *pRemotOper,u8 *mBuf) +{ + memcpy(mBuf,pRemotOper->content,pRemotOper->length); + return pRemotOper->length; +} + +int siPkServiceAct (SiServiceAct *pServiceAct,u8 *mBuf) +{ + memcpy(mBuf,pServiceAct->serviceAct,pServiceAct->length); + return pServiceAct->length; +} + +int siPkSubNum (SiSubNum *pSubNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pSubNum->numOfDigit/2 + (pSubNum->numOfDigit & 0x01); + num_ptr = mBuf+1; + pSubNum->oddEven = pSubNum->numOfDigit & 0x01; + + mBuf[0] = (pSubNum->oddEven &0x01) <<7; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pSubNum->addrSig[j++] & 0x0f; + num_ptr[i] += pSubNum->addrSig[j++] << 4; + } + + if(pSubNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 1; +} + +int siPkSusResInd (SiSusResInd *pSusResInd,u8 *mBuf) +{ + mBuf[0] = pSusResInd->susResInd &0x01; + return 1; +} + +int siPkTranNetSel (SiTranNetSel *pTranNetSel,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pTranNetSel->numOfDigit/2 + (pTranNetSel->numOfDigit & 0x01); + num_ptr = mBuf+1; + + pTranNetSel->oddEven = pTranNetSel->numOfDigit & 0x01; + + mBuf[0] = pTranNetSel->netIdPln & 0x0F; + mBuf[0] |= (pTranNetSel->typNetId & 0x03) <<4; + mBuf[0] |= (pTranNetSel->oddEven & 0x01) <<7; + + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pTranNetSel->netId[j++] & 0x0f; + num_ptr[i] += pTranNetSel->netId[j++] << 4; + } + + if(pTranNetSel->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 1; +} + +int siPkTxMedReq (SiTxMedReq *pTxMedReq,u8 *mBuf) +{ + mBuf[0] = pTxMedReq->trMedReq; + return 1; +} + +int siPkSiUsrServInfo (SiUsrServInfo *pUsrServInfo,u8 *mBuf) +{ + memcpy(mBuf,pUsrServInfo->content,pUsrServInfo->length); + return pUsrServInfo->length; +} + +int siPkSiUsrTSrvInfo (SiUsrTSrvInfo *pUsrTSrvInfo,u8 *mBuf) +{ + memcpy(mBuf,pUsrTSrvInfo->content,pUsrTSrvInfo->length); + return pUsrTSrvInfo->length; +} + +int siPkUsr2UsrInd (SiUsr2UsrInd *pUsr2UsrInd,u8 *mBuf) +{ + mBuf[0] = pUsr2UsrInd->type & 0x01; + mBuf[0] |= (pUsr2UsrInd->serv1 & 0x03)<<1; + mBuf[0] |= (pUsr2UsrInd->serv2 & 0x03)<<3; + mBuf[0] |= (pUsr2UsrInd->serv3 & 0x03)<<5; + mBuf[0] |= (pUsr2UsrInd->spare & 0x01)<<7; + return 1; +} + +int siPkUsr2UsrInfo (SiUsr2UsrInfo *pUsr2UsrInfo,u8 *mBuf) +{ + memcpy(mBuf, pUsr2UsrInfo->info, pUsr2UsrInfo->length); + return pUsr2UsrInfo->length; +} + +int siPkPassAlng (SiPassAlng *pPassAlng,u8 *mBuf) +{ + memcpy(mBuf,pPassAlng->passAlng,pPassAlng->length); + return pPassAlng->length; +} +/* packing functions for ITU97/ETSIV3 Information Element */ +int siPkSiConfTrtInd (SiConfTrtInd *pConfTrtInd,u8 *mBuf) +{ + mBuf[0] = pConfTrtInd->confAcceptInd&0x03; + if(pConfTrtInd->length) + memcpy(mBuf+1, pConfTrtInd->extInfo, pConfTrtInd->length); + else + mBuf[0] = mBuf[0] | 0x80; + return pConfTrtInd->length+1; +} +int siPkUidActionInd (SiUidActionInd *pUidActionInd,u8 *mBuf) +{ + mBuf[0] = pUidActionInd->throughConnInstInd&0x01; + mBuf[0] |= (pUidActionInd->t9InstInd&0x01) << 1; + if(pUidActionInd->length) + memcpy(mBuf+1, pUidActionInd->extInfo, pUidActionInd->length); + else + mBuf[0] = mBuf[0] | 0x80; + return pUidActionInd->length+1; +} +int siPkBackGVNS (SiBackGVNS *pBackGVNS,u8 *mBuf) +{ + mBuf[0] = pBackGVNS->termAccessInd&0x03; + if(pBackGVNS->length) + { + memcpy(mBuf+1, pBackGVNS->extInfo, pBackGVNS->length); + } + else + mBuf[0] = mBuf[0] | 0x80; + return pBackGVNS->length+1; +} + +int siPkDisplayInfo (SiDisplayInfo *pDisplayInfo,u8 *mBuf) +{ + memcpy(mBuf,pDisplayInfo->displayInfo,pDisplayInfo->length); + return pDisplayInfo->length; +} +int siPkForwardGVNS (SiForwardGVNS *pForwardGVNS,u8 *mBuf) +{ + int i,j,num_len,point; + u8 *num_ptr; + + point = 0; + //Originating participating service provider + num_len = pForwardGVNS->numOfDigit1/2 + (pForwardGVNS->numOfDigit1 & 0x01); + if(num_len>4) + num_len=4; + if(num_len==0) + num_len=1; + mBuf[point] = num_len & 0x0F; + mBuf[point] |= (pForwardGVNS->numOfDigit1 & 0x01) << 7; + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pForwardGVNS->digits1[j++] & 0x0f; + num_ptr[i] += pForwardGVNS->digits1[j++] << 4; + } + + if(pForwardGVNS->numOfDigit1 & 0x01) + num_ptr[num_len-1] &= 0x0f; + point +=num_len; + + //GVNS user group + num_len = pForwardGVNS->numOfDigit2/2 + (pForwardGVNS->numOfDigit2 & 0x01); + if(num_len>8) + num_len=8; + if(num_len==0) + num_len=1; + mBuf[point] = num_len & 0x0F; + mBuf[point] |= (pForwardGVNS->numOfDigit2 & 0x01) << 7; + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pForwardGVNS->digits2[j++] & 0x0f; + num_ptr[i] += pForwardGVNS->digits2[j++] << 4; + } + + if(pForwardGVNS->numOfDigit2 & 0x01) + num_ptr[num_len-1] &= 0x0f; + point +=num_len; + + //Terminating network routing number + num_len = pForwardGVNS->numOfDigit3/2 + (pForwardGVNS->numOfDigit3 & 0x01); + if(num_len>8) + num_len=8; + if(num_len==0) + num_len=1; + mBuf[point] = (num_len+1) & 0x0F; + mBuf[point] |= (pForwardGVNS->numPlan & 0x03) << 4; + mBuf[point] |= (pForwardGVNS->numOfDigit2 & 0x01) << 7; + point++; + mBuf[point] = pForwardGVNS->natOfAddr & 0x07F; + point++; + num_ptr = mBuf+point; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pForwardGVNS->digits3[j++] & 0x0f; + num_ptr[i] += pForwardGVNS->digits3[j++] << 4; + } + + if(pForwardGVNS->numOfDigit3 & 0x01) + num_ptr[num_len-1] &= 0x0f; + point +=num_len; + + return point; +} +int siPkCcss (SiCcss *pCcss,u8 *mBuf) +{ + mBuf[0] = pCcss->ccssCallInd&0x01; + return 1; +} +int siPkNetMgmtControls (SiNetMgmtControls *pNetMgmtControls,u8 *mBuf) +{ + mBuf[0] = pNetMgmtControls->tmpAltRoutInd&0x01; + if(pNetMgmtControls->length) + memcpy(mBuf+1, pNetMgmtControls->extInfo, pNetMgmtControls->length); + else + mBuf[0] = mBuf[0] | 0x80; + return pNetMgmtControls->length+1; +} +int siPkCirAsgnMap (SiCirAsgnMap *pCirAsgnMap,u8 *mBuf) +{ + mBuf[0] = pCirAsgnMap->mapType&0x03F; + memcpy(mBuf+1,pCirAsgnMap->mapFormat,4); + return 5; +} +int siPkCorrelationId (SiCorrelationId *pCorrelationId,u8 *mBuf) +{ + memcpy(mBuf,pCorrelationId->correlationId,pCorrelationId->length); + return pCorrelationId->length; +} +int siPkCallDivTrtInd (SiCallDivTrtInd *pCallDivTrtInd,u8 *mBuf) +{ + mBuf[0] = pCallDivTrtInd->callDivInd&0x03; + if(pCallDivTrtInd->length) + memcpy(mBuf+1, pCallDivTrtInd->extInfo, pCallDivTrtInd->length); + else + mBuf[0] = mBuf[0] | 0x80; + return pCallDivTrtInd->length+1; +} +int siPkCallInNmb (SiCallInNmb *pCallInNmb,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pCallInNmb->numOfDigit/2 + (pCallInNmb->numOfDigit & 0x01); + num_ptr = mBuf+2; + pCallInNmb->oddEven = pCallInNmb->numOfDigit & 0x01; + + mBuf[0] = pCallInNmb->natAddrInd & 0x7F; + mBuf[0] |= (pCallInNmb->oddEven & 0x01) << 7; + mBuf[1] = (pCallInNmb->presRest & 0x03) << 2; + mBuf[1] |= (pCallInNmb->numPlan & 0x07) << 4; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pCallInNmb->addrSig[j++] & 0x0f; + num_ptr[i] += pCallInNmb->addrSig[j++] << 4; + } + + if(pCallInNmb->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + +int siPkCallOfferTrtInd (SiCallOfferTrtInd *pCallOfferTrtInd,u8 *mBuf) +{ + mBuf[0] = pCallOfferTrtInd->callOfferInd&0x03; + if(pCallOfferTrtInd->length) + memcpy(mBuf+1, pCallOfferTrtInd->extInfo, pCallOfferTrtInd->length); + else + mBuf[0] = mBuf[0] | 0x80; + return pCallOfferTrtInd->length+1; +} +int siPkScfId (SiScfId *pScfId,u8 *mBuf) +{ + memcpy(mBuf,pScfId->scfId,pScfId->length); + return pScfId->length; +} +int siPkUidCapInd (SiUidCapInd *pUidCapInd,u8 *mBuf) +{ + mBuf[0] = pUidCapInd->throughConnInstInd&0x01; + mBuf[0] |= (pUidCapInd->t9InstInd&0x01) << 1; + if(pUidCapInd->length) + { + memcpy(mBuf+1, pUidCapInd->extInfo, pUidCapInd->length); + } + else + mBuf[0] = mBuf[0] | 0x80; + return pUidCapInd->length+1; +} +int siPkCollCallReq (SiCollCallReq *pCollCallReq,u8 *mBuf) +{ + mBuf[0] = pCollCallReq->collCallReqInd & 0x01; + return 1; +} +int siPkNaPaChgPID (SiNaPaChgPID *pNaPaChgPID,u8 *mBuf) +{ + memcpy(mBuf,pNaPaChgPID->naPaChgPtyId,pNaPaChgPID->length); + return pNaPaChgPID->length; +} +int siPkCallTRef (SiCallTRef *pCallTRef,u8 *mBuf) +{ + mBuf[0] = pCallTRef->callTrnsfr; + return 1; +} +int siPkLoopPrvntInd (SiLoopPrvntInd *pLoopPrvntInd,u8 *mBuf) +{ + mBuf[0] = pLoopPrvntInd->loopPrvntType & 0x01; + mBuf[0] |= (pLoopPrvntInd->loopPrvntRspInd & 0x03)<<1; + return 1; +} +int siPkAppTransParam (SiAppTransParam *pAppTransParam,u8 *mBuf) +{ + mBuf[0] = pAppTransParam->appContextId & 0x7f; + mBuf[0] |= 0x80; + mBuf[1] = pAppTransParam->atii & 0x03; + mBuf[1] |= 0x80; + mBuf[2] = pAppTransParam->apmSegInd & 0x3f; + mBuf[2] |= (pAppTransParam->seqInd & 0x01)<<6; + + if(pAppTransParam->slr) + { + mBuf[3] = pAppTransParam->slr & 0x7f; + mBuf[3] = mBuf[3] |0x80; + memcpy(mBuf+4,pAppTransParam->encapAppInfo,pAppTransParam->length); + return pAppTransParam->length+4; + } + else + { + mBuf[2] |= 0x80; + memcpy(mBuf+3,pAppTransParam->encapAppInfo,pAppTransParam->length); + return pAppTransParam->length+3; + } +} + +/* packing functions for UK specific Information Element */ +int siPkSiNatForCalInd (SiNatForCalInd *pNatForCalInd,u8 *mBuf) +{ + mBuf[0] = pNatForCalInd->cbi & 0x01; + mBuf[0] |= (pNatForCalInd->ntaInd & 0x01)<<1; + mBuf[1] = 0; + return 2; +} + +int siPkSiNatForCalIndLbL (SiNatForCalIndLbL *pNatForCalIndLbL,u8 *mBuf) +{ + mBuf[0] = pNatForCalIndLbL->rci & 0x0f; + if(pNatForCalIndLbL->isi) + { + mBuf[1] = pNatForCalIndLbL->isi & 0x0f; + mBuf[1] = mBuf[1] |0x80; + return 2; + } + else + { + mBuf[0] = mBuf[0] |0x80; + return 1; + } +} + +int siPkSiPresNum (SiPresNum *pPresNum,u8 *mBuf) +{ + int i,j,num_len; + u8 *num_ptr; + num_len = pPresNum->numOfDigit/2 + (pPresNum->numOfDigit & 0x01); + num_ptr = mBuf+2; + + pPresNum->oddEven = pPresNum->numOfDigit & 0x01; + + mBuf[0] = pPresNum->natAddrInd & 0x7F; + mBuf[0] |= (pPresNum->oddEven & 0x01) <<7; + mBuf[1] = pPresNum->scrInd & 0x03; + mBuf[1] |= (pPresNum->presRest & 0x03) << 2; + mBuf[1] |= (pPresNum->numPlan & 0x07) << 4; + mBuf[1] |= (pPresNum->pnp & 0x01) <<7; + if(num_len==0) + num_len=1; + for(i = 0, j = 0; i < num_len; i++) + { + num_ptr[i] = pPresNum->addrSig[j++] & 0x0f; + num_ptr[i] += pPresNum->addrSig[j++] << 4; + } + + if(pPresNum->numOfDigit & 0x01) + num_ptr[num_len-1] &= 0x0f; + return num_len + 2; +} + + + +int siPkSiPartCLI (SiPartCLI *pPartCLI,u8 *mBuf) +{ + mBuf[0] = pPartCLI->swichTypeD1& 0x0f; + mBuf[0] += pPartCLI->swichTypeD2 << 4; + + mBuf[1] = pPartCLI->pnoIdD1& 0x0f; + mBuf[1] += pPartCLI->pnoIdD2 << 4; + + mBuf[2] = pPartCLI->pnoIdD3& 0x0f; + mBuf[2] += pPartCLI->switchNumD1 << 4; + + mBuf[3] = pPartCLI->switchNumD2& 0x0f; + mBuf[3] += pPartCLI->switchNumD3 << 4; + + memcpy(mBuf+4,pPartCLI->agreement,5); + return 9; +} + +int siPkCaldSubBasSerMar (SiCaldSubBasSerMar *pCaldSubBasSerMar,u8 *mBuf) +{ + mBuf[0] = pCaldSubBasSerMar->cbInd & 0x01 ; + mBuf[0] |= (pCaldSubBasSerMar->subIcbInd & 0x01) <<1; + mBuf[0] |= (pCaldSubBasSerMar->preIcbInd & 0x01) <<2; + mBuf[0] |= (pCaldSubBasSerMar->permIcbInd & 0x01) <<3; + mBuf[0] |= (pCaldSubBasSerMar->tosInd & 0x01) <<4; + mBuf[0] |= (pCaldSubBasSerMar->ICBExpInd & 0x01) <<5; + mBuf[0] |= (pCaldSubBasSerMar->caldSubFacInfInd & 0x01) <<6; + mBuf[0] |= (pCaldSubBasSerMar->calgSubFacInfInd & 0x01) <<7; + mBuf[1] = pCaldSubBasSerMar->permOcbInd & 0x01; + mBuf[1] |= (pCaldSubBasSerMar->ogLocCalBarInd & 0x01) <<1; + mBuf[1] |= (pCaldSubBasSerMar->ogNatCalBarInd & 0x01) <<2; + mBuf[1] |= (pCaldSubBasSerMar->ogIntCalBarInd & 0x01) <<3; + mBuf[1] |= (pCaldSubBasSerMar->opCalBarInd & 0x01) <<4; + mBuf[1] |= (pCaldSubBasSerMar->supFacCalBarInd & 0x01)<<5; + mBuf[1] |= (pCaldSubBasSerMar->digMaskInd & 0x01) <<6; + mBuf[1] |= (pCaldSubBasSerMar->calPreBarInd & 0x01) <<7; + mBuf[2] = pCaldSubBasSerMar->caldSubTarGp & 0x7F; + return 3; +} + + +int siPkCalgSubBasSerMar (SiCalgSubBasSerMar *pCalgSubBasSerMar,u8 *mBuf) +{ + mBuf[0] = pCalgSubBasSerMar->cbInd & 0x01 ; + mBuf[0] |= (pCalgSubBasSerMar->subIcbInd & 0x01) <<1; + mBuf[0] |= (pCalgSubBasSerMar->preIcbInd & 0x01) <<2; + mBuf[0] |= (pCalgSubBasSerMar->permIcbInd & 0x01) <<3; + mBuf[0] |= (pCalgSubBasSerMar->tosInd & 0x01) <<4; + mBuf[0] |= (pCalgSubBasSerMar->ICBExpInd & 0x01) <<5; + mBuf[0] |= (pCalgSubBasSerMar->caldSubFacInfInd & 0x01) <<6; + mBuf[0] |= (pCalgSubBasSerMar->calgSubFacInfInd & 0x01) <<7; + mBuf[1] = pCalgSubBasSerMar->permOcbInd & 0x01; + mBuf[1] |= (pCalgSubBasSerMar->ogLocCalBarInd & 0x01) <<1; + mBuf[1] |= (pCalgSubBasSerMar->ogNatCalBarInd & 0x01) <<2; + mBuf[1] |= (pCalgSubBasSerMar->ogIntCalBarInd & 0x01) <<3; + mBuf[1] |= (pCalgSubBasSerMar->opCalBarInd & 0x01) <<4; + mBuf[1] |= (pCalgSubBasSerMar->supFacCalBarInd & 0x01)<<5; + mBuf[1] |= (pCalgSubBasSerMar->digMaskInd & 0x01) <<6; + mBuf[1] |= (pCalgSubBasSerMar->calPreBarInd & 0x01) <<7; + mBuf[2] = pCalgSubBasSerMar->calgSubTarGp & 0x7F; + mBuf[2] |= (pCalgSubBasSerMar->opInd & 0x01) <<7; + return 3; +} + + +int siPkCalgSubOrgFacMar (SiCalgSubOrgFacMar *pCalgSubOrgFacMar,u8 *mBuf) +{ + mBuf[0] = pCalgSubOrgFacMar->disSubInd & 0x01 ; + mBuf[0] |= (pCalgSubOrgFacMar->attCOI & 0x01) <<1; + mBuf[0] |= (pCalgSubOrgFacMar->adDurChgInd & 0x01) <<2; + mBuf[0] |= (pCalgSubOrgFacMar->PBXSubInd & 0x01) <<3; + mBuf[1] = 0; + return 2; +} + +int siPkCaldSubTermFacMar (SiCaldSubTermFacMar *pCaldSubTermFacMar,u8 *mBuf) +{ + mBuf[0] = pCaldSubTermFacMar->sviInd & 0x01 ; + mBuf[0] |= (pCaldSubTermFacMar->cniInd & 0x01) <<1; + mBuf[0] |= (pCaldSubTermFacMar->pbxNigIntInd & 0x01) <<2; + mBuf[0] |= (pCaldSubTermFacMar->calWaitInd & 0x01) <<3; + mBuf[0] |= (pCaldSubTermFacMar->fixedDestSerInd & 0x01) <<4; + mBuf[1] = 0; + return 2; +} + +int siPkNatInfReqInd (SiNatInfReqInd *pNatInfReqInd,u8 *mBuf) +{ + mBuf[0] = pNatInfReqInd->calgSubBasSerMarReqInd & 0x01 ; + mBuf[0] |= (pNatInfReqInd->caldSubBasSerMarReqInd & 0x01) <<1; + mBuf[0] |= (pNatInfReqInd->calgSubOrgFacMarReqInd & 0x01) <<2; + mBuf[0] |= (pNatInfReqInd->caldSubTerFacMarReqInd & 0x01) <<3; + mBuf[1] = 0; + return 2; +} + +int siPkNatInfInd (SiNatInfInd *pNatInfInd,u8 *mBuf) +{ + mBuf[0] = pNatInfInd->calgSubBasSerMarRespInd & 0x01 ; + mBuf[0] |= (pNatInfInd->caldSubBasSerMarRespInd & 0x01) <<1; + mBuf[0] |= (pNatInfInd->calgSubOrgFacMarRespInd & 0x01) <<2; + mBuf[0] |= (pNatInfInd->caldSubTerFacMarRespInd & 0x01) <<3; + mBuf[1] = 0; + return 2; +} +//for ansi-isup +int siPkCirValRspInd (SiCirValRspInd *pCirValRspInd,u8 *mBuf) +{ + mBuf[0] = pCirValRspInd->cirValRspInd & 0x01 ; + return 1; +} + +int siPkCirGrpCharInd (SiCirGrpCharInd *pCirGrpCharInd,u8 *mBuf) +{ + mBuf[0] = pCirGrpCharInd->cirGrpCarInd & 0x03 ; + mBuf[0] |= (pCirGrpCharInd->dblSzCtrlInd & 0x03) <<2; + mBuf[0] |= (pCirGrpCharInd->alarmCarInd & 0x03) <<4; + mBuf[0] |= (pCirGrpCharInd->contChkReqInd & 0x03) <<6; + return 1; +} + +int siPkCirIdName (SiCirIdName *pCirIdName,u8 *mBuf) +{ + int i; + for(i=0;i<26;i++) + { + mBuf[i] = pCirIdName->trunkNumClli[i] & 0x7f ; + } + return 26; +} + +int siPkCLLI (SiCLLI *pCLLI,u8 *mBuf) +{ + int i; + for(i=0;i<11;i++) + { + mBuf[i] = pCLLI->clliCode[i] & 0x7f ; + } + return 11; +} + + +/* unpacking/packing functions for ISUP message */ +int siUnpkACM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduACM *ptr = &(pdus_ptr->m.addrComp); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=2 m_v=0 + if(length < 2) + return -1; + + //M-fixed + siUnpkBckCalInd(&ptr->bckCalInd,flw_ptr,0); + flw_ptr += 2; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_OPBACKCALLIND: + siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CAUSIND: + siUnpkCauseDgn (&ptr->causeDgn,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDUSD: + siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCDELINFO: + siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRNUM: + siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLDIVERS: + siUnpkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRRESTR: + siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONFTRTIND: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_UIDACTIONIND: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkUidActionInd(&ptr->uidActionInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALDSUBBASSERMAR: //UK specific + siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkACM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduACM *ptr = &(pdus_ptr->m.addrComp); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkBckCalInd(&ptr->bckCalInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + if(ptr->optBckCalInd.pres == 1) + { + flw_ptr[0] = ME_OPBACKCALLIND; + flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->causeDgn.pres == 1) + { + flw_ptr[0] = ME_CAUSIND; + flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->notifInd1.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsed.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDUSD; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accDelInfo.pres == 1) + { + flw_ptr[0] = ME_ACCDELINFO; + flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirNum.pres == 1) + { + flw_ptr[0] = ME_REDIRNUM; + flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cllDivr.pres == 1) + { + flw_ptr[0] = ME_CLLDIVERS; + flw_ptr[1] = siPkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirRstr.pres == 1) + { + flw_ptr[0] = ME_REDIRRESTR; + flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CONFTRTIND; + flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->uidActionInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_UIDACTIONIND; + flw_ptr[1] = siPkUidActionInd(&ptr->uidActionInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubBasSerMar.pres == 1)//UK specific + { + flw_ptr[0] = ME_CALDSUBBASSERMAR; + flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkANM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduANM *ptr = &(pdus_ptr->m.answer); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_BACKCALLIND: + siUnpkBckCalInd (&ptr->bckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPBACKCALLIND: + siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONNUMB: + siUnpkConnectedNum(&ptr->connNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCDELINFO: + siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLHISTORY: + siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDUSD: + siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRGNUM: + siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRRESTR: + siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_BACKWARDGVNS: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_DISPLAYINFO: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkDisplayInfo(&ptr->displayInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALDSUBBASSERMAR: //UK specific + siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkANM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduANM *ptr = &(pdus_ptr->m.answer); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + if(ptr->bckCalInd.pres == 1) + { + flw_ptr[0] = ME_BACKCALLIND; + flw_ptr[1] = siPkBckCalInd(&ptr->bckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->optBckCalInd.pres == 1) + { + flw_ptr[0] = ME_OPBACKCALLIND; + flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connNum.pres == 1) + { + flw_ptr[0] = ME_CONNUMB; + flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accDelInfo.pres == 1) + { + flw_ptr[0] = ME_ACCDELINFO; + flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd1.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cllHstry.pres == 1) + { + flw_ptr[0] = ME_CLLHISTORY; + flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsed.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDUSD; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirNum.pres == 1) + { + flw_ptr[0] = ME_REDIRGNUM; + flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirRstr.pres == 1) + { + flw_ptr[0] = ME_REDIRRESTR; + flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->backGVNS.pres == 1)//(SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_BACKWARDGVNS; + flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->displayInfo.pres == 1)//(SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_DISPLAYINFO; + flw_ptr[1] = siPkDisplayInfo(&ptr->displayInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubBasSerMar.pres == 1)//UK specific + { + flw_ptr[0] = ME_CALDSUBBASSERMAR; + flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + + +int siUnpkCPG(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCPG *ptr = &(pdus_ptr->m.caProg); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkEvntInfo(&ptr->evntInfo,flw_ptr,0); + flw_ptr += 1; + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_EVNTINFO: + siUnpkEvntInfo(&ptr->evntInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CAUSIND: + siUnpkCauseDgn (&ptr->causeDgn,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_BACKCALLIND: + siUnpkBckCalInd (&ptr->bckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPBACKCALLIND: + siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd1,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDUSD: + siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCDELINFO: + siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRNUM: + siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLDIVERS: + siUnpkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRRESTR: + siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALLTRNSFRNMB: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONNUMB: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkConnectedNum(&ptr->connNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_BACKWARDGVNS: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLHISTORY: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONFTRTIND: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_UIDACTIONIND: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkUidActionInd(&ptr->uidActionInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALDSUBBASSERMAR: //UK specific + siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkCPG(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCPG *ptr = &(pdus_ptr->m.caProg); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkEvntInfo(&ptr->evntInfo,flw_ptr); + + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + if(ptr->evntInfo.pres == 1) + { + flw_ptr[0] = ME_EVNTINFO; + flw_ptr[1] = siPkEvntInfo(&ptr->evntInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->causeDgn.pres == 1) + { + flw_ptr[0] = ME_CAUSIND; + flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->bckCalInd.pres == 1) + { + flw_ptr[0] = ME_BACKCALLIND; + flw_ptr[1] = siPkBckCalInd(&ptr->bckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->optBckCalInd.pres == 1) + { + flw_ptr[0] = ME_OPBACKCALLIND; + flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd1.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsed.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDUSD; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accDelInfo.pres == 1) + { + flw_ptr[0] = ME_ACCDELINFO; + flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirNum.pres == 1) + { + flw_ptr[0] = ME_REDIRNUM; + flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cllDivr.pres == 1) + { + flw_ptr[0] = ME_CLLDIVERS; + flw_ptr[1] = siPkSiCllDiverInfo(&ptr->cllDivr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirRstr.pres == 1) + { + flw_ptr[0] = ME_REDIRRESTR; + flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->calTrnsNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CALLTRNSFRNMB; + flw_ptr[1] = siPkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connNum.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CONNUMB; + flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->backGVNS.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_BACKWARDGVNS; + flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cllHstry.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CLLHISTORY; + flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CONFTRTIND; + flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->uidActionInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_UIDACTIONIND; + flw_ptr[1] = siPkUidActionInd(&ptr->uidActionInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubBasSerMar.pres == 1)//UK specific + { + flw_ptr[0] = ME_CALDSUBBASSERMAR; + flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + + +int siUnpkCQR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCQR *ptr = &(pdus_ptr->m.cirGrpQryRes); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=2 + if(length < 2) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCirStateInd(&ptr->cirSteInd,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCQR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCQR *ptr = &(pdus_ptr->m.cirGrpQryRes); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 len;//opt_pointer + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + + len = flw_ptr-pointer_ptr; + *(pointer_ptr) = len; + flw_ptr[0] = siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + pointer_ptr++; + + len = flw_ptr-pointer_ptr; + *(pointer_ptr) = len; + flw_ptr[0] = siPkCirStateInd(&ptr->cirSteInd,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + pointer_ptr++; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkGRA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduGRA *ptr = &(pdus_ptr->m.cirGrpResAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]); + + + //Optional + + return 1; +} + +int siPkGRA(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduGRA *ptr = &(pdus_ptr->m.cirGrpResAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + + //M-variable + opt_pointer =0; + pointer_ptr = flw_ptr; + flw_ptr += 1; + *(pointer_ptr++) = 1; + + flw_ptr[0] = siPkRangStat(&ptr->rangStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + + //Optional + return flw_ptr - raw_ptr; +} + +int siUnpkCFN(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCFN *ptr = &(pdus_ptr->m.confusion); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + + return 1; +} + +int siPkCFN(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCFN *ptr = &(pdus_ptr->m.confusion); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + + return flw_ptr - raw_ptr; +} + +int siUnpkCON(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCON *ptr = &(pdus_ptr->m.connect); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=2 m_v=0 + if(length < 2) + return -1; + + //M-fixed + siUnpkBckCalInd(&ptr->bckCalInd,flw_ptr,0); + flw_ptr += 2; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_OPBACKCALLIND: + siUnpkOptBckCalInd (&ptr->optBckCalInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONNUMB: + siUnpkConnectedNum(&ptr->connNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDUSD: + siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCDELINFO: + siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLHISTORY: + siUnpkSiPropDly(&ptr->cllHstry,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRGNUM: + siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRRESTR: + siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_BACKWARDGVNS: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkBackGVNS(&ptr->backGVNS,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONFTRTIND: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + + case ME_CALDSUBBASSERMAR: //UK specific + siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkCON(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCON *ptr = &(pdus_ptr->m.connect); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkBckCalInd(&ptr->bckCalInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + if(ptr->optBckCalInd.pres == 1) + { + flw_ptr[0] = ME_OPBACKCALLIND; + flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connNum.pres == 1) + { + flw_ptr[0] = ME_CONNUMB; + flw_ptr[1] = siPkConnectedNum(&ptr->connNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsed.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDUSD; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accDelInfo.pres == 1) + { + flw_ptr[0] = ME_ACCDELINFO; + flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cllHstry.pres == 1) + { + flw_ptr[0] = ME_CLLHISTORY; + flw_ptr[1] = siPkSiPropDly(&ptr->cllHstry,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirNum.pres == 1) + { + flw_ptr[0] = ME_REDIRGNUM; + flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirRstr.pres == 1) + { + flw_ptr[0] = ME_REDIRRESTR; + flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + + if(ptr->backGVNS.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_BACKWARDGVNS; + flw_ptr[1] = siPkBackGVNS(&ptr->backGVNS,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->confTrtInd.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CONFTRTIND; + flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubBasSerMar.pres == 1)//UK specific + { + flw_ptr[0] = ME_CALDSUBBASSERMAR; + flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkCOT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCOT *ptr = &(pdus_ptr->m.continuity); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkContInd(&ptr->contInd,flw_ptr,0); + + return 1; +} + +int siPkCOT(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCOT *ptr = &(pdus_ptr->m.continuity); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + opt_pointer = 0; + pointer_ptr = 0; + + //M-fixed + siPkContInd(&ptr->contInd,flw_ptr); + flw_ptr += 1; + + return flw_ptr - raw_ptr; +} + +int siUnpkFRJ(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduFRJ *ptr = &(pdus_ptr->m.facReject); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + //check mandatory length + //m_f=1 m_v=1 + if(length < 2) + return -1; + + //M-fixed + siUnpkFacInd(&ptr->facInd,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_USR2USRIND: + siUnpkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkFRJ(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduFRJ *ptr = &(pdus_ptr->m.facReject); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + siPkFacInd(&ptr->facInd,flw_ptr); + flw_ptr += 1; + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + //Optional + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkINF(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduINF *ptr = &(pdus_ptr->m.info); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=2 m_v=0 + if(length < 2) + return -1; + + //M-fixed + siUnpkInfoInd(&ptr->infoInd,flw_ptr,0); + flw_ptr += 2; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CALGPARTCAT: + siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGPARTNUM: + siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONREQ: + siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NATINFIND: //UK specific + siUnpkNatInfInd(&ptr->natInfInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALDSUBBASSERMAR://UK specific + siUnpkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGSUBBASSERMAR://UK specific + siUnpkCalgSubBasSerMar(&ptr->calgSubBasSerMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGSUBORIFACMAR://UK specific + siUnpkCalgSubOrgFacMar(&ptr->calgSubOrgFacMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALDSUBTERFACMAR://UK specific + siUnpkCaldSubTermFacMar(&ptr->caldSubTermFacMar,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkINF(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduINF *ptr = &(pdus_ptr->m.info); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkInfoInd(&ptr->infoInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + if(ptr->cgPtyCat.pres == 1) + { + flw_ptr[0] = ME_CALGPARTCAT; + flw_ptr[1] = siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum.pres == 1) + { + flw_ptr[0] = ME_CALGPARTNUM; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connReq.pres == 1) + { + flw_ptr[0] = ME_CONREQ; + flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + + if(ptr->natInfInd.pres == 1)//UK specific + { + flw_ptr[0] = ME_NATINFIND; + flw_ptr[1] = siPkNatInfInd(&ptr->natInfInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubBasSerMar.pres == 1) //UK specific + { + flw_ptr[0] = ME_CALDSUBBASSERMAR; + flw_ptr[1] = siPkCaldSubBasSerMar(&ptr->caldSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->calgSubBasSerMar.pres == 1) //UK specific + { + flw_ptr[0] = ME_CALGSUBBASSERMAR; + flw_ptr[1] = siPkCalgSubBasSerMar(&ptr->calgSubBasSerMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->calgSubOrgFacMar.pres == 1) //UK specific + { + flw_ptr[0] = ME_CALGSUBORIFACMAR; + flw_ptr[1] = siPkCalgSubOrgFacMar(&ptr->calgSubOrgFacMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->caldSubTermFacMar.pres == 1) //UK specific + { + flw_ptr[0] = ME_CALDSUBTERFACMAR; + flw_ptr[1] = siPkCaldSubTermFacMar(&ptr->caldSubTermFacMar,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkINR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduINR *ptr = &(pdus_ptr->m.infoReq); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=2 m_v=0 + if(length < 2) + return -1; + + //M-fixed + siUnpkInfoReqInd(&ptr->infoReqInd,flw_ptr,0); + flw_ptr += 2; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + + switch(*flw_ptr) + { + case ME_CALREF: + siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NATINFREQIND: //UK specific + siUnpkNatInfReqInd(&ptr->natInfReqInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkINR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduINR *ptr = &(pdus_ptr->m.infoReq); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkInfoReqInd(&ptr->infoReqInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->natInfReqInd.pres == 1)//UK specific + { + flw_ptr[0] = ME_NATINFREQIND; + flw_ptr[1] = siPkNatInfReqInd(&ptr->natInfReqInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkIAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduIAM *ptr = &(pdus_ptr->m.initAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + //check mandatory length + //m_f=5 m_v=1 + if(length < 6) + return -1; + + //M-fixed + siUnpkNatConInd(&ptr->natConInd,flw_ptr,0); + flw_ptr += 1; + siUnpkFwdCallInd(&ptr->fwdCallInd,flw_ptr,0); + flw_ptr += 2; + siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr,0); + flw_ptr += 1; + siUnpkTxMedReq(&ptr->txMedReq,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCdPtyNum(&ptr->cdPtyNum,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_TRANNETSEL: + siUnpkTranNetSel(&ptr->tranNetSel,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGPARTNUM: + siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPFWDCALLIND: + siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRGNUM: + siUnpkRedirgNum(&ptr->redirgNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRINFO: + siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLSDUGRPINTCDE: + siUnpkCugIntCode(&ptr->cugIntCode,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONREQ: + siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ORIGCALDNUM: + siUnpkOrigCdNum(&ptr->origCdNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USRSERVINFO: + siUnpkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PROPDLYCTR: + siUnpkSiPropDly(&ptr->propDly,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USRSERVINFOPR: + siUnpkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENDIGITS: + siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ORISCCDE: + siUnpkSigPointCode(&ptr->orgPteCde,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USRTSRVINFO: + siUnpkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_MLPPPREC: + siUnpkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDPRM: + siUnpkTxMedReq(&ptr->txMedUsPr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_LOCNMB: + siUnpkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; +// SS7_ITU97 + case ME_FORWARDGVNS: + siUnpkForwardGVNS(&ptr->forwardGVNS,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CCSS: + siUnpkCcss(&ptr->ccss,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETMGMTCONTROLS: + siUnpkNetMgmtControls(&ptr->netMgmtControls,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CIRASGNMAP: + siUnpkCirAsgnMap(&ptr->cirAsgnMap,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CORRELATIONID: + siUnpkCorrelationId(&ptr->correlationId,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALLDIVTRTIND: + siUnpkCallDivTrtInd(&ptr->callDivTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALLINNMB: + siUnpkCallInNmb(&ptr->callInNmb,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALLOFFERTRTIND: + siUnpkCallOfferTrtInd(&ptr->callOfferTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONFTRTIND: + siUnpkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SCFID: + siUnpkScfId(&ptr->scfId,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_UIDCAPIND: + siUnpkUidCapInd(&ptr->uidCapInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_HOPCOUNTER: + siUnpkHopCounter(&ptr->hopCounter,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_COLLCALLREQ: + siUnpkCollCallReq(&ptr->collCallReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; +//UK specific + case ME_NATFORCALIND: + siUnpkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PRESNUM: + siUnpkSiPresNum(&ptr->presNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_LASDIVLINID: + siUnpkCgPtyNum(&ptr->lasDivLinId,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARTCLI: + siUnpkSiPartCLI(&ptr->partCLI,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NATFORCALIND_LTL: + siUnpkSiNatForCalIndLbL(&ptr->natForCalIndLbL,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siUnpkIAM_AN(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduIAM *ptr = &(pdus_ptr->m.initAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + //check mandatory length + //m_f=4 m_v=2 + if(length < 6) + return -1; + + //M-fixed + siUnpkNatConInd(&ptr->natConInd,flw_ptr,0); + flw_ptr += 1; + siUnpkFwdCallInd(&ptr->fwdCallInd,flw_ptr,0); + flw_ptr += 2; + siUnpkCgPtyCat(&ptr->cgPtyCat,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkSiUsrServInfo(&ptr->usrServInfo,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCdPtyNum(&ptr->cdPtyNum,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_TRANNETSEL: + siUnpkTranNetSel(&ptr->tranNetSel,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGPARTNUM: + siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPFWDCALLIND: + siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRGNUM: + siUnpkRedirgNum(&ptr->redirgNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRINFO: + siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLSDUGRPINTCDE: + siUnpkCugIntCode(&ptr->cugIntCode,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONREQ: + siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ORIGCALDNUM: + siUnpkOrigCdNum(&ptr->origCdNum,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PROPDLYCTR: + siUnpkSiPropDly(&ptr->propDly,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USRSERVINFOPR: + siUnpkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENDIGITS: + siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ORISCCDE: + siUnpkSigPointCode(&ptr->orgPteCde,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USRTSRVINFO: + siUnpkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_MLPPPREC: + siUnpkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDPRM: + siUnpkTxMedReq(&ptr->txMedUsPr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_LOCNMB: + siUnpkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkIAM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduIAM *ptr = &(pdus_ptr->m.initAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkNatConInd(&ptr->natConInd,flw_ptr); + flw_ptr += siPkFwdCallInd(&ptr->fwdCallInd,flw_ptr); + flw_ptr += siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr); + flw_ptr += siPkTxMedReq(&ptr->txMedReq,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkCdPtyNum(&ptr->cdPtyNum,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + + //Optional + if(ptr->tranNetSel.pres == 1) + { + flw_ptr[0] = ME_TRANNETSEL; + flw_ptr[1] = siPkTranNetSel(&ptr->tranNetSel,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum.pres == 1) + { + flw_ptr[0] = ME_CALGPARTNUM; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->natForCalInd.pres == 1)//UK specific + { + flw_ptr[0] = ME_NATFORCALIND; + flw_ptr[1] = siPkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->opFwdCalInd.pres == 1) + { + flw_ptr[0] = ME_OPFWDCALLIND; + flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirgNum.pres == 1) + { + flw_ptr[0] = ME_REDIRGNUM; + flw_ptr[1] = siPkRedirgNum(&ptr->redirgNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirInfo.pres == 1) + { + flw_ptr[0] = ME_REDIRINFO; + flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cugIntCode.pres == 1) + { + flw_ptr[0] = ME_CLSDUGRPINTCDE; + flw_ptr[1] = siPkCugIntCode(&ptr->cugIntCode,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connReq.pres == 1) + { + flw_ptr[0] = ME_CONREQ; + flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->origCdNum.pres == 1) + { + flw_ptr[0] = ME_ORIGCALDNUM; + flw_ptr[1] = siPkOrigCdNum(&ptr->origCdNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->usrServInfo.pres == 1) + { + flw_ptr[0] = ME_USRSERVINFO; + flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->propDly.pres == 1) + { + flw_ptr[0] = ME_PROPDLYCTR; + flw_ptr[1] = siPkSiPropDly(&ptr->propDly,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usrServInfo1.pres == 1) + { + flw_ptr[0] = ME_USRSERVINFOPR; + flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genDigits.pres == 1) + { + flw_ptr[0] = ME_GENDIGITS; + flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->orgPteCde.pres == 1) + { + flw_ptr[0] = ME_ORISCCDE; + flw_ptr[1] = siPkSigPointCode(&ptr->orgPteCde,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usrTSrvInfo.pres == 1) + { + flw_ptr[0] = ME_USRTSRVINFO; + flw_ptr[1] = siPkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->mlppPrec.pres == 1) + { + flw_ptr[0] = ME_MLPPPREC; + flw_ptr[1] = siPkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsPr.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDPRM; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsPr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum1.pres == 1) + { + flw_ptr[0] = ME_LOCNMB; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } +// SS7_ITU97 + if(ptr->forwardGVNS.pres == 1) + { + flw_ptr[0] = ME_FORWARDGVNS; + flw_ptr[1] = siPkForwardGVNS(&ptr->forwardGVNS,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->ccss.pres == 1) + { + flw_ptr[0] = ME_CCSS; + flw_ptr[1] = siPkCcss(&ptr->ccss,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netMgmtControls.pres == 1) + { + flw_ptr[0] = ME_NETMGMTCONTROLS; + flw_ptr[1] = siPkNetMgmtControls(&ptr->netMgmtControls,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cirAsgnMap.pres == 1) + { + flw_ptr[0] = ME_CIRASGNMAP; + flw_ptr[1] = siPkCirAsgnMap(&ptr->cirAsgnMap,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->correlationId.pres == 1) + { + flw_ptr[0] = ME_CORRELATIONID; + flw_ptr[1] = siPkCorrelationId(&ptr->correlationId,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callDivTrtInd.pres == 1) + { + flw_ptr[0] = ME_CALLDIVTRTIND; + flw_ptr[1] = siPkCallDivTrtInd(&ptr->callDivTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callInNmb.pres == 1) + { + flw_ptr[0] = ME_CALLINNMB; + flw_ptr[1] = siPkCallInNmb(&ptr->callInNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callOfferTrtInd.pres == 1) + { + flw_ptr[0] = ME_CALLOFFERTRTIND; + flw_ptr[1] = siPkCallOfferTrtInd(&ptr->callOfferTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->confTrtInd.pres == 1) + { + flw_ptr[0] = ME_CONFTRTIND; + flw_ptr[1] = siPkSiConfTrtInd(&ptr->confTrtInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->scfId.pres == 1) + { + flw_ptr[0] = ME_SCFID; + flw_ptr[1] = siPkScfId(&ptr->scfId,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->uidCapInd.pres == 1) + { + flw_ptr[0] = ME_UIDCAPIND; + flw_ptr[1] = siPkUidCapInd(&ptr->uidCapInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->hopCounter.pres == 1) + { + flw_ptr[0] = ME_HOPCOUNTER; + flw_ptr[1] = siPkHopCounter(&ptr->hopCounter,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->collCallReq.pres == 1) + { + flw_ptr[0] = ME_COLLCALLREQ; + flw_ptr[1] = siPkCollCallReq(&ptr->collCallReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + +//UK specific +// if(ptr->natForCalInd.pres == 1) +// { +// flw_ptr[0] = ME_NATFORCALIND; +// flw_ptr[1] = siPkSiNatForCalInd(&ptr->natForCalInd,flw_ptr+2); +// flw_ptr += flw_ptr[1] + 2; +// *pointer_ptr = opt_pointer; +// } + if(ptr->presNum.pres == 1) + { + flw_ptr[0] = ME_PRESNUM; + flw_ptr[1] = siPkSiPresNum(&ptr->presNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->lasDivLinId.pres == 1) + { + flw_ptr[0] = ME_LASDIVLINID; + flw_ptr[1] = siPkCgPtyNum(&ptr->lasDivLinId,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->partCLI.pres == 1) + { + flw_ptr[0] = ME_PARTCLI; + flw_ptr[1] = siPkSiPartCLI(&ptr->partCLI,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->natForCalIndLbL.pres == 1) + { + flw_ptr[0] = ME_NATFORCALIND_LTL; + flw_ptr[1] = siPkSiNatForCalIndLbL(&ptr->natForCalIndLbL,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siPkIAM_AN(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduIAM *ptr = &(pdus_ptr->m.initAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkNatConInd(&ptr->natConInd,flw_ptr); + flw_ptr += siPkFwdCallInd(&ptr->fwdCallInd,flw_ptr); + flw_ptr += siPkCgPtyCat(&ptr->cgPtyCat,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 3; + + *(pointer_ptr++) = 3; + + flw_ptr[0] = siPkSiUsrServInfo(&ptr->usrServInfo,flw_ptr+1); + opt_pointer = flw_ptr[0] + 3; + flw_ptr += flw_ptr[0]+1; + *(pointer_ptr++) = opt_pointer; + + flw_ptr[0] = siPkCdPtyNum(&ptr->cdPtyNum,flw_ptr+1); + opt_pointer = flw_ptr[0] + 1 + opt_pointer -1; + flw_ptr += flw_ptr[0]+1; + + + + //Optional + if(ptr->tranNetSel.pres == 1) + { + flw_ptr[0] = ME_TRANNETSEL; + flw_ptr[1] = siPkTranNetSel(&ptr->tranNetSel,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum.pres == 1) + { + flw_ptr[0] = ME_CALGPARTNUM; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->opFwdCalInd.pres == 1) + { + flw_ptr[0] = ME_OPFWDCALLIND; + flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirgNum.pres == 1) + { + flw_ptr[0] = ME_REDIRGNUM; + flw_ptr[1] = siPkRedirgNum(&ptr->redirgNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirInfo.pres == 1) + { + flw_ptr[0] = ME_REDIRINFO; + flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cugIntCode.pres == 1) + { + flw_ptr[0] = ME_CLSDUGRPINTCDE; + flw_ptr[1] = siPkCugIntCode(&ptr->cugIntCode,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connReq.pres == 1) + { + flw_ptr[0] = ME_CONREQ; + flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->origCdNum.pres == 1) + { + flw_ptr[0] = ME_ORIGCALDNUM; + flw_ptr[1] = siPkOrigCdNum(&ptr->origCdNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->propDly.pres == 1) + { + flw_ptr[0] = ME_PROPDLYCTR; + flw_ptr[1] = siPkSiPropDly(&ptr->propDly,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usrServInfo1.pres == 1) + { + flw_ptr[0] = ME_USRSERVINFOPR; + flw_ptr[1] = siPkSiUsrServInfo(&ptr->usrServInfo1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genDigits.pres == 1) + { + flw_ptr[0] = ME_GENDIGITS; + flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->orgPteCde.pres == 1) + { + flw_ptr[0] = ME_ORISCCDE; + flw_ptr[1] = siPkSigPointCode(&ptr->orgPteCde,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usrTSrvInfo.pres == 1) + { + flw_ptr[0] = ME_USRTSRVINFO; + flw_ptr[1] = siPkSiUsrTSrvInfo(&ptr->usrTSrvInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->mlppPrec.pres == 1) + { + flw_ptr[0] = ME_MLPPPREC; + flw_ptr[1] = siPkSiMlppPrec(&ptr->mlppPrec,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->txMedUsPr.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDPRM; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsPr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum1.pres == 1) + { + flw_ptr[0] = ME_LOCNMB; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum1,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkREL(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduREL *ptr = &(pdus_ptr->m.release); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkCauseDgn(&ptr->causeDgn,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_REDIRINFO: + siUnpkRedirInfo(&ptr->redirInfo,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRNUM: + siUnpkCdPtyNum(&ptr->redirNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SIGPTCDE: + siUnpkSigPointCode(&ptr->sigPointCode,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_AUTOCONGLVL: + siUnpkAutoCongLvl (&ptr->auCongLvl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NETSPFAC: + siUnpkSiNetSpecFacil(&ptr->netFac,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCDELINFO: + siUnpkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REDIRRESTR: + siUnpkSiRedirRestr(&ptr->redirRstr,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_DISPLAYINFO: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkDisplayInfo(&ptr->displayInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + + return 1; +} + +int siPkREL(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduREL *ptr = &(pdus_ptr->m.release); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + //Optional + if(ptr->redirInfo.pres == 1) + { + flw_ptr[0] = ME_REDIRINFO; + flw_ptr[1] = siPkRedirInfo(&ptr->redirInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirNum.pres == 1) + { + flw_ptr[0] = ME_REDIRNUM; + flw_ptr[1] = siPkCdPtyNum(&ptr->redirNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->sigPointCode.pres == 1) + { + flw_ptr[0] = ME_SIGPTCDE; + flw_ptr[1] = siPkSigPointCode(&ptr->sigPointCode,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->auCongLvl.pres == 1) + { + flw_ptr[0] = ME_AUTOCONGLVL; + flw_ptr[1] = siPkAutoCongLvl(&ptr->auCongLvl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->netFac.pres == 1) + { + flw_ptr[0] = ME_NETSPFAC; + flw_ptr[1] = siPkSiNetSpecFacil(&ptr->netFac,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accDelInfo.pres == 1) + { + flw_ptr[0] = ME_ACCDELINFO; + flw_ptr[1] = siPkSiAccDelInfo(&ptr->accDelInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->redirRstr.pres == 1) + { + flw_ptr[0] = ME_REDIRRESTR; + flw_ptr[1] = siPkSiRedirRestr(&ptr->redirRstr,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->displayInfo.pres == 1)//(SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_DISPLAYINFO; + flw_ptr[1] = siPkDisplayInfo(&ptr->displayInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkRLC(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduRLC *ptr = &(pdus_ptr->m.relComplete); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CAUSIND: + siUnpkCauseDgn(&ptr->causeDgn,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkRLC(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduRLC *ptr = &(pdus_ptr->m.relComplete); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->causeDgn.pres == 1) + { + flw_ptr[0] = ME_CAUSIND; + flw_ptr[1] = siPkCauseDgn(&ptr->causeDgn,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkSAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduSAM *ptr = &(pdus_ptr->m.subAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkSubNum(&ptr->subNum,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkSAM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduSAM *ptr = &(pdus_ptr->m.subAddr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkSubNum(&ptr->subNum,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkUSR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduUSR *ptr = &(pdus_ptr->m.usr2Usr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkUsr2UsrInfo(&ptr->usr2UsrInfo,pointer_ptr+1, pointer_ptr[0]); + flw_ptr++; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + + return 1; +} + +int siPkUSR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduUSR *ptr = &(pdus_ptr->m.usr2Usr); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 2; + *(pointer_ptr++) = 2; + *pointer_ptr = 0; + flw_ptr[0] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + //Optional + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkFOT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduFOT *ptr = &(pdus_ptr->m.fwdTrans); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CALREF: + siUnpkCallRef(&ptr->callRef,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkFOT(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduFOT *ptr = &(pdus_ptr->m.fwdTrans); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkRES(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduRES *ptr = &(pdus_ptr->m.resume); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkSusResInd(&ptr->suspResInd,flw_ptr,0); + flw_ptr += 1; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CALREF: + siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkRES(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduRES *ptr = &(pdus_ptr->m.resume); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + //M-fixed + flw_ptr += siPkSusResInd(&ptr->suspResInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkSUS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduSUS *ptr = &(pdus_ptr->m.suspend); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkSusResInd(&ptr->suspResInd,flw_ptr,0); + flw_ptr += 1; + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CALREF: + siUnpkCallRef(&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkSUS(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduSUS *ptr = &(pdus_ptr->m.suspend); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkSusResInd(&ptr->suspResInd,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *pointer_ptr = 0; + opt_pointer=1; + + //Optional + + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkCGB(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCGB *ptr = &(pdus_ptr->m.cirGrpBlk); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=1 m_v=1 + if(length < 2) + return -1; + + //M-fixed + siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCGB(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCGB *ptr = &(pdus_ptr->m.cirGrpBlk); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + opt_pointer=0; + + + //M-fixed + flw_ptr += siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = siPkRangStat(&ptr->rangStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkCGBA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCGBA *ptr = &(pdus_ptr->m.cirGrpBlkAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=1 m_v=1 + if(length < 2) + return -1; + + //M-fixed + siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCGBA(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCGBA *ptr = &(pdus_ptr->m.cirGrpBlkAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + opt_pointer=1; + + + //M-fixed + flw_ptr += siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = siPkRangStat(&ptr->rangStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkCGU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCGU *ptr = &(pdus_ptr->m.cirGrpUnblk); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=1 m_v=1 + if(length < 2) + return -1; + + //M-fixed + siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0); + flw_ptr += 1; + + //M-variable + //flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCGU(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCGU *ptr = &(pdus_ptr->m.cirGrpUnblk); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + opt_pointer=0; + //M-fixed + flw_ptr += siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = siPkRangStat(&ptr->rangStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkCGUA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCGUA *ptr = &(pdus_ptr->m.cirGrpUblkAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=1 m_v=1 + if(length < 2) + return -1; + + //M-fixed + siUnpkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr,0); + flw_ptr += 1; + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangStat(&ptr->rangStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCGUA(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCGUA *ptr = &(pdus_ptr->m.cirGrpUblkAck); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + opt_pointer =0; + + + //M-fixed + flw_ptr += siPkCirGrpSupMTypInd(&ptr->cgsmti,flw_ptr); + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 1; + flw_ptr[0] = siPkRangStat(&ptr->rangStat,flw_ptr+1); + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkGRS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduGRS *ptr = &(pdus_ptr->m.cirGrpRes); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable +// flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkGRS(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduGRS *ptr = &(pdus_ptr->m.cirGrpRes); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *(pointer_ptr++) = 1; + + flw_ptr[0] = siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkCQM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCQM *ptr = &(pdus_ptr->m.cirGrpQry); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + + + //check mandatory length + //m_f=0 m_v=1 + if(length < 1) + return -1; + + //M-fixed + + //M-variable + //flw_ptr += *flw_ptr; + pointer_ptr = flw_ptr + *flw_ptr; + if(pointer_ptr+pointer_ptr[0]+1-raw_ptr > length) + return -1; + siUnpkRangNoStat(&ptr->rangNoStat,pointer_ptr+1, pointer_ptr[0]); + + //Optional + + return 1; +} + +int siPkCQM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCQM *ptr = &(pdus_ptr->m.cirGrpQry); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + pointer_ptr = flw_ptr; + flw_ptr += 1; + *(pointer_ptr++) = 1; + flw_ptr[0] = siPkRangNoStat(&ptr->rangNoStat,flw_ptr+1); + opt_pointer = flw_ptr[0] + 2; + flw_ptr += flw_ptr[0]+1; + + //Optional + + return flw_ptr - raw_ptr; +} + +int siUnpkFAA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduFAA *ptr = &(pdus_ptr->m.facAccept); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkFacInd(&ptr->facInd,flw_ptr,0); + flw_ptr += 1; + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONREQ: + siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkFAA(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduFAA *ptr = &(pdus_ptr->m.facAccept); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkFacInd(&ptr->facInd,flw_ptr); + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + + //Optional + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connReq.pres == 1) + { + flw_ptr[0] = ME_CONREQ; + flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkFAR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduFAR *ptr = &(pdus_ptr->m.facRequest); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=1 m_v=0 + if(length < 1) + return -1; + + //M-fixed + siUnpkFacInd(&ptr->facInd,flw_ptr,0); + flw_ptr += 1; + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_USR2USRIND: + siUnpkUsr2UsrInd (&ptr->usr2UsrInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALREF: + siUnpkCallRef (&ptr->callRef,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CONREQ: + siUnpkConnReq(&ptr->connReq,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkFAR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduFAR *ptr = &(pdus_ptr->m.facRequest); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkFacInd(&ptr->facInd,flw_ptr); + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + + //Optional + if(ptr->usr2UsrInd.pres == 1) + { + flw_ptr[0] = ME_USR2USRIND; + flw_ptr[1] = siPkUsr2UsrInd(&ptr->usr2UsrInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->callRef.pres == 1) + { + flw_ptr[0] = ME_CALREF; + flw_ptr[1] = siPkCallRef(&ptr->callRef,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->connReq.pres == 1) + { + flw_ptr[0] = ME_CONREQ; + flw_ptr[1] = siPkConnReq(&ptr->connReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkPAM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduPAM *ptr = &(pdus_ptr->m.passAlng); + u8 *flw_ptr = raw_ptr; + + siUnpkPassAlng(&ptr->passAlng,flw_ptr,length); + + return 1; +} + +int siPkPAM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduPAM *ptr = &(pdus_ptr->m.passAlng); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + pointer_ptr = 0; + opt_pointer = 0; + + return siPkPassAlng(&ptr->passAlng,flw_ptr); +} + +int siUnpkUPT(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduUPAT *ptr = &(pdus_ptr->m.usrPrtAvTst); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkUPT(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduUPAT *ptr = &(pdus_ptr->m.usrPrtAvTst); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkUPA(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduUPAT *ptr = &(pdus_ptr->m.usrPrtAvTst); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkUPA(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduUPAT *ptr = &(pdus_ptr->m.usrPrtAvTst); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkFAC(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduFAC *ptr = &(pdus_ptr->m.facility); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_REMOTOPER: + siUnpkSiRemotOper(&ptr->remotOper,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_SERVACT: + siUnpkServiceAct(&ptr->serviceAct,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALLTRNSFRNMB: // (SS7_ITU97 || SS7_ETSIV3) + siUnpkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt (&ptr->accTrans,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkFAC(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduFAC *ptr = &(pdus_ptr->m.facility); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->remotOper.pres == 1) + { + flw_ptr[0] = ME_REMOTOPER; + flw_ptr[1] = siPkSiRemotOper(&ptr->remotOper,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->serviceAct.pres == 1) + { + flw_ptr[0] = ME_SERVACT; + flw_ptr[1] = siPkServiceAct(&ptr->serviceAct,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->calTrnsNmb.pres == 1)// (SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = ME_CALLTRNSFRNMB; + flw_ptr[1] = siPkCgPtyNum(&ptr->calTrnsNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->notifInd.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkNRM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduNRM *ptr = &(pdus_ptr->m.netResMgt); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ECHOCNTRL: + siUnpkSiEchoCtl(&ptr->echoControl,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_TRANSMEDUSD: + siUnpkTxMedReq(&ptr->txMedUsed,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkNRM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduNRM *ptr = &(pdus_ptr->m.netResMgt); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->txMedUsed.pres == 1) + { + flw_ptr[0] = ME_TRANSMEDUSD; + flw_ptr[1] = siPkTxMedReq(&ptr->txMedUsed,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->echoControl.pres == 1) + { + flw_ptr[0] = ME_ECHOCNTRL; + flw_ptr[1] = siPkSiEchoCtl(&ptr->echoControl,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkIDR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduIDR *ptr = &(pdus_ptr->m.identReq); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MCIDREQ: + siUnpkSiMcidReqInd(&ptr->mcidReq,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkIDR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduIDR *ptr = &(pdus_ptr->m.identReq); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->mcidReq.pres == 1) + { + flw_ptr[0] = ME_MCIDREQ; + flw_ptr[1] = siPkSiMcidReqInd(&ptr->mcidReq,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkIRS(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduIRS *ptr = &(pdus_ptr->m.identRsp); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MCIDRSP: + siUnpkSiMcidRspInd(&ptr->mcidRsp,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CALGPARTNUM: + siUnpkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case MEI_CHRGINFODELAY: //( SS7_ITU97 || SS7_ETSIV3) + siUnpkNaPaChgPID(&ptr->naPaChgPID,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkIRS(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduIRS *ptr = &(pdus_ptr->m.identRsp); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->mcidRsp.pres == 1) + { + flw_ptr[0] = ME_MCIDRSP; + flw_ptr[1] = siPkSiMcidRspInd(&ptr->mcidRsp,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->cgPtyNum.pres == 1) + { + flw_ptr[0] = ME_CALGPARTNUM; + flw_ptr[1] = siPkCgPtyNum(&ptr->cgPtyNum,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->naPaChgPID.pres == 1)//( SS7_ITU97 || SS7_ETSIV3) + { + flw_ptr[0] = MEI_CHRGINFODELAY; + flw_ptr[1] = siPkNaPaChgPID(&ptr->naPaChgPID,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkSGM(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduSGM *ptr = &(pdus_ptr->m.segment); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_ACCTPORT: + siUnpkAccTrnspt(&ptr->accTrans,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_USR2USRINFO: + siUnpkUsr2UsrInfo (&ptr->usr2UsrInfo,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgComp,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENDIGITS: + siUnpkSiGenDigits(&ptr->genDigits,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_NOTIFINDC: + siUnpkNotifInd(&ptr->notifInd,flw_ptr+2, flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_GENNMB: + siUnpkSiGenNum(&ptr->genNmb,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkSGM(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduSGM *ptr = &(pdus_ptr->m.segment); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->accTrans.pres == 1) + { + flw_ptr[0] = ME_ACCTPORT; + flw_ptr[1] = siPkAccTrnspt(&ptr->accTrans,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->usr2UsrInfo.pres == 1) + { + flw_ptr[0] = ME_USR2USRINFO; + flw_ptr[1] = siPkUsr2UsrInfo(&ptr->usr2UsrInfo,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->msgComp.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgComp,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->genDigits.pres == 1) + { + flw_ptr[0] = ME_GENDIGITS; + flw_ptr[1] = siPkSiGenDigits(&ptr->genDigits,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->notifInd.pres == 1) + { + flw_ptr[0] = ME_NOTIFINDC; + flw_ptr[1] = siPkNotifInd(&ptr->notifInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(ptr->genNmb.pres == 1) + { + flw_ptr[0] = ME_GENNMB; + flw_ptr[1] = siPkSiGenNum(&ptr->genNmb,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + + +int siUnpkPRI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduPRI *ptr = &(pdus_ptr->m.preRelease); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPBACKCALLIND: + siUnpkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_OPFWDCALLIND: + siUnpkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_APPTRAN: + siUnpkAppTransParam(&ptr->appTransParam,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkPRI(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduPRI *ptr = &(pdus_ptr->m.preRelease); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->optBckCalInd.pres == 1) + { + flw_ptr[0] = ME_OPBACKCALLIND; + flw_ptr[1] = siPkOptBckCalInd(&ptr->optBckCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->opFwdCalInd.pres == 1) + { + flw_ptr[0] = ME_OPFWDCALLIND; + flw_ptr[1] = siPkOpFwdCalInd(&ptr->opFwdCalInd,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->appTransParam.pres == 1) + { + flw_ptr[0] = ME_APPTRAN; + flw_ptr[1] = siPkAppTransParam(&ptr->appTransParam,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkAPP(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduAPP *ptr = &(pdus_ptr->m.appTransport); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=0 m_v=0 +// if(length < 1) +// return -1; + + //M-fixed + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_MSGCOMP: + siUnpkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_PARCOMPIN: + siUnpkSiParmCompInfo(&ptr->parmCom,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_APPTRAN: + siUnpkAppTransParam(&ptr->appTransParam,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkAPP(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduAPP *ptr = &(pdus_ptr->m.appTransport); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + //Optional + if(ptr->msgCom.pres == 1) + { + flw_ptr[0] = ME_MSGCOMP; + flw_ptr[1] = siPkSiMsgCompInfo(&ptr->msgCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->parmCom.pres == 1) + { + flw_ptr[0] = ME_PARCOMPIN; + flw_ptr[1] = siPkSiParmCompInfo(&ptr->parmCom,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->appTransParam.pres == 1) + { + flw_ptr[0] = ME_APPTRAN; + flw_ptr[1] = siPkAppTransParam(&ptr->appTransParam,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + +int siUnpkCVR(SiAllPdus *pdus_ptr, u8 *raw_ptr, u16 length) +{ + SiPduCVR *ptr = &(pdus_ptr->m.cirValRsp); + u8 *flw_ptr = raw_ptr; + + + //check mandatory length + //m_f=2 m_v=0 + if(length < 2) + return -1; + + //M-fixed + siUnpkCirValRspInd(&ptr->valRspInd,flw_ptr,0); + flw_ptr += 1; + siUnpkCirGrpCharInd(&ptr->grpCharInd,flw_ptr,0); + flw_ptr += 1; + + //M-variable + + //Optional + if(*flw_ptr != 0) + { + flw_ptr += *flw_ptr; + while(*flw_ptr != 0) + { + if(flw_ptr+flw_ptr[1]+2-raw_ptr > length) + return -3; + switch(*flw_ptr) + { + case ME_CIRIDNAME: + siUnpkCirIdName(&ptr->cirIdName,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + case ME_CLLI: + siUnpkCLLI(&ptr->clli,flw_ptr+2,flw_ptr[1]); + flw_ptr += flw_ptr[1] + 2; + break; + default: + flw_ptr += flw_ptr[1] + 2; + break; + } + } + } + return 1; +} + +int siPkCVR(SiAllPdus *pdus_ptr, u8 *raw_ptr) +{ + SiPduCVR *ptr = &(pdus_ptr->m.cirValRsp); + u8 *flw_ptr = raw_ptr; + u8 *pointer_ptr; + u8 opt_pointer; + + + //M-fixed + flw_ptr += siPkCirValRspInd(&ptr->valRspInd,flw_ptr); + flw_ptr += siPkCirGrpCharInd(&ptr->grpCharInd,flw_ptr); + + //M-variable + opt_pointer = 1; + pointer_ptr = flw_ptr; + flw_ptr++; + *pointer_ptr = 0; + + //Optional + if(ptr->cirIdName.pres == 1) + { + flw_ptr[0] = ME_CIRIDNAME; + flw_ptr[1] = siPkCirIdName(&ptr->cirIdName,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + if(ptr->clli.pres == 1) + { + flw_ptr[0] = ME_CLLI; + flw_ptr[1] = siPkCLLI(&ptr->clli,flw_ptr+2); + flw_ptr += flw_ptr[1] + 2; + *pointer_ptr = opt_pointer; + } + + if(*pointer_ptr != 0) + *(flw_ptr++) = 0; //End of optional parameters + + return flw_ptr - raw_ptr; +} + + +static int siSelUnpkFun_ITU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length) +{ + switch(type) + { + case M_ACM: + return siUnpkACM(pdus_ptr, raw_ptr, length); + case M_ANM: + return siUnpkANM(pdus_ptr, raw_ptr, length); + case M_CPG: + return siUnpkCPG(pdus_ptr, raw_ptr, length); + case M_CGB: + return siUnpkCGB(pdus_ptr, raw_ptr, length); + case M_CGBA: + return siUnpkCGBA(pdus_ptr, raw_ptr, length); + case M_CQM: + return siUnpkCQM(pdus_ptr, raw_ptr, length); + case M_CQR: + return siUnpkCQR(pdus_ptr, raw_ptr, length); + case M_GRS: + return siUnpkGRS(pdus_ptr, raw_ptr, length); + case M_GRA: + return siUnpkGRA(pdus_ptr, raw_ptr, length); + case M_CGU: + return siUnpkCGU(pdus_ptr, raw_ptr, length); + case M_CGUA: + return siUnpkCGUA(pdus_ptr, raw_ptr, length); + case M_CFN: + return siUnpkCFN(pdus_ptr, raw_ptr, length); + case M_CON: + return siUnpkCON(pdus_ptr, raw_ptr, length); + case M_COT: + return siUnpkCOT(pdus_ptr, raw_ptr, length); + case M_FAC: + return siUnpkFAC(pdus_ptr, raw_ptr, length); + case M_FAA: + return siUnpkFAA(pdus_ptr, raw_ptr, length); + case M_FRJ: + return siUnpkFRJ(pdus_ptr, raw_ptr, length); + case M_FAR: + return siUnpkFAR(pdus_ptr, raw_ptr, length); + case M_FOT: + return siUnpkFOT(pdus_ptr, raw_ptr, length); + case M_IDR: + return siUnpkIDR(pdus_ptr, raw_ptr, length); + case M_IRS: + return siUnpkIRS(pdus_ptr, raw_ptr, length); + case M_INF: + return siUnpkINF(pdus_ptr, raw_ptr, length); + case M_INR: + return siUnpkINR(pdus_ptr, raw_ptr, length); + case M_IAM: + return siUnpkIAM(pdus_ptr, raw_ptr, length); + case M_NRM: + return siUnpkNRM(pdus_ptr, raw_ptr, length); + case M_PAM: + return siUnpkPAM(pdus_ptr, raw_ptr, length); + case M_REL: + return siUnpkREL(pdus_ptr, raw_ptr, length); + case M_RLC: + return siUnpkRLC(pdus_ptr, raw_ptr, length); + case M_RES: + return siUnpkRES(pdus_ptr, raw_ptr, length); + case M_SGM: + return siUnpkSGM(pdus_ptr, raw_ptr, length); + case M_SAM: + return siUnpkSAM(pdus_ptr, raw_ptr, length); + case M_SUS: + return siUnpkSUS(pdus_ptr, raw_ptr, length); + case M_UPA: + return siUnpkUPA(pdus_ptr, raw_ptr, length); + case M_UPT: + return siUnpkUPT(pdus_ptr, raw_ptr, length); + case M_USR: + return siUnpkUSR(pdus_ptr, raw_ptr, length); + case M_PRI: + return siUnpkPRI(pdus_ptr, raw_ptr, length); + case M_APP: + return siUnpkAPP(pdus_ptr, raw_ptr, length); + case M_UBL: + case M_UBA: + case M_UCIC: + case M_BLO: + case M_BLA: + case M_RSC: + case M_OLM: + case M_LPA: + case M_CRG: + return 1; + default: + break; + } + return -2;//nonsupport +} + +static int siSelPkFun_ITU(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type) +{ + switch(type) + { + case M_ACM: + return siPkACM(pdus_ptr, raw_ptr); + case M_ANM: + return siPkANM(pdus_ptr, raw_ptr); + case M_CPG: + return siPkCPG(pdus_ptr, raw_ptr); + case M_CGB: + return siPkCGB(pdus_ptr, raw_ptr); + case M_CGBA: + return siPkCGBA(pdus_ptr, raw_ptr); + case M_CQM: + return siPkCQM(pdus_ptr, raw_ptr); + case M_CQR: + return siPkCQR(pdus_ptr, raw_ptr); + case M_GRS: + return siPkGRS(pdus_ptr, raw_ptr); + case M_GRA: + return siPkGRA(pdus_ptr, raw_ptr); + case M_CGU: + return siPkCGU(pdus_ptr, raw_ptr); + case M_CGUA: + return siPkCGUA(pdus_ptr, raw_ptr); + case M_CFN: + return siPkCFN(pdus_ptr, raw_ptr); + case M_CON: + return siPkCON(pdus_ptr, raw_ptr); + case M_COT: + return siPkCOT(pdus_ptr, raw_ptr); + case M_FAC: + return siPkFAC(pdus_ptr, raw_ptr); + case M_FAA: + return siPkFAA(pdus_ptr, raw_ptr); + case M_FRJ: + return siPkFRJ(pdus_ptr, raw_ptr); + case M_FAR: + return siPkFAR(pdus_ptr, raw_ptr); + case M_FOT: + return siPkFOT(pdus_ptr, raw_ptr); + case M_IDR: + return siPkIDR(pdus_ptr, raw_ptr); + case M_IRS: + return siPkIRS(pdus_ptr, raw_ptr); + case M_INF: + return siPkINF(pdus_ptr, raw_ptr); + case M_INR: + return siPkINR(pdus_ptr, raw_ptr); + case M_IAM: + return siPkIAM(pdus_ptr, raw_ptr); + case M_NRM: + return siPkNRM(pdus_ptr, raw_ptr); + case M_PAM: + return siPkPAM(pdus_ptr, raw_ptr); + case M_REL: + return siPkREL(pdus_ptr, raw_ptr); + case M_RLC: + return siPkRLC(pdus_ptr, raw_ptr); + case M_RES: + return siPkRES(pdus_ptr, raw_ptr); + case M_SGM: + return siPkSGM(pdus_ptr, raw_ptr); + case M_SAM: + return siPkSAM(pdus_ptr, raw_ptr); + case M_SUS: + return siPkSUS(pdus_ptr, raw_ptr); + case M_UPA: + return siPkUPA(pdus_ptr, raw_ptr); + case M_UPT: + return siPkUPT(pdus_ptr, raw_ptr); + case M_USR: + return siPkUSR(pdus_ptr, raw_ptr); + case M_PRI: + return siPkPRI(pdus_ptr, raw_ptr); + case M_APP: + return siPkAPP(pdus_ptr, raw_ptr); + case M_UBL: + case M_UBA: + case M_UCIC: + case M_BLO: + case M_BLA: + case M_RSC: + case M_OLM: + case M_LPA: + case M_CRG: + return 0; + default: + break; + } + return -2; +} + +static int siSelUnpkFun_ANSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length) +{ + switch(type) + { + case M_ACM: + return siUnpkACM(pdus_ptr, raw_ptr, length); + case M_ANM: + return siUnpkANM(pdus_ptr, raw_ptr, length); + case M_CPG: + return siUnpkCPG(pdus_ptr, raw_ptr, length); + case M_CGB: + return siUnpkCGB(pdus_ptr, raw_ptr, length); + case M_CGBA: + return siUnpkCGBA(pdus_ptr, raw_ptr, length); + case M_CQM: + return siUnpkCQM(pdus_ptr, raw_ptr, length); + case M_CQR: + return siUnpkCQR(pdus_ptr, raw_ptr, length); + case M_GRS: + return siUnpkGRS(pdus_ptr, raw_ptr, length); + case M_GRA: + return siUnpkGRA(pdus_ptr, raw_ptr, length); + case M_CGU: + return siUnpkCGU(pdus_ptr, raw_ptr, length); + case M_CGUA: + return siUnpkCGUA(pdus_ptr, raw_ptr, length); + case M_CFN: + return siUnpkCFN(pdus_ptr, raw_ptr, length); + case M_CON: + return siUnpkCON(pdus_ptr, raw_ptr, length); + case M_COT: + return siUnpkCOT(pdus_ptr, raw_ptr, length); + case M_FAC: + return siUnpkFAC(pdus_ptr, raw_ptr, length); + case M_FAA: + return siUnpkFAA(pdus_ptr, raw_ptr, length); + case M_FRJ: + return siUnpkFRJ(pdus_ptr, raw_ptr, length); + case M_FAR: + return siUnpkFAR(pdus_ptr, raw_ptr, length); + case M_FOT: + return siUnpkFOT(pdus_ptr, raw_ptr, length); + case M_IDR: + return siUnpkIDR(pdus_ptr, raw_ptr, length); + case M_IRS: + return siUnpkIRS(pdus_ptr, raw_ptr, length); + case M_INF: + return siUnpkINF(pdus_ptr, raw_ptr, length); + case M_INR: + return siUnpkINR(pdus_ptr, raw_ptr, length); + case M_IAM: + return siUnpkIAM_AN(pdus_ptr, raw_ptr, length); + case M_NRM: + return siUnpkNRM(pdus_ptr, raw_ptr, length); + case M_PAM: + return siUnpkPAM(pdus_ptr, raw_ptr, length); + case M_REL: + return siUnpkREL(pdus_ptr, raw_ptr, length); + case M_RLC: + return siUnpkRLC(pdus_ptr, raw_ptr, length); + case M_RES: + return siUnpkRES(pdus_ptr, raw_ptr, length); + case M_SGM: + return siUnpkSGM(pdus_ptr, raw_ptr, length); + case M_SAM: + return siUnpkSAM(pdus_ptr, raw_ptr, length); + case M_SUS: + return siUnpkSUS(pdus_ptr, raw_ptr, length); + case M_UPA: + return siUnpkUPA(pdus_ptr, raw_ptr, length); + case M_UPT: + return siUnpkUPT(pdus_ptr, raw_ptr, length); + case M_USR: + return siUnpkUSR(pdus_ptr, raw_ptr, length); + case M_PRI: + return siUnpkPRI(pdus_ptr, raw_ptr, length); + case M_CVR://for ansi only + return siUnpkCVR(pdus_ptr, raw_ptr, length); + case M_UBL: + case M_UBA: + case M_UCIC: + case M_BLO: + case M_BLA: + case M_RSC: + case M_OLM: + case M_LPA: + case M_CRG: + case M_CVT://only for ansi + return 1; + default: + break; + } + return -2; +} + +static int siSelPkFun_ANSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type) +{ + switch(type) + { + case M_ACM: + return siPkACM(pdus_ptr, raw_ptr); + case M_ANM: + return siPkANM(pdus_ptr, raw_ptr); + case M_CPG: + return siPkCPG(pdus_ptr, raw_ptr); + case M_CGB: + return siPkCGB(pdus_ptr, raw_ptr); + case M_CGBA: + return siPkCGBA(pdus_ptr, raw_ptr); + case M_CQM: + return siPkCQM(pdus_ptr, raw_ptr); + case M_CQR: + return siPkCQR(pdus_ptr, raw_ptr); + case M_GRS: + return siPkGRS(pdus_ptr, raw_ptr); + case M_GRA: + return siPkGRA(pdus_ptr, raw_ptr); + case M_CGU: + return siPkCGU(pdus_ptr, raw_ptr); + case M_CGUA: + return siPkCGUA(pdus_ptr, raw_ptr); + case M_CFN: + return siPkCFN(pdus_ptr, raw_ptr); + case M_CON: + return siPkCON(pdus_ptr, raw_ptr); + case M_COT: + return siPkCOT(pdus_ptr, raw_ptr); + case M_FAC: + return siPkFAC(pdus_ptr, raw_ptr); + case M_FAA: + return siPkFAA(pdus_ptr, raw_ptr); + case M_FRJ: + return siPkFRJ(pdus_ptr, raw_ptr); + case M_FAR: + return siPkFAR(pdus_ptr, raw_ptr); + case M_FOT: + return siPkFOT(pdus_ptr, raw_ptr); + case M_IDR: + return siPkIDR(pdus_ptr, raw_ptr); + case M_IRS: + return siPkIRS(pdus_ptr, raw_ptr); + case M_INF: + return siPkINF(pdus_ptr, raw_ptr); + case M_INR: + return siPkINR(pdus_ptr, raw_ptr); + case M_IAM: + return siPkIAM_AN(pdus_ptr, raw_ptr); + case M_NRM: + return siPkNRM(pdus_ptr, raw_ptr); + case M_PAM: + return siPkPAM(pdus_ptr, raw_ptr); + case M_REL: + return siPkREL(pdus_ptr, raw_ptr); + case M_RLC: + return siPkRLC(pdus_ptr, raw_ptr); + case M_RES: + return siPkRES(pdus_ptr, raw_ptr); + case M_SGM: + return siPkSGM(pdus_ptr, raw_ptr); + case M_SAM: + return siPkSAM(pdus_ptr, raw_ptr); + case M_SUS: + return siPkSUS(pdus_ptr, raw_ptr); + case M_UPA: + return siPkUPA(pdus_ptr, raw_ptr); + case M_UPT: + return siPkUPT(pdus_ptr, raw_ptr); + case M_USR: + return siPkUSR(pdus_ptr, raw_ptr); + case M_PRI: + return siPkPRI(pdus_ptr, raw_ptr); + case M_CVR: + return siPkCVR(pdus_ptr, raw_ptr); + case M_UBL: + case M_UBA: + case M_UCIC: + case M_BLO: + case M_BLA: + case M_RSC: + case M_OLM: + case M_LPA: + case M_CRG: + case M_CVT://only for ansi + return 0; + default: + break; + } + return -2; +} + + + + + + + +int siSelUnpkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length, u8 variant) +{ + switch(variant) + { + case VARIANT_ITU: + case VARIANT_ETSI: + case VARIANT_UK: + return siSelUnpkFun_ITU(pdus_ptr, raw_ptr, type, length); + case VARIANT_ANSI: + return siSelUnpkFun_ANSI(pdus_ptr, raw_ptr, type, length); + default: + break; + } + return -2; +} + +int siSelPkFun(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type,u8 variant) +{ + switch(variant) + { + case VARIANT_ETSI: + case VARIANT_UK: + case VARIANT_ITU: + return siSelPkFun_ITU(pdus_ptr, raw_ptr, type); + case VARIANT_ANSI: + return siSelPkFun_ANSI(pdus_ptr, raw_ptr, type); + default: + break; + } + return -2; +} + + + + + + + +// +//static int siSelUnpkFun_ETSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length) +//{ +// return -1; +//} +// +//static int siSelPkFun_ETSI(SiAllPdus *pdus_ptr, u8 *raw_ptr, int type) +//{ +// return -1; +//} +// +//static int siSelUnpkFun_UK(SiAllPdus *pdus_ptr, u8 *raw_ptr, u8 type, int length) +//{ +// return -1; +//} +// +//static int siSelPkFun_UK(SiAllPdus *pdus_ptr, u8 *raw_ptr, int type) +//{ +// return -1; +//} + +void isup_send_cvr(u32 pid) +{ + SiPduCVR *ptr = &(isup_sd_pdus.m.cirValRsp); + + memset(ptr,0,sizeof(SiPduCVR)); + ptr->valRspInd.cirValRspInd = 0; //0=successful,1=failure + ptr->grpCharInd.cirGrpCarInd = 2; + ptr->grpCharInd.dblSzCtrlInd = 3; + ptr->grpCharInd.alarmCarInd = 1; + ptr->grpCharInd.contChkReqInd = 1; + isup_send_msg(pid,M_CVR); +} + diff --git a/omc/plat/isup/src/isup_transit.c b/omc/plat/isup/src/isup_transit.c new file mode 100644 index 0000000..87ad220 --- /dev/null +++ b/omc/plat/isup/src/isup_transit.c @@ -0,0 +1,402 @@ +/* + * + * Copyright (C) 2008 LGC Wireless, Inc + * Written by: Xinyu Yan + * + *- + */ +#include "./include/isup_debug.h" +#include "./include/isup_public.h" +#include "./include/isup_if.h" +#include "./include/isup_struct.h" +#include "./include/isup_def.h" +#include "./include/isup_const.h" + +#define MAX_ISUP_VAR 10 +#define MAX_ISUP_OPT 50 + +struct param_unit { + u8 len; + u8 *ptr; +}; + +struct isup_gen_fmt { + u8 var_num; + u8 opt_num; + struct param_unit fix; + struct param_unit var[MAX_ISUP_VAR]; + struct param_unit opt[MAX_ISUP_OPT]; +}; + +#define MAX_ISUP_MSGTYPE 100 //not sure, just an assumption +#define LEN_OF_LV(ptr) (*ptr + 1) +#define LEN_OF_TLV(ptr) (*(ptr+1) + 2) + +struct isup_fmt_desc { + u8 exist; + u8 fixed_len; /* fixed len start from message type(include) */ + u8 var_num; +}; + +const static struct isup_fmt_desc fmt_desc_itu[MAX_ISUP_MSGTYPE] = { + {0}, + {1, 6, 1}, //Initial address(1) + {1, 1, 1}, //Subsequent address(2) + {1,3,0},//Information request (national use)(3) + {1,3,0},//Information (national use)(4) + {1,2,0},//Continuity(5) + {1,3,0},//Address complete(6) + {1,3,0},//Connect(7) + {1,1,0},//Forward transfer(8) + {1,1,0},//Answer(9) + {0},//10 + {0},//11 + {1,1,1},//Release(12) + {1,2,0},//Suspend(13) + {1,2,0},//Resume(14) + {0},//15 + {1,1,0},//Release complete(16) + {0}, + {0}, + {0}, + {0},//Unblocking(20) + {0}, + {0},//Unblocking acknowledgement(22) + {0}, + {0}, + {0},//25 + {0}, + {0}, + {0}, + {0}, + {0},//30 + {1,2,0},//Facility request(31) + {1,2,0},//Facility accepted(32) + {1,2,1},//Facility reject(33) + {0}, + {0},//35 + {0},//Loop Back Acknowledgement(36) + {0}, + {0}, + {0}, + {0},//Pass-Along(40) + {0}, + {0}, + {0}, + {1,2,0},//Call progress(44) + {1,1,1},//User-to-user information(45) + {0},//Unequipped CIC (national use)(46) + {1,1,1},//Confusion(47) + {0},//Overload(48) + {0},//Charge information (national use)(49) + {1,1,0},//Network resource management(50) + {1,1,0},//Facility (51) + {1,1,0},//User Part Test(52) + {1,1,0},//User Part Available(53) + {1,1,0},//Identification request(54) + {1,1,0},//Identification response(55) + {1,1,0},//Segmentation(56) + {0}, + {0}, + {0}, + {0},//60 + {0}, + {0}, + {0}, + {1,1,0},//Loop Prevention(64) + {1,1,0},//Application transport message(65) + {1,1,0},//Pre-release information message (66) +}; + +const static struct isup_fmt_desc fmt_desc_ansi[MAX_ISUP_MSGTYPE] = { + {0}, + {1, 5, 2}, //Initial address(1) + {1, 1, 1}, //Subsequent address(2) + {1,3,0},//Information request (national use)(3) + {1,3,0},//Information (national use)(4) + {1,2,0},//Continuity(5) + {1,3,0},//Address complete(6) + {1,3,0},//Connect(7) + {1,1,0},//Forward transfer(8) + {1,1,0},//Answer(9) + {0},//10 + {0},//11 + {1,1,1},//Release(12) + {1,2,0},//Suspend(13) + {1,2,0},//Resume(14) + {0},//15 + {1,1,0},//Release complete(16) + {0}, + {0}, + {0}, + {0},//Unblocking(20) + {0}, + {0},//Unblocking acknowledgement(22) + {0}, + {0}, + {0},//25 + {0}, + {0}, + {0}, + {0}, + {0},//30 + {1,2,0},//Facility request(31) + {1,2,0},//Facility accepted(32) + {1,2,1},//Facility reject(33) + {0}, + {0},//35 + {0},//Loop Back Acknowledgement(36) + {0}, + {0}, + {0}, + {0},//Pass-Along(40) + {0}, + {0}, + {0}, + {1,2,0},//Call progress(44) + {1,1,1},//User-to-user information(45) + {0},//Unequipped CIC (national use)(46) + {1,1,1},//Confusion(47) + {0},//Overload(48) + {0},//Charge information (national use)(49) + {1,1,0},//Network resource management(50) + {1,1,0},//Facility (51) + {1,1,0},//User Part Test(52) + {1,1,0},//User Part Available(53) + {1,1,0},//Identification request(54) + {1,1,0},//Identification response(55) + {1,1,0},//Segmentation(56) + {0}, + {0}, + {0}, + {0},//60 + {0}, + {0}, + {0}, + {1,1,0},//Loop Prevention(64) + {1,1,0},//Application transport message(65) + {1,1,0},//Pre-release information message (66) +}; + +int raw_to_fmt(struct isup_gen_fmt *fmt, u8 *raw_head, u16 raw_len, u8 variant) +{ + int i; + const struct isup_fmt_desc *desc; + struct param_unit *opt; + u8 msg_type; + u8 *raw = raw_head; + + msg_type = *raw; + if(msg_type >= MAX_ISUP_MSGTYPE) + return 0; + if(variant == VARIANT_ANSI) + desc = &fmt_desc_ansi[msg_type]; + else + desc = &fmt_desc_itu[msg_type]; + if(desc->exist == 0) + return 0; + + memset(fmt, 0, sizeof(struct isup_gen_fmt)); + + // M Fixed // + fmt->fix.len = desc->fixed_len; + fmt->fix.ptr = raw; + raw += fmt->fix.len; + + // M Variable // + fmt->var_num = desc->var_num; + raw += *raw; + if(fmt->var_num != 0) + { + for(i = 0; i < fmt->var_num; i++) + { + if(raw + LEN_OF_LV(raw) - raw_head > raw_len) + return -1; + fmt->var[i].len = LEN_OF_LV(raw); + fmt->var[i].ptr = raw; + raw += fmt->var[i].len; + } + } + + // Option // + while(*raw != 0) + { + if(raw + LEN_OF_TLV(raw) - raw_head > raw_len) + return -1; + opt = &fmt->opt[fmt->opt_num++]; + opt->len = LEN_OF_TLV(raw); + opt->ptr = raw; + raw += opt->len; + } + return 1; +} + +int param_need_merge(u8 param_name) +{ + switch(param_name) + { + case ME_REDIRGNUM: + case ME_REDIRINFO: + case ME_ORIGCALDNUM: + case ME_LOCNMB: + case ME_LASDIVLINID: + return 1; + } + return 0; +} + +int param_already_exist(u8 *index, struct isup_gen_fmt *org, u8 param_name) +{ + int i; + + for(i = 0; i < org->opt_num; i++) + { + if(*(org->opt[i].ptr) == param_name) + { + *index = i; + return 1; + } + } + return 0; +} + +static u8 bw_call_ind[4]; +void merge_cpg_acm(struct isup_gen_fmt *dst, struct isup_gen_fmt *cpg, struct isup_gen_fmt *acm) +{ + int i; + u8 param_name; + u8 index; + + memcpy(dst, cpg, sizeof(struct isup_gen_fmt)); + + /* backward call ind, from fix part to opt */ + bw_call_ind[0] = ME_BACKCALLIND; + bw_call_ind[1] = 2; + memcpy(bw_call_ind+2, acm->fix.ptr+1, 2); + dst->opt[dst->opt_num].len = 4; + dst->opt[dst->opt_num].ptr = bw_call_ind; + dst->opt_num++; + + for(i = 0; i < acm->opt_num; i++) + { + param_name = *(acm->opt[i].ptr); + /* discard echo control infomation */ + if(param_name == ME_ECHOCNTRL) + continue; + if(param_already_exist(&index, dst, param_name) == 1) + memcpy(&dst->opt[index], &acm->opt[i], sizeof(struct param_unit)); + else + memcpy(&dst->opt[dst->opt_num++], &acm->opt[i], sizeof(struct param_unit)); + } +} + +void merge_fmt(struct isup_gen_fmt *dst, struct isup_gen_fmt *org, struct isup_gen_fmt *add) +{ + int i; + u8 param_name; + u8 index; + + memcpy(dst, org, sizeof(struct isup_gen_fmt)); + + if(*(add->fix.ptr) == M_CPG) + memcpy(&dst->fix, &add->fix, sizeof(struct param_unit)); + + if(*(add->fix.ptr) == M_IAM) + { + for(i = 0; i < add->var_num; i++) + { + memcpy(&dst->var[i], &add->var[i], sizeof(struct param_unit)); + } + } + else + { + for(i = 0; i < org->var_num; i++) + { + memcpy(&dst->var[i], &org->var[i], sizeof(struct param_unit)); + } + } + + for(i = 0; i < add->opt_num; i++) + { + param_name = *(add->opt[i].ptr); + if(param_need_merge(param_name) == 0) + continue; + if(param_already_exist(&index, dst, param_name) == 1) + memcpy(&dst->opt[index], &add->opt[i], sizeof(struct param_unit)); + else + memcpy(&dst->opt[dst->opt_num++], &add->opt[i], sizeof(struct param_unit)); + } +} + +int fmt_to_raw(u8 *raw_head, struct isup_gen_fmt *fmt) +{ + u8 *raw = raw_head; + int i; + u8 pre_pointer; + u8 pre_varlen; + + // M Fixed // + memcpy(raw, fmt->fix.ptr, fmt->fix.len); + raw += fmt->fix.len; + + /* Set initial condition, note that if VAR not exist, it applys to OPT directly */ + pre_varlen = fmt->var_num + 1; + pre_pointer = 1; + + // M Variable // + if(fmt->var_num != 0) + { + for(i = 0; i < fmt->var_num; i++) + { + *raw = pre_pointer + pre_varlen - 1; + memcpy(raw+*raw, fmt->var[i].ptr, fmt->var[i].len); + pre_varlen = fmt->var[i].len; + pre_pointer = *(raw++); + } + +// /* "pointer of optional part" is set to 0 first */ +// *raw = 0; + } + + // Option // + if(fmt->opt_num != 0) + { + /* Set "pointer of optional part" */ + *raw = pre_pointer + pre_varlen - 1; + + raw += *raw; + for(i = 0; i < fmt->opt_num; i++) + { + memcpy(raw, fmt->opt[i].ptr, fmt->opt[i].len); + raw += fmt->opt[i].len; + } + +// /* Set "end of optional parameter" */ +// *raw = 0; + } + + /* Last octet set to 0. It may be "pointer of optional part" or "end of optional parameter" */ + *(raw++) = 0; + if(fmt->opt_num == 0) + return raw-raw_head+pre_pointer + pre_varlen - 1 -1; + else + return raw-raw_head; +} + +int isup_transit_msg(u8 *raw_dst, u8 *raw_add, u8 len_add, u8 *raw_org, u8 len_org, u8 variant) +{ + struct isup_gen_fmt fmt_org; + struct isup_gen_fmt fmt_add; + struct isup_gen_fmt fmt_dst; + + if(raw_to_fmt(&fmt_org, raw_org, len_org, variant)==0) + return 0; + if(raw_to_fmt(&fmt_add, raw_add, len_add, variant)==0) + return 0; + if((*(fmt_org.fix.ptr) == M_ACM) && (*(fmt_add.fix.ptr) == M_CPG)) + merge_cpg_acm(&fmt_dst, &fmt_add, &fmt_org); + else + merge_fmt(&fmt_dst, &fmt_org, &fmt_add); + return fmt_to_raw(raw_dst, &fmt_dst); +} + diff --git a/omc/plat/isup/src/vssver2.scc b/omc/plat/isup/src/vssver2.scc new file mode 100644 index 0000000..c8381a5 Binary files /dev/null and b/omc/plat/isup/src/vssver2.scc differ diff --git a/omc/plat/isup/ut/.copyarea.db b/omc/plat/isup/ut/.copyarea.db new file mode 100644 index 0000000..b611f5e --- /dev/null +++ b/omc/plat/isup/ut/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\isup\ut +2 +3 +11:isup_msg_send.txt|1|11d70a3febd|169a|29541b1f|f8d96acbbfa411dc852a001c23e19543|0 +b:isup_main.c|1|11d70a3fe8e|da9|d59418e1|f8496aafbfa411dc852a001c23e19543|0 +f:isup_msg_rv.txt|1|11d70a3feec|8fb|7abefafe|f9796ae7bfa411dc852a001c23e19543|0 diff --git a/omc/plat/isup/ut/isup_main.c b/omc/plat/isup/ut/isup_main.c new file mode 100644 index 0000000..b8cf2a9 --- /dev/null +++ b/omc/plat/isup/ut/isup_main.c @@ -0,0 +1,187 @@ +// *************************************************************** +// isup_main version: 1.0 · date: 04/06/2007 +// ------------------------------------------------------------- +// DESCRIPTION: For isup module test +// +// AUTHOR: Zane +// +// HISTORY: +// ------------------------------------------------------------- +// Copyright (C) 2007 - All Rights Reserved +// *************************************************************** +// +// *************************************************************** + +#include +#include +#include "./include/isup_if.h" +#include "../../plat/snmp/src/include/snmp.h" +#include "../../plat/public/src/include/license_id.h" + +#define SYS_IT_INTERVAL_SEC 0 +#define SYS_IT_INTERVAL_USEC (20*1000) + +static char serialNumber[18]=""; +static int systemID=0,systemInited=0; +static int sys_timer10ms=0; + +extern void m2ua_init(void); +extern void m2ua_timer(void); +extern void debug_init_wxc2_ver(); + +static void isup_param_init(void) +{ + Sap_Attrib_struct sap; + Cg_Attrib_struct cg; + Circuit_Attrib_struct trunk; + int sap_id,cg_id,trunk_id; + + memset(&sap,0,sizeof(Sap_Attrib_struct)); + memset(&cg,0,sizeof(Cg_Attrib_struct)); + memset(&trunk,0,sizeof(Circuit_Attrib_struct)); + + if((sap_id = isup_bind_sap(&sap)) == -1) + { + printf("add sap error!\r\n"); + return; + } + + cg.opc = 1; + cg.dpc = 2; + cg.network_id = 0; + cg.priority = 1; // 0:Reattempt ind / 1:Discard + cg.tg_id = 0; + cg.variant_type = VARIANT_ITU; + + if((cg_id = isup_add_cg(sap_id, &cg)) == -1) + { + printf("Failed to create isup trunk group socket\r\n"); + return; + } + + trunk.cic_range = 32; + trunk.head_cic = 0; + trunk.plat_id = CTRL_PLAT_0; + if((trunk_id = isup_add_circuit(cg_id, &trunk)) == -1) + { + printf("Failed to create isup trunk socket\r\n"); + return; + } + + isup_set_run_mode(ISUP_SINGLE_MODE,0); + printf("isup init ok.\r\n"); +} + + +int wxc2_get_license(int functionID) +{ + return 1; +} + +static void sysTimer_IRQ() +{ + sys_timer10ms = 1; +} + + +static void SigactionSystem() +{ + struct sigaction action;//,actsegv; + + action.sa_handler = sysTimer_IRQ; + sigemptyset(&action.sa_mask); + action.sa_flags = SA_RESTART; + if(sigaction(SIGALRM, &action, NULL)<0) + { + printf("sigactin sigalarm failed\n"); + } +} + +static void moduleInit() +{ + printf("\n\n【R9 Platform Init】\n\n"); + + debug_init(); + iptrMainInit(); + + m2ua_init(); + + snmp_init(4957); + + mtp_shm_init(); + + mtp3_init_serial(serialNumber); + +// sccp_init(systemID, 0, 0); + + isup_init(systemID,10); + + printf("\n\n【R9 Platform Init completed】\n\n"); + +} + +static void SetFSMTimer() +{ + struct itimerval *ptv, tv; + + ptv = (struct itimerval *) &tv; + ptv->it_interval.tv_sec = SYS_IT_INTERVAL_SEC; + ptv->it_interval.tv_usec = SYS_IT_INTERVAL_USEC; + ptv->it_value. tv_sec = SYS_IT_INTERVAL_SEC; + ptv->it_value.tv_usec = SYS_IT_INTERVAL_USEC; + setitimer(ITIMER_REAL, ptv, NULL); +} + +static void moduleProc() +{ + static int wait_sccp_normal_count = 0; + + iptrans_timer(); + + + snmp_timer(); + + if(systemInited) + { + wait_sccp_normal_count=6001; + + heartbeat_timer(); + m2ua_timer(); + mtp3_proc(); + +// sccp_timer(); + + isup_timer(); + } + + + debug_rt(); +} + +int main(int argc, char **argv) +{ + moduleInit(); + + debug_init_wxc2_ver("ISUP TEST CASE v1.0 - Init..."); + + SigactionSystem(); + SetFSMTimer(); + + isup_param_init(); + + sys_timer10ms = 1; + + while(1) + { + if(sys_timer10ms) + { + sys_timer10ms = 0; + moduleProc(); + systemInited = 1; + } + if (sys_timer10ms == 0) + usleep(1); + } + + return 1; +} diff --git a/omc/plat/isup/ut/isup_msg_rv.txt b/omc/plat/isup/ut/isup_msg_rv.txt new file mode 100644 index 0000000..527b81e --- /dev/null +++ b/omc/plat/isup/ut/isup_msg_rv.txt @@ -0,0 +1,87 @@ +Test 1 + +0 PUB.SET SYNC=0 + +0 PUB.SET RECYCLE=0 + +1 M2UA.SET UPPERLAYER=MTP3 + +0 M2UA.SET LOCAL_PORT=2904 + +0 M2UA.SET REMOTE_PORT=2904 + +0 M2UA.SET REMOTE_IP=172.54.242.252 + +0 M2UA.SET STREAM_ID=1 + +10 M2UA.SET CLIENT // 建链 + +20 M2UA.SET SG_LINK //等待计数到20后查看信令网关建立情况,成功则继续 + +20 M2UA.SET LINK_ID=0 // 在服务器分配好线路号后,分配线路号并请求建立链路 + +20 M2UA.SET LK_LINK // 等待计数到20后查看链路建立情况,成功则继续 + +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV +10000000 M2UA.RECV + + + diff --git a/omc/plat/isup/ut/isup_msg_send.txt b/omc/plat/isup/ut/isup_msg_send.txt new file mode 100644 index 0000000..fac2556 --- /dev/null +++ b/omc/plat/isup/ut/isup_msg_send.txt @@ -0,0 +1,62 @@ +Test 1 +0 PUB.SET SYNC=0 +0 PUB.SET RECYCLE=0 +1 M2UA.SET UPPERLAYER=MTP3 +0 M2UA.SET LOCAL_PORT=2904 +0 M2UA.SET REMOTE_PORT=2904 +0 M2UA.SET REMOTE_IP=172.54.242.252 +0 M2UA.SET STREAM_ID=1 +10 M2UA.SET CLIENT +20 M2UA.SET SG_LINK +20 M2UA.SET LINK_ID=0 +20 M2UA.SET LK_LINK +20 M2UA.SEND 00 5B 05 01 80 00 A0 0A 00 06 55 7F 01 29 01 0F 01 05 01 01 01 01 00 12 03 A1 81 01 2A 01 2B 20 01 01 03 02 01 00 2C 01 01 35 01 01 37 01 55 2E 01 01 0C 04 81 90 21 03 39 02 01 01 36 01 09 2F 02 01 01 32 02 01 01 33 02 01 01 40 01 01 72 03 01 01 01 74 02 03 01 FA 03 FF FF 01 00 +10 M2UA.SEND 00 6C 05 01 80 00 A0 0A 00 09 01 11 02 55 7F 29 01 0F 01 05 01 01 01 01 00 2A 01 2B 20 01 01 21 06 81 15 21 43 65 07 03 02 01 00 2E 01 01 2C 01 01 39 03 01 01 01 2D 02 00 01 C0 07 01 81 95 21 43 65 07 35 01 01 2F 02 01 01 32 02 01 01 0B 05 81 90 21 43 05 33 02 01 01 37 01 76 40 01 01 4D 03 01 01 01 73 02 01 01 FA 03 FF FF 01 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 13 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 15 00 +10 M2UA.SEND 00 83 05 01 80 00 A0 0A 00 2C 81 01 24 01 81 12 03 A1 81 01 01 05 01 01 01 01 00 11 02 55 7F 29 01 0F 03 03 01 01 01 2A 01 2B 2C 01 01 2F 03 01 01 01 32 03 01 01 01 35 01 01 2E 01 01 0C 05 81 90 21 43 05 39 03 01 01 01 36 01 0A 33 03 01 01 01 40 01 01 45 04 81 95 11 01 37 01 55 21 06 81 15 21 43 65 07 4D 03 01 01 01 C0 05 01 81 95 21 03 2D 02 00 01 72 03 01 01 01 74 03 03 01 01 FA 03 FF FF 01 00 +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 18 01 01 05 1F FF FF FF FF +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 1A 01 01 05 1F FF FF FF FF +10 M2UA.SEND 00 0B 05 01 80 00 A0 0A 00 2A 01 01 01 +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 2B 02 03 01 01 03 01 01 01 +10 M2UA.SEND 00 0B 05 01 80 00 A0 0A 00 17 01 01 01 +10 M2UA.SEND 00 0F 05 01 80 00 A0 0A 00 29 01 05 1F FF FF FF FF +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 19 01 01 05 1F FF FF FF FF +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 1B 01 01 05 1F FF FF FF FF +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 31 00 +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 2F 02 00 05 A1 81 01 01 01 +10 M2UA.SEND 00 6F 05 01 80 00 A0 0A 00 07 55 7F 01 29 01 0F 21 06 81 15 21 43 65 07 01 05 01 01 01 01 00 2A 01 2B 20 01 01 03 03 01 01 01 2F 03 01 01 01 2C 01 01 32 03 01 01 01 35 01 01 37 01 55 2E 01 01 2D 02 00 01 39 03 01 01 01 0B 05 81 90 21 43 05 33 03 01 01 01 C0 07 01 81 95 21 43 65 07 40 01 01 4D 03 01 01 01 72 03 01 01 01 FA 03 FF FF 01 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 05 01 +10 M2UA.SEND 00 2A 05 01 80 00 A0 0A 00 33 01 38 01 3F 39 03 01 01 01 32 03 01 01 01 33 03 01 01 01 45 04 81 95 11 01 03 03 01 01 01 2C 01 01 00 +10 M2UA.SEND 00 23 05 01 80 00 A0 0A 00 20 01 01 2A 01 2B 01 05 01 01 01 01 00 0D 07 01 01 01 01 00 01 01 39 03 01 01 01 00 +10 M2UA.SEND 00 14 05 01 80 00 A0 0A 00 21 01 02 06 04 A1 81 01 01 2A 01 2B 00 +10 M2UA.SEND 00 23 05 01 80 00 A0 0A 00 1F 01 01 2A 01 2B 01 05 01 01 01 01 00 0D 07 01 01 01 01 00 01 01 39 03 01 01 01 00 +10 M2UA.SEND 00 11 05 01 80 00 A0 0A 00 08 01 01 05 01 01 01 01 00 00 +10 M2UA.SEND 00 15 05 01 80 00 A0 0A 00 36 01 3B 01 03 38 01 3F 39 03 01 01 01 00 +10 M2UA.SEND 00 2C 05 01 80 00 A0 0A 00 37 01 3C 01 03 38 01 3F 39 03 01 01 01 0A 04 81 95 11 01 03 03 01 01 01 C0 05 01 81 95 21 03 71 03 01 01 01 00 +10 M2UA.SEND 00 43 05 01 80 00 A0 0A 00 04 E5 00 01 09 01 01 0A 04 81 95 11 01 01 05 01 01 01 01 00 0D 07 01 01 01 01 00 01 01 39 03 01 01 01 2F 03 01 01 01 F5 02 0F 00 FA 03 FF FF 01 F9 03 FF FF 81 F8 01 0F F7 01 1F 00 +10 M2UA.SEND 00 21 05 01 80 00 A0 0A 00 03 9B 00 01 01 05 00 00 01 01 00 39 03 01 01 01 2F 03 01 01 01 F6 02 0F 00 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 24 00 +10 M2UA.SEND 00 18 05 01 80 00 A0 0A 00 32 01 38 01 3F 39 03 01 01 01 35 01 02 37 01 55 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 30 00 +10 M2UA.SEND 00 0B 05 01 80 00 A0 0A 00 28 01 01 01 +10 M2UA.SEND 00 48 05 01 80 00 A0 0A 00 0C 02 06 04 A1 81 01 01 13 02 11 11 0C 04 81 90 21 03 03 03 01 01 01 1E 02 01 00 20 03 01 01 01 27 01 01 2F 03 01 01 01 2E 01 01 39 03 01 01 01 40 01 01 2A 01 2B 73 03 01 01 01 32 03 01 01 01 00 +10 M2UA.SEND 00 10 05 01 80 00 A0 0A 00 10 01 12 04 A1 81 01 01 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 12 00 +10 M2UA.SEND 00 12 05 01 80 00 A0 0A 00 0E 01 01 01 05 01 01 01 01 00 00 +10 M2UA.SEND 00 27 05 01 80 00 A0 0A 00 38 01 03 03 01 01 01 20 03 01 01 01 38 01 3F C1 04 21 01 02 03 2C 01 01 C0 05 01 81 95 21 03 00 +10 M2UA.SEND 00 0E 05 01 80 00 A0 0A 00 02 02 00 03 80 11 01 +10 M2UA.SEND 00 12 05 01 80 00 A0 0A 00 0D 01 01 01 05 01 01 01 01 00 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 14 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 16 00 +10 M2UA.SEND 00 09 05 01 80 00 A0 0A 00 2E 00 +10 M2UA.SEND 00 0F 05 01 80 00 A0 0A 00 35 01 39 03 01 01 01 00 +10 M2UA.SEND 00 0F 05 01 80 00 A0 0A 00 34 01 39 03 01 01 01 00 +10 M2UA.SEND 00 14 05 01 80 00 A0 0A 00 2D 02 05 03 01 01 01 03 03 01 01 01 00 +10 M2UA.SEND 00 C9 05 01 80 00 A0 0A 00 01 15 7B 03 01 01 02 05 03 81 90 01 23 02 91 01 0B 03 81 14 01 13 02 11 11 1A 04 11 11 00 01 0D 07 01 01 01 01 00 01 01 28 03 81 14 01 20 02 01 01 03 03 01 01 01 1D 02 01 01 2A 01 2B 2B 02 02 00 34 02 01 01 32 02 01 01 39 02 01 01 2C 01 01 33 02 01 01 3A 06 21 11 11 00 00 01 3E 01 01 4C 0A 82 21 03 82 21 03 93 01 21 03 4B 01 01 5B 03 01 01 01 25 05 01 02 01 01 02 65 02 01 01 6E 03 01 01 01 6F 03 81 14 01 70 03 01 01 01 72 03 01 01 01 66 02 01 01 75 03 03 01 01 37 01 55 3D 01 01 79 01 01 FE 02 0F 00 FD 03 81 95 01 FC 03 81 95 01 FB 09 11 11 11 11 01 01 01 01 01 F4 02 01 81 00 +10 M2UA.SEND 00 21 05 01 80 00 A0 0A 00 42 01 38 01 3F 39 03 01 01 01 29 01 0F 08 01 0D 78 07 81 81 41 81 01 01 01 00 +10 M2UA.SEND 00 21 05 01 80 00 A0 0A 00 42 01 38 01 3F 39 03 01 01 01 29 01 0F 08 01 0D 78 07 81 81 41 81 01 01 01 00 + + + +10000000 M2UA.recv \ No newline at end of file diff --git a/omc/plat/m2ua/.copyarea.db b/omc/plat/m2ua/.copyarea.db new file mode 100644 index 0000000..45e5f21 --- /dev/null +++ b/omc/plat/m2ua/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua +2 +6 +3:doc|2|0|0|0|fbd9680cbfa411dc8544001c23e19543|0 +2:ut|2|0|0|0|11e96bfcbfa511dc8544001c23e19543|0 +7:src_old|2|0|0|0|07c96a3cbfa511dc8544001c23e19543|0 +3:src|2|0|0|0|fda9687cbfa411dc8544001c23e19543|0 +8:Makefile|1|11d70a3ff98|b43|554fc528|fd096860bfa411dc8544001c23e19543|0 +3:lib|2|0|0|0|fc696844bfa411dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/Makefile b/omc/plat/m2ua/Makefile new file mode 100644 index 0000000..2af2ba0 --- /dev/null +++ b/omc/plat/m2ua/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/m2ua/doc/.copyarea.db b/omc/plat/m2ua/doc/.copyarea.db new file mode 100644 index 0000000..0f7dbc1 --- /dev/null +++ b/omc/plat/m2ua/doc/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\doc +2 +1 +13:M2UA_R9V0_04P01.doc|1|11d70a40063|e400|4af957ec|fbd96828bfa411dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/doc/M2UA_R9V0_04P01.doc b/omc/plat/m2ua/doc/M2UA_R9V0_04P01.doc new file mode 100644 index 0000000..e58c1a6 Binary files /dev/null and b/omc/plat/m2ua/doc/M2UA_R9V0_04P01.doc differ diff --git a/omc/plat/m2ua/lib/libm2ua.a b/omc/plat/m2ua/lib/libm2ua.a new file mode 100644 index 0000000..4beca5a Binary files /dev/null and b/omc/plat/m2ua/lib/libm2ua.a differ diff --git a/omc/plat/m2ua/obj/m2ua.o b/omc/plat/m2ua/obj/m2ua.o new file mode 100644 index 0000000..36166c2 Binary files /dev/null and b/omc/plat/m2ua/obj/m2ua.o differ diff --git a/omc/plat/m2ua/obj/m2ua_debug.o b/omc/plat/m2ua/obj/m2ua_debug.o new file mode 100644 index 0000000..6ae2480 Binary files /dev/null and b/omc/plat/m2ua/obj/m2ua_debug.o differ diff --git a/omc/plat/m2ua/obj/m2ua_fsm.o b/omc/plat/m2ua/obj/m2ua_fsm.o new file mode 100644 index 0000000..be5faac Binary files /dev/null and b/omc/plat/m2ua/obj/m2ua_fsm.o differ diff --git a/omc/plat/m2ua/obj/m2ua_msg.o b/omc/plat/m2ua/obj/m2ua_msg.o new file mode 100644 index 0000000..b0852f4 Binary files /dev/null and b/omc/plat/m2ua/obj/m2ua_msg.o differ diff --git a/omc/plat/m2ua/src/.copyarea.db b/omc/plat/m2ua/src/.copyarea.db new file mode 100644 index 0000000..70f73e8 --- /dev/null +++ b/omc/plat/m2ua/src/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\src +2 +5 +c:m2ua_debug.c|1|11d70a401ab|2ef2|cdb83516|581648ca9a8611dd8b36001c23e19543|0 +a:m2ua_msg.c|1|11d70a400ef|175e8|3a2f7bcf|581648b29a8611dd8b36001c23e19543|0 +6:m2ua.c|1|11d70a4017c|2216|3cc9cd8a|ec5345be339011dd9fa7001c23e19543|0 +7:include|2|0|0|0|00996908bfa511dc8544001c23e19543|0 +a:m2ua_fsm.c|1|11d70a401e9|c086|40b0ae42|e91483be6cf311dd91a5001c23e19543|0 diff --git a/omc/plat/m2ua/src/include/.copyarea.db b/omc/plat/m2ua/src/include/.copyarea.db new file mode 100644 index 0000000..ea6968d --- /dev/null +++ b/omc/plat/m2ua/src/include/.copyarea.db @@ -0,0 +1,14 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\src\include +2 +a +c:m2ua_const.h|1|11d70a40350|3549|eb3921e3|ed93464e339011dd9fa7001c23e19543|0 +c:m2ua_debug.h|1|11d70a4041b|102|5d4353b1|05f96a04bfa511dc8544001c23e19543|0 +a:m2ua_msg.h|1|11d70a40321|6eb|e0335c89|ed934636339011dd9fa7001c23e19543|0 +a:m2ua_def.h|1|11d70a402b4|68d|2c90017f|ecf34606339011dd9fa7001c23e19543|0 +a:m2ua_ext.h|1|11d70a4038f|711|23a53b20|ee234666339011dd9fa7001c23e19543|0 +a:m2ua_fsm.h|1|11d70a403ec|8a|e7592b04|056969e8bfa511dc8544001c23e19543|0 +d:m2ua_struct.h|1|11d70a402f3|214d|6368b7e1|ecf3461e339011dd9fa7001c23e19543|0 +6:sctp.h|1|11d70a403be|4a78|3abef872|04c969ccbfa511dc8544001c23e19543|0 +6:m2ua.h|1|11d70a4045a|efe|ba074e5|ee23467e339011dd9fa7001c23e19543|0 +a:m2ua_pub.h|1|11d70a40276|46a|351c789a|01396924bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/src/include/m2ua.h b/omc/plat/m2ua/src/include/m2ua.h new file mode 100644 index 0000000..58c4238 --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_const.h b/omc/plat/m2ua/src/include/m2ua_const.h new file mode 100644 index 0000000..aa2477a --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_const.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_debug.h b/omc/plat/m2ua/src/include/m2ua_debug.h new file mode 100644 index 0000000..5e1915b --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_debug.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_def.h b/omc/plat/m2ua/src/include/m2ua_def.h new file mode 100644 index 0000000..2ac0358 --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_def.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_ext.h b/omc/plat/m2ua/src/include/m2ua_ext.h new file mode 100644 index 0000000..aed0952 --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_ext.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_fsm.h b/omc/plat/m2ua/src/include/m2ua_fsm.h new file mode 100644 index 0000000..b3ace0e --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_fsm.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_msg.h b/omc/plat/m2ua/src/include/m2ua_msg.h new file mode 100644 index 0000000..bc2e56a --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_msg.h @@ -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 diff --git a/omc/plat/m2ua/src/include/m2ua_pub.h b/omc/plat/m2ua/src/include/m2ua_pub.h new file mode 100644 index 0000000..694861b --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_pub.h @@ -0,0 +1,65 @@ +#ifndef _M2UA_PUB__H +#define _M2UA_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//by simon at 23/9/22 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _LKSCTP +#include +#include +#include +#include +#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 diff --git a/omc/plat/m2ua/src/include/m2ua_struct.h b/omc/plat/m2ua/src/include/m2ua_struct.h new file mode 100644 index 0000000..abc9d3f --- /dev/null +++ b/omc/plat/m2ua/src/include/m2ua_struct.h @@ -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 diff --git a/omc/plat/m2ua/src/include/sctp.h b/omc/plat/m2ua/src/include/sctp.h new file mode 100644 index 0000000..2cadd6e --- /dev/null +++ b/omc/plat/m2ua/src/include/sctp.h @@ -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 + * + * Or submit a bug report through the following website: + * http://www.sf.net/projects/lksctp + * + * Written or modified by: + * La Monte H.P. Yarroll + * R. Stewart + * K. Morneau + * Q. Xie + * Karl Knutson + * Jon Grimm + * Daisy Chang + * Inaky Perez-Gonzalez + * Sridhar Samudrala + * + * 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 +#include +#include + +__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 . + */ +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 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__ */ diff --git a/omc/plat/m2ua/src/m2ua.c b/omc/plat/m2ua/src/m2ua.c new file mode 100644 index 0000000..e27c36d --- /dev/null +++ b/omc/plat/m2ua/src/m2ua.c @@ -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; +} + + diff --git a/omc/plat/m2ua/src/m2ua_debug.c b/omc/plat/m2ua/src/m2ua_debug.c new file mode 100644 index 0000000..ccca41f --- /dev/null +++ b/omc/plat/m2ua/src/m2ua_debug.c @@ -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; +} diff --git a/omc/plat/m2ua/src/m2ua_fsm.c b/omc/plat/m2ua/src/m2ua_fsm.c new file mode 100644 index 0000000..32b90de --- /dev/null +++ b/omc/plat/m2ua/src/m2ua_fsm.c @@ -0,0 +1,1571 @@ +#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 "./include/m2ua_msg.h" +#include "./include/m2ua_debug.h" + + +int find_sg_by_ipv4(DWORD ipv4,uint16_t sg_id) +{ + WORD sg; + BYTE type; + BYTE ascitemp_buf[256]; + BYTE mask; + + if (sg_id == M2UA_LISTEN_SG_NUM_0 || + sg_id == M2UA_LISTEN_SG_NUM_1) + { + type = M2UA_APP; + mask = sg_id - M2UA_LISTEN_SG_NUM_0; + } + else if (sg_id == IUA_LISTEN_SG_NUM_0 || + sg_id == IUA_LISTEN_SG_NUM_1) + { + type = IUA_APP; + mask = sg_id - IUA_LISTEN_SG_NUM_0; + } + else if (sg_id == M3UA_LISTEN_SG_NUM_0 || + sg_id == M3UA_LISTEN_SG_NUM_1) + { + type = M3UA_APP; +// mask = sg_id - M3UA_LISTEN_SG_NUM_0; + mask = 0; + } + + for (sg = 0; sg < M2UA_MAX_SG_NUM; sg++) + { + if (m2ua_para.sg_para[sg].enable && + m2ua_sg_info[sg].enable && + m2ua_para.sg_para[sg].server && + ((m2ua_para.sg_para[sg].xUA_ack>>1)==type) && + (m2ua_para.sg_para[sg].ip == ipv4) + ) + return sg; + } + + sprintf(ascitemp_buf, "can't find sg by ipv4: %X\n\r", ipv4); + m2ua_log_err(sg_id, ascitemp_buf); + return -1; +} + +int rel_sid(WORD sg, BYTE lk) +{ + WORD ostr; + BYTE dw_index, bit_index; + + if (m2ua_lk_info[lk].sid == 0) + return -1; + + ostr = m2ua_lk_info[lk].sid - 1; + m2ua_lk_info[lk].sid = 0; + + dw_index = ostr / 32; + bit_index = ostr % 32; + + m2ua_sg_info[sg].sid_st[dw_index] &= (~(0x00000001 << bit_index)); + m2ua_sg_info[sg].rem_ostrs++; + + return 0; +} + +int assign_sid(WORD sg, BYTE lk) +{ + WORD i; + BYTE dw_index, bit_index; + + if ((m2ua_sg_info[sg].ostrs < 2) ||(m2ua_sg_info[sg].ostrs > 257) || + (m2ua_sg_info[sg].rem_ostrs == 0) || (m2ua_lk_info[lk].sid > 0)) + return -1; + + for (i = 0; i < m2ua_sg_info[sg].ostrs - 1; i++) + { + dw_index = i / 32; + bit_index = i % 32; + if ((m2ua_sg_info[sg].sid_st[dw_index] >> bit_index) & 1) + continue; + else + { + m2ua_sg_info[sg].sid_st[dw_index] |= (0x00000001 << bit_index); + m2ua_sg_info[sg].rem_ostrs--; + m2ua_lk_info[lk].sid = i + 1; + return 0; + } + } + + return -1; +} + +int rel_sg_lk(WORD sg_id) +{ + WORD lk; + BYTE flag = 0; + + if ((m2ua_para.sg_para[sg_id].enable == 0) || + (m2ua_para.sg_para[sg_id].enable == 2)) + flag = 1; + + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + ; + } + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && + m2ua_lk_info[lk].enable) + { + rel_sid(sg_id, lk); + if (m2ua_lk_info[lk].lk_st > M2UA_LK_DOWN) + { + m2ua_lk_info[lk].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[lk].alarm_code = m2ua_sg_info[sg_id].alarm_code; + m2ua_sd_mtp3_primi(lk, M2UA_LK_DOWN); + m2ua_csta.lk_csta[lk].lk_dn_times++; + } + if (flag) + { + m2ua_lk_info[lk].enable = 0; + m2ua_lk_info[lk].lk_st = M2UA_LK_IDLE; + } + } + } + + m2ua_sg_info[sg_id].up_lks_cur = 0; + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_NORMAL; + + return 0; +} + + +int chg_sg_lk_status(WORD sg_id, BYTE status) +{ + WORD lk; + + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && + m2ua_lk_info[lk].enable) + m2ua_lk_info[lk].lk_st = status; + } + + return 1; +} + +int m2ua_fsm(WORD sg_id) +{ + WORD m2ua_cmd, mtp3_cmd, mgmt_cmd; + BYTE iid, lk_enable; + BYTE server; + int ret_val; + + m2ua_cmd = m2ua_sg_info[sg_id].m2ua_cmd; + mtp3_cmd = m2ua_sg_info[sg_id].mtp3_cmd; + mgmt_cmd = m2ua_sg_info[sg_id].mgmt_cmd; + + if (m2ua_sg_info[sg_id].m2ua_state < 3) + { + if (mgmt_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].mgmt_cmd = M2UA_CMD_IDLEW; + if (mtp3_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + } + + server = m2ua_para.sg_para[sg_id].server; + iid = m2ua_sg_info[sg_id].iid; + lk_enable = m2ua_para.lk_para[iid].enable; + + switch (m2ua_sg_info[sg_id].m2ua_state) + { + case 0: // Wait For M2UA ASP Up, or send ASP Up + if (server) + { + if (m2ua_cmd != M2UA_CMD_IDLEW) + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_INACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 1; + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + chg_sg_lk_status(sg_id, M2UA_LK_UP); + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m3ua_sd_mtp3_user_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + } + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + else if ((m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) || + (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE)) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + } + } + else + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + m2ua_sg_info[sg_id].m2ua_state = 1; + m2ua_sg_info[sg_id].retrans_times = 0; + } + break; + case 1: // Wait For M2UA ASP Active, or wait for ASP Up Ack + if (server) + { + if (m2ua_cmd != M2UA_CMD_IDLEW) + { + if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_ACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + else if (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE_ACK); + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 0; + } + } + + if (m2ua_sg_info[sg_id].T_r > 0) + { + if (--m2ua_sg_info[sg_id].T_r == 0) + { + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_INACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + } + } + } + else + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP_ACK) + { + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + chg_sg_lk_status(sg_id, M2UA_LK_UP); + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m3ua_sd_mtp3_user_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + } + else //m2ua iua + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + m2ua_sg_info[sg_id].m2ua_state = 2; + m2ua_sg_info[sg_id].retrans_times = 0; + } + } + else if (m2ua_sg_info[sg_id].T_ack > 0) + { + if (--m2ua_sg_info[sg_id].T_ack == 0) + { + if (++m2ua_sg_info[sg_id].retrans_times >= M2UA_MAX_RETRANS) + return -2; + else + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + } + } + } + } + break; + case 2: // Wait for ASP ACTIVE ACK, only client can come to this state + if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE_ACK) + { + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + chg_sg_lk_status(sg_id, M2UA_LK_DOWN); + m2ua_sg_info[sg_id].retrans_times = 0; + } + else if (m2ua_cmd == M2UA_MGMT_ERROR) + { + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].retrans_times = 0; + m2ua_sg_info[sg_id].m2ua_state = 0; + return -2; + } + else if (m2ua_sg_info[sg_id].T_ack > 0) + { + if (--m2ua_sg_info[sg_id].T_ack == 0) + { + if (++m2ua_sg_info[sg_id].retrans_times >= M2UA_MAX_RETRANS) + return -2; + else + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + } + } + } + break; + case 3: // M2UA ASP Active + if (mgmt_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mgmt_cmd = M2UA_CMD_IDLEW; + if (((mgmt_cmd == M2UA_MGMT_CMD_LK_LOCK) + ||(mgmt_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MGMT_CMD_LK_LOCK))) + &&(m2ua_lk_info[iid].lk_st >= M2UA_LK_UP)) + { + if (server) + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + else + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + rel_sid(sg_id, iid); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((mgmt_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MGMT_CMD_LK_LOCK)) && + (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP)) + { + if (server) + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_IND); + else + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + rel_sid(sg_id, iid); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((mgmt_cmd == COMBO_W(M3UA_MGMT_CMD,M2UA_MGMT_CMD_LK_LOCK)) && + (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE; + m3ua_sd_mtp3_user_primi(iid, M2UA_LK_DOWN); + rel_sid(sg_id, iid); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + return -1; + } + + if (server) + { + if (mtp3_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && + ( (mtp3_cmd == M2UA_MTP3_CMD_DEACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_STOP_L2) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)) + )) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && + ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)))) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_IND); + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if (mtp3_cmd == COMBO_W(M3UA_RC_CMD,xUA_MTP3_CMD_DEACTIVE_RC)) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE); + } + else if (m2ua_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd == M2UA_MAUP_DATA) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + m2ua_sd_mtp3_msg(sg_id, iid); + err[13]++; + } + return 0; + } + else if (m2ua_cmd == M2UA_MAUP_ESTABLISH_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_CFM); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m2ua_sd_mtp3_primi(iid, M2UA_LK_UP); + } + } + } + else if (m2ua_cmd == M2UA_MAUP_RELEASE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_CFM); + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + } + } + else if (m2ua_cmd == M2UA_MAUP_STATE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + ret_val = assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + if (m2ua_sg_info[sg_id].state == M2UA_STATUS_AUDIT) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_CFM); + else + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + } + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_CFM); + if (ret_val != -1) + rel_sid(sg_id, iid); + } + } + } + else if (m2ua_cmd == IUA_QPTM_DATA_REQ ||m2ua_cmd == IUA_QPTM_UDATA_REQ || + m2ua_cmd == IUA_QPTM_DATA_IND ||m2ua_cmd == IUA_QPTM_UDATA_IND) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + iua_sd_q931_msg(sg_id, iid); + err[13]++; + } + return 0; + } + else if (m2ua_cmd == M3UA_MAUP_DATA) + { + m3ua_sd_mtp3_user_msg(sg_id); + return 0; + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, IUA_QPTM_ESTABLISH_CFM); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + } + } + } + else if (m2ua_cmd == IUA_QPTM_RELEASE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_CFM); + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + } + } + else if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) + { + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) != M3UA_APP) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE_ACK); + } + else if ((m2ua_cmd == M2UA_ASPSM_ASP_DOWN) || + (m2ua_cmd == M2UA_ASPSM_ASP_UP) || + (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE)) + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + if(m2ua_sg_info[sg_id].status == ((M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_ACTIVE)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + m2ua_sg_info[sg_id].m2ua_state = 1; + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_PENDING; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].m2ua_state = 0; + } + else if (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE) + { + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) != M3UA_APP) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE_ACK); + } + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) != M3UA_APP) + { + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_REMOTE_AS_DOWN; + rel_sg_lk(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + m2ua_csta.sg_csta[sg_id].sg_asp_dn_times++; + } + } + } + } + else + { + if (mtp3_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if ((mtp3_cmd == M2UA_MTP3_CMD_ACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_ACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_EMERG_ALIGN)) + ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1) && + (!m2ua_lk_info[iid].lk_timer)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + if (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) + { + m2ua_sg_info[sg_id].state = M2UA_STATUS_EMER_SET; + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_REQ); + } + else if (mtp3_cmd == M2UA_MTP3_CMD_ACTIVE_LK) + { + m2ua_sg_info[sg_id].state = M2UA_STATUS_EMER_CLEAR; + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_REQ); + } + if (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + else + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + } + } + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && (!m2ua_lk_info[iid].lk_timer) && + ((mtp3_cmd == M2UA_MTP3_CMD_DEACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_STOP_L2) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)) + )) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_ACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_EMERG_ALIGN))) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1) && + (!m2ua_lk_info[iid].lk_timer)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + /* + if (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) + { + m2ua_sg_info[sg_id].state = M2UA_STATUS_EMER_SET; + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_REQ); + } + */ + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; +// if (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) + if (m2ua_lk_info[iid].lk_st > M2UA_LK_UP) + { + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + else + m2ua_send_msg(sg_id, IUA_QPTM_ESTABLISH_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + } + } + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && (!m2ua_lk_info[iid].lk_timer) && + ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)))) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && (!m2ua_lk_info[iid].lk_timer) && + ((mtp3_cmd == COMBO_W(M3UA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M3UA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)))) + { + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m3ua_sd_mtp3_user_primi(iid, M2UA_LK_DOWN); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if (mtp3_cmd == COMBO_W(M3UA_RC_CMD,xUA_MTP3_CMD_ACTIVE_RC)) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE); + } + else if (mtp3_cmd == COMBO_W(M3UA_RC_CMD,xUA_MTP3_CMD_DEACTIVE_RC)) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE); + } + } + else if (m2ua_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd == M2UA_MAUP_DATA) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + err[13]++; + m2ua_sd_mtp3_msg(sg_id, iid); +// if ((m2ua_para.sg_para[sg_id].data_ack == 1) && + if (((m2ua_para.sg_para[sg_id].xUA_ack&0x01) == 0x01) && + (m2ua_sg_info[sg_id].cor_id != 0)) + m2ua_send_msg(sg_id, M2UA_MAUP_DATA_ACK); + } + return 0; + } + else if (m2ua_cmd == M2UA_MAUP_ESTABLISH_CFM) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m2ua_sd_mtp3_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + } + else if (m2ua_cmd == M2UA_MAUP_RELEASE_IND) + { + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + else if (m2ua_cmd == IUA_QPTM_DATA_IND ||m2ua_cmd == IUA_QPTM_UDATA_IND || + m2ua_cmd == IUA_QPTM_DATA_REQ ||m2ua_cmd == IUA_QPTM_UDATA_REQ) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + err[13]++; + iua_sd_q931_msg(sg_id, iid); + } + return 0; + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_CFM) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_IND) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + } + } + else if (m2ua_cmd == IUA_QPTM_RELEASE_IND) + { + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + else if (m2ua_cmd == M3UA_MAUP_DATA) + { + m3ua_sd_mtp3_user_msg(sg_id); + return 0; + } + else if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE_ACK) + { + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_UP); + } + } + } + break; + default: + m2ua_sg_info[sg_id].m2ua_state = 0; + break; + } + + return -1; +} + +int m2ua_sctp_down(WORD sg_id) +{ + if (m2ua_sg_info[sg_id].m2ua_state == 3) + m2ua_csta.sg_csta[sg_id].sg_asp_dn_times++; + + m2ua_sg_info[sg_id].m2ua_state = 0; + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].T_r = 0; + + m2ua_sg_info[sg_id].sctp_cmd = M2UA_CMD_IDLEW; + + rel_sg_lk(sg_id); + + m2ua_sg_info[sg_id].up_lks_pre = m2ua_sg_info[sg_id].up_lks_cur = 0; + + return 0; +} + +int m2ua_sg_fsm(WORD sg_id) +{ + int fd; + int msg, con_sg, ret; + BYTE enable; + BYTE conn_id; + BYTE server; + DWORD sctp_cmd; +#ifndef _LKSCTP + struct t_opthdr *oh; + t_scalar_t *str_val; + m2ua_sctp_addr_t *addr; +#else + struct sctp_assoc_change *sac; + int new_fd, addr_len; + struct sockaddr_in sin[1]; + BYTE ascitemp_buf[256]; + struct timeval TOut = {0, 0}; + fd_set ReadFds; +#endif + + if (((m2ua_sg_info[sg_id].enable == 0) ||(m2ua_sg_info[sg_id].fd == 0)) && + !((m2ua_sg_info[sg_id].sctp_state == 3) && (m2ua_sg_info[sg_id].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + return -1; + else + { + fd = m2ua_sg_info[sg_id].fd; + sctp_cmd = m2ua_sg_info[sg_id].sctp_cmd; + if (sg_id < M2UA_MAX_SG_NUM) + { + enable = m2ua_para.sg_para[sg_id].enable; + server = m2ua_para.sg_para[sg_id].server; + } + else + { + con_sg = m2ua_sg_info[sg_id].con_sg; + enable = m2ua_para.sg_para[con_sg].enable; + server = m2ua_para.sg_para[con_sg].server; + } + } + + switch (m2ua_sg_info[sg_id].sctp_state) + { + case 0: // SCTP Option Negotiate + if (((enable == 0) || (enable == 2)) && + (sg_id < M2UA_MAX_SG_NUM)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Send optmgnt request +#ifndef _LKSCTP + m2ua_sctp_optmgmt_req(fd, sg_id, T_NEGOTIATE); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#else + if (m2ua_sctp_optmgmt_req_lksctp(fd, sg_id) == 0) + { + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + else + { + if ((sg_id >= M2UA_MAX_SG_NUM) || + ((sg_id < M2UA_MAX_SG_NUM) && !server)) + { // Client or Listener + m2ua_sg_info[sg_id].sctp_state = 1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else + { // Server + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 5; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + } +#endif + break; + case 1: // Receive optmgmt response +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_OPTMGMT_ACK) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state = 1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer) +#else + if (m2ua_sg_info[sg_id].sg_timer) +#endif + m2ua_sg_info[sg_id].sg_timer--; + else + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + break; + case 1: // SCTP Address Bind + if (((enable == 0) || (enable == 2)) && + (sg_id < M2UA_MAX_SG_NUM)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Send bind request + //if (sg_id == M2UA_MAX_SG_NUM) + if (sg_id >= M2UA_MAX_SG_NUM) + conn_id = 1; + else + conn_id = 0; + m2ua_sctp_addr.addr.s_addr = htonl(INADDR_ANY); +#ifndef _LKSCTP + if (sg_id == M2UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M2UA_PORT_0); + else if (sg_id == M2UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M2UA_PORT_1); + else if (sg_id == IUA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(IUA_PORT_0); + else if (sg_id == IUA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(IUA_PORT_1); + else if (sg_id == M3UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M3UA_PORT_0); + else if (sg_id == M3UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M3UA_PORT_1); + else if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M2UA_APP) + m2ua_sctp_addr.port = htons(M2UA_PORT_0+20000); + else if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == IUA_APP) + m2ua_sctp_addr.port = htons(IUA_PORT_0+20000); + else if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + m2ua_sctp_addr.port = htons(M3UA_PORT_0+20000); + m2ua_sctp_bind_req(fd, sg_id, &m2ua_sctp_addr, conn_id); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#else + if ((sg_id >= M2UA_MAX_SG_NUM) || + ((sg_id < M2UA_MAX_SG_NUM) && !server)) + { // Client or Listener + if (sg_id == M2UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M2UA_PORT_0); + else if (sg_id == M2UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M2UA_PORT_1); + else if (sg_id == IUA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(IUA_PORT_0); + else if (sg_id == IUA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(IUA_PORT_1); + else if (sg_id == M3UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M3UA_PORT_0); + else if (sg_id == M3UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M3UA_PORT_1); + else + m2ua_sctp_addr.port = 0; + if (m2ua_sctp_bind_req_lksctp(fd, sg_id, &m2ua_sctp_addr, conn_id) == 0) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + break; + } + } + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; +#endif + break; + case 1: // Receive bind response +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_BIND_ACK) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer) +#else + if (m2ua_sg_info[sg_id].sg_timer) +#endif + m2ua_sg_info[sg_id].sg_timer--; + else + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + break; + case 2: // Wait for SCTP Connection Request from peer or Send conn req to the peer + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Wait for connection indication from peer or conn req to the peer + if (sg_id >= M2UA_MAX_SG_NUM) + { +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_CONN_IND) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].seq = m2ua_sctp_cmd.tpi.conn_ind.SEQ_number; + addr = (m2ua_sctp_addr_t *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_ind.SRC_offset); + con_sg = find_sg_by_ipv4(addr->addr.s_addr,sg_id); + if (con_sg < 0) + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + else + { + oh = (struct t_opthdr *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_ind.OPT_offset); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_ISTREAMS) + m2ua_sg_info[sg_id].istrs = *str_val; + oh = (struct t_opthdr *)((BYTE *)oh + oh->len); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_OSTREAMS) + m2ua_sg_info[sg_id].ostrs = *str_val; + m2ua_sg_info[sg_id].con_sg = con_sg; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + } + } +#else + FD_ZERO(&ReadFds); + FD_SET(fd, &ReadFds); + if ((select(fd + 1, &ReadFds, NULL, NULL, &TOut) > 0) && + FD_ISSET(fd, &ReadFds)) + { + addr_len = sizeof(*sin); + if ((new_fd = accept(fd, (struct sockaddr *)sin, &addr_len)) > 0) + { + if (fcntl(new_fd, F_SETFL, O_NONBLOCK) < 0) + m2ua_log_err(sg_id, "got lksctp incoming connection, but set nonblock failure!"); + + con_sg = find_sg_by_ipv4(sin->sin_addr.s_addr,sg_id); + if ((con_sg < 0) || (m2ua_sg_info[con_sg].enable == 0)) + { + if (con_sg < 0) + sprintf(ascitemp_buf, "got lksctp incoming connection, but can't find sg by ipv4: %X\n\r", sin->sin_addr.s_addr); + else + sprintf(ascitemp_buf, "got lksctp incoming connection, but sg[%d] not enabled!\n\r", con_sg); + m2ua_log_err(sg_id, ascitemp_buf); +// m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_sctp_discon_req_lksctp(new_fd, sg_id, 0); + } + else if ((m2ua_sg_info[con_sg].sctp_state == 3) && + (m2ua_sg_info[con_sg].sctp_state_1 == 0)) + { +// m2ua_sg_info[con_sg].sctp_cmd = M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST; + sprintf(ascitemp_buf, "got lksctp incoming connection, but sg[%d] is still in ESTABLISHED state! Disconnect it!\n\r", con_sg); + m2ua_log_err(sg_id, ascitemp_buf); + m2ua_sctp_discon_req_lksctp(new_fd, sg_id, 0); + } + else + { + m2ua_sg_info[con_sg].fd = new_fd; + m2ua_sg_info[con_sg].rem_port = sin->sin_port; + } + } + } +#endif + } + else + { + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (sctp_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].sctp_cmd = M2UA_CMD_IDLEW; + + if (!server && (enable == 1)) + { // M2UA Client + m2ua_sctp_server_addr.port = htons(m2ua_para.sg_para[sg_id].plat_port[0]); + m2ua_sctp_server_addr.addr.s_addr = m2ua_para.sg_para[sg_id].ip; + if (m2ua_sg_info[sg_id].sg_timer) + m2ua_sg_info[sg_id].sg_timer--; +#ifndef _LKSCTP + else if (m2ua_sctp_conn_req(fd, sg_id, &m2ua_sctp_server_addr) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 3; + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + } +#else + else if (m2ua_sctp_conn_req_lksctp(fd, sg_id, &m2ua_sctp_server_addr) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_2; + m2ua_sg_info[sg_id].sctp_state_1 = 4; + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + } +#endif + else + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + } + break; +#ifndef _LKSCTP + case 1: // Only SG_ID = M2UA_MAX_SG_NUM can come to this state + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 2)) + { + m2ua_sg_info[con_sg].seq = m2ua_sg_info[sg_id].seq; + m2ua_sg_info[con_sg].istrs = m2ua_sg_info[sg_id].istrs; + m2ua_sg_info[con_sg].ostrs = m2ua_sg_info[sg_id].ostrs; + m2ua_sg_info[con_sg].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + + if (m2ua_sctp_conn_res(fd, m2ua_sg_info[con_sg].fd, sg_id, m2ua_sg_info[sg_id].seq) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state_1 = 2; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + chg_sg_lk_status(con_sg, M2UA_LK_IDLE); + break; + } + } + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + m2ua_sg_info[sg_id].sctp_state_1 = 0; + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 3)) + m2ua_sg_info[con_sg].sctp_cmd = T_DISCON_IND; + break; + case 2: // Only SG_ID = M2UA_MAX_SG_NUM can come to this state + if (expect(fd, sg_id, &msg, T_OK_ACK) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + + m2ua_sg_info[con_sg].sctp_state = 3; + m2ua_sg_info[con_sg].sctp_state_1 = 0; + } + else if ((msg == T_ERROR_ACK) || (!m2ua_sg_info[sg_id].sg_timer)) + { + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 3)) + m2ua_sg_info[con_sg].sctp_cmd = T_DISCON_IND; + } + else + m2ua_sg_info[sg_id].sg_timer--; + break; + case 3: // Only M2UA client can come to this state + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sctp_close(fd, sg_id); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (expect(fd, sg_id, &msg, T_OK_ACK) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_2; + m2ua_sg_info[sg_id].sctp_state_1 = 4; + } + else if (msg == T_ERROR_ACK) + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + break; +#endif + case 4: // only M2UA client can come to this state + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_CONN_CON) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sg_timer = 0; + oh = (struct t_opthdr *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_con.OPT_offset); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_ISTREAMS) + m2ua_sg_info[sg_id].istrs = *str_val; + oh = (struct t_opthdr *)((BYTE *)oh + oh->len); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_OSTREAMS) + { + m2ua_sg_info[sg_id].ostrs = *str_val; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + } + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } +#else + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP) == M2UA_SUCCESS) + { + sac = (struct sctp_assoc_change *) m2ua_sctp_dat; + m2ua_sg_info[sg_id].istrs = sac->sac_inbound_streams; + m2ua_sg_info[sg_id].ostrs = sac->sac_outbound_streams; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sctp_optmgmt_req_lksctp_ext(fd, sg_id); + } +#endif + else + { +#ifndef _LKSCTP + if (msg == T_DISCON_IND) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } +#else + if (msg == M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + } +#endif + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { +#ifndef _LKSCTP + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#endif + } + } + break; +#ifdef _LKSCTP + case 5: // only M2UA server_lksctp can come to this state + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 0); + + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP) == M2UA_SUCCESS) + { + sac = (struct sctp_assoc_change *) m2ua_sctp_dat; + m2ua_sg_info[sg_id].istrs = sac->sac_inbound_streams; + m2ua_sg_info[sg_id].ostrs = sac->sac_outbound_streams; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sctp_optmgmt_req_lksctp_ext(fd, sg_id); + } + else + { + if (msg == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 1);//fixed by zane + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 1);//fixed by zane + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + } + break; +#endif + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + }; + break; + case 3: // M2UA SCTP Link Established + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Normal +#ifndef _LKSCTP + if ((enable == 0) || (enable == 2) || (sctp_cmd == T_DISCON_IND) || + (!server && !m2ua_sg_info[sg_id].up_lks_cur && m2ua_sg_info[sg_id].up_lks_pre)) + { + if ((enable == 0) || (enable == 2)) + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + else + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_discon_req(fd, sg_id, 0); +#else + if ((enable == 0) || (enable == 2) || (sctp_cmd == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) || + (!server && !m2ua_sg_info[sg_id].up_lks_cur && m2ua_sg_info[sg_id].up_lks_pre)) + { + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + } + else + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + } +#endif + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if ((enable == 0) || (enable == 2)) + { + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + } + else + { + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_log_err(sg_id, "All links are down, to reestablish the SCTP link!"); + } + + return -1; + } + else if (m2ua_sg_info[sg_id].up_lks_pre != m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_pre = m2ua_sg_info[sg_id].up_lks_cur; + +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_DATA_IND) == M2UA_FAILURE) + { // Handle SCTP Primitives + if ((msg == T_DISCON_IND) || (msg == T_ORDREL_IND)) + { + if (msg == T_ORDREL_IND) + m2ua_sctp_ordrel_req(fd, sg_id); +#else + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_DATA_IND) == M2UA_FAILURE) + { // Handle SCTP Primitives + if ((msg == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) || + (msg == M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP) || + (msg == M2UA_LKSCTP_SHUTDOWN_EVENT)) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + if(server) + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_WAIT; + else + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_log_err(sg_id, "Got discon_ind from SCTP, wait to reestablish the SCTP link!"); + + return -1; + } +#ifdef _LKSCTP + else if (msg == M2UA_LKSCTP_ASSOC_CHANGE_RESTART) + { + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + m2ua_log_err(sg_id, "Got M2UA_LKSCTP_ASSOC_CHANGE_RESTART from SCTP!"); + return -1; + } +#endif + ret = -1; + } + else + { + m2ua_dec_msg(sg_id); + ret = 0; + } + + if ((m2ua_fsm(sg_id) == -2) && (!server)) + { +#ifndef _LKSCTP + m2ua_sctp_discon_req(fd, sg_id, 0); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1);//fixed by zane +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_REMOTE_AS_DOWN; + m2ua_sctp_down(sg_id); + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + + m2ua_log_err(sg_id, "ASP UP/ACTIVE timeout, wait to reestablish the SCTP link!"); + + return -2; + } + else + return ret; + break; + case 1: // Wait... + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } +#ifndef _LKSCTP + if ((m2ua_sg_info[sg_id].sg_timer--) > 0) + expect(fd, sg_id, &msg, T_OK_ACK); + else + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } +#else + if ((m2ua_sg_info[sg_id].sg_timer--) > 0); + //expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_DATA_IND); + else + { + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } +#endif + break; + default: + break; + } + break; + default: + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + + return -1; +} + + diff --git a/omc/plat/m2ua/src/m2ua_msg.c b/omc/plat/m2ua/src/m2ua_msg.c new file mode 100644 index 0000000..e6cce24 --- /dev/null +++ b/omc/plat/m2ua/src/m2ua_msg.c @@ -0,0 +1,3481 @@ +#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 "./include/m2ua_fsm.h" +#include "./include/m2ua_debug.h" +#include "./include/m2ua_msg.h" + + +#ifndef _LKSCTP + +static struct strfdinsert m2ua_sctp_fdi = +{ + {M2UA_SCTP_CMD_BUFSIZE, 0, m2ua_sctp_cmd.cbuf}, + {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat}, + 0, + 0, + 0 +}; + +static m2ua_sctp_opt_data_t m2ua_sctp_opt_data = +{ + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SID, + T_SUCCESS + }, + 0 +}; + +m2ua_sctp_opt_optm_t m2ua_sctp_opt_optm = +{ + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_NODELAY, + T_SUCCESS + }, + T_YES, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_CORK, + T_SUCCESS + }, + T_YES, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_PPI, + T_SUCCESS + }, + 2, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SID, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RECVOPT, + T_SUCCESS + }, + T_NO, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_COOKIE_LIFE, + T_SUCCESS + }, + 60000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SACK_DELAY, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_PATH_MAX_RETRANS, + T_SUCCESS + }, + 5, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_ASSOC_MAX_RETRANS, + T_SUCCESS + }, + 5, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_MAX_INIT_RETRIES, + T_SUCCESS + }, + 8, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_HEARTBEAT_ITVL, + T_SUCCESS + }, + 20000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_INITIAL, + T_SUCCESS + }, + 1000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_MIN, + T_SUCCESS + }, + 1000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_MAX, + T_SUCCESS + }, + 5000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_OSTREAMS, + T_SUCCESS + }, + 257, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_ISTREAMS, + T_SUCCESS + }, + 257, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_COOKIE_INC, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_THROTTLE_ITVL, + T_SUCCESS + }, + 50, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_MAC_TYPE, + T_SUCCESS + }, + SCTP_HMAC_NONE, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_DEBUG, + T_SUCCESS + }, + 0 +}; + +#endif +extern int check_m3ua_rc_verify(DWORD rc); + +char *dec_m2ua_msg(WORD m2ua_msg) +{ + switch (m2ua_msg) + { + case M2UA_MAUP_DATA: return("M2UA_MAUP_DATA"); + case M2UA_MAUP_ESTABLISH_REQ: return("M2UA_MAUP_ESTABLISH_REQ"); + case M2UA_MAUP_ESTABLISH_CFM: return("M2UA_MAUP_ESTABLISH_CFM"); + case M2UA_MAUP_RELEASE_REQ: return("M2UA_MAUP_RELEASE_REQ"); + case M2UA_MAUP_RELEASE_CFM: return("M2UA_MAUP_RELEASE_CFM"); + case M2UA_MAUP_RELEASE_IND: return("M2UA_MAUP_RELEASE_IND"); + case M2UA_MAUP_STATE_REQ: return("M2UA_MAUP_STATE_REQ"); + case M2UA_MAUP_STATE_CFM: return("M2UA_MAUP_STATE_CFM"); + case M2UA_MAUP_STATE_IND: return("M2UA_MAUP_STATE_IND"); + case M2UA_MAUP_DATA_RETIEVE_REQ: return("M2UA_MAUP_DATA_RETIEVE_REQ"); + case M2UA_MAUP_DATA_RETIEVE_CFM: return("M2UA_MAUP_DATA_RETIEVE_CFM"); + case M2UA_MAUP_DATA_RETIEVE_IND: return("M2UA_MAUP_DATA_RETIEVE_IND"); + case M2UA_MAUP_DATA_RETIEVE_CMP: return("M2UA_MAUP_DATA_RETIEVE_CMP"); + case M2UA_MAUP_CONGESTION_IND: return("M2UA_MAUP_CONGESTION_IND"); + case M2UA_MAUP_DATA_ACK: return("M2UA_MAUP_DATA_ACK"); + + case xUA_MGMT_ERROR: return("xUA_MGMT_ERROR"); + case xUA_MGMT_NOTIFY: return("xUA_MGMT_NOTIFY"); + case xUA_MGMT_TEI_S_REQ: return("xUA_MGMT_TEI_S_REQ"); + case xUA_MGMT_TEI_S_CFM: return("xUA_MGMT_TEI_S_CFM"); + case xUA_MGMT_TEI_S_IND: return("xUA_MGMT_TEI_S_IND"); + + case xUA_ASPSM_ASP_UP: return("xUA_ASPSM_ASP_UP"); + case xUA_ASPSM_ASP_DOWN: return("xUA_ASPSM_ASP_DOWN"); + case xUA_ASPSM_HEARTBEAT: return("xUA_ASPSM_HEARTBEAT"); + case xUA_ASPSM_ASP_UP_ACK: return("xUA_ASPSM_ASP_UP_ACK"); + case xUA_ASPSM_ASP_DOWN_ACK: return("xUA_ASPSM_ASP_DOWN_ACK"); + case xUA_ASPSM_HEARTBEAT_ACK: return("xUA_ASPSM_HEARTBEAT_ACK"); + + case xUA_ASPTM_ASP_ACTIVE: return("xUA_ASPTM_ASP_ACTIVE"); + case xUA_ASPTM_ASP_INACTIVE: return("xUA_ASPTM_ASP_INACTIVE"); + case xUA_ASPTM_ASP_ACTIVE_ACK: return("xUA_ASPTM_ASP_ACTIVE_ACK"); + case xUA_ASPTM_ASP_INACTIVE_ACK: return("xUA_ASPTM_ASP_INACTIVE_ACK"); + + case IUA_QPTM_DATA_REQ: return("IUA_QPTM_DATA_REQ"); + case IUA_QPTM_DATA_IND: return("IUA_QPTM_DATA_IND"); + case IUA_QPTM_UDATA_REQ: return("IUA_QPTM_UDATA_REQ"); + case IUA_QPTM_UDATA_IND: return("IUA_QPTM_UDATA_IND"); + case IUA_QPTM_ESTABLISH_REQ: return("IUA_QPTM_ESTABLISH_REQ"); + case IUA_QPTM_ESTABLISH_CFM: return("IUA_QPTM_ESTABLISH_CFM"); + case IUA_QPTM_ESTABLISH_IND: return("IUA_QPTM_ESTABLISH_IND"); + case IUA_QPTM_RELEASE_REQ: return("IUA_QPTM_RELEASE_REQ"); + case IUA_QPTM_RELEASE_CFM: return("IUA_QPTM_RELEASE_CFM"); + case IUA_QPTM_RELEASE_IND: return("IUA_QPTM_RELEASE_IND"); + + case M3UA_MAUP_DATA: return("M3UA_MAUP_DATA"); + + case M3UA_SSNM_DUNA: return("M3UA_SSNM_DUNA"); + case M3UA_SSNM_DAVA: return("M3UA_SSNM_DAVA"); + case M3UA_SSNM_DAUD: return("M3UA_SSNM_DAUD"); + case M3UA_SSNM_SCON: return("M3UA_SSNM_SCON"); + case M3UA_SSNM_DUPU: return("M3UA_SSNM_DUPU"); + case M3UA_SSNM_DRST: return("M3UA_SSNM_DRST"); + + default: return("Unexpected"); + } +} + +int m2ua_make_par(m2ua_var_par_t *par_ptr, WORD par_type, BYTE *par_addr, WORD par_len) +{ + WORD len = 0; + + par_ptr->hdr.tag = htons(par_type); + par_ptr->hdr.len = htons(sizeof(m2ua_par_hdr_t) + par_len); + + len = sizeof(m2ua_par_hdr_t) + ((par_len + 3) & 0xFFFC); + if (par_type == M2UA_PAR_PROTO_DATA_1 || + par_type == M3UA_Protocol_Data ) + bzero(par_ptr->val + par_len, len - par_len); + else + bcopy(par_addr, par_ptr->val, par_len); + + + return len; +} + +int m2ua_send_msg(WORD sg_id, WORD msg) +{ + BYTE msg_class, msg_type; + WORD len = 0, msg_len; + WORD par_len, par_start = 0; + WORD sid = 0, i; + DWORD dw; + BYTE iid, lk, flag = 0; + WORD dlci; + m2ua_msg_t *msg_ptr; + + msg_class = msg >> 8; + msg_type = msg & 0xFF; + + if (msg == M2UA_MAUP_DATA || msg == M3UA_MAUP_DATA || + msg == IUA_QPTM_DATA_REQ || msg == IUA_QPTM_UDATA_REQ || + msg == IUA_QPTM_DATA_IND || msg == IUA_QPTM_UDATA_IND ) + msg_ptr = (m2ua_msg_t *)m2ua_sg_info[sg_id].msg; + else + //msg_ptr = (m2ua_msg_t *)m2ua_sctp_dat; + msg_ptr = (m2ua_msg_t *)m2ua_sctp_dat_send; + + switch (msg_class) + { + case M2UA_MCLASS_MGMT: + { + switch (msg_type) + { + case xUA_ERROR: + dw = htonl(m2ua_sg_info[sg_id].err_code); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_ERR_CODE, (BYTE *)&dw, 4); + len += par_len; + if(m2ua_sg_info[sg_id].err_code == M3UA_ERR_INVALID_RC) + { + par_start += par_len; + dw = htonl(m2ua_sg_info[sg_id].rc); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *)&dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case xUA_NOTIFY: + dw = htonl(m2ua_sg_info[sg_id].status); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATUS, (BYTE *)&dw, 4); + len += par_len; + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + par_start += par_len; + dw = htonl(m2ua_sg_info[sg_id].rc); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *)&dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case TEI_S_REQ: + case TEI_S_CFM: + case TEI_S_IND: + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + //DLCI + par_start += par_len; + dlci = m2ua_para.lk_para[lk].dlci; + dw = htons(dlci) << 16; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_DLCI, (BYTE *) &dw, 4); + len += par_len; + if(msg_type != TEI_S_REQ) + { + dw = htonl(m2ua_sg_info[sg_id].tei_state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_TEI_STATUS, (BYTE *) &dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + } + case M2UA_MCLASS_ASPSM: + { + switch (msg_type) + { + case ASP_UP: + dw = host_ip; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_ASP_IDENTIFIER, (BYTE *)&dw, 4); + len += par_len; + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_UP; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_DOWN: + break; + case HEARTBEAT: + break; + case ASP_UP_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_UP_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_DOWN_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_DOWN_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case HEARTBEAT_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = HEARTBEAT_ACK; + len = m2ua_sg_info[sg_id].msg_len; + break; + default: + break; + } + break; + } + case M2UA_MCLASS_ASPTM: + { + sid = 1; + switch (msg_type) + { + case ASP_ACTIVE: + //dw = htonl(M2UA_TRAFFIC_MODE_LOADSHARE); + dw = htonl(M2UA_TRAFFIC_MODE_OVERRIDE); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_TRAFFIC_MODE, (BYTE *)&dw, 4); + len += par_len; + par_start += par_len; + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + dw = htonl(m2ua_sg_info[sg_id].rc); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *)&dw, 4); + len += par_len; + par_start += par_len; + } + else + { + for (i = 0; i < M2UA_MAX_LK_NUM; i++) + { + if (m2ua_lk_info[i].enable && (m2ua_para.lk_para[i].lk_sg == sg_id)) + { + dw = htonl(m2ua_para.lk_para[i].iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *)&dw, 4); + len += par_len; + par_start += par_len; + } + } + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_ACTIVE; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_INACTIVE: + break; + case ASP_ACTIVE_ACK: + dw = htonl(M2UA_TRAFFIC_MODE_OVERRIDE); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_TRAFFIC_MODE, (BYTE *)&dw, 4); + len += par_len; + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + par_start += par_len; + dw = htonl(m2ua_sg_info[sg_id].rc); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *)&dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_ACTIVE_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_INACTIVE_ACK: + if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M3UA_APP) + { + lk = m2ua_sg_info[sg_id].iid & 0xFF; + dw = htonl(m2ua_sg_info[sg_id].rc); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *)&dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_INACTIVE_ACK; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + } + case M2UA_MCLASS_MAUP: + { + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + switch (msg_type) + { + case DATA: + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_PROTO_DATA_1, m2ua_sg_info[sg_id].msg + 20, msg_len); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = DATA; + len += sizeof(m2ua_comhdr_t); + + m2ua_csta.sg_csta[sg_id].sg_out_msg++; + m2ua_csta.lk_csta[lk].lk_out_msg++; + m2ua_csta.sg_csta[sg_id].sg_out_bytes += msg_len; + m2ua_csta.lk_csta[lk].lk_out_bytes += msg_len; + err[3]++; + break; + case ESTABLISH_REQ: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = ESTABLISH_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case ESTABLISH_CFM: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = ESTABLISH_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_REQ: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_CFM: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_IND: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_IND; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_REQ: + dw = htonl(m2ua_sg_info[sg_id].state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATE, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = STATE_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_CFM: + dw = htonl(m2ua_sg_info[sg_id].state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATE, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = STATE_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_IND: + break; + case DATA_RETIEVE_REQ: + case DATA_RETIEVE_CFM: + case DATA_RETIEVE_IND: + case DATA_RETIEVE_CMP: + case CONGESTION_IND: + break; + case DATA_ACK: + dw = htonl(m2ua_sg_info[sg_id].cor_id); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_CORRELATION_ID, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = DATA_ACK; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + } + case xUA_MCLASS_QPTM: + { + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + //DLCI + par_start += par_len; + dlci = m2ua_para.lk_para[lk].dlci; + dw = htons(dlci) << 16; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_DLCI, (BYTE *) &dw, 4); + len += par_len; + switch (msg_type) + { + case IUA_UDATA_REQ: + case IUA_UDATA_IND: + break; + case IUA_DATA_REQ: + case IUA_DATA_IND: + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_PROTOCOL_DATA, m2ua_sg_info[sg_id].msg + 28, msg_len); + len += par_len; + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + + m2ua_csta.sg_csta[sg_id].sg_out_msg++; + m2ua_csta.lk_csta[lk].lk_out_msg++; + m2ua_csta.sg_csta[sg_id].sg_out_bytes += msg_len; + m2ua_csta.lk_csta[lk].lk_out_bytes += msg_len; + err[3]++; + break; + case IUA_ESTABLISH_REQ: + case IUA_ESTABLISH_CFM: + case IUA_ESTABLISH_IND: + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case IUA_RELEASE_REQ: + case IUA_RELEASE_IND: + dw = htonl(m2ua_sg_info[sg_id].rel_reason); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_REL_REASON, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case IUA_RELEASE_CFM: + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + } + case xUA_MCLASS_TRMSG: + { + switch (msg_type) + { + case M3UA_DATA: + lk = m2ua_sg_info[sg_id].iid & 0xFF; + dw = htonl(m2ua_sg_info[sg_id].rc); + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_Routing_Context, (BYTE *) &dw, 4); + len += par_len; + + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M3UA_Protocol_Data, m2ua_sg_info[sg_id].msg + 20, msg_len+12); + len += par_len; + msg_ptr->comhdr.msg_class = xUA_MCLASS_TRMSG; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + } + default: + break; + } + + if (len == 0) + return 0; + + msg_ptr->comhdr.version = 1; + msg_ptr->comhdr.spare = 0; + msg_ptr->comhdr.len = htonl(len); + + if ((moniter_fg & MONITOR_M2UA) == MONITOR_M2UA) + { + if (m2ua_sg_mon_fg[sg_id] == 1) + { + if (msg_class == M2UA_MCLASS_MAUP) + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, lk=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, lk, sid, len); + else + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, sid, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)msg_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + flag = 1; + } + } + if ((msg_class == M2UA_MCLASS_MAUP ||msg_class == xUA_MCLASS_QPTM) && !flag) + { + if ((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, lk=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, lk, sid, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)msg_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + +#ifndef _LKSCTP + m2ua_sctp_opt_data.sid_val = sid; + m2ua_sctp_data.buf = (BYTE *)msg_ptr; + m2ua_sctp_optdata_req(m2ua_sg_info[sg_id].fd, sg_id, len); +#else + m2ua_sctp_data.sid = sid; + m2ua_sctp_data.buf = (BYTE *)msg_ptr; + m2ua_sctp_optdata_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, len); +#endif + + return len; +} + +int m2ua_find_link_by_sg_iid(WORD sg_id, WORD iid) +{ + int i; + lk_para_t *lk_para; + + lk_para = &m2ua_para.lk_para[0]; + + for (i = 0; i < M2UA_MAX_LK_NUM; i++) + { + if (m2ua_lk_info[i].enable && (lk_para->lk_sg%256 == sg_id%256) && (lk_para->iid == iid)) + return i; + lk_para++; + } + + return -1; +} + +int m2ua_dec_par(WORD sg_id, m2ua_var_par_t *par_ptr, WORD par_type) +{ + WORD len = 0, hdr_len; + DWORD *dw_ptr; + WORD *w_ptr; + int iid; + + hdr_len = ntohs(par_ptr->hdr.len); + + switch (par_type) + { + case M2UA_PAR_INTERFACE_ID_INT: + { + if ((par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_INT)) && + (par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_TXT))) + return 0; + else if (par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_INT)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_IIT; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } +// else if (hdr_len % 4) +// { +// m2ua_sg_info[sg_id].err_code = M2UA_ERR_PARA_FIELD_ERROR; +// m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); +// return -1; +// } + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + iid = ntohl(*dw_ptr); + if ((iid = m2ua_find_link_by_sg_iid(sg_id, iid)) < 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + else + m2ua_sg_info[sg_id].iid = iid; + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M2UA_PAR_PROTO_DATA_1: + { + if (hdr_len <= (M2UA_MAX_MSG_LEN - 2)) + { + m2ua_sg_info[sg_id].msg = &par_ptr->val[0]; + m2ua_sg_info[sg_id].msg_len = hdr_len - sizeof(m2ua_par_hdr_t); + len = (hdr_len + 3) & 0xFFFC; + } + break; + } + case M2UA_PAR_CORRELATION_ID: + { + if (par_ptr->hdr.tag != htons(M2UA_PAR_CORRELATION_ID)) + m2ua_sg_info[sg_id].cor_id = 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].cor_id = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M2UA_PAR_STATE: + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].state = ntohl(*dw_ptr); + if (m2ua_sg_info[sg_id].state > M2UA_STATUS_CONG_DISCARD) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_PARA_VAL; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else + len = ((hdr_len + 3) & 0xFFFC); + break; + } + case M2UA_PAR_TRAFFIC_MODE: + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].tra_hdl_mode = ntohl(*dw_ptr); + if (m2ua_sg_info[sg_id].tra_hdl_mode != M2UA_TRAFFIC_MODE_OVERRIDE) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_TRA_HDL_MODE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else + len = ((hdr_len + 3) & 0xFFFC); + break; + } + case xUA_PAR_DLCI: + { + if (par_ptr->hdr.tag != htons(xUA_PAR_DLCI)) + m2ua_sg_info[sg_id].dlci = 0; + else + { + w_ptr = (WORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].dlci = ntohl(*w_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case xUA_PAR_REL_REASON: + { + if (par_ptr->hdr.tag != htons(xUA_PAR_REL_REASON)) + m2ua_sg_info[sg_id].rel_reason = 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].rel_reason = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case xUA_PAR_PROTOCOL_DATA: + { + if (hdr_len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg_id].msg = &par_ptr->val[0]; + m2ua_sg_info[sg_id].msg_len = hdr_len - sizeof(m2ua_par_hdr_t); + len = (hdr_len + 3) & 0xFFFC; + } + break; + } + + case M3UA_Network_Appearance: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].net_app = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case xUA_Routing_Context: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + int RCn,ii; + RCn = ((hdr_len- 4 + 3) & 0xFFFC) >> 2; + for(ii=0;iival[ii*4]; + m2ua_sg_info[sg_id].rc = ntohl(*dw_ptr); + if (check_m3ua_rc_verify(ntohl(*dw_ptr)) < 0) + { + m2ua_sg_info[sg_id].err_code = M3UA_ERR_INVALID_RC; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else + { + if (m2ua_sg_info[sg_id].m2ua_state == 3) + { + switch(m2ua_sg_info[sg_id].m2ua_cmd) + { + case M2UA_ASPTM_ASP_ACTIVE: + m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_UP); + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE_ACK); + if(m2ua_sg_info[sg_id].status != ((M2UA_STATUS_TYPE_AS_STATE_CHG << 16)|M2UA_STATUS_INFO_AS_ACTIVE)) + { + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16)|M2UA_STATUS_INFO_AS_ACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + } + break; + case M2UA_ASPTM_ASP_INACTIVE: + m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_DOWN); + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE_ACK); + if(m2ua_sg_info[sg_id].status != ((M2UA_STATUS_TYPE_AS_STATE_CHG << 16)|M2UA_STATUS_INFO_AS_PENDING)) + { + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_PENDING; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + } + break; + case M3UA_MAUP_DATA: + break; + case M3UA_SSNM_DUNA: + m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_DOWN); + break; + case M3UA_SSNM_DAVA: + m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_UP); + break; + } + } + } + } + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M3UA_Protocol_Data: + { + if (hdr_len <= (M2UA_MAX_MSG_LEN - 2)) + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].opc = ntohl(*dw_ptr); + + dw_ptr = (DWORD *) &par_ptr->val[4]; + m2ua_sg_info[sg_id].dpc = ntohl(*dw_ptr); + + m2ua_sg_info[sg_id].si = par_ptr->val[8]; + m2ua_sg_info[sg_id].ni = par_ptr->val[9]; + m2ua_sg_info[sg_id].mp = par_ptr->val[10]; + m2ua_sg_info[sg_id].sls = par_ptr->val[11]; + + m2ua_sg_info[sg_id].msg = &par_ptr->val[12]; + m2ua_sg_info[sg_id].msg_len = hdr_len - 12 - sizeof(m2ua_par_hdr_t); + len = (hdr_len + 3) & 0xFFFC; + } + break; + } + case xUA_Affected_PC: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].aff_pc = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M3UA_User_Cause: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].user_cause = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M3UA_Congestion_Indications: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].cong_ind = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + case M3UA_Concerned_Destination: + { + if (par_ptr->hdr.tag != htons(par_type)) + return 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].con_dpc = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + } + default: + break; + } + + return len; +} + +int m2ua_dec_msg(WORD sg_id) +{ + BYTE server, m2ua_state, flag = 0; + m2ua_msg_t *msg_ptr; + + WORD msg_sg,msg_len, par_start = 0; + int par_len = 0; + BYTE msg_class, msg_type; + WORD msg = M2UA_CMD_IDLEW; + + WORD iid; + WORD mtp3_msg_len; + DWORD comm_len; + +#ifndef _LKSCTP + msg_len = m2ua_sctp_data.len; +#else + msg_len = m2ua_sctp_dat_len; +#endif + + msg_ptr = (m2ua_msg_t *) m2ua_sctp_dat; + + msg_class = msg_ptr->comhdr.msg_class; + msg_type = msg_ptr->comhdr.msg_type; + comm_len = ntohl(msg_ptr->comhdr.len); + + server = m2ua_para.sg_para[sg_id].server; + m2ua_state = m2ua_sg_info[sg_id].m2ua_state; + + if ((moniter_fg & MONITOR_M2UA) == MONITOR_M2UA) + { + if (m2ua_sg_mon_fg[sg_id] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + flag = 1; + } + } + + if (msg_ptr->comhdr.version != 1) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_VERSION; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } +// else if (comm_len % 4) +// { +// m2ua_sg_info[sg_id].err_code = M2UA_ERR_PARA_FIELD_ERROR; +// m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); +// return -1; +// } + + err[6]++; + + switch (msg_class) + { + case M2UA_MCLASS_MGMT: + { + err[7]++; + if ((msg_type > TEI_S_IND)) + //if ((msg_type != ERROR) && (msg_type != NOTIFY)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else if ((msg_type == xUA_NOTIFY) && server) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_PROTOCOL_ERROR; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else if (msg_type == xUA_ERROR) + msg = M2UA_MGMT_ERROR; + break; + } + case M2UA_MCLASS_ASPSM: + { + err[8]++; + switch (msg_type) + { + case ASP_UP: + msg = M2UA_ASPSM_ASP_UP; + break; + case ASP_DOWN: + msg = M2UA_ASPSM_ASP_DOWN; + break; + case HEARTBEAT: + m2ua_sg_info[sg_id].msg_len = msg_len; + m2ua_send_msg(sg_id, M2UA_ASPSM_HEARTBEAT_ACK); + break; + case ASP_UP_ACK: + msg = M2UA_ASPSM_ASP_UP_ACK; + break; + case ASP_DOWN_ACK: + msg = M2UA_ASPSM_ASP_DOWN_ACK; + break; + case HEARTBEAT_ACK: + msg = M2UA_ASPSM_HEARTBEAT_ACK; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + case M2UA_MCLASS_ASPTM: + { + err[9]++; + switch (msg_type) + { + case ASP_ACTIVE: + if (comm_len > sizeof(m2ua_comhdr_t)) + { + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_TRAFFIC_MODE); + par_start += par_len; + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_ASPTM_ASP_ACTIVE; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Routing_Context); + m2ua_sg_info[sg_id].m2ua_cmd = 0; + if(par_len >= 0) + msg = M2UA_ASPTM_ASP_ACTIVE; + } + else + msg = M2UA_ASPTM_ASP_ACTIVE; + break; + case ASP_INACTIVE: + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_ASPTM_ASP_INACTIVE; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Routing_Context); + m2ua_sg_info[sg_id].m2ua_cmd = 0; + msg = M2UA_ASPTM_ASP_INACTIVE; + break; + case ASP_ACTIVE_ACK: + msg = M2UA_ASPTM_ASP_ACTIVE_ACK; +// par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Routing_Context); +// { +// int lk; +// for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) +// { +// if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && m2ua_lk_info[lk].enable) +// m2ua_lk_info[lk].lk_act = 1; +// } +// } + break; + case ASP_INACTIVE_ACK: + msg = M2UA_ASPTM_ASP_INACTIVE_ACK; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + case M2UA_MCLASS_MAUP: + { + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=M2UA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_INTERFACE_ID_INT); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + + iid = m2ua_sg_info[sg_id].iid; + msg_sg = m2ua_para.lk_para[iid].lk_sg; + + if ((iid >= M2UA_MAX_LK_NUM) || + (msg_sg != sg_id)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + err[11]++; + + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + switch (msg_type) + { + case DATA: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_PROTO_DATA_1); + if (par_len > 0) + { + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_CORRELATION_ID); + msg = M2UA_MAUP_DATA; + + mtp3_msg_len = m2ua_sg_info[sg_id].msg_len; + m2ua_csta.sg_csta[sg_id].sg_in_msg++; + m2ua_csta.lk_csta[iid].lk_in_msg++; + m2ua_csta.sg_csta[sg_id].sg_in_bytes += mtp3_msg_len; + m2ua_csta.lk_csta[iid].lk_in_bytes += mtp3_msg_len; + err[12]++; + } + break; + case ESTABLISH_REQ: + msg = M2UA_MAUP_ESTABLISH_REQ; + break; + case ESTABLISH_CFM: + msg = M2UA_MAUP_ESTABLISH_CFM; + break; + case RELEASE_REQ: + msg = M2UA_MAUP_RELEASE_REQ; + break; + case RELEASE_CFM: + msg = M2UA_MAUP_RELEASE_CFM; + break; + case RELEASE_IND: + msg = M2UA_MAUP_RELEASE_IND; + break; + case STATE_REQ: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_STATE); + if (par_len) + msg = M2UA_MAUP_STATE_REQ; + break; + case STATE_CFM: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_STATE); + break; + case STATE_IND: + case DATA_ACK: + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + case xUA_MCLASS_QPTM: + { + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=IUA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_INTERFACE_ID_INT); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + + iid = m2ua_sg_info[sg_id].iid; + msg_sg = m2ua_para.lk_para[iid].lk_sg; + + + if ((iid >= M2UA_MAX_LK_NUM) || + (msg_sg != sg_id)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_DLCI); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + err[11]++; + + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + switch (msg_type) + { + case IUA_DATA_REQ: + case IUA_DATA_IND: + case IUA_UDATA_REQ: + case IUA_UDATA_IND: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_PROTOCOL_DATA); + if (par_len > 0) + { + msg = (xUA_MCLASS_QPTM << 8) + msg_type; + + mtp3_msg_len = m2ua_sg_info[sg_id].msg_len; + m2ua_csta.sg_csta[sg_id].sg_in_msg++; + m2ua_csta.lk_csta[iid].lk_in_msg++; + m2ua_csta.sg_csta[sg_id].sg_in_bytes += mtp3_msg_len; + m2ua_csta.lk_csta[iid].lk_in_bytes += mtp3_msg_len; + err[12]++; + } + break; + case IUA_ESTABLISH_REQ: + msg = IUA_QPTM_ESTABLISH_REQ; + break; + case IUA_ESTABLISH_CFM: + msg = IUA_QPTM_ESTABLISH_CFM; + break; + case IUA_ESTABLISH_IND: + msg = IUA_QPTM_ESTABLISH_IND; + break; + case IUA_RELEASE_REQ: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_REL_REASON); + if (par_len) + msg = IUA_QPTM_RELEASE_REQ; + break; + case IUA_RELEASE_CFM: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_REL_REASON); + if (par_len) + msg = IUA_QPTM_RELEASE_CFM; + break; + case IUA_RELEASE_IND: + msg = IUA_QPTM_RELEASE_IND; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + case xUA_MCLASS_TRMSG: + { + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=M3UA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + iid = m2ua_sg_info[sg_id].iid; + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + switch (msg_type) + { + case M3UA_DATA: + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_Network_Appearance); + par_start += par_len; + m2ua_sg_info[sg_id].m2ua_cmd = M3UA_MAUP_DATA; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Routing_Context); + m2ua_sg_info[sg_id].m2ua_cmd =0; + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_Protocol_Data); + if (par_len > 0) + { + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_CORRELATION_ID); + msg = (msg_class << 8) + msg_type; + + mtp3_msg_len = m2ua_sg_info[sg_id].msg_len; + m2ua_csta.sg_csta[sg_id].sg_in_msg++; + m2ua_csta.sg_csta[sg_id].sg_in_bytes += mtp3_msg_len; + err[12]++; + } + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + case xUA_MCLASS_SSNM: + { + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=M3UA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_Network_Appearance); + par_start += par_len; + m2ua_sg_info[sg_id].m2ua_cmd = (msg_class << 8) + msg_type; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Routing_Context); + m2ua_sg_info[sg_id].m2ua_cmd = 0; + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_Affected_PC); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + switch (msg_type) + { + case SSNM_DUNA: + msg = (msg_class << 8) + msg_type; +// m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_DOWN); + break; + case SSNM_DAVA: + msg = (msg_class << 8) + msg_type; +// m3ua_sd_mtp3_user_rc_cmd(sg_id, M3UA_RC_UP); + break; + case SSNM_DAUD: + msg = (msg_class << 8) + msg_type; + break; + case SSNM_SCON: + msg = (msg_class << 8) + msg_type; + break; + case SSNM_DUPU: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_User_Cause); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + msg = (msg_class << 8) + msg_type; + break; + case SSNM_DRST: + msg = (msg_class << 8) + msg_type; + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_Congestion_Indications); + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M3UA_Concerned_Destination); + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + } + default: + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_CLASS; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + } + + if (msg != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = msg; + return 0; + } + else + return -1; +} + +int m2ua_sd_mtp3_primi(BYTE lk, BYTE primi) +{ + m2ua_up_msg_t *up_ptr; + + if (((m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m2ua_mtp3_sd_t) + return -1; + + up_ptr = (m2ua_up_msg_t *) (m2ua_mtp3_sd + x256[m2ua_mtp3_sd_h]); + up_ptr->link = lk; + up_ptr->len = htons(4); + up_ptr->sio = M2UA_SIO_CMD; + up_ptr->msg.lm.mtp3_ip = 0; + up_ptr->msg.lm.opercode = primi; + + if ((m2ua_lk_info[lk].lk_st == M2UA_LK_UP) && + (m2ua_lk_info[lk].alarm_code != M2UA_ALARM_CODE_NORMAL)) + m2ua_lk_info[lk].alarm_code = M2UA_ALARM_CODE_NORMAL; + up_ptr->msg.lm.alarmcode = m2ua_lk_info[lk].alarm_code; + + m2ua_mtp3_sd_h = (m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[15]++; + + return 0; +} + +int m2ua_sd_mtp3_msg(WORD sg, BYTE lk) +{ + BYTE *msg; + int len; + m2ua_up_msg_t *up_ptr; + + if (((m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m2ua_mtp3_sd_t) + return -1; + + len = m2ua_sg_info[sg].msg_len; + msg = m2ua_sg_info[sg].msg; + + up_ptr = (m2ua_up_msg_t *) (m2ua_mtp3_sd + x256[m2ua_mtp3_sd_h]); + up_ptr->link = lk; + up_ptr->len = htons(len); + up_ptr->sio = *msg; + + bcopy(msg + 1, up_ptr->msg.mtp3.content, len); + + m2ua_mtp3_sd_h = (m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[14]++; + + return 1; +} + +int iua_sd_q931_primi(BYTE lk, BYTE primi) +{ + xua_up_msg_t *up_ptr; + + if (((iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == iua_q931_sd_t) + return -1; + + up_ptr = (xua_up_msg_t *) (iua_q931_sd + x256[iua_q931_sd_h]); + up_ptr->msg_class = IUA_MGMT_CMD; + + up_ptr->msg.lm_lk.link = lk; + up_ptr->msg.lm_lk.len = htons(3); + up_ptr->msg.lm_lk.mtp3_ip = 0; + up_ptr->msg.lm_lk.opercode = primi; + + if ((m2ua_lk_info[lk].lk_st == M2UA_LK_UP) && + (m2ua_lk_info[lk].alarm_code != M2UA_ALARM_CODE_NORMAL)) + m2ua_lk_info[lk].alarm_code = M2UA_ALARM_CODE_NORMAL; + + + iua_q931_sd_h = (iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[15]++; + + return 0; +} + +int iua_sd_q931_msg(WORD sg, BYTE lk) +{ + BYTE *msg; + int len; + xua_up_msg_t *up_ptr; + + if (((iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == iua_q931_sd_t) + return -1; + + len = m2ua_sg_info[sg].msg_len; + msg = m2ua_sg_info[sg].msg; + + up_ptr = (xua_up_msg_t *) (iua_q931_sd + x256[iua_q931_sd_h]); + up_ptr->msg_class = IUA_QPTM_MSG; + + up_ptr->msg.iua.link = lk; + up_ptr->msg.iua.len = htons(len); + bcopy(msg, up_ptr->msg.iua.content, len); + + iua_q931_sd_h = (iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[14]++; + + return 1; +} + +int m3ua_sd_mtp3_user_primi(BYTE lk, BYTE primi) +{ + xua_up_msg_t *up_ptr; + + if (((m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m3ua_mtp3_sd_t) + return -1; + + up_ptr = (xua_up_msg_t *) (m3ua_mtp3_sd + x256[m3ua_mtp3_sd_h]); + up_ptr->msg_class = M3UA_MGMT_CMD; + + up_ptr->msg.lm_lk.link = lk; + up_ptr->msg.lm_lk.len = htons(3); + up_ptr->msg.lm_lk.mtp3_ip = 0; + up_ptr->msg.lm_lk.opercode = primi; + up_ptr->msg.lm_lk.alarmcode = m2ua_lk_info[lk].alarm_code; + + m3ua_mtp3_sd_h = (m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + return 0; +} + +int m3ua_sd_mtp3_user_rc_cmd(WORD sg, BYTE primi) +{ + xua_up_msg_t *up_ptr; + WORD lk; + + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if (((m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m3ua_mtp3_sd_t) + return -1; + if ((m2ua_para.lk_para[lk].lk_sg == sg) && m2ua_lk_info[lk].enable) + { + up_ptr = (xua_up_msg_t *) (m3ua_mtp3_sd + x256[m3ua_mtp3_sd_h]); + up_ptr->msg_class = M3UA_RC_CMD; + + up_ptr->msg.rc_cmd.link = lk; + up_ptr->msg.rc_cmd.len = htons(5); + up_ptr->msg.rc_cmd.opercode = primi; + up_ptr->msg.rc_cmd.rc = m2ua_sg_info[sg].rc; + + m3ua_mtp3_sd_h = (m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + } + } + + return 0; +} + +int m3ua_sd_mtp3_user_msg(WORD sg) +{ + BYTE *msg; + int len,lk; + xua_up_msg_t *up_ptr; + + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if (((m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m3ua_mtp3_sd_t) + return -1; + if ((m2ua_para.lk_para[lk].lk_sg == sg) && m2ua_lk_info[lk].enable) + { + len = m2ua_sg_info[sg].msg_len; + msg = m2ua_sg_info[sg].msg; + + up_ptr = (xua_up_msg_t *) (m3ua_mtp3_sd + x256[m3ua_mtp3_sd_h]); + up_ptr->msg_class = M3UA_MAUP_MSG; + + up_ptr->msg.m3ua.link = lk; + up_ptr->msg.m3ua.dpc = m2ua_sg_info[sg].dpc; + up_ptr->msg.m3ua.opc = m2ua_sg_info[sg].opc; + up_ptr->msg.m3ua.sls = m2ua_sg_info[sg].sls; + up_ptr->msg.m3ua.mp = m2ua_sg_info[sg].mp; + up_ptr->msg.m3ua.ni = m2ua_sg_info[sg].ni; + up_ptr->msg.m3ua.si = m2ua_sg_info[sg].si; + + up_ptr->msg.m3ua.len = htons(len); + bcopy(msg, up_ptr->msg.m3ua.content, len); + + m3ua_mtp3_sd_h = (m3ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + break; + } + } + + return 0; +} + + +int m2ua_sg_init(WORD id) +{ + bzero((BYTE *)&m2ua_sg_info[id], sizeof(m2ua_sg_info_t)); + + m2ua_sg_info[id].m2ua_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].sctp_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].mtp3_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].mgmt_cmd = M2UA_CMD_IDLEW; + + return 0; +} + +int m2ua_lk_init(BYTE id) +{ + WORD lk_sg; + + bzero(&m2ua_lk_info[id], sizeof(m2ua_lk_info_t)); + + lk_sg = m2ua_para.lk_para[id].lk_sg; + if (m2ua_sg_info[lk_sg].m2ua_state == 3) + m2ua_lk_info[id].lk_st = M2UA_LK_DOWN; + else + m2ua_lk_info[id].lk_st = M2UA_LK_IDLE; + + return 0; +} + +int enable_sg(WORD sg) +{ + int fd; + + if (m2ua_para.sg_para[sg].enable && + (m2ua_sg_info[sg].fd == 0)) + { +#ifndef _LKSCTP + if ((fd = m2ua_sctp_t_open(sg)) <= 0) + { + m2ua_log_err(sg, "enable sg, open sctp fail!"); + return -1; + } + else + { + m2ua_sg_init(sg); + m2ua_sg_info[sg].fd = fd; + m2ua_sg_info[sg].enable = 1; + } +#else + if (!m2ua_para.sg_para[sg].server) + { + if ((fd = m2ua_sctp_open_lksctp(sg)) <= 0) + { + m2ua_log_err(sg, "enable sg, open sctp fail!"); + return -1; + } + m2ua_sg_init(sg); + m2ua_sg_info[sg].fd = fd; + } + else if (!m2ua_sg_info[sg].enable) + m2ua_sg_init(sg); + m2ua_sg_info[sg].enable = 1; +#endif + } + + return 0; +} + +int rm_sg_lk(WORD sg, BYTE lk) +{ + int fd; + + rel_sid(sg, lk); + + if (--m2ua_sg_info[sg].act_lks == 0) + { + fd = m2ua_sg_info[sg].fd; + if (fd > 0) + { +#ifndef _LKSCTP + if ((m2ua_sg_info[sg].sctp_state > 2) || + ((m2ua_sg_info[sg].sctp_state == 2) && + (m2ua_sg_info[sg].sctp_state_1 > 0))) + m2ua_sctp_discon_req(fd, sg, 0); + m2ua_sctp_close(fd, sg); +#else + if ((m2ua_sg_info[sg].sctp_state > 2) || + ((m2ua_sg_info[sg].sctp_state == 2) && + (m2ua_sg_info[sg].sctp_state_1 > 0))) + m2ua_sctp_discon_req_lksctp(fd, sg, 0); +#endif + } + m2ua_sg_init(sg); + } + + return 0; +} + +int get_m2ua_msg(m2ua_up_msg_t **data_ptr) +{ + m2ua_up_msg_t *up_ptr; + BYTE lk; + int len; + WORD sg; + + if (m2ua_mtp3_sd_t == m2ua_mtp3_sd_h) + return -1; + + up_ptr = (m2ua_up_msg_t *)(m2ua_mtp3_sd + x256[m2ua_mtp3_sd_t]); + lk = up_ptr->link; + len = ntohs(up_ptr->len) + 3; + sg = m2ua_para.lk_para[lk].lk_sg; + *data_ptr = up_ptr; + + m2ua_mtp3_sd_t = (m2ua_mtp3_sd_t + 1) & M2UA_MAX_M3MSG_NUM_1; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send MSG to MTP3, sg=%d, lk=%d, len=%d\n\r", sg, lk, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)up_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + err[16]++; + + return 0; +} + +int put_m2ua_msg(m2ua_up_msg_t *data_ptr) +{ + BYTE lk; + int len; + WORD sg; + + lk = data_ptr->link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = ntohs(data_ptr->len); + err[0]++; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from MTP3, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+3); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+3, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != M2UA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not m2ua!"); + return -1; + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + if (data_ptr->sio == M2UA_MTP3_SIO_CMD) + { + err[1]++; + if ((data_ptr->msg.lm.opercode == M2UA_ENABLE_M2UA_LINK) && + (!m2ua_lk_info[lk].enable)) + { + if (enable_sg(sg) < 0) + return -1; + + m2ua_lk_init(lk); + m2ua_lk_info[lk].enable = 1; + m2ua_sg_info[sg].act_lks++; + } + else if ((data_ptr->msg.lm.opercode == M2UA_STOP_M2UA_LINK) && + m2ua_lk_info[lk].enable) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].mgmt_cmd = M2UA_MGMT_CMD_LK_LOCK; + m2ua_fsm(sg); + } + + rm_sg_lk(sg, lk); + m2ua_lk_init(lk); + + m2ua_lk_info[lk].enable = 0; + } + else if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = data_ptr->msg.lm.opercode; + m2ua_sg_info[sg].iid = lk; + m2ua_fsm(sg); + } + return 0; + } + else if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - 2)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - 18 + 1; + m2ua_sg_info[sg].msg_len = len; + m2ua_send_msg(sg, M2UA_MAUP_DATA); + err[4]++; + return 0; + } + } + + return -1; +} + +int get_xua_msg(BYTE xUA_type, xua_up_msg_t **data_ptr) +{ + xua_up_msg_t *up_ptr; + BYTE lk; + int len,msg_len; + BYTE *xua_msg_sd; + WORD sg, *xua_sd_h, *xua_sd_t; + + if(data_ptr == NULL) + return -1; + + switch (xUA_type) + { + case M2UA_APP: + return -1;//reserve + xua_msg_sd = m2ua_mtp3_sd; + xua_sd_t = &m2ua_mtp3_sd_t; + xua_sd_h = &m2ua_mtp3_sd_h; + break; + case IUA_APP: + xua_msg_sd = iua_q931_sd; + xua_sd_t = &iua_q931_sd_t; + xua_sd_h = &iua_q931_sd_h; + break; + case M3UA_APP: + xua_msg_sd = m3ua_mtp3_sd; + xua_sd_t = &m3ua_mtp3_sd_t; + xua_sd_h = &m3ua_mtp3_sd_h; + break; + default: + return -1; + } + if (*xua_sd_t == *xua_sd_h) + return -1; + + up_ptr = (xua_up_msg_t *)(xua_msg_sd + x256[*xua_sd_t]); + lk = up_ptr->msg.lm_lk.link; + len = ntohs(up_ptr->msg.lm_lk.len); + sg = m2ua_para.lk_para[lk].lk_sg; + *data_ptr = up_ptr; + + *xua_sd_t = (*xua_sd_t + 1) & M2UA_MAX_M3MSG_NUM_1; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send MSG to UP LAYER, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)up_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + err[16]++; + msg_len = len+XUAHEADOFFSET; + return msg_len; +} + +int put_xua_msg(xua_up_msg_t *data_ptr) +{ + BYTE lk, server; + int len; + WORD sg; + if(data_ptr == NULL) + return -1; + + switch (data_ptr->msg_class) + { + case M2UA_MGMT_CMD: + case IUA_MGMT_CMD: + { + lk = data_ptr->msg.lm_lk.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = ntohs(data_ptr->msg.lm_lk.len); + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from upper layer, sg=%d, lk=%d, len=%d\n\r", sg, lk, len + XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len + XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + err[1]++; + if ((data_ptr->msg.lm_lk.opercode == xUA_ENABLE_xUA_LINK) && + (!m2ua_lk_info[lk].enable)) + { + if (enable_sg(sg) < 0) + return -1; + + m2ua_lk_init(lk); + m2ua_lk_info[lk].enable = 1; + m2ua_sg_info[sg].act_lks++; + } + else if ((data_ptr->msg.lm_lk.opercode == xUA_STOP_xUA_LINK) && + m2ua_lk_info[lk].enable) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].mgmt_cmd = COMBO_W(data_ptr->msg_class,M2UA_MGMT_CMD_LK_LOCK); + m2ua_fsm(sg); + } + + rm_sg_lk(sg, lk); + m2ua_lk_init(lk); + + m2ua_lk_info[lk].enable = 0; + } + else if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = COMBO_W(data_ptr->msg_class,data_ptr->msg.lm_lk.opercode); + m2ua_sg_info[sg].iid = lk; + m2ua_fsm(sg); + } + return 0; + } + case IUA_QPTM_MSG: + { + lk = data_ptr->msg.iua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = ntohs(data_ptr->msg.iua.len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != IUA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not iua!"); + return -1; + } + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Q931, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - RESERVE_FOR_IUAHEAD; + m2ua_sg_info[sg].msg_len = len; + server = m2ua_para.sg_para[sg].server; + if(server) + m2ua_send_msg(sg, IUA_QPTM_DATA_IND); + else + m2ua_send_msg(sg, IUA_QPTM_DATA_REQ); + err[4]++; + return 0; + } + } + break; + } + case M2UA_MAUP_MSG: + { + lk = data_ptr->msg.m2ua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = ntohs(data_ptr->msg.m2ua.len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != M2UA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not m2ua!"); + return -1; + } + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Q931, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - RESERVE_FOR_M2UAHEAD; + m2ua_sg_info[sg].msg_len = len; + m2ua_send_msg(sg, M2UA_MAUP_DATA); + err[4]++; + return 0; + } + } + break; + } + default: + return -1; + } + return -1; +} + +int get_m3ua_msg(xua_up_msg_t **data_ptr) +{ + xua_up_msg_t *up_ptr; + BYTE lk; + int len; + BYTE *xua_msg_sd; + WORD sg, *xua_sd_h, *xua_sd_t; + + if(data_ptr == NULL) + return -1; + + xua_msg_sd = m3ua_mtp3_sd; + xua_sd_t = &m3ua_mtp3_sd_t; + xua_sd_h = &m3ua_mtp3_sd_h; + + if (*xua_sd_t == *xua_sd_h) + return -1; + + up_ptr = (xua_up_msg_t *)(xua_msg_sd + x256[*xua_sd_t]); + *xua_sd_t = (*xua_sd_t + 1) & M2UA_MAX_M3MSG_NUM_1; + + + lk = up_ptr->msg.m3ua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + if(up_ptr->msg_class == M3UA_MAUP_MSG) + len = ntohs(up_ptr->msg.m3ua.len)+XUAHEADOFFSET; + else + len = 9; + + *data_ptr = up_ptr; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send MSG to MTP3-User, sg=%d, lk=%d, len=%d\n\r", sg, lk, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)up_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + return 0; +} + +int put_m3ua_msg(xua_up_msg_t *data_ptr) +{ + BYTE lk; + int len; + WORD sg; + if(data_ptr == NULL) + return -1; + + switch (data_ptr->msg_class) + { + case M3UA_MGMT_CMD: + { + lk = data_ptr->msg.lm_lk.link; + sg = m2ua_para.lk_para[lk].lk_sg; + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != M3UA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not m3ua!"); + return -1; + } + + len = 7; + + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Mtp3-User, sg=%d, lk=%d, len=%d\n\r", sg, lk, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + if ((data_ptr->msg.lm_lk.opercode == xUA_ENABLE_xUA_LINK) && + (!m2ua_lk_info[lk].enable)) + { + if (enable_sg(sg) < 0) + return -1; + + m2ua_lk_init(lk); + m2ua_lk_info[lk].enable = 1; + m2ua_sg_info[sg].act_lks++; + } + else if ((data_ptr->msg.lm_lk.opercode == xUA_STOP_xUA_LINK) && + m2ua_lk_info[lk].enable) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].mgmt_cmd = COMBO_W(data_ptr->msg_class,M2UA_MGMT_CMD_LK_LOCK); + m2ua_fsm(sg); + } + + rm_sg_lk(sg, lk); + m2ua_lk_init(lk); + + m2ua_lk_info[lk].enable = 0; + } + else if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = COMBO_W(data_ptr->msg_class,data_ptr->msg.lm_lk.opercode); + m2ua_sg_info[sg].iid = lk; + m2ua_fsm(sg); + } + return 0; + } + case M3UA_MAUP_MSG: + { + lk = data_ptr->msg.m3ua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = ntohs(data_ptr->msg.m3ua.len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != M3UA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not m3ua!"); + return -1; + } + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Mtp3-User, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+20); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+20, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + if (len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + DWORD pc; + pc = ntohl(data_ptr->msg.m3ua.opc); + data_ptr->msg.m3ua.opc = pc; + pc = ntohl(data_ptr->msg.m3ua.dpc); + data_ptr->msg.m3ua.dpc = pc; + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].rc = data_ptr->msg.m3ua.rc; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - RESERVE_FOR_M3UAHEAD; + m2ua_sg_info[sg].msg_len = len; + m2ua_send_msg(sg, M3UA_MAUP_DATA); + return 0; + } + } + break; + } + case M3UA_RC_CMD: + { + lk = data_ptr->msg.rc_cmd.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = 9; + if ((m2ua_para.sg_para[sg].xUA_ack>>1) != M3UA_APP) + { + m2ua_log_err(sg, "ERROR: SG type is not m3ua!"); + return -1; + } + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Mtp3-User, sg=%d, lk=%d, len=%d\n\r", sg, lk, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = COMBO_W(data_ptr->msg_class,data_ptr->msg.rc_cmd.opercode); + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].rc = data_ptr->msg.m3ua.rc; + m2ua_fsm(sg); + } + return 0; + } + default: + return -1; + } + return -1; +} + +int set_m2ua_link(BYTE link, BYTE *data_ptr) +{ + BYTE len; + WORD sg; + m2ua_lk_pro_t *m2ua_lk_pro = (m2ua_lk_pro_t *)data_ptr; + lk_para_t *lk_ptr; + + lk_ptr = (lk_para_t *) &m2ua_para.lk_para[link]; + sg = lk_ptr->lk_sg; + len = sizeof(m2ua_lk_pro_t); + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[link] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MTP3 Set Link Attributes, sg=%d, lk=%d, len=%d\n\r", sg, link, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)m2ua_lk_pro, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + /* + if (init_flag < 2) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + if (link == 255) + init_flag++; + } + else + */ + { + if (lk_ptr->enable) + { + if (m2ua_lk_pro->e1_lk_type & 0x01) // Bit 0: Link enable status, 0/1=disable/enable + return -1; + //else if (m2ua_lk_pro->e1_to_sg != sg) + //return -1; + } + + /* + if (m2ua_lk_pro->e1_to_sg != sg) + { + if (!((m2ua_para.sg_para[sg].enable == 0) && + (m2ua_para.sg_para[m2ua_lk_pro->e1_to_sg].enable == 0))) + return -1; + if (((m2ua_lk_pro->e1_lk_type & 0x07) == 0x03) && // SIGTRAN | ENABLE | NOT MTP3LITE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip) || + (m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + } + if (m2ua_lk_info[link].enable == 1) + { + rm_sg_lk(sg, link); + m2ua_lk_info[link].enable = 0; + } + } + else + { + if (((m2ua_lk_pro->e1_lk_type & 0x07) == 0x03) && // SIGTRAN | ENABLE | NOT MTP3LITE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip) || + (m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + } + } + */ + } + + sg = lk_ptr->lk_sg; + + if (m2ua_lk_info[link].enable == 0) + { + if ((((m2ua_lk_pro->e1_lk_type & 0x0F) == 0x03 || (m2ua_lk_pro->e1_lk_type & 0x0F) == 0x09) && // M2UA|M3UA | ENABLE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip)||(m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + || ((m2ua_lk_pro->e1_lk_type & 0x0F) == 0x07)) //No ss7 | ENABLE + { + // Bit 1-3: Link type, 0/1/2/3/4: non-sigtran/sigtran-m2ua/mtp3lite/iua/sigtran-m3ua + lk_ptr->enable = 1; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + lk_ptr->dlci = 0; + + if(link < 128) + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + else + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg + M2UA_MAX_SG_NUM/2; + + if((m2ua_lk_pro->e1_lk_type & 0x0F) == 0x09) //m3ua + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + //if (enable_sg(sg) < 0) + //return -1; + + m2ua_lk_init(link); + //m2ua_lk_info[link].enable = 1; + //m2ua_sg_info[sg].act_lks++; + } + else if (lk_ptr->enable) + { + lk_ptr->enable = 0; + lk_ptr->lk_sg = 0; + lk_ptr->iid = 0; + lk_ptr->dlci = 0; + } + } + else + { + if ((((m2ua_lk_pro->e1_lk_type & 0x0F) != 0x03 || (m2ua_lk_pro->e1_lk_type & 0x0F) != 0x09) || + ((m2ua_lk_pro->e1_to_mtp3 != host_ip) && (m2ua_lk_pro->e1_to_alterMTP3 != host_ip)) || + (m2ua_lk_pro->e1_to_linkset >= M2UA_MTP3_MAX_LS_NUM)) + && ((m2ua_lk_pro->e1_lk_type & 0x0F) != 0x07)) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = link; + m2ua_sg_info[sg].mgmt_cmd = M2UA_MGMT_CMD_LK_LOCK; + m2ua_fsm(sg); + } + + rm_sg_lk(sg, link); + m2ua_lk_init(link); + + lk_ptr->enable = 0; + lk_ptr->lk_sg = 0; + lk_ptr->iid = 0; + lk_ptr->dlci = 0; + } + } + + return len; +} + +int set_m2ua_sg(WORD sg, BYTE *data_ptr) +{ + BYTE len; + sg_para_t *sg_ptr; + + len = sizeof(sg_para_t); + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv MTP3 Set SG Attributes, sg=%d, len=%d\n\r", sg, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(data_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + /* + if (init_flag < 2) + { + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if (sg == 255) + init_flag++; + } + else + */ + { + sg_ptr = (sg_para_t *) data_ptr; + + if (m2ua_para.sg_para[sg].enable && + m2ua_para.sg_para[sg+M2UA_MAX_SG_NUM/2].enable) + { + if (sg_ptr->enable) + return -1; +// else if ((sg_ptr->server != m2ua_para.sg_para[sg].server) || +// (sg_ptr->ip != m2ua_para.sg_para[sg].ip)) + else + { + if (((m2ua_sg_info[sg].enable == 0) ||(m2ua_sg_info[sg].fd == 0)) && + !((m2ua_sg_info[sg].sctp_state == 3) && (m2ua_sg_info[sg].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + m2ua_para.sg_para[sg].enable = 0; + else + m2ua_para.sg_para[sg].enable = 2; + + sg = sg + M2UA_MAX_SG_NUM/2; + if (((m2ua_sg_info[sg].enable == 0) ||(m2ua_sg_info[sg].fd == 0)) && + !((m2ua_sg_info[sg].sctp_state == 3) && (m2ua_sg_info[sg].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + m2ua_para.sg_para[sg].enable = 0; + else + m2ua_para.sg_para[sg].enable = 2; + return len; + } + } + + /* + if ((sg_ptr->server != m2ua_para.sg_para[sg].server) || + (sg_ptr->ip != m2ua_para.sg_para[sg].ip)) + m2ua_para.sg_para[sg].enable = 2; + else if (sg_ptr->enable >= 1) + m2ua_para.sg_para[sg].enable = 1; + else + m2ua_para.sg_para[sg].enable = 0; + bcopy(data_ptr + 1, (BYTE *) &m2ua_para.sg_para[sg] + 1, len - 1); + */ + + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M2UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M2UA_PORT_0; + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == IUA_APP) + m2ua_para.sg_para[sg].plat_port[0] = IUA_PORT_0; + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M3UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M3UA_PORT_0; + + sg = sg + M2UA_MAX_SG_NUM/2; + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M2UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M2UA_PORT_1; + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == IUA_APP) + m2ua_para.sg_para[sg].plat_port[0] = IUA_PORT_1; + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M3UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M3UA_PORT_1; + } + m2ua_para.sg_para[sg].plat_port[1] = 0; + return len; +} + +int m2ua_sctp_close(int fd, WORD sg_id) +{ + int ret; + + if ((ret = close(fd)) < 0) + m2ua_log_err(sg_id, "ERROR: M2UA SCTP close!"); + + return ret; +} + +#ifndef _LKSCTP + +int m2ua_sctp_get_msg(int fd, WORD sg) +{ + int ret; + int flags = 0; + BYTE err_text[128]; + //BYTE in_b; + + m2ua_sctp_data.buf = m2ua_sctp_dat; + + //in_b = inb(0x378); + //outb(in_b | 0x02, 0x378); + //20 us + + while ((ret = getmsg(fd, &m2ua_sctp_ctrl, &m2ua_sctp_data, &flags)) < 0) + { + switch (errno) + { + default: + case EPROTO: + case EINVAL: + sprintf(err_text, "ERROR: M2UA SCTP getmsg: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + case EINTR: + case ERESTART: + continue; + case EAGAIN: + break; + } + break; + } + + //outb(in_b & 0xFD, 0x378); + + if (!ret) + return (m2ua_sctp_cmd.tpi.type); + else + return (-1); +} + +char *dec_sctp_primi(long sctp_primi) +{ + switch (sctp_primi) + { + case T_CONN_REQ: return("T_CONN_REQ"); + case T_CONN_RES: return("T_CONN_RES"); + case T_DISCON_REQ: return("T_DISCON_REQ"); + case T_DATA_REQ: return("T_DATA_REQ"); + case T_EXDATA_REQ: return("T_EXDATA_REQ"); + case T_OPTDATA_REQ: return("T_OPTDATA_REQ"); + case T_INFO_REQ: return("T_INFO_REQ"); + case T_BIND_REQ: return("T_BIND_REQ"); + case T_UNBIND_REQ: return("T_UNBIND_REQ"); + case T_UNITDATA_REQ: return("T_UNITDATA_REQ"); + case T_OPTMGMT_REQ: return("T_OPTMGMT_REQ"); + case T_ORDREL_REQ: return("T_ORDREL_REQ"); + case T_CONN_IND: return("T_CONN_IND"); + case T_CONN_CON: return("T_CONN_CON"); + case T_DISCON_IND: return("T_DISCON_IND"); + case T_DATA_IND: return("T_DATA_IND"); + case T_EXDATA_IND: return("T_EXDATA_IND"); + case T_OPTDATA_IND: return("T_OPTDATA_IND"); + case T_INFO_ACK: return("T_INFO_ACK"); + case T_BIND_ACK: return("T_BIND_ACK"); + case T_ERROR_ACK: return("T_ERROR_ACK"); + case T_OK_ACK: return("T_OK_ACK"); + case T_UNITDATA_IND: return("T_UNITDATA_IND"); + case T_UDERROR_IND: return("T_UDERROR_IND"); + case T_OPTMGMT_ACK: return("T_OPTMGMT_ACK"); + case T_ORDREL_IND: return("T_ORDREL_IND"); + case T_ADDR_REQ: return("T_ADDR_REQ"); + case T_ADDR_ACK: return("T_ADDR_ACK"); + default: return("Unexpected"); + } +} + +char *dec_sctp_err(long sctp_err) +{ + switch (sctp_err) + { + case TBADADDR: return("TBADADDR"); + case TBADOPT: return("TBADOPT"); + case TACCES: return("TACCES"); + case TBADF: return("TBADF"); + case TNOADDR: return("TNOADDR"); + case TOUTSTATE: return("TOUTSTATE"); + case TBADSEQ: return("TBADSEQ"); + case TSYSERR: return("TSYSERR"); + case TLOOK: return("TLOOK"); + case TBADDATA: return("TBADDATA"); + case TBUFOVFLW: return("TBUFOVFLW"); + case TFLOW: return("TFLOW"); + case TNODATA: return("TNODATA"); + case TNODIS: return("TNODIS"); + case TNOUDERR: return("TNOUDERR"); + case TBADFLAG: return("TBADFLAG"); + case TNOREL: return("TNOREL"); + case TNOTSUPPORT: return("TNOTSUPPORT"); + case TSTATECHNG: return("TSTATECHNG"); + case TNOSTRUCTYPE: return("TNOSTRUCTTYPE"); + case TBADNAME: return("TBADNAME"); + case TBADQLEN: return("TBADQLEN"); + case TADDRBUSY: return("TADDRBUSY"); + case TINDOUT: return("TINDOUT"); + case TPROVMISMATCH: return("TPROVMISMATCH"); + case TRESQLEN: return("TRESQLEN"); + case TRESADDR: return("TRESADDR"); + case TQFULL: return("TQFULL"); + case TPROTO: return("TPROTO"); + default: return("(unknown)"); + } +} + +int expect(int fd, int sg, int *msg, int want) +{ + int got; + + got = m2ua_sctp_get_msg(fd, sg); + *msg = got; + + if (got >= 0) + { + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + if (m2ua_sctp_cmd.tpi.type == T_ERROR_ACK) + { + sprintf(m2ua_ascitemp_buf, "Error Code: %s\n\r", dec_sctp_err(m2ua_sctp_cmd.tpi.error_ack.TLI_error)); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_sctp_data.len > 0) + { + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Data len=%d\n\r", m2ua_sctp_data.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_data.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + } + + if (got == want) + return M2UA_SUCCESS; + else + return M2UA_FAILURE; +} + +int m2ua_sctp_put_msg(int fd, int sg) +{ + int ret; + struct strbuf *mydata = m2ua_sctp_data.len ? &m2ua_sctp_data : NULL; + BYTE err_text[128]; + //BYTE in_b; + + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Send %s to SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + + if (m2ua_sctp_data.len > 0) + { + sprintf(m2ua_ascitemp_buf, "Data len=%d\n\r", m2ua_sctp_data.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_data.buf, m2ua_sctp_data.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + + //in_b = inb(0x378); + //outb(in_b | 0x04, 0x378); + //88 us + + while ((ret = putpmsg(fd, &m2ua_sctp_ctrl, mydata, 0, MSG_HIPRI)) < 0) + { + switch (errno) + { + default: + sprintf(err_text, "ERROR: M2UA SCTP putpmsg: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + break; + case EINTR: + case ERESTART: + continue; + case EAGAIN: + printf("m2ua put msg EAGAIN\n"); + break; + } + break; + } + + //outb(in_b & 0xFB, 0x378); + + if (!ret) + return(0); + else + return(-1); +} + +int m2ua_sctp_put_fdi(int fd, int fd2, int sg, int offset, int flags) +{ + BYTE err_text[256]; + + m2ua_sctp_fdi.flags = flags; + m2ua_sctp_fdi.fildes = fd2; + m2ua_sctp_fdi.offset = offset; + + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Send %s to SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (ioctl(fd, I_FDINSERT, &m2ua_sctp_fdi) < 0) + { + sprintf(err_text, "ERROR: M2UA SCTP ioctl: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + } + + return(0); +} + +int m2ua_sctp_t_open(WORD sg) +{ + int fd; + + if ((fd = open("/dev/sctp_t",O_NONBLOCK|O_RDWR)) < 0) + m2ua_log_err(sg, "ERROR: M2UA SCTP open"); + + return fd; +} + +int m2ua_sctp_optmgmt_req(int fd, int sg, DWORD flags) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.optmgmt_req) + sizeof(m2ua_sctp_opt_optm); + m2ua_sctp_cmd.tpi.type = T_OPTMGMT_REQ; + m2ua_sctp_cmd.tpi.optmgmt_req.MGMT_flags = flags; + m2ua_sctp_cmd.tpi.optmgmt_req.OPT_length = sizeof(m2ua_sctp_opt_optm); + m2ua_sctp_cmd.tpi.optmgmt_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.optmgmt_req); + + m2ua_sctp_opt_optm.ppi_val = m2ua_para.sg_para[sg].xUA_ack>>1; + bcopy(&m2ua_sctp_opt_optm, (m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.optmgmt_req)), sizeof(m2ua_sctp_opt_optm)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_bind_req(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.bind_req) + sizeof(*addr); + m2ua_sctp_cmd.tpi.type = T_BIND_REQ; + m2ua_sctp_cmd.tpi.bind_req.ADDR_length = sizeof(*addr); + m2ua_sctp_cmd.tpi.bind_req.ADDR_offset = sizeof(m2ua_sctp_cmd.tpi.bind_req); + m2ua_sctp_cmd.tpi.bind_req.CONIND_number = coninds; + bcopy(addr, (&m2ua_sctp_cmd.tpi.bind_req) + 1, sizeof(*addr)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_conn_req(int fd, int sg, m2ua_sctp_addr_t *addr) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.conn_req)+sizeof(*addr); + m2ua_sctp_cmd.tpi.type = T_CONN_REQ; + m2ua_sctp_cmd.tpi.conn_req.DEST_length = sizeof(*addr); + m2ua_sctp_cmd.tpi.conn_req.DEST_offset = sizeof(m2ua_sctp_cmd.tpi.conn_req); + m2ua_sctp_cmd.tpi.conn_req.OPT_length = 0; + m2ua_sctp_cmd.tpi.conn_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.conn_req)+sizeof(*addr); + bcopy(addr, (m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.conn_req)), sizeof(*addr)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_conn_res(int fd, int fd2, int sg, long seq) +{ + m2ua_sctp_fdi.databuf.len = 0; + m2ua_sctp_fdi.ctlbuf.len = sizeof(m2ua_sctp_cmd.tpi.conn_res); + m2ua_sctp_cmd.tpi.type = T_CONN_RES; + m2ua_sctp_cmd.tpi.conn_res.ACCEPTOR_id = 0; + m2ua_sctp_cmd.tpi.conn_res.SEQ_number = seq; + m2ua_sctp_cmd.tpi.conn_res.OPT_offset = 0; + m2ua_sctp_cmd.tpi.conn_res.OPT_length = 0; + return m2ua_sctp_put_fdi(fd, fd2, sg, 4, 0); +} + +int m2ua_sctp_discon_req(int fd, int sg, DWORD seq) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.discon_req); + m2ua_sctp_cmd.tpi.type = T_DISCON_REQ; + m2ua_sctp_cmd.tpi.discon_req.SEQ_number = seq; + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_ordrel_req(int fd, int sg) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.ordrel_req); + m2ua_sctp_cmd.tpi.type = T_ORDREL_REQ; + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_optdata_req(int fd, int sg, int len) +{ + if (!len) + return (-1); + else + m2ua_sctp_data.len = len; + + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.optdata_req) + sizeof(m2ua_sctp_opt_data); + m2ua_sctp_cmd.tpi.type = T_OPTDATA_REQ; + m2ua_sctp_cmd.tpi.optdata_req.DATA_flag = 0; + m2ua_sctp_cmd.tpi.optdata_req.OPT_length = sizeof(m2ua_sctp_opt_data); + m2ua_sctp_cmd.tpi.optdata_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.optdata_req); + bcopy(&m2ua_sctp_opt_data, m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.optdata_req), sizeof(m2ua_sctp_opt_data)); + return m2ua_sctp_put_msg(fd, sg); +} + +#else + +char *dec_sctp_primi_lksctp(long sctp_primi) +{ + switch (sctp_primi) + { + case M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP: return("M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP"); + case M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST: return("M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST"); + case M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP: return("M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP"); + case M2UA_LKSCTP_ASSOC_CHANGE_RESTART: return("M2UA_LKSCTP_ASSOC_CHANGE_RESTART"); + case M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC: return("M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC"); + case M2UA_LKSCTP_SEND_FAILED: return("M2UA_LKSCTP_SEND_FAILED"); + case M2UA_LKSCTP_PEER_ADDR_CHANGE: return("M2UA_LKSCTP_PEER_ADDR_CHANGE"); + case M2UA_LKSCTP_REMOTE_ERROR: return("M2UA_LKSCTP_REMOTE_ERROR"); + case M2UA_LKSCTP_SHUTDOWN_EVENT: return("M2UA_LKSCTP_SHUTDOWN_EVENT"); + case M2UA_LKSCTP_DATA_IND: return("M2UA_LKSCTP_DATA_IND"); + case M2UA_LKSCTP_UNKNOWN_EVENT: return("M2UA_LKSCTP_UNKNOWN_EVENT"); + default: return("Unexpected"); + } +} + +int m2ua_sctp_optmgmt_req_lksctp(int fd, int sg) +{ + struct linger lg; + struct sctp_event_subscribe event; + struct sctp_initmsg initopt; + struct sctp_rtoinfo rtoinfo; + struct sctp_assocparams assocparams; + + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) + { + m2ua_log_err(sg, "M2UA set nonblock failure!"); + return 0; + } + + lg.l_onoff = 1; + lg.l_linger = 0; + + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lg, sizeof(lg)) != 0) + { + m2ua_log_err(sg, "set linger failed!"); + //return 0; + } + + if ((sg >= M2UA_MAX_SG_NUM) || + ((sg < M2UA_MAX_SG_NUM) && !m2ua_para.sg_para[sg].server)) + { + // Enable all events + event.sctp_data_io_event = 1; + event.sctp_association_event = 1; + event.sctp_address_event = 1; + event.sctp_send_failure_event = 1; + event.sctp_peer_error_event = 1; + event.sctp_shutdown_event = 1; + event.sctp_partial_delivery_event = 1; + event.sctp_adaptation_layer_event = 1; + //event.sctp_adaption_layer_event = 1; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) + { + m2ua_log_err(sg, "set event failed!"); + return 0; + } + + initopt.sinit_num_ostreams = 257; + initopt.sinit_max_instreams = 257; + initopt.sinit_max_attempts = 8; + initopt.sinit_max_init_timeo = 0; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initopt, sizeof(initopt)) != 0) + { + m2ua_log_err(sg, "set initopt failed!"); + return 0; + } + + rtoinfo.srto_assoc_id = 0; + rtoinfo.srto_initial = 1000; + rtoinfo.srto_max = 5000; + rtoinfo.srto_min = 1000; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo)) != 0) + { + m2ua_log_err(sg, "set rtoinfo failed!"); + //return 0; + } + + memset((BYTE *)&assocparams, 0, sizeof(assocparams)); + assocparams.sasoc_asocmaxrxt = 5; + if (setsockopt(fd, IPPROTO_SCTP, SCTP_ASSOCINFO, &assocparams, sizeof(assocparams)) != 0) + { + m2ua_log_err(sg, "set assocparams failed!"); + //return 0; + } + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_optmgmt_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 1; +} + +int m2ua_sctp_optmgmt_req_lksctp_ext(int fd, int sg) +{ + struct sctp_paddrparams paddrparams; + struct sockaddr_in *paddr; + + if (sg < M2UA_MAX_SG_NUM) + { + memset((BYTE *)&paddrparams, 0, sizeof(paddrparams)); + paddr = (struct sockaddr_in *)&paddrparams.spp_address; + paddr->sin_family = AF_INET; + if (m2ua_para.sg_para[sg].server) + paddr->sin_port = m2ua_sg_info[sg].rem_port; + else + { + if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M2UA_APP) + paddr->sin_port = htons(M2UA_PORT_0); + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == IUA_APP) + paddr->sin_port = htons(IUA_PORT_0); + else if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M3UA_APP) + paddr->sin_port = htons(M3UA_PORT_0); + } + paddr->sin_addr.s_addr = m2ua_para.sg_para[sg].ip; + paddrparams.spp_hbinterval = 20000; + paddrparams.spp_pathmaxrxt = 5; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &paddrparams, sizeof(paddrparams)) != 0) + { + m2ua_log_err(sg, "set paddrparams failed!"); + //return 0; + } + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_optmgmt_req_lksctp_ext succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 1; +} + +int m2ua_sctp_bind_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds) +{ + struct sockaddr_in sin[1]; + + sin->sin_family = AF_INET; + sin->sin_port = addr->port; + sin->sin_addr.s_addr = addr->addr.s_addr; + + if (bind(fd, (struct sockaddr *)sin, sizeof (*sin)) == -1) + { + m2ua_log_err(sg, "bind failed!"); + return 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_bind_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + if (coninds) + { + if (listen(fd, 1) == -1) + { + m2ua_log_err(sg, "listen failed!"); + return 0; + } + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_listen_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + } + + return 1; +} + +int m2ua_sctp_open_lksctp(WORD sg) +{ + int fd; + + if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) == -1) + m2ua_log_err(sg, "M2UA lksctp open failure!"); + + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) + { + m2ua_log_err(sg, "M2UA set nonblock failure!"); + return 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_open_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return fd; +} + +int m2ua_sctp_conn_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr) +{ + struct sockaddr_in sin[1]; + + sin->sin_family = AF_INET; + sin->sin_port = addr->port; + sin->sin_addr.s_addr = addr->addr.s_addr; + + connect(fd, (struct sockaddr *)sin, sizeof(sin)); + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_conn_req_lksctp sent, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 0; +} + +int m2ua_handle_event_lksctp(void *buf) +{ + struct sctp_assoc_change *sac; + //struct sctp_send_failed *ssf; + //struct sctp_paddr_change *spc; + //struct sctp_remote_error *sre; + union sctp_notification *snp; + //char addrbuf[8]; + //const char *ap; + //struct sockaddr_in *sin; + + snp = buf; + + switch (snp->sn_header.sn_type) + { + case SCTP_ASSOC_CHANGE: + sac = &snp->sn_assoc_change; + //printf("^^^ assoc_change: state=%hu, error=%hu, instr=%hu " + // "outstr=%hu\n", sac->sac_state, sac->sac_error, + // sac->sac_inbound_streams, sac->sac_outbound_streams); + return ((SCTP_ASSOC_CHANGE << 16) | (sac->sac_state & 0xFFFF)); + case SCTP_SEND_FAILED: + //ssf = &snp->sn_send_failed; + //printf("^^^ sendfailed: len=%hu err=%d\n", ssf->ssf_length, + // ssf->ssf_error); + return M2UA_LKSCTP_SEND_FAILED; + case SCTP_PEER_ADDR_CHANGE: + //spc = &snp->sn_paddr_change; + //if (spc->spc_aaddr.ss_family == AF_INET) { + // sin = (struct sockaddr_in *)&spc->spc_aaddr; + // ap = inet_ntop(AF_INET, &sin->sin_addr, + // addrbuf, 8); + //} + //printf("^^^ intf_change: %s state=%d, error=%d\n", ap, + // spc->spc_state, spc->spc_error); + return M2UA_LKSCTP_PEER_ADDR_CHANGE; + case SCTP_REMOTE_ERROR: + //sre = &snp->sn_remote_error; + //printf("^^^ remote_error: err=%hu len=%hu\n", + // ntohs(sre->sre_error), ntohs(sre->sre_length)); + return M2UA_LKSCTP_REMOTE_ERROR; + case SCTP_SHUTDOWN_EVENT: + //printf("^^^ shutdown event\n"); + return M2UA_LKSCTP_SHUTDOWN_EVENT; + default: + //printf("unknown type: %hu\n", snp->sn_header.sn_type); + return M2UA_LKSCTP_UNKNOWN_EVENT; + } + + return -1; +} + +void *m2ua_recvmsg_lksctp(WORD sg, int fd, struct msghdr *msg, void *data_buf, int *data_len, int cmsglen) +{ + int nr = 0, nnr = 0; + struct iovec iov[1]; + //BYTE tmp_buf[M2UA_SCTP_DAT_BUFSIZE]; + + *data_len = 0; + iov->iov_base = data_buf; + iov->iov_len = M2UA_SCTP_DAT_BUFSIZE; + + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + //for (;;) + { +#ifndef MSG_XPG4_2 +#define MSG_XPG4_2 0 +#endif + msg->msg_flags = MSG_XPG4_2; + msg->msg_controllen = cmsglen; + + nnr = recvmsg(fd, msg, 0); + if (nnr <= 0) + { + /* EOF or error */ + *data_len = nr; + return (NULL); + } + nr += nnr; + + if ((msg->msg_flags & MSG_EOR) != 0) + { + *data_len = nr; + return (data_buf); + } + + //iov->iov_base = tmp_buf; + //iov->iov_len = M2UA_SCTP_DAT_BUFSIZE; + } + + m2ua_log_err(sg, "m2ua_recvmsg_lksctp MSG_EOR flag not set!"); + + return (NULL); +} + +int m2ua_sctp_get_msg_lksctp(int fd, WORD sg) +{ + int ret = -1; + //BYTE in_b; + struct sctp_sndrcvinfo *sri; + struct msghdr msg[1]; + struct cmsghdr *cmsg; + BYTE *cbuf; + BYTE *dbuf; + int cmsglen = sizeof(*cmsg) + sizeof(*sri); + + //in_b = inb(0x378); + //outb(in_b | 0x02, 0x378); + + /* Set up the msghdr structure for receiving */ + memset(msg, 0, sizeof (*msg)); + cbuf = m2ua_sctp_cmd.cbuf; + dbuf = m2ua_sctp_dat; + msg->msg_control = cbuf; + msg->msg_controllen = cmsglen; + msg->msg_flags = 0; + cmsg = (struct cmsghdr *)cbuf; + sri = (struct sctp_sndrcvinfo *)(cmsg + 1); + m2ua_sctp_dat_len = M2UA_SCTP_DAT_BUFSIZE; + + if ((dbuf = m2ua_recvmsg_lksctp(sg, fd, msg, dbuf, &m2ua_sctp_dat_len, cmsglen)) > 0) + { + /* Intercept notifications here */ + if (msg->msg_flags & MSG_NOTIFICATION) + ret = m2ua_handle_event_lksctp(dbuf); + else + ret = M2UA_LKSCTP_DATA_IND; + } + + //outb(in_b & 0xFD, 0x378); + + return ret; +} + +int expect_lksctp(int fd, int sg, int *msg, int want) +{ + int got; + + *msg = got = m2ua_sctp_get_msg_lksctp(fd, sg); + + if (got != -1) + { + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + if (m2ua_sctp_dat_len > 0) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from SCTP, sg=%d, data len=%d\n\r", dec_sctp_primi_lksctp(got), sg, m2ua_sctp_dat_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_dat_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + + if (got == want) + return M2UA_SUCCESS; + else + return M2UA_FAILURE; +} + +int m2ua_sctp_discon_req_lksctp(int fd, int sg, int flag) +{ + BYTE enable1, enable2, server; + WORD lk; + + m2ua_sctp_close(fd, sg); + if (sg < M2UA_MAX_SG_NUM) + { + //enable1 = m2ua_sg_info[sg].enable; + //m2ua_sg_init(sg); + //m2ua_sg_info[sg].enable = enable1; + m2ua_sg_info[sg].fd = 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_discon_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + if ((flag == 0) || (sg >= M2UA_MAX_SG_NUM)) + return 0; + + enable1 = m2ua_sg_info[sg].enable; + enable2 = m2ua_para.sg_para[sg].enable; + server = m2ua_para.sg_para[sg].server; + + if (!server && enable1 && (enable2 == 1)) + { + if ((fd = m2ua_sctp_open_lksctp(sg)) <= 0) + { + m2ua_sg_info[sg].enable = 0; + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if(m2ua_para.lk_para[lk].lk_sg == sg) + m2ua_lk_info[lk].enable = 0; + } + m2ua_log_err(sg, "M2UA lksctp open failure!"); + } + else + m2ua_sg_info[sg].fd = fd; + } + + return 1; +} + +int m2ua_sctp_put_msg_lksctp(int fd, int sg) +{ + //BYTE err_text[128]; + //BYTE in_b; + BYTE ppid; + struct sctp_sndrcvinfo *sri; + struct msghdr msg[1]; + struct cmsghdr *cmsg; + struct iovec iov[1]; + int cmsglen = sizeof(*cmsg) + sizeof(*sri); + int ret; + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + if (m2ua_sctp_dat_len > 0) + { + sprintf(m2ua_ascitemp_buf, "Send M2UA_LKSCTP_DATA to SCTP, sg=%d, data len=%d\n\r", sg, m2ua_sctp_dat_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_dat_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + //in_b = inb(0x378); + //outb(in_b | 0x04, 0x378); + //88 us + + /* Set up the msghdr structure for receiving */ + memset(msg, 0, sizeof (*msg)); + + iov->iov_base = m2ua_sctp_data.buf; + iov->iov_len = m2ua_sctp_data.len; + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + msg->msg_control = m2ua_sctp_cmd.cbuf; + msg->msg_controllen = cmsglen; + msg->msg_flags = MSG_XPG4_2; + + cmsg = (struct cmsghdr *)m2ua_sctp_cmd.cbuf; + sri = (struct sctp_sndrcvinfo *)(cmsg + 1); + + cmsg->cmsg_len = cmsglen; + cmsg->cmsg_level = IPPROTO_SCTP; + cmsg->cmsg_type = SCTP_SNDRCV; + + memset((BYTE *)sri, 0, sizeof(*sri)); + sri->sinfo_stream = m2ua_sctp_data.sid; + //sri->sinfo_ppid = htonl(2); //m2ua + switch(m2ua_para.sg_para[sg].xUA_ack>>1)//SCTP Payload Protocol Identifier + { + case M2UA_APP: + ppid = 2; + break; + case IUA_APP: + ppid = 1; + break; + case M3UA_APP: + ppid = 3; + break; + default: + ppid = 2; + break; + } + sri->sinfo_ppid = htonl(ppid); + + if ((ret = sendmsg(fd, msg, MSG_NOSIGNAL)) < 0) + { + BYTE ascitemp_buf[256]; + sprintf(ascitemp_buf, "ret=%d,lksctp sendmsg failure: %d(%s)", ret,errno, strerror(errno)); + m2ua_log_err(sg, ascitemp_buf); + return -1; + } + + //outb(in_b & 0xFB, 0x378); + + return 0; +} + +int m2ua_sctp_optdata_req_lksctp(int fd, int sg, int len) +{ + if (!len) + return (-1); + else + { + if (len > M2UA_MAX_MSG_LEN) + return (-1); + else + m2ua_sctp_data.len = len; + } + + return m2ua_sctp_put_msg_lksctp(fd, sg); +} + +#endif diff --git a/omc/plat/m2ua/src_old/.copyarea.db b/omc/plat/m2ua/src_old/.copyarea.db new file mode 100644 index 0000000..bf11b8c --- /dev/null +++ b/omc/plat/m2ua/src_old/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\src_old +2 +5 +c:m2ua_debug.c|1|11d70a40563|2df5|274e395|09896a90bfa511dc8544001c23e19543|0 +a:m2ua_msg.c|1|11d70a404f6|12209|b5f0df09|08596a58bfa511dc8544001c23e19543|0 +6:m2ua.c|1|11d70a40525|1d83|2c056bdc|08f96a74bfa511dc8544001c23e19543|0 +7:include|2|0|0|0|0ab96ac8bfa511dc8544001c23e19543|0 +a:m2ua_fsm.c|1|11d70a40592|b53f|b87a847|0a296aacbfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/src_old/include/.copyarea.db b/omc/plat/m2ua/src_old/include/.copyarea.db new file mode 100644 index 0000000..b58818a --- /dev/null +++ b/omc/plat/m2ua/src_old/include/.copyarea.db @@ -0,0 +1,14 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\src_old\include +2 +a +c:m2ua_const.h|1|11d70a40709|2c55|4f1fe502|0db96b54bfa511dc8544001c23e19543|0 +c:m2ua_debug.h|1|11d70a407d4|102|5a9253a9|10b96bc4bfa511dc8544001c23e19543|0 +a:m2ua_msg.h|1|11d70a406da|67f|a6f337b2|0d196b38bfa511dc8544001c23e19543|0 +a:m2ua_def.h|1|11d70a4067c|610|b01bdf4e|0be96b00bfa511dc8544001c23e19543|0 +a:m2ua_ext.h|1|11d70a40738|66c|51d00b3c|0ee96b70bfa511dc8544001c23e19543|0 +a:m2ua_fsm.h|1|11d70a407a5|8a|e7592b04|10196ba8bfa511dc8544001c23e19543|0 +d:m2ua_struct.h|1|11d70a406ab|1eaa|328f49e|0c896b1cbfa511dc8544001c23e19543|0 +6:sctp.h|1|11d70a40767|4a78|3abef872|0f896b8cbfa511dc8544001c23e19543|0 +6:m2ua.h|1|11d70a40803|8aa|b5b099a3|11496be0bfa511dc8544001c23e19543|0 +a:m2ua_pub.h|1|11d70a4064e|46a|351c789a|0b596ae4bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/src_old/include/m2ua.h b/omc/plat/m2ua/src_old/include/m2ua.h new file mode 100644 index 0000000..e26528b --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_const.h b/omc/plat/m2ua/src_old/include/m2ua_const.h new file mode 100644 index 0000000..7274599 --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_const.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_debug.h b/omc/plat/m2ua/src_old/include/m2ua_debug.h new file mode 100644 index 0000000..0060606 --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_debug.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_def.h b/omc/plat/m2ua/src_old/include/m2ua_def.h new file mode 100644 index 0000000..9d47913 --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_def.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_ext.h b/omc/plat/m2ua/src_old/include/m2ua_ext.h new file mode 100644 index 0000000..d45ea8d --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_ext.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_fsm.h b/omc/plat/m2ua/src_old/include/m2ua_fsm.h new file mode 100644 index 0000000..b3ace0e --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_fsm.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_msg.h b/omc/plat/m2ua/src_old/include/m2ua_msg.h new file mode 100644 index 0000000..2882e8d --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_msg.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_pub.h b/omc/plat/m2ua/src_old/include/m2ua_pub.h new file mode 100644 index 0000000..38ec74e --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_pub.h @@ -0,0 +1,63 @@ +#ifndef _M2UA_PUB__H +#define _M2UA_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _LKSCTP +#include +#include +#include +#include +#else +#include +#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 diff --git a/omc/plat/m2ua/src_old/include/m2ua_struct.h b/omc/plat/m2ua/src_old/include/m2ua_struct.h new file mode 100644 index 0000000..b071518 --- /dev/null +++ b/omc/plat/m2ua/src_old/include/m2ua_struct.h @@ -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 diff --git a/omc/plat/m2ua/src_old/include/sctp.h b/omc/plat/m2ua/src_old/include/sctp.h new file mode 100644 index 0000000..62ba0d0 --- /dev/null +++ b/omc/plat/m2ua/src_old/include/sctp.h @@ -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 + * + * Or submit a bug report through the following website: + * http://www.sf.net/projects/lksctp + * + * Written or modified by: + * La Monte H.P. Yarroll + * R. Stewart + * K. Morneau + * Q. Xie + * Karl Knutson + * Jon Grimm + * Daisy Chang + * Inaky Perez-Gonzalez + * Sridhar Samudrala + * + * 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 +#include +#include + +__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 . + */ +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 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__ */ diff --git a/omc/plat/m2ua/src_old/m2ua.c b/omc/plat/m2ua/src_old/m2ua.c new file mode 100644 index 0000000..bb8556f --- /dev/null +++ b/omc/plat/m2ua/src_old/m2ua.c @@ -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; +} diff --git a/omc/plat/m2ua/src_old/m2ua_debug.c b/omc/plat/m2ua/src_old/m2ua_debug.c new file mode 100644 index 0000000..1436daf --- /dev/null +++ b/omc/plat/m2ua/src_old/m2ua_debug.c @@ -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; +} diff --git a/omc/plat/m2ua/src_old/m2ua_fsm.c b/omc/plat/m2ua/src_old/m2ua_fsm.c new file mode 100644 index 0000000..b71663a --- /dev/null +++ b/omc/plat/m2ua/src_old/m2ua_fsm.c @@ -0,0 +1,1505 @@ +#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 "./include/m2ua_msg.h" +#include "./include/m2ua_debug.h" + +//add by yizane +int find_sg_by_ipv4(DWORD ipv4,uint16_t sg_id) +{ + WORD sg; + BYTE type; + BYTE ascitemp_buf[256]; + + if (sg_id == M2UA_LISTEN_SG_NUM_0 || + sg_id == M2UA_LISTEN_SG_NUM_1) + type = M2UA_APP; + else if (sg_id == IUA_LISTEN_SG_NUM_0 || + sg_id == IUA_LISTEN_SG_NUM_1) + type = IUA_APP; + + for (sg = 0; sg < M2UA_MAX_SG_NUM; sg++) + { + if (m2ua_para.sg_para[sg].enable && + m2ua_sg_info[sg].enable && + m2ua_para.sg_para[sg].server && + ((m2ua_para.sg_para[sg].xUA_ack>>1)==type) && + (m2ua_para.sg_para[sg].ip == ipv4) + ) + return sg; + } + sprintf(ascitemp_buf, "can't find sg by ipv4: %X\n\r", ipv4); + m2ua_log_err(sg_id, ascitemp_buf); + return -1; +} +/* +int find_sg_by_ipv4(DWORD ipv4) +{ + WORD sg; + + for (sg = 0; sg < M2UA_MAX_SG_NUM; sg++) + { + if (m2ua_para.sg_para[sg].enable && + m2ua_para.sg_para[sg].server && + (m2ua_para.sg_para[sg].ip == ipv4)) + return sg; + } + + return -1; +} +*/ +int rel_sid(WORD sg, BYTE lk) +{ + WORD ostr; + BYTE dw_index, bit_index; + + if (m2ua_lk_info[lk].sid == 0) + return -1; + + ostr = m2ua_lk_info[lk].sid - 1; + m2ua_lk_info[lk].sid = 0; + + dw_index = ostr / 32; + bit_index = ostr % 32; + + m2ua_sg_info[sg].sid_st[dw_index] &= (~(0x00000001 << bit_index)); + m2ua_sg_info[sg].rem_ostrs++; + + return 0; +} + +int assign_sid(WORD sg, BYTE lk) +{ + WORD i; + BYTE dw_index, bit_index; + + if ((m2ua_sg_info[sg].ostrs < 2) ||(m2ua_sg_info[sg].ostrs > 257) || + (m2ua_sg_info[sg].rem_ostrs == 0) || (m2ua_lk_info[lk].sid > 0)) + return -1; + + for (i = 0; i < m2ua_sg_info[sg].ostrs - 1; i++) + { + dw_index = i / 32; + bit_index = i % 32; + if ((m2ua_sg_info[sg].sid_st[dw_index] >> bit_index) & 1) + continue; + else + { + m2ua_sg_info[sg].sid_st[dw_index] |= (0x00000001 << bit_index); + m2ua_sg_info[sg].rem_ostrs--; + m2ua_lk_info[lk].sid = i + 1; + return 0; + } + } + + return -1; +} + +int rel_sg_lk(WORD sg_id) +{ + WORD lk; + BYTE flag = 0; + + if ((m2ua_para.sg_para[sg_id].enable == 0) || + (m2ua_para.sg_para[sg_id].enable == 2)) + flag = 1; + + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && + m2ua_lk_info[lk].enable) + { + rel_sid(sg_id, lk); + if (m2ua_lk_info[lk].lk_st > M2UA_LK_DOWN) + { + m2ua_lk_info[lk].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[lk].alarm_code = m2ua_sg_info[sg_id].alarm_code; + m2ua_sd_mtp3_primi(lk, M2UA_LK_DOWN); + m2ua_csta.lk_csta[lk].lk_dn_times++; + } + if (flag) + { + m2ua_lk_info[lk].enable = 0; + m2ua_lk_info[lk].lk_st = M2UA_LK_IDLE; + } + } + } + + m2ua_sg_info[sg_id].up_lks_cur = 0; + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_NORMAL; + + return 0; +} + +int chg_sg_lk_status(WORD sg_id, BYTE status) +{ + WORD lk; + + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && + m2ua_lk_info[lk].enable) + m2ua_lk_info[lk].lk_st = status; + } + + return 1; +} + +int m2ua_fsm(WORD sg_id) +{ + WORD m2ua_cmd, mtp3_cmd, mgmt_cmd; + BYTE iid, lk_enable; + BYTE server; + int ret_val; + + m2ua_cmd = m2ua_sg_info[sg_id].m2ua_cmd; + mtp3_cmd = m2ua_sg_info[sg_id].mtp3_cmd; + mgmt_cmd = m2ua_sg_info[sg_id].mgmt_cmd; + + if (m2ua_sg_info[sg_id].m2ua_state < 3) + { + if (mgmt_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].mgmt_cmd = M2UA_CMD_IDLEW; + if (mtp3_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + } + + server = m2ua_para.sg_para[sg_id].server; + iid = m2ua_sg_info[sg_id].iid; + lk_enable = m2ua_para.lk_para[iid].enable; + + switch (m2ua_sg_info[sg_id].m2ua_state) + { + case 0: // Wait For M2UA ASP Up, or send ASP Up + if (server) + { + if (m2ua_cmd != M2UA_CMD_IDLEW) + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_INACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 1; + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + else if ((m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) || + (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE)) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + } + } + else + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + m2ua_sg_info[sg_id].m2ua_state = 1; + //add by yizane; + m2ua_sg_info[sg_id].retrans_times = 0; + } + break; + case 1: // Wait For M2UA ASP Active, or wait for ASP Up Ack + if (server) + { + if (m2ua_cmd != M2UA_CMD_IDLEW) + { + if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_ACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + else if (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE_ACK); + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].T_r = 0; + m2ua_sg_info[sg_id].m2ua_state = 0; + } + } + + if (m2ua_sg_info[sg_id].T_r > 0) + { + if (--m2ua_sg_info[sg_id].T_r == 0) + { + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_INACTIVE; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + } + } + } + else + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP_ACK) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + m2ua_sg_info[sg_id].m2ua_state = 2; + m2ua_sg_info[sg_id].retrans_times = 0; + } + else if (m2ua_sg_info[sg_id].T_ack > 0) + { + if (--m2ua_sg_info[sg_id].T_ack == 0) + { + if (++m2ua_sg_info[sg_id].retrans_times >= M2UA_MAX_RETRANS) + return -2; + else + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + } + } + } + } + break; + case 2: // Wait for ASP ACTIVE ACK, only client can come to this state + if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE_ACK) + { + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].m2ua_state = 3; + chg_sg_lk_status(sg_id, M2UA_LK_DOWN); + m2ua_sg_info[sg_id].retrans_times = 0; + } + else if (m2ua_cmd == M2UA_MGMT_ERROR) + { + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].retrans_times = 0; + m2ua_sg_info[sg_id].m2ua_state = 0; + return -2; + } + else if (m2ua_sg_info[sg_id].T_ack > 0) + { + if (--m2ua_sg_info[sg_id].T_ack == 0) + { + if (++m2ua_sg_info[sg_id].retrans_times >= M2UA_MAX_RETRANS) + return -2; + else + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE); + m2ua_sg_info[sg_id].T_ack = M2UA_T_ACK; + } + } + } + break; + case 3: // M2UA ASP Active + if (mgmt_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mgmt_cmd = M2UA_CMD_IDLEW; + if (((mgmt_cmd == M2UA_MGMT_CMD_LK_LOCK) + ||(mgmt_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MGMT_CMD_LK_LOCK))) + &&(m2ua_lk_info[iid].lk_st >= M2UA_LK_UP)) + { + if (server) + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + else + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + rel_sid(sg_id, iid); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((mgmt_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MGMT_CMD_LK_LOCK)) && + (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP)) + { + if (server) + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_IND); + else + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + rel_sid(sg_id, iid); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + return -1; + } + + if (server) + { + if (mtp3_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && + ( (mtp3_cmd == M2UA_MTP3_CMD_DEACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_STOP_L2) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)) + )) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && + ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)))) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_IND); + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + } + else if (m2ua_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd == M2UA_MAUP_DATA) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + m2ua_sd_mtp3_msg(sg_id, iid); + err[13]++; + } + return 0; + } + else if (m2ua_cmd == M2UA_MAUP_ESTABLISH_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_CFM); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m2ua_sd_mtp3_primi(iid, M2UA_LK_UP); + } + } + } + else if (m2ua_cmd == M2UA_MAUP_RELEASE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_CFM); + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + } + } + else if (m2ua_cmd == M2UA_MAUP_STATE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + ret_val = assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + if (m2ua_sg_info[sg_id].state == M2UA_STATUS_AUDIT) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_CFM); + else + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_IND); + } + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_CFM); + if (ret_val != -1) + rel_sid(sg_id, iid); + } + } + } + //add by yizane + //for iua + else if (m2ua_cmd == IUA_QPTM_DATA_REQ ||m2ua_cmd == IUA_QPTM_UDATA_REQ) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + iua_sd_q931_msg(sg_id, iid); + err[13]++; + } + return 0; + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, IUA_QPTM_ESTABLISH_CFM); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + } + } + } + else if (m2ua_cmd == IUA_QPTM_RELEASE_REQ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_CFM); + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + } + } + //add by yizane + else if (m2ua_cmd == M2UA_ASPTM_ASP_ACTIVE) + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_ACTIVE_ACK); + else if ((m2ua_cmd == M2UA_ASPSM_ASP_DOWN) || + (m2ua_cmd == M2UA_ASPSM_ASP_UP) || + (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE)) + { + if (m2ua_cmd == M2UA_ASPSM_ASP_UP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_UP_ACK); + m2ua_sg_info[sg_id].m2ua_state = 1; + } + else if (m2ua_cmd == M2UA_ASPSM_ASP_DOWN) + { + m2ua_send_msg(sg_id, M2UA_ASPSM_ASP_DOWN_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_PENDING; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].m2ua_state = 0; + } + else if (m2ua_cmd == M2UA_ASPTM_ASP_INACTIVE) + { + m2ua_send_msg(sg_id, M2UA_ASPTM_ASP_INACTIVE_ACK); + m2ua_sg_info[sg_id].status = (M2UA_STATUS_TYPE_AS_STATE_CHG << 16) | M2UA_STATUS_INFO_AS_PENDING; + m2ua_send_msg(sg_id, M2UA_MGMT_NOTIFY); + m2ua_sg_info[sg_id].T_r = M2UA_T_R; + m2ua_sg_info[sg_id].m2ua_state = 1; + } + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_REMOTE_AS_DOWN; + rel_sg_lk(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + m2ua_csta.sg_csta[sg_id].sg_asp_dn_times++; + } + } + } + else + { + if (mtp3_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].mtp3_cmd = M2UA_CMD_IDLEW; + if ((mtp3_cmd == M2UA_MTP3_CMD_ACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_ACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_EMERG_ALIGN)) + ) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1) && + (!m2ua_lk_info[iid].lk_timer)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + /* + if (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) + { + m2ua_sg_info[sg_id].state = M2UA_STATUS_EMER_SET; + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_REQ); + } + */ + if (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + else + m2ua_send_msg(sg_id, M2UA_MAUP_ESTABLISH_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + } + } + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && (!m2ua_lk_info[iid].lk_timer) && + ((mtp3_cmd == M2UA_MTP3_CMD_DEACTIVE_LK) || + (mtp3_cmd == M2UA_MTP3_CMD_STOP_L2) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(M2UA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)) + )) + { + m2ua_send_msg(sg_id, M2UA_MAUP_RELEASE_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + //add by yizane + //iua-> + else if ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_ACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_EMERG_ALIGN))) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1) && + (!m2ua_lk_info[iid].lk_timer)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + /* + if (mtp3_cmd == M2UA_MTP3_CMD_EMERG_ALIGN) + { + m2ua_sg_info[sg_id].state = M2UA_STATUS_EMER_SET; + m2ua_send_msg(sg_id, M2UA_MAUP_STATE_REQ); + } + */ + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; +// if (m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) + if (m2ua_lk_info[iid].lk_st > M2UA_LK_UP) + { + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + else + m2ua_send_msg(sg_id, IUA_QPTM_ESTABLISH_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + } + } + } + else if ((m2ua_lk_info[iid].lk_st >= M2UA_LK_UP) && (!m2ua_lk_info[iid].lk_timer) && + ((mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_DEACTIVE_LK)) || + (mtp3_cmd == COMBO_W(IUA_MGMT_CMD,M2UA_MTP3_CMD_STOP_L2)))) + { + m2ua_sg_info[sg_id].rel_reason = IUA_RELEASE_MGMT; + m2ua_send_msg(sg_id, IUA_QPTM_RELEASE_REQ); + m2ua_lk_info[iid].lk_timer = M2UA_T_LK_ESTAB; + rel_sid(sg_id, iid); + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + //iua<- + //add by yizane + } + else if (m2ua_cmd != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = M2UA_CMD_IDLEW; + if (m2ua_cmd == M2UA_MAUP_DATA) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + err[13]++; + m2ua_sd_mtp3_msg(sg_id, iid); +// if ((m2ua_para.sg_para[sg_id].data_ack == 1) && + if (((m2ua_para.sg_para[sg_id].xUA_ack&0x01) == 0x01) && + (m2ua_sg_info[sg_id].cor_id != 0)) + m2ua_send_msg(sg_id, M2UA_MAUP_DATA_ACK); + } + return 0; + } + else if (m2ua_cmd == M2UA_MAUP_ESTABLISH_CFM) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + m2ua_sd_mtp3_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + } + else if (m2ua_cmd == M2UA_MAUP_RELEASE_IND) + { + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + m2ua_sd_mtp3_primi(iid, M2UA_LK_DOWN); + } + //add by yizane + //for iua + else if (m2ua_cmd == IUA_QPTM_DATA_IND ||m2ua_cmd == IUA_QPTM_UDATA_IND) + { + if (m2ua_lk_info[iid].lk_st == M2UA_LK_UP) + { + err[13]++; + iua_sd_q931_msg(sg_id, iid); + } + return 0; + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_CFM) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + } + else if (m2ua_cmd == IUA_QPTM_ESTABLISH_IND) + { + if ((lk_enable == 1) && + (m2ua_lk_info[iid].enable == 1)) + { + assign_sid(sg_id, iid); + if (m2ua_lk_info[iid].sid > 0) + { + m2ua_send_msg(sg_id, IUA_QPTM_ESTABLISH_CFM); + if (m2ua_lk_info[iid].lk_st == M2UA_LK_DOWN) + { + m2ua_sg_info[sg_id].up_lks_pre++; + m2ua_sg_info[sg_id].up_lks_cur++; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_UP; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_NORMAL; + iua_sd_q931_primi(iid, M2UA_LK_UP); + } + } + } + else if (m2ua_cmd == IUA_QPTM_RELEASE_IND) + { + rel_sid(sg_id, iid); + if (m2ua_lk_info[iid].lk_st > M2UA_LK_DOWN) + { + m2ua_csta.lk_csta[iid].lk_dn_times++; + if (m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_cur--; + } + m2ua_lk_info[iid].lk_st = M2UA_LK_DOWN; + m2ua_lk_info[iid].alarm_code = M2UA_ALARM_CODE_REMOTE_LINK_RELEASE; + iua_sd_q931_primi(iid, M2UA_LK_DOWN); + } + //add by yizane + } + } + break; + default: + m2ua_sg_info[sg_id].m2ua_state = 0; + break; + } + + return -1; +} + +int m2ua_sctp_down(WORD sg_id) +{ + if (m2ua_sg_info[sg_id].m2ua_state == 3) + m2ua_csta.sg_csta[sg_id].sg_asp_dn_times++; + + m2ua_sg_info[sg_id].m2ua_state = 0; + m2ua_sg_info[sg_id].T_ack = 0; + m2ua_sg_info[sg_id].T_r = 0; + + m2ua_sg_info[sg_id].sctp_cmd = M2UA_CMD_IDLEW; + + rel_sg_lk(sg_id); + + m2ua_sg_info[sg_id].up_lks_pre = m2ua_sg_info[sg_id].up_lks_cur = 0; + + return 0; +} + +int m2ua_sg_fsm(WORD sg_id) +{ + int fd; + int msg, con_sg, ret; + BYTE enable; + BYTE conn_id; + BYTE server; + DWORD sctp_cmd; +#ifndef _LKSCTP + struct t_opthdr *oh; + t_scalar_t *str_val; + m2ua_sctp_addr_t *addr; +#else + struct sctp_assoc_change *sac; + int new_fd, addr_len; + struct sockaddr_in sin[1]; + BYTE ascitemp_buf[256]; + struct timeval TOut = {0, 0}; + fd_set ReadFds; +#endif + + if (((m2ua_sg_info[sg_id].enable == 0) ||(m2ua_sg_info[sg_id].fd == 0)) && + !((m2ua_sg_info[sg_id].sctp_state == 3) && (m2ua_sg_info[sg_id].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + return -1; + else + { + fd = m2ua_sg_info[sg_id].fd; + sctp_cmd = m2ua_sg_info[sg_id].sctp_cmd; + if (sg_id < M2UA_MAX_SG_NUM) + { + enable = m2ua_para.sg_para[sg_id].enable; + server = m2ua_para.sg_para[sg_id].server; + } + else + { + con_sg = m2ua_sg_info[sg_id].con_sg; + enable = m2ua_para.sg_para[con_sg].enable; + server = m2ua_para.sg_para[con_sg].server; + } + } + + switch (m2ua_sg_info[sg_id].sctp_state) + { + case 0: // SCTP Option Negotiate + if (((enable == 0) || (enable == 2)) && + (sg_id < M2UA_MAX_SG_NUM)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Send optmgnt request +#ifndef _LKSCTP + m2ua_sctp_optmgmt_req(fd, sg_id, T_NEGOTIATE); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#else + if (m2ua_sctp_optmgmt_req_lksctp(fd, sg_id) == 0) + { + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + else + { + //add by yizane + // if ((sg_id == M2UA_MAX_SG_NUM) || + if ((sg_id >= M2UA_MAX_SG_NUM) || + ((sg_id < M2UA_MAX_SG_NUM) && !server)) + { // Client or Listener + m2ua_sg_info[sg_id].sctp_state = 1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else + { // Server + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 5; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + } +#endif + break; + case 1: // Receive optmgmt response +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_OPTMGMT_ACK) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state = 1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer) +#else + if (m2ua_sg_info[sg_id].sg_timer) +#endif + m2ua_sg_info[sg_id].sg_timer--; + else + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + break; + case 1: // SCTP Address Bind + if (((enable == 0) || (enable == 2)) && + (sg_id < M2UA_MAX_SG_NUM)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Send bind request + //add by yizane + //if (sg_id == M2UA_MAX_SG_NUM) + if (sg_id >= M2UA_MAX_SG_NUM) + conn_id = 1; + else + conn_id = 0; + m2ua_sctp_addr.addr.s_addr = htonl(INADDR_ANY); +#ifndef _LKSCTP +//add by yizane + if (sg_id == M2UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M2UA_PORT_0); + else if (sg_id == M2UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M2UA_PORT_1); + else if (sg_id == IUA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(IUA_PORT_0); + else if (sg_id == IUA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(IUA_PORT_1); + else if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == M2UA_APP) + m2ua_sctp_addr.port = htons(M2UA_PORT_0+10000); + else if ((m2ua_para.sg_para[sg_id].xUA_ack>>1) == IUA_APP) + m2ua_sctp_addr.port = htons(IUA_PORT_0+10000); +//add by yizane + m2ua_sctp_bind_req(fd, sg_id, &m2ua_sctp_addr, conn_id); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#else + if ((sg_id >= M2UA_MAX_SG_NUM) || + ((sg_id < M2UA_MAX_SG_NUM) && !server)) + { // Client or Listener + if (sg_id == M2UA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(M2UA_PORT_0); + else if (sg_id == M2UA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(M2UA_PORT_1); + else if (sg_id == IUA_LISTEN_SG_NUM_0) + m2ua_sctp_addr.port = htons(IUA_PORT_0); + else if (sg_id == IUA_LISTEN_SG_NUM_1) + m2ua_sctp_addr.port = htons(IUA_PORT_1); + else + m2ua_sctp_addr.port = 0; + if (m2ua_sctp_bind_req_lksctp(fd, sg_id, &m2ua_sctp_addr, conn_id) == 0) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + break; + } + } + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; +#endif + break; + case 1: // Receive bind response +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_BIND_ACK) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer) +#else + if (m2ua_sg_info[sg_id].sg_timer) +#endif + m2ua_sg_info[sg_id].sg_timer--; + else + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + break; + case 2: // Wait for SCTP Connection Request from peer or Send conn req to the peer + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Wait for connection indication from peer or conn req to the peer + //add by yizane + //if (sg_id == M2UA_MAX_SG_NUM) + if (sg_id >= M2UA_MAX_SG_NUM) + { +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_CONN_IND) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].seq = m2ua_sctp_cmd.tpi.conn_ind.SEQ_number; + addr = (m2ua_sctp_addr_t *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_ind.SRC_offset); + //add by yizane + //con_sg = find_sg_by_ipv4(addr->addr.s_addr); + con_sg = find_sg_by_ipv4(addr->addr.s_addr,sg_id); + if (con_sg < 0) + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + else + { + oh = (struct t_opthdr *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_ind.OPT_offset); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_ISTREAMS) + m2ua_sg_info[sg_id].istrs = *str_val; + oh = (struct t_opthdr *)((BYTE *)oh + oh->len); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_OSTREAMS) + m2ua_sg_info[sg_id].ostrs = *str_val; + m2ua_sg_info[sg_id].con_sg = con_sg; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + } + } +#else + FD_ZERO(&ReadFds); + FD_SET(fd, &ReadFds); + if ((select(fd + 1, &ReadFds, NULL, NULL, &TOut) > 0) && + FD_ISSET(fd, &ReadFds)) + { + addr_len = sizeof(*sin); + if ((new_fd = accept(fd, (struct sockaddr *)sin, &addr_len)) > 0) + { + if (fcntl(new_fd, F_SETFL, O_NONBLOCK) < 0) + m2ua_log_err(sg_id, "got lksctp incoming connection, but set nonblock failure!"); + //add by yizane + con_sg = find_sg_by_ipv4(sin->sin_addr.s_addr,sg_id); + if ((con_sg < 0) || (m2ua_sg_info[con_sg].enable == 0)) + { + if (con_sg < 0) + sprintf(ascitemp_buf, "got lksctp incoming connection, but can't find sg by ipv4: %X\n\r", sin->sin_addr.s_addr); + else + sprintf(ascitemp_buf, "got lksctp incoming connection, but sg[%d] not enabled!\n\r", con_sg); + m2ua_log_err(sg_id, ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_sctp_discon_req_lksctp(new_fd, sg_id, 0); + } + else if ((m2ua_sg_info[con_sg].sctp_state == 3) && + (m2ua_sg_info[con_sg].sctp_state_1 == 0)) + { + m2ua_sg_info[con_sg].sctp_cmd = M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST; + sprintf(ascitemp_buf, "got lksctp incoming connection, but sg[%d] is still in ESTABLISHED state! Disconnect it!\n\r", con_sg); + m2ua_log_err(sg_id, ascitemp_buf); + m2ua_sctp_discon_req_lksctp(new_fd, sg_id, 0); + } + else + { + m2ua_sg_info[con_sg].fd = new_fd; + m2ua_sg_info[con_sg].rem_port = sin->sin_port; + } + } + } +#endif + } + else + { + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (sctp_cmd != M2UA_CMD_IDLEW) + m2ua_sg_info[sg_id].sctp_cmd = M2UA_CMD_IDLEW; + + if (!server && (enable == 1)) + { // M2UA Client + m2ua_sctp_server_addr.port = htons(m2ua_para.sg_para[sg_id].plat_port[0]); + m2ua_sctp_server_addr.addr.s_addr = m2ua_para.sg_para[sg_id].ip; + if (m2ua_sg_info[sg_id].sg_timer) + m2ua_sg_info[sg_id].sg_timer--; +#ifndef _LKSCTP + else if (m2ua_sctp_conn_req(fd, sg_id, &m2ua_sctp_server_addr) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 3; + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + } +#else + else if (m2ua_sctp_conn_req_lksctp(fd, sg_id, &m2ua_sctp_server_addr) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_2; + m2ua_sg_info[sg_id].sctp_state_1 = 4; + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + } +#endif + else + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + } + } + break; +#ifndef _LKSCTP + case 1: // Only SG_ID = M2UA_MAX_SG_NUM can come to this state + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 2)) + { + m2ua_sg_info[con_sg].seq = m2ua_sg_info[sg_id].seq; + m2ua_sg_info[con_sg].istrs = m2ua_sg_info[sg_id].istrs; + m2ua_sg_info[con_sg].ostrs = m2ua_sg_info[sg_id].ostrs; + m2ua_sg_info[con_sg].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + + if (m2ua_sctp_conn_res(fd, m2ua_sg_info[con_sg].fd, sg_id, m2ua_sg_info[sg_id].seq) != M2UA_FAILURE) + { + m2ua_sg_info[sg_id].sctp_state_1 = 2; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + chg_sg_lk_status(con_sg, M2UA_LK_IDLE); + break; + } + } + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + m2ua_sg_info[sg_id].sctp_state_1 = 0; + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 3)) + m2ua_sg_info[con_sg].sctp_cmd = T_DISCON_IND; + break; + case 2: // Only SG_ID = M2UA_MAX_SG_NUM can come to this state + if (expect(fd, sg_id, &msg, T_OK_ACK) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + + m2ua_sg_info[con_sg].sctp_state = 3; + m2ua_sg_info[con_sg].sctp_state_1 = 0; + } + else if ((msg == T_ERROR_ACK) || (!m2ua_sg_info[sg_id].sg_timer)) + { + m2ua_sctp_discon_req(fd, sg_id, m2ua_sg_info[sg_id].seq); + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + if ((enable == 1) && server && + (m2ua_sg_info[con_sg].sctp_state == 3)) + m2ua_sg_info[con_sg].sctp_cmd = T_DISCON_IND; + } + else + m2ua_sg_info[sg_id].sg_timer--; + break; + case 3: // Only M2UA client can come to this state + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sctp_close(fd, sg_id); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (expect(fd, sg_id, &msg, T_OK_ACK) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_2; + m2ua_sg_info[sg_id].sctp_state_1 = 4; + } + else if (msg == T_ERROR_ACK) + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_1; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + break; +#endif + case 4: // only M2UA client can come to this state + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_discon_req(fd, sg_id, 0); + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_CONN_CON) == M2UA_SUCCESS) + { + m2ua_sg_info[sg_id].sg_timer = 0; + oh = (struct t_opthdr *) (m2ua_sctp_cmd.cbuf + m2ua_sctp_cmd.tpi.conn_con.OPT_offset); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_ISTREAMS) + m2ua_sg_info[sg_id].istrs = *str_val; + oh = (struct t_opthdr *)((BYTE *)oh + oh->len); + str_val = (t_uscalar_t *)(oh + 1); + if (oh->name == T_SCTP_OSTREAMS) + { + m2ua_sg_info[sg_id].ostrs = *str_val; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + } + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } +#else + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP) == M2UA_SUCCESS) + { + sac = (struct sctp_assoc_change *) m2ua_sctp_dat; + m2ua_sg_info[sg_id].istrs = sac->sac_inbound_streams; + m2ua_sg_info[sg_id].ostrs = sac->sac_outbound_streams; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sctp_optmgmt_req_lksctp_ext(fd, sg_id); + } +#endif + else + { +#ifndef _LKSCTP + if (msg == T_DISCON_IND) + { + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } +#else + if (msg == M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + } +#endif + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { +#ifndef _LKSCTP + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; +#endif + } + } + break; +#ifdef _LKSCTP + case 5: // only M2UA server_lksctp can come to this state + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 0); + + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } + + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP) == M2UA_SUCCESS) + { + sac = (struct sctp_assoc_change *) m2ua_sctp_dat; + m2ua_sg_info[sg_id].istrs = sac->sac_inbound_streams; + m2ua_sg_info[sg_id].ostrs = sac->sac_outbound_streams; + m2ua_sg_info[sg_id].rem_ostrs = m2ua_sg_info[sg_id].ostrs - 1; + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sctp_optmgmt_req_lksctp_ext(fd, sg_id); + } + else + { + if (msg == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 1);//fixed by zane + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + else if (m2ua_sg_info[sg_id].sg_timer > 0) + m2ua_sg_info[sg_id].sg_timer--; + else + { + m2ua_sctp_discon_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, 1);//fixed by zane + m2ua_sg_info[sg_id].sg_timer = 0; + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + } + } + break; +#endif + default: + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + }; + break; + case 3: // M2UA SCTP Link Established + switch (m2ua_sg_info[sg_id].sctp_state_1) + { + case 0: // Normal +#ifndef _LKSCTP + if ((enable == 0) || (enable == 2) || (sctp_cmd == T_DISCON_IND) || + (!server && !m2ua_sg_info[sg_id].up_lks_cur && m2ua_sg_info[sg_id].up_lks_pre)) + { + if ((enable == 0) || (enable == 2)) + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + else + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_discon_req(fd, sg_id, 0); +#else + if ((enable == 0) || (enable == 2) || (sctp_cmd == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) || + (!server && !m2ua_sg_info[sg_id].up_lks_cur && m2ua_sg_info[sg_id].up_lks_pre)) + { + if ((enable == 0) || (enable == 2)) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + } + else + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + } +#endif + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if ((enable == 0) || (enable == 2)) + { + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + } + else + { + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_log_err(sg_id, "All links are down, to reestablish the SCTP link!"); + } + + return -1; + } + else if (m2ua_sg_info[sg_id].up_lks_pre != m2ua_sg_info[sg_id].up_lks_cur) + m2ua_sg_info[sg_id].up_lks_pre = m2ua_sg_info[sg_id].up_lks_cur; + +#ifndef _LKSCTP + if (expect(fd, sg_id, &msg, T_DATA_IND) == M2UA_FAILURE) + { // Handle SCTP Primitives + if ((msg == T_DISCON_IND) || (msg == T_ORDREL_IND)) + { + if (msg == T_ORDREL_IND) + m2ua_sctp_ordrel_req(fd, sg_id); +#else + if (expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_DATA_IND) == M2UA_FAILURE) + { // Handle SCTP Primitives + if ((msg == M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST) || + (msg == M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP) || + (msg == M2UA_LKSCTP_SHUTDOWN_EVENT)) + { + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + if(server) + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_WAIT; + else + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + m2ua_log_err(sg_id, "Got discon_ind from SCTP, wait to reestablish the SCTP link!"); + + return -1; + } +#ifdef _LKSCTP + else if (msg == M2UA_LKSCTP_ASSOC_CHANGE_RESTART) + { + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_SCTP_FAILURE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + m2ua_log_err(sg_id, "Got M2UA_LKSCTP_ASSOC_CHANGE_RESTART from SCTP!"); + return -1; + } +#endif + ret = -1; + } + else + { + m2ua_dec_msg(sg_id); + ret = 0; + } + + if ((m2ua_fsm(sg_id) == -2) && (!server)) + { +#ifndef _LKSCTP + m2ua_sctp_discon_req(fd, sg_id, 0); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 1);//fixed by zane +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_REMOTE_AS_DOWN; + m2ua_sctp_down(sg_id); + m2ua_sg_info[sg_id].sctp_state = 3; + m2ua_sg_info[sg_id].sctp_state_1 = 1; + m2ua_sg_info[sg_id].sg_timer = M2UA_T_SG_ESTAB_3; + + m2ua_log_err(sg_id, "ASP UP/ACTIVE timeout, wait to reestablish the SCTP link!"); + + return -2; + } + else + return ret; + break; + case 1: // Wait... + if ((enable == 0) || (enable == 2)) + { +#ifndef _LKSCTP + m2ua_sctp_close(fd, sg_id); +#else + m2ua_sctp_discon_req_lksctp(fd, sg_id, 0); +#endif + m2ua_sg_info[sg_id].alarm_code = M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE; + m2ua_sctp_down(sg_id); + chg_sg_lk_status(sg_id, M2UA_LK_IDLE); + + if (enable == 2) + m2ua_para.sg_para[sg_id].enable = 0; + + m2ua_sg_init(sg_id); + m2ua_log_err(sg_id, "SG disabled!"); + return -1; + } +#ifndef _LKSCTP + if ((m2ua_sg_info[sg_id].sg_timer--) > 0) + expect(fd, sg_id, &msg, T_OK_ACK); + else + { + m2ua_sg_info[sg_id].sctp_state = 2; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } +#else + if ((m2ua_sg_info[sg_id].sg_timer--) > 0); + //expect_lksctp(fd, sg_id, &msg, M2UA_LKSCTP_DATA_IND); + else + { + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + m2ua_sg_info[sg_id].sg_timer = 0; + } +#endif + break; + default: + break; + } + break; + default: + m2ua_sg_info[sg_id].sctp_state = 0; + m2ua_sg_info[sg_id].sctp_state_1 = 0; + break; + } + + return -1; +} + + diff --git a/omc/plat/m2ua/src_old/m2ua_msg.c b/omc/plat/m2ua/src_old/m2ua_msg.c new file mode 100644 index 0000000..d635734 --- /dev/null +++ b/omc/plat/m2ua/src_old/m2ua_msg.c @@ -0,0 +1,2749 @@ +#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 "./include/m2ua_fsm.h" +#include "./include/m2ua_debug.h" +#include "./include/m2ua_msg.h" + +#ifndef _LKSCTP + +static struct strfdinsert m2ua_sctp_fdi = +{ + {M2UA_SCTP_CMD_BUFSIZE, 0, m2ua_sctp_cmd.cbuf}, + {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat}, + 0, + 0, + 0 +}; + +static m2ua_sctp_opt_data_t m2ua_sctp_opt_data = +{ + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SID, + T_SUCCESS + }, + 0 +}; + +m2ua_sctp_opt_optm_t m2ua_sctp_opt_optm = +{ + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_NODELAY, + T_SUCCESS + }, + T_YES, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_CORK, + T_SUCCESS + }, + T_YES, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_PPI, + T_SUCCESS + }, + 2, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SID, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RECVOPT, + T_SUCCESS + }, + T_NO, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_COOKIE_LIFE, + T_SUCCESS + }, + 60000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_SACK_DELAY, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_PATH_MAX_RETRANS, + T_SUCCESS + }, + 5, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_ASSOC_MAX_RETRANS, + T_SUCCESS + }, + 5, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_MAX_INIT_RETRIES, + T_SUCCESS + }, + 8, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_HEARTBEAT_ITVL, + T_SUCCESS + }, + 20000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_INITIAL, + T_SUCCESS + }, + 1000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_MIN, + T_SUCCESS + }, + 1000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_RTO_MAX, + T_SUCCESS + }, + 5000, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_OSTREAMS, + T_SUCCESS + }, + 257, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_ISTREAMS, + T_SUCCESS + }, + 257, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_COOKIE_INC, + T_SUCCESS + }, + 0, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_THROTTLE_ITVL, + T_SUCCESS + }, + 50, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_MAC_TYPE, + T_SUCCESS + }, + SCTP_HMAC_NONE, + { + sizeof(struct t_opthdr) + sizeof(t_scalar_t), + T_INET_SCTP, + T_SCTP_DEBUG, + T_SUCCESS + }, + 0 +}; + +#endif + +char *dec_m2ua_msg(WORD m2ua_msg) +{ + switch (m2ua_msg) + { + + case M2UA_MAUP_DATA: return("M2UA_MAUP_DATA"); + case M2UA_MAUP_ESTABLISH_REQ: return("M2UA_MAUP_ESTABLISH_REQ"); + case M2UA_MAUP_ESTABLISH_CFM: return("M2UA_MAUP_ESTABLISH_CFM"); + case M2UA_MAUP_RELEASE_REQ: return("M2UA_MAUP_RELEASE_REQ"); + case M2UA_MAUP_RELEASE_CFM: return("M2UA_MAUP_RELEASE_CFM"); + case M2UA_MAUP_RELEASE_IND: return("M2UA_MAUP_RELEASE_IND"); + case M2UA_MAUP_STATE_REQ: return("M2UA_MAUP_STATE_REQ"); + case M2UA_MAUP_STATE_CFM: return("M2UA_MAUP_STATE_CFM"); + case M2UA_MAUP_STATE_IND: return("M2UA_MAUP_STATE_IND"); + case M2UA_MAUP_DATA_RETIEVE_REQ: return("M2UA_MAUP_DATA_RETIEVE_REQ"); + case M2UA_MAUP_DATA_RETIEVE_CFM: return("M2UA_MAUP_DATA_RETIEVE_CFM"); + case M2UA_MAUP_DATA_RETIEVE_IND: return("M2UA_MAUP_DATA_RETIEVE_IND"); + case M2UA_MAUP_DATA_RETIEVE_CMP: return("M2UA_MAUP_DATA_RETIEVE_CMP"); + case M2UA_MAUP_CONGESTION_IND: return("M2UA_MAUP_CONGESTION_IND"); + case M2UA_MAUP_DATA_ACK: return("M2UA_MAUP_DATA_ACK"); + + //add by yizane + case xUA_MGMT_ERROR: return("xUA_MGMT_ERROR"); + case xUA_MGMT_NOTIFY: return("xUA_MGMT_NOTIFY"); + case xUA_MGMT_TEI_S_REQ: return("xUA_MGMT_TEI_S_REQ"); + case xUA_MGMT_TEI_S_CFM: return("xUA_MGMT_TEI_S_CFM"); + case xUA_MGMT_TEI_S_IND: return("xUA_MGMT_TEI_S_IND"); + + case xUA_ASPSM_ASP_UP: return("xUA_ASPSM_ASP_UP"); + case xUA_ASPSM_ASP_DOWN: return("xUA_ASPSM_ASP_DOWN"); + case xUA_ASPSM_HEARTBEAT: return("xUA_ASPSM_HEARTBEAT"); + case xUA_ASPSM_ASP_UP_ACK: return("xUA_ASPSM_ASP_UP_ACK"); + case xUA_ASPSM_ASP_DOWN_ACK: return("xUA_ASPSM_ASP_DOWN_ACK"); + case xUA_ASPSM_HEARTBEAT_ACK: return("xUA_ASPSM_HEARTBEAT_ACK"); + + case xUA_ASPTM_ASP_ACTIVE: return("xUA_ASPTM_ASP_ACTIVE"); + case xUA_ASPTM_ASP_INACTIVE: return("xUA_ASPTM_ASP_INACTIVE"); + case xUA_ASPTM_ASP_ACTIVE_ACK: return("xUA_ASPTM_ASP_ACTIVE_ACK"); + case xUA_ASPTM_ASP_INACTIVE_ACK: return("xUA_ASPTM_ASP_INACTIVE_ACK"); + + case IUA_QPTM_DATA_REQ: return("IUA_QPTM_DATA_REQ"); + case IUA_QPTM_DATA_IND: return("IUA_QPTM_DATA_IND"); + case IUA_QPTM_UDATA_REQ: return("IUA_QPTM_UDATA_REQ"); + case IUA_QPTM_UDATA_IND: return("IUA_QPTM_UDATA_IND"); + case IUA_QPTM_ESTABLISH_REQ: return("IUA_QPTM_ESTABLISH_REQ"); + case IUA_QPTM_ESTABLISH_CFM: return("IUA_QPTM_ESTABLISH_CFM"); + case IUA_QPTM_ESTABLISH_IND: return("IUA_QPTM_ESTABLISH_IND"); + case IUA_QPTM_RELEASE_REQ: return("IUA_QPTM_RELEASE_REQ"); + case IUA_QPTM_RELEASE_CFM: return("IUA_QPTM_RELEASE_CFM"); + case IUA_QPTM_RELEASE_IND: return("IUA_QPTM_RELEASE_IND"); + //add by yizane + default: return("Unexpected"); + } +} + +int m2ua_make_par(m2ua_var_par_t *par_ptr, WORD par_type, BYTE *par_addr, WORD par_len) +{ + WORD len = 0; + + par_ptr->hdr.tag = htons(par_type); + par_ptr->hdr.len = htons(sizeof(m2ua_par_hdr_t) + par_len); + + len = sizeof(m2ua_par_hdr_t) + ((par_len + 3) & 0xFFFC); + if (par_type != M2UA_PAR_PROTO_DATA_1) + bcopy(par_addr, par_ptr->val, par_len); + bzero(par_ptr->val + par_len, len - par_len); + + return len; +} + +int m2ua_send_msg(WORD sg_id, WORD msg) +{ + BYTE msg_class, msg_type; + WORD len = 0, msg_len; + WORD par_len, par_start = 0; + WORD sid = 0, i; + DWORD dw; + BYTE iid, lk, flag = 0; + //add by yizane + WORD dlci; + //add by yizane + m2ua_msg_t *msg_ptr; + + msg_class = msg >> 8; + msg_type = msg & 0xFF; + +// add by yizane + if (msg == M2UA_MAUP_DATA || + msg == IUA_QPTM_DATA_REQ || msg == IUA_QPTM_UDATA_REQ || + msg == IUA_QPTM_DATA_IND || msg == IUA_QPTM_UDATA_IND ) + msg_ptr = (m2ua_msg_t *)m2ua_sg_info[sg_id].msg; + else + msg_ptr = (m2ua_msg_t *)m2ua_sctp_dat; + + switch (msg_class) + { + case M2UA_MCLASS_MGMT: + switch (msg_type) + { + case ERROR: + dw = htonl(m2ua_sg_info[sg_id].err_code); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_ERR_CODE, (BYTE *)&dw, 4); + len += par_len; + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = ERROR; + len += sizeof(m2ua_comhdr_t); + break; + case NOTIFY: + dw = htonl(m2ua_sg_info[sg_id].status); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATUS, (BYTE *)&dw, 4); + len += par_len; + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = NOTIFY; + len += sizeof(m2ua_comhdr_t); + break; + //add by yizane + case TEI_S_REQ: + case TEI_S_CFM: + case TEI_S_IND: + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + //DLCI + par_start += par_len; + dlci = m2ua_para.lk_para[lk].dlci; + dw = htons(dlci) << 16; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_DLCI, (BYTE *) &dw, 4); + len += par_len; + if(msg_type != TEI_S_REQ) + { + dw = htonl(m2ua_sg_info[sg_id].tei_state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_TEI_STATUS, (BYTE *) &dw, 4); + len += par_len; + } + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MGMT; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + //add by yizane + default: + break; + } + break; + case M2UA_MCLASS_ASPSM: + switch (msg_type) + { + case ASP_UP: + dw = host_ip; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_ASP_IDENTIFIER, (BYTE *)&dw, 4); + len += par_len; + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_UP; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_DOWN: + break; + case HEARTBEAT: + break; + case ASP_UP_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_UP_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_DOWN_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = ASP_DOWN_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case HEARTBEAT_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPSM; + msg_ptr->comhdr.msg_type = HEARTBEAT_ACK; + len = m2ua_sg_info[sg_id].msg_len; + break; + default: + break; + } + break; + case M2UA_MCLASS_ASPTM: + sid = 1; + switch (msg_type) + { + case ASP_ACTIVE: + //dw = htonl(M2UA_TRAFFIC_MODE_LOADSHARE); + dw = htonl(M2UA_TRAFFIC_MODE_OVERRIDE); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_TRAFFIC_MODE, (BYTE *)&dw, 4); + len += par_len; + par_start += par_len; + + for (i = 0; i < M2UA_MAX_LK_NUM; i++) + { + if (m2ua_lk_info[i].enable && (m2ua_para.lk_para[i].lk_sg == sg_id)) + { + dw = htonl(m2ua_para.lk_para[i].iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *)&dw, 4); + len += par_len; + par_start += par_len; + } + } + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_ACTIVE; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_INACTIVE: + break; + case ASP_ACTIVE_ACK: + dw = htonl(M2UA_TRAFFIC_MODE_OVERRIDE); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_TRAFFIC_MODE, (BYTE *)&dw, 4); + len += par_len; + + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_ACTIVE_ACK; + len += sizeof(m2ua_comhdr_t); + break; + case ASP_INACTIVE_ACK: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_ASPTM; + msg_ptr->comhdr.msg_type = ASP_INACTIVE_ACK; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + case M2UA_MCLASS_MAUP: + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + switch (msg_type) + { + case DATA: + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_PROTO_DATA_1, m2ua_sg_info[sg_id].msg + 20, msg_len); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = DATA; + len += sizeof(m2ua_comhdr_t); + + m2ua_csta.sg_csta[sg_id].sg_out_msg++; + m2ua_csta.lk_csta[lk].lk_out_msg++; + m2ua_csta.sg_csta[sg_id].sg_out_bytes += msg_len; + m2ua_csta.lk_csta[lk].lk_out_bytes += msg_len; + err[3]++; + break; + case ESTABLISH_REQ: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = ESTABLISH_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case ESTABLISH_CFM: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = ESTABLISH_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_REQ: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_CFM: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case RELEASE_IND: + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = RELEASE_IND; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_REQ: + dw = htonl(m2ua_sg_info[sg_id].state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATE, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = STATE_REQ; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_CFM: + dw = htonl(m2ua_sg_info[sg_id].state); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_STATE, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = STATE_CFM; + len += sizeof(m2ua_comhdr_t); + break; + case STATE_IND: + break; + case DATA_RETIEVE_REQ: + case DATA_RETIEVE_CFM: + case DATA_RETIEVE_IND: + case DATA_RETIEVE_CMP: + case CONGESTION_IND: + break; + case DATA_ACK: + dw = htonl(m2ua_sg_info[sg_id].cor_id); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_CORRELATION_ID, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = M2UA_MCLASS_MAUP; + msg_ptr->comhdr.msg_type = DATA_ACK; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + //add by yizane + case xUA_MCLASS_QPTM: + lk = m2ua_sg_info[sg_id].iid & 0xFF; + iid = m2ua_para.lk_para[lk].iid; + msg_len = m2ua_sg_info[sg_id].msg_len; + sid = m2ua_lk_info[lk].sid; + dw = htonl(iid); + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + M2UA_PAR_INTERFACE_ID_INT, (BYTE *) &dw, 4); + len += par_len; + //DLCI + par_start += par_len; + dlci = m2ua_para.lk_para[lk].dlci; + dw = htons(dlci) << 16; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_DLCI, (BYTE *) &dw, 4); + len += par_len; + switch (msg_type) + { + case IUA_UDATA_REQ: + case IUA_UDATA_IND: + break; + case IUA_DATA_REQ: + case IUA_DATA_IND: + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_PROTOCOL_DATA, m2ua_sg_info[sg_id].msg + 28, msg_len); + len += par_len; + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + + m2ua_csta.sg_csta[sg_id].sg_out_msg++; + m2ua_csta.lk_csta[lk].lk_out_msg++; + m2ua_csta.sg_csta[sg_id].sg_out_bytes += msg_len; + m2ua_csta.lk_csta[lk].lk_out_bytes += msg_len; + err[3]++; + break; + case IUA_ESTABLISH_REQ: + case IUA_ESTABLISH_CFM: + case IUA_ESTABLISH_IND: + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case IUA_RELEASE_REQ: + case IUA_RELEASE_IND: + dw = htonl(m2ua_sg_info[sg_id].rel_reason); + par_start += par_len; + par_len = m2ua_make_par((m2ua_var_par_t *) &msg_ptr->msg[par_start], + xUA_PAR_REL_REASON, (BYTE *) &dw, 4); + len += par_len; + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + case IUA_RELEASE_CFM: + msg_ptr->comhdr.msg_class = xUA_MCLASS_QPTM; + msg_ptr->comhdr.msg_type = msg_type; + len += sizeof(m2ua_comhdr_t); + break; + default: + break; + } + break; + //add by yizane + default: + break; + } + + if (len == 0) + return 0; + + msg_ptr->comhdr.version = 1; + msg_ptr->comhdr.spare = 0; + msg_ptr->comhdr.len = htonl(len); + + if ((moniter_fg & MONITOR_M2UA) == MONITOR_M2UA) + { + if (m2ua_sg_mon_fg[sg_id] == 1) + { + if (msg_class == M2UA_MCLASS_MAUP) + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, lk=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, lk, sid, len); + else + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, sid, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)msg_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + flag = 1; + } + } + if ((msg_class == M2UA_MCLASS_MAUP ||msg_class == xUA_MCLASS_QPTM) && !flag) + { + if ((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send %s to The Peer, sg=%d, lk=%d, sid=%d, len=%d\n\r", dec_m2ua_msg(msg), sg_id, lk, sid, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)msg_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + +#ifndef _LKSCTP + m2ua_sctp_opt_data.sid_val = sid; + m2ua_sctp_data.buf = (BYTE *)msg_ptr; + m2ua_sctp_optdata_req(m2ua_sg_info[sg_id].fd, sg_id, len); +#else + m2ua_sctp_data.sid = sid; + m2ua_sctp_data.buf = (BYTE *)msg_ptr; + m2ua_sctp_optdata_req_lksctp(m2ua_sg_info[sg_id].fd, sg_id, len); +#endif + + return len; +} + +int m2ua_find_link_by_sg_iid(WORD sg_id, WORD iid) +{ + int i; + lk_para_t *lk_para; + + lk_para = &m2ua_para.lk_para[0]; + + for (i = 0; i < M2UA_MAX_LK_NUM; i++) + { + if (m2ua_lk_info[i].enable && (lk_para->lk_sg == sg_id) && (lk_para->iid == iid)) + return i; + lk_para++; + } + + return -1; +} + +int m2ua_dec_par(WORD sg_id, m2ua_var_par_t *par_ptr, WORD par_type) +{ + WORD len = 0, hdr_len; + DWORD *dw_ptr; + int iid; + + hdr_len = ntohs(par_ptr->hdr.len); + + switch (par_type) + { + case M2UA_PAR_INTERFACE_ID_INT: + if ((par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_INT)) && + (par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_TXT))) + return 0; + else if (par_ptr->hdr.tag != htons(M2UA_PAR_INTERFACE_ID_INT)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_IIT; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + else if (hdr_len % 4) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_PARA_FIELD_ERROR; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + iid = ntohl(*dw_ptr); + if ((iid = m2ua_find_link_by_sg_iid(sg_id, iid)) < 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + else + m2ua_sg_info[sg_id].iid = iid; + len = ((hdr_len + 3) & 0xFFFC); + } + break; + case M2UA_PAR_PROTO_DATA_1: + if (hdr_len <= (M2UA_MAX_MSG_LEN - 2)) + { + m2ua_sg_info[sg_id].msg = &par_ptr->val[0]; + m2ua_sg_info[sg_id].msg_len = hdr_len - sizeof(m2ua_par_hdr_t); + len = (hdr_len + 3) & 0xFFFC; + } + break; + case M2UA_PAR_CORRELATION_ID: + if (par_ptr->hdr.tag != htons(M2UA_PAR_CORRELATION_ID)) + m2ua_sg_info[sg_id].cor_id = 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].cor_id = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + case M2UA_PAR_STATE: + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].state = ntohl(*dw_ptr); + if (m2ua_sg_info[sg_id].state > M2UA_STATUS_CONG_DISCARD) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_PARA_VAL; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else + len = ((hdr_len + 3) & 0xFFFC); + break; + case M2UA_PAR_TRAFFIC_MODE: + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].tra_hdl_mode = ntohl(*dw_ptr); + if (m2ua_sg_info[sg_id].tra_hdl_mode != M2UA_TRAFFIC_MODE_OVERRIDE) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_TRA_HDL_MODE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else + len = ((hdr_len + 3) & 0xFFFC); + break; + //add by yizane + case xUA_PAR_DLCI: + if (par_ptr->hdr.tag != htons(xUA_PAR_DLCI)) + m2ua_sg_info[sg_id].dlci = 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].dlci = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + case xUA_PAR_REL_REASON: + if (par_ptr->hdr.tag != htons(xUA_PAR_REL_REASON)) + m2ua_sg_info[sg_id].rel_reason = 0; + else + { + dw_ptr = (DWORD *) &par_ptr->val[0]; + m2ua_sg_info[sg_id].rel_reason = ntohl(*dw_ptr); + len = ((hdr_len + 3) & 0xFFFC); + } + break; + case xUA_PAR_PROTOCOL_DATA: + if (hdr_len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg_id].msg = &par_ptr->val[0]; + m2ua_sg_info[sg_id].msg_len = hdr_len - sizeof(m2ua_par_hdr_t); + len = (hdr_len + 3) & 0xFFFC; + } + break; + //add by yizane + default: + break; + } + + return len; +} + +int m2ua_dec_msg(WORD sg_id) +{ + BYTE server, m2ua_state, flag = 0; + m2ua_msg_t *msg_ptr; + + WORD msg_sg,msg_len, par_start = 0; + int par_len; + BYTE msg_class, msg_type; + WORD msg = M2UA_CMD_IDLEW; + + WORD iid; + WORD mtp3_msg_len; + DWORD comm_len; + +#ifndef _LKSCTP + msg_len = m2ua_sctp_data.len; +#else + msg_len = m2ua_sctp_dat_len; +#endif + + msg_ptr = (m2ua_msg_t *) m2ua_sctp_dat; + + msg_class = msg_ptr->comhdr.msg_class; + msg_type = msg_ptr->comhdr.msg_type; + comm_len = ntohl(msg_ptr->comhdr.len); + + server = m2ua_para.sg_para[sg_id].server; + m2ua_state = m2ua_sg_info[sg_id].m2ua_state; + + if ((moniter_fg & MONITOR_M2UA) == MONITOR_M2UA) + { + if (m2ua_sg_mon_fg[sg_id] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + flag = 1; + } + } + + if (msg_ptr->comhdr.version != 1) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_VERSION; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + else if (comm_len % 4) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_PARA_FIELD_ERROR; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + err[6]++; + + switch (msg_class) + { + case M2UA_MCLASS_MGMT: + err[7]++; + //add by yizane + if ((msg_type > TEI_S_IND)) + //if ((msg_type != ERROR) && (msg_type != NOTIFY)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else if ((msg_type == NOTIFY) && server) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_PROTOCOL_ERROR; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + else if (msg_type == ERROR) + msg = M2UA_MGMT_ERROR; + break; + case M2UA_MCLASS_ASPSM: + err[8]++; + switch (msg_type) + { + case ASP_UP: + msg = M2UA_ASPSM_ASP_UP; + break; + case ASP_DOWN: + msg = M2UA_ASPSM_ASP_DOWN; + break; + case HEARTBEAT: + m2ua_sg_info[sg_id].msg_len = msg_len; + m2ua_send_msg(sg_id, M2UA_ASPSM_HEARTBEAT_ACK); + break; + case ASP_UP_ACK: + msg = M2UA_ASPSM_ASP_UP_ACK; + break; + case ASP_DOWN_ACK: + msg = M2UA_ASPSM_ASP_DOWN_ACK; + break; + case HEARTBEAT_ACK: + msg = M2UA_ASPSM_HEARTBEAT_ACK; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + case M2UA_MCLASS_ASPTM: + err[9]++; + switch (msg_type) + { + case ASP_ACTIVE: + if (comm_len > sizeof(m2ua_comhdr_t)) + { + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_TRAFFIC_MODE); + if (par_len > 0) + msg = M2UA_ASPTM_ASP_ACTIVE; + } + else + msg = M2UA_ASPTM_ASP_ACTIVE; + break; + case ASP_INACTIVE: + msg = M2UA_ASPTM_ASP_INACTIVE; + break; + case ASP_ACTIVE_ACK: + msg = M2UA_ASPTM_ASP_ACTIVE_ACK; + { + int lk; + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if ((m2ua_para.lk_para[lk].lk_sg == sg_id) && m2ua_lk_info[lk].enable) + m2ua_lk_info[lk].lk_act = 1; + } + } + break; + case ASP_INACTIVE_ACK: + msg = M2UA_ASPTM_ASP_INACTIVE_ACK; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + case M2UA_MCLASS_MAUP: + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=M2UA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_INTERFACE_ID_INT); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + + iid = m2ua_sg_info[sg_id].iid; + msg_sg = m2ua_para.lk_para[iid].lk_sg; + + if ((iid >= M2UA_MAX_LK_NUM) || + (msg_sg != sg_id)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + err[11]++; + + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + switch (msg_type) + { + case DATA: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_PROTO_DATA_1); + if (par_len > 0) + { + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_CORRELATION_ID); + msg = M2UA_MAUP_DATA; + + mtp3_msg_len = m2ua_sg_info[sg_id].msg_len; + m2ua_csta.sg_csta[sg_id].sg_in_msg++; + m2ua_csta.lk_csta[iid].lk_in_msg++; + m2ua_csta.sg_csta[sg_id].sg_in_bytes += mtp3_msg_len; + m2ua_csta.lk_csta[iid].lk_in_bytes += mtp3_msg_len; + err[12]++; + } + break; + case ESTABLISH_REQ: + msg = M2UA_MAUP_ESTABLISH_REQ; + break; + case ESTABLISH_CFM: + msg = M2UA_MAUP_ESTABLISH_CFM; + break; + case RELEASE_REQ: + msg = M2UA_MAUP_RELEASE_REQ; + break; + case RELEASE_CFM: + msg = M2UA_MAUP_RELEASE_CFM; + break; + case RELEASE_IND: + msg = M2UA_MAUP_RELEASE_IND; + break; + case STATE_REQ: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_STATE); + if (par_len) + msg = M2UA_MAUP_STATE_REQ; + break; + case STATE_CFM: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_STATE); + break; + case STATE_IND: + case DATA_ACK: + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + //add by yizane + case xUA_MCLASS_QPTM: + err[10]++; + if (m2ua_state != 3||(m2ua_para.sg_para[sg_id].xUA_ack>>1)!=IUA_APP) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNEXPECTED_MSG; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), M2UA_PAR_INTERFACE_ID_INT); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + + iid = m2ua_sg_info[sg_id].iid; + msg_sg = m2ua_para.lk_para[iid].lk_sg; + + + if ((iid >= M2UA_MAX_LK_NUM) || + (msg_sg != sg_id)) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_INVALID_IID; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + return -1; + } + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_DLCI); + if (par_len <= 0) + { + if (par_len == 0) + { + m2ua_sg_info[sg_id].err_code = M2UA_ERR_MISSING_PARA; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + } + return -1; + } + err[11]++; + + if (((moniter_fg & MONITOR_MAUP) == MONITOR_MAUP) && !flag) + { + if ((m2ua_sg_mon_fg[sg_id] == 1) || (m2ua_lk_mon_fg[iid] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from The Peer, sg=%d, lk=%d, len=%d\n\r", dec_m2ua_msg((msg_class << 8) | msg_type), sg_id, iid, msg_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, msg_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + switch (msg_type) + { + case IUA_DATA_REQ: + case IUA_DATA_IND: + case IUA_UDATA_REQ: + case IUA_UDATA_IND: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_PROTOCOL_DATA); + if (par_len > 0) + { + msg = (xUA_MCLASS_QPTM << 8) + msg_type; + + mtp3_msg_len = m2ua_sg_info[sg_id].msg_len; + m2ua_csta.sg_csta[sg_id].sg_in_msg++; + m2ua_csta.lk_csta[iid].lk_in_msg++; + m2ua_csta.sg_csta[sg_id].sg_in_bytes += mtp3_msg_len; + m2ua_csta.lk_csta[iid].lk_in_bytes += mtp3_msg_len; + err[12]++; + } + break; + case IUA_ESTABLISH_REQ: + msg = IUA_QPTM_ESTABLISH_REQ; + break; + case IUA_ESTABLISH_CFM: + msg = IUA_QPTM_ESTABLISH_CFM; + break; + case IUA_ESTABLISH_IND: + msg = IUA_QPTM_ESTABLISH_IND; + break; + case IUA_RELEASE_REQ: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_REL_REASON); + if (par_len) + msg = IUA_QPTM_RELEASE_REQ; + break; + case IUA_RELEASE_CFM: + par_start += par_len; + par_len = m2ua_dec_par(sg_id, (m2ua_var_par_t *) &(msg_ptr->msg[par_start]), xUA_PAR_REL_REASON); + if (par_len) + msg = IUA_QPTM_RELEASE_CFM; + break; + case IUA_RELEASE_IND: + msg = IUA_QPTM_RELEASE_IND; + break; + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_TYPE; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + break; + //add by yizane + default: + m2ua_sg_info[sg_id].err_code = M2UA_ERR_UNSUPPORTED_MSG_CLASS; + m2ua_send_msg(sg_id, M2UA_MGMT_ERROR); + break; + } + + if (msg != M2UA_CMD_IDLEW) + { + m2ua_sg_info[sg_id].m2ua_cmd = msg; + return 0; + } + else + return -1; +} + +int m2ua_sd_mtp3_primi(BYTE lk, BYTE primi) +{ + m2ua_up_msg_t *up_ptr; + + if (((m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m2ua_mtp3_sd_t) + return -1; + + up_ptr = (m2ua_up_msg_t *) (m2ua_mtp3_sd + x256[m2ua_mtp3_sd_h]); + up_ptr->link = lk; + up_ptr->len = 4; + up_ptr->sio = M2UA_SIO_CMD; + up_ptr->msg.lm.mtp3_ip = 0; + up_ptr->msg.lm.opercode = primi; + + if ((m2ua_lk_info[lk].lk_st == M2UA_LK_UP) && + (m2ua_lk_info[lk].alarm_code != M2UA_ALARM_CODE_NORMAL)) + m2ua_lk_info[lk].alarm_code = M2UA_ALARM_CODE_NORMAL; + up_ptr->msg.lm.alarmcode = m2ua_lk_info[lk].alarm_code; + + m2ua_mtp3_sd_h = (m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[15]++; + + return 0; +} + +int m2ua_sd_mtp3_msg(WORD sg, BYTE lk) +{ + BYTE len, *msg; + m2ua_up_msg_t *up_ptr; + + if (((m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == m2ua_mtp3_sd_t) + return -1; + + len = m2ua_sg_info[sg].msg_len; + msg = m2ua_sg_info[sg].msg; + + up_ptr = (m2ua_up_msg_t *) (m2ua_mtp3_sd + x256[m2ua_mtp3_sd_h]); + up_ptr->link = lk; + up_ptr->len = len; + up_ptr->sio = *msg; + + bcopy(msg + 1, up_ptr->msg.mtp3.content, len); + + m2ua_mtp3_sd_h = (m2ua_mtp3_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[14]++; + + return 1; +} +//add by yizane +int iua_sd_q931_primi(BYTE lk, BYTE primi) +{ + xua_up_msg_t *up_ptr; + + if (((iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == iua_q931_sd_t) + return -1; + + up_ptr = (xua_up_msg_t *) (iua_q931_sd + x256[iua_q931_sd_h]); + up_ptr->msg_class = IUA_MGMT_CMD; + + up_ptr->msg.lm_lk.link = lk; + up_ptr->msg.lm_lk.len = 3; + up_ptr->msg.lm_lk.mtp3_ip = 0; + up_ptr->msg.lm_lk.opercode = primi; + + if ((m2ua_lk_info[lk].lk_st == M2UA_LK_UP) && + (m2ua_lk_info[lk].alarm_code != M2UA_ALARM_CODE_NORMAL)) + m2ua_lk_info[lk].alarm_code = M2UA_ALARM_CODE_NORMAL; + up_ptr->msg.lm_lk.alarmcode = m2ua_lk_info[lk].alarm_code; + + iua_q931_sd_h = (iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[15]++; + + return 0; +} + +int iua_sd_q931_msg(WORD sg, BYTE lk) +{ + BYTE len, *msg; + xua_up_msg_t *up_ptr; + + if (((iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1) == iua_q931_sd_t) + return -1; + + len = m2ua_sg_info[sg].msg_len; + msg = m2ua_sg_info[sg].msg; + + up_ptr = (xua_up_msg_t *) (iua_q931_sd + x256[iua_q931_sd_h]); + up_ptr->msg_class = IUA_QPTM_MSG; + + up_ptr->msg.iua.link = lk; + up_ptr->msg.iua.len = len; + bcopy(msg, up_ptr->msg.iua.content, len); + + iua_q931_sd_h = (iua_q931_sd_h + 1) & M2UA_MAX_M3MSG_NUM_1; + + err[14]++; + + return 1; +} +//add by yizane + + +int m2ua_sg_init(WORD id) +{ + bzero((BYTE *)&m2ua_sg_info[id], sizeof(m2ua_sg_info_t)); + + m2ua_sg_info[id].m2ua_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].sctp_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].mtp3_cmd = M2UA_CMD_IDLEW; + m2ua_sg_info[id].mgmt_cmd = M2UA_CMD_IDLEW; + + return 0; +} + +int m2ua_lk_init(BYTE id) +{ + WORD lk_sg; + + bzero(&m2ua_lk_info[id], sizeof(m2ua_lk_info_t)); + + lk_sg = m2ua_para.lk_para[id].lk_sg; + if (m2ua_sg_info[lk_sg].m2ua_state == 3) + m2ua_lk_info[id].lk_st = M2UA_LK_DOWN; + else + m2ua_lk_info[id].lk_st = M2UA_LK_IDLE; + + return 0; +} + +int enable_sg(WORD sg) +{ + int fd; + + if (m2ua_para.sg_para[sg].enable && + (m2ua_sg_info[sg].fd == 0)) + { +#ifndef _LKSCTP + if ((fd = m2ua_sctp_t_open(sg)) <= 0) + { + m2ua_log_err(sg, "enable sg, open sctp fail!"); + return -1; + } + else + { + m2ua_sg_init(sg); + m2ua_sg_info[sg].fd = fd; + m2ua_sg_info[sg].enable = 1; + } +#else + if (!m2ua_para.sg_para[sg].server) + { + if ((fd = m2ua_sctp_open_lksctp(sg)) <= 0) + { + m2ua_log_err(sg, "enable sg, open sctp fail!"); + return -1; + } + m2ua_sg_init(sg); + m2ua_sg_info[sg].fd = fd; + } + else if (!m2ua_sg_info[sg].enable) + m2ua_sg_init(sg); + m2ua_sg_info[sg].enable = 1; +#endif + } + + return 0; +} + +int rm_sg_lk(WORD sg, BYTE lk) +{ + int fd; + + rel_sid(sg, lk); + + if (--m2ua_sg_info[sg].act_lks == 0) + { + fd = m2ua_sg_info[sg].fd; + if (fd > 0) + { +#ifndef _LKSCTP + if ((m2ua_sg_info[sg].sctp_state > 2) || + ((m2ua_sg_info[sg].sctp_state == 2) && + (m2ua_sg_info[sg].sctp_state_1 > 0))) + m2ua_sctp_discon_req(fd, sg, 0); + m2ua_sctp_close(fd, sg); +#else + if ((m2ua_sg_info[sg].sctp_state > 2) || + ((m2ua_sg_info[sg].sctp_state == 2) && + (m2ua_sg_info[sg].sctp_state_1 > 0))) + m2ua_sctp_discon_req_lksctp(fd, sg, 0); +#endif + } + m2ua_sg_init(sg); + } + + return 0; +} + +int get_m2ua_msg(m2ua_up_msg_t **data_ptr) +{ + m2ua_up_msg_t *up_ptr; + BYTE lk, len; + WORD sg; + + if (m2ua_mtp3_sd_t == m2ua_mtp3_sd_h) + return -1; + + up_ptr = (m2ua_up_msg_t *)(m2ua_mtp3_sd + x256[m2ua_mtp3_sd_t]); + lk = up_ptr->link; + len = up_ptr->len + 2; + sg = m2ua_para.lk_para[lk].lk_sg; + *data_ptr = up_ptr; + + m2ua_mtp3_sd_t = (m2ua_mtp3_sd_t + 1) & M2UA_MAX_M3MSG_NUM_1; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send MSG to MTP3, sg=%d, lk=%d, len=%d\n\r", sg, lk, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)up_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + err[16]++; + + return 0; +} + +int put_m2ua_msg(m2ua_up_msg_t *data_ptr) +{ + BYTE lk, len; + WORD sg; + + lk = data_ptr->link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = data_ptr->len; + err[0]++; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from MTP3, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+2); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+2, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + if (data_ptr->sio == M2UA_MTP3_SIO_CMD) + { + err[1]++; + if ((data_ptr->msg.lm.opercode == M2UA_ENABLE_M2UA_LINK) && + (!m2ua_lk_info[lk].enable)) + { + if (enable_sg(sg) < 0) + return -1; + + m2ua_lk_init(lk); + m2ua_lk_info[lk].enable = 1; + m2ua_sg_info[sg].act_lks++; + } + else if ((data_ptr->msg.lm.opercode == M2UA_STOP_M2UA_LINK) && + m2ua_lk_info[lk].enable) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].mgmt_cmd = M2UA_MGMT_CMD_LK_LOCK; + m2ua_fsm(sg); + } + + rm_sg_lk(sg, lk); + m2ua_lk_init(lk); + + m2ua_lk_info[lk].enable = 0; + } + else if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = data_ptr->msg.lm.opercode; + m2ua_sg_info[sg].iid = lk; + m2ua_fsm(sg); + } + return 0; + } + else if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - 2)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - 18; + m2ua_sg_info[sg].msg_len = len; + m2ua_send_msg(sg, M2UA_MAUP_DATA); + err[4]++; + return 0; + } + } + + return -1; +} + +//add by yizane +int get_xua_msg(BYTE xUA_type, xua_up_msg_t **data_ptr) +{ + xua_up_msg_t *up_ptr; + BYTE lk, len,msg_len; + BYTE *xua_msg_sd; + WORD sg, *xua_sd_h, *xua_sd_t; + + if(data_ptr == NULL) + return -1; + + switch (xUA_type) + { + case M2UA_APP: + return -1;//reserve + xua_msg_sd = m2ua_mtp3_sd; + xua_sd_t = &m2ua_mtp3_sd_t; + xua_sd_h = &m2ua_mtp3_sd_h; + break; + case IUA_APP: + xua_msg_sd = iua_q931_sd; + xua_sd_t = &iua_q931_sd_t; + xua_sd_h = &iua_q931_sd_h; + break; + default: + return -1; + } + if (*xua_sd_t == *xua_sd_h) + return -1; + + up_ptr = (xua_up_msg_t *)(xua_msg_sd + x256[*xua_sd_t]); + lk = up_ptr->msg.lm_lk.link; + len = up_ptr->msg.lm_lk.len; + sg = m2ua_para.lk_para[lk].lk_sg; + *data_ptr = up_ptr; + + *xua_sd_t = (*xua_sd_t + 1) & M2UA_MAX_M3MSG_NUM_1; + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Send MSG to UP LAYER, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)up_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + err[16]++; + msg_len = len+XUAHEADOFFSET; + return msg_len; +} + +int put_xua_msg(xua_up_msg_t *data_ptr) +{ + BYTE lk, len, server; + WORD sg; + if(data_ptr == NULL) + return -1; + + switch (data_ptr->msg_class) + { + case M2UA_MGMT_CMD: + case IUA_MGMT_CMD: + { + lk = data_ptr->msg.lm_lk.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = data_ptr->msg.lm_lk.len; + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from upper layer, sg=%d, lk=%d, len=%d\n\r", sg, lk, len + XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len + XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + + err[1]++; + if ((data_ptr->msg.lm_lk.opercode == xUA_ENABLE_xUA_LINK) && + (!m2ua_lk_info[lk].enable)) + { + if (enable_sg(sg) < 0) + return -1; + + m2ua_lk_init(lk); + m2ua_lk_info[lk].enable = 1; + m2ua_sg_info[sg].act_lks++; + } + else if ((data_ptr->msg.lm_lk.opercode == xUA_STOP_xUA_LINK) && + m2ua_lk_info[lk].enable) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].mgmt_cmd = COMBO_W(data_ptr->msg_class,M2UA_MGMT_CMD_LK_LOCK); + m2ua_fsm(sg); + } + + rm_sg_lk(sg, lk); + m2ua_lk_init(lk); + + m2ua_lk_info[lk].enable = 0; + } + else if ((m2ua_sg_info[sg].m2ua_state == 3) && m2ua_lk_info[lk].enable) + { + m2ua_sg_info[sg].mtp3_cmd = COMBO_W(data_ptr->msg_class,data_ptr->msg.lm_lk.opercode); + m2ua_sg_info[sg].iid = lk; + m2ua_fsm(sg); + } + return 0; + } + case IUA_QPTM_MSG: + { + lk = data_ptr->msg.iua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = data_ptr->msg.iua.len; + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Q931, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - RESERVE_FOR_IUAHEAD; + m2ua_sg_info[sg].msg_len = len; + server = m2ua_para.sg_para[sg].server; + if(server) + m2ua_send_msg(sg, IUA_QPTM_DATA_IND); + else + m2ua_send_msg(sg, IUA_QPTM_DATA_REQ); + err[4]++; + return 0; + } + } + break; + } + case M2UA_MAUP_MSG: + { + lk = data_ptr->msg.m2ua.link; + sg = m2ua_para.lk_para[lk].lk_sg; + len = data_ptr->msg.m2ua.len; + err[0]++; + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[lk] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MSG from Q931, sg=%d, lk=%d, len=%d\n\r", sg, lk, len+XUAHEADOFFSET); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)data_ptr, len+XUAHEADOFFSET, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + if (m2ua_para.lk_para[lk].enable == 0) + return -1; + if (m2ua_para.sg_para[sg].enable == 0) + return -1; + if (m2ua_lk_info[lk].lk_st == M2UA_LK_UP) + { + err[2]++; + if (len <= (M2UA_MAX_MSG_LEN - XUAHEADOFFSET)) + { + m2ua_sg_info[sg].iid = lk; + m2ua_sg_info[sg].msg = (BYTE *)data_ptr - RESERVE_FOR_M2UAHEAD; + m2ua_sg_info[sg].msg_len = len; + m2ua_send_msg(sg, M2UA_MAUP_DATA); + err[4]++; + return 0; + } + } + break; + } + default: + return -1; + } + return -1; +} +//add by yizane + +int set_m2ua_link(BYTE link, BYTE *data_ptr) +{ + BYTE len; + WORD sg; + m2ua_lk_pro_t *m2ua_lk_pro = (m2ua_lk_pro_t *)data_ptr; + lk_para_t *lk_ptr; + + lk_ptr = (lk_para_t *) &m2ua_para.lk_para[link]; + sg = lk_ptr->lk_sg; + len = sizeof(m2ua_lk_pro_t); + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if ((m2ua_sg_mon_fg[sg] == 1) || (m2ua_lk_mon_fg[link] == 1)) + { + sprintf(m2ua_ascitemp_buf, "Recv MTP3 Set Link Attributes, sg=%d, lk=%d, len=%d\n\r", sg, link, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii((BYTE *)m2ua_lk_pro, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + /* + if (init_flag < 2) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + if (link == 255) + init_flag++; + } + else + */ + { + if (lk_ptr->enable) + { + if (m2ua_lk_pro->e1_lk_type & 0x01) // Bit 0: Link enable status, 0/1=disable/enable + return -1; + //else if (m2ua_lk_pro->e1_to_sg != sg) + //return -1; + } + + /* + if (m2ua_lk_pro->e1_to_sg != sg) + { + if (!((m2ua_para.sg_para[sg].enable == 0) && + (m2ua_para.sg_para[m2ua_lk_pro->e1_to_sg].enable == 0))) + return -1; + if (((m2ua_lk_pro->e1_lk_type & 0x07) == 0x03) && // SIGTRAN | ENABLE | NOT MTP3LITE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip) || + (m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + } + if (m2ua_lk_info[link].enable == 1) + { + rm_sg_lk(sg, link); + m2ua_lk_info[link].enable = 0; + } + } + else + { + if (((m2ua_lk_pro->e1_lk_type & 0x07) == 0x03) && // SIGTRAN | ENABLE | NOT MTP3LITE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip) || + (m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + { + lk_ptr->enable = (m2ua_lk_pro->e1_lk_type >> 1) & 0x01; + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + } + } + */ + } + + sg = lk_ptr->lk_sg; + + if (m2ua_lk_info[link].enable == 0) + { + if ( (((m2ua_lk_pro->e1_lk_type & 0x0F) == 0x03) && // SIGTRAN | ENABLE + ((m2ua_lk_pro->e1_to_mtp3 == host_ip)||(m2ua_lk_pro->e1_to_alterMTP3 == host_ip)) && + (m2ua_lk_pro->e1_to_linkset < M2UA_MTP3_MAX_LS_NUM)) + || ((m2ua_lk_pro->e1_lk_type & 0x0F) == 0x07)) //No ss7 | ENABLE + { + // Bit 1-3: Link type, 0/1/2: non-sigtran/sigtran/mtp3lite + + lk_ptr->enable = 1; + lk_ptr->iid = m2ua_lk_pro->e1_to_iid; + lk_ptr->dlci = 0; + + if(link < 128) + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg; + else + lk_ptr->lk_sg = m2ua_lk_pro->e1_to_sg + M2UA_MAX_SG_NUM/2; + //if (enable_sg(sg) < 0) + //return -1; + + m2ua_lk_init(link); + //m2ua_lk_info[link].enable = 1; + //m2ua_sg_info[sg].act_lks++; + } + else if (lk_ptr->enable) + { + lk_ptr->enable = 0; + lk_ptr->lk_sg = 0; + lk_ptr->iid = 0; + lk_ptr->dlci = 0; + } + } + else + { + if ((((m2ua_lk_pro->e1_lk_type & 0x0F) != 0x03) || + ((m2ua_lk_pro->e1_to_mtp3 != host_ip) && (m2ua_lk_pro->e1_to_alterMTP3 != host_ip)) || + (m2ua_lk_pro->e1_to_linkset >= M2UA_MTP3_MAX_LS_NUM)) + && ((m2ua_lk_pro->e1_lk_type & 0x0F) != 0x07)) + { + if (m2ua_sg_info[sg].m2ua_state == 3) + { + m2ua_sg_info[sg].iid = link; + m2ua_sg_info[sg].mgmt_cmd = M2UA_MGMT_CMD_LK_LOCK; + m2ua_fsm(sg); + } + + rm_sg_lk(sg, link); + m2ua_lk_init(link); + + lk_ptr->enable = 0; + lk_ptr->lk_sg = 0; + lk_ptr->iid = 0; + lk_ptr->dlci = 0; + } + } + + return len; +} + +int set_m2ua_sg(WORD sg, BYTE *data_ptr) +{ + BYTE len; + sg_para_t *sg_ptr; + + len = sizeof(sg_para_t); + + if ((moniter_fg & MONITOR_MTP3) == MONITOR_MTP3) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv MTP3 Set SG Attributes, sg=%d, len=%d\n\r", sg, len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(data_ptr, len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + /* + if (init_flag < 2) + { + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if (sg == 255) + init_flag++; + } + else + */ + { + sg_ptr = (sg_para_t *) data_ptr; + + if (m2ua_para.sg_para[sg].enable && + m2ua_para.sg_para[sg+M2UA_MAX_SG_NUM/2].enable) + { + if (sg_ptr->enable) + return -1; +// else if ((sg_ptr->server != m2ua_para.sg_para[sg].server) || +// (sg_ptr->ip != m2ua_para.sg_para[sg].ip)) + else + { + if (((m2ua_sg_info[sg].enable == 0) ||(m2ua_sg_info[sg].fd == 0)) && + !((m2ua_sg_info[sg].sctp_state == 3) && (m2ua_sg_info[sg].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + m2ua_para.sg_para[sg].enable = 0; + else + m2ua_para.sg_para[sg].enable = 2; + + sg = sg + M2UA_MAX_SG_NUM/2; + if (((m2ua_sg_info[sg].enable == 0) ||(m2ua_sg_info[sg].fd == 0)) && + !((m2ua_sg_info[sg].sctp_state == 3) && (m2ua_sg_info[sg].sctp_state_1 == 1))) // Not Client at sctp 3-1 state + m2ua_para.sg_para[sg].enable = 0; + else + m2ua_para.sg_para[sg].enable = 2; + return len; + } + } + + /* + if ((sg_ptr->server != m2ua_para.sg_para[sg].server) || + (sg_ptr->ip != m2ua_para.sg_para[sg].ip)) + m2ua_para.sg_para[sg].enable = 2; + else if (sg_ptr->enable >= 1) + m2ua_para.sg_para[sg].enable = 1; + else + m2ua_para.sg_para[sg].enable = 0; + bcopy(data_ptr + 1, (BYTE *) &m2ua_para.sg_para[sg] + 1, len - 1); + */ + + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M2UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M2UA_PORT_0; + else + m2ua_para.sg_para[sg].plat_port[0] = IUA_PORT_0; + + sg = sg + M2UA_MAX_SG_NUM/2; + bcopy(data_ptr, (BYTE *) &m2ua_para.sg_para[sg], len); + if ((m2ua_para.sg_para[sg].xUA_ack>>1) == M2UA_APP) + m2ua_para.sg_para[sg].plat_port[0] = M2UA_PORT_1; + else + m2ua_para.sg_para[sg].plat_port[0] = IUA_PORT_1; + } + + return len; +} + +int m2ua_sctp_close(int fd, WORD sg_id) +{ + int ret; + + if ((ret = close(fd)) < 0) + m2ua_log_err(sg_id, "ERROR: M2UA SCTP close!"); + + return ret; +} + +#ifndef _LKSCTP + +int m2ua_sctp_get_msg(int fd, WORD sg) +{ + int ret; + int flags = 0; + BYTE err_text[128]; + //BYTE in_b; + + m2ua_sctp_data.buf = m2ua_sctp_dat; + + //in_b = inb(0x378); + //outb(in_b | 0x02, 0x378); + //20 us + + while ((ret = getmsg(fd, &m2ua_sctp_ctrl, &m2ua_sctp_data, &flags)) < 0) + { + switch (errno) + { + default: + case EPROTO: + case EINVAL: + sprintf(err_text, "ERROR: M2UA SCTP getmsg: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + case EINTR: + case ERESTART: + continue; + case EAGAIN: + break; + } + break; + } + + //outb(in_b & 0xFD, 0x378); + + if (!ret) + return (m2ua_sctp_cmd.tpi.type); + else + return (-1); +} + +char *dec_sctp_primi(long sctp_primi) +{ + switch (sctp_primi) + { + case T_CONN_REQ: return("T_CONN_REQ"); + case T_CONN_RES: return("T_CONN_RES"); + case T_DISCON_REQ: return("T_DISCON_REQ"); + case T_DATA_REQ: return("T_DATA_REQ"); + case T_EXDATA_REQ: return("T_EXDATA_REQ"); + case T_OPTDATA_REQ: return("T_OPTDATA_REQ"); + case T_INFO_REQ: return("T_INFO_REQ"); + case T_BIND_REQ: return("T_BIND_REQ"); + case T_UNBIND_REQ: return("T_UNBIND_REQ"); + case T_UNITDATA_REQ: return("T_UNITDATA_REQ"); + case T_OPTMGMT_REQ: return("T_OPTMGMT_REQ"); + case T_ORDREL_REQ: return("T_ORDREL_REQ"); + case T_CONN_IND: return("T_CONN_IND"); + case T_CONN_CON: return("T_CONN_CON"); + case T_DISCON_IND: return("T_DISCON_IND"); + case T_DATA_IND: return("T_DATA_IND"); + case T_EXDATA_IND: return("T_EXDATA_IND"); + case T_OPTDATA_IND: return("T_OPTDATA_IND"); + case T_INFO_ACK: return("T_INFO_ACK"); + case T_BIND_ACK: return("T_BIND_ACK"); + case T_ERROR_ACK: return("T_ERROR_ACK"); + case T_OK_ACK: return("T_OK_ACK"); + case T_UNITDATA_IND: return("T_UNITDATA_IND"); + case T_UDERROR_IND: return("T_UDERROR_IND"); + case T_OPTMGMT_ACK: return("T_OPTMGMT_ACK"); + case T_ORDREL_IND: return("T_ORDREL_IND"); + case T_ADDR_REQ: return("T_ADDR_REQ"); + case T_ADDR_ACK: return("T_ADDR_ACK"); + default: return("Unexpected"); + } +} + +char *dec_sctp_err(long sctp_err) +{ + switch (sctp_err) + { + case TBADADDR: return("TBADADDR"); + case TBADOPT: return("TBADOPT"); + case TACCES: return("TACCES"); + case TBADF: return("TBADF"); + case TNOADDR: return("TNOADDR"); + case TOUTSTATE: return("TOUTSTATE"); + case TBADSEQ: return("TBADSEQ"); + case TSYSERR: return("TSYSERR"); + case TLOOK: return("TLOOK"); + case TBADDATA: return("TBADDATA"); + case TBUFOVFLW: return("TBUFOVFLW"); + case TFLOW: return("TFLOW"); + case TNODATA: return("TNODATA"); + case TNODIS: return("TNODIS"); + case TNOUDERR: return("TNOUDERR"); + case TBADFLAG: return("TBADFLAG"); + case TNOREL: return("TNOREL"); + case TNOTSUPPORT: return("TNOTSUPPORT"); + case TSTATECHNG: return("TSTATECHNG"); + case TNOSTRUCTYPE: return("TNOSTRUCTTYPE"); + case TBADNAME: return("TBADNAME"); + case TBADQLEN: return("TBADQLEN"); + case TADDRBUSY: return("TADDRBUSY"); + case TINDOUT: return("TINDOUT"); + case TPROVMISMATCH: return("TPROVMISMATCH"); + case TRESQLEN: return("TRESQLEN"); + case TRESADDR: return("TRESADDR"); + case TQFULL: return("TQFULL"); + case TPROTO: return("TPROTO"); + default: return("(unknown)"); + } +} + +int expect(int fd, int sg, int *msg, int want) +{ + int got; + + got = m2ua_sctp_get_msg(fd, sg); + *msg = got; + + if (got >= 0) + { + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + if (m2ua_sctp_cmd.tpi.type == T_ERROR_ACK) + { + sprintf(m2ua_ascitemp_buf, "Error Code: %s\n\r", dec_sctp_err(m2ua_sctp_cmd.tpi.error_ack.TLI_error)); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (m2ua_sctp_data.len > 0) + { + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Data len=%d\n\r", m2ua_sctp_data.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_data.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + } + + if (got == want) + return M2UA_SUCCESS; + else + return M2UA_FAILURE; +} + +int m2ua_sctp_put_msg(int fd, int sg) +{ + int ret; + struct strbuf *mydata = m2ua_sctp_data.len ? &m2ua_sctp_data : NULL; + BYTE err_text[128]; + //BYTE in_b; + + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Send %s to SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + + if (m2ua_sctp_data.len > 0) + { + sprintf(m2ua_ascitemp_buf, "Data len=%d\n\r", m2ua_sctp_data.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_data.buf, m2ua_sctp_data.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + + //in_b = inb(0x378); + //outb(in_b | 0x04, 0x378); + //88 us + + while ((ret = putpmsg(fd, &m2ua_sctp_ctrl, mydata, 0, MSG_HIPRI)) < 0) + { + switch (errno) + { + default: + sprintf(err_text, "ERROR: M2UA SCTP putpmsg: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + break; + case EINTR: + case ERESTART: + continue; + case EAGAIN: + printf("m2ua put msg EAGAIN\n"); + break; + } + break; + } + + //outb(in_b & 0xFB, 0x378); + + if (!ret) + return(0); + else + return(-1); +} + +int m2ua_sctp_put_fdi(int fd, int fd2, int sg, int offset, int flags) +{ + BYTE err_text[256]; + + m2ua_sctp_fdi.flags = flags; + m2ua_sctp_fdi.fildes = fd2; + m2ua_sctp_fdi.offset = offset; + + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + if (m2ua_sg_mon_fg[sg] == 1) + { + sprintf(m2ua_ascitemp_buf, "Send %s to SCTP, sg=%d, ctrl len=%d\n\r", dec_sctp_primi(m2ua_sctp_cmd.tpi.type), sg, m2ua_sctp_ctrl.len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_cmd.cbuf, m2ua_sctp_ctrl.len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + if (ioctl(fd, I_FDINSERT, &m2ua_sctp_fdi) < 0) + { + sprintf(err_text, "ERROR: M2UA SCTP ioctl: [%d] %s", errno, strerror(errno)); + m2ua_log_err(sg, err_text); + } + + return(0); +} + +int m2ua_sctp_t_open(WORD sg) +{ + int fd; + + if ((fd = open("/dev/sctp_t",O_NONBLOCK|O_RDWR)) < 0) + m2ua_log_err(sg, "ERROR: M2UA SCTP open"); + + return fd; +} + +int m2ua_sctp_optmgmt_req(int fd, int sg, DWORD flags) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.optmgmt_req) + sizeof(m2ua_sctp_opt_optm); + m2ua_sctp_cmd.tpi.type = T_OPTMGMT_REQ; + m2ua_sctp_cmd.tpi.optmgmt_req.MGMT_flags = flags; + m2ua_sctp_cmd.tpi.optmgmt_req.OPT_length = sizeof(m2ua_sctp_opt_optm); + m2ua_sctp_cmd.tpi.optmgmt_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.optmgmt_req); + //add by yizane + m2ua_sctp_opt_optm.ppi_val = m2ua_para.sg_para[sg].xUA_ack>>1; + bcopy(&m2ua_sctp_opt_optm, (m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.optmgmt_req)), sizeof(m2ua_sctp_opt_optm)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_bind_req(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.bind_req) + sizeof(*addr); + m2ua_sctp_cmd.tpi.type = T_BIND_REQ; + m2ua_sctp_cmd.tpi.bind_req.ADDR_length = sizeof(*addr); + m2ua_sctp_cmd.tpi.bind_req.ADDR_offset = sizeof(m2ua_sctp_cmd.tpi.bind_req); + m2ua_sctp_cmd.tpi.bind_req.CONIND_number = coninds; + bcopy(addr, (&m2ua_sctp_cmd.tpi.bind_req) + 1, sizeof(*addr)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_conn_req(int fd, int sg, m2ua_sctp_addr_t *addr) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.conn_req)+sizeof(*addr); + m2ua_sctp_cmd.tpi.type = T_CONN_REQ; + m2ua_sctp_cmd.tpi.conn_req.DEST_length = sizeof(*addr); + m2ua_sctp_cmd.tpi.conn_req.DEST_offset = sizeof(m2ua_sctp_cmd.tpi.conn_req); + m2ua_sctp_cmd.tpi.conn_req.OPT_length = 0; + m2ua_sctp_cmd.tpi.conn_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.conn_req)+sizeof(*addr); + bcopy(addr, (m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.conn_req)), sizeof(*addr)); + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_conn_res(int fd, int fd2, int sg, long seq) +{ + m2ua_sctp_fdi.databuf.len = 0; + m2ua_sctp_fdi.ctlbuf.len = sizeof(m2ua_sctp_cmd.tpi.conn_res); + m2ua_sctp_cmd.tpi.type = T_CONN_RES; + m2ua_sctp_cmd.tpi.conn_res.ACCEPTOR_id = 0; + m2ua_sctp_cmd.tpi.conn_res.SEQ_number = seq; + m2ua_sctp_cmd.tpi.conn_res.OPT_offset = 0; + m2ua_sctp_cmd.tpi.conn_res.OPT_length = 0; + return m2ua_sctp_put_fdi(fd, fd2, sg, 4, 0); +} + +int m2ua_sctp_discon_req(int fd, int sg, DWORD seq) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.discon_req); + m2ua_sctp_cmd.tpi.type = T_DISCON_REQ; + m2ua_sctp_cmd.tpi.discon_req.SEQ_number = seq; + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_ordrel_req(int fd, int sg) +{ + m2ua_sctp_data.len = 0; + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.ordrel_req); + m2ua_sctp_cmd.tpi.type = T_ORDREL_REQ; + return m2ua_sctp_put_msg(fd, sg); +} + +int m2ua_sctp_optdata_req(int fd, int sg, BYTE len) +{ + if (!len) + return (-1); + else + m2ua_sctp_data.len = len; + + m2ua_sctp_ctrl.len = sizeof(m2ua_sctp_cmd.tpi.optdata_req) + sizeof(m2ua_sctp_opt_data); + m2ua_sctp_cmd.tpi.type = T_OPTDATA_REQ; + m2ua_sctp_cmd.tpi.optdata_req.DATA_flag = 0; + m2ua_sctp_cmd.tpi.optdata_req.OPT_length = sizeof(m2ua_sctp_opt_data); + m2ua_sctp_cmd.tpi.optdata_req.OPT_offset = sizeof(m2ua_sctp_cmd.tpi.optdata_req); + bcopy(&m2ua_sctp_opt_data, m2ua_sctp_cmd.cbuf + sizeof(m2ua_sctp_cmd.tpi.optdata_req), sizeof(m2ua_sctp_opt_data)); + return m2ua_sctp_put_msg(fd, sg); +} + +#else + +char *dec_sctp_primi_lksctp(long sctp_primi) +{ + switch (sctp_primi) + { + case M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP: return("M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP"); + case M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST: return("M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST"); + case M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP: return("M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP"); + case M2UA_LKSCTP_ASSOC_CHANGE_RESTART: return("M2UA_LKSCTP_ASSOC_CHANGE_RESTART"); + case M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC: return("M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC"); + case M2UA_LKSCTP_SEND_FAILED: return("M2UA_LKSCTP_SEND_FAILED"); + case M2UA_LKSCTP_PEER_ADDR_CHANGE: return("M2UA_LKSCTP_PEER_ADDR_CHANGE"); + case M2UA_LKSCTP_REMOTE_ERROR: return("M2UA_LKSCTP_REMOTE_ERROR"); + case M2UA_LKSCTP_SHUTDOWN_EVENT: return("M2UA_LKSCTP_SHUTDOWN_EVENT"); + case M2UA_LKSCTP_DATA_IND: return("M2UA_LKSCTP_DATA_IND"); + case M2UA_LKSCTP_UNKNOWN_EVENT: return("M2UA_LKSCTP_UNKNOWN_EVENT"); + default: return("Unexpected"); + } +} + +int m2ua_sctp_optmgmt_req_lksctp(int fd, int sg) +{ + struct linger lg; + struct sctp_event_subscribe event; + struct sctp_initmsg initopt; + struct sctp_rtoinfo rtoinfo; + struct sctp_assocparams assocparams; + + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) + { + m2ua_log_err(sg, "M2UA set nonblock failure!"); + return 0; + } + + lg.l_onoff = 1; + lg.l_linger = 0; + + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lg, sizeof(lg)) != 0) + { + m2ua_log_err(sg, "set linger failed!"); + //return 0; + } + + if ((sg >= M2UA_MAX_SG_NUM) || + ((sg < M2UA_MAX_SG_NUM) && !m2ua_para.sg_para[sg].server)) + { + // Enable all events + event.sctp_data_io_event = 1; + event.sctp_association_event = 1; + event.sctp_address_event = 1; + event.sctp_send_failure_event = 1; + event.sctp_peer_error_event = 1; + event.sctp_shutdown_event = 1; + event.sctp_partial_delivery_event = 1; + event.sctp_adaption_layer_event = 1; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) + { + m2ua_log_err(sg, "set event failed!"); + return 0; + } + + initopt.sinit_num_ostreams = 257; + initopt.sinit_max_instreams = 257; + initopt.sinit_max_attempts = 8; + initopt.sinit_max_init_timeo = 0; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initopt, sizeof(initopt)) != 0) + { + m2ua_log_err(sg, "set initopt failed!"); + return 0; + } + + rtoinfo.srto_assoc_id = 0; + rtoinfo.srto_initial = 1000; + rtoinfo.srto_max = 5000; + rtoinfo.srto_min = 1000; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo)) != 0) + { + m2ua_log_err(sg, "set rtoinfo failed!"); + //return 0; + } + + memset((BYTE *)&assocparams, 0, sizeof(assocparams)); + assocparams.sasoc_asocmaxrxt = 5; + if (setsockopt(fd, IPPROTO_SCTP, SCTP_ASSOCINFO, &assocparams, sizeof(assocparams)) != 0) + { + m2ua_log_err(sg, "set assocparams failed!"); + //return 0; + } + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_optmgmt_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 1; +} + +int m2ua_sctp_optmgmt_req_lksctp_ext(int fd, int sg) +{ + struct sctp_paddrparams paddrparams; + struct sockaddr_in *paddr; + + if (sg < M2UA_MAX_SG_NUM) + { + memset((BYTE *)&paddrparams, 0, sizeof(paddrparams)); + paddr = (struct sockaddr_in *)&paddrparams.spp_address; + paddr->sin_family = AF_INET; + if (m2ua_para.sg_para[sg].server) + paddr->sin_port = m2ua_sg_info[sg].rem_port; + else + paddr->sin_port = htons(2904); + paddr->sin_addr.s_addr = m2ua_para.sg_para[sg].ip; + paddrparams.spp_hbinterval = 20000; + paddrparams.spp_pathmaxrxt = 5; + + if (setsockopt(fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &paddrparams, sizeof(paddrparams)) != 0) + { + m2ua_log_err(sg, "set paddrparams failed!"); + //return 0; + } + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_optmgmt_req_lksctp_ext succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 1; +} + +int m2ua_sctp_bind_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds) +{ + struct sockaddr_in sin[1]; + + sin->sin_family = AF_INET; + sin->sin_port = addr->port; + sin->sin_addr.s_addr = addr->addr.s_addr; + + if (bind(fd, (struct sockaddr *)sin, sizeof (*sin)) == -1) + { + m2ua_log_err(sg, "bind failed!"); + return 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_bind_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + if (coninds) + { + if (listen(fd, 1) == -1) + { + m2ua_log_err(sg, "listen failed!"); + return 0; + } + if ((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_listen_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + } + + return 1; +} + +int m2ua_sctp_open_lksctp(WORD sg) +{ + int fd; + + if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) == -1) + m2ua_log_err(sg, "M2UA lksctp open failure!"); + + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) + { + m2ua_log_err(sg, "M2UA set nonblock failure!"); + return 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_open_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return fd; +} + +int m2ua_sctp_conn_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr) +{ + struct sockaddr_in sin[1]; + + sin->sin_family = AF_INET; + sin->sin_port = addr->port; + sin->sin_addr.s_addr = addr->addr.s_addr; + + connect(fd, (struct sockaddr *)sin, sizeof(sin)); + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_conn_req_lksctp sent, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + return 0; +} + +int m2ua_handle_event_lksctp(void *buf) +{ + struct sctp_assoc_change *sac; + //struct sctp_send_failed *ssf; + //struct sctp_paddr_change *spc; + //struct sctp_remote_error *sre; + union sctp_notification *snp; + //char addrbuf[8]; + //const char *ap; + //struct sockaddr_in *sin; + + snp = buf; + + switch (snp->sn_header.sn_type) + { + case SCTP_ASSOC_CHANGE: + sac = &snp->sn_assoc_change; + //printf("^^^ assoc_change: state=%hu, error=%hu, instr=%hu " + // "outstr=%hu\n", sac->sac_state, sac->sac_error, + // sac->sac_inbound_streams, sac->sac_outbound_streams); + return ((SCTP_ASSOC_CHANGE << 16) | (sac->sac_state & 0xFFFF)); + case SCTP_SEND_FAILED: + //ssf = &snp->sn_send_failed; + //printf("^^^ sendfailed: len=%hu err=%d\n", ssf->ssf_length, + // ssf->ssf_error); + return M2UA_LKSCTP_SEND_FAILED; + case SCTP_PEER_ADDR_CHANGE: + //spc = &snp->sn_paddr_change; + //if (spc->spc_aaddr.ss_family == AF_INET) { + // sin = (struct sockaddr_in *)&spc->spc_aaddr; + // ap = inet_ntop(AF_INET, &sin->sin_addr, + // addrbuf, 8); + //} + //printf("^^^ intf_change: %s state=%d, error=%d\n", ap, + // spc->spc_state, spc->spc_error); + return M2UA_LKSCTP_PEER_ADDR_CHANGE; + case SCTP_REMOTE_ERROR: + //sre = &snp->sn_remote_error; + //printf("^^^ remote_error: err=%hu len=%hu\n", + // ntohs(sre->sre_error), ntohs(sre->sre_length)); + return M2UA_LKSCTP_REMOTE_ERROR; + case SCTP_SHUTDOWN_EVENT: + //printf("^^^ shutdown event\n"); + return M2UA_LKSCTP_SHUTDOWN_EVENT; + default: + //printf("unknown type: %hu\n", snp->sn_header.sn_type); + return M2UA_LKSCTP_UNKNOWN_EVENT; + } + + return -1; +} + +void *m2ua_recvmsg_lksctp(WORD sg, int fd, struct msghdr *msg, void *data_buf, int *data_len, int cmsglen) +{ + int nr = 0, nnr = 0; + struct iovec iov[1]; + //BYTE tmp_buf[M2UA_SCTP_DAT_BUFSIZE]; + + *data_len = 0; + iov->iov_base = data_buf; + iov->iov_len = M2UA_SCTP_DAT_BUFSIZE; + + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + //for (;;) + { +#ifndef MSG_XPG4_2 +#define MSG_XPG4_2 0 +#endif + msg->msg_flags = MSG_XPG4_2; + msg->msg_controllen = cmsglen; + + nnr = recvmsg(fd, msg, 0); + if (nnr <= 0) + { + /* EOF or error */ + *data_len = nr; + return (NULL); + } + nr += nnr; + + if ((msg->msg_flags & MSG_EOR) != 0) + { + *data_len = nr; + return (data_buf); + } + + //iov->iov_base = tmp_buf; + //iov->iov_len = M2UA_SCTP_DAT_BUFSIZE; + } + + m2ua_log_err(sg, "m2ua_recvmsg_lksctp MSG_EOR flag not set!"); + + return (NULL); +} + +int m2ua_sctp_get_msg_lksctp(int fd, WORD sg) +{ + int ret = -1; + //BYTE in_b; + struct sctp_sndrcvinfo *sri; + struct msghdr msg[1]; + struct cmsghdr *cmsg; + BYTE *cbuf; + BYTE *dbuf; + int cmsglen = sizeof(*cmsg) + sizeof(*sri); + + //in_b = inb(0x378); + //outb(in_b | 0x02, 0x378); + + /* Set up the msghdr structure for receiving */ + memset(msg, 0, sizeof (*msg)); + cbuf = m2ua_sctp_cmd.cbuf; + dbuf = m2ua_sctp_dat; + msg->msg_control = cbuf; + msg->msg_controllen = cmsglen; + msg->msg_flags = 0; + cmsg = (struct cmsghdr *)cbuf; + sri = (struct sctp_sndrcvinfo *)(cmsg + 1); + m2ua_sctp_dat_len = M2UA_SCTP_DAT_BUFSIZE; + + if ((dbuf = m2ua_recvmsg_lksctp(sg, fd, msg, dbuf, &m2ua_sctp_dat_len, cmsglen)) > 0) + { + /* Intercept notifications here */ + if (msg->msg_flags & MSG_NOTIFICATION) + ret = m2ua_handle_event_lksctp(dbuf); + else + ret = M2UA_LKSCTP_DATA_IND; + } + + //outb(in_b & 0xFD, 0x378); + + return ret; +} + +int expect_lksctp(int fd, int sg, int *msg, int want) +{ + int got; + + *msg = got = m2ua_sctp_get_msg_lksctp(fd, sg); + + if (got != -1) + { + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + if (m2ua_sctp_dat_len > 0) + { + sprintf(m2ua_ascitemp_buf, "Recv %s from SCTP, sg=%d, data len=%d\n\r", dec_sctp_primi_lksctp(got), sg, m2ua_sctp_dat_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_dat_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + } + + if (got == want) + return M2UA_SUCCESS; + else + return M2UA_FAILURE; +} + +int m2ua_sctp_discon_req_lksctp(int fd, int sg, int flag) +{ + BYTE enable1, enable2, server; + WORD lk; + + m2ua_sctp_close(fd, sg); + if (sg < M2UA_MAX_SG_NUM) + { + //enable1 = m2ua_sg_info[sg].enable; + //m2ua_sg_init(sg); + //m2ua_sg_info[sg].enable = enable1; + m2ua_sg_info[sg].fd = 0; + } + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + sprintf(m2ua_ascitemp_buf, "m2ua_sctp_discon_req_lksctp succeed, sg=%d, fd=%d\n\r", sg, fd); + m2ua_asciout_proc(m2ua_ascitemp_buf); + } + + if ((flag == 0) || (sg >= M2UA_MAX_SG_NUM)) + return 0; + + enable1 = m2ua_sg_info[sg].enable; + enable2 = m2ua_para.sg_para[sg].enable; + server = m2ua_para.sg_para[sg].server; + + if (!server && enable1 && (enable2 == 1)) + { + if ((fd = m2ua_sctp_open_lksctp(sg)) <= 0) + { + m2ua_sg_info[sg].enable = 0; + for (lk = 0; lk < M2UA_MAX_LK_NUM; lk++) + { + if(m2ua_para.lk_para[lk].lk_sg == sg) + m2ua_lk_info[lk].enable = 0; + } + m2ua_log_err(sg, "M2UA lksctp open failure!"); + } + else + m2ua_sg_info[sg].fd = fd; + } + + return 1; +} + +int m2ua_sctp_put_msg_lksctp(int fd, int sg) +{ + //BYTE err_text[128]; + //BYTE in_b; + BYTE ppid; + struct sctp_sndrcvinfo *sri; + struct msghdr msg[1]; + struct cmsghdr *cmsg; + struct iovec iov[1]; + int cmsglen = sizeof(*cmsg) + sizeof(*sri); + int ret; + + if (((moniter_fg & MONITOR_SCTP) == MONITOR_SCTP) && + (m2ua_sg_mon_fg[sg] == 1)) + { + if (m2ua_sctp_dat_len > 0) + { + sprintf(m2ua_ascitemp_buf, "Send M2UA_LKSCTP_DATA to SCTP, sg=%d, data len=%d\n\r", sg, m2ua_sctp_dat_len); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_hex_to_ascii(m2ua_sctp_dat, m2ua_sctp_dat_len, m2ua_ascitemp_buf); + m2ua_asciout_proc(m2ua_ascitemp_buf); + m2ua_asciout_proc("\n\r"); + } + } + + //in_b = inb(0x378); + //outb(in_b | 0x04, 0x378); + //88 us + + /* Set up the msghdr structure for receiving */ + memset(msg, 0, sizeof (*msg)); + + iov->iov_base = m2ua_sctp_data.buf; + iov->iov_len = m2ua_sctp_data.len; + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + msg->msg_control = m2ua_sctp_cmd.cbuf; + msg->msg_controllen = cmsglen; + msg->msg_flags = MSG_XPG4_2; + + cmsg = (struct cmsghdr *)m2ua_sctp_cmd.cbuf; + sri = (struct sctp_sndrcvinfo *)(cmsg + 1); + + cmsg->cmsg_len = cmsglen; + cmsg->cmsg_level = IPPROTO_SCTP; + cmsg->cmsg_type = SCTP_SNDRCV; + + memset((BYTE *)sri, 0, sizeof(*sri)); + sri->sinfo_stream = m2ua_sctp_data.sid; + //add by yizane + //sri->sinfo_ppid = htonl(2); //m2ua + switch(m2ua_para.sg_para[sg].xUA_ack>>1) + { + case M2UA_APP: + ppid = 2; + break; + case IUA_APP: + ppid = 1; + break; + default: + ppid = 2; + break; + } + sri->sinfo_ppid = htonl(ppid); + + if ((ret = sendmsg(fd, msg, MSG_NOSIGNAL)) < 0) + { + sprintf(m2ua_ascitemp_buf, "lksctp sendmsg failure: %d(%s)", ret, strerror(ret)); + m2ua_log_err(sg, m2ua_ascitemp_buf); + return -1; + } + + //outb(in_b & 0xFB, 0x378); + + return 0; +} + +int m2ua_sctp_optdata_req_lksctp(int fd, int sg, int len) +{ + if (!len) + return (-1); + else + { + if (len > 272) + return (-1); + else + m2ua_sctp_data.len = len; + } + + return m2ua_sctp_put_msg_lksctp(fd, sg); +} + +#endif diff --git a/omc/plat/m2ua/ut/.copyarea.db b/omc/plat/m2ua/ut/.copyarea.db new file mode 100644 index 0000000..8b3a9fd --- /dev/null +++ b/omc/plat/m2ua/ut/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\ut +2 +2 +8:testcate|2|0|0|0|28896fecbfa511dc8544001c23e19543|0 +8:xua_test|2|0|0|0|12796c18bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/ut/testcate/.copyarea.db b/omc/plat/m2ua/ut/testcate/.copyarea.db new file mode 100644 index 0000000..a6b8e74 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\ut\testcate +2 +9 +c:headfile.txt|1|11d70a41187|91|562f27a5|2b897078bfa511dc8544001c23e19543|0 +14:MGC(M2UA)_Server.txt|1|11d70a41158|596|c9de3f60|2ae9705cbfa511dc8544001c23e19543|0 +13:SG(M2UA)_Client.txt|1|11d70a4111a|85a|8f2ee09a|2a597040bfa511dc8544001c23e19543|0 +12:SG(IUA)_Client.txt|1|11d70a411d5|975|36fc0fb4|2cb970b0bfa511dc8544001c23e19543|0 +13:MGC(IUA)_Server.txt|1|11d70a411a6|5bc|9a4b3d4d|2c197094bfa511dc8544001c23e19543|0 +13:SG(M2UA)_Server.txt|1|11d70a41214|e7|d5a142d6|2d4970ccbfa511dc8544001c23e19543|0 +12:SG(IUA)_Server.txt|1|11d70a41233|e9|2e7242e3|2de970e8bfa511dc8544001c23e19543|0 +13:MGC(IUA)_Client.txt|1|11d70a410eb|1d1|5ad78e6|29b97024bfa511dc8544001c23e19543|0 +14:MGC(M2UA)_Client.txt|1|11d70a4109d|1c7|1bc57729|29297008bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/ut/testcate/MGC(IUA)_Client.txt b/omc/plat/m2ua/ut/testcate/MGC(IUA)_Client.txt new file mode 100644 index 0000000..5a0b341 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/MGC(IUA)_Client.txt @@ -0,0 +1,32 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP +//0 send +//A5 00 03 00 02 00 +// +//10 send +//A5 00 03 00 06 00 + +10 send +A5 00 03 00 07 00 + +100 send +A5 00 03 00 01 00 + +10 send +05 00 03 FF 01 F0 +1000 recv +?? +10 send +05 00 03 FF 01 F1 +1000 recv +?? + +100 send +A5 00 03 00 02 00 + +50 send +A5 00 03 00 06 00 diff --git a/omc/plat/m2ua/ut/testcate/MGC(IUA)_Server.txt b/omc/plat/m2ua/ut/testcate/MGC(IUA)_Server.txt new file mode 100644 index 0000000..3f527bf --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/MGC(IUA)_Server.txt @@ -0,0 +1,52 @@ +#include "headfile.txt" + +test 1 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 +01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? + + +0 SCTP.send +01 00 03 04 00 00 00 08 + +0 SCTP.send +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02 + +1000 SCTP.FLTR +01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? + +1000 SCTP.RECV +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 +01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01 + +0 SCTP.send +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03 + +1000 SCTP.RECV +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 +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 +?? +0 SCTP.SEND +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 +?? +0 SCTP.SEND +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 +//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 +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 diff --git a/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Client.txt b/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Client.txt new file mode 100644 index 0000000..8100dcf --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Client.txt @@ -0,0 +1,33 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP + +0 send +A6 02 03 00 02 00 + +10 send +A6 02 03 00 06 00 + +10 send +A6 02 03 00 07 00 + +100 send +A6 02 03 00 01 00 + +10 send +06 02 03 FF 01 F0 +1000 recv +?? +10 send +06 02 03 FF 01 F1 +1000 recv +?? + +100 send +A6 02 03 00 02 00 + +50 send +A6 02 03 00 06 00 diff --git a/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Server.txt b/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Server.txt new file mode 100644 index 0000000..b1b6a0d --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/MGC(M2UA)_Server.txt @@ -0,0 +1,61 @@ +#include "headfile.txt" + +test 1 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 +01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? +//ip + +0 SCTP.send +01 00 03 04 00 00 00 08 + +0 SCTP.send +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02 + +1000 SCTP.FLTR +01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? +//ip 3 + +1000 SCTP.RECV +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 +01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01 + +0 SCTP.send +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03 + +1000 SCTP.RECV +01 00 06 02 00 00 00 10 00 01 00 08 00 00 00 00 + + +0 SCTP.send +01 00 06 03 00 00 00 10 00 01 00 08 00 00 00 00 + +1000 SCTP.RECV +?? +0 SCTP.SEND +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 +?? +0 SCTP.SEND +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 +// 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 +01 00 06 04 00 00 00 10 00 01 00 08 00 00 00 00 +//stop +0 SCTP.send +01 00 06 05 00 00 00 10 00 01 00 08 00 00 00 00 + +1000 SCTP.RECV +? \ No newline at end of file diff --git a/omc/plat/m2ua/ut/testcate/SG(IUA)_Client.txt b/omc/plat/m2ua/ut/testcate/SG(IUA)_Client.txt new file mode 100644 index 0000000..4a4d0e7 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/SG(IUA)_Client.txt @@ -0,0 +1,80 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP + +0 send +A5 01 03 00 06 00 +10 send +A5 01 03 00 07 00 + +test 2 +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 +01 00 03 01 00 00 00 10 00 11 00 08 AC 36 F0 A0 //ip +1000 SCTP.RECV +01 00 03 04 00 00 00 08 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02 +0 SCTP.SEND +01 00 04 01 00 00 00 10 00 0B 00 08 00 00 00 01 +1000 SCTP.RECV +01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03 +0 SCTP.SEND +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 +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 +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 01 +1 SCTP.SEND +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 03 +1 SCTP.SEND +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 04 + + +0 SCTP.SEND +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 +?? + +0 SCTP.SEND +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 +?? + +1 SCTP.SEND +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 +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 +01 00 04 02 00 00 00 10 +1000 SCTP.RECV +01 00 04 04 00 00 00 08 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 04 + +1 SCTP.SEND +01 00 03 02 00 00 00 10 +1000 SCTP.RECV +01 00 03 05 00 00 00 08 + + +test 3 +100 SCTP.SET ABORT + diff --git a/omc/plat/m2ua/ut/testcate/SG(IUA)_Server.txt b/omc/plat/m2ua/ut/testcate/SG(IUA)_Server.txt new file mode 100644 index 0000000..e5619b4 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/SG(IUA)_Server.txt @@ -0,0 +1,16 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP + +1000 recv +?? +10 send +05 01 03 FF 01 F0 + +1000 recv +?? +10 send +05 01 03 FF 01 F1 diff --git a/omc/plat/m2ua/ut/testcate/SG(M2UA)_Client.txt b/omc/plat/m2ua/ut/testcate/SG(M2UA)_Client.txt new file mode 100644 index 0000000..87b988f --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/SG(M2UA)_Client.txt @@ -0,0 +1,79 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP + +0 send +A6 03 03 00 06 00 +10 send +A6 03 03 00 07 00 + +test 2 +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 +01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? //ip +1000 SCTP.RECV +01 00 03 04 00 00 00 08 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02 +0 SCTP.SEND +01 00 04 01 00 00 00 10 00 0B 00 08 00 00 00 01 +1000 SCTP.RECV +01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03 +0 SCTP.SEND +01 00 06 02 00 00 00 10 00 01 00 08 00 00 00 00 +1000 SCTP.RECV +01 00 06 03 00 00 00 10 00 01 00 08 00 00 00 00 +1 SCTP.SEND +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 01 +1 SCTP.SEND +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 03 +1 SCTP.SEND +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 +01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 04 + + +0 SCTP.SEND +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 +?? +0 SCTP.SEND +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 +?? + +1 SCTP.SEND +01 00 06 04 00 00 00 10 00 01 00 08 00 00 00 00 +1000 SCTP.RECV +?? + + +1 SCTP.SEND +01 00 04 02 00 00 00 10 +1000 SCTP.RECV +01 00 04 04 00 00 00 08 +1000 SCTP.RECV +01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 04 + +1 SCTP.SEND +01 00 03 02 00 00 00 10 +1000 SCTP.RECV +01 00 03 05 00 00 00 08 + + +test 3 +100 SCTP.SET ABORT + diff --git a/omc/plat/m2ua/ut/testcate/SG(M2UA)_Server.txt b/omc/plat/m2ua/ut/testcate/SG(M2UA)_Server.txt new file mode 100644 index 0000000..9bc3382 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/SG(M2UA)_Server.txt @@ -0,0 +1,15 @@ +#include "headfile.txt" + +test 1 udp +UDP.Set remote_port=MSG_PORT +UDP.Set local_port=MSG_PORT +UDP.Set remote_ip=MSC_IP +1000 recv +?? +10 send +06 03 03 FF 01 F0 + +1000 recv +?? +10 send +06 03 03 FF 01 F1 diff --git a/omc/plat/m2ua/ut/testcate/headfile.txt b/omc/plat/m2ua/ut/testcate/headfile.txt new file mode 100644 index 0000000..d931868 --- /dev/null +++ b/omc/plat/m2ua/ut/testcate/headfile.txt @@ -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 \ No newline at end of file diff --git a/omc/plat/m2ua/ut/xua_test/.copyarea.db b/omc/plat/m2ua/ut/xua_test/.copyarea.db new file mode 100644 index 0000000..0e6ffa8 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\ut\xua_test +2 +3 +4:conf|2|0|0|0|13196c50bfa511dc8544001c23e19543|0 +9:xuatest.c|1|11d70a4095a|1cf3|1654cf4d|27f96fd0bfa511dc8544001c23e19543|0 +8:Makefile|1|11d70a4090c|230|12969e30|12796c34bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/ut/xua_test/Makefile b/omc/plat/m2ua/ut/xua_test/Makefile new file mode 100644 index 0000000..bf9b54b --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/Makefile @@ -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 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/.copyarea.db b/omc/plat/m2ua/ut/xua_test/conf/.copyarea.db new file mode 100644 index 0000000..96dd6c4 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/.copyarea.db @@ -0,0 +1,35 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\m2ua\ut\xua_test\conf +2 +1f +9:help_page|1|11d70a40a83|21d|76e388e2|15796cc0bfa511dc8544001c23e19543|0 +e:wxc2_sys.conf~|1|11d70a40f45|27|ca2b0a3e|24f96f44bfa511dc8544001c23e19543|0 +12:cap_operation.conf|1|11d70a40e0d|4b0|ef2a579d|20396e80bfa511dc8544001c23e19543|0 +c:cap_acn.conf|1|11d70a40c19|d1|e2e74291|19a96d68bfa511dc8544001c23e19543|0 +10:conv_prefix.conf|1|11d70a40bfa|1000|d03e33b0|19096d4cbfa511dc8544001c23e19543|0 +e:smsc_csta.conf|1|11d70a40f17|180|865a75d9|24596f28bfa511dc8544001c23e19543|0 +c:map_acn.conf|1|11d70a40b6d|5e5|45d6ce17|18796d30bfa511dc8544001c23e19543|0 +d:wxc2_sys.conf|1|11d70a40ae1|3c|e51f0ff6|16a96cf8bfa511dc8544001c23e19543|0 +c:iptrans.conf|1|11d70a41001|131|51ad4ddb|27596fb4bfa511dc8544001c23e19543|0 +9:menu_page|1|11d70a409f7|20a|2b951fe|13a96c6cbfa511dc8544001c23e19543|0 +7:profile|1|11d70a40e6b|328|6617ec7f|21696eb8bfa511dc8544001c23e19543|0 +a:system.ini|1|11d70a40fd2|d4|c3160d16|26c96f98bfa511dc8544001c23e19543|0 +a:HlrSysPara|1|11d70a40e3c|1c4c|cd70b8b6|20c96e9cbfa511dc8544001c23e19543|0 +d:smsc_sys.conf|1|11d70a40ee8|5b|d6b11819|23296f0cbfa511dc8544001c23e19543|0 +9:mnpf.conf|1|11d70a40c67|2ce|d60203f0|1ad96da0bfa511dc8544001c23e19543|0 +12:map_operation.conf|1|11d70a40d61|a7a|bac9fcb5|1e696e2cbfa511dc8544001c23e19543|0 +a:AucSysPara|1|11d70a40f74|38|4cb608e9|25896f60bfa511dc8544001c23e19543|0 +d:sccp_sts.conf|1|11d70a40cd5|1103|e115fddb|1c096dd8bfa511dc8544001c23e19543|0 +a:EirSysPara|1|11d70a40d04|4444|10b70979|1c996df4bfa511dc8544001c23e19543|0 +9:sccp.conf|1|11d70a40a25|1414|b255d16|14496c88bfa511dc8544001c23e19543|0 +11:hlr_parambit.conf|1|11d70a40e9a|5104|45018cef|21f96ed4bfa511dc8544001c23e19543|0 +8:msc_conf|1|11d70a40da0|35f10|c72c6332|1f096e48bfa511dc8544001c23e19543|0 +d:sccp_omt.conf|1|11d70a40fa3|14f4|912d7b40|26296f7cbfa511dc8544001c23e19543|0 +b:ppsConf.txt|1|11d70a40a54|11ac|d847f7af|14d96ca4bfa511dc8544001c23e19543|0 +9:mtp3.conf|1|11d70a40b10|17450|e8129109|17496d14bfa511dc8544001c23e19543|0 +e:ppsCrdConf.txt|1|11d70a40ec8|2831|28310001|22996ef0bfa511dc8544001c23e19543|0 +d:cc_table.conf|1|11d70a40c38|1156|31d07a59|1a396d84bfa511dc8544001c23e19543|0 +8:vlr.conf|1|11d70a40ab2|80|a6bd1cd5|16196cdcbfa511dc8544001c23e19543|0 +12:smsc_parambit.conf|1|11d70a40dde|16b4|130762e0|1f996e64bfa511dc8544001c23e19543|0 +c:wxc2exit.txt|1|11d70a40ca6|4a|52241550|1b696dbcbfa511dc8544001c23e19543|0 +11:xap_sysparam.conf|1|11d70a40d23|d|1b510569|1d396e10bfa511dc8544001c23e19543|0 diff --git a/omc/plat/m2ua/ut/xua_test/conf/AucSysPara b/omc/plat/m2ua/ut/xua_test/conf/AucSysPara new file mode 100644 index 0000000..d36dbec Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/AucSysPara differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/EirSysPara b/omc/plat/m2ua/ut/xua_test/conf/EirSysPara new file mode 100644 index 0000000..30432ac Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/EirSysPara differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/HlrSysPara b/omc/plat/m2ua/ut/xua_test/conf/HlrSysPara new file mode 100644 index 0000000..5e6c09f Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/HlrSysPara differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/cap_acn.conf b/omc/plat/m2ua/ut/xua_test/conf/cap_acn.conf new file mode 100644 index 0000000..6a18ef5 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/cap_acn.conf @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/cap_operation.conf b/omc/plat/m2ua/ut/xua_test/conf/cap_operation.conf new file mode 100644 index 0000000..a1789ea --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/cap_operation.conf @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/cc_table.conf b/omc/plat/m2ua/ut/xua_test/conf/cc_table.conf new file mode 100644 index 0000000..72da771 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/cc_table.conf @@ -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 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/conv_prefix.conf b/omc/plat/m2ua/ut/xua_test/conf/conv_prefix.conf new file mode 100644 index 0000000..246d463 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/conv_prefix.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/help_page b/omc/plat/m2ua/ut/xua_test/conf/help_page new file mode 100644 index 0000000..f384302 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/help_page @@ -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". + +$ diff --git a/omc/plat/m2ua/ut/xua_test/conf/hlr_parambit.conf b/omc/plat/m2ua/ut/xua_test/conf/hlr_parambit.conf new file mode 100644 index 0000000..8497c6f Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/hlr_parambit.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/iptrans.conf b/omc/plat/m2ua/ut/xua_test/conf/iptrans.conf new file mode 100644 index 0000000..1e12ec1 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/iptrans.conf @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/map_acn.conf b/omc/plat/m2ua/ut/xua_test/conf/map_acn.conf new file mode 100644 index 0000000..ebaf2b1 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/map_acn.conf @@ -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) diff --git a/omc/plat/m2ua/ut/xua_test/conf/map_operation.conf b/omc/plat/m2ua/ut/xua_test/conf/map_operation.conf new file mode 100644 index 0000000..ddcaec8 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/map_operation.conf @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/menu_page b/omc/plat/m2ua/ut/xua_test/conf/menu_page new file mode 100644 index 0000000..29f6fb8 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/menu_page @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/mnpf.conf b/omc/plat/m2ua/ut/xua_test/conf/mnpf.conf new file mode 100644 index 0000000..6dfc892 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/mnpf.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/msc_conf b/omc/plat/m2ua/ut/xua_test/conf/msc_conf new file mode 100644 index 0000000..43b066b Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/msc_conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/mtp3.conf b/omc/plat/m2ua/ut/xua_test/conf/mtp3.conf new file mode 100644 index 0000000..3121a5e --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/mtp3.conf @@ -0,0 +1,1408 @@ +#MTP3 CONFIGURE FILE + +[SERVICE NETWORK SP LEN] +[08] + +[LOCAL SP] +[000001] [000000] [001fd3] [002ee0] +[000001] [000000] [000000] [000202] + +[LINK ATTRIBUTE] +[00.00.00] [03.04.62] [ff.00.62] [05.04.62] +[7e.00.62] [14.00.62] [00.00.00] [00.00.00] +[00.00.00] [03.02.62] [00.00.00] [05.02.62] +[00.00.00] [15.00.62] [00.00.00] [00.00.00] +[00.00.00] [03.00.62] [00.00.00] [05.00.62] +[00.00.00] [00.00.00] [00.00.00] [0a.00.62] +[01.00.62] [03.06.62] [07.00.62] [05.06.62] +[00.00.00] [00.00.00] [00.00.00] [0b.00.62] +[1e.01.62] [40.00.62] [08.00.62] [05.08.62] +[00.00.00] [00.00.00] [00.00.00] [0c.00.62] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.01.00] [03.01.63] [08.01.63] [05.01.63] +[7f.00.63] [14.01.63] [00.00.00] [00.00.00] +[00.00.00] [03.03.63] [00.00.00] [00.00.00] +[05.03.63] [15.01.63] [00.00.00] [00.00.00] +[00.00.00] [03.05.63] [00.00.00] [05.05.63] +[00.00.00] [00.00.00] [00.00.00] [0a.01.63] +[00.00.00] [03.07.63] [07.01.63] [05.07.63] +[00.00.00] [00.00.00] [00.00.00] [0b.01.63] +[00.00.00] [40.01.63] [00.00.00] [05.09.63] +[00.00.00] [00.00.00] [00.00.00] [0c.01.63] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] + +[LINKSET ATTRIBUTE] +[000000.00] [000b03.02] [000000.00] [002eea.02] +[000000.00] [002eeb.02] [000000.00] [001fe7.02] +[001fe8.02] [000000.00] [0032d2.02] [0032d3.02] +[0032d4.02] [000000.00] [0032dc.03] [0032dd.03] +[000000.00] [000000.00] [000000.00] [000000.00] +[000003.02] [000004.02] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [002024.02] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[002eec.02] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [00007e.0b] [00007f.0b] + +[NATIONAL NETWORK SP] +[0032d2.0a.7e] [000b03.01.7f] [002081.01.7f] [000000.80.80] +[000003.14.7e] [000004.15.7e] [000000.80.80] [002eea.03.7e] +[000000.80.80] [000000.80.80] [001fe7.07.7e] [001fe8.08.7e] +[000000.80.80] [000000.80.80] [0032d3.0b.7e] [0032d4.0c.7e] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [00001b.1b.80] +[00001c.1c.80] [00001d.1d.80] [000000.80.80] [00001f.1f.80] +[002eeb.05.7e] [000000.80.80] [00003c.22.00] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [002024.1e.7f] [002eec.40.7e] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[NATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [00007e.7e.7f] +[00007f.7f.7e] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[LOCAL ACN] +030303030202020202030302020202020202020203030303030303030303030302020202 + +[INTERNATIONAL NETWORK ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[INTERNATIONAL NETWORK SPARE ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[NATIONAL NETWORK ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +030303030202020202030302020202020202020203030303030303030303030302020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[NATIONAL NETWORK SPARE ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/ppsConf.txt b/omc/plat/m2ua/ut/xua_test/conf/ppsConf.txt new file mode 100644 index 0000000..dacce58 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/ppsConf.txt differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/ppsCrdConf.txt b/omc/plat/m2ua/ut/xua_test/conf/ppsCrdConf.txt new file mode 100644 index 0000000..5d2c23c Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/ppsCrdConf.txt differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/profile b/omc/plat/m2ua/ut/xua_test/conf/profile new file mode 100644 index 0000000..de17bc9 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/profile @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/sccp.conf b/omc/plat/m2ua/ut/xua_test/conf/sccp.conf new file mode 100644 index 0000000..5a16b37 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/sccp.conf @@ -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 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/sccp_omt.conf b/omc/plat/m2ua/ut/xua_test/conf/sccp_omt.conf new file mode 100644 index 0000000..e23cfca --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/sccp_omt.conf @@ -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 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/sccp_sts.conf b/omc/plat/m2ua/ut/xua_test/conf/sccp_sts.conf new file mode 100644 index 0000000..c24ad70 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/sccp_sts.conf @@ -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 + diff --git a/omc/plat/m2ua/ut/xua_test/conf/smsc_csta.conf b/omc/plat/m2ua/ut/xua_test/conf/smsc_csta.conf new file mode 100644 index 0000000..b38d7f7 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/smsc_csta.conf @@ -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 diff --git a/omc/plat/m2ua/ut/xua_test/conf/smsc_parambit.conf b/omc/plat/m2ua/ut/xua_test/conf/smsc_parambit.conf new file mode 100644 index 0000000..3871a69 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/smsc_parambit.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/smsc_sys.conf b/omc/plat/m2ua/ut/xua_test/conf/smsc_sys.conf new file mode 100644 index 0000000..a6081a9 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/smsc_sys.conf @@ -0,0 +1,5 @@ +#SMSC system configure file + +#IP info of SMSC +wxc2-0=172.18.98.1; +wxc2-1=172.18.99.1; diff --git a/omc/plat/m2ua/ut/xua_test/conf/system.ini b/omc/plat/m2ua/ut/xua_test/conf/system.ini new file mode 100644 index 0000000..6dfbc13 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/system.ini differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/vlr.conf b/omc/plat/m2ua/ut/xua_test/conf/vlr.conf new file mode 100644 index 0000000..9d07544 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/vlr.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/conf/wxc2_sys.conf b/omc/plat/m2ua/ut/xua_test/conf/wxc2_sys.conf new file mode 100644 index 0000000..d2da574 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/wxc2_sys.conf @@ -0,0 +1,3 @@ +yizane=172.48.234.133; +pps-1=172.18.128.137; +heartbeat no=9 diff --git a/omc/plat/m2ua/ut/xua_test/conf/wxc2exit.txt b/omc/plat/m2ua/ut/xua_test/conf/wxc2exit.txt new file mode 100644 index 0000000..910c426 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/conf/wxc2exit.txt @@ -0,0 +1,4 @@ +WXC2 procedure exit log + Time: Tue Jan 18 10:22:59 2005 + +Now module: MSC diff --git a/omc/plat/m2ua/ut/xua_test/conf/xap_sysparam.conf b/omc/plat/m2ua/ut/xua_test/conf/xap_sysparam.conf new file mode 100644 index 0000000..e466c96 Binary files /dev/null and b/omc/plat/m2ua/ut/xua_test/conf/xap_sysparam.conf differ diff --git a/omc/plat/m2ua/ut/xua_test/xuatest.c b/omc/plat/m2ua/ut/xua_test/xuatest.c new file mode 100644 index 0000000..19d4051 --- /dev/null +++ b/omc/plat/m2ua/ut/xua_test/xuatest.c @@ -0,0 +1,293 @@ +/************************************************/ +/*Title: xuatest.c */ +/*Descr: Processor for xUA Unitest */ +/*Author: Yi Zane */ +/*Create: 2006-05-17 */ +/************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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; +} + diff --git a/omc/plat/make_plat b/omc/plat/make_plat new file mode 100644 index 0000000..a59d74a --- /dev/null +++ b/omc/plat/make_plat @@ -0,0 +1,19 @@ +#!/bin/bash + +platDir=/usr/local/omc/plat +platModuleList="8ecp aif bicc debug haepub iptrans isdn isup m2ua mgc mgcp mgc_v2 mtp3 pal public rtp sccp scf sip smpp snmp tcap xapp" +for mod in $platModuleList; do + echo "====================== make $mod ======================="; + cd $platDir/$mod + make clean + make + + if [ $mod == "iptrans" ] ; then + ./generate_iptrans + cp -f ./iptrans /usr/local/omc/bin/ + fi + + cd - + echo "" +done + diff --git a/omc/plat/mgc/.copyarea.db b/omc/plat/mgc/.copyarea.db new file mode 100644 index 0000000..d561d37 --- /dev/null +++ b/omc/plat/mgc/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc +2 +5 +3:doc|2|0|0|0|30e96971bfa511dc8589001c23e19543|0 +2:ut|2|0|0|0|3c396b85bfa511dc8589001c23e19543|0 +3:src|2|0|0|0|6db4722b6cf311dd91c7001c23e19543|0 +8:Makefile|1|11d70a4130e|b2c|f1cbf16|317969a9bfa511dc8589001c23e19543|0 +3:lib|2|0|0|0|3179698dbfa511dc8589001c23e19543|0 diff --git a/omc/plat/mgc/Makefile b/omc/plat/mgc/Makefile new file mode 100644 index 0000000..50540dd --- /dev/null +++ b/omc/plat/mgc/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = mgc +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../app + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/mgc/lib/libmgc.a b/omc/plat/mgc/lib/libmgc.a new file mode 100644 index 0000000..c56a2a1 Binary files /dev/null and b/omc/plat/mgc/lib/libmgc.a differ diff --git a/omc/plat/mgc/obj/mgc.o b/omc/plat/mgc/obj/mgc.o new file mode 100644 index 0000000..90af9b9 Binary files /dev/null and b/omc/plat/mgc/obj/mgc.o differ diff --git a/omc/plat/mgc/obj/mgc_debug.o b/omc/plat/mgc/obj/mgc_debug.o new file mode 100644 index 0000000..44a87f2 Binary files /dev/null and b/omc/plat/mgc/obj/mgc_debug.o differ diff --git a/omc/plat/mgc/obj/mgc_fsm.o b/omc/plat/mgc/obj/mgc_fsm.o new file mode 100644 index 0000000..4b9e018 Binary files /dev/null and b/omc/plat/mgc/obj/mgc_fsm.o differ diff --git a/omc/plat/mgc/obj/mgc_sess_ctl.o b/omc/plat/mgc/obj/mgc_sess_ctl.o new file mode 100644 index 0000000..ba005cb Binary files /dev/null and b/omc/plat/mgc/obj/mgc_sess_ctl.o differ diff --git a/omc/plat/mgc/src/.copyarea.db b/omc/plat/mgc/src/.copyarea.db new file mode 100644 index 0000000..9cc7cbf --- /dev/null +++ b/omc/plat/mgc/src/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc\src +2 +8 +5:mgc.c|1|11d70a41475|27c51|e37b4482|17b22fb07faf11dd8601001c23e19543|0 +e:mgc_sess_ctl.c|1|11d70a41511|fb9|eb0774a7|fcc48ade6cf311dd91a5001c23e19543|0 +9:mgc.c.bak|1|11d70a413ba|221a6|fe9f4305|32a969e1bfa511dc8589001c23e19543|0 +7:include|2|0|0|0|6e5472376cf311dd91c7001c23e19543|0 +d:mgc_fsm.c.bak|1|11d70a41446|90e6|5ec648a3|34796a35bfa511dc8589001c23e19543|0 +b:mgc_debug.c|1|11d70a41427|2a74|6e29f133|33d96a19bfa511dc8589001c23e19543|0 +9:mgc_fsm.c|1|11d70a414e2|c238|944fc00d|18522fc87faf11dd8601001c23e19543|0 +a:.mgc.c.swp|1|11d70a413e8|4000|a9e2fec6|334969fdbfa511dc8589001c23e19543|0 diff --git a/omc/plat/mgc/src/include/.copyarea.db b/omc/plat/mgc/src/include/.copyarea.db new file mode 100644 index 0000000..576c010 --- /dev/null +++ b/omc/plat/mgc/src/include/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc\src\include +2 +9 +9:mgc_def.h|1|11d70a41714|650|3b82df45|eae4844e6cf311dd91a5001c23e19543|0 +5:mgc.h|1|11d70a415dc|1fce|4708214d|e9b483ee6cf311dd91a5001c23e19543|0 +e:mgc_sess_ctl.h|1|11d70a41782|368|68f705aa|fc348ac66cf311dd91a5001c23e19543|0 +9:mgc_pub.h|1|11d70a4161b|93|519c2e5b|36d96aa5bfa511dc8589001c23e19543|0 +b:mgc_debug.h|1|11d70a41659|13d|7ae68cf|37796ac1bfa511dc8589001c23e19543|0 +9:mgc_fsm.h|1|11d70a41753|a0|21d73362|3a696b4dbfa511dc8589001c23e19543|0 +9:mgc_ext.h|1|11d70a416c6|3cd|d7c35c3|ea54841e6cf311dd91a5001c23e19543|0 +c:mgc_struct.h|1|11d70a416e6|d5e|477a2e7b|eae484366cf311dd91a5001c23e19543|0 +b:mgc_const.h|1|11d70a41688|80c|c6b62f59|ea5484066cf311dd91a5001c23e19543|0 diff --git a/omc/plat/mgc/src/include/mgc.h b/omc/plat/mgc/src/include/mgc.h new file mode 100644 index 0000000..3b21539 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc.h @@ -0,0 +1,251 @@ +#ifndef _MGC__H +#define _MGC__H + +#include "../../../public/src/include/pub_sdp.h" +#include "../../../mgcp/src/include/mgcp.h" +#include "../../../8ecp/src/include/8ecp.h" + +#define MGC_MAX_NUM_OF_SAP 4 +#define MGC_MAX_USER_NAME_LEN 8 +#define MGC_MAX_DOMAIN_LEN 64 +#define MGC_MAX_PHY_PORT_PER_MG 32 + +#define MGC_USER_TYPE_MGC 0 +#define MGC_USER_TYPE_MG 1 + +#define MGC_MAX_NUM_OF_MG 1024 +#define MGC_MAX_NUM_OF_PHY_PORT 1024 +#define MGC_MAX_NUM_OF_CHNL 9424 +#define MGC_MAX_NUM_OF_PORT 8192 + +#define MGC_MAX_NUM_OF_AAS_MGC 4 + +#define MGC_MG_TYPE_INTERNAL 0 +#define MGC_MG_TYPE_AudioCoder 1 +#define MGC_MG_TYPE_LGC_MG 2 +#define MGC_MG_TYPE_SSW_CSS 3 +#define MGC_MG_TYPE_IPBSS 4 +#define MGC_MG_TYPE_ANALOG 11 +#define MGC_MG_TYPE_ANN 21 + +#define MGC_PHY_PORT_TYPE_E1 1 +#define MGC_PHY_PORT_TYPE_T1 2 +#define MGC_PHY_PORT_TYPE_ANALOG 3 + +#define MGC_MG_CTRL_TYPE_MGCP 0 +#define MGC_MG_CTRL_TYPE_8ECP 1 + +#define MGC_MEDIA_ATTR_EC_FLAG 0x01 +#define MGC_MEDIA_ATTR_SS_FLAG 0x02 +#define MGC_MEDIA_ATTR_VT_FLAG 0x04 + +#define MGC_OPER_ID_CONNECT_CHNL 1 +#define MGC_OPER_ID_CONNECT_DTMF 2 +#define MGC_OPER_ID_CONNECT_TONE 3 +#define MGC_OPER_ID_CRCX 4 +#define MGC_OPER_ID_MDCX 5 +#define MGC_OPER_ID_DLCX 6 +#define MGC_OPER_ID_RQNT 7 +#define MGC_OPER_ID_AUEP 8 +#define MGC_OPER_ID_CONNECT_AAS 9 + +#define MGC_OPER_FAILURE 0 +#define MGC_OPER_SUCCESS 1 + +#define MGC_VCTYPE_MAX 13 +#define MGC_VCTYPE_MAX_1 12 + +#define MGC_VCTYPE_PCMA 0 +#define MGC_VCTYPE_PCMU 1 +#define MGC_VCTYPE_GSM 2 +#define MGC_VCTYPE_GSM_EFR 3 +#define MGC_VCTYPE_AMR_12_2 4 +#define MGC_VCTYPE_G729B 5 +#define MGC_VCTYPE_AMR_10_2 6 +#define MGC_VCTYPE_AMR_7_95 7 +#define MGC_VCTYPE_AMR_7_4 8 +#define MGC_VCTYPE_AMR_6_7 9 +#define MGC_VCTYPE_AMR_5_15 10 +#define MGC_VCTYPE_AMR_5_9 11 +#define MGC_VCTYPE_AMR_4_75 12 + + + +#define MGC_MEDIA_PARA_FLAG_EC 0x0001 +#define MGC_MEDIA_PARA_FLAG_SS 0x0002 +#define MGC_MEDIA_PARA_FLAG_VT 0x0004 +#define MGC_MEDIA_PARA_FLAG_CM 0x0008 +#define MGC_MEDIA_PARA_FLAG_PT 0x0010 + +#define MGC_MAX_NUM_OF_CODEC 16 + +#define MGC_HOLD_MUSIC 7 +#define MGC_TONE_RING 8 +#define MGC_TONE_BUSY 9 +#define MGC_TONE_WARN 10 + +#define MGC_CONNECT_SILENT_TONE 0x01 + +#define MGC_MG_NETWORK_PORT 4967 +#define MGC_MGC_NETWORK_PORT 4966 + + +#define MGC_CONNECT_STATUS_IDLE 0 +#define MGC_CONNECT_STATUS_CREATING 1 +#define MGC_CONNECT_STATUS_CREATED 2 +#define MGC_CONNECT_STATUS_TONE 3 + +typedef enum{ + MGC_DTMF_1 = 1, + MGC_DTMF_2 = 2, + MGC_DTMF_3 = 3, + MGC_DTMF_4 = 4, + MGC_DTMF_5 = 5, + MGC_DTMF_6 = 6, + MGC_DTMF_7 = 7, + MGC_DTMF_8 = 8, + MGC_DTMF_9 = 9, + MGC_DTMF_0 = 10, + MGC_DTMF_START = 11, + MGC_DTMF_POUND = 12 +}MGC_DTMF_DEF; + +typedef enum{ + MGC_PKG_L = 0, + MGC_PKG_D = 1, + MGC_PKG_G = 2 +}MGC_PKG_TYPE; + +typedef struct _OPER_REC +{ + BYTE operaId; + BYTE tone; + WORD duration; + WORD times; +}OPER_REC; + +typedef struct _CHNL +{ + WORD mgNo; // mg No. + BYTE portNo; // local physical port No. of that mg + WORD chlNo; // local channel No. of that trunk + WORD connectNo; +}CHNL; + +typedef struct _MGC_CODEC_LIST +{ + BYTE num; // num of codecs + WORD priority; // priority level, used when comparing different codec list + BYTE codec[MGC_MAX_NUM_OF_CODEC]; // codec ID number, high priority codec first +}MGC_CODEC_LIST; + +typedef struct _MEDIA_PARA +{ + WORD flag; // which media attribute is affected + BYTE ecDisable; // echo canceller disable or enable + BYTE ssDisable; // silence suppression disable or enable; + BYTE conMode; // connect mode + BYTE ptime; // packetization period + MGC_CODEC_LIST vocoderType; // vocoder type +}MEDIA_PARA; + +typedef struct _MG_ATTR +{ + BYTE ptime; // ptime, in ms + BYTE mgType; // non-virtual/ann + BYTE ctrlType; // 8ecp or mgcp + BYTE epDes; // endpoint description method: structured or unstructured + BYTE toneCap; // Tone generation capability + BYTE maxPorts; // maximum physical ports of this MG + WORD maxChnls; // maximum channels of this MG, only applicable to virtual MG. + DWORD ip; // IP address of the MG + char domain[MGC_MAX_DOMAIN_LEN]; // domain name of the mg + BYTE e1cardNo; + DWORD auditTimer; + + MGC_CODEC_LIST codecList; // list of codecs that the MG supports +}MG_ATTR; + +typedef struct _MEDIA_ATTR +{ + BYTE ecDisable; // echo canceller disable or enable + BYTE ssDisable; // silence suppression disable or enable + BYTE vocoderType; // vocoder type + BYTE conMode; // connect mode + char callId[33]; // call Id + char conId[33]; // connection id + BYTE ptime; // packetization period + WORD pkgEvent; // package + event + WORD pkgSignal; // package + signal + WORD pkgReq; //package+req + WORD restMode; // restart mode + WORD restDelay; // restart delay + + PUB_SDP_MSG sdp; // media info of this channel +}MEDIA_ATTR; + +typedef struct _EVENT +{ + BYTE pkg; // package name + BYTE event; // event name +}EVENT; + +typedef struct _SIGNAL +{ + BYTE pkg; // package name + BYTE signal; // signal name +}SIGNAL; + +typedef struct _MGC_SAP +{ + char usrName[MGC_MAX_USER_NAME_LEN]; // user name + BYTE usrType; // user acts as a mg or mgc + + // callback function registration - indication + int (*mgc_ind)(CHNL chnl, BYTE cmd, WORD *usrPort, WORD mgcPort, MEDIA_ATTR *mediaAttr); + + // callback function registration - confirmation + int (*mgc_cnf)(WORD usrPort, WORD mgcPort, BYTE operId, BYTE success, WORD cause); +}MGC_SAP; + +int mgc_bind(MGC_SAP *sap); +int mgc_unbind(MGC_SAP *sap, BYTE sapIndex); + +int mgc_crcx_chnl(WORD usrPort, CHNL chnl); +int mgc_dlcx_chnl(WORD usrPort, CHNL chnl); +int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *mediaPara, BYTE sdFlag); +int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl); +int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, EVENT *event, SIGNAL *signal); +int mgc_auep_chnl(WORD usrPort, CHNL chnl); + +int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag); +int mgc_connect_dtmf(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE dtmfNo); +int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration); +int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration, WORD times); + +int mgc_create_MG(BYTE sapIndex, MG_ATTR *mgAttr); +int mgc_delete_MG(BYTE sapIndex, WORD mgNo); +int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr); + +int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType); +int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo); +int mgc_modify_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType); + +int mgc_query_mg_status(WORD mgNo); +int mgc_query_port_status(WORD mgNo, BYTE portNo); +int mgc_query_channel_status(CHNL chnl); + +int mgc_create_virtual_chnl(WORD port, CHNL *chnl); +int mgc_release_virtual_chnl(WORD port, CHNL chnl); + +int mgc_query_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG **mediaInfo, BYTE *mgPayloads, BYTE *mgPlNum); +int mgc_update_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG *mediaInfo); + +int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum); + +int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *mediaAttr); + +int mgc_chnl_codec_update(CHNL chnl , MGC_CODEC_LIST codecList); +int mgc_query_chnl_status(CHNL chnl); +OPER_REC *mgc_query_chnl_oper_rec(CHNL chnl); +#endif diff --git a/omc/plat/mgc/src/include/mgc_const.h b/omc/plat/mgc/src/include/mgc_const.h new file mode 100644 index 0000000..79e5597 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_const.h @@ -0,0 +1,75 @@ +#ifndef _MGC_CONST__H +#define _MGC_CONST__H + +#define MGC_MAX_OPER_STEPS_NUM 8 + +#define MGC_MGCF_STATE_REQUEST 1 +#define MGC_MGCF_STATE_INDICATION 2 +#define MGC_MGCF_STATE_INIT 3 + +#define MGC_MGCF_TIMER_50MS 5 +#define MGC_MGCF_TIMER_1S 100 +#define MGC_MGCF_TIMER_10S 10 * MGC_MGCF_TIMER_1S +#define MGC_MGCF_TIMER_20S 20 * MGC_MGCF_TIMER_1S +#define MGC_MGCF_TIMER_1H 3600 * MGC_MGCF_TIMER_1S + +#define MGC_CHNL_START_DS 0 +#define MGC_CHNL_START_INTERNAL 8192 +#define MGC_CHNL_START_ANN 9216 +#define MGC_CHNL_START_MSS 9256 +#define MGC_CHNL_START_AALN 9416 + +#define MGC_CHNL_NUM_INTERNAL 1024 +#define MGC_CHNL_NUM_ANN 200 +//#define MGC_CHNL_NUM_MSS 4 +#define MGC_CHNL_NUM_AALN 8 +#define MGC_CHNL_NUM_DS_TOTAL 8192 + +#define MGC_CHNL_NUM_INTERNAL_PER_PORT 1 +#define MGC_CHNL_NUM_AALN_PER_PORT 1 +#define MGC_CHNL_NUM_ANN_PER_TYPE 40 +#define MGC_CHNL_NUM_DS_PER_PORT 32 + +#define MGC_MNG_CMD_IDLE 0 +#define MGC_MNG_CMD_REMOVE_CHNL 1 +#define MGC_MNG_CMD_OVERWRITE 2 +#define MGC_MNG_CMD_CLEAR_AFTER_OPER 3 + +#define MGC_CHNL_STATUS_IDLE 0 +#define MGC_CHNL_STATUS_CREATING 1 +#define MGC_CHNL_STATUS_CREATED 2 + + +#define MGC_INTERNAL_VIRTUAL_MG 0 +#define MGC_8ECP_MG_OFFSET 1 +#define MGC_8ECP_MAX_TRK_PER_MG 8 + +#define MGC_MAX_NUM_OF_CHNL_CON 512 +#define MGC_MAX_NUM_OF_CON 8192 + +#define MGC_MGCP_MGC_PORT 2727 +#define MGC_MGCP_MG_PORT 2427 + +#define MGC_MAX_ASCIIIN_LEN 4096 +#define MGC_MAX_ASCIIOUT_LEN 4096 +#define MGC_MAX_ASCITMP_LEN 4096 + +#define MGC_MONITOR_NONE 0x0000 +#define MGC_MONITOR_ERROR 0x0010 +#define MGC_MONITOR_ALL 0xffff + +#define MGC_CHNL_CLEAR_PORT 0 +#define MGC_CHNL_SAVE_PORT 1 + +#define MGC_MAX_TONE_NO 16 + +//#define MGC_8K_TONE_CHNL_SILENT (0 * 8 + 7) * 32 + 31 + +#define MGC_PKG_SIG_G_RT ((MGCP_PKG_G << 8) | MGCP_G_SIG_RT) +#define MGC_PKG_SIG_L_BZ ((MGCP_PKG_L << 8) | MGCP_L_SIG_BZ) +#define MGC_PKG_SIG_L_WT ((MGCP_PKG_L << 8) | MGCP_L_SIG_WT) + +#define MGC_CHNL_AUEP_IDLE 0 +#define MGC_CHNL_AUEP_IN_PROGRESS 1 + +#endif diff --git a/omc/plat/mgc/src/include/mgc_debug.h b/omc/plat/mgc/src/include/mgc_debug.h new file mode 100644 index 0000000..6aaf31b --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_debug.h @@ -0,0 +1,11 @@ +#ifndef _MGC_DEBUG__H +#define _MGC_DEBUG__H + +void mgc_mon(void); +int mgc_debug_set(void); +int mgc_asciout_proc(BYTE *out_str); +int mgc_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc); +int mgc_log_err(char *err_msg); +int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg); + +#endif diff --git a/omc/plat/mgc/src/include/mgc_def.h b/omc/plat/mgc/src/include/mgc_def.h new file mode 100644 index 0000000..ab94771 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_def.h @@ -0,0 +1,74 @@ +#ifndef _MGC_DEF__H +#define _MGC_DEF__H + +#include "mgc_pub.h" +#include "mgc.h" +#include "mgc_const.h" +#include "mgc_struct.h" + +DWORD sysID; +DWORD localIP; +DWORD peerIP; + +_8ECP_SAP mgc8ecpSap; +MGCP_SAP mgcMgcpSap; +int mgc8ecpSapIndex; +int mgcMgcpSapIndex; +MGC_SAP mgcSap[MGC_MAX_NUM_OF_SAP]; + +WORD mgcSelectPort; +WORD mgc_select_connection; +WORD mgc_select_ass_mgc_mgNo; + +WORD mgc_e1card0_mgNo; +WORD mgc_e1card1_mgNo; + +WORD mgc_aas_mgNo[MGC_MAX_NUM_OF_AAS_MGC]; + +WORD mgc_8k_tone_card_silent; + +MG_INFO mgcMgInfo[MGC_MAX_NUM_OF_MG]; +PHY_PORT_INFO mgcPhyPort[MGC_MAX_NUM_OF_PHY_PORT]; +CHNL_INFO mgcChnl[MGC_MAX_NUM_OF_CHNL]; +PORT_INFO mgcPort[MGC_MAX_NUM_OF_PORT]; + +MGCP_PARA mgcMgcpPara; + +CONNECT_INFO mgcConnectInfo[MGC_MAX_NUM_OF_CON]; + +WORD mgcMaxMgNo; +WORD mgcMaxChlNo; + +WORD mgcMgCreated; +WORD mgcChlAssigned; + +char vcName[MGC_VCTYPE_MAX][16]; + +const BYTE MGC_AC_LINE_STATUS_IDLEN = 12; + +DWORD MGC_AC_LINE_STATUS_OID[20] = +{ + 1,3,6,1,2,1,10,18,6,1,10,0 +}; + +const BYTE MGC_LGC_MG_STATUS_IDLEN = 13; + +DWORD MGC_LGC_MG_STATUS_OID[20] = +{ + 1,3,6,1,4,1,1373,2,2,30,2,1,0 +}; + +BYTE mgcAsciInBuf[MGC_MAX_ASCIIIN_LEN]; +BYTE mgcAsciOutBuf[MGC_MAX_ASCIIOUT_LEN]; +BYTE mgcAsciTempBuf[MGC_MAX_ASCITMP_LEN]; +WORD mgcMonitorFg; + +const WORD MGC_TONE_NO_TO_PKG_SIG[16] = +{ + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, + MGC_PKG_SIG_G_RT, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_WT, + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ +}; + +#endif diff --git a/omc/plat/mgc/src/include/mgc_ext.h b/omc/plat/mgc/src/include/mgc_ext.h new file mode 100644 index 0000000..e6bdbb3 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_ext.h @@ -0,0 +1,39 @@ +#ifndef _MGC_EXT__H +#define _MGC_EXT__H + +#include "mgc_pub.h" +#include "mgc.h" +#include "mgc_const.h" +#include "mgc_struct.h" + +extern _8ECP_SAP mgc8ecpSap; +extern MGCP_SAP mgcMgcpSap; +extern int mgc8ecpSapIndex; +extern int mgcMgcpSapIndex; +extern MGC_SAP mgcSap[MGC_MAX_NUM_OF_SAP]; + +extern MG_INFO mgcMgInfo[MGC_MAX_NUM_OF_MG]; +extern PHY_PORT_INFO mgcPhyPort[MGC_MAX_NUM_OF_PHY_PORT]; +extern CHNL_INFO mgcChnl[MGC_MAX_NUM_OF_CHNL]; +extern PORT_INFO mgcPort[MGC_MAX_NUM_OF_PORT]; + +extern MGCP_PARA mgcMgcpPara; + +extern WORD mgcMaxMgNo; +extern WORD mgcMaxChlNo; + +extern WORD mgcMgCreated; +extern WORD mgcChlAssigned; + +extern CONNECT_INFO mgcConnectInfo[MGC_MAX_NUM_OF_CON]; + +extern char vcName[MGC_VCTYPE_MAX][16]; + +extern BYTE mgcAsciInBuf[MGC_MAX_ASCIIIN_LEN]; +extern BYTE mgcAsciOutBuf[MGC_MAX_ASCIIOUT_LEN]; +extern BYTE mgcAsciTempBuf[MGC_MAX_ASCITMP_LEN]; +extern WORD mgcMonitorFg; + +extern const WORD MGC_TONE_NO_TO_PKG_SIG[16]; + +#endif diff --git a/omc/plat/mgc/src/include/mgc_fsm.h b/omc/plat/mgc/src/include/mgc_fsm.h new file mode 100644 index 0000000..6ac25df --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_fsm.h @@ -0,0 +1,11 @@ +#ifndef _MGC_FSM__H +#define _MGC_FSM__H + +#include "mgc_pub.h" +#include "mgc.h" +#include "mgc_const.h" +#include "mgc_struct.h" + +void mgc_fsm(WORD port); + +#endif diff --git a/omc/plat/mgc/src/include/mgc_pub.h b/omc/plat/mgc/src/include/mgc_pub.h new file mode 100644 index 0000000..d8dc111 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_pub.h @@ -0,0 +1,7 @@ +#ifndef _MGC_PUB__H +#define _MGC_PUB__H + +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" + +#endif diff --git a/omc/plat/mgc/src/include/mgc_sess_ctl.h b/omc/plat/mgc/src/include/mgc_sess_ctl.h new file mode 100644 index 0000000..7c1d7a7 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_sess_ctl.h @@ -0,0 +1,40 @@ +#ifndef _MGC_SESS_CTL_H +#define _MGC_SESS_CTL_H +#include "mgc_pub.h" +#include "mgc.h" +#include "mgc_const.h" +#include "mgc_ext.h" +#include "mgc_struct.h" +#include "mgc_debug.h" + +#define MGC_SESS_RECORD 8192 +#define MGC_SDP_IPADDR_LEN 35 +typedef struct _MGC_SDP_TAG +{ + PUB_SDP_MEDIA m; + PUB_SDP_C c; + BYTE mode; +}MGC_SDP_TAG; + +typedef enum{ + MGC_SESS_STATUS_UNDEF =-1, + MGC_SESS_STATUS_IDLE, + MGC_SESS_STATUS_USED +}MGC_SESS_STATUS; + +typedef struct _MGC_SESS_REC +{ + int id; + MGC_SESS_STATUS status; + CHNL chnl; + MGC_SDP_TAG sdpTag; +}MGC_SESS_REC; + +void mgc_sess_init(void); +void mgc_sess_rec_init(MGC_SESS_REC *pSess , int id); +MGC_SESS_REC *mgc_sess_is_already_rec(CHNL chnl); +BOOL mgc_sess_rec_org_and_dst_chnl(CHNL orgChnl , CHNL destChnl); +BOOL mgc_sess_is_chnl_need_update(CHNL chnl, MGCP_PARA *pPara); + +#endif + diff --git a/omc/plat/mgc/src/include/mgc_struct.h b/omc/plat/mgc/src/include/mgc_struct.h new file mode 100644 index 0000000..11c20f1 --- /dev/null +++ b/omc/plat/mgc/src/include/mgc_struct.h @@ -0,0 +1,114 @@ +#ifndef _MGC_STRUCT__H +#define _MGC_STRUCT__H + +#include "mgc.h" +#include "mgc_const.h" + +typedef struct _MG_INFO +{ + BYTE created; // created flag; + BYTE status; // MG status: available/unavailable + BYTE stLast; // MG status last: available/unavailable + BYTE monFlag; + BYTE usrType; // user acts as a mg or mgc + DWORD auditTimer; + + MG_ATTR mgAttr; // MG attributes + + // number and index of the ports created on this MG, not applicable to virtual MG + BYTE portNum; + WORD portIndex[MGC_MAX_PHY_PORT_PER_MG];// max 32 physical ports per MG + + // number and starting index of the channel created on this MG, only applicable to virtual MG + WORD chnlNum; + WORD chnlStartIndex; + BYTE sapIndex[MGC_MAX_NUM_OF_SAP]; + + DWORD requestId; // SNMP request id +}MG_INFO; + +typedef struct _PHY_PORT_INFO +{ + BYTE created; // created flag + BYTE mgNo; // mg No. this port resides on + BYTE portNo; // mg local physical port No. + BYTE portType; // port type: E1/T1/analogue + BYTE sapIndex; // sap index, indicating which user creates this port + BYTE phyStatus; // physical port status: online/offline + BYTE stLast; // physical port status: online/offline + BYTE monFlag; + + // number and starting index of the channel created on this port, not applicable to virtual MG + BYTE chnlNum; // depend on mg type + WORD chnlStartIndex; +}PHY_PORT_INFO; + +typedef struct _CHNL_INFO +{ + BYTE assigned; // assigned flag + BYTE mgNo; // mg No. this channel resides on + BYTE portNo; // mg local physical port No., not applicable to virtual MG + BYTE status; // connection status, created or not + WORD port; // which port is in handling this channel + BYTE sapIndex; // sap index, indicating which user creates this channel, applicable for ANN MG + BYTE monFlag; // monitor flag + BYTE auepSt; // AUEP status + WORD connectNum; + + WORD connectIndex[MGC_MAX_NUM_OF_CHNL_CON]; //Media Index + MEDIA_ATTR comMediaAttr; + + +// MGC_CODEC_LIST codecList; // list of codecs that this channel may negotiate with other channel +// MEDIA_ATTR mediaAttr; // media info of this channel +}CHNL_INFO; + +typedef struct _CONNECT_INFO +{ + BYTE assigned; + WORD chlIndex; + WORD port; // which port is in handling this connection + BYTE status; + CHNL aasChnl; + DWORD flag; + + MGC_CODEC_LIST codecList; + MEDIA_ATTR mediaAttr; + OPER_REC operRec; +}CONNECT_INFO; + +typedef struct _MGCF_OPER_STEP +{ + CHNL localChnl; // local channel to be operated, mandatory + CHNL remChnl; // remote channel to be operated, optional + BYTE cmd; // operation command + DWORD delay; // delay after the operation + WORD pkgSignal; // package + signal + MEDIA_PARA media; // media para + + WORD chnlConnectIndex; //chnl connectIndex + + WORD flag; +}MGCF_OPER_STEP; + +typedef struct _PORT_INFO +{ + BYTE assigned; + BYTE mgcfState; // mgcf state + BYTE mgcfState2; // mgcf state2 + WORD mgcfTimer; // mgcf timer + CHNL mgcfChnl; // current operation channel + WORD usrPort; // user port + WORD llPort; // lower layer port + WORD usrCmd; // user command or response + WORD llCmd; // lower layer command or response + BYTE mngCmd; // management commmand + DWORD ip; + + BYTE mgcfOperId; + BYTE mgcfOperStepsNum; // total number of operation steps + BYTE mgcfOperStepIndex; // current operation step index + MGCF_OPER_STEP mgcfOperSteps[MGC_MAX_OPER_STEPS_NUM]; // max 8 steps +}PORT_INFO; + +#endif diff --git a/omc/plat/mgc/src/mgc.c b/omc/plat/mgc/src/mgc.c new file mode 100644 index 0000000..eaed12d --- /dev/null +++ b/omc/plat/mgc/src/mgc.c @@ -0,0 +1,4697 @@ +/****************************************************************/ +/* MGC Implementation Program */ +/* Version 9.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2007-4-17 */ +/****************************************************************/ + +#include "./include/mgc_pub.h" +#include "./include/mgc.h" +#include "./include/mgc_const.h" +#include "./include/mgc_def.h" +#include "./include/mgc_struct.h" +#include "./include/mgc_fsm.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_sess_ctl.h" +#include "../../snmp/src/include/snmp.h" +#include "../../public/src/include/license_id.h" + +int mgc_is_non_virtual_mg(BYTE mgType) +{ + if ((mgType > MGC_MG_TYPE_INTERNAL) && (mgType < MGC_MG_TYPE_ANN)) + { + return 1; + } + else + { + return 0; + } + +} + +int mgc_codec_to_payload(BYTE codec) +{ + if (codec== MGC_VCTYPE_GSM) + return 3; + else if (codec == MGC_VCTYPE_GSM_EFR) + return 84; + else if (codec == MGC_VCTYPE_AMR_12_2) + return 71; + else if (codec== MGC_VCTYPE_G729B) + return 118; + else if (codec== MGC_VCTYPE_PCMU) + return 0; + else if(codec == MGC_VCTYPE_AMR_10_2) + return 70; + else if(codec == MGC_VCTYPE_AMR_7_95) + return 69; + else if(codec == MGC_VCTYPE_AMR_7_4) + return 68; + else if(codec == MGC_VCTYPE_AMR_6_7) + return 67; + else if(codec == MGC_VCTYPE_AMR_5_15) + return 65; + else if(codec == MGC_VCTYPE_AMR_5_9) + return 66; + else if(codec == MGC_VCTYPE_AMR_4_75) + return 64; + return 8; +} + +int mgc_8ecp_update_mg_status(BYTE mgNo, BYTE status) +{ + char tmpStr[128]; + + if (mgcMgInfo[mgNo].created == 0) + { + sprintf(tmpStr, "mgc_8ecp_update_mg_status: MG not created, mgNo = %d\n\r", mgNo); + mgc_log_err(tmpStr); + return -1; + } + + mgcMgInfo[mgNo].stLast = status; + + if (1 == mgcMgInfo[mgNo].mgAttr.e1cardNo) + { + if ((1 == status) + && ((0 == mgc_e1card0_mgNo) || (0 == mgcMgInfo[mgc_e1card0_mgNo].stLast))) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + } + } + else if (0 == mgcMgInfo[mgNo].mgAttr.e1cardNo) + { + if ((0 == status) + && (0 != mgc_e1card1_mgNo) && (1 == mgcMgInfo[mgc_e1card1_mgNo].stLast)) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + } + } + + return 0; +} + +int mgc_8ecp_update_trk_status(BYTE mgNo, BYTE trkNo, BYTE status) +{ + WORD portIndex; + char tmpStr[128]; + + if (mgcMgInfo[mgNo].created == 0) + { + sprintf(tmpStr, "mgc_8ecp_update_trk_status: MG not created, mgNo = %d\n\r", mgNo); + mgc_log_err(tmpStr); + return -1; + } + + if (trkNo >= MGC_8ECP_MAX_TRK_PER_MG) + { + sprintf(tmpStr, "mgc_8ecp_update_trk_status: invalid trkNo, trkNo = %d\n\r", trkNo); + mgc_log_err(tmpStr); + return -1; + } + + portIndex = mgcMgInfo[mgNo].portIndex[trkNo]; + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + return -1; + + mgcPhyPort[portIndex].stLast = status; + + return 0; +} + +int mgc_bind_8ecp() +{ + sprintf(mgc8ecpSap.name, "MGC"); + mgc8ecpSap.update_mg_status = mgc_8ecp_update_mg_status; + mgc8ecpSap.update_trk_status = mgc_8ecp_update_trk_status; + + if ((mgc8ecpSapIndex = _8ecp_bind(&mgc8ecpSap)) < 0) + return -1; + + return 0; +} + +int mgc_find_mg_by_name(char *mgName, WORD localPort, DWORD ip) +{ + WORD i; + char tmpStr[128]; + BYTE usrType; + + if (MGC_MG_NETWORK_PORT == localPort) + { + usrType = MGC_USER_TYPE_MG; + } + else + { + usrType = MGC_USER_TYPE_MGC; + } + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 0) + continue; + + if ((strcmp(mgcMgInfo[i].mgAttr.domain, mgName) == 0) + && (mgcMgInfo[i].usrType == usrType)) + return i; + } + + sprintf(tmpStr, "mgc_find_mg_by_name: invalid mgName: %s, ip: %ld\n\r", mgName, ip); + mgc_log_err(tmpStr); + + return -1; +} + +int mgc_codec_str_to_api(char *codec) +{ + if (strcmp(codec, "PCMA") == 0) + return MGC_VCTYPE_PCMA; + else if (strcmp(codec, "PCMU") == 0) + return MGC_VCTYPE_PCMU; + else if (strcmp(codec, "GSM") == 0) + return MGC_VCTYPE_GSM; + else if (strcmp(codec, "GSM-EFR") == 0) + return MGC_VCTYPE_GSM_EFR; + else if (strcmp(codec, "AMR") == 0) + return MGC_VCTYPE_AMR_12_2; + else if (strcmp(codec, "G729B") == 0) + return MGC_VCTYPE_G729B; + else if (strcmp(codec, "AMR_12_2") == 0) + return MGC_VCTYPE_AMR_12_2; + else if (strcmp(codec, "AMR_10_2") == 0) + return MGC_VCTYPE_AMR_10_2; + else if (strcmp(codec, "AMR_7_95") == 0) + return MGC_VCTYPE_AMR_7_95; + else if (strcmp(codec, "AMR_7_4") == 0) + return MGC_VCTYPE_AMR_7_4; + else if (strcmp(codec, "AMR_6_7") == 0) + return MGC_VCTYPE_AMR_6_7; + else if (strcmp(codec, "AMR_5_15") == 0) + return MGC_VCTYPE_AMR_5_15; + else if (strcmp(codec, "AMR_5_9") == 0) + return MGC_VCTYPE_AMR_5_9; + else if (strcmp(codec, "AMR_4_75") == 0) + return MGC_VCTYPE_AMR_4_75; + + return MGC_VCTYPE_PCMA; +} + +void mgc_connect_init(WORD connectIndex) +{ + memset((BYTE *) &mgcConnectInfo[connectIndex], 0, sizeof(CONNECT_INFO)); + mgcConnectInfo[connectIndex].port = 0xFFFF; + mgcConnectInfo[connectIndex].chlIndex = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.mgNo = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.portNo = 0xFF; + mgcConnectInfo[connectIndex].aasChnl.chlNo = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.connectNo = 0xFFFF; +} + +int mgc_assign_connect_to_chnl(CHNL chnl) +{ + WORD portIndex; + WORD chnlIndex; + WORD connectIndex = mgc_select_connection; + CHNL_INFO *chnlInfo; + int i; + + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_select_connection may be changed\n\r"); + + connectIndex = 0; + } + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if (1 == mgcConnectInfo[connectIndex].assigned) + { + if (++connectIndex >= MGC_MAX_NUM_OF_CON) + { + connectIndex = 0; + } + + continue; + } + else + { + mgc_connect_init(connectIndex); + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_assign_connect_to_chnl: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl.chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_assign_connect_to_chnl: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if ((chnlInfo->connectIndex[chnl.connectNo] >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[chnlInfo->connectIndex[chnl.connectNo]].assigned != 1)) + { + chnlInfo->connectIndex[chnl.connectNo] = connectIndex; + + mgcConnectInfo[connectIndex].assigned = 1; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + mgcConnectInfo[connectIndex].chlIndex = chnlIndex; + + mgc_select_connection = connectIndex + 1; + + if (mgc_select_connection >= MGC_MAX_NUM_OF_CON) + { + mgc_select_connection = 0; + } + + return connectIndex; + } + else + { + if ((chnlInfo->connectIndex[chnl.connectNo] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[chnlInfo->connectIndex[chnl.connectNo]].assigned == 1)) + { + mgc_log_err("mgc_assign_connect_to_chnl: one connect already created on chnl's connectNo\n\r"); + return chnlInfo->connectIndex[chnl.connectNo]; + } + + return -1; + } + } + } + + mgc_log_err("mgc_assign_connect_to_chnl: connect resource is not sufficient\n\r"); + return -1; +} + +int mgc_assign_connect(CHNL *chnl, WORD *chnlConnectIndex) +{ + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + WORD connectIndex = mgc_select_connection; + int i; + int j; + + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_select_connection may be changed\n\r"); + + connectIndex = 0; + } + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if (1 == mgcConnectInfo[connectIndex].assigned) + { + if (++connectIndex >= MGC_MAX_NUM_OF_CON) + { + connectIndex = 0; + } + + continue; + } + else + { + mgc_connect_init(connectIndex); + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl->mgNo].chnlStartIndex + chnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl->mgNo].portIndex[chnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_assign_connect: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_assign_connect: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + for (j = 0; j < MGC_MAX_NUM_OF_CHNL_CON; j++) + { + if ((chnlInfo->connectIndex[j] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[chnlInfo->connectIndex[j]].assigned == 1)) + { + continue; + } + else + { + chnlInfo->connectIndex[j] = connectIndex; + *chnlConnectIndex = j; + chnl->connectNo = j; + + mgcConnectInfo[connectIndex].assigned = 1; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + mgcConnectInfo[connectIndex].chlIndex = chnlIndex; + + mgc_select_connection = connectIndex + 1; + + if (mgc_select_connection >= MGC_MAX_NUM_OF_CON) + { + mgc_select_connection = 0; + } + + return connectIndex; + } + } + + mgc_log_err("mgc_assign_connect: chnl connect resource is not sufficient\n\r"); + return -1; + } + } + + mgc_log_err("mgc_assign_connect: connect resource is not sufficient\n\r"); + return -1; +} + +void mgc_remove_connect(WORD chnl) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if ((mgcConnectInfo[i].assigned != 1) + || (mgcConnectInfo[i].chlIndex != chnl)) + { + continue; + } + else + { + mgc_connect_init(i); + } + } +} + +int mgc_release_connect(CHNL *chnl) +{ + WORD portIndex; + WORD chnlIndex; + WORD connectIndex; + CHNL_INFO *chnlInfo; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl->mgNo].chnlStartIndex + chnl->chlNo; + chnlInfo = &mgcChnl[chnlIndex]; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl->mgNo].portIndex[chnl->portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl->chlNo; + chnlInfo = &mgcChnl[chnlIndex]; + } + + + if (((connectIndex = chnlInfo->connectIndex[chnl->connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[connectIndex].chlIndex != chnlIndex)) + { + mgc_log_err("mgc_release_connect: the chnl connectNo has no connection\n\r"); + return -1; + } + else + { + mgc_connect_init(connectIndex); + + if (chnlInfo->connectNum > 0) + { + chnlInfo->connectNum--; + } + else + { + chnlInfo->connectNum = 0; + } + } + + return 0; +} + +int mgc_find_connect_by_con_id(CHNL *Chnl, char *conId) +{ + int i; + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + WORD chnlConnectIndex; + WORD connectIndex; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[Chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[Chnl->mgNo].chnlStartIndex + Chnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[Chnl->mgNo].portIndex[Chnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_find_connect_by_con_id: portIndex out of range!\r\n"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + Chnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_find_connect_by_con_id: chnlIndex out of range!\r\n"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if (mgcMgInfo[Chnl->mgNo].usrType == MGC_USER_TYPE_MG) + { + chnlConnectIndex = strtoll(conId, NULL, 16) >> 48; + + if ((chnlConnectIndex >= MGC_MAX_NUM_OF_CHNL_CON) + || (chnlInfo->connectIndex[chnlConnectIndex] >= MGC_MAX_NUM_OF_CON) + || (strcmp(conId, mgcConnectInfo[chnlInfo->connectIndex[chnlConnectIndex]].mediaAttr.conId) != 0)) + return -1; + else + return chnlConnectIndex; + } + else if (mgcMgInfo[Chnl->mgNo].usrType == MGC_USER_TYPE_MGC) + { + for (i = 0; i < MGC_MAX_NUM_OF_CHNL_CON; i++) + { + if ((connectIndex = chnlInfo->connectIndex[i]) >= MGC_MAX_NUM_OF_CON) + { + continue; + } + else + { + if ((0 == strcmp(conId, mgcConnectInfo[connectIndex].mediaAttr.conId)) + && (chnlIndex == mgcConnectInfo[connectIndex].chlIndex)) + { + return i; + } + } + } + + return -1; + } + else + return -1; +} + + +int mgc_extract_media_info(BYTE flag, BYTE cmd, MGCP_PARA *para, WORD port)//new replace +//int mgc_extract_media_info(BYTE flag, MGCP_PARA *para, CHNL *mgcfChnl) +{ + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + CHNL *mgcfChnl; + int connectIndex; + int chnlConnectIndex;//new replace + PORT_INFO *portInfo; + + portInfo = &mgcPort[port]; + mgcfChnl = &portInfo->mgcfChnl;//new replace + + if (((MGC_MG_TYPE_ANN != mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) && (mgcfChnl->portNo >= MGC_MAX_PHY_PORT_PER_MG)) + || (mgcfChnl->chlNo >= MGC_MAX_NUM_OF_CHNL)) + return 0; + + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[mgcfChnl->mgNo].chnlStartIndex + mgcfChnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[mgcfChnl->mgNo].portIndex[mgcfChnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_extract_media_info: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + mgcfChnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_extract_media_info: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if (flag == MGCP_RESPONSE) + { + if ((MGC_MG_TYPE_ANN != mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) && (MGCP_CMD_CRCX == cmd) + && (((para->flag & MGCP_PARA_FLAG_I) != MGCP_PARA_FLAG_I) || ((para->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP))) + { + mgc_log_err("mgc_extract_media_info: crcx response miss para!!\n\r"); + return -4; + } + + if (mgcfChnl->connectNo != mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].chnlConnectIndex) + { + mgc_log_err("mgc_extract_media_info: connectNo is mismatch!\n\r"); + return -1; + } + + if((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd) && (MGCP_CMD_RSIP != cmd)) + { + connectIndex = chnlInfo->connectIndex[mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].chnlConnectIndex]; + } + + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_extract_media_info: chnl's connection released\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_I) == MGCP_PARA_FLAG_I) + { + strcpy(mgcConnectInfo[connectIndex].mediaAttr.conId, para->i.conId); + } + + if ((para->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + chnlInfo->comMediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + + if ((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd)) + mgcConnectInfo[connectIndex].mediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + } + } + else + { + if (MGCP_CMD_CRCX == cmd) + { + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) && ((para->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP)) + { + mgc_log_err("mgc_extract_media_info: crcx command miss sdp!!\n\r"); + return -2; + } + + if ((connectIndex = mgc_assign_connect(mgcfChnl, &mgcPort[port].mgcfOperSteps[0].chnlConnectIndex)) < 0) + { + mgc_log_err("mgc_extract_media_info: assign connect failed\n\r"); + return -3; + } + + mgcPort[port].mgcfOperStepsNum = 1; + } + else if ((MGCP_CMD_MDCX == cmd) || (MGCP_CMD_DLCX == cmd)) + { + if ((chnlConnectIndex = mgc_find_connect_by_con_id(mgcfChnl, para->i.conId)) < 0) + { + mgc_log_err("mgc_extract_media_info: find connect by id failed\n\r"); + return -1; + } + + mgcfChnl->connectNo = chnlConnectIndex; + + connectIndex = chnlInfo->connectIndex[chnlConnectIndex]; + } + else if((MGCP_CMD_NTFY == cmd)&&((para->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O)) + { + chnlInfo->comMediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + return 0; + } +/* else + { + if (0xFFFF == (connectIndex = chnlInfo->connectIndex[0])) + { + mgc_log_err("mgc_extract_media_info: chnl's 0 connection released\n\r"); + return -1; + } + } +*/ + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_extract_media_info: chnl's connection released\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_L) == MGCP_PARA_FLAG_L) + { + mgcConnectInfo[connectIndex].mediaAttr.ecDisable = para->l.ecDisable; + mgcConnectInfo[connectIndex].mediaAttr.ssDisable = para->l.ssDisable; + mgcConnectInfo[connectIndex].mediaAttr.ptime = para->l.p; + mgcConnectInfo[connectIndex].mediaAttr.vocoderType = mgc_codec_str_to_api(para->l.codec); + } + + if ((para->flag & MGCP_PARA_FLAG_M) == MGCP_PARA_FLAG_M) + mgcConnectInfo[connectIndex].mediaAttr.conMode = para->m.mode; + + if ((para->flag & MGCP_PARA_FLAG_C) == MGCP_PARA_FLAG_C) + strcpy(mgcConnectInfo[connectIndex].mediaAttr.callId, para->c.callId); + + if ((para->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + chnlInfo->comMediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + mgcConnectInfo[connectIndex].mediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + } + + if ((para->flag & MGCP_PARA_FLAG_S) == MGCP_PARA_FLAG_S) + { + chnlInfo->comMediaAttr.pkgSignal = (para->s.pkg << 8) | para->s.signal; + mgcConnectInfo[connectIndex].mediaAttr.pkgSignal = (para->s.pkg << 8) | para->s.signal; + } + } + + if ((para->flag & MGCP_PARA_FLAG_SDP) == MGCP_PARA_FLAG_SDP) + { + if (flag == MGCP_RESPONSE) + { + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcConnectInfo[connectIndex].flag |= MGCP_PARA_FLAG_TFO; + memcpy(para->sdp.medias.medias, mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias, sizeof(PUB_SDP_MEDIA) * 8); + } + else + { + mgcConnectInfo[connectIndex].flag &= ~MGCP_PARA_FLAG_TFO; + } + } +/* + if (mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) + { + num = para->sdp.medias.medias[0].m.plNum; + for (i = 0; i < mgcMgInfo[mgcfChnl->mgNo].mgAttr.codecList.num; i++) + { + para->sdp.medias.medias[0].m.payloads[num + i] = mgc_codec_to_payload(mgcMgInfo[mgcfChnl->mgNo].mgAttr.codecList.codec[i]); + para->sdp.medias.medias[0].m.plNum++; + + if (para->sdp.medias.medias[0].m.plNum >= 8) + break; + } + }*/ + + //memcpy((BYTE *) &chnlInfo->mediaAttr.sdp, (BYTE *) ¶->sdp, sizeof(PUB_SDP_MSG)); + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, (BYTE *) ¶->sdp, sizeof(PUB_SDP_MSG)); + } + + if ((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd)) + { + if ((mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].flag & PUB_SDP_FLAG_C) != PUB_SDP_FLAG_C) + //if ((chnlInfo->mediaAttr.sdp.medias.medias[0].flag & PUB_SDP_FLAG_C) != PUB_SDP_FLAG_C) + { + //memcpy(&chnlInfo->mediaAttr.sdp.medias.medias[0].c, &chnlInfo->mediaAttr.sdp.c, sizeof(PUB_SDP_C)); + //chnlInfo->mediaAttr.sdp.medias.medias[0].flag |= PUB_SDP_FLAG_C; + memcpy(&mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].c, &mgcConnectInfo[connectIndex].mediaAttr.sdp.c, sizeof(PUB_SDP_C)); + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].flag |= PUB_SDP_FLAG_C; + } +/* + num = mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.num; + //num = chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.num; + if (num < PUB_SDP_MAX_ATTR_NUM) + { + //chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aType = PUB_SDP_ATTR_TYPE_PTIME; + //sprintf(chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aValue, "%d", chnlInfo->mediaAttr.ptime); + //chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.num++; + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aType = PUB_SDP_ATTR_TYPE_PTIME; + sprintf(mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aValue, "%d", mgcConnectInfo[connectIndex].mediaAttr.ptime); + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.num++; + }*/ + } + + return 0; +} + +void mgc_port_init(WORD port) +{ + memset((BYTE *) &mgcPort[port], 0, sizeof(PORT_INFO)); +} + +int mgc_get_port() +{ + WORD i; + WORD port = mgcSelectPort; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + mgc_log_err("mgcSelectPort may be changed\n\r"); + + port = 0; + } + + for (i = 0; i < MGC_MAX_NUM_OF_PORT; i++) + { + if (mgcPort[port].assigned != 0) + { + if (++port >= MGC_MAX_NUM_OF_PORT) + { + port = 0; + } + continue; + } + + mgcPort[port].assigned = 1; + + mgcSelectPort = port + 1; + if (mgcSelectPort >= MGC_MAX_NUM_OF_PORT) + { + mgcSelectPort = 0; + } + return port; + } + + return -1; +} + +int mgc_mgcp_ind(BYTE cmd, WORD *usrPort, WORD hdlPort, MGCP_PARA *para) +{ + int ret; + int port; + int mgNo; + PORT_INFO *portInfo; + MGCP_SL *sl; + WORD portIndex = 0xFFFF, chnlIndex = 0xFFFF; + char tmpStr[128]; + MG_ATTR *mgAttr; + WORD associPort; + + if (para == NULL) + { + mgc_log_err("mgc_mgcp_ind: para is NULL\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_SL) != MGCP_PARA_FLAG_SL) + { + mgc_log_err("mgc_mgcp_ind: missing start line\n\r"); + return -1; + } + + sl = ¶->sl; + if ((mgNo = mgc_find_mg_by_name(sl->mgName, para->localPort, para->ip)) < 0) + { + mgc_log_err("mgc_mgcp_ind: can't find the mgName\n\r"); + return -1; + } + + if ((mgcMgInfo[mgNo].portIndex[sl->trkNum] >= MGC_MAX_NUM_OF_PHY_PORT) + && (cmd == MGCP_CMD_RSIP)) + { + mgcMgcpPara.ip = mgcMgInfo[mgNo].mgAttr.ip; + + if (mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MGC) + { + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + } + else + { + mgcMgcpPara.localPort = MGC_MGCP_MG_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MGC_PORT; + } + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = MGCP_RESPONSE; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + MGCP_rsp(mgcMgcpSapIndex, cmd, 0xFFFF, hdlPort, 200, &mgcMgcpPara); + return 0; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mgcp_ind: can't allocate port\n\r"); + return -1; + } + + mgAttr = &mgcMgInfo[mgNo].mgAttr; + + portInfo = &mgcPort[port]; + portInfo->mgcfState = MGC_MGCF_STATE_INDICATION; + portInfo->llPort = hdlPort; + portInfo->llCmd = cmd; + + if (mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MG) + portInfo->ip = para->ip; + + portInfo->mgcfChnl.mgNo = mgNo; + portInfo->mgcfChnl.portNo = sl->trkNum; + portInfo->mgcfChnl.chlNo = sl->chlNum; + + if ((MGCP_CMD_CRCX == cmd) || (MGCP_CMD_MDCX == cmd) || (MGCP_CMD_DLCX == cmd)||(MGCP_CMD_NTFY == cmd)) + { + if ((ret = mgc_extract_media_info(MGCP_COMMAND, cmd, para, port)) < 0) + { + if (ret == -2) + { + mgc_log_err("mgc_mgcp_ind: crcx command to aas miss sdp!\n\r"); + mgc_port_init(port); + return -1; + } + else if (ret == -3) + { + mgc_log_err("mgc_mgcp_ind: aas mg no connection resource!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + mgc_log_err("mgc_mgcp_ind: extract media info failed!\n\r"); + mgc_port_init(port); + return -1; + } + } + } + + *usrPort = port; + + if (sl->trkNum < MGC_MAX_PHY_PORT_PER_MG) + { + portIndex = mgcMgInfo[mgNo].portIndex[sl->trkNum]; + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && + (sl->chlNum < mgcPhyPort[portIndex].chnlNum)) + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + sl->chlNum; + } + else + { + chnlIndex = mgcMgInfo[mgNo].chnlStartIndex + sl->chlNum; + } + + sprintf(tmpStr, "mgc_mgcp_ind: succeed, cmd = %d, usrPort = %d, hdlPort = %d, mgNo: %d, portNo: %d, chlNo: %d\n\r", + cmd, port, hdlPort, portInfo->mgcfChnl.mgNo, portInfo->mgcfChnl.portNo, portInfo->mgcfChnl.chlNo); + mgc_log_procedure(mgNo, portIndex, chnlIndex, tmpStr); + + if ((mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MGC) + && (cmd != MGCP_CMD_RSIP) && (cmd != MGCP_CMD_NTFY)) + { + if ((portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + || (mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo] >= MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_mgcp_ind: connectNo >= MGC_MAX_NUM_OF_CHNL_CON\n\r"); + mgc_port_init(port); + return -1; + } + + associPort = mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]].port; + + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_CLEAR_AFTER_OPER; + mgc_log_err("mgc_mgcp_ind: DLCX recved from MG, Chnl clear remain connection operation !\n\r"); + + mgcMgcpPara.ip = mgcMgInfo[mgNo].mgAttr.ip; + + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = MGCP_RESPONSE; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + MGCP_rsp(mgcMgcpSapIndex, cmd, port, hdlPort, 250, &mgcMgcpPara); + +// mgc_connect_init(mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]); + mgc_port_init(port); + } + } + + return 0; +} + +int mgc_mgcp_cnf(BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para) +{ + char tmpStr[128]; + + if (usrPort >= MGC_MAX_NUM_OF_PORT) + { + sprintf(tmpStr, "mgc_mgcp_cnf, invalid usrPort = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", usrPort, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (mgcPort[usrPort].llPort != hdlPort) + { + sprintf(tmpStr, "mgc_mgcp_cnf, mismatched llport = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", mgcPort[usrPort].llPort, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (mgcPort[usrPort].mgcfOperSteps[mgcPort[usrPort].mgcfOperStepIndex].cmd != cmd) + { + sprintf(tmpStr, "mgc_mgcp_cnf, mismatched cmd = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", + mgcPort[usrPort].mgcfOperSteps[mgcPort[usrPort].mgcfOperStepIndex].cmd, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (((MGCP_CMD_CRCX == cmd) && (retCode == 200)) || (MGCP_CMD_MDCX == cmd)) + { + +// mgc_extract_media_info(MGCP_RESPONSE, para, &mgcPort[usrPort].mgcfChnl); + if (mgc_extract_media_info(MGCP_RESPONSE, cmd, para, usrPort) < 0)//new replace + { + sprintf(tmpStr, "mgc_mgcp_cnf: extract_media fail cmd = %d, hdlPort = %d, retCode = %d\n\r", cmd, hdlPort, retCode); + mgc_log_err(tmpStr); + return -1; + } + } + + mgcPort[usrPort].llCmd = retCode; + + return 0; +} + +int mgc_bind_mgcp() +{ + sprintf(mgcMgcpSap.name, "MGC"); + mgcMgcpSap.MGCP_ind = mgc_mgcp_ind; + mgcMgcpSap.MGCP_cnf = mgc_mgcp_cnf; + + if ((mgcMgcpSapIndex = mgcp_bind(&mgcMgcpSap)) < 0) + return -1; + + return 0; +} + +void mgc_chnl_init(WORD chnl) +{ + memset((BYTE *) &mgcChnl[chnl], 0, sizeof(CHNL_INFO)); + memset((BYTE *) mgcChnl[chnl].connectIndex, 0xFFFF, sizeof(WORD)*MGC_MAX_NUM_OF_CHNL_CON);//new replace + mgcChnl[chnl].port = 0xFFFF; + mgcChnl[chnl].sapIndex = 0xFF; +} + +int mgc_vc_name_init() +{ + strcpy(vcName[MGC_VCTYPE_PCMA], "PCMA"); + strcpy(vcName[MGC_VCTYPE_PCMU], "PCMU"); + strcpy(vcName[MGC_VCTYPE_GSM], "GSM"); + strcpy(vcName[MGC_VCTYPE_GSM_EFR], "GSM-EFR"); + strcpy(vcName[MGC_VCTYPE_AMR_12_2], "AMR_12_2"); + strcpy(vcName[MGC_VCTYPE_G729B], "G729B"); + strcpy(vcName[MGC_VCTYPE_AMR_10_2], "AMR_10_2"); + strcpy(vcName[MGC_VCTYPE_AMR_7_95], "AMR_7_95"); + strcpy(vcName[MGC_VCTYPE_AMR_7_4], "AMR_7_4"); + strcpy(vcName[MGC_VCTYPE_AMR_6_7], "AMR_6_7"); + strcpy(vcName[MGC_VCTYPE_AMR_5_15], "AMR_5_15"); + strcpy(vcName[MGC_VCTYPE_AMR_5_9], "AMR_5_9"); + strcpy(vcName[MGC_VCTYPE_AMR_4_75], "AMR_4_75"); + return 0; +} + +int mgc_get_non_virtual_trk_status(WORD mgNo) +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, j = 0; + MG_INFO *mgInfo; + + mgInfo = &mgcMgInfo[mgNo]; + mgcVarList = &mgcSnmpPdu.var[0]; + mgcSnmpPdu.var_num = 0; //val list number + + if (MGC_MG_TYPE_AudioCoder == mgInfo->mgAttr.mgType) + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgInfo->portIndex[i] != 0xFFFF) + { + mgcVarList[j].oidlen = MGC_AC_LINE_STATUS_IDLEN; + MGC_AC_LINE_STATUS_OID[MGC_AC_LINE_STATUS_IDLEN - 1] = i; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_AC_LINE_STATUS_OID, MGC_AC_LINE_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + j++; + } + } + } + else if (MGC_MG_TYPE_LGC_MG == mgInfo->mgAttr.mgType) + { + mgcVarList[0].oidlen = MGC_LGC_MG_STATUS_IDLEN; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_LGC_MG_STATUS_OID, MGC_LGC_MG_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + }//revise by Francis 0822 + + mgInfo->requestId = (++mgInfo->requestId) & 0xFFFF; + if (mgInfo->requestId == 0) + mgInfo->requestId = 1; + + mgcSnmpPdu.pdu_type = 0x00; //get + mgcSnmpPdu.request_id = (mgNo << 16) | mgInfo->requestId; + + mgcSnmpAddr.local_port = 4968; + mgcSnmpAddr.remote_port = 161; + mgcSnmpAddr.broadcast = 0; //Not broadcast + mgcSnmpAddr.remote_ip = mgInfo->mgAttr.ip; + + if (mgcSnmpPdu.var_num) + snmp_send(&mgcSnmpPdu,&mgcSnmpAddr); + + return 1; +} + +int mgc_get_snmp_msg() +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, trkNo; + WORD mgNo, portIndex; + MG_INFO *mgInfo; + + mgcSnmpAddr.local_port = 4968; + if (!snmp_receive(&mgcSnmpPdu, &mgcSnmpAddr)) + return 0; + + if (mgcSnmpPdu.error_index != 0) + return -1; + + mgNo = mgcSnmpPdu.request_id >> 16; + mgInfo = &mgcMgInfo[mgNo]; + if ((mgcSnmpPdu.request_id & 0xFFFF) != mgInfo->requestId) + return -1; + + if (mgcSnmpPdu.var_num > MGC_MAX_PHY_PORT_PER_MG) + return -1; + + mgcVarList = &mgcSnmpPdu.var[0]; + + for (i = 0; i < mgcSnmpPdu.var_num; i++) + { + trkNo = mgcVarList[i].oid[MGC_AC_LINE_STATUS_IDLEN - 1]; + if (trkNo > (MGC_MAX_PHY_PORT_PER_MG - 1)) + return -1; + if ((portIndex = mgInfo->portIndex[trkNo]) != 0xFFFF) + { + if (mgcVarList[i].msg[0] == 1) + { // No Alarm + mgcPhyPort[portIndex].stLast = 1;//revise by Francis 0822 + } + else + { // Alarm + mgcPhyPort[portIndex].stLast = 0;//revise by Francis 0822 + } + } + } + + return 1; +} + +void mgc_get_mg_trk_status(WORD mg, BYTE stage) +{ + BYTE i; + WORD portIndex; + CHNL chnl = {0, 0, 0, 0}; +// static BYTE stage = 0; + +// stage++; + +// for (mg = 0; mg < MGC_MAX_NUM_OF_MG; mg++) +// { + if ((mgcMgInfo[mg].created == 0) || + ((!mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType)) && + (mgcMgInfo[mg].mgAttr.mgType != MGC_MG_TYPE_ANN))) + return; + + chnl.mgNo = mg; + chnl.chlNo = 1; + + if ((mgcMgInfo[mg].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_MGCP) + && (mgcMgInfo[mg].usrType == MGC_USER_TYPE_MGC)) + { + if (mgcMgInfo[mg].mgAttr.mgType == MGC_MG_TYPE_ANN)//revise by Francis 0822 + { + chnl.portNo = 0; + mgc_auep_chnl(0xFFFF, chnl); + } + else if (mgcMgInfo[mg].portNum > 0) + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgcMgInfo[mg].portIndex[i] == 0xFFFF) + continue; + else + { + chnl.portNo = i; + mgc_auep_chnl(0xFFFF, chnl); + break; + } + } + } + + if ((mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType)) + && (mgcMgInfo[mg].portNum > 0)) + { + if (MGC_MG_TYPE_SSW_CSS != mgcMgInfo[mg].mgAttr.mgType) + { + mgc_get_non_virtual_trk_status(mg); + }//revise by Francis 0822 + } + } + + if ((stage & 1) == 0) + { + mgcMgInfo[mg].status = mgcMgInfo[mg].stLast; + mgcMgInfo[mg].stLast = 0; + if (mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType))//revise by Francis 0822 + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + portIndex = mgcMgInfo[mg].portIndex[i]; + if (portIndex != 0xFFFF) + { + mgcPhyPort[portIndex].phyStatus = mgcPhyPort[portIndex].stLast; + mgcPhyPort[portIndex].stLast = 0; + } + } + } + } +// } +} + +void mgc_t10s() +{ +// static DWORD cntT10s = 0; + static DWORD cntT50ms = 0; + static BYTE stage[MGC_MAX_NUM_OF_MG] = {0}; + WORD i; + + if (++cntT50ms >= MGC_MGCF_TIMER_50MS) + { // 50 mini seconds period + cntT50ms = 0; + mgc_get_snmp_msg(); + mgc_mon(); + } + + for (i = 1; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 0) + continue; + + if (++mgcMgInfo[i].auditTimer >= mgcMgInfo[i].mgAttr.auditTimer) + { + stage[i]++; + mgcMgInfo[i].auditTimer = 0; + mgc_get_mg_trk_status(i, stage[i]); + } + } + +/* if (++cntT10s >= MGC_MGCF_TIMER_10S) + { // 10 seconds period + cntT10s = 0; + mgc_get_mg_trk_status(); + } +*/ +} + +int mgc_mg_init(WORD mgNo) +{ + memset((BYTE *) &mgcMgInfo[mgNo], 0, sizeof(MG_INFO)); + memset((BYTE *) &mgcMgInfo[mgNo].portIndex, 0xFFFF, sizeof(WORD) * MGC_MAX_PHY_PORT_PER_MG); + + return 0; +} + +void mgc_init(DWORD systemId, DWORD localIp, DWORD peerIp) +{ + WORD i; + MG_ATTR tmpMgAttr; + MG_ATTR *mgAttr = &tmpMgAttr; + + printf("MGC module init start!\n"); + if (mgc_bind_8ecp() < 0) + printf("MGC module binds 8ECP fail!\n"); + if (mgc_bind_mgcp() < 0) + printf("MGC module binds MGCP fail!\n"); + + memset((BYTE *) &mgcSap[0], 0, sizeof(MGC_SAP) * MGC_MAX_NUM_OF_SAP); + memset((BYTE *) &mgcPhyPort[0], 0, sizeof(PHY_PORT_INFO) * MGC_MAX_NUM_OF_PHY_PORT); + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + mgc_mg_init(i); + + for (i = 0; i < MGC_MAX_NUM_OF_PORT; i++) + mgc_port_init(i); + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + mgc_chnl_init(i); + + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + mgc_connect_init(i);//new replace + + mgc_sess_init(); + mgc_vc_name_init(); + + memset(mgc_aas_mgNo, 0xFFFF, sizeof(WORD)*MGC_MAX_NUM_OF_AAS_MGC); + + mgcSelectPort = 0; + mgc_select_connection = 0; + mgc_select_ass_mgc_mgNo = 0; + + mgcMaxMgNo = MGC_MAX_NUM_OF_MG; + mgcMaxChlNo = MGC_MAX_NUM_OF_CHNL; + mgcMgCreated = 0; + mgcChlAssigned = 0; + + memset(mgAttr, 0, sizeof(MG_ATTR)); + mgAttr->mgType = MGC_MG_TYPE_INTERNAL; + mgAttr->ctrlType = MGC_MG_CTRL_TYPE_MGCP; + strcpy(mgAttr->domain, "InternalMG"); + mgAttr->ip = 1; + + mgc_create_MG(0, mgAttr); + + mgc_8k_tone_card_silent = 0; + + mgc_e1card0_mgNo = 0; + mgc_e1card1_mgNo = 0; + + sysID = systemId; + localIP = localIp; + peerIP = peerIp; + + strcpy(mgcAsciInBuf, "\0"); + strcpy(mgcAsciOutBuf, "\0"); + mgcMonitorFg = MGC_MONITOR_NONE; + mgc_debug_set(); + + printf("MGC module init complete!\n"); +} + +void mgc_timer() +{ + WORD port; + + for (port = 0; port < MGC_MAX_NUM_OF_PORT; port++) + { + if (mgcPort[port].assigned == 0) + continue; + + mgc_fsm(port); + } + + mgc_t10s(); +} + +int mgc_bind(MGC_SAP *sap) +{ + BYTE sapIndex; + + if (wxc2_get_license(LIC_MGC) <= 0) + { + mgc_log_err("mgc_bind: mgc module is not presented!\n\r"); + return -1; + } + + if ((sap == NULL) || + (sap->mgc_cnf == NULL) || + (sap->usrType > MGC_USER_TYPE_MG)) + return -1; + + for (sapIndex = 0; sapIndex < MGC_MAX_NUM_OF_SAP; sapIndex++) + { + if (mgcSap[sapIndex].mgc_cnf != NULL) + continue; + + memcpy((BYTE *) &mgcSap[sapIndex], sap, sizeof(MGC_SAP)); + return sapIndex; + } + + return -1; +} + +int mgc_unbind(MGC_SAP *sap, BYTE sapIndex) +{ + if ((sap == NULL) || (sapIndex >= MGC_MAX_NUM_OF_SAP)) + return -1; + + if ((strcmp(sap->usrName, mgcSap[sapIndex].usrName) != 0) || + (sap->usrType != mgcSap[sapIndex].usrType)) + return -1; + + memset((BYTE *) &mgcSap[sapIndex], 0, sizeof(MGC_SAP)); + + return 0; +} + +int mgc_store_aas_mgc_mg(WORD mgNo) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if ((mgc_aas_mgNo[i] < MGC_MAX_NUM_OF_MG) && (mgc_aas_mgNo[i] > 0)) + { + continue; + } + else + { + mgc_aas_mgNo[i] = mgNo; + return 0; + } + } + + return -1; +} + +int mgc_delet_aas_mgc_mg(WORD mgNo) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if ((mgc_aas_mgNo[i] > 0) && (mgc_aas_mgNo[i] != mgNo)) + { + continue; + } + else + { + mgc_aas_mgNo[i] = 0; + return 0; + } + } + + return -1; +} + +int mgc_assign_chnl(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE chnlType) +{ + WORD i, j; + WORD chnlStart, chnlEnd, chnlNum; + + if (mgNo >= MGC_MAX_NUM_OF_MG) + { + return -1; + } + + if (chnlType == MGC_MG_TYPE_ANN) + { + chnlStart = MGC_CHNL_START_ANN; + chnlEnd = MGC_CHNL_START_ANN + MGC_CHNL_NUM_ANN; + chnlNum = MGC_CHNL_NUM_ANN_PER_TYPE; + } + else if (chnlType == MGC_PHY_PORT_TYPE_ANALOG) + { + chnlStart = MGC_CHNL_START_AALN; + chnlEnd = MGC_CHNL_START_AALN + MGC_CHNL_NUM_AALN; + chnlNum = MGC_CHNL_NUM_AALN_PER_PORT; + } + else if(chnlType == MGC_MG_TYPE_INTERNAL) + { + chnlStart = MGC_CHNL_START_INTERNAL; + chnlEnd = MGC_CHNL_START_INTERNAL+ MGC_CHNL_NUM_INTERNAL; + chnlNum = MGC_CHNL_NUM_INTERNAL_PER_PORT; + } + else + { + chnlStart = MGC_CHNL_START_DS; + chnlEnd = MGC_CHNL_START_DS + MGC_CHNL_NUM_DS_TOTAL; + chnlNum = MGC_CHNL_NUM_DS_PER_PORT; + } + + if ((mgcChlAssigned + chnlNum) > mgcMaxChlNo) + return -1; + + for (i = chnlStart; i < chnlEnd; i += chnlNum) + { + if (mgcChnl[i].assigned == 1) + continue; + + for (j = 0; j < chnlNum; j++) + { + mgcChnl[i + j].assigned = 1; + mgcChnl[i + j].mgNo = mgNo; + mgcChnl[i + j].portNo = portNo; + mgcChnl[i + j].port = 0xFFFF; + + if (chnlType == MGC_MG_TYPE_ANN) + { + mgcChnl[i + j].sapIndex = sapIndex; + } + } + + mgcChlAssigned += chnlNum; + + return i; + } + + return -1; +} + +int mgc_remove_chnl(WORD chnlIndex, WORD chnlNum) +{ + WORD i, port; + + if ((chnlIndex>MGC_MAX_NUM_OF_CHNL) || ((chnlIndex+chnlNum)>MGC_MAX_NUM_OF_CHNL)) + { + return -1; + } + + for (i = 0; i < chnlNum; i++) + { + port = mgcChnl[chnlIndex + i].port; + if (port < MGC_MAX_NUM_OF_CHNL) + mgcPort[port].mngCmd = MGC_MNG_CMD_REMOVE_CHNL; + + mgc_chnl_init(chnlIndex + i); + + mgc_remove_connect(chnlIndex + i); + } + + if (mgcChlAssigned > chnlNum) + mgcChlAssigned -= chnlNum; + else + mgcChlAssigned = 0; + + return 0; +} + +int mgc_assign_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr) +{ + int chnlIndex; + BYTE cardNo; + + if ((mgNo >= MGC_MAX_NUM_OF_MG) || (mgAttr == NULL) || (0 == strcmp(mgAttr->domain, "")) + || (0 == mgAttr->ip)) + { + return -1; + } + + if (mgAttr->mgType == MGC_MG_TYPE_ANN) + { + if ((chnlIndex = mgc_assign_chnl(sapIndex, mgNo, 0xFF, MGC_MG_TYPE_ANN)) < 0) + return -1; + mgcMgInfo[mgNo].chnlNum = MGC_CHNL_NUM_ANN_PER_TYPE; + mgcMgInfo[mgNo].chnlStartIndex = chnlIndex; + } + + if (mgAttr->mgType == MGC_MG_TYPE_INTERNAL) + { + if ((chnlIndex = mgc_assign_chnl(0xFF, mgNo, 0xFF, MGC_MG_TYPE_INTERNAL)) < 0) + return -1; + mgcMgInfo[mgNo].chnlNum = MGC_CHNL_NUM_INTERNAL_PER_PORT; + mgcMgInfo[mgNo].chnlStartIndex = chnlIndex; + }//add by Francis + + if (MGC_MG_CTRL_TYPE_8ECP == mgAttr->ctrlType) + { + if ((cardNo = atoi(mgAttr->domain)) > 31) + { + mgc_log_err("mgc_create_MG: 8ecp domain out of range!\n\r"); + return -1; + } + + _8ecp_createMG(mgNo, mgAttr->ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = mgNo; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = mgNo; + } + } + + mgcMgInfo[mgNo].created = 1; + memcpy((BYTE *) &mgcMgInfo[mgNo].mgAttr, (BYTE *) mgAttr, sizeof(MG_ATTR)); + + if (mgcMgInfo[mgNo].mgAttr.auditTimer == 0) + { + mgcMgInfo[mgNo].mgAttr.auditTimer = MGC_MGCF_TIMER_10S; + } + else + { + mgcMgInfo[mgNo].mgAttr.auditTimer = mgcMgInfo[mgNo].mgAttr.auditTimer * MGC_MGCF_TIMER_1S; + } + + mgcMgInfo[mgNo].mgAttr.e1cardNo = cardNo; + mgcMgInfo[mgNo].portNum = 0; + memset((BYTE *) mgcMgInfo[mgNo].portIndex, 0xFFFF, sizeof(WORD) * MGC_MAX_PHY_PORT_PER_MG); + + mgcMgCreated++; + + return mgNo; +} + +int mgc_create_MG(BYTE sapIndex, MG_ATTR *mgAttr) +{ + WORD i; + int mgNo; + char tmpStr[128]; + + if ((mgAttr == NULL) || (sapIndex >= MGC_MAX_NUM_OF_SAP) || (0 == strcmp(mgAttr->domain, "")) + || (0 == mgAttr->ip) || ((MGC_MG_CTRL_TYPE_8ECP != mgAttr->ctrlType) && (MGC_MG_CTRL_TYPE_MGCP != mgAttr->ctrlType))) + { + mgc_log_err("mgc_create_MG: invalid sapIndex or NULL mgAttr or No domain or No ip!\n\r"); + return -1; + } + + if ((mgcMgCreated + 1) > mgcMaxMgNo) + { + mgc_log_err("mgc_create_MG: license not enough!\n\r"); + return -1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 0) + { + continue; + } + + if ((0 == strcmp(mgcMgInfo[i].mgAttr.domain, mgAttr->domain)) + && (mgcMgInfo[i].mgAttr.ip == mgAttr->ip) && (mgcMgInfo[i].usrType == mgcSap[sapIndex].usrType)) + { + if (mgcMgInfo[i].sapIndex[sapIndex] == 0) + { + mgcMgInfo[i].sapIndex[sapIndex] = 1; + return i; + } + else + { + mgc_log_err("mgc_create_MG: duplicated MG and sapIndex!\n\r"); + return -1; + } + } + } + + if (mgAttr->mgType == MGC_MG_TYPE_INTERNAL) + { + if (0 == mgcMgInfo[0].created) + return mgc_assign_MG(0xFF, MGC_INTERNAL_VIRTUAL_MG, mgAttr); + else + return -1; + } + + for (i = 1; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 1) + continue; + mgNo = mgc_assign_MG(sapIndex, i, mgAttr); + if (mgNo >= 0) + { + if ((mgcMonitorFg & MGC_MONITOR_ALL) == MGC_MONITOR_ALL) + { + sprintf(tmpStr, "mgc_create_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgAttr->domain); + mgc_asciout_proc(tmpStr); + mgcMgInfo[mgNo].monFlag = 1; + } + mgcMgInfo[mgNo].usrType = mgcSap[sapIndex].usrType; + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgNo].mgAttr.mgType) + && (MGC_USER_TYPE_MGC == mgcMgInfo[mgNo].usrType)) + { + if (mgc_store_aas_mgc_mg(mgNo) < 0) + { + mgc_log_err("mgc_assign_MG: no resource store AAS MGC MG!\n\r"); + mgc_mg_init(mgNo); + return -1; + } + } + + mgcMgInfo[mgNo].sapIndex[sapIndex] = 1; + + return mgNo; + } + else + { + mgc_log_err("mgc_assign_MG: MG assign failed!\n\r"); + + return -1; + } + } + + mgc_log_err("mgc_create_MG: MG resource not available!\n\r"); + + return -1; +} + +int mgc_delete_MG(BYTE sapIndex, WORD mgNo) +{ + BYTE i; + char tmpStr[128]; + BYTE cardNo; + BYTE mgFlag = 0; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || (0 == mgNo) + || (0 == mgcMgInfo[mgNo].created))//add by Francis + { + mgc_log_err("mgc_delete_MG: invalid sapIndex or mgNo!\n\r"); + return -1; + } + + if (MGC_MG_CTRL_TYPE_8ECP == mgcMgInfo[mgNo].mgAttr.ctrlType) + { + cardNo = mgcMgInfo[mgNo].mgAttr.e1cardNo; + + if (cardNo > 31) + { + mgc_log_err("mgc_delete_MG: invalid 8ecp cardNo!\n\r"); + return -1; + } + + _8ecp_deleteMG(mgNo, mgcMgInfo[mgNo].mgAttr.ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = 0; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = 0; + } + } + else + { + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgNo].mgAttr.mgType) && (mgcMgInfo[mgNo].chnlNum > 0)) + { + mgc_delet_aas_mgc_mg(mgNo); + + mgc_remove_chnl(mgcMgInfo[mgNo].chnlStartIndex, mgcMgInfo[mgNo].chnlNum); + }//add by Francis + else + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgcMgInfo[mgNo].portIndex[i] < MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_delete_port(sapIndex, mgNo, i); + } + } + } + } + + mgcMgInfo[mgNo].sapIndex[sapIndex] = 0; + + for (i = 0; i < MGC_MAX_NUM_OF_SAP; i++) + { + if (mgcMgInfo[mgNo].sapIndex[i] == 1) + { + mgFlag = 1; + break; + } + } + + if (mgFlag == 0) + { + mgc_mg_init(mgNo); + + if (mgcMgCreated > 0) + mgcMgCreated--; + + sprintf(tmpStr, "mgc_delete_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgcMgInfo[mgNo].mgAttr.domain); + mgc_asciout_proc(tmpStr); + + return 0; + } + + mgc_log_err("mgc_delete_MG: other users are using this mg!\n\r"); + + return 0; +} + +int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr) +{ + char tmpStr[128]; + BYTE cardNo; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_modify_MG: invalid sapIndex or mgNo!\n\r"); + return -1; + } + + if (0 == mgcMgInfo[mgNo].created) + { + mgc_log_err("mgc_modify_MG: mg not create!\n\r"); + return -1; + } + + if (MGC_MG_CTRL_TYPE_8ECP == mgAttr->ctrlType) + { + if ((cardNo = atoi(mgAttr->domain)) > 31) + { + mgc_log_err("mgc_modify_MG: 8ecp domain out of range!\n\r"); + return -1; + } + + _8ecp_createMG(mgNo, mgAttr->ip, cardNo); + } + + memcpy((BYTE *) &mgcMgInfo[mgNo].mgAttr, (BYTE *) mgAttr, sizeof(MG_ATTR)); + + sprintf(tmpStr, "mgc_modify_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgAttr->domain); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType) +{ + WORD i; + int chnlIndex; + MG_INFO *mgInfo; + BYTE chnlNum; + WORD portIndex; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (portType > MGC_PHY_PORT_TYPE_ANALOG)) + { + mgc_log_err("mgc_add_port: invalid sapIndex, mgNo, portNo, or portType!\n\r"); + return -1; + } + + mgInfo = &mgcMgInfo[mgNo]; + + if (mgInfo->created != 1) + { + mgc_log_err("mgc_add_port: MG not created!\n\r"); + return -1; + } + + if ((mgInfo->portNum + 1) > mgInfo->mgAttr.maxPorts) + { + mgc_log_err("mgc_add_port: reached maxPorts of that MG!\n\r"); + return -1; + } + + portIndex = mgcMgInfo[mgNo].portIndex[portNo]; + + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && + (mgcPhyPort[portIndex].created == 1)) + { + mgc_log_err("mgc_add_port: port already created!\n\r"); + return -1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + { + if (mgcPhyPort[i].created == 1) + continue; + if (mgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + { + if (portType == MGC_PHY_PORT_TYPE_ANALOG) + chnlNum = MGC_CHNL_NUM_AALN_PER_PORT; + else + chnlNum = MGC_CHNL_NUM_DS_PER_PORT; + if ((chnlIndex = mgc_assign_chnl(sapIndex, mgNo, portNo, portType)) < 0) + { + mgc_log_err("mgc_add_port: insufficient channel resources!\n\r"); + return -1; + } + mgcPhyPort[i].chnlNum = chnlNum; + mgcPhyPort[i].chnlStartIndex = chnlIndex; + } + + mgcPhyPort[i].created = 1; + mgcPhyPort[i].mgNo = mgNo; + mgcPhyPort[i].portNo = portNo; + mgcPhyPort[i].portType = portType; + mgcPhyPort[i].sapIndex = sapIndex; + + mgInfo->portIndex[portNo] = i; + mgInfo->portNum++; + + if ((mgcMonitorFg & MGC_MONITOR_ALL) == MGC_MONITOR_ALL) + mgcPhyPort[i].monFlag = 1; + + sprintf(tmpStr, "mgc_add_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d, portType = %d, allocated portNo = %d\n\r", sapIndex, mgNo, portNo, portType, i); + mgc_log_procedure(mgNo, i, 0xFFFF, tmpStr); + + return i; + } + + mgc_log_err("mgc_add_port: insufficient port resource!\n\r"); + + return -1; +} + +int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo) +{ + WORD portIndex; + MG_INFO *mgInfo; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_delete_port: invalid sapIndex, mgNo, portNo!\n\r"); + return -1; + } + + mgInfo = &mgcMgInfo[mgNo]; + portIndex = mgInfo->portIndex[portNo]; + + if (mgcPhyPort[portIndex].sapIndex == sapIndex) + { + mgc_remove_chnl(mgcPhyPort[portIndex].chnlStartIndex, mgcPhyPort[portIndex].chnlNum); + memset((BYTE *) &mgcPhyPort[portIndex], 0, sizeof(PHY_PORT_INFO)); + + mgInfo->portIndex[portNo] = 0xFFFF; + mgInfo->portNum--; + + sprintf(tmpStr, "mgc_delete_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d\n\r", sapIndex, mgNo, portNo); + mgc_asciout_proc(tmpStr); + + return 0; + } + else + { + mgc_log_err("mgc_delete_port: invalid sapIndex for the portNo!\n\r"); + return -1; + } + +} + +int mgc_modify_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType) +{ + WORD phyPort; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (!mgc_is_non_virtual_mg(mgcMgInfo[mgNo].mgAttr.mgType))||//add by Francis + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (portType > MGC_PHY_PORT_TYPE_ANALOG)) + { + mgc_log_err("mgc_modify_port: invalid sapIndex, mgNo, portNo, or portType!\n\r"); + return -1; + } + + phyPort = mgcMgInfo[mgNo].portIndex[portNo]; + + if (phyPort >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_modify_port: invalid phyPort!\n\r"); + return -1; + } + + mgcPhyPort[phyPort].portType = portType; + + sprintf(tmpStr, "mgc_modify_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d, portType = %d\n\r", sapIndex, mgNo, portNo, portType); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_apply_aas_tone(CHNL *aasChnl, BYTE toneNo) +{ + int i; + int j; + WORD chnlIndex; + WORD connectIndex; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if (mgc_select_ass_mgc_mgNo > 3) + { + mgc_select_ass_mgc_mgNo = 0; + } + + if ((mgc_aas_mgNo[mgc_select_ass_mgc_mgNo] >= MGC_MAX_NUM_OF_MG) + || (mgc_aas_mgNo[mgc_select_ass_mgc_mgNo] == 0) + || (mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].status != 1) + || (mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].mgAttr.ip != localIP)) + { + mgc_select_ass_mgc_mgNo++; + continue; + } + else + { + chnlIndex = mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].chnlStartIndex + toneNo; + + for (j = 0; j < MGC_MAX_NUM_OF_CHNL_CON; j++) + { + if (((connectIndex = mgcChnl[chnlIndex].connectIndex[j]) < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[connectIndex].assigned == 1)) + { + continue; + } + else + { + aasChnl->mgNo = mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]; + aasChnl->portNo = 0xFF; + aasChnl->chlNo = toneNo; + aasChnl->connectNo = j; + + if (mgc_assign_connect_to_chnl(*aasChnl) < 0) + { + mgc_log_err("mgc_apply_aas_tone: assigned connect to chnl failed!\n\r"); + return -1; + } + + mgc_select_ass_mgc_mgNo++; + + return 0; + } + } + } + } + + return -1; +} + +int mgc_match_codec_list(MGC_CODEC_LIST *dest, MGC_CODEC_LIST *aParty, MGC_CODEC_LIST *bParty) +{ + BYTE i, j, num = 0; + + MGC_CODEC_LIST *base, *highPri; + + if (dest == NULL) + { + mgc_log_err("mgc_match_codec_list: dest == NULL!\n\r"); + return -1; + } + dest->num = 0; + dest->priority = 0; + + if (aParty->priority >= bParty->priority) + { + base = bParty; + highPri = aParty; + } + else + { + base = aParty; + highPri = bParty; + } + + if (aParty->codec[0] == MGC_VCTYPE_G729B) + { + base = bParty; + highPri = aParty; + } + else if (bParty->codec[0] == MGC_VCTYPE_G729B) + { + base = aParty; + highPri = bParty; + } + + if (base->num == 0) + { + if (highPri->num == 0) + { + mgc_log_err("mgc_match_codec_list: base->num == 0!\n\r"); + return -1; + } + else + { + memcpy((BYTE *) dest, (BYTE *) highPri, sizeof(MGC_CODEC_LIST)); + return 0; + } + } + + if (highPri->num == 0) + { + memcpy((BYTE *) dest, (BYTE *) base, sizeof(MGC_CODEC_LIST)); + return 0; + } + + for (i = 0; i < highPri->num; i++) + { + for (j = 0; j < base->num; j++) + { + if (highPri->codec[i] == base->codec[j]) + { + dest->codec[num++] = highPri->codec[i]; + break; + } + } + } + + if (num > 0) + { + dest->num = num; + dest->priority = highPri->priority; + return 0; + } + else + { + mgc_log_err("mgc_match_codec_list: can't match at all!\n\r"); + return -1; + } +} + +int mgc_crcx_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort, associPort; + char tmpStr[256]; + BYTE ptime; + int connectIndex;//new replace + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_crcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_log_err("mgc_crcx_chnl: MGC_MG_TYPE_INTERNAL!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_crcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_crcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_crcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if ((mgcChnl[chnlIndex].connectIndex[chnl.connectNo] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned == 1) + && ((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status == MGC_CONNECT_STATUS_CREATED) + ||(mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status == MGC_CONNECT_STATUS_TONE)))//new replace + { + mgc_log_err("mgc_crcx_chnl: connection already created on this channel!\n\r"); + return 0; + } + + if ((mgcChnl[chnlIndex].connectIndex[chnl.connectNo] >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned != 1)) + { + if ((connectIndex = mgc_assign_connect_to_chnl(chnl)) < 0) + { + mgc_log_err("mgc_crcx_chnl: connect resource not available!\n\r"); + return -1; + }//new replace + } + else + { + connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + } + + associPort = mgcConnectInfo[connectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: chnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: chnl operation overwritten!\n\r"); + } + + if (mgcConnectInfo[connectIndex].codecList.num == 0) +// if (mgcChnl[chnlIndex].codecList.num == 0) + { + if (mgc_match_codec_list(&mgcConnectInfo[connectIndex].codecList, &mgcConnectInfo[connectIndex].codecList, &mgcMgInfo[chnl.mgNo].mgAttr.codecList) < 0) + //if (mgc_match_codec_list(&codecList, &mgcChnl[chnlIndex].codecList, &mgcMgInfo[chnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_crcx_chnl: mgcChnl[chnlIndex].codecList error!\n\n"); + return -1; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_crcx_chnl: port resource not available!\n\r"); + return -1; + } + + ptime = mgcMgInfo[chnl.mgNo].mgAttr.ptime; + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[0].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[0].media.vocoderType = mgcConnectInfo[connectIndex].codecList; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_CRCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_CRCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + + sprintf(tmpStr, "mgc_crcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, chnlConnectNo = %d, connectIndex = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, connectIndex);//new replace + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *mediaPara, BYTE sdFlag) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + WORD connectIndex;//new replace + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_mdcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_mdcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_mdcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON);//new replace + { + mgc_log_err("mgc_mdcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_EC) == MGC_MEDIA_PARA_FLAG_EC) + //mgcChnl[chnlIndex].mediaAttr.ecDisable = mediaPara->ecDisable; + mgcConnectInfo[connectIndex].mediaAttr.ecDisable = mediaPara->ecDisable; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_SS) == MGC_MEDIA_PARA_FLAG_SS) + //mgcChnl[chnlIndex].mediaAttr.ssDisable = mediaPara->ssDisable; + mgcConnectInfo[connectIndex].mediaAttr.ssDisable = mediaPara->ssDisable; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_CM) == MGC_MEDIA_PARA_FLAG_CM) + //mgcChnl[chnlIndex].mediaAttr.conMode = mediaPara->conMode; + mgcConnectInfo[connectIndex].mediaAttr.conMode = mediaPara->conMode; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_PT) == MGC_MEDIA_PARA_FLAG_PT) + //mgcChnl[chnlIndex].mediaAttr.ptime = mediaPara->ptime; + mgcConnectInfo[connectIndex].mediaAttr.ptime = mediaPara->ptime; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_VT) == MGC_MEDIA_PARA_FLAG_VT) + { + //mgc_match_codec_list(&mgcChnl[chnlIndex].codecList, &mediaPara->vocoderType, &mgcMgInfo[chnl.mgNo].mgAttr.codecList); + mgc_match_codec_list(&mgcConnectInfo[connectIndex].codecList, &mediaPara->vocoderType, &mgcMgInfo[chnl.mgNo].mgAttr.codecList); + } + + if (sdFlag == 0) + { +// sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, sdFlag); + sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, sdFlag);//new replace + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + return 0; + } + + if ((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned != 1) + || ((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status != MGC_CONNECT_STATUS_CREATED)&&((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status != MGC_CONNECT_STATUS_TONE))))//new replace +// if (mgcChnl[chnlIndex].status != MGC_CHNL_STATUS_CREATED) + { + mgc_log_err("mgc_mdcx_chnl: connection not created on this channel!\n\r"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mdcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_MDCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_MDCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + +// sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, sdFlag); + sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, sdFlag); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl) +{ + int port; + BYTE ptime; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst; + char tmpStr[256]; + int orgConnectIndex; + int destConnectIndex; + MGC_CODEC_LIST codecList; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (destChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_recvonly_chnl: invalid mgNo!\n\r"); + return -1; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (destChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_recvonly_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (destChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_recvonly_chnl: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if ((chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_recvonly_chnl: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1) + || ((mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_TONE)))//new replace + { + mgc_log_err("mgc_recvonly_chnl: orgChnl connectionIndex invaild or connection not create!\n\r"); + return -1; + + } + + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode == MGCP_CON_MODE_RECVONLY) + { + sprintf(tmpStr, "mgc_recvonly_chnl: connection already in recvonly mode, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + || (mgcMgInfo[destChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_recvonly_chnl: invalid chnlIndex or phyPort of destChnl!\n\r"); + return -1; + } + + + if (((destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[destChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[destConnectIndex].assigned != 1) + || ((mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_TONE)))//new replace + { + mgc_log_err("mgc_recvonly_chnl: destChnl connectionIndex invaild or connection not create!\n\r"); + return -1; + } + + if (mgcConnectInfo[orgConnectIndex].codecList.num == 0) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_crcx_chnl: mgcChnl[chnlIndex].codecList error!\n\n"); + return -1; + } + } + + codecList = mgcConnectInfo[orgConnectIndex].codecList; + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mdcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[0].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[0].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[0].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[0].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_MDCX; + mgcPort[port].mgcfOperSteps[0].media.vocoderType = codecList; + mgcPort[port].mgcfOperId = MGC_OPER_ID_MDCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + sprintf(tmpStr, "mgc_recvonly_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo, destConnectIndex); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_dlcx_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort, associPort; + char tmpStr[256]; + WORD orgChl, dstChl; + WORD connectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_dlcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[chnl.mgNo].mgAttr.e1cardNo * 8 + chnl.portNo) * 32 + chnl.chlNo; + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + _8ecp_connect_chnl(orgChl, dstChl, 0); //ecDisable:0/1=enable/disable echo canceller + + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + + sprintf(tmpStr, "mgc_dlcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; + } + + if ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) + && (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_dlcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_dlcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (chnl.chlNo >= MGC_MAX_NUM_OF_CHNL) + { + if (chnl.chlNo != MGCP_EP_NAME_CHNL_WILDCAST) + { + mgc_log_err("mgc_dlcx_chnl: invalid chnlIndex!\n\r"); + return -1; + } + } + + if (chnl.chlNo < MGC_MAX_NUM_OF_CHNL) + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_dlcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON)//new replace + { + mgc_log_err("mgc_dlcx_chnl: invalid connectIndex!\n\r"); + return -1; + } + + + associPort = mgcConnectInfo[connectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: chnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: chnl operation overwritten!\n\r"); + } + + if ((mgcConnectInfo[connectIndex].assigned != 1) + || ((mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_TONE))) //new replace + { + mgc_log_err("mgc_dlcx_chnl: connection not created on this channel!\n\r"); + return 0; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_dlcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_DLCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_DLCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + + sprintf(tmpStr, "mgc_dlcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + MGC_SESS_REC *pSess; + + pSess = mgc_sess_is_already_rec(chnl); + if(pSess != NULL) + mgc_sess_rec_init(pSess, pSess->id); + + return 0; +} + +int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, EVENT *event, SIGNAL *signal) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_rqnt_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_rqnt_chnl: invalid portNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) || + ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_rqnt_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if ((mgcChnl[chnlIndex].port < MGC_MAX_NUM_OF_PORT) + && (mgcPort[mgcChnl[chnlIndex].port].assigned != 0)) + { + mgc_log_err("mgc_rqnt_chnl: channel already engaged!\n\r"); + return 0; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_rqnt_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperId = MGC_OPER_ID_RQNT; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = 0xFFFF; + + if (event != NULL) + //mgcChnl[chnlIndex].mediaAttr.pkgEvent = (event->pkg << 8) | event->event; + mgcChnl[chnlIndex].comMediaAttr.pkgEvent = (event->pkg << 8) | event->event; + + if (signal != NULL) + //mgcChnl[chnlIndex].mediaAttr.pkgSignal = (signal->pkg << 8) | signal->signal; + mgcChnl[chnlIndex].comMediaAttr.pkgSignal = (signal->pkg << 8) | signal->signal; + +// sprintf(tmpStr, "mgc_rqnt_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + sprintf(tmpStr, "mgc_rqnt_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_auep_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_auep_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_auep_chnl: invalid portNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_auep_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if (mgcChnl[chnlIndex].auepSt != MGC_CHNL_AUEP_IDLE) + { + mgc_log_err("mgc_auep_chnl: auep already in progress!\n\r"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_auep_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_AUEP; + mgcPort[port].mgcfOperId = MGC_OPER_ID_AUEP; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = 0xFFFF; + + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IN_PROGRESS; + +// sprintf(tmpStr, "mgc_auep_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + sprintf(tmpStr, "mgc_auep_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + MGC_CODEC_LIST codecList; + int orgConnectIndex; + int destConnectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + CONNECT_INFO *pConnect; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (destChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_chnl: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[destChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[destChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + if ((flag & MGC_CONNECT_SILENT_TONE) == MGC_CONNECT_SILENT_TONE) + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + else + dstChl = (mgcMgInfo[destChnl.mgNo].mgAttr.e1cardNo * 8 + destChnl.portNo) * 32 + destChnl.chlNo; + + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + _8ecp_connect_chnl(orgChl, dstChl, mgcChnl[chnlIndexOrg].comMediaAttr.ecDisable); //ecDisable:0/1=enable/disable echo canceller + + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + + sprintf(tmpStr, "mgc_connect_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, destChnl.mgNo, destChnl.portNo, destChnl.chlNo); + + if (mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr) < 0) + mgc_log_procedure(destChnl.mgNo, phyPortDst, chnlIndexDst, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (destChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (destChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + phyPortOrg = 0; + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + } + + if ((chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_chnl: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_chnl: assigned connect on orgChnl failed!\n\r"); + return -1; + } + + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: orgChnl operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: orgChnl chnl operation overwritten!\n\r"); + } + + if (mgcMgInfo[destChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + phyPortDst = 0; + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + } + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_chnl: invalid chnlIndex or phyPort of destChnl!\n\r"); + return -1; + } + + + if (((destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[destChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[destConnectIndex].assigned != 1))//new replace + { + if ((destConnectIndex = mgc_assign_connect_to_chnl(destChnl)) < 0) + { + mgc_log_err("mgc_connect_chnl: assigned connect on destChnl failed!\n\r"); + return -1; + } + } + + if (mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) + { + associPort = mgcConnectInfo[destConnectIndex].port; + + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: destChnl operation overwritten!\n\r"); + } + + associPort = mgcChnl[chnlIndexDst].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: destChnl chnl operation overwritten!\n\r"); + } + + } + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if ((mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[destChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: mgcConnectInfo[destConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: can't match codec!\n\n"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ptime >= mgcMgInfo[destChnl.mgNo].mgAttr.ptime) + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + else + ptime = mgcMgInfo[destChnl.mgNo].mgAttr.ptime; + + if ((mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_TONE)) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + + if ((mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_TONE)) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = destChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + + if ((MGC_MG_TYPE_IPBSS != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) && (orgChnl.mgNo == destChnl.mgNo) + && ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) != MGCP_PARA_FLAG_TFO)) + { + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_IPBSS) + && (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType)) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + else if ((orgChnl.mgNo != destChnl.mgNo) + && ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO)) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + + if ((MGC_MG_TYPE_IPBSS != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) && (orgChnl.mgNo == destChnl.mgNo)) + { + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + } + + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + + if ((flag & MGC_CONNECT_SILENT_TONE) == MGC_CONNECT_SILENT_TONE) + { + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + } + else + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDRECV; + + if ((MGC_MG_TYPE_IPBSS != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) && (orgChnl.mgNo == destChnl.mgNo)) + { + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + } + + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = destChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + + + if(mgcMgInfo[destChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_AudioCoder) + { + mgcPort[port].mgcfOperSteps[step].localChnl = destChnl; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_RQNT; + mgcChnl[chnlIndexDst].comMediaAttr.pkgReq = (MGCP_PKG_D << 8)|(MGCP_D_SIG_WILD); + } + + pConnect = &mgcConnectInfo[orgConnectIndex]; + memset(&(pConnect->operRec) , 0 , sizeof(OPER_REC)); + pConnect->operRec.operaId = MGC_OPER_ID_CONNECT_CHNL; + + if (step == 0) + mgc_port_init(port); + else + { + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_CHNL; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + mgcPort[port].mgcfOperStepsNum = step; + } + + sprintf(tmpStr, "mgc_connect_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo, destConnectIndex, step); + if (mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr) < 0) + mgc_log_procedure(destChnl.mgNo, phyPortDst, chnlIndexDst, tmpStr); + + + if(mgc_sess_rec_org_and_dst_chnl(orgChnl , destChnl) == FALSE) + return -1; + + return 0; +} + +int mgc_connect_dtmf(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE dtmfNo) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, phyPortOrg, associPort; + char tmpStr[256]; + BYTE digit = 0; + int orgConnectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_dtmf: invalid mgNo!\n\r"); + return -1; + } + + if (0 == dtmfNo) + { + digit = 10; + } + else + { + digit = dtmfNo; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo; + _8ecp_connect_dtmf(orgChl, dstChl, digit); + + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + + sprintf(tmpStr, "mgc_connect_dtmf: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, dtmfNo = %d\n\r", usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, dtmfNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if (orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_connect_dtmf: invalid portNo!\n\r"); + return -1; + } + + if (orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_connect_dtmf: invalid connectNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_dtmf: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_dtmf: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: orgChnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: orgChnl chnl operation overwritten!\n\r"); + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_dtmf: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if ((mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_TONE)) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = (MGCP_PKG_D << 8) | digit; + if(mgcMgInfo[orgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_AudioCoder) + { + mgcChnl[orgConnectIndex].comMediaAttr.pkgReq = (MGCP_PKG_D << 8)|(MGCP_D_SIG_WILD); + } + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperStepsNum = step; + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_DTMF; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + sprintf(tmpStr, "mgc_connect_dtmf: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, dtmfNo = %d\n\r", usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, dtmfNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration, WORD times) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + CHNL aasChnl = {0xFFFF, 0, 0xFFFF, 0xFFFF}; + int orgConnectIndex; + int destConnectIndex; + WORD aasConnectIndex; + WORD chnlIndexAAS; + MGC_CODEC_LIST codecList; + WORD orgAASChnlIndex; + WORD orgAASConnectIndex; + CHNL orgAASChnl; + CONNECT_INFO *pConnect; + BYTE tone; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_AAS: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (toneNo >= MGC_MAX_TONE_NO) + { + mgc_log_err("mgc_connect_AAS: invalid toneNo!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + + if ((0 == dstChnl.mgNo) && (0 == dstChnl.portNo) && (0 == dstChnl.chlNo)) + { + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + } + else if ((1 == mgcMgInfo[dstChnl.mgNo].created) + && (1 == mgcPhyPort[mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]].created)) + { + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo;//need revise + } + else + { + mgc_log_err("mgc_connect_AAS: invalid 8ecp mgNo or portNo!\n\r"); + return -1; + } + + _8ecp_connect_tone(orgChl, dstChl, toneNo, duration); + + sprintf(tmpStr, "mgc_connect_AAS: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (dstChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_AAS: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (dstChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_AAS: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_AAS: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_AAS: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: orgChnl connection operation overwritten!\n\r"); + } + + orgAASChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((orgAASChnl.mgNo < MGC_MAX_NUM_OF_MG) && (orgAASChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (orgAASChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + orgAASChnlIndex = mgcMgInfo[orgAASChnl.mgNo].chnlStartIndex + orgAASChnl.chlNo; + + if ((orgAASConnectIndex = mgcChnl[orgAASChnlIndex].connectIndex[orgAASChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[orgAASConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: orgChnl chnl operation overwritten!\n\r"); + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType)) + { + chnlIndexDst = mgcMgInfo[dstChnl.mgNo].chnlStartIndex + dstChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + dstChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_AAS: invalid destChnl chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[dstChnl.connectNo]; + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) && (mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[dstChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: mgcConnectInfo[dstConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: orgConnect and dstConnect code negotiation fail!\n\n"); + return -1; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_AAS: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if (toneNo == MGC_HOLD_MUSIC) + { + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + else + { + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[destConnectIndex].codecList;//orgConnectIndex + } + else + { + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + } + + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + } + + if (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) + { + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[destConnectIndex].status == MGC_CONNECT_STATUS_CREATED)) + { + if (mgcConnectInfo[destConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[dstChnl.mgNo].mgAttr.ptime; + + if ((mgcConnectInfo[destConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + } + + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = dstChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList;//destConnectIndex + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + } + + toneNo = times * 10 + (toneNo - 7); + + if (mgc_apply_aas_tone(&aasChnl, toneNo) < 0) + { + mgc_log_err("mgc_connect_AAS: apply aas tone fail!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((aasChnl.mgNo >= MGC_MAX_NUM_OF_MG) || (aasChnl.portNo != 0xFF) + || (aasChnl.chlNo != toneNo) || (aasChnl.connectNo > MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_connect_AAS: apply aas mg fail!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + + if (toneNo == 0) + { + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + } + else + { + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode;; + } + + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[destConnectIndex].codecList;//orgConnectIndex + } + else + { + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + } + + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + chnlIndexAAS = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + aasConnectIndex = mgcChnl[chnlIndexAAS].connectIndex[aasChnl.connectNo]; + + ptime = mgcConnectInfo[orgConnectIndex].mediaAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_CRCX; +// mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcMgInfo[orgChnl.mgNo].mgAttr.codecList; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + + mgcConnectInfo[orgConnectIndex].aasChnl = aasChnl; + + memcpy((BYTE *) &mgcConnectInfo[aasConnectIndex].mediaAttr.sdp, (BYTE *) &mgcConnectInfo[orgConnectIndex].mediaAttr.sdp, sizeof(PUB_SDP_MSG)); + + if (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step].delay = duration * MGC_MGCF_TIMER_1S; + } + } + + mgcPort[port].mgcfOperSteps[step++].chnlConnectIndex = aasChnl.connectNo; + + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_MDCX; + + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + } + + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_DLCX; + } + } + + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_AAS; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperStepsNum = step; + + pConnect = &mgcConnectInfo[orgConnectIndex]; + memset(&(pConnect->operRec) , 0 , sizeof(OPER_REC)); + pConnect->operRec.operaId = MGC_OPER_ID_CONNECT_AAS; + pConnect->operRec.tone = tone; + pConnect->operRec.duration = duration; + pConnect->operRec.times = times; + + sprintf(tmpStr, "mgc_connect_AAS: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, dstChnl.mgNo, dstChnl.portNo, dstChnl.chlNo, dstChnl.connectNo, destConnectIndex, step); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + CHNL aasChnl = {0xFFFF, 0, 0xFFFF, 0xFFFF}; + int orgConnectIndex; + int destConnectIndex; + WORD aasConnectIndex; + WORD chnlIndexAAS; + MGC_CODEC_LIST codecList; + WORD orgAASChnlIndex; + WORD orgAASConnectIndex; + CHNL orgAASChnl; + CONNECT_INFO *pConnect; + BYTE tone; + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_tone: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (toneNo >= MGC_MAX_TONE_NO) + { + mgc_log_err("mgc_connect_tone: invalid toneNo!\n\r"); + return -1; + } + + tone = toneNo; + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + + if ((0 == dstChnl.mgNo) && (0 == dstChnl.portNo) && (0 == dstChnl.chlNo)) + { + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + } + else if ((1 == mgcMgInfo[dstChnl.mgNo].created) + && (1 == mgcPhyPort[mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]].created)) + { + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo;//need revise + } + else + { + mgc_log_err("mgc_connect_tone: invalid 8ecp mgNo or portNo!\n\r"); + return -1; + } + + _8ecp_connect_tone(orgChl, dstChl, toneNo, duration); + + sprintf(tmpStr, "mgc_connect_tone: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (dstChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_tone: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (dstChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_tone: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_tone: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_tone: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: orgChnl connection operation overwritten!\n\r"); + } + + orgAASChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((orgAASChnl.mgNo < MGC_MAX_NUM_OF_MG) && (orgAASChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (orgAASChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + orgAASChnlIndex = mgcMgInfo[orgAASChnl.mgNo].chnlStartIndex + orgAASChnl.chlNo; + + if ((orgAASConnectIndex = mgcChnl[orgAASChnlIndex].connectIndex[orgAASChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[orgAASConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: orgChnl chnl operation overwritten!\n\r"); + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType)) + { + chnlIndexDst = mgcMgInfo[dstChnl.mgNo].chnlStartIndex + dstChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + dstChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_tone: invalid destChnl chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[dstChnl.connectNo]; + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_tone: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + if ((mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[dstChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_tone: mgcConnectInfo[dstConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: orgConnect and dstConnect code negotiation fail!\n\n"); + return -1; + } + } + else + codecList = mgcConnectInfo[orgConnectIndex].codecList; + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_tone: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + else + { + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[destConnectIndex].status == MGC_CONNECT_STATUS_CREATED)) + { + if (mgcConnectInfo[destConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[dstChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = dstChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.toneCap == 1) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperSteps[step].pkgSignal = MGC_TONE_NO_TO_PKG_SIG[toneNo]; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_RQNT; + } + else + { + toneNo = toneNo - 7; + + if (mgc_apply_aas_tone(&aasChnl, toneNo) < 0) + { + mgc_log_err("mgc_connect_tone: mg no toneCap and no AAS MG!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((aasChnl.mgNo >= MGC_MAX_NUM_OF_MG) || (aasChnl.portNo != 0xFF) + || (aasChnl.chlNo != toneNo) || (aasChnl.connectNo > MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_connect_tone: mg no toneCap and apply aas mg fault!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + chnlIndexAAS = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + aasConnectIndex = mgcChnl[chnlIndexAAS].connectIndex[aasChnl.connectNo]; + + ptime = mgcConnectInfo[orgConnectIndex].mediaAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_CRCX; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + + mgcConnectInfo[orgConnectIndex].aasChnl = aasChnl; + + memcpy((BYTE *) &mgcConnectInfo[aasConnectIndex].mediaAttr.sdp, (BYTE *) &mgcConnectInfo[orgConnectIndex].mediaAttr.sdp, sizeof(PUB_SDP_MSG)); + if (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step].delay = duration * MGC_MGCF_TIMER_1S; + } + } + mgcPort[port].mgcfOperSteps[step++].chnlConnectIndex = aasChnl.connectNo; + + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_MDCX; + + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + } + + + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_DLCX; + } + } + } + + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_TONE; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperStepsNum = step; + + pConnect = &mgcConnectInfo[orgConnectIndex]; + memset(&(pConnect->operRec) , 0 , sizeof(OPER_REC)); + pConnect->operRec.operaId = MGC_OPER_ID_CONNECT_TONE; + pConnect->operRec.tone = tone; + pConnect->operRec.duration = duration; + + sprintf(tmpStr, "mgc_connect_tone: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, dstChnl.mgNo, dstChnl.portNo, dstChnl.chlNo, dstChnl.connectNo, destConnectIndex, step); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_query_mg_status(WORD mgNo) +{ + if (mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_query_mg_status: invalid mgNo!\n\r"); + return -1; + } + + return mgcMgInfo[mgNo].status; +} + +int mgc_query_port_status(WORD mgNo, BYTE portNo) +{ + if ((mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || (0 == mgcPhyPort[mgcMgInfo[mgNo].portIndex[portNo]].created)) + { + mgc_log_err("mgc_query_port_status: invalid mgNo or portNo!\n\r"); + return 0; + } + + return mgcPhyPort[mgcMgInfo[mgNo].portIndex[portNo]].phyStatus; +} + +int mgc_query_channel_status(CHNL chnl) +{ + if ((chnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_query_channel_status: invalid mgNo or portNo!\n\r"); + return -1; + } + + return mgcChnl[mgcPhyPort[mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]].chnlStartIndex + chnl.chlNo].status; +} + +int mgc_create_virtual_chnl(WORD port, CHNL *chnl) +{ + int chnlIndex; + char tmpStr[128]; + + chnl->mgNo = MGC_INTERNAL_VIRTUAL_MG; + chnl->portNo = 0; + if ((chnlIndex = mgc_assign_chnl(0xFF, MGC_INTERNAL_VIRTUAL_MG, 0xFF, MGC_MG_TYPE_INTERNAL)) < 0) + { + mgc_log_err("mgc_create_virtual_chnl: can't allocate virtual channel!\n\r"); + return -1; + } + + chnl->chlNo = chnlIndex - mgcMgInfo[chnl->mgNo].chnlStartIndex; + + if (mgc_assign_connect_to_chnl(*chnl) < 0) + { + mgc_log_err("mgc_create_virtual_chnl: can't allocate connect!\n\r"); + return -1; + } + + sprintf(tmpStr, "mgc_create_virtual_chnl: succeed, usrPort = %d, assigned chnlIndex = %d\n\r", port, chnlIndex); + mgc_log_procedure(chnl->mgNo, 0xFFFF, chnlIndex, tmpStr); +// mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_release_virtual_chnl(WORD port, CHNL chnl) +{ + WORD chnlIndex; + char tmpStr[128]; + int connectIndex; + WORD associPort; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + + if ((chnl.mgNo != MGC_INTERNAL_VIRTUAL_MG) || + (chnl.portNo != 0)) + { + mgc_log_err("mgc_release_virtual_chnl: invalid mgNo or portNo!\n\r"); + return -1; + } + + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_release_virtual_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + } + else + { + mgc_log_err("mgc_release_virtual_chnl: invalid connectIndex!\n\r"); + } + + mgc_remove_chnl(chnlIndex, MGC_CHNL_NUM_INTERNAL_PER_PORT); + + sprintf(tmpStr, "mgc_release_virtual_chnl: succeed, usrPort = %d, chnlIndex = %d\n\r", port, chnlIndex); + mgc_log_procedure(chnl.mgNo, 0xFFFF, chnlIndex, tmpStr); +// mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_query_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG **mediaInfo, BYTE *mgPayloads, BYTE *mgPlNum) +{ + WORD phyPort, chnlIndex; + WORD connectIndex; + int i; + char tmpStr[128]; + + if ((chnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_query_chnl_media: invalid mgNo or portNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + return -1; + } + + if ((mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_CREATED)&&(mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_TONE)) +// if (mgcChnl[chnlIndex].status != MGC_CHNL_STATUS_CREATED) + return -1; + + *mediaInfo = &mgcConnectInfo[connectIndex].mediaAttr.sdp; + + for (i = 0; i < mgcConnectInfo[connectIndex].codecList.num; i++) + { + mgPayloads[i] = mgc_codec_to_payload(mgcConnectInfo[connectIndex].codecList.codec[i]); + } + + *mgPlNum = mgcConnectInfo[connectIndex].codecList.num; +// *mediaInfo = &mgcChnl[chnlIndex].mediaAttr.sdp; + + sprintf(tmpStr, "mgc_query_chnl: rtpmap=%s\n\r", (*mediaInfo)->medias.medias[0].attrs.attrs[0].aValue); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_payload_to_codec(WORD payload, PUB_SDP_ATTRS attrs) +{ + BYTE i = 0; + + if (attrs.num > 0) + { + for (i = 0; i < attrs.num; i++) + { + if (attrs.attrs[i].aType != PUB_SDP_ATTR_TYPE_RTPMAP) + { + continue; + } + + if (strtol(attrs.attrs[i].aValue, NULL, 10) == payload) + { + if (strstr(attrs.attrs[i].aValue, " GSM/") != NULL) + return MGC_VCTYPE_GSM; + else if (strstr(attrs.attrs[i].aValue, "GSM-EFR") != NULL) + return MGC_VCTYPE_GSM_EFR; + else if (strstr(attrs.attrs[i].aValue, "AMR") != NULL) + return MGC_VCTYPE_AMR_12_2; + else if (strstr(attrs.attrs[i].aValue, "G729B") != NULL) + return MGC_VCTYPE_G729B; + else if (strstr(attrs.attrs[i].aValue, "PCMU") != NULL) + return MGC_VCTYPE_PCMU; + else if (strstr(attrs.attrs[i].aValue, "AMR_12_2") != NULL) + return MGC_VCTYPE_AMR_12_2; + else if (strstr(attrs.attrs[i].aValue, "AMR_10_2") != NULL) + return MGC_VCTYPE_AMR_10_2; + else if (strstr(attrs.attrs[i].aValue, "AMR_7_95") != NULL) + return MGC_VCTYPE_AMR_7_95; + else if (strstr(attrs.attrs[i].aValue, "AMR_7_4") != NULL) + return MGC_VCTYPE_AMR_7_4; + else if (strstr(attrs.attrs[i].aValue, "AMR_6_7") != NULL) + return MGC_VCTYPE_AMR_6_7; + else if (strstr(attrs.attrs[i].aValue, "AMR_5_15") != NULL) + return MGC_VCTYPE_AMR_5_15; + else if (strstr(attrs.attrs[i].aValue, "AMR_5_9") != NULL) + return MGC_VCTYPE_AMR_5_9; + else if (strstr(attrs.attrs[i].aValue, "AMR_4_75") != NULL) + return MGC_VCTYPE_AMR_4_75; + else + return MGC_VCTYPE_PCMA; + } + } + } + + if (i == attrs.num) + { + if (payload == 3) + return MGC_VCTYPE_GSM; + else if (payload == 84) + return MGC_VCTYPE_GSM_EFR; + else if (payload == 118) + return MGC_VCTYPE_G729B; + else if (payload == 0) + return MGC_VCTYPE_PCMU; + else if (payload == 71) + return MGC_VCTYPE_AMR_12_2; + else if (payload == 70) + return MGC_VCTYPE_AMR_10_2; + else if (payload == 69) + return MGC_VCTYPE_AMR_7_95; + else if (payload == 68) + return MGC_VCTYPE_AMR_7_4; + else if (payload == 67) + return MGC_VCTYPE_AMR_6_7; + else if (payload == 65) + return MGC_VCTYPE_AMR_5_15; + else if (payload == 66) + return MGC_VCTYPE_AMR_5_9; + else if (payload == 64) + return MGC_VCTYPE_AMR_4_75; + } + + return MGC_VCTYPE_PCMA; +} + +int mgc_update_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG *mediaInfo) +{ + WORD chnlIndex; + BYTE i; + WORD connectIndex; + BYTE ptime; + char tmpStr[128]; + + if ((chnl.mgNo != MGC_INTERNAL_VIRTUAL_MG) || + (chnl.portNo != 0)) + { + mgc_log_err("mgc_update_chnl_media: invalid mgNo or portNo!\n\r"); + return -1; + } + + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + + connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + + if (connectIndex > MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_update_chnl_media: invalid chnl connectNo!\n\r"); + return -1; + } + + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, mediaInfo, sizeof(PUB_SDP_MSG)); +// memcpy((BYTE *) &mgcChnl[chnlIndex].mediaAttr.sdp, mediaInfo, sizeof(PUB_SDP_MSG)); + + mgcConnectInfo[connectIndex].codecList.num = mediaInfo->medias.medias[0].m.plNum; + for (i = 0; i < mgcConnectInfo[connectIndex].codecList.num; i++) + { + mgcConnectInfo[connectIndex].codecList.codec[i] = mgc_payload_to_codec(mediaInfo->medias.medias[0].m.payloads[i], mediaInfo->medias.medias[0].attrs); + } + mgcConnectInfo[connectIndex].codecList.priority = 256; + + if (chnl.mgNo == MGC_MG_TYPE_INTERNAL) + { + mgcMgInfo[chnl.mgNo].mgAttr.codecList.num = mediaInfo->medias.medias[0].m.plNum; + + for (i = 0; i < mgcConnectInfo[connectIndex].codecList.num; i++) + { + mgcMgInfo[chnl.mgNo].mgAttr.codecList.codec[i] = mgcConnectInfo[connectIndex].codecList.codec[i]; + } + } + + for (i = 0; i < mediaInfo->medias.medias[0].attrs.num; i++) + { + if (mediaInfo->medias.medias[0].attrs.attrs[i].aType == PUB_SDP_ATTR_TYPE_PTIME) + { + ptime = atoi(mediaInfo->medias.medias[0].attrs.attrs[0].aValue); + break; + } + } + + if (i == mediaInfo->medias.medias[0].attrs.num) + ptime = 20; + + mgcConnectInfo[connectIndex].mediaAttr.ptime = ptime; + + if (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { +// mgcChnl[chnl.chlNo].status = MGC_CHNL_STATUS_CREATED; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + +// mgcChnl[chnlIndex].codecList.num = mediaInfo->medias.medias[0].m.plNum; +// for (i = 0; i < mgcChnl[chnlIndex].codecList.num; i++) +// mgcChnl[chnlIndex].codecList.codec[i] = mgc_payload_to_codec(mediaInfo->medias.medias[0].m.payloads[i]); +// mgcChnl[chnlIndex].codecList.priority = 1; + sprintf(tmpStr, "mgc_update_chnl_media: codec=%d, connectIndex=%d\n\r", mgcConnectInfo[connectIndex].codecList.codec[0], connectIndex); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum) +{ + char tmpStr[128]; + + if ((maxMgNum > MGC_MAX_NUM_OF_MG) || + (maxChnlNum > MGC_MAX_NUM_OF_CHNL)) + { + mgc_log_err("mgc_license_ctrl: invalid maxMgNum or maxChnlNum!\n\r"); + return -1; + } + + mgcMaxMgNo = maxMgNum; + mgcMaxChlNo = maxChnlNum; + + sprintf(tmpStr, "mgc_license_ctrl: succeed, mgcMaxMgNo = %d, mgcMaxChlNo = %d\n\r", mgcMaxMgNo, mgcMaxChlNo); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *mediaAttr) +{ + WORD portIndex; + WORD chnlIndex; + PORT_INFO *portInfo; + char tmpStr[128]; + int connectIndex; + + if ((port >= MGC_MAX_NUM_OF_PORT) || + ((cmd != MGCP_CMD_CRCX) && (mgcPort[port].usrPort != usrPort)) || + (mgcPort[port].llCmd != cmd)) + { + mgc_log_err("mgc_rsp: invalid port or cmd!\n\r"); + return -1; + } + + portInfo = &mgcPort[port]; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + + if ((cmd == MGCP_CMD_CRCX) && (retCode == 200)) + { + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_rsp: CRCX invalid connectIndex!\n\r"); + return -1; + } + + sprintf(mgcConnectInfo[connectIndex].mediaAttr.conId, "%X%04X%lX", portInfo->mgcfChnl.connectNo, usrPort, time(NULL)); + +// memcpy((BYTE *) &mgcChnl[chnlIndex].mediaAttr.sdp, (BYTE *) mediaAttr, sizeof(PUB_SDP_MSG)); + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, (BYTE *) &mediaAttr->sdp, sizeof(PUB_SDP_MSG)); + } + + mgcPort[port].usrCmd = retCode; + + sprintf(tmpStr, "mgc_rsp: succeed, usrPort = %d, port = %d, retCode = %d, cmd = %d\n\r", usrPort, port, retCode, cmd); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 0; +} + +/* +Parameter + chnl: the chnl need to update codec + codecList: the codec up layer support +Result + failure: return -1 + sucess : return 0~6 which is represent following codec + +#define MGC_VCTYPE_PCMA 0 +#define MGC_VCTYPE_PCMU 1 +#define MGC_VCTYPE_GSM 2 +#define MGC_VCTYPE_GSM_EFR 3 +#define MGC_VCTYPE_AMR 4 +#define MGC_VCTYPE_G729B 5 +#define MGC_VCTYPE_AMR_7_4 6 +*/ +int mgc_chnl_codec_update(CHNL chnl , MGC_CODEC_LIST codecList) +{ + MG_INFO *pMgInfo; + WORD chnlIndex, phyPort; + int connectIndex; + MGC_CODEC_LIST codecListMg; + MGC_CODEC_LIST codecListResult; + BYTE codec; + CONNECT_INFO *pConn = NULL; + int i,j; + + if(chnl.mgNo > MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_chnl_codec_update: invalid mgNo!\n\r"); + return -1; + } + + pMgInfo = &mgcMgInfo[chnl.mgNo]; + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return -1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_chnl_codec_update: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_chnl_codec_update: invalid connectNo!\n\r"); + return -1; + } + + + if ((MGC_MG_TYPE_ANN == pMgInfo->mgAttr.mgType)||(MGC_MG_TYPE_INTERNAL == pMgInfo->mgAttr.mgType)) + { + chnlIndex = pMgInfo->chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = pMgInfo->portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_chnl_codec_update: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if((mgcChnl[chnlIndex].connectIndex[chnl.connectNo] >= MGC_MAX_NUM_OF_CON)|| + ((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned != 1))) + { + connectIndex = mgc_assign_connect_to_chnl(chnl); + if(connectIndex < 0) + return -1; + } + else + { + connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + } + + pConn = &mgcConnectInfo[connectIndex]; + + memset(&codecListResult , 0 , sizeof(MGC_CODEC_LIST)); + memcpy(&codecListMg , &pMgInfo->mgAttr.codecList , sizeof(MGC_CODEC_LIST)); + codecListMg.priority = codecList.priority + 1; + + for(i=0 ; imgAttr.mgType == MGC_MG_TYPE_IPBSS) + memcpy(&pConn->codecList , &codecListResult , sizeof(MGC_CODEC_LIST)); + + switch(codecListResult.codec[0]) + { + case MGC_VCTYPE_AMR_12_2: + case MGC_VCTYPE_AMR_10_2: + return MGC_VCTYPE_AMR_12_2; + case MGC_VCTYPE_AMR_7_95: + case MGC_VCTYPE_AMR_7_4: + case MGC_VCTYPE_AMR_6_7: + case MGC_VCTYPE_AMR_5_15: + case MGC_VCTYPE_AMR_5_9: + case MGC_VCTYPE_AMR_4_75: + return MGC_VCTYPE_AMR_7_95; + default: + return codecListResult.codec[0]; + } + + return -1; +} + + +/* +Parameter + chnl: the chnl need to be queried +Result: + failure: return -1 + success: return 0~3 which represent following status + +#define MGC_CONNECT_STATUS_IDLE 0 +#define MGC_CONNECT_STATUS_CREATING 1 +#define MGC_CONNECT_STATUS_CREATED 2 +#define MGC_CONNECT_STATUS_TONE 3 +*/ +int mgc_query_chnl_status(CHNL chnl) +{ + MG_INFO *pMgInfo; + WORD chnlIndex, phyPort , connIndex; + + if(chnl.mgNo > MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_query_chnl_status: invalid mgNo!\n\r"); + return -1; + } + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_query_chnl_status: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_query_chnl_status: invalid connectNo!\n\r"); + return -1; + } + + + pMgInfo = &mgcMgInfo[chnl.mgNo]; + + if ((MGC_MG_TYPE_ANN == pMgInfo->mgAttr.mgType)||(MGC_MG_TYPE_INTERNAL == pMgInfo->mgAttr.mgType)) + { + chnlIndex = pMgInfo->chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = pMgInfo->portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + connIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + + if(connIndex > MGC_MAX_NUM_OF_CON) + return -1; + + return(mgcConnectInfo[connIndex].status); +} + + +OPER_REC *mgc_query_chnl_oper_rec(CHNL chnl) +{ + MG_INFO *pMgInfo; + WORD chnlIndex, phyPort , connIndex; + + if(chnl.mgNo > MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_query_chnl_status: invalid mgNo!\n\r"); + return NULL; + } + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_query_chnl_status: invalid portNo!\n\r"); + return NULL; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_query_chnl_status: invalid connectNo!\n\r"); + return NULL; + } + + + pMgInfo = &mgcMgInfo[chnl.mgNo]; + + if ((MGC_MG_TYPE_ANN == pMgInfo->mgAttr.mgType)||(MGC_MG_TYPE_INTERNAL == pMgInfo->mgAttr.mgType)) + { + chnlIndex = pMgInfo->chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = pMgInfo->portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + connIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + + if(connIndex > MGC_MAX_NUM_OF_CON) + return NULL; + + return &(mgcConnectInfo[connIndex].operRec); +} diff --git a/omc/plat/mgc/src/mgc.c.bak b/omc/plat/mgc/src/mgc.c.bak new file mode 100644 index 0000000..e5e6575 --- /dev/null +++ b/omc/plat/mgc/src/mgc.c.bak @@ -0,0 +1,4016 @@ +/****************************************************************/ +/* MGC Implementation Program */ +/* Version 9.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2007-4-17 */ +/****************************************************************/ + +#include "./include/mgc_pub.h" +#include "./include/mgc.h" +#include "./include/mgc_const.h" +#include "./include/mgc_def.h" +#include "./include/mgc_struct.h" +#include "./include/mgc_fsm.h" +#include "./include/mgc_debug.h" +#include "../../snmp/src/include/snmp.h" +#include "../../public/src/include/license_id.h" + +int mgc_is_non_virtual_mg(BYTE mgType) +{ + if ((mgType > MGC_MG_TYPE_INTERNAL) && (mgType < MGC_MG_TYPE_ANN)) + { + return 1; + } + else + { + return 0; + } + +} + +int mgc_8ecp_update_mg_status(BYTE mgNo, BYTE status) +{ + char tmpStr[128]; + + if (mgcMgInfo[mgNo].created == 0) + { + sprintf(tmpStr, "mgc_8ecp_update_mg_status: MG not created, mgNo = %d\n\r", mgNo); + mgc_log_err(tmpStr); + return -1; + } + + mgcMgInfo[mgNo].stLast = status; + + if (1 == mgcMgInfo[mgNo].mgAttr.e1cardNo) + { + if ((1 == status) + && ((0 == mgc_e1card0_mgNo) || (0 == mgcMgInfo[mgc_e1card0_mgNo].stLast))) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + } + } + else if (0 == mgcMgInfo[mgNo].mgAttr.e1cardNo) + { + if ((0 == status) + && (0 != mgc_e1card1_mgNo) && (1 == mgcMgInfo[mgc_e1card1_mgNo].stLast)) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + } + } + + return 0; +} + +int mgc_8ecp_update_trk_status(BYTE mgNo, BYTE trkNo, BYTE status) +{ + WORD portIndex; + char tmpStr[128]; + + if (mgcMgInfo[mgNo].created == 0) + { + sprintf(tmpStr, "mgc_8ecp_update_trk_status: MG not created, mgNo = %d\n\r", mgNo); + mgc_log_err(tmpStr); + return -1; + } + + if (trkNo >= MGC_8ECP_MAX_TRK_PER_MG) + { + sprintf(tmpStr, "mgc_8ecp_update_trk_status: invalid trkNo, trkNo = %d\n\r", trkNo); + mgc_log_err(tmpStr); + return -1; + } + + portIndex = mgcMgInfo[mgNo].portIndex[trkNo]; + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + return -1; + + mgcPhyPort[portIndex].stLast = status; + + return 0; +} + +int mgc_bind_8ecp() +{ + sprintf(mgc8ecpSap.name, "MGC"); + mgc8ecpSap.update_mg_status = mgc_8ecp_update_mg_status; + mgc8ecpSap.update_trk_status = mgc_8ecp_update_trk_status; + + if ((mgc8ecpSapIndex = _8ecp_bind(&mgc8ecpSap)) < 0) + return -1; + + return 0; +} + +int mgc_find_mg_by_name(char *mgName, WORD localPort, DWORD ip) +{ + WORD i; + char tmpStr[128]; + BYTE usrType; + + if (MGC_MG_NETWORK_PORT == localPort) + { + usrType = MGC_USER_TYPE_MG; + } + else + { + usrType = MGC_USER_TYPE_MGC; + } + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 0) + continue; + + if ((strcmp(mgcMgInfo[i].mgAttr.domain, mgName) == 0) + && (mgcMgInfo[i].usrType == usrType)) + return i; + } + + sprintf(tmpStr, "mgc_find_mg_by_name: invalid mgName: %s, ip: %ld\n\r", mgName, ip); + mgc_log_err(tmpStr); + + return -1; +} + +int mgc_codec_str_to_api(char *codec) +{ + if (strcmp(codec, "PCMA") == 0) + return MGC_VCTYPE_PCMA; + else if (strcmp(codec, "PCMU") == 0) + return MGC_VCTYPE_PCMU; + else if (strcmp(codec, "GSM") == 0) + return MGC_VCTYPE_GSM; + else if (strcmp(codec, "GSM-EFR") == 0) + return MGC_VCTYPE_GSM_EFR; + else if (strcmp(codec, "AMR") == 0) + return MGC_VCTYPE_AMR; + else if (strcmp(codec, "G729B") == 0) + return MGC_VCTYPE_G729B; + + return MGC_VCTYPE_PCMA; +} + +void mgc_connect_init(WORD connectIndex) +{ + memset((BYTE *) &mgcConnectInfo[connectIndex], 0, sizeof(CONNECT_INFO)); + mgcConnectInfo[connectIndex].port = 0xFFFF; + mgcConnectInfo[connectIndex].chlIndex = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.mgNo = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.portNo = 0xFF; + mgcConnectInfo[connectIndex].aasChnl.chlNo = 0xFFFF; + mgcConnectInfo[connectIndex].aasChnl.connectNo = 0xFFFF; +} + +int mgc_assign_connect_to_chnl(CHNL chnl) +{ + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if (1 == mgcConnectInfo[i].assigned) + { + continue; + } + else + { + mgc_connect_init(i); + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_assign_connect_to_chnl: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl.chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_assign_connect_to_chnl: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if ((chnlInfo->connectIndex[chnl.connectNo] >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[chnlInfo->connectIndex[chnl.connectNo]].assigned != 1)) + { + chnlInfo->connectIndex[chnl.connectNo] = i; + + mgcConnectInfo[i].assigned = 1; + mgcConnectInfo[i].status = MGC_CONNECT_STATUS_IDLE; + mgcConnectInfo[i].chlIndex = chnlIndex; + + return i; + } + else + { + if ((chnlInfo->connectIndex[chnl.connectNo] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[chnlInfo->connectIndex[chnl.connectNo]].assigned == 1)) + { + mgc_log_err("mgc_assign_connect_to_chnl: one connect already created on chnl's connectNo\n\r"); + return chnlInfo->connectIndex[chnl.connectNo]; + } + + return -1; + } + } + } + + mgc_log_err("mgc_assign_connect_to_chnl: connect resource is not sufficient\n\r"); + return -1; +} + +int mgc_assign_connect(CHNL *chnl, WORD *chnlConnectIndex) +{ + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + int i; + int j; + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if (1 == mgcConnectInfo[i].assigned) + { + continue; + } + else + { + mgc_connect_init(i); + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl->mgNo].chnlStartIndex + chnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl->mgNo].portIndex[chnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_assign_connect: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_assign_connect: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + for (j = 0; j < MGC_MAX_NUM_OF_CHNL_CON; j++) + { + if ((chnlInfo->connectIndex[j] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[chnlInfo->connectIndex[j]].assigned == 1)) + { + continue; + } + else + { + chnlInfo->connectIndex[j] = i; + *chnlConnectIndex = j; + chnl->connectNo = j; + + mgcConnectInfo[i].assigned = 1; + mgcConnectInfo[i].status = MGC_CONNECT_STATUS_IDLE; + mgcConnectInfo[i].chlIndex = chnlIndex; + + return i; + } + } + + mgc_log_err("mgc_assign_connect: chnl connect resource is not sufficient\n\r"); + return -1; + } + } + + mgc_log_err("mgc_assign_connect: connect resource is not sufficient\n\r"); + return -1; +} + +void mgc_remove_connect(WORD chnl) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + { + if ((mgcConnectInfo[i].assigned != 1) + || (mgcConnectInfo[i].chlIndex != chnl)) + { + continue; + } + else + { + mgc_connect_init(i); + } + } +} + +int mgc_release_connect(CHNL *chnl) +{ + WORD portIndex; + WORD chnlIndex; + WORD connectIndex; + CHNL_INFO *chnlInfo; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl->mgNo].chnlStartIndex + chnl->chlNo; + chnlInfo = &mgcChnl[chnlIndex]; + }//add by Francis + else + { + portIndex = mgcMgInfo[chnl->mgNo].portIndex[chnl->portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chnl->chlNo; + chnlInfo = &mgcChnl[chnlIndex]; + } + + + if (((connectIndex = chnlInfo->connectIndex[chnl->connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[connectIndex].chlIndex != chnlIndex)) + { + mgc_log_err("mgc_release_connect: the chnl connectNo has no connection\n\r"); + return -1; + } + else + { + mgc_connect_init(connectIndex); + + if (chnlInfo->connectNum > 0) + { + chnlInfo->connectNum--; + } + else + { + chnlInfo->connectNum = 0; + } + } + + return 0; +} + +int mgc_find_connect_by_con_id(CHNL *Chnl, char *conId) +{ + int i; + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + WORD chnlConnectIndex; + WORD connectIndex; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[Chnl->mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[Chnl->mgNo].chnlStartIndex + Chnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[Chnl->mgNo].portIndex[Chnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_find_connect_by_con_id: portIndex out of range!\r\n"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + Chnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_find_connect_by_con_id: chnlIndex out of range!\r\n"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if (mgcMgInfo[Chnl->mgNo].usrType == MGC_USER_TYPE_MG) + { + chnlConnectIndex = strtoll(conId, NULL, 16) >> 48; + + if ((chnlConnectIndex >= MGC_MAX_NUM_OF_CHNL_CON) + || (chnlInfo->connectIndex[chnlConnectIndex] >= MGC_MAX_NUM_OF_CON) + || (strcmp(conId, mgcConnectInfo[chnlInfo->connectIndex[chnlConnectIndex]].mediaAttr.conId) != 0)) + return -1; + else + return chnlConnectIndex; + } + else if (mgcMgInfo[Chnl->mgNo].usrType == MGC_USER_TYPE_MGC) + { + for (i = 0; i < MGC_MAX_NUM_OF_CHNL_CON; i++) + { + if ((connectIndex = chnlInfo->connectIndex[i]) >= MGC_MAX_NUM_OF_CON) + { + continue; + } + else + { + if ((0 == strcmp(conId, mgcConnectInfo[connectIndex].mediaAttr.conId)) + && (chnlIndex == mgcConnectInfo[connectIndex].chlIndex)) + { + return i; + } + } + } + + return -1; + } + else + return -1; +} + + +int mgc_extract_media_info(BYTE flag, BYTE cmd, MGCP_PARA *para, WORD port)//new replace +//int mgc_extract_media_info(BYTE flag, MGCP_PARA *para, CHNL *mgcfChnl) +{ + WORD portIndex; + WORD chnlIndex; + CHNL_INFO *chnlInfo; + BYTE num; + CHNL *mgcfChnl; + int connectIndex; + int chnlConnectIndex;//new replace + PORT_INFO *portInfo; + + portInfo = &mgcPort[port]; + mgcfChnl = &portInfo->mgcfChnl;//new replace + + if (((MGC_MG_TYPE_ANN != mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) && (mgcfChnl->portNo >= MGC_MAX_PHY_PORT_PER_MG)) + || (mgcfChnl->chlNo >= MGC_MAX_NUM_OF_CHNL)) + return 0; + + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[mgcfChnl->mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[mgcfChnl->mgNo].chnlStartIndex + mgcfChnl->chlNo; + }//add by Francis + else + { + portIndex = mgcMgInfo[mgcfChnl->mgNo].portIndex[mgcfChnl->portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_extract_media_info: phy portIndex out of range!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + mgcfChnl->chlNo; + } + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + { + mgc_log_err("mgc_extract_media_info: chnlIndex out of range!\n\r"); + return -1; + } + + chnlInfo = &mgcChnl[chnlIndex]; + + if (flag == MGCP_RESPONSE) + { + if ((MGCP_CMD_CRCX == cmd) + && (((para->flag & MGCP_PARA_FLAG_I) != MGCP_PARA_FLAG_I) || ((para->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP))) + { + mgc_log_err("mgc_extract_media_info: crcx miss para!!\n\r"); + return -1; + } + + if (mgcfChnl->connectNo != mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].chnlConnectIndex) + { + mgc_log_err("mgc_extract_media_info: connectNo is mismatch!\n\r"); + return -1; + } + + if((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd) && (MGCP_CMD_RSIP != cmd)) + { + connectIndex = chnlInfo->connectIndex[mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].chnlConnectIndex]; + } + + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_extract_media_info: chnl's connection released\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_I) == MGCP_PARA_FLAG_I) + { + strcpy(mgcConnectInfo[connectIndex].mediaAttr.conId, para->i.conId); + } + + if ((para->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + chnlInfo->comMediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + + if ((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd)) + mgcConnectInfo[connectIndex].mediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + } + } + else + { + if (MGCP_CMD_CRCX == cmd) + { + if ((connectIndex = mgc_assign_connect(mgcfChnl, &mgcPort[port].mgcfOperSteps[0].chnlConnectIndex)) < 0) + { + mgc_log_err("mgc_extract_media_info: assign connect failed\n\r"); + return -1; + } + + mgcPort[port].mgcfOperStepsNum = 1; + } + else if ((MGCP_CMD_MDCX == cmd) || (MGCP_CMD_DLCX == cmd)) + { + if ((chnlConnectIndex = mgc_find_connect_by_con_id(mgcfChnl, para->i.conId)) < 0) + { + mgc_log_err("mgc_extract_media_info: find connect by id failed\n\r"); + return -1; + } + + mgcfChnl->connectNo = chnlConnectIndex; + + connectIndex = chnlInfo->connectIndex[chnlConnectIndex]; + } +/* else + { + if (0xFFFF == (connectIndex = chnlInfo->connectIndex[0])) + { + mgc_log_err("mgc_extract_media_info: chnl's 0 connection released\n\r"); + return -1; + } + } +*/ + if (connectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_extract_media_info: chnl's connection released\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_L) == MGCP_PARA_FLAG_L) + { + mgcConnectInfo[connectIndex].mediaAttr.ecDisable = para->l.ecDisable; + mgcConnectInfo[connectIndex].mediaAttr.ssDisable = para->l.ssDisable; + mgcConnectInfo[connectIndex].mediaAttr.ptime = para->l.p; + mgcConnectInfo[connectIndex].mediaAttr.vocoderType = mgc_codec_str_to_api(para->l.codec); + } + + if ((para->flag & MGCP_PARA_FLAG_M) == MGCP_PARA_FLAG_M) + mgcConnectInfo[connectIndex].mediaAttr.conMode = para->m.mode; + + if ((para->flag & MGCP_PARA_FLAG_C) == MGCP_PARA_FLAG_C) + strcpy(mgcConnectInfo[connectIndex].mediaAttr.callId, para->c.callId); + + if ((para->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + chnlInfo->comMediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + mgcConnectInfo[connectIndex].mediaAttr.pkgEvent = (para->o.package << 8) | para->o.event; + } + + if ((para->flag & MGCP_PARA_FLAG_S) == MGCP_PARA_FLAG_S) + { + chnlInfo->comMediaAttr.pkgSignal = (para->s.pkg << 8) | para->s.signal; + mgcConnectInfo[connectIndex].mediaAttr.pkgSignal = (para->s.pkg << 8) | para->s.signal; + } + } + + if ((para->flag & MGCP_PARA_FLAG_SDP) == MGCP_PARA_FLAG_SDP) + { + if (flag == MGCP_RESPONSE) + { + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcConnectInfo[connectIndex].flag |= MGCP_PARA_FLAG_TFO; + memcpy(para->sdp.medias.medias, mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias, sizeof(PUB_SDP_MEDIA) * 8); + } + else + { + mgcConnectInfo[connectIndex].flag &= ~MGCP_PARA_FLAG_TFO; + } + } + + //memcpy((BYTE *) &chnlInfo->mediaAttr.sdp, (BYTE *) ¶->sdp, sizeof(PUB_SDP_MSG)); + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, (BYTE *) ¶->sdp, sizeof(PUB_SDP_MSG)); + } + + if ((MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RQNT != cmd)) + { + if ((mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].flag & PUB_SDP_FLAG_C) != PUB_SDP_FLAG_C) + //if ((chnlInfo->mediaAttr.sdp.medias.medias[0].flag & PUB_SDP_FLAG_C) != PUB_SDP_FLAG_C) + { + //memcpy(&chnlInfo->mediaAttr.sdp.medias.medias[0].c, &chnlInfo->mediaAttr.sdp.c, sizeof(PUB_SDP_C)); + //chnlInfo->mediaAttr.sdp.medias.medias[0].flag |= PUB_SDP_FLAG_C; + memcpy(&mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].c, &mgcConnectInfo[connectIndex].mediaAttr.sdp.c, sizeof(PUB_SDP_C)); + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].flag |= PUB_SDP_FLAG_C; + } + + num = mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.num; + //num = chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.num; + if (num < PUB_SDP_MAX_ATTR_NUM) + { + //chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aType = PUB_SDP_ATTR_TYPE_PTIME; + //sprintf(chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aValue, "%d", chnlInfo->mediaAttr.ptime); + //chnlInfo->mediaAttr.sdp.medias.medias[0].attrs.num++; + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aType = PUB_SDP_ATTR_TYPE_PTIME; + sprintf(mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.attrs[num].aValue, "%d", mgcConnectInfo[connectIndex].mediaAttr.ptime); + mgcConnectInfo[connectIndex].mediaAttr.sdp.medias.medias[0].attrs.num++; + } + } + + return 0; +} + +void mgc_port_init(WORD port) +{ + memset((BYTE *) &mgcPort[port], 0, sizeof(PORT_INFO)); +} + +int mgc_get_port() +{ + WORD i; + + for (i = 0; i < MGC_MAX_NUM_OF_PORT; i++) + { + if (mgcPort[i].assigned != 0) + continue; + + mgcPort[i].assigned = 1; + return i; + } + + return -1; +} + +int mgc_mgcp_ind(BYTE cmd, WORD *usrPort, WORD hdlPort, MGCP_PARA *para) +{ + int port; + int mgNo; + PORT_INFO *portInfo; + MGCP_SL *sl; + WORD portIndex = 0xFFFF, chnlIndex = 0xFFFF; + char tmpStr[128]; + MG_ATTR *mgAttr; + WORD associPort; + + if (para == NULL) + { + mgc_log_err("mgc_mgcp_ind: para is NULL\n\r"); + return -1; + } + + if ((para->flag & MGCP_PARA_FLAG_SL) != MGCP_PARA_FLAG_SL) + { + mgc_log_err("mgc_mgcp_ind: missing start line\n\r"); + return -1; + } + + sl = ¶->sl; + if ((mgNo = mgc_find_mg_by_name(sl->mgName, para->localPort, para->ip)) < 0) + { + mgc_log_err("mgc_mgcp_ind: can't find the mgName\n\r"); + return -1; + } + + if ((mgcMgInfo[mgNo].portIndex[sl->trkNum] >= MGC_MAX_NUM_OF_PHY_PORT) + && (cmd == MGCP_CMD_RSIP)) + { + mgcMgcpPara.ip = mgcMgInfo[mgNo].mgAttr.ip; + + if (mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MGC) + { + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + } + else + { + mgcMgcpPara.localPort = MGC_MGCP_MG_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MGC_PORT; + } + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = MGCP_RESPONSE; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + MGCP_rsp(mgcMgcpSapIndex, cmd, 0xFFFF, hdlPort, 200, &mgcMgcpPara); + return 0; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mgcp_ind: can't allocate port\n\r"); + return -1; + } + + mgAttr = &mgcMgInfo[mgNo].mgAttr; + + portInfo = &mgcPort[port]; + portInfo->mgcfState = MGC_MGCF_STATE_INDICATION; + portInfo->llPort = hdlPort; + portInfo->llCmd = cmd; + + if (mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MG) + portInfo->ip = para->ip; + + portInfo->mgcfChnl.mgNo = mgNo; + portInfo->mgcfChnl.portNo = sl->trkNum; + portInfo->mgcfChnl.chlNo = sl->chlNum; + + if ((MGCP_CMD_CRCX == cmd) || (MGCP_CMD_MDCX == cmd) || (MGCP_CMD_DLCX == cmd)) + { + mgc_extract_media_info(MGCP_COMMAND, cmd, para, port);//new replace + } + + *usrPort = port; + + if (sl->trkNum < MGC_MAX_PHY_PORT_PER_MG) + { + portIndex = mgcMgInfo[mgNo].portIndex[sl->trkNum]; + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && + (sl->chlNum < mgcPhyPort[portIndex].chnlNum)) + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + sl->chlNum; + } + else + { + chnlIndex = mgcMgInfo[mgNo].chnlStartIndex + sl->chlNum; + } + + sprintf(tmpStr, "mgc_mgcp_ind: succeed, cmd = %d, usrPort = %d, hdlPort = %d, mgNo: %d, portNo: %d, chlNo: %d\n\r", + cmd, port, hdlPort, portInfo->mgcfChnl.mgNo, portInfo->mgcfChnl.portNo, portInfo->mgcfChnl.chlNo); + mgc_log_procedure(mgNo, portIndex, chnlIndex, tmpStr); + + if ((mgcMgInfo[mgNo].usrType == MGC_USER_TYPE_MGC) + && (cmd != MGCP_CMD_RSIP)) + { + if ((portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + || (mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo] >= MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_mgcp_ind: connectNo >= MGC_MAX_NUM_OF_CHNL_CON\n\r"); + mgc_port_init(port); + return -1; + } + + associPort = mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]].port; + + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_CLEAR_AFTER_OPER; + mgc_log_err("mgc_mgcp_ind: DLCX recved from MG, Chnl clear remain connection operation !\n\r"); + + mgcMgcpPara.ip = mgcMgInfo[mgNo].mgAttr.ip; + + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = MGCP_RESPONSE; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + MGCP_rsp(mgcMgcpSapIndex, cmd, port, hdlPort, 250, &mgcMgcpPara); + +// mgc_connect_init(mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]); + mgc_port_init(port); + } + } + + return 0; +} + +int mgc_mgcp_cnf(BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para) +{ + char tmpStr[128]; + + if (usrPort >= MGC_MAX_NUM_OF_PORT) + { + sprintf(tmpStr, "mgc_mgcp_cnf, invalid usrPort = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", usrPort, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (mgcPort[usrPort].llPort != hdlPort) + { + sprintf(tmpStr, "mgc_mgcp_cnf, mismatched llport = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", mgcPort[usrPort].llPort, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (mgcPort[usrPort].mgcfOperSteps[mgcPort[usrPort].mgcfOperStepIndex].cmd != cmd) + { + sprintf(tmpStr, "mgc_mgcp_cnf, mismatched cmd = %d, hdlPort = %d, cmd = %d, retCode = %d\n\r", + mgcPort[usrPort].mgcfOperSteps[mgcPort[usrPort].mgcfOperStepIndex].cmd, hdlPort, cmd, retCode); + mgc_log_err(tmpStr); + return -1; + } + + if (((MGCP_CMD_CRCX == cmd) && (retCode == 200)) || (MGCP_CMD_MDCX == cmd)) + { +// mgc_extract_media_info(MGCP_RESPONSE, para, &mgcPort[usrPort].mgcfChnl); + if (mgc_extract_media_info(MGCP_RESPONSE, cmd, para, usrPort) < 0)//new replace + { + sprintf(tmpStr, "mgc_mgcp_cnf: extract_media fail cmd = %d, hdlPort = %d, retCode = %d\n\r", cmd, hdlPort, retCode); + mgc_log_err(tmpStr); + return -1; + } + } + + mgcPort[usrPort].llCmd = retCode; + + return 0; +} + +int mgc_bind_mgcp() +{ + sprintf(mgcMgcpSap.name, "MGC"); + mgcMgcpSap.MGCP_ind = mgc_mgcp_ind; + mgcMgcpSap.MGCP_cnf = mgc_mgcp_cnf; + + if ((mgcMgcpSapIndex = mgcp_bind(&mgcMgcpSap)) < 0) + return -1; + + return 0; +} + +void mgc_chnl_init(WORD chnl) +{ + memset((BYTE *) &mgcChnl[chnl], 0, sizeof(CHNL_INFO)); + memset((BYTE *) mgcChnl[chnl].connectIndex, 0xFFFF, sizeof(WORD)*MGC_MAX_NUM_OF_CHNL_CON);//new replace + mgcChnl[chnl].port = 0xFFFF; + mgcChnl[chnl].sapIndex = 0xFF; +} + +int mgc_vc_name_init() +{ + strcpy(vcName[0], "PCMA"); + strcpy(vcName[1], "PCMU"); + strcpy(vcName[2], "GSM"); + strcpy(vcName[3], "GSM-EFR"); + strcpy(vcName[4], "AMR"); + strcpy(vcName[5], "G729B"); + + return 0; +} + +int mgc_get_non_virtual_trk_status(WORD mgNo) +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, j = 0; + MG_INFO *mgInfo; + + mgInfo = &mgcMgInfo[mgNo]; + mgcVarList = &mgcSnmpPdu.var[0]; + mgcSnmpPdu.var_num = 0; //val list number + + if (MGC_MG_TYPE_AudioCoder == mgInfo->mgAttr.mgType) + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgInfo->portIndex[i] != 0xFFFF) + { + mgcVarList[j].oidlen = MGC_AC_LINE_STATUS_IDLEN; + MGC_AC_LINE_STATUS_OID[MGC_AC_LINE_STATUS_IDLEN - 1] = i; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_AC_LINE_STATUS_OID, MGC_AC_LINE_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + j++; + } + } + } + else if (MGC_MG_TYPE_LGC_MG == mgInfo->mgAttr.mgType) + { + mgcVarList[0].oidlen = MGC_LGC_MG_STATUS_IDLEN; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_LGC_MG_STATUS_OID, MGC_LGC_MG_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + }//revise by Francis 0822 + + mgInfo->requestId = (++mgInfo->requestId) & 0xFFFF; + if (mgInfo->requestId == 0) + mgInfo->requestId = 1; + + mgcSnmpPdu.pdu_type = 0x00; //get + mgcSnmpPdu.request_id = (mgNo << 16) | mgInfo->requestId; + + mgcSnmpAddr.local_port = 4968; + mgcSnmpAddr.remote_port = 161; + mgcSnmpAddr.broadcast = 0; //Not broadcast + mgcSnmpAddr.remote_ip = mgInfo->mgAttr.ip; + + if (mgcSnmpPdu.var_num) + snmp_send(&mgcSnmpPdu,&mgcSnmpAddr); + + return 1; +} + +int mgc_get_snmp_msg() +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, trkNo; + WORD mgNo, portIndex; + MG_INFO *mgInfo; + + mgcSnmpAddr.local_port = 4968; + if (!snmp_receive(&mgcSnmpPdu, &mgcSnmpAddr)) + return 0; + + if (mgcSnmpPdu.error_index != 0) + return -1; + + mgNo = mgcSnmpPdu.request_id >> 16; + mgInfo = &mgcMgInfo[mgNo]; + if ((mgcSnmpPdu.request_id & 0xFFFF) != mgInfo->requestId) + return -1; + + if (mgcSnmpPdu.var_num > MGC_MAX_PHY_PORT_PER_MG) + return -1; + + mgcVarList = &mgcSnmpPdu.var[0]; + + for (i = 0; i < mgcSnmpPdu.var_num; i++) + { + trkNo = mgcVarList[i].oid[MGC_AC_LINE_STATUS_IDLEN - 1]; + if (trkNo > (MGC_MAX_PHY_PORT_PER_MG - 1)) + return -1; + if ((portIndex = mgInfo->portIndex[trkNo]) != 0xFFFF) + { + if (mgcVarList[i].msg[0] == 1) + { // No Alarm + mgcPhyPort[portIndex].stLast = 1;//revise by Francis 0822 + } + else + { // Alarm + mgcPhyPort[portIndex].stLast = 0;//revise by Francis 0822 + } + } + } + + return 1; +} + +void mgc_get_mg_trk_status() +{ + BYTE i; + WORD mg, portIndex; + CHNL chnl; + static BYTE stage = 0; + + stage++; + + for (mg = 0; mg < MGC_MAX_NUM_OF_MG; mg++) + { + if ((mgcMgInfo[mg].created == 0) || + ((!mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType)) && + (mgcMgInfo[mg].mgAttr.mgType != MGC_MG_TYPE_ANN))) + continue; + + chnl.mgNo = mg; + chnl.chlNo = 1; + + if ((mgcMgInfo[mg].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_MGCP) + && (mgcMgInfo[mg].usrType == MGC_USER_TYPE_MGC)) + { + if (mgcMgInfo[mg].mgAttr.mgType == MGC_MG_TYPE_ANN)//revise by Francis 0822 + { + chnl.portNo = 0; + mgc_auep_chnl(0xFFFF, chnl); + } + else if (mgcMgInfo[mg].portNum > 0) + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgcMgInfo[mg].portIndex[i] == 0xFFFF) + continue; + else + { + chnl.portNo = i; + mgc_auep_chnl(0xFFFF, chnl); + break; + } + } + } + + if ((mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType)) + && (mgcMgInfo[mg].portNum > 0)) + { + if (MGC_MG_TYPE_SSW_CSS != mgcMgInfo[mg].mgAttr.mgType) + { + mgc_get_non_virtual_trk_status(mg); + }//revise by Francis 0822 + } + } + + if ((stage & 1) == 0) + { + mgcMgInfo[mg].status = mgcMgInfo[mg].stLast; + mgcMgInfo[mg].stLast = 0; + if (mgc_is_non_virtual_mg(mgcMgInfo[mg].mgAttr.mgType))//revise by Francis 0822 + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + portIndex = mgcMgInfo[mg].portIndex[i]; + if (portIndex != 0xFFFF) + { + mgcPhyPort[portIndex].phyStatus = mgcPhyPort[portIndex].stLast; + mgcPhyPort[portIndex].stLast = 0; + } + } + } + } + } +} + +void mgc_t10s() +{ + static DWORD cntT10s = 0; + static DWORD cntT50ms = 0; + + if (++cntT50ms >= MGC_MGCF_TIMER_50MS) + { // 50 mini seconds period + cntT50ms = 0; + mgc_get_snmp_msg(); + mgc_mon(); + } + + if (++cntT10s >= MGC_MGCF_TIMER_10S) + { // 10 seconds period + cntT10s = 0; + mgc_get_mg_trk_status(); + } +} + +int mgc_mg_init(WORD mgNo) +{ + memset((BYTE *) &mgcMgInfo[mgNo], 0, sizeof(MG_INFO)); + memset((BYTE *) &mgcMgInfo[mgNo].portIndex, 0xFFFF, sizeof(WORD) * MGC_MAX_PHY_PORT_PER_MG); + + return 0; +} + +void mgc_init(DWORD systemId, DWORD localIp, DWORD peerIp) +{ + WORD i; + MG_ATTR tmpMgAttr; + MG_ATTR *mgAttr = &tmpMgAttr; + + printf("MGC module init start!\n"); + + if (mgc_bind_8ecp() < 0) + printf("MGC module binds 8ECP fail!\n"); + if (mgc_bind_mgcp() < 0) + printf("MGC module binds MGCP fail!\n"); + + memset((BYTE *) &mgcSap[0], 0, sizeof(MGC_SAP) * MGC_MAX_NUM_OF_SAP); + memset((BYTE *) &mgcPhyPort[0], 0, sizeof(PHY_PORT_INFO) * MGC_MAX_NUM_OF_PHY_PORT); + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + mgc_mg_init(i); + + for (i = 0; i < MGC_MAX_NUM_OF_PORT; i++) + mgc_port_init(i); + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + mgc_chnl_init(i); + + + for (i = 0; i < MGC_MAX_NUM_OF_CON; i++) + mgc_connect_init(i);//new replace + + + mgc_vc_name_init(); + + memset(mgc_aas_mgNo, 0xFFFF, sizeof(WORD)*MGC_MAX_NUM_OF_AAS_MGC); + + mgc_select_ass_mgc_mgNo = 0; + + mgcMaxMgNo = MGC_MAX_NUM_OF_MG; + mgcMaxChlNo = MGC_MAX_NUM_OF_CHNL; + mgcMgCreated = 0; + mgcChlAssigned = 0; + + memset(mgAttr, 0, sizeof(MG_ATTR)); + mgAttr->mgType = MGC_MG_TYPE_INTERNAL; + mgAttr->ctrlType = MGC_MG_CTRL_TYPE_MGCP; + strcpy(mgAttr->domain, "InternalMG"); + mgAttr->ip = 1; + + mgc_create_MG(0, mgAttr); + + mgc_8k_tone_card_silent = 0; + + mgc_e1card0_mgNo = 0; + mgc_e1card1_mgNo = 0; + + sysID = systemId; + localIP = localIp; + peerIP = peerIp; + + strcpy(mgcAsciInBuf, "\0"); + strcpy(mgcAsciOutBuf, "\0"); + mgcMonitorFg = MGC_MONITOR_NONE; + mgc_debug_set(); + + printf("MGC module init complete!\n"); +} + +void mgc_timer() +{ + WORD port; + + for (port = 0; port < MGC_MAX_NUM_OF_PORT; port++) + { + if (mgcPort[port].assigned == 0) + continue; + + mgc_fsm(port); + } + + mgc_t10s(); +} + +int mgc_bind(MGC_SAP *sap) +{ + BYTE sapIndex; + + if (wxc2_get_license(LIC_MGC) <= 0) + { + mgc_log_err("mgc_bind: mgc module is not presented!\n\r"); + return -1; + } + + if ((sap == NULL) || + (sap->mgc_cnf == NULL) || + (sap->usrType > MGC_USER_TYPE_MG)) + return -1; + + for (sapIndex = 0; sapIndex < MGC_MAX_NUM_OF_SAP; sapIndex++) + { + if (mgcSap[sapIndex].mgc_cnf != NULL) + continue; + + memcpy((BYTE *) &mgcSap[sapIndex], sap, sizeof(MGC_SAP)); + return sapIndex; + } + + return -1; +} + +int mgc_unbind(MGC_SAP *sap, BYTE sapIndex) +{ + if ((sap == NULL) || (sapIndex >= MGC_MAX_NUM_OF_SAP)) + return -1; + + if ((strcmp(sap->usrName, mgcSap[sapIndex].usrName) != 0) || + (sap->usrType != mgcSap[sapIndex].usrType)) + return -1; + + memset((BYTE *) &mgcSap[sapIndex], 0, sizeof(MGC_SAP)); + + return 0; +} + +int mgc_store_aas_mgc_mg(WORD mgNo) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if ((mgc_aas_mgNo[i] < MGC_MAX_NUM_OF_MG) && (mgc_aas_mgNo[i] > 0)) + { + continue; + } + else + { + mgc_aas_mgNo[i] = mgNo; + return 0; + } + } + + return -1; +} + +int mgc_delet_aas_mgc_mg(WORD mgNo) +{ + int i; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if ((mgc_aas_mgNo[i] > 0) && (mgc_aas_mgNo[i] != mgNo)) + { + continue; + } + else + { + mgc_aas_mgNo[i] = 0; + return 0; + } + } + + return -1; +} + +int mgc_assign_chnl(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE chnlType) +{ + WORD i, j; + WORD chnlStart, chnlEnd, chnlNum; + + if (mgNo >= MGC_MAX_NUM_OF_MG) + { + return -1; + } + + if (chnlType == MGC_MG_TYPE_ANN) + { + chnlStart = MGC_CHNL_START_ANN; + chnlEnd = MGC_CHNL_START_ANN + MGC_CHNL_NUM_ANN; + chnlNum = MGC_CHNL_NUM_ANN_PER_TYPE; + } + else if (chnlType == MGC_PHY_PORT_TYPE_ANALOG) + { + chnlStart = MGC_CHNL_START_AALN; + chnlEnd = MGC_CHNL_START_AALN + MGC_CHNL_NUM_AALN; + chnlNum = MGC_CHNL_NUM_AALN_PER_PORT; + } + else if(chnlType == MGC_MG_TYPE_INTERNAL) + { + chnlStart = MGC_CHNL_START_INTERNAL; + chnlEnd = MGC_CHNL_START_INTERNAL+ MGC_CHNL_NUM_INTERNAL; + chnlNum = MGC_CHNL_NUM_INTERNAL_PER_PORT; + } + else + { + chnlStart = MGC_CHNL_START_DS; + chnlEnd = MGC_CHNL_START_DS + MGC_CHNL_NUM_DS_TOTAL; + chnlNum = MGC_CHNL_NUM_DS_PER_PORT; + } + + if ((mgcChlAssigned + chnlNum) > mgcMaxChlNo) + return -1; + + for (i = chnlStart; i < chnlEnd; i += chnlNum) + { + if (mgcChnl[i].assigned == 1) + continue; + + for (j = 0; j < chnlNum; j++) + { + mgcChnl[i + j].assigned = 1; + mgcChnl[i + j].mgNo = mgNo; + mgcChnl[i + j].portNo = portNo; + mgcChnl[i + j].port = 0xFFFF; + + if (chnlType == MGC_MG_TYPE_ANN) + { + mgcChnl[i + j].sapIndex = sapIndex; + } + } + + mgcChlAssigned += chnlNum; + + return i; + } + + return -1; +} + +int mgc_remove_chnl(WORD chnlIndex, WORD chnlNum) +{ + WORD i, port; + + if ((chnlIndex>MGC_MAX_NUM_OF_CHNL) || ((chnlIndex+chnlNum)>MGC_MAX_NUM_OF_CHNL)) + { + return -1; + } + + for (i = 0; i < chnlNum; i++) + { + port = mgcChnl[chnlIndex + i].port; + if (port < MGC_MAX_NUM_OF_CHNL) + mgcPort[port].mngCmd = MGC_MNG_CMD_REMOVE_CHNL; + + mgc_chnl_init(chnlIndex + i); + + mgc_remove_connect(chnlIndex + i); + } + + if (mgcChlAssigned > chnlNum) + mgcChlAssigned -= chnlNum; + else + mgcChlAssigned = 0; + + return 0; +} + +int mgc_assign_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr) +{ + int chnlIndex; + BYTE cardNo; + + if ((mgNo >= MGC_MAX_NUM_OF_MG) || (mgAttr == NULL) || (0 == strcmp(mgAttr->domain, "")) + || (0 == mgAttr->ip)) + { + return -1; + } + + if (mgAttr->mgType == MGC_MG_TYPE_ANN) + { + if ((chnlIndex = mgc_assign_chnl(sapIndex, mgNo, 0xFF, MGC_MG_TYPE_ANN)) < 0) + return -1; + mgcMgInfo[mgNo].chnlNum = MGC_CHNL_NUM_ANN_PER_TYPE; + mgcMgInfo[mgNo].chnlStartIndex = chnlIndex; + } + + if (mgAttr->mgType == MGC_MG_TYPE_INTERNAL) + { + if ((chnlIndex = mgc_assign_chnl(0xFF, mgNo, 0xFF, MGC_MG_TYPE_INTERNAL)) < 0) + return -1; + mgcMgInfo[mgNo].chnlNum = MGC_CHNL_NUM_INTERNAL_PER_PORT; + mgcMgInfo[mgNo].chnlStartIndex = chnlIndex; + }//add by Francis + + if (MGC_MG_CTRL_TYPE_8ECP == mgAttr->ctrlType) + { + if ((cardNo = atoi(mgAttr->domain)) > 31) + { + mgc_log_err("mgc_create_MG: 8ecp domain out of range!\n\r"); + return -1; + } + + _8ecp_createMG(mgNo, mgAttr->ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = mgNo; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = mgNo; + } + } + + mgcMgInfo[mgNo].created = 1; + memcpy((BYTE *) &mgcMgInfo[mgNo].mgAttr, (BYTE *) mgAttr, sizeof(MG_ATTR)); + mgcMgInfo[mgNo].mgAttr.e1cardNo = cardNo; + mgcMgInfo[mgNo].portNum = 0; + memset((BYTE *) mgcMgInfo[mgNo].portIndex, 0xFFFF, sizeof(WORD) * MGC_MAX_PHY_PORT_PER_MG); + + mgcMgCreated++; + + return mgNo; +} + +int mgc_create_MG(BYTE sapIndex, MG_ATTR *mgAttr) +{ + WORD i; + int mgNo; + char tmpStr[128]; + + if ((mgAttr == NULL) || (sapIndex >= MGC_MAX_NUM_OF_SAP) || (0 == strcmp(mgAttr->domain, "")) + || (0 == mgAttr->ip) || ((MGC_MG_CTRL_TYPE_8ECP != mgAttr->ctrlType) && (MGC_MG_CTRL_TYPE_MGCP != mgAttr->ctrlType))) + { + mgc_log_err("mgc_create_MG: invalid sapIndex or NULL mgAttr or No domain or No ip!\n\r"); + return -1; + } + + if ((mgcMgCreated + 1) > mgcMaxMgNo) + { + mgc_log_err("mgc_create_MG: license not enough!\n\r"); + return -1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 0) + { + continue; + } + + if ((0 == strcmp(mgcMgInfo[i].mgAttr.domain, mgAttr->domain)) + && (mgcMgInfo[i].mgAttr.ip == mgAttr->ip) && (mgcMgInfo[i].usrType == mgcSap[sapIndex].usrType)) + { + if (mgcMgInfo[i].sapIndex[sapIndex] == 0) + { + mgcMgInfo[i].sapIndex[sapIndex] = 1; + return i; + } + else + { + mgc_log_err("mgc_create_MG: duplicated MG and sapIndex!\n\r"); + return -1; + } + } + } + + if (mgAttr->mgType == MGC_MG_TYPE_INTERNAL) + { + if (0 == mgcMgInfo[0].created) + return mgc_assign_MG(0xFF, MGC_INTERNAL_VIRTUAL_MG, mgAttr); + else + return -1; + } + + for (i = 1; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created == 1) + continue; + mgNo = mgc_assign_MG(sapIndex, i, mgAttr); + if (mgNo >= 0) + { + if ((mgcMonitorFg & MGC_MONITOR_ALL) == MGC_MONITOR_ALL) + { + sprintf(tmpStr, "mgc_create_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgAttr->domain); + mgc_asciout_proc(tmpStr); + mgcMgInfo[mgNo].monFlag = 1; + } + mgcMgInfo[mgNo].usrType = mgcSap[sapIndex].usrType; + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgNo].mgAttr.mgType) + && (MGC_USER_TYPE_MGC == mgcMgInfo[mgNo].usrType)) + { + if (mgc_store_aas_mgc_mg(mgNo) < 0) + { + mgc_log_err("mgc_assign_MG: no resource store AAS MGC MG!\n\r"); + mgc_mg_init(mgNo); + return -1; + } + } + + mgcMgInfo[mgNo].sapIndex[sapIndex] = 1; + + return mgNo; + } + else + { + mgc_log_err("mgc_assign_MG: MG assign failed!\n\r"); + + return -1; + } + } + + mgc_log_err("mgc_create_MG: MG resource not available!\n\r"); + + return -1; +} + +int mgc_delete_MG(BYTE sapIndex, WORD mgNo) +{ + BYTE i; + char tmpStr[128]; + BYTE cardNo; + BYTE mgFlag = 0; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || (0 == mgNo) + || (0 == mgcMgInfo[mgNo].created))//add by Francis + { + mgc_log_err("mgc_delete_MG: invalid sapIndex or mgNo!\n\r"); + return -1; + } + + if (MGC_MG_CTRL_TYPE_8ECP == mgcMgInfo[mgNo].mgAttr.ctrlType) + { + cardNo = mgcMgInfo[mgNo].mgAttr.e1cardNo; + + if (cardNo > 31) + { + mgc_log_err("mgc_delete_MG: invalid 8ecp cardNo!\n\r"); + return -1; + } + + _8ecp_deleteMG(mgNo, mgcMgInfo[mgNo].mgAttr.ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = 0; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = 0; + } + } + else + { + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgNo].mgAttr.mgType) && (mgcMgInfo[mgNo].chnlNum > 0)) + { + mgc_delet_aas_mgc_mg(mgNo); + + mgc_remove_chnl(mgcMgInfo[mgNo].chnlStartIndex, mgcMgInfo[mgNo].chnlNum); + }//add by Francis + else + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + if (mgcMgInfo[mgNo].portIndex[i] < MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_delete_port(sapIndex, mgNo, i); + } + } + } + } + + mgcMgInfo[mgNo].sapIndex[sapIndex] = 0; + + for (i = 0; i < MGC_MAX_NUM_OF_SAP; i++) + { + if (mgcMgInfo[mgNo].sapIndex[i] == 1) + { + mgFlag = 1; + break; + } + } + + if (mgFlag == 0) + { + mgc_mg_init(mgNo); + + if (mgcMgCreated > 0) + mgcMgCreated--; + + sprintf(tmpStr, "mgc_delete_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgcMgInfo[mgNo].mgAttr.domain); + mgc_asciout_proc(tmpStr); + + return 0; + } + + mgc_log_err("mgc_delete_MG: other users are using this mg!\n\r"); + + return 0; +} + +int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr) +{ + char tmpStr[128]; + BYTE cardNo; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_modify_MG: invalid sapIndex or mgNo!\n\r"); + return -1; + } + + if (0 == mgcMgInfo[mgNo].created) + { + mgc_log_err("mgc_modify_MG: mg not create!\n\r"); + return -1; + } + + if (MGC_MG_CTRL_TYPE_8ECP == mgAttr->ctrlType) + { + if ((cardNo = atoi(mgAttr->domain)) > 31) + { + mgc_log_err("mgc_modify_MG: 8ecp domain out of range!\n\r"); + return -1; + } + + _8ecp_createMG(mgNo, mgAttr->ip, cardNo); + } + + memcpy((BYTE *) &mgcMgInfo[mgNo].mgAttr, (BYTE *) mgAttr, sizeof(MG_ATTR)); + + sprintf(tmpStr, "mgc_modify_MG: succeed, sapIndex = %d, mgNo = %d, mgDomain: %s\n\r", sapIndex, mgNo, mgAttr->domain); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType) +{ + WORD i; + int chnlIndex; + MG_INFO *mgInfo; + BYTE chnlNum; + WORD portIndex; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (portType > MGC_PHY_PORT_TYPE_ANALOG)) + { + mgc_log_err("mgc_add_port: invalid sapIndex, mgNo, portNo, or portType!\n\r"); + return -1; + } + + mgInfo = &mgcMgInfo[mgNo]; + + if (mgInfo->created != 1) + { + mgc_log_err("mgc_add_port: MG not created!\n\r"); + return -1; + } + + if ((mgInfo->portNum + 1) > mgInfo->mgAttr.maxPorts) + { + mgc_log_err("mgc_add_port: reached maxPorts of that MG!\n\r"); + return -1; + } + + portIndex = mgcMgInfo[mgNo].portIndex[portNo]; + + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && + (mgcPhyPort[portIndex].created == 1)) + { + mgc_log_err("mgc_add_port: port already created!\n\r"); + return -1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + { + if (mgcPhyPort[i].created == 1) + continue; + if (mgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + { + if (portType == MGC_PHY_PORT_TYPE_ANALOG) + chnlNum = MGC_CHNL_NUM_AALN_PER_PORT; + else + chnlNum = MGC_CHNL_NUM_DS_PER_PORT; + if ((chnlIndex = mgc_assign_chnl(sapIndex, mgNo, portNo, portType)) < 0) + { + mgc_log_err("mgc_add_port: insufficient channel resources!\n\r"); + return -1; + } + mgcPhyPort[i].chnlNum = chnlNum; + mgcPhyPort[i].chnlStartIndex = chnlIndex; + } + + mgcPhyPort[i].created = 1; + mgcPhyPort[i].mgNo = mgNo; + mgcPhyPort[i].portNo = portNo; + mgcPhyPort[i].portType = portType; + mgcPhyPort[i].sapIndex = sapIndex; + + mgInfo->portIndex[portNo] = i; + mgInfo->portNum++; + + if ((mgcMonitorFg & MGC_MONITOR_ALL) == MGC_MONITOR_ALL) + mgcPhyPort[i].monFlag = 1; + + sprintf(tmpStr, "mgc_add_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d, portType = %d, allocated portNo = %d\n\r", sapIndex, mgNo, portNo, portType, i); + mgc_log_procedure(mgNo, i, 0xFFFF, tmpStr); + + return i; + } + + mgc_log_err("mgc_add_port: insufficient port resource!\n\r"); + + return -1; +} + +int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo) +{ + WORD portIndex; + MG_INFO *mgInfo; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_delete_port: invalid sapIndex, mgNo, portNo!\n\r"); + return -1; + } + + mgInfo = &mgcMgInfo[mgNo]; + portIndex = mgInfo->portIndex[portNo]; + + if (mgcPhyPort[portIndex].sapIndex == sapIndex) + { + mgc_remove_chnl(mgcPhyPort[portIndex].chnlStartIndex, mgcPhyPort[portIndex].chnlNum); + memset((BYTE *) &mgcPhyPort[portIndex], 0, sizeof(PHY_PORT_INFO)); + + mgInfo->portIndex[portNo] = 0xFFFF; + mgInfo->portNum--; + + sprintf(tmpStr, "mgc_delete_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d\n\r", sapIndex, mgNo, portNo); + mgc_asciout_proc(tmpStr); + + return 0; + } + else + { + mgc_log_err("mgc_delete_port: invalid sapIndex for the portNo!\n\r"); + return -1; + } + +} + +int mgc_modify_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType) +{ + WORD phyPort; + char tmpStr[128]; + + if ((sapIndex >= MGC_MAX_NUM_OF_SAP) || + (mgNo >= MGC_MAX_NUM_OF_MG) || + (!mgc_is_non_virtual_mg(mgcMgInfo[mgNo].mgAttr.mgType))||//add by Francis + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (portType > MGC_PHY_PORT_TYPE_ANALOG)) + { + mgc_log_err("mgc_modify_port: invalid sapIndex, mgNo, portNo, or portType!\n\r"); + return -1; + } + + phyPort = mgcMgInfo[mgNo].portIndex[portNo]; + + if (phyPort >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_modify_port: invalid phyPort!\n\r"); + return -1; + } + + mgcPhyPort[phyPort].portType = portType; + + sprintf(tmpStr, "mgc_modify_port: succeed, sapIndex = %d, mgNo = %d, portNo = %d, portType = %d\n\r", sapIndex, mgNo, portNo, portType); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_apply_aas_tone(CHNL *aasChnl, BYTE toneNo) +{ + int i; + int j; + WORD chnlIndex; + WORD connectIndex; + + for (i = 0; i < MGC_MAX_NUM_OF_AAS_MGC; i++) + { + if (mgc_select_ass_mgc_mgNo > 3) + { + mgc_select_ass_mgc_mgNo = 0; + } + + if ((mgc_aas_mgNo[mgc_select_ass_mgc_mgNo] >= MGC_MAX_NUM_OF_MG) + || (mgc_aas_mgNo[mgc_select_ass_mgc_mgNo] == 0) + || (mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].status != 1) + || (mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].mgAttr.ip != localIP)) + { + mgc_select_ass_mgc_mgNo++; + continue; + } + else + { + chnlIndex = mgcMgInfo[mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]].chnlStartIndex + toneNo; + + for (j = 0; j < MGC_MAX_NUM_OF_CHNL_CON; j++) + { + if (((connectIndex = mgcChnl[chnlIndex].connectIndex[j]) < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[connectIndex].assigned == 1)) + { + continue; + } + else + { + aasChnl->mgNo = mgc_aas_mgNo[mgc_select_ass_mgc_mgNo]; + aasChnl->portNo = 0xFF; + aasChnl->chlNo = toneNo; + aasChnl->connectNo = j; + + if (mgc_assign_connect_to_chnl(*aasChnl) < 0) + { + mgc_log_err("mgc_apply_aas_tone: assigned connect to chnl failed!\n\r"); + return -1; + } + + mgc_select_ass_mgc_mgNo++; + + return 0; + } + } + } + } + + return -1; +} + +int mgc_match_codec_list(MGC_CODEC_LIST *dest, MGC_CODEC_LIST *aParty, MGC_CODEC_LIST *bParty) +{ + BYTE i, j, num = 0; + + MGC_CODEC_LIST *base, *highPri; + + if (dest == NULL) + { + mgc_log_err("mgc_match_codec_list: dest == NULL!\n\r"); + return -1; + } + dest->num = 0; + dest->priority = 0; + + if (aParty->priority >= bParty->priority) + { + base = bParty; + highPri = aParty; + } + else + { + base = aParty; + highPri = bParty; + } + + if (base->num == 0) + { + if (highPri->num == 0) + { + mgc_log_err("mgc_match_codec_list: base->num == 0!\n\r"); + return -1; + } + else + { + memcpy((BYTE *) dest, (BYTE *) highPri, sizeof(MGC_CODEC_LIST)); + return 0; + } + } + + if (highPri->num == 0) + { + memcpy((BYTE *) dest, (BYTE *) base, sizeof(MGC_CODEC_LIST)); + return 0; + } + + for (i = 0; i < highPri->num; i++) + { + for (j = 0; j < base->num; j++) + { + if (highPri->codec[i] == base->codec[j]) + { + dest->codec[num++] = highPri->codec[i]; + break; + } + } + } + + if (num > 0) + { + dest->num = num; + dest->priority = highPri->priority; + return 0; + } + else + { + mgc_log_err("mgc_match_codec_list: can't match at all!\n\r"); + return -1; + } +} + +int mgc_crcx_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort, associPort; + char tmpStr[256]; + BYTE ptime; + int connectIndex;//new replace + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_crcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_log_err("mgc_crcx_chnl: MGC_MG_TYPE_INTERNAL!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_crcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_crcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_crcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if ((mgcChnl[chnlIndex].connectIndex[chnl.connectNo] < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned == 1) + && (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status == MGC_CONNECT_STATUS_CREATED))//new replace + { + mgc_log_err("mgc_crcx_chnl: connection already created on this channel!\n\r"); + return 0; + } + + if ((mgcChnl[chnlIndex].connectIndex[chnl.connectNo] >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned != 1)) + { + if ((connectIndex = mgc_assign_connect_to_chnl(chnl)) < 0) + { + mgc_log_err("mgc_crcx_chnl: connect resource not available!\n\r"); + return -1; + }//new replace + } + else + { + connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + } + + associPort = mgcConnectInfo[connectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: chnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_crcx_chnl: chnl operation overwritten!\n\r"); + } + + if (mgcConnectInfo[connectIndex].codecList.num == 0) +// if (mgcChnl[chnlIndex].codecList.num == 0) + { + if (mgc_match_codec_list(&mgcConnectInfo[connectIndex].codecList, &mgcConnectInfo[connectIndex].codecList, &mgcMgInfo[chnl.mgNo].mgAttr.codecList) < 0) + //if (mgc_match_codec_list(&codecList, &mgcChnl[chnlIndex].codecList, &mgcMgInfo[chnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_crcx_chnl: mgcChnl[chnlIndex].codecList error!\n\n"); + return -1; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_crcx_chnl: port resource not available!\n\r"); + return -1; + } + + ptime = mgcMgInfo[chnl.mgNo].mgAttr.ptime; + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[0].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[0].media.vocoderType = mgcConnectInfo[connectIndex].codecList; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_CRCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_CRCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + + sprintf(tmpStr, "mgc_crcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, chnlConnectNo = %d, connectIndex = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, connectIndex);//new replace + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *mediaPara, BYTE sdFlag) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + WORD connectIndex;//new replace + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_mdcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_mdcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_mdcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON);//new replace + { + mgc_log_err("mgc_mdcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_EC) == MGC_MEDIA_PARA_FLAG_EC) + //mgcChnl[chnlIndex].mediaAttr.ecDisable = mediaPara->ecDisable; + mgcConnectInfo[connectIndex].mediaAttr.ecDisable = mediaPara->ecDisable; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_SS) == MGC_MEDIA_PARA_FLAG_SS) + //mgcChnl[chnlIndex].mediaAttr.ssDisable = mediaPara->ssDisable; + mgcConnectInfo[connectIndex].mediaAttr.ssDisable = mediaPara->ssDisable; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_CM) == MGC_MEDIA_PARA_FLAG_CM) + //mgcChnl[chnlIndex].mediaAttr.conMode = mediaPara->conMode; + mgcConnectInfo[connectIndex].mediaAttr.conMode = mediaPara->conMode; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_PT) == MGC_MEDIA_PARA_FLAG_PT) + //mgcChnl[chnlIndex].mediaAttr.ptime = mediaPara->ptime; + mgcConnectInfo[connectIndex].mediaAttr.ptime = mediaPara->ptime; + + if ((mediaPara->flag & MGC_MEDIA_PARA_FLAG_VT) == MGC_MEDIA_PARA_FLAG_VT) + { + //mgc_match_codec_list(&mgcChnl[chnlIndex].codecList, &mediaPara->vocoderType, &mgcMgInfo[chnl.mgNo].mgAttr.codecList); + mgc_match_codec_list(&mgcConnectInfo[connectIndex].codecList, &mediaPara->vocoderType, &mgcMgInfo[chnl.mgNo].mgAttr.codecList); + } + + if (sdFlag == 0) + { +// sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, sdFlag); + sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, sdFlag);//new replace + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + return 0; + } + + if ((mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].assigned != 1) + || (mgcConnectInfo[mgcChnl[chnlIndex].connectIndex[chnl.connectNo]].status != MGC_CONNECT_STATUS_CREATED))//new replace +// if (mgcChnl[chnlIndex].status != MGC_CHNL_STATUS_CREATED) + { + mgc_log_err("mgc_mdcx_chnl: connection not created on this channel!\n\r"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mdcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_MDCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_MDCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + +// sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, sdFlag); + sprintf(tmpStr, "mgc_mdcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, sdFlag = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo, sdFlag); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl) +{ + int port; + BYTE ptime; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst; + char tmpStr[256]; + int orgConnectIndex; + int destConnectIndex; + MGC_CODEC_LIST codecList; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (destChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_recvonly_chnl: invalid mgNo!\n\r"); + return -1; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (destChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_recvonly_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (destChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_recvonly_chnl: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if ((chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_recvonly_chnl: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1) + || (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED))//new replace + { + mgc_log_err("mgc_recvonly_chnl: orgChnl connectionIndex invaild or connection not create!\n\r"); + return -1; + + } + + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode == MGCP_CON_MODE_RECVONLY) + { + sprintf(tmpStr, "mgc_recvonly_chnl: connection already in recvonly mode, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + || (mgcMgInfo[destChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_recvonly_chnl: invalid chnlIndex or phyPort of destChnl!\n\r"); + return -1; + } + + + if (((destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[destChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[destConnectIndex].assigned != 1) + || (mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_CREATED))//new replace + { + mgc_log_err("mgc_recvonly_chnl: destChnl connectionIndex invaild or connection not create!\n\r"); + return -1; + } + + if (mgcConnectInfo[orgConnectIndex].codecList.num == 0) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_crcx_chnl: mgcChnl[chnlIndex].codecList error!\n\n"); + return -1; + } + } + + codecList = mgcConnectInfo[orgConnectIndex].codecList; + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_mdcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[0].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[0].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[0].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[0].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_MDCX; + mgcPort[port].mgcfOperSteps[0].media.vocoderType = codecList; + mgcPort[port].mgcfOperId = MGC_OPER_ID_MDCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + sprintf(tmpStr, "mgc_recvonly_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo, destConnectIndex); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_dlcx_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort, associPort; + char tmpStr[256]; + WORD orgChl, dstChl; + WORD connectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_dlcx_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[chnl.mgNo].mgAttr.e1cardNo * 8 + chnl.portNo) * 32 + chnl.chlNo; + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + _8ecp_connect_chnl(orgChl, dstChl, 0); //ecDisable:0/1=enable/disable echo canceller + + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + + sprintf(tmpStr, "mgc_dlcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; + } + + if ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) + && (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_dlcx_chnl: invalid portNo!\n\r"); + return -1; + } + + if (chnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_dlcx_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (chnl.chlNo >= MGC_MAX_NUM_OF_CHNL) + { + if (chnl.chlNo != MGCP_EP_NAME_CHNL_WILDCAST) + { + mgc_log_err("mgc_dlcx_chnl: invalid chnlIndex!\n\r"); + return -1; + } + } + + if (chnl.chlNo < MGC_MAX_NUM_OF_CHNL) + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_dlcx_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON)//new replace + { + mgc_log_err("mgc_dlcx_chnl: invalid connectIndex!\n\r"); + return -1; + } + + + associPort = mgcConnectInfo[connectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: chnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_dlcx_chnl: chnl operation overwritten!\n\r"); + } + + if ((mgcConnectInfo[connectIndex].assigned != 1) + || (mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_CREATED)) //new replace + { + mgc_log_err("mgc_dlcx_chnl: connection not created on this channel!\n\r"); + return 0; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_dlcx_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_DLCX; + mgcPort[port].mgcfOperId = MGC_OPER_ID_DLCX; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = chnl.connectNo; + + sprintf(tmpStr, "mgc_dlcx_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, EVENT *event, SIGNAL *signal) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_rqnt_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_rqnt_chnl: invalid portNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) || + ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_rqnt_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if ((mgcChnl[chnlIndex].port < MGC_MAX_NUM_OF_PORT) + && (mgcPort[mgcChnl[chnlIndex].port].assigned != 0)) + { + mgc_log_err("mgc_rqnt_chnl: channel already engaged!\n\r"); + return 0; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_rqnt_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperId = MGC_OPER_ID_RQNT; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = 0xFFFF; + + if (event != NULL) + //mgcChnl[chnlIndex].mediaAttr.pkgEvent = (event->pkg << 8) | event->event; + mgcChnl[chnlIndex].comMediaAttr.pkgEvent = (event->pkg << 8) | event->event; + + if (signal != NULL) + //mgcChnl[chnlIndex].mediaAttr.pkgSignal = (signal->pkg << 8) | signal->signal; + mgcChnl[chnlIndex].comMediaAttr.pkgSignal = (signal->pkg << 8) | signal->signal; + +// sprintf(tmpStr, "mgc_rqnt_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + sprintf(tmpStr, "mgc_rqnt_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_auep_chnl(WORD usrPort, CHNL chnl) +{ + int port; + WORD chnlIndex, phyPort; + char tmpStr[256]; + +// return 0; + + if (chnl.mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_auep_chnl: invalid mgNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return 1; + + if (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_auep_chnl: invalid portNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + } + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[chnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPort >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_auep_chnl: invalid chnlIndex or phyPort!\n\r"); + return -1; + } + + if (mgcChnl[chnlIndex].auepSt != MGC_CHNL_AUEP_IDLE) + { + mgc_log_err("mgc_auep_chnl: auep already in progress!\n\r"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_auep_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + mgcPort[port].mgcfOperStepsNum = 1; + mgcPort[port].mgcfOperSteps[0].localChnl = chnl; + mgcPort[port].mgcfOperSteps[0].cmd = MGCP_CMD_AUEP; + mgcPort[port].mgcfOperId = MGC_OPER_ID_AUEP; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperSteps[0].chnlConnectIndex = 0xFFFF; + + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IN_PROGRESS; + +// sprintf(tmpStr, "mgc_auep_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo); + sprintf(tmpStr, "mgc_auep_chnl: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d\n\r", usrPort, chnl.mgNo, chnl.portNo, chnl.chlNo, chnl.connectNo); + mgc_log_procedure(chnl.mgNo, phyPort, chnlIndex, tmpStr); + + return 0; +} + +int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + MGC_CODEC_LIST codecList; + int orgConnectIndex; + int destConnectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (destChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_chnl: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[destChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[destChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + if ((flag & MGC_CONNECT_SILENT_TONE) == MGC_CONNECT_SILENT_TONE) + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + else + dstChl = (mgcMgInfo[destChnl.mgNo].mgAttr.e1cardNo * 8 + destChnl.portNo) * 32 + destChnl.chlNo; + + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + _8ecp_connect_chnl(orgChl, dstChl, mgcChnl[chnlIndexOrg].comMediaAttr.ecDisable); //ecDisable:0/1=enable/disable echo canceller + + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + + sprintf(tmpStr, "mgc_connect_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, destChnl.mgNo, destChnl.portNo, destChnl.chlNo); + + if (mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr) < 0) + mgc_log_procedure(destChnl.mgNo, phyPortDst, chnlIndexDst, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (destChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_chnl: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (destChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_chnl: invalid connectNo!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + phyPortOrg = 0; + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + } + + if ((chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL) + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_chnl: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_chnl: assigned connect on orgChnl failed!\n\r"); + return -1; + } + + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: orgChnl operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: orgChnl chnl operation overwritten!\n\r"); + } + + if (mgcMgInfo[destChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + phyPortDst = 0; + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + if (MGC_MG_TYPE_ANN == mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + chnlIndexDst = mgcMgInfo[destChnl.mgNo].chnlStartIndex + destChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[destChnl.mgNo].portIndex[destChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + destChnl.chlNo; + } + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_chnl: invalid chnlIndex or phyPort of destChnl!\n\r"); + return -1; + } + + + if (((destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[destChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[destConnectIndex].assigned != 1))//new replace + { + if ((destConnectIndex = mgc_assign_connect_to_chnl(destChnl)) < 0) + { + mgc_log_err("mgc_connect_chnl: assigned connect on destChnl failed!\n\r"); + return -1; + } + } + + if (mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) + { + associPort = mgcConnectInfo[destConnectIndex].port; + + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: destChnl operation overwritten!\n\r"); + } + + associPort = mgcChnl[chnlIndexDst].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_chnl: destChnl chnl operation overwritten!\n\r"); + } + + } + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if ((mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[destChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[destChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: mgcConnectInfo[destConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_chnl: can't match codec!\n\n"); + return -1; + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_chnl: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ptime >= mgcMgInfo[destChnl.mgNo].mgAttr.ptime) + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + else + ptime = mgcMgInfo[destChnl.mgNo].mgAttr.ptime; + + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + + if (mgcConnectInfo[destConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = destChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + + if ((orgChnl.mgNo == destChnl.mgNo) + && ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) != MGCP_PARA_FLAG_TFO)) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + else if ((orgChnl.mgNo != destChnl.mgNo) + && ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO)) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[destChnl.mgNo].mgAttr.mgType) + { + mgcPort[port].mgcfOperSteps[step].localChnl = destChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + + if ((flag & MGC_CONNECT_SILENT_TONE) == MGC_CONNECT_SILENT_TONE) + { + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + } + else + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDRECV; + + if (orgChnl.mgNo == destChnl.mgNo) + { + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + } + + mgcPort[port].mgcfOperSteps[step].media.vocoderType = codecList; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = destChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + if (step == 0) + mgc_port_init(port); + else + { + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_CHNL; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + mgcPort[port].mgcfOperStepsNum = step; + } + + sprintf(tmpStr, "mgc_connect_chnl: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, destChnl.mgNo, destChnl.portNo, destChnl.chlNo, destChnl.connectNo, destConnectIndex, step); + if (mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr) < 0) + mgc_log_procedure(destChnl.mgNo, phyPortDst, chnlIndexDst, tmpStr); + + return 0; +} + +int mgc_connect_dtmf(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE dtmfNo) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, phyPortOrg, associPort; + char tmpStr[256]; + BYTE digit = 0; + int orgConnectIndex; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + +// return 0; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_dtmf: invalid mgNo!\n\r"); + return -1; + } + + if (0 == dtmfNo) + { + digit = 10; + } + else + { + digit = dtmfNo; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo; + _8ecp_connect_dtmf(orgChl, dstChl, digit); + + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + + sprintf(tmpStr, "mgc_connect_dtmf: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, dtmfNo = %d\n\r", usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, dtmfNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if (orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_connect_dtmf: invalid portNo!\n\r"); + return -1; + } + + if (orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_connect_dtmf: invalid connectNo!\n\r"); + return -1; + } + + if (MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_dtmf: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_dtmf: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: orgChnl connection operation overwritten!\n\r"); + } + + aasChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_dtmf: orgChnl chnl operation overwritten!\n\r"); + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_dtmf: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = (MGCP_PKG_D << 8) | digit; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = 0xFFFF; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperStepsNum = step; + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_DTMF; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + sprintf(tmpStr, "mgc_connect_dtmf: succeed, usrPort = %d, mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, dtmfNo = %d\n\r", usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, dtmfNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration, WORD times) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + CHNL aasChnl = {0xFFFF, 0, 0xFFFF, 0xFFFF}; + int orgConnectIndex; + int destConnectIndex; + WORD aasConnectIndex; + WORD chnlIndexAAS; + MGC_CODEC_LIST codecList; + WORD orgAASChnlIndex; + WORD orgAASConnectIndex; + CHNL orgAASChnl; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_AAS: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (toneNo >= MGC_MAX_TONE_NO) + { + mgc_log_err("mgc_connect_AAS: invalid toneNo!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + + if ((0 == dstChnl.mgNo) && (0 == dstChnl.portNo) && (0 == dstChnl.chlNo)) + { + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + } + else if ((1 == mgcMgInfo[dstChnl.mgNo].created) + && (1 == mgcPhyPort[mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]].created)) + { + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo;//need revise + } + else + { + mgc_log_err("mgc_connect_AAS: invalid 8ecp mgNo or portNo!\n\r"); + return -1; + } + + _8ecp_connect_tone(orgChl, dstChl, toneNo, duration); + + sprintf(tmpStr, "mgc_connect_AAS: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (dstChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_AAS: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (dstChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_AAS: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_AAS: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_AAS: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: orgChnl connection operation overwritten!\n\r"); + } + + orgAASChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((orgAASChnl.mgNo < MGC_MAX_NUM_OF_MG) && (orgAASChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (orgAASChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + orgAASChnlIndex = mgcMgInfo[orgAASChnl.mgNo].chnlStartIndex + orgAASChnl.chlNo; + + if ((orgAASConnectIndex = mgcChnl[orgAASChnlIndex].connectIndex[orgAASChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[orgAASConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_AAS: orgChnl chnl operation overwritten!\n\r"); + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType)) + { + chnlIndexDst = mgcMgInfo[dstChnl.mgNo].chnlStartIndex + dstChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + dstChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_AAS: invalid destChnl chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[dstChnl.connectNo]; + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) && (mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[dstChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: mgcConnectInfo[dstConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: orgConnect and dstConnect code negotiation fail!\n\n"); + return -1; + } + } + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_AAS: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if (toneNo == MGC_HOLD_MUSIC) + { + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + else + { + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[destConnectIndex].codecList;//orgConnectIndex + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + } + + if (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) + { + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[destConnectIndex].status == MGC_CONNECT_STATUS_CREATED)) + { + if (mgcConnectInfo[destConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[dstChnl.mgNo].mgAttr.ptime; + + if ((mgcConnectInfo[destConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcPort[port].mgcfOperSteps[step].flag |= MGCP_PARA_FLAG_TFO; + } + + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = dstChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList;//destConnectIndex + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + } + + toneNo = times * 10 + (toneNo - 7); + + if (mgc_apply_aas_tone(&aasChnl, toneNo) < 0) + { + mgc_log_err("mgc_connect_AAS: apply aas tone fail!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((aasChnl.mgNo >= MGC_MAX_NUM_OF_MG) || (aasChnl.portNo != 0xFF) + || (aasChnl.chlNo != toneNo) || (aasChnl.connectNo > MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_connect_AAS: apply aas mg fail!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + + if (toneNo == 0) + { + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + } + else + { + mgcPort[port].mgcfOperSteps[step].media.conMode = mgcConnectInfo[orgConnectIndex].mediaAttr.conMode;; + } + + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[destConnectIndex].codecList;//orgConnectIndex + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + chnlIndexAAS = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + aasConnectIndex = mgcChnl[chnlIndexAAS].connectIndex[aasChnl.connectNo]; + + ptime = mgcConnectInfo[orgConnectIndex].mediaAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_CRCX; +// mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcMgInfo[orgChnl.mgNo].mgAttr.codecList; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + + mgcConnectInfo[orgConnectIndex].aasChnl = aasChnl; + + memcpy((BYTE *) &mgcConnectInfo[aasConnectIndex].mediaAttr.sdp, (BYTE *) &mgcConnectInfo[orgConnectIndex].mediaAttr.sdp, sizeof(PUB_SDP_MSG)); + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_DLCX; + } + } + + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_AAS; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperStepsNum = step; + + sprintf(tmpStr, "mgc_connect_AAS: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, dstChnl.mgNo, dstChnl.portNo, dstChnl.chlNo, dstChnl.connectNo, destConnectIndex, step); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration) +{ + int port; + BYTE step = 0, ptime; + WORD orgChl, dstChl; + WORD chnlIndexOrg, chnlIndexDst, phyPortOrg, phyPortDst, associPort; + char tmpStr[256]; + CHNL aasChnl = {0xFFFF, 0, 0xFFFF, 0xFFFF}; + int orgConnectIndex; + int destConnectIndex; + WORD aasConnectIndex; + WORD chnlIndexAAS; + MGC_CODEC_LIST codecList; + WORD orgAASChnlIndex; + WORD orgAASConnectIndex; + CHNL orgAASChnl; + + if ((orgChnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (dstChnl.mgNo >= MGC_MAX_NUM_OF_MG)) + { + mgc_log_err("mgc_connect_tone: invalid mgNo!\n\r"); + return -1; + } + + if ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType != mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType) + && ((mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) || (mgcMgInfo[dstChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP))) + { + mgc_log_err("mgc_connect_chnl: mg ctrlType error!\n\r"); + return -1; + } + + if (toneNo >= MGC_MAX_TONE_NO) + { + mgc_log_err("mgc_connect_tone: invalid toneNo!\n\r"); + return -1; + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + orgChl = (mgcMgInfo[orgChnl.mgNo].mgAttr.e1cardNo * 8 + orgChnl.portNo) * 32 + orgChnl.chlNo; + + if ((0 == dstChnl.mgNo) && (0 == dstChnl.portNo) && (0 == dstChnl.chlNo)) + { + dstChl = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + } + else if ((1 == mgcMgInfo[dstChnl.mgNo].created) + && (1 == mgcPhyPort[mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]].created)) + { + dstChl = (mgcMgInfo[dstChnl.mgNo].mgAttr.e1cardNo * 8 + dstChnl.portNo) * 32 + dstChnl.chlNo;//need revise + } + else + { + mgc_log_err("mgc_connect_tone: invalid 8ecp mgNo or portNo!\n\r"); + return -1; + } + + _8ecp_connect_tone(orgChl, dstChl, toneNo, duration); + + sprintf(tmpStr, "mgc_connect_tone: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; + } + + if ((orgChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) || + (dstChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_connect_tone: invalid portNo!\n\r"); + return -1; + } + + if ((orgChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) || + (dstChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + { + mgc_log_err("mgc_connect_tone: invalid connectNo!\n\r"); + return -1; + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[orgChnl.mgNo].mgAttr.mgType)) + { + chnlIndexOrg = mgcMgInfo[orgChnl.mgNo].chnlStartIndex + orgChnl.chlNo; + } + else + { + phyPortOrg = mgcMgInfo[orgChnl.mgNo].portIndex[orgChnl.portNo]; + chnlIndexOrg = mgcPhyPort[phyPortOrg].chnlStartIndex + orgChnl.chlNo; + } + + if (chnlIndexOrg >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortOrg >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_tone: invalid chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + if (((orgConnectIndex = mgcChnl[chnlIndexOrg].connectIndex[orgChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + || (mgcConnectInfo[orgConnectIndex].assigned != 1))//new replace + { + if ((orgConnectIndex = mgc_assign_connect_to_chnl(orgChnl)) < 0) + { + mgc_log_err("mgc_connect_tone: assigned connect on orgChnl failed!\n\r"); + return -1; + } + } + + associPort = mgcConnectInfo[orgConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: orgChnl connection operation overwritten!\n\r"); + } + + orgAASChnl = mgcConnectInfo[orgConnectIndex].aasChnl; + + if ((orgAASChnl.mgNo < MGC_MAX_NUM_OF_MG) && (orgAASChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (orgAASChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + orgAASChnlIndex = mgcMgInfo[orgAASChnl.mgNo].chnlStartIndex + orgAASChnl.chlNo; + + if ((orgAASConnectIndex = mgcChnl[orgAASChnlIndex].connectIndex[orgAASChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[orgAASConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: connection aasChnl operation overwritten!\n\r"); + } + } + } + + associPort = mgcChnl[chnlIndexOrg].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_connect_tone: orgChnl chnl operation overwritten!\n\r"); + } + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[dstChnl.mgNo].mgAttr.mgType)) + { + chnlIndexDst = mgcMgInfo[dstChnl.mgNo].chnlStartIndex + dstChnl.chlNo; + } + else + { + phyPortDst = mgcMgInfo[dstChnl.mgNo].portIndex[dstChnl.portNo]; + chnlIndexDst = mgcPhyPort[phyPortDst].chnlStartIndex + dstChnl.chlNo; + } + + if (chnlIndexDst >= MGC_MAX_NUM_OF_CHNL + || ((mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (phyPortDst >= MGC_MAX_NUM_OF_PHY_PORT))) + { + mgc_log_err("mgc_connect_tone: invalid destChnl chnlIndex or phyPort of orgChnl!\n\r"); + return -1; + } + + destConnectIndex = mgcChnl[chnlIndexDst].connectIndex[dstChnl.connectNo]; + + if ((mgcConnectInfo[orgConnectIndex].codecList.num == 0) + && (mgcMgInfo[orgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcMgInfo[orgChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_tone: mgcConnectInfo[orgConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (destConnectIndex < MGC_MAX_NUM_OF_CON) + { + if ((mgcConnectInfo[destConnectIndex].codecList.num == 0) + && (mgcMgInfo[dstChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + { + if (mgc_match_codec_list(&mgcConnectInfo[destConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList, &mgcMgInfo[dstChnl.mgNo].mgAttr.codecList) < 0) + { + mgc_log_err("mgc_connect_tone: mgcConnectInfo[dstConnectIndex].codecList error!\n\n"); + return -1; + } + } + + if (mgc_match_codec_list(&codecList, &mgcConnectInfo[orgConnectIndex].codecList, &mgcConnectInfo[destConnectIndex].codecList) < 0) + { + mgc_log_err("mgc_connect_AAS: orgConnect and dstConnect code negotiation fail!\n\n"); + return -1; + } + } + else + codecList = mgcConnectInfo[orgConnectIndex].codecList; + + if ((port = mgc_get_port()) < 0) + { + mgc_log_err("mgc_connect_tone: port resource not available!\n\r"); + return -1; + } + + mgcPort[port].usrPort = usrPort; + + if (mgcConnectInfo[orgConnectIndex].status != MGC_CONNECT_STATUS_CREATED) + { + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[orgChnl.mgNo].mgAttr.mgType) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = orgChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_CRCX; + } + } + else + { + if (mgcConnectInfo[orgConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if ((destConnectIndex < MGC_MAX_NUM_OF_CON) + && (mgcConnectInfo[destConnectIndex].status == MGC_CONNECT_STATUS_CREATED)) + { + if (mgcConnectInfo[destConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + ptime = mgcMgInfo[dstChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = dstChnl.connectNo; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + } + + if (mgcMgInfo[orgChnl.mgNo].mgAttr.toneCap == 1) + { + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_RQNT; + mgcPort[port].mgcfOperSteps[step].pkgSignal = MGC_TONE_NO_TO_PKG_SIG[toneNo]; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = 0xFFFF; + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].pkgSignal = 0; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = 0xFFFF; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_RQNT; + } + else + { + toneNo = toneNo - 7; + + if (mgc_apply_aas_tone(&aasChnl, toneNo) < 0) + { + mgc_log_err("mgc_connect_tone: mg no toneCap and no AAS MG!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((aasChnl.mgNo >= MGC_MAX_NUM_OF_MG) || (aasChnl.portNo != 0xFF) + || (aasChnl.chlNo != toneNo) || (aasChnl.connectNo > MGC_MAX_NUM_OF_CON)) + { + mgc_log_err("mgc_connect_tone: mg no toneCap and apply aas mg fault!\n\r"); + mgc_port_init(port); + return -1; + } + else + { + if ((mgcConnectInfo[orgConnectIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + ptime = mgcMgInfo[orgChnl.mgNo].mgAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_RECVONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = orgChnl; + mgcPort[port].mgcfOperSteps[step].remChnl = dstChnl; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_MDCX; + } + + chnlIndexAAS = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + aasConnectIndex = mgcChnl[chnlIndexAAS].connectIndex[aasChnl.connectNo]; + + ptime = mgcConnectInfo[orgConnectIndex].mediaAttr.ptime; + mgcPort[port].mgcfOperSteps[step].media.ptime = ptime; + mgcPort[port].mgcfOperSteps[step].media.conMode = MGCP_CON_MODE_SENDONLY; + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].cmd = MGCP_CMD_CRCX; + mgcPort[port].mgcfOperSteps[step].media.vocoderType = mgcConnectInfo[orgConnectIndex].codecList; + + mgcConnectInfo[orgConnectIndex].aasChnl = aasChnl; + + memcpy((BYTE *) &mgcConnectInfo[aasConnectIndex].mediaAttr.sdp, (BYTE *) &mgcConnectInfo[orgConnectIndex].mediaAttr.sdp, sizeof(PUB_SDP_MSG)); + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + if (duration == 0) + { + mgcPort[port].mgcfOperSteps[step++].delay = MGC_MGCF_TIMER_1H; + } + else + { + mgcPort[port].mgcfOperSteps[step++].delay = duration * MGC_MGCF_TIMER_1S; + } + + + mgcPort[port].mgcfOperSteps[step].localChnl = aasChnl; + mgcPort[port].mgcfOperSteps[step].chnlConnectIndex = aasChnl.connectNo; + mgcPort[port].mgcfOperSteps[step++].cmd = MGCP_CMD_DLCX; + } + } + } + + mgcPort[port].mgcfOperId = MGC_OPER_ID_CONNECT_TONE; + mgcPort[port].mgcfState = MGC_MGCF_STATE_REQUEST; + + mgcPort[port].mgcfOperStepsNum = step; + + sprintf(tmpStr, "mgc_connect_tone: succeed, usrPort = %d, Org: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, Dest: mgNo = %d, portNo = %d, chnlNo = %d, connectNo = %d, connectIndex = %d, step = %d\n\r", + usrPort, orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo, orgChnl.connectNo, orgConnectIndex, dstChnl.mgNo, dstChnl.portNo, dstChnl.chlNo, dstChnl.connectNo, destConnectIndex, step); + mgc_log_procedure(orgChnl.mgNo, phyPortOrg, chnlIndexOrg, tmpStr); + + return 0; +} + +int mgc_query_mg_status(WORD mgNo) +{ + if (mgNo >= MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_query_mg_status: invalid mgNo!\n\r"); + return -1; + } + + return mgcMgInfo[mgNo].status; +} + +int mgc_query_port_status(WORD mgNo, BYTE portNo) +{ + if ((mgNo >= MGC_MAX_NUM_OF_MG) || + (portNo >= MGC_MAX_PHY_PORT_PER_MG) || (0 == mgcPhyPort[mgcMgInfo[mgNo].portIndex[portNo]].created)) + { + mgc_log_err("mgc_query_port_status: invalid mgNo or portNo!\n\r"); + return 0; + } + + return mgcPhyPort[mgcMgInfo[mgNo].portIndex[portNo]].phyStatus; +} + +int mgc_query_channel_status(CHNL chnl) +{ + if ((chnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_query_channel_status: invalid mgNo or portNo!\n\r"); + return -1; + } + + return mgcChnl[mgcPhyPort[mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]].chnlStartIndex + chnl.chlNo].status; +} + +int mgc_create_virtual_chnl(WORD port, CHNL *chnl) +{ + int chnlIndex; + char tmpStr[128]; + + chnl->mgNo = MGC_INTERNAL_VIRTUAL_MG; + chnl->portNo = 0; + if ((chnlIndex = mgc_assign_chnl(0xFF, MGC_INTERNAL_VIRTUAL_MG, 0xFF, MGC_MG_TYPE_INTERNAL)) < 0) + { + mgc_log_err("mgc_create_virtual_chnl: can't allocate virtual channel!\n\r"); + return -1; + } + + chnl->chlNo = chnlIndex - mgcMgInfo[chnl->mgNo].chnlStartIndex; + + if (mgc_assign_connect_to_chnl(*chnl) < 0) + { + mgc_log_err("mgc_create_virtual_chnl: can't allocate connect!\n\r"); + return -1; + } + + sprintf(tmpStr, "mgc_create_virtual_chnl: succeed, usrPort = %d, assigned chnlIndex = %d\n\r", port, chnlIndex); + mgc_log_procedure(chnl->mgNo, 0xFFFF, chnlIndex, tmpStr); +// mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_release_virtual_chnl(WORD port, CHNL chnl) +{ + WORD chnlIndex; + char tmpStr[128]; + int connectIndex; + WORD associPort; + WORD aasChnlIndex; + WORD aasConnectIndex; + CHNL aasChnl; + + if ((chnl.mgNo != MGC_INTERNAL_VIRTUAL_MG) || + (chnl.portNo != 0)) + { + mgc_log_err("mgc_release_virtual_chnl: invalid mgNo or portNo!\n\r"); + return -1; + } + + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + + aasChnl = mgcConnectInfo[connectIndex].aasChnl; + + if ((aasChnl.mgNo < MGC_MAX_NUM_OF_MG) && (aasChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + && (aasChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + aasChnlIndex = mgcMgInfo[aasChnl.mgNo].chnlStartIndex + aasChnl.chlNo; + + if ((aasConnectIndex = mgcChnl[aasChnlIndex].connectIndex[aasChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + { + associPort = mgcConnectInfo[aasConnectIndex].port; + if ((associPort < MGC_MAX_NUM_OF_PORT) + && (mgcPort[associPort].assigned != 0)) + { + mgcPort[associPort].mngCmd = MGC_MNG_CMD_OVERWRITE; + mgc_log_err("mgc_release_virtual_chnl: connection aasChnl operation overwritten!\n\r"); + } + } + } + } + else + { + mgc_log_err("mgc_release_virtual_chnl: invalid connectIndex!\n\r"); + } + + mgc_remove_chnl(chnlIndex, MGC_CHNL_NUM_INTERNAL_PER_PORT); + + sprintf(tmpStr, "mgc_release_virtual_chnl: succeed, usrPort = %d, chnlIndex = %d\n\r", port, chnlIndex); + mgc_log_procedure(chnl.mgNo, 0xFFFF, chnlIndex, tmpStr); +// mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_query_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG **mediaInfo) +{ + WORD phyPort, chnlIndex; + WORD connectIndex; + + if ((chnl.mgNo >= MGC_MAX_NUM_OF_MG) || + (chnl.portNo >= MGC_MAX_PHY_PORT_PER_MG)) + { + mgc_log_err("mgc_query_chnl_media: invalid mgNo or portNo!\n\r"); + return -1; + } + + if (mgcMgInfo[chnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + else + { + phyPort = mgcMgInfo[chnl.mgNo].portIndex[chnl.portNo]; + chnlIndex = mgcPhyPort[phyPort].chnlStartIndex + chnl.chlNo; + } + + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + return -1; + } + + if (mgcConnectInfo[connectIndex].status != MGC_CONNECT_STATUS_CREATED) +// if (mgcChnl[chnlIndex].status != MGC_CHNL_STATUS_CREATED) + return -1; + + *mediaInfo = &mgcConnectInfo[connectIndex].mediaAttr.sdp; +// *mediaInfo = &mgcChnl[chnlIndex].mediaAttr.sdp; + + return 0; +} + +int mgc_payload_to_codec(WORD payload) +{ + if (payload == 3) + return MGC_VCTYPE_GSM; + else if (payload == 84) + return MGC_VCTYPE_GSM_EFR; + else if (payload == 64) + return MGC_VCTYPE_AMR; + else if (payload == 118) + return MGC_VCTYPE_G729B; + else if (payload == 0) + return MGC_VCTYPE_PCMU; + + return MGC_VCTYPE_PCMA; +} + +int mgc_update_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG *mediaInfo) +{ + WORD chnlIndex; + BYTE i; + WORD connectIndex; + BYTE ptime; + + if ((chnl.mgNo != MGC_INTERNAL_VIRTUAL_MG) || + (chnl.portNo != 0)) + { + mgc_log_err("mgc_update_chnl_media: invalid mgNo or portNo!\n\r"); + return -1; + } + + chnlIndex = mgcMgInfo[chnl.mgNo].chnlStartIndex + chnl.chlNo; + + connectIndex = mgcChnl[chnlIndex].connectIndex[chnl.connectNo]; + + if (connectIndex > MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_update_chnl_media: invalid chnl connectNo!\n\r"); + return -1; + } + + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, mediaInfo, sizeof(PUB_SDP_MSG)); +// memcpy((BYTE *) &mgcChnl[chnlIndex].mediaAttr.sdp, mediaInfo, sizeof(PUB_SDP_MSG)); + + mgcConnectInfo[connectIndex].codecList.num = mediaInfo->medias.medias[0].m.plNum; + for (i = 0; i < mgcConnectInfo[connectIndex].codecList.num; i++) + mgcConnectInfo[connectIndex].codecList.codec[i] = mgc_payload_to_codec(mediaInfo->medias.medias[0].m.payloads[i]); + mgcConnectInfo[connectIndex].codecList.priority = 256; + + ptime = atoi(mediaInfo->medias.medias[0].attrs.attrs[0].aValue); + + mgcConnectInfo[connectIndex].mediaAttr.ptime = ptime; + + if (MGC_MG_TYPE_INTERNAL == mgcMgInfo[chnl.mgNo].mgAttr.mgType) + { +// mgcChnl[chnl.chlNo].status = MGC_CHNL_STATUS_CREATED; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + +// mgcChnl[chnlIndex].codecList.num = mediaInfo->medias.medias[0].m.plNum; +// for (i = 0; i < mgcChnl[chnlIndex].codecList.num; i++) +// mgcChnl[chnlIndex].codecList.codec[i] = mgc_payload_to_codec(mediaInfo->medias.medias[0].m.payloads[i]); +// mgcChnl[chnlIndex].codecList.priority = 1; + + return 0; +} + +int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum) +{ + char tmpStr[128]; + + if ((maxMgNum > MGC_MAX_NUM_OF_MG) || + (maxChnlNum > MGC_MAX_NUM_OF_CHNL)) + { + mgc_log_err("mgc_license_ctrl: invalid maxMgNum or maxChnlNum!\n\r"); + return -1; + } + + mgcMaxMgNo = maxMgNum; + mgcMaxChlNo = maxChnlNum; + + sprintf(tmpStr, "mgc_license_ctrl: succeed, mgcMaxMgNo = %d, mgcMaxChlNo = %d\n\r", mgcMaxMgNo, mgcMaxChlNo); + mgc_asciout_proc(tmpStr); + + return 0; +} + +int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *mediaAttr) +{ + WORD portIndex; + WORD chnlIndex; + PORT_INFO *portInfo; + char tmpStr[128]; + int connectIndex; + + if ((port >= MGC_MAX_NUM_OF_PORT) || + ((cmd != MGCP_CMD_CRCX) && (mgcPort[port].usrPort != usrPort)) || + (mgcPort[port].llCmd != cmd)) + { + mgc_log_err("mgc_rsp: invalid port or cmd!\n\r"); + return -1; + } + + portInfo = &mgcPort[port]; + + if (MGC_MG_TYPE_ANN == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + + if ((cmd == MGCP_CMD_CRCX) && (retCode == 200)) + { + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_rsp: CRCX invalid connectIndex!\n\r"); + return -1; + } + + sprintf(mgcConnectInfo[connectIndex].mediaAttr.conId, "%X%04X%lX", portInfo->mgcfChnl.connectNo, usrPort, time(NULL)); + +// memcpy((BYTE *) &mgcChnl[chnlIndex].mediaAttr.sdp, (BYTE *) mediaAttr, sizeof(PUB_SDP_MSG)); + memcpy((BYTE *) &mgcConnectInfo[connectIndex].mediaAttr.sdp, (BYTE *) mediaAttr, sizeof(PUB_SDP_MSG)); + } + + mgcPort[port].usrCmd = retCode; + + sprintf(tmpStr, "mgc_rsp: succeed, usrPort = %d, port = %d, retCode = %d, cmd = %d\n\r", usrPort, port, retCode, cmd); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 0; +} diff --git a/omc/plat/mgc/src/mgc_debug.c b/omc/plat/mgc/src/mgc_debug.c new file mode 100644 index 0000000..d31e281 --- /dev/null +++ b/omc/plat/mgc/src/mgc_debug.c @@ -0,0 +1,478 @@ +#include "./include/mgc_pub.h" +#include "./include/mgc.h" +#include "./include/mgc_const.h" +#include "./include/mgc_struct.h" +#include "./include/mgc_ext.h" +#include "./include/mgc_debug.h" +#include "../../debug/src/include/debug.h" + +#define MGC_DEBUG_ID 18 +#define MGC_VER_DEBUG "R9V0_07" + +static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + +static BYTE log_help[] = { +"MGC 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 \n\r\ +4.[log mg-xxxx on/off] display mg logs \n\r\ +5.[log port-xxxx-xxx on/off] display port logs \n\r\ +6.[log chnl-xxxx-xxx-xxxx on/off] display chnl 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,MGC_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,MGC_DEBUG_ID + 2,2 + }; + +static DWORD debug_ascin_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,3 + }; + +static DWORD debug_ascout_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,4 + }; + +static DWORD debug_page_title[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,1 + }; + +static DWORD debug_page_line[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,2,1 + }; + +const static BYTE MGC_BASE_ID_LEN = 15; +const static BYTE MGC_PAGE_POINT = 14; +const static BYTE MGC_LINE_POINT = 15; + +static BYTE title1_p[] = +{ + " MGC Page 01 MG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +MG_Info\n\r" +}; + +static BYTE title2_p[] = +{ + " MGC Page 02 Phy Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Phy_Port\n\r" +}; + +static BYTE title3_p[] = +{ + " MGC Page 03 Channel Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Chnl_Info\n\r" +}; + +static BYTE title4_p[] = +{ + " MGC Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Port_Info\n\r" +}; + +BYTE mgc_disp_line(BYTE page, BYTE line) +{ + BYTE disp_length; + + disp_length = 16; + disp_ptr = (BYTE *) disp_page; + + switch (page) + { + case 1: // Page 1: MG Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgcMgInfo + disp_page[page] * sizeof(MG_INFO) + (line - 1) * 16; + break; + case 2: // Page 2: Phy Port Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgcPhyPort + disp_page[page] * sizeof(PHY_PORT_INFO) + (line - 1) * 16; + break; + case 3: // Page 3: Channel Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgcChnl + disp_page[page] * sizeof(CHNL_INFO) + (line - 1) * 16; + break; + case 4: // Page 4: Software Port Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgcPort + disp_page[page] * sizeof(PORT_INFO) + (line - 1) * 16; + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +void mgc_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + + debug_page_line[MGC_PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = mgc_disp_line(page, disp_line); + debug_page_line[MGC_LINE_POINT] = disp_line + 2; + debug_page_line[MGC_LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(MGC_BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +int mgc_debug_set(void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + + bzero(disp_page, 20); + + ptr = data; + + debug_set_response(MGC_BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(MGC_BASE_ID_LEN, debug_name_id, MGC_VER_DEBUG, 10); + debug_set_response(MGC_BASE_ID_LEN, debug_ascin_id, mgcAsciInBuf, 4096); + debug_set_response(MGC_BASE_ID_LEN, debug_ascout_id, mgcAsciOutBuf, 4096); + + for (page = 1; page < 5; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + case 2: //page 2 + ptr = title2_p; + break; + case 3: //page 3 + ptr = title3_p; + break; + case 4: //page 4 + ptr = title4_p; + break; + default: + break; + } + + debug_page_title[MGC_PAGE_POINT] = 5 + page; + debug_set_response(MGC_BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + mgc_disp_page(page); + } + + return 1; +} + +int mgc_asciout_proc(BYTE *out_str) +{ + int out_len; + + out_len = strlen(out_str); + + if (out_len + strlen(mgcAsciOutBuf) > MAX_ASCIIOUT_LEN - 2) + { + strcpy(mgcAsciOutBuf, out_str); + } + else + strcat(mgcAsciOutBuf, out_str); + + return 1; +} + +void mgc_log_all() +{ + WORD i; + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created != 0) + mgcMgInfo[i].monFlag = 1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + { + if (mgcPhyPort[i].created != 0) + mgcPhyPort[i].monFlag = 1; + } + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + { + if (mgcChnl[i].assigned != 0) + mgcChnl[i].monFlag = 1; + } +} + +void mgc_log_none() +{ + WORD i; + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + { + if (mgcMgInfo[i].created != 0) + mgcMgInfo[i].monFlag = 0; + } + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + { + if (mgcPhyPort[i].created != 0) + mgcPhyPort[i].monFlag = 0; + } + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + { + if (mgcChnl[i].assigned != 0) + mgcChnl[i].monFlag = 0; + } +} + +void mgc_mon(void) +{ + BYTE in_page, err_fg = 0; + BYTE *ascii_in_ptr = NULL; + BYTE *str_start = NULL; + WORD str_len; + WORD mgNo, portNo, chlNo, portIndex, chnlIndex, num; + + if ((str_len = strlen(mgcAsciInBuf)) > 0) + { + in_page = mgcAsciInBuf[0] - 1; + ascii_in_ptr = mgcAsciInBuf + 1; + + if (in_page > 4) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + mgcMonitorFg = mgcMonitorFg | MGC_MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + mgcMonitorFg = mgcMonitorFg & (~MGC_MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + mgcMonitorFg = MGC_MONITOR_ALL; + mgc_log_all(); + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + mgcMonitorFg = MGC_MONITOR_NONE; + mgc_log_none(); + } + else if (strcmp(ascii_in_ptr,"help") == 0) + { + mgc_asciout_proc(log_help); + } + else if (strstr(ascii_in_ptr, "log mg") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + else if (strstr(ascii_in_ptr, "on") != NULL) + mgcMgInfo[mgNo].monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + mgcMgInfo[mgNo].monFlag = 0; + else + err_fg = 1; + } + else + err_fg = 1; + } + else if (strstr(ascii_in_ptr, "log port") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + portNo = strtoul(str_start + 1, NULL, 10); + if (portNo >= MGC_MAX_PHY_PORT_PER_MG) + err_fg = 1; + portIndex = mgcMgInfo[mgNo].portIndex[portNo]; + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + err_fg = 2; + else + { + if (strstr(str_start + 1, "on") != NULL) + mgcPhyPort[portIndex].monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + mgcPhyPort[portIndex].monFlag = 0; + else + err_fg = 1; + } + } + } + else + err_fg = 1; + } + else if (strstr(ascii_in_ptr, "log chnl") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + portNo = strtoul(str_start + 1, NULL, 10); + if (portNo >= MGC_MAX_PHY_PORT_PER_MG) + err_fg = 1; + portIndex = mgcMgInfo[mgNo].portIndex[portNo]; + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + err_fg = 2; + else + { + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + chlNo = strtoul(str_start + 1, NULL, 10); + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chlNo; + if (strstr(str_start + 1, "on") != NULL) + mgcChnl[chnlIndex].monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + mgcChnl[chnlIndex].monFlag = 0; + 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; + mgc_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; + mgc_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; + mgc_disp_page(in_page); + } + else + err_fg = 1; + + if (err_fg == 0) + mgc_asciout_proc("Command OK!\n\r"); + else if (err_fg == 2) + mgc_asciout_proc("MG port not created!\n\r"); + else + mgc_asciout_proc("Command Error!\n\r"); + + strcpy(mgcAsciInBuf, "\0"); + } +} + +int mgc_hex_to_ascii(BYTE *from_hex, BYTE 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 mgc_log_err(char *err_msg) +{ + if ((mgcMonitorFg & MGC_MONITOR_ERROR) == MGC_MONITOR_ERROR) + { + mgc_asciout_proc("\33[31m"); + if (strlen(err_msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s\n\r", err_msg); + strcat(mgcAsciTempBuf, "\33[37m"); + mgc_asciout_proc(mgcAsciTempBuf); + } + + return 1; +} + +int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg) +{ + BYTE monFlag = 0; + + if ((mgNo < MGC_MAX_NUM_OF_MG) && (mgcMgInfo[mgNo].monFlag == 1)) + monFlag = 1; + else if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && (mgcPhyPort[portIndex].monFlag == 1)) + monFlag = 1; + else if ((chnlIndex < MGC_MAX_NUM_OF_CHNL) && (mgcChnl[chnlIndex].monFlag == 1)) + monFlag = 1; + + if (monFlag == 1) + { + if (strlen(msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s\n\r", msg); + mgc_asciout_proc(mgcAsciTempBuf); + return 0; + } + + return -1; +} diff --git a/omc/plat/mgc/src/mgc_fsm.c b/omc/plat/mgc/src/mgc_fsm.c new file mode 100644 index 0000000..96ef232 --- /dev/null +++ b/omc/plat/mgc/src/mgc_fsm.c @@ -0,0 +1,1456 @@ +#include "./include/mgc_pub.h" +#include "./include/mgc.h" +#include "./include/mgc_const.h" +#include "./include/mgc_ext.h" +#include "./include/mgc_struct.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_sess_ctl.h" + +extern void mgc_port_init(WORD port); +extern void mgc_connect_init(WORD connectIndex); +extern int mgc_is_non_virtual_mg(BYTE mgType); + +void mgc_rpl_para_amr_sdp() +{ + int i; + char tmp[64]; + char *dash; + char *slash; + + for (i = 0; i < mgcMgcpPara.sdp.medias.medias[0].attrs.num; i++) + { + if (mgcMgcpPara.sdp.medias.medias[0].attrs.attrs[i].aType != PUB_SDP_ATTR_TYPE_RTPMAP) + continue; + + if ((dash = strstr(mgcMgcpPara.sdp.medias.medias[0].attrs.attrs[i].aValue, "AMR_")) == NULL) + continue; + + if ((slash = strchr(dash, '/')) != NULL) + { + strcpy(tmp, slash); + strcpy(dash+3, tmp); + } + + } +} + +int mgc_rtp_proxy_find_mgNo(MG_INFO *pMgInfo) +{ + int i; + + if(pMgInfo == NULL) + return -1; + + for (i = 1; i < MGC_MAX_NUM_OF_MG; i++) + { + if(&(mgcMgInfo[i]) == pMgInfo) + return i; + } + + return -1; +} + + + +BOOL mgc_rtp_proxy_connection_find_own_chnl(CONNECT_INFO *pConn ,CHNL *pChnl) +{ + CHNL_INFO *pChnlInfo = NULL; + MG_INFO *pMgInfo = NULL; + BOOL tag =FALSE; + int i; + + if((pConn == NULL)||(pChnl == NULL)) + return FALSE; + + if(pConn->chlIndex>=MGC_MAX_NUM_OF_CHNL) + return FALSE; + + pChnlInfo = &mgcChnl[pConn->chlIndex]; + tag = FALSE; + for(i=0 ; iconnectIndex[i]]) + { + pChnl->connectNo = i; + tag = TRUE; + break; + } + } + + if(tag == FALSE) + return FALSE; + + pMgInfo = &(mgcMgInfo[pChnlInfo->mgNo]); + i= mgc_rtp_proxy_find_mgNo(pMgInfo); + if(i<0) + return FALSE; + + pChnl->mgNo = i; + return TRUE; +} + + + + +int mgc_create_para_call_id(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + if (connectInfo->mediaAttr.callId[0] == '\0') + { + sprintf(connectInfo->mediaAttr.callId, "%X%lX", portInfo->usrPort, time(NULL)); + } + + strcpy(mgcMgcpPara.c.callId, connectInfo->mediaAttr.callId); + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_C; + + return 0; +} + +int mgc_create_para_con_id(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + + strcpy(mgcMgcpPara.i.conId, connectInfo->mediaAttr.conId); + mgcMgcpPara.flag |= MGCP_PARA_FLAG_I; + + return 0; +} + +int mgc_create_para_local_opt(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + CHNL chnl; + MG_INFO *pMgInfo = NULL; + if(connectInfo == NULL) + return -1; + + if(mgc_rtp_proxy_connection_find_own_chnl(connectInfo , &chnl) == TRUE) + { + pMgInfo = &mgcMgInfo[chnl.mgNo]; + } + + if(pMgInfo == NULL) + return -1; + + mgcMgcpPara.l.p = connectInfo->mediaAttr.ptime; + + if (connectInfo->mediaAttr.vocoderType > MGC_VCTYPE_MAX_1) + { + strcpy(mgcMgcpPara.l.codec, vcName[0]); + } + else + { + strcpy(mgcMgcpPara.l.codec, vcName[connectInfo->mediaAttr.vocoderType]); + }//add by Francis + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_IPBSS) + { + switch(connectInfo->mediaAttr.vocoderType) + { + case MGC_VCTYPE_AMR_12_2: + case MGC_VCTYPE_AMR_10_2: + case MGC_VCTYPE_AMR_7_95: + case MGC_VCTYPE_AMR_7_4: + case MGC_VCTYPE_AMR_6_7: + case MGC_VCTYPE_AMR_5_15: + case MGC_VCTYPE_AMR_5_9: + case MGC_VCTYPE_AMR_4_75: + sprintf(mgcMgcpPara.l.codec , "AMR"); + break; + default: + break; + } + } + + mgcMgcpPara.l.ecDisable = connectInfo->mediaAttr.ecDisable; + mgcMgcpPara.l.ssDisable = connectInfo->mediaAttr.ssDisable; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_L; + + return 0; +} + +int mgc_create_para_con_mode(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + if (connectInfo->mediaAttr.conMode > 3)//new replace + { + return -1; + }//add by Francis + + mgcMgcpPara.m.mode = connectInfo->mediaAttr.conMode; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_M; + + return 0; +} + +int mgc_create_para_signal_request(PORT_INFO *portInfo, CHNL_INFO *chnlInfo) +{ + if (chnlInfo == NULL) + { + mgcMgcpPara.s.pkg = 0; + mgcMgcpPara.s.signal = 0; + } + else + { + if(portInfo->mgcfOperId == MGC_OPER_ID_CONNECT_CHNL) + { + mgcMgcpPara.r.pkg = chnlInfo->comMediaAttr.pkgReq>> 8; + mgcMgcpPara.r.event= chnlInfo->comMediaAttr.pkgReq & 0xFF; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_R; + return 0; + } + + if (MGC_OPER_ID_CONNECT_DTMF == portInfo->mgcfOperId) + { + mgcMgcpPara.r.pkg = chnlInfo->comMediaAttr.pkgReq>> 8; + mgcMgcpPara.r.event= chnlInfo->comMediaAttr.pkgReq & 0xFF; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_R; + } + + mgcMgcpPara.s.pkg = chnlInfo->comMediaAttr.pkgSignal >> 8; + mgcMgcpPara.s.signal = chnlInfo->comMediaAttr.pkgSignal & 0xFF; + } + mgcMgcpPara.flag |= MGCP_PARA_FLAG_S; + return 0; +} + +int mgc_create_para_sdp(PORT_INFO *portInfo, CONNECT_INFO *connectInfo, BYTE vocoderType) +{ + + memcpy((BYTE *) &mgcMgcpPara.sdp, (BYTE *) &connectInfo->mediaAttr.sdp, sizeof(PUB_SDP_MSG)); +/* + switch (vocoderType) + { + case MGC_VCTYPE_PCMA: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 8; + break; + case MGC_VCTYPE_PCMU: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 0; + break; + case MGC_VCTYPE_GSM: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 3; + break; + case MGC_VCTYPE_GSM_EFR: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 84; + break; + case MGC_VCTYPE_AMR_12_2: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 71; + break; + case MGC_VCTYPE_G729B: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 118; + break; + case MGC_VCTYPE_AMR_10_2: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 70; + break; + case MGC_VCTYPE_AMR_7_95: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 69; + break; + case MGC_VCTYPE_AMR_7_4: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 68; + break; + case MGC_VCTYPE_AMR_6_7: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 67; + break; + case MGC_VCTYPE_AMR_5_15: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 65; + break; + case MGC_VCTYPE_AMR_5_9: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 66; + break; + case MGC_VCTYPE_AMR_4_75: + mgcMgcpPara.sdp.medias.medias[0].m.payloads[0] = 64; + break; + default: + break; + } +*/ + + if (mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_IPBSS) + { + mgc_rpl_para_amr_sdp(); + } + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SDP; + + if ((mgcMgcpPara.sdp.flag & PUB_SDP_FLAG_O) == 0) + { + mgc_log_err("mgc_create_para_sdp: No SDP Flag !\n\r"); + } + + return 0; +} + +int mgc_create_para_crcx(BYTE type, WORD port, WORD localConnectIndex) +{ + PORT_INFO *portInfo; + CONNECT_INFO *connectInfo; + MGCF_OPER_STEP *pStep; + CHNL remChnl; + MG_INFO *pMgInfo; + WORD remChnlIndex, phyPort , remConnIndex; + if (port >= MGC_MAX_NUM_OF_PORT) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + connectInfo = &mgcConnectInfo[localConnectIndex];//new replace + + + + + if (type == MGCP_COMMAND) + { + if (mgc_create_para_con_mode(portInfo, connectInfo) < 0) + { + return -1; + }//add by Francis + + mgc_create_para_call_id(portInfo, connectInfo); + mgc_create_para_local_opt(portInfo, connectInfo); + + if ((mgcPort[port].mgcfOperId == MGC_OPER_ID_CONNECT_TONE) + || (mgcPort[port].mgcfOperId == MGC_OPER_ID_CONNECT_AAS)) + { + + pStep = &portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex]; + memcpy(&remChnl , &pStep->remChnl , sizeof(remChnl)); + + if(remChnl.mgNo > MGC_MAX_NUM_OF_MG) + { + mgc_log_err("mgc_create_para_crcx: invalid mgNo!\n\r"); + return -1; + } + + if (remChnl.portNo >= MGC_MAX_PHY_PORT_PER_MG) + { + mgc_log_err("mgc_create_para_crcx: invalid portNo!\n\r"); + return -1; + } + + if (remChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON) + { + mgc_log_err("mgc_create_para_crcx: invalid connectNo!\n\r"); + return -1; + } + + + pMgInfo = &mgcMgInfo[remChnl.mgNo]; + + if ((MGC_MG_TYPE_ANN == pMgInfo->mgAttr.mgType)||(MGC_MG_TYPE_INTERNAL == pMgInfo->mgAttr.mgType)) + { + remChnlIndex= pMgInfo->chnlStartIndex + remChnl.chlNo; + } + else + { + phyPort = pMgInfo->portIndex[remChnl.portNo]; + remChnlIndex= mgcPhyPort[phyPort].chnlStartIndex + remChnl.chlNo; + } + + remConnIndex= mgcChnl[remChnlIndex].connectIndex[remChnl.connectNo]; + if(remConnIndex > MGC_MAX_NUM_OF_CON) + return -1; + mgc_create_para_sdp(portInfo, &mgcConnectInfo[remConnIndex], connectInfo->mediaAttr.vocoderType); + } + } + else + { + mgc_create_para_con_id(portInfo, connectInfo); + mgc_create_para_sdp(portInfo, connectInfo, connectInfo->mediaAttr.vocoderType); + } + + return 0; +} + +int mgc_create_para_mdcx(BYTE type, WORD port, WORD localChnlIndex, WORD remoteChnlIndex, WORD localConnectIndex, WORD remoteConnectIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *localChnlInfo, *remoteChnlInfo; + CONNECT_INFO *localConnectInfo; + CONNECT_INFO *remoteConnectInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (localChnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + localChnlInfo = &mgcChnl[localChnlIndex]; + remoteChnlInfo = &mgcChnl[remoteChnlIndex]; + localConnectInfo = &mgcConnectInfo[localConnectIndex]; + remoteConnectInfo = &mgcConnectInfo[remoteConnectIndex]; + + + if (type == MGCP_COMMAND) + { + if (mgc_create_para_con_mode(portInfo, localConnectInfo) < 0) + { + return -1; + }//add by Francis + + mgc_create_para_call_id(portInfo, localConnectInfo); + mgc_create_para_con_id(portInfo, localConnectInfo); + mgc_create_para_local_opt(portInfo, localConnectInfo); + mgc_create_para_signal_request(portInfo, localChnlInfo); + +// if (localConnectInfo->mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + mgc_create_para_sdp(portInfo, remoteConnectInfo, localConnectInfo->mediaAttr.vocoderType); + } + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcMgcpPara.flag |= MGCP_PARA_FLAG_TFO; + } + } + + return 0; +} + +int mgc_create_para_dlcx(BYTE type, WORD port, WORD chnlIndex, WORD connectIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *chnlInfo = NULL; + CONNECT_INFO *connectInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (chnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + chnlInfo = &mgcChnl[chnlIndex]; + connectInfo = &mgcConnectInfo[connectIndex]; + + if (type == MGCP_COMMAND) + { + if (chnlIndex < MGC_MAX_NUM_OF_CHNL) + { + if (0 == (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & 0x01)) + { + mgc_create_para_call_id(portInfo, connectInfo); + mgc_create_para_con_id(portInfo, connectInfo); + } + } + mgc_create_para_signal_request(portInfo, chnlInfo); + } + + return 0; +} + +int mgc_create_para_rqnt(BYTE type, WORD port, WORD chnlIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *chnlInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (chnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + chnlInfo = &mgcChnl[chnlIndex]; + + if (type == MGCP_COMMAND) + mgc_create_para_signal_request(portInfo, chnlInfo); + + return 0; +} + +int mgc_create_para_auep(BYTE type, WORD port, WORD chnlIndex) +{ + return 0; +} + +int mgc_create_para(BYTE type, WORD port, MG_ATTR *mgAttr, BYTE cmd) +{ + PORT_INFO *portInfo; + CHNL remChnl; + WORD localChnlIndex = 0xFFFF, remoteChnlIndex; + WORD localConnectIndex; + WORD remoteConnectIndex; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + + if ((type == MGCP_RESPONSE) && (mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType == MGC_USER_TYPE_MG)) + { + mgcMgcpPara.ip = portInfo->ip; + } + else + { + mgcMgcpPara.ip = mgAttr->ip; + } + + if (mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType == MGC_USER_TYPE_MGC) + { + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + } + else + { + mgcMgcpPara.localPort = MGC_MGCP_MG_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MGC_PORT; + } + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = type; + if (type == MGCP_COMMAND) + { + mgcMgcpPara.sl.epNameMethod = mgAttr->epDes; + mgcMgcpPara.sl.mgType = mgAttr->mgType; + if (mgc_is_non_virtual_mg(mgAttr->mgType)) + { + mgcMgcpPara.sl.portType = mgcPhyPort[mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]].portType; + } + else + { + mgcMgcpPara.sl.portType = 0; + }//add by Francis + mgcMgcpPara.sl.trkNum = portInfo->mgcfChnl.portNo; + mgcMgcpPara.sl.chlNum = portInfo->mgcfChnl.chlNo; + strcpy(mgcMgcpPara.sl.mgName, mgAttr->domain); + } + else + mgcMgcpPara.sl.retCode = portInfo->usrCmd; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + if (portInfo->mgcfChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + { + if ((MGC_MG_TYPE_ANN == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType)) + { + localChnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + localChnlIndex = mgcPhyPort[mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + } + + if ((MGCP_CMD_RQNT != cmd) && (MGCP_CMD_NTFY != cmd) && (MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RSIP != cmd)) + { + localConnectIndex = mgcChnl[localChnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]; + + if (localConnectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_create_para: localConnectIndex out of range!\n\r"); + return -1; + } + } + + switch (cmd) + { + case MGCP_CMD_CRCX: + mgc_create_para_crcx(type, port, localConnectIndex); + break; + case MGCP_CMD_MDCX: + remChnl = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].remChnl; + if ((MGC_MG_TYPE_INTERNAL != mgcMgInfo[remChnl.mgNo].mgAttr.mgType) && (MGC_MG_TYPE_ANN != mgcMgInfo[remChnl.mgNo].mgAttr.mgType)) + remoteChnlIndex = mgcPhyPort[mgcMgInfo[remChnl.mgNo].portIndex[remChnl.portNo]].chnlStartIndex + remChnl.chlNo; + else + remoteChnlIndex = mgcMgInfo[remChnl.mgNo].chnlStartIndex + remChnl.chlNo; + + remoteConnectIndex = mgcChnl[remoteChnlIndex].connectIndex[remChnl.connectNo]; +// if (mgcConnectInfo[localConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + if (remoteConnectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_create_para: remoteConnectIndex out of range!\n\r"); + return -1; + } + } + + mgc_create_para_mdcx(type, port, localChnlIndex, remoteChnlIndex, localConnectIndex, remoteConnectIndex); + break; + case MGCP_CMD_DLCX: + mgc_create_para_dlcx(type, port, localChnlIndex, localConnectIndex); + break; + case MGCP_CMD_RQNT: + mgc_create_para_rqnt(type, port, localChnlIndex); + break; + case MGCP_CMD_AUEP: + mgc_create_para_auep(type, port, localChnlIndex); + break; + } + + return 0; +} + + +int mgc_update_connect_media_by_step(WORD port, BYTE savPort, CHNL mgcfChnl, MGCF_OPER_STEP *currOperStep) +{ + WORD portIndex, chnlIndex; + WORD connectIndex; + PORT_INFO *portInfo; + + portInfo = &mgcPort[port]; + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgcfChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[mgcfChnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[mgcfChnl.mgNo].chnlStartIndex + mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[mgcfChnl.mgNo].portIndex[mgcfChnl.portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + mgcfChnl.chlNo; + } + + if (savPort == MGC_CHNL_CLEAR_PORT) + { + if (portInfo->mngCmd == MGC_MNG_CMD_OVERWRITE) + { + portInfo->mngCmd = MGC_MNG_CMD_IDLE; + } + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_AUEP) && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RQNT) + && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RSIP)) + { + connectIndex = mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo]; + mgcConnectInfo[connectIndex].port = 0xFFFF; + mgcChnl[chnlIndex].port = 0xFFFF; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd == MGCP_CMD_DLCX) + && (0 == (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & 0x01))) + { + mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo] = 0xFFFF; + } + } + else + { + mgcChnl[chnlIndex].port = 0xFFFF; + } + return 0; + } + else + { + if ((currOperStep->cmd == MGCP_CMD_AUEP) || (currOperStep->cmd == MGCP_CMD_RQNT) || (currOperStep->cmd == MGCP_CMD_RSIP)) + { + mgcChnl[chnlIndex].port = port; + } + else + { + connectIndex = mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo]; + + mgcConnectInfo[connectIndex].port = port; + mgcChnl[chnlIndex].port = port; + + mgcConnectInfo[connectIndex].mediaAttr.ptime = currOperStep->media.ptime; + mgcConnectInfo[connectIndex].mediaAttr.conMode = currOperStep->media.conMode; + mgcConnectInfo[connectIndex].mediaAttr.vocoderType = currOperStep->media.vocoderType.codec[0]; + mgcConnectInfo[connectIndex].mediaAttr.pkgSignal = currOperStep->pkgSignal; + } + } + + mgcChnl[chnlIndex].comMediaAttr.pkgSignal = currOperStep->pkgSignal; + + return 0; +} + +BYTE mgc_mgcf_request(WORD port, BYTE *clrFlag, BYTE *mgcInsert) +{ + PORT_INFO *portInfo; + MG_ATTR *mgAttr; + BYTE sapIndex; + WORD cmd, res; + int llPort; + WORD portIndex = 0xFFFF; + WORD chnlIndex = 0xFFFF; + char tmpStr[128]; + int i; + WORD connectIndex = 0xFFFF; + BYTE toneNo, oldMode; + CHNL aasOrgChnl; + + WORD aasPhyPortOrg; + + WORD aasChnlIndexOrg; + + WORD aasOrgConnectIndex; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return 0; + }//add by Francis + + portInfo = &mgcPort[port]; + mgAttr = &mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr; + + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) + && (portInfo->mgcfChnl.chlNo < MGC_MAX_NUM_OF_CHNL)) + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + *clrFlag = 0; + + if (chnlIndex >= MGC_MAX_NUM_OF_CHNL) + return 2; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_AUEP) + && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RSIP)) + { + if (((portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + || (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].chnlConnectIndex != portInfo->mgcfChnl.connectNo) + || ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON)) + { +// *clrFlag = 1; + return 2; + } + } + + if (portInfo->mgcfOperStepsNum >= MGC_MAX_OPER_STEPS_NUM) + { + mgc_log_err("mgc_mgcf_request: OperStepsNum out of range!\n\r"); + *clrFlag = 1; + return 2; + } + + switch (portInfo->mgcfState2) + { + case 0: + cmd = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd; + + if (cmd != MGCP_CMD_AUEP) + { + if (chnlIndex < MGC_MAX_NUM_OF_CHNL) + { + if (((cmd != MGCP_CMD_RQNT) && (cmd != MGCP_CMD_RSIP) && (mgcConnectInfo[connectIndex].port < MGC_MAX_NUM_OF_PORT)) + || (((cmd == MGCP_CMD_RQNT) || (cmd == MGCP_CMD_RSIP)) && (mgcChnl[chnlIndex].port < MGC_MAX_NUM_OF_PORT))) + { + if (portInfo->mgcfTimer == 0) + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + else if (--portInfo->mgcfTimer == 0) + { + *clrFlag = 1;// + return 2; + } + return 0; + } + else if (cmd == MGCP_CMD_CRCX) + { + if ((mgcConnectInfo[connectIndex].status == MGC_CONNECT_STATUS_CREATED)||(mgcConnectInfo[connectIndex].status == MGC_CONNECT_STATUS_TONE)) + { + *clrFlag = 0;// + return 1; + } + else + portInfo->mgcfTimer = 0; + } + + oldMode = mgcConnectInfo[connectIndex].mediaAttr.conMode; + mgc_update_connect_media_by_step(port, MGC_CHNL_SAVE_PORT, mgcPort[port].mgcfChnl, &mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex]); + } + } + + MGCF_OPER_STEP *pStep; + pStep = &mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex]; + + + mgc_create_para(MGCP_COMMAND, port, mgAttr, cmd); + + if(cmd == MGCP_CMD_MDCX) + { + if(mgc_sess_is_chnl_need_update(pStep->localChnl , &mgcMgcpPara) == FALSE) + { + *clrFlag = 1; + return 1; + } + } + + if ((llPort = MGCP_req(mgcMgcpSapIndex, cmd, port, &mgcMgcpPara)) < 0) + { + sprintf(tmpStr, "mgc_mgcf_request: MGCP_req failed, cmd: %d, usrPort: %d, port = %d\n\r", cmd, portInfo->usrPort, port); + mgc_log_err(tmpStr); + + if (cmd != MGCP_CMD_AUEP) + { + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, MGCP_RET_CODE_TRANS_TIME_OUT); + *clrFlag = 1; + } + else // AUEP + { + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + *clrFlag = 0; + } + return 2; + } + + sprintf(tmpStr, "mgc_mgcf_request: send mgcp command: %d, port = %d, llPort = %d, OperStepIndex = %d\n\r", cmd, port, llPort, portInfo->mgcfOperStepIndex); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + //if (cmd == MGCP_CMD_CRCX) + //mgcChnl[chnlIndex].status = MGC_CHNL_STATUS_CREATING; + + portInfo->llPort = llPort; + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + portInfo->mgcfState2 = 1; + break; + case 1: + if (portInfo->llCmd != 0) + { + res = portInfo->llCmd; + portInfo->llCmd = 0; + + if ((res >= 100) && (res < 200)) + return 0; + + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + cmd = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd; + + sprintf(tmpStr, "mgc_mgcf_request: got response: %d, port = %d, usrPort = %d\n\r", res, port, portInfo->usrPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if ((res == 200) || + ((res == 250) && (cmd == MGCP_CMD_DLCX))) + { + if (cmd == MGCP_CMD_AUEP) + { // AUEP + mgcMgInfo[portInfo->mgcfChnl.mgNo].stLast = 1; + + if ((mgc_is_non_virtual_mg(mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType)) + && (mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_AudioCoder))//revise by Francis 0822 + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[i]; + if (portIndex != 0xFFFF) + { + mgcPhyPort[portIndex].stLast = 1; + } + } + } + + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + *clrFlag = 0; + return 2; + } + else + { + if (cmd == MGCP_CMD_CRCX) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum++; + +// if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex-1].flag & 0x01) == 1) +// { +// mgcConnectInfo[connectIndex].assigned = 1; +// } + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + + if (cmd == MGCP_CMD_DLCX) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + + if ((portInfo->mgcfOperId == MGC_OPER_ID_CONNECT_TONE) || (portInfo->mgcfOperId == MGC_OPER_ID_CONNECT_AAS)) + + { + + aasOrgChnl = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].remChnl; + + + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType) + + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType)) + + { + + aasChnlIndexOrg = mgcMgInfo[aasOrgChnl.mgNo].chnlStartIndex + aasOrgChnl.chlNo; + + } + + else + + { + + aasPhyPortOrg = mgcMgInfo[aasOrgChnl.mgNo].portIndex[aasOrgChnl.portNo]; + + aasChnlIndexOrg = mgcPhyPort[aasPhyPortOrg].chnlStartIndex + aasOrgChnl.chlNo; + + } + + + + if (((mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType != MGC_MG_TYPE_ANN) && (aasPhyPortOrg < MGC_MAX_NUM_OF_PHY_PORT) && (aasChnlIndexOrg < MGC_MAX_NUM_OF_CHNL)) + + || ((mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_INTERNAL) && (mgcMgInfo[aasOrgChnl.mgNo].mgAttr.mgType == MGC_MG_TYPE_ANN) && (aasChnlIndexOrg < MGC_MAX_NUM_OF_CHNL))) + + { + + if ((aasOrgConnectIndex = mgcChnl[aasChnlIndexOrg].connectIndex[aasOrgChnl.connectNo]) < MGC_MAX_NUM_OF_CON) + + { + + mgcConnectInfo[aasOrgConnectIndex].aasChnl.mgNo = 0xFFFF; + + mgcConnectInfo[aasOrgConnectIndex].aasChnl.portNo = 0xFF; + + mgcConnectInfo[aasOrgConnectIndex].aasChnl.chlNo = 0xFFFF; + + mgcConnectInfo[aasOrgConnectIndex].aasChnl.connectNo = 0xFFFF; + + mgcConnectInfo[aasOrgConnectIndex].status = MGC_CONNECT_STATUS_CREATED; + + sprintf(tmpStr, "mgc_mgcf_request: clear aas orgconnect info: mgNo = %d, port = %d, chl = %d\n\r", aasOrgChnl.mgNo, aasOrgChnl.portNo, aasOrgChnl.chlNo); + + mgc_log_procedure(aasOrgChnl.mgNo, aasPhyPortOrg, aasChnlIndexOrg, tmpStr); + + + + } + + + + } + + } + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & 0x01) != 1) + { + mgcConnectInfo[connectIndex].assigned = 0; + } + + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + + if((cmd == MGCP_CMD_RQNT)&&(portInfo->mgcfOperId == MGC_OPER_ID_CONNECT_TONE)) + { + if(portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].pkgSignal != 0) + { + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_TONE; + } + else + { + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + } + + if((cmd == MGCP_CMD_CRCX)&&(portInfo->mgcfOperId == MGC_OPER_ID_CONNECT_TONE)) + { + MG_INFO *pMgInfo , *pRemMgInfo; + int remConnIndex = -1; + int remChnlIndex = -1; + WORD remPortIndex; + CHNL remChnl; + + if(portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].localChnl.mgNo < MGC_MAX_NUM_OF_MG) + { + pMgInfo = &mgcMgInfo[portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].localChnl.mgNo]; + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_ANN) + { + remChnl = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].remChnl; + + if(remChnl.mgNo < MGC_MAX_NUM_OF_MG) + { + pRemMgInfo = &mgcMgInfo[remChnl.mgNo]; + + if ((MGC_MG_TYPE_ANN == pRemMgInfo->mgAttr.mgType)||(MGC_MG_TYPE_INTERNAL == pRemMgInfo->mgAttr.mgType)) + { + remChnlIndex = pRemMgInfo->chnlStartIndex + remChnl.chlNo; + } + else + { + + remPortIndex = pRemMgInfo->portIndex[remChnl.portNo]; + if ((remPortIndex < MGC_MAX_NUM_OF_PHY_PORT)&&(remChnl.chlNo < MGC_MAX_NUM_OF_CHNL)) + remChnlIndex = mgcPhyPort[remPortIndex].chnlStartIndex+remChnl.chlNo; + } + + if((remChnlIndex >= 0)&&(remChnl.connectNo < MGC_MAX_NUM_OF_CHNL_CON)) + { + remConnIndex = mgcChnl[remChnlIndex].connectIndex[remChnl.connectNo]; + } + + if((remConnIndex >=0)&&(remConnIndex < MGC_MAX_NUM_OF_CON)) + { + mgcConnectInfo[remConnIndex].status = MGC_CONNECT_STATUS_TONE; + } + } + } + } + } + + + + if ((portInfo->mgcfOperStepIndex + 1) >= portInfo->mgcfOperStepsNum) + { + if (mgcSap[sapIndex].mgc_cnf == NULL) + { + *clrFlag = 1;// + return 2; + } + + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, 0); + + if (0 == portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay) + *clrFlag = 1;// + + return 1; + } + } + } + else if ((MGCP_CMD_CRCX == cmd) && (502 == res)) + { + for (i = portInfo->mgcfOperStepsNum; i > portInfo->mgcfOperStepIndex; i--) + { + portInfo->mgcfOperSteps[i] = portInfo->mgcfOperSteps[i-1]; + } + + + portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd = MGCP_CMD_DLCX; + portInfo->mgcfOperStepsNum = portInfo->mgcfOperStepsNum + 1; + + portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag |= 0x01; + portInfo->mgcfState2 = 0; + *mgcInsert = 1; + *clrFlag = 1; + return 1; + }//add by Franics 0823 + else if (cmd != MGCP_CMD_AUEP) + { + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, cmd); + + if (connectIndex < MGC_MAX_NUM_OF_CON) + { + mgc_connect_init(connectIndex); + } + + *clrFlag = 1; + return 2; + } + else + { // AUEP + *clrFlag = 0; + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + return 2; + } + + if (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay == 0) + { + portInfo->mgcfState2 = 0; + *clrFlag = 1; + return 1; + } + else + { + portInfo->mgcfTimer = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay; + portInfo->mgcfState2 = 2; + } + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + sprintf(tmpStr, "mgc_mgcf_request: timeout, port = %d, usrPort = %d\n\r", port, portInfo->usrPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + cmd = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd; + + if ((cmd != MGCP_CMD_AUEP) && (MGCP_CMD_RQNT != cmd) && (MGCP_CMD_RSIP != cmd)) + { +// if (cmd == MGCP_CMD_DLCX) +// { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; +// } + + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, MGCP_RET_CODE_TRANS_TIME_OUT); + *clrFlag = 1; + } + else // AUEP + { + *clrFlag = 0; + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + } + return 2; + } + } + break; + case 2: + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + if (portInfo->mngCmd != MGC_MNG_CMD_IDLE) + { + if (portInfo->mngCmd == MGC_MNG_CMD_OVERWRITE) + { + if ((0 != portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].pkgSignal) + || (portInfo->mgcfOperId = MGC_OPER_ID_CONNECT_TONE) + || (portInfo->mgcfOperId = MGC_OPER_ID_CONNECT_AAS)) + { + portInfo->mgcfState2 = 0; + + *clrFlag = 1;// + + return 1; + } + else + { + *clrFlag = 1;// + return 2; + } + } + else if (portInfo->mngCmd == MGC_MNG_CMD_CLEAR_AFTER_OPER) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + + if (mgcSap[sapIndex].mgc_cnf != NULL) + { + if (MGC_OPER_ID_CONNECT_AAS == portInfo->mgcfOperId) + { + toneNo = (portInfo->mgcfChnl.chlNo%10) + 7; + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, toneNo); + } + else + { + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, 0); + } + } + + *clrFlag = 1;// + return 2; + } + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + *clrFlag = 1;// + + portInfo->mgcfState2 = 0; + + return 1; + } + } + break; + } + + return 0; +} + +BYTE mgc_mgcf_indication(WORD port) +{ + PORT_INFO *portInfo; + MG_ATTR *mgAttr; + BYTE sapIndex; + WORD portIndex; + WORD chnlIndex; + WORD cmd, res; + char tmpStr[128]; + int connectIndex; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return 0; + }//add by Francis + + portInfo = &mgcPort[port]; + mgAttr = &mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr; + + if ((mgAttr->mgType == MGC_MG_TYPE_ANN) + || (mgAttr->mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_mgcf_indication: invalid portIndex!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + if (((portInfo->llCmd != MGCP_CMD_RSIP) && (chnlIndex >= MGC_MAX_NUM_OF_CHNL)) || (portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + return -1; + + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)&& (portInfo->llCmd != MGCP_CMD_NTFY)) + { + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_mgcf_indication: invalid connectIndex!\n\r"); + return -1; + } + } + + switch (portInfo->mgcfState2) + { + case 0: + cmd = portInfo->llCmd; + + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp indication: %d, port = %d, mgNo: %d, portNo: %d, chlNo: %d\n\r", + cmd, port, portInfo->mgcfChnl.mgNo, portInfo->mgcfChnl.portNo, portInfo->mgcfChnl.chlNo); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if (mgcSap[sapIndex].mgc_ind == NULL) + { + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP) && (portInfo->llCmd != MGCP_CMD_NTFY)) + { + mgcConnectInfo[connectIndex].assigned = 0; + } + + return 1; + } + + if ((cmd != MGCP_CMD_CRCX) && (portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (cmd != MGCP_CMD_RSIP) && (mgcSap[sapIndex].usrType == MGC_USER_TYPE_MG)) + { + portInfo->usrPort = ((strtoll(mgcConnectInfo[connectIndex].mediaAttr.conId, NULL, 16))>>32) & 0xFFFF ; + } + + if ((cmd == MGCP_CMD_RSIP) || (cmd == MGCP_CMD_AUEP) || (cmd == MGCP_CMD_RQNT)) + { + if (mgcSap[sapIndex].mgc_ind(portInfo->mgcfChnl, cmd, &portInfo->usrPort, port, NULL) < 0) + return 1; + } + else if ((MGC_USER_TYPE_MGC == mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType) + && ((MGCP_CMD_CRCX == cmd) || (MGCP_CMD_MDCX == cmd))) + { + mgc_log_err("mgc_mgcf_indication: invalid command!\n\r"); + return -1; + } + else if((MGC_USER_TYPE_MGC == mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType)&&(MGCP_CMD_NTFY == cmd)) + { + mgcSap[sapIndex].mgc_ind(portInfo->mgcfChnl, cmd, &portInfo->usrPort, port, &mgcChnl[chnlIndex].comMediaAttr); + } + else if (mgcSap[sapIndex].mgc_ind(portInfo->mgcfChnl, cmd, &portInfo->usrPort, port, &mgcConnectInfo[connectIndex].mediaAttr) < 0) + { + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)) + { + mgcConnectInfo[connectIndex].assigned = 0; + } + + return 1; + } + + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + portInfo->mgcfState2 = 1; + break; + case 1: + if (portInfo->usrCmd != 0) + { + res = portInfo->usrCmd; + portInfo->usrCmd = 0; + + mgc_create_para(MGCP_RESPONSE, port, mgAttr, portInfo->llCmd); + MGCP_rsp(mgcMgcpSapIndex, portInfo->llCmd, port, portInfo->llPort, res, &mgcMgcpPara); + + if (MGCP_CMD_CRCX == portInfo->llCmd) + { + if (200 == res) + { + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + else + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + } + else if (MGCP_CMD_DLCX == portInfo->llCmd) + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp response: %d, port = %d, llPort = %d\n\r", res, port, portInfo->llPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 1; + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + sprintf(tmpStr, "mgc_mgcf_indication: timeout, port = %d\n\r", port); + mgc_log_err(tmpStr); + + MGCP_rsp(mgcMgcpSapIndex, portInfo->llCmd, port, portInfo->llPort, MGCP_RET_CODE_TRANS_TIME_OUT, &mgcMgcpPara); + + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP) && (portInfo->llCmd != MGCP_CMD_NTFY)) + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp response: %d, port = %d, llPort = %d\n\r", MGCP_RET_CODE_TRANS_TIME_OUT, port, portInfo->llPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 1; + } + } + break; + } + + return 0; +} + +void mgc_fsm(WORD port) +{ + BYTE clrFlag; + BYTE mgcInsert = 0; + + switch (mgcPort[port].mgcfState) + { + case MGC_MGCF_STATE_REQUEST: + if (0 == mgcPort[port].mgcfOperStepIndex) + mgcPort[port].mgcfChnl = mgcPort[port].mgcfOperSteps[0].localChnl; + + switch (mgc_mgcf_request(port, &clrFlag, &mgcInsert)) + { + case 0: + break; + case 1: + if (clrFlag == 1) + mgc_update_connect_media_by_step(port, MGC_CHNL_CLEAR_PORT, mgcPort[port].mgcfChnl, NULL); + + if (++mgcPort[port].mgcfOperStepIndex >= mgcPort[port].mgcfOperStepsNum) + { + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + } + else + { + if (1 == mgcInsert) + { + mgcPort[port].mgcfOperStepIndex--; + mgcInsert = 0; + } + + mgcPort[port].mgcfChnl = mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].localChnl; + mgc_fsm(port); + } + break; + default: + if (clrFlag == 1) + mgc_update_connect_media_by_step(port, MGC_CHNL_CLEAR_PORT, mgcPort[port].mgcfChnl, NULL); + + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + break; + } + break; + case MGC_MGCF_STATE_INDICATION: + switch (mgc_mgcf_indication(port)) + { + case 0: + break; + default: + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + break; + } + break; + case MGC_MGCF_STATE_INIT: + mgc_port_init(port); + break; + } +} diff --git a/omc/plat/mgc/src/mgc_fsm.c.bak b/omc/plat/mgc/src/mgc_fsm.c.bak new file mode 100644 index 0000000..03628e7 --- /dev/null +++ b/omc/plat/mgc/src/mgc_fsm.c.bak @@ -0,0 +1,1052 @@ +#include "./include/mgc_pub.h" +#include "./include/mgc.h" +#include "./include/mgc_const.h" +#include "./include/mgc_ext.h" +#include "./include/mgc_struct.h" +#include "./include/mgc_debug.h" + +extern void mgc_port_init(WORD port); + +int mgc_create_para_call_id(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + if (connectInfo->mediaAttr.callId[0] == '\0') + { + sprintf(connectInfo->mediaAttr.callId, "%X%lX", portInfo->usrPort, time(NULL)); + } + + strcpy(mgcMgcpPara.c.callId, connectInfo->mediaAttr.callId); + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_C; + + return 0; +} + +int mgc_create_para_con_id(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + + strcpy(mgcMgcpPara.i.conId, connectInfo->mediaAttr.conId); + mgcMgcpPara.flag |= MGCP_PARA_FLAG_I; + + return 0; +} + +int mgc_create_para_local_opt(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + mgcMgcpPara.l.p = connectInfo->mediaAttr.ptime; + + if (connectInfo->mediaAttr.vocoderType > MGC_VCTYPE_MAX_1) + { + strcpy(mgcMgcpPara.l.codec, vcName[0]); + } + else + { + strcpy(mgcMgcpPara.l.codec, vcName[connectInfo->mediaAttr.vocoderType]); + }//add by Francis + + mgcMgcpPara.l.ecDisable = connectInfo->mediaAttr.ecDisable; + mgcMgcpPara.l.ssDisable = connectInfo->mediaAttr.ssDisable; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_L; + + return 0; +} + +int mgc_create_para_con_mode(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + if (connectInfo->mediaAttr.conMode > 3)//new replace + { + return -1; + }//add by Francis + + mgcMgcpPara.m.mode = connectInfo->mediaAttr.conMode; + mgcMgcpPara.flag |= MGCP_PARA_FLAG_M; + + return 0; +} + +int mgc_create_para_signal_request(PORT_INFO *portInfo, CHNL_INFO *chnlInfo) +{ + if (chnlInfo == NULL) + { + mgcMgcpPara.s.pkg = 0; + mgcMgcpPara.s.signal = 0; + } + else + { + mgcMgcpPara.s.pkg = chnlInfo->comMediaAttr.pkgSignal >> 8; + mgcMgcpPara.s.signal = chnlInfo->comMediaAttr.pkgSignal & 0xFF; + } + mgcMgcpPara.flag |= MGCP_PARA_FLAG_S; + + return 0; +} + +int mgc_create_para_sdp(PORT_INFO *portInfo, CONNECT_INFO *connectInfo) +{ + + memcpy((BYTE *) &mgcMgcpPara.sdp, (BYTE *) &connectInfo->mediaAttr.sdp, sizeof(PUB_SDP_MSG)); + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SDP; + + return 0; +} + +int mgc_create_para_crcx(BYTE type, WORD port, WORD localConnectIndex) +{ + PORT_INFO *portInfo; + CONNECT_INFO *connectInfo; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + connectInfo = &mgcConnectInfo[localConnectIndex];//new replace + + if (type == MGCP_COMMAND) + { + if (mgc_create_para_con_mode(portInfo, connectInfo) < 0) + { + return -1; + }//add by Francis + + mgc_create_para_call_id(portInfo, connectInfo); + mgc_create_para_local_opt(portInfo, connectInfo); + + if ((mgcPort[port].mgcfOperId == MGC_OPER_ID_CONNECT_TONE) + || (mgcPort[port].mgcfOperId == MGC_OPER_ID_CONNECT_AAS)) + { + mgc_create_para_sdp(portInfo, connectInfo); + } + } + else + { + mgc_create_para_con_id(portInfo, connectInfo); + mgc_create_para_sdp(portInfo, connectInfo); + } + + return 0; +} + +int mgc_create_para_mdcx(BYTE type, WORD port, WORD localChnlIndex, WORD remoteChnlIndex, WORD localConnectIndex, WORD remoteConnectIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *localChnlInfo, *remoteChnlInfo; + CONNECT_INFO *localConnectInfo; + CONNECT_INFO *remoteConnectInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (localChnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + localChnlInfo = &mgcChnl[localChnlIndex]; + remoteChnlInfo = &mgcChnl[remoteChnlIndex]; + localConnectInfo = &mgcConnectInfo[localConnectIndex]; + remoteConnectInfo = &mgcConnectInfo[remoteConnectIndex]; + + + if (type == MGCP_COMMAND) + { + if (mgc_create_para_con_mode(portInfo, localConnectInfo) < 0) + { + return -1; + }//add by Francis + + mgc_create_para_call_id(portInfo, localConnectInfo); + mgc_create_para_con_id(portInfo, localConnectInfo); + mgc_create_para_local_opt(portInfo, localConnectInfo); + mgc_create_para_signal_request(portInfo, localChnlInfo); + + if (localConnectInfo->mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + mgc_create_para_sdp(portInfo, remoteConnectInfo); + } + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + mgcMgcpPara.flag |= MGCP_PARA_FLAG_TFO; + } + } + + return 0; +} + +int mgc_create_para_dlcx(BYTE type, WORD port, WORD chnlIndex, WORD connectIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *chnlInfo = NULL; + CONNECT_INFO *connectInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (chnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + chnlInfo = &mgcChnl[chnlIndex]; + connectInfo = &mgcConnectInfo[connectIndex]; + + if (type == MGCP_COMMAND) + { + if (chnlIndex < MGC_MAX_NUM_OF_CHNL) + { + if (0 == (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & 0x01)) + { + mgc_create_para_call_id(portInfo, connectInfo); + mgc_create_para_con_id(portInfo, connectInfo); + } + } + mgc_create_para_signal_request(portInfo, chnlInfo); + } + + return 0; +} + +int mgc_create_para_rqnt(BYTE type, WORD port, WORD chnlIndex) +{ + PORT_INFO *portInfo; + CHNL_INFO *chnlInfo; + + if ((port >= MGC_MAX_NUM_OF_PORT) || (chnlIndex >= mgcMaxChlNo)) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + chnlInfo = &mgcChnl[chnlIndex]; + + if (type == MGCP_COMMAND) + mgc_create_para_signal_request(portInfo, chnlInfo); + + return 0; +} + +int mgc_create_para_auep(BYTE type, WORD port, WORD chnlIndex) +{ + return 0; +} + +int mgc_create_para(BYTE type, WORD port, MG_ATTR *mgAttr, BYTE cmd) +{ + PORT_INFO *portInfo; + CHNL remChnl; + WORD localChnlIndex = 0xFFFF, remoteChnlIndex; + WORD localConnectIndex; + WORD remoteConnectIndex; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return -1; + }//add by Francis + + portInfo = &mgcPort[port]; + + if ((type == MGCP_RESPONSE) && (mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType == MGC_USER_TYPE_MG)) + { + mgcMgcpPara.ip = portInfo->ip; + } + else + { + mgcMgcpPara.ip = mgAttr->ip; + } + + if (mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType == MGC_USER_TYPE_MGC) + { + mgcMgcpPara.localPort = MGC_MGCP_MGC_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MG_PORT; + } + else + { + mgcMgcpPara.localPort = MGC_MGCP_MG_PORT; + mgcMgcpPara.peerPort = MGC_MGCP_MGC_PORT; + } + mgcMgcpPara.flag = 0; + + mgcMgcpPara.sl.cmdRes = type; + if (type == MGCP_COMMAND) + { + mgcMgcpPara.sl.epNameMethod = mgAttr->epDes; + mgcMgcpPara.sl.mgType = mgAttr->mgType; + if (mgc_is_non_virtual_mg(mgAttr->mgType)) + { + mgcMgcpPara.sl.portType = mgcPhyPort[mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]].portType; + } + else + { + mgcMgcpPara.sl.portType = 0; + }//add by Francis + mgcMgcpPara.sl.trkNum = portInfo->mgcfChnl.portNo; + mgcMgcpPara.sl.chlNum = portInfo->mgcfChnl.chlNo; + strcpy(mgcMgcpPara.sl.mgName, mgAttr->domain); + } + else + mgcMgcpPara.sl.retCode = portInfo->usrCmd; + + mgcMgcpPara.flag |= MGCP_PARA_FLAG_SL; + + if (portInfo->mgcfChnl.chlNo < MGC_MAX_NUM_OF_CHNL) + { + if ((MGC_MG_TYPE_ANN == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType)) + { + localChnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + localChnlIndex = mgcPhyPort[mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + } + + if ((MGCP_CMD_RQNT != cmd) && (MGCP_CMD_NTFY != cmd) && (MGCP_CMD_AUEP != cmd) && (MGCP_CMD_RSIP != cmd)) + { + localConnectIndex = mgcChnl[localChnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]; + + if (localConnectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_create_para: localConnectIndex out of range!\n\r"); + return -1; + } + } + + switch (cmd) + { + case MGCP_CMD_CRCX: + mgc_create_para_crcx(type, port, localConnectIndex); + break; + case MGCP_CMD_MDCX: + remChnl = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].remChnl; + if (MGC_MG_TYPE_INTERNAL != mgcMgInfo[remChnl.mgNo].mgAttr.mgType) + remoteChnlIndex = mgcPhyPort[mgcMgInfo[remChnl.mgNo].portIndex[remChnl.portNo]].chnlStartIndex + remChnl.chlNo; + else + remoteChnlIndex = mgcMgInfo[remChnl.mgNo].chnlStartIndex + remChnl.chlNo; + + remoteConnectIndex = mgcChnl[remoteChnlIndex].connectIndex[remChnl.connectNo]; + if (mgcConnectInfo[localConnectIndex].mediaAttr.conMode >= MGCP_CON_MODE_SENDONLY) + { + if (remoteConnectIndex >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_create_para: remoteConnectIndex out of range!\n\r"); + return -1; + } + } + + mgc_create_para_mdcx(type, port, localChnlIndex, remoteChnlIndex, localConnectIndex, remoteConnectIndex); + break; + case MGCP_CMD_DLCX: + mgc_create_para_dlcx(type, port, localChnlIndex, localConnectIndex); + break; + case MGCP_CMD_RQNT: + mgc_create_para_rqnt(type, port, localChnlIndex); + break; + case MGCP_CMD_AUEP: + mgc_create_para_auep(type, port, localChnlIndex); + break; + } + + return 0; +} + + +int mgc_update_connect_media_by_step(WORD port, BYTE savPort, CHNL mgcfChnl, MGCF_OPER_STEP *currOperStep) +{ + WORD portIndex, chnlIndex; + WORD connectIndex; + PORT_INFO *portInfo; + + portInfo = &mgcPort[port]; + + if ((MGC_MG_TYPE_ANN == mgcMgInfo[mgcfChnl.mgNo].mgAttr.mgType) + || (MGC_MG_TYPE_INTERNAL == mgcMgInfo[mgcfChnl.mgNo].mgAttr.mgType)) + { + chnlIndex = mgcMgInfo[mgcfChnl.mgNo].chnlStartIndex + mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[mgcfChnl.mgNo].portIndex[mgcfChnl.portNo]; + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + mgcfChnl.chlNo; + } + + if (savPort == MGC_CHNL_CLEAR_PORT) + { + if (portInfo->mngCmd == MGC_MNG_CMD_OVERWRITE) + { + portInfo->mngCmd = MGC_MNG_CMD_IDLE; + } + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_AUEP) && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RQNT) + && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RSIP)) + { + connectIndex = mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo]; + mgcConnectInfo[connectIndex].port = 0xFFFF; + mgcChnl[chnlIndex].port = 0xFFFF; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd == MGCP_CMD_DLCX) + && (0 == (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag & 0x01))) + { + mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo] = 0xFFFF; + } + } + else + { + mgcChnl[chnlIndex].port = 0xFFFF; + } + return 0; + } + else + { + if ((currOperStep->cmd == MGCP_CMD_AUEP) || (currOperStep->cmd == MGCP_CMD_RQNT) || (currOperStep->cmd == MGCP_CMD_RSIP)) + { + mgcChnl[chnlIndex].port = port; + } + else + { + connectIndex = mgcChnl[chnlIndex].connectIndex[mgcfChnl.connectNo]; + + mgcConnectInfo[connectIndex].port = port; + mgcChnl[chnlIndex].port = port; + + mgcConnectInfo[connectIndex].mediaAttr.ptime = currOperStep->media.ptime; + mgcConnectInfo[connectIndex].mediaAttr.conMode = currOperStep->media.conMode; + mgcConnectInfo[connectIndex].mediaAttr.vocoderType = currOperStep->media.vocoderType.codec[0]; + mgcConnectInfo[connectIndex].mediaAttr.pkgSignal = currOperStep->pkgSignal; + } + } + + mgcChnl[chnlIndex].comMediaAttr.pkgSignal = currOperStep->pkgSignal; + + return 0; +} + +BYTE mgc_mgcf_request(WORD port, BYTE *clrFlag, BYTE *Insert) +{ + PORT_INFO *portInfo; + MG_ATTR *mgAttr; + BYTE sapIndex; + WORD cmd, res; + int llPort; + WORD portIndex = 0xFFFF; + WORD chnlIndex = 0xFFFF; + char tmpStr[128]; + int i; + WORD connectIndex = 0xFFFF; + BYTE toneNo; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return 0; + }//add by Francis + + portInfo = &mgcPort[port]; + mgAttr = &mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr; + + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) + && (portInfo->mgcfChnl.chlNo < MGC_MAX_NUM_OF_CHNL)) + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + *clrFlag = 0; + + if ((chnlIndex >= MGC_MAX_NUM_OF_CHNL) || (portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + return 2; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_AUEP) + && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RQNT) + && (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd != MGCP_CMD_RSIP)) + { + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].chnlConnectIndex != portInfo->mgcfChnl.connectNo) + || ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON)) + { +// *clrFlag = 1; + return 2; + } + } + + if (portInfo->mgcfOperStepsNum >= MGC_MAX_OPER_STEPS_NUM) + { + mgc_log_err("mgc_mgcf_request: OperStepsNum out of range!\n\r"); + *clrFlag = 1; + return 2; + } + + switch (portInfo->mgcfState2) + { + case 0: + cmd = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd; + + if (cmd != MGCP_CMD_AUEP) + { + if (chnlIndex < MGC_MAX_NUM_OF_CHNL) + { + if (((cmd != MGCP_CMD_RQNT) && (cmd != MGCP_CMD_RSIP) && (mgcConnectInfo[connectIndex].port < MGC_MAX_NUM_OF_PORT)) + || (((cmd == MGCP_CMD_RQNT) || (cmd == MGCP_CMD_RSIP)) && (mgcChnl[chnlIndex].port < MGC_MAX_NUM_OF_PORT))) + { + if (portInfo->mgcfTimer == 0) + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + else if (--portInfo->mgcfTimer == 0) + { + *clrFlag = 1;// + return 2; + } + return 0; + } + else if (cmd == MGCP_CMD_CRCX) + { + if (mgcConnectInfo[connectIndex].status == MGC_CONNECT_STATUS_CREATED) + { + *clrFlag = 0;// + return 1; + } + else + portInfo->mgcfTimer = 0; + } + + mgc_update_connect_media_by_step(port, MGC_CHNL_SAVE_PORT, mgcPort[port].mgcfChnl, &mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex]); + } + } + + mgc_create_para(MGCP_COMMAND, port, mgAttr, cmd); + + if ((llPort = MGCP_req(mgcMgcpSapIndex, cmd, port, &mgcMgcpPara)) < 0) + { + sprintf(tmpStr, "mgc_mgcf_request: MGCP_req failed, cmd: %d, usrPort: %d, port = %d\n\r", cmd, portInfo->usrPort, port); + mgc_log_err(tmpStr); + + if (cmd != MGCP_CMD_AUEP) + { + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, MGCP_RET_CODE_TRANS_TIME_OUT); + *clrFlag = 1; + } + else // AUEP + { + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + *clrFlag = 0; + } + return 2; + } + + sprintf(tmpStr, "mgc_mgcf_request: send mgcp command: %d, port = %d, llPort = %d, OperStepIndex = %d\n\r", cmd, port, llPort, portInfo->mgcfOperStepIndex); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + //if (cmd == MGCP_CMD_CRCX) + //mgcChnl[chnlIndex].status = MGC_CHNL_STATUS_CREATING; + + portInfo->llPort = llPort; + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + portInfo->mgcfState2 = 1; + break; + case 1: + if (portInfo->llCmd != 0) + { + res = portInfo->llCmd; + portInfo->llCmd = 0; + + if ((res >= 100) && (res < 200)) + return 0; + + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + cmd = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd; + + sprintf(tmpStr, "mgc_mgcf_request: got response: %d, port = %d, usrPort = %d\n\r", res, port, portInfo->usrPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if ((res == 200) || + ((res == 250) && (cmd == MGCP_CMD_DLCX))) + { + if (cmd == MGCP_CMD_AUEP) + { // AUEP + mgcMgInfo[portInfo->mgcfChnl.mgNo].stLast = 1; + + if (mgc_is_non_virtual_mg(mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr.mgType))//revise by Francis 0822 + { + for (i = 0; i < MGC_MAX_PHY_PORT_PER_MG; i++) + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[i]; + if (portIndex != 0xFFFF) + { + mgcPhyPort[portIndex].stLast = 1; + } + } + } + + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + *clrFlag = 0; + return 2; + } + else + { + if (cmd == MGCP_CMD_CRCX) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum++; + + if ((portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex-1].flag & 0x01) == 1) + { + mgcConnectInfo[connectIndex].assigned = 1; + } + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + + if (cmd == MGCP_CMD_DLCX) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + if ((portInfo->mgcfOperStepIndex + 1) >= portInfo->mgcfOperStepsNum) + { + if (mgcSap[sapIndex].mgc_cnf == NULL) + { + *clrFlag = 1;// + return 2; + } + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, 0); + + if (0 == portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay) + *clrFlag = 1;// + + return 1; + } + } + } + else if ((MGCP_CMD_CRCX == cmd) && (502 == res)) + { + for (i = portInfo->mgcfOperStepsNum; i > portInfo->mgcfOperStepIndex; i--) + { + portInfo->mgcfOperSteps[i] = portInfo->mgcfOperSteps[i-1]; + } + + + portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].cmd = MGCP_CMD_DLCX; + portInfo->mgcfOperStepsNum = portInfo->mgcfOperStepsNum + 1; + + portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].flag |= 0x01; + portInfo->mgcfState2 = 0; + *Insert = 1; + *clrFlag = 1; + return 1; + }//add by Franics 0823 + else if (cmd != MGCP_CMD_AUEP) + { + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, cmd); + + mgc_connect_init(connectIndex); + *clrFlag = 1; + return 2; + } + else + { // AUEP + *clrFlag = 0; + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + return 2; + } + + if (portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay == 0) + { + portInfo->mgcfState2 = 0; + *clrFlag = 1; + return 1; + } + else + { + portInfo->mgcfTimer = portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].delay; + portInfo->mgcfState2 = 2; + } + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + sprintf(tmpStr, "mgc_mgcf_request: timeout, port = %d, usrPort = %d\n\r", port, portInfo->usrPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if ((cmd != MGCP_CMD_AUEP) && (MGCP_CMD_RQNT != cmd) && (MGCP_CMD_RSIP != cmd)) + { +// if (cmd == MGCP_CMD_DLCX) +// { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; +// } + + if (mgcSap[sapIndex].mgc_cnf != NULL) + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_FAILURE, MGCP_RET_CODE_TRANS_TIME_OUT); + *clrFlag = 1; + } + else // AUEP + { + *clrFlag = 0; + mgcChnl[chnlIndex].auepSt = MGC_CHNL_AUEP_IDLE; + } + return 2; + } + } + break; + case 2: + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + if (portInfo->mngCmd != MGC_MNG_CMD_IDLE) + { + if (portInfo->mngCmd == MGC_MNG_CMD_OVERWRITE) + { + if ((0 != portInfo->mgcfOperSteps[portInfo->mgcfOperStepIndex].pkgSignal) + || (portInfo->mgcfOperId = MGC_OPER_ID_CONNECT_TONE) + || (portInfo->mgcfOperId = MGC_OPER_ID_CONNECT_AAS)) + { + portInfo->mgcfState2 = 0; + + *clrFlag = 1;// + + return 1; + } + else + { + *clrFlag = 1;// + return 2; + } + } + else if (portInfo->mngCmd == MGC_MNG_CMD_CLEAR_AFTER_OPER) + { + if ((MGC_MG_TYPE_ANN == mgAttr->mgType) + || (MGC_MG_TYPE_INTERNAL == mgAttr->mgType)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + mgcChnl[chnlIndex].connectNum--; + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + + if (mgcSap[sapIndex].mgc_cnf != NULL) + { + if (MGC_OPER_ID_CONNECT_AAS == portInfo->mgcfOperId) + { + toneNo = (portInfo->mgcfChnl.chlNo%10) + 7; + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, toneNo); + } + else + { + mgcSap[sapIndex].mgc_cnf(portInfo->usrPort, port, portInfo->mgcfOperId, MGC_OPER_SUCCESS, 0); + } + } + + *clrFlag = 1;// + return 2; + } + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + *clrFlag = 1;// + + portInfo->mgcfState2 = 0; + + return 1; + } + } + break; + } + + return 0; +} + +BYTE mgc_mgcf_indication(WORD port) +{ + PORT_INFO *portInfo; + MG_ATTR *mgAttr; + BYTE sapIndex; + WORD portIndex; + WORD chnlIndex; + WORD cmd, res; + char tmpStr[128]; + int connectIndex; + + if (port >= MGC_MAX_NUM_OF_PORT) + { + return 0; + }//add by Francis + + portInfo = &mgcPort[port]; + mgAttr = &mgcMgInfo[portInfo->mgcfChnl.mgNo].mgAttr; + + if ((mgAttr->mgType == MGC_MG_TYPE_ANN) + || (mgAttr->mgType == MGC_MG_TYPE_INTERNAL)) + { + chnlIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + else + { + portIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].portIndex[portInfo->mgcfChnl.portNo]; + + if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT) + { + mgc_log_err("mgc_mgcf_indication: invalid portIndex!\n\r"); + return -1; + } + + chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + portInfo->mgcfChnl.chlNo; + } + + if (((portInfo->llCmd != MGCP_CMD_RSIP) && (chnlIndex >= MGC_MAX_NUM_OF_CHNL)) || (portInfo->mgcfChnl.connectNo >= MGC_MAX_NUM_OF_CHNL_CON)) + return -1; + + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)) + { + if ((connectIndex = mgcChnl[chnlIndex].connectIndex[portInfo->mgcfChnl.connectNo]) >= MGC_MAX_NUM_OF_CON) + { + mgc_log_err("mgc_mgcf_indication: invalid connectIndex!\n\r"); + return -1; + } + } + + switch (portInfo->mgcfState2) + { + case 0: + cmd = portInfo->llCmd; + + if (MGC_MG_TYPE_ANN == mgAttr->mgType) + { +// sapIndex = mgcMgInfo[portInfo->mgcfChnl.mgNo].sapIndex; + sapIndex = mgcChnl[chnlIndex].sapIndex; + } + else + { + sapIndex = mgcPhyPort[portIndex].sapIndex; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp indication: %d, port = %d, mgNo: %d, portNo: %d, chlNo: %d\n\r", + cmd, port, portInfo->mgcfChnl.mgNo, portInfo->mgcfChnl.portNo, portInfo->mgcfChnl.chlNo); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + if (mgcSap[sapIndex].mgc_ind == NULL) + { + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)) + { + mgcConnectInfo[connectIndex].assigned = 0; + } + + return 1; + } + + if ((cmd != MGCP_CMD_CRCX) && (portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (cmd != MGCP_CMD_RSIP) && (mgcSap[sapIndex].usrType == MGC_USER_TYPE_MG)) + { + portInfo->usrPort = ((strtoll(mgcConnectInfo[connectIndex].mediaAttr.conId, NULL, 16))>>32) & 0xFFFF ; + } + + if ((cmd == MGCP_CMD_RSIP) || (cmd == MGCP_CMD_AUEP)) + { + if (mgcSap[sapIndex].mgc_ind(portInfo->mgcfChnl, cmd, &portInfo->usrPort, port, NULL) < 0) + return 1; + } + else if ((MGC_USER_TYPE_MGC == mgcMgInfo[portInfo->mgcfChnl.mgNo].usrType) + && ((MGCP_CMD_CRCX == cmd) || (MGCP_CMD_MDCX == cmd))) + { + mgc_log_err("mgc_mgcf_indication: invalid command!\n\r"); + return -1; + } + else if (mgcSap[sapIndex].mgc_ind(portInfo->mgcfChnl, cmd, &portInfo->usrPort, port, &mgcConnectInfo[connectIndex].mediaAttr) < 0) + { + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)) + { + mgcConnectInfo[connectIndex].assigned = 0; + } + + return 1; + } + + portInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + portInfo->mgcfState2 = 1; + break; + case 1: + if (portInfo->usrCmd != 0) + { + res = portInfo->usrCmd; + portInfo->usrCmd = 0; + + mgc_create_para(MGCP_RESPONSE, port, mgAttr, portInfo->llCmd); + MGCP_rsp(mgcMgcpSapIndex, portInfo->llCmd, port, portInfo->llPort, res, &mgcMgcpPara); + + if (MGCP_CMD_CRCX == portInfo->llCmd) + { + if (200 == res) + { + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_CREATED; + } + else + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + } + else if (MGCP_CMD_DLCX == portInfo->llCmd) + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp response: %d, port = %d, llPort = %d\n\r", res, port, portInfo->llPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 1; + } + else if (portInfo->mgcfTimer > 0) + { + if (--portInfo->mgcfTimer == 0) + { + sprintf(tmpStr, "mgc_mgcf_indication: timeout, port = %d\n\r", port); + mgc_log_err(tmpStr); + + MGCP_rsp(mgcMgcpSapIndex, portInfo->llCmd, port, portInfo->llPort, MGCP_RET_CODE_TRANS_TIME_OUT, &mgcMgcpPara); + + if ((portInfo->llCmd != MGCP_CMD_RQNT) && (portInfo->llCmd != MGCP_CMD_AUEP) + && (portInfo->llCmd != MGCP_CMD_RSIP)) + { + mgcConnectInfo[connectIndex].assigned = 0; + mgcConnectInfo[connectIndex].status = MGC_CONNECT_STATUS_IDLE; + } + + sprintf(tmpStr, "mgc_mgcf_indication: send mgcp response: %d, port = %d, llPort = %d\n\r", MGCP_RET_CODE_TRANS_TIME_OUT, port, portInfo->llPort); + mgc_log_procedure(portInfo->mgcfChnl.mgNo, portIndex, chnlIndex, tmpStr); + + return 1; + } + } + break; + } + + return 0; +} + +void mgc_fsm(WORD port) +{ + BYTE clrFlag; + BYTE Insert = 0; + + switch (mgcPort[port].mgcfState) + { + case MGC_MGCF_STATE_REQUEST: + if (0 == mgcPort[port].mgcfOperStepIndex) + mgcPort[port].mgcfChnl = mgcPort[port].mgcfOperSteps[0].localChnl; + + switch (mgc_mgcf_request(port, &clrFlag, &Insert)) + { + case 0: + break; + case 1: + if (clrFlag == 1) + mgc_update_connect_media_by_step(port, MGC_CHNL_CLEAR_PORT, mgcPort[port].mgcfChnl, NULL); + + if (++mgcPort[port].mgcfOperStepIndex >= mgcPort[port].mgcfOperStepsNum) + { + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + } + else + { + if (1 == Insert) + { + mgcPort[port].mgcfOperStepIndex--; + Insert = 0; + } + + mgcPort[port].mgcfChnl = mgcPort[port].mgcfOperSteps[mgcPort[port].mgcfOperStepIndex].localChnl; + mgc_fsm(port); + } + break; + default: + if (clrFlag == 1) + mgc_update_connect_media_by_step(port, MGC_CHNL_CLEAR_PORT, mgcPort[port].mgcfChnl, NULL); + + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + break; + } + break; + case MGC_MGCF_STATE_INDICATION: + switch (mgc_mgcf_indication(port)) + { + case 0: + break; + default: + mgcPort[port].mgcfState = MGC_MGCF_STATE_INIT; + break; + } + break; + case MGC_MGCF_STATE_INIT: + mgc_port_init(port); + break; + } +} diff --git a/omc/plat/mgc/src/mgc_sess_ctl.c b/omc/plat/mgc/src/mgc_sess_ctl.c new file mode 100644 index 0000000..ba798cd --- /dev/null +++ b/omc/plat/mgc/src/mgc_sess_ctl.c @@ -0,0 +1,199 @@ +#include "./include/mgc_sess_ctl.h" + + +MGC_SESS_REC mgcSess[MGC_SESS_RECORD]; + +void mgc_sess_rec_init(MGC_SESS_REC *pSess , int id) +{ + if(pSess == NULL) + return; + + memset(pSess , 0 , sizeof(MGC_SESS_REC)); + pSess->status = MGC_SESS_STATUS_IDLE; + pSess->id = id; + return; +} + +void mgc_sess_init(void) +{ + MGC_SESS_REC *pSess; + int i; + + for(i=0 ; istatus = status; +} + +MGC_SESS_STATUS mgc_sess_get_status(MGC_SESS_REC *pSess) +{ + if(pSess == NULL) + return MGC_SESS_STATUS_UNDEF; + + return pSess->status; +} + + +MGC_SESS_REC *mgc_sess_get_unused(void) +{ + int i; + MGC_SESS_REC *pSess; + + for(i=0 ; ichnl , chnl) == FALSE) + continue; + + return pSess; + } + + return NULL; +} + + +BOOL mgc_sess_rec_chnl(MGC_SESS_REC *pSess ,CHNL chnl) +{ + if(pSess == NULL) + return FALSE; + + memcpy(&pSess->chnl , &chnl , sizeof(CHNL)); + mgc_sess_set_status(pSess,MGC_SESS_STATUS_USED); + return TRUE; +} + +BOOL mgc_sess_rec_org_and_dst_chnl(CHNL orgChnl , CHNL destChnl) +{ + MGC_SESS_REC *pOrgSess, *pDestSess; + + pOrgSess = mgc_sess_is_already_rec(orgChnl); + pDestSess = mgc_sess_is_already_rec(destChnl); + + if(pOrgSess == NULL) + { + pOrgSess = mgc_sess_get_unused(); + if(pOrgSess == NULL) + return FALSE; + } + + mgc_sess_rec_chnl(pOrgSess, orgChnl); + + if(pDestSess == NULL) + { + pDestSess = mgc_sess_get_unused(); + if(pDestSess == NULL) + return FALSE; + } + + mgc_sess_rec_chnl(pDestSess, destChnl); + return TRUE; +} + + +BOOL mgc_sess_is_media_info_same(MGC_SDP_TAG *pSdpTag , PUB_SDP_MSG *pSdp) +{ + if((pSdpTag == NULL)||(pSdp == NULL)) + return FALSE; + + if(pSdpTag->m.m.port != pSdp->medias.medias[0].m.port) + return FALSE; + + if(strcmp(pSdpTag->c.addr , pSdp->c.addr) != 0) + return FALSE; + + if(pSdpTag->m.m.payloads[0] != pSdp->medias.medias[0].m.payloads[0]) + return FALSE; + + return TRUE; +} + + +BOOL mgc_sess_is_chnl_need_update(CHNL chnl, MGCP_PARA *pPara) +{ + PUB_SDP_MSG *pSdp; + MGC_SDP_TAG *pSdpTag; + MGC_SESS_REC *pSess; + + pSess = mgc_sess_is_already_rec(chnl); + + if((pSess == NULL)||(pPara == NULL)) + return TRUE; + + pSdp = &pPara->sdp; + pSdpTag = &pSess->sdpTag; + + + if(pSdpTag->mode!= pPara->m.mode) + { + pSdpTag->mode = pPara->m.mode; + memcpy(&pSdpTag->c, &pSdp->c , sizeof(PUB_SDP_C)); + memcpy(&pSdpTag->m, &(pSdp->medias.medias[0]) , sizeof(PUB_SDP_MEDIA)); + return TRUE; +} + + if((pPara->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP) + return TRUE; + + if(mgc_sess_is_media_info_same(&pSess->sdpTag , &(pPara->sdp)) == TRUE) +{ + return FALSE; + } + + pSdpTag->mode = pPara->m.mode; + memcpy(&pSdpTag->c, &pSdp->c , sizeof(PUB_SDP_C)); + memcpy(&pSdpTag->m, &(pSdp->medias.medias[0]) , sizeof(PUB_SDP_MEDIA)); + + return TRUE; + } + + diff --git a/omc/plat/mgc_v2/.copyarea.db b/omc/plat/mgc_v2/.copyarea.db new file mode 100644 index 0000000..463cedb --- /dev/null +++ b/omc/plat/mgc_v2/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2 +2 +5 +3:doc|2|0|0|0|8290c245a0da11dd9cdb001c23e19543|0 +2:ut|2|0|0|0|9a60c5fda0d911dd9cdb001c23e19543|0 +3:src|2|0|0|0|a76f9fe5aa3711dd84a8001c23e19543|0 +8:Makefile|1|11d70a499b3|b2f|913dc01d|5a6593f5a19211dd8868001c23e19543|0 +3:lib|2|0|0|0|8320c261a0da11dd9cdb001c23e19543|0 diff --git a/omc/plat/mgc_v2/Makefile b/omc/plat/mgc_v2/Makefile new file mode 100644 index 0000000..09b2d11 --- /dev/null +++ b/omc/plat/mgc_v2/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = mgc_v2 +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../app + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/mgc_v2/lib/libmgc_v2.a b/omc/plat/mgc_v2/lib/libmgc_v2.a new file mode 100644 index 0000000..761a070 Binary files /dev/null and b/omc/plat/mgc_v2/lib/libmgc_v2.a differ diff --git a/omc/plat/mgc_v2/obj/mgc.o b/omc/plat/mgc_v2/obj/mgc.o new file mode 100644 index 0000000..9be3d90 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_8ecp.o b/omc/plat/mgc_v2/obj/mgc_8ecp.o new file mode 100644 index 0000000..a41da27 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_8ecp.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_chnl_info.o b/omc/plat/mgc_v2/obj/mgc_chnl_info.o new file mode 100644 index 0000000..a74d181 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_chnl_info.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_conn_info.o b/omc/plat/mgc_v2/obj/mgc_conn_info.o new file mode 100644 index 0000000..00ce05b Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_conn_info.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_ctl.o b/omc/plat/mgc_v2/obj/mgc_ctl.o new file mode 100644 index 0000000..6122506 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_ctl.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_debug.o b/omc/plat/mgc_v2/obj/mgc_debug.o new file mode 100644 index 0000000..2640f0f Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_debug.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_internal.o b/omc/plat/mgc_v2/obj/mgc_internal.o new file mode 100644 index 0000000..d401cce Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_internal.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_mg_info.o b/omc/plat/mgc_v2/obj/mgc_mg_info.o new file mode 100644 index 0000000..1089cba Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_mg_info.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_mgcp.o b/omc/plat/mgc_v2/obj/mgc_mgcp.o new file mode 100644 index 0000000..948c5fa Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_mgcp.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_phy_port.o b/omc/plat/mgc_v2/obj/mgc_phy_port.o new file mode 100644 index 0000000..46f38d0 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_phy_port.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_port_info.o b/omc/plat/mgc_v2/obj/mgc_port_info.o new file mode 100644 index 0000000..81e536d Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_port_info.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_port_list.o b/omc/plat/mgc_v2/obj/mgc_port_list.o new file mode 100644 index 0000000..e7a73da Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_port_list.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_sur_info.o b/omc/plat/mgc_v2/obj/mgc_sur_info.o new file mode 100644 index 0000000..c508189 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_sur_info.o differ diff --git a/omc/plat/mgc_v2/obj/mgc_tandem_info.o b/omc/plat/mgc_v2/obj/mgc_tandem_info.o new file mode 100644 index 0000000..4cab926 Binary files /dev/null and b/omc/plat/mgc_v2/obj/mgc_tandem_info.o differ diff --git a/omc/plat/mgc_v2/src/.copyarea.db b/omc/plat/mgc_v2/src/.copyarea.db new file mode 100644 index 0000000..75ae9dc --- /dev/null +++ b/omc/plat/mgc_v2/src/.copyarea.db @@ -0,0 +1,19 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2\src +2 +f +5:mgc.c|1|11d8a87d5f1|1680b|b37fa4ff|ed30309baf1211dd889f001c23e19543|0 +e:mgc_phy_port.c|1|11d758d245c|39c5|19d92b91|4bef2902ac8911dd898a001c23e19543|0 +9:mgc_ctl.c|1|11d70a49a6e|c42|38290aaa|8450c2b5a0da11dd9cdb001c23e19543|0 +7:include|2|0|0|0|a8af9fefaa3711dd84a9001c23e19543|0 +b:mgc_debug.c|1|11d8a87d573|4224|9c39cdf9|ec903096af1211dd889f001c23e19543|0 +f:mgc_conn_info.c|1|11d9047aeff|d723|d2d41af|729a9c52b0a011dd8699001c23e19543|0 +a:mgc_8ecp.c|1|11d70a49cfe|1f39|7f156c80|99d0c5e1a0d911dd9cdb001c23e19543|0 +f:mgc_port_info.c|1|11d9047ae72|c952|49635542|720a9c51b0a011dd8699001c23e19543|0 +a:mgc_mgcp.c|1|11d70a49ba6|aa41|2b916ec6|faeffffeaa4511dd84f5001c23e19543|0 +e:mgc_internal.c|1|11d70a49c81|28df|b3280c26|8a769633a67d11dd9624001c23e19543|0 +e:mgc_sur_info.c|1|11d70a49aad|2fe8|6b6c0368|ab0f9ff9aa3711dd84ab001c23e19543|0 +f:mgc_chnl_info.c|1|11d70a49be5|4a2b|defdbfdd|e783fb8baade11dd8649001c23e19543|0 +d:mgc_mg_info.c|1|11d758d2548|61ff|2112d650|4dbf290eac8911dd898b001c23e19543|0 +11:mgc_tandem_info.c|1|11d9047af6c|9e18|e7265e11|1d0a0d28b08b11dd8640001c23e19543|0 +f:mgc_port_list.c|1|11d70a49d3c|177f|7247bcbd|b22fa028aa3711dd84b1001c23e19543|0 diff --git a/omc/plat/mgc_v2/src/include/.copyarea.db b/omc/plat/mgc_v2/src/include/.copyarea.db new file mode 100644 index 0000000..a4f4f86 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/.copyarea.db @@ -0,0 +1,21 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2\src\include +2 +11 +f:mgc_port_list.h|1|11d70a4a143|12c|af836631|b19fa025aa3711dd84b0001c23e19543|0 +d:mgc_mg_info.h|1|11d70a4a0c6|5b4|4897f55e|fe700014aa4611dd84f8001c23e19543|0 +5:mgc.h|1|11d70a49de8|303d|1aeae8c3|fcb0000daa4611dd84f6001c23e19543|0 +b:mgc_debug.h|1|11d758d25c5|7ef|9d383e4c|4c8f2904ac8911dd898b001c23e19543|0 +e:mgc_phy_port.h|1|11d70a49e17|39e|c68240ab|57a5023ba64111dd959c001c23e19543|0 +c:mgc_struct.h|1|11d9047afca|10d1|c79d204d|733a9c57b0a011dd8699001c23e19543|0 +f:mgc_port_info.h|1|11d758d2633|809|3d02b243|4d1f2909ac8911dd898b001c23e19543|0 +e:mgc_sur_info.h|1|11d70a49f8e|312|630c0801|af2fa013aa3711dd84ad001c23e19543|0 +f:mgc_chnl_info.h|1|11d70a4a114|50e|4aa3b7f4|e953fb97aade11dd864a001c23e19543|0 +e:mgc_internal.h|1|11d70a49ef2|24d|ecaab846|9040c491a0da11dd9cdb001c23e19543|0 +a:mgc_8ecp.h|1|11d70a4a059|26b|d354ca86|95a0c555a0d911dd9cdb001c23e19543|0 +9:mgc_pub.h|1|11d70a49e56|94|80012e65|8e70c43da0da11dd9cdb001c23e19543|0 +a:mgc_mgcp.h|1|11d70a49fcc|89f|13d2e268|e823fb8daade11dd864a001c23e19543|0 +11:mgc_tandem_info.h|1|11d70a49eb3|7f6|6239f17|8fa0c475a0da11dd9cdb001c23e19543|0 +f:mgc_conn_info.h|1|11d70a4a01b|f77|dac22645|e8b3fb92aade11dd864a001c23e19543|0 +a:mgc_snmp.h|1|11d70a49f5f|11f|912c48d5|9210c4c9a0da11dd9cdb001c23e19543|0 +9:mgc_ctl.h|1|11d70a49ffb|19a|f731901d|9470c51da0d911dd9cdb001c23e19543|0 diff --git a/omc/plat/mgc_v2/src/include/mgc.h b/omc/plat/mgc_v2/src/include/mgc.h new file mode 100644 index 0000000..78aa079 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc.h @@ -0,0 +1,449 @@ +#ifndef _MGC_H +#define _MGC_H + +#define MGC_MAX_NUM_OF_SAP 5 +#define MGC_MAX_USER_NAME_LEN 32 +#define MGC_MAX_DOMAIN_LEN 64 + +#define MGC_MAX_PHY_PORT_PER_MG 32 +#define MGC_MAX_CHNL_NUM_PER_PHY 1024 +#define MGC_MAX_NUM_OF_CHNL_CON 512 +#define MGC_MAX_NUM_OF_CON 8192 + +#define MGC_MAX_OPER_STEPS_NUM 15 + + +#define MGC_MAX_NUM_OF_MG 1024 +#define MGC_MAX_NUM_OF_PHY_PORT 1024 +#define MGC_MAX_NUM_OF_CHNL 9424 +#define MGC_MAX_NUM_OF_PORT 8192 +#define MGC_MAX_NUM_OF_SESS 1024 +#define MGC_MAX_NUM_OF_RTP_PROXY_SESS 4096 + + + +#define MGC_MGCF_TIMER_50MS 5 +#define MGC_MGCF_TIMER_20MS 2 +#define MGC_MGCF_TIMER_1S 100 +#define MGC_MGCF_TIMER_10S 10 * MGC_MGCF_TIMER_1S +#define MGC_MGCF_TIMER_20S 20 * MGC_MGCF_TIMER_1S +#define MGC_MGCF_TIMER_1H 3600 * MGC_MGCF_TIMER_1S + + +#define MGC_CHNL_NUM_INTERNAL_PER_PORT 1024 +#define MGC_CHNL_NUM_AALN_PER_PORT 1 +#define MGC_CHNL_NUM_ANN_PER_TYPE 200 +#define MGC_CHNL_NUM_DS_PER_PORT 32 +#define MGC_CHNL_NUM_TANDEM_PER_TYPE 1024 +#define MGC_CHNL_NUM_SERVEILLANCE_PER_TYPE 1024 + +#define MGC_HOLD_MUSIC 7 +#define MGC_TONE_RING 8 +#define MGC_TONE_BUSY 9 +#define MGC_TONE_WARN 10 + + + +#define MGC_MGCP_MGC_PORT 2727 +#define MGC_MGCP_MG_PORT 2427 + +#define MGC_MG_NETWORK_PORT 4967 +#define MGC_MGC_NETWORK_PORT 4966 + +#define MGC_OPERA_NO_DELAY 0 +#define MGC_CONNECT_SILENT_TONE 0x01 + + +#define MGC_MAX_NUM_OF_TANDEM 4096 +#define MGC_MAX_NUM_OF_RTP_PROXY_NUM 2 + +#define MGC_MAX_NUM_OF_TANDEM_CONN (MGC_MAX_NUM_OF_TANDEM*2) +#define MGC_MAX_NUM_OF_TANDEM_CHNL (MGC_MAX_NUM_OF_TANDEM) +#define MGC_TANDEM_CONN_STAR_ID (MGC_MAX_NUM_OF_CON) +#define MGC_TANDEM_CHNL_STAR_ID (MGC_MAX_NUM_OF_CHNL) +#define MGC_TANDEM_PHY_PORT_STAR_ID (MGC_MAX_NUM_OF_PHY_PORT) + + +#define MGC_MAX_NUM_OF_SURVEILLANCE_NUM 2 +#define MGC_MAX_NUM_OF_SURVEILLANCE_CONN 1024 +#define MGC_MAX_NUM_OF_SURVEILLANCE_NODE (MGC_MAX_NUM_OF_SURVEILLANCE_CONN) +#define MGC_MAX_NUM_OF_SURVEILLIANCE_CHNL (MGC_MAX_NUM_OF_SURVEILLANCE_CONN) +#define MGC_SURVEILLIANCE_CONN_STAR_ID (MGC_TANDEM_CONN_STAR_ID+MGC_MAX_NUM_OF_TANDEM_CONN) +#define MGC_SURVEILLIANCE_CHNL_STAR_ID (MGC_TANDEM_CHNL_STAR_ID+MGC_MAX_NUM_OF_TANDEM_CHNL) +#define MGC_SURVEILLIANCE_PHY_PORT_STAR_ID (MGC_TANDEM_PHY_PORT_STAR_ID+ MGC_MAX_NUM_OF_RTP_PROXY_NUM) + +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" +#include "../../../public/src/include/license_id.h" +#include "../../../public/src/include/pub_sdp.h" +//#include "../../../mgcp/src/include/mgcp.h" + + +typedef enum +{ + MGC_RESULT_LACK_PARA = -4, + MGC_RESULT_NO_RES = -3 , + MGC_RESULT_INPUT_ILLEGAL = -2, + MGC_RESULT_FAILURE = -1, + MGC_RESULT_OK = 0, + MGC_RESULT_8ECP_OK = 1 +}MGC_RESULT; + +typedef enum{ + MGC_DTMF_1 = 1, + MGC_DTMF_2 = 2, + MGC_DTMF_3 = 3, + MGC_DTMF_4 = 4, + MGC_DTMF_5 = 5, + MGC_DTMF_6 = 6, + MGC_DTMF_7 = 7, + MGC_DTMF_8 = 8, + MGC_DTMF_9 = 9, + MGC_DTMF_0 = 10, + MGC_DTMF_START = 11, + MGC_DTMF_POUND = 12 +}MGC_DTMF_DEF; + +typedef enum{ + MGC_PKG_L = 0, + MGC_PKG_D = 1, + MGC_PKG_G = 2 +}MGC_PKG_TYPE; + + +typedef enum +{ + MGC_USER_TYPE_UNDEF = -1, + MGC_USER_TYPE_MGC = 0, + MGC_USER_TYPE_MG = 1 +}MGC_USER_TYPE; + +typedef enum +{ + MGC_CONNECT_STATUS_UNDEF = -1, + MGC_CONNECT_STATUS_IDLE , + MGC_CONNECT_STATUS_CREATING , + MGC_CONNECT_STATUS_CREATE, + MGC_CONNECT_STATUS_CREATED +}MGC_CONNECT_STATUS; + +typedef enum +{ + MGC_CON_MODE_UNDEF = -1, + MGC_CON_MODE_INACTIVE , + MGC_CON_MODE_RECVONLY , + MGC_CON_MODE_SENDONLY , + MGC_CON_MODE_SENDRECV , + MGC_CON_MODE_OWN +}MGC_CON_MODE; + +typedef enum +{ + MGC_CHNL_INFO_STATUS_UNDEF = -1, + MGC_CHNL_INFO_STATUS_IDLE, + MGC_CHNL_INFO_STATUS_USED +}MGC_CHNL_INFO_STATUS; + + +typedef enum +{ + MGC_PHY_PORT_STATUS_UNDEF = -1, + MGC_PHY_PORT_STATUS_OFF_LINE, + MGC_PHY_PORT_STATUS_ON_LINE +}MGC_PHY_PORT_STATUS; + + +typedef enum +{ + MGC_PHY_PORT_TYPE_UNDEF = -1, + MGC_PHY_PORT_TYPE_E1 = 1 , + MGC_PHY_PORT_TYPE_T1 = 2 , + MGC_PHY_PORT_TYPE_ANALOG , + MGC_PHY_VIRTUAL_TYPE_ANN, + MGC_PHY_VIRTUAL_TYPE_INTERNAL, + MGC_PHY_VIRTUAL_TYPE_TANDEM, + MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE +}MGC_PHY_PORT_TYPE; + + +typedef enum +{ + MGC_MG_CTRL_TYPE_UNDEF = -1, + MGC_MG_CTRL_TYPE_MGCP, + MGC_MG_CTRL_TYPE_8ECP +}MGC_MG_CTRL_TYPE; + + +typedef enum +{ + MGC_MG_TYPE_UNDEF = -1, + MGC_MG_TYPE_INTERNAL = 0 , + MGC_MG_TYPE_AudioCoder = 1 , + MGC_MG_TYPE_LGC_MG = 2, + MGC_MG_TYPE_SSW_CSS = 3 , + MGC_MG_TYPE_IPBSS =4 , + MGC_MG_TYPE_ANALOG = 11 , + MGC_MG_TYPE_TANDEM = 20, + MGC_MG_TYPE_ANN =21 +}MGC_MG_TYPE; + + +typedef enum +{ + MGC_OPER_ID_UNDEF =-1, + MGC_OPER_ID_CONNECT_CHNL = 1, + MGC_OPER_ID_CONNECT_DTMF = 2, + MGC_OPER_ID_CONNECT_TONE =3, + MGC_OPER_ID_CRCX = 4, + MGC_OPER_ID_MDCX = 5, + MGC_OPER_ID_DLCX = 6, + MGC_OPER_ID_RQNT = 7, + MGC_OPER_ID_AUEP = 8, + MGC_OPER_ID_CONNECT_AAS = 9, + MGC_OPER_ID_TANDEM_CREATE, + MGC_OPER_ID_TANDEM_SET_TAR, + MGC_OPER_ID_TANDEM_UNSET_TAR, + MGC_OPER_ID_TANDEM_CLEAR, + MGC_OPER_ID_TANDEM_FORK_CHNL, + MGC_OPER_ID_CREATE_VIRTUAL_CHNL, + MGC_OPER_ID_RELEASE_VIRTUAL_CHNL, + MGC_OPER_ID_UPDATE_CHNL_MEDIA, + MGC_OPER_ID_IND +}MGC_MG_OPER_ID_TYPE; + +typedef enum +{ + MGC_CMD_UNDEF = -1, + MGC_CMD_CRCX = 1, + MGC_CMD_MDCX , + MGC_CMD_DLCX , + MGC_CMD_RQNT , + MGC_CMD_NTFY , + MGC_CMD_AUEP , + MGC_CMD_RSIP , + MGC_CMD_NOP //do noting +}MGC_CMD_TYPE; + +typedef enum +{ + MGCP_OPER_STEP_UNDEF =-1, + MGCP_OPER_STEP_REQUEST, + MGCP_OPER_STEP_REQUEST_SENT, + MGCP_OPER_STEP_RESPONSE_GET, +/*************************************************** +* up status is used for MGC , following status is used for MG +*****************************************************/ + MGCP_OPER_STEP_IND, + MGCP_OPER_STEP_IND_SENT, + MGCP_OPER_STEP_RESPONSE +}MGCP_OPER_STEP_STATUS; + + +typedef enum +{ + MGC_OPER_FAILURE = 0, + MGC_OPER_SUCCESS = 1 +}MGC_OPER_RESULT; + + +typedef enum +{ + MGC_VCTYPE_PCMA = 0 , + MGC_VCTYPE_PCMU = 1, + MGC_VCTYPE_GSM =2 , + MGC_VCTYPE_GSM_EFR = 3, + MGC_VCTYPE_AMR_12_2 = 4, + MGC_VCTYPE_G729B = 5, + MGC_VCTYPE_AMR_10_2 = 6, + MGC_VCTYPE_AMR_7_95 = 7, + MGC_VCTYPE_AMR_7_4 = 8, + MGC_VCTYPE_AMR_6_7 = 9, + MGC_VCTYPE_AMR_5_15 = 10, + MGC_VCTYPE_AMR_5_9 = 11, + MGC_VCTYPE_AMR_4_75 = 12, + MGC_VCTYPE_NUM, + MGC_VCTYPE_UNSUPPORT +}MGC_VCTYPE; + + + +typedef enum +{ + MGC_TANDEM_STATUS_UNDEF = -1, + MGC_TANDEM_STATUS_IDLE, + MGC_TANDEM_STATUS_USED +}MGC_TANDEM_STATUS; + +typedef struct _MGC_ESCCD +{ + char domain[MGC_MAX_DOMAIN_LEN]; + WORD port; +}MGC_ESCCD; + + +typedef struct _OPER_REC +{ + MGC_MG_OPER_ID_TYPE operaId; + BYTE tone; + WORD duration; + WORD times; +}OPER_REC; + + +typedef struct _CHNL +{ + WORD mgNo; // mg No. + BYTE portNo; // local physical port No. of that mg + WORD chlNo; // local channel No. of that trunk + WORD connectNo; +}CHNL; + +typedef struct _MGC_CODEC_LIST +{ + BYTE num; // num of codecs + WORD priority; // priority level, used when comparing different codec list + MGC_VCTYPE codec[MGC_VCTYPE_NUM]; // codec ID number, high priority codec first +}MGC_CODEC_LIST; + +typedef struct _MG_ATTR +{ + BYTE ptime; // ptime, in ms + MGC_MG_TYPE mgType; // non-virtual/ann + MGC_MG_CTRL_TYPE ctrlType; // 8ecp or mgcp + BYTE epDes; // endpoint description method: structured or unstructured + BYTE toneCap; // Tone generation capability + BYTE maxPorts; // maximum physical ports of this MG + WORD maxChnls; // maximum channels of this MG, only applicable to virtual MG. + DWORD ip; // IP address of the MG + char domain[MGC_MAX_DOMAIN_LEN]; // domain name of the mg + BYTE e1cardNo; + DWORD auditTimer; + + MGC_CODEC_LIST codecList; // list of codecs that the MG supports +}MG_ATTR; + + +typedef struct _PKG_EVENT +{ + BYTE pkg; // package name + BYTE event; // event name +}PKG_EVENT; + +typedef struct _PKG_SIGNAL +{ + BYTE pkg; // package name + BYTE signal; // signal name +}PKG_SIGNAL; + +typedef struct _PKG_REQ +{ + BYTE pkg; // package name + BYTE req; // request name +}PKG_REQ; + + +#define MGC_MEDIA_PARA_FLAG_EC 0x0001 +#define MGC_MEDIA_PARA_FLAG_SS 0x0002 +#define MGC_MEDIA_PARA_FLAG_VT 0x0004 +#define MGC_MEDIA_PARA_FLAG_CM 0x0008 +#define MGC_MEDIA_PARA_FLAG_PT 0x0010 + + +typedef struct _MEDIA_PARA +{ + WORD flag; // which media attribute is affected + BYTE ecDisable; // echo canceller disable or enable + BYTE ssDisable; // silence suppression disable or enable; + BYTE conMode; // connect mode + BYTE ptime; // packetization period + MGC_CODEC_LIST vocoderType; // vocoder type +}MEDIA_PARA; + + +typedef struct _MEDIA_ATTR +{ + BYTE ecDisable; // echo canceller disable or enable + BYTE ssDisable; // silence suppression disable or enable + MGC_VCTYPE vocoderType; // vocoder type + MGC_CON_MODE conMode; // connect mode + char callId[33]; // call Id + char conId[33]; // connection id + BYTE ptime; // packetization period + PKG_EVENT pkgEvent; // package + event + PKG_SIGNAL pkgSignal; // package + signal + PKG_REQ pkgReq; + PUB_SDP_MSG sdp; // media info of this channel +}MEDIA_ATTR; + + + +typedef int (*mgc_ind_callback)(CHNL chnl, MGC_CMD_TYPE cmd, WORD *usrPort, WORD mgcPort, MEDIA_ATTR *mediaAttr); +typedef int (*mgc_cnf_callback)(WORD usrPort, WORD mgcPort, MGC_MG_OPER_ID_TYPE operId, MGC_OPER_RESULT success, WORD cause); + + +typedef struct _MGC_SAP +{ + int id; //internal used , should not be modified by up layer + char usrName[MGC_MAX_USER_NAME_LEN]; // user name + MGC_USER_TYPE usrType; // user acts as a mg or mgc + + mgc_ind_callback ind_func; + mgc_cnf_callback cnf_func; +}MGC_SAP; + + +void mgc_init(DWORD systemId, DWORD localIp, DWORD peerIp); +int mgc_bind(MGC_SAP *pSap); +int mgc_unbind(MGC_SAP *pSap, BYTE sapIndex); +void mgc_timer(void); + + +int mgc_create_MG(BYTE sapIndex, MG_ATTR *pMgAttr); +int mgc_delete_MG(BYTE sapIndex, WORD mgNo); +int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *pMgAttr); + +int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, MGC_PHY_PORT_TYPE portType); +int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo); + +int mgc_crcx_chnl(WORD usrPort, CHNL chnl); +int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *pMediaPara); +int mgc_dlcx_chnl(WORD usrPort, CHNL chnl); +int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig); + + +int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag); +int mgc_connect_dtmf(WORD usrPort, CHNL chnl,CHNL dstChnl, BYTE dtmfNo); +int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl); +int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE toneNo, WORD duration, WORD times); +int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE toneNo, WORD duration); + + +int mgc_query_mg_status(WORD mgNo); +int mgc_query_port_status(WORD mgNo, BYTE portNo); +int mgc_query_channel_status(CHNL chnl); + +int mgc_create_virtual_chnl(WORD usrPort, CHNL *pChnl); +int mgc_release_virtual_chnl(WORD usrPort,CHNL chnl); + +int mgc_query_chnl_media(WORD usrPort, CHNL chnl, PUB_SDP_MSG **ppMediaInfo, BYTE *pMgPayloads, BYTE *pMgPlNum); +int mgc_update_chnl_media(WORD usrPort, CHNL chnl, PUB_SDP_MSG *pMediaInfo); +int mgc_chnl_codec_update(CHNL chnl , MGC_CODEC_LIST codecList); + + +OPER_REC *mgc_query_chnl_oper_rec(CHNL chnl); +int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum); + +int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *pMediaAttr); + +int mgc_get_idle_tandem_id(void); +int mgc_bind_chnl_to_tandem(WORD usrPort , CHNL tarChnl , DWORD tandId); +int mgc_create_tandem(WORD usrPort , DWORD tandId); +int mgc_unbind_chnl_from_tandem(WORD usrPort , CHNL tarChnl , DWORD tandId); +int mgc_delete_tandem(WORD usrPort , DWORD tandemId); +int mgc_get_tandem_near_end(DWORD tandem_id, CHNL *pChnl); +int mgc_get_tandem_far_end(DWORD tandem_id, CHNL *pChnl); +int mgc_fork_chnl(WORD usrPort , CHNL parent, CHNL *pChild); + +char *mgc_print_failure_reason(int ret); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_8ecp.h b/omc/plat/mgc_v2/src/include/mgc_8ecp.h new file mode 100644 index 0000000..d27a343 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_8ecp.h @@ -0,0 +1,17 @@ +#ifndef _MGC_8ECP_H +#define _MGC_8ECP_H +#include "mgc_struct.h" + +#define MGC_8ECP_MAX_TRK_PER_MG 8 + +int mgc_bind_8ecp_setup(void); +int mgc_8ecp_update_trk_status(BYTE mgNo, BYTE trkNo, BYTE status); +int mgc_8ecp_update_mg_status(BYTE mgNo, BYTE status); +BOOL mgc_8ecp_create(MG_INFO *pMgInfo , MG_ATTR *pMgAttr); +BOOL mgc_8ecp_delete(MG_INFO *pMgInfo); +BOOL mgc_8ecp_dlcx_chnl(CHNL chnl); +BOOL mgc_8ecp_connect_chnl(CHNL orgChnl, CHNL destChnl, BYTE flag); +BOOL mgc_8ecp_connect_dtmf(CHNL orgChnl, CHNL destChnl, BYTE digit); +BOOL mgc_8ecp_connect_tone(CHNL orgChnl, CHNL destChnl, BYTE tone , BYTE duration); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_chnl_info.h b/omc/plat/mgc_v2/src/include/mgc_chnl_info.h new file mode 100644 index 0000000..099f9f0 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_chnl_info.h @@ -0,0 +1,32 @@ +#ifndef _MGC_CHNL_INFO_H +#define _MGC_CHNL_INFO_H + +#include "mgc_struct.h" + +void mgc_chnl_info_setup(void); +void mgc_chnl_info_init(CHNL_INFO *pChnlInfo , int id); +void mgc_chnl_info_clear(CHNL_INFO *pChnlInfo); +void mgc_chnl_info_status_set(CHNL_INFO *pChnlInfo , MGC_CHNL_INFO_STATUS status); +CHNL_INFO *mgc_chnl_info_get_unused_chnl(void); +CHNL_INFO *mgc_chnl_info_get_chnl(CHNL chnl); + + +BOOL mgc_chnl_info_attach_to_phy_port(CHNL_INFO *pChnlInfo , PHY_PORT_INFO *pPhyPort); +CHNL_INFO *mgc_chnl_info_find_chnl_of_phy(PHY_PORT_INFO *pPhyPort , int chnlNo); +int mgc_chnl_info_get_chnl_no_of_phy(CHNL_INFO *pChnlInfo , PHY_PORT_INFO *pPhyPort); + + +BOOL mgc_chnl_info_attach_connect(CHNL_INFO *pChnlInfo , CONNECT_INFO *pConnect , int connNo); +BOOL mgc_chnl_info_detach_connect(CHNL_INFO *pChnlInfo , CONNECT_INFO *pConnect); + +CONNECT_INFO *mgc_chnl_info_assign_connect(CHNL_INFO *pChnlInfo , int connNo); +CONNECT_INFO *mgc_chnl_info_assign_idle_connect(CHNL_INFO *pChnlInfo); + +void mgc_chnl_info_set_mon(int id, BOOL enable); +BYTE *mgc_chnl_info_get_res_addr(void); +char *mgc_chnl_info_print_status(CHNL_INFO *pChnlInfo); +char *mgc_chnl_info_print_remote(CHNL_INFO *pChnlInfo); +char *mgc_chnl_info_print_mode(CHNL_INFO *pChnlInfo); +char *mgc_chnl_info_print_codec(CHNL_INFO *pChnlInfo); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_conn_info.h b/omc/plat/mgc_v2/src/include/mgc_conn_info.h new file mode 100644 index 0000000..3b35369 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_conn_info.h @@ -0,0 +1,71 @@ +#ifndef _MGC_CONNECT_H +#define _MGC_CONNECT_H +#include "mgc_struct.h" + +void mgc_connect_setup(void); +void mgc_connect_init(CONNECT_INFO *pConnect , int id); +CONNECT_INFO *mgc_connect_get_unused(void); +void mgc_connect_set_status(CONNECT_INFO *pConnect , MGC_CONNECT_STATUS status); +MGC_CONNECT_STATUS mgc_connect_get_status(CONNECT_INFO *pConnect); +char *mgc_connect_print_statuts(MGC_CONNECT_STATUS status); +void mgc_connect_codec_list_init(MGC_CODEC_LIST *pList); + +/*fuplayers and downlayer operation*/ +CHNL_INFO *mgc_connect_get_own_chnl_info(CONNECT_INFO *pConnect); +PHY_PORT_INFO *mgc_connect_get_own_phy_port_info(CONNECT_INFO *pConnect); +MGC_SAP *mgc_connect_get_conn_report_sap(CONNECT_INFO *pConnect); +MG_INFO *mgc_connect_get_own_mg_info(CONNECT_INFO *pConnect); +CONNECT_INFO *mgc_connect_find_connect_of_chnl(CHNL_INFO *pChnlInfo , int connNo); +BOOL mgc_connect_attach_connect_to_chnl(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo); +int mgc_connect_get_connNo_of_chnl_info(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo); + + +/*attr*/ +BOOL mgc_connect_set_conn_mode(CONNECT_INFO *pConnect , MGC_CON_MODE mode); +MGC_CON_MODE mgc_connect_get_conn_mode(CONNECT_INFO *pConnect); +void mgc_connect_attr_init(CONNECT_INFO *pConnect); +BOOL mgc_connect_attr_negotiate(CONNECT_INFO *pConnect); +BOOL mgc_connect_set_dtmf(CONNECT_INFO *pConnect , BYTE dtmfNo); +BOOL mgc_connect_set_tone(CONNECT_INFO *pConnect , BYTE toneNo); +BOOL mgc_connect_clear_tone(CONNECT_INFO *pConnect); +BOOL mgc_connect_set_req(CONNECT_INFO *pConnect , BYTE pkg , BYTE req); + + +/*operate */ +BOOL mgc_connect_attach_step_info(CONNECT_INFO *pConnect , MGCF_OPER_STEP *pOperStep); +BOOL mgc_connect_dettach_step_info(CONNECT_INFO *pConnect); +MGCF_OPER_STEP *mgc_connect_get_step_info(CONNECT_INFO *pConnect); + + +/*para create*/ +BOOL mgc_connect_auep_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_crcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_mdcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_dlcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_crcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_mdcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_rqnt_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_is_conn_need_update(CONNECT_INFO *pConnect , MGCP_PARA *pPara); + +/*para parse*/ +CONNECT_INFO *mgc_connect_assign_conn_by_para(MGCP_PARA *pPara); +CONNECT_INFO *mgc_connect_find_conn_by_conid(MGCP_PARA *pPara); +BOOL mgc_connect_crcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_mdcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_connect_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara); + +BOOL mgc_connect_add_auep(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_crcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_crcx_with_mode(CONNECT_INFO *pConnect, MGC_CON_MODE mode ,PORT_INFO *pPortInfo); +BOOL mgc_connect_add_crcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_mdcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect,PORT_INFO *pPortInfo); +BOOL mgc_connect_add_dlcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_mdcx(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect , MGC_CON_MODE mode, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_nop_with_delay(CONNECT_INFO *pConnect, DWORD delay ,PORT_INFO *pPortInfo); +BOOL mgc_connect_add_nop(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_rqnt(CONNECT_INFO *pConnect, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo); +BOOL mgc_connect_add_rqnt_with_delay(CONNECT_INFO *pConnect, WORD delay, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo); + +CONNECT_INFO *mgc_connect_dup_attr(CONNECT_INFO *pConnect); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_ctl.h b/omc/plat/mgc_v2/src/include/mgc_ctl.h new file mode 100644 index 0000000..c957628 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_ctl.h @@ -0,0 +1,16 @@ +#ifndef _MGC_CTL_H +#define _MGC_CTL_H +#include "mgc_struct.h" + + +void mgc_ctl_num_init(WORD sysId , WORD localIp , WORD peerIp); +BOOL mgc_ctl_is_mg_full(void); +void mgc_ctl_mg_add_one(void); +void mgc_ctl_mg_remove_one(void); +BOOL mgc_ctl_is_chnl_full(void); +void mgc_ctl_chnl_add_one(void); +void mgc_ctl_chnl_remove_one(void); +int mgc_ctl_set_mg_max_num(int num); +int mgc_ctl_set_chnl_max_num(int num); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_debug.h b/omc/plat/mgc_v2/src/include/mgc_debug.h new file mode 100644 index 0000000..51a295d --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_debug.h @@ -0,0 +1,67 @@ +#ifndef _MGC_DEBUG_H +#define _MGC_DEBUG_H +#include "mgc_struct.h" + +//#define MGC_TEST_DEBUG +#define MGC_MAX_LINE_LENGTH 256 + +#define MGC_MAX_ASCIIIN_LEN 4096 +#define MGC_MAX_ASCIIOUT_LEN (4096*2) +#define MGC_MAX_ASCITMP_LEN 4096 + + + +#define MGC_MONITOR_NONE 0x0000 +#define MGC_MONITOR_DEBUG 0x0001 +#define MGC_MONITOR_ERROR 0x0010 +#define MGC_MONITOR_WARN 0x0100 +#define MGC_MONITOR_INFO 0x1000 +#define MGC_MONITOR_ALL 0xffff + +#ifdef MGC_TEST_DEBUG +#define MGC_DEBUG(msg...) printf("\33[37m DEBUG: [%s:%d]",__FILE__ ,__LINE__ );printf(msg);printf("\n \33[37m") +#define MGC_WARN(msg...) printf("\33[33m WARN: [%s:%d]",__FILE__ ,__LINE__ );printf(msg);printf("\n \33[37m") +#define MGC_ERROR(msg...) printf("\33[31m ERROR: [%s:%d]",__FILE__ ,__LINE__ );printf(msg);printf("\n \33[37m") +#define MGC_INFO(msg...) printf("\33[32m INFO: [%s:%d]",__FILE__ ,__LINE__ );printf(msg);printf("\n \33[37m") +#else +void MGC_DEBUG(char *msg,...); +void MGC_WARN(char *msg,...); +void MGC_ERROR(char *msg,...); +void MGC_INFO(char *msg,...); +#endif + +/* +#define NONE "\033[m" +#define RED "\033[0;32;31m" +#define LIGHT_RED "\033[1;31m" +#define GREEN "\033[0;32;32m" +#define LIGHT_GREEN "\033[1;32m" +#define BLUE "\033[0;32;34m" +#define LIGHT_BLUE "\033[1;34m" +#define DARY_GRAY "\033[1;30m" +#define CYAN "\033[0;36m" +#define LIGHT_CYAN "\033[1;36m" +#define PURPLE "\033[0;35m" +#define LIGHT_PURPLE "\033[1;35m" +#define BROWN "\033[0;33m" +#define YELLOW "\033[1;33m" +#define LIGHT_GRAY "\033[0;37m" +#define WHITE "\033[1;37m" +*/ + + +BYTE mgcAsciInBuf[MGC_MAX_ASCIIIN_LEN]; +BYTE mgcAsciOutBuf[MGC_MAX_ASCIIOUT_LEN]; +BYTE mgcAsciTempBuf[MGC_MAX_ASCITMP_LEN]; +WORD mgcMonitorFg; + + +void mgc_mon(void); +int mgc_debug_set(void); +int mgc_asciout_proc(BYTE *out_str); +int mgc_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc); +int mgc_log_err(char *err_msg); +int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg); + + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_internal.h b/omc/plat/mgc_v2/src/include/mgc_internal.h new file mode 100644 index 0000000..9abaa4c --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_internal.h @@ -0,0 +1,32 @@ +#ifndef _MGC_INTERNAL_H +#define _MGC_INTERNAL_H + +#include "mgc_struct.h" +#define ITL_OPERA_NUM 1024 +#define ITL_OPERA_PORT_NO 127 +#define ITL_MG_INFO_PORT_NO 37 +typedef enum +{ + ITL_OPERA_STATE_UNDEF =-1 , + ITL_OPERA_STATE_IDLE, + ITL_OPERA_STATE_REQUEST , + ITL_OPERA_STATE_RESPONSE +}ITL_OPERA_STATE; + +typedef struct _ITL_OPERA_STRUCT +{ + int userPort; + ITL_OPERA_STATE status; + CHNL chnl; +}ITL_OPERA_STRUCT; + + +BOOL mgc_internal_sap_bind(void); +BOOL mgc_internal_mg_create(void); +BOOL mgc_internal_opera_auep_request(MG_INFO *pMgInfo); +int mgc_internal_get_sap_index(void); + + + + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_mg_info.h b/omc/plat/mgc_v2/src/include/mgc_mg_info.h new file mode 100644 index 0000000..b86d7a3 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_mg_info.h @@ -0,0 +1,30 @@ +#ifndef _MGC_MG_INFO_H +#define _MGC_MG_INFO_H +#include "mgc_struct.h" + + +void mgc_mg_info_setup(void); +void mgc_mg_info_init(MG_INFO *pMgInfo , int id); +void mgc_mg_info_clear(MG_INFO *pMgInfo); +int mgc_mg_info_attached_phy_port_num(MG_INFO *pMgInfo); +BOOL mgc_mg_info_attach_phy_port(MG_INFO *pMgInfo , PHY_PORT_INFO *pPhyPort, MGC_SAP *pSap); +void mgc_mg_info_dettach_phy_port(MG_INFO *pMgInfo , PHY_PORT_INFO *pPhyPort); +MG_INFO *mgc_mg_info_get_unused_mg(void); +MG_INFO *mgc_mg_info_get_index_mg(int index); +BOOL mgc_mg_info_assign_attr(MG_INFO *pMgInfo , MG_ATTR *pMgAttr); +void mgc_mg_info_update_mg_status(MG_INFO *pMgInfo , BOOL status); +MG_INFO *mgc_mg_info_check_mg_is_exsit(MG_ATTR *pMgAttr); +void mgc_mg_info_state_check(MG_INFO *pMgInfo); +CHNL_INFO *mgc_mg_info_find_idle_chnl_info(MG_INFO *pMgInfo); +BOOL mgc_mg_info_is_port_already_exist(MG_INFO *pMgInfo , int portNo , MGC_SAP *pSap); +MG_INFO *mgc_mg_info_find_available_mg(MGC_MG_TYPE mgType); +CONNECT_INFO *mgc_mg_info_assign_idle_connection(MG_INFO *pMgInfo); +CONNECT_INFO *mgc_mg_info_assign_aas_tone_connection(BYTE toneNo); +PHY_PORT_INFO *mgc_mg_info_find_port_by_name(char *name ,WORD localPort); +PHY_PORT_INFO *mgc_mg_info_find_port_by_name_and_portNo(char *name , BYTE portNo ,WORD localPort); +MG_INFO *mgc_mg_info_find_mg_by_name(char *name); +void mgc_mg_info_set_mon(int id , BOOL enable ); +BYTE *mgc_mg_info_get_res_addr(void); +void mgc_mg_info_print_info(MG_INFO *pMgInfo); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_mgcp.h b/omc/plat/mgc_v2/src/include/mgc_mgcp.h new file mode 100644 index 0000000..b517fdf --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_mgcp.h @@ -0,0 +1,41 @@ +#ifndef _MGC_MGCP_H +#define _MGC_MGCP_H +#include "mgc_struct.h" +#include "../../../mgcp/src/include/mgcp.h" + + +int mgc_mgcp_get_sap_index(void); +int mgc_mgcp_match_codec_list(MGC_CODEC_LIST *dest, MGC_CODEC_LIST *aParty, MGC_CODEC_LIST *bParty); +BOOL mgc_mgcp_check_codec_valid(MGC_VCTYPE codec); +int mgc_bind_mgcp_setup(void); +int mgc_mgcp_print_vc_num(MGC_VCTYPE vcCodec); +char *mgc_mgcp_print_vc_codec(MGC_VCTYPE vcCodec); +BYTE mgc_mgcp_convert_cmd_to_mgcp(MGC_CMD_TYPE mgcCmd); +MGC_CMD_TYPE mgc_mgcp_convert_mgcp_to_cmd(BYTE mgcpCmd); +MGC_CON_MODE mgc_mgcp_convert_to_mgc_mode(BYTE mode); +BYTE mgc_mgcp_conver_to_mgcp_mode(MGC_CON_MODE mode); +char *mgc_mgcp_print_mgc_mode(MGC_CON_MODE mode); +char *mgc_mgcp_print_ip(DWORD addr); + +BOOL mgc_mgcp_create_connect_dest_ip(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_port(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_req_start_line(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_con_mode(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_con_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_call_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_local_opt(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_pkg_sig(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_pkg_req(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_sdp(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_create_connect_resp_start_line(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_response_msg(CONNECT_INFO *pConnect , MGCP_PARA *pPara, int retCode); + + +BOOL mgc_mgcp_parse_connect_sdp(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_parse_connect_pkg_sig(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_parse_connect_pkg_event(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_parse_connect_call_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_parse_connect_mode(CONNECT_INFO *pConnect , MGCP_PARA *pPara); +BOOL mgc_mgcp_parse_connect_local_opt(CONNECT_INFO *pConnect , MGCP_PARA *pPara); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_phy_port.h b/omc/plat/mgc_v2/src/include/mgc_phy_port.h new file mode 100644 index 0000000..ff7b547 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_phy_port.h @@ -0,0 +1,24 @@ +#ifndef _MGC_PHY_PORT_H +#define _MGC_PHY_PORT_H +#include "mgc_struct.h" + + +void mgc_phy_port_setup(void); +void mgc_phy_port_init(PHY_PORT_INFO *pPhyPort , int id); +void mgc_phy_port_clear(PHY_PORT_INFO *pPhyPort); +PHY_PORT_INFO *mgc_phy_port_get_unused_phy(void); +PHY_PORT_INFO *mgc_phy_port_find_port_of_mg(MG_INFO *pMgInfo , int portNo); +PHY_PORT_INFO *mgc_phy_port_find_port_of_mg_by_index(MG_INFO *pMgInfo , int index); +void mgc_phy_port_set_chnl_num(PHY_PORT_INFO *pPhyPort , MGC_PHY_PORT_TYPE portType); +BOOL mgc_phy_port_attach_chnl(PHY_PORT_INFO *pPhyPort); +void mgc_phy_port_update_status(PHY_PORT_INFO *pPhyPort , BOOL status); + + +CHNL_INFO *mgc_phy_port_find_idle_chnl(PHY_PORT_INFO *pPhyPort); +CONNECT_INFO *mgc_phy_port_assign_idle_connection(PHY_PORT_INFO *pPhyPort); +void mgc_phy_port_set_mon(int id, BOOL enalbe); +BYTE *mgc_phy_port_get_res_addr(void); + +void mgc_phy_port_print(PHY_PORT_INFO *pPhyPort); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_port_info.h b/omc/plat/mgc_v2/src/include/mgc_port_info.h new file mode 100644 index 0000000..9dc6b9a --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_port_info.h @@ -0,0 +1,38 @@ +#ifndef _MGC_PORT_INFO_H +#define _MGC_PORT_INFO_H +#include "mgc_struct.h" + + +void mgc_port_info_setup(void); +void mgc_port_info_init(PORT_INFO *pPortInfo , int id); +void mgc_port_info_clear(PORT_INFO *pPortInfo); +PORT_INFO *mgc_port_info_get_unused_port(void); +void mgc_port_info_fsm(PORT_INFO *pPortInfo); +void mgc_port_info_oper_failure_report(PORT_INFO *pPortInfo , MGC_SAP *pMgcSap); +void mgc_port_info_oper_success_report(PORT_INFO *pPortInfo , MGC_SAP *pMgcSap); +PORT_INFO *mgc_port_info_find_port_by_id(int id); +PORT_INFO *mgc_port_info_get_step_port(MGCF_OPER_STEP *pOperStep); +BOOL mgc_port_info_add_opera_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo); +BOOL mgc_port_info_add_ind_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGC_CMD_TYPE cmd , int hdlPort , DWORD remoteIp); +int mgc_port_info_cnf(PORT_INFO *pPortInfo , BYTE cmd, WORD hdlPort, WORD retCode, MGCP_PARA *pPara); + + +MGCF_OPER_STEP *mgc_port_info_get_unused_oper_step(PORT_INFO *pPortInfo); +void mgc_port_info_set_step_to_start(PORT_INFO *pPortInfo); +BOOL mgc_port_info_set_step_to_next(PORT_INFO *pPortInfo); +void mgc_port_info_set_oper_id(PORT_INFO *pPortInfo , MGC_MG_OPER_ID_TYPE operId); +void mgc_port_info_set_fsm_time(PORT_INFO *pPortInfo , WORD timer); +BOOL mgc_port_info_set_oper_step(MGCF_OPER_STEP *pMgcfOperStep , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo); +BOOL mgc_port_info_oper_step_cnf(MGCF_OPER_STEP *pMgcOperStep , MGCP_PARA *pPara); + +void mgc_port_info_set_step_info(MGCF_STEP_INFO *pStepInfo , MGC_CMD_TYPE cmd , CONNECT_INFO *pPeerConn , + WORD delay, MGC_CON_MODE mode, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig , PKG_REQ *pPkgReq); + +BYTE *mgc_port_info_get_res_addr(void); +char *mgc_port_info_print_cmd(MGC_CMD_TYPE cmd); +char *mgc_port_info_print_opera_id(MGC_MG_OPER_ID_TYPE operaId); + +BOOL mgc_port_info_insert_dlcx_req(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect); +BOOL mgc_port_info_mv_step_into_new_port(PORT_INFO *pPortInfo , MGCF_OPER_STEP *pOperStep); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_port_list.h b/omc/plat/mgc_v2/src/include/mgc_port_list.h new file mode 100644 index 0000000..f5f1090 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_port_list.h @@ -0,0 +1,10 @@ +#ifndef _MGC_PORT_LIST_H +#define _MGC_PORT_LIST_H +#include "mgc_struct.h" + +void mgc_port_active_list_proc(void); +BOOL mgc_port_list_remove_from_active_list(PORT_INFO *pPortInfo); +MGC_PORT_NODE *mgc_port_list_add_to_active_list(PORT_INFO *pPortInfo); +void mgc_port_list_setup(void); + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_pub.h b/omc/plat/mgc_v2/src/include/mgc_pub.h new file mode 100644 index 0000000..1bf567b --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_pub.h @@ -0,0 +1,8 @@ +#ifndef _MGC_PUB__H +#define _MGC_PUB__H + +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" + +#endif + diff --git a/omc/plat/mgc_v2/src/include/mgc_snmp.h b/omc/plat/mgc_v2/src/include/mgc_snmp.h new file mode 100644 index 0000000..dd20f61 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_snmp.h @@ -0,0 +1,17 @@ +#ifndef _MGC_SNMP_H +#define _MGC_SNMP_H + +const BYTE MGC_AC_LINE_STATUS_IDLEN = 12; +DWORD MGC_AC_LINE_STATUS_OID[20] = +{ + 1,3,6,1,2,1,10,18,6,1,10,0 +}; + +const BYTE MGC_LGC_MG_STATUS_IDLEN = 13; + +DWORD MGC_LGC_MG_STATUS_OID[20] = +{ + 1,3,6,1,4,1,1373,2,2,30,2,1,0 +}; + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_struct.h b/omc/plat/mgc_v2/src/include/mgc_struct.h new file mode 100644 index 0000000..91a885d --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_struct.h @@ -0,0 +1,196 @@ +#ifndef _MGC_STRUCT_H +#define _MGC_STRUCT_H + +#include "mgc.h" +#include "../../../mgcp/src/include/mgcp.h" +#include "../../../8ecp/src/include/8ecp.h" + +#define MGC_PORT_LIST_EN +#define MGC_REC_PORT +typedef struct _MGCP_REC_TAG +{ + PUB_SDP_MEDIA m; + PUB_SDP_C c; + MGCP_M mode; + char esCci[32]; +}MGCP_REC_TAG; + + +typedef struct _CONNECT_INFO +{ + int id; + DWORD flag; + struct _MGCF_OPER_STEP *pOperStep; +#ifdef MGC_REC_PORT + struct _PORT_INFO *pPrePortInfo; +#endif + struct _CHNL_INFO *pChnlInfo; + MGC_CONNECT_STATUS status; + MGC_CODEC_LIST codecList; + MEDIA_ATTR mediaAttr; + OPER_REC operRec; + MGCP_REC_TAG mgcpRec; + struct _MGC_TANDEM_INFO *pTandem; +}CONNECT_INFO; + + + +typedef struct _CHNL_INFO +{ + int id; + BOOL monFlag; // monitor flag + MGC_CHNL_INFO_STATUS status; + struct _PHY_PORT_INFO *pPhyPort; //chnl's owner + WORD connectNum; //how many connection is attached + WORD maxConnectNum; //max connection num could be attached to the chnl accroding to chnl's owner + struct _CONNECT_INFO *pConnection[MGC_MAX_NUM_OF_CHNL_CON]; //Media Index +}CHNL_INFO; + + + +typedef struct _PHY_PORT_INFO +{ + int id; + int portNo; // mg local physical port No. ?? + MGC_SAP *pMgcSap; // sap index, indicating which user creates this port + BOOL monFlag; + MGC_PHY_PORT_STATUS status; // physical port status: online/offline + MGC_PHY_PORT_TYPE portType; // port type: E1/T1/analogue + struct _MG_INFO *pMgInfo; // mg No. this port resides on ?? + WORD chnlNum; // depend on mg type + struct _CHNL_INFO *pChnlInfo[MGC_MAX_CHNL_NUM_PER_PHY]; +}PHY_PORT_INFO; + + + +typedef struct _MG_INFO +{ + int id; //internal used + BOOL created; // created flag; + BOOL enable; // MG status: available/unavailable + BOOL monFlag; + MG_ATTR mgAttr; // MG attributes + + PHY_PORT_INFO *pPhyPort[MGC_MAX_PHY_PORT_PER_MG]; + DWORD requestId; // SNMP request id + DWORD auditTimer; +}MG_INFO; + + +typedef struct _MGCF_STEP_INFO +{ + struct _CONNECT_INFO *pPeerConn; + int delay; + MGC_CON_MODE mode; + MGC_CMD_TYPE cmd; + MGC_CODEC_LIST codecList; + PKG_SIGNAL pkgSig; + BOOL sigEn; + PKG_EVENT pkgEvent; + BOOL eventEn; + PKG_REQ pkgReq; + BOOL reqEn; + DWORD remoteIp; //only used for MG +}MGCF_STEP_INFO; + + +typedef struct _MGCF_OPER_STEP +{ + int id; + struct _CONNECT_INFO *pConnect; //chnl connectIndex + struct _PORT_INFO *pPortInfo; + MGCF_STEP_INFO stepInfo; + MGCP_OPER_STEP_STATUS status; + WORD hdlPort; // lower layer port + WORD llCmd; // lower layer command or response +}MGCF_OPER_STEP; + +typedef struct _PORT_INFO{ + int id; + BOOL assigned; + WORD usrPort; + WORD mgcfTimer; // mgcf timer + MGC_MG_OPER_ID_TYPE mgcfOperId; + WORD cause; //reason to tell uplayer + struct _MGCF_OPER_STEP *pMgcOperCurrent; + struct _MGCF_OPER_STEP mgcfOperSteps[MGC_MAX_OPER_STEPS_NUM]; // max 8 steps +} +PORT_INFO; + + +typedef struct _MGC_8ECP_SAP +{ + struct _8ECP_SAP sap8ecp; + int sapIndex; +}MGC_8ECP_SAP; + +typedef struct _MGC_MGCP_SAP +{ + struct _MGCP_SAP sapMgcp; + int sapIndex; +}MGC_MGCP_SAP; + +typedef struct _MGC_CTL +{ + WORD sysId; + WORD localIp; + WORD peerIp; //??? + WORD mgcMaxMgNo; + WORD mgcMaxChlNo; + WORD mgcMgCreated; + WORD mgcChlAssigned; +}MGC_CTL; + +typedef struct _MGC_INTERNAL_SAP +{ + MGC_SAP mgcSap; + int mgcSapIndex; + int mgNoITL; +}MGC_INTERNAL_SAP; + + +typedef struct _MGC_SUR_INFO_NODE +{ + int id; + struct _CONNECT_INFO *pConn; + struct _MGC_SUR_INFO_NODE *pPrior; + struct _MGC_SUR_INFO_NODE *pNext; +}MGC_SUR_INFO_NODE; + +typedef struct _MGC_SUR_INFO_LIST +{ + struct _MGC_SUR_INFO_NODE *pHead; + WORD len; +}MGC_SUR_INFO_LIST; + + + +typedef struct _MGC_TANDEM_INFO +{ + int id; + char escci[32]; + struct _MGC_SUR_INFO_LIST list; + MGC_TANDEM_STATUS status; + CONNECT_INFO *pTconn; //pointer to target + CONNECT_INFO *pTxconn; //pointer to where target conn to send + CONNECT_INFO *pRxconn; //pointer to where targe conn to recieve from + CONNECT_INFO *pAconn; // pointer to associator +}MGC_TANDEM_INFO; + +typedef struct _MGC_PORT_LIST +{ + struct _MGC_PORT_NODE *pHead; + WORD len; +}MGC_PORT_LIST; + +typedef struct _MGC_PORT_NODE +{ + int id; + struct _PORT_INFO *pPortInfo; + struct _MGC_PORT_NODE *pPrior; + struct _MGC_PORT_NODE *pNext; + struct _MGC_PORT_LIST *pList; +}MGC_PORT_NODE; + +#endif + diff --git a/omc/plat/mgc_v2/src/include/mgc_sur_info.h b/omc/plat/mgc_v2/src/include/mgc_sur_info.h new file mode 100644 index 0000000..cfd3e58 --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_sur_info.h @@ -0,0 +1,19 @@ +#ifndef _MGC_SUR_INFO_H +#define _MGC_SUR_INFO_H +#include "mgc_struct.h" + +void mgc_sur_info_list_init(MGC_SUR_INFO_LIST *pList); +BOOL mgc_sur_info_add_conn_to_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn); +BOOL mgc_sur_info_remove_conn_to_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn); +MGC_SUR_INFO_NODE *mgc_sur_info_find_conn_in_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn); +MGC_SUR_INFO_NODE *mgc_sur_info_get_list_tail(MGC_SUR_INFO_LIST *pList); +MGC_SUR_INFO_NODE *mgc_sur_info_get_list_node(MGC_SUR_INFO_LIST *pList , WORD index); + +BOOL mgc_sur_info_add_survillance_res(BYTE sapIndex, WORD mgNo); +void mgc_sur_info_setup(void); +void mgc_sur_info_clear_list(MGC_SUR_INFO_LIST *pList); + +CONNECT_INFO *mgc_sur_info_find_sur_conn_in_mg(MG_INFO *pMgInfo); + + +#endif diff --git a/omc/plat/mgc_v2/src/include/mgc_tandem_info.h b/omc/plat/mgc_v2/src/include/mgc_tandem_info.h new file mode 100644 index 0000000..f4bec8f --- /dev/null +++ b/omc/plat/mgc_v2/src/include/mgc_tandem_info.h @@ -0,0 +1,37 @@ +#ifndef _MGC_TANDEM_INFO_H +#define _MGC_TANDEM_INFO_H + +#include "mgc_struct.h" + +typedef enum +{ + MGC_TANDEM_CONN_POS_UNDEF = -1, + MGC_TANDEM_CONN_POS_TAR, + MGC_TANDEM_CONN_POS_TX, + MGC_TANDEM_CONN_POS_RX, + MGC_TANDEM_CONN_POS_AOR, + MGC_TANDEM_CONN_POS_SUR +}MGC_TANDEM_CONN_POS; + +BOOL mgc_tandem_info_unset_conn(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConnect); +BOOL mgc_tandem_info_set_conn(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConn, MGC_TANDEM_CONN_POS pos); +MGC_TANDEM_CONN_POS mgc_tandem_info_get_conn_pos(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConn); +MGC_TANDEM_INFO *mgc_tandem_info_get_tandem_by_id(DWORD id); +MGC_TANDEM_INFO *mgc_tandem_info_get_idle_tandem(void); +void mgc_tandem_info_setup(void); +BOOL mgc_tandem_info_add_tandem_res(BYTE sapIndex, WORD mgNo); +BOOL mgc_tandem_info_set_esccd_info(MGC_TANDEM_INFO *pTandem , MGCP_ESCCD rxEsccd , MGCP_ESCCD txEsccd); +BOOL mgc_tandem_info_create_tar_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_create_tandem(MGC_TANDEM_INFO *pTandem , PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_stop_tandem_send_to_tar(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_stop_tandem_send_to_aor(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +MGC_TANDEM_STATUS mgc_tandem_info_get_status(MGC_TANDEM_INFO *pTandem); +BOOL mgc_tandem_info_dettach_aor_related_tandem(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_connect(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, MGC_CON_MODE mode , PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_remove_connection_from_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_mdcx(CONNECT_INFO *pConnect , PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_add_crcx_aas(CONNECT_INFO *pAasConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_add_mdcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pAasConnect, PORT_INFO *pPortInfo); +BOOL mgc_tandem_info_clear(MGC_TANDEM_INFO *pTandem, PORT_INFO *pPortInfo); + +#endif diff --git a/omc/plat/mgc_v2/src/mgc.c b/omc/plat/mgc_v2/src/mgc.c new file mode 100644 index 0000000..0483883 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc.c @@ -0,0 +1,2633 @@ + +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* +* +* +* mgcSap <---------mgcPhyPorts --------> mgcMgInfo +* | +* | +* | +* mgcChnls <-----------mgcConnections +*/ + + +/********************************************************************************* + * + * This file contain APIs which is provided to uplayer to implement media control between sessions + * by using MGCP protocol + * + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + + +#define MGC_AAS_ITL_PORT_NO 255 + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ +#include "./include/mgc_struct.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_port_info.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_ctl.h" +#include "./include/mgc_8ecp.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_internal.h" +#include "./include/mgc_snmp.h" +#include "./include/mgc_tandem_info.h" +#include "./include/mgc_sur_info.h" +#ifdef MGC_PORT_LIST_EN +#include "./include/mgc_port_list.h" +#endif + +static MGC_SAP mgcSap[MGC_MAX_NUM_OF_SAP]; + + +/*-----------------------------------------------------------------------*/ +/* MODULE FUNCTIONS */ +/*-----------------------------------------------------------------------*/ +static int mgc_get_snmp_msg(void); + + +/*----------------------------------------------------------------------- + MGC - SAP M A N A G E R + ------------------------------------------------------------------------*/ + + +char *mgc_print_failure_reason(int ret) +{ + if(ret >= 0) + return "MGC_RESULT_OK"; + + switch(ret) + { + case MGC_RESULT_FAILURE: + return "MGC_RESULT_FAILURE"; + case MGC_RESULT_INPUT_ILLEGAL: + return "MGC_RESULT_INPUT_ILLEGAL"; + case MGC_RESULT_NO_RES: + return "MGC_RESULT_NO_RES"; + case MGC_RESULT_LACK_PARA: + return "MGC_RESULT_LACK_PARA"; + default: + break; + } + + return "MGC_RESULT_UNKNOW_REASON"; +} + + +/*************************************************************************** + * mgc_sap_init + * ------------------------------------------------------------------------ + * General: init MGC_SAP structure object , and set the id of this MGC_SAP object. + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcSap - pointer of the MGC_SAP object which want to be init + * id - the id of this MGC_SAP object should be, this id can't be set out of MGC module + ***************************************************************************/ +static void mgc_sap_init(MGC_SAP *pMgcSap , int id) +{ + if(pMgcSap == NULL) + return ; + + pMgcSap->id = id; + memset(pMgcSap->usrName , 0 , MGC_MAX_USER_NAME_LEN); + pMgcSap->usrType = MGC_USER_TYPE_UNDEF; + pMgcSap->cnf_func = NULL; + pMgcSap->ind_func = NULL; + return; +} + +static void mgc_sap_setup(void) +{ + int i; + MGC_SAP *pMgcSap = NULL; + + for(i=0 ; i= MGC_MAX_NUM_OF_SAP)) + return NULL; + + return &(mgcSap[index]); +} + + +/*************************************************************************** + * mgc_sap_get_idle_sap + * ------------------------------------------------------------------------ + * General: get an pointer of the MGC_SAP object which is not used. + * Return Value: if failed return NULL , else return a pointer. + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + * + ***************************************************************************/ +static MGC_SAP *mgc_sap_get_idle_sap(void) +{ + int i; + MGC_SAP *pSap = NULL; + + for(i=0 ; i< MGC_MAX_NUM_OF_SAP ; i++) + { + pSap = &mgcSap[i]; + if((pSap->usrType == MGC_USER_TYPE_UNDEF)&&(pSap->ind_func == NULL) && (pSap->cnf_func == NULL)) + return pSap; + } + + return NULL; +} + +/*************************************************************************** + * mgc_sap_is_already_bind + * ------------------------------------------------------------------------ + * General: check if the MGC_SAP object is already exist. + * Return Value: if not exist return NULL , else return a pointer. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pSap- the pointer + * + ***************************************************************************/ +static MGC_SAP *mgc_sap_is_already_bind(MGC_SAP *pSap) +{ + int i; + MGC_SAP *pSapTmp = NULL; + + if(pSap == NULL) + return NULL; + + for(i=0 ; iusrType == MGC_USER_TYPE_UNDEF) + continue; + + if(strcmp(pSapTmp->usrName , pSap->usrName) != 0) + continue; + + return pSapTmp; + } + + return NULL; +} + + +/*----------------------------------------------------------------------- + MGC - INTERFACE M A N A G E R + ------------------------------------------------------------------------*/ + + +/*************************************************************************** + * mgc_init + * ------------------------------------------------------------------------ + * General: init mgc module, which is used by up-layer + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: systemId - the ID of the MGC + * localIp - the IP of the MGC + * peerIp - the IP of the peer object + * + * Notice : the input arguments is not actually useful, just for keep interface unchange + ***************************************************************************/ +void mgc_init(DWORD systemId, DWORD localIp, DWORD peerIp) +{ + mgc_debug_set(); + MGC_DEBUG("MGC %ld init start!!" , systemId); + + if(mgc_bind_8ecp_setup() < 0) + return; + + if(mgc_bind_mgcp_setup() < 0) + return; + + mgc_sap_setup(); + mgc_phy_port_setup(); + mgc_mg_info_setup(); + mgc_chnl_info_setup(); + mgc_connect_setup(); + mgc_port_info_setup(); + mgc_tandem_info_setup(); + mgc_sur_info_setup(); + mgc_ctl_num_init(systemId , localIp , peerIp); + +#ifdef MGC_PORT_LIST_EN + mgc_port_list_setup(); +#endif + /*create internal mg, need to be done*/ + + if(mgc_internal_sap_bind() == FALSE) + { + MGC_ERROR("bind internal sap failed"); + return; + } + + if(mgc_internal_mg_create() == FALSE) + { + MGC_ERROR("create internal mg failed!"); + return; + } + + MGC_DEBUG("mgc module init over"); + return; +} + + +/*************************************************************************** + * mgc_bind + * ------------------------------------------------------------------------ + * General: bind up-layer user info to MGC_SAP object + * Return Value: if failed return -1 , else return the id of the MGC_SAP object. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pSap - pointer to the up-layer info + * + ***************************************************************************/ +int mgc_bind(MGC_SAP *pSap) +{ + MGC_SAP *pSapIdle = NULL; + +#ifndef MGC_TEST_ENABLE + if (wxc2_get_license(LIC_MGC) <= 0) + { + MGC_ERROR("mgc_bind: mgc module is not presented!"); + return MGC_RESULT_INPUT_ILLEGAL; + } +#endif + if(pSap == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + switch(pSap->usrType) + { + case MGC_USER_TYPE_MG: + if(pSap->ind_func == NULL) + return MGC_RESULT_LACK_PARA; + break; + case MGC_USER_TYPE_MGC: + if(pSap->cnf_func == NULL) + return MGC_RESULT_LACK_PARA; + break; + default: + return MGC_RESULT_INPUT_ILLEGAL; + } + + pSapIdle = mgc_sap_is_already_bind(pSap); + if(pSapIdle != NULL) + { + MGC_WARN("mgcSap[%d] already bind" , pSap->id); + return pSapIdle->id; + } + + pSapIdle = mgc_sap_get_idle_sap(); + if(pSapIdle == NULL) + return MGC_RESULT_NO_RES; + + sprintf(pSapIdle->usrName , "%s" , pSap->usrName); + pSapIdle->usrType = pSap->usrType; + pSapIdle->ind_func = pSap->ind_func; + pSapIdle->cnf_func = pSap->cnf_func; + + MGC_DEBUG("mgcSap[%d] %s bind !" , pSapIdle->id , pSapIdle->usrName); + return pSapIdle->id; +} + + +/*************************************************************************** + * mgc_unbind + * ------------------------------------------------------------------------ + * General: remove the up-layer info from MGC_SAP objects + * Return Value: if failed return -1 , else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: pSap - pointer to the up-layer info which want to be remove + * sapIndex - the MGC_SAP object id which is returned when use mgc_bind + ***************************************************************************/ +int mgc_unbind(MGC_SAP *pSap, BYTE sapIndex) +{ + MGC_SAP *pDestSap = NULL; + + if(pSap == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pDestSap = mgc_sap_get_index_sap(sapIndex); + if(pDestSap == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if((pSap->usrType != pDestSap->usrType)||(strcmp(pSap->usrName , pDestSap->usrName))) + { + MGC_WARN("unbind mgc sap not matched!"); + } + + MGC_DEBUG("mgcSap[%d] %s unbind !" ,pDestSap->id,pDestSap->usrName); + mgc_sap_init(pDestSap , pDestSap->id); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_misc_timer + * ------------------------------------------------------------------------ + * General: handle snmp msg and debug msg reciving + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +static void mgc_misc_timer(void) +{ + static DWORD cntT50ms; + + if(cntT50ms++ >= MGC_MGCF_TIMER_50MS) + { + cntT50ms = 0; + mgc_get_snmp_msg(); + } + + mgc_mon(); +} + +/*************************************************************************** + * mgc_timer + * ------------------------------------------------------------------------ + * General: mgc Module polling + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +void mgc_timer(void) +{ +#ifndef MGC_PORT_LIST_EN + PORT_INFO *pPortInfo = NULL; +#endif + MG_INFO *pMgInfo = NULL; + int i; + +#ifndef MGC_PORT_LIST_EN + for(i=0 ; imgType == MGC_MG_TYPE_ANN) + { + portType = MGC_PHY_VIRTUAL_TYPE_ANN; + } + else if(pMgAttr->mgType == MGC_MG_TYPE_TANDEM) + { + portType = MGC_PHY_VIRTUAL_TYPE_TANDEM; + } + + pMgInfo = mgc_mg_info_check_mg_is_exsit(pMgAttr); + if(pMgInfo != NULL) + { + /*check if the same sapIndex already create MGC_MG_TYPE_ANN*/ + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_ANN) + { + tag = FALSE; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->pMgcSap != pMgcSap) + continue; + + tag = TRUE; // the same user already create MGC_MG_TYPE_ANN + } + + if(tag == FALSE) //new user create MGC_MG_TYPE_ANN + { + pPhyPort = mgc_phy_port_get_unused_phy(); + /*only add one phyPort for rtp_proxy*/ + + if(mgc_add_port(sapIndex, pMgInfo->id, MGC_AAS_ITL_PORT_NO,portType) < 0) + { + mgc_delete_MG(sapIndex, pMgInfo->id); + return MGC_RESULT_FAILURE ; + } + } + } + + return pMgInfo->id; + } + + pMgInfo = mgc_mg_info_get_unused_mg(); + if(pMgInfo == NULL) + return MGC_RESULT_NO_RES; + + if(mgc_mg_info_assign_attr(pMgInfo ,pMgAttr) == FALSE) + { + mgc_mg_info_init(pMgInfo, pMgInfo->id); + return MGC_RESULT_FAILURE ; + } + + mgc_ctl_mg_add_one(); + + + if(pMgAttr->mgType == MGC_MG_TYPE_ANN) + { + pPhyPort = mgc_phy_port_get_unused_phy(); + /*only add one phyPort for rtp_proxy*/ + MGC_DEBUG("add phyPort[%d] to aas" , pPhyPort->id); + if(mgc_add_port(sapIndex, pMgInfo->id, MGC_AAS_ITL_PORT_NO,portType) < 0) + { + mgc_delete_MG(sapIndex, pMgInfo->id); + return MGC_RESULT_FAILURE ; + } + } + + if(pMgAttr->mgType == MGC_MG_TYPE_TANDEM) + { + if(mgc_tandem_info_add_tandem_res(sapIndex , pMgInfo->id) == FALSE) + { + mgc_delete_MG(sapIndex, pMgInfo->id); + return MGC_RESULT_FAILURE ; + } + + if(mgc_sur_info_add_survillance_res(sapIndex, pMgInfo->id) == FALSE) + { + MGC_ERROR("add survilliance res failed!"); + mgc_delete_MG(sapIndex, pMgInfo->id); + return MGC_RESULT_FAILURE ; + } + } + + MGC_DEBUG("create mg[%d] %s success" , pMgInfo->id , pMgInfo->mgAttr.domain); + return pMgInfo->id; +} + +/*************************************************************************** + * mgc_delete_MG + * ------------------------------------------------------------------------ + * General: inferace for up-layer delete mg + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: sapIndex - the id of the MGC_SAP object which is provided by mgc_bind + * mgNo - the id of which MG_INFO need to be removed + ***************************************************************************/ +int mgc_delete_MG(BYTE sapIndex, WORD mgNo) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + + if((pMgInfo == NULL)||(pMgcSap) == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->created == FALSE) + { + MGC_WARN("mg[%d] is not created, could not delete" , pMgInfo->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + switch(pMgInfo->mgAttr.ctrlType) + { + case MGC_MG_CTRL_TYPE_8ECP: + mgc_8ecp_delete(pMgInfo); + break; + case MGC_MG_CTRL_TYPE_MGCP: + break; + default: + MGC_WARN("mg[%d] unsupport ctrlType %d" , pMgInfo->id , pMgInfo->mgAttr.ctrlType); + break; + } + + mgc_mg_info_clear(pMgInfo); + MGC_DEBUG("remove mg[%d] success" , pMgInfo->id); + mgc_ctl_mg_remove_one(); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_modify_MG + * ------------------------------------------------------------------------ + * General: inferace for up-layer to modify mg + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: sapIndex - the id of the MGC_SAP object which is provided by mgc_bind + * mgNo - the id of which MG_INFO need to be modified + * pMgAttr - pointer of the new mg attribute + ***************************************************************************/ +int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *pMgAttr) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + + if((pMgInfo == NULL)||(pMgcSap) == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->created == FALSE) + { + MGC_ERROR("mg[%d] is not created, could not modify" , pMgInfo->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if(pMgInfo->mgAttr.ctrlType != pMgAttr->ctrlType) + { + MGC_ERROR("do not support different ctltype modify"); + return MGC_RESULT_INPUT_ILLEGAL; + } + + switch(pMgAttr->ctrlType) + { + case MGC_MG_CTRL_TYPE_8ECP: + mgc_8ecp_create(pMgInfo, pMgAttr); + break; + case MGC_MG_CTRL_TYPE_MGCP: + mgc_mg_info_assign_attr(pMgInfo , pMgAttr); + break; + default: + MGC_WARN("mg[%d] unsupport ctrlType %d" , pMgInfo->id , pMgInfo->mgAttr.ctrlType); + return MGC_RESULT_INPUT_ILLEGAL; + } + + MGC_DEBUG("modify mg[%d] %s success" , pMgInfo->id , pMgInfo->mgAttr.domain); + return MGC_RESULT_OK; +} + + +static char *mgc_print_user_type(MGC_USER_TYPE userType) +{ + switch(userType) + { + case MGC_USER_TYPE_MG: + return "MGC_USER_TYPE_MG"; + case MGC_USER_TYPE_MGC: + return "MGC_USER_TYPE_MGC"; + default: + return "MGC_USER_TYPE_UNDKNOWN"; + } + return "MGC_USER_TYPE_UNDKNOWN"; +} + + +/*************************************************************************** + * mgc_add_port + * ------------------------------------------------------------------------ + * General: inferace for up-layer to add phyPort + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: sapIndex - the id of the MGC_SAP object which is provided by mgc_bind + * mgNo - the id of which MG_INFO need to attach to + * portNo - the id of the phyPort in the up-layer, this is used for up-layer find phyPort in the MGC + * portType - the phyPort type to be created + ***************************************************************************/ +int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, MGC_PHY_PORT_TYPE portType) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + + if((pMgInfo == NULL)||(pMgcSap) == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->created == FALSE) + { + MGC_ERROR("mg[%d] is not created, could not add port" , pMgInfo->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if((ITL_OPERA_PORT_NO == portNo)&&(sapIndex != mgc_internal_get_sap_index())) + { + MGC_ERROR("portNo %d is internal used! " , portNo); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if(mgc_mg_info_is_port_already_exist(pMgInfo , portNo , pMgcSap) == TRUE) + return MGC_RESULT_OK; + + pPhyPort = mgc_phy_port_get_unused_phy(); + if(pPhyPort == NULL) + return MGC_RESULT_NO_RES; + + pPhyPort->portType = portType; + pPhyPort->portNo = portNo; + pPhyPort->pMgcSap = pMgcSap; + pPhyPort->pMgInfo = pMgInfo; + + switch(pMgInfo->mgAttr.ctrlType) + { + case MGC_MG_CTRL_TYPE_8ECP: + /*do nothing ?*/ + mgc_phy_port_set_chnl_num(pPhyPort , MGC_PHY_PORT_TYPE_E1); + return MGC_RESULT_8ECP_OK; + case MGC_MG_CTRL_TYPE_MGCP: + mgc_phy_port_set_chnl_num(pPhyPort , pPhyPort->portType); + break; + default: + mgc_phy_port_clear(pPhyPort); + MGC_ERROR("mgcMgInfo[%d] unsupport ctrl type %d" , pMgInfo->id , pMgInfo->mgAttr.ctrlType); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if(mgc_phy_port_attach_chnl(pPhyPort) == FALSE) + { + mgc_phy_port_clear(pPhyPort); + return MGC_RESULT_FAILURE; + } + + if(mgc_mg_info_attach_phy_port(pMgInfo , pPhyPort , pMgcSap)== FALSE) + { + mgc_phy_port_clear(pPhyPort); + return MGC_RESULT_FAILURE; + } + + if(sapIndex != mgc_internal_get_sap_index()) + { + MGC_INFO("phyPort[%d] is add to mgInfo[%d] %s , as portNo %d, userType %s" + , pPhyPort->id , pMgInfo->id , pMgInfo->mgAttr.domain, pPhyPort->portNo , mgc_print_user_type(pPhyPort->pMgcSap->usrType)); + } + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_delete_port + * ------------------------------------------------------------------------ + * General: inferace for up-layer to delete phyPort + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: sapIndex - the id of the MGC_SAP object which is provided by mgc_bind + * mgNo - the id of which MG_INFO need to attach to + * portNo - the id of the phyPort in the up-layer, this is used for up-layer find phyPort in the MGC + ***************************************************************************/ +int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + + if((pMgInfo == NULL)||(pMgcSap) == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo , portNo); + if(pPhyPort == NULL) + { + if(sapIndex != mgc_internal_get_sap_index()) + { + MGC_ERROR("mg[%d] %s do not have port[%d]" , pMgInfo->id , pMgInfo->mgAttr.domain , portNo); + } + return MGC_RESULT_INPUT_ILLEGAL; + } + + if(pPhyPort->pMgcSap != pMgcSap) + { + MGC_ERROR("Port[%d] is not belong to mgcSap[%d] %s" , pPhyPort->portNo, pMgcSap->id , pMgcSap->usrName); + return MGC_RESULT_INPUT_ILLEGAL; + } + + + if(sapIndex != mgc_internal_get_sap_index()) + { + MGC_INFO("phyPort[%d] is remove from mgInfo[%d] %s , as portNo %d, userType %s" + , pPhyPort->id , pMgInfo->id , pMgInfo->mgAttr.domain, pPhyPort->portNo , mgc_print_user_type(pPhyPort->pMgcSap->usrType)); + } + + mgc_mg_info_dettach_phy_port(pMgInfo , pPhyPort); + mgc_phy_port_clear(pPhyPort); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_auep_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to send auep + * Return Value : if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * chnl - the chnl need to send auep + ***************************************************************************/ +int mgc_auep_chnl(WORD usrPort, CHNL chnl) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if((pMgInfo == NULL)||(pChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return MGC_RESULT_8ECP_OK; + + pConnect = mgc_chnl_info_assign_connect(pChnlInfo, chnl.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + if((pPortInfo == NULL)||(pConnect == NULL)) + { + return MGC_RESULT_NO_RES; + } + + mgc_connect_add_auep(pConnect , pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_AUEP); + pPortInfo->usrPort = usrPort; + + return MGC_RESULT_OK; +} + + + +/*************************************************************************** + * mgc_crcx_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to send crcx, on the specific chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * chnl - the chnl need to send crcx + ***************************************************************************/ +int mgc_crcx_chnl(WORD usrPort, CHNL chnl) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + CONNECT_INFO *pConnectTmp = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + pConnect = mgc_chnl_info_assign_connect(pChnlInfo, chnl.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pPortInfo == NULL)||(pConnect == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return MGC_RESULT_8ECP_OK; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return MGC_RESULT_INPUT_ILLEGAL; + + MGC_DEBUG("mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo , pConnect->id); + + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_IDLE) + { + MGC_WARN("conn[%d] should be idle" , pConnect->id); + pConnectTmp = mgc_connect_dup_attr(pConnect); + mgc_connect_add_dlcx(pConnectTmp, pPortInfo); + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_IDLE); + mgc_connect_codec_list_init(&pConnect->codecList); + memset(&pConnect->mediaAttr , 0 , sizeof(MEDIA_ATTR)); + } + + mgc_connect_add_crcx(pConnect , pPortInfo); + mgc_connect_add_nop(pConnect,pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CRCX); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + + +int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig) +{ + CHNL_INFO *pChnlInfo = NULL; + MG_INFO *pMgInfo = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo,chnl.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + MGC_DEBUG("func %s " , __FUNCTION__); + + if((pChnlInfo == NULL)||(pConnect== NULL)||(pPortInfo == NULL)||(pMgInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + return MGC_RESULT_8ECP_OK; + + mgc_connect_add_rqnt(pConnect, pPkgEvent, pPkgSig, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_RQNT); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + +int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *pMediaPara) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + MGC_DEBUG("func %s " , __FUNCTION__); + + pPortInfo = mgc_port_info_get_unused_port(); + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + + if(pMediaPara) + { + if((pMediaPara->flag & MGC_MEDIA_PARA_FLAG_EC) == MGC_MEDIA_PARA_FLAG_EC) + { + pConnect->mediaAttr.ecDisable = pMediaPara->ecDisable; + } + + if((pMediaPara->flag & MGC_MEDIA_PARA_FLAG_SS) == MGC_MEDIA_PARA_FLAG_SS) + { + pConnect->mediaAttr.ssDisable = pMediaPara->ssDisable; + } + + if((pMediaPara->flag & MGC_MEDIA_PARA_FLAG_CM) == MGC_MEDIA_PARA_FLAG_CM) + { + pConnect->mediaAttr.conMode = mgc_mgcp_convert_to_mgc_mode(pMediaPara->conMode); + } + + if((pMediaPara->flag & MGC_MEDIA_PARA_FLAG_PT) == MGC_MEDIA_PARA_FLAG_PT) + { + pConnect->mediaAttr.ptime = pMediaPara->ptime; + } + + if((pMediaPara->flag & MGC_MEDIA_PARA_FLAG_VT) == MGC_MEDIA_PARA_FLAG_VT) + { + mgc_mgcp_match_codec_list(&pConnect->codecList , &pMediaPara->vocoderType , &pConnect->codecList); + } + } + + mgc_tandem_info_mdcx(pConnect, pPortInfo); + mgc_connect_add_nop(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_MDCX); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + + +/*************************************************************************** + * mgc_connect_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to connect orgChnl to the destChnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * orgChnl - the chnl need to send connect info + * destChnl - the peer chnl to be connected + * flag - reserved + *------------------------------------------------------------------------- + *Note: if connection of the chnl is not created send crcx first, then send mdcx + ***************************************************************************/ +int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + CHNL_INFO *pOrgChnlInfo = NULL; + CHNL_INFO *pDestChnlInfo = NULL; + CONNECT_INFO *pOrgConnect = NULL; + CONNECT_INFO *pDestConnect = NULL; + CONNECT_INFO *pPeerConnect = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pOrgChnlInfo = mgc_chnl_info_get_chnl(orgChnl); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + pDestChnlInfo = mgc_chnl_info_get_chnl(destChnl); + + if((pOrgMgInfo == NULL)||(pOrgChnlInfo == NULL)||(pDestMgInfo == NULL) || (pDestChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if((pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP)||(pDestMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) ) + return -MGC_RESULT_INPUT_ILLEGAL; + + if(pOrgMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + mgc_8ecp_connect_chnl(orgChnl, destChnl, flag); + return MGC_RESULT_OK ; + } + + MGC_DEBUG("func %s " , __FUNCTION__); + pOrgConnect = mgc_chnl_info_assign_connect(pOrgChnlInfo,orgChnl.connectNo); + pDestConnect= mgc_chnl_info_assign_connect(pDestChnlInfo, destChnl.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + if((pPortInfo == NULL)||(pOrgConnect == NULL)||(pDestConnect == NULL)) + { + return MGC_RESULT_NO_RES; + } + + MGC_DEBUG("Org mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , + orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo,orgChnl.connectNo , pOrgConnect->id); + + MGC_DEBUG("Dest mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , + destChnl.mgNo, destChnl.portNo, destChnl.chlNo,destChnl.connectNo , pDestConnect->id); + + pConnect = pOrgConnect; + pPeerConnect = pDestConnect; +/* + if((pConnect->pOperStep != NULL)&&(pConnect->pOperStep->stepInfo.delay != 0)) + { + pConnect->pOperStep->stepInfo.delay = 0; + MGC_DEBUG("conn[%d] set clear delay" , pConnect->id); + } + + if(pPeerConnect->pOperStep != NULL) + { + pPeerConnect->pOperStep->stepInfo.delay = 0; + MGC_DEBUG("conn[%d] set clear delay" , pPeerConnect->id); + } + */ + if(pConnect->pOperStep != NULL) + mgc_port_info_mv_step_into_new_port(pPortInfo, pConnect->pOperStep); + + if(pPeerConnect->pOperStep != NULL) + mgc_port_info_mv_step_into_new_port(pPortInfo, pPeerConnect->pOperStep); + + //if any connection is a target, create the tandem if neccessary + mgc_connect_add_crcx(pConnect,pPortInfo); + + mgc_connect_add_crcx(pPeerConnect,pPortInfo); + + //if any connecion is aor, stop related tandem and dettach from the tandem + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if((mgc_tandem_info_get_conn_pos(pConnect->pTandem , pConnect) == MGC_TANDEM_CONN_POS_TAR) + &&(pConnect->pTandem == pPeerConnect->pTandem)) + { + MGC_DEBUG("PeerConn[%d] and Conn[%d] is in tandem[%d]" , pPeerConnect->id , pConnect->id , pConnect->pTandem->id); + } + else + { + mgc_tandem_info_dettach_aor_related_tandem(pConnect , pPeerConnect, pPortInfo); + } + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if((mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem , pPeerConnect) == MGC_TANDEM_CONN_POS_TAR) + &&(pPeerConnect->pTandem == pConnect->pTandem)) + { + MGC_DEBUG("Conn[%d] and PeerConn[%d] is in tandem[%d]" , pConnect->id , pPeerConnect->id , pConnect->pTandem->id); + } + else + { + mgc_tandem_info_dettach_aor_related_tandem(pPeerConnect , pConnect, pPortInfo); + } + } + + //connect to peer connection + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED) + { + mgc_tandem_info_connect(pConnect,pPeerConnect, MGC_CON_MODE_OWN, pPortInfo); + } + + mgc_tandem_info_connect(pPeerConnect, pConnect,MGC_CON_MODE_SENDRECV,pPortInfo); + + if((pOrgMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL)&&(pDestMgInfo->mgAttr.mgType != MGC_MG_TYPE_INTERNAL)) + mgc_connect_add_nop(pPeerConnect, pPortInfo); + + if((flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + pDestConnect->flag |= MGCP_PARA_FLAG_TFO; + pOrgConnect->flag |= MGCP_PARA_FLAG_TFO; + } + + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CONNECT_CHNL); + pPortInfo->usrPort = usrPort; + + memset(&pOrgConnect->operRec , 0 , sizeof(OPER_REC)); + pOrgConnect->operRec.operaId = MGC_OPER_ID_CONNECT_CHNL; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] and mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + orgChnl.mgNo,orgChnl.portNo,orgChnl.chlNo,orgChnl.connectNo, + destChnl.mgNo,destChnl.portNo,destChnl.chlNo,destChnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + + +/*************************************************************************** + * mgc_dlcx_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to send dlcx to the specific chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * chnl - the chnl need to send dlcx + ***************************************************************************/ +int mgc_dlcx_chnl(WORD usrPort, CHNL chnl) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + pPortInfo = mgc_port_info_get_unused_port(); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + mgc_8ecp_dlcx_chnl(chnl); + return MGC_RESULT_OK; + } + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + { + MGC_ERROR("lost connect in dlcx"); + return MGC_RESULT_INPUT_ILLEGAL; + } + +/* + if((pConnect->pOperStep != NULL)&&(pConnect->pOperStep->stepInfo.delay != 0)) + { + pConnect->pOperStep->stepInfo.delay = 0; + MGC_DEBUG("conn[%d] set clear delay" , pConnect->id); + } +*/ + if(pConnect->pOperStep != NULL) + mgc_port_info_mv_step_into_new_port(pPortInfo, pConnect->pOperStep); + + + MGC_DEBUG("mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo , pConnect->id); + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + + mgc_connect_add_dlcx(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_DLCX); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + +int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + CHNL_INFO *pOrgChnlInfo = NULL; + CHNL_INFO *pDestChnlInfo = NULL; + CONNECT_INFO *pOrgConnect = NULL; + CONNECT_INFO *pDestConnect = NULL; + CONNECT_INFO *pPeerConnect = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pOrgChnlInfo = mgc_chnl_info_get_chnl(orgChnl); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + pDestChnlInfo = mgc_chnl_info_get_chnl(destChnl); + + if((pOrgMgInfo == NULL)||(pOrgChnlInfo == NULL)||(pDestMgInfo == NULL) || (pDestChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + if((pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP)||(pDestMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP)) + return MGC_RESULT_INPUT_ILLEGAL; + + pOrgConnect = mgc_connect_find_connect_of_chnl(pOrgChnlInfo,orgChnl.connectNo); + pDestConnect= mgc_connect_find_connect_of_chnl(pDestChnlInfo, destChnl.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + if((pPortInfo == NULL)||(pOrgConnect == NULL)||(pDestConnect == NULL)) + return MGC_RESULT_NO_RES; + + pConnect = pOrgConnect; + pPeerConnect = pDestConnect; + + //if any connecion is aor, stop related tandem and dettach from the tandem + mgc_tandem_info_dettach_aor_related_tandem(pConnect , pPeerConnect, pPortInfo); + mgc_tandem_info_connect(pConnect, pPeerConnect,MGC_CON_MODE_RECVONLY, pPortInfo); + memset(&pOrgConnect->operRec , 0 , sizeof(OPER_REC)); + pOrgConnect->operRec.operaId = MGC_OPER_ID_MDCX; + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_MDCX); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] and mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + orgChnl.mgNo,orgChnl.portNo,orgChnl.chlNo,orgChnl.connectNo, + destChnl.mgNo,destChnl.portNo,destChnl.chlNo,destChnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + +/*************************************************************************** + * mgc_connect_dtmf + * ------------------------------------------------------------------------ + * General: inferace for up-layer to send dtmf to the specific chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * chnl - the chnl need to send dtmf + * dtmfNo - the dtmf need to be sent + ***************************************************************************/ +int mgc_connect_dtmf(WORD usrPort, CHNL chnl,CHNL dstChnl, BYTE dtmfNo) +{ + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MG_INFO *pMgInfo = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + pPortInfo = mgc_port_info_get_unused_port(); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + mgc_8ecp_connect_dtmf(chnl, dstChnl, dtmfNo); + return MGC_RESULT_OK; + } + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + { + MGC_WARN("lost connect in dtmf"); + return MGC_RESULT_INPUT_ILLEGAL; + } + + mgc_connect_set_dtmf(pConnect, dtmfNo); + mgc_connect_add_rqnt(pConnect, NULL , &pConnect->mediaAttr.pkgSignal,pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CONNECT_DTMF); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] and mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo, + dstChnl.mgNo,dstChnl.portNo,dstChnl.chlNo,dstChnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_connect_AAS + * ------------------------------------------------------------------------ + * General: inferace for up-layer to make the specific orgChnl to connect to specific toneNo chnl on the AAS + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * orgChnl - the chnl need to send tone + * destChnl - the peer endpoint of the orgChnl + * toneNo - the tone identify on the AAS + * duration - the time need to be played + * times - reserved + ***************************************************************************/ +int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE toneNo, WORD duration, WORD times) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + MG_INFO *pAasMgInfo = NULL; + CHNL_INFO *pOrgChnlInfo = NULL; + CHNL_INFO *pDestChnlInfo = NULL; + CONNECT_INFO *pOrgConnect = NULL; + CONNECT_INFO *pDestConnect = NULL; + CONNECT_INFO *pAasConnect = NULL; + CONNECT_INFO *pPeerConnect = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + PORT_INFO *pPortInfoTmp = NULL; + + DWORD delay; + BYTE tone; + + MGC_DEBUG("func %s toneNo[%d] times[%d] duration[%d]" , __FUNCTION__ , toneNo , times , duration); + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pOrgChnlInfo = mgc_chnl_info_get_chnl(orgChnl); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + pDestChnlInfo = mgc_chnl_info_get_chnl(destChnl); + tone = toneNo; + + if((pOrgMgInfo == NULL)||(pOrgChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return MGC_RESULT_INPUT_ILLEGAL; + + toneNo = times * 10 + (toneNo - 7); + pAasConnect = mgc_mg_info_assign_aas_tone_connection(toneNo); + pOrgConnect = mgc_connect_find_connect_of_chnl(pOrgChnlInfo,orgChnl.connectNo); + pDestConnect= mgc_connect_find_connect_of_chnl(pDestChnlInfo, destChnl.connectNo); + pPortInfoTmp = mgc_port_info_get_unused_port(); + if((pPortInfoTmp == NULL)||(pOrgConnect == NULL)||(pAasConnect == NULL)) + return MGC_RESULT_NO_RES; + + MGC_DEBUG("Org mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , + orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo,orgChnl.connectNo , pOrgConnect->id); + + pAasMgInfo = mgc_connect_get_own_mg_info(pAasConnect); + if((mgc_connect_get_status(pAasConnect) != MGC_CONNECT_STATUS_IDLE)||(pAasMgInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if((mgc_connect_get_status(pOrgConnect) == MGC_CONNECT_STATUS_IDLE)|| + (mgc_connect_get_status(pDestConnect) == MGC_CONNECT_STATUS_IDLE)) + { + MGC_ERROR("conn[%d] and conn[%d] is not created" , pOrgConnect->id , pDestConnect->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + pConnect = pOrgConnect; + pPeerConnect = pDestConnect; + + //stop stream sending + if(mgc_connect_get_status(pPeerConnect) == MGC_CONNECT_STATUS_CREATED) + { + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + mgc_tandem_info_connect(pPeerConnect, pConnect,MGC_CON_MODE_RECVONLY, pPortInfoTmp); + } + else + { + mgc_connect_add_mdcx(pPeerConnect, pConnect, MGC_CON_MODE_RECVONLY, pPortInfoTmp); + } + mgc_connect_add_nop(pPeerConnect, pPortInfoTmp); + mgc_port_info_set_step_to_start(pPortInfoTmp); + mgc_port_info_set_oper_id(pPortInfoTmp , MGC_OPER_ID_MDCX); + pPortInfoTmp->usrPort = usrPort; + } + + pPortInfo = mgc_port_info_get_unused_port(); + if(pPortInfo == NULL) + return MGC_RESULT_NO_RES; + + delay = duration * MGC_MGCF_TIMER_1S; + if(delay == 0) + delay = MGC_MGCF_TIMER_1H; + + /*copy dest connection sdp and made codec negotiate*/ + pConnect = pAasConnect; + pPeerConnect = pOrgConnect; + if(pPeerConnect->pOperStep != NULL) + mgc_port_info_mv_step_into_new_port(pPortInfo, pPeerConnect->pOperStep); + MGC_DEBUG("conn[%d] send crcx to aas with %ld delay" , pConnect->id , delay); + mgc_tandem_info_add_crcx_aas(pConnect, pPeerConnect, pPortInfo); + mgc_tandem_info_add_mdcx_aas(pPeerConnect, pConnect, pPortInfo); + mgc_connect_add_nop_with_delay(pPeerConnect, delay , pPortInfo); + /*remove aas connection*/ + MGC_DEBUG("conn[%d] send dlcx to delete aas" , pConnect->id); + mgc_connect_add_dlcx(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CONNECT_AAS); + pPortInfo->usrPort = usrPort; + pPortInfo->cause = tone; + + memset(&pOrgConnect->operRec , 0 , sizeof(OPER_REC)); + pOrgConnect->operRec.operaId = MGC_OPER_ID_CONNECT_AAS; + pOrgConnect->operRec.duration = duration; + pOrgConnect->operRec.times = times; + pOrgConnect->operRec.tone = tone; + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + orgChnl.mgNo,orgChnl.portNo,orgChnl.chlNo,orgChnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + +/*************************************************************************** + * mgc_connect_tone + * ------------------------------------------------------------------------ + * General: inferace for up-layer to make the specific orgChnl to connect to specific toneNo chnl on the AAS + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: usrPort - up-layer parameter to identify + * orgChnl - the chnl need to send tone + * destChnl - the peer endpoint of the orgChnl + * toneNo - the tone identify on the AAS + * duration - the time need to be played + ***************************************************************************/ +int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE toneNo, WORD duration) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + MG_INFO *pAasMgInfo = NULL; + CHNL_INFO *pOrgChnlInfo = NULL; + CHNL_INFO *pDestChnlInfo = NULL; + CONNECT_INFO *pOrgConnect = NULL; + CONNECT_INFO *pDestConnect = NULL; + CONNECT_INFO *pAasConnect = NULL; + CONNECT_INFO *pPeerConnect = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + PORT_INFO *pPortInfoTmp = NULL; + DWORD delay; + BYTE tone , toneTmp; + + MGC_DEBUG("func %s " , __FUNCTION__); + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pOrgChnlInfo = mgc_chnl_info_get_chnl(orgChnl); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + pDestChnlInfo = mgc_chnl_info_get_chnl(destChnl); + + MGC_DEBUG("Org mg[%d]port[%d]chnl[%d]conNo[%d]" , + orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo,orgChnl.connectNo); + + MGC_DEBUG("Dest mg[%d]port[%d]chnl[%d]conNo[%d]" , + destChnl.mgNo, destChnl.portNo, destChnl.chlNo,destChnl.connectNo); + if((pOrgMgInfo == NULL)||(pOrgChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pOrgMgInfo->mgAttr.ctrlType == MGC_MG_CTRL_TYPE_8ECP) + { + mgc_8ecp_connect_tone(orgChnl, destChnl, toneNo , duration); + return MGC_RESULT_OK; + } + + if((pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) ) + return MGC_RESULT_INPUT_ILLEGAL; + + tone = toneNo; + toneTmp = toneNo-7; + pAasConnect = mgc_mg_info_assign_aas_tone_connection(toneTmp); + pOrgConnect = mgc_connect_find_connect_of_chnl(pOrgChnlInfo,orgChnl.connectNo); + pDestConnect= mgc_connect_find_connect_of_chnl(pDestChnlInfo, destChnl.connectNo); + pPortInfoTmp = mgc_port_info_get_unused_port(); + if((pPortInfoTmp == NULL)||(pOrgConnect == NULL)||(pAasConnect == NULL)) + return MGC_RESULT_NO_RES; + + MGC_DEBUG("Org mg[%d]port[%d]chnl[%d]conNo[%d] ==> conn[%d]" , + orgChnl.mgNo, orgChnl.portNo, orgChnl.chlNo,orgChnl.connectNo , pOrgConnect->id); + + pAasMgInfo = mgc_connect_get_own_mg_info(pAasConnect); + if((mgc_connect_get_status(pAasConnect) != MGC_CONNECT_STATUS_IDLE)||(pAasMgInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = pOrgConnect; + pPeerConnect = pDestConnect; + + // stop dest send stream to org + if(mgc_connect_get_status(pPeerConnect) == MGC_CONNECT_STATUS_CREATED) + { + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + mgc_tandem_info_connect(pPeerConnect, pConnect,MGC_CON_MODE_RECVONLY, pPortInfoTmp); + } + else + { + mgc_connect_add_mdcx(pPeerConnect, pConnect, MGC_CON_MODE_RECVONLY, pPortInfoTmp); + } + mgc_connect_add_nop(pPeerConnect, pPortInfoTmp); + mgc_port_info_set_step_to_start(pPortInfoTmp); + mgc_port_info_set_oper_id(pPortInfoTmp , MGC_OPER_ID_MDCX); + pPortInfoTmp->usrPort = usrPort; + } + + pPortInfo = mgc_port_info_get_unused_port(); + if(pPortInfo == NULL) + return MGC_RESULT_NO_RES; + + //if org is not created create first + if(mgc_connect_get_status(pOrgConnect) == MGC_CONNECT_STATUS_IDLE) + { + mgc_connect_add_crcx(pOrgConnect , pPortInfo); + } + + if(pOrgConnect->pOperStep != NULL) + mgc_port_info_mv_step_into_new_port(pPortInfo, pOrgConnect->pOperStep); + + delay = duration * MGC_MGCF_TIMER_1S; + if(delay == 0) + delay = MGC_MGCF_TIMER_1H; + + if(pOrgMgInfo->mgAttr.toneCap == 1) + { + mgc_connect_set_tone(pConnect , toneNo); + mgc_connect_add_rqnt_with_delay(pConnect, delay, NULL ,&pOrgConnect->mediaAttr.pkgSignal,pPortInfo); + mgc_connect_clear_tone(pConnect); + mgc_connect_add_rqnt(pConnect,NULL,&pOrgConnect->mediaAttr.pkgSignal,pPortInfo); + } + else + { + pConnect = pAasConnect; + pPeerConnect = pOrgConnect; + mgc_tandem_info_add_crcx_aas(pConnect, pPeerConnect, pPortInfo); + mgc_tandem_info_add_mdcx_aas(pPeerConnect, pConnect, pPortInfo); + mgc_connect_add_nop_with_delay(pPeerConnect, delay, pPortInfo); + mgc_connect_add_dlcx(pConnect, pPortInfo); + } + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CONNECT_TONE); + pPortInfo->usrPort = usrPort; + memset(&pOrgConnect->operRec , 0 , sizeof(OPER_REC)); + pOrgConnect->operRec.operaId = MGC_OPER_ID_CONNECT_TONE; + pOrgConnect->operRec.duration = duration; + pOrgConnect->operRec.tone = tone; + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] ==> %s", + __FUNCTION__ , + orgChnl.mgNo,orgChnl.portNo,orgChnl.chlNo,orgChnl.connectNo, + mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + return MGC_RESULT_OK; +} + + + +/*************************************************************************** + * mgc_query_mg_status + * ------------------------------------------------------------------------ + * General: inferace for up-layer to query the specific mg status + * Return Value: if mg not created return -1, + * else return the status of the mg, 1 stand for enable, 0 stand for disable + * ------------------------------------------------------------------------ + * Arguments: + * Input: mgNo - the mg id, return by mgc_create_MG + ***************************************************************************/ +int mgc_query_mg_status(WORD mgNo) +{ + MG_INFO *pMgInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + if(pMgInfo == NULL) + return -1; + MGC_INFO("%s mg[%d] %s" , __FUNCTION__ , pMgInfo->id , pMgInfo->enable?"ENABLE":"DISABLE"); + return pMgInfo->enable; +} + + +/*************************************************************************** + * mgc_query_port_status + * ------------------------------------------------------------------------ + * General: inferace for up-layer to query the specific port + * Return Value: if port not created return -1, + * else return the status of the port, 1 stand for enable, 0 stand for disable + * ------------------------------------------------------------------------ + * Arguments: + * Input: mgNo - the mg id, return by mgc_create_MG + * portNo - used in the mgc_add_port + ***************************************************************************/ +int mgc_query_port_status(WORD mgNo, BYTE portNo) +{ + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + if(pMgInfo == NULL) + return -1; + + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo, portNo); + if(pPhyPort == NULL) + return -1; + + return pPhyPort->status; +} + + +/*************************************************************************** + * mgc_query_channel_status + * ------------------------------------------------------------------------ + * General: inferace for up-layer to query the specific chnl + * Return Value: if port not created return -1, + * else return the status of the chnl, 1 stand for enable, 0 stand for disable + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - the chnl need to query + ***************************************************************************/ +int mgc_query_channel_status(CHNL chnl) +{ + CHNL_INFO *pChnlInfo = NULL; + + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if(pChnlInfo == NULL) + return -1; + + return pChnlInfo->status; +} + + + +/*************************************************************************** + * mgc_create_virtual_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to create virtual chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnl - the address of the chnl to be filled + * usrPort - reserved + ***************************************************************************/ +int mgc_create_virtual_chnl(WORD usrPort, CHNL *pChnl) +{ + MG_INFO *pMgInfo = NULL; + CONNECT_INFO *pConnect = NULL; + CHNL_INFO *pChnlInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + PORT_INFO *pPortInfo = NULL; + + pPortInfo = mgc_port_info_get_unused_port(); + + if((pChnl == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_NO_RES; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_find_available_mg(MGC_MG_TYPE_INTERNAL); + if(pMgInfo == NULL) + return MGC_RESULT_NO_RES; + + pConnect = mgc_mg_info_assign_idle_connection(pMgInfo); + if(pConnect == NULL) + return MGC_RESULT_NO_RES; + + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + if(pChnlInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + if(pPhyPort == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pChnl->mgNo = pMgInfo->id; + pChnl->portNo = pPhyPort->portNo; + pChnl->chlNo = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo, pPhyPort); + pChnl->connectNo = mgc_connect_get_connNo_of_chnl_info(pConnect, pChnlInfo); + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_CREATING); + mgc_connect_add_nop(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_CREATE_VIRTUAL_CHNL); + pPortInfo->usrPort = usrPort; + MGC_INFO("create virtual mg[%d]port[%d]chnl[%d]connNo[%d]" , pChnl->mgNo , pChnl->portNo , pChnl->chlNo , pChnl->connectNo); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_release_virtual_chnl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to release virtual chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnl - the address of the chnl to be filled + * usrPort - reserved + ***************************************************************************/ +int mgc_release_virtual_chnl(WORD usrPort, CHNL chnl) +{ + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pPortInfo = mgc_port_info_get_unused_port(); + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if((pChnlInfo == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + + mgc_connect_add_dlcx(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_RELEASE_VIRTUAL_CHNL); + pPortInfo->usrPort = usrPort; + MGC_INFO("release virtual mg[%d]port[%d]chnl[%d]connNo[%d]" , chnl.mgNo , chnl.portNo , chnl.chlNo , chnl.connectNo); + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_license_ctrl + * ------------------------------------------------------------------------ + * General: inferace for up-layer to make license control + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: maxMgNum - the maxMgNum could be created + * maxChnlNum - the maxChnlNum could be created + ***************************************************************************/ +int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum) +{ + if(mgc_ctl_set_mg_max_num(maxMgNum) != maxMgNum) + return MGC_RESULT_FAILURE; + + if(mgc_ctl_set_chnl_max_num(maxChnlNum) != maxChnlNum) + return MGC_RESULT_FAILURE; + + return MGC_RESULT_OK; +} + + +/*************************************************************************** + * mgc_rsp + * ------------------------------------------------------------------------ + * General: interface for up-layer to send rsp msg to the incoming ind + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: cmd - mgcp ind command + * usrPort - up-layer parameter for identify + * port - the mgcPort id , get from ind callback function + * retCode - the respond code + * pMediaAttr - media info get from up-layer + ***************************************************************************/ +int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *pMediaAttr) +{ + PORT_INFO *pPortInfo = NULL; + MGCF_OPER_STEP *pCurrentStep = NULL; + CONNECT_INFO *pConnect = NULL; + + MGC_DEBUG("mgc rsp to mgcPort[%d]" , port); + pPortInfo = mgc_port_info_find_port_by_id(port); + if(pPortInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pCurrentStep = pPortInfo->pMgcOperCurrent; + if(pCurrentStep == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pCurrentStep->status != MGCP_OPER_STEP_IND_SENT) + { + MGC_WARN("mgcPort[%d]step[%d] error status" , port , pCurrentStep->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + pConnect = pCurrentStep->pConnect; + if(pConnect == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMediaAttr != NULL) + memcpy(&(pConnect->mediaAttr) , pMediaAttr, sizeof(MEDIA_ATTR)); + pCurrentStep->llCmd = retCode; + pCurrentStep->stepInfo.pPeerConn = pConnect; + pCurrentStep->status = MGCP_OPER_STEP_RESPONSE; + return MGC_RESULT_OK; +} + + + +/*************************************************************************** + * mgc_chnl_codec_update + * ------------------------------------------------------------------------ + * General: interface for up-layer to update codecList on the specific chnl + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - the chnl to be update + * codecList - the codecList from the up-layer + ***************************************************************************/ +int mgc_chnl_codec_update(CHNL chnl , MGC_CODEC_LIST codecList) +{ + int i ,j; + BYTE codec; + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MGC_CODEC_LIST codecListResult, codecListMg; + + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if(pChnlInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + MGC_DEBUG("func %s " , __FUNCTION__); + + pConnect = mgc_chnl_info_assign_connect(pChnlInfo , chnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_NO_RES; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return MGC_RESULT_FAILURE; + + mgc_connect_codec_list_init(&codecListResult); + memcpy(&codecListMg , &pMgInfo->mgAttr.codecList , sizeof(MGC_CODEC_LIST)); + codecListMg.priority = codecList.priority+1; + + + for(i=0 ; imgAttr.mgType == MGC_MG_TYPE_IPBSS) + memcpy(&pConnect->codecList , &codecListResult , sizeof(MGC_CODEC_LIST)); + + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] sucess", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo); + switch(codecListResult.codec[0]) + { + case MGC_VCTYPE_AMR_12_2: + case MGC_VCTYPE_AMR_10_2: + return MGC_VCTYPE_AMR_12_2; + case MGC_VCTYPE_AMR_7_95: + case MGC_VCTYPE_AMR_7_4: + case MGC_VCTYPE_AMR_6_7: + case MGC_VCTYPE_AMR_5_15: + case MGC_VCTYPE_AMR_5_9: + case MGC_VCTYPE_AMR_4_75: + return MGC_VCTYPE_AMR_7_95; + default : + return codecListResult.codec[0]; + } + + + return MGC_RESULT_FAILURE; +} + + +/*************************************************************************** + * mgc_query_chnl_oper_rec + * ------------------------------------------------------------------------ + * General: interface for up-layer to query last time operation + * Return Value: if failure return NULL, else return pointer of the record + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - the chnl to be query + ***************************************************************************/ +OPER_REC *mgc_query_chnl_oper_rec(CHNL chnl) +{ + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if(pChnlInfo == NULL) + return NULL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + return NULL; + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] sucess", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo); + + return &(pConnect->operRec); +} + + +/*************************************************************************** + * mgc_query_chnl_media + * ------------------------------------------------------------------------ + * General: interface for up-layer to query chnl media info + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - the chnl to be query + ***************************************************************************/ +int mgc_query_chnl_media(WORD usrPort, CHNL chnl, PUB_SDP_MSG **ppMediaInfo, BYTE *pMgPayloads, BYTE *pMgPlNum) +{ + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + int i; + + if((ppMediaInfo == NULL)||(pMgPayloads == NULL)||(pMgPlNum == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if(pChnlInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pTandem = pConnect->pTandem; + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_TAR) + { + pConnect= pTandem->pRxconn; + } + else if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + pConnect = pConnect; + } + else if((mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_UNDEF)&& + (mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_SUR)) + { + MGC_ERROR("conn[%d] in illegal tandem" , pConnect->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + return MGC_RESULT_INPUT_ILLEGAL; + + *ppMediaInfo = &(pConnect->mediaAttr.sdp); + + for(i=0 ; i< pConnect->codecList.num ; i++) + { + pMgPayloads[i] = mgc_mgcp_print_vc_num(pConnect->codecList.codec[i]); + } + + *pMgPlNum = pConnect->codecList.num; + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] sucess", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo); + + return MGC_RESULT_OK; +} + + +static int mgc_payload_to_codec(WORD payload, PUB_SDP_ATTRS attrs) +{ + BYTE i = 0; + + if (attrs.num > 0) + { + for (i = 0; i < attrs.num; i++) + { + if (attrs.attrs[i].aType != PUB_SDP_ATTR_TYPE_RTPMAP) + { + continue; + } + + if (strtol(attrs.attrs[i].aValue, NULL, 10) == payload) + { + if (strstr(attrs.attrs[i].aValue, " GSM/") != NULL) + return MGC_VCTYPE_GSM; + else if (strstr(attrs.attrs[i].aValue, "GSM-EFR") != NULL) + return MGC_VCTYPE_GSM_EFR; + else if (strstr(attrs.attrs[i].aValue, "AMR") != NULL) + return MGC_VCTYPE_AMR_12_2; + else if (strstr(attrs.attrs[i].aValue, "G729B") != NULL) + return MGC_VCTYPE_G729B; + else if (strstr(attrs.attrs[i].aValue, "PCMU") != NULL) + return MGC_VCTYPE_PCMU; + else if (strstr(attrs.attrs[i].aValue, "AMR_12_2") != NULL) + return MGC_VCTYPE_AMR_12_2; + else if (strstr(attrs.attrs[i].aValue, "AMR_10_2") != NULL) + return MGC_VCTYPE_AMR_10_2; + else if (strstr(attrs.attrs[i].aValue, "AMR_7_95") != NULL) + return MGC_VCTYPE_AMR_7_95; + else if (strstr(attrs.attrs[i].aValue, "AMR_7_4") != NULL) + return MGC_VCTYPE_AMR_7_4; + else if (strstr(attrs.attrs[i].aValue, "AMR_6_7") != NULL) + return MGC_VCTYPE_AMR_6_7; + else if (strstr(attrs.attrs[i].aValue, "AMR_5_15") != NULL) + return MGC_VCTYPE_AMR_5_15; + else if (strstr(attrs.attrs[i].aValue, "AMR_5_9") != NULL) + return MGC_VCTYPE_AMR_5_9; + else if (strstr(attrs.attrs[i].aValue, "AMR_4_75") != NULL) + return MGC_VCTYPE_AMR_4_75; + else + return MGC_VCTYPE_PCMA; + } + } + } + + if (i == attrs.num) + { + if (payload == 3) + return MGC_VCTYPE_GSM; + else if (payload == 84) + return MGC_VCTYPE_GSM_EFR; + else if (payload == 118) + return MGC_VCTYPE_G729B; + else if (payload == 0) + return MGC_VCTYPE_PCMU; + else if (payload == 71) + return MGC_VCTYPE_AMR_12_2; + else if (payload == 70) + return MGC_VCTYPE_AMR_10_2; + else if (payload == 69) + return MGC_VCTYPE_AMR_7_95; + else if (payload == 68) + return MGC_VCTYPE_AMR_7_4; + else if (payload == 67) + return MGC_VCTYPE_AMR_6_7; + else if (payload == 65) + return MGC_VCTYPE_AMR_5_15; + else if (payload == 66) + return MGC_VCTYPE_AMR_5_9; + else if (payload == 64) + return MGC_VCTYPE_AMR_4_75; + } + + return MGC_VCTYPE_PCMA; +} + + +/*************************************************************************** + * mgc_update_chnl_media + * ------------------------------------------------------------------------ + * General: interface for up-layer to update chnl media info + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - the chnl to be update + ***************************************************************************/ +int mgc_update_chnl_media(WORD usrPort, CHNL chnl, PUB_SDP_MSG *pMediaInfo) +{ + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MG_INFO *pMgInfo = NULL; + PUB_SDP_A *pSdpA = NULL; + PORT_INFO *pPortInfo = NULL; + BYTE ptime; + int i; + + pPortInfo = mgc_port_info_get_unused_port(); + if((pMediaInfo == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pChnlInfo = mgc_chnl_info_get_chnl(chnl); + if(pChnlInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, chnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + memcpy(&pConnect->mediaAttr.sdp , pMediaInfo , sizeof(PUB_SDP_MSG)); + + pConnect->codecList.num = pMediaInfo->medias.medias[0].m.plNum; + + for(i=0 ; icodecList.num ; i++) + { + pConnect->codecList.codec[i] = mgc_payload_to_codec(pMediaInfo->medias.medias[0].m.payloads[i], pMediaInfo->medias.medias[0].attrs); + } + + pConnect->codecList.priority = 255; + + for (i = 0; i < pMediaInfo->medias.medias[0].attrs.num; i++) + { + pSdpA = &pMediaInfo->medias.medias[0].attrs.attrs[i]; + if (pSdpA->aType == PUB_SDP_ATTR_TYPE_PTIME) + { + ptime = atoi(pSdpA->aValue); + continue; + } + + if(strcmp(pSdpA->aValue , "inactive") == 0) + { + mgc_connect_set_conn_mode(pConnect, MGC_CON_MODE_INACTIVE); + } + else if(strcmp(pSdpA->aValue , "sendonly") == 0) + { + mgc_connect_set_conn_mode(pConnect, MGC_CON_MODE_SENDONLY); + } + else if(strcmp(pSdpA->aValue , "recvonly") == 0) + { + mgc_connect_set_conn_mode(pConnect, MGC_CON_MODE_RECVONLY); + } + else if(strcmp(pSdpA->aValue , "sendrecv") == 0) + { + mgc_connect_set_conn_mode(pConnect, MGC_CON_MODE_SENDRECV); + } + } + + if (i == pMediaInfo->medias.medias[0].attrs.num) + ptime = 20; + + pConnect->mediaAttr.ptime = ptime; + + MGC_DEBUG("conn[%d] , %s " , pConnect->id ,__FUNCTION__); + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_connect_add_crcx(pConnect, pPortInfo); + } + mgc_connect_add_nop(pConnect, pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_UPDATE_CHNL_MEDIA); + mgc_port_info_set_step_to_start(pPortInfo); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] sucess", + __FUNCTION__ , + chnl.mgNo,chnl.portNo,chnl.chlNo,chnl.connectNo); + return MGC_RESULT_OK; +} + + +/*----------------------------------------------------------------------- + SNMP M A N A G E R + ------------------------------------------------------------------------*/ + + +/*************************************************************************** + * mgc_get_snmp_msg + * ------------------------------------------------------------------------ + * General: check trunk state by snmp info msg + * Return Value: if failed return -1 , else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +static int mgc_get_snmp_msg(void) +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, trkNo; + WORD mgNo; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + mgcSnmpAddr.local_port = 4968; + if (!snmp_receive(&mgcSnmpPdu, &mgcSnmpAddr)) + return 0; + + if (mgcSnmpPdu.error_index != 0) + return -1; + + mgNo = mgcSnmpPdu.request_id >> 16; + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + if(pMgInfo == NULL) + return -1; + + if ((mgcSnmpPdu.request_id & 0xFFFF) != pMgInfo->requestId) + return -1; + + if (mgcSnmpPdu.var_num > MGC_MAX_PHY_PORT_PER_MG) + return -1; + + mgcVarList = &mgcSnmpPdu.var[0]; + + for (i = 0; i < mgcSnmpPdu.var_num; i++) + { + trkNo = mgcVarList[i].oid[MGC_AC_LINE_STATUS_IDLEN - 1]; + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo, trkNo); + if(pPhyPort == NULL) + return -1; + + if(mgcVarList[i].msg[0] == 1) + { + pPhyPort->status = MGC_PHY_PORT_STATUS_ON_LINE; + } + else + { + pPhyPort->status = MGC_PHY_PORT_STATUS_OFF_LINE; + } + + } + + return 1; +} + + +/*************************************************************************** + * mgc_get_non_virtual_trk_status + * ------------------------------------------------------------------------ + * General: send snmp msg to check mg status + * Return Value: if failed return -1 , else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +int mgc_get_non_virtual_trk_status(MG_INFO *pMgInfo) +{ + struct snmp_pdu mgcSnmpPdu; + struct snmp_addr mgcSnmpAddr; + struct var_list *mgcVarList; + BYTE i, j = 0; + PHY_PORT_INFO *pPhyPort; + + if(pMgInfo == NULL) + return MGC_RESULT_FAILURE; + + mgcVarList = &mgcSnmpPdu.var[0]; + mgcSnmpPdu.var_num = 0; //val list number + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_AudioCoder) + { + for(i=0 ; i< MGC_MAX_PHY_PORT_PER_MG ; i++) + { + pPhyPort = mgc_phy_port_find_port_of_mg_by_index(pMgInfo, i); + + if(pPhyPort == NULL) + continue; + + mgcVarList[j].oidlen = MGC_AC_LINE_STATUS_IDLEN; + MGC_AC_LINE_STATUS_OID[MGC_AC_LINE_STATUS_IDLEN - 1] = pPhyPort->portNo; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_AC_LINE_STATUS_OID, MGC_AC_LINE_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + j++; + } + } + + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_LGC_MG) + { + for(i=0 ; i< MGC_MAX_PHY_PORT_PER_MG ; i++) + { + pPhyPort = mgc_phy_port_find_port_of_mg_by_index(pMgInfo, i); + + if(pPhyPort == NULL) + continue; + + mgcVarList[j].oidlen = MGC_AC_LINE_STATUS_IDLEN; + MGC_AC_LINE_STATUS_OID[MGC_AC_LINE_STATUS_IDLEN - 1] = i; + memcpy(&mgcVarList[mgcSnmpPdu.var_num].oid[0], MGC_AC_LINE_STATUS_OID, MGC_LGC_MG_STATUS_IDLEN*4); + mgcVarList[mgcSnmpPdu.var_num].vartype = 0x04;//octet string + mgcVarList[mgcSnmpPdu.var_num].msglen = 0; + mgcSnmpPdu.var_num++; + j++; + } + } + + pMgInfo->requestId = (++pMgInfo->requestId) & 0xFFFF; + if (pMgInfo->requestId == 0) + pMgInfo->requestId = 1; + + mgcSnmpPdu.pdu_type = 0x00; //get + mgcSnmpPdu.request_id = (pMgInfo->id<< 16) | pMgInfo->requestId; + + mgcSnmpAddr.local_port = 4968; + mgcSnmpAddr.remote_port = 161; + mgcSnmpAddr.broadcast = 0; //Not broadcast + mgcSnmpAddr.remote_ip = pMgInfo->mgAttr.ip; + + if (mgcSnmpPdu.var_num) + snmp_send(&mgcSnmpPdu,&mgcSnmpAddr); + + return MGC_RESULT_OK; +} + + +int mgc_get_idle_tandem_id(void) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + pTandem = mgc_tandem_info_get_idle_tandem(); + if(pTandem == NULL) + return MGC_RESULT_NO_RES; + + MGC_INFO("%s tandem[%d]" , __FUNCTION__ , pTandem->id); + return pTandem->id; +} + + +int mgc_create_tandem(WORD usrPort , DWORD tandId) +{ + MGC_TANDEM_INFO *pTandem = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pTandem = mgc_tandem_info_get_tandem_by_id(tandId); + pPortInfo = mgc_port_info_get_unused_port(); + + if((pTandem == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + mgc_tandem_info_create_tandem(pTandem, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_TANDEM_CREATE); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s tandem[%d]" , __FUNCTION__ , pTandem->id); + return MGC_RESULT_OK; +} + +int mgc_bind_chnl_to_tandem(WORD usrPort , CHNL tarChnl , DWORD tandId) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_get_index_mg(tarChnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(tarChnl); + pTandem = mgc_tandem_info_get_tandem_by_id(tandId); + pPortInfo = mgc_port_info_get_unused_port(); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pTandem == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return -MGC_RESULT_INPUT_ILLEGAL; + + MGC_DEBUG("mg[%d]port[%d]chnl[%d]connNo[%d]" , tarChnl.mgNo,tarChnl.portNo,tarChnl.chlNo,tarChnl.connectNo); + pConnect = mgc_chnl_info_assign_connect(pChnlInfo, tarChnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_NO_RES; + + if(mgc_tandem_info_get_conn_pos(pTandem , pTandem->pTconn) != MGC_TANDEM_CONN_POS_UNDEF) + { + MGC_ERROR("tandem[%d] is in use" ,pTandem->id); + return MGC_RESULT_FAILURE; + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + MGC_WARN("conn[%d] already bind to tandem[%d]" , pConnect->id , pConnect->pTandem->id); + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + } + + if(mgc_tandem_info_set_conn(pTandem,pConnect, MGC_TANDEM_CONN_POS_TAR) == FALSE) + return MGC_RESULT_FAILURE; + + mgc_tandem_info_create_tar_tandem(pConnect, pPortInfo); + mgc_connect_add_nop(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_TANDEM_SET_TAR); + MGC_DEBUG("%s tandem[%ld] conn[%d]" , __FUNCTION__, tandId , pConnect->id); + MGC_DEBUG("tandem[%d] rxConn[%d] txConn[%d]" , pTandem->id , pTandem->pRxconn->id , pTandem->pTxconn->id); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] bind tandem[%d] success" , __FUNCTION__ , + tarChnl.mgNo , tarChnl.portNo , tarChnl.chlNo , tarChnl.connectNo ,pTandem->id); + return MGC_RESULT_OK; +} + + +int mgc_unbind_chnl_from_tandem(WORD usrPort , CHNL tarChnl , DWORD tandId) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + PORT_INFO *pPortInfo = NULL; + + MGC_DEBUG("func %s " , __FUNCTION__); + pMgInfo = mgc_mg_info_get_index_mg(tarChnl.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(tarChnl); + pTandem = mgc_tandem_info_get_tandem_by_id(tandId); + pPortInfo = mgc_port_info_get_unused_port(); + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pTandem == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP) + return -MGC_RESULT_INPUT_ILLEGAL; + + MGC_DEBUG("mg[%d]port[%d]chnl[%d]connNo[%d]" , tarChnl.mgNo,tarChnl.portNo,tarChnl.chlNo,tarChnl.connectNo); + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, tarChnl.connectNo); + if(pConnect == NULL) + return MGC_RESULT_NO_RES; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + return MGC_RESULT_FAILURE; + + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_TANDEM_UNSET_TAR); + pPortInfo->usrPort = usrPort; + + MGC_INFO("%s mg[%d]port[%d]chnl[%d]conNo[%d] unbind tandem[%d] success" , __FUNCTION__ , + tarChnl.mgNo , tarChnl.portNo , tarChnl.chlNo , tarChnl.connectNo ,pTandem->id); + return MGC_RESULT_OK; +} + + +int mgc_get_tandem_near_end(DWORD tandem_id, CHNL *pChnl) +{ + MGC_TANDEM_INFO *pTandem = NULL; + CONNECT_INFO *pConnect = NULL; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + + if(pChnl == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + MGC_DEBUG("func %s " , __FUNCTION__); + pTandem = mgc_tandem_info_get_tandem_by_id(tandem_id); + if(pTandem == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(mgc_tandem_info_get_conn_pos(pTandem, pTandem->pTxconn) != MGC_TANDEM_CONN_POS_TX) + { + MGC_ERROR("tandem[%d] lost TxConn" , pTandem->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + pConnect = pTandem->pTxconn; + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + if((pConnect == NULL)||(pMgInfo == NULL)||(pPhyPort == NULL)||(pChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pChnl->mgNo = pMgInfo->id; + pChnl->portNo = pPhyPort->portNo; + pChnl->chlNo = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo, pPhyPort); + pChnl->connectNo = mgc_connect_get_connNo_of_chnl_info(pConnect, pChnlInfo); + MGC_INFO("%s success" , __FUNCTION__); + return MGC_RESULT_OK; +} + + +int mgc_get_tandem_far_end(DWORD tandem_id, CHNL *pChnl) +{ + MGC_TANDEM_INFO *pTandem = NULL; + CONNECT_INFO *pConnect = NULL; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + + if(pChnl == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + MGC_DEBUG("func %s " , __FUNCTION__); + + pTandem = mgc_tandem_info_get_tandem_by_id(tandem_id); + if(pTandem == NULL) + return MGC_RESULT_INPUT_ILLEGAL; + + if(mgc_tandem_info_get_conn_pos(pTandem, pTandem->pRxconn) != MGC_TANDEM_CONN_POS_RX) + { + MGC_ERROR("tandem[%d] lost RxConn" , pTandem->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + pConnect = pTandem->pRxconn; + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + if((pConnect == NULL)||(pMgInfo == NULL)||(pPhyPort == NULL)||(pChnlInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pChnl->mgNo = pMgInfo->id; + pChnl->portNo = pPhyPort->portNo; + pChnl->chlNo = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo, pPhyPort); + pChnl->connectNo = mgc_connect_get_connNo_of_chnl_info(pConnect, pChnlInfo); + MGC_INFO("%s success" , __FUNCTION__); + return MGC_RESULT_OK; +} + + +int mgc_fork_chnl(WORD usrPort , CHNL parent, CHNL *pChild) +{ + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + CONNECT_INFO *pSurConnect = NULL; + PHY_PORT_INFO *pSurPhyPort = NULL; + CHNL_INFO *pSurChnlInfo = NULL; + PORT_INFO *pPortInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(parent.mgNo); + pChnlInfo = mgc_chnl_info_get_chnl(parent); + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo,parent.connectNo); + pPortInfo = mgc_port_info_get_unused_port(); + MGC_DEBUG("func %s " , __FUNCTION__); + + if((pMgInfo == NULL)||(pChnlInfo == NULL)||(pConnect == NULL)||(pPortInfo == NULL)||(pChild == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + if(pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + { + MGC_ERROR("mg[%d] is not tandem type!" , pMgInfo->id); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if((mgc_tandem_info_get_conn_pos(pConnect->pTandem,pConnect) != MGC_TANDEM_CONN_POS_RX)&& + (mgc_tandem_info_get_conn_pos(pConnect->pTandem,pConnect) != MGC_TANDEM_CONN_POS_TX)) + { + MGC_ERROR("conn[%d] is not a connection on tandem" , pConnect->id); + return MGC_RESULT_FAILURE; + } + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + { + MGC_ERROR("conn[%d] of tandem[%d] is not created, can't fork!" , pConnect->id , pConnect->pTandem->id); + return MGC_RESULT_FAILURE; + } + + pTandem = pConnect->pTandem; + pSurConnect = mgc_sur_info_find_sur_conn_in_mg(pMgInfo); + pSurPhyPort = mgc_connect_get_own_phy_port_info(pSurConnect); + pSurChnlInfo = mgc_connect_get_own_chnl_info(pSurConnect); + if((pSurConnect == NULL)||(pSurChnlInfo == NULL)||(pSurPhyPort == NULL)) + return MGC_RESULT_NO_RES; + + if(mgc_tandem_info_set_conn(pTandem, pSurConnect,MGC_TANDEM_CONN_POS_SUR) == FALSE) + return MGC_RESULT_FAILURE; + + pChild->mgNo = pMgInfo->id; + pChild->portNo = pSurPhyPort->portNo; + pChild->chlNo = mgc_chnl_info_get_chnl_no_of_phy(pSurChnlInfo, pSurPhyPort); + pChild->connectNo = mgc_connect_get_connNo_of_chnl_info(pSurConnect, pSurChnlInfo); + + sprintf(pSurConnect->mediaAttr.callId, "%s" , pConnect->mediaAttr.callId); + memcpy(&pSurConnect->codecList, &pConnect->codecList , sizeof(MGC_CODEC_LIST)); + mgc_connect_add_crcx_with_mode(pSurConnect, MGC_CON_MODE_SENDONLY , pPortInfo); + mgc_connect_add_nop(pConnect, pPortInfo); //report to the parant chnl + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_TANDEM_FORK_CHNL); + pPortInfo->usrPort = usrPort; + MGC_DEBUG("conn[%d] fork conn[%d] callid :%s , on tandem[%d]" , pConnect->id , pSurConnect->id , pSurConnect->mediaAttr.callId, pTandem->id); + MGC_DEBUG("fork mg[%d]port[%d]chnl[%d]connNo[%d]" , pChild->mgNo , pChild->portNo , pChild->chlNo, pChild->connectNo); + MGC_INFO("%s success" , __FUNCTION__); + return MGC_RESULT_OK; +} + +int mgc_delete_tandem(WORD usrPort , DWORD tandemId) +{ + MGC_TANDEM_INFO *pTandem = NULL; + PORT_INFO *pPortInfo = NULL; + CONNECT_INFO *pConnect = NULL; + + pTandem = mgc_tandem_info_get_tandem_by_id(tandemId); + pPortInfo = mgc_port_info_get_unused_port(); + MGC_DEBUG("func %s " , __FUNCTION__); + + if((pTandem == NULL)||(pPortInfo == NULL)) + return MGC_RESULT_INPUT_ILLEGAL; + + pConnect = pTandem->pTxconn; + mgc_tandem_info_unset_conn(pTandem, pTandem->pTconn); + mgc_tandem_info_unset_conn(pTandem, pTandem->pAconn); + mgc_tandem_info_clear(pTandem, pPortInfo); + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , MGC_OPER_ID_TANDEM_CLEAR); + pPortInfo->usrPort = usrPort; + MGC_INFO("%s tandem[%d] success" , __FUNCTION__ , pTandem->id); + return MGC_RESULT_OK; +} + +int mgc_update_phy_port_status(CHNL chnl, BOOL status) +{ + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo, chnl.portNo); + + MGC_DEBUG("func %s " , __FUNCTION__); + + if((pMgInfo == NULL)||(pPhyPort == NULL)) + { + MGC_ERROR("update phyport failed! ,lost phyport"); + return MGC_RESULT_INPUT_ILLEGAL; + } + + if(status == TRUE) + { + pPhyPort->status = MGC_PHY_PORT_STATUS_ON_LINE; + } + else + { + pPhyPort->status = MGC_PHY_PORT_STATUS_OFF_LINE; + } + + return MGC_RESULT_OK; +} + diff --git a/omc/plat/mgc_v2/src/mgc_8ecp.c b/omc/plat/mgc_v2/src/mgc_8ecp.c new file mode 100644 index 0000000..36c1c99 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_8ecp.c @@ -0,0 +1,326 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* do not support now +*/ + + +/********************************************************************************* + * + * This file should include 8ecp related APIs used in MGC module, but now is not supported!!!! + * + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + + + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + +#include "./include/mgc_8ecp.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_debug.h" + + +static WORD mgc_e1card0_mgNo; +static WORD mgc_e1card1_mgNo; +static WORD mgc_8k_tone_card_silent; +static MGC_8ECP_SAP mgc8ecpSap; + + +/*----------------------------------------------------------------------- + MGC - 8ECP M A N A G E R + ------------------------------------------------------------------------*/ + +int mgc_8ecp_update_mg_status(BYTE mgNo, BYTE status) +{ + MG_INFO *pMgInfo = NULL ; + MG_INFO *pMgInfoE1 = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgInfoE1 = mgc_mg_info_get_index_mg(mgc_e1card0_mgNo); + if((pMgInfo == NULL)||(pMgInfoE1 == NULL)) + return -1; + + if(pMgInfo->created == FALSE) + { + MGC_ERROR("%s : mg[%d] not created" , __FUNCTION__, pMgInfo->id); + return -1; + } + + pMgInfo->enable = status; + + if(pMgInfo->mgAttr.e1cardNo == 1) + { + if((status == 1)&&((0 == mgc_e1card0_mgNo)||(0 == pMgInfoE1->enable))) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + + } + } + else if(pMgInfo->mgAttr.e1cardNo == 0) + { + if ((0 == status) + && (0 != mgc_e1card1_mgNo) && (1 == pMgInfoE1->enable)) + { + mgc_8k_tone_card_silent = 1; + } + else + { + mgc_8k_tone_card_silent = 0; + } + } + + return 0; + +} + +int mgc_8ecp_update_trk_status(BYTE mgNo, BYTE trkNo, BYTE status) +{ + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + + if(pMgInfo == NULL) + return -1; + + if(pMgInfo->created == FALSE) + { + MGC_ERROR("%s : mg[%d] not created" , __FUNCTION__, pMgInfo->id); + return -1; + } + + if (trkNo >= MGC_8ECP_MAX_TRK_PER_MG) + { + MGC_ERROR("%s : invalid trkNo, trkNo = %d" , __FUNCTION__ , trkNo); + return -1; + } + + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo, trkNo); + + if(pPhyPort == NULL) + return -1; + + pPhyPort->status = status; + + return 0; +} + + +static int mgc_bind_8ecp(MGC_8ECP_SAP *pSap) +{ + if(pSap == NULL) + return -1; + + sprintf(pSap->sap8ecp.name, "MGC"); + pSap->sap8ecp.update_mg_status = mgc_8ecp_update_mg_status; + pSap->sap8ecp.update_trk_status = mgc_8ecp_update_trk_status; + + pSap->sapIndex= _8ecp_bind(&pSap->sap8ecp); + if(pSap->sapIndex < 0) + { + MGC_ERROR("8ecp %s bind failed!" , pSap->sap8ecp.name); + return -1; + } + + + mgc_8k_tone_card_silent = 0; + + mgc_e1card0_mgNo = 0; + mgc_e1card1_mgNo = 0; + + return pSap->sapIndex; +} + +int mgc_bind_8ecp_setup(void) +{ + MGC_8ECP_SAP *pSap = NULL; + + pSap = &mgc8ecpSap; + + if(mgc_bind_8ecp(pSap)<0) + return -1; + + return 0; +} + +BOOL mgc_8ecp_create(MG_INFO *pMgInfo , MG_ATTR *pMgAttr) +{ + BYTE cardNo; + + if((pMgInfo == NULL)||(pMgAttr == NULL)) + return FALSE; + + if(pMgAttr->ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + cardNo = atoi(pMgAttr->domain); + if(cardNo > 31) + return FALSE; + + _8ecp_createMG(pMgInfo->id, pMgAttr->ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = pMgInfo->id; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = pMgInfo->id; + } + + memcpy(&pMgInfo->mgAttr , pMgAttr , sizeof(MG_ATTR)); + return TRUE; +} + + +BOOL mgc_8ecp_delete(MG_INFO *pMgInfo) +{ + BYTE cardNo; + + if(pMgInfo == NULL) + return FALSE; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + cardNo = atoi(pMgInfo->mgAttr.domain); + if(cardNo > 31) + return FALSE; + + _8ecp_deleteMG(pMgInfo->id, pMgInfo->mgAttr.ip, cardNo); + + if (0 == cardNo) + { + mgc_e1card0_mgNo = 0; + } + else if (1 == cardNo) + { + mgc_e1card1_mgNo = 0; + } + + return TRUE; +} + +BOOL mgc_8ecp_dlcx_chnl(CHNL chnl) +{ + MG_INFO *pMgInfo = NULL; + WORD org, dest; + + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + if(pMgInfo == NULL) + return FALSE; + + if(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + org = (pMgInfo->mgAttr.e1cardNo*8 + chnl.portNo)*32 + chnl.chlNo; + dest = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + + _8ecp_connect_chnl(org, dest, 0); + + return TRUE; +} + +BOOL mgc_8ecp_connect_chnl(CHNL orgChnl, CHNL destChnl, BYTE flag) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + WORD org, dest; + + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + + if((pOrgMgInfo == NULL)||(pDestMgInfo == NULL)) + return FALSE; + + if(pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + if(pDestMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + org = (pOrgMgInfo->mgAttr.e1cardNo*8 + orgChnl.portNo)*32 + orgChnl.chlNo; + dest= (pDestMgInfo->mgAttr.e1cardNo*8 + destChnl.portNo)*32 + destChnl.chlNo; + + if((flag & MGC_CONNECT_SILENT_TONE) == MGC_CONNECT_SILENT_TONE) + dest = (mgc_8k_tone_card_silent * 8 + 7) * 32 + 31; + + _8ecp_connect_chnl(org, dest, 0); + + return TRUE; +} + + +BOOL mgc_8ecp_connect_dtmf(CHNL orgChnl, CHNL destChnl, BYTE digit) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + WORD org, dest; + + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + + if((pOrgMgInfo == NULL)||(pDestMgInfo == NULL)) + return FALSE; + + if(pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + if(pDestMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + org = (pOrgMgInfo->mgAttr.e1cardNo*8 + orgChnl.portNo)*32 + orgChnl.chlNo; + dest= (pDestMgInfo->mgAttr.e1cardNo*8 + destChnl.portNo)*32 + destChnl.chlNo; + + if(digit == 0) + digit = 10; + + _8ecp_connect_chnl(org, dest, digit); + + return TRUE; +} + + +BOOL mgc_8ecp_connect_tone(CHNL orgChnl, CHNL destChnl, BYTE tone , BYTE duration) +{ + MG_INFO *pOrgMgInfo = NULL; + MG_INFO *pDestMgInfo = NULL; + WORD org, dest; + + pOrgMgInfo = mgc_mg_info_get_index_mg(orgChnl.mgNo); + pDestMgInfo = mgc_mg_info_get_index_mg(destChnl.mgNo); + + if((pOrgMgInfo == NULL)||(pDestMgInfo == NULL)) + return FALSE; + + if(pOrgMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + if(pDestMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_8ECP) + return FALSE; + + org = (pOrgMgInfo->mgAttr.e1cardNo*8 + orgChnl.portNo)*32 + orgChnl.chlNo; + dest= (pDestMgInfo->mgAttr.e1cardNo*8 + destChnl.portNo)*32 + destChnl.chlNo; + + _8ecp_connect_tone(org, dest, tone ,duration); + + return TRUE; +} + + diff --git a/omc/plat/mgc_v2/src/mgc_chnl_info.c b/omc/plat/mgc_v2/src/mgc_chnl_info.c new file mode 100644 index 0000000..a5ffb42 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_chnl_info.c @@ -0,0 +1,613 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* mgcPhyPort <---------- mgcChnls <-----------mgcConnections +*/ + + +/********************************************************************************* + * + * This file should provide CHNL_INFO APIs used in MGC module. Every chnl should be attached to + *a phyport if used, and could contain servral connections + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_mgcp.h" + +static CHNL_INFO mgcChnl[MGC_MAX_NUM_OF_CHNL]; +/*----------------------------------------------------------------------- + CHNL_INFO M A N A G E R + ------------------------------------------------------------------------*/ + +/*************************************************************************** + * mgc_chnl_info_init + * ------------------------------------------------------------------------ + * General: init CHNL_INFO structure objcet + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo- the pointer of the CHNL_INFO object which should be init + * id - the id of the CHNL_INFO object + ***************************************************************************/ +void mgc_chnl_info_init(CHNL_INFO *pChnlInfo , int id) +{ + int i; + if((pChnlInfo == NULL)||(id < 0)) + return; + + pChnlInfo->id = id; + pChnlInfo->status = MGC_CHNL_INFO_STATUS_UNDEF; + pChnlInfo->pPhyPort = NULL; + pChnlInfo->connectNum = 0; + pChnlInfo->monFlag = 0; + pChnlInfo->maxConnectNum = 0; + for(i=0 ; ipConnection[i] = NULL; + } + return; +} + +void mgc_chnl_info_setup(void) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + for(i=0 ; ipConnection[i]; + + if(pConnect == NULL) + continue; + + if((mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE)) + { + if(mgc_connect_dlcx_para_create(pConnect , &mgcpPara) == TRUE) + MGCP_req(mgc_mgcp_get_sap_index(), MGCP_CMD_DLCX , 0xFFFF , &mgcpPara); + } + mgc_connect_init(pConnect , pConnect->id); + } + + mgc_chnl_info_init(pChnlInfo , pChnlInfo->id); + return; +} + + +/*************************************************************************** + * mgc_chnl_info_get_unused_chnl + * ------------------------------------------------------------------------ + * General: get a unused CHNL_INFO structure + * Return Value: if failure return NULL , else return a pointer + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +CHNL_INFO *mgc_chnl_info_get_unused_chnl(void) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + for(i=0 ; ipPhyPort != NULL) + continue; + + return pChnlInfo; + } + + return NULL; +} + +/*************************************************************************** + * mgc_chnl_info_attach_to_phy_port + * ------------------------------------------------------------------------ + * General: record the owner phyPort of the chnl + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to record it's own phyPort + * pPhyPort - the pointer of the PHY_PORT_INFO object which is the owner of the chnl + ***************************************************************************/ +BOOL mgc_chnl_info_attach_to_phy_port(CHNL_INFO *pChnlInfo , PHY_PORT_INFO *pPhyPort) +{ + if((pChnlInfo == NULL) || (pPhyPort == NULL)) + return FALSE; + + if(pChnlInfo->status != MGC_CHNL_INFO_STATUS_UNDEF) + return FALSE; + + switch(pPhyPort->portType) + { + case MGC_PHY_PORT_TYPE_E1: + case MGC_PHY_PORT_TYPE_T1: + case MGC_PHY_PORT_TYPE_ANALOG: + case MGC_PHY_VIRTUAL_TYPE_INTERNAL: + pChnlInfo->maxConnectNum = 1; + break; + case MGC_PHY_VIRTUAL_TYPE_TANDEM: + pChnlInfo->maxConnectNum = 2; + break; + case MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE: + pChnlInfo->maxConnectNum = 1; + break; + case MGC_PHY_VIRTUAL_TYPE_ANN: + pChnlInfo->maxConnectNum = MGC_MAX_NUM_OF_CHNL_CON; + break; + default: + pChnlInfo->maxConnectNum = 0; + break; + } + + pChnlInfo->pPhyPort = pPhyPort; + return TRUE; +} + +/*************************************************************************** + * mgc_chnl_info_status_set + * ------------------------------------------------------------------------ + * General: set the status of the CHNL_INFO object + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to be set + * status - the status of the CHNL_INFO object + ***************************************************************************/ +void mgc_chnl_info_status_set(CHNL_INFO *pChnlInfo , MGC_CHNL_INFO_STATUS status) +{ + if(pChnlInfo == NULL) + return; + + pChnlInfo->status = status; + return; +} + + + +/*************************************************************************** + * mgc_chnl_info_find_chnl_of_phy + * ------------------------------------------------------------------------ + * General: get the CHNL_INFO object in the phyPort according to the chnl id + * Return Value: if failure return NULL , else return the pointor of the object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the phyPort which contain the CHNL_INFO objects pointers + * chnlNo - the CHNL_INFO object id + ***************************************************************************/ +CHNL_INFO *mgc_chnl_info_find_chnl_of_phy(PHY_PORT_INFO *pPhyPort , int chnlNo) +{ + + if(pPhyPort == NULL) + return NULL; + + if(chnlNo > MGC_MAX_CHNL_NUM_PER_PHY) + return NULL; + + if(chnlNo >= pPhyPort->chnlNum) + { + MGC_WARN("chnlNo is out of suppose to be "); + } + + return pPhyPort->pChnlInfo[chnlNo]; +} + +/*************************************************************************** + * mgc_chnl_info_get_chnl + * ------------------------------------------------------------------------ + * General: get the CHNL_INFO object according to the CHNL parameters + * Return Value: if failure return NULL , else return the pointor of the object + * ------------------------------------------------------------------------ + * Arguments: + * Input: chnl - CHNL object which contain mgNo , chnlNo, connectNo and phyPort No + ***************************************************************************/ +CHNL_INFO *mgc_chnl_info_get_chnl(CHNL chnl) +{ + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(chnl.mgNo); + if(pMgInfo == NULL) + return NULL; + + pPhyPort = mgc_phy_port_find_port_of_mg(pMgInfo , chnl.portNo); + if(pPhyPort == NULL) + return NULL; + + pChnlInfo = mgc_chnl_info_find_chnl_of_phy(pPhyPort , chnl.chlNo); + if(pChnlInfo == NULL) + return NULL; + + return pChnlInfo; +} + + +/*************************************************************************** + * mgc_chnl_info_attach_connect + * ------------------------------------------------------------------------ + * General: record a connection in the assgined place + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to record the connect + * pConnect - the pointer of the CONNECT_INFO object + * connNo - the place where the CONNECT_INFO should be record in + ***************************************************************************/ +BOOL mgc_chnl_info_attach_connect(CHNL_INFO *pChnlInfo , CONNECT_INFO *pConnect , int connNo) +{ + if((pChnlInfo == NULL)||(pConnect == NULL)) + return FALSE; + + if(connNo >= MGC_MAX_NUM_OF_CHNL_CON) + return FALSE; + + if(mgc_connect_get_status(pConnect)!= MGC_CONNECT_STATUS_UNDEF) + return FALSE; + + if(pChnlInfo->pConnection[connNo] != NULL) + return FALSE; + + if(pChnlInfo->connectNum >= pChnlInfo->maxConnectNum) + return FALSE; + + if(mgc_connect_attach_connect_to_chnl(pConnect , pChnlInfo) == FALSE) + return FALSE; + + pChnlInfo->pConnection[connNo] = pConnect; + pChnlInfo->connectNum++; + mgc_connect_set_status(pConnect , MGC_CONNECT_STATUS_IDLE); + mgc_chnl_info_status_set(pChnlInfo , MGC_CHNL_INFO_STATUS_USED); + return TRUE; +} + +/*************************************************************************** + * mgc_chnl_info_detach_connect + * ------------------------------------------------------------------------ + * General: remove a connect info from the CHNL_INFO object + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to remove connect info + * pConnect - the pointer of the CONNECT_INFO object which need to be remove + ***************************************************************************/ +BOOL mgc_chnl_info_detach_connect(CHNL_INFO *pChnlInfo , CONNECT_INFO *pConnect) +{ + int i; + + if((pChnlInfo == NULL)||(pConnect == NULL)) + return FALSE; + + for(i=0 ; ipConnection[i]) + continue; + + pChnlInfo->pConnection[i] = NULL; + pChnlInfo->connectNum--; + mgc_connect_init(pConnect, pConnect->id); +// MGC_DEBUG("conn[%d] detach from chnlInfo[%d], as connNo %d" , pConnect->id , pChnlInfo->id , i); + return TRUE; + } + + return FALSE; +} + +/*************************************************************************** + * mgc_chnl_info_get_chnl_no_of_phy + * ------------------------------------------------------------------------ + * General: find the record place of the CHNL_INFO object in it's owner phyPort + * Return Value: if failure return -1 , else return the place number + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to be find + * pPhyPort - the pointer of the PHY_PORT_INFO object which contain the CHNL_INFO + ***************************************************************************/ +int mgc_chnl_info_get_chnl_no_of_phy(CHNL_INFO *pChnlInfo , PHY_PORT_INFO *pPhyPort) +{ + int i; + if((pChnlInfo == NULL)||(pPhyPort == NULL)) + return -1; + + for(i=0 ; ipChnlInfo[i]) + continue; + + return i; + } + + return -1; +} + + +/*************************************************************************** + * mgc_chnl_info_assign_connect + * ------------------------------------------------------------------------ + * General: assgin a connection on the assigned place + * Return Value: if failure return NULL, else return the pointer of the connect + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to assign + * connNo - the assgined place NO + ***************************************************************************/ +CONNECT_INFO *mgc_chnl_info_assign_connect(CHNL_INFO *pChnlInfo , int connNo) +{ + CONNECT_INFO *pConnect = NULL; + + if(pChnlInfo == NULL) + return NULL; + + pConnect = mgc_connect_find_connect_of_chnl(pChnlInfo, connNo); + if(pConnect != NULL) + { + //MGC_DEBUG("chnlInfo[%d] already have conn[%d], as connNo %d" , pChnlInfo->id , pConnect->id , connNo); + return pConnect; + } + + if(pChnlInfo->connectNum >= pChnlInfo->maxConnectNum) + return FALSE; + + pConnect = mgc_connect_get_unused(); + if(pConnect == NULL) + return NULL; + + if(mgc_chnl_info_attach_connect(pChnlInfo , pConnect , connNo) == FALSE) + return NULL; + + //MGC_DEBUG("assign unused conn[%d] to chnlInfo[%d]connNo[%d]" , pConnect->id , pChnlInfo->id, connNo); + return pConnect; +} + + +/*************************************************************************** + * mgc_chnl_info_assign_idle_connect + * ------------------------------------------------------------------------ + * General: assgin a connection on the CHNL_INFO object + * Return Value: if failure return NULL, else return the pointer of the connect + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which need to assign + ***************************************************************************/ +CONNECT_INFO *mgc_chnl_info_assign_idle_connect(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + CONNECT_INFO *pConnectTmp = NULL; + + if(pChnlInfo == NULL) + return NULL; + + //MGC_DEBUG("func %s " , __FUNCTION__); + for(i=0 ; ipConnection[i]; + + if(pConnect != NULL) + { + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_IDLE) + continue; + + return pConnect; + } + + pConnectTmp = mgc_chnl_info_assign_connect(pChnlInfo , i); + + if(pConnectTmp == NULL) + continue; + + return pConnectTmp; + } + + return NULL; +} + +void mgc_chnl_info_set_mon(int id, BOOL enable) +{ + if((id < 0) || (id > MGC_MAX_NUM_OF_CHNL)) + return; + + mgcChnl[id].monFlag = enable; +} + +BYTE *mgc_chnl_info_get_res_addr(void) +{ + return (BYTE *)mgcChnl; +} + + +char *mgc_chnl_info_print_codec(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + if(pChnlInfo == NULL) + return "UNKNOWN"; + + if(pChnlInfo->maxConnectNum > 1) + return "UNKNOWN"; + + for(i=0 ; imaxConnectNum ; i++) + { + pConnect = pChnlInfo->pConnection[i]; + if(pConnect != NULL) + break; + } + + if(pConnect == NULL) + return "UNKNOWN"; + + return mgc_mgcp_print_vc_codec(pConnect->mediaAttr.vocoderType); +} + + + +char *mgc_chnl_info_print_remote(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + PUB_SDP_MEDIA *pMedia = NULL; + PUB_SDP_MSG *pSdp = NULL; + static char buf[32]; + + sprintf(buf , "0.0.0.0:0"); + + if(pChnlInfo == NULL) + return buf; + + if(pChnlInfo->maxConnectNum > 1) + return buf; + + for(i=0 ; imaxConnectNum ; i++) + { + pConnect = pChnlInfo->pConnection[i]; + if(pConnect != NULL) + break; + } + + if(pConnect == NULL) + return buf; + + pSdp = &pConnect->mediaAttr.sdp; + pMedia = &pSdp->medias.medias[0]; + if((pMedia->m.port != 0)||(strlen(pSdp->c.addr) != 0)) + sprintf(buf , "%s:%d" , pSdp->c.addr, pMedia->m.port); + return buf; +} + +char *mgc_chnl_info_print_mode(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + if(pChnlInfo == NULL) + return "INACTIVE"; + + if(pChnlInfo->maxConnectNum > 1) + return "INACTIVE"; + + for(i=0 ; imaxConnectNum ; i++) + { + pConnect = pChnlInfo->pConnection[i]; + if(pConnect != NULL) + break; + } + + if(pConnect == NULL) + return "INACTIVE"; + + switch(mgc_connect_get_conn_mode(pConnect)) + { + case MGC_CON_MODE_INACTIVE: + return "INACTIVE"; + case MGC_CON_MODE_RECVONLY: + return "RECVONLY"; + case MGC_CON_MODE_SENDONLY: + return "SENDONLY"; + case MGC_CON_MODE_SENDRECV: + return "SENDRECV"; + default: + break; + } + + return "INACTIVE"; +} + +char *mgc_chnl_info_print_status(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + if(pChnlInfo == NULL) + return "UNDEF"; + + if(pChnlInfo->maxConnectNum > 1) + return "UNDEF"; + + for(i=0 ; imaxConnectNum ; i++) + { + pConnect = pChnlInfo->pConnection[i]; + if(pConnect != NULL) + break; + } + + if(pConnect == NULL) + return "IDLE"; + + switch(mgc_connect_get_status(pConnect)) + { + case MGC_CONNECT_STATUS_IDLE: + return "IDLE"; + case MGC_CONNECT_STATUS_CREATE: + return "CREATE"; + case MGC_CONNECT_STATUS_CREATED: + return "CONNECT"; + case MGC_CONNECT_STATUS_CREATING: + return "CREATING"; + default: + break; + } + + return "UNDEF"; +} + +#ifdef MGC_TEST_ENABLE +int mgc_chnl_info_assigned_num(void) +{ + int i , num; + CHNL_INFO *pChnlInfo = NULL; + + num = 0; + for(i=0 ; ipPhyPort != NULL) + num++; + } + + return num; +} + +#endif diff --git a/omc/plat/mgc_v2/src/mgc_conn_info.c b/omc/plat/mgc_v2/src/mgc_conn_info.c new file mode 100644 index 0000000..8e54e9d --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_conn_info.c @@ -0,0 +1,1724 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* mgcChnl <-----------mgcConnections +*/ + + +/********************************************************************************* + * + * This file should provide CONNECT_INFO object APIs used in MGC module. Every CONNECT_INFO + * object should be attached to CHNL_INFO object + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + +#include "./include/mgc_conn_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_tandem_info.h" +#include "./include/mgc_port_info.h" +/*-----------------------------------------------------------------------*/ +/* GLOABLE definition */ +/*-----------------------------------------------------------------------*/ + +#define MGC_PKG_SIG_G_RT ((MGCP_PKG_G << 8) | MGCP_G_SIG_RT) +#define MGC_PKG_SIG_L_BZ ((MGCP_PKG_L << 8) | MGCP_L_SIG_BZ) +#define MGC_PKG_SIG_L_WT ((MGCP_PKG_L << 8) | MGCP_L_SIG_WT) + + +const WORD MGC_TONE_NO_TO_PKG_SIG[16] = +{ + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, + MGC_PKG_SIG_G_RT, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_WT, + MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ +}; + + +static CONNECT_INFO mgcConnectInfo[MGC_MAX_NUM_OF_CON]; + +/*----------------------------------------------------------------------- + CONNCET_INFO M A N A G E R + ------------------------------------------------------------------------*/ + +char *mgc_connect_print_statuts(MGC_CONNECT_STATUS status) +{ + switch(status) + { + case MGC_CONNECT_STATUS_UNDEF: + return "MGC_CONNECT_STATUS_UNDEF"; + case MGC_CONNECT_STATUS_IDLE: + return "MGC_CONNECT_STATUS_IDLE"; + case MGC_CONNECT_STATUS_CREATING: + return "MGC_CONNECT_STATUS_CREATING"; + case MGC_CONNECT_STATUS_CREATED: + return "MGC_CONNECT_STATUS_CREATED"; + case MGC_CONNECT_STATUS_CREATE: + return "MGC_CONNECT_STATUS_CREATE"; + } + return "MGC_CONNECT_STATUS_UNKNOW"; +} + + +void mgc_connect_codec_list_init(MGC_CODEC_LIST *pList) +{ + int i; + + if(pList == NULL) + return ; + + for(i=0 ; icodec[i] = MGC_VCTYPE_UNSUPPORT; + + pList->num = 0; + pList->priority = 0; + return; +} + +/*************************************************************************** + * mgc_connect_init + * ------------------------------------------------------------------------ + * General: init CONNCET_INFO structure objcet + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect- the pointer of the CONNCET_INFO object which should be init + * id - the id of the CHNL_INFO object + ***************************************************************************/ +void mgc_connect_init(CONNECT_INFO *pConnect , int id) +{ + if((pConnect == NULL) || (id < 0)) + return; + + pConnect->id = id; + pConnect->flag = 0; + pConnect->status = MGC_CHNL_INFO_STATUS_UNDEF; + pConnect->pChnlInfo = NULL; + pConnect->pOperStep= NULL; +#ifdef MGC_REC_PORT + pConnect->pPrePortInfo= NULL; +#endif + pConnect->pTandem = NULL; + mgc_connect_codec_list_init(&pConnect->codecList); + memset(&pConnect->mediaAttr , 0 , sizeof(MEDIA_ATTR)); + memset(&pConnect->operRec , 0 , sizeof(OPER_REC)); + memset(&pConnect->mgcpRec , 0 , sizeof(MGCP_REC_TAG)); + return; +} + +void mgc_connect_setup(void) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + for(i=0 ; ipChnlInfo != NULL) + continue; + + if(pConnect->pOperStep!= NULL) + continue; + + pConnectTmp = pConnect; + index = i; + break; + + }while(i != index); + + return pConnectTmp; +} + +int mgc_connect_unused_num(void) +{ + int i , num; + CONNECT_INFO *pConnect = NULL; + + num = 0; + for(i=0 ; ipChnlInfo != NULL) + continue; + + num++; + } + + return num; +} + +/*************************************************************************** + * mgc_connect_attach_step_info + * ------------------------------------------------------------------------ + * General: record the operate step which will do sth on this CONNCET_INFO object + * Return Value: if failure return FALSE , else return TRUE. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the pointer of the CONNCET_INFO object which will be used + * pOperStep - the pointer of the step which will operate on the conncet + ***************************************************************************/ +BOOL mgc_connect_attach_step_info(CONNECT_INFO *pConnect , MGCF_OPER_STEP *pOperStep) +{ + if((pConnect == NULL)||(pOperStep == NULL)) + return FALSE; + + if(pConnect->pOperStep != NULL) + return FALSE; + + pConnect->pOperStep = pOperStep; + return TRUE; +} + +BOOL mgc_connect_dettach_step_info(CONNECT_INFO *pConnect) +{ + if(pConnect == NULL) + return FALSE; + + pConnect->pOperStep = NULL; + return TRUE; +} + +/*************************************************************************** + * mgc_connect_get_step_info + * ------------------------------------------------------------------------ + * General: get the step info related to this conncetion + * Return Value: if failure return NULL , else return the pointer of the operate step. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the pointer of the CONNCET_INFO object + ***************************************************************************/ +MGCF_OPER_STEP *mgc_connect_get_step_info(CONNECT_INFO *pConnect) +{ + if(pConnect == NULL) + return NULL; + + return pConnect->pOperStep; +} + +/*************************************************************************** + * mgc_connect_find_connect_of_chnl + * ------------------------------------------------------------------------ + * General: get the CONNCET_INFO object in the CHNL_INFO object + * Return Value: if failure return NULL , else return the pointer of the CONNCET_INFO object. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pChnlInfo - the pointer of the CHNL_INFO object which contain the CONNCET_INFO ojbects + * connNo - the place where record CONNECT_INFO object + ***************************************************************************/ +CONNECT_INFO *mgc_connect_find_connect_of_chnl(CHNL_INFO *pChnlInfo , int connNo) +{ + CONNECT_INFO *pConnect = NULL; + + if(pChnlInfo == NULL) + return NULL; + + if((connNo < 0)||(connNo > MGC_MAX_NUM_OF_CHNL_CON)) + return NULL; + + pConnect = pChnlInfo->pConnection[connNo]; + if(pConnect == NULL) + return NULL; + + return pConnect; +} + +/*************************************************************************** + * mgc_connect_attach_connect_to_chnl + * ------------------------------------------------------------------------ + * General: record the owner of the CONNCET_INFO object + * Return Value: if failure return FALSE , else return TRUE. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pChnlInfo - the pointer of the CHNL_INFO object which contain the CONNCET_INFO object + ***************************************************************************/ +BOOL mgc_connect_attach_connect_to_chnl(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo) +{ + if((pConnect == NULL)||(pChnlInfo == NULL)) + return FALSE; + + if(pConnect->pChnlInfo != NULL) + return FALSE; + + pConnect->pChnlInfo = pChnlInfo; + return TRUE; +} + +/*************************************************************************** + * mgc_connect_set_status + * ------------------------------------------------------------------------ + * General: set the status of the CONNCET_INFO object + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * status - the status of the CONNCET_INFO objecct + ***************************************************************************/ +void mgc_connect_set_status(CONNECT_INFO *pConnect , MGC_CONNECT_STATUS status) +{ + if(pConnect == NULL) + return; + + if((pConnect->status != status)&&(pConnect->status != MGC_CONNECT_STATUS_UNDEF)) + { + MGC_DEBUG("conn[%d] state %s =>> %s" , + pConnect->id , mgc_connect_print_statuts(pConnect->status) , mgc_connect_print_statuts(status)); + } + pConnect->status = status; +} + +/*************************************************************************** + * mgc_connect_get_status + * ------------------------------------------------------------------------ + * General: get the status of the CONNCET_INFO object + * Return Value: return the status of the CONNCET_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +MGC_CONNECT_STATUS mgc_connect_get_status(CONNECT_INFO *pConnect) +{ + if(pConnect == NULL) + return MGC_CONNECT_STATUS_UNDEF; + + return pConnect->status; +} + +/*************************************************************************** + * mgc_connect_set_dtmf + * ------------------------------------------------------------------------ + * General: set the dtmf info in the conncet + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * dtmfNo - the dtmf + ***************************************************************************/ +BOOL mgc_connect_set_dtmf(CONNECT_INFO *pConnect , BYTE dtmfNo) +{ + BYTE digit; + MEDIA_ATTR *pMedia = NULL; + + if(pConnect == NULL) + return FALSE; + + digit = dtmfNo; + if(digit == 0) + digit = 10; + + pMedia = &pConnect->mediaAttr; + pMedia->pkgSignal.pkg = MGCP_PKG_D; + pMedia->pkgSignal.signal = digit; + return TRUE; +} + +/*************************************************************************** + * mgc_connect_clear_tone + * ------------------------------------------------------------------------ + * General: clear tone info in the CONNCET_INFO object + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +BOOL mgc_connect_clear_tone(CONNECT_INFO *pConnect) +{ + MEDIA_ATTR *pMedia = NULL; + if(pConnect == NULL) + return FALSE; + + pMedia = &pConnect->mediaAttr; + pMedia->pkgSignal.pkg = 0; + pMedia->pkgSignal.signal = 0; + return TRUE; +} + +/*************************************************************************** + * mgc_connect_set_tone + * ------------------------------------------------------------------------ + * General: set tone info in the CONNCET_INFO object + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * toneNo - tone id + ***************************************************************************/ +BOOL mgc_connect_set_tone(CONNECT_INFO *pConnect , BYTE toneNo) +{ + MEDIA_ATTR *pMedia = NULL; + WORD pkgSignal; + if(pConnect == NULL) + return FALSE; + + pkgSignal = MGC_TONE_NO_TO_PKG_SIG[toneNo]; + pMedia = &pConnect->mediaAttr; + pMedia->pkgSignal.pkg = (pkgSignal&0xFF00) >> 8; + pMedia->pkgSignal.signal = (pkgSignal&0x00FF); + MGC_DEBUG("conn[%d] set pkg[%d]sig[%d]" , pConnect->id , pMedia->pkgSignal.pkg , pMedia->pkgSignal.signal); + return TRUE; +} + +/*************************************************************************** + * mgc_connect_set_tone + * ------------------------------------------------------------------------ + * General: set request on the specific connect + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pkg - the name of the package + * req - the name of the request + ***************************************************************************/ +BOOL mgc_connect_set_req(CONNECT_INFO *pConnect , BYTE pkg , BYTE req) +{ + MEDIA_ATTR *pMedia = NULL; + + if(pConnect == NULL) + return FALSE; + + pMedia = &pConnect->mediaAttr; + pMedia->pkgReq.pkg = pkg; + pMedia->pkgReq.req = req; + MGC_DEBUG("conn[%d] set pkg[%d]req[%d]" , pConnect->id , pMedia->pkgReq.pkg , pMedia->pkgReq.req); + return TRUE; +} + + + +/*************************************************************************** + * mgc_connect_get_own_chnl_info + * ------------------------------------------------------------------------ + * General: get the owner CHNL_INFO object of the CONNCET_INFO object + * Return Value: if failure return NULL , else return the pointer of the CHNL_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +CHNL_INFO *mgc_connect_get_own_chnl_info(CONNECT_INFO *pConnect) +{ + CHNL_INFO *pChnlInfo = NULL; + + if(pConnect == NULL) + return NULL; + + pChnlInfo = pConnect->pChnlInfo; + if(pChnlInfo == NULL) + return NULL; + + return pChnlInfo; +} + + + +/*************************************************************************** + * mgc_connect_get_own_phy_port_info + * ------------------------------------------------------------------------ + * General: get the owner phyPort of the CONNCET_INFO object + * Return Value: if failure return NULL , else return the pointer of the PHY_PORT_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +PHY_PORT_INFO *mgc_connect_get_own_phy_port_info(CONNECT_INFO *pConnect) +{ + CHNL_INFO *pChnlInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + if(pConnect == NULL) + return NULL; + + pChnlInfo = pConnect->pChnlInfo; + if(pChnlInfo == NULL) + return NULL; + + pPhyPort = pChnlInfo->pPhyPort; + if(pPhyPort == NULL) + return NULL; + + return pPhyPort; +} + + +/*************************************************************************** + * mgc_connect_get_conn_report_sap + * ------------------------------------------------------------------------ + * General: get the MGC_SAP info from the CONNCET_INFO object + * Return Value: if failure return NULL , else return the pointer of the MGC_SAP object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +MGC_SAP *mgc_connect_get_conn_report_sap(CONNECT_INFO *pConnect) +{ + PHY_PORT_INFO *pPhyPort = NULL; + + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + if(pPhyPort == NULL) + return NULL; + + return pPhyPort->pMgcSap; +} + +/*************************************************************************** + * mgc_connect_get_own_mg_info + * ------------------------------------------------------------------------ + * General: get the owner MG_INFO object of the CONNCET_INFO object + * Return Value: if failure return NULL , else return the pointer of the MG_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +MG_INFO *mgc_connect_get_own_mg_info(CONNECT_INFO *pConnect) +{ + CHNL_INFO *pChnlInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + MG_INFO *pMgInfo = NULL; + + if(pConnect == NULL) + return NULL; + + pChnlInfo = pConnect->pChnlInfo; + if(pChnlInfo == NULL) + return NULL; + + pPhyPort = pChnlInfo->pPhyPort; + if(pPhyPort == NULL) + return NULL; + + pMgInfo = pPhyPort->pMgInfo; + if(pMgInfo == NULL) + return NULL; + + return pMgInfo; +} + + +/*************************************************************************** + * mgc_connect_get_connNo_of_chnl_info + * ------------------------------------------------------------------------ + * General: get the record place of the CONNCET_INFO in it's owner CHNL_INFO + * Return Value: if failure return -1 , else return place number + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pChnlInfo - the pointer of the CHNL_INFO object + ***************************************************************************/ +int mgc_connect_get_connNo_of_chnl_info(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo) +{ + int i; + + if((pConnect == NULL)||(pChnlInfo == NULL)) + return -1; + + for(i=0 ; ipConnection[i] == NULL) + continue; + + if(pChnlInfo->pConnection[i] != pConnect) + continue; + + return i; + } + + return -1; +} + + +/*************************************************************************** + * mgc_connect_attr_init + * ------------------------------------------------------------------------ + * General: init the attribute of the connect + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +void mgc_connect_attr_init(CONNECT_INFO *pConnect) +{ + MG_INFO *pMgInfo = NULL; + MG_INFO *pTarMgInfo = NULL; + MG_ATTR *pMgAttr = NULL; + MEDIA_ATTR *pMediaAttr = NULL; + MGCF_STEP_INFO *pStepInfo = NULL; + MGC_CODEC_LIST *pCodecList = NULL; + + if((pConnect == NULL)||(pConnect->pOperStep == NULL)) + return; + + pMediaAttr = &pConnect->mediaAttr; + pStepInfo = &pConnect->pOperStep->stepInfo; + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return; + + pMgAttr = &pMgInfo->mgAttr; + pCodecList = &pStepInfo->codecList; + mgc_connect_set_conn_mode(pConnect, pStepInfo->mode); + + if(pConnect->codecList.num == 0) + { + mgc_mgcp_match_codec_list(&pConnect->codecList, &pConnect->codecList, &pMgAttr->codecList); + } + + if(pMediaAttr->ptime == 0) + pMediaAttr->ptime = pMgInfo->mgAttr.ptime; + + if((mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_TX) + ||(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_RX)) + { + pTarMgInfo = mgc_connect_get_own_mg_info(pConnect->pTandem->pTconn); + + if(pConnect->pTandem->pTconn == NULL) + { + MGC_ERROR("tandem[%d] lost TarConn", pConnect->pTandem->id); + } + else if(mgc_connect_get_status(pConnect->pTandem->pTconn) == MGC_CONNECT_STATUS_CREATED) + { + memcpy(&pConnect->codecList , &pConnect->pTandem->pTconn->codecList , sizeof(MGC_CODEC_LIST)); + pMediaAttr->ptime = pConnect->mediaAttr.ptime; + } + else + { + if(pTarMgInfo != NULL) + { + memcpy(&pConnect->codecList , &pTarMgInfo->mgAttr.codecList , sizeof(MGC_CODEC_LIST)); + pMediaAttr->ptime = pTarMgInfo->mgAttr.ptime; + } + } + + } + + if(pCodecList->num != 0) + { + memcpy(&pConnect->codecList , pCodecList , sizeof(MGC_CODEC_LIST)); + } + + pMediaAttr->vocoderType = pConnect->codecList.codec[0]; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) != MGC_TANDEM_CONN_POS_SUR) + sprintf(pMediaAttr->callId , "%x%lx" , pConnect->id ,time(NULL)); + + return; +} + + +/*************************************************************************** + * mgc_connect_attr_negotiate + * ------------------------------------------------------------------------ + * General: do media info negotiate, this function should be used only when conncet related step + opera is set. + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + ***************************************************************************/ +BOOL mgc_connect_attr_negotiate(CONNECT_INFO *pConnect) +{ + MGC_CODEC_LIST codecList; + CONNECT_INFO *pConnectTmp = NULL; + MGCF_STEP_INFO *pStepInfo = NULL; + int ret = -1; + + if((pConnect == NULL)||(pConnect->pOperStep== NULL)) + return FALSE; + + pStepInfo = &(pConnect->pOperStep->stepInfo); + pConnectTmp = pStepInfo->pPeerConn; + mgc_connect_codec_list_init(&codecList); + MGC_DEBUG("enter %s " , __FUNCTION__); + if(pConnectTmp == NULL) + { + MGC_ERROR("conn[%d] lost peer connection info" , pConnectTmp->id); + return FALSE; + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_TAR) + { + if(mgc_tandem_info_get_conn_pos(pConnectTmp->pTandem, pConnectTmp) != MGC_TANDEM_CONN_POS_TX) + { + MGC_ERROR("conn[%d] is not a TxConn in Tandem" , pConnectTmp->id); + return FALSE; + } + + if(pConnect->pTandem->pAconn != NULL) + { + pConnectTmp = pConnect->pTandem->pAconn; + } + } + else if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_get_conn_pos(pConnectTmp->pTandem, pConnectTmp) != MGC_TANDEM_CONN_POS_RX) + { + MGC_ERROR("conn[%d] is not a RxConn in Tandem" , pConnectTmp->id); + return FALSE; + } + + if(pConnect->pTandem->pTconn != NULL) + { + pConnectTmp = pConnect->pTandem->pTconn; + } + } + else if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_TX) + { + if(pConnect->pTandem->pTconn != NULL) + { + pConnectTmp = pConnect->pTandem->pTconn; + memcpy(&pConnect->codecList , &pConnectTmp->codecList , sizeof(MGC_CODEC_LIST)); + } + } + else if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_RX) + { + + if(pConnect->pTandem->pAconn!= NULL) + { + pConnectTmp = pConnect->pTandem->pAconn; + memcpy(&pConnect->codecList , &pConnectTmp->codecList , sizeof(MGC_CODEC_LIST)); + } + + } + else if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_SUR) + { + if(strcmp(pConnect->mediaAttr.callId , pConnect->pTandem->pTxconn->mediaAttr.callId) == 0) + { + memcpy(&pConnect->codecList , &pConnect->pTandem->pTxconn->codecList , sizeof(MGC_CODEC_LIST)); + } + else if(strcmp(pConnect->mediaAttr.callId , pConnect->pTandem->pRxconn->mediaAttr.callId) == 0) + { + memcpy(&pConnect->codecList , &pConnect->pTandem->pRxconn->codecList , sizeof(MGC_CODEC_LIST)); + } + else + { + MGC_ERROR("SurConn[%d] is illegal!" , pConnect->id); + return FALSE; + } + } + + if(pConnectTmp != NULL) + { + if(pConnect->mediaAttr.ptime > pConnectTmp->mediaAttr.ptime) + { + pConnect->mediaAttr.ptime = pConnect->mediaAttr.ptime; + } + else + { + pConnect->mediaAttr.ptime = pConnectTmp->mediaAttr.ptime; + } + } + + if(pConnect->mediaAttr.ptime == 0) + { + MGC_WARN("ptime negotiate failed!"); + pConnect->mediaAttr.ptime = 20; + } + + pConnectTmp = pStepInfo->pPeerConn; + ret = mgc_mgcp_match_codec_list(&codecList , &pConnect->codecList , &pConnectTmp->codecList); + + if(ret < 0) + return FALSE; + + memcpy(&pConnect->codecList , &codecList , sizeof(MGC_CODEC_LIST)); + pConnect->mediaAttr.vocoderType = codecList.codec[0]; + return TRUE; +} + +BOOL mgc_connect_set_conn_mode(CONNECT_INFO *pConnect , MGC_CON_MODE mode) +{ + if(pConnect == NULL) + return FALSE; + + if(mode == MGC_CON_MODE_OWN) + { + MGC_DEBUG("conn[%d] keep own mode %s" , pConnect->id , mgc_mgcp_print_mgc_mode(pConnect->mediaAttr.conMode)); + return TRUE; + } + + if(mode != pConnect->mediaAttr.conMode) + { + MGC_DEBUG("conn[%d] mode %s ==>> %s" , + pConnect->id , mgc_mgcp_print_mgc_mode(pConnect->mediaAttr.conMode ), mgc_mgcp_print_mgc_mode(mode)); + } + + pConnect->mediaAttr.conMode = mode; + return TRUE; +} + +MGC_CON_MODE mgc_connect_get_conn_mode(CONNECT_INFO *pConnect) +{ + if(pConnect == NULL) + return MGC_CON_MODE_UNDEF; + + return pConnect->mediaAttr.conMode; +} + + +/*************************************************************************** + * mgc_connect_rqnt_para_create + * ------------------------------------------------------------------------ + * General: create rqnt req msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be write + ***************************************************************************/ +BOOL mgc_connect_rqnt_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + /*set dest ip*/ + if(mgc_mgcp_create_connect_dest_ip(pConnect , pPara) == FALSE) + return FALSE; + + /*set port*/ + if(mgc_mgcp_create_connect_port(pConnect , pPara) == FALSE) + return FALSE; + + /*create sl*/ + if(mgc_mgcp_create_connect_req_start_line(pConnect , pPara) == FALSE) + return FALSE; + + /*create pkg signal*/ + if(mgc_mgcp_create_connect_pkg_sig(pConnect , pPara) == FALSE) + return FALSE; + + /*create pkg request*/ + if(mgc_mgcp_create_connect_pkg_req(pConnect , pPara) == FALSE) + return FALSE; + + return TRUE; +} + + +/*************************************************************************** + * mgc_connect_auep_para_create + * ------------------------------------------------------------------------ + * General: create auep req msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be write + ***************************************************************************/ +BOOL mgc_connect_auep_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + /*set dest ip*/ + if(mgc_mgcp_create_connect_dest_ip(pConnect , pPara) == FALSE) + return FALSE; + + /*set port*/ + if(mgc_mgcp_create_connect_port(pConnect , pPara) == FALSE) + return FALSE; + + /*create sl*/ + if(mgc_mgcp_create_connect_req_start_line(pConnect , pPara) == FALSE) + return FALSE; + + pPara->sl.trkNum = 0; + pPara->sl.chlNum = 1; + return TRUE; +} + +/*************************************************************************** + * mgc_connect_crcx_para_create + * ------------------------------------------------------------------------ + * General: create crcx req msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be write + ***************************************************************************/ +BOOL mgc_connect_crcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MG_INFO *pMgInfo = NULL; + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + /*set dest ip*/ + if(mgc_mgcp_create_connect_dest_ip(pConnect , pPara) == FALSE) + return FALSE; + + /*set port*/ + if(mgc_mgcp_create_connect_port(pConnect , pPara) == FALSE) + return FALSE; + + /*create sl*/ + if(mgc_mgcp_create_connect_req_start_line(pConnect , pPara) == FALSE) + return FALSE; + + /*create call id*/ + if(mgc_mgcp_create_connect_call_id(pConnect , pPara) == FALSE) + return FALSE; + + /*create conn mode*/ + if(mgc_mgcp_create_connect_con_mode(pConnect , pPara) == FALSE) + return FALSE; + + /*create local opt*/ + if(mgc_mgcp_create_connect_local_opt(pConnect , pPara) == FALSE) + return FALSE; + + /*special process for AAS crcx*/ + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return FALSE; + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_ANN) + { + if(mgc_mgcp_create_connect_sdp(pConnect, pPara) == FALSE) + return TRUE; + } + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_mdcx_para_create + * ------------------------------------------------------------------------ + * General: create mdcx req msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be write + ***************************************************************************/ +BOOL mgc_connect_mdcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCF_OPER_STEP *pOperStep = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + return FALSE; + + pOperStep = pConnect->pOperStep; + if(pOperStep == NULL) + return FALSE; + + mgc_connect_attr_negotiate(pConnect); + + /*set dest ip*/ + if(mgc_mgcp_create_connect_dest_ip(pConnect , pPara) == FALSE) + return FALSE; + + /*set port*/ + if(mgc_mgcp_create_connect_port(pConnect , pPara) == FALSE) + return FALSE; + + /*create sl*/ + if(mgc_mgcp_create_connect_req_start_line(pConnect , pPara) == FALSE) + return FALSE; + + /*create call id*/ + if(mgc_mgcp_create_connect_call_id(pConnect , pPara) == FALSE) + return FALSE; + + /*create conn mode*/ + if(mgc_mgcp_create_connect_con_mode(pConnect , pPara) == FALSE) + return FALSE; + + /*create conn id*/ + if(mgc_mgcp_create_connect_con_id(pConnect , pPara) == FALSE) + return FALSE; + + /*create local opt*/ + if(mgc_mgcp_create_connect_local_opt(pConnect , pPara) == FALSE) + return FALSE; + + /*create pkg signal*/ + if(mgc_mgcp_create_connect_pkg_sig(pConnect , pPara) == FALSE) + return FALSE; + + /*create sdp*/ + if(mgc_mgcp_create_connect_sdp(pConnect , pPara) == FALSE) + return FALSE; + + if(( pConnect->flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + pPara->flag |= MGCP_PARA_FLAG_TFO; + } + + return TRUE; +} + + +/*************************************************************************** + * mgc_connect_dlcx_para_create + * ------------------------------------------------------------------------ + * General: create dlcx req msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be write + ***************************************************************************/ +BOOL mgc_connect_dlcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + /*set dest ip*/ + if(mgc_mgcp_create_connect_dest_ip(pConnect , pPara) == FALSE) + return FALSE; + + /*set port*/ + if(mgc_mgcp_create_connect_port(pConnect , pPara) == FALSE) + return FALSE; + + /*create sl*/ + if(mgc_mgcp_create_connect_req_start_line(pConnect , pPara) == FALSE) + return FALSE; + + /*create call id*/ + if(mgc_mgcp_create_connect_call_id(pConnect , pPara) == FALSE) + return FALSE; + + /*create conn id*/ + if(mgc_mgcp_create_connect_con_id(pConnect , pPara) == FALSE) + return FALSE; + + /*create pkg signal*/ + if(mgc_mgcp_create_connect_pkg_sig(pConnect , pPara) == FALSE) + return FALSE; + + return TRUE; +} + + +/*************************************************************************** + * mgc_connect_crcx_resp_parse_para + * ------------------------------------------------------------------------ + * General: parse crcx response + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_crcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + + /*record connection id*/ + if((pPara->flag & MGCP_PARA_FLAG_I) == MGCP_PARA_FLAG_I ) + { + sprintf(pConnect->mediaAttr.conId , "%s" , pPara->i.conId); + } + + if((pPara->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + pConnect->mediaAttr.pkgEvent.pkg = pPara->o.package; + pConnect->mediaAttr.pkgEvent.event = pPara->o.event; + } + + if((pPara->flag & MGCP_PARA_FLAG_SDP) == MGCP_PARA_FLAG_SDP) + { + memcpy(&(pConnect->mediaAttr.sdp) , &pPara->sdp , sizeof(PUB_SDP_MSG)); + } + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_mdcx_resp_parse_para + * ------------------------------------------------------------------------ + * General: parse mdcx response + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_mdcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + + /*record connection id*/ + if((pPara->flag & MGCP_PARA_FLAG_I) == MGCP_PARA_FLAG_I ) + { + sprintf(pConnect->mediaAttr.conId , "%s" , pPara->i.conId); + } + + if((pPara->flag & MGCP_PARA_FLAG_O) == MGCP_PARA_FLAG_O) + { + pConnect->mediaAttr.pkgEvent.pkg = pPara->o.package; + pConnect->mediaAttr.pkgEvent.event = pPara->o.event; + + } + + if((pPara->flag & MGCP_PARA_FLAG_SDP) == MGCP_PARA_FLAG_SDP) + { + memcpy(&(pConnect->mediaAttr.sdp) , &pPara->sdp , sizeof(PUB_SDP_MSG)); + } + + return TRUE; +} + + +CONNECT_INFO *mgc_connect_find_conn_by_conid(MGCP_PARA *pPara) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + if(pPara == NULL) + return NULL; + + if(strlen(pPara->i.conId) == 0) + return NULL; + + for( i=0 ; ipChnlInfo == NULL) + continue; + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + continue; + + if(strcmp(pConnect->mediaAttr.conId , pPara->i.conId) != 0) + continue; + + return pConnect; + } + + return pConnect; +} + + +/*************************************************************************** + * mgc_connect_assign_conn_by_para + * ------------------------------------------------------------------------ + * General: assign an conncet to handle incoming MGCP req + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPara - the MGCP para need to be parsed + ***************************************************************************/ +CONNECT_INFO *mgc_connect_assign_conn_by_para(MGCP_PARA *pPara) +{ + PHY_PORT_INFO *pPhyPort = NULL; + CONNECT_INFO *pConnect = NULL; + CHNL_INFO *pChnlInfo = NULL; + MGCP_SL *pSl = NULL; + + if(pPara == NULL) + return NULL; + + pSl = &pPara->sl; + MGC_DEBUG("enter %s " , __FUNCTION__); + MGC_DEBUG("alloc res to mg:%s port %d chnl %d" , pSl->mgName, pSl->trkNum, pSl->chlNum); + if(pSl->epNameMethod == MGCP_EP_NAME_STRUCTURED) + { + pPhyPort = mgc_mg_info_find_port_by_name_and_portNo(pSl->mgName, pSl->trkNum, pPara->localPort); + } + else + { + pPhyPort = mgc_mg_info_find_port_by_name(pSl->mgName , pPara->localPort); + } + if(pPhyPort == NULL) + return NULL; + + pChnlInfo = mgc_chnl_info_find_chnl_of_phy(pPhyPort, pSl->chlNum); + if(pChnlInfo == NULL) + return NULL; + + pConnect = mgc_chnl_info_assign_idle_connect(pChnlInfo); + if(pConnect == NULL) + return NULL; + + MGC_DEBUG("conn[%d] is assigend" , pConnect->id); + return pConnect; +} + + + + +/*************************************************************************** + * mgc_connect_crcx_req_parse_para + * ------------------------------------------------------------------------ + * General: parse crcx req + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_crcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if(mgc_mgcp_parse_connect_local_opt(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_mode(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_call_id(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_event(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_sig(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_sdp(pConnect, pPara) == FALSE) + return FALSE; + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_mdcx_req_parse_para + * ------------------------------------------------------------------------ + * General: parse mdcx req + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_mdcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if(mgc_mgcp_parse_connect_local_opt(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_mode(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_call_id(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_event(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_sig(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_sdp(pConnect, pPara) == FALSE) + return FALSE; + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_req_parse_para + * ------------------------------------------------------------------------ + * General: parse req + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if(mgc_mgcp_parse_connect_local_opt(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_mode(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_call_id(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_event(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_pkg_sig(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_parse_connect_sdp(pConnect, pPara) == FALSE) + return FALSE; + + return TRUE; +} + + +/*************************************************************************** + * mgc_connect_rec_mgcp_tag + * ------------------------------------------------------------------------ + * General: record MGCP msg tag + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be record + ***************************************************************************/ +BOOL mgc_connect_rec_mgcp_tag(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCP_REC_TAG *pRecTag = NULL; + PUB_SDP_MSG *pSdp = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + pRecTag = &pConnect->mgcpRec; + pSdp = &pPara->sdp; + memcpy(&pRecTag->mode , &pPara->m , sizeof(MGCP_M)); + memcpy(&pRecTag->c, &pSdp->c, sizeof(MGCP_C)); + memcpy(&pRecTag->m, &(pSdp->medias.medias[0]) , sizeof(PUB_SDP_MEDIA)); + + if(pConnect->pTandem == NULL) + return TRUE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_RX) + { + sprintf(pRecTag->esCci , "%s" , pTandem->escci); + } + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_TX) + { + sprintf(pRecTag->esCci , "%s" , pTandem->escci); + } + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_is_mgcp_tag_same + * ------------------------------------------------------------------------ + * General: check whether the MGCP msg it the same with the fomer one + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_is_mgcp_tag_same(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCP_REC_TAG *pRecTag = NULL; + PUB_SDP_MSG *pSdp = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + pRecTag = &pConnect->mgcpRec; + pSdp = &pPara->sdp; + + if(pRecTag->mode.mode != pPara->m.mode) + return FALSE; + + if(pRecTag->m.m.port != pSdp->medias.medias[0].m.port ) + return FALSE; + + if(pRecTag->m.m.payloads[0] != pSdp->medias.medias[0].m.payloads[0]) + return FALSE; + + if(strcmp(pRecTag->c.addr , pSdp->c.addr) != 0) + return FALSE; + + if(pConnect->pTandem == NULL) + return TRUE; + + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_RX) + { + if(strcmp(pRecTag->esCci , pTandem->escci) != 0) + return FALSE; + } + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_TX) + { + if(strcmp(pRecTag->esCci , pTandem->escci) != 0) + return FALSE; + } + + return TRUE; +} + +/*************************************************************************** + * mgc_connect_is_conn_need_update + * ------------------------------------------------------------------------ + * General: check whether the connection need to update + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnct - the pointer of the CONNCET_INFO object + * pPara - the MGCP para need to be parsed + ***************************************************************************/ +BOOL mgc_connect_is_conn_need_update(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if(mgc_connect_is_mgcp_tag_same(pConnect , pPara) == TRUE) + return FALSE; + + mgc_connect_rec_mgcp_tag(pConnect, pPara); + return TRUE; +} + + +BOOL mgc_connect_add_auep(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_IDLE) + return TRUE; + + if(pConnect->pOperStep != NULL) + return TRUE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_AUEP, NULL, MGC_OPERA_NO_DELAY, MGC_CON_MODE_RECVONLY, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_connect_add_crcx_with_mode(CONNECT_INFO *pConnect, MGC_CON_MODE mode ,PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + if((mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE)) + return TRUE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_CRCX, NULL, MGC_OPERA_NO_DELAY, mode, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + + +BOOL mgc_connect_add_crcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + if((mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE)) + return TRUE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_CRCX, NULL, MGC_OPERA_NO_DELAY, MGC_CON_MODE_RECVONLY, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_connect_add_crcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo) +{ + MG_INFO *pPeerMgInfo; + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + pPeerMgInfo = mgc_connect_get_own_mg_info(pPeerConnect); + if(pPeerMgInfo == NULL) + { + MGC_ERROR("lost peerConn in aas"); + return FALSE; + } + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_CRCX, pPeerConnect, MGC_OPERA_NO_DELAY, MGC_CON_MODE_SENDRECV, + NULL, NULL, NULL); + + switch(mgc_connect_get_status(pPeerConnect)) + { + case MGC_CONNECT_STATUS_CREATING: + case MGC_CONNECT_STATUS_CREATE: + case MGC_CONNECT_STATUS_CREATED: + memcpy(&stepInfo.codecList , &pPeerConnect->codecList , sizeof(MGC_CODEC_LIST)); + pConnect->mediaAttr.ptime = pPeerConnect->mediaAttr.ptime; + break; + case MGC_CONNECT_STATUS_IDLE: + memcpy(&stepInfo.codecList , &pPeerMgInfo->mgAttr.codecList , sizeof(MGC_CODEC_LIST)); + pConnect->mediaAttr.ptime = pPeerMgInfo->mgAttr.ptime; + break; + default: + MGC_ERROR("conn[%d] is not allocated ", pPeerConnect->id); + return FALSE; + } + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + +BOOL mgc_connect_add_mdcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_MDCX, pPeerConnect, MGC_OPERA_NO_DELAY, MGC_CON_MODE_OWN, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; + +} + + +BOOL mgc_connect_add_dlcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_DLCX, NULL, MGC_OPERA_NO_DELAY, MGC_CON_MODE_INACTIVE, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_connect_add_mdcx(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect , MGC_CON_MODE mode, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_MDCX, pPeerConnect, MGC_OPERA_NO_DELAY, mode, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_connect_add_nop_with_delay(CONNECT_INFO *pConnect, DWORD delay , PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_NOP, NULL, delay, MGC_CON_MODE_OWN, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + MGC_DEBUG("conn[%d] will suspend %ld" , pConnect->id , delay); + return TRUE; +} + +BOOL mgc_connect_add_nop(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo , MGC_CMD_NOP, NULL, MGC_OPERA_NO_DELAY, MGC_CON_MODE_OWN, + NULL, NULL, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + + +BOOL mgc_connect_add_rqnt(CONNECT_INFO *pConnect, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo, MGC_CMD_RQNT, NULL, MGC_OPERA_NO_DELAY, MGC_CON_MODE_SENDRECV, + pPkgEvent, pPkgSig, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_connect_add_rqnt_with_delay(CONNECT_INFO *pConnect, WORD delay, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo) +{ + MGCF_STEP_INFO stepInfo; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_own_chnl_info(pConnect) == NULL) + return FALSE; + + mgc_port_info_set_step_info(&stepInfo, MGC_CMD_RQNT, NULL, delay, MGC_CON_MODE_SENDRECV, + pPkgEvent, pPkgSig, NULL); + + if(mgc_port_info_add_opera_to_port(pPortInfo , pConnect, &stepInfo) == FALSE) + return FALSE; + + return TRUE; +} + + +CONNECT_INFO *mgc_connect_dup_attr(CONNECT_INFO *pConnect) +{ + CONNECT_INFO *pConnTmp = NULL; + + if(pConnect == NULL) + return NULL; + + pConnTmp = mgc_connect_get_unused(); + if(pConnTmp == NULL) + return NULL; + + + pConnTmp->flag = pConnect->flag; + pConnTmp->pChnlInfo = pConnect->pChnlInfo; + pConnTmp->status = pConnect->status; + return pConnTmp; +} + + +#ifdef MGC_TEST_ENABLE +int mgc_connect_inused_num(void) +{ + int i , num; + CONNECT_INFO *pConnect = NULL; + + num = 0; + for(i=0 ; ipChnlInfo == NULL) + continue; + + num++; + MGC_DEBUG("conn[%d] in use" , pConnect->id); + } + return num; +} +#endif + diff --git a/omc/plat/mgc_v2/src/mgc_ctl.c b/omc/plat/mgc_v2/src/mgc_ctl.c new file mode 100644 index 0000000..ec1f041 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_ctl.c @@ -0,0 +1,146 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +*/ + + +/********************************************************************************* + * + * This file contain global variable control + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ +#include "./include/mgc_ctl.h" + +MGC_CTL mgcCtl; + + +void mgc_ctl_num_init(WORD sysId , WORD localIp , WORD peerIp) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + pMgcCtl->mgcChlAssigned = 0; + pMgcCtl->mgcMgCreated = 0; + pMgcCtl->mgcMaxChlNo = MGC_MAX_NUM_OF_CHNL; + pMgcCtl->mgcMaxMgNo = MGC_MAX_NUM_OF_MG; + + pMgcCtl->sysId = sysId; + pMgcCtl->localIp = localIp; + pMgcCtl->peerIp = peerIp; + return; +} + +BOOL mgc_ctl_is_mg_full(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + if((pMgcCtl->mgcMgCreated + 1) > pMgcCtl->mgcMaxMgNo) + return TRUE; + + return FALSE; +} + +void mgc_ctl_mg_add_one(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + pMgcCtl->mgcMgCreated++; + return; +} + +void mgc_ctl_mg_remove_one(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + pMgcCtl->mgcMgCreated--; + return; +} + +BOOL mgc_ctl_is_chnl_full(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + if((pMgcCtl->mgcChlAssigned+ 1) > pMgcCtl->mgcMaxChlNo) + return TRUE; + + return FALSE; + +} + +void mgc_ctl_chnl_add_one(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + pMgcCtl->mgcChlAssigned++; + return; + +} + +void mgc_ctl_chnl_remove_one(void) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + pMgcCtl->mgcChlAssigned--; + return; +} + + +int mgc_ctl_set_mg_max_num(int num) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + if((num <= 0)||(num>MGC_MAX_NUM_OF_MG)) + return -1; + + pMgcCtl->mgcMaxMgNo = num; + return num; +} + +int mgc_ctl_set_chnl_max_num(int num) +{ + MGC_CTL *pMgcCtl = NULL; + pMgcCtl = &mgcCtl; + + if((num <= 0)||( num > MGC_MAX_NUM_OF_CHNL)) + return -1; + + pMgcCtl->mgcMaxChlNo = num; + return num; +} + + +#ifdef MGC_TEST_ENABLE +int mgc_ctl_chnl_num(void) +{ + MGC_CTL *pMgcCtl; + pMgcCtl = &mgcCtl; + + return pMgcCtl->mgcChlAssigned; +} + +int mgc_ctl_mg_num(void) +{ + MGC_CTL *pMgcCtl; + pMgcCtl = &mgcCtl; + + return pMgcCtl->mgcMgCreated; +} + +#endif diff --git a/omc/plat/mgc_v2/src/mgc_debug.c b/omc/plat/mgc_v2/src/mgc_debug.c new file mode 100644 index 0000000..526de07 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_debug.c @@ -0,0 +1,779 @@ +#include "./include/mgc_debug.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_port_info.h" +#include "../../debug/src/include/debug.h" + +#define MGC_DEBUG_ID 18 +#define MGC_VER_DEBUG "R9V0_07" + +static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + +static BYTE log_help[] = { +"MGC Debug Monitor Help:\n\r\ +\n\r\ +1.[help] display help menu\n\r\ +2.[log info on/off] display info logs\n\r\ +3.[log error on/off] display error logs \n\r\ +4.[log warn on/off] display warn logs \n\r\ +5.[log all/none] display all/none logs\n\r\ +6.[log record -f FILENAME] write debug message to FILENAME \n\r\ +7.[print mg ID/Domain] print mg[ID]/Domain info \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,MGC_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,MGC_DEBUG_ID + 2,2 + }; + +static DWORD debug_ascin_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,3 + }; + +static DWORD debug_ascout_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,4 + }; + +static DWORD debug_page_title[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,1 + }; + +static DWORD debug_page_line[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,2,1 + }; + +const static BYTE MGC_BASE_ID_LEN = 15; +const static BYTE MGC_PAGE_POINT = 14; +const static BYTE MGC_LINE_POINT = 15; + +static BYTE title1_p[] = +{ + " MGC Page 01 MG Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +MG_Info\n\r" +}; + +static BYTE title2_p[] = +{ + " MGC Page 02 Phy Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Phy_Port\n\r" +}; + +static BYTE title3_p[] = +{ + " MGC Page 03 Channel Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Chnl_Info\n\r" +}; + +static BYTE title4_p[] = +{ + " MGC Page 04 Port Info\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Port_Info\n\r" +}; + +#define FILENAMELEN 128 +static char fileName[FILENAMELEN]; + +BYTE mgc_disp_line(BYTE page, BYTE line) +{ + BYTE disp_length; + + disp_length = 16; + disp_ptr = (BYTE *) disp_page; + + switch (page) + { + case 1: // Page 1: MG Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgc_mg_info_get_res_addr() + disp_page[page] * sizeof(MG_INFO) + (line - 1) * 16; + break; + case 2: // Page 2: Phy Port Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgc_phy_port_get_res_addr() + disp_page[page] * sizeof(PHY_PORT_INFO) + (line - 1) * 16; + break; + case 3: // Page 3: Channel Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgc_chnl_info_get_res_addr + disp_page[page] * sizeof(CHNL_INFO) + (line - 1) * 16; + break; + case 4: // Page 4: Software Port Info + if (line == 0) + { + disp_ptr = (BYTE *) &disp_page[page]; + disp_length = 2; + } + else + disp_ptr = (BYTE *) mgc_port_info_get_res_addr + disp_page[page] * sizeof(PORT_INFO) + (line - 1) * 16; + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +void mgc_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + + debug_page_line[MGC_PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = mgc_disp_line(page, disp_line); + debug_page_line[MGC_LINE_POINT] = disp_line + 2; + debug_page_line[MGC_LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(MGC_BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length); + } +} + +int mgc_debug_set(void) +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + time_t timep; + struct tm *p; + bzero(disp_page, 20); + + ptr = data; + + debug_set_response(MGC_BASE_ID_LEN, debug_status_id, &debug_status, 1); + debug_set_response(MGC_BASE_ID_LEN, debug_name_id, MGC_VER_DEBUG, 10); + debug_set_response(MGC_BASE_ID_LEN, debug_ascin_id, mgcAsciInBuf, 4096); + debug_set_response(MGC_BASE_ID_LEN, debug_ascout_id, mgcAsciOutBuf, MGC_MAX_ASCIIOUT_LEN); + + for (page = 1; page < 5; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + case 2: //page 2 + ptr = title2_p; + break; + case 3: //page 3 + ptr = title3_p; + break; + case 4: //page 4 + ptr = title4_p; + break; + default: + break; + } + + debug_page_title[MGC_PAGE_POINT] = 5 + page; + debug_set_response(MGC_BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + mgc_disp_page(page); + } + +// mkdir("mgc_log" , 777); + time(&timep); + p = gmtime(&timep); + + memset(fileName , 0 , FILENAMELEN); + //sprintf(fileName , "mgc_log/mgc_log_%d_%d_%d_%d.txt", p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); + return 1; +} + + +BOOL mgc_debug_parse_print_info(char *pAscin) +{ + char *ptr = NULL; + char *ptrTmp = NULL; + MG_INFO *pMgInfo = NULL; + int id = -1; + + if(pAscin == NULL) + return FALSE; + + if(strstr(pAscin , "print") == NULL) + return FALSE; + + ptr = strstr(pAscin , "mg"); + if(ptr == NULL) + return FALSE; + + ptr = ptr+2; + + while(*ptr != '\n') + { + if(*ptr != ' ') + { + ptrTmp = ptr; + break; + } + + ptr++; + } + + if(ptrTmp == NULL) + return FALSE; + + pMgInfo = mgc_mg_info_find_mg_by_name(ptrTmp); + if(pMgInfo == NULL) + { + id = atoi(ptrTmp); + pMgInfo = mgc_mg_info_get_index_mg(id); + } + + if(pMgInfo == NULL) + return FALSE; + + mgc_mg_info_print_info(pMgInfo); + return TRUE; +} + + +BOOL mgc_debug_parse_log_file(char *pAscin) +{ + char *ptr = NULL; + char *ptrTmp = NULL; + int i=0; + FILE *fp; + + if(pAscin == NULL) + return FALSE; + + if(strstr(pAscin , "log record") == NULL) + return FALSE; + + ptr = strstr(pAscin , "-f"); + if(ptr == NULL) + return FALSE; + + memset(fileName , 0 , FILENAMELEN); + ptr = ptr+2; + while(*ptr != '\n') + { + if(*ptr != ' ') + { + ptrTmp = ptr; + break; + } + + ptr++; + } + + if(ptrTmp == NULL) + return FALSE; + + while(*ptr != '\0') + { + ptr++; + i++; + if(i>=FILENAMELEN) + break; + } + + if(i>=FILENAMELEN) + return FALSE; + + memcpy(fileName, ptrTmp , ptr-ptrTmp); + + fp = fopen(fileName , "w+"); + if(fp == NULL) + return FALSE; + + fclose(fp); + return TRUE; +} + + +BOOL mgc_debug_write_file(char *msg , int len) +{ + FILE *fp = NULL; + + if(strlen(fileName) == 0) + return FALSE; + + fp = fopen(fileName , "a"); + if(fp == NULL) + return FALSE; + + if(fwrite(msg, sizeof(char) , len , fp) < len) + return FALSE; + + fclose(fp); + return TRUE; +} + +int mgc_asciout_proc(BYTE *out_str) +{ + int out_len; + + out_len = strlen(out_str); + + if (out_len + strlen(mgcAsciOutBuf) > MGC_MAX_ASCIIOUT_LEN - 2) + { + strcpy(mgcAsciOutBuf, out_str); + } + else + strcat(mgcAsciOutBuf, out_str); + + return 1; +} + +void mgc_log_all() +{ + WORD i; + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + mgc_mg_info_set_mon(i , TRUE); + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + mgc_phy_port_set_mon(i, TRUE); + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + mgc_chnl_info_set_mon(i, TRUE); +} + +void mgc_log_none() +{ + WORD i; + + for (i = 0; i < MGC_MAX_NUM_OF_MG; i++) + mgc_mg_info_set_mon(i , FALSE); + + + for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++) + mgc_phy_port_set_mon(i, FALSE); + + + for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++) + mgc_chnl_info_set_mon(i, FALSE); + + memset(fileName , 0 , FILENAMELEN); +} + +void mgc_mon(void) +{ + BYTE in_page, err_fg = 0; + BYTE *ascii_in_ptr = NULL; + BYTE *str_start = NULL; + WORD str_len; + WORD num; +// WORD mgNo, chlNo , portNo; + //PHY_PORT_INFO *pPhyPort; + //CHNL_INFO *pChnlInfo; + + if ((str_len = strlen(mgcAsciInBuf)) > 0) + { + in_page = mgcAsciInBuf[0] - 1; + ascii_in_ptr = mgcAsciInBuf + 1; + + if (in_page > 4) + err_fg = 1; + else if (strcmp(ascii_in_ptr,"log error on") == 0) + { + mgcMonitorFg = mgcMonitorFg | MGC_MONITOR_ERROR; + } + else if (strcmp(ascii_in_ptr,"log error off") == 0) + { + mgcMonitorFg = mgcMonitorFg & (~MGC_MONITOR_ERROR); + } + else if (strcmp(ascii_in_ptr,"log warn on") == 0) + { + mgcMonitorFg = mgcMonitorFg | MGC_MONITOR_WARN; + } + else if (strcmp(ascii_in_ptr,"log warn off") == 0) + { + mgcMonitorFg = mgcMonitorFg & (~MGC_MONITOR_WARN); + } + else if (strcmp(ascii_in_ptr,"log info on") == 0) + { + mgcMonitorFg = mgcMonitorFg | MGC_MONITOR_INFO; + } + else if (strcmp(ascii_in_ptr,"log info off") == 0) + { + mgcMonitorFg = mgcMonitorFg & (~MGC_MONITOR_INFO); + } + else if (strcmp(ascii_in_ptr,"log all") == 0) + { + mgcMonitorFg = MGC_MONITOR_ALL; + mgc_log_all(); + } + else if (strcmp(ascii_in_ptr,"log none") == 0) + { + mgcMonitorFg = MGC_MONITOR_NONE; + mgc_log_none(); + } + else if (strcmp(ascii_in_ptr,"help") == 0) + { + mgc_asciout_proc(log_help); + } + else if(strstr(ascii_in_ptr, "log record") != NULL) + { + if(mgc_debug_parse_log_file(ascii_in_ptr) == FALSE) + err_fg = 1; + } + else if(strstr(ascii_in_ptr, "print") != NULL) + { + if(mgc_debug_parse_print_info(ascii_in_ptr) == FALSE) + err_fg = 1; + } +#if 0 + else if (strstr(ascii_in_ptr, "log mg") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + else if (strstr(ascii_in_ptr, "on") != NULL) + mgcMgInfo[mgNo].monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + mgcMgInfo[mgNo].monFlag = 0; + else + err_fg = 1; + } + else + err_fg = 1; + } + else if (strstr(ascii_in_ptr, "log port") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + portNo = strtoul(str_start + 1, NULL, 10); + if (portNo >= MGC_MAX_PHY_PORT_PER_MG) + err_fg = 1; + pPhyPort = mgc_phy_port_find_port_of_mg(&(mgcMgInfo[mgNo]), portNo); + if (pPhyPort == NULL) + err_fg = 2; + else + { + if (strstr(str_start + 1, "on") != NULL) + pPhyPort->monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + pPhyPort->monFlag = 0; + else + err_fg = 1; + } + } + } + else + err_fg = 1; + } + else if (strstr(ascii_in_ptr, "log chnl") != NULL) + { + if ((str_start = strstr(ascii_in_ptr, "-")) != NULL) + { + mgNo = strtoul(str_start + 1, NULL, 10); + if (mgNo >= MGC_MAX_NUM_OF_MG) + err_fg = 1; + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + portNo = strtoul(str_start + 1, NULL, 10); + if (portNo >= MGC_MAX_PHY_PORT_PER_MG) + err_fg = 1; + pPhyPort = mgc_phy_port_find_port_of_mg(&mgcMgInfo[mgNo], portNo); + if (pPhyPort == NULL) + err_fg = 2; + else + { + if ((str_start = strstr(str_start + 1, "-")) != NULL) + { + chlNo = strtoul(str_start + 1, NULL, 10); + pChnlInfo = mgc_chnl_info_find_chnl_of_phy(pPhyPort, chlNo); + if (strstr(str_start + 1, "on") != NULL) + pChnlInfo->monFlag = 1; + else if (strstr(ascii_in_ptr, "off") != NULL) + pChnlInfo->monFlag = 0; + else + err_fg = 1; + } + } + } + } + else + err_fg = 1; + } +#endif + else if (isdigit(ascii_in_ptr[0])) + { + num = strtoul(ascii_in_ptr, NULL, 10); + disp_page[in_page] = num; + mgc_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; + mgc_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; + mgc_disp_page(in_page); + } + else + err_fg = 1; + + if (err_fg == 0) + mgc_asciout_proc("Command OK!\n\r"); + else if (err_fg == 2) + mgc_asciout_proc("MG port not created!\n\r"); + else + mgc_asciout_proc("Command Error!\n\r"); + + strcpy(mgcAsciInBuf, "\0"); + } +} + +int mgc_hex_to_ascii(BYTE *from_hex, BYTE 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 mgc_log_err(char *err_msg) +{ + if ((mgcMonitorFg & MGC_MONITOR_ERROR) == MGC_MONITOR_ERROR) + { + mgc_asciout_proc("\33[31m"); + if (strlen(err_msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s", err_msg); + strcat(mgcAsciTempBuf, "\33[37m"); + mgc_asciout_proc(mgcAsciTempBuf); + } + + return 1; +} + +int mgc_log_warn(char *err_msg) +{ + if ((mgcMonitorFg & MGC_MONITOR_WARN) == MGC_MONITOR_WARN) + { + mgc_asciout_proc("\33[33m"); + if (strlen(err_msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s", err_msg); + strcat(mgcAsciTempBuf, "\33[37m"); + mgc_asciout_proc(mgcAsciTempBuf); + } + + return 1; +} + + +int mgc_log_info(char *err_msg) +{ + if ((mgcMonitorFg & MGC_MONITOR_INFO) == MGC_MONITOR_INFO) + { + mgc_asciout_proc("\33[32m"); + if (strlen(err_msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s", err_msg); + strcat(mgcAsciTempBuf, "\33[37m"); + mgc_asciout_proc(mgcAsciTempBuf); + } + + return 1; +} + + +int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg) +{ +/* + BYTE monFlag = 0; + + if ((mgNo < MGC_MAX_NUM_OF_MG) && (mgcMgInfo[mgNo].monFlag == 1)) + monFlag = 1; + else if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && (mgcPhyPort[portIndex].monFlag == 1)) + monFlag = 1; + else if ((chnlIndex < MGC_MAX_NUM_OF_CHNL) && (mgcChnl[chnlIndex].monFlag == 1)) + monFlag = 1; + + if (monFlag == 1) + { + if (strlen(msg) >= MGC_MAX_ASCITMP_LEN) + sprintf(mgcAsciTempBuf, "log msg is too long!\n\r"); + else + sprintf(mgcAsciTempBuf, "%s\n\r", msg); + mgc_asciout_proc(mgcAsciTempBuf); + return 0; + } +*/ + return -1; +} + +#ifndef MGC_TEST_DEBUG +void MGC_DEBUG(char *msg,...) +{ + char printedMessage[MGC_MAX_LINE_LENGTH]; + char* ptr; + va_list v; + + ptr = printedMessage; + memset(ptr , 0 , MGC_MAX_LINE_LENGTH); + + sprintf(ptr, "DEBUG:"); + ptr = ptr+strlen(ptr); + /* Format the given line with the arguments */ + va_start(v, msg); + vsprintf(ptr, msg, v); + va_end(v); + + ptr = ptr+strlen(ptr); + sprintf(ptr, "\r\n"); + ptr = printedMessage; + + if((mgcMonitorFg&MGC_MONITOR_DEBUG) != MGC_MONITOR_DEBUG) + return; + + mgc_debug_write_file(ptr, strlen(ptr)); + mgc_asciout_proc(ptr); + return; +} + +void MGC_WARN(char *msg,...) +{ + char printedMessage[MGC_MAX_LINE_LENGTH]; + char* ptr; + va_list v; + + ptr = printedMessage; + memset(ptr , 0 , MGC_MAX_LINE_LENGTH); + sprintf(ptr, "WARN:"); + ptr = ptr+strlen(ptr); + + /* Format the given line with the arguments */ + va_start(v, msg); + vsprintf(ptr, msg, v); + va_end(v); + + ptr = ptr+strlen(ptr); + sprintf(ptr, "\r\n"); + ptr = printedMessage; + + if((mgcMonitorFg&MGC_MONITOR_WARN) != MGC_MONITOR_WARN) + return; + + mgc_debug_write_file(ptr, strlen(ptr)); + mgc_log_warn(ptr); + return; +} + + +void MGC_INFO(char *msg,...) +{ + char printedMessage[MGC_MAX_LINE_LENGTH]; + char* ptr; + va_list v; + + ptr = printedMessage; + memset(ptr , 0 , MGC_MAX_LINE_LENGTH); + sprintf(ptr, "INFO:"); + ptr = ptr+strlen(ptr); + + /* Format the given line with the arguments */ + va_start(v, msg); + vsprintf(ptr, msg, v); + va_end(v); + + ptr = ptr+strlen(ptr); + sprintf(ptr, "\r\n"); + ptr = printedMessage; + + if((mgcMonitorFg&MGC_MONITOR_INFO) != MGC_MONITOR_INFO) + return; + + mgc_debug_write_file(ptr, strlen(ptr)); + mgc_log_info(ptr); + return; +} + + +void MGC_ERROR(char *msg,...) +{ + char printedMessage[MGC_MAX_LINE_LENGTH]; + char* ptr; + va_list v; + + ptr = printedMessage; + memset(ptr , 0 , MGC_MAX_LINE_LENGTH); + + sprintf(ptr, "ERROR:"); + ptr = ptr+strlen(ptr); + /* Format the given line with the arguments */ + va_start(v, msg); + vsprintf(ptr, msg, v); + va_end(v); + + ptr = ptr+strlen(ptr); + sprintf(ptr, "\r\n"); + ptr = printedMessage; + + if((mgcMonitorFg&MGC_MONITOR_ERROR) != MGC_MONITOR_ERROR) + return; + + mgc_debug_write_file(ptr, strlen(ptr)); + mgc_log_err(ptr); + return; +} +#endif diff --git a/omc/plat/mgc_v2/src/mgc_internal.c b/omc/plat/mgc_v2/src/mgc_internal.c new file mode 100644 index 0000000..249a8f8 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_internal.c @@ -0,0 +1,377 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +*/ + + +/********************************************************************************* + * + * This file should is internal interface to do misc operation. So far, only AUEP is used + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ +#include "./include/mgc_internal.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_mg_info.h" + +static MGC_INTERNAL_SAP mgcItlSap; +static ITL_OPERA_STRUCT opera[ITL_OPERA_NUM]; + +extern int mgc_update_phy_port_status(CHNL chnl, BOOL status); +extern int mgc_auep_chnl(WORD usrPort, CHNL chnl); +void mgc_internal_opera_init(ITL_OPERA_STRUCT *pOpera , int usrPort); + +BOOL mgc_internal_get_local_ip(char *ipAddr) +{ + struct hostent *host; + char localName[50]; + + if(ipAddr == NULL) + return FALSE; + + if (gethostname(localName , 50) == -1) + { + return FALSE; + } + + if ((host = gethostbyname(localName)) == NULL) + { + return FALSE; + } + + sprintf(ipAddr, "%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]); + + return TRUE; +} + + + +char *mgc_internal_print_opera_id(MGC_MG_OPER_ID_TYPE operaId) +{ + switch(operaId) + { + case MGC_OPER_ID_CONNECT_CHNL: + return "MGC_OPER_ID_CONNECT_CHNL"; + case MGC_OPER_ID_CONNECT_DTMF: + return "MGC_OPER_ID_CONNECT_DTMF"; + case MGC_OPER_ID_CONNECT_TONE: + return "MGC_OPER_ID_CONNECT_TONE"; + case MGC_OPER_ID_CRCX: + return "MGC_OPER_ID_CRCX"; + case MGC_OPER_ID_MDCX: + return "MGC_OPER_ID_MDCX"; + case MGC_OPER_ID_DLCX: + return "MGC_OPER_ID_DLCX"; + case MGC_OPER_ID_RQNT: + return "MGC_OPER_ID_RQNT"; + case MGC_OPER_ID_AUEP: + return "MGC_OPER_ID_AUEP"; + case MGC_OPER_ID_CONNECT_AAS: + return "MGC_OPER_ID_CONNECT_AAS"; + case MGC_OPER_ID_UNDEF: + return "MGC_OPER_ID_UNDEF"; + case MGC_OPER_ID_IND: + return "MGC_OPER_ID_IND"; + case MGC_OPER_ID_TANDEM_CREATE: + return "MGC_OPER_ID_TANDEM_CREATE"; + case MGC_OPER_ID_TANDEM_CLEAR: + return "MGC_OPER_ID_TANDEM_CLEAR"; + case MGC_OPER_ID_TANDEM_SET_TAR: + return "MGC_OPER_ID_TANDEM_SET_TAR"; + case MGC_OPER_ID_TANDEM_UNSET_TAR: + return "MGC_OPER_ID_TANDEM_UNSET_TAR"; + default: + break; + } + + return "MGC_OPERA_ID_UNSUPPORTED"; +} + + + +int mgc_internal_get_sap_index(void) +{ + return mgcItlSap.mgcSapIndex; +} + +ITL_OPERA_STRUCT *mgc_internal_find_owne_opera(int usrPort) +{ + ITL_OPERA_STRUCT *pOpera = NULL; + int i; + + for(i=0; iuserPort != usrPort) + continue; + + return pOpera; + } + return NULL; +} + + + +int mgc_internal_ind_callback(CHNL chnl, MGC_CMD_TYPE cmd, WORD *usrPort, WORD mgcPort, MEDIA_ATTR *mediaAttr) +{ + + return 0; +} + + +int mgc_internal_cnf_callback(WORD usrPort, WORD mgcPort, MGC_MG_OPER_ID_TYPE operId, MGC_OPER_RESULT success, WORD cause) +{ + ITL_OPERA_STRUCT *pOpera = NULL; + MG_INFO *pMgInfo = NULL; + BOOL status = FALSE; + pOpera = mgc_internal_find_owne_opera(usrPort); + if(pOpera == NULL) + { + MGC_WARN("internal usrport[%d] lost owner" , usrPort); + return -1; + } + if(pOpera->status != ITL_OPERA_STATE_REQUEST) + { + mgc_internal_opera_init(pOpera, pOpera->userPort); + return -1; + } + // MGC_DEBUG("opera[%d] operate %s" , pOpera->userPort , success?"success" : "failure"); + switch(operId) + { + case MGC_OPER_ID_AUEP: + pMgInfo = mgc_mg_info_get_index_mg(pOpera->chnl.mgNo); + if(success == MGC_OPER_SUCCESS) + { + status = TRUE; + } + mgc_mg_info_update_mg_status(pMgInfo, status); + mgc_delete_port(mgc_internal_get_sap_index(), pOpera->chnl.mgNo, pOpera->chnl.portNo); + break; + default: + MGC_WARN("internal opera do not support %s" , mgc_internal_print_opera_id(operId)); + break; + } + + mgc_internal_opera_init(pOpera, pOpera->userPort); + return 0; +} + +ITL_OPERA_STRUCT *mgc_internal_get_idle_opera(void) +{ + ITL_OPERA_STRUCT *pOpera = NULL; + int i; + + for(i=0 ; istatus != ITL_OPERA_STATE_IDLE) + continue; + + return pOpera; + } + + return NULL; +} + +void mgc_internal_opera_init(ITL_OPERA_STRUCT *pOpera , int usrPort) +{ + if(pOpera == NULL) + return; + + pOpera->userPort = usrPort; + pOpera->status = ITL_OPERA_STATE_IDLE; + memset(&pOpera->chnl , 0 ,sizeof(CHNL)); + return; +} + +void mgc_internal_opera_clear(void) +{ + int i; + ITL_OPERA_STRUCT *pOpera = NULL; + + for(i=0 ; istatus == ITL_OPERA_STATE_IDLE) + continue; + + mgc_delete_port(mgc_internal_get_sap_index(), pOpera->chnl.mgNo, pOpera->chnl.portNo); + mgc_internal_opera_init(pOpera, pOpera->userPort); + } + + return; +} + +/*************************************************************************** + * mgc_internal_opera_auep_request + * ------------------------------------------------------------------------ + * General: inferace to be used for auep detection + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO object which need to send auep + ***************************************************************************/ +BOOL mgc_internal_opera_auep_request(MG_INFO *pMgInfo) +{ + ITL_OPERA_STRUCT *pOpera = NULL; + int i,ret; + PHY_PORT_INFO *pPhyPort = NULL; + + if(pMgInfo == NULL) + return FALSE; + + if((pMgInfo->created == FALSE)||(pMgInfo->mgAttr.ctrlType != MGC_MG_CTRL_TYPE_MGCP)) + return FALSE; + + if(pMgInfo->mgAttr.mgType ==MGC_MG_TYPE_INTERNAL) + { + pMgInfo->enable = TRUE; + return TRUE; + } + + for(i=0 ; i< MGC_MAX_PHY_PORT_PER_MG ; i++) + { + pPhyPort = pMgInfo->pPhyPort[i]; + pOpera = mgc_internal_get_idle_opera(); + + if(pOpera == NULL) + { + MGC_ERROR("internal opera is no more resource!"); + mgc_internal_opera_clear(); + continue; + } + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->pMgcSap == NULL) + continue; + + if(pPhyPort->pMgcSap->usrType != MGC_USER_TYPE_MGC) + continue; + + ret = mgc_add_port(mgc_internal_get_sap_index(), pMgInfo->id, ITL_OPERA_PORT_NO , MGC_PHY_PORT_TYPE_E1); + if(ret < 0) + { + mgc_delete_port(mgc_internal_get_sap_index(),pMgInfo->id,ITL_OPERA_PORT_NO); + mgc_internal_opera_init(pOpera, pOpera->userPort); + return FALSE; + } + + pOpera->chnl.mgNo = pMgInfo->id; + pOpera->chnl.portNo = ITL_OPERA_PORT_NO; + pOpera->chnl.chlNo = 0; + pOpera->chnl.connectNo = 0; + pOpera->status = ITL_OPERA_STATE_REQUEST; + + if(MGC_RESULT_OK != mgc_auep_chnl(pOpera->userPort , pOpera->chnl)) + mgc_internal_opera_init(pOpera, pOpera->userPort); + + break; + } + + return TRUE; +} + + +/*************************************************************************** + * mgc_internal_sap_bind + * ------------------------------------------------------------------------ + * General: inferace to be called in mgc_init + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +BOOL mgc_internal_sap_bind(void) +{ + MGC_INTERNAL_SAP *pSap = NULL; + ITL_OPERA_STRUCT *pOpera = NULL; + MGC_SAP *pMgcSap = NULL; + int ret , i; + + pSap = &mgcItlSap; + + if(pSap == NULL) + return FALSE; + + pSap->mgcSapIndex = -1; + pMgcSap = &(pSap->mgcSap); + sprintf(pMgcSap->usrName , "%s" , "MGC_ITL_SAP"); + pMgcSap->cnf_func = mgc_internal_cnf_callback; + pMgcSap->ind_func = mgc_internal_ind_callback; + pMgcSap->usrType = MGC_USER_TYPE_MGC; + + ret = mgc_bind(pMgcSap); + if(ret < 0) + return FALSE; + + pSap->mgcSapIndex = ret; + + for(i=0 ; imgcSapIndex < 0) + return FALSE; + + memset(&mgAttr , 0 , sizeof(MG_ATTR)); + mgAttr.mgType = MGC_MG_TYPE_INTERNAL; + mgAttr.ctrlType = MGC_MG_CTRL_TYPE_MGCP; + mgAttr.epDes = MGCP_EP_NAME_UNSTRUCTURED; + mgAttr.ptime = 20; + sprintf(mgAttr.domain , "InternalMG"); + mgc_internal_get_local_ip(localIp); + mgAttr.ip = inet_addr(localIp); + + ret = mgc_create_MG(pSap->mgcSapIndex , &mgAttr); + if(ret < 0) + return FALSE; + + pSap->mgNoITL = ret; + ret = mgc_add_port(pSap->mgcSapIndex, pSap->mgNoITL , ITL_MG_INFO_PORT_NO , MGC_PHY_VIRTUAL_TYPE_INTERNAL); + if(ret < 0) + return FALSE; + + return TRUE; +} + + diff --git a/omc/plat/mgc_v2/src/mgc_mg_info.c b/omc/plat/mgc_v2/src/mgc_mg_info.c new file mode 100644 index 0000000..2bc37af --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_mg_info.c @@ -0,0 +1,937 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* +* +* +* mgcSap <---------mgcPhyPorts --------> mgcMgInfo +* +* +*/ + + + + +/********************************************************************************* + * + * This file should provide MG_INFO object APIs + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + + +#include "./include/mgc_mg_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_8ecp.h" +#include "./include/mgc_internal.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_conn_info.h" +static MG_INFO mgcMgInfo[MGC_MAX_NUM_OF_MG]; + +extern int mgc_get_non_virtual_trk_status(MG_INFO *pMgInfo); + + +/*----------------------------------------------------------------------- + MG_INFO M A N A G E R + ------------------------------------------------------------------------*/ + + + +/*************************************************************************** + * mgc_mg_info_init + * ------------------------------------------------------------------------ + * General: init MG_INFO structure objcet + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo- the pointer of the MG_INFO object which should be init + * id - the id of the MG_INFO object + ***************************************************************************/ +void mgc_mg_info_init(MG_INFO *pMgInfo , int id) +{ + int i; + if((pMgInfo == NULL)||(id < 0)) + return ; + + pMgInfo->id = id; + pMgInfo->requestId = 0; + pMgInfo->created = FALSE; + pMgInfo->enable = FALSE; + memset(&pMgInfo->mgAttr , 0 , sizeof(MG_ATTR)); + pMgInfo->mgAttr.ctrlType = MGC_MG_CTRL_TYPE_UNDEF; + pMgInfo->mgAttr.mgType= MGC_MG_TYPE_UNDEF; + pMgInfo->auditTimer = 0; + for(i=0 ; ipPhyPort[i] = NULL ; + } + + return; +} + +void mgc_mg_info_setup(void) +{ + int i; + MG_INFO *pMgInfo = NULL; + + for(i=0 ; ipPhyPort[i]; + if(pPhyPort == NULL) + continue; + + mgc_phy_port_clear(pPhyPort); + } + + mgc_mg_info_init(pMgInfo, pMgInfo->id); + return; +} + + +/*************************************************************************** + * mgc_mg_info_attached_phy_port_num + * ------------------------------------------------------------------------ + * General: calculate how many phyPort is attached on the MG_INFO objec + * Return Value: the number of attached phyPort. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo- the pointer of the MG_INFO object + ***************************************************************************/ +int mgc_mg_info_attached_phy_port_num(MG_INFO *pMgInfo) +{ + int num , i; + + if(pMgInfo == NULL) + return 0; + + num = 0; + for(i=0 ; ipPhyPort[i] != NULL) + num++; + } + + return num; +} + +/*************************************************************************** + * mgc_mg_info_is_port_already_exist + * ------------------------------------------------------------------------ + * General: check whether the phyport is already attached on this MG_INFO object + * Return Value: if already attached return TRUE, else return FALSE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo- the pointer of the MG_INFO object + * portNo - the phyPort number + ***************************************************************************/ +BOOL mgc_mg_info_is_port_already_exist(MG_INFO *pMgInfo , int portNo , MGC_SAP *pSap) +{ + int i; + + if(pMgInfo == NULL) + return FALSE; + + for(i=0 ; ipPhyPort[i] == NULL) + continue; + + if(pMgInfo->pPhyPort[i]->pMgcSap != pSap) + continue; + + if(pMgInfo->pPhyPort[i]->portNo != portNo) + continue; + + if(portNo != ITL_OPERA_PORT_NO) + { + MGC_WARN("mg[%d] already have Port[%d]" , pMgInfo->id , portNo); + } + return TRUE; + } + + return FALSE; +} + +/*************************************************************************** + * mgc_mg_info_attach_phy_port + * ------------------------------------------------------------------------ + * General: attach a phyport on the MG_INFO object + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo- the pointer of the MG_INFO object + * pPhyPort - the pointer of the phyPort + ***************************************************************************/ +BOOL mgc_mg_info_attach_phy_port(MG_INFO *pMgInfo , PHY_PORT_INFO *pPhyPort , MGC_SAP *pSap) +{ + int i; + + if((pMgInfo == NULL)||(pPhyPort == NULL)) + return FALSE; + + if(mgc_mg_info_is_port_already_exist(pMgInfo , pPhyPort->portNo , pSap) == TRUE) + return FALSE; + + for(i=0 ; ipPhyPort[i] != NULL) + continue; + + pMgInfo->pPhyPort[i] = pPhyPort; + return TRUE; + } + + return FALSE; +} + + +/*************************************************************************** + * mgc_mg_info_dettach_phy_port + * ------------------------------------------------------------------------ + * General: remove a phyport from the MG_INFO object + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo- the pointer of the MG_INFO object + * pPhyPort - the pointer of the phyPort + ***************************************************************************/ +void mgc_mg_info_dettach_phy_port(MG_INFO *pMgInfo , PHY_PORT_INFO *pPhyPort) +{ + int i; + + if((pMgInfo == NULL)||(pPhyPort == NULL)) + return; + + for(i=0 ; ipPhyPort[i] != pPhyPort) + continue; + + pMgInfo->pPhyPort[i] = NULL; + //MGC_DEBUG("mgcMgInfo[%d] dettach phyport[%d]" , pMgInfo->id , pPhyPort->id); + return; + } + + return ; +} + +/*************************************************************************** + * mgc_mg_info_get_unused_mg + * ------------------------------------------------------------------------ + * General: get unused MG_INFO object + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +MG_INFO *mgc_mg_info_get_unused_mg(void) +{ + int i; + MG_INFO *pMgInfo = NULL; + + for(i=0 ; icreated == TRUE) + continue; + + return pMgInfo; + } + + return NULL; +} + +/*************************************************************************** + * mgc_mg_info_get_index_mg + * ------------------------------------------------------------------------ + * General: get the pointer of the MG_INFO object by index + * Return Value: if failure return NULL , else return the pointer + * ------------------------------------------------------------------------ + * Arguments: + * Input: index - index of the MG_INFO + ***************************************************************************/ +MG_INFO *mgc_mg_info_get_index_mg(int index) +{ + if((index < 0)||(index >= MGC_MAX_NUM_OF_MG)) + return NULL; + + return &mgcMgInfo[index]; +} + + +BOOL mgc_mg_info_check_codec_list(MG_INFO *pMgInfo) +{ + int i; + MGC_CODEC_LIST codecList; + MGC_CODEC_LIST *pList = NULL; + + if(pMgInfo == NULL) + return FALSE; + + mgc_connect_codec_list_init(&codecList); + pList = &pMgInfo->mgAttr.codecList; + + for(i = 0 ; inum ; i++) + { + if(mgc_mgcp_check_codec_valid(pList->codec[i]) != TRUE) + continue; + + codecList.codec[codecList.num] = pList->codec[i]; + codecList.num++; + } + + if(pList->num != codecList.num) + { + MGC_WARN("mg[%d] codeclist rec wrong" , pMgInfo->id); + } + + if(codecList.num > 0) + memcpy(pList , &codecList , sizeof(MGC_CODEC_LIST)); + + return TRUE; +} + +/*************************************************************************** + * mgc_mg_info_assign_attr + * ------------------------------------------------------------------------ + * General: give MG_INFO object attribute + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO object + * pMgAttr - the pointer of the attribute descprition + ***************************************************************************/ +BOOL mgc_mg_info_assign_attr(MG_INFO *pMgInfo , MG_ATTR *pMgAttr) +{ + if((pMgInfo == NULL)||(pMgAttr == NULL)) + return FALSE; + + if(strlen(pMgAttr->domain) == 0) + return FALSE; + + + switch(pMgAttr->ctrlType) + { + case MGC_MG_CTRL_TYPE_8ECP: + mgc_8ecp_create(pMgInfo , pMgAttr); + break; + case MGC_MG_CTRL_TYPE_MGCP: + memcpy(&pMgInfo->mgAttr , pMgAttr , sizeof(MG_ATTR)); + if(pMgInfo->mgAttr.auditTimer == 0) + { + pMgInfo->mgAttr.auditTimer = MGC_MGCF_TIMER_10S; + } + else + { + pMgInfo->mgAttr.auditTimer = pMgInfo->mgAttr.auditTimer*MGC_MGCF_TIMER_1S; + } + break; + default: + MGC_ERROR("unsupport ctrlType %d" , pMgAttr->ctrlType); + return FALSE; + } + + mgc_mg_info_check_codec_list(pMgInfo); + pMgInfo->auditTimer = pMgInfo->mgAttr.auditTimer; + pMgInfo->created = TRUE; + return TRUE; +} + +/*************************************************************************** + * mgc_mg_info_state_check + * ------------------------------------------------------------------------ + * General: check MG status + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO object + ***************************************************************************/ +void mgc_mg_info_state_check(MG_INFO *pMgInfo) +{ + if(pMgInfo == NULL) + return; + + if(pMgInfo->created == FALSE) + return; + + if(++pMgInfo->auditTimer < pMgInfo->mgAttr.auditTimer) + return; + + switch(pMgInfo->mgAttr.ctrlType) + { + case MGC_MG_CTRL_TYPE_MGCP: + mgc_internal_opera_auep_request(pMgInfo); + mgc_get_non_virtual_trk_status(pMgInfo); + break; + case MGC_MG_CTRL_TYPE_8ECP: + break; + default: + break; + } + + + pMgInfo->auditTimer = 0; + return; +} + +/*************************************************************************** + * mgc_mg_info_update_mg_status + * ------------------------------------------------------------------------ + * General: update MG_INFO object status + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO object + * status - TRUE stand for enable, FALSE stand for disable + ***************************************************************************/ +void mgc_mg_info_update_mg_status(MG_INFO *pMgInfo , BOOL status) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + + if(pMgInfo == NULL) + return; + + pMgInfo->enable = status; + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_AudioCoder) + return; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(status == TRUE) + pPhyPort->status = MGC_PHY_PORT_STATUS_ON_LINE; + + if(status == FALSE) + pPhyPort->status = MGC_PHY_PORT_STATUS_OFF_LINE; + } + return; +} + +/*************************************************************************** + * mgc_mg_info_check_mg_is_exsit + * ------------------------------------------------------------------------ + * General: check MG_INFO object is already be created + * Return Value: if already created return the pointer , else return NULL + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgAttr - the pointer of the MG attribute description + ***************************************************************************/ +MG_INFO *mgc_mg_info_check_mg_is_exsit(MG_ATTR *pMgAttr) +{ + int i; + MG_INFO *pMgInfo= NULL; + + if(pMgAttr == NULL) + return NULL; + + for(i=0 ; icreated == FALSE) + continue; + + if(strcmp(pMgInfo->mgAttr.domain , pMgAttr->domain) != 0) + continue; + + if(pMgInfo->mgAttr.ip != pMgAttr->ip) + continue; + + return pMgInfo; + } + + return NULL; +} + + +/*************************************************************************** + * mgc_mg_info_find_port_by_name + * ------------------------------------------------------------------------ + * General: find the phyPort by mg name and local port + * Return Value: if failure return NUL , else return the pointer of the phyPort + * ------------------------------------------------------------------------ + * Arguments: + * Input: name - the name of the mg + * localPort - the local MGCP port + ***************************************************************************/ +PHY_PORT_INFO *mgc_mg_info_find_port_by_name_and_portNo(char *name , BYTE portNo ,WORD localPort) +{ + int i , j; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + MGC_USER_TYPE usrType ; + + if(localPort == MGC_MG_NETWORK_PORT) + { + usrType = MGC_USER_TYPE_MG; + } + else if(localPort == MGC_MGC_NETWORK_PORT) + { + usrType = MGC_USER_TYPE_MGC; + } + else + { + return NULL; + } + + + + for(i=0 ; imgAttr.domain , name) != 0) + continue; + + for(j=0 ; jpPhyPort[j]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->pMgcSap->usrType != usrType) + continue; + + if(pPhyPort->portNo != portNo) + continue; + + return pPhyPort; + } + } + return NULL; +} + + +PHY_PORT_INFO *mgc_mg_info_find_port_by_name(char *name ,WORD localPort) +{ + int i , j; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + MGC_USER_TYPE usrType ; + + if(localPort == MGC_MG_NETWORK_PORT) + { + usrType = MGC_USER_TYPE_MG; + } + else if(localPort == MGC_MGC_NETWORK_PORT) + { + usrType = MGC_USER_TYPE_MGC; + } + else + { + return NULL; + } + + + for(i=0 ; imgAttr.domain , name) != 0) + continue; + + for(j=0 ; jpPhyPort[j]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->pMgcSap->usrType != usrType) + continue; + + return pPhyPort; + } + } + return NULL; +} + + + + + +MG_INFO *mgc_mg_info_find_mg_by_name(char *name) +{ + int i ; + MG_INFO *pMgInfo = NULL; + + for(i=0 ; imgAttr.domain , name) != 0) + continue; + + return pMgInfo; + } + + return NULL; +} + +/*************************************************************************** + * mgc_mg_info_find_available_mg + * ------------------------------------------------------------------------ + * General: find a MG_INFO object which is enabled according to the mgType + * Return Value: if failure return NUL , else return the pointer of the MG_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: mgType - the Type of MG + ***************************************************************************/ +MG_INFO *mgc_mg_info_find_available_mg(MGC_MG_TYPE mgType) +{ + int i; + MG_INFO *pMgInfo = NULL; + + if(mgType == MGC_MG_TYPE_UNDEF) + return NULL; + + for(i=0 ; imgAttr.mgType != mgType) + continue; + + if(pMgInfo->enable == FALSE) + continue; + + return pMgInfo; + } + + return NULL; +} + +/*************************************************************************** + * mgc_mg_info_assign_idle_connection + * ------------------------------------------------------------------------ + * General: assign a idle connection of the specific MG_INFO objcet + * Return Value: if failure return NUL , else return the pointer of the connection + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO + ***************************************************************************/ +CONNECT_INFO *mgc_mg_info_assign_idle_connection(MG_INFO *pMgInfo) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + CONNECT_INFO *pConnect = NULL; + + if(pMgInfo == NULL) + return NULL; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + pConnect = mgc_phy_port_assign_idle_connection(pPhyPort); + + if(pConnect == NULL) + continue; + + return pConnect; + } + + return NULL; +} + + + +/*************************************************************************** + * mgc_mg_info_find_idle_chnl_info + * ------------------------------------------------------------------------ + * General: find a idle chnl which is not attached by any connection in the specific MG_INFO object + * Return Value: if failure return NUL , else return the pointer of the CHNL_INFO + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG_INFO + ***************************************************************************/ +CHNL_INFO *mgc_mg_info_find_idle_chnl_info(MG_INFO *pMgInfo) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + + if(pMgInfo == NULL) + return NULL; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + pChnlInfo = mgc_phy_port_find_idle_chnl(pPhyPort); + if(pChnlInfo == NULL) + continue; + + return pChnlInfo; + } + + return NULL; +} + + +/*************************************************************************** + * mgc_mg_info_assign_aas_tone_connection + * ------------------------------------------------------------------------ + * General: assign a idle connection according to the Tone + * Return Value: if failure return NUL , else return the pointer of the connection + * ------------------------------------------------------------------------ + * Arguments: + * Input: toneNo - tone id + ***************************************************************************/ +CONNECT_INFO *mgc_mg_info_assign_aas_tone_connection(BYTE toneNo) +{ + int i; + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CONNECT_INFO *pConnect = NULL; + + pMgInfo = mgc_mg_info_find_available_mg(MGC_MG_TYPE_ANN); + if(pMgInfo == NULL) + return NULL; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->pMgcSap->usrType != MGC_USER_TYPE_MGC) + continue; + + break; + } + + if(pPhyPort == NULL) + return NULL; + + pChnlInfo = mgc_chnl_info_find_chnl_of_phy(pPhyPort, toneNo); + if(pChnlInfo == NULL) + return NULL; + + pConnect = mgc_chnl_info_assign_idle_connect(pChnlInfo); + if(pConnect == NULL) + return NULL; + + MGC_DEBUG("aas phyPort[%d] assign chnl[%d] conn[%d] to send tone" , pPhyPort->id, toneNo, pConnect->id); + return pConnect; +} + +void mgc_mg_info_set_mon(int id , BOOL enable ) +{ + MG_INFO *pMgInfo = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(id); + if(pMgInfo == NULL) + return; + + pMgInfo->monFlag = enable; +} + +BYTE *mgc_mg_info_get_res_addr(void) +{ + return (BYTE *)mgcMgInfo; +} + + +static char *mgc_mg_info_print_mg_type(MGC_MG_TYPE type) +{ + switch(type) + { + case MGC_MG_TYPE_INTERNAL: + return "MGC_MG_TYPE_INTERNAL"; + case MGC_MG_TYPE_AudioCoder: + return "MGC_MG_TYPE_AudioCoder"; + case MGC_MG_TYPE_LGC_MG: + return "MGC_MG_TYPE_LGC_MG"; + case MGC_MG_TYPE_SSW_CSS: + return "MGC_MG_TYPE_SSW_CSS"; + case MGC_MG_TYPE_IPBSS: + return "MGC_MG_TYPE_IPBSS"; + case MGC_MG_TYPE_ANALOG: + return "MGC_MG_TYPE_ANALOG"; + case MGC_MG_TYPE_TANDEM: + return "MGC_MG_TYPE_TANDEM"; + case MGC_MG_TYPE_ANN: + return "MGC_MG_TYPE_ANN"; + default: + break; + } + + return "MGC_MG_TYPE_UNDEF"; +} + + +static char *mgc_mg_info_print_ip(DWORD addr) +{ + struct sockaddr_in sin; + + sin.sin_addr.s_addr = addr; + return ((char *) inet_ntoa(sin.sin_addr) ); +} + + +static char *mgc_mg_info_print_ctl_type(MGC_MG_CTRL_TYPE ctlType) +{ + switch(ctlType) + { + case MGC_MG_CTRL_TYPE_MGCP: + return "MGC_MG_CTRL_TYPE_MGCP"; + case MGC_MG_CTRL_TYPE_8ECP: + return "MGC_MG_CTRL_TYPE_8ECP"; + default: + break; + } + + return "MGC_MG_CTRL_TYPE_UNDEF"; +} + +static char *mgc_mg_info_print_codec_list(MGC_CODEC_LIST codecList) +{ + int i; + static char buf[256]; + + memset(buf , 0 ,256); + + for(i=0 ; i= 255) + break; + } + + return buf; +} + +void mgc_mg_info_print_info(MG_INFO *pMgInfo) +{ + MG_ATTR *pAttr; + int i; + PHY_PORT_INFO *pPhyPort; + + if(pMgInfo == NULL) + return; + + if(pMgInfo->created == FALSE) + { + MGC_INFO("mgInfo[%d] is not created! " , pMgInfo->id); + return; + } + + pAttr = &pMgInfo->mgAttr; + + MGC_INFO("--------mgInfo[%d] %s---------" , pMgInfo->id , pMgInfo->enable?"ENABLE":"DISABLE"); + MGC_INFO("Domain : %s" , pAttr->domain); + MGC_INFO("Type : %s" , mgc_mg_info_print_mg_type(pAttr->mgType)); + MGC_INFO("Ip : %s" , mgc_mg_info_print_ip(pAttr->ip)); + MGC_INFO("CTL TYPE : %s" , mgc_mg_info_print_ctl_type(pAttr->ctrlType)); + if(pAttr->epDes == MGCP_EP_NAME_UNSTRUCTURED) + { + MGC_INFO("epDes : MGCP_EP_NAME_UNSTRUCTURED"); + } + else if(pAttr->epDes == MGCP_EP_NAME_STRUCTURED) + { + MGC_INFO("epDes : MGCP_EP_NAME_STRUCTURED"); + } + else + { + MGC_INFO("epDes : MGCP_EP_NAME_UNKNOWN"); + } + + MGC_INFO("tonCap : %s" , (pAttr->toneCap == 1)?"ON":"OFF"); + MGC_INFO("ptime : %d" , pAttr->ptime); + MGC_INFO("audit time : %ld" , pAttr->auditTimer); + MGC_INFO("e1cardNo : %d" , pAttr->e1cardNo); + MGC_INFO("maxPort : %d" , pAttr->maxPorts); + MGC_INFO("maxChnl : %d" , pAttr->maxChnls); + MGC_INFO("codelist len %d : %s" , pAttr->codecList.num , mgc_mg_info_print_codec_list(pAttr->codecList)); + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->portNo == ITL_OPERA_PORT_NO) + continue; + + mgc_phy_port_print(pPhyPort); + } + MGC_INFO("--------mgInfo[%d] end---------" , pMgInfo->id); + return; +} + + + +#ifdef MGC_TEST_ENABLE +int mgc_mg_info_created_num(void) +{ + int i , num; + MG_INFO *pMgInfo = NULL; + + num = 0; + for(i=0 ; icreated) + num++; + } + + return num; +} + +#endif diff --git a/omc/plat/mgc_v2/src/mgc_mgcp.c b/omc/plat/mgc_v2/src/mgc_mgcp.c new file mode 100644 index 0000000..cfd39b5 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_mgcp.c @@ -0,0 +1,1398 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +*/ + + +/********************************************************************************* + * + * This file should provide MGCP related APIs, ind callback and cnf callback, MGCP paramter create + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + + + +#include "./include/mgc_mgcp.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_port_info.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_tandem_info.h" + +static MGC_MGCP_SAP mgcMgcpSap; + + +/*----------------------------------------------------------------------- + MGCP M A N A G E R + ------------------------------------------------------------------------*/ + +BYTE mgc_mgcp_convert_cmd_to_mgcp(MGC_CMD_TYPE mgcCmd) +{ + switch(mgcCmd) + { + case MGC_CMD_CRCX: + return MGCP_CMD_CRCX; + case MGC_CMD_MDCX: + return MGCP_CMD_MDCX; + case MGC_CMD_DLCX: + return MGCP_CMD_DLCX; + case MGC_CMD_RQNT: + return MGCP_CMD_RQNT; + case MGC_CMD_NTFY: + return MGCP_CMD_NTFY; + case MGC_CMD_AUEP: + return MGCP_CMD_AUEP; + case MGC_CMD_RSIP: + return MGCP_CMD_RSIP; + default: + return 127; + } +} + + +char *mgc_mgcp_print_mgc_mode(MGC_CON_MODE mode) +{ + switch(mode) + { + case MGC_CON_MODE_INACTIVE: + return "MGC_CON_MODE_INACTIVE"; + case MGC_CON_MODE_RECVONLY: + return "MGC_CON_MODE_RECVONLY"; + case MGC_CON_MODE_SENDONLY: + return "MGC_CON_MODE_SENDONLY"; + case MGC_CON_MODE_SENDRECV: + return "MGC_CON_MODE_SENDRECV"; + case MGC_CON_MODE_OWN: + return "MGC_CON_MODE_OWN"; + default: + break; + } + + return "MGC_CON_MODE_UNDEF"; +} + + +MGC_CON_MODE mgc_mgcp_convert_to_mgc_mode(BYTE mode) +{ + switch(mode) + { + case MGCP_CON_MODE_INACTIVE: + return MGC_CON_MODE_INACTIVE; + case MGCP_CON_MODE_SENDONLY: + return MGC_CON_MODE_SENDONLY; + case MGCP_CON_MODE_RECVONLY: + return MGC_CON_MODE_RECVONLY; + case MGCP_CON_MODE_SENDRECV: + return MGC_CON_MODE_SENDRECV; + default: + break; + } + + return MGC_CON_MODE_INACTIVE; +} + +BYTE mgc_mgcp_conver_to_mgcp_mode(MGC_CON_MODE mode) +{ + switch(mode) + { + case MGC_CON_MODE_INACTIVE: + return MGCP_CON_MODE_INACTIVE; + case MGC_CON_MODE_SENDONLY: + return MGCP_CON_MODE_SENDONLY; + case MGC_CON_MODE_RECVONLY: + return MGCP_CON_MODE_RECVONLY; + case MGC_CON_MODE_SENDRECV: + return MGCP_CON_MODE_SENDRECV; + default: + break; + } + + return MGCP_CON_MODE_INACTIVE; +} + +MGC_CMD_TYPE mgc_mgcp_convert_mgcp_to_cmd(BYTE mgcpCmd) +{ + switch(mgcpCmd) + { + case MGCP_CMD_CRCX: + return MGC_CMD_CRCX; + case MGCP_CMD_MDCX: + return MGC_CMD_MDCX; + case MGCP_CMD_DLCX: + return MGC_CMD_DLCX; + case MGCP_CMD_RQNT: + return MGC_CMD_RQNT; + case MGCP_CMD_NTFY: + return MGC_CMD_NTFY; + case MGCP_CMD_AUEP: + return MGC_CMD_AUEP; + case MGCP_CMD_RSIP: + return MGC_CMD_RSIP; + default: + return MGC_CMD_UNDEF; + } +} + + +BOOL mgc_mgcp_check_codec_valid(MGC_VCTYPE codec) +{ + switch(codec) + { + case MGC_VCTYPE_PCMA: + case MGC_VCTYPE_PCMU: + case MGC_VCTYPE_GSM: + case MGC_VCTYPE_GSM_EFR: + case MGC_VCTYPE_AMR_12_2: + case MGC_VCTYPE_G729B: + case MGC_VCTYPE_AMR_10_2: + case MGC_VCTYPE_AMR_7_95: + case MGC_VCTYPE_AMR_7_4: + case MGC_VCTYPE_AMR_6_7: + case MGC_VCTYPE_AMR_5_15: + case MGC_VCTYPE_AMR_5_9: + case MGC_VCTYPE_AMR_4_75: + return TRUE; + default : + break; + } + + return FALSE; +} + +/*************************************************************************** + * mgc_mgcp_match_codec_list + * ------------------------------------------------------------------------ + * General: do codecList negotiate + * Return Value: if failure return -1 , else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: + ***************************************************************************/ +int mgc_mgcp_match_codec_list(MGC_CODEC_LIST *dest, MGC_CODEC_LIST *aParty, MGC_CODEC_LIST *bParty) +{ + BYTE i, j; + MGC_CODEC_LIST *base = NULL; + MGC_CODEC_LIST *highPri = NULL; + MGC_CODEC_LIST base_list , high_list , res_list; + + if ((dest == NULL)||(aParty == NULL)||(bParty == NULL)) + { + MGC_ERROR("mgc_match_codec_list: dest == NULL!\n\r"); + return -1; + } + dest->num = 0; + dest->priority = 0; + + if (aParty->priority >= bParty->priority) + { + base = bParty; + highPri = aParty; + } + else + { + base = aParty; + highPri = bParty; + } + + if (aParty->codec[0] == MGC_VCTYPE_G729B) + { + base = bParty; + highPri = aParty; + } + else if (bParty->codec[0] == MGC_VCTYPE_G729B) + { + base = aParty; + highPri = bParty; + } + + + mgc_connect_codec_list_init(&base_list); + mgc_connect_codec_list_init(&high_list); + mgc_connect_codec_list_init(&res_list); + + for(i=0 ; icodec[i]) == TRUE) + { + base_list.codec[base_list.num] = base->codec[i]; + base_list.num++; + } + + if(mgc_mgcp_check_codec_valid(highPri->codec[i]) == TRUE) + { + high_list.codec[high_list.num] = highPri->codec[i]; + high_list.num++; + } + } + + if(base_list.num != base->num) + { + MGC_WARN("codeclist rec wrong codec num!"); + } + base_list.priority= base->priority; + memcpy(base , &base_list , sizeof(MGC_CODEC_LIST)); + + if(high_list.num!= highPri->num) + { + MGC_WARN("codeclist rec wrong codec num!"); + } + high_list.priority = highPri->priority; + memcpy(highPri , &high_list , sizeof(MGC_CODEC_LIST)); + + + if((base->num == 0)&&(highPri->num == 0)) + { + MGC_ERROR("negotiate list all are none!"); + return -1; + } + + if (base->num == 0) + { + memcpy(&res_list , highPri , sizeof(MGC_CODEC_LIST)); + } + else if (highPri->num == 0) + { + memcpy(&res_list , base , sizeof(MGC_CODEC_LIST)); + } + else if((base->num !=0 )&&(highPri->num != 0)) + { + for (i = 0; i < highPri->num; i++) + { + for (j = 0; j < base->num; j++) + { + if (highPri->codec[i] == base->codec[j]) + { + res_list.codec[res_list.num] = highPri->codec[i]; + res_list.num++; + break; + } + } + } + + } + + if(res_list.num > 0) + { + res_list.priority = highPri->priority; + memcpy(dest , &res_list , sizeof(MGC_CODEC_LIST)); + return 0; + } + + MGC_ERROR("%s failed!" , __FUNCTION__); + MGC_ERROR("base list:"); + for(i=0 ; inum ; i++) + { + MGC_ERROR("%s" , mgc_mgcp_print_vc_codec(base->codec[i])); + } + MGC_ERROR("high list:"); + for(i=0 ; inum ; i++) + { + MGC_ERROR("%s" , mgc_mgcp_print_vc_codec(highPri->codec[i])); + } + return -1; + } + + +char *mgc_mgcp_print_ip(DWORD addr) +{ + struct sockaddr_in sin; + + sin.sin_addr.s_addr = addr; + return ((char *) inet_ntoa(sin.sin_addr) ); +} + +/*************************************************************************** + * mgc_mgcp_ind_para_valid_check + * ------------------------------------------------------------------------ + * General: check the incoming ind is valid + * Return Value: if valid return TRUE, else return FALSE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPara - the paramter to be parsed + ***************************************************************************/ +BOOL mgc_mgcp_ind_para_valid_check(MGCP_PARA *pPara) +{ + if(pPara == NULL) + { + MGC_ERROR("%s: para is NULL" , __FUNCTION__); + return FALSE; + } + + if((pPara->flag & MGCP_PARA_FLAG_SL) != MGCP_PARA_FLAG_SL) + { + MGC_ERROR("%s: start line is lost" , __FUNCTION__); + return FALSE; + } + + if(mgc_mgcp_print_ip(pPara->ip) == NULL) + { + MGC_ERROR("%s: srcIP is lost" , __FUNCTION__); + return FALSE; + } + + if((pPara->localPort != MGC_MG_NETWORK_PORT)&&(pPara->localPort != MGC_MGC_NETWORK_PORT)) + { + MGC_ERROR("%s: portNo is illegal" , __FUNCTION__); + return FALSE; + } + + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_find_conn_by_con_id + * ------------------------------------------------------------------------ + * General: find CONNCET_INFO object by parameter + * Return Value: if failure return NULL , else return the pointer of CONNCET_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPara - the paramter to be parsed + ***************************************************************************/ +CONNECT_INFO *mgc_mgcp_find_conn_by_con_id(MGCP_PARA *pPara) +{ + int i , j; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + + if(pPara == NULL) + return NULL; + + if(pPara->sl.epNameMethod == MGCP_EP_NAME_STRUCTURED) + { + pPhyPort = mgc_mg_info_find_port_by_name_and_portNo(pPara->sl.mgName, pPara->sl.trkNum, pPara->localPort); + } + else + { + pPhyPort = mgc_mg_info_find_port_by_name(pPara->sl.mgName, pPara->localPort); + } + if(pPhyPort == NULL) + return NULL; + + for(i=0 ; ipChnlInfo[i]; + + if(pChnlInfo == NULL) + continue; + + for(j=0 ; jpConnection[j]; + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + continue; + + if(strcmp(pConnect->mediaAttr.conId , pPara->i.conId) != 0) + continue; + MGC_DEBUG("conn[%d] is found" , pConnect->id); + return pConnect; + } + } + + return NULL; +} + + +/*************************************************************************** + * mgc_mgcp_ind + * ------------------------------------------------------------------------ + * General: ind callback func of the MGCP module + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: cmd - the MGCP command type + * usrPort - the user id tagged by MGC and will be used in send response + * hdlPort - operate tag from MGCP layer + * pPara - MGCP msg + ***************************************************************************/ +int mgc_mgcp_ind(BYTE cmd, WORD *usrPort, WORD hdlPort, MGCP_PARA *pPara) +{ + CONNECT_INFO *pConnect = NULL; + BOOL result = FALSE; + PORT_INFO *pPortInfo = NULL; + int retCode = 404; + MGC_CMD_TYPE mgcCmd; + MG_INFO *pMgInfo = NULL; + + if(mgc_mgcp_ind_para_valid_check(pPara) == FALSE) + return -1; + + pPortInfo = mgc_port_info_get_unused_port(); + if(pPortInfo == NULL) + return -1; + + mgcCmd = mgc_mgcp_convert_mgcp_to_cmd(cmd); + + pConnect = mgc_mgcp_find_conn_by_con_id(pPara); + if((mgcCmd != MGC_CMD_AUEP)&&(mgcCmd != MGC_CMD_RSIP)) + { + MGC_DEBUG("receive ind %s " , mgc_port_info_print_cmd(mgcCmd)); + } + + switch(mgcCmd) + { + case MGC_CMD_MDCX: + break; + case MGC_CMD_DLCX: + break; + case MGC_CMD_CRCX: + case MGC_CMD_RQNT: + case MGC_CMD_NTFY: + if(pConnect == NULL) + pConnect = mgc_connect_assign_conn_by_para(pPara); + break; + case MGC_CMD_RSIP: + case MGC_CMD_AUEP: + pMgInfo = mgc_mg_info_find_mg_by_name(pPara->sl.mgName); + retCode = 200; + if(pMgInfo == NULL) + retCode = 404; + pPara->flag = 0; + pPara->sl.cmdRes = MGCP_RESPONSE; + pPara->flag |= MGCP_PARA_FLAG_SL; + pPara->localPort = MGC_MGCP_MG_PORT; + pPara->peerPort = MGC_MGCP_MGC_PORT; + MGCP_rsp(mgc_mgcp_get_sap_index(), cmd, *usrPort ,hdlPort, retCode,pPara); + return 0; + default: + break; + } + + if(pConnect != NULL) + { + result = mgc_connect_req_parse_para(pConnect, pPara); + } + + if(result == FALSE) + { + if(pConnect != NULL) + mgc_connect_init(pConnect, pConnect->id); + + pPara->flag = 0; + pPara->sl.cmdRes = MGCP_RESPONSE; + pPara->flag |= MGCP_PARA_FLAG_SL; + pPara->localPort = MGC_MGCP_MG_PORT; + pPara->peerPort = MGC_MGCP_MGC_PORT; + MGC_WARN("send ind %s resp %d" , mgc_port_info_print_cmd(mgcCmd) , retCode); + MGCP_rsp(mgc_mgcp_get_sap_index(), cmd, *usrPort,hdlPort, retCode, pPara); + /*send some error resp*/ + return 0; + } + + *usrPort = pConnect->id; + mgc_port_info_add_ind_to_port(pPortInfo , pConnect , mgcCmd , hdlPort, pPara->ip); + mgc_port_info_set_oper_id(pPortInfo,MGC_OPER_ID_IND); + mgc_port_info_set_fsm_time(pPortInfo,MGC_MGCF_TIMER_20MS); + mgc_port_info_set_step_to_start(pPortInfo); + return 0; +} + + +/*************************************************************************** + * mgc_mgcp_cnf + * ------------------------------------------------------------------------ + * General: cnf callback func of the MGCP module + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: cmd - the MGCP command type + * usrPort - the user id tagged by MGC and will be used in send response + * hdlPort - operate tag from MGCP layer + * pPara - MGCP msg + ***************************************************************************/ +int mgc_mgcp_cnf(BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para) +{ + PORT_INFO *pPortInfo = NULL; + int ret; + pPortInfo = mgc_port_info_find_port_by_id(usrPort); + if(pPortInfo == NULL) + { + MGC_WARN("lost mgcp response owner , usrPort[%d]" , usrPort); + return -1; + } + + ret = mgc_port_info_cnf(pPortInfo , cmd, hdlPort, retCode, para); + return ret; +} + + +/*************************************************************************** + * mgc_bind_mgcp + * ------------------------------------------------------------------------ + * General: bind MGC to the MGCP module + * Return Value: if failure return -1, else return SapIndex of the MGCP module + * ------------------------------------------------------------------------ + * Arguments: + * Input: pSap - the parameter of MGCP info in MGC module + ***************************************************************************/ +static int mgc_bind_mgcp(MGC_MGCP_SAP *pSap) +{ + if(pSap == NULL) + return 0; + + sprintf(pSap->sapMgcp.name , "MGC"); + pSap->sapMgcp.MGCP_cnf = mgc_mgcp_cnf; + pSap->sapMgcp.MGCP_ind = mgc_mgcp_ind; + + pSap->sapIndex = mgcp_bind(&pSap->sapMgcp); + if(pSap->sapIndex < 0) + { + MGC_ERROR("MGCP %s bind failed!" , pSap->sapMgcp.name); + return -1; + } + + return pSap->sapIndex; +} + +int mgc_bind_mgcp_setup(void) +{ + MGC_MGCP_SAP *pSap = NULL; + + pSap = &mgcMgcpSap; + + if(mgc_bind_mgcp(pSap) < 0) + return -1; + return 0; +} + +/*************************************************************************** + * mgc_mgcp_get_sap_index + * ------------------------------------------------------------------------ + * General: get MGCP sap of MGC module + * Return Value: MGCP sap + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +int mgc_mgcp_get_sap_index(void) +{ + return(mgcMgcpSap.sapIndex); +} + + +/*************************************************************************** + * mgc_mgcp_str_to_vc_code + * ------------------------------------------------------------------------ + * General: translate codec string into codec + * Return Value: MGC_VCTYPE + * ------------------------------------------------------------------------ + * Arguments: + * Input: codec - codec name + ***************************************************************************/ +MGC_VCTYPE mgc_mgcp_str_to_vc_code(char *codec) +{ + if (strcmp(codec, "PCMA") == 0) + return MGC_VCTYPE_PCMA; + else if (strcmp(codec, "PCMU") == 0) + return MGC_VCTYPE_PCMU; + else if (strcmp(codec, "GSM") == 0) + return MGC_VCTYPE_GSM; + else if (strcmp(codec, "GSM-EFR") == 0) + return MGC_VCTYPE_GSM_EFR; + else if (strcmp(codec, "AMR") == 0) + return MGC_VCTYPE_AMR_12_2; + else if (strcmp(codec, "G729B") == 0) + return MGC_VCTYPE_G729B; + else if (strcmp(codec, "AMR_12_2") == 0) + return MGC_VCTYPE_AMR_12_2; + else if (strcmp(codec, "AMR_10_2") == 0) + return MGC_VCTYPE_AMR_10_2; + else if (strcmp(codec, "AMR_7_95") == 0) + return MGC_VCTYPE_AMR_7_95; + else if (strcmp(codec, "AMR_7_4") == 0) + return MGC_VCTYPE_AMR_7_4; + else if (strcmp(codec, "AMR_6_7") == 0) + return MGC_VCTYPE_AMR_6_7; + else if (strcmp(codec, "AMR_5_15") == 0) + return MGC_VCTYPE_AMR_5_15; + else if (strcmp(codec, "AMR_5_9") == 0) + return MGC_VCTYPE_AMR_5_9; + else if (strcmp(codec, "AMR_4_75") == 0) + return MGC_VCTYPE_AMR_4_75; + return MGC_VCTYPE_UNSUPPORT; +} + + +/*************************************************************************** + * mgc_mgcp_print_vc_codec + * ------------------------------------------------------------------------ + * General: translate codec to string + * Return Value: codec name + * ------------------------------------------------------------------------ + * Arguments: + * Input: vcCodec - MGC voice codec + ***************************************************************************/ +char *mgc_mgcp_print_vc_codec(MGC_VCTYPE vcCodec) +{ + switch(vcCodec) + { + case MGC_VCTYPE_PCMA: + return "PCMA"; + case MGC_VCTYPE_PCMU: + return "PCMU"; + case MGC_VCTYPE_GSM: + return "GSM"; + case MGC_VCTYPE_GSM_EFR: + return "GSM-EFR"; + case MGC_VCTYPE_G729B: + return "G729B"; + case MGC_VCTYPE_AMR_12_2: + return "AMR"; + case MGC_VCTYPE_AMR_10_2: + return "AMR_10_2"; + case MGC_VCTYPE_AMR_7_95: + return "AMR_7_95"; + case MGC_VCTYPE_AMR_7_4: + return "AMR_7_4"; + case MGC_VCTYPE_AMR_6_7: + return "AMR_6_7"; + case MGC_VCTYPE_AMR_5_15: + return "AMR_5_15"; + case MGC_VCTYPE_AMR_5_9: + return "AMR_5_9"; + case MGC_VCTYPE_AMR_4_75: + return "AMR_4_75"; + default: + return "UNSUPPORT"; + } +} + +/*************************************************************************** + * mgc_mgcp_print_vc_num + * ------------------------------------------------------------------------ + * General: translate codec to codec num + * Return Value: codec num + * ------------------------------------------------------------------------ + * Arguments: + * Input: vcCodec -MGC voice codec + ***************************************************************************/ +int mgc_mgcp_print_vc_num(MGC_VCTYPE vcCodec) +{ + switch(vcCodec) + { + case MGC_VCTYPE_PCMA: + return 8; + case MGC_VCTYPE_PCMU: + return 0; + case MGC_VCTYPE_GSM: + return 3; + case MGC_VCTYPE_GSM_EFR: + return 84; + case MGC_VCTYPE_G729B: + return 118; + case MGC_VCTYPE_AMR_12_2: + return 71; + case MGC_VCTYPE_AMR_10_2: + return 70; + case MGC_VCTYPE_AMR_7_95: + return 69; + case MGC_VCTYPE_AMR_7_4: + return 68; + case MGC_VCTYPE_AMR_6_7: + return 67; + case MGC_VCTYPE_AMR_5_15: + return 65; + case MGC_VCTYPE_AMR_5_9: + return 66; + case MGC_VCTYPE_AMR_4_75: + return 64; + default: + return 8; + } + +} + +/*************************************************************************** + * mgc_mgcp_create_connect_dest_ip + * ------------------------------------------------------------------------ + * General:create mgcp dest ip + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_dest_ip(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + MGCF_OPER_STEP *pStep = NULL; + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + pMgcSap = mgc_connect_get_conn_report_sap(pConnect); + if(pMgcSap == NULL) + return FALSE; + + pStep = mgc_connect_get_step_info(pConnect); + if(pStep == NULL) + return FALSE; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return FALSE; + + if(pMgcSap->usrType == MGC_USER_TYPE_MGC) + { + pPara->ip = pMgInfo->mgAttr.ip; + } + else if(pMgcSap->usrType == MGC_USER_TYPE_MG) + { + pPara->ip = pStep->stepInfo.remoteIp; + } + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_create_connect_port + * ------------------------------------------------------------------------ + * General:create mgcp dest port + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_port(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + PHY_PORT_INFO *pPhyPort = NULL; + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + + pPhyPort= mgc_connect_get_own_phy_port_info(pConnect); + if(pPhyPort == NULL) + return FALSE; + + if(pPhyPort->pMgcSap == NULL) + { + MGC_ERROR("mgcPhyPort[%d] lost owner" , pPhyPort->id); + return FALSE; + } + + switch(pPhyPort->pMgcSap->usrType) + { + case MGC_USER_TYPE_MG: + pPara->localPort = MGC_MGCP_MG_PORT; + pPara->peerPort = MGC_MGCP_MGC_PORT; + break; + case MGC_USER_TYPE_MGC: + pPara->localPort= MGC_MGCP_MGC_PORT; + pPara->peerPort= MGC_MGCP_MG_PORT; + break; + default: + MGC_ERROR("mgcSap[%d] %s , unsupport type %d" , pPhyPort->pMgcSap->id , pPhyPort->pMgcSap->usrName, pPhyPort->pMgcSap->usrType); + return FALSE; + } + + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_create_connect_resp_start_line + * ------------------------------------------------------------------------ + * General:create mgcp response start line + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_resp_start_line(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + pPara->sl.cmdRes = MGCP_RESPONSE; + pPara->flag |= MGCP_PARA_FLAG_SL; + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_create_connect_req_start_line + * ------------------------------------------------------------------------ + * General:create mgcp request start line + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_req_start_line(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MG_INFO *pMgInfo = NULL; + MGCP_SL *pSl = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + if(pChnlInfo == NULL) + return FALSE; + + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + if(pPhyPort == NULL) + return FALSE; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return FALSE; + + pSl = &pPara->sl; + pSl->cmdRes = MGCP_COMMAND; + pSl->epNameMethod = pMgInfo->mgAttr.epDes; + pSl->mgType = pMgInfo->mgAttr.mgType; + + + switch(pPhyPort->portType) + { + case MGC_PHY_PORT_TYPE_E1: + pSl->portType = MGC_PHY_PORT_TYPE_E1; + break; + case MGC_PHY_PORT_TYPE_T1: + pSl->portType = MGC_PHY_PORT_TYPE_T1; + break; + case MGC_PHY_PORT_TYPE_ANALOG: + pSl->portType = MGC_PHY_PORT_TYPE_ANALOG; + break; + case MGC_PHY_VIRTUAL_TYPE_INTERNAL: + case MGC_PHY_VIRTUAL_TYPE_ANN: + case MGC_PHY_VIRTUAL_TYPE_TANDEM: + case MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE: + pSl->portType = 0 ; //?? uncertain + break; + default: + MGC_WARN("unsupport port type %d" , pPhyPort->portType); + return FALSE; + } + + pSl->trkNum = pPhyPort->portNo; + pSl->chlNum = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo , pPhyPort); + sprintf(pSl->mgName , "%s" , pMgInfo->mgAttr.domain); + pPara->flag |= MGCP_PARA_FLAG_SL; + + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_create_connect_con_mode + * ------------------------------------------------------------------------ + * General:create mgcp mode info + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_con_mode(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCF_OPER_STEP *pStep = NULL; + if((pConnect == NULL) || (pPara == NULL)||(pConnect->pOperStep == NULL)) + return FALSE; + + pStep = pConnect->pOperStep; + mgc_connect_set_conn_mode(pConnect, pStep->stepInfo.mode); + pPara->m.mode = mgc_mgcp_conver_to_mgcp_mode(pConnect->mediaAttr.conMode); + pPara->flag |= MGCP_PARA_FLAG_M; + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_create_connect_con_id + * ------------------------------------------------------------------------ + * General:create mgcp connection id + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_con_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + if(strlen(pConnect->mediaAttr.conId) == 0) + return TRUE; + + sprintf(pPara->i.conId , "%s" , pConnect->mediaAttr.conId); + pPara->flag |= MGCP_PARA_FLAG_I; + + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_create_connect_call_id + * ------------------------------------------------------------------------ + * General:create mgcp call id + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_call_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + if(strlen(pConnect->mediaAttr.callId) == 0) + return TRUE; + + sprintf(pPara->c.callId, "%s" , pConnect->mediaAttr.callId); + pPara->flag |= MGCP_PARA_FLAG_C; + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_create_connect_pkg_sig + * ------------------------------------------------------------------------ + * General:create mgcp signal event + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_pkg_sig(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCF_OPER_STEP *pStep = NULL; + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + pStep = mgc_connect_get_step_info(pConnect); + if(pStep == NULL) + return FALSE; + + if(pStep->stepInfo.sigEn == FALSE) // no sig is needed + return TRUE; + + pPara->s.pkg = pStep->stepInfo.pkgSig.pkg; + pPara->s.signal = pStep->stepInfo.pkgSig.signal; + pPara->flag |= MGCP_PARA_FLAG_S; + MGC_DEBUG("conn[%d] create pkg[%d]sig[%d]" , pConnect->id , pConnect->mediaAttr.pkgSignal.pkg ,pConnect->mediaAttr.pkgSignal.signal); + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_create_connect_pkg_req + * ------------------------------------------------------------------------ + * General:create mgcp req event + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_pkg_req(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCF_OPER_STEP *pStep = NULL; + if((pConnect == NULL) || (pPara == NULL)) + return FALSE; + + pStep = mgc_connect_get_step_info(pConnect); + if(pStep == NULL) + return FALSE; + + if(pStep->stepInfo.reqEn== FALSE) // no sig is needed + return TRUE; + + pPara->r.pkg = pStep->stepInfo.pkgReq.pkg; + pPara->r.event= pStep->stepInfo.pkgReq.req; + pPara->flag |= MGCP_PARA_FLAG_R; + MGC_DEBUG("conn[%d] create pkg[%d]req[%d]" , pConnect->id , pConnect->mediaAttr.pkgReq.pkg ,pConnect->mediaAttr.pkgReq.req); + return TRUE; +} + + + +/*************************************************************************** + * mgc_mgcp_create_connect_local_opt + * ------------------------------------------------------------------------ + * General:create mgcp local description + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_local_opt(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MG_INFO *pMgInfo = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if((pConnect == NULL) || (pPara == NULL)||(pMgInfo == NULL)) + return FALSE; + + if(pConnect->pTandem) + { + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem , pConnect) == MGC_TANDEM_CONN_POS_RX) + { + sprintf(pPara->l.esCci , "%s" , pTandem->escci); + pPara->l.flag |= MGCP_PARA_L_FLAG_ESS_CCI; + } + + + if(mgc_tandem_info_get_conn_pos(pTandem , pConnect) == MGC_TANDEM_CONN_POS_TX) + { + sprintf(pPara->l.esCci , "%s" , pTandem->escci); + pPara->l.flag |= MGCP_PARA_L_FLAG_ESS_CCI; + } + } + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_IPBSS) + { + switch(pConnect->mediaAttr.vocoderType) + { + case MGC_VCTYPE_AMR_12_2: + case MGC_VCTYPE_AMR_10_2: + case MGC_VCTYPE_AMR_7_95: + case MGC_VCTYPE_AMR_7_4: + case MGC_VCTYPE_AMR_6_7: + case MGC_VCTYPE_AMR_5_15: + case MGC_VCTYPE_AMR_5_9: + case MGC_VCTYPE_AMR_4_75: + sprintf(pPara->l.codec , "AMR"); + break; + default: + sprintf(pPara->l.codec , "%s" , mgc_mgcp_print_vc_codec(pConnect->mediaAttr.vocoderType)); + break; + } + } + else + { + sprintf(pPara->l.codec , "%s" , mgc_mgcp_print_vc_codec(pConnect->mediaAttr.vocoderType)); + } + + pPara->l.p = pConnect->mediaAttr.ptime; + pPara->l.ecDisable = pConnect->mediaAttr.ecDisable; + pPara->l.ssDisable = pConnect->mediaAttr.ssDisable; + + pPara->flag |= MGCP_PARA_FLAG_L; + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_create_connect_sdp + * ------------------------------------------------------------------------ + * General:create mgcp sdp info + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP msg + * pPara - the MSG which will be send out + ***************************************************************************/ +BOOL mgc_mgcp_create_connect_sdp(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + CONNECT_INFO *pTmpConnect = NULL; + MGCF_STEP_INFO *pStep = NULL; + PUB_SDP_A *pSdpAttr = NULL; + PUB_SDP_MEDIA *pMedia = NULL; + int i; + char tmp[PUB_SDP_MAX_ATTR_LEN]; + + if((pConnect == NULL) || (pPara == NULL)||(pConnect->pOperStep == NULL)) + return FALSE; + + pStep = &(pConnect->pOperStep->stepInfo); + pTmpConnect = pStep->pPeerConn; + pMedia = &pPara->sdp.medias.medias[0]; + if(pTmpConnect == NULL) + return FALSE; + + memcpy(&pPara->sdp , &(pTmpConnect->mediaAttr.sdp) , sizeof(PUB_SDP_MSG)); + pMedia->attrs.num = 0; + if((pMedia->flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + for(i=0 ; i< pMedia->attrs.num ; i++ ) + { + pSdpAttr = &pMedia->attrs.attrs[i]; + if(pSdpAttr->aType != 0) + { + pMedia->attrs.num++; + continue; + } + + memset(pSdpAttr->aValue , 0 , PUB_SDP_MAX_ATTR_LEN); + } + } + + + pPara->sdp.medias.num = 1; + pMedia->m.payloads[0] = mgc_mgcp_print_vc_num(pConnect->mediaAttr.vocoderType); + + switch(pConnect->mediaAttr.conMode) + { + case MGC_CON_MODE_RECVONLY: + sprintf(tmp , "recvonly"); + break; + case MGC_CON_MODE_SENDONLY: + sprintf(tmp, "sendonly"); + break; + case MGC_CON_MODE_SENDRECV: + sprintf(tmp , "sendrecv"); + break; + default: + sprintf(tmp, "inactive"); + break; + } + + pSdpAttr = NULL; + for(i=0 ; iattrs.attrs[pMedia->attrs.num]; + + if(pSdpAttr->aType != 0) + continue; + + sprintf(pSdpAttr->aValue , "%s" , tmp); + pMedia->attrs.num++; + pPara->sdp.medias.medias[0].flag |= PUB_SDP_FLAG_A; + break; + } + + pPara->flag |= MGCP_PARA_FLAG_SDP; + + if((pPara->sdp.flag & PUB_SDP_FLAG_O) == 0) + { + MGC_WARN("lost sdp"); + } + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_parse_connect_local_opt + * ------------------------------------------------------------------------ + * General: parse mgcp local descritpion + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_local_opt(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCP_L *pL = NULL; + MEDIA_ATTR *pMediaAttr = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_L) != MGCP_PARA_FLAG_L) + return TRUE; + + pL = &pPara->l; + pMediaAttr = &pConnect->mediaAttr; + + pMediaAttr->ecDisable = pL->ecDisable; + pMediaAttr->ssDisable = pL->ssDisable; + pMediaAttr->ptime = pL->p; + pMediaAttr->vocoderType = mgc_mgcp_str_to_vc_code(pL->codec); + + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_parse_connect_mode + * ------------------------------------------------------------------------ + * General: parse mgcp connection mode + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_mode(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MGCP_M *pMode = NULL; + MGC_CON_MODE mode; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_M) != MGCP_PARA_FLAG_M) + return TRUE; + + pMode = &pPara->m; + mode = mgc_mgcp_convert_to_mgc_mode(pPara->m.mode); + mgc_connect_set_conn_mode(pConnect, mode); + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_parse_connect_call_id + * ------------------------------------------------------------------------ + * General: parse mgcp call id + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_call_id(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MEDIA_ATTR *pMediaAttr = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_C) != MGCP_PARA_FLAG_C) + return TRUE; + + pMediaAttr = &pConnect->mediaAttr; + + sprintf(pMediaAttr->callId , "%s" , pPara->c.callId); + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_parse_connect_pkg_event + * ------------------------------------------------------------------------ + * General: parse mgcp observed event + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_pkg_event(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MEDIA_ATTR *pMediaAttr = NULL; + MGCP_O *pPkgEvent = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_O) != MGCP_PARA_FLAG_O) + return TRUE; + + pMediaAttr = &pConnect->mediaAttr; + pPkgEvent = &pPara->o; + + pMediaAttr->pkgEvent.pkg = pPkgEvent->package; + pMediaAttr->pkgEvent.event = pPkgEvent->event; + return TRUE; +} + +/*************************************************************************** + * mgc_mgcp_parse_connect_pkg_sig + * ------------------------------------------------------------------------ + * General: parse mgcp signal event + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_pkg_sig(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + MEDIA_ATTR *pMediaAttr = NULL; + MGCP_S *pPkgSig = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_S) != MGCP_PARA_FLAG_S) + return TRUE; + + pMediaAttr = &pConnect->mediaAttr; + pPkgSig= &pPara->s; + + pMediaAttr->pkgSignal.pkg = pPkgSig->pkg; + pMediaAttr->pkgSignal.signal= pPkgSig->signal; + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_parse_connect_sdp + * ------------------------------------------------------------------------ + * General: parse mgcp sdp info + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which handle incoming MGCP msg + * pPara - the MSG which is received + ***************************************************************************/ +BOOL mgc_mgcp_parse_connect_sdp(CONNECT_INFO *pConnect , MGCP_PARA *pPara) +{ + PUB_SDP_MSG *pSdp = NULL; + MEDIA_ATTR *pMediaAttr = NULL; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if((pPara->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP) + return TRUE; + + pSdp = &pPara->sdp; + pMediaAttr = &pConnect->mediaAttr; + + memcpy(&pMediaAttr->sdp , pSdp , sizeof(PUB_SDP_MSG)); + + return TRUE; +} + + +/*************************************************************************** + * mgc_mgcp_response_msg + * ------------------------------------------------------------------------ + * General: send mgcp response + * Return Value: if failure return FALSE, else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pConnect - the connect which will send out MGCP resp + * pPara - the MSG which will be sent + * retCode - response code + ***************************************************************************/ +BOOL mgc_mgcp_response_msg(CONNECT_INFO *pConnect, MGCP_PARA *pPara, int retCode) +{ + MGCF_OPER_STEP *pStep = NULL; + BYTE cmd; + + if((pConnect == NULL)||(pPara == NULL)) + return FALSE; + + if(mgc_mgcp_create_connect_resp_start_line(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_create_connect_port(pConnect, pPara) == FALSE) + return FALSE; + + if(mgc_mgcp_create_connect_dest_ip(pConnect, pPara) == FALSE) + return FALSE; + + pStep = mgc_connect_get_step_info(pConnect); + if(pStep == NULL) + return FALSE; + + cmd = mgc_mgcp_convert_cmd_to_mgcp(pStep->stepInfo.cmd); + MGCP_rsp(mgc_mgcp_get_sap_index(), cmd, pConnect->id , pStep->hdlPort, retCode, pPara); + return TRUE; +} diff --git a/omc/plat/mgc_v2/src/mgc_phy_port.c b/omc/plat/mgc_v2/src/mgc_phy_port.c new file mode 100644 index 0000000..6c88785 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_phy_port.c @@ -0,0 +1,482 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* +* +* +* mgcSap <---------mgcPhyPorts --------> mgcMgInfo +* +* +*/ + + + + +/********************************************************************************* + * + * This file should provide MG_INFO object APIs + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + +#include "./include/mgc_phy_port.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_ctl.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_internal.h" + +static PHY_PORT_INFO mgcPhyPort[MGC_MAX_NUM_OF_PHY_PORT]; + +/*----------------------------------------------------------------------- + PHY_PORT_INFO M A N A G E R + ------------------------------------------------------------------------*/ + +/*************************************************************************** + * mgc_phy_port_init + * ------------------------------------------------------------------------ + * General: init PHY_PORT_INFO structure objcet + * Return Value: void. + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort- the pointer of the PHY_PORT_INFO object which should be init + * id - the id of the MG_INFO object + ***************************************************************************/ +void mgc_phy_port_init(PHY_PORT_INFO *pPhyPort , int id) +{ + int i; + if((pPhyPort == NULL)||(id < 0)) + return; + + pPhyPort->id = id; + pPhyPort->portNo = -1; + pPhyPort->monFlag = 0; + pPhyPort->status = MGC_PHY_PORT_STATUS_UNDEF; + pPhyPort->portType = MGC_PHY_PORT_TYPE_UNDEF; + pPhyPort->pMgInfo = NULL; + pPhyPort->pMgcSap= NULL; + pPhyPort->chnlNum = 0; + + for(i=0 ; ipChnlInfo[i] = NULL; + } + return; +} + +void mgc_phy_port_setup(void) +{ + int i; + PHY_PORT_INFO *pPhyPort; + + for(i=0 ; ipChnlInfo[i]; + + if(pChnlInfo == NULL) + continue; + + mgc_chnl_info_clear(pChnlInfo); + if(pPhyPort->pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + mgc_ctl_chnl_remove_one(); + } + + mgc_phy_port_init(pPhyPort , pPhyPort->id); +} + + + +/*************************************************************************** + * mgc_phy_port_get_unused_phy + * ------------------------------------------------------------------------ + * General: get unused PHY_PORT_INFO structure objcet + * Return Value: if failure return NULL , else return the pointer of the PHY_PORT_INFO object. + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +PHY_PORT_INFO *mgc_phy_port_get_unused_phy(void) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + + for(i=0 ; ichnlNum == 0)&&(pPhyPort->pMgInfo == NULL)) + return pPhyPort; + } + return NULL; +} + +/*************************************************************************** + * mgc_phy_port_set_chnl_num + * ------------------------------------------------------------------------ + * General: set the chnl number of the phyport according to the portType + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the PHY_PORT_INFO object + * portType - the type of the port + ***************************************************************************/ +void mgc_phy_port_set_chnl_num(PHY_PORT_INFO *pPhyPort , MGC_PHY_PORT_TYPE portType) +{ + if(pPhyPort == NULL) + return; + + switch(portType) + { + case MGC_PHY_PORT_TYPE_UNDEF: + pPhyPort->chnlNum = 0; + break; + case MGC_PHY_PORT_TYPE_ANALOG: + pPhyPort->chnlNum = MGC_CHNL_NUM_AALN_PER_PORT; + break; + case MGC_PHY_VIRTUAL_TYPE_ANN: + pPhyPort->chnlNum = MGC_CHNL_NUM_ANN_PER_TYPE; + break; + case MGC_PHY_VIRTUAL_TYPE_TANDEM: + pPhyPort->chnlNum = MGC_CHNL_NUM_TANDEM_PER_TYPE; + break; + case MGC_PHY_VIRTUAL_TYPE_INTERNAL: + pPhyPort->chnlNum = MGC_CHNL_NUM_INTERNAL_PER_PORT; + break; + case MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE: + pPhyPort->chnlNum = MGC_CHNL_NUM_SERVEILLANCE_PER_TYPE; + default : + pPhyPort->chnlNum = MGC_CHNL_NUM_DS_PER_PORT; + break; + } + + return; +} + + +/*************************************************************************** + * mgc_phy_port_attach_chnl + * ------------------------------------------------------------------------ + * General: attach chnls to the phyPort + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the PHY_PORT_INFO object + ***************************************************************************/ +BOOL mgc_phy_port_attach_chnl(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + if(pPhyPort == NULL) + return FALSE; + + for(i=0 ; ichnlNum ; i++) + { + pChnlInfo = mgc_chnl_info_get_unused_chnl(); + if(pChnlInfo == NULL) + return FALSE; + + if((mgc_ctl_is_chnl_full() == TRUE)&&(pPhyPort->pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM)) + return FALSE; + + pPhyPort->pChnlInfo[i] = pChnlInfo; + + if(mgc_chnl_info_attach_to_phy_port(pChnlInfo , pPhyPort) == FALSE) + return FALSE; + + mgc_chnl_info_status_set(pChnlInfo , MGC_CHNL_INFO_STATUS_IDLE); + + if(pPhyPort->pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + mgc_ctl_chnl_add_one(); + } + + if(pPhyPort->chnlNum == 0) + { + MGC_ERROR("mg[%d]port[%d] not support type!" , pPhyPort->pMgInfo->id , pPhyPort->portNo); + return FALSE; + } + + if(pPhyPort->portNo != ITL_OPERA_PORT_NO) + { + MGC_DEBUG("mg[%d]port[%d] ==> phyPort[%d] {chnlInfo[%d] ~ chnlInfo[%d]}" , + pPhyPort->pMgInfo->id ,pPhyPort->portNo,pPhyPort->id , pPhyPort->pChnlInfo[0]->id, pPhyPort->pChnlInfo[pPhyPort->chnlNum-1]->id); + } + + return TRUE; +} + +/*************************************************************************** + * mgc_phy_port_find_port_of_mg + * ------------------------------------------------------------------------ + * General: find the phyPort in the MG accroding to the PortNo + * Return Value: if failure return NULL , else return the pointer of the PHY_PORT_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG + * portNo - the portNo of the phyPort + ***************************************************************************/ +PHY_PORT_INFO *mgc_phy_port_find_port_of_mg(MG_INFO *pMgInfo , int portNo) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + + if(pMgInfo == NULL) + return NULL; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->portNo != portNo) + continue; + + return pPhyPort; + } + + return NULL; +} + + +/*************************************************************************** + * mgc_phy_port_find_port_of_mg_by_index + * ------------------------------------------------------------------------ + * General: find the phyPort in the MG accroding to the index + * Return Value: if failure return NULL , else return the pointer of the PHY_PORT_INFO object + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgInfo - the pointer of the MG + * index - index + ***************************************************************************/ +PHY_PORT_INFO *mgc_phy_port_find_port_of_mg_by_index(MG_INFO *pMgInfo , int index) +{ + PHY_PORT_INFO *pPhyPort = NULL; + + if(pMgInfo == NULL) + return NULL; + + pPhyPort = pMgInfo->pPhyPort[index]; + if(pPhyPort == NULL) + return NULL; + + return pPhyPort; +} + +/*************************************************************************** + * mgc_phy_port_update_status + * ------------------------------------------------------------------------ + * General: update phyPort status + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the PHY_PORT_INFO object + * status - the status of the phyPort + ***************************************************************************/ +void mgc_phy_port_update_status(PHY_PORT_INFO *pPhyPort , BOOL status) +{ + if(pPhyPort == NULL) + return; + + if(status) + { + pPhyPort->status = MGC_PHY_PORT_STATUS_ON_LINE; + } + else + { + pPhyPort->status = MGC_PHY_PORT_STATUS_OFF_LINE; + } + return; +} + +/*************************************************************************** + * mgc_phy_port_find_idle_chnl + * ------------------------------------------------------------------------ + * General: find a idle chnl in the phyPort + * Return Value: if failure return NULL , else return the pointer of the chnl + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the PHY_PORT_INFO object + ***************************************************************************/ +CHNL_INFO *mgc_phy_port_find_idle_chnl(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + if(pPhyPort == NULL) + return NULL; + + for(i=0 ; ipChnlInfo[i]; + + if(pChnlInfo == NULL) + continue; + + if(pChnlInfo->connectNum != 0) + continue; + + return pChnlInfo; + } + + return NULL; +} + + +/*************************************************************************** + * mgc_phy_port_assign_idle_connection + * ------------------------------------------------------------------------ + * General: find a idle connection in the phyPort + * Return Value: if failure return NULL , else return the pointer of the connction + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPhyPort - the pointer of the PHY_PORT_INFO object + ***************************************************************************/ +CONNECT_INFO *mgc_phy_port_assign_idle_connection(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + CONNECT_INFO *pConnect = NULL; + + if(pPhyPort == NULL) + return NULL; + + for(i=0 ; ipChnlInfo[i]; + + if(pChnlInfo == NULL) + continue; + + pConnect = mgc_chnl_info_assign_idle_connect(pChnlInfo); + + if(pConnect == NULL) + continue; + + return pConnect; + } + + return NULL; +} + + + +BYTE *mgc_phy_port_get_res_addr(void) +{ + return (BYTE *)mgcPhyPort; +} + + +static char *mgc_phy_port_print_user_type(MGC_USER_TYPE type) +{ + switch(type) + { + case MGC_USER_TYPE_MGC: + return "MGC_USER_TYPE_MGC"; + case MGC_USER_TYPE_MG: + return "MGC_USER_TYPE_MG"; + default : + break; + } + + return "MGC_USER_TYPE_UNDEF"; +} + +void mgc_phy_port_print_chnl_info(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo; + if(pPhyPort == NULL) + return; + + if((pPhyPort->portType != MGC_PHY_PORT_TYPE_E1)&&(pPhyPort->portType != MGC_PHY_PORT_TYPE_T1)) + { + MGC_INFO("port type do not support!"); + return; + } + + MGC_INFO("%8s %10s %10s %10s %20s" , "ChnlNo", "Status", "Mode" , "Codec" , "LocalIP"); + for(i=0 ; ichnlNum ; i++) + { + pChnlInfo = pPhyPort->pChnlInfo[i]; + + if(pChnlInfo == NULL) + continue; + + MGC_INFO("chnl[%02d] %10s %10s %10s %20s", + i , mgc_chnl_info_print_status(pChnlInfo), mgc_chnl_info_print_mode(pChnlInfo), + mgc_chnl_info_print_codec(pChnlInfo), mgc_chnl_info_print_remote(pChnlInfo)); + } + + return; +} + +void mgc_phy_port_print(PHY_PORT_INFO *pPhyPort) +{ + if(pPhyPort == NULL) + return; + + if((pPhyPort->pMgInfo == NULL)||(pPhyPort->pMgcSap == NULL) ) + { + MGC_INFO("mgcPhyPort[%d] is not used!" , pPhyPort->id); + return; + } + + MGC_INFO("mgInfo[%d]Port[%d] ==>> mgcPhyPort[%d] " , pPhyPort->pMgInfo->id , pPhyPort->portNo , pPhyPort->id); + MGC_INFO("mgInfo[%d]Port[%d] ==>> %s %s" , + pPhyPort->pMgInfo->id , pPhyPort->portNo , pPhyPort->pMgcSap->usrName,mgc_phy_port_print_user_type(pPhyPort->pMgcSap->usrType)); + MGC_INFO("mgInfo[%d]Port[%d] %s" , pPhyPort->pMgInfo->id , pPhyPort->portNo, (pPhyPort->status == MGC_PHY_PORT_STATUS_ON_LINE)?"on":"off"); + mgc_phy_port_print_chnl_info(pPhyPort); + return; +} + +int mgc_modify_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType) +{ + MGC_ERROR("port modify is not support now!"); + MGC_ERROR("Please delete first , and then re-add"); + return -1; +} + +void mgc_phy_port_set_mon(int id, BOOL enalbe) +{ + if((id<0)||(id >= MGC_MAX_NUM_OF_PHY_PORT)) + return; + + mgcPhyPort[id].monFlag = enalbe; +} + diff --git a/omc/plat/mgc_v2/src/mgc_port_info.c b/omc/plat/mgc_v2/src/mgc_port_info.c new file mode 100644 index 0000000..e36777e --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_port_info.c @@ -0,0 +1,1627 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* +* +*/ + + +/********************************************************************************* + * + * This file contain APIs which is provided to MGC to send and receive MGCP msg + * + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + + + + +/*-----------------------------------------------------------------------*/ +/* INCLUDE HEADER FILES */ +/*-----------------------------------------------------------------------*/ + + +#include "./include/mgc_port_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_tandem_info.h" +#include "./include/mgc_internal.h" +#ifdef MGC_PORT_LIST_EN +#include "./include/mgc_port_list.h" +#endif + +extern MGC_SAP *mgc_sap_get_index_sap(int index); + + +static PORT_INFO mgcPort[MGC_MAX_NUM_OF_PORT]; + + +/*----------------------------------------------------------------------- + MGC_PORT_INFO M A N A G E R + ------------------------------------------------------------------------*/ + +char *mgc_port_info_print_opera_id(MGC_MG_OPER_ID_TYPE operaId) +{ + switch(operaId) + { + case MGC_OPER_ID_CONNECT_CHNL: + return "MGC_OPER_ID_CONNECT_CHNL"; + case MGC_OPER_ID_CONNECT_DTMF: + return "MGC_OPER_ID_CONNECT_DTMF"; + case MGC_OPER_ID_CONNECT_TONE: + return "MGC_OPER_ID_CONNECT_TONE"; + case MGC_OPER_ID_CRCX: + return "MGC_OPER_ID_CRCX"; + case MGC_OPER_ID_MDCX: + return "MGC_OPER_ID_MDCX"; + case MGC_OPER_ID_DLCX: + return "MGC_OPER_ID_DLCX"; + case MGC_OPER_ID_RQNT: + return "MGC_OPER_ID_RQNT"; + case MGC_OPER_ID_AUEP: + return "MGC_OPER_ID_AUEP"; + case MGC_OPER_ID_CONNECT_AAS : + return "MGC_OPER_ID_CONNECT_AAS "; + case MGC_OPER_ID_TANDEM_CREATE: + return "MGC_OPER_ID_TANDEM_CREATE"; + case MGC_OPER_ID_TANDEM_SET_TAR: + return "MGC_OPER_ID_TANDEM_SET_TAR"; + case MGC_OPER_ID_TANDEM_UNSET_TAR: + return "MGC_OPER_ID_TANDEM_UNSET_TAR"; + case MGC_OPER_ID_TANDEM_CLEAR: + return "MGC_OPER_ID_TANDEM_CLEAR"; + case MGC_OPER_ID_TANDEM_FORK_CHNL: + return "MGC_OPER_ID_TANDEM_FORK_CHNL"; + case MGC_OPER_ID_IND: + return "MGC_OPER_ID_IND"; + case MGC_OPER_ID_CREATE_VIRTUAL_CHNL: + return "MGC_OPER_ID_CREATE_VIRTUAL_CHNL"; + case MGC_OPER_ID_RELEASE_VIRTUAL_CHNL: + return "MGC_OPER_ID_RELEASE_VIRTUAL_CHNL"; + case MGC_OPER_ID_UPDATE_CHNL_MEDIA: + return"MGC_OPER_ID_UPDATE_CHNL_MEDIA"; + default: + break; + } + + return "MGC_OPER_ID_UNDEF"; +} + + +char *mgc_port_info_print_cmd(MGC_CMD_TYPE cmd) +{ + switch(cmd) + { + case MGC_CMD_CRCX: + return "MGC_CMD_CRCX"; + case MGC_CMD_MDCX: + return "MGC_CMD_MDCX"; + case MGC_CMD_DLCX: + return "MGC_CMD_DLCX"; + case MGC_CMD_RQNT: + return "MGC_CMD_RQNT"; + case MGC_CMD_NTFY: + return "MGC_CMD_NTFY"; + case MGC_CMD_AUEP: + return "MGC_CMD_AUEP"; + case MGC_CMD_RSIP: + return "MGC_CMD_RSIP"; + case MGC_CMD_NOP: + return "MGC_CMD_NOP"; + default: + return "MGC_CMD_UNDEF"; + } +} + + + +/*************************************************************************** + * mgc_port_info_step_info_init + * ------------------------------------------------------------------------ + * General: init step operate info + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pStep - the pointer of the object + ***************************************************************************/ +void mgc_port_info_step_info_init(MGCF_STEP_INFO *pStepInfo) +{ + if(pStepInfo == NULL) + return; + + pStepInfo->cmd = MGC_CMD_UNDEF; + pStepInfo->delay = MGC_OPERA_NO_DELAY; + pStepInfo->pPeerConn = NULL; + pStepInfo->mode = MGC_CON_MODE_UNDEF; + pStepInfo->remoteIp = 0; + memset(&pStepInfo->pkgEvent , 0, sizeof(PKG_EVENT)); + memset(&pStepInfo->pkgSig , 0, sizeof(PKG_SIGNAL)); + memset(&pStepInfo->pkgReq , 0 , sizeof(PKG_REQ)); + pStepInfo->eventEn = FALSE; + pStepInfo->reqEn = FALSE; + pStepInfo->sigEn= FALSE; + return; +} + + +/*************************************************************************** + * mgc_port_info_set_step_info + * ------------------------------------------------------------------------ + * General: set up step infomation + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pStep - the pointer of the step info object + * cmd - MGCP cmd which should be used in the step + * pPeerConn - the pointer of the connection which is at peer position of the operate connection + * delay - the time of this step should be delayed + * mode - the connect mode of the operate connection + * pPkgEvent - the event thing needed in the step + * pPkgSig - the signal thing needed in the step + * pPkgReq - the request msg needed in the step + * pCodeList - the codelist which should be negotiate in the step + ***************************************************************************/ +void mgc_port_info_set_step_info(MGCF_STEP_INFO *pStepInfo , MGC_CMD_TYPE cmd , CONNECT_INFO *pPeerConn , + WORD delay, MGC_CON_MODE mode, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig , PKG_REQ *pPkgReq) +{ + if(pStepInfo == NULL) + return; + + pStepInfo->delay = delay; + pStepInfo->pPeerConn = pPeerConn; + pStepInfo->mode = mode; + pStepInfo->cmd = cmd; + + if(pPkgEvent != NULL) + { + memcpy(&pStepInfo->pkgEvent , pPkgEvent, sizeof(PKG_EVENT)); + pStepInfo->eventEn = TRUE; + } + else + { + memset(&pStepInfo->pkgEvent , 0, sizeof(PKG_EVENT)); + pStepInfo->eventEn = FALSE; + } + + if(pPkgSig != NULL) + { + memcpy(&pStepInfo->pkgSig , pPkgSig, sizeof(PKG_SIGNAL)); + pStepInfo->sigEn= TRUE; + } + else + { + memset(&pStepInfo->pkgSig , 0, sizeof(PKG_SIGNAL)); + pStepInfo->sigEn= FALSE; + } + + if(pPkgReq != NULL) + { + memcpy(&pStepInfo->pkgReq , pPkgReq , sizeof(PKG_REQ)); + pStepInfo->reqEn = TRUE; + } + else + { + memset(&pStepInfo->pkgReq , 0 , sizeof(PKG_REQ)); + pStepInfo->reqEn = FALSE; + } + + return; +} + + +/*************************************************************************** + * mgc_port_info_oper_step_init + * ------------------------------------------------------------------------ + * General: init step info + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pStep - the pointer of the object + * id - the id of the step + ***************************************************************************/ +void mgc_port_info_oper_step_init(MGCF_OPER_STEP *pMgcfOperStep , PORT_INFO *pPortInfo , int id) +{ + if((pMgcfOperStep == NULL)||(pPortInfo == NULL)) + return; + + pMgcfOperStep->id = id; + pMgcfOperStep->status = MGCP_OPER_STEP_UNDEF; + pMgcfOperStep->pConnect = NULL; + pMgcfOperStep->hdlPort = 0; + pMgcfOperStep->llCmd = 0; + pMgcfOperStep->pPortInfo = pPortInfo; + mgc_port_info_step_info_init(&pMgcfOperStep->stepInfo); + return; +} + +/*************************************************************************** + * mgc_port_info_get_step_port + * ------------------------------------------------------------------------ + * General: find the owner of the step + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pStep - the pointer of the object + ***************************************************************************/ +PORT_INFO *mgc_port_info_get_step_port(MGCF_OPER_STEP *pOperStep) +{ + if(pOperStep == NULL) + return NULL; + + return pOperStep->pPortInfo; +} + + +/*************************************************************************** + * mgc_port_info_find_port_by_id + * ------------------------------------------------------------------------ + * General: find the PORT_INFO object by id + * Return Value: if failure return NULL , else return pointer of the port + * ------------------------------------------------------------------------ + * Arguments: + * Input: id - the id of the PORT_INFO object + ***************************************************************************/ +PORT_INFO *mgc_port_info_find_port_by_id(int id) +{ + if((id <0) ||(id >= MGC_MAX_NUM_OF_PORT)) + return NULL; + + return &mgcPort[id] ; +} + +/*************************************************************************** + * mgc_port_info_get_unused_oper_step + * ------------------------------------------------------------------------ + * General: find unused step in the specific PORT_INFO object + * Return Value: if failure return NULL , else return pointer of the step + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + ***************************************************************************/ +MGCF_OPER_STEP *mgc_port_info_get_unused_oper_step(PORT_INFO *pPortInfo) +{ + int i; + MGCF_OPER_STEP *pMgcfOperStep = NULL; + + if(pPortInfo == NULL) + return NULL; + + for(i=0 ; imgcfOperSteps[i]; + + if(pMgcfOperStep->pConnect != NULL) + continue; + + return pMgcfOperStep; + } + + return NULL; +} + + +/*************************************************************************** + * mgc_port_info_set_oper_step + * ------------------------------------------------------------------------ + * General: set up step related operation parameter + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcfOperStep - the pointer of the step + * pConnect - the pointer of the operate connect + * pStepInfo - the pointer of the related step infomation + ***************************************************************************/ +BOOL mgc_port_info_set_oper_step(MGCF_OPER_STEP *pMgcfOperStep , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo) +{ + if((pMgcfOperStep == NULL)||(pConnect == NULL)||(pStepInfo == NULL)) + return FALSE; + + if(pMgcfOperStep->status != MGCP_OPER_STEP_UNDEF) + return FALSE; + + pMgcfOperStep->pConnect = pConnect; + pMgcfOperStep->status = MGCP_OPER_STEP_REQUEST; + memcpy(&pMgcfOperStep->stepInfo , pStepInfo , sizeof(MGCF_STEP_INFO)); + return TRUE; +} + +/*************************************************************************** + * mgc_port_info_add_opera_to_port + * ------------------------------------------------------------------------ + * General: add a operation into the specific PORT_INFO object + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * pConnect - the pointer of the operate connect + * pStepInfo - the pointer of the related step infomation + ***************************************************************************/ +BOOL mgc_port_info_add_opera_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo) +{ + MGCF_OPER_STEP *pOperStep = NULL; + + if((pPortInfo == NULL)||(pConnect == NULL)||(pStepInfo == NULL)) + return FALSE; + + pOperStep = mgc_port_info_get_unused_oper_step(pPortInfo); + if(pOperStep == NULL) + { + MGC_ERROR("port[%d] is full of operations" , pPortInfo->id); + return FALSE; + } + + if(mgc_port_info_set_oper_step(pOperStep , pConnect , pStepInfo) == FALSE) + return FALSE; + + if(pStepInfo->cmd != MGC_CMD_AUEP) + { + MGC_DEBUG("mgcPort[%d]step[%d] set conn[%d] to do %s" , pPortInfo->id ,pOperStep->id , pConnect->id , mgc_port_info_print_cmd(pStepInfo->cmd)); + } + return TRUE; +} + + +/*************************************************************************** + * mgc_port_info_add_ind_to_port + * ------------------------------------------------------------------------ + * General: add a ind info into the specific PORT_INFO object + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * pConnect - the pointer of the operate connect + * cmd - the MGCP cmd + * hdlport - low-layer operate id + * remoteIp -peerIp parse from low-layer + ***************************************************************************/ +BOOL mgc_port_info_add_ind_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGC_CMD_TYPE cmd , int hdlPort , DWORD remoteIp) +{ + MGCF_OPER_STEP *pOperStep = NULL; + + if((pPortInfo == NULL)||(pConnect == NULL)) + return FALSE; + + pOperStep = mgc_port_info_get_unused_oper_step(pPortInfo); + if(pOperStep == NULL) + return FALSE; + + if(pOperStep->status != MGCP_OPER_STEP_UNDEF) + return FALSE; + + pOperStep->pConnect = pConnect; + pOperStep->status = MGCP_OPER_STEP_IND; + pOperStep->hdlPort = hdlPort; + pOperStep->llCmd = 404; + pOperStep->stepInfo.remoteIp = remoteIp; + pOperStep->stepInfo.cmd = cmd; + + if(cmd != MGC_CMD_AUEP) + { + MGC_DEBUG("mgcPort[%d]step[%d] add conn[%d] ind %s" , pPortInfo->id,pOperStep->id , pConnect->id , mgc_port_info_print_cmd(cmd)); + } + return TRUE; +} + + +/*************************************************************************** + * mgc_port_info_oper_success_report + * ------------------------------------------------------------------------ + * General: report success to the up-layer + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * pMgcSap - the pointer of the mgcSap which should be reported + ***************************************************************************/ +void mgc_port_info_oper_success_report(PORT_INFO *pPortInfo , MGC_SAP *pMgcSap) +{ + if((pPortInfo == NULL)||(pMgcSap == NULL)) + return; + + if(pPortInfo->mgcfOperId != MGC_OPER_ID_AUEP) + { + MGC_DEBUG("mgcPort[%d] %s success" , pPortInfo->id , mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + } + pMgcSap->cnf_func(pPortInfo->usrPort , pPortInfo->id , pPortInfo->mgcfOperId , MGC_OPER_SUCCESS , pPortInfo->cause); + return; +} + +/*************************************************************************** + * mgc_port_info_oper_failure_report + * ------------------------------------------------------------------------ + * General: report failure to the up-layer + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * pMgcSap - the pointer of the mgcSap which should be reported + ***************************************************************************/ +void mgc_port_info_oper_failure_report(PORT_INFO *pPortInfo , MGC_SAP *pMgcSap) +{ + if((pPortInfo == NULL)||(pMgcSap == NULL)) + return; + + if(pPortInfo->mgcfOperId != MGC_OPER_ID_AUEP) + { + MGC_ERROR("mgcPort[%d] %s failure" , pPortInfo->id , mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + } + pMgcSap->cnf_func(pPortInfo->usrPort , pPortInfo->id , pPortInfo->mgcfOperId , MGC_OPER_FAILURE , MGCP_RET_CODE_TRANS_TIME_OUT); + return; +} + + + +/*************************************************************************** + * mgc_port_info_oper_step_request + * ------------------------------------------------------------------------ + * General: send mgcp req according to the step info + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcfOperStep - the pointer of the operate step + ***************************************************************************/ +BOOL mgc_port_info_oper_step_request(MGCF_OPER_STEP *pMgcfOperStep) +{ + int ret; + CONNECT_INFO *pConnect = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + BOOL result = FALSE; + MGCP_PARA mgcpPara; + PORT_INFO *pPortInfo = NULL; + PORT_INFO *pPortInfoTmp = NULL; + MG_INFO *pMgInfo = NULL; + BYTE mgcpCmd; + + if(pMgcfOperStep == NULL) + return FALSE; + + pPortInfo = mgc_port_info_get_step_port(pMgcfOperStep); + if(pPortInfo == NULL) + return FALSE; + + if(pMgcfOperStep->status != MGCP_OPER_STEP_REQUEST) + return FALSE; + + if(pMgcfOperStep->pConnect == NULL) + return FALSE; + + pConnect = pMgcfOperStep->pConnect; + + if(pMgcfOperStep->stepInfo.cmd != MGC_CMD_AUEP) + { + // MGC_DEBUG("mgcPort[%d]step[%d] conn[%d] request" , pPortInfo->id , pMgcfOperStep->id , pConnect->id); + } + + if(pConnect->pOperStep != NULL) //wait for pre-step work over + { + pPortInfoTmp = mgc_port_info_get_step_port(pConnect->pOperStep); + if(pPortInfoTmp != NULL) + { + MGC_WARN("conn[%d] suspend by mgcPort[%d]step[%d] %s!" , + pConnect->id , pPortInfoTmp->id , pConnect->pOperStep->id , mgc_port_info_print_opera_id(pPortInfoTmp->mgcfOperId)); + } + if((pConnect->pOperStep->stepInfo.cmd == MGC_CMD_NOP)&&(pConnect->pOperStep->stepInfo.delay != MGC_OPERA_NO_DELAY)) + pConnect->pOperStep->stepInfo.delay = MGC_OPERA_NO_DELAY; + return TRUE; + } + + if(mgc_connect_attach_step_info(pConnect, pMgcfOperStep) == FALSE) + return FALSE; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return FALSE; + + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + if(pPhyPort == NULL) + return FALSE; + + memset(&mgcpPara , 0 , sizeof(MGCP_PARA)); + switch(pMgcfOperStep->stepInfo.cmd) + { + case MGC_CMD_CRCX: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_connect_set_status(pConnect , MGC_CONNECT_STATUS_CREATED); + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + + if((mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE)) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_IDLE) + { + result = FALSE; + break; + } + mgc_connect_attr_init(pConnect); + result = mgc_connect_crcx_para_create(pConnect , &mgcpPara); + mgc_connect_set_status(pConnect , MGC_CONNECT_STATUS_CREATING); + break; + case MGC_CMD_MDCX: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + { + result = FALSE; + break; + } + + if(mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE) + { + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_CREATED); + } + + result = mgc_connect_mdcx_para_create(pConnect , &mgcpPara); + if(result == TRUE) + { + if(mgc_connect_is_conn_need_update(pConnect , &mgcpPara) == FALSE) + { + MGC_DEBUG("conn[%d] do not need send mdcx" , pConnect->id); + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + } + break; + case MGC_CMD_DLCX: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_connect_codec_list_init(&pConnect->codecList); + memset(&pConnect->mediaAttr , 0 , sizeof(MEDIA_ATTR)); + memset(&pConnect->operRec , 0 , sizeof(OPER_REC)); + memset(&pConnect->mgcpRec , 0 , sizeof(MGCP_REC_TAG)); + mgc_connect_set_status(pConnect, MGC_CONNECT_STATUS_IDLE); + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&& + (mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)&& + (mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATING) + ) + { + MGC_WARN("conn[%d] is not created,do not need dlcx" , pConnect->id); + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + result = mgc_connect_dlcx_para_create(pConnect , &mgcpPara); + break; + case MGC_CMD_AUEP: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + + if(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_IDLE) + { + result = FALSE; + break; + } + result = mgc_connect_auep_para_create(pConnect , &mgcpPara); + break; + case MGC_CMD_NTFY: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + break; + case MGC_CMD_RQNT: + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + } + if((mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATED)&&(mgc_connect_get_status(pConnect) != MGC_CONNECT_STATUS_CREATE)) + { + MGC_WARN("conn[%d] is not created, can't send reqnt" , pConnect->id); + result = FALSE; + break; + } + result = mgc_connect_rqnt_para_create(pConnect , &mgcpPara); + break; + case MGC_CMD_RSIP: + break; + case MGC_CMD_NOP: //do nothing for this cmd + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + return TRUE; + default: + break; + } + + if(result == FALSE) + return FALSE; + + mgcpCmd = mgc_mgcp_convert_cmd_to_mgcp(pMgcfOperStep->stepInfo.cmd); + ret = MGCP_req(mgc_mgcp_get_sap_index(), mgcpCmd , pPortInfo->id , &mgcpPara); + if(ret < 0) + return FALSE; + pMgcfOperStep->hdlPort = ret; + pMgcfOperStep->status= MGCP_OPER_STEP_REQUEST_SENT; + + if(pMgcfOperStep->stepInfo.cmd != MGC_CMD_AUEP) + { + MGC_DEBUG("mgcPort[%d]Step[%d] conn[%d] send request %s" , + pPortInfo->id, pMgcfOperStep->id ,pConnect->id , mgc_port_info_print_cmd(pMgcfOperStep->stepInfo.cmd)); + } + + return TRUE; +} + + + + +/*************************************************************************** + * mgc_port_info_oper_step_cnf + * ------------------------------------------------------------------------ + * General: step cnf process + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcfOperStep - the pointer of the operate step + * pPara - the pointer of the resp Msg + ***************************************************************************/ +BOOL mgc_port_info_oper_step_cnf(MGCF_OPER_STEP *pMgcOperStep , MGCP_PARA *pPara) +{ + BOOL result = FALSE; + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + MG_INFO *pMgInfo = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + CHNL_INFO *pChnlInfo = NULL; + MGC_CMD_TYPE cmd; + int connNo = -1; + int chnlNo = -1; + WORD retCode; + + if((pMgcOperStep == NULL)||(pPara == NULL)) + return FALSE; + + if(pMgcOperStep->status != MGCP_OPER_STEP_REQUEST_SENT) + return FALSE; + + if(pMgcOperStep->pConnect == NULL) + return FALSE; + + retCode = pMgcOperStep->llCmd; + pConnect = pMgcOperStep->pConnect; + cmd = pMgcOperStep->stepInfo.cmd; + + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + pPortInfo = mgc_port_info_get_step_port(pMgcOperStep); + + if(pPortInfo == NULL) + { + MGC_ERROR("step lost mgcPort!!"); + return FALSE; + } + + if((pChnlInfo == NULL)||(pPhyPort == NULL)||(pMgInfo == NULL)) + { + MGC_ERROR("mgcPort[%d]step[%d] lost conn rec" , pPortInfo->id , pMgcOperStep->id); + return FALSE; + } + + + pMgcOperStep->status = MGCP_OPER_STEP_RESPONSE_GET; + switch( cmd ) + { + case MGC_CMD_CRCX: + if(retCode == 200) + { + result = mgc_connect_crcx_resp_parse_para(pConnect , pPara); + if(result == TRUE) + mgc_connect_set_status(pConnect , MGC_CONNECT_STATUS_CREATE); + } + else if(retCode == 502) + { + MGC_DEBUG("need to insert dlcx"); + pPortInfo = mgc_port_info_get_step_port(pMgcOperStep); + result = mgc_port_info_insert_dlcx_req(pPortInfo, pConnect); + mgc_connect_dettach_step_info(pConnect); + } + else + { + MGC_DEBUG("connect[%d] crcx failed!" , pConnect->id); + result = FALSE; + } + break; + case MGC_CMD_MDCX: + if(retCode == 200) + { + result = mgc_connect_mdcx_resp_parse_para(pConnect , pPara); + } + else + { + result = FALSE; + } + break; + case MGC_CMD_DLCX: + if(pConnect->pTandem == NULL) + { + mgc_chnl_info_detach_connect(pConnect->pChnlInfo, pConnect) ; + mgc_connect_init(pConnect, pConnect->id); + } + else + { + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_IDLE); + mgc_connect_codec_list_init(&pConnect->codecList); + memset(&pConnect->mediaAttr , 0 , sizeof(MEDIA_ATTR)); + memset(&pConnect->operRec , 0 , sizeof(OPER_REC)); + memset(&pConnect->mgcpRec , 0 , sizeof(MGCP_REC_TAG)); + } + + result = TRUE; + break; + case MGC_CMD_AUEP: + if(retCode == 200) + result = TRUE; + + if(mgc_chnl_info_detach_connect(pConnect->pChnlInfo, pConnect) == FALSE) + mgc_connect_init(pConnect, pConnect->id); + break; + case MGC_CMD_NTFY: + if(retCode== 200) + result = TRUE; + break; + case MGC_CMD_RQNT: + if(retCode == 200) + result = TRUE; + break; + case MGC_CMD_RSIP: + if(retCode == 200) + result = TRUE; + break; + default: + break; + } + + if(cmd != MGC_CMD_AUEP) + { + MGC_DEBUG("conn[%d] get %s response code %d %s" , + pConnect->id , mgc_port_info_print_cmd(cmd) , retCode , result?"success":"failure"); + + if(result == FALSE) + { + connNo = mgc_connect_get_connNo_of_chnl_info(pConnect, pChnlInfo); + chnlNo = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo,pPhyPort); + MGC_ERROR("mg[%d]port[%d]chnl[%d]conn[%d] %s get %d mgcPort[%d]step[%d] %s", + pMgInfo->id , pPhyPort->portNo , chnlNo, connNo , mgc_port_info_print_cmd(cmd) , + retCode , pPortInfo->id , pMgcOperStep->id , mgc_port_info_print_opera_id(pPortInfo->mgcfOperId)); + } + } + return result; +} + + +/*************************************************************************** + * mgc_port_info_oper_step_ind + * ------------------------------------------------------------------------ + * General: step ind process + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcfOperStep - the pointer of the operate step + ***************************************************************************/ +BOOL mgc_port_info_oper_step_ind(MGCF_OPER_STEP *pMgcfOperStep) +{ + int ret; + CHNL chnl; + CONNECT_INFO *pConnect = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + PORT_INFO *pPortInfo = NULL; + MG_INFO *pMgInfo = NULL; + CHNL_INFO *pChnlInfo = NULL; + WORD usrPort; + + if(pMgcfOperStep == NULL) + return FALSE; + + pPortInfo = mgc_port_info_get_step_port(pMgcfOperStep); + if(pPortInfo == NULL) + return FALSE; + + if(pMgcfOperStep->status != MGCP_OPER_STEP_IND) + return FALSE; + + if(pMgcfOperStep->pConnect == NULL) + return FALSE; + + pConnect = pMgcfOperStep->pConnect; + if(mgc_connect_attach_step_info(pConnect, pMgcfOperStep) == FALSE) + return FALSE; + + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if(pMgInfo == NULL) + return FALSE; + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + pMgcfOperStep->status = MGCP_OPER_STEP_RESPONSE; + return TRUE; + } + + pPhyPort = mgc_connect_get_own_phy_port_info(pConnect); + pChnlInfo = mgc_connect_get_own_chnl_info(pConnect); + if((pPhyPort == NULL)||(pChnlInfo == NULL)) + return FALSE; + + pMgcfOperStep->status = MGCP_OPER_STEP_IND_SENT; + if(pPhyPort->pMgcSap->ind_func == NULL) + return TRUE; + + chnl.mgNo = pMgInfo->id; + chnl.portNo = pPhyPort->portNo; + chnl.chlNo = mgc_chnl_info_get_chnl_no_of_phy(pChnlInfo, pPhyPort); + chnl.connectNo = mgc_connect_get_connNo_of_chnl_info(pConnect, pChnlInfo); + if(mgc_connect_get_step_info(pConnect) == NULL) + return FALSE; + + if(strlen(pConnect->mediaAttr.conId) != 0) + { + usrPort = atoi(pConnect->mediaAttr.conId); + MGC_DEBUG("sent %s to usrPort[%d]" , mgc_port_info_print_cmd(pMgcfOperStep->stepInfo.cmd) , usrPort); + } + + switch(pMgcfOperStep->stepInfo.cmd) + { + case MGC_CMD_CRCX: + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_CREATING); + case MGC_CMD_MDCX: + case MGC_CMD_DLCX: + case MGC_CMD_NTFY: + ret = pPhyPort->pMgcSap->ind_func(chnl, pMgcfOperStep->stepInfo.cmd , &usrPort, pPortInfo->id , &pConnect->mediaAttr); + break; + case MGC_CMD_RQNT: + case MGC_CMD_AUEP: + case MGC_CMD_RSIP: + ret = pPhyPort->pMgcSap->ind_func(chnl, pMgcfOperStep->stepInfo.cmd , &usrPort, pPortInfo->id , NULL); + break; + default: + break; + } + if(ret < 0) + return FALSE; + + if(strlen(pConnect->mediaAttr.conId) == 0) + { + sprintf(pConnect->mediaAttr.conId , "%d" , usrPort); + MGC_DEBUG("conn[%d] get usrPort[%s]" , pConnect->id , pConnect->mediaAttr.conId); + } + + return TRUE; +} + + + +/*************************************************************************** + * mgc_port_info_oper_step_resp + * ------------------------------------------------------------------------ + * General: step send resp Msg + * Return Value: if failure return FALSE , else return TRUE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pMgcfOperStep - the pointer of the operate step + ***************************************************************************/ +BOOL mgc_port_info_oper_step_resp(MGCF_OPER_STEP *pMgcfOperStep) +{ + CONNECT_INFO *pConnect = NULL; + PORT_INFO *pPortInfo = NULL; + MGCP_PARA mgcpPara; + BOOL result = FALSE; + if(pMgcfOperStep == NULL) + return FALSE; + + pPortInfo = mgc_port_info_get_step_port(pMgcfOperStep); + if(pPortInfo == NULL) + return FALSE; + + if(pMgcfOperStep->status != MGCP_OPER_STEP_RESPONSE) + return FALSE; + + pConnect = pMgcfOperStep->pConnect; + if(pConnect == NULL) + return FALSE; + + + switch(pMgcfOperStep->stepInfo.cmd) + { + case MGC_CMD_CRCX: + if(pMgcfOperStep->llCmd == 200) + { + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_CREATED); + result = TRUE; + } + mgc_mgcp_create_connect_con_id(pConnect, &mgcpPara); + mgc_mgcp_create_connect_sdp(pConnect,&mgcpPara); + break; + case MGC_CMD_MDCX: + result = TRUE; + break; + case MGC_CMD_DLCX: + case MGC_CMD_AUEP: + case MGC_CMD_RQNT: + case MGC_CMD_NTFY: + break; + default: + break; + } + + mgc_mgcp_response_msg(pConnect, &mgcpPara, pMgcfOperStep->llCmd); + if(result == FALSE) + { + mgc_chnl_info_detach_connect(pConnect->pChnlInfo, pConnect); + mgc_connect_init(pConnect, pConnect->id); + } + + mgc_connect_dettach_step_info(pConnect); + return TRUE; +} + + +void mgc_port_info_set_fsm_time(PORT_INFO *pPortInfo , WORD timer) +{ + if(pPortInfo == NULL) + return; + + pPortInfo->mgcfTimer = timer; + return; +} + +void mgc_port_info_set_oper_id(PORT_INFO *pPortInfo , MGC_MG_OPER_ID_TYPE operId) +{ + if(pPortInfo == NULL) + return; + + pPortInfo->mgcfOperId = operId; + if(operId != MGC_OPER_ID_AUEP) + { + MGC_DEBUG("mgcPort[%d] set %s" , pPortInfo->id , mgc_port_info_print_opera_id(operId)); +} +} + + + + +/*************************************************************************** + * mgc_port_info_init + * ------------------------------------------------------------------------ + * General: PORT_INFO object init + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * id - the id of the PORT_INFO object + ***************************************************************************/ +void mgc_port_info_init(PORT_INFO *pPortInfo , int id) +{ + int i; + MGCF_OPER_STEP *pMgcfOperStep = NULL; + + if(pPortInfo == NULL) + return; + + pPortInfo->id = id; + pPortInfo->assigned = FALSE; + pPortInfo->mgcfOperId = MGC_OPER_ID_UNDEF; + pPortInfo->usrPort = 0xFFFF; + pPortInfo->mgcfTimer = MGC_MGCF_TIMER_20S; + pPortInfo->pMgcOperCurrent = NULL; + pPortInfo->cause = 0; + for(i=0 ; imgcfOperSteps[i]; + mgc_port_info_oper_step_init(pMgcfOperStep, pPortInfo,i); + } + + return; +} + +void mgc_port_info_setup(void) +{ + int i; + PORT_INFO *pPortInfo = NULL; + + for(i=0 ; imgcfOperSteps[i]; + + pConnect = pMgcfOperStep->pConnect; + pMgInfo = mgc_connect_get_own_mg_info(pConnect); + if((pConnect == NULL)||(pMgInfo == NULL)) + continue; + + mgc_connect_dettach_step_info(pConnect); + if( (pMgcfOperStep != pPortInfo->pMgcOperCurrent)&& + (pMgInfo->mgAttr.mgType != MGC_MG_TYPE_ANN)) + continue; + + if((mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATED)|| + (mgc_connect_get_status(pConnect) == MGC_CONNECT_STATUS_CREATE)) + { + if(mgc_connect_dlcx_para_create(pConnect , &mgcpPara) == TRUE) + MGCP_req(mgc_mgcp_get_sap_index(), MGCP_CMD_DLCX , 0xFFFF , &mgcpPara); + } + + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_IDLE); + mgc_connect_codec_list_init(&pConnect->codecList); + memset(&pConnect->mediaAttr , 0 , sizeof(MEDIA_ATTR)); + memset(&pConnect->operRec , 0 , sizeof(OPER_REC)); + memset(&pConnect->mgcpRec , 0 , sizeof(MGCP_REC_TAG)); + + if(pMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL) + { + mgc_chnl_info_detach_connect(pConnect->pChnlInfo, pConnect); + mgc_connect_init(pConnect, pConnect->id); + } + MGC_DEBUG("mgcPort[%d]step[%d] clear conn[%d]" , pPortInfo->id , pMgcfOperStep->id , pConnect->id); + } + + mgc_port_info_init(pPortInfo , pPortInfo->id); + return; +} + + + + +/*************************************************************************** + * mgc_port_info_get_unused_port + * ------------------------------------------------------------------------ + * General: find a unused PORT_INFO object + * Return Value: if failure return NULL , else return pointer of the object + * ------------------------------------------------------------------------ + * Arguments: + * Input: void + ***************************************************************************/ +PORT_INFO *mgc_port_info_get_unused_port(void) +{ + int i; + static int index = 0; + PORT_INFO *pPortInfo = NULL; + PORT_INFO *pPortInfoTmp = NULL; + + i = index ; + do + { + i++; + if(i == MGC_MAX_NUM_OF_PORT) + i=0; + + pPortInfo = &(mgcPort[i]); + if(pPortInfo->assigned == TRUE) + continue; + + pPortInfoTmp = pPortInfo; + index = i; + break; + + }while(i != index); + + return pPortInfoTmp; +} + +void mgc_port_info_rm_conn_from_pre_port_info(CONNECT_INFO *pConnect) +{ + int i; + PORT_INFO *pPrePortInfo = NULL; + MGCF_OPER_STEP *pStep = NULL; + + if((pConnect == NULL)||(pConnect->pPrePortInfo == NULL)) + return; + + pPrePortInfo = pConnect->pPrePortInfo; + + for(i=0 ; imgcfOperSteps[i]; + + if(pStep == pPrePortInfo->pMgcOperCurrent) + continue; + + if(pStep->pConnect != pConnect) + continue; + + mgc_port_info_oper_step_init(pStep, pStep->pPortInfo, pStep->id); + pConnect->pPrePortInfo = NULL; + MGC_DEBUG("conn[%d] remove from mgcPort[%d]step[%d]" , pConnect->id , pPrePortInfo->id , pStep->id); + } + + return; +} + +void mgc_port_info_conn_rec_port_info(PORT_INFO *pPortInfo) +{ + MGCF_OPER_STEP *pStep = NULL; + CONNECT_INFO *pConn = NULL; + int i; + if(pPortInfo == NULL) + return; + + for(i=0 ; imgcfOperSteps[i]; + + if(pStep->status != MGCP_OPER_STEP_REQUEST) + continue; + + pConn = pStep->pConnect; + if(pConn == NULL) + { + MGC_ERROR("mgcPort[%d]step[%d] lost conn" , pPortInfo->id , pStep->id); + continue; + } + + mgc_port_info_rm_conn_from_pre_port_info(pConn); + pConn->pPrePortInfo = pPortInfo; + } + + return; +} + +/*************************************************************************** + * mgc_port_info_set_step_to_start + * ------------------------------------------------------------------------ + * General: make the PORT_INFO object to process it's steps + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + ***************************************************************************/ +void mgc_port_info_set_step_to_start(PORT_INFO *pPortInfo) +{ + if(pPortInfo == NULL) + return; + + if(pPortInfo->mgcfOperSteps[0].pConnect == NULL) + return; + +#ifdef MGC_REC_PORT + mgc_port_info_conn_rec_port_info(pPortInfo); +#endif + +#ifdef MGC_PORT_LIST_EN + mgc_port_list_add_to_active_list(pPortInfo); +#endif + + pPortInfo->pMgcOperCurrent = &(pPortInfo->mgcfOperSteps[0]); + pPortInfo->assigned = TRUE; + return; +} + +/*************************************************************************** + * mgc_port_info_set_step_to_next + * ------------------------------------------------------------------------ + * General: make PORT_INFO object move to the next step + * Return Value: if no more step return TRUE, else return FALSE + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + ***************************************************************************/ +BOOL mgc_port_info_set_step_to_next(PORT_INFO *pPortInfo) +{ + int i; + MGCF_OPER_STEP *pMgcOperCurrent = NULL; + MGCF_OPER_STEP *pMgcOperNext = NULL; + if(pPortInfo == NULL) + return FALSE; + + pMgcOperCurrent = pPortInfo->pMgcOperCurrent; + if(pMgcOperCurrent == NULL) + return FALSE; + + /*the duration between two steps*/ + if(pMgcOperCurrent->stepInfo.delay> MGC_OPERA_NO_DELAY) + { + return FALSE; + } + + for(i=0 ; imgcfOperSteps[i].status == MGCP_OPER_STEP_REQUEST) + { + pMgcOperNext = &pPortInfo->mgcfOperSteps[i]; + break; + } + } + + if(pMgcOperNext == NULL) + return TRUE; + + MGC_DEBUG("mgcPort[%d] current step[%d] =>> step[%d]" , pPortInfo->id , pMgcOperCurrent->id , pMgcOperNext->id); + pPortInfo->pMgcOperCurrent = pMgcOperNext; + return FALSE; +} + + + + +/*************************************************************************** + * mgc_port_info_cnf + * ------------------------------------------------------------------------ + * General: cnf function to handle response to the PORT_INFO object + * Return Value: if failure return -1, else return 0 + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + * cmd - MGCP cmd + * hdlPort - low-layer operate id + * retCode - response code + * pPara - response msg + ***************************************************************************/ +int mgc_port_info_cnf(PORT_INFO *pPortInfo , BYTE cmd, WORD hdlPort, WORD retCode, MGCP_PARA *pPara) +{ + MGCF_OPER_STEP *pCurrentStep = NULL; + MGC_SAP *pMgcSap = NULL; + + if((pPortInfo == NULL)||(pPara == NULL)) + return -1; + + pCurrentStep = pPortInfo->pMgcOperCurrent; + if(pCurrentStep == NULL) + { + MGC_ERROR("lost opera record"); + mgc_port_info_clear(pPortInfo); + return -1; + } + + if(pCurrentStep->hdlPort != hdlPort) + { + MGC_ERROR("lost mismatch hdlport"); + mgc_port_info_clear(pPortInfo); + return -1; + } + + if(pCurrentStep->stepInfo.cmd!= cmd) + { + MGC_ERROR("mismatch cmd"); + mgc_port_info_clear(pPortInfo); + return -1; + } + + if(pCurrentStep->pConnect == NULL) + { + MGC_ERROR("lost connection record"); + mgc_port_info_clear(pPortInfo); + return -1; + } + + pMgcSap = mgc_connect_get_conn_report_sap(pCurrentStep->pConnect); + pCurrentStep->llCmd = retCode; + if(mgc_port_info_oper_step_cnf(pCurrentStep , pPara) == FALSE) + { + if(pPortInfo->mgcfOperId != MGC_OPER_ID_AUEP) + { + MGC_ERROR("req cnf failure!"); + } + mgc_port_info_oper_failure_report(pPortInfo , pMgcSap); + mgc_connect_dettach_step_info(pCurrentStep->pConnect); + mgc_port_info_clear(pPortInfo); + return -1; + } + + if(--pCurrentStep->stepInfo.delay <= 0 ) + { + mgc_connect_dettach_step_info(pCurrentStep->pConnect); + if(mgc_port_info_set_step_to_next(pPortInfo) == TRUE) + { + mgc_port_info_oper_success_report(pPortInfo , pMgcSap); + mgc_port_info_init(pPortInfo, pPortInfo->id); + if(pPortInfo->mgcfOperId != MGC_OPER_ID_AUEP) + { + MGC_DEBUG("mgcPort[%d] work over" , pPortInfo->id); + } + } + } + + return 0; +} + + +char *mgc_port_info_print_step_status(MGCF_OPER_STEP *pOperaStep) +{ + if(pOperaStep == NULL) + return "MGCP_OPER_STEP_UNDEF"; + + switch(pOperaStep->status) + { + case MGCP_OPER_STEP_REQUEST: + return "MGCP_OPER_STEP_REQUEST"; + case MGCP_OPER_STEP_REQUEST_SENT: + return "MGCP_OPER_STEP_REQUEST_SENT"; + case MGCP_OPER_STEP_RESPONSE_GET: + return "MGCP_OPER_STEP_RESPONSE_GET"; + default: + return "MGCP_OPER_STEP_UNDEF"; + } + return "MGCP_OPER_STEP_UNDEF"; +} + +/*************************************************************************** + * mgc_port_info_fsm + * ------------------------------------------------------------------------ + * General: PORT_INFO object fsm function + * Return Value: void + * ------------------------------------------------------------------------ + * Arguments: + * Input: pPortInfo - the pointer of the PORT_INFO object + ***************************************************************************/ +void mgc_port_info_fsm(PORT_INFO *pPortInfo) +{ + int i; + MGCF_OPER_STEP *pCurrentStep = NULL; + MGCF_OPER_STEP *pStep = NULL; + MGCP_OPER_STEP_STATUS stepStatus; + MGC_SAP *pSap = NULL; + BOOL result = TRUE; + if(pPortInfo == NULL) + return; + + if(pPortInfo->pMgcOperCurrent == NULL) + return; + + pCurrentStep = pPortInfo->pMgcOperCurrent; + pSap = mgc_connect_get_conn_report_sap(pCurrentStep->pConnect); + //MGC_DEBUG("mgcPort[%d]step[%d] state %s" , pPortInfo->id , pCurrentStep->id , mgc_port_info_print_step_status(pCurrentStep)); + stepStatus = pCurrentStep->status; + switch(stepStatus) + { + case MGCP_OPER_STEP_REQUEST: + if(mgc_port_info_oper_step_request(pCurrentStep) == TRUE) + { + result = TRUE; + } + else + { + result = FALSE; + } + break; + case MGCP_OPER_STEP_REQUEST_SENT: + pPortInfo->mgcfTimer--; + if(pPortInfo->mgcfTimer == 0) + { + result = FALSE; + MGC_WARN("mgcPort[%d] operate timeout" , pPortInfo->id ); + } + break; + case MGCP_OPER_STEP_RESPONSE_GET: + //MGC_DEBUG("mgcPort[%d]step[%d] delay %d" , pPortInfo->id, pCurrentStep->id , pCurrentStep->stepInfo.delay); + if(--pCurrentStep->stepInfo.delay <= 0 ) + { + mgc_connect_dettach_step_info(pCurrentStep->pConnect); + if(mgc_port_info_set_step_to_next(pPortInfo) == TRUE) + { + mgc_port_info_oper_success_report(pPortInfo , pSap); + if(pPortInfo->mgcfOperId != MGC_OPER_ID_AUEP) + { + MGC_DEBUG("mgcPort[%d] work over" , pPortInfo->id); + } + mgc_port_info_init(pPortInfo, pPortInfo->id); + } + } + break; +/************************************************************************* +* following status is used for MG control, up status is used for MGC control +****************************************************************************/ + case MGCP_OPER_STEP_IND: + // MGC_DEBUG("mgcPort[%d]step[%d] enter IND" , pPortInfo->id , pCurrentStep->id); + result = mgc_port_info_oper_step_ind(pCurrentStep); + break; + case MGCP_OPER_STEP_IND_SENT: + // MGC_DEBUG("mgcPort[%d]step[%d] delay %d" , pPortInfo->id, pCurrentStep->id , pCurrentStep->stepInfo.delay); + pPortInfo->mgcfTimer--; + if(pPortInfo->mgcfTimer == 0) + { + pCurrentStep->status = MGCP_OPER_STEP_RESPONSE; + MGC_WARN("mgcPort[%d]Step[%d] operate timeout" , pPortInfo->id , pCurrentStep->id); + } + break; + case MGCP_OPER_STEP_RESPONSE: + result = mgc_port_info_oper_step_resp(pCurrentStep); + if(result == TRUE) + mgc_port_info_init(pPortInfo, pPortInfo->id); + break; + default: + MGC_WARN("mgcPort[%d]step[%d] unhandle state %d" , pPortInfo->id , pCurrentStep->id , pCurrentStep->status); + break; + } + + switch(stepStatus) + { + case MGCP_OPER_STEP_REQUEST: + case MGCP_OPER_STEP_REQUEST_SENT: + case MGCP_OPER_STEP_RESPONSE_GET: + if(result == FALSE) + { + MGC_DEBUG("mgcPort[%d] step[%d] state %s failure", pPortInfo->id , pCurrentStep->id , mgc_port_info_print_step_status(pCurrentStep)); + mgc_port_info_oper_failure_report(pPortInfo , mgc_connect_get_conn_report_sap(pCurrentStep->pConnect)); + mgc_connect_dettach_step_info(pCurrentStep->pConnect); + mgc_port_info_clear(pPortInfo); + } + break; + case MGCP_OPER_STEP_IND: + case MGCP_OPER_STEP_IND_SENT: + case MGCP_OPER_STEP_RESPONSE: + if(result == FALSE) + { + for(i=0 ; imgcfOperSteps[i]; + + if(pStep->pConnect == NULL) + continue; + + // mgc_port_info_oper_step_resp(pStep); + mgc_chnl_info_detach_connect(pStep->pConnect->pChnlInfo, pStep->pConnect); + mgc_connect_init(pStep->pConnect, pStep->pConnect->id); + } + mgc_port_info_init(pPortInfo, pPortInfo->id); + } + break; + default : + break; + } + return; +} + +BOOL mgc_port_info_insert_dlcx_req(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect) +{ + int i; + PORT_INFO portInfoTmp; + MGCF_OPER_STEP *pStep = NULL; + CONNECT_INFO *pConnTmp = NULL; + + if((pPortInfo == NULL)||(pConnect == NULL)) + return FALSE; + + mgc_port_info_init(&portInfoTmp, 0xFFFF); + + if(pPortInfo->pMgcOperCurrent == NULL) + return FALSE; + + if(pPortInfo->pMgcOperCurrent->pConnect != pConnect) + return FALSE; + + pConnTmp = mgc_connect_dup_attr(pConnect); + if(pConnTmp == NULL) + return FALSE; + + mgc_connect_add_dlcx(pConnTmp, &portInfoTmp); + pPortInfo->pMgcOperCurrent->status = MGCP_OPER_STEP_REQUEST; + mgc_connect_set_status(pConnect,MGC_CONNECT_STATUS_IDLE); + for(i= 0; imgcfOperSteps[i]; + + if(pStep->status != MGCP_OPER_STEP_REQUEST) + continue; + + if(mgc_port_info_add_opera_to_port(&portInfoTmp, pStep->pConnect, &pStep->stepInfo) == TRUE) + continue; + + return FALSE; + } + + portInfoTmp.usrPort = pPortInfo->usrPort; + portInfoTmp.mgcfTimer = pPortInfo->mgcfTimer; + mgc_port_info_set_oper_id(&portInfoTmp , pPortInfo->mgcfOperId); + + mgc_port_info_init(pPortInfo, pPortInfo->id); + + mgc_connect_add_nop(pConnect, pPortInfo); + for(i= 0; istatus != MGCP_OPER_STEP_REQUEST) + continue; + + if(mgc_port_info_add_opera_to_port(pPortInfo, pStep->pConnect, &pStep->stepInfo) == TRUE) + continue; + + mgc_port_info_init(pPortInfo, pPortInfo->id); + return FALSE; + } + + mgc_port_info_set_step_to_start(pPortInfo); + mgc_port_info_set_oper_id(pPortInfo , portInfoTmp.mgcfOperId); + pPortInfo->usrPort = portInfoTmp.usrPort; + return TRUE; +} + + +BOOL mgc_port_info_mv_step_into_new_port(PORT_INFO *pPortInfo , MGCF_OPER_STEP *pOperStep) +{ + int i; + PORT_INFO *pOldPortInfo = NULL; + MGCF_OPER_STEP *pStep = NULL; + if((pPortInfo == NULL)||(pOperStep == NULL)) + return FALSE; + + pOldPortInfo = mgc_port_info_get_step_port(pOperStep); + if(pOldPortInfo == NULL) + return FALSE; + + MGC_DEBUG("enter %s" , __FUNCTION__); + + if(pOldPortInfo->pMgcOperCurrent != pOperStep) + { + MGC_WARN("mgcPort[%d] illegal step status" , pOldPortInfo->id); + return FALSE; + } + + if(pOperStep->stepInfo.delay != MGC_OPERA_NO_DELAY) + pOperStep->stepInfo.delay = MGC_OPERA_NO_DELAY; + + for(i= pOperStep->id+1 ; imgcfOperSteps[i]; + + if(pStep->status != MGCP_OPER_STEP_REQUEST) + continue; + + if(pStep->stepInfo.delay != MGC_OPERA_NO_DELAY) + pStep->stepInfo.delay = MGC_OPERA_NO_DELAY; + + if(mgc_port_info_add_opera_to_port(pPortInfo, pStep->pConnect, &pStep->stepInfo) != TRUE) + break; + + mgc_port_info_oper_step_init(pStep, pStep->pPortInfo,pStep->id); + } + + return TRUE; +} + + +BYTE *mgc_port_info_get_res_addr(void) +{ + return (BYTE *)mgcPort; +} + diff --git a/omc/plat/mgc_v2/src/mgc_port_list.c b/omc/plat/mgc_v2/src/mgc_port_list.c new file mode 100644 index 0000000..189dc88 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_port_list.c @@ -0,0 +1,291 @@ +#include "./include/mgc_port_list.h" +#include "./include/mgc_port_info.h" +#include "./include/mgc_debug.h" + +#define MGC_MAX_NUM_OF_PORT_NODE (MGC_MAX_NUM_OF_PORT) + +MGC_PORT_NODE mgcPortNode[MGC_MAX_NUM_OF_PORT_NODE]; +MGC_PORT_LIST mgcPortActiveList; + +static void mgc_port_list_node_init(MGC_PORT_NODE *pNode , int id) +{ + if(pNode == NULL) + return; + + pNode->id = id; + pNode->pPortInfo = NULL; + pNode->pPrior = NULL; + pNode->pNext = NULL; + pNode->pList = NULL; + return; +} + +static void mgc_port_list_init(MGC_PORT_LIST *pList) +{ + if(pList == NULL) + return; + + pList->pHead = NULL; + pList->len = 0; + return; +} + +static MGC_PORT_NODE *mgc_port_list_get_unused_node(void) +{ + int i; + static int index = 0 ; + MGC_PORT_NODE *pNode = NULL; + MGC_PORT_NODE *pNodeTmp = NULL; + + i = index; + do + { + i++; + + if(i == MGC_MAX_NUM_OF_PORT_NODE) + i = 0; + + pNode = &mgcPortNode[i]; + + if((pNode->pNext != NULL)||(pNode->pPrior != NULL)) + continue; + + if((pNode->pPortInfo != NULL)||(pNode->pList != NULL)) + { + MGC_ERROR("mgcNode[%d] error rec" , pNode->id); + mgc_port_list_node_init(pNode, pNode->id); + continue; + } + + pNodeTmp = pNode; + index = i; + break; + + }while( i!=index); + + return pNodeTmp; +} + +void mgc_port_list_setup(void) +{ + int i; + MGC_PORT_NODE *pNode = NULL; + + for(i=0 ; ilen; +} + +MGC_PORT_NODE *mgc_port_list_get_tail(MGC_PORT_LIST *pList) +{ + if((pList == NULL)||(pList->pHead == NULL)) + return NULL; + + return (pList->pHead->pPrior); +} + + +static BOOL mgc_port_list_add_node_to_list(MGC_PORT_LIST *pList , MGC_PORT_NODE *pNode) +{ + MGC_PORT_NODE *pNodeTail; + if((pList == NULL)||(pNode == NULL)) + return FALSE; + + if(pList->pHead == NULL) + { + pList->pHead = pNode; + pList->pHead->pPrior = pNode; + pList->pHead->pNext = pNode; + pNode->pList = pList; + } + + pNodeTail = mgc_port_list_get_tail(pList); + if(pNodeTail == NULL) + { + MGC_ERROR("lost portlist tail"); + return FALSE; + } + + pNode->pPrior = pNodeTail; + pNode->pNext = pNodeTail->pNext; + pNode->pList = pList; + pNodeTail->pNext = pNode; + pList->pHead->pPrior = pNode; + pList->len++; + + return TRUE; +} + +static MGC_PORT_NODE *mgc_port_list_find_port_in_active_list(PORT_INFO *pPortInfo) +{ + MGC_PORT_NODE *pNode = NULL; + MGC_PORT_NODE *pNodeTmp = NULL; + MGC_PORT_NODE *pHead = NULL; + + if(pPortInfo == NULL) + return NULL; + + pHead = mgcPortActiveList.pHead; + + if(pHead == NULL) + return NULL; + + pNode = pHead; + do{ + if(pNode->pPortInfo == pPortInfo) + { + pNodeTmp = pNode; + break; + } + + pNode = pNode->pNext; + }while(pNode != pHead); + + return pNodeTmp; +} + + +MGC_PORT_NODE *mgc_port_list_add_to_active_list(PORT_INFO *pPortInfo) +{ + MGC_PORT_NODE *pNode = NULL; + + if(pPortInfo == NULL) + return NULL; + + pNode = mgc_port_list_find_port_in_active_list(pPortInfo); + if(pNode != NULL) + return pNode; + + pNode = mgc_port_list_get_unused_node(); + + if(pNode == NULL) + { + MGC_ERROR("mgcPortNode is full!"); + return NULL; + } + + pNode->pPortInfo = pPortInfo; + + if(mgc_port_list_add_node_to_list(&mgcPortActiveList, pNode) == FALSE) + { + mgc_port_list_node_init(pNode, pNode->id); + return NULL; + } + //MGC_DEBUG("mgcPort[%d] add to mgcPortNode[%d]" , pPortInfo->id , pNode->id); + return pNode; +} + + + + +static BOOL mgc_port_list_remove_node_from_list(MGC_PORT_LIST *pList , MGC_PORT_NODE *pNode) +{ + MGC_PORT_NODE *pPrior = NULL; + MGC_PORT_NODE *pNext = NULL; + + if((pList == NULL) || (pNode == NULL)) + return FALSE; + + if(pNode->pList != pList) + { + MGC_ERROR("mgcPortNode[%d] not belong to the list" , pNode->id); + return FALSE; + } + + pPrior = pNode->pPrior; + pNext = pNode->pNext; + + if((pPrior == NULL)||(pNext == NULL)) + { + MGC_ERROR("mgcPortNode[%d] lost rec" , pNode->id); + return FALSE; + } + + pPrior->pNext = pNext; + pNext->pPrior = pPrior; + pList->len--; + + if(pList->pHead == pNode) + { + pList->pHead = pNext; + } + + if((pPrior == pNode)&&(pNext == pNode)) + { + pList->pHead = NULL; + } + + mgc_port_list_node_init(pNode, pNode->id); + return TRUE; +} + +BOOL mgc_port_list_remove_from_active_list(PORT_INFO *pPortInfo) +{ + MGC_PORT_NODE *pNode = NULL; + + if(pPortInfo == NULL) + return FALSE; + + pNode = mgc_port_list_find_port_in_active_list(pPortInfo); + if(pNode == NULL) + { + MGC_ERROR("mgcPort[%d] is not in the active list" , pPortInfo->id); + return FALSE; + } + + if(mgc_port_list_remove_node_from_list(&mgcPortActiveList, pNode) == FALSE) + return FALSE; + + //MGC_DEBUG("mgcPort[%d] remove from mgcPortNode[%d]" , pPortInfo->id , pNode->id); + return TRUE; +} + + +void mgc_port_active_list_proc(void) +{ + MGC_PORT_NODE *pNode = NULL; + MGC_PORT_NODE *pNodeTmp = NULL; + PORT_INFO *pPortInfo = NULL; + MGC_PORT_LIST *pList = &mgcPortActiveList; + + if(pList->pHead == NULL) + return; + + pNode = pList->pHead; + do{ + pPortInfo = pNode->pPortInfo; + pNodeTmp = pNode; + pNode = pNode->pNext; + + if(pPortInfo == NULL) + { + MGC_ERROR("mgcPortNode[%d] lost rec" , pNodeTmp->id); + mgc_port_list_remove_node_from_list(pNodeTmp->pList, pNodeTmp); + } + else + { + mgc_port_info_fsm(pNode->pPortInfo); + if(pPortInfo->assigned == FALSE) + mgc_port_list_remove_from_active_list(pPortInfo); + } + + }while((pNode != pList->pHead)&&(pList->pHead != NULL)); + + return; +} + + + diff --git a/omc/plat/mgc_v2/src/mgc_sur_info.c b/omc/plat/mgc_v2/src/mgc_sur_info.c new file mode 100644 index 0000000..28a729a --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_sur_info.c @@ -0,0 +1,562 @@ +#include "./include/mgc_sur_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_tandem_info.h" + + + + + +static CONNECT_INFO mgcSurvillanceConn[MGC_MAX_NUM_OF_SURVEILLANCE_CONN]; +static CHNL_INFO mgcSurvillianceChnl[MGC_MAX_NUM_OF_SURVEILLIANCE_CHNL]; +static PHY_PORT_INFO mgcSurvilliancePort[MGC_MAX_NUM_OF_SURVEILLANCE_NUM]; +static MGC_SUR_INFO_NODE mgcSurvillianceNode[MGC_MAX_NUM_OF_SURVEILLANCE_NODE]; + + +extern MGC_SAP *mgc_sap_get_index_sap(int index); + + +static void mgc_sur_info_node_init(MGC_SUR_INFO_NODE *pNode , int id) +{ + if(pNode == NULL) + return ; + + pNode->id = id; + pNode->pConn = NULL; + pNode->pNext = NULL; + pNode->pPrior = NULL; + return; +} + + +static MGC_SUR_INFO_NODE *mgc_sur_info_get_unused_node(void) +{ + int i; + static int index = 0; + MGC_SUR_INFO_NODE *pNode = NULL; + MGC_SUR_INFO_NODE *pNodeTmp = NULL; + + i = index; + do + { + i++; + if(i == MGC_MAX_NUM_OF_SURVEILLANCE_NODE) + i = 0; + + pNode = &mgcSurvillianceNode[i]; + if(pNode->pConn != NULL) + continue; + + index = i; + pNodeTmp = pNode; + break; + }while(i != index); + + return pNodeTmp; +} + + +void mgc_sur_info_list_init(MGC_SUR_INFO_LIST *pList) +{ + if(pList == NULL) + return ; + + pList->len = 0; + pList->pHead = NULL; + return; +} + +MGC_SUR_INFO_NODE *mgc_sur_info_get_list_tail(MGC_SUR_INFO_LIST *pList) +{ + MGC_SUR_INFO_NODE *pNode = NULL; + MGC_SUR_INFO_NODE *pNodeHead = NULL; + + if((pList == NULL)||(pList->pHead == NULL)) + return NULL; + + pNode = NULL; + pNodeHead = pList->pHead; + pNode = pNodeHead->pNext; + while(pNode->pNext != pNodeHead) + { + pNode = pNode->pNext; + } + + return pNode; +} + +MGC_SUR_INFO_NODE *mgc_sur_info_get_list_node(MGC_SUR_INFO_LIST *pList , WORD index) +{ + MGC_SUR_INFO_NODE *pNode = NULL; + MGC_SUR_INFO_NODE *pNodeTmp = NULL; + int i; + + if((pList == NULL) || (pList->pHead == NULL)) + return NULL; + + if(index >= pList->len) + { + MGC_WARN("list len %d <= %d" , pList->len , index); + return NULL; + } + + i = 0; + pNode = pList->pHead; + do + { + if(i == index) + { + pNodeTmp = pNode; + break; + } + + i++; + pNode = pNode->pNext; + }while(pNode != pList->pHead); + + return pNodeTmp; +} + + +MGC_SUR_INFO_NODE *mgc_sur_info_find_conn_in_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn) +{ + MGC_SUR_INFO_NODE *pNode = NULL; + BOOL result = FALSE; + + if((pList == NULL)||(pConn == NULL)||(pList->pHead == NULL)) + return NULL; + + pNode = pList->pHead; + do + { + if(pNode->pConn == pConn) + { + result = TRUE; + //MGC_DEBUG("find conn[%d] in the list" , pConn->id); + break; + } + + pNode = pNode->pNext; + }while(pNode != pList->pHead); + + if(result == TRUE) + return pNode; + + return NULL; +} + + +BOOL mgc_sur_info_add_conn_to_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn) +{ + MGC_SUR_INFO_NODE *pNode = NULL; + MGC_SUR_INFO_NODE *pNodeTail = NULL; + + if((pList == NULL)||(pConn == NULL)) + return FALSE; + + pNode = mgc_sur_info_get_unused_node(); + if(pNode == NULL) + return FALSE; + + pNode->pConn = pConn; + pNode->pPrior = pNode; + pNode->pNext = pNode; + + if(pList->pHead == NULL) + pList->pHead = pNode; + + + pNodeTail = mgc_sur_info_get_list_tail(pList); + if(pNodeTail == NULL) + { + MGC_ERROR("lost list tail"); + return FALSE; + } + + pNode->pPrior = pNodeTail; + pNode->pNext = pNodeTail->pNext; + pNodeTail->pNext = pNode; + pList->pHead->pPrior = pNode; + + pList->len++; + MGC_DEBUG("conn[%d] is add to node[%d] , list len %d" , pConn->id , pNode->id , pList->len); + return TRUE; +} + + + +BOOL mgc_sur_info_remove_conn_to_list(MGC_SUR_INFO_LIST *pList , CONNECT_INFO *pConn) +{ + MGC_SUR_INFO_NODE *pNode = NULL; + MGC_SUR_INFO_NODE *pPrior = NULL; + MGC_SUR_INFO_NODE *pNext = NULL; + + if((pList == NULL)||(pConn == NULL)||(pList->pHead == NULL)) + return FALSE; + + pNode = mgc_sur_info_find_conn_in_list(pList, pConn); + if(pNode == NULL) + { + MGC_ERROR("conn[%d] is not find in the list" , pConn->id); + return FALSE; + } + + pPrior = pNode->pPrior; + pNext = pNode->pNext; + + pPrior->pNext = pNext; + pNext->pPrior = pPrior; + + pList->len--; + + if(pList->pHead == pNode) + { + pList->pHead = pNext; + } + + if((pPrior == pNode)&&(pNext == pNode)) + { + if(pList->len != 0) + { + MGC_DEBUG("list shoulde be empty, len %d" , pList->len); + } + pList->pHead = NULL; + } + + MGC_DEBUG("conn[%d] is removed from node[%d] list len %d" , pConn->id , pNode->id , pList->len); + mgc_sur_info_node_init(pNode, pNode->id); + return TRUE; +} + + + +void mgc_sur_info_clear_list(MGC_SUR_INFO_LIST *pList) +{ + MGC_SUR_INFO_NODE *pNodeTail = NULL; + CONNECT_INFO *pConn = NULL; + MGCP_PARA mgcpPara; + + if((pList == NULL)||(pList->pHead == NULL)) + return ; + + pNodeTail = mgc_sur_info_get_list_tail(pList); + while(pNodeTail != NULL) + { + pConn = pNodeTail->pConn; + + if((mgc_connect_get_status(pConn) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pConn) == MGC_CONNECT_STATUS_CREATE)) + { + if(mgc_connect_dlcx_para_create(pConn , &mgcpPara) == TRUE) + MGCP_req(mgc_mgcp_get_sap_index(), MGCP_CMD_DLCX , 0xFFFF , &mgcpPara); + } + mgc_tandem_info_unset_conn(pConn->pTandem, pConn); + mgc_chnl_info_detach_connect(pConn->pChnlInfo, pConn); + mgc_connect_init(pConn, pConn->id); + mgc_sur_info_remove_conn_to_list(pList , pConn); + pNodeTail = mgc_sur_info_get_list_tail(pList); + } + + if(pList->len != 0) + { + MGC_ERROR("list clear failed!"); + } + + return; +} + + + +static CHNL_INFO *mgc_sur_info_get_unsed_chnl(void) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + for(i=0 ; istatus != MGC_CHNL_INFO_STATUS_UNDEF) + continue; + + return pChnlInfo; + } + + return NULL; +} + + + +static CONNECT_INFO *mgc_sur_info_get_unsed_conn(void) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + for(i=0 ; ipChnlInfo != NULL) + continue; + + return pConnect; + } + + return NULL; +} + +#if 0 +static BOOL mgc_sur_info_add_conn_to_chnl(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConn; + + if(pChnlInfo == NULL) + return FALSE; + + for(i=0 ; imaxConnectNum ; i++) + { + pConn = mgc_sur_info_get_unsed_conn(); + if(pConn == NULL) + return FALSE; + + if(mgc_chnl_info_attach_connect(pChnlInfo, pConn, i) == FALSE) + return FALSE; + + //MGC_DEBUG("surConn[%d] add to chnlInfo[%d]", pConn->id , pChnlInfo->id); + } + + return TRUE; +} +#endif + + +static BOOL mgc_sur_info_add_chnl_to_port(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + if(pPhyPort == NULL) + return FALSE; + + for(i=0 ; ichnlNum ; i++) + { + pChnlInfo = mgc_sur_info_get_unsed_chnl(); + if(pChnlInfo == NULL) + return FALSE; + + pPhyPort->pChnlInfo[i] = pChnlInfo; + + if(mgc_chnl_info_attach_to_phy_port(pChnlInfo , pPhyPort) == FALSE) + return FALSE; + +// if(mgc_sur_info_add_conn_to_chnl(pChnlInfo) == FALSE) +// return FALSE; + + mgc_chnl_info_status_set(pChnlInfo , MGC_CHNL_INFO_STATUS_IDLE); + //MGC_DEBUG("chnlInfo[%d] add to phyPort[%d]" , pChnlInfo->id, pPhyPort->id); + } + + return TRUE; +} + + +static PHY_PORT_INFO *mgc_sur_info_get_unused_phy_port(void) +{ + int i; + PHY_PORT_INFO *pPhyPort = NULL; + + for(i=0 ; ichnlNum == 0)&&(pPhyPort->pMgInfo == NULL)) + return pPhyPort; + } + return NULL; +} + + + + +BOOL mgc_sur_info_add_survillance_res(BYTE sapIndex, WORD mgNo) +{ + MG_INFO *pMgInfo; + MGC_SAP *pMgcSap; + int i; + BOOL result = FALSE; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + if((pMgInfo == NULL)||(pMgcSap == NULL)) + return FALSE; + + if(pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + return FALSE; + + pPhyPort = mgc_sur_info_get_unused_phy_port(); + if(pPhyPort == NULL) + return FALSE; + + for(i=0 ; ipPhyPort[i] != NULL) + continue; + result = TRUE; + break; + } + + if(result == FALSE) + { + MGC_DEBUG("mg[%d] is full of phyport" , pMgInfo->id); + return FALSE; + } + pPhyPort->portType = MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE; + pPhyPort->portNo = i; + pPhyPort->pMgcSap = pMgcSap; + pPhyPort->pMgInfo = pMgInfo; + + switch(pMgInfo->mgAttr.ctrlType) + { + case MGC_MG_CTRL_TYPE_MGCP: + mgc_phy_port_set_chnl_num(pPhyPort , pPhyPort->portType); + break; + default: + mgc_phy_port_clear(pPhyPort); + MGC_ERROR("mgcMgInfo[%d] unsupport ctrl type %d" , pMgInfo->id , pMgInfo->mgAttr.ctrlType); + return FALSE; + } + + + if(mgc_sur_info_add_chnl_to_port(pPhyPort) == FALSE) + { + mgc_phy_port_clear(pPhyPort); + return FALSE; + } + + if(mgc_mg_info_attach_phy_port(pMgInfo , pPhyPort, pMgcSap)== FALSE) + { + mgc_phy_port_clear(pPhyPort); + return FALSE; + } + + return TRUE; + +} + + +void mgc_sur_info_setup(void) +{ + int i; + CONNECT_INFO *pConn = NULL; + CHNL_INFO *pChnl = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + MGC_SUR_INFO_NODE *pNode = NULL; + + for(i=0; ichnlNum ; i++) + { + pChnlInfo = pPhyPort->pChnlInfo[i]; + if(pChnlInfo == NULL) + { + MGC_WARN("phyPort[%d] lost chnl[%d] info" , pPhyPort->id , i); + continue; + } + + for(j=0 ; jmaxConnectNum ; j++) + { + pConnect = pChnlInfo->pConnection[j]; + + if(pConnect == NULL) + { + pConnect = mgc_sur_info_get_unsed_conn(); + if(pConnect == NULL) + continue; + + if(pConnect->pTandem != NULL) + { + MGC_WARN("surConn[%d] attached illegal tandem[%d]", pConnect->id, pConnect->pTandem->id); + mgc_connect_init(pConnect, pConnect->id); + continue; + } + + if(mgc_chnl_info_attach_connect(pChnlInfo, pConnect, j) == FALSE) + continue; + + return pConnect; + } + } + } + + MGC_DEBUG("no unattached conn find in phyport[%d]" , pPhyPort->id); + return NULL; +} + +CONNECT_INFO *mgc_sur_info_find_sur_conn_in_mg(MG_INFO *pMgInfo) +{ + int i; + CONNECT_INFO *pConnect = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + if((pMgInfo == NULL)||(pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM)) + return NULL; + + for(i=0 ; ipPhyPort[i]; + + if(pPhyPort == NULL) + continue; + + if(pPhyPort->portType != MGC_PHY_VIRTUAL_TYPE_SURVEILLANCE) + continue; + + break; + } + + if(pPhyPort == NULL) + { + MGC_ERROR("no surveillant port find in mg[%d]" , pMgInfo->id); + return NULL; + } + + pConnect = mgc_sur_info_find_unattached_conn_in_phy_port(pPhyPort); + return pConnect; +} diff --git a/omc/plat/mgc_v2/src/mgc_tandem_info.c b/omc/plat/mgc_v2/src/mgc_tandem_info.c new file mode 100644 index 0000000..0026b13 --- /dev/null +++ b/omc/plat/mgc_v2/src/mgc_tandem_info.c @@ -0,0 +1,1374 @@ +/* +********************************************************************************* +* * +* NOTICE: * +* * +********************************************************************************* +* ++++++++++++++++++++++++++++++++++ +* + + +* + + +* target -------> + recv endpoint <-------------->send enpoint + <--------------associator +* + | | + +* + | | + +* + | | + +* + + +* + tandem objec + +* ++++++++++++++++++++++++++++++++++ +* +* +* +*/ + + + + +/********************************************************************************* + * + * This file should provide rtp_proxy related object APIs + * + * Author Date + * ------ ------ + * Sam Yao Aug 2008 + *********************************************************************************/ + + +#include "./include/mgc_tandem_info.h" +#include "./include/mgc_debug.h" +#include "./include/mgc_conn_info.h" +#include "./include/mgc_chnl_info.h" +#include "./include/mgc_phy_port.h" +#include "./include/mgc_mgcp.h" +#include "./include/mgc_mg_info.h" +#include "./include/mgc_port_info.h" +#include "./include/mgc_sur_info.h" +static MGC_TANDEM_INFO mgcTandem[MGC_MAX_NUM_OF_TANDEM]; +static CONNECT_INFO mgcTandConn[MGC_MAX_NUM_OF_TANDEM_CONN]; +static CHNL_INFO mgcTandChnl[MGC_MAX_NUM_OF_TANDEM_CHNL]; +static PHY_PORT_INFO mgcTandPort[MGC_MAX_NUM_OF_RTP_PROXY_NUM]; + + +extern MGC_SAP *mgc_sap_get_index_sap(int index); + +MGC_TANDEM_STATUS mgc_tandem_info_get_status(MGC_TANDEM_INFO *pTandem) +{ + if(pTandem == NULL) + return MGC_TANDEM_STATUS_UNDEF; + + return pTandem->status; +} + +void mgc_tandem_info_set_status(MGC_TANDEM_INFO *pTandem , MGC_TANDEM_STATUS status) +{ + if((pTandem == NULL)||(status == MGC_TANDEM_STATUS_UNDEF)) + return; + + pTandem->status = status; +} + +CONNECT_INFO *mgc_tandem_info_get_unattached_conn(void) +{ + CONNECT_INFO *pConnect = NULL; + int i; + + for(i=0 ; ipTandem != NULL) + continue; + + return pConnect; + } + + return NULL; +} + +BOOL mgc_tandem_info_conn_rec_tandem(CONNECT_INFO *pConnect , MGC_TANDEM_INFO *pTandem) +{ + if((pConnect == NULL) || (pTandem == NULL)) + return FALSE; + + if(pConnect->pTandem != NULL) + { + MGC_ERROR("conn[%d] already attached to tandem[%d]!" , pConnect->id, pConnect->pTandem->id); + return FALSE; + } + + pConnect->pTandem = pTandem; + return TRUE; +} + + +BOOL mgc_tandem_info_unset_conn(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConnect) +{ + if((pTandem == NULL)||(pConnect == NULL)) + return FALSE; + + if(pTandem->pAconn == pConnect) + { + pTandem->pAconn = NULL; + MGC_DEBUG("tandem[%d] unset aor conn[%d]!" , pTandem->id, pConnect->id); + } + else if(pTandem->pTconn == pConnect) + { + pTandem->pTconn = NULL; + MGC_DEBUG("tandem[%d] unset tar conn[%d]!" , pTandem->id, pConnect->id); + } + else if(pTandem->pTxconn == pConnect) + { + pTandem->pTxconn = NULL; + MGC_WARN("tandem[%d] tx is removed!" , pTandem->id); + } + else if(pTandem->pRxconn == pConnect) + { + pTandem->pRxconn = NULL; + MGC_WARN("tandem[%d] rx is removed!" , pTandem->id); + } + else if(mgc_sur_info_remove_conn_to_list(&pTandem->list, pConnect) != FALSE) + { + MGC_DEBUG("tandem[%d] remove sur conn[%d]" , pTandem->id , pConnect->id); + } + pConnect->pTandem = NULL; + return TRUE; +} + + +BOOL mgc_tandem_info_set_conn(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConnect, MGC_TANDEM_CONN_POS pos) +{ + BOOL result = FALSE; + + if((pTandem == NULL)||(pConnect== NULL)||(pos == MGC_TANDEM_CONN_POS_UNDEF)) + return FALSE; + + if(pConnect->pTandem != NULL) + { + MGC_ERROR("conn[%d] already attached to tandem[%d]!" , pConnect->id, pConnect->pTandem->id); + return FALSE; + } + + switch(pos) + { + case MGC_TANDEM_CONN_POS_TAR: + if(pTandem->pTconn != NULL) + { + MGC_ERROR("tandem[%d] already have target conn[%d]!" , pTandem->id, pTandem->pTconn->id); + break; + } + if(mgc_tandem_info_conn_rec_tandem(pConnect, pTandem) == TRUE) + { + pTandem->pTconn = pConnect; + result = TRUE; + MGC_DEBUG("tandem[%d] set tar conn[%d]", pTandem->id, pConnect->id); + } + mgc_tandem_info_set_status(pTandem, MGC_TANDEM_STATUS_USED); + break; + case MGC_TANDEM_CONN_POS_TX: + if(pTandem->pTxconn != NULL) + { + MGC_ERROR("tandem[%d] already have tx conn[%d]!" , pTandem->id, pTandem->pTxconn->id); + break; + } + if(mgc_tandem_info_conn_rec_tandem(pConnect, pTandem) == TRUE) + { + pTandem->pTxconn = pConnect; + result = TRUE; + // MGC_DEBUG("tandem[%d] set tx conn[%d]", pTandem->id, pConnect->id); + } + break; + case MGC_TANDEM_CONN_POS_RX: + if(pTandem->pRxconn != NULL) + { + MGC_ERROR("tandem[%d] already have rx conn[%d]!" , pTandem->id, pTandem->pRxconn->id); + break; + } + if(mgc_tandem_info_conn_rec_tandem(pConnect, pTandem) == TRUE) + { + pTandem->pRxconn = pConnect; + result = TRUE; + // MGC_DEBUG("tandem[%d] set rx conn[%d]", pTandem->id, pConnect->id); + } + break; + case MGC_TANDEM_CONN_POS_AOR: + if(pTandem->pAconn != NULL) + { + MGC_ERROR("tandem[%d] already have associator conn[%d]!" , pTandem->id, pTandem->pAconn->id); + break; + } + + if(mgc_tandem_info_get_status(pTandem) == MGC_TANDEM_STATUS_IDLE) + { + MGC_ERROR("tandem[%d] should not set aorConn[%d] fisrt" , pTandem->id , pConnect->id); + result = FALSE; + break; + } + + if(mgc_tandem_info_conn_rec_tandem(pConnect, pTandem) == TRUE) + { + pTandem->pAconn = pConnect; + result = TRUE; + MGC_DEBUG("tandem[%d] set aor conn[%d]", pTandem->id, pConnect->id); + } + break; + case MGC_TANDEM_CONN_POS_SUR: + MGC_DEBUG("try find conn[%d] in tandem[%d] list" , pConnect->id , pTandem->id); + if(mgc_sur_info_find_conn_in_list(&pTandem->list, pConnect) != NULL) + { + result = TRUE; + MGC_DEBUG("tandem[%d] already has sur conn[%d]" , pTandem->id , pConnect->id); + break; + } + if(mgc_tandem_info_conn_rec_tandem(pConnect, pTandem) == FALSE) + break; + if(mgc_sur_info_add_conn_to_list(&pTandem->list, pConnect) == TRUE) + { + result = TRUE; + MGC_DEBUG("tandem[%d] add sur conn[%d]" , pTandem->id , pConnect->id); + break; + } + break; + default: + return result; + } + + pConnect->pTandem = pTandem; + return result; +} + + + + +MGC_TANDEM_CONN_POS mgc_tandem_info_get_conn_pos(MGC_TANDEM_INFO *pTandem , CONNECT_INFO *pConnect) +{ + MGC_TANDEM_CONN_POS pos = MGC_TANDEM_CONN_POS_UNDEF; + + + if((pTandem == NULL) || (pConnect == NULL)) + return MGC_TANDEM_CONN_POS_UNDEF; + + if(pTandem->pTconn == pConnect) + { + pos = MGC_TANDEM_CONN_POS_TAR; + } + else if(pTandem->pTxconn == pConnect) + { + pos = MGC_TANDEM_CONN_POS_TX; + } + else if(pTandem->pRxconn == pConnect) + { + pos = MGC_TANDEM_CONN_POS_RX; + } + else if(pTandem->pAconn == pConnect) + { + pos = MGC_TANDEM_CONN_POS_AOR; + } + else if(mgc_sur_info_find_conn_in_list(&pTandem->list,pConnect) != NULL) + { + pos = MGC_TANDEM_CONN_POS_SUR; + } + + if(pos != MGC_TANDEM_CONN_POS_UNDEF) + { + if(pTandem != pConnect->pTandem) + { + MGC_ERROR(" conn[%d] do not bleong to tandem[%d]" , pConnect->id , pTandem->id); + pos = MGC_TANDEM_CONN_POS_UNDEF; + } + } + + return pos; +} + + +BOOL mgc_tandem_info_init(MGC_TANDEM_INFO *pTandem , int id) +{ + CONNECT_INFO *pConn = NULL; + MGCP_PARA mgcpPara; + + if(pTandem == NULL) + return FALSE; + + pTandem->id = id; + pTandem->pTconn = NULL; + pTandem->pAconn = NULL; + + if(pTandem->pRxconn != NULL) + { + if((mgc_connect_get_status(pTandem->pRxconn) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pTandem->pRxconn) == MGC_CONNECT_STATUS_CREATE)) + { + if(mgc_connect_dlcx_para_create(pTandem->pRxconn , &mgcpPara) == TRUE) + MGCP_req(mgc_mgcp_get_sap_index(), MGCP_CMD_DLCX , 0xFFFF , &mgcpPara); + } + mgc_tandem_info_unset_conn(pTandem,pTandem->pRxconn); + mgc_chnl_info_detach_connect(pTandem->pRxconn->pChnlInfo,pTandem->pRxconn); + mgc_connect_init(pTandem->pRxconn , pTandem->pRxconn->id); + } + + if(pTandem->pTxconn != NULL) + { + if((mgc_connect_get_status(pTandem->pTxconn) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pTandem->pTxconn) == MGC_CONNECT_STATUS_CREATE)) + { + if(mgc_connect_dlcx_para_create(pTandem->pTxconn , &mgcpPara) == TRUE) + MGCP_req(mgc_mgcp_get_sap_index(), MGCP_CMD_DLCX , 0xFFFF , &mgcpPara); + } + mgc_tandem_info_unset_conn(pTandem,pTandem->pTxconn); + mgc_chnl_info_detach_connect(pTandem->pTxconn->pChnlInfo,pTandem->pTxconn); + mgc_connect_init(pTandem->pTxconn , pTandem->pTxconn->id); + } + + pTandem->status = MGC_TANDEM_STATUS_UNDEF; + + + pConn = mgc_tandem_info_get_unattached_conn(); + if(pConn == NULL) + return FALSE; + + if(mgc_tandem_info_set_conn(pTandem, pConn,MGC_TANDEM_CONN_POS_RX) == FALSE) + return FALSE; + + pConn = mgc_tandem_info_get_unattached_conn(); + if(pConn == NULL) + return FALSE; + + if(mgc_tandem_info_set_conn(pTandem, pConn,MGC_TANDEM_CONN_POS_TX) == FALSE) + return FALSE; + + mgc_sur_info_clear_list(&pTandem->list); + mgc_tandem_info_set_status(pTandem,MGC_TANDEM_STATUS_IDLE); + sprintf(pTandem->escci , "%x%lx" , id , time(NULL)); + return TRUE; +} + + +MGC_TANDEM_INFO *mgc_tandem_info_get_tandem_by_id(DWORD id) +{ + if(id >= MGC_MAX_NUM_OF_TANDEM) + return NULL; + + return &mgcTandem[id]; +} + +MGC_TANDEM_INFO *mgc_tandem_info_get_idle_tandem(void) +{ + int i; + static int index = 0; + MGC_TANDEM_INFO *pTandem = NULL; + MGC_TANDEM_INFO *pTandemTmp = NULL; + MG_INFO *pMgInfo = NULL; + + i = index; + do + { + i++; + if(i == MGC_MAX_NUM_OF_TANDEM) + i = 0; + + pTandem = &mgcTandem[i]; + + if(mgc_tandem_info_get_status(pTandem) != MGC_TANDEM_STATUS_IDLE) + continue; + + if(pTandem->pRxconn == NULL) + { + MGC_ERROR("tandem[%d] lost rxConn" , pTandem->id); + continue; + } + + if(pTandem->pTxconn == NULL) + { + MGC_ERROR("tandem[%d] lost txConn" , pTandem->id); + continue; + } + + pMgInfo = mgc_connect_get_own_mg_info(pTandem->pRxconn); + if(pMgInfo == NULL) + continue; + + if(pMgInfo != mgc_connect_get_own_mg_info(pTandem->pTxconn)) + { + MGC_WARN("tandem[%d] txConn and rxConn is not on the same rtpproxy" , pTandem->id); + continue; + } + + if(pMgInfo->enable == FALSE) + continue; + + pTandemTmp = pTandem; + index = i; + break; + + }while(i != index); + + return pTandemTmp; +} + + +void mgc_tandem_info_setup(void) +{ + int i; + CONNECT_INFO *pConn = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + CHNL_INFO *pChnl = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + for(i=0; ichnlNum == 0)&&(pPhyPort->pMgInfo == NULL)) + return pPhyPort; + } + return NULL; +} + + +static CONNECT_INFO *mgc_tandem_info_get_unsed_conn(void) +{ + int i; + CONNECT_INFO *pConnect = NULL; + + for(i=0 ; ipChnlInfo != NULL) + continue; + + return pConnect; + } + + return NULL; +} + + + +static CHNL_INFO *mgc_tandem_info_get_unsed_chnl(void) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + for(i=0 ; istatus != MGC_CHNL_INFO_STATUS_UNDEF) + continue; + + return pChnlInfo; + } + + return NULL; +} + +static BOOL mgc_tandem_info_add_conn_to_chnl(CHNL_INFO *pChnlInfo) +{ + int i; + CONNECT_INFO *pConn = NULL; + + if(pChnlInfo == NULL) + return FALSE; + + for(i=0 ; imaxConnectNum ; i++) + { + pConn = mgc_tandem_info_get_unsed_conn(); + if(pConn == NULL) + return FALSE; + + if(mgc_chnl_info_attach_connect(pChnlInfo, pConn, i) == FALSE) + return FALSE; + } + + return TRUE; +} + + +static BOOL mgc_tandem_info_check_tandem_chnl_conn(CHNL_INFO *pChnlInfo) +{ + int i; + BOOL result = FALSE; + CONNECT_INFO *pConn = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + + if(pChnlInfo == NULL) + return FALSE; + + /*get first attached connection's tandem*/ + for(i=0; imaxConnectNum ; i++) + { + pConn = pChnlInfo->pConnection[i]; + + if(pConn == NULL) + continue; + + result = TRUE; + pTandem = pConn->pTandem; + break; + } + + for(i=0; imaxConnectNum ; i++) + { + pConn = pChnlInfo->pConnection[i]; + + if(pConn == NULL) + continue; + + if(pTandem == pConn->pTandem) + continue; + + result = FALSE; + break; + } + + return result; +} + +static BOOL mgc_tandem_info_add_chnl_to_port(PHY_PORT_INFO *pPhyPort) +{ + int i; + CHNL_INFO *pChnlInfo = NULL; + + if(pPhyPort == NULL) + return FALSE; + + for(i=0 ; ichnlNum ; i++) + { + pChnlInfo = mgc_tandem_info_get_unsed_chnl(); + if(pChnlInfo == NULL) + return FALSE; + + pPhyPort->pChnlInfo[i] = pChnlInfo; + + if(mgc_chnl_info_attach_to_phy_port(pChnlInfo , pPhyPort) == FALSE) + return FALSE; + + if(mgc_tandem_info_add_conn_to_chnl(pChnlInfo) == FALSE) + return FALSE; + + if(mgc_tandem_info_check_tandem_chnl_conn(pChnlInfo) == FALSE) + return FALSE; + + mgc_chnl_info_status_set(pChnlInfo , MGC_CHNL_INFO_STATUS_IDLE); + } + + return TRUE; +} + + + + +static BOOL mgc_tandem_info_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, MGC_PHY_PORT_TYPE portType) +{ + MG_INFO *pMgInfo = NULL; + MGC_SAP *pMgcSap = NULL; + PHY_PORT_INFO *pPhyPort = NULL; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + pMgcSap = mgc_sap_get_index_sap(sapIndex); + + if((pMgcSap == NULL)||(pMgInfo == NULL)) + return FALSE; + + if(pMgInfo->created == FALSE) + return FALSE; + + if(portType!= MGC_PHY_VIRTUAL_TYPE_TANDEM) + return FALSE; + + if(pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + return FALSE; + + pPhyPort = mgc_tandem_info_get_unused_phy_port(); + if(pPhyPort == NULL) + return FALSE; + + pPhyPort->portType = portType; + pPhyPort->portNo = portNo; + pPhyPort->pMgcSap = pMgcSap; + pPhyPort->pMgInfo = pMgInfo; + + switch(pMgInfo->mgAttr.ctrlType) + { + case MGC_MG_CTRL_TYPE_MGCP: + mgc_phy_port_set_chnl_num(pPhyPort , pPhyPort->portType); + break; + default: + mgc_phy_port_clear(pPhyPort); + MGC_ERROR("mgcMgInfo[%d] unsupport ctrl type %d" , pMgInfo->id , pMgInfo->mgAttr.ctrlType); + return FALSE; + } + + if(mgc_tandem_info_add_chnl_to_port(pPhyPort) == FALSE) + { + mgc_phy_port_clear(pPhyPort); + return FALSE; + } + + if(mgc_mg_info_attach_phy_port(pMgInfo , pPhyPort, pMgcSap)== FALSE) + { + mgc_phy_port_clear(pPhyPort); + return FALSE; + } + + return TRUE; +} + + + + + +BOOL mgc_tandem_info_add_tandem_res(BYTE sapIndex, WORD mgNo) +{ + MG_INFO *pMgInfo = NULL; + BOOL result = FALSE; + PHY_PORT_INFO *pPhyPort = NULL; + int i; + + pMgInfo = mgc_mg_info_get_index_mg(mgNo); + + if(pMgInfo == NULL) + return FALSE; + + if(pMgInfo->mgAttr.mgType != MGC_MG_TYPE_TANDEM) + return FALSE; + + pPhyPort = mgc_tandem_info_get_unused_phy_port(); + if(pPhyPort == NULL) + return FALSE; + + for(i=0 ; i< MGC_MAX_PHY_PORT_PER_MG ; i++) + { + if(pMgInfo->pPhyPort[i] != NULL) + continue; + result = TRUE; + break; + } + + + if(result == FALSE) + { + MGC_DEBUG("mg[%d] is full of phyport" , pMgInfo->id); + return FALSE; + } + + if(mgc_tandem_info_add_port(sapIndex, mgNo, i , MGC_PHY_VIRTUAL_TYPE_TANDEM) == FALSE) + return FALSE; + + return TRUE; +} + + +BOOL mgc_tandem_info_create_tandem(MGC_TANDEM_INFO *pTandem , PORT_INFO *pPortInfo) +{ + if((pTandem == NULL) || (pPortInfo == NULL)) + return FALSE; + + if(mgc_connect_get_status(pTandem->pTxconn) == MGC_CONNECT_STATUS_IDLE) + mgc_connect_add_crcx_with_mode(pTandem->pTxconn, MGC_CON_MODE_SENDRECV ,pPortInfo); + + if(mgc_connect_get_status(pTandem->pRxconn) == MGC_CONNECT_STATUS_IDLE) + mgc_connect_add_crcx_with_mode(pTandem->pRxconn, MGC_CON_MODE_RECVONLY,pPortInfo); + + mgc_connect_add_nop(pTandem->pTxconn, pPortInfo); + mgc_tandem_info_set_status(pTandem, MGC_TANDEM_STATUS_USED); + return TRUE; +} + +BOOL mgc_tandem_info_updadte_media(MGC_TANDEM_INFO *pTandem , PORT_INFO *pPortInfo) +{ + CONNECT_INFO *pTarConn = NULL; + CONNECT_INFO *pSurConn = NULL; + MG_INFO *pTarMgInfo = NULL; + MGC_SUR_INFO_NODE *pNode = NULL; + BYTE ptime; + MGC_CODEC_LIST codeclist; + int i; + + if((pTandem == NULL) ||(pPortInfo == NULL)) + return FALSE; + + pTarConn = pTandem->pTconn; + if(mgc_tandem_info_get_conn_pos(pTandem, pTarConn) != MGC_TANDEM_CONN_POS_TAR) + return FALSE; + + pTarMgInfo = mgc_connect_get_own_mg_info(pTarConn); + if(pTarMgInfo == NULL) + return FALSE; + + mgc_connect_codec_list_init(&codeclist); + ptime = 0; + if((mgc_connect_get_status(pTarConn) == MGC_CONNECT_STATUS_CREATED)||(mgc_connect_get_status(pTarConn) == MGC_CONNECT_STATUS_CREATE)) + { + memcpy(&codeclist , &pTarConn->codecList , sizeof(MGC_CODEC_LIST)); + ptime = pTarConn->mediaAttr.ptime; + } + else + { + memcpy(&codeclist , &pTarMgInfo->mgAttr.codecList , sizeof(MGC_CODEC_LIST)); + ptime = pTarMgInfo->mgAttr.ptime; + } + + if(pTandem->pRxconn == NULL) + { + MGC_ERROR("tandem[%d] lost RxConn" , pTandem->id); + return FALSE; + } + + memcpy(&pTandem->pRxconn->codecList , &codeclist, sizeof(MGC_CODEC_LIST)); + pTandem->pRxconn->mediaAttr.ptime = ptime; + + if(pTandem->pTxconn == NULL) + { + MGC_ERROR("tandem[%d] lost TxConn" , pTandem->id); + return FALSE; + } + + memcpy(&pTandem->pTxconn->codecList , &codeclist,sizeof(MGC_CODEC_LIST)); + pTandem->pTxconn->mediaAttr.ptime = ptime; + + for(i=0 ; ilist.len ; i++) + { + pNode = mgc_sur_info_get_list_node(&pTandem->list , i); + if(pNode == NULL) + { + MGC_WARN("tandem[%d] sur_list lost node[%d]" , pTandem->id , i); + continue; + } + + pSurConn = pNode->pConn; + if(pSurConn == NULL) + { + MGC_WARN("tandem[%d] sur_list node[%d] lost surConn " , pTandem->id , i); + continue; + } + + memcpy(&pSurConn->codecList , &codeclist , sizeof(MGC_CODEC_LIST)); + pSurConn->mediaAttr.ptime = ptime; + } + + return TRUE; +} + + +BOOL mgc_tandem_info_create_tar_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + return FALSE; + + mgc_tandem_info_create_tandem(pTandem, pPortInfo); + mgc_tandem_info_updadte_media(pTandem, pPortInfo); + return TRUE; +} + + +BOOL mgc_tandem_info_stop_tar_send_to_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + return FALSE; + + mgc_connect_add_mdcx(pConnect, pTandem->pTxconn, MGC_CON_MODE_RECVONLY, pPortInfo); + MGC_DEBUG("tarConn[%d] stop send stream to tandem[%d]" , pConnect->id , pTandem->id); + return TRUE; +} + + +BOOL mgc_tandem_info_stop_aor_send_to_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_AOR) + return FALSE; + + mgc_connect_add_mdcx(pConnect, pTandem->pRxconn, MGC_CON_MODE_RECVONLY, pPortInfo); + MGC_DEBUG("AorConn[%d] stop send stream to tandem[%d]" , pConnect->id , pTandem->id); + return TRUE; +} + + + +BOOL mgc_tandem_info_stop_tandem_send_to_tar(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + return FALSE; + + mgc_connect_add_mdcx(pTandem->pTxconn, pConnect, MGC_CON_MODE_RECVONLY, pPortInfo); + MGC_DEBUG("tandem[%d] stop send stream to TarConn[%d]" , pTandem->id , pConnect->id); + return TRUE; +} + +BOOL mgc_tandem_info_stop_tandem_send_to_aor(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_AOR) + return FALSE; + + mgc_connect_add_mdcx(pTandem->pRxconn, pConnect, MGC_CON_MODE_RECVONLY, pPortInfo); + MGC_DEBUG("tandem[%d] stop send stream to AorConn[%d]" , pTandem->id , pConnect->id); + return TRUE; +} + + +BOOL mgc_tandem_info_start_tandem_send_to_tar(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + return FALSE; + + mgc_connect_add_mdcx(pConnect, pTandem->pTxconn, MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pTandem->pTxconn, pConnect, MGC_CON_MODE_SENDRECV, pPortInfo); + MGC_DEBUG("tandem[%d] start communication with tar conn[%d]" , pTandem->id , pConnect->id); + return TRUE; +} + + +BOOL mgc_tandem_info_start_tandem_send_to_aor(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return FALSE; + + pTandem = pConnect->pTandem; + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_AOR) + return FALSE; + + mgc_connect_add_mdcx(pConnect, pTandem->pRxconn, MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pTandem->pRxconn, pConnect, MGC_CON_MODE_SENDRECV, pPortInfo); + MGC_DEBUG("tandem[%d] start communication with aor conn[%d]" , pTandem->id , pConnect->id); + return TRUE; +} + + +BOOL mgc_tandem_info_dettach_aor_related_tandem(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo) +{ + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_stop_tandem_send_to_aor(pConnect, pPortInfo) == FALSE) + return FALSE; + + mgc_tandem_info_unset_conn(pConnect->pTandem, pConnect); + } + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_stop_tandem_send_to_aor(pPeerConnect, pPortInfo) == FALSE) + return FALSE; + + mgc_tandem_info_unset_conn(pPeerConnect->pTandem, pPeerConnect); + } + return TRUE; +} + +BOOL mgc_tandem_info_connect_tandem_to_connection(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, MGC_CON_MODE mode , PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + { + MGC_ERROR("conn[%d] is not a target!!" , pConnect->id); + return FALSE; + } + + if(pPeerConnect->pTandem) + { + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem,pPeerConnect) != MGC_TANDEM_CONN_POS_AOR) + { + MGC_ERROR("conn[%d] should not be related to any tandem!" , pPeerConnect->id); + return FALSE; + } + + if(pConnect->pTandem != pPeerConnect->pTandem) + { + MGC_ERROR("conn[%d] and peerConn[%d] should not be called by %s!" , pConnect->id, pPeerConnect->id, __FUNCTION__); + return FALSE; + } + } + + MGC_DEBUG("enter %s" , __FUNCTION__); + pTandem = pConnect->pTandem; + mgc_connect_add_mdcx(pTandem->pTxconn, pConnect, MGC_CON_MODE_SENDRECV , pPortInfo); + mgc_connect_add_mdcx(pTandem->pRxconn , pPeerConnect, MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pConnect,pTandem->pTxconn,mode, pPortInfo); + if(pPeerConnect->pTandem == NULL) + mgc_tandem_info_set_conn(pTandem, pPeerConnect, MGC_TANDEM_CONN_POS_AOR); + + MGC_DEBUG("tandem[%d] connect to conn[%d]" , pTandem->id , pPeerConnect->id); + return TRUE; +} + + +BOOL mgc_tandem_info_connect_tandem_to_tandem(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, MGC_CON_MODE mode , PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + MGC_TANDEM_INFO *pPeerTandem = NULL; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) != MGC_TANDEM_CONN_POS_TAR) + { + MGC_ERROR("conn[%d] is not a target!!" , pConnect->id); + return FALSE; + } + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_TAR) + { + MGC_ERROR("conn[%d] is not a target!!" , pPeerConnect->id); + return FALSE; + } + MGC_DEBUG("enter %s" , __FUNCTION__); + + pTandem = pConnect->pTandem; + pPeerTandem = pPeerConnect->pTandem; + + mgc_connect_add_mdcx(pTandem->pTxconn, pConnect, MGC_CON_MODE_SENDRECV , pPortInfo); + mgc_connect_add_mdcx(pTandem->pRxconn , pPeerTandem->pRxconn , MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pPeerTandem->pRxconn , pTandem->pRxconn , MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pConnect,pTandem->pTxconn,mode, pPortInfo); + MGC_DEBUG("tandem[%d] connect to tandem[%d]" , pTandem->id , pPeerTandem->id); + return TRUE; +} + + +BOOL mgc_tandem_info_connect_connection_to_tandem(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, MGC_CON_MODE mode , PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pPeerTandem = NULL; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + MGC_DEBUG("enter %s" , __FUNCTION__); + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_TAR) + { + MGC_ERROR("conn[%d] is not a target!!" , pPeerConnect->id); + return FALSE; + } + + if(pConnect->pTandem != NULL) + { + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem,pConnect) != MGC_TANDEM_CONN_POS_AOR) + { + MGC_ERROR("conn[%d] should not be related to tandem[%d]!" , pConnect->id , pConnect->pTandem->id); + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + } + + if(pConnect->pTandem != pPeerConnect->pTandem) + { + MGC_ERROR("conn[%d] and peerConn[%d] should not be called by %s!" , pConnect->id, pPeerConnect->id, __FUNCTION__); + return FALSE; + } + } + + pPeerTandem = pPeerConnect->pTandem; + mgc_connect_add_mdcx(pPeerTandem->pRxconn, pConnect, MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pPeerTandem->pTxconn, pPeerConnect , MGC_CON_MODE_SENDRECV, pPortInfo); + mgc_connect_add_mdcx(pConnect, pPeerTandem->pRxconn , mode, pPortInfo); + if(pConnect->pTandem == NULL) + mgc_tandem_info_set_conn(pPeerTandem, pConnect, MGC_TANDEM_CONN_POS_AOR); + + MGC_DEBUG("conn[%d] connect to tandem[%d]" , pConnect->id , pPeerTandem->id); + return TRUE; +} + +BOOL mgc_tandem_info_connect(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, MGC_CON_MODE mode , PORT_INFO *pPortInfo) +{ + MG_INFO *pPeerMgInfo = NULL; + + if((pConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_TAR) + { + if(pConnect->pTandem->pAconn != pPeerConnect) + mgc_tandem_info_remove_connection_from_tandem(pConnect->pTandem->pAconn, pPortInfo); + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_TAR) + { + mgc_tandem_info_connect_tandem_to_tandem(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem,pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + mgc_tandem_info_connect_tandem_to_connection(pConnect, pPeerConnect,mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_UNDEF) + { + mgc_tandem_info_connect_tandem_to_connection(pConnect, pPeerConnect,mode, pPortInfo); + } + else + { + MGC_ERROR("peerConn[%d] is in illegal tandem[%d]!" , pPeerConnect->id, pPeerConnect->pTandem->id); + return FALSE; + } + + return TRUE; + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem,pPeerConnect) == MGC_TANDEM_CONN_POS_TAR) + { + if(pPeerConnect->pTandem != pConnect->pTandem) + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + + if(pPeerConnect->pTandem->pAconn != pConnect) + mgc_tandem_info_remove_connection_from_tandem(pPeerConnect->pTandem->pAconn, pPortInfo); + + mgc_tandem_info_connect_connection_to_tandem(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + mgc_tandem_info_remove_connection_from_tandem(pPeerConnect, pPortInfo); + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_UNDEF) + { + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + } + else + { + MGC_WARN("AorConn[%d] is not rec correct" , pConnect->id); + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + return FALSE; + } + + return TRUE; + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_SUR) + { + mode = MGC_CON_MODE_SENDONLY; + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + MGC_ERROR("surConn[%d] can't connect conn[%d]" , pConnect->id , pPeerConnect->id); + return FALSE; + } + + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + return TRUE; + } + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_UNDEF) + { + + if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_TAR) + { + mgc_tandem_info_remove_connection_from_tandem(pPeerConnect->pTandem->pAconn, pPortInfo); + mgc_tandem_info_connect_connection_to_tandem(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + mgc_tandem_info_remove_connection_from_tandem(pPeerConnect, pPortInfo); + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_SUR) + { + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + } + else if(mgc_tandem_info_get_conn_pos(pPeerConnect->pTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_UNDEF) + { + pPeerMgInfo = mgc_connect_get_own_mg_info(pPeerConnect); + if(pPeerMgInfo == NULL) + return FALSE; + + if((pPeerMgInfo->mgAttr.mgType == MGC_MG_TYPE_INTERNAL)&&(pPeerConnect->mediaAttr.conMode == MGC_CON_MODE_SENDONLY)) + mode = MGC_CON_MODE_RECVONLY; + + mgc_connect_add_mdcx(pConnect, pPeerConnect, mode, pPortInfo); + } + else + { + MGC_ERROR("conn[%d] can't connect conn[%d]" , pConnect->id , pPeerConnect->id); + return FALSE; + } + + return TRUE; + } + + MGC_ERROR("Conn[%d] is in illegal tandem[%d]!" , pConnect->id, pConnect->pTandem->id); + return FALSE; +} + + + +BOOL mgc_tandem_info_add_crcx_aas(CONNECT_INFO *pAasConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo) +{ + CONNECT_INFO *pPeerConn = NULL; + CONNECT_INFO *pConn = NULL; + MGC_TANDEM_INFO *pPeerTandem = NULL; + + if((pAasConnect == NULL)||(pPeerConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + pPeerConn = pPeerConnect; + pConn = pAasConnect; + pPeerTandem = pPeerConnect->pTandem; + + if(pConn->pTandem != NULL) + { + MGC_WARN("aasConn[%d] should not rec any tandem!" , pConn->id); + mgc_tandem_info_remove_connection_from_tandem(pConn, pPortInfo); + mgc_connect_add_dlcx(pConn, pPortInfo); + } + + if(mgc_tandem_info_get_conn_pos(pPeerTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_TAR) + { + if(pPeerConnect->pTandem->pAconn != NULL) + mgc_tandem_info_remove_connection_from_tandem(pPeerTandem->pAconn, pPortInfo); + + mgc_tandem_info_start_tandem_send_to_tar(pPeerConnect, pPortInfo); + pPeerConn = pPeerTandem->pRxconn; + } + else if(mgc_tandem_info_get_conn_pos(pPeerTandem, pPeerConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_get_conn_pos(pPeerTandem, pPeerTandem->pTconn) == MGC_TANDEM_CONN_POS_TAR) + { + mgc_tandem_info_remove_connection_from_tandem(pPeerConnect, pPortInfo); + } + else + { + mgc_tandem_info_start_tandem_send_to_aor(pPeerConnect, pPortInfo); + pPeerConn = pPeerTandem->pTxconn; + } + } + else if(mgc_tandem_info_get_conn_pos(pPeerTandem, pPeerConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + MGC_ERROR("peerConn[%d] is in illegal tandem[%d]!" , pPeerConnect->id, pPeerTandem->id); + return FALSE; + } + + MGC_DEBUG("aasConn[%d] send tone to peerConn[%d]" , pConn->id , pPeerConn->id); + mgc_connect_add_crcx_aas(pConn, pPeerConn, pPortInfo); + return TRUE; +} + + + + +BOOL mgc_tandem_info_add_mdcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pAasConnect, PORT_INFO *pPortInfo) +{ + CONNECT_INFO *pPeerConn = NULL; + CONNECT_INFO *pConn = NULL; + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pAasConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + pPeerConn = pAasConnect; + pConn = pConnect; + pTandem = pConn->pTandem; + + if(pPeerConn->pTandem != NULL) + { + MGC_WARN("aasConn[%d] should not related to any tandem" , pAasConnect->id); + mgc_tandem_info_remove_connection_from_tandem(pPeerConn, pPortInfo); + mgc_connect_add_dlcx(pConnect, pPortInfo); + return FALSE; + } + + if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_TAR) + { + mgc_tandem_info_start_tandem_send_to_tar(pConnect, pPortInfo); + pConn = pTandem->pRxconn; + } + else if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + { + if(mgc_tandem_info_get_conn_pos(pTandem, pTandem->pTconn) == MGC_TANDEM_CONN_POS_TAR) + { + mgc_tandem_info_remove_connection_from_tandem(pConnect, pPortInfo); + } + else + { + mgc_tandem_info_start_tandem_send_to_aor(pConnect, pPortInfo); + pConn = pTandem->pTxconn; + } + } + else if(mgc_tandem_info_get_conn_pos(pTandem, pConnect) != MGC_TANDEM_CONN_POS_UNDEF) + { + MGC_ERROR("Conn[%d] is in illegal tandem[%d]!" , pConnect->id, pTandem->id); + return FALSE; + } + MGC_DEBUG("conn[%d] hear aasConn[%d] " , pConn->id , pPeerConn->id); + mgc_connect_add_mdcx_aas(pConn, pPeerConn, pPortInfo); + return TRUE; +} + + + +BOOL mgc_tandem_info_mdcx(CONNECT_INFO *pConnect , PORT_INFO *pPortInfo) +{ + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_TAR) + mgc_connect_add_mdcx(pConnect, pConnect->pTandem->pTxconn, pConnect->mediaAttr.conMode, pPortInfo); + + if(mgc_tandem_info_get_conn_pos(pConnect->pTandem, pConnect) == MGC_TANDEM_CONN_POS_AOR) + mgc_connect_add_mdcx(pConnect, pConnect->pTandem->pRxconn, pConnect->mediaAttr.conMode, pPortInfo); + + return TRUE; +} + +BOOL mgc_tandem_info_remove_connection_from_tandem(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo) +{ + MGC_TANDEM_INFO *pTandem = NULL; + + if((pConnect == NULL)||(pPortInfo == NULL)) + return FALSE; + + if(pConnect->pTandem == NULL) + return TRUE; + + pTandem = pConnect->pTandem; + switch(mgc_tandem_info_get_conn_pos(pTandem, pConnect)) + { + case MGC_TANDEM_CONN_POS_TAR: + mgc_tandem_info_stop_tandem_send_to_tar(pConnect, pPortInfo); + mgc_tandem_info_stop_tar_send_to_tandem(pConnect, pPortInfo); + mgc_tandem_info_unset_conn(pTandem, pConnect); + break; + case MGC_TANDEM_CONN_POS_AOR: + mgc_tandem_info_stop_tandem_send_to_aor(pConnect, pPortInfo); + mgc_tandem_info_stop_aor_send_to_tandem(pConnect, pPortInfo); + mgc_tandem_info_unset_conn(pTandem, pConnect); + break; + case MGC_TANDEM_CONN_POS_TX: + case MGC_TANDEM_CONN_POS_RX: + MGC_ERROR("tandem[%d] is not allowed remove conn[%d]" , pTandem->id, pConnect->id); + break; + default: + MGC_ERROR("conn[%d] in illegal tandem[%d]", pConnect->id , pConnect->pTandem->id); + return FALSE; + } + return TRUE; +} + +BOOL mgc_tandem_info_clear(MGC_TANDEM_INFO *pTandem, PORT_INFO *pPortInfo) +{ + CONNECT_INFO *pConnect = NULL; + MGC_SUR_INFO_NODE *pNode = NULL; + + + if((pTandem == NULL)||(pPortInfo == NULL)) + return FALSE; + + pNode = mgc_sur_info_get_list_tail(&pTandem->list); + while(pNode != NULL) + { + pConnect = pNode->pConn; + mgc_connect_add_dlcx(pConnect, pPortInfo); + mgc_tandem_info_unset_conn(pTandem, pConnect); + pNode = mgc_sur_info_get_list_tail(&pTandem->list); + } + + mgc_connect_add_dlcx(pTandem->pRxconn, pPortInfo); + mgc_connect_add_dlcx(pTandem->pTxconn, pPortInfo); + mgc_tandem_info_unset_conn(pTandem, pTandem->pAconn); + mgc_tandem_info_unset_conn(pTandem, pTandem->pTconn); + mgc_tandem_info_set_status(pTandem, MGC_TANDEM_STATUS_IDLE); + return TRUE; +} + diff --git a/omc/plat/mgc_v2/ut/.copyarea.db b/omc/plat/mgc_v2/ut/.copyarea.db new file mode 100644 index 0000000..e9c4462 --- /dev/null +++ b/omc/plat/mgc_v2/ut/.copyarea.db @@ -0,0 +1,14 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2\ut +2 +a +4:conf|2|0|0|0|9fc0c6dda0d911dd9cdb001c23e19543|0 +3:obj|2|0|0|0|a950c865a0d911dd9cdb001c23e19543|0 +d:CUnit-Run.xsl|1|11d70a4a4fc|1072|f098c142|9e90c6a5a0d911dd9cdb001c23e19543|0 +b:mgc_v2_test|1|11d70a4a431|e4e69|dadd61f1|9c30c651a0d911dd9cdb001c23e19543|0 +7:include|2|0|0|0|a190c731a0d911dd9cdb001c23e19543|0 +d:CUnit-Run.dtd|1|11d70a4a1ff|596|1d497e8b|9b90c635a0d911dd9cdb001c23e19543|0 +e:CUnit-List.xsl|1|11d70a4a4ae|f87|f6516bae|9d60c689a0d911dd9cdb001c23e19543|0 +8:Makefile|1|11d70a4a52b|b72|2a5d4e7|9f20c6c1a0d911dd9cdb001c23e19543|0 +d:mgc_v2_test.c|1|11d70a4a1d0|bdfe|e603ddac|9b00c619a0d911dd9cdb001c23e19543|0 +e:CUnit-List.dtd|1|11d70a4a460|5bb|ad46941b|9cc0c66da0d911dd9cdb001c23e19543|0 diff --git a/omc/plat/mgc_v2/ut/CUnit-List.dtd b/omc/plat/mgc_v2/ut/CUnit-List.dtd new file mode 100644 index 0000000..4e805ce --- /dev/null +++ b/omc/plat/mgc_v2/ut/CUnit-List.dtd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/omc/plat/mgc_v2/ut/CUnit-List.xsl b/omc/plat/mgc_v2/ut/CUnit-List.xsl new file mode 100644 index 0000000..88f4c63 --- /dev/null +++ b/omc/plat/mgc_v2/ut/CUnit-List.xsl @@ -0,0 +1,119 @@ + + + + + + + CUnit - Logical Test Case Organization in Test Registry + + + + + + + + + +
+

CUnit - A Unit testing framework for C. +
http://cunit.sourceforge.net/

+
+
+ + +

+ + +
+ + + + + + + + + + + + + + +

+

Listing of All Tests

+ + +
+
+ + + + + + + + Suite + + + Initialize Function? + + + Cleanup Function? + + + Test Count + + + + + + + Test Cases + + +
+
+ + +
+ + + + + + + + Suite + + + Initialize Function? + + + Cleanup Function? + + + Test Count + + + + + + + Test Cases + + +
+
+ + +
+ + +

+


+
+ +
+
+ +
diff --git a/omc/plat/mgc_v2/ut/CUnit-Run.dtd b/omc/plat/mgc_v2/ut/CUnit-Run.dtd new file mode 100644 index 0000000..1e92a0a --- /dev/null +++ b/omc/plat/mgc_v2/ut/CUnit-Run.dtd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/omc/plat/mgc_v2/ut/CUnit-Run.xsl b/omc/plat/mgc_v2/ut/CUnit-Run.xsl new file mode 100644 index 0000000..25df483 --- /dev/null +++ b/omc/plat/mgc_v2/ut/CUnit-Run.xsl @@ -0,0 +1,131 @@ + + + + + + + CUnit - All Test Run Summary Report + + + + + + + + + +
+

CUnit - A Unit testing framework for C. +
http://cunit.sourceforge.net/

+
+
+ + + + + + + + + + +
+
+ + + + + + + + + + + Running Suite + + + + + + + + + + + Running Group + + + + + + + + + + Running test ... Passed + + + + + + Running test ... Failed + + + + + + + +
File Name Line Number
Condition
+ + +
+ + + + Running Suite ... + + + + + + + Running Group ... + + + + + +

+ + + + + + + + + + + + + + + + + + +
Cumulative Summary for Run
Type Total Run Succeeded Failed
+ + + +

+


+
+ +
+
+ +
diff --git a/omc/plat/mgc_v2/ut/Makefile b/omc/plat/mgc_v2/ut/Makefile new file mode 100644 index 0000000..0521321 --- /dev/null +++ b/omc/plat/mgc_v2/ut/Makefile @@ -0,0 +1,100 @@ +##----------------------------------------------------------## +## ## +## 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 = mgc_v2_test +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = exef +CFG = debug + + +PLT_LIB = mgcp debug snmp iptrans public sccp mtp3 rtp 8ecp + +APP_LIB = + +LIB_ADD = -lm -lcunit + +SRC_PATH = ./ +INC_PATH = ./ +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- + +include Makefile.rules + diff --git a/omc/plat/mgc_v2/ut/conf/.copyarea.db b/omc/plat/mgc_v2/ut/conf/.copyarea.db new file mode 100644 index 0000000..3980985 --- /dev/null +++ b/omc/plat/mgc_v2/ut/conf/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2\ut\conf +2 +2 +c:iptrans.conf|1|11d70a4a615|227|b33f8c12|a0f0c715a0d911dd9cdb001c23e19543|0 +9:menu_page|1|11d70a4a5e6|2ce|7a7341|a060c6f9a0d911dd9cdb001c23e19543|0 diff --git a/omc/plat/mgc_v2/ut/conf/iptrans.conf b/omc/plat/mgc_v2/ut/conf/iptrans.conf new file mode 100644 index 0000000..e8a9001 --- /dev/null +++ b/omc/plat/mgc_v2/ut/conf/iptrans.conf @@ -0,0 +1,43 @@ +#ipconfig for pps +#port=type,num,interface +#type=UDP/TCP +#num=0-6 +#interface=BUFFER/DIRECT +4950=UDP,6,DIRECT +#SS7 +4952=UDP,3,BUFFER +#MSC +4953=UDP,3,BUFFER +#VLR +4954=UDP,3,BUFFER +#SMSC +4955=UDP,3,BUFFER +#PPS +4956=UDP,3,BUFFER +#DEBUG +4957=UDP,4,BUFFER +#HEARTBEAT +4959=UDP,2,BUFFER +#IWF +4960=UDP,3,BUFFER +#OMC +4965=TCP,3,BUFFER +#DEBUG +4966=UDP,3,DIRECT +#MGCP_SERVER +4967=UDP,3,DIRECT +#MGCP_CLIENT +4968=UDP,2,BUFFER +#MSC GET +4969=UDP,3,BUFFER +#EIR +4970=UDP,3,BUFFER +#HLR +4971=UDP,2,BUFFER +#PPS +4972=UDP,2,BUFFER +#AUC +[port transfer] +4966=2727 +4967=2427 + diff --git a/omc/plat/mgc_v2/ut/conf/menu_page b/omc/plat/mgc_v2/ut/conf/menu_page new file mode 100644 index 0000000..ef995d0 --- /dev/null +++ b/omc/plat/mgc_v2/ut/conf/menu_page @@ -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 -- XUA + f -- MSC s -- BICC + g -- VLR t -- MGC + h -- SSF u -- GCP + i -- HLR v -- 8ECP + j -- SMSC w -- AIF + k -- PPS y -- ISUP + l -- SNMP z -- AAS diff --git a/omc/plat/mgc_v2/ut/include/.copyarea.db b/omc/plat/mgc_v2/ut/include/.copyarea.db new file mode 100644 index 0000000..3d58072 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/.copyarea.db @@ -0,0 +1,14 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgc_v2\ut\include +2 +a +9:CUError.h|1|11d70a4a895|13ee|f8001235|a820c849a0d911dd9cdb001c23e19543|0 +b:Automated.h|1|11d70a4a7bb|800|13be81cf|a5b0c7d9a0d911dd9cdb001c23e19543|0 +7:CUnit.h|1|11d70a4a6d0|494d|7d6cd6ab|a2c0c769a0d911dd9cdb001c23e19543|0 +7:Basic.h|1|11d70a4a78c|7e4|6a018341|a480c7bda0d911dd9cdb001c23e19543|0 +9:TestRun.h|1|11d70a4a73e|21e2|db012d57|a3f0c7a1a0d911dd9cdb001c23e19543|0 +8:TestDB.h|1|11d70a4a838|3dd1|3bd3f2bd|a6e0c811a0d911dd9cdb001c23e19543|0 +9:Console.h|1|11d70a4a7f9|6b2|95fb18d0|a650c7f5a0d911dd9cdb001c23e19543|0 +a:CUCurses.h|1|11d70a4a867|6d1|ac3a22e3|a780c82da0d911dd9cdb001c23e19543|0 +7:MyMem.h|1|11d70a4a70f|1001|e9410e14|a350c785a0d911dd9cdb001c23e19543|0 +6:Util.h|1|11d70a4a692|b83|279b2ab|a220c74da0d911dd9cdb001c23e19543|0 diff --git a/omc/plat/mgc_v2/ut/include/Automated.h b/omc/plat/mgc_v2/ut/include/Automated.h new file mode 100644 index 0000000..933d798 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/Automated.h @@ -0,0 +1,63 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Automated Interface (generates HTML Report Files). + * + * Feb 2002 Initial implementation (AK) + * + * 13/Feb/2002 Single interface to automated_run_tests. (AK) + * + * 20-Jul-2004 New interface, doxygen comments. (JDS) + */ + +/** @file + * Automated testing interface with xml output (user interface). + */ +/** @addtogroup Automated + * @{ + */ + +#ifndef CUNIT_AUTOMATED_H_SEEN +#define CUNIT_AUTOMATED_H_SEEN + +#include "CUnit.h" +#include "TestDB.h" + +#ifdef __cplusplus +extern "C" { +#endif + +CU_EXPORT void CU_automated_run_tests(void); +CU_EXPORT CU_ErrorCode CU_list_tests_to_file(void); +CU_EXPORT void CU_set_output_filename(const char* szFilenameRoot); + +#ifdef USE_DEPRECATED_CUNIT_NAMES +/** Deprecated (version 1). @deprecated Use CU_automated_run_tests(). */ +#define automated_run_tests() CU_automated_run_tests() +/** Deprecated (version 1). @deprecated Use CU_set_output_filename(). */ +#define set_output_filename(x) CU_set_output_filename((x)) +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_AUTOMATED_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/Basic.h b/omc/plat/mgc_v2/ut/include/Basic.h new file mode 100644 index 0000000..516e3fb --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/Basic.h @@ -0,0 +1,61 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2004,2005,2006 Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Interface for simple test runner. + * + * 11-Aug-2004 Initial implementation of basic test runner interface. (JDS) + */ + +/** @file + * Basic interface with output to stdout. + */ +/** @addtogroup Basic + * @{ + */ + +#ifndef CUNIT_BASIC_H_SEEN +#define CUNIT_BASIC_H_SEEN + +#include "CUnit.h" +#include "TestDB.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Run modes for the basic interface. */ +typedef enum { + CU_BRM_NORMAL = 0, /**< Normal mode - failures and run summary are printed [default]. */ + CU_BRM_SILENT, /**< Silent mode - no output is printed except framework error messages. */ + CU_BRM_VERBOSE /**< Verbose mode - maximum output of run details. */ +} CU_BasicRunMode; + +CU_EXPORT CU_ErrorCode CU_basic_run_tests(void); +CU_EXPORT CU_ErrorCode CU_basic_run_suite(CU_pSuite pSuite); +CU_EXPORT CU_ErrorCode CU_basic_run_test(CU_pSuite pSuite, CU_pTest pTest); +CU_EXPORT void CU_basic_set_mode(CU_BasicRunMode mode); +CU_EXPORT CU_BasicRunMode CU_basic_get_mode(void); +CU_EXPORT void CU_basic_show_failures(CU_pFailureRecord pFailure); + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_BASIC_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/CUCurses.h b/omc/plat/mgc_v2/ut/include/CUCurses.h new file mode 100644 index 0000000..02de939 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/CUCurses.h @@ -0,0 +1,61 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains Interface for console Run tests. + * + * Aug 2001 Initial implementation. (AK) + * + * 09/Aug/2001 Single interface to Console_run_tests. (AK) + * + * 18-Jul-2004 New interface. (JDS) + * + * 21-Apr-2005 Changed header name to avoid clash with system curses.h. (JDS) + */ + +/** @file + * Curses testing interface with interactive output (user interface). + */ +/** @addtogroup Curses + * @{ + */ + +#ifndef CUNIT_CURSES_H_SEEN +#define CUNIT_CURSES_H_SEEN + +#include "CUnit.h" +#include "TestDB.h" + +#ifdef __cplusplus +extern "C" { +#endif + +CU_EXPORT void CU_curses_run_tests(void); + +#ifdef USE_DEPRECATED_CUNIT_NAMES +/** Deprecated (version 1). @deprecated Use CU_curses_run_tests(). */ +#define curses_run_tests() CU_curses_run_tests() +#endif + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_CURSES_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/CUError.h b/omc/plat/mgc_v2/ut/include/CUError.h new file mode 100644 index 0000000..e36697a --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/CUError.h @@ -0,0 +1,134 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains CUnit error codes which can be used externally. + * + * Aug 2001 Initial implementation. (AK) + * + * 02/Oct/2001 Added proper Eror Codes. (AK) + * + * 13-Oct-2001 Added Error Codes for Duplicate TestGroup and Test. (AK) + * + * 03-Aug-2004 Converted error code macros to an enum, doxygen comments, moved + * error handing code here, changed file name from Errno.h, added + * error codes for file open errors, added error action selection. (JDS) + * + * 05-Sep-2004 Added internal test interface. (JDS) + */ + +/** @file + * Error handling functions (user interface). + * CUnit uses a simple (and conventional) error handling strategy. + * Functions that can generate errors set (and usually return) an + * error code to indicate the run status. The error code can be + * inspected using the CU_get_error() function. A descriptive + * error message can be retrieved using CU_get_error_msg(). + */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_CUERROR_H_SEEN +#define CUNIT_CUERROR_H_SEEN + +#include + +/*------------------------------------------------------------------------*/ +/** CUnit error codes. + * If codes are added or removed, be sure to make a change to the + * error messages in CUError.c/get_error_desc(). + * @see CU_set_error() + * @see CU_get_error() + * @see CU_get_error_msg() + */ +typedef enum { + /* basic errors */ + CUE_SUCCESS = 0, /**< No error condition. */ + CUE_NOMEMORY = 1, /**< Memory allocation failed. */ + + /* Test Registry Level Errors */ + CUE_NOREGISTRY = 10, /**< Test registry not initialized. */ + CUE_REGISTRY_EXISTS = 11, /**< Attempt to CU_set_registry() without CU_cleanup_registry(). */ + + /* Test Suite Level Errors */ + CUE_NOSUITE = 20, /**< A required CU_pSuite pointer was NULL. */ + CUE_NO_SUITENAME = 21, /**< Required CU_Suite name not provided. */ + CUE_SINIT_FAILED = 22, /**< Suite initialization failed. */ + CUE_SCLEAN_FAILED = 23, /**< Suite cleanup failed. */ + CUE_DUP_SUITE = 24, /**< Duplicate suite name not allowed. */ + + /* Test Case Level Errors */ + CUE_NOTEST = 30, /**< A required CU_pTest pointer was NULL. */ + CUE_NO_TESTNAME = 31, /**< Required CU_Test name not provided. */ + CUE_DUP_TEST = 32, /**< Duplicate test case name not allowed. */ + CUE_TEST_NOT_IN_SUITE = 33, /**< Test not registered in specified suite. */ + + /* File handling errors */ + CUE_FOPEN_FAILED = 40, /**< An error occurred opening a file. */ + CUE_FCLOSE_FAILED = 41, /**< An error occurred closing a file. */ + CUE_BAD_FILENAME = 42, /**< A bad filename was requested (NULL, empty, nonexistent, etc.). */ + CUE_WRITE_ERROR = 43 /**< An error occurred during a write to a file. */ +} CU_ErrorCode; + +/*------------------------------------------------------------------------*/ +/** CUnit error action codes. + * These are used to set the action desired when an error + * condition is detected in the CUnit framework. + * @see CU_set_error_action() + * @see CU_get_error_action() + */ +typedef enum CU_ErrorAction { + CUEA_IGNORE, /**< Runs should be continued when an error condition occurs (if possible). */ + CUEA_FAIL, /**< Runs should be stopped when an error condition occurs. */ + CUEA_ABORT /**< The application should exit() when an error conditions occurs. */ +} CU_ErrorAction; + +/* Error handling & reporting functions. */ + +#include "CUnit.h" + +#ifdef __cplusplus +extern "C" { +#endif + +CU_EXPORT CU_ErrorCode CU_get_error(void); +CU_EXPORT const char* CU_get_error_msg(void); +CU_EXPORT void CU_set_error_action(CU_ErrorAction action); +CU_EXPORT CU_ErrorAction CU_get_error_action(void); + +#ifdef CUNIT_BUILD_TESTS +void test_cunit_CUError(void); +#endif + +/* Internal function - users should not generally call this function */ +void CU_set_error(CU_ErrorCode error); + +#ifdef __cplusplus +} +#endif + +#ifdef USE_DEPRECATED_CUNIT_NAMES +/** Deprecated (version 1). @deprecated Use CU_get_error_msg(). */ +#define get_error() CU_get_error_msg() +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#endif /* CUNIT_CUERROR_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/CUnit.h b/omc/plat/mgc_v2/ut/include/CUnit.h new file mode 100644 index 0000000..6302579 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/CUnit.h @@ -0,0 +1,372 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains ASSERT Macro definitions. + * + * 09/Aug/2001 ASSERT definitions. (AK) + * + * 12/Mar/2003 New Assert definitions. (AK) + * + * 27/Jul/2003 Modified ASSERT_XXX Macro definitions. (AK) + * + * 15-Jul-2004 New interface, changed action on assert failure to not + * return, provided _FATAL versions of assertions to return + * from test function on failure. (JDS) + * + * 01-Sep-2004 Modified assertions for setjmp/longjmp mechanism of + * aborting test runs, added CU_FAIL and CU_PASS macros. (JDS) + * + * 07-May-2005 Added CU_ prefix to remaining CUnit defines (BOOL, TRUE, + * FALSE, MAX_...). Added CU_UNREFERENCED_PARAMETER() define. (JDS) + */ + +/** @file + * Basic CUnit include file for user and system code. + * Defines macros for assertions for use in user test cases. + * Basic system macro definitions also appear here. + */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_CUNIT_H_SEEN +#define CUNIT_CUNIT_H_SEEN + +#include +#include + +/** CUnit version number. */ +#define CU_VERSION "2.1-0" + +/* Max string lengths for names (includes terminating NULL. */ +/** Maximum length of a test name string. */ +#define CU_MAX_TEST_NAME_LENGTH 256 +/** Maximim length of a suite name string. */ +#define CU_MAX_SUITE_NAME_LENGTH 256 + +/* Global type Definitions to be used for boolean operators. */ +#ifndef CU_BOOL + /** Boolean type for CUnit use. */ + #define CU_BOOL int +#endif + +#ifndef CU_TRUE + /** Boolean TRUE for CUnit use. */ + #define CU_TRUE 1 +#endif + +#ifndef CU_FALSE + /** Boolean FALSE for CUnit use. */ + #define CU_FALSE 0 +#endif + +#ifndef CU_UNREFERENCED_PARAMETER + /** Consistent approach to referencing unused parameters. */ + #define CU_UNREFERENCED_PARAMETER(x) (void)x +#endif + +#ifdef WIN32 +# ifdef CU_DLL +# ifdef CU_BUILD_DLL +# define CU_EXPORT __declspec(dllexport) +# else +# define CU_EXPORT __declspec(dllimport) +# endif +# else +# define CU_EXPORT +# endif +#else +# define CU_EXPORT +#endif + +#include "CUError.h" +#include "TestDB.h" /* not needed here - included for user convenience */ +#include "TestRun.h" /* not needed here - include (after BOOL define) for user convenience */ + +/** Record a pass condition without performing a logical test. */ +#define CU_PASS(msg) \ + { CU_assertImplementation(CU_TRUE, __LINE__, ("CU_PASS(" #msg ")"), __FILE__, "", CU_FALSE); } + +/** Simple assertion. + * Reports failure with no other action. + */ +#define CU_ASSERT(value) \ + { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_FALSE); } + +/** Simple assertion. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_FATAL(value) \ + { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_TRUE); } + +/** Simple assertion. + * Reports failure with no other action. + */ +#define CU_TEST(value) \ + { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_FALSE); } + +/** Simple assertion. + * Reports failure and causes test to abort. + */ +#define CU_TEST_FATAL(value) \ + { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_TRUE); } + +/** Record a failure without performing a logical test. */ +#define CU_FAIL(msg) \ + { CU_assertImplementation(CU_FALSE, __LINE__, ("CU_FAIL(" #msg ")"), __FILE__, "", CU_FALSE); } + +/** Record a failure without performing a logical test, and abort test. */ +#define CU_FAIL_FATAL(msg) \ + { CU_assertImplementation(CU_FALSE, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that value is CU_TRUE. + * Reports failure with no other action. + */ +#define CU_ASSERT_TRUE(value) \ + { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE(" #value ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that value is CU_TRUE. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_TRUE_FATAL(value) \ + { CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE_FATAL(" #value ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that value is CU_FALSE. + * Reports failure with no other action. + */ +#define CU_ASSERT_FALSE(value) \ + { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE(" #value ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that value is CU_FALSE. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_FALSE_FATAL(value) \ + { CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE_FATAL(" #value ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that actual == expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_EQUAL(actual, expected) \ + { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that actual == expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that actual != expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_NOT_EQUAL(actual, expected) \ + { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that actual != expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_NOT_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that pointers actual == expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_PTR_EQUAL(actual, expected) \ + { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that pointers actual == expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_PTR_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation(((void*)(actual) == (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that pointers actual != expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_PTR_NOT_EQUAL(actual, expected) \ + { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that pointers actual != expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation(((void*)(actual) != (void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that pointer value is NULL. + * Reports failure with no other action. + */ +#define CU_ASSERT_PTR_NULL(value) \ + { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL(" #value")"), __FILE__, "", CU_FALSE); } + +/** Asserts that pointer value is NULL. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_PTR_NULL_FATAL(value) \ + { CU_assertImplementation((NULL == (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL_FATAL(" #value")"), __FILE__, "", CU_TRUE); } + +/** Asserts that pointer value is not NULL. + * Reports failure with no other action. + */ +#define CU_ASSERT_PTR_NOT_NULL(value) \ + { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", CU_FALSE); } + +/** Asserts that pointer value is not NULL. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_PTR_NOT_NULL_FATAL(value) \ + { CU_assertImplementation((NULL != (void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value")"), __FILE__, "", CU_TRUE); } + +/** Asserts that string actual == expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_STRING_EQUAL(actual, expected) \ + { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that string actual == expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_STRING_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that string actual != expected. + * Reports failure with no other action. + */ +#define CU_ASSERT_STRING_NOT_EQUAL(actual, expected) \ + { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that string actual != expected. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected) \ + { CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that string actual == expected with length specified. + * The comparison is limited to count characters. + * Reports failure with no other action. + */ +#define CU_ASSERT_NSTRING_EQUAL(actual, expected, count) \ + { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that string actual == expected with length specified. + * The comparison is limited to count characters. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count) \ + { CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that string actual != expected with length specified. + * The comparison is limited to count characters. + * Reports failure with no other action. + */ +#define CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) \ + { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that string actual != expected with length specified. + * The comparison is limited to count characters. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count) \ + { CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that double actual == expected within the specified tolerance. + * If actual is within granularity of expected, the assertion passes. + * Reports failure with no other action. + */ +#define CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) \ + { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that double actual == expected within the specified tolerance. + * If actual is within granularity of expected, the assertion passes. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity) \ + { CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_TRUE); } + +/** Asserts that double actual != expected within the specified tolerance. + * If actual is within granularity of expected, the assertion fails. + * Reports failure with no other action. + */ +#define CU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) \ + { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_FALSE); } + +/** Asserts that double actual != expected within the specified tolerance. + * If actual is within granularity of expected, the assertion fails. + * Reports failure and causes test to abort. + */ +#define CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) \ + { CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_TRUE); } + +#ifdef USE_DEPRECATED_CUNIT_NAMES + +#ifndef BOOL + /** Deprecated (version 2.0-2). @deprecated Use CU_BOOL. */ + #define BOOL int +#endif + +#ifndef TRUE + /** Deprecated (version 2.0-2). @deprecated Use CU_TRUE. */ + #define TRUE 1 +#endif + +#ifndef FALSE + /** Deprecated (version 2.0-2). @deprecated Use CU_FALSE. */ + #define FALSE 0 +#endif + +/** Deprecated (version 2.0-2). @deprecated Use CU_MAX_TEST_NAME_LENGTH. */ +#define MAX_TEST_NAME_LENGTH 256 +/** Deprecated (version 2.0-2). @deprecated Use CU_MAX_SUITE_NAME_LENGTH. */ +#define MAX_SUITE_NAME_LENGTH 256 + +/** Deprecated (version 1). @deprecated Use CU_ASSERT_FATAL. */ +#define ASSERT(value) { if (FALSE == (int)(value)) { CU_assertImplementation((BOOL)value, __LINE__, #value, __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_TRUE_FATAL. */ +#define ASSERT_TRUE(value) { if (FALSE == (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_TRUE(" #value ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_FALSE_FATAL. */ +#define ASSERT_FALSE(value) { if (FALSE != (value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_FALSE(" #value ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_EQUAL_FATAL. */ +#define ASSERT_EQUAL(actual, expected) { if ((actual) != (expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_NOT_EQUAL_FATAL. */ +#define ASSERT_NOT_EQUAL(actual, expected) { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_PTR_EQUAL_FATAL. */ +#define ASSERT_PTR_EQUAL(actual, expected) { if ((void*)(actual) != (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_PTR_NOT_EQUAL_FATAL. */ +#define ASSERT_PTR_NOT_EQUAL(actual, expected) { if ((void*)(actual) == (void*)(expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_PTR_NULL_FATAL. */ +#define ASSERT_PTR_NULL(value) { if (NULL != (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NULL(" #value")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_PTR_NOT_NULL_FATAL. */ +#define ASSERT_PTR_NOT_NULL(value) { if (NULL == (void*)(value)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_STRING_EQUAL_FATAL. */ +#define ASSERT_STRING_EQUAL(actual, expected) { if (strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_STRING_NOT_EQUAL_FATAL. */ +#define ASSERT_STRING_NOT_EQUAL(actual, expected) { if (!strcmp((const char*)actual, (const char*)expected)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_NSTRING_EQUAL_FATAL. */ +#define ASSERT_NSTRING_EQUAL(actual, expected, count) { if (strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_NSTRING_NOT_EQUAL_FATAL. */ +#define ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) { if (!strncmp((const char*)actual, (const char*)expected, (size_t)count)) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_DOUBLE_EQUAL_FATAL. */ +#define ASSERT_DOUBLE_EQUAL(actual, expected, granularity) { if ((fabs((double)actual - expected) > fabs((double)granularity))) { CU_assertImplementation(FALSE, __LINE__, ("ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }} +/** Deprecated (version 1). @deprecated Use CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL. */ +#define ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) { if ((fabs((double)actual - expected) <= fabs((double)granularity))) { CU_assertImplementation(TRUE, __LINE__, ("ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", FALSE); return; }} +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#endif /* CUNIT_CUNIT_H_SEEN */ + +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/Console.h b/omc/plat/mgc_v2/ut/include/Console.h new file mode 100644 index 0000000..b21cdd7 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/Console.h @@ -0,0 +1,59 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains Interface for console Run tests. + * + * Aug 2001 Initial implementation. (AK) + * + * 09/Aug/2001 Single interface to Console_run_tests. (AK) + * + * 20-Jul-2004 New interface, doxygen comments. (JDS) + */ + +/** @file + * Console interface with interactive output (user interface). + */ +/** @addtogroup Console + * @{ + */ + +#ifndef CUNIT_CONSOLE_H_SEEN +#define CUNIT_CONSOLE_H_SEEN + +#include "CUnit.h" +#include "TestDB.h" + +#ifdef __cplusplus +extern "C" { +#endif + +CU_EXPORT void CU_console_run_tests(void); + +#ifdef USE_DEPRECATED_CUNIT_NAMES +/** Deprecated (version 1). @deprecated Use CU_console_run_tests(). */ +#define console_run_tests() CU_console_run_tests() +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_CONSOLE_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/MyMem.h b/omc/plat/mgc_v2/ut/include/MyMem.h new file mode 100644 index 0000000..e636a58 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/MyMem.h @@ -0,0 +1,104 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains Memory Related Defines to use internal routines to detect Memory Leak + * in Debug Versions + * + * 18/Jun/2002 Memory Debug Functions. (AK) + * + * 17-Jul-2004 New interface for global function names. (JDS) + * + * 05-Sep-2004 Added internal test interface. (JDS) + */ + +/** @file + * Memory management functions (user interface). + * Two versions of memory allocation/deallocation are available. + * If compiled with MEMTRACE defined, CUnit keeps track of all + * system allocations & deallocations. The memory record can + * then be reported using CU_CREATE_MEMORY_REPORT. Otherwise, + * standard system memory allocation is used without tracing. + */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_MYMEM_H_SEEN +#define CUNIT_MYMEM_H_SEEN + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MEMTRACE + void* CU_calloc(size_t nmemb, size_t size, unsigned int uiLine, const char* szFileName); + void* CU_malloc(size_t size, unsigned int uiLine, const char* szFileName); + void CU_free(void *ptr, unsigned int uiLine, const char* szFileName); + void* CU_realloc(void *ptr, size_t size, unsigned int uiLine, const char* szFileName); + CU_EXPORT void CU_dump_memory_usage(const char*); + + /** c-allocate with memory tracking. */ + #define CU_CALLOC(x, y) CU_calloc((x), (y), __LINE__, __FILE__) + /** m-allocate with memory tracking. */ + #define CU_MALLOC(x) CU_malloc((x), __LINE__, __FILE__) + /** Free with memory tracking. */ + #define CU_FREE(x) CU_free((x), __LINE__, __FILE__) + /** Reallocate with memory tracking. */ + #define CU_REALLOC(x, y) CU_realloc((x), (y), __LINE__, __FILE__) + /** Generate report on tracked memory. */ + #define CU_CREATE_MEMORY_REPORT(x) CU_dump_memory_usage((x)) + /** Generate report on tracked memory (old macro). */ + #define CU_DUMP_MEMORY_USAGE(x) CU_dump_memory_usage((x)) +#else /* MEMTRACE */ + /** Standard calloc() if MEMTRACE not defined. */ + #define CU_CALLOC(x, y) calloc((x), (y)) + /** Standard malloc() if MEMTRACE not defined. */ + #define CU_MALLOC(x) malloc((x)) + /** Standard free() if MEMTRACE not defined. */ + #define CU_FREE(x) free((x)) + /** Standard realloc() if MEMTRACE not defined. */ + #define CU_REALLOC(x, y) realloc((x), (y)) + /** No-op if MEMTRACE not defined. */ + #define CU_CREATE_MEMORY_REPORT(x) + /** No-op if MEMTRACE not defined. */ + #define CU_DUMP_MEMORY_USAGE(x) +#endif /* MEMTRACE */ + +#ifdef CUNIT_BUILD_TESTS +/** Disable memory allocation for testing purposes. */ +void test_cunit_deactivate_malloc(void); +/** Enable memory allocation for testing purposes. */ +void test_cunit_activate_malloc(void); +/** Retrieve number of memory events for a given pointer */ +unsigned int test_cunit_get_n_memevents(void* pLocation); +/** Retrieve number of allocations for a given pointer */ +unsigned int test_cunit_get_n_allocations(void* pLocation); +/** Retrieve number of deallocations for a given pointer */ +unsigned int test_cunit_get_n_deallocations(void* pLocation); + +void test_cunit_MyMem(void); +#endif /* CUNIT_BUILD_TESTS */ + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_MYMEM_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/TestDB.h b/omc/plat/mgc_v2/ut/include/TestDB.h new file mode 100644 index 0000000..2acbc61 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/TestDB.h @@ -0,0 +1,357 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains all the Type Definitions and functions declarations + * for the CUnit test database maintenance. + * + * Aug 2001 Initial implementation. (AK) + * + * 09/Aug/2001 Added Preprocessor conditionals for the file. (AK) + * + * 24/aug/2001 Made the linked list from SLL to DLL(doubly linked list). (AK) + * + * 31-Aug-2004 Restructured to eliminate global variables error_number, + * g_pTestRegistry; new interface, support for deprecated + * version 1 interface, moved error handling code to + * CUError.[ch], moved test run counts and _TestResult out + * of TestRegistry to TestRun.h. (JDS) + * + * 01-Sep-2004 Added jmp_buf to CU_Test. (JDS) + * + * 05-Sep-2004 Added internal test interface. (JDS) + */ + +/** @file + * Management functions for tests, suites, and the test registry (user interface). + * Unit testing in CUnit follows the standard structure of unit + * tests aggregated in suites, which are themselves aggregated + * in a test registry. This module provides functions and + * typedef's to support the creation, registration, and manipulation + * of test cases, suites, and the registry. + */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_TESTDB_H_SEEN +#define CUNIT_TESTDB_H_SEEN + +#include /* jmp_buf */ + +#include "CUnit.h" +#include "CUError.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type definition for Initialization/Cleaup/TestFunction */ +typedef int (*CU_InitializeFunc)(void); /**< Signature for suite initialization function. */ +typedef int (*CU_CleanupFunc)(void); /**< Signature for suite cleanup function. */ +typedef void (*CU_TestFunc)(void); /**< Signature for a testing function in a test case. */ + +/** CUnit test case data type. + * CU_Test is a linked list of unit tests. Each test + * has a name and a callable test function, as well as + * links to the next and previous tests in the list. A + * test also holds a jmp_buf reference for use in + * implementing fatal assertions. + *

+ * Generally, the linked list includes tests which are + * associated with each other in a CU_Suite. As a result, + * tests are run in the order in which they are added to a + * suite (see CU_add_test()). + *

+ * In the current implementation, the name of each CU_Test + * in a suite must have a unique name. There is no + * restriction on the test function. This means that the + * same function could, in principle, be called more than + * once as long as it is registered with different tests + * having distinct names. + * @see CU_Suite + * @see CU_TestRegistry + */ +typedef struct CU_Test +{ + char* pName; /**< Test name. */ + CU_TestFunc pTestFunc; /**< Pointer to the test function. */ + jmp_buf* pJumpBuf; /**< Jump buffer for setjmp/longjmp test abort mechanism. */ + + struct CU_Test* pNext; /**< Pointer to the next test in linked list. */ + struct CU_Test* pPrev; /**< Pointer to the previous test in linked list. */ + +} CU_Test; +typedef CU_Test* CU_pTest; /**< Pointer to a CUnit test case. */ + +/** CUnit suite data type. + * CU_Suite is a linked list of CU_Test containers. + * Each suite has a name and count of associated unit + * tests. It also holds a pointer to optional + * initialization and cleanup functions. If non-NULL, + * these are called before and after running the suite's + * tests, respectively. In addition, the suite holds a + * pointer to the head of the linked list of associated + * CU_Test objects. Finally, pointers to the next and + * previous suites in the linked list are maintained. + *

+ * Generally, the linked list includes suites which are + * associated with each other in a CU_TestRegistry. As a + * result, suites are run in the order in which they are + * registered (see CU_add_suite()). + *

+ * In the current implementation, the name of each CU_Suite + * in a test registry must have a unique name. There is no + * restriction on the contained tests. This means that the + * same CU_Test could, in principle, be run more than + * once as long as it is registered with different suites + * having distinct names. + * @see CU_Test + * @see CU_TestRegistry + */ +typedef struct CU_Suite +{ + char* pName; /**< Suite name. */ + CU_pTest pTest; /**< Pointer to the 1st test in the suite. */ + CU_InitializeFunc pInitializeFunc; /**< Pointer to the suite initialization function. */ + CU_CleanupFunc pCleanupFunc; /**< Pointer to the suite cleanup function. */ + + unsigned int uiNumberOfTests; /**< Number of tests in the suite. */ + struct CU_Suite* pNext; /**< Pointer to the next suite in linked list. */ + struct CU_Suite* pPrev; /**< Pointer to the previous suite in linked list. */ + +} CU_Suite; +typedef CU_Suite* CU_pSuite; /**< Pointer to a CUnit suite. */ + +/** CUnit test registry data type. + * CU_TestRegisty is the repository for suites containing + * unit tests. The test registry maintains a count of the + * number of CU_Suite objects contained in the registry, as + * well as a count of the total number of CU_Test objects + * associated with those suites. It also holds a pointer + * to the head of the linked list of CU_Suite objects. + *

+ * With this structure, the user will normally add suites + * implictly to the internal test registry using CU_add_suite(), + * and then add tests to each suite using CU_add_test(). + * Test runs are then initiated using one of the appropriate + * functions in TestRun.c via one of the interfaces. + *

+ * Automatic creation and destruction of the internal registry + * and its objects is available using CU_initialize_registry() + * and CU_cleanup_registry(), respectively. For internal and + * testing purposes, the internal registry can be retrieved and + * assigned. Functions are also provided for creating and + * destroying independent registries. + *

+ * Note that earlier versions of CUnit also contained a + * pointer to a linked list of CU_FailureRecord objects + * (termed _TestResults). This has been removed from the + * registry and relocated to TestRun.c. + * @see CU_Test + * @see CU_Suite + * @see CU_initialize_registry() + * @see CU_cleanup_registry() + * @see CU_get_registry() + * @see CU_set_registry() + * @see CU_create_new_registry() + * @see CU_destroy_existing_registry() + */ +typedef struct CU_TestRegistry +{ +#ifdef USE_DEPRECATED_CUNIT_NAMES + /** Union to support v1.1-1 member name. */ + union { + unsigned int uiNumberOfSuites; /**< Number of suites in the test registry. */ + unsigned int uiNumberOfGroups; /**< Deprecated (version 1). @deprecated Use uiNumberOfSuites. */ + }; + unsigned int uiNumberOfTests; /**< Number of tests in the test registry. */ + /** Union to support v1.1-1 member name. */ + union { + CU_pSuite pSuite; /**< Pointer to the 1st suite in the test registry. */ + CU_pSuite pGroup; /**< Deprecated (version 1). @deprecated Use pSuite. */ + }; +#else + unsigned int uiNumberOfSuites; /**< Number of suites in the test registry. */ + unsigned int uiNumberOfTests; /**< Number of tests in the test registry. */ + CU_pSuite pSuite; /**< Pointer to the 1st suite in the test registry. */ +#endif +} CU_TestRegistry; +typedef CU_TestRegistry* CU_pTestRegistry; /**< Pointer to a CUnit test registry. */ + +/* Public interface functions */ +CU_EXPORT CU_ErrorCode CU_initialize_registry(void); +CU_EXPORT void CU_cleanup_registry(void); +CU_EXPORT CU_BOOL CU_registry_initialized(void); + +CU_EXPORT CU_pSuite CU_add_suite(const char* strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean); +CU_EXPORT CU_pTest CU_add_test(CU_pSuite pSuite, const char* strName, CU_TestFunc pTestFunc); + +/** Shortcut macro for adding a test to a suite. */ +#define CU_ADD_TEST(suite, test) (CU_add_test(suite, #test, (CU_TestFunc)test)) + +/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ +/* This section is based conceptually on code + * Copyright (C) 2004 Aurema Pty Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Derived from code contributed by K. Cheung and Aurema Pty Ltd. (thanks!) + * test_case_t, test_group_t, test_suite_t + */ + +/** Test case parameters. + * This data type is provided to assist CUnit users + * manage collections of test and suites. It is + * intended to be used to build arrays of test case + * parameters that can be then be referred to in + * a CU_suite_info_t variable. + */ +typedef struct CU_TestInfo { + char *pName; /**< Test name. */ + CU_TestFunc pTestFunc; /**< Test function. */ +} CU_TestInfo; +typedef CU_TestInfo* CU_pTestInfo; /**< Pointer to CU_TestInfo type. */ + +/** Suite parameters. + * This data type is provided to assist CUnit users + * manage collections of test and suites. It is + * intended to be used to build arrays of suite + * parameters that can be passed to a bulk registration + * function such as CU_register_suite() or + * CU_register_suites(). + */ +typedef struct CU_SuiteInfo { + char *pName; /**< Suite name. */ + CU_InitializeFunc pInitFunc; /**< Suite initialization function. */ + CU_CleanupFunc pCleanupFunc; /**< Suite cleanup function */ + CU_TestInfo *pTests; /**< Test case array - must be NULL terminated. */ +} CU_SuiteInfo; +typedef CU_SuiteInfo* CU_pSuiteInfo; /**< Pointer to CU_SuiteInfo type. */ + +/** NULL CU_test_info_t to terminate arrays of tests. */ +#define CU_TEST_INFO_NULL { NULL, NULL } +/** NULL CU_suite_info_t to terminate arrays of suites. */ +#define CU_SUITE_INFO_NULL { NULL, NULL, NULL, NULL } + +CU_EXPORT CU_ErrorCode CU_register_suites(CU_SuiteInfo suite_info[]); +CU_EXPORT CU_ErrorCode CU_register_nsuites(int suite_count, ...); + +#ifdef USE_DEPRECATED_CUNIT_NAMES +typedef CU_TestInfo test_case_t; /**< Deprecated (version 1). @deprecated Use CU_TestInfo. */ +typedef CU_SuiteInfo test_group_t; /**< Deprecated (version 1). @deprecated Use CU_SuiteInfo. */ + +/** Deprecated (version 1). @deprecated Use CU_SuiteInfo and CU_TestInfo. */ +typedef struct test_suite { + char *name; /**< Suite name. Currently not used. */ + test_group_t *groups; /**< Test groups. This must be a NULL terminated array. */ +} test_suite_t; + +/** Deprecated (version 1). @deprecated Use CU_TEST_INFO_NULL. */ +#define TEST_CASE_NULL { NULL, NULL } +/** Deprecated (version 1). @deprecated Use CU_TEST_GROUP_NULL. */ +#define TEST_GROUP_NULL { NULL, NULL, NULL, NULL } + +/** Deprecated (version 1). @deprecated Use CU_register_suites(). */ +#define test_group_register(tg) CU_register_suites(tg) + +/** Deprecated (version 1). @deprecated Use CU_SuiteInfo and CU_register_suites(). */ +CU_EXPORT int test_suite_register(test_suite_t *ts) +{ + test_group_t *tg; + int error; + + for (tg = ts->groups; tg->pName; tg++) + if ((error = CU_register_suites(tg)) != CUE_SUCCESS) + return error; + + return CUE_SUCCESS; +} +#endif /* USE_DEPRECATED_CUNIT_NAMES */ +/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ + +#ifdef USE_DEPRECATED_CUNIT_NAMES +typedef CU_InitializeFunc InitializeFunc; /**< Deprecated (version 1). @deprecated Use CU_InitializeFunc. */ +typedef CU_CleanupFunc CleanupFunc; /**< Deprecated (version 1). @deprecated Use CU_CleanupFunc. */ +typedef CU_TestFunc TestFunc; /**< Deprecated (version 1). @deprecated Use CU_TestFunc. */ + +typedef CU_Test _TestCase; /**< Deprecated (version 1). @deprecated Use CU_Test. */ +typedef CU_pTest PTestCase; /**< Deprecated (version 1). @deprecated Use CU_pTest. */ + +typedef CU_Suite _TestGroup; /**< Deprecated (version 1). @deprecated Use CU_Suite. */ +typedef CU_pSuite PTestGroup; /**< Deprecated (version 1). @deprecated Use CU_pSuite. */ + +typedef CU_TestRegistry _TestRegistry; /**< Deprecated (version 1). @deprecated Use CU_TestRegistry. */ +typedef CU_pTestRegistry PTestRegistry; /**< Deprecated (version 1). @deprecated Use CU_pTestRegistry. */ + +/* Public interface functions */ +/** Deprecated (version 1). @deprecated Use CU_initialize_registry(). */ +#define initialize_registry() CU_initialize_registry() +/** Deprecated (version 1). @deprecated Use CU_cleanup_registry(). */ +#define cleanup_registry() CU_cleanup_registry() +/** Deprecated (version 1). @deprecated Use CU_add_suite(). */ +#define add_test_group(name, init, clean) CU_add_suite(name, init, clean) +/** Deprecated (version 1). @deprecated Use CU_add_test(). */ +#define add_test_case(group, name, test) CU_add_test(group, name, test) + +/* private internal CUnit testing functions */ +/** Deprecated (version 1). @deprecated Use CU_get_registry(). */ +#define get_registry() CU_get_registry() +/** Deprecated (version 1). @deprecated Use CU_set_registry(). */ +#define set_registry(reg) CU_set_registry((reg)) + +/** Deprecated (version 1). @deprecated Use CU_get_suite_by_name(). */ +#define get_group_by_name(group, reg) CU_get_suite_by_name(group, reg) +/** Deprecated (version 1). @deprecated Use CU_get_test_by_name(). */ +#define get_test_by_name(test, group) CU_get_test_by_name(test, group) + +/** Deprecated (version 1). @deprecated Use ADD_TEST_TO_SUITE. */ +#define ADD_TEST_TO_GROUP(group, test) (CU_add_test(group, #test, (CU_TestFunc)test)) +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +/* Internal CUnit system functions. Should not be routinely called by users. */ +CU_EXPORT CU_pTestRegistry CU_get_registry(void); +CU_EXPORT CU_pTestRegistry CU_set_registry(CU_pTestRegistry pTestRegistry); +CU_EXPORT CU_pTestRegistry CU_create_new_registry(void); +CU_EXPORT void CU_destroy_existing_registry(CU_pTestRegistry* ppRegistry); +CU_EXPORT CU_pSuite CU_get_suite_by_name(const char* szSuiteName, CU_pTestRegistry pRegistry); +CU_EXPORT CU_pTest CU_get_test_by_name(const char* szTestName, CU_pSuite pSuite); + +#ifdef CUNIT_BUILD_TESTS +void test_cunit_TestDB(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_TESTDB_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/TestRun.h b/omc/plat/mgc_v2/ut/include/TestRun.h new file mode 100644 index 0000000..30cea12 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/TestRun.h @@ -0,0 +1,193 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains Interface to Run tests. + * + * Aug 2001 Initial implementation. (AK) + * + * 09/Aug/2001 Contains generic run tests interface which can be used + * for any type of frontend interface framework. (AK) + * + * 24/Nov/2001 Added Handler for Group Initialization failure condition. (AK) + * + * 05-Aug-2004 New interface. Since these should be internal functions, + * no support for deprecated version 1 names provided now, + * eliminated global variables for current test & suite, + * moved (renamed) _TestResult here from TestDB.h. (JDS) + * + * 05-Sep-2004 Added internal test interface. (JDS) + */ + +/** @file + * Test run management functions (user interface). + * The TestRun module implements functions supporting the running + * of tests elements (suites and tests). This includes functions for + * running suites and tests, retrieving the number of tests/suites run, + * and managing callbacks during the run process. + * + *

The callback mechanism works as follows. The CUnit runtime system + * supports the registering and calling of functions at the start and end + * of each test, when all tests are complete, and when a suite + * initialialization function returns an error. This allows clients to + * perform actions associated with these events such as output formatting + * and reporting.

+ */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_TESTRUN_H_SEEN +#define CUNIT_TESTRUN_H_SEEN + +#include "CUnit.h" +#include "CUError.h" +#include "TestDB.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* CU_FailureRecord type definition. */ +/** Data type for holding assertion failure information (linked list). */ +typedef struct CU_FailureRecord +{ + unsigned int uiLineNumber; /**< Line number of failure. */ + char* strFileName; /**< Name of file where failure occurred. */ + char* strCondition; /**< Test condition which failed. */ + CU_pTest pTest; /**< Test containing failure. */ + CU_pSuite pSuite; /**< Suite containing test having failure. */ + + struct CU_FailureRecord* pNext; /**< Pointer to next record in linked list. */ + struct CU_FailureRecord* pPrev; /**< Pointer to previous record in linked list. */ + +} CU_FailureRecord; +typedef CU_FailureRecord* CU_pFailureRecord; /**< Pointer to CU_FailureRecord. */ + +/* CU_RunSummary type definition. */ +/** Data type for holding statistics and assertion failures for a test run. */ +typedef struct CU_RunSummary +{ + unsigned int nSuitesRun; /**< Number of suites completed during run. */ + unsigned int nSuitesFailed; /**< Number of suites for which initialization failed. */ + unsigned int nTestsRun; /**< Number of tests completed during run. */ + unsigned int nTestsFailed; /**< Number of tests containing failed assertions. */ + unsigned int nAsserts; /**< Number of assertions tested during run. */ + unsigned int nAssertsFailed; /**< Number of failed assertions. */ + unsigned int nFailureRecords; /**< Number of failure records generated. */ +} CU_RunSummary; +typedef CU_RunSummary* CU_pRunSummary; /**< Pointer to CU_RunSummary. */ + +/* Type Definitions for Message Handlers. */ +/** Message handler called at the start of a test. + * The parameters are the test and suite being run. + * The test run is considered in progress when the + * message handler is called. Neither pTest nor + * pSuite may be null. + */ +typedef void (*CU_TestStartMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite); +/** Message handler called at the completion of a test. + * The parameters are the test and suite being run, plus + * a pointer to the first failure record applicable to + * this test. If the test did not have any assertion + * failures, pFailure will be NULL. + * The test run is considered in progress when the + * message handler is called. + */ +typedef void (*CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite, + const CU_pFailureRecord pFailure); +/** Message handler called at the completion of a test run. + * The parameter is a pointer to the linked list holding + * the failure records for the test run. + * The test run is considered completed when the + * message handler is called. + */ +typedef void (*CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure); + +/** Message handler called when a suite initializer fails. + * The test run is considered in progress when the + * message handler is called. + */ +typedef void (*CU_SuiteInitFailureMessageHandler)(const CU_pSuite pSuite); + +/** Message handler called when a suite cleanup function fails. + * The test run is considered in progress when the + * message handler is called. + */ +typedef void (*CU_SuiteCleanupFailureMessageHandler)(const CU_pSuite pSuite); + +/* Get/Set functions for Message Handlers. */ +CU_EXPORT void CU_set_test_start_handler(CU_TestStartMessageHandler pTestStartMessage); +CU_EXPORT void CU_set_test_complete_handler(CU_TestCompleteMessageHandler pTestCompleteMessage); +CU_EXPORT void CU_set_all_test_complete_handler(CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage); +CU_EXPORT void CU_set_suite_init_failure_handler(CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage); +CU_EXPORT void CU_set_suite_cleanup_failure_handler(CU_SuiteCleanupFailureMessageHandler pSuiteCleanupFailureMessage); + +CU_EXPORT CU_TestStartMessageHandler CU_get_test_start_handler(void); +CU_EXPORT CU_TestCompleteMessageHandler CU_get_test_complete_handler(void); +CU_EXPORT CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void); +CU_EXPORT CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void); +CU_EXPORT CU_SuiteCleanupFailureMessageHandler CU_get_suite_cleanup_failure_handler(void); + +/* Functions for running registered tests and suites. */ +CU_EXPORT CU_ErrorCode CU_run_all_tests(void); +CU_EXPORT CU_ErrorCode CU_run_suite(CU_pSuite pSuite); +CU_EXPORT CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest); + +/* Functions for getting information about the previous test run. */ +CU_EXPORT unsigned int CU_get_number_of_suites_run(void); +CU_EXPORT unsigned int CU_get_number_of_suites_failed(void); +CU_EXPORT unsigned int CU_get_number_of_tests_run(void); +CU_EXPORT unsigned int CU_get_number_of_tests_failed(void); +CU_EXPORT unsigned int CU_get_number_of_asserts(void); +CU_EXPORT unsigned int CU_get_number_of_successes(void); +CU_EXPORT unsigned int CU_get_number_of_failures(void); +CU_EXPORT unsigned int CU_get_number_of_failure_records(void); +CU_EXPORT CU_pFailureRecord CU_get_failure_list(void); +CU_EXPORT CU_pRunSummary CU_get_run_summary(void); + +/* Functions for internal & testing use. */ +CU_EXPORT CU_pSuite CU_get_current_suite(void); +CU_EXPORT CU_pTest CU_get_current_test(void); +CU_EXPORT CU_BOOL CU_is_test_running(void); +CU_EXPORT void CU_clear_previous_results(void); + +/* Assertion implementation function. */ +CU_EXPORT CU_BOOL CU_assertImplementation(CU_BOOL bValue, + unsigned int uiLine, + char strCondition[], + char strFile[], + char strFunction[], + CU_BOOL bFatal); + +#ifdef USE_DEPRECATED_CUNIT_NAMES +typedef CU_FailureRecord _TestResult; /**< @deprecated Use CU_FailureRecord. */ +typedef CU_pFailureRecord PTestResult; /**< @deprecated Use CU_pFailureRecord. */ +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#ifdef CUNIT_BUILD_TESTS +void test_cunit_TestRun(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* CUNIT_TESTRUN_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/include/Util.h b/omc/plat/mgc_v2/ut/include/Util.h new file mode 100644 index 0000000..201f8a1 --- /dev/null +++ b/omc/plat/mgc_v2/ut/include/Util.h @@ -0,0 +1,87 @@ +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Contains Type Definitions for some generic functions used across + * CUnit project files. + * + * 13/Oct/2001 Moved some of the generic functions declarations from + * other files to this one so as to use the functions + * consitently. This file is not included in the distribution + * headers because it is used internally by CUnit. (AK) + * + * 20-Jul-2004 New interface, support for deprecated version 1 names. (JDS) + * + * 5-Sep-2004 Added internal test interface. (JDS) + */ + +/** @file + * Utility functions (user interface). + */ +/** @addtogroup Framework + * @{ + */ + +#ifndef CUNIT_UTIL_H_SEEN +#define CUNIT_UTIL_H_SEEN + +#include "CUnit.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Maximum string length. */ +#define CUNIT_MAX_STRING_LENGTH 1024 +/** maximum number of characters in a translated xml entity. */ +#define CUNIT_MAX_ENTITY_LEN 5 + +CU_EXPORT int CU_translate_special_characters(const char* szSrc, char* szDest, size_t maxlen); +CU_EXPORT int CU_compare_strings(const char* szSrc, const char* szDest); + +CU_EXPORT void CU_trim_left(char* szString); +CU_EXPORT void CU_trim_right(char* szString); +CU_EXPORT void CU_trim(char* szString); + +#ifdef CUNIT_BUILD_TESTS +void test_cunit_Util(void); +#endif + +#ifdef __cplusplus +} +#endif + +#ifdef USE_DEPRECATED_CUNIT_NAMES +/** Deprecated (version 1). @deprecated Use CU_translate_special_characters(). */ +#define translate_special_characters(src, dest, len) CU_translate_special_characters(src, dest, len) +/** Deprecated (version 1). @deprecated Use CU_compare_strings(). */ +#define compare_strings(src, dest) CU_compare_strings(src, dest) + +/** Deprecated (version 1). @deprecated Use CU_trim_left(). */ +#define trim_left(str) CU_trim_left(str) +/** Deprecated (version 1). @deprecated Use CU_trim_right(). */ +#define trim_right(str) CU_trim_right(str) +/** Deprecated (version 1). @deprecated Use CU_trim(). */ +#define trim(str) CU_trim(str) + +#endif /* USE_DEPRECATED_CUNIT_NAMES */ + +#endif /* CUNIT_UTIL_H_SEEN */ +/** @} */ diff --git a/omc/plat/mgc_v2/ut/mgc_v2_test b/omc/plat/mgc_v2/ut/mgc_v2_test new file mode 100644 index 0000000..801f6cf Binary files /dev/null and b/omc/plat/mgc_v2/ut/mgc_v2_test differ diff --git a/omc/plat/mgc_v2/ut/mgc_v2_test.c b/omc/plat/mgc_v2/ut/mgc_v2_test.c new file mode 100644 index 0000000..3c15b26 --- /dev/null +++ b/omc/plat/mgc_v2/ut/mgc_v2_test.c @@ -0,0 +1,1786 @@ +#include "./include/CUnit.h" +#include "./include/CUError.h" +#include "./include/Automated.h" +#define MGC_TEST_ENABLE + + +#include "../../public/src/include/includes.h" +#include "../../public/src/include/public.h" + + + +#include "../src/include/mgc_struct.h" +#include "../src/include/mgc_8ecp.h" +#include "../src/include/mgc_chnl_info.h" +#include "../src/include/mgc_conn_info.h" +#include "../src/include/mgc_ctl.h" +#include "../src/include/mgc_internal.h" +#include "../src/include/mgc_mgcp.h" +#include "../src/include/mgc_mg_info.h" +#include "../src/include/mgc_port_info.h" +#include "../src/include/mgc_phy_port.h" +#include "../src/include/mgc.h" +#include "../src/include/mgc_debug.h" +#include "../src/include/mgc_tandem_info.h" +#include "../src/include/mgc_sur_info.h" + +#include "../../mgcp/src/include/mgcp.h" + +#include "../src/mgc.c" +#include "../src/mgc_8ecp.c" +#include "../src/mgc_chnl_info.c" +#include "../src/mgc_conn_info.c" +#include "../src/mgc_ctl.c" +#include "../src/mgc_internal.c" +#include "../src/mgc_mgcp.c" +#include "../src/mgc_mg_info.c" +#include "../src/mgc_phy_port.c" +#include "../src/mgc_port_info.c" +#include "../src/mgc_tandem_info.c" +#include "../src/mgc_sur_info.c" + +#include "../src/mgc_debug.c" +#include "../../rtp/src/include/rtp.h" + + +extern void mgcp_init(void); +extern void mgcp_timer(void); +extern void debug_init(); +extern int iptrMainInit(); +extern void snmp_init(WORD nport); + +#define MGC_TEST_SAP_NUM 10 +#define MGC_TEST_MG_NUM 1025 + +typedef enum +{ + OPERA_STATE_UNDEF =-1, + OPERA_STATE_SEND, + OPERA_STATE_GET, +}OPERA_STATE; + + +typedef struct _opera_struct +{ + int userPort; + OPERA_STATE status; + MGC_OPER_RESULT result; +}opera_struct; + + +typedef struct _test_mgc_sap +{ + int id; + MGC_SAP mgcSap; + int sapIndex; +}test_mgc_sap; + + +typedef struct _test_mg +{ + int mgNo; + int userPort; + int PortType; + int portNo; + BOOL enable; + MG_ATTR mgAttr; + test_mgc_sap *pMgcsap; +}test_mg; + +typedef struct _MGC_RTP_SAP +{ + RTP_SAP rtpSap; + int rtpSapIndex; + int hdlport; + int userPort; + WORD localport; + char localIP[33]; +}MGC_RTP_SAP; + + + +test_mg mgA , mgB , mgRtpProxy , mgAas; +test_mgc_sap testSap[MGC_TEST_SAP_NUM]; +opera_struct testOpera; +MGC_RTP_SAP mgcRtpSap; + + +int mgc_rtp_handshake(WORD usrPort, WORD hdlPort, WORD rtpPort) +{ + return 1; +} + +int mgc_rtp_recv(WORD usrPort, WORD hdlPort, BYTE pt, WORD sn, BYTE *payload, WORD len) +{ + + fputs(payload, stdout); + memset(payload , 0 , len); + return 0; +} + +BOOL mgc_test_rtp_bind(MGC_RTP_SAP *pRtpSap) +{ + RTP_SAP *pSap; + if(pRtpSap == NULL) + return FALSE; + + pSap = &(pRtpSap->rtpSap); + sprintf(pSap->name , "MGC_RTP_SAP"); + pSap->rtp_handshake = mgc_rtp_handshake; + pSap->rtp_recv = mgc_rtp_recv; + pRtpSap->rtpSapIndex = rtp_bind(pSap); + + if(pRtpSap->rtpSapIndex < 0) + return FALSE; + + return TRUE; +} + + +opera_struct *mgc_find_owner(WORD usrPort , WORD mgcPort) +{ + opera_struct *pOpera; + + pOpera = &testOpera; + if(pOpera->userPort == usrPort) + return pOpera ; + + return NULL; +} + +int mgc_ind_test(CHNL chnl, MGC_CMD_TYPE cmd, WORD *usrPort, WORD mgcPort, MEDIA_ATTR *pMediaAttr) +{ + PUB_SDP_MSG *pSdp; + MGC_DEBUG("mg[%d]port[%d]chnl[%d]conn[%d] get ind %s from mgcPort[%d]", + chnl.mgNo , chnl.portNo , chnl.chlNo , chnl.connectNo , mgc_port_info_print_cmd(cmd) , mgcPort); + switch(cmd) + { + case MGC_CMD_AUEP: + *usrPort = mgcPort; + mgc_rsp(cmd, *usrPort, mgcPort, 200 , NULL); + break; + case MGC_CMD_CRCX: + *usrPort = mgcPort; + if(pMediaAttr != NULL) + { + pSdp = &pMediaAttr->sdp; + MGC_DEBUG("remote ip : %s:%d" , pSdp->c.addr , pSdp->medias.medias[0].m.port); + } + mgc_rsp(cmd, *usrPort, mgcPort, 200 , NULL); + break; + case MGC_CMD_DLCX: + *usrPort = mgcPort; + mgc_rsp(cmd, *usrPort, mgcPort, 250 , NULL); + break; + default: + break; + } + + return 0; +} + +int mgc_cnf_test(WORD usrPort, WORD mgcPort, MGC_MG_OPER_ID_TYPE operId, MGC_OPER_RESULT success, WORD cause) +{ + opera_struct *pOpera = NULL; + + pOpera = mgc_find_owner(usrPort, mgcPort); + if(pOpera) + { + if(pOpera->status== OPERA_STATE_SEND) + { + pOpera->status= OPERA_STATE_GET; + pOpera->result = success; + MGC_DEBUG("opera[%d] get response %s" , pOpera->userPort , success?"success":"failure"); + } + else + { + pOpera->result = MGC_OPER_FAILURE; + MGC_WARN("opera[%d] error state" , pOpera->userPort); + CU_ASSERT_EQUAL_FATAL(pOpera->status , OPERA_STATE_SEND); + } + } + else + { + MGC_WARN("usrPort :%d mgcPort :%d , lost owner" , usrPort , mgcPort); + } + + + return 0; +} + + +void test_mgc_wait_time(opera_struct *pOpera , int seconds) +{ + struct timeval t1 ,t2 , t3; + + + if(pOpera == NULL) + return; + + MGC_DEBUG(" wait %d seconds....." , seconds); + gettimeofday(&t2 , NULL); + gettimeofday(&t3 , NULL); + while(1) + { + gettimeofday(&t1 , NULL); + if(t1.tv_usec - t2.tv_usec > 10) + { + iptrans_timer(); + mgcp_timer(); + debug_rt(); + rtp_timer(); + mgc_timer(); + gettimeofday(&t2 , NULL); + } + + if(t1.tv_sec - t3.tv_sec > seconds) + pOpera->status = OPERA_STATE_UNDEF; + + + if(pOpera->status!= OPERA_STATE_SEND) + return; + } + + return; + +} + + +void mgc_test_sap_init(test_mgc_sap *pSap , int id) +{ + if(pSap == NULL) + return; + + pSap->id = id; + sprintf(pSap->mgcSap.usrName , "test_mgcsap[%d]" , id); + pSap->mgcSap.usrType = MGC_USER_TYPE_MGC; + pSap->mgcSap.cnf_func = mgc_cnf_test; + pSap->mgcSap.ind_func = NULL; + return; +} + +void mgc_test_mg_init(test_mg *pMg , char *name , char *mgAddr , int mgType , int PortType) +{ + if((pMg == NULL) ||(name == NULL)||(mgAddr == NULL)) + return; + + pMg->enable = FALSE; + pMg->mgNo = -1; + pMg->userPort = -1; + pMg->PortType = PortType; + + pMg->pMgcsap = NULL; + pMg->mgAttr.mgType = mgType; + + sprintf(pMg->mgAttr.domain, "%s" , name); + pMg->mgAttr.codecList.num = 6; + pMg->mgAttr.codecList.priority = 0; + pMg->mgAttr.codecList.codec[0] = MGC_VCTYPE_PCMA; + pMg->mgAttr.codecList.codec[1] = MGC_VCTYPE_PCMU; + pMg->mgAttr.codecList.codec[2] = MGC_VCTYPE_GSM; + pMg->mgAttr.codecList.codec[3] = MGC_VCTYPE_GSM_EFR; + pMg->mgAttr.codecList.codec[4] = MGC_VCTYPE_AMR_12_2; + pMg->mgAttr.codecList.codec[5] = MGC_VCTYPE_G729B; + + pMg->mgAttr.ctrlType = MGC_MG_CTRL_TYPE_MGCP; + if(pMg->mgAttr.mgType == MGC_MG_TYPE_TANDEM) + { + pMg->mgAttr.epDes = MGCP_EP_NAME_UNSTRUCTURED; + } + else + { + pMg->mgAttr.epDes = MGCP_EP_NAME_STRUCTURED; + } + pMg->mgAttr.toneCap = 1; + pMg->mgAttr.ip = inet_addr(mgAddr); + pMg->mgAttr.maxChnls = 512; + pMg->mgAttr.ptime = 4*20;// 80ms + pMg->mgAttr.maxPorts = 30; + pMg->mgAttr.auditTimer = 15*10; + pMg->portNo = 0; + return; +} + + +int mgc_cunit_clean(void) +{ + + return 0; +} + +BOOL mgc_get_local_ip(char *ipAddr) +{ + struct hostent *host; + char localName[50]; + + if(ipAddr == NULL) + return FALSE; + + if (gethostname(localName , 50) == -1) + { + return FALSE; + } + + if ((host = gethostbyname(localName)) == NULL) + { + return FALSE; + } + + sprintf(ipAddr, "%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]); + + return TRUE; +} + + + +int mgc_test_cunit_init(void) +{ + test_mgc_sap *pSap; + char ipAddr[33]; + int i; + debug_init(); + iptrMainInit(); + mgcp_init(); + rtp_init(); + snmp_init(4957); + mgc_get_local_ip(ipAddr); + mgc_test_mg_init(&mgA , "mg-4444" , "172.54.240.202" , MGC_MG_TYPE_AudioCoder , MGC_PHY_PORT_TYPE_E1 ); + mgc_test_mg_init(&mgB , "mg-5555" , "172.54.240.214" , MGC_MG_TYPE_AudioCoder , MGC_PHY_PORT_TYPE_E1 ); + mgc_test_mg_init(&mgRtpProxy, "rtpproxy-1234" , "172.54.240.201" , MGC_MG_TYPE_TANDEM, MGC_PHY_VIRTUAL_TYPE_TANDEM); + mgc_test_mg_init(&mgAas , "aas", ipAddr , MGC_MG_TYPE_ANN , MGC_PHY_VIRTUAL_TYPE_ANN); + for(i=0 ; isapIndex = mgc_bind(&pSap->mgcSap); + if(pSap->sapIndex >= 0) + num++; + } + MGC_DEBUG("testSap bind success %d" , num); + CU_ASSERT_EQUAL_FATAL(num , MGC_MAX_NUM_OF_SAP-1); + + for(i=0 ; imgcSap , pSap->sapIndex); + if(i < num) + { + CU_ASSERT_FATAL(ret>=0); + } + else + { + CU_ASSERT_FATAL(ret < 0); + } + + mgc_test_sap_init(pSap, pSap->id); + } + + return; +} + + +void test_mgc_mg_create_and_delete(void) +{ + int i , num ,ret , k ; + test_mgc_sap *pSap; + test_mg mgTest[MGC_TEST_MG_NUM]; + test_mg *pMg = NULL; + char buf[32]; + + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + num = 0; + k = mgc_mg_info_created_num(); + for(i=0 ; ipMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + if(ret>=0) + num++; + pMg->mgNo = ret; + } + + CU_ASSERT_EQUAL_FATAL(num , (mgc_mg_info_created_num()-k)); + CU_ASSERT_EQUAL_FATAL(mgc_mg_info_created_num() , mgc_ctl_mg_num()); + + for(i=0 ; ipMgcsap->sapIndex , pMg->mgNo); + if(i < num) + { + CU_ASSERT_FATAL(ret>=0); + + } + else + { + CU_ASSERT_FATAL(ret<0); + } + } + + CU_ASSERT_EQUAL_FATAL(mgc_mg_info_created_num() , mgc_ctl_mg_num()); + CU_ASSERT_EQUAL_FATAL(k , mgc_ctl_mg_num()); + mgc_unbind(&pSap->mgcSap , pSap->sapIndex); + return; +} + + + + +void test_mgc_mg_max_num_ctl(void) +{ + int i , num ,ret , k , maxNum; + test_mgc_sap *pSap; + test_mg mgTest[MGC_TEST_MG_NUM]; + test_mg *pMg = NULL; + char buf[32]; + + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + maxNum = MGC_TEST_MG_NUM/2; + mgc_ctl_set_mg_max_num(maxNum); + num = 0; + k = mgc_mg_info_created_num(); + for(i=0 ; ipMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + if(ret>=0) + num++; + pMg->mgNo = ret; + } + CU_ASSERT_EQUAL_FATAL(num , maxNum); + CU_ASSERT_EQUAL_FATAL(num , (mgc_mg_info_created_num()-k)); + CU_ASSERT_EQUAL_FATAL(mgc_mg_info_created_num() , mgc_ctl_mg_num()); + + for(i=0 ; ipMgcsap->sapIndex , pMg->mgNo); + if(i < num) + { + CU_ASSERT_FATAL(ret>=0); + + } + else + { + CU_ASSERT_FATAL(ret<0); + } + } + + CU_ASSERT_EQUAL_FATAL(mgc_mg_info_created_num() , mgc_ctl_mg_num()); + CU_ASSERT_EQUAL_FATAL(k , mgc_ctl_mg_num()); + mgc_ctl_set_mg_max_num(MGC_MAX_NUM_OF_MG); + mgc_unbind(&pSap->mgcSap , pSap->sapIndex); + return; +} + + + +void test_mgc_mg_create_twice(void) +{ + int num ,ret , k ; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + + pMg = &mgA; + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + num = mgc_mg_info_created_num(); + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + + k = mgc_mg_info_created_num(); + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + CU_ASSERT_EQUAL_FATAL(ret , pMg->mgNo); + CU_ASSERT_EQUAL_FATAL(k , mgc_mg_info_created_num()); + CU_ASSERT_EQUAL_FATAL(k , mgc_ctl_mg_num()); + + ret = mgc_delete_MG(pMg->pMgcsap->sapIndex , pMg->mgNo); + CU_ASSERT(ret >= 0); + ret = mgc_delete_MG(pMg->pMgcsap->sapIndex , pMg->mgNo); + CU_ASSERT(ret < 0); + CU_ASSERT_EQUAL_FATAL(num , mgc_mg_info_created_num()); + mgc_unbind(&pSap->mgcSap , pSap->sapIndex); + return; +} + + +void test_mgc_port_add_and_delete(void) +{ + int i , num ,ret , k ; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + PHY_PORT_INFO phyPort; + + pMg = &mgA; + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + num = mgc_chnl_info_assigned_num(); + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + + k = 0; + for(i=0 ; ipMgcsap->sapIndex ,pMg->mgNo, i , pMg->PortType); + if(ret >= 0) + { + mgc_phy_port_set_chnl_num(&phyPort, pMg->PortType); + k += phyPort.chnlNum; + } + } + + CU_ASSERT_EQUAL_FATAL(k , mgc_ctl_chnl_num()-num); + CU_ASSERT_EQUAL_FATAL(mgc_ctl_chnl_num() , mgc_chnl_info_assigned_num()); + + for(i=0 ; ipMgcsap->sapIndex ,pMg->mgNo, i); + } + + CU_ASSERT_EQUAL_FATAL(num , mgc_chnl_info_assigned_num()); + CU_ASSERT_EQUAL_FATAL(mgc_ctl_chnl_num() , mgc_chnl_info_assigned_num()); + mgc_unbind(&pSap->mgcSap , pSap->sapIndex); + return; +} + + +void test_mgc_create_mg_a(void) +{ + int ret; + opera_struct opera; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + MG_INFO *pMgInfo; + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + MGC_DEBUG("enter %s", __FUNCTION__); + + pMg = &mgA; + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + + pMg->portNo = 0; + ret = mgc_add_port(pMg->pMgcsap->sapIndex ,pMg->mgNo , pMg->portNo , pMg->PortType); + CU_ASSERT(ret >= 0); + + opera.status = OPERA_STATE_SEND; + test_mgc_wait_time(&opera , 2); + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT_PTR_NOT_NULL_FATAL(pMgInfo); + if(pMgInfo->enable == FALSE) + { + MGC_ERROR("mg[%d] %s is not detected" , pMg->mgNo, pMg->mgAttr.domain); + } + CU_ASSERT_TRUE_FATAL(pMgInfo->enable); + + MGC_DEBUG("mg[%d] %s , bind mgcSap[%d] , attach phyport[%d]" , pMg->mgNo, pMg->mgAttr.domain , + pMg->pMgcsap->sapIndex , ret); + return; +} + + +void test_mgc_create_mg_b(void) +{ + int ret; + opera_struct opera; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + MG_INFO *pMgInfo; + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + MGC_DEBUG("enter %s", __FUNCTION__); + pMg = &mgB; + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + + pMg->portNo = 0; + ret = mgc_add_port(pMg->pMgcsap->sapIndex ,pMg->mgNo , pMg->portNo , pMg->PortType); + CU_ASSERT(ret >= 0); + + opera.status = OPERA_STATE_SEND; + test_mgc_wait_time(&opera , 2); + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT_PTR_NOT_NULL_FATAL(pMgInfo); + if(pMgInfo->enable == FALSE) + { + MGC_ERROR("mg[%d] %s is not detected" , pMg->mgNo, pMg->mgAttr.domain); + } + CU_ASSERT_TRUE_FATAL(pMgInfo->enable); + + MGC_DEBUG("mg[%d] %s , bind mgcSap[%d] , attach phyport[%d]" , pMg->mgNo, pMg->mgAttr.domain , + pMg->pMgcsap->sapIndex , ret); + return; + +} + + +void test_mgc_create_tandem(void) +{ + int ret; + opera_struct opera; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + MG_INFO *pMgInfo; + + + + MGC_DEBUG("enter %s", __FUNCTION__); + pSap = &testSap[0]; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret>=0); + pSap->sapIndex = ret; + + pMg = &mgRtpProxy; + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + + opera.status = OPERA_STATE_SEND; + test_mgc_wait_time(&opera , 2); + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT_PTR_NOT_NULL_FATAL(pMgInfo); + if(pMgInfo->enable == FALSE) + { + MGC_ERROR("mg[%d] %s is not detected" , pMg->mgNo, pMg->mgAttr.domain); + } + CU_ASSERT_TRUE_FATAL(pMgInfo->enable); + MGC_DEBUG("mg[%d] %s , bind mgcSap[%d] , attach phyport[%d]" , pMg->mgNo, pMg->mgAttr.domain , + pMg->pMgcsap->sapIndex , ret); + return; +} + + +void test_mgc_create_aas_mg_and_mgc(void) +{ + int ret; + opera_struct opera; + test_mgc_sap *pSap; + test_mg *pMg = NULL; + MG_INFO *pMgInfo; + + + MGC_DEBUG("enter %s", __FUNCTION__); + pMg = &mgAas; + pSap = &testSap[1]; + pSap->mgcSap.usrType = MGC_USER_TYPE_MGC; + MGC_DEBUG("create mgc aas"); + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret > 0); + pSap->sapIndex = ret; + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + opera.status = OPERA_STATE_SEND; + test_mgc_wait_time(&opera , 2); + CU_ASSERT(pMgInfo->enable); + + MGC_DEBUG("create mg aas"); + pSap = &testSap[2]; + pSap->mgcSap.usrType = MGC_USER_TYPE_MG; + pSap->mgcSap.ind_func = mgc_ind_test; + pSap->mgcSap.cnf_func = NULL; + ret = mgc_bind(&pSap->mgcSap); + CU_ASSERT(ret > 0); + pSap->sapIndex = ret; + pMg->pMgcsap = pSap; + ret = mgc_create_MG(pMg->pMgcsap->sapIndex , &pMg->mgAttr); + CU_ASSERT(ret >= 0); + pMg->mgNo = ret; + opera.status = OPERA_STATE_SEND; + test_mgc_wait_time(&opera , 2); + + + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT(pMgInfo->enable); + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT_PTR_NOT_NULL_FATAL(pMgInfo); + if(pMgInfo->enable == FALSE) + { + MGC_ERROR("mg[%d] %s is not detected" , pMg->mgNo, pMg->mgAttr.domain); + } + CU_ASSERT_TRUE_FATAL(pMgInfo->enable); + return; +} + + + + +void test_mgc_crcx_and_dlcx(void) +{ + int ret , num; + MG_INFO *pMgInfo; + test_mg *pMg = &mgA; + CHNL chnl; + opera_struct *pOpera = &testOpera; + + MGC_DEBUG("test crcx and dlcx"); + pMgInfo = mgc_mg_info_get_index_mg(pMg->mgNo); + CU_ASSERT_PTR_NOT_NULL_FATAL(pMgInfo); + CU_ASSERT_TRUE_FATAL(pMgInfo->enable); + + chnl.mgNo = pMg->mgNo; + chnl.portNo = pMg->portNo; + chnl.chlNo = 1; + chnl.connectNo = 0 ; + + MGC_DEBUG("enter %s", __FUNCTION__); + + num = mgc_connect_inused_num(); + + pOpera->userPort++; + ret = mgc_crcx_chnl(pOpera->userPort , chnl); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + //MGC_DEBUG("before num %d , after num %d " , num , mgc_connect_inused_num()); + CU_ASSERT_EQUAL_FATAL(num , mgc_connect_inused_num()); + return; +} + + + + + + +void test_mgc_connect(void) +{ + int ret , num; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + MGC_DEBUG("enter %s", __FUNCTION__); + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + num = mgc_connect_inused_num(); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 60); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + CU_ASSERT_EQUAL_FATAL(num , mgc_connect_inused_num()); + return; +} + + +void test_mgc_connect_tone(void) +{ + int ret ; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + MGC_DEBUG("enter %s", __FUNCTION__); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 3); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 3); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 10); + + pOpera->userPort++; + ret = mgc_connect_tone(pOpera->userPort , chnl_b , chnl_a , 8 , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 3); + // CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); +// CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); +/* + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 5); + +*/ + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 10); + + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + return; +} + + + +void test_mgc_connect_aas(void) +{ + int ret ; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + pOpera->userPort++; + MGC_DEBUG("enter %s", __FUNCTION__); + + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 10); + + MGC_DEBUG("connect chnl_a to aas"); + pOpera->userPort++; + ret = mgc_connect_AAS(pOpera->userPort , chnl_b , chnl_a , 8 , 1 ,3); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 60); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + return; +} + + +void test_mgc_connect_tandem_to_connection(void) +{ + int ret , tandemId; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + MGC_DEBUG("enter %s", __FUNCTION__); + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + tandemId = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_a ,tandemId); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 15); + + + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_delete_tandem(pOpera->userPort , tandemId); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + return; + +} + + + +void test_mgc_connect_connection_to_tandem(void) +{ + int ret , tandemId; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + MGC_DEBUG("enter %s", __FUNCTION__); + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + tandemId = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_b ,tandemId); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 15); + + + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_delete_tandem(pOpera->userPort , tandemId); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + return; + +} + + + + +void test_mgc_connect_tandem_to_tandem(void) +{ + int ret , tandemId_a , tandemId_b; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + MGC_DEBUG("enter %s", __FUNCTION__); + + tandemId_a = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_a ,tandemId_a); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + tandemId_b = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_b ,tandemId_b); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 15); + + + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_delete_tandem(pOpera->userPort , tandemId_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_delete_tandem(pOpera->userPort , tandemId_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + return; + +} + + + + +void test_mgc_connect_tandem_to_aas(void) +{ + int ret ,tandemId; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + MGC_DEBUG("enter %s", __FUNCTION__); + + tandemId = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_b ,tandemId); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 10); + + MGC_DEBUG("connect chnl_a to aas"); + pOpera->userPort++; + ret = mgc_connect_AAS(pOpera->userPort , chnl_b , chnl_a , 8 , 1 ,3); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 60); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 10); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + return; +} + + + + +void test_mgc_tandem_fork(void) +{ + int ret , tandemId; + opera_struct *pOpera = &testOpera; + test_mg *pMgA = &mgA; + CHNL chnl_a; + + test_mg *pMgB = &mgB; + CHNL chnl_b; + CHNL chnl_c; + CHNL chnl_tandem; + CHNL chnl_fork; + + MGC_DEBUG("enter %s", __FUNCTION__); + + chnl_a.mgNo = pMgA->mgNo; + chnl_a.portNo = pMgA->portNo; + chnl_a.chlNo = 1; + chnl_a.connectNo = 0 ; + + chnl_b.mgNo = pMgB->mgNo; + chnl_b.portNo = pMgB->portNo; + chnl_b.chlNo = 1; + chnl_b.connectNo = 0 ; + + chnl_c.mgNo = pMgB->mgNo; + chnl_c.portNo = pMgB->portNo; + chnl_c.chlNo = 2; + chnl_c.connectNo = 0; + + tandemId = mgc_get_idle_tandem_id(); + pOpera->userPort++; + ret = mgc_bind_chnl_to_tandem(pOpera->userPort , chnl_a ,tandemId); + CU_ASSERT(ret >= 0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_a , chnl_b , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_b , chnl_a , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + mgc_get_tandem_near_end(tandemId , &chnl_tandem); + ret = mgc_fork_chnl(pOpera->userPort , chnl_tandem , &chnl_fork); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_c , chnl_fork, 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_connect_chnl(pOpera->userPort , chnl_fork, chnl_c , 0); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 5); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + + pOpera->userPort++; + pOpera->status = OPERA_STATE_SEND; + test_mgc_wait_time(pOpera , 45); + + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_a); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_b); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + pOpera->userPort++; + ret = mgc_dlcx_chnl(pOpera->userPort , chnl_c); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + + pOpera->userPort++; + ret = mgc_delete_tandem(pOpera->userPort , tandemId); + MGC_DEBUG("ret %d" , ret); + CU_ASSERT_FATAL(ret>=0); + pOpera->status = OPERA_STATE_SEND; + pOpera->result = MGC_OPER_FAILURE; + test_mgc_wait_time(pOpera, 2); + CU_ASSERT_EQUAL_FATAL(pOpera->status ,OPERA_STATE_GET); + CU_ASSERT_EQUAL_FATAL(pOpera->result ,MGC_OPER_SUCCESS); + + return; + +} + + + + + +void test_mgc_sur_info_list(void) +{ + int i,j, repeat; + MGC_SUR_INFO_LIST list; + MGC_SUR_INFO_NODE *pNode; + CONNECT_INFO *pConn; + BOOL result; + + repeat = MGC_MAX_NUM_OF_SURVEILLANCE_CONN; //0 + mgc_sur_info_list_init(&list); + CU_ASSERT_PTR_NULL(list.pHead); + CU_ASSERT_EQUAL(list.len, 0); + for(i=0 ; i< repeat; i++) + { + pConn = &mgcSurvillanceConn[i]; + + result = mgc_sur_info_add_conn_to_list(&list, pConn); + CU_ASSERT_TRUE(result); + CU_ASSERT_EQUAL(list.len, i+1); + } + + pConn = &mgcSurvillanceConn[5]; + pNode = mgc_sur_info_find_conn_in_list(&list, pConn); + CU_ASSERT_PTR_NOT_NULL(pNode); + CU_ASSERT_EQUAL(pNode->id, 5); +/* + for(i=0 ; i< repeat; i++) + { + pConn = &mgcSurvillanceConn[i]; + j = list.len; + result = mgc_sur_info_remove_conn_to_list(&list, pConn); + CU_ASSERT_TRUE(result); + CU_ASSERT_EQUAL(list.len, j-1); + } +*/ + mgc_sur_info_clear_list(&list); + CU_ASSERT_PTR_NULL(list.pHead); + CU_ASSERT_EQUAL(list.len, 0); + + return; +} + + +CU_BOOL mgc_add_test(void) +{ + CU_pSuite pSuite = NULL; + + pSuite = CU_add_suite("MGC_TEST", mgc_test_cunit_init , mgc_cunit_clean); + + if(NULL == pSuite) + return CU_FALSE; + + if((NULL == CU_add_test(pSuite, "test of mgc init", test_mgc_init))|| + /* (NULL == CU_add_test(pSuite, "test of mgc bind and unbind", test_mgc_sap_bind_and_unbind))|| + (NULL == CU_add_test(pSuite, "test of mg create and delete", test_mgc_mg_create_and_delete))|| + (NULL == CU_add_test(pSuite, "test of mg create and delete twice", test_mgc_mg_create_twice))|| + (NULL == CU_add_test(pSuite, "test of mg port add and delete", test_mgc_port_add_and_delete))|| */ + // (NULL == CU_add_test(pSuite, "test of mg create mgA", test_mgc_create_mg_a))|| + // (NULL == CU_add_test(pSuite, "test of mg create mgB", test_mgc_create_mg_b))|| + // (NULL == CU_add_test(pSuite, "test of create aas mg and mgc ", test_mgc_create_aas_mg_and_mgc))|| + // (NULL == CU_add_test(pSuite, "test of mg create tandem", test_mgc_create_tandem))|| + (NULL == CU_add_test(pSuite, "test of sur info lis operatioin", test_mgc_sur_info_list)) + // (NULL == CU_add_test(pSuite, "test of mg crcx and dlcx", test_mgc_crcx_and_dlcx)) + // (NULL == CU_add_test(pSuite, "test of mg connect", test_mgc_connect)) + // (NULL == CU_add_test(pSuite, "test of connect aas ", test_mgc_connect_aas))|| + // (NULL == CU_add_test(pSuite, "test of rtp proxy connect tone ", test_mgc_connect_tone)) + // (NULL == CU_add_test(pSuite, "test of mg connect tandem to connection", test_mgc_connect_tandem_to_connection)) + // (NULL == CU_add_test(pSuite, "test of mg connect connection to tandem", test_mgc_connect_connection_to_tandem)) + // (NULL == CU_add_test(pSuite, "test of mg connect tandem to tandem", test_mgc_connect_tandem_to_tandem)) + // (NULL == CU_add_test(pSuite, "test of mg connect tandem to aas", test_mgc_connect_tandem_to_aas)) + // (NULL == CU_add_test(pSuite, "test of tandem fork", test_mgc_tandem_fork)) + ) + return CU_FALSE; + + return CU_TRUE; +} + + +int main(int argc, char* argv[]) +{ + CU_BOOL Run = CU_FALSE ; + + setvbuf(stdout, NULL, _IONBF, 0); + + if (argc > 1) { + if (!strcmp("-i", argv[1])) { + Run = CU_TRUE ; + CU_set_error_action(CUEA_IGNORE); + } + else if (!strcmp("-f", argv[1])) { + Run = CU_TRUE ; + CU_set_error_action(CUEA_FAIL); + } + else if (!strcmp("-A", argv[1])) { + Run = CU_TRUE ; + CU_set_error_action(CUEA_ABORT); + } + else if (!strcmp("-e", argv[1])) { + //print_example_results(); + } + else { + printf("\nUsage: AutomatedTest [option]\n\n" + " Options: -i Run, ignoring framework errors [default].\n" + " -f Run, failing on framework error.\n" + " -A Run, aborting on framework error.\n" + " -e Print expected test results and exit.\n" + " -h Print this message.\n\n"); + } + } + else { + Run = CU_TRUE; + CU_set_error_action(CUEA_IGNORE); + } + + if (CU_TRUE == Run) { + if (CU_initialize_registry()) { + printf("\nInitialization of Test Registry failed."); + } + else { + if(mgc_add_test() == CU_FALSE) + { + CU_cleanup_registry(); + CU_get_error(); + } + + CU_set_output_filename("mgc_unit_test"); + CU_list_tests_to_file(); + CU_automated_run_tests(); + CU_cleanup_registry(); + } + } + + + return 1; +} + diff --git a/omc/plat/mgcp/.copyarea.db b/omc/plat/mgcp/.copyarea.db new file mode 100644 index 0000000..a2ab4a2 --- /dev/null +++ b/omc/plat/mgcp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgcp +2 +5 +3:doc|2|0|0|0|3d6969c5bfa511dc8595001c23e19543|0 +2:ut|2|0|0|0|48b96bd9bfa511dc8595001c23e19543|0 +3:src|2|0|0|0|3e996a19bfa511dc8595001c23e19543|0 +8:Makefile|1|11d70a4183d|b31|960ac018|3df969fdbfa511dc8595001c23e19543|0 +3:lib|2|0|0|0|3df969e1bfa511dc8595001c23e19543|0 diff --git a/omc/plat/mgcp/Makefile b/omc/plat/mgcp/Makefile new file mode 100644 index 0000000..7e8c06f --- /dev/null +++ b/omc/plat/mgcp/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = mgcp +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/mgcp/lib/libmgcp.a b/omc/plat/mgcp/lib/libmgcp.a new file mode 100644 index 0000000..d055eb3 Binary files /dev/null and b/omc/plat/mgcp/lib/libmgcp.a differ diff --git a/omc/plat/mgcp/obj/mgcp.o b/omc/plat/mgcp/obj/mgcp.o new file mode 100644 index 0000000..13d62cb Binary files /dev/null and b/omc/plat/mgcp/obj/mgcp.o differ diff --git a/omc/plat/mgcp/obj/mgcp_debug.o b/omc/plat/mgcp/obj/mgcp_debug.o new file mode 100644 index 0000000..25b7d51 Binary files /dev/null and b/omc/plat/mgcp/obj/mgcp_debug.o differ diff --git a/omc/plat/mgcp/obj/mgcp_msg.o b/omc/plat/mgcp/obj/mgcp_msg.o new file mode 100644 index 0000000..fe1b0a5 Binary files /dev/null and b/omc/plat/mgcp/obj/mgcp_msg.o differ diff --git a/omc/plat/mgcp/obj/mgcp_trans.o b/omc/plat/mgcp/obj/mgcp_trans.o new file mode 100644 index 0000000..982f16d Binary files /dev/null and b/omc/plat/mgcp/obj/mgcp_trans.o differ diff --git a/omc/plat/mgcp/src/.copyarea.db b/omc/plat/mgcp/src/.copyarea.db new file mode 100644 index 0000000..77a603b --- /dev/null +++ b/omc/plat/mgcp/src/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgcp\src +2 +6 +c:mgcp_trans.c|1|11d70a41928|156a|b5711bdd|40696a6dbfa511dc8595001c23e19543|0 +e:mgcp_msg.c.bak|1|11d70a418f9|f6f7|496f7d1e|3fc96a51bfa511dc8595001c23e19543|0 +a:mgcp_msg.c|1|11d70a41966|12869|144ae62b|27764318a67111dd9610001c23e19543|0 +7:include|2|0|0|0|40f96a89bfa511dc8595001c23e19543|0 +c:mgcp_debug.c|1|11d70a418d9|3a56|9dc0526c|3f396a35bfa511dc8595001c23e19543|0 +6:mgcp.c|1|11d70a41995|1b4f|ccf385b4|48296bbdbfa511dc8595001c23e19543|0 diff --git a/omc/plat/mgcp/src/include/.copyarea.db b/omc/plat/mgcp/src/include/.copyarea.db new file mode 100644 index 0000000..0cb32f6 --- /dev/null +++ b/omc/plat/mgcp/src/include/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mgcp\src\include +2 +9 +c:mgcp_const.h|1|11d70a41b4a|5ba|d3990dc|45296b4dbfa511dc8595001c23e19543|0 +a:mgcp_msg.h|1|11d70a41b89|116|fe215d62|46596b69bfa511dc8595001c23e19543|0 +d:mgcp_struct.h|1|11d70a41b1b|2a9|d3b8d395|44896b31bfa511dc8595001c23e19543|0 +6:mgcp.h|1|11d70a41ba8|1e14|7cf97be|ec1484ae6cf311dd91a5001c23e19543|0 +c:mgcp_trans.h|1|11d70a41aec|a7|9c78393c|43f96b15bfa511dc8595001c23e19543|0 +a:mgcp_ext.h|1|11d70a41a9e|47b|d565713c|ec1484966cf311dd91a5001c23e19543|0 +a:mgcp_def.h|1|11d70a41a60|baf|2ea9ef1f|eb84847e6cf311dd91a5001c23e19543|0 +c:mgcp_debug.h|1|11d70a41a31|f1|53ce4e9e|41996aa5bfa511dc8595001c23e19543|0 +a:mgcp_pub.h|1|11d70a41abe|3d1|c7b944b7|43596af9bfa511dc8595001c23e19543|0 diff --git a/omc/plat/mgcp/src/include/mgcp.h b/omc/plat/mgcp/src/include/mgcp.h new file mode 100644 index 0000000..1e5ac7d --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp.h @@ -0,0 +1,311 @@ +#ifndef _MGCP__H +#define _MGCP__H + +#include "../../../public/src/include/pub_sdp.h" +#include "../../../iptrans/src/include/iptrans.h" + +#define MGCP_RET_CODE_TEMP_RSP 100 +#define MGCP_RET_CODE_TEMP_RSP_DESC "temp response" + +#define MGCP_RET_CODE_TRANS_OK 200 +#define MGCP_RET_CODE_TRANS_OK_DESC "OK" + +#define MGCP_RET_CODE_TRANS_TIME_OUT 406 +#define MGCP_RET_CODE_TRANS_TIME_OUT_DESC "transaction time out" + +#define MGCP_RET_CODE_INTERNAL_OVERLOAD 409 +#define MGCP_RET_CODE_INTERNAL_OVERLOAD_DESC "internal overload" + +#define MGCP_RET_CODE_UNEP 500 +#define MGCP_RET_CODE_UNEP_DESC "endpoint unknow" + +#define MGCP_RET_CODE_UNCMD 504 +#define MGCP_RET_CODE_UNCMD_DESC "unknow or unsupport command" + +#define MGCP_RET_CODE_RCD_ERR 509 +#define MGCP_RET_CODE_RCD_ERR_DESC "remoto connection descriptor error" + +#define MGCP_RET_CODE_INCONID 515 +#define MGCP_RET_CODE_INCONID_DESC "incorrect connect id" + +#define MGCP_RET_CODE_UNCLLID 516 +#define MGCP_RET_CODE_UNCLLID_DESC "unknow call id" + +#define MGCP_RET_CODE_UNMD 517 +#define MGCP_RET_CODE_UNMD_DESC "unsupported or invalid mode" + +#define MGCP_RET_CODE_UNPKG 518 +#define MGCP_RET_CODE_UNPKG_DESC "unsupported or unknow package" + +#define MGCP_RET_CODE_NES 522 +#define MGCP_RET_CODE_NES_DESC "no such event or signal" + +#define MGCP_RET_CODE_ILCO 524 +#define MGCP_RET_CODE_ILCO_DESC "internal inconsistency in LocalConnectionOption" + +#define MGCP_RET_CODE_UNRM 526 +#define MGCP_RET_CODE_UNRM_DESC "unknow or unsupported RestartMethod" + +#define MGCP_MAX_NUM_OF_SAP 1 +#define MGCP_MAX_NUM_OF_PORT 8192 + +#define MGCP_MAX_USER_NAME_LEN 16 +#define MGCP_MAX_MG_NAME_LEN 32 +#define MGCP_MAX_DOMAIN_LEN 64 + +#define MGCP_COMMAND 1 +#define MGCP_RESPONSE 2 + +#define MGCP_CMD_CRCX 1 +#define MGCP_CMD_MDCX 2 +#define MGCP_CMD_DLCX 3 +#define MGCP_CMD_RQNT 4 +#define MGCP_CMD_NTFY 5 +#define MGCP_CMD_AUEP 6 +#define MGCP_CMD_RSIP 7 + +#define MGCP_EP_NAME_STRUCTURED 1 +#define MGCP_EP_NAME_UNSTRUCTURED 2 +#define MGCP_EP_NAME_CHNL_WILDCAST 0xFFFF +#define MGCP_EP_NAME_TRK_WILDCAST 0xFF + +#define MGCP_MG_TYPE_AudioCoder 1 +#define MGCP_MG_TYPE_LGC_MG 2 +#define MGCP_MG_TYPE_SSW_CSS 3 +#define MGCP_MG_TYPE_ANALOG 11 +#define MGCP_MG_TYPE_ANN 21 + +#define MGCP_PORT_TYPE_E1 1 +#define MGCP_PORT_TYPE_T1 2 +#define MGCP_PORT_TYPE_AALN 3 + +#define MGCP_CON_MODE_INACTIVE 0 +#define MGCP_CON_MODE_RECVONLY 1 +#define MGCP_CON_MODE_SENDONLY 2 +#define MGCP_CON_MODE_SENDRECV 3 + +#define MGCP_RST_MODE_RESTART 0 +#define MGCP_RST_MODE_FORCED 1 +#define MGCP_RST_MODE_DISCONNECTED 2 +#define MGCP_RST_MODE_GRACEFUL 3 +#define MGCP_RST_MODE_CANCEL_GRACEFUL 4 + +#define MGCP_PKG_L 0 +#define MGCP_PKG_D 1 +#define MGCP_PKG_G 2 + +#define MGCP_SIG_DL 1 +#define MGCP_SIG_BZ 2 +#define MGCP_SIG_RT 3 +#define MGCP_SIG_WT 4 + +#define MGCP_L_SIG_AW 1 +#define MGCP_L_SIG_DL 2 +#define MGCP_L_SIG_BZ 3 +#define MGCP_L_SIG_WT 4 +#define MGCP_L_SIG_NBZ 5 +#define MGCP_L_SIG_RG 6 +#define MGCP_L_SIG_E 7 +#define MGCP_L_SIG_OT 8 + +#define MGCP_D_SIG_ONE 1 +#define MGCP_D_SIG_TWO 2 +#define MGCP_D_SIG_THREE 3 +#define MGCP_D_SIG_FOUR 4 +#define MGCP_D_SIG_FIVE 5 +#define MGCP_D_SIG_SIX 6 +#define MGCP_D_SIG_SEVEN 7 +#define MGCP_D_SIG_EIGHT 8 +#define MGCP_D_SIG_NINE 9 +#define MGCP_D_SIG_ZERO 10 +#define MGCP_D_SIG_STAR 11 +#define MGCP_D_SIG_POUND 12 +#define MGCP_D_SIG_WILD 13 + +#define MGCP_G_SIG_RT 1 +#define MGCP_G_SIG_CF 2 +#define MGCP_G_SIG_CG 3 +#define MGCP_G_SIG_IT 4 +#define MGCP_G_SIG_PT 5 + + +#define MGCP_OBDENT_ZERO 0 +#define MGCP_OBDENT_HU 1 +#define MGCP_OBDENT_HD 2 + +#define MGCP_L_EVENT_HD 1 +#define MGCP_L_EVENT_HU 2 +#define MGCP_L_EVENT_HF 3 +#define MGCP_L_EVENT_AW 4 +#define MGCP_L_EVENT_NBZ 5 +#define MGCP_L_EVENT_E 6 +#define MGCP_L_EVENT_OC 7 +#define MGCP_L_EVENT_OF 8 + +#define MGCP_D_EVENT_ONE 1 +#define MGCP_D_EVENT_TWO 2 +#define MGCP_D_EVENT_THREE 3 +#define MGCP_D_EVENT_FOUR 4 +#define MGCP_D_EVENT_FIVE 5 +#define MGCP_D_EVENT_SIX 6 +#define MGCP_D_EVENT_SEVEN 7 +#define MGCP_D_EVENT_EIGHT 8 +#define MGCP_D_EVENT_NINE 9 +#define MGCP_D_EVENT_ZERO 10 +#define MGCP_D_EVENT_STAR 11 +#define MGCP_D_EVENT_POUND 12 + + + + +#define MGCP_G_EVENT_MT 1 +#define MGCP_G_EVENT_FT 2 +#define MGCP_G_EVENT_LD 3 +#define MGCP_G_EVENT_OF 4 + +#define MGCP_PACKAGE_MAX 3 +#define MGCP_PACKAGE_AALN 0 +#define MGCP_PACKAGE_SIG_NONE 0 + +#define MGCP_PKG_AALN_SIG_MAX 18 + +#define MGCP_OBD_ENT_MAX 3 +#define MGCP_ENT_MAX 18 + +#define MGCP_REST_MOD_MAX 5 + +#define MGCP_PARA_FLAG_SL 0x00000001 +#define MGCP_PARA_FLAG_C 0x00000002 +#define MGCP_PARA_FLAG_I 0x00000004 +#define MGCP_PARA_FLAG_L 0x00000008 +#define MGCP_PARA_FLAG_M 0x00000010 +#define MGCP_PARA_FLAG_S 0x00000020 +#define MGCP_PARA_FLAG_RM 0x00000040 +#define MGCP_PARA_FLAG_RD 0x00000080 +#define MGCP_PARA_FLAG_R 0x00000100 +#define MGCP_PARA_FLAG_O 0x00000200 +#define MGCP_PARA_FLAG_SDP 0x00000400 +#define MGCP_PARA_FLAG_TFO 0x00000800 + +#define MGCP_PARA_L_FLAG_ESS_CCI 0x00000001 +#define MGCP_PARA_L_FLAG_ESS_CCD 0x00000002 + +typedef struct _MGCP_ESCCD +{ + char domain[MGCP_MAX_DOMAIN_LEN]; + WORD port; +}MGCP_ESCCD; + +typedef struct _MGCP_SL +{ + BYTE cmdRes; // command or response + + DWORD transId; // transaction ID for command received + + BYTE epNameMethod; // structured/unstructured + BYTE mgType; // Non-Virtual/ANN + BYTE portType; // E1/T1/Analog + BYTE trkNum; // trunk number + WORD chlNum; // channel number + char mgName[MGCP_MAX_MG_NAME_LEN]; + + WORD retCode; // return code, for response message only + char desc[64]; // descriptions +}MGCP_SL; + +typedef struct _MGCP_C +{ + char callId[33]; // max 32 hexadecimal digits +}MGCP_C; + +typedef struct _MGCP_I +{ + char conId[33]; // max 32 hexadecimal digits +}MGCP_I; + +typedef struct _MGCP_L +{ + BYTE flag; + BYTE p; // packetization period in ms + char codec[16]; // PCMA/PCMU/EVRC/QCELP + char esCci[32]; + MGCP_ESCCD esCcd; + BYTE ecDisable; // echo canceller enable or disable + BYTE ssDisable; // silence suppression enable or disable +}MGCP_L; + +typedef struct _MGCP_M +{ + BYTE mode; // inactive/recvonly/sendonly/sendrecv +}MGCP_M; + +typedef struct _MGCP_S +{ + BYTE pkg; // package id + BYTE signal; // signal id + char reqId[32]; +}MGCP_S; + +typedef struct _MGCP_RM +{ + BYTE rm; // restart mode, restart/forced +}MGCP_RM; + +typedef struct _MGCP_RD +{ + WORD rd; // restart delay, no delay/delay time +}MGCP_RD; + +typedef struct _MGCP_R +{ + BYTE pkg; // package id + BYTE event; // signal id + char reqId[32]; +}MGCP_R; + +typedef struct _MGCP_O +{ + BYTE package; // package id + BYTE event; // event id + char reqId[32]; +}MGCP_O; + +typedef struct _MGCP_PARA +{ + DWORD ip; + WORD localPort; + WORD peerPort; + + DWORD flag; + + MGCP_SL sl; + MGCP_C c; + MGCP_I i; + MGCP_L l; + MGCP_M m; + MGCP_S s; + MGCP_RM rm; + MGCP_RD rd; + MGCP_R r; + MGCP_O o; + + PUB_SDP_MSG sdp; +}MGCP_PARA; + +typedef struct _MGCP_SAP +{ + char name[MGCP_MAX_USER_NAME_LEN]; // User name + + // The MGCP module sends a indication to its user when it receives a + // MGCP CRCX/MDCX/DLCX/RQNT/NTFY/AUEP/RSIP command message + int (*MGCP_ind)(BYTE cmd, WORD *usrPort, WORD hdlPort, MGCP_PARA *para); + + // The MGCP module sends this failure/success return code to the user + int (*MGCP_cnf)(BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para); +}MGCP_SAP; + +int mgcp_bind(MGCP_SAP *sap); +int MGCP_req(BYTE sapIndex, BYTE cmd, WORD usrPort, MGCP_PARA *para); +int MGCP_rsp(BYTE sapIndex, BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para); + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_const.h b/omc/plat/mgcp/src/include/mgcp_const.h new file mode 100644 index 0000000..d7f139f --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_const.h @@ -0,0 +1,47 @@ +#ifndef _MGCP_CONST__H +#define _MGCP_CONST__H + +#define MGCP_REQUEST 1 +#define MGCP_INDICATION 2 + +#define MGCP_TRANS_IDLE_STATE 0 +#define MGCP_TRANS_AWAIT_PEER_RESPONSE_STATE 1 +#define MGCP_TRANS_AWAIT_USER_RESPONSE_STATE 2 +#define MGCP_TRANS_INIT_STATE 3 + +#define MGCP_MUTIPLE_T1S 100 +#define MGCP_MAX_RETRANS_TIMER (10 * MGCP_MUTIPLE_T1S) +#define MGCP_RETRANS_TIMER (2 * MGCP_MUTIPLE_T1S) +#define MGCP_TIME_WAIT_TIMER (5 * MGCP_MUTIPLE_T1S) + +#define MGCP_INT_PORT_2727 4966 +#define MGCP_INT_PORT_2427 4967 + +#define MGCP_MAX_RET_CODE_INDEX 20 +#define MGCP_RET_CODE_TRANS_TIME_OUT_INDEX 0 +#define MGCP_RET_CODE_INTERNAL_OVERLOAD_INDEX 1 +#define MGCP_RET_CODE_UNEP_INDEX 2 +#define MGCP_RET_CODE_UNCMD_INDEX 3 +#define MGCP_RET_CODE_RCD_ERR_INDEX 4 +#define MGCP_RET_CODE_INCONID_INDEX 5 +#define MGCP_RET_CODE_UNCLLID_INDEX 6 +#define MGCP_RET_CODE_UNMD_INDEX 7 +#define MGCP_RET_CODE_UNPKG_INDEX 8 +#define MGCP_RET_CODE_NES_INDEX 9 +#define MGCP_RET_CODE_ILCO_INDEX 10 +#define MGCP_RET_CODE_UNRM_INDEX 11 +#define MGCP_RET_CODE_TRANS_OK_INDEX 12 +#define MGCP_RET_CODE_TEMP_RSP_INDEX 13 + +#define MGCP_MAX_ASCIIIN_LEN 4096 +#define MGCP_MAX_ASCIIOUT_LEN 4096 +#define MGCP_MAX_ASCITMP_LEN 4096 + +#define MONITOR_NONE 0x0000 +#define MONITOR_ERROR 0x0001 +#define MONITOR_MG0_MSG 0x0002 +#define MONITOR_MG1_MSG 0x0004 +#define MONITOR_MG2_MSG 0x0008 +#define MONITOR_ALL 0xffff + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_debug.h b/omc/plat/mgcp/src/include/mgcp_debug.h new file mode 100644 index 0000000..386702b --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_debug.h @@ -0,0 +1,10 @@ +#ifndef _MGCP_DEBUG__H +#define _MGCP_DEBUG__H + +void mgcp_mon(void); +int mgcp_debug_set(void); +int mgcp_asciout_proc(BYTE *outStr); +int mgcp_hex_to_ascii(BYTE *fromHex, BYTE fromLen, BYTE *toAsc); +int mgcp_log_err(BYTE *errMsg); + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_def.h b/omc/plat/mgcp/src/include/mgcp_def.h new file mode 100644 index 0000000..d79dd8e --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_def.h @@ -0,0 +1,62 @@ +#ifndef _MGCP_DEF__H +#define _MGCP_DEF__H + +#include "mgcp_pub.h" +#include "mgcp.h" +#include "mgcp_const.h" +#include "mgcp_struct.h" + +MGCP_SAP mgcpSap[MGCP_MAX_NUM_OF_SAP]; +MGCP_PORT mgcpPort[MGCP_MAX_NUM_OF_PORT]; +WORD mgcpTransStart[MGCP_MAX_NUM_OF_PORT]; + +WORD mgcpPortSelect; + +char mgcpCmdToStr[8][5] = {{""}, {"CRCX"}, {"MDCX"}, {"DLCX"}, {"RQNT"}, {"NTFY"}, {"AUEP"}, {"RSIP"}}; +char mgcpConModeToStr[4][9] = {{"inactive"}, {"recvonly"}, {"sendonly"}, {"sendrecv"}}; + +char mgcpPkgToStr[MGCP_PACKAGE_MAX][8] = {{"L"},{"D"},{"G"}}; +char mgcpAalnSigToStr[MGCP_PACKAGE_MAX][MGCP_PKG_AALN_SIG_MAX][16] = {{"", "aw", "dl", "bz", "wt", "nbz", "rg", "e", "ot"} + , {"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "#", "[0-9*#](N)"} + , {"", "rt", "cf", "cg", "it", "pt"}}; + + +char mgcpEntToStr[MGCP_PACKAGE_MAX][MGCP_ENT_MAX][16] = {{"", "hd", "hu", "hf", "aw", "nbz", "e", "oc", "of"} + , {"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "#","[0-9#*](N)"} + , {"", "mt", "ft", "ld", "of"} + }; + +char mgcpRestModToStr[MGCP_REST_MOD_MAX][16] = {{"restart"}, {"forced"}, {"disconnected"}, {"graceful"}, {"cancel-graceful"}}; + +BYTE mgcpMaxPkgSig[MGCP_PACKAGE_MAX] = {8, 13, 5}; +BYTE mgcpMaxPkgEvent[MGCP_PACKAGE_MAX] = {8, 13, 4}; + +message_list mgcpSdMsg; +message_list mgcpRvMsg; + +MGCP_PARA mgcpRespPara; + +MGCP_RET_CODE mgcpRetCode[MGCP_MAX_RET_CODE_INDEX] = { {MGCP_RET_CODE_TRANS_TIME_OUT, MGCP_RET_CODE_TRANS_TIME_OUT_DESC} + , {MGCP_RET_CODE_INTERNAL_OVERLOAD, MGCP_RET_CODE_INTERNAL_OVERLOAD_DESC} + , {MGCP_RET_CODE_UNEP, MGCP_RET_CODE_UNEP_DESC} + , {MGCP_RET_CODE_UNCMD, MGCP_RET_CODE_UNCMD_DESC} + , {MGCP_RET_CODE_RCD_ERR, MGCP_RET_CODE_RCD_ERR_DESC} + , {MGCP_RET_CODE_INCONID, MGCP_RET_CODE_INCONID_DESC} + , {MGCP_RET_CODE_UNCLLID, MGCP_RET_CODE_UNCLLID_DESC} + , {MGCP_RET_CODE_UNMD,MGCP_RET_CODE_UNMD_DESC} + , {MGCP_RET_CODE_UNPKG, MGCP_RET_CODE_UNPKG_DESC} + , {MGCP_RET_CODE_NES, MGCP_RET_CODE_NES_DESC} + , {MGCP_RET_CODE_ILCO, MGCP_RET_CODE_ILCO_DESC} + , {MGCP_RET_CODE_UNRM, MGCP_RET_CODE_UNRM_DESC} + , {MGCP_RET_CODE_TRANS_OK, MGCP_RET_CODE_TRANS_OK_DESC} + , {MGCP_RET_CODE_TEMP_RSP, MGCP_RET_CODE_TEMP_RSP_DESC} + }; + +BYTE mgcpAsciInBuf[MGCP_MAX_ASCIIIN_LEN]; +BYTE mgcpAsciOutBuf[MGCP_MAX_ASCIIOUT_LEN]; +BYTE mgcpAsciTempBuf[MGCP_MAX_ASCITMP_LEN]; +WORD mgcpMonitorFg; + +char dbgmgNamemg[3][MGCP_MAX_MG_NAME_LEN]; + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_ext.h b/omc/plat/mgcp/src/include/mgcp_ext.h new file mode 100644 index 0000000..046cb76 --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_ext.h @@ -0,0 +1,42 @@ +#ifndef _MGCP_EXT__H +#define _MGCP_EXT__H + +#include "mgcp_pub.h" +#include "mgcp.h" +#include "mgcp_const.h" +#include "mgcp_struct.h" + +extern MGCP_SAP mgcpSap[MGCP_MAX_NUM_OF_SAP]; +extern MGCP_PORT mgcpPort[MGCP_MAX_NUM_OF_PORT]; +extern WORD mgcpTransStart[MGCP_MAX_NUM_OF_PORT]; + +extern WORD mgcpPortSelect; + +extern char mgcpCmdToStr[8][5]; +extern char mgcpConModeToStr[4][9]; + +extern char mgcpPkgToStr[MGCP_PACKAGE_MAX][8]; +extern char mgcpAalnSigToStr[MGCP_PACKAGE_MAX][MGCP_PKG_AALN_SIG_MAX][16]; + +extern char mgcpEntToStr[MGCP_PACKAGE_MAX][MGCP_ENT_MAX][16]; + +extern char mgcpRestModToStr[MGCP_REST_MOD_MAX][8]; + +extern BYTE mgcpMaxPkgSig[MGCP_PACKAGE_MAX]; +extern BYTE mgcpMaxPkgEvent[MGCP_PACKAGE_MAX]; + +extern message_list mgcpSdMsg; +extern message_list mgcpRvMsg; + +extern MGCP_PARA mgcpRespPara; + +extern MGCP_RET_CODE mgcpRetCode[MGCP_MAX_RET_CODE_INDEX]; + +extern BYTE mgcpAsciInBuf[MGCP_MAX_ASCIIIN_LEN]; +extern BYTE mgcpAsciOutBuf[MGCP_MAX_ASCIIOUT_LEN]; +extern BYTE mgcpAsciTempBuf[MGCP_MAX_ASCITMP_LEN]; +extern WORD mgcpMonitorFg; + +extern char dbgmgNamemg[3][MGCP_MAX_MG_NAME_LEN]; + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_msg.h b/omc/plat/mgcp/src/include/mgcp_msg.h new file mode 100644 index 0000000..73f252c --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_msg.h @@ -0,0 +1,10 @@ +#ifndef _MGCP_MSG__H +#define _MGCP_MSG__H + +void mgcp_recv_msg(); +int mgcp_send_msg(WORD port, BYTE cmdRes); +int mgcp_send_incmd_rsp(DWORD transId, BYTE retCodeIndex); +int mgcp_send_rsp(WORD port, BYTE retCodeIndex); +int mgcp_ep_id_encode(MGCP_SL *sl, char *endPointId); + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_pub.h b/omc/plat/mgcp/src/include/mgcp_pub.h new file mode 100644 index 0000000..3a20ef7 --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_pub.h @@ -0,0 +1,55 @@ +#ifndef _MGCP_PUB__H +#define _MGCP_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//by simon at 23/9/22 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/omc/plat/mgcp/src/include/mgcp_struct.h b/omc/plat/mgcp/src/include/mgcp_struct.h new file mode 100644 index 0000000..cd5a93d --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_struct.h @@ -0,0 +1,31 @@ +#ifndef _MGCP_STRUCT__H +#define _MGCP_STRUCT__H + +#include "mgcp.h" +#include "mgcp_const.h" + +typedef struct _MGCP_PORT +{ + BYTE flag; // used or not + BYTE sapIndex; + BYTE state; // mgcp transaction state + BYTE state2; // mgcp transaction state #2 + BYTE cmd; // mgcp command + BYTE reqInd; // request or indication + BYTE gotProvRes; // got provisional response flag + WORD usrPort; + + DWORD timer; + DWORD transId; // transaction id + + MGCP_PARA para; // operation specific parameters, used for command +// MGCP_PARA paraAux; // auxilliary parameters, used for response +}MGCP_PORT; + +typedef struct _MGCP_RET_CODE +{ + WORD retCode; + char desc[64]; +}MGCP_RET_CODE; + +#endif diff --git a/omc/plat/mgcp/src/include/mgcp_trans.h b/omc/plat/mgcp/src/include/mgcp_trans.h new file mode 100644 index 0000000..3fd645a --- /dev/null +++ b/omc/plat/mgcp/src/include/mgcp_trans.h @@ -0,0 +1,8 @@ +#ifndef _MGCP_TRANS__H +#define _MGCP_TRANS__H + +void mgcp_trans_proc(); +int mgcp_match_client_trans(DWORD transId); +int mgcp_match_server_trans(DWORD transId); + +#endif diff --git a/omc/plat/mgcp/src/mgcp.c b/omc/plat/mgcp/src/mgcp.c new file mode 100644 index 0000000..c813a9a --- /dev/null +++ b/omc/plat/mgcp/src/mgcp.c @@ -0,0 +1,249 @@ +/****************************************************************/ +/* MGCP Implementation Program */ +/* Version 9.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2007-3-26 */ +/****************************************************************/ + +#include "./include/mgcp_pub.h" +#include "./include/mgcp.h" +#include "./include/mgcp_const.h" +#include "./include/mgcp_def.h" +#include "./include/mgcp_struct.h" +#include "./include/mgcp_msg.h" +#include "./include/mgcp_trans.h" +#include "./include/mgcp_debug.h" + +void mgcp_init(void) +{ + printf("MGCP Init Start!\n"); + + memset((BYTE *) &mgcpSap[0], 0, sizeof(MGCP_SAP) * MGCP_MAX_NUM_OF_SAP); + memset((BYTE *) &mgcpPort[0], 0, sizeof(MGCP_PORT) * MGCP_MAX_NUM_OF_PORT); + memset((BYTE *) &mgcpTransStart[0], 0, sizeof(WORD) * MGCP_MAX_NUM_OF_PORT); + + mgcpPortSelect = 1; + + mgcp_debug_set(); + + printf("MGCP Init Complete!\n"); +} + +// Called every 10 ms +void mgcp_t10ms() +{ + static DWORD cnt_10ms = 0; + + if (!(++cnt_10ms % 10)) + { // 100 ms + mgcp_mon(); + } +} + +void mgcp_timer(void) +{ + mgcp_recv_msg(); + mgcp_trans_proc(); + + mgcp_t10ms(); +} + +int mgcp_sap_init(BYTE sapIndex) +{ + if (sapIndex >= MGCP_MAX_NUM_OF_SAP) + return -1; + + memset((BYTE *) &mgcpSap[sapIndex], 0, sizeof(MGCP_SAP)); + + return 0; +} + +int mgcp_port_init(WORD port) +{ + if(port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + memset((BYTE *) &mgcpPort[port], 0, sizeof(MGCP_PORT)); + + return 0; +} + +int mgcp_bind(MGCP_SAP *sap) +{ + if ((sap == NULL) || + (sap->MGCP_ind == NULL) || + (sap->MGCP_cnf == NULL)) + return -1; + + if ((mgcpSap[0].MGCP_ind != NULL) || + (mgcpSap[0].MGCP_cnf != NULL)) + return -1; + + memcpy((BYTE *) &mgcpSap[0], sap, sizeof(MGCP_SAP)); + mgcpSap[0].name[MGCP_MAX_USER_NAME_LEN - 1] = '\0'; + + return 0; +} + +int mgcp_unbind(MGCP_SAP *sap, BYTE sapIndex) +{ + if ((sap == NULL) || (sapIndex >= MGCP_MAX_NUM_OF_SAP)) + return -1; + + if (strcmp(sap->name, mgcpSap[sapIndex].name) != 0) + return -1; + + if (mgcp_sap_init(sapIndex) < 0) + return -1; + + return 0; +} + +int mgcp_get_port() +{ + WORD port = mgcpPortSelect; + WORD i; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || (port == 0)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mgcpPortSelect may be changed\n port=%d\n", port); + mgcp_log_err(mgcpAsciTempBuf); + } + + port = 1; + } + + for (i = 1; i < MGCP_MAX_NUM_OF_PORT; i++) + { + if (mgcpPort[port].flag == 1) + { + if (++port >= MGCP_MAX_NUM_OF_PORT) + port = 1; + continue; + } + mgcpPort[port].flag = 1; + mgcpPortSelect = port + 1; + if (mgcpPortSelect >= MGCP_MAX_NUM_OF_PORT) + mgcpPortSelect = 1; + return port; + } + + return -1; +} + +int MGCP_req(BYTE sapIndex, BYTE cmd, WORD usrPort, MGCP_PARA *para) +{ + int port; + + if ((sapIndex >= MGCP_MAX_NUM_OF_SAP) || + (cmd < MGCP_CMD_CRCX) || + (cmd > MGCP_CMD_RSIP) || + (para == NULL)) + return -1; + + if ((port = mgcp_get_port()) < 0) + return -1; + + mgcpPort[port].sapIndex = sapIndex; + mgcpPort[port].usrPort = usrPort; + mgcpPort[port].cmd = cmd; + mgcpPort[port].reqInd = MGCP_REQUEST; + + memcpy((BYTE *) &mgcpPort[port].para, para, sizeof(MGCP_PARA)); + + return port; +} + +int MGCP_cancel_req(BYTE sapIndex, BYTE cmd, WORD usrPort, WORD hdlPort) +{ + MGCP_PORT *trans; + + if ((sapIndex >= MGCP_MAX_NUM_OF_SAP) || + (cmd < MGCP_CMD_CRCX) || + (cmd > MGCP_CMD_RSIP) || + (hdlPort >= MGCP_MAX_NUM_OF_PORT) || + (hdlPort == 0)) + return -1; + + trans = &mgcpPort[hdlPort]; + if ((trans->cmd != cmd) || + (trans->reqInd != MGCP_REQUEST)) + return -1; + + trans->cmd = 0; + + return 0; +} + +int MGCP_rsp(BYTE sapIndex, BYTE cmd, WORD usrPort, WORD hdlPort, WORD retCode, MGCP_PARA *para) +{ + if ((sapIndex >= MGCP_MAX_NUM_OF_SAP) || + (cmd < MGCP_CMD_CRCX) || + (cmd > MGCP_CMD_RSIP) || + (para == NULL) || + (hdlPort >= MGCP_MAX_NUM_OF_PORT) || + (hdlPort == 0)) + return -1; + + memcpy((BYTE *) &mgcpPort[hdlPort].para, para, sizeof(MGCP_PARA)); + + if ((retCode >=200) && (retCode < 300)) + { + mgcpPort[hdlPort].para.sl.retCode = retCode; + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_TRANS_OK_INDEX].desc); + } + else if ((retCode >=100) && (retCode < 200)) + { + mgcpPort[hdlPort].para.sl.retCode = retCode; + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_TEMP_RSP_INDEX].desc); + } + else + { + mgcpPort[hdlPort].para.sl.retCode = retCode; + switch(retCode) + { + case MGCP_RET_CODE_TRANS_TIME_OUT: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_TRANS_TIME_OUT_INDEX].desc); + + case MGCP_RET_CODE_INTERNAL_OVERLOAD: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_TRANS_TIME_OUT_INDEX].desc); + + case MGCP_RET_CODE_UNEP: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNEP_INDEX].desc); + + case MGCP_RET_CODE_UNCMD: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNCMD_INDEX].desc); + + case MGCP_RET_CODE_RCD_ERR: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_RCD_ERR_INDEX].desc); + + case MGCP_RET_CODE_INCONID: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_INCONID_INDEX].desc); + + case MGCP_RET_CODE_UNCLLID: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNCLLID_INDEX].desc); + + case MGCP_RET_CODE_UNMD: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNMD_INDEX].desc); + + case MGCP_RET_CODE_UNPKG: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNPKG_INDEX].desc); + + case MGCP_RET_CODE_NES: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_NES_INDEX].desc); + + case MGCP_RET_CODE_ILCO: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_ILCO_INDEX].desc); + + case MGCP_RET_CODE_UNRM: + strcpy(mgcpPort[hdlPort].para.sl.desc, mgcpRetCode[MGCP_RET_CODE_UNRM_INDEX].desc); + + default: + strcpy(mgcpPort[hdlPort].para.sl.desc, "FAILED"); + } + } + + return 0; +} diff --git a/omc/plat/mgcp/src/mgcp_debug.c b/omc/plat/mgcp/src/mgcp_debug.c new file mode 100644 index 0000000..e09832b --- /dev/null +++ b/omc/plat/mgcp/src/mgcp_debug.c @@ -0,0 +1,585 @@ +#include "./include/mgcp_pub.h" +#include "./include/mgcp.h" +#include "./include/mgcp_const.h" +#include "./include/mgcp_struct.h" +#include "./include/mgcp_ext.h" +#include "../../debug/src/include/debug.h" + +#define MGCP_DEBUG_ID 19 +#define MGCP_VER_DEBUG "R9V0_02" + +extern char *mgcp_clrncpy(char *dst, char *src, WORD len); + +static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + +static BYTE log_help[] = { +"MGCP 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\n\r\ +4.[log mg-mg_name on/off] display MGCP specific mg msg logs\n\r\ +5.[list] display all mg which have been log\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,MGCP_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,MGCP_DEBUG_ID + 2,2 + }; + +static DWORD debug_ascin_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGCP_DEBUG_ID + 2,3 + }; + +static DWORD debug_ascout_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGCP_DEBUG_ID + 2,4 + }; + +static DWORD debug_page_title[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGCP_DEBUG_ID + 2,1,1 + }; + +static DWORD debug_page_line[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,MGCP_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[] = +{ + " MGCP Page 01 mgcpPort Status\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Trans_Status\n\r" +}; + +BYTE mgcp_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 + disp_ptr = (BYTE *) &mgcpPort[disp_page[page]]; + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +void mgcp_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 = mgcp_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 mgcp_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, MGCP_VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, mgcpAsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, mgcpAsciOutBuf, 4096); + + for (page = 1; page < 2; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + default: + break; + } + + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + mgcp_disp_page(page); + } + + return 1; +} + +int mgcp_asciout_proc(BYTE *outStr) +{ + int outLen; + + outLen = strlen(outStr); + + if (outLen + strlen(mgcpAsciOutBuf) > MGCP_MAX_ASCIIOUT_LEN - 2) + { + strcpy(mgcpAsciOutBuf, outStr); + } + else + strcat(mgcpAsciOutBuf, outStr); + + return 1; +} + +void mgcp_mon(void) +{ + BYTE inPage, errFg = 0; + BYTE *asciiInPtr = NULL; + BYTE *mgNM = NULL; +// BYTE *trkNM = NULL; +// BYTE *chlNM = NULL; + BYTE *poo = NULL; + BYTE *strStart = NULL; + BYTE tmp[128]; +// BYTE tmptrkNum; +// WORD tmpchlNum; + WORD strLen, num; + + if ((strLen = strlen(mgcpAsciInBuf)) > 0) + { + inPage = mgcpAsciInBuf[0] - 1; + asciiInPtr = mgcpAsciInBuf + 1; + + if (inPage > 7) + errFg = 1; + else if (strcmp(asciiInPtr,"c") == 0) + { + } + else if (strcmp(asciiInPtr,"log error on") == 0) + { + mgcpMonitorFg = mgcpMonitorFg | MONITOR_ERROR; + } + else if (strcmp(asciiInPtr,"log error off") == 0) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_ERROR); + } + else if (strncmp(asciiInPtr,"log mg-", 7) == 0) + { + if (NULL == (poo = strrchr(asciiInPtr, 'o'))) + { + errFg = 1; + } + else + { + mgNM = strchr(asciiInPtr, '-'); + + if (poo <= mgNM) + { + errFg = 1; + } + else + { + mgcp_clrncpy(tmp, mgNM+1, poo-mgNM-1); + + if (0 == strcmp(poo, "on")) + { + if(mgcpMonitorFg == MONITOR_ALL) + { + mgcp_asciout_proc("Status is log all\n\r"); + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + && ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + && ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) + &&(mgcpMonitorFg != MONITOR_ALL)) + + { + mgcp_asciout_proc("Can not log more MG\n\r"); + } + else + { + if ((((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) && (0 == strcmp(dbgmgNamemg[0], tmp))) + || (((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) && (0 == strcmp(dbgmgNamemg[1], tmp))) + || (((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) && (0 == strcmp(dbgmgNamemg[2], tmp)))) + { + mgcp_asciout_proc("MG already be on\n\r"); + } + else + { + if (((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) && (0 == strcmp(dbgmgNamemg[0], tmp))) + { + mgcpMonitorFg |= MONITOR_MG0_MSG; + } + else if (((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) && (0 == strcmp(dbgmgNamemg[1], tmp))) + { + mgcpMonitorFg |= MONITOR_MG1_MSG; + } + else if (((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) && (0 == strcmp(dbgmgNamemg[2], tmp))) + { + mgcpMonitorFg |= MONITOR_MG2_MSG; + } + else if ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) + { + strcpy(dbgmgNamemg[0], tmp); + + mgcpMonitorFg |= MONITOR_MG0_MSG; + } + else if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + strcpy(dbgmgNamemg[1], tmp); + + mgcpMonitorFg |= MONITOR_MG1_MSG; + } + else + { + strcpy(dbgmgNamemg[2], tmp); + + mgcpMonitorFg |= MONITOR_MG2_MSG; + } + } + } + } + else if (0 == strcmp(poo, "off")) + { + if (mgcpMonitorFg == MONITOR_NONE) + { + mgcp_asciout_proc("Status is log none\n\r"); + } + else if((mgcpMonitorFg == MONITOR_ALL) + ||((mgcpMonitorFg | MONITOR_MG0_MSG | MONITOR_MG1_MSG | MONITOR_MG2_MSG | MONITOR_ERROR) == MONITOR_ALL)) + { + if (mgcpMonitorFg == MONITOR_ALL) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG0_MSG); + strcpy(dbgmgNamemg[0], tmp); + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + ||((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + ||((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG)) + { + if(((0 == strcmp(dbgmgNamemg[0], tmp)) && ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0)) + ||((0 == strcmp(dbgmgNamemg[1], tmp)) && ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0)) + ||((0 == strcmp(dbgmgNamemg[2], tmp)) && ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0))) + { + mgcp_asciout_proc("MG already be off\n\r"); + } + else if ((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG0_MSG); + strcpy(dbgmgNamemg[0], tmp); + } + else if ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG1_MSG); + strcpy(dbgmgNamemg[1], tmp); + } + else + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG2_MSG); + strcpy(dbgmgNamemg[2], tmp); + } + } + else + { + mgcp_asciout_proc("Can not off more MG\n\r"); + } + } + else if (0 == strcmp(dbgmgNamemg[0], tmp)) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG0_MSG); + } + else if (0 == strcmp(dbgmgNamemg[1], tmp)) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG1_MSG); + } + else if (0 == strcmp(dbgmgNamemg[2], tmp)) + { + mgcpMonitorFg = mgcpMonitorFg & (~MONITOR_MG2_MSG); + } + else + { + mgcp_asciout_proc("MG has not been on\n\r"); + } + } + else + { + errFg = 1; + } + } + } + } +/* else if (strncmp(asciiInPtr,"log trk-", 8) == 0) + { + if (NULL == (poo = strrchr(asciiInPtr, 'o'))) + { + errFg = 1; + } + else + { + + mgNM = strchr(asciiInPtr, '-'); + + if (NULL == (trkNM = strchr(mgNM+1, '-'))) + { + errFg = 1; + } + else + { + mgcp_clrncpy(tmp, mgNM+1, trkNM-mgNM-1); + + tmptrkNum = strtoul(trkNM+1, NULL, 10); + + if (0 == strcmp(poo, "on")) + { + strcpy(dbgmgNametrk, tmp); + + dbgtrkNumtrk = tmptrkNum; + + mgcpMonitorFg |= MONITOR_TRK_MSG; + } + else if (0 == strcmp(poo, "off")) + { + if ((0 == strcmp(dbgmgNamemg, tmp))||((0 == strcmp(dbgmgNametrk, tmp))&&(dbgtrkNumtrk == tmptrkNum))) + { + strcpy(dbgmgNametrk, tmp); + + dbgtrkNumtrk = tmptrkNum; + + mgcpMonitorFg &= (~MONITOR_TRK_MSG); + } + else + { + mgcp_asciout_proc("trk already be off!\n\r"); + } + } + else + { + errFg = 1; + } + } + } + } + else if (strncmp(asciiInPtr,"log chl-", 8) == 0) + { + if (NULL == (poo = strrchr(asciiInPtr, 'o'))) + { + errFg = 1; + } + else + { + + mgNM = strchr(asciiInPtr, '-'); + + if (NULL == (trkNM = strchr(mgNM+1, '-'))) + { + errFg = 1; + } + else + { + if (NULL == (chlNM = strchr(trkNM, '-'))) + { + errFg = 1; + } + else + { + + mgcp_clrncpy(tmp, mgNM+1, trkNM-mgNM-1); + + tmptrkNum = strtoul(trkNM+1, NULL, 10); + + tmpchlNum = strtoul(chlNM+1, NULL, 10); + + if (0 == strcmp(poo, "on")) + { + strcpy(dbgmgNamechl, tmp); + + dbgtrkNumchl = tmptrkNum; + + dbgchlNumchl = tmpchlNum; + + mgcpMonitorFg |= MONITOR_TRK_MSG; + } + else if (0 == strcmp(poo, "off")) + { + if ((0 == strcmp(dbgmgNamemg, tmp))||((0 == strcmp(dbgmgNametrk, tmp))&&(dbgtrkNumtrk == tmptrkNum)) + ||((0 == strcmp(dbgmgNamechl, tmp))&&(dbgtrkNumchl == tmptrkNum)&&(dbgchlNumchl == tmpchlNum))) + { + strcpy(dbgmgNamechl, tmp); + + dbgtrkNumchl = tmptrkNum; + + dbgchlNumchl = tmpchlNum; + + mgcpMonitorFg &= (~MONITOR_TRK_MSG); + } + else + { + mgcp_asciout_proc("chl already be off!\n\r"); + } + } + else + { + errFg = 1; + } + } + } + } + } + */ + + else if (strcmp(asciiInPtr, "list") == 0) + { + if ((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + { + sprintf(mgcpAsciTempBuf, "MG :%s on\r\n", dbgmgNamemg[0]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "MG :%s off\r\n", dbgmgNamemg[0]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + { + sprintf(mgcpAsciTempBuf, "MG :%s on\r\n", dbgmgNamemg[1]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "MG :%s off\r\n", dbgmgNamemg[1]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) + { + sprintf(mgcpAsciTempBuf, "MG :%s on\r\n", dbgmgNamemg[2]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "MG :%s off\r\n", dbgmgNamemg[2]); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + + else if (strcmp(asciiInPtr,"log all") == 0) + { + strcpy(dbgmgNamemg[0], ""); + strcpy(dbgmgNamemg[1], ""); + strcpy(dbgmgNamemg[2], ""); + mgcpMonitorFg = MONITOR_ALL; + } + else if (strcmp(asciiInPtr,"log none") == 0) + { + strcpy(dbgmgNamemg[0], ""); + strcpy(dbgmgNamemg[1], ""); + strcpy(dbgmgNamemg[2], ""); + mgcpMonitorFg = MONITOR_NONE; + } + else if (strcmp(asciiInPtr,"help") == 0) + { + mgcp_asciout_proc(log_help); + } + else if (isdigit(asciiInPtr[0])) + { + num = strtoul(asciiInPtr, NULL, 10); + disp_page[inPage] = num; + mgcp_disp_page(inPage); + } + else if ((strStart = strstr(asciiInPtr, ">")) != NULL) + { + num = strtoul(strStart + 1, NULL, 10); + disp_page[inPage] += num; + mgcp_disp_page(inPage); + } + else if ((strStart = strstr(asciiInPtr, "<"))!= NULL) + { + num = strtoul(strStart + 1, NULL, 10); + disp_page[inPage] -= num; + mgcp_disp_page(inPage); + } + else + errFg = 1; + + if (errFg == 0) + mgcp_asciout_proc("Command OK!\n\r"); + else + mgcp_asciout_proc("Command Error!\n\r"); + + strcpy(mgcpAsciInBuf, "\0"); + } +} + +int mgcp_hex_to_ascii(BYTE *fromHex, BYTE fromLen, BYTE *toAsc) +{ + int i, j; + + j = 0; + + for (i = 0; i< fromLen; i++) + { + toAsc[j] = ascii[fromHex[i] >> 4]; + j++; + toAsc[j] = ascii[fromHex[i] & 0x0F]; + j++; + toAsc[j] = ' '; + j++; + } + + toAsc[j] = '\0'; + + return 1; +} + +int mgcp_log_err(BYTE *errMsg) +{ + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + mgcp_asciout_proc("\33[31m"); + if (strlen(errMsg) >= MGCP_MAX_ASCITMP_LEN) + sprintf(mgcpAsciTempBuf, "log msg is too long: %d\n\r", strlen(errMsg)); + else + sprintf(mgcpAsciTempBuf, "%s\n\r", errMsg); + strcat(mgcpAsciTempBuf, "\33[37m"); + mgcp_asciout_proc(mgcpAsciTempBuf); + } + + return 1; +} diff --git a/omc/plat/mgcp/src/mgcp_msg.c b/omc/plat/mgcp/src/mgcp_msg.c new file mode 100644 index 0000000..9ac3005 --- /dev/null +++ b/omc/plat/mgcp/src/mgcp_msg.c @@ -0,0 +1,2740 @@ +#include "./include/mgcp_pub.h" +#include "./include/mgcp.h" +#include "./include/mgcp_const.h" +#include "./include/mgcp_ext.h" +#include "./include/mgcp_struct.h" +#include "./include/mgcp_trans.h" +#include "./include/mgcp_msg.h" + +extern int mgcp_get_port(); +extern void mgcp_port_init(WORD port); +extern int mgcp_log_err(BYTE *errMsg); +extern int mgcp_asciout_proc(BYTE *outStr); + +int mgcp_cmd_str_to_api(char *str, BYTE *cmd) +{ + if (strcasecmp(str, "CRCX") == 0) + *cmd = MGCP_CMD_CRCX; + else if (strcasecmp(str, "MDCX") == 0) + *cmd = MGCP_CMD_MDCX; + else if (strcasecmp(str, "DLCX") == 0) + *cmd = MGCP_CMD_DLCX; + else if (strcasecmp(str, "RQNT") == 0) + *cmd = MGCP_CMD_RQNT; + else if (strcasecmp(str, "NTFY") == 0) + *cmd = MGCP_CMD_NTFY; + else if (strcasecmp(str, "AUEP") == 0) + *cmd = MGCP_CMD_AUEP; + else if (strcasecmp(str, "RSIP") == 0) + *cmd = MGCP_CMD_RSIP; + else + { + return -1; + } + + return 0; +} + +int mgcp_mgtype_str_to_api(char *str, BYTE *mgtp, BYTE *porttp) +{ + if (strcasecmp(str, "e1") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_E1; + } + else if (strcasecmp(str, "t1") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_T1; + } + else if (strcasecmp(str, "ann") == 0) + { + *mgtp = MGCP_MG_TYPE_ANN; + *porttp = 0; + } + else if (strcasecmp(str, "aaln") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_AALN; + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong mg type\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_mode_str_to_api(char *str, BYTE *md) +{ + if (strcasecmp(str, "inactive") == 0) + *md = MGCP_CON_MODE_INACTIVE; + else if (strcasecmp(str, "recvonly") == 0) + *md = MGCP_CON_MODE_RECVONLY; + else if (strcasecmp(str, "sendonly") == 0) + *md = MGCP_CON_MODE_SENDONLY; + else if (strcasecmp(str, "sendrecv") == 0) + *md = MGCP_CON_MODE_SENDRECV; + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong connect mode\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_rm_str_to_api(char *str, BYTE *rm) +{ + if (strcasecmp(str, "restart") == 0) + *rm = MGCP_RST_MODE_RESTART; + else if (strcasecmp(str, "forced") == 0) + *rm = MGCP_RST_MODE_FORCED; + else if (strcasecmp(str, "disconnected") == 0) + *rm = MGCP_RST_MODE_DISCONNECTED; + else if (strcasecmp(str, "graceful") == 0) + *rm = MGCP_RST_MODE_GRACEFUL; + else if (strcasecmp(str, "cancel-graceful") == 0) + *rm = MGCP_RST_MODE_CANCEL_GRACEFUL; + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong restart mode\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_pkg_str_to_api(char *str, BYTE *pkg) +{ + if (strcasecmp(str, "L") == 0) + *pkg = MGCP_PKG_L; + else if (strcasecmp(str, "D") == 0) + *pkg = MGCP_PKG_D; + else if (strcasecmp(str, "G") == 0) + *pkg = MGCP_PKG_G; + else + return -1; + + return 0; +} + +int mgcp_sig_str_to_api(char *str, BYTE *sig, BYTE pkg) +{ + if (MGCP_PKG_L == pkg) + { + if (strcasecmp(str, "aw") == 0) + *sig = MGCP_L_SIG_AW; + else if (strcasecmp(str, "dl") == 0) + *sig = MGCP_L_SIG_DL; + else if (strcasecmp(str, "bz") == 0) + *sig = MGCP_L_SIG_BZ; + else if (strcasecmp(str, "wt") == 0) + *sig = MGCP_L_SIG_WT; + else if (strcasecmp(str, "nbz") == 0) + *sig = MGCP_L_SIG_NBZ; + else if (strcasecmp(str, "rg") == 0) + *sig = MGCP_L_SIG_RG; + else if (strcasecmp(str, "e") == 0) + *sig = MGCP_L_SIG_E; + else if (strcasecmp(str, "ot") == 0) + *sig = MGCP_L_SIG_OT; + else + return -1; + } + else if (MGCP_PKG_D == pkg) + { + if (strcasecmp(str, "0") == 0) + *sig = MGCP_D_SIG_ZERO; + else if (strcasecmp(str, "1") == 0) + *sig = MGCP_D_SIG_ONE; + else if (strcasecmp(str, "2") == 0) + *sig = MGCP_D_SIG_TWO; + else if (strcasecmp(str, "3") == 0) + *sig = MGCP_D_SIG_THREE; + else if (strcasecmp(str, "4") == 0) + *sig = MGCP_D_SIG_FOUR; + else if (strcasecmp(str, "5") == 0) + *sig = MGCP_D_SIG_FIVE; + else if (strcasecmp(str, "6") == 0) + *sig = MGCP_D_SIG_SIX; + else if (strcasecmp(str, "7") == 0) + *sig = MGCP_D_SIG_SEVEN; + else if (strcasecmp(str, "8") == 0) + *sig = MGCP_D_SIG_EIGHT; + else if (strcasecmp(str, "9") == 0) + *sig = MGCP_D_SIG_NINE; + else if (strcasecmp(str, "#") == 0) + *sig = MGCP_D_SIG_POUND; + else if (strcasecmp(str, "*") == 0) + *sig = MGCP_D_SIG_STAR; + else + return -1; + } + else if (MGCP_PKG_G == pkg) + { + if (strcasecmp(str, "rt") == 0) + *sig = MGCP_G_SIG_RT; + else if (strcasecmp(str, "cf") == 0) + *sig = MGCP_G_SIG_CF; + else if (strcasecmp(str, "cg") == 0) + *sig = MGCP_G_SIG_CG; + else if (strcasecmp(str, "it") == 0) + *sig = MGCP_G_SIG_IT; + else if (strcasecmp(str, "pt") == 0) + *sig = MGCP_G_SIG_PT; + else + return -1; + } + else + return -1; + + return 0; +} + +int mgcp_event_str_to_api(char *str, BYTE *ent, BYTE pkg) +{ + if (MGCP_PKG_L == pkg) + { + if (strcasecmp(str, "hd") == 0) + *ent = MGCP_L_EVENT_HD; + else if (strcasecmp(str, "hu") == 0) + *ent = MGCP_L_EVENT_HU; + else if (strcasecmp(str, "hf") == 0) + *ent = MGCP_L_EVENT_HF; + else if (strcasecmp(str, "aw") == 0) + *ent = MGCP_L_EVENT_AW; + else if (strcasecmp(str, "nbz") == 0) + *ent = MGCP_L_EVENT_NBZ; + else if (strcasecmp(str, "e") == 0) + *ent = MGCP_L_EVENT_E; + else if (strcasecmp(str, "oc") == 0) + *ent = MGCP_L_EVENT_OC; + else if (strcasecmp(str, "of") == 0) + *ent = MGCP_L_EVENT_OF; + else + return -1; + } + else if (MGCP_PKG_D == pkg) + { + if (strcasecmp(str, "0") == 0) + *ent = MGCP_D_EVENT_ZERO; + else if (strcasecmp(str, "1") == 0) + *ent = MGCP_D_EVENT_ONE; + else if (strcasecmp(str, "2") == 0) + *ent = MGCP_D_EVENT_TWO; + else if (strcasecmp(str, "3") == 0) + *ent = MGCP_D_EVENT_THREE; + else if (strcasecmp(str, "4") == 0) + *ent = MGCP_D_EVENT_FOUR; + else if (strcasecmp(str, "5") == 0) + *ent = MGCP_D_EVENT_FIVE; + else if (strcasecmp(str, "6") == 0) + *ent = MGCP_D_EVENT_SIX; + else if (strcasecmp(str, "7") == 0) + *ent = MGCP_D_EVENT_SEVEN; + else if (strcasecmp(str, "8") == 0) + *ent = MGCP_D_EVENT_EIGHT; + else if (strcasecmp(str, "9") == 0) + *ent = MGCP_D_EVENT_NINE; + else if (strcasecmp(str, "#") == 0) + *ent = MGCP_D_EVENT_POUND; + else if (strcasecmp(str, "*") == 0) + *ent = MGCP_D_EVENT_STAR; + else + return -1; + } + else if (MGCP_PKG_G == pkg) + { + if (strcasecmp(str, "mt") == 0) + *ent = MGCP_G_EVENT_MT; + else if (strcasecmp(str, "ft") == 0) + *ent = MGCP_G_EVENT_FT; + else if (strcasecmp(str, "ld") == 0) + *ent = MGCP_G_EVENT_LD; + else if (strcasecmp(str, "of") == 0) + *ent = MGCP_G_EVENT_OF; + else + return -1; + } + else + return -1; + + return 0; +} + +void mgcp_util_replace_all_lws(char *msg) +{ + char *tmp; + + if (msg == NULL) + return; + tmp = msg; + + for (; tmp[0] != '\0'; tmp++) + { + if (('\0' == tmp[0]) || ('\0' == tmp[1]) || + ('\0' == tmp[2]) || ('\0' == tmp[3])) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ('\r' == tmp[2]) && ('\n' == tmp[3])) || + (('\r' == tmp[0]) && ('\r' == tmp[1])) || + (('\n' == tmp[0]) && ('\n' == tmp[1]))) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ((' ' == tmp[2]) || ('\t' == tmp[2]))) || + (('\r' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1]))) || + (('\n' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1])))) + { + // Replace line end and TAB symbols by SP + tmp[0] = ' '; + tmp[1] = ' '; + tmp = tmp + 2; + // Replace all following TAB symbols + for (; ('\t' == tmp[0] || ' ' == tmp[0]); ) + { + tmp[0] = ' '; + tmp++; + } + } + } +} + +int mgcp_find_next_crlf(char *startOfHeader, char **endOfHeader) +{ + char *soh = startOfHeader; + + *endOfHeader = NULL; + + while (('\r' != *soh) && ('\n' != *soh)) + { + if (*soh) + soh++; + else + { + printf("Final CRLF is missing\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Final CRLF is missing\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + } + + // case 1: CRLF is the separator + // case 2 or 3: CR or LF is the separator + if (('\r' == soh[0]) && ('\n' == soh[1])) + soh = soh + 1; + + // VERIFY if TMP is the end of header or LWS. + // LWS are extra SP, HT, CR and LF contained in headers. + if ((' ' == soh[1]) || ('\t' == soh[1])) + { + // incoming message that potentially + // contains LWS must be processed with + // mgcp_util_replace_all_lws(char *) + printf("Message that contains LWS must be processed with sip_util_replace_all_lws(char *tmp) before being parsed.\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Message that contains LWS must be processed with sip_util_replace_all_lws(char *tmp) before being parsed.\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + *endOfHeader = soh + 1; + + return 0; +} + +char *mgcp_clrncpy(char *dst, char *src, WORD len) +{ + char *pbeg; + char *pend; + char *p; + WORD spaceLessLength; + + if ((src == NULL) || (len == 0)) + return NULL; + + // find the start of relevant text + pbeg = src; + while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg)) + pbeg++; + + // find the end of relevant text + pend = src + len - 1; + while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend)) + { + pend--; + if (pend < pbeg) + { + *dst = '\0'; + return dst; + } + } + + // if pend == pbeg there is only one char to copy + spaceLessLength = pend - pbeg + 1; // excluding any '\0' + memcpy(dst, pbeg, spaceLessLength); + p = dst + spaceLessLength; + + // terminate the string and pad dest with zeros until len + do + { + *p = '\0'; + p++; + spaceLessLength++; + } + while (spaceLessLength < len); + + return dst; +} + +int mgcp_msg_start_line_parse_resp(char *buf, char **nextHeader) +{ + char *hp; + char tmp[128]; + char *statusCode; + char *transId; + char *endoftransId; + MGCP_SL *sl; + WORD retCode; + DWORD transIdValue; + int port; + + *nextHeader = buf; + + statusCode = strchr(buf, ' '); // Search for first SPACE + if (statusCode == NULL) + return -1; + mgcp_clrncpy(tmp, buf, statusCode - buf); + retCode = strtoul(tmp, NULL, 10); + + transId = strchr(statusCode + 1, ' '); + if (transId == NULL) + return -1; + + mgcp_clrncpy(tmp, statusCode + 1, transId - statusCode - 1); + transIdValue = strtoul(tmp, &endoftransId, 10); + if ('\0' != endoftransId[0]) + { + printf("the space of transId is at wrong position.\n"); + return -1; + } + + if ((port = mgcp_match_client_trans(transIdValue)) < 0) + return -1; + + memset(&mgcpRespPara, 0, sizeof(MGCP_PARA)); + + sl = &mgcpRespPara.sl; + sl->cmdRes = MGCP_RESPONSE; + sl->retCode = retCode; + sl->transId = transIdValue; + + hp = transId; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + printf("No crlf found\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "No crlf found\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + } + mgcp_clrncpy(sl->desc, transId + 1, hp - transId - 1); + + hp++; + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + (*nextHeader) = hp; + + return port; +} + +int mgcp_msg_start_line_parse_cmd(int *portAllocated, char *buf, char **nextHeader) +{ + char *hp; + char tmp[128]; + char *cmdName; + char *transId; + char *mgName; + char *endmgName; + char *trkNum; + char *chlNum; + char *endoftransId; + char mgtype[128]; + char *mgtypeslash; + MGCP_SL *sl; + MGCP_PARA *para; + MGCP_PORT *trans; + int port; + BYTE cmd; + BYTE mgtp; + BYTE porttp; + DWORD transID; + + *portAllocated = -1; + + *nextHeader = buf; + + cmdName = strchr(buf, ' '); // Search for first SPACE + if (cmdName == NULL) + return -1; + mgcp_clrncpy(tmp, buf, cmdName - buf); + + mgcp_cmd_str_to_api(tmp, &cmd); +/*{ + return -1; + } +*/ + transId = strchr(cmdName + 1, ' '); + if (transId == NULL) + return -1; + + mgcp_clrncpy(tmp, cmdName + 1, transId - cmdName - 1); + transID = strtoul(tmp, &endoftransId, 10); + if ('\0' != endoftransId[0]) + { + printf("the space of transId is at wrong position.\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "the space of transId is at wrong position.\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + if ((cmdMGCP_CMD_RSIP)) + { + printf("unknown or unsupport command\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unknown or unsupport command\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNCMD_INDEX); + return -1; + } + + if ((port = mgcp_match_server_trans(transID)) >= 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Find the same transID\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -2; + } + + if ((port = mgcp_get_port()) < 0) + { + return -1; + } + *portAllocated = port; + + trans = &mgcpPort[port]; + para = &trans->para; + sl = ¶->sl; + + hp = transId; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + printf("No crlf found\n"); + return -1; + } + } + mgcp_clrncpy(tmp, transId + 1, hp - transId - 1); + + if ((mgName = strchr(tmp, '@')) == NULL) + { + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if ((endmgName = strstr(mgName, " ")) == NULL) + { + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (NULL == mgcp_clrncpy(sl->mgName, mgName+1, endmgName-mgName-1)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown:no domain name\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (isdigit(tmp[0])||(tmp[0]=='*')) + { + sl->epNameMethod = MGCP_EP_NAME_UNSTRUCTURED; + if (tmp[0] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(tmp, NULL, 10); + } + else + { + sl->epNameMethod = MGCP_EP_NAME_STRUCTURED; + if (((trkNum = strchr(tmp, '-')) != NULL) + && (trkNum < mgName)) + { + if (((mgtypeslash = strchr(tmp, '/')) == NULL) || (mgtypeslash >= trkNum)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + mgcp_clrncpy(mgtype, mgtypeslash +1, trkNum - mgtypeslash - 1); + + if (mgcp_mgtype_str_to_api(mgtype, &mgtp, &porttp) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if ('*' == trkNum[1]) + { + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + } + else + { + sl->trkNum = strtoul(trkNum + 1, NULL, 10); + } + + if ((chlNum = strchr(trkNum + 1, '/')) != NULL) + { + if (chlNum[1] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(chlNum + 1, NULL, 10); + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + else if(((NULL == trkNum) && ('a' == tmp[0])) + || ((trkNum != NULL) && (trkNum >= mgName))) + { + if ((chlNum = strchr(tmp, '/')) != NULL) + { + mgcp_clrncpy(mgtype, tmp, chlNum - tmp); + + if (mgcp_mgtype_str_to_api(mgtype, &mgtp, &porttp) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (MGCP_PORT_TYPE_AALN == porttp) + { + if (chlNum[1] == '*') + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + else + sl->trkNum = strtoul(chlNum + 1, NULL, 10); + + sl->chlNum = 0; + } + else + { + if (chlNum[1] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(chlNum + 1, NULL, 10); + + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + + trans->transId = transID; + trans->cmd = cmd; + + para->ip = mgcpRvMsg.msgSrcIP; + para->peerPort = mgcpRvMsg.msgSrcPort; + para->localPort = mgcpRvMsg.msgDstPort; + +// mgcp_clrncpy(sl->mgName, mgName+1, endmgName-mgName-1); + sl->cmdRes = MGCP_COMMAND; + sl->transId = transID; + sl->mgType = mgtp; + sl->portType = porttp; + + hp++; + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + (*nextHeader) = hp; + + return port; +} + +int mgcp_msg_start_line_parse(BYTE *cmdRes, char *buf, char **nextHeader) +{ + int port = -1; + int ret; + + if (isdigit(buf[0])) + { + if ((port = mgcp_msg_start_line_parse_resp(buf, nextHeader)) < 0) + return -1; + *cmdRes = MGCP_RESPONSE; + } + else + { + if ((ret = mgcp_msg_start_line_parse_cmd(&port, buf, nextHeader)) < 0) + { + if (port >= 0) + mgcp_port_init(port); + + if (ret == -2) + return -2; + else + return -1; + } + mgcpPort[port].reqInd = MGCP_INDICATION; + *cmdRes = MGCP_COMMAND; + } + + return port; +} + +int mgcp_con_id_parse(MGCP_I *conId, char *value) +{ + if (NULL == value) + return -1; + + strcpy(conId->conId, value); + return 0; +} + +int mgcp_call_id_parse(MGCP_C *callId, char *value) +{ + if (NULL == value) + return -1; + + strcpy(callId->callId, value); + return 0; +} + +int mgcp_local_opt_p_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + + localopt->p=atoi(value); + return 0; +} + +int mgcp_local_opt_a_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + + strcpy(localopt->codec, value); + return 0; +} + +int mgcp_local_opt_nt_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + if (0 == strcasecmp(value, "IN")) + { + localopt->ecDisable=0; + localopt->ssDisable=0; + return 0; + } + else if (0 == strcasecmp(value, "IN, e:off")) + { + localopt->ecDisable=1; + localopt->ssDisable=0; + return 0; + } + else if (0 == strcasecmp(value, "IN, s:off")) + { + localopt->ecDisable=0; + localopt->ssDisable=1; + return 0; + } + else if (0 == strcasecmp(value, "IN, e:off, s:off")) + { + localopt->ecDisable=1; + localopt->ssDisable=1; + return 0; + } + else + return -1; +} + +int mgcp_local_opt_es_cci_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + + strcpy(localopt->esCci, value); + + localopt->flag |= MGCP_PARA_L_FLAG_ESS_CCI; + + return 0; +} + +int mgcp_local_opt_es_ccd_parse(MGCP_L *localopt, char *value) +{ + char *colon; + int len; + + if (NULL == value) + return -1; + + if (((colon = strchr(value, ':')) == NULL) || (value > colon)) + { + sprintf(mgcpAsciTempBuf, "es ccd wrong format\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + return -1; + } + + if ((len = (colon - value)) > MGCP_MAX_DOMAIN_LEN) + { + sprintf(mgcpAsciTempBuf, "es ccd domain to long\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + return -1; + } + + mgcp_clrncpy(localopt->esCcd.domain, value, len); + + localopt->esCcd.port = strtol(colon+1, NULL, 10); + + localopt->flag |= MGCP_PARA_L_FLAG_ESS_CCD; + + return 0; + +} + +int mgcp_local_opt_parse(MGCP_L *localopt, char *value) +{ + char hvaluename[64]; + char hvalue[128]; + char *colonIndex; + char *comma; + char *endofvalue = value; + char *begofvalue = value; + int len, commaNum = 0; + + if (NULL == value) + return -1; + + for (;;) + { + if ('\0' == *begofvalue) + return 0; + + begofvalue = endofvalue; + +/* if (2 > commaNum) + { + while(',' != *endofvalue) + { + if (*endofvalue) + endofvalue++; + else + { + printf("lack of comma,can not find endofvalue\n"); + return -1; + } + } + commaNum++; + }*/ + if ((comma =strchr(endofvalue, ',')) != NULL) + { + endofvalue = comma; + commaNum++; + } + else + { + if (commaNum < 2) + { + mgcp_log_err("mgcp l parse:lack of comma,can not find endofvalue\r\n"); + return -1; + } + + while('\0' != *endofvalue) + { + if (*endofvalue) + endofvalue++; + } + } + colonIndex = strchr (begofvalue, ':'); + + if (NULL == colonIndex) + { + printf("can not find colonIndex in the value of Lopt, the wrong format.\n"); + return -1; + } + + if (endofvalue < colonIndex) + return -1; + + len = colonIndex - begofvalue; + mgcp_clrncpy(hvaluename, begofvalue, len); + + len = endofvalue -colonIndex-1; + mgcp_clrncpy(hvalue, colonIndex+1, len); + + if (strncasecmp(hvaluename, "p", 1) == 0) + { + if (mgcp_local_opt_p_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "a", 1) == 0) + { + if (mgcp_local_opt_a_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "nt", 2) == 0) + { + if (mgcp_local_opt_nt_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "es-cci", 6) == 0) + { + if (mgcp_local_opt_es_cci_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "es-ccd", 6) == 0) + { + if (mgcp_local_opt_es_ccd_parse(localopt, hvalue) < 0) + return -1; + } + else + return -1; + + begofvalue = endofvalue++; + } + +} + +int mgcp_connect_mode_parse(MGCP_M *m, char *value) +{ + if (NULL == value) + return -1; + + if (mgcp_mode_str_to_api(value, &m->mode) < 0) + return -1; + + return 0; +} + +int mgcp_observed_reqId_parse(MGCP_O *o, char *value) +{ + if (NULL == value) + return -1; + + strcpy(o->reqId, value); + return 0; +} + +int mgcp_event_parse(DWORD transId, MGCP_O *o, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &o->package) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("event package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_event_str_to_api(hvalue, &o->event, o->package) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such event\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("event is unknown\n"); + return -1; + } + + return 0; +} + +int mgcp_signl_reqId_parse(MGCP_S *s, char *value) +{ + if (NULL == value) + return -1; + + strcpy(s->reqId, value); + return 0; +} + +int mgcp_signl_parse(DWORD transId, MGCP_S *s, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + if (0 == strcmp(value, "")) + { + s->signal = MGCP_PACKAGE_SIG_NONE; + return 0; + } + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in signal event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &s->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("signal package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_sig_str_to_api(hvalue, &s->signal, s->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such signal\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("signal event is unknown\n"); + return -1; + } + + return 0; +} + + +int mgcp_reqent_parse(DWORD transId, MGCP_R *r, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in signal event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &r->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("request event package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_event_str_to_api(hvalue, &r->event, r->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such request event\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("request event is unknown\n"); + return -1; + } + + return 0; +} + +int mgcp_restart_mode_parse(MGCP_RM *rm, char *value) +{ + if (NULL == value) + return -1; + + if (mgcp_rm_str_to_api(value, &rm->rm) < 0) + { + return -1; + } + + return 0; +} + +int mgcp_restart_delay_parse(MGCP_RD *rd, char *value) +{ + if (NULL == value) + return -1; + + rd->rd = atoi(value); + return 0; +} + +int mgcp_msg_params_parse(BYTE cmdRes, WORD port, char *buf, char **body) +{ + char *colonIndex; + char hname[64]; + char hvalue[128]; + char *startOfHeader = buf; + char *endOfHeader; + char *end; + BYTE S_R_Flag = 0; + BYTE len; + MGCP_PARA *para; + + if (cmdRes == MGCP_COMMAND) + { + para = &mgcpPort[port].para; + } + else if (cmdRes == MGCP_RESPONSE) + { + para = &mgcpRespPara; + } + else + return -1; + + if ((startOfHeader[0] == '\0') && (mgcpPort[port].cmd != MGCP_CMD_AUEP)&&(cmdRes == MGCP_COMMAND)) + { + printf("no parameter in buf.\n"); + return -1; + } + + for (;;) + { + if (startOfHeader[0] == '\0') + { + *body = NULL; + return 0; + } + + if (mgcp_find_next_crlf(startOfHeader, &endOfHeader) < 0) + { + printf("End of header Not found\n"); + return -1; + } + + if ((startOfHeader[0] == '\r') || (startOfHeader[0] == '\n')) + { + *body = startOfHeader; + return 0; + } + else if (((startOfHeader[0] == '.') && (startOfHeader[1] == '\r') && (startOfHeader[2] == '\n'))) + { + *body = startOfHeader + 3; + return 1; + } + + // find the header name + colonIndex = strchr(startOfHeader, ':'); + if (colonIndex == NULL) + { + printf("End of header Not found\n"); + return -1; + } + if (endOfHeader <= colonIndex) + { + printf("Malformed message\n"); + return -1; + } + len = colonIndex - startOfHeader; + mgcp_clrncpy(hname, startOfHeader, len); + + // END of header is (end_of_header-2) if header separation is CRLF + // END of header is (end_of_header-1) if header separation is CR or LF + if ((endOfHeader[-2] == '\r') || (endOfHeader[-2] == '\n')) + end = endOfHeader - 2; + else + end = endOfHeader - 1; + if ((end - colonIndex) < 2) + strcpy(hvalue, ""); // some headers can be empty + else + { + len = end - colonIndex - 1; + mgcp_clrncpy(hvalue, colonIndex + 1, len); + } + + if (strncasecmp(hname, "I", 1) == 0) + { + if (mgcp_con_id_parse(¶->i, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "incorrect connect id\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_INCONID_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_I; + } + + if (strncasecmp(hname,"C",1) == 0) + { + if (mgcp_call_id_parse(¶->c, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unknown call id\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNCLLID_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_C; + } + + if (strncasecmp(hname,"L",1) == 0) + { + if (mgcp_local_opt_parse(¶->l, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "internal inconsistency in LocalConnectionOption\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_ILCO_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_L; + } + + if (strncasecmp(hname,"M",1) == 0) + { + if (mgcp_connect_mode_parse(¶->m, hvalue) < 0) + { + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNMD_INDEX); + return -1; + } + para->flag |=MGCP_PARA_FLAG_M; + } + + if (strncasecmp(hname,"O",1) == 0) + { + if ((para->flag & MGCP_PARA_FLAG_O) == 0) + return -1; + if (mgcp_event_parse(mgcpPort[port].transId, ¶->o, hvalue) < 0) + return -1; + } + + if (strncasecmp(hname,"X",1) == 0) + { + if (mgcpPort[port].cmd == MGCP_CMD_NTFY) + { + if (mgcp_observed_reqId_parse(¶->o, hvalue) < 0) + return -1; + para->flag |=MGCP_PARA_FLAG_O; + } + else + { + if (mgcp_signl_reqId_parse(¶->s, hvalue) < 0) + return -1; + S_R_Flag = 1; + } + } + + if (strncasecmp(hname,"S",1) == 0) + { + if (0 == S_R_Flag) + { + printf("Have no requestId.\n"); + return -1; + } + if (mgcp_signl_parse(mgcpPort[port].transId, ¶->s, hvalue) < 0) + return -1; + + para->flag |=MGCP_PARA_FLAG_S; + } + + if (strncasecmp(hname,"R",2) == 0) + { + if(0 == S_R_Flag) + { + printf("Have no requestId.\n"); + return -1; + } + if (mgcp_reqent_parse(mgcpPort[port].transId, ¶->r, hvalue) < 0) + return -1; + + para->flag |=MGCP_PARA_FLAG_R; + } + + if (strncasecmp(hname,"RM",2) == 0) + { + if (mgcp_restart_mode_parse(¶->rm, hvalue) < 0) + { + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNRM_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_RM; + } + + if (strncasecmp(hname,"RD",2) == 0) + { + if (mgcp_restart_delay_parse(¶->rd, hvalue) < 0) + return -1; + para->flag |= MGCP_PARA_FLAG_RD; + } + + + // continue on the next header + startOfHeader = endOfHeader; + } + +// return -1; +} + +int mgcp_msg_parse_single(char *msg, WORD len, char **nextMsg, WORD networkPort) +{ + char *nextHeader; + int port; + MGCP_PARA *para; + BYTE cmdRes; + int ret; + + if ((port = mgcp_msg_start_line_parse(&cmdRes, msg, &nextHeader)) < 0) + { + if (port == -1) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "start_line_parse fault\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", msg); + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + + return -1; + } + if (port >= MGCP_MAX_NUM_OF_PORT) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, msg); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if (cmdRes == MGCP_COMMAND) + { + para = &mgcpPort[port].para; + } + else if (cmdRes == MGCP_RESPONSE) + { + para = &mgcpRespPara; + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, msg); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } +// else +// para = &mgcpPort[port].para; + para->flag |= MGCP_PARA_FLAG_SL; + + if ((ret = mgcp_msg_params_parse(cmdRes, port, nextHeader, &nextHeader)) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "params_parse fault\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + + if (cmdRes == MGCP_COMMAND) + mgcp_port_init(port); + + return -1; + } + + if (0 == ret) + { + if ((MGCP_CMD_CRCX == mgcpPort[port].cmd) || (MGCP_CMD_MDCX == mgcpPort[port].cmd)) + { + if (nextHeader != NULL) + { + pub_sdp_msg_init(¶->sdp); + if ((ret = pub_sdp_parse(¶->sdp, nextHeader, &nextHeader, 0xFFFFFFFF)) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "remotoconnectiondescriptor error\r\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_RCD_ERR_INDEX); + + if (cmdRes == MGCP_COMMAND) + mgcp_port_init(port); + + return -1; + } + para->flag |= MGCP_PARA_FLAG_SDP; + } + } + } + + if (cmdRes == MGCP_RESPONSE) + memcpy(&mgcpPort[port].para, &mgcpRespPara, sizeof(MGCP_PARA)); + + if ((mgcpPort[port].para.localPort = networkPort) == MGCP_INT_PORT_2427) + { + mgcpPort[port].para.peerPort = MGCP_INT_PORT_2727; + } + else + { + mgcpPort[port].para.peerPort = MGCP_INT_PORT_2427; + } + + if (((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) || ((mgcpMonitorFg | MONITOR_ERROR) == MONITOR_ALL)) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else if ((mgcpMonitorFg | MONITOR_MG0_MSG | MONITOR_MG1_MSG | MONITOR_MG2_MSG |MONITOR_ERROR) == MONITOR_ALL) + { + if ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + || ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + || ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG)) + { + if ((((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0]))) + || (((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + || (((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + + if (1 == ret) + { + *nextMsg = nextHeader; + return 1; + } + + return 0; +} + +int mgcp_msg_parse(WORD networkPort) +{ + char *msg, *nextMsg; + WORD len; + WORD lenTotal; + int ret; + int i; + + nextMsg = msg = mgcpRvMsg.msgContent; + lenTotal = len = mgcpRvMsg.msgLength; + + mgcp_util_replace_all_lws(msg); + + for (i = 0; i < 10; i++) + { + if ((ret = mgcp_msg_parse_single(nextMsg, len, &nextMsg, networkPort)) <= 0) + break; + else + { + len = nextMsg - msg; + + if (len >= lenTotal) + break; + else + len = lenTotal -len; + } + } + + return 1; +} + +void mgcp_recv_msg() +{ + BYTE i; + WORD port; + + for (i = 0; i < 64; i++) + { + if (i & 1) + port = MGCP_INT_PORT_2427; + else + port = MGCP_INT_PORT_2727; + + if (iptrDirectRecvMsg(&mgcpRvMsg, port) > 0) + { + if (mgcpRvMsg.msgLength >= 1500) + continue; + mgcpRvMsg.msgContent[mgcpRvMsg.msgLength] = '\0'; + mgcp_msg_parse(port); + } + } +} + +// MGCP Message Encoding + +int mgcp_create_req_id(WORD port, char *reqId) +{ + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + if (reqId[0] == '\0') + sprintf(reqId, "%X%lX", port, time(NULL)); + else + return 0; + + return 0; +} + +int mgcp_ep_id_encode(MGCP_SL *sl, char *endPointId) +{ + char epType[8]; + + if (sl->epNameMethod == MGCP_EP_NAME_UNSTRUCTURED) + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "*"); + else + sprintf(endPointId, "%d", sl->chlNum); + } + else if (sl->epNameMethod == MGCP_EP_NAME_STRUCTURED) + { + if ((sl->mgType >= MGCP_MG_TYPE_AudioCoder) && (sl->mgType < MGCP_MG_TYPE_ANN)) + { + if ((sl->portType == MGCP_PORT_TYPE_E1) || + (sl->portType == MGCP_PORT_TYPE_T1)) + { + if (sl->portType == MGCP_PORT_TYPE_E1) + sprintf(epType, "e1"); + else + sprintf(epType, "t1"); + if (MGCP_EP_NAME_TRK_WILDCAST == sl->trkNum) + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "ds/%s-*/*", epType); + else + sprintf(endPointId, "ds/%s-*/%d", epType, sl->chlNum); + } + else + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "ds/%s-%d/*", epType, sl->trkNum); + else + sprintf(endPointId, "ds/%s-%d/%d", epType, sl->trkNum, sl->chlNum); + } + } + else if (MGCP_PORT_TYPE_AALN == sl->portType) + { + sprintf(epType, "aaln"); + if (sl->trkNum == MGCP_EP_NAME_TRK_WILDCAST) + sprintf(endPointId, "%s/*", epType); + else + sprintf(endPointId, "%s/%d", epType, sl->trkNum); + } + else + return -1; + } + else if (sl->mgType == MGCP_MG_TYPE_ANN) + { + sprintf(epType, "ann"); + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "%s/*", epType); + else + sprintf(endPointId, "%s/%d", epType, sl->chlNum); + } + else + return -1; + } + else + return -1; + + return 0; +} + +int mgcp_para_call_id_encode(MGCP_C *c, char *msgPara) +{ + if ((c == NULL) || + (msgPara == NULL)) + return -1; + + sprintf(msgPara, "C: %s\r\n", c->callId); + + return 0; +} + +int mgcp_para_con_id_encode(MGCP_I *i, char *msgPara) +{ + if ((i == NULL) || + (msgPara == NULL)) + return -1; + + sprintf(msgPara, "I: %s\r\n", i->conId); + + return 0; +} + +int mgcp_para_local_con_opt_encode(MGCP_L *l, char *msgPara, WORD flag) +{ + char codec[16]=""; + + if ((l == NULL) || + (msgPara == NULL)) + return -1; + + if ((flag & MGCP_PARA_FLAG_TFO) == MGCP_PARA_FLAG_TFO) + { + strcpy(codec, "PCMA"); + if ((l->flag & MGCP_PARA_L_FLAG_ESS_CCI) == MGCP_PARA_L_FLAG_ESS_CCI) + { + if ((l->flag & MGCP_PARA_L_FLAG_ESS_CCD) == MGCP_PARA_L_FLAG_ESS_CCD) + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s, es-cci:%s, es-ccd:%s:%d\r\n", l->p, codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : "", l->esCci, l->esCcd.domain, l->esCcd.port); + } + else + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s, es-cci:%s\r\n", l->p, codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : "", l->esCci); + } + } + else + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s\r\n", l->p, codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : ""); + } + } + else + { + if ((l->flag & MGCP_PARA_L_FLAG_ESS_CCI) == MGCP_PARA_L_FLAG_ESS_CCI) + { + if ((l->flag & MGCP_PARA_L_FLAG_ESS_CCD) == MGCP_PARA_L_FLAG_ESS_CCD) + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s, es-cci:%s, es-ccd:%s:%d\r\n", l->p, l->codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : "", l->esCci, l->esCcd.domain, l->esCcd.port); + } + else + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s, es-cci:%s\r\n", l->p, l->codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : "", l->esCci); + } + } + else + { + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s\r\n", l->p, l->codec + , (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : ""); + } + } + + return 0; +} + +int mgcp_para_con_mode_encode(MGCP_M *m, char *msgPara) +{ + if ((m == NULL) || + (msgPara == NULL)) + return -1; + + if (m->mode > MGCP_CON_MODE_SENDRECV) + return -1; + + sprintf(msgPara, "M: %s\r\n", mgcpConModeToStr[m->mode]); + + return 0; +} + +int mgcp_para_signal_req_encode(WORD port, MGCP_S *s, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (s == NULL) || + (msgPara == NULL)) + return -1; + + if (s->pkg >= MGCP_PACKAGE_MAX) + return -1; + + + if (s->signal > mgcpMaxPkgSig[s->pkg]) + return -1; + + + if (mgcp_create_req_id(port, s->reqId) < 0) + return -1; + + sprintf(msgPara, "X: %s\r\n", s->reqId); + + if (s->signal == MGCP_PACKAGE_SIG_NONE) + strcat(msgPara, "S:\r\n"); + else + { + sprintf(str, "S: %s/%s\r\n", mgcpPkgToStr[s->pkg], mgcpAalnSigToStr[s->pkg][s->signal]); + strcat(msgPara, str); + } + + return 0; +} + +int mgcp_para_request_event_encode(WORD port, MGCP_R *r, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) ||(r == NULL) || + (msgPara == NULL)) + return -1; + + if (r->pkg >= MGCP_PACKAGE_MAX) + return -1; + + if (r->event > mgcpMaxPkgEvent[r->pkg]) + return -1; + + if (mgcp_create_req_id(port, r->reqId) < 0) + return -1; + + sprintf(msgPara, "X: %s\r\n", r->reqId); + + sprintf(str, "R: %s/%s\r\n", mgcpPkgToStr[r->pkg], mgcpEntToStr[r->pkg][r->event]); + strcat(msgPara, str); + + return 0; +} + +int mgcp_para_observed_ent_encode(WORD port, MGCP_O *o, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) ||(o == NULL) || + (msgPara == NULL)) + return -1; + + if (o->package >= MGCP_PACKAGE_MAX) + return -1; + + if (o->event > mgcpMaxPkgEvent[o->package]) + return -1; + + if (mgcp_create_req_id(port, o->reqId) < 0) + return -1; + sprintf(msgPara, "X: %s\r\n", o->reqId); + + sprintf(str, "O: %s/%s\r\n", mgcpPkgToStr[o->package], mgcpEntToStr[o->package][o->event]); + strcat(msgPara, str); + + return 0; +} + + +int mgcp_para_restart_mod_encode(MGCP_RM *rm, char *msgPara) +{ + if ((NULL == rm)||(NULL == msgPara)) + return -1; + + if (rm->rm >= MGCP_REST_MOD_MAX) + return -1; + + sprintf(msgPara, "%s", mgcpRestModToStr[rm->rm]); + + return 0; +} + +int mgcp_para_restart_delay_encode(MGCP_RD *rd, char *msgPara) +{ + if ((NULL == rd)||(NULL == msgPara)) + return -1; + + sprintf(msgPara, "RD: %d\r\n", rd->rd); + + return 0; +} +/**/ +int mgcp_cmd_crcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) == 0) + return -1; + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_L) != 0) + { + if (mgcp_para_local_con_opt_encode(¶->l, msgPara, flag) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_M) == 0) + return -1; + if (mgcp_para_con_mode_encode(¶->m, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + return 0; +} + +int mgcp_cmd_mdcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) == 0) + return -1; + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_I) == 0) + return -1; + if (mgcp_para_con_id_encode(¶->i, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_L) != 0) + { + if (mgcp_para_local_con_opt_encode(¶->l, msgPara, flag) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_M) != 0) + { + if (mgcp_para_con_mode_encode(¶->m, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_dlcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) != 0) + { + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_I) != 0) + { + if (mgcp_para_con_id_encode(¶->i, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_rqnt_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_R) != 0) + { + if (mgcp_para_request_event_encode(port, ¶->r, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_ntfy_para_encode(WORD port, char *msgText) +{ + + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_O) == 0) + return -1; + if (mgcp_para_observed_ent_encode(port, ¶->o, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + return 0; +} + +int mgcp_cmd_auep_para_encode(WORD port, char *msgText) +{ + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + return 0; + +} + +int mgcp_cmd_rsip_para_encode(WORD port, char *msgText) +{ + + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + if ((flag & MGCP_PARA_FLAG_RM) == 0) + return -1; + if (mgcp_para_restart_mod_encode(¶->rm, msgPara) < 0) + return -1; + sprintf(msgText, "RM: %s\r\n", msgPara); + + if ((flag & MGCP_PARA_FLAG_RD) != 0) + { + if (mgcp_para_restart_delay_encode(¶->rd, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + return 0; + +} + +int mgcp_send_msg(WORD port, BYTE cmdRes) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + MGCP_SL *sl; + DWORD flag; + BYTE cmd; + WORD len; + char endPointId[16]; + char *msgText = mgcpSdMsg.msgContent; + char resPara[256]; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + msgText[MAX_CONTENT_LEN - 1] = '\0'; + + trans = &mgcpPort[port]; + + if (cmdRes == MGCP_COMMAND) + { + cmd = trans->cmd; + para = &trans->para; + flag = para->flag; + sl = ¶->sl; + + if ((flag & MGCP_PARA_FLAG_SL) == 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "MGCP_COMMAND have no sl flag\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if ((cmd < MGCP_CMD_CRCX) || (cmd > MGCP_CMD_RSIP)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "cmd is unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if (mgcp_ep_id_encode(sl, endPointId) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "ep id encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + // Start Line + if (0 == strcmp(sl->mgName, "")) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no domain name\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + sprintf(msgText, "%s %ld %s@%s MGCP 1.0\r\n", mgcpCmdToStr[cmd], trans->transId, endPointId, sl->mgName); + + // Parameters + switch (cmd) + { + case MGCP_CMD_CRCX: + if (mgcp_cmd_crcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "crcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_MDCX: + if (mgcp_cmd_mdcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mdcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_DLCX: + if (mgcp_cmd_dlcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "dlcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_RQNT: + if (mgcp_cmd_rqnt_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "rqnt para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_NTFY: + if (mgcp_cmd_ntfy_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "ntfy para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_AUEP: + if (mgcp_cmd_auep_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "auep para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_RSIP: + if (mgcp_cmd_rsip_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "rsip para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + default: + break; + } + + len = strlen(msgText); + + // SDP + if ((flag & MGCP_PARA_FLAG_SDP) != 0) + { + strcat(msgText, "\r\n"); + len += 2; + if (pub_sdp_encode(¶->sdp, msgText + len, flag) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mgcp send cmd: pub sdp encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + len += strlen(msgText + len); + } + } + else + { + para = &trans->para; + flag = para->flag; + sl = ¶->sl; + + if ((flag & MGCP_PARA_FLAG_SL) == 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "MGCP_RESPONSE have no sl flag\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + // Start Line + sprintf(msgText, "%d %ld %s\r\n", sl->retCode, trans->transId, sl->desc); + + if (((trans->cmd == MGCP_CMD_CRCX) || (trans->cmd == MGCP_CMD_MDCX))&& (sl->retCode == 200)) + { + if (trans->cmd == MGCP_CMD_CRCX) + { + sprintf(resPara, "I: %s\r\n", para->i.conId); + strcat(msgText, resPara); + } + + // SDP + if ((flag & MGCP_PARA_FLAG_SDP) != 0) + { + strcat(msgText, "\r\n"); + + len = strlen(msgText); + + if (pub_sdp_encode(¶->sdp, msgText + len, flag) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mgcp send rsp: pub sdp encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + } + } + + len = strlen(msgText); + } + + if (((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) || ((mgcpMonitorFg | MONITOR_ERROR) == MONITOR_ALL)) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else if ((mgcpMonitorFg | MONITOR_MG0_MSG | MONITOR_MG1_MSG | MONITOR_MG2_MSG |MONITOR_ERROR) == MONITOR_ALL) + { + if ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + || ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + || ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG)) + { + if ((((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0]))) + || (((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + || (((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + + + mgcpSdMsg.msgDstIP = para->ip; + mgcpSdMsg.msgSrcPort = para->localPort; + mgcpSdMsg.msgDstPort = para->peerPort; + mgcpSdMsg.msgLength = len; + + iptrDirectSendMsg(mgcpSdMsg); + + return 0; +} + +int mgcp_send_rsp(WORD port, BYTE retCodeIndex) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + MGCP_SL *sl; +// WORD tPort; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (retCodeIndex >= MGCP_MAX_RET_CODE_INDEX)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mgcp_send_rsp: port or retCodeIndex fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + trans = &mgcpPort[port]; + para = &trans->para; + sl = ¶->sl; + + para->flag = MGCP_PARA_FLAG_SL; + + sl->cmdRes = MGCP_RESPONSE; + sl->retCode = mgcpRetCode[retCodeIndex].retCode; + strcpy(sl->desc, mgcpRetCode[retCodeIndex].desc); + + if (mgcp_send_msg(port, MGCP_RESPONSE) < 0) + return -1; + + return 0; +} + +int mgcp_send_incmd_rsp(DWORD transId, BYTE retCodeIndex) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + + trans = &mgcpPort[0]; + para = &trans->para; + + trans->transId = transId; + para->ip = mgcpRvMsg.msgSrcIP; + para->peerPort = mgcpRvMsg.msgSrcPort; + para->localPort = mgcpRvMsg.msgDstPort; + + if (mgcp_send_rsp(0, retCodeIndex) < 0) + return -1; + + return 0; +} diff --git a/omc/plat/mgcp/src/mgcp_msg.c.bak b/omc/plat/mgcp/src/mgcp_msg.c.bak new file mode 100644 index 0000000..a0ac874 --- /dev/null +++ b/omc/plat/mgcp/src/mgcp_msg.c.bak @@ -0,0 +1,2612 @@ +#include "./include/mgcp_pub.h" +#include "./include/mgcp.h" +#include "./include/mgcp_const.h" +#include "./include/mgcp_ext.h" +#include "./include/mgcp_struct.h" +#include "./include/mgcp_trans.h" +#include "./include/mgcp_msg.h" + +extern int mgcp_get_port(); +extern void mgcp_port_init(WORD port); +extern int mgcp_log_err(BYTE *errMsg); +extern int mgcp_asciout_proc(BYTE *outStr); + +int mgcp_cmd_str_to_api(char *str, BYTE *cmd) +{ + if (strcasecmp(str, "CRCX") == 0) + *cmd = MGCP_CMD_CRCX; + else if (strcasecmp(str, "MDCX") == 0) + *cmd = MGCP_CMD_MDCX; + else if (strcasecmp(str, "DLCX") == 0) + *cmd = MGCP_CMD_DLCX; + else if (strcasecmp(str, "RQNT") == 0) + *cmd = MGCP_CMD_RQNT; + else if (strcasecmp(str, "NTFY") == 0) + *cmd = MGCP_CMD_NTFY; + else if (strcasecmp(str, "AUEP") == 0) + *cmd = MGCP_CMD_AUEP; + else if (strcasecmp(str, "RSIP") == 0) + *cmd = MGCP_CMD_RSIP; + else + { + return -1; + } + + return 0; +} + +int mgcp_mgtype_str_to_api(char *str, BYTE *mgtp, BYTE *porttp) +{ + if (strcasecmp(str, "e1") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_E1; + } + else if (strcasecmp(str, "t1") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_T1; + } + else if (strcasecmp(str, "ann") == 0) + { + *mgtp = MGCP_MG_TYPE_ANN; + *porttp = 0; + } + else if (strcasecmp(str, "aaln") == 0) + { + *mgtp = MGCP_MG_TYPE_AudioCoder; + *porttp = MGCP_PORT_TYPE_AALN; + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong mg type\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_mode_str_to_api(char *str, BYTE *md) +{ + if (strcasecmp(str, "inactive") == 0) + *md = MGCP_CON_MODE_INACTIVE; + else if (strcasecmp(str, "recvonly") == 0) + *md = MGCP_CON_MODE_RECVONLY; + else if (strcasecmp(str, "sendonly") == 0) + *md = MGCP_CON_MODE_SENDONLY; + else if (strcasecmp(str, "sendrecv") == 0) + *md = MGCP_CON_MODE_SENDRECV; + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong connect mode\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_rm_str_to_api(char *str, BYTE *rm) +{ + if (strcasecmp(str, "restart") == 0) + *rm = MGCP_RST_MODE_RESTART; + else if (strcasecmp(str, "forced") == 0) + *rm = MGCP_RST_MODE_FORCED; + else if (strcasecmp(str, "disconnected") == 0) + *rm = MGCP_RST_MODE_DISCONNECTED; + else if (strcasecmp(str, "graceful") == 0) + *rm = MGCP_RST_MODE_GRACEFUL; + else if (strcasecmp(str, "cancel-graceful") == 0) + *rm = MGCP_RST_MODE_CANCEL_GRACEFUL; + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Wrong restart mode\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + return 0; +} + +int mgcp_pkg_str_to_api(char *str, BYTE *pkg) +{ + if (strcasecmp(str, "L") == 0) + *pkg = MGCP_PKG_L; + else if (strcasecmp(str, "D") == 0) + *pkg = MGCP_PKG_D; + else if (strcasecmp(str, "G") == 0) + *pkg = MGCP_PKG_G; + else + return -1; + + return 0; +} + +int mgcp_sig_str_to_api(char *str, BYTE *sig, BYTE pkg) +{ + if (MGCP_PKG_L == pkg) + { + if (strcasecmp(str, "aw") == 0) + *sig = MGCP_L_SIG_AW; + else if (strcasecmp(str, "dl") == 0) + *sig = MGCP_L_SIG_DL; + else if (strcasecmp(str, "bz") == 0) + *sig = MGCP_L_SIG_BZ; + else if (strcasecmp(str, "wt") == 0) + *sig = MGCP_L_SIG_WT; + else if (strcasecmp(str, "nbz") == 0) + *sig = MGCP_L_SIG_NBZ; + else if (strcasecmp(str, "rg") == 0) + *sig = MGCP_L_SIG_RG; + else if (strcasecmp(str, "e") == 0) + *sig = MGCP_L_SIG_E; + else if (strcasecmp(str, "ot") == 0) + *sig = MGCP_L_SIG_OT; + else + return -1; + } + else if (MGCP_PKG_D == pkg) + { + if (strcasecmp(str, "0") == 0) + *sig = MGCP_D_SIG_ZERO; + else if (strcasecmp(str, "1") == 0) + *sig = MGCP_D_SIG_ONE; + else if (strcasecmp(str, "2") == 0) + *sig = MGCP_D_SIG_TWO; + else if (strcasecmp(str, "3") == 0) + *sig = MGCP_D_SIG_THREE; + else if (strcasecmp(str, "4") == 0) + *sig = MGCP_D_SIG_FOUR; + else if (strcasecmp(str, "5") == 0) + *sig = MGCP_D_SIG_FIVE; + else if (strcasecmp(str, "6") == 0) + *sig = MGCP_D_SIG_SIX; + else if (strcasecmp(str, "7") == 0) + *sig = MGCP_D_SIG_SEVEN; + else if (strcasecmp(str, "8") == 0) + *sig = MGCP_D_SIG_EIGHT; + else if (strcasecmp(str, "9") == 0) + *sig = MGCP_D_SIG_NINE; + else if (strcasecmp(str, "#") == 0) + *sig = MGCP_D_SIG_POUND; + else if (strcasecmp(str, "*") == 0) + *sig = MGCP_D_SIG_STAR; + else + return -1; + } + else if (MGCP_PKG_G == pkg) + { + if (strcasecmp(str, "rt") == 0) + *sig = MGCP_G_SIG_RT; + else if (strcasecmp(str, "cf") == 0) + *sig = MGCP_G_SIG_CF; + else if (strcasecmp(str, "cg") == 0) + *sig = MGCP_G_SIG_CG; + else if (strcasecmp(str, "it") == 0) + *sig = MGCP_G_SIG_IT; + else if (strcasecmp(str, "pt") == 0) + *sig = MGCP_G_SIG_PT; + else + return -1; + } + else + return -1; + + return 0; +} + +int mgcp_event_str_to_api(char *str, BYTE *ent, BYTE pkg) +{ + if (MGCP_PKG_L == pkg) + { + if (strcasecmp(str, "hd") == 0) + *ent = MGCP_L_EVENT_HD; + else if (strcasecmp(str, "hu") == 0) + *ent = MGCP_L_EVENT_HU; + else if (strcasecmp(str, "hf") == 0) + *ent = MGCP_L_EVENT_HF; + else if (strcasecmp(str, "aw") == 0) + *ent = MGCP_L_EVENT_AW; + else if (strcasecmp(str, "nbz") == 0) + *ent = MGCP_L_EVENT_NBZ; + else if (strcasecmp(str, "e") == 0) + *ent = MGCP_L_EVENT_E; + else if (strcasecmp(str, "oc") == 0) + *ent = MGCP_L_EVENT_OC; + else if (strcasecmp(str, "of") == 0) + *ent = MGCP_L_EVENT_OF; + else + return -1; + } + else if (MGCP_PKG_D == pkg) + { + if (strcasecmp(str, "0") == 0) + *ent = MGCP_D_EVENT_ZERO; + else if (strcasecmp(str, "1") == 0) + *ent = MGCP_D_EVENT_ONE; + else if (strcasecmp(str, "2") == 0) + *ent = MGCP_D_EVENT_TWO; + else if (strcasecmp(str, "3") == 0) + *ent = MGCP_D_EVENT_THREE; + else if (strcasecmp(str, "4") == 0) + *ent = MGCP_D_EVENT_FOUR; + else if (strcasecmp(str, "5") == 0) + *ent = MGCP_D_EVENT_FIVE; + else if (strcasecmp(str, "6") == 0) + *ent = MGCP_D_EVENT_SIX; + else if (strcasecmp(str, "7") == 0) + *ent = MGCP_D_EVENT_SEVEN; + else if (strcasecmp(str, "8") == 0) + *ent = MGCP_D_EVENT_EIGHT; + else if (strcasecmp(str, "9") == 0) + *ent = MGCP_D_EVENT_NINE; + else if (strcasecmp(str, "#") == 0) + *ent = MGCP_D_EVENT_POUND; + else if (strcasecmp(str, "*") == 0) + *ent = MGCP_D_EVENT_STAR; + else + return -1; + } + else if (MGCP_PKG_G == pkg) + { + if (strcasecmp(str, "mt") == 0) + *ent = MGCP_G_EVENT_MT; + else if (strcasecmp(str, "ft") == 0) + *ent = MGCP_G_EVENT_FT; + else if (strcasecmp(str, "ld") == 0) + *ent = MGCP_G_EVENT_LD; + else if (strcasecmp(str, "of") == 0) + *ent = MGCP_G_EVENT_OF; + else + return -1; + } + else + return -1; + + return 0; +} + +void mgcp_util_replace_all_lws(char *msg) +{ + char *tmp; + + if (msg == NULL) + return; + tmp = msg; + + for (; tmp[0] != '\0'; tmp++) + { + if (('\0' == tmp[0]) || ('\0' == tmp[1]) || + ('\0' == tmp[2]) || ('\0' == tmp[3])) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ('\r' == tmp[2]) && ('\n' == tmp[3])) || + (('\r' == tmp[0]) && ('\r' == tmp[1])) || + (('\n' == tmp[0]) && ('\n' == tmp[1]))) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ((' ' == tmp[2]) || ('\t' == tmp[2]))) || + (('\r' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1]))) || + (('\n' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1])))) + { + // Replace line end and TAB symbols by SP + tmp[0] = ' '; + tmp[1] = ' '; + tmp = tmp + 2; + // Replace all following TAB symbols + for (; ('\t' == tmp[0] || ' ' == tmp[0]); ) + { + tmp[0] = ' '; + tmp++; + } + } + } +} + +int mgcp_find_next_crlf(char *startOfHeader, char **endOfHeader) +{ + char *soh = startOfHeader; + + *endOfHeader = NULL; + + while (('\r' != *soh) && ('\n' != *soh)) + { + if (*soh) + soh++; + else + { + printf("Final CRLF is missing\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Final CRLF is missing\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + } + + // case 1: CRLF is the separator + // case 2 or 3: CR or LF is the separator + if (('\r' == soh[0]) && ('\n' == soh[1])) + soh = soh + 1; + + // VERIFY if TMP is the end of header or LWS. + // LWS are extra SP, HT, CR and LF contained in headers. + if ((' ' == soh[1]) || ('\t' == soh[1])) + { + // incoming message that potentially + // contains LWS must be processed with + // mgcp_util_replace_all_lws(char *) + printf("Message that contains LWS must be processed with sip_util_replace_all_lws(char *tmp) before being parsed.\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Message that contains LWS must be processed with sip_util_replace_all_lws(char *tmp) before being parsed.\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + *endOfHeader = soh + 1; + + return 0; +} + +char *mgcp_clrncpy(char *dst, char *src, WORD len) +{ + char *pbeg; + char *pend; + char *p; + WORD spaceLessLength; + + if ((src == NULL) || (len == 0)) + return NULL; + + // find the start of relevant text + pbeg = src; + while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg)) + pbeg++; + + // find the end of relevant text + pend = src + len - 1; + while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend)) + { + pend--; + if (pend < pbeg) + { + *dst = '\0'; + return dst; + } + } + + // if pend == pbeg there is only one char to copy + spaceLessLength = pend - pbeg + 1; // excluding any '\0' + memcpy(dst, pbeg, spaceLessLength); + p = dst + spaceLessLength; + + // terminate the string and pad dest with zeros until len + do + { + *p = '\0'; + p++; + spaceLessLength++; + } + while (spaceLessLength < len); + + return dst; +} + +int mgcp_msg_start_line_parse_resp(char *buf, char **nextHeader) +{ + char *hp; + char tmp[128]; + char *statusCode; + char *transId; + char *endoftransId; + MGCP_SL *sl; + WORD retCode; + DWORD transIdValue; + int port; + + *nextHeader = buf; + + statusCode = strchr(buf, ' '); // Search for first SPACE + if (statusCode == NULL) + return -1; + mgcp_clrncpy(tmp, buf, statusCode - buf); + retCode = strtoul(tmp, NULL, 10); + + transId = strchr(statusCode + 1, ' '); + if (transId == NULL) + return -1; + + mgcp_clrncpy(tmp, statusCode + 1, transId - statusCode - 1); + transIdValue = strtoul(tmp, &endoftransId, 10); + if ('\0' != endoftransId[0]) + { + printf("the space of transId is at wrong position.\n"); + return -1; + } + + if ((port = mgcp_match_client_trans(transIdValue)) < 0) + return -1; + + memset(&mgcpRespPara, 0, sizeof(MGCP_PARA)); + + sl = &mgcpRespPara.sl; + sl->cmdRes = MGCP_RESPONSE; + sl->retCode = retCode; + sl->transId = transIdValue; + + hp = transId; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + printf("No crlf found\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "No crlf found\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + } + mgcp_clrncpy(sl->desc, transId + 1, hp - transId - 1); + + hp++; + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + (*nextHeader) = hp; + + return port; +} + +int mgcp_msg_start_line_parse_cmd(int *portAllocated, char *buf, char **nextHeader) +{ + char *hp; + char tmp[128]; + char *cmdName; + char *transId; + char *mgName; + char *endmgName; + char *trkNum; + char *chlNum; + char *endoftransId; + char mgtype[128]; + char *mgtypeslash; + MGCP_SL *sl; + MGCP_PARA *para; + MGCP_PORT *trans; + int port; + BYTE cmd; + BYTE mgtp; + BYTE porttp; + DWORD transID; + + *portAllocated = -1; + + *nextHeader = buf; + + cmdName = strchr(buf, ' '); // Search for first SPACE + if (cmdName == NULL) + return -1; + mgcp_clrncpy(tmp, buf, cmdName - buf); + + mgcp_cmd_str_to_api(tmp, &cmd); +/*{ + return -1; + } +*/ + transId = strchr(cmdName + 1, ' '); + if (transId == NULL) + return -1; + + mgcp_clrncpy(tmp, cmdName + 1, transId - cmdName - 1); + transID = strtoul(tmp, &endoftransId, 10); + if ('\0' != endoftransId[0]) + { + printf("the space of transId is at wrong position.\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "the space of transId is at wrong position.\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + return -1; + } + + if ((cmdMGCP_CMD_RSIP)) + { + printf("unknown or unsupport command\n"); + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unknown or unsupport command\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNCMD_INDEX); + return -1; + } + + if ((port = mgcp_match_server_trans(transID)) >= 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "Find the same transID\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -2; + } + + if ((port = mgcp_get_port()) < 0) + { + return -1; + } + *portAllocated = port; + + trans = &mgcpPort[port]; + para = &trans->para; + sl = ¶->sl; + + hp = transId; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + printf("No crlf found\n"); + return -1; + } + } + mgcp_clrncpy(tmp, transId + 1, hp - transId - 1); + + if ((mgName = strchr(tmp, '@')) == NULL) + { + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if ((endmgName = strstr(mgName, " ")) == NULL) + { + + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (NULL == mgcp_clrncpy(sl->mgName, mgName+1, endmgName-mgName-1)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown:no domain name\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (isdigit(tmp[0])||(tmp[0]=='*')) + { + sl->epNameMethod = MGCP_EP_NAME_UNSTRUCTURED; + if (tmp[0] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(tmp, NULL, 10); + } + else + { + sl->epNameMethod = MGCP_EP_NAME_STRUCTURED; + if ((trkNum = strchr(tmp, '-')) != NULL) + { + if ((mgtypeslash = strchr(tmp, '/')) >= trkNum) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + mgcp_clrncpy(mgtype, mgtypeslash +1, trkNum - mgtypeslash - 1); + + if (mgcp_mgtype_str_to_api(mgtype, &mgtp, &porttp) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if ('*' == trkNum[1]) + { + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + } + else + { + sl->trkNum = strtoul(trkNum + 1, NULL, 10); + } + + if ((chlNum = strchr(trkNum + 1, '/')) != NULL) + { + if (chlNum[1] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(chlNum + 1, NULL, 10); + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + else if((NULL == trkNum) && ('a' == tmp[0])) + { + if ((chlNum = strchr(tmp, '/')) != NULL) + { + mgcp_clrncpy(mgtype, tmp, chlNum - tmp); + + if (mgcp_mgtype_str_to_api(mgtype, &mgtp, &porttp) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + + if (MGCP_PORT_TYPE_AALN == porttp) + { + if (chlNum[1] == '*') + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + else + sl->trkNum = strtoul(chlNum + 1, NULL, 10); + + sl->chlNum = 0; + } + else + { + if (chlNum[1] == '*') + sl->chlNum = MGCP_EP_NAME_CHNL_WILDCAST; + else + sl->chlNum = strtoul(chlNum + 1, NULL, 10); + + sl->trkNum = MGCP_EP_NAME_TRK_WILDCAST; + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "endpoint unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transID, MGCP_RET_CODE_UNEP_INDEX); + return -1; + } + } + + trans->transId = transID; + trans->cmd = cmd; + + para->ip = mgcpRvMsg.msgSrcIP; + para->peerPort = mgcpRvMsg.msgSrcPort; + para->localPort = mgcpRvMsg.msgDstPort; + +// mgcp_clrncpy(sl->mgName, mgName+1, endmgName-mgName-1); + sl->cmdRes = MGCP_COMMAND; + sl->transId = transID; + sl->mgType = mgtp; + sl->portType = porttp; + + hp++; + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + (*nextHeader) = hp; + + return port; +} + +int mgcp_msg_start_line_parse(BYTE *cmdRes, char *buf, char **nextHeader) +{ + int port = -1; + int ret; + + if (isdigit(buf[0])) + { + if ((port = mgcp_msg_start_line_parse_resp(buf, nextHeader)) < 0) + return -1; + *cmdRes = MGCP_RESPONSE; + } + else + { + if ((ret = mgcp_msg_start_line_parse_cmd(&port, buf, nextHeader)) < 0) + { + if (port >= 0) + mgcp_port_init(port); + + if (ret == -2) + return -2; + else + return -1; + } + mgcpPort[port].reqInd = MGCP_INDICATION; + *cmdRes = MGCP_COMMAND; + } + + return port; +} + +int mgcp_con_id_parse(MGCP_I *conId, char *value) +{ + if (NULL == value) + return -1; + + strcpy(conId->conId, value); + return 0; +} + +int mgcp_call_id_parse(MGCP_C *callId, char *value) +{ + if (NULL == value) + return -1; + + strcpy(callId->callId, value); + return 0; +} + +int mgcp_local_opt_p_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + + localopt->p=atoi(value); + return 0; +} + +int mgcp_local_opt_a_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + + strcpy(localopt->codec, value); + return 0; +} + +int mgcp_local_opt_nt_parse(MGCP_L *localopt, char *value) +{ + if (NULL == value) + return -1; + if (0 == strcasecmp(value, "IN")) + { + localopt->ecDisable=0; + localopt->ssDisable=0; + return 0; + } + else if (0 == strcasecmp(value, "IN, e:off")) + { + localopt->ecDisable=1; + localopt->ssDisable=0; + return 0; + } + else if (0 == strcasecmp(value, "IN, s:off")) + { + localopt->ecDisable=0; + localopt->ssDisable=1; + return 0; + } + else if (0 == strcasecmp(value, "IN, e:off, s:off")) + { + localopt->ecDisable=1; + localopt->ssDisable=1; + return 0; + } + else + return -1; +} + +int mgcp_local_opt_parse(MGCP_L *localopt, char *value) +{ + char hvaluename[64]; + char hvalue[128]; + char *colonIndex; + char *endofvalue = value; + char *begofvalue = value; + int len, commaNum = 0; + + if (NULL == value) + return -1; + + for (;;) + { + if ('\0' == *begofvalue) + return 0; + + begofvalue = endofvalue; + + if (2 > commaNum) + { + while(',' != *endofvalue) + { + if (*endofvalue) + endofvalue++; + else + { + printf("lack of comma,can not find endofvalue\n"); + return -1; + } + } + commaNum++; + } + else + { + while('\0' != *endofvalue) + { + if (*endofvalue) + endofvalue++; + } + } + colonIndex = strchr (begofvalue, ':'); + + if (NULL == colonIndex) + { + printf("can not find colonIndex in the value of Lopt, the wrong format.\n"); + return -1; + } + + if (endofvalue < colonIndex) + return -1; + + len = colonIndex - begofvalue; + mgcp_clrncpy(hvaluename, begofvalue, len); + + len = endofvalue -colonIndex-1; + mgcp_clrncpy(hvalue, colonIndex+1, len); + + if (strncasecmp(hvaluename, "p", 1) == 0) + { + if (mgcp_local_opt_p_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "a", 1) == 0) + { + if (mgcp_local_opt_a_parse(localopt, hvalue) < 0) + return -1; + } + else if (strncasecmp(hvaluename, "nt", 2) == 0) + { + if (mgcp_local_opt_nt_parse(localopt, hvalue) < 0) + return -1; + } + else + return -1; + + begofvalue = endofvalue++; + } + +} + +int mgcp_connect_mode_parse(MGCP_M *m, char *value) +{ + if (NULL == value) + return -1; + + if (mgcp_mode_str_to_api(value, &m->mode) < 0) + return -1; + + return 0; +} + +int mgcp_observed_reqId_parse(MGCP_O *o, char *value) +{ + if (NULL == value) + return -1; + + strcpy(o->reqId, value); + return 0; +} + +int mgcp_event_parse(DWORD transId, MGCP_O *o, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &o->package) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("event package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_event_str_to_api(hvalue, &o->event, o->package) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such event\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("event is unknown\n"); + return -1; + } + + return 0; +} + +int mgcp_signl_reqId_parse(MGCP_S *s, char *value) +{ + if (NULL == value) + return -1; + + strcpy(s->reqId, value); + return 0; +} + +int mgcp_signl_parse(DWORD transId, MGCP_S *s, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + if (0 == strcmp(value, "")) + { + s->signal = MGCP_PACKAGE_SIG_NONE; + return 0; + } + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in signal event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &s->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("signal package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_sig_str_to_api(hvalue, &s->signal, s->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such signal\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("signal event is unknown\n"); + return -1; + } + + return 0; +} + + +int mgcp_reqent_parse(DWORD transId, MGCP_R *r, char *value) +{ + char hvalue[128]; + char *begofvalue =value; + char *endofvalue; + char *slashIndex; + int len; + + if (NULL == value) + return -1; + + while('\0' != *begofvalue) + { + if(*begofvalue) + begofvalue++; + } + endofvalue = begofvalue; + + slashIndex = strchr(value, '/'); + if(NULL == slashIndex) + { + printf("can not find slash in signal event, the wrong format.\n"); + return -1; + } + + len=slashIndex-value; + mgcp_clrncpy(hvalue, value, len); + + if (mgcp_pkg_str_to_api(hvalue, &r->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unsupported or unknown package\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_UNPKG_INDEX); + printf("request event package is unknown\n"); + return -1; + } + + len=endofvalue-slashIndex-1; + mgcp_clrncpy(hvalue, slashIndex+1, len); + + if (mgcp_event_str_to_api(hvalue, &r->event, r->pkg) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no such request event\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(transId, MGCP_RET_CODE_NES_INDEX); + printf("request event is unknown\n"); + return -1; + } + + return 0; +} + +int mgcp_restart_mode_parse(MGCP_RM *rm, char *value) +{ + if (NULL == value) + return -1; + + if (mgcp_rm_str_to_api(value, &rm->rm) < 0) + { + return -1; + } + + return 0; +} + +int mgcp_restart_delay_parse(MGCP_RD *rd, char *value) +{ + if (NULL == value) + return -1; + + rd->rd = atoi(value); + return 0; +} + +int mgcp_msg_params_parse(BYTE cmdRes, WORD port, char *buf, char **body) +{ + char *colonIndex; + char hname[64]; + char hvalue[128]; + char *startOfHeader = buf; + char *endOfHeader; + char *end; + BYTE S_R_Flag = 0; + BYTE len; + MGCP_PARA *para; + + if (cmdRes == MGCP_COMMAND) + { + para = &mgcpPort[port].para; + } + else if (cmdRes == MGCP_RESPONSE) + { + para = &mgcpRespPara; + } + else + return -1; + + if ((startOfHeader[0] == '\0') && (mgcpPort[port].cmd != MGCP_CMD_AUEP)&&(cmdRes == MGCP_COMMAND)) + { + printf("no parameter in buf.\n"); + return -1; + } + + for (;;) + { + if (startOfHeader[0] == '\0') + { + *body = NULL; + return 0; + } + + if (mgcp_find_next_crlf(startOfHeader, &endOfHeader) < 0) + { + printf("End of header Not found\n"); + return -1; + } + + if ((startOfHeader[0] == '\r') || (startOfHeader[0] == '\n')) + { + *body = startOfHeader; + return 0; + } + else if (((startOfHeader[0] == '.') && (startOfHeader[1] == '\r') && (startOfHeader[2] == '\n'))) + { + *body = startOfHeader + 3; + return 1; + } + + // find the header name + colonIndex = strchr(startOfHeader, ':'); + if (colonIndex == NULL) + { + printf("End of header Not found\n"); + return -1; + } + if (endOfHeader <= colonIndex) + { + printf("Malformed message\n"); + return -1; + } + len = colonIndex - startOfHeader; + mgcp_clrncpy(hname, startOfHeader, len); + + // END of header is (end_of_header-2) if header separation is CRLF + // END of header is (end_of_header-1) if header separation is CR or LF + if ((endOfHeader[-2] == '\r') || (endOfHeader[-2] == '\n')) + end = endOfHeader - 2; + else + end = endOfHeader - 1; + if ((end - colonIndex) < 2) + strcpy(hvalue, ""); // some headers can be empty + else + { + len = end - colonIndex - 1; + mgcp_clrncpy(hvalue, colonIndex + 1, len); + } + + if (strncasecmp(hname, "I", 1) == 0) + { + if (mgcp_con_id_parse(¶->i, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "incorrect connect id\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_INCONID_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_I; + } + + if (strncasecmp(hname,"C",1) == 0) + { + if (mgcp_call_id_parse(¶->c, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "unknown call id\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNCLLID_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_C; + } + + if (strncasecmp(hname,"L",1) == 0) + { + if (mgcp_local_opt_parse(¶->l, hvalue) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "internal inconsistency in LocalConnectionOption\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_ILCO_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_L; + } + + if (strncasecmp(hname,"M",1) == 0) + { + if (mgcp_connect_mode_parse(¶->m, hvalue) < 0) + { + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNMD_INDEX); + return -1; + } + para->flag |=MGCP_PARA_FLAG_M; + } + + if (strncasecmp(hname,"O",1) == 0) + { + if ((para->flag & MGCP_PARA_FLAG_O) == 0) + return -1; + if (mgcp_event_parse(mgcpPort[port].transId, ¶->o, hvalue) < 0) + return -1; + } + + if (strncasecmp(hname,"X",1) == 0) + { + if (mgcpPort[port].cmd == MGCP_CMD_NTFY) + { + if (mgcp_observed_reqId_parse(¶->o, hvalue) < 0) + return -1; + para->flag |=MGCP_PARA_FLAG_O; + } + else + { + if (mgcp_signl_reqId_parse(¶->s, hvalue) < 0) + return -1; + S_R_Flag = 1; + } + } + + if (strncasecmp(hname,"S",1) == 0) + { + if (0 == S_R_Flag) + { + printf("Have no requestId.\n"); + return -1; + } + if (mgcp_signl_parse(mgcpPort[port].transId, ¶->s, hvalue) < 0) + return -1; + + para->flag |=MGCP_PARA_FLAG_S; + } + + if (strncasecmp(hname,"R",2) == 0) + { + if(0 == S_R_Flag) + { + printf("Have no requestId.\n"); + return -1; + } + if (mgcp_reqent_parse(mgcpPort[port].transId, ¶->r, hvalue) < 0) + return -1; + + para->flag |=MGCP_PARA_FLAG_R; + } + + if (strncasecmp(hname,"RM",2) == 0) + { + if (mgcp_restart_mode_parse(¶->rm, hvalue) < 0) + { + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_UNRM_INDEX); + return -1; + } + para->flag |= MGCP_PARA_FLAG_RM; + } + + if (strncasecmp(hname,"RD",2) == 0) + { + if (mgcp_restart_delay_parse(¶->rd, hvalue) < 0) + return -1; + para->flag |= MGCP_PARA_FLAG_RD; + } + + + // continue on the next header + startOfHeader = endOfHeader; + } + +// return -1; +} + +int mgcp_msg_parse_single(char *msg, WORD len, char **nextMsg, WORD networkPort) +{ + char *nextHeader; + int port; + MGCP_PARA *para; + BYTE cmdRes; + int ret; + + if ((port = mgcp_msg_start_line_parse(&cmdRes, msg, &nextHeader)) < 0) + { + if (port == -1) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "start_line_parse fault\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + } + else + { + if ((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", msg); + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + + return -1; + } + if (port >= MGCP_MAX_NUM_OF_PORT) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, msg); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if (cmdRes == MGCP_COMMAND) + { + para = &mgcpPort[port].para; + } + else if (cmdRes == MGCP_RESPONSE) + { + para = &mgcpRespPara; + } + else + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, msg); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } +// else +// para = &mgcpPort[port].para; + para->flag |= MGCP_PARA_FLAG_SL; + + if ((ret = mgcp_msg_params_parse(cmdRes, port, nextHeader, &nextHeader)) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "params_parse fault\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + + if (cmdRes == MGCP_COMMAND) + mgcp_port_init(port); + + return -1; + } + + + if (0 == ret) + { + if ((MGCP_CMD_CRCX == mgcpPort[port].cmd) || (MGCP_CMD_MDCX == mgcpPort[port].cmd)) + { + if (nextHeader != NULL) + { + pub_sdp_msg_init(¶->sdp); + if ((ret = pub_sdp_parse(¶->sdp, nextHeader, &nextHeader, 0xFFFFFFFF)) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "remotoconnectiondescriptor error\r\n%s\n", msg); + mgcp_log_err(mgcpAsciTempBuf); + } + + mgcp_send_incmd_rsp(mgcpPort[port].transId, MGCP_RET_CODE_RCD_ERR_INDEX); + + if (cmdRes == MGCP_COMMAND) + mgcp_port_init(port); + + return -1; + } + para->flag |= MGCP_PARA_FLAG_SDP; + } + } + } + + if (cmdRes == MGCP_RESPONSE) + memcpy(&mgcpPort[port].para, &mgcpRespPara, sizeof(MGCP_PARA)); + + if ((mgcpPort[port].para.localPort = networkPort) == MGCP_INT_PORT_2427) + { + mgcpPort[port].para.peerPort = MGCP_INT_PORT_2727; + } + else + { + mgcpPort[port].para.peerPort = MGCP_INT_PORT_2427; + } + + if (((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) || ((mgcpMonitorFg | MONITOR_ERROR) == MONITOR_ALL)) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else if ((mgcpMonitorFg | MONITOR_MG0_MSG | MONITOR_MG1_MSG | MONITOR_MG2_MSG |MONITOR_ERROR) == MONITOR_ALL) + { + if ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + || ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + || ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG)) + { + if ((((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0]))) + || (((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + || (((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])))) + { + if (mgcpPort[port].para.sl.cmdRes == MGCP_COMMAND) + { + sprintf(mgcpAsciTempBuf, "Receive Command: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else + { + sprintf(mgcpAsciTempBuf, "Receive Response: %s\r\n", mgcpRvMsg.msgContent); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + + if (1 == ret) + { + *nextMsg = nextHeader; + return 1; + } + + return 0; +} + +int mgcp_msg_parse(WORD networkPort) +{ + char *msg, *nextMsg; + WORD len; + WORD lenTotal; + int port; + MGCP_PARA *para; + BYTE cmdRes; + int ret; + int i; + + nextMsg = msg = mgcpRvMsg.msgContent; + lenTotal = len = mgcpRvMsg.msgLength; + + mgcp_util_replace_all_lws(msg); + + for (i = 0; i < 5; i++) + { + if ((ret = mgcp_msg_parse_single(nextMsg, len, &nextMsg, networkPort)) <= 0) + break; + else + { + len = nextMsg - msg; + + if (len >= lenTotal) + break; + else + len = lenTotal -len; + } + } + + return 1; +} + +void mgcp_recv_msg() +{ + BYTE i; + WORD port; + + for (i = 0; i < 64; i++) + { + if (i & 1) + port = MGCP_INT_PORT_2427; + else + port = MGCP_INT_PORT_2727; + + if (iptrDirectRecvMsg(&mgcpRvMsg, port) > 0) + { + if (mgcpRvMsg.msgLength >= 1500) + continue; + mgcpRvMsg.msgContent[mgcpRvMsg.msgLength] = '\0'; + mgcp_msg_parse(port); + } + } +} + +// MGCP Message Encoding + +int mgcp_create_req_id(WORD port, char *reqId) +{ + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + if (reqId[0] == '\0') + sprintf(reqId, "%X%lX", port, time(NULL)); + else + return 0; + + return 0; +} + +int mgcp_ep_id_encode(MGCP_SL *sl, char *endPointId) +{ + char epType[8]; + + if (sl->epNameMethod == MGCP_EP_NAME_UNSTRUCTURED) + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "*"); + else + sprintf(endPointId, "%d", sl->chlNum); + } + else if (sl->epNameMethod == MGCP_EP_NAME_STRUCTURED) + { + if ((sl->mgType >= MGCP_MG_TYPE_AudioCoder) && (sl->mgType < MGCP_MG_TYPE_ANN)) + { + if ((sl->portType == MGCP_PORT_TYPE_E1) || + (sl->portType == MGCP_PORT_TYPE_T1)) + { + if (sl->portType == MGCP_PORT_TYPE_E1) + sprintf(epType, "e1"); + else + sprintf(epType, "t1"); + if (MGCP_EP_NAME_TRK_WILDCAST == sl->trkNum) + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "ds/%s-*/*", epType); + else + sprintf(endPointId, "ds/%s-*/%d", epType, sl->chlNum); + } + else + { + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "ds/%s-%d/*", epType, sl->trkNum); + else + sprintf(endPointId, "ds/%s-%d/%d", epType, sl->trkNum, sl->chlNum); + } + } + else if (MGCP_PORT_TYPE_AALN == sl->portType) + { + sprintf(epType, "aaln"); + if (sl->trkNum == MGCP_EP_NAME_TRK_WILDCAST) + sprintf(endPointId, "%s/*", epType); + else + sprintf(endPointId, "%s/%d", epType, sl->trkNum); + } + else + return -1; + } + else if (sl->mgType == MGCP_MG_TYPE_ANN) + { + sprintf(epType, "ann"); + if (sl->chlNum == MGCP_EP_NAME_CHNL_WILDCAST) + sprintf(endPointId, "%s/*", epType); + else + sprintf(endPointId, "%s/%d", epType, sl->chlNum); + } + else + return -1; + } + else + return -1; + + return 0; +} + +int mgcp_para_call_id_encode(MGCP_C *c, char *msgPara) +{ + if ((c == NULL) || + (msgPara == NULL)) + return -1; + + sprintf(msgPara, "C: %s\r\n", c->callId); + + return 0; +} + +int mgcp_para_con_id_encode(MGCP_I *i, char *msgPara) +{ + if ((i == NULL) || + (msgPara == NULL)) + return -1; + + sprintf(msgPara, "I: %s\r\n", i->conId); + + return 0; +} + +int mgcp_para_local_con_opt_encode(MGCP_L *l, char *msgPara, WORD flag) +{ + if ((l == NULL) || + (msgPara == NULL)) + return -1; + + sprintf(msgPara, "L: p:%d, a:%s, nt:IN%s%s\r\n", l->p, l->codec, + (l->ecDisable)? ", e:off" : "", (l->ssDisable)? ", s:off" : ""); + + return 0; +} + +int mgcp_para_con_mode_encode(MGCP_M *m, char *msgPara) +{ + if ((m == NULL) || + (msgPara == NULL)) + return -1; + + if (m->mode > MGCP_CON_MODE_SENDRECV) + return -1; + + sprintf(msgPara, "M: %s\r\n", mgcpConModeToStr[m->mode]); + + return 0; +} + +int mgcp_para_signal_req_encode(WORD port, MGCP_S *s, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (s == NULL) || + (msgPara == NULL)) + return -1; + + if (s->pkg >= MGCP_PACKAGE_MAX) + return -1; + + + if (s->signal > mgcpMaxPkgSig[s->pkg]) + return -1; + + + if (mgcp_create_req_id(port, s->reqId) < 0) + return -1; + + sprintf(msgPara, "X: %s\r\n", s->reqId); + + if (s->signal == MGCP_PACKAGE_SIG_NONE) + strcat(msgPara, "S:\r\n"); + else + { + sprintf(str, "S: %s/%s\r\n", mgcpPkgToStr[s->pkg], mgcpAalnSigToStr[s->pkg][s->signal]); + strcat(msgPara, str); + } + + return 0; +} + +int mgcp_para_request_event_encode(WORD port, MGCP_R *r, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) ||(r == NULL) || + (msgPara == NULL)) + return -1; + + if (r->pkg >= MGCP_PACKAGE_MAX) + return -1; + + if (r->event > mgcpMaxPkgEvent[r->pkg]) + return -1; + + if (mgcp_create_req_id(port, r->reqId) < 0) + return -1; + + sprintf(msgPara, "X: %s\r\n", r->reqId); + + sprintf(str, "R: %s/%s\r\n", mgcpPkgToStr[r->pkg], mgcpEntToStr[r->pkg][r->event]); + strcpy(msgPara, str); + + return 0; +} + +int mgcp_para_observed_ent_encode(WORD port, MGCP_O *o, char *msgPara) +{ + char str[32]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) ||(o == NULL) || + (msgPara == NULL)) + return -1; + + if (o->package >= MGCP_PACKAGE_MAX) + return -1; + + if (o->event > mgcpMaxPkgEvent[o->package]) + return -1; + + if (mgcp_create_req_id(port, o->reqId) < 0) + return -1; + sprintf(msgPara, "X: %s\r\n", o->reqId); + + sprintf(str, "O: %s/%s\r\n", mgcpPkgToStr[o->package], mgcpEntToStr[o->package][o->event]); + strcat(msgPara, str); + + return 0; +} + + +int mgcp_para_restart_mod_encode(MGCP_RM *rm, char *msgPara) +{ + if ((NULL == rm)||(NULL == msgPara)) + return -1; + + if (rm->rm >= MGCP_REST_MOD_MAX) + return -1; + + sprintf(msgPara, "%s", mgcpRestModToStr[rm->rm]); + + return 0; +} + +int mgcp_para_restart_delay_encode(MGCP_RD *rd, char *msgPara) +{ + if ((NULL == rd)||(NULL == msgPara)) + return -1; + + sprintf(msgPara, "RD: %d\r\n", rd->rd); + + return 0; +} +/**/ +int mgcp_cmd_crcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) == 0) + return -1; + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_L) != 0) + { + if (mgcp_para_local_con_opt_encode(¶->l, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_M) == 0) + return -1; + if (mgcp_para_con_mode_encode(¶->m, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + return 0; +} + +int mgcp_cmd_mdcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) == 0) + return -1; + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_I) == 0) + return -1; + if (mgcp_para_con_id_encode(¶->i, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + if ((flag & MGCP_PARA_FLAG_L) != 0) + { + if (mgcp_para_local_con_opt_encode(¶->l, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_M) != 0) + { + if (mgcp_para_con_mode_encode(¶->m, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_dlcx_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_C) != 0) + { + if (mgcp_para_call_id_encode(¶->c, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_I) != 0) + { + if (mgcp_para_con_id_encode(¶->i, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_rqnt_para_encode(WORD port, char *msgText) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_S) != 0) + { + if (mgcp_para_signal_req_encode(port, ¶->s, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + if ((flag & MGCP_PARA_FLAG_R) != 0) + { + if (mgcp_para_request_event_encode(port, ¶->r, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + + return 0; +} + +int mgcp_cmd_ntfy_para_encode(WORD port, char *msgText) +{ + + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + + if ((flag & MGCP_PARA_FLAG_O) == 0) + return -1; + if (mgcp_para_observed_ent_encode(port, ¶->o, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + + return 0; +} + +int mgcp_cmd_auep_para_encode(WORD port, char *msgText) +{ + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + return 0; + +} + +int mgcp_cmd_rsip_para_encode(WORD port, char *msgText) +{ + + MGCP_PORT *trans; + MGCP_PARA *para; + DWORD flag; + char msgPara[128]; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (msgText == NULL)) + return -1; + + trans = &mgcpPort[port]; + para = &trans->para; + flag = para->flag; + if ((flag & MGCP_PARA_FLAG_RM) == 0) + return -1; + if (mgcp_para_restart_mod_encode(¶->rm, msgPara) < 0) + return -1; + sprintf(msgText, "RM: %s\r\n", msgPara); + + if ((flag & MGCP_PARA_FLAG_RD) != 0) + { + if (mgcp_para_restart_delay_encode(¶->rd, msgPara) < 0) + return -1; + strcat(msgText, msgPara); + } + return 0; + +} + +int mgcp_send_msg(WORD port, BYTE cmdRes) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + MGCP_SL *sl; + DWORD flag; + BYTE cmd; + WORD len; + char endPointId[16]; + char *msgText = mgcpSdMsg.msgContent; + char resPara[256]; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + msgText[MAX_CONTENT_LEN - 1] = '\0'; + + trans = &mgcpPort[port]; + + if (cmdRes == MGCP_COMMAND) + { + cmd = trans->cmd; + para = &trans->para; + flag = para->flag; + sl = ¶->sl; + + if ((flag & MGCP_PARA_FLAG_SL) == 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "MGCP_COMMAND have no sl flag\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if ((cmd < MGCP_CMD_CRCX) || (cmd > MGCP_CMD_RSIP)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "cmd is unknown\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + if (mgcp_ep_id_encode(sl, endPointId) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "ep id encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + // Start Line + if (0 == strcmp(sl->mgName, "")) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "no domain name\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + sprintf(msgText, "%s %ld %s@%s MGCP 1.0\r\n", mgcpCmdToStr[cmd], trans->transId, endPointId, sl->mgName); + + // Parameters + switch (cmd) + { + case MGCP_CMD_CRCX: + if (mgcp_cmd_crcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "crcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_MDCX: + if (mgcp_cmd_mdcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mdcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_DLCX: + if (mgcp_cmd_dlcx_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "dlcx para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_RQNT: + if (mgcp_cmd_rqnt_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "rqnt para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_NTFY: + if (mgcp_cmd_ntfy_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "ntfy para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_AUEP: + if (mgcp_cmd_auep_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "auep para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + case MGCP_CMD_RSIP: + if (mgcp_cmd_rsip_para_encode(port, msgText) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "rsip para encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + break; + default: + break; + } + + len = strlen(msgText); + + // SDP + if ((flag & MGCP_PARA_FLAG_SDP) != 0) + { + strcat(msgText, "\r\n"); + len += 2; + if (pub_sdp_encode(¶->sdp, msgText + len) < 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "pub sdp encode fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + len += strlen(msgText + len); + } + } + else + { + para = &trans->para; + flag = para->flag; + sl = ¶->sl; + + if ((flag & MGCP_PARA_FLAG_SL) == 0) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "MGCP_RESPONSE have no sl flag\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + // Start Line + sprintf(msgText, "%d %ld %s\r\n", sl->retCode, trans->transId, sl->desc); + + if ((trans->cmd == MGCP_CMD_CRCX) && (sl->retCode == 200)) + { + sprintf(resPara, "I: %s\r\n", para->i.conId); + strcat(msgText, resPara); + } + + len = strlen(msgText); + } + + if (((mgcpMonitorFg & MONITOR_ALL) == MONITOR_ALL) || ((mgcpMonitorFg | MONITOR_ERROR) == MONITOR_ALL)) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + else if ((mgcpMonitorFg | MONITOR_MG0_MSG | MONITOR_MG1_MSG | MONITOR_MG2_MSG |MONITOR_ERROR) == MONITOR_ALL) + { + if ((mgcpMonitorFg & MONITOR_MG0_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG1_MSG) == 0) + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if ((0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + && (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2]))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + else + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + else + { + if ((mgcpMonitorFg & MONITOR_MG2_MSG) == 0) + { + if (0 != strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + } + } + } + else if (((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) + || ((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) + || ((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG)) + { + if ((((mgcpMonitorFg & MONITOR_MG0_MSG) == MONITOR_MG0_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[0]))) + || (((mgcpMonitorFg & MONITOR_MG1_MSG) == MONITOR_MG1_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[1]))) + || (((mgcpMonitorFg & MONITOR_MG2_MSG) == MONITOR_MG2_MSG) && (0 == strcmp(mgcpPort[port].para.sl.mgName, dbgmgNamemg[2])))) + { + sprintf(mgcpAsciTempBuf, "Send Message: %s\r\n", msgText); + + mgcp_asciout_proc(mgcpAsciTempBuf); + } + } + + + mgcpSdMsg.msgDstIP = para->ip; + mgcpSdMsg.msgSrcPort = para->localPort; + mgcpSdMsg.msgDstPort = para->peerPort; + mgcpSdMsg.msgLength = len; + + iptrDirectSendMsg(mgcpSdMsg); + + return 0; +} + +int mgcp_send_rsp(WORD port, BYTE retCodeIndex) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + MGCP_SL *sl; +// WORD tPort; + + if ((port >= MGCP_MAX_NUM_OF_PORT) || + (retCodeIndex >= MGCP_MAX_RET_CODE_INDEX)) + { + if ((mgcpMonitorFg & MONITOR_ERROR) == MONITOR_ERROR) + { + sprintf(mgcpAsciTempBuf, "mgcp_send_rsp: port or retCodeIndex fault\r\n"); + mgcp_log_err(mgcpAsciTempBuf); + } + return -1; + } + + trans = &mgcpPort[port]; + para = &trans->para; + sl = ¶->sl; + + para->flag = MGCP_PARA_FLAG_SL; + + sl->cmdRes = MGCP_RESPONSE; + sl->retCode = mgcpRetCode[retCodeIndex].retCode; + strcpy(sl->desc, mgcpRetCode[retCodeIndex].desc); + + if (mgcp_send_msg(port, MGCP_RESPONSE) < 0) + return -1; + + return 0; +} + +int mgcp_send_incmd_rsp(DWORD transId, BYTE retCodeIndex) +{ + MGCP_PORT *trans; + MGCP_PARA *para; + + trans = &mgcpPort[0]; + para = &trans->para; + + trans->transId = transId; + para->ip = mgcpRvMsg.msgSrcIP; + para->peerPort = mgcpRvMsg.msgSrcPort; + para->localPort = mgcpRvMsg.msgDstPort; + + if (mgcp_send_rsp(0, retCodeIndex) < 0) + return -1; + + return 0; +} diff --git a/omc/plat/mgcp/src/mgcp_trans.c b/omc/plat/mgcp/src/mgcp_trans.c new file mode 100644 index 0000000..71afd19 --- /dev/null +++ b/omc/plat/mgcp/src/mgcp_trans.c @@ -0,0 +1,300 @@ +#include "./include/mgcp_pub.h" +#include "./include/mgcp.h" +#include "./include/mgcp_const.h" +#include "./include/mgcp_ext.h" +#include "./include/mgcp_struct.h" +#include "./include/mgcp_msg.h" + +int mgcp_create_trans_id(WORD port) +{ + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + mgcpTransStart[port]++; + + mgcpPort[port].transId = (port << 16) | mgcpTransStart[port]; + + return 0; +} + +int mgcp_match_client_trans(DWORD transId) +{ + WORD port; + DWORD srcIp; + MGCP_PORT *trans; + + port = transId >> 16; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return -1; + + trans = &mgcpPort[port]; + if (trans->flag == 0) + return -1; + + srcIp = mgcpRvMsg.msgSrcIP; + + if ((trans->reqInd == MGCP_REQUEST) + && (trans->transId == transId) + && (trans->para.ip == srcIp)) + return port; + + return -1; +} + +int mgcp_match_server_trans(DWORD transId) +{ + WORD port; + DWORD srcIp; + MGCP_PORT *trans; + + srcIp = mgcpRvMsg.msgSrcIP; + + for (port = 1; port < MGCP_MAX_NUM_OF_PORT; port++) + { + trans = &mgcpPort[port]; + if (trans->flag == 0) + continue; + + if ((trans->reqInd == MGCP_INDICATION) + && (trans->transId == transId) + && (trans->para.ip == srcIp)) + { + if (1 == trans->state2) + { + mgcp_send_msg(port, MGCP_RESPONSE); + + trans->timer = MGCP_TIME_WAIT_TIMER; + } + return port; + } + } + + return -1; +} + +BYTE mgcp_trans_init_proc(WORD port) +{ + if (port >= MGCP_MAX_NUM_OF_PORT) + return 0; + + memset((BYTE *) &mgcpPort[port], 0, sizeof(MGCP_PORT)); + + return 1; +} + +BYTE mgcp_trans_idle_proc(WORD port) +{ + BYTE cmd; + MGCP_PARA *para; + MGCP_PORT *trans; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return 0; + + trans = &mgcpPort[port]; + cmd = trans->cmd; + + if ((cmd < MGCP_CMD_CRCX) || (cmd > MGCP_CMD_RSIP)) + return 3; + + para = &trans->para; + + if (para->sl.cmdRes == MGCP_COMMAND) + { + para->sl.cmdRes = 0; + + if (trans->reqInd == MGCP_REQUEST) + { + mgcp_create_trans_id(port); + if (mgcp_send_msg(port, MGCP_COMMAND) < 0) + { + if (mgcpSap[0].MGCP_cnf == NULL) + return 3; + mgcpSap[0].MGCP_cnf(trans->cmd, trans->usrPort, port, MGCP_RET_CODE_TRANS_TIME_OUT, &trans->para); + return 3; + } + trans->timer = MGCP_MAX_RETRANS_TIMER; + return 1; + } + else if (trans->reqInd == MGCP_INDICATION) + { + if (mgcpSap[0].MGCP_ind == NULL) + return 3; + + if (mgcpSap[0].MGCP_ind(cmd, &trans->usrPort, port, para) < 0) + return 3; + + trans->timer = MGCP_MAX_RETRANS_TIMER; + return 2; + } + else + return 3; + } + + return 3; +} + +BYTE mgcp_trans_await_peer_response_proc(WORD port) +{ + MGCP_PORT *trans; + MGCP_SL *sl; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return 0; + + trans = &mgcpPort[port]; + sl = &trans->para.sl; + + if ((trans->cmd < MGCP_CMD_CRCX) || (trans->cmd > MGCP_CMD_RSIP)) + return 1; + + if (sl->cmdRes == MGCP_RESPONSE) + { + if (mgcpSap[0].MGCP_cnf == NULL) + return 1; + + if (mgcpSap[0].MGCP_cnf(trans->cmd, trans->usrPort, port, sl->retCode, &trans->para) < 0) + return 1; + else + { + if ((sl->retCode < 100) || + (sl->retCode >= 200)) + return 1; + sl->cmdRes = 0; + trans->gotProvRes = 1; + } + } + + if (trans->timer > 0) + { + if (--trans->timer == 0) + { + if (mgcpSap[0].MGCP_cnf == NULL) + return 1; + mgcpSap[0].MGCP_cnf(trans->cmd, trans->usrPort, port, MGCP_RET_CODE_TRANS_TIME_OUT, &trans->para); + return 1; + } + else if ((trans->gotProvRes == 0) && + ((trans->timer % MGCP_RETRANS_TIMER) == 0)) + mgcp_send_msg(port, MGCP_COMMAND); + } + + return 0; +} + +BYTE mgcp_trans_await_user_response_proc(WORD port) +{ + MGCP_PORT *trans; + MGCP_SL *sl; + + if (port >= MGCP_MAX_NUM_OF_PORT) + return 0; + + trans = &mgcpPort[port]; + sl = &trans->para.sl; + + switch (trans->state2 & 1) + { + case 0: + if (sl->cmdRes == MGCP_RESPONSE) + { + if (mgcp_send_msg(port, MGCP_RESPONSE) < 0) + return 1; + + if ((sl->retCode < 100) || + (sl->retCode >= 200)) + { + trans->state2 = 1; + trans->timer = MGCP_TIME_WAIT_TIMER; + return 0; + } + sl->cmdRes = 0; + trans->gotProvRes = 1; + } + + if (trans->timer > 0) + { + if (--trans->timer == 0) + { + if (mgcp_send_rsp(port, MGCP_RET_CODE_TRANS_TIME_OUT_INDEX) < 0) + return 1; + + trans->state2 = 1; + trans->timer = MGCP_TIME_WAIT_TIMER; + return 0; + } + } + break; + case 1: + if (trans->timer > 0) + { + if (--trans->timer == 0) + return 1; + } + break; + } + + return 0; +} + +void mgcp_trans_proc() +{ + WORD port; + + for (port = 1; port < MGCP_MAX_NUM_OF_PORT; port++) + { + if (mgcpPort[port].flag != 1) + continue; + + switch (mgcpPort[port].state) + { + case MGCP_TRANS_IDLE_STATE: + switch (mgcp_trans_idle_proc(port)) + { + case 0: + break; + case 1: + mgcpPort[port].state = MGCP_TRANS_AWAIT_PEER_RESPONSE_STATE; + break; + case 2: + mgcpPort[port].state = MGCP_TRANS_AWAIT_USER_RESPONSE_STATE; + break; + case 3: + mgcpPort[port].state = MGCP_TRANS_INIT_STATE; + break; + } + break; + case MGCP_TRANS_AWAIT_PEER_RESPONSE_STATE: + switch (mgcp_trans_await_peer_response_proc(port)) + { + case 0: + break; + case 1: + mgcpPort[port].state = MGCP_TRANS_INIT_STATE; + break; + } + break; + case MGCP_TRANS_AWAIT_USER_RESPONSE_STATE: + switch (mgcp_trans_await_user_response_proc(port)) + { + case 0: + break; + case 1: + mgcpPort[port].state = MGCP_TRANS_INIT_STATE; + break; + } + break; + case MGCP_TRANS_INIT_STATE: + switch (mgcp_trans_init_proc(port)) + { + case 0: + break; + case 1: + mgcpPort[port].state = MGCP_TRANS_IDLE_STATE; + break; + } + break; + } + } +} diff --git a/omc/plat/mtp3/.copyarea.db b/omc/plat/mtp3/.copyarea.db new file mode 100644 index 0000000..b15dc1b --- /dev/null +++ b/omc/plat/mtp3/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3 +2 +5 +3:doc|2|0|0|0|49e96a1fbfa511dc85a0001c23e19543|0 +2:ut|2|0|0|0|58396c6bbfa511dc85a0001c23e19543|0 +3:src|2|0|0|0|4bb96a73bfa511dc85a0001c23e19543|0 +8:Makefile|1|11d70a41c54|b71|77f4d1c1|4b196a57bfa511dc85a0001c23e19543|0 +3:lib|2|0|0|0|4a896a3bbfa511dc85a0001c23e19543|0 diff --git a/omc/plat/mtp3/Makefile b/omc/plat/mtp3/Makefile new file mode 100644 index 0000000..967afb0 --- /dev/null +++ b/omc/plat/mtp3/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = mtp3 +TYPE = plat + +DBUG_FLAGS_ADD = -DDEBUG -D_INCLUDE_M2UA -D_CDMA_SNMP +RELS_FLAGS_ADD = -D_INCLUDE_M2UA -D_CDMA_SNMP + +##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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/mtp3/lib/libmtp3.a b/omc/plat/mtp3/lib/libmtp3.a new file mode 100644 index 0000000..efd8407 Binary files /dev/null and b/omc/plat/mtp3/lib/libmtp3.a differ diff --git a/omc/plat/mtp3/obj/mtp3lite.o b/omc/plat/mtp3/obj/mtp3lite.o new file mode 100644 index 0000000..27eb34f Binary files /dev/null and b/omc/plat/mtp3/obj/mtp3lite.o differ diff --git a/omc/plat/mtp3/obj/mtpinit.o b/omc/plat/mtp3/obj/mtpinit.o new file mode 100644 index 0000000..2be5a33 Binary files /dev/null and b/omc/plat/mtp3/obj/mtpinit.o differ diff --git a/omc/plat/mtp3/obj/mtpm.o b/omc/plat/mtp3/obj/mtpm.o new file mode 100644 index 0000000..095e6d0 Binary files /dev/null and b/omc/plat/mtp3/obj/mtpm.o differ diff --git a/omc/plat/mtp3/obj/mtpmib.o b/omc/plat/mtp3/obj/mtpmib.o new file mode 100644 index 0000000..1ce71db Binary files /dev/null and b/omc/plat/mtp3/obj/mtpmib.o differ diff --git a/omc/plat/mtp3/obj/mtpslm.o b/omc/plat/mtp3/obj/mtpslm.o new file mode 100644 index 0000000..f585b33 Binary files /dev/null and b/omc/plat/mtp3/obj/mtpslm.o differ diff --git a/omc/plat/mtp3/obj/mtpsmh.o b/omc/plat/mtp3/obj/mtpsmh.o new file mode 100644 index 0000000..0f0fb90 Binary files /dev/null and b/omc/plat/mtp3/obj/mtpsmh.o differ diff --git a/omc/plat/mtp3/obj/mtpsrm.o b/omc/plat/mtp3/obj/mtpsrm.o new file mode 100644 index 0000000..c408e37 Binary files /dev/null and b/omc/plat/mtp3/obj/mtpsrm.o differ diff --git a/omc/plat/mtp3/obj/mtpstm.o b/omc/plat/mtp3/obj/mtpstm.o new file mode 100644 index 0000000..eef494e Binary files /dev/null and b/omc/plat/mtp3/obj/mtpstm.o differ diff --git a/omc/plat/mtp3/src/.copyarea.db b/omc/plat/mtp3/src/.copyarea.db new file mode 100644 index 0000000..c62ca00 --- /dev/null +++ b/omc/plat/mtp3/src/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3\src +2 +9 +8:mtpmib.c|1|11d9047aab9|f0f1|263f8bde|2ab9bcfdb07f11dd85e3001c23e19543|0 +8:mtpsmh.c|1|11d70a41d0f|1be10|96e61327|ecb484de6cf311dd91a5001c23e19543|0 +8:mtpslm.c|1|11d70a41e76|2a52|6ee27efa|a95b4dee15c111dd8f7b001c23e19543|0 +7:include|2|0|0|0|4e196ae3bfa511dc85a0001c23e19543|0 +8:mtpstm.c|1|11d70a41d3e|f9dd|3876dc4e|ef5346de339011dd9fa7001c23e19543|0 +8:mtpsrm.c|1|11d70a41dda|2126|72c62bcc|f1b347ce339011dd9fa7001c23e19543|0 +9:mtpinit.c|1|11d70a41e47|c26b|85cc797c|ede485266cf311dd91a5001c23e19543|0 +a:mtp3lite.c|1|11d70a41d6d|4bd8|17766c21|ed4484f66cf311dd91a5001c23e19543|0 +6:mtpm.c|1|11d9047ab36|e316|50230af0|0d28dec5b05e11dd8511001c23e19543|0 diff --git a/omc/plat/mtp3/src/include/.copyarea.db b/omc/plat/mtp3/src/include/.copyarea.db new file mode 100644 index 0000000..1baaf0b --- /dev/null +++ b/omc/plat/mtp3/src/include/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3\src\include +2 +8 +8:mtpdef.h|1|11d70a4203b|d08|59b0359a|f1234786339011dd9fa7001c23e19543|0 +9:mtpfunc.h|1|11d70a4206a|117d|a4742d2c|f123479e339011dd9fa7001c23e19543|0 +8:mtpext.h|1|11d70a41ffd|f14|6c4f1cc8|f083476e339011dd9fa7001c23e19543|0 +a:mtp3lite.h|1|11d70a41f9f|1f9|4ea3a3fb|f083473e339011dd9fa7001c23e19543|0 +e:mtp3lite_pub.h|1|11d70a41fce|3c4|1c113fad|f0834756339011dd9fa7001c23e19543|0 +6:mtp3.h|1|11d70a41f61|109d|ecb1683c|eff34726339011dd9fa7001c23e19543|0 +a:mtpconst.h|1|11d9047ab93|418e|88c053ff|0c88debeb05e11dd8510001c23e19543|0 +8:mtpstm.h|1|11d70a41f03|1706|33254f89|ef5346f6339011dd9fa7001c23e19543|0 diff --git a/omc/plat/mtp3/src/include/mtp3.h b/omc/plat/mtp3/src/include/mtp3.h new file mode 100644 index 0000000..d24c8b1 --- /dev/null +++ b/omc/plat/mtp3/src/include/mtp3.h @@ -0,0 +1,171 @@ +#include "../../../iptrans/src/include/iptrans.h" +#ifdef _INCLUDE_M2UA + #include "../../../m2ua/src/include/m2ua.h" +#endif +#ifndef _MTP3_HEAD_FILE +#define _MTP3_HEAD_FILE + +#define _up_message up_message +#define MAX_SS7_MSG_LEN 272 + +typedef struct up_message{ + long dest_ip; + long dpc; + long opc; + BYTE cic[2]; + BYTE link; + BYTE sio; +// BYTE len;/* len not include itself */ + WORD len;//long message + BYTE msgList[MAX_SS7_MSG_LEN]; +}up_message; + +typedef struct up_message_2{ + long dest_ip; + long dpc; + long opc; + BYTE cic[4]; + BYTE link; + BYTE sio; // 13 for BICC +// BYTE len;/* len not include itself */ + WORD len;//long message + BYTE msgList[MAX_SS7_MSG_LEN]; +}up_message_2; + +typedef struct up_buffer /* user part buffer. user part:telephone user part, + isdn user part, and sccp part */ +{ + BYTE RSub; /* subscript of array msgList for reader */ + BYTE WSub; /* subscript of array msgList for writer */ + up_message msgNum[256];/* this buffer can storge up to 256 + messages */ +}up_buffer; + +typedef struct up_buffer_2 /* user part buffer. user part:telephone user part, + isdn user part, and sccp part */ +{ + BYTE RSub; /* subscript of array msgList for reader */ + BYTE WSub; /* subscript of array msgList for writer */ + up_message_2 msgNum[256];/* this buffer can storge up to 256 + messages */ +}up_buffer_2; + +#define _tup_shm tup_shm +typedef struct tup_shm { + up_buffer TM_Buf; + up_buffer MT_Buf; +} tup_shm; + +#define _isup_shm isup_shm +typedef struct isup_shm { + up_buffer IM_Buf; + up_buffer MI_Buf; +} isup_shm; + +#define _bicc_shm bicc_shm +typedef struct bicc_shm { + up_buffer_2 IM_Buf; + up_buffer_2 MI_Buf; +} bicc_shm; + +#define _sccp_shm sccp_shm +typedef struct sccp_shm { + up_buffer SM_Buf; + up_buffer MS_Buf; +} sccp_shm; + +typedef struct iprt1 +{ + BYTE pad[20] __attribute__((packed)); + message_list io_msg __attribute__((packed)); +}iprt1; + +typedef struct mtp_primitive +{ + long pc; + BYTE nw_indicator; + BYTE availability; +}mtp_primitive; + +typedef struct primitive_to_tup +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_tup; + +typedef struct primitive_to_isup +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_isup; + +typedef struct primitive_to_bicc +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_bicc; + +typedef struct primitive_to_sccp +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_sccp; + +typedef struct mtp3_routing_result +{ + BYTE tupMsgOutLink[256]; + BYTE isupMsgOutLink[256]; + BYTE biccMsgOutLink[256]; + BYTE sccpMsgOutLink[256]; +}mtp3_routing_result; + +#define MTP3DB_CMD 0 +#define MTP3DB_SNMMSG 1 +#define MTP3DB_SCCPMSG 2 +#define MTP3DB_TUPMSG 3 +#define MTP3DB_ISUPMSG 4 +#define MTP3DB_ERROR 5 +#define MTP3DB_EVENT 6 +#define MTP3DB_ALLLKON 7 +#define MTP3DB_PFHB 8// platform heartbeat +#define MTP3DB_APP_APP_MSG 9// msg from app to app +#define MTP3DB_PRIMITIVE_MSG 10// msg from MTP3 to MTP2 +#define MTP3DB_BICCMSG 11 + +void mtp_shm_init(WORD moduleid_systemid); +//moduleid = 8/9/11 vss/mss/aas +//void iptrans_init(); +void mtp3_proc(); +int tup_to_mtp3(up_message *msgptr); +int isup_to_mtp3(up_message *msgptr); +int bicc_to_mtp3(up_message_2 *msgptr); +int sccp_to_mtp3(up_message *msgptr); +int sccp_redirect(up_message *msgptr); +int bicc_redirect(up_message_2 *msgptr); +int isup_redirect(up_message *msgptr); +int tup_GetMsg(up_message *msgptr); +int isup_GetMsg(up_message *msgptr); +int bicc_GetMsg(up_message_2 *msgptr); +int sccp_GetMsg(up_message *msgptr); +int sccp_get_SPstate(mtp_primitive *ptr); +int isup_get_SPstate(mtp_primitive *ptr); +int bicc_get_SPstate(mtp_primitive *ptr); +int tup_get_SPstate(mtp_primitive *ptr); +BYTE *spc_to_acn(BYTE netID,DWORD spc); +BYTE mtp3_ansiFlag(BYTE netID); +BYTE *check_MTP3LinkType(); +BYTE *check_MTP3LinkL2State(); +void MTP3_activate(DWORD ip); +void MTP3_deactivate(DWORD ip); +void MTP3_Enable_SubSystem(BYTE SubSystem); +void MTP3_Disable_SubSystem(BYTE SubSystem); +void mtp3_init_serial(char *Serial); +int mtp3_create_opc(BYTE nw, DWORD opc); +int mtp3_delete_opc(BYTE nw, DWORD opc); +int check_m3ua_rc_verify(DWORD rc); + +#endif diff --git a/omc/plat/mtp3/src/include/mtp3lite.h b/omc/plat/mtp3/src/include/mtp3lite.h new file mode 100644 index 0000000..b6ea464 --- /dev/null +++ b/omc/plat/mtp3/src/include/mtp3lite.h @@ -0,0 +1,28 @@ +#ifndef _MTP3LITE_H +#define _MTP3LITE_H + +#include "mtp3lite_pub.h" + +typedef struct _mtp3lite_lk +{ + int connfd; + int cliSockfd; + WORD remote_port; + WORD local_inactive; + WORD local_reconnect; + WORD remote_inactive; + BYTE remote_inactive_timeouts; + WORD init_guard_timer; +}mtp3lite_lk; + +void mtp3lite_init(void); +void mtp3lite_timer(void); + +int put_mtp3lite_msg(BYTE *msg_ptr); + +#define MTP3LITE_TCP_FAILURE 16 +#define MTP3LITE_INACTIVITY_TIMEOUT 17 + +#define MTP3LITE_MSG_BUF_SIZE_PER_LINK 1024 + +#endif diff --git a/omc/plat/mtp3/src/include/mtp3lite_pub.h b/omc/plat/mtp3/src/include/mtp3lite_pub.h new file mode 100644 index 0000000..f105dfd --- /dev/null +++ b/omc/plat/mtp3/src/include/mtp3lite_pub.h @@ -0,0 +1,53 @@ +#ifndef _MTP3LITE_PUB__H +#define _MTP3LITE_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/omc/plat/mtp3/src/include/mtpconst.h b/omc/plat/mtp3/src/include/mtpconst.h new file mode 100644 index 0000000..102f38e --- /dev/null +++ b/omc/plat/mtp3/src/include/mtpconst.h @@ -0,0 +1,575 @@ +#ifndef _T_ULL +#define _T_ULL + typedef unsigned long long ull; +#endif + + +#define SIGNAL_TFA 0x54 +#define SIGNAL_TFP 0x14 +#define SIGNAL_TRA 0x17 +#define SIGNAL_RST 0x15 +#define SIGNAL_COO 0x11 +#define SIGNAL_COA 0x21 +#define SIGNAL_CBD 0x51 +#define SIGNAL_CBA 0x61 +#define SIGNAL_ECO 0x12 +#define SIGNAL_ECA 0x22 +#define SIGNAL_LIN 0x16 +#define SIGNAL_LUN 0x26 +#define SIGNAL_LIA 0x36 +#define SIGNAL_LUA 0x46 +#define SIGNAL_LID 0x56 +#define SIGNAL_LFU 0x66 +#define SIGNAL_LLT 0x76 +#define SIGNAL_LRT 0x86 +#define SIGNAL_SLTM 0x11 +#define SIGNAL_SLTA 0x21 + + +#define MTP3_ISUP_IAM 0x01 +#define MTP3_ISUP_ACM 0x06 +#define MTP3_ISUP_CPG 0x2c +#define MTP3_ISUP_ANM 0x09 +#define MTP3_ISUP_REL 0x0c +#define MTP3_ISUP_RLC 0x10 +#define MTP3_ISUP_UBL 0x14 +#define MTP3_ISUP_UBA 0x16 +#define MTP3_ISUP_GRA 0x19 + + +#define MTP3_TUP_IAM 0x11 +#define MTP3_TUP_IAI 0x21 +#define MTP3_TUP_SAM 0x31 +#define MTP3_TUP_SAO 0x41 +#define MTP3_TUP_GSM 0x12 +#define MTP3_TUP_COT 0x32 +/*#define MTP3_TUP_CCF '0x42',*/ +#define MTP3_TUP_GRQ 0x13 +#define MTP3_TUP_ACM 0x14 +#define MTP3_TUP_SEC 0x15 +#define MTP3_TUP_CGC 0x25 +#define MTP3_TUP_CFL 0x55 +#define MTP3_TUP_SSB 0x65 +/*#define MTP3_TUP_SLB 0x1E, +#define MTP3_TUP_STB 0x2E,*/ +#define MTP3_TUP_UNN 0x75 +#define MTP3_TUP_LOS 0x85 +#define MTP3_TUP_SST 0x95 +#define MTP3_TUP_ACB 0xa5 +#define MTP3_TUP_DPN 0xb5 +#define MTP3_TUP_ANU 0x06 +#define MTP3_TUP_ANC 0x16 +#define MTP3_TUP_ANN 0x26 +#define MTP3_TUP_CBK 0x36 +#define MTP3_TUP_CLF 0x46 +#define MTP3_TUP_CCL 0x76 +#define MTP3_TUP_RLG 0x17 +#define MTP3_TUP_BLO 0x27 +#define MTP3_TUP_BLA 0x37 +#define MTP3_TUP_UBL 0x47 +#define MTP3_TUP_UBA 0x57 +#define MTP3_TUP_ADI 0x45 + + +#define MTP3_SCCP_CR 1 +#define MTP3_SCCP_CC 2 +#define MTP3_SCCP_CREF 3 +#define MTP3_SCCP_RLSD 4 +#define MTP3_SCCP_RLC 5 +#define MTP3_SCCP_DT1 6 +#define MTP3_SCCP_DT2 7 +#define MTP3_SCCP_AK 8 +#define MTP3_SCCP_UDT 9 +#define MTP3_SCCP_UDTS 10 +#define MTP3_SCCP_ED 11 +#define MTP3_SCCP_EA 12 +#define MTP3_SCCP_RSR 13 +#define MTP3_SCCP_RSC 14 +#define MTP3_SCCP_ERR 15 +#define MTP3_SCCP_IT 16 +#define MTP3_SCCP_XUDT 17 +#define MTP3_SCCP_XUDTS 18 +#define MTP3_SCCP_LUDT 19 +#define MTP3_SCCP_LUDTS 20 + + +#define BETWEEN_LS 0x00 +#define WITHIN_LS 0x01 + +#define NORMAL_LS 0x00 +#define ALTERNATIVE_LS 0x01 +#define NO_ROUTE 0x02 + +/**************************************TCOC INPUT**************************************/ +/* TCOC INPUT FROM L2 */ + +#define TCOC_L2_BSNT 1 +#define TCOC_L2_BSNT_CANNOT_RECOVER 2 +#define TCOC_L2_RETRIEVED_MSG 3 +#define TCOC_L2_RETRIEVAL_CMP 4 +#define TCOC_L2_RETRIEVAL_NOT_POSSIBLE 5 + +/* TCOC INPUT FROM TSRC */ +#define TCOC_ALTERATIVE_ROUTE_DT 1 + +/* TCOC INPUT FROM STM */ +#define TCOC_LINK_UNAVAILABLE 1 +#define TCOC_LINK_AVAILABLE 2 +#define TCOC_TLAC_COO_COMMAND 3 +#define TCOC_TLAC_ECO_COMMAND 4 + +/* TCOC INPUT FROM HMDT */ +#define TCOC_HMDT_COA_COMMAND 1 +#define TCOC_HMDT_ECA_COMMAND 2 + +/* TCOC INPUT FROM L2 */ +//#define TCOC_L2_RETRIEVED_MSG 1 +#define TCOC_L2_RETRIEVE_CMP 254 +#define TCOC_L2_RETRIEVE_NOT_POSSIBLE 255 +/**************************************TCOC INPUT**************************************/ + + +/**************************************TCBC INPUT**************************************/ +#define TCBC_LINK_UNAVAILABLE 1 +#define TCBC_LINK_AVAILABLE 2 +#define TCBC_HMDT_CBD_COMMAND 3 +#define TCBC_HMDT_CBA_COMMAND 4 + +/* TCBC INPUT FROM TSRC */ +#define TCBC_ALTERATIVE_ROUTE_DT 1 + +/**************************************TCBC INPUT**************************************/ + + +/**************************************TLAC INPUT**************************************/ +/* TLAC INPUT FROM HMDT*/ +#define TLAC_HMDT_INHIBIT_SIGLINK 1 +#define TLAC_HMDT_UINHIBIT_SIGLINK 2 +#define TLAC_HMDT_INHIBIT_ACK 3 +#define TLAC_HMDT_UNINHIBIT_ACK 4 +#define TLAC_HMDT_INHIBIT_DENIED 5 +#define TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK 6 +#define TLAC_HMDT_CHANGEOVER_ORDER 7 +#define TLAC_HMDT_ECHANGEOVER_ORDER 8 +#define TLAC_HMDT_LOCAL_INHIBIT_TEST 9 +#define TLAC_HMDT_REMOTE_INHIBIT_TEST 10 + + +/* TLAC INPUT FROM MGMT */ +#define TLAC_MGMT_INHIBIT_SIGLINK 1 +#define TLAC_MGMT_UINHIBIT_SIGLINK 2 + +/* TLAC INPUT FROM SLM */ +#define TLAC_LSAC_SIGLINK_FAILED 1 +#define TLAC_LSAC_LINK_IN_SERVICE 2 +#define TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE 3 +#define TLAC_LSAC_REMOTE_PROCESSOR_RECOVER 4 + +/* TLAC INPUT FROM STM */ +#define TLAC_TCBC_CHANGEBACK_TERMINATED 1 +#define TLAC_TCOC_CHANGEOVER_EXECUTED 2 +#define TLAC_TCOC_CHANGEOVER_NOT_REQ 3 +#define TLAC_LOCAL_INHIBIT_ALLOWED 4 +#define TLAC_REMOTE_INHIBIT_ALLOWED 5 +#define TLAC_LOCAL_INHIBIT_DENIED 6 +#define TLAC_REMOTE_INHIBIT_DENIED 7 +#define TLAC_UINHIBIT_SIGLINK_FROM_TSRC 8 +#define TLAC_UNINHIBIT_NOT_POSSIBLE 9 +#define TLAC_UNINHIBIT_POSSIBLE 10 +#define TLAC_ADJACENT_SP_RESTARTING 11 +#define TLAC_RESTART_BEGINS 12 +#define TLAC_RESTART_ENDS 13 +#define TLAC_ADJACENT_SP_RESTART_ENDS 14 + +/* TLAC INPUT FROM TIMER CONTROL */ +#define TLAC_T12_EXPIRED 1 +#define TLAC_T13_EXPIRED 2 +#define TLAC_T14_EXPIRED 3 +#define TLAC_T22_EXPIRED 4 +#define TLAC_T23_EXPIRED 5 +/**************************************TLAC INPUT**************************************/ + + +/**************************************TSRC INPUT**************************************/ +/* TSRC_INPUT_FROM_TCOC */ +#define TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_TCOC_ACCESS_DATA_REQ 2 +#define TSRC_TCOC_CHANGEOVER_EXECUTED 3 +#define TSRC_TCOC_CHANGEOVER_NOT_REQ 4 + +/* TSRC_INPUT_FROM_TCBC */ +#define TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_PROCEDURE_TERMINATED 2 + +/*TSRC_INPUT_FROM_STM*/ +#define TSRC_TFRC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_TCRC_ALTERNATIVE_ROUTING_DATA_REQUEST 2 +#define TSRC_RESTART_BEGINS 3 +#define TSRC_RESTART_ENDS 4 +#define TSRC_TRAFFIC_RESTART_ALLOWED 5 +#define TSRC_SENDING_STATUS_PHASE 6 + +/*TSRC_INPUT_FROM_SRM*/ +#define TSRC_RTAC_ROUTE_AVAILABLE 1 +#define TSRC_RTPC_ROUTE_UNAVAILABLE 2 + +/* TSRC_INPUT_FROM_TLAC */ +#define TSRC_TLAC_LINK_UNAVAILABLE 1 +#define TSRC_TLAC_LINK_AVAILABLE 2 +#define TSRC_TLAC_LOCAL_INHIBIT_REQ 3 +#define TSRC_TLAC_REMOTE_INHIBIT_REQ 4 +#define TSRC_TLAC_LINK_INHIBITED 5 +#define TSRC_TLAC_CANCEL_LINK_INHIBITED 6 +#define TSRC_TLAC_UNINHIBIT_REQ 7 +/**************************************TSRC INPUT**************************************/ + + +/**************************************TFRC INPUT**************************************/ +#define TFRC_SIG_RT_UNAVAILABLE 0 +#define TFRC_SIG_RT_AVAILABLE 1 +#define TFRC_ALTERNATIVE_RT_DT 2 +/**************************************TFRC INPUT**************************************/ + + +/**************************************TCRC INPUT**************************************/ +#define TCRC_SIG_RT_AVAILABLE 0 +#define TCRC_ALTERNATIVE_RT_DT 1 +/**************************************TCRC INPUT**************************************/ + +/**************************************TPRC INPUT**************************************/ +#define TPRC_ADJACENT_SP_RESTARTING 1 +#define TPRC_TRA_MSG 2 +#define TPRC_RTPC_TFP_SENT 3 +/**************************************TPRC INPUT ABOUT dst**************************************/ +#define TPRC_LINK_AVAILABLE 1 +#define TPRC_LINK_UNAVAILABLE 2 +#define TPRC_SP_RESTART_INDICATION 3 +#define TPRC_STATUS_SENT 4 +/**************************************TPRC INPUT**************************************/ + +/**************************************RTPC INPUT**************************************/ +#define RTPC_MSGREV_FOR_INACCESS_SP 1 +#define RTPC_RSRT_SEND_TFP_MSG 2 +#define RTPC_TSRC_SEND_TFP_MSG 3 +#define RTPC_DEST_INACCESSIBLE 4 +#define RTPC_TFP_MSG 5 +#define RTPC_CTRL_RERT_TERMINATED 6 +#define RTPC_CONTROLLED_RERT 7 +#define RTPC_RESTART_BEGINS 8 +#define RTPC_RESTART_ENDS 9 +/**************************************RTPC INPUT**************************************/ + + +/**************************************RTAC INPUT**************************************/ +#define RTAC_TFA_MSG 1 +#define RTAC_DEST_ACCESSIBLE 2 +#define RTAC_STP_NOLONGER_FOR_DEST 3 +#define RTAC_SEND_TFA_MSG 4 +#define RTAC_FORCED_RERT 5 +#define RTAC_FORCED_RERT_TERMINATED 6 +#define RTAC_FORCED_RERT_NOT_REQ 7 +#define RTAC_RESTART_BEGINS 8 +#define RTAC_RESTART_ENDS 9 +/**************************************RTAC INPUT**************************************/ + +#define RSRT_RTPC_ROUTE_SET_TEST 1 +#define RSRT_TSRC_ROUTE_SET_TEST 2 +#define RSRT_RTAC_ROUTE_AVAILABLE 3 + +#define RSRT_IDLE_STATE 0 +#define RSRT_WAIT_STATE 1 +/**************************************LSAC INPUT**************************************/ +/* LSAC INPUT FROM L2*/ +#define LSAC_L2_IN_SERVICE 1 +#define LSAC_L2_OUT_OF_SERVICE 2 +#define LSAC_L2_REMOTE_PROCESSOR_RECOV 3 +#define LSAC_L2_REMOTE_PROCESSOR_OUTAGE 4 + +/* LSAC INPUT FROM SLTC */ +#define LSAC_SLTC_SLT_SUCCESSFUL 1 +#define LSAC_SLTC_SLT_FAILED 2 + +/* LSAC INPUT FROM TCOC */ +#define LSAC_TCOC_STM_READY 1 +#define LSAC_TCOC_STOP_L2 2 + +/* LSAC INPUT FROM STM */ +#define LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED 1 + +/* LSAC INPUT FROM SLM */ +#define LSAC_ACTIVATE_LINK_FROM_LLSC 1 +#define LSAC_DEACTIVATE_LINK_FROM_LLSC 2 +#define LSAC_EMERGENCY 3 +#define LSAC_EMERGENCY_CEASES 4 + +/* LSAC INPUT FROM MGMT */ +#define LSAC_MGMT_ACTIVATE_LINK 1 +#define LSAC_MGMT_DEACTIVATE_LINK 0 +/**************************************LSAC INPUT**************************************/ +#define LLSC_MGMT_ACTIVATE_LINKSET 1 +#define LLSC_MGMT_DEACTIVATE_LINKSET 2 +#define LLSC_TPRC_RESTART_BEGINS 3 + +/* MGMT INPUT */ +#define MGMT_TLAC_LINK_INHIBITED 1 +#define MGMT_TLAC_LINK_UNINHIBITED 2 +#define MGMT_UNINHIBIT_NOT_POSSIBLE 3 +#define MGMT_INHIBIT_DENIED 4 + +#define TCOC_IDLE_STATE 0 +#define TCOC_WAIT01_STATE 1 +#define TCOC_WAIT02_STATE 2 +#define TCOC_WAIT05_STATE 3 +#define TCOC_WAIT06_STATE 4 +#define TCOC_WAIT07_STATE 5 +#define TCOC_WAITACK_STATE 6 +#define TCOC_RETRIEVING_STATE 7 +#define TCOC_SEND_BUFMSG_STATE 8 + +#define TLAC_UNAVAILABLE_STATE 0 +#define TLAC_AVAILABLE_STATE 1 +#define TLAC_SP_RESTARTING_STATE 2 + +#define LSAC_INACTIVE_STATE 0 +#define LSAC_RESTORING_STATE 1 +#define LSAC_ACTIVE_STATE 2 +#define LSAC_WAIT_STATE 3 +#define LSAC_FAILED_STATE 4 + +#define TSRC_IDLE_STATE 0 +#define TSRC_WAIT01_STATE 1 +#define TSRC_WAIT02_STATE 2 +#define TSRC_WAIT03_STATE 3 +#define TSRC_WAIT04_STATE 4 +#define TSRC_WAIT05_STATE 5 + +#define TCBC_IDLE_STATE 0 +#define TCBC_WAIT_FOR_ROUTING_DATA_STATE 1 +#define TCBC_TCTRL_DIVERSION_STATE 2 +#define TCBC_FIRST_ATTEMPT_STATE 3 +#define TCBC_SECOND_ATTEMPT_STATE 4 + +#define RTPC_IDLE_STATE 0 +#define RTPC_WAIT_STATE 1 + +#define TPRC_IDLE_STATE 0 +#define TPRC_WAIT01_STATE 1 +#define TPRC_WAIT02_STATE 2 +#define TPRC_WAIT03_STATE 3 +#define TPRC_RESTART_ENDS_STATE 4 + +#define SLTC_IDLE_STATE 0 +#define SLTC_FIRST_TRY_STATE 1 +#define SLTC_SECOND_TRY_STATE 2 +#define SLTC_THIRD_TRY_STATE 3 +#define SLTC_RUNNING_STATE 4 + +#define SLTC_START 1 +#define SLTA_MSG 2 +#define SLTC_SECOND_TRY 3 +#define SLTC_STOP 4 + +#ifndef IDLE +#define IDLE 0xee +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#define COMMAND_START 1 +#define COMMAND_STOP 0 +#define TIMER_START 1 +#define TIMER_STOP 2 + +#define SP_ACCESSIBLE 1 +#define SP_INACCESSIBLE 0 +//#define LS_UNAVAILABLE 2 + +#define LOCAL_INHIBIT_REQ 0 +#define REMOTE_INHIBIT_REQ 1 + +#define UNAVAILABLE 0 +#define AVAILABLE 1 +#define INHIBITED 2 + +#define LOCAL_INHIBIT_REQ 0 +#define REMOTE_INHIBIT_REQ 1 + +#define MTP3_DEBUG_ID 1 + +//#define MTP3_OID {1,3,6,1,4,1,1373,1,3,2,2,2} +#define MTP3_OID {1,3,6,1,4,1,1373,2,3,2,2} +#define MTP3_OID_LEN 11 + +//#define MTP3_OMC_OID {1,3,6,1,4,1,1373,1,4} +#define MTP3_OMC_OID {1,3,6,1,4,1,1373,2,4} +#define MTP3_OMC_OID_LEN 9 + +//#define PLATFORM_HB_OID {1,3,6,1,4,1,1373,1,3,2,1} +#define PLATFORM_HB_OID {1,3,6,1,4,1,1373,2,3,2} +#define PLATFORM_HB_LEN 10 +#define MTP2_HB_OID {1,3,6,1,4,1,1373,1,3,1,1,3,4} +#define MTP2_HBOID_LEN 13 + +#define MTP2_ACTIVE_LINK 1 +#define MTP2_DEACTIVE_LINK 2 +#define MTP2_STOP_L2 3 +#define MTP2_EMERGEN_ALIGNMENT 4 +#define MTP2_RETRIEVE 5 +#define MTP3_M2UA_DISABLE 6 +#define MTP3_M2UA_ENABLE 7 +#define MTP3_M3UA_ENABLE 7 +#define MTP3_M3UA_DISABLE 6 + +#define ROUTE_AVAILABLE 0 +#define ROUTE_UNAVAILABLE 1 + +#define MTP_MAX_ASCIIOUT_LEN 2048 + +#define DISPLAY_SNM_MESSAGE 0 +#define DISPLAY_TM_MESSAGE 1 +#define DISPLAY_SCCP_MESSAGE 3 +#define DISPLAY_TUP_MESSAGE 4 +#define DISPLAY_ISUP_MESSAGE 5 +#define DISPLAY_MTP3_ERROR_LOG 6 +#define MTP3_MSGLOG_ON 1 +#define MTP3_MSGLOG_OFF 0 + +#define SNM_SIO 0 +#define TM_SIO 1/* T+M */ +#define SCCP_SIO 3 +#define TUP_SIO 4 +#define ISUP_SIO 5 +#define BICC_SIO 13 + +#define MTP2_STATE_IDLE 0 +#define MTP2_STATE_STOP 1 +#define MTP2_STATE_ASSIGN 2 +#define MTP2_STATE_READY 3 +#define MTP2_STATE_NOT_READY 4 +#define MTP2_STATE_WORKING 5 +#define MTP2_STATE_ERROR 6 +#define MTP2_STATE_WAITING 7 +#define MTP2_STATE_STATE_CONGEST 8 + +#define MTP3_TO_USERPART 0 +#define USERPART_TO_MTP3 1 +#define MTP_MSG_UP 0 +#define MTP_MSG_DOWN 1 +#define MTP_MSG_STP 2 +#define MTP_MSG_OTHER_SERVER 3 +#define MTP_SNM_MSG 4 +#define MTP_TO_LITE 5 +#define MTP_FROM_LITE 6 + +#define SS7_PORT 4950 +#define M2UA_PORT 2904 +#define MTP3_MULTICAST_PORT 4969 + +#define MTP3_IPTX_MSG 0 +#define MTP3_UP_MSG 1 + +#define E1CARD_BASE_IP 0x010012AC +#define E1CARD_BASE_IP_MASK 0xff00ffff + +#define PARA_CONFIGURED 1 +#define PARA_NOT_CONFIGURED 0 + + +#define LS_AVAILABLE 0 +#define LS_UNAVAILABLE 1 +#define NLS_AVAILABLE 0 +#define ALS_AVAILABLE 0 +#define NLS_UNAVAILABLE 2 +#define ALS_UNAVAILABLE 2 + +#define UPDATE_NLS 0 +#define UPDATE_ALS 1 + +#define LINK_TO_IP(link) (link >> 3) << 16 | 0x010012AC + +#define MAX_LS_DPC 128 +#define MAX_LS_DPC_ADD1 129 +#define MAX_LS_NUM 128 + +#define MTP3_14BIT_PC 14 +#define MTP3_24BIT_PC 24 + +#define MSG_FROM_MTP2 0 +#define MSG_FROM_MTP3 1 + +#define MAX_ACN_NUM 36 + +#define MAX_MTP3_NUM 64 + +#define MTP3_LINK_COMPONENT 23 +#define MTP3_LINKSET_COMPONENT 279 +#define MTP3_SG_COMPONENT 264 + +#define MTP3_VERSION {9, 1, 6} +//9,0,2 change ss7 format to "link-0, len -1-2, sio-3 " +//9,0,3 support m3ua msg +//9,1,6 support multiple opc + +#define MTP3_COMPONENT_ID 1 +#define ALARM_LINK_UNAVAILABLE 0 +#define ALARM_LINK_AVAILABLE 1 +#define ALARM_LINK_INHIBIT 2 +#define ALARM_LS_UNAVAILABLE 3 +#define ALARM_LS_AVAILABLE 4 +#define ALARM_LS_INHIBIT 5 +#define NORMAL_HEARTBEAT 6 + +#define M2UAALARM_SCTP_Failure 1 +#define M2UAALARM_SG_Maintenance 2 +#define M2UAALARM_Remote_MTP2_down 3 +#define M2UAALARM_Local_MTP3_Request_Link_Down 4 +#define M2UAALARM_Local_SGLink_Maintenance 5 +#define M2UAALARM_SCCPLite_TCP_Failure 16 +#define M2UAALARM_SCCPLite_Inactivity_Timeout 17 + +#define MTP3ALARM_LINK_TEST_FAILED 1 +#define MTP3ALARM_LINK_COO_RECEIVED 2 +#define MTP3ALARM_LINK_CHANGE_OVER 3 +#define MTP3ALARM_LINK_MGMT_REQUEST 4 +#define MTP3ALARM_LINK_CB_TO_NMTP3 5 +#define MTP3ALARM_LINK_LOCAL_INHIBITED 6 +#define MTP3ALARM_LINK_REMOTE_INHIBITED 7 + +#define MTP3_HB_LEN 134 +#define MTP3_SERNUM_LEN 4//4 bytes + +typedef enum +{ + LKTYPE_NONE_SIGTRAN = 0, + LKTYPE_SIGTRAN = 1, + LKTYPE_MTP3_LITE = 2, + LKTYPE_RESERVED1 = 3, + LKTYPE_M3UA = 4, + LKTYPE_RESERVED3 = 5, + LKTYPE_RESERVED4 = 6, + LKTYPE_RESERVED5 = 7, +}MTP3_LKTYPE_LIST; + +typedef enum +{ + MTP3_SUB_SNM = 0, + MTP3_SUB_STM = 1, + MTP3_SUB_STM2 = 2, + MTP3_SUB_SCCP = 3, + MTP3_SUB_TUP = 4, + MTP3_SUB_ISUP = 5, + MTP3_SUB_DUP1 = 6, + MTP3_SUB_DUP2 = 7, + MTP3_SUB_NONE2 = 8, + MTP3_SUB_BISUP = 9, + MTP3_SUB_SISUP = 10, + MTP3_SUB_NONE3 = 11, + MTP3_SUB_NONE4 = 12, + MTP3_SUB_BICC = 13 +}MTP3_SUB_NAME; + +#define MTP3_MAX_DYNAMIC_OPC_PER_NW 16 diff --git a/omc/plat/mtp3/src/include/mtpdef.h b/omc/plat/mtp3/src/include/mtpdef.h new file mode 100644 index 0000000..76cc148 --- /dev/null +++ b/omc/plat/mtp3/src/include/mtpdef.h @@ -0,0 +1,155 @@ +BYTE ls_slc[2048]; +BYTE ls_sls[2048]; +BYTE sls_to_link[2048]; + +/** link mark **/ +BYTE link_available[256]; +BYTE link_unavailable[256]; +BYTE changeover_possible[256]; +BYTE retrieval_required[256]; +BYTE remote_bsnt_retrieved[256]; +BYTE changeback_in_progress[256]; +BYTE changeover_in_progress[256]; +BYTE changeback_required[256]; +BYTE changeover_required[256]; +BYTE emergency_changeover_order[256]; +BYTE changeover_order[256]; +BYTE changeover_completed[256]; +BYTE failed[256]; +BYTE blocked_by[256]; +BYTE local_blocked[256]; +BYTE remote_blocked[256]; +BYTE first_failure[256]; +BYTE changeover_select[256]; +BYTE changeback_select[256]; +BYTE co_msg_can_exchange[256]; +BYTE cb_msg_can_exchange[256]; +BYTE local_bsnt_retrievable[256]; +BYTE retrieved_bsnt[256]; +BYTE fsnt[256]; +BYTE fsnl[256]; +BYTE fsnc[256]; +BYTE bsnt[256]; +BYTE tcbc_route_change[256]; +BYTE command3[256]; +BYTE cbd_cbc_r[256]; +BYTE cba_cbc_r[256]; +BYTE cbc_s[256]; +BYTE controlled_rerouting_in_progress[256]; +BYTE transfer_prohibited[256]; +BYTE own_sp_restarting; +BYTE link_remotely_inhibited[256]; +BYTE link_locally_inhibited[256]; +BYTE link_inhibited[256]; +BYTE local_inhibit_in_progress[256]; +BYTE uninhibit_in_progress[256]; +BYTE management_req[256]; +BYTE t12_expired_2nd_time[256]; +BYTE t13_expired_2nd_time[256]; +BYTE sending_phase_finished[128]; + +WORD mtp3_timer[24]; + +BYTE sd_buf_h[256]; +BYTE sd_buf_t[256]; + +MTP3Parameter *mtp3_para; +MTP3Parameter mtp3_para_init; +mtp mtp3; +mtp3_csta mtp3_measure; +measure_of_mtp3 *current_measure; +BYTE current_mtime;/* current measure time */ +heartbeat_compoent_of_mtp3 mtp3_heartbeat; + +/** debug **/ + +BYTE mtp_asciout_buf[2048]; +BYTE mtp_asciin_buf[80]; + +BYTE t1_delay_mtp3[256]; +BYTE t2_delay_mtp3[256]; +BYTE t3_delay_mtp3[256]; +BYTE t4_delay_mtp3[256]; +BYTE t5_delay_mtp3[256]; +BYTE t6_delay_mtp3[256]; +BYTE t7_delay_mtp3[256]; +BYTE t8_delay_mtp3[256]; +BYTE t9_delay_mtp3[256]; +BYTE t10_delay_mtp3[256]; +BYTE t11_delay_mtp3[256]; +BYTE t12_delay_mtp3[256]; +BYTE t13_delay_mtp3[256]; +BYTE t14_delay_mtp3[256]; +BYTE t15_delay_mtp3[256]; +BYTE t16_delay_mtp3[256]; +BYTE t17_delay_mtp3[256]; +BYTE t18_delay_mtp3; +BYTE t19_delay_mtp3; +BYTE t20_delay_mtp3; +BYTE t21_delay_mtp3[128]; +BYTE t22_delay_mtp3[256]; +BYTE t23_delay_mtp3[256]; +BYTE t24_delay_mtp3[256]; +BYTE sltc_t1_delay[256]; +BYTE sltc_t2_delay[256]; + +BYTE mtp3_t21_flag[128]; +BYTE mtp3_t22_flag[256]; +BYTE mtp3_t23_flag[256]; +BYTE mtp3_t12_flag[256]; +BYTE mtp3_t13_flag[256]; +BYTE mtp3_t14_flag[256]; + +BYTE srm_nw; +BYTE active_ls_num; +BYTE current_active_ls_num; +BYTE rv_TRA_num; +BYTE tprc_nw; +BYTE taprc_loop[128]; + +BYTE mtp_t1[256]; +BYTE mtp_t2[256]; +BYTE mtp_t3[256]; +BYTE mtp_t4[256]; +BYTE mtp_t5[256]; +BYTE mtp_t7[256]; +BYTE mtp_t12[256]; +BYTE mtp_t13[256]; +BYTE mtp_t14[256]; +BYTE mtp_t17[256]; +BYTE mtp_t22[256]; +BYTE mtp_t23[256]; +BYTE mtp_t24[256]; + +BYTE mtp2_flag_new[32]; +BYTE mtp2_flag_old[32]; + +DWORD mtp3_localip; +DWORD mtp3_alterip; + +WORD wx5[256]; +BYTE debug_link[256]; + +long mtp3_timestamp; +long mtp3_csta_p; + +DWORD mtp3_get_msg; + +BYTE local_change_over[256]; + +BYTE mtp2_buf_full[256]; +BYTE nld_cause_lkd[256]; + +BYTE init_lsac_state[256]; +BYTE init_tlac_state[256]; + +DWORD TFAmsg_OPC; +BYTE TFAmsg_SrcLk; +DWORD TFPmsg_OPC; +BYTE TFPmsg_SrcLk; +BYTE sdTFP_Ls; +BYTE sdTFA_Ls; +BYTE mtp2_module; +BYTE mtp2_systemid; +// mtp3 dynamic opc +mtp3_dynamic_opc mtp3_opc; diff --git a/omc/plat/mtp3/src/include/mtpext.h b/omc/plat/mtp3/src/include/mtpext.h new file mode 100644 index 0000000..a454282 --- /dev/null +++ b/omc/plat/mtp3/src/include/mtpext.h @@ -0,0 +1,140 @@ +extern BYTE ls_slc[2048]; +extern BYTE ls_sls[2048]; +extern BYTE sls_to_link[2048]; + +/** link mark **/ +extern BYTE link_available[256]; +extern BYTE changeover_possible[256]; +extern BYTE retrieval_required[256]; +extern BYTE remote_bsnt_retrieved[256]; +extern BYTE changeback_in_progress[256]; +extern BYTE changeover_in_progress[256]; +extern BYTE changeback_required[256]; +extern BYTE changeover_required[256]; +extern BYTE emergency_changeover_order[256]; +extern BYTE changeover_order[256]; +extern BYTE changeover_completed[256]; +extern BYTE failed[256]; +extern BYTE blocked_by[256]; +extern BYTE local_blocked[256]; +extern BYTE remote_blocked[256]; +extern BYTE first_failure[256]; +extern BYTE changeback_select[256]; +extern BYTE changeover_select[256]; +extern BYTE co_msg_can_exchange[256]; +extern BYTE cb_msg_can_exchange[256]; +extern BYTE local_bsnt_retrievable[256]; +extern BYTE retrieved_bsnt[256]; +extern BYTE fsnt[256]; +extern BYTE fsnl[256]; +extern BYTE fsnc[256]; +extern BYTE bsnt[256]; +extern BYTE tcbc_route_change[256]; +extern BYTE command3[256]; +extern BYTE cbd_cbc_r[256]; +extern BYTE cba_cbc_r[256]; +extern BYTE cbc_s[256]; +extern BYTE controlled_rerouting_in_progress[256]; +extern BYTE transfer_prohibited[256]; +extern BYTE own_sp_restarting; +extern BYTE link_remotely_inhibited[256]; +extern BYTE link_locally_inhibited[256]; +extern BYTE link_inhibited[256]; +extern BYTE local_inhibit_in_progress[256]; +extern BYTE uninhibit_in_progress[256]; +extern BYTE management_req[256]; +extern BYTE t12_expired_2nd_time[256]; +extern BYTE t13_expired_2nd_time[256]; +extern BYTE sending_phase_finished[128]; + +extern WORD mtp3_timer[24]; + +extern BYTE sd_buf_h[256]; +extern BYTE sd_buf_t[256]; + +extern MTP3Parameter *mtp3_para; +extern mtp mtp3; +extern mtp3_csta mtp3_measure; +extern measure_of_mtp3 *current_measure; +extern BYTE current_mtime;/* current measure time */ + +/** debug **/ + +extern BYTE mtp_asciout_buf[2048]; +extern BYTE mtp_asciin_buf[80]; + +extern BYTE t1_delay_mtp3[256]; +extern BYTE t2_delay_mtp3[256]; +extern BYTE t3_delay_mtp3[256]; +extern BYTE t4_delay_mtp3[256]; +extern BYTE t5_delay_mtp3[256]; +extern BYTE t6_delay_mtp3[256]; +extern BYTE t7_delay_mtp3[256]; +extern BYTE t8_delay_mtp3[256]; +extern BYTE t9_delay_mtp3[256]; +extern BYTE t10_delay_mtp3[256]; +extern BYTE t11_delay_mtp3[256]; +extern BYTE t12_delay_mtp3[256]; +extern BYTE t13_delay_mtp3[256]; +extern BYTE t14_delay_mtp3[256]; +extern BYTE t15_delay_mtp3[256]; +extern BYTE t16_delay_mtp3[256]; +extern BYTE t17_delay_mtp3[256]; +extern BYTE t18_delay_mtp3; +extern BYTE t19_delay_mtp3; +extern BYTE t20_delay_mtp3; +extern BYTE t21_delay_mtp3[128]; +extern BYTE t22_delay_mtp3[256]; +extern BYTE t23_delay_mtp3[256]; +extern BYTE t24_delay_mtp3[256]; +extern BYTE sltc_t1_delay[256]; +extern BYTE sltc_t2_delay[256]; + +extern BYTE mtp3_t21_flag[128]; +extern BYTE mtp3_t22_flag[256]; +extern BYTE mtp3_t23_flag[256]; +extern BYTE mtp3_t12_flag[256]; +extern BYTE mtp3_t13_flag[256]; +extern BYTE mtp3_t14_flag[256]; + +extern BYTE srm_nw; +extern BYTE active_ls_num; +extern BYTE current_active_ls_num; +extern BYTE rv_TRA_num; +extern BYTE tprc_nw; +extern BYTE taprc_loop[128]; + +extern BYTE mtp2_flag_new[32]; +extern BYTE mtp2_flag_old[32]; + +extern heartbeat_compoent_of_mtp3 mtp3_heartbeat; + +extern DWORD mtp3_localip; +extern DWORD mtp3_alterip; +extern WORD wx5[256]; +extern BYTE debug_link[256]; + +extern long mtp3_timestamp; +extern long mtp3_csta_p; + +extern DWORD mtp3_get_msg; + +extern BYTE local_change_over[256]; + +extern BYTE mtp2_buf_full[256]; +extern BYTE nld_cause_lkd[256]; + +extern BYTE init_lsac_state[256]; +extern BYTE init_tlac_state[256]; + +extern DWORD TFAmsg_OPC; +extern BYTE TFAmsg_SrcLk; +extern DWORD TFPmsg_OPC; +extern BYTE TFPmsg_SrcLk; +extern BYTE sdTFP_Ls; +extern BYTE sdTFA_Ls; +extern BYTE mtp2_module; +extern BYTE mtp2_systemid; + +// mtp3 opc +extern mtp3_dynamic_opc mtp3_opc; diff --git a/omc/plat/mtp3/src/include/mtpfunc.h b/omc/plat/mtp3/src/include/mtpfunc.h new file mode 100644 index 0000000..f544e41 --- /dev/null +++ b/omc/plat/mtp3/src/include/mtpfunc.h @@ -0,0 +1,102 @@ +int find_outbound_cclink(BYTE chl);/* find outbound changeover link */ +int search_outbound_link(BYTE ls); +int pc_length(BYTE nw); +void send_mtp_msg(int outlink, BYTE *msgptr); +void send_snm_msg(BYTE ls,BYTE *msgptr); +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst); +int check_outbound_route(BYTE sio, long dpc, BYTE sls, long opc); +int send_to_tup(BYTE *msgptr);/* send tup msg to tele user part */ +int send_to_isup(BYTE *msgptr);/* send isup msg to tele user part */ +int send_to_bicc(BYTE *msgptr);/* send bicc msg to tele user part */ +int send_to_sccp(BYTE *msgptr);/* send sccp msg to tele user part */ +int send_to_sccp_lite(up_message *msgptr);/* send sccp-lite msg to sccp */ +int get_tup(up_message *GetTup); +int get_isup(up_message *GetIsup); +int get_bicc(up_message_2 *GetBicc); +int get_sccp(up_message *GetSccp); +int find_dst_place(long dst,BYTE ls); +int find_direct_ls_to_dst(long dst, BYTE nw, long opc); +void mtp2_mtp3_internal_msg(BYTE *msgptr); +void hmdt_test_msg(BYTE *msgptr); +void hmrt_tra_msg(BYTE linkset); +void sd_STM_msg(BYTE chl, BYTE MsgType); +void hmrt_xxxx_adjacent_sp_restart(ls_info *ls); +void hmrt_hmdc_message_for_routing(ls_info *ls); +void hmrt_xxxx_signalling_link_management_message(ls_info *ls); +void hmrt_xxxx_signalling_route_management_message(ls_info *ls); +void hmrt_xxxx_mtp_testing_user_part_message(ls_info *ls); +void hmrt_tprc_restart_begins(ls_info *ls); +void hmrt_tprc_restart_ends(ls_info *ls); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void hmrt_sltc_signalling_link_test_ack(BYTE chl); +void hmrt_sltc_signalling_link_test_msg(BYTE chl); +void hmrt_tcbc_changeback_ack(BYTE chl); +void hmrt_tcbc_changeback_declaration(BYTE chl); +void hmrt_tcoc_changeover_ack(BYTE chl); +void hmrt_tcoc_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_ack(BYTE chl); +void hmrt_tcoc_emergency_changeover_order(BYTE chl); +void hmrt_tcbc_update_routing_tables(BYTE chl); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void hmrt_tlac_emergency_changeover_ack(BYTE chl); +void hmrt_tlac_force_uninhibit_signalling_link(BYTE chl); +void hmrt_tlac_inhibit_ack(BYTE chl); +void hmrt_tlac_inhibit_denied(BYTE chl); +void hmrt_tlac_local_inhibit_test(BYTE chl); +void hmrt_tlac_remote_inhibit_test(BYTE chl); +void hmrt_tlac_uninhibit_ack(BYTE chl); +void send_command_to_mtp2(BYTE chl, BYTE command); +void update_nid_table(BYTE ls, long dst, BYTE place); +void update_aid_table(BYTE ls, long dst, BYTE place); +void get_para_from_disk(); +int mtp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen); +int mtp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +void mtp_snmp_init(); +void tup_shm_init(); +void isup_shm_init(); +void sccp_shm_init(); +int GetMtp2Msg(DWORD ip_port); +void m3ua_timer(); +int GetM3uaMsg(DWORD port); +int tup_GetMsg(up_message *msgptr); +int isup_GetMsg(up_message *msgptr); +int sccp_GetMsg(up_message *msgptr); +int tup_to_mtp3(up_message *msgptr); +int isup_to_mtp3(up_message *msgptr); +int sccp_to_mtp3(up_message *msgptr); +void sltc_proc(BYTE chl); +void lsac_proc(BYTE chl); +void rtpc_proc(BYTE nw,BYTE dst); +void rtac_proc(BYTE nw,BYTE dst); +void tsrc_proc(BYTE chl); +void tlac_proc(BYTE chl); +void tcoc_proc(BYTE chl); +void tcbc_proc(BYTE chl); +void tprc_mgmt_signalling_point_restart_indication(); +void tprc_proc(); +void taprc_proc(BYTE linkset);/* adjacent sp restart control */ +void mtp_send_error(char *object,int chl, char *err_str); +void mtp_send_error2(BYTE *msg,BYTE sio,DWORD dpc,char *err_str,BYTE from); +int mtp_debug_set(); +void mtp_m_rt(); +void mtp_put_error(BYTE type,BYTE chl); +void mtp3_readpara_from_disk(); +BOOL iptrans_msg_flow(BYTE *msg,BYTE pclen,int direction,DWORD dest_ip); +BOOL iptrans_msg_flow_2(up_message *up_msg_ptr); +void mtp_prompt(char *object, BYTE value); +void set_heartbeat(BYTE reason,BYTE object); +void mtp3_send_alarm(WORD component_id,BYTE alarm_code); +void update_sls_to_link_table(int ls); +int update_ls_slc_table(int link); +void mtp3_debug(int n,const char *fmt,...); +void reset_mtp3(); +void mtp3Timer_proc(BYTE i); +int pc_length(BYTE nw); +void mtp3_showbuf(int n,BYTE *msg,int len); +int mtp3lite_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode); +void mtp3lite_upd_route_status(BYTE chl, BYTE flag); +int Mtp3BinSearchValue(BYTE low, BYTE high,BYTE nw,ull key); +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm); +BYTE MTP3_LINK_TYPE(BYTE Link); +int Mtp3AddSortRec(BYTE nw,DWORD dpc, DWORD real_index, DWORD opc); +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm); diff --git a/omc/plat/mtp3/src/include/mtpstm.h b/omc/plat/mtp3/src/include/mtpstm.h new file mode 100644 index 0000000..e198d9e --- /dev/null +++ b/omc/plat/mtp3/src/include/mtpstm.h @@ -0,0 +1,261 @@ +#include "mtpconst.h" + +typedef struct ls_info{ + BYTE links_available; + BYTE links_available_t; + BYTE adjacentsp_acessible; + BYTE adjacentsp_restarting; + WORD adjacent_sp_place; + BYTE linksNum_configured; + + + BYTE influ_dstnum_asNLS; + BYTE influ_dstnum_asALS; + + BYTE influ_dstplace_intable_asNLS[MAX_LS_DPC]; + BYTE influ_dstplace_intable_asALS[MAX_LS_DPC]; +}ls_info; + +typedef struct mtp3_flow{ + DWORD UtoM[5]; + DWORD MtoI[5]; + DWORD ItoM[5]; + DWORD MtoU[5]; + DWORD stp[5]; + DWORD UtoM_throwed[5]; + DWORD MtoI_throwed[5]; + DWORD ItoM_throwed[5]; + DWORD MtoU_throwed[5]; + DWORD stp_throwed[5]; + DWORD stp_loop[5]; + DWORD isup_detail[32]; +}mtp3_flow; + +typedef struct network{ + BYTE routine[256]; /* bit0-1: normal route available + bit2-3: alternative route available + bit4-5: acessible + bit6-7: current route */ + BYTE rtpc_state[256]; + BYTE rtpc_input[256]; + BYTE rtac_state[256]; + BYTE rtac_input[256]; + BYTE rsrt_state[256]; + BYTE rsrt_input[256]; + BYTE rsrt_t10[256]; + BYTE m3ua_rc_status[256]; + mtp3_flow flow; +}network; + +typedef struct nw_para{ + DWORD dpc[256]; + BYTE normal_ls[256]; + BYTE alternative_ls[256]; + DWORD opc24; + DWORD opc14; + BYTE mtp3_t8[256]; + BYTE mtp3_t15[256]; + BYTE mtp3_t16[256]; + BYTE acn[256][MAX_ACN_NUM]; + BYTE ansi_local14b; + BYTE ansi_local24b; + BYTE ansi_remote[256]; + DWORD rc[256]; + DWORD opc[256]; +}nw_para; + +typedef struct 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));//Bit0:0=ss7,1=m2ua + //Bit1:1=enable,0=disable + //Bit2:0=MTP3,1=MTP3LITE + //BIT3:0=server,1=client + BYTE e1_to_sg __attribute__((packed)); + BYTE e1_to_iid __attribute__((packed)); + DWORD remote_ip __attribute__((packed)); + BYTE inactive __attribute__((packed));// Inactivity timer + BYTE inactive_tm __attribute__((packed));// Allowed inactivity timeouts + DWORD e1_to_alterMTP3 __attribute__((packed));//alternative MTP3 +}lk_pro; + +typedef struct lk_timer +{ + BYTE t1;/* 500ms-1200ms */ + BYTE t2;/* 700ms-2000ms */ + BYTE t3;/* 500ms-1200ms */ + BYTE t4;/* 500ms-1200ms */ + BYTE t5;/* 500ms-1200ms */ + BYTE t7;/* 1s-2s */ + BYTE t8;/* 800ms-1200ms */ + BYTE t12;/* 800ms-1500ms */ + BYTE t13;/* 800ms-1500ms */ + BYTE t14;/* 2s-3s */ + BYTE t22; + BYTE t23; +}lk_timer; + +typedef struct sg_para +{ + BYTE enable __attribute__((packed)); + BYTE server __attribute__((packed)); + BYTE data_ack __attribute__((packed)); + DWORD ip __attribute__((packed)); +}sg_para; + +typedef struct MTP3Parameter +{ + lk_pro lk[256]; + lk_timer lt[256]; + sg_para sg[256]; + BYTE nw_pro; + DWORD ls_op_pc[128];/* for 128 linkset */ + BYTE ls_pro[128]; + char ls_reserved[128][16];//each linkset reserved 16 bytes for omc + BYTE mtp3_t10; + BYTE mtp3_t18; + BYTE mtp3_t19; + BYTE mtp3_t20; + WORD mtp3_t21; + WORD mtp3lite_port; + nw_para nw[4]; + BYTE localAcn[MAX_ACN_NUM]; + ull MTP3SerialNum; + DWORD ls_opc[128];/*for 128 linkset opc*/ +}MTP3Parameter; + +typedef struct mtp{ + ls_info ls[128]; + network nw[4]; +}mtp; + +typedef struct measure_of_mtp3{ + long time_stamp; + DWORD lk_measure1[256][9];/* link measure oid=*.1 */ + DWORD ls_measure[128][8];/* linkset measure oid=*.3 */ +/*** traffic */ +// DWORD tf_measure1[6][20];/* traffic octets */ + DWORD tf_measure2[6][20];/* traffic MSUs */ + DWORD tf_measure5[3]; +}measure_of_mtp3; + +typedef struct mtp3_csta{ + measure_of_mtp3 measure[96]; +}mtp3_csta; + +typedef struct heartbeat_compoent_of_mtp3 +{ + BYTE version[3]; + BYTE state; + BYTE link_state[64]; + BYTE linkset_state[32]; + BYTE masterMTP3[32]; + BYTE SubState[2]; +}heartbeat_compoent_of_mtp3; + +typedef struct mtp2_heartbeat +{ + BYTE systemid; + BYTE moduleid; + BYTE timestamp[4]; + BYTE led_ctl_code[8]; + BYTE alarm_component; + BYTE alarm_code; + BYTE reserved; + BYTE l1_state; + BYTE l2_state[8]; + BYTE e1_dstip[8]; + BYTE retrieved_bsnt[8]; +}mtp2_heartbeat; + +typedef struct mtp3DPCIndex +{ + DWORD sortedNum; +// DWORD dpc[256]; + ull dpc[256];//dpc = (opc<<32) | dpc + DWORD index[256]; +}mtp3DPCIndex; + +typedef struct mtp3_dpc_index +{ + mtp3DPCIndex nw[4]; +}mtp3_dpc_index; +/* by simon at 23/9/26 */ +extern mtp3_dpc_index mtp3SortRoutine; + +typedef struct _mtp3_state +{ + BYTE link_l1_state[256]; + BYTE link_l2_state[256]; + BYTE link_l3_state[256]; + BYTE lk_configured[256]; + BYTE lk_command[256]; + BYTE link_type[256]; + DWORD lk_mtp3[256]; + BYTE lk_NMTP3_ok[256];//normal mtp3 ok + BYTE lk_AMTP3_ok[256];//alternative mtp3 ok + + BYTE lk_SpecANSI_flag[256]; + //special ANSI, use the Signalling network testing and maintenance special message + + BYTE lsac_state[256]; + BYTE tlac_state[256]; + BYTE tcoc_state[256]; + BYTE tcbc_state[256]; + BYTE tsrc_state[256]; + BYTE sltc_state[256]; + BYTE tprc_state; + + BYTE MTP3WatchDog[256]; +}_mtp3_state; +/* by simon at 23/9/26 */ +extern _mtp3_state mtp3ObjState; + +typedef struct _mtp3_input +{ + BYTE lsac_input_from_l2[256]; + BYTE lsac_input_from_sltc[256]; + BYTE lsac_input_from_stm[256]; + BYTE lsac_input_from_tcoc[256]; + BYTE lsac_input_from_mgmt[256]; + BYTE tlac_input_from_slm[256]; + BYTE tlac_input_from_mgmt[256]; + BYTE tlac_input_from_stm[256]; + BYTE tlac_input_from_hmdt[256]; + BYTE tlac_input_from_Tctl[256];/* input from timer control center*/ + BYTE tsrc_input_from_tcoc[256]; + BYTE tsrc_input_from_tcbc[256]; + BYTE tsrc_input_from_stm[256]; + BYTE tsrc_input_from_tlac[256]; + BYTE tcoc_input_from_tsrc[256]; + BYTE tcoc_input_from_stm[256]; + BYTE tcoc_input_from_hmdt[256]; + BYTE tcbc_input[256]; + BYTE tcbc_input_from_tsrc[256]; + BYTE sltc_input[256]; + BYTE tprc_input; + BYTE taprc_input[128]; +}_mtp3_input; +/* by simon at 23/9/26 */ +extern _mtp3_input mtp3ObjInput; + +typedef struct _mtp3_IPMng +{ + BYTE mtp3_flag_new[MAX_MTP3_NUM]; + BYTE mtp3_flag_old[MAX_MTP3_NUM]; + DWORD mtp3_flag_ip[MAX_MTP3_NUM]; + + BYTE LinkIPNum; + DWORD LinkIP[MAX_MTP3_NUM]; + BYTE LinkIPSubSta[MAX_MTP3_NUM][2]; +}_mtp3_IPMng; + +typedef struct _mtp3_dynamic_opc +{ + BYTE opc_num[4]; + DWORD opc[4][MTP3_MAX_DYNAMIC_OPC_PER_NW]; +}mtp3_dynamic_opc; +/* by simon at 23/9/26 */ +extern _mtp3_IPMng MTP3IPMng; diff --git a/omc/plat/mtp3/src/mtp3lite.c b/omc/plat/mtp3/src/mtp3lite.c new file mode 100644 index 0000000..8533e4b --- /dev/null +++ b/omc/plat/mtp3/src/mtp3lite.c @@ -0,0 +1,742 @@ +/****************************************************/ +/* MTP3LITE Implementation Program */ +/* Version 10.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2005-04-7 */ +/* Modify : Victor Luo, 2005-07-14 add TCP client for mtp3lite*/ +/****************************************************/ + +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtp3lite.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +BYTE mtp3lite_ka_msg[3]; +mtp3lite_lk mtp3lite_link[256]; +int mtp3lite_listen_fd; +BYTE mtp3lite_msg_buf[256][MTP3LITE_MSG_BUF_SIZE_PER_LINK]; +BYTE mtp3lite_rem_len[256]; +BYTE mtp3lite_id_fg[256]; + +/*@ignore@*/ +void mtp3lite_print_msg(BYTE *ptr, WORD len) +{ + int i; + + for (i = 0; i < len; i++) + { + printf("%X ", ptr[i]); + } + printf("\n"); +} + +void mtp3lite_init_lk(BYTE lk) +{ + mtp3lite_link[lk].connfd = -1; + mtp3lite_link[lk].cliSockfd = -1; + mtp3lite_link[lk].remote_port = 0; + mtp3lite_link[lk].local_inactive = 2000; // 20 seconds + mtp3lite_link[lk].local_reconnect = 10; // 10 * 2.56 seconds + mtp3lite_link[lk].remote_inactive = mtp3_para->lk[lk].inactive * 100; + mtp3lite_link[lk].remote_inactive_timeouts = mtp3_para->lk[lk].inactive_tm; + mtp3lite_link[lk].init_guard_timer = 2000; // 20 seconds + mtp3lite_msg_buf[lk][0] = 0; + mtp3lite_rem_len[lk] = 0; + mtp3lite_id_fg[lk] = 0; +} + +void mtp3lite_init_ka_msg(void) +{ + mtp3lite_ka_msg[0] = 2; + mtp3lite_ka_msg[1] = 0x4B; + mtp3lite_ka_msg[2] = 0x41; +} + +int mtp3lite_Init_TCPSocket(struct sockaddr_in saddr,int needBind) +{ //flag,0=client, 1=server + int sock; + long sockbuf = 40*1024; + int on = 1, timeout = 20; + + sock = socket(AF_INET, SOCK_STREAM, 0); + + if (sock < 0) + { + fprintf(stderr,"Socket() failed\n"); + return -3; + } + + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &sockbuf, sizeof(sockbuf)) != 0) + { + fprintf(stderr,"set socket buffer failed\n"); + return -4; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + &on,sizeof(on)) != 0) + { + fprintf(stderr,"set addr reusable failed\n"); + return -5; + } + + if (setsockopt(sock,SOL_SOCKET, SO_KEEPALIVE, + &timeout, sizeof(timeout)) != 0) + { + fprintf(stderr,"set keepalive failed\n"); + return -6; + } + + if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr,"set nonblock failed\n"); + return -7; + } + + if(needBind) + { + if (bind(sock, (struct sockaddr*)&saddr, sizeof(struct sockaddr)) < 0) + { + fprintf(stderr,"MTP3LITE bind failed,port:%d\n",htons(saddr.sin_port)); + close(sock); + return -2; + } + } + return sock; +} + +int mtp3lite_InitServerSocket() +{ + struct sockaddr_in sin_addr; + + memset(&sin_addr, 0, sizeof(struct sockaddr)); + sin_addr.sin_family = AF_INET; + //sin_addr.sin_port = htons(mtp3lite_port); + sin_addr.sin_port = mtp3_para->mtp3lite_port; + sin_addr.sin_addr.s_addr = INADDR_ANY; + bzero(&(sin_addr.sin_zero),8); + + if ((mtp3lite_listen_fd = mtp3lite_Init_TCPSocket(sin_addr,1)) < 0) + { + printf("MTP3LITE TCP Socket(%X) Init Failed!\n", mtp3_para->mtp3lite_port); + exit(1); + } + else + listen(mtp3lite_listen_fd, 1); + + printf("mtp3lite_listen_fd: %d\n", mtp3lite_listen_fd); + + return 1; +} + +int isMtp3LiteClientLink(BYTE lk) +{ + //4bits:none sigtran, link enable, mtp3lite enable,client + if ((mtp3_para->lk[lk].e1_lk_type & 0x1f)==0x15 && mtp3_para->lk[lk].remote_ip>0) + { + return 1; + } + return 0; +} + +int checkIfOveridesocket(BYTE lk) +{ + int i; + for(i=0;ilk[lk].remote_ip==mtp3_para->lk[i].remote_ip) + { + printf("mtp3lite client, lk %d is overide with %d \n",lk,i); + return 1; + } + } + return 0; +} + + +int mtp3lite_InitClientSocket(BYTE lk) +{ + struct sockaddr_in sin_addr; + int socketfd; + + bzero(&sin_addr,sizeof(struct sockaddr)); + sin_addr.sin_family = AF_INET; + //sin_addr.sin_port = htons(mtp3lite_port); + + mtp3lite_link[lk].cliSockfd = -1; + if (isMtp3LiteClientLink(lk) && !checkIfOveridesocket(lk)) + { + //sin_addr.sin_port = mtp3_para->mtp3lite_port; //server port,tmp + //sin_addr.sin_addr.s_addr = mtp3_para->lk[lk].remote_ip; + //bzero(&(sin_addr.sin_zero),8); + if ((socketfd = mtp3lite_Init_TCPSocket(sin_addr,0)) < 0) + { + printf("MTP3LITE TCP Client Socket(%d) Init Failed!\n",mtp3_para->mtp3lite_port); + //exit(1); + return 0; + } + mtp3lite_link[lk].cliSockfd = socketfd; + printf("mtp3lite: init client socket link=%d\n",lk); + } + + return 1; +} + +int mtp3lite_CloseTcpConn(BYTE link) +{ + if(mtp3lite_link[link].connfd>=0) + close(mtp3lite_link[link].connfd); + if(mtp3lite_link[link].cliSockfd>=0) + close(mtp3lite_link[link].cliSockfd); + mtp3lite_init_lk(link); + + return 1; +} + +int mtp3lite_get_lk_by_ip(struct sockaddr_in *client_addr) +{ + int lk; + + for (lk = 0; lk < 256; lk++) + { + if ((mtp3_para->lk[lk].remote_ip == client_addr->sin_addr.s_addr) && + (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) && + ((mtp3_para->lk[lk].e1_lk_type & 0x1f) == 0x05) && // Server & MTP3LITE & Enabled + (mtp3ObjState.lk_command[lk]!=0)) //Command enabled + { + if (mtp3lite_link[lk].connfd > 0) + { + mtp3lite_CloseTcpConn(lk); + mtp3lite_updateStatus(lk, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } + else if (mtp3lite_link[lk].init_guard_timer == 0) + return lk; + return -1; + } + } + + return -1; +} + +int mtp3lite_DirectSendMsg(BYTE link, int len, BYTE *msg_ptr) +{ + struct sockaddr_in sin; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link] == 0) || // Command Disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + bzero(&sin.sin_zero, sizeof(sin.sin_zero)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = mtp3_para->lk[link].remote_ip; + sin.sin_port = mtp3lite_link[link].remote_port; + + return send(mtp3lite_link[link].connfd, msg_ptr, len, MSG_NOSIGNAL); +} + +int mtp3liteTcpConnect(int sock,struct sockaddr_in *sin_addr) +{ + if (connect(sock, (struct sockaddr *)sin_addr, sizeof(struct sockaddr)) < 0) + { + return 0; + } + else + { + printf("tcpConnect success, ip=%s\n",inet_ntoa(sin_addr->sin_addr)); + return 1; + } +} + +int mtp3lite_TcpConnectCheck() +{ + int timeout = 20; + int connfdtmp = 0; + socklen_t clilen; + struct sockaddr_in cliaddr; + int link; + static BYTE cliLk=0; + + bzero(&cliaddr,(clilen = sizeof(struct sockaddr))); + + connfdtmp = accept(mtp3lite_listen_fd,(struct sockaddr *)&cliaddr,&clilen); + if (connfdtmp <= 0)//no connect request , check client socke + { + link = cliLk++; + if (!isMtp3LiteClientLink(link)) + return 0; + if (mtp3lite_link[link].connfd > 0) + return 0; + else if (mtp3lite_link[link].local_reconnect > 0) + { + mtp3lite_link[link].local_reconnect--; + return 0; + } + + if (mtp3lite_link[link].cliSockfd <= 0) + { + if (!mtp3lite_InitClientSocket(link)) + mtp3lite_init_lk(link); + } + cliaddr.sin_family = AF_INET; + cliaddr.sin_port = mtp3_para->mtp3lite_port; + cliaddr.sin_addr.s_addr = mtp3_para->lk[link].remote_ip; + bzero(&(cliaddr.sin_zero),8); + connfdtmp = mtp3lite_link[link].cliSockfd; + if (!mtp3liteTcpConnect(connfdtmp, &cliaddr)) + { + if ((errno != EINPROGRESS) && (errno != EALREADY)) + mtp3lite_CloseTcpConn(link); + return 0; + } + } + else if ((link = mtp3lite_get_lk_by_ip(&cliaddr)) < 0) + { + close(connfdtmp); + return 0; + } + + mtp3lite_init_lk(link); + mtp3lite_link[link].init_guard_timer = 0; + mtp3lite_link[link].connfd = connfdtmp; + mtp3lite_link[link].cliSockfd = connfdtmp; + mtp3lite_link[link].remote_port = cliaddr.sin_port; + printf("link[%d] connfd: %d, rem_port: %d\n", link, connfdtmp, ntohs(mtp3lite_link[link].remote_port)); + + fcntl(mtp3lite_link[link].connfd,F_SETFL,O_NONBLOCK); + if (setsockopt(mtp3lite_link[link].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) != 0) + fprintf(stderr,"set keepalive failed\n"); + if (setsockopt(mtp3lite_link[link].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) !=0) + fprintf(stderr,"set keepalive failed\n"); + + mtp3lite_updateStatus(link, MTP2_STATE_WORKING, 0); +// mtp3lite_DirectSendMsg(link, 3, mtp3lite_ka_msg); + + return 1; +} + +int mtp3lite_DirectRecvMsg(BYTE link) +{ + struct sockaddr_in sin; + int len, nbytes; + BYTE len1; + + len = sizeof(struct sockaddr); + if ((len1 = mtp3lite_rem_len[link])>0) + printf("len1: %d\n", len1); + nbytes = recvfrom(mtp3lite_link[link].connfd, mtp3lite_msg_buf[link] + len1, + MTP3LITE_MSG_BUF_SIZE_PER_LINK - len1, 0, (struct sockaddr *) &sin, &len); + + if (nbytes == 0) + { + printf("tcp link[%d] error : %d\n", link, errno); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_TCP_FAILURE); + mtp3lite_rem_len[link] = 0; + } + + if ((len1 > 0) && (nbytes > 0)) + nbytes += len1; + + return nbytes; +} +/* +int mtp3lite_decode_tcp_msg(WORD total_len, BYTE link) +{ + BYTE lk_set, *buf_ptr; + WORD sub_len, rem_len, total_hdl_len = 0; + up_message up_msg; + up_message *up_msg_ptr = &up_msg; + BYTE nw; + + if (total_len > MTP3LITE_MSG_BUF_SIZE_PER_LINK) + return -1; + + while (total_hdl_len < total_len) + { + buf_ptr = mtp3lite_msg_buf[link] + total_hdl_len; + rem_len = total_len - total_hdl_len; + sub_len = buf_ptr[0]; + + if (rem_len < (sub_len + 1)) + { + if (total_hdl_len > 0) + memcpy(mtp3lite_msg_buf[link], mtp3lite_msg_buf[link] + total_hdl_len, rem_len); + mtp3lite_rem_len[link] = rem_len; + //printf("Remain: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + return 1; + } + + if (sub_len < 2) + return -1; + else if (sub_len == 2) + { + if ((buf_ptr[1] == 0x4B) && (buf_ptr[2] == 0x41)) + { // Receive Keep Alive Message + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + //mtp3lite_print_msg(buf_ptr, 3); + total_hdl_len += (sub_len + 1); + //printf("KeepAlive: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + continue; + } + else + return -1; + } + + if ((buf_ptr[1] > 9) || (buf_ptr[1] == 0)) + return -1; + + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + + //mtp3lite_print_msg(buf_ptr, sub_len + 1); + + up_msg_ptr->len = sub_len; + up_msg_ptr->link = link; + lk_set = mtp3_para->lk[link].e1_to_linkset; + if (lk_set >= 128) + return -1; + nw = mtp3_para->ls_pro[lk_set] & 3; + up_msg_ptr->sio = 0x03 | (nw << 6) | 0x10;//sccp lite always ansi message + up_msg_ptr->opc = mtp3_para->ls_op_pc[lk_set]; + if (pc_length(up_msg_ptr->sio >> 6) == MTP3_24BIT_PC) + up_msg_ptr->dpc = mtp3_para->nw[nw].opc24; + else + up_msg_ptr->dpc = mtp3_para->nw[nw].opc14; + + memcpy(up_msg_ptr->msgList, buf_ptr + 1, sub_len); + + iptrans_msg_flow_2(up_msg_ptr); + send_to_sccp_lite(up_msg_ptr); + + total_hdl_len += (sub_len + 1); + //printf("Data: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + } + + mtp3lite_rem_len[link] = 0; + return 1; +} +*/ +/******change to struct: 00, len, 0xfd*****/ +int mtp3lite_decode_tcp_msg(WORD total_len, BYTE link) +{ + BYTE lk_set, *buf_ptr; + WORD sub_len, rem_len, total_hdl_len = 0; + up_message up_msg; + up_message *up_msg_ptr = &up_msg; + BYTE nw; + + if (total_len > MTP3LITE_MSG_BUF_SIZE_PER_LINK) + return -1; + + while (total_hdl_len < total_len) + { + buf_ptr = mtp3lite_msg_buf[link] + total_hdl_len; + rem_len = total_len - total_hdl_len; + sub_len = (buf_ptr[0]<<8) + buf_ptr[1]; + + if (rem_len < (sub_len + 1)) + { + if (total_hdl_len > 0) + memcpy(mtp3lite_msg_buf[link], mtp3lite_msg_buf[link] + total_hdl_len, rem_len); + mtp3lite_rem_len[link] = rem_len; + //printf("Remain: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + return 1; + } + + if (sub_len < 1) + return -1; + else if (sub_len == 1) + { + if(buf_ptr[1+2] == 0x6) + { // Receive Keep Alive Message + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + //mtp3lite_print_msg(buf_ptr, 3); + total_hdl_len += (sub_len + 3); + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d RECV Inditify ACK",link); + //printf("KeepAlive: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + continue; + } + else + return -1; + } + + // if ((buf_ptr[1+2] > 9) || (buf_ptr[1+2] == 0)) + // return -1; + + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + + //mtp3lite_print_msg(buf_ptr, sub_len + 1); + + up_msg_ptr->len = sub_len; + up_msg_ptr->link = link; + lk_set = mtp3_para->lk[link].e1_to_linkset; + if (lk_set >= 128) + return -1; + nw = mtp3_para->ls_pro[lk_set] & 3; + up_msg_ptr->sio = 0x03 | (nw << 6);//sccp lite always itu message + up_msg_ptr->opc = mtp3_para->ls_op_pc[lk_set]; + if (pc_length(up_msg_ptr->sio >> 6) == MTP3_24BIT_PC) + up_msg_ptr->dpc = mtp3_para->nw[nw].opc24; + else + up_msg_ptr->dpc = mtp3_para->nw[nw].opc14; + + memcpy(up_msg_ptr->msgList, buf_ptr + 1 + 2, sub_len); + + iptrans_msg_flow_2(up_msg_ptr); + send_to_sccp_lite(up_msg_ptr); + + total_hdl_len += (sub_len + 1 + 2); + //printf("Data: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + } + + mtp3lite_rem_len[link] = 0; + return 1; +} + +int send_mtp3lite_id_ack(BYTE link) +{ + BYTE id_ack_msg[4]={0,0x1,0xfe, 0x6}; + + mtp3lite_DirectSendMsg(link, 4, id_ack_msg); + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d send Inditify ACK",link); + return 1; +} + +int get_mtp3lite_msg(BYTE link) +{ + int nbytes; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + { + return -1; + } + + if ((nbytes = mtp3lite_DirectRecvMsg(link)) <= 0) + return -1; + + //mtp3lite_print_msg(mtp3lite_msg_buf[link], nbytes); + + if (mtp3lite_decode_tcp_msg(nbytes, link) < 0) + { + printf("tcp link[%d] decode error!\n", link); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_TCP_FAILURE); + mtp3lite_rem_len[link] = 0; + return -1; + } + + return 1; +} + +int put_mtp3lite_msg(BYTE *msg_ptr) +{ + BYTE link, ls, nw, pclen, offset; + WORD len; + + link = msg_ptr[0]; + len = (msg_ptr[1]<<8) + msg_ptr[2]; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // Command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + if ((ls = mtp3_para->lk[link].e1_to_linkset) >= 128) + return -1; + + nw = mtp3_para->ls_pro[ls] & 0x03; + pclen = (mtp3_para->nw_pro >> nw) & 0x01; + + if (pclen) + { + if (len <= 8) + return -1; + offset = 9+1;//msg_ptr[offset+1] = sccp data + msg_ptr[offset-1] = (len - 8)%0xff; + msg_ptr[offset-2] = (len - 8)/0xff; + len = len - 7+2; + } + else + { + if (len <= 5) + return -1; + offset = 6+1; + msg_ptr[offset-1] = (len - 5)%0xff; + msg_ptr[offset-2] = (len - 5)/0xff; + len = len - 4+2; + } +/******change to struct: 00, len, 0xfd*****/ + msg_ptr[offset] = 0xfd; + +/******change to struct: 00, len, 0xfd*****/ + mtp3lite_DirectSendMsg(link, len, msg_ptr + offset - 2); + //mtp3lite_link[link].local_inactive = 2000; + + return 0; +} +/* +int put_mtp3lite_msg(BYTE *msg_ptr) +{ + BYTE link, len, ls, nw, pclen, offset; + + link = msg_ptr[0]; + len = msg_ptr[1]; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // Command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + if ((ls = mtp3_para->lk[link].e1_to_linkset) >= 128) + return -1; + + nw = mtp3_para->ls_pro[ls] & 0x03; + pclen = (mtp3_para->nw_pro >> nw) & 0x01; + + if (pclen) + { + if (len <= 8) + return -1; + offset = 9; + msg_ptr[offset] = len - 8; + len = len - 7; + } + else + { + if (len <= 5) + return -1; + offset = 6; + msg_ptr[offset] = len - 5; + len = len - 4; + } + + mtp3lite_DirectSendMsg(link, len, msg_ptr + offset); + //mtp3lite_link[link].local_inactive = 2000; + + return 0; +} +*/ +int mtp3lite_chk_lk(BYTE link) +{ +// char str[19]={7,0,0x11,0x83,0x71,0xab,0xdc,0x1a,0x06,0xf6, 0,0,0,1,5,1,3,2,9,4}; + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link] == 0)) // Command disabled + return 0; + + if (mtp3lite_link[link].init_guard_timer > 0) + mtp3lite_link[link].init_guard_timer--; + + if (mtp3lite_link[link].connfd <= 0) // Link Not Established + return 0; + + if (mtp3lite_link[link].remote_inactive > 0) + { + if (--mtp3lite_link[link].remote_inactive == 0) + { + +// if (++mtp3lite_link[link].remote_inactive_timeouts >= mtp3_para->lk[link].inactive_tm) + if(0) + { + printf("link[%d] remote inactivity %d seconds timeout %d times!\n", link, mtp3_para->lk[link].inactive, mtp3_para->lk[link].inactive_tm); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } + else + { + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + } + } + } + + if (mtp3lite_link[link].local_inactive > 0) + { + if(mtp3lite_id_fg[link]==0) + { + mtp3lite_id_fg[link] = 1; + send_mtp3lite_id_ack(link); + } + if (--mtp3lite_link[link].local_inactive == 0) + { +// mtp3lite_DirectSendMsg(link, 3, mtp3lite_ka_msg); +// put_mtp3lite_msg(&str); + mtp3lite_link[link].local_inactive = 2000; + } + } + + return 1; +} + +void deactive_mtp3lite_lk(link) +{ + if ((MTP3_LINK_TYPE(link) == LKTYPE_MTP3_LITE) && // MTP3LITE + (mtp3_para->lk[link].e1_lk_type & 0x01) && // Enabled + (mtp3lite_link[link].connfd > 0)) + {//sccp lite link + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d Deactive by MNG",link); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } +} + +void mtp3lite_init(void) +{ + int i; + + printf("MTP3LITE Init Start!\n"); + + for (i = 0; i < 256; i++) + { + mtp3lite_init_lk(i); + mtp3lite_InitClientSocket(i); + } + + mtp3lite_listen_fd = -1; + +// mtp3lite_InitServerSocket(); + + mtp3lite_init_ka_msg();//keep alive message + + printf("MTP3LITE Init Complete!\n"); +} + +void mtp3lite_reset(void) +{ + int link; + + for (link=0;link<256;link++) + { + if (mtp3lite_link[link].connfd >=0) + { + mtp3lite_CloseTcpConn(link); + mtp3lite_rem_len[link] = 0; + } + } +} + +void mtp3lite_timer(void) +{ + int link; + + mtp3lite_TcpConnectCheck(); + + for (link = 0; link < 256; link++) + { + get_mtp3lite_msg(link); + mtp3lite_chk_lk(link); + } +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpinit.c b/omc/plat/mtp3/src/mtpinit.c new file mode 100644 index 0000000..cffd084 --- /dev/null +++ b/omc/plat/mtp3/src/mtpinit.c @@ -0,0 +1,2025 @@ +#include "../../public/src/include/includes.h" +#include "../../debug/src/include/debug.h" +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpdef.h" +#include "./include/mtpfunc.h" +#include "./include/mtp3lite.h" + + +/*@ignore@*/ +#define PROG_NAME "iptrans" + +/* by simon at 23/9/26 */ +extern mtp3_dpc_index mtp3SortRoutine; +extern _mtp3_input mtp3ObjInput; +extern _mtp3_state mtp3ObjState; +extern _mtp3_IPMng MTP3IPMng; + +extern iprt1 mtp3_iprt; +struct tm mtp3_tm; +struct tm *mtp3_time = &mtp3_tm; +iptrans_shm *IPTRANS_shm_ptr; +static int iptrans_shm_id; +tup_shm *T_shm_ptr; +isup_shm *I_shm_ptr; +bicc_shm *B_shm_ptr; +sccp_shm *S_shm_ptr; +primitive_to_isup *I_primitive; +primitive_to_bicc *B_primitive; +primitive_to_sccp *S_primitive; +primitive_to_tup *T_primitive; + +primitive_to_isup I_primitive_init; +primitive_to_bicc B_primitive_init; +primitive_to_sccp S_primitive_init; +primitive_to_tup T_primitive_init; +tup_shm tup_shm_ptr_init; +isup_shm isup_shm_ptr_init; +bicc_shm bicc_shm_ptr_init; +sccp_shm sccp_shm_ptr_init; + +BOOL mtp3DebugFull=0; +mtp3_routing_result routingResult; +void scan_conf_right_or_not(BYTE nw); +void rsrt_proc(BYTE netw,BYTE dst); +void mtp3lite_reset(void); +void otherMTP3_managed_link_unavailable(BYTE chl); + +int mtp3lite_InitServerSocket(); +extern int mtp3lite_listen_fd; +extern ull Str2Ull(char *pStr); +extern void send_to_mtp2(long dest_ip); +extern void send_to_mtp2_new_struct(long dest_ip);//link,len_high,len_low,sio... +extern void MTP3_send_isup_count(BYTE nw,BYTE type); +extern void get_routes_from_other_plat(); +extern void deactive_m3ua_lk(BYTE link); + +void send_ip_to_mtp2(); + +void mtp3_init_dynamic_opc() +{ + memset((BYTE *)&mtp3_opc, 0, sizeof(mtp3_dynamic_opc)); +} + +int mtp3_create_opc(BYTE nw, DWORD opc) +{ + BYTE i, pclen, num; + DWORD para_opc; + + if ((nw > 3) || (opc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (opc == para_opc) + return 0; + + num = mtp3_opc.opc_num[nw]; + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == opc) + return 0; + } + + if (num >= MTP3_MAX_DYNAMIC_OPC_PER_NW) + return -1; + + mtp3_opc.opc[nw][num] = opc; + mtp3_opc.opc_num[nw]++; + + return 0; +} + +int mtp3_delete_opc(BYTE nw, DWORD opc) +{ + BYTE i, pclen, num, num_mv; + DWORD para_opc; + + if ((nw > 3) || (opc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (opc == para_opc) + return 0; + + num = mtp3_opc.opc_num[nw]; + if (num == 0) + return -1; + + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == opc) + { + num_mv = num - i - 1; + memcpy((BYTE *) &mtp3_opc.opc[nw][i], (BYTE *) &mtp3_opc.opc[nw][i+1], num_mv * sizeof(DWORD)); + mtp3_opc.opc_num[nw]--; + return 0; + } + } + + return -1; +} + +BYTE mtp3_check_dpc_equal_to_opc(BYTE nw, DWORD dpc) +{ + BYTE i, pclen, num; + DWORD para_opc; + + if ((nw > 3) || (dpc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (dpc == para_opc) + return 1; + + num = mtp3_opc.opc_num[nw]; + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == dpc) + return 1; + } + + return 0; +} + +BYTE MTP3_LINK_TYPE(BYTE Link) +{ + return (mtp3_para->lk[Link].e1_lk_type >> 1) & 0x07; +} + +void MTP3_Enable_SubSystem(BYTE SubSystem) +{ + SubSystem &= 15; + + if (SubSystem < 8) + mtp3_heartbeat.SubState[0] |= (1 << SubSystem); + else + mtp3_heartbeat.SubState[1] |= (1 << (SubSystem & 7)); +} + +void MTP3_Disable_SubSystem(BYTE SubSystem) +{ + SubSystem &= 15; + + if (SubSystem < 8) + mtp3_heartbeat.SubState[0] |= (~(1 << SubSystem)); + else + mtp3_heartbeat.SubState[1] |= (~(1 << (SubSystem & 7))); + +} + +void scan_lk_state_quickly(BYTE lk) +{ + if (mtp3ObjState.lk_configured[lk] != PARA_CONFIGURED) + { + lk = lk+1; + return; + } + if (mtp3ObjState.link_l3_state[lk] != AVAILABLE) + { + current_measure->lk_measure1[lk][3]++;//Duration of SL unavailability(for any reason + } + else if (mtp3ObjState.link_l3_state[lk] == UNAVAILABLE) + current_measure->lk_measure1[lk][6]++;//Duration of SL unavailability due to link fai + if (mtp3ObjState.link_l3_state[lk] == INHIBITED) + { + if (link_locally_inhibited[lk] == TRUE) + { + current_measure->lk_measure1[lk][4]++;//Duration of SL inhibition due to local management actions + } + else + current_measure->lk_measure1[lk][5]++;//Duration of SL inhibition due to remote management actions + } + + if (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) + {//this mtp3 is the normal mtp3 of this link + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15)//Alternative MTP3 available + { +// mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + //do nothing, waiting for alternative unavailable + } + else if (mtp3ObjState.lk_NMTP3_ok[lk] >> 4)//if Alternative MTP3 not avilable and normal mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change from backup to normal",lk); + mtp3ObjState.lk_NMTP3_ok[lk] &= 0x0f; + if (mtp3ObjState.lk_mtp3[lk] == mtp3_para->lk[lk].e1_to_alterMTP3) + { + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + if (mtp3ObjState.link_l3_state[lk] == AVAILABLE) + otherMTP3_managed_link_unavailable(lk); + } + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else//other case normal is always the host + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else if (mtp3_para->lk[lk].e1_to_alterMTP3 == mtp3_localip) + {//this mtp3 is the alternative mtp3 of this link + if (mtp3ObjState.lk_mtp3[lk] == mtp3_localip)//it is the current host + { + if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==2)//only the deactivate command can make it abandon host + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change back to normal",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + +/* disable the link */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service (changing back to normal MTP3)",lk); + mtp3ObjInput.lsac_input_from_l2[lk] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjInput.sltc_input[lk] = SLTC_STOP; + sltc_proc(lk); + + /* send stop command to mtp2 */ + if (MTP3_LINK_TYPE(lk) == LKTYPE_SIGTRAN)//m2ua link + { + send_command_to_mtp2(lk,MTP2_DEACTIVE_LINK); + send_command_to_mtp2(lk,MTP3_M2UA_DISABLE); + } + else + send_command_to_mtp2(lk,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+lk,MTP3ALARM_LINK_CB_TO_NMTP3); + } + } + else + { + if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + {//normal ok + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + else if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==1)//if normal MTP3 not avilable and alternative mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change to alternative",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + } + } + } + + else + { + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + else if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + + if (mtp3ObjState.lk_mtp3[lk]==mtp3_localip) + { + mtp3_heartbeat.masterMTP3[lk/8] |= (1<<(lk&7)); + } + else + mtp3_heartbeat.masterMTP3[lk/8] &= (~(1<<(lk&7))); + + lk = lk+1; + + if (lk==255) + { + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + } +} + + +void MTP3_activate(DWORD ip) +{ + int chl; + + for (chl=0; chl<256; chl++) + { + if ( mtp3_para->lk[chl].e1_to_mtp3 == ip ) + { + if ((mtp3_para->lk[chl].e1_to_alterMTP3 != 0) && (mtp3_para->lk[chl].e1_to_alterMTP3 != 0xffffffff)) + { + mtp3ObjState.lk_NMTP3_ok[chl] = 0x11;// activated and set ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_ACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer active link %d normal MTP3",chl); + } + } + else if ( mtp3_para->lk[chl].e1_to_alterMTP3 == ip ) + { + mtp3ObjState.lk_AMTP3_ok[chl] = 0x11;// activated and set ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_ACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer active link %d alternative MTP3",chl); + mtp3_alterip = ip;//take over altermtp3 + } + } +} + +void MTP3_deactivate(DWORD ip) +{ + int chl; + + for (chl=0; chl<256; chl++) + { +/* if ( mtp3_para->lk[chl].e1_to_mtp3 == ip ) + { + if ((mtp3_para->lk[chl].e1_to_alterMTP3 != 0) && (mtp3_para->lk[chl].e1_to_alterMTP3 != 0xffffffff)) + { + mtp3ObjState.lk_NMTP3_ok[chl] = 0x20;//deactive and set not ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_DEACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer deactive link %d normal MTP3",chl); + } + } +*/ + if ( mtp3_para->lk[chl].e1_to_alterMTP3 == ip ) + { + mtp3ObjState.lk_AMTP3_ok[chl] = 0x20;//deactive and set not ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_DEACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer deactive link %d alternative MTP3",chl); + deactive_m3ua_lk(chl); + if ((MTP3_LINK_TYPE(chl) == LKTYPE_M3UA) && // M3UA + (mtp3_para->lk[chl].e1_lk_type & 0x01)) + scan_lk_state_quickly(chl); + mtp3_alterip = 0;//take over altermtp3 + } +// mtp3_heartbeat.link_state[chl/8] = mtp3_heartbeat.link_state[chl/8] & (~(1<<(chl&7))); + } +} + +BYTE *check_MTP3LinkType() +{ + return mtp3ObjState.link_type; +} + +BYTE *check_MTP3LinkL2State() +{ + return mtp3ObjState.link_l2_state; +} + +int mtp3_get_time() +{ + long curr_time; + curr_time = time((long *)0); + mtp3_time = localtime(&curr_time); + return 1; +} + +void mtp3_set_csta_p() +{ + BYTE csta_p; + long timestamp; + + csta_p = (mtp3_time->tm_hour*4+(mtp3_time->tm_min/15))%96; + if (mtp3_csta_p != csta_p) + {/* clear csta_p buffer */ + timestamp = time((long *)0); + memset(&mtp3_measure.measure[csta_p],0,sizeof(struct measure_of_mtp3)); + mtp3_measure.measure[csta_p].time_stamp = timestamp; + } + mtp3_csta_p = csta_p; + current_measure = &mtp3_measure.measure[mtp3_csta_p]; +} + +void mtp_lgetlocalip() +{ + struct hostent *host; + struct in_addr *hostip_addr; + char name[100]; + + gethostname(name,24); + if ( (host=gethostbyname(name)) == NULL ) + { + printf("MTP3 Get Host Name Failed!\n"); + exit(0); + } + hostip_addr = (struct in_addr*) (*host->h_addr_list); + mtp3_localip = hostip_addr->s_addr; +// return (unsigned char)host->h_addr_list[0][2]; +} + +void * +mtp3_ShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg) +{ +void *retp; +//char *func_name = "ShmInit"; + + shm_id = shmget(key, size, shmflg); + + retp = shmat(shm_id, (char *)0, 0); + + return retp; +} + +/*******************************/ + +void tup_shm_init() +{ + T_shm_ptr = &tup_shm_ptr_init; + T_shm_ptr->TM_Buf.RSub = 0; + T_shm_ptr->TM_Buf.WSub = 0; + T_shm_ptr->MT_Buf.RSub = 0; + T_shm_ptr->MT_Buf.WSub = 0; + + T_primitive = &T_primitive_init; + T_primitive->WSub = 0; + T_primitive->RSub = 0; +} + +void isup_shm_init() +{ + I_shm_ptr = &isup_shm_ptr_init; + I_shm_ptr->IM_Buf.RSub = 0; + I_shm_ptr->IM_Buf.WSub = 0; + I_shm_ptr->MI_Buf.RSub = 0; + I_shm_ptr->MI_Buf.WSub = 0; + + I_primitive = &I_primitive_init; + I_primitive->WSub = 0; + I_primitive->RSub = 0; +} + +void bicc_shm_init() +{ + B_shm_ptr = &bicc_shm_ptr_init; + B_shm_ptr->IM_Buf.RSub = 0; + B_shm_ptr->IM_Buf.WSub = 0; + B_shm_ptr->MI_Buf.RSub = 0; + B_shm_ptr->MI_Buf.WSub = 0; + + B_primitive = &B_primitive_init; + B_primitive->WSub = 0; + B_primitive->RSub = 0; +} + +void sccp_shm_init() +{ + S_shm_ptr = &sccp_shm_ptr_init; + S_shm_ptr->SM_Buf.RSub = 0; + S_shm_ptr->SM_Buf.WSub = 0; + S_shm_ptr->MS_Buf.RSub = 0; + S_shm_ptr->MS_Buf.WSub = 0; + + S_primitive = &S_primitive_init; + S_primitive->WSub = 0; + S_primitive->RSub = 0; +} + +void iptransInit_mtp3() +{ + /* + * Get shared memory block, + * IPTRANS_SHM_KEY to be defined in iptrans.h + */ + IPTRANS_shm_ptr = (iptrans_shm *) mtp3_ShmInit(iptrans_shm_id, PROG_NAME,IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT); +// memset(IPTRANS_shm_ptr, 0, sizeof(iptrans_shm)); +} + +void init_mtp3para() +{ + int i,j; + mtp3_para = &mtp3_para_init; + for (i=0; i<256; i++) + { + mtp3_para->lk[i].e1_to_linkset = 128; + mtp3_para->lk[i].e1_to_slc = 16; + for (j=0; j<4; j++) + { + mtp3_para->nw[j].normal_ls[i] = 128; + mtp3_para->nw[j].alternative_ls[i] = 128; + } + } +} + + +int mtp3_set_flag_ip(BYTE link, DWORD mtp3_ip) +{ + int i; + + + for(i = 0; i <= MAX_MTP3_NUM; i++) + { + if(MTP3IPMng.mtp3_flag_ip[i] == mtp3_ip) + return 2; + + } + for(i = 0; i <= MAX_MTP3_NUM; i++) + { + if(MTP3IPMng.mtp3_flag_ip[i] == 0) + { + MTP3IPMng.mtp3_flag_new[i] = 1; + MTP3IPMng.mtp3_flag_ip[i] = mtp3_ip; + return 1; + } + } + return 0; +} + + +void mtp3_set_link_manager(BYTE link) +{ + if (mtp3_para->lk[link].e1_to_mtp3 == mtp3_localip) + { + if (mtp3_para->lk[link].e1_to_alterMTP3 != 0 && mtp3_para->lk[link].e1_to_alterMTP3 != 0xffffffff) + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3ObjState.lk_AMTP3_ok[link] = 1; +// MTP3IPMng.mtp3_flag_new[0] = 1; +// MTP3IPMng.mtp3_flag_ip[0] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3_set_flag_ip(link, mtp3_localip); + if(mtp3_set_flag_ip(link, mtp3_para->lk[link].e1_to_alterMTP3)<=0) + { + printf("\r\n mtp3 set flag ip error! link=%d, e1_to_alterMTP3=%ld\r\n", link, mtp3_para->lk[link].e1_to_alterMTP3 ); + } + } + else + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + mtp3ObjState.lk_AMTP3_ok[link] = 0; + } + } + else if (mtp3_para->lk[link].e1_to_alterMTP3 == mtp3_localip) + { + if (mtp3_para->lk[link].e1_to_mtp3 != 0 && mtp3_para->lk[link].e1_to_mtp3 != 0xffffffff) + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + mtp3ObjState.lk_NMTP3_ok[link] = 1; +// MTP3IPMng.mtp3_flag_new[1] = 1; +// MTP3IPMng.mtp3_flag_ip[1] = mtp3_para->lk[0].e1_to_mtp3; + if(mtp3_set_flag_ip(link, mtp3_para->lk[link].e1_to_mtp3)<=0) + { + printf("\r\n mtp3 set flag ip error! link=%d, e1_to_mtp3=%ld\r\n", link, mtp3_para->lk[link].e1_to_mtp3 ); + } + } +/* else + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3ObjState.lk_NMTP3_ok[link] = 0; + }*/ + } + else + { + mtp3ObjState.lk_NMTP3_ok[link] = 0; + mtp3ObjState.lk_AMTP3_ok[link] = 0; + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + } +} + +static void i_sys() +{ + int i; + BYTE version[3] = MTP3_VERSION; + + memset(&mtp3_heartbeat,0,sizeof(heartbeat_compoent_of_mtp3)); + memset(&mtp3SortRoutine,0,sizeof(mtp3_dpc_index)); + + for (i=0; i<32; i++) + { + mtp2_flag_new[i] = IDLE; + mtp2_flag_old[i] = IDLE; + } + for (i=0; ilk[i].e1_to_alterMTP3; + else if (mtp3ObjState.lk_NMTP3_ok[i]) + mtp3ObjState.lk_mtp3[i] = mtp3_para->lk[i].e1_to_MTP3; + else + mtp3ObjState.lk_mtp3[i] = 0;*/ + + wx5[i] = i*5; + debug_link[i] = MTP3_MSGLOG_OFF; + } + + mtp3_heartbeat.state = 0; + mtp3_heartbeat.SubState[0] = 0xff;//all subs system available + mtp3_heartbeat.SubState[1] = 0xff;//all subs system available + memcpy(mtp3_heartbeat.version,version,3); +} + +int MTP3_LinkIP_List(DWORD IP,BYTE mode) +{//mode=0:query ip, mode=1:add ip, mode=2:del ip + int i; + + if (IP==0 || IP==0xffffffff) + return -1; + + for (i=0;i1)) + memcpy(&MTP3IPMng.LinkIP[i],&MTP3IPMng.LinkIP[i+1],MTP3IPMng.LinkIPNum-i-1); + MTP3IPMng.LinkIPNum--; + } + return i; + } + } + + if (MTP3IPMng.LinkIPNum >= MAX_MTP3_NUM) + return 0; + + if (mode==1) + { + MTP3IPMng.LinkIP[MTP3IPMng.LinkIPNum] = IP; + MTP3IPMng.LinkIPNum = (MTP3IPMng.LinkIPNum + 1) & (MAX_MTP3_NUM-1); + return MTP3IPMng.LinkIPNum-1; + } + + return -1; +} + +/* slc0 slc1 slc3 slc5 +sls 0 1 2 3 +sls 4 5 6 7 +sls 8 9 10 11 +sls 12 13 14 15 */ + + +void update_sls_to_link_table(int ls) +{ + int i=0,j; + BYTE sls=0; + int lknum; + int place; + int lsx16; + int link; + + lsx16 = ls*16; + lknum = mtp3.ls[ls].linksNum_configured; +// lknum = linknum_in_ls[ls]; + if (lknum > 0) + { + for (sls=0; sls<16; sls++) + { + place = sls % lknum; + j=0; + for (i=0; i<16; i++) + { + link = ls_slc[lsx16+i]; + if (mtp3ObjState.lk_configured[link] == PARA_CONFIGURED) + { + if (j == place) + { + sls_to_link[lsx16+sls] = link; + break; + } + else + j++; + } + } + } + } + else + { + for (sls=0; sls<16; sls++) + { + sls_to_link[lsx16+sls] = 0xFF; + } + } +} + +int update_ls_slc_table(int link) +{ + WORD ls; + int lsx16; + BYTE slc; + int temp; + int idiv4; + int idiv8; + + idiv4 = link/4; + idiv8 = link/8; + temp = 3<<((link%4)*2); + ls = mtp3_para->lk[link].e1_to_linkset; + if (ls < 128) + { + lsx16 = ls << 4; + slc = mtp3_para->lk[link].e1_to_slc; + if ( (slc < 16) && + (mtp3_para->lk[link].e1_lk_type & 1) &&//enabled + (mtp3ObjState.lk_configured[ls_slc[lsx16+slc]] != PARA_CONFIGURED)) + { + mtp3ObjState.lk_configured[link] = PARA_CONFIGURED; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + mtp3.ls[ls].linksNum_configured++; + ls_slc[lsx16+slc] = link; +// linknum_in_ls[ls]++; + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] & (~temp); + return 1; + } + else + { + mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] | temp; + } + } + else + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] | temp; + + return 0; +} + +void update_influence_table(BYTE nw_no) +{ + nw_para *routine; + int lsno; + BYTE dst_num; + int i; + ls_info *ls; + BOOL added=0; + + routine = &mtp3_para->nw[nw_no]; + for ( i=0; i<256; i++ ) + { + if (routine->dpc[i] == 0) + continue; + lsno = routine->normal_ls[i]; + if ( (lsno < 128) && + ((mtp3_para->ls_pro[lsno] & 3) == nw_no) ) + { + added = 1; + Mtp3AddSortRec(nw_no,routine->dpc[i],i, routine->opc[i]); + ls = &mtp3.ls[lsno]; + dst_num = ls->influ_dstnum_asNLS; + if ( dst_num < MAX_LS_DPC ) + { + ls->influ_dstplace_intable_asNLS[dst_num] = i; + ls->influ_dstnum_asNLS ++; + } + } + + lsno = routine->alternative_ls[i]; + if ( (lsno < 128) && + (routine->normal_ls[i] < 128) && + ((mtp3_para->ls_pro[lsno] & 3) == nw_no) ) + { + if (!added) + Mtp3AddSortRec(nw_no,routine->dpc[i],i, routine->opc[i]); + ls = &mtp3.ls[lsno]; + dst_num = ls->influ_dstnum_asALS; + if ( dst_num < MAX_LS_DPC ) + { + ls->influ_dstplace_intable_asALS[dst_num] = i; + ls->influ_dstnum_asALS ++; + } + } + + added = 0; + } +} + +void update_ls_adjacent_sp_place(BYTE ls)/*linkset adjacent sp's place in sp table */ +{ + BYTE lsnw;/* network that linkset belong to */ + long pc, opc; + int j; + + pc = mtp3_para->ls_op_pc[ls]; + opc = mtp3_para->ls_opc[ls]; + if ( pc != 0) + { + for (j=0; j<256; j++) + { + lsnw = (mtp3_para->ls_pro[ls]) & 3; + if (mtp3_para->nw[lsnw].dpc[j] == pc && mtp3_para->nw[lsnw].opc[j] == opc ) + { + mtp3.ls[ls].adjacent_sp_place = j; + return; + } + } + } +} + +void update_active_ls_num() +{ + int i; + + for (i=0; i<128; i++) + { + if (mtp3.ls[i].linksNum_configured > 0) +// if ( linknum_in_ls[i] > 0 ) + { + active_ls_num ++; + } + else + { + mtp3_heartbeat.linkset_state[i/4] = mtp3_heartbeat.linkset_state[i/4] | (3<<((i%4)*2)); + } + } +} + +void update_timer(int link) +{ + lk_timer *lt; + +// mtp3_para->lt[i].t1 = 5;/* 800ms */ +// mtp3_para->lt[i].t2 = 8;/* 1280ms */ +// mtp3_para->lt[i].t3 = 5;/* 800ms */ +// mtp3_para->lt[i].t4 = 5;/* 800ms */ +// mtp3_para->lt[i].t5 = 5;/* 800ms */ +// mtp3_para->lt[i].t7 = 10;/* 1600ms */ +// mtp3_para->lt[i].t8 = 6;/* 960ms */ +// mtp3_para->lt[i].t12 = 7;/* 1120ms */ +// mtp3_para->lt[i].t13 = 7;/* 1120ms */ +// mtp3_para->lt[i].t14 = 15;/* 2400ms */ + + + lt = &mtp3_para->lt[link]; + if ( (lt->t1 > 7) || (lt->t1 < 4) ) + lt->t1 = 5; + if ( (lt->t2 > 7) || (lt->t2 < 5) ) + lt->t2 = 6; + if ( (lt->t3 > 7) || (lt->t3 < 4) ) + lt->t3 = 5; + if ( (lt->t4 > 7) || (lt->t4 < 4) ) + lt->t4 = 5; + if ( (lt->t5 > 7) || (lt->t5 < 4) ) + lt->t5 = 5; + if ( (lt->t7 > 12) || (lt->t7 < 6) ) + lt->t7 = 10; + if ( (lt->t8 > 7) || (lt->t8 < 5) ) + lt->t8 = 6; + if ( (lt->t12 > 10) || (lt->t12 < 5) ) + lt->t12 = 7; + if ( (lt->t13 > 10) || (lt->t13 < 5) ) + lt->t13 = 7; + if ( (lt->t14 > 19) || (lt->t14 < 12) ) + lt->t14 = 15; +} + +void init_mtp3table() +{ + int i; + + for (i=0; i<256; i++) + { + if (update_ls_slc_table(i)); + MTP3_LinkIP_List(mtp3_para->lk[i].e1_to_mtp3,1);//addip + MTP3_LinkIP_List(mtp3_para->lk[i].e1_to_alterMTP3,1);//addip + } + for (i=0; i<128; i++) + { + update_sls_to_link_table(i); + } + for (i=0; i<4; i++) + { + update_influence_table(i); + } + for (i=0; i<128; i++) + { + update_ls_adjacent_sp_place(i); + } + update_active_ls_num(); + for (i=0; i<256; i++) + { + update_timer(i); + } + mtp3_para->mtp3_t10 = 63;/* 40 SECOND, unit=640ms,for dpc */ + mtp3_para->mtp3_t18 = 20; + mtp3_para->mtp3_t19 = 4; + mtp3_para->mtp3_t20 = 4; + mtp3_para->mtp3_t21 = 375;/* 30 SECOND,unit=80ms, for linkset */ + mtp3ObjInput.tprc_input = TPRC_SP_RESTART_INDICATION; + own_sp_restarting = 1; + tprc_mgmt_signalling_point_restart_indication(); + mtp3_get_time(); + mtp3_set_csta_p(); + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + get_routes_from_other_plat(); + mtp3_debug(MTP3DB_CMD,"MTP3 INIT COMPLETE(%08lx)",mtp3_localip); +} + +void reset_mtp3() +{ +// init_mtp3para(); + + mtp3lite_reset(); + i_sys(); + init_mtp3table(); + if(mtp3_alterip != 0)//take over altermtp3 + { + MTP3_activate(mtp3_alterip); + } +} + +void mtp3_reload_data() +{ + mtp3_readpara_from_disk(); +// recover_para(); + i_sys(); + init_mtp3table(); +} + +void mtp_shm_init(WORD moduleid_systemid) +{ + printf("mtp3 start init\n"); + mtp_lgetlocalip(); + sccp_shm_init(); + tup_shm_init(); + isup_shm_init(); + bicc_shm_init(); + iptransInit_mtp3(); + init_mtp3para(); + mtp_debug_set(); + mtp_snmp_init(); + mtp3_reload_data(); + mtp3lite_init(); + mtp3_init_dynamic_opc(); + mtp2_module = moduleid_systemid>>8; + mtp2_systemid = moduleid_systemid & 0xff; + printf("mtp3 complete init\n"); +} + +void mtp3_init_serial(char *Serial) +{ + mtp3_para->MTP3SerialNum = Str2Ull(Serial); +} + +int sccp_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = S_primitive->RSub; + if (RSub != S_primitive->WSub) + { + memcpy(ptr,&S_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + S_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int isup_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = I_primitive->RSub; + if (RSub != I_primitive->WSub) + { + memcpy(ptr,&I_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + I_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int bicc_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = B_primitive->RSub; + if (RSub != B_primitive->WSub) + { + memcpy(ptr,&B_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + B_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int tup_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = I_primitive->RSub; + if (RSub != I_primitive->WSub) + { + memcpy(ptr,&I_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + I_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int tup_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = T_shm_ptr->MT_Buf.RSub; + if (RSub != T_shm_ptr->MT_Buf.WSub) + { + memcpy(msgptr,&T_shm_ptr->MT_Buf.msgNum[RSub],sizeof(up_message)); + + T_shm_ptr->MT_Buf.RSub++; + return 1; + } + return 0; +} + +int isup_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = I_shm_ptr->MI_Buf.RSub; + if (RSub != I_shm_ptr->MI_Buf.WSub) + { + memcpy(msgptr,&I_shm_ptr->MI_Buf.msgNum[RSub],sizeof(up_message)); + + I_shm_ptr->MI_Buf.RSub++; + return 1; + } + return 0; +} + +int bicc_GetMsg(up_message_2 *msgptr) +{ + BYTE RSub; + + RSub = B_shm_ptr->MI_Buf.RSub; + if (RSub != B_shm_ptr->MI_Buf.WSub) + { + memcpy(msgptr,&B_shm_ptr->MI_Buf.msgNum[RSub],sizeof(up_message_2)); + + B_shm_ptr->MI_Buf.RSub++; + return 1; + } + return 0; +} + +int sccp_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = S_shm_ptr->MS_Buf.RSub; + if (RSub != S_shm_ptr->MS_Buf.WSub) + { + memcpy(msgptr,&S_shm_ptr->MS_Buf.msgNum[RSub],sizeof(up_message)); + S_shm_ptr->MS_Buf.RSub++; + return 1; + } + return 0; +} + +int mtp3_perform_routing(up_message *msgptr,BYTE WriteSub) +{ + BYTE sls; + int returnValue; + BYTE sio; + + sio = msgptr->sio; + if (msgptr->dest_ip != 0xffffffff) + return 256; + else + { + sls = msgptr->cic[0] & 0x0f; + returnValue = check_outbound_route((msgptr->sio>>6)&3,msgptr->dpc,sls, msgptr->opc);//??- + if (returnValue >= 0) + { + switch (sio & 7) + { + case 3: + routingResult.sccpMsgOutLink[WriteSub] = returnValue; + break; + case 4: + routingResult.tupMsgOutLink[WriteSub] = returnValue; + break; + case 5: + routingResult.isupMsgOutLink[WriteSub] = returnValue; + break; + case 13: + routingResult.biccMsgOutLink[WriteSub] = returnValue; + break; + } + } + else + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,SIO=%x,DPC=%lx,len=%d",msgptr->sio,msgptr->dpc,msgptr->len); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + switch (returnValue) + { + case -1: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset unavailable"); + break; + case -2: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset not configured"); + break; + case -3: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:dpc(dpc->linkset) not configured"); + break; + default: + break; + } + } + return returnValue; + } +} + +int mtp3_perform_routing_2(up_message_2 *msgptr,BYTE WriteSub) +{ + BYTE sls; + int returnValue; + BYTE sio; + + sio = msgptr->sio; + if (msgptr->dest_ip != 0xffffffff) + return 256; + else + { + sls = msgptr->cic[0] & 0x0f; + returnValue = check_outbound_route((msgptr->sio>>6)&3,msgptr->dpc,sls, msgptr->opc);//??- + if (returnValue >= 0) + { + switch (sio & 15) + { + case 3: + routingResult.sccpMsgOutLink[WriteSub] = returnValue; + break; + case 4: + routingResult.tupMsgOutLink[WriteSub] = returnValue; + break; + case 5: + routingResult.isupMsgOutLink[WriteSub] = returnValue; + break; + case 13: + routingResult.biccMsgOutLink[WriteSub] = returnValue; + break; + } + } + else + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,SIO=%x,DPC=%lx,len=%d",msgptr->sio,msgptr->dpc,msgptr->len); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + switch (returnValue) + { + case -1: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset unavailable"); + break; + case -2: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset not configured"); + break; + case -3: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:dpc(dpc->linkset) not configured"); + break; + default: + break; + } + } + return returnValue; + } +} + +int sccp_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+2]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+2]++;/* MSUs */ + + ReadSub = S_shm_ptr->SM_Buf.RSub; + WriteSub = S_shm_ptr->SM_Buf.WSub; + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from SCCP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&S_shm_ptr->SM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + S_shm_ptr->SM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[2]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+2]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+2]++;/* MSUs */ + } + return rtResult; +} + +int tup_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + ReadSub = T_shm_ptr->TM_Buf.RSub; + WriteSub = T_shm_ptr->TM_Buf.WSub; + +// current_measure->tf_measure1[0][wx5[nw]+3]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+3]++;/* MSUs */ + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from TUP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[3]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&T_shm_ptr->TM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + T_shm_ptr->TM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[3]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+3]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+3]++;/* MSUs */ + } + return rtResult; +} + +int isup_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+4]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+4]++;/* MSUs */ + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from ISUP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + ReadSub = I_shm_ptr->IM_Buf.RSub; + WriteSub = I_shm_ptr->IM_Buf.WSub; + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[4]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&I_shm_ptr->IM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + I_shm_ptr->IM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[4]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+4]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+4]++;/* MSUs */ + } + return rtResult; +} + +int bicc_to_mtp3(up_message_2 *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+4]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+4]++;/* MSUs */ + + ReadSub = B_shm_ptr->IM_Buf.RSub; + WriteSub = B_shm_ptr->IM_Buf.WSub; + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from BICC,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[4]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing_2(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&B_shm_ptr->IM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message_2)); + B_shm_ptr->IM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[4]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+4]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+4]++;/* MSUs */ + } + return rtResult; +} + +void scan_lk_state() +{ + static BYTE lk=0; + + if (mtp3ObjState.lk_configured[lk] != PARA_CONFIGURED) + { + lk = lk+1; + return; + } + if (mtp3ObjState.link_l3_state[lk] != AVAILABLE) + { + current_measure->lk_measure1[lk][3]++;//Duration of SL unavailability(for any reason + } + else if (mtp3ObjState.link_l3_state[lk] == UNAVAILABLE) + current_measure->lk_measure1[lk][6]++;//Duration of SL unavailability due to link fai + if (mtp3ObjState.link_l3_state[lk] == INHIBITED) + { + if (link_locally_inhibited[lk] == TRUE) + { + current_measure->lk_measure1[lk][4]++;//Duration of SL inhibition due to local management actions + } + else + current_measure->lk_measure1[lk][5]++;//Duration of SL inhibition due to remote management actions + } + + if (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) + {//this mtp3 is the normal mtp3 of this link + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15)//Alternative MTP3 available + { +// mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + //do nothing, waiting for alternative unavailable + } + else if (mtp3ObjState.lk_NMTP3_ok[lk] >> 4)//if Alternative MTP3 not avilable and normal mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change from backup to normal",lk); + mtp3ObjState.lk_NMTP3_ok[lk] &= 0x0f; + if (mtp3ObjState.lk_mtp3[lk] == mtp3_para->lk[lk].e1_to_alterMTP3) + { + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + if (mtp3ObjState.link_l3_state[lk] == AVAILABLE) + otherMTP3_managed_link_unavailable(lk); + } + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else//other case normal is always the host + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else if (mtp3_para->lk[lk].e1_to_alterMTP3 == mtp3_localip) + {//this mtp3 is the alternative mtp3 of this link + if (mtp3ObjState.lk_mtp3[lk] == mtp3_localip)//it is the current host + { + if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==2)//only the deactivate command can make it abandon host + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change back to normal",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + +/* disable the link */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service (changing back to normal MTP3)",lk); + mtp3ObjInput.lsac_input_from_l2[lk] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjInput.sltc_input[lk] = SLTC_STOP; + sltc_proc(lk); + + /* send stop command to mtp2 */ + if (MTP3_LINK_TYPE(lk) == LKTYPE_SIGTRAN)//m2ua link + { + send_command_to_mtp2(lk,MTP2_DEACTIVE_LINK); + send_command_to_mtp2(lk,MTP3_M2UA_DISABLE); + } + else + send_command_to_mtp2(lk,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+lk,MTP3ALARM_LINK_CB_TO_NMTP3); + } + } + else + { + if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + {//normal ok + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + else if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==1)//if normal MTP3 not avilable and alternative mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change to alternative",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + } + } + } + + else + { + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + else if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + + if (mtp3ObjState.lk_mtp3[lk]==mtp3_localip) + { + mtp3_heartbeat.masterMTP3[lk/8] |= (1<<(lk&7)); + } + else + mtp3_heartbeat.masterMTP3[lk/8] &= (~(1<<(lk&7))); + + lk = lk+1; + + if (lk==255) + { + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + } +} + + +void scan_ls_state() +{ + BYTE nw; + WORD adsp_place; + static BYTE ls=0; + + adsp_place = mtp3.ls[ls].adjacent_sp_place; + if (adsp_place > 255) + { + ls = (ls + 1) & 0x7f; + return; + } + nw = ( mtp3_para->ls_pro[ls] ) & 3; + if (mtp3.ls[ls].adjacentsp_acessible != TRUE) + { + current_measure->ls_measure[ls][6]++;/* duration_of_adjacent_sp_inaccessible */; + } + if ( (mtp3.ls[ls].links_available == 0) && + (mtp3.ls[ls].linksNum_configured) ) +// (linknum_in_ls[ls] > 0) ) + { + current_measure->ls_measure[ls][0]++;/* duration_of_unavailability */ + } + ls = (ls + 1) & 0x7f; +} + +void scan_mtp2_activity()// check mtp2 exist or not +{ + int i,j; + int tmp; + int chl; + static BYTE mtp_t20s=0; + + mtp_t20s++; + if (mtp_t20s == 3) + { + mtp_t20s = 0; + for (i=0; i<32; i++) + { + if ( (mtp2_flag_old[i] != mtp2_flag_new[i]) && + (mtp2_flag_new[i] == IDLE) ) + { + tmp = i << 3; + for (j=0; j<8; j++) + { + chl = tmp+j; + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_IDLE; + nld_cause_lkd[chl] ++;/* internet cable disconnect cause lk disconnect */ + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + } + } + } + mtp2_flag_old[i] = mtp2_flag_new[i]; + mtp2_flag_new[i] = IDLE; + } + } +} + +int sys_mtp3_table(DWORD ip); +void scan_mtp3_activity()// check other mtp3 can use or not +{ + int chl; + static BYTE mtp3ip=0; +/* WORD lsno; + ls_info *ls=NULL;*/ + + mtp3ip=(mtp3ip+1) % 127; + + if (mtp3ip >= MAX_MTP3_NUM) + return; + + if ( (MTP3IPMng.mtp3_flag_old[mtp3ip] != MTP3IPMng.mtp3_flag_new[mtp3ip]) && + (MTP3IPMng.mtp3_flag_new[mtp3ip] == IDLE) && + (MTP3IPMng.mtp3_flag_ip[mtp3ip] != mtp3_localip) ) + { + for (chl=0; chl<256; chl++) + { + if ( (mtp3ObjState.lk_mtp3[chl] == MTP3IPMng.mtp3_flag_ip[mtp3ip]) && + (mtp3ObjState.link_l3_state[chl] == AVAILABLE) ) + { +/* lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + ls->links_available--;*/ + mtp3_debug(MTP3DB_EVENT,"link %d MTP3 %08lx timeout",chl,mtp3ObjState.lk_mtp3[chl]); + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + tsrc_proc(chl); + hmrt_tcoc_update_routing_tables(chl); + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + } + + if (mtp3_para->lk[chl].e1_to_mtp3 == MTP3IPMng.mtp3_flag_ip[mtp3ip]) + mtp3ObjState.lk_NMTP3_ok[chl] = 0; + else if (mtp3_para->lk[chl].e1_to_alterMTP3 == MTP3IPMng.mtp3_flag_ip[mtp3ip]) + mtp3ObjState.lk_AMTP3_ok[chl] = 0; + + } + } + MTP3IPMng.mtp3_flag_old[mtp3ip] = MTP3IPMng.mtp3_flag_new[mtp3ip]; + MTP3IPMng.mtp3_flag_new[mtp3ip] = IDLE; +} + +void mtp3_proc() +{ + up_message getmsg; + up_message_2 getmsg_2; + up_message *msgptr = (up_message*)&getmsg; + up_message_2 *msgptr_2 = (up_message_2*)&getmsg_2; + BYTE i; + BYTE temp; +// BYTE ib_b; +// unsigned short addr; + static BYTE sltc_loop=0; + static BYTE dst_loop=0; + static BYTE mtp_t1s=0; + static BYTE mtp_t10s=0; + static BYTE mtp_10ms_tick=0; + static BYTE mtp_100ms_tick=0; + +// addr = 0x378; +// ib_b = inb(addr); +// outb(ib_b | 2,addr); + + mtp3DebugFull = 0; + + for (i = 0; i<128; i++) + { + GetMtp2Msg(SS7_PORT);// get mtp2 message by port 4950 + GetMtp2Msg(M2UA_PORT);// get m2ua message + GetM3uaMsg(M2UA_PORT);// get m3ua message + get_isup(msgptr);// check isup buffer message + get_bicc(msgptr_2);// check bicc buffer message + get_tup(msgptr);// check tup buffer message + get_sccp(msgptr);// check sccp buffer message + } + + mtp3lite_timer(); + m3ua_timer(); +/* Q.704 state machine */ + for (i=0; i<16; i++) + { + temp = dst_loop + i; + if (MTP3_LINK_TYPE(temp) == LKTYPE_MTP3_LITE ||MTP3_LINK_TYPE(temp) == LKTYPE_M3UA) + continue; + lsac_proc(temp); + tlac_proc(temp); + tsrc_proc(temp); + tcoc_proc(temp); + tcbc_proc(temp); + rtpc_proc(srm_nw,temp); + rtac_proc(srm_nw,temp); + rsrt_proc(srm_nw,temp); + mtp3Timer_proc(temp); + taprc_proc(temp); + } + dst_loop = dst_loop + 16; + if (dst_loop == 0) + srm_nw = (srm_nw + 1) & 3; + if (MTP3_LINK_TYPE(sltc_loop) != LKTYPE_MTP3_LITE && MTP3_LINK_TYPE(sltc_loop) != LKTYPE_M3UA) + sltc_proc(sltc_loop); + sltc_loop++; +/* Q.704 state machine */ + + for (i=0;i<4;i++) + { + scan_conf_right_or_not(i); + } + + switch (mtp_10ms_tick)/* every 160ms loop one times */ + { + case 0:/* 10ms */ + break; + case 1:/* 20ms */ + break; + case 2:/* 30ms */ + scan_lk_state(); + break; + case 3:/* 40ms */ + break; + case 4:/* 50ms */ + break; + case 5:/* 60ms */ + break; + case 6:/* 70ms */ + scan_lk_state(); + break; + case 7:/* 80ms */ + scan_ls_state(); + break; + case 8:/* 90ms */ + break; + case 9:/* 100ms */ + mtp_m_rt(); + break; + case 10:/* 110ms */ + scan_lk_state(); + break; + case 11:/* 120ms */ + break; + case 12:/* 130ms */ + break; + case 13:/* 140ms */ + scan_mtp3_activity(); + break; + case 14:/* 150ms */ + scan_lk_state(); + break; + case 15:/* 160ms */ + scan_ls_state(); + break; + default: + break; + } + mtp_10ms_tick = ((mtp_10ms_tick+1) & 15); + + if (mtp_100ms_tick == 9) + { + mtp_100ms_tick = 0; + mtp_t1s++; + if (mtp_t1s == 10)/* 1 second */ + { + mtp_t1s = 0; + tprc_proc(); + mtp_t10s++; + send_ip_to_mtp2(); + send_ip_to_mtp2(); + if (mtp_t10s == 10)/* 10 second */ + { + mtp3_heartbeat.state = 1; + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + mtp3_get_time();// get current time + mtp3_set_csta_p();// set csta portion + scan_mtp2_activity(); + mtp_t10s = 0; + + if (mtp3lite_listen_fd <= 0) + mtp3lite_InitServerSocket(); + } + } + } + mtp_100ms_tick ++; + +// outb(ib_b & 0xfd,addr); +} + +//These functions is added by Roy Jiang for supporting SCCP dual server redirect +int sccp_redirect(up_message *msgptr) +{ +// BYTE len; + WORD len;//long message + BYTE sio; + long route_mark;/* dpc opc sls */ + BYTE sls; + long dpc; + long opc; + BYTE pclen; + int outlink=0; + long dest_ip; + BYTE *pContent; + BYTE nw; + + assert (msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio & 0xcf; + dpc = msgptr->dpc; + opc = msgptr->opc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + dest_ip = msgptr->dest_ip; + outlink = msgptr->link; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + len = msgptr->len; + if (pclen == MTP3_24BIT_PC) + { + mtp3_iprt.io_msg.msgLength = len + 10 + 1; + pContent[0] = outlink; + pContent[1] = (len+8)>>8; + pContent[2] = (len+8)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&opc,3); + memcpy(&pContent[10],&msgptr->cic[0],1); + memcpy(&pContent[11],&msgptr->msgList,len); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(opc << 14)+dpc; + pContent[0] = outlink; + pContent[1] = (len+5)>>8; + pContent[2] = (len+5)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->msgList,len); + } + len = (pContent[1]<<8) +pContent[2]; + if (len < 5 || len >272) + { + mtp3ObjState.MTP3WatchDog[10]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&pContent[0],len + 3); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[2]++; + + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} + +int isup_redirect(up_message *msgptr) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE nw; + DWORD dest_ip; +// BYTE rSub; + BYTE *pContent; + + assert (msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio & 0xcf; + dpc = msgptr->dpc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + outlink = msgptr->link; + dest_ip = msgptr->dest_ip; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + pContent[0] = outlink; + pContent[1] = (len + 10)>>8; + pContent[2] = (len + 10)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&msgptr->opc,3);//keep the UP filled opc + pContent[10] = msgptr->cic[0] & 0x0f; + memcpy(&pContent[11],&msgptr->cic[0],2); + memcpy(&pContent[13],&msgptr->msgList,len); + MTP3_send_isup_count(nw,pContent[13]); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(msgptr->opc << 14)+dpc;//keep the UP filled opc + pContent[0] = outlink; + pContent[1] = (len+7)>>8; + pContent[2] = (len+7)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->cic,2); + memcpy(&pContent[10],&msgptr->msgList,len); + MTP3_send_isup_count(nw,pContent[10]); + } + + len = (pContent[1]<<8) + pContent[2]; + if (len < 5 || len > 272) + { + mtp3ObjState.MTP3WatchDog[14]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&pContent[0],len + 3); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[4]++; + + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} + +int bicc_redirect(up_message_2 *msgptr) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *pContent; + BYTE nw; + DWORD dest_ip; +// BYTE rSub; + + assert(msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio; + dpc = msgptr->dpc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + dest_ip = msgptr->dest_ip; + outlink = msgptr->link; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + pContent[0] = outlink; + pContent[1] = (len + 12)>>8; + pContent[2] = (len + 12)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&msgptr->opc,3);//keep the UP filled opc + pContent[10] = msgptr->cic[0] & 0x0f; + memcpy(&pContent[11],&msgptr->cic[0],4); + memcpy(&pContent[15],&msgptr->msgList,len); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(msgptr->opc << 14)+dpc;//keep the UP filled opc + pContent[0] = outlink; + pContent[1] = (len+9)>>8; + pContent[2] = (len+9)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->cic,4); + memcpy(&pContent[12],&msgptr->msgList,len); + } + mtp3.nw[nw].flow.MtoI[4]++; + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpm.c b/omc/plat/mtp3/src/mtpm.c new file mode 100644 index 0000000..706d21d --- /dev/null +++ b/omc/plat/mtp3/src/mtpm.c @@ -0,0 +1,2492 @@ +#include "../../debug/src/include/debug.h" +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +extern void mtp3_debug(int n,const char *fmt,...); +/*@ignore@*/ +int mtp3_send_netcap=0; + +void reset_mtp3(); +long atol(const char *nptr); +// by simon at 23/9/22 +//int gettimeofday(struct timeval *tv,struct timezone *tz); +struct tm *localtime(const time_t *timep); +void mtp3_list_link(BYTE i); + +static char ascii[16] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39, + 0x41,0x42,0x43,0x44,0x45,0x46}; +extern BOOL mtp3DebugFull; + +BYTE disp_flag; +BYTE disp_page[16]; + +/* by simon at 23/9/27 */ +extern BYTE * disp_ptr; +extern BYTE disp_length; + +static DWORD debug_mask=0; +void mtp3_show_routine_status(BYTE nw); +void mtp3_show_routine_status_sorted(BYTE nw); +void mtp3_list_log_status(); +void mtp3_reload_data(); +int mtp3_write_parameter(); + +static BYTE title1_p[] = +{ + " PAGE01 MTP3 Measure-TRAFFIC sub-page0:flow, sub-page1:throwed \n\r\ + [---SNM---] [---T+M---] [--SCCP---] [---TUP---] [--ISUP---]\n\r\ +--Page--\n\r\ + U (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + M (nw3)\n\r\ + M (nw0)\n\r\ + t (nw1) E\n\r\ + o (nw2) 1\n\r\ + I (nw3)\n\r\ + I (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + M (nw3)\n\r\ + M (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + U (nw3)\n\r\ + M (nw0)\n\r\ + S (nw1)\n\r\ + T (nw2)\n\r\ + P (nw3)\n\r\ +" +}; + +static BYTE title2_p[] = +{ + " PAGE02 link mark \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--Page--\n\r\ +link_available\n\r\ +link_unavailable\n\r\ +failed\n\r\ +CB_in_progress\n\r\ +CO_in_progress\n\r\ +link_inhibited\n\r\ +locally_inhibited\n\r\ +remotely_inhibited\n\r\ +localInhibit_inPro\n\r\ +uninhibit_in_pro\n\r\ +local_blocked\n\r\ +remote_blocked\n\r\ +local_change_over\n\r\ +" +}; + +static BYTE title3_p[] = +{ + " PAGE03 MTP2 MTP3 flag \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ + Page\n\r\ + mtp2 flag(old)\n\r\ + \n\r\ + mtp2 flag(new)\n\r\ + \n\r\ + \n\r\ + page\n\r\ + 0:mtp3 ip\n\r\ + 1:mtp3 flag old\n\r\ + 2:mtp3 flag new\n\r\ + 3:lk_configured\n\r\ +" +}; + +static BYTE title4_p[] = +{ + " PAGE09 MTP3 STATE MACHINE'S INPUT \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--Page--\n\r\ +LSAC L2\n\r\ +LSAC SLTC\n\r\ +LSAC SLM\n\r\ +LSAC STM\n\r\ +LSAC TCOC\n\r\ +LSAC MGMT\n\r\ +TLAC SLM\n\r\ +TLAC STM\n\r\ +TLAC HMDT\n\r\ +TSRC STM\n\r\ +TSRC TLAC\n\r\ +TSRC TCOC\n\r\ +TSRC TCBC\n\r\ +TSRC SRM\n\r\ +TCOC L2\n\r\ +TCOC STM\n\r\ +TCOC TSRC\n\r\ +TCOC HMDT\n\r\ +TCBC\n\r\ +TCBC_TSRC\n\r\ +T(A)PRC\n\r\ +" +}; + +static BYTE title5_p[] = +{ + " PAGE05 MTP3 Port state(16 port per sub page)\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +subPage\r\n\ +L1\r\n\ +L2\r\n\ +L3\r\n\ +lsac\r\n\ +sltc\r\n\ +tlac\r\n\ +tsrc\r\n\ +tcoc\r\n\ +tcbc\r\n\ +rtpc[nw0]\r\n\ +rtpc[nw1]\r\n\ +rtpc[nw2]\r\n\ +rtpc[nw3]\r\n\ +rtac[nw0]\r\n\ +rtac[nw1]\r\n\ +rtac[nw2]\r\n\ +rtac[nw3]\r\n\ +tprc" +}; + +static BYTE title6_p[] = +{ + " PAGE06 MTP3 ROUTINE TABLE(4) \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--PAGE--\n\r\ +0 INTERNATIONAL\n\r\ +1 INTERNATIONAL(S)\n\r\ +2 NATIONAL\n\r\ +3 NATIONAL(S)\n\r\ +\n\r\ +\n\r\ +value=\n\r\ +18:route:normal ls\n\r\ + nls:available\n\r\ + als:unavailable\n\r\ +10:route:normal ls\n\r\ + nls:available\n\r\ + als:available\n\r\ +52:route=alter ls\n\r\ + nls:unavailable\n\r\ + als:available\n\r\ +8A:no route\n\r\ +other:problem bug\n\r\ +" +}; + +static BYTE title7_p[] = +{ + " PAGE07 MTP3 LINKSET SLS TABLE \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--PAGE--\n\r\ +(16*page+00)ls\n\r\ +(16*page+01)ls\n\r\ +(16*page+02)ls\n\r\ +(16*page+03)ls\n\r\ +(16*page+04)ls\n\r\ +(16*page+05)ls\n\r\ +(16*page+06)ls\n\r\ +(16*page+07)ls\n\r\ +(16*page+08)ls\n\r\ +(16*page+09)ls\n\r\ +(16*page+10)ls\n\r\ +(16*page+11)ls\n\r\ +(16*page+12)ls\n\r\ +(16*page+13)ls\n\r\ +(16*page+14)ls\n\r\ +(16*page+15)ls\n\r\ +" +}; + +static BYTE title8_p[] = +{ + " PAGE08 MTP3 Version 1.0 linkset State \n\r\ + avail mark place cf influence dst number\n\r\ +--Page--\n\r\ +(16*page+00)ls\n\r\ +(16*page+01)ls\n\r\ +(16*page+02)ls\n\r\ +(16*page+03)ls\n\r\ +(16*page+04)ls\n\r\ +(16*page+05)ls\n\r\ +(16*page+06)ls\n\r\ +(16*page+07)ls\n\r\ +(16*page+08)ls\n\r\ +(16*page+09)ls\n\r\ +(16*page+10)ls\n\r\ +(16*page+11)ls\n\r\ +(16*page+12)ls\n\r\ +(16*page+13)ls\n\r\ +(16*page+14)ls\n\r\ +(16*page+15)ls\n\r\ +" +}; + +static BYTE title9_p[] = +{ + " PAGE9 MTP3 ls influence dst\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--page--\n\r\ +page0-page127\n\r\ +ls0 -ls127\n\r\ +[NLS]\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +[ALS]\n\r\ +" +}; + +static BYTE title10_p[] = +{ + " PAGE10 MTP3 isup sd/rv count\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--page--\n\r\ +RvISUP\n\r\ +\n\r\ +\n\r\ +\n\r\ +SdISUP\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +" +}; + +static BYTE title11_p[] = +{ + " PAGE11 MTP3 watch dog\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Dog\n\r\ +" +}; + +void mtpi_m() +{ + memset(disp_page,0,16); +} + +BYTE mtp_disp_line(BYTE page, BYTE line)//return display length,disp data ptr per line +{ + BYTE disp_length; + BYTE subpage; + + disp_length = 16; + + page = page & 15; + disp_page[page] = disp_page[page] & 31; + subpage = disp_page[page]; + + switch(page) + { + case 1: + if (subpage == 0) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.UtoM; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.UtoM; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.UtoM; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.UtoM; + break; + case 5: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoI; + break; + case 6: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoI; + break; + case 7: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoI; + break; + case 8: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoI; + break; + case 9: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.ItoM; + break; + case 10: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.ItoM; + break; + case 11: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.ItoM; + break; + case 12: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.ItoM; + break; + case 13: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoU; + break; + case 14: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoU; + break; + case 15: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoU; + break; + case 16: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoU; + break; + case 17: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp; + break; + case 18: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp; + break; + case 19: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp; + break; + case 20: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp; + break; + default: + disp_length = 0; + break; + } + } + else if (subpage == 1) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.UtoM_throwed; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.UtoM_throwed; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.UtoM_throwed; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.UtoM_throwed; + break; + case 5: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoI_throwed; + break; + case 6: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoI_throwed; + break; + case 7: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoI_throwed; + break; + case 8: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoI_throwed; + break; + case 9: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.ItoM_throwed; + break; + case 10: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.ItoM_throwed; + break; + case 11: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.ItoM_throwed; + break; + case 12: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.ItoM_throwed; + break; + case 13: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoU_throwed; + break; + case 14: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoU_throwed; + break; + case 15: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoU_throwed; + break; + case 16: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoU_throwed; + break; + case 17: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp_throwed; + break; + case 18: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp_throwed; + break; + case 19: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp_throwed; + break; + case 20: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp_throwed; + break; + default: + disp_length = 0; + break; + } + } + else if (subpage == 2) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp_loop; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp_loop; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp_loop; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp_loop; + break; + default: + disp_length = 0; + break; + } + } + else + disp_length = 0; + break; + case 2: + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = link_available + subpage*16; + break; + case 2: +/* disp_ptr = link_unavailable + subpage*16;*/ + break; + case 3: + disp_ptr = failed + subpage*16; + break; + case 4:/* l3 */ + disp_ptr = changeback_in_progress + subpage*16; + break; + case 5:/* l2 */ + disp_ptr = changeover_in_progress + subpage*16; + break; + case 6: + disp_ptr = link_inhibited + subpage*16; + break; + case 7: + disp_ptr = link_locally_inhibited + subpage*16; + break; + case 8: + disp_ptr = link_remotely_inhibited + subpage*16; + break; + case 9: + disp_ptr = local_inhibit_in_progress + subpage*16; + break; + case 10: + disp_ptr = uninhibit_in_progress + subpage*16; + break; + case 11: + disp_ptr = local_blocked + subpage*16; + break; + case 12: + disp_ptr = remote_blocked + subpage*16; + break; + case 13: + disp_ptr = local_change_over + subpage*16; + break; + default: + disp_length = 0; + + } + break; + case 3: + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 3) + { + disp_ptr = mtp2_flag_old+(line-1)*16; + } + else if (line < 5) + { + disp_ptr = mtp2_flag_new+(line-3)*16; + } + else if (line==5) + { + disp_ptr = &MTP3IPMng.LinkIPNum; + disp_length = 1; + } + else if (line < 24) + { + if (subpage == 0) + disp_ptr = (BYTE*)MTP3IPMng.mtp3_flag_ip+(line-6)*16; + else if (subpage == 1) + disp_ptr = MTP3IPMng.mtp3_flag_old+(line-6)*16; + else if (subpage == 2) + disp_ptr = MTP3IPMng.mtp3_flag_new+(line-6)*16; + else if (subpage == 3) + disp_ptr = mtp3ObjState.lk_configured+(line-6)*16; + else if (subpage == 4) + disp_ptr = mtp3ObjState.lk_NMTP3_ok+(line-6)*16; + else if (subpage == 5) + disp_ptr = mtp3ObjState.lk_AMTP3_ok+(line-6)*16; + else if (subpage == 6) + disp_ptr = (BYTE*)MTP3IPMng.LinkIP+(line-6)*16; + } + else + disp_length = 0; + break; + case 4:/* input of state machine */ + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1:/* l3 */ + disp_ptr = mtp3ObjInput.lsac_input_from_l2 + subpage*16; + break; + case 2:/* l2 */ + disp_ptr = mtp3ObjInput.lsac_input_from_sltc + subpage*16; + break; + case 3:/* l1 */ + disp_length = 0; + break; + case 4: + disp_ptr = mtp3ObjInput.lsac_input_from_stm + subpage*16; + break; + case 5: + disp_ptr = mtp3ObjInput.lsac_input_from_tcoc + subpage*16; + break; + case 6: + disp_ptr = mtp3ObjInput.lsac_input_from_mgmt + subpage*16; + break; + case 7: + disp_ptr = mtp3ObjInput.tlac_input_from_slm + subpage*16; + break; + case 8: + disp_ptr = mtp3ObjInput.tlac_input_from_stm + subpage*16; + break; + case 9: + disp_ptr = mtp3ObjInput.tlac_input_from_hmdt + subpage*16; + break; + case 10: + disp_ptr = mtp3ObjInput.tsrc_input_from_stm + subpage*16; + break; + case 11: + disp_ptr = mtp3ObjInput.tsrc_input_from_tlac + subpage*16; + break; + case 12: + disp_ptr = mtp3ObjInput.tsrc_input_from_tcoc + subpage*16; + break; + case 13: + disp_ptr = mtp3ObjInput.tsrc_input_from_tcbc + subpage*16; + break; + case 14: + disp_length = 0; + break; + case 15: + disp_length = 0; + break; + case 16: + disp_ptr = mtp3ObjInput.tcoc_input_from_stm + subpage*16; + break; + case 17: + disp_ptr = mtp3ObjInput.tcoc_input_from_tsrc + subpage*16; + break; + case 18: + disp_ptr = mtp3ObjInput.tcoc_input_from_hmdt + subpage*16; + break; + case 19: + disp_ptr = mtp3ObjInput.tcbc_input + subpage*16; + break; + case 20: + disp_ptr = mtp3ObjInput.tcbc_input_from_tsrc + subpage*16; + break; +/* case 21: + disp_ptr = mtp3ObjInput.sltc_input + subpage*16; + break;*/ + case 21: + disp_ptr = mtp3ObjInput.taprc_input + subpage*16; + break; + case 22: + disp_ptr = &mtp3ObjInput.tprc_input; + disp_length = 1; + break; + default: + disp_length = 0; + break; + + } + break; + case 5: /* state machine */ + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = mtp3ObjState.link_l1_state+subpage*16; + break; + case 2: + disp_ptr = mtp3ObjState.link_l2_state+subpage*16; + break; + case 3: + disp_ptr = mtp3ObjState.link_l3_state+subpage*16; + break; + case 4: + disp_ptr = mtp3ObjState.lsac_state+subpage*16; + break; + case 5: + disp_ptr = mtp3ObjState.sltc_state+subpage*16; + break; + case 6: + disp_ptr = mtp3ObjState.tlac_state+subpage*16; + break; + case 7: + disp_ptr = mtp3ObjState.tsrc_state+subpage*16; + break; + case 8: + disp_ptr = mtp3ObjState.tcoc_state+subpage*16; + break; + case 9: + disp_ptr = mtp3ObjState.tcbc_state+subpage*16; + break; + case 10: + disp_ptr = mtp3.nw[0].rtpc_state+subpage*16; + break; + case 11: + disp_ptr = mtp3.nw[1].rtpc_state+subpage*16; + break; + case 12: + disp_ptr = mtp3.nw[2].rtpc_state+subpage*16; + break; + case 13: + disp_ptr = mtp3.nw[3].rtpc_state+subpage*16; + break; + case 14: + disp_ptr = mtp3.nw[0].rtac_state+subpage*16; + break; + case 15: + disp_ptr = mtp3.nw[1].rtac_state+subpage*16; + break; + case 16: + disp_ptr = mtp3.nw[2].rtac_state+subpage*16; + break; + case 17: + disp_ptr = mtp3.nw[3].rtac_state+subpage*16; + break; + case 18: + disp_ptr = &mtp3ObjState.tprc_state; + disp_length = 1; + break; + default: + disp_length = 0; + break; + } + + break; + case 6:/* routine */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if ( line <17 ) + { + if (subpage < 4) + { + disp_ptr = mtp3.nw[subpage].routine+(line-1)*16; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + + case 7:/* ls sls & ls slc table */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if ( line <17 ) + { + if (subpage < 8) + { + disp_ptr = ls_sls + (line-1)*16 + subpage*256; + } + else if (subpage < 16) + { + disp_ptr = ls_slc + (line-1)*16 + (subpage-8)*256; + } + else if (subpage < 24) + { + disp_ptr = sls_to_link + (line-1)*16 + (subpage-16)*256; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + + case 8:/* E1 STATE */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 17) + { + if (subpage < 8) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage*16+line-1]; + disp_length = 9; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + case 9:/* ls influence dstination table */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 18) + { + if (subpage < 128) + { + if (line < 9) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage].influ_dstplace_intable_asNLS[(line-1)*16]; + disp_length = 16; + } + else if (line == 9) + { + disp_length = 0; + } + else + { + disp_ptr = (BYTE*)&mtp3.ls[subpage].influ_dstplace_intable_asALS[(line-10)*16]; + disp_length = 16; + } + } + else + disp_length = 0; + } + else if (line == 18) + disp_length = 0; + else if (line == 19) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage]; + disp_length = 9; + } + else + disp_length = 0; + break; + + case 10:/* isup watch dog */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 9) + { + disp_ptr = (BYTE*)&mtp3.nw[page].flow.isup_detail[(line-1)*16]; + disp_length = 16; + } + else + disp_length = 0; + break; + case 11:/* watch dog */ + if (line < 16) + { + disp_ptr = (BYTE*)&mtp3ObjState.MTP3WatchDog[line*16]; + disp_length = 16; + } + else + disp_length = 0; + break; + default: + disp_length = 0; + break; + } + return disp_length; +} + +void mtp_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + DWORD object_id[20];//for test + +/* object_id head */ + object_id[0] = 1; + object_id[1] = 3; + object_id[2] = 6; + object_id[3] = 1; + object_id[4] = 4; + object_id[5] = 1; + object_id[6] = 1373; + object_id[7] = 1; + object_id[8] = 1; + object_id[9] = 2; +/* object_id head */ + + object_id[10] = 3; + object_id[11] = 1; + + object_id[12] = 2; + object_id[13] = MTP3_DEBUG_ID + 2; + object_id[14] = 5 + page;//page + //object_id[3] = 2;//line + object_id[16] = 0;//instance + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = mtp_disp_line(page,disp_line); + object_id[15] = disp_line + 2;//line +// debug_set_response(17,object_id,&disp_length,10); + object_id[16] = 2;//data pointer + debug_set_response(17,object_id,disp_ptr,disp_length); + } +} + +int mtp_debug_set() +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + DWORD object_id[20];//for test + BYTE mtp3_ver[20] = MTP3_VERSION; + + sprintf(mtp3_ver,"R%dV%d_%03d",mtp3_ver[0],mtp3_ver[1],mtp3_ver[2]); + + mtpi_m(); + + ptr = data; + +/* object_id head */ + object_id[0] = 1; + object_id[1] = 3; + object_id[2] = 6; + object_id[3] = 1; + object_id[4] = 4; + object_id[5] = 1; + object_id[6] = 1373; + object_id[7] = 1; + object_id[8] = 1; + object_id[9] = 2; +/* object_id head */ + object_id[10] = 3; + object_id[11] = 1; + + object_id[12] = 2; + object_id[13] = MTP3_DEBUG_ID+2; + object_id[14] = 1; + object_id[15] = 0;//instance + + data[0] = 1;//active this module + + debug_set_response(16,object_id,data,1); + object_id[14] = 2; + debug_set_response(15,object_id,mtp3_ver,strlen(mtp3_ver));//module name + object_id[14] = 3; + debug_set_response(15,object_id,mtp_asciin_buf,80);//ascii in buf + object_id[14] = 4; + debug_set_response(15,object_id,mtp_asciout_buf,4096);//ascii out buf + + + object_id[15] = 1;//TITLE +// object_id[16] = 2;//instance + for (page = 1; page < 16; page ++) + { + switch (page) + { + case 1: + ptr = title1_p;/*measure*/ + break; + case 2: + ptr = title2_p; + break; + case 3: + ptr = title3_p;/* MIB1 */ + break; + case 4: + ptr = title4_p;/* MIB2 */ + break; + case 5://page 1 + ptr = title5_p; + break; + case 6: + ptr = title6_p; + break; + case 7: + ptr = title7_p; + break; + case 8: + ptr = title8_p; + break; + case 9: + ptr = title9_p; + break; + case 10: + ptr = title10_p; + break; + case 11: + ptr = title11_p; + break; + default: + continue; + } + object_id[14] = 5 + page; + debug_set_response(17,object_id,ptr,strlen(ptr)); + mtp_disp_page(page); + } + + return 1; +} + +int mtp_send_ascout(BYTE *out_str) +{ +#ifdef _WXC_TEST + if( strlen(out_str) < MTP_MAX_ASCIIOUT_LEN ) + printf("[MTP3]\n%s" ,out_str ); +#else + int out_len; + + out_len = strlen(out_str); + + if (out_len + strlen(mtp_asciout_buf) > MTP_MAX_ASCIIOUT_LEN - 2) + { + mtp3DebugFull = 1; + return 0; +// strcpy(mtp_asciout_buf,out_str); + } + else + strcat(mtp_asciout_buf,out_str); +#endif + return 1; +} + +void mtp3_type_command(BYTE *ascin_ptr,BYTE option) +{ + BYTE info_str[80]; + BYTE *tmp_ptr; + int link; + unsigned long one=1; + BYTE inputValue; + int lsx16; + int i; + + if (strstr(ascin_ptr,"link all") != NULL) + { + if (option == 0)/* off */ + { + debug_mask=debug_mask & (~(one< 0) + { + page = mtp_asciin_buf[0]; + if (( page < 11) && (page > 1)) + { + disp_page[page-1] = atoi(ascin_ptr); + mtp_disp_page(page-1); + } + if (strcmp(ascin_ptr,"C") == 0) + { + memset(&mtp3.nw[0].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[1].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[2].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[3].flow,0,sizeof(struct mtp3_flow)); + memset(mtp3ObjState.MTP3WatchDog,0,256); + } + else if (strstr(ascin_ptr,"list") != NULL) + { + if (strncmp(ascin_ptr,"list par.opc",12) == 0) + { + mtp3_show_parameter(0,0); + } + else if (strncmp(ascin_ptr,"list par.link",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(1,input); + } + else if (strncmp(ascin_ptr,"list par.ls",11) == 0) + { + input = atol(&ascin_ptr[11]); + mtp3_show_parameter(2,input); + } + else if (strncmp(ascin_ptr,"list par.ints",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(4,input); + } + else if (strncmp(ascin_ptr,"list par.int",12) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(3,input); + } + else if (strncmp(ascin_ptr,"list par.nats",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(6,input); + } + else if (strncmp(ascin_ptr,"list par.nat",12) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(5,input); + } + else if (strncmp(ascin_ptr,"list par.sg",11) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(7,input); + } + else if (strncmp(ascin_ptr,"list route.",11) == 0) + { + input = atol(&ascin_ptr[11]); + mtp3_show_routine_status(input); + } + else if (strncmp(ascin_ptr,"list rt.",8) == 0) + { + input = atol(&ascin_ptr[8]); + mtp3_show_routine_status_sorted(input); + } + else if (strstr(ascin_ptr,"list log status") != NULL) + { + mtp3_list_log_status(); + } + if (strncmp(ascin_ptr,"list link.",10) == 0) + { + input = atol(&ascin_ptr[10]); + mtp3_list_link(input); + } + } + else if (strstr(ascin_ptr,"log all") != NULL) + { + debug_mask = debug_mask | 0xfffffaff;//not concern mtp3 hb & primitive +// debug_mask = 0xffffffff; + memset(debug_link,MTP3_MSGLOG_ON,256); + mtp_send_ascout("all logs on\n\r"); + } + else if( strstr(ascin_ptr, "net cap start") !=NULL ) + { + mtp3_send_netcap = 1; + mtp_send_ascout("mtp3 send netcap start"); + } + else if( strstr(ascin_ptr, "net cap stop") !=NULL ) + { + mtp3_send_netcap = 0; + mtp_send_ascout("mtp3 send netcap end"); + } + else if (strstr(ascin_ptr,"log none") != NULL) + { + debug_mask = 0; + memset(debug_link,MTP3_MSGLOG_OFF,256); + mtp_send_ascout("all logs off\n\r"); + } + else if ((tmp_ptr=strstr(ascin_ptr,"log"))!=NULL) + { + if (strstr(ascin_ptr,"on") != NULL) + mtp3_type_command(tmp_ptr,1); + else if (strstr(ascin_ptr,"off") != NULL) + mtp3_type_command(tmp_ptr,0); + else + mtp_send_ascout("command error\n\r"); + } + + else if (strcmp(ascin_ptr,"current portion")==0) + { + sprintf(info_str,"current portion is %ld\n\r",mtp3_csta_p); + mtp_send_ascout(info_str); + } + + else if (strcmp(ascin_ptr,"restart")==0) + { + sprintf(info_str,"mtp3 restarting...\n\r"); + mtp_send_ascout(info_str); + reset_mtp3(); + } + + else if (strcmp(ascin_ptr,"reload parameters")==0) + { + sprintf(info_str,"reloading mtp3 parameters...\n\r"); + mtp_send_ascout(info_str); + mtp3_reload_data(); + } + + else if (strcmp(ascin_ptr,"save parameters")==0) + { + sprintf(info_str,"saving mtp3 parameters...\n\r"); + mtp_send_ascout(info_str); + mtp3_write_parameter(); + } + + else if ( (strstr(ascin_ptr,"HELP") != NULL) | + (strstr(ascin_ptr,"help") != NULL) ) + { + mtp3_help_page(); + } + else if (strstr(ascin_ptr,"Activate") != NULL) + { + MTP3_activate(mtp3_localip);//deactivate alternative mtp3 + } + else if (strstr(ascin_ptr,"Deactivate") != NULL) + { + MTP3_deactivate(mtp3_localip);//deactivate alternative mtp3 + } + + strcpy(mtp_asciin_buf,"\0"); + } +} + +int mtp_hex_to_ascii(BYTE *from_hex,WORD from_len, BYTE *to_asc) +{ + int i,j; + + if(from_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"mtp_hex_to_ascii, length longer than 300, len=%d!", from_len); + from_len = 300; + } + 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] = 0x20; + j++; + } + to_asc[j] = '\0'; + return 1; +} + +void mtp3_showbuf(int n,BYTE *msg,int len) +{ + char info_str[1024]; + unsigned long one=1; + + if (mtp3DebugFull == 1) + return; + + if (((one << n) & debug_mask) == 0) + return; + + mtp_hex_to_ascii(msg,len,info_str); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); +} + +void slt_message_decode(BYTE code,char *c) +{ + switch (code) + { + case SIGNAL_SLTM: + sprintf(c,"SLTM"); + break; + case SIGNAL_SLTA: + sprintf(c,"SLTA"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void snm_message_decode(BYTE code,char *c) +{ + switch (code) + { + case SIGNAL_TFA: + sprintf(c,"TFA"); + break; + case SIGNAL_TFP: + sprintf(c,"TFP"); + break; + case SIGNAL_TRA: + sprintf(c,"TRA"); + break; + case SIGNAL_RST: + sprintf(c,"RST"); + break; + case SIGNAL_COO: + sprintf(c,"COO"); + break; + case SIGNAL_COA: + sprintf(c,"COA"); + break; + case SIGNAL_CBD: + sprintf(c,"CBD"); + break; + case SIGNAL_CBA: + sprintf(c,"CBA"); + break; + case SIGNAL_ECO: + sprintf(c,"ECA"); + break; + case SIGNAL_ECA: + sprintf(c,"ECA"); + break; + case SIGNAL_LIN: + sprintf(c,"LIN"); + break; + case SIGNAL_LUN: + sprintf(c,"LUN"); + break; + case SIGNAL_LIA: + sprintf(c,"LIA"); + break; + case SIGNAL_LUA: + sprintf(c,"LUA"); + break; + case SIGNAL_LID: + sprintf(c,"LID"); + break; + case SIGNAL_LFU: + sprintf(c,"LFU"); + break; + case SIGNAL_LLT: + sprintf(c,"LLT"); + break; + case SIGNAL_LRT: + sprintf(c,"LRT"); + break; + default: + sprintf(c,"UNK"); + break; + + } +} + +void sccp_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_SCCP_CR: + sprintf(c,"CR"); + break; + case MTP3_SCCP_CC: + sprintf(c,"CC"); + break; + case MTP3_SCCP_CREF: + sprintf(c,"CREF"); + break; + case MTP3_SCCP_RLSD: + sprintf(c,"RLSD"); + break; + case MTP3_SCCP_RLC: + sprintf(c,"RLC"); + break; + case MTP3_SCCP_DT1: + sprintf(c,"DT1"); + break; + case MTP3_SCCP_DT2: + sprintf(c,"DT2"); + break; + case MTP3_SCCP_AK: + sprintf(c,"AK"); + break; + case MTP3_SCCP_UDT: + sprintf(c,"UDT"); + break; + case MTP3_SCCP_UDTS: + sprintf(c,"UDTS"); + break; + case MTP3_SCCP_ED: + sprintf(c,"ED"); + break; + case MTP3_SCCP_EA: + sprintf(c,"EA"); + break; + case MTP3_SCCP_RSR: + sprintf(c,"RSR"); + break; + case MTP3_SCCP_RSC: + sprintf(c,"RSC"); + break; + case MTP3_SCCP_ERR: + sprintf(c,"ERR"); + break; + case MTP3_SCCP_IT: + sprintf(c,"IT"); + break; + case MTP3_SCCP_XUDT: + sprintf(c,"XUDT"); + break; + case MTP3_SCCP_XUDTS: + sprintf(c,"XUDTS"); + break; + case MTP3_SCCP_LUDT: + sprintf(c,"LUDT"); + break; + case MTP3_SCCP_LUDTS: + sprintf(c,"LUDTS"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void tup_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_TUP_IAM: + sprintf(c,"IAM"); + break; + case MTP3_TUP_IAI: + sprintf(c,"IAI"); + break; + case MTP3_TUP_SAM: + sprintf(c,"SAM"); + break; + case MTP3_TUP_SAO: + sprintf(c,"SAO"); + break; + case MTP3_TUP_GSM: + sprintf(c,"GSM"); + break; + case MTP3_TUP_COT: + sprintf(c,"COT"); + break; + case MTP3_TUP_GRQ: + sprintf(c,"GRQ"); + break; + case MTP3_TUP_ACM: + sprintf(c,"ACM"); + break; + case MTP3_TUP_SEC: + sprintf(c,"SEC"); + break; + case MTP3_TUP_CGC: + sprintf(c,"CGC"); + break; + case MTP3_TUP_CFL: + sprintf(c,"CFL"); + break; + case MTP3_TUP_SSB: + sprintf(c,"SSB"); + break; + case MTP3_TUP_UNN: + sprintf(c,"UNN"); + break; + case MTP3_TUP_LOS: + sprintf(c,"LOS"); + break; + case MTP3_TUP_SST: + sprintf(c,"SST"); + break; + case MTP3_TUP_ACB: + sprintf(c,"ACB"); + break; + case MTP3_TUP_DPN: + sprintf(c,"DPN"); + break; + case MTP3_TUP_ANU: + sprintf(c,"ANU"); + break; + case MTP3_TUP_ANC: + sprintf(c,"ANC"); + break; + case MTP3_TUP_ANN: + sprintf(c,"ANN"); + break; + case MTP3_TUP_CBK: + sprintf(c,"CBK"); + break; + case MTP3_TUP_CLF: + sprintf(c,"CLF"); + break; + case MTP3_TUP_CCL: + sprintf(c,"CCL"); + break; + case MTP3_TUP_RLG: + sprintf(c,"RLG"); + break; + case MTP3_TUP_BLO: + sprintf(c,"BLO"); + break; + case MTP3_TUP_BLA: + sprintf(c,"BLA"); + break; + case MTP3_TUP_UBL: + sprintf(c,"UBL"); + break; + case MTP3_TUP_UBA: + sprintf(c,"UBA"); + break; + case MTP3_TUP_ADI: + sprintf(c,"ADI"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void isup_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_ISUP_IAM: + sprintf(c,"IAM"); + break; + case MTP3_ISUP_ACM: + sprintf(c,"ACM"); + break; + case MTP3_ISUP_CPG: + sprintf(c,"CPG"); + break; + case MTP3_ISUP_ANM: + sprintf(c,"ANM"); + break; + case MTP3_ISUP_REL: + sprintf(c,"REL"); + break; + case MTP3_ISUP_RLC: + sprintf(c,"RLC"); + break; + case MTP3_ISUP_UBL: + sprintf(c,"UBL"); + break; + case MTP3_ISUP_UBA: + sprintf(c,"UBA"); + break; + case MTP3_ISUP_GRA: + sprintf(c,"GRA"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +BOOL iptrans_msg_flow(BYTE *msg,BYTE pclen,int direction,DWORD dest_ip) +{ + char info_str[1024]; + long dpc=0; + long opc=0; + BYTE sls; + char tempbuf[1024]; + long route_mark; + BYTE sio; + struct timeval tv; + struct timezone tz; + struct tm *t; + BYTE ssf; + unsigned long one=1; + struct in_addr in; + BOOL msg2mtp2; + char type[10]; + BYTE nw; + char netID[10]; + char codeName[16]; + int msg_len; + + if (mtp3DebugFull == 1) + return 0; + + in.s_addr = dest_ip; + +/* if (((dest_ip & E1CARD_BASE_IP_MASK) == E1CARD_BASE_IP) && + (((dest_ip >> 16) & 0xff) < 32))*/ + if (msg[0] < 255) + { + msg2mtp2 = TRUE; + } + else + msg2mtp2 = FALSE; + + sio = msg[3]; + nw = (sio >> 6) & 3; + + switch (nw) + { + case 0: + sprintf(netID,"INAT"); + break; + case 1: + sprintf(netID,"INATs"); + break; + case 2: + sprintf(netID,"NAT"); + break; + case 3: + sprintf(netID,"NATs"); + break; + } + + if (pclen == MTP3_24BIT_PC) + { + memcpy((BYTE *)&dpc,&msg[4],3); + memcpy((BYTE *)&opc,&msg[7],3); + sls = msg[10] & 0x0f; + } + else + { + memcpy((BYTE*)&route_mark,&msg[4],4); + dpc = route_mark & 0x3FFF; + opc = (route_mark & 0x0FFFFFFF) >> 14; + sls = (route_mark >> 28) & 0x0f; + } + + if (debug_link[msg[0]] != MTP3_MSGLOG_ON) + { + if (msg2mtp2 == TRUE) + return 0; + } + + { + msg_len = (msg[1]<<8) + msg[2]; + if(msg_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in iptrans_msg_flow, length longer than 300!"); + msg[1]=0; + } + + } + ssf= sio & 0x0f; + switch (ssf) + { + case TUP_SIO: + if (((one << MTP3DB_TUPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"TUP"); + if (pclen == MTP3_24BIT_PC) + tup_message_decode(msg[12],codeName); + else + tup_message_decode(msg[9],codeName); + break; + case ISUP_SIO: + if (((one << MTP3DB_ISUPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"ISUP"); + if (pclen == MTP3_24BIT_PC) + isup_message_decode(msg[13],codeName); + else + isup_message_decode(msg[10],codeName); + break; + case BICC_SIO: + if (((one << MTP3DB_BICCMSG) & debug_mask) == 0) + return 0; + sprintf(type,"BICC"); + if (pclen == MTP3_24BIT_PC) + isup_message_decode(msg[13],codeName); + else + isup_message_decode(msg[10],codeName); + break; + case SCCP_SIO: + if (((one << MTP3DB_SCCPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SCCP"); + if (pclen == MTP3_24BIT_PC) + sccp_message_decode(msg[11],codeName); + else + sccp_message_decode(msg[8],codeName); + break; + case SNM_SIO: + if (((one << MTP3DB_SNMMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SNM"); + if (pclen == MTP3_24BIT_PC) + snm_message_decode(msg[11],codeName); + else + snm_message_decode(msg[8],codeName); + break; + case TM_SIO: + if (((one << MTP3DB_SNMMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SLT"); + if (pclen == MTP3_24BIT_PC) + slt_message_decode(msg[11],codeName); + else + slt_message_decode(msg[8],codeName); + break; + default: + return 0; + } + + gettimeofday(&tv,&tz); + t = localtime(&tv.tv_sec); + switch (direction) + { + case MTP_MSG_UP: + if (msg2mtp2 == TRUE) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==MTP2,%dB %s SPC(%lx->%lx) SLS=%x LI=%x srcLINK=%03d srcIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + else + { + if (((one << MTP3DB_APP_APP_MSG) & debug_mask) != 0) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==MTP3,%dB %s SPC(%lx->%lx) SLS=%x LI=%x srcIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],inet_ntoa(in)); + else + return 0; + } + mtp_hex_to_ascii(msg, (msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); + return 1; + break; + case MTP_MSG_DOWN: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==USER,%s DPC=%lx SLS=%x\n\rPerform routing:MTP3==>MTP2,%dB SPC(%lx->%lx) LI=%02x dstLINK=%03d dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + break; + case MTP_MSG_STP: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld)Perform STP:MTP3==>MTP2,SPC(%lx->%lx) dstLINK=%x dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,opc,dpc,msg[0],inet_ntoa(in)); + break; + case MTP_MSG_OTHER_SERVER: + if (msg2mtp2 == TRUE) + sprintf(info_str,"%s%s(%02d:%02d:%02d.%06ld):MTP3<==USER, %s DPC=%lx SLS=%x\n\rRouting by UP:MTP3==>MTP2,%dB SPC(%lx->%lx) LI=%02x dstLINK=%03d dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + else + { + if (((one << MTP3DB_APP_APP_MSG) & debug_mask) != 0) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==USER, %s DPC=%lx SLS=%x\n\rRouting by UP:MTP3==>MTP3,%dB SPC(%lx->%lx) LI=%02x dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],inet_ntoa(in)); + else + return 0; + } + break; + case MTP_SNM_MSG: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3==>MTP2,%dB %s SPC(%lx->%lx) SLS=%d LI=%02x dstLINK=%03d dstIP=%s\r\n", +type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + mtp_hex_to_ascii(msg,(msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); + return 1; + break; + } + mtp_hex_to_ascii(msg,(msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r\n\r"); + mtp_send_ascout(info_str); + return 1; +} + +BOOL iptrans_msg_flow_2(up_message *up_msg_ptr) +{ + char info_str[1024]; + char tempbuf[1024]; + BYTE sio; + struct timeval tv; + struct timezone tz; + struct tm *t; + unsigned long one=1; + char type[10]; + BYTE nw; + char netID[10]; + char codeName[16]; + + if (mtp3DebugFull == 1) + return 0; + + if(up_msg_ptr->len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in iptrans_msg_flow_2, length longer than 300!"); + up_msg_ptr->len = 300; + } + sio = up_msg_ptr->sio; + nw = (sio >> 6) & 3; + + switch (nw) + { + case 0: + sprintf(netID,"INAT"); + break; + case 1: + sprintf(netID,"INATs"); + break; + case 2: + sprintf(netID,"NAT"); + break; + case 3: + sprintf(netID,"NATs"); + break; + } + + if (((one << MTP3DB_SCCPMSG) & debug_mask) == 0) + return 0; + + sprintf(type,"SCCP"); + sccp_message_decode(up_msg_ptr->msgList[0],codeName); + + gettimeofday(&tv,&tz); + t = localtime(&tv.tv_sec); + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3LITE==>USER,%s LI=%x srcLINK=%03d\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,up_msg_ptr->len,up_msg_ptr->link); + mtp_hex_to_ascii(&up_msg_ptr->msgList[0], up_msg_ptr->len, tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r\n\r"); + mtp_send_ascout(info_str); + + return 1; +} + +void mtp3_debug(int n,const char *fmt,...) +{ + char info_str[1024]; + char tempbuf[1024]; + va_list ap; + unsigned long one=1; + struct timeval tv; + struct timezone tz; + struct tm *t; + + if (mtp3DebugFull == 1) + return; + + if(((one<tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_SCCPMSG: + sprintf(tempbuf,"\33[36mSCCP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_ISUPMSG: + sprintf(tempbuf,"\33[36mISUP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_TUPMSG: + sprintf(tempbuf,"\33[36mTUP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_ERROR: + sprintf(tempbuf,"\33[31m(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_PFHB: + sprintf(tempbuf,"(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_PRIMITIVE_MSG: + sprintf(tempbuf,"(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_CMD: + sprintf(tempbuf,"\33[1;33m(%d:%d:%d)",t->tm_hour,t->tm_min,t->tm_sec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + default: + break; + } +} + +void mtp3_list_log_status() +{ + int i; + BYTE info_str[80]; + + mtp_send_ascout("\33[32mmtp3 log status-->\33[0m\n\r"); + if ((debug_mask & 2) != 0) + mtp_send_ascout("log snm \33[33mON\33[0m\n\r"); + if ((debug_mask & 4) != 0) + mtp_send_ascout("log sccp \33[33mON\33[0m\n\r"); + if ((debug_mask & 8) != 0) + mtp_send_ascout("log tup \33[33mON\33[0m\n\r"); + if ((debug_mask & 16) != 0) + mtp_send_ascout("log isup \33[33mON\33[0m\n\r"); + if ((debug_mask & 32) != 0) + mtp_send_ascout("log error \33[33mON\33[0m\n\r"); + if ((debug_mask & 64) != 0) + mtp_send_ascout("log event \33[33mON\33[0m\n\r"); + if ((debug_mask & 256) != 0) + mtp_send_ascout("log mtp3hb \33[33mON\33[0m\n\r"); + if ((debug_mask & 512) != 0) + mtp_send_ascout("log internal \33[33mON\33[0m\n\r"); + if ((debug_mask & 1024) != 0) + mtp_send_ascout("log primitive \33[33mON\33[0m\n\r"); + if ((debug_mask & 128) != 0) + { + mtp_send_ascout("log all link \33[33mON\33[0m\n\r"); + return; + } + for (i=0;i<256;i++) + { + if (debug_link[i] == MTP3_MSGLOG_ON) + { + sprintf(info_str,"log link=%d \33[33mON\33[0m\n\r",i); + mtp_send_ascout(info_str); + } + } +} + +void mtp3_show_routine_status(BYTE nw) +{ + int i; + char info_str[4096]; + char tempbuf[4096]; + nw_para *para; + network *sp; + BYTE current_rt; + BYTE nls; + BYTE als; + static BYTE last_show[4]={0}; + BYTE showCount=0; + + nw = nw & 3; + + para = &mtp3_para->nw[nw]; + sp = &mtp3.nw[nw]; + switch (nw) + { + case 0: + sprintf(info_str,"\33[33mInternational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 1: + sprintf(info_str,"\33[33mInternational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 2: + sprintf(info_str,"\33[33mNational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 3: + sprintf(info_str,"\33[33mNational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + default: + break; + } + mtp_send_ascout(info_str); + showCount=0; + for (i=last_show[nw];i<256;i++) + { + nls = para->normal_ls[i]; + als = para->alternative_ls[i]; + if ((para->dpc[i] != 0) && + (nls < 128) ) + { + current_rt = (sp->routine[i] >> 6) & 3; + switch (current_rt) + { + case 0: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[i],nls,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[i],nls,nls); + mtp_send_ascout(tempbuf); + break; + case 1: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[i],als,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[i],als,nls); + mtp_send_ascout(tempbuf); + break; + case 2: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t%02d\n\r",para->dpc[i],nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t--\n\r",para->dpc[i],nls); + mtp_send_ascout(tempbuf); + break; + default: + break; + } + showCount++; + } + if (showCount > 31) + { + last_show[nw] = i+1; + break; + } + } + if (i>=255) + { + last_show[nw] = 0; + } + +} + +void mtp3_show_routine_status_sorted(BYTE nw) +{ + int i; + char info_str[4096]; + char tempbuf[4096]; + nw_para *para; + network *sp; + mtp3DPCIndex *sort_rec; + BYTE current_rt; + BYTE nls; + BYTE als; + static BYTE last_show[4]={0}; + BYTE showCount=0; + int index; + + nw = nw & 3; + + para = &mtp3_para->nw[nw]; + sp = &mtp3.nw[nw]; + sort_rec = &mtp3SortRoutine.nw[nw]; + switch (nw) + { + case 0: + sprintf(info_str,"\33[33mInternational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 1: + sprintf(info_str,"\33[33mInternational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 2: + sprintf(info_str,"\33[33mNational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 3: + sprintf(info_str,"\33[33mNational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + default: + break; + } + mtp_send_ascout(info_str); + showCount=0; + for (i=last_show[nw];isortedNum;i++) + { + index = sort_rec->index[i]; + nls = para->normal_ls[index]; + als = para->alternative_ls[index]; + if ((para->dpc[index] != 0) && + (nls < 128) ) + { + current_rt = (sp->routine[index] >> 6) & 3; + switch (current_rt) + { + case 0: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[index],nls,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[index],nls,nls); + mtp_send_ascout(tempbuf); + break; + case 1: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[index],als,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[index],als,nls); + mtp_send_ascout(tempbuf); + break; + case 2: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t%02d\n\r",para->dpc[index],nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t--\n\r",para->dpc[index],nls); + mtp_send_ascout(tempbuf); + break; + default: + break; + } + showCount++; + } + if (showCount > 31) + { + last_show[nw] = i+1; + break; + } + } + if (i>=sort_rec->sortedNum-1) + { + last_show[nw] = 0; + } +} + +int pc_length(BYTE nw); +int mtp3_show_parameter(BYTE option,BYTE index) +{ + int i; + char info_str[4096]; + int maxindex; + char nw[20]; + + switch (option) + { + case 0: + mtp_send_ascout("Network\t\t\tSPC Len\t\tOPC\n\r"); + if (pc_length(0) == MTP3_24BIT_PC) + sprintf(info_str,"International\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[0].opc24); + else + sprintf(info_str,"International\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[0].opc14); + mtp_send_ascout(info_str); + if (pc_length(1) == MTP3_24BIT_PC) + sprintf(info_str,"International(s)\t24BIT\t\t%06lx\n\r",mtp3_para->nw[1].opc24); + else + sprintf(info_str,"International(s)\t14BIT\t\t%06lx\n\r",mtp3_para->nw[1].opc14); + mtp_send_ascout(info_str); + if (pc_length(2) == MTP3_24BIT_PC) + sprintf(info_str,"National\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[2].opc24); + else + sprintf(info_str,"National\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[2].opc14); + mtp_send_ascout(info_str); + if (pc_length(3) == MTP3_24BIT_PC) + sprintf(info_str,"National(s)\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[3].opc24); + else + sprintf(info_str,"National(s)\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[3].opc14); + mtp_send_ascout(info_str); + sprintf(info_str, "International Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[0], mtp3_opc.opc[0][0], mtp3_opc.opc[0][1], mtp3_opc.opc[0][2], + mtp3_opc.opc[0][3], mtp3_opc.opc[0][4], mtp3_opc.opc[0][5], mtp3_opc.opc[0][6], mtp3_opc.opc[0][7], + mtp3_opc.opc[0][8], mtp3_opc.opc[0][9], mtp3_opc.opc[0][10], mtp3_opc.opc[0][11], mtp3_opc.opc[0][12], + mtp3_opc.opc[0][13], mtp3_opc.opc[0][14], mtp3_opc.opc[0][15]); + mtp_send_ascout(info_str); + sprintf(info_str, "International(s) Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[1], mtp3_opc.opc[1][0], mtp3_opc.opc[1][1], mtp3_opc.opc[1][2], + mtp3_opc.opc[1][3], mtp3_opc.opc[1][4], mtp3_opc.opc[1][5], mtp3_opc.opc[1][6], mtp3_opc.opc[1][7], + mtp3_opc.opc[1][8], mtp3_opc.opc[1][9], mtp3_opc.opc[1][10], mtp3_opc.opc[1][11], mtp3_opc.opc[1][12], + mtp3_opc.opc[1][13], mtp3_opc.opc[1][14], mtp3_opc.opc[1][15]); + mtp_send_ascout(info_str); + sprintf(info_str, "National Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[2], mtp3_opc.opc[2][0], mtp3_opc.opc[2][1], mtp3_opc.opc[2][2], + mtp3_opc.opc[2][3], mtp3_opc.opc[2][4], mtp3_opc.opc[2][5], mtp3_opc.opc[2][6], mtp3_opc.opc[2][7], + mtp3_opc.opc[2][8], mtp3_opc.opc[2][9], mtp3_opc.opc[2][10], mtp3_opc.opc[2][11], mtp3_opc.opc[2][12], + mtp3_opc.opc[2][13], mtp3_opc.opc[2][14], mtp3_opc.opc[2][15]); + mtp_send_ascout(info_str); + sprintf(info_str, "National(s) Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[3], mtp3_opc.opc[3][0], mtp3_opc.opc[3][1], mtp3_opc.opc[3][2], + mtp3_opc.opc[3][3], mtp3_opc.opc[3][4], mtp3_opc.opc[3][5], mtp3_opc.opc[3][6], mtp3_opc.opc[3][7], + mtp3_opc.opc[3][8], mtp3_opc.opc[3][9], mtp3_opc.opc[3][10], mtp3_opc.opc[3][11], mtp3_opc.opc[3][12], + mtp3_opc.opc[3][13], mtp3_opc.opc[3][14], mtp3_opc.opc[3][15]); + mtp_send_ascout(info_str); + break; + case 1: + sprintf(info_str," \33[32mLink Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLink\tLinkset\tSLC\tNormalMTP3\tAlterMTP3\tType\tSG\tCfg\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; ilk[i].e1_to_linkset,mtp3_para->lk[i].e1_to_slc, + mtp3_para->lk[i].e1_to_mtp3,mtp3_para->lk[i].e1_to_alterMTP3,mtp3_para->lk[i].e1_lk_type,mtp3_para->lk[i].e1_to_sg,mtp3ObjState.lk_configured[i]); + mtp_send_ascout(info_str); + } + break; + case 2: + sprintf(info_str," \33[32mLinkset Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLinkset\tRemote_SPC\tNetwork\t\tLoopBack\n\r\33[0m"); + mtp_send_ascout(info_str); + index = index % 128; + if (index > 96) + maxindex = 128; + else + maxindex = index+32; + for (i=index; ils_pro[i] & 3) + { + case 0: + sprintf(nw,"INT"); + break; + case 1: + sprintf(nw,"INT(s)"); + break; + case 2: + sprintf(nw,"NAT"); + break; + case 3: + sprintf(nw,"NAT(s)"); + break; + } + if ((mtp3_para->ls_pro[i] & 8) == 0) + sprintf(info_str,"%03d\t%06lx\t\t%s\t\tN\n\r",i,mtp3_para->ls_op_pc[i],nw); + else + sprintf(info_str,"%03d\t%06lx\t\t%s\t\tY\n\r",i,mtp3_para->ls_op_pc[i],nw); + mtp_send_ascout(info_str); + } + break; + case 3:// international routine */ + sprintf(info_str," \33[32mInternational Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[0].dpc[i],mtp3_para->nw[0].normal_ls[i],mtp3_para->nw[0].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 4:// international(s) routine + sprintf(info_str," \33[32mInternational(S) Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[1].dpc[i],mtp3_para->nw[1].normal_ls[i],mtp3_para->nw[1].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 5:// national routine + sprintf(info_str," \33[32mNational Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[2].dpc[i],mtp3_para->nw[2].normal_ls[i],mtp3_para->nw[2].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 6:// national(s) routine + sprintf(info_str," \33[32mNational(S) Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[3].dpc[i],mtp3_para->nw[3].normal_ls[i],mtp3_para->nw[3].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 7:// SG Attribute + sprintf(info_str," \33[32mSG Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32mSG Enable\tServer\tACK\tRemoteIP\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; isg[i].enable,mtp3_para->sg[i].server, + mtp3_para->sg[i].data_ack,mtp3_para->sg[i].ip); + mtp_send_ascout(info_str); + } + break; + } + + return 1; +} + + +void mtp3_list_link(BYTE i) +{ + char info_str[4096]; + + sprintf(info_str," \33[32mLink Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLink\tE1_MTP3\t\tNMTP3\tAMTP3\n\r\33[0m"); + mtp_send_ascout(info_str); + + sprintf(info_str,"%03d\t%08lx\t%02x\t%02x\n\r",i, + mtp3ObjState.lk_mtp3[i],mtp3ObjState.lk_NMTP3_ok[i],mtp3ObjState.lk_AMTP3_ok[i]); + mtp_send_ascout(info_str); +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpmib.c b/omc/plat/mtp3/src/mtpmib.c new file mode 100644 index 0000000..bfee013 --- /dev/null +++ b/omc/plat/mtp3/src/mtpmib.c @@ -0,0 +1,2598 @@ +#include "../../public/src/include/pub_include.h" +#include "../../snmp/src/include/snmp.h" +#include "../../snmp/src/include/heartbeat.h" +#include "./include/mtp3.h" + +#ifdef _INCLUDE_M2UA + #include "../../m2ua/src/include/m2ua.h" +#endif +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +char mtpconfile[] = {"./conf/mtp3.conf"}; +FILE *mtpfpConf; +char MTP_OBJECT_LKA[20]={"[LINK ATTRIBUTE]\n"}; +char MTP_OBJECT_NSP[80]={"[NATIONAL NETWORK SP]\n"}; +char MTP_OBJECT_NSSP[80]={"[NATIONAL NETWORK SPARE SP]\n"}; +char MTP_OBJECT_ISP[80]={"[INTERNATIONAL NETWORK SP]\n"}; +char MTP_OBJECT_ISSP[80]={"[INTERNATIONAL NETWORK SPARE SP]\n"}; +char MTP_OBJECT_LSA[40]={"[LINKSET ATTRIBUTE]\n"}; +char MTP_OBJECT_LSP[20]={"[LOCAL SP]\n"}; +char MTP_OBJECT_SNL[40]={"[SERVICE NETWORK SP LEN]\n"}; +char MTP_OBJECT_SG[40]={"[SG ATTRIBUTES]\n"}; +char MTP_OBJECT_MTP3LITE_PORT[40]={"[MTP3LITE TCP PORT]"}; + +long atol(const char *nptr); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void hmrt_tcbc_update_routing_tables(BYTE chl); +void update_timer(int link); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_alternative_linkset_unavailable(BYTE *routine); +void mark_alternative_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void otherMTP3_managed_link_unavailable(BYTE chl); +void mtp3_reload_data(); +int MTP3_LinkIP_List(DWORD IP,BYTE mode); +void deactive_mtp3lite_lk(BYTE link); + +//extern from sccp/sccpfun.c +extern ull Bcd2Ull(BYTE *pBcd, int BcdLen); +extern int ParseLine(char *str, char (*row)[128], int maxrow); +extern int Str2Bcd(BYTE *pBcd, char *pStr, int maxLen); +extern void deactive_m3ua_lk(BYTE link); + +static u32 mtp3_primomcip=0; // primary omc ip address +static u32 mtp3_secdomcip=0; // secondary omc ip address + +static u32 mtp2_object_id[] = {1,3,6,1,4,1,1373,1,3,1,1,3}; +#define MTP2_PREOID_LEN 12 +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm) +{ + snmp_pdu snmp_buf; + snmp_addr snmp_addr; + time_t cur_time; + u8 *buf; + + snmp_addr.remote_port = 4957; + snmp_addr.local_port = 4957; + snmp_addr.broadcast = 0; + snmp_buf.pdu_type = 7; + snmp_buf.var_num = 1; + memcpy(snmp_buf.var[0].oid, mtp2_object_id, MTP2_PREOID_LEN*4); + snmp_buf.var[0].oid[MTP2_PREOID_LEN] = 4; + snmp_buf.var[0].oidlen = MTP2_PREOID_LEN + 1; + snmp_buf.var[0].vartype = 4; + buf = snmp_buf.var[0].msg; + buf[0] = mtp2_module; // system id + buf[1] = mtp2_systemid; + cur_time = time(NULL); + buf[2] = cur_time >> 24; // time stamp + buf[3] = cur_time >> 16; + buf[4] = cur_time >> 8; + buf[5] = cur_time; + // byte 6--13 16 LED status (green continuous: 0x09, yellow continuous: 0x0a) + buf[6] = 0x99; + if (alarm != 0) + buf[7] = 0xaf; + else + buf[7] = 0x9f; + memset(buf+8, 0xff, 6); + + buf[14] = component>>8; // first byte of component id + buf[15] = component&255; // second byte of component id + buf[16] = alarm; // alarm level + + buf[17] = 0; + buf[18] = 0;//length 1 + + buf[19] = 0;//component id + buf[20] = 0;//component id + + buf[21] = 0; + buf[22] = 20;//length 2 + +// memcpy(buf+30, hlr_vm_ptr->sys_param.hlr_seqnum, HLR_SEQNUM_LEN); +// snmp_buf.var[0].msglen = 37 + HLR_SEQNUM_LEN; + snmp_buf.var[0].msglen = 23; + +// snmp_addr.remote_ip = 0x81ea12ac; + + if (mtp3_primomcip != 0) + { + snmp_addr.remote_ip = mtp3_primomcip; + snmp_send(&snmp_buf, &snmp_addr); + } + + if (mtp3_secdomcip != 0) + { + snmp_addr.remote_ip = mtp3_secdomcip; + snmp_send(&snmp_buf, &snmp_addr); + } +} + +int Mtp3BinSearchIndex(BYTE low, BYTE high,ull key, BYTE nw) +{ + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + static int mid; + static long long midvalue; + + if(low>high) + { +// LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); + return low; + } + + if(high == low+1 ) + { + if(key<=sort_rec->dpc[low]) + return low; + else if(key<=sort_rec->dpc[high]) + return high; + else + return high+1; + } + + if(low == high) + { + if(key<=sort_rec->dpc[low]) + return low; + else + return low+1; + } + + mid = (low + high)/2; + midvalue = sort_rec->dpc[mid]; + + if(key == midvalue) + { + return mid; + } + else if(keyhigh) + { +// LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); + return -1; + } + + if (sort_rec->sortedNum <= 0) + return -1; + + if (high > sort_rec->sortedNum-1) + high = sort_rec->sortedNum-1; + + if(high == low+1 ) + { + if(key==sort_rec->dpc[low]) + return low; + else if(key==sort_rec->dpc[high]) + return high; + else + return -1; + } + + if(low == high) + { + if(key==sort_rec->dpc[low]) + return low; + else + return -1; + } + + mid = (low + high)/2; + midvalue = sort_rec->dpc[mid]; + + if(key == midvalue) + { + return mid; + } + else if(keysortedNum > 256 - 1) + { + mtp3SortRoutine.nw[nw].sortedNum = 256 - 1; + return 0; + } + + if(opc == mtp3_para->nw[nw].opc14 && (pc_length(nw)==MTP3_14BIT_PC)) + opc = 0; + else if(opc == mtp3_para->nw[nw].opc24 && (pc_length(nw)==MTP3_24BIT_PC)) + opc = 0; + opc_dpc = opc; + opc_dpc = (opc_dpc<<32)|dpc; + if(sort_rec->sortedNum == 0) + { + index1 = 0; + sort_rec->dpc[index1] = opc_dpc; + sort_rec->sortedNum = 1; + sort_rec->index[index1] = real_index; + return 1; + } + else + { + index1 = Mtp3BinSearchValue(0,255,nw,opc_dpc); + if (index1>=0 && index1 < sort_rec->sortedNum)//already has this record + return 0; + + + while(sort_rec->dpc[0] > sort_rec->dpc[sort_rec->sortedNum - 1]) + sort_rec->sortedNum = (sort_rec->sortedNum - 1) % 256; + //LogErr("--AddSortRec,start BinSearchIndex key=%lld",key); + index1 = Mtp3BinSearchIndex(0,sort_rec->sortedNum-1,opc_dpc,nw); + if (index1 >= sort_rec->sortedNum) + { + if (sort_rec->sortedNum >= 256-1) + { + return 0; + } + sort_rec->dpc[sort_rec->sortedNum] = opc_dpc; + sort_rec->index[sort_rec->sortedNum] = real_index; + sort_rec->sortedNum ++; + } + +// LogErr("---AddSortRec: index1=%d,store_i=%d,old_key=%lld",index1,index,sort_rec[index1].key); + } + + if (sort_rec->dpc[index1] != opc_dpc) + {// insert a item + int moveNum = (sort_rec->sortedNum-index1) % 256; + + if (sort_rec->sortedNum >= 256) + { + return 0; + } + memmove(&sort_rec->dpc[index1+1],&sort_rec->dpc[index1],moveNum*sizeof(ull)); + memmove(&sort_rec->index[index1+1],&sort_rec->index[index1],moveNum*sizeof(DWORD)); + sort_rec->dpc[index1]=opc_dpc; + sort_rec->index[index1]=real_index; + sort_rec->sortedNum ++; + return 1; + } + + //LogErr("--rearrange:%lld,%lld,%lld",sort_rec[index1-1].key,key,sort_rec[index1+1].key); + + return 1; +} + +int Mtp3DeleteRecord(ull key,BYTE nw) //VLR_RECORD vlr_record) +{ + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; +// long long imsi=key; + DWORD MoveNum; + int index=-1; + + if (sort_rec->sortedNum == 0) + { + return 0; + } + + index = Mtp3BinSearchValue(0,255,nw,key); + +// index = BinSearchIndex(1,vlr_record_number,key); + if(index<0 || index>=sort_rec->sortedNum) + { +// LogMsg("VLR--ERROR!Delete Record index=%ld",index); + return 0; + } + + MoveNum = (sort_rec->sortedNum-index) % 256; + memmove(&sort_rec->dpc[index],&sort_rec->dpc[index+1],MoveNum*sizeof(ull)); + memmove(&sort_rec->index[index],&sort_rec->index[index+1],MoveNum*sizeof(DWORD)); + + // LogErr("----After del %lld,%lld,%lld",sort_rec[index-1].key,sort_rec[index].key,sort_rec[index+1].key); + + sort_rec->dpc[sort_rec->sortedNum]=0; + sort_rec->index[sort_rec->sortedNum]=0; + + sort_rec->sortedNum--; + + return 1; +} + + +BYTE mtp_encode_integer(BYTE *buf,DWORD val,BYTE value_len) +{ + if(val<128) + { + if (value_len == 4) + { + buf[0] = 0; + buf[1] = 0; + buf[2]=val; + return 3; + } + else + { + buf[0] = val; + return 1; + } + } + else if(val<0x8000) + { + if (value_len == 4) + { + buf[0] = 0; + buf[1]=val >>8; + buf[2]=val & 0xFF; + return 3; + } + else + { + buf[0]=val; + return 1; + } + } + else if(val <0x800000) + { + buf[0]=val >>16; + buf[1]=(val & 0xFF00)>>8; + buf[2]=val & 0xFF; + return 3; + } +// else if(val <0x80000000) + else + { + buf[0]=(val & 0xFF0000)>>16; + buf[1]=(val & 0xFF00)>>8; + buf[2]=val & 0xFF; + return 3; + } +} + +int mtp3_reset_sccp() +{ + DWORD oid[20] = {1,3,6,1,4,1,1373,2,3,2,3,3,2};//SCCP_OID + BYTE value=0; + return set_response(13,oid,&value,1); +} + +void del_1dst_from_table(ls_info *ls, BYTE dpc_place, BYTE ud_select) +{ + BYTE dst_num; + int i; + + switch (ud_select) + { + case UPDATE_NLS: + dst_num = ls->influ_dstnum_asNLS; + if (dst_num == 0) + return; + ls->influ_dstnum_asNLS --; + for (i=0; iinflu_dstplace_intable_asNLS[i] == dpc_place) + { + memcpy(&ls->influ_dstplace_intable_asNLS[i], + &ls->influ_dstplace_intable_asNLS[i+1],dst_num-i-1); + ls->influ_dstplace_intable_asNLS[dst_num-1] = 0; + return; + } + } + break; + case 1: + dst_num = ls->influ_dstnum_asALS; + if (dst_num == 0) + return; + ls->influ_dstnum_asALS --; + for (i=0; iinflu_dstplace_intable_asALS[i] == dpc_place) + { + memcpy(&ls->influ_dstplace_intable_asALS[i], + &ls->influ_dstplace_intable_asALS[i+1],dst_num-i-1); + ls->influ_dstplace_intable_asALS[dst_num-1] = 0; + return; + } + } + break; + } +} + +void add_1dst_to_table(ls_info *ls, BYTE place,BYTE ud_select) +{ + BYTE dst_num; + + switch (ud_select) + { + case UPDATE_NLS: + dst_num = ls->influ_dstnum_asNLS; + ls->influ_dstplace_intable_asNLS[dst_num] = place; + ls->influ_dstnum_asNLS = dst_num + 1; + break; + case UPDATE_ALS: + dst_num = ls->influ_dstnum_asALS; + ls->influ_dstplace_intable_asALS[dst_num] = place; + ls->influ_dstnum_asALS = dst_num + 1; + break; + } +} + +void scan_conf_right_or_not(BYTE nw) +{ + static BYTE index=0; + BYTE nls; + BYTE lsnw; + + return; + nls = mtp3_para->nw[nw].normal_ls[index]; + if (nls < 128) + { + lsnw = mtp3_para->ls_pro[nls] & 3; + if ((lsnw != nw) && (mtp3_para->nw[nw].dpc[index] != 0)) + printf("configure error,nw %d,dpc=%lx normal linkset belong to network %d\n",nw,mtp3_para->nw[nw].dpc[index],lsnw); + } + index ++; +} + +void mtp3lite_upd_route_status(BYTE chl, BYTE flag) +{ + ls_info *ls; + int i; + BYTE dpc_index, lsno, nw; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno >= 0x80) + return; + + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + + for (i = 0; i < ls->influ_dstnum_asNLS; i++) + { + dpc_index = ls->influ_dstplace_intable_asNLS[i]; + if (!flag) + mark_normal_linkset_unavailable(&mtp3.nw[nw].routine[dpc_index]); + else + mark_normal_linkset_available(&mtp3.nw[nw].routine[dpc_index]); + if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,nw); + } +} + +void change_the_whole_ls(BYTE lsno,BYTE oldnw,BYTE nw) +{ + ls_info *ls; + int i; + nw_para *nwpara; + BYTE *routine; + BYTE ls_available; + BYTE dpc_index; + int added=0; + ull opc_dpc=0; + + ls = &mtp3.ls[lsno]; + +// printf("oldnw = %d,newnw=%d\n",oldnw,nw); + + for (i=0;iinflu_dstnum_asNLS;i++) + { + dpc_index = ls->influ_dstplace_intable_asNLS[i]; + mark_normal_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); + if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,oldnw); + ls->influ_dstplace_intable_asNLS[i] = 0xff; + opc_dpc = mtp3_para->nw[oldnw].opc[dpc_index]; + opc_dpc = (opc_dpc<<32)| mtp3_para->nw[oldnw].dpc[dpc_index]; + Mtp3DeleteRecord(opc_dpc, oldnw); + } + for (i=0;iinflu_dstnum_asALS;i++) + { + dpc_index = ls->influ_dstplace_intable_asALS[i]; + mark_alternative_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); + if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,oldnw); + ls->influ_dstplace_intable_asALS[i] = 0xff; + opc_dpc = mtp3_para->nw[oldnw].opc[dpc_index]; + opc_dpc = (opc_dpc<<32) | mtp3_para->nw[oldnw].dpc[dpc_index]; + Mtp3DeleteRecord(opc_dpc,oldnw); + } + ls->influ_dstnum_asNLS = 0; + ls->influ_dstnum_asALS = 0; + + if (mtp3.ls[lsno].links_available_t > 0) + ls_available = TRUE; + else + ls_available = FALSE; + + nwpara = &mtp3_para->nw[nw]; + for (i=0;i<256;i++) + { + if (nwpara->dpc[i] == 0) + continue; + routine = &mtp3.nw[nw].routine[i]; + if (nwpara->normal_ls[i] == lsno) + { + if (ls_available == TRUE) + mark_normal_linkset_available(routine); + else + mark_normal_linkset_unavailable(routine); + add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_NLS); + Mtp3AddSortRec(nw,nwpara->dpc[i], i, nwpara->opc[i]);//??- + added = 1; + } + if ((nwpara->alternative_ls[i] == lsno) && + (nwpara->normal_ls[i] < 128) ) + { + if (ls_available == TRUE) + mark_alternative_linkset_available(routine); + else + mark_alternative_linkset_unavailable(routine); + add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_ALS); + + if (!added) + Mtp3AddSortRec(nw,nwpara->dpc[i], i, nwpara->opc[i]);//??- + } + hmrt_tfrc_update_routing_tables(i,nw); + + added=0; + } +} + +void update_ls_influence_dst_table(BYTE nw, long dst, BYTE place, BYTE nls, BYTE als, DWORD rc, long opc)//??- +{ + BYTE *routine; + DWORD pc_new, rc_new, opc_new; + BYTE nls_old; + BYTE als_old; + DWORD pc_old; + BYTE nlsnw; + BYTE alsnw; + ull opc_dpc_new=0, opc_dpc_old=0; + + pc_new = decode_integer((BYTE*)&dst,4); + rc_new = decode_integer((BYTE*)&rc,4); + opc_new = decode_integer((BYTE*)&opc,4); + + routine = &mtp3.nw[nw].routine[place]; + + nls_old = mtp3_para->nw[nw].normal_ls[place]; + als_old = mtp3_para->nw[nw].alternative_ls[place]; + pc_old = mtp3_para->nw[nw].dpc[place]; + nlsnw = mtp3_para->ls_pro[nls] & 3; + alsnw = mtp3_para->ls_pro[als] & 3; + + if ((pc_old == pc_new) && + (nls_old == nls) && + (als_old == als) && + (mtp3_para->nw[nw].rc[place] == rc_new)&& + (mtp3_para->nw[nw].opc[place] == opc_new)) + return; +/* + if(opc_new == 0 && pc_new != 0) + { + if(pc_length(nw) == MTP3_24BIT_PC) + opc_new = mtp3_para->nw[nw].opc24; + else + opc_new = mtp3_para->nw[nw].opc14; + + } +*/ + opc_dpc_new = opc_new; + opc_dpc_new = (opc_dpc_new<<32)|pc_new; + opc_dpc_old = mtp3_para->nw[nw].opc[place]; + opc_dpc_old = (opc_dpc_old<<32)|pc_old; + if (pc_old > 0) + Mtp3DeleteRecord(opc_dpc_old,nw);//delect this pc from sort table //??- + if (pc_new > 0) + { + if ((nls<128 && nlsnw == nw) || (als<128 && alsnw==nw)) + { + Mtp3AddSortRec(nw,pc_new,place, opc_new);//add this new pc to the sort table //??- + } + } + + if ( (nls != nls_old) || + (als != als_old) ) + { + if ((nls < 128) && + (nlsnw == nw)) + { + if (mtp3.ls[nls].links_available_t > 0) + mark_normal_linkset_available(routine); + else + mark_normal_linkset_unavailable(routine); + if (nls != nls_old) + add_1dst_to_table(&mtp3.ls[nls],place,UPDATE_NLS); + } + else + mark_normal_linkset_unavailable(routine); + if ((als < 128) && + (nls < 128) &&// if one spc doesn't has normal linkset,it can not has alternative linkset + (alsnw == nw)) + { + if (mtp3.ls[als].links_available_t > 0) + mark_alternative_linkset_available(routine); + else + mark_alternative_linkset_unavailable(routine); + if ((als != als_old) || (nls_old > 127) ) + { +// printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); + add_1dst_to_table(&mtp3.ls[als],place,UPDATE_ALS); +// printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); + } + } + else + mark_alternative_linkset_unavailable(routine); + if ((mtp3.nw[nw].routine[place] & 0x0f) == 0x0a) + mark_dstSP_inaccessible(routine); + hmrt_tfrc_update_routing_tables(place,nw); + + mtp3_para->nw[nw].dpc[place] = pc_new; + mtp3_para->nw[nw].opc[place] = opc_new; + mtp3_para->nw[nw].normal_ls[place] = nls; + mtp3_para->nw[nw].alternative_ls[place] = als; + + if ( (nls_old < 128) && + (nls_old != nls) ) + del_1dst_from_table(&mtp3.ls[nls_old],place,UPDATE_NLS); + + if ( (als_old < 128) && + (als_old != als) ) + del_1dst_from_table(&mtp3.ls[als_old],place,UPDATE_ALS); + } + if (mtp3_para->ls_op_pc[nls] == pc_new) + mtp3.ls[nls].adjacent_sp_place = place; + mtp3_para->nw[nw].dpc[place] = pc_new; + mtp3_para->nw[nw].opc[place] = opc_new; + mtp3_para->nw[nw].rc[place] = rc_new; +} + +int mtp3_write_parameter() +{ + int i,j; + int ix4; + + mtpfpConf = fopen(mtpconfile,"w"); + if (mtpfpConf == NULL) + return -1; + + fprintf(mtpfpConf,"#MTP3 CONFIGURE FILE\n"); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[SERVICE NETWORK SP LEN]\n"); + fprintf(mtpfpConf,"[%02x]\n",mtp3_para->nw_pro); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[MTP3LITE TCP PORT]\n"); + fprintf(mtpfpConf,"[%04x]\n",mtp3_para->mtp3lite_port); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[LOCAL SP]\n"); + fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc14, + mtp3_para->nw[1].opc14,mtp3_para->nw[2].opc14,mtp3_para->nw[3].opc14); + fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc24, + mtp3_para->nw[1].opc24,mtp3_para->nw[2].opc24,mtp3_para->nw[3].opc24); + fprintf(mtpfpConf,"\n"); + +/* e1 to linkset */ + fprintf(mtpfpConf,"[LINK ATTRIBUTE]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%02x.%02x.%08lx.%02x.%02x.%02x.%08lx.%02x.%02x.%08lx]\t",mtp3_para->lk[ix4+j].e1_to_linkset, + mtp3_para->lk[ix4+j].e1_to_slc,mtp3_para->lk[ix4+j].e1_to_mtp3,mtp3_para->lk[ix4+j].e1_lk_type,mtp3_para->lk[ix4+j].e1_to_sg,mtp3_para->lk[ix4+j].e1_to_iid, + mtp3_para->lk[ix4+j].remote_ip,mtp3_para->lk[ix4+j].inactive,mtp3_para->lk[ix4+j].inactive_tm,mtp3_para->lk[ix4+j].e1_to_alterMTP3); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* linkset remote sp */ + fprintf(mtpfpConf,"[LINKSET ATTRIBUTE]\n"); + for (i=0; i<32; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + if (1) + { + char ls_reserved[128]={0}; + char temp[16]; + int k; + for (k=0;k<16;k++) + { + sprintf(temp,"%02x",mtp3_para->ls_reserved[ix4+j][k]); + strcat(ls_reserved,temp); + } + fprintf(mtpfpConf,"[%06lx.%02x.%-16s.%08lx]\t",mtp3_para->ls_op_pc[ix4+j],mtp3_para->ls_pro[ix4+j],ls_reserved, mtp3_para->ls_opc[ix4+j]); + } + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* SG */ + fprintf(mtpfpConf, "[SG ATTRIBUTES]\n"); + for (i = 0; i < 64; i++) + { + ix4 = i * 4; + + for (j = 0; j < 4; j++) + { + fprintf(mtpfpConf, "[%02X.%02X.%02X.%08lX]\t", mtp3_para->sg[ix4+j].enable, mtp3_para->sg[ix4+j].server, + mtp3_para->sg[ix4+j].data_ack, mtp3_para->sg[ix4+j].ip); + } + + fprintf(mtpfpConf, "\n"); + } + fprintf(mtpfpConf, "\n"); + +/* NATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[NATIONAL NETWORK SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[2].dpc[ix4+j],mtp3_para->nw[2].normal_ls[ix4+j], + mtp3_para->nw[2].alternative_ls[ix4+j], mtp3_para->nw[2].rc[ix4+j], mtp3_para->nw[2].opc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* NATIONAL NETWORK SPARE SP */ + fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[3].dpc[ix4+j],mtp3_para->nw[3].normal_ls[ix4+j], + mtp3_para->nw[3].alternative_ls[ix4+j], mtp3_para->nw[3].rc[ix4+j], mtp3_para->nw[3].opc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* INTERNATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[0].dpc[ix4+j],mtp3_para->nw[0].normal_ls[ix4+j], + mtp3_para->nw[0].alternative_ls[ix4+j], mtp3_para->nw[0].rc[ix4+j], mtp3_para->nw[0].opc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* INTERNATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[1].dpc[ix4+j],mtp3_para->nw[1].normal_ls[ix4+j], + mtp3_para->nw[1].alternative_ls[ix4+j], mtp3_para->nw[1].rc[ix4+j], mtp3_para->nw[1].opc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[LOCAL ACN]\n"); + for(i=0;ilocalAcn[i]); + } + fprintf(mtpfpConf,"\n\n"); + + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[0].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[1].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[NATIONAL NETWORK ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[2].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[3].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fclose(mtpfpConf); + return 1; +} + +static int issquare(char c) +{ + if ((c=='[') || (c==']') || (c==' ') || (c=='\t')) + return 1; + return 0; +} + +static int isdot(char c) +{ + if ((c=='.')) + return 1; + return 0; +} + +int ParseLineWithSquare(char *str, char (*row)[128], int maxrow) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen(str); + for(i = 0; i < len && index < maxrow; i++) + { + if(issquare(str[i])) + { + if(black == 0) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if(black == 1) + { + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + } + return index; +} + +int ParseLineWithDot(char *str, char (*row)[128], int maxrow) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen(str); + for(i = 0; i < len && index < maxrow; i++) + { + if(isdot(str[i])) + { + if(black == 0) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if(black == 1) + { + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + } + return index; +} + +int ReadMtp3NetworkPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLineWithSquare(s, LineInfo, 1); + mtp3_para->nw_pro = strtoll(LineInfo[0],NULL,16); + + return 1; +} + +int ReadMtp3LitePortPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLineWithSquare(s, LineInfo, 1); + mtp3_para->mtp3lite_port = strtoll(LineInfo[0],NULL,16); + + return 1; +} + +int ReadMtp3OPCPara(char *s) +{ + char LineInfo[8][128]; + int rtn; + int instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links + if (Base==0) + { + for (instance=0;instance<4;instance++) + { + mtp3_para->nw[instance].opc14 = strtoll(LineInfo[instance],NULL,16); + } + } + else + { + for (instance=0;instance<4;instance++) + { + mtp3_para->nw[instance].opc24 = strtoll(LineInfo[instance],NULL,16); + } + } + + Base++; + + if (Base > 1) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LinkPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + DWORD mtp3ip; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,10); + mtp3_para->lk[Base+Instance].e1_to_linkset = strtoll(DetailInfo[0],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_slc = strtoll(DetailInfo[1],NULL,16); + mtp3ip = strtoll(DetailInfo[2],NULL,16); + if (rtn == 3) + { + if (mtp3ip == 0xff) + mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0xffffffff; + else + mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0x010012ac | ((mtp3ip & 0xff) << 16); + mtp3_para->lk[Base+Instance].e1_lk_type = 0x01; + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; + } + else + { + mtp3_para->lk[Base+Instance].e1_to_mtp3 = mtp3ip; + mtp3_para->lk[Base+Instance].e1_lk_type = strtoll(DetailInfo[3],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_sg = strtoll(DetailInfo[4],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_iid = strtoll(DetailInfo[5],NULL,16); + mtp3_para->lk[Base+Instance].remote_ip = strtoll(DetailInfo[6],NULL,16); + mtp3_para->lk[Base+Instance].inactive = strtoll(DetailInfo[7],NULL,16); + mtp3_para->lk[Base+Instance].inactive_tm = strtoll(DetailInfo[8],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = strtoll(DetailInfo[9],NULL,16); + if(mtp3_para->lk[Base+Instance].e1_to_alterMTP3 == mtp3_para->lk[Base+Instance].e1_to_mtp3) + { + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; + } + } +#ifdef _INCLUDE_M2UA + set_m2ua_link(Base+Instance, (BYTE *) &mtp3_para->lk[Base+Instance]); +#endif + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LinksetPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + memset(DetailInfo, 0, sizeof(DetailInfo)); + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->ls_op_pc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->ls_pro[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + if (rtn == 3) + Str2Bcd(mtp3_para->ls_reserved[Base+Instance],DetailInfo[2],16); + mtp3_para->ls_opc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + } + + Base+=4; + + if (Base >= 128) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3SGPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->sg[Base+Instance].enable = strtoll(DetailInfo[0],NULL,16); + mtp3_para->sg[Base+Instance].server = strtoll(DetailInfo[1],NULL,16); + mtp3_para->sg[Base+Instance].data_ack = strtoll(DetailInfo[2],NULL,16); + mtp3_para->sg[Base+Instance].ip = strtoll(DetailInfo[3],NULL,16); +#ifdef _INCLUDE_M2UA + set_m2ua_sg(Base+Instance, (BYTE *) &mtp3_para->sg[Base+Instance]); +#endif + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + memset(DetailInfo, 0, sizeof(DetailInfo)); + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5);//4);//3); + mtp3_para->nw[2].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[2].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[2].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[2].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + mtp3_para->nw[2].opc[Base+Instance] = strtoll(DetailInfo[4],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATsPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + memset(DetailInfo, 0, sizeof(DetailInfo)); + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); + mtp3_para->nw[3].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[3].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[3].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[3].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + mtp3_para->nw[3].opc[Base+Instance] = strtoll(DetailInfo[4],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + memset(DetailInfo, 0, sizeof(DetailInfo)); + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); + mtp3_para->nw[0].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[0].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[0].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[0].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + mtp3_para->nw[0].opc[Base+Instance] = strtoll(DetailInfo[4],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTsPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + memset(DetailInfo, 0, sizeof(DetailInfo)); + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); + mtp3_para->nw[1].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[1].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[1].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[1].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + mtp3_para->nw[1].opc[Base+Instance] = strtoll(DetailInfo[4],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LocalACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->localAcn,LineInfo[0],MAX_ACN_NUM*2); + + return 1; +} + +int ReadMtp3INTACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[0].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTsACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[1].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[2].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATSACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[3].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +void mtp3_readpara_from_disk() +{ + char s[1024]={0}; + int len; + BYTE state = 0; + FILE *fp; + + fp = fopen(mtpconfile,"rb"); + + if (fp==NULL) + { + printf("mtp3 config file %s missed!!\n",mtpconfile); + return; + } + + s[0] = 0; + while ( fgets(s,1024,fp) != (char *)0 ) + { + if ( (int *)strchr(s,'#') != NULL ) continue; + if ( (len=strlen(s))==0 ) continue; + + if ( strstr(s,"[SERVICE NETWORK SP LEN]") != NULL ) + { + state = 1; + continue; + } + else if ( strstr(s,"[MTP3LITE TCP PORT]") != NULL ) + { + state = 2; + continue; + } + else if ( strstr(s,"[LOCAL SP]") != NULL ) + { + state = 3; + continue; + } + + else if ( strstr(s,"[LINK ATTRIBUTE]") != NULL ) + { + state = 4; + continue; + } + else if ( strstr(s,"[LINKSET ATTRIBUTE]") != NULL ) + { + state = 5; + continue; + } + else if ( strstr(s,"[SG ATTRIBUTES]") != NULL ) + { + state = 6; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SP]") != NULL ) + { + state = 7; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SPARE SP]") != NULL ) + { + state = 8; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SP]") != NULL ) + { + state = 9; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE SP]") != NULL ) + { + state = 10; + continue; + } + else if ( strstr(s,"[LOCAL ACN]") != NULL ) + { + state = 11; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK ACN]") != NULL ) + { + state = 12; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE ACN]") != NULL ) + { + state = 13; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK ACN]") != NULL ) + { + state = 14; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SPARE ACN]") != NULL ) + { + state = 15; + continue; + } + + + switch (state) + { + case 1: + if (ReadMtp3NetworkPara(s)) + state = 0; + break; + case 2: + if (ReadMtp3LitePortPara(s)) + state = 0; + break; + case 3: + if (ReadMtp3OPCPara(s)) + state = 0; + break; + case 4: + if (ReadMtp3LinkPara(s)) + state = 0; + break; + case 5: + if (ReadMtp3LinksetPara(s)) + state = 0; + break; + case 6: + if (ReadMtp3SGPara(s)) + state = 0; + break; + case 7: + if (ReadMtp3NATPara(s)) + state = 0; + break; + case 8: + if (ReadMtp3NATsPara(s)) + state = 0; + break; + case 9: + if (ReadMtp3INTPara(s)) + state = 0; + break; + case 10: + if (ReadMtp3INTsPara(s)) + state = 0; + break; + case 11: + if (ReadMtp3LocalACNPara(s)) + state = 0; + break; + case 12: + if (ReadMtp3INTACNPara(s)) + state = 0; + break; + case 13: + if (ReadMtp3INTsACNPara(s)) + state = 0; + break; + case 14: + if (ReadMtp3NATACNPara(s)) + state = 0; + break; + case 15: + if (ReadMtp3NATSACNPara(s)) + state = 0; + break; + default: + break; + } + } + + fclose(fp); +} + +void mtp3_setlink_to_IDLE(BYTE link) +{ + BYTE oldls; + BYTE oldslc; + DWORD oldip; + BYTE oldtp; + + oldls = mtp3_para->lk[link].e1_to_linkset; + oldslc = mtp3_para->lk[link].e1_to_slc; + oldip = mtp3_para->lk[link].e1_to_mtp3; + oldtp = mtp3_para->lk[link].e1_lk_type; + + if (mtp3ObjState.link_l3_state[link] == AVAILABLE) + { + + if ((MTP3_LINK_TYPE(link) == LKTYPE_MTP3_LITE) && // Not MTP3LITE + (mtp3_para->lk[link].e1_lk_type & 0x01)) // Enabled + {//sccp lite link + deactive_mtp3lite_lk(link); + } + else if((MTP3_LINK_TYPE(link) == LKTYPE_M3UA) && // Not M3UA + (mtp3_para->lk[link].e1_lk_type & 0x01)) // Enabled + {//sccp lite link + deactive_m3ua_lk(link); + } + else + { + mtp3ObjInput.sltc_input[link] = SLTC_STOP; + sltc_proc(link); + init_lsac_state[link] = TRUE; + lsac_proc(link); + init_tlac_state[link] = TRUE; + tlac_proc(link); + + if (mtp3ObjState.link_l3_state[link] == AVAILABLE) + otherMTP3_managed_link_unavailable(link); + mtp3ObjState.link_l2_state[link] = UNAVAILABLE; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + } + } + + if (mtp3ObjState.lk_configured[link] == PARA_CONFIGURED) + { + mtp3.ls[oldls].linksNum_configured--; + ls_slc[oldls*16+oldslc] = 0xff; + update_sls_to_link_table(oldls); + } + mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED; + +// printf("link %d update para,new ls=%d,new slc = %d,new ip=%lx\n",link,newls,newslc,newip); +} + +int mtp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen) +{ + int instance; + DWORD pc; + BYTE command; + int ls; + int slc; + DWORD ip; + DWORD ip1; + int tp; + int i; + DWORD oldpc, opc, oldopc; + BYTE old_lsnw; + BYTE new_lsnw; + DWORD oldpar, rc; + BOOL para_changed=0; + + if ( oidlen < MTP3_OID_LEN) + { + printf("set failed,object id length not correct\n"); + return -1; + } + + if ( oid[MTP3_OID_LEN] == 2 )/* configure */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* sp/stp */ + break; + case 2:/* 14/24bit (for four service networks) */ + oldpar = mtp3_para->nw_pro; + mtp3_para->nw_pro = decode_integer(pdata,datalen); + if (oldpar != mtp3_para->nw_pro) + mtp3_reset_sccp(); + return 1; + case 3:/* opc */ + memcpy(&pc,pdata,4); + pc = pc << 8; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + oldpar = mtp3_para->nw[0].opc14; + mtp3_para->nw[0].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[0].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(0, mtp3_para->nw[0].opc14); + } + return 3; + case 2: + oldpar = mtp3_para->nw[1].opc14; + mtp3_para->nw[1].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[1].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(1, mtp3_para->nw[1].opc14); + } + return 3; + case 3: + oldpar = mtp3_para->nw[2].opc14; + mtp3_para->nw[2].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[2].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(2, mtp3_para->nw[2].opc14); + } + return 3; + case 4: + oldpar = mtp3_para->nw[3].opc14; + mtp3_para->nw[3].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[3].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(3, mtp3_para->nw[3].opc14); + } + return 3; + case 5: + oldpar = mtp3_para->nw[0].opc24; + mtp3_para->nw[0].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[0].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(0, mtp3_para->nw[0].opc24); + } + return 3; + case 6: + oldpar = mtp3_para->nw[1].opc24; + mtp3_para->nw[1].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[1].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(1, mtp3_para->nw[1].opc24); + } + return 3; + case 7: + oldpar = mtp3_para->nw[2].opc24; + mtp3_para->nw[2].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[2].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(2, mtp3_para->nw[2].opc24); + } + return 3; + case 8: + oldpar = mtp3_para->nw[3].opc24; + mtp3_para->nw[3].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[3].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(3, mtp3_para->nw[3].opc24); + } + return 3; + default: + return -1; + } + break; + case 4:/* linkset */ + instance = oid[MTP3_OID_LEN+3]; + if (instance > 127) + return -1; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + oldpc = mtp3_para->ls_op_pc[instance]; + old_lsnw = mtp3_para->ls_pro[instance] & 3; + if(datalen>=24) + { + memcpy(&opc, &pdata[20], 4); + opc = ntohl(opc); + } + oldopc = mtp3_para->ls_opc[instance]; + mtp3_para->ls_opc[instance]=opc; + new_lsnw = pdata[3] & 3; + memcpy(&pc,pdata,4); + pc = pc << 8; + mtp3_para->ls_op_pc[instance] = decode_integer((BYTE*)&pc,4); + /* linkset adjacent sp */ + mtp3_para->ls_pro[instance] = pdata[3]; + memcpy(&mtp3_para->ls_reserved[instance],&pdata[4],16); + if (old_lsnw != new_lsnw) + { + change_the_whole_ls(instance,old_lsnw,new_lsnw); + } + if ((oldpc != mtp3_para->ls_op_pc[instance]) || + (old_lsnw != new_lsnw)||(oldopc != mtp3_para->ls_opc[instance]) ) + { + pc = mtp3_para->ls_op_pc[instance]; + for (i=0;i<256;i++) + { + if (mtp3_para->nw[new_lsnw].dpc[i] == pc && mtp3_para->nw[new_lsnw].opc[i] == opc) + { + mtp3.ls[instance].adjacent_sp_place = i; + return 24; + } + } +// printf("not found pc in table\n"); + mtp3.ls[instance].adjacent_sp_place = 0xffff; + } + return 24; + default: + return -1; + } + break; + case 5:/* link */ + instance = oid[MTP3_OID_LEN+3]; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* e1 to linkset */ + ls = pdata[0]; + slc = pdata[1]; + memcpy(&ip,&pdata[2],4); + memcpy(&ip1,&pdata[15],4); +// ip = pdata[2]; + tp = pdata[6]; + if(ip == ip1 && ip1 != 0xffffff) + {//ip can not be same as ip1 + ip1 = 0xffffffff; + memcpy(&pdata[15], &ip1, 4); + } + + if (ls!=mtp3_para->lk[instance].e1_to_linkset || slc!=mtp3_para->lk[instance].e1_to_slc + || ip!=mtp3_para->lk[instance].e1_to_mtp3 || ip1!=mtp3_para->lk[instance].e1_to_alterMTP3 + || tp != mtp3_para->lk[instance].e1_lk_type) + { + mtp3_setlink_to_IDLE(instance); + para_changed = 1; + } + if (datalen<19) + memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 15); + else + memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 19); + mtp3ObjState.link_type[instance] = mtp3_para->lk[instance].e1_lk_type; + if (para_changed) + { + if (update_ls_slc_table(instance) == 1) + { + update_sls_to_link_table(ls); + MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_mtp3,1); + MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_alterMTP3,1); + } + } +#ifdef _INCLUDE_M2UA + set_m2ua_link(instance & 0xff, pdata); +#endif + return 19; + case 2:/* link command */ + mtp3ObjState.lk_command[instance] = pdata[0]; + + if (mtp3ObjState.lk_mtp3[instance] != mtp3_localip) + return 1; + if (MTP3_LINK_TYPE(instance) == LKTYPE_MTP3_LITE) + { + if (pdata[0]==0)//disable + deactive_mtp3lite_lk(instance); + + return 1; + } + else if (MTP3_LINK_TYPE(instance) == LKTYPE_M3UA) + { + if (pdata[0]==0)//disable + deactive_m3ua_lk(instance); + + return 1; + } + else + { + command = pdata[0]; + if (command < 2) + { + mtp3ObjInput.lsac_input_from_mgmt[instance] = command; + return 1; + } + else if (command < 4) + { + mtp3ObjInput.tlac_input_from_mgmt[instance] = command - 1; + return 1; + } + else + return -1; + } + case 3:/* MTP3LITE TCP Port */ + mtp3_para->mtp3lite_port = pdata[1]; + mtp3_para->mtp3lite_port = (mtp3_para->mtp3lite_port << 8) | pdata[0]; + return 2; + default: + return -1; + } + break; + case 6:/* routine table */ + instance = oid[MTP3_OID_LEN+3]; + memcpy(&pc,pdata,4); + memcpy(&rc,&pdata[5],4); + pc = pc << 8; + memcpy(&opc, &pdata[9], 4); + if ((oid[MTP3_OID_LEN+2] > 4) || (oid[MTP3_OID_LEN+2] < 1)) + return -1; + update_ls_influence_dst_table((oid[MTP3_OID_LEN+2]-1),pc,instance,pdata[3],pdata[4], rc, opc); + return 13; + case 7:/* dpc->acn */ + instance = oid[MTP3_OID_LEN+3]; + + if (oid[MTP3_OID_LEN+2] == 1) + { + memcpy(mtp3_para->localAcn,pdata,MAX_ACN_NUM); + } + else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) + { + memcpy(mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].acn[instance],pdata,MAX_ACN_NUM); + } + else + return -1; + return MAX_ACN_NUM; + case 8:/* timer */ + instance = oid[MTP3_OID_LEN+3]; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* link timer */ + memcpy(&mtp3_para->lt[instance].t1,pdata,10); + update_timer(instance); + return 10; + default: + return -1; + } + return -1; + case 9:/* sg */ + instance = oid[MTP3_OID_LEN+2]; + memcpy(&mtp3_para->sg[instance],pdata,7); +#ifdef _INCLUDE_M2UA + set_m2ua_sg(instance & 0xff, pdata); + return 7; +#else + return 7; +#endif + default: + return -1; + } + return -1; + } + else if (oid[MTP3_OID_LEN] == 3)/* status */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 7: + case 8:/* command */ + switch (pdata[0]) + { + case 1: + reset_mtp3(); + break; + case 2: + printf("save parameter\n"); + return mtp3_write_parameter(); + break; + case 3://load data + mtp3_reload_data(); + break; + default: + break; + } + return 1; + default: + return -1; + } + } + else + return -1; +} + +void mtp3_data_reverse(BYTE *pdata,BYTE *csta,BYTE len,BYTE data_type) +{ + int i; + int j=0; + + for (i=0; i 15) + temp = 15; + mtp3_measure.measure[portion_num].lk_measure1[instance][i] = temp; + } + break; + case 1: + temp = mtp3_measure.measure[portion_num].ls_measure[instance][0]; + temp = (temp + 3) / 6; + if (temp > 15) + temp = 15; + mtp3_measure.measure[portion_num].ls_measure[instance][0] = temp; + temp = mtp3_measure.measure[portion_num].ls_measure[instance][6]; + temp = (temp + 3) / 6; + if (temp > 15) + temp = 15; + mtp3_measure.measure[portion_num].ls_measure[instance][6] = temp; + break; + default: + break; + } +} + +int mtp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ +/* 1.3.6.1.4.1.1373.1.1.2.2.2.2 */ + unsigned int instance; + BYTE portion_num=0; + DWORD timestamp; + DWORD get_rc=0; + + if ( oidlen < 12 ) + { + printf("get fail,object id not correct\n"); + return -1; + } + if ( oid[MTP3_OID_LEN] == 2 )/* configure */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* sp/stp */ + return -1; + case 2:/* 14/24bit (for four service networks) */ + *vartype = 4; + return mtp_encode_integer(pdata,mtp3_para->nw_pro,1); + case 3:/* opc */ + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + return mtp_encode_integer(pdata,mtp3_para->nw[0].opc14,4); + case 2: + return mtp_encode_integer(pdata,mtp3_para->nw[1].opc14,4); + case 3: + return mtp_encode_integer(pdata,mtp3_para->nw[2].opc14,4); + case 4: + return mtp_encode_integer(pdata,mtp3_para->nw[3].opc14,4); + case 5: + return mtp_encode_integer(pdata,mtp3_para->nw[0].opc24,4); + case 6: + return mtp_encode_integer(pdata,mtp3_para->nw[1].opc24,4); + case 7: + return mtp_encode_integer(pdata,mtp3_para->nw[2].opc24,4); + case 8: + return mtp_encode_integer(pdata,mtp3_para->nw[3].opc24,4); + default: + return -1; + } + return -1; + case 4:/* linkset */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + mtp_encode_integer(pdata,mtp3_para->ls_op_pc[instance],4); + pdata[3] = mtp3_para->ls_pro[instance]; + memcpy(&pdata[4],&mtp3_para->ls_reserved[instance],16); + get_rc = htonl(mtp3_para->ls_opc[instance]); + memcpy(&pdata[20], &get_rc, 4); + return 24; + /* linkset adjacent sp */ + default: + return -1; + } + return -1; + case 5:/* link */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* e1 to linkset */ + memcpy(pdata,&mtp3_para->lk[instance].e1_to_linkset,19); + return 19; + case 2: + memcpy(pdata,&mtp3ObjState.lk_command[instance],1); + return 1; + case 3: + pdata[0] = mtp3_para->mtp3lite_port; + pdata[1] = mtp3_para->mtp3lite_port >> 8; + return 2; + default: + return -1; + } + return -1; + case 6:/* internation network routine table */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + mtp_encode_integer(pdata,mtp3_para->nw[0].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[0].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[0].alternative_ls[instance],1); + get_rc = htonl(mtp3_para->nw[0].rc[instance]); + memcpy(&pdata[5], &get_rc, 4); + get_rc = htonl(mtp3_para->nw[0].opc[instance]); + memcpy(&pdata[9], &get_rc, 4); + return 13; + case 2: + mtp_encode_integer(pdata,mtp3_para->nw[1].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[1].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[1].alternative_ls[instance],1); + get_rc = htonl(mtp3_para->nw[1].rc[instance]); + memcpy(&pdata[5], &get_rc, 4); + get_rc = htonl(mtp3_para->nw[1].opc[instance]); + memcpy(&pdata[9], &get_rc, 4); + return 13; + case 3: + mtp_encode_integer(pdata,mtp3_para->nw[2].dpc[instance], 4); + memcpy(&pdata[3],&mtp3_para->nw[2].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[2].alternative_ls[instance],1); + get_rc = htonl(mtp3_para->nw[2].rc[instance]); + memcpy(&pdata[5], &get_rc, 4); + get_rc = htonl(mtp3_para->nw[2].opc[instance]); + memcpy(&pdata[9], &get_rc, 4); + return 13; + case 4: + mtp_encode_integer(pdata,mtp3_para->nw[3].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[3].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[3].alternative_ls[instance],1); + get_rc = htonl(mtp3_para->nw[3].rc[instance]); + memcpy(&pdata[5], &get_rc, 4); + get_rc = htonl(mtp3_para->nw[3].opc[instance]); + memcpy(&pdata[9], &get_rc, 4); + return 13; + default: + return -1; + } + return -1; + case 7: + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + if (oid[MTP3_OID_LEN+2] == 1) + { + memcpy(pdata,mtp3_para->localAcn,MAX_ACN_NUM); + } + else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) + { + memcpy(pdata,mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].acn[instance],MAX_ACN_NUM); + } + else + return -1; + return MAX_ACN_NUM; + case 8: + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* link timer */ + memcpy(pdata,&mtp3_para->lt[instance].t1,10); + return 10; + default: + return -1; + } + return -1; + case 9:/* SG */ + instance = oid[MTP3_OID_LEN+2]; + *vartype = 4; + memcpy(pdata,&mtp3_para->sg[instance],7); + return 7; + default: + return -1; + } + return -1; + } + + else if (oid[MTP3_OID_LEN] == 3)/* status */ + { + *vartype = 4; + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* link status */ + return mtp_encode_integer(pdata,mtp3ObjState.link_l3_state[oid[MTP3_OID_LEN+2]],1); + case 2:/* linkset status */ + instance= oid[MTP3_OID_LEN+2]; + if (instance > 127) + return -1; + if (mtp3.ls[instance].links_available > 0) + pdata[0] = 1; + else + pdata[0] = 0; + return 1; + case 3:/* international network routine */ + return mtp_encode_integer(pdata,mtp3.nw[0].routine[oid[MTP3_OID_LEN+2]],1); + case 4:/* international network spare routine */ + return mtp_encode_integer(pdata,mtp3.nw[1].routine[oid[MTP3_OID_LEN+2]],1); + case 5:/* national network routine */ + return mtp_encode_integer(pdata,mtp3.nw[2].routine[oid[MTP3_OID_LEN+2]],1); + case 6:/* national network spare routine */ + return mtp_encode_integer(pdata,mtp3.nw[3].routine[oid[MTP3_OID_LEN+2]],1); + case 7:/* version */ + memcpy(pdata,mtp3_heartbeat.version,3); + return 3; + default: + return -1; + + } + } + + else if (oid[MTP3_OID_LEN] == 1)/* measurement */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* MTP signalling link faults and performance */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+2]; + if (instance > 8) + return -1; + portion_num = oid[MTP3_OID_LEN+3]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + second_to_min(0,portion_num,instance); + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].lk_measure1[instance],36,4); + return 40; + case 2:/* Signalling link availability */ + return -1; + case 3:/* Signalling link set and route set availability */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+2]; + if (instance > 127) + return -1; + portion_num = oid[MTP3_OID_LEN+3]; +/* if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1;*/ + timestamp = mtp3_measure.measure[portion_num].time_stamp; +/* if (timestamp == 0) + return 0;*/ + second_to_min(1,portion_num,instance); + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].ls_measure[instance],32,4); + return 36; + case 5:/* Signalling traffic distribution */ + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* total traffic */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+3]; + portion_num = oid[MTP3_OID_LEN+4]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; +/* if (instance < 8) + { + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure1[instance-1],80,4); + return 84; + }*/ + else if (instance < 14) + { + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure2[instance-8],80,4); + return 84; + } + else + return -1; + default: + return -1; + } + return -1; + case 6:/* error */ + *vartype = 4; + portion_num = oid[MTP3_OID_LEN+2]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)mtp3_measure.measure[portion_num].tf_measure5,12,4); + return 16; + default: + return -1; + } + } + else + return -1; +} + +void set_led(BYTE nled,BYTE ncolor); +//void set_alarm(BYTE component_id,BYTE alarm_code); +//void set_status(BYTE component_id,BYTE info_len,BYTE *info); + +void set_heartbeat(BYTE reason,BYTE object) +{ + BYTE place; + BYTE temp; + + place = object/4; + temp = (object % 4)*2; + switch (reason) + { + case ALARM_LINK_UNAVAILABLE: + mtp3_heartbeat.link_state[place] &= (~(3<lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno];*/ + + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + tsrc_proc(chl); +/* ls->links_available++;*/ + hmrt_tcbc_update_routing_tables(chl); +} + +void otherMTP3_managed_link_unavailable(BYTE chl) +{ +/* WORD lsno; + ls_info *ls; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno];*/ + + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + tsrc_proc(chl); +/* ls->links_available--;*/ + hmrt_tcoc_update_routing_tables(chl); +// mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; +/*init init_tlac_state*/ + init_tlac_state[chl] = TRUE; + tlac_proc(chl); + + init_lsac_state[chl] = TRUE; + lsac_proc(chl); +} + +int sys_mtp3_table(DWORD ip) +{ + int empty; + int i; + + if (ip==0) + return -1; + + empty = -1; + for (i=0;i= 0) + return empty; + return -1; +} + +void master_MTP3(BYTE link,BYTE masterMTP3,DWORD srcIP) +{ + DWORD NMTP3; + DWORD AMTP3; + + masterMTP3 = masterMTP3 & 1; + + NMTP3 = mtp3_para->lk[link].e1_to_mtp3; + AMTP3 = mtp3_para->lk[link].e1_to_alterMTP3; + + if (srcIP==NMTP3) + { + if (masterMTP3) + mtp3ObjState.lk_NMTP3_ok[link] |= 1; + else + mtp3ObjState.lk_NMTP3_ok[link] &= 0xf0; + } + else if (srcIP==AMTP3) + { + if (masterMTP3) + mtp3ObjState.lk_AMTP3_ok[link] |= 1; + else + mtp3ObjState.lk_AMTP3_ok[link] &= 0xf0; + } +} + +void trap_platform (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + heartbeat_msg *phbmsg = (heartbeat_msg *)msg_ptr; + BYTE *pstatus = phbmsg->info; + heartbeat_compoent_of_mtp3 *phbmtp3 = NULL; + WORD mtp3len=0; + int i,j,pos = 2; //component_id=0:iptrans; + BYTE newHeartbeat=0; + int chl; + BYTE chl_state; + DWORD remote_ip; + int temp; + struct in_addr in; + in.s_addr = addr->remote_ip; + + mtp3_debug(MTP3DB_PFHB,"get platform heartbeat from %s",inet_ntoa(in)); + if (msg_len > 128) + mtp3_showbuf(MTP3DB_PFHB,msg_ptr,128); + else + mtp3_showbuf(MTP3DB_PFHB,msg_ptr,msg_len); + + remote_ip = addr->remote_ip; + + if ((temp=sys_mtp3_table(remote_ip)) >= 0) + { + MTP3IPMng.mtp3_flag_new[temp] = 1; + MTP3IPMng.mtp3_flag_ip[temp] = remote_ip; + } + + if ( remote_ip == mtp3_localip )/* heartbeat from itself */ + return; + + if ((temp=MTP3_LinkIP_List(remote_ip,0))<0) + return; + + if (sizeof(struct heartbeat_msg) >= (INFO_LEN + 18)) + newHeartbeat = 1; + + if (!newHeartbeat) + {//old version heartbeat, length and component_id are one octet + pos = 1; + pos += pstatus[pos]+1; //length of iptrans status + pos++; //component_id=1:MTP3 + + mtp3len = pstatus[pos]; + pos++; //length of mtp3 hb + if (pstatus[pos-1] != 1)//not mtp3 component + return; + } + else + {//new version heartbeat, length and component_id are 2 octets + pos ++; //length is 2 octets + pos += pstatus[pos]+1; //length of iptrans status + pos ++; //component_id=1:mtp3 + pos ++; //component_id is 2 octets + + if (pstatus[pos-1] != 1)//not mtp3 component + return; + + mtp3len = pstatus[pos]*256+pstatus[pos+1]; + pos ++; //length of mtp3 hb + pos ++; //length is 2 octets + } + + phbmtp3 = (heartbeat_compoent_of_mtp3*)&pstatus[pos]; + + if (mtp3len > MTP3_HB_LEN || mtp3len < (MTP3_HB_LEN-34)) + return; + + for (i=0; i<64; i++) + { + temp = phbmtp3->link_state[i]; + for (j=0; j<4; j++) + { + chl = i*4+j; + chl_state = (temp >> (j*2)) & 3; + if ( (mtp3ObjState.lk_mtp3[chl] == remote_ip) && + (mtp3ObjState.link_l3_state[chl] != chl_state) ) + { + if ( mtp3ObjState.lk_configured[chl] != PARA_CONFIGURED ) + { + continue; + } + switch (chl_state) + { + case UNAVAILABLE: + if (mtp3ObjState.link_l3_state[chl] == INHIBITED) + { + mtp3_debug(MTP3DB_EVENT,"link %d L3 state changed from INHIBITED to UNAVAILABLE,invoke by %s",chl,inet_ntoa(in)); + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d L3 out of service,invoke by %s",chl,inet_ntoa(in)); + otherMTP3_managed_link_unavailable(chl); + } + break; + case AVAILABLE: + mtp3_debug(MTP3DB_EVENT,"link %d L3 in service,invoke by %s",chl,inet_ntoa(in)); + otherMTP3_managed_link_available(chl); + break; + case INHIBITED: + mtp3_debug(MTP3DB_EVENT,"link %d L3 inhibited,invoke by %s",chl,inet_ntoa(in)); + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + otherMTP3_managed_link_unavailable(chl); + mtp3ObjState.link_l3_state[chl] = INHIBITED; + break; + default: + break; + } + } + } + } + + if (mtp3len > 100) + { + for (i=0;i<32;i++) + { + for (j=0; j<8; j++) + { + chl = i*8+j; + master_MTP3(chl,(phbmtp3->masterMTP3[i]>>j),remote_ip); + } + } + if (mtp3len > 132) + { + MTP3IPMng.LinkIPSubSta[temp][0] = phbmtp3->SubState[0]; + MTP3IPMng.LinkIPSubSta[temp][1] = phbmtp3->SubState[1]; + } + else + { + MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; + MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; + } + } + else + { + MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; + MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; + } +} + +void trap_mtp2 (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + int i; + mtp2_heartbeat *mtp2; + BYTE offset; + BYTE new_l2_state; + BYTE chl; + BYTE ls; + BYTE module_id; + struct in_addr in; + in.s_addr = addr->remote_ip; + + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get MTP2 heartbeat from %s",inet_ntoa(in)); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,msg_ptr,msg_len); + + mtp2 = (mtp2_heartbeat*)msg_ptr; + module_id = (mtp2->systemid & 1)*16+mtp2->moduleid; + if (module_id > 31) + return; + mtp2_flag_new[module_id] = 1; + offset = module_id << 3; + for ( i=0; i<8; i++ ) + { + chl = offset + i; + mtp3ObjState.link_l1_state[chl] = (mtp2->l1_state >> i) & 1; + new_l2_state = mtp2->l2_state[i];/* e1 l2 state from mtp2 */ + if ( (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) ) + continue; + if ( new_l2_state != mtp3ObjState.link_l2_state[chl] ) + { + ls = mtp3_para->lk[chl].e1_to_linkset; + if (new_l2_state == MTP2_STATE_WORKING)/* link from unavailable->available */ + { + current_measure->lk_measure1[chl][2]++;/* restoration */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 in service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)/* link from available->unavailable */ + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + if ( mtp2->retrieved_bsnt[i] < 128 ) + local_bsnt_retrievable[chl] = TRUE; + else + { +// mtp3_debug(MTP3_DEBUG_LOG,"Link %d BSNT RETRIEVE FAILED",chl); + local_bsnt_retrievable[chl] = FALSE; + } + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + } + } + mtp3ObjState.link_l2_state[chl] = new_l2_state; + if ( (mtp2->e1_dstip[i]+32 != ((mtp3ObjState.lk_mtp3[chl] >> 16) & 0xff)) && + (mtp3ObjState.lk_configured[chl] == PARA_CONFIGURED) ) + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK);/* give this port a correct ip */ + retrieved_bsnt[chl] = mtp2->retrieved_bsnt[i]; + } + + if (mtp2->alarm_code == 3) + { + mtp2_buf_full[mtp2->alarm_component]++; + } +} + +void mtp3_dealtrap(BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + DWORD mtp2_oid[20] = MTP2_HB_OID; + DWORD platform_oid[20] = PLATFORM_HB_OID; + DWORD omc_oid[20] = MTP3_OMC_OID; + + if (memcmp(&oid_ptr[9],&mtp2_oid[9],16)==0) + { + trap_mtp2 (oid_len,oid_ptr,msg_ptr,msg_len,addr); + } + else if (memcmp(&oid_ptr[9],&platform_oid[9],8)==0) + { + trap_platform(oid_len,oid_ptr,msg_ptr,msg_len,addr); + } + else if (memcmp(oid_ptr,omc_oid,MTP3_OMC_OID_LEN*sizeof(DWORD))==0) + {//omc heartbeat + if ((mtp3_para->MTP3SerialNum==0) ||//support old version, do not have serial number + (Bcd2Ull(&msg_ptr[39],MTP3_SERNUM_LEN)==mtp3_para->MTP3SerialNum) ) + { + switch(msg_ptr[0]) + { + case 0: + mtp3_primomcip = addr->remote_ip; + break; + case 1: + mtp3_secdomcip = addr->remote_ip; + break; + default: + break; + } + } + } +} + +void mtp_snmp_init() +{ + DWORD mib_oid[20] = MTP3_OID; + + snmp_init(4957); + heartbeat_init(0xff); + + inquire_setmsg(MTP3_OID_LEN,mib_oid, mtp_setmib); + inquire_getmsg(MTP3_OID_LEN,mib_oid, mtp_getmib); +// inquire_trapmsg(trapcall trap_mtp2)/* mtp2 heartbeat */ + inquire_trapmsg(mtp3_dealtrap); +// rob_trapmsg(MTP2_HBOID_LEN,mtp2_oid,trap_mtp2); +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpslm.c b/omc/plat/mtp3/src/mtpslm.c new file mode 100644 index 0000000..697323d --- /dev/null +++ b/omc/plat/mtp3/src/mtpslm.c @@ -0,0 +1,405 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void sltc_proc(BYTE chl) +{ + ls_info *ls; + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + if (mtp3ObjInput.sltc_input[chl] == SLTC_STOP) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjState.sltc_state[chl] = SLTC_IDLE_STATE; + } + + switch (mtp3ObjState.sltc_state[chl]) + { + case SLTC_IDLE_STATE: + if (mtp3ObjInput.sltc_input[chl] == SLTC_START) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + hmrt_sltc_signalling_link_test_msg(chl); + sltc_t1_delay[chl] = 4; + mtp3ObjState.sltc_state[chl] = SLTC_FIRST_TRY_STATE; + } + break; + + case SLTC_FIRST_TRY_STATE: + sltc_t1_delay[chl] --; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + sltc_t1_delay[chl] = 4; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_SECOND_TRY_STATE; + } + break; + + case SLTC_SECOND_TRY_STATE: + sltc_t1_delay[chl]--; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + sltc_t1_delay[chl] = 4; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_THIRD_TRY_STATE; + } + break; + + case SLTC_THIRD_TRY_STATE: + sltc_t1_delay[chl]--; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_FAILED; + mtp3ObjState.sltc_state[chl] = SLTC_IDLE_STATE; + } + break; + + case SLTC_RUNNING_STATE: + sltc_t2_delay[chl] --; + if ( sltc_t2_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_FIRST_TRY_STATE; + sltc_t1_delay[chl] = 4; + } + break; + + default: + break; + } +} + +int link_auc(BYTE chl) +{ + BYTE linkset; + + linkset = mtp3_para->lk[chl].e1_to_linkset; + if ( (mtp3ObjState.lk_configured[chl] != PARA_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) ) + return 3; + if (mtp3ObjState.link_l1_state[chl] != 1) + return 2; + if (mtp3.ls[linkset].links_available == 0) + return 1; + else + return 0; + +/* return value: + * 0=linkset not only one link available + * 1=linkset only one link available + * 2=send command to enable this link + * 3=no need to send command to this link */ +} + +void lsac_proc(BYTE chl) +{ + int aucResult; + static BYTE timer[256]; + + if (init_lsac_state[chl] == TRUE) + { + init_lsac_state[chl] = IDLE; + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + return; + } + + switch (mtp3ObjState.lsac_state[chl]) + { + case LSAC_INACTIVE_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + if (timer[chl]++>50) + { + timer[chl] = 0; + aucResult = link_auc(chl); + switch (aucResult) + { + case 0: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d normal alignment",chl); +// printf("chl %d normal alignment\n",chl); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + timer[chl] = 0; + break; + case 1: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_EMERGEN_ALIGNMENT); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d emergent alignment",chl); +// printf("chl %d emergent alignment\n",chl); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + timer[chl] = 0; + break; + case 2: + if (MTP3_LINK_TYPE(chl) != LKTYPE_MTP3_LITE)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + break; + default: + break; + } + } + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + break; + + case LSAC_RESTORING_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + if ( (mtp3ObjState.sltc_state[chl] == SLTC_IDLE_STATE) && + (timer[chl]++>60)) // change timer 8s to 9.6s + { + timer[chl] = 0; + aucResult = link_auc(chl); + switch (aucResult) + { + case 0: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + break; + case 1: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_EMERGEN_ALIGNMENT); + break; + default: + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + } + } + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + send_command_to_mtp2(chl,MTP2_DEACTIVE_LINK); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d L2 in service,start testing procedure",chl); + mtp3ObjInput.sltc_input[chl] = SLTC_START; + sltc_proc(chl);/* start to send sltm */ + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_sltc[chl]) + { + case LSAC_SLTC_SLT_SUCCESSFUL: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_LINK_IN_SERVICE; + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d complete test procedure,test pass",chl); + break; + + case LSAC_SLTC_SLT_FAILED: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjState.link_l2_state[chl] = UNAVAILABLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d complete test procedure,test failed",chl); + break; + + default: + break; + } + break; + + case LSAC_ACTIVE_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_WAIT_STATE; +// mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d failed",chl); +// printf("lsac link %d failed\n",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + if (link_inhibited[chl] != TRUE) + { + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_sltc[chl]) + { + case LSAC_SLTC_SLT_SUCCESSFUL: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + break; + + case LSAC_SLTC_SLT_FAILED: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d test failed during active state",chl); + mtp3ObjState.link_l2_state[chl] = UNAVAILABLE; + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_TEST_FAILED); + if (link_inhibited[chl] != TRUE) + { + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_tcoc[chl]) + { + case LSAC_TCOC_STM_READY: + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + break; + + case LSAC_TCOC_STOP_L2: + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_CHANGE_OVER); + if (link_inhibited[chl] != TRUE) + { + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_stm[chl]) + { + case LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED: + mtp3ObjInput.lsac_input_from_stm[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_CHANGE_OVER); + mtp3_debug(MTP3DB_EVENT,"[lsac]receive coo"); +// printf("lsac receive coo\n"); + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + break; + + default: + break; + } + break; + + case LSAC_WAIT_STATE: + if ( mtp3ObjInput.lsac_input_from_tcoc[chl] == LSAC_TCOC_STM_READY) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_MGMT_REQUEST); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + } + break; + + case LSAC_FAILED_STATE: + if (mtp3ObjInput.lsac_input_from_stm[chl] != IDLE) + { + mtp3ObjInput.lsac_input_from_stm[chl] = IDLE; + } + if ( mtp3ObjInput.lsac_input_from_tcoc[chl] == LSAC_TCOC_STM_READY ) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + changeover_in_progress[chl] = FALSE; + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + } + break; + + default: + break; + } +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpsmh.c b/omc/plat/mtp3/src/mtpsmh.c new file mode 100644 index 0000000..281ae3c --- /dev/null +++ b/omc/plat/mtp3/src/mtpsmh.c @@ -0,0 +1,4369 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" +#include "./include/mtp3lite.h" +#include "../../public/src/include/pub_netcap.h" + +/*@ignore@*/ +extern int mtp3_send_netcap; +#ifndef _M3UA_ +#define _M3UA_ +#endif +iprt1 mtp3_iprt; +#ifdef _INCLUDE_M2UA + static m2ua_up_msg_t *mtp3_m2ua_msg; +#endif +#ifdef _M3UA_ + static xua_up_msg_t *mtp3_m3ua_msg; +#endif +extern tup_shm *T_shm_ptr; +extern isup_shm *I_shm_ptr; +extern bicc_shm *B_shm_ptr; +extern sccp_shm *S_shm_ptr; +DWORD msgSourceIP; +extern primitive_to_isup *I_primitive; +extern primitive_to_bicc *B_primitive; +extern primitive_to_sccp *S_primitive; +extern primitive_to_tup *T_primitive; +extern mtp3_routing_result routingResult; +extern void mtp3_debug(int n,const char *fmt,...); +extern BYTE mtp3_check_dpc_equal_to_opc(BYTE nw, DWORD dpc); + +void tsrc_fun5(BYTE linkset); +void stop_mtp3T21(BYTE linkset); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); +void send_to_host_mtp3(BYTE *msgptr,DWORD dst_ip); +int MTP3_LinkIP_List(DWORD IP,BYTE mode); +void sp_unaccessable(BYTE *routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +BYTE get_route_value(u32 dpc, u8 nw, u32 opc); +int send_route_to_other_plat(u32 dpc, BYTE nw, BYTE routine, long dest_ip, BYTE chl, u32 opc); +int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, BYTE chl, u32 opc); + + +void primitive_to_userpart(BYTE nw,long dst,BYTE state) +{ + BYTE I_WSub; + BYTE B_WSub; + BYTE S_WSub; + BYTE T_WSub; + mtp_primitive *I_ptr; + mtp_primitive *B_ptr; + mtp_primitive *S_ptr; + mtp_primitive *T_ptr; + + I_WSub = I_primitive->WSub; + B_WSub = B_primitive->WSub; + S_WSub = S_primitive->WSub; + T_WSub = T_primitive->WSub; + I_ptr = &I_primitive->primitive[I_WSub]; + B_ptr = &B_primitive->primitive[I_WSub]; + S_ptr = &S_primitive->primitive[I_WSub]; + T_ptr = &T_primitive->primitive[I_WSub]; + + I_ptr->pc = dst; + I_ptr->nw_indicator = nw; + I_ptr->availability = state; + + B_ptr->pc = dst; + B_ptr->nw_indicator = nw; + B_ptr->availability = state; + + S_ptr->pc = dst; + S_ptr->nw_indicator = nw; + S_ptr->availability = state; + + T_ptr->pc = dst; + T_ptr->nw_indicator = nw; + T_ptr->availability = state; + + I_primitive->WSub = (I_WSub + 1) & 0x0f; + B_primitive->WSub = (I_WSub + 1) & 0x0f; + S_primitive->WSub = (S_WSub + 1) & 0x0f; + T_primitive->WSub = (T_WSub + 1) & 0x0f; +} + +BYTE *spc_to_acn(BYTE netID,DWORD spc)//??- +{ + nw_para *nw; + DWORD index; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[netID]; + ull opc_dpc=0; + + netID = netID % 4; + nw = &mtp3_para->nw[netID]; + + if (pc_length(netID) == MTP3_24BIT_PC) + { + opc_dpc = mtp3_para->nw[netID].opc24; + opc_dpc = (opc_dpc<<32) | spc; + if (nw->opc24 == spc) + return mtp3_para->localAcn; + } + else + { + opc_dpc = mtp3_para->nw[netID].opc14; + opc_dpc = (opc_dpc<<32) | spc; + if (nw->opc14 == spc) + return mtp3_para->localAcn; + } + + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,netID,opc_dpc);//??- + if (index>=0 && index<256) + return nw->acn[sort_rec->index[index]]; + return NULL; +} + +BYTE mtp3_ansiFlag(BYTE netID) +{ + netID = netID & 3; + return (mtp3_para->nw_pro >> (netID+4)) & 1; +} + +int search_outbound_coLink(BYTE chl)/* find outbound changeover link */ +{ + ls_info *ls; + int i; + int lsx16; + WORD adsp_place; + BYTE nw; + int outls; + int outlink; + int lsno; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + if (ls->links_available > 0) + { + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; +/* if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (outlink != chl) && + (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) )*/ + if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (outlink != chl) ) + { + return ls_slc[lsx16+i]; + } + } + return -1; + } + else + { + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return -1; + if ( ((mtp3.nw[nw].routine[adsp_place] >> 2) & 3) == 0)/* alternative route available */ + { + outls = mtp3_para->nw[nw].alternative_ls[adsp_place]; + lsx16 = outls << 4; + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; +/* if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) )*/ + if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) ) + { + mtp3_debug(MTP3DB_EVENT,"outlink is %d",outlink); + return outlink; + } + } + return -1; + } + } + return -1; +} + +int pc_length(BYTE nw) +{ + if (((mtp3_para->nw_pro >> nw) & 1) == 1) + return MTP3_24BIT_PC; + else + return MTP3_14BIT_PC; +} + +void send_to_mtp2(long dest_ip) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; +// iptrPutMessage(mtp3_iprt.io_msg); + {//delete one byte of len +// BYTE tmp[300]; + mtp3_iprt.io_msg.msgLength = mtp3_iprt.io_msg.msgContent[2]+2; + memcpy(&mtp3_iprt.io_msg.msgContent[1], &mtp3_iprt.io_msg.msgContent[2], mtp3_iprt.io_msg.msgContent[2]+1); +// tmp[0] = mtp3_iprt.io_msg.msgContent[0]; +// memcpy(&mtp3_iprt.io_msg.msgContent[0], tmp, tmp[1]+2); + } + iptrDirectSendMsg(mtp3_iprt.io_msg); +} + +void send_to_mtp2_new_struct(long dest_ip)//link,len_high,len_low,sio... +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + if(mtp3_iprt.io_msg.msgLength >300) + { + mtp3_debug(MTP3DB_ERROR,"Send message in SS7 port 4950, length longer than 300, len=%d!", mtp3_iprt.io_msg.msgLength); + return; + } + iptrDirectSendMsg(mtp3_iprt.io_msg); +} +#ifndef _M3UA_ +void send_mtp_msg(int outlink, BYTE *msgptr) +{ + int linkset; + ls_info *ls; + int ls_pro; + BYTE nw; + DWORD dst_ip; + long opc; + long route_mark; + BYTE sls; + BYTE pclen; + WORD len; + BYTE ssf; + BYTE debugtype=0; + + if(msgptr == NULL) + { + return; + } + ssf = msgptr[3] & 0x0f; + linkset = mtp3_para->lk[outlink].e1_to_linkset; + ls = &mtp3.ls[linkset]; + ls_pro = mtp3_para->ls_pro[linkset]; + nw = ls_pro & 3; + pclen = pc_length(nw); + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + if ( pclen == MTP3_24BIT_PC ) + { + opc = mtp3_para->nw[nw].opc24; + memcpy( &msgptr[3],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[3],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(opc << 14)+opc; + memcpy(&msgptr[3],&route_mark,4); + } + } + + if (ssf > 1) + { + ssf--; + debugtype = MTP_MSG_DOWN; + } + else + debugtype = MTP_SNM_MSG; +// current_measure->tf_measure1[4][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[4][wx5[nw]+ssf]++;/* MSUs */ + +// len = msgptr[1]+2; + len = (msgptr[1]<<8) + msgptr[2]+3; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"send_mtp_msg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + mtp3_iprt.io_msg.msgLength = len; + + if( mtp3_send_netcap && ( ( msgptr[3] & 0xF0) != 0xF0 ) ) + { + int pclen; + BYTE sio; + BYTE nw; + + sio = msgptr[3]; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 0 ); + } + } + +#if _INCLUDE_M2UA + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + {//transfer to remote plat + dst_ip = mtp3ObjState.lk_mtp3[outlink]; + //dst_ip = (dst_ip << 16) | E1CARD_BASE_IP; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ +// send_to_mtp2(dst_ip); + send_to_mtp2_new_struct(dst_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) +#endif + { + dst_ip = LINK_TO_IP(outlink); + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + send_to_mtp2(dst_ip);//use old struct send to 8k bload + } +#if _INCLUDE_M2UA + else + { + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + /* debug show message */ + dst_ip = mtp3_para->lk[outlink].remote_ip; + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + return; + } + else + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return; + } + } +#endif + + +} +#endif +int check_snmmsg_route(BYTE ls) +{ + WORD sp_place; + BYTE nw; + BYTE routine; + BYTE outbound_ls=128; + int outlink=256; + int lsx16; + int i; + + if (mtp3.ls[ls].links_available_t > 0) + { + outbound_ls = ls; + } + else + { + sp_place = mtp3.ls[ls].adjacent_sp_place; + if (sp_place > 255) + return -1; + nw = mtp3_para->ls_pro[ls] & 3; + routine = mtp3.nw[nw].routine[sp_place]; + if ( (routine & 3) == NLS_AVAILABLE ) + outbound_ls = mtp3_para->nw[nw].normal_ls[sp_place]; + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE ) + outbound_ls = mtp3_para->nw[nw].alternative_ls[sp_place]; + else + { +// mtp3_debug(MTP3DB_ERROR,"ls %d Can't find Outbound LS TO LS-Remote PC when SNM\n\r",ls); + return -1; + } + } + lsx16 = outbound_ls << 4; + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; + if ( mtp3ObjState.link_l3_state[outlink] == AVAILABLE ) + { + return outlink; + } + else if (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) + { + if (changeback_in_progress[outlink] == TRUE) + { + return outlink; + } + } + } + return -1; +} + +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + int outlink; + + if (linkset > 127) + return; + if (dst == mtp3_para->ls_op_pc[linkset]) + return; + outlink = check_snmmsg_route(linkset); + if (outlink == -1) + return; + ls = &mtp3.ls[linkset]; + nw = (mtp3_para->ls_pro[linkset]) & 3; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 12; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + //memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + if(mtp3_para->ls_opc[linkset]==0) + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&sd_tmp_buf[7],&mtp3_para->ls_opc[linkset],3); + sd_tmp_buf[10] = 0; + sd_tmp_buf[11] = MsgType; + memcpy(&sd_tmp_buf[12],&dst,3); + } + else + { + if(mtp3_para->ls_opc[linkset]==0) + route_mark = (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[linkset]; + else + route_mark = (mtp3_para->ls_opc[linkset] << 14) + mtp3_para->ls_op_pc[linkset]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 8; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = MsgType; + memcpy(&sd_tmp_buf[9],&dst,2); + } + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); +} + +BYTE priority_own_link(WORD lsno,BYTE sls) +{ + ls_info *ls; + int i; + BYTE link; + + if (lsno >= MAX_LS_NUM) + return -1; + + ls = &mtp3.ls[lsno]; + for (i=0;ilk[link].e1_to_mtp3 == mtp3_localip) + return link; + } + return ls_sls[(lsno<<4)+(sls & 15)]; +} + +int check_outbound_route(BYTE nw, long dpc, BYTE sls, long opc) +{ + network *sp; + BYTE outroute; + WORD ls; + BYTE i; + BYTE routine; + WORD nls; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + BYTE outlink; + ull opc_dpc=0; + + if (dpc==0) + return -3; + + sp = &mtp3.nw[nw]; + if(opc == mtp3_para->nw[nw].opc14 && (pc_length(nw)==MTP3_14BIT_PC)) + opc = 0; + else if(opc == mtp3_para->nw[nw].opc24 && (pc_length(nw)==MTP3_24BIT_PC)) + opc = 0; + opc_dpc = opc; + opc_dpc = (opc_dpc <<32)|dpc; + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,opc_dpc); + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return -3; + + routine = sp->routine[i]; + outroute = (routine >> 6) & 3; + if ( outroute == 2 )/* no outbound route */ + { + nls = mtp3_para->nw[nw].normal_ls[i]; + if (mtp3.ls[nls].linksNum_configured > 0) +// if (linknum_in_ls[nls] > 0) + return -1; + else + return -2; + } + else if ( (outroute == 0) && + ((routine & 3) == NLS_AVAILABLE) )/* current route is normal route */ + { + ls = mtp3_para->nw[nw].normal_ls[i]; + outlink = ls_sls[(ls<<4)+sls]; + if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip) + return outlink; + else + return priority_own_link(ls,sls); + } + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE) + { + ls = mtp3_para->nw[nw].alternative_ls[i]; + outlink = ls_sls[(ls<<4)+sls]; + if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip) + return outlink; + else + return priority_own_link(ls,sls); + } + return -3; +} + +/* pc_length:point code type + * ss7 network has two kind of point code,one is 14bits length, + * another is 24bits length */ + +int send_to_sccp(BYTE *msgptr)/* send sccp msg to tele user part */ +{ + up_message *ToSccp; + WORD len; + long route_mark;/* route mark */ + BYTE pclen; + BYTE nw; + BYTE sio; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + link = msgptr[0]; + ToSccp->link = link; + ToSccp->dest_ip = msgSourceIP; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 9)//len < 9 + { + mtp3ObjState.MTP3WatchDog[3]++; + mtp3.nw[nw].flow.MtoU_throwed[0]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE *)&ToSccp->dpc,msgptr+4,3);/* message's dpc */ + memcpy((BYTE *)&ToSccp->opc,&msgptr[7],3);/* message's opc */ + ToSccp->sio = sio; + ToSccp->cic[0] = msgptr[10]; + len = (msgptr[1]<<8) + msgptr[2]-8; + ToSccp->len = len; + memcpy(&ToSccp->msgList,&msgptr[11],len); + } + else + { + if (msgptr[1] == 0 && msgptr[2] < 6) + { + mtp3ObjState.MTP3WatchDog[4]++; + mtp3.nw[nw].flow.MtoU_throwed[0]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToSccp->cic[0] = route_mark >> 28; + ToSccp->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToSccp->dpc = (route_mark & 0x3FFF); + ToSccp->sio = sio; + len = (msgptr[1]<<8) + msgptr[2] -5; + ToSccp->len = len; + memcpy(&ToSccp->msgList,&msgptr[8],len); + } + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + return 1; +} + +int send_to_sccp_lite(up_message *msgptr)/* send sccp-lite msg to sccp */ +{ + up_message *ToSccp; + BYTE nw; + + nw = msgptr->sio >> 6; + + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + memcpy((BYTE *)ToSccp, (BYTE *)msgptr, sizeof(up_message)); + + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + + return 1; +} + +int send_to_tup(BYTE *msgptr)/* send tup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message *ToTup; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + link = msgptr[0]; + pclen = pc_length(nw); + ToTup = &T_shm_ptr->MT_Buf.msgNum[T_shm_ptr->MT_Buf.WSub]; + ToTup->link = link; + ToTup->dest_ip = msgSourceIP; + + if (pclen == MTP3_24BIT_PC)/* for 24bits network */ + { + if (msgptr[1] == 0 && msgptr[2] < 10) + { + mtp3ObjState.MTP3WatchDog[5]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + ToTup->sio = sio; + memcpy((BYTE*)&ToTup->dpc,&msgptr[4],3);/* message's dpc */ + memcpy((BYTE*)&ToTup->opc,&msgptr[7],3);/* message's opc */ + ToTup->cic[0] = msgptr[10]; + ToTup->cic[1] = msgptr[11]; + len = (msgptr[1]<<8) + msgptr[2] -9; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr[12],len); + } + else/* for 14bits network */ + { + if (msgptr[1] == 0 && msgptr[2] < 7) + { + mtp3ObjState.MTP3WatchDog[6]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToTup->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToTup->dpc = (route_mark & 0x3FFF); + ToTup->cic[0] = (msgptr[7] >> 4) + ((msgptr[8] & 0x0f) << 4); + ToTup->cic[1] = (msgptr[8] >> 4); + ToTup->sio = sio; + len = (msgptr[1]<<8) + msgptr[2] - 6; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr[9],len); + } + T_shm_ptr->MT_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[3]++; + return 1; +} + +void MTP3_recv_isup_count(BYTE nw,BYTE type) +{ + switch (type) + { + case MTP3_ISUP_IAM: + mtp3.nw[nw].flow.isup_detail[0]++; + break; + case MTP3_ISUP_ACM: + mtp3.nw[nw].flow.isup_detail[1]++; + break; + case MTP3_ISUP_CPG: + mtp3.nw[nw].flow.isup_detail[2]++; + break; + case MTP3_ISUP_ANM: + mtp3.nw[nw].flow.isup_detail[3]++; + break; + case MTP3_ISUP_REL: + mtp3.nw[nw].flow.isup_detail[4]++; + break; + case MTP3_ISUP_RLC: + mtp3.nw[nw].flow.isup_detail[5]++; + break; + default: + break; + } +} + +int send_to_isup(BYTE *msgptr)/* send isup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message *ToIsup; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToIsup = &I_shm_ptr->MI_Buf.msgNum[I_shm_ptr->MI_Buf.WSub]; + pclen = pc_length(nw); + link = msgptr[0]; + ToIsup->link = link; + ToIsup->dest_ip = msgSourceIP; + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 11) + { + mtp3ObjState.MTP3WatchDog[7]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&ToIsup->dpc,&msgptr[4],3); + memcpy((BYTE*)&ToIsup->opc,&msgptr[7],3); + ToIsup->sio = sio; + ToIsup->cic[0] = msgptr[11]; + ToIsup->cic[1] = msgptr[12]; + len = (msgptr[1]<<8) + msgptr[2] -10; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr[13],len); + MTP3_recv_isup_count(nw,msgptr[13]); + } + else/* for 14bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 8) + { + mtp3ObjState.MTP3WatchDog[8]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToIsup->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToIsup->dpc = (route_mark & 0x3FFF); + ToIsup->sio = sio; + ToIsup->cic[0] = msgptr[8]; + ToIsup->cic[1] = msgptr[9]; + len = (msgptr[1]<<8) + msgptr[2] -7; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr[10],len); + MTP3_recv_isup_count(nw,msgptr[10]); + } + I_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int send_to_bicc(BYTE *msgptr)/* send isup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message_2 *ToBicc; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToBicc = &B_shm_ptr->MI_Buf.msgNum[B_shm_ptr->MI_Buf.WSub]; + pclen = pc_length(nw); + link = msgptr[0]; + ToBicc->link = link; + ToBicc->dest_ip = msgSourceIP; + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + memcpy((BYTE*)&ToBicc->dpc,&msgptr[4],3); + memcpy((BYTE*)&ToBicc->opc,&msgptr[7],3); + ToBicc->sio = sio; + ToBicc->cic[0] = msgptr[11]; + ToBicc->cic[1] = msgptr[12]; + ToBicc->cic[2] = msgptr[13]; + ToBicc->cic[3] = msgptr[14]; + len = (msgptr[1]<<8) + msgptr[2] -12; + ToBicc->len = len; + memcpy(&ToBicc->msgList,&msgptr[15],len); + } + else/* for 14bit ss7 network */ + { + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToBicc->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToBicc->dpc = (route_mark & 0x3FFF); + ToBicc->sio = sio; + ToBicc->cic[0] = msgptr[8]; + ToBicc->cic[1] = msgptr[9]; + ToBicc->cic[2] = msgptr[10]; + ToBicc->cic[3] = msgptr[11]; + len = (msgptr[1]<<8) + msgptr[2] -9; + ToBicc->len = len; + memcpy(&ToBicc->msgList,&msgptr[12],len); + } + B_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int get_sccp(up_message *GetSccp) +{ + WORD len; + BYTE sio; + long route_mark;/* dpc opc sls */ + BYTE sls; + long dpc; + BYTE pclen; + int outlink=0; + long dest_ip; + BYTE *msgptr; + BYTE nw; + BYTE rSub; + + rSub = S_shm_ptr->SM_Buf.RSub; + if (rSub != S_shm_ptr->SM_Buf.WSub) + { + GetSccp = &S_shm_ptr->SM_Buf.msgNum[rSub]; + sio = GetSccp->sio & 0xcf; + dpc = GetSccp->dpc; + sls = GetSccp->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetSccp->len; + + dest_ip = GetSccp->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.sccpMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,sio=%x,dpc=%lx",GetSccp->sio,GetSccp->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetSccp->msgList,GetSccp->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + } + else{ + outlink = GetSccp->link; + } + + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + len = GetSccp->len; + if (pclen == MTP3_24BIT_PC) + { + mtp3_iprt.io_msg.msgLength = len + 10+1; + msgptr[0] = outlink; + msgptr[1] = (len+8)>>8; + msgptr[2] = (len+8) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + if(GetSccp->opc==0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetSccp->opc,3); + memcpy(&msgptr[10],&GetSccp->cic[0],1); + memcpy(&msgptr[11],&GetSccp->msgList,len); + } + else + { + if(GetSccp->opc==0) + route_mark = (GetSccp->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetSccp->cic[0] << 28)+(GetSccp->opc << 14)+dpc; + msgptr[0] = outlink; + msgptr[1] = (len+5)>>8; + msgptr[2] = (len+5) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetSccp->msgList,len); + } + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[10]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len + 3); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[2]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len + 3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + +/* in.s_addr = dest_ip; + mtp3_debug(MTP3DB_SCCPMSG,"USER==>MTP3,sio=%x,dpc=%lx",GetSccp->sio,GetSccp->dpc); + mtp3_debug(MTP3DB_SCCPMSG,"perform routing:%dBIT LI=%x LINK=%x IP=%s",pclen,sio,sls,inet_ntoa(in)); + userpart_msg_flow(msgptr);*/ + + } + S_shm_ptr->SM_Buf.RSub ++; + } + return 1; +} + +int get_tup(up_message *GetTup) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = T_shm_ptr->TM_Buf.RSub; + if (rSub != T_shm_ptr->TM_Buf.WSub) + { + + GetTup = &T_shm_ptr->TM_Buf.msgNum[rSub]; + sio = GetTup->sio & 0xcf; + dpc = GetTup->dpc; + sls = GetTup->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetTup->len; + + dest_ip = GetTup->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.tupMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetTup->sio,GetTup->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetTup->msgList,GetTup->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + T_shm_ptr->TM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[3]++; + return 0; + } + } + else + outlink = GetTup->link; + + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len+9)>>8; + msgptr[2] = (len+9) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + //memcpy(&msgptr[6],&mtp3_para->nw[nw].opc24,3); + + if (dest_ip == 0xffffffff) + { + if (GetTup->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetTup->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetTup->opc,3);//keep the UP filled opc + + memcpy(&msgptr[10],&GetTup->cic[0],2); + memcpy(&msgptr[12],&GetTup->msgList,len); + } + else + { + //route_mark = (GetTup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + + if (dest_ip == 0xffffffff) + { + if (GetTup->opc == 0) + route_mark = (GetTup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetTup->cic[0] << 28)+(GetTup->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetTup->cic[0] << 28)+(GetTup->opc << 14)+dpc;//keep the UP filled opc + + msgptr[0] = outlink; + msgptr[1] = (GetTup->len+6)>>8; + msgptr[2] = (GetTup->len+6) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + msgptr[8] = (GetTup->cic[0] >> 4) + (GetTup->cic[1] << 4); + memcpy(&msgptr[9],&GetTup->msgList,len); + } + + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[12]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len+3); + T_shm_ptr->TM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[3]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[3]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + T_shm_ptr->TM_Buf.RSub ++; + } + return 1; +} + +void MTP3_send_isup_count(BYTE nw,BYTE type) +{ + switch (type) + { + case MTP3_ISUP_IAM: + mtp3.nw[nw].flow.isup_detail[16]++; + break; + case MTP3_ISUP_ACM: + mtp3.nw[nw].flow.isup_detail[17]++; + break; + case MTP3_ISUP_CPG: + mtp3.nw[nw].flow.isup_detail[18]++; + break; + case MTP3_ISUP_ANM: + mtp3.nw[nw].flow.isup_detail[19]++; + break; + case MTP3_ISUP_REL: + mtp3.nw[nw].flow.isup_detail[20]++; + break; + case MTP3_ISUP_RLC: + mtp3.nw[nw].flow.isup_detail[21]++; + break; + default: + break; + } +} + +int get_isup(up_message *GetIsup) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = I_shm_ptr->IM_Buf.RSub; + if (rSub != I_shm_ptr->IM_Buf.WSub) + { + + GetIsup = &I_shm_ptr->IM_Buf.msgNum[rSub]; + sio = GetIsup->sio & 0xcf; + dpc = GetIsup->dpc; + sls = GetIsup->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetIsup->len; + + dest_ip = GetIsup->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.isupMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetIsup->sio,GetIsup->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetIsup->msgList,GetIsup->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + } + else + outlink = GetIsup->link; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len + 10)/0xff; + msgptr[2] = (len + 10)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + if (dest_ip == 0xffffffff) + { + if (GetIsup->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetIsup->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetIsup->opc,3);//keep the UP filled opc + + msgptr[10] = GetIsup->cic[0] & 0x0f; + memcpy(&msgptr[11],&GetIsup->cic[0],2); + memcpy(&msgptr[13],&GetIsup->msgList,len); + MTP3_send_isup_count(nw,msgptr[13]); + } + else + { + if (dest_ip == 0xffffffff) + { + if (GetIsup->opc == 0) + route_mark = (GetIsup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetIsup->cic[0] << 28)+(GetIsup->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetIsup->cic[0] << 28)+(GetIsup->opc << 14)+dpc;//keep the UP filled opc + msgptr[0] = outlink; + msgptr[1] = (len+7)/0xff; + msgptr[2] = (len+7)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetIsup->cic,2); + memcpy(&msgptr[10],&GetIsup->msgList,len); + MTP3_send_isup_count(nw,msgptr[10]); + } + + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[14]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len+3); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[4]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + I_shm_ptr->IM_Buf.RSub ++; + } + return 1; +} + +int get_bicc(up_message_2 *GetBicc) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = B_shm_ptr->IM_Buf.RSub; + if (rSub != B_shm_ptr->IM_Buf.WSub) + { + GetBicc = &B_shm_ptr->IM_Buf.msgNum[rSub]; + sio = GetBicc->sio; + dpc = GetBicc->dpc; + sls = GetBicc->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetBicc->len; + + dest_ip = GetBicc->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.biccMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetBicc->sio,GetBicc->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetBicc->msgList,GetBicc->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + B_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + } + else + outlink = GetBicc->link; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len + 12)/0xff; + msgptr[2] = (len + 12)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + //memcpy(&msgptr[6],&mtp3_para->nw[nw].opc24,3); + + if (dest_ip == 0xffffffff) + { + if (GetBicc->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetBicc->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetBicc->opc,3);//keep the UP filled opc + + msgptr[10] = GetBicc->cic[0] & 0x0f; + memcpy(&msgptr[11],&GetBicc->cic[0],4); + memcpy(&msgptr[15],&GetBicc->msgList,len); + } + else + { + //route_mark = (GetBicc->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + + if (dest_ip == 0xffffffff) + { + if (GetBicc->opc == 0) + route_mark = (GetBicc->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetBicc->cic[0] << 28)+(GetBicc->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetBicc->cic[0] << 28)+(GetBicc->opc << 14)+dpc;//keep the UP filled opc + + msgptr[0] = outlink; + msgptr[1] = (len + 9) / 0xff; + msgptr[2] = (len+9) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetBicc->cic,4); + memcpy(&msgptr[12],&GetBicc->msgList,len); + } + mtp3.nw[nw].flow.MtoI[4]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = (msgptr[1]<<8) + msgptr[2]+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + B_shm_ptr->IM_Buf.RSub ++; + } + return 1; +} + +int find_dst_place(long dst,BYTE lsno) +{ + BYTE i; + BYTE nw; + BYTE dpc_place; + ls_info *ls; + + if (lsno > 127) + return -1; + + ls = &mtp3.ls[lsno]; + nw = (mtp3_para->ls_pro[lsno]) & 3; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asNLS[i]; + if ( mtp3_para->nw[nw].dpc[dpc_place] == dst ) + return dpc_place; + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asALS[i]; + if ( mtp3_para->nw[nw].dpc[dpc_place] == dst ) + return dpc_place; + } + return -1; +} + +int find_direct_ls_to_dst(long dst, BYTE nw, long opc) +{ + BYTE i, default_flag=0; + + if(pc_length(nw)==MTP3_14BIT_PC && opc == mtp3_para->nw[nw].opc14) + default_flag = 1; + else if(pc_length(nw)==MTP3_24BIT_PC && opc == mtp3_para->nw[nw].opc24) + default_flag = 1; + + for (i=0; i<128; i++) + { + if (mtp3_para->ls_op_pc[i] == dst && ( (mtp3_para->ls_pro[i] & 3) == nw)) + { + if(mtp3_para->ls_opc[i] == opc ) + return i; + else if(mtp3_para->ls_opc[i] == 0 && default_flag) + return i; + } + } + + mtp3_debug(MTP3DB_EVENT,"dst %d opc %d Can't find direct linkset to destination",dst, opc); + return 128; +} + +int get_chl_via_slc(int linkset,BYTE slc,long msgopc, long msgdpc) +{ + ls_info *ls; + int lsx16; + BYTE nw; + int link; + + if (linkset > 127) + return -1; + if (slc > 15) + return -1; + lsx16 = linkset << 4; + ls = &mtp3.ls[linkset]; + if (mtp3_para->ls_op_pc[linkset] == msgopc) + { + link = ls_slc[lsx16+slc]; + if ( mtp3ObjState.lk_configured[link] == PARA_CONFIGURED ) + return ls_slc[lsx16+slc]; + } + else + { + nw = mtp3_para->ls_pro[linkset] & 3; + linkset = find_direct_ls_to_dst(msgopc,nw, msgdpc); + if ( linkset < 128 ) + { + lsx16 = linkset << 4; + return ls_slc[lsx16+slc]; + } + } + mtp3_debug(MTP3DB_EVENT,"slc %d Can't Find This slc",slc); + return -1; +} + +void send_to_host_mtp3(BYTE *msgptr,DWORD dst_ip) +{ + mtp3_iprt.io_msg.msgSrcPort = SS7_PORT; + mtp3_iprt.io_msg.msgDstPort = SS7_PORT; + mtp3_iprt.io_msg.msgDstIP = dst_ip; + mtp3_iprt.io_msg.msgLength = (msgptr[1]<<8) + msgptr[2]+3; + memcpy(&mtp3_iprt.io_msg.msgContent, msgptr,mtp3_iprt.io_msg.msgLength); +// mtp3_iprt.io_msg.msgContent[0] = msgptr[0]; +// iptrPutMessage(mtp3_iprt.io_msg); + + iptrDirectSendMsg(mtp3_iprt.io_msg); +} + +void mtp3_multicast(BYTE *msgptr) +{ + int i; + DWORD dst_ip; + + for (i=0;ilk[link].e1_to_linkset; + if (lsno > 127) + return; + ls = &mtp3.ls[lsno]; + + nw = (msgptr[3] >> 6) & 3; + pc_len = pc_length(nw); + if (pc_len == MTP3_24BIT_PC) + { + msgtype_offset = 10+1; + memcpy(&MsgOpc,&msgptr[7],3); + memcpy(&MsgDpc, &msgptr[4],3); + slc = msgptr[10] & 0x0f; + } + else + { + memcpy(&MsgOpc,&msgptr[4],4); + slc = (MsgOpc >> 28) & 0x0f; + MsgDpc = MsgOpc & 0x3fff; + MsgOpc = (MsgOpc & 0x0fffffff) >> 14; + msgtype_offset = 7+1; + } + + msgtype = msgptr[msgtype_offset]; + h0 = msgtype & 0x0F; + h1 = (msgtype >> 4) & 0x0f; + switch (h0) + { + case 1:/* COO/COA/CBD/CBA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc, MsgDpc); + if (chl == -1) + return; + if ( (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) && + (src_host == MSG_FROM_MTP2) ) + { + send_to_host_mtp3(msgptr, mtp3ObjState.lk_mtp3[chl]); //<< 16) | 0x010012ac); + return; + } + switch (h1) + { + case 1:/* COO */ + remote_bsnt = msgptr[msgtype_offset+1]; + if (remote_bsnt < 128) + { + mtp3_debug(MTP3DB_EVENT,"link %d RVed COO",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_CHANGEOVER_ORDER; + fsnc[chl] = msgptr[msgtype_offset+1]; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d RECEIVE COO WITH INVALID BSN",chl); + } + break; + case 2:/* COA */ + remote_bsnt = msgptr[msgtype_offset+1]; + if (remote_bsnt < 128) + { + mtp3ObjInput.tcoc_input_from_hmdt[chl] = TCOC_HMDT_COA_COMMAND; + mtp3_debug(MTP3DB_EVENT,"chl %d rv COA",chl); +// printf("chl %d rv COA\n",chl); + fsnc[chl] = msgptr[msgtype_offset+1]; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d RECEIVE COA WITH INVALID BSN",chl); + } + break; + case 5:/* CBD */ + mtp3_debug(MTP3DB_EVENT,"chl %d rev cbd,tcbc state is %d",chl,mtp3ObjState.tcbc_state[chl]); +// printf("chl %d rev cbd,tcbc state is %d\n",chl,mtp3ObjState.tcbc_state[chl]); +// tcbc_input can cause this var override in some case +// tcbc_input[chl] = TCBC_HMDT_CBD_COMMAND; + cbd_cbc_r[chl] = msgptr[msgtype_offset+1]; + hmrt_tcbc_changeback_ack(chl); + break; + case 6:/* CBA */ + mtp3_debug(MTP3DB_EVENT,"chl %d rev cba",chl); +// printf("chl %d rev cba\n",chl); +// tcbc_input[chl] = TCBC_HMDT_CBA_COMMAND; + cba_cbc_r[chl] = msgptr[msgtype_offset+1]; + break; + default: + break; + } + break; + case 2:/* ECO/ECA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc, MsgDpc); + if (chl == -1) + return; + switch (h1) + { + case 1:/* ECO */ + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_ECHANGEOVER_ORDER; + break; + case 2:/* ECA */ + mtp3ObjInput.tcoc_input_from_hmdt[chl] = TCOC_HMDT_ECA_COMMAND; + break; + default: + break; + } + break; + case 4:/* TFP/TFA/ */ + switch (h1) + { + case 1:/* TFP */ + if (src_host == MSG_FROM_MTP2) + { + mtp3_multicast(msgptr); + return; + } + if ( pc_len == MTP3_24BIT_PC ) + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + } + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + if (mtp3_para->ls_op_pc[lsno] == tfdst) + return; + sp_place = find_dst_place(tfdst,lsno); + if ( sp_place == -1 ) + return; + TFPmsg_OPC = MsgOpc; + TFPmsg_SrcLk = link; + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TFP_MSG; + rtpc_proc(nw,sp_place); + break; + + case 5:/* TFA */ + if (src_host == MSG_FROM_MTP2) + { + mtp3_multicast(msgptr); + return; + } + if ( pc_len == MTP3_24BIT_PC ) + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + if (mtp3_para->ls_op_pc[lsno] == tfdst) + return; + sp_place = find_dst_place(tfdst,lsno); + if ( sp_place == -1 ) + return; + TFAmsg_OPC = MsgOpc; + TFAmsg_SrcLk = link; + mtp3.nw[nw].rtac_input[sp_place] = RTAC_TFA_MSG; + rtac_proc(nw,sp_place); + break; + + default: + break; + } + break; + case 5:/* RST */ + if ( pc_len == MTP3_24BIT_PC ) + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + sp_place = find_dst_place(tfdst,lsno); + if (sp_place == -1) + return; + if ( ((mtp3.nw[nw].routine[sp_place] >> 4) & 3) != 1 )/* inaccessable */ + { + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_RSRT_SEND_TFP_MSG; + sdTFP_Ls = lsno;/* send TFP to this linkset's remote sp */ + rtpc_proc(nw,sp_place); + } + else + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_SEND_TFA_MSG; + sdTFA_Ls = lsno; + rtac_proc(nw,sp_place); + } + break; + case 6:/* inhibit message */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + if (chl == -1) + return; + if ( (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) && + (src_host == MSG_FROM_MTP2) ) + { + send_to_host_mtp3(msgptr, mtp3ObjState.lk_mtp3[chl]);// << 16) | 0x010012ac); + return; + } + + switch (h1) + { + case 1:/* LIN */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_SIGLINK; + break; + case 2:/* LUN */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_UINHIBIT_SIGLINK; + break; + case 3:/* LIA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_ACK; + break; + case 4:/* LUA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_UNINHIBIT_ACK; + break; + case 5:/* LID */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_DENIED; + break; + case 6:/* LFU */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK; + break; + case 7:/* LLT */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_LOCAL_INHIBIT_TEST; + break; + case 8:/* LRT */ + chl = get_chl_via_slc(lsno,slc,MsgOpc,MsgDpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_REMOTE_INHIBIT_TEST; + break; + default: + break; + } + break; + case 7:/* TRA */ + if (own_sp_restarting)/* sp restarting */ + { + rv_TRA_num++; + } + else + { + lsno=find_direct_ls_to_dst(MsgOpc,nw,MsgDpc); + if ( (lsno != -1) && + (mtp3.ls[lsno].adjacentsp_restarting==1) ) + {/* from an restarting adjacent sp? */ + if (sending_phase_finished[lsno] == TRUE) + { + sending_phase_finished[lsno] = FALSE; + stop_mtp3T21(lsno); + tsrc_fun5(lsno); + } + else + { + } + } + else + { + for (i=0; i<256; i++) + { + if ( (mtp3.nw[nw].routine[i] & 0x30) == 0 )/* dst inaccessible */ + { + if ( (mtp3_para->nw[nw].normal_ls[i] < 128) || + (mtp3_para->nw[nw].alternative_ls[i] < 128)) + { + mtp3.nw[nw].rtpc_input[i] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = lsno;/* send TFP to this linkset's remote sp */ + tprc_proc(nw,i); + } + } + } + } + } + break; + default: + break; + } +} + +void hmdt_test_msg(BYTE *msgptr) +{ + int i; + BYTE chl; + BYTE linkset; + WORD sp_place; + ls_info *ls=NULL; + BYTE nw; + long route_mark; + BYTE msg_LI; + BYTE len; + BYTE *sd_tmp_buf; + DWORD opc,dpc; + BYTE slc=0; + + chl = msgptr[0]; + linkset = mtp3_para->lk[chl].e1_to_linkset; + nw = (mtp3_para->ls_pro[linkset]) & 3; + ls = &mtp3.ls[linkset]; + sp_place = ls->adjacent_sp_place; + if (sp_place > 255) + return; + + if( msgptr[11] == 0x11 && !(mtp3_para->lk[chl].e1_lk_type & 0x01 )) + { + mtp3_debug(MTP3DB_ERROR,"mtp3 link have been locked , discard sltm msg\r\n"); + return; + } + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if (pc_length(nw) == MTP3_24BIT_PC) + {/* For 24 Bit */ + if (msgptr[11] == 0x11 ) + { + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + slc = msgptr[12] & 0x0f; + else + slc = msgptr[10] & 0x0f; + if (slc != mtp3_para->lk[chl].e1_to_slc)//slc incorrect + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,24BIT,link=%d,slc=%d incorrect,should be %d",chl,slc,mtp3_para->lk[chl].e1_to_slc); + return; + } + memcpy(&dpc,&msgptr[4],3); + memcpy(&opc,&msgptr[7],3); + msg_LI = (msgptr[12] >> 4); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = msgptr[1]; + sd_tmp_buf[2] = msgptr[2]; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6)+2; + else + sd_tmp_buf[3] = (nw << 6)+1; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + //memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3);//?? + memcpy(&sd_tmp_buf[7],&dpc,3); + sd_tmp_buf[10] = msgptr[10]; + sd_tmp_buf[11]= SIGNAL_SLTA; + sd_tmp_buf[12] = msgptr[12]; + for (i=1; i<=msg_LI; i++) + { + len = i + 11; + sd_tmp_buf[len+1] = msgptr[len+1]; + } + send_mtp_msg(chl,sd_tmp_buf); + } + else + { + if (msgptr[13] == chl) + { + + mtp3ObjInput.sltc_input[chl] = SLTA_MSG; + if (mtp3ObjState.sltc_state[chl] != 3) + sltc_proc(chl); + } + } + } + + else/* 14 bit */ + { + if (msgptr[8] == 0x11 ) + { + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + slc = msgptr[9] & 0x0f; + else + slc = (msgptr[7] >> 4) & 0x0f; + if (slc != mtp3_para->lk[chl].e1_to_slc)//slc incorrect + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,14BIT,link=%d,slc=%d incorrect,should be %d",chl,slc,mtp3_para->lk[chl].e1_to_slc); + return; + } + memcpy(&route_mark,&msgptr[4],4); + dpc = route_mark & 0x3FFF; + opc = (route_mark & 0x0FFFFFFF) >> 14; + //route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + (mtp3_para->ls_op_pc[linkset]);//?? + route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (dpc<< 14) + (mtp3_para->ls_op_pc[linkset]); + msg_LI = (msgptr[9] >> 4); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = msgptr[1]; + sd_tmp_buf[2] = msgptr[2]; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_SLTA; + for (i=0; i<=msg_LI; i++) + { + len = i+8; + sd_tmp_buf[len+1] = msgptr[len+1]; + } + send_mtp_msg(chl,sd_tmp_buf); + } + else + { + if (msgptr[10] == chl) + { + mtp3ObjInput.sltc_input[chl] = SLTA_MSG; + if (mtp3ObjState.sltc_state[chl] != 3) + sltc_proc(chl); + } + } + } +} + +int mtp3_Trans_stpMsg(BYTE *msgptr,BYTE outlink,BYTE pc_len) +{ + long dest_ip; + BYTE nw=0; + BYTE ssf=0; + WORD len; + + nw = (msgptr[3] >> 6) & 3; + ssf = msgptr[3] & 7; + len = (msgptr[1]<<8) + msgptr[2] + 3; + + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"mtp3_Trans_stpMsg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + if (ssf>1) + ssf = ssf - 1; + + if (mtp3_para->lk[msgptr[0]].e1_to_linkset == mtp3_para->lk[outlink].e1_to_linkset) + {//to avoid stp back to the incoming linkset + mtp3.nw[nw].flow.stp_loop[ssf]++; + return 0; + } + +// current_measure->tf_measure1[3][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[3][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.stp[ssf]++; + + mtp3_iprt.io_msg.msgLength = len; + mtp3_iprt.io_msg.msgContent[0] = outlink; + + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + { + dest_ip = mtp3ObjState.lk_mtp3[outlink]; + //dest_ip = (dest_ip << 16) | E1CARD_BASE_IP; + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) + { + dest_ip = LINK_TO_IP(outlink); + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + send_to_mtp2(dest_ip); + } + else + { +#if _INCLUDE_M2UA + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + + } + else + { + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return 1; + } +#endif + } + + + + return 1; +} + +void mtp3_print_routeFailure(BYTE sio,BYTE reason) +{ + BYTE debug_type; + + switch(sio & 0x0f) + { + case 0x0: + break; + case 0x1: + debug_type = MTP3DB_SNMMSG; + break; + case 0x3: + debug_type = MTP3DB_SCCPMSG; + break; + case 0x4: + debug_type = MTP3DB_TUPMSG; + break; + case 0x5: + debug_type = MTP3DB_ISUPMSG; + break; + default: + break; + } + + switch (reason) + { + case 0: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:no route\33[0m"); + break; + case 1: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:buf overflow\33[0m"); + break; + case 2: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:network conflict\33[0m"); + break; + default: + break; + } +} + +int mtp3lite_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode) +{ + BYTE ls_t; + + if ((mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3_para->lk[chl].e1_to_mtp3 != mtp3_localip)) + return 0; + + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state != mtp3ObjState.link_l2_state[chl]) + { + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d L2 in service",chl); + mtp3_send_mtp2_alarm(8+chl,0); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3ObjState.link_l1_state[chl] = 1; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 1); + mtp3.ls[ls_t].links_available ++; + hmrt_tcbc_update_routing_tables(chl); + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + mtp3ObjState.lk_mtp3[chl] = mtp3_localip; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d L2 out of service",chl); + mtp3_send_mtp2_alarm(8+chl,alarmCode); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + //mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + //sltc_proc(chl); + mtp3ObjState.link_l1_state[chl] = 0; + mtp3ObjState.link_l2_state[chl] = 0; + mtp3ObjState.lsac_state[chl] = 0; + mtp3ObjState.sltc_state[chl] = 0; + mtp3ObjState.tlac_state[chl] = 0; + if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 0); + hmrt_tcoc_update_routing_tables(chl); + mtp3ObjState.link_l3_state[chl] = 0; + + } + } + + return 1; +} + +int Link_Alternative_Mtp3_SubSystem_State(BYTE Link, BYTE SubSystem) +{ + DWORD AlterMTP3=mtp3_para->lk[Link].e1_to_alterMTP3; + int Idx=-1; + + if ((Idx = MTP3_LinkIP_List(AlterMTP3,0)) >= 0) + { + if (SubSystem < 8) + { + return ((MTP3IPMng.LinkIPSubSta[Idx][0] >> SubSystem) & 1); + } + else + return ((MTP3IPMng.LinkIPSubSta[Idx][1] >> (SubSystem & 7)) & 1); + } + + return 0; +} + +int check_stp_route(BYTE nw, long dpc, BYTE sls) +{ + long opc=0; + int i=0, outlink=0; + int max_opc=mtp3_opc.opc_num[nw]; + + outlink = check_outbound_route(nw,dpc, sls, 0); + if(outlink>=0) + return outlink; + for(i=0; i=0) + return outlink; + } + return -1; +} + +int GetMtp2Msg(DWORD ip_port)/* get ss7 message from iptrans via the 4950:ss7 port,4969:multicast port*/ +{ + BYTE module_id; + BYTE *msgptr=NULL; + BYTE sio; + ls_info *ls; + long route_mark; + BYTE chl; + BYTE routine; + BYTE nw; + BYTE lsnw; + BYTE pc_len; + int outlink; + BYTE sls; + BYTE lsno=0; + BYTE ls_pro; + long opc=0; + long msgdpc=0; + long msgopc=0; + WORD len, tmp_len; + BYTE ssf; + BYTE printmsgsuccess; + BYTE src_host; + BYTE dpc_equal_to_opc; + BYTE tmp_up_message[300]; + +#if _INCLUDE_M2UA + BYTE new_l2_state; + BYTE ls_t; +#endif + + printmsgsuccess = 0; + outlink = 256; +// if (iptrGetMessage(&mtp3_iprt.io_msg,ip_port) > 0) +#if _INCLUDE_M2UA + if (((ip_port == SS7_PORT) && (iptrDirectRecvMsg(&mtp3_iprt.io_msg,ip_port) > 0)) || + ((ip_port == M2UA_PORT) && (!get_m2ua_msg(&mtp3_m2ua_msg)))) +#else + if (((ip_port == SS7_PORT) && (iptrDirectRecvMsg(&mtp3_iprt.io_msg,ip_port) > 0))) +#endif + { + if (ip_port == SS7_PORT) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8 ) + mtp3_iprt.io_msg.msgContent[2]; + if(mtp3_iprt.io_msg.msgContent[1] >=2)//old structure: LINK,len,sio... + {//insert one byte len in msgContent, change to new structure: LINK , len_high,len_low,sio + memcpy(tmp_up_message+2, &mtp3_iprt.io_msg.msgContent[1], mtp3_iprt.io_msg.msgContent[1] + 1); + tmp_up_message[0] = mtp3_iprt.io_msg.msgContent[0]; + tmp_up_message[1] = 0; + memcpy(&mtp3_iprt.io_msg.msgContent[0], tmp_up_message, tmp_up_message[2]+3); + } + else if(tmp_len > 300)//max len = 300 + { + mtp3_debug(MTP3DB_ERROR,"Get message in SS7 port 4950, length longer than 300!"); + return 0; + } + } +#if _INCLUDE_M2UA + if(ip_port == M2UA_PORT) + { + if(1) + {//check len + len = ntohs(mtp3_m2ua_msg->len)+2; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in m2ua, length longer than 300!"); + return 0; + } + len = 0; + } + if( mtp3_send_netcap && ( (mtp3_m2ua_msg->sio & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_m2ua_msg->sio; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_m2ua_msg->sio + , ntohs(mtp3_m2ua_msg->len), 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_m2ua_msg->sio + , ntohs(mtp3_m2ua_msg->len), 0 ); + } + } + + } + else +#endif + { + if( mtp3_send_netcap && ( ( mtp3_iprt.io_msg.msgContent[3] & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_iprt.io_msg.msgContent[3]; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_iprt.io_msg.msgContent[3] + , (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_iprt.io_msg.msgContent[3] + , (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2], 0 ); + } + } + } + if (ip_port == SS7_PORT) + { + msgSourceIP = mtp3_iprt.io_msg.msgSrcIP; + module_id = (msgSourceIP >> 16) & 0xff; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if ( ((msgSourceIP & E1CARD_BASE_IP) == E1CARD_BASE_IP) && + (module_id < 32) ) + { + src_host = MSG_FROM_MTP2; + } + else + src_host = MSG_FROM_MTP3; + } +#ifdef _INCLUDE_M2UA + else + { + src_host = MSG_FROM_MTP2; + if (mtp3_m2ua_msg->sio == 0xEF) + { + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M2UA heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_m2ua_msg->link,ntohs(mtp3_m2ua_msg->len)+2); + + chl = mtp3_m2ua_msg->link; + new_l2_state = mtp3_m2ua_msg->msg.lm.opercode; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state == 0) + mtp3ObjState.link_l1_state[chl] = 0; + else + mtp3ObjState.link_l1_state[chl] = 1; + if ( (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip)) + return 0; + + if ( new_l2_state != mtp3ObjState.link_l2_state[chl] ) + { + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 in service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,0);//clear alarm + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + /* + if ( mtp2->retrieved_bsnt[i] < 128 ) + local_bsnt_retrievable[chl] = TRUE; + else + { + mtp3_debug(MTP3_DEBUG_LOG,"Link %d BSNT RETRIEVE FAILED",chl); + local_bsnt_retrievable[chl] = FALSE; + } + */ + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + + if (mtp3_m2ua_msg->msg.lm.alarmcode == 0) + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,M2UAALARM_Remote_MTP2_down); + else + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,mtp3_m2ua_msg->msg.lm.alarmcode); + } + } + mtp3ObjState.link_l2_state[chl] = new_l2_state; + return 1; + } + else if (mtp3_m2ua_msg->sio == 0xEE)//sg + { + mtp3_send_alarm(MTP3_SG_COMPONENT+mtp3_m2ua_msg->link,mtp3_m2ua_msg->msg.lm.alarmcode); + } + else + { + msgptr = (BYTE *)mtp3_m2ua_msg; + chl = msgptr[0]; + msgSourceIP = mtp3_para->sg[mtp3_para->lk[chl].e1_to_sg].ip; +/* module_id = chl >> 3; + msgSourceIP = module_id; + msgSourceIP = (msgSourceIP << 16) | E1CARD_BASE_IP;*/ + } + } +#endif + + chl = msgptr[0]; + len = (msgptr[1]<<8)+msgptr[2]+3; + sio = msgptr[3]; + nw = sio >> 6; + ssf = sio & 0x0f; + if (ssf > 1) + ssf--; +// current_measure->tf_measure2[1][wx5[nw]+ssf]++;/* MSUs */ +// mtp3.nw[nw].flow.ItoM[ssf]++; + + pc_len = pc_length(nw); + + printmsgsuccess = iptrans_msg_flow(msgptr,pc_len,MTP_MSG_UP,msgSourceIP); + if (src_host == MSG_FROM_MTP2) + { + + current_measure->tf_measure2[1][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM[ssf]++; + src_host = MSG_FROM_MTP2; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno > 127) + { +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + + ls_pro = mtp3_para->ls_pro[lsno]; + lsnw = (ls_pro & 3); + if (lsnw != nw) + { + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,2); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==mtp2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d,linkset=%d",pc_len,sio,msgopc,msgdpc,chl,lsno); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2]+3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:linkset belong to net %d,but sio=%d",lsnw,sio); + } + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + + if (lsno > 127) + { +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + ls = &mtp3.ls[lsno]; + + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + nw = ls_pro & 3; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + opc = mtp3_para->ls_op_pc[lsno]; + memcpy( &msgptr[7],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(mtp3_para->ls_op_pc[lsno] << 14)+opc; + memcpy(&msgptr[4],&route_mark,4); + } + } + else if ( ls_pro & 0x10 ) + { + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + memcpy( &msgptr[4], &mtp3_para->nw[nw].opc24, 3);/* change msg's dpc to opc */ + } + else + { + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + route_mark = (route_mark & 0xFFFFC000) | (mtp3_para->nw[nw].opc14 & 0x3FFF); + memcpy(&msgptr[4],&route_mark,4); + } + } + + if (pc_len == MTP3_24BIT_PC) + { + memcpy(&msgdpc,&msgptr[4],3); + memcpy(&msgopc,&msgptr[7],3); + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + //if (msgdpc != mtp3_para->nw[nw].opc24)/* STP */ + if (!dpc_equal_to_opc) //STP + { + sls = msgptr[10] & 0x0f; + //outlink = check_outbound_route(nw,msgdpc,sls, 0);//?? + outlink = check_stp_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } + } + } + + else/* 14 bit network */ + { + memcpy(&route_mark,&msgptr[4],4); + msgdpc = route_mark & 0x3FFF; + msgopc = (route_mark & 0x0FFFFFFF) >> 14; + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + //if (msgdpc != mtp3_para->nw[nw].opc14)/* STP !!! */ + if (!dpc_equal_to_opc) + { + sls = (route_mark >> 28) & 0x0f; + //outlink = check_outbound_route(nw,msgdpc,sls, 0);//?? + outlink = check_stp_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } + } + } + } + else if (src_host == MSG_FROM_MTP3) + { +#ifdef _M3UA_ + switch(sio) + { + case 0x1f://get route table from other plat + chl = msgptr[0]; + nw = msgptr[4]; + memcpy(&msgdpc, msgptr+5, 4); + memcpy(&msgopc, msgptr+9, 4); + routine = get_route_value(msgdpc, nw, msgopc); + send_route_to_other_plat(msgdpc, nw, routine, mtp3_iprt.io_msg.msgSrcIP, chl, msgopc); + return 1; + case 0x2f: + chl = msgptr[0]; + nw = msgptr[4]; + memcpy(&msgdpc, msgptr+5, 4); + routine = msgptr[9]; + memcpy(&msgopc, msgptr+10, 4); + update_route_by_other_plat(msgdpc,nw, routine, chl, msgopc); + return 1; + default: + break; + } + + +#endif + if (pc_len == MTP3_24BIT_PC) + memcpy(&msgdpc,&msgptr[4],3); + else + { + memcpy(&route_mark,&msgptr[4],4); + msgdpc = route_mark & 0x3FFF; + } + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + if (!dpc_equal_to_opc) + { + if (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) + return 0; + + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN) + send_to_mtp2(LINK_TO_IP(chl)); +#if _INCLUDE_M2UA + else if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]; + if(tmp_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"put_m2ua_msg, length longer than 300, len=%d!", tmp_len); + mtp3_iprt.io_msg.msgContent[1] = 0; + tmp_len= 272; + } + put_m2ua_msg((m2ua_up_msg_t *) mtp3_iprt.io_msg.msgContent); + } + else if (MTP3_LINK_TYPE(chl) == LKTYPE_M3UA) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]; + if(tmp_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"put_m3ua_msg, length longer than 300, len=%d!", tmp_len); + mtp3_iprt.io_msg.msgContent[1] = 0; + tmp_len= 272; + } + send_mtp_msg(chl, mtp3_iprt.io_msg.msgContent); + } +#endif + return 1; + } + } + + if (outlink < 0) + { + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,0); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d",pc_len,sio,msgopc,msgdpc,chl); +// mtp3_debug(msgptr,MTP3_ERROR_LOG,"\33[31m[STP]Route Failed! SIO=%x,DPC=%lx\n\r\33[0m",sio,msgdpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2] + 3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:STP failed"); + } + hmrt_srm_msg(lsno,SIGNAL_TFP,msgdpc); +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.stp_throwed[ssf]++; + return 0; + } + +// current_measure->tf_measure1[2][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[2][wx5[nw]+ssf]++;/* MSUs */ + switch (sio & 0x0f) + { + case MTP3_SUB_SNM: + mtp3.nw[nw].flow.MtoU[0]++; + hmdt_SNM_message_for_distribution(msgptr,src_host); + return 1; + case MTP3_SUB_STM: + mtp3.nw[nw].flow.MtoU[1]++; + hmdt_test_msg(msgptr); + return 1; + case MTP3_SUB_STM2: + mtp3ObjState.lk_SpecANSI_flag[chl] = 1;//mark special T+M + mtp3.nw[nw].flow.MtoU[1]++; + hmdt_test_msg(msgptr); + return 1; + case MTP3_SUB_SCCP: + if ((mtp3_heartbeat.SubState[0] & 0x08) || (MSG_FROM_MTP3==src_host)) + { + if ( (S_shm_ptr->MS_Buf.WSub+1) == S_shm_ptr->MS_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[0]++; + break; + } + send_to_sccp(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_SCCPMSG,"Perform routing:transfer to SCCP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_SCCP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_SCCPMSG,"Perform routing:SCCP UP is Locked,transfer to Alternative SCCP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No SCCP UP Available"); + } + + return 1; + case MTP3_SUB_TUP: + if ((mtp3_heartbeat.SubState[0] & 0x10) || (MSG_FROM_MTP3==src_host)) + { + if ( (T_shm_ptr->MT_Buf.WSub+1) == T_shm_ptr->MT_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[1]++; + break; + } + send_to_tup(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_TUPMSG,"Perform routing:transfer to TUP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_TUP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_TUPMSG,"Perform routing:TUP UP is Locked,transfer to Alternative TUP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No TUP UP Available"); + } + return 1; + case MTP3_SUB_ISUP: + if ((mtp3_heartbeat.SubState[0] & 0x20) || (MSG_FROM_MTP3==src_host)) + { + if ( (I_shm_ptr->MI_Buf.WSub+1) == I_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + send_to_isup(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ISUPMSG,"Perform routing:transfer to ISUP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_ISUP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ISUPMSG,"Perform routing:ISUP UP is Locked,transfer to Alternative ISUP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No ISUP UP Available"); + } + return 1; + case MTP3_SUB_BICC: // BICC + if ((mtp3_heartbeat.SubState[1] & 0x40) || (MSG_FROM_MTP3==src_host)) + { + if ( (B_shm_ptr->MI_Buf.WSub+1) == B_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + send_to_bicc(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_BICCMSG,"Perform routing:transfer to BICC"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_BICC)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_BICCMSG,"Perform routing:BICC UP is Locked,transfer to Alternative BICC UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No BICC UP Available"); + } + return 1; + default: + break; + } + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,1); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d",pc_len,sio,msgopc,msgdpc,chl); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2]+3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:buffer fulled"); + } + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + return 1; +} + +#ifdef _M3UA_ +int m3ua_send_to_sccp(xua_m3ua_msg *msgptr)/* send sccp msg to tele user part */ +{ + up_message *ToSccp; + WORD len; + BYTE nw; + BYTE link; + +// sio = msgptr[3]; + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + nw = msgptr->ni; + ToSccp->sio = (nw <<6) | msgptr->si; + ToSccp->sio = ToSccp->sio | (mtp3_ansiFlag(nw) << 4); +// sio = sio | (mtp3_ansiFlag(nw) << 4); + link = msgptr->link; + ToSccp->link = link; + ToSccp->dest_ip = msgSourceIP; + +// pclen = pc_length(nw); +// if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ +// { +// if (msgptr[1] == 0 && msgptr[2] < 9)//len < 9 +// { +// mtp3ObjState.MTP3WatchDog[3]++; +// mtp3.nw[nw].flow.MtoU_throwed[0]++; +// mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); +// return 0; +// } + +// memcpy((BYTE *)&ToSccp->dpc,msgptr+4,3);/* message's dpc */ +// memcpy((BYTE *)&ToSccp->opc,&msgptr[7],3);/* message's opc */ + ToSccp->dpc = msgptr->dpc; + ToSccp->opc = msgptr->opc; + + ToSccp->cic[0] = msgptr->sls; +// len = (msgptr[1]<<8) + msgptr[2]-8; + len = ntohs(msgptr->len); + ToSccp->len = len; + memcpy(&ToSccp->msgList,msgptr->content, len); + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + return 1; +} + +int m3ua_send_to_bicc(xua_m3ua_msg *msgptr)/* send isup msg to tele user part */ +{ + WORD len; + up_message_2 *ToBicc; + BYTE nw; + + ToBicc = &B_shm_ptr->MI_Buf.msgNum[B_shm_ptr->MI_Buf.WSub]; + nw = msgptr->ni; + ToBicc->sio = (nw<<6) | msgptr->si; + ToBicc->sio = ToBicc->sio | (mtp3_ansiFlag(nw) << 4); + ToBicc->link = msgptr->link; + ToBicc->dest_ip = msgSourceIP; + ToBicc->dpc = msgptr->dpc; + ToBicc->opc = msgptr->opc; + ToBicc->cic[0] = msgptr->content[0]; + ToBicc->cic[1] = msgptr->content[1]; + ToBicc->cic[2] = msgptr->content[2]; + ToBicc->cic[3] = msgptr->content[3]; + len = ntohs(msgptr->len); + ToBicc->len = len-4; + memcpy(&ToBicc->msgList,&msgptr->content[4],len); + B_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int m3ua_send_to_isup(xua_m3ua_msg *msgptr)/* send isup msg to tele user part */ +{ + WORD len; + up_message *ToIsup; + BYTE nw; + + ToIsup = &I_shm_ptr->MI_Buf.msgNum[I_shm_ptr->MI_Buf.WSub]; + nw = msgptr->ni; + ToIsup->sio = (nw<<6) | msgptr->si; + ToIsup->sio = ToIsup->sio | (mtp3_ansiFlag(nw) << 4); + ToIsup->link = msgptr->link; + ToIsup->dest_ip = msgSourceIP; + if (msgptr->len <= 0) + { + mtp3ObjState.MTP3WatchDog[7]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr->len, msgptr->link); + return 0; + } + ToIsup->dpc = msgptr->dpc; + ToIsup->opc = msgptr->opc; + ToIsup->cic[0] = msgptr->content[0]; + ToIsup->cic[1] = msgptr->content[1]; + len = ntohs(msgptr->len) -2; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr->content[2],len); + MTP3_recv_isup_count(nw,msgptr->content[2]); + I_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int m3ua_send_to_tup(xua_m3ua_msg *msgptr)/* send tup msg to tele user part */ +{ + WORD len; + up_message *ToTup; + BYTE nw; + + ToTup = &T_shm_ptr->MT_Buf.msgNum[T_shm_ptr->MT_Buf.WSub]; + nw = msgptr->ni; + ToTup->sio = (nw<<6) | msgptr->si; + ToTup->sio = ToTup->sio | (mtp3_ansiFlag(nw) << 4); + ToTup->link = msgptr->link; + ToTup->dest_ip = msgSourceIP; + if (msgptr->len <= 0) + { + mtp3ObjState.MTP3WatchDog[5]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr->len,msgptr->link); + return 0; + } + ToTup->dpc = msgptr->dpc;/* message's dpc */ + ToTup->opc = msgptr->opc;/* message's opc */ + ToTup->cic[0] = msgptr->content[0]; + ToTup->cic[1] = msgptr->content[1]; + len = ntohs(msgptr->len) - 2; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr->content[2],len); + T_shm_ptr->MT_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[3]++; + return 1; +} + +int check_m3ua_rc_verify(DWORD rc) +{ + int routing_no, nw; + for(nw = 0; nw<4; nw++) + { + for(routing_no = 0; routing_no<256;routing_no++) + { + if(rc==mtp3_para->nw[nw].rc[routing_no]) + return 1; + } + } + return -1; +} +int get_m3ua_rc_by_dpc(BYTE nw, long dpc, long opc)//??- +{ + network *sp; + BYTE i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + ull opc_dpc=0; + + if (dpc==0) + return -3; + + sp = &mtp3.nw[nw]; + if(opc == mtp3_para->nw[nw].opc14 && (pc_length(nw)==MTP3_14BIT_PC)) + opc = 0; + else if(opc == mtp3_para->nw[nw].opc24 && (pc_length(nw)==MTP3_24BIT_PC)) + opc = 0; + opc_dpc = opc; + opc_dpc = (opc_dpc <<32)|dpc; + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,opc_dpc);//??- + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return -3; + return mtp3_para->nw[nw].rc[i]; +} + +int find_rc_dst_place(DWORD rc, BYTE lsno, BYTE nls_als) +{ + BYTE i; + BYTE nw; + BYTE dpc_place; + ls_info *ls; + + if (lsno > 127) + return -1; + + ls = &mtp3.ls[lsno]; + nw = (mtp3_para->ls_pro[lsno]) & 3; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asNLS[i]; + if ( mtp3_para->nw[nw].rc[dpc_place] == rc ) + { + return dpc_place; + } + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asALS[i]; + if ( mtp3_para->nw[nw].rc[dpc_place] == rc ) + { + return dpc_place; + } + } + + return -1; +} + +void m3ua_upd_route_status(BYTE chl, DWORD rc, BYTE rc_status, BYTE ls_disable) +{ + ls_info *ls; + int i; + BYTE lsno, nw,spplace; + int dpc_index; + WORD lsx16; + DWORD dpc,opc; + BYTE *routine; + network *sp; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno >= 0x80) + return; + + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + lsx16 = lsno << 4; + sp = &mtp3.nw[nw]; + + if(!ls_disable) + { + dpc_index = find_rc_dst_place(rc, lsno, 1); + dpc = mtp3_para->nw[nw].dpc[dpc_index]; + opc = mtp3_para->nw[nw].opc[dpc_index]; + if(dpc_index == -1 || dpc_index > 255) + return; + sp->m3ua_rc_status[dpc_index] = rc_status; + } + + if (rc_status!=5) + {// mark_normal_linkset_unavailable(&mtp3.nw[nw].routine[dpc_index]); + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc && ls_disable==0) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + if ( ((sp->routine[spplace] >> 2) & 3) == 0 )/*alternative route available */ + sp->routine[spplace] = (sp->routine[spplace] & 0x3f) + 0x40;/* current route change from normal linkset to alternative linkset */ + else/* sp not accessible */ + { + sp_unaccessable((BYTE *)&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(mtp3_para->nw[nw].dpc[spplace], nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl, mtp3_para->nw[nw].opc[spplace]); + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc && ls_disable==0) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + if ( (sp->routine[spplace] & 3) != 0 )/* normal route unavailable */ + { + sp_unaccessable((BYTE *)&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(mtp3_para->nw[nw].dpc[spplace], nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl, mtp3_para->nw[nw].opc[spplace]); + } + if(ls_disable) + { + memset(&ls_sls[lsx16],0xff,16); + set_heartbeat(ALARM_LS_UNAVAILABLE,lsno); + } + + + } + else + { + sp->m3ua_rc_status[dpc_index] = rc_status; + set_heartbeat(ALARM_LS_AVAILABLE,lsno); + memset(&ls_sls[lsx16],chl,16); + mark_normal_linkset_available(&mtp3.nw[nw].routine[dpc_index]); + routine = (BYTE *)&mtp3.nw[nw].routine[dpc_index]; + if (Nlinkset_status(*routine) == LS_AVAILABLE) + *routine = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + { + (*routine) = ((*routine) & 0x3f) + 0x80; + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[dpc_index],AVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(dpc, nw, sp->routine[dpc_index], mtp3_para->lk[chl].e1_to_alterMTP3, chl, opc); + + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + routine = (BYTE*)&sp->routine[spplace]; + if ( (*routine) >> 6 == 2 )/* no route */ + { + (*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */ + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + + if (Nlinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + (*routine) = ((*routine) & 0x3f) + 0x80; + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(dpc, nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl, opc); + } + + + + } +// if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable +// mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]); +// hmrt_tfrc_update_routing_tables(dpc_index,nw); + +} + + + +int m3ua_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode, DWORD rc, BYTE rc_status) +{ + BYTE ls_t; + + if ((mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip)) + return 0; + + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state != mtp3ObjState.link_l2_state[chl]) + { + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"m3ua link %d L2 in service",chl); + mtp3_debug(MTP3DB_EVENT,"\33[32mM3UA Link %d L3 in service,linkset = %d \33[0m",chl, ls_t); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// mtp3_send_alarm(ls_t+MTP3_LINKSET_COMPONENT,0); + mtp3_send_mtp2_alarm(8+chl,0); + } + set_heartbeat(ALARM_LS_AVAILABLE,ls_t); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3ObjState.link_l1_state[chl] = 1; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + if (mtp3.ls[ls_t].links_available == 0) + mtp3.ls[ls_t].links_available = 1; +/* if (mtp3.ls[ls_t].links_available == 0) + m3ua_upd_route_status(chl, 1, rc, rc_status); + mtp3.ls[ls_t].links_available ++; + hmrt_tcbc_update_routing_tables(chl); +*/ + mtp3ObjState.lk_mtp3[chl] = mtp3_localip; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"m3ua link %d L2 out of service",chl); + mtp3_debug(MTP3DB_EVENT,"\33[31mM3UA Link %d L3 out of service,Linkset %d out of service\33[0m",chl,ls_t); + set_heartbeat(ALARM_LS_UNAVAILABLE,ls_t); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// mtp3_send_alarm(ls_t+MTP3_LINKSET_COMPONENT,1); + mtp3_send_mtp2_alarm(8+chl,M2UAALARM_SCTP_Failure); + } + + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + //mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + //sltc_proc(chl); + mtp3ObjState.link_l1_state[chl] = 0; + mtp3ObjState.link_l2_state[chl] = 0; + mtp3ObjState.link_l3_state[chl] = 0; + mtp3ObjState.lsac_state[chl] = 0; + mtp3ObjState.sltc_state[chl] = 0; + mtp3ObjState.tlac_state[chl] = 0; + m3ua_upd_route_status(chl, rc, 0, 1); + if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; +/* if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 0); + hmrt_tcoc_update_routing_tables(chl); +*/ + } + + } + if(rc!=0) + { + m3ua_upd_route_status(chl, rc, rc_status, 0); + } + + return 1; +} + +int GetM3uaMsg(DWORD port) +{ + xua_m3ua_msg *msgptr = NULL; + xua_lm_lk *lm_lk_ptr = NULL; + xua_rc_cmd *rc_cmd_ptr = NULL; + BYTE nw,dpc_equal_to_opc,ssf; + BYTE new_l2_state, chl; + BYTE rc_status, db_type; + DWORD rc; + WORD m3ua_msg_len; + + if(!get_m3ua_msg(&mtp3_m3ua_msg)) + { + msgptr = &mtp3_m3ua_msg->msg.m3ua; + lm_lk_ptr = &mtp3_m3ua_msg->msg.lm_lk; + rc_cmd_ptr = &mtp3_m3ua_msg->msg.rc_cmd; +/* if( mtp3_send_netcap && ( (mtp3_m3ua_msg->sio & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_m3ua_msg->sio; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_m3ua_msg->sio + , ntohs(mtp3_m3ua_msg->len), 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_m3ua_msg->sio + , ntohs(mtp3_m3ua_msg->len), 0 ); + } + } +*/ + + if(mtp3_m3ua_msg->msg_class == M3UA_MGMT_CMD) + { + + chl = lm_lk_ptr->link; + new_l2_state = lm_lk_ptr->opercode; + m3ua_updateStatus(chl, new_l2_state, 0, 0 ,0); + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA link heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,(BYTE *)mtp3_m3ua_msg,ntohs(lm_lk_ptr->len)+4); + + return 0; + + } + else if(mtp3_m3ua_msg->msg_class == M3UA_RC_CMD) + { + chl = rc_cmd_ptr->link; + rc_status = rc_cmd_ptr->opercode; + rc = rc_cmd_ptr->rc; + m3ua_updateStatus(chl, 5, 0, rc, rc_status); + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA rc heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,(BYTE *)mtp3_m3ua_msg,ntohs(rc_cmd_ptr->len)+4); + return 0; + + } + else if(mtp3_m3ua_msg->msg_class == M3UA_MAUP_MSG)// M3uaMsg + { + nw = msgptr->ni; + ssf = msgptr->si; + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(msgptr->ni, msgptr->dpc); + m3ua_msg_len = ntohs(msgptr->len)+20; + //if (msgdpc != mtp3_para->nw[nw].opc24)/* STP */ + if (!dpc_equal_to_opc) //STP + { + mtp3_debug(MTP3DB_ERROR,"mtp3<==m3ua, dpc=%lx!=local opc, len=%d!", msgptr->dpc, m3ua_msg_len); + mtp3_showbuf(MTP3DB_ERROR,(BYTE *)mtp3_m3ua_msg, m3ua_msg_len); + return 1;//not support STP +/* + sls = msgprt->sls;//msgptr[10] & 0x0f; + outlink = check_outbound_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } +*/ + + } + else + { + switch(msgptr->si) + { + case SCCP_SIO: + if ( (S_shm_ptr->MS_Buf.WSub+1) == S_shm_ptr->MS_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[0]++; + break; + } + m3ua_send_to_sccp(msgptr); + db_type = MTP3DB_SCCPMSG; + mtp3_debug(db_type,"SCCP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case BICC_SIO: + if ( (B_shm_ptr->MI_Buf.WSub+1) == B_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + m3ua_send_to_bicc(msgptr); + db_type = MTP3DB_BICCMSG; + mtp3_debug(db_type,"BICC<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case ISUP_SIO: + if ( (I_shm_ptr->MI_Buf.WSub+1) == I_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + m3ua_send_to_isup(msgptr); + db_type = MTP3DB_ISUPMSG; + mtp3_debug(db_type,"ISUP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case TUP_SIO: + if ( (T_shm_ptr->MT_Buf.WSub+1) == T_shm_ptr->MT_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[1]++; + break; + } + m3ua_send_to_tup(msgptr); + db_type = MTP3DB_TUPMSG; + mtp3_debug(db_type,"TUP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + + default: + db_type = MTP3DB_ERROR; + mtp3_debug(db_type,"MTP3<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + mtp3.nw[msgptr->ni].flow.ItoM_throwed[msgptr->si-1]++; + break; + + } + + mtp3_showbuf(db_type, (BYTE *)mtp3_m3ua_msg, m3ua_msg_len); + } + } + } + return 1; +} + + +int send_command_to_m3ua(BYTE link, BYTE command, BYTE xua_msg_class, DWORD rc) +{ + char charCmd[32]; + + if(xua_msg_class == M3UA_RC_CMD) + { + mtp3_iprt.io_msg.msgLength = 5+1+4; + mtp3_iprt.io_msg.msgContent[0] = xua_msg_class; + mtp3_iprt.io_msg.msgContent[1] = link; + mtp3_iprt.io_msg.msgContent[2] = 0; + mtp3_iprt.io_msg.msgContent[3] = 7; + mtp3_iprt.io_msg.msgContent[8] = command; + memcpy(&mtp3_iprt.io_msg.msgContent[4], &rc, 4); + }else if(xua_msg_class == M3UA_MGMT_CMD) + { + mtp3_iprt.io_msg.msgLength = 5+1; + mtp3_iprt.io_msg.msgContent[0] = xua_msg_class; + mtp3_iprt.io_msg.msgContent[1] = link; + mtp3_iprt.io_msg.msgContent[2] = 0; + mtp3_iprt.io_msg.msgContent[3] = 3; + mtp3_iprt.io_msg.msgContent[4] = ((mtp3ObjState.lk_mtp3[link] >> 16) & 0xff)-32;// 172.18.x+32.1 + mtp3_iprt.io_msg.msgContent[5] = command; + + switch (command) + { + case MTP2_DEACTIVE_LINK: + sprintf(charCmd,"M3UA_DEACTIVE_LINK"); + break; + case MTP3_M3UA_ENABLE: + sprintf(charCmd,"M3UA_ACTIVE_LINK"); + break; + default: + break; + } + } + else + return 0; + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send command %s to m3ua link %d",charCmd,link); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],mtp3_iprt.io_msg.msgLength); + put_m3ua_msg((xua_up_msg_t *) mtp3_iprt.io_msg.msgContent); + return 1; +} + +void deactive_m3ua_lk(BYTE link) +{ + if ((MTP3_LINK_TYPE(link) == LKTYPE_M3UA) && // M3UA + (mtp3_para->lk[link].e1_lk_type & 0x01)) + { + mtp3_debug(MTP3DB_EVENT,"m3ua link %d Deactive by MNG",link); + send_command_to_m3ua(link, MTP3_M3UA_DISABLE,M3UA_MGMT_CMD,0); + m3ua_updateStatus(link, 0, 0, 0 ,0); + + } +} + +void check_m3ua_link_status() +{ + int link,i; + BYTE lsno, nw, spplace; + DWORD rc; + network *sp; + ls_info *ls; + static int link_timer=0; + static int rc_timer=0; + + if(rc_timer >= 200)//2s + { + rc_timer = 0; + for(link=0;link<256; link++) + { + + if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].e1_lk_type & 1)&&(mtp3ObjState.lk_mtp3[link] == mtp3_localip)) + { + if(mtp3ObjState.link_l3_state[link] == AVAILABLE) + { + lsno = mtp3_para->lk[link].e1_to_linkset; + if (lsno >= 0x80) + return; + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + sp = &mtp3.nw[nw]; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + rc = mtp3_para->nw[nw].rc[spplace]; + if (sp->m3ua_rc_status[spplace]==0)/*normal route unavailable */ + { + send_command_to_m3ua(link, 1,M3UA_RC_CMD , rc); + } + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + rc = mtp3_para->nw[nw].rc[spplace]; + if (sp->m3ua_rc_status[spplace]==0)/*alter route unavailable */ + { + send_command_to_m3ua(link, 1, M3UA_RC_CMD, rc); + } + } + } + } + } + } + if(link_timer>=1000)//10s + { + link_timer = 0; + for(link=0;link<256; link++) + { + if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].e1_lk_type & 1) &&(mtp3ObjState.lk_mtp3[link] == mtp3_localip)) + { + if(mtp3ObjState.link_l3_state[link] == UNAVAILABLE) + send_command_to_m3ua(link, MTP3_M3UA_ENABLE,M3UA_MGMT_CMD,0); + } +/* if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && mtp3ObjInput.lsac_input_from_mgmt[link] == LSAC_MGMT_DEACTIVATE_LINK) + { +// mtp3_debug(MTP3DB_EVENT,"m3ua link %d Deactive by other plat MNG",link); +// send_command_to_m3ua(link, MTP3_M3UA_DISABLE,M3UA_MGMT_CMD,0); + deactive_m3ua_lk(link); + mtp3ObjInput.lsac_input_from_mgmt[link] = LSAC_MGMT_ACTIVATE_LINK; + + } +*/ + } + } + link_timer++; + rc_timer++; +} + + +void m3ua_timer() +{ + check_m3ua_link_status(); +} + +void send_mtp_msg(int outlink, BYTE *msgptr) +{ + int linkset; + ls_info *ls; + int ls_pro; + BYTE nw; + DWORD dst_ip; + long opc,dpc; + long route_mark; + BYTE sls; + BYTE pclen; + WORD len; + BYTE ssf; + BYTE debugtype=0; + xua_up_msg_t *m3ua_ptr=NULL; + + if(msgptr == NULL) + { + return; + } + m3ua_ptr = (xua_up_msg_t *)msgptr; + ssf = msgptr[3] & 0x0f; + linkset = mtp3_para->lk[outlink].e1_to_linkset; + ls = &mtp3.ls[linkset]; + ls_pro = mtp3_para->ls_pro[linkset]; + nw = ls_pro & 3; + pclen = pc_length(nw); + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + if ( pclen == MTP3_24BIT_PC ) + { + opc = mtp3_para->nw[nw].opc24; + memcpy( &msgptr[4],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(opc << 14)+opc; + memcpy(&msgptr[4],&route_mark,4); + } + } + + if (ssf > 1) + { + ssf--; + debugtype = MTP_MSG_DOWN; + } + else + debugtype = MTP_SNM_MSG; +// current_measure->tf_measure1[4][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[4][wx5[nw]+ssf]++;/* MSUs */ + +// len = msgptr[1]+2; + len = (msgptr[1]<<8) + msgptr[2]+3; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"send_mtp_msg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + mtp3_iprt.io_msg.msgLength = len; + + if( mtp3_send_netcap && ( ( msgptr[3] & 0xF0) != 0xF0 ) ) + { + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 0 ); + } + } + +#if _INCLUDE_M2UA + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + {//transfer to remote plat + dst_ip = mtp3ObjState.lk_mtp3[outlink]; + //dst_ip = (dst_ip << 16) | E1CARD_BASE_IP; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ +// send_to_mtp2(dst_ip); + send_to_mtp2_new_struct(dst_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) +#endif + { + dst_ip = LINK_TO_IP(outlink); + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + send_to_mtp2(dst_ip);//use old struct send to 8k bload + } +#if _INCLUDE_M2UA + else + { + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + /* debug show message */ + dst_ip = mtp3_para->lk[outlink].remote_ip; + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + return; + } + if (MTP3_LINK_TYPE(outlink) == LKTYPE_M3UA) + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if(pclen == MTP3_24BIT_PC) + { + memmove(m3ua_ptr->msg.m3ua.content, msgptr+11, len-8); + memcpy(&m3ua_ptr->msg.m3ua.dpc,&msgptr[4],3); + memcpy(&m3ua_ptr->msg.m3ua.opc,&msgptr[7],3); + m3ua_ptr->msg_class = M3UA_MAUP_MSG; + m3ua_ptr->msg.m3ua.ni = nw; + m3ua_ptr->msg.m3ua.si = msgptr[3] & 0x0f; + m3ua_ptr->msg.m3ua.len = ntohs(len - 8); + m3ua_ptr->msg.m3ua.mp = 0; + m3ua_ptr->msg.m3ua.sls = sls; + m3ua_ptr->msg.m3ua.rc = get_m3ua_rc_by_dpc(nw, m3ua_ptr->msg.m3ua.dpc, m3ua_ptr->msg.m3ua.opc); + } + else + { + memmove(m3ua_ptr->msg.m3ua.content, msgptr+8, len-5); + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + dpc = route_mark & 0x3fff; + opc = (route_mark >>14)&0x3fff; + m3ua_ptr->msg.m3ua.opc = opc; + m3ua_ptr->msg.m3ua.dpc = dpc; +// memcpy(&m3ua_ptr->msg.m3ua.opc,&msgptr[7],3); + m3ua_ptr->msg_class = M3UA_MAUP_MSG; + m3ua_ptr->msg.m3ua.ni = nw; + m3ua_ptr->msg.m3ua.si = msgptr[3] & 0x0f; + m3ua_ptr->msg.m3ua.len = ntohs(len - 5); + m3ua_ptr->msg.m3ua.mp = 0; + m3ua_ptr->msg.m3ua.sls = sls; + m3ua_ptr->msg.m3ua.rc = get_m3ua_rc_by_dpc(nw, m3ua_ptr->msg.m3ua.dpc, m3ua_ptr->msg.m3ua.opc); + } + m3ua_ptr->msg.m3ua.link = outlink; + + put_m3ua_msg((xua_up_msg_t *)msgptr); + return; + } + else + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return; + } + } +#endif + + +} + +int get_route_from_other_plat(u32 dpc, u8 nw, long dest_ip, BYTE chl, u32 opc) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + mtp3_iprt.io_msg.msgContent[3] = 0x1f; + mtp3_iprt.io_msg.msgContent[4] = nw; + memcpy(&mtp3_iprt.io_msg.msgContent[5], &dpc, 4); + memcpy(&mtp3_iprt.io_msg.msgContent[9], &opc, 4); + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 10; + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + iptrDirectSendMsg(mtp3_iprt.io_msg); + return 1; +} + +void get_routes_from_other_plat() +{ + BYTE link,i; + BYTE lsno, nw, spplace; + DWORD dpc, opc; + network *sp; + ls_info *ls; + + for(link=0; link<0xff;link++) + { + if(mtp3_para->lk[link].e1_lk_type == ((LKTYPE_M3UA<<1)+1)) + { + if(mtp3_para->lk[link].e1_to_mtp3 != mtp3_localip) + { + lsno = mtp3_para->lk[link].e1_to_linkset; + if (lsno >= 0x80) + return; + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + sp = &mtp3.nw[nw]; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + dpc= mtp3_para->nw[nw].dpc[spplace]; + opc= mtp3_para->nw[nw].opc[spplace]; + get_route_from_other_plat(dpc, nw, mtp3_para->lk[link].e1_to_mtp3, link, opc); + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + dpc= mtp3_para->nw[nw].dpc[spplace]; + opc= mtp3_para->nw[nw].opc[spplace]; + get_route_from_other_plat(dpc, nw, mtp3_para->lk[link].e1_to_mtp3, link, opc); + } + } + } + + } +} + +BYTE get_route_value(u32 dpc, u8 nw, u32 opc) +{ + network *sp; + BYTE i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + ull opc_dpc=0; + + if (dpc==0) + return 0; + if(opc == mtp3_para->nw[nw].opc14 && (pc_length(nw)==MTP3_14BIT_PC)) + opc = 0; + else if(opc == mtp3_para->nw[nw].opc24 && (pc_length(nw)==MTP3_24BIT_PC)) + opc = 0; + opc_dpc = opc; + opc_dpc = (opc_dpc <<32)|dpc; + sp = &mtp3.nw[nw]; + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,opc_dpc);//?? + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return 0; + + return sp->routine[i]; +} +int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, BYTE chl, u32 opc) +{ + network *sp; + int i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + ls_info *ls; + BYTE lsno; + WORD lsx16; + BYTE outroute; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ull opc_dpc=0; + if (lsno >= 0x80) + return 0; + if (dpc==0) + return 0; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + + sp = &mtp3.nw[nw]; + if(opc == mtp3_para->nw[nw].opc14 && (pc_length(nw)==MTP3_14BIT_PC)) + opc = 0; + else if(opc == mtp3_para->nw[nw].opc24 && (pc_length(nw)==MTP3_24BIT_PC)) + opc = 0; + opc_dpc = opc; + opc_dpc = (opc_dpc <<32)|dpc; + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,opc_dpc);//??- + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return 0; + sp->routine[i] = routine; + + outroute = (routine >> 6) & 3; + if ( outroute == 2 )/* no outbound route */ + { + memset(&ls_sls[lsx16],0xff,16); + } + else if ( (outroute == 0) && + ((routine & 3) == NLS_AVAILABLE) )/* current route is normal route */ + { + memset(&ls_sls[lsx16],chl,16); + } + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE) + { + memset(&ls_sls[lsx16],chl,16); + } + return 1; +} + +int send_route_to_other_plat(u32 dpc, BYTE nw, BYTE routine, long dest_ip, BYTE chl, u32 opc) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + mtp3_iprt.io_msg.msgContent[3] = 0x2f; + mtp3_iprt.io_msg.msgContent[4] = nw; + memcpy(&mtp3_iprt.io_msg.msgContent[5], &dpc, 4); + mtp3_iprt.io_msg.msgContent[9] = routine; + memcpy(&mtp3_iprt.io_msg.msgContent[10], &opc, 4); + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 11; + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + iptrDirectSendMsg(mtp3_iprt.io_msg); + return 1; + +} + +#endif +/* + * Referenced functions. + */ + +/* + * Forward declarations. + */ + +/* + * Consistent with link set and link functions of: + * + * Signalling Message Handling (SMH) + * Message Routing (HMRT) + * Figure 26/Q.704 + * + * Note:- the HMRT state machine is a single state state machine which is + * best organized as a series of function calls and the interrogation of the + * ls->statem.own_sp_restart flag. These link set and link functions are + * essentially subroutine calls made by the route set and route functions + * which are part of the MTPI. + */ + +void hmrt_tra_msg(BYTE linkset) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + int outlink; + + outlink = check_snmmsg_route(linkset); + if (outlink == -1) + return; + + ls = &mtp3.ls[linkset]; + nw = (mtp3_para->ls_pro[linkset] & 3); + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + //memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + if(mtp3_para->ls_opc[linkset]==0) + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&sd_tmp_buf[7],&mtp3_para->ls_opc[linkset],3); + sd_tmp_buf[10] = 0; + sd_tmp_buf[11] = SIGNAL_TRA; + } + else + { + if(mtp3_para->ls_opc[linkset]==0) + route_mark = (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[linkset]; + else + route_mark = (mtp3_para->ls_opc[linkset] << 14) + mtp3_para->ls_op_pc[linkset]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 6; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_TRA; + } + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); + mtp3.nw[nw].flow.MtoI[0]++; +} + +void sd_STM_msg(BYTE chl, BYTE MsgType) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE H1; + BYTE H0; + BYTE supplymsg; + BYTE ls_no; + int outlink=-1; + BYTE *sd_tmp_buf; + + ls_no = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[ls_no]; + nw = mtp3_para->ls_pro[ls_no] & 3; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[ls_no],3); +// memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + if(mtp3_para->ls_opc[ls_no]==0) + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&sd_tmp_buf[7],&mtp3_para->ls_opc[ls_no],3); + sd_tmp_buf[10] = mtp3_para->lk[chl].e1_to_slc; + sd_tmp_buf[11] = MsgType; + supplymsg = 11+1; + } + else + { + if(mtp3_para->ls_opc[ls_no]==0) + route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[ls_no]; + else + route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (mtp3_para->ls_opc[ls_no] << 14) + mtp3_para->ls_op_pc[ls_no]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 6; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = MsgType; + supplymsg = 8+1; + } + + H0 = MsgType & 0x0F; + H1 = MsgType >> 4; + + switch (H0) + { + case 1: + switch (H1) + { + case 1:/* COO */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = retrieved_bsnt[chl]; + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COO,SUP MSG=%d",chl,sd_tmp_buf[supplymsg]); + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COO,BSNT=%d",chl,retrieved_bsnt[chl]); + outlink = search_outbound_coLink(chl); + break; + case 2:/* COA */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = retrieved_bsnt[chl]; + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COA,SUP MSG=%d",chl,sd_tmp_buf[supplymsg]); + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COA,BSNT=%d",chl,retrieved_bsnt[chl]); + outlink = search_outbound_coLink(chl); + break; + case 5:/* CBD */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = cbc_s[chl]; + outlink = search_outbound_coLink(chl); + break; + case 6:/* CBA */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = cbd_cbc_r[chl]; + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + case 2: + switch (H1) + { + case 1:/* ECO */ + outlink = search_outbound_coLink(chl); + break; + case 2:/* ECA */ + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + case 6: + switch (H1) + { + case 1:// LIN + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 2:// LUN + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 3:// LIA + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 4:// LUA + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 5:// LID + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 6:// LFU + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + outlink=chl; + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 7:// LLT + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 8:// LRT + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + default: + break; + } + if (outlink != -1) + { + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); + } +} + +void hmrt_xxxx_adjacent_sp_restart(ls_info *ls) +{ + if ( own_sp_restarting ) + { + ls->adjacentsp_restarting = 1; + hmrt_xxxx_adjacent_sp_restart(ls); + } +} + +void hmrt_hmdc_message_for_routing(ls_info *ls) +{ +// ls_prim_t *p = (ls_prim_t *)mp->b_rptr; +// chl = &ls->device[p->sig.mh.rl.sls]; + /* + * This function is called only by the MTP state machines (HMCG) to route + * a message once the link set has been selected. + */ +// hmcg_hmrt_message(ls, mp); +} + +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw) +{ + network *sp; + BYTE routine; + + sp = &mtp3.nw[nw]; + routine = sp->routine[dst]; + + if (Nlinkset_status(routine) == LS_AVAILABLE) +// if ( Nls_state == 0 ) + sp->routine[dst] = sp->routine[dst] & 0x3f;/* current route is normal route */ + else if (Alinkset_status(routine) == LS_AVAILABLE) +// else if ( Als_state == 0 ) + sp->routine[dst] = ( sp->routine[dst] & 0x3f ) + 0x40;/* current route is Alternative route */ + else + sp->routine[dst] = ( sp->routine[dst] & 0x3f ) + 0x80;/* no route */ +} + +void hmrt_sltc_signalling_link_test_msg(BYTE chl) +{ + BYTE linkset; + ls_info *ls; + WORD sp_place; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + BYTE slc; + + linkset = mtp3_para->lk[chl].e1_to_linkset; + if (linkset > 127) + { + mtp3_debug(MTP3DB_EVENT,"Warning!! link %d doesn't asign a linkset,stop test procedure",chl); + return; + } + nw = (mtp3_para->ls_pro[linkset]) & 3; + ls = &mtp3.ls[linkset]; + sp_place = ls->adjacent_sp_place; + if (sp_place > 255) + { + mtp3_debug(MTP3DB_EVENT,"Warning!! linkset %d remote SPC doesn't config in the routine table,stop test procedure",linkset); + return; + } + slc = mtp3_para->lk[chl].e1_to_slc; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if (pc_length(nw) == MTP3_24BIT_PC) + { + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 12; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + //memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + if(mtp3_para->ls_opc[linkset]==0) + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&sd_tmp_buf[7],&mtp3_para->ls_opc[linkset],3); + sd_tmp_buf[10] = slc; + sd_tmp_buf[11] = SIGNAL_SLTM; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[12] = 0x20+slc; + else + sd_tmp_buf[12] = 0x20; + sd_tmp_buf[13] = chl; + sd_tmp_buf[14] = slc; + } + else + { + if(mtp3_para->ls_opc[linkset]==0) + route_mark = (slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + (mtp3_para->ls_op_pc[linkset]); + else + route_mark = (slc << 28) + (mtp3_para->ls_opc[linkset] << 14) + (mtp3_para->ls_op_pc[linkset]); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_SLTM; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[9] = 0x20+slc; + else + sd_tmp_buf[9] = 0x20; + sd_tmp_buf[10] = chl; + sd_tmp_buf[11] = slc; + } + + send_mtp_msg(chl,sd_tmp_buf); +} + +void hmrt_tcbc_changeback_ack(BYTE chl) +{ + sd_STM_msg(chl,SIGNAL_CBA); +} + +void hmrt_tcbc_changeback_declaration(BYTE chl) +{ + +/* for ( i=0; i> 2) & 3) == 0 ) + return LS_AVAILABLE; + else + return LS_UNAVAILABLE; +} + +int scan_ls_link_available(BYTE ls_no) +{ + int chl,lk_available; + + lk_available = 0; + for(chl=0; chl < 256; chl++) + { + if(mtp3ObjState.link_l3_state[chl] == AVAILABLE && mtp3_para->lk[chl].e1_to_linkset == ls_no) + lk_available++; + } + return lk_available; +} +void hmrt_tcbc_update_routing_tables(BYTE chl) +{ + BYTE i,j; + ls_info *ls; + network *sp; + DWORD nw; + unsigned int lsno; + WORD lsx16; + DWORD spplace; + BYTE link_num; + unsigned int sls; + BYTE *routine; + BYTE link_already_available; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno > 127) + return; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + nw = mtp3_para->ls_pro[lsno] & 3; + link_num = ls->linksNum_configured; +// link_num = linknum_in_ls[lsno]; + if (link_num == 0) + { + mtp3_debug(MTP3DB_EVENT,"linkset %d havn't config active link",lsno); +// mtp_send_error("Linkset",lsno,"LINKSET HAVN'T CONFIG ACTIVE LINK"); + return; + } + link_already_available = mtp3ObjState.link_l3_state[chl]; + ls->links_available_t = scan_ls_link_available(lsno); + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + set_heartbeat(ALARM_LINK_AVAILABLE,chl); + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0);//clear alarm + + if ( ls->links_available_t > 0 )/* WITHIN LS */ + { + for ( j=0; j<16; j++ ) + { + sls = lsx16+j; + if ( (ls_sls[sls] != chl) && + (sls_to_link[sls] == chl) ) + ls_sls[sls] = chl; + } + } + + else + { + current_active_ls_num++; + current_measure->ls_measure[lsno][2]++;/* STOP of link set failure */ + sp = &mtp3.nw[nw]; + memset(&ls_sls[lsx16],chl,16); + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + routine = (BYTE*)&sp->routine[spplace]; + if (Nlinkset_status(*routine) == LS_AVAILABLE) + *routine = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + { + (*routine) = ((*routine) & 0x3f) + 0x80; + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + routine = (BYTE*)&sp->routine[spplace]; + if ( (*routine) >> 6 == 2 )/* no route */ + { + (*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */ + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + + if (Nlinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + (*routine) = ((*routine) & 0x3f) + 0x80; + } + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(lsno+MTP3_LINKSET_COMPONENT,0); + set_heartbeat(ALARM_LS_AVAILABLE,lsno); + } + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0); + + if ( ls->links_available_t > 0 )/* within ls */ + mtp3_debug(MTP3DB_EVENT,"\33[32mLink %d L3 in service,links_available_t=%d\33[0m",chl, ls->links_available_t); + else + mtp3_debug(MTP3DB_EVENT,"\33[32mLink %d L3 in service,Linkset %d in service\33[0m",chl,lsno); + if(link_already_available != AVAILABLE) + ls->links_available_t++; + else + mtp3_debug(MTP3DB_ERROR,"update routing table fail, links=%d have already available", chl); + current_measure->lk_measure1[chl][1]++;/* local changeback */ +// printf("\r\n tcbc %d update routine cmp link_available = %d \n\r",chl, ls->links_available_t); +} + +void sp_unaccessable(BYTE *routine) +{ + (*routine) = ((*routine) & 0x3f) + 0x80; +} + +void hmrt_tcoc_update_routing_tables(BYTE chl) +{ + BYTE i,j; + ls_info *ls; + network *sp; + DWORD nw; + int lsno; + int lsx16; + BYTE select_slc; + BYTE slc[16]; + DWORD spplace; + int link; + BYTE lk_available; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + + ls->links_available_t = scan_ls_link_available(lsno); + lk_available = mtp3ObjState.link_l3_state[chl]; + nw = mtp3_para->ls_pro[lsno] & 3; + if (link_inhibited[chl] == TRUE) + mtp3ObjState.link_l3_state[chl] = INHIBITED; + else + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + set_heartbeat(ALARM_LINK_UNAVAILABLE,chl); + if (ls->links_available_t > 0 && lk_available == AVAILABLE) + ls->links_available_t--; + else + mtp3_debug(MTP3DB_ERROR,"hmrt_tcoc_update routing table fail, links=%d have already unavailable", chl); + if ( ls->links_available_t > 0 )/* within ls */ + { + j = 0; + for ( i=0; i<16; i++ ) + { + link = ls_slc[lsx16+i]; + if ( (link != chl) && (mtp3ObjState.link_l3_state[link] == AVAILABLE) ) + { + slc[j] = link; + j++; + } + } + + for ( j=0; j<16; j++ ) + { + if (ls_sls[lsx16+j] == chl) + { + if (ls->links_available_t == 0) + { + mtp3_debug(MTP3DB_ERROR,"LINKSET %d ERROR,LINKS AVAILABLE = 0\n\r",lsno); + return; + } + select_slc = (j % ls->links_available_t); + ls_sls[lsx16+j] = slc[select_slc]; + } + } +/* if (mtp3_para->lk[chl].e1_to_mtp3 == mtp3_localip) + mtp3_send_alarm(0,0);*/ + } + + + else/* changeover between link set */ + { + current_measure->ls_measure[lsno][1]++;/* Start of link set failure */ + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + if ( ((sp->routine[spplace] >> 2) & 3) == 0 )/*alternative route available */ + sp->routine[spplace] = (sp->routine[spplace] & 0x3f) + 0x40;/* current route change from normal linkset to alternative linkset */ + else/* sp not accessible */ + { + sp_unaccessable(&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if ( (sp->routine[spplace] & 3) != 0 )/* normal route unavailable */ + { + sp_unaccessable(&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + } + + memset(&ls_sls[lsx16],0xff,16); + + set_heartbeat(ALARM_LS_UNAVAILABLE,lsno); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(lsno+MTP3_LINKSET_COMPONENT,1); + } + + current_measure->lk_measure1[chl][0]++;/* local changeover */ + if ( ls->links_available_t > 0 )/* within ls */ + mtp3_debug(MTP3DB_EVENT,"\33[31mLink %d L3 out of service, links_available_t=%d\33[0m",chl, ls->links_available_t); + else + mtp3_debug(MTP3DB_EVENT,"\33[31mLink %d L3 out of service,Linkset %d out of service\33[0m",chl,lsno); +// printf("/r/ntcoc %d update routine cmp link_available = %d \n",chl, ls->links_available_t); +} + +void send_ip_to_mtp2()/* send message to mtp2, tell mtp2 which is it's host mtp3 */ + /* this message send every 16 second */ +{ + static int mtp2_subsys = 0; + int i,j; + int basePort; + BYTE *msgContent; + BYTE e1_to_mtp3; + + basePort = mtp2_subsys*8; + for (i=0;i<8;i++) + { + if ((mtp3ObjState.lk_mtp3[basePort+i] == mtp3_localip) && + (mtp3ObjState.lk_configured[basePort+i] == PARA_CONFIGURED) ) + { + mtp3_iprt.io_msg.msgLength = 14+1; + mtp3_iprt.io_msg.msgContent[0] = 0; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 12; + mtp3_iprt.io_msg.msgContent[3] = 0xff; + mtp3_iprt.io_msg.msgContent[4] = 0xee; + mtp3_iprt.io_msg.msgContent[5] = 0xff; + msgContent = &mtp3_iprt.io_msg.msgContent[6]; + for (j=0;j<8;j++) + { + + e1_to_mtp3 = mtp3ObjState.lk_mtp3[basePort+j]; + if ((e1_to_mtp3 != mtp3_localip) || + (mtp3ObjState.lk_configured[basePort+j] != PARA_CONFIGURED) ) + msgContent[j] = 0xee; + else + msgContent[j] = ((e1_to_mtp3 >> 16) & 0xff)-32;// 172.18.x+32.1 + } + msgContent[8] = mtp3_para->nw_pro; + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send IP to MTP2 %d",mtp2_subsys); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],14+1); + send_to_mtp2(LINK_TO_IP(basePort)); + break; + } + } + mtp2_subsys = (mtp2_subsys+1) & 0x1f; +} + +void send_command_to_mtp2(BYTE chl, BYTE command) +{ + char charCmd[32]; + + mtp3_iprt.io_msg.msgLength = 5+1; + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 3; + mtp3_iprt.io_msg.msgContent[3] = 0xff; + mtp3_iprt.io_msg.msgContent[4] = ((mtp3ObjState.lk_mtp3[chl] >> 16) & 0xff)-32;// 172.18.x+32.1 + mtp3_iprt.io_msg.msgContent[5] = command; + + switch (command) + { + case MTP2_ACTIVE_LINK: + command3[chl] = MTP2_ACTIVE_LINK; + sprintf(charCmd,"MTP2_ACTIVE_LINK"); + break; + case MTP2_DEACTIVE_LINK: + command3[chl] = MTP2_DEACTIVE_LINK; + sprintf(charCmd,"MTP2_DEACTIVE_LINK"); + break; + case MTP2_STOP_L2: + if (link_inhibited[chl] != TRUE) + { + command3[chl] = MTP2_STOP_L2; + } + else + return; + sprintf(charCmd,"MTP2_STOP_L2"); + break; + case MTP2_EMERGEN_ALIGNMENT: + command3[chl] = MTP2_EMERGEN_ALIGNMENT; + sprintf(charCmd,"MTP2_EMERGEN_ALIGNMENT"); + break; + case MTP2_RETRIEVE:/* not support */ +/* command3[chl] = MTP2_RETRIEVE; + iprt.io_msg.msgLength = 5; + iprt.io_msg.msgContent[1] = 3; + iprt.io_msg.msgContent[4] = fsnc[chl]; + break;*/ + return; + case MTP3_M2UA_ENABLE: + sprintf(charCmd,"ENABLE M2UA LINK"); + break; + default: + break; + } + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN ||MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + { + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send command %s to link %d",charCmd,chl); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],5+1); + } + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN) + send_to_mtp2(LINK_TO_IP(chl)); +#if _INCLUDE_M2UA + else if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + put_m2ua_msg((m2ua_up_msg_t *) mtp3_iprt.io_msg.msgContent); +#endif +} +/*@end@*/ diff --git a/omc/plat/mtp3/src/mtpsrm.c b/omc/plat/mtp3/src/mtpsrm.c new file mode 100644 index 0000000..ba3863a --- /dev/null +++ b/omc/plat/mtp3/src/mtpsrm.c @@ -0,0 +1,336 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void tsrc_fun6(BYTE link,BYTE nw,BYTE sp_place); +void tsrc_fun8(BYTE ls,BYTE nw,BYTE sp_place); +int find_dst_place(long dst,BYTE ls); + +void mark_alternative_linkset_available(BYTE *routine) +{ + (*routine) = ( (*routine) & 0xc3 ) + 0x10;/* mark alternative route use and acessible*/ +} + +void mark_alternative_linkset_unavailable(BYTE *routine) +{ + (*routine) = ((*routine) & 0xf3 ) + 0x08;/* mark alternative route can't use */ +} + +void mark_normal_linkset_available(BYTE *routine) +{ + (*routine) = ((*routine) & 0xcc) + 0x10;/* mark normal route can use,and acessible */ +} + +void mark_normal_linkset_unavailable(BYTE *routine) +{ + (*routine) = ((*routine) & 0xfc) + 0x02;/* mark normal route unavailable */ +} + +void mark_dstSP_inaccessible(BYTE *routine) +{ + (*routine) = ((*routine) & 0xcf);/* mark destination sp inaccessible */ +} + +int find_directLS_to_dst(long dst) +{ + BYTE i; + + for ( i=0; i<128; i++ ) + { + if ( mtp3_para->ls_op_pc[i] == dst ) + return i; + } + return 128; +} + +void tsrc_rtpc_signalling_route_unavailable(BYTE dst, BYTE nw) +{ + BYTE ls; + network *sp; + BYTE msgopc; + BYTE nls; + BYTE als; + + nls = mtp3_para->nw[nw].normal_ls[dst]; + als = mtp3_para->nw[nw].alternative_ls[dst]; + sp = &mtp3.nw[nw]; + msgopc = TFPmsg_OPC; + ls = mtp3_para->lk[TFPmsg_SrcLk].e1_to_linkset; + + if ( ls > 127 ) + return; + if ( mtp3.ls[ls].adjacentsp_restarting == 1 )/* adjacent sp restarting */ + { + if (nls == ls) + mark_normal_linkset_unavailable(&sp->routine[dst]); + else if (als == ls) + mark_alternative_linkset_unavailable(&sp->routine[dst]); + } + else + { + if ( nls == ls ) + { + if ( (sp->routine[dst] >> 6) == 2 ) + return; + tsrc_fun6(TFPmsg_SrcLk,nw,dst); + hmrt_tfrc_update_routing_tables(dst,nw); + } + else if ( als == ls ) + { + tsrc_fun6(TFPmsg_SrcLk,nw,dst); + hmrt_tfrc_update_routing_tables(dst,nw); + } + } +} + +void tsrc_rtac_signalling_route_available(BYTE dst, BYTE nw) +{ + int ls; + network *sp; + DWORD msgopc; + BYTE nls_t; + BYTE als_t; + BYTE current_route; + WORD msgopc_place; + int lsnoRSP_is_msgOPC; + + sp = &mtp3.nw[nw]; + current_route = sp->routine[dst] >> 6; + msgopc = TFAmsg_OPC; + ls = mtp3_para->lk[TFAmsg_SrcLk].e1_to_linkset; + if ( ls > 127 ) + return; + lsnoRSP_is_msgOPC = find_directLS_to_dst(msgopc); + if ( lsnoRSP_is_msgOPC == 128 ) + return;/* msg opc is not any linkset's remote sp */ + msgopc_place = mtp3.ls[lsnoRSP_is_msgOPC].adjacent_sp_place; + if (msgopc_place > 255) + return; + + if ( !own_sp_restarting ) + { + if ( ((sp->routine[msgopc_place] >> 4) & 3) == SP_ACCESSIBLE )/* msg opc accessible */ + tsrc_fun8(ls,nw,dst); + + else/* msg opc inacessible */ + { +// mtp3_debug(MTP3_DEBUG_LOG,"msgopc inacessible\n\r"); + sp->rtac_input[msgopc_place] = RTAC_DEST_ACCESSIBLE;/* send tfa to all adjacent sp */ + + nls_t = mtp3_para->nw[nw].normal_ls[msgopc_place]; + als_t = mtp3_para->nw[nw].alternative_ls[msgopc_place]; + mtp3ObjInput.taprc_input[lsnoRSP_is_msgOPC] = TPRC_ADJACENT_SP_RESTARTING; + + if ( nls_t == ls ) + mark_normal_linkset_available(&sp->routine[msgopc_place]); + else if ( als_t == ls ) + mark_alternative_linkset_available(&sp->routine[msgopc_place]); + current_measure->ls_measure[ls][4]++;/* Broadcast TFA for recovery of measured linkset */ + } + } + hmrt_tfrc_update_routing_tables(msgopc_place,nw); + hmrt_tfrc_update_routing_tables(dst,nw); +} + +void rtpc_proc(BYTE netw,BYTE dst) +{ + network *nw; + BYTE ls; + + nw = &mtp3.nw[netw]; + switch ( nw->rtpc_state[dst] ) + { + case RTPC_IDLE_STATE: + switch ( nw->rtpc_input[dst] ) + { + case RTPC_RSRT_SEND_TFP_MSG:/* not supported */ + nw->rtpc_input[dst] = IDLE; + hmrt_srm_msg(sdTFP_Ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_state[dst] = RTPC_WAIT_STATE; + break; + + case RTPC_TSRC_SEND_TFP_MSG:/* send tfp message to linkset opposit sp */ +// printf("send tfp message to linkset %d,TFDPC=%lx\n",sdTFP_Ls,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_input[dst] = IDLE; + hmrt_srm_msg(sdTFP_Ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_state[dst] = RTPC_WAIT_STATE; + break; + + case RTPC_DEST_INACCESSIBLE:/*one dst inaccessible, send tfp to all adjacent sp about this dst */ + nw->rtpc_input[dst] = IDLE; + for ( ls=0; ls<128; ls++ ) + { + if ((mtp3_para->ls_pro[ls] & 3) == netw) + { +// printf("send tfp message to linkset %d,TFDPC=%lx\n",ls,mtp3_para->nw[netw].dpc[dst]); + hmrt_srm_msg(ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]);/* send tfp to adjacent sp */ + } + } + if (own_sp_restarting == 1) + { +// hmrt_tra_msg(ls);//printf("send tra\n"); + mtp3ObjInput.tprc_input = TPRC_RTPC_TFP_SENT; + } + break; + + case RTPC_TFP_MSG:/* receive TFP from other sp */ +// printf("rtpc dst %d tfp\n",dst); + nw->rtpc_input[dst] = IDLE; + if ( controlled_rerouting_in_progress[dst] == TRUE ) + transfer_prohibited[dst] = TRUE; + else + { + tsrc_rtpc_signalling_route_unavailable(dst,netw); + if (!own_sp_restarting) + { + nw->rsrt_input[dst] = RSRT_RTPC_ROUTE_SET_TEST; + } + //if sp isn't restarting + //start route set test + } + break; + + case RTPC_CTRL_RERT_TERMINATED:/* not supported */ + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = FALSE; + if ( transfer_prohibited[dst] == TRUE ) + { + transfer_prohibited[dst] = FALSE; + //tsrc_rtpc_signalling_route_unavailable + //if sp isn't restarting + //start route set test + } + break; + + case RTPC_CONTROLLED_RERT:/* not supported */ + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = TRUE; + break; + + case RTPC_RESTART_BEGINS: + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = FALSE; + transfer_prohibited[dst] = FALSE; + /* mark sp restarting */ + break; + + case RTPC_RESTART_ENDS: + nw->rtpc_input[dst] = IDLE; + /* cancel sp restarting */ + break; + } + break; + + case RTPC_WAIT_STATE: + nw->rtpc_state[dst] = RTPC_IDLE_STATE; + break; + } +} + +void rtac_proc(BYTE netw,BYTE dst) +{ + network *nw; + BYTE ls; + + nw = &mtp3.nw[netw]; + switch ( nw->rtac_input[dst] ) + { + case RTAC_TFA_MSG: + nw->rtac_input[dst] = IDLE; + tsrc_rtac_signalling_route_available(dst,netw); + nw->rsrt_input[dst] = RSRT_RTAC_ROUTE_AVAILABLE; + break; + + case RTAC_DEST_ACCESSIBLE:// one dst become accessible, send tfa to all adjacent sp about this dst + nw->rtac_input[dst] = IDLE; + for ( ls=0; ls<128; ls++ ) + { + if ( (mtp3_para->ls_pro[ls] & 3) == netw) + { + hmrt_srm_msg(ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]);/* send tfa to adjacent sp */ + } + } + break; + + case RTAC_STP_NOLONGER_FOR_DEST: + nw->rtac_input[dst] = IDLE; + hmrt_srm_msg(sdTFA_Ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]); + break; + + case RTAC_SEND_TFA_MSG: + nw->rtac_input[dst] = IDLE; + hmrt_srm_msg(sdTFA_Ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]); + break; + + case RTAC_FORCED_RERT: + break; + + case RTAC_FORCED_RERT_TERMINATED: + break; + + case RTAC_FORCED_RERT_NOT_REQ: + break; + + case RTAC_RESTART_BEGINS: + break; + + case RTAC_RESTART_ENDS: + break; + } +} + +void rsrt_proc(BYTE netw,BYTE dst) +{ + network *nw; + + nw = &mtp3.nw[netw]; + switch (nw->rsrt_state[dst]) + { + case RSRT_IDLE_STATE: + switch (nw->rsrt_input[dst]) + { + case RSRT_RTPC_ROUTE_SET_TEST: + nw->rsrt_t10[dst] = 0; + nw->rsrt_state[dst] = RSRT_WAIT_STATE; + break; + case RSRT_TSRC_ROUTE_SET_TEST: + hmrt_srm_msg(mtp3_para->nw[netw].normal_ls[dst],SIGNAL_RST,mtp3_para->nw[netw].dpc[dst]); + break; + default: + break; + } + break; + case RSRT_WAIT_STATE: + nw->rsrt_t10[dst] ++; + switch (nw->rsrt_input[dst]) + { + case RSRT_RTPC_ROUTE_SET_TEST: + break; + case RSRT_TSRC_ROUTE_SET_TEST: + break; + case RSRT_RTAC_ROUTE_AVAILABLE: + nw->rsrt_t10[dst] = 0; + nw->rsrt_state[dst] = RSRT_IDLE_STATE; + break; + default: + break; + } + if (nw->rsrt_t10[dst] >= mtp3_para->mtp3_t10) + { + hmrt_srm_msg(mtp3_para->nw[netw].normal_ls[dst],SIGNAL_RST,mtp3_para->nw[netw].dpc[dst]); + //send route test message out + nw->rsrt_t10[dst] = 0; + } + break; + default: + break; + + } + nw->rsrt_input[dst] = IDLE; +} +/*@end@*/ + diff --git a/omc/plat/mtp3/src/mtpstm.c b/omc/plat/mtp3/src/mtpstm.c new file mode 100644 index 0000000..c7b37f0 --- /dev/null +++ b/omc/plat/mtp3/src/mtpstm.c @@ -0,0 +1,2204 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void hmrt_tcoc_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_ack(BYTE chl); +void hmrt_tcoc_changeover_ack(BYTE chl); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void mark_alternative_linkset_available(BYTE *routine); +void mark_alternative_linkset_unavailable(BYTE *routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); + +/* by simon at 23/9/26 */ +mtp3_dpc_index mtp3SortRoutine; +_mtp3_state mtp3ObjState; +_mtp3_input mtp3ObjInput; +_mtp3_IPMng MTP3IPMng; + +void start_mtp3T12(BYTE link) +{ + t12_delay_mtp3[link] = mtp3_para->lt[link].t12; + mtp3_t12_flag[link] = TIMER_START; +} + +void stop_mtp3T12(BYTE link) +{ + t12_delay_mtp3[link] = mtp3_para->lt[link].t12;//not decided + mtp3_t12_flag[link] = TIMER_STOP; +} + +void stop_mtp3T21(BYTE linkset) +{ + t21_delay_mtp3[linkset] = mtp3_para->mtp3_t21; + mtp3_t21_flag[linkset] = TIMER_STOP; +} + +void start_mtp3T21(BYTE linkset) +{ + t21_delay_mtp3[linkset] = mtp3_para->mtp3_t21; + mtp3_t21_flag[linkset] = TIMER_START; +} + +void tsrc_fun5(BYTE linkset) +{ + int i; + BYTE nw; + network *sp; + BYTE sp_place; + ls_info *ls; + BYTE rs_2;/* normal route and alternative route status */ + + if (linkset > 127) + return; + nw = mtp3_para->ls_pro[linkset] & 3; + ls = &mtp3.ls[linkset]; + ls->adjacentsp_restarting = 0;/* cancel adjacent sp restarting */ + + /* not support RSRT */ + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + rs_2 = sp->routine[sp_place]; + if (((rs_2 >> 6) & 3) == 2)// spc unreachable + { + mtp3.nw[nw].rsrt_input[sp_place] = RSRT_TSRC_ROUTE_SET_TEST; + } + if ((Nlinkset_status(rs_2) == LS_AVAILABLE) && + (Alinkset_status(rs_2) == LS_UNAVAILABLE) ) +/* if ( ((rs_2 & 3) == NLS_AVAILABLE) && + (((rs_2 >> 2) & 3) == ALS_UNAVAILABLE) )*/ + {/* sp just accesible */ + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + } + hmrt_tfrc_update_routing_tables(sp_place,nw); + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + rs_2 = sp->routine[sp_place]; + if (((rs_2 >> 6) & 3) == 2)// spc unreachable + { + mtp3.nw[nw].rsrt_input[sp_place] = RSRT_TSRC_ROUTE_SET_TEST; + } + if ((Nlinkset_status(rs_2) == LS_UNAVAILABLE) && + (Alinkset_status(rs_2) == LS_AVAILABLE) ) +/* if ( ((rs_2 & 3) == NLS_UNAVAILABLE) && + (((rs_2 >> 2) & 3) == ALS_AVAILABLE) )*/ + {/* sp just accesible */ + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + } + hmrt_tfrc_update_routing_tables(sp_place,nw); + } +} + +void mtp3T21_expired(BYTE linkset) +{ + tsrc_fun5(linkset); +} + +void start_mtp3T22(BYTE link) +{ + t22_delay_mtp3[link] = 20; + mtp3_t22_flag[link] = TIMER_START; +} + +void start_mtp3T23(BYTE link) +{ + t23_delay_mtp3[link] = 20; + mtp3_t23_flag[link] = TIMER_START; +} + +void start_mtp3T13(BYTE link) +{ + t13_delay_mtp3[link] = mtp3_para->lt[link].t13; + mtp3_t13_flag[link] = TIMER_START; +} + +void stop_mtp3T13(BYTE link) +{ + t13_delay_mtp3[link] = mtp3_para->lt[link].t13; + mtp3_t13_flag[link] = TIMER_STOP; +} + +void stop_mtp3T14(BYTE link) +{ + t14_delay_mtp3[link] = mtp3_para->lt[link].t14; + mtp3_t14_flag[link] = TIMER_STOP; +} + +void start_mtp3T14(BYTE link) +{ + t14_delay_mtp3[link] = mtp3_para->lt[link].t14; + mtp3_t14_flag[link] = TIMER_START; +} + +void mtp3Timer_proc(BYTE i) +{ + if (mtp3_t12_flag[i] == TIMER_START) + { + t12_delay_mtp3[i] --; + if (t12_delay_mtp3[i] == 0) + { + mtp3_t12_flag[i] = TIMER_STOP; + t12_delay_mtp3[i] = mtp3_para->lt[i].t12; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T12_EXPIRED; + } + } + + if (mtp3_t13_flag[i] == TIMER_START) + { + t13_delay_mtp3[i] --; + if (t13_delay_mtp3[i] == 0) + { + mtp3_t13_flag[i] = TIMER_STOP; + t13_delay_mtp3[i] = mtp3_para->lt[i].t13; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T13_EXPIRED; + } + } + + if (mtp3_t14_flag[i] == TIMER_START) + { + t14_delay_mtp3[i] --; + if (t14_delay_mtp3[i] == 0) + { + mtp3_t14_flag[i] = TIMER_STOP; + t14_delay_mtp3[i] = mtp3_para->lt[i].t14; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T14_EXPIRED; + } + } + + if (mtp3_t22_flag[i] == TIMER_START) + { + t22_delay_mtp3[i] --; + if (t22_delay_mtp3[i] == 0) + { + mtp3_t22_flag[i] = TIMER_STOP; + t22_delay_mtp3[i] = mtp3_para->lt[i].t22; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T22_EXPIRED; + } + } + + if (mtp3_t23_flag[i] == TIMER_START) + { + t23_delay_mtp3[i] --; + if (t23_delay_mtp3[i] == 0) + { + mtp3_t23_flag[i] = TIMER_STOP; + t23_delay_mtp3[i] = mtp3_para->lt[i].t23; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T23_EXPIRED; + } + } + + i = i & 127; + if (mtp3_t21_flag[i] == TIMER_START) + { + t21_delay_mtp3[i] --; + if (t21_delay_mtp3[i] == 0) + { + mtp3_t21_flag[i] = TIMER_STOP; + t21_delay_mtp3[i] = mtp3_para->mtp3_t21; + mtp3T21_expired(i); + } + } +} + +void mtp3_send_tfp(BYTE link,BYTE nw,BYTE index) +{ + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + mtp3.nw[nw].rtpc_input[index] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = mtp3_para->lk[link].e1_to_linkset; + rtpc_proc(nw,index); + } +} + +void tsrc_fun6(BYTE link,BYTE nw,BYTE sp_place) +{ + BYTE ls; + BYTE nls; + BYTE als; + BYTE *routine; + int lsx16; + int i; + + network *sp; + sp = &mtp3.nw[nw]; + ls = mtp3_para->lk[link].e1_to_linkset; + + + nls = mtp3_para->nw[nw].normal_ls[sp_place]; + als = mtp3_para->nw[nw].alternative_ls[sp_place]; + + routine = (BYTE*)&sp->routine[sp_place]; + + + if (ls == nls)/* normal route unavailable */ + { +// printf("link %d unavailable,Nls %d UNAVAILABLE\n",link,nls); + mark_normal_linkset_unavailable(&sp->routine[sp_place]); + if (Alinkset_status(*routine) == LS_AVAILABLE) +// if ( (((*routine) >> 2) & 3) == ALS_AVAILABLE )/* Alternative route available */ + /* this destination has alternative route */ + {/* new stp use for destination */ + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { +// printf("link %d send TFP via ALS\n",link); + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = als; + rtpc_proc(nw,sp_place); + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d spc %lx normal linkset %d unavailable,send TFP to Als %d remote sp",nw,mtp3_para->nw[nw].dpc[sp_place],ls,als); + } + //mark new stp used for destination + } + else + { + lsx16 = ls*16; + for (i=0; i<16; i++) + { + if (mtp3ObjState.link_l3_state[ls_slc[lsx16+i]] == INHIBITED) /* some link inhibited in alternative linkset */ + mtp3ObjInput.tlac_input_from_stm[ls_slc[lsx16+i]] = TLAC_UINHIBIT_SIGLINK_FROM_TSRC; + } + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + sp->rtpc_input[sp_place] = RTPC_DEST_INACCESSIBLE;/* broadcast tfp */ + rtpc_proc(nw,sp_place); +// printf("mark send tfp to adjacent sp\n"); + current_measure->ls_measure[ls][3]++;/* Broadcast TFP due to failure of measured link set */ + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx normal linkset %d unavailable,Unreachable!!,broad cast TFP",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + } + else + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx normal linkset %d unavailable,Unreachable!!",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + //tsfc_tsrc_destination_inacessible + } + } + else if (ls == als)/* als unavailable */ + { + mark_alternative_linkset_unavailable(&sp->routine[sp_place]); + if (Nlinkset_status(*routine) == LS_AVAILABLE) +// if ( ((*routine) & 3) == NLS_AVAILABLE ) + { + } + else + { + lsx16 = ls*16; + for (i=0; i<16; i++) + { + if (mtp3ObjState.link_l3_state[ls_slc[lsx16+i]] == INHIBITED) /* some link inhibited in alternative linkset */ + mtp3ObjInput.tlac_input_from_stm[ls_slc[lsx16+i]] = TLAC_UINHIBIT_SIGLINK_FROM_TSRC; + } + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx alternative linkset %d unavailable,broadcast TFP",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + sp->rtpc_input[sp_place] = RTPC_DEST_INACCESSIBLE;/* broadcast tfp */ + rtpc_proc(nw,sp_place); +// printf("mark send tfp to adjacent sp,because als unavailable\n"); + current_measure->ls_measure[ls][3]++;/* Broadcast TFP due to failure of measured link set */ + } + else + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx alternative linkset %d unavailable,Unreachable!!",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + //tsfc_tsrc_destination_inacessible + } + } + if ( (sp->routine[sp_place] & 0x0f) == 0x0a) + { + mark_dstSP_inaccessible(&sp->routine[sp_place]); + } +} + + +void tsrc_fun8(BYTE ls,BYTE nw,BYTE sp_place) +{ + BYTE nls; + BYTE als; + BYTE *routine; + + network *sp; + sp = &mtp3.nw[nw]; + + nls = mtp3_para->nw[nw].normal_ls[sp_place]; + als = mtp3_para->nw[nw].alternative_ls[sp_place]; + + routine = (BYTE*)&sp->routine[sp_place]; + + if ( ((*routine) >> 4) & 3 )/* dst acessible */ + { + if (nls == ls) + { + if (Nlinkset_status(*routine) == LS_UNAVAILABLE) +// if ( ((*routine) & 3) == NLS_UNAVAILABLE) + { + if ( ((*routine) & 0x0C) == ALS_UNAVAILABLE) + {/* new stp use for destination */ + } + else/* als available,route change back to normal route + * stp no longer use for destination */ + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_STP_NOLONGER_FOR_DEST; + sdTFA_Ls = als; + rtac_proc(nw,sp_place); + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc%lx normal linkset %d available,no long use als %d for routing,send TFA to als RSP",nw,mtp3_para->nw[nw].dpc[sp_place],ls,als); + {/* tsrc->rtac stp no longer use for destination */ + } + {/* new stp use for destination */ + } + } + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = ls; + rtpc_proc(nw,sp_place); + } + mark_normal_linkset_available(routine); + } + else if (als == ls) + {/* mark als available */ + mark_alternative_linkset_available(routine); + } + } + else/* dst not accessible */ + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + //tsfc_tsrc_destination_accessible(ls); + if (nls == ls) + { + mark_normal_linkset_available(routine); + if (Nlinkset_status(*routine) == LS_UNAVAILABLE) +// if ( ((*routine) & 3) == NLS_UNAVAILABLE) + {/* new stp use for destination */ + } + } + else if (als == ls) + {/* new stp use for destination */ + mark_alternative_linkset_available(routine); + } + } +} + +void tsrc_fun7(WORD chl, BYTE nw) +{ + WORD lsx8; + BYTE sp_place; + int i; + network *sp; + ls_info *ls; + WORD lsno; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + lsx8 = lsno<<3; + + ls = &mtp3.ls[lsno]; + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + if ( !own_sp_restarting ) + { + tsrc_fun8(lsno,nw,sp_place); + } + else + mark_normal_linkset_available(&sp->routine[sp_place]); + } + + /* select sp that use this linkset for alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + if ( !own_sp_restarting ) + { + tsrc_fun8(lsno,nw,sp_place); + } + else + mark_alternative_linkset_available(&sp->routine[sp_place]); + } +} + +void tsrc_tsrc_signalling_link_set_available(BYTE chl) +{ + int i; + BYTE nw; + network *sp; + WORD lsx8; + BYTE sp_place; + WORD adsp_place; + WORD lsno; + WORD lsx16; + BYTE adsp_acessible; + BYTE owner_of_link; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx8 = lsno << 3; + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + owner_of_link = 1; + else + owner_of_link = 0; + + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return; + adsp_acessible = (mtp3.nw[nw].routine[adsp_place] >> 4) & 3; + + ls->adjacentsp_acessible = TRUE; + current_measure->ls_measure[lsno][7]++;/* Stop of adjacent SP inaccessible */ + + if ( own_sp_restarting )/* local restarting */ + { + if (adsp_acessible == 1) + cb_msg_can_exchange[chl] = TRUE; + else + cb_msg_can_exchange[chl] = FALSE; + tsrc_fun7(chl,nw); + } + else + { + if ( adsp_acessible == 1 )/* adjacent sp acessible */ + { + if (adsp_acessible == 1) + cb_msg_can_exchange[chl] = TRUE; + else + cb_msg_can_exchange[chl] = FALSE; + tsrc_fun7(chl,nw); + } + else/* adjacent sp inacessible */ + { + lsx16 = lsno << 4; + ls->adjacentsp_restarting = 1; + start_mtp3T21(lsno); + sp = &mtp3.nw[nw]; +/*** mark all route available ***/ + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + mark_normal_linkset_available(&sp->routine[sp_place]); + if (Alinkset_status(sp->routine[sp_place]) == LS_AVAILABLE) +// if ( ((sp->routine[sp_place] >> 2) & 3) == ALS_AVAILABLE) + { + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// printf("link %d send TFA via ALS\n",chl); + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFA_Ls = mtp3_para->nw[nw].alternative_ls[lsno]; + rtac_proc(nw,sp_place); + } + } + } + + /* select sp that use this linkset for alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + mark_alternative_linkset_available(&sp->routine[sp_place]); + } +/*** mark all route can available ***/ +// tsfc_tsrc_adjacent_sp_restarting(ls); +// tprc_tsrc_adjacent_sp_restarting(ls); + mtp3.ls[lsno].adjacentsp_restarting = 1;/* mark adjacent sp restarting */ + if (owner_of_link == 1) + mtp3ObjInput.taprc_input[lsno] = TPRC_ADJACENT_SP_RESTARTING; +// mtp3_debug(MTP3DB_EVENT,"chl %d,linkset %d adjacent sp restarting",chl,lsno); + } + } +} + +void tsrc_tsrc_signalling_link_set_unavailable(BYTE chl) +{ + BYTE i; + BYTE nw; + network *sp; + WORD lsx8; + BYTE sp_place; + WORD lsno; + WORD adsp_place; + BYTE owner_of_link; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx8 = lsno << 3; + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + owner_of_link = 1; + else + owner_of_link = 0; + + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return; + + if ( (mtp3.nw[nw].routine[adsp_place] & 0x0f) == 0 )/* normal and alternative route are available before */ + co_msg_can_exchange[chl] = TRUE; + else + { + ls->adjacentsp_acessible = FALSE; + current_measure->ls_measure[lsno][5]++;/* Adjacent SP inaccessible */ + co_msg_can_exchange[chl] = FALSE; + } + + sp = &mtp3.nw[nw]; + /* select sp that use this linkset as normal route */ + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + if ( own_sp_restarting ) + { + mark_normal_linkset_unavailable(&sp->routine[sp_place]); + if (Alinkset_status(sp->routine[sp_place]) != LS_AVAILABLE) + { +// if ( ((sp->routine[sp_place] >> 2) & 3) != ALS_AVAILABLE )/* Alternative route available */ + mark_dstSP_inaccessible(&sp->routine[sp_place]); + printf("mark inaccessible\n"); + } + } + else + tsrc_fun6(chl,nw,sp_place); + } + + /* select sp that use this linkset as alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + if ( own_sp_restarting ) + { + mark_alternative_linkset_unavailable(&sp->routine[sp_place]); + if (Nlinkset_status(sp->routine[sp_place]) != LS_AVAILABLE) +// if ( (sp->routine[sp_place] & 3) != NLS_AVAILABLE )/* normal route unavailable */ + mark_dstSP_inaccessible(&sp->routine[sp_place]); + } + else + tsrc_fun6(chl,nw,sp_place); + } +} + +int inhibit_allow_or_not(BYTE ls,BYTE nw) +{ + int dpc; + BYTE routine; + + for (dpc=0; dpc<256; dpc++) + { + routine = mtp3.nw[nw].routine[dpc]; + if ( (mtp3_para->nw[nw].normal_ls[dpc] == ls) && + (Alinkset_status(routine) == LS_UNAVAILABLE) ) +// (((routine >> 2) & 3) == ALS_UNAVAILABLE) ) + return FALSE; + else if ( (mtp3_para->nw[nw].alternative_ls[dpc] == ls) && + (Nlinkset_status(routine) == LS_UNAVAILABLE) ) +// ((routine & 3) == NLS_UNAVAILABLE) ) + return FALSE; + } + return TRUE; +} + +void tsrc_fun15(BYTE chl,BYTE inhibit_req_by) +{ + switch (inhibit_req_by) + { + case LOCAL_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_LOCAL_INHIBIT_DENIED; + break; + case REMOTE_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_REMOTE_INHIBIT_DENIED; + break; + } +} + +void tsrc_inhibit_allow(BYTE chl,BYTE inhibit_req_by) +{ + switch (inhibit_req_by) + { + case LOCAL_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_LOCAL_INHIBIT_ALLOWED; + break; + case REMOTE_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_REMOTE_INHIBIT_ALLOWED; + link_inhibited[chl] = TRUE;/* mark link inhibited */ + break; + } +} + +void tsrc_fun13(BYTE chl,BYTE inhibit_req_by) +{ + BYTE ls; + BYTE nw; + BYTE route_st; + int inhibit; + WORD sp_place; + + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d rv inhibit request from tlac",chl); + + ls = mtp3_para->lk[chl].e1_to_linkset; + nw = mtp3_para->ls_pro[ls] & 3; + if (mtp3ObjState.link_l3_state[chl] == UNAVAILABLE)/* link l3 state unavailable */ + { + sp_place = mtp3.ls[ls].adjacent_sp_place; + if (sp_place > 255) + return; + route_st = (mtp3.nw[nw].routine[sp_place] >> 4) & 3; + if (route_st == SP_ACCESSIBLE)/* remote sp can access */ + { + tsrc_inhibit_allow(chl,inhibit_req_by); + } + else/* remote sp can't access */ + { + tsrc_fun15(chl,inhibit_req_by);/* [inhibit dennid] */ + } + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + } + else/* link l3 state available */ + { + if (mtp3.ls[ls].links_available == 1)/* there is only one link left available in this linkset */ + { + inhibit = inhibit_allow_or_not(ls,nw); + if (inhibit == FALSE)/* inhibit this link maybe can cause one dpc not accessable */ + tsrc_fun15(chl,inhibit_req_by);/* [inhibit dennid] */ + else/* inhibit this link will not cause any dpc not accessable */ + tsrc_inhibit_allow(chl,inhibit_req_by); + } + else/* there is another available link in this linkset */ + tsrc_inhibit_allow(chl,inhibit_req_by); + } +} + +void tsrc_proc(BYTE chl) +{ + BYTE cc_lk_num; + WORD lsno; + BYTE rmSP_routine;/* remote sp routine */ + WORD rmSP_place; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + + switch (mtp3ObjState.tsrc_state[chl]) + { + case TSRC_IDLE_STATE: + switch (mtp3ObjInput.tsrc_input_from_tlac[chl]) + { + case TSRC_TLAC_LINK_UNAVAILABLE: +// printf("tsrc link %d unavailable\n",chl); + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + if (ls->links_available > 0) + ls->links_available--; + // if ( /* emergency see 12.2.4 */ ) +// lk_llsc_tsrc_emergency(lk); + if ( ls->links_available == 0 ) + { + changeover_select[chl] = BETWEEN_LS; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d unavailable,linkset %d unavailable",chl,lsno); + tsrc_tsrc_signalling_link_set_unavailable(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d unavailable",chl); + co_msg_can_exchange[chl] = TRUE; + changeover_select[chl] = WITHIN_LS; + } + break; + + case TSRC_TLAC_LINK_AVAILABLE: +// printf("tsrc link %d available\n",chl); + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_available[chl] = AVAILABLE; + ls->links_available++; + // if ( /* not emergency see 12.2.4 */ ) + // lk_llsc_tsrc_emergency_ceases(lk); + if ( ls->links_available == 1 )/* no other links available in linkset */ + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d available,linkset available",chl); + tsrc_tsrc_signalling_link_set_available(chl); + changeback_select[chl] = BETWEEN_LS; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d available",chl); + changeback_select[chl] = WITHIN_LS; + cb_msg_can_exchange[chl] = TRUE; + } + break; + + case TSRC_TLAC_LOCAL_INHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + tsrc_fun13(chl,LOCAL_INHIBIT_REQ); + break; + + case TSRC_TLAC_REMOTE_INHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + tsrc_fun13(chl,REMOTE_INHIBIT_REQ); + break; + + case TSRC_TLAC_LINK_INHIBITED: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_inhibited[chl] = TRUE; + break; + + case TSRC_TLAC_CANCEL_LINK_INHIBITED: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_inhibited[chl] = FALSE; + break; + + case TSRC_TLAC_UNINHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + rmSP_place = mtp3.ls[lsno].adjacent_sp_place; + if (rmSP_place > 255) + return; + rmSP_routine = mtp3.nw[mtp3_para->ls_pro[lsno] & 3].routine[rmSP_place]; + if ( ((rmSP_routine >> 4) & 1) == SP_INACCESSIBLE)/* no route */ + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_UNINHIBIT_NOT_POSSIBLE; + else + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_UNINHIBIT_POSSIBLE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_tcoc[chl]) + { + case TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST: + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + /* obtain alternative routing data according to rules specified in Q.704 4.4 */ + /* during SP restart the adjacent SP is considered inaccessible */ + /* locally or request from MTP level state machine */ +/********/ +/********/ changeover_required[chl] = TRUE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = TCOC_ALTERATIVE_ROUTE_DT; + mtp3ObjState.tsrc_state[chl] = TSRC_WAIT01_STATE; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d tcoc asking for alternative route date",chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_tcbc[chl]) + { + case TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST: + mtp3ObjInput.tsrc_input_from_tcbc[chl] = IDLE; + cc_lk_num = 0; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + /* obtain alternative routing data */ + /* during SP restart the adjacent SP is considered inaccessible */ + /* locally or request from MTP level state machine */ + if ( changeback_select[chl] == BETWEEN_LS )/* this is the first link */ + { +// mtp3_debug(MTP3DB_EVENT,"link %d changeback_select BETWEEN_LS",chl); + /* but change back message will not exchange between link set */ + } + else + { + } +// printf("tsrc link %d tcbc alter data cmp\n",chl); + mtp3ObjInput.tcbc_input_from_tsrc[chl] = TCBC_ALTERATIVE_ROUTE_DT; + mtp3ObjState.tsrc_state[chl] = TSRC_WAIT02_STATE; + tcbc_route_change[chl] = TRUE; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d tcbc asking for alternative route date",chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_stm[chl]) + { + default: + break; + } + + case TSRC_WAIT01_STATE:/* 1 TSRC_WAIT1_STATE */ + if (mtp3ObjInput.tsrc_input_from_tcoc[chl] == TSRC_TCOC_CHANGEOVER_EXECUTED) + { + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + changeover_completed[chl] = 1; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + else if (mtp3ObjInput.tsrc_input_from_tcoc[chl] == TSRC_TCOC_CHANGEOVER_NOT_REQ) + { + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + break; + + case TSRC_WAIT02_STATE:/* 2 TSRC_WAIT2_STATE */ + if ( mtp3ObjInput.tsrc_input_from_tcbc[chl] == TSRC_PROCEDURE_TERMINATED ) + { + mtp3ObjInput.tsrc_input_from_tcbc[chl] = IDLE; + changeover_completed[chl] = 0; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + break; + + case TSRC_WAIT03_STATE: + break; + case TSRC_WAIT04_STATE: + break; + case TSRC_WAIT05_STATE: + /* this state's function put in the tprc state machine */ + break; + default: + break; + } +} + +void tlac_fun5(BYTE link) +{ + mtp3ObjInput.tcbc_input[link] = TCBC_LINK_AVAILABLE; + changeback_in_progress[link] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[link] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjState.tlac_state[link] = TLAC_AVAILABLE_STATE; +} + +void tlac_fun6(BYTE link) +{ + if (changeover_in_progress[link] == TRUE) + { + mtp3ObjInput.tcoc_input_from_stm[link] = TCOC_LINK_AVAILABLE; + } + else + tlac_fun5(link); +} + +void tlac_fun7(BYTE link) +{ + sd_STM_msg(link,SIGNAL_LUN); + uninhibit_in_progress[link] = TRUE; + start_mtp3T12(link); +} + +void tlac_fun1(BYTE link) +{ + if (changeback_in_progress[link] == TRUE) + { +// mtp3_debug(MTP3DB_EVENT,"changeback in progress"); + link_available[link] = FALSE; + } + else + { + changeover_in_progress[link] = TRUE; + mtp3ObjInput.tcoc_input_from_stm[link] = TCOC_LINK_UNAVAILABLE; + } + mtp3ObjInput.tsrc_input_from_tlac[link] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjState.tlac_state[link] = TLAC_UNAVAILABLE_STATE; +} + +void mgmt_tlac_proc(BYTE link,BYTE input) +{ + switch (input) + { + case 0: + break; + case 1: + break; + } +} + +void tlac_proc(BYTE chl) +{ + ls_info *ls; + int lsno; + + if (init_tlac_state[chl] == TRUE) + { + init_tlac_state[chl] = IDLE; + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + changeover_in_progress[chl] = FALSE; + changeback_in_progress[chl] = FALSE; + failed[chl] = TRUE; + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + return; + } + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + switch (mtp3ObjState.tlac_state[chl]) + { + case TLAC_UNAVAILABLE_STATE: + switch (mtp3ObjInput.tlac_input_from_mgmt[chl]) + { + case TLAC_MGMT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ; + current_measure->lk_measure1[chl][7]++;//Local management inhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv local MGMT inhibit request in unavailable state",chl); + break; + case TLAC_MGMT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + management_req[chl] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_UNINHIBIT_REQ; + current_measure->lk_measure1[chl][8]++;//Local management uninhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv local MGMT uninhibit request in unavailable state",chl); + break; + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_remotely_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIN,send LIA",chl); + sd_STM_msg(chl,SIGNAL_LIA);/* send inhibit ack signal */ + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIN,send LIA,mark Inhibited",chl); + link_remotely_inhibited[chl] = TRUE; + link_locally_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LIA); + mtp3ObjState.link_l3_state[chl] = INHIBITED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + start_mtp3T22(chl); + } + break; + + case TLAC_HMDT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(unavai)]link %d (inhibited) rv LUN,send LUA",chl); + link_remotely_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LUA); + stop_mtp3T13(chl); + if (link_locally_inhibited[chl] != TRUE) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_CANCEL_LINK_INHIBITED; + link_inhibited[chl] = FALSE; + if ( (blocked_by[chl] == IDLE) && + (failed[chl] != TRUE) ) + tlac_fun6(chl); + else + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + } + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(unavai)]link %d (unavailable) rv LUN,send LUA",chl); + sd_STM_msg(chl,SIGNAL_LUA); + } + break; + + case TLAC_HMDT_INHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (local_inhibit_in_progress[chl] == TRUE) + { + link_locally_inhibited[chl] = TRUE; + link_remotely_inhibited[chl] = FALSE; + link_inhibited[chl] = TRUE; + mtp3ObjState.link_l3_state[chl] = INHIBITED; + local_inhibit_in_progress[chl] = FALSE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIA,TLAC->TSRC:LINK INHIBITED",chl); + stop_mtp3T14(chl); + } + start_mtp3T22(chl); + break; + + case TLAC_HMDT_UNINHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LUA",chl); + if (uninhibit_in_progress[chl] == TRUE) + { + management_req[chl] = FALSE; + uninhibit_in_progress[chl] = FALSE; + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + stop_mtp3T12(chl); + if (link_remotely_inhibited[chl] != TRUE) + { + link_inhibited[chl] = FALSE; + link_locally_inhibited[chl] = FALSE; +// mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_CANCEL_LINK_INHIBITED; + if ( (blocked_by[chl] == IDLE) && + (failed[chl] != TRUE) ) + tlac_fun6(chl); + } + } + break; + + case TLAC_HMDT_INHIBIT_DENIED: + break; + + case TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d (inhibited) rv LFU",chl); + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LFU",chl); + sd_STM_msg(chl,SIGNAL_LUN); + } + break; + + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if ( changeover_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv COO,TLAC->TCOC:COO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv COO,send ECA",chl); + hmrt_tcoc_emergency_changeover_ack(chl); + } + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if ( changeover_in_progress[chl] == TRUE) /*changeover is executing */ + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv ECO,TLAC->TCOC:ECO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv ECO,send ECA",chl); + sd_STM_msg(chl,SIGNAL_ECA); + } + break; + + case TLAC_HMDT_LOCAL_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_remotely_inhibited[chl] != TRUE) + { + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + break; + case TLAC_HMDT_REMOTE_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_locally_inhibited[chl] != TRUE) + { + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + } + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_TCBC_CHANGEBACK_TERMINATED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeback_in_progress[chl] = FALSE; + if ( changeover_order[chl] == TRUE) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + else if ( emergency_changeover_order[chl] == TRUE) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + else if ( link_available[chl] != TRUE ) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_UNAVAILABLE; + link_available[chl] = IDLE; + changeover_order[chl] = IDLE; + emergency_changeover_order[chl] = IDLE; + changeover_in_progress[chl] = TRUE;/* mark change over in progress */ + break; + + case TLAC_TCOC_CHANGEOVER_EXECUTED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeover_in_progress[chl] = IDLE;/* cancel mark */ + if (link_inhibited[chl] != TRUE) + { + if ( failed[chl] != TRUE ) + { + tlac_fun5(chl); + } + } + break; + + case TLAC_LOCAL_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d local inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LIN); + local_inhibit_in_progress[chl] = TRUE; + start_mtp3T14(chl); + break; + + case TLAC_REMOTE_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d remote inhibit allow",chl); + break; + case TLAC_LOCAL_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d local inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + break; + + case TLAC_REMOTE_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d remote inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + break; + + case TLAC_UINHIBIT_SIGLINK_FROM_TSRC: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv uninhibit sig from TSRC",chl); + if (uninhibit_in_progress[chl] != TRUE) + { + uninhibit_in_progress[chl] = TRUE; + if ( (blocked_by[chl] != IDLE) || + (failed[chl] == TRUE) ) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit no success, blocked or failed",chl); + } + else + { + if (link_locally_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d send LUN",chl); + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + } + else if (link_remotely_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d send LFU",chl); + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d is not being local or remotely inhibited",chl); + } + } + } + else + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit in progress",chl); + break; + + case TLAC_UNINHIBIT_NOT_POSSIBLE: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit not possible",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + if ( (blocked_by[chl] != IDLE) && + (failed[chl] == TRUE) ) + { + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + management_req[chl] = FALSE; + } + else + { + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + } + break; + + case TLAC_UNINHIBIT_POSSIBLE: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit possible",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + break; + + case TLAC_RESTART_BEGINS: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mtp3ObjState.tlac_state[chl] = TLAC_SP_RESTARTING_STATE; + break; + + case TLAC_TCOC_CHANGEOVER_NOT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeover_in_progress[chl] = IDLE;/* cancel mark */ + if ( failed[chl] != TRUE ) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = FALSE;/* cancel mark link fail */ + if (link_inhibited[chl] != TRUE) + { + if (changeover_in_progress[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d in service,changeover in progress,TLAC->TCOC:LINK AVAILABLE",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_AVAILABLE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d in service,TLAC->TSRC(TCBC):LINK AVAILABLE",chl); + tlac_fun5(chl); + } + } + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_Tctl[chl]) + { + case TLAC_T12_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + uninhibit_in_progress[chl] = FALSE;/* cancel uninhibit in progress */ + if (t12_expired_2nd_time[chl] == TRUE) + { + t12_expired_2nd_time[chl] = FALSE; + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + } + else + { + t12_expired_2nd_time[chl] = TRUE; + if (management_req[chl] == TRUE) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_UNINHIBIT_REQ; + } + else + tlac_fun7(chl); + } + break; + case TLAC_T13_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (t13_expired_2nd_time[chl] == TRUE) + { + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + } + else + { + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + break; + case TLAC_T14_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + local_inhibit_in_progress[chl] = FALSE;/* cancel local inhibit in progress */ + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ;/* local inhibit request */ + break; + case TLAC_T22_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (link_locally_inhibited[chl] == TRUE) + { + sd_STM_msg(chl,SIGNAL_LLT); + start_mtp3T22(chl); + } + break; + case TLAC_T23_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (link_remotely_inhibited[chl] == TRUE) + { + sd_STM_msg(chl,SIGNAL_LRT); + start_mtp3T23(chl); + } + break; + default: + break; + } + + break; + + case TLAC_AVAILABLE_STATE: + switch (mtp3ObjInput.tlac_input_from_mgmt[chl]) + { + case TLAC_MGMT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ; + current_measure->lk_measure1[chl][7]++;//Local management inhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv local MGMT uninhibit request",chl); + break; + case TLAC_MGMT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + current_measure->lk_measure1[chl][8]++;//Local management uninhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv local MGMT uninhibit request",chl); + break; + default: + break; + } + + switch ( mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_INHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LIN",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_REMOTE_INHIBIT_REQ; + break; + + case TLAC_HMDT_UINHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LUN",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUA); + break; + + case TLAC_HMDT_INHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (local_inhibit_in_progress[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv LIA,inhibit in progress",chl); + link_locally_inhibited[chl] = TRUE; + link_remotely_inhibited[chl] = FALSE; + local_inhibit_in_progress[chl] = FALSE; + stop_mtp3T14(chl); + link_inhibited[chl] = TRUE; +// mtp3ObjInput.tsrc_input_from_stm[chl] = TSRC_TLAC_LINK_INHIBITED; + mgmt_tlac_proc(chl,MGMT_TLAC_LINK_INHIBITED); + start_mtp3T22(chl); + tlac_fun1(chl); + } + else + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LIA",chl); + break; + + case TLAC_HMDT_UNINHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + break; + + case TLAC_HMDT_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LID",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mgmt_tlac_proc(chl,MGMT_INHIBIT_DENIED); + local_inhibit_in_progress[chl] = FALSE; + stop_mtp3T14(chl); + break; + + case TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LFU",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + break; + + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + failed[chl] = TRUE;/* mark failed */ + if ( changeback_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv COO command,changeback in progress",chl); + changeover_order[chl] = TRUE;/* mark received coo command */ + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv COO command,TLAC->TCOC:COO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + changeover_in_progress[chl] = TRUE; + } + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + failed[chl] = TRUE; + if ( changeback_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv ECO command,changeback in progress",chl); + emergency_changeover_order[chl] = TRUE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv EOO command,TLAC->TCOC:EOO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + changeover_in_progress[chl] = TRUE; + } + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_HMDT_LOCAL_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + break; + case TLAC_HMDT_REMOTE_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_TCBC_CHANGEBACK_TERMINATED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeback_in_progress[chl] = FALSE; + break; + + case TLAC_TCOC_CHANGEOVER_EXECUTED: + break; + + case TLAC_TCOC_CHANGEOVER_NOT_REQ: + break; + + case TLAC_LOCAL_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d local inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LIN); + local_inhibit_in_progress[chl] = TRUE; + start_mtp3T14(chl); + break; + + case TLAC_REMOTE_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d remote inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + link_remotely_inhibited[chl] = TRUE; + link_locally_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LIA); +// mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + link_inhibited[chl] = TRUE; + start_mtp3T23(chl); + tlac_fun1(chl); + break; + + case TLAC_LOCAL_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d local inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mgmt_tlac_proc(chl,MGMT_INHIBIT_DENIED); + break; + + case TLAC_REMOTE_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d remote inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LID); + break; + + case TLAC_RESTART_BEGINS: + link_available[chl] = AVAILABLE; + mtp3ObjState.tlac_state[chl] = TLAC_SP_RESTARTING_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d outof service",chl); + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + tlac_fun1(chl); + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d in service",chl); + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_Tctl[chl]) + { + case TLAC_T12_EXPIRED: + break; + case TLAC_T13_EXPIRED: + break; + case TLAC_T14_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + local_inhibit_in_progress[chl] = FALSE;/* cancel local inhibit in progress */ + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ;/* local inhibit request */ + break; + default: + break; + } + + break; + + case TLAC_SP_RESTARTING_STATE: + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(rest)]link %d unavailable in restarting state",chl); +// printf("tlac link %d failed\n",chl); + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + link_available[chl] = FALSE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_UNAVAILABLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = FALSE; + link_available[chl] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjInput.tcbc_input[chl] = TCBC_LINK_AVAILABLE; + if ( (ls->links_available - 1) == mtp3.ls[lsno].linksNum_configured ) + current_active_ls_num ++; + mtp3_debug(MTP3DB_EVENT,"[TLAC(rest)]link %d in service in restarting state",chl); + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (failed[chl] == FALSE)/* link available */ + { + failed[chl] = TRUE;/* mark failed */ + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE COO(link active)\n\r",chl); + } + else + { + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE COO(link fail)\n\r",chl); + } + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (failed[chl] == FALSE) + { + failed[chl] = TRUE;/* mark failed */ + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE ECO IN RESTART STATE(link active)\n\r",chl); + } + else + { + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE ECO IN RESTART STATE(link fail)\n\r",chl); + } + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_RESTART_ENDS: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + if ( link_available[chl] == TRUE ) + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + else + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + break; + + case TLAC_ADJACENT_SP_RESTART_ENDS: + break; + } + break; + + default: + break; + } +} + +void changeover_not_req(BYTE chl) +{ + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STM_READY; + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCOC_CHANGEOVER_NOT_REQ; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_CHANGEOVER_NOT_REQ; +} + +void tcoc_proc(BYTE chl) +{ + ls_info *ls; + int l2_input; + + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + + switch (mtp3ObjState.tcoc_state[chl]) + { + case TCOC_IDLE_STATE: + switch (mtp3ObjInput.tcoc_input_from_stm[chl]) + { + case TCOC_LINK_UNAVAILABLE: + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d unavailable",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT01_STATE; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST; + break; + + case TCOC_LINK_AVAILABLE: + break; + + case TCOC_TLAC_COO_COMMAND: +// mtp3_debug(MTP3DB_EVENT,"link %d rev coo",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + remote_bsnt_retrieved[chl] = TRUE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT05_STATE; + break; + + case TCOC_TLAC_ECO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + remote_bsnt_retrieved[chl] = FALSE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT05_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tcoc_input_from_hmdt[chl]) + { + case TCOC_HMDT_COA_COMMAND: + remote_bsnt_retrieved[chl] = TRUE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d RV COA IN IDLE STATE\n\r",chl); + break; + + case TCOC_HMDT_ECA_COMMAND: + remote_bsnt_retrieved[chl] = FALSE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d RV ECA IN IDLE STATE\n\r",chl); + break; + + default: + break; + } + break; + + case TCOC_WAIT01_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT1 STATE\n\r",chl); + changeover_not_req(chl); + } + else if ( mtp3ObjInput.tcoc_input_from_tsrc[chl] == TCOC_ALTERATIVE_ROUTE_DT ) + { + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d get routing data from tsrc",chl); +// printf("tcoc link %d route data\n",chl); + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + if ( changeover_required[chl] == TRUE ) + { + if ( co_msg_can_exchange[chl] == TRUE ) + { + co_msg_can_exchange[chl] = IDLE; +// mtp3_debug(MTP3DB_EVENT,"chl %d cc msg can exchange",chl); + if ( local_bsnt_retrievable[chl] == TRUE) + hmrt_tcoc_changeover_order(chl);/* send coo */ + else + { + hmrt_tcoc_emergency_changeover_order(chl); + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STOP_L2; + } + t2_delay_mtp3[chl] = mtp3_para->lt[chl].t2; + mtp3ObjState.tcoc_state[chl] = TCOC_WAITACK_STATE; + } + else if ( co_msg_can_exchange[chl] == FALSE ) + { + co_msg_can_exchange[chl] = IDLE; + t1_delay_mtp3[chl] = mtp3_para->lt[chl].t1; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT07_STATE; + } + } + else/* changeover not required */ + { + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d changeover not required,update routing table",chl); + hmrt_tcoc_update_routing_tables(chl); + } + } + break; + + case TCOC_WAIT05_STATE:/* wait for e1 l1 state change to unavailable */ + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + changeover_not_req(chl); +// mtp3_debug(MTP3DB_EVENT,"TCOC LINK %d AVAILABLE AT WAIT5 STATE",chl); + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; + } + else + { +/* if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl); + else*/ + hmrt_tcoc_emergency_changeover_ack(chl); + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT06_STATE; + send_command_to_mtp2(chl,MTP2_DEACTIVE_LINK); + } + break; + + case TCOC_WAIT06_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT6 STATE\n\r",chl); + changeover_not_req(chl); + } + else if ( mtp3ObjInput.tcoc_input_from_tsrc[chl] == TCOC_ALTERATIVE_ROUTE_DT ) + { + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; +// mtp3_debug(MTP3DB_EVENT,"tcoc link %d get data",chl); + if ( remote_bsnt_retrieved[chl] == TRUE ) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d retrieve begins in WAIT6",chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + } + else + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + } + break; + + case TCOC_WAIT07_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT07 STATE\n\r",chl); + changeover_not_req(chl); + } + else + { + + t1_delay_mtp3[chl] = t1_delay_mtp3[chl] - 1; + if ( t1_delay_mtp3[chl] == 0 ) + { + changeover_not_req(chl); + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d update routing table after T1 expired",chl); + hmrt_tcoc_update_routing_tables(chl); + } + } + break; + + case TCOC_WAITACK_STATE: + switch (mtp3ObjInput.tcoc_input_from_stm[chl]) + { + case TCOC_LINK_UNAVAILABLE: + break; + + case TCOC_LINK_AVAILABLE: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + changeover_not_req(chl); + break; + + case TCOC_TLAC_COO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl);/* send COA */ + else + hmrt_tcoc_emergency_changeover_ack(chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); +// mtp3_debug(MTP3DB_EVENT,"chl %d retrieve begins in WAITACK",chl); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + break; + + case TCOC_TLAC_ECO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl); + else + hmrt_tcoc_emergency_changeover_ack(chl); + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tcoc_input_from_hmdt[chl]) + { + case TCOC_HMDT_COA_COMMAND: + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d rv coa at waitack state",chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + } + break; + + case TCOC_HMDT_ECA_COMMAND: + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + break; + + default: + break; + } + + t2_delay_mtp3[chl] = t2_delay_mtp3[chl] - 1; + if ( t2_delay_mtp3[chl] == 0 ) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d rv coa timeout waitack state",chl); + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STOP_L2; + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + } + break; + + case TCOC_RETRIEVING_STATE: + l2_input = retrieved_bsnt[chl]; +/* if (l2_input == TCOC_L2_RETRIEVE_CMP) + {*/ + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; +/* } + else if (l2_input == TCOC_L2_RETRIEVE_NOT_POSSIBLE) + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + }*/ + break; + + case TCOC_SEND_BUFMSG_STATE: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCOC_CHANGEOVER_EXECUTED; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_CHANGEOVER_EXECUTED; + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; /* IDLE STATE */ + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STM_READY; + hmrt_tcoc_update_routing_tables(chl); + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d update routing table after retrieved msg",chl); + break; + + default: + break; + } +} + +void changeback_terminated(BYTE chl) +{ + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCBC_CHANGEBACK_TERMINATED; + mtp3ObjInput.tsrc_input_from_tcbc[chl] = TSRC_PROCEDURE_TERMINATED; + mtp3ObjState.tcbc_state[chl] = TCBC_IDLE_STATE; + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d change back complete,update routing table",chl); + hmrt_tcbc_update_routing_tables(chl); +} + +void tcbc_proc(BYTE chl) +{ + ls_info *ls; + BYTE lsno; + + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + switch (mtp3ObjState.tcbc_state[chl]) + { + case TCBC_IDLE_STATE: + switch (mtp3ObjInput.tcbc_input[chl]) + { + case TCBC_LINK_UNAVAILABLE: + break; + + case TCBC_LINK_AVAILABLE: + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d available",chl); + mtp3ObjInput.tcbc_input[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tcbc[chl] = TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST; + mtp3ObjState.tcbc_state[chl] = TCBC_WAIT_FOR_ROUTING_DATA_STATE; + break; + + case TCBC_HMDT_CBD_COMMAND: + mtp3ObjInput.tcbc_input[chl] = IDLE; + hmrt_tcbc_changeback_ack(chl); + break; + + case TCBC_HMDT_CBA_COMMAND: + mtp3ObjInput.tcbc_input[chl] = IDLE; + break; + + default: + break; + } + break; + + case TCBC_WAIT_FOR_ROUTING_DATA_STATE: + if ( mtp3ObjInput.tcbc_input_from_tsrc[chl] == TCBC_ALTERATIVE_ROUTE_DT ) + { + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d get routing data from tsrc",chl); +// printf("tcbc link %d get data complete\n",chl); + mtp3ObjInput.tcbc_input_from_tsrc[chl] = IDLE; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if ( tcbc_route_change[chl] == TRUE ) + { + if ( cb_msg_can_exchange[chl] == TRUE ) + /* adjacent sp acessible */ + { + hmrt_tcbc_changeback_declaration(chl); + t4_delay_mtp3[chl] = mtp3_para->lt[chl].t4; + mtp3ObjState.tcbc_state[chl] = TCBC_FIRST_ATTEMPT_STATE; + } + else + { +// mtp3_debug(MTP3DB_EVENT,"start t3"); + t3_delay_mtp3[chl] = mtp3_para->lt[chl].t3; + mtp3ObjState.tcbc_state[chl] = TCBC_TCTRL_DIVERSION_STATE; + } + } + else + { +// mtp3_debug(MTP3DB_EVENT,"error"); + mtp3ObjState.tcbc_state[chl] = TCBC_IDLE_STATE; + changeback_terminated(chl); + } + } + break; + + case TCBC_TCTRL_DIVERSION_STATE: + t3_delay_mtp3[chl] = t3_delay_mtp3[chl] - 1; + if ( t3_delay_mtp3[chl] == 0 ) + changeback_terminated(chl); + break; + + case TCBC_FIRST_ATTEMPT_STATE: + if ( mtp3ObjInput.tcbc_input[chl] == TCBC_HMDT_CBA_COMMAND ) + { +// mtp3_debug(MTP3DB_EVENT,"tcbc receive cba"); + mtp3ObjInput.tcbc_input[chl] = IDLE; + changeback_terminated(chl); + } + + t4_delay_mtp3[chl] = t4_delay_mtp3[chl] - 1; + if ( t4_delay_mtp3[chl] == 0 ) + { + if (mtp3ObjState.tcbc_state[chl] == TCBC_FIRST_ATTEMPT_STATE) + { + hmrt_tcbc_changeback_declaration(chl); + t5_delay_mtp3[chl] = mtp3_para->lt[chl].t5; + mtp3ObjState.tcbc_state[chl] = TCBC_SECOND_ATTEMPT_STATE; + } + } + break; + + case TCBC_SECOND_ATTEMPT_STATE: + t5_delay_mtp3[chl] = t5_delay_mtp3[chl] - 1; + if ( t5_delay_mtp3[chl] == 0 || + mtp3ObjInput.tcbc_input[chl] == TCBC_HMDT_CBA_COMMAND ) + { + mtp3ObjInput.tcbc_input[chl] = IDLE; + changeback_terminated(chl); + } + break; + + default: + break; + } +} + +void tprc_mgmt_signalling_point_restart_indication() +{ + int i,j; + // tprc to llsc restart begins + + for ( i=0; i<=255; i++) + { + //llsc_input_from_stm[chl] = LLSC_INPUT_FROM_STM; + mtp3ObjInput.tsrc_input_from_stm[i] = TSRC_RESTART_BEGINS; + mtp3ObjInput.tlac_input_from_stm[i] = TLAC_RESTART_BEGINS; + //tfrc_input_from_stm[chl] = TFRC_INPUT_FROM_STM; + //rtrc_input_from_stm[chl] = RTRC_INPUT_FROM_STM; + for ( j=0; j<4; j++ ) + { + mtp3.nw[j].rtpc_input[i] = RTPC_RESTART_BEGINS; + mtp3.nw[j].rtac_input[i] = RTAC_RESTART_BEGINS; +// mtp3.nw[j].rsrt_input[i] = RSRT_RESTART_BEGINS; + /* start t18 */ + } + } +} + +void tsrc_send_state_proc(BYTE nw) +{ + int dst; + + for (dst=0; dst<256; dst++) + { + if ( (mtp3.nw[nw].routine[dst] >> 6) == 2 ) + { + if ( (mtp3_para->nw[nw].normal_ls[dst] < 128) && + (mtp3_para->nw[nw].dpc[dst] != 0) ) + mtp3.nw[nw].rtpc_input[dst] = RTPC_DEST_INACCESSIBLE; + hmrt_tfrc_update_routing_tables(dst,tprc_nw); + } + } +} + +void tprc_fun2() +{ + tsrc_send_state_proc(tprc_nw); + tprc_nw++; + mtp3ObjState.tprc_state = TPRC_WAIT03_STATE; + t20_delay_mtp3 = mtp3_para->mtp3_t20; +} + +void tprc_proc()/* we always have stp function */ +{ + int i; + + switch (mtp3ObjState.tprc_state) + { + case TPRC_IDLE_STATE: + switch (mtp3ObjInput.tprc_input) + { + case TPRC_SP_RESTART_INDICATION: + mtp3ObjInput.tprc_input = IDLE; + mtp3ObjState.tprc_state = TPRC_WAIT01_STATE; + t18_delay_mtp3 = mtp3_para->mtp3_t18; + break; + + default: + break; + } + break; + + case TPRC_WAIT01_STATE: + t18_delay_mtp3 = t18_delay_mtp3 - 1; + if ( t18_delay_mtp3 == 0 )/* t18 expired */ + { + if (rv_TRA_num == active_ls_num) + tprc_fun2(); + else + { + t19_delay_mtp3 = mtp3_para->mtp3_t19;//start t19 + mtp3ObjState.tprc_state = TPRC_WAIT02_STATE; + } + } + else + { + if ( current_active_ls_num == active_ls_num) + { + if (rv_TRA_num == active_ls_num) + tprc_fun2(); + else + { + mtp3ObjState.tprc_state = TPRC_WAIT02_STATE; + t19_delay_mtp3 = mtp3_para->mtp3_t19; + } + } + } + break; + + case TPRC_WAIT02_STATE: + t19_delay_mtp3 = t19_delay_mtp3 - 1; + if ( t19_delay_mtp3 == 0 ) + { + tprc_fun2(); + } + break; + + case TPRC_WAIT03_STATE: + t20_delay_mtp3 = t20_delay_mtp3 - 1; + if ( t20_delay_mtp3 == 0 ) + { + for ( i=0; i<=255; i++) + { + //llsc_input_from_stm[chl] = LLSC_INPUT_FROM_STM; + mtp3ObjInput.tsrc_input_from_stm[i] = TSRC_RESTART_ENDS; + mtp3ObjInput.tlac_input_from_stm[i] = TLAC_RESTART_ENDS; + //tfrc_input_from_stm[chl] = TFRC_INPUT_FROM_STM; + //rtrc_input_from_stm[chl] = RTRC_INPUT_FROM_STM; + } + mtp3ObjState.tprc_state = TPRC_RESTART_ENDS_STATE; + } + else + { + if ( tprc_nw < 4 ) + { + tsrc_send_state_proc(tprc_nw); + tprc_nw ++; + } + else + tprc_nw = 0; + } + break; + + case TPRC_RESTART_ENDS_STATE: + mtp3_debug(MTP3DB_EVENT,"sp restart ends"); + mtp3ObjInput.tprc_input = IDLE; + for (i=0; i<128; i++) + { + hmrt_tra_msg(i); + } + mtp3ObjState.tprc_state = TPRC_IDLE_STATE; + rv_TRA_num = 0; + own_sp_restarting = 0; + break; + + default: + break; + } +} + +void taprc_proc(BYTE linkset)/* [STM]adjacent sp restart control,send TFP/TRA to adjacent sp */ +{ + int i; + network *sp; + BYTE nw; + + linkset = linkset & 0x7f; + if (linkset > 127) + return; + nw = (mtp3_para->ls_pro[linkset]) & 3; + sp = &mtp3.nw[nw]; + + switch (mtp3ObjInput.taprc_input[linkset]) + { + case TPRC_ADJACENT_SP_RESTARTING: + for (i=taprc_loop[linkset]; i<=taprc_loop[linkset]+7; i++) + { + if ((sp->routine[i] & 0x30) == 0)/* dst inaccessible */ + { + if ( (mtp3_para->nw[nw].normal_ls[i] < 128) && + (mtp3_para->nw[nw].dpc[i] != 0) ) + { + mtp3.nw[nw].rtpc_input[i] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = linkset;/* send TFP to this linkset's remote sp */ + rtpc_proc(nw,i); + } + } + } + taprc_loop[linkset] = taprc_loop[linkset] + 8; + if ( taprc_loop[linkset] == 0 ) + { + mtp3ObjInput.taprc_input[linkset] = IDLE; + sending_phase_finished[linkset] = TRUE; + hmrt_tra_msg(linkset); +// mtp3_debug(MTP3DB_EVENT,"Sd TFA to linkset %d remote sp",linkset); + } + break; + default: + break; + + } +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/.copyarea.db b/omc/plat/mtp3_old/.copyarea.db new file mode 100644 index 0000000..b15dc1b --- /dev/null +++ b/omc/plat/mtp3_old/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3 +2 +5 +3:doc|2|0|0|0|49e96a1fbfa511dc85a0001c23e19543|0 +2:ut|2|0|0|0|58396c6bbfa511dc85a0001c23e19543|0 +3:src|2|0|0|0|4bb96a73bfa511dc85a0001c23e19543|0 +8:Makefile|1|11d70a41c54|b71|77f4d1c1|4b196a57bfa511dc85a0001c23e19543|0 +3:lib|2|0|0|0|4a896a3bbfa511dc85a0001c23e19543|0 diff --git a/omc/plat/mtp3_old/Makefile b/omc/plat/mtp3_old/Makefile new file mode 100644 index 0000000..967afb0 --- /dev/null +++ b/omc/plat/mtp3_old/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = mtp3 +TYPE = plat + +DBUG_FLAGS_ADD = -DDEBUG -D_INCLUDE_M2UA -D_CDMA_SNMP +RELS_FLAGS_ADD = -D_INCLUDE_M2UA -D_CDMA_SNMP + +##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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/mtp3_old/src/.copyarea.db b/omc/plat/mtp3_old/src/.copyarea.db new file mode 100644 index 0000000..c62ca00 --- /dev/null +++ b/omc/plat/mtp3_old/src/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3\src +2 +9 +8:mtpmib.c|1|11d9047aab9|f0f1|263f8bde|2ab9bcfdb07f11dd85e3001c23e19543|0 +8:mtpsmh.c|1|11d70a41d0f|1be10|96e61327|ecb484de6cf311dd91a5001c23e19543|0 +8:mtpslm.c|1|11d70a41e76|2a52|6ee27efa|a95b4dee15c111dd8f7b001c23e19543|0 +7:include|2|0|0|0|4e196ae3bfa511dc85a0001c23e19543|0 +8:mtpstm.c|1|11d70a41d3e|f9dd|3876dc4e|ef5346de339011dd9fa7001c23e19543|0 +8:mtpsrm.c|1|11d70a41dda|2126|72c62bcc|f1b347ce339011dd9fa7001c23e19543|0 +9:mtpinit.c|1|11d70a41e47|c26b|85cc797c|ede485266cf311dd91a5001c23e19543|0 +a:mtp3lite.c|1|11d70a41d6d|4bd8|17766c21|ed4484f66cf311dd91a5001c23e19543|0 +6:mtpm.c|1|11d9047ab36|e316|50230af0|0d28dec5b05e11dd8511001c23e19543|0 diff --git a/omc/plat/mtp3_old/src/include/.copyarea.db b/omc/plat/mtp3_old/src/include/.copyarea.db new file mode 100644 index 0000000..1baaf0b --- /dev/null +++ b/omc/plat/mtp3_old/src/include/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\mtp3\src\include +2 +8 +8:mtpdef.h|1|11d70a4203b|d08|59b0359a|f1234786339011dd9fa7001c23e19543|0 +9:mtpfunc.h|1|11d70a4206a|117d|a4742d2c|f123479e339011dd9fa7001c23e19543|0 +8:mtpext.h|1|11d70a41ffd|f14|6c4f1cc8|f083476e339011dd9fa7001c23e19543|0 +a:mtp3lite.h|1|11d70a41f9f|1f9|4ea3a3fb|f083473e339011dd9fa7001c23e19543|0 +e:mtp3lite_pub.h|1|11d70a41fce|3c4|1c113fad|f0834756339011dd9fa7001c23e19543|0 +6:mtp3.h|1|11d70a41f61|109d|ecb1683c|eff34726339011dd9fa7001c23e19543|0 +a:mtpconst.h|1|11d9047ab93|418e|88c053ff|0c88debeb05e11dd8510001c23e19543|0 +8:mtpstm.h|1|11d70a41f03|1706|33254f89|ef5346f6339011dd9fa7001c23e19543|0 diff --git a/omc/plat/mtp3_old/src/include/mtp3.h b/omc/plat/mtp3_old/src/include/mtp3.h new file mode 100644 index 0000000..d24c8b1 --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtp3.h @@ -0,0 +1,171 @@ +#include "../../../iptrans/src/include/iptrans.h" +#ifdef _INCLUDE_M2UA + #include "../../../m2ua/src/include/m2ua.h" +#endif +#ifndef _MTP3_HEAD_FILE +#define _MTP3_HEAD_FILE + +#define _up_message up_message +#define MAX_SS7_MSG_LEN 272 + +typedef struct up_message{ + long dest_ip; + long dpc; + long opc; + BYTE cic[2]; + BYTE link; + BYTE sio; +// BYTE len;/* len not include itself */ + WORD len;//long message + BYTE msgList[MAX_SS7_MSG_LEN]; +}up_message; + +typedef struct up_message_2{ + long dest_ip; + long dpc; + long opc; + BYTE cic[4]; + BYTE link; + BYTE sio; // 13 for BICC +// BYTE len;/* len not include itself */ + WORD len;//long message + BYTE msgList[MAX_SS7_MSG_LEN]; +}up_message_2; + +typedef struct up_buffer /* user part buffer. user part:telephone user part, + isdn user part, and sccp part */ +{ + BYTE RSub; /* subscript of array msgList for reader */ + BYTE WSub; /* subscript of array msgList for writer */ + up_message msgNum[256];/* this buffer can storge up to 256 + messages */ +}up_buffer; + +typedef struct up_buffer_2 /* user part buffer. user part:telephone user part, + isdn user part, and sccp part */ +{ + BYTE RSub; /* subscript of array msgList for reader */ + BYTE WSub; /* subscript of array msgList for writer */ + up_message_2 msgNum[256];/* this buffer can storge up to 256 + messages */ +}up_buffer_2; + +#define _tup_shm tup_shm +typedef struct tup_shm { + up_buffer TM_Buf; + up_buffer MT_Buf; +} tup_shm; + +#define _isup_shm isup_shm +typedef struct isup_shm { + up_buffer IM_Buf; + up_buffer MI_Buf; +} isup_shm; + +#define _bicc_shm bicc_shm +typedef struct bicc_shm { + up_buffer_2 IM_Buf; + up_buffer_2 MI_Buf; +} bicc_shm; + +#define _sccp_shm sccp_shm +typedef struct sccp_shm { + up_buffer SM_Buf; + up_buffer MS_Buf; +} sccp_shm; + +typedef struct iprt1 +{ + BYTE pad[20] __attribute__((packed)); + message_list io_msg __attribute__((packed)); +}iprt1; + +typedef struct mtp_primitive +{ + long pc; + BYTE nw_indicator; + BYTE availability; +}mtp_primitive; + +typedef struct primitive_to_tup +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_tup; + +typedef struct primitive_to_isup +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_isup; + +typedef struct primitive_to_bicc +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_bicc; + +typedef struct primitive_to_sccp +{ + mtp_primitive primitive[16]; + BYTE WSub; + BYTE RSub; +}primitive_to_sccp; + +typedef struct mtp3_routing_result +{ + BYTE tupMsgOutLink[256]; + BYTE isupMsgOutLink[256]; + BYTE biccMsgOutLink[256]; + BYTE sccpMsgOutLink[256]; +}mtp3_routing_result; + +#define MTP3DB_CMD 0 +#define MTP3DB_SNMMSG 1 +#define MTP3DB_SCCPMSG 2 +#define MTP3DB_TUPMSG 3 +#define MTP3DB_ISUPMSG 4 +#define MTP3DB_ERROR 5 +#define MTP3DB_EVENT 6 +#define MTP3DB_ALLLKON 7 +#define MTP3DB_PFHB 8// platform heartbeat +#define MTP3DB_APP_APP_MSG 9// msg from app to app +#define MTP3DB_PRIMITIVE_MSG 10// msg from MTP3 to MTP2 +#define MTP3DB_BICCMSG 11 + +void mtp_shm_init(WORD moduleid_systemid); +//moduleid = 8/9/11 vss/mss/aas +//void iptrans_init(); +void mtp3_proc(); +int tup_to_mtp3(up_message *msgptr); +int isup_to_mtp3(up_message *msgptr); +int bicc_to_mtp3(up_message_2 *msgptr); +int sccp_to_mtp3(up_message *msgptr); +int sccp_redirect(up_message *msgptr); +int bicc_redirect(up_message_2 *msgptr); +int isup_redirect(up_message *msgptr); +int tup_GetMsg(up_message *msgptr); +int isup_GetMsg(up_message *msgptr); +int bicc_GetMsg(up_message_2 *msgptr); +int sccp_GetMsg(up_message *msgptr); +int sccp_get_SPstate(mtp_primitive *ptr); +int isup_get_SPstate(mtp_primitive *ptr); +int bicc_get_SPstate(mtp_primitive *ptr); +int tup_get_SPstate(mtp_primitive *ptr); +BYTE *spc_to_acn(BYTE netID,DWORD spc); +BYTE mtp3_ansiFlag(BYTE netID); +BYTE *check_MTP3LinkType(); +BYTE *check_MTP3LinkL2State(); +void MTP3_activate(DWORD ip); +void MTP3_deactivate(DWORD ip); +void MTP3_Enable_SubSystem(BYTE SubSystem); +void MTP3_Disable_SubSystem(BYTE SubSystem); +void mtp3_init_serial(char *Serial); +int mtp3_create_opc(BYTE nw, DWORD opc); +int mtp3_delete_opc(BYTE nw, DWORD opc); +int check_m3ua_rc_verify(DWORD rc); + +#endif diff --git a/omc/plat/mtp3_old/src/include/mtp3lite.h b/omc/plat/mtp3_old/src/include/mtp3lite.h new file mode 100644 index 0000000..b6ea464 --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtp3lite.h @@ -0,0 +1,28 @@ +#ifndef _MTP3LITE_H +#define _MTP3LITE_H + +#include "mtp3lite_pub.h" + +typedef struct _mtp3lite_lk +{ + int connfd; + int cliSockfd; + WORD remote_port; + WORD local_inactive; + WORD local_reconnect; + WORD remote_inactive; + BYTE remote_inactive_timeouts; + WORD init_guard_timer; +}mtp3lite_lk; + +void mtp3lite_init(void); +void mtp3lite_timer(void); + +int put_mtp3lite_msg(BYTE *msg_ptr); + +#define MTP3LITE_TCP_FAILURE 16 +#define MTP3LITE_INACTIVITY_TIMEOUT 17 + +#define MTP3LITE_MSG_BUF_SIZE_PER_LINK 1024 + +#endif diff --git a/omc/plat/mtp3_old/src/include/mtp3lite_pub.h b/omc/plat/mtp3_old/src/include/mtp3lite_pub.h new file mode 100644 index 0000000..f105dfd --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtp3lite_pub.h @@ -0,0 +1,53 @@ +#ifndef _MTP3LITE_PUB__H +#define _MTP3LITE_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/omc/plat/mtp3_old/src/include/mtpconst.h b/omc/plat/mtp3_old/src/include/mtpconst.h new file mode 100644 index 0000000..208eb4a --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtpconst.h @@ -0,0 +1,574 @@ +#ifndef _T_ULL +#define _T_ULL + typedef unsigned long long ull; +#endif + + +#define SIGNAL_TFA 0x54 +#define SIGNAL_TFP 0x14 +#define SIGNAL_TRA 0x17 +#define SIGNAL_RST 0x15 +#define SIGNAL_COO 0x11 +#define SIGNAL_COA 0x21 +#define SIGNAL_CBD 0x51 +#define SIGNAL_CBA 0x61 +#define SIGNAL_ECO 0x12 +#define SIGNAL_ECA 0x22 +#define SIGNAL_LIN 0x16 +#define SIGNAL_LUN 0x26 +#define SIGNAL_LIA 0x36 +#define SIGNAL_LUA 0x46 +#define SIGNAL_LID 0x56 +#define SIGNAL_LFU 0x66 +#define SIGNAL_LLT 0x76 +#define SIGNAL_LRT 0x86 +#define SIGNAL_SLTM 0x11 +#define SIGNAL_SLTA 0x21 + + +#define MTP3_ISUP_IAM 0x01 +#define MTP3_ISUP_ACM 0x06 +#define MTP3_ISUP_CPG 0x2c +#define MTP3_ISUP_ANM 0x09 +#define MTP3_ISUP_REL 0x0c +#define MTP3_ISUP_RLC 0x10 +#define MTP3_ISUP_UBL 0x14 +#define MTP3_ISUP_UBA 0x16 +#define MTP3_ISUP_GRA 0x19 + + +#define MTP3_TUP_IAM 0x11 +#define MTP3_TUP_IAI 0x21 +#define MTP3_TUP_SAM 0x31 +#define MTP3_TUP_SAO 0x41 +#define MTP3_TUP_GSM 0x12 +#define MTP3_TUP_COT 0x32 +/*#define MTP3_TUP_CCF '0x42',*/ +#define MTP3_TUP_GRQ 0x13 +#define MTP3_TUP_ACM 0x14 +#define MTP3_TUP_SEC 0x15 +#define MTP3_TUP_CGC 0x25 +#define MTP3_TUP_CFL 0x55 +#define MTP3_TUP_SSB 0x65 +/*#define MTP3_TUP_SLB 0x1E, +#define MTP3_TUP_STB 0x2E,*/ +#define MTP3_TUP_UNN 0x75 +#define MTP3_TUP_LOS 0x85 +#define MTP3_TUP_SST 0x95 +#define MTP3_TUP_ACB 0xa5 +#define MTP3_TUP_DPN 0xb5 +#define MTP3_TUP_ANU 0x06 +#define MTP3_TUP_ANC 0x16 +#define MTP3_TUP_ANN 0x26 +#define MTP3_TUP_CBK 0x36 +#define MTP3_TUP_CLF 0x46 +#define MTP3_TUP_CCL 0x76 +#define MTP3_TUP_RLG 0x17 +#define MTP3_TUP_BLO 0x27 +#define MTP3_TUP_BLA 0x37 +#define MTP3_TUP_UBL 0x47 +#define MTP3_TUP_UBA 0x57 +#define MTP3_TUP_ADI 0x45 + + +#define MTP3_SCCP_CR 1 +#define MTP3_SCCP_CC 2 +#define MTP3_SCCP_CREF 3 +#define MTP3_SCCP_RLSD 4 +#define MTP3_SCCP_RLC 5 +#define MTP3_SCCP_DT1 6 +#define MTP3_SCCP_DT2 7 +#define MTP3_SCCP_AK 8 +#define MTP3_SCCP_UDT 9 +#define MTP3_SCCP_UDTS 10 +#define MTP3_SCCP_ED 11 +#define MTP3_SCCP_EA 12 +#define MTP3_SCCP_RSR 13 +#define MTP3_SCCP_RSC 14 +#define MTP3_SCCP_ERR 15 +#define MTP3_SCCP_IT 16 +#define MTP3_SCCP_XUDT 17 +#define MTP3_SCCP_XUDTS 18 +#define MTP3_SCCP_LUDT 19 +#define MTP3_SCCP_LUDTS 20 + + +#define BETWEEN_LS 0x00 +#define WITHIN_LS 0x01 + +#define NORMAL_LS 0x00 +#define ALTERNATIVE_LS 0x01 +#define NO_ROUTE 0x02 + +/**************************************TCOC INPUT**************************************/ +/* TCOC INPUT FROM L2 */ + +#define TCOC_L2_BSNT 1 +#define TCOC_L2_BSNT_CANNOT_RECOVER 2 +#define TCOC_L2_RETRIEVED_MSG 3 +#define TCOC_L2_RETRIEVAL_CMP 4 +#define TCOC_L2_RETRIEVAL_NOT_POSSIBLE 5 + +/* TCOC INPUT FROM TSRC */ +#define TCOC_ALTERATIVE_ROUTE_DT 1 + +/* TCOC INPUT FROM STM */ +#define TCOC_LINK_UNAVAILABLE 1 +#define TCOC_LINK_AVAILABLE 2 +#define TCOC_TLAC_COO_COMMAND 3 +#define TCOC_TLAC_ECO_COMMAND 4 + +/* TCOC INPUT FROM HMDT */ +#define TCOC_HMDT_COA_COMMAND 1 +#define TCOC_HMDT_ECA_COMMAND 2 + +/* TCOC INPUT FROM L2 */ +//#define TCOC_L2_RETRIEVED_MSG 1 +#define TCOC_L2_RETRIEVE_CMP 254 +#define TCOC_L2_RETRIEVE_NOT_POSSIBLE 255 +/**************************************TCOC INPUT**************************************/ + + +/**************************************TCBC INPUT**************************************/ +#define TCBC_LINK_UNAVAILABLE 1 +#define TCBC_LINK_AVAILABLE 2 +#define TCBC_HMDT_CBD_COMMAND 3 +#define TCBC_HMDT_CBA_COMMAND 4 + +/* TCBC INPUT FROM TSRC */ +#define TCBC_ALTERATIVE_ROUTE_DT 1 + +/**************************************TCBC INPUT**************************************/ + + +/**************************************TLAC INPUT**************************************/ +/* TLAC INPUT FROM HMDT*/ +#define TLAC_HMDT_INHIBIT_SIGLINK 1 +#define TLAC_HMDT_UINHIBIT_SIGLINK 2 +#define TLAC_HMDT_INHIBIT_ACK 3 +#define TLAC_HMDT_UNINHIBIT_ACK 4 +#define TLAC_HMDT_INHIBIT_DENIED 5 +#define TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK 6 +#define TLAC_HMDT_CHANGEOVER_ORDER 7 +#define TLAC_HMDT_ECHANGEOVER_ORDER 8 +#define TLAC_HMDT_LOCAL_INHIBIT_TEST 9 +#define TLAC_HMDT_REMOTE_INHIBIT_TEST 10 + + +/* TLAC INPUT FROM MGMT */ +#define TLAC_MGMT_INHIBIT_SIGLINK 1 +#define TLAC_MGMT_UINHIBIT_SIGLINK 2 + +/* TLAC INPUT FROM SLM */ +#define TLAC_LSAC_SIGLINK_FAILED 1 +#define TLAC_LSAC_LINK_IN_SERVICE 2 +#define TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE 3 +#define TLAC_LSAC_REMOTE_PROCESSOR_RECOVER 4 + +/* TLAC INPUT FROM STM */ +#define TLAC_TCBC_CHANGEBACK_TERMINATED 1 +#define TLAC_TCOC_CHANGEOVER_EXECUTED 2 +#define TLAC_TCOC_CHANGEOVER_NOT_REQ 3 +#define TLAC_LOCAL_INHIBIT_ALLOWED 4 +#define TLAC_REMOTE_INHIBIT_ALLOWED 5 +#define TLAC_LOCAL_INHIBIT_DENIED 6 +#define TLAC_REMOTE_INHIBIT_DENIED 7 +#define TLAC_UINHIBIT_SIGLINK_FROM_TSRC 8 +#define TLAC_UNINHIBIT_NOT_POSSIBLE 9 +#define TLAC_UNINHIBIT_POSSIBLE 10 +#define TLAC_ADJACENT_SP_RESTARTING 11 +#define TLAC_RESTART_BEGINS 12 +#define TLAC_RESTART_ENDS 13 +#define TLAC_ADJACENT_SP_RESTART_ENDS 14 + +/* TLAC INPUT FROM TIMER CONTROL */ +#define TLAC_T12_EXPIRED 1 +#define TLAC_T13_EXPIRED 2 +#define TLAC_T14_EXPIRED 3 +#define TLAC_T22_EXPIRED 4 +#define TLAC_T23_EXPIRED 5 +/**************************************TLAC INPUT**************************************/ + + +/**************************************TSRC INPUT**************************************/ +/* TSRC_INPUT_FROM_TCOC */ +#define TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_TCOC_ACCESS_DATA_REQ 2 +#define TSRC_TCOC_CHANGEOVER_EXECUTED 3 +#define TSRC_TCOC_CHANGEOVER_NOT_REQ 4 + +/* TSRC_INPUT_FROM_TCBC */ +#define TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_PROCEDURE_TERMINATED 2 + +/*TSRC_INPUT_FROM_STM*/ +#define TSRC_TFRC_ALTERNATIVE_ROUTING_DATA_REQUEST 1 +#define TSRC_TCRC_ALTERNATIVE_ROUTING_DATA_REQUEST 2 +#define TSRC_RESTART_BEGINS 3 +#define TSRC_RESTART_ENDS 4 +#define TSRC_TRAFFIC_RESTART_ALLOWED 5 +#define TSRC_SENDING_STATUS_PHASE 6 + +/*TSRC_INPUT_FROM_SRM*/ +#define TSRC_RTAC_ROUTE_AVAILABLE 1 +#define TSRC_RTPC_ROUTE_UNAVAILABLE 2 + +/* TSRC_INPUT_FROM_TLAC */ +#define TSRC_TLAC_LINK_UNAVAILABLE 1 +#define TSRC_TLAC_LINK_AVAILABLE 2 +#define TSRC_TLAC_LOCAL_INHIBIT_REQ 3 +#define TSRC_TLAC_REMOTE_INHIBIT_REQ 4 +#define TSRC_TLAC_LINK_INHIBITED 5 +#define TSRC_TLAC_CANCEL_LINK_INHIBITED 6 +#define TSRC_TLAC_UNINHIBIT_REQ 7 +/**************************************TSRC INPUT**************************************/ + + +/**************************************TFRC INPUT**************************************/ +#define TFRC_SIG_RT_UNAVAILABLE 0 +#define TFRC_SIG_RT_AVAILABLE 1 +#define TFRC_ALTERNATIVE_RT_DT 2 +/**************************************TFRC INPUT**************************************/ + + +/**************************************TCRC INPUT**************************************/ +#define TCRC_SIG_RT_AVAILABLE 0 +#define TCRC_ALTERNATIVE_RT_DT 1 +/**************************************TCRC INPUT**************************************/ + +/**************************************TPRC INPUT**************************************/ +#define TPRC_ADJACENT_SP_RESTARTING 1 +#define TPRC_TRA_MSG 2 +#define TPRC_RTPC_TFP_SENT 3 +/**************************************TPRC INPUT ABOUT dst**************************************/ +#define TPRC_LINK_AVAILABLE 1 +#define TPRC_LINK_UNAVAILABLE 2 +#define TPRC_SP_RESTART_INDICATION 3 +#define TPRC_STATUS_SENT 4 +/**************************************TPRC INPUT**************************************/ + +/**************************************RTPC INPUT**************************************/ +#define RTPC_MSGREV_FOR_INACCESS_SP 1 +#define RTPC_RSRT_SEND_TFP_MSG 2 +#define RTPC_TSRC_SEND_TFP_MSG 3 +#define RTPC_DEST_INACCESSIBLE 4 +#define RTPC_TFP_MSG 5 +#define RTPC_CTRL_RERT_TERMINATED 6 +#define RTPC_CONTROLLED_RERT 7 +#define RTPC_RESTART_BEGINS 8 +#define RTPC_RESTART_ENDS 9 +/**************************************RTPC INPUT**************************************/ + + +/**************************************RTAC INPUT**************************************/ +#define RTAC_TFA_MSG 1 +#define RTAC_DEST_ACCESSIBLE 2 +#define RTAC_STP_NOLONGER_FOR_DEST 3 +#define RTAC_SEND_TFA_MSG 4 +#define RTAC_FORCED_RERT 5 +#define RTAC_FORCED_RERT_TERMINATED 6 +#define RTAC_FORCED_RERT_NOT_REQ 7 +#define RTAC_RESTART_BEGINS 8 +#define RTAC_RESTART_ENDS 9 +/**************************************RTAC INPUT**************************************/ + +#define RSRT_RTPC_ROUTE_SET_TEST 1 +#define RSRT_TSRC_ROUTE_SET_TEST 2 +#define RSRT_RTAC_ROUTE_AVAILABLE 3 + +#define RSRT_IDLE_STATE 0 +#define RSRT_WAIT_STATE 1 +/**************************************LSAC INPUT**************************************/ +/* LSAC INPUT FROM L2*/ +#define LSAC_L2_IN_SERVICE 1 +#define LSAC_L2_OUT_OF_SERVICE 2 +#define LSAC_L2_REMOTE_PROCESSOR_RECOV 3 +#define LSAC_L2_REMOTE_PROCESSOR_OUTAGE 4 + +/* LSAC INPUT FROM SLTC */ +#define LSAC_SLTC_SLT_SUCCESSFUL 1 +#define LSAC_SLTC_SLT_FAILED 2 + +/* LSAC INPUT FROM TCOC */ +#define LSAC_TCOC_STM_READY 1 +#define LSAC_TCOC_STOP_L2 2 + +/* LSAC INPUT FROM STM */ +#define LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED 1 + +/* LSAC INPUT FROM SLM */ +#define LSAC_ACTIVATE_LINK_FROM_LLSC 1 +#define LSAC_DEACTIVATE_LINK_FROM_LLSC 2 +#define LSAC_EMERGENCY 3 +#define LSAC_EMERGENCY_CEASES 4 + +/* LSAC INPUT FROM MGMT */ +#define LSAC_MGMT_ACTIVATE_LINK 1 +#define LSAC_MGMT_DEACTIVATE_LINK 0 +/**************************************LSAC INPUT**************************************/ +#define LLSC_MGMT_ACTIVATE_LINKSET 1 +#define LLSC_MGMT_DEACTIVATE_LINKSET 2 +#define LLSC_TPRC_RESTART_BEGINS 3 + +/* MGMT INPUT */ +#define MGMT_TLAC_LINK_INHIBITED 1 +#define MGMT_TLAC_LINK_UNINHIBITED 2 +#define MGMT_UNINHIBIT_NOT_POSSIBLE 3 +#define MGMT_INHIBIT_DENIED 4 + +#define TCOC_IDLE_STATE 0 +#define TCOC_WAIT01_STATE 1 +#define TCOC_WAIT02_STATE 2 +#define TCOC_WAIT05_STATE 3 +#define TCOC_WAIT06_STATE 4 +#define TCOC_WAIT07_STATE 5 +#define TCOC_WAITACK_STATE 6 +#define TCOC_RETRIEVING_STATE 7 +#define TCOC_SEND_BUFMSG_STATE 8 + +#define TLAC_UNAVAILABLE_STATE 0 +#define TLAC_AVAILABLE_STATE 1 +#define TLAC_SP_RESTARTING_STATE 2 + +#define LSAC_INACTIVE_STATE 0 +#define LSAC_RESTORING_STATE 1 +#define LSAC_ACTIVE_STATE 2 +#define LSAC_WAIT_STATE 3 +#define LSAC_FAILED_STATE 4 + +#define TSRC_IDLE_STATE 0 +#define TSRC_WAIT01_STATE 1 +#define TSRC_WAIT02_STATE 2 +#define TSRC_WAIT03_STATE 3 +#define TSRC_WAIT04_STATE 4 +#define TSRC_WAIT05_STATE 5 + +#define TCBC_IDLE_STATE 0 +#define TCBC_WAIT_FOR_ROUTING_DATA_STATE 1 +#define TCBC_TCTRL_DIVERSION_STATE 2 +#define TCBC_FIRST_ATTEMPT_STATE 3 +#define TCBC_SECOND_ATTEMPT_STATE 4 + +#define RTPC_IDLE_STATE 0 +#define RTPC_WAIT_STATE 1 + +#define TPRC_IDLE_STATE 0 +#define TPRC_WAIT01_STATE 1 +#define TPRC_WAIT02_STATE 2 +#define TPRC_WAIT03_STATE 3 +#define TPRC_RESTART_ENDS_STATE 4 + +#define SLTC_IDLE_STATE 0 +#define SLTC_FIRST_TRY_STATE 1 +#define SLTC_SECOND_TRY_STATE 2 +#define SLTC_THIRD_TRY_STATE 3 +#define SLTC_RUNNING_STATE 4 + +#define SLTC_START 1 +#define SLTA_MSG 2 +#define SLTC_SECOND_TRY 3 +#define SLTC_STOP 4 + +#ifndef IDLE +#define IDLE 0xee +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#define COMMAND_START 1 +#define COMMAND_STOP 0 +#define TIMER_START 1 +#define TIMER_STOP 2 + +#define SP_ACCESSIBLE 1 +#define SP_INACCESSIBLE 0 +//#define LS_UNAVAILABLE 2 + +#define LOCAL_INHIBIT_REQ 0 +#define REMOTE_INHIBIT_REQ 1 + +#define UNAVAILABLE 0 +#define AVAILABLE 1 +#define INHIBITED 2 + +#define LOCAL_INHIBIT_REQ 0 +#define REMOTE_INHIBIT_REQ 1 + +#define MTP3_DEBUG_ID 1 + +//#define MTP3_OID {1,3,6,1,4,1,1373,1,3,2,2,2} +#define MTP3_OID {1,3,6,1,4,1,1373,2,3,2,2} +#define MTP3_OID_LEN 11 + +//#define MTP3_OMC_OID {1,3,6,1,4,1,1373,1,4} +#define MTP3_OMC_OID {1,3,6,1,4,1,1373,2,4} +#define MTP3_OMC_OID_LEN 9 + +//#define PLATFORM_HB_OID {1,3,6,1,4,1,1373,1,3,2,1} +#define PLATFORM_HB_OID {1,3,6,1,4,1,1373,2,3,2} +#define PLATFORM_HB_LEN 10 +#define MTP2_HB_OID {1,3,6,1,4,1,1373,1,3,1,1,3,4} +#define MTP2_HBOID_LEN 13 + +#define MTP2_ACTIVE_LINK 1 +#define MTP2_DEACTIVE_LINK 2 +#define MTP2_STOP_L2 3 +#define MTP2_EMERGEN_ALIGNMENT 4 +#define MTP2_RETRIEVE 5 +#define MTP3_M2UA_DISABLE 6 +#define MTP3_M2UA_ENABLE 7 +#define MTP3_M3UA_ENABLE 7 +#define MTP3_M3UA_DISABLE 6 + +#define ROUTE_AVAILABLE 0 +#define ROUTE_UNAVAILABLE 1 + +#define MTP_MAX_ASCIIOUT_LEN 2048 + +#define DISPLAY_SNM_MESSAGE 0 +#define DISPLAY_TM_MESSAGE 1 +#define DISPLAY_SCCP_MESSAGE 3 +#define DISPLAY_TUP_MESSAGE 4 +#define DISPLAY_ISUP_MESSAGE 5 +#define DISPLAY_MTP3_ERROR_LOG 6 +#define MTP3_MSGLOG_ON 1 +#define MTP3_MSGLOG_OFF 0 + +#define SNM_SIO 0 +#define TM_SIO 1/* T+M */ +#define SCCP_SIO 3 +#define TUP_SIO 4 +#define ISUP_SIO 5 +#define BICC_SIO 13 + +#define MTP2_STATE_IDLE 0 +#define MTP2_STATE_STOP 1 +#define MTP2_STATE_ASSIGN 2 +#define MTP2_STATE_READY 3 +#define MTP2_STATE_NOT_READY 4 +#define MTP2_STATE_WORKING 5 +#define MTP2_STATE_ERROR 6 +#define MTP2_STATE_WAITING 7 +#define MTP2_STATE_STATE_CONGEST 8 + +#define MTP3_TO_USERPART 0 +#define USERPART_TO_MTP3 1 +#define MTP_MSG_UP 0 +#define MTP_MSG_DOWN 1 +#define MTP_MSG_STP 2 +#define MTP_MSG_OTHER_SERVER 3 +#define MTP_SNM_MSG 4 +#define MTP_TO_LITE 5 +#define MTP_FROM_LITE 6 + +#define SS7_PORT 4950 +#define M2UA_PORT 2904 +#define MTP3_MULTICAST_PORT 4969 + +#define MTP3_IPTX_MSG 0 +#define MTP3_UP_MSG 1 + +#define E1CARD_BASE_IP 0x010012AC +#define E1CARD_BASE_IP_MASK 0xff00ffff + +#define PARA_CONFIGURED 1 +#define PARA_NOT_CONFIGURED 0 + + +#define LS_AVAILABLE 0 +#define LS_UNAVAILABLE 1 +#define NLS_AVAILABLE 0 +#define ALS_AVAILABLE 0 +#define NLS_UNAVAILABLE 2 +#define ALS_UNAVAILABLE 2 + +#define UPDATE_NLS 0 +#define UPDATE_ALS 1 + +#define LINK_TO_IP(link) (link >> 3) << 16 | 0x010012AC + +#define MAX_LS_DPC 128 +#define MAX_LS_DPC_ADD1 129 +#define MAX_LS_NUM 128 + +#define MTP3_14BIT_PC 14 +#define MTP3_24BIT_PC 24 + +#define MSG_FROM_MTP2 0 +#define MSG_FROM_MTP3 1 + +#define MAX_ACN_NUM 36 + +#define MAX_MTP3_NUM 64 + +#define MTP3_LINK_COMPONENT 23 +#define MTP3_LINKSET_COMPONENT 279 +#define MTP3_SG_COMPONENT 264 + +#define MTP3_VERSION {9, 1, 5} +//9,0,2 change ss7 format to "link-0, len -1-2, sio-3 " +//9,0,3 support m3ua msg + +#define MTP3_COMPONENT_ID 1 +#define ALARM_LINK_UNAVAILABLE 0 +#define ALARM_LINK_AVAILABLE 1 +#define ALARM_LINK_INHIBIT 2 +#define ALARM_LS_UNAVAILABLE 3 +#define ALARM_LS_AVAILABLE 4 +#define ALARM_LS_INHIBIT 5 +#define NORMAL_HEARTBEAT 6 + +#define M2UAALARM_SCTP_Failure 1 +#define M2UAALARM_SG_Maintenance 2 +#define M2UAALARM_Remote_MTP2_down 3 +#define M2UAALARM_Local_MTP3_Request_Link_Down 4 +#define M2UAALARM_Local_SGLink_Maintenance 5 +#define M2UAALARM_SCCPLite_TCP_Failure 16 +#define M2UAALARM_SCCPLite_Inactivity_Timeout 17 + +#define MTP3ALARM_LINK_TEST_FAILED 1 +#define MTP3ALARM_LINK_COO_RECEIVED 2 +#define MTP3ALARM_LINK_CHANGE_OVER 3 +#define MTP3ALARM_LINK_MGMT_REQUEST 4 +#define MTP3ALARM_LINK_CB_TO_NMTP3 5 +#define MTP3ALARM_LINK_LOCAL_INHIBITED 6 +#define MTP3ALARM_LINK_REMOTE_INHIBITED 7 + +#define MTP3_HB_LEN 134 +#define MTP3_SERNUM_LEN 4//4 bytes + +typedef enum +{ + LKTYPE_NONE_SIGTRAN = 0, + LKTYPE_SIGTRAN = 1, + LKTYPE_MTP3_LITE = 2, + LKTYPE_RESERVED1 = 3, + LKTYPE_M3UA = 4, + LKTYPE_RESERVED3 = 5, + LKTYPE_RESERVED4 = 6, + LKTYPE_RESERVED5 = 7, +}MTP3_LKTYPE_LIST; + +typedef enum +{ + MTP3_SUB_SNM = 0, + MTP3_SUB_STM = 1, + MTP3_SUB_STM2 = 2, + MTP3_SUB_SCCP = 3, + MTP3_SUB_TUP = 4, + MTP3_SUB_ISUP = 5, + MTP3_SUB_DUP1 = 6, + MTP3_SUB_DUP2 = 7, + MTP3_SUB_NONE2 = 8, + MTP3_SUB_BISUP = 9, + MTP3_SUB_SISUP = 10, + MTP3_SUB_NONE3 = 11, + MTP3_SUB_NONE4 = 12, + MTP3_SUB_BICC = 13 +}MTP3_SUB_NAME; + +#define MTP3_MAX_DYNAMIC_OPC_PER_NW 8 diff --git a/omc/plat/mtp3_old/src/include/mtpdef.h b/omc/plat/mtp3_old/src/include/mtpdef.h new file mode 100644 index 0000000..76cc148 --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtpdef.h @@ -0,0 +1,155 @@ +BYTE ls_slc[2048]; +BYTE ls_sls[2048]; +BYTE sls_to_link[2048]; + +/** link mark **/ +BYTE link_available[256]; +BYTE link_unavailable[256]; +BYTE changeover_possible[256]; +BYTE retrieval_required[256]; +BYTE remote_bsnt_retrieved[256]; +BYTE changeback_in_progress[256]; +BYTE changeover_in_progress[256]; +BYTE changeback_required[256]; +BYTE changeover_required[256]; +BYTE emergency_changeover_order[256]; +BYTE changeover_order[256]; +BYTE changeover_completed[256]; +BYTE failed[256]; +BYTE blocked_by[256]; +BYTE local_blocked[256]; +BYTE remote_blocked[256]; +BYTE first_failure[256]; +BYTE changeover_select[256]; +BYTE changeback_select[256]; +BYTE co_msg_can_exchange[256]; +BYTE cb_msg_can_exchange[256]; +BYTE local_bsnt_retrievable[256]; +BYTE retrieved_bsnt[256]; +BYTE fsnt[256]; +BYTE fsnl[256]; +BYTE fsnc[256]; +BYTE bsnt[256]; +BYTE tcbc_route_change[256]; +BYTE command3[256]; +BYTE cbd_cbc_r[256]; +BYTE cba_cbc_r[256]; +BYTE cbc_s[256]; +BYTE controlled_rerouting_in_progress[256]; +BYTE transfer_prohibited[256]; +BYTE own_sp_restarting; +BYTE link_remotely_inhibited[256]; +BYTE link_locally_inhibited[256]; +BYTE link_inhibited[256]; +BYTE local_inhibit_in_progress[256]; +BYTE uninhibit_in_progress[256]; +BYTE management_req[256]; +BYTE t12_expired_2nd_time[256]; +BYTE t13_expired_2nd_time[256]; +BYTE sending_phase_finished[128]; + +WORD mtp3_timer[24]; + +BYTE sd_buf_h[256]; +BYTE sd_buf_t[256]; + +MTP3Parameter *mtp3_para; +MTP3Parameter mtp3_para_init; +mtp mtp3; +mtp3_csta mtp3_measure; +measure_of_mtp3 *current_measure; +BYTE current_mtime;/* current measure time */ +heartbeat_compoent_of_mtp3 mtp3_heartbeat; + +/** debug **/ + +BYTE mtp_asciout_buf[2048]; +BYTE mtp_asciin_buf[80]; + +BYTE t1_delay_mtp3[256]; +BYTE t2_delay_mtp3[256]; +BYTE t3_delay_mtp3[256]; +BYTE t4_delay_mtp3[256]; +BYTE t5_delay_mtp3[256]; +BYTE t6_delay_mtp3[256]; +BYTE t7_delay_mtp3[256]; +BYTE t8_delay_mtp3[256]; +BYTE t9_delay_mtp3[256]; +BYTE t10_delay_mtp3[256]; +BYTE t11_delay_mtp3[256]; +BYTE t12_delay_mtp3[256]; +BYTE t13_delay_mtp3[256]; +BYTE t14_delay_mtp3[256]; +BYTE t15_delay_mtp3[256]; +BYTE t16_delay_mtp3[256]; +BYTE t17_delay_mtp3[256]; +BYTE t18_delay_mtp3; +BYTE t19_delay_mtp3; +BYTE t20_delay_mtp3; +BYTE t21_delay_mtp3[128]; +BYTE t22_delay_mtp3[256]; +BYTE t23_delay_mtp3[256]; +BYTE t24_delay_mtp3[256]; +BYTE sltc_t1_delay[256]; +BYTE sltc_t2_delay[256]; + +BYTE mtp3_t21_flag[128]; +BYTE mtp3_t22_flag[256]; +BYTE mtp3_t23_flag[256]; +BYTE mtp3_t12_flag[256]; +BYTE mtp3_t13_flag[256]; +BYTE mtp3_t14_flag[256]; + +BYTE srm_nw; +BYTE active_ls_num; +BYTE current_active_ls_num; +BYTE rv_TRA_num; +BYTE tprc_nw; +BYTE taprc_loop[128]; + +BYTE mtp_t1[256]; +BYTE mtp_t2[256]; +BYTE mtp_t3[256]; +BYTE mtp_t4[256]; +BYTE mtp_t5[256]; +BYTE mtp_t7[256]; +BYTE mtp_t12[256]; +BYTE mtp_t13[256]; +BYTE mtp_t14[256]; +BYTE mtp_t17[256]; +BYTE mtp_t22[256]; +BYTE mtp_t23[256]; +BYTE mtp_t24[256]; + +BYTE mtp2_flag_new[32]; +BYTE mtp2_flag_old[32]; + +DWORD mtp3_localip; +DWORD mtp3_alterip; + +WORD wx5[256]; +BYTE debug_link[256]; + +long mtp3_timestamp; +long mtp3_csta_p; + +DWORD mtp3_get_msg; + +BYTE local_change_over[256]; + +BYTE mtp2_buf_full[256]; +BYTE nld_cause_lkd[256]; + +BYTE init_lsac_state[256]; +BYTE init_tlac_state[256]; + +DWORD TFAmsg_OPC; +BYTE TFAmsg_SrcLk; +DWORD TFPmsg_OPC; +BYTE TFPmsg_SrcLk; +BYTE sdTFP_Ls; +BYTE sdTFA_Ls; +BYTE mtp2_module; +BYTE mtp2_systemid; +// mtp3 dynamic opc +mtp3_dynamic_opc mtp3_opc; diff --git a/omc/plat/mtp3_old/src/include/mtpext.h b/omc/plat/mtp3_old/src/include/mtpext.h new file mode 100644 index 0000000..a454282 --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtpext.h @@ -0,0 +1,140 @@ +extern BYTE ls_slc[2048]; +extern BYTE ls_sls[2048]; +extern BYTE sls_to_link[2048]; + +/** link mark **/ +extern BYTE link_available[256]; +extern BYTE changeover_possible[256]; +extern BYTE retrieval_required[256]; +extern BYTE remote_bsnt_retrieved[256]; +extern BYTE changeback_in_progress[256]; +extern BYTE changeover_in_progress[256]; +extern BYTE changeback_required[256]; +extern BYTE changeover_required[256]; +extern BYTE emergency_changeover_order[256]; +extern BYTE changeover_order[256]; +extern BYTE changeover_completed[256]; +extern BYTE failed[256]; +extern BYTE blocked_by[256]; +extern BYTE local_blocked[256]; +extern BYTE remote_blocked[256]; +extern BYTE first_failure[256]; +extern BYTE changeback_select[256]; +extern BYTE changeover_select[256]; +extern BYTE co_msg_can_exchange[256]; +extern BYTE cb_msg_can_exchange[256]; +extern BYTE local_bsnt_retrievable[256]; +extern BYTE retrieved_bsnt[256]; +extern BYTE fsnt[256]; +extern BYTE fsnl[256]; +extern BYTE fsnc[256]; +extern BYTE bsnt[256]; +extern BYTE tcbc_route_change[256]; +extern BYTE command3[256]; +extern BYTE cbd_cbc_r[256]; +extern BYTE cba_cbc_r[256]; +extern BYTE cbc_s[256]; +extern BYTE controlled_rerouting_in_progress[256]; +extern BYTE transfer_prohibited[256]; +extern BYTE own_sp_restarting; +extern BYTE link_remotely_inhibited[256]; +extern BYTE link_locally_inhibited[256]; +extern BYTE link_inhibited[256]; +extern BYTE local_inhibit_in_progress[256]; +extern BYTE uninhibit_in_progress[256]; +extern BYTE management_req[256]; +extern BYTE t12_expired_2nd_time[256]; +extern BYTE t13_expired_2nd_time[256]; +extern BYTE sending_phase_finished[128]; + +extern WORD mtp3_timer[24]; + +extern BYTE sd_buf_h[256]; +extern BYTE sd_buf_t[256]; + +extern MTP3Parameter *mtp3_para; +extern mtp mtp3; +extern mtp3_csta mtp3_measure; +extern measure_of_mtp3 *current_measure; +extern BYTE current_mtime;/* current measure time */ + +/** debug **/ + +extern BYTE mtp_asciout_buf[2048]; +extern BYTE mtp_asciin_buf[80]; + +extern BYTE t1_delay_mtp3[256]; +extern BYTE t2_delay_mtp3[256]; +extern BYTE t3_delay_mtp3[256]; +extern BYTE t4_delay_mtp3[256]; +extern BYTE t5_delay_mtp3[256]; +extern BYTE t6_delay_mtp3[256]; +extern BYTE t7_delay_mtp3[256]; +extern BYTE t8_delay_mtp3[256]; +extern BYTE t9_delay_mtp3[256]; +extern BYTE t10_delay_mtp3[256]; +extern BYTE t11_delay_mtp3[256]; +extern BYTE t12_delay_mtp3[256]; +extern BYTE t13_delay_mtp3[256]; +extern BYTE t14_delay_mtp3[256]; +extern BYTE t15_delay_mtp3[256]; +extern BYTE t16_delay_mtp3[256]; +extern BYTE t17_delay_mtp3[256]; +extern BYTE t18_delay_mtp3; +extern BYTE t19_delay_mtp3; +extern BYTE t20_delay_mtp3; +extern BYTE t21_delay_mtp3[128]; +extern BYTE t22_delay_mtp3[256]; +extern BYTE t23_delay_mtp3[256]; +extern BYTE t24_delay_mtp3[256]; +extern BYTE sltc_t1_delay[256]; +extern BYTE sltc_t2_delay[256]; + +extern BYTE mtp3_t21_flag[128]; +extern BYTE mtp3_t22_flag[256]; +extern BYTE mtp3_t23_flag[256]; +extern BYTE mtp3_t12_flag[256]; +extern BYTE mtp3_t13_flag[256]; +extern BYTE mtp3_t14_flag[256]; + +extern BYTE srm_nw; +extern BYTE active_ls_num; +extern BYTE current_active_ls_num; +extern BYTE rv_TRA_num; +extern BYTE tprc_nw; +extern BYTE taprc_loop[128]; + +extern BYTE mtp2_flag_new[32]; +extern BYTE mtp2_flag_old[32]; + +extern heartbeat_compoent_of_mtp3 mtp3_heartbeat; + +extern DWORD mtp3_localip; +extern DWORD mtp3_alterip; +extern WORD wx5[256]; +extern BYTE debug_link[256]; + +extern long mtp3_timestamp; +extern long mtp3_csta_p; + +extern DWORD mtp3_get_msg; + +extern BYTE local_change_over[256]; + +extern BYTE mtp2_buf_full[256]; +extern BYTE nld_cause_lkd[256]; + +extern BYTE init_lsac_state[256]; +extern BYTE init_tlac_state[256]; + +extern DWORD TFAmsg_OPC; +extern BYTE TFAmsg_SrcLk; +extern DWORD TFPmsg_OPC; +extern BYTE TFPmsg_SrcLk; +extern BYTE sdTFP_Ls; +extern BYTE sdTFA_Ls; +extern BYTE mtp2_module; +extern BYTE mtp2_systemid; + +// mtp3 opc +extern mtp3_dynamic_opc mtp3_opc; diff --git a/omc/plat/mtp3_old/src/include/mtpfunc.h b/omc/plat/mtp3_old/src/include/mtpfunc.h new file mode 100644 index 0000000..5a6657a --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtpfunc.h @@ -0,0 +1,102 @@ +int find_outbound_cclink(BYTE chl);/* find outbound changeover link */ +int search_outbound_link(BYTE ls); +int pc_length(BYTE nw); +void send_mtp_msg(int outlink, BYTE *msgptr); +void send_snm_msg(BYTE ls,BYTE *msgptr); +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst); +int check_outbound_route(BYTE sio, long dpc, BYTE sls); +int send_to_tup(BYTE *msgptr);/* send tup msg to tele user part */ +int send_to_isup(BYTE *msgptr);/* send isup msg to tele user part */ +int send_to_bicc(BYTE *msgptr);/* send bicc msg to tele user part */ +int send_to_sccp(BYTE *msgptr);/* send sccp msg to tele user part */ +int send_to_sccp_lite(up_message *msgptr);/* send sccp-lite msg to sccp */ +int get_tup(up_message *GetTup); +int get_isup(up_message *GetIsup); +int get_bicc(up_message_2 *GetBicc); +int get_sccp(up_message *GetSccp); +int find_dst_place(long dst,BYTE ls); +int find_direct_ls_to_dst(long dst, BYTE nw); +void mtp2_mtp3_internal_msg(BYTE *msgptr); +void hmdt_test_msg(BYTE *msgptr); +void hmrt_tra_msg(BYTE linkset); +void sd_STM_msg(BYTE chl, BYTE MsgType); +void hmrt_xxxx_adjacent_sp_restart(ls_info *ls); +void hmrt_hmdc_message_for_routing(ls_info *ls); +void hmrt_xxxx_signalling_link_management_message(ls_info *ls); +void hmrt_xxxx_signalling_route_management_message(ls_info *ls); +void hmrt_xxxx_mtp_testing_user_part_message(ls_info *ls); +void hmrt_tprc_restart_begins(ls_info *ls); +void hmrt_tprc_restart_ends(ls_info *ls); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void hmrt_sltc_signalling_link_test_ack(BYTE chl); +void hmrt_sltc_signalling_link_test_msg(BYTE chl); +void hmrt_tcbc_changeback_ack(BYTE chl); +void hmrt_tcbc_changeback_declaration(BYTE chl); +void hmrt_tcoc_changeover_ack(BYTE chl); +void hmrt_tcoc_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_ack(BYTE chl); +void hmrt_tcoc_emergency_changeover_order(BYTE chl); +void hmrt_tcbc_update_routing_tables(BYTE chl); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void hmrt_tlac_emergency_changeover_ack(BYTE chl); +void hmrt_tlac_force_uninhibit_signalling_link(BYTE chl); +void hmrt_tlac_inhibit_ack(BYTE chl); +void hmrt_tlac_inhibit_denied(BYTE chl); +void hmrt_tlac_local_inhibit_test(BYTE chl); +void hmrt_tlac_remote_inhibit_test(BYTE chl); +void hmrt_tlac_uninhibit_ack(BYTE chl); +void send_command_to_mtp2(BYTE chl, BYTE command); +void update_nid_table(BYTE ls, long dst, BYTE place); +void update_aid_table(BYTE ls, long dst, BYTE place); +void get_para_from_disk(); +int mtp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen); +int mtp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +void mtp_snmp_init(); +void tup_shm_init(); +void isup_shm_init(); +void sccp_shm_init(); +int GetMtp2Msg(DWORD ip_port); +void m3ua_timer(); +int GetM3uaMsg(DWORD port); +int tup_GetMsg(up_message *msgptr); +int isup_GetMsg(up_message *msgptr); +int sccp_GetMsg(up_message *msgptr); +int tup_to_mtp3(up_message *msgptr); +int isup_to_mtp3(up_message *msgptr); +int sccp_to_mtp3(up_message *msgptr); +void sltc_proc(BYTE chl); +void lsac_proc(BYTE chl); +void rtpc_proc(BYTE nw,BYTE dst); +void rtac_proc(BYTE nw,BYTE dst); +void tsrc_proc(BYTE chl); +void tlac_proc(BYTE chl); +void tcoc_proc(BYTE chl); +void tcbc_proc(BYTE chl); +void tprc_mgmt_signalling_point_restart_indication(); +void tprc_proc(); +void taprc_proc(BYTE linkset);/* adjacent sp restart control */ +void mtp_send_error(char *object,int chl, char *err_str); +void mtp_send_error2(BYTE *msg,BYTE sio,DWORD dpc,char *err_str,BYTE from); +int mtp_debug_set(); +void mtp_m_rt(); +void mtp_put_error(BYTE type,BYTE chl); +void mtp3_readpara_from_disk(); +BOOL iptrans_msg_flow(BYTE *msg,BYTE pclen,int direction,DWORD dest_ip); +BOOL iptrans_msg_flow_2(up_message *up_msg_ptr); +void mtp_prompt(char *object, BYTE value); +void set_heartbeat(BYTE reason,BYTE object); +void mtp3_send_alarm(WORD component_id,BYTE alarm_code); +void update_sls_to_link_table(int ls); +int update_ls_slc_table(int link); +void mtp3_debug(int n,const char *fmt,...); +void reset_mtp3(); +void mtp3Timer_proc(BYTE i); +int pc_length(BYTE nw); +void mtp3_showbuf(int n,BYTE *msg,int len); +int mtp3lite_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode); +void mtp3lite_upd_route_status(BYTE chl, BYTE flag); +int Mtp3BinSearchValue(BYTE low, BYTE high,BYTE nw,DWORD key); +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm); +BYTE MTP3_LINK_TYPE(BYTE Link); +int Mtp3AddSortRec(BYTE nw,DWORD dpc, DWORD real_index); +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm); diff --git a/omc/plat/mtp3_old/src/include/mtpstm.h b/omc/plat/mtp3_old/src/include/mtpstm.h new file mode 100644 index 0000000..43193b3 --- /dev/null +++ b/omc/plat/mtp3_old/src/include/mtpstm.h @@ -0,0 +1,259 @@ +#include "mtpconst.h" + +typedef struct ls_info{ + BYTE links_available; + BYTE links_available_t; + BYTE adjacentsp_acessible; + BYTE adjacentsp_restarting; + WORD adjacent_sp_place; + BYTE linksNum_configured; + + + BYTE influ_dstnum_asNLS; + BYTE influ_dstnum_asALS; + + BYTE influ_dstplace_intable_asNLS[MAX_LS_DPC]; + BYTE influ_dstplace_intable_asALS[MAX_LS_DPC]; +}ls_info; + +typedef struct mtp3_flow{ + DWORD UtoM[5]; + DWORD MtoI[5]; + DWORD ItoM[5]; + DWORD MtoU[5]; + DWORD stp[5]; + DWORD UtoM_throwed[5]; + DWORD MtoI_throwed[5]; + DWORD ItoM_throwed[5]; + DWORD MtoU_throwed[5]; + DWORD stp_throwed[5]; + DWORD stp_loop[5]; + DWORD isup_detail[32]; +}mtp3_flow; + +typedef struct network{ + BYTE routine[256]; /* bit0-1: normal route available + bit2-3: alternative route available + bit4-5: acessible + bit6-7: current route */ + BYTE rtpc_state[256]; + BYTE rtpc_input[256]; + BYTE rtac_state[256]; + BYTE rtac_input[256]; + BYTE rsrt_state[256]; + BYTE rsrt_input[256]; + BYTE rsrt_t10[256]; + BYTE m3ua_rc_status[256]; + mtp3_flow flow; +}network; + +typedef struct nw_para{ + DWORD dpc[256]; + BYTE normal_ls[256]; + BYTE alternative_ls[256]; + DWORD opc24; + DWORD opc14; + BYTE mtp3_t8[256]; + BYTE mtp3_t15[256]; + BYTE mtp3_t16[256]; + BYTE acn[256][MAX_ACN_NUM]; + BYTE ansi_local14b; + BYTE ansi_local24b; + BYTE ansi_remote[256]; + DWORD rc[256]; +}nw_para; + +typedef struct 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));//Bit0:0=ss7,1=m2ua + //Bit1:1=enable,0=disable + //Bit2:0=MTP3,1=MTP3LITE + //BIT3:0=server,1=client + BYTE e1_to_sg __attribute__((packed)); + BYTE e1_to_iid __attribute__((packed)); + DWORD remote_ip __attribute__((packed)); + BYTE inactive __attribute__((packed));// Inactivity timer + BYTE inactive_tm __attribute__((packed));// Allowed inactivity timeouts + DWORD e1_to_alterMTP3 __attribute__((packed));//alternative MTP3 +}lk_pro; + +typedef struct lk_timer +{ + BYTE t1;/* 500ms-1200ms */ + BYTE t2;/* 700ms-2000ms */ + BYTE t3;/* 500ms-1200ms */ + BYTE t4;/* 500ms-1200ms */ + BYTE t5;/* 500ms-1200ms */ + BYTE t7;/* 1s-2s */ + BYTE t8;/* 800ms-1200ms */ + BYTE t12;/* 800ms-1500ms */ + BYTE t13;/* 800ms-1500ms */ + BYTE t14;/* 2s-3s */ + BYTE t22; + BYTE t23; +}lk_timer; + +typedef struct sg_para +{ + BYTE enable __attribute__((packed)); + BYTE server __attribute__((packed)); + BYTE data_ack __attribute__((packed)); + DWORD ip __attribute__((packed)); +}sg_para; + +typedef struct MTP3Parameter +{ + lk_pro lk[256]; + lk_timer lt[256]; + sg_para sg[256]; + BYTE nw_pro; + DWORD ls_op_pc[128];/* for 128 linkset */ + BYTE ls_pro[128]; + char ls_reserved[128][16];//each linkset reserved 16 bytes for omc + BYTE mtp3_t10; + BYTE mtp3_t18; + BYTE mtp3_t19; + BYTE mtp3_t20; + WORD mtp3_t21; + WORD mtp3lite_port; + nw_para nw[4]; + BYTE localAcn[MAX_ACN_NUM]; + ull MTP3SerialNum; +}MTP3Parameter; + +typedef struct mtp{ + ls_info ls[128]; + network nw[4]; +}mtp; + +typedef struct measure_of_mtp3{ + long time_stamp; + DWORD lk_measure1[256][9];/* link measure oid=*.1 */ + DWORD ls_measure[128][8];/* linkset measure oid=*.3 */ +/*** traffic */ +// DWORD tf_measure1[6][20];/* traffic octets */ + DWORD tf_measure2[6][20];/* traffic MSUs */ + DWORD tf_measure5[3]; +}measure_of_mtp3; + +typedef struct mtp3_csta{ + measure_of_mtp3 measure[96]; +}mtp3_csta; + +typedef struct heartbeat_compoent_of_mtp3 +{ + BYTE version[3]; + BYTE state; + BYTE link_state[64]; + BYTE linkset_state[32]; + BYTE masterMTP3[32]; + BYTE SubState[2]; +}heartbeat_compoent_of_mtp3; + +typedef struct mtp2_heartbeat +{ + BYTE systemid; + BYTE moduleid; + BYTE timestamp[4]; + BYTE led_ctl_code[8]; + BYTE alarm_component; + BYTE alarm_code; + BYTE reserved; + BYTE l1_state; + BYTE l2_state[8]; + BYTE e1_dstip[8]; + BYTE retrieved_bsnt[8]; +}mtp2_heartbeat; + +typedef struct mtp3DPCIndex +{ + DWORD sortedNum; + DWORD dpc[256]; + DWORD index[256]; +}mtp3DPCIndex; + +typedef struct mtp3_dpc_index +{ + mtp3DPCIndex nw[4]; +}mtp3_dpc_index; + +/* by simon at 23/9/26 */ +//extern mtp3_dpc_index mtp3SortRoutine; + +typedef struct _mtp3_state +{ + BYTE link_l1_state[256]; + BYTE link_l2_state[256]; + BYTE link_l3_state[256]; + BYTE lk_configured[256]; + BYTE lk_command[256]; + BYTE link_type[256]; + DWORD lk_mtp3[256]; + BYTE lk_NMTP3_ok[256];//normal mtp3 ok + BYTE lk_AMTP3_ok[256];//alternative mtp3 ok + + BYTE lk_SpecANSI_flag[256]; + //special ANSI, use the Signalling network testing and maintenance special message + + BYTE lsac_state[256]; + BYTE tlac_state[256]; + BYTE tcoc_state[256]; + BYTE tcbc_state[256]; + BYTE tsrc_state[256]; + BYTE sltc_state[256]; + BYTE tprc_state; + + BYTE MTP3WatchDog[256]; +}_mtp3_state; +/* by simon at 23/9/26 */ +//extern _mtp3_state mtp3ObjState; + +typedef struct _mtp3_input +{ + BYTE lsac_input_from_l2[256]; + BYTE lsac_input_from_sltc[256]; + BYTE lsac_input_from_stm[256]; + BYTE lsac_input_from_tcoc[256]; + BYTE lsac_input_from_mgmt[256]; + BYTE tlac_input_from_slm[256]; + BYTE tlac_input_from_mgmt[256]; + BYTE tlac_input_from_stm[256]; + BYTE tlac_input_from_hmdt[256]; + BYTE tlac_input_from_Tctl[256];/* input from timer control center*/ + BYTE tsrc_input_from_tcoc[256]; + BYTE tsrc_input_from_tcbc[256]; + BYTE tsrc_input_from_stm[256]; + BYTE tsrc_input_from_tlac[256]; + BYTE tcoc_input_from_tsrc[256]; + BYTE tcoc_input_from_stm[256]; + BYTE tcoc_input_from_hmdt[256]; + BYTE tcbc_input[256]; + BYTE tcbc_input_from_tsrc[256]; + BYTE sltc_input[256]; + BYTE tprc_input; + BYTE taprc_input[128]; +}_mtp3_input; +/* by simon at 23/9/26 */ +//extern _mtp3_input mtp3ObjInput; + +typedef struct _mtp3_IPMng +{ + BYTE mtp3_flag_new[MAX_MTP3_NUM]; + BYTE mtp3_flag_old[MAX_MTP3_NUM]; + DWORD mtp3_flag_ip[MAX_MTP3_NUM]; + + BYTE LinkIPNum; + DWORD LinkIP[MAX_MTP3_NUM]; + BYTE LinkIPSubSta[MAX_MTP3_NUM][2]; +}_mtp3_IPMng; + +typedef struct _mtp3_dynamic_opc +{ + BYTE opc_num[4]; + DWORD opc[4][MTP3_MAX_DYNAMIC_OPC_PER_NW]; +}mtp3_dynamic_opc; +/* by simon at 23/9/26 */ +//extern _mtp3_IPMng MTP3IPMng; diff --git a/omc/plat/mtp3_old/src/mtp3lite.c b/omc/plat/mtp3_old/src/mtp3lite.c new file mode 100644 index 0000000..8533e4b --- /dev/null +++ b/omc/plat/mtp3_old/src/mtp3lite.c @@ -0,0 +1,742 @@ +/****************************************************/ +/* MTP3LITE Implementation Program */ +/* Version 10.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2005-04-7 */ +/* Modify : Victor Luo, 2005-07-14 add TCP client for mtp3lite*/ +/****************************************************/ + +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtp3lite.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +BYTE mtp3lite_ka_msg[3]; +mtp3lite_lk mtp3lite_link[256]; +int mtp3lite_listen_fd; +BYTE mtp3lite_msg_buf[256][MTP3LITE_MSG_BUF_SIZE_PER_LINK]; +BYTE mtp3lite_rem_len[256]; +BYTE mtp3lite_id_fg[256]; + +/*@ignore@*/ +void mtp3lite_print_msg(BYTE *ptr, WORD len) +{ + int i; + + for (i = 0; i < len; i++) + { + printf("%X ", ptr[i]); + } + printf("\n"); +} + +void mtp3lite_init_lk(BYTE lk) +{ + mtp3lite_link[lk].connfd = -1; + mtp3lite_link[lk].cliSockfd = -1; + mtp3lite_link[lk].remote_port = 0; + mtp3lite_link[lk].local_inactive = 2000; // 20 seconds + mtp3lite_link[lk].local_reconnect = 10; // 10 * 2.56 seconds + mtp3lite_link[lk].remote_inactive = mtp3_para->lk[lk].inactive * 100; + mtp3lite_link[lk].remote_inactive_timeouts = mtp3_para->lk[lk].inactive_tm; + mtp3lite_link[lk].init_guard_timer = 2000; // 20 seconds + mtp3lite_msg_buf[lk][0] = 0; + mtp3lite_rem_len[lk] = 0; + mtp3lite_id_fg[lk] = 0; +} + +void mtp3lite_init_ka_msg(void) +{ + mtp3lite_ka_msg[0] = 2; + mtp3lite_ka_msg[1] = 0x4B; + mtp3lite_ka_msg[2] = 0x41; +} + +int mtp3lite_Init_TCPSocket(struct sockaddr_in saddr,int needBind) +{ //flag,0=client, 1=server + int sock; + long sockbuf = 40*1024; + int on = 1, timeout = 20; + + sock = socket(AF_INET, SOCK_STREAM, 0); + + if (sock < 0) + { + fprintf(stderr,"Socket() failed\n"); + return -3; + } + + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &sockbuf, sizeof(sockbuf)) != 0) + { + fprintf(stderr,"set socket buffer failed\n"); + return -4; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + &on,sizeof(on)) != 0) + { + fprintf(stderr,"set addr reusable failed\n"); + return -5; + } + + if (setsockopt(sock,SOL_SOCKET, SO_KEEPALIVE, + &timeout, sizeof(timeout)) != 0) + { + fprintf(stderr,"set keepalive failed\n"); + return -6; + } + + if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr,"set nonblock failed\n"); + return -7; + } + + if(needBind) + { + if (bind(sock, (struct sockaddr*)&saddr, sizeof(struct sockaddr)) < 0) + { + fprintf(stderr,"MTP3LITE bind failed,port:%d\n",htons(saddr.sin_port)); + close(sock); + return -2; + } + } + return sock; +} + +int mtp3lite_InitServerSocket() +{ + struct sockaddr_in sin_addr; + + memset(&sin_addr, 0, sizeof(struct sockaddr)); + sin_addr.sin_family = AF_INET; + //sin_addr.sin_port = htons(mtp3lite_port); + sin_addr.sin_port = mtp3_para->mtp3lite_port; + sin_addr.sin_addr.s_addr = INADDR_ANY; + bzero(&(sin_addr.sin_zero),8); + + if ((mtp3lite_listen_fd = mtp3lite_Init_TCPSocket(sin_addr,1)) < 0) + { + printf("MTP3LITE TCP Socket(%X) Init Failed!\n", mtp3_para->mtp3lite_port); + exit(1); + } + else + listen(mtp3lite_listen_fd, 1); + + printf("mtp3lite_listen_fd: %d\n", mtp3lite_listen_fd); + + return 1; +} + +int isMtp3LiteClientLink(BYTE lk) +{ + //4bits:none sigtran, link enable, mtp3lite enable,client + if ((mtp3_para->lk[lk].e1_lk_type & 0x1f)==0x15 && mtp3_para->lk[lk].remote_ip>0) + { + return 1; + } + return 0; +} + +int checkIfOveridesocket(BYTE lk) +{ + int i; + for(i=0;ilk[lk].remote_ip==mtp3_para->lk[i].remote_ip) + { + printf("mtp3lite client, lk %d is overide with %d \n",lk,i); + return 1; + } + } + return 0; +} + + +int mtp3lite_InitClientSocket(BYTE lk) +{ + struct sockaddr_in sin_addr; + int socketfd; + + bzero(&sin_addr,sizeof(struct sockaddr)); + sin_addr.sin_family = AF_INET; + //sin_addr.sin_port = htons(mtp3lite_port); + + mtp3lite_link[lk].cliSockfd = -1; + if (isMtp3LiteClientLink(lk) && !checkIfOveridesocket(lk)) + { + //sin_addr.sin_port = mtp3_para->mtp3lite_port; //server port,tmp + //sin_addr.sin_addr.s_addr = mtp3_para->lk[lk].remote_ip; + //bzero(&(sin_addr.sin_zero),8); + if ((socketfd = mtp3lite_Init_TCPSocket(sin_addr,0)) < 0) + { + printf("MTP3LITE TCP Client Socket(%d) Init Failed!\n",mtp3_para->mtp3lite_port); + //exit(1); + return 0; + } + mtp3lite_link[lk].cliSockfd = socketfd; + printf("mtp3lite: init client socket link=%d\n",lk); + } + + return 1; +} + +int mtp3lite_CloseTcpConn(BYTE link) +{ + if(mtp3lite_link[link].connfd>=0) + close(mtp3lite_link[link].connfd); + if(mtp3lite_link[link].cliSockfd>=0) + close(mtp3lite_link[link].cliSockfd); + mtp3lite_init_lk(link); + + return 1; +} + +int mtp3lite_get_lk_by_ip(struct sockaddr_in *client_addr) +{ + int lk; + + for (lk = 0; lk < 256; lk++) + { + if ((mtp3_para->lk[lk].remote_ip == client_addr->sin_addr.s_addr) && + (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) && + ((mtp3_para->lk[lk].e1_lk_type & 0x1f) == 0x05) && // Server & MTP3LITE & Enabled + (mtp3ObjState.lk_command[lk]!=0)) //Command enabled + { + if (mtp3lite_link[lk].connfd > 0) + { + mtp3lite_CloseTcpConn(lk); + mtp3lite_updateStatus(lk, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } + else if (mtp3lite_link[lk].init_guard_timer == 0) + return lk; + return -1; + } + } + + return -1; +} + +int mtp3lite_DirectSendMsg(BYTE link, int len, BYTE *msg_ptr) +{ + struct sockaddr_in sin; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link] == 0) || // Command Disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + bzero(&sin.sin_zero, sizeof(sin.sin_zero)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = mtp3_para->lk[link].remote_ip; + sin.sin_port = mtp3lite_link[link].remote_port; + + return send(mtp3lite_link[link].connfd, msg_ptr, len, MSG_NOSIGNAL); +} + +int mtp3liteTcpConnect(int sock,struct sockaddr_in *sin_addr) +{ + if (connect(sock, (struct sockaddr *)sin_addr, sizeof(struct sockaddr)) < 0) + { + return 0; + } + else + { + printf("tcpConnect success, ip=%s\n",inet_ntoa(sin_addr->sin_addr)); + return 1; + } +} + +int mtp3lite_TcpConnectCheck() +{ + int timeout = 20; + int connfdtmp = 0; + socklen_t clilen; + struct sockaddr_in cliaddr; + int link; + static BYTE cliLk=0; + + bzero(&cliaddr,(clilen = sizeof(struct sockaddr))); + + connfdtmp = accept(mtp3lite_listen_fd,(struct sockaddr *)&cliaddr,&clilen); + if (connfdtmp <= 0)//no connect request , check client socke + { + link = cliLk++; + if (!isMtp3LiteClientLink(link)) + return 0; + if (mtp3lite_link[link].connfd > 0) + return 0; + else if (mtp3lite_link[link].local_reconnect > 0) + { + mtp3lite_link[link].local_reconnect--; + return 0; + } + + if (mtp3lite_link[link].cliSockfd <= 0) + { + if (!mtp3lite_InitClientSocket(link)) + mtp3lite_init_lk(link); + } + cliaddr.sin_family = AF_INET; + cliaddr.sin_port = mtp3_para->mtp3lite_port; + cliaddr.sin_addr.s_addr = mtp3_para->lk[link].remote_ip; + bzero(&(cliaddr.sin_zero),8); + connfdtmp = mtp3lite_link[link].cliSockfd; + if (!mtp3liteTcpConnect(connfdtmp, &cliaddr)) + { + if ((errno != EINPROGRESS) && (errno != EALREADY)) + mtp3lite_CloseTcpConn(link); + return 0; + } + } + else if ((link = mtp3lite_get_lk_by_ip(&cliaddr)) < 0) + { + close(connfdtmp); + return 0; + } + + mtp3lite_init_lk(link); + mtp3lite_link[link].init_guard_timer = 0; + mtp3lite_link[link].connfd = connfdtmp; + mtp3lite_link[link].cliSockfd = connfdtmp; + mtp3lite_link[link].remote_port = cliaddr.sin_port; + printf("link[%d] connfd: %d, rem_port: %d\n", link, connfdtmp, ntohs(mtp3lite_link[link].remote_port)); + + fcntl(mtp3lite_link[link].connfd,F_SETFL,O_NONBLOCK); + if (setsockopt(mtp3lite_link[link].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) != 0) + fprintf(stderr,"set keepalive failed\n"); + if (setsockopt(mtp3lite_link[link].connfd,SOL_SOCKET,SO_KEEPALIVE, + &timeout,sizeof(timeout)) !=0) + fprintf(stderr,"set keepalive failed\n"); + + mtp3lite_updateStatus(link, MTP2_STATE_WORKING, 0); +// mtp3lite_DirectSendMsg(link, 3, mtp3lite_ka_msg); + + return 1; +} + +int mtp3lite_DirectRecvMsg(BYTE link) +{ + struct sockaddr_in sin; + int len, nbytes; + BYTE len1; + + len = sizeof(struct sockaddr); + if ((len1 = mtp3lite_rem_len[link])>0) + printf("len1: %d\n", len1); + nbytes = recvfrom(mtp3lite_link[link].connfd, mtp3lite_msg_buf[link] + len1, + MTP3LITE_MSG_BUF_SIZE_PER_LINK - len1, 0, (struct sockaddr *) &sin, &len); + + if (nbytes == 0) + { + printf("tcp link[%d] error : %d\n", link, errno); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_TCP_FAILURE); + mtp3lite_rem_len[link] = 0; + } + + if ((len1 > 0) && (nbytes > 0)) + nbytes += len1; + + return nbytes; +} +/* +int mtp3lite_decode_tcp_msg(WORD total_len, BYTE link) +{ + BYTE lk_set, *buf_ptr; + WORD sub_len, rem_len, total_hdl_len = 0; + up_message up_msg; + up_message *up_msg_ptr = &up_msg; + BYTE nw; + + if (total_len > MTP3LITE_MSG_BUF_SIZE_PER_LINK) + return -1; + + while (total_hdl_len < total_len) + { + buf_ptr = mtp3lite_msg_buf[link] + total_hdl_len; + rem_len = total_len - total_hdl_len; + sub_len = buf_ptr[0]; + + if (rem_len < (sub_len + 1)) + { + if (total_hdl_len > 0) + memcpy(mtp3lite_msg_buf[link], mtp3lite_msg_buf[link] + total_hdl_len, rem_len); + mtp3lite_rem_len[link] = rem_len; + //printf("Remain: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + return 1; + } + + if (sub_len < 2) + return -1; + else if (sub_len == 2) + { + if ((buf_ptr[1] == 0x4B) && (buf_ptr[2] == 0x41)) + { // Receive Keep Alive Message + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + //mtp3lite_print_msg(buf_ptr, 3); + total_hdl_len += (sub_len + 1); + //printf("KeepAlive: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + continue; + } + else + return -1; + } + + if ((buf_ptr[1] > 9) || (buf_ptr[1] == 0)) + return -1; + + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + + //mtp3lite_print_msg(buf_ptr, sub_len + 1); + + up_msg_ptr->len = sub_len; + up_msg_ptr->link = link; + lk_set = mtp3_para->lk[link].e1_to_linkset; + if (lk_set >= 128) + return -1; + nw = mtp3_para->ls_pro[lk_set] & 3; + up_msg_ptr->sio = 0x03 | (nw << 6) | 0x10;//sccp lite always ansi message + up_msg_ptr->opc = mtp3_para->ls_op_pc[lk_set]; + if (pc_length(up_msg_ptr->sio >> 6) == MTP3_24BIT_PC) + up_msg_ptr->dpc = mtp3_para->nw[nw].opc24; + else + up_msg_ptr->dpc = mtp3_para->nw[nw].opc14; + + memcpy(up_msg_ptr->msgList, buf_ptr + 1, sub_len); + + iptrans_msg_flow_2(up_msg_ptr); + send_to_sccp_lite(up_msg_ptr); + + total_hdl_len += (sub_len + 1); + //printf("Data: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + } + + mtp3lite_rem_len[link] = 0; + return 1; +} +*/ +/******change to struct: 00, len, 0xfd*****/ +int mtp3lite_decode_tcp_msg(WORD total_len, BYTE link) +{ + BYTE lk_set, *buf_ptr; + WORD sub_len, rem_len, total_hdl_len = 0; + up_message up_msg; + up_message *up_msg_ptr = &up_msg; + BYTE nw; + + if (total_len > MTP3LITE_MSG_BUF_SIZE_PER_LINK) + return -1; + + while (total_hdl_len < total_len) + { + buf_ptr = mtp3lite_msg_buf[link] + total_hdl_len; + rem_len = total_len - total_hdl_len; + sub_len = (buf_ptr[0]<<8) + buf_ptr[1]; + + if (rem_len < (sub_len + 1)) + { + if (total_hdl_len > 0) + memcpy(mtp3lite_msg_buf[link], mtp3lite_msg_buf[link] + total_hdl_len, rem_len); + mtp3lite_rem_len[link] = rem_len; + //printf("Remain: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + return 1; + } + + if (sub_len < 1) + return -1; + else if (sub_len == 1) + { + if(buf_ptr[1+2] == 0x6) + { // Receive Keep Alive Message + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + //mtp3lite_print_msg(buf_ptr, 3); + total_hdl_len += (sub_len + 3); + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d RECV Inditify ACK",link); + //printf("KeepAlive: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + continue; + } + else + return -1; + } + + // if ((buf_ptr[1+2] > 9) || (buf_ptr[1+2] == 0)) + // return -1; + + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + mtp3lite_link[link].remote_inactive_timeouts = 0; + + //mtp3lite_print_msg(buf_ptr, sub_len + 1); + + up_msg_ptr->len = sub_len; + up_msg_ptr->link = link; + lk_set = mtp3_para->lk[link].e1_to_linkset; + if (lk_set >= 128) + return -1; + nw = mtp3_para->ls_pro[lk_set] & 3; + up_msg_ptr->sio = 0x03 | (nw << 6);//sccp lite always itu message + up_msg_ptr->opc = mtp3_para->ls_op_pc[lk_set]; + if (pc_length(up_msg_ptr->sio >> 6) == MTP3_24BIT_PC) + up_msg_ptr->dpc = mtp3_para->nw[nw].opc24; + else + up_msg_ptr->dpc = mtp3_para->nw[nw].opc14; + + memcpy(up_msg_ptr->msgList, buf_ptr + 1 + 2, sub_len); + + iptrans_msg_flow_2(up_msg_ptr); + send_to_sccp_lite(up_msg_ptr); + + total_hdl_len += (sub_len + 1 + 2); + //printf("Data: total_len: %d, total_hld_len: %d, sub_len: %d, rem_len: %d\n", total_len, total_hdl_len, sub_len, rem_len); + } + + mtp3lite_rem_len[link] = 0; + return 1; +} + +int send_mtp3lite_id_ack(BYTE link) +{ + BYTE id_ack_msg[4]={0,0x1,0xfe, 0x6}; + + mtp3lite_DirectSendMsg(link, 4, id_ack_msg); + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d send Inditify ACK",link); + return 1; +} + +int get_mtp3lite_msg(BYTE link) +{ + int nbytes; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + { + return -1; + } + + if ((nbytes = mtp3lite_DirectRecvMsg(link)) <= 0) + return -1; + + //mtp3lite_print_msg(mtp3lite_msg_buf[link], nbytes); + + if (mtp3lite_decode_tcp_msg(nbytes, link) < 0) + { + printf("tcp link[%d] decode error!\n", link); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_TCP_FAILURE); + mtp3lite_rem_len[link] = 0; + return -1; + } + + return 1; +} + +int put_mtp3lite_msg(BYTE *msg_ptr) +{ + BYTE link, ls, nw, pclen, offset; + WORD len; + + link = msg_ptr[0]; + len = (msg_ptr[1]<<8) + msg_ptr[2]; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // Command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + if ((ls = mtp3_para->lk[link].e1_to_linkset) >= 128) + return -1; + + nw = mtp3_para->ls_pro[ls] & 0x03; + pclen = (mtp3_para->nw_pro >> nw) & 0x01; + + if (pclen) + { + if (len <= 8) + return -1; + offset = 9+1;//msg_ptr[offset+1] = sccp data + msg_ptr[offset-1] = (len - 8)%0xff; + msg_ptr[offset-2] = (len - 8)/0xff; + len = len - 7+2; + } + else + { + if (len <= 5) + return -1; + offset = 6+1; + msg_ptr[offset-1] = (len - 5)%0xff; + msg_ptr[offset-2] = (len - 5)/0xff; + len = len - 4+2; + } +/******change to struct: 00, len, 0xfd*****/ + msg_ptr[offset] = 0xfd; + +/******change to struct: 00, len, 0xfd*****/ + mtp3lite_DirectSendMsg(link, len, msg_ptr + offset - 2); + //mtp3lite_link[link].local_inactive = 2000; + + return 0; +} +/* +int put_mtp3lite_msg(BYTE *msg_ptr) +{ + BYTE link, len, ls, nw, pclen, offset; + + link = msg_ptr[0]; + len = msg_ptr[1]; + + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link]==0) || // Command disabled + (mtp3lite_link[link].connfd <= 0)) // Link Not Established + return -1; + + if ((ls = mtp3_para->lk[link].e1_to_linkset) >= 128) + return -1; + + nw = mtp3_para->ls_pro[ls] & 0x03; + pclen = (mtp3_para->nw_pro >> nw) & 0x01; + + if (pclen) + { + if (len <= 8) + return -1; + offset = 9; + msg_ptr[offset] = len - 8; + len = len - 7; + } + else + { + if (len <= 5) + return -1; + offset = 6; + msg_ptr[offset] = len - 5; + len = len - 4; + } + + mtp3lite_DirectSendMsg(link, len, msg_ptr + offset); + //mtp3lite_link[link].local_inactive = 2000; + + return 0; +} +*/ +int mtp3lite_chk_lk(BYTE link) +{ +// char str[19]={7,0,0x11,0x83,0x71,0xab,0xdc,0x1a,0x06,0xf6, 0,0,0,1,5,1,3,2,9,4}; + if ((MTP3_LINK_TYPE(link) != LKTYPE_MTP3_LITE) || // Not MTP3LITE + !(mtp3_para->lk[link].e1_lk_type & 0x01) || // Not Enabled + (mtp3ObjState.lk_command[link] == 0)) // Command disabled + return 0; + + if (mtp3lite_link[link].init_guard_timer > 0) + mtp3lite_link[link].init_guard_timer--; + + if (mtp3lite_link[link].connfd <= 0) // Link Not Established + return 0; + + if (mtp3lite_link[link].remote_inactive > 0) + { + if (--mtp3lite_link[link].remote_inactive == 0) + { + +// if (++mtp3lite_link[link].remote_inactive_timeouts >= mtp3_para->lk[link].inactive_tm) + if(0) + { + printf("link[%d] remote inactivity %d seconds timeout %d times!\n", link, mtp3_para->lk[link].inactive, mtp3_para->lk[link].inactive_tm); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } + else + { + mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100; + } + } + } + + if (mtp3lite_link[link].local_inactive > 0) + { + if(mtp3lite_id_fg[link]==0) + { + mtp3lite_id_fg[link] = 1; + send_mtp3lite_id_ack(link); + } + if (--mtp3lite_link[link].local_inactive == 0) + { +// mtp3lite_DirectSendMsg(link, 3, mtp3lite_ka_msg); +// put_mtp3lite_msg(&str); + mtp3lite_link[link].local_inactive = 2000; + } + } + + return 1; +} + +void deactive_mtp3lite_lk(link) +{ + if ((MTP3_LINK_TYPE(link) == LKTYPE_MTP3_LITE) && // MTP3LITE + (mtp3_para->lk[link].e1_lk_type & 0x01) && // Enabled + (mtp3lite_link[link].connfd > 0)) + {//sccp lite link + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d Deactive by MNG",link); + mtp3lite_CloseTcpConn(link); + mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_INACTIVITY_TIMEOUT); + } +} + +void mtp3lite_init(void) +{ + int i; + + printf("MTP3LITE Init Start!\n"); + + for (i = 0; i < 256; i++) + { + mtp3lite_init_lk(i); + mtp3lite_InitClientSocket(i); + } + + mtp3lite_listen_fd = -1; + +// mtp3lite_InitServerSocket(); + + mtp3lite_init_ka_msg();//keep alive message + + printf("MTP3LITE Init Complete!\n"); +} + +void mtp3lite_reset(void) +{ + int link; + + for (link=0;link<256;link++) + { + if (mtp3lite_link[link].connfd >=0) + { + mtp3lite_CloseTcpConn(link); + mtp3lite_rem_len[link] = 0; + } + } +} + +void mtp3lite_timer(void) +{ + int link; + + mtp3lite_TcpConnectCheck(); + + for (link = 0; link < 256; link++) + { + get_mtp3lite_msg(link); + mtp3lite_chk_lk(link); + } +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpinit.c b/omc/plat/mtp3_old/src/mtpinit.c new file mode 100644 index 0000000..19439f1 --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpinit.c @@ -0,0 +1,2018 @@ +#include "../../public/src/include/includes.h" +#include "../../debug/src/include/debug.h" +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpdef.h" +#include "./include/mtpfunc.h" +#include "./include/mtp3lite.h" + + +/*@ignore@*/ +#define PROG_NAME "iptrans" + +extern iprt1 mtp3_iprt; +struct tm mtp3_tm; +struct tm *mtp3_time = &mtp3_tm; +iptrans_shm *IPTRANS_shm_ptr; +static int iptrans_shm_id; +tup_shm *T_shm_ptr; +isup_shm *I_shm_ptr; +bicc_shm *B_shm_ptr; +sccp_shm *S_shm_ptr; +primitive_to_isup *I_primitive; +primitive_to_bicc *B_primitive; +primitive_to_sccp *S_primitive; +primitive_to_tup *T_primitive; + +primitive_to_isup I_primitive_init; +primitive_to_bicc B_primitive_init; +primitive_to_sccp S_primitive_init; +primitive_to_tup T_primitive_init; +tup_shm tup_shm_ptr_init; +isup_shm isup_shm_ptr_init; +bicc_shm bicc_shm_ptr_init; +sccp_shm sccp_shm_ptr_init; + +BOOL mtp3DebugFull=0; +mtp3_routing_result routingResult; +void scan_conf_right_or_not(BYTE nw); +void rsrt_proc(BYTE netw,BYTE dst); +void mtp3lite_reset(void); +void otherMTP3_managed_link_unavailable(BYTE chl); + +int mtp3lite_InitServerSocket(); +extern int mtp3lite_listen_fd; +extern ull Str2Ull(char *pStr); +extern void send_to_mtp2(long dest_ip); +extern void send_to_mtp2_new_struct(long dest_ip);//link,len_high,len_low,sio... +extern void MTP3_send_isup_count(BYTE nw,BYTE type); +extern void get_routes_from_other_plat(); +extern void deactive_m3ua_lk(BYTE link); + +void send_ip_to_mtp2(); + +void mtp3_init_dynamic_opc() +{ + memset((BYTE *)&mtp3_opc, 0, sizeof(mtp3_dynamic_opc)); +} + +int mtp3_create_opc(BYTE nw, DWORD opc) +{ + BYTE i, pclen, num; + DWORD para_opc; + + if ((nw > 3) || (opc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (opc == para_opc) + return 0; + + num = mtp3_opc.opc_num[nw]; + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == opc) + return 0; + } + + if (num >= MTP3_MAX_DYNAMIC_OPC_PER_NW) + return -1; + + mtp3_opc.opc[nw][num] = opc; + mtp3_opc.opc_num[nw]++; + + return 0; +} + +int mtp3_delete_opc(BYTE nw, DWORD opc) +{ + BYTE i, pclen, num, num_mv; + DWORD para_opc; + + if ((nw > 3) || (opc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (opc == para_opc) + return 0; + + num = mtp3_opc.opc_num[nw]; + if (num == 0) + return -1; + + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == opc) + { + num_mv = num - i - 1; + memcpy((BYTE *) &mtp3_opc.opc[nw][i], (BYTE *) &mtp3_opc.opc[nw][i+1], num_mv * sizeof(DWORD)); + mtp3_opc.opc_num[nw]--; + return 0; + } + } + + return -1; +} + +BYTE mtp3_check_dpc_equal_to_opc(BYTE nw, DWORD dpc) +{ + BYTE i, pclen, num; + DWORD para_opc; + + if ((nw > 3) || (dpc == 0)) + return -1; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC) + para_opc = mtp3_para->nw[nw].opc24; + else + para_opc = mtp3_para->nw[nw].opc14; + if (dpc == para_opc) + return 1; + + num = mtp3_opc.opc_num[nw]; + for (i = 0; i < num; i++) + { + if (mtp3_opc.opc[nw][i] == dpc) + return 1; + } + + return 0; +} + +BYTE MTP3_LINK_TYPE(BYTE Link) +{ + return (mtp3_para->lk[Link].e1_lk_type >> 1) & 0x07; +} + +void MTP3_Enable_SubSystem(BYTE SubSystem) +{ + SubSystem &= 15; + + if (SubSystem < 8) + mtp3_heartbeat.SubState[0] |= (1 << SubSystem); + else + mtp3_heartbeat.SubState[1] |= (1 << (SubSystem & 7)); +} + +void MTP3_Disable_SubSystem(BYTE SubSystem) +{ + SubSystem &= 15; + + if (SubSystem < 8) + mtp3_heartbeat.SubState[0] |= (~(1 << SubSystem)); + else + mtp3_heartbeat.SubState[1] |= (~(1 << (SubSystem & 7))); + +} + +void scan_lk_state_quickly(BYTE lk) +{ + if (mtp3ObjState.lk_configured[lk] != PARA_CONFIGURED) + { + lk = lk+1; + return; + } + if (mtp3ObjState.link_l3_state[lk] != AVAILABLE) + { + current_measure->lk_measure1[lk][3]++;//Duration of SL unavailability(for any reason + } + else if (mtp3ObjState.link_l3_state[lk] == UNAVAILABLE) + current_measure->lk_measure1[lk][6]++;//Duration of SL unavailability due to link fai + if (mtp3ObjState.link_l3_state[lk] == INHIBITED) + { + if (link_locally_inhibited[lk] == TRUE) + { + current_measure->lk_measure1[lk][4]++;//Duration of SL inhibition due to local management actions + } + else + current_measure->lk_measure1[lk][5]++;//Duration of SL inhibition due to remote management actions + } + + if (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) + {//this mtp3 is the normal mtp3 of this link + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15)//Alternative MTP3 available + { +// mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + //do nothing, waiting for alternative unavailable + } + else if (mtp3ObjState.lk_NMTP3_ok[lk] >> 4)//if Alternative MTP3 not avilable and normal mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change from backup to normal",lk); + mtp3ObjState.lk_NMTP3_ok[lk] &= 0x0f; + if (mtp3ObjState.lk_mtp3[lk] == mtp3_para->lk[lk].e1_to_alterMTP3) + { + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + if (mtp3ObjState.link_l3_state[lk] == AVAILABLE) + otherMTP3_managed_link_unavailable(lk); + } + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else//other case normal is always the host + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else if (mtp3_para->lk[lk].e1_to_alterMTP3 == mtp3_localip) + {//this mtp3 is the alternative mtp3 of this link + if (mtp3ObjState.lk_mtp3[lk] == mtp3_localip)//it is the current host + { + if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==2)//only the deactivate command can make it abandon host + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change back to normal",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + +/* disable the link */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service (changing back to normal MTP3)",lk); + mtp3ObjInput.lsac_input_from_l2[lk] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjInput.sltc_input[lk] = SLTC_STOP; + sltc_proc(lk); + + /* send stop command to mtp2 */ + if (MTP3_LINK_TYPE(lk) == LKTYPE_SIGTRAN)//m2ua link + { + send_command_to_mtp2(lk,MTP2_DEACTIVE_LINK); + send_command_to_mtp2(lk,MTP3_M2UA_DISABLE); + } + else + send_command_to_mtp2(lk,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+lk,MTP3ALARM_LINK_CB_TO_NMTP3); + } + } + else + { + if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + {//normal ok + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + else if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==1)//if normal MTP3 not avilable and alternative mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change to alternative",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + } + } + } + + else + { + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + else if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + + if (mtp3ObjState.lk_mtp3[lk]==mtp3_localip) + { + mtp3_heartbeat.masterMTP3[lk/8] |= (1<<(lk&7)); + } + else + mtp3_heartbeat.masterMTP3[lk/8] &= (~(1<<(lk&7))); + + lk = lk+1; + + if (lk==255) + { + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + } +} + + +void MTP3_activate(DWORD ip) +{ + int chl; + + for (chl=0; chl<256; chl++) + { + if ( mtp3_para->lk[chl].e1_to_mtp3 == ip ) + { + if ((mtp3_para->lk[chl].e1_to_alterMTP3 != 0) && (mtp3_para->lk[chl].e1_to_alterMTP3 != 0xffffffff)) + { + mtp3ObjState.lk_NMTP3_ok[chl] = 0x11;// activated and set ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_ACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer active link %d normal MTP3",chl); + } + } + else if ( mtp3_para->lk[chl].e1_to_alterMTP3 == ip ) + { + mtp3ObjState.lk_AMTP3_ok[chl] = 0x11;// activated and set ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_ACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer active link %d alternative MTP3",chl); + mtp3_alterip = ip;//take over altermtp3 + } + } +} + +void MTP3_deactivate(DWORD ip) +{ + int chl; + + for (chl=0; chl<256; chl++) + { +/* if ( mtp3_para->lk[chl].e1_to_mtp3 == ip ) + { + if ((mtp3_para->lk[chl].e1_to_alterMTP3 != 0) && (mtp3_para->lk[chl].e1_to_alterMTP3 != 0xffffffff)) + { + mtp3ObjState.lk_NMTP3_ok[chl] = 0x20;//deactive and set not ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_DEACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer deactive link %d normal MTP3",chl); + } + } +*/ + if ( mtp3_para->lk[chl].e1_to_alterMTP3 == ip ) + { + mtp3ObjState.lk_AMTP3_ok[chl] = 0x20;//deactive and set not ok + mtp3ObjInput.lsac_input_from_mgmt[chl] = LSAC_MGMT_DEACTIVATE_LINK; + mtp3_debug(MTP3DB_EVENT,"Upper layer deactive link %d alternative MTP3",chl); + deactive_m3ua_lk(chl); + if ((MTP3_LINK_TYPE(chl) == LKTYPE_M3UA) && // M3UA + (mtp3_para->lk[chl].e1_lk_type & 0x01)) + scan_lk_state_quickly(chl); + mtp3_alterip = 0;//take over altermtp3 + } +// mtp3_heartbeat.link_state[chl/8] = mtp3_heartbeat.link_state[chl/8] & (~(1<<(chl&7))); + } +} + +BYTE *check_MTP3LinkType() +{ + return mtp3ObjState.link_type; +} + +BYTE *check_MTP3LinkL2State() +{ + return mtp3ObjState.link_l2_state; +} + +int mtp3_get_time() +{ + long curr_time; + curr_time = time((long *)0); + mtp3_time = localtime(&curr_time); + return 1; +} + +void mtp3_set_csta_p() +{ + BYTE csta_p; + long timestamp; + + csta_p = (mtp3_time->tm_hour*4+(mtp3_time->tm_min/15))%96; + if (mtp3_csta_p != csta_p) + {/* clear csta_p buffer */ + timestamp = time((long *)0); + memset(&mtp3_measure.measure[csta_p],0,sizeof(struct measure_of_mtp3)); + mtp3_measure.measure[csta_p].time_stamp = timestamp; + } + mtp3_csta_p = csta_p; + current_measure = &mtp3_measure.measure[mtp3_csta_p]; +} + +void mtp_lgetlocalip() +{ + struct hostent *host; + struct in_addr *hostip_addr; + char name[100]; + + gethostname(name,24); + if ( (host=gethostbyname(name)) == NULL ) + { + printf("MTP3 Get Host Name Failed!\n"); + exit(0); + } + hostip_addr = (struct in_addr*) (*host->h_addr_list); + mtp3_localip = hostip_addr->s_addr; +// return (unsigned char)host->h_addr_list[0][2]; +} + +void * +mtp3_ShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg) +{ +void *retp; +//char *func_name = "ShmInit"; + + shm_id = shmget(key, size, shmflg); + + retp = shmat(shm_id, (char *)0, 0); + + return retp; +} + +/*******************************/ + +void tup_shm_init() +{ + T_shm_ptr = &tup_shm_ptr_init; + T_shm_ptr->TM_Buf.RSub = 0; + T_shm_ptr->TM_Buf.WSub = 0; + T_shm_ptr->MT_Buf.RSub = 0; + T_shm_ptr->MT_Buf.WSub = 0; + + T_primitive = &T_primitive_init; + T_primitive->WSub = 0; + T_primitive->RSub = 0; +} + +void isup_shm_init() +{ + I_shm_ptr = &isup_shm_ptr_init; + I_shm_ptr->IM_Buf.RSub = 0; + I_shm_ptr->IM_Buf.WSub = 0; + I_shm_ptr->MI_Buf.RSub = 0; + I_shm_ptr->MI_Buf.WSub = 0; + + I_primitive = &I_primitive_init; + I_primitive->WSub = 0; + I_primitive->RSub = 0; +} + +void bicc_shm_init() +{ + B_shm_ptr = &bicc_shm_ptr_init; + B_shm_ptr->IM_Buf.RSub = 0; + B_shm_ptr->IM_Buf.WSub = 0; + B_shm_ptr->MI_Buf.RSub = 0; + B_shm_ptr->MI_Buf.WSub = 0; + + B_primitive = &B_primitive_init; + B_primitive->WSub = 0; + B_primitive->RSub = 0; +} + +void sccp_shm_init() +{ + S_shm_ptr = &sccp_shm_ptr_init; + S_shm_ptr->SM_Buf.RSub = 0; + S_shm_ptr->SM_Buf.WSub = 0; + S_shm_ptr->MS_Buf.RSub = 0; + S_shm_ptr->MS_Buf.WSub = 0; + + S_primitive = &S_primitive_init; + S_primitive->WSub = 0; + S_primitive->RSub = 0; +} + +void iptransInit_mtp3() +{ + /* + * Get shared memory block, + * IPTRANS_SHM_KEY to be defined in iptrans.h + */ + IPTRANS_shm_ptr = (iptrans_shm *) mtp3_ShmInit(iptrans_shm_id, PROG_NAME,IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT); +// memset(IPTRANS_shm_ptr, 0, sizeof(iptrans_shm)); +} + +void init_mtp3para() +{ + int i,j; + mtp3_para = &mtp3_para_init; + for (i=0; i<256; i++) + { + mtp3_para->lk[i].e1_to_linkset = 128; + mtp3_para->lk[i].e1_to_slc = 16; + for (j=0; j<4; j++) + { + mtp3_para->nw[j].normal_ls[i] = 128; + mtp3_para->nw[j].alternative_ls[i] = 128; + } + } +} + + +int mtp3_set_flag_ip(BYTE link, DWORD mtp3_ip) +{ + int i; + + + for(i = 0; i <= MAX_MTP3_NUM; i++) + { + if(MTP3IPMng.mtp3_flag_ip[i] == mtp3_ip) + return 2; + + } + for(i = 0; i <= MAX_MTP3_NUM; i++) + { + if(MTP3IPMng.mtp3_flag_ip[i] == 0) + { + MTP3IPMng.mtp3_flag_new[i] = 1; + MTP3IPMng.mtp3_flag_ip[i] = mtp3_ip; + return 1; + } + } + return 0; +} + + +void mtp3_set_link_manager(BYTE link) +{ + if (mtp3_para->lk[link].e1_to_mtp3 == mtp3_localip) + { + if (mtp3_para->lk[link].e1_to_alterMTP3 != 0 && mtp3_para->lk[link].e1_to_alterMTP3 != 0xffffffff) + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3ObjState.lk_AMTP3_ok[link] = 1; +// MTP3IPMng.mtp3_flag_new[0] = 1; +// MTP3IPMng.mtp3_flag_ip[0] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3_set_flag_ip(link, mtp3_localip); + if(mtp3_set_flag_ip(link, mtp3_para->lk[link].e1_to_alterMTP3)<=0) + { + printf("\r\n mtp3 set flag ip error! link=%d, e1_to_alterMTP3=%ld\r\n", link, mtp3_para->lk[link].e1_to_alterMTP3 ); + } + } + else + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + mtp3ObjState.lk_AMTP3_ok[link] = 0; + } + } + else if (mtp3_para->lk[link].e1_to_alterMTP3 == mtp3_localip) + { + if (mtp3_para->lk[link].e1_to_mtp3 != 0 && mtp3_para->lk[link].e1_to_mtp3 != 0xffffffff) + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + mtp3ObjState.lk_NMTP3_ok[link] = 1; +// MTP3IPMng.mtp3_flag_new[1] = 1; +// MTP3IPMng.mtp3_flag_ip[1] = mtp3_para->lk[0].e1_to_mtp3; + if(mtp3_set_flag_ip(link, mtp3_para->lk[link].e1_to_mtp3)<=0) + { + printf("\r\n mtp3 set flag ip error! link=%d, e1_to_mtp3=%ld\r\n", link, mtp3_para->lk[link].e1_to_mtp3 ); + } + } +/* else + { + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_alterMTP3; + mtp3ObjState.lk_NMTP3_ok[link] = 0; + }*/ + } + else + { + mtp3ObjState.lk_NMTP3_ok[link] = 0; + mtp3ObjState.lk_AMTP3_ok[link] = 0; + mtp3ObjState.lk_mtp3[link] = mtp3_para->lk[link].e1_to_mtp3; + } +} + +static void i_sys() +{ + int i; + BYTE version[3] = MTP3_VERSION; + + memset(&mtp3_heartbeat,0,sizeof(heartbeat_compoent_of_mtp3)); + memset(&mtp3SortRoutine,0,sizeof(mtp3_dpc_index)); + + for (i=0; i<32; i++) + { + mtp2_flag_new[i] = IDLE; + mtp2_flag_old[i] = IDLE; + } + for (i=0; ilk[i].e1_to_alterMTP3; + else if (mtp3ObjState.lk_NMTP3_ok[i]) + mtp3ObjState.lk_mtp3[i] = mtp3_para->lk[i].e1_to_MTP3; + else + mtp3ObjState.lk_mtp3[i] = 0;*/ + + wx5[i] = i*5; + debug_link[i] = MTP3_MSGLOG_OFF; + } + + mtp3_heartbeat.state = 0; + mtp3_heartbeat.SubState[0] = 0xff;//all subs system available + mtp3_heartbeat.SubState[1] = 0xff;//all subs system available + memcpy(mtp3_heartbeat.version,version,3); +} + +int MTP3_LinkIP_List(DWORD IP,BYTE mode) +{//mode=0:query ip, mode=1:add ip, mode=2:del ip + int i; + + if (IP==0 || IP==0xffffffff) + return -1; + + for (i=0;i1)) + memcpy(&MTP3IPMng.LinkIP[i],&MTP3IPMng.LinkIP[i+1],MTP3IPMng.LinkIPNum-i-1); + MTP3IPMng.LinkIPNum--; + } + return i; + } + } + + if (MTP3IPMng.LinkIPNum >= MAX_MTP3_NUM) + return 0; + + if (mode==1) + { + MTP3IPMng.LinkIP[MTP3IPMng.LinkIPNum] = IP; + MTP3IPMng.LinkIPNum = (MTP3IPMng.LinkIPNum + 1) & (MAX_MTP3_NUM-1); + return MTP3IPMng.LinkIPNum-1; + } + + return -1; +} + +/* slc0 slc1 slc3 slc5 +sls 0 1 2 3 +sls 4 5 6 7 +sls 8 9 10 11 +sls 12 13 14 15 */ + + +void update_sls_to_link_table(int ls) +{ + int i=0,j; + BYTE sls=0; + int lknum; + int place; + int lsx16; + int link; + + lsx16 = ls*16; + lknum = mtp3.ls[ls].linksNum_configured; +// lknum = linknum_in_ls[ls]; + if (lknum > 0) + { + for (sls=0; sls<16; sls++) + { + place = sls % lknum; + j=0; + for (i=0; i<16; i++) + { + link = ls_slc[lsx16+i]; + if (mtp3ObjState.lk_configured[link] == PARA_CONFIGURED) + { + if (j == place) + { + sls_to_link[lsx16+sls] = link; + break; + } + else + j++; + } + } + } + } + else + { + for (sls=0; sls<16; sls++) + { + sls_to_link[lsx16+sls] = 0xFF; + } + } +} + +int update_ls_slc_table(int link) +{ + WORD ls; + int lsx16; + BYTE slc; + int temp; + int idiv4; + int idiv8; + + idiv4 = link/4; + idiv8 = link/8; + temp = 3<<((link%4)*2); + ls = mtp3_para->lk[link].e1_to_linkset; + if (ls < 128) + { + lsx16 = ls << 4; + slc = mtp3_para->lk[link].e1_to_slc; + if ( (slc < 16) && + (mtp3_para->lk[link].e1_lk_type & 1) &&//enabled + (mtp3ObjState.lk_configured[ls_slc[lsx16+slc]] != PARA_CONFIGURED)) + { + mtp3ObjState.lk_configured[link] = PARA_CONFIGURED; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + mtp3.ls[ls].linksNum_configured++; + ls_slc[lsx16+slc] = link; +// linknum_in_ls[ls]++; + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] & (~temp); + return 1; + } + else + { + mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] | temp; + } + } + else + mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] | temp; + + return 0; +} + +void update_influence_table(BYTE nw_no) +{ + nw_para *routine; + int lsno; + BYTE dst_num; + int i; + ls_info *ls; + BOOL added=0; + + routine = &mtp3_para->nw[nw_no]; + for ( i=0; i<256; i++ ) + { + if (routine->dpc[i] == 0) + continue; + lsno = routine->normal_ls[i]; + if ( (lsno < 128) && + ((mtp3_para->ls_pro[lsno] & 3) == nw_no) ) + { + added = 1; + Mtp3AddSortRec(nw_no,routine->dpc[i],i); + ls = &mtp3.ls[lsno]; + dst_num = ls->influ_dstnum_asNLS; + if ( dst_num < MAX_LS_DPC ) + { + ls->influ_dstplace_intable_asNLS[dst_num] = i; + ls->influ_dstnum_asNLS ++; + } + } + + lsno = routine->alternative_ls[i]; + if ( (lsno < 128) && + (routine->normal_ls[i] < 128) && + ((mtp3_para->ls_pro[lsno] & 3) == nw_no) ) + { + if (!added) + Mtp3AddSortRec(nw_no,routine->dpc[i],i); + ls = &mtp3.ls[lsno]; + dst_num = ls->influ_dstnum_asALS; + if ( dst_num < MAX_LS_DPC ) + { + ls->influ_dstplace_intable_asALS[dst_num] = i; + ls->influ_dstnum_asALS ++; + } + } + + added = 0; + } +} + +void update_ls_adjacent_sp_place(BYTE ls)/*linkset adjacent sp's place in sp table */ +{ + BYTE lsnw;/* network that linkset belong to */ + long pc; + int j; + + pc = mtp3_para->ls_op_pc[ls]; + if ( pc != 0) + { + for (j=0; j<256; j++) + { + lsnw = (mtp3_para->ls_pro[ls]) & 3; + if (mtp3_para->nw[lsnw].dpc[j] == pc) + { + mtp3.ls[ls].adjacent_sp_place = j; + return; + } + } + } +} + +void update_active_ls_num() +{ + int i; + + for (i=0; i<128; i++) + { + if (mtp3.ls[i].linksNum_configured > 0) +// if ( linknum_in_ls[i] > 0 ) + { + active_ls_num ++; + } + else + { + mtp3_heartbeat.linkset_state[i/4] = mtp3_heartbeat.linkset_state[i/4] | (3<<((i%4)*2)); + } + } +} + +void update_timer(int link) +{ + lk_timer *lt; + +// mtp3_para->lt[i].t1 = 5;/* 800ms */ +// mtp3_para->lt[i].t2 = 8;/* 1280ms */ +// mtp3_para->lt[i].t3 = 5;/* 800ms */ +// mtp3_para->lt[i].t4 = 5;/* 800ms */ +// mtp3_para->lt[i].t5 = 5;/* 800ms */ +// mtp3_para->lt[i].t7 = 10;/* 1600ms */ +// mtp3_para->lt[i].t8 = 6;/* 960ms */ +// mtp3_para->lt[i].t12 = 7;/* 1120ms */ +// mtp3_para->lt[i].t13 = 7;/* 1120ms */ +// mtp3_para->lt[i].t14 = 15;/* 2400ms */ + + + lt = &mtp3_para->lt[link]; + if ( (lt->t1 > 7) || (lt->t1 < 4) ) + lt->t1 = 5; + if ( (lt->t2 > 7) || (lt->t2 < 5) ) + lt->t2 = 6; + if ( (lt->t3 > 7) || (lt->t3 < 4) ) + lt->t3 = 5; + if ( (lt->t4 > 7) || (lt->t4 < 4) ) + lt->t4 = 5; + if ( (lt->t5 > 7) || (lt->t5 < 4) ) + lt->t5 = 5; + if ( (lt->t7 > 12) || (lt->t7 < 6) ) + lt->t7 = 10; + if ( (lt->t8 > 7) || (lt->t8 < 5) ) + lt->t8 = 6; + if ( (lt->t12 > 10) || (lt->t12 < 5) ) + lt->t12 = 7; + if ( (lt->t13 > 10) || (lt->t13 < 5) ) + lt->t13 = 7; + if ( (lt->t14 > 19) || (lt->t14 < 12) ) + lt->t14 = 15; +} + +void init_mtp3table() +{ + int i; + + for (i=0; i<256; i++) + { + if (update_ls_slc_table(i)); + MTP3_LinkIP_List(mtp3_para->lk[i].e1_to_mtp3,1);//addip + MTP3_LinkIP_List(mtp3_para->lk[i].e1_to_alterMTP3,1);//addip + } + for (i=0; i<128; i++) + { + update_sls_to_link_table(i); + } + for (i=0; i<4; i++) + { + update_influence_table(i); + } + for (i=0; i<128; i++) + { + update_ls_adjacent_sp_place(i); + } + update_active_ls_num(); + for (i=0; i<256; i++) + { + update_timer(i); + } + mtp3_para->mtp3_t10 = 63;/* 40 SECOND, unit=640ms,for dpc */ + mtp3_para->mtp3_t18 = 20; + mtp3_para->mtp3_t19 = 4; + mtp3_para->mtp3_t20 = 4; + mtp3_para->mtp3_t21 = 375;/* 30 SECOND,unit=80ms, for linkset */ + mtp3ObjInput.tprc_input = TPRC_SP_RESTART_INDICATION; + own_sp_restarting = 1; + tprc_mgmt_signalling_point_restart_indication(); + mtp3_get_time(); + mtp3_set_csta_p(); + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + get_routes_from_other_plat(); + mtp3_debug(MTP3DB_CMD,"MTP3 INIT COMPLETE(%08lx)",mtp3_localip); +} + +void reset_mtp3() +{ +// init_mtp3para(); + + mtp3lite_reset(); + i_sys(); + init_mtp3table(); + if(mtp3_alterip != 0)//take over altermtp3 + { + MTP3_activate(mtp3_alterip); + } +} + +void mtp3_reload_data() +{ + mtp3_readpara_from_disk(); +// recover_para(); + i_sys(); + init_mtp3table(); +} + +void mtp_shm_init(WORD moduleid_systemid) +{ + printf("mtp3 start init\n"); + mtp_lgetlocalip(); + sccp_shm_init(); + tup_shm_init(); + isup_shm_init(); + bicc_shm_init(); + iptransInit_mtp3(); + init_mtp3para(); + mtp_debug_set(); + mtp_snmp_init(); + mtp3_reload_data(); + mtp3lite_init(); + mtp3_init_dynamic_opc(); + mtp2_module = moduleid_systemid>>8; + mtp2_systemid = moduleid_systemid & 0xff; + printf("mtp3 complete init\n"); +} + +void mtp3_init_serial(char *Serial) +{ + mtp3_para->MTP3SerialNum = Str2Ull(Serial); +} + +int sccp_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = S_primitive->RSub; + if (RSub != S_primitive->WSub) + { + memcpy(ptr,&S_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + S_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int isup_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = I_primitive->RSub; + if (RSub != I_primitive->WSub) + { + memcpy(ptr,&I_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + I_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int bicc_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = B_primitive->RSub; + if (RSub != B_primitive->WSub) + { + memcpy(ptr,&B_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + B_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int tup_get_SPstate(mtp_primitive *ptr) +{ + BYTE RSub; + + RSub = I_primitive->RSub; + if (RSub != I_primitive->WSub) + { + memcpy(ptr,&I_primitive->primitive[RSub],sizeof (struct mtp_primitive)); + I_primitive->RSub = (RSub+1) & 0x0f; + return 1; + } + return 0; +} + +int tup_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = T_shm_ptr->MT_Buf.RSub; + if (RSub != T_shm_ptr->MT_Buf.WSub) + { + memcpy(msgptr,&T_shm_ptr->MT_Buf.msgNum[RSub],sizeof(up_message)); + + T_shm_ptr->MT_Buf.RSub++; + return 1; + } + return 0; +} + +int isup_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = I_shm_ptr->MI_Buf.RSub; + if (RSub != I_shm_ptr->MI_Buf.WSub) + { + memcpy(msgptr,&I_shm_ptr->MI_Buf.msgNum[RSub],sizeof(up_message)); + + I_shm_ptr->MI_Buf.RSub++; + return 1; + } + return 0; +} + +int bicc_GetMsg(up_message_2 *msgptr) +{ + BYTE RSub; + + RSub = B_shm_ptr->MI_Buf.RSub; + if (RSub != B_shm_ptr->MI_Buf.WSub) + { + memcpy(msgptr,&B_shm_ptr->MI_Buf.msgNum[RSub],sizeof(up_message_2)); + + B_shm_ptr->MI_Buf.RSub++; + return 1; + } + return 0; +} + +int sccp_GetMsg(up_message *msgptr) +{ + BYTE RSub; + + RSub = S_shm_ptr->MS_Buf.RSub; + if (RSub != S_shm_ptr->MS_Buf.WSub) + { + memcpy(msgptr,&S_shm_ptr->MS_Buf.msgNum[RSub],sizeof(up_message)); + S_shm_ptr->MS_Buf.RSub++; + return 1; + } + return 0; +} + +int mtp3_perform_routing(up_message *msgptr,BYTE WriteSub) +{ + BYTE sls; + int returnValue; + BYTE sio; + + sio = msgptr->sio; + if (msgptr->dest_ip != 0xffffffff) + return 256; + else + { + sls = msgptr->cic[0] & 0x0f; + returnValue = check_outbound_route((msgptr->sio>>6)&3,msgptr->dpc,sls); + if (returnValue >= 0) + { + switch (sio & 7) + { + case 3: + routingResult.sccpMsgOutLink[WriteSub] = returnValue; + break; + case 4: + routingResult.tupMsgOutLink[WriteSub] = returnValue; + break; + case 5: + routingResult.isupMsgOutLink[WriteSub] = returnValue; + break; + case 13: + routingResult.biccMsgOutLink[WriteSub] = returnValue; + break; + } + } + else + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,SIO=%x,DPC=%lx,len=%d",msgptr->sio,msgptr->dpc,msgptr->len); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + switch (returnValue) + { + case -1: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset unavailable"); + break; + case -2: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset not configured"); + break; + case -3: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:dpc(dpc->linkset) not configured"); + break; + default: + break; + } + } + return returnValue; + } +} + +int mtp3_perform_routing_2(up_message_2 *msgptr,BYTE WriteSub) +{ + BYTE sls; + int returnValue; + BYTE sio; + + sio = msgptr->sio; + if (msgptr->dest_ip != 0xffffffff) + return 256; + else + { + sls = msgptr->cic[0] & 0x0f; + returnValue = check_outbound_route((msgptr->sio>>6)&3,msgptr->dpc,sls); + if (returnValue >= 0) + { + switch (sio & 15) + { + case 3: + routingResult.sccpMsgOutLink[WriteSub] = returnValue; + break; + case 4: + routingResult.tupMsgOutLink[WriteSub] = returnValue; + break; + case 5: + routingResult.isupMsgOutLink[WriteSub] = returnValue; + break; + case 13: + routingResult.biccMsgOutLink[WriteSub] = returnValue; + break; + } + } + else + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,SIO=%x,DPC=%lx,len=%d",msgptr->sio,msgptr->dpc,msgptr->len); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + switch (returnValue) + { + case -1: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset unavailable"); + break; + case -2: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:linkset not configured"); + break; + case -3: + mtp3_debug(MTP3DB_ERROR,"Routing Failed,Reason:dpc(dpc->linkset) not configured"); + break; + default: + break; + } + } + return returnValue; + } +} + +int sccp_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+2]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+2]++;/* MSUs */ + + ReadSub = S_shm_ptr->SM_Buf.RSub; + WriteSub = S_shm_ptr->SM_Buf.WSub; + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from SCCP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&S_shm_ptr->SM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + S_shm_ptr->SM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[2]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+2]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+2]++;/* MSUs */ + } + return rtResult; +} + +int tup_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + ReadSub = T_shm_ptr->TM_Buf.RSub; + WriteSub = T_shm_ptr->TM_Buf.WSub; + +// current_measure->tf_measure1[0][wx5[nw]+3]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+3]++;/* MSUs */ + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from TUP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[3]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&T_shm_ptr->TM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + T_shm_ptr->TM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[3]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+3]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+3]++;/* MSUs */ + } + return rtResult; +} + +int isup_to_mtp3(up_message *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+4]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+4]++;/* MSUs */ + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from ISUP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + ReadSub = I_shm_ptr->IM_Buf.RSub; + WriteSub = I_shm_ptr->IM_Buf.WSub; + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[4]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&I_shm_ptr->IM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message)); + I_shm_ptr->IM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[4]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+4]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+4]++;/* MSUs */ + } + return rtResult; +} + +int bicc_to_mtp3(up_message_2 *msgptr) +{ + BYTE ReadSub; + BYTE WriteSub; + BYTE nw; + int rtResult; + + nw = ((msgptr->sio) >> 6) & 3; + +// current_measure->tf_measure1[0][wx5[nw]+4]+=msgptr->len;/* octets */ + current_measure->tf_measure2[0][wx5[nw]+4]++;/* MSUs */ + + ReadSub = B_shm_ptr->IM_Buf.RSub; + WriteSub = B_shm_ptr->IM_Buf.WSub; + if(msgptr->dest_ip == 0 && msgptr->dpc == 0) + { + mtp3_debug(MTP3DB_ERROR,"receive message from BICC,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:dst ip=0, dpc=0 "); + return -4; + } + if ( (WriteSub+1) == ReadSub)// buffer overflow + { + mtp3.nw[nw].flow.UtoM_throwed[4]++; + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",msgptr->sio,msgptr->dpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr->msgList,msgptr->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:buffer overflow"); + return -4; + } + rtResult = mtp3_perform_routing_2(msgptr,WriteSub); + if (rtResult >= 0) + { + memcpy(&B_shm_ptr->IM_Buf.msgNum[WriteSub],msgptr,sizeof(struct up_message_2)); + B_shm_ptr->IM_Buf.WSub++; + mtp3.nw[nw].flow.UtoM[4]++; + } + else + { +// current_measure->tf_measure1[5][wx5[nw]+4]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+4]++;/* MSUs */ + } + return rtResult; +} + +void scan_lk_state() +{ + static BYTE lk=0; + + if (mtp3ObjState.lk_configured[lk] != PARA_CONFIGURED) + { + lk = lk+1; + return; + } + if (mtp3ObjState.link_l3_state[lk] != AVAILABLE) + { + current_measure->lk_measure1[lk][3]++;//Duration of SL unavailability(for any reason + } + else if (mtp3ObjState.link_l3_state[lk] == UNAVAILABLE) + current_measure->lk_measure1[lk][6]++;//Duration of SL unavailability due to link fai + if (mtp3ObjState.link_l3_state[lk] == INHIBITED) + { + if (link_locally_inhibited[lk] == TRUE) + { + current_measure->lk_measure1[lk][4]++;//Duration of SL inhibition due to local management actions + } + else + current_measure->lk_measure1[lk][5]++;//Duration of SL inhibition due to remote management actions + } + + if (mtp3_para->lk[lk].e1_to_mtp3 == mtp3_localip) + {//this mtp3 is the normal mtp3 of this link + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15)//Alternative MTP3 available + { +// mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + //do nothing, waiting for alternative unavailable + } + else if (mtp3ObjState.lk_NMTP3_ok[lk] >> 4)//if Alternative MTP3 not avilable and normal mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change from backup to normal",lk); + mtp3ObjState.lk_NMTP3_ok[lk] &= 0x0f; + if (mtp3ObjState.lk_mtp3[lk] == mtp3_para->lk[lk].e1_to_alterMTP3) + { + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + if (mtp3ObjState.link_l3_state[lk] == AVAILABLE) + otherMTP3_managed_link_unavailable(lk); + } + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else//other case normal is always the host + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + else if (mtp3_para->lk[lk].e1_to_alterMTP3 == mtp3_localip) + {//this mtp3 is the alternative mtp3 of this link + if (mtp3ObjState.lk_mtp3[lk] == mtp3_localip)//it is the current host + { + if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==2)//only the deactivate command can make it abandon host + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change back to normal",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + +/* disable the link */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service (changing back to normal MTP3)",lk); + mtp3ObjInput.lsac_input_from_l2[lk] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjInput.sltc_input[lk] = SLTC_STOP; + sltc_proc(lk); + + /* send stop command to mtp2 */ + if (MTP3_LINK_TYPE(lk) == LKTYPE_SIGTRAN)//m2ua link + { + send_command_to_mtp2(lk,MTP2_DEACTIVE_LINK); + send_command_to_mtp2(lk,MTP3_M2UA_DISABLE); + } + else + send_command_to_mtp2(lk,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+lk,MTP3ALARM_LINK_CB_TO_NMTP3); + } + } + else + { + if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + {//normal ok + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + else if ((mtp3ObjState.lk_AMTP3_ok[lk]>>4)==1)//if normal MTP3 not avilable and alternative mtp3 is activated + { + mtp3_debug(MTP3DB_EVENT,"link %d host MTP3 change to alternative",lk); + mtp3ObjState.lk_AMTP3_ok[lk] &= 0x0f; + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + } + } + } + + else + { + if (mtp3ObjState.lk_AMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_alterMTP3; + + else if (mtp3ObjState.lk_NMTP3_ok[lk] & 15) + mtp3ObjState.lk_mtp3[lk] = mtp3_para->lk[lk].e1_to_mtp3; + } + + + if (mtp3ObjState.lk_mtp3[lk]==mtp3_localip) + { + mtp3_heartbeat.masterMTP3[lk/8] |= (1<<(lk&7)); + } + else + mtp3_heartbeat.masterMTP3[lk/8] &= (~(1<<(lk&7))); + + lk = lk+1; + + if (lk==255) + { + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + } +} + + +void scan_ls_state() +{ + BYTE nw; + WORD adsp_place; + static BYTE ls=0; + + adsp_place = mtp3.ls[ls].adjacent_sp_place; + if (adsp_place > 255) + { + ls = (ls + 1) & 0x7f; + return; + } + nw = ( mtp3_para->ls_pro[ls] ) & 3; + if (mtp3.ls[ls].adjacentsp_acessible != TRUE) + { + current_measure->ls_measure[ls][6]++;/* duration_of_adjacent_sp_inaccessible */; + } + if ( (mtp3.ls[ls].links_available == 0) && + (mtp3.ls[ls].linksNum_configured) ) +// (linknum_in_ls[ls] > 0) ) + { + current_measure->ls_measure[ls][0]++;/* duration_of_unavailability */ + } + ls = (ls + 1) & 0x7f; +} + +void scan_mtp2_activity()// check mtp2 exist or not +{ + int i,j; + int tmp; + int chl; + static BYTE mtp_t20s=0; + + mtp_t20s++; + if (mtp_t20s == 3) + { + mtp_t20s = 0; + for (i=0; i<32; i++) + { + if ( (mtp2_flag_old[i] != mtp2_flag_new[i]) && + (mtp2_flag_new[i] == IDLE) ) + { + tmp = i << 3; + for (j=0; j<8; j++) + { + chl = tmp+j; + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_IDLE; + nld_cause_lkd[chl] ++;/* internet cable disconnect cause lk disconnect */ + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + } + } + } + mtp2_flag_old[i] = mtp2_flag_new[i]; + mtp2_flag_new[i] = IDLE; + } + } +} + +int sys_mtp3_table(DWORD ip); +void scan_mtp3_activity()// check other mtp3 can use or not +{ + int chl; + static BYTE mtp3ip=0; +/* WORD lsno; + ls_info *ls=NULL;*/ + + mtp3ip=(mtp3ip+1) % 127; + + if (mtp3ip >= MAX_MTP3_NUM) + return; + + if ( (MTP3IPMng.mtp3_flag_old[mtp3ip] != MTP3IPMng.mtp3_flag_new[mtp3ip]) && + (MTP3IPMng.mtp3_flag_new[mtp3ip] == IDLE) && + (MTP3IPMng.mtp3_flag_ip[mtp3ip] != mtp3_localip) ) + { + for (chl=0; chl<256; chl++) + { + if ( (mtp3ObjState.lk_mtp3[chl] == MTP3IPMng.mtp3_flag_ip[mtp3ip]) && + (mtp3ObjState.link_l3_state[chl] == AVAILABLE) ) + { +/* lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + ls->links_available--;*/ + mtp3_debug(MTP3DB_EVENT,"link %d MTP3 %08lx timeout",chl,mtp3ObjState.lk_mtp3[chl]); + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + tsrc_proc(chl); + hmrt_tcoc_update_routing_tables(chl); + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + } + + if (mtp3_para->lk[chl].e1_to_mtp3 == MTP3IPMng.mtp3_flag_ip[mtp3ip]) + mtp3ObjState.lk_NMTP3_ok[chl] = 0; + else if (mtp3_para->lk[chl].e1_to_alterMTP3 == MTP3IPMng.mtp3_flag_ip[mtp3ip]) + mtp3ObjState.lk_AMTP3_ok[chl] = 0; + + } + } + MTP3IPMng.mtp3_flag_old[mtp3ip] = MTP3IPMng.mtp3_flag_new[mtp3ip]; + MTP3IPMng.mtp3_flag_new[mtp3ip] = IDLE; +} + +void mtp3_proc() +{ + up_message getmsg; + up_message_2 getmsg_2; + up_message *msgptr = (up_message*)&getmsg; + up_message_2 *msgptr_2 = (up_message_2*)&getmsg_2; + BYTE i; + BYTE temp; +// BYTE ib_b; +// unsigned short addr; + static BYTE sltc_loop=0; + static BYTE dst_loop=0; + static BYTE mtp_t1s=0; + static BYTE mtp_t10s=0; + static BYTE mtp_10ms_tick=0; + static BYTE mtp_100ms_tick=0; + +// addr = 0x378; +// ib_b = inb(addr); +// outb(ib_b | 2,addr); + + mtp3DebugFull = 0; + + for (i = 0; i<128; i++) + { + GetMtp2Msg(SS7_PORT);// get mtp2 message by port 4950 + GetMtp2Msg(M2UA_PORT);// get m2ua message + GetM3uaMsg(M2UA_PORT);// get m3ua message + get_isup(msgptr);// check isup buffer message + get_bicc(msgptr_2);// check bicc buffer message + get_tup(msgptr);// check tup buffer message + get_sccp(msgptr);// check sccp buffer message + } + + mtp3lite_timer(); + m3ua_timer(); +/* Q.704 state machine */ + for (i=0; i<16; i++) + { + temp = dst_loop + i; + if (MTP3_LINK_TYPE(temp) == LKTYPE_MTP3_LITE ||MTP3_LINK_TYPE(temp) == LKTYPE_M3UA) + continue; + lsac_proc(temp); + tlac_proc(temp); + tsrc_proc(temp); + tcoc_proc(temp); + tcbc_proc(temp); + rtpc_proc(srm_nw,temp); + rtac_proc(srm_nw,temp); + rsrt_proc(srm_nw,temp); + mtp3Timer_proc(temp); + taprc_proc(temp); + } + dst_loop = dst_loop + 16; + if (dst_loop == 0) + srm_nw = (srm_nw + 1) & 3; + if (MTP3_LINK_TYPE(sltc_loop) != LKTYPE_MTP3_LITE && MTP3_LINK_TYPE(sltc_loop) != LKTYPE_M3UA) + sltc_proc(sltc_loop); + sltc_loop++; +/* Q.704 state machine */ + + for (i=0;i<4;i++) + { + scan_conf_right_or_not(i); + } + + switch (mtp_10ms_tick)/* every 160ms loop one times */ + { + case 0:/* 10ms */ + break; + case 1:/* 20ms */ + break; + case 2:/* 30ms */ + scan_lk_state(); + break; + case 3:/* 40ms */ + break; + case 4:/* 50ms */ + break; + case 5:/* 60ms */ + break; + case 6:/* 70ms */ + scan_lk_state(); + break; + case 7:/* 80ms */ + scan_ls_state(); + break; + case 8:/* 90ms */ + break; + case 9:/* 100ms */ + mtp_m_rt(); + break; + case 10:/* 110ms */ + scan_lk_state(); + break; + case 11:/* 120ms */ + break; + case 12:/* 130ms */ + break; + case 13:/* 140ms */ + scan_mtp3_activity(); + break; + case 14:/* 150ms */ + scan_lk_state(); + break; + case 15:/* 160ms */ + scan_ls_state(); + break; + default: + break; + } + mtp_10ms_tick = ((mtp_10ms_tick+1) & 15); + + if (mtp_100ms_tick == 9) + { + mtp_100ms_tick = 0; + mtp_t1s++; + if (mtp_t1s == 10)/* 1 second */ + { + mtp_t1s = 0; + tprc_proc(); + mtp_t10s++; + send_ip_to_mtp2(); + send_ip_to_mtp2(); + if (mtp_t10s == 10)/* 10 second */ + { + mtp3_heartbeat.state = 1; + set_status(MTP3_COMPONENT_ID,MTP3_HB_LEN,(BYTE*)&mtp3_heartbeat.version); + mtp3_get_time();// get current time + mtp3_set_csta_p();// set csta portion + scan_mtp2_activity(); + mtp_t10s = 0; + + if (mtp3lite_listen_fd <= 0) + mtp3lite_InitServerSocket(); + } + } + } + mtp_100ms_tick ++; + +// outb(ib_b & 0xfd,addr); +} + +//These functions is added by Roy Jiang for supporting SCCP dual server redirect +int sccp_redirect(up_message *msgptr) +{ +// BYTE len; + WORD len;//long message + BYTE sio; + long route_mark;/* dpc opc sls */ + BYTE sls; + long dpc; + long opc; + BYTE pclen; + int outlink=0; + long dest_ip; + BYTE *pContent; + BYTE nw; + + assert (msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio & 0xcf; + dpc = msgptr->dpc; + opc = msgptr->opc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + dest_ip = msgptr->dest_ip; + outlink = msgptr->link; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + len = msgptr->len; + if (pclen == MTP3_24BIT_PC) + { + mtp3_iprt.io_msg.msgLength = len + 10 + 1; + pContent[0] = outlink; + pContent[1] = (len+8)>>8; + pContent[2] = (len+8)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&opc,3); + memcpy(&pContent[10],&msgptr->cic[0],1); + memcpy(&pContent[11],&msgptr->msgList,len); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(opc << 14)+dpc; + pContent[0] = outlink; + pContent[1] = (len+5)>>8; + pContent[2] = (len+5)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->msgList,len); + } + len = (pContent[1]<<8) +pContent[2]; + if (len < 5 || len >272) + { + mtp3ObjState.MTP3WatchDog[10]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&pContent[0],len + 3); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[2]++; + + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} + +int isup_redirect(up_message *msgptr) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE nw; + DWORD dest_ip; +// BYTE rSub; + BYTE *pContent; + + assert (msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio & 0xcf; + dpc = msgptr->dpc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + outlink = msgptr->link; + dest_ip = msgptr->dest_ip; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + pContent[0] = outlink; + pContent[1] = (len + 10)>>8; + pContent[2] = (len + 10)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&msgptr->opc,3);//keep the UP filled opc + pContent[10] = msgptr->cic[0] & 0x0f; + memcpy(&pContent[11],&msgptr->cic[0],2); + memcpy(&pContent[13],&msgptr->msgList,len); + MTP3_send_isup_count(nw,pContent[13]); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(msgptr->opc << 14)+dpc;//keep the UP filled opc + pContent[0] = outlink; + pContent[1] = (len+7)>>8; + pContent[2] = (len+7)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->cic,2); + memcpy(&pContent[10],&msgptr->msgList,len); + MTP3_send_isup_count(nw,pContent[10]); + } + + len = (pContent[1]<<8) + pContent[2]; + if (len < 5 || len > 272) + { + mtp3ObjState.MTP3WatchDog[14]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&pContent[0],len + 3); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[4]++; + + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} + +int bicc_redirect(up_message_2 *msgptr) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *pContent; + BYTE nw; + DWORD dest_ip; +// BYTE rSub; + + assert(msgptr->dest_ip != 0xffffffff); + sio = msgptr->sio; + dpc = msgptr->dpc; + sls = msgptr->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = msgptr->len; + dest_ip = msgptr->dest_ip; + outlink = msgptr->link; + + pContent = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + pContent[0] = outlink; + pContent[1] = (len + 12)>>8; + pContent[2] = (len + 12)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&dpc,3); + memcpy(&pContent[7],&msgptr->opc,3);//keep the UP filled opc + pContent[10] = msgptr->cic[0] & 0x0f; + memcpy(&pContent[11],&msgptr->cic[0],4); + memcpy(&pContent[15],&msgptr->msgList,len); + } + else + { + route_mark = (msgptr->cic[0] << 28)+(msgptr->opc << 14)+dpc;//keep the UP filled opc + pContent[0] = outlink; + pContent[1] = (len+9)>>8; + pContent[2] = (len+9)&0xff; + pContent[3] = sio; + memcpy(&pContent[4],&route_mark,4); + memcpy(&pContent[8],&msgptr->cic,4); + memcpy(&pContent[12],&msgptr->msgList,len); + } + mtp3.nw[nw].flow.MtoI[4]++; + mtp3_iprt.io_msg.msgLength = pContent[2]+2+1; + iptrans_msg_flow(pContent,pclen,MTP_MSG_OTHER_SERVER,dest_ip); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + return 1; +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpm.c b/omc/plat/mtp3_old/src/mtpm.c new file mode 100644 index 0000000..b666240 --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpm.c @@ -0,0 +1,2483 @@ +#include "../../debug/src/include/debug.h" +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +extern void mtp3_debug(int n,const char *fmt,...); +/*@ignore@*/ +int mtp3_send_netcap=0; + +void reset_mtp3(); +long atol(const char *nptr); +int gettimeofday(struct timeval *tv,struct timezone *tz); +struct tm *localtime(const time_t *timep); +void mtp3_list_link(BYTE i); + +static char ascii[16] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39, + 0x41,0x42,0x43,0x44,0x45,0x46}; +extern BOOL mtp3DebugFull; + +BYTE disp_flag; +BYTE disp_page[16]; + +/* by simon at 23/9/27 */ +extern BYTE * disp_ptr; +extern BYTE disp_length; + +static DWORD debug_mask=0; +void mtp3_show_routine_status(BYTE nw); +void mtp3_show_routine_status_sorted(BYTE nw); +void mtp3_list_log_status(); +void mtp3_reload_data(); +int mtp3_write_parameter(); + +static BYTE title1_p[] = +{ + " PAGE01 MTP3 Measure-TRAFFIC sub-page0:flow, sub-page1:throwed \n\r\ + [---SNM---] [---T+M---] [--SCCP---] [---TUP---] [--ISUP---]\n\r\ +--Page--\n\r\ + U (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + M (nw3)\n\r\ + M (nw0)\n\r\ + t (nw1) E\n\r\ + o (nw2) 1\n\r\ + I (nw3)\n\r\ + I (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + M (nw3)\n\r\ + M (nw0)\n\r\ + t (nw1)\n\r\ + o (nw2)\n\r\ + U (nw3)\n\r\ + M (nw0)\n\r\ + S (nw1)\n\r\ + T (nw2)\n\r\ + P (nw3)\n\r\ +" +}; + +static BYTE title2_p[] = +{ + " PAGE02 link mark \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--Page--\n\r\ +link_available\n\r\ +link_unavailable\n\r\ +failed\n\r\ +CB_in_progress\n\r\ +CO_in_progress\n\r\ +link_inhibited\n\r\ +locally_inhibited\n\r\ +remotely_inhibited\n\r\ +localInhibit_inPro\n\r\ +uninhibit_in_pro\n\r\ +local_blocked\n\r\ +remote_blocked\n\r\ +local_change_over\n\r\ +" +}; + +static BYTE title3_p[] = +{ + " PAGE03 MTP2 MTP3 flag \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ + Page\n\r\ + mtp2 flag(old)\n\r\ + \n\r\ + mtp2 flag(new)\n\r\ + \n\r\ + \n\r\ + page\n\r\ + 0:mtp3 ip\n\r\ + 1:mtp3 flag old\n\r\ + 2:mtp3 flag new\n\r\ + 3:lk_configured\n\r\ +" +}; + +static BYTE title4_p[] = +{ + " PAGE09 MTP3 STATE MACHINE'S INPUT \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--Page--\n\r\ +LSAC L2\n\r\ +LSAC SLTC\n\r\ +LSAC SLM\n\r\ +LSAC STM\n\r\ +LSAC TCOC\n\r\ +LSAC MGMT\n\r\ +TLAC SLM\n\r\ +TLAC STM\n\r\ +TLAC HMDT\n\r\ +TSRC STM\n\r\ +TSRC TLAC\n\r\ +TSRC TCOC\n\r\ +TSRC TCBC\n\r\ +TSRC SRM\n\r\ +TCOC L2\n\r\ +TCOC STM\n\r\ +TCOC TSRC\n\r\ +TCOC HMDT\n\r\ +TCBC\n\r\ +TCBC_TSRC\n\r\ +T(A)PRC\n\r\ +" +}; + +static BYTE title5_p[] = +{ + " PAGE05 MTP3 Port state(16 port per sub page)\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +subPage\r\n\ +L1\r\n\ +L2\r\n\ +L3\r\n\ +lsac\r\n\ +sltc\r\n\ +tlac\r\n\ +tsrc\r\n\ +tcoc\r\n\ +tcbc\r\n\ +rtpc[nw0]\r\n\ +rtpc[nw1]\r\n\ +rtpc[nw2]\r\n\ +rtpc[nw3]\r\n\ +rtac[nw0]\r\n\ +rtac[nw1]\r\n\ +rtac[nw2]\r\n\ +rtac[nw3]\r\n\ +tprc" +}; + +static BYTE title6_p[] = +{ + " PAGE06 MTP3 ROUTINE TABLE(4) \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--PAGE--\n\r\ +0 INTERNATIONAL\n\r\ +1 INTERNATIONAL(S)\n\r\ +2 NATIONAL\n\r\ +3 NATIONAL(S)\n\r\ +\n\r\ +\n\r\ +value=\n\r\ +18:route:normal ls\n\r\ + nls:available\n\r\ + als:unavailable\n\r\ +10:route:normal ls\n\r\ + nls:available\n\r\ + als:available\n\r\ +52:route=alter ls\n\r\ + nls:unavailable\n\r\ + als:available\n\r\ +8A:no route\n\r\ +other:problem bug\n\r\ +" +}; + +static BYTE title7_p[] = +{ + " PAGE07 MTP3 LINKSET SLS TABLE \n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--PAGE--\n\r\ +(16*page+00)ls\n\r\ +(16*page+01)ls\n\r\ +(16*page+02)ls\n\r\ +(16*page+03)ls\n\r\ +(16*page+04)ls\n\r\ +(16*page+05)ls\n\r\ +(16*page+06)ls\n\r\ +(16*page+07)ls\n\r\ +(16*page+08)ls\n\r\ +(16*page+09)ls\n\r\ +(16*page+10)ls\n\r\ +(16*page+11)ls\n\r\ +(16*page+12)ls\n\r\ +(16*page+13)ls\n\r\ +(16*page+14)ls\n\r\ +(16*page+15)ls\n\r\ +" +}; + +static BYTE title8_p[] = +{ + " PAGE08 MTP3 Version 1.0 linkset State \n\r\ + avail mark place cf influence dst number\n\r\ +--Page--\n\r\ +(16*page+00)ls\n\r\ +(16*page+01)ls\n\r\ +(16*page+02)ls\n\r\ +(16*page+03)ls\n\r\ +(16*page+04)ls\n\r\ +(16*page+05)ls\n\r\ +(16*page+06)ls\n\r\ +(16*page+07)ls\n\r\ +(16*page+08)ls\n\r\ +(16*page+09)ls\n\r\ +(16*page+10)ls\n\r\ +(16*page+11)ls\n\r\ +(16*page+12)ls\n\r\ +(16*page+13)ls\n\r\ +(16*page+14)ls\n\r\ +(16*page+15)ls\n\r\ +" +}; + +static BYTE title9_p[] = +{ + " PAGE9 MTP3 ls influence dst\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--page--\n\r\ +page0-page127\n\r\ +ls0 -ls127\n\r\ +[NLS]\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +[ALS]\n\r\ +" +}; + +static BYTE title10_p[] = +{ + " PAGE10 MTP3 isup sd/rv count\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +--page--\n\r\ +RvISUP\n\r\ +\n\r\ +\n\r\ +\n\r\ +SdISUP\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +" +}; + +static BYTE title11_p[] = +{ + " PAGE11 MTP3 watch dog\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Dog\n\r\ +" +}; + +void mtpi_m() +{ + memset(disp_page,0,16); +} + +BYTE mtp_disp_line(BYTE page, BYTE line)//return display length,disp data ptr per line +{ + BYTE disp_length; + BYTE subpage; + + disp_length = 16; + + page = page & 15; + disp_page[page] = disp_page[page] & 31; + subpage = disp_page[page]; + + switch(page) + { + case 1: + if (subpage == 0) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.UtoM; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.UtoM; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.UtoM; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.UtoM; + break; + case 5: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoI; + break; + case 6: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoI; + break; + case 7: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoI; + break; + case 8: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoI; + break; + case 9: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.ItoM; + break; + case 10: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.ItoM; + break; + case 11: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.ItoM; + break; + case 12: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.ItoM; + break; + case 13: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoU; + break; + case 14: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoU; + break; + case 15: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoU; + break; + case 16: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoU; + break; + case 17: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp; + break; + case 18: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp; + break; + case 19: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp; + break; + case 20: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp; + break; + default: + disp_length = 0; + break; + } + } + else if (subpage == 1) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.UtoM_throwed; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.UtoM_throwed; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.UtoM_throwed; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.UtoM_throwed; + break; + case 5: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoI_throwed; + break; + case 6: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoI_throwed; + break; + case 7: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoI_throwed; + break; + case 8: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoI_throwed; + break; + case 9: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.ItoM_throwed; + break; + case 10: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.ItoM_throwed; + break; + case 11: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.ItoM_throwed; + break; + case 12: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.ItoM_throwed; + break; + case 13: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.MtoU_throwed; + break; + case 14: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.MtoU_throwed; + break; + case 15: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.MtoU_throwed; + break; + case 16: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.MtoU_throwed; + break; + case 17: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp_throwed; + break; + case 18: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp_throwed; + break; + case 19: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp_throwed; + break; + case 20: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp_throwed; + break; + default: + disp_length = 0; + break; + } + } + else if (subpage == 2) + { + disp_length = 20; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = (BYTE*)&mtp3.nw[0].flow.stp_loop; + break; + case 2: + disp_ptr = (BYTE*)&mtp3.nw[1].flow.stp_loop; + break; + case 3: + disp_ptr = (BYTE*)&mtp3.nw[2].flow.stp_loop; + break; + case 4: + disp_ptr = (BYTE*)&mtp3.nw[3].flow.stp_loop; + break; + default: + disp_length = 0; + break; + } + } + else + disp_length = 0; + break; + case 2: + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = link_available + subpage*16; + break; + case 2: +/* disp_ptr = link_unavailable + subpage*16;*/ + break; + case 3: + disp_ptr = failed + subpage*16; + break; + case 4:/* l3 */ + disp_ptr = changeback_in_progress + subpage*16; + break; + case 5:/* l2 */ + disp_ptr = changeover_in_progress + subpage*16; + break; + case 6: + disp_ptr = link_inhibited + subpage*16; + break; + case 7: + disp_ptr = link_locally_inhibited + subpage*16; + break; + case 8: + disp_ptr = link_remotely_inhibited + subpage*16; + break; + case 9: + disp_ptr = local_inhibit_in_progress + subpage*16; + break; + case 10: + disp_ptr = uninhibit_in_progress + subpage*16; + break; + case 11: + disp_ptr = local_blocked + subpage*16; + break; + case 12: + disp_ptr = remote_blocked + subpage*16; + break; + case 13: + disp_ptr = local_change_over + subpage*16; + break; + default: + disp_length = 0; + + } + break; + case 3: + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 3) + { + disp_ptr = mtp2_flag_old+(line-1)*16; + } + else if (line < 5) + { + disp_ptr = mtp2_flag_new+(line-3)*16; + } + else if (line==5) + { + disp_ptr = &MTP3IPMng.LinkIPNum; + disp_length = 1; + } + else if (line < 24) + { + if (subpage == 0) + disp_ptr = (BYTE*)MTP3IPMng.mtp3_flag_ip+(line-6)*16; + else if (subpage == 1) + disp_ptr = MTP3IPMng.mtp3_flag_old+(line-6)*16; + else if (subpage == 2) + disp_ptr = MTP3IPMng.mtp3_flag_new+(line-6)*16; + else if (subpage == 3) + disp_ptr = mtp3ObjState.lk_configured+(line-6)*16; + else if (subpage == 4) + disp_ptr = mtp3ObjState.lk_NMTP3_ok+(line-6)*16; + else if (subpage == 5) + disp_ptr = mtp3ObjState.lk_AMTP3_ok+(line-6)*16; + else if (subpage == 6) + disp_ptr = (BYTE*)MTP3IPMng.LinkIP+(line-6)*16; + } + else + disp_length = 0; + break; + case 4:/* input of state machine */ + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1:/* l3 */ + disp_ptr = mtp3ObjInput.lsac_input_from_l2 + subpage*16; + break; + case 2:/* l2 */ + disp_ptr = mtp3ObjInput.lsac_input_from_sltc + subpage*16; + break; + case 3:/* l1 */ + disp_length = 0; + break; + case 4: + disp_ptr = mtp3ObjInput.lsac_input_from_stm + subpage*16; + break; + case 5: + disp_ptr = mtp3ObjInput.lsac_input_from_tcoc + subpage*16; + break; + case 6: + disp_ptr = mtp3ObjInput.lsac_input_from_mgmt + subpage*16; + break; + case 7: + disp_ptr = mtp3ObjInput.tlac_input_from_slm + subpage*16; + break; + case 8: + disp_ptr = mtp3ObjInput.tlac_input_from_stm + subpage*16; + break; + case 9: + disp_ptr = mtp3ObjInput.tlac_input_from_hmdt + subpage*16; + break; + case 10: + disp_ptr = mtp3ObjInput.tsrc_input_from_stm + subpage*16; + break; + case 11: + disp_ptr = mtp3ObjInput.tsrc_input_from_tlac + subpage*16; + break; + case 12: + disp_ptr = mtp3ObjInput.tsrc_input_from_tcoc + subpage*16; + break; + case 13: + disp_ptr = mtp3ObjInput.tsrc_input_from_tcbc + subpage*16; + break; + case 14: + disp_length = 0; + break; + case 15: + disp_length = 0; + break; + case 16: + disp_ptr = mtp3ObjInput.tcoc_input_from_stm + subpage*16; + break; + case 17: + disp_ptr = mtp3ObjInput.tcoc_input_from_tsrc + subpage*16; + break; + case 18: + disp_ptr = mtp3ObjInput.tcoc_input_from_hmdt + subpage*16; + break; + case 19: + disp_ptr = mtp3ObjInput.tcbc_input + subpage*16; + break; + case 20: + disp_ptr = mtp3ObjInput.tcbc_input_from_tsrc + subpage*16; + break; +/* case 21: + disp_ptr = mtp3ObjInput.sltc_input + subpage*16; + break;*/ + case 21: + disp_ptr = mtp3ObjInput.taprc_input + subpage*16; + break; + case 22: + disp_ptr = &mtp3ObjInput.tprc_input; + disp_length = 1; + break; + default: + disp_length = 0; + break; + + } + break; + case 5: /* state machine */ + if (subpage > 15) + return 0; + switch (line) + { + case 0: + disp_ptr = &disp_page[page]; + disp_length = 1; + break; + case 1: + disp_ptr = mtp3ObjState.link_l1_state+subpage*16; + break; + case 2: + disp_ptr = mtp3ObjState.link_l2_state+subpage*16; + break; + case 3: + disp_ptr = mtp3ObjState.link_l3_state+subpage*16; + break; + case 4: + disp_ptr = mtp3ObjState.lsac_state+subpage*16; + break; + case 5: + disp_ptr = mtp3ObjState.sltc_state+subpage*16; + break; + case 6: + disp_ptr = mtp3ObjState.tlac_state+subpage*16; + break; + case 7: + disp_ptr = mtp3ObjState.tsrc_state+subpage*16; + break; + case 8: + disp_ptr = mtp3ObjState.tcoc_state+subpage*16; + break; + case 9: + disp_ptr = mtp3ObjState.tcbc_state+subpage*16; + break; + case 10: + disp_ptr = mtp3.nw[0].rtpc_state+subpage*16; + break; + case 11: + disp_ptr = mtp3.nw[1].rtpc_state+subpage*16; + break; + case 12: + disp_ptr = mtp3.nw[2].rtpc_state+subpage*16; + break; + case 13: + disp_ptr = mtp3.nw[3].rtpc_state+subpage*16; + break; + case 14: + disp_ptr = mtp3.nw[0].rtac_state+subpage*16; + break; + case 15: + disp_ptr = mtp3.nw[1].rtac_state+subpage*16; + break; + case 16: + disp_ptr = mtp3.nw[2].rtac_state+subpage*16; + break; + case 17: + disp_ptr = mtp3.nw[3].rtac_state+subpage*16; + break; + case 18: + disp_ptr = &mtp3ObjState.tprc_state; + disp_length = 1; + break; + default: + disp_length = 0; + break; + } + + break; + case 6:/* routine */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if ( line <17 ) + { + if (subpage < 4) + { + disp_ptr = mtp3.nw[subpage].routine+(line-1)*16; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + + case 7:/* ls sls & ls slc table */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if ( line <17 ) + { + if (subpage < 8) + { + disp_ptr = ls_sls + (line-1)*16 + subpage*256; + } + else if (subpage < 16) + { + disp_ptr = ls_slc + (line-1)*16 + (subpage-8)*256; + } + else if (subpage < 24) + { + disp_ptr = sls_to_link + (line-1)*16 + (subpage-16)*256; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + + case 8:/* E1 STATE */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 17) + { + if (subpage < 8) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage*16+line-1]; + disp_length = 9; + } + else + disp_length = 0; + } + else + disp_length = 0; + break; + case 9:/* ls influence dstination table */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 18) + { + if (subpage < 128) + { + if (line < 9) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage].influ_dstplace_intable_asNLS[(line-1)*16]; + disp_length = 16; + } + else if (line == 9) + { + disp_length = 0; + } + else + { + disp_ptr = (BYTE*)&mtp3.ls[subpage].influ_dstplace_intable_asALS[(line-10)*16]; + disp_length = 16; + } + } + else + disp_length = 0; + } + else if (line == 18) + disp_length = 0; + else if (line == 19) + { + disp_ptr = (BYTE*)&mtp3.ls[subpage]; + disp_length = 9; + } + else + disp_length = 0; + break; + + case 10:/* isup watch dog */ + if (line == 0) + { + disp_ptr = &disp_page[page]; + disp_length = 1; + } + else if (line < 9) + { + disp_ptr = (BYTE*)&mtp3.nw[page].flow.isup_detail[(line-1)*16]; + disp_length = 16; + } + else + disp_length = 0; + break; + case 11:/* watch dog */ + if (line < 16) + { + disp_ptr = (BYTE*)&mtp3ObjState.MTP3WatchDog[line*16]; + disp_length = 16; + } + else + disp_length = 0; + break; + default: + disp_length = 0; + break; + } + return disp_length; +} + +void mtp_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + DWORD object_id[20];//for test + +/* object_id head */ + object_id[0] = 1; + object_id[1] = 3; + object_id[2] = 6; + object_id[3] = 1; + object_id[4] = 4; + object_id[5] = 1; + object_id[6] = 1373; + object_id[7] = 1; + object_id[8] = 1; + object_id[9] = 2; +/* object_id head */ + + object_id[10] = 3; + object_id[11] = 1; + + object_id[12] = 2; + object_id[13] = MTP3_DEBUG_ID + 2; + object_id[14] = 5 + page;//page + //object_id[3] = 2;//line + object_id[16] = 0;//instance + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = mtp_disp_line(page,disp_line); + object_id[15] = disp_line + 2;//line +// debug_set_response(17,object_id,&disp_length,10); + object_id[16] = 2;//data pointer + debug_set_response(17,object_id,disp_ptr,disp_length); + } +} + +int mtp_debug_set() +{ + BYTE page; + BYTE data[10]; + BYTE *ptr; + DWORD object_id[20];//for test + BYTE mtp3_ver[20] = MTP3_VERSION; + + sprintf(mtp3_ver,"R%dV%d_%03d",mtp3_ver[0],mtp3_ver[1],mtp3_ver[2]); + + mtpi_m(); + + ptr = data; + +/* object_id head */ + object_id[0] = 1; + object_id[1] = 3; + object_id[2] = 6; + object_id[3] = 1; + object_id[4] = 4; + object_id[5] = 1; + object_id[6] = 1373; + object_id[7] = 1; + object_id[8] = 1; + object_id[9] = 2; +/* object_id head */ + object_id[10] = 3; + object_id[11] = 1; + + object_id[12] = 2; + object_id[13] = MTP3_DEBUG_ID+2; + object_id[14] = 1; + object_id[15] = 0;//instance + + data[0] = 1;//active this module + + debug_set_response(16,object_id,data,1); + object_id[14] = 2; + debug_set_response(15,object_id,mtp3_ver,strlen(mtp3_ver));//module name + object_id[14] = 3; + debug_set_response(15,object_id,mtp_asciin_buf,80);//ascii in buf + object_id[14] = 4; + debug_set_response(15,object_id,mtp_asciout_buf,4096);//ascii out buf + + + object_id[15] = 1;//TITLE +// object_id[16] = 2;//instance + for (page = 1; page < 16; page ++) + { + switch (page) + { + case 1: + ptr = title1_p;/*measure*/ + break; + case 2: + ptr = title2_p; + break; + case 3: + ptr = title3_p;/* MIB1 */ + break; + case 4: + ptr = title4_p;/* MIB2 */ + break; + case 5://page 1 + ptr = title5_p; + break; + case 6: + ptr = title6_p; + break; + case 7: + ptr = title7_p; + break; + case 8: + ptr = title8_p; + break; + case 9: + ptr = title9_p; + break; + case 10: + ptr = title10_p; + break; + case 11: + ptr = title11_p; + break; + default: + continue; + } + object_id[14] = 5 + page; + debug_set_response(17,object_id,ptr,strlen(ptr)); + mtp_disp_page(page); + } + + return 1; +} + +int mtp_send_ascout(BYTE *out_str) +{ +#ifdef _WXC_TEST + if( strlen(out_str) < MTP_MAX_ASCIIOUT_LEN ) + printf("[MTP3]\n%s" ,out_str ); +#else + int out_len; + + out_len = strlen(out_str); + + if (out_len + strlen(mtp_asciout_buf) > MTP_MAX_ASCIIOUT_LEN - 2) + { + mtp3DebugFull = 1; + return 0; +// strcpy(mtp_asciout_buf,out_str); + } + else + strcat(mtp_asciout_buf,out_str); +#endif + return 1; +} + +void mtp3_type_command(BYTE *ascin_ptr,BYTE option) +{ + BYTE info_str[80]; + BYTE *tmp_ptr; + int link; + unsigned long one=1; + BYTE inputValue; + int lsx16; + int i; + + if (strstr(ascin_ptr,"link all") != NULL) + { + if (option == 0)/* off */ + { + debug_mask=debug_mask & (~(one< 0) + { + page = mtp_asciin_buf[0]; + if (( page < 11) && (page > 1)) + { + disp_page[page-1] = atoi(ascin_ptr); + mtp_disp_page(page-1); + } + if (strcmp(ascin_ptr,"C") == 0) + { + memset(&mtp3.nw[0].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[1].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[2].flow,0,sizeof(struct mtp3_flow)); + memset(&mtp3.nw[3].flow,0,sizeof(struct mtp3_flow)); + memset(mtp3ObjState.MTP3WatchDog,0,256); + } + else if (strstr(ascin_ptr,"list") != NULL) + { + if (strncmp(ascin_ptr,"list par.opc",12) == 0) + { + mtp3_show_parameter(0,0); + } + else if (strncmp(ascin_ptr,"list par.link",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(1,input); + } + else if (strncmp(ascin_ptr,"list par.ls",11) == 0) + { + input = atol(&ascin_ptr[11]); + mtp3_show_parameter(2,input); + } + else if (strncmp(ascin_ptr,"list par.ints",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(4,input); + } + else if (strncmp(ascin_ptr,"list par.int",12) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(3,input); + } + else if (strncmp(ascin_ptr,"list par.nats",13) == 0) + { + input = atol(&ascin_ptr[13]); + mtp3_show_parameter(6,input); + } + else if (strncmp(ascin_ptr,"list par.nat",12) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(5,input); + } + else if (strncmp(ascin_ptr,"list par.sg",11) == 0) + { + input = atol(&ascin_ptr[12]); + mtp3_show_parameter(7,input); + } + else if (strncmp(ascin_ptr,"list route.",11) == 0) + { + input = atol(&ascin_ptr[11]); + mtp3_show_routine_status(input); + } + else if (strncmp(ascin_ptr,"list rt.",8) == 0) + { + input = atol(&ascin_ptr[8]); + mtp3_show_routine_status_sorted(input); + } + else if (strstr(ascin_ptr,"list log status") != NULL) + { + mtp3_list_log_status(); + } + if (strncmp(ascin_ptr,"list link.",10) == 0) + { + input = atol(&ascin_ptr[10]); + mtp3_list_link(input); + } + } + else if (strstr(ascin_ptr,"log all") != NULL) + { + debug_mask = debug_mask | 0xfffffaff;//not concern mtp3 hb & primitive +// debug_mask = 0xffffffff; + memset(debug_link,MTP3_MSGLOG_ON,256); + mtp_send_ascout("all logs on\n\r"); + } + else if( strstr(ascin_ptr, "net cap start") !=NULL ) + { + mtp3_send_netcap = 1; + mtp_send_ascout("mtp3 send netcap start"); + } + else if( strstr(ascin_ptr, "net cap stop") !=NULL ) + { + mtp3_send_netcap = 0; + mtp_send_ascout("mtp3 send netcap end"); + } + else if (strstr(ascin_ptr,"log none") != NULL) + { + debug_mask = 0; + memset(debug_link,MTP3_MSGLOG_OFF,256); + mtp_send_ascout("all logs off\n\r"); + } + else if ((tmp_ptr=strstr(ascin_ptr,"log"))!=NULL) + { + if (strstr(ascin_ptr,"on") != NULL) + mtp3_type_command(tmp_ptr,1); + else if (strstr(ascin_ptr,"off") != NULL) + mtp3_type_command(tmp_ptr,0); + else + mtp_send_ascout("command error\n\r"); + } + + else if (strcmp(ascin_ptr,"current portion")==0) + { + sprintf(info_str,"current portion is %ld\n\r",mtp3_csta_p); + mtp_send_ascout(info_str); + } + + else if (strcmp(ascin_ptr,"restart")==0) + { + sprintf(info_str,"mtp3 restarting...\n\r"); + mtp_send_ascout(info_str); + reset_mtp3(); + } + + else if (strcmp(ascin_ptr,"reload parameters")==0) + { + sprintf(info_str,"reloading mtp3 parameters...\n\r"); + mtp_send_ascout(info_str); + mtp3_reload_data(); + } + + else if (strcmp(ascin_ptr,"save parameters")==0) + { + sprintf(info_str,"saving mtp3 parameters...\n\r"); + mtp_send_ascout(info_str); + mtp3_write_parameter(); + } + + else if ( (strstr(ascin_ptr,"HELP") != NULL) | + (strstr(ascin_ptr,"help") != NULL) ) + { + mtp3_help_page(); + } + else if (strstr(ascin_ptr,"Activate") != NULL) + { + MTP3_activate(mtp3_localip);//deactivate alternative mtp3 + } + else if (strstr(ascin_ptr,"Deactivate") != NULL) + { + MTP3_deactivate(mtp3_localip);//deactivate alternative mtp3 + } + + strcpy(mtp_asciin_buf,"\0"); + } +} + +int mtp_hex_to_ascii(BYTE *from_hex,WORD from_len, BYTE *to_asc) +{ + int i,j; + + if(from_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"mtp_hex_to_ascii, length longer than 300, len=%d!", from_len); + from_len = 300; + } + 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] = 0x20; + j++; + } + to_asc[j] = '\0'; + return 1; +} + +void mtp3_showbuf(int n,BYTE *msg,int len) +{ + char info_str[1024]; + unsigned long one=1; + + if (mtp3DebugFull == 1) + return; + + if (((one << n) & debug_mask) == 0) + return; + + mtp_hex_to_ascii(msg,len,info_str); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); +} + +void slt_message_decode(BYTE code,char *c) +{ + switch (code) + { + case SIGNAL_SLTM: + sprintf(c,"SLTM"); + break; + case SIGNAL_SLTA: + sprintf(c,"SLTA"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void snm_message_decode(BYTE code,char *c) +{ + switch (code) + { + case SIGNAL_TFA: + sprintf(c,"TFA"); + break; + case SIGNAL_TFP: + sprintf(c,"TFP"); + break; + case SIGNAL_TRA: + sprintf(c,"TRA"); + break; + case SIGNAL_RST: + sprintf(c,"RST"); + break; + case SIGNAL_COO: + sprintf(c,"COO"); + break; + case SIGNAL_COA: + sprintf(c,"COA"); + break; + case SIGNAL_CBD: + sprintf(c,"CBD"); + break; + case SIGNAL_CBA: + sprintf(c,"CBA"); + break; + case SIGNAL_ECO: + sprintf(c,"ECA"); + break; + case SIGNAL_ECA: + sprintf(c,"ECA"); + break; + case SIGNAL_LIN: + sprintf(c,"LIN"); + break; + case SIGNAL_LUN: + sprintf(c,"LUN"); + break; + case SIGNAL_LIA: + sprintf(c,"LIA"); + break; + case SIGNAL_LUA: + sprintf(c,"LUA"); + break; + case SIGNAL_LID: + sprintf(c,"LID"); + break; + case SIGNAL_LFU: + sprintf(c,"LFU"); + break; + case SIGNAL_LLT: + sprintf(c,"LLT"); + break; + case SIGNAL_LRT: + sprintf(c,"LRT"); + break; + default: + sprintf(c,"UNK"); + break; + + } +} + +void sccp_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_SCCP_CR: + sprintf(c,"CR"); + break; + case MTP3_SCCP_CC: + sprintf(c,"CC"); + break; + case MTP3_SCCP_CREF: + sprintf(c,"CREF"); + break; + case MTP3_SCCP_RLSD: + sprintf(c,"RLSD"); + break; + case MTP3_SCCP_RLC: + sprintf(c,"RLC"); + break; + case MTP3_SCCP_DT1: + sprintf(c,"DT1"); + break; + case MTP3_SCCP_DT2: + sprintf(c,"DT2"); + break; + case MTP3_SCCP_AK: + sprintf(c,"AK"); + break; + case MTP3_SCCP_UDT: + sprintf(c,"UDT"); + break; + case MTP3_SCCP_UDTS: + sprintf(c,"UDTS"); + break; + case MTP3_SCCP_ED: + sprintf(c,"ED"); + break; + case MTP3_SCCP_EA: + sprintf(c,"EA"); + break; + case MTP3_SCCP_RSR: + sprintf(c,"RSR"); + break; + case MTP3_SCCP_RSC: + sprintf(c,"RSC"); + break; + case MTP3_SCCP_ERR: + sprintf(c,"ERR"); + break; + case MTP3_SCCP_IT: + sprintf(c,"IT"); + break; + case MTP3_SCCP_XUDT: + sprintf(c,"XUDT"); + break; + case MTP3_SCCP_XUDTS: + sprintf(c,"XUDTS"); + break; + case MTP3_SCCP_LUDT: + sprintf(c,"LUDT"); + break; + case MTP3_SCCP_LUDTS: + sprintf(c,"LUDTS"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void tup_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_TUP_IAM: + sprintf(c,"IAM"); + break; + case MTP3_TUP_IAI: + sprintf(c,"IAI"); + break; + case MTP3_TUP_SAM: + sprintf(c,"SAM"); + break; + case MTP3_TUP_SAO: + sprintf(c,"SAO"); + break; + case MTP3_TUP_GSM: + sprintf(c,"GSM"); + break; + case MTP3_TUP_COT: + sprintf(c,"COT"); + break; + case MTP3_TUP_GRQ: + sprintf(c,"GRQ"); + break; + case MTP3_TUP_ACM: + sprintf(c,"ACM"); + break; + case MTP3_TUP_SEC: + sprintf(c,"SEC"); + break; + case MTP3_TUP_CGC: + sprintf(c,"CGC"); + break; + case MTP3_TUP_CFL: + sprintf(c,"CFL"); + break; + case MTP3_TUP_SSB: + sprintf(c,"SSB"); + break; + case MTP3_TUP_UNN: + sprintf(c,"UNN"); + break; + case MTP3_TUP_LOS: + sprintf(c,"LOS"); + break; + case MTP3_TUP_SST: + sprintf(c,"SST"); + break; + case MTP3_TUP_ACB: + sprintf(c,"ACB"); + break; + case MTP3_TUP_DPN: + sprintf(c,"DPN"); + break; + case MTP3_TUP_ANU: + sprintf(c,"ANU"); + break; + case MTP3_TUP_ANC: + sprintf(c,"ANC"); + break; + case MTP3_TUP_ANN: + sprintf(c,"ANN"); + break; + case MTP3_TUP_CBK: + sprintf(c,"CBK"); + break; + case MTP3_TUP_CLF: + sprintf(c,"CLF"); + break; + case MTP3_TUP_CCL: + sprintf(c,"CCL"); + break; + case MTP3_TUP_RLG: + sprintf(c,"RLG"); + break; + case MTP3_TUP_BLO: + sprintf(c,"BLO"); + break; + case MTP3_TUP_BLA: + sprintf(c,"BLA"); + break; + case MTP3_TUP_UBL: + sprintf(c,"UBL"); + break; + case MTP3_TUP_UBA: + sprintf(c,"UBA"); + break; + case MTP3_TUP_ADI: + sprintf(c,"ADI"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +void isup_message_decode(BYTE code,char *c) +{ + switch (code) + { + case MTP3_ISUP_IAM: + sprintf(c,"IAM"); + break; + case MTP3_ISUP_ACM: + sprintf(c,"ACM"); + break; + case MTP3_ISUP_CPG: + sprintf(c,"CPG"); + break; + case MTP3_ISUP_ANM: + sprintf(c,"ANM"); + break; + case MTP3_ISUP_REL: + sprintf(c,"REL"); + break; + case MTP3_ISUP_RLC: + sprintf(c,"RLC"); + break; + case MTP3_ISUP_UBL: + sprintf(c,"UBL"); + break; + case MTP3_ISUP_UBA: + sprintf(c,"UBA"); + break; + case MTP3_ISUP_GRA: + sprintf(c,"GRA"); + break; + default: + sprintf(c,"UNK"); + break; + } +} + +BOOL iptrans_msg_flow(BYTE *msg,BYTE pclen,int direction,DWORD dest_ip) +{ + char info_str[1024]; + long dpc=0; + long opc=0; + BYTE sls; + char tempbuf[1024]; + long route_mark; + BYTE sio; + struct timeval tv; + struct timezone tz; + struct tm *t; + BYTE ssf; + unsigned long one=1; + struct in_addr in; + BOOL msg2mtp2; + char type[10]; + BYTE nw; + char netID[10]; + char codeName[16]; + int msg_len; + + if (mtp3DebugFull == 1) + return 0; + + in.s_addr = dest_ip; + +/* if (((dest_ip & E1CARD_BASE_IP_MASK) == E1CARD_BASE_IP) && + (((dest_ip >> 16) & 0xff) < 32))*/ + if (msg[0] < 255) + { + msg2mtp2 = TRUE; + } + else + msg2mtp2 = FALSE; + + sio = msg[3]; + nw = (sio >> 6) & 3; + + switch (nw) + { + case 0: + sprintf(netID,"INAT"); + break; + case 1: + sprintf(netID,"INATs"); + break; + case 2: + sprintf(netID,"NAT"); + break; + case 3: + sprintf(netID,"NATs"); + break; + } + + if (pclen == MTP3_24BIT_PC) + { + memcpy((BYTE *)&dpc,&msg[4],3); + memcpy((BYTE *)&opc,&msg[7],3); + sls = msg[10] & 0x0f; + } + else + { + memcpy((BYTE*)&route_mark,&msg[4],4); + dpc = route_mark & 0x3FFF; + opc = (route_mark & 0x0FFFFFFF) >> 14; + sls = (route_mark >> 28) & 0x0f; + } + + if (debug_link[msg[0]] != MTP3_MSGLOG_ON) + { + if (msg2mtp2 == TRUE) + return 0; + } + + { + msg_len = (msg[1]<<8) + msg[2]; + if(msg_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in iptrans_msg_flow, length longer than 300!"); + msg[1]=0; + } + + } + ssf= sio & 0x0f; + switch (ssf) + { + case TUP_SIO: + if (((one << MTP3DB_TUPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"TUP"); + if (pclen == MTP3_24BIT_PC) + tup_message_decode(msg[12],codeName); + else + tup_message_decode(msg[9],codeName); + break; + case ISUP_SIO: + if (((one << MTP3DB_ISUPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"ISUP"); + if (pclen == MTP3_24BIT_PC) + isup_message_decode(msg[13],codeName); + else + isup_message_decode(msg[10],codeName); + break; + case BICC_SIO: + if (((one << MTP3DB_BICCMSG) & debug_mask) == 0) + return 0; + sprintf(type,"BICC"); + if (pclen == MTP3_24BIT_PC) + isup_message_decode(msg[13],codeName); + else + isup_message_decode(msg[10],codeName); + break; + case SCCP_SIO: + if (((one << MTP3DB_SCCPMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SCCP"); + if (pclen == MTP3_24BIT_PC) + sccp_message_decode(msg[11],codeName); + else + sccp_message_decode(msg[8],codeName); + break; + case SNM_SIO: + if (((one << MTP3DB_SNMMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SNM"); + if (pclen == MTP3_24BIT_PC) + snm_message_decode(msg[11],codeName); + else + snm_message_decode(msg[8],codeName); + break; + case TM_SIO: + if (((one << MTP3DB_SNMMSG) & debug_mask) == 0) + return 0; + sprintf(type,"SLT"); + if (pclen == MTP3_24BIT_PC) + slt_message_decode(msg[11],codeName); + else + slt_message_decode(msg[8],codeName); + break; + default: + return 0; + } + + gettimeofday(&tv,&tz); + t = localtime(&tv.tv_sec); + switch (direction) + { + case MTP_MSG_UP: + if (msg2mtp2 == TRUE) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==MTP2,%dB %s SPC(%lx->%lx) SLS=%x LI=%x srcLINK=%03d srcIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + else + { + if (((one << MTP3DB_APP_APP_MSG) & debug_mask) != 0) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==MTP3,%dB %s SPC(%lx->%lx) SLS=%x LI=%x srcIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],inet_ntoa(in)); + else + return 0; + } + mtp_hex_to_ascii(msg, (msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); + return 1; + break; + case MTP_MSG_DOWN: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==USER,%s DPC=%lx SLS=%x\n\rPerform routing:MTP3==>MTP2,%dB SPC(%lx->%lx) LI=%02x dstLINK=%03d dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + break; + case MTP_MSG_STP: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld)Perform STP:MTP3==>MTP2,SPC(%lx->%lx) dstLINK=%x dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,opc,dpc,msg[0],inet_ntoa(in)); + break; + case MTP_MSG_OTHER_SERVER: + if (msg2mtp2 == TRUE) + sprintf(info_str,"%s%s(%02d:%02d:%02d.%06ld):MTP3<==USER, %s DPC=%lx SLS=%x\n\rRouting by UP:MTP3==>MTP2,%dB SPC(%lx->%lx) LI=%02x dstLINK=%03d dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + else + { + if (((one << MTP3DB_APP_APP_MSG) & debug_mask) != 0) + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3<==USER, %s DPC=%lx SLS=%x\n\rRouting by UP:MTP3==>MTP3,%dB SPC(%lx->%lx) LI=%02x dstIP=%s\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,dpc,sls,pclen,opc,dpc,(msg[1]<<8)+msg[2],inet_ntoa(in)); + else + return 0; + } + break; + case MTP_SNM_MSG: + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3==>MTP2,%dB %s SPC(%lx->%lx) SLS=%d LI=%02x dstLINK=%03d dstIP=%s\r\n", +type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,pclen,netID,opc,dpc,sls,(msg[1]<<8)+msg[2],msg[0],inet_ntoa(in)); + mtp_hex_to_ascii(msg,(msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r"); + mtp_send_ascout(info_str); + return 1; + break; + } + mtp_hex_to_ascii(msg,(msg[1]<<8)+msg[2]+3,tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r\n\r"); + mtp_send_ascout(info_str); + return 1; +} + +BOOL iptrans_msg_flow_2(up_message *up_msg_ptr) +{ + char info_str[1024]; + char tempbuf[1024]; + BYTE sio; + struct timeval tv; + struct timezone tz; + struct tm *t; + unsigned long one=1; + char type[10]; + BYTE nw; + char netID[10]; + char codeName[16]; + + if (mtp3DebugFull == 1) + return 0; + + if(up_msg_ptr->len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in iptrans_msg_flow_2, length longer than 300!"); + up_msg_ptr->len = 300; + } + sio = up_msg_ptr->sio; + nw = (sio >> 6) & 3; + + switch (nw) + { + case 0: + sprintf(netID,"INAT"); + break; + case 1: + sprintf(netID,"INATs"); + break; + case 2: + sprintf(netID,"NAT"); + break; + case 3: + sprintf(netID,"NATs"); + break; + } + + if (((one << MTP3DB_SCCPMSG) & debug_mask) == 0) + return 0; + + sprintf(type,"SCCP"); + sccp_message_decode(up_msg_ptr->msgList[0],codeName); + + gettimeofday(&tv,&tz); + t = localtime(&tv.tv_sec); + sprintf(info_str,"%s-%s(%02d:%02d:%02d.%06ld):MTP3LITE==>USER,%s LI=%x srcLINK=%03d\r\n", + type,codeName,t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec,netID,up_msg_ptr->len,up_msg_ptr->link); + mtp_hex_to_ascii(&up_msg_ptr->msgList[0], up_msg_ptr->len, tempbuf); + strcat(info_str,tempbuf); + strcat(info_str,"\n\r\n\r"); + mtp_send_ascout(info_str); + + return 1; +} + +void mtp3_debug(int n,const char *fmt,...) +{ + char info_str[1024]; + char tempbuf[1024]; + va_list ap; + unsigned long one=1; + struct timeval tv; + struct timezone tz; + struct tm *t; + + if (mtp3DebugFull == 1) + return; + + if(((one<tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_SCCPMSG: + sprintf(tempbuf,"\33[36mSCCP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_ISUPMSG: + sprintf(tempbuf,"\33[36mISUP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_TUPMSG: + sprintf(tempbuf,"\33[36mTUP(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_ERROR: + sprintf(tempbuf,"\33[31m(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_PFHB: + sprintf(tempbuf,"(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_PRIMITIVE_MSG: + sprintf(tempbuf,"(%d:%d:%d.%ld)",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\n\r"); + mtp_send_ascout(tempbuf); + break; + case MTP3DB_CMD: + sprintf(tempbuf,"\33[1;33m(%d:%d:%d)",t->tm_hour,t->tm_min,t->tm_sec); + strcat(tempbuf,info_str); + strcat(tempbuf,"\33[0m\n\r"); + mtp_send_ascout(tempbuf); + break; + default: + break; + } +} + +void mtp3_list_log_status() +{ + int i; + BYTE info_str[80]; + + mtp_send_ascout("\33[32mmtp3 log status-->\33[0m\n\r"); + if ((debug_mask & 2) != 0) + mtp_send_ascout("log snm \33[33mON\33[0m\n\r"); + if ((debug_mask & 4) != 0) + mtp_send_ascout("log sccp \33[33mON\33[0m\n\r"); + if ((debug_mask & 8) != 0) + mtp_send_ascout("log tup \33[33mON\33[0m\n\r"); + if ((debug_mask & 16) != 0) + mtp_send_ascout("log isup \33[33mON\33[0m\n\r"); + if ((debug_mask & 32) != 0) + mtp_send_ascout("log error \33[33mON\33[0m\n\r"); + if ((debug_mask & 64) != 0) + mtp_send_ascout("log event \33[33mON\33[0m\n\r"); + if ((debug_mask & 256) != 0) + mtp_send_ascout("log mtp3hb \33[33mON\33[0m\n\r"); + if ((debug_mask & 512) != 0) + mtp_send_ascout("log internal \33[33mON\33[0m\n\r"); + if ((debug_mask & 1024) != 0) + mtp_send_ascout("log primitive \33[33mON\33[0m\n\r"); + if ((debug_mask & 128) != 0) + { + mtp_send_ascout("log all link \33[33mON\33[0m\n\r"); + return; + } + for (i=0;i<256;i++) + { + if (debug_link[i] == MTP3_MSGLOG_ON) + { + sprintf(info_str,"log link=%d \33[33mON\33[0m\n\r",i); + mtp_send_ascout(info_str); + } + } +} + +void mtp3_show_routine_status(BYTE nw) +{ + int i; + char info_str[4096]; + char tempbuf[4096]; + nw_para *para; + network *sp; + BYTE current_rt; + BYTE nls; + BYTE als; + static BYTE last_show[4]={0}; + BYTE showCount=0; + + nw = nw & 3; + + para = &mtp3_para->nw[nw]; + sp = &mtp3.nw[nw]; + switch (nw) + { + case 0: + sprintf(info_str,"\33[33mInternational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 1: + sprintf(info_str,"\33[33mInternational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 2: + sprintf(info_str,"\33[33mNational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 3: + sprintf(info_str,"\33[33mNational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + default: + break; + } + mtp_send_ascout(info_str); + showCount=0; + for (i=last_show[nw];i<256;i++) + { + nls = para->normal_ls[i]; + als = para->alternative_ls[i]; + if ((para->dpc[i] != 0) && + (nls < 128) ) + { + current_rt = (sp->routine[i] >> 6) & 3; + switch (current_rt) + { + case 0: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[i],nls,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[i],nls,nls); + mtp_send_ascout(tempbuf); + break; + case 1: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[i],als,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[i],als,nls); + mtp_send_ascout(tempbuf); + break; + case 2: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t%02d\n\r",para->dpc[i],nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t--\n\r",para->dpc[i],nls); + mtp_send_ascout(tempbuf); + break; + default: + break; + } + showCount++; + } + if (showCount > 31) + { + last_show[nw] = i+1; + break; + } + } + if (i>=255) + { + last_show[nw] = 0; + } + +} + +void mtp3_show_routine_status_sorted(BYTE nw) +{ + int i; + char info_str[4096]; + char tempbuf[4096]; + nw_para *para; + network *sp; + mtp3DPCIndex *sort_rec; + BYTE current_rt; + BYTE nls; + BYTE als; + static BYTE last_show[4]={0}; + BYTE showCount=0; + int index; + + nw = nw & 3; + + para = &mtp3_para->nw[nw]; + sp = &mtp3.nw[nw]; + sort_rec = &mtp3SortRoutine.nw[nw]; + switch (nw) + { + case 0: + sprintf(info_str,"\33[33mInternational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 1: + sprintf(info_str,"\33[33mInternational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 2: + sprintf(info_str,"\33[33mNational Network\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + case 3: + sprintf(info_str,"\33[33mNational Network spare\n\rSPC\t\tReachable\tPath\t\tNLS\tALS\n\r\33[0m"); + break; + default: + break; + } + mtp_send_ascout(info_str); + showCount=0; + for (i=last_show[nw];isortedNum;i++) + { + index = sort_rec->index[i]; + nls = para->normal_ls[index]; + als = para->alternative_ls[index]; + if ((para->dpc[index] != 0) && + (nls < 128) ) + { + current_rt = (sp->routine[index] >> 6) & 3; + switch (current_rt) + { + case 0: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[index],nls,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[index],nls,nls); + mtp_send_ascout(tempbuf); + break; + case 1: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t%02d\n\r",para->dpc[index],als,nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[32mY\33[0m\t\tLinkset %02d\t%02d\t--\n\r",para->dpc[index],als,nls); + mtp_send_ascout(tempbuf); + break; + case 2: + if (als < 128) + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t%02d\n\r",para->dpc[index],nls,als); + else + sprintf(tempbuf,"%06lx\t\t\33[31mN\33[0m\t\tNo Path\t\t%02d\t--\n\r",para->dpc[index],nls); + mtp_send_ascout(tempbuf); + break; + default: + break; + } + showCount++; + } + if (showCount > 31) + { + last_show[nw] = i+1; + break; + } + } + if (i>=sort_rec->sortedNum-1) + { + last_show[nw] = 0; + } +} + +int pc_length(BYTE nw); +int mtp3_show_parameter(BYTE option,BYTE index) +{ + int i; + char info_str[4096]; + int maxindex; + char nw[20]; + + switch (option) + { + case 0: + mtp_send_ascout("Network\t\t\tSPC Len\t\tOPC\n\r"); + if (pc_length(0) == MTP3_24BIT_PC) + sprintf(info_str,"International\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[0].opc24); + else + sprintf(info_str,"International\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[0].opc14); + mtp_send_ascout(info_str); + if (pc_length(1) == MTP3_24BIT_PC) + sprintf(info_str,"International(s)\t24BIT\t\t%06lx\n\r",mtp3_para->nw[1].opc24); + else + sprintf(info_str,"International(s)\t14BIT\t\t%06lx\n\r",mtp3_para->nw[1].opc14); + mtp_send_ascout(info_str); + if (pc_length(2) == MTP3_24BIT_PC) + sprintf(info_str,"National\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[2].opc24); + else + sprintf(info_str,"National\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[2].opc14); + mtp_send_ascout(info_str); + if (pc_length(3) == MTP3_24BIT_PC) + sprintf(info_str,"National(s)\t\t24BIT\t\t%06lx\n\r",mtp3_para->nw[3].opc24); + else + sprintf(info_str,"National(s)\t\t14BIT\t\t%06lx\n\r",mtp3_para->nw[3].opc14); + mtp_send_ascout(info_str); + sprintf(info_str, "International Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[0], mtp3_opc.opc[0][0], mtp3_opc.opc[0][1], mtp3_opc.opc[0][2], + mtp3_opc.opc[0][3], mtp3_opc.opc[0][4], mtp3_opc.opc[0][5], mtp3_opc.opc[0][6], mtp3_opc.opc[0][7]); + mtp_send_ascout(info_str); + sprintf(info_str, "International(s) Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[1], mtp3_opc.opc[1][0], mtp3_opc.opc[1][1], mtp3_opc.opc[1][2], + mtp3_opc.opc[1][3], mtp3_opc.opc[1][4], mtp3_opc.opc[1][5], mtp3_opc.opc[1][6], mtp3_opc.opc[1][7]); + mtp_send_ascout(info_str); + sprintf(info_str, "National Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[2], mtp3_opc.opc[2][0], mtp3_opc.opc[2][1], mtp3_opc.opc[2][2], + mtp3_opc.opc[2][3], mtp3_opc.opc[2][4], mtp3_opc.opc[2][5], mtp3_opc.opc[2][6], mtp3_opc.opc[2][7]); + mtp_send_ascout(info_str); + sprintf(info_str, "National(s) Dynamic (%d): %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\r\n", + mtp3_opc.opc_num[3], mtp3_opc.opc[3][0], mtp3_opc.opc[3][1], mtp3_opc.opc[3][2], + mtp3_opc.opc[3][3], mtp3_opc.opc[3][4], mtp3_opc.opc[3][5], mtp3_opc.opc[3][6], mtp3_opc.opc[3][7]); + mtp_send_ascout(info_str); + break; + case 1: + sprintf(info_str," \33[32mLink Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLink\tLinkset\tSLC\tNormalMTP3\tAlterMTP3\tType\tSG\tCfg\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; ilk[i].e1_to_linkset,mtp3_para->lk[i].e1_to_slc, + mtp3_para->lk[i].e1_to_mtp3,mtp3_para->lk[i].e1_to_alterMTP3,mtp3_para->lk[i].e1_lk_type,mtp3_para->lk[i].e1_to_sg,mtp3ObjState.lk_configured[i]); + mtp_send_ascout(info_str); + } + break; + case 2: + sprintf(info_str," \33[32mLinkset Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLinkset\tRemote_SPC\tNetwork\t\tLoopBack\n\r\33[0m"); + mtp_send_ascout(info_str); + index = index % 128; + if (index > 96) + maxindex = 128; + else + maxindex = index+32; + for (i=index; ils_pro[i] & 3) + { + case 0: + sprintf(nw,"INT"); + break; + case 1: + sprintf(nw,"INT(s)"); + break; + case 2: + sprintf(nw,"NAT"); + break; + case 3: + sprintf(nw,"NAT(s)"); + break; + } + if ((mtp3_para->ls_pro[i] & 8) == 0) + sprintf(info_str,"%03d\t%06lx\t\t%s\t\tN\n\r",i,mtp3_para->ls_op_pc[i],nw); + else + sprintf(info_str,"%03d\t%06lx\t\t%s\t\tY\n\r",i,mtp3_para->ls_op_pc[i],nw); + mtp_send_ascout(info_str); + } + break; + case 3:// international routine */ + sprintf(info_str," \33[32mInternational Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[0].dpc[i],mtp3_para->nw[0].normal_ls[i],mtp3_para->nw[0].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 4:// international(s) routine + sprintf(info_str," \33[32mInternational(S) Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[1].dpc[i],mtp3_para->nw[1].normal_ls[i],mtp3_para->nw[1].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 5:// national routine + sprintf(info_str," \33[32mNational Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[2].dpc[i],mtp3_para->nw[2].normal_ls[i],mtp3_para->nw[2].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 6:// national(s) routine + sprintf(info_str," \33[32mNational(S) Routine\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32m SPC\tNormal LS\tAlternative LS\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; inw[3].dpc[i],mtp3_para->nw[3].normal_ls[i],mtp3_para->nw[3].alternative_ls[i]); + mtp_send_ascout(info_str); + } + break; + case 7:// SG Attribute + sprintf(info_str," \33[32mSG Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str," \33[32mSG Enable\tServer\tACK\tRemoteIP\n\r\33[0m"); + mtp_send_ascout(info_str); + if (index > 224) + maxindex = 256; + else + maxindex = index+32; + for (i=index; isg[i].enable,mtp3_para->sg[i].server, + mtp3_para->sg[i].data_ack,mtp3_para->sg[i].ip); + mtp_send_ascout(info_str); + } + break; + } + + return 1; +} + + +void mtp3_list_link(BYTE i) +{ + char info_str[4096]; + + sprintf(info_str," \33[32mLink Attribute-->\n\r\33[0m"); + mtp_send_ascout(info_str); + sprintf(info_str,"\33[32mLink\tE1_MTP3\t\tNMTP3\tAMTP3\n\r\33[0m"); + mtp_send_ascout(info_str); + + sprintf(info_str,"%03d\t%08lx\t%02x\t%02x\n\r",i, + mtp3ObjState.lk_mtp3[i],mtp3ObjState.lk_NMTP3_ok[i],mtp3ObjState.lk_AMTP3_ok[i]); + mtp_send_ascout(info_str); +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpmib.c b/omc/plat/mtp3_old/src/mtpmib.c new file mode 100644 index 0000000..feb528d --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpmib.c @@ -0,0 +1,2544 @@ +#include "../../public/src/include/pub_include.h" +#include "../../snmp/src/include/snmp.h" +#include "../../snmp/src/include/heartbeat.h" +#include "./include/mtp3.h" + +#ifdef _INCLUDE_M2UA + #include "../../m2ua/src/include/m2ua.h" +#endif +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +char mtpconfile[] = {"./conf/mtp3.conf"}; +FILE *mtpfpConf; +char MTP_OBJECT_LKA[20]={"[LINK ATTRIBUTE]\n"}; +char MTP_OBJECT_NSP[80]={"[NATIONAL NETWORK SP]\n"}; +char MTP_OBJECT_NSSP[80]={"[NATIONAL NETWORK SPARE SP]\n"}; +char MTP_OBJECT_ISP[80]={"[INTERNATIONAL NETWORK SP]\n"}; +char MTP_OBJECT_ISSP[80]={"[INTERNATIONAL NETWORK SPARE SP]\n"}; +char MTP_OBJECT_LSA[40]={"[LINKSET ATTRIBUTE]\n"}; +char MTP_OBJECT_LSP[20]={"[LOCAL SP]\n"}; +char MTP_OBJECT_SNL[40]={"[SERVICE NETWORK SP LEN]\n"}; +char MTP_OBJECT_SG[40]={"[SG ATTRIBUTES]\n"}; +char MTP_OBJECT_MTP3LITE_PORT[40]={"[MTP3LITE TCP PORT]"}; + +long atol(const char *nptr); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void hmrt_tcbc_update_routing_tables(BYTE chl); +void update_timer(int link); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_alternative_linkset_unavailable(BYTE *routine); +void mark_alternative_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void otherMTP3_managed_link_unavailable(BYTE chl); +void mtp3_reload_data(); +int MTP3_LinkIP_List(DWORD IP,BYTE mode); +void deactive_mtp3lite_lk(BYTE link); + +//extern from sccp/sccpfun.c +extern ull Bcd2Ull(BYTE *pBcd, int BcdLen); +extern int ParseLine(char *str, char (*row)[128], int maxrow); +extern int Str2Bcd(BYTE *pBcd, char *pStr, int maxLen); +extern void deactive_m3ua_lk(BYTE link); + +static u32 mtp3_primomcip=0; // primary omc ip address +static u32 mtp3_secdomcip=0; // secondary omc ip address + +static u32 mtp2_object_id[] = {1,3,6,1,4,1,1373,1,3,1,1,3}; +#define MTP2_PREOID_LEN 12 +void mtp3_send_mtp2_alarm(WORD component,BYTE alarm) +{ + snmp_pdu snmp_buf; + snmp_addr snmp_addr; + time_t cur_time; + u8 *buf; + + snmp_addr.remote_port = 4957; + snmp_addr.local_port = 4957; + snmp_addr.broadcast = 0; + snmp_buf.pdu_type = 7; + snmp_buf.var_num = 1; + memcpy(snmp_buf.var[0].oid, mtp2_object_id, MTP2_PREOID_LEN*4); + snmp_buf.var[0].oid[MTP2_PREOID_LEN] = 4; + snmp_buf.var[0].oidlen = MTP2_PREOID_LEN + 1; + snmp_buf.var[0].vartype = 4; + buf = snmp_buf.var[0].msg; + buf[0] = mtp2_module; // system id + buf[1] = mtp2_systemid; + cur_time = time(NULL); + buf[2] = cur_time >> 24; // time stamp + buf[3] = cur_time >> 16; + buf[4] = cur_time >> 8; + buf[5] = cur_time; + // byte 6--13 16 LED status (green continuous: 0x09, yellow continuous: 0x0a) + buf[6] = 0x99; + if (alarm != 0) + buf[7] = 0xaf; + else + buf[7] = 0x9f; + memset(buf+8, 0xff, 6); + + buf[14] = component>>8; // first byte of component id + buf[15] = component&255; // second byte of component id + buf[16] = alarm; // alarm level + + buf[17] = 0; + buf[18] = 0;//length 1 + + buf[19] = 0;//component id + buf[20] = 0;//component id + + buf[21] = 0; + buf[22] = 20;//length 2 + +// memcpy(buf+30, hlr_vm_ptr->sys_param.hlr_seqnum, HLR_SEQNUM_LEN); +// snmp_buf.var[0].msglen = 37 + HLR_SEQNUM_LEN; + snmp_buf.var[0].msglen = 23; + +// snmp_addr.remote_ip = 0x81ea12ac; + + if (mtp3_primomcip != 0) + { + snmp_addr.remote_ip = mtp3_primomcip; + snmp_send(&snmp_buf, &snmp_addr); + } + + if (mtp3_secdomcip != 0) + { + snmp_addr.remote_ip = mtp3_secdomcip; + snmp_send(&snmp_buf, &snmp_addr); + } +} + +int Mtp3BinSearchIndex(BYTE low, BYTE high,DWORD key, BYTE nw) +{ + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + static int mid; + static long long midvalue; + + if(low>high) + { +// LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); + return low; + } + + if(high == low+1 ) + { + if(key<=sort_rec->dpc[low]) + return low; + else if(key<=sort_rec->dpc[high]) + return high; + else + return high+1; + } + + if(low == high) + { + if(key<=sort_rec->dpc[low]) + return low; + else + return low+1; + } + + mid = (low + high)/2; + midvalue = sort_rec->dpc[mid]; + + if(key == midvalue) + { + return mid; + } + else if(keyhigh) + { +// LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); + return -1; + } + + if (sort_rec->sortedNum <= 0) + return -1; + + if (high > sort_rec->sortedNum-1) + high = sort_rec->sortedNum-1; + + if(high == low+1 ) + { + if(key==sort_rec->dpc[low]) + return low; + else if(key==sort_rec->dpc[high]) + return high; + else + return -1; + } + + if(low == high) + { + if(key==sort_rec->dpc[low]) + return low; + else + return -1; + } + + mid = (low + high)/2; + midvalue = sort_rec->dpc[mid]; + + if(key == midvalue) + { + return mid; + } + else if(keysortedNum > 256 - 1) + { + mtp3SortRoutine.nw[nw].sortedNum = 256 - 1; + return 0; + } + + if(sort_rec->sortedNum == 0) + { + index1 = 0; + sort_rec->dpc[index1] = dpc; + sort_rec->sortedNum = 1; + sort_rec->index[index1] = real_index; + return 1; + } + else + { + index1 = Mtp3BinSearchValue(0,255,nw,dpc); + if (index1>=0 && index1 < sort_rec->sortedNum)//already has this record + return 0; + + + while(sort_rec->dpc[0] > sort_rec->dpc[sort_rec->sortedNum - 1]) + sort_rec->sortedNum = (sort_rec->sortedNum - 1) % 256; + //LogErr("--AddSortRec,start BinSearchIndex key=%lld",key); + index1 = Mtp3BinSearchIndex(0,sort_rec->sortedNum-1,dpc,nw); + if (index1 >= sort_rec->sortedNum) + { + if (sort_rec->sortedNum >= 256-1) + { + return 0; + } + sort_rec->dpc[sort_rec->sortedNum] = dpc; + sort_rec->index[sort_rec->sortedNum] = real_index; + sort_rec->sortedNum ++; + } + +// LogErr("---AddSortRec: index1=%d,store_i=%d,old_key=%lld",index1,index,sort_rec[index1].key); + } + + if (sort_rec->dpc[index1] != dpc) + {// insert a item + int moveNum = (sort_rec->sortedNum-index1) % 256; + + if (sort_rec->sortedNum >= 256) + { + return 0; + } + memmove(&sort_rec->dpc[index1+1],&sort_rec->dpc[index1],moveNum*sizeof(DWORD)); + memmove(&sort_rec->index[index1+1],&sort_rec->index[index1],moveNum*sizeof(DWORD)); + sort_rec->dpc[index1]=dpc; + sort_rec->index[index1]=real_index; + sort_rec->sortedNum ++; + return 1; + } + + //LogErr("--rearrange:%lld,%lld,%lld",sort_rec[index1-1].key,key,sort_rec[index1+1].key); + + return 1; +} + +int Mtp3DeleteRecord(DWORD key,BYTE nw) //VLR_RECORD vlr_record) +{ + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; +// long long imsi=key; + DWORD MoveNum; + int index=-1; + + if (sort_rec->sortedNum == 0) + { + return 0; + } + + index = Mtp3BinSearchValue(0,255,nw,key); + +// index = BinSearchIndex(1,vlr_record_number,key); + if(index<0 || index>=sort_rec->sortedNum) + { +// LogMsg("VLR--ERROR!Delete Record index=%ld",index); + return 0; + } + + MoveNum = (sort_rec->sortedNum-index) % 256; + memmove(&sort_rec->dpc[index],&sort_rec->dpc[index+1],MoveNum*sizeof(DWORD)); + memmove(&sort_rec->index[index],&sort_rec->index[index+1],MoveNum*sizeof(DWORD)); + + // LogErr("----After del %lld,%lld,%lld",sort_rec[index-1].key,sort_rec[index].key,sort_rec[index+1].key); + + sort_rec->dpc[sort_rec->sortedNum]=0; + sort_rec->index[sort_rec->sortedNum]=0; + + sort_rec->sortedNum--; + + return 1; +} + + +BYTE mtp_encode_integer(BYTE *buf,DWORD val,BYTE value_len) +{ + if(val<128) + { + if (value_len == 4) + { + buf[0] = 0; + buf[1] = 0; + buf[2]=val; + return 3; + } + else + { + buf[0] = val; + return 1; + } + } + else if(val<0x8000) + { + if (value_len == 4) + { + buf[0] = 0; + buf[1]=val >>8; + buf[2]=val & 0xFF; + return 3; + } + else + { + buf[0]=val; + return 1; + } + } + else if(val <0x800000) + { + buf[0]=val >>16; + buf[1]=(val & 0xFF00)>>8; + buf[2]=val & 0xFF; + return 3; + } +// else if(val <0x80000000) + else + { + buf[0]=(val & 0xFF0000)>>16; + buf[1]=(val & 0xFF00)>>8; + buf[2]=val & 0xFF; + return 3; + } +} + +int mtp3_reset_sccp() +{ + DWORD oid[20] = {1,3,6,1,4,1,1373,2,3,2,3,3,2};//SCCP_OID + BYTE value=0; + return set_response(13,oid,&value,1); +} + +void del_1dst_from_table(ls_info *ls, BYTE dpc_place, BYTE ud_select) +{ + BYTE dst_num; + int i; + + switch (ud_select) + { + case UPDATE_NLS: + dst_num = ls->influ_dstnum_asNLS; + if (dst_num == 0) + return; + ls->influ_dstnum_asNLS --; + for (i=0; iinflu_dstplace_intable_asNLS[i] == dpc_place) + { + memcpy(&ls->influ_dstplace_intable_asNLS[i], + &ls->influ_dstplace_intable_asNLS[i+1],dst_num-i-1); + ls->influ_dstplace_intable_asNLS[dst_num-1] = 0; + return; + } + } + break; + case 1: + dst_num = ls->influ_dstnum_asALS; + if (dst_num == 0) + return; + ls->influ_dstnum_asALS --; + for (i=0; iinflu_dstplace_intable_asALS[i] == dpc_place) + { + memcpy(&ls->influ_dstplace_intable_asALS[i], + &ls->influ_dstplace_intable_asALS[i+1],dst_num-i-1); + ls->influ_dstplace_intable_asALS[dst_num-1] = 0; + return; + } + } + break; + } +} + +void add_1dst_to_table(ls_info *ls, BYTE place,BYTE ud_select) +{ + BYTE dst_num; + + switch (ud_select) + { + case UPDATE_NLS: + dst_num = ls->influ_dstnum_asNLS; + ls->influ_dstplace_intable_asNLS[dst_num] = place; + ls->influ_dstnum_asNLS = dst_num + 1; + break; + case UPDATE_ALS: + dst_num = ls->influ_dstnum_asALS; + ls->influ_dstplace_intable_asALS[dst_num] = place; + ls->influ_dstnum_asALS = dst_num + 1; + break; + } +} + +void scan_conf_right_or_not(BYTE nw) +{ + static BYTE index=0; + BYTE nls; + BYTE lsnw; + + return; + nls = mtp3_para->nw[nw].normal_ls[index]; + if (nls < 128) + { + lsnw = mtp3_para->ls_pro[nls] & 3; + if ((lsnw != nw) && (mtp3_para->nw[nw].dpc[index] != 0)) + printf("configure error,nw %d,dpc=%lx normal linkset belong to network %d\n",nw,mtp3_para->nw[nw].dpc[index],lsnw); + } + index ++; +} + +void mtp3lite_upd_route_status(BYTE chl, BYTE flag) +{ + ls_info *ls; + int i; + BYTE dpc_index, lsno, nw; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno >= 0x80) + return; + + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + + for (i = 0; i < ls->influ_dstnum_asNLS; i++) + { + dpc_index = ls->influ_dstplace_intable_asNLS[i]; + if (!flag) + mark_normal_linkset_unavailable(&mtp3.nw[nw].routine[dpc_index]); + else + mark_normal_linkset_available(&mtp3.nw[nw].routine[dpc_index]); + if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,nw); + } +} + +void change_the_whole_ls(BYTE lsno,BYTE oldnw,BYTE nw) +{ + ls_info *ls; + int i; + nw_para *nwpara; + BYTE *routine; + BYTE ls_available; + BYTE dpc_index; + int added=0; + + ls = &mtp3.ls[lsno]; + +// printf("oldnw = %d,newnw=%d\n",oldnw,nw); + + for (i=0;iinflu_dstnum_asNLS;i++) + { + dpc_index = ls->influ_dstplace_intable_asNLS[i]; + mark_normal_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); + if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,oldnw); + ls->influ_dstplace_intable_asNLS[i] = 0xff; + Mtp3DeleteRecord(mtp3_para->nw[oldnw].dpc[dpc_index],oldnw); + } + for (i=0;iinflu_dstnum_asALS;i++) + { + dpc_index = ls->influ_dstplace_intable_asALS[i]; + mark_alternative_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); + if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable + mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); + hmrt_tfrc_update_routing_tables(dpc_index,oldnw); + ls->influ_dstplace_intable_asALS[i] = 0xff; + Mtp3DeleteRecord(mtp3_para->nw[oldnw].dpc[dpc_index],oldnw); + } + ls->influ_dstnum_asNLS = 0; + ls->influ_dstnum_asALS = 0; + + if (mtp3.ls[lsno].links_available_t > 0) + ls_available = TRUE; + else + ls_available = FALSE; + + nwpara = &mtp3_para->nw[nw]; + for (i=0;i<256;i++) + { + if (nwpara->dpc[i] == 0) + continue; + routine = &mtp3.nw[nw].routine[i]; + if (nwpara->normal_ls[i] == lsno) + { + if (ls_available == TRUE) + mark_normal_linkset_available(routine); + else + mark_normal_linkset_unavailable(routine); + add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_NLS); + Mtp3AddSortRec(nw,nwpara->dpc[i],i); + added = 1; + } + if ((nwpara->alternative_ls[i] == lsno) && + (nwpara->normal_ls[i] < 128) ) + { + if (ls_available == TRUE) + mark_alternative_linkset_available(routine); + else + mark_alternative_linkset_unavailable(routine); + add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_ALS); + + if (!added) + Mtp3AddSortRec(nw,nwpara->dpc[i],i); + } + hmrt_tfrc_update_routing_tables(i,nw); + + added=0; + } +} + +void update_ls_influence_dst_table(BYTE nw, long dst, BYTE place, BYTE nls, BYTE als, DWORD rc) +{ + BYTE *routine; + DWORD pc_new, rc_new; + BYTE nls_old; + BYTE als_old; + DWORD pc_old; + BYTE nlsnw; + BYTE alsnw; + + pc_new = decode_integer((BYTE*)&dst,4); + rc_new = decode_integer((BYTE*)&rc,4); + + + routine = &mtp3.nw[nw].routine[place]; + + nls_old = mtp3_para->nw[nw].normal_ls[place]; + als_old = mtp3_para->nw[nw].alternative_ls[place]; + pc_old = mtp3_para->nw[nw].dpc[place]; + nlsnw = mtp3_para->ls_pro[nls] & 3; + alsnw = mtp3_para->ls_pro[als] & 3; + + if ((pc_old == pc_new) && + (nls_old == nls) && + (als_old == als) && + (mtp3_para->nw[nw].rc[place] == rc_new)) + return; + + if (pc_old > 0) + Mtp3DeleteRecord(pc_old,nw);//delect this pc from sort table + if (pc_new > 0) + { + if ((nls<128 && nlsnw == nw) || (als<128 && alsnw==nw)) + { + Mtp3AddSortRec(nw,pc_new,place);//add this new pc to the sort table + } + } + + if ( (nls != nls_old) || + (als != als_old) ) + { + if ((nls < 128) && + (nlsnw == nw)) + { + if (mtp3.ls[nls].links_available_t > 0) + mark_normal_linkset_available(routine); + else + mark_normal_linkset_unavailable(routine); + if (nls != nls_old) + add_1dst_to_table(&mtp3.ls[nls],place,UPDATE_NLS); + } + else + mark_normal_linkset_unavailable(routine); + if ((als < 128) && + (nls < 128) &&// if one spc doesn't has normal linkset,it can not has alternative linkset + (alsnw == nw)) + { + if (mtp3.ls[als].links_available_t > 0) + mark_alternative_linkset_available(routine); + else + mark_alternative_linkset_unavailable(routine); + if ((als != als_old) || (nls_old > 127) ) + { +// printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); + add_1dst_to_table(&mtp3.ls[als],place,UPDATE_ALS); +// printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); + } + } + else + mark_alternative_linkset_unavailable(routine); + if ((mtp3.nw[nw].routine[place] & 0x0f) == 0x0a) + mark_dstSP_inaccessible(routine); + hmrt_tfrc_update_routing_tables(place,nw); + + mtp3_para->nw[nw].dpc[place] = pc_new; + mtp3_para->nw[nw].normal_ls[place] = nls; + mtp3_para->nw[nw].alternative_ls[place] = als; + + if ( (nls_old < 128) && + (nls_old != nls) ) + del_1dst_from_table(&mtp3.ls[nls_old],place,UPDATE_NLS); + + if ( (als_old < 128) && + (als_old != als) ) + del_1dst_from_table(&mtp3.ls[als_old],place,UPDATE_ALS); + } + if (mtp3_para->ls_op_pc[nls] == pc_new) + mtp3.ls[nls].adjacent_sp_place = place; + mtp3_para->nw[nw].dpc[place] = pc_new; + mtp3_para->nw[nw].rc[place] = rc_new; +} + +int mtp3_write_parameter() +{ + int i,j; + int ix4; + + mtpfpConf = fopen(mtpconfile,"w"); + if (mtpfpConf == NULL) + return -1; + + fprintf(mtpfpConf,"#MTP3 CONFIGURE FILE\n"); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[SERVICE NETWORK SP LEN]\n"); + fprintf(mtpfpConf,"[%02x]\n",mtp3_para->nw_pro); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[MTP3LITE TCP PORT]\n"); + fprintf(mtpfpConf,"[%04x]\n",mtp3_para->mtp3lite_port); + fprintf(mtpfpConf,"\n"); + fprintf(mtpfpConf,"[LOCAL SP]\n"); + fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc14, + mtp3_para->nw[1].opc14,mtp3_para->nw[2].opc14,mtp3_para->nw[3].opc14); + fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc24, + mtp3_para->nw[1].opc24,mtp3_para->nw[2].opc24,mtp3_para->nw[3].opc24); + fprintf(mtpfpConf,"\n"); + +/* e1 to linkset */ + fprintf(mtpfpConf,"[LINK ATTRIBUTE]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%02x.%02x.%08lx.%02x.%02x.%02x.%08lx.%02x.%02x.%08lx]\t",mtp3_para->lk[ix4+j].e1_to_linkset, + mtp3_para->lk[ix4+j].e1_to_slc,mtp3_para->lk[ix4+j].e1_to_mtp3,mtp3_para->lk[ix4+j].e1_lk_type,mtp3_para->lk[ix4+j].e1_to_sg,mtp3_para->lk[ix4+j].e1_to_iid, + mtp3_para->lk[ix4+j].remote_ip,mtp3_para->lk[ix4+j].inactive,mtp3_para->lk[ix4+j].inactive_tm,mtp3_para->lk[ix4+j].e1_to_alterMTP3); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* linkset remote sp */ + fprintf(mtpfpConf,"[LINKSET ATTRIBUTE]\n"); + for (i=0; i<32; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + if (1) + { + char ls_reserved[128]={0}; + char temp[16]; + int k; + for (k=0;k<16;k++) + { + sprintf(temp,"%02x",mtp3_para->ls_reserved[ix4+j][k]); + strcat(ls_reserved,temp); + } + fprintf(mtpfpConf,"[%06lx.%02x.%-16s]\t",mtp3_para->ls_op_pc[ix4+j],mtp3_para->ls_pro[ix4+j],ls_reserved); + } + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* SG */ + fprintf(mtpfpConf, "[SG ATTRIBUTES]\n"); + for (i = 0; i < 64; i++) + { + ix4 = i * 4; + + for (j = 0; j < 4; j++) + { + fprintf(mtpfpConf, "[%02X.%02X.%02X.%08lX]\t", mtp3_para->sg[ix4+j].enable, mtp3_para->sg[ix4+j].server, + mtp3_para->sg[ix4+j].data_ack, mtp3_para->sg[ix4+j].ip); + } + + fprintf(mtpfpConf, "\n"); + } + fprintf(mtpfpConf, "\n"); + +/* NATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[NATIONAL NETWORK SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx]\t",mtp3_para->nw[2].dpc[ix4+j],mtp3_para->nw[2].normal_ls[ix4+j], + mtp3_para->nw[2].alternative_ls[ix4+j], mtp3_para->nw[2].rc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* NATIONAL NETWORK SPARE SP */ + fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx]\t",mtp3_para->nw[3].dpc[ix4+j],mtp3_para->nw[3].normal_ls[ix4+j], + mtp3_para->nw[3].alternative_ls[ix4+j], mtp3_para->nw[3].rc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* INTERNATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx]\t",mtp3_para->nw[0].dpc[ix4+j],mtp3_para->nw[0].normal_ls[ix4+j], + mtp3_para->nw[0].alternative_ls[ix4+j], mtp3_para->nw[0].rc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + +/* INTERNATIONAL NETWORK SP */ + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE SP]\n"); + for (i=0; i<64; i++) + { + ix4 = i*4; + for (j=0; j<4; j++) + { + fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx]\t",mtp3_para->nw[1].dpc[ix4+j],mtp3_para->nw[1].normal_ls[ix4+j], + mtp3_para->nw[1].alternative_ls[ix4+j], mtp3_para->nw[1].rc[ix4+j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[LOCAL ACN]\n"); + for(i=0;ilocalAcn[i]); + } + fprintf(mtpfpConf,"\n\n"); + + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[0].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[1].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[NATIONAL NETWORK ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[2].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE ACN]\n"); + for (i=0; i<256; i++) + { + for (j=0;jnw[3].acn[i][j]); + } + fprintf(mtpfpConf,"\n"); + } + fprintf(mtpfpConf,"\n"); + + fclose(mtpfpConf); + return 1; +} + +static int issquare(char c) +{ + if ((c=='[') || (c==']') || (c==' ') || (c=='\t')) + return 1; + return 0; +} + +static int isdot(char c) +{ + if ((c=='.')) + return 1; + return 0; +} + +int ParseLineWithSquare(char *str, char (*row)[128], int maxrow) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen(str); + for(i = 0; i < len && index < maxrow; i++) + { + if(issquare(str[i])) + { + if(black == 0) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if(black == 1) + { + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + } + return index; +} + +int ParseLineWithDot(char *str, char (*row)[128], int maxrow) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen(str); + for(i = 0; i < len && index < maxrow; i++) + { + if(isdot(str[i])) + { + if(black == 0) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if(black == 1) + { + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + } + return index; +} + +int ReadMtp3NetworkPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLineWithSquare(s, LineInfo, 1); + mtp3_para->nw_pro = strtoll(LineInfo[0],NULL,16); + + return 1; +} + +int ReadMtp3LitePortPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLineWithSquare(s, LineInfo, 1); + mtp3_para->mtp3lite_port = strtoll(LineInfo[0],NULL,16); + + return 1; +} + +int ReadMtp3OPCPara(char *s) +{ + char LineInfo[8][128]; + int rtn; + int instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links + if (Base==0) + { + for (instance=0;instance<4;instance++) + { + mtp3_para->nw[instance].opc14 = strtoll(LineInfo[instance],NULL,16); + } + } + else + { + for (instance=0;instance<4;instance++) + { + mtp3_para->nw[instance].opc24 = strtoll(LineInfo[instance],NULL,16); + } + } + + Base++; + + if (Base > 1) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LinkPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + DWORD mtp3ip; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,10); + mtp3_para->lk[Base+Instance].e1_to_linkset = strtoll(DetailInfo[0],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_slc = strtoll(DetailInfo[1],NULL,16); + mtp3ip = strtoll(DetailInfo[2],NULL,16); + if (rtn == 3) + { + if (mtp3ip == 0xff) + mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0xffffffff; + else + mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0x010012ac | ((mtp3ip & 0xff) << 16); + mtp3_para->lk[Base+Instance].e1_lk_type = 0x01; + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; + } + else + { + mtp3_para->lk[Base+Instance].e1_to_mtp3 = mtp3ip; + mtp3_para->lk[Base+Instance].e1_lk_type = strtoll(DetailInfo[3],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_sg = strtoll(DetailInfo[4],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_iid = strtoll(DetailInfo[5],NULL,16); + mtp3_para->lk[Base+Instance].remote_ip = strtoll(DetailInfo[6],NULL,16); + mtp3_para->lk[Base+Instance].inactive = strtoll(DetailInfo[7],NULL,16); + mtp3_para->lk[Base+Instance].inactive_tm = strtoll(DetailInfo[8],NULL,16); + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = strtoll(DetailInfo[9],NULL,16); + if(mtp3_para->lk[Base+Instance].e1_to_alterMTP3 == mtp3_para->lk[Base+Instance].e1_to_mtp3) + { + mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; + } + } +#ifdef _INCLUDE_M2UA + set_m2ua_link(Base+Instance, (BYTE *) &mtp3_para->lk[Base+Instance]); +#endif + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LinksetPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,3); + mtp3_para->ls_op_pc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->ls_pro[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + if (rtn == 3) + Str2Bcd(mtp3_para->ls_reserved[Base+Instance],DetailInfo[2],16); + } + + Base+=4; + + if (Base >= 128) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3SGPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->sg[Base+Instance].enable = strtoll(DetailInfo[0],NULL,16); + mtp3_para->sg[Base+Instance].server = strtoll(DetailInfo[1],NULL,16); + mtp3_para->sg[Base+Instance].data_ack = strtoll(DetailInfo[2],NULL,16); + mtp3_para->sg[Base+Instance].ip = strtoll(DetailInfo[3],NULL,16); +#ifdef _INCLUDE_M2UA + set_m2ua_sg(Base+Instance, (BYTE *) &mtp3_para->sg[Base+Instance]); +#endif + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4);//3); + mtp3_para->nw[2].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[2].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[2].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[2].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATsPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->nw[3].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[3].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[3].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[3].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->nw[0].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[0].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[0].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[0].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTsPara(char *s) +{ + char LineInfo[8][128]; + char DetailInfo[10][128]; + int rtn; + int Instance; + static int Base=0; + + rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets + for (Instance=0;Instance<4;Instance++) + { + rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); + mtp3_para->nw[1].dpc[Base+Instance] = strtoll(DetailInfo[0],NULL,16); + mtp3_para->nw[1].normal_ls[Base+Instance] = strtoll(DetailInfo[1],NULL,16); + mtp3_para->nw[1].alternative_ls[Base+Instance] = strtoll(DetailInfo[2],NULL,16); + mtp3_para->nw[1].rc[Base+Instance] = strtoll(DetailInfo[3],NULL,16); + } + + Base+=4; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3LocalACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->localAcn,LineInfo[0],MAX_ACN_NUM*2); + + return 1; +} + +int ReadMtp3INTACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[0].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3INTsACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[1].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[2].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +int ReadMtp3NATSACNPara(char *s) +{ + char LineInfo[1][128]; + int rtn; + static int Base=0; + + rtn = ParseLine(s, LineInfo, 1);//each line four linksets + AsciiToBcd(mtp3_para->nw[3].acn[Base],LineInfo[0],MAX_ACN_NUM*2); + + Base++; + + if (Base >= 256) + { + Base = 0; + return 1; + } + return 0; +} + +void mtp3_readpara_from_disk() +{ + char s[1024]={0}; + int len; + BYTE state = 0; + FILE *fp; + + fp = fopen(mtpconfile,"rb"); + + if (fp==NULL) + { + printf("mtp3 config file %s missed!!\n",mtpconfile); + return; + } + + s[0] = 0; + while ( fgets(s,1024,fp) != (char *)0 ) + { + if ( (int *)strchr(s,'#') != NULL ) continue; + if ( (len=strlen(s))==0 ) continue; + + if ( strstr(s,"[SERVICE NETWORK SP LEN]") != NULL ) + { + state = 1; + continue; + } + else if ( strstr(s,"[MTP3LITE TCP PORT]") != NULL ) + { + state = 2; + continue; + } + else if ( strstr(s,"[LOCAL SP]") != NULL ) + { + state = 3; + continue; + } + + else if ( strstr(s,"[LINK ATTRIBUTE]") != NULL ) + { + state = 4; + continue; + } + else if ( strstr(s,"[LINKSET ATTRIBUTE]") != NULL ) + { + state = 5; + continue; + } + else if ( strstr(s,"[SG ATTRIBUTES]") != NULL ) + { + state = 6; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SP]") != NULL ) + { + state = 7; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SPARE SP]") != NULL ) + { + state = 8; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SP]") != NULL ) + { + state = 9; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE SP]") != NULL ) + { + state = 10; + continue; + } + else if ( strstr(s,"[LOCAL ACN]") != NULL ) + { + state = 11; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK ACN]") != NULL ) + { + state = 12; + continue; + } + else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE ACN]") != NULL ) + { + state = 13; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK ACN]") != NULL ) + { + state = 14; + continue; + } + else if ( strstr(s,"[NATIONAL NETWORK SPARE ACN]") != NULL ) + { + state = 15; + continue; + } + + + switch (state) + { + case 1: + if (ReadMtp3NetworkPara(s)) + state = 0; + break; + case 2: + if (ReadMtp3LitePortPara(s)) + state = 0; + break; + case 3: + if (ReadMtp3OPCPara(s)) + state = 0; + break; + case 4: + if (ReadMtp3LinkPara(s)) + state = 0; + break; + case 5: + if (ReadMtp3LinksetPara(s)) + state = 0; + break; + case 6: + if (ReadMtp3SGPara(s)) + state = 0; + break; + case 7: + if (ReadMtp3NATPara(s)) + state = 0; + break; + case 8: + if (ReadMtp3NATsPara(s)) + state = 0; + break; + case 9: + if (ReadMtp3INTPara(s)) + state = 0; + break; + case 10: + if (ReadMtp3INTsPara(s)) + state = 0; + break; + case 11: + if (ReadMtp3LocalACNPara(s)) + state = 0; + break; + case 12: + if (ReadMtp3INTACNPara(s)) + state = 0; + break; + case 13: + if (ReadMtp3INTsACNPara(s)) + state = 0; + break; + case 14: + if (ReadMtp3NATACNPara(s)) + state = 0; + break; + case 15: + if (ReadMtp3NATSACNPara(s)) + state = 0; + break; + default: + break; + } + } + + fclose(fp); +} + +void mtp3_setlink_to_IDLE(BYTE link) +{ + BYTE oldls; + BYTE oldslc; + DWORD oldip; + BYTE oldtp; + + oldls = mtp3_para->lk[link].e1_to_linkset; + oldslc = mtp3_para->lk[link].e1_to_slc; + oldip = mtp3_para->lk[link].e1_to_mtp3; + oldtp = mtp3_para->lk[link].e1_lk_type; + + if (mtp3ObjState.link_l3_state[link] == AVAILABLE) + { + + if ((MTP3_LINK_TYPE(link) == LKTYPE_MTP3_LITE) && // Not MTP3LITE + (mtp3_para->lk[link].e1_lk_type & 0x01)) // Enabled + {//sccp lite link + deactive_mtp3lite_lk(link); + } + else if((MTP3_LINK_TYPE(link) == LKTYPE_M3UA) && // Not M3UA + (mtp3_para->lk[link].e1_lk_type & 0x01)) // Enabled + {//sccp lite link + deactive_m3ua_lk(link); + } + else + { + mtp3ObjInput.sltc_input[link] = SLTC_STOP; + sltc_proc(link); + init_lsac_state[link] = TRUE; + lsac_proc(link); + init_tlac_state[link] = TRUE; + tlac_proc(link); + + if (mtp3ObjState.link_l3_state[link] == AVAILABLE) + otherMTP3_managed_link_unavailable(link); + mtp3ObjState.link_l2_state[link] = UNAVAILABLE; + mtp3ObjState.link_l3_state[link] = UNAVAILABLE; + } + } + + if (mtp3ObjState.lk_configured[link] == PARA_CONFIGURED) + { + mtp3.ls[oldls].linksNum_configured--; + ls_slc[oldls*16+oldslc] = 0xff; + update_sls_to_link_table(oldls); + } + mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED; + +// printf("link %d update para,new ls=%d,new slc = %d,new ip=%lx\n",link,newls,newslc,newip); +} + +int mtp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen) +{ + int instance; + DWORD pc; + BYTE command; + int ls; + int slc; + DWORD ip; + DWORD ip1; + int tp; + int i; + DWORD oldpc; + BYTE old_lsnw; + BYTE new_lsnw; + DWORD oldpar, rc; + BOOL para_changed=0; + + if ( oidlen < MTP3_OID_LEN) + { + printf("set failed,object id length not correct\n"); + return -1; + } + + if ( oid[MTP3_OID_LEN] == 2 )/* configure */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* sp/stp */ + break; + case 2:/* 14/24bit (for four service networks) */ + oldpar = mtp3_para->nw_pro; + mtp3_para->nw_pro = decode_integer(pdata,datalen); + if (oldpar != mtp3_para->nw_pro) + mtp3_reset_sccp(); + return 1; + case 3:/* opc */ + memcpy(&pc,pdata,4); + pc = pc << 8; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + oldpar = mtp3_para->nw[0].opc14; + mtp3_para->nw[0].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[0].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(0, mtp3_para->nw[0].opc14); + } + return 3; + case 2: + oldpar = mtp3_para->nw[1].opc14; + mtp3_para->nw[1].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[1].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(1, mtp3_para->nw[1].opc14); + } + return 3; + case 3: + oldpar = mtp3_para->nw[2].opc14; + mtp3_para->nw[2].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[2].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(2, mtp3_para->nw[2].opc14); + } + return 3; + case 4: + oldpar = mtp3_para->nw[3].opc14; + mtp3_para->nw[3].opc14 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[3].opc14) + { + mtp3_reset_sccp(); + mtp3_delete_opc(3, mtp3_para->nw[3].opc14); + } + return 3; + case 5: + oldpar = mtp3_para->nw[0].opc24; + mtp3_para->nw[0].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[0].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(0, mtp3_para->nw[0].opc24); + } + return 3; + case 6: + oldpar = mtp3_para->nw[1].opc24; + mtp3_para->nw[1].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[1].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(1, mtp3_para->nw[1].opc24); + } + return 3; + case 7: + oldpar = mtp3_para->nw[2].opc24; + mtp3_para->nw[2].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[2].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(2, mtp3_para->nw[2].opc24); + } + return 3; + case 8: + oldpar = mtp3_para->nw[3].opc24; + mtp3_para->nw[3].opc24 = decode_integer((BYTE*)&pc,4); + if (oldpar != mtp3_para->nw[3].opc24) + { + mtp3_reset_sccp(); + mtp3_delete_opc(3, mtp3_para->nw[3].opc24); + } + return 3; + default: + return -1; + } + break; + case 4:/* linkset */ + instance = oid[MTP3_OID_LEN+3]; + if (instance > 127) + return -1; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + oldpc = mtp3_para->ls_op_pc[instance]; + old_lsnw = mtp3_para->ls_pro[instance] & 3; + new_lsnw = pdata[3] & 3; + memcpy(&pc,pdata,4); + pc = pc << 8; + mtp3_para->ls_op_pc[instance] = decode_integer((BYTE*)&pc,4); + /* linkset adjacent sp */ + mtp3_para->ls_pro[instance] = pdata[3]; + memcpy(&mtp3_para->ls_reserved[instance],&pdata[4],16); + if (old_lsnw != new_lsnw) + { + change_the_whole_ls(instance,old_lsnw,new_lsnw); + } + if ((oldpc != mtp3_para->ls_op_pc[instance]) || + (old_lsnw != new_lsnw) ) + { + pc = mtp3_para->ls_op_pc[instance]; + for (i=0;i<256;i++) + { + if (mtp3_para->nw[new_lsnw].dpc[i] == pc) + { + mtp3.ls[instance].adjacent_sp_place = i; + return 4; + } + } +// printf("not found pc in table\n"); + mtp3.ls[instance].adjacent_sp_place = 0xffff; + } + return 20; + default: + return -1; + } + break; + case 5:/* link */ + instance = oid[MTP3_OID_LEN+3]; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* e1 to linkset */ + ls = pdata[0]; + slc = pdata[1]; + memcpy(&ip,&pdata[2],4); + memcpy(&ip1,&pdata[15],4); +// ip = pdata[2]; + tp = pdata[6]; + if(ip == ip1 && ip1 != 0xffffff) + {//ip can not be same as ip1 + ip1 = 0xffffffff; + memcpy(&pdata[15], &ip1, 4); + } + + if (ls!=mtp3_para->lk[instance].e1_to_linkset || slc!=mtp3_para->lk[instance].e1_to_slc + || ip!=mtp3_para->lk[instance].e1_to_mtp3 || ip1!=mtp3_para->lk[instance].e1_to_alterMTP3 + || tp != mtp3_para->lk[instance].e1_lk_type) + { + mtp3_setlink_to_IDLE(instance); + para_changed = 1; + } + if (datalen<19) + memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 15); + else + memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 19); + mtp3ObjState.link_type[instance] = mtp3_para->lk[instance].e1_lk_type; + if (para_changed) + { + if (update_ls_slc_table(instance) == 1) + { + update_sls_to_link_table(ls); + MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_mtp3,1); + MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_alterMTP3,1); + } + } +#ifdef _INCLUDE_M2UA + set_m2ua_link(instance & 0xff, pdata); +#endif + return 19; + case 2:/* link command */ + mtp3ObjState.lk_command[instance] = pdata[0]; + + if (mtp3ObjState.lk_mtp3[instance] != mtp3_localip) + return 1; + if (MTP3_LINK_TYPE(instance) == LKTYPE_MTP3_LITE) + { + if (pdata[0]==0)//disable + deactive_mtp3lite_lk(instance); + + return 1; + } + else if (MTP3_LINK_TYPE(instance) == LKTYPE_M3UA) + { + if (pdata[0]==0)//disable + deactive_m3ua_lk(instance); + + return 1; + } + else + { + command = pdata[0]; + if (command < 2) + { + mtp3ObjInput.lsac_input_from_mgmt[instance] = command; + return 1; + } + else if (command < 4) + { + mtp3ObjInput.tlac_input_from_mgmt[instance] = command - 1; + return 1; + } + else + return -1; + } + case 3:/* MTP3LITE TCP Port */ + mtp3_para->mtp3lite_port = pdata[1]; + mtp3_para->mtp3lite_port = (mtp3_para->mtp3lite_port << 8) | pdata[0]; + return 2; + default: + return -1; + } + break; + case 6:/* routine table */ + instance = oid[MTP3_OID_LEN+3]; + memcpy(&pc,pdata,4); + memcpy(&rc,&pdata[5],4); + pc = pc << 8; + if ((oid[MTP3_OID_LEN+2] > 4) || (oid[MTP3_OID_LEN+2] < 1)) + return -1; + update_ls_influence_dst_table((oid[MTP3_OID_LEN+2]-1),pc,instance,pdata[3],pdata[4], rc); + return 9; + case 7:/* dpc->acn */ + instance = oid[MTP3_OID_LEN+3]; + + if (oid[MTP3_OID_LEN+2] == 1) + { + memcpy(mtp3_para->localAcn,pdata,MAX_ACN_NUM); + } + else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) + { + memcpy(mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].acn[instance],pdata,MAX_ACN_NUM); + } + else + return -1; + return MAX_ACN_NUM; + case 8:/* timer */ + instance = oid[MTP3_OID_LEN+3]; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* link timer */ + memcpy(&mtp3_para->lt[instance].t1,pdata,10); + update_timer(instance); + return 10; + default: + return -1; + } + return -1; + case 9:/* sg */ + instance = oid[MTP3_OID_LEN+2]; + memcpy(&mtp3_para->sg[instance],pdata,7); +#ifdef _INCLUDE_M2UA + set_m2ua_sg(instance & 0xff, pdata); + return 7; +#else + return 7; +#endif + default: + return -1; + } + return -1; + } + else if (oid[MTP3_OID_LEN] == 3)/* status */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 7: + case 8:/* command */ + switch (pdata[0]) + { + case 1: + reset_mtp3(); + break; + case 2: + printf("save parameter\n"); + return mtp3_write_parameter(); + break; + case 3://load data + mtp3_reload_data(); + break; + default: + break; + } + return 1; + default: + return -1; + } + } + else + return -1; +} + +void mtp3_data_reverse(BYTE *pdata,BYTE *csta,BYTE len,BYTE data_type) +{ + int i; + int j=0; + + for (i=0; i 15) + temp = 15; + mtp3_measure.measure[portion_num].lk_measure1[instance][i] = temp; + } + break; + case 1: + temp = mtp3_measure.measure[portion_num].ls_measure[instance][0]; + temp = (temp + 3) / 6; + if (temp > 15) + temp = 15; + mtp3_measure.measure[portion_num].ls_measure[instance][0] = temp; + temp = mtp3_measure.measure[portion_num].ls_measure[instance][6]; + temp = (temp + 3) / 6; + if (temp > 15) + temp = 15; + mtp3_measure.measure[portion_num].ls_measure[instance][6] = temp; + break; + default: + break; + } +} + +int mtp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ +/* 1.3.6.1.4.1.1373.1.1.2.2.2.2 */ + unsigned int instance; + BYTE portion_num=0; + DWORD timestamp; + + if ( oidlen < 12 ) + { + printf("get fail,object id not correct\n"); + return -1; + } + if ( oid[MTP3_OID_LEN] == 2 )/* configure */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* sp/stp */ + return -1; + case 2:/* 14/24bit (for four service networks) */ + *vartype = 4; + return mtp_encode_integer(pdata,mtp3_para->nw_pro,1); + case 3:/* opc */ + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + return mtp_encode_integer(pdata,mtp3_para->nw[0].opc14,4); + case 2: + return mtp_encode_integer(pdata,mtp3_para->nw[1].opc14,4); + case 3: + return mtp_encode_integer(pdata,mtp3_para->nw[2].opc14,4); + case 4: + return mtp_encode_integer(pdata,mtp3_para->nw[3].opc14,4); + case 5: + return mtp_encode_integer(pdata,mtp3_para->nw[0].opc24,4); + case 6: + return mtp_encode_integer(pdata,mtp3_para->nw[1].opc24,4); + case 7: + return mtp_encode_integer(pdata,mtp3_para->nw[2].opc24,4); + case 8: + return mtp_encode_integer(pdata,mtp3_para->nw[3].opc24,4); + default: + return -1; + } + return -1; + case 4:/* linkset */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + mtp_encode_integer(pdata,mtp3_para->ls_op_pc[instance],4); + pdata[3] = mtp3_para->ls_pro[instance]; + memcpy(&pdata[4],&mtp3_para->ls_reserved[instance],16); + return 20; + /* linkset adjacent sp */ + default: + return -1; + } + return -1; + case 5:/* link */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* e1 to linkset */ + memcpy(pdata,&mtp3_para->lk[instance].e1_to_linkset,19); + return 19; + case 2: + memcpy(pdata,&mtp3ObjState.lk_command[instance],1); + return 1; + case 3: + pdata[0] = mtp3_para->mtp3lite_port; + pdata[1] = mtp3_para->mtp3lite_port >> 8; + return 2; + default: + return -1; + } + return -1; + case 6:/* internation network routine table */ + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1: + mtp_encode_integer(pdata,mtp3_para->nw[0].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[0].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[0].alternative_ls[instance],1); + memset(&pdata[5], 0 , 4); + encode_integer(&pdata[5],mtp3_para->nw[0].rc[instance]); + return 9; + case 2: + mtp_encode_integer(pdata,mtp3_para->nw[1].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[1].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[1].alternative_ls[instance],1); + memset(&pdata[5], 0 , 4); + encode_integer(&pdata[5],mtp3_para->nw[1].rc[instance]); + return 9; + case 3: + mtp_encode_integer(pdata,mtp3_para->nw[2].dpc[instance], 4); + memcpy(&pdata[3],&mtp3_para->nw[2].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[2].alternative_ls[instance],1); + memset(&pdata[5], 0 , 4); + encode_integer(&pdata[5],mtp3_para->nw[2].rc[instance]); + return 9; + case 4: + mtp_encode_integer(pdata,mtp3_para->nw[3].dpc[instance],4); + memcpy(&pdata[3],&mtp3_para->nw[3].normal_ls[instance],1); + memcpy(&pdata[4],&mtp3_para->nw[3].alternative_ls[instance],1); + memset(&pdata[5], 0 , 4); + encode_integer(&pdata[5],mtp3_para->nw[3].rc[instance]); + return 9; + default: + return -1; + } + return -1; + case 7: + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + if (oid[MTP3_OID_LEN+2] == 1) + { + memcpy(pdata,mtp3_para->localAcn,MAX_ACN_NUM); + } + else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) + { + memcpy(pdata,mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].acn[instance],MAX_ACN_NUM); + } + else + return -1; + return MAX_ACN_NUM; + case 8: + instance = oid[MTP3_OID_LEN+3]; + *vartype = 4; + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* link timer */ + memcpy(pdata,&mtp3_para->lt[instance].t1,10); + return 10; + default: + return -1; + } + return -1; + case 9:/* SG */ + instance = oid[MTP3_OID_LEN+2]; + *vartype = 4; + memcpy(pdata,&mtp3_para->sg[instance],7); + return 7; + default: + return -1; + } + return -1; + } + + else if (oid[MTP3_OID_LEN] == 3)/* status */ + { + *vartype = 4; + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* link status */ + return mtp_encode_integer(pdata,mtp3ObjState.link_l3_state[oid[MTP3_OID_LEN+2]],1); + case 2:/* linkset status */ + instance= oid[MTP3_OID_LEN+2]; + if (instance > 127) + return -1; + if (mtp3.ls[instance].links_available > 0) + pdata[0] = 1; + else + pdata[0] = 0; + return 1; + case 3:/* international network routine */ + return mtp_encode_integer(pdata,mtp3.nw[0].routine[oid[MTP3_OID_LEN+2]],1); + case 4:/* international network spare routine */ + return mtp_encode_integer(pdata,mtp3.nw[1].routine[oid[MTP3_OID_LEN+2]],1); + case 5:/* national network routine */ + return mtp_encode_integer(pdata,mtp3.nw[2].routine[oid[MTP3_OID_LEN+2]],1); + case 6:/* national network spare routine */ + return mtp_encode_integer(pdata,mtp3.nw[3].routine[oid[MTP3_OID_LEN+2]],1); + case 7:/* version */ + memcpy(pdata,mtp3_heartbeat.version,3); + return 3; + default: + return -1; + + } + } + + else if (oid[MTP3_OID_LEN] == 1)/* measurement */ + { + switch (oid[MTP3_OID_LEN+1]) + { + case 1:/* MTP signalling link faults and performance */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+2]; + if (instance > 8) + return -1; + portion_num = oid[MTP3_OID_LEN+3]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + second_to_min(0,portion_num,instance); + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].lk_measure1[instance],36,4); + return 40; + case 2:/* Signalling link availability */ + return -1; + case 3:/* Signalling link set and route set availability */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+2]; + if (instance > 127) + return -1; + portion_num = oid[MTP3_OID_LEN+3]; +/* if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1;*/ + timestamp = mtp3_measure.measure[portion_num].time_stamp; +/* if (timestamp == 0) + return 0;*/ + second_to_min(1,portion_num,instance); + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].ls_measure[instance],32,4); + return 36; + case 5:/* Signalling traffic distribution */ + switch (oid[MTP3_OID_LEN+2]) + { + case 1:/* total traffic */ + *vartype = 4; + instance = oid[MTP3_OID_LEN+3]; + portion_num = oid[MTP3_OID_LEN+4]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; +/* if (instance < 8) + { + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure1[instance-1],80,4); + return 84; + }*/ + else if (instance < 14) + { + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure2[instance-8],80,4); + return 84; + } + else + return -1; + default: + return -1; + } + return -1; + case 6:/* error */ + *vartype = 4; + portion_num = oid[MTP3_OID_LEN+2]; + if ( (portion_num > 95) || + (portion_num == mtp3_csta_p) ) + return -1; + timestamp = mtp3_measure.measure[portion_num].time_stamp; + if (timestamp == 0) + return 0; + mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); + mtp3_data_reverse(&pdata[4],(BYTE*)mtp3_measure.measure[portion_num].tf_measure5,12,4); + return 16; + default: + return -1; + } + } + else + return -1; +} + +void set_led(BYTE nled,BYTE ncolor); +//void set_alarm(BYTE component_id,BYTE alarm_code); +//void set_status(BYTE component_id,BYTE info_len,BYTE *info); + +void set_heartbeat(BYTE reason,BYTE object) +{ + BYTE place; + BYTE temp; + + place = object/4; + temp = (object % 4)*2; + switch (reason) + { + case ALARM_LINK_UNAVAILABLE: + mtp3_heartbeat.link_state[place] &= (~(3<lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno];*/ + + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + tsrc_proc(chl); +/* ls->links_available++;*/ + hmrt_tcbc_update_routing_tables(chl); +} + +void otherMTP3_managed_link_unavailable(BYTE chl) +{ +/* WORD lsno; + ls_info *ls; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno];*/ + + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + tsrc_proc(chl); +/* ls->links_available--;*/ + hmrt_tcoc_update_routing_tables(chl); +// mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; +/*init init_tlac_state*/ + init_tlac_state[chl] = TRUE; + tlac_proc(chl); + + init_lsac_state[chl] = TRUE; + lsac_proc(chl); +} + +int sys_mtp3_table(DWORD ip) +{ + int empty; + int i; + + if (ip==0) + return -1; + + empty = -1; + for (i=0;i= 0) + return empty; + return -1; +} + +void master_MTP3(BYTE link,BYTE masterMTP3,DWORD srcIP) +{ + DWORD NMTP3; + DWORD AMTP3; + + masterMTP3 = masterMTP3 & 1; + + NMTP3 = mtp3_para->lk[link].e1_to_mtp3; + AMTP3 = mtp3_para->lk[link].e1_to_alterMTP3; + + if (srcIP==NMTP3) + { + if (masterMTP3) + mtp3ObjState.lk_NMTP3_ok[link] |= 1; + else + mtp3ObjState.lk_NMTP3_ok[link] &= 0xf0; + } + else if (srcIP==AMTP3) + { + if (masterMTP3) + mtp3ObjState.lk_AMTP3_ok[link] |= 1; + else + mtp3ObjState.lk_AMTP3_ok[link] &= 0xf0; + } +} + +void trap_platform (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + heartbeat_msg *phbmsg = (heartbeat_msg *)msg_ptr; + BYTE *pstatus = phbmsg->info; + heartbeat_compoent_of_mtp3 *phbmtp3 = NULL; + WORD mtp3len=0; + int i,j,pos = 2; //component_id=0:iptrans; + BYTE newHeartbeat=0; + int chl; + BYTE chl_state; + DWORD remote_ip; + int temp; + struct in_addr in; + in.s_addr = addr->remote_ip; + + mtp3_debug(MTP3DB_PFHB,"get platform heartbeat from %s",inet_ntoa(in)); + if (msg_len > 128) + mtp3_showbuf(MTP3DB_PFHB,msg_ptr,128); + else + mtp3_showbuf(MTP3DB_PFHB,msg_ptr,msg_len); + + remote_ip = addr->remote_ip; + + if ((temp=sys_mtp3_table(remote_ip)) >= 0) + { + MTP3IPMng.mtp3_flag_new[temp] = 1; + MTP3IPMng.mtp3_flag_ip[temp] = remote_ip; + } + + if ( remote_ip == mtp3_localip )/* heartbeat from itself */ + return; + + if ((temp=MTP3_LinkIP_List(remote_ip,0))<0) + return; + + if (sizeof(struct heartbeat_msg) >= (INFO_LEN + 18)) + newHeartbeat = 1; + + if (!newHeartbeat) + {//old version heartbeat, length and component_id are one octet + pos = 1; + pos += pstatus[pos]+1; //length of iptrans status + pos++; //component_id=1:MTP3 + + mtp3len = pstatus[pos]; + pos++; //length of mtp3 hb + if (pstatus[pos-1] != 1)//not mtp3 component + return; + } + else + {//new version heartbeat, length and component_id are 2 octets + pos ++; //length is 2 octets + pos += pstatus[pos]+1; //length of iptrans status + pos ++; //component_id=1:mtp3 + pos ++; //component_id is 2 octets + + if (pstatus[pos-1] != 1)//not mtp3 component + return; + + mtp3len = pstatus[pos]*256+pstatus[pos+1]; + pos ++; //length of mtp3 hb + pos ++; //length is 2 octets + } + + phbmtp3 = (heartbeat_compoent_of_mtp3*)&pstatus[pos]; + + if (mtp3len > MTP3_HB_LEN || mtp3len < (MTP3_HB_LEN-34)) + return; + + for (i=0; i<64; i++) + { + temp = phbmtp3->link_state[i]; + for (j=0; j<4; j++) + { + chl = i*4+j; + chl_state = (temp >> (j*2)) & 3; + if ( (mtp3ObjState.lk_mtp3[chl] == remote_ip) && + (mtp3ObjState.link_l3_state[chl] != chl_state) ) + { + if ( mtp3ObjState.lk_configured[chl] != PARA_CONFIGURED ) + { + continue; + } + switch (chl_state) + { + case UNAVAILABLE: + if (mtp3ObjState.link_l3_state[chl] == INHIBITED) + { + mtp3_debug(MTP3DB_EVENT,"link %d L3 state changed from INHIBITED to UNAVAILABLE,invoke by %s",chl,inet_ntoa(in)); + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d L3 out of service,invoke by %s",chl,inet_ntoa(in)); + otherMTP3_managed_link_unavailable(chl); + } + break; + case AVAILABLE: + mtp3_debug(MTP3DB_EVENT,"link %d L3 in service,invoke by %s",chl,inet_ntoa(in)); + otherMTP3_managed_link_available(chl); + break; + case INHIBITED: + mtp3_debug(MTP3DB_EVENT,"link %d L3 inhibited,invoke by %s",chl,inet_ntoa(in)); + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + otherMTP3_managed_link_unavailable(chl); + mtp3ObjState.link_l3_state[chl] = INHIBITED; + break; + default: + break; + } + } + } + } + + if (mtp3len > 100) + { + for (i=0;i<32;i++) + { + for (j=0; j<8; j++) + { + chl = i*8+j; + master_MTP3(chl,(phbmtp3->masterMTP3[i]>>j),remote_ip); + } + } + if (mtp3len > 132) + { + MTP3IPMng.LinkIPSubSta[temp][0] = phbmtp3->SubState[0]; + MTP3IPMng.LinkIPSubSta[temp][1] = phbmtp3->SubState[1]; + } + else + { + MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; + MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; + } + } + else + { + MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; + MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; + } +} + +void trap_mtp2 (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + int i; + mtp2_heartbeat *mtp2; + BYTE offset; + BYTE new_l2_state; + BYTE chl; + BYTE ls; + BYTE module_id; + struct in_addr in; + in.s_addr = addr->remote_ip; + + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get MTP2 heartbeat from %s",inet_ntoa(in)); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,msg_ptr,msg_len); + + mtp2 = (mtp2_heartbeat*)msg_ptr; + module_id = (mtp2->systemid & 1)*16+mtp2->moduleid; + if (module_id > 31) + return; + mtp2_flag_new[module_id] = 1; + offset = module_id << 3; + for ( i=0; i<8; i++ ) + { + chl = offset + i; + mtp3ObjState.link_l1_state[chl] = (mtp2->l1_state >> i) & 1; + new_l2_state = mtp2->l2_state[i];/* e1 l2 state from mtp2 */ + if ( (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) ) + continue; + if ( new_l2_state != mtp3ObjState.link_l2_state[chl] ) + { + ls = mtp3_para->lk[chl].e1_to_linkset; + if (new_l2_state == MTP2_STATE_WORKING)/* link from unavailable->available */ + { + current_measure->lk_measure1[chl][2]++;/* restoration */ + mtp3_debug(MTP3DB_EVENT,"link %d L2 in service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)/* link from available->unavailable */ + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + if ( mtp2->retrieved_bsnt[i] < 128 ) + local_bsnt_retrievable[chl] = TRUE; + else + { +// mtp3_debug(MTP3_DEBUG_LOG,"Link %d BSNT RETRIEVE FAILED",chl); + local_bsnt_retrievable[chl] = FALSE; + } + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + } + } + mtp3ObjState.link_l2_state[chl] = new_l2_state; + if ( (mtp2->e1_dstip[i]+32 != ((mtp3ObjState.lk_mtp3[chl] >> 16) & 0xff)) && + (mtp3ObjState.lk_configured[chl] == PARA_CONFIGURED) ) + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK);/* give this port a correct ip */ + retrieved_bsnt[chl] = mtp2->retrieved_bsnt[i]; + } + + if (mtp2->alarm_code == 3) + { + mtp2_buf_full[mtp2->alarm_component]++; + } +} + +void mtp3_dealtrap(BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) +{ + DWORD mtp2_oid[20] = MTP2_HB_OID; + DWORD platform_oid[20] = PLATFORM_HB_OID; + DWORD omc_oid[20] = MTP3_OMC_OID; + + if (memcmp(&oid_ptr[9],&mtp2_oid[9],16)==0) + { + trap_mtp2 (oid_len,oid_ptr,msg_ptr,msg_len,addr); + } + else if (memcmp(&oid_ptr[9],&platform_oid[9],8)==0) + { + trap_platform(oid_len,oid_ptr,msg_ptr,msg_len,addr); + } + else if (memcmp(oid_ptr,omc_oid,MTP3_OMC_OID_LEN*sizeof(DWORD))==0) + {//omc heartbeat + if ((mtp3_para->MTP3SerialNum==0) ||//support old version, do not have serial number + (Bcd2Ull(&msg_ptr[39],MTP3_SERNUM_LEN)==mtp3_para->MTP3SerialNum) ) + { + switch(msg_ptr[0]) + { + case 0: + mtp3_primomcip = addr->remote_ip; + break; + case 1: + mtp3_secdomcip = addr->remote_ip; + break; + default: + break; + } + } + } +} + +void mtp_snmp_init() +{ + DWORD mib_oid[20] = MTP3_OID; + + snmp_init(4957); + heartbeat_init(0xff); + + inquire_setmsg(MTP3_OID_LEN,mib_oid, mtp_setmib); + inquire_getmsg(MTP3_OID_LEN,mib_oid, mtp_getmib); +// inquire_trapmsg(trapcall trap_mtp2)/* mtp2 heartbeat */ + inquire_trapmsg(mtp3_dealtrap); +// rob_trapmsg(MTP2_HBOID_LEN,mtp2_oid,trap_mtp2); +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpslm.c b/omc/plat/mtp3_old/src/mtpslm.c new file mode 100644 index 0000000..697323d --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpslm.c @@ -0,0 +1,405 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void sltc_proc(BYTE chl) +{ + ls_info *ls; + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + if (mtp3ObjInput.sltc_input[chl] == SLTC_STOP) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjState.sltc_state[chl] = SLTC_IDLE_STATE; + } + + switch (mtp3ObjState.sltc_state[chl]) + { + case SLTC_IDLE_STATE: + if (mtp3ObjInput.sltc_input[chl] == SLTC_START) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + hmrt_sltc_signalling_link_test_msg(chl); + sltc_t1_delay[chl] = 4; + mtp3ObjState.sltc_state[chl] = SLTC_FIRST_TRY_STATE; + } + break; + + case SLTC_FIRST_TRY_STATE: + sltc_t1_delay[chl] --; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + sltc_t1_delay[chl] = 4; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_SECOND_TRY_STATE; + } + break; + + case SLTC_SECOND_TRY_STATE: + sltc_t1_delay[chl]--; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + sltc_t1_delay[chl] = 4; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_THIRD_TRY_STATE; + } + break; + + case SLTC_THIRD_TRY_STATE: + sltc_t1_delay[chl]--; + if ( mtp3ObjInput.sltc_input[chl] == SLTA_MSG ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_SUCCESSFUL; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + sltc_t2_delay[chl] = 30; + } + else if ( sltc_t1_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + mtp3ObjInput.lsac_input_from_sltc[chl] = LSAC_SLTC_SLT_FAILED; + mtp3ObjState.sltc_state[chl] = SLTC_IDLE_STATE; + } + break; + + case SLTC_RUNNING_STATE: + sltc_t2_delay[chl] --; + if ( sltc_t2_delay[chl] == 0 ) + { + mtp3ObjInput.sltc_input[chl] = IDLE; + hmrt_sltc_signalling_link_test_msg(chl); + mtp3ObjState.sltc_state[chl] = SLTC_FIRST_TRY_STATE; + sltc_t1_delay[chl] = 4; + } + break; + + default: + break; + } +} + +int link_auc(BYTE chl) +{ + BYTE linkset; + + linkset = mtp3_para->lk[chl].e1_to_linkset; + if ( (mtp3ObjState.lk_configured[chl] != PARA_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) ) + return 3; + if (mtp3ObjState.link_l1_state[chl] != 1) + return 2; + if (mtp3.ls[linkset].links_available == 0) + return 1; + else + return 0; + +/* return value: + * 0=linkset not only one link available + * 1=linkset only one link available + * 2=send command to enable this link + * 3=no need to send command to this link */ +} + +void lsac_proc(BYTE chl) +{ + int aucResult; + static BYTE timer[256]; + + if (init_lsac_state[chl] == TRUE) + { + init_lsac_state[chl] = IDLE; + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + return; + } + + switch (mtp3ObjState.lsac_state[chl]) + { + case LSAC_INACTIVE_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + if (timer[chl]++>50) + { + timer[chl] = 0; + aucResult = link_auc(chl); + switch (aucResult) + { + case 0: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d normal alignment",chl); +// printf("chl %d normal alignment\n",chl); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + timer[chl] = 0; + break; + case 1: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_EMERGEN_ALIGNMENT); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d emergent alignment",chl); +// printf("chl %d emergent alignment\n",chl); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + timer[chl] = 0; + break; + case 2: + if (MTP3_LINK_TYPE(chl) != LKTYPE_MTP3_LITE)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + break; + default: + break; + } + } + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + break; + + case LSAC_RESTORING_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + if ( (mtp3ObjState.sltc_state[chl] == SLTC_IDLE_STATE) && + (timer[chl]++>60)) // change timer 8s to 9.6s + { + timer[chl] = 0; + aucResult = link_auc(chl); + switch (aucResult) + { + case 0: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + break; + case 1: + if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN)//m2ua link + send_command_to_mtp2(chl,MTP3_M2UA_ENABLE); + send_command_to_mtp2(chl,MTP2_EMERGEN_ALIGNMENT); + break; + default: + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + } + } + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + send_command_to_mtp2(chl,MTP2_DEACTIVE_LINK); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d L2 in service,start testing procedure",chl); + mtp3ObjInput.sltc_input[chl] = SLTC_START; + sltc_proc(chl);/* start to send sltm */ + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_sltc[chl]) + { + case LSAC_SLTC_SLT_SUCCESSFUL: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_LINK_IN_SERVICE; + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d complete test procedure,test pass",chl); + break; + + case LSAC_SLTC_SLT_FAILED: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjState.link_l2_state[chl] = UNAVAILABLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d complete test procedure,test failed",chl); + break; + + default: + break; + } + break; + + case LSAC_ACTIVE_STATE: + switch (mtp3ObjInput.lsac_input_from_mgmt[chl]) + { + case LSAC_MGMT_ACTIVATE_LINK: + break; + + case LSAC_MGMT_DEACTIVATE_LINK: + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_WAIT_STATE; +// mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_l2[chl]) + { + case LSAC_L2_IN_SERVICE: + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + break; + + case LSAC_L2_OUT_OF_SERVICE: + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d failed",chl); +// printf("lsac link %d failed\n",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = IDLE; + if (link_inhibited[chl] != TRUE) + { + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + case LSAC_L2_REMOTE_PROCESSOR_RECOV: + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_sltc[chl]) + { + case LSAC_SLTC_SLT_SUCCESSFUL: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + break; + + case LSAC_SLTC_SLT_FAILED: + mtp3ObjInput.lsac_input_from_sltc[chl] = IDLE; + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_debug(MTP3DB_EVENT,"[lsac]link %d test failed during active state",chl); + mtp3ObjState.link_l2_state[chl] = UNAVAILABLE; + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_TEST_FAILED); + if (link_inhibited[chl] != TRUE) + { + mtp3ObjInput.tlac_input_from_slm[chl] = TLAC_LSAC_SIGLINK_FAILED; + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_tcoc[chl]) + { + case LSAC_TCOC_STM_READY: + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + break; + + case LSAC_TCOC_STOP_L2: + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_CHANGE_OVER); + if (link_inhibited[chl] != TRUE) + { + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.lsac_input_from_stm[chl]) + { + case LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED: + mtp3ObjInput.lsac_input_from_stm[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_CHANGE_OVER); + mtp3_debug(MTP3DB_EVENT,"[lsac]receive coo"); +// printf("lsac receive coo\n"); + mtp3ObjState.lsac_state[chl] = LSAC_FAILED_STATE; + break; + + default: + break; + } + break; + + case LSAC_WAIT_STATE: + if ( mtp3ObjInput.lsac_input_from_tcoc[chl] == LSAC_TCOC_STM_READY) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + send_command_to_mtp2(chl,MTP2_STOP_L2); + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,MTP3ALARM_LINK_MGMT_REQUEST); + mtp3ObjState.lsac_state[chl] = LSAC_INACTIVE_STATE; + } + break; + + case LSAC_FAILED_STATE: + if (mtp3ObjInput.lsac_input_from_stm[chl] != IDLE) + { + mtp3ObjInput.lsac_input_from_stm[chl] = IDLE; + } + if ( mtp3ObjInput.lsac_input_from_tcoc[chl] == LSAC_TCOC_STM_READY ) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = IDLE; + changeover_in_progress[chl] = FALSE; + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + send_command_to_mtp2(chl,MTP2_ACTIVE_LINK); + mtp3ObjState.lsac_state[chl] = LSAC_RESTORING_STATE; + } + break; + + default: + break; + } +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpsmh.c b/omc/plat/mtp3_old/src/mtpsmh.c new file mode 100644 index 0000000..e1449e8 --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpsmh.c @@ -0,0 +1,4260 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" +#include "./include/mtp3lite.h" +#include "../../public/src/include/pub_netcap.h" + +/*@ignore@*/ +extern int mtp3_send_netcap; +#ifndef _M3UA_ +#define _M3UA_ +#endif +iprt1 mtp3_iprt; +#ifdef _INCLUDE_M2UA + static m2ua_up_msg_t *mtp3_m2ua_msg; +#endif +#ifdef _M3UA_ + static xua_up_msg_t *mtp3_m3ua_msg; +#endif +extern tup_shm *T_shm_ptr; +extern isup_shm *I_shm_ptr; +extern bicc_shm *B_shm_ptr; +extern sccp_shm *S_shm_ptr; +DWORD msgSourceIP; +extern primitive_to_isup *I_primitive; +extern primitive_to_bicc *B_primitive; +extern primitive_to_sccp *S_primitive; +extern primitive_to_tup *T_primitive; +extern mtp3_routing_result routingResult; +extern void mtp3_debug(int n,const char *fmt,...); +extern BYTE mtp3_check_dpc_equal_to_opc(BYTE nw, DWORD dpc); + +void tsrc_fun5(BYTE linkset); +void stop_mtp3T21(BYTE linkset); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); +void send_to_host_mtp3(BYTE *msgptr,DWORD dst_ip); +int MTP3_LinkIP_List(DWORD IP,BYTE mode); +void sp_unaccessable(BYTE *routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +BYTE get_route_value(u32 dpc, u8 nw); +int send_route_to_other_plat(u32 dpc, BYTE nw, BYTE routine, long dest_ip, BYTE chl); +int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, BYTE chl); + + +void primitive_to_userpart(BYTE nw,long dst,BYTE state) +{ + BYTE I_WSub; + BYTE B_WSub; + BYTE S_WSub; + BYTE T_WSub; + mtp_primitive *I_ptr; + mtp_primitive *B_ptr; + mtp_primitive *S_ptr; + mtp_primitive *T_ptr; + + I_WSub = I_primitive->WSub; + B_WSub = B_primitive->WSub; + S_WSub = S_primitive->WSub; + T_WSub = T_primitive->WSub; + I_ptr = &I_primitive->primitive[I_WSub]; + B_ptr = &B_primitive->primitive[I_WSub]; + S_ptr = &S_primitive->primitive[I_WSub]; + T_ptr = &T_primitive->primitive[I_WSub]; + + I_ptr->pc = dst; + I_ptr->nw_indicator = nw; + I_ptr->availability = state; + + B_ptr->pc = dst; + B_ptr->nw_indicator = nw; + B_ptr->availability = state; + + S_ptr->pc = dst; + S_ptr->nw_indicator = nw; + S_ptr->availability = state; + + T_ptr->pc = dst; + T_ptr->nw_indicator = nw; + T_ptr->availability = state; + + I_primitive->WSub = (I_WSub + 1) & 0x0f; + B_primitive->WSub = (I_WSub + 1) & 0x0f; + S_primitive->WSub = (S_WSub + 1) & 0x0f; + T_primitive->WSub = (T_WSub + 1) & 0x0f; +} + +BYTE *spc_to_acn(BYTE netID,DWORD spc) +{ + nw_para *nw; + DWORD index; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[netID]; + + netID = netID % 4; + nw = &mtp3_para->nw[netID]; + + if (pc_length(netID) == MTP3_24BIT_PC) + { + if (nw->opc24 == spc) + return mtp3_para->localAcn; + } + else + { + if (nw->opc14 == spc) + return mtp3_para->localAcn; + } + + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,netID,spc); + if (index>=0 && index<256) + return nw->acn[sort_rec->index[index]]; + return NULL; +} + +BYTE mtp3_ansiFlag(BYTE netID) +{ + netID = netID & 3; + return (mtp3_para->nw_pro >> (netID+4)) & 1; +} + +int search_outbound_coLink(BYTE chl)/* find outbound changeover link */ +{ + ls_info *ls; + int i; + int lsx16; + WORD adsp_place; + BYTE nw; + int outls; + int outlink; + int lsno; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + if (ls->links_available > 0) + { + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; +/* if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (outlink != chl) && + (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) )*/ + if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (outlink != chl) ) + { + return ls_slc[lsx16+i]; + } + } + return -1; + } + else + { + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return -1; + if ( ((mtp3.nw[nw].routine[adsp_place] >> 2) & 3) == 0)/* alternative route available */ + { + outls = mtp3_para->nw[nw].alternative_ls[adsp_place]; + lsx16 = outls << 4; + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; +/* if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) && + (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) )*/ + if ( (mtp3ObjState.link_l3_state[outlink] == AVAILABLE) ) + { + mtp3_debug(MTP3DB_EVENT,"outlink is %d",outlink); + return outlink; + } + } + return -1; + } + } + return -1; +} + +int pc_length(BYTE nw) +{ + if (((mtp3_para->nw_pro >> nw) & 1) == 1) + return MTP3_24BIT_PC; + else + return MTP3_14BIT_PC; +} + +void send_to_mtp2(long dest_ip) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; +// iptrPutMessage(mtp3_iprt.io_msg); + {//delete one byte of len +// BYTE tmp[300]; + mtp3_iprt.io_msg.msgLength = mtp3_iprt.io_msg.msgContent[2]+2; + memcpy(&mtp3_iprt.io_msg.msgContent[1], &mtp3_iprt.io_msg.msgContent[2], mtp3_iprt.io_msg.msgContent[2]+1); +// tmp[0] = mtp3_iprt.io_msg.msgContent[0]; +// memcpy(&mtp3_iprt.io_msg.msgContent[0], tmp, tmp[1]+2); + } + iptrDirectSendMsg(mtp3_iprt.io_msg); +} + +void send_to_mtp2_new_struct(long dest_ip)//link,len_high,len_low,sio... +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + if(mtp3_iprt.io_msg.msgLength >300) + { + mtp3_debug(MTP3DB_ERROR,"Send message in SS7 port 4950, length longer than 300, len=%d!", mtp3_iprt.io_msg.msgLength); + return; + } + iptrDirectSendMsg(mtp3_iprt.io_msg); +} +#ifndef _M3UA_ +void send_mtp_msg(int outlink, BYTE *msgptr) +{ + int linkset; + ls_info *ls; + int ls_pro; + BYTE nw; + DWORD dst_ip; + long opc; + long route_mark; + BYTE sls; + BYTE pclen; + WORD len; + BYTE ssf; + BYTE debugtype=0; + + if(msgptr == NULL) + { + return; + } + ssf = msgptr[3] & 0x0f; + linkset = mtp3_para->lk[outlink].e1_to_linkset; + ls = &mtp3.ls[linkset]; + ls_pro = mtp3_para->ls_pro[linkset]; + nw = ls_pro & 3; + pclen = pc_length(nw); + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + if ( pclen == MTP3_24BIT_PC ) + { + opc = mtp3_para->nw[nw].opc24; + memcpy( &msgptr[3],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[3],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(opc << 14)+opc; + memcpy(&msgptr[3],&route_mark,4); + } + } + + if (ssf > 1) + { + ssf--; + debugtype = MTP_MSG_DOWN; + } + else + debugtype = MTP_SNM_MSG; +// current_measure->tf_measure1[4][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[4][wx5[nw]+ssf]++;/* MSUs */ + +// len = msgptr[1]+2; + len = (msgptr[1]<<8) + msgptr[2]+3; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"send_mtp_msg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + mtp3_iprt.io_msg.msgLength = len; + + if( mtp3_send_netcap && ( ( msgptr[3] & 0xF0) != 0xF0 ) ) + { + int pclen; + BYTE sio; + BYTE nw; + + sio = msgptr[3]; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 0 ); + } + } + +#if _INCLUDE_M2UA + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + {//transfer to remote plat + dst_ip = mtp3ObjState.lk_mtp3[outlink]; + //dst_ip = (dst_ip << 16) | E1CARD_BASE_IP; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ +// send_to_mtp2(dst_ip); + send_to_mtp2_new_struct(dst_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) +#endif + { + dst_ip = LINK_TO_IP(outlink); + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + send_to_mtp2(dst_ip);//use old struct send to 8k bload + } +#if _INCLUDE_M2UA + else + { + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + /* debug show message */ + dst_ip = mtp3_para->lk[outlink].remote_ip; + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + return; + } + else + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return; + } + } +#endif + + +} +#endif +int check_snmmsg_route(BYTE ls) +{ + WORD sp_place; + BYTE nw; + BYTE routine; + BYTE outbound_ls=128; + int outlink=256; + int lsx16; + int i; + + if (mtp3.ls[ls].links_available_t > 0) + { + outbound_ls = ls; + } + else + { + sp_place = mtp3.ls[ls].adjacent_sp_place; + if (sp_place > 255) + return -1; + nw = mtp3_para->ls_pro[ls] & 3; + routine = mtp3.nw[nw].routine[sp_place]; + if ( (routine & 3) == NLS_AVAILABLE ) + outbound_ls = mtp3_para->nw[nw].normal_ls[sp_place]; + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE ) + outbound_ls = mtp3_para->nw[nw].alternative_ls[sp_place]; + else + { +// mtp3_debug(MTP3DB_ERROR,"ls %d Can't find Outbound LS TO LS-Remote PC when SNM\n\r",ls); + return -1; + } + } + lsx16 = outbound_ls << 4; + for (i=0; i<16; i++) + { + outlink = ls_slc[lsx16+i]; + if ( mtp3ObjState.link_l3_state[outlink] == AVAILABLE ) + { + return outlink; + } + else if (mtp3ObjState.link_l2_state[outlink] == MTP2_STATE_WORKING) + { + if (changeback_in_progress[outlink] == TRUE) + { + return outlink; + } + } + } + return -1; +} + +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + int outlink; + + if (linkset > 127) + return; + if (dst == mtp3_para->ls_op_pc[linkset]) + return; + outlink = check_snmmsg_route(linkset); + if (outlink == -1) + return; + ls = &mtp3.ls[linkset]; + nw = (mtp3_para->ls_pro[linkset]) & 3; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 12; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + sd_tmp_buf[10] = 0; + sd_tmp_buf[11] = MsgType; + memcpy(&sd_tmp_buf[12],&dst,3); + } + else + { + route_mark = (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[linkset]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 8; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = MsgType; + memcpy(&sd_tmp_buf[9],&dst,2); + } + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); +} + +BYTE priority_own_link(WORD lsno,BYTE sls) +{ + ls_info *ls; + int i; + BYTE link; + + if (lsno >= MAX_LS_NUM) + return -1; + + ls = &mtp3.ls[lsno]; + for (i=0;ilk[link].e1_to_mtp3 == mtp3_localip) + return link; + } + return ls_sls[(lsno<<4)+(sls & 15)]; +} + +int check_outbound_route(BYTE nw, long dpc, BYTE sls) +{ + network *sp; + BYTE outroute; + WORD ls; + BYTE i; + BYTE routine; + WORD nls; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + BYTE outlink; + + if (dpc==0) + return -3; + + sp = &mtp3.nw[nw]; + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,dpc); + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return -3; + + routine = sp->routine[i]; + outroute = (routine >> 6) & 3; + if ( outroute == 2 )/* no outbound route */ + { + nls = mtp3_para->nw[nw].normal_ls[i]; + if (mtp3.ls[nls].linksNum_configured > 0) +// if (linknum_in_ls[nls] > 0) + return -1; + else + return -2; + } + else if ( (outroute == 0) && + ((routine & 3) == NLS_AVAILABLE) )/* current route is normal route */ + { + ls = mtp3_para->nw[nw].normal_ls[i]; + outlink = ls_sls[(ls<<4)+sls]; + if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip) + return outlink; + else + return priority_own_link(ls,sls); + } + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE) + { + ls = mtp3_para->nw[nw].alternative_ls[i]; + outlink = ls_sls[(ls<<4)+sls]; + if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip) + return outlink; + else + return priority_own_link(ls,sls); + } + return -3; +} + +/* pc_length:point code type + * ss7 network has two kind of point code,one is 14bits length, + * another is 24bits length */ + +int send_to_sccp(BYTE *msgptr)/* send sccp msg to tele user part */ +{ + up_message *ToSccp; + WORD len; + long route_mark;/* route mark */ + BYTE pclen; + BYTE nw; + BYTE sio; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + link = msgptr[0]; + ToSccp->link = link; + ToSccp->dest_ip = msgSourceIP; + + pclen = pc_length(nw); + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 9)//len < 9 + { + mtp3ObjState.MTP3WatchDog[3]++; + mtp3.nw[nw].flow.MtoU_throwed[0]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE *)&ToSccp->dpc,msgptr+4,3);/* message's dpc */ + memcpy((BYTE *)&ToSccp->opc,&msgptr[7],3);/* message's opc */ + ToSccp->sio = sio; + ToSccp->cic[0] = msgptr[10]; + len = (msgptr[1]<<8) + msgptr[2]-8; + ToSccp->len = len; + memcpy(&ToSccp->msgList,&msgptr[11],len); + } + else + { + if (msgptr[1] == 0 && msgptr[2] < 6) + { + mtp3ObjState.MTP3WatchDog[4]++; + mtp3.nw[nw].flow.MtoU_throwed[0]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToSccp->cic[0] = route_mark >> 28; + ToSccp->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToSccp->dpc = (route_mark & 0x3FFF); + ToSccp->sio = sio; + len = (msgptr[1]<<8) + msgptr[2] -5; + ToSccp->len = len; + memcpy(&ToSccp->msgList,&msgptr[8],len); + } + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + return 1; +} + +int send_to_sccp_lite(up_message *msgptr)/* send sccp-lite msg to sccp */ +{ + up_message *ToSccp; + BYTE nw; + + nw = msgptr->sio >> 6; + + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + memcpy((BYTE *)ToSccp, (BYTE *)msgptr, sizeof(up_message)); + + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + + return 1; +} + +int send_to_tup(BYTE *msgptr)/* send tup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message *ToTup; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + link = msgptr[0]; + pclen = pc_length(nw); + ToTup = &T_shm_ptr->MT_Buf.msgNum[T_shm_ptr->MT_Buf.WSub]; + ToTup->link = link; + ToTup->dest_ip = msgSourceIP; + + if (pclen == MTP3_24BIT_PC)/* for 24bits network */ + { + if (msgptr[1] == 0 && msgptr[2] < 10) + { + mtp3ObjState.MTP3WatchDog[5]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + ToTup->sio = sio; + memcpy((BYTE*)&ToTup->dpc,&msgptr[4],3);/* message's dpc */ + memcpy((BYTE*)&ToTup->opc,&msgptr[7],3);/* message's opc */ + ToTup->cic[0] = msgptr[10]; + ToTup->cic[1] = msgptr[11]; + len = (msgptr[1]<<8) + msgptr[2] -9; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr[12],len); + } + else/* for 14bits network */ + { + if (msgptr[1] == 0 && msgptr[2] < 7) + { + mtp3ObjState.MTP3WatchDog[6]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToTup->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToTup->dpc = (route_mark & 0x3FFF); + ToTup->cic[0] = (msgptr[7] >> 4) + ((msgptr[8] & 0x0f) << 4); + ToTup->cic[1] = (msgptr[8] >> 4); + ToTup->sio = sio; + len = (msgptr[1]<<8) + msgptr[2] - 6; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr[9],len); + } + T_shm_ptr->MT_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[3]++; + return 1; +} + +void MTP3_recv_isup_count(BYTE nw,BYTE type) +{ + switch (type) + { + case MTP3_ISUP_IAM: + mtp3.nw[nw].flow.isup_detail[0]++; + break; + case MTP3_ISUP_ACM: + mtp3.nw[nw].flow.isup_detail[1]++; + break; + case MTP3_ISUP_CPG: + mtp3.nw[nw].flow.isup_detail[2]++; + break; + case MTP3_ISUP_ANM: + mtp3.nw[nw].flow.isup_detail[3]++; + break; + case MTP3_ISUP_REL: + mtp3.nw[nw].flow.isup_detail[4]++; + break; + case MTP3_ISUP_RLC: + mtp3.nw[nw].flow.isup_detail[5]++; + break; + default: + break; + } +} + +int send_to_isup(BYTE *msgptr)/* send isup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message *ToIsup; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToIsup = &I_shm_ptr->MI_Buf.msgNum[I_shm_ptr->MI_Buf.WSub]; + pclen = pc_length(nw); + link = msgptr[0]; + ToIsup->link = link; + ToIsup->dest_ip = msgSourceIP; + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 11) + { + mtp3ObjState.MTP3WatchDog[7]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&ToIsup->dpc,&msgptr[4],3); + memcpy((BYTE*)&ToIsup->opc,&msgptr[7],3); + ToIsup->sio = sio; + ToIsup->cic[0] = msgptr[11]; + ToIsup->cic[1] = msgptr[12]; + len = (msgptr[1]<<8) + msgptr[2] -10; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr[13],len); + MTP3_recv_isup_count(nw,msgptr[13]); + } + else/* for 14bit ss7 network */ + { + if (msgptr[1] == 0 && msgptr[2] < 8) + { + mtp3ObjState.MTP3WatchDog[8]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); + return 0; + } + + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToIsup->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToIsup->dpc = (route_mark & 0x3FFF); + ToIsup->sio = sio; + ToIsup->cic[0] = msgptr[8]; + ToIsup->cic[1] = msgptr[9]; + len = (msgptr[1]<<8) + msgptr[2] -7; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr[10],len); + MTP3_recv_isup_count(nw,msgptr[10]); + } + I_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int send_to_bicc(BYTE *msgptr)/* send isup msg to tele user part */ +{ + BYTE sio; + WORD len; + up_message_2 *ToBicc; + long route_mark; + BYTE pclen; + BYTE nw; + BYTE link; + + sio = msgptr[3]; + nw = sio >> 6; + sio = sio | (mtp3_ansiFlag(nw) << 4); + ToBicc = &B_shm_ptr->MI_Buf.msgNum[B_shm_ptr->MI_Buf.WSub]; + pclen = pc_length(nw); + link = msgptr[0]; + ToBicc->link = link; + ToBicc->dest_ip = msgSourceIP; + if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ + { + memcpy((BYTE*)&ToBicc->dpc,&msgptr[4],3); + memcpy((BYTE*)&ToBicc->opc,&msgptr[7],3); + ToBicc->sio = sio; + ToBicc->cic[0] = msgptr[11]; + ToBicc->cic[1] = msgptr[12]; + ToBicc->cic[2] = msgptr[13]; + ToBicc->cic[3] = msgptr[14]; + len = (msgptr[1]<<8) + msgptr[2] -12; + ToBicc->len = len; + memcpy(&ToBicc->msgList,&msgptr[15],len); + } + else/* for 14bit ss7 network */ + { + memcpy((BYTE*)&route_mark,&msgptr[4],4);/* include message's dpc,opc,sls */ + ToBicc->opc = (route_mark & 0x0FFFFFFF) >> 14; + ToBicc->dpc = (route_mark & 0x3FFF); + ToBicc->sio = sio; + ToBicc->cic[0] = msgptr[8]; + ToBicc->cic[1] = msgptr[9]; + ToBicc->cic[2] = msgptr[10]; + ToBicc->cic[3] = msgptr[11]; + len = (msgptr[1]<<8) + msgptr[2] -9; + ToBicc->len = len; + memcpy(&ToBicc->msgList,&msgptr[12],len); + } + B_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int get_sccp(up_message *GetSccp) +{ + WORD len; + BYTE sio; + long route_mark;/* dpc opc sls */ + BYTE sls; + long dpc; + BYTE pclen; + int outlink=0; + long dest_ip; + BYTE *msgptr; + BYTE nw; + BYTE rSub; + + rSub = S_shm_ptr->SM_Buf.RSub; + if (rSub != S_shm_ptr->SM_Buf.WSub) + { + GetSccp = &S_shm_ptr->SM_Buf.msgNum[rSub]; + sio = GetSccp->sio & 0xcf; + dpc = GetSccp->dpc; + sls = GetSccp->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetSccp->len; + + dest_ip = GetSccp->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.sccpMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"USER==>MTP3,sio=%x,dpc=%lx",GetSccp->sio,GetSccp->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetSccp->msgList,GetSccp->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + } + else{ + outlink = GetSccp->link; + } + + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + len = GetSccp->len; + if (pclen == MTP3_24BIT_PC) + { + mtp3_iprt.io_msg.msgLength = len + 10+1; + msgptr[0] = outlink; + msgptr[1] = (len+8)>>8; + msgptr[2] = (len+8) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + + memcpy(&msgptr[10],&GetSccp->cic[0],1); + memcpy(&msgptr[11],&GetSccp->msgList,len); + } + else + { + route_mark = (GetSccp->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + msgptr[0] = outlink; + msgptr[1] = (len+5)>>8; + msgptr[2] = (len+5) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetSccp->msgList,len); + } + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[10]++; + mtp3_debug(MTP3DB_ERROR,"[SCCP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len + 3); + S_shm_ptr->SM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[2]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[2]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len + 3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + +/* in.s_addr = dest_ip; + mtp3_debug(MTP3DB_SCCPMSG,"USER==>MTP3,sio=%x,dpc=%lx",GetSccp->sio,GetSccp->dpc); + mtp3_debug(MTP3DB_SCCPMSG,"perform routing:%dBIT LI=%x LINK=%x IP=%s",pclen,sio,sls,inet_ntoa(in)); + userpart_msg_flow(msgptr);*/ + + } + S_shm_ptr->SM_Buf.RSub ++; + } + return 1; +} + +int get_tup(up_message *GetTup) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = T_shm_ptr->TM_Buf.RSub; + if (rSub != T_shm_ptr->TM_Buf.WSub) + { + + GetTup = &T_shm_ptr->TM_Buf.msgNum[rSub]; + sio = GetTup->sio & 0xcf; + dpc = GetTup->dpc; + sls = GetTup->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetTup->len; + + dest_ip = GetTup->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.tupMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetTup->sio,GetTup->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetTup->msgList,GetTup->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + T_shm_ptr->TM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[3]++; + return 0; + } + } + else + outlink = GetTup->link; + + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len+9)>>8; + msgptr[2] = (len+9) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + //memcpy(&msgptr[6],&mtp3_para->nw[nw].opc24,3); + + if (dest_ip == 0xffffffff) + { + if (GetTup->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetTup->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetTup->opc,3);//keep the UP filled opc + + memcpy(&msgptr[10],&GetTup->cic[0],2); + memcpy(&msgptr[12],&GetTup->msgList,len); + } + else + { + //route_mark = (GetTup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + + if (dest_ip == 0xffffffff) + { + if (GetTup->opc == 0) + route_mark = (GetTup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetTup->cic[0] << 28)+(GetTup->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetTup->cic[0] << 28)+(GetTup->opc << 14)+dpc;//keep the UP filled opc + + msgptr[0] = outlink; + msgptr[1] = (GetTup->len+6)>>8; + msgptr[2] = (GetTup->len+6) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + msgptr[8] = (GetTup->cic[0] >> 4) + (GetTup->cic[1] << 4); + memcpy(&msgptr[9],&GetTup->msgList,len); + } + + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[12]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len+3); + T_shm_ptr->TM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[3]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[3]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + T_shm_ptr->TM_Buf.RSub ++; + } + return 1; +} + +void MTP3_send_isup_count(BYTE nw,BYTE type) +{ + switch (type) + { + case MTP3_ISUP_IAM: + mtp3.nw[nw].flow.isup_detail[16]++; + break; + case MTP3_ISUP_ACM: + mtp3.nw[nw].flow.isup_detail[17]++; + break; + case MTP3_ISUP_CPG: + mtp3.nw[nw].flow.isup_detail[18]++; + break; + case MTP3_ISUP_ANM: + mtp3.nw[nw].flow.isup_detail[19]++; + break; + case MTP3_ISUP_REL: + mtp3.nw[nw].flow.isup_detail[20]++; + break; + case MTP3_ISUP_RLC: + mtp3.nw[nw].flow.isup_detail[21]++; + break; + default: + break; + } +} + +int get_isup(up_message *GetIsup) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = I_shm_ptr->IM_Buf.RSub; + if (rSub != I_shm_ptr->IM_Buf.WSub) + { + + GetIsup = &I_shm_ptr->IM_Buf.msgNum[rSub]; + sio = GetIsup->sio & 0xcf; + dpc = GetIsup->dpc; + sls = GetIsup->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetIsup->len; + + dest_ip = GetIsup->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.isupMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetIsup->sio,GetIsup->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetIsup->msgList,GetIsup->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + } + else + outlink = GetIsup->link; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len + 10)/0xff; + msgptr[2] = (len + 10)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + if (dest_ip == 0xffffffff) + { + if (GetIsup->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetIsup->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetIsup->opc,3);//keep the UP filled opc + + msgptr[10] = GetIsup->cic[0] & 0x0f; + memcpy(&msgptr[11],&GetIsup->cic[0],2); + memcpy(&msgptr[13],&GetIsup->msgList,len); + MTP3_send_isup_count(nw,msgptr[13]); + } + else + { + if (dest_ip == 0xffffffff) + { + if (GetIsup->opc == 0) + route_mark = (GetIsup->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetIsup->cic[0] << 28)+(GetIsup->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetIsup->cic[0] << 28)+(GetIsup->opc << 14)+dpc;//keep the UP filled opc + msgptr[0] = outlink; + msgptr[1] = (len+7)/0xff; + msgptr[2] = (len+7)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetIsup->cic,2); + memcpy(&msgptr[10],&GetIsup->msgList,len); + MTP3_send_isup_count(nw,msgptr[10]); + } + + len = (msgptr[1]<<8) | msgptr[2]; +// if ((msgptr[1] < 5) || (msgptr[1] > 0xfd)) + if ((len < 5) || (len > 272)) + { + mtp3ObjState.MTP3WatchDog[14]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]USER==>MTP3,LI over range and discarded! LI=%04d,Link=%d",len,outlink); + mtp3_showbuf(MTP3DB_ERROR,&msgptr[0],len+3); + I_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + + mtp3.nw[nw].flow.MtoI[4]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = len+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + I_shm_ptr->IM_Buf.RSub ++; + } + return 1; +} + +int get_bicc(up_message_2 *GetBicc) +{ + int outlink=0; + WORD len; + BYTE sio; + long route_mark; + long dpc; + BYTE sls; + BYTE pclen; + BYTE *msgptr; + BYTE nw; + DWORD dest_ip; + BYTE rSub; + + rSub = B_shm_ptr->IM_Buf.RSub; + if (rSub != B_shm_ptr->IM_Buf.WSub) + { + GetBicc = &B_shm_ptr->IM_Buf.msgNum[rSub]; + sio = GetBicc->sio; + dpc = GetBicc->dpc; + sls = GetBicc->cic[0] & 0x0f; + nw = (sio >> 6) & 3; + pclen = pc_length(nw); + len = GetBicc->len; + + dest_ip = GetBicc->dest_ip; + if (dest_ip == 0xffffffff) + { + outlink = routingResult.biccMsgOutLink[rSub]; +// outlink = check_outbound_route(nw,dpc,sls); + if ( outlink < 0 ) + { + mtp3_debug(MTP3DB_ERROR,"receive message from UP,sio=%x,dpc=%lx",GetBicc->sio,GetBicc->dpc); + mtp3_showbuf(MTP3DB_ERROR,GetBicc->msgList,GetBicc->len); + mtp3_debug(MTP3DB_ERROR,"perform routing:Route Failure,Reason:program bug"); + B_shm_ptr->IM_Buf.RSub ++; + mtp3.nw[nw].flow.MtoI_throwed[4]++; + return 0; + } + } + else + outlink = GetBicc->link; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if (pclen == MTP3_24BIT_PC) + { + msgptr[0] = outlink; + msgptr[1] = (len + 12)/0xff; + msgptr[2] = (len + 12)&0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&dpc,3); + + //memcpy(&msgptr[6],&mtp3_para->nw[nw].opc24,3); + + if (dest_ip == 0xffffffff) + { + if (GetBicc->opc == 0) + memcpy(&msgptr[7],&mtp3_para->nw[nw].opc24,3); + else + memcpy(&msgptr[7],&GetBicc->opc,3);//keep the UP filled opc + } + else + memcpy(&msgptr[7],&GetBicc->opc,3);//keep the UP filled opc + + msgptr[10] = GetBicc->cic[0] & 0x0f; + memcpy(&msgptr[11],&GetBicc->cic[0],4); + memcpy(&msgptr[15],&GetBicc->msgList,len); + } + else + { + //route_mark = (GetBicc->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + + if (dest_ip == 0xffffffff) + { + if (GetBicc->opc == 0) + route_mark = (GetBicc->cic[0] << 28)+(mtp3_para->nw[nw].opc14 << 14)+dpc; + else + route_mark = (GetBicc->cic[0] << 28)+(GetBicc->opc << 14)+dpc;//keep the UP filled opc + } + else + route_mark = (GetBicc->cic[0] << 28)+(GetBicc->opc << 14)+dpc;//keep the UP filled opc + + msgptr[0] = outlink; + msgptr[1] = (len + 9) / 0xff; + msgptr[2] = (len+9) & 0xff; + msgptr[3] = sio; + memcpy(&msgptr[4],&route_mark,4); + memcpy(&msgptr[8],&GetBicc->cic,4); + memcpy(&msgptr[12],&GetBicc->msgList,len); + } + mtp3.nw[nw].flow.MtoI[4]++; + if (dest_ip == 0xffffffff) + { + send_mtp_msg(outlink,msgptr); + } + else + { + mtp3_iprt.io_msg.msgLength = (msgptr[1]<<8) + msgptr[2]+3; + if (iptrans_msg_flow(msgptr,pclen,MTP_MSG_OTHER_SERVER,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + B_shm_ptr->IM_Buf.RSub ++; + } + return 1; +} + +int find_dst_place(long dst,BYTE lsno) +{ + BYTE i; + BYTE nw; + BYTE dpc_place; + ls_info *ls; + + if (lsno > 127) + return -1; + + ls = &mtp3.ls[lsno]; + nw = (mtp3_para->ls_pro[lsno]) & 3; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asNLS[i]; + if ( mtp3_para->nw[nw].dpc[dpc_place] == dst ) + return dpc_place; + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asALS[i]; + if ( mtp3_para->nw[nw].dpc[dpc_place] == dst ) + return dpc_place; + } + return -1; +} + +int find_direct_ls_to_dst(long dst, BYTE nw) +{ + BYTE i; + + + for (i=0; i<128; i++) + { + if (mtp3_para->ls_op_pc[i] == dst && ( (mtp3_para->ls_pro[i] & 3) == nw)) + return i; + } + mtp3_debug(MTP3DB_EVENT,"dst %d Can't find direct linkset to destination",dst); + return 128; +} + +int get_chl_via_slc(int linkset,BYTE slc,long msgopc) +{ + ls_info *ls; + int lsx16; + BYTE nw; + int link; + + if (linkset > 127) + return -1; + if (slc > 15) + return -1; + lsx16 = linkset << 4; + ls = &mtp3.ls[linkset]; + if (mtp3_para->ls_op_pc[linkset] == msgopc) + { + link = ls_slc[lsx16+slc]; + if ( mtp3ObjState.lk_configured[link] == PARA_CONFIGURED ) + return ls_slc[lsx16+slc]; + } + else + { + nw = mtp3_para->ls_pro[linkset] & 3; + linkset = find_direct_ls_to_dst(msgopc,nw); + if ( linkset < 128 ) + { + lsx16 = linkset << 4; + return ls_slc[lsx16+slc]; + } + } + mtp3_debug(MTP3DB_EVENT,"slc %d Can't Find This slc",slc); + return -1; +} + +void send_to_host_mtp3(BYTE *msgptr,DWORD dst_ip) +{ + mtp3_iprt.io_msg.msgSrcPort = SS7_PORT; + mtp3_iprt.io_msg.msgDstPort = SS7_PORT; + mtp3_iprt.io_msg.msgDstIP = dst_ip; + mtp3_iprt.io_msg.msgLength = (msgptr[1]<<8) + msgptr[2]+3; + memcpy(&mtp3_iprt.io_msg.msgContent, msgptr,mtp3_iprt.io_msg.msgLength); +// mtp3_iprt.io_msg.msgContent[0] = msgptr[0]; +// iptrPutMessage(mtp3_iprt.io_msg); + + iptrDirectSendMsg(mtp3_iprt.io_msg); +} + +void mtp3_multicast(BYTE *msgptr) +{ + int i; + DWORD dst_ip; + + for (i=0;ilk[link].e1_to_linkset; + if (lsno > 127) + return; + ls = &mtp3.ls[lsno]; + + nw = (msgptr[3] >> 6) & 3; + pc_len = pc_length(nw); + if (pc_len == MTP3_24BIT_PC) + { + msgtype_offset = 10+1; + memcpy(&MsgOpc,&msgptr[7],3); + slc = msgptr[10] & 0x0f; + } + else + { + memcpy(&MsgOpc,&msgptr[4],4); + slc = (MsgOpc >> 28) & 0x0f; + MsgOpc = (MsgOpc & 0x0fffffff) >> 14; + msgtype_offset = 7+1; + } + + msgtype = msgptr[msgtype_offset]; + h0 = msgtype & 0x0F; + h1 = (msgtype >> 4) & 0x0f; + switch (h0) + { + case 1:/* COO/COA/CBD/CBA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + if (chl == -1) + return; + if ( (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) && + (src_host == MSG_FROM_MTP2) ) + { + send_to_host_mtp3(msgptr, mtp3ObjState.lk_mtp3[chl]); //<< 16) | 0x010012ac); + return; + } + switch (h1) + { + case 1:/* COO */ + remote_bsnt = msgptr[msgtype_offset+1]; + if (remote_bsnt < 128) + { + mtp3_debug(MTP3DB_EVENT,"link %d RVed COO",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_CHANGEOVER_ORDER; + fsnc[chl] = msgptr[msgtype_offset+1]; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d RECEIVE COO WITH INVALID BSN",chl); + } + break; + case 2:/* COA */ + remote_bsnt = msgptr[msgtype_offset+1]; + if (remote_bsnt < 128) + { + mtp3ObjInput.tcoc_input_from_hmdt[chl] = TCOC_HMDT_COA_COMMAND; + mtp3_debug(MTP3DB_EVENT,"chl %d rv COA",chl); +// printf("chl %d rv COA\n",chl); + fsnc[chl] = msgptr[msgtype_offset+1]; + } + else + { + mtp3_debug(MTP3DB_EVENT,"link %d RECEIVE COA WITH INVALID BSN",chl); + } + break; + case 5:/* CBD */ + mtp3_debug(MTP3DB_EVENT,"chl %d rev cbd,tcbc state is %d",chl,mtp3ObjState.tcbc_state[chl]); +// printf("chl %d rev cbd,tcbc state is %d\n",chl,mtp3ObjState.tcbc_state[chl]); +// tcbc_input can cause this var override in some case +// tcbc_input[chl] = TCBC_HMDT_CBD_COMMAND; + cbd_cbc_r[chl] = msgptr[msgtype_offset+1]; + hmrt_tcbc_changeback_ack(chl); + break; + case 6:/* CBA */ + mtp3_debug(MTP3DB_EVENT,"chl %d rev cba",chl); +// printf("chl %d rev cba\n",chl); +// tcbc_input[chl] = TCBC_HMDT_CBA_COMMAND; + cba_cbc_r[chl] = msgptr[msgtype_offset+1]; + break; + default: + break; + } + break; + case 2:/* ECO/ECA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + if (chl == -1) + return; + switch (h1) + { + case 1:/* ECO */ + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_ECHANGEOVER_ORDER; + break; + case 2:/* ECA */ + mtp3ObjInput.tcoc_input_from_hmdt[chl] = TCOC_HMDT_ECA_COMMAND; + break; + default: + break; + } + break; + case 4:/* TFP/TFA/ */ + switch (h1) + { + case 1:/* TFP */ + if (src_host == MSG_FROM_MTP2) + { + mtp3_multicast(msgptr); + return; + } + if ( pc_len == MTP3_24BIT_PC ) + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + } + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + if (mtp3_para->ls_op_pc[lsno] == tfdst) + return; + sp_place = find_dst_place(tfdst,lsno); + if ( sp_place == -1 ) + return; + TFPmsg_OPC = MsgOpc; + TFPmsg_SrcLk = link; + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TFP_MSG; + rtpc_proc(nw,sp_place); + break; + + case 5:/* TFA */ + if (src_host == MSG_FROM_MTP2) + { + mtp3_multicast(msgptr); + return; + } + if ( pc_len == MTP3_24BIT_PC ) + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + if (mtp3_para->ls_op_pc[lsno] == tfdst) + return; + sp_place = find_dst_place(tfdst,lsno); + if ( sp_place == -1 ) + return; + TFAmsg_OPC = MsgOpc; + TFAmsg_SrcLk = link; + mtp3.nw[nw].rtac_input[sp_place] = RTAC_TFA_MSG; + rtac_proc(nw,sp_place); + break; + + default: + break; + } + break; + case 5:/* RST */ + if ( pc_len == MTP3_24BIT_PC ) + memcpy(&tfdst,&msgptr[msgtype_offset+1],3); + else + { + memcpy(&tfdst,&msgptr[msgtype_offset+1],2); + tfdst = tfdst & 0x3fff; + } + sp_place = find_dst_place(tfdst,lsno); + if (sp_place == -1) + return; + if ( ((mtp3.nw[nw].routine[sp_place] >> 4) & 3) != 1 )/* inaccessable */ + { + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_RSRT_SEND_TFP_MSG; + sdTFP_Ls = lsno;/* send TFP to this linkset's remote sp */ + rtpc_proc(nw,sp_place); + } + else + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_SEND_TFA_MSG; + sdTFA_Ls = lsno; + rtac_proc(nw,sp_place); + } + break; + case 6:/* inhibit message */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + if (chl == -1) + return; + if ( (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) && + (src_host == MSG_FROM_MTP2) ) + { + send_to_host_mtp3(msgptr, mtp3ObjState.lk_mtp3[chl]);// << 16) | 0x010012ac); + return; + } + + switch (h1) + { + case 1:/* LIN */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_SIGLINK; + break; + case 2:/* LUN */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_UINHIBIT_SIGLINK; + break; + case 3:/* LIA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_ACK; + break; + case 4:/* LUA */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_UNINHIBIT_ACK; + break; + case 5:/* LID */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_INHIBIT_DENIED; + break; + case 6:/* LFU */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK; + break; + case 7:/* LLT */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_LOCAL_INHIBIT_TEST; + break; + case 8:/* LRT */ + chl = get_chl_via_slc(lsno,slc,MsgOpc); + mtp3ObjInput.tlac_input_from_hmdt[chl] = TLAC_HMDT_REMOTE_INHIBIT_TEST; + break; + default: + break; + } + break; + case 7:/* TRA */ + if (own_sp_restarting)/* sp restarting */ + { + rv_TRA_num++; + } + else + { + lsno=find_direct_ls_to_dst(MsgOpc,nw); + if ( (lsno != -1) && + (mtp3.ls[lsno].adjacentsp_restarting==1) ) + {/* from an restarting adjacent sp? */ + if (sending_phase_finished[lsno] == TRUE) + { + sending_phase_finished[lsno] = FALSE; + stop_mtp3T21(lsno); + tsrc_fun5(lsno); + } + else + { + } + } + else + { + for (i=0; i<256; i++) + { + if ( (mtp3.nw[nw].routine[i] & 0x30) == 0 )/* dst inaccessible */ + { + if ( (mtp3_para->nw[nw].normal_ls[i] < 128) || + (mtp3_para->nw[nw].alternative_ls[i] < 128)) + { + mtp3.nw[nw].rtpc_input[i] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = lsno;/* send TFP to this linkset's remote sp */ + tprc_proc(nw,i); + } + } + } + } + } + break; + default: + break; + } +} + +void hmdt_test_msg(BYTE *msgptr) +{ + int i; + BYTE chl; + BYTE linkset; + WORD sp_place; + ls_info *ls=NULL; + BYTE nw; + long route_mark; + BYTE msg_LI; + BYTE len; + BYTE *sd_tmp_buf; + BYTE slc=0; + + chl = msgptr[0]; + linkset = mtp3_para->lk[chl].e1_to_linkset; + nw = (mtp3_para->ls_pro[linkset]) & 3; + ls = &mtp3.ls[linkset]; + sp_place = ls->adjacent_sp_place; + if (sp_place > 255) + return; + + if( msgptr[11] == 0x11 && !(mtp3_para->lk[chl].e1_lk_type & 0x01 )) + { + mtp3_debug(MTP3DB_ERROR,"mtp3 link have been locked , discard sltm msg\r\n"); + return; + } + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if (pc_length(nw) == MTP3_24BIT_PC) + {/* For 24 Bit */ + if (msgptr[11] == 0x11 ) + { + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + slc = msgptr[12] & 0x0f; + else + slc = msgptr[10] & 0x0f; + if (slc != mtp3_para->lk[chl].e1_to_slc)//slc incorrect + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,24BIT,link=%d,slc=%d incorrect,should be %d",chl,slc,mtp3_para->lk[chl].e1_to_slc); + return; + } + + msg_LI = (msgptr[12] >> 4); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = msgptr[1]; + sd_tmp_buf[2] = msgptr[2]; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6)+2; + else + sd_tmp_buf[3] = (nw << 6)+1; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + sd_tmp_buf[10] = msgptr[10]; + sd_tmp_buf[11]= SIGNAL_SLTA; + sd_tmp_buf[12] = msgptr[12]; + for (i=1; i<=msg_LI; i++) + { + len = i + 11; + sd_tmp_buf[len+1] = msgptr[len+1]; + } + send_mtp_msg(chl,sd_tmp_buf); + } + else + { + if (msgptr[13] == chl) + { + + mtp3ObjInput.sltc_input[chl] = SLTA_MSG; + if (mtp3ObjState.sltc_state[chl] != 3) + sltc_proc(chl); + } + } + } + + else/* 14 bit */ + { + if (msgptr[8] == 0x11 ) + { + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + slc = msgptr[9] & 0x0f; + else + slc = (msgptr[7] >> 4) & 0x0f; + if (slc != mtp3_para->lk[chl].e1_to_slc)//slc incorrect + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,14BIT,link=%d,slc=%d incorrect,should be %d",chl,slc,mtp3_para->lk[chl].e1_to_slc); + return; + } + + route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + (mtp3_para->ls_op_pc[linkset]); + msg_LI = (msgptr[9] >> 4); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = msgptr[1]; + sd_tmp_buf[2] = msgptr[2]; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_SLTA; + for (i=0; i<=msg_LI; i++) + { + len = i+8; + sd_tmp_buf[len+1] = msgptr[len+1]; + } + send_mtp_msg(chl,sd_tmp_buf); + } + else + { + if (msgptr[10] == chl) + { + mtp3ObjInput.sltc_input[chl] = SLTA_MSG; + if (mtp3ObjState.sltc_state[chl] != 3) + sltc_proc(chl); + } + } + } +} + +int mtp3_Trans_stpMsg(BYTE *msgptr,BYTE outlink,BYTE pc_len) +{ + long dest_ip; + BYTE nw=0; + BYTE ssf=0; + WORD len; + + nw = (msgptr[3] >> 6) & 3; + ssf = msgptr[3] & 7; + len = (msgptr[1]<<8) + msgptr[2] + 3; + + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"mtp3_Trans_stpMsg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + if (ssf>1) + ssf = ssf - 1; + + if (mtp3_para->lk[msgptr[0]].e1_to_linkset == mtp3_para->lk[outlink].e1_to_linkset) + {//to avoid stp back to the incoming linkset + mtp3.nw[nw].flow.stp_loop[ssf]++; + return 0; + } + +// current_measure->tf_measure1[3][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[3][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.stp[ssf]++; + + mtp3_iprt.io_msg.msgLength = len; + mtp3_iprt.io_msg.msgContent[0] = outlink; + + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + { + dest_ip = mtp3ObjState.lk_mtp3[outlink]; + //dest_ip = (dest_ip << 16) | E1CARD_BASE_IP; + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); +// send_to_mtp2(dest_ip); + send_to_mtp2_new_struct(dest_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) + { + dest_ip = LINK_TO_IP(outlink); + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + send_to_mtp2(dest_ip); + } + else + { +#if _INCLUDE_M2UA + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + + } + else + { + if (iptrans_msg_flow(&mtp3_iprt.io_msg.msgContent[0],pc_len,MTP_MSG_STP,dest_ip)); + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return 1; + } +#endif + } + + + + return 1; +} + +void mtp3_print_routeFailure(BYTE sio,BYTE reason) +{ + BYTE debug_type; + + switch(sio & 0x0f) + { + case 0x0: + break; + case 0x1: + debug_type = MTP3DB_SNMMSG; + break; + case 0x3: + debug_type = MTP3DB_SCCPMSG; + break; + case 0x4: + debug_type = MTP3DB_TUPMSG; + break; + case 0x5: + debug_type = MTP3DB_ISUPMSG; + break; + default: + break; + } + + switch (reason) + { + case 0: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:no route\33[0m"); + break; + case 1: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:buf overflow\33[0m"); + break; + case 2: + mtp3_debug(debug_type,"Perform routing:\33[31mRoute Failure,Reason:network conflict\33[0m"); + break; + default: + break; + } +} + +int mtp3lite_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode) +{ + BYTE ls_t; + + if ((mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3_para->lk[chl].e1_to_mtp3 != mtp3_localip)) + return 0; + + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state != mtp3ObjState.link_l2_state[chl]) + { + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d L2 in service",chl); + mtp3_send_mtp2_alarm(8+chl,0); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3ObjState.link_l1_state[chl] = 1; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 1); + mtp3.ls[ls_t].links_available ++; + hmrt_tcbc_update_routing_tables(chl); + + mtp3ObjState.lk_mtp3[chl] = mtp3_localip; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d L2 out of service",chl); + mtp3_send_mtp2_alarm(8+chl,alarmCode); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + //mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + //sltc_proc(chl); + mtp3ObjState.link_l1_state[chl] = 0; + mtp3ObjState.link_l2_state[chl] = 0; + mtp3ObjState.link_l3_state[chl] = 0; + mtp3ObjState.lsac_state[chl] = 0; + mtp3ObjState.sltc_state[chl] = 0; + mtp3ObjState.tlac_state[chl] = 0; + if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 0); + hmrt_tcoc_update_routing_tables(chl); + } + } + + return 1; +} + +int Link_Alternative_Mtp3_SubSystem_State(BYTE Link, BYTE SubSystem) +{ + DWORD AlterMTP3=mtp3_para->lk[Link].e1_to_alterMTP3; + int Idx=-1; + + if ((Idx = MTP3_LinkIP_List(AlterMTP3,0)) >= 0) + { + if (SubSystem < 8) + { + return ((MTP3IPMng.LinkIPSubSta[Idx][0] >> SubSystem) & 1); + } + else + return ((MTP3IPMng.LinkIPSubSta[Idx][1] >> (SubSystem & 7)) & 1); + } + + return 0; +} + +int GetMtp2Msg(DWORD ip_port)/* get ss7 message from iptrans via the 4950:ss7 port,4969:multicast port*/ +{ + BYTE module_id; + BYTE *msgptr=NULL; + BYTE sio; + ls_info *ls; + long route_mark; + BYTE chl; + BYTE routine; + BYTE nw; + BYTE lsnw; + BYTE pc_len; + int outlink; + BYTE sls; + BYTE lsno=0; + BYTE ls_pro; + long opc=0; + long msgdpc=0; + long msgopc=0; + WORD len, tmp_len; + BYTE ssf; + BYTE printmsgsuccess; + BYTE src_host; + BYTE dpc_equal_to_opc; + BYTE tmp_up_message[300]; + +#if _INCLUDE_M2UA + BYTE new_l2_state; + BYTE ls_t; +#endif + + printmsgsuccess = 0; + outlink = 256; +// if (iptrGetMessage(&mtp3_iprt.io_msg,ip_port) > 0) +#if _INCLUDE_M2UA + if (((ip_port == SS7_PORT) && (iptrDirectRecvMsg(&mtp3_iprt.io_msg,ip_port) > 0)) || + ((ip_port == M2UA_PORT) && (!get_m2ua_msg(&mtp3_m2ua_msg)))) +#else + if (((ip_port == SS7_PORT) && (iptrDirectRecvMsg(&mtp3_iprt.io_msg,ip_port) > 0))) +#endif + { + if (ip_port == SS7_PORT) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8 ) + mtp3_iprt.io_msg.msgContent[2]; + if(mtp3_iprt.io_msg.msgContent[1] >=2)//old structure: LINK,len,sio... + {//insert one byte len in msgContent, change to new structure: LINK , len_high,len_low,sio + memcpy(tmp_up_message+2, &mtp3_iprt.io_msg.msgContent[1], mtp3_iprt.io_msg.msgContent[1] + 1); + tmp_up_message[0] = mtp3_iprt.io_msg.msgContent[0]; + tmp_up_message[1] = 0; + memcpy(&mtp3_iprt.io_msg.msgContent[0], tmp_up_message, tmp_up_message[2]+3); + } + else if(tmp_len > 300)//max len = 300 + { + mtp3_debug(MTP3DB_ERROR,"Get message in SS7 port 4950, length longer than 300!"); + return 0; + } + } +#if _INCLUDE_M2UA + if(ip_port == M2UA_PORT) + { + if(1) + {//check len + len = ntohs(mtp3_m2ua_msg->len)+2; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"Get message in m2ua, length longer than 300!"); + return 0; + } + len = 0; + } + if( mtp3_send_netcap && ( (mtp3_m2ua_msg->sio & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_m2ua_msg->sio; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_m2ua_msg->sio + , ntohs(mtp3_m2ua_msg->len), 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_m2ua_msg->sio + , ntohs(mtp3_m2ua_msg->len), 0 ); + } + } + + } + else +#endif + { + if( mtp3_send_netcap && ( ( mtp3_iprt.io_msg.msgContent[3] & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_iprt.io_msg.msgContent[3]; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_iprt.io_msg.msgContent[3] + , (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_iprt.io_msg.msgContent[3] + , (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2], 0 ); + } + } + } + if (ip_port == SS7_PORT) + { + msgSourceIP = mtp3_iprt.io_msg.msgSrcIP; + module_id = (msgSourceIP >> 16) & 0xff; + msgptr = &mtp3_iprt.io_msg.msgContent[0]; + if ( ((msgSourceIP & E1CARD_BASE_IP) == E1CARD_BASE_IP) && + (module_id < 32) ) + { + src_host = MSG_FROM_MTP2; + } + else + src_host = MSG_FROM_MTP3; + } +#ifdef _INCLUDE_M2UA + else + { + src_host = MSG_FROM_MTP2; + if (mtp3_m2ua_msg->sio == 0xEF) + { + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M2UA heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_m2ua_msg->link,ntohs(mtp3_m2ua_msg->len)+2); + + chl = mtp3_m2ua_msg->link; + new_l2_state = mtp3_m2ua_msg->msg.lm.opercode; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state == 0) + mtp3ObjState.link_l1_state[chl] = 0; + else + mtp3ObjState.link_l1_state[chl] = 1; + if ( (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip)) + return 0; + + if ( new_l2_state != mtp3ObjState.link_l2_state[chl] ) + { + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 in service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,0);//clear alarm + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service",chl); + mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + /* + if ( mtp2->retrieved_bsnt[i] < 128 ) + local_bsnt_retrievable[chl] = TRUE; + else + { + mtp3_debug(MTP3_DEBUG_LOG,"Link %d BSNT RETRIEVE FAILED",chl); + local_bsnt_retrievable[chl] = FALSE; + } + */ + mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + sltc_proc(chl); + + if (mtp3_m2ua_msg->msg.lm.alarmcode == 0) + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,M2UAALARM_Remote_MTP2_down); + else + mtp3_send_mtp2_alarm(8+mtp3_m2ua_msg->link,mtp3_m2ua_msg->msg.lm.alarmcode); + } + } + mtp3ObjState.link_l2_state[chl] = new_l2_state; + return 1; + } + else if (mtp3_m2ua_msg->sio == 0xEE)//sg + { + mtp3_send_alarm(MTP3_SG_COMPONENT+mtp3_m2ua_msg->link,mtp3_m2ua_msg->msg.lm.alarmcode); + } + else + { + msgptr = (BYTE *)mtp3_m2ua_msg; + chl = msgptr[0]; + msgSourceIP = mtp3_para->sg[mtp3_para->lk[chl].e1_to_sg].ip; +/* module_id = chl >> 3; + msgSourceIP = module_id; + msgSourceIP = (msgSourceIP << 16) | E1CARD_BASE_IP;*/ + } + } +#endif + + chl = msgptr[0]; + len = (msgptr[1]<<8)+msgptr[2]+3; + sio = msgptr[3]; + nw = sio >> 6; + ssf = sio & 0x0f; + if (ssf > 1) + ssf--; +// current_measure->tf_measure2[1][wx5[nw]+ssf]++;/* MSUs */ +// mtp3.nw[nw].flow.ItoM[ssf]++; + + pc_len = pc_length(nw); + + printmsgsuccess = iptrans_msg_flow(msgptr,pc_len,MTP_MSG_UP,msgSourceIP); + if (src_host == MSG_FROM_MTP2) + { + + current_measure->tf_measure2[1][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM[ssf]++; + src_host = MSG_FROM_MTP2; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno > 127) + { +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + + ls_pro = mtp3_para->ls_pro[lsno]; + lsnw = (ls_pro & 3); + if (lsnw != nw) + { + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,2); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==mtp2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d,linkset=%d",pc_len,sio,msgopc,msgdpc,chl,lsno); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2]+3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:linkset belong to net %d,but sio=%d",lsnw,sio); + } + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + + if (lsno > 127) + { +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + ls = &mtp3.ls[lsno]; + + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + nw = ls_pro & 3; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + opc = mtp3_para->ls_op_pc[lsno]; + memcpy( &msgptr[7],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(mtp3_para->ls_op_pc[lsno] << 14)+opc; + memcpy(&msgptr[4],&route_mark,4); + } + } + else if ( ls_pro & 0x10 ) + { + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + memcpy( &msgptr[4], &mtp3_para->nw[nw].opc24, 3);/* change msg's dpc to opc */ + } + else + { + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + route_mark = (route_mark & 0xFFFFC000) | (mtp3_para->nw[nw].opc14 & 0x3FFF); + memcpy(&msgptr[4],&route_mark,4); + } + } + + if (pc_len == MTP3_24BIT_PC) + { + memcpy(&msgdpc,&msgptr[4],3); + memcpy(&msgopc,&msgptr[7],3); + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + //if (msgdpc != mtp3_para->nw[nw].opc24)/* STP */ + if (!dpc_equal_to_opc) //STP + { + sls = msgptr[10] & 0x0f; + outlink = check_outbound_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } + } + } + + else/* 14 bit network */ + { + memcpy(&route_mark,&msgptr[4],4); + msgdpc = route_mark & 0x3FFF; + msgopc = (route_mark & 0x0FFFFFFF) >> 14; + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + //if (msgdpc != mtp3_para->nw[nw].opc14)/* STP !!! */ + if (!dpc_equal_to_opc) + { + sls = (route_mark >> 28) & 0x0f; + outlink = check_outbound_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } + } + } + } + else if (src_host == MSG_FROM_MTP3) + { +#ifdef _M3UA_ + switch(sio) + { + case 0x1f://get route table from other plat + chl = msgptr[0]; + nw = msgptr[4]; + memcpy(&msgdpc, msgptr+5, 4); + routine = get_route_value(msgdpc, nw); + send_route_to_other_plat(msgdpc, nw, routine, mtp3_iprt.io_msg.msgSrcIP, chl); + return 1; + case 0x2f: + chl = msgptr[0]; + nw = msgptr[4]; + memcpy(&msgdpc, msgptr+5, 4); + routine = msgptr[9]; + update_route_by_other_plat(msgdpc,nw, routine, chl); + return 1; + default: + break; + } + + +#endif + if (pc_len == MTP3_24BIT_PC) + memcpy(&msgdpc,&msgptr[4],3); + else + { + memcpy(&route_mark,&msgptr[4],4); + msgdpc = route_mark & 0x3FFF; + } + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(nw, msgdpc); + + if (!dpc_equal_to_opc) + { + if (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) + return 0; + + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN) + send_to_mtp2(LINK_TO_IP(chl)); +#if _INCLUDE_M2UA + else if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]; + if(tmp_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"put_m2ua_msg, length longer than 300, len=%d!", tmp_len); + mtp3_iprt.io_msg.msgContent[1] = 0; + tmp_len= 272; + } + put_m2ua_msg((m2ua_up_msg_t *) mtp3_iprt.io_msg.msgContent); + } + else if (MTP3_LINK_TYPE(chl) == LKTYPE_M3UA) + { + tmp_len = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]; + if(tmp_len > 300) + { + mtp3_debug(MTP3DB_ERROR,"put_m3ua_msg, length longer than 300, len=%d!", tmp_len); + mtp3_iprt.io_msg.msgContent[1] = 0; + tmp_len= 272; + } + send_mtp_msg(chl, mtp3_iprt.io_msg.msgContent); + } +#endif + return 1; + } + } + + if (outlink < 0) + { + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,0); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d",pc_len,sio,msgopc,msgdpc,chl); +// mtp3_debug(msgptr,MTP3_ERROR_LOG,"\33[31m[STP]Route Failed! SIO=%x,DPC=%lx\n\r\33[0m",sio,msgdpc); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2] + 3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:STP failed"); + } + hmrt_srm_msg(lsno,SIGNAL_TFP,msgdpc); +// current_measure->tf_measure1[5][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[5][wx5[nw]+ssf]++;/* MSUs */ + mtp3.nw[nw].flow.stp_throwed[ssf]++; + return 0; + } + +// current_measure->tf_measure1[2][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[2][wx5[nw]+ssf]++;/* MSUs */ + switch (sio & 0x0f) + { + case MTP3_SUB_SNM: + mtp3.nw[nw].flow.MtoU[0]++; + hmdt_SNM_message_for_distribution(msgptr,src_host); + return 1; + case MTP3_SUB_STM: + mtp3.nw[nw].flow.MtoU[1]++; + hmdt_test_msg(msgptr); + return 1; + case MTP3_SUB_STM2: + mtp3ObjState.lk_SpecANSI_flag[chl] = 1;//mark special T+M + mtp3.nw[nw].flow.MtoU[1]++; + hmdt_test_msg(msgptr); + return 1; + case MTP3_SUB_SCCP: + if ((mtp3_heartbeat.SubState[0] & 0x08) || (MSG_FROM_MTP3==src_host)) + { + if ( (S_shm_ptr->MS_Buf.WSub+1) == S_shm_ptr->MS_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[0]++; + break; + } + send_to_sccp(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_SCCPMSG,"Perform routing:transfer to SCCP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_SCCP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_SCCPMSG,"Perform routing:SCCP UP is Locked,transfer to Alternative SCCP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No SCCP UP Available"); + } + + return 1; + case MTP3_SUB_TUP: + if ((mtp3_heartbeat.SubState[0] & 0x10) || (MSG_FROM_MTP3==src_host)) + { + if ( (T_shm_ptr->MT_Buf.WSub+1) == T_shm_ptr->MT_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[1]++; + break; + } + send_to_tup(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_TUPMSG,"Perform routing:transfer to TUP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_TUP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_TUPMSG,"Perform routing:TUP UP is Locked,transfer to Alternative TUP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No TUP UP Available"); + } + return 1; + case MTP3_SUB_ISUP: + if ((mtp3_heartbeat.SubState[0] & 0x20) || (MSG_FROM_MTP3==src_host)) + { + if ( (I_shm_ptr->MI_Buf.WSub+1) == I_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + send_to_isup(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ISUPMSG,"Perform routing:transfer to ISUP"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_ISUP)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ISUPMSG,"Perform routing:ISUP UP is Locked,transfer to Alternative ISUP UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No ISUP UP Available"); + } + return 1; + case MTP3_SUB_BICC: // BICC + if ((mtp3_heartbeat.SubState[1] & 0x40) || (MSG_FROM_MTP3==src_host)) + { + if ( (B_shm_ptr->MI_Buf.WSub+1) == B_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + send_to_bicc(msgptr); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_BICCMSG,"Perform routing:transfer to BICC"); + } + else if (Link_Alternative_Mtp3_SubSystem_State(chl,MTP3_SUB_BICC)) + { +// send_to_mtp2(mtp3_para->lk[chl].e1_to_alterMTP3); + send_to_mtp2_new_struct(mtp3_para->lk[chl].e1_to_alterMTP3); + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_BICCMSG,"Perform routing:BICC UP is Locked,transfer to Alternative BICC UP"); + } + else + { + if (printmsgsuccess == 1) + mtp3_debug(MTP3DB_ERROR,"Perform routing:No BICC UP Available"); + } + return 1; + default: + break; + } + if (printmsgsuccess == 1) + mtp3_print_routeFailure(sio,1); + else + { + mtp3_debug(MTP3DB_ERROR,"MTP3<==MTP2,%dBIT,SIO=%x,SPC(%lx->%lx),link=%d",pc_len,sio,msgopc,msgdpc,chl); + mtp3_showbuf(MTP3DB_ERROR,msgptr, (msgptr[1]<<8)+msgptr[2]+3); + mtp3_debug(MTP3DB_ERROR,"Perform routing:buffer fulled"); + } + mtp3.nw[nw].flow.ItoM_throwed[ssf]++; + return 0; + } + return 1; +} + +#ifdef _M3UA_ +int m3ua_send_to_sccp(xua_m3ua_msg *msgptr)/* send sccp msg to tele user part */ +{ + up_message *ToSccp; + WORD len; + BYTE nw; + BYTE link; + +// sio = msgptr[3]; + ToSccp = &S_shm_ptr->MS_Buf.msgNum[S_shm_ptr->MS_Buf.WSub]; + nw = msgptr->ni; + ToSccp->sio = (nw <<6) | msgptr->si; + ToSccp->sio = ToSccp->sio | (mtp3_ansiFlag(nw) << 4); +// sio = sio | (mtp3_ansiFlag(nw) << 4); + link = msgptr->link; + ToSccp->link = link; + ToSccp->dest_ip = msgSourceIP; + +// pclen = pc_length(nw); +// if (pclen == MTP3_24BIT_PC)/* for 24bit ss7 network */ +// { +// if (msgptr[1] == 0 && msgptr[2] < 9)//len < 9 +// { +// mtp3ObjState.MTP3WatchDog[3]++; +// mtp3.nw[nw].flow.MtoU_throwed[0]++; +// mtp3_debug(MTP3DB_ERROR,"[SCCP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr[2],link); +// return 0; +// } + +// memcpy((BYTE *)&ToSccp->dpc,msgptr+4,3);/* message's dpc */ +// memcpy((BYTE *)&ToSccp->opc,&msgptr[7],3);/* message's opc */ + ToSccp->dpc = msgptr->dpc; + ToSccp->opc = msgptr->opc; + + ToSccp->cic[0] = msgptr->sls; +// len = (msgptr[1]<<8) + msgptr[2]-8; + len = ntohs(msgptr->len); + ToSccp->len = len; + memcpy(&ToSccp->msgList,msgptr->content, len); + S_shm_ptr->MS_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[2]++; + return 1; +} + +int m3ua_send_to_bicc(xua_m3ua_msg *msgptr)/* send isup msg to tele user part */ +{ + WORD len; + up_message_2 *ToBicc; + BYTE nw; + + ToBicc = &B_shm_ptr->MI_Buf.msgNum[B_shm_ptr->MI_Buf.WSub]; + nw = msgptr->ni; + ToBicc->sio = (nw<<6) | msgptr->si; + ToBicc->sio = ToBicc->sio | (mtp3_ansiFlag(nw) << 4); + ToBicc->link = msgptr->link; + ToBicc->dest_ip = msgSourceIP; + ToBicc->dpc = msgptr->dpc; + ToBicc->opc = msgptr->opc; + ToBicc->cic[0] = msgptr->content[0]; + ToBicc->cic[1] = msgptr->content[1]; + ToBicc->cic[2] = msgptr->content[2]; + ToBicc->cic[3] = msgptr->content[3]; + len = ntohs(msgptr->len); + ToBicc->len = len-4; + memcpy(&ToBicc->msgList,&msgptr->content[4],len); + B_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int m3ua_send_to_isup(xua_m3ua_msg *msgptr)/* send isup msg to tele user part */ +{ + WORD len; + up_message *ToIsup; + BYTE nw; + + ToIsup = &I_shm_ptr->MI_Buf.msgNum[I_shm_ptr->MI_Buf.WSub]; + nw = msgptr->ni; + ToIsup->sio = (nw<<6) | msgptr->si; + ToIsup->sio = ToIsup->sio | (mtp3_ansiFlag(nw) << 4); + ToIsup->link = msgptr->link; + ToIsup->dest_ip = msgSourceIP; + if (msgptr->len <= 0) + { + mtp3ObjState.MTP3WatchDog[7]++; + mtp3.nw[nw].flow.MtoU_throwed[2]++; + mtp3_debug(MTP3DB_ERROR,"[ISUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr->len, msgptr->link); + return 0; + } + ToIsup->dpc = msgptr->dpc; + ToIsup->opc = msgptr->opc; + ToIsup->cic[0] = msgptr->content[0]; + ToIsup->cic[1] = msgptr->content[1]; + len = ntohs(msgptr->len) -2; + ToIsup->len = len; + memcpy(&ToIsup->msgList,&msgptr->content[2],len); + MTP3_recv_isup_count(nw,msgptr->content[2]); + I_shm_ptr->MI_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[4]++; + return 1; +} + +int m3ua_send_to_tup(xua_m3ua_msg *msgptr)/* send tup msg to tele user part */ +{ + WORD len; + up_message *ToTup; + BYTE nw; + + ToTup = &T_shm_ptr->MT_Buf.msgNum[T_shm_ptr->MT_Buf.WSub]; + nw = msgptr->ni; + ToTup->sio = (nw<<6) | msgptr->si; + ToTup->sio = ToTup->sio | (mtp3_ansiFlag(nw) << 4); + ToTup->link = msgptr->link; + ToTup->dest_ip = msgSourceIP; + if (msgptr->len <= 0) + { + mtp3ObjState.MTP3WatchDog[5]++; + mtp3.nw[nw].flow.MtoU_throwed[1]++; + mtp3_debug(MTP3DB_ERROR,"[TUP]MTP3<==MTP2,LI over range and discarded! LI=%02d,Link=%d",msgptr->len,msgptr->link); + return 0; + } + ToTup->dpc = msgptr->dpc;/* message's dpc */ + ToTup->opc = msgptr->opc;/* message's opc */ + ToTup->cic[0] = msgptr->content[0]; + ToTup->cic[1] = msgptr->content[1]; + len = ntohs(msgptr->len) - 2; + ToTup->len = len; + memcpy(&ToTup->msgList,&msgptr->content[2],len); + T_shm_ptr->MT_Buf.WSub ++; + mtp3.nw[nw].flow.MtoU[3]++; + return 1; +} + +int check_m3ua_rc_verify(DWORD rc) +{ + int routing_no, nw; + for(nw = 0; nw<4; nw++) + { + for(routing_no = 0; routing_no<256;routing_no++) + { + if(rc==mtp3_para->nw[nw].rc[routing_no]) + return 1; + } + } + return -1; +} +int get_m3ua_rc_by_dpc(BYTE nw, long dpc) +{ + network *sp; + BYTE i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + + if (dpc==0) + return -3; + + sp = &mtp3.nw[nw]; + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,dpc); + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return -3; + return mtp3_para->nw[nw].rc[i]; +} + +int find_rc_dst_place(DWORD rc, BYTE lsno, BYTE nls_als) +{ + BYTE i; + BYTE nw; + BYTE dpc_place; + ls_info *ls; + + if (lsno > 127) + return -1; + + ls = &mtp3.ls[lsno]; + nw = (mtp3_para->ls_pro[lsno]) & 3; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asNLS[i]; + if ( mtp3_para->nw[nw].rc[dpc_place] == rc ) + { + return dpc_place; + } + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + dpc_place = ls->influ_dstplace_intable_asALS[i]; + if ( mtp3_para->nw[nw].rc[dpc_place] == rc ) + { + return dpc_place; + } + } + + return -1; +} + +void m3ua_upd_route_status(BYTE chl, DWORD rc, BYTE rc_status, BYTE ls_disable) +{ + ls_info *ls; + int i; + BYTE lsno, nw,spplace; + int dpc_index; + WORD lsx16; + DWORD dpc; + BYTE *routine; + network *sp; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno >= 0x80) + return; + + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + lsx16 = lsno << 4; + sp = &mtp3.nw[nw]; + + if(!ls_disable) + { + dpc_index = find_rc_dst_place(rc, lsno, 1); + dpc = mtp3_para->nw[nw].dpc[dpc_index]; + if(dpc_index == -1 || dpc_index > 255) + return; + sp->m3ua_rc_status[dpc_index] = rc_status; + } + + if (rc_status!=5) + {// mark_normal_linkset_unavailable(&mtp3.nw[nw].routine[dpc_index]); + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc && ls_disable==0) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + if ( ((sp->routine[spplace] >> 2) & 3) == 0 )/*alternative route available */ + sp->routine[spplace] = (sp->routine[spplace] & 0x3f) + 0x40;/* current route change from normal linkset to alternative linkset */ + else/* sp not accessible */ + { + sp_unaccessable((BYTE *)&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(mtp3_para->nw[nw].dpc[spplace], nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl); + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc && ls_disable==0) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + if ( (sp->routine[spplace] & 3) != 0 )/* normal route unavailable */ + { + sp_unaccessable((BYTE *)&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(mtp3_para->nw[nw].dpc[spplace], nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl); + } + if(ls_disable) + { + memset(&ls_sls[lsx16],0xff,16); + set_heartbeat(ALARM_LS_UNAVAILABLE,lsno); + } + + + } + else + { + sp->m3ua_rc_status[dpc_index] = rc_status; + set_heartbeat(ALARM_LS_AVAILABLE,lsno); + memset(&ls_sls[lsx16],chl,16); + mark_normal_linkset_available(&mtp3.nw[nw].routine[dpc_index]); + routine = (BYTE *)&mtp3.nw[nw].routine[dpc_index]; + if (Nlinkset_status(*routine) == LS_AVAILABLE) + *routine = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + { + (*routine) = ((*routine) & 0x3f) + 0x80; + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[dpc_index],AVAILABLE); + } + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(dpc, nw, sp->routine[dpc_index], mtp3_para->lk[chl].e1_to_alterMTP3, chl); + + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if(mtp3_para->nw[nw].dpc[spplace] != dpc) + continue; + sp->m3ua_rc_status[spplace] = rc_status; + routine = (BYTE*)&sp->routine[spplace]; + if ( (*routine) >> 6 == 2 )/* no route */ + { + (*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */ + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + + if (Nlinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + (*routine) = ((*routine) & 0x3f) + 0x80; + if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0) + send_route_to_other_plat(dpc, nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl); + } + + + + } +// if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable +// mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]); +// hmrt_tfrc_update_routing_tables(dpc_index,nw); + +} + + + +int m3ua_updateStatus(BYTE chl, BYTE new_l2_state,BYTE alarmCode, DWORD rc, BYTE rc_status) +{ + BYTE ls_t; + + if ((mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || + (mtp3ObjState.lk_mtp3[chl] != mtp3_localip)) + return 0; + + ls_t = mtp3_para->lk[chl].e1_to_linkset; + if(mtp3ObjState.link_l1_state[chl] == 0 && mtp3ObjState.link_l2_state[chl]!=0) + { + mtp3ObjState.link_l2_state[chl] = 0;//reset l2 state + } + if (new_l2_state != mtp3ObjState.link_l2_state[chl]) + { + if (new_l2_state == MTP2_STATE_WORKING) + { + current_measure->lk_measure1[chl][2]++; + mtp3_debug(MTP3DB_EVENT,"m3ua link %d L2 in service",chl); + mtp3_debug(MTP3DB_EVENT,"\33[32mM3UA Link %d L3 in service,linkset = %d \33[0m",chl, ls_t); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// mtp3_send_alarm(ls_t+MTP3_LINKSET_COMPONENT,0); + mtp3_send_mtp2_alarm(8+chl,0); + } + set_heartbeat(ALARM_LS_AVAILABLE,ls_t); + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; + mtp3ObjState.link_l1_state[chl] = 1; + mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + mtp3ObjState.lsac_state[chl] = LSAC_ACTIVE_STATE; + mtp3ObjState.sltc_state[chl] = SLTC_RUNNING_STATE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + if (mtp3.ls[ls_t].links_available == 0) + mtp3.ls[ls_t].links_available = 1; +/* if (mtp3.ls[ls_t].links_available == 0) + m3ua_upd_route_status(chl, 1, rc, rc_status); + mtp3.ls[ls_t].links_available ++; + hmrt_tcbc_update_routing_tables(chl); +*/ + mtp3ObjState.lk_mtp3[chl] = mtp3_localip; + } + else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING) + { + local_change_over[chl]++; + mtp3_debug(MTP3DB_EVENT,"m3ua link %d L2 out of service",chl); + mtp3_debug(MTP3DB_EVENT,"\33[31mM3UA Link %d L3 out of service,Linkset %d out of service\33[0m",chl,ls_t); + set_heartbeat(ALARM_LS_UNAVAILABLE,ls_t); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// mtp3_send_alarm(ls_t+MTP3_LINKSET_COMPONENT,1); + mtp3_send_mtp2_alarm(8+chl,M2UAALARM_SCTP_Failure); + } + + //mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; + //mtp3ObjInput.sltc_input[chl] = SLTC_STOP; + //sltc_proc(chl); + mtp3ObjState.link_l1_state[chl] = 0; + mtp3ObjState.link_l2_state[chl] = 0; + mtp3ObjState.link_l3_state[chl] = 0; + mtp3ObjState.lsac_state[chl] = 0; + mtp3ObjState.sltc_state[chl] = 0; + mtp3ObjState.tlac_state[chl] = 0; + m3ua_upd_route_status(chl, rc, 0, 1); + if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; +/* if (mtp3.ls[ls_t].links_available > 0) + mtp3.ls[ls_t].links_available --; + if (mtp3.ls[ls_t].links_available == 0) + mtp3lite_upd_route_status(chl, 0); + hmrt_tcoc_update_routing_tables(chl); +*/ + } + + } + if(rc!=0) + { + m3ua_upd_route_status(chl, rc, rc_status, 0); + } + + return 1; +} + +int GetM3uaMsg(DWORD port) +{ + xua_m3ua_msg *msgptr = NULL; + xua_lm_lk *lm_lk_ptr = NULL; + xua_rc_cmd *rc_cmd_ptr = NULL; + BYTE nw,dpc_equal_to_opc,ssf; + BYTE new_l2_state, chl; + BYTE rc_status, db_type; + DWORD rc; + WORD m3ua_msg_len; + + if(!get_m3ua_msg(&mtp3_m3ua_msg)) + { + msgptr = &mtp3_m3ua_msg->msg.m3ua; + lm_lk_ptr = &mtp3_m3ua_msg->msg.lm_lk; + rc_cmd_ptr = &mtp3_m3ua_msg->msg.rc_cmd; +/* if( mtp3_send_netcap && ( (mtp3_m3ua_msg->sio & 0xF0 ) != 0xF0 ) ) + { + int pclen ; + sio = mtp3_m3ua_msg->sio; + nw = sio >> 6; + pclen = pc_length(nw); + + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &mtp3_m3ua_msg->sio + , ntohs(mtp3_m3ua_msg->len), 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &mtp3_m3ua_msg->sio + , ntohs(mtp3_m3ua_msg->len), 0 ); + } + } +*/ + + if(mtp3_m3ua_msg->msg_class == M3UA_MGMT_CMD) + { + + chl = lm_lk_ptr->link; + new_l2_state = lm_lk_ptr->opercode; + m3ua_updateStatus(chl, new_l2_state, 0, 0 ,0); + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA link heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,(BYTE *)mtp3_m3ua_msg,ntohs(lm_lk_ptr->len)+4); + + return 0; + + } + else if(mtp3_m3ua_msg->msg_class == M3UA_RC_CMD) + { + chl = rc_cmd_ptr->link; + rc_status = rc_cmd_ptr->opercode; + rc = rc_cmd_ptr->rc; + m3ua_updateStatus(chl, 5, 0, rc, rc_status); + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA rc heartbeat from %lx",msgSourceIP); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,(BYTE *)mtp3_m3ua_msg,ntohs(rc_cmd_ptr->len)+4); + return 0; + + } + else if(mtp3_m3ua_msg->msg_class == M3UA_MAUP_MSG)// M3uaMsg + { + nw = msgptr->ni; + ssf = msgptr->si; + dpc_equal_to_opc = mtp3_check_dpc_equal_to_opc(msgptr->ni, msgptr->dpc); + m3ua_msg_len = ntohs(msgptr->len)+20; + //if (msgdpc != mtp3_para->nw[nw].opc24)/* STP */ + if (!dpc_equal_to_opc) //STP + { + mtp3_debug(MTP3DB_ERROR,"mtp3<==m3ua, dpc=%lx!=local opc, len=%d!", msgptr->dpc, m3ua_msg_len); + mtp3_showbuf(MTP3DB_ERROR,(BYTE *)mtp3_m3ua_msg, m3ua_msg_len); + return 1;//not support STP +/* + sls = msgprt->sls;//msgptr[10] & 0x0f; + outlink = check_outbound_route(nw,msgdpc,sls); + if (outlink >= 0) + { + if (ip_port == M2UA_PORT) + { + memcpy(mtp3_iprt.io_msg.msgContent, msgptr, len); + msgptr = mtp3_iprt.io_msg.msgContent; + } + mtp3_Trans_stpMsg(msgptr,outlink,pc_len); + return 1; + } +*/ + + } + else + { + switch(msgptr->si) + { + case SCCP_SIO: + if ( (S_shm_ptr->MS_Buf.WSub+1) == S_shm_ptr->MS_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[0]++; + break; + } + m3ua_send_to_sccp(msgptr); + db_type = MTP3DB_SCCPMSG; + mtp3_debug(db_type,"SCCP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case BICC_SIO: + if ( (B_shm_ptr->MI_Buf.WSub+1) == B_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + m3ua_send_to_bicc(msgptr); + db_type = MTP3DB_BICCMSG; + mtp3_debug(db_type,"BICC<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case ISUP_SIO: + if ( (I_shm_ptr->MI_Buf.WSub+1) == I_shm_ptr->MI_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[2]++; + break; + } + m3ua_send_to_isup(msgptr); + db_type = MTP3DB_ISUPMSG; + mtp3_debug(db_type,"ISUP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + case TUP_SIO: + if ( (T_shm_ptr->MT_Buf.WSub+1) == T_shm_ptr->MT_Buf.RSub)// buffer overflow + { + mtp3.nw[nw].flow.MtoU_throwed[1]++; + break; + } + m3ua_send_to_tup(msgptr); + db_type = MTP3DB_TUPMSG; + mtp3_debug(db_type,"TUP<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + break; + + default: + db_type = MTP3DB_ERROR; + mtp3_debug(db_type,"MTP3<==M3UA,NW=%x,SIO=%x,SPC(%lx->%lx),link=%d",msgptr->ni,msgptr->si,msgptr->opc,msgptr->dpc,msgptr->link); + mtp3.nw[msgptr->ni].flow.ItoM_throwed[msgptr->si-1]++; + break; + + } + + mtp3_showbuf(db_type, (BYTE *)mtp3_m3ua_msg, m3ua_msg_len); + } + } + } + return 1; +} + + +int send_command_to_m3ua(BYTE link, BYTE command, BYTE xua_msg_class, DWORD rc) +{ + char charCmd[32]; + + if(xua_msg_class == M3UA_RC_CMD) + { + mtp3_iprt.io_msg.msgLength = 5+1+4; + mtp3_iprt.io_msg.msgContent[0] = xua_msg_class; + mtp3_iprt.io_msg.msgContent[1] = link; + mtp3_iprt.io_msg.msgContent[2] = 0; + mtp3_iprt.io_msg.msgContent[3] = 7; + mtp3_iprt.io_msg.msgContent[8] = command; + memcpy(&mtp3_iprt.io_msg.msgContent[4], &rc, 4); + }else if(xua_msg_class == M3UA_MGMT_CMD) + { + mtp3_iprt.io_msg.msgLength = 5+1; + mtp3_iprt.io_msg.msgContent[0] = xua_msg_class; + mtp3_iprt.io_msg.msgContent[1] = link; + mtp3_iprt.io_msg.msgContent[2] = 0; + mtp3_iprt.io_msg.msgContent[3] = 3; + mtp3_iprt.io_msg.msgContent[4] = ((mtp3ObjState.lk_mtp3[link] >> 16) & 0xff)-32;// 172.18.x+32.1 + mtp3_iprt.io_msg.msgContent[5] = command; + + switch (command) + { + case MTP2_DEACTIVE_LINK: + sprintf(charCmd,"M3UA_DEACTIVE_LINK"); + break; + case MTP3_M3UA_ENABLE: + sprintf(charCmd,"M3UA_ACTIVE_LINK"); + break; + default: + break; + } + } + else + return 0; + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send command %s to m3ua link %d",charCmd,link); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],mtp3_iprt.io_msg.msgLength); + put_m3ua_msg((xua_up_msg_t *) mtp3_iprt.io_msg.msgContent); + return 1; +} + +void deactive_m3ua_lk(BYTE link) +{ + if ((MTP3_LINK_TYPE(link) == LKTYPE_M3UA) && // M3UA + (mtp3_para->lk[link].e1_lk_type & 0x01)) + { + mtp3_debug(MTP3DB_EVENT,"m3ua link %d Deactive by MNG",link); + send_command_to_m3ua(link, MTP3_M3UA_DISABLE,M3UA_MGMT_CMD,0); + m3ua_updateStatus(link, 0, 0, 0 ,0); + + } +} + +void check_m3ua_link_status() +{ + int link,i; + BYTE lsno, nw, spplace; + DWORD rc; + network *sp; + ls_info *ls; + static int link_timer=0; + static int rc_timer=0; + + if(rc_timer >= 200)//2s + { + rc_timer = 0; + for(link=0;link<256; link++) + { + + if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].e1_lk_type & 1)&&(mtp3ObjState.lk_mtp3[link] == mtp3_localip)) + { + if(mtp3ObjState.link_l3_state[link] == AVAILABLE) + { + lsno = mtp3_para->lk[link].e1_to_linkset; + if (lsno >= 0x80) + return; + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + sp = &mtp3.nw[nw]; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + rc = mtp3_para->nw[nw].rc[spplace]; + if (sp->m3ua_rc_status[spplace]==0)/*normal route unavailable */ + { + send_command_to_m3ua(link, 1,M3UA_RC_CMD , rc); + } + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + rc = mtp3_para->nw[nw].rc[spplace]; + if (sp->m3ua_rc_status[spplace]==0)/*alter route unavailable */ + { + send_command_to_m3ua(link, 1, M3UA_RC_CMD, rc); + } + } + } + } + } + } + if(link_timer>=1000)//10s + { + link_timer = 0; + for(link=0;link<256; link++) + { + if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].e1_lk_type & 1) &&(mtp3ObjState.lk_mtp3[link] == mtp3_localip)) + { + if(mtp3ObjState.link_l3_state[link] == UNAVAILABLE) + send_command_to_m3ua(link, MTP3_M3UA_ENABLE,M3UA_MGMT_CMD,0); + } +/* if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && mtp3ObjInput.lsac_input_from_mgmt[link] == LSAC_MGMT_DEACTIVATE_LINK) + { +// mtp3_debug(MTP3DB_EVENT,"m3ua link %d Deactive by other plat MNG",link); +// send_command_to_m3ua(link, MTP3_M3UA_DISABLE,M3UA_MGMT_CMD,0); + deactive_m3ua_lk(link); + mtp3ObjInput.lsac_input_from_mgmt[link] = LSAC_MGMT_ACTIVATE_LINK; + + } +*/ + } + } + link_timer++; + rc_timer++; +} + + +void m3ua_timer() +{ + check_m3ua_link_status(); +} + +void send_mtp_msg(int outlink, BYTE *msgptr) +{ + int linkset; + ls_info *ls; + int ls_pro; + BYTE nw; + DWORD dst_ip; + long opc,dpc; + long route_mark; + BYTE sls; + BYTE pclen; + WORD len; + BYTE ssf; + BYTE debugtype=0; + xua_up_msg_t *m3ua_ptr=NULL; + + if(msgptr == NULL) + { + return; + } + m3ua_ptr = (xua_up_msg_t *)msgptr; + ssf = msgptr[3] & 0x0f; + linkset = mtp3_para->lk[outlink].e1_to_linkset; + ls = &mtp3.ls[linkset]; + ls_pro = mtp3_para->ls_pro[linkset]; + nw = ls_pro & 3; + pclen = pc_length(nw); + if ( (ls_pro & 8) != 0 )/* this linkset is loop back linkset */ + { + if ( pclen == MTP3_24BIT_PC ) + { + opc = mtp3_para->nw[nw].opc24; + memcpy( &msgptr[4],&opc,3);/* change msg's dpc to opc */ + } + else + { + opc = mtp3_para->nw[nw].opc14; + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + route_mark = (sls << 28)+(opc << 14)+opc; + memcpy(&msgptr[4],&route_mark,4); + } + } + + if (ssf > 1) + { + ssf--; + debugtype = MTP_MSG_DOWN; + } + else + debugtype = MTP_SNM_MSG; +// current_measure->tf_measure1[4][wx5[nw]+ssf]+=len;/* octets */ + current_measure->tf_measure2[4][wx5[nw]+ssf]++;/* MSUs */ + +// len = msgptr[1]+2; + len = (msgptr[1]<<8) + msgptr[2]+3; + if(len > 300) + { + mtp3_debug(MTP3DB_ERROR,"send_mtp_msg, length longer than 300, len=%d!", len); + msgptr[1] = 0; + len = 272; + } + mtp3_iprt.io_msg.msgLength = len; + + if( mtp3_send_netcap && ( ( msgptr[3] & 0xF0) != 0xF0 ) ) + { + if ( pclen == MTP3_24BIT_PC ) //ansi + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 1 ); + } + else if ( pclen == MTP3_14BIT_PC ) //ITU + { + NcMtp3Send ( &msgptr[3], (msgptr[1]<<8) + msgptr[2], 0 ); + } + } + +#if _INCLUDE_M2UA + if (mtp3ObjState.lk_mtp3[outlink] != mtp3_localip) + {//transfer to remote plat + dst_ip = mtp3ObjState.lk_mtp3[outlink]; + //dst_ip = (dst_ip << 16) | E1CARD_BASE_IP; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ +// send_to_mtp2(dst_ip); + send_to_mtp2_new_struct(dst_ip); + } + else if (MTP3_LINK_TYPE(outlink) == LKTYPE_NONE_SIGTRAN) +#endif + { + dst_ip = LINK_TO_IP(outlink); + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + send_to_mtp2(dst_ip);//use old struct send to 8k bload + } +#if _INCLUDE_M2UA + else + { + if (MTP3_LINK_TYPE(outlink) == LKTYPE_MTP3_LITE) + { + /* debug show message */ + dst_ip = mtp3_para->lk[outlink].remote_ip; + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if ((msgptr[3] & 0x0f) == 3) + put_mtp3lite_msg(msgptr); + return; + } + if (MTP3_LINK_TYPE(outlink) == LKTYPE_M3UA) + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + if(pclen == MTP3_24BIT_PC) + { + memmove(m3ua_ptr->msg.m3ua.content, msgptr+11, len-8); + memcpy(&m3ua_ptr->msg.m3ua.dpc,&msgptr[4],3); + memcpy(&m3ua_ptr->msg.m3ua.opc,&msgptr[7],3); + m3ua_ptr->msg_class = M3UA_MAUP_MSG; + m3ua_ptr->msg.m3ua.ni = nw; + m3ua_ptr->msg.m3ua.si = msgptr[3] & 0x0f; + m3ua_ptr->msg.m3ua.len = ntohs(len - 8); + m3ua_ptr->msg.m3ua.mp = 0; + m3ua_ptr->msg.m3ua.sls = sls; + m3ua_ptr->msg.m3ua.rc = get_m3ua_rc_by_dpc(nw, m3ua_ptr->msg.m3ua.dpc); + } + else + { + memmove(m3ua_ptr->msg.m3ua.content, msgptr+8, len-5); + memcpy( (BYTE*)&route_mark,&msgptr[4],4); + sls = route_mark >> 28; + dpc = route_mark & 0x3fff; + opc = (route_mark >>14)&0x3fff; + m3ua_ptr->msg.m3ua.opc = opc; + m3ua_ptr->msg.m3ua.dpc = dpc; +// memcpy(&m3ua_ptr->msg.m3ua.opc,&msgptr[7],3); + m3ua_ptr->msg_class = M3UA_MAUP_MSG; + m3ua_ptr->msg.m3ua.ni = nw; + m3ua_ptr->msg.m3ua.si = msgptr[3] & 0x0f; + m3ua_ptr->msg.m3ua.len = ntohs(len - 5); + m3ua_ptr->msg.m3ua.mp = 0; + m3ua_ptr->msg.m3ua.sls = sls; + m3ua_ptr->msg.m3ua.rc = get_m3ua_rc_by_dpc(nw, m3ua_ptr->msg.m3ua.dpc); + } + m3ua_ptr->msg.m3ua.link = outlink; + + put_m3ua_msg((xua_up_msg_t *)msgptr); + return; + } + else + { + dst_ip = mtp3_para->sg[mtp3_para->lk[outlink].e1_to_sg].ip; + /* debug show message */ + if (iptrans_msg_flow(msgptr,pclen,debugtype,dst_ip)); + /* debug show message */ + put_m2ua_msg((m2ua_up_msg_t *)msgptr); + return; + } + } +#endif + + +} + +int get_route_from_other_plat(u32 dpc, u8 nw, long dest_ip, BYTE chl) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + mtp3_iprt.io_msg.msgContent[3] = 0x1f; + mtp3_iprt.io_msg.msgContent[4] = nw; + memcpy(&mtp3_iprt.io_msg.msgContent[5], &dpc, 4); + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 6; + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + iptrDirectSendMsg(mtp3_iprt.io_msg); + return 1; +} + +void get_routes_from_other_plat() +{ + BYTE link,i; + BYTE lsno, nw, spplace; + DWORD dpc; + network *sp; + ls_info *ls; + + for(link=0; link<0xff;link++) + { + if(mtp3_para->lk[link].e1_lk_type == ((LKTYPE_M3UA<<1)+1)) + { + if(mtp3_para->lk[link].e1_to_mtp3 != mtp3_localip) + { + lsno = mtp3_para->lk[link].e1_to_linkset; + if (lsno >= 0x80) + return; + ls = &mtp3.ls[lsno]; + nw = mtp3_para->ls_pro[lsno] & 3; + sp = &mtp3.nw[nw]; + + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + dpc= mtp3_para->nw[nw].dpc[spplace]; + get_route_from_other_plat(dpc, nw, mtp3_para->lk[link].e1_to_mtp3, link); + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + dpc= mtp3_para->nw[nw].dpc[spplace]; + get_route_from_other_plat(dpc, nw, mtp3_para->lk[link].e1_to_mtp3, link); + } + } + } + + } +} + +BYTE get_route_value(u32 dpc, u8 nw) +{ + network *sp; + BYTE i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + + if (dpc==0) + return 0; + + sp = &mtp3.nw[nw]; + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,dpc); + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return 0; + + return sp->routine[i]; +} +int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, BYTE chl) +{ + network *sp; + int i; + mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; + int index; + ls_info *ls; + BYTE lsno; + WORD lsx16; + BYTE outroute; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno >= 0x80) + return 0; + if (dpc==0) + return 0; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + + sp = &mtp3.nw[nw]; + + index = Mtp3BinSearchValue(0,sort_rec->sortedNum-1,nw,dpc); + if ((index >= 0) && (index < 256)) + i = sort_rec->index[index]; + else + return 0; + sp->routine[i] = routine; + + outroute = (routine >> 6) & 3; + if ( outroute == 2 )/* no outbound route */ + { + memset(&ls_sls[lsx16],0xff,16); + } + else if ( (outroute == 0) && + ((routine & 3) == NLS_AVAILABLE) )/* current route is normal route */ + { + memset(&ls_sls[lsx16],chl,16); + } + else if ( ((routine >> 2) & 3) == ALS_AVAILABLE) + { + memset(&ls_sls[lsx16],chl,16); + } + return 1; +} + +int send_route_to_other_plat(u32 dpc, BYTE nw, BYTE routine, long dest_ip, BYTE chl) +{ + mtp3_iprt.io_msg.msgSrcPort = 4950; + mtp3_iprt.io_msg.msgDstPort = 4950; + mtp3_iprt.io_msg.msgDstIP = dest_ip; + mtp3_iprt.io_msg.msgContent[3] = 0x2f; + mtp3_iprt.io_msg.msgContent[4] = nw; + memcpy(&mtp3_iprt.io_msg.msgContent[5], &dpc, 4); + mtp3_iprt.io_msg.msgContent[9] = routine; + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 7; + mtp3_iprt.io_msg.msgLength = (mtp3_iprt.io_msg.msgContent[1]<<8) + mtp3_iprt.io_msg.msgContent[2]+3; + iptrDirectSendMsg(mtp3_iprt.io_msg); + return 1; + +} + +#endif +/* + * Referenced functions. + */ + +/* + * Forward declarations. + */ + +/* + * Consistent with link set and link functions of: + * + * Signalling Message Handling (SMH) + * Message Routing (HMRT) + * Figure 26/Q.704 + * + * Note:- the HMRT state machine is a single state state machine which is + * best organized as a series of function calls and the interrogation of the + * ls->statem.own_sp_restart flag. These link set and link functions are + * essentially subroutine calls made by the route set and route functions + * which are part of the MTPI. + */ + +void hmrt_tra_msg(BYTE linkset) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + int outlink; + + outlink = check_snmmsg_route(linkset); + if (outlink == -1) + return; + + ls = &mtp3.ls[linkset]; + nw = (mtp3_para->ls_pro[linkset] & 3); + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + sd_tmp_buf[10] = 0; + sd_tmp_buf[11] = SIGNAL_TRA; + } + else + { + route_mark = (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[linkset]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 6; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_TRA; + } + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); + mtp3.nw[nw].flow.MtoI[0]++; +} + +void sd_STM_msg(BYTE chl, BYTE MsgType) +{ + ls_info *ls; + BYTE nw; + long route_mark; + BYTE H1; + BYTE H0; + BYTE supplymsg; + BYTE ls_no; + int outlink=-1; + BYTE *sd_tmp_buf; + + ls_no = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[ls_no]; + nw = mtp3_para->ls_pro[ls_no] & 3; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if ( pc_length(nw) == MTP3_24BIT_PC ) + { + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[ls_no],3); + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + sd_tmp_buf[10] = mtp3_para->lk[chl].e1_to_slc; + sd_tmp_buf[11] = MsgType; + supplymsg = 11+1; + } + else + { + route_mark = (mtp3_para->lk[chl].e1_to_slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + mtp3_para->ls_op_pc[ls_no]; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 6; + sd_tmp_buf[3] = nw << 6; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = MsgType; + supplymsg = 8+1; + } + + H0 = MsgType & 0x0F; + H1 = MsgType >> 4; + + switch (H0) + { + case 1: + switch (H1) + { + case 1:/* COO */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = retrieved_bsnt[chl]; + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COO,SUP MSG=%d",chl,sd_tmp_buf[supplymsg]); + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COO,BSNT=%d",chl,retrieved_bsnt[chl]); + outlink = search_outbound_coLink(chl); + break; + case 2:/* COA */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = retrieved_bsnt[chl]; + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COA,SUP MSG=%d",chl,sd_tmp_buf[supplymsg]); + mtp3_debug(MTP3DB_EVENT,"Link %d SEND COA,BSNT=%d",chl,retrieved_bsnt[chl]); + outlink = search_outbound_coLink(chl); + break; + case 5:/* CBD */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = cbc_s[chl]; + outlink = search_outbound_coLink(chl); + break; + case 6:/* CBA */ + sd_tmp_buf[2] = sd_tmp_buf[2] + 1; + sd_tmp_buf[supplymsg] = cbd_cbc_r[chl]; + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + case 2: + switch (H1) + { + case 1:/* ECO */ + outlink = search_outbound_coLink(chl); + break; + case 2:/* ECA */ + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + case 6: + switch (H1) + { + case 1:// LIN + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 2:// LUN + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 3:// LIA + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 4:// LUA + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 5:// LID + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 6:// LFU + if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + outlink=chl; + else + outlink = search_outbound_coLink(chl); +/* if (outlink == -1) + outlink = chl;*/ + break; + case 7:// LLT + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + case 8:// LRT + if ((link_inhibited[chl] == TRUE) && (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)) + { + outlink=chl; + } + else if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) + outlink = chl; + else + outlink = search_outbound_coLink(chl); + break; + default: + break; + } + break; + default: + break; + } + if (outlink != -1) + { + sd_tmp_buf[0] = outlink; + send_mtp_msg(outlink,sd_tmp_buf); + } +} + +void hmrt_xxxx_adjacent_sp_restart(ls_info *ls) +{ + if ( own_sp_restarting ) + { + ls->adjacentsp_restarting = 1; + hmrt_xxxx_adjacent_sp_restart(ls); + } +} + +void hmrt_hmdc_message_for_routing(ls_info *ls) +{ +// ls_prim_t *p = (ls_prim_t *)mp->b_rptr; +// chl = &ls->device[p->sig.mh.rl.sls]; + /* + * This function is called only by the MTP state machines (HMCG) to route + * a message once the link set has been selected. + */ +// hmcg_hmrt_message(ls, mp); +} + +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw) +{ + network *sp; + BYTE routine; + + sp = &mtp3.nw[nw]; + routine = sp->routine[dst]; + + if (Nlinkset_status(routine) == LS_AVAILABLE) +// if ( Nls_state == 0 ) + sp->routine[dst] = sp->routine[dst] & 0x3f;/* current route is normal route */ + else if (Alinkset_status(routine) == LS_AVAILABLE) +// else if ( Als_state == 0 ) + sp->routine[dst] = ( sp->routine[dst] & 0x3f ) + 0x40;/* current route is Alternative route */ + else + sp->routine[dst] = ( sp->routine[dst] & 0x3f ) + 0x80;/* no route */ +} + +void hmrt_sltc_signalling_link_test_msg(BYTE chl) +{ + BYTE linkset; + ls_info *ls; + WORD sp_place; + BYTE nw; + long route_mark; + BYTE *sd_tmp_buf; + BYTE slc; + + linkset = mtp3_para->lk[chl].e1_to_linkset; + if (linkset > 127) + { + mtp3_debug(MTP3DB_EVENT,"Warning!! link %d doesn't asign a linkset,stop test procedure",chl); + return; + } + nw = (mtp3_para->ls_pro[linkset]) & 3; + ls = &mtp3.ls[linkset]; + sp_place = ls->adjacent_sp_place; + if (sp_place > 255) + { + mtp3_debug(MTP3DB_EVENT,"Warning!! linkset %d remote SPC doesn't config in the routine table,stop test procedure",linkset); + return; + } + slc = mtp3_para->lk[chl].e1_to_slc; + + sd_tmp_buf = &mtp3_iprt.io_msg.msgContent[0]; + if (pc_length(nw) == MTP3_24BIT_PC) + { + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 12; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&mtp3_para->ls_op_pc[linkset],3); + memcpy(&sd_tmp_buf[7],&mtp3_para->nw[nw].opc24,3); + sd_tmp_buf[10] = slc; + sd_tmp_buf[11] = SIGNAL_SLTM; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[12] = 0x20+slc; + else + sd_tmp_buf[12] = 0x20; + sd_tmp_buf[13] = chl; + sd_tmp_buf[14] = slc; + } + else + { + route_mark = (slc << 28) + (mtp3_para->nw[nw].opc14 << 14) + (mtp3_para->ls_op_pc[linkset]); + sd_tmp_buf[0] = chl; + sd_tmp_buf[1] = 0; + sd_tmp_buf[2] = 9; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[3] = (nw << 6) + 2; + else + sd_tmp_buf[3] = (nw << 6) + 1; + memcpy(&sd_tmp_buf[4],&route_mark,4); + sd_tmp_buf[8] = SIGNAL_SLTM; + if (mtp3ObjState.lk_SpecANSI_flag[chl] == 1) + sd_tmp_buf[9] = 0x20+slc; + else + sd_tmp_buf[9] = 0x20; + sd_tmp_buf[10] = chl; + sd_tmp_buf[11] = slc; + } + + send_mtp_msg(chl,sd_tmp_buf); +} + +void hmrt_tcbc_changeback_ack(BYTE chl) +{ + sd_STM_msg(chl,SIGNAL_CBA); +} + +void hmrt_tcbc_changeback_declaration(BYTE chl) +{ + +/* for ( i=0; i> 2) & 3) == 0 ) + return LS_AVAILABLE; + else + return LS_UNAVAILABLE; +} + +int scan_ls_link_available(BYTE ls_no) +{ + int chl,lk_available; + + lk_available = 0; + for(chl=0; chl < 256; chl++) + { + if(mtp3ObjState.link_l3_state[chl] == AVAILABLE && mtp3_para->lk[chl].e1_to_linkset == ls_no) + lk_available++; + } + return lk_available; +} +void hmrt_tcbc_update_routing_tables(BYTE chl) +{ + BYTE i,j; + ls_info *ls; + network *sp; + DWORD nw; + unsigned int lsno; + WORD lsx16; + DWORD spplace; + BYTE link_num; + unsigned int sls; + BYTE *routine; + BYTE link_already_available; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + if (lsno > 127) + return; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + nw = mtp3_para->ls_pro[lsno] & 3; + link_num = ls->linksNum_configured; +// link_num = linknum_in_ls[lsno]; + if (link_num == 0) + { + mtp3_debug(MTP3DB_EVENT,"linkset %d havn't config active link",lsno); +// mtp_send_error("Linkset",lsno,"LINKSET HAVN'T CONFIG ACTIVE LINK"); + return; + } + link_already_available = mtp3ObjState.link_l3_state[chl]; + ls->links_available_t = scan_ls_link_available(lsno); + mtp3ObjState.link_l3_state[chl] = AVAILABLE; + set_heartbeat(ALARM_LINK_AVAILABLE,chl); + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0);//clear alarm + + if ( ls->links_available_t > 0 )/* WITHIN LS */ + { + for ( j=0; j<16; j++ ) + { + sls = lsx16+j; + if ( (ls_sls[sls] != chl) && + (sls_to_link[sls] == chl) ) + ls_sls[sls] = chl; + } + } + + else + { + current_active_ls_num++; + current_measure->ls_measure[lsno][2]++;/* STOP of link set failure */ + sp = &mtp3.nw[nw]; + memset(&ls_sls[lsx16],chl,16); + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + routine = (BYTE*)&sp->routine[spplace]; + if (Nlinkset_status(*routine) == LS_AVAILABLE) + *routine = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + { + (*routine) = ((*routine) & 0x3f) + 0x80; + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + routine = (BYTE*)&sp->routine[spplace]; + if ( (*routine) >> 6 == 2 )/* no route */ + { + (*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */ + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],AVAILABLE); + } + + if (Nlinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f);/* current route is normal linkset */ + else if (Alinkset_status(*routine) == LS_AVAILABLE) + (*routine) = ((*routine) & 0x3f) + 0x40; + else + (*routine) = ((*routine) & 0x3f) + 0x80; + } + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(lsno+MTP3_LINKSET_COMPONENT,0); + set_heartbeat(ALARM_LS_AVAILABLE,lsno); + } + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0); + + if ( ls->links_available_t > 0 )/* within ls */ + mtp3_debug(MTP3DB_EVENT,"\33[32mLink %d L3 in service,links_available_t=%d\33[0m",chl, ls->links_available_t); + else + mtp3_debug(MTP3DB_EVENT,"\33[32mLink %d L3 in service,Linkset %d in service\33[0m",chl,lsno); + if(link_already_available != AVAILABLE) + ls->links_available_t++; + else + mtp3_debug(MTP3DB_ERROR,"update routing table fail, links=%d have already available", chl); + current_measure->lk_measure1[chl][1]++;/* local changeback */ +// printf("\r\n tcbc %d update routine cmp link_available = %d \n\r",chl, ls->links_available_t); +} + +void sp_unaccessable(BYTE *routine) +{ + (*routine) = ((*routine) & 0x3f) + 0x80; +} + +void hmrt_tcoc_update_routing_tables(BYTE chl) +{ + BYTE i,j; + ls_info *ls; + network *sp; + DWORD nw; + int lsno; + int lsx16; + BYTE select_slc; + BYTE slc[16]; + DWORD spplace; + int link; + BYTE lk_available; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx16 = lsno << 4; + + ls->links_available_t = scan_ls_link_available(lsno); + lk_available = mtp3ObjState.link_l3_state[chl]; + nw = mtp3_para->ls_pro[lsno] & 3; + if (link_inhibited[chl] == TRUE) + mtp3ObjState.link_l3_state[chl] = INHIBITED; + else + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + set_heartbeat(ALARM_LINK_UNAVAILABLE,chl); + if (ls->links_available_t > 0 && lk_available == AVAILABLE) + ls->links_available_t--; + else + mtp3_debug(MTP3DB_ERROR,"hmrt_tcoc_update routing table fail, links=%d have already unavailable", chl); + if ( ls->links_available_t > 0 )/* within ls */ + { + j = 0; + for ( i=0; i<16; i++ ) + { + link = ls_slc[lsx16+i]; + if ( (link != chl) && (mtp3ObjState.link_l3_state[link] == AVAILABLE) ) + { + slc[j] = link; + j++; + } + } + + for ( j=0; j<16; j++ ) + { + if (ls_sls[lsx16+j] == chl) + { + if (ls->links_available_t == 0) + { + mtp3_debug(MTP3DB_ERROR,"LINKSET %d ERROR,LINKS AVAILABLE = 0\n\r",lsno); + return; + } + select_slc = (j % ls->links_available_t); + ls_sls[lsx16+j] = slc[select_slc]; + } + } +/* if (mtp3_para->lk[chl].e1_to_mtp3 == mtp3_localip) + mtp3_send_alarm(0,0);*/ + } + + + else/* changeover between link set */ + { + current_measure->ls_measure[lsno][1]++;/* Start of link set failure */ + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asNLS[i]; + if ( ((sp->routine[spplace] >> 2) & 3) == 0 )/*alternative route available */ + sp->routine[spplace] = (sp->routine[spplace] & 0x3f) + 0x40;/* current route change from normal linkset to alternative linkset */ + else/* sp not accessible */ + { + sp_unaccessable(&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + } + + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + spplace = ls->influ_dstplace_intable_asALS[i]; + if ( (sp->routine[spplace] & 3) != 0 )/* normal route unavailable */ + { + sp_unaccessable(&sp->routine[spplace]); + primitive_to_userpart(nw,mtp3_para->nw[nw].dpc[spplace],UNAVAILABLE); + } + } + + memset(&ls_sls[lsx16],0xff,16); + + set_heartbeat(ALARM_LS_UNAVAILABLE,lsno); + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + mtp3_send_alarm(lsno+MTP3_LINKSET_COMPONENT,1); + } + + current_measure->lk_measure1[chl][0]++;/* local changeover */ + if ( ls->links_available_t > 0 )/* within ls */ + mtp3_debug(MTP3DB_EVENT,"\33[31mLink %d L3 out of service, links_available_t=%d\33[0m",chl, ls->links_available_t); + else + mtp3_debug(MTP3DB_EVENT,"\33[31mLink %d L3 out of service,Linkset %d out of service\33[0m",chl,lsno); +// printf("/r/ntcoc %d update routine cmp link_available = %d \n",chl, ls->links_available_t); +} + +void send_ip_to_mtp2()/* send message to mtp2, tell mtp2 which is it's host mtp3 */ + /* this message send every 16 second */ +{ + static int mtp2_subsys = 0; + int i,j; + int basePort; + BYTE *msgContent; + BYTE e1_to_mtp3; + + basePort = mtp2_subsys*8; + for (i=0;i<8;i++) + { + if ((mtp3ObjState.lk_mtp3[basePort+i] == mtp3_localip) && + (mtp3ObjState.lk_configured[basePort+i] == PARA_CONFIGURED) ) + { + mtp3_iprt.io_msg.msgLength = 14+1; + mtp3_iprt.io_msg.msgContent[0] = 0; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 12; + mtp3_iprt.io_msg.msgContent[3] = 0xff; + mtp3_iprt.io_msg.msgContent[4] = 0xee; + mtp3_iprt.io_msg.msgContent[5] = 0xff; + msgContent = &mtp3_iprt.io_msg.msgContent[6]; + for (j=0;j<8;j++) + { + + e1_to_mtp3 = mtp3ObjState.lk_mtp3[basePort+j]; + if ((e1_to_mtp3 != mtp3_localip) || + (mtp3ObjState.lk_configured[basePort+j] != PARA_CONFIGURED) ) + msgContent[j] = 0xee; + else + msgContent[j] = ((e1_to_mtp3 >> 16) & 0xff)-32;// 172.18.x+32.1 + } + msgContent[8] = mtp3_para->nw_pro; + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send IP to MTP2 %d",mtp2_subsys); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],14+1); + send_to_mtp2(LINK_TO_IP(basePort)); + break; + } + } + mtp2_subsys = (mtp2_subsys+1) & 0x1f; +} + +void send_command_to_mtp2(BYTE chl, BYTE command) +{ + char charCmd[32]; + + mtp3_iprt.io_msg.msgLength = 5+1; + mtp3_iprt.io_msg.msgContent[0] = chl; + mtp3_iprt.io_msg.msgContent[1] = 0; + mtp3_iprt.io_msg.msgContent[2] = 3; + mtp3_iprt.io_msg.msgContent[3] = 0xff; + mtp3_iprt.io_msg.msgContent[4] = ((mtp3ObjState.lk_mtp3[chl] >> 16) & 0xff)-32;// 172.18.x+32.1 + mtp3_iprt.io_msg.msgContent[5] = command; + + switch (command) + { + case MTP2_ACTIVE_LINK: + command3[chl] = MTP2_ACTIVE_LINK; + sprintf(charCmd,"MTP2_ACTIVE_LINK"); + break; + case MTP2_DEACTIVE_LINK: + command3[chl] = MTP2_DEACTIVE_LINK; + sprintf(charCmd,"MTP2_DEACTIVE_LINK"); + break; + case MTP2_STOP_L2: + if (link_inhibited[chl] != TRUE) + { + command3[chl] = MTP2_STOP_L2; + } + else + return; + sprintf(charCmd,"MTP2_STOP_L2"); + break; + case MTP2_EMERGEN_ALIGNMENT: + command3[chl] = MTP2_EMERGEN_ALIGNMENT; + sprintf(charCmd,"MTP2_EMERGEN_ALIGNMENT"); + break; + case MTP2_RETRIEVE:/* not support */ +/* command3[chl] = MTP2_RETRIEVE; + iprt.io_msg.msgLength = 5; + iprt.io_msg.msgContent[1] = 3; + iprt.io_msg.msgContent[4] = fsnc[chl]; + break;*/ + return; + case MTP3_M2UA_ENABLE: + sprintf(charCmd,"ENABLE M2UA LINK"); + break; + default: + break; + } + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN ||MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + { + mtp3_debug(MTP3DB_PRIMITIVE_MSG,"MTP3 send command %s to link %d",charCmd,chl); + mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,&mtp3_iprt.io_msg.msgContent[0],5+1); + } + if (MTP3_LINK_TYPE(chl) == LKTYPE_NONE_SIGTRAN) + send_to_mtp2(LINK_TO_IP(chl)); +#if _INCLUDE_M2UA + else if (MTP3_LINK_TYPE(chl) == LKTYPE_SIGTRAN) + put_m2ua_msg((m2ua_up_msg_t *) mtp3_iprt.io_msg.msgContent); +#endif +} +/*@end@*/ diff --git a/omc/plat/mtp3_old/src/mtpsrm.c b/omc/plat/mtp3_old/src/mtpsrm.c new file mode 100644 index 0000000..ba3863a --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpsrm.c @@ -0,0 +1,336 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void hmrt_srm_msg(BYTE linkset, BYTE MsgType, long dst); +void hmrt_tfrc_update_routing_tables(BYTE dst, BYTE nw); +void tsrc_fun6(BYTE link,BYTE nw,BYTE sp_place); +void tsrc_fun8(BYTE ls,BYTE nw,BYTE sp_place); +int find_dst_place(long dst,BYTE ls); + +void mark_alternative_linkset_available(BYTE *routine) +{ + (*routine) = ( (*routine) & 0xc3 ) + 0x10;/* mark alternative route use and acessible*/ +} + +void mark_alternative_linkset_unavailable(BYTE *routine) +{ + (*routine) = ((*routine) & 0xf3 ) + 0x08;/* mark alternative route can't use */ +} + +void mark_normal_linkset_available(BYTE *routine) +{ + (*routine) = ((*routine) & 0xcc) + 0x10;/* mark normal route can use,and acessible */ +} + +void mark_normal_linkset_unavailable(BYTE *routine) +{ + (*routine) = ((*routine) & 0xfc) + 0x02;/* mark normal route unavailable */ +} + +void mark_dstSP_inaccessible(BYTE *routine) +{ + (*routine) = ((*routine) & 0xcf);/* mark destination sp inaccessible */ +} + +int find_directLS_to_dst(long dst) +{ + BYTE i; + + for ( i=0; i<128; i++ ) + { + if ( mtp3_para->ls_op_pc[i] == dst ) + return i; + } + return 128; +} + +void tsrc_rtpc_signalling_route_unavailable(BYTE dst, BYTE nw) +{ + BYTE ls; + network *sp; + BYTE msgopc; + BYTE nls; + BYTE als; + + nls = mtp3_para->nw[nw].normal_ls[dst]; + als = mtp3_para->nw[nw].alternative_ls[dst]; + sp = &mtp3.nw[nw]; + msgopc = TFPmsg_OPC; + ls = mtp3_para->lk[TFPmsg_SrcLk].e1_to_linkset; + + if ( ls > 127 ) + return; + if ( mtp3.ls[ls].adjacentsp_restarting == 1 )/* adjacent sp restarting */ + { + if (nls == ls) + mark_normal_linkset_unavailable(&sp->routine[dst]); + else if (als == ls) + mark_alternative_linkset_unavailable(&sp->routine[dst]); + } + else + { + if ( nls == ls ) + { + if ( (sp->routine[dst] >> 6) == 2 ) + return; + tsrc_fun6(TFPmsg_SrcLk,nw,dst); + hmrt_tfrc_update_routing_tables(dst,nw); + } + else if ( als == ls ) + { + tsrc_fun6(TFPmsg_SrcLk,nw,dst); + hmrt_tfrc_update_routing_tables(dst,nw); + } + } +} + +void tsrc_rtac_signalling_route_available(BYTE dst, BYTE nw) +{ + int ls; + network *sp; + DWORD msgopc; + BYTE nls_t; + BYTE als_t; + BYTE current_route; + WORD msgopc_place; + int lsnoRSP_is_msgOPC; + + sp = &mtp3.nw[nw]; + current_route = sp->routine[dst] >> 6; + msgopc = TFAmsg_OPC; + ls = mtp3_para->lk[TFAmsg_SrcLk].e1_to_linkset; + if ( ls > 127 ) + return; + lsnoRSP_is_msgOPC = find_directLS_to_dst(msgopc); + if ( lsnoRSP_is_msgOPC == 128 ) + return;/* msg opc is not any linkset's remote sp */ + msgopc_place = mtp3.ls[lsnoRSP_is_msgOPC].adjacent_sp_place; + if (msgopc_place > 255) + return; + + if ( !own_sp_restarting ) + { + if ( ((sp->routine[msgopc_place] >> 4) & 3) == SP_ACCESSIBLE )/* msg opc accessible */ + tsrc_fun8(ls,nw,dst); + + else/* msg opc inacessible */ + { +// mtp3_debug(MTP3_DEBUG_LOG,"msgopc inacessible\n\r"); + sp->rtac_input[msgopc_place] = RTAC_DEST_ACCESSIBLE;/* send tfa to all adjacent sp */ + + nls_t = mtp3_para->nw[nw].normal_ls[msgopc_place]; + als_t = mtp3_para->nw[nw].alternative_ls[msgopc_place]; + mtp3ObjInput.taprc_input[lsnoRSP_is_msgOPC] = TPRC_ADJACENT_SP_RESTARTING; + + if ( nls_t == ls ) + mark_normal_linkset_available(&sp->routine[msgopc_place]); + else if ( als_t == ls ) + mark_alternative_linkset_available(&sp->routine[msgopc_place]); + current_measure->ls_measure[ls][4]++;/* Broadcast TFA for recovery of measured linkset */ + } + } + hmrt_tfrc_update_routing_tables(msgopc_place,nw); + hmrt_tfrc_update_routing_tables(dst,nw); +} + +void rtpc_proc(BYTE netw,BYTE dst) +{ + network *nw; + BYTE ls; + + nw = &mtp3.nw[netw]; + switch ( nw->rtpc_state[dst] ) + { + case RTPC_IDLE_STATE: + switch ( nw->rtpc_input[dst] ) + { + case RTPC_RSRT_SEND_TFP_MSG:/* not supported */ + nw->rtpc_input[dst] = IDLE; + hmrt_srm_msg(sdTFP_Ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_state[dst] = RTPC_WAIT_STATE; + break; + + case RTPC_TSRC_SEND_TFP_MSG:/* send tfp message to linkset opposit sp */ +// printf("send tfp message to linkset %d,TFDPC=%lx\n",sdTFP_Ls,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_input[dst] = IDLE; + hmrt_srm_msg(sdTFP_Ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]); + nw->rtpc_state[dst] = RTPC_WAIT_STATE; + break; + + case RTPC_DEST_INACCESSIBLE:/*one dst inaccessible, send tfp to all adjacent sp about this dst */ + nw->rtpc_input[dst] = IDLE; + for ( ls=0; ls<128; ls++ ) + { + if ((mtp3_para->ls_pro[ls] & 3) == netw) + { +// printf("send tfp message to linkset %d,TFDPC=%lx\n",ls,mtp3_para->nw[netw].dpc[dst]); + hmrt_srm_msg(ls,SIGNAL_TFP,mtp3_para->nw[netw].dpc[dst]);/* send tfp to adjacent sp */ + } + } + if (own_sp_restarting == 1) + { +// hmrt_tra_msg(ls);//printf("send tra\n"); + mtp3ObjInput.tprc_input = TPRC_RTPC_TFP_SENT; + } + break; + + case RTPC_TFP_MSG:/* receive TFP from other sp */ +// printf("rtpc dst %d tfp\n",dst); + nw->rtpc_input[dst] = IDLE; + if ( controlled_rerouting_in_progress[dst] == TRUE ) + transfer_prohibited[dst] = TRUE; + else + { + tsrc_rtpc_signalling_route_unavailable(dst,netw); + if (!own_sp_restarting) + { + nw->rsrt_input[dst] = RSRT_RTPC_ROUTE_SET_TEST; + } + //if sp isn't restarting + //start route set test + } + break; + + case RTPC_CTRL_RERT_TERMINATED:/* not supported */ + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = FALSE; + if ( transfer_prohibited[dst] == TRUE ) + { + transfer_prohibited[dst] = FALSE; + //tsrc_rtpc_signalling_route_unavailable + //if sp isn't restarting + //start route set test + } + break; + + case RTPC_CONTROLLED_RERT:/* not supported */ + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = TRUE; + break; + + case RTPC_RESTART_BEGINS: + nw->rtpc_input[dst] = IDLE; + controlled_rerouting_in_progress[dst] = FALSE; + transfer_prohibited[dst] = FALSE; + /* mark sp restarting */ + break; + + case RTPC_RESTART_ENDS: + nw->rtpc_input[dst] = IDLE; + /* cancel sp restarting */ + break; + } + break; + + case RTPC_WAIT_STATE: + nw->rtpc_state[dst] = RTPC_IDLE_STATE; + break; + } +} + +void rtac_proc(BYTE netw,BYTE dst) +{ + network *nw; + BYTE ls; + + nw = &mtp3.nw[netw]; + switch ( nw->rtac_input[dst] ) + { + case RTAC_TFA_MSG: + nw->rtac_input[dst] = IDLE; + tsrc_rtac_signalling_route_available(dst,netw); + nw->rsrt_input[dst] = RSRT_RTAC_ROUTE_AVAILABLE; + break; + + case RTAC_DEST_ACCESSIBLE:// one dst become accessible, send tfa to all adjacent sp about this dst + nw->rtac_input[dst] = IDLE; + for ( ls=0; ls<128; ls++ ) + { + if ( (mtp3_para->ls_pro[ls] & 3) == netw) + { + hmrt_srm_msg(ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]);/* send tfa to adjacent sp */ + } + } + break; + + case RTAC_STP_NOLONGER_FOR_DEST: + nw->rtac_input[dst] = IDLE; + hmrt_srm_msg(sdTFA_Ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]); + break; + + case RTAC_SEND_TFA_MSG: + nw->rtac_input[dst] = IDLE; + hmrt_srm_msg(sdTFA_Ls,SIGNAL_TFA,mtp3_para->nw[netw].dpc[dst]); + break; + + case RTAC_FORCED_RERT: + break; + + case RTAC_FORCED_RERT_TERMINATED: + break; + + case RTAC_FORCED_RERT_NOT_REQ: + break; + + case RTAC_RESTART_BEGINS: + break; + + case RTAC_RESTART_ENDS: + break; + } +} + +void rsrt_proc(BYTE netw,BYTE dst) +{ + network *nw; + + nw = &mtp3.nw[netw]; + switch (nw->rsrt_state[dst]) + { + case RSRT_IDLE_STATE: + switch (nw->rsrt_input[dst]) + { + case RSRT_RTPC_ROUTE_SET_TEST: + nw->rsrt_t10[dst] = 0; + nw->rsrt_state[dst] = RSRT_WAIT_STATE; + break; + case RSRT_TSRC_ROUTE_SET_TEST: + hmrt_srm_msg(mtp3_para->nw[netw].normal_ls[dst],SIGNAL_RST,mtp3_para->nw[netw].dpc[dst]); + break; + default: + break; + } + break; + case RSRT_WAIT_STATE: + nw->rsrt_t10[dst] ++; + switch (nw->rsrt_input[dst]) + { + case RSRT_RTPC_ROUTE_SET_TEST: + break; + case RSRT_TSRC_ROUTE_SET_TEST: + break; + case RSRT_RTAC_ROUTE_AVAILABLE: + nw->rsrt_t10[dst] = 0; + nw->rsrt_state[dst] = RSRT_IDLE_STATE; + break; + default: + break; + } + if (nw->rsrt_t10[dst] >= mtp3_para->mtp3_t10) + { + hmrt_srm_msg(mtp3_para->nw[netw].normal_ls[dst],SIGNAL_RST,mtp3_para->nw[netw].dpc[dst]); + //send route test message out + nw->rsrt_t10[dst] = 0; + } + break; + default: + break; + + } + nw->rsrt_input[dst] = IDLE; +} +/*@end@*/ + diff --git a/omc/plat/mtp3_old/src/mtpstm.c b/omc/plat/mtp3_old/src/mtpstm.c new file mode 100644 index 0000000..75e6426 --- /dev/null +++ b/omc/plat/mtp3_old/src/mtpstm.c @@ -0,0 +1,2203 @@ +#include "./include/mtp3.h" +#include "./include/mtpstm.h" +#include "./include/mtpext.h" +#include "./include/mtpfunc.h" + +/*@ignore@*/ +void hmrt_tcoc_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_order(BYTE chl); +void hmrt_tcoc_emergency_changeover_ack(BYTE chl); +void hmrt_tcoc_changeover_ack(BYTE chl); +void hmrt_tcoc_update_routing_tables(BYTE chl); +void mark_alternative_linkset_available(BYTE *routine); +void mark_alternative_linkset_unavailable(BYTE *routine); +void mark_normal_linkset_available(BYTE *routine); +void mark_normal_linkset_unavailable(BYTE *routine); +void mark_dstSP_inaccessible(BYTE *routine); +BOOL Alinkset_status(BYTE routine); +BOOL Nlinkset_status(BYTE routine); +/* by simon at 23/9/26 */ +mtp3_dpc_index mtp3SortRoutine; +_mtp3_state mtp3ObjState; +_mtp3_input mtp3ObjInput; +_mtp3_IPMng MTP3IPMng; + +void start_mtp3T12(BYTE link) +{ + t12_delay_mtp3[link] = mtp3_para->lt[link].t12; + mtp3_t12_flag[link] = TIMER_START; +} + +void stop_mtp3T12(BYTE link) +{ + t12_delay_mtp3[link] = mtp3_para->lt[link].t12;//not decided + mtp3_t12_flag[link] = TIMER_STOP; +} + +void stop_mtp3T21(BYTE linkset) +{ + t21_delay_mtp3[linkset] = mtp3_para->mtp3_t21; + mtp3_t21_flag[linkset] = TIMER_STOP; +} + +void start_mtp3T21(BYTE linkset) +{ + t21_delay_mtp3[linkset] = mtp3_para->mtp3_t21; + mtp3_t21_flag[linkset] = TIMER_START; +} + +void tsrc_fun5(BYTE linkset) +{ + int i; + BYTE nw; + network *sp; + BYTE sp_place; + ls_info *ls; + BYTE rs_2;/* normal route and alternative route status */ + + if (linkset > 127) + return; + nw = mtp3_para->ls_pro[linkset] & 3; + ls = &mtp3.ls[linkset]; + ls->adjacentsp_restarting = 0;/* cancel adjacent sp restarting */ + + /* not support RSRT */ + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + rs_2 = sp->routine[sp_place]; + if (((rs_2 >> 6) & 3) == 2)// spc unreachable + { + mtp3.nw[nw].rsrt_input[sp_place] = RSRT_TSRC_ROUTE_SET_TEST; + } + if ((Nlinkset_status(rs_2) == LS_AVAILABLE) && + (Alinkset_status(rs_2) == LS_UNAVAILABLE) ) +/* if ( ((rs_2 & 3) == NLS_AVAILABLE) && + (((rs_2 >> 2) & 3) == ALS_UNAVAILABLE) )*/ + {/* sp just accesible */ + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + } + hmrt_tfrc_update_routing_tables(sp_place,nw); + } + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + rs_2 = sp->routine[sp_place]; + if (((rs_2 >> 6) & 3) == 2)// spc unreachable + { + mtp3.nw[nw].rsrt_input[sp_place] = RSRT_TSRC_ROUTE_SET_TEST; + } + if ((Nlinkset_status(rs_2) == LS_UNAVAILABLE) && + (Alinkset_status(rs_2) == LS_AVAILABLE) ) +/* if ( ((rs_2 & 3) == NLS_UNAVAILABLE) && + (((rs_2 >> 2) & 3) == ALS_AVAILABLE) )*/ + {/* sp just accesible */ + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + } + hmrt_tfrc_update_routing_tables(sp_place,nw); + } +} + +void mtp3T21_expired(BYTE linkset) +{ + tsrc_fun5(linkset); +} + +void start_mtp3T22(BYTE link) +{ + t22_delay_mtp3[link] = 20; + mtp3_t22_flag[link] = TIMER_START; +} + +void start_mtp3T23(BYTE link) +{ + t23_delay_mtp3[link] = 20; + mtp3_t23_flag[link] = TIMER_START; +} + +void start_mtp3T13(BYTE link) +{ + t13_delay_mtp3[link] = mtp3_para->lt[link].t13; + mtp3_t13_flag[link] = TIMER_START; +} + +void stop_mtp3T13(BYTE link) +{ + t13_delay_mtp3[link] = mtp3_para->lt[link].t13; + mtp3_t13_flag[link] = TIMER_STOP; +} + +void stop_mtp3T14(BYTE link) +{ + t14_delay_mtp3[link] = mtp3_para->lt[link].t14; + mtp3_t14_flag[link] = TIMER_STOP; +} + +void start_mtp3T14(BYTE link) +{ + t14_delay_mtp3[link] = mtp3_para->lt[link].t14; + mtp3_t14_flag[link] = TIMER_START; +} + +void mtp3Timer_proc(BYTE i) +{ + if (mtp3_t12_flag[i] == TIMER_START) + { + t12_delay_mtp3[i] --; + if (t12_delay_mtp3[i] == 0) + { + mtp3_t12_flag[i] = TIMER_STOP; + t12_delay_mtp3[i] = mtp3_para->lt[i].t12; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T12_EXPIRED; + } + } + + if (mtp3_t13_flag[i] == TIMER_START) + { + t13_delay_mtp3[i] --; + if (t13_delay_mtp3[i] == 0) + { + mtp3_t13_flag[i] = TIMER_STOP; + t13_delay_mtp3[i] = mtp3_para->lt[i].t13; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T13_EXPIRED; + } + } + + if (mtp3_t14_flag[i] == TIMER_START) + { + t14_delay_mtp3[i] --; + if (t14_delay_mtp3[i] == 0) + { + mtp3_t14_flag[i] = TIMER_STOP; + t14_delay_mtp3[i] = mtp3_para->lt[i].t14; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T14_EXPIRED; + } + } + + if (mtp3_t22_flag[i] == TIMER_START) + { + t22_delay_mtp3[i] --; + if (t22_delay_mtp3[i] == 0) + { + mtp3_t22_flag[i] = TIMER_STOP; + t22_delay_mtp3[i] = mtp3_para->lt[i].t22; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T22_EXPIRED; + } + } + + if (mtp3_t23_flag[i] == TIMER_START) + { + t23_delay_mtp3[i] --; + if (t23_delay_mtp3[i] == 0) + { + mtp3_t23_flag[i] = TIMER_STOP; + t23_delay_mtp3[i] = mtp3_para->lt[i].t23; + mtp3ObjInput.tlac_input_from_Tctl[i] = TLAC_T23_EXPIRED; + } + } + + i = i & 127; + if (mtp3_t21_flag[i] == TIMER_START) + { + t21_delay_mtp3[i] --; + if (t21_delay_mtp3[i] == 0) + { + mtp3_t21_flag[i] = TIMER_STOP; + t21_delay_mtp3[i] = mtp3_para->mtp3_t21; + mtp3T21_expired(i); + } + } +} + +void mtp3_send_tfp(BYTE link,BYTE nw,BYTE index) +{ + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + mtp3.nw[nw].rtpc_input[index] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = mtp3_para->lk[link].e1_to_linkset; + rtpc_proc(nw,index); + } +} + +void tsrc_fun6(BYTE link,BYTE nw,BYTE sp_place) +{ + BYTE ls; + BYTE nls; + BYTE als; + BYTE *routine; + int lsx16; + int i; + + network *sp; + sp = &mtp3.nw[nw]; + ls = mtp3_para->lk[link].e1_to_linkset; + + + nls = mtp3_para->nw[nw].normal_ls[sp_place]; + als = mtp3_para->nw[nw].alternative_ls[sp_place]; + + routine = (BYTE*)&sp->routine[sp_place]; + + + if (ls == nls)/* normal route unavailable */ + { +// printf("link %d unavailable,Nls %d UNAVAILABLE\n",link,nls); + mark_normal_linkset_unavailable(&sp->routine[sp_place]); + if (Alinkset_status(*routine) == LS_AVAILABLE) +// if ( (((*routine) >> 2) & 3) == ALS_AVAILABLE )/* Alternative route available */ + /* this destination has alternative route */ + {/* new stp use for destination */ + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { +// printf("link %d send TFP via ALS\n",link); + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = als; + rtpc_proc(nw,sp_place); + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d spc %lx normal linkset %d unavailable,send TFP to Als %d remote sp",nw,mtp3_para->nw[nw].dpc[sp_place],ls,als); + } + //mark new stp used for destination + } + else + { + lsx16 = ls*16; + for (i=0; i<16; i++) + { + if (mtp3ObjState.link_l3_state[ls_slc[lsx16+i]] == INHIBITED) /* some link inhibited in alternative linkset */ + mtp3ObjInput.tlac_input_from_stm[ls_slc[lsx16+i]] = TLAC_UINHIBIT_SIGLINK_FROM_TSRC; + } + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + sp->rtpc_input[sp_place] = RTPC_DEST_INACCESSIBLE;/* broadcast tfp */ + rtpc_proc(nw,sp_place); +// printf("mark send tfp to adjacent sp\n"); + current_measure->ls_measure[ls][3]++;/* Broadcast TFP due to failure of measured link set */ + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx normal linkset %d unavailable,Unreachable!!,broad cast TFP",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + } + else + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx normal linkset %d unavailable,Unreachable!!",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + //tsfc_tsrc_destination_inacessible + } + } + else if (ls == als)/* als unavailable */ + { + mark_alternative_linkset_unavailable(&sp->routine[sp_place]); + if (Nlinkset_status(*routine) == LS_AVAILABLE) +// if ( ((*routine) & 3) == NLS_AVAILABLE ) + { + } + else + { + lsx16 = ls*16; + for (i=0; i<16; i++) + { + if (mtp3ObjState.link_l3_state[ls_slc[lsx16+i]] == INHIBITED) /* some link inhibited in alternative linkset */ + mtp3ObjInput.tlac_input_from_stm[ls_slc[lsx16+i]] = TLAC_UINHIBIT_SIGLINK_FROM_TSRC; + } + if (mtp3ObjState.lk_mtp3[link] == mtp3_localip) + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx alternative linkset %d unavailable,broadcast TFP",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + sp->rtpc_input[sp_place] = RTPC_DEST_INACCESSIBLE;/* broadcast tfp */ + rtpc_proc(nw,sp_place); +// printf("mark send tfp to adjacent sp,because als unavailable\n"); + current_measure->ls_measure[ls][3]++;/* Broadcast TFP due to failure of measured link set */ + } + else + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc %lx alternative linkset %d unavailable,Unreachable!!",nw,mtp3_para->nw[nw].dpc[sp_place],ls); + //tsfc_tsrc_destination_inacessible + } + } + if ( (sp->routine[sp_place] & 0x0f) == 0x0a) + { + mark_dstSP_inaccessible(&sp->routine[sp_place]); + } +} + + +void tsrc_fun8(BYTE ls,BYTE nw,BYTE sp_place) +{ + BYTE nls; + BYTE als; + BYTE *routine; + + network *sp; + sp = &mtp3.nw[nw]; + + nls = mtp3_para->nw[nw].normal_ls[sp_place]; + als = mtp3_para->nw[nw].alternative_ls[sp_place]; + + routine = (BYTE*)&sp->routine[sp_place]; + + if ( ((*routine) >> 4) & 3 )/* dst acessible */ + { + if (nls == ls) + { + if (Nlinkset_status(*routine) == LS_UNAVAILABLE) +// if ( ((*routine) & 3) == NLS_UNAVAILABLE) + { + if ( ((*routine) & 0x0C) == ALS_UNAVAILABLE) + {/* new stp use for destination */ + } + else/* als available,route change back to normal route + * stp no longer use for destination */ + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_STP_NOLONGER_FOR_DEST; + sdTFA_Ls = als; + rtac_proc(nw,sp_place); + mtp3_debug(MTP3DB_EVENT,"[tsrc]net%d,spc%lx normal linkset %d available,no long use als %d for routing,send TFA to als RSP",nw,mtp3_para->nw[nw].dpc[sp_place],ls,als); + {/* tsrc->rtac stp no longer use for destination */ + } + {/* new stp use for destination */ + } + } + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = ls; + rtpc_proc(nw,sp_place); + } + mark_normal_linkset_available(routine); + } + else if (als == ls) + {/* mark als available */ + mark_alternative_linkset_available(routine); + } + } + else/* dst not accessible */ + { + mtp3.nw[nw].rtac_input[sp_place] = RTAC_DEST_ACCESSIBLE; + //tsfc_tsrc_destination_accessible(ls); + if (nls == ls) + { + mark_normal_linkset_available(routine); + if (Nlinkset_status(*routine) == LS_UNAVAILABLE) +// if ( ((*routine) & 3) == NLS_UNAVAILABLE) + {/* new stp use for destination */ + } + } + else if (als == ls) + {/* new stp use for destination */ + mark_alternative_linkset_available(routine); + } + } +} + +void tsrc_fun7(WORD chl, BYTE nw) +{ + WORD lsx8; + BYTE sp_place; + int i; + network *sp; + ls_info *ls; + WORD lsno; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + lsx8 = lsno<<3; + + ls = &mtp3.ls[lsno]; + sp = &mtp3.nw[nw]; + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + if ( !own_sp_restarting ) + { + tsrc_fun8(lsno,nw,sp_place); + } + else + mark_normal_linkset_available(&sp->routine[sp_place]); + } + + /* select sp that use this linkset for alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + if ( !own_sp_restarting ) + { + tsrc_fun8(lsno,nw,sp_place); + } + else + mark_alternative_linkset_available(&sp->routine[sp_place]); + } +} + +void tsrc_tsrc_signalling_link_set_available(BYTE chl) +{ + int i; + BYTE nw; + network *sp; + WORD lsx8; + BYTE sp_place; + WORD adsp_place; + WORD lsno; + WORD lsx16; + BYTE adsp_acessible; + BYTE owner_of_link; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx8 = lsno << 3; + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + owner_of_link = 1; + else + owner_of_link = 0; + + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return; + adsp_acessible = (mtp3.nw[nw].routine[adsp_place] >> 4) & 3; + + ls->adjacentsp_acessible = TRUE; + current_measure->ls_measure[lsno][7]++;/* Stop of adjacent SP inaccessible */ + + if ( own_sp_restarting )/* local restarting */ + { + if (adsp_acessible == 1) + cb_msg_can_exchange[chl] = TRUE; + else + cb_msg_can_exchange[chl] = FALSE; + tsrc_fun7(chl,nw); + } + else + { + if ( adsp_acessible == 1 )/* adjacent sp acessible */ + { + if (adsp_acessible == 1) + cb_msg_can_exchange[chl] = TRUE; + else + cb_msg_can_exchange[chl] = FALSE; + tsrc_fun7(chl,nw); + } + else/* adjacent sp inacessible */ + { + lsx16 = lsno << 4; + ls->adjacentsp_restarting = 1; + start_mtp3T21(lsno); + sp = &mtp3.nw[nw]; +/*** mark all route available ***/ + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + mark_normal_linkset_available(&sp->routine[sp_place]); + if (Alinkset_status(sp->routine[sp_place]) == LS_AVAILABLE) +// if ( ((sp->routine[sp_place] >> 2) & 3) == ALS_AVAILABLE) + { + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + { +// printf("link %d send TFA via ALS\n",chl); + mtp3.nw[nw].rtpc_input[sp_place] = RTPC_TSRC_SEND_TFP_MSG; + sdTFA_Ls = mtp3_para->nw[nw].alternative_ls[lsno]; + rtac_proc(nw,sp_place); + } + } + } + + /* select sp that use this linkset for alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + mark_alternative_linkset_available(&sp->routine[sp_place]); + } +/*** mark all route can available ***/ +// tsfc_tsrc_adjacent_sp_restarting(ls); +// tprc_tsrc_adjacent_sp_restarting(ls); + mtp3.ls[lsno].adjacentsp_restarting = 1;/* mark adjacent sp restarting */ + if (owner_of_link == 1) + mtp3ObjInput.taprc_input[lsno] = TPRC_ADJACENT_SP_RESTARTING; +// mtp3_debug(MTP3DB_EVENT,"chl %d,linkset %d adjacent sp restarting",chl,lsno); + } + } +} + +void tsrc_tsrc_signalling_link_set_unavailable(BYTE chl) +{ + BYTE i; + BYTE nw; + network *sp; + WORD lsx8; + BYTE sp_place; + WORD lsno; + WORD adsp_place; + BYTE owner_of_link; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + lsx8 = lsno << 3; + + if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) + owner_of_link = 1; + else + owner_of_link = 0; + + nw = mtp3_para->ls_pro[lsno] & 3; + adsp_place = ls->adjacent_sp_place; + if (adsp_place > 255) + return; + + if ( (mtp3.nw[nw].routine[adsp_place] & 0x0f) == 0 )/* normal and alternative route are available before */ + co_msg_can_exchange[chl] = TRUE; + else + { + ls->adjacentsp_acessible = FALSE; + current_measure->ls_measure[lsno][5]++;/* Adjacent SP inaccessible */ + co_msg_can_exchange[chl] = FALSE; + } + + sp = &mtp3.nw[nw]; + /* select sp that use this linkset as normal route */ + for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asNLS[i]; + if ( own_sp_restarting ) + { + mark_normal_linkset_unavailable(&sp->routine[sp_place]); + if (Alinkset_status(sp->routine[sp_place]) != LS_AVAILABLE) + { +// if ( ((sp->routine[sp_place] >> 2) & 3) != ALS_AVAILABLE )/* Alternative route available */ + mark_dstSP_inaccessible(&sp->routine[sp_place]); + printf("mark inaccessible\n"); + } + } + else + tsrc_fun6(chl,nw,sp_place); + } + + /* select sp that use this linkset as alternative route */ + for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ ) + { + sp_place = ls->influ_dstplace_intable_asALS[i]; + if ( own_sp_restarting ) + { + mark_alternative_linkset_unavailable(&sp->routine[sp_place]); + if (Nlinkset_status(sp->routine[sp_place]) != LS_AVAILABLE) +// if ( (sp->routine[sp_place] & 3) != NLS_AVAILABLE )/* normal route unavailable */ + mark_dstSP_inaccessible(&sp->routine[sp_place]); + } + else + tsrc_fun6(chl,nw,sp_place); + } +} + +int inhibit_allow_or_not(BYTE ls,BYTE nw) +{ + int dpc; + BYTE routine; + + for (dpc=0; dpc<256; dpc++) + { + routine = mtp3.nw[nw].routine[dpc]; + if ( (mtp3_para->nw[nw].normal_ls[dpc] == ls) && + (Alinkset_status(routine) == LS_UNAVAILABLE) ) +// (((routine >> 2) & 3) == ALS_UNAVAILABLE) ) + return FALSE; + else if ( (mtp3_para->nw[nw].alternative_ls[dpc] == ls) && + (Nlinkset_status(routine) == LS_UNAVAILABLE) ) +// ((routine & 3) == NLS_UNAVAILABLE) ) + return FALSE; + } + return TRUE; +} + +void tsrc_fun15(BYTE chl,BYTE inhibit_req_by) +{ + switch (inhibit_req_by) + { + case LOCAL_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_LOCAL_INHIBIT_DENIED; + break; + case REMOTE_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_REMOTE_INHIBIT_DENIED; + break; + } +} + +void tsrc_inhibit_allow(BYTE chl,BYTE inhibit_req_by) +{ + switch (inhibit_req_by) + { + case LOCAL_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_LOCAL_INHIBIT_ALLOWED; + break; + case REMOTE_INHIBIT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_REMOTE_INHIBIT_ALLOWED; + link_inhibited[chl] = TRUE;/* mark link inhibited */ + break; + } +} + +void tsrc_fun13(BYTE chl,BYTE inhibit_req_by) +{ + BYTE ls; + BYTE nw; + BYTE route_st; + int inhibit; + WORD sp_place; + + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d rv inhibit request from tlac",chl); + + ls = mtp3_para->lk[chl].e1_to_linkset; + nw = mtp3_para->ls_pro[ls] & 3; + if (mtp3ObjState.link_l3_state[chl] == UNAVAILABLE)/* link l3 state unavailable */ + { + sp_place = mtp3.ls[ls].adjacent_sp_place; + if (sp_place > 255) + return; + route_st = (mtp3.nw[nw].routine[sp_place] >> 4) & 3; + if (route_st == SP_ACCESSIBLE)/* remote sp can access */ + { + tsrc_inhibit_allow(chl,inhibit_req_by); + } + else/* remote sp can't access */ + { + tsrc_fun15(chl,inhibit_req_by);/* [inhibit dennid] */ + } + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + } + else/* link l3 state available */ + { + if (mtp3.ls[ls].links_available == 1)/* there is only one link left available in this linkset */ + { + inhibit = inhibit_allow_or_not(ls,nw); + if (inhibit == FALSE)/* inhibit this link maybe can cause one dpc not accessable */ + tsrc_fun15(chl,inhibit_req_by);/* [inhibit dennid] */ + else/* inhibit this link will not cause any dpc not accessable */ + tsrc_inhibit_allow(chl,inhibit_req_by); + } + else/* there is another available link in this linkset */ + tsrc_inhibit_allow(chl,inhibit_req_by); + } +} + +void tsrc_proc(BYTE chl) +{ + BYTE cc_lk_num; + WORD lsno; + BYTE rmSP_routine;/* remote sp routine */ + WORD rmSP_place; + + ls_info *ls; + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + + switch (mtp3ObjState.tsrc_state[chl]) + { + case TSRC_IDLE_STATE: + switch (mtp3ObjInput.tsrc_input_from_tlac[chl]) + { + case TSRC_TLAC_LINK_UNAVAILABLE: +// printf("tsrc link %d unavailable\n",chl); + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + if (ls->links_available > 0) + ls->links_available--; + // if ( /* emergency see 12.2.4 */ ) +// lk_llsc_tsrc_emergency(lk); + if ( ls->links_available == 0 ) + { + changeover_select[chl] = BETWEEN_LS; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d unavailable,linkset %d unavailable",chl,lsno); + tsrc_tsrc_signalling_link_set_unavailable(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d unavailable",chl); + co_msg_can_exchange[chl] = TRUE; + changeover_select[chl] = WITHIN_LS; + } + break; + + case TSRC_TLAC_LINK_AVAILABLE: +// printf("tsrc link %d available\n",chl); + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_available[chl] = AVAILABLE; + ls->links_available++; + // if ( /* not emergency see 12.2.4 */ ) + // lk_llsc_tsrc_emergency_ceases(lk); + if ( ls->links_available == 1 )/* no other links available in linkset */ + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d available,linkset available",chl); + tsrc_tsrc_signalling_link_set_available(chl); + changeback_select[chl] = BETWEEN_LS; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d available",chl); + changeback_select[chl] = WITHIN_LS; + cb_msg_can_exchange[chl] = TRUE; + } + break; + + case TSRC_TLAC_LOCAL_INHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + tsrc_fun13(chl,LOCAL_INHIBIT_REQ); + break; + + case TSRC_TLAC_REMOTE_INHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + tsrc_fun13(chl,REMOTE_INHIBIT_REQ); + break; + + case TSRC_TLAC_LINK_INHIBITED: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_inhibited[chl] = TRUE; + break; + + case TSRC_TLAC_CANCEL_LINK_INHIBITED: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + link_inhibited[chl] = FALSE; + break; + + case TSRC_TLAC_UNINHIBIT_REQ: + mtp3ObjInput.tsrc_input_from_tlac[chl] = IDLE; + rmSP_place = mtp3.ls[lsno].adjacent_sp_place; + if (rmSP_place > 255) + return; + rmSP_routine = mtp3.nw[mtp3_para->ls_pro[lsno] & 3].routine[rmSP_place]; + if ( ((rmSP_routine >> 4) & 1) == SP_INACCESSIBLE)/* no route */ + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_UNINHIBIT_NOT_POSSIBLE; + else + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_UNINHIBIT_POSSIBLE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_tcoc[chl]) + { + case TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST: + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + /* obtain alternative routing data according to rules specified in Q.704 4.4 */ + /* during SP restart the adjacent SP is considered inaccessible */ + /* locally or request from MTP level state machine */ +/********/ +/********/ changeover_required[chl] = TRUE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = TCOC_ALTERATIVE_ROUTE_DT; + mtp3ObjState.tsrc_state[chl] = TSRC_WAIT01_STATE; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d tcoc asking for alternative route date",chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_tcbc[chl]) + { + case TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST: + mtp3ObjInput.tsrc_input_from_tcbc[chl] = IDLE; + cc_lk_num = 0; + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[lsno]; + /* obtain alternative routing data */ + /* during SP restart the adjacent SP is considered inaccessible */ + /* locally or request from MTP level state machine */ + if ( changeback_select[chl] == BETWEEN_LS )/* this is the first link */ + { +// mtp3_debug(MTP3DB_EVENT,"link %d changeback_select BETWEEN_LS",chl); + /* but change back message will not exchange between link set */ + } + else + { + } +// printf("tsrc link %d tcbc alter data cmp\n",chl); + mtp3ObjInput.tcbc_input_from_tsrc[chl] = TCBC_ALTERATIVE_ROUTE_DT; + mtp3ObjState.tsrc_state[chl] = TSRC_WAIT02_STATE; + tcbc_route_change[chl] = TRUE; + mtp3_debug(MTP3DB_EVENT,"[tsrc]link %d tcbc asking for alternative route date",chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tsrc_input_from_stm[chl]) + { + default: + break; + } + + case TSRC_WAIT01_STATE:/* 1 TSRC_WAIT1_STATE */ + if (mtp3ObjInput.tsrc_input_from_tcoc[chl] == TSRC_TCOC_CHANGEOVER_EXECUTED) + { + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + changeover_completed[chl] = 1; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + else if (mtp3ObjInput.tsrc_input_from_tcoc[chl] == TSRC_TCOC_CHANGEOVER_NOT_REQ) + { + mtp3ObjInput.tsrc_input_from_tcoc[chl] = IDLE; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + break; + + case TSRC_WAIT02_STATE:/* 2 TSRC_WAIT2_STATE */ + if ( mtp3ObjInput.tsrc_input_from_tcbc[chl] == TSRC_PROCEDURE_TERMINATED ) + { + mtp3ObjInput.tsrc_input_from_tcbc[chl] = IDLE; + changeover_completed[chl] = 0; + mtp3ObjState.tsrc_state[chl] = TSRC_IDLE_STATE; + } + break; + + case TSRC_WAIT03_STATE: + break; + case TSRC_WAIT04_STATE: + break; + case TSRC_WAIT05_STATE: + /* this state's function put in the tprc state machine */ + break; + default: + break; + } +} + +void tlac_fun5(BYTE link) +{ + mtp3ObjInput.tcbc_input[link] = TCBC_LINK_AVAILABLE; + changeback_in_progress[link] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[link] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjState.tlac_state[link] = TLAC_AVAILABLE_STATE; +} + +void tlac_fun6(BYTE link) +{ + if (changeover_in_progress[link] == TRUE) + { + mtp3ObjInput.tcoc_input_from_stm[link] = TCOC_LINK_AVAILABLE; + } + else + tlac_fun5(link); +} + +void tlac_fun7(BYTE link) +{ + sd_STM_msg(link,SIGNAL_LUN); + uninhibit_in_progress[link] = TRUE; + start_mtp3T12(link); +} + +void tlac_fun1(BYTE link) +{ + if (changeback_in_progress[link] == TRUE) + { +// mtp3_debug(MTP3DB_EVENT,"changeback in progress"); + link_available[link] = FALSE; + } + else + { + changeover_in_progress[link] = TRUE; + mtp3ObjInput.tcoc_input_from_stm[link] = TCOC_LINK_UNAVAILABLE; + } + mtp3ObjInput.tsrc_input_from_tlac[link] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjState.tlac_state[link] = TLAC_UNAVAILABLE_STATE; +} + +void mgmt_tlac_proc(BYTE link,BYTE input) +{ + switch (input) + { + case 0: + break; + case 1: + break; + } +} + +void tlac_proc(BYTE chl) +{ + ls_info *ls; + int lsno; + + if (init_tlac_state[chl] == TRUE) + { + init_tlac_state[chl] = IDLE; + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + changeover_in_progress[chl] = FALSE; + changeback_in_progress[chl] = FALSE; + failed[chl] = TRUE; + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + return; + } + + lsno = mtp3_para->lk[chl].e1_to_linkset; + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + switch (mtp3ObjState.tlac_state[chl]) + { + case TLAC_UNAVAILABLE_STATE: + switch (mtp3ObjInput.tlac_input_from_mgmt[chl]) + { + case TLAC_MGMT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ; + current_measure->lk_measure1[chl][7]++;//Local management inhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv local MGMT inhibit request in unavailable state",chl); + break; + case TLAC_MGMT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + management_req[chl] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_UNINHIBIT_REQ; + current_measure->lk_measure1[chl][8]++;//Local management uninhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv local MGMT uninhibit request in unavailable state",chl); + break; + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_remotely_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIN,send LIA",chl); + sd_STM_msg(chl,SIGNAL_LIA);/* send inhibit ack signal */ + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIN,send LIA,mark Inhibited",chl); + link_remotely_inhibited[chl] = TRUE; + link_locally_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LIA); + mtp3ObjState.link_l3_state[chl] = INHIBITED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + start_mtp3T22(chl); + } + break; + + case TLAC_HMDT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(unavai)]link %d (inhibited) rv LUN,send LUA",chl); + link_remotely_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LUA); + stop_mtp3T13(chl); + if (link_locally_inhibited[chl] != TRUE) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_CANCEL_LINK_INHIBITED; + link_inhibited[chl] = FALSE; + if ( (blocked_by[chl] == IDLE) && + (failed[chl] != TRUE) ) + tlac_fun6(chl); + else + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + } + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(unavai)]link %d (unavailable) rv LUN,send LUA",chl); + sd_STM_msg(chl,SIGNAL_LUA); + } + break; + + case TLAC_HMDT_INHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (local_inhibit_in_progress[chl] == TRUE) + { + link_locally_inhibited[chl] = TRUE; + link_remotely_inhibited[chl] = FALSE; + link_inhibited[chl] = TRUE; + mtp3ObjState.link_l3_state[chl] = INHIBITED; + local_inhibit_in_progress[chl] = FALSE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LIA,TLAC->TSRC:LINK INHIBITED",chl); + stop_mtp3T14(chl); + } + start_mtp3T22(chl); + break; + + case TLAC_HMDT_UNINHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LUA",chl); + if (uninhibit_in_progress[chl] == TRUE) + { + management_req[chl] = FALSE; + uninhibit_in_progress[chl] = FALSE; + mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; + stop_mtp3T12(chl); + if (link_remotely_inhibited[chl] != TRUE) + { + link_inhibited[chl] = FALSE; + link_locally_inhibited[chl] = FALSE; +// mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_CANCEL_LINK_INHIBITED; + if ( (blocked_by[chl] == IDLE) && + (failed[chl] != TRUE) ) + tlac_fun6(chl); + } + } + break; + + case TLAC_HMDT_INHIBIT_DENIED: + break; + + case TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d (inhibited) rv LFU",chl); + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv LFU",chl); + sd_STM_msg(chl,SIGNAL_LUN); + } + break; + + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if ( changeover_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv COO,TLAC->TCOC:COO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv COO,send ECA",chl); + hmrt_tcoc_emergency_changeover_ack(chl); + } + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if ( changeover_in_progress[chl] == TRUE) /*changeover is executing */ + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv ECO,TLAC->TCOC:ECO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv ECO,send ECA",chl); + sd_STM_msg(chl,SIGNAL_ECA); + } + break; + + case TLAC_HMDT_LOCAL_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_remotely_inhibited[chl] != TRUE) + { + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + break; + case TLAC_HMDT_REMOTE_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (link_locally_inhibited[chl] != TRUE) + { + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + } + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_TCBC_CHANGEBACK_TERMINATED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeback_in_progress[chl] = FALSE; + if ( changeover_order[chl] == TRUE) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + else if ( emergency_changeover_order[chl] == TRUE) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + else if ( link_available[chl] != TRUE ) + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_UNAVAILABLE; + link_available[chl] = IDLE; + changeover_order[chl] = IDLE; + emergency_changeover_order[chl] = IDLE; + changeover_in_progress[chl] = TRUE;/* mark change over in progress */ + break; + + case TLAC_TCOC_CHANGEOVER_EXECUTED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeover_in_progress[chl] = IDLE;/* cancel mark */ + if (link_inhibited[chl] != TRUE) + { + if ( failed[chl] != TRUE ) + { + tlac_fun5(chl); + } + } + break; + + case TLAC_LOCAL_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d local inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LIN); + local_inhibit_in_progress[chl] = TRUE; + start_mtp3T14(chl); + break; + + case TLAC_REMOTE_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d remote inhibit allow",chl); + break; + case TLAC_LOCAL_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d local inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + break; + + case TLAC_REMOTE_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d remote inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + break; + + case TLAC_UINHIBIT_SIGLINK_FROM_TSRC: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d rv uninhibit sig from TSRC",chl); + if (uninhibit_in_progress[chl] != TRUE) + { + uninhibit_in_progress[chl] = TRUE; + if ( (blocked_by[chl] != IDLE) || + (failed[chl] == TRUE) ) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit no success, blocked or failed",chl); + } + else + { + if (link_locally_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d send LUN",chl); + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + } + else if (link_remotely_inhibited[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d send LFU",chl); + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d is not being local or remotely inhibited",chl); + } + } + } + else + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit in progress",chl); + break; + + case TLAC_UNINHIBIT_NOT_POSSIBLE: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit not possible",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + if ( (blocked_by[chl] != IDLE) && + (failed[chl] == TRUE) ) + { + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + management_req[chl] = FALSE; + } + else + { + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + } + break; + + case TLAC_UNINHIBIT_POSSIBLE: + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d uninhibit possible",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + uninhibit_in_progress[chl] = TRUE; + start_mtp3T12(chl); + break; + + case TLAC_RESTART_BEGINS: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mtp3ObjState.tlac_state[chl] = TLAC_SP_RESTARTING_STATE; + break; + + case TLAC_TCOC_CHANGEOVER_NOT_REQ: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeover_in_progress[chl] = IDLE;/* cancel mark */ + if ( failed[chl] != TRUE ) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + } + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = FALSE;/* cancel mark link fail */ + if (link_inhibited[chl] != TRUE) + { + if (changeover_in_progress[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d in service,changeover in progress,TLAC->TCOC:LINK AVAILABLE",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_AVAILABLE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[TLAC(unavai)]link %d in service,TLAC->TSRC(TCBC):LINK AVAILABLE",chl); + tlac_fun5(chl); + } + } + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_Tctl[chl]) + { + case TLAC_T12_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + uninhibit_in_progress[chl] = FALSE;/* cancel uninhibit in progress */ + if (t12_expired_2nd_time[chl] == TRUE) + { + t12_expired_2nd_time[chl] = FALSE; + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + } + else + { + t12_expired_2nd_time[chl] = TRUE; + if (management_req[chl] == TRUE) + { + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_UNINHIBIT_REQ; + } + else + tlac_fun7(chl); + } + break; + case TLAC_T13_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (t13_expired_2nd_time[chl] == TRUE) + { + mgmt_tlac_proc(chl,MGMT_UNINHIBIT_NOT_POSSIBLE); + } + else + { + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + } + break; + case TLAC_T14_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + local_inhibit_in_progress[chl] = FALSE;/* cancel local inhibit in progress */ + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ;/* local inhibit request */ + break; + case TLAC_T22_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (link_locally_inhibited[chl] == TRUE) + { + sd_STM_msg(chl,SIGNAL_LLT); + start_mtp3T22(chl); + } + break; + case TLAC_T23_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + if (link_remotely_inhibited[chl] == TRUE) + { + sd_STM_msg(chl,SIGNAL_LRT); + start_mtp3T23(chl); + } + break; + default: + break; + } + + break; + + case TLAC_AVAILABLE_STATE: + switch (mtp3ObjInput.tlac_input_from_mgmt[chl]) + { + case TLAC_MGMT_INHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ; + current_measure->lk_measure1[chl][7]++;//Local management inhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv local MGMT uninhibit request",chl); + break; + case TLAC_MGMT_UINHIBIT_SIGLINK: + mtp3ObjInput.tlac_input_from_mgmt[chl] = IDLE; + current_measure->lk_measure1[chl][8]++;//Local management uninhibit + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv local MGMT uninhibit request",chl); + break; + default: + break; + } + + switch ( mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_INHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LIN",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_REMOTE_INHIBIT_REQ; + break; + + case TLAC_HMDT_UINHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LUN",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUA); + break; + + case TLAC_HMDT_INHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (local_inhibit_in_progress[chl] == TRUE) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv LIA,inhibit in progress",chl); + link_locally_inhibited[chl] = TRUE; + link_remotely_inhibited[chl] = FALSE; + local_inhibit_in_progress[chl] = FALSE; + stop_mtp3T14(chl); + link_inhibited[chl] = TRUE; +// mtp3ObjInput.tsrc_input_from_stm[chl] = TSRC_TLAC_LINK_INHIBITED; + mgmt_tlac_proc(chl,MGMT_TLAC_LINK_INHIBITED); + start_mtp3T22(chl); + tlac_fun1(chl); + } + else + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LIA",chl); + break; + + case TLAC_HMDT_UNINHIBIT_ACK: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + break; + + case TLAC_HMDT_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LID",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mgmt_tlac_proc(chl,MGMT_INHIBIT_DENIED); + local_inhibit_in_progress[chl] = FALSE; + stop_mtp3T14(chl); + break; + + case TLAC_HMDT_FORCE_UNINHIBIT_SIGLINK: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d rv LFU",chl); + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + break; + + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + failed[chl] = TRUE;/* mark failed */ + if ( changeback_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv COO command,changeback in progress",chl); + changeover_order[chl] = TRUE;/* mark received coo command */ + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv COO command,TLAC->TCOC:COO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + changeover_in_progress[chl] = TRUE; + } + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + failed[chl] = TRUE; + if ( changeback_in_progress[chl] == TRUE ) + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv ECO command,changeback in progress",chl); + emergency_changeover_order[chl] = TRUE; + } + else + { + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d rv EOO command,TLAC->TCOC:EOO COMMAND",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + changeover_in_progress[chl] = TRUE; + } + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_HMDT_LOCAL_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LFU); + start_mtp3T13(chl); + break; + case TLAC_HMDT_REMOTE_INHIBIT_TEST: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LUN); + start_mtp3T12(chl); + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_TCBC_CHANGEBACK_TERMINATED: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + changeback_in_progress[chl] = FALSE; + break; + + case TLAC_TCOC_CHANGEOVER_EXECUTED: + break; + + case TLAC_TCOC_CHANGEOVER_NOT_REQ: + break; + + case TLAC_LOCAL_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d local inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LIN); + local_inhibit_in_progress[chl] = TRUE; + start_mtp3T14(chl); + break; + + case TLAC_REMOTE_INHIBIT_ALLOWED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d remote inhibit allow",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + link_remotely_inhibited[chl] = TRUE; + link_locally_inhibited[chl] = FALSE; + sd_STM_msg(chl,SIGNAL_LIA); +// mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_INHIBITED; + link_inhibited[chl] = TRUE; + start_mtp3T23(chl); + tlac_fun1(chl); + break; + + case TLAC_LOCAL_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d local inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + mgmt_tlac_proc(chl,MGMT_INHIBIT_DENIED); + break; + + case TLAC_REMOTE_INHIBIT_DENIED: + mtp3_debug(MTP3DB_EVENT,"[tlac(avai)]link %d remote inhibit denied",chl); + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + sd_STM_msg(chl,SIGNAL_LID); + break; + + case TLAC_RESTART_BEGINS: + link_available[chl] = AVAILABLE; + mtp3ObjState.tlac_state[chl] = TLAC_SP_RESTARTING_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d outof service",chl); + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + tlac_fun1(chl); + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + mtp3_debug(MTP3DB_EVENT,"[TLAC(avai)]link %d in service",chl); + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_Tctl[chl]) + { + case TLAC_T12_EXPIRED: + break; + case TLAC_T13_EXPIRED: + break; + case TLAC_T14_EXPIRED: + mtp3ObjInput.tlac_input_from_Tctl[chl] = IDLE; + local_inhibit_in_progress[chl] = FALSE;/* cancel local inhibit in progress */ + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LOCAL_INHIBIT_REQ;/* local inhibit request */ + break; + default: + break; + } + + break; + + case TLAC_SP_RESTARTING_STATE: + switch (mtp3ObjInput.tlac_input_from_slm[chl]) + { + case TLAC_LSAC_SIGLINK_FAILED: + mtp3_debug(MTP3DB_EVENT,"[TLAC(rest)]link %d unavailable in restarting state",chl); +// printf("tlac link %d failed\n",chl); + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = TRUE;/* mark link fail */ + link_available[chl] = FALSE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_LINK_UNAVAILABLE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + break; + + case TLAC_LSAC_LINK_IN_SERVICE: + mtp3ObjInput.tlac_input_from_slm[chl] = IDLE; + failed[chl] = FALSE; + link_available[chl] = TRUE; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; + mtp3ObjInput.tcbc_input[chl] = TCBC_LINK_AVAILABLE; + if ( (ls->links_available - 1) == mtp3.ls[lsno].linksNum_configured ) + current_active_ls_num ++; + mtp3_debug(MTP3DB_EVENT,"[TLAC(rest)]link %d in service in restarting state",chl); + break; + + case TLAC_LSAC_REMOTE_PROCESSOR_OUTAGE: + break; + + default: + break; + } + + switch (mtp3ObjInput.tlac_input_from_hmdt[chl]) + { + case TLAC_HMDT_CHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (failed[chl] == FALSE)/* link available */ + { + failed[chl] = TRUE;/* mark failed */ + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_COO_COMMAND; + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE COO(link active)\n\r",chl); + } + else + { + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE COO(link fail)\n\r",chl); + } + break; + + case TLAC_HMDT_ECHANGEOVER_ORDER: + mtp3ObjInput.tlac_input_from_hmdt[chl] = IDLE; + if (failed[chl] == FALSE) + { + failed[chl] = TRUE;/* mark failed */ + mtp3ObjInput.lsac_input_from_stm[chl] = LSAC_TLAC_CHANGEOVER_ORDER_RECEIVED; + mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; + mtp3ObjInput.tcoc_input_from_stm[chl] = TCOC_TLAC_ECO_COMMAND; + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE ECO IN RESTART STATE(link active)\n\r",chl); + } + else + { + mtp3_debug(MTP3DB_ERROR,"[TLAC(rest)]link %d RECEIVE ECO IN RESTART STATE(link fail)\n\r",chl); + } + break; + } + + switch (mtp3ObjInput.tlac_input_from_stm[chl]) + { + case TLAC_RESTART_ENDS: + mtp3ObjInput.tlac_input_from_stm[chl] = IDLE; + if ( link_available[chl] == TRUE ) + mtp3ObjState.tlac_state[chl] = TLAC_AVAILABLE_STATE; + else + mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; + break; + + case TLAC_ADJACENT_SP_RESTART_ENDS: + break; + } + break; + + default: + break; + } +} + +void changeover_not_req(BYTE chl) +{ + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STM_READY; + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCOC_CHANGEOVER_NOT_REQ; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_CHANGEOVER_NOT_REQ; +} + +void tcoc_proc(BYTE chl) +{ + ls_info *ls; + int l2_input; + + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + + switch (mtp3ObjState.tcoc_state[chl]) + { + case TCOC_IDLE_STATE: + switch (mtp3ObjInput.tcoc_input_from_stm[chl]) + { + case TCOC_LINK_UNAVAILABLE: + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d unavailable",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT01_STATE; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST; + break; + + case TCOC_LINK_AVAILABLE: + break; + + case TCOC_TLAC_COO_COMMAND: +// mtp3_debug(MTP3DB_EVENT,"link %d rev coo",chl); + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + remote_bsnt_retrieved[chl] = TRUE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT05_STATE; + break; + + case TCOC_TLAC_ECO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + remote_bsnt_retrieved[chl] = FALSE; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT05_STATE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tcoc_input_from_hmdt[chl]) + { + case TCOC_HMDT_COA_COMMAND: + remote_bsnt_retrieved[chl] = TRUE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d RV COA IN IDLE STATE\n\r",chl); + break; + + case TCOC_HMDT_ECA_COMMAND: + remote_bsnt_retrieved[chl] = FALSE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d RV ECA IN IDLE STATE\n\r",chl); + break; + + default: + break; + } + break; + + case TCOC_WAIT01_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT1 STATE\n\r",chl); + changeover_not_req(chl); + } + else if ( mtp3ObjInput.tcoc_input_from_tsrc[chl] == TCOC_ALTERATIVE_ROUTE_DT ) + { + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d get routing data from tsrc",chl); +// printf("tcoc link %d route data\n",chl); + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + if ( changeover_required[chl] == TRUE ) + { + if ( co_msg_can_exchange[chl] == TRUE ) + { + co_msg_can_exchange[chl] = IDLE; +// mtp3_debug(MTP3DB_EVENT,"chl %d cc msg can exchange",chl); + if ( local_bsnt_retrievable[chl] == TRUE) + hmrt_tcoc_changeover_order(chl);/* send coo */ + else + { + hmrt_tcoc_emergency_changeover_order(chl); + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STOP_L2; + } + t2_delay_mtp3[chl] = mtp3_para->lt[chl].t2; + mtp3ObjState.tcoc_state[chl] = TCOC_WAITACK_STATE; + } + else if ( co_msg_can_exchange[chl] == FALSE ) + { + co_msg_can_exchange[chl] = IDLE; + t1_delay_mtp3[chl] = mtp3_para->lt[chl].t1; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT07_STATE; + } + } + else/* changeover not required */ + { + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d changeover not required,update routing table",chl); + hmrt_tcoc_update_routing_tables(chl); + } + } + break; + + case TCOC_WAIT05_STATE:/* wait for e1 l1 state change to unavailable */ + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + changeover_not_req(chl); +// mtp3_debug(MTP3DB_EVENT,"TCOC LINK %d AVAILABLE AT WAIT5 STATE",chl); + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; + } + else + { +/* if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl); + else*/ + hmrt_tcoc_emergency_changeover_ack(chl); + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_ALTERNATIVE_ROUTING_DATA_REQUEST; + mtp3ObjState.tcoc_state[chl] = TCOC_WAIT06_STATE; + send_command_to_mtp2(chl,MTP2_DEACTIVE_LINK); + } + break; + + case TCOC_WAIT06_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT6 STATE\n\r",chl); + changeover_not_req(chl); + } + else if ( mtp3ObjInput.tcoc_input_from_tsrc[chl] == TCOC_ALTERATIVE_ROUTE_DT ) + { + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; +// mtp3_debug(MTP3DB_EVENT,"tcoc link %d get data",chl); + if ( remote_bsnt_retrieved[chl] == TRUE ) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d retrieve begins in WAIT6",chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + } + else + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + } + break; + + case TCOC_WAIT07_STATE: + if (mtp3ObjInput.tcoc_input_from_stm[chl] == TCOC_LINK_AVAILABLE) + { + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_tsrc[chl] = IDLE; + mtp3_debug(MTP3DB_ERROR,"[tcoc]link %d AVAILABLE AT WAIT07 STATE\n\r",chl); + changeover_not_req(chl); + } + else + { + + t1_delay_mtp3[chl] = t1_delay_mtp3[chl] - 1; + if ( t1_delay_mtp3[chl] == 0 ) + { + changeover_not_req(chl); + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d update routing table after T1 expired",chl); + hmrt_tcoc_update_routing_tables(chl); + } + } + break; + + case TCOC_WAITACK_STATE: + switch (mtp3ObjInput.tcoc_input_from_stm[chl]) + { + case TCOC_LINK_UNAVAILABLE: + break; + + case TCOC_LINK_AVAILABLE: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + changeover_not_req(chl); + break; + + case TCOC_TLAC_COO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl);/* send COA */ + else + hmrt_tcoc_emergency_changeover_ack(chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); +// mtp3_debug(MTP3DB_EVENT,"chl %d retrieve begins in WAITACK",chl); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + break; + + case TCOC_TLAC_ECO_COMMAND: + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + if ( local_bsnt_retrievable[chl] == TRUE ) + hmrt_tcoc_changeover_ack(chl); + else + hmrt_tcoc_emergency_changeover_ack(chl); + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + break; + + default: + break; + } + + switch (mtp3ObjInput.tcoc_input_from_hmdt[chl]) + { + case TCOC_HMDT_COA_COMMAND: + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d rv coa at waitack state",chl); + send_command_to_mtp2(chl,MTP2_RETRIEVE); + mtp3ObjState.tcoc_state[chl] = TCOC_RETRIEVING_STATE; + } + break; + + case TCOC_HMDT_ECA_COMMAND: + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + break; + + default: + break; + } + + t2_delay_mtp3[chl] = t2_delay_mtp3[chl] - 1; + if ( t2_delay_mtp3[chl] == 0 ) + { +// mtp3_debug(MTP3DB_EVENT,"chl %d rv coa timeout waitack state",chl); + if (mtp3ObjState.tcoc_state[chl] == TCOC_WAITACK_STATE) + { + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STOP_L2; + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + } + } + break; + + case TCOC_RETRIEVING_STATE: + l2_input = retrieved_bsnt[chl]; +/* if (l2_input == TCOC_L2_RETRIEVE_CMP) + {*/ + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; +/* } + else if (l2_input == TCOC_L2_RETRIEVE_NOT_POSSIBLE) + { + mtp3ObjState.tcoc_state[chl] = TCOC_SEND_BUFMSG_STATE; + }*/ + break; + + case TCOC_SEND_BUFMSG_STATE: + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCOC_CHANGEOVER_EXECUTED; + mtp3ObjInput.tsrc_input_from_tcoc[chl] = TSRC_TCOC_CHANGEOVER_EXECUTED; + mtp3ObjInput.tcoc_input_from_stm[chl] = IDLE; + mtp3ObjInput.tcoc_input_from_hmdt[chl] = IDLE; + mtp3ObjState.tcoc_state[chl] = TCOC_IDLE_STATE; /* IDLE STATE */ + mtp3ObjInput.lsac_input_from_tcoc[chl] = LSAC_TCOC_STM_READY; + hmrt_tcoc_update_routing_tables(chl); + mtp3_debug(MTP3DB_EVENT,"[tcoc]link %d update routing table after retrieved msg",chl); + break; + + default: + break; + } +} + +void changeback_terminated(BYTE chl) +{ + mtp3ObjInput.tlac_input_from_stm[chl] = TLAC_TCBC_CHANGEBACK_TERMINATED; + mtp3ObjInput.tsrc_input_from_tcbc[chl] = TSRC_PROCEDURE_TERMINATED; + mtp3ObjState.tcbc_state[chl] = TCBC_IDLE_STATE; + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d change back complete,update routing table",chl); + hmrt_tcbc_update_routing_tables(chl); +} + +void tcbc_proc(BYTE chl) +{ + ls_info *ls; + BYTE lsno; + + ls = &mtp3.ls[mtp3_para->lk[chl].e1_to_linkset]; + + switch (mtp3ObjState.tcbc_state[chl]) + { + case TCBC_IDLE_STATE: + switch (mtp3ObjInput.tcbc_input[chl]) + { + case TCBC_LINK_UNAVAILABLE: + break; + + case TCBC_LINK_AVAILABLE: + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d available",chl); + mtp3ObjInput.tcbc_input[chl] = IDLE; + mtp3ObjInput.tsrc_input_from_tcbc[chl] = TSRC_TCBC_ALTERNATIVE_ROUTING_DATA_REQUEST; + mtp3ObjState.tcbc_state[chl] = TCBC_WAIT_FOR_ROUTING_DATA_STATE; + break; + + case TCBC_HMDT_CBD_COMMAND: + mtp3ObjInput.tcbc_input[chl] = IDLE; + hmrt_tcbc_changeback_ack(chl); + break; + + case TCBC_HMDT_CBA_COMMAND: + mtp3ObjInput.tcbc_input[chl] = IDLE; + break; + + default: + break; + } + break; + + case TCBC_WAIT_FOR_ROUTING_DATA_STATE: + if ( mtp3ObjInput.tcbc_input_from_tsrc[chl] == TCBC_ALTERATIVE_ROUTE_DT ) + { + mtp3_debug(MTP3DB_EVENT,"[tcbc]link %d get routing data from tsrc",chl); +// printf("tcbc link %d get data complete\n",chl); + mtp3ObjInput.tcbc_input_from_tsrc[chl] = IDLE; + lsno = mtp3_para->lk[chl].e1_to_linkset; + if ( tcbc_route_change[chl] == TRUE ) + { + if ( cb_msg_can_exchange[chl] == TRUE ) + /* adjacent sp acessible */ + { + hmrt_tcbc_changeback_declaration(chl); + t4_delay_mtp3[chl] = mtp3_para->lt[chl].t4; + mtp3ObjState.tcbc_state[chl] = TCBC_FIRST_ATTEMPT_STATE; + } + else + { +// mtp3_debug(MTP3DB_EVENT,"start t3"); + t3_delay_mtp3[chl] = mtp3_para->lt[chl].t3; + mtp3ObjState.tcbc_state[chl] = TCBC_TCTRL_DIVERSION_STATE; + } + } + else + { +// mtp3_debug(MTP3DB_EVENT,"error"); + mtp3ObjState.tcbc_state[chl] = TCBC_IDLE_STATE; + changeback_terminated(chl); + } + } + break; + + case TCBC_TCTRL_DIVERSION_STATE: + t3_delay_mtp3[chl] = t3_delay_mtp3[chl] - 1; + if ( t3_delay_mtp3[chl] == 0 ) + changeback_terminated(chl); + break; + + case TCBC_FIRST_ATTEMPT_STATE: + if ( mtp3ObjInput.tcbc_input[chl] == TCBC_HMDT_CBA_COMMAND ) + { +// mtp3_debug(MTP3DB_EVENT,"tcbc receive cba"); + mtp3ObjInput.tcbc_input[chl] = IDLE; + changeback_terminated(chl); + } + + t4_delay_mtp3[chl] = t4_delay_mtp3[chl] - 1; + if ( t4_delay_mtp3[chl] == 0 ) + { + if (mtp3ObjState.tcbc_state[chl] == TCBC_FIRST_ATTEMPT_STATE) + { + hmrt_tcbc_changeback_declaration(chl); + t5_delay_mtp3[chl] = mtp3_para->lt[chl].t5; + mtp3ObjState.tcbc_state[chl] = TCBC_SECOND_ATTEMPT_STATE; + } + } + break; + + case TCBC_SECOND_ATTEMPT_STATE: + t5_delay_mtp3[chl] = t5_delay_mtp3[chl] - 1; + if ( t5_delay_mtp3[chl] == 0 || + mtp3ObjInput.tcbc_input[chl] == TCBC_HMDT_CBA_COMMAND ) + { + mtp3ObjInput.tcbc_input[chl] = IDLE; + changeback_terminated(chl); + } + break; + + default: + break; + } +} + +void tprc_mgmt_signalling_point_restart_indication() +{ + int i,j; + // tprc to llsc restart begins + + for ( i=0; i<=255; i++) + { + //llsc_input_from_stm[chl] = LLSC_INPUT_FROM_STM; + mtp3ObjInput.tsrc_input_from_stm[i] = TSRC_RESTART_BEGINS; + mtp3ObjInput.tlac_input_from_stm[i] = TLAC_RESTART_BEGINS; + //tfrc_input_from_stm[chl] = TFRC_INPUT_FROM_STM; + //rtrc_input_from_stm[chl] = RTRC_INPUT_FROM_STM; + for ( j=0; j<4; j++ ) + { + mtp3.nw[j].rtpc_input[i] = RTPC_RESTART_BEGINS; + mtp3.nw[j].rtac_input[i] = RTAC_RESTART_BEGINS; +// mtp3.nw[j].rsrt_input[i] = RSRT_RESTART_BEGINS; + /* start t18 */ + } + } +} + +void tsrc_send_state_proc(BYTE nw) +{ + int dst; + + for (dst=0; dst<256; dst++) + { + if ( (mtp3.nw[nw].routine[dst] >> 6) == 2 ) + { + if ( (mtp3_para->nw[nw].normal_ls[dst] < 128) && + (mtp3_para->nw[nw].dpc[dst] != 0) ) + mtp3.nw[nw].rtpc_input[dst] = RTPC_DEST_INACCESSIBLE; + hmrt_tfrc_update_routing_tables(dst,tprc_nw); + } + } +} + +void tprc_fun2() +{ + tsrc_send_state_proc(tprc_nw); + tprc_nw++; + mtp3ObjState.tprc_state = TPRC_WAIT03_STATE; + t20_delay_mtp3 = mtp3_para->mtp3_t20; +} + +void tprc_proc()/* we always have stp function */ +{ + int i; + + switch (mtp3ObjState.tprc_state) + { + case TPRC_IDLE_STATE: + switch (mtp3ObjInput.tprc_input) + { + case TPRC_SP_RESTART_INDICATION: + mtp3ObjInput.tprc_input = IDLE; + mtp3ObjState.tprc_state = TPRC_WAIT01_STATE; + t18_delay_mtp3 = mtp3_para->mtp3_t18; + break; + + default: + break; + } + break; + + case TPRC_WAIT01_STATE: + t18_delay_mtp3 = t18_delay_mtp3 - 1; + if ( t18_delay_mtp3 == 0 )/* t18 expired */ + { + if (rv_TRA_num == active_ls_num) + tprc_fun2(); + else + { + t19_delay_mtp3 = mtp3_para->mtp3_t19;//start t19 + mtp3ObjState.tprc_state = TPRC_WAIT02_STATE; + } + } + else + { + if ( current_active_ls_num == active_ls_num) + { + if (rv_TRA_num == active_ls_num) + tprc_fun2(); + else + { + mtp3ObjState.tprc_state = TPRC_WAIT02_STATE; + t19_delay_mtp3 = mtp3_para->mtp3_t19; + } + } + } + break; + + case TPRC_WAIT02_STATE: + t19_delay_mtp3 = t19_delay_mtp3 - 1; + if ( t19_delay_mtp3 == 0 ) + { + tprc_fun2(); + } + break; + + case TPRC_WAIT03_STATE: + t20_delay_mtp3 = t20_delay_mtp3 - 1; + if ( t20_delay_mtp3 == 0 ) + { + for ( i=0; i<=255; i++) + { + //llsc_input_from_stm[chl] = LLSC_INPUT_FROM_STM; + mtp3ObjInput.tsrc_input_from_stm[i] = TSRC_RESTART_ENDS; + mtp3ObjInput.tlac_input_from_stm[i] = TLAC_RESTART_ENDS; + //tfrc_input_from_stm[chl] = TFRC_INPUT_FROM_STM; + //rtrc_input_from_stm[chl] = RTRC_INPUT_FROM_STM; + } + mtp3ObjState.tprc_state = TPRC_RESTART_ENDS_STATE; + } + else + { + if ( tprc_nw < 4 ) + { + tsrc_send_state_proc(tprc_nw); + tprc_nw ++; + } + else + tprc_nw = 0; + } + break; + + case TPRC_RESTART_ENDS_STATE: + mtp3_debug(MTP3DB_EVENT,"sp restart ends"); + mtp3ObjInput.tprc_input = IDLE; + for (i=0; i<128; i++) + { + hmrt_tra_msg(i); + } + mtp3ObjState.tprc_state = TPRC_IDLE_STATE; + rv_TRA_num = 0; + own_sp_restarting = 0; + break; + + default: + break; + } +} + +void taprc_proc(BYTE linkset)/* [STM]adjacent sp restart control,send TFP/TRA to adjacent sp */ +{ + int i; + network *sp; + BYTE nw; + + linkset = linkset & 0x7f; + if (linkset > 127) + return; + nw = (mtp3_para->ls_pro[linkset]) & 3; + sp = &mtp3.nw[nw]; + + switch (mtp3ObjInput.taprc_input[linkset]) + { + case TPRC_ADJACENT_SP_RESTARTING: + for (i=taprc_loop[linkset]; i<=taprc_loop[linkset]+7; i++) + { + if ((sp->routine[i] & 0x30) == 0)/* dst inaccessible */ + { + if ( (mtp3_para->nw[nw].normal_ls[i] < 128) && + (mtp3_para->nw[nw].dpc[i] != 0) ) + { + mtp3.nw[nw].rtpc_input[i] = RTPC_TSRC_SEND_TFP_MSG; + sdTFP_Ls = linkset;/* send TFP to this linkset's remote sp */ + rtpc_proc(nw,i); + } + } + } + taprc_loop[linkset] = taprc_loop[linkset] + 8; + if ( taprc_loop[linkset] == 0 ) + { + mtp3ObjInput.taprc_input[linkset] = IDLE; + sending_phase_finished[linkset] = TRUE; + hmrt_tra_msg(linkset); +// mtp3_debug(MTP3DB_EVENT,"Sd TFA to linkset %d remote sp",linkset); + } + break; + default: + break; + + } +} +/*@end@*/ diff --git a/omc/plat/pal/.copyarea.db b/omc/plat/pal/.copyarea.db new file mode 100644 index 0000000..81e1099 --- /dev/null +++ b/omc/plat/pal/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\pal +2 +4 +5:pal.h|1|11d70a498c8|c5a|3de0ff64|1a1230a07faf11dd8601001c23e19543|0 +4:rm.c|1|11d70a49907|1bd7|3bd2b6c3|1ab230b87faf11dd8601001c23e19543|0 +8:Makefile|1|11d70a4987a|af|e40a2cda|fb948a7e6cf311dd91a5001c23e19543|0 +3:lib|2|0|0|0|bfc1243a464f11dd8a6c001c23e19543|0 diff --git a/omc/plat/pal/Makefile b/omc/plat/pal/Makefile new file mode 100644 index 0000000..a434db7 --- /dev/null +++ b/omc/plat/pal/Makefile @@ -0,0 +1,13 @@ +cc = gcc +CFLAG = -g -Wall -c +PAL_OBJ = rm.o +PAL_LIB = lib/libpal.a + +all: $(PAL_OBJ) + ar -r $(PAL_LIB) $(PAL_OBJ) + +rm.o: rm.c + $(cc) $(CFLAG) $< +clean: + rm -rf *.o $(PAL_LIB) + diff --git a/omc/plat/pal/lib/Just for creating lib directory.txt b/omc/plat/pal/lib/Just for creating lib directory.txt new file mode 100644 index 0000000..e69de29 diff --git a/omc/plat/pal/lib/libpal.a b/omc/plat/pal/lib/libpal.a new file mode 100644 index 0000000..5ff4941 Binary files /dev/null and b/omc/plat/pal/lib/libpal.a differ diff --git a/omc/plat/pal/pal.h b/omc/plat/pal/pal.h new file mode 100644 index 0000000..66b7a02 --- /dev/null +++ b/omc/plat/pal/pal.h @@ -0,0 +1,123 @@ +#ifndef _PAL_H_ +#define _PAL_H_ + +#include "../public/src/include/public.h" + +#define PROTO_AIF 0 +#define PROTO_ISUP 1 +#define PROTO_BICC 2 +#define PROTO_ISDN 3 +#define PROTO_TUP 4 +#define PROTO_SIP 5 +#define PROTO_MGC 6 +#define MAX_PROTO_TYPE 7 + +#define VARIANT_ITU 0 +#define VARIANT_ANSI 1 +#define VARIANT_ETSI 2 +#define VARIANT_UK 3 +#define VARIANT_QSIG 4 + +#define DUAL_SEIZURE_REATTEMPT 0 /* Re-attempt on detection of dual seizure */ +#define DUAL_SEIZURE_CONTINUE 1 /* Continue the call on detection of dual seizure */ + +#define CTRL_PLAT_0 0 +#define CTRL_PLAT_1 1 + +#define PAL_MAX_CALLBACK 64 +#define PAL_MAX_SAP 16 +#define PAL_MAX_CG 256 +#define PAL_MAX_CIRCUIT 256 +#define PAL_DOMAIN_LEN 32 + +typedef struct sap_attribute { + void *event_handle[PAL_MAX_CALLBACK]; +} sap_attrib_struct; + +/* Non-Facility Associated Signalling */ +struct nfas_info { + u8 flag; + u32 prim_link; + u32 backup_link; +}; + +typedef struct cg_attribute { + u8 protocol; + u8 variant; + u8 priority; //0: re-attempt; 1: continue + u8 network_id; + u32 dpc; + u32 opc; + char dest_domain[PAL_DOMAIN_LEN]; //for sip + char local_domain[PAL_DOMAIN_LEN]; //for sip + struct nfas_info nfas; + u32 tg_id; +} cg_attrib_struct; + +typedef struct circuit_attribute { + u8 plat_id; + u8 cic_range; + u32 head_cic; + u32 link_id; //for isdn + u8 user_network_if; //for isdn + u8 d_chnl; //for isdn +} circuit_attrib_struct; + +typedef struct pal_sap { + u8 id; + u8 enable; + sap_attrib_struct attrib; +} pal_sap_struct; + +typedef struct pal_circuitgroup { + u8 id; + u8 enable; + u8 sap_id; + u8 circuit_num; + cg_attrib_struct attrib; +} pal_cg_struct; + +typedef struct pal_circuit { + u8 id; + u8 enable; + u8 cg_id; + circuit_attrib_struct attrib; +} pal_circuit_struct; + +typedef struct _pst_struct +{ + u16 cg_id; + u32 tg_id; + u32 cic; + + u32 sp_proc_id; + u32 su_proc_id; + + int trace_flag; +} Pst; + +/* Upper layer interface */ +extern u8 *pal_version(void); +extern char* pal_error(void); +extern int pal_bind_sap(sap_attrib_struct *attrib); +extern int pal_create_cg(u8 sap_id, cg_attrib_struct *attrib); +extern int pal_delete_cg(int cg_id); +extern int pal_modify_cg(int cg_id, cg_attrib_struct *attrib); +extern int pal_create_circuit(int cg_id, circuit_attrib_struct *attrib); +extern int pal_delete_circuit(int circuit_id); + +/* Lower layer interface */ +extern void *pal_get_handler(u32 cg_id); +extern const pal_sap_struct *pal_sap_ptr(u8 sap_id); +extern const pal_cg_struct *pal_cg_ptr(u32 cg_id); +extern const pal_circuit_struct *pal_circuit_ptr(u32 circuit_id); +extern const pal_cg_struct *pal_ss7_find_cg(u8 ni, u32 dpc, u32 opc); +extern const pal_cg_struct *pal_isdn_find_cg(u32 link_id); +extern const pal_cg_struct *pal_sip_find_cg(char *domain, char *their_domain); +extern const pal_circuit_struct *pal_locate_circuit(u32 cg_id, u32 cic); +extern const pal_circuit_struct *pal_ss7_find_circuit(u8 ni, u32 dpc, u32 opc, u32 cic); +extern const pal_circuit_struct *pal_isdn_find_circuit(u32 link_id, u32 cic); +extern const pal_circuit_struct *pal_isdn_find_circuit_of_link(u32 link_id); + +#endif + diff --git a/omc/plat/pal/rm.c b/omc/plat/pal/rm.c new file mode 100644 index 0000000..8801c75 --- /dev/null +++ b/omc/plat/pal/rm.c @@ -0,0 +1,339 @@ +/* + * pal/rm.c + * + * Copyright (C) 2008 ACRD + * Written by: Xinyu Yan + * + * Description: Protocol Abstraction Layer - resource management part + */ + +#include +#include +#include "pal.h" + +struct resource_mgmt { + pal_sap_struct sap[PAL_MAX_SAP]; + pal_cg_struct cg[PAL_MAX_CG]; + pal_circuit_struct circuit[PAL_MAX_CIRCUIT]; +}; + +#define ERROR_STRING_LEN 256 + +static u8 version[4] = {9, 0, 0, 1}; +static struct resource_mgmt pal_resource; +static char error_string[ERROR_STRING_LEN+1]; + +u8 *pal_version(void) +{ + return version; +} + +char *pal_error(void) +{ + return error_string; +} + +/****************************************************/ +/*************** PAL upper layer interface ***************/ +/****************************************************/ +int pal_bind_sap(sap_attrib_struct *attrib) +{ + int i; + pal_sap_struct *sap; + + for(i = 0; i < PAL_MAX_SAP; i++) + { + sap = &pal_resource.sap[i]; + if(sap->enable == 0) + { + sap->id = i; + sap->enable = 1; + memcpy(&sap->attrib, attrib, sizeof(sap_attrib_struct)); + return i; + } + } + sprintf(error_string, "%s: no free sap\r\n", __FUNCTION__); + return -1; +} + +int pal_unbind_sap(u8 sap_id) +{ + //need not support// + return -1; +} + +int pal_create_cg(u8 sap_id, cg_attrib_struct *attrib) +{ + int i; + pal_cg_struct *cg; + + if(sap_id >= PAL_MAX_SAP) + { + sprintf(error_string, "%s: sap id(%d) out of range\r\n", __FUNCTION__, sap_id); + return -1; + } + if(pal_resource.sap[sap_id].enable == 0) + { + sprintf(error_string, "%s: sap (%d) is not created\r\n", __FUNCTION__, sap_id); + return -1; + } + + for(i = 0; i < PAL_MAX_CG; i++) + { + cg = &pal_resource.cg[i]; + if(cg->enable == 0) + { + cg->id = i; + cg->enable = 1; + cg->sap_id = sap_id; + cg->circuit_num = 0; + memcpy(&cg->attrib, attrib, sizeof(cg_attrib_struct)); + return i; + } + } + sprintf(error_string, "%s: no free cg\r\n", __FUNCTION__); + return -1; +} + +int pal_delete_cg(int cg_id) +{ + pal_cg_struct *cg; + + if(cg_id >= PAL_MAX_CG) + { + sprintf(error_string, "%s: cg id(%d) out of range\r\n", __FUNCTION__, cg_id); + return -1; + } + cg = &pal_resource.cg[cg_id]; + if(cg->circuit_num > 0) + { + sprintf(error_string, "%s: %d circuit in used\r\n", __FUNCTION__, cg->circuit_num); + return -1; + } + cg->enable = 0; + return 0; +} + +int pal_modify_cg(int cg_id, cg_attrib_struct *attrib) +{ + pal_cg_struct *cg; + + if(cg_id >= PAL_MAX_CG) + { + sprintf(error_string, "%s: cg id(%d) out of range\r\n", __FUNCTION__, cg_id); + return -1; + } + cg = &pal_resource.cg[cg_id]; + memcpy(&cg->attrib, attrib, sizeof(cg_attrib_struct)); + return 0; +} + +int pal_create_circuit(int cg_id, circuit_attrib_struct *attrib) +{ + int i; + pal_cg_struct *cg; + pal_circuit_struct *circuit; + + if(cg_id >= PAL_MAX_CG) + { + sprintf(error_string, "%s: cg id(%d) out of range\r\n", __FUNCTION__, cg_id); + return -1; + } + cg = &pal_resource.cg[cg_id]; + if(cg->enable == 0) + { + sprintf(error_string, "%s: cg(%d) is not created\r\n", __FUNCTION__, cg_id); + return -1; + } + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit = &pal_resource.circuit[i]; + if(circuit->enable == 0) + { + circuit->id = i; + circuit->enable = 1; + circuit->cg_id = cg_id; + memcpy(&circuit->attrib, attrib, sizeof(circuit_attrib_struct)); + cg->circuit_num++; + return i; + } + } + sprintf(error_string, "%s: no free circuit\r\n", __FUNCTION__); + return -1; +} + +int pal_delete_circuit(int circuit_id) +{ + pal_cg_struct *cg; + pal_circuit_struct *circuit; + + if(circuit_id >= PAL_MAX_CIRCUIT) + { + sprintf(error_string, "%s: circuit id(%d) out of range\r\n", __FUNCTION__, circuit_id); + return -1; + } + circuit = &pal_resource.circuit[circuit_id]; + cg = &pal_resource.cg[circuit->cg_id]; + circuit->enable = 0; + cg->circuit_num--; + return 0; +} + +/****************************************************/ +/*************** PAL lower layer interface ***************/ +/****************************************************/ +static int protocol_is_ss7(u8 proto) +{ + if((proto == PROTO_AIF) || (proto == PROTO_ISUP) || (proto == PROTO_BICC)) + return 1; + else + return 0; +} + +void *pal_get_handler(u32 cg_id) +{ + u32 sap_id; + + sap_id = pal_resource.cg[cg_id].sap_id; + return pal_resource.sap[sap_id].attrib.event_handle; +} + +const pal_sap_struct *pal_sap_ptr(u8 sap_id) +{ + if(sap_id < PAL_MAX_SAP) + return &pal_resource.sap[sap_id]; + else + return NULL; +} + +const pal_cg_struct *pal_cg_ptr(u32 cg_id) +{ + if(cg_id < PAL_MAX_CG) + return &pal_resource.cg[cg_id]; + else + return NULL; +} + +const pal_circuit_struct *pal_circuit_ptr(u32 circuit_id) +{ + if(circuit_id < PAL_MAX_CIRCUIT) + return &pal_resource.circuit[circuit_id]; + else + return NULL; +} + +const pal_cg_struct *pal_ss7_find_cg(u8 ni, u32 dpc, u32 opc) +{ + int i; + pal_cg_struct *cg; + + for(i = 0; i < PAL_MAX_CG; i++) + { + cg = &pal_resource.cg[i]; + if(cg->enable == 0) + continue; + if(protocol_is_ss7(cg->attrib.protocol) == 0) + continue; + if((cg->attrib.network_id == ni) && + (cg->attrib.opc == opc) && + (cg->attrib.dpc == dpc)) + return cg; + } + return NULL; +} + +const pal_cg_struct *pal_isdn_find_cg(u32 link_id) +{ + int i; + pal_circuit_struct *circuit; + + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit = &pal_resource.circuit[i]; + if(circuit->enable == 0) + continue; + if(pal_resource.cg[circuit->cg_id].attrib.protocol != PROTO_ISDN) + continue; + if(circuit->attrib.link_id == link_id) + return &pal_resource.cg[circuit->cg_id]; + } + return NULL; +} + +const pal_cg_struct *pal_sip_find_cg(char *domain, char *their_domain) +{ + int i; + pal_cg_struct *cg; + + for(i = 0; i < PAL_MAX_CG; i++) + { + cg = &pal_resource.cg[i]; + if(cg->enable == 0) + continue; + if(cg->attrib.protocol != PROTO_SIP) + continue; + if((strcmp(cg->attrib.local_domain, domain) == 0) && \ + (strcmp(cg->attrib.dest_domain, their_domain) == 0)) + return cg; + } + return NULL; +} + +/* + * Use "locate" when received primitive from upper layer + * Use "find" when received message from network + */ +const pal_circuit_struct *pal_locate_circuit(u32 cg_id, u32 cic) +{ + int i; + pal_circuit_struct *circuit; + circuit_attrib_struct *attrib; + + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit = &pal_resource.circuit[i]; + if(circuit->cg_id != cg_id) + continue; + attrib = &circuit->attrib; + if((cic >= attrib->head_cic) && (cic < attrib->head_cic+attrib->cic_range)) + return circuit; + } + return NULL; +} + +const pal_circuit_struct *pal_ss7_find_circuit(u8 ni, u32 dpc, u32 opc, u32 cic) +{ + const pal_cg_struct *cg; + + if((cg = pal_ss7_find_cg(ni, dpc, opc)) == NULL) + return NULL; + return pal_locate_circuit(cg->id, cic); +} + +const pal_circuit_struct *pal_isdn_find_circuit(u32 link_id, u32 cic) +{ + const pal_cg_struct *cg; + + if((cg = pal_isdn_find_cg(link_id)) == NULL) + return NULL; + return pal_locate_circuit(cg->id, cic); +} + +const pal_circuit_struct *pal_isdn_find_circuit_of_link(u32 link_id) +{ + int i; + pal_circuit_struct *circuit; + + for(i = 0; i < PAL_MAX_CIRCUIT; i++) + { + circuit = &pal_resource.circuit[i]; + if(circuit->enable == 0) + continue; + if(pal_resource.cg[circuit->cg_id].attrib.protocol != PROTO_ISDN) + continue; + if(circuit->attrib.link_id == link_id) + return circuit; + } + return NULL; +} + diff --git a/omc/plat/pal/rm.o b/omc/plat/pal/rm.o new file mode 100644 index 0000000..b986d3a Binary files /dev/null and b/omc/plat/pal/rm.o differ diff --git a/omc/plat/public/.copyarea.db b/omc/plat/public/.copyarea.db new file mode 100644 index 0000000..e60b01b --- /dev/null +++ b/omc/plat/public/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public +2 +5 +2:ut|2|0|0|0|7a396fe3bfa511dc85ad001c23e19543|0 +3:src|2|0|0|0|9d3d9499069b11e18fbf001ec9cf72cd|0 +8:Makefile|1|127d644622f|b9b|b9b8c7a2|5a996abfbfa511dc85ad001c23e19543|0 +3:doc|2|0|0|0|5a096a87bfa511dc85ad001c23e19543|0 +3:lib|2|0|0|0|5a996aa3bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/Makefile b/omc/plat/public/Makefile new file mode 100644 index 0000000..842a1e8 --- /dev/null +++ b/omc/plat/public/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = public +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = -DDEBUG + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/public/lib/libpublic.a b/omc/plat/public/lib/libpublic.a new file mode 100644 index 0000000..5750559 Binary files /dev/null and b/omc/plat/public/lib/libpublic.a differ diff --git a/omc/plat/public/obj/apiKey.o b/omc/plat/public/obj/apiKey.o new file mode 100644 index 0000000..cda2da3 Binary files /dev/null and b/omc/plat/public/obj/apiKey.o differ diff --git a/omc/plat/public/obj/asn1.o b/omc/plat/public/obj/asn1.o new file mode 100644 index 0000000..0cd1e7e Binary files /dev/null and b/omc/plat/public/obj/asn1.o differ diff --git a/omc/plat/public/obj/bisearch.o b/omc/plat/public/obj/bisearch.o new file mode 100644 index 0000000..6a4b426 Binary files /dev/null and b/omc/plat/public/obj/bisearch.o differ diff --git a/omc/plat/public/obj/cJSON.o b/omc/plat/public/obj/cJSON.o new file mode 100644 index 0000000..a0ad2d7 Binary files /dev/null and b/omc/plat/public/obj/cJSON.o differ diff --git a/omc/plat/public/obj/cdr.o b/omc/plat/public/obj/cdr.o new file mode 100644 index 0000000..ce927b0 Binary files /dev/null and b/omc/plat/public/obj/cdr.o differ diff --git a/omc/plat/public/obj/crypt.o b/omc/plat/public/obj/crypt.o new file mode 100644 index 0000000..a24a993 Binary files /dev/null and b/omc/plat/public/obj/crypt.o differ diff --git a/omc/plat/public/obj/list.o b/omc/plat/public/obj/list.o new file mode 100644 index 0000000..33dfd88 Binary files /dev/null and b/omc/plat/public/obj/list.o differ diff --git a/omc/plat/public/obj/memwatch.o b/omc/plat/public/obj/memwatch.o new file mode 100644 index 0000000..c4a2c64 Binary files /dev/null and b/omc/plat/public/obj/memwatch.o differ diff --git a/omc/plat/public/obj/number.o b/omc/plat/public/obj/number.o new file mode 100644 index 0000000..a0511b7 Binary files /dev/null and b/omc/plat/public/obj/number.o differ diff --git a/omc/plat/public/obj/numgrp.o b/omc/plat/public/obj/numgrp.o new file mode 100644 index 0000000..650fd24 Binary files /dev/null and b/omc/plat/public/obj/numgrp.o differ diff --git a/omc/plat/public/obj/pub_conf.o b/omc/plat/public/obj/pub_conf.o new file mode 100644 index 0000000..f1c5ccb Binary files /dev/null and b/omc/plat/public/obj/pub_conf.o differ diff --git a/omc/plat/public/obj/pub_debug.o b/omc/plat/public/obj/pub_debug.o new file mode 100644 index 0000000..59c2fff Binary files /dev/null and b/omc/plat/public/obj/pub_debug.o differ diff --git a/omc/plat/public/obj/pub_file.o b/omc/plat/public/obj/pub_file.o new file mode 100644 index 0000000..d1c7739 Binary files /dev/null and b/omc/plat/public/obj/pub_file.o differ diff --git a/omc/plat/public/obj/pub_fmt.o b/omc/plat/public/obj/pub_fmt.o new file mode 100644 index 0000000..cdf5459 Binary files /dev/null and b/omc/plat/public/obj/pub_fmt.o differ diff --git a/omc/plat/public/obj/pub_inet.o b/omc/plat/public/obj/pub_inet.o new file mode 100644 index 0000000..bda34b7 Binary files /dev/null and b/omc/plat/public/obj/pub_inet.o differ diff --git a/omc/plat/public/obj/pub_log.o b/omc/plat/public/obj/pub_log.o new file mode 100644 index 0000000..387653d Binary files /dev/null and b/omc/plat/public/obj/pub_log.o differ diff --git a/omc/plat/public/obj/pub_malloc.o b/omc/plat/public/obj/pub_malloc.o new file mode 100644 index 0000000..68d16d3 Binary files /dev/null and b/omc/plat/public/obj/pub_malloc.o differ diff --git a/omc/plat/public/obj/pub_netcap.o b/omc/plat/public/obj/pub_netcap.o new file mode 100644 index 0000000..39e1bfd Binary files /dev/null and b/omc/plat/public/obj/pub_netcap.o differ diff --git a/omc/plat/public/obj/pub_sdp.o b/omc/plat/public/obj/pub_sdp.o new file mode 100644 index 0000000..7a500c8 Binary files /dev/null and b/omc/plat/public/obj/pub_sdp.o differ diff --git a/omc/plat/public/obj/pub_str.o b/omc/plat/public/obj/pub_str.o new file mode 100644 index 0000000..a59fe78 Binary files /dev/null and b/omc/plat/public/obj/pub_str.o differ diff --git a/omc/plat/public/obj/pub_sys.o b/omc/plat/public/obj/pub_sys.o new file mode 100644 index 0000000..88542b1 Binary files /dev/null and b/omc/plat/public/obj/pub_sys.o differ diff --git a/omc/plat/public/obj/pub_time.o b/omc/plat/public/obj/pub_time.o new file mode 100644 index 0000000..85b88e1 Binary files /dev/null and b/omc/plat/public/obj/pub_time.o differ diff --git a/omc/plat/public/obj/pub_timer.o b/omc/plat/public/obj/pub_timer.o new file mode 100644 index 0000000..2a5ac42 Binary files /dev/null and b/omc/plat/public/obj/pub_timer.o differ diff --git a/omc/plat/public/obj/pub_wnet.o b/omc/plat/public/obj/pub_wnet.o new file mode 100644 index 0000000..3eb1575 Binary files /dev/null and b/omc/plat/public/obj/pub_wnet.o differ diff --git a/omc/plat/public/obj/shm.o b/omc/plat/public/obj/shm.o new file mode 100644 index 0000000..36c1738 Binary files /dev/null and b/omc/plat/public/obj/shm.o differ diff --git a/omc/plat/public/src/.copyarea.db b/omc/plat/public/src/.copyarea.db new file mode 100644 index 0000000..768717e --- /dev/null +++ b/omc/plat/public/src/.copyarea.db @@ -0,0 +1,26 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\src +2 +16 +9:pub_sdp.c|1|127d6447386|9e8e|dc2ee6b1|9b54784a8b0e11de883f001ec9cf72cd|0 +c:pub_netcap.c|1|127d6446c13|245d|32552b6d|1daf6d5641e311df8afa001ec9cf72cd|0 +4:uwav|2|0|0|0|96f6447d9a8511dd8b36001c23e19543|0 +9:pub_sys.c|1|127d6447049|3979|31567382|65596c7fbfa511dc85ad001c23e19543|0 +9:pub_fmt.c|1|128cd7f376c|6f21|beb2f409|8dccec6867aa11df82b4001ec9cf72cd|0 +a:pub_conf.c|1|127d64464b0|10e|20a74078|5bc96af7bfa511dc85ad001c23e19543|0 +9:pub_str.c|1|127d64467cd|661e|d3c0ff5a|5e296b67bfa511dc85ad001c23e19543|0 +6:asn1.c|1|12e7ee24c03|4dc7|3d4c79dc|47416718460f11e09283001ec9cf72cd|0 +a:pub_inet.c|1|127d6446cee|28da|793e6029|1daf6d6e41e311df8afa001ec9cf72cd|0 +7:include|2|0|0|0|ac1d94cd069b11e18fbf001ec9cf72cd|0 +b:pub_timer.c|1|127d6446eb3|16db|39db0bf7|64296c47bfa511dc85ad001c23e19543|0 +7:crypt.c|1|127d6447124|26e6|6634adda|65e96c9bbfa511dc85ad001c23e19543|0 +a:pub_wnet.c|1|127d644653c|317b|e1890fbb|5c696b13bfa511dc85ad001c23e19543|0 +9:pub_log.c|1|127d64468b7|b2d|c3f1bd3b|5f696b83bfa511dc85ad001c23e19543|0 +a:pub_time.c|1|127d6446a5d|d8f|990a6107|60996bbbbfa511dc85ad001c23e19543|0 +5:cdr.c|1|1345dd30e40|2bcc|5f9d882|87761e132ba411e19630001ec9cf72cd|0 +a:bisearch.c|1|127d6446607|1385|f4371070|5cf96b2fbfa511dc85ad001c23e19543|0 +c:pub_malloc.c|1|127d6446992|185|b9cb602e|5ff96b9fbfa511dc85ad001c23e19543|0 +b:pub_debug.c|1|127d6446702|486|f3bb2044|5d996b4bbfa511dc85ad001c23e19543|0 +a:pub_file.c|1|127d6446de8|434|22fef381|62f96c2bbfa511dc85ad001c23e19543|0 +a:memwatch.c|1|127d64472ab|128e8|ccb0b9c1|78696fabbfa511dc85ad001c23e19543|0 +5:shm.c|1|13334a44f40|695|0|a16d94b5069b11e18fbf001ec9cf72cd|0 diff --git a/omc/plat/public/src/apiKey.c b/omc/plat/public/src/apiKey.c new file mode 100644 index 0000000..ab5344e --- /dev/null +++ b/omc/plat/public/src/apiKey.c @@ -0,0 +1,14 @@ +#include +#include +#include "./include/keyValuePair.h" + +keyValuePair_t *keyValuePair_create(char *key, void *value) { + keyValuePair_t *keyValuePair = malloc(sizeof(keyValuePair_t)); + keyValuePair->key = key; + keyValuePair->value = value; + return keyValuePair; +} + +void keyValuePair_free(keyValuePair_t *keyValuePair) { + free(keyValuePair); +} diff --git a/omc/plat/public/src/asn1.c b/omc/plat/public/src/asn1.c new file mode 100644 index 0000000..a5b2c57 --- /dev/null +++ b/omc/plat/public/src/asn1.c @@ -0,0 +1,943 @@ +/********************************************************************/ +/*Title: asn1.c */ +/*Descr: ASN.1 Encoding/Decoding Module */ +/*Author: Liang Hanxi */ +/*Create: 2002-1-15 */ +/*Version: */ +/*Modify: 2002-10-22 */ +/********************************************************************/ + + +#include "./include/asn1.h" +#include +#include +#include + +/*@ignore@*/ +void AsnEncode(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf) +{ + asnbuf->msgbuf=msg_buf; + memset(msg_buf,0,2); + asnbuf->msglen=0; + asnbuf->maxlen=maxlen; +} + +void asn_encode(u_char *msg_buf,ASN_BUF *asnbuf) +{ + AsnEncode(msg_buf,256,asnbuf); +} + +void asn_encode_v3(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf) +{ + AsnEncode(msg_buf,maxlen,asnbuf); +} + +int add_tlv(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf) +{ + return AddTLV(tag_seq,length,pvalue,tlv_type,asnbuf); +} + +int AddTLV(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_short tags[50][2]; + int level; + int rest,swaplen=0,oldlen=0; + int ntag,nlen; + int addval,temp,i,rtn; //temp variable + u_char flag; //temp variable + u_char *ptlv,*pt,*ptr[50],asn_swap[1024]; + + if(asnbuf->msglen+length+5>asnbuf->maxlen) + { + printf("No room for new tlv.maxlen=%d,msglen=%d,addlen=%d\n",asnbuf->maxlen,asnbuf->msglen,length); + return -1; + } + /*search position for new data--->*/ + level = parse_tags(tag_seq,tags); + pt = asnbuf->msgbuf; //start pointer + rest = asnbuf->msglen % 1024; //remain length + for(i = 1; i < level; i++) + { + if(tags[i][1] == 0) //according to tagcode + rtn = findtlv(pt, tags[i][0], &ptlv, rest); + else //according to order + rtn = findtlv2(pt, tags[i][1], &ptlv, rest); + + if(rtn == -1) //length check error + return -1; + else if(rtn == 1) //not found,create it + { + swaplen = asnbuf->msglen - (ptlv - asnbuf->msgbuf); + if(swaplen > 0) + memcpy(asn_swap, ptlv, swaplen); + pt = ptlv; + while(i < level) + { + //printf("create level=%d\n",i); + ntag = addtagcode(pt, tags[i][0], 0xA0); + nlen = addlength(pt + ntag, 0); + ptr[i] = pt + ntag; + addval = modifylength(ptr, i - 1, ntag + nlen); + if(addval==(ntag+nlen+1)) + ptr[i]=pt+ntag+1;//reasigned ptr[i] + pt += addval; + asnbuf->msglen += addval; + i ++; + } + rest = 0; + } + else //found,continue + { + if((rtn & 0x20) == 0) + return -1; + + ntag=gettagcode(ptlv,&temp,&flag); + nlen=getlength(ptlv+ntag,&rest); + ptr[i]=ptlv+ntag; + pt=ptlv+ntag+nlen; + } + } + //insert new data + if(tags[level][1]==0) + { + rtn=findtlv(pt,tags[level][0],&ptlv,rest); + + if(rtn<0) + return -1; + else if(rtn!=1) + { + oldlen=0; + oldlen=gettagcode(ptlv,&temp,&flag); + oldlen+=getlength(ptlv+oldlen,&temp); + oldlen+=temp; + } + if(swaplen==0) + { + swaplen=asnbuf->msglen-(ptlv+oldlen-asnbuf->msgbuf); + if(swaplen>0) + memcpy(asn_swap,ptlv+oldlen,swaplen); + } + + ntag=addtagcode(ptlv,tags[level][0],tlv_type); + nlen=addlength(ptlv+ntag,length); + + memcpy(ptlv+ntag+nlen,pvalue,length); + //modify parent's length + addval=modifylength(ptr,level-1,ntag+nlen+length); + asnbuf->msglen+=addval; + ptlv+=addval; + + } + else + { + rtn=findtlv2(pt,tags[level][1],&ptlv,rest); + if(rtn<0) + return -1; + if(swaplen==0) + { + swaplen=asnbuf->msglen-(ptlv-asnbuf->msgbuf); + if(swaplen>0) + memcpy(asn_swap,ptlv,swaplen); + + } + ntag=addtagcode(ptlv,tags[level][0],tlv_type); + nlen=addlength(ptlv+ntag,length); + memcpy(ptlv+ntag+nlen,pvalue,length); + //modify parent's length + addval=modifylength(ptr,level-1,ntag+nlen+length); + asnbuf->msglen+=addval; + ptlv+=addval; + } + if(swaplen>0) + memcpy(ptlv,asn_swap,swaplen); + return asnbuf->msglen; +} + + +int asn_decode(u_char *msg_buf,int ntlv,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,256,ntlv,NULL,asnbuf); +} + +int asn_decode_v2(u_char *msg_buf,int ntlv,int *errpos,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,256,ntlv,errpos,asnbuf); +} + +int asn_decode_v3(u_char *msg_buf,int msglen,int *errpos,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,msglen,100,errpos,asnbuf); +} + +int AsnDecode(u_char *msg_buf,int msglen,int maxtlv,int *errpos,ASN_BUF *asnbuf) +{ + ASN_TLV *p1=NULL,*p2; + int ntlv=0,retval,sublen=0; + + asnbuf->msgbuf = msg_buf; + asnbuf->tlvcount=0; + asnbuf->pos = 0; + asnbuf->msglen = msglen; + asnbuf->errmsg[0]='\0'; + + while(asnbuf->pos < msglen && ntlvpos; + + retval=parse_tlv(&p2,asnbuf); + + if(retval<0) + { + return -1; + } + else if(retval==0) + { + return sublen; + } + else + { + if(p1!=NULL) + p1->pnext = p2; + p1 = p2; + sublen+=retval; + } + ntlv++; + } + if(errpos!=NULL) + *errpos = asnbuf->pos; + + return sublen; +} + +int get_tlv(const char *tag_seq,u_char *pvalue,ASN_BUF *asnbuf) +{ + return get_tlv_v2(tag_seq,pvalue,NULL,asnbuf); +} + +int get_tlv_v2(const char *tag_seq,u_char *pvalue,u_char *flag,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(flag!=NULL) + *flag=p1->tagtype; + + if(p1->length < 0) + return -1; + else if(p1->length <= 256) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,256); + return 256; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int GetTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char flag,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + //printf("flag:%02X/%02X\n",p1->tagtype,flag); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (depthtagtype == flag) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(p1->length < 0) + return -1; + else if(p1->length <= maxlen) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,maxlen); + return maxlen; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int GetAnyTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char *pflag,u_short *ptagcode,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + //printf("flag:%02X/%02X\n",p1->tagtype,flag); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(pflag!=NULL) + *pflag = p1->tagtype; + if(ptagcode != NULL) + *ptagcode = p1->tagcode; + + if(p1->length < 0) + return -1; + else if(p1->length <= maxlen) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,maxlen); + return maxlen; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int parse_tlv(ASN_TLV **pnode,ASN_BUF *asnbuf) +//idefinite length +{ + int ntag,nlen,length,sublen=0,retval; + u_int tagcode; + u_char tagtype; + u_char *msgbuf=asnbuf->msgbuf; + ASN_TLV *ptlv,*p1=NULL,*p2; + + if(asnbuf->pos == asnbuf->msglen) + { + *pnode=NULL; + return 0; + } + + if(asnbuf->pos+2 > asnbuf->msglen || asnbuf->tlvcount >=256) + { + sprintf(asnbuf->errmsg,"Length check error(rest=%d)/exceed limit(tlvcount=%d)\n",asnbuf->msglen-asnbuf->pos,asnbuf->tlvcount); + return -1; + } + //printf("tlvcount=%d\n",asnbuf->tlvcount); + *pnode = ptlv = &asnbuf->heap[asnbuf->tlvcount++]; + ptlv->psub = ptlv->pnext = NULL; + ptlv->length = -1; + + if((ntag=gettagcode(msgbuf+asnbuf->pos,&tagcode,&tagtype))<1) + { + sprintf(asnbuf->errmsg,"Wrong encoding of tag(pos=%d:%02X %02X %02X)\n",asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + asnbuf->pos+=ntag; + + if((nlen=getlength(msgbuf+asnbuf->pos,&length))<1) + { + sprintf(asnbuf->errmsg,"Wrong encoding of Length(pos=%d:%02X %02X %02X)\n",asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + asnbuf->pos+=nlen; + + if(asnbuf->pos + length >asnbuf->msglen) + { + sprintf(asnbuf->errmsg,"Length Check error.length=%d,rest=%d(pos=%d:%02X %02X %02X)\n",length,asnbuf->msglen-asnbuf->pos,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + + ptlv->tagtype=tagtype; + ptlv->tagcode=tagcode; + ptlv->pvalue=msgbuf+asnbuf->pos; + + if((tagtype & 0x20)==0) //primitive + { + if(length==-1) + { + sprintf(asnbuf->errmsg,"Wrong Encoding of Length:primitive form with indefinite length\n(pos=%d)",asnbuf->pos); + return -1; + } + else + { + ptlv->length = length; + asnbuf->pos += length; + return length+ntag+nlen; + } + } + else //constructor + { + if(length >=0) //short/long definite length + { + ptlv->length = length; + while(sublenerrmsg,"Length Check error.length=%d,sublen=%d(pos=%d:%02X %02X %02X)\n",length,sublen,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + { + if(p1==NULL) + p1=ptlv->psub = p2; + else + { + p1->pnext = p2; + p1 = p2; + } + sublen+=retval; + } + } + if(sublen>length) + { + sprintf(asnbuf->errmsg,"Length Check error.length=%d,sublen=%d(pos=%d:%02X %02X %02X)\n",length,sublen,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + ptlv->length = sublen; + return sublen+ntag+nlen; + } + else //indefinite length + { + while(msgbuf[asnbuf->pos]!=0 || msgbuf[asnbuf->pos+1]!=0) + { + retval=parse_tlv(&p2,asnbuf); + if(retval<0) + { + return -1; + } + else if(retval==0) + { + ptlv->length = sublen; + return sublen+ntag+nlen; + } + else + { + if(p1==NULL) + p1=ptlv->psub = p2; + else + { + p1->pnext = p2; + p1 = p2; + } + sublen+=retval; + } + } + asnbuf->pos += 2; + ptlv->length = sublen; + return sublen+ntag+nlen+2; + } + } + + +} + + +int findtlv(u_char *pasn,u_int tagcode,u_char **pnext,int rest) +//according to tagcode +{ + int ntag,nlen,nvalue,pos=0; + u_int curtag; + u_char type; + //printf("findtlv rest=%d\n",rest); + if(rest==0) + { + *pnext=pasn; + return 1; + } + else if(rest<0) + return -1; + ntag=gettagcode(pasn,&curtag,&type); + if((nlen=getlength(pasn+ntag,&nvalue)) < 0 || nvalue < 0) + return -1; + //printf("ntag=%d,nlen=%d,nvalue=%d\n",ntag,nlen,nvalue); + if(curtag0 && rest>0) + { + ntag=gettagcode((*pnext),&curtag,&type); + nlen=getlength((*pnext)+ntag,&nvalue); + (*pnext)+=(ntag+nlen+nvalue); + rest-=(ntag+nlen+nvalue); + } + + if(index==0 && rest>0) //found + { + ntag=gettagcode((*pnext),&curtag,&type); + return type; + } + else if(rest==0) //seek to end(not found) + return 1; + else + return -1; +} + +int gettagcode(u_char *asnbuf,u_int *tagcode,u_char *type) +{ + u_int pos=0; + *type=asnbuf[pos] & 0xE0; + *tagcode=asnbuf[pos] & 0x1F; + pos++; + if(*tagcode==0x1F) + { + *tagcode=0; + while((asnbuf[pos] & 0x80)==0x80 && pos<3) + { + *tagcode=(*tagcode) * 0x80 + (asnbuf[pos++] & 0x7F); + } + *tagcode=(*tagcode) * 0x80 + (asnbuf[pos++] & 0x7F); + } + return pos; +} + +int getlength(u_char *asnbuf,int *len) +{ + u_int pos=0,lenbyte; + + if((asnbuf[pos] & 0x80)==0) + *len=asnbuf[pos++] & 0x7F; + else + { + *len=0; + lenbyte=asnbuf[pos++] & 0x7F; + if(lenbyte>3 || lenbyte<0) + return -1; + + if(lenbyte==0) + { + *len=-1; + return 1; + } + else + { + while(lenbyte-->0) + *len=(*len)*0x100 + asnbuf[pos++]; + } + + } + + return pos; +} + +int addtagcode(u_char *msg_buf,u_int tagcode,u_char type) +{ + u_int tagbyte=0,pos=0; + int i=3; + u_char buf[4]; + msg_buf[pos]=type & 0xE0; + if(tagcode<31) + msg_buf[pos++]+=tagcode; + else + { + msg_buf[pos++]+=0x1F; + while(i>=0 && tagcode>0) + { + buf[i]=tagcode & 0x7F; + buf[i]|=0x80; + tagcode=tagcode >> 7; + i--; + } + buf[3]&=0x7F; + tagbyte=3-i; + memcpy(msg_buf+pos,buf+i+1,tagbyte); + pos+=tagbyte; + } + return pos; +} +int addlength(u_char *msg_buf,u_int len) +{ + u_int lenbyte=0,pos=0; + int i=3; + u_char buf[4]; + + if(len>=0 && len<=127) + msg_buf[pos++]=len; + else if(len>0) + { + while(i>=0 && len>0) + { + buf[i]=len & 0xFF; + len=len>>8; + i--; + } + lenbyte=3-i; + msg_buf[pos++]=lenbyte | 0x80; + memcpy(msg_buf+pos,buf+i+1,lenbyte); + pos+=lenbyte; + } + return pos; +} + +int parse_tags(const char *tag_seq,u_short (*tags)[2]) +{ + u_short i,j=0,level=1,len; + len=strlen(tag_seq); + + tags[1][0]=0xFFFF; + tags[1][1]=0; + for(i=0;ilenbyte1) + { + memcpy(swapbuf+2,ptr[level]+lenbyte1+2,len+addval-2); + memcpy(ptr[level]+lenbyte2,swapbuf,len+addval); + } + return modifylength(ptr,level-1,addval+lenbyte2-lenbyte1); +} + +void showbuf(u_char *buf,int len) +{ + int i; + for(i=0;i*/ +///////////////////////////////////////////////// +int add_bool(const char *tag_seq,u_char value,u_char tlv_type,ASN_BUF *asnbuf) +{ + return add_tlv(tag_seq,1,&value,tlv_type,asnbuf); +} + +u_char get_bool(const char *tag_seq,ASN_BUF *asnbuf) +{ + u_char pvalue[10]; + get_tlv(tag_seq,pvalue,asnbuf); + return pvalue[0]; +} + +int add_int(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf) +{ + return AddInteger(tag_seq,value,tlv_type,asnbuf); +} + +int AddInteger(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_char buf[4]; + u_int *p_uint=(u_int *)buf; + int i; + + *p_uint=htonl(value); + + if(value<0) + { + for(i=0;i<4;i++) + { + if(buf[i]!=0xFF) + { + if((buf[i] & 0x80)==0) + i--; + break; + } + } + } + else + { + for(i=0;i<4;i++) + { + if(buf[i]!=0) + { + if((buf[i] & 0x80)==0x80) + i--; + break; + } + } + } + + if(i>=4) + i=3; + + return add_tlv(tag_seq,4-i,buf+i,tlv_type,asnbuf); +} + +int GetInteger(const char *tag_seq,int *rtn,u_char flag,ASN_BUF *asnbuf) +{ + u_char pvalue[10]; + int length,i; + length=GetTLV(tag_seq,5,pvalue,flag,asnbuf); + if(length==-1) + return -1; + + if((pvalue[0] & 0x80)==0x80) + *rtn=-1; + else + *rtn=0; + + for(i=0;i=0) + return 1; + else + return -1; +} +int add_oid(const char *tag_seq,const char *oidstr,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_char pvalue[50],buf[4]; + int oid[20],len,i,j,level=0,pos=0; + len=strlen(oidstr); + memset(oid,0,sizeof(oid)); + for(i=0;i>7; + j--; + }while(oid[i]>0 && j>=0); + buf[3]&=0x7F; + len=3-j; + memcpy(pvalue+pos,buf+j+1,len); + pos+=len; + } + return add_tlv(tag_seq,pos,pvalue,tlv_type,asnbuf); +} + +int get_oid(const char *tag_seq,char *oid,ASN_BUF *asnbuf) +{ + u_char pvalue[50]; + char tempstr[50],firstoctet=1; + int length,i,temp=0; + length=get_tlv(tag_seq,pvalue,asnbuf); + + if(length<=0) + return -1; + + for(i=0;i 0) + { + len--; + ptr[i] = buf[len]; + } + else + ptr[i] = pad; + } + return ret; +} +/*@end@*/ diff --git a/omc/plat/public/src/bisearch.c b/omc/plat/public/src/bisearch.c new file mode 100644 index 0000000..1fe339a --- /dev/null +++ b/omc/plat/public/src/bisearch.c @@ -0,0 +1,199 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic implement */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ +#include "memory.h" +#include "malloc.h" +#include "stdlib.h" +#include "./include/bisearch.h" + +/*@ignore@*/ + +int BISearchReg ( BiSearchArray *pBSA, int nTotalSize , void *GetIdleNodeFunc ) +{ + if( pBSA == NULL ) + exit(0); + memset( pBSA , 0 , sizeof(BiSearchArray) ); + pBSA->nArrayCount = 0; + pBSA->nArrayTotalLen = nTotalSize; + pBSA->pBiArray = malloc( sizeof(BiSearch)*nTotalSize ); + memset ( pBSA->pBiArray, 0, BS_SIZE * nTotalSize ); + pBSA->GetIdleNodeFunc = (int (*)(int *))GetIdleNodeFunc; + return 1; +} + +int BISearchUnReg ( BiSearchArray * pBSA) +{ + if( pBSA !=NULL && pBSA->pBiArray != NULL ) + { + free(pBSA->pBiArray); + return 1; + } + return 0; +} + +int BSearch ( BiSearchArray * pBSA, int nStart, int nEnd, LL llKey, int * nPosResult ) +{ + BiSearch *pArray ; + int nPos = -1; + + if( pBSA == NULL ) + + return 0; + if( nStart < 0 || nEnd < 0 || nStart > nEnd || pBSA->nArrayCount < nStart ) + { + return 0; + } + + pArray = pBSA->pBiArray; + if( !pBSA->nArrayCount ) + return (*nPosResult = 0); + if( nEnd > pBSA->nArrayCount-1 ) + nEnd = pBSA->nArrayCount-1; + + for ( nPos = nStart; nStart <= nEnd; nPos = ( nStart + nEnd ) / 2 ) + { + if( pArray[nPos].llKey == llKey ) + { + *nPosResult = nPos; + return 1; + } + if( pArray[nPos].llKey > llKey ) + { + nEnd = nPos - 1; + } + if( pArray[nPos].llKey < llKey ) + { + nStart = nPos + 1; + } + } + if( nPos != -1 && pArray[nPos].llKey < llKey ) + nPos++; + *nPosResult = nPos; + return 0; +} + +int BSearchArray ( BiSearchArray * pBSA, LL llKey, int *nPosResult ) +{ + if( pBSA == NULL ) + return 0; + + return BSearch ( pBSA, 0, (pBSA->nArrayCount > 0 ? pBSA->nArrayCount-1 : 0), llKey, nPosResult ); +} + +int BISInsert ( BiSearchArray * pBSA, LL llKey, int nDUPosIndex ) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + //memery protect: Data Unit Index exceed Data Unit Array Length + if( nDUPosIndex > pBSA->nArrayTotalLen || nDUPosIndex < 0) + return 0; + + if( pBSA->nArrayCount >= pBSA->nArrayTotalLen ) //Array Full + return 0; + + if( !BSearchArray ( pBSA , llKey, &nPos ) && nPos != -1 ) + { + BiSearch *pBS = pBSA->pBiArray + nPos ; + + memmove ( pBS + 1, pBS , BS_SIZE * ( pBSA->nArrayCount - nPos ) ); + pBS->llKey = llKey; + pBS->nDUPosIndex = nDUPosIndex; + pBSA->nArrayCount++; + return 1; + + } + //The Key is existed, insert fail. + return 0; +} + +int BISDelete ( BiSearchArray * pBSA, LL llKey ) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + if( pBSA->nArrayCount <= 0 ) + return 0; + + if( BSearchArray ( pBSA ,llKey, &nPos ) ) + { + BiSearch *pBS = pBSA->pBiArray + nPos; + + memmove ( pBS, pBS + 1, BS_SIZE * ( pBSA->nArrayCount - nPos ) ); + memset ( pBSA->pBiArray + pBSA->nArrayCount, 0, BS_SIZE ); + pBSA->nArrayCount--; + return 1; + } + return 0; +} + +int BISSearch ( BiSearchArray * pBSA, LL llKey , int* nDUPosIndex) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + if( BSearchArray ( pBSA ,llKey, &nPos ) ) + { + *nDUPosIndex = pBSA->pBiArray[nPos].nDUPosIndex; + if( *nDUPosIndex > pBSA->nArrayTotalLen ) + return 0; + return 1; + } + return 0; +} + + +int GetBISearchCount ( BiSearchArray * pBSA) +{ + if( pBSA == NULL ) + return 0; + + return pBSA->nArrayCount; +} + +int GetDUIndex ( BiSearchArray * pBSA, int nBIIndex) +{ + if( pBSA == NULL ) + return 0; + + if( nBIIndex >= pBSA->nArrayCount ) + return -1; + else + return pBSA->pBiArray[nBIIndex].nDUPosIndex; +} + +int BISSearchMng( BiSearchArray * pBSA, BIS_OP mng_type,LL llkey, int* nDUIndex ) +{ + switch( mng_type ) + { + case BIS_INIT: + return BISInsert( pBSA , llkey , *nDUIndex ); + case BIS_SEARCH: + return BISSearch( pBSA , llkey , nDUIndex ); + case BIS_INSERT: + if( pBSA->GetIdleNodeFunc != NULL && pBSA->GetIdleNodeFunc( nDUIndex ) ) + return BISInsert( pBSA , llkey , *nDUIndex ); + break; + case BIS_DELETE: + return BISDelete( pBSA, llkey); + break; + default: + return 0; + } + return 1; +} + +/*@end@*/ + diff --git a/omc/plat/public/src/cJSON.c b/omc/plat/public/src/cJSON.c new file mode 100644 index 0000000..aaa1277 --- /dev/null +++ b/omc/plat/public/src/cJSON.c @@ -0,0 +1,2932 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/* cJSON */ +/* JSON parser in C. */ + +/* disable warnings about old C89 functions in MSVC */ +#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#ifdef __GNUC__ +#pragma GCC visibility push(default) +#endif +#if defined(_MSC_VER) +#pragma warning (push) +/* disable warning about single line comments in system headers */ +#pragma warning (disable : 4001) +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_LOCALES +#include +#endif + +#if defined(_MSC_VER) +#pragma warning (pop) +#endif +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + +#include "./include/cJSON.h" + +/* define our own boolean type */ +#define true ((cJSON_bool)1) +#define false ((cJSON_bool)0) + +typedef struct { + const unsigned char *json; + size_t position; +} error; +static error global_error = { NULL, 0 }; + +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) +{ + return (const char*) (global_error.json + global_error.position); +} + +CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { + if (!cJSON_IsString(item)) { + return NULL; + } + + return item->valuestring; +} + +/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ +#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 7) + #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. +#endif + +CJSON_PUBLIC(const char*) cJSON_Version(void) +{ + static char version[15]; + sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); + + return version; +} + +/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */ +static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) +{ + if ((string1 == NULL) || (string2 == NULL)) + { + return 1; + } + + if (string1 == string2) + { + return 0; + } + + for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) + { + if (*string1 == '\0') + { + return 0; + } + } + + return tolower(*string1) - tolower(*string2); +} + +typedef struct internal_hooks +{ + void *(*allocate)(size_t size); + void (*deallocate)(void *pointer); + void *(*reallocate)(void *pointer, size_t size); +} internal_hooks; + +#if defined(_MSC_VER) +/* work around MSVC error C2322: '...' address of dillimport '...' is not static */ +static void *internal_malloc(size_t size) +{ + return malloc(size); +} +static void internal_free(void *pointer) +{ + free(pointer); +} +static void *internal_realloc(void *pointer, size_t size) +{ + return realloc(pointer, size); +} +#else +#define internal_malloc malloc +#define internal_free free +#define internal_realloc realloc +#endif + +static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; + +static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) +{ + size_t length = 0; + unsigned char *copy = NULL; + + if (string == NULL) + { + return NULL; + } + + length = strlen((const char*)string) + sizeof(""); + copy = (unsigned char*)hooks->allocate(length); + if (copy == NULL) + { + return NULL; + } + memcpy(copy, string, length); + + return copy; +} + +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) +{ + if (hooks == NULL) + { + /* Reset hooks */ + global_hooks.allocate = malloc; + global_hooks.deallocate = free; + global_hooks.reallocate = realloc; + return; + } + + global_hooks.allocate = malloc; + if (hooks->malloc_fn != NULL) + { + global_hooks.allocate = hooks->malloc_fn; + } + + global_hooks.deallocate = free; + if (hooks->free_fn != NULL) + { + global_hooks.deallocate = hooks->free_fn; + } + + /* use realloc only if both free and malloc are used */ + global_hooks.reallocate = NULL; + if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free)) + { + global_hooks.reallocate = realloc; + } +} + +/* Internal constructor. */ +static cJSON *cJSON_New_Item(const internal_hooks * const hooks) +{ + cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON)); + if (node) + { + memset(node, '\0', sizeof(cJSON)); + } + + return node; +} + +/* Delete a cJSON structure. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) +{ + cJSON *next = NULL; + while (item != NULL) + { + next = item->next; + if (!(item->type & cJSON_IsReference) && (item->child != NULL)) + { + cJSON_Delete(item->child); + } + if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) + { + global_hooks.deallocate(item->valuestring); + } + if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + { + global_hooks.deallocate(item->string); + } + global_hooks.deallocate(item); + item = next; + } +} + +/* get the decimal point character of the current locale */ +static unsigned char get_decimal_point(void) +{ +#ifdef ENABLE_LOCALES + struct lconv *lconv = localeconv(); + return (unsigned char) lconv->decimal_point[0]; +#else + return '.'; +#endif +} + +typedef struct +{ + const unsigned char *content; + size_t length; + size_t offset; + size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */ + internal_hooks hooks; +} parse_buffer; + +/* check if the given size is left to read in a given parse buffer (starting with 1) */ +#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) +/* check if the buffer can be accessed at the given index (starting with 0) */ +#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) +#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) +/* get a pointer to the buffer at the position */ +#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) + +/* Parse the input text to generate a number, and populate the result into item. */ +static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) +{ + double number = 0; + unsigned char *after_end = NULL; + unsigned char number_c_string[64]; + unsigned char decimal_point = get_decimal_point(); + size_t i = 0; + + if ((input_buffer == NULL) || (input_buffer->content == NULL)) + { + return false; + } + + /* copy the number into a temporary buffer and replace '.' with the decimal point + * of the current locale (for strtod) + * This also takes care of '\0' not necessarily being available for marking the end of the input */ + for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) + { + switch (buffer_at_offset(input_buffer)[i]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '+': + case '-': + case 'e': + case 'E': + number_c_string[i] = buffer_at_offset(input_buffer)[i]; + break; + + case '.': + number_c_string[i] = decimal_point; + break; + + default: + goto loop_end; + } + } +loop_end: + number_c_string[i] = '\0'; + + number = strtod((const char*)number_c_string, (char**)&after_end); + if (number_c_string == after_end) + { + return false; /* parse_error */ + } + + item->valuedouble = number; + + /* use saturation in case of overflow */ + if (number >= INT_MAX) + { + item->valueint = INT_MAX; + } + else if (number <= INT_MIN) + { + item->valueint = INT_MIN; + } + else + { + item->valueint = (int)number; + } + + item->type = cJSON_Number; + + input_buffer->offset += (size_t)(after_end - number_c_string); + return true; +} + +/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) +{ + if (number >= INT_MAX) + { + object->valueint = INT_MAX; + } + else if (number <= INT_MIN) + { + object->valueint = INT_MIN; + } + else + { + object->valueint = (int)number; + } + + return object->valuedouble = number; +} + +typedef struct +{ + unsigned char *buffer; + size_t length; + size_t offset; + size_t depth; /* current nesting depth (for formatted printing) */ + cJSON_bool noalloc; + cJSON_bool format; /* is this print a formatted print */ + internal_hooks hooks; +} printbuffer; + +/* realloc printbuffer if necessary to have at least "needed" bytes more */ +static unsigned char* ensure(printbuffer * const p, size_t needed) +{ + unsigned char *newbuffer = NULL; + size_t newsize = 0; + + if ((p == NULL) || (p->buffer == NULL)) + { + return NULL; + } + + if ((p->length > 0) && (p->offset >= p->length)) + { + /* make sure that offset is valid */ + return NULL; + } + + if (needed > INT_MAX) + { + /* sizes bigger than INT_MAX are currently not supported */ + return NULL; + } + + needed += p->offset + 1; + if (needed <= p->length) + { + return p->buffer + p->offset; + } + + if (p->noalloc) { + return NULL; + } + + /* calculate new buffer size */ + if (needed > (INT_MAX / 2)) + { + /* overflow of int, use INT_MAX if possible */ + if (needed <= INT_MAX) + { + newsize = INT_MAX; + } + else + { + return NULL; + } + } + else + { + newsize = needed * 2; + } + + if (p->hooks.reallocate != NULL) + { + /* reallocate with realloc if available */ + newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize); + if (newbuffer == NULL) + { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + } + else + { + /* otherwise reallocate manually */ + newbuffer = (unsigned char*)p->hooks.allocate(newsize); + if (!newbuffer) + { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + if (newbuffer) + { + memcpy(newbuffer, p->buffer, p->offset + 1); + } + p->hooks.deallocate(p->buffer); + } + p->length = newsize; + p->buffer = newbuffer; + + return newbuffer + p->offset; +} + +/* calculate the new length of the string in a printbuffer and update the offset */ +static void update_offset(printbuffer * const buffer) +{ + const unsigned char *buffer_pointer = NULL; + if ((buffer == NULL) || (buffer->buffer == NULL)) + { + return; + } + buffer_pointer = buffer->buffer + buffer->offset; + + buffer->offset += strlen((const char*)buffer_pointer); +} + +/* Render the number nicely from the given item into a string. */ +static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + double d = item->valuedouble; + int length = 0; + size_t i = 0; + unsigned char number_buffer[26]; /* temporary buffer to print the number into */ + unsigned char decimal_point = get_decimal_point(); + double test; + + if (output_buffer == NULL) + { + return false; + } + + /* This checks for NaN and Infinity */ + if ((d * 0) != 0) + { + length = sprintf((char*)number_buffer, "null"); + } + else + { + /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ + length = sprintf((char*)number_buffer, "%1.15g", d); + + /* Check whether the original double can be recovered */ + if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || ((double)test != d)) + { + /* If not, print with 17 decimal places of precision */ + length = sprintf((char*)number_buffer, "%1.17g", d); + } + } + + /* sprintf failed or buffer overrun occured */ + if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) + { + return false; + } + + /* reserve appropriate space in the output */ + output_pointer = ensure(output_buffer, (size_t)length + sizeof("")); + if (output_pointer == NULL) + { + return false; + } + + /* copy the printed number to the output and replace locale + * dependent decimal point with '.' */ + for (i = 0; i < ((size_t)length); i++) + { + if (number_buffer[i] == decimal_point) + { + output_pointer[i] = '.'; + continue; + } + + output_pointer[i] = number_buffer[i]; + } + output_pointer[i] = '\0'; + + output_buffer->offset += (size_t)length; + + return true; +} + +/* parse 4 digit hexadecimal number */ +static unsigned parse_hex4(const unsigned char * const input) +{ + unsigned int h = 0; + size_t i = 0; + + for (i = 0; i < 4; i++) + { + /* parse digit */ + if ((input[i] >= '0') && (input[i] <= '9')) + { + h += (unsigned int) input[i] - '0'; + } + else if ((input[i] >= 'A') && (input[i] <= 'F')) + { + h += (unsigned int) 10 + input[i] - 'A'; + } + else if ((input[i] >= 'a') && (input[i] <= 'f')) + { + h += (unsigned int) 10 + input[i] - 'a'; + } + else /* invalid */ + { + return 0; + } + + if (i < 3) + { + /* shift left to make place for the next nibble */ + h = h << 4; + } + } + + return h; +} + +/* converts a UTF-16 literal to UTF-8 + * A literal can be one or two sequences of the form \uXXXX */ +static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer) +{ + long unsigned int codepoint = 0; + unsigned int first_code = 0; + const unsigned char *first_sequence = input_pointer; + unsigned char utf8_length = 0; + unsigned char utf8_position = 0; + unsigned char sequence_length = 0; + unsigned char first_byte_mark = 0; + + if ((input_end - first_sequence) < 6) + { + /* input ends unexpectedly */ + goto fail; + } + + /* get the first utf16 sequence */ + first_code = parse_hex4(first_sequence + 2); + + /* check that the code is valid */ + if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) + { + goto fail; + } + + /* UTF16 surrogate pair */ + if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) + { + const unsigned char *second_sequence = first_sequence + 6; + unsigned int second_code = 0; + sequence_length = 12; /* \uXXXX\uXXXX */ + + if ((input_end - second_sequence) < 6) + { + /* input ends unexpectedly */ + goto fail; + } + + if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) + { + /* missing second half of the surrogate pair */ + goto fail; + } + + /* get the second utf16 sequence */ + second_code = parse_hex4(second_sequence + 2); + /* check that the code is valid */ + if ((second_code < 0xDC00) || (second_code > 0xDFFF)) + { + /* invalid second half of the surrogate pair */ + goto fail; + } + + + /* calculate the unicode codepoint from the surrogate pair */ + codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF)); + } + else + { + sequence_length = 6; /* \uXXXX */ + codepoint = first_code; + } + + /* encode as UTF-8 + * takes at maximum 4 bytes to encode: + * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ + if (codepoint < 0x80) + { + /* normal ascii, encoding 0xxxxxxx */ + utf8_length = 1; + } + else if (codepoint < 0x800) + { + /* two bytes, encoding 110xxxxx 10xxxxxx */ + utf8_length = 2; + first_byte_mark = 0xC0; /* 11000000 */ + } + else if (codepoint < 0x10000) + { + /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */ + utf8_length = 3; + first_byte_mark = 0xE0; /* 11100000 */ + } + else if (codepoint <= 0x10FFFF) + { + /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */ + utf8_length = 4; + first_byte_mark = 0xF0; /* 11110000 */ + } + else + { + /* invalid unicode codepoint */ + goto fail; + } + + /* encode as utf8 */ + for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) + { + /* 10xxxxxx */ + (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF); + codepoint >>= 6; + } + /* encode first byte */ + if (utf8_length > 1) + { + (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF); + } + else + { + (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F); + } + + *output_pointer += utf8_length; + + return sequence_length; + +fail: + return 0; +} + +/* Parse the input text into an unescaped cinput, and populate item. */ +static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) +{ + const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; + const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; + unsigned char *output_pointer = NULL; + unsigned char *output = NULL; + + /* not a string */ + if (buffer_at_offset(input_buffer)[0] != '\"') + { + goto fail; + } + + { + /* calculate approximate size of the output (overestimate) */ + size_t allocation_length = 0; + size_t skipped_bytes = 0; + while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) + { + /* is escape sequence */ + if (input_end[0] == '\\') + { + if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) + { + /* prevent buffer overflow when last input character is a backslash */ + goto fail; + } + skipped_bytes++; + input_end++; + } + input_end++; + } + if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) + { + goto fail; /* string ended unexpectedly */ + } + + /* This is at most how much we need for the output */ + allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes; + output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof("")); + if (output == NULL) + { + goto fail; /* allocation failure */ + } + } + + output_pointer = output; + /* loop through the string literal */ + while (input_pointer < input_end) + { + if (*input_pointer != '\\') + { + *output_pointer++ = *input_pointer++; + } + /* escape sequence */ + else + { + unsigned char sequence_length = 2; + if ((input_end - input_pointer) < 1) + { + goto fail; + } + + switch (input_pointer[1]) + { + case 'b': + *output_pointer++ = '\b'; + break; + case 'f': + *output_pointer++ = '\f'; + break; + case 'n': + *output_pointer++ = '\n'; + break; + case 'r': + *output_pointer++ = '\r'; + break; + case 't': + *output_pointer++ = '\t'; + break; + case '\"': + case '\\': + case '/': + *output_pointer++ = input_pointer[1]; + break; + + /* UTF-16 literal */ + case 'u': + sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer); + if (sequence_length == 0) + { + /* failed to convert UTF16-literal to UTF-8 */ + goto fail; + } + break; + + default: + goto fail; + } + input_pointer += sequence_length; + } + } + + /* zero terminate the output */ + *output_pointer = '\0'; + + item->type = cJSON_String; + item->valuestring = (char*)output; + + input_buffer->offset = (size_t) (input_end - input_buffer->content); + input_buffer->offset++; + + return true; + +fail: + if (output != NULL) + { + input_buffer->hooks.deallocate(output); + } + + if (input_pointer != NULL) + { + input_buffer->offset = (size_t)(input_pointer - input_buffer->content); + } + + return false; +} + +/* Render the cstring provided to an escaped version that can be printed. */ +static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) +{ + const unsigned char *input_pointer = NULL; + unsigned char *output = NULL; + unsigned char *output_pointer = NULL; + size_t output_length = 0; + /* numbers of additional characters needed for escaping */ + size_t escape_characters = 0; + + if (output_buffer == NULL) + { + return false; + } + + /* empty string */ + if (input == NULL) + { + output = ensure(output_buffer, sizeof("\"\"")); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "\"\""); + + return true; + } + + /* set "flag" to 1 if something needs to be escaped */ + for (input_pointer = input; *input_pointer; input_pointer++) + { + switch (*input_pointer) + { + case '\"': + case '\\': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + /* one character escape sequence */ + escape_characters++; + break; + default: + if (*input_pointer < 32) + { + /* UTF-16 escape sequence uXXXX */ + escape_characters += 5; + } + break; + } + } + output_length = (size_t)(input_pointer - input) + escape_characters; + + output = ensure(output_buffer, output_length + sizeof("\"\"")); + if (output == NULL) + { + return false; + } + + /* no characters have to be escaped */ + if (escape_characters == 0) + { + output[0] = '\"'; + memcpy(output + 1, input, output_length); + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; + } + + output[0] = '\"'; + output_pointer = output + 1; + /* copy the string */ + for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) + { + if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) + { + /* normal character, copy */ + *output_pointer = *input_pointer; + } + else + { + /* character needs to be escaped */ + *output_pointer++ = '\\'; + switch (*input_pointer) + { + case '\\': + *output_pointer = '\\'; + break; + case '\"': + *output_pointer = '\"'; + break; + case '\b': + *output_pointer = 'b'; + break; + case '\f': + *output_pointer = 'f'; + break; + case '\n': + *output_pointer = 'n'; + break; + case '\r': + *output_pointer = 'r'; + break; + case '\t': + *output_pointer = 't'; + break; + default: + /* escape and print as unicode codepoint */ + sprintf((char*)output_pointer, "u%04x", *input_pointer); + output_pointer += 4; + break; + } + } + } + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; +} + +/* Invoke print_string_ptr (which is useful) on an item. */ +static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) +{ + return print_string_ptr((unsigned char*)item->valuestring, p); +} + +/* Predeclare these prototypes. */ +static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer); + +/* Utility to jump whitespace and cr/lf */ +static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer) +{ + if ((buffer == NULL) || (buffer->content == NULL)) + { + return NULL; + } + + while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) + { + buffer->offset++; + } + + if (buffer->offset == buffer->length) + { + buffer->offset--; + } + + return buffer; +} + +/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */ +static parse_buffer *skip_utf8_bom(parse_buffer * const buffer) +{ + if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) + { + return NULL; + } + + if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) + { + buffer->offset += 3; + } + + return buffer; +} + +/* Parse an object - create a new root, and populate. */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) +{ + parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; + cJSON *item = NULL; + + /* reset error position */ + global_error.json = NULL; + global_error.position = 0; + + if (value == NULL) + { + goto fail; + } + + buffer.content = (const unsigned char*)value; + buffer.length = strlen((const char*)value) + sizeof(""); + buffer.offset = 0; + buffer.hooks = global_hooks; + + item = cJSON_New_Item(&global_hooks); + if (item == NULL) /* memory fail */ + { + goto fail; + } + + if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) + { + /* parse failure. ep is set. */ + goto fail; + } + + /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ + if (require_null_terminated) + { + buffer_skip_whitespace(&buffer); + if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') + { + goto fail; + } + } + if (return_parse_end) + { + *return_parse_end = (const char*)buffer_at_offset(&buffer); + } + + return item; + +fail: + if (item != NULL) + { + cJSON_Delete(item); + } + + if (value != NULL) + { + error local_error; + local_error.json = (const unsigned char*)value; + local_error.position = 0; + + if (buffer.offset < buffer.length) + { + local_error.position = buffer.offset; + } + else if (buffer.length > 0) + { + local_error.position = buffer.length - 1; + } + + if (return_parse_end != NULL) + { + *return_parse_end = (const char*)local_error.json + local_error.position; + } + + global_error = local_error; + } + + return NULL; +} + +/* Default options for cJSON_Parse */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) +{ + return cJSON_ParseWithOpts(value, 0, 0); +} + +#define cjson_min(a, b) ((a < b) ? a : b) + +static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) +{ + static const size_t default_buffer_size = 256; + printbuffer buffer[1]; + unsigned char *printed = NULL; + + memset(buffer, 0, sizeof(buffer)); + + /* create buffer */ + buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size); + buffer->length = default_buffer_size; + buffer->format = format; + buffer->hooks = *hooks; + if (buffer->buffer == NULL) + { + goto fail; + } + + /* print the value */ + if (!print_value(item, buffer)) + { + goto fail; + } + update_offset(buffer); + + /* check if reallocate is available */ + if (hooks->reallocate != NULL) + { + printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1); + if (printed == NULL) { + goto fail; + } + buffer->buffer = NULL; + } + else /* otherwise copy the JSON over to a new buffer */ + { + printed = (unsigned char*) hooks->allocate(buffer->offset + 1); + if (printed == NULL) + { + goto fail; + } + memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1)); + printed[buffer->offset] = '\0'; /* just to be sure */ + + /* free the buffer */ + hooks->deallocate(buffer->buffer); + } + + return printed; + +fail: + if (buffer->buffer != NULL) + { + hooks->deallocate(buffer->buffer); + } + + if (printed != NULL) + { + hooks->deallocate(printed); + } + + return NULL; +} + +/* Render a cJSON item/entity/structure to text. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) +{ + return (char*)print(item, true, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) +{ + return (char*)print(item, false, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) +{ + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if (prebuffer < 0) + { + return NULL; + } + + p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); + if (!p.buffer) + { + return NULL; + } + + p.length = (size_t)prebuffer; + p.offset = 0; + p.noalloc = false; + p.format = fmt; + p.hooks = global_hooks; + + if (!print_value(item, &p)) + { + global_hooks.deallocate(p.buffer); + return NULL; + } + + return (char*)p.buffer; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) +{ + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if ((len < 0) || (buf == NULL)) + { + return false; + } + + p.buffer = (unsigned char*)buf; + p.length = (size_t)len; + p.offset = 0; + p.noalloc = true; + p.format = fmt; + p.hooks = global_hooks; + + return print_value(item, &p); +} + +/* Parser core - when encountering text, process appropriately. */ +static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) +{ + if ((input_buffer == NULL) || (input_buffer->content == NULL)) + { + return false; /* no input */ + } + + /* parse the different types of values */ + /* null */ + if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) + { + item->type = cJSON_NULL; + input_buffer->offset += 4; + return true; + } + /* false */ + if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) + { + item->type = cJSON_False; + input_buffer->offset += 5; + return true; + } + /* true */ + if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0)) + { + item->type = cJSON_True; + item->valueint = 1; + input_buffer->offset += 4; + return true; + } + /* string */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) + { + return parse_string(item, input_buffer); + } + /* number */ + if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) + { + return parse_number(item, input_buffer); + } + /* array */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) + { + return parse_array(item, input_buffer); + } + /* object */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) + { + return parse_object(item, input_buffer); + } + + return false; +} + +/* Render a value to text. */ +static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output = NULL; + + if ((item == NULL) || (output_buffer == NULL)) + { + return false; + } + + switch ((item->type) & 0xFF) + { + case cJSON_NULL: + output = ensure(output_buffer, 5); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "null"); + return true; + + case cJSON_False: + output = ensure(output_buffer, 6); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "false"); + return true; + + case cJSON_True: + output = ensure(output_buffer, 5); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "true"); + return true; + + case cJSON_Number: + return print_number(item, output_buffer); + + case cJSON_Raw: + { + size_t raw_length = 0; + if (item->valuestring == NULL) + { + return false; + } + + raw_length = strlen(item->valuestring) + sizeof(""); + output = ensure(output_buffer, raw_length); + if (output == NULL) + { + return false; + } + memcpy(output, item->valuestring, raw_length); + return true; + } + + case cJSON_String: + return print_string(item, output_buffer); + + case cJSON_Array: + return print_array(item, output_buffer); + + case cJSON_Object: + return print_object(item, output_buffer); + + default: + return false; + } +} + +/* Build an array from input text. */ +static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) +{ + cJSON *head = NULL; /* head of the linked list */ + cJSON *current_item = NULL; + + if (input_buffer->depth >= CJSON_NESTING_LIMIT) + { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if (buffer_at_offset(input_buffer)[0] != '[') + { + /* not an array */ + goto fail; + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) + { + /* empty array */ + goto success; + } + + /* check if we skipped to the end of the buffer */ + if (cannot_access_at_index(input_buffer, 0)) + { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do + { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if (new_item == NULL) + { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if (head == NULL) + { + /* start the linked list */ + current_item = head = new_item; + } + else + { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse next value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_value(current_item, input_buffer)) + { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } + while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') + { + goto fail; /* expected end of array */ + } + +success: + input_buffer->depth--; + + item->type = cJSON_Array; + item->child = head; + + input_buffer->offset++; + + return true; + +fail: + if (head != NULL) + { + cJSON_Delete(head); + } + + return false; +} + +/* Render an array to text */ +static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_element = item->child; + + if (output_buffer == NULL) + { + return false; + } + + /* Compose the output array. */ + /* opening square bracket */ + output_pointer = ensure(output_buffer, 1); + if (output_pointer == NULL) + { + return false; + } + + *output_pointer = '['; + output_buffer->offset++; + output_buffer->depth++; + + while (current_element != NULL) + { + if (!print_value(current_element, output_buffer)) + { + return false; + } + update_offset(output_buffer); + if (current_element->next) + { + length = (size_t) (output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ','; + if(output_buffer->format) + { + *output_pointer++ = ' '; + } + *output_pointer = '\0'; + output_buffer->offset += length; + } + current_element = current_element->next; + } + + output_pointer = ensure(output_buffer, 2); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ']'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Build an object from the text. */ +static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) +{ + cJSON *head = NULL; /* linked list head */ + cJSON *current_item = NULL; + + if (input_buffer->depth >= CJSON_NESTING_LIMIT) + { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) + { + goto fail; /* not an object */ + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) + { + goto success; /* empty object */ + } + + /* check if we skipped to the end of the buffer */ + if (cannot_access_at_index(input_buffer, 0)) + { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do + { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if (new_item == NULL) + { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if (head == NULL) + { + /* start the linked list */ + current_item = head = new_item; + } + else + { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse the name of the child */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_string(current_item, input_buffer)) + { + goto fail; /* faile to parse name */ + } + buffer_skip_whitespace(input_buffer); + + /* swap valuestring and string, because we parsed the name */ + current_item->string = current_item->valuestring; + current_item->valuestring = NULL; + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) + { + goto fail; /* invalid object */ + } + + /* parse the value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_value(current_item, input_buffer)) + { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } + while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) + { + goto fail; /* expected end of object */ + } + +success: + input_buffer->depth--; + + item->type = cJSON_Object; + item->child = head; + + input_buffer->offset++; + return true; + +fail: + if (head != NULL) + { + cJSON_Delete(head); + } + + return false; +} + +/* Render an object to text. */ +static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_item = item->child; + + if (output_buffer == NULL) + { + return false; + } + + /* Compose the output: */ + length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */ + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + + *output_pointer++ = '{'; + output_buffer->depth++; + if (output_buffer->format) + { + *output_pointer++ = '\n'; + } + output_buffer->offset += length; + + while (current_item) + { + if (output_buffer->format) + { + size_t i; + output_pointer = ensure(output_buffer, output_buffer->depth); + if (output_pointer == NULL) + { + return false; + } + for (i = 0; i < output_buffer->depth; i++) + { + *output_pointer++ = '\t'; + } + output_buffer->offset += output_buffer->depth; + } + + /* print key */ + if (!print_string_ptr((unsigned char*)current_item->string, output_buffer)) + { + return false; + } + update_offset(output_buffer); + + length = (size_t) (output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ':'; + if (output_buffer->format) + { + *output_pointer++ = '\t'; + } + output_buffer->offset += length; + + /* print value */ + if (!print_value(current_item, output_buffer)) + { + return false; + } + update_offset(output_buffer); + + /* print comma if not last */ + length = (size_t) ((output_buffer->format ? 1 : 0) + (current_item->next ? 1 : 0)); + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + if (current_item->next) + { + *output_pointer++ = ','; + } + + if (output_buffer->format) + { + *output_pointer++ = '\n'; + } + *output_pointer = '\0'; + output_buffer->offset += length; + + current_item = current_item->next; + } + + output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); + if (output_pointer == NULL) + { + return false; + } + if (output_buffer->format) + { + size_t i; + for (i = 0; i < (output_buffer->depth - 1); i++) + { + *output_pointer++ = '\t'; + } + } + *output_pointer++ = '}'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Get Array size/item / object item. */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) +{ + cJSON *child = NULL; + size_t size = 0; + + if (array == NULL) + { + return 0; + } + + child = array->child; + + while(child != NULL) + { + size++; + child = child->next; + } + + /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ + + return (int)size; +} + +static cJSON* get_array_item(const cJSON *array, size_t index) +{ + cJSON *current_child = NULL; + + if (array == NULL) + { + return NULL; + } + + current_child = array->child; + while ((current_child != NULL) && (index > 0)) + { + index--; + current_child = current_child->next; + } + + return current_child; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) +{ + if (index < 0) + { + return NULL; + } + + return get_array_item(array, (size_t)index); +} + +static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) +{ + cJSON *current_element = NULL; + + if ((object == NULL) || (name == NULL)) + { + return NULL; + } + + current_element = object->child; + if (case_sensitive) + { + while ((current_element != NULL) && (strcmp(name, current_element->string) != 0)) + { + current_element = current_element->next; + } + } + else + { + while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0)) + { + current_element = current_element->next; + } + } + + return current_element; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string) +{ + return get_object_item(object, string, false); +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) +{ + return get_object_item(object, string, true); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) +{ + return cJSON_GetObjectItem(object, string) ? 1 : 0; +} + +/* Utility for array list handling. */ +static void suffix_object(cJSON *prev, cJSON *item) +{ + prev->next = item; + item->prev = prev; +} + +/* Utility for handling references. */ +static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) +{ + cJSON *reference = NULL; + if (item == NULL) + { + return NULL; + } + + reference = cJSON_New_Item(hooks); + if (reference == NULL) + { + return NULL; + } + + memcpy(reference, item, sizeof(cJSON)); + reference->string = NULL; + reference->type |= cJSON_IsReference; + reference->next = reference->prev = NULL; + return reference; +} + +static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) +{ + cJSON *child = NULL; + + if ((item == NULL) || (array == NULL)) + { + return false; + } + + child = array->child; + + if (child == NULL) + { + /* list is empty, start new one */ + array->child = item; + } + else + { + /* append to the end */ + while (child->next) + { + child = child->next; + } + suffix_object(child, item); + } + + return true; +} + +/* Add item to array/object. */ +CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) +{ + add_item_to_array(array, item); +} + +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) + #pragma GCC diagnostic push +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif +/* helper function to cast away const */ +static void* cast_away_const(const void* string) +{ + return (void*)string; +} +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) + #pragma GCC diagnostic pop +#endif + + +static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key) +{ + char *new_key = NULL; + int new_type = cJSON_Invalid; + + if ((object == NULL) || (string == NULL) || (item == NULL)) + { + return false; + } + + if (constant_key) + { + new_key = (char*)cast_away_const(string); + new_type = item->type | cJSON_StringIsConst; + } + else + { + new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks); + if (new_key == NULL) + { + return false; + } + + new_type = item->type & ~cJSON_StringIsConst; + } + + if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + { + hooks->deallocate(item->string); + } + + item->string = new_key; + item->type = new_type; + + return add_item_to_array(object, item); +} + +CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) +{ + add_item_to_object(object, string, item, &global_hooks, false); +} + +/* Add an item to an object with constant string as key */ +CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) +{ + add_item_to_object(object, string, item, &global_hooks, true); +} + +CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) +{ + if (array == NULL) + { + return; + } + + add_item_to_array(array, create_reference(item, &global_hooks)); +} + +CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) +{ + if ((object == NULL) || (string == NULL)) + { + return; + } + + add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); +} + +CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) +{ + cJSON *null = cJSON_CreateNull(); + if (add_item_to_object(object, name, null, &global_hooks, false)) + { + return null; + } + + cJSON_Delete(null); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name) +{ + cJSON *true_item = cJSON_CreateTrue(); + if (add_item_to_object(object, name, true_item, &global_hooks, false)) + { + return true_item; + } + + cJSON_Delete(true_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name) +{ + cJSON *false_item = cJSON_CreateFalse(); + if (add_item_to_object(object, name, false_item, &global_hooks, false)) + { + return false_item; + } + + cJSON_Delete(false_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean) +{ + cJSON *bool_item = cJSON_CreateBool(boolean); + if (add_item_to_object(object, name, bool_item, &global_hooks, false)) + { + return bool_item; + } + + cJSON_Delete(bool_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number) +{ + cJSON *number_item = cJSON_CreateNumber(number); + if (add_item_to_object(object, name, number_item, &global_hooks, false)) + { + return number_item; + } + + cJSON_Delete(number_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string) +{ + cJSON *string_item = cJSON_CreateString(string); + if (add_item_to_object(object, name, string_item, &global_hooks, false)) + { + return string_item; + } + + cJSON_Delete(string_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) +{ + cJSON *raw_item = cJSON_CreateRaw(raw); + if (add_item_to_object(object, name, raw_item, &global_hooks, false)) + { + return raw_item; + } + + cJSON_Delete(raw_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name) +{ + cJSON *object_item = cJSON_CreateObject(); + if (add_item_to_object(object, name, object_item, &global_hooks, false)) + { + return object_item; + } + + cJSON_Delete(object_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name) +{ + cJSON *array = cJSON_CreateArray(); + if (add_item_to_object(object, name, array, &global_hooks, false)) + { + return array; + } + + cJSON_Delete(array); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) +{ + if ((parent == NULL) || (item == NULL)) + { + return NULL; + } + + if (item->prev != NULL) + { + /* not the first element */ + item->prev->next = item->next; + } + if (item->next != NULL) + { + /* not the last element */ + item->next->prev = item->prev; + } + + if (item == parent->child) + { + /* first element */ + parent->child = item->next; + } + /* make sure the detached item doesn't point anywhere anymore */ + item->prev = NULL; + item->next = NULL; + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) +{ + if (which < 0) + { + return NULL; + } + + return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) +{ + cJSON_Delete(cJSON_DetachItemFromArray(array, which)); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) +{ + cJSON *to_detach = cJSON_GetObjectItem(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) +{ + cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) +{ + cJSON_Delete(cJSON_DetachItemFromObject(object, string)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) +{ + cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); +} + +/* Replace array/object items with new ones. */ +CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) +{ + cJSON *after_inserted = NULL; + + if (which < 0) + { + return; + } + + after_inserted = get_array_item(array, (size_t)which); + if (after_inserted == NULL) + { + add_item_to_array(array, newitem); + return; + } + + newitem->next = after_inserted; + newitem->prev = after_inserted->prev; + after_inserted->prev = newitem; + if (after_inserted == array->child) + { + array->child = newitem; + } + else + { + newitem->prev->next = newitem; + } +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) +{ + if ((parent == NULL) || (replacement == NULL) || (item == NULL)) + { + return false; + } + + if (replacement == item) + { + return true; + } + + replacement->next = item->next; + replacement->prev = item->prev; + + if (replacement->next != NULL) + { + replacement->next->prev = replacement; + } + if (replacement->prev != NULL) + { + replacement->prev->next = replacement; + } + if (parent->child == item) + { + parent->child = replacement; + } + + item->next = NULL; + item->prev = NULL; + cJSON_Delete(item); + + return true; +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) +{ + if (which < 0) + { + return; + } + + cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); +} + +static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) +{ + if ((replacement == NULL) || (string == NULL)) + { + return false; + } + + /* replace the name in the replacement */ + if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) + { + cJSON_free(replacement->string); + } + replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); + replacement->type &= ~cJSON_StringIsConst; + + cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); + + return true; +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) +{ + replace_item_in_object(object, string, newitem, false); +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) +{ + replace_item_in_object(object, string, newitem, true); +} + +/* Create basic types: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_NULL; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_True; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = b ? cJSON_True : cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_Number; + item->valuedouble = num; + + /* use saturation in case of overflow */ + if (num >= INT_MAX) + { + item->valueint = INT_MAX; + } + else if (num <= INT_MIN) + { + item->valueint = INT_MIN; + } + else + { + item->valueint = (int)num; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_String; + item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); + if(!item->valuestring) + { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) + { + item->type = cJSON_String | cJSON_IsReference; + item->valuestring = (char*)cast_away_const(string); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) { + item->type = cJSON_Object | cJSON_IsReference; + item->child = (cJSON*)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) { + item->type = cJSON_Array | cJSON_IsReference; + item->child = (cJSON*)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_Raw; + item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); + if(!item->valuestring) + { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type=cJSON_Array; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item) + { + item->type = cJSON_Object; + } + + return item; +} + +/* Create Arrays: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + for(i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber(numbers[i]); + if (!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber((double)numbers[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0;a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber(numbers[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (strings == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for (i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateString(strings[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p,n); + } + p = n; + } + + return a; +} + +/* Duplication */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) +{ + cJSON *newitem = NULL; + cJSON *child = NULL; + cJSON *next = NULL; + cJSON *newchild = NULL; + + /* Bail on bad ptr */ + if (!item) + { + goto fail; + } + /* Create new item */ + newitem = cJSON_New_Item(&global_hooks); + if (!newitem) + { + goto fail; + } + /* Copy over all vars */ + newitem->type = item->type & (~cJSON_IsReference); + newitem->valueint = item->valueint; + newitem->valuedouble = item->valuedouble; + if (item->valuestring) + { + newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); + if (!newitem->valuestring) + { + goto fail; + } + } + if (item->string) + { + newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks); + if (!newitem->string) + { + goto fail; + } + } + /* If non-recursive, then we're done! */ + if (!recurse) + { + return newitem; + } + /* Walk the ->next chain for the child. */ + child = item->child; + while (child != NULL) + { + newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ + if (!newchild) + { + goto fail; + } + if (next != NULL) + { + /* If newitem->child already set, then crosswire ->prev and ->next and move on */ + next->next = newchild; + newchild->prev = next; + next = newchild; + } + else + { + /* Set newitem->child and move to it */ + newitem->child = newchild; + next = newchild; + } + child = child->next; + } + + return newitem; + +fail: + if (newitem != NULL) + { + cJSON_Delete(newitem); + } + + return NULL; +} + +CJSON_PUBLIC(void) cJSON_Minify(char *json) +{ + unsigned char *into = (unsigned char*)json; + + if (json == NULL) + { + return; + } + + while (*json) + { + if (*json == ' ') + { + json++; + } + else if (*json == '\t') + { + /* Whitespace characters. */ + json++; + } + else if (*json == '\r') + { + json++; + } + else if (*json=='\n') + { + json++; + } + else if ((*json == '/') && (json[1] == '/')) + { + /* double-slash comments, to end of line. */ + while (*json && (*json != '\n')) + { + json++; + } + } + else if ((*json == '/') && (json[1] == '*')) + { + /* multiline comments. */ + while (*json && !((*json == '*') && (json[1] == '/'))) + { + json++; + } + json += 2; + } + else if (*json == '\"') + { + /* string literals, which are \" sensitive. */ + *into++ = (unsigned char)*json++; + while (*json && (*json != '\"')) + { + if (*json == '\\') + { + *into++ = (unsigned char)*json++; + } + *into++ = (unsigned char)*json++; + } + *into++ = (unsigned char)*json++; + } + else + { + /* All other characters. */ + *into++ = (unsigned char)*json++; + } + } + + /* and null-terminate. */ + *into = '\0'; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Invalid; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_False; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xff) == cJSON_True; +} + + +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & (cJSON_True | cJSON_False)) != 0; +} +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_NULL; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Number; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_String; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Array; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Object; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Raw; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) +{ + if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) + { + return false; + } + + /* check if type is valid */ + switch (a->type & 0xFF) + { + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + case cJSON_Number: + case cJSON_String: + case cJSON_Raw: + case cJSON_Array: + case cJSON_Object: + break; + + default: + return false; + } + + /* identical objects are equal */ + if (a == b) + { + return true; + } + + switch (a->type & 0xFF) + { + /* in these cases and equal type is enough */ + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + return true; + + case cJSON_Number: + if (a->valuedouble == b->valuedouble) + { + return true; + } + return false; + + case cJSON_String: + case cJSON_Raw: + if ((a->valuestring == NULL) || (b->valuestring == NULL)) + { + return false; + } + if (strcmp(a->valuestring, b->valuestring) == 0) + { + return true; + } + + return false; + + case cJSON_Array: + { + cJSON *a_element = a->child; + cJSON *b_element = b->child; + + for (; (a_element != NULL) && (b_element != NULL);) + { + if (!cJSON_Compare(a_element, b_element, case_sensitive)) + { + return false; + } + + a_element = a_element->next; + b_element = b_element->next; + } + + /* one of the arrays is longer than the other */ + if (a_element != b_element) { + return false; + } + + return true; + } + + case cJSON_Object: + { + cJSON *a_element = NULL; + cJSON *b_element = NULL; + cJSON_ArrayForEach(a_element, a) + { + /* TODO This has O(n^2) runtime, which is horrible! */ + b_element = get_object_item(b, a_element->string, case_sensitive); + if (b_element == NULL) + { + return false; + } + + if (!cJSON_Compare(a_element, b_element, case_sensitive)) + { + return false; + } + } + + /* doing this twice, once on a and b to prevent true comparison if a subset of b + * TODO: Do this the proper way, this is just a fix for now */ + cJSON_ArrayForEach(b_element, b) + { + a_element = get_object_item(a, b_element->string, case_sensitive); + if (a_element == NULL) + { + return false; + } + + if (!cJSON_Compare(b_element, a_element, case_sensitive)) + { + return false; + } + } + + return true; + } + + default: + return false; + } +} + +CJSON_PUBLIC(void *) cJSON_malloc(size_t size) +{ + return global_hooks.allocate(size); +} + +CJSON_PUBLIC(void) cJSON_free(void *object) +{ + global_hooks.deallocate(object); +} diff --git a/omc/plat/public/src/cdr.c b/omc/plat/public/src/cdr.c new file mode 100644 index 0000000..29c379e --- /dev/null +++ b/omc/plat/public/src/cdr.c @@ -0,0 +1,448 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "./include/cdr.h" + +static _cdr_vm_struct *cdr_vm_ptr; +static int cdr_sem_id; +static _cdr_param cdr_param; +static char cdr_time[8]; +static int cdr_counter0=0,cdr_counter1=0; +static int ssn_counter[256]; + +int cdr_init(char plane_id, char type_flag) /* type=0/1: slave(MSS), master */ +{ + int cdr_shm_id; + + GetCurrentTime(cdr_time); + + cdr_vm_ptr = (_cdr_vm_struct *)shm_init(cdr_shm_id, + "cdr_init", + CDR_SHM_KEY, + sizeof(_cdr_vm_struct), + CDR_SHM_PERM|IPC_CREAT); + cdr_sem_id = sem_init("cdr_init", CDR_SEM_KEY, 1, CDR_SEM_PERM|IPC_CREAT ); + + if(type_flag == 0) + { + memset(cdr_vm_ptr, 0x00, sizeof(_cdr_vm_struct)); + cdr_vm_ptr->plane_id = plane_id; + } + else + { + cdr_config(); + cdr_vm_ptr->plane_id = cdr_param.system_id; + } + + + return 0; +} + +int cdr_timer() +{ + static int cdr_timer_counter = 0; + + if(cdr_timer_counter++%200 == 0) /*every 2 seconds */ + { + GetCurrentTime(cdr_time); + if(cdr_time[4] == 0 && cdr_time[5]>0 && cdr_time[5] <= 2) + { + cdr_open_all_new_fd(); + } + if(cdr_time[3] == 0 && cdr_time[4] ==0 && cdr_time[5] <= 2) + { + clean_expired_backup_file(); + } + } + + cdr_backup(); + + return 1; +} + +/* -------- initialisation functions *---------- */ + +_cdr_param default_param= +{ + 0, + "/usr/local/backup/cdr", + ".csv", + 0, + 7, +}; + +int cdr_open_ssn_file(int index) +{ + char *file_name, file_name0[128],file_name_new[128]; + + if(!cdr_param.ssn_param[index].ssn) + return 0; + file_name = &file_name0[0]; + + if(cdr_param.max_records_per_file == 0) + { + sprintf(file_name,"%s/cdrFrom%s%d_%d_%02d_%02d_%02d%s", + cdr_param.base_dir, + cdr_param.ssn_param[index].name, + cdr_vm_ptr->plane_id, + cdr_time[0]+2000, + cdr_time[1], + cdr_time[2], + cdr_time[3], + cdr_param.file_suffix); + } + else + { + if(cdr_param.init_flag == 0) + { + DIR *dp; + struct dirent *dirp; + int no=0,n; + + if((dp=opendir(cdr_param.base_dir))==NULL) + printf("can't open %s",cdr_param.base_dir); + + while (((dirp=readdir(dp))!=NULL) && (n<=50)) + { + sprintf(file_name_new,"cdrFrom%s%d_%d_%02d_%02d_%02d", + cdr_param.ssn_param[index].name, + cdr_vm_ptr->plane_id, + cdr_time[0]+2000, + cdr_time[1], + cdr_time[2], + cdr_time[3]); + no = 0; + if(!strncasecmp(dirp->d_name,file_name_new,strlen((char *)file_name_new))) + { + while(1) + { + sprintf(file_name,"%s_%d%s", + file_name_new, + no, + cdr_param.file_suffix); + if(strncasecmp(dirp->d_name,file_name,strlen((char *)file_name)<0)) + break; + else if(!strncasecmp(dirp->d_name,file_name,strlen((char *)file_name))) + { + if((no+1)>cdr_param.ssn_param[index].file_sn) /* a new file */ + cdr_param.ssn_param[index].file_sn = no+1; + break; + } + no++; + } //while + } //if + }//while + + closedir(dp); + + sprintf(file_name,"%s/cdrFrom%s%d_%d_%02d_%02d_%02d_%d%s", + cdr_param.base_dir, + cdr_param.ssn_param[index].name, + cdr_vm_ptr->plane_id, + cdr_time[0]+2000, + cdr_time[1], + cdr_time[2], + cdr_time[3], + cdr_param.ssn_param[index].file_sn++, + cdr_param.file_suffix); + + } + else + { + sprintf(file_name,"%s/cdrFrom%s%d_%d_%02d_%02d_%02d_%d%s", + cdr_param.base_dir, + cdr_param.ssn_param[index].name, + cdr_vm_ptr->plane_id, + cdr_time[0]+2000, + cdr_time[1], + cdr_time[2], + cdr_time[3], + cdr_param.ssn_param[index].file_sn++, + cdr_param.file_suffix); + } + } + + strcpy(cdr_param.ssn_param[index].file_name,file_name); + + if(cdr_param.ssn_param[index].fd != NULL) + fclose(cdr_param.ssn_param[index].fd); + + cdr_param.ssn_param[index].fd = fopen(file_name,"a+b"); + cdr_param.ssn_param[index].total_records = 0; + + return 1; +} + +int cdr_open_all_new_fd() +{ + int index; + + for(index=0;index=MAX_CDR_APP_NUM) continue; + + if(!strncasecmp(s,"ssn=",4)) + { + cdr_param.ssn_param[index].ssn = atoi(&s[4]); + continue; + } + if(!strncasecmp(s,"name=",5)) + { + strcpy(cdr_param.ssn_param[index].name,&s[5]); + } + } + fclose(fp); + + for(index=0;indexd_name); + stat(name,&fileinfo); + + if(time(NULL)>=(fileinfo.st_mtime+cdr_param.max_days*3600*24) ) + { + remove(name); + } + } + closedir(dp); + + return 1; +} + +/* -------- END of initialisation functions *----*/ + +/* ------- CDR submit & write file--------------*/ + +int cdr_submit1(char ssn, unsigned short length, char *data) +{ + int head, tail; + _cdr_record *ptr=NULL; + + head = cdr_vm_ptr->head_ptr; + tail = cdr_vm_ptr->tail_ptr; + + ptr = &cdr_vm_ptr->cdr_data[head]; + ptr->ssn = ssn; + ptr->length = length%CDR_RECORD_SIZE; + memcpy(ptr->data, data , ptr->length); + + // sem_lock(cdr_sem_id, 1, 1, IPC_NOWAIT); + cdr_vm_ptr->head_ptr ++; + if(cdr_vm_ptr->head_ptr>=MAX_CDR_RECORDS) + cdr_vm_ptr->head_ptr = 0; +/* + if(cdr_vm_ptr->head_ptr == tail) + { + cdr_vm_ptr->tail_ptr ++; + if(cdr_vm_ptr->tail_ptr>=MAX_CDR_RECORDS) + cdr_vm_ptr->tail_ptr = 0; + } +*/ + // sem_unlock(cdr_sem_id, 1, 1, IPC_NOWAIT); + + cdr_counter0++; + ssn_counter[ssn]++; + return 1; +} + +int cdr_submit(char ssn, unsigned short length, char *data) +{ + int head, tail; + _cdr_record *ptr=NULL; + + head = cdr_vm_ptr->head_ptr; + tail = cdr_vm_ptr->tail_ptr; + + ptr = &cdr_vm_ptr->cdr_data[head]; + ptr->ssn = ssn; + ptr->length = length%CDR_RECORD_SIZE; + memcpy(ptr->data, data , ptr->length); + + // sem_lock(cdr_sem_id, 1, 1, IPC_NOWAIT); + cdr_vm_ptr->head_ptr ++; + if(cdr_vm_ptr->head_ptr>=MAX_CDR_RECORDS) + cdr_vm_ptr->head_ptr = 0; +/* + if(cdr_vm_ptr->head_ptr == tail) + { + cdr_vm_ptr->tail_ptr ++; + if(cdr_vm_ptr->tail_ptr>=MAX_CDR_RECORDS) + cdr_vm_ptr->tail_ptr = 0; + } +*/ + // sem_unlock(cdr_sem_id, 1, 1, IPC_NOWAIT); + + cdr_counter1++; + ssn_counter[ssn]++; + return 1; +} + +int cdr_get_ssn_index(int ssn) +{ + int i; + + for(i=0;issn))<0) + return 0; + + if(cdr_param.ssn_param[index].fd == NULL) + return 0; + + BcdToAscii(data,ptr->data,(ptr->length%CDR_RECORD_SIZE)*2); + + fprintf(cdr_param.ssn_param[index].fd,"%s\n",data); + cdr_param.ssn_param[index].total_records++; + + if(cdr_param.max_records_per_file>0) + { + if(cdr_param.ssn_param[index].total_records>=cdr_param.max_records_per_file) + cdr_open_ssn_file(index); + } + + return 1; +} + +int cdr_backup() +{ + int head, tail; + _cdr_record *ptr=NULL; + register int loop; + + head = cdr_vm_ptr->head_ptr; + + for(loop=0;looptail_ptr; + if(head == tail) + break; + + ptr = &cdr_vm_ptr->cdr_data[tail]; + //memcpy(ptr, &cdr_vm_ptr->cdr_data, sizeof(_cdr_record)); + + cdr_back_record(ptr); + + // sem_lock(cdr_sem_id, 1, 1, IPC_NOWAIT); + cdr_vm_ptr->tail_ptr ++; + if(cdr_vm_ptr->tail_ptr>=MAX_CDR_RECORDS) + cdr_vm_ptr->tail_ptr = 0; + // sem_unlock(cdr_sem_id, 1, 1, IPC_NOWAIT); + + // if(cdr_vm_ptr->tail_ptr == head) + // { + // break; + // } + } + return 1; +} diff --git a/omc/plat/public/src/crypt.c b/omc/plat/public/src/crypt.c new file mode 100644 index 0000000..1ead301 --- /dev/null +++ b/omc/plat/public/src/crypt.c @@ -0,0 +1,493 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD February, 2001 +** +** file name: crypt.c +** CVS $Id: crypt.c,v 1.1 2001/06/28 07:21:15 zhangsz Exp $ +** +** Crypt functions +** +*/ + +#include +#include +#include +#include + +/*@ignore@*/ + +#define DES_KEY "N2r3T5B0" + +static unsigned char T1[] = +{ + 57,49,41,33,25,17, 9, 1, + 59,51,43,35,27,19,11, 3, + 61,53,45,37,29,21,13, 5, + 63,55,47,39,31,23,15, 7, + 56,48,40,32,24,16, 8, 0, + 58,50,42,34,26,18,10, 2, + 60,52,44,36,28,20,12, 4, + 62,54,46,38,30,22,14, 6 +}; + +static unsigned char T2[] = +{ + 39, 7,47,15,55,23,63,31, + 38, 6,46,14,54,22,62,30, + 37, 5,45,13,53,21,61,29, + 36, 4,44,12,52,20,60,28, + 35, 3,43,11,51,19,59,27, + 34, 2,42,10,50,18,58,26, + 33, 1,41, 9,49,17,57,25, + 32, 0,40, 8,48,16,56,24 +}; + +static unsigned char T3[] = +{ + 31, 0, 1, 2, 3, 4, + 3, 4, 5, 6, 7, 8, + 7, 8, 9,10,11,12, + 11,12,13,14,15,16, + 15,16,17,18,19,20, + 19,20,21,22,23,24, + 23,24,25,26,27,28, + 27,28,29,30,31, 0 +}; + +static unsigned char T5[] = +{ + 15, 6,19,20, + 28,11,27,16, + 0,14,22,25, + 4,17,30, 9, + 1, 7,23,13, + 31,26, 2, 8, + 18,12,29, 5, + 21,10, 3,24 +}; + +static unsigned char T7_1_2[] = +{ + 56,48,40,32,24,16, 8, + 0,57,49,41,33,25,17, + 9, 1,58,50,42,34,26, + 18,10, 2,59,51,43,35, + 62,54,46,38,30,22,14, + 6,61,53,45,37,29,21, + 13, 5,60,52,44,36,28, + 20,12, 4,27,19,11, 3 +}; + +static unsigned char T8[] = +{ + 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 +}; + +static unsigned char T9[] = +{ + 13,16,10,23, 0, 4, + 2,27,14, 5,20, 9, + 22,18,11, 3,25, 7, + 15, 6,26,19,12, 1, + 40,51,30,36,46,54, + 29,39,50,44,32,47, + 43,48,38,55,33,52, + 45,41,49,35,28,31 +}; + +static unsigned char T6[][64] = +{ + {/* S1 */ + 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7, + 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8, + 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0, + 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13 + }, + {/* S2 */ + 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10, + 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5, + 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15, + 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9 + }, + {/* S3 */ + 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1, + 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7, + 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12 + }, + {/* S4 */ + 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15, + 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9, + 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4, + 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14 + }, + {/* S5 */ + 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9, + 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6, + 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14, + 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3 + }, + {/* S6 */ + 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11, + 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8, + 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6, + 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13 + }, + {/* S7 */ + 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1, + 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6, + 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2, + 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12 + }, + {/* S8 */ + 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7, + 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2, + 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8, + 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11 + } +}; + +unsigned char TE[][4] = +{ + {0,0,0,0}, + {0,0,0,1}, + {0,0,1,0}, + {0,0,1,1}, + {0,1,0,0}, + {0,1,0,1}, + {0,1,1,0}, + {0,1,1,1}, + {1,0,0,0}, + {1,0,0,1}, + {1,0,1,0}, + {1,0,1,1}, + {1,1,0,0}, + {1,1,0,1}, + {1,1,1,0}, + {1,1,1,1} +}; + +void Ks (unsigned char *Key, unsigned char Kn[16][48]) +{ + unsigned char cd[56]; + unsigned char zt[60]; + int n, i; + unsigned char tmp11, tmp12, tmp21, tmp22; + unsigned char *Knn; + + /* choix 1 */ + for (i = 0; i < 56; i++) + { + cd[i] = Key[T7_1_2[i]]; + } + + for (n = 0; n < 16; n++) + { + if (T8[n] == 0) + { + tmp11 = cd[0]; + tmp21 = cd[28]; + memcpy( zt , &cd[1] , 55 ); + memcpy( cd , zt , 55 ); + cd[27] = tmp11; + cd[55] = tmp21; + } + else + { + tmp11 = cd[0]; + tmp12 = cd[1]; + tmp21= cd[28]; + tmp22 = cd[29]; + + memcpy( zt , &cd[2] , 54 ); + memcpy( cd , zt , 54 ); + + cd[26] = tmp11; + cd[27] = tmp12; + cd[54] = tmp21; + cd[55] = tmp22; + } + Knn = Kn[n]; + for (i = 0; i < 48; i++) + { + Knn[i] = cd[T9[i]]; + } + } +} + +void fonction(unsigned char *Knn, unsigned char *r, unsigned char *s) +{ + + unsigned char x[32]; + unsigned int *px; + int i, l; + unsigned char c; + unsigned char t; + + for (i = 0, l = 0, px = (unsigned int *) x; i < 8;) + { + c = 32 * (r[T3[l]] ^ Knn[l]); + l++; + c += 8 * (r[T3[l]] ^ Knn[l]); + l++; + c += 4 * (r[T3[l]] ^ Knn[l]); + l++; + c += 2 * (r[T3[l]] ^ Knn[l]); + l++; + c += 1 * (r[T3[l]] ^ Knn[l]); + l++; + c += 16 * (r[T3[l]] ^ Knn[l]); + l++; + t = T6[i][c]; + i++; + *px = *(int *)TE[t]; + px++; + } + for (i = 0; i < 32; i++) + { + s[i] = x[T5[i]]; + } +} + +void permutation(unsigned char *org, unsigned char *tab) +{ + unsigned char tmp[64]; + int i; + + + memcpy(tmp, org, 64); + for (i = 0; i < 64; i++) + { + org[i] = tmp[tab[i]]; + } +} + +void chiffrement(unsigned char *xi, unsigned char *xo, unsigned char Kn[16][48]) +{ + unsigned char r[32], l[32]; + unsigned char rp[32], lp[32]; + + int i; + int n; + + memcpy(l, &xi[0], 32); + memcpy(r, &xi[32], 32); + + for (n = 0; n < 16; n++) + { + memcpy(lp, r, 32); + + fonction(Kn[n], r, rp); + for (i = 0; i < 32; i++) + { + r[i] =( ( l[i]) ^ (rp[i] ) ) ; + } + memcpy(l, lp, 32); + } + memcpy(&xo[0], r, 32); + memcpy(&xo[32], l, 32); + +} + +void dechiffrement(unsigned char *xi, unsigned char *xo, unsigned char Kn[16][48]) +{ + unsigned char r[32], l[32], rp[32], lp[32]; + + int i; + int n; + + memcpy(l, &xi[0], 32); + memcpy(r, &xi[32], 32); + + for (n = 0; n < 16; n++) + { + memcpy(lp, r, 32); + fonction(Kn[15 - n], r, rp); + for (i = 0; i < 32; i++) + { + r[i] =( ( l[i] ) ^ ( rp[i] )) ; + } + memcpy(l, lp, 32); + } + + memcpy(&xo[0], r, 32); + memcpy(&xo[32], l, 32); +} + +void eclater(const unsigned char *buf_bit, unsigned char *byte) +{ + int i; + unsigned char m; + + for (i = 0; i < 8; i++) + { + for (m = 0x80; m != 0; ) + { + if ((buf_bit[i] & m) != 0) + *byte = 1; + else + *byte = 0; + byte++; + m=m/2 ; + } + } +} + +void compacter(unsigned char *byte, unsigned char *buf_bit) +{ + int i; + unsigned char m, n; + + for (i = 0; i < 8; i++) + { + n = 0; + for (m = 0x80; m != 0; ) + { + if (*byte++) + n = n | m; + m=m/2 ; + + } + buf_bit[i] = n; + } +} + +// direction 0/1=Encryption/Decryption +// binput,boutput,bkey = 8bytes +// direction: 0/1=Encryt/Decrypt +void des(unsigned char *boutput, const unsigned char *binput, const unsigned char *bkey, int direction) +{ + unsigned char input[64]; /* data input */ + unsigned char output[64]; /* data output */ + unsigned char Key[64]; + unsigned char Kn[16][48]; + + eclater(binput, input); + eclater(bkey, Key); + Ks(Key, Kn); + permutation(input, T1); + + if (direction) dechiffrement(input, output, Kn); + else chiffrement(input, output, Kn); + + permutation(output, T2); + compacter(output, boutput); +} + +void atob (unsigned char *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + + for (i=0; i='a') ch -= 'a' - 10; + else if (ch>='A') ch -= 'A' - 10; + else ch -= '0'; + if (i & 1) *(bcd_buf++) |= ch & 0x0f; + else *bcd_buf = ch << 4; + } +} + +void btoa (char *ascii_buf, const unsigned char *bcd_buf, int len) +{ + int i; + char ch; + + for (i=0; i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} + +void EncryptPIN (unsigned char cipher[], const char plain[], const char pan[], const unsigned char pin_key[]) +{ + char pin[20]; + unsigned char buf1[8], buf2[8]; + int i; + + i = strlen(plain); + buf1[0] = i; + strcpy(pin, plain); + for (; i<14; ++i) pin[i] = 'F'; + atob(buf1+1, pin, 14); + buf2[0] = buf2[1] = 0x00; + atob(buf2+2, pan+strlen(pan)-13, 12); + for (i=0; i<8; ++i) buf1[i] ^= buf2[i]; + des(cipher, buf1, pin_key, 0); +} + +/* length of pan more than 13, and length of pin key more than 8 */ +void DecryptPIN (char plain[], const unsigned char cipher[], const char pan[], const unsigned char pin_key[]) +{ + unsigned char buf1[8], buf2[8]; + int i; + + des(buf1, cipher, pin_key, 1); + buf2[0] = buf2[1] = 0x00; + atob(buf2+2, pan+strlen(pan)-13, 12); + for (i=0; i<8; i++) buf1[i] ^= buf2[i]; + i = buf1[0]; + if (i <= 14) btoa(plain, buf1+1, i); + else plain[0] = '\0'; +} + +void CalcMAC (char mac[], const char data[], const unsigned char mac_key[]) +{ + int i; + unsigned char m[8]; + + memset(m, 0, 8); + for (i=0; data[i];) + { + m[i&7] ^= data[i]; + ++i; + if (!((i&7) && data[i])) des(m, m, mac_key, 0); + } + btoa(mac, m, 8); +} + +void CalcMAC1 (unsigned char mac[], const unsigned char data[], int len, const unsigned char mac_key[]) +{ + int i; + + memset(mac, 0, 8); + for (i=0; i +#include + +typedef struct ASN_TLV +{ + u_char tagtype; + u_short tagcode; + int length; + u_char *pvalue; + struct ASN_TLV *pnext; + struct ASN_TLV *psub; +}ASN_TLV; + +typedef struct _ASN_BUFFER +{ + u_char *msgbuf; //store pointer of buffer + int maxlen; + int msglen; //totallength of message + int pos; + + ASN_TLV heap[256]; + char errmsg[1024]; + short tlvcount; +}ASN_BUF; + +//interface======> +void AsnEncode(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf); +int AsnDecode(u_char *msg_buf,int msglen,int maxtlv,int *errpos,ASN_BUF *asnbuf); +int GetTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char flag,ASN_BUF *asnbuf); +int GetAnyTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char *pflag,u_short *ptagcode,ASN_BUF *asnbuf); +int AddTLV(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf); +int GetInteger(const char *tag_seq,int *rtn,u_char flag,ASN_BUF *asnbuf); +int AddInteger(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf); + +void asn_encode(u_char *asn_buf,ASN_BUF *asnbuf); +void asn_encode_v3(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf); +int add_tlv(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf); +int asn_decode(u_char *asn_buf,int ntlv,ASN_BUF *asnbuf); +int asn_decode_v2(u_char *msg_buf,int ntlv,int *plen,ASN_BUF *asnbuf); +int asn_decode_v3(u_char *msg_buf,int msglen,int *errpos,ASN_BUF *asnbuf); +int get_tlv(const char *tag_seq,u_char *pvalue,ASN_BUF *asnbuf); +int get_tlv_v2(const char *tag_seq,u_char *pvalue,u_char *flag,ASN_BUF *asnbuf); +int parse_tlv(ASN_TLV **pnode,ASN_BUF *asnbuf); +//int parse_tlv2(u_char *asn_buf,int rest,u_short (*tags)[2],int order,ASN_BUF *asnbuf); +int findtlv(u_char *pasn,u_int tagcode,u_char **pnext,int rest); +int findtlv2(u_char *pasn,int index,u_char **pnext,int rest); +int gettagcode(u_char *asnbuf,u_int *tagcode,u_char *type); +int getlength(u_char *asnbuf,int *len); +int addtagcode(u_char *asn_buf,u_int tagcode,u_char type); +int addlength(u_char *asn_buf,u_int len); +int parse_tags(const char *tag_seq,u_short (*tags)[2]); +int modifylength(u_char *ptr[],int level,int addval); +void showbuf(u_char *buf,int len); + +int add_bool(const char *tag_seq,u_char value,u_char tlv_type,ASN_BUF *asnbuf); +u_char get_bool(const char *tag_seq,ASN_BUF *asnbuf); +int add_int(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf); +int get_int(const char *tag_seq,ASN_BUF *asnbuf); +int get_int_v2(const char *tag_seq,int *rtn,ASN_BUF *asnbuf); +int add_oid(const char *tag_seq,const char *oidstr,u_char tlv_type,ASN_BUF *asnbuf); +int get_oid(const char *tag_seq,char *oid,ASN_BUF *asnbuf); +int add_null(const char *tag_seq,u_char tlv_type,ASN_BUF *asnbuf); +int get_null(const char *tag_seq,ASN_BUF *asnbuf); +int DecodeInteger(u_char *buf, u_char len); +#endif diff --git a/omc/plat/public/src/include/bisearch.h b/omc/plat/public/src/include/bisearch.h new file mode 100644 index 0000000..7d16629 --- /dev/null +++ b/omc/plat/public/src/include/bisearch.h @@ -0,0 +1,123 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic Structure */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ + +#ifndef _BISEARCH_H_ +#define _BISEARCH_H_ + +#define LL long long +#define u8 unsigned char + +typedef struct BiSearch +{ + LL llKey; //BiSearch Array Node Key + int nDUPosIndex; //Data Unit array Position Index +} +BiSearch; + +#define BS_SIZE sizeof(BiSearch) + +typedef struct BiSearchArray +{ + int nArrayCount; + int nArrayTotalLen; + BiSearch *pBiArray; //SearchArray pointer + int (*GetIdleNodeFunc)(int* nDUIndex); +} +BiSearchArray; + +/*********************************************************************/ +/*BiSearchReg : Init BiSearch Struct, Alloc BiSearch Memery */ +/*Return : [0]:BiSearchReg fail [1] :BiSearchReg Success */ +/*********************************************************************/ +extern int BISearchReg ( BiSearchArray * pBSA, int nTotalSize ,void *GetIdleNodeFunc ); + + +/*********************************************************************/ +/*BiSearchUnReg : Release BiSearch Memery */ +/*Return : [0]:BiSearchUnReg fail [1] :BiSearchUnReg Success */ +/*********************************************************************/ +int BISearchUnReg ( BiSearchArray * pBSA); + + +/*********************************************************************/ +/*BSearch : BiSearch from nStart to nEnd with the llKey */ +/* Search Result save in the val "nPosResult" */ +/*Return : [0]:BSearch fail [1] :BSearch Success */ +/*********************************************************************/ +int BSearch ( BiSearchArray * pBSA, int nStart, int nEnd, LL llKey, int *nPosResult ); + + +/*********************************************************************/ +/*BSearchArray : BiSearch from 0 to ArrayEndIndex with the llKey */ +/* Search nPos Result save in the val "nPosResult" */ +/*Return : [0]:BSearchArray fail [1] :BSearchArray Success */ +/*********************************************************************/ +int BSearchArray ( BiSearchArray * pBSA, LL llKey, int *nPosResult ); + + +/*********************************************************************/ +/*BISInsert : Insert a BiSearch Array Element with the llKey */ +/* return Data Unit Array Index Get by GetIdleNodeFunc*/ +/*Return : [0]:BISInsert fail [1]:BISInsert Success */ +/*********************************************************************/ +int BISInsert ( BiSearchArray * pBSA, LL llKey, int nDUPosIndex ); + +/*********************************************************************/ +/*BISDelete : Delete a BiSearch Array Element with the llKey */ +/*Return : [0]:BISDelete fail [1]:BISDelete Success */ +/*********************************************************************/ +int BISDelete ( BiSearchArray * pBSA, LL llKey ); + + +/*********************************************************************/ +/*BISSearch : BiSearch from 0 to ArrayEndIndex with the llKey */ +/* Search DUIndex Result save in the val "nDUPosIndex"*/ +/*Return : [0]:BISSearch fail [1]:BISSearch Success */ +/*********************************************************************/ +int BISSearch ( BiSearchArray * pBSA, LL llKey , int* nDUPosIndex); + +/*********************************************************************/ +/*GetBISearchCount : Get The BiSearch struct counter */ +/*Return : return The BiSearch struct counter */ +/*********************************************************************/ +int GetBISearchCount ( BiSearchArray * pBSA); + +/*********************************************************************/ +/*GetDUIndex : Get The Data Unit Index by bisearch struct index */ +/*Return : return the BiSearch struct dataunit index */ +/*********************************************************************/ +int GetDUIndex ( BiSearchArray * pBSA, int nBIIndex); + +//BiSearch ManageMent Operation +typedef enum _BIS_OP +{ + BIS_INIT = 0, + BIS_SEARCH, + BIS_INSERT, + BIS_DELETE, +}BIS_OP; + +/*********************************************************************/ +/*BISSearchMng : BiSearch Management Opertion fuction */ +/* Init : use BIS_OP [BIS_INIT] Insert the elment */ +/* with the key_str and nDUIndex */ +/* Search : use BIS_OP [BIS_SEARCH] search the elemnt */ +/* with the key_str ,return nDUIndex */ +/* Insert : se BIS_OP [BIS_Insert] Insert a BiSearch */ +/* Array Element with the llKey ,return Data */ +/* Unit Array Index Get by GetIdleNodeFunc() */ +/* by GetIdleNodeFunc() */ +/* Delete : use BIS_OP [BIS_DELETE] Delete the elment */ +/* with the key_str */ +/*Return : [0] fail [1] success */ +/*********************************************************************/ +int BISSearchMng( BiSearchArray * pBSA, BIS_OP mng_type,LL llkey, int* nDUIndex ); + +#endif diff --git a/omc/plat/public/src/include/cJSON.h b/omc/plat/public/src/include/cJSON.h new file mode 100644 index 0000000..6e0bde9 --- /dev/null +++ b/omc/plat/public/src/include/cJSON.h @@ -0,0 +1,277 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef cJSON__h +#define cJSON__h + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* project version */ +#define CJSON_VERSION_MAJOR 1 +#define CJSON_VERSION_MINOR 7 +#define CJSON_VERSION_PATCH 7 + +#include + +/* cJSON Types: */ +#define cJSON_Invalid (0) +#define cJSON_False (1 << 0) +#define cJSON_True (1 << 1) +#define cJSON_NULL (1 << 2) +#define cJSON_Number (1 << 3) +#define cJSON_String (1 << 4) +#define cJSON_Array (1 << 5) +#define cJSON_Object (1 << 6) +#define cJSON_Raw (1 << 7) /* raw json */ + +#define cJSON_IsReference 256 +#define cJSON_StringIsConst 512 + +/* The cJSON structure: */ +typedef struct cJSON +{ + /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ + struct cJSON *next; + struct cJSON *prev; + /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ + struct cJSON *child; + + /* The type of the item, as above. */ + int type; + + /* The item's string, if type==cJSON_String and type == cJSON_Raw */ + char *valuestring; + /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ + int valueint; + /* The item's number, if type==cJSON_Number */ + double valuedouble; + + /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ + char *string; +} cJSON; + +typedef struct cJSON_Hooks +{ + void *(*malloc_fn)(size_t sz); + void (*free_fn)(void *ptr); +} cJSON_Hooks; + +typedef int cJSON_bool; + +#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) +#define __WINDOWS__ +#endif +#ifdef __WINDOWS__ + +/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options: + +CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols +CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) +CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol + +For *nix builds that support visibility attribute, you can define similar behavior by + +setting default visibility to hidden by adding +-fvisibility=hidden (for gcc) +or +-xldscope=hidden (for sun cc) +to CFLAGS + +then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does + +*/ + +/* export symbols by default, this is necessary for copy pasting the C and header file */ +#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_EXPORT_SYMBOLS +#endif + +#if defined(CJSON_HIDE_SYMBOLS) +#define CJSON_PUBLIC(type) type __stdcall +#elif defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall +#elif defined(CJSON_IMPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall +#endif +#else /* !WIN32 */ +#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) +#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type +#else +#define CJSON_PUBLIC(type) type +#endif +#endif + +/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. + * This is to prevent stack overflows. */ +#ifndef CJSON_NESTING_LIMIT +#define CJSON_NESTING_LIMIT 1000 +#endif + +/* returns the version of cJSON as a string */ +CJSON_PUBLIC(const char*) cJSON_Version(void); + +/* Supply malloc, realloc and free functions to cJSON */ +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); + +/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */ +/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); +/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ +/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); + +/* Render a cJSON entity to text for transfer/storage. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); +/* Render a cJSON entity to text for transfer/storage without any formatting. */ +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); +/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); +/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */ +/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); +/* Delete a cJSON entity and all subentities. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *c); + +/* Returns the number of items in an array (or object). */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); +/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */ +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); +/* Get item "string" from object. Case insensitive. */ +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); + +/* Check if the item is a string and return its valuestring */ +CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item); + +/* These functions check the type of an item */ +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); + +/* These calls create a cJSON item of the appropriate type. */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); +/* raw json */ +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); + +/* Create a string where valuestring references a string so + * it will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); +/* Create an object/arrray that only references it's elements so + * they will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); + +/* These utilities create an Array of count items. */ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count); + +/* Append item to the specified array/object. */ +CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. + * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before + * writing to `item->string` */ +CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); +/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ +CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); + +/* Remove/Detatch items from Arrays/Objects. */ +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); + +/* Update array items. */ +CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); +CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); +CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); +CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); + +/* Duplicate a cJSON item */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); +/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will +need to be released. With recurse!=0, it will duplicate any children connected to the item. +The item->next and ->prev pointers are always zero on return from Duplicate. */ +/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. + * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); + + +CJSON_PUBLIC(void) cJSON_Minify(char *json); + +/* Helper functions for creating and adding items to an object at the same time. + * They return the added item or NULL on failure. */ +CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); +CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); +CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); +CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); +CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); + +/* When assigning an integer value, it needs to be propagated to valuedouble too. */ +#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) +/* helper for the cJSON_SetNumberValue macro */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); +#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) + +/* Macro for iterating over an array or object */ +#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) + +/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */ +CJSON_PUBLIC(void *) cJSON_malloc(size_t size); +CJSON_PUBLIC(void) cJSON_free(void *object); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/omc/plat/public/src/include/cdr.h b/omc/plat/public/src/include/cdr.h new file mode 100644 index 0000000..418d5f9 --- /dev/null +++ b/omc/plat/public/src/include/cdr.h @@ -0,0 +1,60 @@ +#ifndef _CDR_H +#define _CDR_H + +#include +#include + +#define CDR_SHM_KEY 0x60000006 +#define CDR_SHM_PERM 0777 +#define CDR_SEM_KEY 0x60000007 +#define CDR_SEM_PERM 0777 + +#define MAX_CDR_RECORDS 8192 +#define CDR_RECORD_SIZE 256 + +#define MAX_CDR_PER_CYCLE 256 +#define MAX_CDR_APP_NUM 4 + +typedef struct cdr_record +{ + char ssn; + unsigned short length; + char data[CDR_RECORD_SIZE]; +}_cdr_record; + +typedef struct cdr_vm_struct +{ + char plane_id; /* 0/1=mss0,mss1*/ + unsigned short head_ptr; + unsigned short tail_ptr; + _cdr_record cdr_data[MAX_CDR_RECORDS]; +}_cdr_vm_struct; + +typedef struct cdr_ssn_param +{ + char ssn; + char name[32]; + char file_name[128]; + int total_records; + int file_sn; + FILE *fd; +}_cdr_ssn_param; + +typedef struct cdr_param +{ + char system_id; + char base_dir[128]; + char file_suffix[32]; + int max_records_per_file; + char max_days; + char init_flag; + char now_time[8]; + _cdr_ssn_param ssn_param[MAX_CDR_APP_NUM]; +}_cdr_param; + +int cdr_init(char plane_id, char memset_flag); +int cdr_timer(); + +int cdr_bakcup(); + +#endif diff --git a/omc/plat/public/src/include/crypt.h b/omc/plat/public/src/include/crypt.h new file mode 100644 index 0000000..521f87f --- /dev/null +++ b/omc/plat/public/src/include/crypt.h @@ -0,0 +1,28 @@ +/* + * crypt.h ---- Key management and data encryption/decryption. + */ + +#ifndef CRYPT__H +#define CRYPT__H + +void des(unsigned char *output, const unsigned char *input, const unsigned char *key, int direction); +void atob (unsigned char *bcd_buf, const char *ascii_buf, int len); +void btoa (char *ascii_buf, const unsigned char *bcd_buf, int len); +void EncryptPIN (unsigned char cipher[], const char plain[], const char pan[], const unsigned char pin_key[]); +void DecryptPIN (char plain[], const unsigned char cipher[], const char pan[], const unsigned char pin_key[]); +void CalcMAC (char mac[], const char data[], const unsigned char mac_key[]); +void CalcMAC1 (unsigned char mac[], const unsigned char data[], int len, const unsigned char mac_key[]); +void EncryptKey (char cipher[], const unsigned char plain[]); +void DecryptKey (unsigned char plain[], const char cipher[]); + +typedef enum _des_crypt_mode{ + _DES_ENCRYPT_ = 0, + _DES_DECRYPT_ +}_DesMode; + +void DesCrypt( +unsigned char *Output /*8 bytes*/, +unsigned char *Input /*8 bytes*/, +unsigned char *DesKey/*default=NULL.While using for user licenses control,can keep the default value*/, +unsigned char DesMode/*encrpt or decrypt,refer to enum _DesMode*/); +#endif diff --git a/omc/plat/public/src/include/includes.h b/omc/plat/public/src/include/includes.h new file mode 100644 index 0000000..56d2720 --- /dev/null +++ b/omc/plat/public/src/include/includes.h @@ -0,0 +1,47 @@ +/* public include head file */ +/* written by Liu Zhiguo 2002-03-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _PUBLIC_INCLUDES_H_ +#define _PUBLIC_INCLUDES_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif diff --git a/omc/plat/public/src/include/keyValuePair.h b/omc/plat/public/src/include/keyValuePair.h new file mode 100644 index 0000000..90f92e7 --- /dev/null +++ b/omc/plat/public/src/include/keyValuePair.h @@ -0,0 +1,15 @@ +#ifndef _keyValuePair_H_ +#define _keyValuePair_H_ + +#include + +typedef struct keyValuePair_t { + char* key; + void* value; +} keyValuePair_t; + +keyValuePair_t *keyValuePair_create(char *key, void *value); + +void keyValuePair_free(keyValuePair_t *keyValuePair); + +#endif /* _keyValuePair_H_ */ \ No newline at end of file diff --git a/omc/plat/public/src/include/license_id.h b/omc/plat/public/src/include/license_id.h new file mode 100644 index 0000000..b332de5 --- /dev/null +++ b/omc/plat/public/src/include/license_id.h @@ -0,0 +1,37 @@ +#ifndef _LICENCE_ID__H +#define _LICENCE_ID__H + +typedef enum _WXC2_LICENSE_ID +{ + LIC_MSC_TRUNK=0, + LIC_HLR_USERS, + LIC_VLR_USERS, + LIC_AUC_USERS, + LIC_EIR_USERS, + LIC_PPS_USERS, + LIC_SMSC_USERS, + LIC_MNP_USERS, + LIC_SMEG_USERS, + LIC_OPPS_USERS, + LIC_PALIM_USERS, + + LIC_GPRS=16, + LIC_USSD, + LIC_ISUP, + LIC_BICC, + LIC_AIF, + LIC_MGC, + LIC_CAP, + LIC_OPPS_OPR, + LIC_OPPS_IMDM, + LIC_ISDN, + LIC_SIP, + LIC_RLS, + LIC_MAX_ID, +}WXC2_LICENSE_ID; + +/* functionID: listed above, + if functionID doesn't exist, return -1, else return license value +*/ +int wxc2_get_license(int functionID); +#endif diff --git a/omc/plat/public/src/include/list.h b/omc/plat/public/src/include/list.h new file mode 100644 index 0000000..8540178 --- /dev/null +++ b/omc/plat/public/src/include/list.h @@ -0,0 +1,38 @@ +#ifndef INCLUDE_LIST_H +#define INCLUDE_LIST_H + +#include "cJSON.h" + +typedef struct list_t list_t; + +typedef struct listEntry_t listEntry_t; + +struct listEntry_t { + listEntry_t* nextListEntry; + listEntry_t* prevListEntry; + void* data; +}; + +typedef struct list_t { + listEntry_t *firstEntry; + listEntry_t *lastEntry; + + long count; +} list_t; + +#define list_ForEach(element, list) for(element = (list != NULL) ? (list)->firstEntry : NULL; element != NULL; element = element->nextListEntry) + +list_t* list_create(); +void list_free(list_t* listToFree); + +void list_addElement(list_t* list, void* dataToAddInList); +listEntry_t* list_getElementAt(list_t *list, long indexOfElement); +listEntry_t* list_getWithIndex(list_t* list, int index); +void list_removeElement(list_t* list, listEntry_t* elementToRemove); + +void list_iterateThroughListForward(list_t* list, void (*operationToPerform)(listEntry_t*, void*), void *additionalDataNeededForCallbackFunction); +void list_iterateThroughListBackward(list_t* list, void (*operationToPerform)(listEntry_t*, void*), void *additionalDataNeededForCallbackFunction); + +void listEntry_printAsInt(listEntry_t* listEntry, void *additionalData); +void listEntry_free(listEntry_t *listEntry, void *additionalData); +#endif // INCLUDE_LIST_H diff --git a/omc/plat/public/src/include/memwatch.h b/omc/plat/public/src/include/memwatch.h new file mode 100644 index 0000000..d63fd76 --- /dev/null +++ b/omc/plat/public/src/include/memwatch.h @@ -0,0 +1,707 @@ +/* +** MEMWATCH.H +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2002 Johan Lindh +** All rights reserved. +** Version 2.71 +** +************************************************************************ +** +** PURPOSE: +** +** MEMWATCH has been written to allow guys and gals that like to +** program in C a public-domain memory error control product. +** I hope you'll find it's as advanced as most commercial packages. +** The idea is that you use it during the development phase and +** then remove the MEMWATCH define to produce your final product. +** MEMWATCH is distributed in source code form in order to allow +** you to compile it for your platform with your own compiler. +** It's aim is to be 100% ANSI C, but some compilers are more stingy +** than others. If it doesn't compile without warnings, please mail +** me the configuration of operating system and compiler you are using +** along with a description of how to modify the source, and the version +** number of MEMWATCH that you are using. +** +************************************************************************ + + This file is part of MEMWATCH. + + MEMWATCH 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 of the License, or + (at your option) any later version. + + MEMWATCH 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 MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +************************************************************************ +** +** REVISION HISTORY: +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +** +** To use, simply include 'MEMWATCH.H' as a header file, +** and add MEMWATCH.C to your list of files, and define the macro +** 'MEMWATCH'. If this is not defined, MEMWATCH will disable itself. +** +** To call the standard C malloc / realloc / calloc / free; use mwMalloc_(), +** mwCalloc_() and mwFree_(). Note that mwFree_() will correctly +** free both malloc()'d memory as well as mwMalloc()'d. +** +** 980317: C++ support has been disabled. +** The code remains, but is not compiled. +** +** For use with C++, which allows use of inlining in header files +** and class specific new/delete, you must also define 'new' as +** 'mwNew' and 'delete' as 'mwDelete'. Do this *after* you include +** C++ header files from libraries, otherwise you can mess up their +** class definitions. If you don't define these, the C++ allocations +** will not have source file and line number information. Also note, +** most C++ class libraries implement their own C++ memory management, +** and don't allow anyone to override them. MFC belongs to this crew. +** In these cases, the only thing to do is to use MEMWATCH_NOCPP. +** +** You can capture output from MEMWATCH using mwSetOutFunc(). +** Just give it the adress of a "void myOutFunc(int c)" function, +** and all characters to be output will be redirected there. +** +** A failing ASSERT() or VERIFY() will normally always abort your +** program. This can be changed using mwSetAriFunc(). Give it a +** pointer to a "int myAriFunc(const char *)" function. Your function +** must ask the user whether to Abort, Retry or Ignore the trap. +** Return 2 to Abort, 1 to Retry or 0 to Ignore. Beware retry; it +** causes the expression to be evaluated again! MEMWATCH has a +** default ARI handler. It's disabled by default, but you can enable +** it by calling 'mwDefaultAri()'. Note that this will STILL abort +** your program unless you define MEMWATCH_STDIO to allow MEMWATCH +** to use the standard C I/O streams. Also, setting the ARI function +** will cause MEMWATCH *NOT* to write the ARI error to stderr. The +** error string is passed to the ARI function instead, as the +** 'const char *' parameter. +** +** You can disable MEMWATCH's ASSERT/VERIFY and/or TRACE implementations. +** This can be useful if you're using a debug terminal or smart debugger. +** Disable them by defining MW_NOASSERT, MW_NOVERIFY or MW_NOTRACE. +** +** MEMWATCH fills all allocated memory with the byte 0xFE, so if +** you're looking at erroneous data which are all 0xFE:s, the +** data probably was not initialized by you. The exception is +** calloc(), which will fill with zero's. All freed buffers are +** zapped with 0xFD. If this is what you look at, you're using +** data that has been freed. If this is the case, be aware that +** MEMWATCH places a 'free'd block info' structure immediately +** before the freed data. This block contains info about where +** the block was freed. The information is in readable text, +** in the format "FBIfilename(line)", for example: +** "FBI<267>test.c(12)". Using FBI's slows down free(), so it's +** disabled by default. Use mwFreeBufferInfo(1) to enable it. +** +** To aid in tracking down wild pointer writes, MEMWATCH can perform +** no-mans-land allocations. No-mans-land will contain the byte 0xFC. +** MEMWATCH will, when this is enabled, convert recently free'd memory +** into NML allocations. +** +** MEMWATCH protects it's own data buffers with checksums. If you +** get an internal error, it means you're overwriting wildly, +** or using an uninitialized pointer. +** +************************************************************************ +** +** Note when compiling with Microsoft C: +** - MSC ignores fflush() by default. This is overridden, so that +** the disk log will always be current. +** +** This utility has been tested with: +** PC-lint 7.0k, passed as 100% ANSI C compatible +** Microsoft Visual C++ on Win16 and Win32 +** Microsoft C on DOS +** SAS C on an Amiga 500 +** Gnu C on a PC running Red Hat Linux +** ...and using an (to me) unknown compiler on an Atari machine. +** +************************************************************************ +** +** Format of error messages in MEMWATCH.LOG: +** message: filename(linenumber), information +** +** Errors caught by MemWatch, when they are detected, and any +** actions taken besides writing to the log file MEMWATCH.LOG: +** +** Double-freeing: +** A pointer that was recently freed and has not since been +** reused was freed again. The place where the previous free() +** was executed is displayed. +** Detect: delete or free() using the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** Underflow: +** You have written just ahead of the allocated memory. +** The size and place of the allocation is displayed. +** Detect: delete or free() of the damaged buffer. +** Action: The buffer is freed, but there may be secondary damage. +** Overflow: +** Like underflow, but you've written after the end of the buffer. +** Detect: see Underflow. +** Action: see Underflow. +** WILD free: +** An unrecognized pointer was passed to delete or free(). +** The pointer may have been returned from a library function; +** in that case, use mwFree_() to force free() of it. +** Also, this may be a double-free, but the previous free was +** too long ago, causing MEMWATCH to 'forget' it. +** Detect: delete or free() of the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** NULL free: +** It's unclear to me whether or not freeing of NULL pointers +** is legal in ANSI C, therefore a warning is written to the log file, +** but the error counter remains the same. This is legal using C++, +** so the warning does not appear with delete. +** Detect: When you free(NULL). +** Action: The free() is cancelled. +** Failed: +** A request to allocate memory failed. If the allocation is +** small, this may be due to memory depletion, but is more likely +** to be memory fragmentation problems. The amount of memory +** allocated so far is displayed also. +** Detect: When you new, malloc(), realloc() or calloc() memory. +** Action: NULL is returned. +** Realloc: +** A request to re-allocate a memory buffer failed for reasons +** other than out-of-memory. The specific reason is shown. +** Detect: When you realloc() +** Action: realloc() is cancelled, NULL is returned +** Limit fail: +** A request to allocate memory failed since it would violate +** the limit set using mwLimit(). mwLimit() is used to stress-test +** your code under simulated low memory conditions. +** Detect: At new, malloc(), realloc() or calloc(). +** Action: NULL is returned. +** Assert trap: +** An ASSERT() failed. The ASSERT() macro works like C's assert() +** macro/function, except that it's interactive. See your C manual. +** Detect: On the ASSERT(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the ASSERT to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Verify trap: +** A VERIFY() failed. The VERIFY() macro works like ASSERT(), +** but if MEMWATCH is not defined, it still evaluates the +** expression, but it does not act upon the result. +** Detect: On the VERIFY(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the VERIFY to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Wild pointer: +** A no-mans-land buffer has been written into. MEMWATCH can +** allocate and distribute chunks of memory solely for the +** purpose of trying to catch random writes into memory. +** Detect: Always on CHECK(), but can be detected in several places. +** Action: The error is logged, and if an ARI handler is installed, +** it is executed, otherwise, execution continues. +** Unfreed: +** A memory buffer you allocated has not been freed. +** You are informed where it was allocated, and whether any +** over or underflow has occured. MemWatch also displays up to +** 16 bytes of the data, as much as it can, in hex and text. +** Detect: When MemWatch terminates. +** Action: The buffer is freed. +** Check: +** An error was detected during a CHECK() operation. +** The associated pointer is displayed along with +** the file and line where the CHECK() was executed. +** Followed immediately by a normal error message. +** Detect: When you CHECK() +** Action: Depends on the error +** Relink: +** After a MEMWATCH internal control block has been trashed, +** MEMWATCH tries to repair the damage. If successful, program +** execution will continue instead of aborting. Some information +** about the block may be gone permanently, though. +** Detect: N/A +** Action: Relink successful: program continues. +** Relink fails: program aborts. +** Internal: +** An internal error is flagged by MEMWATCH when it's control +** structures have been damaged. You are likely using an uninitialized +** pointer somewhere in your program, or are zapping memory all over. +** The message may give you additional diagnostic information. +** If possible, MEMWATCH will recover and continue execution. +** Detect: Various actions. +** Action: Whatever is needed +** Mark: +** The program terminated without umarking all marked pointers. Marking +** can be used to track resources other than memory. mwMark(pointer,text,...) +** when the resource is allocated, and mwUnmark(pointer) when it's freed. +** The 'text' is displayed for still marked pointers when the program +** ends. +** Detect: When MemWatch terminates. +** Action: The error is logged. +** +** +************************************************************************ +** +** The author may be reached by e-mail at the address below. If you +** mail me about source code changes in MEMWATCH, remember to include +** MW's version number. +** +** Johan Lindh +** johan@linkdata.se +** +** The latest version of MEMWATCH may be downloaded from +** http://www.linkdata.se/ +*/ + +#ifndef __MEMWATCH_H +#define __MEMWATCH_H + +/* Make sure that malloc(), realloc(), calloc() and free() are declared. */ +/*lint -save -e537 */ +#include +/*lint -restore */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +** Constants used +** All MEMWATCH constants start with the prefix MW_, followed by +** a short mnemonic which indicates where the constant is used, +** followed by a descriptive text about it. +*/ + +#define MW_ARI_NULLREAD 0x10 /* Null read (to start debugger) */ +#define MW_ARI_ABORT 0x04 /* ARI handler says: abort program! */ +#define MW_ARI_RETRY 0x02 /* ARI handler says: retry action! */ +#define MW_ARI_IGNORE 0x01 /* ARI handler says: ignore error! */ + +#define MW_VAL_NEW 0xFE /* value in newly allocated memory */ +#define MW_VAL_DEL 0xFD /* value in newly deleted memory */ +#define MW_VAL_NML 0xFC /* value in no-mans-land */ +#define MW_VAL_GRB 0xFB /* value in grabbed memory */ + +#define MW_TEST_ALL 0xFFFF /* perform all tests */ +#define MW_TEST_CHAIN 0x0001 /* walk the heap chain */ +#define MW_TEST_ALLOC 0x0002 /* test allocations & NML guards */ +#define MW_TEST_NML 0x0004 /* test all-NML areas for modifications */ + +#define MW_NML_NONE 0 /* no NML */ +#define MW_NML_FREE 1 /* turn FREE'd memory into NML */ +#define MW_NML_ALL 2 /* all unused memory is NML */ +#define MW_NML_DEFAULT 0 /* the default NML setting */ + +#define MW_STAT_GLOBAL 0 /* only global statistics collected */ +#define MW_STAT_MODULE 1 /* collect statistics on a module basis */ +#define MW_STAT_LINE 2 /* collect statistics on a line basis */ +#define MW_STAT_DEFAULT 0 /* the default statistics setting */ + +/* +** MemWatch internal constants +** You may change these and recompile MemWatch to change the limits +** of some parameters. Respect the recommended minimums! +*/ +#define MW_TRACE_BUFFER 2048 /* (min 160) size of TRACE()'s output buffer */ +#define MW_FREE_LIST 64 /* (min 4) number of free()'s to track */ + +/* +** Exported variables +** In case you have to remove the 'const' keyword because your compiler +** doesn't support it, be aware that changing the values may cause +** unpredictable behaviour. +** - mwCounter contains the current action count. You can use this to +** place breakpoints using a debugger, if you want. +*/ +#ifndef __MEMWATCH_C +extern const unsigned long mwCounter; +#endif + +/* +** System functions +** Normally, it is not nessecary to call any of these. MEMWATCH will +** automatically initialize itself on the first MEMWATCH function call, +** and set up a call to mwAbort() using atexit(). Some C++ implementations +** run the atexit() chain before the program has terminated, so you +** may have to use mwInit() or the MemWatch C++ class to get good +** behaviour. +** - mwInit() can be called to disable the atexit() usage. If mwInit() +** is called directly, you must call mwTerm() to end MemWatch, or +** mwAbort(). +** - mwTerm() is usually not nessecary to call; but if called, it will +** call mwAbort() if it finds that it is cancelling the 'topmost' +** mwInit() call. +** - mwAbort() cleans up after MEMWATCH, reports unfreed buffers, etc. +*/ +void mwInit( void ); +void mwTerm( void ); +void mwAbort( void ); + +/* +** Setup functions +** These functions control the operation of MEMWATCH's protective features. +** - mwFlushNow() causes MEMWATCH to flush it's buffers. +** - mwDoFlush() controls whether MEMWATCH flushes the disk buffers after +** writes. The default is smart flushing: MEMWATCH will not flush buffers +** explicitly until memory errors are detected. Then, all writes are +** flushed until program end or mwDoFlush(0) is called. +** - mwLimit() sets the allocation limit, an arbitrary limit on how much +** memory your program may allocate in bytes. Used to stress-test app. +** Also, in virtual-memory or multitasking environs, puts a limit on +** how much MW_NML_ALL can eat up. +** - mwGrab() grabs up X kilobytes of memory. Allocates actual memory, +** can be used to stress test app & OS both. +** - mwDrop() drops X kilobytes of grabbed memory. +** - mwNoMansLand() sets the behaviour of the NML logic. See the +** MW_NML_xxx for more information. The default is MW_NML_DEFAULT. +** - mwStatistics() sets the behaviour of the statistics collector. See +** the MW_STAT_xxx defines for more information. Default MW_STAT_DEFAULT. +** - mwFreeBufferInfo() enables or disables the tagging of free'd buffers +** with freeing information. This information is written in text form, +** using sprintf(), so it's pretty slow. Disabled by default. +** - mwAutoCheck() performs a CHECK() operation whenever a MemWatch function +** is used. Slows down performance, of course. +** - mwCalcCheck() calculates checksums for all data buffers. Slow! +** - mwDumpCheck() logs buffers where stored & calc'd checksums differ. Slow!! +** - mwMark() sets a generic marker. Returns the pointer given. +** - mwUnmark() removes a generic marker. If, at the end of execution, some +** markers are still in existence, these will be reported as leakage. +** returns the pointer given. +*/ +void mwFlushNow( void ); +void mwDoFlush( int onoff ); +void mwLimit( long bytes ); +unsigned mwGrab( unsigned kilobytes ); +unsigned mwDrop( unsigned kilobytes ); +void mwNoMansLand( int mw_nml_level ); +void mwStatistics( int level ); +void mwFreeBufferInfo( int onoff ); +void mwAutoCheck( int onoff ); +void mwCalcCheck( void ); +void mwDumpCheck( void ); +void * mwMark( void *p, const char *description, const char *file, unsigned line ); +void * mwUnmark( void *p, const char *file, unsigned line ); + +/* +** Testing/verification/tracing +** All of these macros except VERIFY() evaluates to a null statement +** if MEMWATCH is not defined during compilation. +** - mwIsReadAddr() checks a memory area for read privilige. +** - mwIsSafeAddr() checks a memory area for both read & write privilige. +** This function and mwIsReadAddr() is highly system-specific and +** may not be implemented. If this is the case, they will default +** to returning nonzero for any non-NULL pointer. +** - CHECK() does a complete memory integrity test. Slow! +** - CHECK_THIS() checks only selected components. +** - CHECK_BUFFER() checks the indicated buffer for errors. +** - mwASSERT() or ASSERT() If the expression evaluates to nonzero, execution continues. +** Otherwise, the ARI handler is called, if present. If not present, +** the default ARI action is taken (set with mwSetAriAction()). +** ASSERT() can be disabled by defining MW_NOASSERT. +** - mwVERIFY() or VERIFY() works just like ASSERT(), but when compiling without +** MEMWATCH the macro evaluates to the expression. +** VERIFY() can be disabled by defining MW_NOVERIFY. +** - mwTRACE() or TRACE() writes some text and data to the log. Use like printf(). +** TRACE() can be disabled by defining MW_NOTRACE. +*/ +int mwIsReadAddr( const void *p, unsigned len ); +int mwIsSafeAddr( void *p, unsigned len ); +int mwTest( const char *file, int line, int mw_test_flags ); +int mwTestBuffer( const char *file, int line, void *p ); +int mwAssert( int, const char*, const char*, int ); +int mwVerify( int, const char*, const char*, int ); + +/* +** User I/O functions +** - mwTrace() works like printf(), but dumps output either to the +** function specified with mwSetOutFunc(), or the log file. +** - mwPuts() works like puts(), dumps output like mwTrace(). +** - mwSetOutFunc() allows you to give the adress of a function +** where all user output will go. (exeption: see mwSetAriFunc) +** Specifying NULL will direct output to the log file. +** - mwSetAriFunc() gives MEMWATCH the adress of a function to call +** when an 'Abort, Retry, Ignore' question is called for. The +** actual error message is NOT printed when you've set this adress, +** but instead it is passed as an argument. If you call with NULL +** for an argument, the ARI handler is disabled again. When the +** handler is disabled, MEMWATCH will automatically take the +** action specified by mwSetAriAction(). +** - mwSetAriAction() sets the default ARI return value MEMWATCH should +** use if no ARI handler is specified. Defaults to MW_ARI_ABORT. +** - mwAriHandler() is an ANSI ARI handler you can use if you like. It +** dumps output to stderr, and expects input from stdin. +** - mwBreakOut() is called in certain cases when MEMWATCH feels it would +** be nice to break into a debugger. If you feel like MEMWATCH, place +** an execution breakpoint on this function. +*/ +void mwTrace( const char* format_string, ... ); +void mwPuts( const char* text ); +void mwSetOutFunc( void (*func)(int) ); +void mwSetAriFunc( int (*func)(const char*) ); +void mwSetAriAction( int mw_ari_value ); +int mwAriHandler( const char* cause ); +void mwBreakOut( const char* cause ); + +/* +** Allocation/deallocation functions +** These functions are the ones actually to perform allocations +** when running MEMWATCH, for both C and C++ calls. +** - mwMalloc() debugging allocator +** - mwMalloc_() always resolves to a clean call of malloc() +** - mwRealloc() debugging re-allocator +** - mwRealloc_() always resolves to a clean call of realloc() +** - mwCalloc() debugging allocator, fills with zeros +** - mwCalloc_() always resolves to a clean call of calloc() +** - mwFree() debugging free. Can only free memory which has +** been allocated by MEMWATCH. +** - mwFree_() resolves to a) normal free() or b) debugging free. +** Can free memory allocated by MEMWATCH and malloc() both. +** Does not generate any runtime errors. +*/ +void* mwMalloc( size_t, const char*, int ); +void* mwMalloc_( size_t ); +void* mwRealloc( void *, size_t, const char*, int ); +void* mwRealloc_( void *, size_t ); +void* mwCalloc( size_t, size_t, const char*, int ); +void* mwCalloc_( size_t, size_t ); +void mwFree( void*, const char*, int ); +void mwFree_( void* ); +char* mwStrdup( const char *, const char*, int ); + +/* +** Enable/disable precompiler block +** This block of defines and if(n)defs make sure that references +** to MEMWATCH is completely removed from the code if the MEMWATCH +** manifest constant is not defined. +*/ +#ifndef __MEMWATCH_C +#ifdef MEMWATCH + +#define mwASSERT(exp) while(mwAssert((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ +#define mwVERIFY(exp) while(mwVerify((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ +#define mwTRACE mwTrace +#ifndef MW_NOTRACE +#ifndef TRACE +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +/* some compilers use a define and not a function */ +/* for strdup(). */ +#ifdef strdup +#undef strdup +#endif + +#define malloc(n) mwMalloc(n,__FILE__,__LINE__) +#define strdup(p) mwStrdup(p,__FILE__,__LINE__) +#define realloc(p,n) mwRealloc(p,n,__FILE__,__LINE__) +#define calloc(n,m) mwCalloc(n,m,__FILE__,__LINE__) +#define free(p) mwFree(p,__FILE__,__LINE__) +#define CHECK() mwTest(__FILE__,__LINE__,MW_TEST_ALL) +#define CHECK_THIS(n) mwTest(__FILE__,__LINE__,n) +#define CHECK_BUFFER(b) mwTestBuffer(__FILE__,__LINE__,b) +#define MARK(p) mwMark(p,#p,__FILE__,__LINE__) +#define UNMARK(p) mwUnmark(p,__FILE__,__LINE__) + +#else /* MEMWATCH */ + +#define mwASSERT(exp) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ + +#define mwVERIFY(exp) exp +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ + +/*lint -esym(773,mwTRACE) */ +#define mwTRACE /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction /*lint -restore */ +#ifndef MW_NOTRACE +#ifndef TRACE +/*lint -esym(773,TRACE) */ +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +extern void mwDummyTraceFunction(const char *,...); +/*lint -save -e652 */ +#define mwDoFlush(n) +#define mwPuts(s) +#define mwInit() +#define mwGrab(n) +#define mwDrop(n) +#define mwLimit(n) +#define mwTest(f,l) +#define mwSetOutFunc(f) +#define mwSetAriFunc(f) +#define mwDefaultAri() +#define mwNomansland() +#define mwStatistics(f) +#define mwMark(p,t,f,n) (p) +#define mwUnmark(p,f,n) (p) +#define mwMalloc(n,f,l) malloc(n) +#define mwStrdup(p,f,l) strdup(p) +#define mwRealloc(p,n,f,l) realloc(p,n) +#define mwCalloc(n,m,f,l) calloc(n,m) +#define mwFree(p) free(p) +#define mwMalloc_(n) malloc(n) +#define mwRealloc_(p,n) realloc(p,n) +#define mwCalloc_(n,m) calloc(n,m) +#define mwFree_(p) free(p) +#define mwAssert(e,es,f,l) +#define mwVerify(e,es,f,l) (e) +#define mwTrace mwDummyTrace +#define mwTestBuffer(f,l,b) (0) +#define CHECK() +#define CHECK_THIS(n) +#define CHECK_BUFFER(b) +#define MARK(p) (p) +#define UNMARK(p) (p) +/*lint -restore */ + +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ + +#ifdef __cplusplus + } +#endif + +#if 0 /* 980317: disabled C++ */ + +/* +** C++ support section +** Implements the C++ support. Please note that in order to avoid +** messing up library classes, C++ support is disabled by default. +** You must NOT enable it until AFTER the inclusion of all header +** files belonging to code that are not compiled with MEMWATCH, and +** possibly for some that are! The reason for this is that a C++ +** class may implement it's own new() function, and the preprocessor +** would substitute this crucial declaration for MEMWATCH new(). +** You can forcibly deny C++ support by defining MEMWATCH_NOCPP. +** To enble C++ support, you must be compiling C++, MEMWATCH must +** be defined, MEMWATCH_NOCPP must not be defined, and finally, +** you must define 'new' to be 'mwNew', and 'delete' to be 'mwDelete'. +** Unlike C, C++ code can begin executing *way* before main(), for +** example if a global variable is created. For this reason, you can +** declare a global variable of the class 'MemWatch'. If this is +** is the first variable created, it will then check ALL C++ allocations +** and deallocations. Unfortunately, this evaluation order is not +** guaranteed by C++, though the compilers I've tried evaluates them +** in the order encountered. +*/ +#ifdef __cplusplus +#ifndef __MEMWATCH_C +#ifdef MEMWATCH +#ifndef MEMWATCH_NOCPP +extern int mwNCur; +extern const char *mwNFile; +extern int mwNLine; +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; +void * operator new(size_t); +void * operator new(size_t,const char *,int); +void * operator new[] (size_t,const char *,int); // hjc 07/16/02 +void operator delete(void *); +#define mwNew new(__FILE__,__LINE__) +#define mwDelete (mwNCur=1,mwNFile=__FILE__,mwNLine=__LINE__),delete +#endif /* MEMWATCH_NOCPP */ +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +#endif /* __MEMWATCH_H */ + +/* EOF MEMWATCH.H */ diff --git a/omc/plat/public/src/include/omc_public.h b/omc/plat/public/src/include/omc_public.h new file mode 100644 index 0000000..34b6137 --- /dev/null +++ b/omc/plat/public/src/include/omc_public.h @@ -0,0 +1,643 @@ + +/************************************************************************/ +/* Title: omc_public.h */ +/* Desc: Public variables def for PACS OMC Project. */ +/* Author: Meng Xiaozhen */ +/* CrtDate: 2000-08-16 */ +/* AltDate: 2001-06-21 */ +/* CVS: $Id: omc_public.h,v 1.1 2000/08/03 01:09:33 mengxz Exp $ */ +/************************************************************************/ +#ifndef OMC_PUBLIC__H +#define OMC_PUBLIC__H + +#ifndef PUBLIC__H + #include "public.h" +#endif + +#ifndef IPTRANS__H + #include "iptrans.h" +#endif + +#define DEBUG 1 + +/***************************************************/ +/* Macro define for Server's system number */ +#define GRP_NUM 32 + +#define TS_NUM 32 +#define TS_SUB 16 +#define TS_E1 8 + +#define PW_NUM 32 +#define PW_SUB 3 + +#define ETH_NUM 32 +#define ETH_SUB 16 + +#define RDEV_NUM 32 +#define RDEV_SUB 8 +#define RDEV_E1 1 + +#define BSS_NUM 48 + +#define BSC_NUM 12 +#define BSC_SUB 9 +#define BSC_E1 2 + +#define BTS_NUM 24 //BTS system include 12 BTS subsystem +#define BTSSITE_NUM 48 //BTS site include 6 BTS subsystem +#define BTS_SUB 12 +#define BTS_E1 2 + +#define SVR_NUM 36 + +#define CONN_NUM 128 +#define CLIENT_NUM 50 +#define BTN_NUM 66 + +#define ALARM_NUM 20 +#define CACHE_BUF 512 +/***************************************************/ + +/***************************************************/ +/* Macro definition of start ID for applet's button used by system device */ +#define TS_START_BTN 0 +#define RDEV_START_BTN 18 +#define SVR_START_BTN 34 +#define BSC_START_BTN 54 +/***************************************************/ + + +/***************************************************/ +/* Macro define for Server's IP Address */ +#define OMC_0 "172.18.128.1" +#define OMC_1 "172.18.129.1" +#define HLR_0 "172.18.132.1" +#define HLR_1 "172.18.133.1" +#define PPS_0 "172.18.136.1" +#define PPS_1 "172.18.137.1" +#define CDR_0 "172.18.160.1" +#define CDR_1 "172.18.161.1" +/***************************************************/ + +/***************************************************/ +/* Macro define for Mysql Database */ +#define HOST_NAME "localhost" +#define DB_NAME1 "mysql" +#define DB_PORT_NUM 0 +#define SOCKET_NAME NULL +#define FLAGS 0 +#define USER_NAME "root" +#define PASSWORD "rootaa" +/***************************************************/ + +/***************************************************/ +/* Macro def for (UDP)Communication port used by OMC */ +#define PORT_OUT 4951 //for sending message to ts +#define PORT_BASE 4951 +#define PORT_REALSTAT 3 /* 4951 + 3 = 4954 */ +#define PORT_CSTA 4 /* 4951 + 4 = 4955 */ +#define PORT_COMM 5 /* 4951 + 5 = 4956 */ +#define PORT_HEARTBEAT 6 /* 4951 + 6 = 4957 */ +#define PORT_CLUSTER 27 /* 4951 + 27 =4978 */ +#define BROADCAST_IP "172.18.255.255" +#define CLUSTER_IP "239.255.10.1" +#define BROADCAST 0 //if broadcast message + +/***************************************************/ +/* Macro def for shm key and sem key used by OMC */ +#define COMM_FLAG_SHM_KEY 0x6a000000 +#define COMM_FLAG_SHM_PERM 0666 +#define COMM_FLAG_SEM_KEY 300 +#define COMM_FLAG_SEM_PERM 0666 +#define COMM_FLAG_SEM_NUM 1 +#define COMM_FLAG_SIZE 1024 + +#define COMM_LIST_SHM_KEY 0x6a100000 +#define COMM_LIST_SHM_PERM 0666 +#define COMM_LIST_SEM_KEY 310 +#define COMM_LIST_SEM_PERM 0666 +#define COMM_LIST_SEM_NUM 1 + +#define STATUS_SHM_KEY 0x6a200000 +#define STATUS_SHM_PERM 0666 +#define STATUS_SEM_KEY 320 +#define STATUS_SEM_PERM 0666 +#define STATUS_SEM_NUM 1 + +#define CACHE_SHM_KEY 0x6a400000 +#define CACHE_SHM_PERM 0666 +#define CACHE_SEM_KEY 340 +#define CACHE_SEM_PERM 0666 +#define CACHE_SEM_NUM 1 + +#define BSS_SHM_KEY 0x6a600000 +#define BSS_SHM_PERM 0666 +#define BSS_SEM_KEY 360 +#define BSS_SEM_PERM 0666 +#define BSS_SEM_NUM 1 + +#define LED_SHM_KEY 0x6a800000 +#define LED_SHM_PERM 0666 +#define LED_SEM_KEY 380 +#define LED_SEM_PERM 0666 +#define LED_SEM_NUM 1 + +#define CLUSTER_SHM_KEY 0x6a900000 +#define CLUSTER_SHM_PERM 0666 +#define CLUSTER_SEM_KEY 390 +#define CLUSTER_SEM_PERM 0666 +#define CLUSTER_SEM_NUM 1 +/***************************************************/ + +/*############################################################################ + * shm structure + * between heartbeat transceiver and heartbeat processor + * & + * between heartbeat transceiver and svr cluster processor + *###########################################################################*/ + typedef struct cache_list{ + long msgSrcIP; + u_short msgLength; + BYTE msgContent[CACHE_BUF]; + }cache_list; + + typedef struct status_cahce{ + //int send_flag; + /*this flag is only for server cluster funciton + *0/1/2=ignore cluster FSM influence,directly send heartbeat/cluster permit *to send heartbeat/can't send heartbeat,waiting cluster's info + */ + u_short msgReadSub; + u_short msgWriteSub; + cache_list msgcache[CACHE_BUF]; + }status_cache; + +/*############################################################################ + * shm structure between real status processor and heartbeat processor + *###########################################################################*/ + +typedef struct clientinfo { + BYTE used_flag; // 0/1=not used/used + BYTE grp_id; // group which is requested by client now + BYTE is_responsed; // 0/1/2=not response/responsing/responsed + long ip; + unsigned int waittime; //if waittime>60seconds,timeout + BYTE updatetime[16]; //last time when client request info +} client_info; + +typedef struct conninfo { + BYTE avail_flag; // 0/1=unavailable/available + BYTE disp_name; // 0/1=not display/display + char name[16]; + char remark[44]; + BYTE lsys_type;// local device system type + BYTE lsys_id; //local device system id + BYTE lsub_id; //local device subsystem id + BYTE rsys_type; //remote device system type + BYTE rsys_id; //remote device system id + BYTE rsub_id; //remote device subsystem id +} conn_info; + +typedef struct btninfo { + BYTE used_flag; // 0/1=not use/used + BYTE sys_type; // device system type + BYTE sys_id; // device system id + BYTE sub_id; // device subsystem id +} btn_info; + +typedef struct grp_simple_stat { + btn_info btn[BTN_NUM]; // relationship between button and device + unsigned int coord[2]; // X,Y coord for group icon + int critical; // critical counter + int alarm; // alarm counter + BYTE isinstalled; // 0/1=not install/install + BYTE ts_id[2]; // Transit switch id(default=99,no ts) + BYTE disp_name; // 0/1=not display/display + BYTE grp_name[17]; // Group name + BYTE grp_remark[45]; // remark about group + BYTE stat_amount; // number of status for group icon + BYTE stat_direct; // direction of display status (0/1=h/v) + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3= uninstalled + */ +}grpsimple_stat; + +typedef struct subts_detail_stat { + BYTE subtype; //subsystem status + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat0[8];// simple status of this subsystem + /* substat0[0] -- if subsys is installed(0/1=not/yes) + * substat0[1] -- if subsys is normal(0/1=abnormal/normal) + * substat0[2] -- if subsys send master clock(0/1=not/sending) + * substat0[3] -- locking clock(0-7:2=normal,7=idle,other=abnormal) + */ + BYTE substat1[8]; // performance or status data of subsystem + /* substat1[0-1] -- CPU Load ('00'-'45') + * substat1[2-4] -- Clock frequency('000'-'255') + */ + + BYTE e1stat0[TS_E1][8]; //simple status of all E1 + /* e1[i][0] -- e1[i] installed/not installed (0/1=not/yes) + * e1[i][1] -- e1[i] layer 2 installed/not installed (0/1=not/yes) + * e1[i][2] -- e1[i] layer 1 connected/disconnected (0/1=not/yes) + * e1[i][3] -- e1[i] layer 2 connected/disconnected (0/1=not/yes) + * e1[i][4] -- e1[i] without/with ECHO CANCELLER (0/1=not/yes) + */ + BYTE e1stat1[TS_E1][8]; // performance or status data of all E1 + /* e1[i][0-1] -- e1[i] idle channels('00'/'30') + */ + + long lock_alarmtime; + /*last time inserting alarm log into db because of clock locking error + */ + long e1_alarmtime[TS_E1][2]; + /*last time inserting alarm log into db because of e1 1,2th error + */ + BYTE version_info[16]; + /*version information for the application + */ + BYTE updatetime[16]; //last time refreshing subsystem status +}subtsdetail_stat; + +typedef struct subpw_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat[2]; // status of this subsystem(0/1=abnomal/normal) + /* substat[0] -- if subsys is installed(0/1=not/yes) + * substat[1] -- if subsys is normal(0/1=abnormal/normal) + */ + + long pcard_alarmtime; + /*last time inserting alarm log into db because of power card error + */ + BYTE updatetime[16]; //last time refreshing subsystem status +}subpwdetail_stat; + +typedef struct ts_detail_stat { + BYTE grp_id; + BYTE clock_status;//if master clock is normal(0/1=N/Y) + long clock_alarmtime;//master clock status + /*last time inserting alarm log into db because of master clock error + */ + subtsdetail_stat sub_detail[TS_SUB]; + subpwdetail_stat subpw_detail[PW_SUB]; +}tsdetail_stat; + +typedef struct subts_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if TS subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subtssimple_stat; + + +typedef struct ts_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for ts icon + BYTE stat_direct; // direction of display status (0/1=h/v) + subtssimple_stat sub_simple[TS_SUB]; + subtssimple_stat subpw_simple[PW_SUB]; +} tssimple_stat; + +typedef struct subeth_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + long self_ip; //ip address of LAN Module self + BYTE mac[6]; //physical address of LAN Module + + BYTE substat[6]; + /* substat[0] -- if LAN Module is installed(0/1) + * substat[1] -- if LAN Module is normal(0/1) + * substat[2] -- if there is unreachable ip(0/1) + * substat[3] -- if LAN Module upload program to csu(0/1) + * substat[4] -- if csu is availabe (0/1) + */ + + BYTE cpu_load[2]; //CPU load of LAN module(hex value) + BYTE unreachable_ip[4]; //ip Can't be found by LAN Module (hex value) + long unreach_time; + + long alarmtime[2]; + /*CSU Upload program status + *alarmtime[0] -- can't reach target ip address + *alarmtime[1] -- uploading program + */ + BYTE version_info[16]; + /*version information for the application + */ + char updatetime[16]; +}subethdetail_stat; + +typedef struct eth_detail_stat { + BYTE grp_id; + subethdetail_stat sub_detail[ETH_SUB]; +}ethdetail_stat; + +typedef struct subeth_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if TS subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subethsimple_stat; + +typedef struct eth_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + subethsimple_stat sub_simple[ETH_SUB]; +} ethsimple_stat; + +typedef struct subrdev_detail_stat { + BYTE subtype; //0-4 + + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat0[6]; + /* substat[0] -- if subsys is installed(0/1=N/Y) + * substat[1] -- if subsys is normal(0/1=N/Y) + * sysstat[2] -- if send master clock(0/1=N/Y) + */ + BYTE substat1[6]; + /* substat[0-1] -- used CPU(00/30) + */ + + BYTE e1stat0[RDEV_E1][8]; + /* e1[0] -- e1 installed/not installed (0/1=N/Y) + * e1[1] -- e1 layer 1 connected/disconnected (0/1=N/Y) + * e1[2] -- e1 layer 2 connected/disconnected (0/1=N/Y) + */ + BYTE e1stat1[RDEV_E1][8]; + /* e1[i][0-1] -- e1 idle channels('00'--'30') + */ + + long e1_alarmtime[RDEV_E1][2]; + /* alarmtime[i][0] -- e1[i] layer 1 + * alarmtime[i][1] -- e1[i] layer 2 + */ + BYTE version_info[16]; + /*version information for the application + */ + char updatetime[16]; +}subrdevdetail_stat; + +typedef struct rdev_detail_stat { + BYTE grp_id; + BYTE systype; //05=VPS;06=PCR + BYTE clock_status;//if master clock is normal(0/1=N/Y) + long clock_alarmtime;//master clock status + /*last time inserting alarm log into db because of master clock error + */ + subrdevdetail_stat sub_detail[RDEV_SUB]; +}rdevdetail_stat; + +typedef struct subrdev_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if Rdev subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subrdevsimple_stat; + +typedef struct rdev_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for rdev icon + BYTE stat_direct; // direction of display status (0/1=h/v) + subrdevsimple_stat sub_simple[RDEV_SUB]; +} rdevsimple_stat; + +typedef struct bts_simple_stat { + BYTE isinstalled; // 0/1=not/installed + BYTE bts_site_id; + BYTE bts_link_id; + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bts site icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} btssimple_stat; + +typedef struct bsc_simple_stat { + BYTE isinstalled; // 0/1=not/installed + BYTE location; // 0/1=local/remote + BYTE timeout; // 0/1=timeout/not timeout + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bsc icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} bscsimple_stat; + + +/* structure for server detail status in heartbeat processor + ************************************/ +typedef struct svr_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=not/timeout) + BYTE grp_id; + BYTE systype; + BYTE sys_id; + int cpuused; + int viravail; + int virfree; + int memavail; + int memfree; + int hdavail; + int hdfree; + BYTE init_progress[3]; + BYTE proc_id[16]; + BYTE proc_status[16]; + BYTE subproc_num[16]; + BYTE sysstat[16]; // 0/1=abnormal/normal + /* + * 0=Normal,1=abnormal + *sysstat[0]: system status + * sysstat[1]:cpu status sysstat[2]:swap status + * sysstat[3]:memory status sysstat[4]:disk status + * sysstat[5]:proc_status sysstat[6]:server working status + * sysstat[7]:database status + */ + long alarmtime[6]; + + BYTE version_info[16]; + /*version information for the application + */ + BYTE updatetime[16]; +} svrdetail_stat; + +typedef struct svr_simple_stat { + BYTE grp_id; + BYTE location; + BYTE isinstalled; + int waittime; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bts site icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} svrsimple_stat; + +struct alarm_log { + BYTE systype; + BYTE sys_id; + BYTE sub_id; + BYTE e1no; + BYTE alarmnum; + BYTE occurtime[16]; +}; + +typedef struct ts_alarm_log { + int readSub; + int writeSub; + struct alarm_log alrlist[ALARM_NUM]; +} tsalarm_log; + +typedef struct ask_alarm_log { + long client_ip; //ip address where the request is sent from + int init_Req_Flag; + int readSub; + int writeSub; + struct alarm_log alrlist[ALARM_NUM]; +} askalarm_log; + +/* + * shared memory structure + *************************/ +typedef struct shm_ts_stat { + BYTE init_flag; + BYTE sys_struct;//0/1=single/double plane system structure + grpsimple_stat grp_simple[GRP_NUM]; + tsdetail_stat ts_detail[TS_NUM]; + tssimple_stat ts_simple[TS_NUM]; + ethdetail_stat eth_detail[ETH_NUM]; + ethsimple_stat eth_simple[ETH_NUM]; + rdevdetail_stat vps_detail[RDEV_NUM]; + rdevsimple_stat vps_simple[RDEV_NUM]; + rdevdetail_stat pcr_detail[RDEV_NUM]; + rdevsimple_stat pcr_simple[RDEV_NUM]; + svrdetail_stat svr_detail[SVR_NUM]; + svrsimple_stat svr_simple[SVR_NUM]; + /* + sysnum=systype*2+sys_id + svr_simple[0]=OMC-0 + svr_simple[1]=OMC-1 + svr_simple[2]=HLR-0 + svr_simple[3]=HLR-1 + svr_simple[4]=PRP-0 + svr_simple[5]=PRP-1 + svr_simple[6]=CDR-0 + svr_simple[7]=CDR-1 + */ + bscsimple_stat bsc_simple[BSC_NUM]; + + BYTE global_status[ETH_NUM]; + conn_info connection[CONN_NUM]; + client_info client[CLIENT_NUM]; + /*global_status[0]= if normal ;global_status[1]= if changed*/ + tsalarm_log alarmlog; +} shm_stat; + +/*****************************************************************************/ +/* Lan Module's global status*/ +typedef struct global_status{ + BYTE eth_mac[ETH_NUM][ETH_SUB][7]; + long update_time[ETH_NUM][ETH_SUB]; + long alarm_time[ETH_NUM][ETH_SUB]; +}eth_global; +/***************************************************/ + +/*****************************************************************************/ +/* structure for BSS simple status in heartbeat processor + ************************************/ +typedef struct bss_simple_stat { + BYTE isinstalled[BSS_NUM]; + BYTE ischanged[BSS_NUM]; + BYTE isnormal[BSS_NUM]; + unsigned int waittime[BSS_NUM]; +} bsssimple_stat; +/***************************************************/ + +#endif /*OMC_PUBLIC__H */ diff --git a/omc/plat/public/src/include/pub_base.h b/omc/plat/public/src/include/pub_base.h new file mode 100644 index 0000000..d1638b0 --- /dev/null +++ b/omc/plat/public/src/include/pub_base.h @@ -0,0 +1,127 @@ +////////////////////////////////////////////////// +//Title : pub_basic.c +//Auhtor : Liu Wei +//Desc : public basic function +//Created : 2007-06-23 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_BASE_H_ +#define _PUB_BASE_H_ + +typedef struct VALUE_STRING +{ + u32 dValue; + u8 *pStr; +} StringVal; + +#define ALPHA_TABLE_LOWER "abcdefghijklmnopqrstuvwsyz" +#define ALPHA_TABLE_UPPER "ABCDEFGHIJKLMNOPQRSTUVWSYZ" + +#define NOTSO(n) ( !(n) ) +#define IsNull(n) ( ((n) == NULL) ) +#define CNULL '\0' +#define IsChNull(ch) ( ch==CNULL ) +#define STR_CHECK_LAST(str,ch) ( str[strlen(str)-1] == ch ) +#define STR_CHECK_FIRST(str,ch) ( str[0] == ch ) +#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL ) + + +#define BitSet(arg,posn) ((arg) | (1L << (posn))) +#define BitClr(arg,posn) ((arg) & ~(1L << (posn))) +#define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) +#define BitTst(arg,posn) (!(!((arg) & (1L << (posn))))) + + +#define HexToChar(ch) ( (ch) + ( ((ch) > 9)? 'A'-10 : '0') ) + +/////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef MAX +#define MAX(a, b) ( (a) > (b) ? (a) : (b) ) +#define MIN(a, b) ( (a) < (b) ? (a) : (b) ) +#endif + +/////////////////////////////////////////////////////////////////////////// +// +// Name : GET_U8 GET_U16 GET_U32 +// Function : Return the u8 /u16 / u32 value of the pointer memery +// Parameter: x : pointer +// +/////////////////////////////////////////////////////////////////////////// +#define GET_U8( x ) ( *( (u8 *) (x) ) ) +#define GET_U16( x ) ( *( (u16 *) (x) ) ) +#define GET_U32( x ) ( *( (u32 *) (x) ) ) + +/////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////// +#define U16_LOW_BYTE ( x ) ( (u8 )( ((u16) (x) ) & 0xFF ) ) +#define U16_HIG_BYTE ( x ) ( (u8 )( ((u16) (x) ) >> 8 ) ) + +#define LSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[0]) * 256) + (uVal)[1] ) +#define MSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[1]) * 256) + (uVal)[0] ) + +#define LSB_WORD2BYTE( wVal , uVal ) \ + (uVal)[0] = ((wVal) / 256); \ + (uVal)[1] = ((wVal) & 0xFF ) + +#define MSB_WORD2BYTE( wVal , uVal ) \ + (uVal)[1] = ((wVal) / 256 ); \ + (uVal)[0] = ((wVal) & 0xFF) + +/////////////////////////////////////////////////////////////////////////// +// +// Name : ARR_SIZE +// Function : Return array size of a +// Parameter: a : array +// +/////////////////////////////////////////////////////////////////////////// +#define ARR_SIZE( a ) ( sizeof( (a) ) / sizeof( (a[0]) ) ) + +/////////////////////////////////////////////////////////////////////////// +// +// Name : STR +// Function : Convert the s to string +// Parameter: a : a value you want to Convert to string but no need "" +// e.g. : printf(STR(if(NOTSO(a)) return 0)); +/////////////////////////////////////////////////////////////////////////// +#define STR(s) #s +#define FILL_VALSTR(n) {n,#n} +#define GET_FILE_NAME(fn) \ + { \ + static char fn[] = STR(_FILE_); \ + } + +#define GetValueString(i,p,Maxtrix,IdMax) \ + { \ + if( (i) >= (IdMax) ) \ + { \ + (p) = Maxtrix[(IdMax)].pStr; \ + } \ + else \ + { \ + (p) = Maxtrix[(i)].pStr; \ + } \ + } + +#define GET_MODULE_VER(x) (x##_VERSION) + +#define FPOS( type, field ) \ +/*lint -e545 */ ( ( dword ) & ( ( type * ) 0 )->field ) /*lint +e545 */ + +#define FSIZ( type, field ) sizeof( ((type *) 0)->field ) + +/////////////////////////////////////////////////////////////////////////// +// DivRndUp: Divide and Round Up /// +/////////////////////////////////////////////////////////////////////////// + +#define DivRndUp(Num,Div) ( ((Num) % (Div))?((Num)/(Div) + 1):((Num)/(Div)) ) + + +#endif diff --git a/omc/plat/public/src/include/pub_debug.h b/omc/plat/public/src/include/pub_debug.h new file mode 100644 index 0000000..adb25b3 --- /dev/null +++ b/omc/plat/public/src/include/pub_debug.h @@ -0,0 +1,43 @@ +////////////////////////////////////////////////// +//Title : pub_debug.h +//Auhtor : Liu Wei +//Desc : public debug api header +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_DEBUG_H_ +#define _PUB_DEBUG_H_ + +#include "stdio.h" +#include "assert.h" +#include "string.h" +#include "stdlib.h" +#include +#include + + +extern void WxcDump(int nSigno); + +extern void WxcBackTrace(); + +#ifdef DEBUG +#define WxcAssert(Expression,pStr) \ + { \ + int nVal = (Expression); \ + if(!nVal) \ + { \ + WxcBackTrace(); \ + } \ + assert( nVal && pStr ); \ + } + +#else +#define WxcAssert(uVal,pStr) +#endif + +#endif + diff --git a/omc/plat/public/src/include/pub_file.h b/omc/plat/public/src/include/pub_file.h new file mode 100644 index 0000000..b8bf495 --- /dev/null +++ b/omc/plat/public/src/include/pub_file.h @@ -0,0 +1,22 @@ +////////////////////////////////////////////////// +//Title : wxc_file.h +//Auhtor : Liu Wei +//Desc : wxc file handle header +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_FILE_H_ +#define _PUB_FILE_H_ + +#include "./public.h" +#include "./includes.h" +#include "./pub_base.h" + + + + +#endif diff --git a/omc/plat/public/src/include/pub_fmt.h b/omc/plat/public/src/include/pub_fmt.h new file mode 100644 index 0000000..b0ffc29 --- /dev/null +++ b/omc/plat/public/src/include/pub_fmt.h @@ -0,0 +1,132 @@ +////////////////////////////////////////////////// +//Title : pub_convert.h +//Auhtor : Liu Wei +//Desc : public type fomat convert inplementation +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// lCRD software network data type assumpsit +// +// Memery Low <<============[Little Endian]===========>> Memery High +// Type abbr. e.g. Remark +// const value CVal 0x12345678 +// Host BCD HBcd/BCd 0x78 0x56 0x34 0x12 +// Anti BCD ABcd 0x87 0x65 0x43 0x21 +// NetBCD NBcd 0x12 0x34 0x56 0x78 +// String Str 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 "12345678" +// U64 U64 0x4E 0x61 0xBC 0x00 0x00 0x00 0x00 0x00 12345678=0xBC614E +// Digit Dig 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef _PUB_FMT_H_ +#define _PUB_FMT_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_debug.h" + +extern inline char HexToCh ( u8 uHex ); +extern inline u8 ChToHex ( char ch ); + + +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len); +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len); + +/////////////////////////////////////////////////////////////////////////// +// ReverseByte : 0010 1010 =>> 0101 0100 +// +/////////////////////////////////////////////////////////////////////////// +extern u8 ReverseByte(u8 uByteIn ); + +/////////////////////////////////////////////////////////////////////////// +// ReverseBCD : 0x12 0x34 0x56 0x78 =>> 0x21 0x43 0x65 0x87 +// +/////////////////////////////////////////////////////////////////////////// +extern void ReverseBCD( u8 *pDst , const u8 *pSrc , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// ReverseArray : 0x12 0x34 0x56 0x78 =>> 0x78 0x56 0x34 0x12 +// +/////////////////////////////////////////////////////////////////////////// +extern void ReverseArray( u8 *pDst , const u8 *pSrc , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToStr : 0x12 0x34 0x56 0x78 =>> "12345678" +// +/////////////////////////////////////////////////////////////////////////// +extern void BcdToStr( char *pStr , const u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToU64 : 0x12 0x34 0x56 0x78 =>> 12345678 +// +////////////////////////////////////////////////////////////////////////// +extern u64 BcdToU64( const u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToDig : 0x12 0x34 0x56 =>>0x01 0x02 0x03 0x04 0x05 0x06 +// +/////////////////////////////////////////////////////////////////////////// +extern int BcdToDig( u8 *pDig , int nDigBuffLen, u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// StrToBcd : "123456" =>> 0x12 0x34 0x56 +// +/////////////////////////////////////////////////////////////////////////// +extern int StrToBcd( u8 *pBcd , char *pStr , int nBcdBuffLen ); + +/////////////////////////////////////////////////////////////////////////// +// U64ToBcd : 1234567 => 0x01 0x23 0x45 0x67 +// +/////////////////////////////////////////////////////////////////////////// +extern int U64ToBcd( u8 *pBcd ,u64 llInput , int nBcdBuffLen ); + +/////////////////////////////////////////////////////////////////////////// +// DigToBcd : 0x01 0x02 0x03 x04 0x05 0x06 0x07 => 0x01 0x23 0x45 0x67 +// +/////////////////////////////////////////////////////////////////////////// +extern int DigToBcd( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen ); +extern int DigToBcdE( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen , int nEnd ); + + +int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen ); +int Bcd2Str ( char *pStr, const BYTE * pBcd, int len ); +int DigitsLen(BYTE *pDigits, int maxLen); +int BcdLen(BYTE *pBcd, int maxLen); +int Digits2Str(char *pStr, BYTE *pDigits, int DigitsLen); +ull Digits2Ull(BYTE *pDigits, int DigitsLen); +int Ull2Digits(BYTE *pDigits, ull value, int DigitsLen); +int Str2Digits(BYTE *pDigits, char *pStr, int DigitsLen); +int Ull2Digits_Ralign(BYTE *pDigits, ull value, int DigitsLen); +ull Bcd2Ull(BYTE *pBcd, int BcdLen); +int Ull2Bcd(BYTE *pBcd, ull value, int BcdLen); +int Digits2Bcd(BYTE *pBcd, BYTE *pDigits, int maxLen); +int Bcd2Digits(BYTE *pDigits, BYTE *pBcd, int maxLen); +int Bcd2Digits_dLen(BYTE *pDigits, BYTE *pBcd, int maxLen); +int Str2Oid(DWORD *pOid, char *pStr, BYTE maxLen); +int TrimLeft(char *pStr); +int TrimRight(char *pStr); +int Array2Digits(BYTE *pDigits, BYTE *pArray, int ArrayLen); +ull Str2Ull(char *pStr); +int Digits2Array(BYTE *pArray, BYTE *pDigits, int DigitsLen); +int Bcd2Array(BYTE *pArray, BYTE *pBcd, int BcdLen); +int Str2Array(BYTE *pArray, char *str, int ArrayLen); +BYTE EditDigits(BYTE *digits_out, BYTE len_max, BYTE *digits_in, BYTE len_in, BYTE len_del, BYTE *digits_ins, BYTE len_ins, BYTE filler); +BYTE DelDigits(BYTE *in_digit, BYTE in_len, BYTE *out_digit, BYTE count, BYTE filler); +void DWORD2BYTE(BYTE *pdword, BYTE *pbyte, int len); +void u32tobyte(u8 *str, u32 data); +u8 u16tobcd(u8 *bcd_string, u16 data); +u16 bcdtou16(u8 *bcd_string, u8 bcd_len); +u8 u32tobcd(u8 *bcd_string, u32 data); +u32 bcdtou32(u8 *bcd_string, u8 bcd_len); +void AsciiToRbcd(BYTE *bcd_buf, const char *ascii_buf, int len); + + +#endif + diff --git a/omc/plat/public/src/include/pub_include.h b/omc/plat/public/src/include/pub_include.h new file mode 100644 index 0000000..1eaac8a --- /dev/null +++ b/omc/plat/public/src/include/pub_include.h @@ -0,0 +1,39 @@ +////////////////////////////////////////////////// +//Title : pub_incudes.h +//Auhtor : Liu Wei +//Desc : public header includes +//Created : 2007-07-13 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _PUB_INCLUDE_H_ +#define _PUB_INCLUDE_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "asn1.h" +#include "crypt.h" +#include "bisearch.h" +#include "pub_base.h" +#include "pub_debug.h" +#include "pub_log.h" +#include "pub_file.h" +#include "pub_list.h" +#include "pub_malloc.h" +#include "pub_fmt.h" +#include "pub_base.h" +#include "pub_time.h" +#include "pub_timer.h" +#include "pub_sys.h" +#include "pub_str.h" +#include "pub_inet.h" +#include "pub_wnet.h" +#include "pub_netcap.h" +#include "pub_sdp.h" + +#endif diff --git a/omc/plat/public/src/include/pub_inet.h b/omc/plat/public/src/include/pub_inet.h new file mode 100644 index 0000000..44955a6 --- /dev/null +++ b/omc/plat/public/src/include/pub_inet.h @@ -0,0 +1,77 @@ +////////////////////////////////////////////////// +//Title : pub_inet.h +//Auhtor : Liu Wei +//Desc : public inet function header +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_INET_H_ +#define _PUB_INET_H_ + +#include "public.h" +#include "includes.h" +#include "pub_debug.h" + +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// + +#define MAXINTERFACES 16 + +typedef struct IF_ADDR +{ + u8 uIfNum; + struct + { + u32 dIfIP; + u8 uIfState; + } + tIfEntity[MAXINTERFACES]; +} +IfAddr; + +extern int GetNetIfInfo ( IfAddr * pIfAddr ); + +extern u32 GetLocalIP(); + +/////////////////////////////////////////////////////////////////////////// +// Ping Interface +/////////////////////////////////////////////////////////////////////////// + +#define PACKET_SIZE 4096 +#define MAX_NO_PACKETS 3 + +typedef void PingCallBack( int nPingResult ); + +typedef struct ICMP_SERVICE +{ + u8 uSrvState; + u8 uIcmpState; + u8 uPackNo; + u8 uDataLen; + u8 nPackNumSend; + u8 nPackNumRecv; + u8 aSendBuff[PACKET_SIZE]; + u8 aRecvBuff[PACKET_SIZE]; + u32 wSockfd; + pid_t tPid; + struct sockaddr_in tToAddr; + struct sockaddr_in tFromAddr; + struct protoent *pProtoent; + PingCallBack *fCallBack; +} +IcmpSrv; + +extern int PingInit ( IcmpSrv *pIS , int nDataLen ); + +extern int PingStart( IcmpSrv *pIS , char *sIP , PingCallBack fCallBack ); + +extern int PingTimer ( IcmpSrv *pIS ); + +DWORD GetLocalIP(); +DWORD wxc2_get_shm_offset(); +#endif diff --git a/omc/plat/public/src/include/pub_list.h b/omc/plat/public/src/include/pub_list.h new file mode 100644 index 0000000..43b49a5 --- /dev/null +++ b/omc/plat/public/src/include/pub_list.h @@ -0,0 +1,501 @@ +////////////////////////////////////////////////// +//Title : pool.c +//Auhtor : Liu Wei +//Desc : List and Pool Queue struct implement +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_LIST_H_ +#define _PUB_LIST_H_ + +//LIFO Queue + +#define LIFOQ_HEAD( name , type ) \ + struct name \ + { \ + struct type *pLqFirst;/*First elment*/ \ + } + +#define LIFOQ_ENTRY(type) \ + struct \ + { \ + struct type *pLqNext; \ + } + +#define LIFOQ_EMPTY(head) \ + ((head)->pLqFirst == NULL) + +#define LIFOQ_FIRST(head) \ + ((head)->pLqFirst) + +#define LIFOQ_FOREACH(var, head, field) \ + for((var) = (head)->pLqFirst; (var); (var) = (var)->field.pLqNext) + +#define LIFOQ_INIT(head) \ + { \ + (head)->pLqFirst = NULL; \ + } + +#define LIFOQ_INSERT_AFTER(lifoq_elm, elm, field) \ + do \ + { \ + (elm)->field.pLqNext = (lifoq_elm)->field.pLqNext; \ + (lifoq_elm)->field.pLqNext = (elm); \ + } while (0) + +#define LIFOQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + (elm)->field.pLqNext = (head)->pLqFirst; \ + (head)->pLqFirst = (elm); \ + } while (0) + +#define LIFOQ_NEXT(elm, field) ((elm)->field.pLqNext) + +#define LIFOQ_REMOVE_HEAD(head, field) \ + do \ + { \ + (head)->pLqFirst = (head)->pLqFirst->field.pLqNext; \ + } while (0) + +#define LIFOQ_REMOVE(head, elm, type, field) \ + do \ + { \ + if ((head)->pLqFirst == (elm)) \ + { \ + LIFOQ_REMOVE_HEAD((head), field); \ + } \ + else \ + { \ + struct type *curelm = (head)->pLqFirst; \ + \ + while( curelm->field.pLqNext != (elm) ) \ + { \ + curelm = curelm->field.pLqNext; \ + } \ + curelm->field.pLqNext = \ + curelm->field.pLqNext->field.pLqNext; \ + } \ + } while (0) + +//FIFO Quence + +#define FIFOQ_HEAD(name, type) \ + struct name \ + { \ + struct type *pFqFirst;/* first element */ \ + struct type **pFqLast;/* addr of last next element */ \ + } + +#define FIFOQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).pFqFirst } + +#define FIFOQ_ENTRY(type) \ + struct \ + { \ + struct type *pFqNext; /* next element */ \ + } + +#define FIFOQ_EMPTY(head) ((head)->pFqFirst == NULL) + +#define FIFOQ_INIT(head) \ + do \ + { \ + (head)->pFqFirst = NULL; \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_FIRST(head) ((head)->pFqFirst) + +#define FIFOQ_LAST(head, type, field) \ + (FIFOQ_EMPTY(head) ? NULL : ((struct type *) \ + ((char *)((head)->spTQLast) - __offsetof(struct type, field)))) + +#define FIFOQ_FOREACH(var, head, field) \ + for((var) = (head)->pFqFirst; (var); (var) = (var)->field.pFqNext) + +#define FIFOQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pFqNext = (head)->pFqFirst) == NULL) \ + (head)->spTQLast = &(elm)->field.pFqNext; \ + (head)->pFqFirst = (elm); \ + } while (0) + +#define FIFOQ_INSERT_TAIL(head, elm, field) \ + do \ + { \ + (elm)->field.pFqNext = NULL; \ + *(head)->spTQLast = (elm); \ + (head)->spTQLast = &(elm)->field.pFqNext; \ + } while (0) + +#define FIFOQ_INSERT_AFTER(head, tqelm, elm, field) \ + do \ + { \ + if (((elm)->field.pFqNext = (tqelm)->field.pFqNext) == NULL)\ + (head)->spTQLast = &(elm)->field.pFqNext; \ + (tqelm)->field.pFqNext = (elm); \ + } while (0) + +#define FIFOQ_NEXT(elm, field) ((elm)->field.pFqNext) + +#define FIFOQ_REMOVE_HEAD(head, field) \ + do \ + { \ + if (((head)->pFqFirst = (head)->pFqFirst->field.pFqNext) == NULL) \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_REMOVE_HEAD_UNTIL(head, elm, field) \ + do \ + { \ + if (((head)->pFqFirst = (elm)->field.pFqNext) == NULL) \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_REMOVE(head, elm, type, field) \ + do \ + { \ + if ((head)->pFqFirst == (elm)) \ + { \ + FIFOQ_REMOVE_HEAD(head, field); \ + } \ + else \ + { \ + struct type *curelm = (head)->pFqFirst; \ + while( curelm->field.pFqNext != (elm) ) \ + curelm = curelm->field.pFqNext; \ + \ + if((curelm->field.pFqNext = \ + curelm->field.pFqNext->field.pFqNext) == NULL)\ + (head)->spTQLast = &(curelm)->field.pFqNext; \ + } \ + } while (0) + +// List + +#define LIST_HEAD(name, type) \ + struct name \ + { \ + struct type *pListFirst; /* first element */ \ + } + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ + struct \ + { \ + struct type *pListNext; /* next element */ \ + struct type **pListPrev; /* address of previous next element */ \ + } + +/* + * List functions. + */ + +#define LIST_EMPTY(head) ((head)->pListFirst == NULL) + +#define LIST_FIRST(head) ((head)->pListFirst) + +#define LIST_FOREACH(var, head, field) \ + for((var) = (head)->pListFirst; (var); (var) = (var)->field.pListNext) + +#define LIST_INIT(head) \ + do \ + { \ + (head)->pListFirst = NULL; \ + } while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) \ + do \ + { \ + if (((elm)->field.pListNext = (listelm)->field.pListNext) != NULL) \ + { \ + (listelm)->field.pListNext->field.pListPrev = \ + &(elm)->field.pListNext; \ + } \ + (listelm)->field.pListNext = (elm); \ + (elm)->field.pListPrev = &(listelm)->field.pListNext; \ + } while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) \ + do \ + { \ + (elm)->field.pListPrev = (listelm)->field.pListPrev; \ + (elm)->field.pListNext = (listelm); \ + *(listelm)->field.pListPrev = (elm); \ + (listelm)->field.pListPrev = &(elm)->field.pListNext; \ + } while (0) + +#define LIST_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pListNext = (head)->pListFirst) != NULL) \ + (head)->pListFirst->field.pListPrev = &(elm)->field.pListNext; \ + (head)->pListFirst = (elm); \ + (elm)->field.pListPrev = &(head)->pListFirst; \ + } while (0) + +#define LIST_NEXT(elm, field) ((elm)->field.pListNext) + +#define LIST_REMOVE(elm, field) \ + do \ + { \ + if ((elm)->field.pListNext != NULL) \ + (elm)->field.pListNext->field.pListPrev = \ + (elm)->field.pListPrev; \ + *(elm)->field.pListPrev = (elm)->field.pListNext; \ + } while (0) + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ + struct name \ + { \ + struct type *pTQFirst; /* first element */ \ + struct type **pTQLast; /* addr of last next element */ \ + } + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).pTQFirst } + +#define TAILQ_ENTRY(type) \ + struct \ + { \ + struct type *pTQNext; /* next element */ \ + struct type **pTQPrev; /* address of previous next element */ \ + } + +/* + * Tail queue functions. + */ +#define TAILQ_EMPTY(head) ((head)->pTQFirst == NULL) + +#define TAILQ_FOREACH(var, head, field) \ + for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FIRST(head) ((head)->pTQFirst) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->pTQLast))->pTQLast)) + +#define TAILQ_NEXT(elm, field) ((elm)->field.pTQNext) + +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.pTQPrev))->pTQLast)) + +#define TAILQ_INIT(head) \ + do \ + { \ + (head)->pTQFirst = NULL; \ + (head)->pTQLast = &(head)->pTQFirst; \ + } while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pTQNext = (head)->pTQFirst) != NULL) \ + (head)->pTQFirst->field.pTQPrev = \ + &(elm)->field.pTQNext; \ + else \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + (head)->pTQFirst = (elm); \ + (elm)->field.pTQPrev = &(head)->pTQFirst; \ + } while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) \ + do \ + { \ + (elm)->field.pTQNext = NULL; \ + (elm)->field.pTQPrev = (head)->pTQLast; \ + *(head)->pTQLast = (elm); \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + } while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \ + do \ + { \ + if (((elm)->field.pTQNext = (listelm)->field.pTQNext) != NULL) \ + (elm)->field.pTQNext->field.pTQPrev = &(elm)->field.pTQNext; \ + else \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + (listelm)->field.pTQNext = (elm); \ + (elm)->field.pTQPrev = &(listelm)->field.pTQNext; \ + } while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) \ + do { \ + (elm)->field.pTQPrev = (listelm)->field.pTQPrev; \ + (elm)->field.pTQNext = (listelm); \ + *(listelm)->field.pTQPrev = (elm); \ + (listelm)->field.pTQPrev = &(elm)->field.pTQNext; \ + } while (0) + +#define TAILQ_REMOVE(head, elm, field) \ + do { \ + if (((elm)->field.pTQNext) != NULL) \ + (elm)->field.pTQNext->field.pTQPrev = (elm)->field.pTQPrev; \ + else \ + (head)->pTQLast = (elm)->field.pTQPrev; \ + *(elm)->field.pTQPrev = (elm)->field.pTQNext; \ + } while (0) + +/* + * Pool -- Circular queue definitions. + */ +#define POOL_HEAD(name, type) \ + struct name \ + { \ + struct type *pPoolFirst; /* first element */ \ + struct type *pPoolLast; /* last element */ \ + } + +#define POOL_ENTRY(type) \ + struct \ + { \ + struct type *pPoolNext; /* next element */ \ + struct type *pPoolPrev; /* previous element */ \ + } + +/* + * Pool -- Circular queue functions. + */ + +#define POOL_EMPTY(head) ((head)->pPoolFirst == (void *)(head)) + +#define POOL_FIRST(head) ((head)->pPoolFirst) + +#define POOL_FOREACH(var, head, field) \ + for((var) = (head)->pPoolFirst; \ + (var) != (void *)(head); \ + (var) = (var)->field.pPoolNext) + +#define POOL_FOREACH_REVERSE(var, head, field) \ + for((var) = (head)->pPoolLast; \ + (var) != (void *)(head); \ + (var) = (var)->field.pPoolPrev) + +#define POOL_INIT(head) \ + do \ + { \ + (head)->pPoolFirst = (void *)(head); \ + (head)->pPoolLast = (void *)(head); \ + } while (0) + +#define POOL_INSERT_AFTER(head, listelm, elm, field) \ + do { \ + (elm)->field.pPoolNext = (listelm)->field.pPoolNext; \ + (elm)->field.pPoolPrev = (listelm); \ + if ((listelm)->field.pPoolNext == (void *)(head)) \ + (head)->pPoolLast = (elm); \ + else \ + (listelm)->field.pPoolNext->field.pPoolPrev = (elm); \ + (listelm)->field.pPoolNext = (elm); \ + } while (0) + +#define POOL_INSERT_BEFORE(head, listelm, elm, field) \ + do { \ + (elm)->field.pPoolNext = (listelm); \ + (elm)->field.pPoolPrev = (listelm)->field.pPoolPrev; \ + if ((listelm)->field.pPoolPrev == (void *)(head)) \ + (head)->pPoolFirst = (elm); \ + else \ + (listelm)->field.pPoolPrev->field.pPoolNext = (elm); \ + (listelm)->field.pPoolPrev = (elm); \ + } while (0) + +#define POOL_INSERT_HEAD(head, elm, field) \ + do { \ + (elm)->field.pPoolNext = (head)->pPoolFirst; \ + (elm)->field.pPoolPrev = (void *)(head); \ + if ((head)->pPoolLast == (void *)(head)) \ + (head)->pPoolLast = (elm); \ + else \ + (head)->pPoolFirst->field.pPoolPrev = (elm); \ + (head)->pPoolFirst = (elm); \ + } while (0) + +#define POOL_INSERT_TAIL(head, elm, field) \ + do { \ + (elm)->field.pPoolNext = (void *)(head); \ + (elm)->field.pPoolPrev = (head)->pPoolLast; \ + if ((head)->pPoolFirst == (void *)(head)) \ + (head)->pPoolFirst = (elm); \ + else \ + (head)->pPoolLast->field.pPoolNext = (elm); \ + (head)->pPoolLast = (elm); \ + } while (0) + +#define POOL_LAST(head) ((head)->pPoolLast) + +#define POOL_NEXT(elm,field) ((elm)->field.pPoolNext) + +#define POOL_PREV(elm,field) ((elm)->field.pPoolPrev) + +#define POOL_REMOVE(head, elm, field) \ + do { \ + if ((elm)->field.pPoolNext == (void *)(head)) \ + (head)->pPoolLast = (elm)->field.pPoolPrev; \ + else \ + (elm)->field.pPoolNext->field.pPoolPrev = (elm)->field.pPoolPrev; \ + \ + if ((elm)->field.pPoolPrev == (void *)(head)) \ + (head)->pPoolFirst = (elm)->field.pPoolNext; \ + else \ + (elm)->field.pPoolPrev->field.pPoolNext =(elm)->field.pPoolNext; \ + } while (0) + +#ifdef _KERNEL +/* + * XXX insque() and remque() are an old way of handling certain queues. + * They bogusly assumes that all queue heads look alike. + */ + +struct quehead +{ + struct quehead *qh_link; + struct quehead *qh_rlink; +}; + +#ifdef __GNUC__ + +static __inline void insque ( void *a, void *b ) +{ + struct quehead *element = a, *head = b; + + element->qh_link = head->qh_link; + element->qh_rlink = head; + head->qh_link = element; + element->qh_link->qh_rlink = element; +} + +static __inline void remque ( void *a ) +{ + struct quehead *element = a; + + element->qh_link->qh_rlink = element->qh_rlink; + element->qh_rlink->qh_link = element->qh_link; + element->qh_rlink = 0; +} + +#else /* !__GNUC__ */ + +void insque __P ( ( void *a, void *b ) ); +void remque __P ( ( void *a ) ); + +#endif /* __GNUC__ */ + +#endif /* _KERNEL */ +#endif diff --git a/omc/plat/public/src/include/pub_log.h b/omc/plat/public/src/include/pub_log.h new file mode 100644 index 0000000..c3d8cce --- /dev/null +++ b/omc/plat/public/src/include/pub_log.h @@ -0,0 +1,68 @@ +////////////////////////////////////////////////// +//Title : pub_log.h +//Auhtor : Liu Wei +//Desc : public log function header +//Created : 2007-05-21 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _PUB_LOG_H_ +#define _PUB_LOG_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_debug.h" +#include "pub_fmt.h" +#include + +#define RESET 0 +#define BRIGHT 1 +#define DIM 2 +#define UNDERLINE 3 +#define BLINK 4 +#define REVERSE 7 +#define HIDDEN 8 +#define BLACK 0 +#define RED 1 +#define GREEN 2 +#define YELLOW 3 +#define BLUE 4 +#define MAGENTA 5 +#define CYAN 6 +#define WHITE 7 + + +///////////////////////////////////////////////////////////////////////// +// Public print information +///////////////////////////////////////////////////////////////////////// + +#define PIF_INFO 0x01 // Normal Information +#define PIF_WARN 0x02 // Warnings +#define PIF_GERR 0x04 // General errors +#define PIF_CERR 0x10 // Critical errors +#define PIF_DBG 0x20 // Debugging +#define PIF_UNKN 0x40 // Things that are unknown + +// Default SIM output +#define PIF_DEFAULT (PIF_INFO|PIF_WARN|PIF_CERR) +// Everything, but DBG +#define PIF_ALL (PIF_INFO|PIF_WARN|PIF_GERR|PIF_CERR|PIF_UNKN) + +#define SYSERR strerror(errno) + +extern char *ByteBinToStr( char *pDst , const u8 *pSrc , int nByte ); +extern char *TxtColor ( int nAttr, int nFg, int nBg, char *pStr ); +extern int MsgToFmtLog ( const BYTE * pBcd, int nBcdLen, char *pStr, int nStrBuffSize ); + +#ifdef DEBUG +#define WxcDebugLog printf +#else +#define WxcDebugLog +#endif + +#endif diff --git a/omc/plat/public/src/include/pub_malloc.h b/omc/plat/public/src/include/pub_malloc.h new file mode 100644 index 0000000..67eb514 --- /dev/null +++ b/omc/plat/public/src/include/pub_malloc.h @@ -0,0 +1,26 @@ +////////////////////////////////////////////////// +//Title : pub_malloc.h +//Auhtor : Liu Wei +//Desc : Public heap memery management +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_MALLOC_H_ +#define _PUB_MALLOC_H_ + +#include "public.h" +#include "includes.h" +//#ifdef _USE_SYS_MALLOC_ + +#define WxcMalloc malloc +#define WxcFree free + +//#endif + +#endif + + diff --git a/omc/plat/public/src/include/pub_netcap.h b/omc/plat/public/src/include/pub_netcap.h new file mode 100644 index 0000000..ef2cc44 --- /dev/null +++ b/omc/plat/public/src/include/pub_netcap.h @@ -0,0 +1,35 @@ +////////////////////////////////////////////////// +//Title : pub_netcap.h +//Auhtor : Liu Wei +//Desc : public netcap header +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_NETCAP_H_ +#define _PUB_NETCAP_H_ + +#include "public.h" +#include "includes.h" + +typedef struct NET_CAPTURE +{ + u8 uState; + u32 nSock; + u32 nPort; + u32 nDstIp; +} +NetCap; + +int NcInit(); +int NcStart( u32 wIP , u32 wPort ); +int NcStop( ); +void NcSetPort( u32 port ); +void NcSetIP( u32 ip ); +void NcMtp3Send( u8 *pMtp3Msg , u32 wMtp3Len , u8 uAnsiFlag ); +int NcSccpSend( u8 *pSccpMsg , u32 wSccpLen , u8 *pIntraMsg , u8 uAnsiFlag ); + +#endif diff --git a/omc/plat/public/src/include/pub_sdp.h b/omc/plat/public/src/include/pub_sdp.h new file mode 100644 index 0000000..f238bfe --- /dev/null +++ b/omc/plat/public/src/include/pub_sdp.h @@ -0,0 +1,200 @@ +#ifndef _PUB_SDP__H +#define _PUB_SDP__H + +#define PUB_SDP_MAX_USER_NAME_LEN 64 +#define PUB_SDP_MAX_SESS_ID_LEN 32 +#define PUB_SDP_MAX_SESS_VER_LEN 16 +#define PUB_SDP_MAX_ADDR_LEN 64 +#define PUB_SDP_MAX_SESS_NAME_LEN 64 +#define PUB_SDP_MAX_SESS_INFO_LEN 64 +#define PUB_SDP_MAX_PAYLOAD_NUM 8 +#define PUB_SDP_MAX_MEDIA_NUM 2//8 +#define PUB_SDP_MAX_ATTR_NUM 16 +#define PUB_SDP_MAX_ATTR_LEN 32 + +#define PUB_SDP_FLAG_V 0x00000001 +#define PUB_SDP_FLAG_O 0x00000002 +#define PUB_SDP_FLAG_S 0x00000004 +#define PUB_SDP_FLAG_I 0x00000008 +#define PUB_SDP_FLAG_U 0x00000010 +#define PUB_SDP_FLAG_E 0x00000020 +#define PUB_SDP_FLAG_P 0x00000040 +#define PUB_SDP_FLAG_C 0x00000080 +#define PUB_SDP_FLAG_B 0x00000100 +#define PUB_SDP_FLAG_Z 0x00000200 +#define PUB_SDP_FLAG_K 0x00000400 +#define PUB_SDP_FLAG_A 0x00000800 +#define PUB_SDP_FLAG_T 0x00001000 +#define PUB_SDP_FLAG_R 0x00002000 +#define PUB_SDP_FLAG_M 0x00004000 + +#define PUB_MGCP_PARA_FLAG_TFO 0x00000800 + +#define PUB_SDP_STR_TO_API 1 +#define PUB_SDP_API_TO_STR 2 + +#define PUB_SDP_NET_TYPE_IN 1 + +#define PUB_SDP_ADDR_TYPE_IPV4 1 +#define PUB_SDP_ADDR_TYPE_IPV6 2 + +#define PUB_SDP_ATTR_TYPE_RTPMAP 1 +#define PUB_SDP_ATTR_TYPE_PTIME 2 +#define PUB_SDP_ATTR_TYPE_FMTP 3 +#define PUB_SDP_ATTR_TYPE_RECVONLY 4 +#define PUB_SDP_ATTR_TYPE_SENDONLY 5 +#define PUB_SDP_ATTR_TYPE_SENDRECV 6 +#define PUB_SDP_ATTR_TYPE_T38VER 7 +#define PUB_SDP_ATTR_TYPE_T38MBR 8 +#define PUB_SDP_ATTR_TYPE_IPBCP 9 + +#define PUB_SDP_MEDIA_TYPE_AUDIO 1 +#define PUB_SDP_MEDIA_TYPE_VIDEO 2 +#define PUB_SDP_MEDIA_TYPE_IMAGE 3 + +#define PUB_SDP_PROTO_TYPE_RTP_AVP 1 +#define PUB_SDP_PROTO_TYPE_IMAGE_UDPTL 2 + +typedef struct _PUB_SDP_V +{ + BYTE value; +}PUB_SDP_V; + +typedef struct _PUB_SDP_O +{ + char userName[PUB_SDP_MAX_USER_NAME_LEN]; + char sessId[PUB_SDP_MAX_SESS_ID_LEN]; + char sessVer[PUB_SDP_MAX_SESS_VER_LEN]; + BYTE netType; + BYTE addrType; + char addr[PUB_SDP_MAX_ADDR_LEN]; +}PUB_SDP_O; + +typedef struct _PUB_SDP_S +{ + char sessName[PUB_SDP_MAX_SESS_NAME_LEN]; +}PUB_SDP_S; + +typedef struct _PUB_SDP_I +{ + char info[PUB_SDP_MAX_SESS_INFO_LEN]; +}PUB_SDP_I; + +typedef struct _PUB_SDP_U +{ +}PUB_SDP_U; + +typedef struct _PUB_SDP_E +{ +}PUB_SDP_E; + +typedef struct _PUB_SDP_P +{ +}PUB_SDP_P; + +typedef struct _PUB_SDP_C +{ + BYTE netType; + BYTE addrType; + char addr[PUB_SDP_MAX_ADDR_LEN]; +}PUB_SDP_C; + +typedef struct _PUB_SDP_B +{ +}PUB_SDP_B; + +typedef struct _PUB_SDP_Z +{ +}PUB_SDP_Z; + +typedef struct _PUB_SDP_K +{ +}PUB_SDP_K; + +typedef struct _PUB_SDP_T +{ + DWORD startTime; + DWORD stopTime; +}PUB_SDP_T; + +typedef struct _PUB_SDP_R +{ +}PUB_SDP_R; + +typedef struct _PUB_SDP_M +{ + BYTE media; + WORD port; + BYTE portNum; + BYTE proto; + BYTE plNum; + BYTE payloads[PUB_SDP_MAX_PAYLOAD_NUM]; +}PUB_SDP_M; + +typedef struct _PUB_SDP_A +{ + BYTE aType; + char aValue[PUB_SDP_MAX_ATTR_LEN]; +}PUB_SDP_A; + +typedef struct _PUB_SDP_ATTRS +{ + BYTE num; + PUB_SDP_A attrs[PUB_SDP_MAX_ATTR_NUM]; +}PUB_SDP_ATTRS; + +typedef struct _PUB_SDP_MEDIA +{ + DWORD flag; + + PUB_SDP_M m; + PUB_SDP_I i; + PUB_SDP_C c; + PUB_SDP_B b; + PUB_SDP_K k; + PUB_SDP_ATTRS attrs; +}PUB_SDP_MEDIA; + +typedef struct _PUB_SDP_MEDIAS +{ + BYTE num; + PUB_SDP_MEDIA medias[PUB_SDP_MAX_MEDIA_NUM]; +}PUB_SDP_MEDIAS; + +typedef struct _PUB_SDP_MSG +{ + DWORD flag; + + PUB_SDP_V v; + PUB_SDP_O o; + PUB_SDP_S s; + PUB_SDP_I i; + PUB_SDP_U u; + PUB_SDP_E e; + PUB_SDP_P p; + PUB_SDP_C c; + PUB_SDP_B b; + PUB_SDP_Z z; + PUB_SDP_K k; + PUB_SDP_A a; + PUB_SDP_T t; + PUB_SDP_R r; + + PUB_SDP_MEDIAS medias; +}PUB_SDP_MSG; + +void pub_replace_all_lws(char *msg); +char *pub_strncpy(char *dest, const char *src, WORD length); +int pub_set_next_token(char *dest, char *buf, int endSeparator, char **next); + +int pub_sdp_msg_init(PUB_SDP_MSG *sdp); +int pub_sdp_parse(PUB_SDP_MSG *sdp, char *buf, char **nextMsg, DWORD flag); +int pub_sdp_encode(PUB_SDP_MSG *sdp, char *dest, WORD flag); + +int pub_sdp_net_type_conv(char *str, BYTE *netType, BYTE flag); +int pub_sdp_addr_type_conv(char *str, BYTE *addrType, BYTE flag); +int pub_sdp_attr_type_conv(char *str, BYTE *attrType, BYTE flag); +int pub_sdp_media_type_conv(char *str, BYTE *mediaType, BYTE flag); +int pub_sdp_proto_type_conv(char *str, BYTE *protoType, BYTE flag); + +#endif diff --git a/omc/plat/public/src/include/pub_str.h b/omc/plat/public/src/include/pub_str.h new file mode 100644 index 0000000..f6db853 --- /dev/null +++ b/omc/plat/public/src/include/pub_str.h @@ -0,0 +1,26 @@ +////////////////////////////////////////////////// +//Title : pub_str.h +//Auhtor : Liu Wei +//Desc : wxc2 string library +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_STR_H_ +#define _PUB_STR_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" + +#endif + + + + + + + diff --git a/omc/plat/public/src/include/pub_sys.h b/omc/plat/public/src/include/pub_sys.h new file mode 100644 index 0000000..aaeb2a3 --- /dev/null +++ b/omc/plat/public/src/include/pub_sys.h @@ -0,0 +1,53 @@ +////////////////////////////////////////////////// +//Title : pub_sys.c +//Auhtor : Liu Wei +//Desc : Public Linux system infomation +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_SYS_H_ +#define _PUB_SYS_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_time.h" +#include +#include +#include +#include +#include +#include +#include +//#include + +#define SIM_NONL 0x1000 // Don't add newline to output +#define SIM_NOLBL 0x2000 // Don't print "Public: Error:" + + +#define MHERTZ 1000000 // MegaHertz +#define BYTES ((u32)1) // Bytes +#define KBYTES ((u32)1024) // Kilo bytes +#define MBYTES ((u32)(1024*1024)) // Mega bytes +#define GBYTES ((u32)(1024*1024*1024)) // Giga bytes + +#define BytesToGBytes(N) ( (float) N / (float) GBYTES ) +#define BytesToMBytes(N) ( (float) N / (float) MBYTES ) +#define BytesToKBytes(N) ( (float) (N / (float) KBYTES) ) +#define MBytesToBytes(N) ( (float) ( (float) N * (float) MBYTES ) ) +#define KBytesToMbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) +#define KBytesToGbytes(N) ( (float) ( (float) N / (float) MBYTES ) ) +#define MbytesToGbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) + +#define EQ(a,b) (a && b && strcasecmp(a,b)==0) +#define EQN(a,b,n) (a && b && strncasecmp(a,b,n)==0) +#define eq(a,b) (a && b && strcmp(a,b)==0) +#define eqn(a,b,n) (a && b && strncmp(a,b,n)==0) +#define ARG(s) ((s) ? s : "") +#define PRTS(s) ( ( s && *s ) ? s : "" ) + +#endif diff --git a/omc/plat/public/src/include/pub_time.h b/omc/plat/public/src/include/pub_time.h new file mode 100644 index 0000000..5a144b4 --- /dev/null +++ b/omc/plat/public/src/include/pub_time.h @@ -0,0 +1,29 @@ +////////////////////////////////////////////////// +//Title : pub_time.h +//Auhtor : Liu Wei +//Desc : Linux time function +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +///////////////////////////////////////////////// + +#ifndef _PUB_TIME_H_ +#define _PUB_TIME_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_log.h" +#include + +/* pub_time.c */ +long GetTickCount(void); +int GetCurrentTime(u8 *pNowTime); +char *GetAsciiTime(void); +char *TimeToStr(time_t TimeVal, char *Format); +char *GetTimeHMS(char *pTimeBuf); + + +#endif diff --git a/omc/plat/public/src/include/pub_timer.h b/omc/plat/public/src/include/pub_timer.h new file mode 100644 index 0000000..b26a060 --- /dev/null +++ b/omc/plat/public/src/include/pub_timer.h @@ -0,0 +1,97 @@ +////////////////////////////////////////////////// +//Title : wxc_timer.h +//Auhtor : Liu Wei +//Desc : WXC2 Public Timer Managemnet +//Created : 2007-04-27 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_TIMER_H_ +#define _PUB_TIMER_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_malloc.h" + +/////////////////////////////////////////////////////////////////////////// + +typedef void ( *TimerCallBack ) ( u16 dSuitId, u16 dData ); + +#define TM_CLOCK_MAX (24*60*60*100) //one day based on wxc2 base timer 10ms + +typedef struct WXC_TIMER +{ + u32 dExpires; //dExpires : Timer expired number + u32 dSuitNumber; //dSuitNumber : Timer suit size of member + TimerCallBack pFunc; //pFunc : Timer call back function + u16 dData; //dData : Pointer for parameter of callback + void *pTimerNode; //pTimerNode : Reserved for timer Managemnet +} +WxcTimer; + +/////////////////////////////////////////////////////////////////////////// + +typedef struct WXC_TIMER_NODE +{ + u32 *dClockArray; //dClockArray : Timer set member clock array + WxcTimer *pTimer; + struct WXC_TIMER_NODE *pNext; + struct WXC_TIMER_NODE *pPrev; +} +WxcTimerNode; + +/////////////////////////////////////////////////////////////////////////// + +#define MAX_TM_MODE 512 + +#define TIMER_NODE_SIZE ( sizeof( WxcTimerNode ) + sizeof( WxcTimer ) ) + +#define CLOCK_SZIE ( sizeof ( u32 ) ) + +#define TMHEAP_MM_SIZE ( MAX_TM_MODE * TIMER_NODE_SIZE ) + +#define GET_TNODE_SIZE(n) ( TIMER_NODE_SIZE + ( n ) *( CLOCK_SZIE )) + +/////////////////////////////////////////////////////////////////////////// + +//by simon 23/9/25 +//extern u8 TMHeap[TMHEAP_MM_SIZE]; + +//extern WxcTimerNode tTimerListHead; +//extern WxcTimerNode *pTLHead; +//extern WxcTimerNode *pTLCur; + +/////////////////////////////////////////////////////////////////////////// + +#ifndef _LINUX_TIMER_H +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) + +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) +#endif + +/////////////////////////////////////////////////////////////////////////// + +#define TimerAfter(a,b) time_after(a,b) +#define TimerBefore(a,b) time_before(a,b) +#define TimerAfterEq(a,b) time_after_eq(a,b) +#define TimerBeforeEq(a,b) time_before_eq(a,b) + + +extern void TimerAdd ( WxcTimer * pTimer ); +extern void TimerMod ( WxcTimer * pTimer, u16 dExpires ); +extern void TimerDel ( WxcTimer * pTimer ); + + +inline void TimerStart ( WxcTimer * pTimer, u16 dSuitId ); +inline void TimerStop ( WxcTimer * pTimer, u16 dSuitId ); +inline void TM_Init ( ); + + + +#endif diff --git a/omc/plat/public/src/include/pub_wnet.h b/omc/plat/public/src/include/pub_wnet.h new file mode 100644 index 0000000..61dccce --- /dev/null +++ b/omc/plat/public/src/include/pub_wnet.h @@ -0,0 +1,41 @@ +////////////////////////////////////////////////// +//Title : pub_wnet.h +//Auhtor : Liu Wei +//Desc : wireless network publice function +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _WXC_WNET_H_ +#define _WXC_WNET_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_fmt.h" + +#define ISDN_LEN 9 +#define IMSI_LEN 8 + +/* ./src/pub_wnet.c */ +u8 GetBcdStr(char *str, u8 *bcd, u8 bcd_len); +void ImsiNtoA(u8 *pAntiImsi, u8 *pNormalImsi); +void ImsiAToN(u8 *pNormalImsi, u8 *pAntiImsi); +void ImsiNToS(u8 *pImsiStr, u8 *pNormalImsi); +void ImsiSToN(u8 *pNormalImsi, u8 *pImsiStr); +void IsdnNToA(u8 *pAntiIsdn, u8 *pNormalIsdn); +void IsdnAToN(u8 *pNormalIsdn, u8 *pAntiIsdn); +void IsdnNToS(u8 *pIsdnStr, u8 *pNormalIsdn); +u8 IsdnSToN(u8 *pNormalIsdn, u8 *pIsdnStr); +void GttToIsdn(u8 *pIsdn, u8 *pGtt); +u8 IsdnToGtai(u8 *pGtai, u8 *pIsdn); +void GtaiToIsdn(u8 *pIsdn, u8 *pGtai, u8 len); +u8 BcdToStrPE(char *str, u8 *bcd, u8 bcd_len); +void AddCcToIsdn(u8 *isdn_str, u8 *cc); +void AddNdcToIsdn(u8 *isdn_str, u8 *ndc); + +#endif diff --git a/omc/plat/public/src/include/public.h b/omc/plat/public/src/include/public.h new file mode 100644 index 0000000..8e933a3 --- /dev/null +++ b/omc/plat/public/src/include/public.h @@ -0,0 +1,102 @@ +/* +** PACS WLL 2000 project, Prepaid System. +** +** File name: public.h +** Written completely by Zhang Shuzhong at 2000-10-17 +** CVS $Id: public.h,v 1.4 2001/01/20 19:58:49 zhangsz Exp $ +** +** Public type definitions for PACS-WLL Project. +** +*/ + +#ifndef PUBLIC__H +#define PUBLIC__H + +#include +#include "memwatch.h" + +#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 + +#ifndef _T_ULL +#define _T_ULL +typedef unsigned long long ull; +#endif + +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#ifndef _T_U64 +#define _T_U64 +typedef unsigned long long u64; +#endif + +#ifndef _T_BOOL +#define _T_BOOL +typedef int BOOL; +#endif + +#ifndef SUCCESS +#define SUCCESS (0) +#endif + +#ifndef FAILURE +#define FAILURE (-1) +#endif + +#ifndef TRUE +#define TRUE (1) +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef YES +#define YES (1) +#endif + +#ifndef NO +#define NO (0) +#endif + +#ifndef ERROR +#define ERROR (-1) +#endif + +#ifndef EMPTY +#define EMPTY (0) +#endif + +#define BUFSIZE 8192 +#define MAXBUFLEN 8192 +#define MAXLINE 8192 + +//#define MAX(a, b) ((a) > (b) ? (a) : (b)) +//#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#endif /* PUBLIC__H */ diff --git a/omc/plat/public/src/include/svrstat.h b/omc/plat/public/src/include/svrstat.h new file mode 100644 index 0000000..f91f468 --- /dev/null +++ b/omc/plat/public/src/include/svrstat.h @@ -0,0 +1,100 @@ +/* +** PACS-WLL 2000 project, WAVEloop System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD Sep, 2001 +** +** file name: svrstat.h +** CVS $Id: $ +** +** The header file is defination about shared memory +** of server state information. +** +*/ + + +#ifndef SVRSTAT__H +#define SVRSTAT__H + +#define SVRSTAT_SHM_KEY 0x00010000 +#define SVRSTAT_SHM_PERM 0666 +#define SVRSTAT_SEM_KEY 0x00010000 +#define SVRSTAT_SEM_PERM 0666 +#define SVRSTAT_SEM_NUM 1 + +enum _server_state_enum { + SS_IDLE, + SS_INITIATE, + SS_NORMAL, + SS_SERVICE_SUSPEND, + SS_SERVICE_HALT, + SS_SHM_REINITIATE, + SS_SERVICE_RESTART, + SS_SYSTEM_RESTART, + SS_SYSTEM_HALT, +}; + +enum _oper_state_enum { + OS_NO_COMMAND, + OS_SET_COMMAND, + OS_GOT_COMMAND, + OS_FINISHED_COMMAND, + OS_REFUSED_COMMAND, +}; + +typedef struct { + u_char component_type; + u_char component_id; + u_char alarm_level; + u_char alarm_code; + DWORD timestamp; +} _alarm_log; + +typedef struct { + u_short read_sub; + u_short write_sub; + _alarm_log alarm_log[16]; +} _alarm_buffer; + +typedef struct { + u_char version[3]; + DWORD distrib_date; + u_char current_state; // Please view server's state enum. + // The server's current state. + u_char received_state; // State received from OMC. + // Please view server's state enum + // for detail. + u_char oper_state; /* 0: No command. + ** 1: Agent set command. + ** 2: Function server got the command. + ** 3: Function server finished. + ** 4: Function server refused. + ** refer to enum of _oper_state_enum + */ + u_char net_status; // 0/1=normal/abnormal, + // status of network + u_char rate_progress; // Rate of progress. + DWORD time_updated; + _alarm_buffer alarm_buffer; // Alarm code +} _server_state; + +typedef struct { + DWORD time_created; // Heartbeating module set the field + DWORD server_list; /* Bit0-15: + ** Server exist if set '1' in bit + ** Bit16-31: + ** 0/1 = Primary/Secondary server. + ** that base server object id. + */ + u_char led_state[16]; /* Led's state: + ** 0: Idle/Disable/Suspend/Halt + ** 1: Enable/Normal + ** 2: Initiating/Activated + */ + u_char port_stat[3]; + _server_state server_state[16]; /* Subscript of array + ** base on server object ID + */ +} _ss_buffer; + +#endif diff --git a/omc/plat/public/src/list.c b/omc/plat/public/src/list.c new file mode 100644 index 0000000..3fb436f --- /dev/null +++ b/omc/plat/public/src/list.c @@ -0,0 +1,166 @@ +#include +#include +#include + +#include "./include/list.h" +static listEntry_t *listEntry_create(void *data) { + listEntry_t *createdListEntry = malloc(sizeof(listEntry_t)); + if(createdListEntry == NULL) { + // TODO Malloc Failure + return NULL; + } + createdListEntry->data = data; + + return createdListEntry; +} + +void listEntry_free(listEntry_t *listEntry, void *additionalData) { + free(listEntry); +} + +void listEntry_printAsInt(listEntry_t *listEntry, void *additionalData) { + printf("%i\n", *((int *) (listEntry->data))); +} + +list_t *list_create() { + list_t *createdList = malloc(sizeof(list_t)); + if(createdList == NULL) { + // TODO Malloc Failure + return NULL; + } + createdList->firstEntry = NULL; + createdList->lastEntry = NULL; + createdList->count = 0; + + return createdList; +} + +void list_iterateThroughListForward(list_t *list, + void (*operationToPerform)( + listEntry_t *, + void *callbackFunctionUsedData), + void *additionalDataNeededForCallbackFunction) +{ + listEntry_t *currentListEntry = list->firstEntry; + listEntry_t *nextListEntry; + + if(currentListEntry == NULL) { + return; + } + + nextListEntry = currentListEntry->nextListEntry; + + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + + while(currentListEntry != NULL) { + nextListEntry = currentListEntry->nextListEntry; + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + } +} + +void list_iterateThroughListBackward(list_t *list, + void (*operationToPerform)( + listEntry_t *, + void *callbackFunctionUsedData), + void *additionalDataNeededForCallbackFunction) +{ + listEntry_t *currentListEntry = list->lastEntry; + listEntry_t *nextListEntry = currentListEntry->prevListEntry; + + if(currentListEntry == NULL) { + return; + } + + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + + while(currentListEntry != NULL) { + nextListEntry = currentListEntry->prevListEntry; + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + } +} + +void list_free(list_t *list) { + list_iterateThroughListForward(list, listEntry_free, NULL); + free(list); +} + +void list_addElement(list_t *list, void *dataToAddInList) { + listEntry_t *newListEntry = listEntry_create(dataToAddInList); + if(newListEntry == NULL) { + // TODO Malloc Failure + return; + } + if(list->firstEntry == NULL) { + list->firstEntry = newListEntry; + list->lastEntry = newListEntry; + + newListEntry->prevListEntry = NULL; + newListEntry->nextListEntry = NULL; + + list->count++; + + return; + } + + list->lastEntry->nextListEntry = newListEntry; + newListEntry->prevListEntry = list->lastEntry; + newListEntry->nextListEntry = NULL; + list->lastEntry = newListEntry; + + list->count++; +} + +void list_removeElement(list_t *list, listEntry_t *elementToRemove) { + listEntry_t *elementBeforeElementToRemove = + elementToRemove->prevListEntry; + listEntry_t *elementAfterElementToRemove = + elementToRemove->nextListEntry; + + if(elementBeforeElementToRemove != NULL) { + elementBeforeElementToRemove->nextListEntry = + elementAfterElementToRemove; + } else { + list->firstEntry = elementAfterElementToRemove; + } + + if(elementAfterElementToRemove != NULL) { + elementAfterElementToRemove->prevListEntry = + elementBeforeElementToRemove; + } else { + list->lastEntry = elementBeforeElementToRemove; + } + + listEntry_free(elementToRemove, NULL); + + list->count--; +} + +listEntry_t *list_getElementAt(list_t *list, long indexOfElement) { + listEntry_t *currentListEntry; + + if((list->count / 2) > indexOfElement) { + currentListEntry = list->firstEntry; + + for(int i = 0; i < indexOfElement; i++) { + currentListEntry = currentListEntry->nextListEntry; + } + + return currentListEntry; + } else { + currentListEntry = list->lastEntry; + + for(int i = 1; i < (list->count - indexOfElement); i++) { + currentListEntry = currentListEntry->prevListEntry; + } + + return currentListEntry; + } +} diff --git a/omc/plat/public/src/memwatch.c b/omc/plat/public/src/memwatch.c new file mode 100644 index 0000000..1716ca7 --- /dev/null +++ b/omc/plat/public/src/memwatch.c @@ -0,0 +1,2669 @@ +/* +** MEMWATCH.C +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2003 Johan Lindh +** All rights reserved. +** Version 2.71 + + This file is part of MEMWATCH. + + MEMWATCH 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 of the License, or + (at your option) any later version. + + MEMWATCH 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 MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +*/ + +/*@ignore@*/ + +#define __MEMWATCH_C 1 + +#ifdef MW_NOCPP +#define MEMWATCH_NOCPP +#endif +#ifdef MW_STDIO +#define MEMWATCH_STDIO +#endif + +/*********************************************************************** +** Include files +***********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "./include/memwatch.h" + +#ifndef toupper +#include +#endif + +#if defined(WIN32) || defined(__WIN32__) +#define MW_HAVE_MUTEX 1 +#include +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +#define MW_HAVE_MUTEX 1 +#include +#endif + +/*********************************************************************** +** Defines & other weird stuff +***********************************************************************/ + +/*lint -save -e767 */ +#define VERSION "2.71" /* the current version number */ +#define CHKVAL(mw) (0xFE0180L^(long)mw->count^(long)mw->size^(long)mw->line) +#define FLUSH() mwFlush() +#define TESTS(f,l) if(mwTestAlways) (void)mwTestNow(f,l,1) +#define PRECHK 0x01234567L +#define POSTCHK 0x76543210L +#define mwBUFFER_TO_MW(p) ( (mwData*) (void*) ( ((char*)p)-mwDataSize-mwOverflowZoneSize ) ) +/*lint -restore */ + +#define MW_NML 0x0001 + +#ifdef _MSC_VER +#define COMMIT "c" /* Microsoft C requires the 'c' to perform as desired */ +#else +#define COMMIT "" /* Normal ANSI */ +#endif /* _MSC_VER */ + +#ifdef __cplusplus +#define CPPTEXT "++" +#else +#define CPPTEXT "" +#endif /* __cplusplus */ + +#ifdef MEMWATCH_STDIO +#define mwSTDERR stderr +#else +#define mwSTDERR mwLog +#endif + +#ifdef MW_HAVE_MUTEX +#define MW_MUTEX_INIT() mwMutexInit() +#define MW_MUTEX_TERM() mwMutexTerm() +#define MW_MUTEX_LOCK() mwMutexLock() +#define MW_MUTEX_UNLOCK() mwMutexUnlock() +#else +#define MW_MUTEX_INIT() +#define MW_MUTEX_TERM() +#define MW_MUTEX_LOCK() +#define MW_MUTEX_UNLOCK() +#endif + +/*********************************************************************** +** If you really, really know what you're doing, +** you can predefine these things yourself. +***********************************************************************/ + +#ifndef mwBYTE_DEFINED +# if CHAR_BIT != 8 +# error need CHAR_BIT to be 8! +# else +typedef unsigned char mwBYTE; +# define mwBYTE_DEFINED 1 +# endif +#endif + +#if defined(ULONGLONG_MAX) || defined(ULLONG_MAX) || defined(_UI64_MAX) || defined(ULONG_LONG_MAX) +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +#else +# if UINT_MAX <= 0xFFFFUL +# define mw16BIT 1 +# define mwROUNDALLOC_DEFAULT 2 +# else +# if ULONG_MAX > 0xFFFFFFFFUL +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +# else +# define mw32BIT 1 +# define mwROUNDALLOC_DEFAULT 4 +# endif +# endif +#endif + +/* mwROUNDALLOC is the number of bytes to */ +/* round up to, to ensure that the end of */ +/* the buffer is suitable for storage of */ +/* any kind of object */ +#ifndef mwROUNDALLOC +# define mwROUNDALLOC mwROUNDALLOC_DEFAULT +#endif + +#ifndef mwDWORD_DEFINED +#if ULONG_MAX == 0xFFFFFFFFUL +typedef unsigned long mwDWORD; +#define mwDWORD_DEFINED "unsigned long" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if UINT_MAX == 0xFFFFFFFFUL +typedef unsigned int mwDWORD; +#define mwDWORD_DEFINED "unsigned int" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if USHRT_MAX == 0xFFFFFFFFUL +typedef unsigned short mwDWORD; +#define mwDWORD_DEFINED "unsigned short" +#endif +#endif + +#ifndef mwBYTE_DEFINED +#error "can't find out the correct type for a 8 bit scalar" +#endif + +#ifndef mwDWORD_DEFINED +#error "can't find out the correct type for a 32 bit scalar" +#endif + +/*********************************************************************** +** Typedefs & structures +***********************************************************************/ + +/* main data holding area, precedes actual allocation */ +typedef struct mwData_ mwData; +struct mwData_ { + mwData* prev; /* previous allocation in chain */ + mwData* next; /* next allocation in chain */ + const char* file; /* file name where allocated */ + long count; /* action count */ + long check; /* integrity check value */ +#if 0 + long crc; /* data crc value */ +#endif + size_t size; /* size of allocation */ + int line; /* line number where allocated */ + unsigned flag; /* flag word */ + }; + +/* statistics structure */ +typedef struct mwStat_ mwStat; +struct mwStat_ { + mwStat* next; /* next statistic buffer */ + const char* file; + long total; /* total bytes allocated */ + long num; /* total number of allocations */ + long max; /* max allocated at one time */ + long curr; /* current allocations */ + int line; + }; + +/* grabbing structure, 1K in size */ +typedef struct mwGrabData_ mwGrabData; +struct mwGrabData_ { + mwGrabData* next; + int type; + char blob[ 1024 - sizeof(mwGrabData*) - sizeof(int) ]; + }; + +typedef struct mwMarker_ mwMarker; +struct mwMarker_ { + void *host; + char *text; + mwMarker *next; + int level; + }; + +#if defined(WIN32) || defined(__WIN32__) +typedef HANDLE mwMutex; +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +typedef pthread_mutex_t mwMutex; +#endif + +/*********************************************************************** +** Static variables +***********************************************************************/ + +static int mwInited = 0; +static int mwInfoWritten = 0; +static int mwUseAtexit = 0; +static FILE* mwLog = NULL; +static int mwFlushing = 0; +static int mwStatLevel = MW_STAT_DEFAULT; +static int mwNML = MW_NML_DEFAULT; +static int mwFBI = 0; +static long mwAllocLimit = 0L; +static int mwUseLimit = 0; + +static long mwNumCurAlloc = 0L; +static mwData* mwHead = NULL; +static mwData* mwTail = NULL; +static int mwDataSize = 0; +static unsigned char mwOverflowZoneTemplate[] = "mEmwAtch"; +static int mwOverflowZoneSize = mwROUNDALLOC; + +static void (*mwOutFunction)(int) = NULL; +static int (*mwAriFunction)(const char*) = NULL; +static int mwAriAction = MW_ARI_ABORT; + +static char mwPrintBuf[MW_TRACE_BUFFER+8]; + +static unsigned long mwCounter = 0L; +static long mwErrors = 0L; + +static int mwTestFlags = 0; +static int mwTestAlways = 0; + +static FILE* mwLogB1 = NULL; +static int mwFlushingB1 = 0; + +static mwStat* mwStatList = NULL; +static long mwStatTotAlloc = 0L; +static long mwStatMaxAlloc = 0L; +static long mwStatNumAlloc = 0L; +static long mwStatCurAlloc = 0L; +static long mwNmlNumAlloc = 0L; +static long mwNmlCurAlloc = 0L; + +static mwGrabData* mwGrabList = NULL; +static long mwGrabSize = 0L; + +static void * mwLastFree[MW_FREE_LIST]; +static const char *mwLFfile[MW_FREE_LIST]; +static int mwLFline[MW_FREE_LIST]; +static int mwLFcur = 0; + +static mwMarker* mwFirstMark = NULL; + +static FILE* mwLogB2 = NULL; +static int mwFlushingB2 = 0; + +#ifdef MW_HAVE_MUTEX +static mwMutex mwGlobalMutex; +#endif + +/*********************************************************************** +** Static function declarations +***********************************************************************/ + +static void mwAutoInit( void ); +static FILE* mwLogR( void ); +static void mwLogW( FILE* ); +static int mwFlushR( void ); +static void mwFlushW( int ); +static void mwFlush( void ); +static void mwIncErr( void ); +static void mwUnlink( mwData*, const char* file, int line ); +static int mwRelink( mwData*, const char* file, int line ); +static int mwIsHeapOK( mwData *mw ); +static int mwIsOwned( mwData* mw, const char* file, int line ); +static int mwTestBuf( mwData* mw, const char* file, int line ); +static void mwDefaultOutFunc( int ); +static void mwWrite( const char* format, ... ); +static void mwLogFile( const char* name ); +static size_t mwFreeUp( size_t, int ); +static const void *mwTestMem( const void *, unsigned, int ); +static int mwStrCmpI( const char *s1, const char *s2 ); +static int mwTestNow( const char *file, int line, int always_invoked ); +static void mwDropAll( void ); +static const char *mwGrabType( int type ); +static unsigned mwGrab_( unsigned kb, int type, int silent ); +static unsigned mwDrop_( unsigned kb, int type, int silent ); +static int mwARI( const char* text ); +static void mwStatReport( void ); +static mwStat* mwStatGet( const char*, int, int ); +static void mwStatAlloc( size_t, const char*, int ); +static void mwStatFree( size_t, const char*, int ); +static int mwCheckOF( const void * p ); +static void mwWriteOF( void * p ); +static char mwDummy( char c ); +#ifdef MW_HAVE_MUTEX +static void mwMutexInit( void ); +static void mwMutexTerm( void ); +static void mwMutexLock( void ); +static void mwMutexUnlock( void ); +#endif + +/*********************************************************************** +** System functions +***********************************************************************/ + +void mwInit( void ) { + time_t tid; + + if( mwInited++ > 0 ) return; + + MW_MUTEX_INIT(); + + /* start a log if none is running */ + if( mwLogR() == NULL ) mwLogFile( "memwatch.log" ); + if( mwLogR() == NULL ) { + int i; + char buf[32]; + /* oops, could not open it! */ + /* probably because it's already open */ + /* so we try some other names */ + for( i=1; i<100; i++ ) { + sprintf( buf, "memwat%02d.log", i ); + mwLogFile( buf ); + if( mwLogR() != NULL ) break; + } + } + + /* initialize the statistics */ + mwStatList = NULL; + mwStatTotAlloc = 0L; + mwStatCurAlloc = 0L; + mwStatMaxAlloc = 0L; + mwStatNumAlloc = 0L; + mwNmlCurAlloc = 0L; + mwNmlNumAlloc = 0L; + + /* calculate the buffer size to use for a mwData */ + mwDataSize = sizeof(mwData); + while( mwDataSize % mwROUNDALLOC ) mwDataSize ++; + + /* write informational header if needed */ + if( !mwInfoWritten ) { + mwInfoWritten = 1; + (void) time( &tid ); + mwWrite( + "\n=============" + " MEMWATCH " VERSION " Copyright (C) 1992-1999 Johan Lindh " + "=============\n"); + mwWrite( "\nStarted at %s\n", ctime( &tid ) ); + +/**************************************************************** Generic */ + mwWrite( "Modes: " ); +#ifdef mwNew + mwWrite( "C++ " ); +#endif /* mwNew */ +#ifdef __STDC__ + mwWrite( "__STDC__ " ); +#endif /* __STDC__ */ +#ifdef mw16BIT + mwWrite( "16-bit " ); +#endif +#ifdef mw32BIT + mwWrite( "32-bit " ); +#endif +#ifdef mw64BIT + mwWrite( "64-bit " ); +#endif + mwWrite( "mwDWORD==(\" mwDWORD_DEFINED \")\n" ); + mwWrite( "mwROUNDALLOC==%d sizeof(mwData)==%d mwDataSize==%d\n", + mwROUNDALLOC, sizeof(mwData), mwDataSize ); +/**************************************************************** Generic */ + +/************************************************************ Microsoft C */ +#ifdef _MSC_VER + mwWrite( "Compiled using Microsoft C" CPPTEXT + " %d.%02d\n", _MSC_VER / 100, _MSC_VER % 100 ); +#endif /* _MSC_VER */ +/************************************************************ Microsoft C */ + +/************************************************************** Borland C */ +#ifdef __BORLANDC__ + mwWrite( "Compiled using Borland C" +#ifdef __cplusplus + "++ %d.%01d\n", __BCPLUSPLUS__/0x100, (__BCPLUSPLUS__%0x100)/0x10 ); +#else + " %d.%01d\n", __BORLANDC__/0x100, (__BORLANDC__%0x100)/0x10 ); +#endif /* __cplusplus */ +#endif /* __BORLANDC__ */ +/************************************************************** Borland C */ + +/************************************************************** Watcom C */ +#ifdef __WATCOMC__ + mwWrite( "Compiled using Watcom C %d.%02d ", + __WATCOMC__/100, __WATCOMC__%100 ); +#ifdef __FLAT__ + mwWrite( "(32-bit flat model)" ); +#endif /* __FLAT__ */ + mwWrite( "\n" ); +#endif /* __WATCOMC__ */ +/************************************************************** Watcom C */ + + mwWrite( "\n" ); + FLUSH(); + } + + if( mwUseAtexit ) (void) atexit( mwAbort ); + return; + } + +void mwAbort( void ) { + mwData *mw; + mwMarker *mrk; + char *data; + time_t tid; + int c, i, j; + int errors; + + tid = time( NULL ); + mwWrite( "\nStopped at %s\n", ctime( &tid) ); + + if( !mwInited ) + mwWrite( "internal: mwAbort(): MEMWATCH not initialized!\n" ); + + /* release the grab list */ + mwDropAll(); + + /* report mwMarked items */ + while( mwFirstMark ) { + mrk = mwFirstMark->next; + mwWrite( "mark: %p: %s\n", mwFirstMark->host, mwFirstMark->text ); + free( mwFirstMark->text ); + free( mwFirstMark ); + mwFirstMark = mrk; + mwErrors ++; + } + + /* release all still allocated memory */ + errors = 0; + while( mwHead != NULL && errors < 3 ) { + if( !mwIsOwned(mwHead, __FILE__, __LINE__ ) ) { + if( errors < 3 ) + { + errors ++; + mwWrite( "internal: NML/unfreed scan restarting\n" ); + FLUSH(); + mwHead = mwHead; + continue; + } + mwWrite( "internal: NML/unfreed scan aborted, heap too damaged\n" ); + FLUSH(); + break; + } + mwFlushW(0); + if( !(mwHead->flag & MW_NML) ) { + mwErrors++; + data = ((char*)mwHead)+mwDataSize; + mwWrite( "unfreed: <%ld> %s(%d), %ld bytes at %p ", + mwHead->count, mwHead->file, mwHead->line, (long)mwHead->size, data+mwOverflowZoneSize ); + if( mwCheckOF( data ) ) { + mwWrite( "[underflowed] "); + FLUSH(); + } + if( mwCheckOF( (data+mwOverflowZoneSize+mwHead->size) ) ) { + mwWrite( "[overflowed] "); + FLUSH(); + } + mwWrite( " \t{" ); + j = 16; if( mwHead->size < 16 ) j = (int) mwHead->size; + for( i=0;i<16;i++ ) { + if( i 126 ) c = '.'; + mwWrite( "%c", c ); + } + mwWrite( "}\n" ); + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + else { + data = ((char*)mwHead) + mwDataSize + mwOverflowZoneSize; + if( mwTestMem( data, mwHead->size, MW_VAL_NML ) ) { + mwErrors++; + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mwHead->count, data + mwOverflowZoneSize, mwHead->file, mwHead->line ); + FLUSH(); + } + mwNmlNumAlloc --; + mwNmlCurAlloc -= mwHead->size; + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + } + + if( mwNmlNumAlloc ) mwWrite("internal: NoMansLand block counter %ld, not zero\n", mwNmlNumAlloc ); + if( mwNmlCurAlloc ) mwWrite("internal: NoMansLand byte counter %ld, not zero\n", mwNmlCurAlloc ); + + /* report statistics */ + mwStatReport(); + FLUSH(); + + mwInited = 0; + mwHead = mwTail = NULL; + if( mwErrors ) + fprintf(mwSTDERR,"MEMWATCH detected %ld anomalies\n",mwErrors); + mwLogFile( NULL ); + mwErrors = 0; + + MW_MUTEX_TERM(); + + } + +void mwTerm( void ) { + if( mwInited == 1 ) + { + mwAbort(); + return; + } + if( !mwInited ) + mwWrite("internal: mwTerm(): MEMWATCH has not been started!\n"); + else + mwInited --; + } + +void mwStatistics( int level ) +{ + mwAutoInit(); + if( level<0 ) level=0; + if( mwStatLevel != level ) + { + mwWrite( "statistics: now collecting on a %s basis\n", + level<1?"global":(level<2?"module":"line") ); + mwStatLevel = level; + } +} + +void mwAutoCheck( int onoff ) { + mwAutoInit(); + mwTestAlways = onoff; + if( onoff ) mwTestFlags = MW_TEST_ALL; + } + +void mwSetOutFunc( void (*func)(int) ) { + mwAutoInit(); + mwOutFunction = func; + } + +static void mwWriteOF( void *p ) +{ + int i; + unsigned char *ptr; + ptr = (unsigned char*) p; + for( i=0; inext is not always set? +*/ +void * mwMark( void *p, const char *desc, const char *file, unsigned line ) { + mwMarker *mrk; + unsigned n, isnew; + char *buf; + int tot, oflow = 0; + char wherebuf[128]; + + mwAutoInit(); + TESTS(NULL,0); + + if( desc == NULL ) desc = "unknown"; + if( file == NULL ) file = "unknown"; + + tot = sprintf( wherebuf, "%.48s called from %s(%d)", desc, file, line ); + if( tot >= (int)sizeof(wherebuf) ) { wherebuf[sizeof(wherebuf)-1] = 0; oflow = 1; } + + if( p == NULL ) { + mwWrite("mark: %s(%d), no mark for NULL:'%s' may be set\n", file, line, desc ); + return p; + } + + if( mwFirstMark != NULL && !mwIsReadAddr( mwFirstMark, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mwFirstMark (%p) is trashed, can't mark for %s\n", + file, line, mwFirstMark, desc ); + return p; + } + + for( mrk=mwFirstMark; mrk; mrk=mrk->next ) + { + if( mrk->next != NULL && !mwIsReadAddr( mrk->next, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mark(%p)->next(%p) is trashed, can't mark for %s\n", + file, line, mrk, mrk->next, desc ); + return p; + } + if( mrk->host == p ) break; + } + + if( mrk == NULL ) { + isnew = 1; + mrk = (mwMarker*) malloc( sizeof( mwMarker ) ); + if( mrk == NULL ) { + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + mrk->next = NULL; + n = 0; + } + else { + isnew = 0; + n = strlen( mrk->text ); + } + + n += strlen( wherebuf ); + buf = (char*) malloc( n+3 ); + if( buf == NULL ) { + if( isnew ) free( mrk ); + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + + if( isnew ) { + memcpy( buf, wherebuf, n+1 ); + mrk->next = mwFirstMark; + mrk->host = p; + mrk->text = buf; + mrk->level = 1; + mwFirstMark = mrk; + } + else { + strcpy( buf, mrk->text ); + strcat( buf, ", " ); + strcat( buf, wherebuf ); + free( mrk->text ); + mrk->text = buf; + mrk->level ++; + } + + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + return p; + } + +void* mwUnmark( void *p, const char *file, unsigned line ) { + mwMarker *mrk, *prv; + mrk = mwFirstMark; + prv = NULL; + while( mrk ) { + if( mrk->host == p ) { + if( mrk->level < 2 ) { + if( prv ) prv->next = mrk->next; + else mwFirstMark = mrk->next; + free( mrk->text ); + free( mrk ); + return p; + } + mrk->level --; + return p; + } + prv = mrk; + mrk = mrk->next; + } + mwWrite("mark: %s(%d), no mark found for %p\n", file, line, p ); + return p; + } + + +/*********************************************************************** +** Abort/Retry/Ignore handlers +***********************************************************************/ + +static int mwARI( const char *estr ) { + char inbuf[81]; + int c; + fprintf(mwSTDERR, "\n%s\nMEMWATCH: Abort, Retry or Ignore? ", estr); + (void) fgets(inbuf,sizeof(inbuf),stdin); + for( c=0; inbuf[c] && inbuf[c] <= ' '; c++ ) ; + c = inbuf[c]; + if( c == 'R' || c == 'r' ) { + mwBreakOut( estr ); + return MW_ARI_RETRY; + } + if( c == 'I' || c == 'i' ) return MW_ARI_IGNORE; + return MW_ARI_ABORT; + } + +/* standard ARI handler (exported) */ +int mwAriHandler( const char *estr ) { + mwAutoInit(); + return mwARI( estr ); + } + +/* used to set the ARI function */ +void mwSetAriFunc( int (*func)(const char *) ) { + mwAutoInit(); + mwAriFunction = func; + } + +/*********************************************************************** +** Allocation handlers +***********************************************************************/ + +void* mwMalloc( size_t size, const char* file, int line) { + size_t needed; + mwData *mw; + char *ptr; + void *p; + + mwAutoInit(); + + MW_MUTEX_LOCK(); + + TESTS(file,line); + + mwCounter ++; + needed = mwDataSize + mwOverflowZoneSize*2 + size; + if( needed < size ) + { + /* theoretical case: req size + mw overhead exceeded size_t limits */ + return NULL; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc > mwAllocLimit) ) { + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (long)size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + mw = (mwData*) malloc( needed ); + if( mw == NULL ) { + if( mwFreeUp(needed,0) >= needed ) { + mw = (mwData*) malloc(needed); + if( mw == NULL ) { + mwWrite( "internal: mwFreeUp(%u) reported success, but malloc() fails\n", needed ); + mwIncErr(); + FLUSH(); + } + } + if( mw == NULL ) { + mwWrite( "fail: <%ld> %s(%d), %ld wanted %ld allocated\n", + mwCounter, file, line, (long)size, mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + mw->count = mwCounter; + mw->prev = NULL; + mw->next = mwHead; + mw->file = file; + mw->size = size; + mw->line = line; + mw->flag = 0; + mw->check = CHKVAL(mw); + + if( mwHead ) mwHead->prev = mw; + mwHead = mw; + if( mwTail == NULL ) mwTail = mw; + + ptr = ((char*)mw) + mwDataSize; + mwWriteOF( ptr ); /* '*(long*)ptr = PRECHK;' */ + ptr += mwOverflowZoneSize; + p = ptr; + memset( ptr, MW_VAL_NEW, size ); + ptr += size; + mwWriteOF( ptr ); /* '*(long*)ptr = POSTCHK;' */ + + mwNumCurAlloc ++; + mwStatCurAlloc += (long) size; + mwStatTotAlloc += (long) size; + if( mwStatCurAlloc > mwStatMaxAlloc ) + mwStatMaxAlloc = mwStatCurAlloc; + mwStatNumAlloc ++; + + if( mwStatLevel ) mwStatAlloc( size, file, line ); + + MW_MUTEX_UNLOCK(); + return p; + } + +void* mwRealloc( void *p, size_t size, const char* file, int line) { + int oldUseLimit, i; + mwData *mw; + char *ptr; + + mwAutoInit(); + + if( p == NULL ) return mwMalloc( size, file, line ); + if( size == 0 ) { mwFree( p, file, line ); return NULL; } + + MW_MUTEX_LOCK(); + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + if( mwIsOwned( mw, file, line ) ) { + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + mwIncErr(); + if( *((unsigned char*)(mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc - (long)mw->size > mwAllocLimit) ) { + TESTS(file,line); + mwCounter ++; + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (unsigned long)size - mw->size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + /* fake realloc operation */ + oldUseLimit = mwUseLimit; + mwUseLimit = 0; + ptr = (char*) mwMalloc( size, file, line ); + if( ptr != NULL ) { + if( size < mw->size ) + memcpy( ptr, p, size ); + else + memcpy( ptr, p, mw->size ); + mwFree( p, file, line ); + } + mwUseLimit = oldUseLimit; + MW_MUTEX_UNLOCK(); + return (void*) ptr; + } + + /* Unknown pointer! */ + + /* using free'd pointer? */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + /* some weird pointer */ + mwIncErr(); + mwWrite( "realloc: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + +char *mwStrdup( const char* str, const char* file, int line ) { + size_t len; + char *newstring; + + MW_MUTEX_LOCK(); + + if( str == NULL ) { + mwIncErr(); + mwWrite( "strdup: <%ld> %s(%d), strdup(NULL) called\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + len = strlen( str ) + 1; + newstring = (char*) mwMalloc( len, file, line ); + if( newstring != NULL ) memcpy( newstring, str, len ); + MW_MUTEX_UNLOCK(); + return newstring; + } + +void mwFree( void* p, const char* file, int line ) { + int i; + mwData* mw; + char buffer[ sizeof(mwData) + (mwROUNDALLOC*3) + 64 ]; + + /* this code is in support of C++ delete */ + if( file == NULL ) { + mwFree_( p ); + MW_MUTEX_UNLOCK(); + return; + } + + mwAutoInit(); + + MW_MUTEX_LOCK(); + TESTS(file,line); + mwCounter ++; + + /* on NULL free, write a warning and return */ + if( p == NULL ) { + mwWrite( "NULL free: <%ld> %s(%d), NULL pointer free'd\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + + if( mwIsOwned( mw, file, line ) ) { + (void) mwTestBuf( mw, file, line ); + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + if( *(((unsigned char*)mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* update the statistics */ + mwNumCurAlloc --; + mwStatCurAlloc -= (long) mw->size; + if( mwStatLevel ) mwStatFree( mw->size, mw->file, mw->line ); + + /* we should either free the allocation or keep it as NML */ + if( mwNML ) { + mw->flag |= MW_NML; + mwNmlNumAlloc ++; + mwNmlCurAlloc += (long) mw->size; + memset( ((char*)mw)+mwDataSize+mwOverflowZoneSize, MW_VAL_NML, mw->size ); + } + else { + /* unlink the allocation, and enter the post-free data */ + mwUnlink( mw, file, line ); + memset( mw, MW_VAL_DEL, + mw->size + mwDataSize+mwOverflowZoneSize+mwOverflowZoneSize ); + if( mwFBI ) { + memset( mw, '.', mwDataSize + mwOverflowZoneSize ); + sprintf( buffer, "FBI<%ld>%s(%d)", mwCounter, file, line ); + strncpy( (char*)(void*)mw, buffer, mwDataSize + mwOverflowZoneSize ); + } + free( mw ); + } + + /* add the pointer to the last-free track */ + mwLFfile[ mwLFcur ] = file; + mwLFline[ mwLFcur ] = line; + mwLastFree[ mwLFcur++ ] = p; + if( mwLFcur == MW_FREE_LIST ) mwLFcur = 0; + + MW_MUTEX_UNLOCK(); + return; + } + + /* check for double-freeing */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + } + + /* some weird pointer... block the free */ + mwIncErr(); + mwWrite( "WILD free: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + +void* mwCalloc( size_t a, size_t b, const char *file, int line ) { + void *p; + size_t size = a * b; + p = mwMalloc( size, file, line ); + if( p == NULL ) return NULL; + memset( p, 0, size ); + return p; + } + +void mwFree_( void *p ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + free(p); + } + +void* mwMalloc_( size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return malloc( size ); + } + +void* mwRealloc_( void *p, size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return realloc( p, size ); + } + +void* mwCalloc_( size_t a, size_t b ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return calloc( a, b ); + } + +void mwFlushNow( void ) { + if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwDoFlush( int onoff ) { + mwFlushW( onoff<1?0:onoff ); + if( onoff ) if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwLimit( long lim ) { + TESTS(NULL,0); + mwWrite("limit: old limit = "); + if( !mwAllocLimit ) mwWrite( "none" ); + else mwWrite( "%ld bytes", mwAllocLimit ); + mwWrite( ", new limit = "); + if( !lim ) { + mwWrite( "none\n" ); + mwUseLimit = 0; + } + else { + mwWrite( "%ld bytes\n", lim ); + mwUseLimit = 1; + } + mwAllocLimit = lim; + FLUSH(); + } + +void mwSetAriAction( int action ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + mwAriAction = action; + MW_MUTEX_UNLOCK(); + return; + } + +int mwAssert( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "assert trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: assert trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + switch( i ) { + case MW_ARI_IGNORE: + mwWrite( "assert trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + case MW_ARI_RETRY: + mwWrite( "assert trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "assert trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: assert trap: %s(%d), %s\n", fn, ln, exps ); + } + + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +int mwVerify( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "verify trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: verify trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + if( i == 0 ) { + mwWrite( "verify trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + if( i == 1 ) { + mwWrite( "verify trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "verify trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: verify trap: %s(%d), %s\n", fn, ln, exps ); + } + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +void mwTrace( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(NULL,0); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + + FLUSH(); + MW_MUTEX_UNLOCK(); + } + + +/*********************************************************************** +** Grab & Drop +***********************************************************************/ + +unsigned mwGrab( unsigned kb ) { + TESTS(NULL,0); + return mwGrab_( kb, MW_VAL_GRB, 0 ); + } + +unsigned mwDrop( unsigned kb ) { + TESTS(NULL,0); + return mwDrop_( kb, MW_VAL_GRB, 0 ); + } + +static void mwDropAll() { + TESTS(NULL,0); + (void) mwDrop_( 0, MW_VAL_GRB, 0 ); + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + if( mwGrabList != NULL ) + mwWrite( "internal: the grab list is not empty after mwDropAll()\n"); + } + +static const char *mwGrabType( int type ) { + switch( type ) { + case MW_VAL_GRB: + return "grabbed"; + case MW_VAL_NML: + return "no-mans-land"; + default: + /* do nothing */ + ; + } + return ""; + } + +static unsigned mwGrab_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd; + if( !kb ) i = kb = 65000U; + + for(;kb;kb--) { + if( mwUseLimit && + (mwStatCurAlloc + mwGrabSize + (long)sizeof(mwGrabData) > mwAllocLimit) ) { + if( !silent ) { + mwWrite("grabbed: all allowed memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + gd = (mwGrabData*) malloc( sizeof(mwGrabData) ); + if( gd == NULL ) { + if( !silent ) { + mwWrite("grabbed: all available memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + mwGrabSize += (long) sizeof(mwGrabData); + gd->next = mwGrabList; + memset( gd->blob, type, sizeof(gd->blob) ); + gd->type = type; + mwGrabList = gd; + } + if( !silent ) { + mwWrite("grabbed: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +static unsigned mwDrop_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd,*tmp,*pr; + const void *p; + + if( mwGrabList == NULL && kb == 0 ) return 0; + if( !kb ) i = kb = 60000U; + + pr = NULL; + gd = mwGrabList; + for(;kb;) { + if( gd == NULL ) { + if( i-kb > 0 && !silent ) { + mwWrite("dropped: all %s memory (%u kb)\n", mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + if( gd->type == type ) { + if( pr ) pr->next = gd->next; + kb --; + tmp = gd; + if( mwGrabList == gd ) mwGrabList = gd->next; + gd = gd->next; + p = mwTestMem( tmp->blob, sizeof( tmp->blob ), type ); + if( p != NULL ) { + mwWrite( "wild pointer: <%ld> %s memory hit at %p\n", + mwCounter, mwGrabType(type), p ); + FLUSH(); + } + mwGrabSize -= (long) sizeof(mwGrabData); + free( tmp ); + } + else { + pr = gd; + gd = gd->next; + } + } + if( !silent ) { + mwWrite("dropped: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +/*********************************************************************** +** No-Mans-Land +***********************************************************************/ + +void mwNoMansLand( int level ) { + mwAutoInit(); + TESTS(NULL,0); + switch( level ) { + case MW_NML_NONE: + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + break; + case MW_NML_FREE: + break; + case MW_NML_ALL: + (void) mwGrab_( 0, MW_VAL_NML, 0 ); + break; + default: + return; + } + mwNML = level; + } + +/*********************************************************************** +** Static functions +***********************************************************************/ + +static void mwAutoInit( void ) +{ + if( mwInited ) return; + mwUseAtexit = 1; + mwInit(); + return; +} + +static FILE *mwLogR() { + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) return mwLog; + if( mwLog == mwLogB1 ) mwLogB2 = mwLog; + if( mwLog == mwLogB2 ) mwLogB1 = mwLog; + if( mwLogB1 == mwLogB2 ) mwLog = mwLogB1; + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) { + mwWrite("internal: log file handle damaged and recovered\n"); + FLUSH(); + return mwLog; + } + fprintf(mwSTDERR,"\nMEMWATCH: log file handle destroyed, using mwSTDERR\n" ); + mwLog = mwLogB1 = mwLogB2 = mwSTDERR; + return mwSTDERR; + } + +static void mwLogW( FILE *p ) { + mwLog = mwLogB1 = mwLogB2 = p; + } + +static int mwFlushR() { + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) return mwFlushing; + if( mwFlushing == mwFlushingB1 ) mwFlushingB2 = mwFlushing; + if( mwFlushing == mwFlushingB2 ) mwFlushingB1 = mwFlushing; + if( mwFlushingB1 == mwFlushingB2 ) mwFlushing = mwFlushingB1; + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) { + mwWrite("internal: flushing flag damaged and recovered\n"); + FLUSH(); + return mwFlushing; + } + mwWrite("internal: flushing flag destroyed, so set to true\n"); + mwFlushing = mwFlushingB1 = mwFlushingB2 = 1; + return 1; + } + +static void mwFlushW( int n ) { + mwFlushing = mwFlushingB1 = mwFlushingB2 = n; + } + +static void mwIncErr() { + mwErrors++; + mwFlushW( mwFlushR()+1 ); + FLUSH(); + } + +static void mwFlush() { + if( mwLogR() == NULL ) return; +#ifdef MW_FLUSH + fflush( mwLogR() ); +#else + if( mwFlushR() ) fflush( mwLogR() ); +#endif + return; + } + +static void mwUnlink( mwData* mw, const char* file, int line ) { + if( mw->prev == NULL ) { + if( mwHead != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 NULL, but not head\n", + mwCounter, file, line, mw ); + mwHead = mw->next; + } + else { + if( mw->prev->next != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 failure\n", + mwCounter, file, line, mw ); + else mw->prev->next = mw->next; + } + if( mw->next == NULL ) { + if( mwTail != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 NULL, but not tail\n", + mwCounter, file, line, mw ); + mwTail = mw->prev; + } + else { + if( mw->next->prev != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 failure\n", + mwCounter, file, line, mw ); + else mw->next->prev = mw->prev; + } + } + +/* +** Relinking tries to repair a damaged mw block. +** Returns nonzero if it thinks it successfully +** repaired the heap chain. +*/ +static int mwRelink( mwData* mw, const char* file, int line ) { + int fails; + mwData *mw1, *mw2; + long count, size; + mwStat *ms; + + if( file == NULL ) file = "unknown"; + + if( mw == NULL ) { + mwWrite("relink: cannot repair MW at NULL\n"); + FLUSH(); + goto emergency; + } + + if( !mwIsSafeAddr(mw, mwDataSize) ) { + mwWrite("relink: MW-%p is a garbage pointer\n", mw); + FLUSH(); + goto emergency; + } + + mwWrite("relink: <%ld> %s(%d) attempting to repair MW-%p...\n", mwCounter, file, line, mw ); + FLUSH(); + fails = 0; + + /* Repair from head */ + if( mwHead != mw ) { + if( !mwIsSafeAddr( mwHead, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; head pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwHead; mw1; mw1=mw1->next ) { + if( mw1->next == mw ) { + mw->prev = mw1; + break; + } + if( mw1->next && + ( !mwIsSafeAddr(mw1->next, mwDataSize ) || mw1->next->prev != mw1) ) { + mwWrite("relink: failed for MW-%p; forward chain fragmented at MW-%p: 'next' is %p\n", mw, mw1, mw1->next ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in forward chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the head (first) allocation\n", mw ); + if( mw->prev != NULL ) + { + mwWrite( "relink: MW-%p prev pointer is non-NULL, you have a wild pointer\n", mw ); + mw->prev = NULL; + } + } + + /* Repair from tail */ + if( mwTail != mw ) { + if( !mwIsSafeAddr( mwTail, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; tail pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwTail; mw1; mw1=mw1->prev ) { + if( mw1->prev == mw ) { + mw->next = mw1; + break; + } + if( mw1->prev && (!mwIsSafeAddr(mw1->prev, mwDataSize ) || mw1->prev->next != mw1) ) { + mwWrite("relink: failed for MW-%p; reverse chain fragmented at MW-%p, 'prev' is %p\n", mw, mw1, mw1->prev ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in reverse chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the tail (last) allocation\n", mw ); + if( mw->next != NULL ) + { + mwWrite( "relink: MW-%p next pointer is non-NULL, you have a wild pointer\n", mw ); + mw->next = NULL; + } + } + + if( fails > 1 ) { + mwWrite("relink: heap appears intact, MW-%p probably garbage pointer\n", mw ); + FLUSH(); + goto verifyok; + } + + /* restore MW info where possible */ + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + mw->check = CHKVAL(mw); + goto verifyok; + + /* Emergency repair */ + emergency: + + if( mwHead == NULL && mwTail == NULL ) + { + if( mwStatCurAlloc == 0 ) + mwWrite("relink: <%ld> %s(%d) heap is empty, nothing to repair\n", mwCounter, file, line ); + else + mwWrite("relink: <%ld> %s(%d) heap damaged beyond repair\n", mwCounter, file, line ); + FLUSH(); + return 0; + } + + mwWrite("relink: <%ld> %s(%d) attempting emergency repairs...\n", mwCounter, file, line ); + FLUSH(); + + if( mwHead == NULL || mwTail == NULL ) + { + if( mwHead == NULL ) mwWrite("relink: mwHead is NULL, but mwTail is %p\n", mwTail ); + else mwWrite("relink: mwTail is NULL, but mwHead is %p\n", mwHead ); + } + + mw1=NULL; + if( mwHead != NULL ) + { + if( !mwIsReadAddr( mwHead, mwDataSize ) || mwHead->check != CHKVAL(mwHead) ) + { + mwWrite("relink: mwHead (MW-%p) is damaged, skipping forward scan\n", mwHead ); + mwHead = NULL; + goto scan_reverse; + } + if( mwHead->prev != NULL ) + { + mwWrite("relink: the mwHead pointer's 'prev' member is %p, not NULL\n", mwHead->prev ); + } + for( mw1=mwHead; mw1; mw1=mw1->next ) + { + if( mw1->next ) + { + if( !mwIsReadAddr(mw1->next,mwDataSize) || + !mw1->next->check != CHKVAL(mw1) || + mw1->next->prev != mw1 ) + { + mwWrite("relink: forward chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw1->file, mw1->line ); + if( mwIsReadAddr(mw1->next,mwDataSize ) ) + { + mwWrite("relink: forward chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1->next, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw1->file,16)?mw1->file:"", mw1->line ); + } + else + { + mwWrite("relink: the 'next' pointer of this MW points to %p, which is out-of-legal-access\n", + mw1->next ); + } + break; + } + } + } + } + + +scan_reverse: + mw2=NULL; + if( mwTail != NULL ) + { + if( !mwIsReadAddr(mwTail,mwDataSize) || mwTail->check != CHKVAL(mwTail) ) + { + mwWrite("relink: mwTail (%p) is damaged, skipping reverse scan\n", mwTail ); + mwTail = NULL; + goto analyze; + } + if( mwTail->next != NULL ) + { + mwWrite("relink: the mwTail pointer's 'next' member is %p, not NULL\n", mwTail->next ); + } + for( mw2=mwTail; mw2; mw2=mw2->prev ) + { + if( mw2->prev ) + { + if( !mwIsReadAddr(mw2->prev,mwDataSize) || + !mw2->prev->check != CHKVAL(mw2) || + mw2->prev->next != mw2 ) + { + mwWrite("relink: reverse chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw2->file, mw2->line ); + if( mwIsReadAddr(mw2->prev,mwDataSize ) ) + { + mwWrite("relink: reverse chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2->prev, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw2->file,16)?mw2->file:"", mw2->line ); + } + else + { + mwWrite("relink: the 'prev' pointer of this MW points to %p, which is out-of-legal-access\n", + mw2->prev ); + } + break; + } + } + } + } + +analyze: + if( mwHead == NULL && mwTail == NULL ) + { + mwWrite("relink: both head and tail pointers damaged, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + if( mwHead == NULL ) + { + mwHead = mw2; + mwWrite("relink: heap truncated, MW-%p designated as new mwHead\n", mw2 ); + mw2->prev = NULL; + mw1 = mw2 = NULL; + } + if( mwTail == NULL ) + { + mwTail = mw1; + mwWrite("relink: heap truncated, MW-%p designated as new mwTail\n", mw1 ); + mw1->next = NULL; + mw1 = mw2 = NULL; + } + if( mw1 == NULL && mw2 == NULL && + mwHead->prev == NULL && mwTail->next == NULL ) { + mwWrite("relink: verifying heap integrity...\n" ); + FLUSH(); + goto verifyok; + } + if( mw1 && mw2 && mw1 != mw2 ) { + mw1->next = mw2; + mw2->prev = mw1; + mwWrite("relink: emergency repairs successful, assessing damage...\n"); + FLUSH(); + } + else { + mwWrite("relink: heap totally destroyed, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + + /* Verify by checking that the number of active allocations */ + /* match the number of entries in the chain */ +verifyok: + if( !mwIsHeapOK( NULL ) ) { + mwWrite("relink: heap verification FAILS - aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + for( size=count=0, mw1=mwHead; mw1; mw1=mw1->next ) { + count ++; + size += (long) mw1->size; + } + if( count == mwNumCurAlloc ) { + mwWrite("relink: successful, "); + if( size == mwStatCurAlloc ) { + mwWrite("no allocations lost\n"); + } + else { + if( mw != NULL ) { + mwWrite("size information lost for MW-%p\n", mw); + mw->size = 0; + } + } + } + else { + mwWrite("relink: partial, %ld MW-blocks of %ld bytes lost\n", + mwNmlNumAlloc+mwNumCurAlloc-count, mwNmlCurAlloc+mwStatCurAlloc-size ); + return 0; + } + + return 1; + } + +/* +** If mwData* is NULL: +** Returns 0 if heap chain is broken. +** Returns 1 if heap chain is intact. +** If mwData* is not NULL: +** Returns 0 if mwData* is missing or if chain is broken. +** Returns 1 if chain is intact and mwData* is found. +*/ +static int mwIsHeapOK( mwData *includes_mw ) { + int found = 0; + mwData *mw; + + for( mw = mwHead; mw; mw=mw->next ) { + if( includes_mw == mw ) found++; + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + if( mw->prev ) { + if( !mwIsSafeAddr( mw->prev, mwDataSize ) ) return 0; + if( mw==mwHead || mw->prev->next != mw ) return 0; + } + if( mw->next ) { + if( !mwIsSafeAddr( mw->next, mwDataSize ) ) return 0; + if( mw==mwTail || mw->next->prev != mw ) return 0; + } + else if( mw!=mwTail ) return 0; + } + + if( includes_mw != NULL && !found ) return 0; + + return 1; + } + +static int mwIsOwned( mwData* mw, const char *file, int line ) { + int retv; + mwStat *ms; + + /* see if the address is legal according to OS */ + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + + /* make sure we have _anything_ allocated */ + if( mwHead == NULL && mwTail == NULL && mwStatCurAlloc == 0 ) + return 0; + + /* calculate checksum */ + if( mw->check != CHKVAL(mw) ) { + /* may be damaged checksum, see if block is in heap */ + if( mwIsHeapOK( mw ) ) { + /* damaged checksum, repair it */ + mwWrite( "internal: <%ld> %s(%d), checksum for MW-%p is incorrect\n", + mwCounter, file, line, mw ); + mwIncErr(); + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + else mw->file = ""; + mw->size = 0; + mw->check = CHKVAL(mw); + return 1; + } + /* no, it's just some garbage data */ + return 0; + } + + /* check that the non-NULL pointers are safe */ + if( mw->prev && !mwIsSafeAddr( mw->prev, mwDataSize ) ) mwRelink( mw, file, line ); + if( mw->next && !mwIsSafeAddr( mw->next, mwDataSize ) ) mwRelink( mw, file, line ); + + /* safe address, checksum OK, proceed with heap checks */ + + /* see if the block is in the heap */ + retv = 0; + if( mw->prev ) { if( mw->prev->next == mw ) retv ++; } + else { if( mwHead == mw ) retv++; } + if( mw->next ) { if( mw->next->prev == mw ) retv ++; } + else { if( mwTail == mw ) retv++; } + if( mw->check == CHKVAL(mw) ) retv ++; + if( retv > 2 ) return 1; + + /* block not in heap, check heap for corruption */ + + if( !mwIsHeapOK( mw ) ) { + if( mwRelink( mw, file, line ) ) + return 1; + } + + /* unable to repair */ + mwWrite( "internal: <%ld> %s(%d), mwIsOwned fails for MW-%p\n", + mwCounter, file, line, mw ); + mwIncErr(); + + return 0; + } + +/* +** mwTestBuf: +** Checks a buffers links and pre/postfixes. +** Writes errors found to the log. +** Returns zero if no errors found. +*/ +static int mwTestBuf( mwData* mw, const char* file, int line ) { + int retv = 0; + char *p; + + if( file == NULL ) file = "unknown"; + + if( !mwIsSafeAddr( mw, mwDataSize + mwOverflowZoneSize ) ) { + mwWrite( "internal: <%ld> %s(%d): pointer MW-%p is invalid\n", + mwCounter, file, line, mw ); + mwIncErr(); + return 2; + } + + if( mw->check != CHKVAL(mw) ) { + mwWrite( "internal: <%ld> %s(%d), info trashed; relinking\n", + mwCounter, file, line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) return 2; + } + + if( mw->prev && mw->prev->next != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link1 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + if( mw->next && mw->next->prev != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link2 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + + p = ((char*)mw) + mwDataSize; + if( mwCheckOF( p ) ) { + mwWrite( "underflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + p += mwOverflowZoneSize + mw->size; + if( mwIsReadAddr( p, mwOverflowZoneSize ) && mwCheckOF( p ) ) { + mwWrite( "overflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + + return retv; + } + +static void mwDefaultOutFunc( int c ) { + if( mwLogR() ) fputc( c, mwLogR() ); + } + +static void mwWrite( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + mwAutoInit(); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwWrite( "\ninternal: mwWrite(): WARNING! OUTPUT EXCEEDED %u CHARS: SYSTEM UNSTABLE\n", MW_TRACE_BUFFER-1 ); + FLUSH(); + } + return; + } + +static void mwLogFile( const char *name ) { + time_t tid; + (void) time( &tid ); + if( mwLogR() != NULL ) { + fclose( mwLogR() ); + mwLogW( NULL ); + } + if( name == NULL ) return; + mwLogW( fopen( name, "a" COMMIT ) ); + if( mwLogR() == NULL ) + mwWrite( "logfile: failed to open/create file '%s'\n", name ); + } + +/* +** Try to free NML memory until a contiguous allocation of +** 'needed' bytes can be satisfied. If this is not enough +** and the 'urgent' parameter is nonzero, grabbed memory is +** also freed. +*/ +static size_t mwFreeUp( size_t needed, int urgent ) { + void *p; + mwData *mw, *mw2; + char *data; + + /* free grabbed NML memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_NML, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + /* free normal NML memory */ + mw = mwHead; + while( mw != NULL ) { + if( !(mw->flag & MW_NML) ) mw = mw->next; + else { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + mw2 = mw->next; + mwUnlink( mw, "mwFreeUp", 0 ); + free( mw ); + mw = mw2; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + } + + /* if not urgent (for internal purposes), fail */ + if( !urgent ) return 0; + + /* free grabbed memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_GRB, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + return 0; + } + +static const void * mwTestMem( const void *p, unsigned len, int c ) { + const unsigned char *ptr; + ptr = (const unsigned char *) p; + while( len-- ) { + if( *ptr != (unsigned char)c ) return (const void*)ptr; + ptr ++; + } + return NULL; + } + +static int mwStrCmpI( const char *s1, const char *s2 ) { + if( s1 == NULL || s2 == NULL ) return 0; + while( *s1 ) { + if( toupper(*s2) == toupper(*s1) ) { s1++; s2++; continue; } + return 1; + } + return 0; + } + +#define AIPH() if( always_invoked ) { mwWrite("autocheck: <%ld> %s(%d) ", mwCounter, file, line ); always_invoked = 0; } + +static int mwTestNow( const char *file, int line, int always_invoked ) { + int retv = 0; + mwData *mw; + char *data; + + if( file && !always_invoked ) + mwWrite("check: <%ld> %s(%d), checking %s%s%s\n", + mwCounter, file, line, + (mwTestFlags & MW_TEST_CHAIN) ? "chain ": "", + (mwTestFlags & MW_TEST_ALLOC) ? "alloc ": "", + (mwTestFlags & MW_TEST_NML) ? "nomansland ": "" + ); + + if( mwTestFlags & MW_TEST_CHAIN ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( !mwIsSafeAddr(mw, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw->prev ) { + if( !mwIsSafeAddr(mw->prev, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwHead || mw->prev->next != mw ) { + AIPH(); + mwWrite("check: heap chain broken, prev link incorrect\n"); + mwIncErr(); + retv ++; + } + } + if( mw->next ) { + if( !mwIsSafeAddr(mw->next, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwTail || mw->next->prev != mw ) { + AIPH(); + mwWrite("check: heap chain broken, next link incorrect\n"); + mwIncErr(); + retv ++; + } + } + else if( mw!=mwTail ) { + AIPH(); + mwWrite("check: heap chain broken, tail incorrect\n"); + mwIncErr(); + retv ++; + } + } + } + if( mwTestFlags & MW_TEST_ALLOC ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( mwTestBuf( mw, file, line ) ) retv ++; + } + } + if( mwTestFlags & MW_TEST_NML ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( (mw->flag & MW_NML) ) { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + } + } + } + + + if( file && !always_invoked && !retv ) + mwWrite("check: <%ld> %s(%d), complete; no errors\n", + mwCounter, file, line ); + return retv; + } + +/********************************************************************** +** Statistics +**********************************************************************/ + +static void mwStatReport() +{ + mwStat* ms, *ms2; + const char *modname; + int modnamelen; + + /* global statistics report */ + mwWrite( "\nMemory usage statistics (global):\n" ); + mwWrite( " N)umber of allocations made: %ld\n", mwStatNumAlloc ); + mwWrite( " L)argest memory usage : %ld\n", mwStatMaxAlloc ); + mwWrite( " T)otal of all alloc() calls: %ld\n", mwStatTotAlloc ); + mwWrite( " U)nfreed bytes totals : %ld\n", mwStatCurAlloc ); + FLUSH(); + + if( mwStatLevel < 1 ) return; + + /* on a per-module basis */ + mwWrite( "\nMemory usage statistics (detailed):\n"); + mwWrite( " Module/Line Number Largest Total Unfreed \n"); + for( ms=mwStatList; ms; ms=ms->next ) + { + if( ms->line == -1 ) + { + if( ms->file == NULL || !mwIsReadAddr(ms->file,22) ) modname = ""; + else modname = ms->file; + modnamelen = strlen(modname); + if( modnamelen > 42 ) + { + modname = modname + modnamelen - 42; + } + + mwWrite(" %-42s %-8ld %-8ld %-8ld %-8ld\n", + modname, ms->num, ms->max, ms->total, ms->curr ); + if( ms->file && mwStatLevel > 1 ) + { + for( ms2=mwStatList; ms2; ms2=ms2->next ) + { + if( ms2->line!=-1 && ms2->file!=NULL && !mwStrCmpI( ms2->file, ms->file ) ) + { + mwWrite( " %-8d %-8ld %-8ld %-8ld %-8ld\n", + ms2->line, ms2->num, ms2->max, ms2->total, ms2->curr ); + } + } + } + } + } +} + +static mwStat* mwStatGet( const char *file, int line, int makenew ) { + mwStat* ms; + + if( mwStatLevel < 2 ) line = -1; + + for( ms=mwStatList; ms!=NULL; ms=ms->next ) { + if( line != ms->line ) continue; + if( file==NULL ) { + if( ms->file == NULL ) break; + continue; + } + if( ms->file == NULL ) continue; + if( !strcmp( ms->file, file ) ) break; + } + + if( ms != NULL ) return ms; + + if( !makenew ) return NULL; + + ms = (mwStat*) malloc( sizeof(mwStat) ); + if( ms == NULL ) { + if( mwFreeUp( sizeof(mwStat), 0 ) < sizeof(mwStat) || + (ms=(mwStat*)malloc(sizeof(mwStat))) == NULL ) { + mwWrite("internal: memory low, statistics incomplete for '%s'\n", file ); + return NULL; + } + } + ms->file = file; + ms->line = line; + ms->total = 0L; + ms->max = 0L; + ms->num = 0L; + ms->curr = 0L; + ms->next = mwStatList; + mwStatList = ms; + return ms; + } + +static void mwStatAlloc( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + } + + } + +static void mwStatFree( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + } + } + +/*********************************************************************** +** Safe memory checkers +** +** Using ifdefs, implement the operating-system specific mechanism +** of identifying a piece of memory as legal to access with read +** and write priviliges. Default: return nonzero for non-NULL pointers. +***********************************************************************/ + +static char mwDummy( char c ) +{ + return c; +} + +#ifndef MW_SAFEADDR +#ifdef WIN32 +#define MW_SAFEADDR +#define WIN32_LEAN_AND_MEAN +#include +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) ) return 0; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + /* NOTE: For some reason, under Win95 the IsBad... */ + /* can return false for invalid pointers. */ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) || IsBadWritePtr(p,len) ) return 0; + return 1; +} +#endif /* WIN32 */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +#ifdef SIGSEGV +#define MW_SAFEADDR + +typedef void (*mwSignalHandlerPtr)( int ); +mwSignalHandlerPtr mwOldSIGSEGV = (mwSignalHandlerPtr) 0; +jmp_buf mwSIGSEGVjump; +static void mwSIGSEGV( int n ); + +static void mwSIGSEGV( int n ) +{ + n = n; + longjmp( mwSIGSEGVjump, 1 ); +} + +int mwIsReadAddr( const void *p, unsigned len ) +{ + const char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read all the bytes in the range */ + ptr = (const char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + if( *ptr == 0x7C ) (void) mwDummy( (char)0 ); + } while( (const void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read and write-back all the bytes in the range */ + ptr = (char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + *ptr = mwDummy( *ptr ); + } while( (void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +#endif /* SIGSEGV */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +#endif + +/********************************************************************** +** Mutex handling +**********************************************************************/ + +#if defined(WIN32) || defined(__WIN32__) + +static void mwMutexInit( void ) +{ + mwGlobalMutex = CreateMutex( NULL, FALSE, NULL); + return; +} + +static void mwMutexTerm( void ) +{ + CloseHandle( mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + if( WaitForSingleObject(mwGlobalMutex, 1000 ) == WAIT_TIMEOUT ) + { + mwWrite( "mwMutexLock: timed out, possible deadlock\n" ); + } + return; +} + +static void mwMutexUnlock( void ) +{ + ReleaseMutex( mwGlobalMutex ); + return; +} + +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) + +static void mwMutexInit( void ) +{ + pthread_mutex_init( &mwGlobalMutex, NULL ); + return; +} + +static void mwMutexTerm( void ) +{ + pthread_mutex_destroy( &mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + pthread_mutex_lock(&mwGlobalMutex); + return; +} + +static void mwMutexUnlock( void ) +{ + pthread_mutex_unlock(&mwGlobalMutex); + return; +} + +#endif + +/********************************************************************** +** C++ new & delete +**********************************************************************/ + +#if 0 /* 980317: disabled C++ */ + +#ifdef __cplusplus +#ifndef MEMWATCH_NOCPP + +int mwNCur = 0; +const char *mwNFile = NULL; +int mwNLine = 0; + +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; + +MemWatch::MemWatch() { + if( mwInited ) return; + mwUseAtexit = 0; + mwInit(); + } + +MemWatch::~MemWatch() { + if( mwUseAtexit ) return; + mwTerm(); + } + +/* +** This global new will catch all 'new' calls where MEMWATCH is +** not active. +*/ +void* operator new( unsigned size ) { + mwNCur = 0; + return mwMalloc( size, "", 0 ); + } + +/* +** This is the new operator that's called when a module uses mwNew. +*/ +void* operator new( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** This is the new operator that's called when a module uses mwNew[]. +** -- hjc 07/16/02 +*/ +void* operator new[] ( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** Since this delete operator will recieve ALL delete's +** even those from within libraries, we must accept +** delete's before we've been initialized. Nor can we +** reliably check for wild free's if the mwNCur variable +** is not set. +*/ +void operator delete( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +void operator delete[]( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +#endif /* MEMWATCH_NOCPP */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +/* MEMWATCH.C */ + +/*@end@*/ + diff --git a/omc/plat/public/src/pub_conf.c b/omc/plat/public/src/pub_conf.c new file mode 100644 index 0000000..bae8333 --- /dev/null +++ b/omc/plat/public/src/pub_conf.c @@ -0,0 +1,12 @@ +////////////////////////////////////////////////// +//Title : pub_conf.c +//Auhtor : Liu Wei +//Desc : public conf file handle inplementation +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + diff --git a/omc/plat/public/src/pub_debug.c b/omc/plat/public/src/pub_debug.c new file mode 100644 index 0000000..276ee20 --- /dev/null +++ b/omc/plat/public/src/pub_debug.c @@ -0,0 +1,52 @@ +////////////////////////////////////////////////// +//Title : wxc_debug.c +//Auhtor : Liu Wei +//Desc : wxc debug api implemetation +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_debug.h" + +/*@ignore@*/ + +void WxcDump( int nSigno ) +{ + char buf[1024]; + char cmd[1024]; + FILE *fh; + + snprintf ( buf, sizeof ( buf ), "/proc/%d/cmdline", getpid ( ) ); + fh = fopen ( buf, "r" ); + if ( fh == NULL ) + exit ( 0 ); + if ( NULL == (fgets ( buf, sizeof ( buf ), fh ) )) + exit ( 0 ); + fclose ( fh ); + if ( buf[strlen ( buf ) - 1] == '\n' ) + buf[strlen ( buf ) - 1] = '\0'; + snprintf ( cmd, sizeof ( cmd ), "gdb %s %d", buf, getpid ( ) ); + system ( cmd ); + + exit ( 0 ); +} + +void WxcBackTrace( ) +{ + int i; + void *array[25]; + int nSize = backtrace ( array, 25 ); + char **symbols = backtrace_symbols ( array, nSize ); + + for ( i = 0; i < nSize; i++ ) + { + printf ( "%s \n", symbols[i] ); + } + free ( symbols ); +} + +/*@end@*/ + diff --git a/omc/plat/public/src/pub_file.c b/omc/plat/public/src/pub_file.c new file mode 100644 index 0000000..c1b151c --- /dev/null +++ b/omc/plat/public/src/pub_file.c @@ -0,0 +1,44 @@ +////////////////////////////////////////////////// +//Title : wxc_file.c +//Auhtor : Liu Wei +//Desc : wxc file handle inplementation +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_file.h" + +/*@ignore@*/ + +/////////////////////////////////////////////////////////////////////////// +// GetOneLine: Read one line of a file +/////////////////////////////////////////////////////////////////////////// + +extern char *GetOneLine ( char *pFileName ) +{ + FILE *pFile; + static char sBuff[1024]; + char *pCh; + + pFile = fopen ( pFileName, "r" ); + if ( pFile != NULL ) + { + if ( fgets ( sBuff, sizeof ( sBuff ), pFile ) != NULL ) + { + if ( NULL != (pCh = strchr ( sBuff, '\n' )) ) + { + *pCh = CNULL; + } + return sBuff; + } + ( void ) fclose ( pFile ); + } + + return ( char * ) NULL; +} + + +/*@end@*/ diff --git a/omc/plat/public/src/pub_fmt.c b/omc/plat/public/src/pub_fmt.c new file mode 100644 index 0000000..8610271 --- /dev/null +++ b/omc/plat/public/src/pub_fmt.c @@ -0,0 +1,1264 @@ +////////////////////////////////////////////////// +//Title : pub_convert.c +//Auhtor : Liu Wei +//Desc : public format type convert inplementation +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// lCRD software network data type assumpsit +// +// Memery Low <<============[Little Endian]===========>> Memery High +// Type abbr. e.g. Remark +// const value CVal U32 dVal= 0x12345678 +// Host BCD HBcd/Bcd 0x78 0x56 0x34 0x12 +// Anti BCD ABcd 0x87 0x65 0x43 0x21 +// NetBCD NBcd 0x12 0x34 0x56 0x78 +// String Str 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 "12345678" +// U64 U64 0x4E 0x61 0xBC 0x00 0x00 0x00 0x00 0x00 12345678=0xBC614E +// Digit Dig 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 +// +//////////////////////////////////////////////////////////////////////////////// + +/** @defgroup format pub_fmt.c + ** @{ + **/ + +#include "./include/pub_fmt.h" + +/////////////////////////////////////////////////////////////////////////// +// For test +// +/////////////////////////////////////////////////////////////////////////// +/* +//define in pub_base.h +#define u8 unsigned char +#define u64 unsigned long long +#define CNULL '\0' + +#define BitSet(arg,posn) ((arg) | (1L << (posn))) +#define BitClr(arg,posn) ((arg) & ~(1L << (posn))) +#define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) +#define BitTst(arg,posn) (!(!((arg) & (1L << (posn))))) + +//define in pub_debug.h +#define WxcAssert +*/ + +/** + ** @note HexToCh : 0 - > '0' + ** + **/ +inline char HexToCh( u8 uHex ) +{ + return ( (uHex) + ( ((uHex) > 9)? 'A'-10 : '0') ); +} + +/** + ** @note ChToHex : '0' - > 0 + ** + **/ +inline u8 ChToHex( char ch) +{ + static char digits[] = "0123456789abcdef"; + u8 uRel = 0; + int s; + + for(s = 0; s < 16; ++s) + { + if( digits[s] == tolower(ch) ) + { + uRel = s; + return(uRel); + } + } + + return(uRel); +} + + +/** + ** @note ReverseByte : 0010 1010 =>> 0101 0100 + ** + **/ +inline u8 ReverseByte(u8 uByteIn ) +{ + u8 i ; + u8 uByteOut = 0; + + for( i = 0 ; i < 8 ; i ++ ) + { + if( BitTst( uByteIn , i ) ) + { + uByteOut = (u8) ( BitSet( uByteOut , 7-i ) ); + } + } + + return uByteOut; +} + +/** + ** @note ReverseBCD : 0x12 0x34 0x56 0x78 =>> 0x21 0x43 0x65 0x87 + ** + **/ +inline void ReverseBCD( u8 *pDst , const u8 *pSrc , int nBcdLen ) +{ + int i; + + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pDst[i] = (pSrc[i] >> 4) + (pSrc[i] << 4) ; + } +} + +/** + ** ReverseArray : 0x12 0x34 0x56 0x78 =>> 0x78 0x56 0x34 0x12 + ** + **/ +inline void ReverseArray( u8 *pDst , const u8 *pSrc , int nBcdLen ) +{ + int i; + + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pDst[i] = pSrc[nBcdLen-i-1]; + } +} + +/** + ** @note BcdToStr : 0x12 0x34 0x56 0x78 =>> "12345678" + ** + **/ +inline void BcdToStr( char *pStr , const u8 *pBcd , int nBcdLen ) +{ + int i , j ; + int nStrLen = nBcdLen * 2 + 1; + + memset( pStr , 0 , nStrLen ); + + j = 0; + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pStr[j++] = HexToCh(pBcd[i] >> 4 ); + pStr[j++] = HexToCh(pBcd[i] & 0x0F); + } + pStr[j] = CNULL; +} + +/** + ** @note BcdToU64 : 0x12 0x34 0x56 0x78 =>> 12345678 + ** + **/ +inline u64 BcdToU64( const u8 *pBcd , int nBcdLen ) +{ + u64 llResult = 0; + u64 llMulti = 1; + int i; + + for( i = nBcdLen*2 -1 ; i >= 0 ; i -- ) + { + u8 uByte = pBcd[i/2] >> (4*((i+1)%2)); + + llResult += ( uByte & 0x0F ) * llMulti; + llMulti *= 10; + } + + return llResult; +} + +/** + ** @note BcdToDig : 0x12 0x34 0x56 =>>0x01 0x02 0x03 0x04 0x05 0x06 + ** + **/ +inline int BcdToDig( u8 *pDig , int nDigBuffLen, u8 *pBcd , int nBcdLen ) +{ + int i , j ; + + i = j = 0; + if( nDigBuffLen < 2*nBcdLen ) + { + return 0; + } + for( i = 0 ; i > 4 ; + pDig[j++] = pBcd[i] & 0x0F; + } + return j; +} + +/** + ** @note StrToBcd : "123456" =>> 0x12 0x34 0x56 + ** + **/ +inline int StrToBcd( u8 *pBcd , char *pStr , int nBcdBuffLen ) +{ + int i , j , k; + int nLen = strlen(pStr); + + i = j = k = 0; + j = (nLen + nLen%2) /2; + if( nBcdBuffLen < j ) + { + return 0; + } + memset( pBcd , 0 , j); + for( i = 0 ; i 0x01 0x23 0x45 0x67 + ** + **/ +inline int U64ToBcd( u8 *pBcd ,u64 llInput , int nBcdBuffLen ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = 0; + int i; + + while( llDiv < llInput ) + { + nDigNum++; + llDiv *= 10; + } + llDiv = ( nDigNum % 2 ) ? llDiv : llDiv/10; + + nDigNum += nDigNum % 2; + nBcdLen = nDigNum/2; + if( nBcdBuffLen < nBcdLen ) + { + return 0; + } + memset(pBcd , 0 , nBcdLen ); + for(i = 0; i < nBcdLen; i++) + { + pBcd[i] |= (((llInput / llDiv) %10) << 4); + llDiv /= 10; + pBcd[i] |= ((llInput / llDiv) % 10) ; + llDiv /= 10; + } + + return nBcdLen; +} + +/** + ** @note DigToBcd : 0x01 0x02 0x03 x04 0x05 0x06 0x07 => 0x01 0x23 0x45 0x67 + ** + **/ +inline int DigToBcd( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = (nDigLen + nDigLen %2)/2; + int i , j; + + j=0; + if( nBcdLen > nBcdBuffLen ) + { + return 0; + } + memset( pBcd , 0 , nBcdLen ); + + for(i = 0; i < nBcdLen; i++) + { + if( nDigLen %2 && !i ) + { + pBcd[i] &= 0x0F; + } + else + { + pBcd[i] |= pDig[j++] <<4; + } + pBcd[i] |= pDig[j++] & 0x0F; + } + return nBcdLen; +} + +/** + ** @note DigToBcd : 0x08 0x06 0x07 x05 0x05 0x00 0x01 => 0x86 0x75 0x50 0x1E + ** + **/ +inline int DigToBcdE( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen , int nEnd ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = (nDigLen + nDigLen %2)/2; + int i , j; + + j=0; + WxcAssert( nEnd <= 0x0F ,"DigToBcdE end code > 0x0F" ); + if( nBcdLen > nBcdBuffLen ) + { + WxcAssert( 0 , "DigToBcdE buffer overflow!"); + return 0; + } + memset( pBcd , 0 , nBcdLen ); + + for(i = 0; i < nBcdLen; i++) + { + pBcd[i] |= pDig[j++] <<4; + if( nDigLen %2 && i == (nBcdLen-1) ) + { + pBcd[i] |= nEnd; + } + else + { + pBcd[i] |= pDig[j++] & 0x0F; + } + + } + return nBcdLen; +} + +void _______________un_fmt______________() +{ + +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer ascii code to bcd code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + char flag=0; + + if (ascii_buf == NULL) + { + for (i=0;i='a') + ch -= 'a' - 10; + else if (ch>='A') + ch -= 'A' - 10; + else + ch -= '0'; + if (flag) + { + if (i & 1) + *bcd_buf = ch << 4; + else + *(bcd_buf++) |= ch & 0x0f; + } + else + { + if (i & 1) + *(bcd_buf++) |= ch & 0x0f; + else + *bcd_buf = ch << 4; + } + } +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer bcd code to ascii code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len) +{ + int i; + char ch; + + if (bcd_buf == NULL) + { + for (i=0;i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} + +int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen ) +{ + int iBcd = 0, iStr = 0, len; + BYTE flag = 0; + char val[3]; + + len = strlen ( pStr ); + val[1] = val[2] = 0; + strcat ( pStr, "F" ); + len++; + do + { + if( !isxdigit ( pStr[iStr] ) ) + continue; + + val[flag] = pStr[iStr]; + if( flag ) + { + pBcd[iBcd++] = strtoul ( val, NULL, 16 ); + } + flag = flag ? 0 : 1; + } + while ( iBcd < maxLen && ++iStr < len ); + + memset ( pBcd + iBcd, 0xFF, maxLen - iBcd ); + return iBcd; +} + +int Bcd2Str ( char *pStr, const BYTE * pBcd, int len ) +{ + int i; + + for ( i = 0; i < len; i++ ) + sprintf ( pStr + 2 * i, "%02X", pBcd[i] ); + + pStr[2 * len] = 0; + return len; +} + +int DigitsLen ( BYTE * pDigits, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pDigits[i] & 0x0F ) > 0x0A ) + return 2 * i; + if( ( pDigits[i] & 0xF0 ) > 0xA0 ) + return 2 * i + 1; + } + return maxLen * 2; +} + +int BcdLen ( BYTE * pBcd, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xA0 ) + return 2 * i; + if( ( pBcd[i] & 0x0F ) > 0x0A ) + return 2 * i + 1; + } + return maxLen * 2; +} + +int Digits2Str ( char *pStr, BYTE * pDigits, int DigitsLen ) +{ + int i = 0; + char low = '0', high = '0'; + + for ( i = 0; i < DigitsLen; i++ ) + { + low = pDigits[i] & 0xF; + if( low < 0x0A ) + { + pStr[2 * i] = low + '0'; + } + else if( low < 0x0E ) + { + pStr[2 * i] = low + 'A' - 10; + } + else + { + pStr[2 * i] = 0; + break; + } + + high = ( pDigits[i] >> 4 ); + if( high < 0x0A ) + { + pStr[2 * i + 1] = high + '0'; + } + else if( high < 0x0E ) + { + pStr[2 * i + 1] = high + 'A' - 10; + } + else + { + pStr[2 * i + 1] = 0; + break; + } + } + pStr[2 * DigitsLen] = '\0'; + return 1; +} + +ull Digits2Ull ( BYTE * pDigits, int DigitsLen ) +{ + ull result = 0; + int i; + BYTE digit; + + if( DigitsLen > 9 ) + DigitsLen = 9; + + for ( i = 0; i < DigitsLen; i++ ) + { + digit = pDigits[i] & 0x0F; + if( digit > 9 ) + return result; + result = result * 10 + digit; + + digit = pDigits[i] >> 4; + if( digit > 9 ) + return result; + result = result * 10 + digit; + } + return result; +} + +//only called by VLR to change IMSI to digits +int Ull2Digits ( BYTE * pDigits, ull value, int DigitsLen ) +{ + char tempStr[64]; + + if((value < 100000000000000LL) && (DigitsLen < 16))//IMSI pad 15 digits + { + sprintf ( tempStr, "%015lld", value ); + } + else + { + sprintf ( tempStr, "%lld", value ); + } + return Str2Digits ( pDigits, tempStr, DigitsLen ); +} + +int Str2Digits ( BYTE * pDigits, char *pStr, int DigitsLen ) +{ + int i = 0, strLen = strlen ( pStr ), len = 0; + char valstr[3]; + + len = strLen / 2; + if( len * 2 < strLen ) + { + strcat ( pStr, "F" ); + len++; + } + if( len > DigitsLen ) + len = DigitsLen; + + valstr[2] = 0; + for ( i = 0; i < len; i++ ) + { + valstr[0] = pStr[2 * i + 1]; + valstr[1] = pStr[2 * i]; + pDigits[i] = strtol ( valstr, NULL, 16 ); + } + return len; +} + +int Ull2Digits_Ralign ( BYTE * pDigits, ull value, int DigitsLen ) //right align +{ + char tempStr[64]; + char printStr[64]; + + sprintf ( printStr, "%%0%dlld", DigitsLen ); + sprintf ( tempStr, printStr, value ); + return Str2Digits ( pDigits, tempStr, ( DigitsLen + 1 ) / 2 ); +} + +ull Bcd2Ull ( BYTE * pBcd, int BcdLen ) +{ + ull result = 0; + int i; + BYTE digit; + + if( BcdLen > 9 ) + BcdLen = 9; + for ( i = 0; i < BcdLen; i++ ) + { + digit = pBcd[i] >> 4; + if( digit > 9 ) + return result; + result = result * 10 + digit; + + digit = pBcd[i] & 0x0F; + if( digit > 9 ) + return result; + result = result * 10 + digit; + } + return result; +} + +int Ull2Bcd ( BYTE * pBcd, ull value, int BcdLen ) +{ + char tempStr[64]; + + sprintf ( tempStr, "%lld", value ); + return Str2Bcd ( pBcd, tempStr, BcdLen ); +} + +int Digits2Bcd ( BYTE * pBcd, BYTE * pDigits, int maxLen ) +//return length +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pDigits[i] & 0x0F ) > 0x0C ) + return i; + + pBcd[i] = ( pDigits[i] << 4 ) | ( pDigits[i] >> 4 ); + + if( ( pDigits[i] & 0xF0 ) > 0xC0 ) + return i + 1; + + } + return maxLen; +} + +int Bcd2Digits ( BYTE * pDigits, BYTE * pBcd, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xC0 ) + return i; + + pDigits[i] = ( pBcd[i] << 4 ) | ( pBcd[i] >> 4 ); + + if( ( pBcd[i] & 0x0F ) > 0x0C ) + return i + 1; + } + return maxLen; +} + +int Bcd2Digits_dLen ( BYTE * pDigits, BYTE * pBcd, int maxLen ) //return digits len +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xC0 ) + return i * 2; + + pDigits[i] = ( pBcd[i] << 4 ) | ( pBcd[i] >> 4 ); + + if( ( pBcd[i] & 0x0F ) > 0x0C ) + return i * 2 + 1; + } + return maxLen * 2; +} + +int Str2Oid ( DWORD * pOid, char *pStr, BYTE maxLen ) +{ + BYTE sub = 0; + short len, i; + char *pvar; + + len = strlen ( pStr ); + pvar = pStr; + for ( i = 0; i < len && sub < maxLen; i++ ) + { + if( pStr[i] == '.' ) + { + pStr[i] = '\0'; + if( strlen ( pvar ) == 0 ) + continue; + pOid[sub++] = atoi ( pvar ); + pvar = pStr + i + 1; + } + } + if( strlen ( pvar ) == 0 ) + return sub; + pOid[sub++] = atoi ( pvar ); + return sub; +} + +//string===> +int TrimLeft ( char *pStr ) +{ + int i = 0; + + while ( ( pStr[i] == ' ' || pStr[i] == '\t' ) && i < 16 ) + i++; + + strcpy ( pStr, pStr + i ); + return 1; +} + +int TrimRight ( char *pStr ) +{ + int len = strlen ( pStr ); + + if( len > 1024 ) + return 0; + + while ( pStr[len - 1] == ' ' || pStr[len - 1] == '\t' ) + { + pStr[len - 1] = 0; + len--; + } + return 1; +} + +int Array2Digits ( BYTE * pDigits, BYTE * pArray, int ArrayLen ) +{ + int i; + + pArray[ArrayLen] = 0xEE; + for ( i = 0; i < ( ArrayLen + 1 ) / 2; i++ ) + pDigits[i] = ( pArray[2 * i + 1] << 4 ) | ( pArray[2 * i] & 0x0F ); + + return i; +} + +ull Str2Ull ( char *pStr ) +{ + ull result, intHigh, intLow; + DWORD len; + char strHigh[16] = "\0", *strLow; + + len = strlen ( pStr ); + if( len > 18 ) + return 0xFFFFFFFFFFFFFFFFll; + if( len > 9 ) + { + strLow = pStr + ( len - 9 ); + intLow = strtoul ( strLow, NULL, 10 ); + + strncpy ( strHigh, pStr, len - 9 ); + intHigh = strtoul ( strHigh, NULL, 10 ); + result = intHigh * 1000000000 + intLow; + return result; + } + else + { + intLow = strtoul ( pStr, NULL, 10 ); + return intLow; + } +} + +int Digits2Array ( BYTE * pArray, BYTE * pDigits, int DigitsLen ) +{ + int i, len = 0; + + for ( i = 0; i < DigitsLen; i++ ) + { + pArray[len] = pDigits[i] & 0x0F; + if( pArray[len] > 13 ) + return len; + len++; + + pArray[len] = pDigits[i] >> 4; + if( pArray[len] > 13 ) + return len; + len++; + } + + return len; +} + +int Bcd2Array ( BYTE * pArray, BYTE * pBcd, int BcdLen ) +{ + int i, len = 0; + + for ( i = 0; i < BcdLen; i++ ) + { + pArray[len] = pBcd[i] >> 4; + if( pArray[len] > 13 ) + return len; + len++; + + pArray[len] = pBcd[i] & 0x0F; + if( pArray[len] > 13 ) + return len; + len++; + } + + return len; +} + +int Str2Array ( BYTE * pArray, char *str, int ArrayLen ) +{ + int i, len; + char mystr[2]; + + mystr[1] = '\0'; + len = strlen ( str ); + if( len > ArrayLen ) + len = ArrayLen; + + for ( i = 0; i < len; i++ ) + { + mystr[0] = str[i]; + if( !isxdigit ( mystr[0] ) ) + return i; + pArray[i] = ( BYTE ) strtol ( mystr, NULL, 16 ); + } + return len; +} + +BYTE EditDigits ( BYTE * digits_out, BYTE len_max, BYTE * digits_in, BYTE len_in, BYTE len_del, BYTE * digits_ins, BYTE len_ins, BYTE filler ) +{ + BYTE len = 0, tmpbuf[64], pos1 = 0, pos2 = 0; + + if( len_ins > len_max ) //invalid insert length + { + memcpy ( digits_out, digits_in, ( len_in + 1 ) / 2 ); + return len_in; + } + else if( len_ins > 0 ) + { + memcpy ( digits_out, digits_ins, ( len_ins + 1 ) / 2 ); + len += len_ins; + } + + if( len_del > len_in ) //invalid delete length + { + memcpy ( digits_out, digits_in, ( len_in + 1 ) / 2 ); + return len_in; + } + else if( len_del == len_in ) + { + return len; + } + + if( ( len & 0x01 ) == ( len_del & 0x01 ) ) + { + if( len & 0x01 ) //odd + { + len_del++; + len_ins++; + pos1 = ( len + 1 ) / 2; + pos2 = ( len_del + 1 ) / 2; + digits_out[pos1 - 1] = ( digits_out[pos1 - 1] & 0x0F ) | ( digits_in[pos2 - 1] & 0xF0 ); + memcpy ( &digits_out[pos1], &digits_in[pos2], ( len_in - len_del + 1 ) / 2 ); + } + else //even + { + pos1 = len / 2; + pos2 = len_del / 2; + memcpy ( &digits_out[pos1], &digits_in[pos2], ( len_in - len_del + 1 ) / 2 ); + } + + /* daniel added this on 2006-04-18 */ + if( ( len_in + len_ins - len_del ) & 0x01 ) //odd + { + pos1 = ( len_in + len_ins - len_del + 1 ) / 2 - 1; + digits_out[pos1] &= 0x0f; + digits_out[pos1] |= ( filler & 0xf0 ); + } + else + { //even + //will not fill the filler + } + return len_in + len_ins - len_del; + /* daniel added this on 2006-04-18 */ + + } + else + { + Digits2Array ( tmpbuf, digits_in, ( len_in + 1 ) / 2 ); + if( len & 0x01 ) + { + pos1 = ( len + 1 ) / 2; + digits_out[pos1 - 1] = ( digits_out[pos1 - 1] & 0x0F ) | ( tmpbuf[len_del] << 4 ); + len_del++; + len_ins++; + } + else + pos1 = len / 2; //victor 2004-10 + tmpbuf[len_in] = filler >> 4; + Array2Digits ( digits_out + pos1, tmpbuf + len_del, len_in - len_del + 1 ); + len = len_in + len_ins - len_del; + + return len_in + len_ins - len_del; + } +} + +BYTE DelDigits ( BYTE * in_digit, BYTE in_len, BYTE * out_digit, BYTE count, BYTE filler ) +{ + return EditDigits ( out_digit, 32, in_digit, in_len, count, NULL, 0, filler ); +} + +void DWORD2BYTE ( BYTE * pdword, BYTE * pbyte, int len ) +{ + int i; + DWORD *p1, *p2; + + for ( i = 0; i < len / 4; i++ ) + { + p1 = ( DWORD * ) ( pdword + 4 * i ); + p2 = ( DWORD * ) ( pbyte + 4 * i ); + *p2 = htonl ( *p1 ); + } +} + +/** + ** @note transfer u32 to byte format\n + ** 0x9872 to 00 00 98 72 + **/ +void u32tobyte(u8 *str,u32 data) +{ + str[0] = data >> 24; + str[1] = data >> 16; + str[2] = data >> 8; + str[3] = data; +} + +/** + ** @note transfer u16 to bcd string format + **/ +u8 u16tobcd(u8 *bcd_string,u16 data) +{ + u8 bcd_len=0; + u8 ii; + u8 flag = 0; + + if (data == 0) + { + bcd_string[0] = 0; + return 1; + } + for (ii = 0;ii < 2;ii ++) + { + bcd_string[bcd_len] = data >> ((1-ii) * 8); + if (bcd_string[bcd_len] != 0 || flag == 1) + { + bcd_len ++; + flag = 1; + } + } + return bcd_len; +} + +/** + ** @note transfer bcd string to u16 format + **/ +u16 bcdtou16(u8 *bcd_string,u8 bcd_len) +{ + u8 ii; + u16 data=0; + + if (bcd_len > 2) + return 0; + data = 0; + for (ii = 0;ii < bcd_len;ii ++) + data += bcd_string[ii] << ((bcd_len-ii-1) * 8); + return data; +} + +/** + ** @note transfer u32 to bcd string format\n + ** 0x9872 to 98 72 and return len=2 + **/ +u8 u32tobcd(u8 *bcd_string,u32 data) +{ + u8 ii; + u8 bcd_len = 0; + u8 temp_data; + + if (data == 0) + { + bcd_string[0] = 0; + return 1; + } + for (ii = 0;ii < 4;ii ++) + { + temp_data = data >> ((3-ii) * 8); +// if (temp_data != 0 || flag == 1) + { + bcd_string[bcd_len++] = temp_data; +// flag = 1; + } + } + return bcd_len; +} + +/** + ** @note transfer bcd string to u32 format + **/ +u32 bcdtou32(u8 *bcd_string,u8 bcd_len) +{ + u8 ii; + u32 data=0; + + if (bcd_len > 4) + return 0; + data = 0; + for (ii = 0;ii < bcd_len;ii ++) + data += bcd_string[ii] << ((bcd_len-ii-1) * 8); + return data; +} +/** @} **/ + + +/* Convert data from ASCII form to right-aligned compact BCD form. */ +void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + + if (len > 0) *bcd_buf = 0x00; + for (i=0; i='a') ch -= 'a' - 10; + else if (ch>='A') ch -= 'A' - 10; + else ch -= '0'; + if ((len - i) & 1) *(bcd_buf++) |= ch & 0x0f; + else *bcd_buf = ch << 4; + } +} + +int ValidateAsciiMSISDN(char *msisdn, int len) +{ + int i; + + if(len>16) return 0; + if(msisdn == NULL) return 0; + + for(i=0;i= 0 ; j --) + { + sprintf( tmpStr , "%d" , pSrc[i] >>j & 0x01); + strcat( pDst , tmpStr) ; + } + } +} + +int main() +{ + u8 aBcd1[] = { 0x12 , 0x34 , 0x56 , 0x78 }; + u8 aBcd2[] = { 0x01 , 0x23 , 0x45 , 0x67 }; + u8 aBcd1Cp[256]; + u8 aBcd2Cp[256]; + u8 aStr[256]; + char tmpStr1[] = "01234567899876543210"; + char tmpStr2[] = "123456789"; + u64 llTmp1 = 1234567890; + u64 llTmp2 = 123456789; + u8 aDig1[] = { 0x01 , 0x09 , 0x08 , 0x07 , 0x06 }; + u8 aDig2[] = { 0x01 , 0x09 , 0x08 , 0x07 }; + u8 uByte; + int nLen = 0; + + uByte = ReverseByte(aBcd1[1]); + ByteBinToStr( aBcd1Cp , &uByte , 1 ); + ByteBinToStr( aBcd2Cp , &aBcd1[1] , 1 ); + printf("ReverseByte : aBcd1[1] : 0x%x [%s], Result : 0x%x[%s]\n" + , aBcd1[1] , aBcd2Cp , uByte , aBcd1Cp ); + + uByte = ReverseByte(aBcd2[1]); + ByteBinToStr( aBcd1Cp , &uByte , 1 ); + ByteBinToStr( aBcd2Cp , &aBcd2[1], 1 ); + printf("ReverseByte : aBcd2[1] : 0x%x [%s], Result : 0x%x[%s]\n\n" + , aBcd2[1] , aBcd2Cp , uByte , aBcd1Cp ); + + MsgToFmtLog(aBcd1 , 4 , aStr , 256 ); + printf("ReverseBcd : aBcd1: %s " , aStr ); + ReverseBCD(aBcd1Cp, aBcd1 , 4); + MsgToFmtLog(aBcd1Cp , 4 , aStr , 256 ); + printf("Result : %s \n" , aStr ); + + MsgToFmtLog(aBcd2 , 4 , aStr , 256 ); + printf("ReverseBcd : aBcd2: %s " , aStr ); + ReverseBCD(aBcd2Cp, aBcd2 , 4); + MsgToFmtLog(aBcd2Cp , 4 , aStr , 256 ); + printf("Result : %s \n\n" , aStr ); + + + MsgToFmtLog(aBcd1 , 4 , aStr , 256 ); + printf("ReverseArray : aBcd1: %s " , aStr ); + ReverseArray(aBcd1Cp, aBcd1 , 4); + MsgToFmtLog(aBcd1Cp , 4 , aStr , 256 ); + printf("Result : %s \n" , aStr ); + + MsgToFmtLog(aBcd2 , 4 , aStr , 256 ); + printf("ReverseArray : aBcd2: %s " , aStr ); + ReverseArray(aBcd2Cp, aBcd2 , 4); + MsgToFmtLog(aBcd2Cp , 4 , aStr , 256 ); + printf("Result : %s \n\n" , aStr ); + + BcdToStr( aStr , aBcd1 , 4); + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf("BcdToStr : aBcd1 : %s result : %s\n", aBcd2Cp , aStr); + BcdToStr( aStr , aBcd2 , 4); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf("BcdToStr : aBcd2 : %s result : %s\n\n",aBcd2Cp , aStr); + + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf( "BcdToU64 aBcd1 : %s result: %lld \n" , aBcd2Cp , BcdToU64( aBcd1, 4 ) ); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf( "BcdToU64 aBcd2 : %s result: %lld \n\n" , aBcd2Cp ,BcdToU64( aBcd2, 4 ) ); + + nLen = BcdToDig( aBcd1Cp , 256 ,aBcd1 , 4 ); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf("BcdToDig :aBcd1 : %s result : %s\n" , aBcd2Cp, aStr ); + + nLen = BcdToDig( aBcd1Cp , 256 , aBcd2 ,sizeof(aBcd2)); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf("BcdToDig :aBcd2 : %s result : %s\n\n" , aBcd2Cp,aStr ); + + + nLen = StrToBcd( aBcd1Cp , tmpStr1 , 256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("StrToBcd :tmpStr1 : %s result : %s\n" ,tmpStr1 , aStr); + + nLen = StrToBcd( aBcd1Cp , tmpStr2 , 256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("StrToBcd :tmpStr2 : %s result : %s\n\n" ,tmpStr2 , aStr); + + nLen = U64ToBcd(aBcd1Cp ,llTmp1 ,256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("U64ToBcd :llTmp1 : %lld , result: %s \n" ,llTmp1, aStr ); + + nLen = U64ToBcd(aBcd1Cp ,llTmp2 ,256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("U64ToBcd :llTmp2 : %lld , result: %s \n\n" ,llTmp2, aStr ); + + nLen = DigToBcd(aBcd1Cp, 256 , aDig1 , sizeof(aDig1)); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aDig1 , sizeof(aDig1) , aBcd2Cp , 256 ); + printf("DigToBcd :aDig1 : %s result: %s \n" ,aBcd2Cp ,aStr ); + + nLen = DigToBcd(aBcd1Cp, 256, aDig2 , sizeof(aDig2) ); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aDig2 , sizeof(aDig2) , aBcd2Cp , 256 ); + printf("DigToBcd :aDig2 : %s result: %s \n" ,aBcd2Cp , aStr ); + + return 0; +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Test result +// +/////////////////////////////////////////////////////////////////////////// + +/* +ReverseByte : aBcd1[1] : 0x34 [00110100], Result : 0x2c[00101100] +ReverseByte : aBcd2[1] : 0x23 [00100011], Result : 0xc4[11000100] + +ReverseBcd : aBcd1: 12 34 56 78 + Result : 21 43 65 87 + +ReverseBcd : aBcd2: 01 23 45 67 + Result : 10 32 54 76 + + +ReverseArray : aBcd1: 12 34 56 78 + Result : 78 56 34 12 + +ReverseArray : aBcd2: 01 23 45 67 + Result : 67 45 23 01 + + +BcdToStr : aBcd1 : 12 34 56 78 + result : 12345678 +BcdToStr : aBcd2 : 01 23 45 67 + result : 01234567 + +BcdToU64 aBcd1 : 12 34 56 78 + result: 12345678 +BcdToU64 aBcd2 : 01 23 45 67 + result: 1234567 + +BcdToDig :aBcd1 : 12 34 56 78 + result : 01 02 03 04 05 06 07 08 + +BcdToDig :aBcd2 : 01 23 45 67 + result : 00 01 02 03 04 05 06 07 + + +StrToBcd :tmpStr1 : 01234567899876543210 result : 01 23 45 67 89 98 76 54 32 10 + +StrToBcd :tmpStr2 : 123456789 result : 01 23 45 67 89 + + +U64ToBcd :llTmp1 : 1234567890 , result: 12 34 56 78 90 + +U64ToBcd :llTmp2 : 123456789 , result: 01 23 45 67 89 + + +DigToBcd :aDig1 : 01 09 08 07 06 + result: 01 98 76 + +DigToBcd :aDig2 : 01 09 08 07 + result: 19 87 + +*/ diff --git a/omc/plat/public/src/pub_inet.c b/omc/plat/public/src/pub_inet.c new file mode 100644 index 0000000..8aba469 --- /dev/null +++ b/omc/plat/public/src/pub_inet.c @@ -0,0 +1,407 @@ +////////////////////////////////////////////////// +//Title : pub_inet.c +//Auhtor : Liu Wei +//Desc : public inet function implementation +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_inet.h" +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// +extern int GetNetIfInfo ( IfAddr * pIfAddr ) +{ + int fd; + struct ifreq buf[MAXINTERFACES]; + struct arpreq arp; + struct ifconf ifc; + + pIfAddr->uIfNum = 0; + + if ( ( fd = socket ( AF_INET, SOCK_DGRAM, 0 ) ) >= 0 ) + { + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = ( caddr_t ) buf; + if ( !ioctl ( fd, SIOCGIFCONF, ( char * ) &ifc ) ) + { + int i; + + pIfAddr->uIfNum = ifc.ifc_len / sizeof ( struct ifreq ); + pIfAddr->uIfNum = pIfAddr->uIfNum % MAXINTERFACES; + for ( i = 0; i < pIfAddr->uIfNum; i++ ) + { + ioctl ( fd, SIOCGIFFLAGS, ( char * ) &buf[i] ); + pIfAddr->tIfEntity[i].uIfState = buf[i].ifr_flags & IFF_UP; + if ( !( ioctl ( fd, SIOCGIFADDR, ( char * ) &buf[i] ) ) ) + { + pIfAddr->tIfEntity[i].dIfIP = ( ( struct sockaddr_in * ) + ( &buf[i].ifr_addr ) )-> + sin_addr.s_addr; + } + } + } + + } + close ( fd ); + return pIfAddr->uIfNum; +} + +static u32 wxc2_bind_ip=0xFFFFFFFF, wxc2_shm_shift; + +void ReadMCMSParam() +{ + char cnf_file[]="./conf/mcms_conf.txt"; + char info_str[256], *buf_ptr;; + FILE *fp=NULL; + + fp = fopen(cnf_file,"r"); + + wxc2_bind_ip = 0; + wxc2_shm_shift = 0; + + if(fp == NULL) + return; + + while (!feof(fp)) + { + info_str[0] = '\n'; + fgets(info_str,250,fp); + if (info_str[0] == '#' || info_str[0] == '\n') + continue; + buf_ptr = info_str; + + if(!strncasecmp(info_str,"bind ip=",8)) + { + + wxc2_bind_ip = inet_addr(&info_str[8]); + continue; + } + if(!strncasecmp(info_str,"shm key shift=",14)) + { + wxc2_shm_shift = atoi(&info_str[14]); + continue; + } + } + + fclose(fp); + +} + +u32 GetLocalIP( ) +{ + struct hostent *host; + struct in_addr *hostip_addr; + char name[100]; + + if(wxc2_bind_ip == 0xFFFFFFFF) + ReadMCMSParam(); + + if(wxc2_bind_ip == 0) + { + gethostname ( name, 24 ); + host = gethostbyname ( name ); + + hostip_addr = ( struct in_addr * ) ( *host->h_addr_list ); + return hostip_addr->s_addr; + } + return wxc2_bind_ip; +} + +u32 GetLocalIP1( ) +{ + if(wxc2_bind_ip == 0xFFFFFFFF) + ReadMCMSParam(); + + if(wxc2_bind_ip == 0) + { + return INADDR_ANY; + + } + return wxc2_bind_ip; +} + +u32 wxc2_get_shm_offset() +{ + if(wxc2_bind_ip == 0xFFFFFFFF) + ReadMCMSParam(); + return wxc2_shm_shift; +} +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// + +//校验和算法 +static u16 IcmpCheckSum ( u16 * addr, int len ) +{ + int nleft = len; + int sum = 0; + u16 *w = addr; + u16 answer = 0; + + //把ICMP报头二进制数据以2字节为单位累加起来 + while ( nleft > 1 ) + { + sum += *w++; + nleft -= 2; + } + + //若ICMP报头为奇数个字节,会剩下最后一字节。 + //把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加 + if ( nleft == 1 ) + { + *( unsigned char * ) ( &answer ) = *( unsigned char * ) w; + sum += answer; + } + + sum = ( sum >> 16 ) + ( sum & 0xffff ); + sum += ( sum >> 16 ); + answer = ~sum; + + return answer; +} + +//设置ICMP报头 +static int IcmpPacking ( IcmpSrv * pIS ) +{ + int i, packsize; + struct icmp *icmp; + struct timeval *tval; + + icmp = ( struct icmp * ) pIS->aSendBuff; + icmp->icmp_type = ICMP_ECHO; + icmp->icmp_code = 0; + icmp->icmp_cksum = 0; + icmp->icmp_seq = pIS->nPackNumSend; + icmp->icmp_id = pIS->tPid; + packsize = 8 + pIS->uDataLen; + + //记录发送时间 + tval = ( struct timeval * ) icmp->icmp_data; + gettimeofday ( tval, NULL ); + + icmp->icmp_cksum = IcmpCheckSum ( ( u16 * ) icmp, packsize ); + + return packsize; +} + +//剥去ICMP报头 +static int IcmpUnPack ( u8 * buf, int len, IcmpSrv * pIS ) +{ + int i, nIpHdrLen; + struct ip *pIP; + struct icmp *icmp; + struct timeval *tvSend; + struct timeval tvRecv; + double rtt; + + gettimeofday ( &tvRecv, NULL ); + pIP = ( struct ip * ) buf; + //求ip报头长度,即ip报头的长度标志乘4 + nIpHdrLen = pIP->ip_hl << 2; + + //越过ip报头,指向ICMP报头 + icmp = ( struct icmp * ) ( buf + nIpHdrLen ); + + //ICMP报头及ICMP数据报的总长度 + len -= nIpHdrLen; + + if ( len < 8 ) + //小于ICMP报头长度则不合理 + { + printf ( "ICMP packets's length is less than 8 " ); + return 0; + } + + //确保所接收的是我所发的的ICMP的回应 + if ( ( icmp->icmp_type == ICMP_ECHOREPLY ) + && ( icmp->icmp_id == pIS->tPid ) ) + { + tvSend = ( struct timeval * ) icmp->icmp_data; + + rtt = ( tvRecv.tv_sec * 1000 + tvRecv.tv_usec / 1000 ) - + ( tvSend->tv_sec * 1000 + tvSend->tv_usec / 1000 ); + + printf ( "%d byte from %s: icmp_seq=%u ttl=%d rtt=%.3f ms \n", len, + inet_ntoa ( pIS->tFromAddr.sin_addr ), icmp->icmp_seq, + pIP->ip_ttl, rtt ); + return 1; + } + return 0; +} + +static void IcmpStatis ( IcmpSrv * pIS ) +{ + int nSend, nRecv; + + nSend = pIS->nPackNumSend; + nRecv = pIS->nPackNumRecv; + + printf ( " --------------------PING statistics------------------- \n" ); + printf ( "%d packets transmitted, %d received , %%%d lost \n\n", nSend, + nRecv, ( nSend - nRecv ) / nSend * 100 ); + close ( pIS->wSockfd ); + pIS->uSrvState = 0; +} + +//发送三个ICMP报文 +static int IcmpSend ( IcmpSrv * pIS ) +{ + int nSize; + + if ( pIS->nPackNumSend < MAX_NO_PACKETS ) + { + pIS->nPackNumSend++; + nSize = IcmpPacking ( pIS ); + + //设置ICMP报头 + if ( sendto ( pIS->wSockfd, pIS->aSendBuff, nSize, 0, + ( struct sockaddr * ) &pIS->tToAddr, + sizeof ( pIS->tToAddr ) ) < 0 ) + { + perror ( "sendto error" ); + return 0; + } + printf ( "[IcmpSend] : Send icmp Pack %d \n", pIS->nPackNumSend ); + return 1; + } + return 0; +} + +//接收所有ICMP报文 +static void IcmpRecv ( IcmpSrv * pIS ) +{ + int n, fromlen; + extern int errno; + + fromlen = sizeof ( pIS->tFromAddr ); + while ( pIS->nPackNumRecv < pIS->nPackNumSend ) + { + if ( ( n = + recvfrom ( pIS->wSockfd, pIS->aRecvBuff, + sizeof ( pIS->aRecvBuff ), 0, + ( struct sockaddr * ) &pIS->tFromAddr, + &fromlen ) ) < 0 ) + + { + if ( errno == EINTR ) + continue; + perror ( "recvfrom error" ); + continue; + } + if ( IcmpUnPack ( pIS->aRecvBuff, n, pIS ) == -1 ) + continue; + pIS->nPackNumRecv++; + } +} + +extern int PingInit ( IcmpSrv * pIS, int nDataLen ) +{ + memset ( pIS, 0, sizeof ( IcmpSrv ) ); + pIS->uSrvState = 0; + + pIS->uDataLen = 56; + + if ( ( pIS->pProtoent = getprotobyname ( "icmp" ) ) == NULL ) + { + perror ( "getprotobyname" ); + exit ( 1 ); + } + + // 回收root权限,设置当前用户权限 + setuid ( getuid ( ) ); + + //获取main的进程id,用于设置ICMP的标志符 + pIS->tPid = getpid ( ); + +} + +extern int PingStart ( IcmpSrv * pIS, char *sIP, PingCallBack fCallBack ) +{ + int nSize; + struct hostent *pHost; + + //struct in_addr *pInAddr; + u32 nInetAddr; + + if ( pIS->uSrvState ) + { + return 0; + } + + pIS->fCallBack = fCallBack; + + //生成使用ICMP的原始套接字,这种套接字只有root才能生成 + if ( ( pIS->wSockfd = + socket ( AF_INET, SOCK_RAW, pIS->pProtoent->p_proto ) ) < 0 ) + { + perror ( "socket error" ); + exit ( 1 ); + } + + //扩大套接字接收缓冲区到50K这样做主要为了减小接收缓冲区溢出的 + //的可能性, 若无意中ping会引来大量应答 + setsockopt ( pIS->wSockfd, SOL_SOCKET, SO_RCVBUF, &nSize, + sizeof ( nSize ) ); + bzero ( &pIS->tToAddr, sizeof ( pIS->tToAddr ) ); + pIS->tToAddr.sin_family = AF_INET; + + //判断是主机名还是ip地址 + nInetAddr = inet_addr ( sIP ); + if ( nInetAddr == INADDR_NONE ) + { + if ( ( pHost = gethostbyname ( sIP ) ) == NULL ) //是主机名 + { + perror ( "gethostbyname error" ); + exit ( 1 ); + } + memcpy ( ( char * ) &pIS->tToAddr.sin_addr, pHost->h_addr, + pHost->h_length ); + } + else //是ip地址 + { + pIS->tToAddr.sin_addr.s_addr = nInetAddr; + //memcpy( (char *)&pIS->tToAddr,(char *)&nInetAddr,host->h_length); + } + printf ( "PING %s(%s): %d bytes data in ICMP packets. \n", sIP, + inet_ntoa ( pIS->tToAddr.sin_addr ), pIS->uDataLen ); + + pIS->uSrvState = 1; + pIS->uIcmpState = 1; + +} + +extern int PingTimer ( IcmpSrv * pIS ) +{ + if ( pIS->uSrvState ) + { + IcmpRecv ( pIS ); + switch ( pIS->uIcmpState ) + { + case 1: + case 2: + case 3: + IcmpSend ( pIS ); + pIS->uIcmpState++; + break; + default: + if ( pIS->nPackNumRecv >= 3 ) + { + IcmpStatis ( pIS ); + pIS->fCallBack ( 1 ); + } + if ( pIS->uIcmpState++ > 200 ) + { + IcmpStatis ( pIS ); + pIS->fCallBack ( 0 ); + } + break; + } + } +} +/*@end@*/ + diff --git a/omc/plat/public/src/pub_log.c b/omc/plat/public/src/pub_log.c new file mode 100644 index 0000000..73e6b99 --- /dev/null +++ b/omc/plat/public/src/pub_log.c @@ -0,0 +1,135 @@ +////////////////////////////////////////////////// +//Title : pub_log.c +//Auhtor : Liu Wei +//Desc : public output log implementation +//Created : 2007-05-21 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#include "./include/pub_log.h" + +void FLogMsg( u8 LogMask , const char *pFmt, ...) +{ + va_list ap; + + va_start(ap, pFmt); + switch( LogMask ) + { + case PIF_INFO: + break; + case PIF_WARN: + break; + case PIF_GERR: + break; + case PIF_CERR: + break; + case PIF_DBG: + break; + case PIF_UNKN: + break; + case PIF_DEFAULT: + break; + case PIF_ALL: + break; + default: + break; + } + printf(pFmt, ap); + va_end(ap); + return; +} + +char *ByteBinToStr( char *pDst , const u8 *pSrc , int nByte ) +{ + register int i , j , k = 0; + + for( i =0 ; i < nByte ; i++ ) + { + for( j = 7 ; j >= 0 ; j --) + { + pDst[k++] = (pSrc[i] >>j & 0x01) + '0'; + } + } + pDst[k++] = CNULL; + return pDst; +} + +inline char *TxtColor ( int nAttr, int nFg, int nBg, char *pStr ) +{ + register int nPos ; + int nLen = strlen(pStr); + char *p = strdup (pStr); + + nPos = 0; + pStr[nPos++] = 27; + pStr[nPos++] = '['; + pStr[nPos++] = nAttr + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 3 + '0'; + pStr[nPos++] = nFg + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 4 + '0'; + pStr[nPos++] = nBg + '0'; + pStr[nPos++] = 'm'; + strcpy( pStr + nPos , p); + nPos += nLen; + pStr[nPos++] = 27; + pStr[nPos++] = '['; + pStr[nPos++] = RESET + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 3 + '0'; + pStr[nPos++] = WHITE + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 4 + '0'; + pStr[nPos++] = BLACK + '0'; + pStr[nPos++] = 'm'; + pStr[nPos] = CNULL; + + free(p); + return pStr; +} + + + +inline int MsgToFmtLog ( const BYTE * pBcd, int nBcdLen, char *pStr, int nStrBuffSize ) +{ + register int i, len = 0; + int nChar; + + nChar = ( nBcdLen / 16 ) * 49; + if( (nBcdLen %16) > 8 ) + { + nChar+=8*3 +1; + + } + nChar += (nBcdLen %8)*3 +1 + 2 ; //add "\r\n" at end + + WxcAssert ( ( nChar < nStrBuffSize ), "sprint bcd string buffer flow" ); + + for ( i = 0; i <= nBcdLen-1; i++ ) + { + pStr[len++] = HexToCh(pBcd[i] >> 4 ); + pStr[len++] = HexToCh(pBcd[i] & 0x0F); + pStr[len++] = ' '; + if ( 0 == ( (i+1) % 16 ) && i) + { + pStr[len++] = '\n'; + } + else if ( 0 == ( (i+1) % 8 ) ) + { + pStr[len++] = ' '; + } + } + if ( 0 != ( len % 49 ) ) + { + pStr[len++] = ' '; + } + pStr[len++] = '\r'; + pStr[len++] = '\n'; + pStr[len++] = CNULL; + return len; +} diff --git a/omc/plat/public/src/pub_malloc.c b/omc/plat/public/src/pub_malloc.c new file mode 100644 index 0000000..735e3ec --- /dev/null +++ b/omc/plat/public/src/pub_malloc.c @@ -0,0 +1,23 @@ +////////////////////////////////////////////////// +//Title : wxc_malloc.c +//Auhtor : Liu Wei +//Desc : WXC2 Public heap memery management +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_malloc.h" +/* +void *WxcMalloc ( ) +{ + return (void*)NULL; +} + +void WxcFree ( ) +{ + +} +*/ diff --git a/omc/plat/public/src/pub_netcap.c b/omc/plat/public/src/pub_netcap.c new file mode 100644 index 0000000..36b1d1b --- /dev/null +++ b/omc/plat/public/src/pub_netcap.c @@ -0,0 +1,370 @@ +////////////////////////////////////////////////// +//Title : wxc_netcap.c +//Auhtor : Liu Wei +//Desc : wxc2 netcap implementation +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_netcap.h" + +/*@ignore@*/ +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif + +static NetCap tNC; + +#define BASE 65521 + +static u32 NcAd32 ( u32 ad, u8 * buf, int len ) +{ + u32 s1 = ad & 0xffff; + u32 s2 = ( ad >> 16 ) & 0xffff; + int n; + + for ( n = 0; n < len; n++, buf++ ) + { + s1 = ( s1 + *buf ); + + if ( s1 >= BASE ) + s1 -= BASE; + + s2 = ( s2 + s1 ); + + if ( s2 >= BASE ) + { + + s2 -= BASE; + } + } + return ( s2 << 16 ) + s1; +} + +#define HEADER_LEN 12 + +static u32 NcCS ( u8 * ptr, u16 count ) +{ + + u32 ad = 1L; + u32 zero = 0L; + + ad = NcAd32 ( ad, ptr, sizeof ( HEADER_LEN - sizeof ( u32 ) ) ); + ad = NcAd32 ( ad, ( u8 * ) & zero, sizeof ( u32 ) ); + ptr += HEADER_LEN; + count -= HEADER_LEN; + + ad = NcAd32 ( ad, ptr, count ); + return ad; +} + +static int NcGetSocket ( u32 port ) +{ + int nSock; + int nOn = 1; + unsigned long 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 = GetLocalIP(); //htonl ( INADDR_ANY ); + + if ( ( nSock = socket ( AF_INET, SOCK_RAW, IPPROTO_SCTP ) ) < 0 ) + { + perror ( "Get SCTP socket error " ); + return -1; + } + + setsockopt ( nSock, SOL_SOCKET, SO_REUSEADDR, &nOn, sizeof ( nOn ) ); + + ioctl ( nSock, FIONBIO, &cmdarg ); + + return ( nSock ); +} + +extern void NcSetPort ( u32 port ) +{ + tNC.nPort = port; +} + +extern void NcSetIP ( u32 ip ) +{ + tNC.nDstIp = ip; +} + +extern int NcInit ( ) +{ + memset ( &tNC, 0, sizeof ( NetCap ) ); + tNC.nPort = 8000; + tNC.nDstIp = inet_addr ( "172.54.240.3" ); + return 1; +} + +extern int NcStart ( u32 wIP, u32 wPort ) +{ + if ( tNC.uState ) + return 0; + tNC.nDstIp = wIP ? wIP : tNC.nDstIp; + tNC.nPort = wPort ? wPort : tNC.nPort; + tNC.nSock = NcGetSocket ( tNC.nPort ); + tNC.uState = 1; + return 1; +} + +extern int NcStop ( ) +{ + shutdown ( tNC.nSock, 2 ); + tNC.uState = 0; + return 1; +} + +#define SCTP_HEADER_LEN 0x1C + +#define SCCTP_CS_POS 0x08 + +#define SCTP_CHUNKLEN_POS 15 + +static u8 SCTP_HEADER[] = { + 0x13, 0x56, 0x13, 0x56, 0x00, 0x00, 0x2d, 0xd1, + 0x05, 0x67, 0x59, 0x7a, 0x00, 0x00, 0x00, 0x3c, + 0x00, 0x00, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x02 +}; + +static int NcStuffSCTP ( u8 * pIPBuff ) +{ + memcpy ( pIPBuff, SCTP_HEADER, SCTP_HEADER_LEN ); + pIPBuff[0] = 4950 >> 8; + pIPBuff[1] = 4950 & 0xFF; + pIPBuff[2] = tNC.nPort >> 8; + pIPBuff[3] = tNC.nPort & 0xFF; + return SCTP_HEADER_LEN; +} + +#define M2UA_HEADER_LEN 0x14 + +#define M2UA_MSGLEN_POS 0x07 + +#define M2UA_PARALEN_POS 0x13 + +static inline int NcGetM2uaParaLen ( u32 wMtp3Len ) +{ + return ( wMtp3Len + 4 ); +} + +static inline int NcGetM2uaMsgLen ( u32 wMtp3Len ) +{ + return ( NcGetM2uaParaLen ( wMtp3Len ) + 16 ); +} + +static u8 M2UA_HEADER[] = { + 0x01, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x2c, + 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x1c +}; + +int NcStuffM2UA ( u8 * pIPBuff, u32 wMtp3Len ) +{ + memcpy ( pIPBuff, M2UA_HEADER, M2UA_HEADER_LEN ); + *( pIPBuff + M2UA_PARALEN_POS ) = NcGetM2uaParaLen ( wMtp3Len ); + *( pIPBuff + M2UA_MSGLEN_POS ) = NcGetM2uaMsgLen ( wMtp3Len ); + return M2UA_HEADER_LEN; +} + +#define MTP3_HAEDER_ANSI_LEN 0x08 + +static u8 MTP3_HEADER_ANSI[] = { + 0x83, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 +}; + +#define MTP3_HAEDER_ITU_LEN 0x05 + +static u8 MTP3_HEADER_ITU[] = { + 0x83, 0x20, 0x00, 0x08, 0x00 +}; + +static int NcStuffMtp3 ( u8 * pIPBuff, u32 wDPC, u32 wOPC, u8 uSLS, + u8 uAnsiFlag ) +{ + u32 MTP3_HAEDER_LEN; + u8 *MTP3_HEADER; + + //printf ( "stuff mtp3 : dpc :%ld opc :%ld sls: %d , ansi :%d \n", wDPC, wOPC, + // uSLS, uAnsiFlag ); + if ( uAnsiFlag ) + { + MTP3_HEADER_ANSI[1] = wDPC ? MTP3_HEADER_ANSI[1] : wDPC; + MTP3_HEADER_ANSI[4] = wOPC ? MTP3_HEADER_ANSI[4] : wOPC; + MTP3_HEADER_ANSI[7] = uSLS ? MTP3_HEADER_ANSI[7] : uSLS; + } + else + { + if ( wDPC ) + { + MTP3_HEADER_ITU[1] = wDPC & 0xFF; + MTP3_HEADER_ITU[2] &= 0xC0; + MTP3_HEADER_ITU[2] |= ( wDPC >> 8 ) & 0x3F; + } + if ( wOPC ) + { + MTP3_HEADER_ITU[2] &= 0x3F; + MTP3_HEADER_ITU[2] |= ( wDPC & 0x03 ) << 6; + MTP3_HEADER_ITU[3] = wDPC >> 2; + MTP3_HEADER_ITU[4] &= 0xF0; + MTP3_HEADER_ITU[4] |= wOPC >> 10; + } + + MTP3_HEADER_ITU[4] &= 0x0F; + MTP3_HEADER_ITU[4] |= uSLS << 4; + } + + MTP3_HEADER = uAnsiFlag ? MTP3_HEADER_ANSI : MTP3_HEADER_ITU; + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + + memcpy ( pIPBuff, MTP3_HEADER, MTP3_HAEDER_LEN ); + return MTP3_HAEDER_LEN; +} + +extern void NcMtp3Send ( u8 * pMtp3Msg, u32 wMtp3Len, u8 uAnsiFlag ) +{ + u8 IPBuff[512]; + u32 wPackLen = 0; + u32 wM2uaLen = 0; + u32 ad = 0; + u32 MTP3_HAEDER_LEN; + u8 uPad = 0; + struct sockaddr_in sin_addr; + + memset ( IPBuff, 0, 512 * sizeof ( u8 ) ); + wPackLen += NcStuffSCTP ( IPBuff + wPackLen ); + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + wM2uaLen = NcStuffM2UA ( IPBuff + wPackLen, wMtp3Len ); + wPackLen += wM2uaLen; + memcpy ( IPBuff + wPackLen, pMtp3Msg, wMtp3Len ); + wPackLen += wMtp3Len; + + uPad = ( IPBuff[SCTP_HEADER_LEN + 7] ) % 4; + uPad = uPad ? ( 4 - uPad ) : 0; + + for ( ; uPad > 0; uPad-- ) + { + IPBuff[SCTP_HEADER_LEN + 7]++; //m2ua msg len + IPBuff[wPackLen++] = 0x00; + } + + IPBuff[SCTP_CHUNKLEN_POS] = 0x10 + IPBuff[SCTP_HEADER_LEN + 7]; + + ad = NcCS ( IPBuff, wPackLen ); + IPBuff[SCCTP_CS_POS] = ad & 0xFF; + IPBuff[SCCTP_CS_POS + 1] = ad / ( 256 ); + IPBuff[SCCTP_CS_POS + 2] = ad / ( 256 * 256 ); + IPBuff[SCCTP_CS_POS + 3] = ad / ( 256 * 256 * 256 ); + + sin_addr.sin_family = AF_INET; + sin_addr.sin_port = htons ( tNC.nPort ); + sin_addr.sin_addr.s_addr = tNC.nDstIp; + + sendto ( tNC.nSock, ( char * ) IPBuff, wPackLen, 0, + ( struct sockaddr * ) &sin_addr, sizeof ( struct sockaddr ) ); + //printf ( "\nMTP3 Send Net cap message!\n " ); +} + +typedef struct WXC_NETCAP_SCCP_INTRA_MESSAGE +{ + u8 msgsource; + u8 msgtype; + u8 msgclass; + u8 msgMNP; + int OPC; + int DPC; + u8 SLS; +} +Wxc_NCSccpIntra; + +extern int NcSccpSend ( u8 * pSccpMsg, u32 wSccpLen, u8 * pIntraMsg, + BYTE uAnsiFlag ) +{ + u8 IPBuff[512]; + u32 wPackLen = 0; + u32 wM2uaLen = 0; + u32 ad = 0; + u8 uPad = 0; + u32 MTP3_HAEDER_LEN; + struct sockaddr_in sin_addr; + Wxc_NCSccpIntra *pIntra = ( Wxc_NCSccpIntra * ) pIntraMsg; + + memset ( IPBuff, 0, 512 * sizeof ( u8 ) ); + wPackLen += NcStuffSCTP ( IPBuff + wPackLen ); + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + wM2uaLen = NcStuffM2UA ( IPBuff + wPackLen, wSccpLen + MTP3_HAEDER_LEN ); + wPackLen += wM2uaLen; + + wPackLen += + NcStuffMtp3 ( IPBuff + wPackLen, pIntra->DPC, pIntra->DPC, pIntra->SLS, + uAnsiFlag ); + memcpy ( IPBuff + wPackLen, pSccpMsg, wSccpLen ); + wPackLen += wSccpLen; + + uPad = ( IPBuff[SCTP_HEADER_LEN + 7] ) % 4; + uPad = uPad ? ( 4 - uPad ) : 0; + + for ( ; uPad > 0; uPad-- ) + { + IPBuff[SCTP_HEADER_LEN + 7]++; //m2ua msg len + IPBuff[wPackLen++] = 0x00; + } + + IPBuff[SCTP_CHUNKLEN_POS] = 0x10 + IPBuff[SCTP_HEADER_LEN + 7]; + + ad = NcCS ( IPBuff, wPackLen ); + + IPBuff[SCCTP_CS_POS] = ad & 0xFF; + IPBuff[SCCTP_CS_POS + 1] = ad / ( 256 ); + IPBuff[SCCTP_CS_POS + 2] = ad / ( 256 * 256 ); + IPBuff[SCCTP_CS_POS + 3] = ad / ( 256 * 256 * 256 ); + + sin_addr.sin_family = AF_INET; + sin_addr.sin_port = htons ( tNC.nPort ); + sin_addr.sin_addr.s_addr = tNC.nDstIp; + + if ( sendto + ( tNC.nSock, ( char * ) IPBuff, wPackLen, 0, + ( struct sockaddr * ) &sin_addr, sizeof ( struct sockaddr ) ) < 0 ) + { + perror ( "SCCP send tNC error!\n" ); + return 0; + } + + //printf ( "\nSCCP Send Net cap message!\n " ); + //write(nSock, IPBuff, wPackLen); + return 1; +} + +/* + #define SCCP_RLSE_LEN 0x0a + + static u8 SCCP_RLSD[ ] = + { + 0x04, 0x01, 0x04, 0x00, 0x00, 0x00, 0x74, 0x00, 0x01, + 0x00 + }; + + void main() + { + int i; + + NcInit(); + NcStart(inet_addr("10.167.144.35") , 8000 ); + for( i = 0 ; i < 5000 ; i ++ ) + { + sleep(1); + NcSccpSend( SCCP_RLSD , SCCP_RLSE_LEN ); + } + NcStop(); + return ; + } + */ +/*@end@*/ diff --git a/omc/plat/public/src/pub_sdp.c b/omc/plat/public/src/pub_sdp.c new file mode 100644 index 0000000..e30f7a1 --- /dev/null +++ b/omc/plat/public/src/pub_sdp.c @@ -0,0 +1,1802 @@ +#include "./include/public.h" +#include "./include/pub_sdp.h" + +/*@ignore@*/ +void pub_replace_all_lws(char *msg) +{ + char *tmp; + + if (msg == NULL) + return; + tmp = msg; + + for (; tmp[0] != '\0'; tmp++) + { + if (('\0' == tmp[0]) || ('\0' == tmp[1]) || + ('\0' == tmp[2]) || ('\0' == tmp[3])) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ('\r' == tmp[2]) && ('\n' == tmp[3])) || + (('\r' == tmp[0]) && ('\r' == tmp[1])) || + (('\n' == tmp[0]) && ('\n' == tmp[1]))) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ((' ' == tmp[2]) || ('\t' == tmp[2]))) || + (('\r' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1]))) || + (('\n' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1])))) + { + // Replace line end and TAB symbols by SP + tmp[0] = ' '; + tmp[1] = ' '; + tmp = tmp + 2; + // Replace all following TAB symbols + for (; ('\t' == tmp[0] || ' ' == tmp[0]); ) + { + tmp[0] = ' '; + tmp++; + } + } + } +} + +char *pub_strncpy(char *dest, const char *src, WORD length) +{ + strncpy(dest, src, length); + dest[length] = '\0'; + return dest; +} + +int pub_set_next_token(char *dest, char *buf, int endSeparator, char **next) +{ + char *sep; // separator + + *next = NULL; + + sep = buf; + while ((*sep != endSeparator) && (*sep != '\0') && (*sep != '\r') + && (*sep != '\n')) + sep++; + if ((*sep == '\r') || (*sep == '\n')) + { // we should continue normally only if this is the separator asked! + if (*sep != endSeparator) + return -1; + } + if (*sep == '\0') + return -1; // value must not end with this separator! + if (sep == buf) + return -1; // empty value (or several space!) + + pub_strncpy(dest, buf, sep - buf); + + *next = sep + 1; // return the position right after the separator + + return 0; +} + +int pub_sdp_msg_init(PUB_SDP_MSG *sdp) +{ + if (sdp == NULL) + return -1; + + memset((BYTE *)sdp, 0, sizeof(PUB_SDP_MSG)); + + return 0; +} + +int pub_sdp_net_type_conv(char *str, BYTE *netType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "IN", 2) == 0) + *netType = PUB_SDP_NET_TYPE_IN; + return 0; + } + else + { + switch (*netType) + { + case PUB_SDP_NET_TYPE_IN: + strcpy(str, "IN"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_addr_type_conv(char *str, BYTE *addrType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "IP4", 3) == 0) + *addrType = PUB_SDP_ADDR_TYPE_IPV4; + return 0; + } + else + { + switch (*addrType) + { + case PUB_SDP_ADDR_TYPE_IPV4: + strcpy(str, "IP4"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_attr_type_conv(char *str, BYTE *attrType, BYTE flag) +{ + int ret = 0; + + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "rtpmap", 6) == 0) + *attrType = PUB_SDP_ATTR_TYPE_RTPMAP; + else if (strncmp(str, "ptime", 5) == 0) + *attrType = PUB_SDP_ATTR_TYPE_PTIME; + else if (strncmp(str, "fmtp", 4) == 0) + *attrType = PUB_SDP_ATTR_TYPE_FMTP; + else if (strncmp(str, "T38FaxVersion", 13) == 0) + *attrType = PUB_SDP_ATTR_TYPE_T38VER; + else if (strncmp(str, "T38MaxBitRate", 13) == 0) + *attrType = PUB_SDP_ATTR_TYPE_T38MBR; + else if (strncmp(str, "ipbcp", 5) == 0) + *attrType = PUB_SDP_ATTR_TYPE_IPBCP; + else + { + ret = -2; + } + return ret; + } + else + { + switch (*attrType) + { + case PUB_SDP_ATTR_TYPE_RTPMAP: + strcpy(str, "rtpmap"); + break; + case PUB_SDP_ATTR_TYPE_PTIME: + strcpy(str, "ptime"); + break; + case PUB_SDP_ATTR_TYPE_FMTP: + strcpy(str, "fmtp"); + break; + case PUB_SDP_ATTR_TYPE_T38VER: + strcpy(str, "T38FaxVersion"); + break; + case PUB_SDP_ATTR_TYPE_T38MBR: + strcpy(str, "T38MaxBitRate"); + break; + case PUB_SDP_ATTR_TYPE_IPBCP: + strcpy(str, "ipbcp"); + break; + default: + return -2; + } + return 0; + } + + return -1; +} + +int pub_sdp_media_type_conv(char *str, BYTE *mediaType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "audio", 6) == 0) + { + *mediaType = PUB_SDP_MEDIA_TYPE_AUDIO; + return 0; + } + else if (strncmp(str, "image", 6) == 0) + { + *mediaType = PUB_SDP_MEDIA_TYPE_IMAGE; + return 0; + } + else + return -2; + } + else + { + switch (*mediaType) + { + case PUB_SDP_MEDIA_TYPE_AUDIO: + strcpy(str, "audio"); + break; + case PUB_SDP_MEDIA_TYPE_IMAGE: + strcpy(str, "image"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_proto_type_conv(char *str, BYTE *protoType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "RTP/AVP", 7) == 0) + *protoType = PUB_SDP_PROTO_TYPE_RTP_AVP; + else if (strncmp(str, "udptl", 5) == 0) + { + *protoType = PUB_SDP_PROTO_TYPE_IMAGE_UDPTL; + return -2; + } + + return 0; + } + else + { + switch (*protoType) + { + case PUB_SDP_PROTO_TYPE_RTP_AVP: + strcpy(str, "RTP/AVP"); + break; + case PUB_SDP_PROTO_TYPE_IMAGE_UDPTL: + strcpy(str, "udptl t38"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_parse_v(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char value[8]; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + if (equal == buf) + return -1; + + // check if header is "v" + if (equal[-1] != 'v') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + pub_strncpy(value, equal + 1, crlf - (equal + 1)); + sdp->v.value = atoi(value); + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("v: %d\n", sdp->v.value); + + sdp->flag |= PUB_SDP_FLAG_V; + + return 0; +} + +int pub_sdp_parse_o(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + int i; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "o" + if (equal[-1] != 'o') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* o=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + tmp = equal + 1; + // o=username sess-id sess-version nettype addrtype addr + // useranme can contain any char (ascii) except "space" and CRLF + if (pub_set_next_token(sdp->o.userName, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // sess_id contains only numeric characters + if (pub_set_next_token(sdp->o.sessId, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // sess_version contains only numeric characters + if (pub_set_next_token (sdp->o.sessVer, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // nettype is "IN" but will surely be extented!!! assume it's some alpha-char + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_net_type_conv(value, &sdp->o.netType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // addrtype is "IP4" or "IP6" but will surely be extented!!! + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_addr_type_conv(value, &sdp->o.addrType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // addr is "IP4" or "IP6" but will surely be extented!!! + i = pub_set_next_token(sdp->o.addr, tmp, '\r', &tmpNext); + if (i != 0) + { /* could it be "\n" only??? rfc says to accept CR or LF instead of CRLF */ + if (pub_set_next_token(sdp->o.addr, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("o: %s, %s, %s, %d, %d, %s\n", sdp->o.userName, sdp->o.sessId, sdp->o.sessVer, sdp->o.netType, sdp->o.addrType, sdp->o.addr); + + sdp->flag |= PUB_SDP_FLAG_O; + + return 0; +} + +int pub_sdp_parse_s(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "s" + if (equal[-1] != 's') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // o=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_S) == PUB_SDP_FLAG_S) + pub_strncpy(sdp->s.sessName, equal + 1, crlf - (equal + 1)); + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("s: %s\n", sdp->s.sessName); + + sdp->flag |= PUB_SDP_FLAG_S; + + return 0; +} + +int pub_sdp_parse_i(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "i" + if (equal[-1] != 'i') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // o=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_I) == PUB_SDP_FLAG_I) + pub_strncpy(sdp->i.info, equal + 1, crlf - (equal + 1)); + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("i: %s\n", sdp->i.info); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_I; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_I; + + return 0; +} + +int pub_sdp_parse_u(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "u" + if (equal[-1] != 'u') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_e(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "e" + if (equal[-1] != 'e') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_p(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "p" + if (equal[-1] != 'p') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_c(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + char *slash; + PUB_SDP_C *cHeader; + int i; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "c" + if (equal[-1] != 'c') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // c=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_C) == PUB_SDP_FLAG_C) + { + tmp = equal + 1; + + // c=nettype addrtype (multicastaddr | addr) + + // nettype is "IN" and will be extended + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_net_type_conv(value, &sdp->c.netType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // nettype is "IP4" or "IP6" and will be extended + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_addr_type_conv(value, &sdp->c.addrType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + /* there we have a multicast or unicast address */ + /* multicast can be ip/ttl [/integer] */ + /* unicast is FQDN or ip (no ttl, no integer) */ + + slash = strchr (tmp, '/'); + cHeader = &sdp->c; + + if (slash != NULL && slash < crlf) // it's a multicast address! + { + // Not supported for the moment + } + else + { + // in this case, we have a unicast address + i = pub_set_next_token(cHeader->addr, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(cHeader->addr, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("c: %d, %d, %s\n", sdp->c.netType, sdp->c.addrType, sdp->c.addr); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_C; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_C; + + return 0; +} + +int pub_sdp_parse_m_c(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + char *slash; + PUB_SDP_C *cHeader; + int i; + + *next = buf; + equal = buf; + + if (sdp->medias.num == 0) + return -1; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "c" + if (equal[-1] != 'c') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // c=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_C) == PUB_SDP_FLAG_C) + { + tmp = equal + 1; + + // c=nettype addrtype (multicastaddr | addr) + + // nettype is "IN" and will be extended + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_net_type_conv(value, &sdp->medias.medias[sdp->medias.num - 1].c.netType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // nettype is "IP4" or "IP6" and will be extended + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_addr_type_conv(value, &sdp->medias.medias[sdp->medias.num - 1].c.addrType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + /* there we have a multicast or unicast address */ + /* multicast can be ip/ttl [/integer] */ + /* unicast is FQDN or ip (no ttl, no integer) */ + + slash = strchr (tmp, '/'); + cHeader = &sdp->medias.medias[sdp->medias.num - 1].c; + + if (slash != NULL && slash < crlf) // it's a multicast address! + { + // Not supported for the moment + } + else + { + // in this case, we have a unicast address + i = pub_set_next_token(cHeader->addr, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(cHeader->addr, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("c: %d, %d, %s\n", sdp->c.netType, sdp->c.addrType, sdp->c.addr); + + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_C; + + return 0; +} + +int pub_sdp_parse_b(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "b" + if (equal[-1] != 'b') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_t(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + int i; + PUB_SDP_T *tHeader; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "t" + if (equal[-1] != 't') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* t=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_T) == PUB_SDP_FLAG_T) + { + tmp = equal + 1; + // t = start_time stop_time + tHeader = &sdp->t; + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + tHeader->startTime = atoi(value); + tmp = tmpNext; + + i = pub_set_next_token(value, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(value, tmp, '\n', &tmpNext) < 0) + return -1; + tHeader->stopTime = atoi(value); + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("t: %ld, %ld\n", sdp->t.startTime, sdp->t.stopTime); + + sdp->flag |= PUB_SDP_FLAG_T; + + return 0; +} + +int pub_sdp_parse_r(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "r" + if (equal[-1] != 'r') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_z(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "z" + if (equal[-1] != 'z') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_k(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "k" + if (equal[-1] != 'k') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_a(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[32]; + int i, ret; + BYTE num, mediaNum; + PUB_SDP_A *a; + char *colon; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "a" + if (equal[-1] != 'a') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* a=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + tmp = equal + 1; + a = &sdp->a; + // a=att-field[:att-value] + + // is there any att-value? + colon = strchr (equal + 1, ':'); + if ((colon != NULL) && (colon < crlf)) + { + // att-field is alpha-numeric + if (pub_set_next_token(value, tmp, ':', &tmpNext) < 0) + return -1; + if ((ret = pub_sdp_attr_type_conv(value, &a->aType, PUB_SDP_STR_TO_API)) == -1) + return -1; + else if (ret == -2) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + return 0; + } + tmp = tmpNext; + + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + else + { + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + sdp->medias.medias[sdp->medias.num - 1].attrs.num++; + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("a: %d, %s\n", a->aType, a->aValue); + + sdp->flag |= PUB_SDP_FLAG_A; + + return 0; +} + +int pub_sdp_parse_m(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[32]; + int i; + PUB_SDP_M *mHeader; + BYTE num; + char *slash; + char *space; + int moreSpace; + int ret; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "m" + if (equal[-1] != 'm') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* a=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_M) == PUB_SDP_FLAG_M) + { + tmp = equal + 1; + num = sdp->medias.num; + mHeader = &sdp->medias.medias[num].m; + // m=media port ["/"integer] proto *(payload_number) + // media is "audio" "video" "application" "data" or other... + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if ((ret = pub_sdp_media_type_conv(value, &mHeader->media, PUB_SDP_STR_TO_API)) < 0) + { + if (-2 == ret) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; + } + + return -1; + } + tmp = tmpNext; + + slash = strchr (tmp, '/'); + space = strchr (tmp, ' '); + if ((slash != NULL) && (slash < space)) + { /* a number of port is specified! */ + if (pub_set_next_token(value, tmp, '/', &tmpNext) < 0) + return -1; + mHeader->port = atoi(value); + tmp = tmpNext; + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->portNum = atoi(value); + tmp = tmpNext; + } + else + { + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->port = atoi(value); + tmp = tmpNext; + } + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + + if ((ret = pub_sdp_proto_type_conv(value, &mHeader->proto, PUB_SDP_STR_TO_API)) < 0) + { + if (ret == -2) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + sdp->medias.medias[sdp->medias.num].flag |= PUB_SDP_FLAG_M; + sdp->flag |= PUB_SDP_FLAG_M; + sdp->medias.num++; + + return 0; + } + + return -1; + } + + tmp = tmpNext; + + space = strchr(tmp + 1, ' '); + if (space == NULL) + moreSpace = 1; + else if ((space != NULL) && (space > crlf)) + moreSpace = 1; + else + moreSpace = 0; + while(moreSpace == 0) + { + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->payloads[mHeader->plNum++] = atoi(value); + tmp = tmpNext; + + space = strchr(tmp + 1, ' '); + if (space == NULL) + moreSpace = 1; + else if ((space != NULL) && (space > crlf)) + moreSpace = 1; + else + moreSpace = 0; + } + if (tmpNext < crlf) + { // tmpNext is still less than clrf: no space + i = pub_set_next_token(value, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(value, tmp, '\n', &tmpNext) < 0) + return -1; + } + mHeader->payloads[mHeader->plNum++] = atoi(value); + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("m: %d, %d, %d, %d, %d, %d, %d\n", mHeader->media, mHeader->port, mHeader->portNum, mHeader->proto, mHeader->plNum, mHeader->payloads[0], mHeader->payloads[1]); + + sdp->medias.medias[sdp->medias.num].flag |= PUB_SDP_FLAG_M; + sdp->flag |= PUB_SDP_FLAG_M; + sdp->medias.num++; + + return 0; +} + +int pub_sdp_parse_m_a(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[32]; + int i, ret; + BYTE num, mediaNum; + PUB_SDP_A *a; + char *colon; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "a" + if (equal[-1] != 'a') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* a=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + tmp = equal + 1; + mediaNum = sdp->medias.num; + num = sdp->medias.medias[mediaNum - 1].attrs.num; + a = &sdp->medias.medias[mediaNum - 1].attrs.attrs[num]; + + // a=att-field[:att-value] + + // is there any att-value? + colon = strchr (equal + 1, ':'); + if ((colon != NULL) && (colon < crlf)) + { + // att-field is alpha-numeric + if (pub_set_next_token(value, tmp, ':', &tmpNext) < 0) + return -1; + if ((ret = pub_sdp_attr_type_conv(value, &a->aType, PUB_SDP_STR_TO_API)) == -1) + return -1; + else if (ret == -2) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + return 0; + } + tmp = tmpNext; + + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + else + { + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + sdp->medias.medias[sdp->medias.num - 1].attrs.num++; + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("a: %d, %s\n", a->aType, a->aValue); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_A; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_A; + + return 0; +} + +int pub_sdp_check_ending(char *ptr, char **nextbuf) +{ + *nextbuf = ptr; + + if ((*ptr == '\0') || (*ptr == '\r') || (*ptr == '\n')) + { + return 0; + } + else if (((ptr[0] == '.') && (ptr[1] == '\r') && (ptr[2] == '\n'))) + { + *nextbuf = ptr + 3; + return 1; + } + else + return -1; +} + +int pub_sdp_parse(PUB_SDP_MSG *sdp, char *buf, char **nextMsg, DWORD flag) +{ + // In SDP, headers must be in the right order + /* This is a simple example + v=0 + o=user1 53655765 2353687637 IN IP4 128.3.4.5 + s=Mbone Audio + i=Discussion of Mbone Engineering Issues + e=mbone@somewhere.com + c=IN IP4 224.2.0.1/127 + t=0 0 + m=audio 3456 RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + */ + + char *nextBuf; + char *ptr; + int i; + int ret; + int moreHeader = 1; + + pub_sdp_msg_init(sdp); + + ptr = (char *) buf; + + // mandatory + if (pub_sdp_parse_v(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // mandatory + if (pub_sdp_parse_o(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // mandatory + if (pub_sdp_parse_s(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + if (pub_sdp_parse_i(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + if (pub_sdp_parse_u(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_e(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_p(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_c(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_b(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // mandatory + if (pub_sdp_parse_t(sdp, ptr, &nextBuf, flag) == -1) + return -1; + + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + + ptr = nextBuf; + + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_r(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_t(sdp, ptr, &nextBuf, flag) == -1) + return -1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + while (moreHeader == 1) + { + i = 0; + while (i == 0) // is a "r" header + { + if ((i = pub_sdp_parse_r(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + if ((i = pub_sdp_parse_t(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + else if (i == -2) + moreHeader = 0; // no more "t" headers + else + moreHeader = 1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_z(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + if (pub_sdp_parse_k(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + // 0 or more "a" header + i = 0; + while (i == 0) // no more "a" header + { + if ((i = pub_sdp_parse_a(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + moreHeader = 0; + while (moreHeader == 0) + { + // optional + if ((moreHeader = pub_sdp_parse_m(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + else if (moreHeader == -2) + break; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + if (pub_sdp_parse_i (sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_m_c(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_b(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_k(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_m_a(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + } + + return 0; +} + +// SDP Encode + +int pub_sdp_encode_v(PUB_SDP_V *v, char *dest) +{ + sprintf(dest, "v=%d\r\n", v->value); + + return 0; +} + +int pub_sdp_encode_o(PUB_SDP_O *o, char *dest) +{ + char origin[128]; + char netType[8]; + char addrType[8]; + + if (pub_sdp_net_type_conv(netType, &o->netType, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_addr_type_conv(addrType, &o->addrType, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(origin, "o=%s %s %s %s %s %s\r\n", o->userName, o->sessId, o->sessVer, netType, addrType, o->addr); + + strcat(dest, origin); + + return 0; +} + +int pub_sdp_encode_s(PUB_SDP_S *s, char *dest) +{ + char sess[64]; + + sprintf(sess, "s=%s\r\n", s->sessName); + + strcat(dest, sess); + + return 0; +} + +int pub_sdp_encode_i(PUB_SDP_I *i, char *dest) +{ + char info[64]; + + sprintf(info, "i=%s\r\n", i->info); + + strcat(dest, info); + + return 0; +} + +int pub_sdp_encode_c(PUB_SDP_C *c, char *dest) +{ + char conn[128]; + char netType[8]; + char addrType[8]; + + if (pub_sdp_net_type_conv(netType, &c->netType, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_addr_type_conv(addrType, &c->addrType, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(conn, "c=%s %s %s\r\n", netType, addrType, c->addr); + + strcat(dest, conn); + + return 0; +} + +int pub_sdp_encode_t(PUB_SDP_T *t, char *dest) +{ + char time[64]; + + sprintf(time, "t=%ld %ld\r\n", t->startTime, t->stopTime); + + strcat(dest, time); + + return 0; +} + +int pub_sdp_encode_m(PUB_SDP_M *m, char *dest, WORD flag) +{ + char media[128]; + char mediaType[8] = ""; + char proto[32]; + char payload[64]; + BYTE i; + + if (pub_sdp_media_type_conv(mediaType, &m->media, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_proto_type_conv(proto, &m->proto, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(media, "m=%s %d %s", mediaType, m->port, proto); + + if (m->proto == PUB_SDP_PROTO_TYPE_RTP_AVP) + { + if ((flag & PUB_MGCP_PARA_FLAG_TFO) == PUB_MGCP_PARA_FLAG_TFO) + { + sprintf(payload, " %d", 8); + strcat(media, payload); + } + + for (i = 0; i < m->plNum; i++) + { + if (i >= PUB_SDP_MAX_PAYLOAD_NUM) + break; + + sprintf(payload, " %d", m->payloads[i]); + strcat(media, payload); + } + } + strcat(media, "\r\n"); + + strcat(dest, media); + + return 0; +} + +int pub_sdp_encode_a(PUB_SDP_A *a, char *dest) +{ + char attr[128]; + char attrType[32]; + int ret; + + if ((ret = pub_sdp_attr_type_conv(attrType, &a->aType, PUB_SDP_API_TO_STR)) == -1) + return -1; + + if (ret == -2) + { + sprintf(attr, "a=%s\r\n", a->aValue); + } + else + { + sprintf(attr, "a=%s:%s\r\n", attrType, a->aValue); + } + + strcat(dest, attr); + + return 0; +} + +int pub_sdp_encode(PUB_SDP_MSG *sdp, char *dest, WORD flag) +{ + BYTE i, j; + BYTE mediaNum, attrNum; + PUB_SDP_MEDIA *media; + PUB_SDP_A *a; + + if ((sdp->flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + if (pub_sdp_encode_v(&sdp->v, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_O) == PUB_SDP_FLAG_O) + { + if (pub_sdp_encode_o(&sdp->o, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_S) == PUB_SDP_FLAG_S) + { + if (pub_sdp_encode_s(&sdp->s, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_I) == PUB_SDP_FLAG_I) + { + if (pub_sdp_encode_i(&sdp->i, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_C) == PUB_SDP_FLAG_C) + { + if (pub_sdp_encode_c(&sdp->c, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_T) == PUB_SDP_FLAG_T) + { + if (pub_sdp_encode_t(&sdp->t, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + if (pub_sdp_encode_a(&sdp->a, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_M) == PUB_SDP_FLAG_M) + { + mediaNum = sdp->medias.num; + for (i = 0; i < mediaNum; i++) + { + media = &sdp->medias.medias[i]; + if (pub_sdp_encode_m(&media->m, dest, flag) < 0) + return -1; + + if ((media->flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + attrNum = media->attrs.num; + for (j = 0; j < attrNum; j++) + { + a = &media->attrs.attrs[j]; + if (pub_sdp_encode_a(a, dest) < 0) + return -1; + } + } + } + } + + return 0; +} + +/*@end@*/ diff --git a/omc/plat/public/src/pub_str.c b/omc/plat/public/src/pub_str.c new file mode 100644 index 0000000..8e83d6e --- /dev/null +++ b/omc/plat/public/src/pub_str.c @@ -0,0 +1,977 @@ +////////////////////////////////////////////////// +//Title : wxc_str.c +//Auhtor : Liu Wei +//Desc : wxc2 string library +//Created : 2007-06-20 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_str.h" +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// Name : StrInc +// Function : test string is included in string "pStr"or not +////////////////////////////////////////////////////////////////////////// +inline char *StrInc ( char *pIncStr, char *pStr ) +{ + int m; + register char *pCh; + register int n; + + m = strlen ( pIncStr ); + n = strlen ( pStr ); + for ( pCh = pStr; !IsChNull(*pCh) && ( n >= m ); pCh++, n-- ) + { + if ( !strncmp ( pIncStr, pCh, m ) ) + { + return ( pCh ); + } + } + return ( NULL ); +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrIns +// Function : Insert string "pStrIns" to string "pSrc" , at the position of +// nPos, the nBufLen of string "pSrc" , is not enought , rerurn +// NULL, nor return pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrIns ( int nPos, const char *pStrIns, char *pSrc, int nBufLen ) +{ + register int i; + int nLen; + + nLen = strlen ( pStrIns ); + + if ( nBufLen < nLen + strlen ( pSrc ) ) + { + return NULL; + } + + *(pSrc+nLen+strlen ( pSrc )) = CNULL; + + for ( i = strlen ( pSrc ); i >= nPos; i-- ) + { + *( pSrc + nLen + i ) = *( pSrc + i ); + } + + for ( i = 0; i < nLen; i++ ) + { + *( pSrc + nPos + i ) = *( pStrIns + i ); + } + + return ( pSrc ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrDel +// Function : Delete string "pStrDel" in string "pStr" , If pStrDel is not +// exist, rerurn NULL, nor return pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrDel ( char *pStrDel, char *pStr ) +{ + char *pCh, *pPos; + + pCh = strstr ( pStr, pStrDel ); + if ( !pCh ) + { + return ( NULL ); + } + pPos = pCh + strlen ( pStrDel ); + strcpy ( pCh, pPos ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepCh +// Function : Replace char cSrc in the string pStr with cDst +// Return : return the replace counter +/////////////////////////////////////////////////////////////////////////// +inline int StrRepCh ( char *pStr, char cSrc, char cDst ) +{ + int nReplaced = 0; + register char *pCh; + + for ( pCh = pStr; !IsChNull ( *pCh ); pCh++ ) + { + if ( cSrc == *pCh ) + { + *pCh = cDst; + nReplaced++; + } + } + return ( nReplaced ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepStr +// Function : Replace the first string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + + pCh = strstr ( pSrc, pStr); + if ( !IsNull(pCh) ) + { + StrDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + return ( pCh ); +} + +/* +inline char *StrRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + int SrcLen; + int DstLen; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + pCh = strstr ( pStr, pSrc); + + if ( (!IsNull(pCh)) && (nBuffLen >DstLen + strlen ( pStr ) - SrcLen)) + { + StrDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh =NULL; + else + pCh = pStr; + } + else + pCh =NULL; + + return ( pCh ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChg +// Function : Replace all the string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +/* +inline char *StrChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + int i; + + i = strlen ( pDst ); + for ( ;; ) + { + if ( IsNull( StrRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + pCh += i; + n++; + } + return ( n ? pStr : NULL ); +} +*/ + +/* +inline char *StrChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + char *pCounter = pStr; + int DstLen; + int SrcLen; + int counter = 0; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + + pCounter = strstr(pCounter, pSrc); + + while (NULL != pCounter) + { + counter++; + pCounter = strstr(pCounter+SrcLen, pSrc); + } + + if ((0 != counter) && (nBuffLen > strlen(pStr)+DstLen*counter-SrcLen*counter)) + { + for ( ;; ) + { + if ( IsNull( StrRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + nBuffLen = nBuffLen - DstLen; + pCh += DstLen; + n++; + } + } + return ( n ? pStr : NULL ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StriInc +// Function : test string is included in string "pStr"or not +// Note : No matter Upper or Lower +/////////////////////////////////////////////////////////////////////////// +inline char *StriInc ( char *pIncStr, char *pStr ) +{ + int m; + register char *pCh; + register int n; + + m = strlen ( pIncStr ); + n = strlen ( pStr ); + for ( pCh = pStr; !IsChNull(*pCh) && ( n >= m ); pCh++, n-- ) + { + if ( !strncasecmp ( pIncStr, pCh, m ) ) + { + return ( pCh ); + } + } + return ( NULL ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StriDel +// Function : Delete string "pStrDel" in string "pStr" , If pStrDel is not +// exist, rerurn NULL, nor return pSrc +// Note : No matter Upper or Lower +////////////////////////////////////////////////////////////////////////// + +inline char *StriDel ( char *pStrDel, char *pStr ) +{ + char *pCh, *pPos; + + pCh = StriInc ( pStrDel, pStr ); + if ( !pCh ) + { + return ( NULL ); + } + pPos = pCh + strlen ( pStrDel ); + strcpy ( pCh, pPos ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepCh +// Function : Replace char cSrc in the string pStr with cDst +// Return : return the replace counter +/////////////////////////////////////////////////////////////////////////// +inline int StriRepCh ( char *pStr, char cSrc, char cDst ) +{ + int nReplaced = 0; + register char *pCh; + + cSrc = toupper ( cSrc ); + for ( pCh = pStr; !IsChNull( *pCh ); pCh++ ) + { + if ( cSrc == toupper ( *pCh ) ) + { + *pCh = cDst; + nReplaced++; + } + } + return ( nReplaced ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StriRepStr +// Function : Replace the first string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StriRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + + pCh = StriInc ( pSrc, pStr); + if ( !IsNull(pCh) ) + { + StriDel ( pSrc, pStr ); + nPos = pCh - pStr; + + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + return ( pCh ); +} + +/* +inline char *StriRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + int SrcLen; + int DstLen; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + pCh = StriInc ( pSrc, pStr); + + if (( !IsNull(pCh) ) && (nBuffLen >DstLen + strlen ( pStr ) - SrcLen)) + { + StriDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + else + pCh = NULL; + + return ( pCh ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChg +// Function : Replace all the string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +// Note : No matter Upper or Lower +/////////////////////////////////////////////////////////////////////////// +/* +inline char *StriChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + int i; + int nSrc , nDst ; + + + i = strlen ( pDst ); + for ( ;; ) + { + if ( IsNull( StriRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + pCh += i; + n++; + } + return ( n ? pStr : NULL ); +} +*/ + +/* +inline char *StriChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + char *pCounter = pStr; + int DstLen; + int SrcLen; + int counter = 0; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + + pCounter = StriInc(pSrc, pCounter); + + while (NULL != pCounter) + { + counter++; + pCounter = StriInc(pSrc, pCounter + SrcLen); + } + + if ((0 != counter) && (nBuffLen > strlen(pStr)+DstLen*counter-SrcLen*counter)) + { + for ( ;; ) + { + if ( IsNull( StriRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + + nBuffLen = nBuffLen - DstLen; + pCh += DstLen; + n++; + } + } + + return ( n ? pStr : NULL ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrCode +// Function : Xor the pStr with pSecCode , used in security coding +/////////////////////////////////////////////////////////////////////////// +inline char *StrCode ( char *pStr, char *pSecCode ) +{ + char *q = pSecCode; + register char *pCh; + + for ( pCh = pStr; !IsChNull(*pCh); pCh++ ) + { + if ( *pCh != *q ) + { + *pCh = *pCh ^ *q; + } + q++; + if ( IsChNull(*q) ) + { + q = pSecCode; + } + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrFinis +// Function : cut the string with '\0', if nPos > the len of pStr , fill +// the string end with ' ' and set the pStr end positon at nPos +/////////////////////////////////////////////////////////////////////////// +inline char *StrFinis ( char *pStr, int nPos ) +{ + int i; + int nLen; + + nLen = strlen ( pStr ); + if ( nPos < nLen ) + { + *( pStr + nPos ) = CNULL; + } + else + { + for ( i = nLen; i < nPos; i++ ) + { + *( pStr + i ) = ' '; + } + *( pStr + i ) = CNULL; + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrEnding +// Function : set the string end with the pEnd string till nPos position +////////////////////////////////////////////////////////////////////////// +inline char *StrEnding( char *pDst, char *pEnd , int nPos ) +{ + register int nLen = strlen(pDst); + int nEndLen = strlen(pEnd); + + if( nPos < nLen + nEndLen ) + { + return NULL; + } + for( ; nPos > nLen + nEndLen ; nLen += nEndLen ) + { + strcat( pDst , pEnd); + } +} + +/////////////////////////////////////////////////////////////////////////// +// StrSuff: checks whether suffix is a suffix of src. If it is not, +// the result is NULL. If it is, the result is a pointer +// to the character of src. +/////////////////////////////////////////////////////////////////////////// +inline char *StrSuff(const char *pSrc, const char *pSuffix ) +{ + register int nLen; + + for ( nLen = 0; *pSuffix++; nLen++ ) + if(!*pSrc++) return NULL; + + while (*pSrc++); + + for ( --pSrc, --pSuffix; --nLen >= 0; ) + if ( *--pSrc != *--pSuffix ) return NULL; + return (char*)pSrc; +} + +/* Fill string 'c' into last area of 'str'. */ +void StringCat(char *str, char *c, int slen) +{ + if (strlen(str) >= slen) + return; + while (strlen(str) < slen) + strcat(str, c); + str[slen] = 0; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrLeftShit +// Function : String left shit , delete first n chars +/////////////////////////////////////////////////////////////////////////// +inline char *StrLeftShit ( char *pStr, int n ) +{ + int i; + int len; + + len = strlen(pStr); + + if( n > len ) + { + return StrFinis(pStr , 0); + } + + len -= n; + + for ( i = 0; i < len; i++ ) + { + *( pStr + i ) = *( pStr + n + i ); + } + StrFinis( pStr , len ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRLeftShit +// Function : String round left shit +/////////////////////////////////////////////////////////////////////////// +inline char *StrRLeftShit ( char *pStr, int n ) +{ + int i, j; + char t; + + if ( !IsChNull(*pStr) ) + { + for ( j = 0; j < n; j++ ) + { + t = *( pStr ); + for ( i = 0; *( pStr + i ); i++ ) + { + *( pStr + i ) = *( pStr + i + 1 ); + } + *( pStr + i - 1 ) = t; + } + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// StrToLower: String all lower case. +/////////////////////////////////////////////////////////////////////////// +//inline char *StrToLower ( char *pStr ) +char *StrToLower ( char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; pCh && *pCh; ++pCh ) + { + if ( isupper ( *pCh ) ) + { + *pCh = tolower ( *pCh ); + } + } + return pStr; +} + +/////////////////////////////////////////////////////////////////////////// +// StrToUpper: String all upper case. +/////////////////////////////////////////////////////////////////////////// +inline char *StrToUpper ( char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; pCh && *pCh; ++pCh ) + { + if ( islower ( *pCh ) ) + { + *pCh = toupper ( *pCh ); + } + } + return pStr; +} + +/////////////////////////////////////////////////////////////////////////// +// StrDupLower: Return an all lower case version of String +// you can free the return pointer +/////////////////////////////////////////////////////////////////////////// +inline char *StrDupLower ( char *pStr ) +{ + static char *pBuffer = NULL; + register char *pCh; + + if ( pBuffer ) + { + free ( pBuffer ); + } + + pBuffer = strdup ( pStr ); + + for ( pCh = pBuffer; pCh && *pCh; ++pCh ) + { + if ( isupper ( *pCh ) ) + { + *pCh = tolower ( *pCh ); + } + } + return ( pBuffer ); +} + +/////////////////////////////////////////////////////////////////////////// +// StrDupUpper: Return an all upper case version of String // you can free the return pointer +/////////////////////////////////////////////////////////////////////////// +inline char *StrDupUpper ( char *pStr ) +{ + static char *pBuffer = NULL; + register char *pCh; + + if ( pBuffer ) + { + free ( pBuffer ); + } + + pBuffer = strdup ( pStr ); + + for ( pCh = pBuffer; pCh && *pCh; ++pCh ) + { + if ( islower ( *pCh ) ) + { + *pCh = toupper ( *pCh ); + } + } + + return ( pBuffer ); +} + +/////////////////////////////////////////////////////////////////////////// +// IsExistCh : Is the char exist in the string +/////////////////////////////////////////////////////////////////////////// +inline int IsExistCh ( char ch, char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; !IsChNull(*pCh); ++pCh ) + { + if ( ch == *pCh ) + { + return ( 1 ); + } + } + + return ( 0 ); +} + +/////////////////////////////////////////////////////////////////////////// +// FindSep: Find the first char in char set in String +/////////////////////////////////////////////////////////////////////////// +inline char *StrChSet ( char *pChSet, char *pStr ) +{ + register char *pCh; + + for ( pCh = pChSet; !IsChNull(*pCh); ++pCh ) + { + if ( IsExistCh ( *pCh, pStr ) ) + { + return ( pCh ); + } + } + return ( ( char * ) NULL ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChNum +// Function : return the char number in the string +/////////////////////////////////////////////////////////////////////////// +inline int StrChNum ( char *pStr, char ch ) +{ + int n = 0; + char *pCh = pStr; + + for( ; !IsChNull(*pCh); pCh++ ) + { + if (ch == *pCh) + n++; + } + + return ( n ); +} + +/* +inline int StrChNum ( char *pStr, char ch ) +{ + int n = 0; + char *pCh = pStr; + + for( ; !IsChNull(*pCh) && (ch == *pCh) ; pCh++ ) + n++; + + return ( n ); +} +*/ +/////////////////////////////////////////////////////////////////////////// +// StrTrimCh: trim the char in the string +/////////////////////////////////////////////////////////////////////////// + char *StrTrimCh ( char *pSrc , char cTrim ) +{ + register char *pCh; + char *p,*q; + + q = pSrc; + p = pCh = strdup(pSrc); + + if (NULL == pCh) + { + return NULL; + } + + for( ; !IsChNull(*pCh) ; pCh++ ) + { + if(*pCh != cTrim) + { + *pSrc++ = *(pCh); + } + } + *pSrc = '\0'; + free(p); + + return q; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimCh: trim the char of the set in the string +/////////////////////////////////////////////////////////////////////////// +inline char *StrTrimChSet ( char *pSrc , char *pTrimSet ) +{ + register char *pCh; + char *p , *q , *m; + + p = pSrc; + m = pCh = strdup(pSrc); + + if (NULL == pCh) + { + return NULL; + } + + for( ; !IsChNull(*pCh) ; pCh++ ) + { + for( q = pTrimSet; *q && *pCh != *q ; q++ ) + { + ; + } + if( IsChNull(*q) ) + { + *pSrc++ = *(pCh); + } + } + + *pSrc = CNULL; + pSrc = p; + free(m); + + return pSrc; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimLeftSpace: trim left space of string +/////////////////////////////////////////////////////////////////////////// +char *StrTrimLeftSpace( const char *pStr ) +{ + const char *p = pStr; + + for ( ; !IsChNull(*p) && isspace(*p) ; ) + { + p++; + } + return (char*) p; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimMoreSpace: trim more than one space +/////////////////////////////////////////////////////////////////////////// +char *StrTrimMoreSpace ( char *pSrc ) +{ + char *pCh , *q; + register char *p; + + pCh = p = strdup(pSrc); + q = pSrc; + for ( ; *p; p++ ) + { + if ( !( isspace ( *p ) && isspace ( *(p+1) ) ) ) + { + *pSrc++ = *p; + } + } + *pSrc = CNULL; + free(pCh); + return pSrc; +} + +/////////////////////////////////////////////////////////////////////////// +// StrPickWord: pick a word from the string +/////////////////////////////////////////////////////////////////////////// +inline char *StrPickWord ( const char *pSrc, char *pDst ) +{ + char *pCh , *q = pDst; + + pCh = StrTrimLeftSpace(pSrc); + for( ; !isspace(*pCh) && !IsChNull(*pCh) ; pCh++) + { + *q++ = *pCh; + } + return (char *)pDst; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrEqTok +// Function: Parse the string and return the expression name and value +// Return : NULL, parse over or string expression error , nor while to call +// StrEqTok at odd times , return the name ; and return the value +// while even times +// Note : use it like strtok +// e.g. : +// { +// char *p = NULL; +// u8 uFlag = 0; +// +// p = StrEqTok(tmpStr); +// printf( "Name: %-20s " , p); +// for( ; p = StrEqTok(NULL); ) +// { +// uFlag = uFlag ? 0 : 1; +// if( uFlag ) +// { +// printf( "Valu: %-20s \n" , p); +// } +// else +// { +// printf( "Name: %-20s " , p); +// } +// } +// } +////////////////////////////////////////////////////////////////////////// +static char *pStrEqTok = NULL; +static u8 uStrEqState = 0; + +char *StrEqTok ( char *pStr ) +{ + char *p, *q, *pCh; + char *pDel = " "; + + pCh = pStr; + if ( pCh == NULL ) + { //last position + pCh = pStrEqTok; + } + else + { + StrTrimLeftSpace ( pCh ); + StrTrimMoreSpace ( pCh ); + } + + if ( pCh == NULL ) + { + return NULL; + } + + uStrEqState = uStrEqState > 2 ? 0 : uStrEqState; + q = strpbrk ( pCh, pDel ); + if ( q == NULL ) + { //over , one word + pStrEqTok = NULL; + q = pCh; + } + else + { //save position + pStrEqTok = q + 1; + *q = CNULL; + } + + p = strchr ( pCh, '=' ); //parse word + if ( p == NULL ) + { //simple word exclude '=' + if ( pStrEqTok == NULL || uStrEqState == 1 ) + { //miss '=' + goto STREQTOK_CLEAN_UP; + } + if ( uStrEqState == 0 || uStrEqState == 2 ) + { //wating expres left or right, recieved + uStrEqState++; + return pCh; + } + } + else + { + if ( uStrEqState == 0 && STR_CHECK_LAST( pCh, '=' ) ) + { //wating expres left , revied left and '=' + uStrEqState += 2; + STR_CUT_LAST( pCh ); + return pCh; + } + else if ( uStrEqState == 1 && STR_CHECK_FIRST( pCh,'=') ) + { //wating '=' , revied + if ( pCh[1] == CNULL ) + { //just '=' + if ( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + pCh = pStrEqTok; + p = strpbrk ( pCh, pDel ); + if ( p == NULL ) + { + pStrEqTok = NULL; + p = pCh; + } + else + { + pStrEqTok = p + 1; + *p = CNULL; + } + uStrEqState = 3; + return pCh; + } + else + { //expres '=' and right + uStrEqState = 3; //all meet + return ++pCh; + } + } + else if ( uStrEqState == 0 ) + { //expres left and '=' and right + if ( pStrEqTok != NULL ) + { + *( pStrEqTok - 1 ) = ' '; + } + pStrEqTok = p + 1; + *p = CNULL; + uStrEqState = 2; + return pCh; + } + else + { + goto STREQTOK_CLEAN_UP; + } + } + + STREQTOK_CLEAN_UP: + pStrEqTok = NULL; + uStrEqState = 0; + return NULL; +} + + +/*@end@*/ + diff --git a/omc/plat/public/src/pub_sys.c b/omc/plat/public/src/pub_sys.c new file mode 100644 index 0000000..4d2ba23 --- /dev/null +++ b/omc/plat/public/src/pub_sys.c @@ -0,0 +1,557 @@ +////////////////////////////////////////////////// +//Title : linux_sys.c +//Auhtor : Liu Wei +//Desc : Linux system infomation +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_sys.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// InitParalPort:Init parallel port data . +/////////////////////////////////////////////////////////////////////////// +extern void InitParalPort(void) +{ +#if 0 + ioperm(0x37a,3,1); + ioperm(0x378,3,1); + ioperm(0x379,3,1); + outb(0,0x37a); + outb(0,0x378); +#endif +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : WriteParalPort +// Function : Write parallel port data +// Node : Parallel port address: +// : flag=0,address=0x37a B1;flag=1,address=0x37a B2 +// : flag=2--9,address=0x378 B0--B7 +/////////////////////////////////////////////////////////////////////////// + +extern void WriteParalPort(u8 uFlag,u8 uData) +{ +#if 0 + u8 ii,jj; + + if (uFlag > 9) + return; + if (uData != 0 && uData != 1) + return; + if (uFlag == 0 || uFlag == 1) // read or write 0x37a + { + ii = inb(0x37a); + jj = 1 << (uFlag + 1); + ii = ii & (~jj); + if (uFlag == 0) + jj = (~uData & 0x01) << (uFlag + 1); + else + jj = uData << (uFlag + 1); + ii = ii | jj; + outb(ii,0x37a); + } + else + { + ii = inb(0x378); + jj = 1 << (uFlag - 2); + ii = ii & (~jj); + jj = uData << (uFlag - 2); + ii = ii | jj; + outb(ii,0x378); + } +#endif +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemoryStr: Get memery string +////////////////////////////////////////////////////////////////////////// +extern char *GetMemoryStr(u32 Amount) +{ + static char Buff[64]; + + if (Amount > 0) { + (void) snprintf(Buff, sizeof(Buff), "%d", Amount/MBYTES); + return(Buff); + } + + return((char *) NULL); +} + +/////////////////////////////////////////////////////////////////////////// +// GetBootTimeProc: Get System Model using the /proc/cpuinfo file. +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_UPTIME "/proc/uptime" + +extern char *GetBootTimeProc ( ) +{ + FILE *pFile; + static char sBuff[64]; + char *pCh; + char *DateStr; + time_t tmUptime; + time_t tmBootTime; + + pFile = fopen ( PROC_FILE_UPTIME, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_UPTIME, + SYSERR ); + return ( ( char * ) NULL ); + } + + if ( !fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + FLogMsg ( PIF_GERR, "%s: Read uptime failed: %s", PROC_FILE_UPTIME, + SYSERR ); + ( void ) fclose ( pFile ); + return ( ( char * ) NULL ); + } + + if ( pCh = strchr ( sBuff, ' ' ) ) + { + *pCh = CNULL; + } + + tmUptime = ( time_t ) strtol ( sBuff, NULL, 0 ); + if ( tmUptime <= 0 ) + { + FLogMsg ( PIF_GERR, "Convert `%s' to long failed", sBuff ); + ( void ) fclose ( pFile ); + return ( ( char * ) NULL ); + } + + tmBootTime = time ( NULL ); + tmBootTime -= tmUptime; + + DateStr = TimeToStr ( tmBootTime, NULL ); + + ( void ) fclose ( pFile ); + + return ( DateStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Get System Model using the /proc/cpuinfo file. +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_CPUINFO "/proc/cpuinfo" +/* +extern char *GetModelProc ( ) +{ + FILE *pFile; + static char sBuff[256]; + char *Cpu = NULL; + char *Vendor = NULL; + char *Model = NULL; + char Speed[64]; + float sp = 0; + char **Argv; + int Argc; + int Cleanup; + + if ( sBuff[0] ) + { + return ( sBuff ); + } + + pFile = fopen ( PROC_FILE_CPUINFO, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_CPUINFO, + SYSERR ); + return ( ( char * ) NULL ); + } + + Speed[0] = CNULL; + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + Cleanup = TRUE; + Argc = StrToArgv ( sBuff, ":", &Argv, NULL, 0 ); + if ( Argc < 2 ) + { + continue; + } + if ( EQ ( Argv[0], "cpu" ) ) + { + Cpu = Argv[1]; + } + else if ( EQ ( Argv[0], "vendor_id" ) ) + { + Vendor = Argv[1]; + } + else if ( EQ ( Argv[0], "model name" ) ) + { + Model = Argv[1]; + } + else if ( EQ ( Argv[0], "cpu MHz" ) ) + { + + // This value is not always perfectly accurate as Linux estimates + // the actual Mhz by doing a loop test at boot. + + if ( sscanf ( Argv[1], "%f", &sp ) ) + { + ( void ) sprintf ( Speed, "%.0f Mhz", rint ( ( double ) sp ) ); + } + } + else + { + DestroyArgv ( &Argv, Argc ); + Cleanup = FALSE; + } + + if ( Cleanup ) + { + ( void ) free ( Argv[0] ); + } + } + + sBuff[0] = CNULL; + if ( Vendor ) + { + ( void ) strcpy ( sBuff, Vendor ); + ( void ) free ( Vendor ); + } + if ( Speed[0] ) + { + if ( sBuff[0] ) + { + ( void ) strcat ( sBuff, " " ); + } + ( void ) strcat ( sBuff, Speed ); + } + if ( Model ) + { + if ( sBuff[0] ) + { + strcat ( sBuff, " " ); + } + strcat ( sBuff, Model ); + ( void ) free ( Model ); + } + if ( Cpu ) + { + if ( sBuff[0] ) + { + strcat ( sBuff, " " ); + } + strcat ( sBuff, Cpu ); + ( void ) free ( Cpu ); + } + + ( void ) fclose ( pFile ); + + return ( sBuff ); +} +*/ +/////////////////////////////////////////////////////////////////////////// +// GetMBytesStr: Get the string of Mbytes +/////////////////////////////////////////////////////////////////////////// + +extern char *GetMBytesStr ( u32 wAmount ) +{ + static char sBuff[64]; + + if ( !wAmount ) + { + return ( ( char * ) NULL ); + } + + if ( wAmount > KBYTES ) + { + ( void ) snprintf ( sBuff, sizeof ( sBuff ), "%.1f GB", + ( float ) MbytesToGbytes ( wAmount ) ); + } + else + { + ( void ) snprintf ( sBuff, sizeof ( sBuff ), "%.0f MB", + ( float ) wAmount ); + } +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemoryKcore: Get System Memory using size of /proc/kcore +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_KCORE "/proc/kcore" + +extern char *GetMemoryKcore ( ) +{ + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + struct stat tStatBuf; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( stat ( PROC_FILE_KCORE, &tStatBuf ) != 0 ) + { + FLogMsg ( PIF_GERR, "%s: stat failed: %s", PROC_FILE_KCORE, SYSERR ); + return ( ( char * ) NULL ); + } + + wMemBytes = ( u32 ) ( tStatBuf.st_size - 4096 ); + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMBytesStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemorySysinfo: Get System Memory using sysinfo() system call +/////////////////////////////////////////////////////////////////////////// + +extern char *GetMemorySysinfo ( ) +{ + struct sysinfo tSysInfo; + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( sysinfo ( &tSysInfo ) != 0 ) + { + FLogMsg ( PIF_GERR, "sysinfo() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + // sysinfo.totalram represents total USABLE physical memory. Memory + // reserved by the kernel is not included. So this is as close as we + // can get for now. + + wMemBytes = ( u32 ) tSysInfo.totalram; + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMemoryStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetVirtMemLinux:Get Virtual Memory using sysinfo() system call +/////////////////////////////////////////////////////////////////////////// + +extern char *GetVirtMemLinux ( ) +{ + struct sysinfo tSysInfo; + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( sysinfo ( &tSysInfo ) != 0 ) + { + FLogMsg ( PIF_GERR, "sysinfo() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + wMemBytes = ( u32 ) ( tSysInfo.totalram + tSysInfo.totalswap ); + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMemoryStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetCpuTypeProc:Get CPU Type from /proc/cpuinfo +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_CPUINFO "/proc/cpuinfo" +/* +extern char *GetCpuTypeProc ( ) +{ + FILE *pFile; + static char sBuff[256]; + static char *Cpu = NULL; + char **Argv; + char *pCh; + int Argc; + + if ( Cpu ) + { + return ( Cpu ); + } + + pFile = fopen ( PROC_FILE_CPUINFO, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_CPUINFO, + SYSERR ); + return ( ( char * ) NULL ); + } + + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + Argc = StrToArgv ( sBuff, ":", &Argv, NULL, 0 ); + if ( Argc < 2 ) + { + continue; + } + if ( EQ ( Argv[0], "cpu" ) ) + { + // Linux 2.0 + Cpu = Argv[1]; + break; + } + else if ( EQ ( Argv[0], "model name" ) ) + { + // Linux 2.2 + Cpu = Argv[1]; + if ( pCh = strchr ( Cpu, ' ' ) ) + { + *pCh = CNULL; + } + break; + } + } + + ( void ) fclose ( pFile ); + + return ( Cpu ); + +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// GetKernVerProc: Get Kernel Version string using /proc/version +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_VERSION "/proc/version" + +extern char *GetKernVerProc ( ) +{ + FILE *pFile; + static char sBuff[512]; + + if ( sBuff[0] ) + { + return ( sBuff ); + } + + pFile = fopen ( PROC_FILE_VERSION, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_VERSION, + SYSERR ); + return ( ( char * ) NULL ); + } + + if ( !fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + FLogMsg ( PIF_GERR, "%s: read failed: %s", PROC_FILE_VERSION, SYSERR ); + return ( ( char * ) NULL ); + } + + ( void ) fclose ( pFile ); + + return ( sBuff ); + +} + +/////////////////////////////////////////////////////////////////////////// +// GetKernVerLinux: Get Kernel Version string using uname() +/////////////////////////////////////////////////////////////////////////// + +extern char *GetKernVerLinux ( ) +{ + static struct utsname tName; + static char *pVerStr = NULL; + + if ( uname ( &tName ) != 0 ) + { + FLogMsg ( PIF_GERR, "uname() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + pVerStr = tName.version; + + return ( pVerStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetOSDistLinux: Get linux distribution (vendor) +/////////////////////////////////////////////////////////////////////////// +/* +extern char *GetOSDistLinux ( ) +{ + static char sBuff[256]; + register char *pCh; + register char *End; + char IssueFile[] = "/etc/issue"; + char Welcome[] = "Welcome to "; + FILE *pFile; + int Found = FALSE; + + if ( !( pFile = fopen ( IssueFile, "r" ) ) ) + { + FLogMsg ( PIF_GERR, "%s: Cannot open to get OS Dist: %s", IssueFile, + SYSERR ); + return ( ( char * ) NULL ); + } + + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + // Some distributions have VGA control chars in them + if ( !isalpha ( sBuff[0] ) ) + { + continue; + } + for ( pCh = sBuff; pCh && *pCh && *pCh != '\n' && !isalpha ( *pCh ); + ++pCh ) + ; + if ( *pCh == '\n' || !strlen ( pCh ) ) + { + continue; + } + // Found first nonblank line + Found = TRUE; + break; + } + + ( void ) fclose ( pFile ); + + if ( !Found ) + { + return ( ( char * ) NULL ); + } + + if ( EQN ( pCh, Welcome, sizeof ( Welcome ) - 1 ) ) + { + pCh += sizeof ( Welcome ) - 1; + } + else if ( EQN ( pCh, "Linux ", 6 ) ) + { + pCh += 6; + } + + if ( End = strchr ( pCh, '-' ) ) + { + --End; + while ( *End && isspace ( *End ) ) + { + --End; + } + *++End = CNULL; + } + + return ( pCh ); +} + +/*@end@*/ diff --git a/omc/plat/public/src/pub_time.c b/omc/plat/public/src/pub_time.c new file mode 100644 index 0000000..6271fac --- /dev/null +++ b/omc/plat/public/src/pub_time.c @@ -0,0 +1,130 @@ +////////////////////////////////////////////////// +//Title : pub_time.c +//Auhtor : Liu Wei +//Desc : Linux time function +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_time.h" + +/*@ignore@*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : GetTickCount +// Function: return the ms value of the time +// Note : +/////////////////////////////////////////////////////////////////////////// +extern long GetTickCount() +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GetCurrentTime +// Function: get current system time(BcdFormate) +// Note : now_time's length is 6: year,month,day,hour,minute,second +// Return : 1 successful 0 fail +/////////////////////////////////////////////////////////////////////////// +extern int GetCurrentTime( u8 *pNowTime ) +{ + struct tm *pTMNowTime; + time_t tTemptime; + + tTemptime = time(NULL); + pTMNowTime = localtime(&tTemptime); + if( pTMNowTime == NULL ) + return 0; + pNowTime[0] = pTMNowTime->tm_year-100; + pNowTime[1] = pTMNowTime->tm_mon+1; + pNowTime[2] = pTMNowTime->tm_mday; + pNowTime[3] = pTMNowTime->tm_hour; + pNowTime[4] = pTMNowTime->tm_min; + pNowTime[5] = pTMNowTime->tm_sec; + + return 1; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : GetCurrentTime +// Function: get current system time in ASCII format +// Note : +/////////////////////////////////////////////////////////////////////////// +extern char *GetAsciiTime() +{ + char *pAscTime; + time_t tCurTime; + + tCurTime = time(NULL); + pAscTime = ctime(&tCurTime); + + return (char *)pAscTime; +} + +char *TimeToStr ( time_t TimeVal, char *Format ) +{ + struct tm *tm; + static char sBuff[128]; + char *String; + char *pCh; + char *Fmt; + + if ( Format != NULL) + { + Fmt = Format; + } + else + { + //Use %H instead of %k as %H is more portable + Fmt = "%a %b %e %H:%M:%S %Y %Z"; + } + tm = localtime ( &TimeVal ); + if ( NULL != tm ) + { + String = asctime ( tm ); + if ( NULL != String ) + { + pCh = strchr ( String, '\n' ); + if ( NULL != pCh ) + { + *pCh = CNULL; + } + return String; + } + } + + FLogMsg ( PIF_DBG, "TimeToStr() failed - No conversion func defined?" ); + + return ( char * ) NULL; +} + + + +/////////////////////////////////////////////////////////////////////////// +// Name : GetTimeHMS +// Function: get current system time string of hour mininute and second +// Note : +/////////////////////////////////////////////////////////////////////////// +extern char *GetTimeHMS(char *pTimeBuf) +{ + struct tm *pTM,tTM; + long lCurTime; + + pTM = &tTM; + lCurTime = time((long *)0); + pTM = localtime(&lCurTime); + sprintf(pTimeBuf,"%02d:%02d:%02d",pTM->tm_hour,pTM->tm_min,pTM->tm_sec); + pTimeBuf[8] = CNULL; + + return pTimeBuf; +} + +/*@end@*/ diff --git a/omc/plat/public/src/pub_timer.c b/omc/plat/public/src/pub_timer.c new file mode 100644 index 0000000..2edb227 --- /dev/null +++ b/omc/plat/public/src/pub_timer.c @@ -0,0 +1,182 @@ +////////////////////////////////////////////////// +//Title : wxc_timer.c +//Auhtor : Liu Wei +//Desc : WXC2 Public Timer Managemnet +//Created : 2007-04-27 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_timer.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +//by simon at 23/9/25 +u8 TMHeap[TMHEAP_MM_SIZE]; +WxcTimerNode tTimerListHead; +WxcTimerNode *pTLHead; +WxcTimerNode *pTLCur; + +extern void TimerAdd ( WxcTimer * pTimer ) +{ + WxcTimerNode *pTNode; + + assert ( NULL != pTimer && NULL != pTimer->pFunc ); + assert ( pTimer->dExpires && pTimer->dSuitNumber < TM_CLOCK_MAX ); + + //pTimer->dSuitNumber = ? : 1; + + pTNode = + ( WxcTimerNode * ) WxcMalloc ( GET_TNODE_SIZE ( pTimer->dSuitNumber ) ); + if( NULL == pTNode ) + { + return ; + } + pTNode->pNext = NULL; + pTNode->pPrev = pTLCur; + pTNode->pTimer = ( WxcTimer * ) ( pTNode + 4 * sizeof ( void * ) ); + pTimer->pTimerNode = ( void * ) pTNode; + memcpy ( pTNode->pTimer, pTimer, sizeof ( WxcTimer ) ); + pTNode->dClockArray = ( u32 * ) ( pTNode->pTimer + sizeof ( WxcTimer ) ); + pTLCur = pTNode; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +inline void TimerStart ( WxcTimer * pTimer, u16 dSuitId ) +{ + assert ( pTimer && pTimer->pTimerNode ); + assert ( dSuitId < pTimer->dSuitNumber ); + + ( ( WxcTimerNode * ) pTimer->pTimerNode )->dClockArray[dSuitId] = 1; +} + +extern void TimerMod ( WxcTimer * pTimer, u16 dExpires ) +{ + int i; + + assert ( NULL != pTimer && dExpires ); + + pTimer->dExpires = dExpires; + for ( i = 0; i < pTimer->dSuitNumber; i++ ) + { + TimerStart ( pTimer, i ); + } +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern void TimerDel ( WxcTimer * pTimer ) +{ + assert ( pTimer && pTimer->pTimerNode ); + + WxcFree ( pTimer->pTimerNode ); + pTimer->pTimerNode = NULL; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern inline void TimerStop ( WxcTimer * pTimer, u16 dSuitId ) +{ + assert ( NULL != pTimer && dSuitId < pTimer->dSuitNumber ); + + ( ( WxcTimerNode * ) pTimer->pTimerNode )->dClockArray[dSuitId] = 0; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +#define TimerRestart(pTimer) TimerStart(pTimer) + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static void *TM_Alloc ( u16 dSize ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static void TM_Free ( void *p ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static inline int TM_Pending ( WxcTimerNode * pTNode, u16 dSuitId ) +{ + return ( pTNode->dClockArray[dSuitId] ? 1 : 0 ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static inline int TM_Expiring ( WxcTimerNode * pTNode, u16 dSuitId ) +{ + return ( TimerAfter + ( pTNode->dClockArray[dSuitId], pTNode->pTimer->dExpires ) ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern inline void TM_Init ( ) +{ + pTLCur = pTLHead = &tTimerListHead; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern void TM_RT ( ) +{ + u16 sid; + WxcTimer *pTimer; + WxcTimerNode *pTNode; + + pTNode = pTLHead; + + for ( ; NULL != pTNode; pTNode = pTNode->pNext ) + { + pTimer = pTNode->pTimer; + for ( sid = 0; sid <= pTimer->dSuitNumber; sid++ ) + { + if ( !TM_Pending ( pTNode, sid ) ) + { + pTNode->dClockArray[sid]++; + if ( TM_Expiring ( pTNode, sid ) ) + { + pTimer->pFunc ( pTimer->dData, sid ); + } + } + } + } +} + +/*@end@*/ diff --git a/omc/plat/public/src/pub_wnet.c b/omc/plat/public/src/pub_wnet.c new file mode 100644 index 0000000..3f7d2d3 --- /dev/null +++ b/omc/plat/public/src/pub_wnet.c @@ -0,0 +1,425 @@ +////////////////////////////////////////////////// +//Title : wxc_netfunc.c +//Auhtor : Liu Wei +//Desc : wxc2 network convert function +//Created : 2007-06-20 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_wnet.h" + +u8 GetBcdStr ( char *str, u8 * bcd, u8 bcd_len ) +{ + u8 ii = 0; + + Bcd2Str ( str, bcd, bcd_len * 2 ); + for ( ii = 0; ii < bcd_len * 2; ii++ ) + { + if( str[ii] == 'e' || str[ii] == 'E' ) + break; + } + str[ii] = '\0'; + return ii; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiNToA +// Function: transfer IMSI format from normal to anti sequence +// Note : 0460022157127001 --> 64002251177200f1 +////////////////////////////////////////////////////////////////////////// + +void ImsiNtoA( u8 *pAntiImsi , u8 *pNormalImsi ) +{ + u8 ii; + u8 aa, bb = 0; + + for ( ii = 1; ii <= IMSI_LEN * 2; ii++ ) + { + if ( ( ii % 2 ) == 1 ) + { + bb = pNormalImsi[ii / 2] & 0x0f; + } + else + { + aa = (ii == IMSI_LEN * 2) ? 0x0f0 : (pNormalImsi[ii / 2] & 0x0f0); + pAntiImsi[ii / 2 - 1] = aa | bb; + } + } + +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiAToN +// Function: transfer IMSI format from anti to normal sequence +// Note : 64002251177200f1 --> 0460022157127001 +////////////////////////////////////////////////////////////////////////// + +void ImsiAToN ( u8 * pNormalImsi, u8 * pAntiImsi ) +{ // the IMSI must 15 digits + u8 ii; + u8 aa, bb = 0; + + pNormalImsi[0] = 0; + for ( ii = 0; ii < IMSI_LEN * 2; ii++ ) + { + if ( ( ii % 2 ) == 1 ) + { + aa = pAntiImsi[ii / 2] & 0x0f; + pNormalImsi[ii / 2] |= aa; + } + else + { + if ( ii / 2 != IMSI_LEN - 1 ) + { + bb = pAntiImsi[ii / 2] & 0x0f0; + pNormalImsi[ii / 2 + 1] = bb; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiNToS +// Function: transfer IMSI format from normal to ascii string +// Note : 0460022157127001 --> "460022157127001" +/////////////////////////////////////////////////////////////////////////// + +void ImsiNToS ( u8 * pImsiStr, u8 * pNormalImsi ) +{ + u8 len; + u8 ii, jj; + + pImsiStr[0] = ( pNormalImsi[0] & 0x0f ) + '0'; + len = 1; + for ( ii = 1; ii < IMSI_LEN; ii++ ) + { + jj = ( pNormalImsi[ii] >> 4 ) & 0x0f; + pImsiStr[len++] = jj + '0'; + jj = pNormalImsi[ii] & 0x0f; + pImsiStr[len++] = jj + '0'; + } + pImsiStr[len] = '\0'; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiSToN +// Function: transfer IMSI format from ascii string to normal +// Note : "460022157127001" --> 0460022157127001 +/////////////////////////////////////////////////////////////////////////// + +void ImsiSToN ( u8 * pNormalImsi, u8 * pImsiStr ) +{ + if ( strlen ( pImsiStr ) != IMSI_LEN * 2 - 1 ) + return; + pNormalImsi[0] = pImsiStr[0] - '0'; + Str2Bcd ( pNormalImsi + 1, pImsiStr + 1, IMSI_LEN * 2 - 2 ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnNToA +// Function: transfer ISDN format from normal to anti sequence +// Note : 918675557127001EEE --> 08916857551700E1 +/////////////////////////////////////////////////////////////////////////// + +void IsdnNToA ( u8 * pAntiIsdn, u8 * pNormalIsdn ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 len; + + // nature of address and numbering plan indicator + pAntiIsdn[1] = pNormalIsdn[0]; + len = 1; + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + if ( pNormalIsdn[ii] == 0xee ) + { + break; + } + else + { + aa = ( pNormalIsdn[ii] & 0x0f0 ) >> 4; + bb = pNormalIsdn[ii] & 0x0f; + if ( bb > 0x0c ) + { + bb = 0x0f; + } + pAntiIsdn[ii + 1] = ( bb << 4 ) + aa; + len++; + } + } + pAntiIsdn[0] = len; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnAToN +// Function: transfer ISDN format from anti to normal sequence +// Note : 08916857551700E1 --> 918675557127001EEE +/////////////////////////////////////////////////////////////////////////// + +void IsdnAToN ( u8 * pNormalIsdn, u8 * pAntiIsdn ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 uIsdnLen; + + uIsdnLen = pAntiIsdn[0]; + if ( uIsdnLen > ISDN_LEN ) + uIsdnLen = ISDN_LEN; + pNormalIsdn[0] = pAntiIsdn[1]; + for ( ii = 1; ii < uIsdnLen; ii++ ) + { + if ( ( pAntiIsdn[ii + 1] & 0x0f ) >= 0x0e ) + break; + aa = ( pAntiIsdn[ii + 1] & 0x0f0 ) >> 4; + if ( aa > 0x0c ) + aa = 0x0e; + bb = pAntiIsdn[ii + 1] & 0x0f; + pNormalIsdn[ii] = ( bb << 4 ) + aa; + } + for ( ; ii < ISDN_LEN; ii++ ) + pNormalIsdn[ii] = 0x0ee; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnNToS +// Function: transfer ISDN format from normal to ascii string +// Note : 918675557127001EEE --> "8675557127001" +/////////////////////////////////////////////////////////////////////////// + +void IsdnNToS ( u8 * pIsdnStr, u8 * pNormalIsdn ) +{ + u8 len = 0; + u8 ii, jj; + + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + jj = ( pNormalIsdn[ii] >> 4 ) & 0x0f; + if ( jj > 0x0c ) + break; + pIsdnStr[len++] = jj + '0'; + jj = pNormalIsdn[ii] & 0x0f; + if ( jj > 0x0c ) + break; + pIsdnStr[len++] = jj + '0'; + } + pIsdnStr[len] = '\0'; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnAToS +// Function: transfer ISDN format from anti to ascii string +// Note : 08916857551700E1 --> "8675557127001" +/////////////////////////////////////////////////////////////////////////// + +void IsdnAToS ( u8 * pAntiIsdn, u8 * pIsdnStr ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 len = 0; + u8 uIsdnLen; + + + uIsdnLen = pAntiIsdn[0]; + if ( uIsdnLen > ISDN_LEN ) + uIsdnLen = ISDN_LEN; + + for ( ii = 1; ii < uIsdnLen; ii++ ) + { + if ((bb = ( pAntiIsdn[ii + 1] & 0x0f )) >= 0x0c) + break; + + pIsdnStr[len++] = bb + '0'; + + if ((aa = ( pAntiIsdn[ii + 1] & 0x0f0 ) >> 4) >= 0x0c) + break; + + pIsdnStr[len++] = aa + '0'; + } + + pIsdnStr[len] = '\0'; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnSToN +// Function: transfer ISDN format from ascii string to normal +// Note : "8675557127001" --> 918675557127001EEE +// Return : 0--string has error; 1--success +/////////////////////////////////////////////////////////////////////////// + +u8 IsdnSToN ( u8 * pNormalIsdn, u8 * pIsdnStr ) +{ + u8 ii; + u8 len; + + len = strlen ( pIsdnStr ); + if ( len > ISDN_LEN * 2 - 2 ) + return 0; + if ( ( len % 2 ) == 1 ) // odd number + { + Str2Bcd ( pNormalIsdn + 1, pIsdnStr, len - 1 ); + ii = len / 2 + 1; + pNormalIsdn[ii] = ( pIsdnStr[len - 1] - '0' ) << 4; + pNormalIsdn[ii] |= 0x0E; + } + else + { + Str2Bcd ( pNormalIsdn + 1, pIsdnStr, len ); + ii = len / 2; + } + memset ( pNormalIsdn + ii + 1, 0xEE, ISDN_LEN - ii - 1 ); + pNormalIsdn[0] = 0x91; // default value + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GttToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void GttToIsdn ( u8 *pIsdn, u8 *pGtt ) +{ + u8 ii, jj; + + pIsdn[0] = 0x91; + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + jj = pGtt[ii - 1] & 0x0f; + if ( jj > 0x0c ) + break; + pIsdn[ii] = jj << 4; + jj = ( pGtt[ii - 1] & 0xf0 ) >> 4; + if ( jj > 0x0c ) + jj = 0x0e; + pIsdn[ii] |= jj; + if ( jj == 0x0e ) + { + ii++; + break; + } + } + for ( ; ii < ISDN_LEN; ii++ ) + pIsdn[ii] = 0xee; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnToGtai +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +u8 IsdnToGtai ( u8 * pGtai, u8 * pIsdn ) +{ + u8 tmpBuf[32]; + u8 ii; + u8 len; + + IsdnNToA ( tmpBuf, pIsdn ); + ii = tmpBuf[0]; + memcpy ( pGtai, tmpBuf + 2, ii - 1 ); + if ( ( tmpBuf[ii] & 0x0f0 ) == 0x0f0 ) + len = ii * 2 - 3; + else + len = ii * 2 - 2; + return len; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GtaiToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void GtaiToIsdn ( u8 * pIsdn, u8 * pGtai, u8 len ) +{ + u8 tmpBuf[32]; + + tmpBuf[0] = ( len + 1 ) / 2; + tmpBuf[1] = 0x91; + memcpy ( tmpBuf + 2, pGtai, tmpBuf[0]++ ); + IsdnAToN ( pIsdn, tmpBuf ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : BcdToStrPE +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +u8 BcdToStrPE ( char *str, u8 * bcd, u8 bcd_len ) +{ + u8 ii = 0; + + Bcd2Str ( str, bcd, bcd_len * 2 ); + for ( ii = 0; ii < bcd_len * 2; ii++ ) + { + if ( str[ii] == 'e' || str[ii] == 'E' ) + break; + } + str[ii] = '\0'; + return ii; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : AddCcToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void AddCcToIsdn ( u8 * isdn_str, u8 * cc ) +{ + char str1[32], str2[32]; + u8 len, len1, len2; + + len1 = BcdToStrPE ( str1, isdn_str + 1, ISDN_LEN - 1 ); + len2 = BcdToStrPE ( str2, cc, 2 ); + memcpy ( str2 + len2, str1, len1 ); + len = len1 + len2; + if ( ( len % 2 ) != 0 ) + str2[len++] = 'E'; + str2[len] = '\0'; + Str2Bcd ( isdn_str + 1, str2, len ); + isdn_str[0] = 0x91; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : AddNdcToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void AddNdcToIsdn ( u8 * isdn_str, u8 * ndc ) +{ + char str1[32], str2[32]; + u8 len, len1, len2; + + len1 = GetBcdStr ( str1, isdn_str + 1, ISDN_LEN - 1 ); + len2 = GetBcdStr ( str2, ndc, 3 ); //6 digit ndc + memcpy ( str2 + len2, str1, len1 ); + len = len1 + len2; + if ( ( len % 2 ) != 0 ) + str2[len++] = 'E'; + Str2Bcd ( isdn_str + 1, str2, len ); + isdn_str[0] = 0xa1; +} + +void BcdToAsciiR(char *ascii_buf, const unsigned char *bcd_buf, int len) +{ + char ch; + int i; + for(i=0;i +#include + +void * shm_init(int shm_id, char *prog_name, key_t key, int size, int shmflg) +{ + void *retp; + char *func_name = "shm_init"; + + shm_id = shmget(key, size, shmflg); + if (shm_id == -1) + printf("%s: %s: shmget(key: %x)", prog_name, func_name, key); + + retp = shmat(shm_id, (char *)0, 0); + if (retp == (void *) -1) + printf("%s: %s: shmat", prog_name, func_name); + + return retp; +} + +int sem_init(char *prog_name, key_t key, int sem_num, int sem_flg) +{ + int initarray[sem_num]; + int sem_id, retval, i; + char *func_name = "sem_init"; + + sem_id = semget(key, sem_num, sem_flg); + if (sem_id == -1) + printf("%s: %s: semget", prog_name, func_name); + for (i=0; i + * + */ + +#include "./number.h" + +/* +ITU: + 0-spare + 1-subscriber + 2-unknown + 3-NDD + 4-IDD + +GSM 09.02: +-- bits 765: nature of address indicator +-- 000 unknown +-- 001 international number +-- 010 national significant number +-- 011 network specific number +-- 100 subscriber number +-- 101 reserved +-- 110 abbreviated number +-- 111 reserved for extension +*/ + +static const u8 NAI_GSM2ITU[8] = {0x02, 0x04, 0x03, 0x03, 0x01, 0x02, 0x02, 0x02}; +static const u8 NAI_ITU2GSM[8] = {0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00}; + +u8 nai_gsm_to_itu(u8 nai) +{ + return NAI_GSM2ITU[nai & 0x07]; +} + +u8 nai_itu_to_gsm(u8 nai) +{ + return NAI_ITU2GSM[nai & 0x07]; +} + +void num_itu_to_gsm(num32_t *gsm_num, const num32_t *itu_num) +{ + int i; + + gsm_num->num_of_digit = itu_num->num_of_digit; + + for(i = 0; i < itu_num->num_of_digit; i++) + { + if(itu_num->digit[i] == 0x0b) + gsm_num->digit[i] = 0x0a; + else if(itu_num->digit[i] == 0x0c) + gsm_num->digit[i] = 0x0b; + else + gsm_num->digit[i] = itu_num->digit[i]; + } +} + +u8 *msc_isdn_to_bcd(u8 *bcd, const isdn_t *isdn) +{ + int i; + const num32_t *num = &isdn->num; + u8 *bcdptr; + + bcd[0] = (num->num_of_digit+1)/2 + 1; + bcd[1] = 0x81 | (nai_itu_to_gsm(isdn->nai) << 4); + bcdptr = bcd + 2; + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcdptr = (num->digit[i] << 4) | 0x0f; + else + { + *bcdptr = (*bcdptr & 0xf0) + num->digit[i]; + bcdptr++; + } + } + return bcd; +} + +isdn_t *netbcd_to_isdn(isdn_t *isdn, const u8 *bcd) +{ + u8 bcd_digits; + u8 digit; + num32_t *num = &isdn->num; + + if(bcd[0] < 1) + { + num->num_of_digit = 0; + return isdn; + } + bcd_digits = (bcd[0]-1) * 2; + isdn->nai = nai_gsm_to_itu((bcd[1] >> 4) & 0x07); + bcd += 2; + for(num->num_of_digit = 0; (num->num_of_digit<32)&&(num->num_of_digitnum_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *bcd & 0x0f; + else + digit = *(bcd++) >> 4; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return isdn; +} + +u8 *isdn_to_netbcd(u8 *bcd, const isdn_t *isdn) +{ + int i; + const num32_t *num = &isdn->num; + u8 *bcdptr; + + bcd[0] = (num->num_of_digit+1)/2 + 1; + bcd[1] = 0x81 | (nai_itu_to_gsm(isdn->nai) << 4); + bcdptr = bcd + 2; + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcdptr = 0xf0 + (num->digit[i] & 0x0f); + else + { + *bcdptr = (num->digit[i] << 4) | (*bcdptr & 0x0f); + bcdptr++; + } + } + return bcd; +} + +/* TBCD: Telephony Binary Coded Decimal (GSM 09.02) */ +int tbcd_to_string(char *str, const u8 *tbcd, u8 tbcd_len) +{ + int i; + u8 max_digits; + u8 digit; + + max_digits = tbcd_len * 2; + for(i = 0; i < max_digits; i++) + { + if((i & 1) == 0) + digit = *tbcd & 0x0f; + else + digit = *(tbcd++) >> 4; + if(is_dail_digit(digit)) + digit_to_char(str[i], digit); + else + break; + } + str[i] = 0; + return i; +} + +isdn_t *tpaddr_to_isdn(isdn_t *isdn, const u8 *tpaddr) +{ + u8 bcd_digits; + u8 digit; + num32_t *num = &isdn->num; + + bcd_digits = tpaddr[0]; + isdn->nai = nai_gsm_to_itu((tpaddr[1] >> 4) & 0x07); + tpaddr += 2; + for(num->num_of_digit = 0; (num->num_of_digit<32)&&(num->num_of_digitnum_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *tpaddr & 0x0f; + else + digit = *(tpaddr++) >> 4; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return isdn; +} + +int string_to_num32(num32_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 32; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num32_to_string(char *str, const num32_t *num) +{ + int i; + + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int string_to_num16(num16_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 16; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num16_to_string(char *str, const num16_t *num) +{ + int i; + + for(i = 0; ((i < 16) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int string_to_num8(num8_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 8; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num8_to_string(char *str, const num8_t *num) +{ + int i; + + for(i = 0; ((i < 8) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int digit_to_netbcd(u8 *netbcd, u8 *digit, u8 max_digit) +{ + int i; + + for(i = 0; i < max_digit; i++) + { + if((i & 1) == 0) + *netbcd = 0xf0 + (digit[i] & 0x0f); + else + { + *netbcd = (digit[i] << 4) | (*netbcd & 0x0f); + netbcd++; + } + } + return (max_digit+1)/2; +} + +int netbcd_to_digit(u8 *digit, u8 *netbcd, u8 max_digit) +{ + int i; + u8 d; + + for(i = 0; i < max_digit; i++) + { + if((i & 1) == 0) + d = *netbcd & 0x0f; + else + d = *(netbcd++) >> 4; + + if(d != 0x0f) + digit[i] = d; + else + break; + } + return i; +} + +void msc_save_lai(u8 *lai, u8 *mcc, u8 *mnc, int lac) +{ + lai[0] = (mcc[1] << 4) + (mcc[0] & 0x0f); + lai[1] = (mnc[2] << 4) | mcc[2]; + lai[2] = (mnc[1] << 4) + (mnc[0] & 0x0f); + lai[3] = lac >> 8; + lai[4] = lac; +} + +void msc_load_lai(u8 *mcc, u8 *mnc, int *lac, u8 *lai) +{ + mcc[0] = lai[0] & 0x0f; + mcc[1] = lai[0] >> 4; + mcc[2] = lai[1] & 0x0f; + mnc[0] = lai[2] & 0x0f; + mnc[1] = lai[2] >> 4; + mnc[2] = lai[1] >> 4; + *lac = (lai[3] << 8) + lai[4]; +} + +#if 0 +/* return the digit counts of number */ +static int bcd_to_num16(num16_t *num, const u8 *bcd) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 16; num->num_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *bcd >> 4; + else + digit = *(bcd++) & 0x0f; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return num->num_of_digit ; +} + +/* return the length of bcd */ +static int num16_to_bcd(u8 *bcd, const num16_t *num) +{ + int i; + + for(i = 0; ((i < 16) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcd = (num->digit[i] << 4) | 0x0f; + else + *(bcd++) = (*bcd & 0xf0) + num->digit[i]; + } + return (i+1)/2; +} +#endif + diff --git a/omc/plat/public/src/uwav/number.h b/omc/plat/public/src/uwav/number.h new file mode 100644 index 0000000..6f98718 --- /dev/null +++ b/omc/plat/public/src/uwav/number.h @@ -0,0 +1,80 @@ +#ifndef _UWAV_NUMBER_H +#define _UWAV_NUMBER_H + +#include "../include/public.h" + +/* + * Number type definition: + * 32 digits number is used for party number handling + * 16 digits number is used for prefix parameter + * 8 digits number is used for short number parameter, i.e. cc, ndc + */ +typedef struct number32 { + u8 num_of_digit; + u8 digit[32]; +} num32_t; + +typedef struct number16 { + u8 num_of_digit; + u8 digit[16]; +} num16_t; + +typedef struct number8 { + u8 num_of_digit; + u8 digit[8]; +} num8_t; + +typedef struct isdn_num { + u8 nai; /* Nature of Address Indicator */ +// u8 npi; /* Number Plan Indicator */ + u8 pi; + u8 si; /* Screen Indicator */ + num32_t num; +} isdn_t; + +struct number_change { + u8 nai; + u8 del_count; + num16_t insert; +}; + +#define is_dail_digit(digit) (digit < 0x0e) +#define char_to_digit(digit, ch) do { \ + if((ch >= '0') && (ch <= '9')) \ + digit = ch - '0'; \ + else if(ch == '*') \ + digit = 0x0b; \ + else if(ch == '#') \ + digit = 0x0c; \ + else \ + break; \ +} while(0) +#define digit_to_char(ch, digit) do { \ + if(digit <= 9) \ + ch = digit + '0'; \ + else if(digit == 0x0b) \ + ch = '*'; \ + else if(digit == 0x0c) \ + ch = '#'; \ +} while(0) + +extern u8 nai_gsm_to_itu(u8 nai); +extern u8 nai_itu_to_gsm(u8 nai); +extern u8 *msc_isdn_to_bcd(u8 *bcd, const isdn_t *isdn); +extern isdn_t *netbcd_to_isdn(isdn_t *isdn, const u8 *bcd); +extern u8 *isdn_to_netbcd(u8 *bcd, const isdn_t *isdn); +extern int tbcd_to_string(char *str, const u8 *tbcd, u8 tbcd_len); +extern isdn_t *tpaddr_to_isdn(isdn_t *isdn, const u8 *tpaddr); +extern int string_to_num32(num32_t *num, const char *str); +extern int num32_to_string(char *str, const num32_t *num); +extern int string_to_num16(num16_t *num, const char *str); +extern int num16_to_string(char *str, const num16_t *num); +extern int string_to_num8(num8_t *num, const char *str); +extern int num8_to_string(char *str, const num8_t *num); +extern int digit_to_netbcd(u8 *netbcd, u8 *digit, u8 max_digit); +extern int netbcd_to_digit(u8 *digit, u8 *netbcd, u8 max_digit); +extern void msc_save_lai(u8 *lai, u8 *mcc, u8 *mnc, int lac); +extern void msc_load_lai(u8 *mcc, u8 *mnc, int *lac, u8 *lai); + +#endif + diff --git a/omc/plat/public/src/uwav/numgrp.c b/omc/plat/public/src/uwav/numgrp.c new file mode 100644 index 0000000..560c6a5 --- /dev/null +++ b/omc/plat/public/src/uwav/numgrp.c @@ -0,0 +1,176 @@ +/* + * public/uwav/numgrp.c + * + * Copyright (C) 2008 ADC, Inc + * Written by: Xinyu Yan + * + * Description: number group lookup algorithm + */ + +#include +#include +#include +#include +#include "numgrp.h" + +static struct numgrp_table group_table[MAX_NUMBER_GROUP_TABLE]; + +struct numgrp_table *assign_numgrp_table(char *name, int size) +{ + int i; + + assert(size <= MAX_NUMBER_GROUP_TABLE_SIZE); + + for(i = 0; i < MAX_NUMBER_GROUP_TABLE; i++) + { + if(group_table[i].size == 0) + { + strncpy(group_table[i].name, name, 32); + group_table[i].size = size; + group_table[i].len = 0; + group_table[i].item = malloc(sizeof(struct number_group) * size); + return &group_table[i]; + } + } + return NULL; +} + +int delete_numgrp_table(struct numgrp_table *table) +{ + int i; + + for(i = 0; i < MAX_NUMBER_GROUP_TABLE; i++) + { + if(&group_table[i] == table) + { + free(group_table[i].item); + memset(&group_table[i], 0, sizeof(struct numgrp_table)); + return 1; + } + } + return 0; +} + +/*Return an integer greater than, equal to, or less than 0, if the number pointed to + by n1 is greater than, equal to, or less than the number pointed to by n2, respectively*/ +static int numcmp(const num16_t *n1, const num16_t *n2) +{ + int i; + + if(n1->num_of_digit > n2->num_of_digit) + return 1; + else if(n1->num_of_digit < n2->num_of_digit) + return -1; + for(i = 0; i < n1->num_of_digit; i++) + { + if(n1->digit[i] > n2->digit[i]) + return 1; + else if(n1->digit[i] < n2->digit[i]) + return -1; + } + return 0; +} + +/*Return an integer greater than, equal to, or less than 0, if the number pointed to + by n is greater than, equal to, or less than the group pointed to by start and end, respectively*/ +static int numgrpcmp(const num16_t *start, const num16_t *end, const num16_t *n) +{ + int ret1, ret2; + + ret1 = numcmp(n, start); + ret2 = numcmp(n, end); + if((ret1 >= 0) && (ret2 <= 0)) + return 0; + else if(ret2 > 0) + return 1; + else + return -1; +} + +/* n: max items of table + * num: number being searched + * m: the position of value which is found or will be inserted + * ret: return 1 if found, otherwise 0 +*/ +static int bisearch(struct number_group *item, int n, num16_t *num, int *m) +{ + int i = 0; + int j = n - 1; + int ret; + + *m = 0; + while(i <= j) + { + *m = (i+j) / 2; + ret = numgrpcmp(&item[*m].start, &item[*m].end, num); + if(ret == 0) + return 1; + else if(ret > 0) + i = *m + 1; + else + j = *m - 1; + } + *m = i; + return 0; +} + +int numgrp_search(int *index, struct numgrp_table *table, num16_t *num) +{ + int m; + + if(table == NULL) + return 0; + if(bisearch(table->item, table->len, num, &m)) + { + *index = table->item[m].index; + return 1; + } + return 0; +} + +int numgrp_insert(struct numgrp_table *table, num16_t *start, num16_t *end, int index) +{ + int m, m2; + + if(numcmp(start, end) > 0) + { + printf("Start number > end number\n"); + return 0; + } + if(bisearch(table->item, table->len, start, &m)) + { + printf("Start number in exist group\n"); + return 0; + } + if(bisearch(table->item, table->len, end, &m2)) + { + printf("End number in exist group\n"); + return 0; + } + if(m != m2) + { + printf("Start-end contains other group\n"); + return 0; + } + memmove(&table->item[m+1], &table->item[m], sizeof(struct number_group)*(table->len-m)); + memcpy(&table->item[m].start, start, sizeof(num16_t)); + memcpy(&table->item[m].end, end, sizeof(num16_t)); + table->item[m].index = index; + table->len++; + return 1; +} + +int numgrp_delete(struct numgrp_table *table, num16_t *num) +{ + int m; + + if(bisearch(table->item, table->len, num, &m)) + { + memmove(&table->item[m], &table->item[m+1], sizeof(struct number_group)*(table->len-m-1)); + memset(&table->item[table->len-1], 0, sizeof(struct number_group)); + table->len--; + return 1; + } + return 0; +} + diff --git a/omc/plat/public/src/uwav/numgrp.h b/omc/plat/public/src/uwav/numgrp.h new file mode 100644 index 0000000..b26a7ac --- /dev/null +++ b/omc/plat/public/src/uwav/numgrp.h @@ -0,0 +1,29 @@ +#ifndef _UWAV_NUMGRP_H_ +#define _UWAV_NUMGRP_H_ + +#include "number.h" + +#define MAX_NUMBER_GROUP_TABLE 32 +#define MAX_NUMBER_GROUP_TABLE_SIZE 1024 + +struct number_group { + num16_t start; + num16_t end; + int index; +}; + +struct numgrp_table { + char name[32]; + int size; + int len; + struct number_group *item; +}; + +extern struct numgrp_table *assign_numgrp_table(char *name, int size);/* size: capability of table in unit of records */ +extern int delete_numgrp_table(struct numgrp_table *table); +extern int numgrp_search(int *index, struct numgrp_table *table, num16_t *num); +extern int numgrp_insert(struct numgrp_table *table, num16_t *start, num16_t *end, int index); +extern int numgrp_delete(struct numgrp_table *table, num16_t *num); + +#endif + diff --git a/omc/plat/public/ut/.copyarea.db b/omc/plat/public/ut/.copyarea.db new file mode 100644 index 0000000..cd1a861 --- /dev/null +++ b/omc/plat/public/ut/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut +2 +8 +4:main|2|0|0|0|7d2970a7bfa511dc85ad001c23e19543|0 +a:function.c|1|127d6449102|668|cbb8c74|832971f7bfa511dc85ad001c23e19543|0 +4:inet|2|0|0|0|80c97187bfa511dc85ad001c23e19543|0 +5:timer|2|0|0|0|7a396fffbfa511dc85ad001c23e19543|0 +8:bisearch|2|0|0|0|85897267bfa511dc85ad001c23e19543|0 +5:asn.1|2|0|0|0|8029714fbfa511dc85ad001c23e19543|0 +9:debug_api|2|0|0|0|83b97213bfa511dc85ad001c23e19543|0 +b:public_test|2|0|0|0|81f971bfbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/asn.1/.copyarea.db b/omc/plat/public/ut/asn.1/.copyarea.db new file mode 100644 index 0000000..fe2b26e --- /dev/null +++ b/omc/plat/public/ut/asn.1/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\asn.1 +2 +1 +9:asntest.c|1|127d6449b73|2613|a2fcc583|8029716bbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/asn.1/asntest.c b/omc/plat/public/ut/asn.1/asntest.c new file mode 100644 index 0000000..4b13d35 --- /dev/null +++ b/omc/plat/public/ut/asn.1/asntest.c @@ -0,0 +1,429 @@ +#include "./include/asn1.h" +#include +#include +#include +int test1(); +int test2(); +int test3(); +int test4(); +int test5(); +int test6(); +int test7(); +int test8(); +int test9(); +int test10(); +int test11(); +int test12(); +int showtlv(const char *tag_seq,ASN_BUF *asnbuf); +int main(int argc,char *argv[]) +{ + if(argc==2) + { + switch(atoi(argv[1])) + { + case 1: + test1(); + break; + case 2: + test2(); + break; + case 3: + test3(); + break; + case 4: + test4(); + break; + case 5: + test5(); + break; + case 6: + test6(); + break; + case 7: + test7(); + break; + case 8: + test8(); + break; + case 9: + test9(); + break; + case 10: + test10(); + break; + case 11: + test11(); + break; + case 12: + test12(); + break; + default: + printf("Out of range!\n"); + } + } + else + printf("Usage:asntest number\n"); + return 0; +} + +int test1() //Tag encoding/decoding test +{ + u_char msg_buf[50]; + int len; + ASN_BUF asnbuf; + + asn_encode(msg_buf,&asnbuf); + + len=add_null("2",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("2",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("32",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("32",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("129",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("129",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("2",0x80,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("2",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("32",0xC0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("32",&asnbuf)==1) + printf("decoding correctly\n"); + + return 1; +} + +int test2() +{ + u_char msg_buf[1024],pvalue[1024]; + ASN_BUF asnbuf; + + memset(pvalue,0xFF,1024); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",0,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",2,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",128,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",129,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",257,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + return 1; +} +int test3() +{ + u_char msg_buf[256]; + ASN_BUF asnbuf; + char oid[20]; + int len; + + //Boolean-----> + asn_encode(msg_buf,&asnbuf); + len=add_bool("1",0,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_bool("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_bool("1",1,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_bool("1",&asnbuf)); + //Integer-----> + asn_encode(msg_buf,&asnbuf); + len=add_int("1",2,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",257,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",-2,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",-259,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + //Object Identifier-----> + asn_encode(msg_buf,&asnbuf); + len=add_oid("1","2.100.6",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + get_oid("1",oid,&asnbuf); + printf("decoded value:%s\n",oid); + + asn_encode(msg_buf,&asnbuf); + len=add_oid("1","0.39.6",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + get_oid("1",oid,&asnbuf); + printf("decoded value:%s\n",oid); + return 1; +} +int test4() //encoding test +{ + u_char msg_buf[256]; + int c1=0,c2=1; + u_char d1[2]={0x22,0x22}; + u_char d2[2]={0x33,0x33}; + u_char b3[2]={0x44,0x44}; + u_char a2[2]={0x55,0x55}; + u_char a3[2]={0x66,0x66}; + int len; + ASN_BUF asnbuf; + + asn_encode_v3(msg_buf,128,&asnbuf); + len=add_int("1.0.2-1",c1,0,&asnbuf); + len=add_int("1.0.2-2",c2,0,&asnbuf); + len=add_tlv("1.0.1-3.0",2,d1,0x80,&asnbuf); + len=add_tlv("1.0.1-3.1",2,d2,0x80,&asnbuf); + len=add_tlv("1.1",2,b3,0x80,&asnbuf); + len=add_tlv("2",2,a2,0x80,&asnbuf); + len=add_tlv("3",2,a3,0x80,&asnbuf); + showbuf(msg_buf,len); + printf("decode......\n"); + asn_decode(msg_buf,3,&asnbuf); + showtlv("1.0.2-1",&asnbuf); + showtlv("1.0.2-2",&asnbuf); + showtlv("1.0.1-3.0",&asnbuf); + showtlv("1.0.1-3.1",&asnbuf); + showtlv("1.1",&asnbuf); + showtlv("2",&asnbuf); + showtlv("3",&asnbuf); + return 1; +} + +int test5() //decoding test(long length) +{ + u_char msg_buf[256]={0xA5,0x80, + 0x82,0x80, + 0x83,0x02,0x00,0x00, + 0x00,0x00, + 0x00,0x00, + 0xA6,0x80,0x82,0x02,0x11,0x11,0x00,0x00}; + ASN_BUF asnbuf; + asn_decode(msg_buf,2,&asnbuf); + showtlv("5.2.3",&asnbuf); + showtlv("6.2",&asnbuf); + showtlv("5.2",&asnbuf); + showtlv("6",&asnbuf); + return 1; +} + +int test6() //decoding test(indefinite length) +{ + u_char msg_buf[256]={0xA5,0x80, + 0xA2,0x81,0x82, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0xA3,0x02,0x01,0x01, + 0x00,0x00, + 0xA6,0x80,0x82,0x02,0x11,0x11,0x00,0x00}; + ASN_BUF asnbuf; + int temp; + asn_decode_v3(msg_buf,256,&temp,&asnbuf); + + showtlv("5.2",&asnbuf); + showtlv("5.3",&asnbuf); + showtlv("5",&asnbuf); + showtlv("6.2",&asnbuf); + return 1; +} + + + +int showtlv(const char *tag_seq,ASN_BUF *asnbuf) +{ + u_char tlvbuf[256]; + int len; + len=get_tlv(tag_seq,tlvbuf,asnbuf); + showbuf(tlvbuf,len); + return 1; +} + +int test7() //decoding test(long length) +{ + u_char msg_buf[256]={0x60,0x80, + 0x80,0x02,0x07,0x80, + 0xa1,0x80, + 0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x01,0x02, + 0x00,0x00, + 0x00,0x00}; + ASN_BUF asnbuf; + asn_decode(msg_buf,1,&asnbuf); + showtlv("0",&asnbuf); + showtlv("0.0",&asnbuf); + showtlv("0.1",&asnbuf); + showtlv("0.1.6",&asnbuf); + return 1; +} + +int test8() //decoding test(long length) +{ + u_char msg_buf[256]={0x10,0x03,0xaa,0xbb,0xcc}; + ASN_BUF asnbuf; + asn_decode(msg_buf,1,&asnbuf); + printf("tlvcount=%d\n",asnbuf.tlvcount); + showtlv("16",&asnbuf); + return 1; +} + +int test9() +{ + u_char msg_buf[256]={0x02,0x01,0xaa, + 0x04,0x02,0xbb,0xbb, + 0x04,0x02,0xcc,0xcc, + 0x04,0x02,0xdd,0xdd, + 0x02,0x01,0xaa, + 0x05,0x02,0x55,0xbb, + 0x05,0x02,0x55,0xcc, + 0x05,0x02,0x55,0xdd}; +// u_char mybuf[64]; +// int len; + int temp; + ASN_BUF asnbuf; + asn_decode_v3(msg_buf,30,&temp,&asnbuf); + + showtlv("2",&asnbuf); + showtlv("4-2",&asnbuf); + showtlv("4-3",&asnbuf); + showtlv("4-4",&asnbuf); + return 1; +} + +int test10() +{ + u_char msg_buf[256]={0xA0,0x80, + 0x04,0x01,0x21, + 0x30,0x80, + 0x30,0x80, + 0x83,0x01,0x11, + 0x84,0x01,0x07, + 0x85,0x05,0x81,0x21,0x84,0x00,0x94, + 0x86,0x01,0x00, + 0x00,0x00, + 0x00,0x00, + 0x00,0x00}; + u_char mybuf[64]; + int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + + len=get_tlv("0",mybuf,&asnbuf); + printf("0:"); + showbuf(mybuf,len); + + len=get_tlv("0.4",mybuf,&asnbuf); + printf("0.4:"); + showbuf(mybuf,len); + + len=get_tlv("0.16",mybuf,&asnbuf); + printf("0.16:"); + showbuf(mybuf,len); + + len=get_tlv("0.16.16.5",mybuf,&asnbuf); + printf("0.16.5:"); + showbuf(mybuf,len); + return 1; +} + +int test11() +{ + u_char msg_buf[256]={0x64,0x6A,0x49 + ,0x04,0x01,0x62,0x00,0x60,0x6B,0x80,0x28,0x80,0x06,0x07,0x00,0x11 + ,0x86,0x05,0x01,0x01,0x01,0xA0,0x80,0x61,0x80,0x80,0x02,0x07,0x80 + ,0xA1,0x80,0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x05,0x02,0x00,0x00 + ,0xA2,0x80,0x02,0x01,0x00,0x00,0x00,0xA3,0x80,0xA1,0x80,0x02,0x01 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x6C,0x26,0xA2,0x80,0x02,0x01,0x00,0x30,0x80,0x02,0x01,0x16,0x30 + ,0x80,0x04,0x08,0x64,0x00,0x92,0x00,0x00,0x00,0x00,0xF1,0x04,0x08 + ,0x91,0x44,0x57,0x25,0x31,0x06,0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 + }; +// u_char mybuf[64]; +// int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + return 1; +} + +int test12() +{ + u_char msg_buf[256]={0xA1,0x0E, + 0x01,0x01,0x01, + 0x02,0x80,0x02,0x01,0x01,0x00,0x00, + 0x02,0x02,0x01,0x02 + }; +// u_char mybuf[64]; +// int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + return 1; +} + diff --git a/omc/plat/public/ut/bisearch/.copyarea.db b/omc/plat/public/ut/bisearch/.copyarea.db new file mode 100644 index 0000000..9e261d6 --- /dev/null +++ b/omc/plat/public/ut/bisearch/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\bisearch +2 +1 +f:bisearch_test.c|1|127d6449f4b|1121|34301804|86197283bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/bisearch/bisearch_test.c b/omc/plat/public/ut/bisearch/bisearch_test.c new file mode 100644 index 0000000..d9ec9ff --- /dev/null +++ b/omc/plat/public/ut/bisearch/bisearch_test.c @@ -0,0 +1,149 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic Tester */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ +#include "../../iptrans/src/include/iptrans.h" +#include "./include/bisearch.h" + +FILE *fp = NULL; +BiSearchArray bsearch_array; + + +int GetIdleNode(int *nDUIndex) +{ + if( bsearch_array.nArrayCount >= bsearch_array.nArrayTotalLen ) + return 0; + *nDUIndex = (rand()*19)%bsearch_array.nArrayTotalLen; + return 1; +} + +void logarray ( BiSearchArray * pBiArray, char *op ) +{ + BiSearch *pBS; + LL lastkey = 0; + int nPos = -1; + char buf[4096]; + char tmp_str[512]; + int i; + buf[0] = '\0'; + + sprintf ( buf, "Array Contents:[total :%d]\n" , pBiArray->nArrayCount); + for ( i = 0; i < pBiArray->nArrayTotalLen; i++ ) + { + pBS = pBiArray->pBiArray + i; + sprintf ( tmp_str, "{%-3u,(%-3llu,%-3u)} ", i, pBS->llKey, pBS->nDUPosIndex ); + strcat ( buf, tmp_str ); + if( i % 6 == 5 ) + { + strcat ( buf, "\n" ); + } + if( lastkey > pBS->llKey && i < pBiArray->nArrayCount ) + nPos = i; + lastkey = pBS->llKey; + } + //if( nPos != -1 ) + { + sprintf ( tmp_str, "\nERR Pos: %d\n\n", nPos ); + strcat ( buf, tmp_str ); + fprintf ( fp, buf ); + } +} + +#define log() logarray( &bsearch_array , op) + +int main ( int argc, char *argv[] ) +{ + + char op[32]; + char buff[64]; + int i; + srand((int)time(0)); + + if( ( fp = fopen ( "./log.txt", "w" ) ) == NULL ) + { + printf ( "Open File Fail\n" ); + return 0; + } + fprintf ( fp, "======================\n" ); + fprintf ( fp, "|| BiSearch Test ||\n" ); + fprintf ( fp, "======================\n\n\n" ); + + for ( i = 0; i < 32; i++ ) + { + op[i] = 'A' + ( i * 3 + 11 ) % 26; + buff[i] = op[i] + ( i * 7 + 19 ) % 26; + } + + BISearchReg ( &bsearch_array, 64 ,GetIdleNode ); + + for ( i = 0; i < 30; i++ ) + { + int key = ( ( i * 11 ) % 5 ) * ( i % 5 ) - 3 * ( i % 11 ) + 39; + int value = (3 * i + 1)%bsearch_array.nArrayTotalLen; + + fprintf ( fp, "Insert(%-3d, %-3d)\n", key, value ); + BISInsert ( &bsearch_array, key, value ); + log(); + } + log(); + + for ( i = 0; i < 128; i++ ) + { + int k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + + k = k % 999; + fprintf ( fp, "=====>>Insert(%d, %d)\n", k, 2 * i ); + BISInsert ( &bsearch_array, k, (2 * i+rand() % 13 * 19 + i*19)%bsearch_array.nArrayTotalLen); + fprintf ( fp, "\n" ); + log(); + + k = ( ( 20 - i ) % 3 ) * 9 - ( 3 * ( 20 - i ) ) + 9*128; + k = k % 999; + fprintf ( fp, "search index: %d" , k ); + if( -1 != GetDUIndex( &bsearch_array ,k ) ) + { + fprintf ( fp, "<<=====Delete Key %d\n", k ); + BISDelete ( &bsearch_array , k ); + } + else + fprintf ( fp, "<<=====Delete Fail , not found [%d]", k ); + fprintf ( fp, "\n" ); + log(); + + } + + for( i = 0 ; i < 128 ; i++ ) + { + int nDUIndex = 0; + int k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + + k = k % 999; + BISSearchMng( &bsearch_array , BIS_INSERT , k , &nDUIndex ); + fprintf ( fp, "=====>>Insert(%d, %d)\n", k, nDUIndex ); + fprintf ( fp, "\n" ); + log(); + + k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + k = k % 999; + fprintf ( fp, "search index: %d" , k ); + if( -1 != GetDUIndex( &bsearch_array ,k ) ) + { + fprintf ( fp, "<<=====Delete Key %d\n", k ); + BISSearchMng( &bsearch_array , BIS_DELETE , k ,&nDUIndex); + } + else + fprintf ( fp, "<<=====Delete Fail , not found [%d]", k ); + + fprintf ( fp, "\n" ); + log(); + + } + //fclose ( fp ); + BISearchUnReg ( &bsearch_array); + return 0; +} diff --git a/omc/plat/public/ut/debug_api/.copyarea.db b/omc/plat/public/ut/debug_api/.copyarea.db new file mode 100644 index 0000000..8959c9e --- /dev/null +++ b/omc/plat/public/ut/debug_api/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\debug_api +2 +2 +5:debug|1|127d6449db5|2e60|abcdd68a|8459722fbfa511dc85ad001c23e19543|0 +10:wxc_debug_test.c|1|127d6449e32|9ec|7232704a|84e9724bbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/debug_api/debug b/omc/plat/public/ut/debug_api/debug new file mode 100644 index 0000000..53d4011 Binary files /dev/null and b/omc/plat/public/ut/debug_api/debug differ diff --git a/omc/plat/public/ut/debug_api/wxc_debug_test.c b/omc/plat/public/ut/debug_api/wxc_debug_test.c new file mode 100644 index 0000000..e1e18e5 --- /dev/null +++ b/omc/plat/public/ut/debug_api/wxc_debug_test.c @@ -0,0 +1,125 @@ +////////////////////////////////////////////////// +//Title : wxc_debug.c +//Auhtor : Liu Wei +//Desc : wxc debug api implemetation +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#include "stdio.h" +#include "assert.h" +#include "string.h" +#include "stdlib.h" +#include +#include + +void dump(int signo) +{ + char buf[1024]; + char cmd[1024]; + FILE *fh; + + snprintf(buf, sizeof(buf), "/proc/%d/cmdline", getpid()); + if(!(fh = fopen(buf, "r"))) + exit(0); + if(!fgets(buf, sizeof(buf), fh)) + exit(0); + fclose(fh); + if(buf[strlen(buf) - 1] == '\n') + buf[strlen(buf) - 1] = '\0'; + snprintf(cmd, sizeof(cmd), "gdb %s %d", buf, getpid()); + system(cmd); + + exit(0); +} + +void WxcBackTrace() +{ + int i; + void * array[25]; + int nSize = backtrace(array, 25); + char ** symbols = backtrace_symbols(array, nSize); + + for (i = 0; i < nSize; i++) + { + printf("%s \n" , symbols[i]); + } + free(symbols); +} + +typedef unsigned char BYTE; + +#define WxcAssert(uVal,pStr) \ + if(!(uVal)) \ + { \ + WxcBackTrace(); \ + } \ + assert( uVal && pStr ); \ + +void sprintf_bcd( const BYTE *pBcdBuff , int nBcdLen , char *pStrBuff , int nStrBuffSize ) +{ + int i ,len = 0; + int nChar; + + nChar = ( nBcdLen % 8 )* 3 + ( nBcdLen / 8 ) * 25 + 1 ; + + WxcAssert((nChar < nStrBuffSize),"sprint bcd string buffer flow"); + + for( i = 1 ; i <= nBcdLen; i ++ ) + { + sprintf ( pStrBuff + len , "%02X ", pBcdBuff[i-1] ); + len += 3; + if( 0 == (i % 16) ) + { + strcat ( pStrBuff , "\n"); + len++; + } + else if( 0 == (i % 8) ) + { + strcat ( pStrBuff , " "); + len++; + } + } + if( 0 != (len % 50) ) + { + strcat ( pStrBuff , "\n"); + } +} + +void testdump(char *p) +{ + *p =0; +} + +void main() +{ + BYTE aBCDBuff[128]; + char temp[256] ; + int i , j; + char *p ; + + p = NULL; + + signal(SIGSEGV, &dump); + + for( i = 0 ; i < 128 ; i ++ ) + { + if( i < 80 ) + aBCDBuff[i] = (BYTE)(1 + i) ; + else + aBCDBuff[i] = (BYTE)(256 - i*2) ; + } + + for( j = 30 ; j < 100 ; j+=7 ) + { + sprintf_bcd(aBCDBuff , j , temp , 256 ); + printf("BCD:\r\n%s\r\n", temp); + } + + testdump(p); + getchar(); +} diff --git a/omc/plat/public/ut/function.c b/omc/plat/public/ut/function.c new file mode 100644 index 0000000..668baf8 --- /dev/null +++ b/omc/plat/public/ut/function.c @@ -0,0 +1,87 @@ +/* public function c file */ +/* written by Liu Zhiguo 2002-03-26 */ +/* version 1.0 */ +/* -------------------------------- */ + +#include "./include/includes.h" +#include "./include/public.h" +#include "./include/pub_debug.h" + +# ifndef S_SPLINT_S +/*@ignore@*/ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer ascii code to bcd code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + char flag=0; + + if (ascii_buf == NULL) + { + for (i=0;i='a') + ch -= 'a' - 10; + else if (ch>='A') + ch -= 'A' - 10; + else + ch -= '0'; + if (flag) + { + if (i & 1) + *bcd_buf = ch << 4; + else + *(bcd_buf++) |= ch & 0x0f; + } + else + { + if (i & 1) + *(bcd_buf++) |= ch & 0x0f; + else + *bcd_buf = ch << 4; + } + } +} +*/ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer bcd code to ascii code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len) +{ + int i; + char ch; + + if (bcd_buf == NULL) + { + for (i=0;i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} +*/ + +/*@end@*/ +#endif diff --git a/omc/plat/public/ut/inet/.copyarea.db b/omc/plat/public/ut/inet/.copyarea.db new file mode 100644 index 0000000..10fa03b --- /dev/null +++ b/omc/plat/public/ut/inet/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\inet +2 +1 +f:pub_inet_test.c|1|127d6449c1f|3c61|9ffc8ccc|815971a3bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/inet/pub_inet_test.c b/omc/plat/public/ut/inet/pub_inet_test.c new file mode 100644 index 0000000..789ea3f --- /dev/null +++ b/omc/plat/public/ut/inet/pub_inet_test.c @@ -0,0 +1,646 @@ +////////////////////////////////////////////////// +//Title : pub_inet_test.c +//Auhtor : Liu Wei +//Desc : public ipnet function test +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef unsigned char u8; +typedef unsigned int u32; +typedef unsigned short u16; + +#define MAXINTERFACES 16 + +typedef struct EIF +{ + u32 dIfIP; + u8 uIfState; +} +EIF; + +typedef struct IF_ADDR +{ + EIF tIfEntity[MAXINTERFACES]; + u8 uIfNum; +} +IfAddr; + +int GetNetIfInfo ( IfAddr * pIfAddr ) +{ + int fd; + struct ifreq buf[MAXINTERFACES]; + struct arpreq arp; + struct ifconf ifc; + + pIfAddr->uIfNum = 0; + + if( ( fd = socket ( AF_INET, SOCK_DGRAM, 0 ) ) >= 0 ) + { + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = ( caddr_t ) buf; + if( !ioctl ( fd, SIOCGIFCONF, ( char * ) &ifc ) ) + { + int i; + + pIfAddr->uIfNum = ifc.ifc_len / sizeof ( struct ifreq ); + pIfAddr->uIfNum = pIfAddr->uIfNum % MAXINTERFACES; + for ( i = 0; i < pIfAddr->uIfNum; i++ ) + { + ioctl ( fd, SIOCGIFFLAGS, ( char * ) &buf[i] ); + pIfAddr->tIfEntity[i].uIfState = buf[i].ifr_flags & IFF_UP; + if( !( ioctl ( fd, SIOCGIFADDR, ( char * ) &buf[i] ) ) ) + { + pIfAddr->tIfEntity[i].dIfIP = ( ( struct sockaddr_in * ) + ( &buf[i].ifr_addr ) )->sin_addr.s_addr; + } + } + } + + } + close ( fd ); + return pIfAddr->uIfNum; +} + + +#define PACKET_SIZE 4096 +#define MAX_NO_PACKETS 3 + +struct sockaddr_in dest_addr; +struct sockaddr_in from; +struct timeval tvrecv; + +typedef void PingCallBack( int nPingResult ); + +typedef struct ICMP_SERVICE +{ + u8 uSrvState; + u8 uPingResult; + u8 uIcmpState; + u8 uPackNo; + u8 uDataLen; + u8 nPackNumSend; + u8 nPackNumRecv; + u8 aSendBuff[PACKET_SIZE]; + u8 aRecvBuff[PACKET_SIZE]; + u32 wSockfd; + pid_t tPid; + struct protoent *pProtoent; + PingCallBack *fCallBack; +} +IcmpSrv; + +IcmpSrv tIcmpSrvEntity; + +//校验和算法 +u16 IcmpCheckSum ( u16 *addr, int len ) +{ + int nleft = len; + int sum = 0; + u16 *w = addr; + u16 answer = 0; + + //把ICMP报头二进制数据以2字节为单位累加起来 + while ( nleft > 1 ) + { + sum += *w++; + nleft -= 2; + } + + //若ICMP报头为奇数个字节,会剩下最后一字节。 + //把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加 + if( nleft == 1 ) + { + *( unsigned char * ) ( &answer ) = *( unsigned char * ) w; + sum += answer; + } + + sum = ( sum >> 16 ) + ( sum & 0xffff ); + sum += ( sum >> 16 ); + answer = ~sum; + + return answer; +} + +//设置ICMP报头 +int IcmpPacking ( IcmpSrv *pIS ) +{ + int i, packsize; + struct icmp *icmp; + struct timeval *tval; + + icmp = ( struct icmp * ) pIS->aSendBuff; + icmp->icmp_type = ICMP_ECHO; + icmp->icmp_code = 0; + icmp->icmp_cksum = 0; + icmp->icmp_seq = pIS->nPackNumSend; + icmp->icmp_id = pIS->tPid; + packsize = 8 + pIS->uDataLen; + + //记录发送时间 + tval = ( struct timeval * ) icmp->icmp_data; + gettimeofday ( tval, NULL ); + + icmp->icmp_cksum = IcmpCheckSum ( (u16 *)icmp, packsize ); + + return packsize; +} + +//剥去ICMP报头 +int IcmpUnPack ( u8 *buf, int len , IcmpSrv *pIS ) +{ + int i, nIpHdrLen; + struct ip *pIP; + struct icmp *icmp; + struct timeval *tvSend; + struct timeval tvRecv; + double rtt; + + + gettimeofday ( &tvRecv, NULL ); + pIP = ( struct ip * ) buf; + //求ip报头长度,即ip报头的长度标志乘4 + nIpHdrLen = pIP->ip_hl << 2; + + //越过ip报头,指向ICMP报头 + icmp = ( struct icmp * ) ( buf + nIpHdrLen ); + + //ICMP报头及ICMP数据报的总长度 + len -= nIpHdrLen; + + if( len < 8 ) + //小于ICMP报头长度则不合理 + { + printf ( "ICMP packets's length is less than 8 " ); + return 0; + } + + //确保所接收的是我所发的的ICMP的回应 + if( ( icmp->icmp_type == ICMP_ECHOREPLY ) && ( icmp->icmp_id == pIS->tPid ) ) + { + tvSend = ( struct timeval * ) icmp->icmp_data; + + rtt = ( tvRecv.tv_sec * 1000 + tvRecv.tv_usec / 1000 ) - + ( tvSend->tv_sec * 1000 + tvSend->tv_usec / 1000 ); + + printf ( "%d byte from %s: icmp_seq=%u ttl=%d rtt=%.3f ms \n" + , len, inet_ntoa ( from.sin_addr ) + , icmp->icmp_seq, pIP->ip_ttl, rtt + ); + return 1; + } + return 0; +} + +void IcmpStatis ( IcmpSrv *pIS ) +{ + int nSend , nRecv ; + + nSend = pIS->nPackNumSend; + nRecv = pIS->nPackNumRecv; + + printf ( " --------------------PING statistics------------------- \n" ); + printf ( "%d packets transmitted, %d received , %%%d lost \n\n" + , nSend, nRecv, ( nSend - nRecv ) / nSend * 100 ); + close ( pIS->wSockfd ); + pIS->uSrvState = 0; +} + +//发送三个ICMP报文 +int IcmpSend ( IcmpSrv *pIS ) +{ + int nSize; + + if ( pIS->nPackNumSend < MAX_NO_PACKETS ) + { + pIS->nPackNumSend++; + nSize = IcmpPacking ( pIS ); + + //设置ICMP报头 + if( sendto ( pIS->wSockfd, pIS->aSendBuff, nSize, 0, + ( struct sockaddr * ) &dest_addr, sizeof ( dest_addr ) ) < 0 ) + { + perror ( "sendto error" ); + return 0; + } + printf("[IcmpSend] : Send icmp Pack %d \n" , pIS->nPackNumSend); + return 1; + } + return 0; +} + +//接收所有ICMP报文 +void IcmpRecv ( IcmpSrv *pIS ) +{ + int n, fromlen; + extern int errno; + + + fromlen = sizeof ( from ); + while ( pIS->nPackNumRecv < pIS->nPackNumSend ) + { + if( ( n = recvfrom ( pIS->wSockfd, pIS->aRecvBuff, sizeof ( pIS->aRecvBuff ), + 0, ( struct sockaddr * ) &from, &fromlen ) ) < 0 ) + + { + if( errno == EINTR ) + continue; + perror ( "recvfrom error" ); + continue; + } + if( IcmpUnPack ( pIS->aRecvBuff, n , pIS ) == -1 ) + continue; + pIS->nPackNumRecv++; + } +} + +int PingInit ( IcmpSrv *pIS , int nDataLen ) +{ + memset( pIS , 0 , sizeof(IcmpSrv) ); + pIS->uSrvState = 0; + + pIS->uDataLen = 56; + + + if( ( pIS->pProtoent = getprotobyname ( "icmp" ) ) == NULL ) + { + perror ( "getprotobyname" ); + exit ( 1 ); + } + + // 回收root权限,设置当前用户权限 + setuid ( getuid ( ) ); + + //获取main的进程id,用于设置ICMP的标志符 + pIS->tPid = getpid ( ); + +} + + +int PingTimer ( IcmpSrv *pIS ) +{ + if( pIS->uSrvState ) + { + IcmpRecv( pIS ); + switch( pIS->uIcmpState ) + { + case 1: + case 2: + case 3: + IcmpSend( pIS ); + pIS->uIcmpState++; + break; + default: + if( pIS->nPackNumRecv >= 3 ) + { + IcmpStatis( pIS ); + pIS->fCallBack( 1 ); + } + if( pIS->uIcmpState++ > 200 ) + { + IcmpStatis( pIS ); + pIS->fCallBack( 0 ); + } + break; + } + } +} + +int PingStart( IcmpSrv *pIS , char *sIP , PingCallBack fCallBack ) +{ + int nSize; + struct hostent *pHost; + //struct in_addr *pInAddr; + u32 nInetAddr; + + + if( pIS->uSrvState ) + { + return 0; + } + + pIS->fCallBack = fCallBack; + + //生成使用ICMP的原始套接字,这种套接字只有root才能生成 + if( ( pIS->wSockfd = socket ( AF_INET, SOCK_RAW, pIS->pProtoent->p_proto ) ) < 0 ) + { + perror ( "socket error" ); + exit ( 1 ); + } + + //扩大套接字接收缓冲区到50K这样做主要为了减小接收缓冲区溢出的 + //的可能性, 若无意中ping会引来大量应答 + setsockopt ( pIS->wSockfd, SOL_SOCKET, SO_RCVBUF, &nSize, sizeof ( nSize ) ); + bzero ( &dest_addr, sizeof ( dest_addr ) ); + dest_addr.sin_family = AF_INET; + + //判断是主机名还是ip地址 + nInetAddr = inet_addr ( sIP ) ; + if( nInetAddr == INADDR_NONE ) + { + if( ( pHost = gethostbyname ( sIP ) ) == NULL ) //是主机名 + { + perror ( "gethostbyname error" ); + exit ( 1 ); + } + memcpy ( ( char * ) &dest_addr.sin_addr, pHost->h_addr, pHost->h_length ); + } + else //是ip地址 + { + dest_addr.sin_addr.s_addr = nInetAddr; + //memcpy( (char *)&dest_addr,(char *)&nInetAddr,host->h_length); + } + printf ( "PING %s(%s): %d bytes data in ICMP packets. \n", sIP + , inet_ntoa ( dest_addr.sin_addr ) , pIS->uDataLen ); + + pIS->uSrvState = 1 ; + pIS->uIcmpState = 1; + +} + +//打印ip报文的信息 +void printIP ( char *packet, int len ) +{ + struct sockaddr_in addr_src, addr_dst; + struct ip *pip = ( struct ip * ) packet; + + printf ( "ip head len:%d ", pip->ip_hl << 2 ); + printf ( "ip len:%d ", ntohs ( pip->ip_len ) ); + printf ( "ip pro id:%d ", pip->ip_p ); + printf ( "ip ttl:%d ", pip->ip_ttl ); + printf ( "ip offset:%d ", ntohs ( pip->ip_off ) & IP_OFFMASK ); + + memset ( &addr_src, 0, sizeof ( struct sockaddr_in ) ); + memset ( &addr_dst, 0, sizeof ( struct sockaddr_in ) ); + memcpy ( &addr_src, &pip->ip_src, sizeof ( struct sockaddr_in ) ); + memcpy ( &addr_dst, &pip->ip_dst, sizeof ( struct sockaddr_in ) ); + printf ( "src ip:%x ", addr_src.sin_addr ); + printf ( "dst ip:%x ", addr_dst.sin_addr ); +} + +void NetCapPing( int nRet ) +{ + if( nRet ) + { + printf("Host is rearchable\n"); + } + else + { + printf("Host is not rearchable\n"); + } +} + +static char *pStrEqTok = NULL; +static u8 uStrEqState = 0; + +#define CNULL '\0' +#define STR_CHECK_END(str,ch) ( str[strlen(str)-1] == ch ) +#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL ) + +void StrTrimMoreSpace(char *pStr ) +{ + char *pSrc , *pDst , *pCh; + + pDst = pStr; + pCh = pSrc = strdup( pStr ); + + for( ; *pSrc ; pSrc++ ) + { + if( !( isspace(*pSrc) && isspace( *(pSrc+1) ) ) ) + { + *pDst++ = *pSrc; + } + } + *pDst = CNULL; +} + +char *StrEqTok( char *pStr ) +{ + char *p, *pCh; + char *pDel = " "; + + pCh = NULL; + + if( pStr == NULL ) + { + pStr = pStrEqTok; + } + else + { + pStr += strspn (pStr, pDel); + if (*pStr == '\0') + { + pStrEqTok = NULL; + return NULL; + } + StrTrimMoreSpace( pStr ); + } + + if( pStr == NULL ) + { + return NULL; + } + + uStrEqState = uStrEqState > 2 ? 0 : uStrEqState; + + pCh = strpbrk (pStr, pDel ); + if( pCh == NULL ) + { + pStrEqTok = NULL; + pCh = pStr; + } + else + { + pStrEqTok = pCh + 1; + *pCh = CNULL; + pCh = pStr; + } + + p = strchr( pCh , '='); + if( p == NULL ) + { + if( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + + if( uStrEqState == 0 || uStrEqState == 2 ) + { //expres left and right + uStrEqState++; + return pCh; + } + else + { //Miss '=' + goto STREQTOK_CLEAN_UP; + } + } + else + { + if( uStrEqState == 0 && STR_CHECK_END( pCh , '=') ) + { //expres left and '=' + uStrEqState+=2; + STR_CUT_LAST(pCh); + return pCh; + } + else if( uStrEqState == 1 && pCh[0] == '=') + { //'=' meet + if( pCh[1] == CNULL ) + { + if( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + pStr = pStrEqTok; + pCh = strpbrk (pStr, pDel); + if( pCh == NULL ) + { + pStrEqTok = NULL; + pCh = pStr; + } + else + { + pStrEqTok = pCh + 1; + *pCh = CNULL; + pCh = pStr; + } + uStrEqState = 3; + return pCh; + + } + else + { //expres '=' and right + uStrEqState = 3; //all meet + return ++pCh; + } + } + else if( uStrEqState == 0 ) + { //expres left and '=' and right + if( pStrEqTok != NULL ) + { + *(pStrEqTok -1) = ' '; + } + pStrEqTok = p + 1; + *p = CNULL; + uStrEqState = 2; + return pCh; + } + else + { + goto STREQTOK_CLEAN_UP; + } + } +STREQTOK_CLEAN_UP: + pStrEqTok = NULL; + uStrEqState = 0; + return NULL; +} + + +int main ( ) +{ + int i, ret = 0; + IfAddr tIfAddr; + IcmpSrv tIcmpSrv; + char tmpStr[80]; + + ret = GetNetIfInfo ( &tIfAddr ); + + printf ( "Interface num :%d \n\n", ret ); + for ( i = 0; i < ret; i++ ) + { + printf ( "If %d : state : %d ip : %s \n\n" + , i, tIfAddr.tIfEntity[i].uIfState + , inet_ntoa ( *((struct in_addr* )&tIfAddr.tIfEntity[i].dIfIP )) + ); + } + + #define STR(s) #s + printf(STR(if(NOTSO(a)) return 0\n)); + + #define FPOS( type, field ) /*lint -e545 */ ( (u32) &(( type *) 0)-> field ) /*lint +e545 */ + + + #define FSIZ( type, field ) sizeof( ((type *) 0)->field ) + + printf("Pos : %ld \n" , FPOS(IfAddr ,uIfNum ) ); + printf("Size : %ld \n" , FSIZ(IfAddr ,uIfNum ) ); + printf("Pos : %ld \n" , FPOS(IfAddr ,tIfEntity ) ); + printf("Size : %ld \n" , FSIZ(IfAddr ,tIfEntity ) ); + printf("Pos : %ld \n" , FPOS(EIF ,dIfIP ) ); + printf("Size : %ld \n" , FSIZ(EIF ,dIfIP ) ); + printf("Pos : %ld \n" , FPOS(EIF ,uIfState ) ); + printf("Size : %ld \n" , FSIZ(EIF ,uIfState ) ); + printf("Pos : %ld \n" , FPOS(IcmpSrv ,nPackNumSend ) ); + printf("Size : %ld \n" , FSIZ(IcmpSrv ,nPackNumSend ) ); + printf("Pos : %ld \n" , FPOS(IcmpSrv ,aSendBuff ) ); + printf("Size : %ld \n" , FSIZ(IcmpSrv ,aSendBuff ) ); + + printf("Please input ip and port : "); + + fgets( tmpStr, 80 ,stdin ); + + printf("%s\n", tmpStr); + if( STR_CHECK_END(tmpStr , '\n' ) ) + { + STR_CUT_LAST(tmpStr ); + } + //StrTrimMoreSpace(tmpStr); + //printf("trim space : \n%s\n" ,tmpStr ); + + { + char *p = NULL; + u8 uFlag = 0; + + p = StrEqTok(tmpStr); + printf( "Name: %-20s " , p); + for( ; p = StrEqTok(NULL); ) + { + uFlag = uFlag ? 0 : 1; + if( uFlag ) + { + printf( "Valu: %-20s \n" , p); + } + else + { + printf( "Name: %-20s " , p); + } + } + } + printf("\n\n"); + PingInit( &tIcmpSrv , 56 ); + + ret = PingStart( &tIcmpSrv , "172.18.99.1" , NetCapPing ); + if( !ret ) + { + printf("ping is processing\n"); + } + + while(1) + { + PingTimer( &tIcmpSrv ); + sleep ( 1 ); + //每隔一秒发送一个ICMP报文 + } + return 1; +} diff --git a/omc/plat/public/ut/main/.copyarea.db b/omc/plat/public/ut/main/.copyarea.db new file mode 100644 index 0000000..21fbfff --- /dev/null +++ b/omc/plat/public/ut/main/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\main +2 +4 +3:bin|2|0|0|0|7e5970fbbfa511dc85ad001c23e19543|0 +3:src|2|0|0|0|7d2970c3bfa511dc85ad001c23e19543|0 +3:obj|2|0|0|0|7f997133bfa511dc85ad001c23e19543|0 +8:Makefile|1|127d64498c3|b99|d5b3c874|7ef97117bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/main/Makefile b/omc/plat/public/ut/main/Makefile new file mode 100644 index 0000000..6c0aba1 --- /dev/null +++ b/omc/plat/public/ut/main/Makefile @@ -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 = publictest +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = exef +CFG = debug + +PLT_LIB = public +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../../../plat +APP_PATH = ../../../../mss + +OBJ_ADD = +TEST_OBJ_PATH = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = on +COVER_NEED = +COVER_REPORT_PATH = ./ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules + + + diff --git a/omc/plat/public/ut/main/src/.copyarea.db b/omc/plat/public/ut/main/src/.copyarea.db new file mode 100644 index 0000000..36f1ef6 --- /dev/null +++ b/omc/plat/public/ut/main/src/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\main\src +2 +1 +6:main.c|1|127d6449ab7|18f|9e99666e|7dc970dfbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/main/src/main.c b/omc/plat/public/ut/main/src/main.c new file mode 100644 index 0000000..9a82b94 --- /dev/null +++ b/omc/plat/public/ut/main/src/main.c @@ -0,0 +1,19 @@ +////////////////////////////////////////////////// +//Title : main.c +//Auhtor : Liu Wei +//Desc : public function test +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "../../src/include/includes.h" +#include "../../src/include/public.h" +#include "../../src/include/function.h" + +int main() +{ + return 1; +} diff --git a/omc/plat/public/ut/public_test/.copyarea.db b/omc/plat/public/ut/public_test/.copyarea.db new file mode 100644 index 0000000..1f3034e --- /dev/null +++ b/omc/plat/public/ut/public_test/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\public_test +2 +1 +d:public_test.c|1|127d6449cea|ff|b2a744c6|828971dbbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/public_test/public_test.c b/omc/plat/public/ut/public_test/public_test.c new file mode 100644 index 0000000..e91d7c7 --- /dev/null +++ b/omc/plat/public/ut/public_test/public_test.c @@ -0,0 +1,15 @@ +/* public test c file */ +/* Written by Liu Zhiguo 2002-03-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "./include/includes.h" +#include "./include/public.h" +#include "./include/function.h" + + + +int main() +{ + return 1; +} diff --git a/omc/plat/public/ut/timer/.copyarea.db b/omc/plat/public/ut/timer/.copyarea.db new file mode 100644 index 0000000..66865be --- /dev/null +++ b/omc/plat/public/ut/timer/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\public\ut\timer +2 +5 +c:wxc_tmtest.c|1|127d6449671|bee|4b8d38e9|7c99708bbfa511dc85ad001c23e19543|0 +3:bin|2|0|0|0|7b697053bfa511dc85ad001c23e19543|0 +2:ut|2|0|0|0|7ac9701bbfa511dc85ad001c23e19543|0 +8:Makefile|1|127d6449587|6c9|7ebea4e5|7bf9706fbfa511dc85ad001c23e19543|0 +3:doc|2|0|0|0|7ac97037bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public/ut/timer/Makefile b/omc/plat/public/ut/timer/Makefile new file mode 100644 index 0000000..b1b556c --- /dev/null +++ b/omc/plat/public/ut/timer/Makefile @@ -0,0 +1,72 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for wxc2 module ## +## --By Wei Liu 2007/04/11 ## +## ## +##----------------------------------------------------------## + + +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +##Module Name +MODULE = tmtest + +#BUILD = lib/exef +BUILD = exef + +#CFG = debug / release +CFG = debug + +#Source file path +SRC_PATH= ./ + +#include file path +INC_PATH= ./ + +#extend wxc2plat module lib need +WXC2_PLT_LIB= public + +#extend wxc2plat module lib need +WXC2_APP_LIB= + +#extend wxc2plat path default to ./wxc2plat +WXC2_PLT_PATH = ../../../../wxc2plat + +#extend wxc2plat path default to ./wxc2app +WXC2_APP_PATH = + +#extend obj needed +CFG_OBJ = + +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +#gcc flag show on/off +CCFLAG_SWITCH = on + +#customer debug version flag add for compile +DEBUG_CFLAGS_ADD = -D_MSCR83 -D_DEVELOPER + +#customer release version flag add for compile +RELEASE_CFLAGS_ADD = -D_MSCR83 + +#need cover fucntion of PTF for test = YES/NO +COVER_NEED = + +#cover fucntion output path of PTF for test +COVER_REPORT_PATH = ./ut/ut_doc/output + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/public/ut/timer/wxc_tmtest.c b/omc/plat/public/ut/timer/wxc_tmtest.c new file mode 100644 index 0000000..17c74e3 --- /dev/null +++ b/omc/plat/public/ut/timer/wxc_tmtest.c @@ -0,0 +1,155 @@ + +#include "assert.h" +#include "../../src/include/includes.h" +#include "../../src/include/public.h" +#include "../../src/include/wxc_timer.h" + + +u32 hlr_timer_flag; +u32 hlr_20ms_flag; + +void system_init ( void ) +{ + sleep ( 3 ); + hlr_timer_flag = 0; + hlr_20ms_flag = 0; +} + +void timer_callback ( ) +{ + hlr_20ms_flag++; + hlr_timer_flag++; + printf("10 ms call back : %d\n" , hlr_timer_flag); +} + +void set_timer ( ) +{ + struct sigaction act; + struct itimerval value; + struct itimerval old_value; + + value.it_interval.tv_sec = 0; + value.it_interval.tv_usec = 10000; // 10 ms + value.it_value.tv_sec = 0; + value.it_value.tv_usec = 10000; // 10 ms + act.sa_handler = timer_callback; + sigemptyset ( &act.sa_mask ); + act.sa_flags = 0; + if( sigaction ( SIGALRM, &act, NULL ) == -1 ) + { + printf ( "Timer error\n" ); + exit ( 0 ); + } + setitimer ( ITIMER_REAL, &value, &old_value ); + iopl ( 3 ); +} + +void tm_app_callback_10ms ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_1s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_50s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_5000s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + + +void tm_app_init ( ) +{ + +} + +int app_state; +WxcTimer tTimer10ms; +WxcTimer tTimer1s; +WxcTimer tTimer50s; +WxcTimer tTimer5000s; + +typedef enum TMTEST_STATE +{ + APP_REGSITER, + APP_START, + APP_TIMEROUT, + APP_STOP, +} +TM_STATE; + + +void tm_app_test ( ) +{ + + + switch ( app_state ) + { + case APP_REGSITER: + tTimer10ms.dExpires = 1; + tTimer10ms.dSuitNumber = 1; + tTimer10ms.pFunc = &tm_app_callback_10ms; + tTimer10ms.dData = 0; + TimerAdd ( &tTimer10ms ); + + tTimer1s.dExpires = 100; + tTimer1s.dSuitNumber = 10; + tTimer1s.pFunc = &tm_app_callback_1s; + tTimer1s.dData = 0; + TimerAdd ( &tTimer1s ); + + tTimer50s.dExpires = 5000; + tTimer50s.dSuitNumber = 100; + tTimer50s.pFunc = &tm_app_callback_50s; + tTimer50s.dData = 0; + TimerAdd ( &tTimer50s ); + + tTimer5000s.dExpires = 5000000; + tTimer5000s.dSuitNumber = 10; + tTimer5000s.pFunc = &tm_app_callback_5000s; + tTimer5000s.dData = 0; + TimerAdd ( &tTimer5000s ); + app_state++; + break; + + case APP_START: + app_state++; + break; + + case APP_TIMEROUT: + + TimerAdd ( &tTimer50s ); + app_state++; + break; + case APP_STOP: + + TimerAdd ( &tTimer50s ); + app_state++; + break; + default: + break; + } +} + + +int main ( int argc, char *argv[] ) +{ + + system_init ( ); + + set_timer ( ); + + while ( 1 ) + { + usleep ( 1 ); + tm_app_test ( ); + } + return 1; +} diff --git a/omc/plat/public_bak/.copyarea.db b/omc/plat/public_bak/.copyarea.db new file mode 100644 index 0000000..e606c76 --- /dev/null +++ b/omc/plat/public_bak/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public +2 +5 +3:doc|2|0|0|0|5a096a87bfa511dc85ad001c23e19543|0 +2:ut|2|0|0|0|7a396fe3bfa511dc85ad001c23e19543|0 +3:src|2|0|0|0|965644719a8511dd8b36001c23e19543|0 +8:Makefile|1|11d70a42106|b39|3f03c2a8|5a996abfbfa511dc85ad001c23e19543|0 +3:lib|2|0|0|0|5a996aa3bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/Makefile b/omc/plat/public_bak/Makefile new file mode 100644 index 0000000..842a1e8 --- /dev/null +++ b/omc/plat/public_bak/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = public +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = -DDEBUG + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/public_bak/src/.copyarea.db b/omc/plat/public_bak/src/.copyarea.db new file mode 100644 index 0000000..1dd0239 --- /dev/null +++ b/omc/plat/public_bak/src/.copyarea.db @@ -0,0 +1,24 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\src +2 +14 +9:pub_sdp.c|1|11d70a4256b|80ba|584e8dc9|ede485566cf311dd91a5001c23e19543|0 +c:pub_netcap.c|1|11d70a423c5|22da|64d013d5|61c96bf3bfa511dc85ad001c23e19543|0 +a:bisearch.c|1|11d70a4224e|12be|16a50655|5cf96b2fbfa511dc85ad001c23e19543|0 +a:pub_wnet.c|1|11d70a4221f|2fd2|c024fa17|5c696b13bfa511dc85ad001c23e19543|0 +4:uwav|2|0|0|0|96f6447d9a8511dd8b36001c23e19543|0 +9:pub_str.c|1|11d70a422ac|624d|d4edcdbd|5e296b67bfa511dc85ad001c23e19543|0 +7:include|2|0|0|0|6ee472436cf311dd91c7001c23e19543|0 +c:pub_malloc.c|1|11d70a42319|16e|46e95f03|5ff96b9fbfa511dc85ad001c23e19543|0 +a:pub_time.c|1|11d70a42358|d0d|db665a6d|60996bbbbfa511dc85ad001c23e19543|0 +b:pub_timer.c|1|11d70a42461|162b|831b0307|64296c47bfa511dc85ad001c23e19543|0 +7:crypt.c|1|11d70a424fd|26e6|6634adda|65e96c9bbfa511dc85ad001c23e19543|0 +b:pub_debug.c|1|11d70a4227d|452|4f2c1da0|5d996b4bbfa511dc85ad001c23e19543|0 +9:pub_sys.c|1|11d70a424cf|3750|1975576d|65596c7fbfa511dc85ad001c23e19543|0 +9:pub_log.c|1|11d70a422db|aa6|3960b660|5f696b83bfa511dc85ad001c23e19543|0 +a:memwatch.c|1|11d70a4253c|128e8|ccb0b9c1|78696fabbfa511dc85ad001c23e19543|0 +6:asn1.c|1|11d70a424a0|49d1|cdca34b4|64b96c63bfa511dc85ad001c23e19543|0 +a:pub_file.c|1|11d70a42432|408|3176f145|62f96c2bbfa511dc85ad001c23e19543|0 +a:pub_inet.c|1|11d70a423f4|233d|5f582334|62596c0fbfa511dc85ad001c23e19543|0 +a:pub_conf.c|1|11d70a421e1|102|d42b3fdc|5bc96af7bfa511dc85ad001c23e19543|0 +9:pub_fmt.c|1|11d70a42387|6d95|c0c28582|61296bd7bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/src/asn1.c b/omc/plat/public_bak/src/asn1.c new file mode 100644 index 0000000..f1263e3 --- /dev/null +++ b/omc/plat/public_bak/src/asn1.c @@ -0,0 +1,941 @@ +/********************************************************************/ +/*Title: asn1.c */ +/*Descr: ASN.1 Encoding/Decoding Module */ +/*Author: Liang Hanxi */ +/*Create: 2002-1-15 */ +/*Version: */ +/*Modify: 2002-10-22 */ +/********************************************************************/ + + +#include "./include/asn1.h" +#include +#include +#include + +/*@ignore@*/ +void AsnEncode(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf) +{ + asnbuf->msgbuf=msg_buf; + memset(msg_buf,0,2); + asnbuf->msglen=0; + asnbuf->maxlen=maxlen; +} + +void asn_encode(u_char *msg_buf,ASN_BUF *asnbuf) +{ + AsnEncode(msg_buf,256,asnbuf); +} + +void asn_encode_v3(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf) +{ + AsnEncode(msg_buf,maxlen,asnbuf); +} + +int add_tlv(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf) +{ + return AddTLV(tag_seq,length,pvalue,tlv_type,asnbuf); +} + +int AddTLV(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_short tags[50][2]; + int level; + int rest,swaplen=0,oldlen=0; + int ntag,nlen; + int addval,temp,i,rtn; //temp variable + u_char flag; //temp variable + u_char *ptlv,*pt,*ptr[50],asn_swap[1024]; + + if(asnbuf->msglen+length+5>asnbuf->maxlen) + { + printf("No room for new tlv.maxlen=%d,msglen=%d,addlen=%d\n",asnbuf->maxlen,asnbuf->msglen,length); + return -1; + } + /*search position for new data--->*/ + level = parse_tags(tag_seq,tags); + pt = asnbuf->msgbuf; //start pointer + rest = asnbuf->msglen % 1024; //remain length + for(i = 1; i < level; i++) + { + if(tags[i][1] == 0) //according to tagcode + rtn = findtlv(pt, tags[i][0], &ptlv, rest); + else //according to order + rtn = findtlv2(pt, tags[i][1], &ptlv, rest); + + if(rtn == -1) //length check error + return -1; + else if(rtn == 1) //not found,create it + { + swaplen = asnbuf->msglen - (ptlv - asnbuf->msgbuf); + if(swaplen > 0) + memcpy(asn_swap, ptlv, swaplen); + pt = ptlv; + while(i < level) + { + //printf("create level=%d\n",i); + ntag = addtagcode(pt, tags[i][0], 0xA0); + nlen = addlength(pt + ntag, 0); + ptr[i] = pt + ntag; + addval = modifylength(ptr, i - 1, ntag + nlen); + pt += addval; + asnbuf->msglen += addval; + i ++; + } + rest = 0; + } + else //found,continue + { + if((rtn & 0x20) == 0) + return -1; + + ntag=gettagcode(ptlv,&temp,&flag); + nlen=getlength(ptlv+ntag,&rest); + ptr[i]=ptlv+ntag; + pt=ptlv+ntag+nlen; + } + } + //insert new data + if(tags[level][1]==0) + { + rtn=findtlv(pt,tags[level][0],&ptlv,rest); + + if(rtn<0) + return -1; + else if(rtn!=1) + { + oldlen=0; + oldlen=gettagcode(ptlv,&temp,&flag); + oldlen+=getlength(ptlv+oldlen,&temp); + oldlen+=temp; + } + if(swaplen==0) + { + swaplen=asnbuf->msglen-(ptlv+oldlen-asnbuf->msgbuf); + if(swaplen>0) + memcpy(asn_swap,ptlv+oldlen,swaplen); + } + + ntag=addtagcode(ptlv,tags[level][0],tlv_type); + nlen=addlength(ptlv+ntag,length); + + memcpy(ptlv+ntag+nlen,pvalue,length); + //modify parent's length + addval=modifylength(ptr,level-1,ntag+nlen+length); + asnbuf->msglen+=addval; + ptlv+=addval; + + } + else + { + rtn=findtlv2(pt,tags[level][1],&ptlv,rest); + if(rtn<0) + return -1; + if(swaplen==0) + { + swaplen=asnbuf->msglen-(ptlv-asnbuf->msgbuf); + if(swaplen>0) + memcpy(asn_swap,ptlv,swaplen); + + } + ntag=addtagcode(ptlv,tags[level][0],tlv_type); + nlen=addlength(ptlv+ntag,length); + memcpy(ptlv+ntag+nlen,pvalue,length); + //modify parent's length + addval=modifylength(ptr,level-1,ntag+nlen+length); + asnbuf->msglen+=addval; + ptlv+=addval; + } + if(swaplen>0) + memcpy(ptlv,asn_swap,swaplen); + return asnbuf->msglen; +} + + +int asn_decode(u_char *msg_buf,int ntlv,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,256,ntlv,NULL,asnbuf); +} + +int asn_decode_v2(u_char *msg_buf,int ntlv,int *errpos,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,256,ntlv,errpos,asnbuf); +} + +int asn_decode_v3(u_char *msg_buf,int msglen,int *errpos,ASN_BUF *asnbuf) +{ + return AsnDecode(msg_buf,msglen,100,errpos,asnbuf); +} + +int AsnDecode(u_char *msg_buf,int msglen,int maxtlv,int *errpos,ASN_BUF *asnbuf) +{ + ASN_TLV *p1=NULL,*p2; + int ntlv=0,retval,sublen=0; + + asnbuf->msgbuf = msg_buf; + asnbuf->tlvcount=0; + asnbuf->pos = 0; + asnbuf->msglen = msglen; + asnbuf->errmsg[0]='\0'; + + while(asnbuf->pos < msglen && ntlvpos; + + retval=parse_tlv(&p2,asnbuf); + + if(retval<0) + { + return -1; + } + else if(retval==0) + { + return sublen; + } + else + { + if(p1!=NULL) + p1->pnext = p2; + p1 = p2; + sublen+=retval; + } + ntlv++; + } + if(errpos!=NULL) + *errpos = asnbuf->pos; + + return sublen; +} + +int get_tlv(const char *tag_seq,u_char *pvalue,ASN_BUF *asnbuf) +{ + return get_tlv_v2(tag_seq,pvalue,NULL,asnbuf); +} + +int get_tlv_v2(const char *tag_seq,u_char *pvalue,u_char *flag,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(flag!=NULL) + *flag=p1->tagtype; + + if(p1->length < 0) + return -1; + else if(p1->length <= 256) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,256); + return 256; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int GetTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char flag,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + //printf("flag:%02X/%02X\n",p1->tagtype,flag); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (depthtagtype == flag) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(p1->length < 0) + return -1; + else if(p1->length <= maxlen) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,maxlen); + return maxlen; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int GetAnyTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char *pflag,u_short *ptagcode,ASN_BUF *asnbuf) +{ + u_short tags[30][2]; + int depth=1,order=1; + ASN_TLV *p1=&asnbuf->heap[0]; + parse_tags(tag_seq,tags); + + if(asnbuf->tlvcount < 1) + return -1; + + while(depthtagcode,tags[depth][0]); + //printf("flag:%02X/%02X\n",p1->tagtype,flag); + if((p1->tagcode == tags[depth][0] || tags[depth][0]==0xFFFF) && (tags[depth][1]==0 || order==tags[depth][1])) + { + if(depth==tags[0][0]) + { + if(pflag!=NULL) + *pflag = p1->tagtype; + if(ptagcode != NULL) + *ptagcode = p1->tagcode; + + if(p1->length < 0) + return -1; + else if(p1->length <= maxlen) + { + memcpy(pvalue,p1->pvalue,p1->length); + return p1->length; + } + else + { + memcpy(pvalue,p1->pvalue,maxlen); + return maxlen; + } + } + else + { + if(p1->psub==NULL) + return -1; + p1=p1->psub; + depth++; + order=1; + } + } + else + { + if(p1->pnext == NULL) + return -1; + p1=p1->pnext; + order++; + } + } + return -1; +} + +int parse_tlv(ASN_TLV **pnode,ASN_BUF *asnbuf) +//idefinite length +{ + int ntag,nlen,length,sublen=0,retval; + u_int tagcode; + u_char tagtype; + u_char *msgbuf=asnbuf->msgbuf; + ASN_TLV *ptlv,*p1=NULL,*p2; + + if(asnbuf->pos == asnbuf->msglen) + { + *pnode=NULL; + return 0; + } + + if(asnbuf->pos+2 > asnbuf->msglen || asnbuf->tlvcount >=256) + { + sprintf(asnbuf->errmsg,"Length check error(rest=%d)/exceed limit(tlvcount=%d)\n",asnbuf->msglen-asnbuf->pos,asnbuf->tlvcount); + return -1; + } + //printf("tlvcount=%d\n",asnbuf->tlvcount); + *pnode = ptlv = &asnbuf->heap[asnbuf->tlvcount++]; + ptlv->psub = ptlv->pnext = NULL; + ptlv->length = -1; + + if((ntag=gettagcode(msgbuf+asnbuf->pos,&tagcode,&tagtype))<1) + { + sprintf(asnbuf->errmsg,"Wrong encoding of tag(pos=%d:%02X %02X %02X)\n",asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + asnbuf->pos+=ntag; + + if((nlen=getlength(msgbuf+asnbuf->pos,&length))<1) + { + sprintf(asnbuf->errmsg,"Wrong encoding of Length(pos=%d:%02X %02X %02X)\n",asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + asnbuf->pos+=nlen; + + if(asnbuf->pos + length >asnbuf->msglen) + { + sprintf(asnbuf->errmsg,"Length Check error.length=%d,rest=%d(pos=%d:%02X %02X %02X)\n",length,asnbuf->msglen-asnbuf->pos,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + + ptlv->tagtype=tagtype; + ptlv->tagcode=tagcode; + ptlv->pvalue=msgbuf+asnbuf->pos; + + if((tagtype & 0x20)==0) //primitive + { + if(length==-1) + { + sprintf(asnbuf->errmsg,"Wrong Encoding of Length:primitive form with indefinite length\n(pos=%d)",asnbuf->pos); + return -1; + } + else + { + ptlv->length = length; + asnbuf->pos += length; + return length+ntag+nlen; + } + } + else //constructor + { + if(length >=0) //short/long definite length + { + ptlv->length = length; + while(sublenerrmsg,"Length Check error.length=%d,sublen=%d(pos=%d:%02X %02X %02X)\n",length,sublen,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + else + { + if(p1==NULL) + p1=ptlv->psub = p2; + else + { + p1->pnext = p2; + p1 = p2; + } + sublen+=retval; + } + } + if(sublen>length) + { + sprintf(asnbuf->errmsg,"Length Check error.length=%d,sublen=%d(pos=%d:%02X %02X %02X)\n",length,sublen,asnbuf->pos,msgbuf[asnbuf->pos],msgbuf[asnbuf->pos+1],msgbuf[asnbuf->pos+2]); + return -1; + } + ptlv->length = sublen; + return sublen+ntag+nlen; + } + else //indefinite length + { + while(msgbuf[asnbuf->pos]!=0 || msgbuf[asnbuf->pos+1]!=0) + { + retval=parse_tlv(&p2,asnbuf); + if(retval<0) + { + return -1; + } + else if(retval==0) + { + ptlv->length = sublen; + return sublen+ntag+nlen; + } + else + { + if(p1==NULL) + p1=ptlv->psub = p2; + else + { + p1->pnext = p2; + p1 = p2; + } + sublen+=retval; + } + } + asnbuf->pos += 2; + ptlv->length = sublen; + return sublen+ntag+nlen+2; + } + } + + +} + + +int findtlv(u_char *pasn,u_int tagcode,u_char **pnext,int rest) +//according to tagcode +{ + int ntag,nlen,nvalue,pos=0; + u_int curtag; + u_char type; + //printf("findtlv rest=%d\n",rest); + if(rest==0) + { + *pnext=pasn; + return 1; + } + else if(rest<0) + return -1; + ntag=gettagcode(pasn,&curtag,&type); + if((nlen=getlength(pasn+ntag,&nvalue)) < 0 || nvalue < 0) + return -1; + //printf("ntag=%d,nlen=%d,nvalue=%d\n",ntag,nlen,nvalue); + if(curtag0 && rest>0) + { + ntag=gettagcode((*pnext),&curtag,&type); + nlen=getlength((*pnext)+ntag,&nvalue); + (*pnext)+=(ntag+nlen+nvalue); + rest-=(ntag+nlen+nvalue); + } + + if(index==0 && rest>0) //found + { + ntag=gettagcode((*pnext),&curtag,&type); + return type; + } + else if(rest==0) //seek to end(not found) + return 1; + else + return -1; +} + +int gettagcode(u_char *asnbuf,u_int *tagcode,u_char *type) +{ + u_int pos=0; + *type=asnbuf[pos] & 0xE0; + *tagcode=asnbuf[pos] & 0x1F; + pos++; + if(*tagcode==0x1F) + { + *tagcode=0; + while((asnbuf[pos] & 0x80)==0x80 && pos<3) + { + *tagcode=(*tagcode) * 0x80 + (asnbuf[pos++] & 0x7F); + } + *tagcode=(*tagcode) * 0x80 + (asnbuf[pos++] & 0x7F); + } + return pos; +} + +int getlength(u_char *asnbuf,int *len) +{ + u_int pos=0,lenbyte; + + if((asnbuf[pos] & 0x80)==0) + *len=asnbuf[pos++] & 0x7F; + else + { + *len=0; + lenbyte=asnbuf[pos++] & 0x7F; + if(lenbyte>3 || lenbyte<0) + return -1; + + if(lenbyte==0) + { + *len=-1; + return 1; + } + else + { + while(lenbyte-->0) + *len=(*len)*0x100 + asnbuf[pos++]; + } + + } + + return pos; +} + +int addtagcode(u_char *msg_buf,u_int tagcode,u_char type) +{ + u_int tagbyte=0,pos=0; + int i=3; + u_char buf[4]; + msg_buf[pos]=type & 0xE0; + if(tagcode<31) + msg_buf[pos++]+=tagcode; + else + { + msg_buf[pos++]+=0x1F; + while(i>=0 && tagcode>0) + { + buf[i]=tagcode & 0x7F; + buf[i]|=0x80; + tagcode=tagcode >> 7; + i--; + } + buf[3]&=0x7F; + tagbyte=3-i; + memcpy(msg_buf+pos,buf+i+1,tagbyte); + pos+=tagbyte; + } + return pos; +} +int addlength(u_char *msg_buf,u_int len) +{ + u_int lenbyte=0,pos=0; + int i=3; + u_char buf[4]; + + if(len>=0 && len<=127) + msg_buf[pos++]=len; + else if(len>0) + { + while(i>=0 && len>0) + { + buf[i]=len & 0xFF; + len=len>>8; + i--; + } + lenbyte=3-i; + msg_buf[pos++]=lenbyte | 0x80; + memcpy(msg_buf+pos,buf+i+1,lenbyte); + pos+=lenbyte; + } + return pos; +} + +int parse_tags(const char *tag_seq,u_short (*tags)[2]) +{ + u_short i,j=0,level=1,len; + len=strlen(tag_seq); + + tags[1][0]=0xFFFF; + tags[1][1]=0; + for(i=0;ilenbyte1) + { + memcpy(swapbuf+2,ptr[level]+lenbyte1+2,len+addval-2); + memcpy(ptr[level]+lenbyte2,swapbuf,len+addval); + } + return modifylength(ptr,level-1,addval+lenbyte2-lenbyte1); +} + +void showbuf(u_char *buf,int len) +{ + int i; + for(i=0;i*/ +///////////////////////////////////////////////// +int add_bool(const char *tag_seq,u_char value,u_char tlv_type,ASN_BUF *asnbuf) +{ + return add_tlv(tag_seq,1,&value,tlv_type,asnbuf); +} + +u_char get_bool(const char *tag_seq,ASN_BUF *asnbuf) +{ + u_char pvalue[10]; + get_tlv(tag_seq,pvalue,asnbuf); + return pvalue[0]; +} + +int add_int(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf) +{ + return AddInteger(tag_seq,value,tlv_type,asnbuf); +} + +int AddInteger(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_char buf[4]; + u_int *p_uint=(u_int *)buf; + int i; + + *p_uint=htonl(value); + + if(value<0) + { + for(i=0;i<4;i++) + { + if(buf[i]!=0xFF) + { + if((buf[i] & 0x80)==0) + i--; + break; + } + } + } + else + { + for(i=0;i<4;i++) + { + if(buf[i]!=0) + { + if((buf[i] & 0x80)==0x80) + i--; + break; + } + } + } + + if(i>=4) + i=3; + + return add_tlv(tag_seq,4-i,buf+i,tlv_type,asnbuf); +} + +int GetInteger(const char *tag_seq,int *rtn,u_char flag,ASN_BUF *asnbuf) +{ + u_char pvalue[10]; + int length,i; + length=GetTLV(tag_seq,5,pvalue,flag,asnbuf); + if(length==-1) + return -1; + + if((pvalue[0] & 0x80)==0x80) + *rtn=-1; + else + *rtn=0; + + for(i=0;i=0) + return 1; + else + return -1; +} +int add_oid(const char *tag_seq,const char *oidstr,u_char tlv_type,ASN_BUF *asnbuf) +{ + u_char pvalue[50],buf[4]; + int oid[20],len,i,j,level=0,pos=0; + len=strlen(oidstr); + memset(oid,0,sizeof(oid)); + for(i=0;i>7; + j--; + }while(oid[i]>0 && j>=0); + buf[3]&=0x7F; + len=3-j; + memcpy(pvalue+pos,buf+j+1,len); + pos+=len; + } + return add_tlv(tag_seq,pos,pvalue,tlv_type,asnbuf); +} + +int get_oid(const char *tag_seq,char *oid,ASN_BUF *asnbuf) +{ + u_char pvalue[50]; + char tempstr[50],firstoctet=1; + int length,i,temp=0; + length=get_tlv(tag_seq,pvalue,asnbuf); + + if(length<=0) + return -1; + + for(i=0;i 0) + { + len--; + ptr[i] = buf[len]; + } + else + ptr[i] = pad; + } + return ret; +} +/*@end@*/ diff --git a/omc/plat/public_bak/src/bisearch.c b/omc/plat/public_bak/src/bisearch.c new file mode 100644 index 0000000..1fe339a --- /dev/null +++ b/omc/plat/public_bak/src/bisearch.c @@ -0,0 +1,199 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic implement */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ +#include "memory.h" +#include "malloc.h" +#include "stdlib.h" +#include "./include/bisearch.h" + +/*@ignore@*/ + +int BISearchReg ( BiSearchArray *pBSA, int nTotalSize , void *GetIdleNodeFunc ) +{ + if( pBSA == NULL ) + exit(0); + memset( pBSA , 0 , sizeof(BiSearchArray) ); + pBSA->nArrayCount = 0; + pBSA->nArrayTotalLen = nTotalSize; + pBSA->pBiArray = malloc( sizeof(BiSearch)*nTotalSize ); + memset ( pBSA->pBiArray, 0, BS_SIZE * nTotalSize ); + pBSA->GetIdleNodeFunc = (int (*)(int *))GetIdleNodeFunc; + return 1; +} + +int BISearchUnReg ( BiSearchArray * pBSA) +{ + if( pBSA !=NULL && pBSA->pBiArray != NULL ) + { + free(pBSA->pBiArray); + return 1; + } + return 0; +} + +int BSearch ( BiSearchArray * pBSA, int nStart, int nEnd, LL llKey, int * nPosResult ) +{ + BiSearch *pArray ; + int nPos = -1; + + if( pBSA == NULL ) + + return 0; + if( nStart < 0 || nEnd < 0 || nStart > nEnd || pBSA->nArrayCount < nStart ) + { + return 0; + } + + pArray = pBSA->pBiArray; + if( !pBSA->nArrayCount ) + return (*nPosResult = 0); + if( nEnd > pBSA->nArrayCount-1 ) + nEnd = pBSA->nArrayCount-1; + + for ( nPos = nStart; nStart <= nEnd; nPos = ( nStart + nEnd ) / 2 ) + { + if( pArray[nPos].llKey == llKey ) + { + *nPosResult = nPos; + return 1; + } + if( pArray[nPos].llKey > llKey ) + { + nEnd = nPos - 1; + } + if( pArray[nPos].llKey < llKey ) + { + nStart = nPos + 1; + } + } + if( nPos != -1 && pArray[nPos].llKey < llKey ) + nPos++; + *nPosResult = nPos; + return 0; +} + +int BSearchArray ( BiSearchArray * pBSA, LL llKey, int *nPosResult ) +{ + if( pBSA == NULL ) + return 0; + + return BSearch ( pBSA, 0, (pBSA->nArrayCount > 0 ? pBSA->nArrayCount-1 : 0), llKey, nPosResult ); +} + +int BISInsert ( BiSearchArray * pBSA, LL llKey, int nDUPosIndex ) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + //memery protect: Data Unit Index exceed Data Unit Array Length + if( nDUPosIndex > pBSA->nArrayTotalLen || nDUPosIndex < 0) + return 0; + + if( pBSA->nArrayCount >= pBSA->nArrayTotalLen ) //Array Full + return 0; + + if( !BSearchArray ( pBSA , llKey, &nPos ) && nPos != -1 ) + { + BiSearch *pBS = pBSA->pBiArray + nPos ; + + memmove ( pBS + 1, pBS , BS_SIZE * ( pBSA->nArrayCount - nPos ) ); + pBS->llKey = llKey; + pBS->nDUPosIndex = nDUPosIndex; + pBSA->nArrayCount++; + return 1; + + } + //The Key is existed, insert fail. + return 0; +} + +int BISDelete ( BiSearchArray * pBSA, LL llKey ) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + if( pBSA->nArrayCount <= 0 ) + return 0; + + if( BSearchArray ( pBSA ,llKey, &nPos ) ) + { + BiSearch *pBS = pBSA->pBiArray + nPos; + + memmove ( pBS, pBS + 1, BS_SIZE * ( pBSA->nArrayCount - nPos ) ); + memset ( pBSA->pBiArray + pBSA->nArrayCount, 0, BS_SIZE ); + pBSA->nArrayCount--; + return 1; + } + return 0; +} + +int BISSearch ( BiSearchArray * pBSA, LL llKey , int* nDUPosIndex) +{ + int nPos = -1; + + if( pBSA == NULL ) + return 0; + + if( BSearchArray ( pBSA ,llKey, &nPos ) ) + { + *nDUPosIndex = pBSA->pBiArray[nPos].nDUPosIndex; + if( *nDUPosIndex > pBSA->nArrayTotalLen ) + return 0; + return 1; + } + return 0; +} + + +int GetBISearchCount ( BiSearchArray * pBSA) +{ + if( pBSA == NULL ) + return 0; + + return pBSA->nArrayCount; +} + +int GetDUIndex ( BiSearchArray * pBSA, int nBIIndex) +{ + if( pBSA == NULL ) + return 0; + + if( nBIIndex >= pBSA->nArrayCount ) + return -1; + else + return pBSA->pBiArray[nBIIndex].nDUPosIndex; +} + +int BISSearchMng( BiSearchArray * pBSA, BIS_OP mng_type,LL llkey, int* nDUIndex ) +{ + switch( mng_type ) + { + case BIS_INIT: + return BISInsert( pBSA , llkey , *nDUIndex ); + case BIS_SEARCH: + return BISSearch( pBSA , llkey , nDUIndex ); + case BIS_INSERT: + if( pBSA->GetIdleNodeFunc != NULL && pBSA->GetIdleNodeFunc( nDUIndex ) ) + return BISInsert( pBSA , llkey , *nDUIndex ); + break; + case BIS_DELETE: + return BISDelete( pBSA, llkey); + break; + default: + return 0; + } + return 1; +} + +/*@end@*/ + diff --git a/omc/plat/public_bak/src/crypt.c b/omc/plat/public_bak/src/crypt.c new file mode 100644 index 0000000..44cc79a --- /dev/null +++ b/omc/plat/public_bak/src/crypt.c @@ -0,0 +1,493 @@ +/* +** PACS-WLL 2000 project, Prepaid System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD February, 2001 +** +** file name: crypt.c +** CVS $Id: crypt.c,v 1.1 2001/06/28 07:21:15 zhangsz Exp $ +** +** Crypt functions +** +*/ + +#include +#include +#include +#include + +/*@ignore@*/ + +#define DES_KEY "N2r3T5B0" + +static unsigned char T1[] = +{ + 57,49,41,33,25,17, 9, 1, + 59,51,43,35,27,19,11, 3, + 61,53,45,37,29,21,13, 5, + 63,55,47,39,31,23,15, 7, + 56,48,40,32,24,16, 8, 0, + 58,50,42,34,26,18,10, 2, + 60,52,44,36,28,20,12, 4, + 62,54,46,38,30,22,14, 6 +}; + +static unsigned char T2[] = +{ + 39, 7,47,15,55,23,63,31, + 38, 6,46,14,54,22,62,30, + 37, 5,45,13,53,21,61,29, + 36, 4,44,12,52,20,60,28, + 35, 3,43,11,51,19,59,27, + 34, 2,42,10,50,18,58,26, + 33, 1,41, 9,49,17,57,25, + 32, 0,40, 8,48,16,56,24 +}; + +static unsigned char T3[] = +{ + 31, 0, 1, 2, 3, 4, + 3, 4, 5, 6, 7, 8, + 7, 8, 9,10,11,12, + 11,12,13,14,15,16, + 15,16,17,18,19,20, + 19,20,21,22,23,24, + 23,24,25,26,27,28, + 27,28,29,30,31, 0 +}; + +static unsigned char T5[] = +{ + 15, 6,19,20, + 28,11,27,16, + 0,14,22,25, + 4,17,30, 9, + 1, 7,23,13, + 31,26, 2, 8, + 18,12,29, 5, + 21,10, 3,24 +}; + +static unsigned char T7_1_2[] = +{ + 56,48,40,32,24,16, 8, + 0,57,49,41,33,25,17, + 9, 1,58,50,42,34,26, + 18,10, 2,59,51,43,35, + 62,54,46,38,30,22,14, + 6,61,53,45,37,29,21, + 13, 5,60,52,44,36,28, + 20,12, 4,27,19,11, 3 +}; + +static unsigned char T8[] = +{ + 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 +}; + +static unsigned char T9[] = +{ + 13,16,10,23, 0, 4, + 2,27,14, 5,20, 9, + 22,18,11, 3,25, 7, + 15, 6,26,19,12, 1, + 40,51,30,36,46,54, + 29,39,50,44,32,47, + 43,48,38,55,33,52, + 45,41,49,35,28,31 +}; + +static unsigned char T6[][64] = +{ + {/* S1 */ + 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7, + 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8, + 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0, + 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13 + }, + {/* S2 */ + 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10, + 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5, + 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15, + 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9 + }, + {/* S3 */ + 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1, + 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7, + 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12 + }, + {/* S4 */ + 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15, + 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9, + 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4, + 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14 + }, + {/* S5 */ + 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9, + 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6, + 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14, + 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3 + }, + {/* S6 */ + 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11, + 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8, + 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6, + 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13 + }, + {/* S7 */ + 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1, + 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6, + 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2, + 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12 + }, + {/* S8 */ + 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7, + 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2, + 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8, + 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11 + } +}; + +unsigned char TE[][4] = +{ + {0,0,0,0}, + {0,0,0,1}, + {0,0,1,0}, + {0,0,1,1}, + {0,1,0,0}, + {0,1,0,1}, + {0,1,1,0}, + {0,1,1,1}, + {1,0,0,0}, + {1,0,0,1}, + {1,0,1,0}, + {1,0,1,1}, + {1,1,0,0}, + {1,1,0,1}, + {1,1,1,0}, + {1,1,1,1} +}; + +void Ks (unsigned char *Key, unsigned char Kn[16][48]) +{ + unsigned char cd[56]; + unsigned char zt[60]; + int n, i; + unsigned char tmp11, tmp12, tmp21, tmp22; + unsigned char *Knn; + + /* choix 1 */ + for (i = 0; i < 56; i++) + { + cd[i] = Key[T7_1_2[i]]; + } + + for (n = 0; n < 16; n++) + { + if (T8[n] == 0) + { + tmp11 = cd[0]; + tmp21 = cd[28]; + memcpy( zt , &cd[1] , 55 ); + memcpy( cd , zt , 55 ); + cd[27] = tmp11; + cd[55] = tmp21; + } + else + { + tmp11 = cd[0]; + tmp12 = cd[1]; + tmp21= cd[28]; + tmp22 = cd[29]; + + memcpy( zt , &cd[2] , 54 ); + memcpy( cd , zt , 54 ); + + cd[26] = tmp11; + cd[27] = tmp12; + cd[54] = tmp21; + cd[55] = tmp22; + } + Knn = Kn[n]; + for (i = 0; i < 48; i++) + { + Knn[i] = cd[T9[i]]; + } + } +} + +void fonction(unsigned char *Knn, unsigned char *r, unsigned char *s) +{ + + unsigned char x[32]; + unsigned long *px; + int i, l; + unsigned char c; + unsigned char t; + + for (i = 0, l = 0, px = (unsigned long *) x; i < 8;) + { + c = 32 * (r[T3[l]] ^ Knn[l]); + l++; + c += 8 * (r[T3[l]] ^ Knn[l]); + l++; + c += 4 * (r[T3[l]] ^ Knn[l]); + l++; + c += 2 * (r[T3[l]] ^ Knn[l]); + l++; + c += 1 * (r[T3[l]] ^ Knn[l]); + l++; + c += 16 * (r[T3[l]] ^ Knn[l]); + l++; + t = T6[i][c]; + i++; + *px = *(long *)TE[t]; + px++; + } + for (i = 0; i < 32; i++) + { + s[i] = x[T5[i]]; + } +} + +void permutation(unsigned char *org, unsigned char *tab) +{ + unsigned char tmp[64]; + int i; + + + memcpy(tmp, org, 64); + for (i = 0; i < 64; i++) + { + org[i] = tmp[tab[i]]; + } +} + +void chiffrement(unsigned char *xi, unsigned char *xo, unsigned char Kn[16][48]) +{ + unsigned char r[32], l[32]; + unsigned char rp[32], lp[32]; + + int i; + int n; + + memcpy(l, &xi[0], 32); + memcpy(r, &xi[32], 32); + + for (n = 0; n < 16; n++) + { + memcpy(lp, r, 32); + + fonction(Kn[n], r, rp); + for (i = 0; i < 32; i++) + { + r[i] =( ( l[i]) ^ (rp[i] ) ) ; + } + memcpy(l, lp, 32); + } + memcpy(&xo[0], r, 32); + memcpy(&xo[32], l, 32); + +} + +void dechiffrement(unsigned char *xi, unsigned char *xo, unsigned char Kn[16][48]) +{ + unsigned char r[32], l[32], rp[32], lp[32]; + + int i; + int n; + + memcpy(l, &xi[0], 32); + memcpy(r, &xi[32], 32); + + for (n = 0; n < 16; n++) + { + memcpy(lp, r, 32); + fonction(Kn[15 - n], r, rp); + for (i = 0; i < 32; i++) + { + r[i] =( ( l[i] ) ^ ( rp[i] )) ; + } + memcpy(l, lp, 32); + } + + memcpy(&xo[0], r, 32); + memcpy(&xo[32], l, 32); +} + +void eclater(const unsigned char *buf_bit, unsigned char *byte) +{ + int i; + unsigned char m; + + for (i = 0; i < 8; i++) + { + for (m = 0x80; m != 0; ) + { + if ((buf_bit[i] & m) != 0) + *byte = 1; + else + *byte = 0; + byte++; + m=m/2 ; + } + } +} + +void compacter(unsigned char *byte, unsigned char *buf_bit) +{ + int i; + unsigned char m, n; + + for (i = 0; i < 8; i++) + { + n = 0; + for (m = 0x80; m != 0; ) + { + if (*byte++) + n = n | m; + m=m/2 ; + + } + buf_bit[i] = n; + } +} + +// direction 0/1=Encryption/Decryption +// binput,boutput,bkey = 8bytes +// direction: 0/1=Encryt/Decrypt +void des(unsigned char *boutput, const unsigned char *binput, const unsigned char *bkey, int direction) +{ + unsigned char input[64]; /* data input */ + unsigned char output[64]; /* data output */ + unsigned char Key[64]; + unsigned char Kn[16][48]; + + eclater(binput, input); + eclater(bkey, Key); + Ks(Key, Kn); + permutation(input, T1); + + if (direction) dechiffrement(input, output, Kn); + else chiffrement(input, output, Kn); + + permutation(output, T2); + compacter(output, boutput); +} + +void atob (unsigned char *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + + for (i=0; i='a') ch -= 'a' - 10; + else if (ch>='A') ch -= 'A' - 10; + else ch -= '0'; + if (i & 1) *(bcd_buf++) |= ch & 0x0f; + else *bcd_buf = ch << 4; + } +} + +void btoa (char *ascii_buf, const unsigned char *bcd_buf, int len) +{ + int i; + char ch; + + for (i=0; i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} + +void EncryptPIN (unsigned char cipher[], const char plain[], const char pan[], const unsigned char pin_key[]) +{ + char pin[20]; + unsigned char buf1[8], buf2[8]; + int i; + + i = strlen(plain); + buf1[0] = i; + strcpy(pin, plain); + for (; i<14; ++i) pin[i] = 'F'; + atob(buf1+1, pin, 14); + buf2[0] = buf2[1] = 0x00; + atob(buf2+2, pan+strlen(pan)-13, 12); + for (i=0; i<8; ++i) buf1[i] ^= buf2[i]; + des(cipher, buf1, pin_key, 0); +} + +/* length of pan more than 13, and length of pin key more than 8 */ +void DecryptPIN (char plain[], const unsigned char cipher[], const char pan[], const unsigned char pin_key[]) +{ + unsigned char buf1[8], buf2[8]; + int i; + + des(buf1, cipher, pin_key, 1); + buf2[0] = buf2[1] = 0x00; + atob(buf2+2, pan+strlen(pan)-13, 12); + for (i=0; i<8; i++) buf1[i] ^= buf2[i]; + i = buf1[0]; + if (i <= 14) btoa(plain, buf1+1, i); + else plain[0] = '\0'; +} + +void CalcMAC (char mac[], const char data[], const unsigned char mac_key[]) +{ + int i; + unsigned char m[8]; + + memset(m, 0, 8); + for (i=0; data[i];) + { + m[i&7] ^= data[i]; + ++i; + if (!((i&7) && data[i])) des(m, m, mac_key, 0); + } + btoa(mac, m, 8); +} + +void CalcMAC1 (unsigned char mac[], const unsigned char data[], int len, const unsigned char mac_key[]) +{ + int i; + + memset(mac, 0, 8); + for (i=0; i +#include + +typedef struct ASN_TLV +{ + u_char tagtype; + u_short tagcode; + int length; + u_char *pvalue; + struct ASN_TLV *pnext; + struct ASN_TLV *psub; +}ASN_TLV; + +typedef struct _ASN_BUFFER +{ + u_char *msgbuf; //store pointer of buffer + int maxlen; + int msglen; //totallength of message + int pos; + + ASN_TLV heap[256]; + char errmsg[1024]; + short tlvcount; +}ASN_BUF; + +//interface======> +void AsnEncode(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf); +int AsnDecode(u_char *msg_buf,int msglen,int maxtlv,int *errpos,ASN_BUF *asnbuf); +int GetTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char flag,ASN_BUF *asnbuf); +int GetAnyTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char *pflag,u_short *ptagcode,ASN_BUF *asnbuf); +int AddTLV(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf); +int GetInteger(const char *tag_seq,int *rtn,u_char flag,ASN_BUF *asnbuf); +int AddInteger(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf); + +void asn_encode(u_char *asn_buf,ASN_BUF *asnbuf); +void asn_encode_v3(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf); +int add_tlv(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf); +int asn_decode(u_char *asn_buf,int ntlv,ASN_BUF *asnbuf); +int asn_decode_v2(u_char *msg_buf,int ntlv,int *plen,ASN_BUF *asnbuf); +int asn_decode_v3(u_char *msg_buf,int msglen,int *errpos,ASN_BUF *asnbuf); +int get_tlv(const char *tag_seq,u_char *pvalue,ASN_BUF *asnbuf); +int get_tlv_v2(const char *tag_seq,u_char *pvalue,u_char *flag,ASN_BUF *asnbuf); +int parse_tlv(ASN_TLV **pnode,ASN_BUF *asnbuf); +//int parse_tlv2(u_char *asn_buf,int rest,u_short (*tags)[2],int order,ASN_BUF *asnbuf); +int findtlv(u_char *pasn,u_int tagcode,u_char **pnext,int rest); +int findtlv2(u_char *pasn,int index,u_char **pnext,int rest); +int gettagcode(u_char *asnbuf,u_int *tagcode,u_char *type); +int getlength(u_char *asnbuf,int *len); +int addtagcode(u_char *asn_buf,u_int tagcode,u_char type); +int addlength(u_char *asn_buf,u_int len); +int parse_tags(const char *tag_seq,u_short (*tags)[2]); +int modifylength(u_char *ptr[],int level,int addval); +void showbuf(u_char *buf,int len); + +int add_bool(const char *tag_seq,u_char value,u_char tlv_type,ASN_BUF *asnbuf); +u_char get_bool(const char *tag_seq,ASN_BUF *asnbuf); +int add_int(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf); +int get_int(const char *tag_seq,ASN_BUF *asnbuf); +int get_int_v2(const char *tag_seq,int *rtn,ASN_BUF *asnbuf); +int add_oid(const char *tag_seq,const char *oidstr,u_char tlv_type,ASN_BUF *asnbuf); +int get_oid(const char *tag_seq,char *oid,ASN_BUF *asnbuf); +int add_null(const char *tag_seq,u_char tlv_type,ASN_BUF *asnbuf); +int get_null(const char *tag_seq,ASN_BUF *asnbuf); +int DecodeInteger(u_char *buf, u_char len); +#endif diff --git a/omc/plat/public_bak/src/include/bisearch.h b/omc/plat/public_bak/src/include/bisearch.h new file mode 100644 index 0000000..7d16629 --- /dev/null +++ b/omc/plat/public_bak/src/include/bisearch.h @@ -0,0 +1,123 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic Structure */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ + +#ifndef _BISEARCH_H_ +#define _BISEARCH_H_ + +#define LL long long +#define u8 unsigned char + +typedef struct BiSearch +{ + LL llKey; //BiSearch Array Node Key + int nDUPosIndex; //Data Unit array Position Index +} +BiSearch; + +#define BS_SIZE sizeof(BiSearch) + +typedef struct BiSearchArray +{ + int nArrayCount; + int nArrayTotalLen; + BiSearch *pBiArray; //SearchArray pointer + int (*GetIdleNodeFunc)(int* nDUIndex); +} +BiSearchArray; + +/*********************************************************************/ +/*BiSearchReg : Init BiSearch Struct, Alloc BiSearch Memery */ +/*Return : [0]:BiSearchReg fail [1] :BiSearchReg Success */ +/*********************************************************************/ +extern int BISearchReg ( BiSearchArray * pBSA, int nTotalSize ,void *GetIdleNodeFunc ); + + +/*********************************************************************/ +/*BiSearchUnReg : Release BiSearch Memery */ +/*Return : [0]:BiSearchUnReg fail [1] :BiSearchUnReg Success */ +/*********************************************************************/ +int BISearchUnReg ( BiSearchArray * pBSA); + + +/*********************************************************************/ +/*BSearch : BiSearch from nStart to nEnd with the llKey */ +/* Search Result save in the val "nPosResult" */ +/*Return : [0]:BSearch fail [1] :BSearch Success */ +/*********************************************************************/ +int BSearch ( BiSearchArray * pBSA, int nStart, int nEnd, LL llKey, int *nPosResult ); + + +/*********************************************************************/ +/*BSearchArray : BiSearch from 0 to ArrayEndIndex with the llKey */ +/* Search nPos Result save in the val "nPosResult" */ +/*Return : [0]:BSearchArray fail [1] :BSearchArray Success */ +/*********************************************************************/ +int BSearchArray ( BiSearchArray * pBSA, LL llKey, int *nPosResult ); + + +/*********************************************************************/ +/*BISInsert : Insert a BiSearch Array Element with the llKey */ +/* return Data Unit Array Index Get by GetIdleNodeFunc*/ +/*Return : [0]:BISInsert fail [1]:BISInsert Success */ +/*********************************************************************/ +int BISInsert ( BiSearchArray * pBSA, LL llKey, int nDUPosIndex ); + +/*********************************************************************/ +/*BISDelete : Delete a BiSearch Array Element with the llKey */ +/*Return : [0]:BISDelete fail [1]:BISDelete Success */ +/*********************************************************************/ +int BISDelete ( BiSearchArray * pBSA, LL llKey ); + + +/*********************************************************************/ +/*BISSearch : BiSearch from 0 to ArrayEndIndex with the llKey */ +/* Search DUIndex Result save in the val "nDUPosIndex"*/ +/*Return : [0]:BISSearch fail [1]:BISSearch Success */ +/*********************************************************************/ +int BISSearch ( BiSearchArray * pBSA, LL llKey , int* nDUPosIndex); + +/*********************************************************************/ +/*GetBISearchCount : Get The BiSearch struct counter */ +/*Return : return The BiSearch struct counter */ +/*********************************************************************/ +int GetBISearchCount ( BiSearchArray * pBSA); + +/*********************************************************************/ +/*GetDUIndex : Get The Data Unit Index by bisearch struct index */ +/*Return : return the BiSearch struct dataunit index */ +/*********************************************************************/ +int GetDUIndex ( BiSearchArray * pBSA, int nBIIndex); + +//BiSearch ManageMent Operation +typedef enum _BIS_OP +{ + BIS_INIT = 0, + BIS_SEARCH, + BIS_INSERT, + BIS_DELETE, +}BIS_OP; + +/*********************************************************************/ +/*BISSearchMng : BiSearch Management Opertion fuction */ +/* Init : use BIS_OP [BIS_INIT] Insert the elment */ +/* with the key_str and nDUIndex */ +/* Search : use BIS_OP [BIS_SEARCH] search the elemnt */ +/* with the key_str ,return nDUIndex */ +/* Insert : se BIS_OP [BIS_Insert] Insert a BiSearch */ +/* Array Element with the llKey ,return Data */ +/* Unit Array Index Get by GetIdleNodeFunc() */ +/* by GetIdleNodeFunc() */ +/* Delete : use BIS_OP [BIS_DELETE] Delete the elment */ +/* with the key_str */ +/*Return : [0] fail [1] success */ +/*********************************************************************/ +int BISSearchMng( BiSearchArray * pBSA, BIS_OP mng_type,LL llkey, int* nDUIndex ); + +#endif diff --git a/omc/plat/public_bak/src/include/crypt.h b/omc/plat/public_bak/src/include/crypt.h new file mode 100644 index 0000000..521f87f --- /dev/null +++ b/omc/plat/public_bak/src/include/crypt.h @@ -0,0 +1,28 @@ +/* + * crypt.h ---- Key management and data encryption/decryption. + */ + +#ifndef CRYPT__H +#define CRYPT__H + +void des(unsigned char *output, const unsigned char *input, const unsigned char *key, int direction); +void atob (unsigned char *bcd_buf, const char *ascii_buf, int len); +void btoa (char *ascii_buf, const unsigned char *bcd_buf, int len); +void EncryptPIN (unsigned char cipher[], const char plain[], const char pan[], const unsigned char pin_key[]); +void DecryptPIN (char plain[], const unsigned char cipher[], const char pan[], const unsigned char pin_key[]); +void CalcMAC (char mac[], const char data[], const unsigned char mac_key[]); +void CalcMAC1 (unsigned char mac[], const unsigned char data[], int len, const unsigned char mac_key[]); +void EncryptKey (char cipher[], const unsigned char plain[]); +void DecryptKey (unsigned char plain[], const char cipher[]); + +typedef enum _des_crypt_mode{ + _DES_ENCRYPT_ = 0, + _DES_DECRYPT_ +}_DesMode; + +void DesCrypt( +unsigned char *Output /*8 bytes*/, +unsigned char *Input /*8 bytes*/, +unsigned char *DesKey/*default=NULL.While using for user licenses control,can keep the default value*/, +unsigned char DesMode/*encrpt or decrypt,refer to enum _DesMode*/); +#endif diff --git a/omc/plat/public_bak/src/include/includes.h b/omc/plat/public_bak/src/include/includes.h new file mode 100644 index 0000000..56d2720 --- /dev/null +++ b/omc/plat/public_bak/src/include/includes.h @@ -0,0 +1,47 @@ +/* public include head file */ +/* written by Liu Zhiguo 2002-03-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _PUBLIC_INCLUDES_H_ +#define _PUBLIC_INCLUDES_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif diff --git a/omc/plat/public_bak/src/include/license_id.h b/omc/plat/public_bak/src/include/license_id.h new file mode 100644 index 0000000..72eb162 --- /dev/null +++ b/omc/plat/public_bak/src/include/license_id.h @@ -0,0 +1,31 @@ +#ifndef _LICENCE_ID__H +#define _LICENCE_ID__H + +typedef enum _WXC2_LICENSE_ID +{ + LIC_MSC_TRUNK, + LIC_HLR_USERS, + LIC_VLR_USERS, + LIC_AUC_USERS, + LIC_EIR_USERS, + LIC_PPS_USERS, + LIC_SMSC_USERS, + LIC_MNP_USERS, + + LIC_GPRS, + LIC_USSD, + LIC_ISUP, + LIC_BICC, + LIC_AIF, + LIC_MGC, + LIC_CAP, + LIC_OPPS_USERS, + LIC_OPPS_OPR, + LIC_OPPS_IMDM, +}WXC2_LICENSE_ID; + +/* functionID: listed above, + if functionID doesn't exist, return -1, else return license value +*/ +int wxc2_get_license(int functionID); +#endif diff --git a/omc/plat/public_bak/src/include/memwatch.h b/omc/plat/public_bak/src/include/memwatch.h new file mode 100644 index 0000000..d63fd76 --- /dev/null +++ b/omc/plat/public_bak/src/include/memwatch.h @@ -0,0 +1,707 @@ +/* +** MEMWATCH.H +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2002 Johan Lindh +** All rights reserved. +** Version 2.71 +** +************************************************************************ +** +** PURPOSE: +** +** MEMWATCH has been written to allow guys and gals that like to +** program in C a public-domain memory error control product. +** I hope you'll find it's as advanced as most commercial packages. +** The idea is that you use it during the development phase and +** then remove the MEMWATCH define to produce your final product. +** MEMWATCH is distributed in source code form in order to allow +** you to compile it for your platform with your own compiler. +** It's aim is to be 100% ANSI C, but some compilers are more stingy +** than others. If it doesn't compile without warnings, please mail +** me the configuration of operating system and compiler you are using +** along with a description of how to modify the source, and the version +** number of MEMWATCH that you are using. +** +************************************************************************ + + This file is part of MEMWATCH. + + MEMWATCH 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 of the License, or + (at your option) any later version. + + MEMWATCH 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 MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +************************************************************************ +** +** REVISION HISTORY: +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +** +** To use, simply include 'MEMWATCH.H' as a header file, +** and add MEMWATCH.C to your list of files, and define the macro +** 'MEMWATCH'. If this is not defined, MEMWATCH will disable itself. +** +** To call the standard C malloc / realloc / calloc / free; use mwMalloc_(), +** mwCalloc_() and mwFree_(). Note that mwFree_() will correctly +** free both malloc()'d memory as well as mwMalloc()'d. +** +** 980317: C++ support has been disabled. +** The code remains, but is not compiled. +** +** For use with C++, which allows use of inlining in header files +** and class specific new/delete, you must also define 'new' as +** 'mwNew' and 'delete' as 'mwDelete'. Do this *after* you include +** C++ header files from libraries, otherwise you can mess up their +** class definitions. If you don't define these, the C++ allocations +** will not have source file and line number information. Also note, +** most C++ class libraries implement their own C++ memory management, +** and don't allow anyone to override them. MFC belongs to this crew. +** In these cases, the only thing to do is to use MEMWATCH_NOCPP. +** +** You can capture output from MEMWATCH using mwSetOutFunc(). +** Just give it the adress of a "void myOutFunc(int c)" function, +** and all characters to be output will be redirected there. +** +** A failing ASSERT() or VERIFY() will normally always abort your +** program. This can be changed using mwSetAriFunc(). Give it a +** pointer to a "int myAriFunc(const char *)" function. Your function +** must ask the user whether to Abort, Retry or Ignore the trap. +** Return 2 to Abort, 1 to Retry or 0 to Ignore. Beware retry; it +** causes the expression to be evaluated again! MEMWATCH has a +** default ARI handler. It's disabled by default, but you can enable +** it by calling 'mwDefaultAri()'. Note that this will STILL abort +** your program unless you define MEMWATCH_STDIO to allow MEMWATCH +** to use the standard C I/O streams. Also, setting the ARI function +** will cause MEMWATCH *NOT* to write the ARI error to stderr. The +** error string is passed to the ARI function instead, as the +** 'const char *' parameter. +** +** You can disable MEMWATCH's ASSERT/VERIFY and/or TRACE implementations. +** This can be useful if you're using a debug terminal or smart debugger. +** Disable them by defining MW_NOASSERT, MW_NOVERIFY or MW_NOTRACE. +** +** MEMWATCH fills all allocated memory with the byte 0xFE, so if +** you're looking at erroneous data which are all 0xFE:s, the +** data probably was not initialized by you. The exception is +** calloc(), which will fill with zero's. All freed buffers are +** zapped with 0xFD. If this is what you look at, you're using +** data that has been freed. If this is the case, be aware that +** MEMWATCH places a 'free'd block info' structure immediately +** before the freed data. This block contains info about where +** the block was freed. The information is in readable text, +** in the format "FBIfilename(line)", for example: +** "FBI<267>test.c(12)". Using FBI's slows down free(), so it's +** disabled by default. Use mwFreeBufferInfo(1) to enable it. +** +** To aid in tracking down wild pointer writes, MEMWATCH can perform +** no-mans-land allocations. No-mans-land will contain the byte 0xFC. +** MEMWATCH will, when this is enabled, convert recently free'd memory +** into NML allocations. +** +** MEMWATCH protects it's own data buffers with checksums. If you +** get an internal error, it means you're overwriting wildly, +** or using an uninitialized pointer. +** +************************************************************************ +** +** Note when compiling with Microsoft C: +** - MSC ignores fflush() by default. This is overridden, so that +** the disk log will always be current. +** +** This utility has been tested with: +** PC-lint 7.0k, passed as 100% ANSI C compatible +** Microsoft Visual C++ on Win16 and Win32 +** Microsoft C on DOS +** SAS C on an Amiga 500 +** Gnu C on a PC running Red Hat Linux +** ...and using an (to me) unknown compiler on an Atari machine. +** +************************************************************************ +** +** Format of error messages in MEMWATCH.LOG: +** message: filename(linenumber), information +** +** Errors caught by MemWatch, when they are detected, and any +** actions taken besides writing to the log file MEMWATCH.LOG: +** +** Double-freeing: +** A pointer that was recently freed and has not since been +** reused was freed again. The place where the previous free() +** was executed is displayed. +** Detect: delete or free() using the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** Underflow: +** You have written just ahead of the allocated memory. +** The size and place of the allocation is displayed. +** Detect: delete or free() of the damaged buffer. +** Action: The buffer is freed, but there may be secondary damage. +** Overflow: +** Like underflow, but you've written after the end of the buffer. +** Detect: see Underflow. +** Action: see Underflow. +** WILD free: +** An unrecognized pointer was passed to delete or free(). +** The pointer may have been returned from a library function; +** in that case, use mwFree_() to force free() of it. +** Also, this may be a double-free, but the previous free was +** too long ago, causing MEMWATCH to 'forget' it. +** Detect: delete or free() of the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** NULL free: +** It's unclear to me whether or not freeing of NULL pointers +** is legal in ANSI C, therefore a warning is written to the log file, +** but the error counter remains the same. This is legal using C++, +** so the warning does not appear with delete. +** Detect: When you free(NULL). +** Action: The free() is cancelled. +** Failed: +** A request to allocate memory failed. If the allocation is +** small, this may be due to memory depletion, but is more likely +** to be memory fragmentation problems. The amount of memory +** allocated so far is displayed also. +** Detect: When you new, malloc(), realloc() or calloc() memory. +** Action: NULL is returned. +** Realloc: +** A request to re-allocate a memory buffer failed for reasons +** other than out-of-memory. The specific reason is shown. +** Detect: When you realloc() +** Action: realloc() is cancelled, NULL is returned +** Limit fail: +** A request to allocate memory failed since it would violate +** the limit set using mwLimit(). mwLimit() is used to stress-test +** your code under simulated low memory conditions. +** Detect: At new, malloc(), realloc() or calloc(). +** Action: NULL is returned. +** Assert trap: +** An ASSERT() failed. The ASSERT() macro works like C's assert() +** macro/function, except that it's interactive. See your C manual. +** Detect: On the ASSERT(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the ASSERT to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Verify trap: +** A VERIFY() failed. The VERIFY() macro works like ASSERT(), +** but if MEMWATCH is not defined, it still evaluates the +** expression, but it does not act upon the result. +** Detect: On the VERIFY(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the VERIFY to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Wild pointer: +** A no-mans-land buffer has been written into. MEMWATCH can +** allocate and distribute chunks of memory solely for the +** purpose of trying to catch random writes into memory. +** Detect: Always on CHECK(), but can be detected in several places. +** Action: The error is logged, and if an ARI handler is installed, +** it is executed, otherwise, execution continues. +** Unfreed: +** A memory buffer you allocated has not been freed. +** You are informed where it was allocated, and whether any +** over or underflow has occured. MemWatch also displays up to +** 16 bytes of the data, as much as it can, in hex and text. +** Detect: When MemWatch terminates. +** Action: The buffer is freed. +** Check: +** An error was detected during a CHECK() operation. +** The associated pointer is displayed along with +** the file and line where the CHECK() was executed. +** Followed immediately by a normal error message. +** Detect: When you CHECK() +** Action: Depends on the error +** Relink: +** After a MEMWATCH internal control block has been trashed, +** MEMWATCH tries to repair the damage. If successful, program +** execution will continue instead of aborting. Some information +** about the block may be gone permanently, though. +** Detect: N/A +** Action: Relink successful: program continues. +** Relink fails: program aborts. +** Internal: +** An internal error is flagged by MEMWATCH when it's control +** structures have been damaged. You are likely using an uninitialized +** pointer somewhere in your program, or are zapping memory all over. +** The message may give you additional diagnostic information. +** If possible, MEMWATCH will recover and continue execution. +** Detect: Various actions. +** Action: Whatever is needed +** Mark: +** The program terminated without umarking all marked pointers. Marking +** can be used to track resources other than memory. mwMark(pointer,text,...) +** when the resource is allocated, and mwUnmark(pointer) when it's freed. +** The 'text' is displayed for still marked pointers when the program +** ends. +** Detect: When MemWatch terminates. +** Action: The error is logged. +** +** +************************************************************************ +** +** The author may be reached by e-mail at the address below. If you +** mail me about source code changes in MEMWATCH, remember to include +** MW's version number. +** +** Johan Lindh +** johan@linkdata.se +** +** The latest version of MEMWATCH may be downloaded from +** http://www.linkdata.se/ +*/ + +#ifndef __MEMWATCH_H +#define __MEMWATCH_H + +/* Make sure that malloc(), realloc(), calloc() and free() are declared. */ +/*lint -save -e537 */ +#include +/*lint -restore */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +** Constants used +** All MEMWATCH constants start with the prefix MW_, followed by +** a short mnemonic which indicates where the constant is used, +** followed by a descriptive text about it. +*/ + +#define MW_ARI_NULLREAD 0x10 /* Null read (to start debugger) */ +#define MW_ARI_ABORT 0x04 /* ARI handler says: abort program! */ +#define MW_ARI_RETRY 0x02 /* ARI handler says: retry action! */ +#define MW_ARI_IGNORE 0x01 /* ARI handler says: ignore error! */ + +#define MW_VAL_NEW 0xFE /* value in newly allocated memory */ +#define MW_VAL_DEL 0xFD /* value in newly deleted memory */ +#define MW_VAL_NML 0xFC /* value in no-mans-land */ +#define MW_VAL_GRB 0xFB /* value in grabbed memory */ + +#define MW_TEST_ALL 0xFFFF /* perform all tests */ +#define MW_TEST_CHAIN 0x0001 /* walk the heap chain */ +#define MW_TEST_ALLOC 0x0002 /* test allocations & NML guards */ +#define MW_TEST_NML 0x0004 /* test all-NML areas for modifications */ + +#define MW_NML_NONE 0 /* no NML */ +#define MW_NML_FREE 1 /* turn FREE'd memory into NML */ +#define MW_NML_ALL 2 /* all unused memory is NML */ +#define MW_NML_DEFAULT 0 /* the default NML setting */ + +#define MW_STAT_GLOBAL 0 /* only global statistics collected */ +#define MW_STAT_MODULE 1 /* collect statistics on a module basis */ +#define MW_STAT_LINE 2 /* collect statistics on a line basis */ +#define MW_STAT_DEFAULT 0 /* the default statistics setting */ + +/* +** MemWatch internal constants +** You may change these and recompile MemWatch to change the limits +** of some parameters. Respect the recommended minimums! +*/ +#define MW_TRACE_BUFFER 2048 /* (min 160) size of TRACE()'s output buffer */ +#define MW_FREE_LIST 64 /* (min 4) number of free()'s to track */ + +/* +** Exported variables +** In case you have to remove the 'const' keyword because your compiler +** doesn't support it, be aware that changing the values may cause +** unpredictable behaviour. +** - mwCounter contains the current action count. You can use this to +** place breakpoints using a debugger, if you want. +*/ +#ifndef __MEMWATCH_C +extern const unsigned long mwCounter; +#endif + +/* +** System functions +** Normally, it is not nessecary to call any of these. MEMWATCH will +** automatically initialize itself on the first MEMWATCH function call, +** and set up a call to mwAbort() using atexit(). Some C++ implementations +** run the atexit() chain before the program has terminated, so you +** may have to use mwInit() or the MemWatch C++ class to get good +** behaviour. +** - mwInit() can be called to disable the atexit() usage. If mwInit() +** is called directly, you must call mwTerm() to end MemWatch, or +** mwAbort(). +** - mwTerm() is usually not nessecary to call; but if called, it will +** call mwAbort() if it finds that it is cancelling the 'topmost' +** mwInit() call. +** - mwAbort() cleans up after MEMWATCH, reports unfreed buffers, etc. +*/ +void mwInit( void ); +void mwTerm( void ); +void mwAbort( void ); + +/* +** Setup functions +** These functions control the operation of MEMWATCH's protective features. +** - mwFlushNow() causes MEMWATCH to flush it's buffers. +** - mwDoFlush() controls whether MEMWATCH flushes the disk buffers after +** writes. The default is smart flushing: MEMWATCH will not flush buffers +** explicitly until memory errors are detected. Then, all writes are +** flushed until program end or mwDoFlush(0) is called. +** - mwLimit() sets the allocation limit, an arbitrary limit on how much +** memory your program may allocate in bytes. Used to stress-test app. +** Also, in virtual-memory or multitasking environs, puts a limit on +** how much MW_NML_ALL can eat up. +** - mwGrab() grabs up X kilobytes of memory. Allocates actual memory, +** can be used to stress test app & OS both. +** - mwDrop() drops X kilobytes of grabbed memory. +** - mwNoMansLand() sets the behaviour of the NML logic. See the +** MW_NML_xxx for more information. The default is MW_NML_DEFAULT. +** - mwStatistics() sets the behaviour of the statistics collector. See +** the MW_STAT_xxx defines for more information. Default MW_STAT_DEFAULT. +** - mwFreeBufferInfo() enables or disables the tagging of free'd buffers +** with freeing information. This information is written in text form, +** using sprintf(), so it's pretty slow. Disabled by default. +** - mwAutoCheck() performs a CHECK() operation whenever a MemWatch function +** is used. Slows down performance, of course. +** - mwCalcCheck() calculates checksums for all data buffers. Slow! +** - mwDumpCheck() logs buffers where stored & calc'd checksums differ. Slow!! +** - mwMark() sets a generic marker. Returns the pointer given. +** - mwUnmark() removes a generic marker. If, at the end of execution, some +** markers are still in existence, these will be reported as leakage. +** returns the pointer given. +*/ +void mwFlushNow( void ); +void mwDoFlush( int onoff ); +void mwLimit( long bytes ); +unsigned mwGrab( unsigned kilobytes ); +unsigned mwDrop( unsigned kilobytes ); +void mwNoMansLand( int mw_nml_level ); +void mwStatistics( int level ); +void mwFreeBufferInfo( int onoff ); +void mwAutoCheck( int onoff ); +void mwCalcCheck( void ); +void mwDumpCheck( void ); +void * mwMark( void *p, const char *description, const char *file, unsigned line ); +void * mwUnmark( void *p, const char *file, unsigned line ); + +/* +** Testing/verification/tracing +** All of these macros except VERIFY() evaluates to a null statement +** if MEMWATCH is not defined during compilation. +** - mwIsReadAddr() checks a memory area for read privilige. +** - mwIsSafeAddr() checks a memory area for both read & write privilige. +** This function and mwIsReadAddr() is highly system-specific and +** may not be implemented. If this is the case, they will default +** to returning nonzero for any non-NULL pointer. +** - CHECK() does a complete memory integrity test. Slow! +** - CHECK_THIS() checks only selected components. +** - CHECK_BUFFER() checks the indicated buffer for errors. +** - mwASSERT() or ASSERT() If the expression evaluates to nonzero, execution continues. +** Otherwise, the ARI handler is called, if present. If not present, +** the default ARI action is taken (set with mwSetAriAction()). +** ASSERT() can be disabled by defining MW_NOASSERT. +** - mwVERIFY() or VERIFY() works just like ASSERT(), but when compiling without +** MEMWATCH the macro evaluates to the expression. +** VERIFY() can be disabled by defining MW_NOVERIFY. +** - mwTRACE() or TRACE() writes some text and data to the log. Use like printf(). +** TRACE() can be disabled by defining MW_NOTRACE. +*/ +int mwIsReadAddr( const void *p, unsigned len ); +int mwIsSafeAddr( void *p, unsigned len ); +int mwTest( const char *file, int line, int mw_test_flags ); +int mwTestBuffer( const char *file, int line, void *p ); +int mwAssert( int, const char*, const char*, int ); +int mwVerify( int, const char*, const char*, int ); + +/* +** User I/O functions +** - mwTrace() works like printf(), but dumps output either to the +** function specified with mwSetOutFunc(), or the log file. +** - mwPuts() works like puts(), dumps output like mwTrace(). +** - mwSetOutFunc() allows you to give the adress of a function +** where all user output will go. (exeption: see mwSetAriFunc) +** Specifying NULL will direct output to the log file. +** - mwSetAriFunc() gives MEMWATCH the adress of a function to call +** when an 'Abort, Retry, Ignore' question is called for. The +** actual error message is NOT printed when you've set this adress, +** but instead it is passed as an argument. If you call with NULL +** for an argument, the ARI handler is disabled again. When the +** handler is disabled, MEMWATCH will automatically take the +** action specified by mwSetAriAction(). +** - mwSetAriAction() sets the default ARI return value MEMWATCH should +** use if no ARI handler is specified. Defaults to MW_ARI_ABORT. +** - mwAriHandler() is an ANSI ARI handler you can use if you like. It +** dumps output to stderr, and expects input from stdin. +** - mwBreakOut() is called in certain cases when MEMWATCH feels it would +** be nice to break into a debugger. If you feel like MEMWATCH, place +** an execution breakpoint on this function. +*/ +void mwTrace( const char* format_string, ... ); +void mwPuts( const char* text ); +void mwSetOutFunc( void (*func)(int) ); +void mwSetAriFunc( int (*func)(const char*) ); +void mwSetAriAction( int mw_ari_value ); +int mwAriHandler( const char* cause ); +void mwBreakOut( const char* cause ); + +/* +** Allocation/deallocation functions +** These functions are the ones actually to perform allocations +** when running MEMWATCH, for both C and C++ calls. +** - mwMalloc() debugging allocator +** - mwMalloc_() always resolves to a clean call of malloc() +** - mwRealloc() debugging re-allocator +** - mwRealloc_() always resolves to a clean call of realloc() +** - mwCalloc() debugging allocator, fills with zeros +** - mwCalloc_() always resolves to a clean call of calloc() +** - mwFree() debugging free. Can only free memory which has +** been allocated by MEMWATCH. +** - mwFree_() resolves to a) normal free() or b) debugging free. +** Can free memory allocated by MEMWATCH and malloc() both. +** Does not generate any runtime errors. +*/ +void* mwMalloc( size_t, const char*, int ); +void* mwMalloc_( size_t ); +void* mwRealloc( void *, size_t, const char*, int ); +void* mwRealloc_( void *, size_t ); +void* mwCalloc( size_t, size_t, const char*, int ); +void* mwCalloc_( size_t, size_t ); +void mwFree( void*, const char*, int ); +void mwFree_( void* ); +char* mwStrdup( const char *, const char*, int ); + +/* +** Enable/disable precompiler block +** This block of defines and if(n)defs make sure that references +** to MEMWATCH is completely removed from the code if the MEMWATCH +** manifest constant is not defined. +*/ +#ifndef __MEMWATCH_C +#ifdef MEMWATCH + +#define mwASSERT(exp) while(mwAssert((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ +#define mwVERIFY(exp) while(mwVerify((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ +#define mwTRACE mwTrace +#ifndef MW_NOTRACE +#ifndef TRACE +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +/* some compilers use a define and not a function */ +/* for strdup(). */ +#ifdef strdup +#undef strdup +#endif + +#define malloc(n) mwMalloc(n,__FILE__,__LINE__) +#define strdup(p) mwStrdup(p,__FILE__,__LINE__) +#define realloc(p,n) mwRealloc(p,n,__FILE__,__LINE__) +#define calloc(n,m) mwCalloc(n,m,__FILE__,__LINE__) +#define free(p) mwFree(p,__FILE__,__LINE__) +#define CHECK() mwTest(__FILE__,__LINE__,MW_TEST_ALL) +#define CHECK_THIS(n) mwTest(__FILE__,__LINE__,n) +#define CHECK_BUFFER(b) mwTestBuffer(__FILE__,__LINE__,b) +#define MARK(p) mwMark(p,#p,__FILE__,__LINE__) +#define UNMARK(p) mwUnmark(p,__FILE__,__LINE__) + +#else /* MEMWATCH */ + +#define mwASSERT(exp) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ + +#define mwVERIFY(exp) exp +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ + +/*lint -esym(773,mwTRACE) */ +#define mwTRACE /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction /*lint -restore */ +#ifndef MW_NOTRACE +#ifndef TRACE +/*lint -esym(773,TRACE) */ +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +extern void mwDummyTraceFunction(const char *,...); +/*lint -save -e652 */ +#define mwDoFlush(n) +#define mwPuts(s) +#define mwInit() +#define mwGrab(n) +#define mwDrop(n) +#define mwLimit(n) +#define mwTest(f,l) +#define mwSetOutFunc(f) +#define mwSetAriFunc(f) +#define mwDefaultAri() +#define mwNomansland() +#define mwStatistics(f) +#define mwMark(p,t,f,n) (p) +#define mwUnmark(p,f,n) (p) +#define mwMalloc(n,f,l) malloc(n) +#define mwStrdup(p,f,l) strdup(p) +#define mwRealloc(p,n,f,l) realloc(p,n) +#define mwCalloc(n,m,f,l) calloc(n,m) +#define mwFree(p) free(p) +#define mwMalloc_(n) malloc(n) +#define mwRealloc_(p,n) realloc(p,n) +#define mwCalloc_(n,m) calloc(n,m) +#define mwFree_(p) free(p) +#define mwAssert(e,es,f,l) +#define mwVerify(e,es,f,l) (e) +#define mwTrace mwDummyTrace +#define mwTestBuffer(f,l,b) (0) +#define CHECK() +#define CHECK_THIS(n) +#define CHECK_BUFFER(b) +#define MARK(p) (p) +#define UNMARK(p) (p) +/*lint -restore */ + +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ + +#ifdef __cplusplus + } +#endif + +#if 0 /* 980317: disabled C++ */ + +/* +** C++ support section +** Implements the C++ support. Please note that in order to avoid +** messing up library classes, C++ support is disabled by default. +** You must NOT enable it until AFTER the inclusion of all header +** files belonging to code that are not compiled with MEMWATCH, and +** possibly for some that are! The reason for this is that a C++ +** class may implement it's own new() function, and the preprocessor +** would substitute this crucial declaration for MEMWATCH new(). +** You can forcibly deny C++ support by defining MEMWATCH_NOCPP. +** To enble C++ support, you must be compiling C++, MEMWATCH must +** be defined, MEMWATCH_NOCPP must not be defined, and finally, +** you must define 'new' to be 'mwNew', and 'delete' to be 'mwDelete'. +** Unlike C, C++ code can begin executing *way* before main(), for +** example if a global variable is created. For this reason, you can +** declare a global variable of the class 'MemWatch'. If this is +** is the first variable created, it will then check ALL C++ allocations +** and deallocations. Unfortunately, this evaluation order is not +** guaranteed by C++, though the compilers I've tried evaluates them +** in the order encountered. +*/ +#ifdef __cplusplus +#ifndef __MEMWATCH_C +#ifdef MEMWATCH +#ifndef MEMWATCH_NOCPP +extern int mwNCur; +extern const char *mwNFile; +extern int mwNLine; +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; +void * operator new(size_t); +void * operator new(size_t,const char *,int); +void * operator new[] (size_t,const char *,int); // hjc 07/16/02 +void operator delete(void *); +#define mwNew new(__FILE__,__LINE__) +#define mwDelete (mwNCur=1,mwNFile=__FILE__,mwNLine=__LINE__),delete +#endif /* MEMWATCH_NOCPP */ +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +#endif /* __MEMWATCH_H */ + +/* EOF MEMWATCH.H */ diff --git a/omc/plat/public_bak/src/include/omc_public.h b/omc/plat/public_bak/src/include/omc_public.h new file mode 100644 index 0000000..34b6137 --- /dev/null +++ b/omc/plat/public_bak/src/include/omc_public.h @@ -0,0 +1,643 @@ + +/************************************************************************/ +/* Title: omc_public.h */ +/* Desc: Public variables def for PACS OMC Project. */ +/* Author: Meng Xiaozhen */ +/* CrtDate: 2000-08-16 */ +/* AltDate: 2001-06-21 */ +/* CVS: $Id: omc_public.h,v 1.1 2000/08/03 01:09:33 mengxz Exp $ */ +/************************************************************************/ +#ifndef OMC_PUBLIC__H +#define OMC_PUBLIC__H + +#ifndef PUBLIC__H + #include "public.h" +#endif + +#ifndef IPTRANS__H + #include "iptrans.h" +#endif + +#define DEBUG 1 + +/***************************************************/ +/* Macro define for Server's system number */ +#define GRP_NUM 32 + +#define TS_NUM 32 +#define TS_SUB 16 +#define TS_E1 8 + +#define PW_NUM 32 +#define PW_SUB 3 + +#define ETH_NUM 32 +#define ETH_SUB 16 + +#define RDEV_NUM 32 +#define RDEV_SUB 8 +#define RDEV_E1 1 + +#define BSS_NUM 48 + +#define BSC_NUM 12 +#define BSC_SUB 9 +#define BSC_E1 2 + +#define BTS_NUM 24 //BTS system include 12 BTS subsystem +#define BTSSITE_NUM 48 //BTS site include 6 BTS subsystem +#define BTS_SUB 12 +#define BTS_E1 2 + +#define SVR_NUM 36 + +#define CONN_NUM 128 +#define CLIENT_NUM 50 +#define BTN_NUM 66 + +#define ALARM_NUM 20 +#define CACHE_BUF 512 +/***************************************************/ + +/***************************************************/ +/* Macro definition of start ID for applet's button used by system device */ +#define TS_START_BTN 0 +#define RDEV_START_BTN 18 +#define SVR_START_BTN 34 +#define BSC_START_BTN 54 +/***************************************************/ + + +/***************************************************/ +/* Macro define for Server's IP Address */ +#define OMC_0 "172.18.128.1" +#define OMC_1 "172.18.129.1" +#define HLR_0 "172.18.132.1" +#define HLR_1 "172.18.133.1" +#define PPS_0 "172.18.136.1" +#define PPS_1 "172.18.137.1" +#define CDR_0 "172.18.160.1" +#define CDR_1 "172.18.161.1" +/***************************************************/ + +/***************************************************/ +/* Macro define for Mysql Database */ +#define HOST_NAME "localhost" +#define DB_NAME1 "mysql" +#define DB_PORT_NUM 0 +#define SOCKET_NAME NULL +#define FLAGS 0 +#define USER_NAME "root" +#define PASSWORD "rootaa" +/***************************************************/ + +/***************************************************/ +/* Macro def for (UDP)Communication port used by OMC */ +#define PORT_OUT 4951 //for sending message to ts +#define PORT_BASE 4951 +#define PORT_REALSTAT 3 /* 4951 + 3 = 4954 */ +#define PORT_CSTA 4 /* 4951 + 4 = 4955 */ +#define PORT_COMM 5 /* 4951 + 5 = 4956 */ +#define PORT_HEARTBEAT 6 /* 4951 + 6 = 4957 */ +#define PORT_CLUSTER 27 /* 4951 + 27 =4978 */ +#define BROADCAST_IP "172.18.255.255" +#define CLUSTER_IP "239.255.10.1" +#define BROADCAST 0 //if broadcast message + +/***************************************************/ +/* Macro def for shm key and sem key used by OMC */ +#define COMM_FLAG_SHM_KEY 0x6a000000 +#define COMM_FLAG_SHM_PERM 0666 +#define COMM_FLAG_SEM_KEY 300 +#define COMM_FLAG_SEM_PERM 0666 +#define COMM_FLAG_SEM_NUM 1 +#define COMM_FLAG_SIZE 1024 + +#define COMM_LIST_SHM_KEY 0x6a100000 +#define COMM_LIST_SHM_PERM 0666 +#define COMM_LIST_SEM_KEY 310 +#define COMM_LIST_SEM_PERM 0666 +#define COMM_LIST_SEM_NUM 1 + +#define STATUS_SHM_KEY 0x6a200000 +#define STATUS_SHM_PERM 0666 +#define STATUS_SEM_KEY 320 +#define STATUS_SEM_PERM 0666 +#define STATUS_SEM_NUM 1 + +#define CACHE_SHM_KEY 0x6a400000 +#define CACHE_SHM_PERM 0666 +#define CACHE_SEM_KEY 340 +#define CACHE_SEM_PERM 0666 +#define CACHE_SEM_NUM 1 + +#define BSS_SHM_KEY 0x6a600000 +#define BSS_SHM_PERM 0666 +#define BSS_SEM_KEY 360 +#define BSS_SEM_PERM 0666 +#define BSS_SEM_NUM 1 + +#define LED_SHM_KEY 0x6a800000 +#define LED_SHM_PERM 0666 +#define LED_SEM_KEY 380 +#define LED_SEM_PERM 0666 +#define LED_SEM_NUM 1 + +#define CLUSTER_SHM_KEY 0x6a900000 +#define CLUSTER_SHM_PERM 0666 +#define CLUSTER_SEM_KEY 390 +#define CLUSTER_SEM_PERM 0666 +#define CLUSTER_SEM_NUM 1 +/***************************************************/ + +/*############################################################################ + * shm structure + * between heartbeat transceiver and heartbeat processor + * & + * between heartbeat transceiver and svr cluster processor + *###########################################################################*/ + typedef struct cache_list{ + long msgSrcIP; + u_short msgLength; + BYTE msgContent[CACHE_BUF]; + }cache_list; + + typedef struct status_cahce{ + //int send_flag; + /*this flag is only for server cluster funciton + *0/1/2=ignore cluster FSM influence,directly send heartbeat/cluster permit *to send heartbeat/can't send heartbeat,waiting cluster's info + */ + u_short msgReadSub; + u_short msgWriteSub; + cache_list msgcache[CACHE_BUF]; + }status_cache; + +/*############################################################################ + * shm structure between real status processor and heartbeat processor + *###########################################################################*/ + +typedef struct clientinfo { + BYTE used_flag; // 0/1=not used/used + BYTE grp_id; // group which is requested by client now + BYTE is_responsed; // 0/1/2=not response/responsing/responsed + long ip; + unsigned int waittime; //if waittime>60seconds,timeout + BYTE updatetime[16]; //last time when client request info +} client_info; + +typedef struct conninfo { + BYTE avail_flag; // 0/1=unavailable/available + BYTE disp_name; // 0/1=not display/display + char name[16]; + char remark[44]; + BYTE lsys_type;// local device system type + BYTE lsys_id; //local device system id + BYTE lsub_id; //local device subsystem id + BYTE rsys_type; //remote device system type + BYTE rsys_id; //remote device system id + BYTE rsub_id; //remote device subsystem id +} conn_info; + +typedef struct btninfo { + BYTE used_flag; // 0/1=not use/used + BYTE sys_type; // device system type + BYTE sys_id; // device system id + BYTE sub_id; // device subsystem id +} btn_info; + +typedef struct grp_simple_stat { + btn_info btn[BTN_NUM]; // relationship between button and device + unsigned int coord[2]; // X,Y coord for group icon + int critical; // critical counter + int alarm; // alarm counter + BYTE isinstalled; // 0/1=not install/install + BYTE ts_id[2]; // Transit switch id(default=99,no ts) + BYTE disp_name; // 0/1=not display/display + BYTE grp_name[17]; // Group name + BYTE grp_remark[45]; // remark about group + BYTE stat_amount; // number of status for group icon + BYTE stat_direct; // direction of display status (0/1=h/v) + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3= uninstalled + */ +}grpsimple_stat; + +typedef struct subts_detail_stat { + BYTE subtype; //subsystem status + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat0[8];// simple status of this subsystem + /* substat0[0] -- if subsys is installed(0/1=not/yes) + * substat0[1] -- if subsys is normal(0/1=abnormal/normal) + * substat0[2] -- if subsys send master clock(0/1=not/sending) + * substat0[3] -- locking clock(0-7:2=normal,7=idle,other=abnormal) + */ + BYTE substat1[8]; // performance or status data of subsystem + /* substat1[0-1] -- CPU Load ('00'-'45') + * substat1[2-4] -- Clock frequency('000'-'255') + */ + + BYTE e1stat0[TS_E1][8]; //simple status of all E1 + /* e1[i][0] -- e1[i] installed/not installed (0/1=not/yes) + * e1[i][1] -- e1[i] layer 2 installed/not installed (0/1=not/yes) + * e1[i][2] -- e1[i] layer 1 connected/disconnected (0/1=not/yes) + * e1[i][3] -- e1[i] layer 2 connected/disconnected (0/1=not/yes) + * e1[i][4] -- e1[i] without/with ECHO CANCELLER (0/1=not/yes) + */ + BYTE e1stat1[TS_E1][8]; // performance or status data of all E1 + /* e1[i][0-1] -- e1[i] idle channels('00'/'30') + */ + + long lock_alarmtime; + /*last time inserting alarm log into db because of clock locking error + */ + long e1_alarmtime[TS_E1][2]; + /*last time inserting alarm log into db because of e1 1,2th error + */ + BYTE version_info[16]; + /*version information for the application + */ + BYTE updatetime[16]; //last time refreshing subsystem status +}subtsdetail_stat; + +typedef struct subpw_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat[2]; // status of this subsystem(0/1=abnomal/normal) + /* substat[0] -- if subsys is installed(0/1=not/yes) + * substat[1] -- if subsys is normal(0/1=abnormal/normal) + */ + + long pcard_alarmtime; + /*last time inserting alarm log into db because of power card error + */ + BYTE updatetime[16]; //last time refreshing subsystem status +}subpwdetail_stat; + +typedef struct ts_detail_stat { + BYTE grp_id; + BYTE clock_status;//if master clock is normal(0/1=N/Y) + long clock_alarmtime;//master clock status + /*last time inserting alarm log into db because of master clock error + */ + subtsdetail_stat sub_detail[TS_SUB]; + subpwdetail_stat subpw_detail[PW_SUB]; +}tsdetail_stat; + +typedef struct subts_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if TS subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subtssimple_stat; + + +typedef struct ts_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for ts icon + BYTE stat_direct; // direction of display status (0/1=h/v) + subtssimple_stat sub_simple[TS_SUB]; + subtssimple_stat subpw_simple[PW_SUB]; +} tssimple_stat; + +typedef struct subeth_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + long self_ip; //ip address of LAN Module self + BYTE mac[6]; //physical address of LAN Module + + BYTE substat[6]; + /* substat[0] -- if LAN Module is installed(0/1) + * substat[1] -- if LAN Module is normal(0/1) + * substat[2] -- if there is unreachable ip(0/1) + * substat[3] -- if LAN Module upload program to csu(0/1) + * substat[4] -- if csu is availabe (0/1) + */ + + BYTE cpu_load[2]; //CPU load of LAN module(hex value) + BYTE unreachable_ip[4]; //ip Can't be found by LAN Module (hex value) + long unreach_time; + + long alarmtime[2]; + /*CSU Upload program status + *alarmtime[0] -- can't reach target ip address + *alarmtime[1] -- uploading program + */ + BYTE version_info[16]; + /*version information for the application + */ + char updatetime[16]; +}subethdetail_stat; + +typedef struct eth_detail_stat { + BYTE grp_id; + subethdetail_stat sub_detail[ETH_SUB]; +}ethdetail_stat; + +typedef struct subeth_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if TS subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subethsimple_stat; + +typedef struct eth_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + subethsimple_stat sub_simple[ETH_SUB]; +} ethsimple_stat; + +typedef struct subrdev_detail_stat { + BYTE subtype; //0-4 + + BYTE timeout; //if the subsystem is timeout(0/1=timeout/not) + BYTE substat0[6]; + /* substat[0] -- if subsys is installed(0/1=N/Y) + * substat[1] -- if subsys is normal(0/1=N/Y) + * sysstat[2] -- if send master clock(0/1=N/Y) + */ + BYTE substat1[6]; + /* substat[0-1] -- used CPU(00/30) + */ + + BYTE e1stat0[RDEV_E1][8]; + /* e1[0] -- e1 installed/not installed (0/1=N/Y) + * e1[1] -- e1 layer 1 connected/disconnected (0/1=N/Y) + * e1[2] -- e1 layer 2 connected/disconnected (0/1=N/Y) + */ + BYTE e1stat1[RDEV_E1][8]; + /* e1[i][0-1] -- e1 idle channels('00'--'30') + */ + + long e1_alarmtime[RDEV_E1][2]; + /* alarmtime[i][0] -- e1[i] layer 1 + * alarmtime[i][1] -- e1[i] layer 2 + */ + BYTE version_info[16]; + /*version information for the application + */ + char updatetime[16]; +}subrdevdetail_stat; + +typedef struct rdev_detail_stat { + BYTE grp_id; + BYTE systype; //05=VPS;06=PCR + BYTE clock_status;//if master clock is normal(0/1=N/Y) + long clock_alarmtime;//master clock status + /*last time inserting alarm log into db because of master clock error + */ + subrdevdetail_stat sub_detail[RDEV_SUB]; +}rdevdetail_stat; + +typedef struct subrdev_simple_stat { + BYTE isinstalled; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + int waittime; // if Rdev subsystem is timeout + BYTE issent ; // if sending get request to timeout ts subsystem +} subrdevsimple_stat; + +typedef struct rdev_simple_stat { + BYTE isinstalled; // 0/1=N/Y + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for rdev icon + BYTE stat_direct; // direction of display status (0/1=h/v) + subrdevsimple_stat sub_simple[RDEV_SUB]; +} rdevsimple_stat; + +typedef struct bts_simple_stat { + BYTE isinstalled; // 0/1=not/installed + BYTE bts_site_id; + BYTE bts_link_id; + BYTE location; // 0/1=local/remote + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bts site icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} btssimple_stat; + +typedef struct bsc_simple_stat { + BYTE isinstalled; // 0/1=not/installed + BYTE location; // 0/1=local/remote + BYTE timeout; // 0/1=timeout/not timeout + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE grp_id; + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bsc icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} bscsimple_stat; + + +/* structure for server detail status in heartbeat processor + ************************************/ +typedef struct svr_detail_stat { + BYTE timeout; //if the subsystem is timeout(0/1=not/timeout) + BYTE grp_id; + BYTE systype; + BYTE sys_id; + int cpuused; + int viravail; + int virfree; + int memavail; + int memfree; + int hdavail; + int hdfree; + BYTE init_progress[3]; + BYTE proc_id[16]; + BYTE proc_status[16]; + BYTE subproc_num[16]; + BYTE sysstat[16]; // 0/1=abnormal/normal + /* + * 0=Normal,1=abnormal + *sysstat[0]: system status + * sysstat[1]:cpu status sysstat[2]:swap status + * sysstat[3]:memory status sysstat[4]:disk status + * sysstat[5]:proc_status sysstat[6]:server working status + * sysstat[7]:database status + */ + long alarmtime[6]; + + BYTE version_info[16]; + /*version information for the application + */ + BYTE updatetime[16]; +} svrdetail_stat; + +typedef struct svr_simple_stat { + BYTE grp_id; + BYTE location; + BYTE isinstalled; + int waittime; + BYTE ischanged; + /* 0/1=N/Y,process will send message to client if status is changed + */ + BYTE status; + /*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled + */ + int critical; // critical counter + int alarm; // alarm counter + BYTE disp_name; // 0/1=not display/display + BYTE name[16]; + BYTE remark[44]; + int coord[2]; + BYTE stat_amount; // number of status for bts site icon + BYTE stat_direct; // direction of display status (0/1=h/v) +} svrsimple_stat; + +struct alarm_log { + BYTE systype; + BYTE sys_id; + BYTE sub_id; + BYTE e1no; + BYTE alarmnum; + BYTE occurtime[16]; +}; + +typedef struct ts_alarm_log { + int readSub; + int writeSub; + struct alarm_log alrlist[ALARM_NUM]; +} tsalarm_log; + +typedef struct ask_alarm_log { + long client_ip; //ip address where the request is sent from + int init_Req_Flag; + int readSub; + int writeSub; + struct alarm_log alrlist[ALARM_NUM]; +} askalarm_log; + +/* + * shared memory structure + *************************/ +typedef struct shm_ts_stat { + BYTE init_flag; + BYTE sys_struct;//0/1=single/double plane system structure + grpsimple_stat grp_simple[GRP_NUM]; + tsdetail_stat ts_detail[TS_NUM]; + tssimple_stat ts_simple[TS_NUM]; + ethdetail_stat eth_detail[ETH_NUM]; + ethsimple_stat eth_simple[ETH_NUM]; + rdevdetail_stat vps_detail[RDEV_NUM]; + rdevsimple_stat vps_simple[RDEV_NUM]; + rdevdetail_stat pcr_detail[RDEV_NUM]; + rdevsimple_stat pcr_simple[RDEV_NUM]; + svrdetail_stat svr_detail[SVR_NUM]; + svrsimple_stat svr_simple[SVR_NUM]; + /* + sysnum=systype*2+sys_id + svr_simple[0]=OMC-0 + svr_simple[1]=OMC-1 + svr_simple[2]=HLR-0 + svr_simple[3]=HLR-1 + svr_simple[4]=PRP-0 + svr_simple[5]=PRP-1 + svr_simple[6]=CDR-0 + svr_simple[7]=CDR-1 + */ + bscsimple_stat bsc_simple[BSC_NUM]; + + BYTE global_status[ETH_NUM]; + conn_info connection[CONN_NUM]; + client_info client[CLIENT_NUM]; + /*global_status[0]= if normal ;global_status[1]= if changed*/ + tsalarm_log alarmlog; +} shm_stat; + +/*****************************************************************************/ +/* Lan Module's global status*/ +typedef struct global_status{ + BYTE eth_mac[ETH_NUM][ETH_SUB][7]; + long update_time[ETH_NUM][ETH_SUB]; + long alarm_time[ETH_NUM][ETH_SUB]; +}eth_global; +/***************************************************/ + +/*****************************************************************************/ +/* structure for BSS simple status in heartbeat processor + ************************************/ +typedef struct bss_simple_stat { + BYTE isinstalled[BSS_NUM]; + BYTE ischanged[BSS_NUM]; + BYTE isnormal[BSS_NUM]; + unsigned int waittime[BSS_NUM]; +} bsssimple_stat; +/***************************************************/ + +#endif /*OMC_PUBLIC__H */ diff --git a/omc/plat/public_bak/src/include/pub_base.h b/omc/plat/public_bak/src/include/pub_base.h new file mode 100644 index 0000000..d1638b0 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_base.h @@ -0,0 +1,127 @@ +////////////////////////////////////////////////// +//Title : pub_basic.c +//Auhtor : Liu Wei +//Desc : public basic function +//Created : 2007-06-23 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_BASE_H_ +#define _PUB_BASE_H_ + +typedef struct VALUE_STRING +{ + u32 dValue; + u8 *pStr; +} StringVal; + +#define ALPHA_TABLE_LOWER "abcdefghijklmnopqrstuvwsyz" +#define ALPHA_TABLE_UPPER "ABCDEFGHIJKLMNOPQRSTUVWSYZ" + +#define NOTSO(n) ( !(n) ) +#define IsNull(n) ( ((n) == NULL) ) +#define CNULL '\0' +#define IsChNull(ch) ( ch==CNULL ) +#define STR_CHECK_LAST(str,ch) ( str[strlen(str)-1] == ch ) +#define STR_CHECK_FIRST(str,ch) ( str[0] == ch ) +#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL ) + + +#define BitSet(arg,posn) ((arg) | (1L << (posn))) +#define BitClr(arg,posn) ((arg) & ~(1L << (posn))) +#define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) +#define BitTst(arg,posn) (!(!((arg) & (1L << (posn))))) + + +#define HexToChar(ch) ( (ch) + ( ((ch) > 9)? 'A'-10 : '0') ) + +/////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef MAX +#define MAX(a, b) ( (a) > (b) ? (a) : (b) ) +#define MIN(a, b) ( (a) < (b) ? (a) : (b) ) +#endif + +/////////////////////////////////////////////////////////////////////////// +// +// Name : GET_U8 GET_U16 GET_U32 +// Function : Return the u8 /u16 / u32 value of the pointer memery +// Parameter: x : pointer +// +/////////////////////////////////////////////////////////////////////////// +#define GET_U8( x ) ( *( (u8 *) (x) ) ) +#define GET_U16( x ) ( *( (u16 *) (x) ) ) +#define GET_U32( x ) ( *( (u32 *) (x) ) ) + +/////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////// +#define U16_LOW_BYTE ( x ) ( (u8 )( ((u16) (x) ) & 0xFF ) ) +#define U16_HIG_BYTE ( x ) ( (u8 )( ((u16) (x) ) >> 8 ) ) + +#define LSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[0]) * 256) + (uVal)[1] ) +#define MSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[1]) * 256) + (uVal)[0] ) + +#define LSB_WORD2BYTE( wVal , uVal ) \ + (uVal)[0] = ((wVal) / 256); \ + (uVal)[1] = ((wVal) & 0xFF ) + +#define MSB_WORD2BYTE( wVal , uVal ) \ + (uVal)[1] = ((wVal) / 256 ); \ + (uVal)[0] = ((wVal) & 0xFF) + +/////////////////////////////////////////////////////////////////////////// +// +// Name : ARR_SIZE +// Function : Return array size of a +// Parameter: a : array +// +/////////////////////////////////////////////////////////////////////////// +#define ARR_SIZE( a ) ( sizeof( (a) ) / sizeof( (a[0]) ) ) + +/////////////////////////////////////////////////////////////////////////// +// +// Name : STR +// Function : Convert the s to string +// Parameter: a : a value you want to Convert to string but no need "" +// e.g. : printf(STR(if(NOTSO(a)) return 0)); +/////////////////////////////////////////////////////////////////////////// +#define STR(s) #s +#define FILL_VALSTR(n) {n,#n} +#define GET_FILE_NAME(fn) \ + { \ + static char fn[] = STR(_FILE_); \ + } + +#define GetValueString(i,p,Maxtrix,IdMax) \ + { \ + if( (i) >= (IdMax) ) \ + { \ + (p) = Maxtrix[(IdMax)].pStr; \ + } \ + else \ + { \ + (p) = Maxtrix[(i)].pStr; \ + } \ + } + +#define GET_MODULE_VER(x) (x##_VERSION) + +#define FPOS( type, field ) \ +/*lint -e545 */ ( ( dword ) & ( ( type * ) 0 )->field ) /*lint +e545 */ + +#define FSIZ( type, field ) sizeof( ((type *) 0)->field ) + +/////////////////////////////////////////////////////////////////////////// +// DivRndUp: Divide and Round Up /// +/////////////////////////////////////////////////////////////////////////// + +#define DivRndUp(Num,Div) ( ((Num) % (Div))?((Num)/(Div) + 1):((Num)/(Div)) ) + + +#endif diff --git a/omc/plat/public_bak/src/include/pub_debug.h b/omc/plat/public_bak/src/include/pub_debug.h new file mode 100644 index 0000000..adb25b3 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_debug.h @@ -0,0 +1,43 @@ +////////////////////////////////////////////////// +//Title : pub_debug.h +//Auhtor : Liu Wei +//Desc : public debug api header +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_DEBUG_H_ +#define _PUB_DEBUG_H_ + +#include "stdio.h" +#include "assert.h" +#include "string.h" +#include "stdlib.h" +#include +#include + + +extern void WxcDump(int nSigno); + +extern void WxcBackTrace(); + +#ifdef DEBUG +#define WxcAssert(Expression,pStr) \ + { \ + int nVal = (Expression); \ + if(!nVal) \ + { \ + WxcBackTrace(); \ + } \ + assert( nVal && pStr ); \ + } + +#else +#define WxcAssert(uVal,pStr) +#endif + +#endif + diff --git a/omc/plat/public_bak/src/include/pub_file.h b/omc/plat/public_bak/src/include/pub_file.h new file mode 100644 index 0000000..b8bf495 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_file.h @@ -0,0 +1,22 @@ +////////////////////////////////////////////////// +//Title : wxc_file.h +//Auhtor : Liu Wei +//Desc : wxc file handle header +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_FILE_H_ +#define _PUB_FILE_H_ + +#include "./public.h" +#include "./includes.h" +#include "./pub_base.h" + + + + +#endif diff --git a/omc/plat/public_bak/src/include/pub_fmt.h b/omc/plat/public_bak/src/include/pub_fmt.h new file mode 100644 index 0000000..b0ffc29 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_fmt.h @@ -0,0 +1,132 @@ +////////////////////////////////////////////////// +//Title : pub_convert.h +//Auhtor : Liu Wei +//Desc : public type fomat convert inplementation +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// lCRD software network data type assumpsit +// +// Memery Low <<============[Little Endian]===========>> Memery High +// Type abbr. e.g. Remark +// const value CVal 0x12345678 +// Host BCD HBcd/BCd 0x78 0x56 0x34 0x12 +// Anti BCD ABcd 0x87 0x65 0x43 0x21 +// NetBCD NBcd 0x12 0x34 0x56 0x78 +// String Str 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 "12345678" +// U64 U64 0x4E 0x61 0xBC 0x00 0x00 0x00 0x00 0x00 12345678=0xBC614E +// Digit Dig 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef _PUB_FMT_H_ +#define _PUB_FMT_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_debug.h" + +extern inline char HexToCh ( u8 uHex ); +extern inline u8 ChToHex ( char ch ); + + +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len); +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len); + +/////////////////////////////////////////////////////////////////////////// +// ReverseByte : 0010 1010 =>> 0101 0100 +// +/////////////////////////////////////////////////////////////////////////// +extern u8 ReverseByte(u8 uByteIn ); + +/////////////////////////////////////////////////////////////////////////// +// ReverseBCD : 0x12 0x34 0x56 0x78 =>> 0x21 0x43 0x65 0x87 +// +/////////////////////////////////////////////////////////////////////////// +extern void ReverseBCD( u8 *pDst , const u8 *pSrc , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// ReverseArray : 0x12 0x34 0x56 0x78 =>> 0x78 0x56 0x34 0x12 +// +/////////////////////////////////////////////////////////////////////////// +extern void ReverseArray( u8 *pDst , const u8 *pSrc , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToStr : 0x12 0x34 0x56 0x78 =>> "12345678" +// +/////////////////////////////////////////////////////////////////////////// +extern void BcdToStr( char *pStr , const u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToU64 : 0x12 0x34 0x56 0x78 =>> 12345678 +// +////////////////////////////////////////////////////////////////////////// +extern u64 BcdToU64( const u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// BcdToDig : 0x12 0x34 0x56 =>>0x01 0x02 0x03 0x04 0x05 0x06 +// +/////////////////////////////////////////////////////////////////////////// +extern int BcdToDig( u8 *pDig , int nDigBuffLen, u8 *pBcd , int nBcdLen ); + +/////////////////////////////////////////////////////////////////////////// +// StrToBcd : "123456" =>> 0x12 0x34 0x56 +// +/////////////////////////////////////////////////////////////////////////// +extern int StrToBcd( u8 *pBcd , char *pStr , int nBcdBuffLen ); + +/////////////////////////////////////////////////////////////////////////// +// U64ToBcd : 1234567 => 0x01 0x23 0x45 0x67 +// +/////////////////////////////////////////////////////////////////////////// +extern int U64ToBcd( u8 *pBcd ,u64 llInput , int nBcdBuffLen ); + +/////////////////////////////////////////////////////////////////////////// +// DigToBcd : 0x01 0x02 0x03 x04 0x05 0x06 0x07 => 0x01 0x23 0x45 0x67 +// +/////////////////////////////////////////////////////////////////////////// +extern int DigToBcd( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen ); +extern int DigToBcdE( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen , int nEnd ); + + +int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen ); +int Bcd2Str ( char *pStr, const BYTE * pBcd, int len ); +int DigitsLen(BYTE *pDigits, int maxLen); +int BcdLen(BYTE *pBcd, int maxLen); +int Digits2Str(char *pStr, BYTE *pDigits, int DigitsLen); +ull Digits2Ull(BYTE *pDigits, int DigitsLen); +int Ull2Digits(BYTE *pDigits, ull value, int DigitsLen); +int Str2Digits(BYTE *pDigits, char *pStr, int DigitsLen); +int Ull2Digits_Ralign(BYTE *pDigits, ull value, int DigitsLen); +ull Bcd2Ull(BYTE *pBcd, int BcdLen); +int Ull2Bcd(BYTE *pBcd, ull value, int BcdLen); +int Digits2Bcd(BYTE *pBcd, BYTE *pDigits, int maxLen); +int Bcd2Digits(BYTE *pDigits, BYTE *pBcd, int maxLen); +int Bcd2Digits_dLen(BYTE *pDigits, BYTE *pBcd, int maxLen); +int Str2Oid(DWORD *pOid, char *pStr, BYTE maxLen); +int TrimLeft(char *pStr); +int TrimRight(char *pStr); +int Array2Digits(BYTE *pDigits, BYTE *pArray, int ArrayLen); +ull Str2Ull(char *pStr); +int Digits2Array(BYTE *pArray, BYTE *pDigits, int DigitsLen); +int Bcd2Array(BYTE *pArray, BYTE *pBcd, int BcdLen); +int Str2Array(BYTE *pArray, char *str, int ArrayLen); +BYTE EditDigits(BYTE *digits_out, BYTE len_max, BYTE *digits_in, BYTE len_in, BYTE len_del, BYTE *digits_ins, BYTE len_ins, BYTE filler); +BYTE DelDigits(BYTE *in_digit, BYTE in_len, BYTE *out_digit, BYTE count, BYTE filler); +void DWORD2BYTE(BYTE *pdword, BYTE *pbyte, int len); +void u32tobyte(u8 *str, u32 data); +u8 u16tobcd(u8 *bcd_string, u16 data); +u16 bcdtou16(u8 *bcd_string, u8 bcd_len); +u8 u32tobcd(u8 *bcd_string, u32 data); +u32 bcdtou32(u8 *bcd_string, u8 bcd_len); +void AsciiToRbcd(BYTE *bcd_buf, const char *ascii_buf, int len); + + +#endif + diff --git a/omc/plat/public_bak/src/include/pub_include.h b/omc/plat/public_bak/src/include/pub_include.h new file mode 100644 index 0000000..1eaac8a --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_include.h @@ -0,0 +1,39 @@ +////////////////////////////////////////////////// +//Title : pub_incudes.h +//Auhtor : Liu Wei +//Desc : public header includes +//Created : 2007-07-13 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _PUB_INCLUDE_H_ +#define _PUB_INCLUDE_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "asn1.h" +#include "crypt.h" +#include "bisearch.h" +#include "pub_base.h" +#include "pub_debug.h" +#include "pub_log.h" +#include "pub_file.h" +#include "pub_list.h" +#include "pub_malloc.h" +#include "pub_fmt.h" +#include "pub_base.h" +#include "pub_time.h" +#include "pub_timer.h" +#include "pub_sys.h" +#include "pub_str.h" +#include "pub_inet.h" +#include "pub_wnet.h" +#include "pub_netcap.h" +#include "pub_sdp.h" + +#endif diff --git a/omc/plat/public_bak/src/include/pub_inet.h b/omc/plat/public_bak/src/include/pub_inet.h new file mode 100644 index 0000000..157452f --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_inet.h @@ -0,0 +1,75 @@ +////////////////////////////////////////////////// +//Title : pub_inet.h +//Auhtor : Liu Wei +//Desc : public inet function header +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_INET_H_ +#define _PUB_INET_H_ + +#include "public.h" +#include "includes.h" +#include "pub_debug.h" + +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// + +#define MAXINTERFACES 16 + +typedef struct IF_ADDR +{ + u8 uIfNum; + struct + { + u32 dIfIP; + u8 uIfState; + } + tIfEntity[MAXINTERFACES]; +} +IfAddr; + +extern int GetNetIfInfo ( IfAddr * pIfAddr ); + +extern u32 GetLocalIP(); + +/////////////////////////////////////////////////////////////////////////// +// Ping Interface +/////////////////////////////////////////////////////////////////////////// + +#define PACKET_SIZE 4096 +#define MAX_NO_PACKETS 3 + +typedef void PingCallBack( int nPingResult ); + +typedef struct ICMP_SERVICE +{ + u8 uSrvState; + u8 uIcmpState; + u8 uPackNo; + u8 uDataLen; + u8 nPackNumSend; + u8 nPackNumRecv; + u8 aSendBuff[PACKET_SIZE]; + u8 aRecvBuff[PACKET_SIZE]; + u32 wSockfd; + pid_t tPid; + struct sockaddr_in tToAddr; + struct sockaddr_in tFromAddr; + struct protoent *pProtoent; + PingCallBack *fCallBack; +} +IcmpSrv; + +extern int PingInit ( IcmpSrv *pIS , int nDataLen ); + +extern int PingStart( IcmpSrv *pIS , char *sIP , PingCallBack fCallBack ); + +extern int PingTimer ( IcmpSrv *pIS ); + +#endif diff --git a/omc/plat/public_bak/src/include/pub_list.h b/omc/plat/public_bak/src/include/pub_list.h new file mode 100644 index 0000000..43b49a5 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_list.h @@ -0,0 +1,501 @@ +////////////////////////////////////////////////// +//Title : pool.c +//Auhtor : Liu Wei +//Desc : List and Pool Queue struct implement +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_LIST_H_ +#define _PUB_LIST_H_ + +//LIFO Queue + +#define LIFOQ_HEAD( name , type ) \ + struct name \ + { \ + struct type *pLqFirst;/*First elment*/ \ + } + +#define LIFOQ_ENTRY(type) \ + struct \ + { \ + struct type *pLqNext; \ + } + +#define LIFOQ_EMPTY(head) \ + ((head)->pLqFirst == NULL) + +#define LIFOQ_FIRST(head) \ + ((head)->pLqFirst) + +#define LIFOQ_FOREACH(var, head, field) \ + for((var) = (head)->pLqFirst; (var); (var) = (var)->field.pLqNext) + +#define LIFOQ_INIT(head) \ + { \ + (head)->pLqFirst = NULL; \ + } + +#define LIFOQ_INSERT_AFTER(lifoq_elm, elm, field) \ + do \ + { \ + (elm)->field.pLqNext = (lifoq_elm)->field.pLqNext; \ + (lifoq_elm)->field.pLqNext = (elm); \ + } while (0) + +#define LIFOQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + (elm)->field.pLqNext = (head)->pLqFirst; \ + (head)->pLqFirst = (elm); \ + } while (0) + +#define LIFOQ_NEXT(elm, field) ((elm)->field.pLqNext) + +#define LIFOQ_REMOVE_HEAD(head, field) \ + do \ + { \ + (head)->pLqFirst = (head)->pLqFirst->field.pLqNext; \ + } while (0) + +#define LIFOQ_REMOVE(head, elm, type, field) \ + do \ + { \ + if ((head)->pLqFirst == (elm)) \ + { \ + LIFOQ_REMOVE_HEAD((head), field); \ + } \ + else \ + { \ + struct type *curelm = (head)->pLqFirst; \ + \ + while( curelm->field.pLqNext != (elm) ) \ + { \ + curelm = curelm->field.pLqNext; \ + } \ + curelm->field.pLqNext = \ + curelm->field.pLqNext->field.pLqNext; \ + } \ + } while (0) + +//FIFO Quence + +#define FIFOQ_HEAD(name, type) \ + struct name \ + { \ + struct type *pFqFirst;/* first element */ \ + struct type **pFqLast;/* addr of last next element */ \ + } + +#define FIFOQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).pFqFirst } + +#define FIFOQ_ENTRY(type) \ + struct \ + { \ + struct type *pFqNext; /* next element */ \ + } + +#define FIFOQ_EMPTY(head) ((head)->pFqFirst == NULL) + +#define FIFOQ_INIT(head) \ + do \ + { \ + (head)->pFqFirst = NULL; \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_FIRST(head) ((head)->pFqFirst) + +#define FIFOQ_LAST(head, type, field) \ + (FIFOQ_EMPTY(head) ? NULL : ((struct type *) \ + ((char *)((head)->spTQLast) - __offsetof(struct type, field)))) + +#define FIFOQ_FOREACH(var, head, field) \ + for((var) = (head)->pFqFirst; (var); (var) = (var)->field.pFqNext) + +#define FIFOQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pFqNext = (head)->pFqFirst) == NULL) \ + (head)->spTQLast = &(elm)->field.pFqNext; \ + (head)->pFqFirst = (elm); \ + } while (0) + +#define FIFOQ_INSERT_TAIL(head, elm, field) \ + do \ + { \ + (elm)->field.pFqNext = NULL; \ + *(head)->spTQLast = (elm); \ + (head)->spTQLast = &(elm)->field.pFqNext; \ + } while (0) + +#define FIFOQ_INSERT_AFTER(head, tqelm, elm, field) \ + do \ + { \ + if (((elm)->field.pFqNext = (tqelm)->field.pFqNext) == NULL)\ + (head)->spTQLast = &(elm)->field.pFqNext; \ + (tqelm)->field.pFqNext = (elm); \ + } while (0) + +#define FIFOQ_NEXT(elm, field) ((elm)->field.pFqNext) + +#define FIFOQ_REMOVE_HEAD(head, field) \ + do \ + { \ + if (((head)->pFqFirst = (head)->pFqFirst->field.pFqNext) == NULL) \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_REMOVE_HEAD_UNTIL(head, elm, field) \ + do \ + { \ + if (((head)->pFqFirst = (elm)->field.pFqNext) == NULL) \ + (head)->spTQLast = &(head)->pFqFirst; \ + } while (0) + +#define FIFOQ_REMOVE(head, elm, type, field) \ + do \ + { \ + if ((head)->pFqFirst == (elm)) \ + { \ + FIFOQ_REMOVE_HEAD(head, field); \ + } \ + else \ + { \ + struct type *curelm = (head)->pFqFirst; \ + while( curelm->field.pFqNext != (elm) ) \ + curelm = curelm->field.pFqNext; \ + \ + if((curelm->field.pFqNext = \ + curelm->field.pFqNext->field.pFqNext) == NULL)\ + (head)->spTQLast = &(curelm)->field.pFqNext; \ + } \ + } while (0) + +// List + +#define LIST_HEAD(name, type) \ + struct name \ + { \ + struct type *pListFirst; /* first element */ \ + } + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ + struct \ + { \ + struct type *pListNext; /* next element */ \ + struct type **pListPrev; /* address of previous next element */ \ + } + +/* + * List functions. + */ + +#define LIST_EMPTY(head) ((head)->pListFirst == NULL) + +#define LIST_FIRST(head) ((head)->pListFirst) + +#define LIST_FOREACH(var, head, field) \ + for((var) = (head)->pListFirst; (var); (var) = (var)->field.pListNext) + +#define LIST_INIT(head) \ + do \ + { \ + (head)->pListFirst = NULL; \ + } while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) \ + do \ + { \ + if (((elm)->field.pListNext = (listelm)->field.pListNext) != NULL) \ + { \ + (listelm)->field.pListNext->field.pListPrev = \ + &(elm)->field.pListNext; \ + } \ + (listelm)->field.pListNext = (elm); \ + (elm)->field.pListPrev = &(listelm)->field.pListNext; \ + } while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) \ + do \ + { \ + (elm)->field.pListPrev = (listelm)->field.pListPrev; \ + (elm)->field.pListNext = (listelm); \ + *(listelm)->field.pListPrev = (elm); \ + (listelm)->field.pListPrev = &(elm)->field.pListNext; \ + } while (0) + +#define LIST_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pListNext = (head)->pListFirst) != NULL) \ + (head)->pListFirst->field.pListPrev = &(elm)->field.pListNext; \ + (head)->pListFirst = (elm); \ + (elm)->field.pListPrev = &(head)->pListFirst; \ + } while (0) + +#define LIST_NEXT(elm, field) ((elm)->field.pListNext) + +#define LIST_REMOVE(elm, field) \ + do \ + { \ + if ((elm)->field.pListNext != NULL) \ + (elm)->field.pListNext->field.pListPrev = \ + (elm)->field.pListPrev; \ + *(elm)->field.pListPrev = (elm)->field.pListNext; \ + } while (0) + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ + struct name \ + { \ + struct type *pTQFirst; /* first element */ \ + struct type **pTQLast; /* addr of last next element */ \ + } + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).pTQFirst } + +#define TAILQ_ENTRY(type) \ + struct \ + { \ + struct type *pTQNext; /* next element */ \ + struct type **pTQPrev; /* address of previous next element */ \ + } + +/* + * Tail queue functions. + */ +#define TAILQ_EMPTY(head) ((head)->pTQFirst == NULL) + +#define TAILQ_FOREACH(var, head, field) \ + for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FIRST(head) ((head)->pTQFirst) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->pTQLast))->pTQLast)) + +#define TAILQ_NEXT(elm, field) ((elm)->field.pTQNext) + +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.pTQPrev))->pTQLast)) + +#define TAILQ_INIT(head) \ + do \ + { \ + (head)->pTQFirst = NULL; \ + (head)->pTQLast = &(head)->pTQFirst; \ + } while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) \ + do \ + { \ + if (((elm)->field.pTQNext = (head)->pTQFirst) != NULL) \ + (head)->pTQFirst->field.pTQPrev = \ + &(elm)->field.pTQNext; \ + else \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + (head)->pTQFirst = (elm); \ + (elm)->field.pTQPrev = &(head)->pTQFirst; \ + } while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) \ + do \ + { \ + (elm)->field.pTQNext = NULL; \ + (elm)->field.pTQPrev = (head)->pTQLast; \ + *(head)->pTQLast = (elm); \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + } while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \ + do \ + { \ + if (((elm)->field.pTQNext = (listelm)->field.pTQNext) != NULL) \ + (elm)->field.pTQNext->field.pTQPrev = &(elm)->field.pTQNext; \ + else \ + (head)->pTQLast = &(elm)->field.pTQNext; \ + (listelm)->field.pTQNext = (elm); \ + (elm)->field.pTQPrev = &(listelm)->field.pTQNext; \ + } while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) \ + do { \ + (elm)->field.pTQPrev = (listelm)->field.pTQPrev; \ + (elm)->field.pTQNext = (listelm); \ + *(listelm)->field.pTQPrev = (elm); \ + (listelm)->field.pTQPrev = &(elm)->field.pTQNext; \ + } while (0) + +#define TAILQ_REMOVE(head, elm, field) \ + do { \ + if (((elm)->field.pTQNext) != NULL) \ + (elm)->field.pTQNext->field.pTQPrev = (elm)->field.pTQPrev; \ + else \ + (head)->pTQLast = (elm)->field.pTQPrev; \ + *(elm)->field.pTQPrev = (elm)->field.pTQNext; \ + } while (0) + +/* + * Pool -- Circular queue definitions. + */ +#define POOL_HEAD(name, type) \ + struct name \ + { \ + struct type *pPoolFirst; /* first element */ \ + struct type *pPoolLast; /* last element */ \ + } + +#define POOL_ENTRY(type) \ + struct \ + { \ + struct type *pPoolNext; /* next element */ \ + struct type *pPoolPrev; /* previous element */ \ + } + +/* + * Pool -- Circular queue functions. + */ + +#define POOL_EMPTY(head) ((head)->pPoolFirst == (void *)(head)) + +#define POOL_FIRST(head) ((head)->pPoolFirst) + +#define POOL_FOREACH(var, head, field) \ + for((var) = (head)->pPoolFirst; \ + (var) != (void *)(head); \ + (var) = (var)->field.pPoolNext) + +#define POOL_FOREACH_REVERSE(var, head, field) \ + for((var) = (head)->pPoolLast; \ + (var) != (void *)(head); \ + (var) = (var)->field.pPoolPrev) + +#define POOL_INIT(head) \ + do \ + { \ + (head)->pPoolFirst = (void *)(head); \ + (head)->pPoolLast = (void *)(head); \ + } while (0) + +#define POOL_INSERT_AFTER(head, listelm, elm, field) \ + do { \ + (elm)->field.pPoolNext = (listelm)->field.pPoolNext; \ + (elm)->field.pPoolPrev = (listelm); \ + if ((listelm)->field.pPoolNext == (void *)(head)) \ + (head)->pPoolLast = (elm); \ + else \ + (listelm)->field.pPoolNext->field.pPoolPrev = (elm); \ + (listelm)->field.pPoolNext = (elm); \ + } while (0) + +#define POOL_INSERT_BEFORE(head, listelm, elm, field) \ + do { \ + (elm)->field.pPoolNext = (listelm); \ + (elm)->field.pPoolPrev = (listelm)->field.pPoolPrev; \ + if ((listelm)->field.pPoolPrev == (void *)(head)) \ + (head)->pPoolFirst = (elm); \ + else \ + (listelm)->field.pPoolPrev->field.pPoolNext = (elm); \ + (listelm)->field.pPoolPrev = (elm); \ + } while (0) + +#define POOL_INSERT_HEAD(head, elm, field) \ + do { \ + (elm)->field.pPoolNext = (head)->pPoolFirst; \ + (elm)->field.pPoolPrev = (void *)(head); \ + if ((head)->pPoolLast == (void *)(head)) \ + (head)->pPoolLast = (elm); \ + else \ + (head)->pPoolFirst->field.pPoolPrev = (elm); \ + (head)->pPoolFirst = (elm); \ + } while (0) + +#define POOL_INSERT_TAIL(head, elm, field) \ + do { \ + (elm)->field.pPoolNext = (void *)(head); \ + (elm)->field.pPoolPrev = (head)->pPoolLast; \ + if ((head)->pPoolFirst == (void *)(head)) \ + (head)->pPoolFirst = (elm); \ + else \ + (head)->pPoolLast->field.pPoolNext = (elm); \ + (head)->pPoolLast = (elm); \ + } while (0) + +#define POOL_LAST(head) ((head)->pPoolLast) + +#define POOL_NEXT(elm,field) ((elm)->field.pPoolNext) + +#define POOL_PREV(elm,field) ((elm)->field.pPoolPrev) + +#define POOL_REMOVE(head, elm, field) \ + do { \ + if ((elm)->field.pPoolNext == (void *)(head)) \ + (head)->pPoolLast = (elm)->field.pPoolPrev; \ + else \ + (elm)->field.pPoolNext->field.pPoolPrev = (elm)->field.pPoolPrev; \ + \ + if ((elm)->field.pPoolPrev == (void *)(head)) \ + (head)->pPoolFirst = (elm)->field.pPoolNext; \ + else \ + (elm)->field.pPoolPrev->field.pPoolNext =(elm)->field.pPoolNext; \ + } while (0) + +#ifdef _KERNEL +/* + * XXX insque() and remque() are an old way of handling certain queues. + * They bogusly assumes that all queue heads look alike. + */ + +struct quehead +{ + struct quehead *qh_link; + struct quehead *qh_rlink; +}; + +#ifdef __GNUC__ + +static __inline void insque ( void *a, void *b ) +{ + struct quehead *element = a, *head = b; + + element->qh_link = head->qh_link; + element->qh_rlink = head; + head->qh_link = element; + element->qh_link->qh_rlink = element; +} + +static __inline void remque ( void *a ) +{ + struct quehead *element = a; + + element->qh_link->qh_rlink = element->qh_rlink; + element->qh_rlink->qh_link = element->qh_link; + element->qh_rlink = 0; +} + +#else /* !__GNUC__ */ + +void insque __P ( ( void *a, void *b ) ); +void remque __P ( ( void *a ) ); + +#endif /* __GNUC__ */ + +#endif /* _KERNEL */ +#endif diff --git a/omc/plat/public_bak/src/include/pub_log.h b/omc/plat/public_bak/src/include/pub_log.h new file mode 100644 index 0000000..c3d8cce --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_log.h @@ -0,0 +1,68 @@ +////////////////////////////////////////////////// +//Title : pub_log.h +//Auhtor : Liu Wei +//Desc : public log function header +//Created : 2007-05-21 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _PUB_LOG_H_ +#define _PUB_LOG_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_debug.h" +#include "pub_fmt.h" +#include + +#define RESET 0 +#define BRIGHT 1 +#define DIM 2 +#define UNDERLINE 3 +#define BLINK 4 +#define REVERSE 7 +#define HIDDEN 8 +#define BLACK 0 +#define RED 1 +#define GREEN 2 +#define YELLOW 3 +#define BLUE 4 +#define MAGENTA 5 +#define CYAN 6 +#define WHITE 7 + + +///////////////////////////////////////////////////////////////////////// +// Public print information +///////////////////////////////////////////////////////////////////////// + +#define PIF_INFO 0x01 // Normal Information +#define PIF_WARN 0x02 // Warnings +#define PIF_GERR 0x04 // General errors +#define PIF_CERR 0x10 // Critical errors +#define PIF_DBG 0x20 // Debugging +#define PIF_UNKN 0x40 // Things that are unknown + +// Default SIM output +#define PIF_DEFAULT (PIF_INFO|PIF_WARN|PIF_CERR) +// Everything, but DBG +#define PIF_ALL (PIF_INFO|PIF_WARN|PIF_GERR|PIF_CERR|PIF_UNKN) + +#define SYSERR strerror(errno) + +extern char *ByteBinToStr( char *pDst , const u8 *pSrc , int nByte ); +extern char *TxtColor ( int nAttr, int nFg, int nBg, char *pStr ); +extern int MsgToFmtLog ( const BYTE * pBcd, int nBcdLen, char *pStr, int nStrBuffSize ); + +#ifdef DEBUG +#define WxcDebugLog printf +#else +#define WxcDebugLog +#endif + +#endif diff --git a/omc/plat/public_bak/src/include/pub_malloc.h b/omc/plat/public_bak/src/include/pub_malloc.h new file mode 100644 index 0000000..67eb514 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_malloc.h @@ -0,0 +1,26 @@ +////////////////////////////////////////////////// +//Title : pub_malloc.h +//Auhtor : Liu Wei +//Desc : Public heap memery management +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_MALLOC_H_ +#define _PUB_MALLOC_H_ + +#include "public.h" +#include "includes.h" +//#ifdef _USE_SYS_MALLOC_ + +#define WxcMalloc malloc +#define WxcFree free + +//#endif + +#endif + + diff --git a/omc/plat/public_bak/src/include/pub_netcap.h b/omc/plat/public_bak/src/include/pub_netcap.h new file mode 100644 index 0000000..ef2cc44 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_netcap.h @@ -0,0 +1,35 @@ +////////////////////////////////////////////////// +//Title : pub_netcap.h +//Auhtor : Liu Wei +//Desc : public netcap header +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_NETCAP_H_ +#define _PUB_NETCAP_H_ + +#include "public.h" +#include "includes.h" + +typedef struct NET_CAPTURE +{ + u8 uState; + u32 nSock; + u32 nPort; + u32 nDstIp; +} +NetCap; + +int NcInit(); +int NcStart( u32 wIP , u32 wPort ); +int NcStop( ); +void NcSetPort( u32 port ); +void NcSetIP( u32 ip ); +void NcMtp3Send( u8 *pMtp3Msg , u32 wMtp3Len , u8 uAnsiFlag ); +int NcSccpSend( u8 *pSccpMsg , u32 wSccpLen , u8 *pIntraMsg , u8 uAnsiFlag ); + +#endif diff --git a/omc/plat/public_bak/src/include/pub_sdp.h b/omc/plat/public_bak/src/include/pub_sdp.h new file mode 100644 index 0000000..5301db5 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_sdp.h @@ -0,0 +1,196 @@ +#ifndef _PUB_SDP__H +#define _PUB_SDP__H + +#define PUB_SDP_MAX_USER_NAME_LEN 64 +#define PUB_SDP_MAX_SESS_ID_LEN 32 +#define PUB_SDP_MAX_SESS_VER_LEN 16 +#define PUB_SDP_MAX_ADDR_LEN 64 +#define PUB_SDP_MAX_SESS_NAME_LEN 64 +#define PUB_SDP_MAX_SESS_INFO_LEN 64 +#define PUB_SDP_MAX_PAYLOAD_NUM 8 +#define PUB_SDP_MAX_MEDIA_NUM 8 +#define PUB_SDP_MAX_ATTR_NUM 16 +#define PUB_SDP_MAX_ATTR_LEN 32 + +#define PUB_SDP_FLAG_V 0x00000001 +#define PUB_SDP_FLAG_O 0x00000002 +#define PUB_SDP_FLAG_S 0x00000004 +#define PUB_SDP_FLAG_I 0x00000008 +#define PUB_SDP_FLAG_U 0x00000010 +#define PUB_SDP_FLAG_E 0x00000020 +#define PUB_SDP_FLAG_P 0x00000040 +#define PUB_SDP_FLAG_C 0x00000080 +#define PUB_SDP_FLAG_B 0x00000100 +#define PUB_SDP_FLAG_Z 0x00000200 +#define PUB_SDP_FLAG_K 0x00000400 +#define PUB_SDP_FLAG_A 0x00000800 +#define PUB_SDP_FLAG_T 0x00001000 +#define PUB_SDP_FLAG_R 0x00002000 +#define PUB_SDP_FLAG_M 0x00004000 + +#define PUB_MGCP_PARA_FLAG_TFO 0x00000800 + +#define PUB_SDP_STR_TO_API 1 +#define PUB_SDP_API_TO_STR 2 + +#define PUB_SDP_NET_TYPE_IN 1 + +#define PUB_SDP_ADDR_TYPE_IPV4 1 +#define PUB_SDP_ADDR_TYPE_IPV6 2 + +#define PUB_SDP_ATTR_TYPE_RTPMAP 1 +#define PUB_SDP_ATTR_TYPE_PTIME 2 +#define PUB_SDP_ATTR_TYPE_FMTP 3 +#define PUB_SDP_ATTR_TYPE_RECVONLY 4 +#define PUB_SDP_ATTR_TYPE_SENDONLY 5 +#define PUB_SDP_ATTR_TYPE_SENDRECV 6 + +#define PUB_SDP_MEDIA_TYPE_AUDIO 1 +#define PUB_SDP_MEDIA_TYPE_VIDEO 2 + +#define PUB_SDP_PROTO_TYPE_RTP_AVP 1 + +typedef struct _PUB_SDP_V +{ + BYTE value; +}PUB_SDP_V; + +typedef struct _PUB_SDP_O +{ + char userName[PUB_SDP_MAX_USER_NAME_LEN]; + char sessId[PUB_SDP_MAX_SESS_ID_LEN]; + char sessVer[PUB_SDP_MAX_SESS_VER_LEN]; + BYTE netType; + BYTE addrType; + char addr[PUB_SDP_MAX_ADDR_LEN]; +}PUB_SDP_O; + +typedef struct _PUB_SDP_S +{ + char sessName[PUB_SDP_MAX_SESS_NAME_LEN]; +}PUB_SDP_S; + +typedef struct _PUB_SDP_I +{ + char info[PUB_SDP_MAX_SESS_INFO_LEN]; +}PUB_SDP_I; + +typedef struct _PUB_SDP_U +{ +}PUB_SDP_U; + +typedef struct _PUB_SDP_E +{ +}PUB_SDP_E; + +typedef struct _PUB_SDP_P +{ +}PUB_SDP_P; + +typedef struct _PUB_SDP_C +{ + BYTE netType; + BYTE addrType; + char addr[PUB_SDP_MAX_ADDR_LEN]; +}PUB_SDP_C; + +typedef struct _PUB_SDP_B +{ +}PUB_SDP_B; + +typedef struct _PUB_SDP_Z +{ +}PUB_SDP_Z; + +typedef struct _PUB_SDP_K +{ +}PUB_SDP_K; + +typedef struct _PUB_SDP_T +{ + DWORD startTime; + DWORD stopTime; +}PUB_SDP_T; + +typedef struct _PUB_SDP_R +{ +}PUB_SDP_R; + +typedef struct _PUB_SDP_M +{ + BYTE media; + WORD port; + BYTE portNum; + BYTE proto; + BYTE plNum; + BYTE payloads[PUB_SDP_MAX_PAYLOAD_NUM]; +}PUB_SDP_M; + +typedef struct _PUB_SDP_A +{ + BYTE aType; + char aValue[PUB_SDP_MAX_ATTR_LEN]; +}PUB_SDP_A; + +typedef struct _PUB_SDP_ATTRS +{ + BYTE num; + PUB_SDP_A attrs[PUB_SDP_MAX_ATTR_NUM]; +}PUB_SDP_ATTRS; + +typedef struct _PUB_SDP_MEDIA +{ + DWORD flag; + + PUB_SDP_M m; + PUB_SDP_I i; + PUB_SDP_C c; + PUB_SDP_B b; + PUB_SDP_K k; + PUB_SDP_ATTRS attrs; +}PUB_SDP_MEDIA; + +typedef struct _PUB_SDP_MEDIAS +{ + BYTE num; + PUB_SDP_MEDIA medias[PUB_SDP_MAX_MEDIA_NUM]; +}PUB_SDP_MEDIAS; + +typedef struct _PUB_SDP_MSG +{ + DWORD flag; + + PUB_SDP_V v; + PUB_SDP_O o; + PUB_SDP_S s; + PUB_SDP_I i; + PUB_SDP_U u; + PUB_SDP_E e; + PUB_SDP_P p; + PUB_SDP_C c; + PUB_SDP_B b; + PUB_SDP_Z z; + PUB_SDP_K k; + PUB_SDP_A a; + + PUB_SDP_T t; + PUB_SDP_R r; + + PUB_SDP_MEDIAS medias; +}PUB_SDP_MSG; + +void pub_replace_all_lws(char *msg); +char *pub_strncpy(char *dest, const char *src, WORD length); +int pub_set_next_token(char *dest, char *buf, int endSeparator, char **next); + +int pub_sdp_msg_init(PUB_SDP_MSG *sdp); +int pub_sdp_parse(PUB_SDP_MSG *sdp, char *buf, char **nextMsg, DWORD flag); +int pub_sdp_encode(PUB_SDP_MSG *sdp, char *dest, WORD flag); + +int pub_sdp_net_type_conv(char *str, BYTE *netType, BYTE flag); +int pub_sdp_addr_type_conv(char *str, BYTE *addrType, BYTE flag); +int pub_sdp_attr_type_conv(char *str, BYTE *attrType, BYTE flag); +int pub_sdp_media_type_conv(char *str, BYTE *mediaType, BYTE flag); +int pub_sdp_proto_type_conv(char *str, BYTE *protoType, BYTE flag); + +#endif diff --git a/omc/plat/public_bak/src/include/pub_str.h b/omc/plat/public_bak/src/include/pub_str.h new file mode 100644 index 0000000..f6db853 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_str.h @@ -0,0 +1,26 @@ +////////////////////////////////////////////////// +//Title : pub_str.h +//Auhtor : Liu Wei +//Desc : wxc2 string library +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_STR_H_ +#define _PUB_STR_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" + +#endif + + + + + + + diff --git a/omc/plat/public_bak/src/include/pub_sys.h b/omc/plat/public_bak/src/include/pub_sys.h new file mode 100644 index 0000000..aaeb2a3 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_sys.h @@ -0,0 +1,53 @@ +////////////////////////////////////////////////// +//Title : pub_sys.c +//Auhtor : Liu Wei +//Desc : Public Linux system infomation +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_SYS_H_ +#define _PUB_SYS_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_time.h" +#include +#include +#include +#include +#include +#include +#include +//#include + +#define SIM_NONL 0x1000 // Don't add newline to output +#define SIM_NOLBL 0x2000 // Don't print "Public: Error:" + + +#define MHERTZ 1000000 // MegaHertz +#define BYTES ((u32)1) // Bytes +#define KBYTES ((u32)1024) // Kilo bytes +#define MBYTES ((u32)(1024*1024)) // Mega bytes +#define GBYTES ((u32)(1024*1024*1024)) // Giga bytes + +#define BytesToGBytes(N) ( (float) N / (float) GBYTES ) +#define BytesToMBytes(N) ( (float) N / (float) MBYTES ) +#define BytesToKBytes(N) ( (float) (N / (float) KBYTES) ) +#define MBytesToBytes(N) ( (float) ( (float) N * (float) MBYTES ) ) +#define KBytesToMbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) +#define KBytesToGbytes(N) ( (float) ( (float) N / (float) MBYTES ) ) +#define MbytesToGbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) + +#define EQ(a,b) (a && b && strcasecmp(a,b)==0) +#define EQN(a,b,n) (a && b && strncasecmp(a,b,n)==0) +#define eq(a,b) (a && b && strcmp(a,b)==0) +#define eqn(a,b,n) (a && b && strncmp(a,b,n)==0) +#define ARG(s) ((s) ? s : "") +#define PRTS(s) ( ( s && *s ) ? s : "" ) + +#endif diff --git a/omc/plat/public_bak/src/include/pub_time.h b/omc/plat/public_bak/src/include/pub_time.h new file mode 100644 index 0000000..5a144b4 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_time.h @@ -0,0 +1,29 @@ +////////////////////////////////////////////////// +//Title : pub_time.h +//Auhtor : Liu Wei +//Desc : Linux time function +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +///////////////////////////////////////////////// + +#ifndef _PUB_TIME_H_ +#define _PUB_TIME_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_log.h" +#include + +/* pub_time.c */ +long GetTickCount(void); +int GetCurrentTime(u8 *pNowTime); +char *GetAsciiTime(void); +char *TimeToStr(time_t TimeVal, char *Format); +char *GetTimeHMS(char *pTimeBuf); + + +#endif diff --git a/omc/plat/public_bak/src/include/pub_timer.h b/omc/plat/public_bak/src/include/pub_timer.h new file mode 100644 index 0000000..8d7ec66 --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_timer.h @@ -0,0 +1,96 @@ +////////////////////////////////////////////////// +//Title : wxc_timer.h +//Auhtor : Liu Wei +//Desc : WXC2 Public Timer Managemnet +//Created : 2007-04-27 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _PUB_TIMER_H_ +#define _PUB_TIMER_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_malloc.h" + +/////////////////////////////////////////////////////////////////////////// + +typedef void ( *TimerCallBack ) ( u16 dSuitId, u16 dData ); + +#define TM_CLOCK_MAX (24*60*60*100) //one day based on wxc2 base timer 10ms + +typedef struct WXC_TIMER +{ + u32 dExpires; //dExpires : Timer expired number + u32 dSuitNumber; //dSuitNumber : Timer suit size of member + TimerCallBack pFunc; //pFunc : Timer call back function + u16 dData; //dData : Pointer for parameter of callback + void *pTimerNode; //pTimerNode : Reserved for timer Managemnet +} +WxcTimer; + +/////////////////////////////////////////////////////////////////////////// + +typedef struct WXC_TIMER_NODE +{ + u32 *dClockArray; //dClockArray : Timer set member clock array + WxcTimer *pTimer; + struct WXC_TIMER_NODE *pNext; + struct WXC_TIMER_NODE *pPrev; +} +WxcTimerNode; + +/////////////////////////////////////////////////////////////////////////// + +#define MAX_TM_MODE 512 + +#define TIMER_NODE_SIZE ( sizeof( WxcTimerNode ) + sizeof( WxcTimer ) ) + +#define CLOCK_SZIE ( sizeof ( u32 ) ) + +#define TMHEAP_MM_SIZE ( MAX_TM_MODE * TIMER_NODE_SIZE ) + +#define GET_TNODE_SIZE(n) ( TIMER_NODE_SIZE + ( n ) *( CLOCK_SZIE )) + +/////////////////////////////////////////////////////////////////////////// + +u8 TMHeap[TMHEAP_MM_SIZE]; + +WxcTimerNode tTimerListHead; +WxcTimerNode *pTLHead; +WxcTimerNode *pTLCur; + +/////////////////////////////////////////////////////////////////////////// + +#ifndef _LINUX_TIMER_H +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) + +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) +#endif + +/////////////////////////////////////////////////////////////////////////// + +#define TimerAfter(a,b) time_after(a,b) +#define TimerBefore(a,b) time_before(a,b) +#define TimerAfterEq(a,b) time_after_eq(a,b) +#define TimerBeforeEq(a,b) time_before_eq(a,b) + + +extern void TimerAdd ( WxcTimer * pTimer ); +extern void TimerMod ( WxcTimer * pTimer, u16 dExpires ); +extern void TimerDel ( WxcTimer * pTimer ); + + +inline void TimerStart ( WxcTimer * pTimer, u16 dSuitId ); +inline void TimerStop ( WxcTimer * pTimer, u16 dSuitId ); +inline void TM_Init ( ); + + + +#endif diff --git a/omc/plat/public_bak/src/include/pub_wnet.h b/omc/plat/public_bak/src/include/pub_wnet.h new file mode 100644 index 0000000..61dccce --- /dev/null +++ b/omc/plat/public_bak/src/include/pub_wnet.h @@ -0,0 +1,41 @@ +////////////////////////////////////////////////// +//Title : pub_wnet.h +//Auhtor : Liu Wei +//Desc : wireless network publice function +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _WXC_WNET_H_ +#define _WXC_WNET_H_ + +#include "public.h" +#include "includes.h" +#include "pub_base.h" +#include "pub_fmt.h" + +#define ISDN_LEN 9 +#define IMSI_LEN 8 + +/* ./src/pub_wnet.c */ +u8 GetBcdStr(char *str, u8 *bcd, u8 bcd_len); +void ImsiNtoA(u8 *pAntiImsi, u8 *pNormalImsi); +void ImsiAToN(u8 *pNormalImsi, u8 *pAntiImsi); +void ImsiNToS(u8 *pImsiStr, u8 *pNormalImsi); +void ImsiSToN(u8 *pNormalImsi, u8 *pImsiStr); +void IsdnNToA(u8 *pAntiIsdn, u8 *pNormalIsdn); +void IsdnAToN(u8 *pNormalIsdn, u8 *pAntiIsdn); +void IsdnNToS(u8 *pIsdnStr, u8 *pNormalIsdn); +u8 IsdnSToN(u8 *pNormalIsdn, u8 *pIsdnStr); +void GttToIsdn(u8 *pIsdn, u8 *pGtt); +u8 IsdnToGtai(u8 *pGtai, u8 *pIsdn); +void GtaiToIsdn(u8 *pIsdn, u8 *pGtai, u8 len); +u8 BcdToStrPE(char *str, u8 *bcd, u8 bcd_len); +void AddCcToIsdn(u8 *isdn_str, u8 *cc); +void AddNdcToIsdn(u8 *isdn_str, u8 *ndc); + +#endif diff --git a/omc/plat/public_bak/src/include/public.h b/omc/plat/public_bak/src/include/public.h new file mode 100644 index 0000000..8e933a3 --- /dev/null +++ b/omc/plat/public_bak/src/include/public.h @@ -0,0 +1,102 @@ +/* +** PACS WLL 2000 project, Prepaid System. +** +** File name: public.h +** Written completely by Zhang Shuzhong at 2000-10-17 +** CVS $Id: public.h,v 1.4 2001/01/20 19:58:49 zhangsz Exp $ +** +** Public type definitions for PACS-WLL Project. +** +*/ + +#ifndef PUBLIC__H +#define PUBLIC__H + +#include +#include "memwatch.h" + +#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 + +#ifndef _T_ULL +#define _T_ULL +typedef unsigned long long ull; +#endif + +#ifndef _T_U8 +#define _T_U8 +typedef unsigned char u8; +#endif + +#ifndef _T_U16 +#define _T_U16 +typedef unsigned short u16; +#endif + +#ifndef _T_U32 +#define _T_U32 +typedef unsigned int u32; +#endif + +#ifndef _T_U64 +#define _T_U64 +typedef unsigned long long u64; +#endif + +#ifndef _T_BOOL +#define _T_BOOL +typedef int BOOL; +#endif + +#ifndef SUCCESS +#define SUCCESS (0) +#endif + +#ifndef FAILURE +#define FAILURE (-1) +#endif + +#ifndef TRUE +#define TRUE (1) +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef YES +#define YES (1) +#endif + +#ifndef NO +#define NO (0) +#endif + +#ifndef ERROR +#define ERROR (-1) +#endif + +#ifndef EMPTY +#define EMPTY (0) +#endif + +#define BUFSIZE 8192 +#define MAXBUFLEN 8192 +#define MAXLINE 8192 + +//#define MAX(a, b) ((a) > (b) ? (a) : (b)) +//#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#endif /* PUBLIC__H */ diff --git a/omc/plat/public_bak/src/include/svrstat.h b/omc/plat/public_bak/src/include/svrstat.h new file mode 100644 index 0000000..f91f468 --- /dev/null +++ b/omc/plat/public_bak/src/include/svrstat.h @@ -0,0 +1,100 @@ +/* +** PACS-WLL 2000 project, WAVEloop System. +** +** The module Copyright (C) 2000-2001 interWAVE Inc. +** Written completely by Zhang Shuzhong at iCRD Sep, 2001 +** +** file name: svrstat.h +** CVS $Id: $ +** +** The header file is defination about shared memory +** of server state information. +** +*/ + + +#ifndef SVRSTAT__H +#define SVRSTAT__H + +#define SVRSTAT_SHM_KEY 0x00010000 +#define SVRSTAT_SHM_PERM 0666 +#define SVRSTAT_SEM_KEY 0x00010000 +#define SVRSTAT_SEM_PERM 0666 +#define SVRSTAT_SEM_NUM 1 + +enum _server_state_enum { + SS_IDLE, + SS_INITIATE, + SS_NORMAL, + SS_SERVICE_SUSPEND, + SS_SERVICE_HALT, + SS_SHM_REINITIATE, + SS_SERVICE_RESTART, + SS_SYSTEM_RESTART, + SS_SYSTEM_HALT, +}; + +enum _oper_state_enum { + OS_NO_COMMAND, + OS_SET_COMMAND, + OS_GOT_COMMAND, + OS_FINISHED_COMMAND, + OS_REFUSED_COMMAND, +}; + +typedef struct { + u_char component_type; + u_char component_id; + u_char alarm_level; + u_char alarm_code; + DWORD timestamp; +} _alarm_log; + +typedef struct { + u_short read_sub; + u_short write_sub; + _alarm_log alarm_log[16]; +} _alarm_buffer; + +typedef struct { + u_char version[3]; + DWORD distrib_date; + u_char current_state; // Please view server's state enum. + // The server's current state. + u_char received_state; // State received from OMC. + // Please view server's state enum + // for detail. + u_char oper_state; /* 0: No command. + ** 1: Agent set command. + ** 2: Function server got the command. + ** 3: Function server finished. + ** 4: Function server refused. + ** refer to enum of _oper_state_enum + */ + u_char net_status; // 0/1=normal/abnormal, + // status of network + u_char rate_progress; // Rate of progress. + DWORD time_updated; + _alarm_buffer alarm_buffer; // Alarm code +} _server_state; + +typedef struct { + DWORD time_created; // Heartbeating module set the field + DWORD server_list; /* Bit0-15: + ** Server exist if set '1' in bit + ** Bit16-31: + ** 0/1 = Primary/Secondary server. + ** that base server object id. + */ + u_char led_state[16]; /* Led's state: + ** 0: Idle/Disable/Suspend/Halt + ** 1: Enable/Normal + ** 2: Initiating/Activated + */ + u_char port_stat[3]; + _server_state server_state[16]; /* Subscript of array + ** base on server object ID + */ +} _ss_buffer; + +#endif diff --git a/omc/plat/public_bak/src/memwatch.c b/omc/plat/public_bak/src/memwatch.c new file mode 100644 index 0000000..1716ca7 --- /dev/null +++ b/omc/plat/public_bak/src/memwatch.c @@ -0,0 +1,2669 @@ +/* +** MEMWATCH.C +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2003 Johan Lindh +** All rights reserved. +** Version 2.71 + + This file is part of MEMWATCH. + + MEMWATCH 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 of the License, or + (at your option) any later version. + + MEMWATCH 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 MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +*/ + +/*@ignore@*/ + +#define __MEMWATCH_C 1 + +#ifdef MW_NOCPP +#define MEMWATCH_NOCPP +#endif +#ifdef MW_STDIO +#define MEMWATCH_STDIO +#endif + +/*********************************************************************** +** Include files +***********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "./include/memwatch.h" + +#ifndef toupper +#include +#endif + +#if defined(WIN32) || defined(__WIN32__) +#define MW_HAVE_MUTEX 1 +#include +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +#define MW_HAVE_MUTEX 1 +#include +#endif + +/*********************************************************************** +** Defines & other weird stuff +***********************************************************************/ + +/*lint -save -e767 */ +#define VERSION "2.71" /* the current version number */ +#define CHKVAL(mw) (0xFE0180L^(long)mw->count^(long)mw->size^(long)mw->line) +#define FLUSH() mwFlush() +#define TESTS(f,l) if(mwTestAlways) (void)mwTestNow(f,l,1) +#define PRECHK 0x01234567L +#define POSTCHK 0x76543210L +#define mwBUFFER_TO_MW(p) ( (mwData*) (void*) ( ((char*)p)-mwDataSize-mwOverflowZoneSize ) ) +/*lint -restore */ + +#define MW_NML 0x0001 + +#ifdef _MSC_VER +#define COMMIT "c" /* Microsoft C requires the 'c' to perform as desired */ +#else +#define COMMIT "" /* Normal ANSI */ +#endif /* _MSC_VER */ + +#ifdef __cplusplus +#define CPPTEXT "++" +#else +#define CPPTEXT "" +#endif /* __cplusplus */ + +#ifdef MEMWATCH_STDIO +#define mwSTDERR stderr +#else +#define mwSTDERR mwLog +#endif + +#ifdef MW_HAVE_MUTEX +#define MW_MUTEX_INIT() mwMutexInit() +#define MW_MUTEX_TERM() mwMutexTerm() +#define MW_MUTEX_LOCK() mwMutexLock() +#define MW_MUTEX_UNLOCK() mwMutexUnlock() +#else +#define MW_MUTEX_INIT() +#define MW_MUTEX_TERM() +#define MW_MUTEX_LOCK() +#define MW_MUTEX_UNLOCK() +#endif + +/*********************************************************************** +** If you really, really know what you're doing, +** you can predefine these things yourself. +***********************************************************************/ + +#ifndef mwBYTE_DEFINED +# if CHAR_BIT != 8 +# error need CHAR_BIT to be 8! +# else +typedef unsigned char mwBYTE; +# define mwBYTE_DEFINED 1 +# endif +#endif + +#if defined(ULONGLONG_MAX) || defined(ULLONG_MAX) || defined(_UI64_MAX) || defined(ULONG_LONG_MAX) +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +#else +# if UINT_MAX <= 0xFFFFUL +# define mw16BIT 1 +# define mwROUNDALLOC_DEFAULT 2 +# else +# if ULONG_MAX > 0xFFFFFFFFUL +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +# else +# define mw32BIT 1 +# define mwROUNDALLOC_DEFAULT 4 +# endif +# endif +#endif + +/* mwROUNDALLOC is the number of bytes to */ +/* round up to, to ensure that the end of */ +/* the buffer is suitable for storage of */ +/* any kind of object */ +#ifndef mwROUNDALLOC +# define mwROUNDALLOC mwROUNDALLOC_DEFAULT +#endif + +#ifndef mwDWORD_DEFINED +#if ULONG_MAX == 0xFFFFFFFFUL +typedef unsigned long mwDWORD; +#define mwDWORD_DEFINED "unsigned long" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if UINT_MAX == 0xFFFFFFFFUL +typedef unsigned int mwDWORD; +#define mwDWORD_DEFINED "unsigned int" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if USHRT_MAX == 0xFFFFFFFFUL +typedef unsigned short mwDWORD; +#define mwDWORD_DEFINED "unsigned short" +#endif +#endif + +#ifndef mwBYTE_DEFINED +#error "can't find out the correct type for a 8 bit scalar" +#endif + +#ifndef mwDWORD_DEFINED +#error "can't find out the correct type for a 32 bit scalar" +#endif + +/*********************************************************************** +** Typedefs & structures +***********************************************************************/ + +/* main data holding area, precedes actual allocation */ +typedef struct mwData_ mwData; +struct mwData_ { + mwData* prev; /* previous allocation in chain */ + mwData* next; /* next allocation in chain */ + const char* file; /* file name where allocated */ + long count; /* action count */ + long check; /* integrity check value */ +#if 0 + long crc; /* data crc value */ +#endif + size_t size; /* size of allocation */ + int line; /* line number where allocated */ + unsigned flag; /* flag word */ + }; + +/* statistics structure */ +typedef struct mwStat_ mwStat; +struct mwStat_ { + mwStat* next; /* next statistic buffer */ + const char* file; + long total; /* total bytes allocated */ + long num; /* total number of allocations */ + long max; /* max allocated at one time */ + long curr; /* current allocations */ + int line; + }; + +/* grabbing structure, 1K in size */ +typedef struct mwGrabData_ mwGrabData; +struct mwGrabData_ { + mwGrabData* next; + int type; + char blob[ 1024 - sizeof(mwGrabData*) - sizeof(int) ]; + }; + +typedef struct mwMarker_ mwMarker; +struct mwMarker_ { + void *host; + char *text; + mwMarker *next; + int level; + }; + +#if defined(WIN32) || defined(__WIN32__) +typedef HANDLE mwMutex; +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +typedef pthread_mutex_t mwMutex; +#endif + +/*********************************************************************** +** Static variables +***********************************************************************/ + +static int mwInited = 0; +static int mwInfoWritten = 0; +static int mwUseAtexit = 0; +static FILE* mwLog = NULL; +static int mwFlushing = 0; +static int mwStatLevel = MW_STAT_DEFAULT; +static int mwNML = MW_NML_DEFAULT; +static int mwFBI = 0; +static long mwAllocLimit = 0L; +static int mwUseLimit = 0; + +static long mwNumCurAlloc = 0L; +static mwData* mwHead = NULL; +static mwData* mwTail = NULL; +static int mwDataSize = 0; +static unsigned char mwOverflowZoneTemplate[] = "mEmwAtch"; +static int mwOverflowZoneSize = mwROUNDALLOC; + +static void (*mwOutFunction)(int) = NULL; +static int (*mwAriFunction)(const char*) = NULL; +static int mwAriAction = MW_ARI_ABORT; + +static char mwPrintBuf[MW_TRACE_BUFFER+8]; + +static unsigned long mwCounter = 0L; +static long mwErrors = 0L; + +static int mwTestFlags = 0; +static int mwTestAlways = 0; + +static FILE* mwLogB1 = NULL; +static int mwFlushingB1 = 0; + +static mwStat* mwStatList = NULL; +static long mwStatTotAlloc = 0L; +static long mwStatMaxAlloc = 0L; +static long mwStatNumAlloc = 0L; +static long mwStatCurAlloc = 0L; +static long mwNmlNumAlloc = 0L; +static long mwNmlCurAlloc = 0L; + +static mwGrabData* mwGrabList = NULL; +static long mwGrabSize = 0L; + +static void * mwLastFree[MW_FREE_LIST]; +static const char *mwLFfile[MW_FREE_LIST]; +static int mwLFline[MW_FREE_LIST]; +static int mwLFcur = 0; + +static mwMarker* mwFirstMark = NULL; + +static FILE* mwLogB2 = NULL; +static int mwFlushingB2 = 0; + +#ifdef MW_HAVE_MUTEX +static mwMutex mwGlobalMutex; +#endif + +/*********************************************************************** +** Static function declarations +***********************************************************************/ + +static void mwAutoInit( void ); +static FILE* mwLogR( void ); +static void mwLogW( FILE* ); +static int mwFlushR( void ); +static void mwFlushW( int ); +static void mwFlush( void ); +static void mwIncErr( void ); +static void mwUnlink( mwData*, const char* file, int line ); +static int mwRelink( mwData*, const char* file, int line ); +static int mwIsHeapOK( mwData *mw ); +static int mwIsOwned( mwData* mw, const char* file, int line ); +static int mwTestBuf( mwData* mw, const char* file, int line ); +static void mwDefaultOutFunc( int ); +static void mwWrite( const char* format, ... ); +static void mwLogFile( const char* name ); +static size_t mwFreeUp( size_t, int ); +static const void *mwTestMem( const void *, unsigned, int ); +static int mwStrCmpI( const char *s1, const char *s2 ); +static int mwTestNow( const char *file, int line, int always_invoked ); +static void mwDropAll( void ); +static const char *mwGrabType( int type ); +static unsigned mwGrab_( unsigned kb, int type, int silent ); +static unsigned mwDrop_( unsigned kb, int type, int silent ); +static int mwARI( const char* text ); +static void mwStatReport( void ); +static mwStat* mwStatGet( const char*, int, int ); +static void mwStatAlloc( size_t, const char*, int ); +static void mwStatFree( size_t, const char*, int ); +static int mwCheckOF( const void * p ); +static void mwWriteOF( void * p ); +static char mwDummy( char c ); +#ifdef MW_HAVE_MUTEX +static void mwMutexInit( void ); +static void mwMutexTerm( void ); +static void mwMutexLock( void ); +static void mwMutexUnlock( void ); +#endif + +/*********************************************************************** +** System functions +***********************************************************************/ + +void mwInit( void ) { + time_t tid; + + if( mwInited++ > 0 ) return; + + MW_MUTEX_INIT(); + + /* start a log if none is running */ + if( mwLogR() == NULL ) mwLogFile( "memwatch.log" ); + if( mwLogR() == NULL ) { + int i; + char buf[32]; + /* oops, could not open it! */ + /* probably because it's already open */ + /* so we try some other names */ + for( i=1; i<100; i++ ) { + sprintf( buf, "memwat%02d.log", i ); + mwLogFile( buf ); + if( mwLogR() != NULL ) break; + } + } + + /* initialize the statistics */ + mwStatList = NULL; + mwStatTotAlloc = 0L; + mwStatCurAlloc = 0L; + mwStatMaxAlloc = 0L; + mwStatNumAlloc = 0L; + mwNmlCurAlloc = 0L; + mwNmlNumAlloc = 0L; + + /* calculate the buffer size to use for a mwData */ + mwDataSize = sizeof(mwData); + while( mwDataSize % mwROUNDALLOC ) mwDataSize ++; + + /* write informational header if needed */ + if( !mwInfoWritten ) { + mwInfoWritten = 1; + (void) time( &tid ); + mwWrite( + "\n=============" + " MEMWATCH " VERSION " Copyright (C) 1992-1999 Johan Lindh " + "=============\n"); + mwWrite( "\nStarted at %s\n", ctime( &tid ) ); + +/**************************************************************** Generic */ + mwWrite( "Modes: " ); +#ifdef mwNew + mwWrite( "C++ " ); +#endif /* mwNew */ +#ifdef __STDC__ + mwWrite( "__STDC__ " ); +#endif /* __STDC__ */ +#ifdef mw16BIT + mwWrite( "16-bit " ); +#endif +#ifdef mw32BIT + mwWrite( "32-bit " ); +#endif +#ifdef mw64BIT + mwWrite( "64-bit " ); +#endif + mwWrite( "mwDWORD==(\" mwDWORD_DEFINED \")\n" ); + mwWrite( "mwROUNDALLOC==%d sizeof(mwData)==%d mwDataSize==%d\n", + mwROUNDALLOC, sizeof(mwData), mwDataSize ); +/**************************************************************** Generic */ + +/************************************************************ Microsoft C */ +#ifdef _MSC_VER + mwWrite( "Compiled using Microsoft C" CPPTEXT + " %d.%02d\n", _MSC_VER / 100, _MSC_VER % 100 ); +#endif /* _MSC_VER */ +/************************************************************ Microsoft C */ + +/************************************************************** Borland C */ +#ifdef __BORLANDC__ + mwWrite( "Compiled using Borland C" +#ifdef __cplusplus + "++ %d.%01d\n", __BCPLUSPLUS__/0x100, (__BCPLUSPLUS__%0x100)/0x10 ); +#else + " %d.%01d\n", __BORLANDC__/0x100, (__BORLANDC__%0x100)/0x10 ); +#endif /* __cplusplus */ +#endif /* __BORLANDC__ */ +/************************************************************** Borland C */ + +/************************************************************** Watcom C */ +#ifdef __WATCOMC__ + mwWrite( "Compiled using Watcom C %d.%02d ", + __WATCOMC__/100, __WATCOMC__%100 ); +#ifdef __FLAT__ + mwWrite( "(32-bit flat model)" ); +#endif /* __FLAT__ */ + mwWrite( "\n" ); +#endif /* __WATCOMC__ */ +/************************************************************** Watcom C */ + + mwWrite( "\n" ); + FLUSH(); + } + + if( mwUseAtexit ) (void) atexit( mwAbort ); + return; + } + +void mwAbort( void ) { + mwData *mw; + mwMarker *mrk; + char *data; + time_t tid; + int c, i, j; + int errors; + + tid = time( NULL ); + mwWrite( "\nStopped at %s\n", ctime( &tid) ); + + if( !mwInited ) + mwWrite( "internal: mwAbort(): MEMWATCH not initialized!\n" ); + + /* release the grab list */ + mwDropAll(); + + /* report mwMarked items */ + while( mwFirstMark ) { + mrk = mwFirstMark->next; + mwWrite( "mark: %p: %s\n", mwFirstMark->host, mwFirstMark->text ); + free( mwFirstMark->text ); + free( mwFirstMark ); + mwFirstMark = mrk; + mwErrors ++; + } + + /* release all still allocated memory */ + errors = 0; + while( mwHead != NULL && errors < 3 ) { + if( !mwIsOwned(mwHead, __FILE__, __LINE__ ) ) { + if( errors < 3 ) + { + errors ++; + mwWrite( "internal: NML/unfreed scan restarting\n" ); + FLUSH(); + mwHead = mwHead; + continue; + } + mwWrite( "internal: NML/unfreed scan aborted, heap too damaged\n" ); + FLUSH(); + break; + } + mwFlushW(0); + if( !(mwHead->flag & MW_NML) ) { + mwErrors++; + data = ((char*)mwHead)+mwDataSize; + mwWrite( "unfreed: <%ld> %s(%d), %ld bytes at %p ", + mwHead->count, mwHead->file, mwHead->line, (long)mwHead->size, data+mwOverflowZoneSize ); + if( mwCheckOF( data ) ) { + mwWrite( "[underflowed] "); + FLUSH(); + } + if( mwCheckOF( (data+mwOverflowZoneSize+mwHead->size) ) ) { + mwWrite( "[overflowed] "); + FLUSH(); + } + mwWrite( " \t{" ); + j = 16; if( mwHead->size < 16 ) j = (int) mwHead->size; + for( i=0;i<16;i++ ) { + if( i 126 ) c = '.'; + mwWrite( "%c", c ); + } + mwWrite( "}\n" ); + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + else { + data = ((char*)mwHead) + mwDataSize + mwOverflowZoneSize; + if( mwTestMem( data, mwHead->size, MW_VAL_NML ) ) { + mwErrors++; + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mwHead->count, data + mwOverflowZoneSize, mwHead->file, mwHead->line ); + FLUSH(); + } + mwNmlNumAlloc --; + mwNmlCurAlloc -= mwHead->size; + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + } + + if( mwNmlNumAlloc ) mwWrite("internal: NoMansLand block counter %ld, not zero\n", mwNmlNumAlloc ); + if( mwNmlCurAlloc ) mwWrite("internal: NoMansLand byte counter %ld, not zero\n", mwNmlCurAlloc ); + + /* report statistics */ + mwStatReport(); + FLUSH(); + + mwInited = 0; + mwHead = mwTail = NULL; + if( mwErrors ) + fprintf(mwSTDERR,"MEMWATCH detected %ld anomalies\n",mwErrors); + mwLogFile( NULL ); + mwErrors = 0; + + MW_MUTEX_TERM(); + + } + +void mwTerm( void ) { + if( mwInited == 1 ) + { + mwAbort(); + return; + } + if( !mwInited ) + mwWrite("internal: mwTerm(): MEMWATCH has not been started!\n"); + else + mwInited --; + } + +void mwStatistics( int level ) +{ + mwAutoInit(); + if( level<0 ) level=0; + if( mwStatLevel != level ) + { + mwWrite( "statistics: now collecting on a %s basis\n", + level<1?"global":(level<2?"module":"line") ); + mwStatLevel = level; + } +} + +void mwAutoCheck( int onoff ) { + mwAutoInit(); + mwTestAlways = onoff; + if( onoff ) mwTestFlags = MW_TEST_ALL; + } + +void mwSetOutFunc( void (*func)(int) ) { + mwAutoInit(); + mwOutFunction = func; + } + +static void mwWriteOF( void *p ) +{ + int i; + unsigned char *ptr; + ptr = (unsigned char*) p; + for( i=0; inext is not always set? +*/ +void * mwMark( void *p, const char *desc, const char *file, unsigned line ) { + mwMarker *mrk; + unsigned n, isnew; + char *buf; + int tot, oflow = 0; + char wherebuf[128]; + + mwAutoInit(); + TESTS(NULL,0); + + if( desc == NULL ) desc = "unknown"; + if( file == NULL ) file = "unknown"; + + tot = sprintf( wherebuf, "%.48s called from %s(%d)", desc, file, line ); + if( tot >= (int)sizeof(wherebuf) ) { wherebuf[sizeof(wherebuf)-1] = 0; oflow = 1; } + + if( p == NULL ) { + mwWrite("mark: %s(%d), no mark for NULL:'%s' may be set\n", file, line, desc ); + return p; + } + + if( mwFirstMark != NULL && !mwIsReadAddr( mwFirstMark, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mwFirstMark (%p) is trashed, can't mark for %s\n", + file, line, mwFirstMark, desc ); + return p; + } + + for( mrk=mwFirstMark; mrk; mrk=mrk->next ) + { + if( mrk->next != NULL && !mwIsReadAddr( mrk->next, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mark(%p)->next(%p) is trashed, can't mark for %s\n", + file, line, mrk, mrk->next, desc ); + return p; + } + if( mrk->host == p ) break; + } + + if( mrk == NULL ) { + isnew = 1; + mrk = (mwMarker*) malloc( sizeof( mwMarker ) ); + if( mrk == NULL ) { + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + mrk->next = NULL; + n = 0; + } + else { + isnew = 0; + n = strlen( mrk->text ); + } + + n += strlen( wherebuf ); + buf = (char*) malloc( n+3 ); + if( buf == NULL ) { + if( isnew ) free( mrk ); + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + + if( isnew ) { + memcpy( buf, wherebuf, n+1 ); + mrk->next = mwFirstMark; + mrk->host = p; + mrk->text = buf; + mrk->level = 1; + mwFirstMark = mrk; + } + else { + strcpy( buf, mrk->text ); + strcat( buf, ", " ); + strcat( buf, wherebuf ); + free( mrk->text ); + mrk->text = buf; + mrk->level ++; + } + + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + return p; + } + +void* mwUnmark( void *p, const char *file, unsigned line ) { + mwMarker *mrk, *prv; + mrk = mwFirstMark; + prv = NULL; + while( mrk ) { + if( mrk->host == p ) { + if( mrk->level < 2 ) { + if( prv ) prv->next = mrk->next; + else mwFirstMark = mrk->next; + free( mrk->text ); + free( mrk ); + return p; + } + mrk->level --; + return p; + } + prv = mrk; + mrk = mrk->next; + } + mwWrite("mark: %s(%d), no mark found for %p\n", file, line, p ); + return p; + } + + +/*********************************************************************** +** Abort/Retry/Ignore handlers +***********************************************************************/ + +static int mwARI( const char *estr ) { + char inbuf[81]; + int c; + fprintf(mwSTDERR, "\n%s\nMEMWATCH: Abort, Retry or Ignore? ", estr); + (void) fgets(inbuf,sizeof(inbuf),stdin); + for( c=0; inbuf[c] && inbuf[c] <= ' '; c++ ) ; + c = inbuf[c]; + if( c == 'R' || c == 'r' ) { + mwBreakOut( estr ); + return MW_ARI_RETRY; + } + if( c == 'I' || c == 'i' ) return MW_ARI_IGNORE; + return MW_ARI_ABORT; + } + +/* standard ARI handler (exported) */ +int mwAriHandler( const char *estr ) { + mwAutoInit(); + return mwARI( estr ); + } + +/* used to set the ARI function */ +void mwSetAriFunc( int (*func)(const char *) ) { + mwAutoInit(); + mwAriFunction = func; + } + +/*********************************************************************** +** Allocation handlers +***********************************************************************/ + +void* mwMalloc( size_t size, const char* file, int line) { + size_t needed; + mwData *mw; + char *ptr; + void *p; + + mwAutoInit(); + + MW_MUTEX_LOCK(); + + TESTS(file,line); + + mwCounter ++; + needed = mwDataSize + mwOverflowZoneSize*2 + size; + if( needed < size ) + { + /* theoretical case: req size + mw overhead exceeded size_t limits */ + return NULL; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc > mwAllocLimit) ) { + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (long)size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + mw = (mwData*) malloc( needed ); + if( mw == NULL ) { + if( mwFreeUp(needed,0) >= needed ) { + mw = (mwData*) malloc(needed); + if( mw == NULL ) { + mwWrite( "internal: mwFreeUp(%u) reported success, but malloc() fails\n", needed ); + mwIncErr(); + FLUSH(); + } + } + if( mw == NULL ) { + mwWrite( "fail: <%ld> %s(%d), %ld wanted %ld allocated\n", + mwCounter, file, line, (long)size, mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + mw->count = mwCounter; + mw->prev = NULL; + mw->next = mwHead; + mw->file = file; + mw->size = size; + mw->line = line; + mw->flag = 0; + mw->check = CHKVAL(mw); + + if( mwHead ) mwHead->prev = mw; + mwHead = mw; + if( mwTail == NULL ) mwTail = mw; + + ptr = ((char*)mw) + mwDataSize; + mwWriteOF( ptr ); /* '*(long*)ptr = PRECHK;' */ + ptr += mwOverflowZoneSize; + p = ptr; + memset( ptr, MW_VAL_NEW, size ); + ptr += size; + mwWriteOF( ptr ); /* '*(long*)ptr = POSTCHK;' */ + + mwNumCurAlloc ++; + mwStatCurAlloc += (long) size; + mwStatTotAlloc += (long) size; + if( mwStatCurAlloc > mwStatMaxAlloc ) + mwStatMaxAlloc = mwStatCurAlloc; + mwStatNumAlloc ++; + + if( mwStatLevel ) mwStatAlloc( size, file, line ); + + MW_MUTEX_UNLOCK(); + return p; + } + +void* mwRealloc( void *p, size_t size, const char* file, int line) { + int oldUseLimit, i; + mwData *mw; + char *ptr; + + mwAutoInit(); + + if( p == NULL ) return mwMalloc( size, file, line ); + if( size == 0 ) { mwFree( p, file, line ); return NULL; } + + MW_MUTEX_LOCK(); + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + if( mwIsOwned( mw, file, line ) ) { + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + mwIncErr(); + if( *((unsigned char*)(mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc - (long)mw->size > mwAllocLimit) ) { + TESTS(file,line); + mwCounter ++; + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (unsigned long)size - mw->size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + /* fake realloc operation */ + oldUseLimit = mwUseLimit; + mwUseLimit = 0; + ptr = (char*) mwMalloc( size, file, line ); + if( ptr != NULL ) { + if( size < mw->size ) + memcpy( ptr, p, size ); + else + memcpy( ptr, p, mw->size ); + mwFree( p, file, line ); + } + mwUseLimit = oldUseLimit; + MW_MUTEX_UNLOCK(); + return (void*) ptr; + } + + /* Unknown pointer! */ + + /* using free'd pointer? */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + /* some weird pointer */ + mwIncErr(); + mwWrite( "realloc: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + +char *mwStrdup( const char* str, const char* file, int line ) { + size_t len; + char *newstring; + + MW_MUTEX_LOCK(); + + if( str == NULL ) { + mwIncErr(); + mwWrite( "strdup: <%ld> %s(%d), strdup(NULL) called\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + len = strlen( str ) + 1; + newstring = (char*) mwMalloc( len, file, line ); + if( newstring != NULL ) memcpy( newstring, str, len ); + MW_MUTEX_UNLOCK(); + return newstring; + } + +void mwFree( void* p, const char* file, int line ) { + int i; + mwData* mw; + char buffer[ sizeof(mwData) + (mwROUNDALLOC*3) + 64 ]; + + /* this code is in support of C++ delete */ + if( file == NULL ) { + mwFree_( p ); + MW_MUTEX_UNLOCK(); + return; + } + + mwAutoInit(); + + MW_MUTEX_LOCK(); + TESTS(file,line); + mwCounter ++; + + /* on NULL free, write a warning and return */ + if( p == NULL ) { + mwWrite( "NULL free: <%ld> %s(%d), NULL pointer free'd\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + + if( mwIsOwned( mw, file, line ) ) { + (void) mwTestBuf( mw, file, line ); + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + if( *(((unsigned char*)mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* update the statistics */ + mwNumCurAlloc --; + mwStatCurAlloc -= (long) mw->size; + if( mwStatLevel ) mwStatFree( mw->size, mw->file, mw->line ); + + /* we should either free the allocation or keep it as NML */ + if( mwNML ) { + mw->flag |= MW_NML; + mwNmlNumAlloc ++; + mwNmlCurAlloc += (long) mw->size; + memset( ((char*)mw)+mwDataSize+mwOverflowZoneSize, MW_VAL_NML, mw->size ); + } + else { + /* unlink the allocation, and enter the post-free data */ + mwUnlink( mw, file, line ); + memset( mw, MW_VAL_DEL, + mw->size + mwDataSize+mwOverflowZoneSize+mwOverflowZoneSize ); + if( mwFBI ) { + memset( mw, '.', mwDataSize + mwOverflowZoneSize ); + sprintf( buffer, "FBI<%ld>%s(%d)", mwCounter, file, line ); + strncpy( (char*)(void*)mw, buffer, mwDataSize + mwOverflowZoneSize ); + } + free( mw ); + } + + /* add the pointer to the last-free track */ + mwLFfile[ mwLFcur ] = file; + mwLFline[ mwLFcur ] = line; + mwLastFree[ mwLFcur++ ] = p; + if( mwLFcur == MW_FREE_LIST ) mwLFcur = 0; + + MW_MUTEX_UNLOCK(); + return; + } + + /* check for double-freeing */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + } + + /* some weird pointer... block the free */ + mwIncErr(); + mwWrite( "WILD free: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + +void* mwCalloc( size_t a, size_t b, const char *file, int line ) { + void *p; + size_t size = a * b; + p = mwMalloc( size, file, line ); + if( p == NULL ) return NULL; + memset( p, 0, size ); + return p; + } + +void mwFree_( void *p ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + free(p); + } + +void* mwMalloc_( size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return malloc( size ); + } + +void* mwRealloc_( void *p, size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return realloc( p, size ); + } + +void* mwCalloc_( size_t a, size_t b ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return calloc( a, b ); + } + +void mwFlushNow( void ) { + if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwDoFlush( int onoff ) { + mwFlushW( onoff<1?0:onoff ); + if( onoff ) if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwLimit( long lim ) { + TESTS(NULL,0); + mwWrite("limit: old limit = "); + if( !mwAllocLimit ) mwWrite( "none" ); + else mwWrite( "%ld bytes", mwAllocLimit ); + mwWrite( ", new limit = "); + if( !lim ) { + mwWrite( "none\n" ); + mwUseLimit = 0; + } + else { + mwWrite( "%ld bytes\n", lim ); + mwUseLimit = 1; + } + mwAllocLimit = lim; + FLUSH(); + } + +void mwSetAriAction( int action ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + mwAriAction = action; + MW_MUTEX_UNLOCK(); + return; + } + +int mwAssert( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "assert trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: assert trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + switch( i ) { + case MW_ARI_IGNORE: + mwWrite( "assert trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + case MW_ARI_RETRY: + mwWrite( "assert trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "assert trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: assert trap: %s(%d), %s\n", fn, ln, exps ); + } + + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +int mwVerify( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "verify trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: verify trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + if( i == 0 ) { + mwWrite( "verify trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + if( i == 1 ) { + mwWrite( "verify trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "verify trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: verify trap: %s(%d), %s\n", fn, ln, exps ); + } + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +void mwTrace( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(NULL,0); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + + FLUSH(); + MW_MUTEX_UNLOCK(); + } + + +/*********************************************************************** +** Grab & Drop +***********************************************************************/ + +unsigned mwGrab( unsigned kb ) { + TESTS(NULL,0); + return mwGrab_( kb, MW_VAL_GRB, 0 ); + } + +unsigned mwDrop( unsigned kb ) { + TESTS(NULL,0); + return mwDrop_( kb, MW_VAL_GRB, 0 ); + } + +static void mwDropAll() { + TESTS(NULL,0); + (void) mwDrop_( 0, MW_VAL_GRB, 0 ); + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + if( mwGrabList != NULL ) + mwWrite( "internal: the grab list is not empty after mwDropAll()\n"); + } + +static const char *mwGrabType( int type ) { + switch( type ) { + case MW_VAL_GRB: + return "grabbed"; + case MW_VAL_NML: + return "no-mans-land"; + default: + /* do nothing */ + ; + } + return ""; + } + +static unsigned mwGrab_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd; + if( !kb ) i = kb = 65000U; + + for(;kb;kb--) { + if( mwUseLimit && + (mwStatCurAlloc + mwGrabSize + (long)sizeof(mwGrabData) > mwAllocLimit) ) { + if( !silent ) { + mwWrite("grabbed: all allowed memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + gd = (mwGrabData*) malloc( sizeof(mwGrabData) ); + if( gd == NULL ) { + if( !silent ) { + mwWrite("grabbed: all available memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + mwGrabSize += (long) sizeof(mwGrabData); + gd->next = mwGrabList; + memset( gd->blob, type, sizeof(gd->blob) ); + gd->type = type; + mwGrabList = gd; + } + if( !silent ) { + mwWrite("grabbed: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +static unsigned mwDrop_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd,*tmp,*pr; + const void *p; + + if( mwGrabList == NULL && kb == 0 ) return 0; + if( !kb ) i = kb = 60000U; + + pr = NULL; + gd = mwGrabList; + for(;kb;) { + if( gd == NULL ) { + if( i-kb > 0 && !silent ) { + mwWrite("dropped: all %s memory (%u kb)\n", mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + if( gd->type == type ) { + if( pr ) pr->next = gd->next; + kb --; + tmp = gd; + if( mwGrabList == gd ) mwGrabList = gd->next; + gd = gd->next; + p = mwTestMem( tmp->blob, sizeof( tmp->blob ), type ); + if( p != NULL ) { + mwWrite( "wild pointer: <%ld> %s memory hit at %p\n", + mwCounter, mwGrabType(type), p ); + FLUSH(); + } + mwGrabSize -= (long) sizeof(mwGrabData); + free( tmp ); + } + else { + pr = gd; + gd = gd->next; + } + } + if( !silent ) { + mwWrite("dropped: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +/*********************************************************************** +** No-Mans-Land +***********************************************************************/ + +void mwNoMansLand( int level ) { + mwAutoInit(); + TESTS(NULL,0); + switch( level ) { + case MW_NML_NONE: + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + break; + case MW_NML_FREE: + break; + case MW_NML_ALL: + (void) mwGrab_( 0, MW_VAL_NML, 0 ); + break; + default: + return; + } + mwNML = level; + } + +/*********************************************************************** +** Static functions +***********************************************************************/ + +static void mwAutoInit( void ) +{ + if( mwInited ) return; + mwUseAtexit = 1; + mwInit(); + return; +} + +static FILE *mwLogR() { + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) return mwLog; + if( mwLog == mwLogB1 ) mwLogB2 = mwLog; + if( mwLog == mwLogB2 ) mwLogB1 = mwLog; + if( mwLogB1 == mwLogB2 ) mwLog = mwLogB1; + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) { + mwWrite("internal: log file handle damaged and recovered\n"); + FLUSH(); + return mwLog; + } + fprintf(mwSTDERR,"\nMEMWATCH: log file handle destroyed, using mwSTDERR\n" ); + mwLog = mwLogB1 = mwLogB2 = mwSTDERR; + return mwSTDERR; + } + +static void mwLogW( FILE *p ) { + mwLog = mwLogB1 = mwLogB2 = p; + } + +static int mwFlushR() { + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) return mwFlushing; + if( mwFlushing == mwFlushingB1 ) mwFlushingB2 = mwFlushing; + if( mwFlushing == mwFlushingB2 ) mwFlushingB1 = mwFlushing; + if( mwFlushingB1 == mwFlushingB2 ) mwFlushing = mwFlushingB1; + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) { + mwWrite("internal: flushing flag damaged and recovered\n"); + FLUSH(); + return mwFlushing; + } + mwWrite("internal: flushing flag destroyed, so set to true\n"); + mwFlushing = mwFlushingB1 = mwFlushingB2 = 1; + return 1; + } + +static void mwFlushW( int n ) { + mwFlushing = mwFlushingB1 = mwFlushingB2 = n; + } + +static void mwIncErr() { + mwErrors++; + mwFlushW( mwFlushR()+1 ); + FLUSH(); + } + +static void mwFlush() { + if( mwLogR() == NULL ) return; +#ifdef MW_FLUSH + fflush( mwLogR() ); +#else + if( mwFlushR() ) fflush( mwLogR() ); +#endif + return; + } + +static void mwUnlink( mwData* mw, const char* file, int line ) { + if( mw->prev == NULL ) { + if( mwHead != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 NULL, but not head\n", + mwCounter, file, line, mw ); + mwHead = mw->next; + } + else { + if( mw->prev->next != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 failure\n", + mwCounter, file, line, mw ); + else mw->prev->next = mw->next; + } + if( mw->next == NULL ) { + if( mwTail != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 NULL, but not tail\n", + mwCounter, file, line, mw ); + mwTail = mw->prev; + } + else { + if( mw->next->prev != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 failure\n", + mwCounter, file, line, mw ); + else mw->next->prev = mw->prev; + } + } + +/* +** Relinking tries to repair a damaged mw block. +** Returns nonzero if it thinks it successfully +** repaired the heap chain. +*/ +static int mwRelink( mwData* mw, const char* file, int line ) { + int fails; + mwData *mw1, *mw2; + long count, size; + mwStat *ms; + + if( file == NULL ) file = "unknown"; + + if( mw == NULL ) { + mwWrite("relink: cannot repair MW at NULL\n"); + FLUSH(); + goto emergency; + } + + if( !mwIsSafeAddr(mw, mwDataSize) ) { + mwWrite("relink: MW-%p is a garbage pointer\n", mw); + FLUSH(); + goto emergency; + } + + mwWrite("relink: <%ld> %s(%d) attempting to repair MW-%p...\n", mwCounter, file, line, mw ); + FLUSH(); + fails = 0; + + /* Repair from head */ + if( mwHead != mw ) { + if( !mwIsSafeAddr( mwHead, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; head pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwHead; mw1; mw1=mw1->next ) { + if( mw1->next == mw ) { + mw->prev = mw1; + break; + } + if( mw1->next && + ( !mwIsSafeAddr(mw1->next, mwDataSize ) || mw1->next->prev != mw1) ) { + mwWrite("relink: failed for MW-%p; forward chain fragmented at MW-%p: 'next' is %p\n", mw, mw1, mw1->next ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in forward chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the head (first) allocation\n", mw ); + if( mw->prev != NULL ) + { + mwWrite( "relink: MW-%p prev pointer is non-NULL, you have a wild pointer\n", mw ); + mw->prev = NULL; + } + } + + /* Repair from tail */ + if( mwTail != mw ) { + if( !mwIsSafeAddr( mwTail, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; tail pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwTail; mw1; mw1=mw1->prev ) { + if( mw1->prev == mw ) { + mw->next = mw1; + break; + } + if( mw1->prev && (!mwIsSafeAddr(mw1->prev, mwDataSize ) || mw1->prev->next != mw1) ) { + mwWrite("relink: failed for MW-%p; reverse chain fragmented at MW-%p, 'prev' is %p\n", mw, mw1, mw1->prev ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in reverse chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the tail (last) allocation\n", mw ); + if( mw->next != NULL ) + { + mwWrite( "relink: MW-%p next pointer is non-NULL, you have a wild pointer\n", mw ); + mw->next = NULL; + } + } + + if( fails > 1 ) { + mwWrite("relink: heap appears intact, MW-%p probably garbage pointer\n", mw ); + FLUSH(); + goto verifyok; + } + + /* restore MW info where possible */ + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + mw->check = CHKVAL(mw); + goto verifyok; + + /* Emergency repair */ + emergency: + + if( mwHead == NULL && mwTail == NULL ) + { + if( mwStatCurAlloc == 0 ) + mwWrite("relink: <%ld> %s(%d) heap is empty, nothing to repair\n", mwCounter, file, line ); + else + mwWrite("relink: <%ld> %s(%d) heap damaged beyond repair\n", mwCounter, file, line ); + FLUSH(); + return 0; + } + + mwWrite("relink: <%ld> %s(%d) attempting emergency repairs...\n", mwCounter, file, line ); + FLUSH(); + + if( mwHead == NULL || mwTail == NULL ) + { + if( mwHead == NULL ) mwWrite("relink: mwHead is NULL, but mwTail is %p\n", mwTail ); + else mwWrite("relink: mwTail is NULL, but mwHead is %p\n", mwHead ); + } + + mw1=NULL; + if( mwHead != NULL ) + { + if( !mwIsReadAddr( mwHead, mwDataSize ) || mwHead->check != CHKVAL(mwHead) ) + { + mwWrite("relink: mwHead (MW-%p) is damaged, skipping forward scan\n", mwHead ); + mwHead = NULL; + goto scan_reverse; + } + if( mwHead->prev != NULL ) + { + mwWrite("relink: the mwHead pointer's 'prev' member is %p, not NULL\n", mwHead->prev ); + } + for( mw1=mwHead; mw1; mw1=mw1->next ) + { + if( mw1->next ) + { + if( !mwIsReadAddr(mw1->next,mwDataSize) || + !mw1->next->check != CHKVAL(mw1) || + mw1->next->prev != mw1 ) + { + mwWrite("relink: forward chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw1->file, mw1->line ); + if( mwIsReadAddr(mw1->next,mwDataSize ) ) + { + mwWrite("relink: forward chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1->next, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw1->file,16)?mw1->file:"", mw1->line ); + } + else + { + mwWrite("relink: the 'next' pointer of this MW points to %p, which is out-of-legal-access\n", + mw1->next ); + } + break; + } + } + } + } + + +scan_reverse: + mw2=NULL; + if( mwTail != NULL ) + { + if( !mwIsReadAddr(mwTail,mwDataSize) || mwTail->check != CHKVAL(mwTail) ) + { + mwWrite("relink: mwTail (%p) is damaged, skipping reverse scan\n", mwTail ); + mwTail = NULL; + goto analyze; + } + if( mwTail->next != NULL ) + { + mwWrite("relink: the mwTail pointer's 'next' member is %p, not NULL\n", mwTail->next ); + } + for( mw2=mwTail; mw2; mw2=mw2->prev ) + { + if( mw2->prev ) + { + if( !mwIsReadAddr(mw2->prev,mwDataSize) || + !mw2->prev->check != CHKVAL(mw2) || + mw2->prev->next != mw2 ) + { + mwWrite("relink: reverse chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw2->file, mw2->line ); + if( mwIsReadAddr(mw2->prev,mwDataSize ) ) + { + mwWrite("relink: reverse chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2->prev, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw2->file,16)?mw2->file:"", mw2->line ); + } + else + { + mwWrite("relink: the 'prev' pointer of this MW points to %p, which is out-of-legal-access\n", + mw2->prev ); + } + break; + } + } + } + } + +analyze: + if( mwHead == NULL && mwTail == NULL ) + { + mwWrite("relink: both head and tail pointers damaged, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + if( mwHead == NULL ) + { + mwHead = mw2; + mwWrite("relink: heap truncated, MW-%p designated as new mwHead\n", mw2 ); + mw2->prev = NULL; + mw1 = mw2 = NULL; + } + if( mwTail == NULL ) + { + mwTail = mw1; + mwWrite("relink: heap truncated, MW-%p designated as new mwTail\n", mw1 ); + mw1->next = NULL; + mw1 = mw2 = NULL; + } + if( mw1 == NULL && mw2 == NULL && + mwHead->prev == NULL && mwTail->next == NULL ) { + mwWrite("relink: verifying heap integrity...\n" ); + FLUSH(); + goto verifyok; + } + if( mw1 && mw2 && mw1 != mw2 ) { + mw1->next = mw2; + mw2->prev = mw1; + mwWrite("relink: emergency repairs successful, assessing damage...\n"); + FLUSH(); + } + else { + mwWrite("relink: heap totally destroyed, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + + /* Verify by checking that the number of active allocations */ + /* match the number of entries in the chain */ +verifyok: + if( !mwIsHeapOK( NULL ) ) { + mwWrite("relink: heap verification FAILS - aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + for( size=count=0, mw1=mwHead; mw1; mw1=mw1->next ) { + count ++; + size += (long) mw1->size; + } + if( count == mwNumCurAlloc ) { + mwWrite("relink: successful, "); + if( size == mwStatCurAlloc ) { + mwWrite("no allocations lost\n"); + } + else { + if( mw != NULL ) { + mwWrite("size information lost for MW-%p\n", mw); + mw->size = 0; + } + } + } + else { + mwWrite("relink: partial, %ld MW-blocks of %ld bytes lost\n", + mwNmlNumAlloc+mwNumCurAlloc-count, mwNmlCurAlloc+mwStatCurAlloc-size ); + return 0; + } + + return 1; + } + +/* +** If mwData* is NULL: +** Returns 0 if heap chain is broken. +** Returns 1 if heap chain is intact. +** If mwData* is not NULL: +** Returns 0 if mwData* is missing or if chain is broken. +** Returns 1 if chain is intact and mwData* is found. +*/ +static int mwIsHeapOK( mwData *includes_mw ) { + int found = 0; + mwData *mw; + + for( mw = mwHead; mw; mw=mw->next ) { + if( includes_mw == mw ) found++; + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + if( mw->prev ) { + if( !mwIsSafeAddr( mw->prev, mwDataSize ) ) return 0; + if( mw==mwHead || mw->prev->next != mw ) return 0; + } + if( mw->next ) { + if( !mwIsSafeAddr( mw->next, mwDataSize ) ) return 0; + if( mw==mwTail || mw->next->prev != mw ) return 0; + } + else if( mw!=mwTail ) return 0; + } + + if( includes_mw != NULL && !found ) return 0; + + return 1; + } + +static int mwIsOwned( mwData* mw, const char *file, int line ) { + int retv; + mwStat *ms; + + /* see if the address is legal according to OS */ + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + + /* make sure we have _anything_ allocated */ + if( mwHead == NULL && mwTail == NULL && mwStatCurAlloc == 0 ) + return 0; + + /* calculate checksum */ + if( mw->check != CHKVAL(mw) ) { + /* may be damaged checksum, see if block is in heap */ + if( mwIsHeapOK( mw ) ) { + /* damaged checksum, repair it */ + mwWrite( "internal: <%ld> %s(%d), checksum for MW-%p is incorrect\n", + mwCounter, file, line, mw ); + mwIncErr(); + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + else mw->file = ""; + mw->size = 0; + mw->check = CHKVAL(mw); + return 1; + } + /* no, it's just some garbage data */ + return 0; + } + + /* check that the non-NULL pointers are safe */ + if( mw->prev && !mwIsSafeAddr( mw->prev, mwDataSize ) ) mwRelink( mw, file, line ); + if( mw->next && !mwIsSafeAddr( mw->next, mwDataSize ) ) mwRelink( mw, file, line ); + + /* safe address, checksum OK, proceed with heap checks */ + + /* see if the block is in the heap */ + retv = 0; + if( mw->prev ) { if( mw->prev->next == mw ) retv ++; } + else { if( mwHead == mw ) retv++; } + if( mw->next ) { if( mw->next->prev == mw ) retv ++; } + else { if( mwTail == mw ) retv++; } + if( mw->check == CHKVAL(mw) ) retv ++; + if( retv > 2 ) return 1; + + /* block not in heap, check heap for corruption */ + + if( !mwIsHeapOK( mw ) ) { + if( mwRelink( mw, file, line ) ) + return 1; + } + + /* unable to repair */ + mwWrite( "internal: <%ld> %s(%d), mwIsOwned fails for MW-%p\n", + mwCounter, file, line, mw ); + mwIncErr(); + + return 0; + } + +/* +** mwTestBuf: +** Checks a buffers links and pre/postfixes. +** Writes errors found to the log. +** Returns zero if no errors found. +*/ +static int mwTestBuf( mwData* mw, const char* file, int line ) { + int retv = 0; + char *p; + + if( file == NULL ) file = "unknown"; + + if( !mwIsSafeAddr( mw, mwDataSize + mwOverflowZoneSize ) ) { + mwWrite( "internal: <%ld> %s(%d): pointer MW-%p is invalid\n", + mwCounter, file, line, mw ); + mwIncErr(); + return 2; + } + + if( mw->check != CHKVAL(mw) ) { + mwWrite( "internal: <%ld> %s(%d), info trashed; relinking\n", + mwCounter, file, line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) return 2; + } + + if( mw->prev && mw->prev->next != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link1 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + if( mw->next && mw->next->prev != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link2 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + + p = ((char*)mw) + mwDataSize; + if( mwCheckOF( p ) ) { + mwWrite( "underflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + p += mwOverflowZoneSize + mw->size; + if( mwIsReadAddr( p, mwOverflowZoneSize ) && mwCheckOF( p ) ) { + mwWrite( "overflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + + return retv; + } + +static void mwDefaultOutFunc( int c ) { + if( mwLogR() ) fputc( c, mwLogR() ); + } + +static void mwWrite( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + mwAutoInit(); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwWrite( "\ninternal: mwWrite(): WARNING! OUTPUT EXCEEDED %u CHARS: SYSTEM UNSTABLE\n", MW_TRACE_BUFFER-1 ); + FLUSH(); + } + return; + } + +static void mwLogFile( const char *name ) { + time_t tid; + (void) time( &tid ); + if( mwLogR() != NULL ) { + fclose( mwLogR() ); + mwLogW( NULL ); + } + if( name == NULL ) return; + mwLogW( fopen( name, "a" COMMIT ) ); + if( mwLogR() == NULL ) + mwWrite( "logfile: failed to open/create file '%s'\n", name ); + } + +/* +** Try to free NML memory until a contiguous allocation of +** 'needed' bytes can be satisfied. If this is not enough +** and the 'urgent' parameter is nonzero, grabbed memory is +** also freed. +*/ +static size_t mwFreeUp( size_t needed, int urgent ) { + void *p; + mwData *mw, *mw2; + char *data; + + /* free grabbed NML memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_NML, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + /* free normal NML memory */ + mw = mwHead; + while( mw != NULL ) { + if( !(mw->flag & MW_NML) ) mw = mw->next; + else { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + mw2 = mw->next; + mwUnlink( mw, "mwFreeUp", 0 ); + free( mw ); + mw = mw2; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + } + + /* if not urgent (for internal purposes), fail */ + if( !urgent ) return 0; + + /* free grabbed memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_GRB, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + return 0; + } + +static const void * mwTestMem( const void *p, unsigned len, int c ) { + const unsigned char *ptr; + ptr = (const unsigned char *) p; + while( len-- ) { + if( *ptr != (unsigned char)c ) return (const void*)ptr; + ptr ++; + } + return NULL; + } + +static int mwStrCmpI( const char *s1, const char *s2 ) { + if( s1 == NULL || s2 == NULL ) return 0; + while( *s1 ) { + if( toupper(*s2) == toupper(*s1) ) { s1++; s2++; continue; } + return 1; + } + return 0; + } + +#define AIPH() if( always_invoked ) { mwWrite("autocheck: <%ld> %s(%d) ", mwCounter, file, line ); always_invoked = 0; } + +static int mwTestNow( const char *file, int line, int always_invoked ) { + int retv = 0; + mwData *mw; + char *data; + + if( file && !always_invoked ) + mwWrite("check: <%ld> %s(%d), checking %s%s%s\n", + mwCounter, file, line, + (mwTestFlags & MW_TEST_CHAIN) ? "chain ": "", + (mwTestFlags & MW_TEST_ALLOC) ? "alloc ": "", + (mwTestFlags & MW_TEST_NML) ? "nomansland ": "" + ); + + if( mwTestFlags & MW_TEST_CHAIN ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( !mwIsSafeAddr(mw, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw->prev ) { + if( !mwIsSafeAddr(mw->prev, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwHead || mw->prev->next != mw ) { + AIPH(); + mwWrite("check: heap chain broken, prev link incorrect\n"); + mwIncErr(); + retv ++; + } + } + if( mw->next ) { + if( !mwIsSafeAddr(mw->next, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwTail || mw->next->prev != mw ) { + AIPH(); + mwWrite("check: heap chain broken, next link incorrect\n"); + mwIncErr(); + retv ++; + } + } + else if( mw!=mwTail ) { + AIPH(); + mwWrite("check: heap chain broken, tail incorrect\n"); + mwIncErr(); + retv ++; + } + } + } + if( mwTestFlags & MW_TEST_ALLOC ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( mwTestBuf( mw, file, line ) ) retv ++; + } + } + if( mwTestFlags & MW_TEST_NML ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( (mw->flag & MW_NML) ) { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + } + } + } + + + if( file && !always_invoked && !retv ) + mwWrite("check: <%ld> %s(%d), complete; no errors\n", + mwCounter, file, line ); + return retv; + } + +/********************************************************************** +** Statistics +**********************************************************************/ + +static void mwStatReport() +{ + mwStat* ms, *ms2; + const char *modname; + int modnamelen; + + /* global statistics report */ + mwWrite( "\nMemory usage statistics (global):\n" ); + mwWrite( " N)umber of allocations made: %ld\n", mwStatNumAlloc ); + mwWrite( " L)argest memory usage : %ld\n", mwStatMaxAlloc ); + mwWrite( " T)otal of all alloc() calls: %ld\n", mwStatTotAlloc ); + mwWrite( " U)nfreed bytes totals : %ld\n", mwStatCurAlloc ); + FLUSH(); + + if( mwStatLevel < 1 ) return; + + /* on a per-module basis */ + mwWrite( "\nMemory usage statistics (detailed):\n"); + mwWrite( " Module/Line Number Largest Total Unfreed \n"); + for( ms=mwStatList; ms; ms=ms->next ) + { + if( ms->line == -1 ) + { + if( ms->file == NULL || !mwIsReadAddr(ms->file,22) ) modname = ""; + else modname = ms->file; + modnamelen = strlen(modname); + if( modnamelen > 42 ) + { + modname = modname + modnamelen - 42; + } + + mwWrite(" %-42s %-8ld %-8ld %-8ld %-8ld\n", + modname, ms->num, ms->max, ms->total, ms->curr ); + if( ms->file && mwStatLevel > 1 ) + { + for( ms2=mwStatList; ms2; ms2=ms2->next ) + { + if( ms2->line!=-1 && ms2->file!=NULL && !mwStrCmpI( ms2->file, ms->file ) ) + { + mwWrite( " %-8d %-8ld %-8ld %-8ld %-8ld\n", + ms2->line, ms2->num, ms2->max, ms2->total, ms2->curr ); + } + } + } + } + } +} + +static mwStat* mwStatGet( const char *file, int line, int makenew ) { + mwStat* ms; + + if( mwStatLevel < 2 ) line = -1; + + for( ms=mwStatList; ms!=NULL; ms=ms->next ) { + if( line != ms->line ) continue; + if( file==NULL ) { + if( ms->file == NULL ) break; + continue; + } + if( ms->file == NULL ) continue; + if( !strcmp( ms->file, file ) ) break; + } + + if( ms != NULL ) return ms; + + if( !makenew ) return NULL; + + ms = (mwStat*) malloc( sizeof(mwStat) ); + if( ms == NULL ) { + if( mwFreeUp( sizeof(mwStat), 0 ) < sizeof(mwStat) || + (ms=(mwStat*)malloc(sizeof(mwStat))) == NULL ) { + mwWrite("internal: memory low, statistics incomplete for '%s'\n", file ); + return NULL; + } + } + ms->file = file; + ms->line = line; + ms->total = 0L; + ms->max = 0L; + ms->num = 0L; + ms->curr = 0L; + ms->next = mwStatList; + mwStatList = ms; + return ms; + } + +static void mwStatAlloc( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + } + + } + +static void mwStatFree( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + } + } + +/*********************************************************************** +** Safe memory checkers +** +** Using ifdefs, implement the operating-system specific mechanism +** of identifying a piece of memory as legal to access with read +** and write priviliges. Default: return nonzero for non-NULL pointers. +***********************************************************************/ + +static char mwDummy( char c ) +{ + return c; +} + +#ifndef MW_SAFEADDR +#ifdef WIN32 +#define MW_SAFEADDR +#define WIN32_LEAN_AND_MEAN +#include +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) ) return 0; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + /* NOTE: For some reason, under Win95 the IsBad... */ + /* can return false for invalid pointers. */ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) || IsBadWritePtr(p,len) ) return 0; + return 1; +} +#endif /* WIN32 */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +#ifdef SIGSEGV +#define MW_SAFEADDR + +typedef void (*mwSignalHandlerPtr)( int ); +mwSignalHandlerPtr mwOldSIGSEGV = (mwSignalHandlerPtr) 0; +jmp_buf mwSIGSEGVjump; +static void mwSIGSEGV( int n ); + +static void mwSIGSEGV( int n ) +{ + n = n; + longjmp( mwSIGSEGVjump, 1 ); +} + +int mwIsReadAddr( const void *p, unsigned len ) +{ + const char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read all the bytes in the range */ + ptr = (const char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + if( *ptr == 0x7C ) (void) mwDummy( (char)0 ); + } while( (const void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read and write-back all the bytes in the range */ + ptr = (char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + *ptr = mwDummy( *ptr ); + } while( (void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +#endif /* SIGSEGV */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +#endif + +/********************************************************************** +** Mutex handling +**********************************************************************/ + +#if defined(WIN32) || defined(__WIN32__) + +static void mwMutexInit( void ) +{ + mwGlobalMutex = CreateMutex( NULL, FALSE, NULL); + return; +} + +static void mwMutexTerm( void ) +{ + CloseHandle( mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + if( WaitForSingleObject(mwGlobalMutex, 1000 ) == WAIT_TIMEOUT ) + { + mwWrite( "mwMutexLock: timed out, possible deadlock\n" ); + } + return; +} + +static void mwMutexUnlock( void ) +{ + ReleaseMutex( mwGlobalMutex ); + return; +} + +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) + +static void mwMutexInit( void ) +{ + pthread_mutex_init( &mwGlobalMutex, NULL ); + return; +} + +static void mwMutexTerm( void ) +{ + pthread_mutex_destroy( &mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + pthread_mutex_lock(&mwGlobalMutex); + return; +} + +static void mwMutexUnlock( void ) +{ + pthread_mutex_unlock(&mwGlobalMutex); + return; +} + +#endif + +/********************************************************************** +** C++ new & delete +**********************************************************************/ + +#if 0 /* 980317: disabled C++ */ + +#ifdef __cplusplus +#ifndef MEMWATCH_NOCPP + +int mwNCur = 0; +const char *mwNFile = NULL; +int mwNLine = 0; + +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; + +MemWatch::MemWatch() { + if( mwInited ) return; + mwUseAtexit = 0; + mwInit(); + } + +MemWatch::~MemWatch() { + if( mwUseAtexit ) return; + mwTerm(); + } + +/* +** This global new will catch all 'new' calls where MEMWATCH is +** not active. +*/ +void* operator new( unsigned size ) { + mwNCur = 0; + return mwMalloc( size, "", 0 ); + } + +/* +** This is the new operator that's called when a module uses mwNew. +*/ +void* operator new( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** This is the new operator that's called when a module uses mwNew[]. +** -- hjc 07/16/02 +*/ +void* operator new[] ( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** Since this delete operator will recieve ALL delete's +** even those from within libraries, we must accept +** delete's before we've been initialized. Nor can we +** reliably check for wild free's if the mwNCur variable +** is not set. +*/ +void operator delete( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +void operator delete[]( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +#endif /* MEMWATCH_NOCPP */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +/* MEMWATCH.C */ + +/*@end@*/ + diff --git a/omc/plat/public_bak/src/pub_conf.c b/omc/plat/public_bak/src/pub_conf.c new file mode 100644 index 0000000..bae8333 --- /dev/null +++ b/omc/plat/public_bak/src/pub_conf.c @@ -0,0 +1,12 @@ +////////////////////////////////////////////////// +//Title : pub_conf.c +//Auhtor : Liu Wei +//Desc : public conf file handle inplementation +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + diff --git a/omc/plat/public_bak/src/pub_debug.c b/omc/plat/public_bak/src/pub_debug.c new file mode 100644 index 0000000..276ee20 --- /dev/null +++ b/omc/plat/public_bak/src/pub_debug.c @@ -0,0 +1,52 @@ +////////////////////////////////////////////////// +//Title : wxc_debug.c +//Auhtor : Liu Wei +//Desc : wxc debug api implemetation +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_debug.h" + +/*@ignore@*/ + +void WxcDump( int nSigno ) +{ + char buf[1024]; + char cmd[1024]; + FILE *fh; + + snprintf ( buf, sizeof ( buf ), "/proc/%d/cmdline", getpid ( ) ); + fh = fopen ( buf, "r" ); + if ( fh == NULL ) + exit ( 0 ); + if ( NULL == (fgets ( buf, sizeof ( buf ), fh ) )) + exit ( 0 ); + fclose ( fh ); + if ( buf[strlen ( buf ) - 1] == '\n' ) + buf[strlen ( buf ) - 1] = '\0'; + snprintf ( cmd, sizeof ( cmd ), "gdb %s %d", buf, getpid ( ) ); + system ( cmd ); + + exit ( 0 ); +} + +void WxcBackTrace( ) +{ + int i; + void *array[25]; + int nSize = backtrace ( array, 25 ); + char **symbols = backtrace_symbols ( array, nSize ); + + for ( i = 0; i < nSize; i++ ) + { + printf ( "%s \n", symbols[i] ); + } + free ( symbols ); +} + +/*@end@*/ + diff --git a/omc/plat/public_bak/src/pub_file.c b/omc/plat/public_bak/src/pub_file.c new file mode 100644 index 0000000..c1b151c --- /dev/null +++ b/omc/plat/public_bak/src/pub_file.c @@ -0,0 +1,44 @@ +////////////////////////////////////////////////// +//Title : wxc_file.c +//Auhtor : Liu Wei +//Desc : wxc file handle inplementation +//Created : 2007-06-04 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_file.h" + +/*@ignore@*/ + +/////////////////////////////////////////////////////////////////////////// +// GetOneLine: Read one line of a file +/////////////////////////////////////////////////////////////////////////// + +extern char *GetOneLine ( char *pFileName ) +{ + FILE *pFile; + static char sBuff[1024]; + char *pCh; + + pFile = fopen ( pFileName, "r" ); + if ( pFile != NULL ) + { + if ( fgets ( sBuff, sizeof ( sBuff ), pFile ) != NULL ) + { + if ( NULL != (pCh = strchr ( sBuff, '\n' )) ) + { + *pCh = CNULL; + } + return sBuff; + } + ( void ) fclose ( pFile ); + } + + return ( char * ) NULL; +} + + +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_fmt.c b/omc/plat/public_bak/src/pub_fmt.c new file mode 100644 index 0000000..f85b92b --- /dev/null +++ b/omc/plat/public_bak/src/pub_fmt.c @@ -0,0 +1,1242 @@ +////////////////////////////////////////////////// +//Title : pub_convert.c +//Auhtor : Liu Wei +//Desc : public format type convert inplementation +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// lCRD software network data type assumpsit +// +// Memery Low <<============[Little Endian]===========>> Memery High +// Type abbr. e.g. Remark +// const value CVal U32 dVal= 0x12345678 +// Host BCD HBcd/Bcd 0x78 0x56 0x34 0x12 +// Anti BCD ABcd 0x87 0x65 0x43 0x21 +// NetBCD NBcd 0x12 0x34 0x56 0x78 +// String Str 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 "12345678" +// U64 U64 0x4E 0x61 0xBC 0x00 0x00 0x00 0x00 0x00 12345678=0xBC614E +// Digit Dig 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 +// +//////////////////////////////////////////////////////////////////////////////// + +/** @defgroup format pub_fmt.c + ** @{ + **/ + +#include "./include/pub_fmt.h" + +/////////////////////////////////////////////////////////////////////////// +// For test +// +/////////////////////////////////////////////////////////////////////////// +/* +//define in pub_base.h +#define u8 unsigned char +#define u64 unsigned long long +#define CNULL '\0' + +#define BitSet(arg,posn) ((arg) | (1L << (posn))) +#define BitClr(arg,posn) ((arg) & ~(1L << (posn))) +#define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) +#define BitTst(arg,posn) (!(!((arg) & (1L << (posn))))) + +//define in pub_debug.h +#define WxcAssert +*/ + +/** + ** @note HexToCh : 0 - > '0' + ** + **/ +inline char HexToCh( u8 uHex ) +{ + return ( (uHex) + ( ((uHex) > 9)? 'A'-10 : '0') ); +} + +/** + ** @note ChToHex : '0' - > 0 + ** + **/ +inline u8 ChToHex( char ch) +{ + static char digits[] = "0123456789abcdef"; + u8 uRel = 0; + int s; + + for(s = 0; s < 16; ++s) + { + if( digits[s] == tolower(ch) ) + { + uRel = s; + return(uRel); + } + } + + return(uRel); +} + + +/** + ** @note ReverseByte : 0010 1010 =>> 0101 0100 + ** + **/ +inline u8 ReverseByte(u8 uByteIn ) +{ + u8 i ; + u8 uByteOut = 0; + + for( i = 0 ; i < 8 ; i ++ ) + { + if( BitTst( uByteIn , i ) ) + { + uByteOut = (u8) ( BitSet( uByteOut , 7-i ) ); + } + } + + return uByteOut; +} + +/** + ** @note ReverseBCD : 0x12 0x34 0x56 0x78 =>> 0x21 0x43 0x65 0x87 + ** + **/ +inline void ReverseBCD( u8 *pDst , const u8 *pSrc , int nBcdLen ) +{ + int i; + + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pDst[i] = (pSrc[i] >> 4) + (pSrc[i] << 4) ; + } +} + +/** + ** ReverseArray : 0x12 0x34 0x56 0x78 =>> 0x78 0x56 0x34 0x12 + ** + **/ +inline void ReverseArray( u8 *pDst , const u8 *pSrc , int nBcdLen ) +{ + int i; + + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pDst[i] = pSrc[nBcdLen-i-1]; + } +} + +/** + ** @note BcdToStr : 0x12 0x34 0x56 0x78 =>> "12345678" + ** + **/ +inline void BcdToStr( char *pStr , const u8 *pBcd , int nBcdLen ) +{ + int i , j ; + int nStrLen = nBcdLen * 2 + 1; + + memset( pStr , 0 , nStrLen ); + + j = 0; + for( i = 0 ; i < nBcdLen ; i ++ ) + { + pStr[j++] = HexToCh(pBcd[i] >> 4 ); + pStr[j++] = HexToCh(pBcd[i] & 0x0F); + } + pStr[j] = CNULL; +} + +/** + ** @note BcdToU64 : 0x12 0x34 0x56 0x78 =>> 12345678 + ** + **/ +inline u64 BcdToU64( const u8 *pBcd , int nBcdLen ) +{ + u64 llResult = 0; + u64 llMulti = 1; + int i; + + for( i = nBcdLen*2 -1 ; i >= 0 ; i -- ) + { + u8 uByte = pBcd[i/2] >> (4*((i+1)%2)); + + llResult += ( uByte & 0x0F ) * llMulti; + llMulti *= 10; + } + + return llResult; +} + +/** + ** @note BcdToDig : 0x12 0x34 0x56 =>>0x01 0x02 0x03 0x04 0x05 0x06 + ** + **/ +inline int BcdToDig( u8 *pDig , int nDigBuffLen, u8 *pBcd , int nBcdLen ) +{ + int i , j ; + + i = j = 0; + if( nDigBuffLen < 2*nBcdLen ) + { + return 0; + } + for( i = 0 ; i > 4 ; + pDig[j++] = pBcd[i] & 0x0F; + } + return j; +} + +/** + ** @note StrToBcd : "123456" =>> 0x12 0x34 0x56 + ** + **/ +inline int StrToBcd( u8 *pBcd , char *pStr , int nBcdBuffLen ) +{ + int i , j , k; + int nLen = strlen(pStr); + + i = j = k = 0; + j = (nLen + nLen%2) /2; + if( nBcdBuffLen < j ) + { + return 0; + } + memset( pBcd , 0 , j); + for( i = 0 ; i 0x01 0x23 0x45 0x67 + ** + **/ +inline int U64ToBcd( u8 *pBcd ,u64 llInput , int nBcdBuffLen ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = 0; + int i; + + while( llDiv < llInput ) + { + nDigNum++; + llDiv *= 10; + } + llDiv = ( nDigNum % 2 ) ? llDiv : llDiv/10; + + nDigNum += nDigNum % 2; + nBcdLen = nDigNum/2; + if( nBcdBuffLen < nBcdLen ) + { + return 0; + } + memset(pBcd , 0 , nBcdLen ); + for(i = 0; i < nBcdLen; i++) + { + pBcd[i] |= (((llInput / llDiv) %10) << 4); + llDiv /= 10; + pBcd[i] |= ((llInput / llDiv) % 10) ; + llDiv /= 10; + } + + return nBcdLen; +} + +/** + ** @note DigToBcd : 0x01 0x02 0x03 x04 0x05 0x06 0x07 => 0x01 0x23 0x45 0x67 + ** + **/ +inline int DigToBcd( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = (nDigLen + nDigLen %2)/2; + int i , j; + + j=0; + if( nBcdLen > nBcdBuffLen ) + { + return 0; + } + memset( pBcd , 0 , nBcdLen ); + + for(i = 0; i < nBcdLen; i++) + { + if( nDigLen %2 && !i ) + { + pBcd[i] &= 0x0F; + } + else + { + pBcd[i] |= pDig[j++] <<4; + } + pBcd[i] |= pDig[j++] & 0x0F; + } + return nBcdLen; +} + +/** + ** @note DigToBcd : 0x08 0x06 0x07 x05 0x05 0x00 0x01 => 0x86 0x75 0x50 0x1E + ** + **/ +inline int DigToBcdE( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen , int nEnd ) +{ + u64 llDiv = 10; + int nDigNum = 1; + int nBcdLen = (nDigLen + nDigLen %2)/2; + int i , j; + + j=0; + WxcAssert( nEnd <= 0x0F ,"DigToBcdE end code > 0x0F" ); + if( nBcdLen > nBcdBuffLen ) + { + WxcAssert( 0 , "DigToBcdE buffer overflow!"); + return 0; + } + memset( pBcd , 0 , nBcdLen ); + + for(i = 0; i < nBcdLen; i++) + { + pBcd[i] |= pDig[j++] <<4; + if( nDigLen %2 && i == (nBcdLen-1) ) + { + pBcd[i] |= nEnd; + } + else + { + pBcd[i] |= pDig[j++] & 0x0F; + } + + } + return nBcdLen; +} + +void _______________un_fmt______________() +{ + +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer ascii code to bcd code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + char flag=0; + + if (ascii_buf == NULL) + { + for (i=0;i='a') + ch -= 'a' - 10; + else if (ch>='A') + ch -= 'A' - 10; + else + ch -= '0'; + if (flag) + { + if (i & 1) + *bcd_buf = ch << 4; + else + *(bcd_buf++) |= ch & 0x0f; + } + else + { + if (i & 1) + *(bcd_buf++) |= ch & 0x0f; + else + *bcd_buf = ch << 4; + } + } +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer bcd code to ascii code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len) +{ + int i; + char ch; + + if (bcd_buf == NULL) + { + for (i=0;i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} + +int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen ) +{ + int iBcd = 0, iStr = 0, len; + BYTE flag = 0; + char val[3]; + + len = strlen ( pStr ); + val[1] = val[2] = 0; + strcat ( pStr, "F" ); + len++; + do + { + if( !isxdigit ( pStr[iStr] ) ) + continue; + + val[flag] = pStr[iStr]; + if( flag ) + { + pBcd[iBcd++] = strtoul ( val, NULL, 16 ); + } + flag = flag ? 0 : 1; + } + while ( iBcd < maxLen && ++iStr < len ); + + memset ( pBcd + iBcd, 0xFF, maxLen - iBcd ); + return iBcd; +} + +int Bcd2Str ( char *pStr, const BYTE * pBcd, int len ) +{ + int i; + + for ( i = 0; i < len; i++ ) + sprintf ( pStr + 2 * i, "%02X", pBcd[i] ); + + pStr[2 * len] = 0; + return len; +} + +int DigitsLen ( BYTE * pDigits, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pDigits[i] & 0x0F ) > 0x0A ) + return 2 * i; + if( ( pDigits[i] & 0xF0 ) > 0xA0 ) + return 2 * i + 1; + } + return maxLen * 2; +} + +int BcdLen ( BYTE * pBcd, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xA0 ) + return 2 * i; + if( ( pBcd[i] & 0x0F ) > 0x0A ) + return 2 * i + 1; + } + return maxLen * 2; +} + +int Digits2Str ( char *pStr, BYTE * pDigits, int DigitsLen ) +{ + int i = 0; + char low = '0', high = '0'; + + for ( i = 0; i < DigitsLen; i++ ) + { + low = pDigits[i] & 0xF; + if( low < 0x0A ) + { + pStr[2 * i] = low + '0'; + } + else if( low < 0x0E ) + { + pStr[2 * i] = low + 'A' - 10; + } + else + { + pStr[2 * i] = 0; + break; + } + + high = ( pDigits[i] >> 4 ); + if( high < 0x0A ) + { + pStr[2 * i + 1] = high + '0'; + } + else if( high < 0x0E ) + { + pStr[2 * i + 1] = high + 'A' - 10; + } + else + { + pStr[2 * i + 1] = 0; + break; + } + } + pStr[2 * DigitsLen] = '\0'; + return 1; +} + +ull Digits2Ull ( BYTE * pDigits, int DigitsLen ) +{ + ull result = 0; + int i; + BYTE digit; + + if( DigitsLen > 9 ) + DigitsLen = 9; + + for ( i = 0; i < DigitsLen; i++ ) + { + digit = pDigits[i] & 0x0F; + if( digit > 9 ) + return result; + result = result * 10 + digit; + + digit = pDigits[i] >> 4; + if( digit > 9 ) + return result; + result = result * 10 + digit; + } + return result; +} + +int Ull2Digits ( BYTE * pDigits, ull value, int DigitsLen ) +{ + char tempStr[64]; + + sprintf ( tempStr, "%lld", value ); + return Str2Digits ( pDigits, tempStr, DigitsLen ); +} + +int Str2Digits ( BYTE * pDigits, char *pStr, int DigitsLen ) +{ + int i = 0, strLen = strlen ( pStr ), len = 0; + char valstr[3]; + + len = strLen / 2; + if( len * 2 < strLen ) + { + strcat ( pStr, "F" ); + len++; + } + if( len > DigitsLen ) + len = DigitsLen; + + valstr[2] = 0; + for ( i = 0; i < len; i++ ) + { + valstr[0] = pStr[2 * i + 1]; + valstr[1] = pStr[2 * i]; + pDigits[i] = strtol ( valstr, NULL, 16 ); + } + return len; +} + +int Ull2Digits_Ralign ( BYTE * pDigits, ull value, int DigitsLen ) //right align +{ + char tempStr[64]; + char printStr[64]; + + sprintf ( printStr, "%%0%dlld", DigitsLen ); + sprintf ( tempStr, printStr, value ); + return Str2Digits ( pDigits, tempStr, ( DigitsLen + 1 ) / 2 ); +} + +ull Bcd2Ull ( BYTE * pBcd, int BcdLen ) +{ + ull result = 0; + int i; + BYTE digit; + + if( BcdLen > 9 ) + BcdLen = 9; + for ( i = 0; i < BcdLen; i++ ) + { + digit = pBcd[i] >> 4; + if( digit > 9 ) + return result; + result = result * 10 + digit; + + digit = pBcd[i] & 0x0F; + if( digit > 9 ) + return result; + result = result * 10 + digit; + } + return result; +} + +int Ull2Bcd ( BYTE * pBcd, ull value, int BcdLen ) +{ + char tempStr[64]; + + sprintf ( tempStr, "%lld", value ); + return Str2Bcd ( pBcd, tempStr, BcdLen ); +} + +int Digits2Bcd ( BYTE * pBcd, BYTE * pDigits, int maxLen ) +//return length +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pDigits[i] & 0x0F ) > 0x0C ) + return i; + + pBcd[i] = ( pDigits[i] << 4 ) | ( pDigits[i] >> 4 ); + + if( ( pDigits[i] & 0xF0 ) > 0xC0 ) + return i + 1; + + } + return maxLen; +} + +int Bcd2Digits ( BYTE * pDigits, BYTE * pBcd, int maxLen ) +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xC0 ) + return i; + + pDigits[i] = ( pBcd[i] << 4 ) | ( pBcd[i] >> 4 ); + + if( ( pBcd[i] & 0x0F ) > 0x0C ) + return i + 1; + } + return maxLen; +} + +int Bcd2Digits_dLen ( BYTE * pDigits, BYTE * pBcd, int maxLen ) //return digits len +{ + int i = 0; + + for ( i = 0; i < maxLen; i++ ) + { + if( ( pBcd[i] & 0xF0 ) > 0xC0 ) + return i * 2; + + pDigits[i] = ( pBcd[i] << 4 ) | ( pBcd[i] >> 4 ); + + if( ( pBcd[i] & 0x0F ) > 0x0C ) + return i * 2 + 1; + } + return maxLen * 2; +} + +int Str2Oid ( DWORD * pOid, char *pStr, BYTE maxLen ) +{ + BYTE sub = 0; + short len, i; + char *pvar; + + len = strlen ( pStr ); + pvar = pStr; + for ( i = 0; i < len && sub < maxLen; i++ ) + { + if( pStr[i] == '.' ) + { + pStr[i] = '\0'; + if( strlen ( pvar ) == 0 ) + continue; + pOid[sub++] = atoi ( pvar ); + pvar = pStr + i + 1; + } + } + if( strlen ( pvar ) == 0 ) + return sub; + pOid[sub++] = atoi ( pvar ); + return sub; +} + +//string===> +int TrimLeft ( char *pStr ) +{ + int i = 0; + + while ( ( pStr[i] == ' ' || pStr[i] == '\t' ) && i < 16 ) + i++; + + strcpy ( pStr, pStr + i ); + return 1; +} + +int TrimRight ( char *pStr ) +{ + int len = strlen ( pStr ); + + if( len > 1024 ) + return 0; + + while ( pStr[len - 1] == ' ' || pStr[len - 1] == '\t' ) + { + pStr[len - 1] = 0; + len--; + } + return 1; +} + +int Array2Digits ( BYTE * pDigits, BYTE * pArray, int ArrayLen ) +{ + int i; + + pArray[ArrayLen] = 0xEE; + for ( i = 0; i < ( ArrayLen + 1 ) / 2; i++ ) + pDigits[i] = ( pArray[2 * i + 1] << 4 ) | ( pArray[2 * i] & 0x0F ); + + return i; +} + +ull Str2Ull ( char *pStr ) +{ + ull result, intHigh, intLow; + DWORD len; + char strHigh[16] = "\0", *strLow; + + len = strlen ( pStr ); + if( len > 18 ) + return 0xFFFFFFFFFFFFFFFFll; + if( len > 9 ) + { + strLow = pStr + ( len - 9 ); + intLow = strtoul ( strLow, NULL, 10 ); + + strncpy ( strHigh, pStr, len - 9 ); + intHigh = strtoul ( strHigh, NULL, 10 ); + result = intHigh * 1000000000 + intLow; + return result; + } + else + { + intLow = strtoul ( pStr, NULL, 10 ); + return intLow; + } +} + +int Digits2Array ( BYTE * pArray, BYTE * pDigits, int DigitsLen ) +{ + int i, len = 0; + + for ( i = 0; i < DigitsLen; i++ ) + { + pArray[len] = pDigits[i] & 0x0F; + if( pArray[len] > 13 ) + return len; + len++; + + pArray[len] = pDigits[i] >> 4; + if( pArray[len] > 13 ) + return len; + len++; + } + + return len; +} + +int Bcd2Array ( BYTE * pArray, BYTE * pBcd, int BcdLen ) +{ + int i, len = 0; + + for ( i = 0; i < BcdLen; i++ ) + { + pArray[len] = pBcd[i] >> 4; + if( pArray[len] > 13 ) + return len; + len++; + + pArray[len] = pBcd[i] & 0x0F; + if( pArray[len] > 13 ) + return len; + len++; + } + + return len; +} + +int Str2Array ( BYTE * pArray, char *str, int ArrayLen ) +{ + int i, len; + char mystr[2]; + + mystr[1] = '\0'; + len = strlen ( str ); + if( len > ArrayLen ) + len = ArrayLen; + + for ( i = 0; i < len; i++ ) + { + mystr[0] = str[i]; + if( !isxdigit ( mystr[0] ) ) + return i; + pArray[i] = ( BYTE ) strtol ( mystr, NULL, 16 ); + } + return len; +} + +BYTE EditDigits ( BYTE * digits_out, BYTE len_max, BYTE * digits_in, BYTE len_in, BYTE len_del, BYTE * digits_ins, BYTE len_ins, BYTE filler ) +{ + BYTE len = 0, tmpbuf[64], pos1 = 0, pos2 = 0; + + if( len_ins > len_max ) //invalid insert length + { + memcpy ( digits_out, digits_in, ( len_in + 1 ) / 2 ); + return len_in; + } + else if( len_ins > 0 ) + { + memcpy ( digits_out, digits_ins, ( len_ins + 1 ) / 2 ); + len += len_ins; + } + + if( len_del > len_in ) //invalid delete length + { + memcpy ( digits_out, digits_in, ( len_in + 1 ) / 2 ); + return len_in; + } + else if( len_del == len_in ) + { + return len; + } + + if( ( len & 0x01 ) == ( len_del & 0x01 ) ) + { + if( len & 0x01 ) //odd + { + len_del++; + len_ins++; + pos1 = ( len + 1 ) / 2; + pos2 = ( len_del + 1 ) / 2; + digits_out[pos1 - 1] = ( digits_out[pos1 - 1] & 0x0F ) | ( digits_in[pos2 - 1] & 0xF0 ); + memcpy ( &digits_out[pos1], &digits_in[pos2], ( len_in - len_del + 1 ) / 2 ); + } + else //even + { + pos1 = len / 2; + pos2 = len_del / 2; + memcpy ( &digits_out[pos1], &digits_in[pos2], ( len_in - len_del + 1 ) / 2 ); + } + + /* daniel added this on 2006-04-18 */ + if( ( len_in + len_ins - len_del ) & 0x01 ) //odd + { + pos1 = ( len_in + len_ins - len_del + 1 ) / 2 - 1; + digits_out[pos1] &= 0x0f; + digits_out[pos1] |= ( filler & 0xf0 ); + } + else + { //even + //will not fill the filler + } + return len_in + len_ins - len_del; + /* daniel added this on 2006-04-18 */ + + } + else + { + Digits2Array ( tmpbuf, digits_in, ( len_in + 1 ) / 2 ); + if( len & 0x01 ) + { + pos1 = ( len + 1 ) / 2; + digits_out[pos1 - 1] = ( digits_out[pos1 - 1] & 0x0F ) | ( tmpbuf[len_del] << 4 ); + len_del++; + len_ins++; + } + else + pos1 = len / 2; //victor 2004-10 + tmpbuf[len_in] = filler >> 4; + Array2Digits ( digits_out + pos1, tmpbuf + len_del, len_in - len_del + 1 ); + len = len_in + len_ins - len_del; + + return len_in + len_ins - len_del; + } +} + +BYTE DelDigits ( BYTE * in_digit, BYTE in_len, BYTE * out_digit, BYTE count, BYTE filler ) +{ + return EditDigits ( out_digit, 32, in_digit, in_len, count, NULL, 0, filler ); +} + +void DWORD2BYTE ( BYTE * pdword, BYTE * pbyte, int len ) +{ + int i; + DWORD *p1, *p2; + + for ( i = 0; i < len / 4; i++ ) + { + p1 = ( DWORD * ) ( pdword + 4 * i ); + p2 = ( DWORD * ) ( pbyte + 4 * i ); + *p2 = htonl ( *p1 ); + } +} + +/** + ** @note transfer u32 to byte format\n + ** 0x9872 to 00 00 98 72 + **/ +void u32tobyte(u8 *str,u32 data) +{ + str[0] = data >> 24; + str[1] = data >> 16; + str[2] = data >> 8; + str[3] = data; +} + +/** + ** @note transfer u16 to bcd string format + **/ +u8 u16tobcd(u8 *bcd_string,u16 data) +{ + u8 bcd_len=0; + u8 ii; + u8 flag = 0; + + if (data == 0) + { + bcd_string[0] = 0; + return 1; + } + for (ii = 0;ii < 2;ii ++) + { + bcd_string[bcd_len] = data >> ((1-ii) * 8); + if (bcd_string[bcd_len] != 0 || flag == 1) + { + bcd_len ++; + flag = 1; + } + } + return bcd_len; +} + +/** + ** @note transfer bcd string to u16 format + **/ +u16 bcdtou16(u8 *bcd_string,u8 bcd_len) +{ + u8 ii; + u16 data=0; + + if (bcd_len > 2) + return 0; + data = 0; + for (ii = 0;ii < bcd_len;ii ++) + data += bcd_string[ii] << ((bcd_len-ii-1) * 8); + return data; +} + +/** + ** @note transfer u32 to bcd string format\n + ** 0x9872 to 98 72 and return len=2 + **/ +u8 u32tobcd(u8 *bcd_string,u32 data) +{ + u8 ii; + u8 bcd_len = 0; + u8 temp_data; + + if (data == 0) + { + bcd_string[0] = 0; + return 1; + } + for (ii = 0;ii < 4;ii ++) + { + temp_data = data >> ((3-ii) * 8); +// if (temp_data != 0 || flag == 1) + { + bcd_string[bcd_len++] = temp_data; +// flag = 1; + } + } + return bcd_len; +} + +/** + ** @note transfer bcd string to u32 format + **/ +u32 bcdtou32(u8 *bcd_string,u8 bcd_len) +{ + u8 ii; + u32 data=0; + + if (bcd_len > 4) + return 0; + data = 0; + for (ii = 0;ii < bcd_len;ii ++) + data += bcd_string[ii] << ((bcd_len-ii-1) * 8); + return data; +} +/** @} **/ + + +/* Convert data from ASCII form to right-aligned compact BCD form. */ +void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + + if (len > 0) *bcd_buf = 0x00; + for (i=0; i='a') ch -= 'a' - 10; + else if (ch>='A') ch -= 'A' - 10; + else ch -= '0'; + if ((len - i) & 1) *(bcd_buf++) |= ch & 0x0f; + else *bcd_buf = ch << 4; + } +} + + +/////////////////////////////////////////////////////////////////////////// +// Test +// +/////////////////////////////////////////////////////////////////////////// +/* +//define in pub_log.h +static void MsgToFmtLog ( const u8 * pBcdBuff, int nBcdLen, char *pStrBuff, + int nStrBuffSize ) +{ + int i, len = 0; + int nChar; + + nChar = ( nBcdLen % 8 ) * 3 + ( nBcdLen / 8 ) * 25 + 1; + + WxcAssert ( ( nChar < nStrBuffSize ), "sprint bcd string buffer flow" ); + + for ( i = 1; i <= nBcdLen; i++ ) + { + sprintf ( pStrBuff + len, "%02X ", pBcdBuff[i - 1] ); + len += 3; + if ( 0 == ( i % 16 ) ) + { + strcat ( pStrBuff, "\n" ); + len++; + } + else if ( 0 == ( i % 8 ) ) + { + strcat ( pStrBuff, " " ); + len++; + } + } + if ( 0 != ( len % 50 ) ) + { + strcat ( pStrBuff, "\n" ); + } +} + +//define in pub_log.h +static void ByteBinToStr( char *pDst , const u8 *pSrc , int nByte ) +{ + char tmpStr[2]; + int i , j ; + + *pDst = CNULL; + for( i =0 ; i < nByte ; i++ ) + { + for( j = 7 ; j >= 0 ; j --) + { + sprintf( tmpStr , "%d" , pSrc[i] >>j & 0x01); + strcat( pDst , tmpStr) ; + } + } +} + +int main() +{ + u8 aBcd1[] = { 0x12 , 0x34 , 0x56 , 0x78 }; + u8 aBcd2[] = { 0x01 , 0x23 , 0x45 , 0x67 }; + u8 aBcd1Cp[256]; + u8 aBcd2Cp[256]; + u8 aStr[256]; + char tmpStr1[] = "01234567899876543210"; + char tmpStr2[] = "123456789"; + u64 llTmp1 = 1234567890; + u64 llTmp2 = 123456789; + u8 aDig1[] = { 0x01 , 0x09 , 0x08 , 0x07 , 0x06 }; + u8 aDig2[] = { 0x01 , 0x09 , 0x08 , 0x07 }; + u8 uByte; + int nLen = 0; + + uByte = ReverseByte(aBcd1[1]); + ByteBinToStr( aBcd1Cp , &uByte , 1 ); + ByteBinToStr( aBcd2Cp , &aBcd1[1] , 1 ); + printf("ReverseByte : aBcd1[1] : 0x%x [%s], Result : 0x%x[%s]\n" + , aBcd1[1] , aBcd2Cp , uByte , aBcd1Cp ); + + uByte = ReverseByte(aBcd2[1]); + ByteBinToStr( aBcd1Cp , &uByte , 1 ); + ByteBinToStr( aBcd2Cp , &aBcd2[1], 1 ); + printf("ReverseByte : aBcd2[1] : 0x%x [%s], Result : 0x%x[%s]\n\n" + , aBcd2[1] , aBcd2Cp , uByte , aBcd1Cp ); + + MsgToFmtLog(aBcd1 , 4 , aStr , 256 ); + printf("ReverseBcd : aBcd1: %s " , aStr ); + ReverseBCD(aBcd1Cp, aBcd1 , 4); + MsgToFmtLog(aBcd1Cp , 4 , aStr , 256 ); + printf("Result : %s \n" , aStr ); + + MsgToFmtLog(aBcd2 , 4 , aStr , 256 ); + printf("ReverseBcd : aBcd2: %s " , aStr ); + ReverseBCD(aBcd2Cp, aBcd2 , 4); + MsgToFmtLog(aBcd2Cp , 4 , aStr , 256 ); + printf("Result : %s \n\n" , aStr ); + + + MsgToFmtLog(aBcd1 , 4 , aStr , 256 ); + printf("ReverseArray : aBcd1: %s " , aStr ); + ReverseArray(aBcd1Cp, aBcd1 , 4); + MsgToFmtLog(aBcd1Cp , 4 , aStr , 256 ); + printf("Result : %s \n" , aStr ); + + MsgToFmtLog(aBcd2 , 4 , aStr , 256 ); + printf("ReverseArray : aBcd2: %s " , aStr ); + ReverseArray(aBcd2Cp, aBcd2 , 4); + MsgToFmtLog(aBcd2Cp , 4 , aStr , 256 ); + printf("Result : %s \n\n" , aStr ); + + BcdToStr( aStr , aBcd1 , 4); + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf("BcdToStr : aBcd1 : %s result : %s\n", aBcd2Cp , aStr); + BcdToStr( aStr , aBcd2 , 4); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf("BcdToStr : aBcd2 : %s result : %s\n\n",aBcd2Cp , aStr); + + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf( "BcdToU64 aBcd1 : %s result: %lld \n" , aBcd2Cp , BcdToU64( aBcd1, 4 ) ); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf( "BcdToU64 aBcd2 : %s result: %lld \n\n" , aBcd2Cp ,BcdToU64( aBcd2, 4 ) ); + + nLen = BcdToDig( aBcd1Cp , 256 ,aBcd1 , 4 ); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aBcd1 , sizeof(aBcd1) , aBcd2Cp , 256 ); + printf("BcdToDig :aBcd1 : %s result : %s\n" , aBcd2Cp, aStr ); + + nLen = BcdToDig( aBcd1Cp , 256 , aBcd2 ,sizeof(aBcd2)); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aBcd2 , sizeof(aBcd2) , aBcd2Cp , 256 ); + printf("BcdToDig :aBcd2 : %s result : %s\n\n" , aBcd2Cp,aStr ); + + + nLen = StrToBcd( aBcd1Cp , tmpStr1 , 256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("StrToBcd :tmpStr1 : %s result : %s\n" ,tmpStr1 , aStr); + + nLen = StrToBcd( aBcd1Cp , tmpStr2 , 256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("StrToBcd :tmpStr2 : %s result : %s\n\n" ,tmpStr2 , aStr); + + nLen = U64ToBcd(aBcd1Cp ,llTmp1 ,256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("U64ToBcd :llTmp1 : %lld , result: %s \n" ,llTmp1, aStr ); + + nLen = U64ToBcd(aBcd1Cp ,llTmp2 ,256); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + printf("U64ToBcd :llTmp2 : %lld , result: %s \n\n" ,llTmp2, aStr ); + + nLen = DigToBcd(aBcd1Cp, 256 , aDig1 , sizeof(aDig1)); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aDig1 , sizeof(aDig1) , aBcd2Cp , 256 ); + printf("DigToBcd :aDig1 : %s result: %s \n" ,aBcd2Cp ,aStr ); + + nLen = DigToBcd(aBcd1Cp, 256, aDig2 , sizeof(aDig2) ); + MsgToFmtLog(aBcd1Cp , nLen , aStr , 256 ); + MsgToFmtLog(aDig2 , sizeof(aDig2) , aBcd2Cp , 256 ); + printf("DigToBcd :aDig2 : %s result: %s \n" ,aBcd2Cp , aStr ); + + return 0; +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Test result +// +/////////////////////////////////////////////////////////////////////////// + +/* +ReverseByte : aBcd1[1] : 0x34 [00110100], Result : 0x2c[00101100] +ReverseByte : aBcd2[1] : 0x23 [00100011], Result : 0xc4[11000100] + +ReverseBcd : aBcd1: 12 34 56 78 + Result : 21 43 65 87 + +ReverseBcd : aBcd2: 01 23 45 67 + Result : 10 32 54 76 + + +ReverseArray : aBcd1: 12 34 56 78 + Result : 78 56 34 12 + +ReverseArray : aBcd2: 01 23 45 67 + Result : 67 45 23 01 + + +BcdToStr : aBcd1 : 12 34 56 78 + result : 12345678 +BcdToStr : aBcd2 : 01 23 45 67 + result : 01234567 + +BcdToU64 aBcd1 : 12 34 56 78 + result: 12345678 +BcdToU64 aBcd2 : 01 23 45 67 + result: 1234567 + +BcdToDig :aBcd1 : 12 34 56 78 + result : 01 02 03 04 05 06 07 08 + +BcdToDig :aBcd2 : 01 23 45 67 + result : 00 01 02 03 04 05 06 07 + + +StrToBcd :tmpStr1 : 01234567899876543210 result : 01 23 45 67 89 98 76 54 32 10 + +StrToBcd :tmpStr2 : 123456789 result : 01 23 45 67 89 + + +U64ToBcd :llTmp1 : 1234567890 , result: 12 34 56 78 90 + +U64ToBcd :llTmp2 : 123456789 , result: 01 23 45 67 89 + + +DigToBcd :aDig1 : 01 09 08 07 06 + result: 01 98 76 + +DigToBcd :aDig2 : 01 09 08 07 + result: 19 87 + +*/ diff --git a/omc/plat/public_bak/src/pub_inet.c b/omc/plat/public_bak/src/pub_inet.c new file mode 100644 index 0000000..267bead --- /dev/null +++ b/omc/plat/public_bak/src/pub_inet.c @@ -0,0 +1,342 @@ +////////////////////////////////////////////////// +//Title : pub_inet.c +//Auhtor : Liu Wei +//Desc : public inet function implementation +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_inet.h" +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// +extern int GetNetIfInfo ( IfAddr * pIfAddr ) +{ + int fd; + struct ifreq buf[MAXINTERFACES]; + struct arpreq arp; + struct ifconf ifc; + + pIfAddr->uIfNum = 0; + + if ( ( fd = socket ( AF_INET, SOCK_DGRAM, 0 ) ) >= 0 ) + { + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = ( caddr_t ) buf; + if ( !ioctl ( fd, SIOCGIFCONF, ( char * ) &ifc ) ) + { + int i; + + pIfAddr->uIfNum = ifc.ifc_len / sizeof ( struct ifreq ); + pIfAddr->uIfNum = pIfAddr->uIfNum % MAXINTERFACES; + for ( i = 0; i < pIfAddr->uIfNum; i++ ) + { + ioctl ( fd, SIOCGIFFLAGS, ( char * ) &buf[i] ); + pIfAddr->tIfEntity[i].uIfState = buf[i].ifr_flags & IFF_UP; + if ( !( ioctl ( fd, SIOCGIFADDR, ( char * ) &buf[i] ) ) ) + { + pIfAddr->tIfEntity[i].dIfIP = ( ( struct sockaddr_in * ) + ( &buf[i].ifr_addr ) )-> + sin_addr.s_addr; + } + } + } + + } + close ( fd ); + return pIfAddr->uIfNum; +} + +u32 GetLocalIP ( ) +{ + struct hostent *host; + struct in_addr *hostip_addr; + char name[100]; + + gethostname ( name, 24 ); + host = gethostbyname ( name ); + + WxcAssert ( NULL != host, "Get Local IP failed" ); + + hostip_addr = ( struct in_addr * ) ( *host->h_addr_list ); + return hostip_addr->s_addr; +} + +/////////////////////////////////////////////////////////////////////////// +// Inet If Address infomation interface +/////////////////////////////////////////////////////////////////////////// + +//校验和算法 +static u16 IcmpCheckSum ( u16 * addr, int len ) +{ + int nleft = len; + int sum = 0; + u16 *w = addr; + u16 answer = 0; + + //把ICMP报头二进制数据以2字节为单位累加起来 + while ( nleft > 1 ) + { + sum += *w++; + nleft -= 2; + } + + //若ICMP报头为奇数个字节,会剩下最后一字节。 + //把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加 + if ( nleft == 1 ) + { + *( unsigned char * ) ( &answer ) = *( unsigned char * ) w; + sum += answer; + } + + sum = ( sum >> 16 ) + ( sum & 0xffff ); + sum += ( sum >> 16 ); + answer = ~sum; + + return answer; +} + +//设置ICMP报头 +static int IcmpPacking ( IcmpSrv * pIS ) +{ + int i, packsize; + struct icmp *icmp; + struct timeval *tval; + + icmp = ( struct icmp * ) pIS->aSendBuff; + icmp->icmp_type = ICMP_ECHO; + icmp->icmp_code = 0; + icmp->icmp_cksum = 0; + icmp->icmp_seq = pIS->nPackNumSend; + icmp->icmp_id = pIS->tPid; + packsize = 8 + pIS->uDataLen; + + //记录发送时间 + tval = ( struct timeval * ) icmp->icmp_data; + gettimeofday ( tval, NULL ); + + icmp->icmp_cksum = IcmpCheckSum ( ( u16 * ) icmp, packsize ); + + return packsize; +} + +//剥去ICMP报头 +static int IcmpUnPack ( u8 * buf, int len, IcmpSrv * pIS ) +{ + int i, nIpHdrLen; + struct ip *pIP; + struct icmp *icmp; + struct timeval *tvSend; + struct timeval tvRecv; + double rtt; + + gettimeofday ( &tvRecv, NULL ); + pIP = ( struct ip * ) buf; + //求ip报头长度,即ip报头的长度标志乘4 + nIpHdrLen = pIP->ip_hl << 2; + + //越过ip报头,指向ICMP报头 + icmp = ( struct icmp * ) ( buf + nIpHdrLen ); + + //ICMP报头及ICMP数据报的总长度 + len -= nIpHdrLen; + + if ( len < 8 ) + //小于ICMP报头长度则不合理 + { + printf ( "ICMP packets's length is less than 8 " ); + return 0; + } + + //确保所接收的是我所发的的ICMP的回应 + if ( ( icmp->icmp_type == ICMP_ECHOREPLY ) + && ( icmp->icmp_id == pIS->tPid ) ) + { + tvSend = ( struct timeval * ) icmp->icmp_data; + + rtt = ( tvRecv.tv_sec * 1000 + tvRecv.tv_usec / 1000 ) - + ( tvSend->tv_sec * 1000 + tvSend->tv_usec / 1000 ); + + printf ( "%d byte from %s: icmp_seq=%u ttl=%d rtt=%.3f ms \n", len, + inet_ntoa ( pIS->tFromAddr.sin_addr ), icmp->icmp_seq, + pIP->ip_ttl, rtt ); + return 1; + } + return 0; +} + +static void IcmpStatis ( IcmpSrv * pIS ) +{ + int nSend, nRecv; + + nSend = pIS->nPackNumSend; + nRecv = pIS->nPackNumRecv; + + printf ( " --------------------PING statistics------------------- \n" ); + printf ( "%d packets transmitted, %d received , %%%d lost \n\n", nSend, + nRecv, ( nSend - nRecv ) / nSend * 100 ); + close ( pIS->wSockfd ); + pIS->uSrvState = 0; +} + +//发送三个ICMP报文 +static int IcmpSend ( IcmpSrv * pIS ) +{ + int nSize; + + if ( pIS->nPackNumSend < MAX_NO_PACKETS ) + { + pIS->nPackNumSend++; + nSize = IcmpPacking ( pIS ); + + //设置ICMP报头 + if ( sendto ( pIS->wSockfd, pIS->aSendBuff, nSize, 0, + ( struct sockaddr * ) &pIS->tToAddr, + sizeof ( pIS->tToAddr ) ) < 0 ) + { + perror ( "sendto error" ); + return 0; + } + printf ( "[IcmpSend] : Send icmp Pack %d \n", pIS->nPackNumSend ); + return 1; + } + return 0; +} + +//接收所有ICMP报文 +static void IcmpRecv ( IcmpSrv * pIS ) +{ + int n, fromlen; + extern int errno; + + fromlen = sizeof ( pIS->tFromAddr ); + while ( pIS->nPackNumRecv < pIS->nPackNumSend ) + { + if ( ( n = + recvfrom ( pIS->wSockfd, pIS->aRecvBuff, + sizeof ( pIS->aRecvBuff ), 0, + ( struct sockaddr * ) &pIS->tFromAddr, + &fromlen ) ) < 0 ) + + { + if ( errno == EINTR ) + continue; + perror ( "recvfrom error" ); + continue; + } + if ( IcmpUnPack ( pIS->aRecvBuff, n, pIS ) == -1 ) + continue; + pIS->nPackNumRecv++; + } +} + +extern int PingInit ( IcmpSrv * pIS, int nDataLen ) +{ + memset ( pIS, 0, sizeof ( IcmpSrv ) ); + pIS->uSrvState = 0; + + pIS->uDataLen = 56; + + if ( ( pIS->pProtoent = getprotobyname ( "icmp" ) ) == NULL ) + { + perror ( "getprotobyname" ); + exit ( 1 ); + } + + // 回收root权限,设置当前用户权限 + setuid ( getuid ( ) ); + + //获取main的进程id,用于设置ICMP的标志符 + pIS->tPid = getpid ( ); + +} + +extern int PingStart ( IcmpSrv * pIS, char *sIP, PingCallBack fCallBack ) +{ + int nSize; + struct hostent *pHost; + + //struct in_addr *pInAddr; + u32 nInetAddr; + + if ( pIS->uSrvState ) + { + return 0; + } + + pIS->fCallBack = fCallBack; + + //生成使用ICMP的原始套接字,这种套接字只有root才能生成 + if ( ( pIS->wSockfd = + socket ( AF_INET, SOCK_RAW, pIS->pProtoent->p_proto ) ) < 0 ) + { + perror ( "socket error" ); + exit ( 1 ); + } + + //扩大套接字接收缓冲区到50K这样做主要为了减小接收缓冲区溢出的 + //的可能性, 若无意中ping会引来大量应答 + setsockopt ( pIS->wSockfd, SOL_SOCKET, SO_RCVBUF, &nSize, + sizeof ( nSize ) ); + bzero ( &pIS->tToAddr, sizeof ( pIS->tToAddr ) ); + pIS->tToAddr.sin_family = AF_INET; + + //判断是主机名还是ip地址 + nInetAddr = inet_addr ( sIP ); + if ( nInetAddr == INADDR_NONE ) + { + if ( ( pHost = gethostbyname ( sIP ) ) == NULL ) //是主机名 + { + perror ( "gethostbyname error" ); + exit ( 1 ); + } + memcpy ( ( char * ) &pIS->tToAddr.sin_addr, pHost->h_addr, + pHost->h_length ); + } + else //是ip地址 + { + pIS->tToAddr.sin_addr.s_addr = nInetAddr; + //memcpy( (char *)&pIS->tToAddr,(char *)&nInetAddr,host->h_length); + } + printf ( "PING %s(%s): %d bytes data in ICMP packets. \n", sIP, + inet_ntoa ( pIS->tToAddr.sin_addr ), pIS->uDataLen ); + + pIS->uSrvState = 1; + pIS->uIcmpState = 1; + +} + +extern int PingTimer ( IcmpSrv * pIS ) +{ + if ( pIS->uSrvState ) + { + IcmpRecv ( pIS ); + switch ( pIS->uIcmpState ) + { + case 1: + case 2: + case 3: + IcmpSend ( pIS ); + pIS->uIcmpState++; + break; + default: + if ( pIS->nPackNumRecv >= 3 ) + { + IcmpStatis ( pIS ); + pIS->fCallBack ( 1 ); + } + if ( pIS->uIcmpState++ > 200 ) + { + IcmpStatis ( pIS ); + pIS->fCallBack ( 0 ); + } + break; + } + } +} +/*@end@*/ + diff --git a/omc/plat/public_bak/src/pub_log.c b/omc/plat/public_bak/src/pub_log.c new file mode 100644 index 0000000..73e6b99 --- /dev/null +++ b/omc/plat/public_bak/src/pub_log.c @@ -0,0 +1,135 @@ +////////////////////////////////////////////////// +//Title : pub_log.c +//Auhtor : Liu Wei +//Desc : public output log implementation +//Created : 2007-05-21 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#include "./include/pub_log.h" + +void FLogMsg( u8 LogMask , const char *pFmt, ...) +{ + va_list ap; + + va_start(ap, pFmt); + switch( LogMask ) + { + case PIF_INFO: + break; + case PIF_WARN: + break; + case PIF_GERR: + break; + case PIF_CERR: + break; + case PIF_DBG: + break; + case PIF_UNKN: + break; + case PIF_DEFAULT: + break; + case PIF_ALL: + break; + default: + break; + } + printf(pFmt, ap); + va_end(ap); + return; +} + +char *ByteBinToStr( char *pDst , const u8 *pSrc , int nByte ) +{ + register int i , j , k = 0; + + for( i =0 ; i < nByte ; i++ ) + { + for( j = 7 ; j >= 0 ; j --) + { + pDst[k++] = (pSrc[i] >>j & 0x01) + '0'; + } + } + pDst[k++] = CNULL; + return pDst; +} + +inline char *TxtColor ( int nAttr, int nFg, int nBg, char *pStr ) +{ + register int nPos ; + int nLen = strlen(pStr); + char *p = strdup (pStr); + + nPos = 0; + pStr[nPos++] = 27; + pStr[nPos++] = '['; + pStr[nPos++] = nAttr + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 3 + '0'; + pStr[nPos++] = nFg + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 4 + '0'; + pStr[nPos++] = nBg + '0'; + pStr[nPos++] = 'm'; + strcpy( pStr + nPos , p); + nPos += nLen; + pStr[nPos++] = 27; + pStr[nPos++] = '['; + pStr[nPos++] = RESET + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 3 + '0'; + pStr[nPos++] = WHITE + '0'; + pStr[nPos++] = ';'; + pStr[nPos++] = 4 + '0'; + pStr[nPos++] = BLACK + '0'; + pStr[nPos++] = 'm'; + pStr[nPos] = CNULL; + + free(p); + return pStr; +} + + + +inline int MsgToFmtLog ( const BYTE * pBcd, int nBcdLen, char *pStr, int nStrBuffSize ) +{ + register int i, len = 0; + int nChar; + + nChar = ( nBcdLen / 16 ) * 49; + if( (nBcdLen %16) > 8 ) + { + nChar+=8*3 +1; + + } + nChar += (nBcdLen %8)*3 +1 + 2 ; //add "\r\n" at end + + WxcAssert ( ( nChar < nStrBuffSize ), "sprint bcd string buffer flow" ); + + for ( i = 0; i <= nBcdLen-1; i++ ) + { + pStr[len++] = HexToCh(pBcd[i] >> 4 ); + pStr[len++] = HexToCh(pBcd[i] & 0x0F); + pStr[len++] = ' '; + if ( 0 == ( (i+1) % 16 ) && i) + { + pStr[len++] = '\n'; + } + else if ( 0 == ( (i+1) % 8 ) ) + { + pStr[len++] = ' '; + } + } + if ( 0 != ( len % 49 ) ) + { + pStr[len++] = ' '; + } + pStr[len++] = '\r'; + pStr[len++] = '\n'; + pStr[len++] = CNULL; + return len; +} diff --git a/omc/plat/public_bak/src/pub_malloc.c b/omc/plat/public_bak/src/pub_malloc.c new file mode 100644 index 0000000..735e3ec --- /dev/null +++ b/omc/plat/public_bak/src/pub_malloc.c @@ -0,0 +1,23 @@ +////////////////////////////////////////////////// +//Title : wxc_malloc.c +//Auhtor : Liu Wei +//Desc : WXC2 Public heap memery management +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_malloc.h" +/* +void *WxcMalloc ( ) +{ + return (void*)NULL; +} + +void WxcFree ( ) +{ + +} +*/ diff --git a/omc/plat/public_bak/src/pub_netcap.c b/omc/plat/public_bak/src/pub_netcap.c new file mode 100644 index 0000000..b89b07b --- /dev/null +++ b/omc/plat/public_bak/src/pub_netcap.c @@ -0,0 +1,370 @@ +////////////////////////////////////////////////// +//Title : wxc_netcap.c +//Auhtor : Liu Wei +//Desc : wxc2 netcap implementation +//Created : 2007-06-05 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_netcap.h" + +/*@ignore@*/ +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif + +static NetCap tNC; + +#define BASE 65521 + +static u32 NcAd32 ( u32 ad, u8 * buf, int len ) +{ + u32 s1 = ad & 0xffff; + u32 s2 = ( ad >> 16 ) & 0xffff; + int n; + + for ( n = 0; n < len; n++, buf++ ) + { + s1 = ( s1 + *buf ); + + if ( s1 >= BASE ) + s1 -= BASE; + + s2 = ( s2 + s1 ); + + if ( s2 >= BASE ) + { + + s2 -= BASE; + } + } + return ( s2 << 16 ) + s1; +} + +#define HEADER_LEN 12 + +static u32 NcCS ( u8 * ptr, u16 count ) +{ + + u32 ad = 1L; + u32 zero = 0L; + + ad = NcAd32 ( ad, ptr, sizeof ( HEADER_LEN - sizeof ( u32 ) ) ); + ad = NcAd32 ( ad, ( u8 * ) & zero, sizeof ( u32 ) ); + ptr += HEADER_LEN; + count -= HEADER_LEN; + + ad = NcAd32 ( ad, ptr, count ); + return ad; +} + +static int NcGetSocket ( u32 port ) +{ + int nSock; + int nOn = 1; + unsigned long 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 ( ( nSock = socket ( AF_INET, SOCK_RAW, IPPROTO_SCTP ) ) < 0 ) + { + perror ( "Get SCTP socket error " ); + return -1; + } + + setsockopt ( nSock, SOL_SOCKET, SO_REUSEADDR, &nOn, sizeof ( nOn ) ); + + ioctl ( nSock, FIONBIO, &cmdarg ); + + return ( nSock ); +} + +extern void NcSetPort ( u32 port ) +{ + tNC.nPort = port; +} + +extern void NcSetIP ( u32 ip ) +{ + tNC.nDstIp = ip; +} + +extern int NcInit ( ) +{ + memset ( &tNC, 0, sizeof ( NetCap ) ); + tNC.nPort = 8000; + tNC.nDstIp = inet_addr ( "172.54.240.3" ); + return 1; +} + +extern int NcStart ( u32 wIP, u32 wPort ) +{ + if ( tNC.uState ) + return 0; + tNC.nDstIp = wIP ? wIP : tNC.nDstIp; + tNC.nPort = wPort ? wPort : tNC.nPort; + tNC.nSock = NcGetSocket ( tNC.nPort ); + tNC.uState = 1; + return 1; +} + +extern int NcStop ( ) +{ + shutdown ( tNC.nSock, 2 ); + tNC.uState = 0; + return 1; +} + +#define SCTP_HEADER_LEN 0x1C + +#define SCCTP_CS_POS 0x08 + +#define SCTP_CHUNKLEN_POS 15 + +static u8 SCTP_HEADER[] = { + 0x13, 0x56, 0x13, 0x56, 0x00, 0x00, 0x2d, 0xd1, + 0x05, 0x67, 0x59, 0x7a, 0x00, 0x00, 0x00, 0x3c, + 0x00, 0x00, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x02 +}; + +static int NcStuffSCTP ( u8 * pIPBuff ) +{ + memcpy ( pIPBuff, SCTP_HEADER, SCTP_HEADER_LEN ); + pIPBuff[0] = 4950 >> 8; + pIPBuff[1] = 4950 & 0xFF; + pIPBuff[2] = tNC.nPort >> 8; + pIPBuff[3] = tNC.nPort & 0xFF; + return SCTP_HEADER_LEN; +} + +#define M2UA_HEADER_LEN 0x14 + +#define M2UA_MSGLEN_POS 0x07 + +#define M2UA_PARALEN_POS 0x13 + +static inline int NcGetM2uaParaLen ( u32 wMtp3Len ) +{ + return ( wMtp3Len + 4 ); +} + +static inline int NcGetM2uaMsgLen ( u32 wMtp3Len ) +{ + return ( NcGetM2uaParaLen ( wMtp3Len ) + 16 ); +} + +static u8 M2UA_HEADER[] = { + 0x01, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x2c, + 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x1c +}; + +int NcStuffM2UA ( u8 * pIPBuff, u32 wMtp3Len ) +{ + memcpy ( pIPBuff, M2UA_HEADER, M2UA_HEADER_LEN ); + *( pIPBuff + M2UA_PARALEN_POS ) = NcGetM2uaParaLen ( wMtp3Len ); + *( pIPBuff + M2UA_MSGLEN_POS ) = NcGetM2uaMsgLen ( wMtp3Len ); + return M2UA_HEADER_LEN; +} + +#define MTP3_HAEDER_ANSI_LEN 0x08 + +static u8 MTP3_HEADER_ANSI[] = { + 0x83, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 +}; + +#define MTP3_HAEDER_ITU_LEN 0x05 + +static u8 MTP3_HEADER_ITU[] = { + 0x83, 0x20, 0x00, 0x08, 0x00 +}; + +static int NcStuffMtp3 ( u8 * pIPBuff, u32 wDPC, u32 wOPC, u8 uSLS, + u8 uAnsiFlag ) +{ + u32 MTP3_HAEDER_LEN; + u8 *MTP3_HEADER; + + //printf ( "stuff mtp3 : dpc :%ld opc :%ld sls: %d , ansi :%d \n", wDPC, wOPC, + // uSLS, uAnsiFlag ); + if ( uAnsiFlag ) + { + MTP3_HEADER_ANSI[1] = wDPC ? MTP3_HEADER_ANSI[1] : wDPC; + MTP3_HEADER_ANSI[4] = wOPC ? MTP3_HEADER_ANSI[4] : wOPC; + MTP3_HEADER_ANSI[7] = uSLS ? MTP3_HEADER_ANSI[7] : uSLS; + } + else + { + if ( wDPC ) + { + MTP3_HEADER_ITU[1] = wDPC & 0xFF; + MTP3_HEADER_ITU[2] &= 0xC0; + MTP3_HEADER_ITU[2] |= ( wDPC >> 8 ) & 0x3F; + } + if ( wOPC ) + { + MTP3_HEADER_ITU[2] &= 0x3F; + MTP3_HEADER_ITU[2] |= ( wDPC & 0x03 ) << 6; + MTP3_HEADER_ITU[3] = wDPC >> 2; + MTP3_HEADER_ITU[4] &= 0xF0; + MTP3_HEADER_ITU[4] |= wOPC >> 10; + } + + MTP3_HEADER_ITU[4] &= 0x0F; + MTP3_HEADER_ITU[4] |= uSLS << 4; + } + + MTP3_HEADER = uAnsiFlag ? MTP3_HEADER_ANSI : MTP3_HEADER_ITU; + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + + memcpy ( pIPBuff, MTP3_HEADER, MTP3_HAEDER_LEN ); + return MTP3_HAEDER_LEN; +} + +extern void NcMtp3Send ( u8 * pMtp3Msg, u32 wMtp3Len, u8 uAnsiFlag ) +{ + u8 IPBuff[512]; + u32 wPackLen = 0; + u32 wM2uaLen = 0; + u32 ad = 0; + u32 MTP3_HAEDER_LEN; + u8 uPad = 0; + struct sockaddr_in sin_addr; + + memset ( IPBuff, 0, 512 * sizeof ( u8 ) ); + wPackLen += NcStuffSCTP ( IPBuff + wPackLen ); + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + wM2uaLen = NcStuffM2UA ( IPBuff + wPackLen, wMtp3Len ); + wPackLen += wM2uaLen; + memcpy ( IPBuff + wPackLen, pMtp3Msg, wMtp3Len ); + wPackLen += wMtp3Len; + + uPad = ( IPBuff[SCTP_HEADER_LEN + 7] ) % 4; + uPad = uPad ? ( 4 - uPad ) : 0; + + for ( ; uPad > 0; uPad-- ) + { + IPBuff[SCTP_HEADER_LEN + 7]++; //m2ua msg len + IPBuff[wPackLen++] = 0x00; + } + + IPBuff[SCTP_CHUNKLEN_POS] = 0x10 + IPBuff[SCTP_HEADER_LEN + 7]; + + ad = NcCS ( IPBuff, wPackLen ); + IPBuff[SCCTP_CS_POS] = ad & 0xFF; + IPBuff[SCCTP_CS_POS + 1] = ad / ( 256 ); + IPBuff[SCCTP_CS_POS + 2] = ad / ( 256 * 256 ); + IPBuff[SCCTP_CS_POS + 3] = ad / ( 256 * 256 * 256 ); + + sin_addr.sin_family = AF_INET; + sin_addr.sin_port = htons ( tNC.nPort ); + sin_addr.sin_addr.s_addr = tNC.nDstIp; + + sendto ( tNC.nSock, ( char * ) IPBuff, wPackLen, 0, + ( struct sockaddr * ) &sin_addr, sizeof ( struct sockaddr ) ); + //printf ( "\nMTP3 Send Net cap message!\n " ); +} + +typedef struct WXC_NETCAP_SCCP_INTRA_MESSAGE +{ + u8 msgsource; + u8 msgtype; + u8 msgclass; + u8 msgMNP; + int OPC; + int DPC; + u8 SLS; +} +Wxc_NCSccpIntra; + +extern int NcSccpSend ( u8 * pSccpMsg, u32 wSccpLen, u8 * pIntraMsg, + BYTE uAnsiFlag ) +{ + u8 IPBuff[512]; + u32 wPackLen = 0; + u32 wM2uaLen = 0; + u32 ad = 0; + u8 uPad = 0; + u32 MTP3_HAEDER_LEN; + struct sockaddr_in sin_addr; + Wxc_NCSccpIntra *pIntra = ( Wxc_NCSccpIntra * ) pIntraMsg; + + memset ( IPBuff, 0, 512 * sizeof ( u8 ) ); + wPackLen += NcStuffSCTP ( IPBuff + wPackLen ); + MTP3_HAEDER_LEN = uAnsiFlag ? MTP3_HAEDER_ANSI_LEN : MTP3_HAEDER_ITU_LEN; + wM2uaLen = NcStuffM2UA ( IPBuff + wPackLen, wSccpLen + MTP3_HAEDER_LEN ); + wPackLen += wM2uaLen; + + wPackLen += + NcStuffMtp3 ( IPBuff + wPackLen, pIntra->DPC, pIntra->DPC, pIntra->SLS, + uAnsiFlag ); + memcpy ( IPBuff + wPackLen, pSccpMsg, wSccpLen ); + wPackLen += wSccpLen; + + uPad = ( IPBuff[SCTP_HEADER_LEN + 7] ) % 4; + uPad = uPad ? ( 4 - uPad ) : 0; + + for ( ; uPad > 0; uPad-- ) + { + IPBuff[SCTP_HEADER_LEN + 7]++; //m2ua msg len + IPBuff[wPackLen++] = 0x00; + } + + IPBuff[SCTP_CHUNKLEN_POS] = 0x10 + IPBuff[SCTP_HEADER_LEN + 7]; + + ad = NcCS ( IPBuff, wPackLen ); + + IPBuff[SCCTP_CS_POS] = ad & 0xFF; + IPBuff[SCCTP_CS_POS + 1] = ad / ( 256 ); + IPBuff[SCCTP_CS_POS + 2] = ad / ( 256 * 256 ); + IPBuff[SCCTP_CS_POS + 3] = ad / ( 256 * 256 * 256 ); + + sin_addr.sin_family = AF_INET; + sin_addr.sin_port = htons ( tNC.nPort ); + sin_addr.sin_addr.s_addr = tNC.nDstIp; + + if ( sendto + ( tNC.nSock, ( char * ) IPBuff, wPackLen, 0, + ( struct sockaddr * ) &sin_addr, sizeof ( struct sockaddr ) ) < 0 ) + { + perror ( "SCCP send tNC error!\n" ); + return 0; + } + + //printf ( "\nSCCP Send Net cap message!\n " ); + //write(nSock, IPBuff, wPackLen); + return 1; +} + +/* + #define SCCP_RLSE_LEN 0x0a + + static u8 SCCP_RLSD[ ] = + { + 0x04, 0x01, 0x04, 0x00, 0x00, 0x00, 0x74, 0x00, 0x01, + 0x00 + }; + + void main() + { + int i; + + NcInit(); + NcStart(inet_addr("10.167.144.35") , 8000 ); + for( i = 0 ; i < 5000 ; i ++ ) + { + sleep(1); + NcSccpSend( SCCP_RLSD , SCCP_RLSE_LEN ); + } + NcStop(); + return ; + } + */ +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_sdp.c b/omc/plat/public_bak/src/pub_sdp.c new file mode 100644 index 0000000..9061fdf --- /dev/null +++ b/omc/plat/public_bak/src/pub_sdp.c @@ -0,0 +1,1563 @@ +#include "./include/public.h" +#include "./include/pub_sdp.h" + +/*@ignore@*/ +void pub_replace_all_lws(char *msg) +{ + char *tmp; + + if (msg == NULL) + return; + tmp = msg; + + for (; tmp[0] != '\0'; tmp++) + { + if (('\0' == tmp[0]) || ('\0' == tmp[1]) || + ('\0' == tmp[2]) || ('\0' == tmp[3])) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ('\r' == tmp[2]) && ('\n' == tmp[3])) || + (('\r' == tmp[0]) && ('\r' == tmp[1])) || + (('\n' == tmp[0]) && ('\n' == tmp[1]))) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ((' ' == tmp[2]) || ('\t' == tmp[2]))) || + (('\r' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1]))) || + (('\n' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1])))) + { + // Replace line end and TAB symbols by SP + tmp[0] = ' '; + tmp[1] = ' '; + tmp = tmp + 2; + // Replace all following TAB symbols + for (; ('\t' == tmp[0] || ' ' == tmp[0]); ) + { + tmp[0] = ' '; + tmp++; + } + } + } +} + +char *pub_strncpy(char *dest, const char *src, WORD length) +{ + strncpy(dest, src, length); + dest[length] = '\0'; + return dest; +} + +int pub_set_next_token(char *dest, char *buf, int endSeparator, char **next) +{ + char *sep; // separator + + *next = NULL; + + sep = buf; + while ((*sep != endSeparator) && (*sep != '\0') && (*sep != '\r') + && (*sep != '\n')) + sep++; + if ((*sep == '\r') || (*sep == '\n')) + { // we should continue normally only if this is the separator asked! + if (*sep != endSeparator) + return -1; + } + if (*sep == '\0') + return -1; // value must not end with this separator! + if (sep == buf) + return -1; // empty value (or several space!) + + pub_strncpy(dest, buf, sep - buf); + + *next = sep + 1; // return the position right after the separator + + return 0; +} + +int pub_sdp_msg_init(PUB_SDP_MSG *sdp) +{ + if (sdp == NULL) + return -1; + + memset((BYTE *)sdp, 0, sizeof(PUB_SDP_MSG)); + + return 0; +} + +int pub_sdp_net_type_conv(char *str, BYTE *netType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "IN", 2) == 0) + *netType = PUB_SDP_NET_TYPE_IN; + return 0; + } + else + { + switch (*netType) + { + case PUB_SDP_NET_TYPE_IN: + strcpy(str, "IN"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_addr_type_conv(char *str, BYTE *addrType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "IP4", 3) == 0) + *addrType = PUB_SDP_ADDR_TYPE_IPV4; + return 0; + } + else + { + switch (*addrType) + { + case PUB_SDP_ADDR_TYPE_IPV4: + strcpy(str, "IP4"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_attr_type_conv(char *str, BYTE *attrType, BYTE flag) +{ + int ret = 0; + + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "rtpmap", 6) == 0) + *attrType = PUB_SDP_ATTR_TYPE_RTPMAP; + else if (strncmp(str, "ptime", 5) == 0) + *attrType = PUB_SDP_ATTR_TYPE_PTIME; + else if (strncmp(str, "fmtp", 4) == 0) + *attrType = PUB_SDP_ATTR_TYPE_FMTP; + else + { + ret = -2; + } + return ret; + } + else + { + switch (*attrType) + { + case PUB_SDP_ATTR_TYPE_RTPMAP: + strcpy(str, "rtpmap"); + break; + case PUB_SDP_ATTR_TYPE_PTIME: + strcpy(str, "ptime"); + break; + case PUB_SDP_ATTR_TYPE_FMTP: + strcpy(str, "fmtp"); + break; + default: + return -2; + } + return 0; + } + + return -1; +} + +int pub_sdp_media_type_conv(char *str, BYTE *mediaType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "audio", 6) == 0) + { + *mediaType = PUB_SDP_MEDIA_TYPE_AUDIO; + return 0; + } + else + return -2; + } + else + { + switch (*mediaType) + { + case PUB_SDP_MEDIA_TYPE_AUDIO: + strcpy(str, "audio"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_proto_type_conv(char *str, BYTE *protoType, BYTE flag) +{ + if (flag == PUB_SDP_STR_TO_API) + { + if (strncmp(str, "RTP/AVP", 7) == 0) + *protoType = PUB_SDP_PROTO_TYPE_RTP_AVP; + return 0; + } + else + { + switch (*protoType) + { + case PUB_SDP_PROTO_TYPE_RTP_AVP: + strcpy(str, "RTP/AVP"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int pub_sdp_parse_v(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char value[8]; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + if (equal == buf) + return -1; + + // check if header is "v" + if (equal[-1] != 'v') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + pub_strncpy(value, equal + 1, crlf - (equal + 1)); + sdp->v.value = atoi(value); + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("v: %d\n", sdp->v.value); + + sdp->flag |= PUB_SDP_FLAG_V; + + return 0; +} + +int pub_sdp_parse_o(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + int i; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "o" + if (equal[-1] != 'o') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* o=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + tmp = equal + 1; + // o=username sess-id sess-version nettype addrtype addr + // useranme can contain any char (ascii) except "space" and CRLF + if (pub_set_next_token(sdp->o.userName, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // sess_id contains only numeric characters + if (pub_set_next_token(sdp->o.sessId, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // sess_version contains only numeric characters + if (pub_set_next_token (sdp->o.sessVer, tmp, ' ', &tmpNext) < 0) + return -1; + tmp = tmpNext; + + // nettype is "IN" but will surely be extented!!! assume it's some alpha-char + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_net_type_conv(value, &sdp->o.netType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // addrtype is "IP4" or "IP6" but will surely be extented!!! + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_addr_type_conv(value, &sdp->o.addrType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // addr is "IP4" or "IP6" but will surely be extented!!! + i = pub_set_next_token(sdp->o.addr, tmp, '\r', &tmpNext); + if (i != 0) + { /* could it be "\n" only??? rfc says to accept CR or LF instead of CRLF */ + if (pub_set_next_token(sdp->o.addr, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("o: %s, %s, %s, %d, %d, %s\n", sdp->o.userName, sdp->o.sessId, sdp->o.sessVer, sdp->o.netType, sdp->o.addrType, sdp->o.addr); + + sdp->flag |= PUB_SDP_FLAG_O; + + return 0; +} + +int pub_sdp_parse_s(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "s" + if (equal[-1] != 's') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // o=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_S) == PUB_SDP_FLAG_S) + pub_strncpy(sdp->s.sessName, equal + 1, crlf - (equal + 1)); + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("s: %s\n", sdp->s.sessName); + + sdp->flag |= PUB_SDP_FLAG_S; + + return 0; +} + +int pub_sdp_parse_i(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "i" + if (equal[-1] != 'i') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // o=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_I) == PUB_SDP_FLAG_I) + pub_strncpy(sdp->i.info, equal + 1, crlf - (equal + 1)); + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("i: %s\n", sdp->i.info); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_I; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_I; + + return 0; +} + +int pub_sdp_parse_u(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "u" + if (equal[-1] != 'u') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_e(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "e" + if (equal[-1] != 'e') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_p(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "p" + if (equal[-1] != 'p') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_c(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + char *slash; + PUB_SDP_C *cHeader; + int i; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "c" + if (equal[-1] != 'c') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // c=\r ?? bad header + + if ((flag & PUB_SDP_FLAG_C) == PUB_SDP_FLAG_C) + { + tmp = equal + 1; + + // c=nettype addrtype (multicastaddr | addr) + + // nettype is "IN" and will be extended + if (pub_set_next_token (value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_net_type_conv(value, &sdp->c.netType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + // nettype is "IP4" or "IP6" and will be extended + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_addr_type_conv(value, &sdp->c.addrType, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + /* there we have a multicast or unicast address */ + /* multicast can be ip/ttl [/integer] */ + /* unicast is FQDN or ip (no ttl, no integer) */ + + slash = strchr (tmp, '/'); + cHeader = &sdp->c; + + if (slash != NULL && slash < crlf) // it's a multicast address! + { + // Not supported for the moment + } + else + { + // in this case, we have a unicast address + i = pub_set_next_token(cHeader->addr, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(cHeader->addr, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("c: %d, %d, %s\n", sdp->c.netType, sdp->c.addrType, sdp->c.addr); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_C; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_C; + + return 0; +} + +int pub_sdp_parse_b(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "b" + if (equal[-1] != 'b') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_t(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[16]; + int i; + PUB_SDP_T *tHeader; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "t" + if (equal[-1] != 't') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* t=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_T) == PUB_SDP_FLAG_T) + { + tmp = equal + 1; + // t = start_time stop_time + tHeader = &sdp->t; + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + tHeader->startTime = atoi(value); + tmp = tmpNext; + + i = pub_set_next_token(value, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(value, tmp, '\n', &tmpNext) < 0) + return -1; + tHeader->stopTime = atoi(value); + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("t: %ld, %ld\n", sdp->t.startTime, sdp->t.stopTime); + + sdp->flag |= PUB_SDP_FLAG_T; + + return 0; +} + +int pub_sdp_parse_r(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "r" + if (equal[-1] != 'r') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_z(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "z" + if (equal[-1] != 'z') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_k(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "k" + if (equal[-1] != 'k') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; // v=\r ?? bad header + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; +} + +int pub_sdp_parse_a(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[32]; + int i, ret; + BYTE num, mediaNum; + PUB_SDP_A *a; + char *colon; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "a" + if (equal[-1] != 'a') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* a=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + tmp = equal + 1; + mediaNum = sdp->medias.num; + num = sdp->medias.medias[mediaNum - 1].attrs.num; + a = &sdp->medias.medias[mediaNum - 1].attrs.attrs[num]; + + // a=att-field[:att-value] + + // is there any att-value? + colon = strchr (equal + 1, ':'); + if ((colon != NULL) && (colon < crlf)) + { + // att-field is alpha-numeric + if (pub_set_next_token(value, tmp, ':', &tmpNext) < 0) + return -1; + if ((ret = pub_sdp_attr_type_conv(value, &a->aType, PUB_SDP_STR_TO_API)) == -1) + return -1; + else if (ret == -2) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + return 0; + } + tmp = tmpNext; + + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + else + { + i = pub_set_next_token(a->aValue, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(a->aValue, tmp, '\n', &tmpNext) < 0) + return -1; + } + } + sdp->medias.medias[sdp->medias.num - 1].attrs.num++; + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("a: %d, %s\n", a->aType, a->aValue); + + if (sdp->medias.num == 0) + sdp->flag |= PUB_SDP_FLAG_A; + else + sdp->medias.medias[sdp->medias.num - 1].flag |= PUB_SDP_FLAG_A; + + return 0; +} + +int pub_sdp_parse_m(PUB_SDP_MSG *sdp, char *buf, char **next, DWORD flag) +{ + char *equal; + char *crlf; + char *tmp; + char *tmpNext; + char value[32]; + int i; + PUB_SDP_M *mHeader; + BYTE num; + char *slash; + char *space; + int moreSpace; + int ret; + + *next = buf; + equal = buf; + + while ((*equal != '=') && (*equal != '\0')) + equal++; + if (*equal == '\0') + return -1; + + // check if header is "m" + if (equal[-1] != 'm') + return -2; + + crlf = equal + 1; + + while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0')) + crlf++; + if (*crlf == '\0') + return -1; + if (crlf == equal + 1) + return -1; /* a=\r ?? bad header */ + + if ((flag & PUB_SDP_FLAG_M) == PUB_SDP_FLAG_M) + { + tmp = equal + 1; + num = sdp->medias.num; + mHeader = &sdp->medias.medias[num].m; + // m=media port ["/"integer] proto *(payload_number) + // media is "audio" "video" "application" "data" or other... + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if ((ret = pub_sdp_media_type_conv(value, &mHeader->media, PUB_SDP_STR_TO_API)) < 0) + { + if (-2 == ret) + { + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + + return 0; + } + + return -1; + } + tmp = tmpNext; + + slash = strchr (tmp, '/'); + space = strchr (tmp, ' '); + if ((slash != NULL) && (slash < space)) + { /* a number of port is specified! */ + if (pub_set_next_token(value, tmp, '/', &tmpNext) < 0) + return -1; + mHeader->port = atoi(value); + tmp = tmpNext; + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->portNum = atoi(value); + tmp = tmpNext; + } + else + { + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->port = atoi(value); + tmp = tmpNext; + } + + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + if (pub_sdp_proto_type_conv(value, &mHeader->proto, PUB_SDP_STR_TO_API) < 0) + return -1; + tmp = tmpNext; + + space = strchr(tmp + 1, ' '); + if (space == NULL) + moreSpace = 1; + else if ((space != NULL) && (space > crlf)) + moreSpace = 1; + else + moreSpace = 0; + while(moreSpace == 0) + { + if (pub_set_next_token(value, tmp, ' ', &tmpNext) < 0) + return -1; + mHeader->payloads[mHeader->plNum++] = atoi(value); + tmp = tmpNext; + + space = strchr(tmp + 1, ' '); + if (space == NULL) + moreSpace = 1; + else if ((space != NULL) && (space > crlf)) + moreSpace = 1; + else + moreSpace = 0; + } + if (tmpNext < crlf) + { // tmpNext is still less than clrf: no space + i = pub_set_next_token(value, tmp, '\r', &tmpNext); + if (i != 0) + { + if (pub_set_next_token(value, tmp, '\n', &tmpNext) < 0) + return -1; + } + mHeader->payloads[mHeader->plNum++] = atoi(value); + } + } + + if (crlf[1] == '\n') + *next = crlf + 2; + else + *next = crlf + 1; + +// printf("m: %d, %d, %d, %d, %d, %d, %d\n", mHeader->media, mHeader->port, mHeader->portNum, mHeader->proto, mHeader->plNum, mHeader->payloads[0], mHeader->payloads[1]); + + sdp->medias.medias[sdp->medias.num].flag |= PUB_SDP_FLAG_M; + sdp->flag |= PUB_SDP_FLAG_M; + sdp->medias.num++; + + return 0; +} + +int pub_sdp_check_ending(char *ptr, char **nextbuf) +{ + *nextbuf = ptr; + + if ((*ptr == '\0') || (*ptr == '\r') || (*ptr == '\n')) + { + return 0; + } + else if (((ptr[0] == '.') && (ptr[1] == '\r') && (ptr[2] == '\n'))) + { + *nextbuf = ptr + 3; + return 1; + } + else + return -1; +} + +int pub_sdp_parse(PUB_SDP_MSG *sdp, char *buf, char **nextMsg, DWORD flag) +{ + // In SDP, headers must be in the right order + /* This is a simple example + v=0 + o=user1 53655765 2353687637 IN IP4 128.3.4.5 + s=Mbone Audio + i=Discussion of Mbone Engineering Issues + e=mbone@somewhere.com + c=IN IP4 224.2.0.1/127 + t=0 0 + m=audio 3456 RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + */ + + char *nextBuf; + char *ptr; + int i; + int ret; + int moreHeader = 1; + + pub_sdp_msg_init(sdp); + + ptr = (char *) buf; + + // mandatory + if (pub_sdp_parse_v(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // mandatory + if (pub_sdp_parse_o(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // mandatory + if (pub_sdp_parse_s(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + if (pub_sdp_parse_i(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + if (pub_sdp_parse_u(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_e(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_p(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_c(sdp, ptr, &nextBuf, flag) == -1) + return -1; + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_b(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + ptr = nextBuf; + } + + // mandatory + if (pub_sdp_parse_t(sdp, ptr, &nextBuf, flag) == -1) + return -1; + + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + + ptr = nextBuf; + + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_r(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_t(sdp, ptr, &nextBuf, flag) == -1) + return -1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + while (moreHeader == 1) + { + i = 0; + while (i == 0) // is a "r" header + { + if ((i = pub_sdp_parse_r(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + if ((i = pub_sdp_parse_t(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + else if (i == -2) + moreHeader = 0; // no more "t" headers + else + moreHeader = 1; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_z(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + if (pub_sdp_parse_k(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + // 0 or more "a" header + i = 0; + while (i == 0) // no more "a" header + { + if ((i = pub_sdp_parse_a(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + moreHeader = 0; + while (moreHeader == 0) + { + // optional + if ((moreHeader = pub_sdp_parse_m(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + else if (moreHeader == -2) + break; + + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + if (pub_sdp_parse_i (sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_c(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_b(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + + // optional + if (pub_sdp_parse_k(sdp, ptr, &nextBuf, flag) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + + // optional + i = 0; + while (i == 0) + { + if ((i = pub_sdp_parse_a(sdp, ptr, &nextBuf, flag)) == -1) + return -1; + if ((ret = pub_sdp_check_ending(nextBuf, &nextBuf)) >= 0) + { + *nextMsg = nextBuf; + return ret; + } + ptr = nextBuf; + } + } + + return 0; +} + +// SDP Encode + +int pub_sdp_encode_v(PUB_SDP_V *v, char *dest) +{ + sprintf(dest, "v=%d\r\n", v->value); + + return 0; +} + +int pub_sdp_encode_o(PUB_SDP_O *o, char *dest) +{ + char origin[128]; + char netType[8]; + char addrType[8]; + + if (pub_sdp_net_type_conv(netType, &o->netType, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_addr_type_conv(addrType, &o->addrType, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(origin, "o=%s %s %s %s %s %s\r\n", o->userName, o->sessId, o->sessVer, netType, addrType, o->addr); + + strcat(dest, origin); + + return 0; +} + +int pub_sdp_encode_s(PUB_SDP_S *s, char *dest) +{ + char sess[64]; + + sprintf(sess, "s=%s\r\n", s->sessName); + + strcat(dest, sess); + + return 0; +} + +int pub_sdp_encode_i(PUB_SDP_I *i, char *dest) +{ + char info[64]; + + sprintf(info, "i=%s\r\n", i->info); + + strcat(dest, info); + + return 0; +} + +int pub_sdp_encode_c(PUB_SDP_C *c, char *dest) +{ + char conn[128]; + char netType[8]; + char addrType[8]; + + if (pub_sdp_net_type_conv(netType, &c->netType, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_addr_type_conv(addrType, &c->addrType, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(conn, "c=%s %s %s\r\n", netType, addrType, c->addr); + + strcat(dest, conn); + + return 0; +} + +int pub_sdp_encode_t(PUB_SDP_T *t, char *dest) +{ + char time[64]; + + sprintf(time, "t=%ld %ld\r\n", t->startTime, t->stopTime); + + strcat(dest, time); + + return 0; +} + +int pub_sdp_encode_m(PUB_SDP_M *m, char *dest, WORD flag) +{ + char media[128]; + char mediaType[8]; + char proto[8]; + char payload[64]; + BYTE i; + + if (pub_sdp_media_type_conv(mediaType, &m->media, PUB_SDP_API_TO_STR) < 0) + return -1; + + if (pub_sdp_proto_type_conv(proto, &m->proto, PUB_SDP_API_TO_STR) < 0) + return -1; + + sprintf(media, "m=%s %d %s", mediaType, m->port, proto); + + if ((flag & PUB_MGCP_PARA_FLAG_TFO) == PUB_MGCP_PARA_FLAG_TFO) + { + sprintf(payload, " %d", 8); + strcat(media, payload); + } + + for (i = 0; i < m->plNum; i++) + { + if (i >= PUB_SDP_MAX_PAYLOAD_NUM) + break; + sprintf(payload, " %d", m->payloads[i]); + strcat(media, payload); + } + strcat(media, "\r\n"); + + strcat(dest, media); + + return 0; +} + +int pub_sdp_encode_a(PUB_SDP_A *a, char *dest) +{ + char attr[128]; + char attrType[8]; + int ret; + + if ((ret = pub_sdp_attr_type_conv(attrType, &a->aType, PUB_SDP_API_TO_STR)) == -1) + return -1; + + if (ret == -2) + { + sprintf(attr, "a=%s\r\n", a->aValue); + } + else + { + sprintf(attr, "a=%s:%s\r\n", attrType, a->aValue); + } + + strcat(dest, attr); + + return 0; +} + +int pub_sdp_encode(PUB_SDP_MSG *sdp, char *dest, WORD flag) +{ + BYTE i, j; + BYTE mediaNum, attrNum; + PUB_SDP_MEDIA *media; + PUB_SDP_A *a; + + if ((sdp->flag & PUB_SDP_FLAG_V) == PUB_SDP_FLAG_V) + { + if (pub_sdp_encode_v(&sdp->v, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_O) == PUB_SDP_FLAG_O) + { + if (pub_sdp_encode_o(&sdp->o, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_S) == PUB_SDP_FLAG_S) + { + if (pub_sdp_encode_s(&sdp->s, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_I) == PUB_SDP_FLAG_I) + { + if (pub_sdp_encode_i(&sdp->i, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_C) == PUB_SDP_FLAG_C) + { + if (pub_sdp_encode_c(&sdp->c, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_T) == PUB_SDP_FLAG_T) + { + if (pub_sdp_encode_t(&sdp->t, dest) < 0) + return -1; + } + + if ((sdp->flag & PUB_SDP_FLAG_M) == PUB_SDP_FLAG_M) + { + mediaNum = sdp->medias.num; + for (i = 0; i < mediaNum; i++) + { + media = &sdp->medias.medias[i]; + if (pub_sdp_encode_m(&media->m, dest, flag) < 0) + return -1; + + if ((media->flag & PUB_SDP_FLAG_A) == PUB_SDP_FLAG_A) + { + attrNum = media->attrs.num; + for (j = 0; j < attrNum; j++) + { + a = &media->attrs.attrs[j]; + if (pub_sdp_encode_a(a, dest) < 0) + return -1; + } + } + } + } + + return 0; +} + +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_str.c b/omc/plat/public_bak/src/pub_str.c new file mode 100644 index 0000000..aedb0af --- /dev/null +++ b/omc/plat/public_bak/src/pub_str.c @@ -0,0 +1,977 @@ +////////////////////////////////////////////////// +//Title : wxc_str.c +//Auhtor : Liu Wei +//Desc : wxc2 string library +//Created : 2007-06-20 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_str.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// Name : StrInc +// Function : test string is included in string "pStr"or not +////////////////////////////////////////////////////////////////////////// +inline char *StrInc ( char *pIncStr, char *pStr ) +{ + int m; + register char *pCh; + register int n; + + m = strlen ( pIncStr ); + n = strlen ( pStr ); + for ( pCh = pStr; !IsChNull(*pCh) && ( n >= m ); pCh++, n-- ) + { + if ( !strncmp ( pIncStr, pCh, m ) ) + { + return ( pCh ); + } + } + return ( NULL ); +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrIns +// Function : Insert string "pStrIns" to string "pSrc" , at the position of +// nPos, the nBufLen of string "pSrc" , is not enought , rerurn +// NULL, nor return pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrIns ( int nPos, const char *pStrIns, char *pSrc, int nBufLen ) +{ + register int i; + int nLen; + + nLen = strlen ( pStrIns ); + + if ( nBufLen < nLen + strlen ( pSrc ) ) + { + return NULL; + } + + *(pSrc+nLen+strlen ( pSrc )) = CNULL; + + for ( i = strlen ( pSrc ); i >= nPos; i-- ) + { + *( pSrc + nLen + i ) = *( pSrc + i ); + } + + for ( i = 0; i < nLen; i++ ) + { + *( pSrc + nPos + i ) = *( pStrIns + i ); + } + + return ( pSrc ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrDel +// Function : Delete string "pStrDel" in string "pStr" , If pStrDel is not +// exist, rerurn NULL, nor return pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrDel ( char *pStrDel, char *pStr ) +{ + char *pCh, *pPos; + + pCh = strstr ( pStr, pStrDel ); + if ( !pCh ) + { + return ( NULL ); + } + pPos = pCh + strlen ( pStrDel ); + strcpy ( pCh, pPos ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepCh +// Function : Replace char cSrc in the string pStr with cDst +// Return : return the replace counter +/////////////////////////////////////////////////////////////////////////// +inline int StrRepCh ( char *pStr, char cSrc, char cDst ) +{ + int nReplaced = 0; + register char *pCh; + + for ( pCh = pStr; !IsChNull ( *pCh ); pCh++ ) + { + if ( cSrc == *pCh ) + { + *pCh = cDst; + nReplaced++; + } + } + return ( nReplaced ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepStr +// Function : Replace the first string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StrRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + + pCh = strstr ( pSrc, pStr); + if ( !IsNull(pCh) ) + { + StrDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + return ( pCh ); +} + +/* +inline char *StrRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + int SrcLen; + int DstLen; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + pCh = strstr ( pStr, pSrc); + + if ( (!IsNull(pCh)) && (nBuffLen >DstLen + strlen ( pStr ) - SrcLen)) + { + StrDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh =NULL; + else + pCh = pStr; + } + else + pCh =NULL; + + return ( pCh ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChg +// Function : Replace all the string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +/* +inline char *StrChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + int i; + + i = strlen ( pDst ); + for ( ;; ) + { + if ( IsNull( StrRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + pCh += i; + n++; + } + return ( n ? pStr : NULL ); +} +*/ + +/* +inline char *StrChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + char *pCounter = pStr; + int DstLen; + int SrcLen; + int counter = 0; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + + pCounter = strstr(pCounter, pSrc); + + while (NULL != pCounter) + { + counter++; + pCounter = strstr(pCounter+SrcLen, pSrc); + } + + if ((0 != counter) && (nBuffLen > strlen(pStr)+DstLen*counter-SrcLen*counter)) + { + for ( ;; ) + { + if ( IsNull( StrRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + nBuffLen = nBuffLen - DstLen; + pCh += DstLen; + n++; + } + } + return ( n ? pStr : NULL ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StriInc +// Function : test string is included in string "pStr"or not +// Note : No matter Upper or Lower +/////////////////////////////////////////////////////////////////////////// +inline char *StriInc ( char *pIncStr, char *pStr ) +{ + int m; + register char *pCh; + register int n; + + m = strlen ( pIncStr ); + n = strlen ( pStr ); + for ( pCh = pStr; !IsChNull(*pCh) && ( n >= m ); pCh++, n-- ) + { + if ( !strncasecmp ( pIncStr, pCh, m ) ) + { + return ( pCh ); + } + } + return ( NULL ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StriDel +// Function : Delete string "pStrDel" in string "pStr" , If pStrDel is not +// exist, rerurn NULL, nor return pSrc +// Note : No matter Upper or Lower +////////////////////////////////////////////////////////////////////////// + +inline char *StriDel ( char *pStrDel, char *pStr ) +{ + char *pCh, *pPos; + + pCh = StriInc ( pStrDel, pStr ); + if ( !pCh ) + { + return ( NULL ); + } + pPos = pCh + strlen ( pStrDel ); + strcpy ( pCh, pPos ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRepCh +// Function : Replace char cSrc in the string pStr with cDst +// Return : return the replace counter +/////////////////////////////////////////////////////////////////////////// +inline int StriRepCh ( char *pStr, char cSrc, char cDst ) +{ + int nReplaced = 0; + register char *pCh; + + cSrc = toupper ( cSrc ); + for ( pCh = pStr; !IsChNull( *pCh ); pCh++ ) + { + if ( cSrc == toupper ( *pCh ) ) + { + *pCh = cDst; + nReplaced++; + } + } + return ( nReplaced ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StriRepStr +// Function : Replace the first string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +/////////////////////////////////////////////////////////////////////////// +inline char *StriRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + + pCh = StriInc ( pSrc, pStr); + if ( !IsNull(pCh) ) + { + StriDel ( pSrc, pStr ); + nPos = pCh - pStr; + + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + return ( pCh ); +} + +/* +inline char *StriRepStr ( char *pStr, char *pSrc, char *pDst, int nBuffLen ) +{ + char *pCh = NULL; + int nPos; + int SrcLen; + int DstLen; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + pCh = StriInc ( pSrc, pStr); + + if (( !IsNull(pCh) ) && (nBuffLen >DstLen + strlen ( pStr ) - SrcLen)) + { + StriDel ( pSrc, pStr ); + nPos = pCh - pStr; + if (NULL == StrIns ( nPos, pDst, pStr, nBuffLen )) + pCh = NULL; + else + pCh = pStr; + } + else + pCh = NULL; + + return ( pCh ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChg +// Function : Replace all the string "pSrc" in string "pStr" with "pDst" , +// If pSrc is not exist or the nBuffLen of pStr is not enought +// to insert pDst , rerurn NULL, nor return new pSrc +// Note : No matter Upper or Lower +/////////////////////////////////////////////////////////////////////////// +/* +inline char *StriChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + int i; + int nSrc , nDst ; + + + i = strlen ( pDst ); + for ( ;; ) + { + if ( IsNull( StriRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + pCh += i; + n++; + } + return ( n ? pStr : NULL ); +} +*/ + +/* +inline char *StriChg ( char *pStr, char *pSrc, char *pDst , int nBuffLen ) +{ + int n = 0; + char *pCh = pStr; + char *pCounter = pStr; + int DstLen; + int SrcLen; + int counter = 0; + + SrcLen = strlen(pSrc); + DstLen = strlen(pDst); + + + pCounter = StriInc(pSrc, pCounter); + + while (NULL != pCounter) + { + counter++; + pCounter = StriInc(pSrc, pCounter + SrcLen); + } + + if ((0 != counter) && (nBuffLen > strlen(pStr)+DstLen*counter-SrcLen*counter)) + { + for ( ;; ) + { + if ( IsNull( StriRepStr ( pCh, pSrc, pDst, nBuffLen ) ) ) + { + break; + } + + nBuffLen = nBuffLen - DstLen; + pCh += DstLen; + n++; + } + } + + return ( n ? pStr : NULL ); +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : StrCode +// Function : Xor the pStr with pSecCode , used in security coding +/////////////////////////////////////////////////////////////////////////// +inline char *StrCode ( char *pStr, char *pSecCode ) +{ + char *q = pSecCode; + register char *pCh; + + for ( pCh = pStr; !IsChNull(*pCh); pCh++ ) + { + if ( *pCh != *q ) + { + *pCh = *pCh ^ *q; + } + q++; + if ( IsChNull(*q) ) + { + q = pSecCode; + } + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrFinis +// Function : cut the string with '\0', if nPos > the len of pStr , fill +// the string end with ' ' and set the pStr end positon at nPos +/////////////////////////////////////////////////////////////////////////// +inline char *StrFinis ( char *pStr, int nPos ) +{ + int i; + int nLen; + + nLen = strlen ( pStr ); + if ( nPos < nLen ) + { + *( pStr + nPos ) = CNULL; + } + else + { + for ( i = nLen; i < nPos; i++ ) + { + *( pStr + i ) = ' '; + } + *( pStr + i ) = CNULL; + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrEnding +// Function : set the string end with the pEnd string till nPos position +////////////////////////////////////////////////////////////////////////// +inline char *StrEnding( char *pDst, char *pEnd , int nPos ) +{ + register int nLen = strlen(pDst); + int nEndLen = strlen(pEnd); + + if( nPos < nLen + nEndLen ) + { + return NULL; + } + for( ; nPos > nLen + nEndLen ; nLen += nEndLen ) + { + strcat( pDst , pEnd); + } +} + +/////////////////////////////////////////////////////////////////////////// +// StrSuff: checks whether suffix is a suffix of src. If it is not, +// the result is NULL. If it is, the result is a pointer +// to the character of src. +/////////////////////////////////////////////////////////////////////////// +inline char *StrSuff(const char *pSrc, const char *pSuffix ) +{ + register int nLen; + + for ( nLen = 0; *pSuffix++; nLen++ ) + if(!*pSrc++) return NULL; + + while (*pSrc++); + + for ( --pSrc, --pSuffix; --nLen >= 0; ) + if ( *--pSrc != *--pSuffix ) return NULL; + return (char*)pSrc; +} + +/* Fill string 'c' into last area of 'str'. */ +void StringCat(char *str, char *c, int slen) +{ + if (strlen(str) >= slen) + return; + while (strlen(str) < slen) + strcat(str, c); + str[slen] = 0; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrLeftShit +// Function : String left shit , delete first n chars +/////////////////////////////////////////////////////////////////////////// +inline char *StrLeftShit ( char *pStr, int n ) +{ + int i; + int len; + + len = strlen(pStr); + + if( n > len ) + { + return StrFinis(pStr , 0); + } + + len -= n; + + for ( i = 0; i < len; i++ ) + { + *( pStr + i ) = *( pStr + n + i ); + } + StrFinis( pStr , len ); + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrRLeftShit +// Function : String round left shit +/////////////////////////////////////////////////////////////////////////// +inline char *StrRLeftShit ( char *pStr, int n ) +{ + int i, j; + char t; + + if ( !IsChNull(*pStr) ) + { + for ( j = 0; j < n; j++ ) + { + t = *( pStr ); + for ( i = 0; *( pStr + i ); i++ ) + { + *( pStr + i ) = *( pStr + i + 1 ); + } + *( pStr + i - 1 ) = t; + } + } + return ( pStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// StrToLower: String all lower case. +/////////////////////////////////////////////////////////////////////////// +inline char *StrToLower ( char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; pCh && *pCh; ++pCh ) + { + if ( isupper ( *pCh ) ) + { + *pCh = tolower ( *pCh ); + } + } + return pStr; +} + +/////////////////////////////////////////////////////////////////////////// +// StrToUpper: String all upper case. +/////////////////////////////////////////////////////////////////////////// +inline char *StrToUpper ( char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; pCh && *pCh; ++pCh ) + { + if ( islower ( *pCh ) ) + { + *pCh = toupper ( *pCh ); + } + } + return pStr; +} + +/////////////////////////////////////////////////////////////////////////// +// StrDupLower: Return an all lower case version of String +// you can free the return pointer +/////////////////////////////////////////////////////////////////////////// +inline char *StrDupLower ( char *pStr ) +{ + static char *pBuffer = NULL; + register char *pCh; + + if ( pBuffer ) + { + free ( pBuffer ); + } + + pBuffer = strdup ( pStr ); + + for ( pCh = pBuffer; pCh && *pCh; ++pCh ) + { + if ( isupper ( *pCh ) ) + { + *pCh = tolower ( *pCh ); + } + } + return ( pBuffer ); +} + +/////////////////////////////////////////////////////////////////////////// +// StrDupUpper: Return an all upper case version of String // you can free the return pointer +/////////////////////////////////////////////////////////////////////////// +inline char *StrDupUpper ( char *pStr ) +{ + static char *pBuffer = NULL; + register char *pCh; + + if ( pBuffer ) + { + free ( pBuffer ); + } + + pBuffer = strdup ( pStr ); + + for ( pCh = pBuffer; pCh && *pCh; ++pCh ) + { + if ( islower ( *pCh ) ) + { + *pCh = toupper ( *pCh ); + } + } + + return ( pBuffer ); +} + +/////////////////////////////////////////////////////////////////////////// +// IsExistCh : Is the char exist in the string +/////////////////////////////////////////////////////////////////////////// +inline int IsExistCh ( char ch, char *pStr ) +{ + register char *pCh; + + for ( pCh = pStr; !IsChNull(*pCh); ++pCh ) + { + if ( ch == *pCh ) + { + return ( 1 ); + } + } + + return ( 0 ); +} + +/////////////////////////////////////////////////////////////////////////// +// FindSep: Find the first char in char set in String +/////////////////////////////////////////////////////////////////////////// +inline char *StrChSet ( char *pChSet, char *pStr ) +{ + register char *pCh; + + for ( pCh = pChSet; !IsChNull(*pCh); ++pCh ) + { + if ( IsExistCh ( *pCh, pStr ) ) + { + return ( pCh ); + } + } + return ( ( char * ) NULL ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : StrChNum +// Function : return the char number in the string +/////////////////////////////////////////////////////////////////////////// +inline int StrChNum ( char *pStr, char ch ) +{ + int n = 0; + char *pCh = pStr; + + for( ; !IsChNull(*pCh); pCh++ ) + { + if (ch == *pCh) + n++; + } + + return ( n ); +} + +/* +inline int StrChNum ( char *pStr, char ch ) +{ + int n = 0; + char *pCh = pStr; + + for( ; !IsChNull(*pCh) && (ch == *pCh) ; pCh++ ) + n++; + + return ( n ); +} +*/ +/////////////////////////////////////////////////////////////////////////// +// StrTrimCh: trim the char in the string +/////////////////////////////////////////////////////////////////////////// +inline char *StrTrimCh ( char *pSrc , char cTrim ) +{ + register char *pCh; + char *p,*q; + + q = pSrc; + p = pCh = strdup(pSrc); + + if (NULL == pCh) + { + return NULL; + } + + for( ; !IsChNull(*pCh) ; pCh++ ) + { + if(*pCh != cTrim) + { + *pSrc++ = *(pCh); + } + } + *pSrc = '\0'; + free(p); + + return q; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimCh: trim the char of the set in the string +/////////////////////////////////////////////////////////////////////////// +inline char *StrTrimChSet ( char *pSrc , char *pTrimSet ) +{ + register char *pCh; + char *p , *q , *m; + + p = pSrc; + m = pCh = strdup(pSrc); + + if (NULL == pCh) + { + return NULL; + } + + for( ; !IsChNull(*pCh) ; pCh++ ) + { + for( q = pTrimSet; *q && *pCh != *q ; q++ ) + { + ; + } + if( IsChNull(*q) ) + { + *pSrc++ = *(pCh); + } + } + + *pSrc = CNULL; + pSrc = p; + free(m); + + return pSrc; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimLeftSpace: trim left space of string +/////////////////////////////////////////////////////////////////////////// +inline char *StrTrimLeftSpace( const char *pStr ) +{ + const char *p = pStr; + + for ( ; !IsChNull(*p) && isspace(*p) ; ) + { + p++; + } + return (char*) p; +} + +/////////////////////////////////////////////////////////////////////////// +// StrTrimMoreSpace: trim more than one space +/////////////////////////////////////////////////////////////////////////// +inline char *StrTrimMoreSpace ( char *pSrc ) +{ + char *pCh , *q; + register char *p; + + pCh = p = strdup(pSrc); + q = pSrc; + for ( ; *p; p++ ) + { + if ( !( isspace ( *p ) && isspace ( *(p+1) ) ) ) + { + *pSrc++ = *p; + } + } + *pSrc = CNULL; + free(pCh); + return pSrc; +} + +/////////////////////////////////////////////////////////////////////////// +// StrPickWord: pick a word from the string +/////////////////////////////////////////////////////////////////////////// +inline char *StrPickWord ( const char *pSrc, char *pDst ) +{ + char *pCh , *q = pDst; + + pCh = StrTrimLeftSpace(pSrc); + for( ; !isspace(*pCh) && !IsChNull(*pCh) ; pCh++) + { + *q++ = *pCh; + } + return (char *)pDst; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : StrEqTok +// Function: Parse the string and return the expression name and value +// Return : NULL, parse over or string expression error , nor while to call +// StrEqTok at odd times , return the name ; and return the value +// while even times +// Note : use it like strtok +// e.g. : +// { +// char *p = NULL; +// u8 uFlag = 0; +// +// p = StrEqTok(tmpStr); +// printf( "Name: %-20s " , p); +// for( ; p = StrEqTok(NULL); ) +// { +// uFlag = uFlag ? 0 : 1; +// if( uFlag ) +// { +// printf( "Valu: %-20s \n" , p); +// } +// else +// { +// printf( "Name: %-20s " , p); +// } +// } +// } +////////////////////////////////////////////////////////////////////////// +static char *pStrEqTok = NULL; +static u8 uStrEqState = 0; + +char *StrEqTok ( char *pStr ) +{ + char *p, *q, *pCh; + char *pDel = " "; + + pCh = pStr; + if ( pCh == NULL ) + { //last position + pCh = pStrEqTok; + } + else + { + StrTrimLeftSpace ( pCh ); + StrTrimMoreSpace ( pCh ); + } + + if ( pCh == NULL ) + { + return NULL; + } + + uStrEqState = uStrEqState > 2 ? 0 : uStrEqState; + q = strpbrk ( pCh, pDel ); + if ( q == NULL ) + { //over , one word + pStrEqTok = NULL; + q = pCh; + } + else + { //save position + pStrEqTok = q + 1; + *q = CNULL; + } + + p = strchr ( pCh, '=' ); //parse word + if ( p == NULL ) + { //simple word exclude '=' + if ( pStrEqTok == NULL || uStrEqState == 1 ) + { //miss '=' + goto STREQTOK_CLEAN_UP; + } + if ( uStrEqState == 0 || uStrEqState == 2 ) + { //wating expres left or right, recieved + uStrEqState++; + return pCh; + } + } + else + { + if ( uStrEqState == 0 && STR_CHECK_LAST( pCh, '=' ) ) + { //wating expres left , revied left and '=' + uStrEqState += 2; + STR_CUT_LAST( pCh ); + return pCh; + } + else if ( uStrEqState == 1 && STR_CHECK_FIRST( pCh,'=') ) + { //wating '=' , revied + if ( pCh[1] == CNULL ) + { //just '=' + if ( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + pCh = pStrEqTok; + p = strpbrk ( pCh, pDel ); + if ( p == NULL ) + { + pStrEqTok = NULL; + p = pCh; + } + else + { + pStrEqTok = p + 1; + *p = CNULL; + } + uStrEqState = 3; + return pCh; + } + else + { //expres '=' and right + uStrEqState = 3; //all meet + return ++pCh; + } + } + else if ( uStrEqState == 0 ) + { //expres left and '=' and right + if ( pStrEqTok != NULL ) + { + *( pStrEqTok - 1 ) = ' '; + } + pStrEqTok = p + 1; + *p = CNULL; + uStrEqState = 2; + return pCh; + } + else + { + goto STREQTOK_CLEAN_UP; + } + } + + STREQTOK_CLEAN_UP: + pStrEqTok = NULL; + uStrEqState = 0; + return NULL; +} + + +/*@end@*/ + diff --git a/omc/plat/public_bak/src/pub_sys.c b/omc/plat/public_bak/src/pub_sys.c new file mode 100644 index 0000000..486fc50 --- /dev/null +++ b/omc/plat/public_bak/src/pub_sys.c @@ -0,0 +1,553 @@ +////////////////////////////////////////////////// +//Title : linux_sys.c +//Auhtor : Liu Wei +//Desc : Linux system infomation +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_sys.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// InitParalPort:Init parallel port data . +/////////////////////////////////////////////////////////////////////////// +extern void InitParalPort(void) +{ + ioperm(0x37a,3,1); + ioperm(0x378,3,1); + ioperm(0x379,3,1); + outb(0,0x37a); + outb(0,0x378); +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : WriteParalPort +// Function : Write parallel port data +// Node : Parallel port address: +// : flag=0,address=0x37a B1;flag=1,address=0x37a B2 +// : flag=2--9,address=0x378 B0--B7 +/////////////////////////////////////////////////////////////////////////// + +extern void WriteParalPort(u8 uFlag,u8 uData) +{ + u8 ii,jj; + + if (uFlag > 9) + return; + if (uData != 0 && uData != 1) + return; + if (uFlag == 0 || uFlag == 1) // read or write 0x37a + { + ii = inb(0x37a); + jj = 1 << (uFlag + 1); + ii = ii & (~jj); + if (uFlag == 0) + jj = (~uData & 0x01) << (uFlag + 1); + else + jj = uData << (uFlag + 1); + ii = ii | jj; + outb(ii,0x37a); + } + else + { + ii = inb(0x378); + jj = 1 << (uFlag - 2); + ii = ii & (~jj); + jj = uData << (uFlag - 2); + ii = ii | jj; + outb(ii,0x378); + } +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemoryStr: Get memery string +////////////////////////////////////////////////////////////////////////// +extern char *GetMemoryStr(u32 Amount) +{ + static char Buff[64]; + + if (Amount > 0) { + (void) snprintf(Buff, sizeof(Buff), "%d", Amount/MBYTES); + return(Buff); + } + + return((char *) NULL); +} + +/////////////////////////////////////////////////////////////////////////// +// GetBootTimeProc: Get System Model using the /proc/cpuinfo file. +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_UPTIME "/proc/uptime" + +extern char *GetBootTimeProc ( ) +{ + FILE *pFile; + static char sBuff[64]; + char *pCh; + char *DateStr; + time_t tmUptime; + time_t tmBootTime; + + pFile = fopen ( PROC_FILE_UPTIME, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_UPTIME, + SYSERR ); + return ( ( char * ) NULL ); + } + + if ( !fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + FLogMsg ( PIF_GERR, "%s: Read uptime failed: %s", PROC_FILE_UPTIME, + SYSERR ); + ( void ) fclose ( pFile ); + return ( ( char * ) NULL ); + } + + if ( pCh = strchr ( sBuff, ' ' ) ) + { + *pCh = CNULL; + } + + tmUptime = ( time_t ) strtol ( sBuff, NULL, 0 ); + if ( tmUptime <= 0 ) + { + FLogMsg ( PIF_GERR, "Convert `%s' to long failed", sBuff ); + ( void ) fclose ( pFile ); + return ( ( char * ) NULL ); + } + + tmBootTime = time ( NULL ); + tmBootTime -= tmUptime; + + DateStr = TimeToStr ( tmBootTime, NULL ); + + ( void ) fclose ( pFile ); + + return ( DateStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// Get System Model using the /proc/cpuinfo file. +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_CPUINFO "/proc/cpuinfo" +/* +extern char *GetModelProc ( ) +{ + FILE *pFile; + static char sBuff[256]; + char *Cpu = NULL; + char *Vendor = NULL; + char *Model = NULL; + char Speed[64]; + float sp = 0; + char **Argv; + int Argc; + int Cleanup; + + if ( sBuff[0] ) + { + return ( sBuff ); + } + + pFile = fopen ( PROC_FILE_CPUINFO, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_CPUINFO, + SYSERR ); + return ( ( char * ) NULL ); + } + + Speed[0] = CNULL; + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + Cleanup = TRUE; + Argc = StrToArgv ( sBuff, ":", &Argv, NULL, 0 ); + if ( Argc < 2 ) + { + continue; + } + if ( EQ ( Argv[0], "cpu" ) ) + { + Cpu = Argv[1]; + } + else if ( EQ ( Argv[0], "vendor_id" ) ) + { + Vendor = Argv[1]; + } + else if ( EQ ( Argv[0], "model name" ) ) + { + Model = Argv[1]; + } + else if ( EQ ( Argv[0], "cpu MHz" ) ) + { + + // This value is not always perfectly accurate as Linux estimates + // the actual Mhz by doing a loop test at boot. + + if ( sscanf ( Argv[1], "%f", &sp ) ) + { + ( void ) sprintf ( Speed, "%.0f Mhz", rint ( ( double ) sp ) ); + } + } + else + { + DestroyArgv ( &Argv, Argc ); + Cleanup = FALSE; + } + + if ( Cleanup ) + { + ( void ) free ( Argv[0] ); + } + } + + sBuff[0] = CNULL; + if ( Vendor ) + { + ( void ) strcpy ( sBuff, Vendor ); + ( void ) free ( Vendor ); + } + if ( Speed[0] ) + { + if ( sBuff[0] ) + { + ( void ) strcat ( sBuff, " " ); + } + ( void ) strcat ( sBuff, Speed ); + } + if ( Model ) + { + if ( sBuff[0] ) + { + strcat ( sBuff, " " ); + } + strcat ( sBuff, Model ); + ( void ) free ( Model ); + } + if ( Cpu ) + { + if ( sBuff[0] ) + { + strcat ( sBuff, " " ); + } + strcat ( sBuff, Cpu ); + ( void ) free ( Cpu ); + } + + ( void ) fclose ( pFile ); + + return ( sBuff ); +} +*/ +/////////////////////////////////////////////////////////////////////////// +// GetMBytesStr: Get the string of Mbytes +/////////////////////////////////////////////////////////////////////////// + +extern char *GetMBytesStr ( u32 wAmount ) +{ + static char sBuff[64]; + + if ( !wAmount ) + { + return ( ( char * ) NULL ); + } + + if ( wAmount > KBYTES ) + { + ( void ) snprintf ( sBuff, sizeof ( sBuff ), "%.1f GB", + ( float ) MbytesToGbytes ( wAmount ) ); + } + else + { + ( void ) snprintf ( sBuff, sizeof ( sBuff ), "%.0f MB", + ( float ) wAmount ); + } +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemoryKcore: Get System Memory using size of /proc/kcore +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_KCORE "/proc/kcore" + +extern char *GetMemoryKcore ( ) +{ + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + struct stat tStatBuf; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( stat ( PROC_FILE_KCORE, &tStatBuf ) != 0 ) + { + FLogMsg ( PIF_GERR, "%s: stat failed: %s", PROC_FILE_KCORE, SYSERR ); + return ( ( char * ) NULL ); + } + + wMemBytes = ( u32 ) ( tStatBuf.st_size - 4096 ); + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMBytesStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetMemorySysinfo: Get System Memory using sysinfo() system call +/////////////////////////////////////////////////////////////////////////// + +extern char *GetMemorySysinfo ( ) +{ + struct sysinfo tSysInfo; + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( sysinfo ( &tSysInfo ) != 0 ) + { + FLogMsg ( PIF_GERR, "sysinfo() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + // sysinfo.totalram represents total USABLE physical memory. Memory + // reserved by the kernel is not included. So this is as close as we + // can get for now. + + wMemBytes = ( u32 ) tSysInfo.totalram; + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMemoryStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetVirtMemLinux:Get Virtual Memory using sysinfo() system call +/////////////////////////////////////////////////////////////////////////// + +extern char *GetVirtMemLinux ( ) +{ + struct sysinfo tSysInfo; + static char *pMemStr = NULL; + u32 wMemBytes = 0; + u32 wAmount = 0; + + if ( pMemStr ) + { + return ( pMemStr ); + } + + if ( sysinfo ( &tSysInfo ) != 0 ) + { + FLogMsg ( PIF_GERR, "sysinfo() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + wMemBytes = ( u32 ) ( tSysInfo.totalram + tSysInfo.totalswap ); + wAmount = DivRndUp( wMemBytes, ( u32 ) MBYTES ); + pMemStr = GetMemoryStr ( wAmount ); + + return ( pMemStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetCpuTypeProc:Get CPU Type from /proc/cpuinfo +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_CPUINFO "/proc/cpuinfo" +/* +extern char *GetCpuTypeProc ( ) +{ + FILE *pFile; + static char sBuff[256]; + static char *Cpu = NULL; + char **Argv; + char *pCh; + int Argc; + + if ( Cpu ) + { + return ( Cpu ); + } + + pFile = fopen ( PROC_FILE_CPUINFO, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_CPUINFO, + SYSERR ); + return ( ( char * ) NULL ); + } + + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + Argc = StrToArgv ( sBuff, ":", &Argv, NULL, 0 ); + if ( Argc < 2 ) + { + continue; + } + if ( EQ ( Argv[0], "cpu" ) ) + { + // Linux 2.0 + Cpu = Argv[1]; + break; + } + else if ( EQ ( Argv[0], "model name" ) ) + { + // Linux 2.2 + Cpu = Argv[1]; + if ( pCh = strchr ( Cpu, ' ' ) ) + { + *pCh = CNULL; + } + break; + } + } + + ( void ) fclose ( pFile ); + + return ( Cpu ); + +} +*/ + +/////////////////////////////////////////////////////////////////////////// +// GetKernVerProc: Get Kernel Version string using /proc/version +/////////////////////////////////////////////////////////////////////////// + +#define PROC_FILE_VERSION "/proc/version" + +extern char *GetKernVerProc ( ) +{ + FILE *pFile; + static char sBuff[512]; + + if ( sBuff[0] ) + { + return ( sBuff ); + } + + pFile = fopen ( PROC_FILE_VERSION, "r" ); + if ( !pFile ) + { + FLogMsg ( PIF_GERR, "%s: open readonly failed: %s", PROC_FILE_VERSION, + SYSERR ); + return ( ( char * ) NULL ); + } + + if ( !fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + FLogMsg ( PIF_GERR, "%s: read failed: %s", PROC_FILE_VERSION, SYSERR ); + return ( ( char * ) NULL ); + } + + ( void ) fclose ( pFile ); + + return ( sBuff ); + +} + +/////////////////////////////////////////////////////////////////////////// +// GetKernVerLinux: Get Kernel Version string using uname() +/////////////////////////////////////////////////////////////////////////// + +extern char *GetKernVerLinux ( ) +{ + static struct utsname tName; + static char *pVerStr = NULL; + + if ( uname ( &tName ) != 0 ) + { + FLogMsg ( PIF_GERR, "uname() system call failed: %s", SYSERR ); + return ( ( char * ) NULL ); + } + + pVerStr = tName.version; + + return ( pVerStr ); +} + +/////////////////////////////////////////////////////////////////////////// +// GetOSDistLinux: Get linux distribution (vendor) +/////////////////////////////////////////////////////////////////////////// +/* +extern char *GetOSDistLinux ( ) +{ + static char sBuff[256]; + register char *pCh; + register char *End; + char IssueFile[] = "/etc/issue"; + char Welcome[] = "Welcome to "; + FILE *pFile; + int Found = FALSE; + + if ( !( pFile = fopen ( IssueFile, "r" ) ) ) + { + FLogMsg ( PIF_GERR, "%s: Cannot open to get OS Dist: %s", IssueFile, + SYSERR ); + return ( ( char * ) NULL ); + } + + while ( fgets ( sBuff, sizeof ( sBuff ), pFile ) ) + { + // Some distributions have VGA control chars in them + if ( !isalpha ( sBuff[0] ) ) + { + continue; + } + for ( pCh = sBuff; pCh && *pCh && *pCh != '\n' && !isalpha ( *pCh ); + ++pCh ) + ; + if ( *pCh == '\n' || !strlen ( pCh ) ) + { + continue; + } + // Found first nonblank line + Found = TRUE; + break; + } + + ( void ) fclose ( pFile ); + + if ( !Found ) + { + return ( ( char * ) NULL ); + } + + if ( EQN ( pCh, Welcome, sizeof ( Welcome ) - 1 ) ) + { + pCh += sizeof ( Welcome ) - 1; + } + else if ( EQN ( pCh, "Linux ", 6 ) ) + { + pCh += 6; + } + + if ( End = strchr ( pCh, '-' ) ) + { + --End; + while ( *End && isspace ( *End ) ) + { + --End; + } + *++End = CNULL; + } + + return ( pCh ); +} + +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_time.c b/omc/plat/public_bak/src/pub_time.c new file mode 100644 index 0000000..6271fac --- /dev/null +++ b/omc/plat/public_bak/src/pub_time.c @@ -0,0 +1,130 @@ +////////////////////////////////////////////////// +//Title : pub_time.c +//Auhtor : Liu Wei +//Desc : Linux time function +//Created : 2007-06-02 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_time.h" + +/*@ignore@*/ + +/////////////////////////////////////////////////////////////////////////// +// Name : GetTickCount +// Function: return the ms value of the time +// Note : +/////////////////////////////////////////////////////////////////////////// +extern long GetTickCount() +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GetCurrentTime +// Function: get current system time(BcdFormate) +// Note : now_time's length is 6: year,month,day,hour,minute,second +// Return : 1 successful 0 fail +/////////////////////////////////////////////////////////////////////////// +extern int GetCurrentTime( u8 *pNowTime ) +{ + struct tm *pTMNowTime; + time_t tTemptime; + + tTemptime = time(NULL); + pTMNowTime = localtime(&tTemptime); + if( pTMNowTime == NULL ) + return 0; + pNowTime[0] = pTMNowTime->tm_year-100; + pNowTime[1] = pTMNowTime->tm_mon+1; + pNowTime[2] = pTMNowTime->tm_mday; + pNowTime[3] = pTMNowTime->tm_hour; + pNowTime[4] = pTMNowTime->tm_min; + pNowTime[5] = pTMNowTime->tm_sec; + + return 1; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : GetCurrentTime +// Function: get current system time in ASCII format +// Note : +/////////////////////////////////////////////////////////////////////////// +extern char *GetAsciiTime() +{ + char *pAscTime; + time_t tCurTime; + + tCurTime = time(NULL); + pAscTime = ctime(&tCurTime); + + return (char *)pAscTime; +} + +char *TimeToStr ( time_t TimeVal, char *Format ) +{ + struct tm *tm; + static char sBuff[128]; + char *String; + char *pCh; + char *Fmt; + + if ( Format != NULL) + { + Fmt = Format; + } + else + { + //Use %H instead of %k as %H is more portable + Fmt = "%a %b %e %H:%M:%S %Y %Z"; + } + tm = localtime ( &TimeVal ); + if ( NULL != tm ) + { + String = asctime ( tm ); + if ( NULL != String ) + { + pCh = strchr ( String, '\n' ); + if ( NULL != pCh ) + { + *pCh = CNULL; + } + return String; + } + } + + FLogMsg ( PIF_DBG, "TimeToStr() failed - No conversion func defined?" ); + + return ( char * ) NULL; +} + + + +/////////////////////////////////////////////////////////////////////////// +// Name : GetTimeHMS +// Function: get current system time string of hour mininute and second +// Note : +/////////////////////////////////////////////////////////////////////////// +extern char *GetTimeHMS(char *pTimeBuf) +{ + struct tm *pTM,tTM; + long lCurTime; + + pTM = &tTM; + lCurTime = time((long *)0); + pTM = localtime(&lCurTime); + sprintf(pTimeBuf,"%02d:%02d:%02d",pTM->tm_hour,pTM->tm_min,pTM->tm_sec); + pTimeBuf[8] = CNULL; + + return pTimeBuf; +} + +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_timer.c b/omc/plat/public_bak/src/pub_timer.c new file mode 100644 index 0000000..1ec7deb --- /dev/null +++ b/omc/plat/public_bak/src/pub_timer.c @@ -0,0 +1,176 @@ +////////////////////////////////////////////////// +//Title : wxc_timer.c +//Auhtor : Liu Wei +//Desc : WXC2 Public Timer Managemnet +//Created : 2007-04-27 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_timer.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern void TimerAdd ( WxcTimer * pTimer ) +{ + WxcTimerNode *pTNode; + + assert ( NULL != pTimer && NULL != pTimer->pFunc ); + assert ( pTimer->dExpires && pTimer->dSuitNumber < TM_CLOCK_MAX ); + + //pTimer->dSuitNumber = ? : 1; + + pTNode = + ( WxcTimerNode * ) WxcMalloc ( GET_TNODE_SIZE ( pTimer->dSuitNumber ) ); + if( NULL == pTNode ) + { + return ; + } + pTNode->pNext = NULL; + pTNode->pPrev = pTLCur; + pTNode->pTimer = ( WxcTimer * ) ( pTNode + 4 * sizeof ( void * ) ); + pTimer->pTimerNode = ( void * ) pTNode; + memcpy ( pTNode->pTimer, pTimer, sizeof ( WxcTimer ) ); + pTNode->dClockArray = ( u32 * ) ( pTNode->pTimer + sizeof ( WxcTimer ) ); + pTLCur = pTNode; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +inline void TimerStart ( WxcTimer * pTimer, u16 dSuitId ) +{ + assert ( pTimer && pTimer->pTimerNode ); + assert ( dSuitId < pTimer->dSuitNumber ); + + ( ( WxcTimerNode * ) pTimer->pTimerNode )->dClockArray[dSuitId] = 1; +} + +extern void TimerMod ( WxcTimer * pTimer, u16 dExpires ) +{ + int i; + + assert ( NULL != pTimer && dExpires ); + + pTimer->dExpires = dExpires; + for ( i = 0; i < pTimer->dSuitNumber; i++ ) + { + TimerStart ( pTimer, i ); + } +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern void TimerDel ( WxcTimer * pTimer ) +{ + assert ( pTimer && pTimer->pTimerNode ); + + WxcFree ( pTimer->pTimerNode ); + pTimer->pTimerNode = NULL; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern inline void TimerStop ( WxcTimer * pTimer, u16 dSuitId ) +{ + assert ( NULL != pTimer && dSuitId < pTimer->dSuitNumber ); + + ( ( WxcTimerNode * ) pTimer->pTimerNode )->dClockArray[dSuitId] = 0; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +#define TimerRestart(pTimer) TimerStart(pTimer) + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static void *TM_Alloc ( u16 dSize ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static void TM_Free ( void *p ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static inline int TM_Pending ( WxcTimerNode * pTNode, u16 dSuitId ) +{ + return ( pTNode->dClockArray[dSuitId] ? 1 : 0 ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +static inline int TM_Expiring ( WxcTimerNode * pTNode, u16 dSuitId ) +{ + return ( TimerAfter + ( pTNode->dClockArray[dSuitId], pTNode->pTimer->dExpires ) ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern inline void TM_Init ( ) +{ + pTLCur = pTLHead = &tTimerListHead; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +extern void TM_RT ( ) +{ + u16 sid; + WxcTimer *pTimer; + WxcTimerNode *pTNode; + + pTNode = pTLHead; + + for ( ; NULL != pTNode; pTNode = pTNode->pNext ) + { + pTimer = pTNode->pTimer; + for ( sid = 0; sid <= pTimer->dSuitNumber; sid++ ) + { + if ( !TM_Pending ( pTNode, sid ) ) + { + pTNode->dClockArray[sid]++; + if ( TM_Expiring ( pTNode, sid ) ) + { + pTimer->pFunc ( pTimer->dData, sid ); + } + } + } + } +} + +/*@end@*/ diff --git a/omc/plat/public_bak/src/pub_wnet.c b/omc/plat/public_bak/src/pub_wnet.c new file mode 100644 index 0000000..3f7d2d3 --- /dev/null +++ b/omc/plat/public_bak/src/pub_wnet.c @@ -0,0 +1,425 @@ +////////////////////////////////////////////////// +//Title : wxc_netfunc.c +//Auhtor : Liu Wei +//Desc : wxc2 network convert function +//Created : 2007-06-20 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/pub_wnet.h" + +u8 GetBcdStr ( char *str, u8 * bcd, u8 bcd_len ) +{ + u8 ii = 0; + + Bcd2Str ( str, bcd, bcd_len * 2 ); + for ( ii = 0; ii < bcd_len * 2; ii++ ) + { + if( str[ii] == 'e' || str[ii] == 'E' ) + break; + } + str[ii] = '\0'; + return ii; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiNToA +// Function: transfer IMSI format from normal to anti sequence +// Note : 0460022157127001 --> 64002251177200f1 +////////////////////////////////////////////////////////////////////////// + +void ImsiNtoA( u8 *pAntiImsi , u8 *pNormalImsi ) +{ + u8 ii; + u8 aa, bb = 0; + + for ( ii = 1; ii <= IMSI_LEN * 2; ii++ ) + { + if ( ( ii % 2 ) == 1 ) + { + bb = pNormalImsi[ii / 2] & 0x0f; + } + else + { + aa = (ii == IMSI_LEN * 2) ? 0x0f0 : (pNormalImsi[ii / 2] & 0x0f0); + pAntiImsi[ii / 2 - 1] = aa | bb; + } + } + +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiAToN +// Function: transfer IMSI format from anti to normal sequence +// Note : 64002251177200f1 --> 0460022157127001 +////////////////////////////////////////////////////////////////////////// + +void ImsiAToN ( u8 * pNormalImsi, u8 * pAntiImsi ) +{ // the IMSI must 15 digits + u8 ii; + u8 aa, bb = 0; + + pNormalImsi[0] = 0; + for ( ii = 0; ii < IMSI_LEN * 2; ii++ ) + { + if ( ( ii % 2 ) == 1 ) + { + aa = pAntiImsi[ii / 2] & 0x0f; + pNormalImsi[ii / 2] |= aa; + } + else + { + if ( ii / 2 != IMSI_LEN - 1 ) + { + bb = pAntiImsi[ii / 2] & 0x0f0; + pNormalImsi[ii / 2 + 1] = bb; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiNToS +// Function: transfer IMSI format from normal to ascii string +// Note : 0460022157127001 --> "460022157127001" +/////////////////////////////////////////////////////////////////////////// + +void ImsiNToS ( u8 * pImsiStr, u8 * pNormalImsi ) +{ + u8 len; + u8 ii, jj; + + pImsiStr[0] = ( pNormalImsi[0] & 0x0f ) + '0'; + len = 1; + for ( ii = 1; ii < IMSI_LEN; ii++ ) + { + jj = ( pNormalImsi[ii] >> 4 ) & 0x0f; + pImsiStr[len++] = jj + '0'; + jj = pNormalImsi[ii] & 0x0f; + pImsiStr[len++] = jj + '0'; + } + pImsiStr[len] = '\0'; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : ImsiSToN +// Function: transfer IMSI format from ascii string to normal +// Note : "460022157127001" --> 0460022157127001 +/////////////////////////////////////////////////////////////////////////// + +void ImsiSToN ( u8 * pNormalImsi, u8 * pImsiStr ) +{ + if ( strlen ( pImsiStr ) != IMSI_LEN * 2 - 1 ) + return; + pNormalImsi[0] = pImsiStr[0] - '0'; + Str2Bcd ( pNormalImsi + 1, pImsiStr + 1, IMSI_LEN * 2 - 2 ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnNToA +// Function: transfer ISDN format from normal to anti sequence +// Note : 918675557127001EEE --> 08916857551700E1 +/////////////////////////////////////////////////////////////////////////// + +void IsdnNToA ( u8 * pAntiIsdn, u8 * pNormalIsdn ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 len; + + // nature of address and numbering plan indicator + pAntiIsdn[1] = pNormalIsdn[0]; + len = 1; + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + if ( pNormalIsdn[ii] == 0xee ) + { + break; + } + else + { + aa = ( pNormalIsdn[ii] & 0x0f0 ) >> 4; + bb = pNormalIsdn[ii] & 0x0f; + if ( bb > 0x0c ) + { + bb = 0x0f; + } + pAntiIsdn[ii + 1] = ( bb << 4 ) + aa; + len++; + } + } + pAntiIsdn[0] = len; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnAToN +// Function: transfer ISDN format from anti to normal sequence +// Note : 08916857551700E1 --> 918675557127001EEE +/////////////////////////////////////////////////////////////////////////// + +void IsdnAToN ( u8 * pNormalIsdn, u8 * pAntiIsdn ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 uIsdnLen; + + uIsdnLen = pAntiIsdn[0]; + if ( uIsdnLen > ISDN_LEN ) + uIsdnLen = ISDN_LEN; + pNormalIsdn[0] = pAntiIsdn[1]; + for ( ii = 1; ii < uIsdnLen; ii++ ) + { + if ( ( pAntiIsdn[ii + 1] & 0x0f ) >= 0x0e ) + break; + aa = ( pAntiIsdn[ii + 1] & 0x0f0 ) >> 4; + if ( aa > 0x0c ) + aa = 0x0e; + bb = pAntiIsdn[ii + 1] & 0x0f; + pNormalIsdn[ii] = ( bb << 4 ) + aa; + } + for ( ; ii < ISDN_LEN; ii++ ) + pNormalIsdn[ii] = 0x0ee; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnNToS +// Function: transfer ISDN format from normal to ascii string +// Note : 918675557127001EEE --> "8675557127001" +/////////////////////////////////////////////////////////////////////////// + +void IsdnNToS ( u8 * pIsdnStr, u8 * pNormalIsdn ) +{ + u8 len = 0; + u8 ii, jj; + + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + jj = ( pNormalIsdn[ii] >> 4 ) & 0x0f; + if ( jj > 0x0c ) + break; + pIsdnStr[len++] = jj + '0'; + jj = pNormalIsdn[ii] & 0x0f; + if ( jj > 0x0c ) + break; + pIsdnStr[len++] = jj + '0'; + } + pIsdnStr[len] = '\0'; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnAToS +// Function: transfer ISDN format from anti to ascii string +// Note : 08916857551700E1 --> "8675557127001" +/////////////////////////////////////////////////////////////////////////// + +void IsdnAToS ( u8 * pAntiIsdn, u8 * pIsdnStr ) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 len = 0; + u8 uIsdnLen; + + + uIsdnLen = pAntiIsdn[0]; + if ( uIsdnLen > ISDN_LEN ) + uIsdnLen = ISDN_LEN; + + for ( ii = 1; ii < uIsdnLen; ii++ ) + { + if ((bb = ( pAntiIsdn[ii + 1] & 0x0f )) >= 0x0c) + break; + + pIsdnStr[len++] = bb + '0'; + + if ((aa = ( pAntiIsdn[ii + 1] & 0x0f0 ) >> 4) >= 0x0c) + break; + + pIsdnStr[len++] = aa + '0'; + } + + pIsdnStr[len] = '\0'; +} + + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnSToN +// Function: transfer ISDN format from ascii string to normal +// Note : "8675557127001" --> 918675557127001EEE +// Return : 0--string has error; 1--success +/////////////////////////////////////////////////////////////////////////// + +u8 IsdnSToN ( u8 * pNormalIsdn, u8 * pIsdnStr ) +{ + u8 ii; + u8 len; + + len = strlen ( pIsdnStr ); + if ( len > ISDN_LEN * 2 - 2 ) + return 0; + if ( ( len % 2 ) == 1 ) // odd number + { + Str2Bcd ( pNormalIsdn + 1, pIsdnStr, len - 1 ); + ii = len / 2 + 1; + pNormalIsdn[ii] = ( pIsdnStr[len - 1] - '0' ) << 4; + pNormalIsdn[ii] |= 0x0E; + } + else + { + Str2Bcd ( pNormalIsdn + 1, pIsdnStr, len ); + ii = len / 2; + } + memset ( pNormalIsdn + ii + 1, 0xEE, ISDN_LEN - ii - 1 ); + pNormalIsdn[0] = 0x91; // default value + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GttToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void GttToIsdn ( u8 *pIsdn, u8 *pGtt ) +{ + u8 ii, jj; + + pIsdn[0] = 0x91; + for ( ii = 1; ii < ISDN_LEN; ii++ ) + { + jj = pGtt[ii - 1] & 0x0f; + if ( jj > 0x0c ) + break; + pIsdn[ii] = jj << 4; + jj = ( pGtt[ii - 1] & 0xf0 ) >> 4; + if ( jj > 0x0c ) + jj = 0x0e; + pIsdn[ii] |= jj; + if ( jj == 0x0e ) + { + ii++; + break; + } + } + for ( ; ii < ISDN_LEN; ii++ ) + pIsdn[ii] = 0xee; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : IsdnToGtai +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +u8 IsdnToGtai ( u8 * pGtai, u8 * pIsdn ) +{ + u8 tmpBuf[32]; + u8 ii; + u8 len; + + IsdnNToA ( tmpBuf, pIsdn ); + ii = tmpBuf[0]; + memcpy ( pGtai, tmpBuf + 2, ii - 1 ); + if ( ( tmpBuf[ii] & 0x0f0 ) == 0x0f0 ) + len = ii * 2 - 3; + else + len = ii * 2 - 2; + return len; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : GtaiToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void GtaiToIsdn ( u8 * pIsdn, u8 * pGtai, u8 len ) +{ + u8 tmpBuf[32]; + + tmpBuf[0] = ( len + 1 ) / 2; + tmpBuf[1] = 0x91; + memcpy ( tmpBuf + 2, pGtai, tmpBuf[0]++ ); + IsdnAToN ( pIsdn, tmpBuf ); +} + +/////////////////////////////////////////////////////////////////////////// +// Name : BcdToStrPE +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +u8 BcdToStrPE ( char *str, u8 * bcd, u8 bcd_len ) +{ + u8 ii = 0; + + Bcd2Str ( str, bcd, bcd_len * 2 ); + for ( ii = 0; ii < bcd_len * 2; ii++ ) + { + if ( str[ii] == 'e' || str[ii] == 'E' ) + break; + } + str[ii] = '\0'; + return ii; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : AddCcToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void AddCcToIsdn ( u8 * isdn_str, u8 * cc ) +{ + char str1[32], str2[32]; + u8 len, len1, len2; + + len1 = BcdToStrPE ( str1, isdn_str + 1, ISDN_LEN - 1 ); + len2 = BcdToStrPE ( str2, cc, 2 ); + memcpy ( str2 + len2, str1, len1 ); + len = len1 + len2; + if ( ( len % 2 ) != 0 ) + str2[len++] = 'E'; + str2[len] = '\0'; + Str2Bcd ( isdn_str + 1, str2, len ); + isdn_str[0] = 0x91; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : AddNdcToIsdn +// Function: +// Note : +/////////////////////////////////////////////////////////////////////////// + +void AddNdcToIsdn ( u8 * isdn_str, u8 * ndc ) +{ + char str1[32], str2[32]; + u8 len, len1, len2; + + len1 = GetBcdStr ( str1, isdn_str + 1, ISDN_LEN - 1 ); + len2 = GetBcdStr ( str2, ndc, 3 ); //6 digit ndc + memcpy ( str2 + len2, str1, len1 ); + len = len1 + len2; + if ( ( len % 2 ) != 0 ) + str2[len++] = 'E'; + Str2Bcd ( isdn_str + 1, str2, len ); + isdn_str[0] = 0xa1; +} + +void BcdToAsciiR(char *ascii_buf, const unsigned char *bcd_buf, int len) +{ + char ch; + int i; + for(i=0;i + * + */ + +#include "./number.h" + +/* +ITU: + 0-spare + 1-subscriber + 2-unknown + 3-NDD + 4-IDD + +GSM 09.02: +-- bits 765: nature of address indicator +-- 000 unknown +-- 001 international number +-- 010 national significant number +-- 011 network specific number +-- 100 subscriber number +-- 101 reserved +-- 110 abbreviated number +-- 111 reserved for extension +*/ + +static const u8 NAI_GSM2ITU[8] = {0x02, 0x04, 0x03, 0x03, 0x01, 0x02, 0x02, 0x02}; +static const u8 NAI_ITU2GSM[8] = {0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00}; + +u8 nai_gsm_to_itu(u8 nai) +{ + return NAI_GSM2ITU[nai & 0x07]; +} + +u8 nai_itu_to_gsm(u8 nai) +{ + return NAI_ITU2GSM[nai & 0x07]; +} + +u8 *msc_isdn_to_bcd(u8 *bcd, const isdn_t *isdn) +{ + int i; + const num32_t *num = &isdn->num; + u8 *bcdptr; + + bcd[0] = (num->num_of_digit+1)/2 + 1; + bcd[1] = 0x81 | (nai_itu_to_gsm(isdn->nai) << 4); + bcdptr = bcd + 2; + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcdptr = (num->digit[i] << 4) | 0x0f; + else + { + *bcdptr = (*bcdptr & 0xf0) + num->digit[i]; + bcdptr++; + } + } + return bcd; +} + +isdn_t *netbcd_to_isdn(isdn_t *isdn, const u8 *bcd) +{ + u8 bcd_digits; + u8 digit; + num32_t *num = &isdn->num; + + if(bcd[0] < 1) + { + num->num_of_digit = 0; + return isdn; + } + bcd_digits = (bcd[0]-1) * 2; + isdn->nai = nai_gsm_to_itu((bcd[1] >> 4) & 0x07); + bcd += 2; + for(num->num_of_digit = 0; (num->num_of_digit<32)&&(num->num_of_digitnum_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *bcd & 0x0f; + else + digit = *(bcd++) >> 4; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return isdn; +} + +u8 *isdn_to_netbcd(u8 *bcd, const isdn_t *isdn) +{ + int i; + const num32_t *num = &isdn->num; + u8 *bcdptr; + + bcd[0] = (num->num_of_digit+1)/2 + 1; + bcd[1] = 0x81 | (nai_itu_to_gsm(isdn->nai) << 4); + bcdptr = bcd + 2; + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcdptr = 0xf0 + (num->digit[i] & 0x0f); + else + { + *bcdptr = (num->digit[i] << 4) | (*bcdptr & 0x0f); + bcdptr++; + } + } + return bcd; +} + +/* TBCD: Telephony Binary Coded Decimal (GSM 09.02) */ +int tbcd_to_string(char *str, const u8 *tbcd, u8 tbcd_len) +{ + int i; + u8 max_digits; + u8 digit; + + max_digits = tbcd_len * 2; + for(i = 0; i < max_digits; i++) + { + if((i & 1) == 0) + digit = *tbcd & 0x0f; + else + digit = *(tbcd++) >> 4; + if(is_dail_digit(digit)) + digit_to_char(str[i], digit); + else + break; + } + str[i] = 0; + return i; +} + +isdn_t *tpaddr_to_isdn(isdn_t *isdn, const u8 *tpaddr) +{ + u8 bcd_digits; + u8 digit; + num32_t *num = &isdn->num; + + bcd_digits = tpaddr[0]; + isdn->nai = nai_gsm_to_itu((tpaddr[1] >> 4) & 0x07); + tpaddr += 2; + for(num->num_of_digit = 0; (num->num_of_digit<32)&&(num->num_of_digitnum_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *tpaddr & 0x0f; + else + digit = *(tpaddr++) >> 4; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return isdn; +} + +int string_to_num32(num32_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 32; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num32_to_string(char *str, const num32_t *num) +{ + int i; + + for(i = 0; ((i < 32) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int string_to_num16(num16_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 16; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num16_to_string(char *str, const num16_t *num) +{ + int i; + + for(i = 0; ((i < 16) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int string_to_num8(num8_t *num, const char *str) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 8; num->num_of_digit++, str++) + { + if((*str >= '0') && (*str <= '9')) + digit = *str - '0'; + else if(*str == '*') + digit = 0x0b; + else if(*str == '#') + digit = 0x0c; + else + break; + num->digit[num->num_of_digit] = digit; + } + return num->num_of_digit; +} + +int num8_to_string(char *str, const num8_t *num) +{ + int i; + + for(i = 0; ((i < 8) && (i < num->num_of_digit)); i++) + { + if(num->digit[i] <= 9) + str[i] = num->digit[i] + '0'; + else if(num->digit[i] == 0x0b) + str[i] = '*'; + else if(num->digit[i] == 0x0c) + str[i] = '#'; + } + str[i] = 0; + return i; +} + +int digit_to_netbcd(u8 *netbcd, u8 *digit, u8 max_digit) +{ + int i; + + for(i = 0; i < max_digit; i++) + { + if((i & 1) == 0) + *netbcd = 0xf0 + (digit[i] & 0x0f); + else + { + *netbcd = (digit[i] << 4) | (*netbcd & 0x0f); + netbcd++; + } + } + return (max_digit+1)/2; +} + +int netbcd_to_digit(u8 *digit, u8 *netbcd, u8 max_digit) +{ + int i; + u8 d; + + for(i = 0; i < max_digit; i++) + { + if((i & 1) == 0) + d = *netbcd & 0x0f; + else + d = *(netbcd++) >> 4; + + if(d != 0x0f) + digit[i] = d; + else + break; + } + return i; +} + +void msc_save_lai(u8 *lai, u8 *mcc, u8 *mnc, int lac) +{ + lai[0] = (mcc[1] << 4) + (mcc[0] & 0x0f); + lai[1] = (mnc[2] << 4) | mcc[2]; + lai[2] = (mnc[1] << 4) + (mnc[0] & 0x0f); + lai[3] = lac >> 8; + lai[4] = lac; +} + +void msc_load_lai(u8 *mcc, u8 *mnc, int *lac, u8 *lai) +{ + mcc[0] = lai[0] & 0x0f; + mcc[1] = lai[0] >> 4; + mcc[2] = lai[1] & 0x0f; + mnc[0] = lai[2] & 0x0f; + mnc[1] = lai[2] >> 4; + mnc[2] = lai[1] >> 4; + *lac = (lai[3] << 8) + lai[4]; +} + +#if 0 +/* return the digit counts of number */ +static int bcd_to_num16(num16_t *num, const u8 *bcd) +{ + u8 digit; + + for(num->num_of_digit = 0; num->num_of_digit < 16; num->num_of_digit++) + { + if((num->num_of_digit & 1) == 0) + digit = *bcd >> 4; + else + digit = *(bcd++) & 0x0f; + if(is_dail_digit(digit)) + num->digit[num->num_of_digit] = digit; + else + break; + } + return num->num_of_digit ; +} + +/* return the length of bcd */ +static int num16_to_bcd(u8 *bcd, const num16_t *num) +{ + int i; + + for(i = 0; ((i < 16) && (i < num->num_of_digit)); i++) + { + if((i & 1) == 0) + *bcd = (num->digit[i] << 4) | 0x0f; + else + *(bcd++) = (*bcd & 0xf0) + num->digit[i]; + } + return (i+1)/2; +} +#endif + diff --git a/omc/plat/public_bak/src/uwav/number.h b/omc/plat/public_bak/src/uwav/number.h new file mode 100644 index 0000000..67e893f --- /dev/null +++ b/omc/plat/public_bak/src/uwav/number.h @@ -0,0 +1,79 @@ +#ifndef _UWAV_NUMBER_H +#define _UWAV_NUMBER_H + +#include "../include/public.h" + +/* + * Number type definition: + * 32 digits number is used for party number handling + * 16 digits number is used for prefix parameter + * 8 digits number is used for short number parameter, i.e. cc, ndc + */ +typedef struct number32 { + u8 num_of_digit; + u8 digit[32]; +} num32_t; + +typedef struct number16 { + u8 num_of_digit; + u8 digit[16]; +} num16_t; + +typedef struct number8 { + u8 num_of_digit; + u8 digit[8]; +} num8_t; + +typedef struct isdn_num { + u8 nai; /* Nature of Address Indicator */ +// u8 npi; /* Number Plan Indicator */ + u8 pi; + num32_t num; +} isdn_t; + +struct number_change { + u8 nai; + u8 del_count; + num16_t insert; +}; + +#define is_dail_digit(digit) (digit < 0x0e) +#define char_to_digit(digit, ch) do { \ + if((ch >= '0') && (ch <= '9')) \ + digit = ch - '0'; \ + else if(ch == '*') \ + digit = 0x0b; \ + else if(ch == '#') \ + digit = 0x0c; \ + else \ + break; \ +} while(0) +#define digit_to_char(ch, digit) do { \ + if(digit <= 9) \ + ch = digit + '0'; \ + else if(digit == 0x0b) \ + ch = '*'; \ + else if(digit == 0x0c) \ + ch = '#'; \ +} while(0) + +extern u8 nai_gsm_to_itu(u8 nai); +extern u8 nai_itu_to_gsm(u8 nai); +extern u8 *msc_isdn_to_bcd(u8 *bcd, const isdn_t *isdn); +extern isdn_t *netbcd_to_isdn(isdn_t *isdn, const u8 *bcd); +extern u8 *isdn_to_netbcd(u8 *bcd, const isdn_t *isdn); +extern int tbcd_to_string(char *str, const u8 *tbcd, u8 tbcd_len); +extern isdn_t *tpaddr_to_isdn(isdn_t *isdn, const u8 *tpaddr); +extern int string_to_num32(num32_t *num, const char *str); +extern int num32_to_string(char *str, const num32_t *num); +extern int string_to_num16(num16_t *num, const char *str); +extern int num16_to_string(char *str, const num16_t *num); +extern int string_to_num8(num8_t *num, const char *str); +extern int num8_to_string(char *str, const num8_t *num); +extern int digit_to_netbcd(u8 *netbcd, u8 *digit, u8 max_digit); +extern int netbcd_to_digit(u8 *digit, u8 *netbcd, u8 max_digit); +extern void msc_save_lai(u8 *lai, u8 *mcc, u8 *mnc, int lac); +extern void msc_load_lai(u8 *mcc, u8 *mnc, int *lac, u8 *lai); + +#endif + diff --git a/omc/plat/public_bak/src/uwav/numgrp.c b/omc/plat/public_bak/src/uwav/numgrp.c new file mode 100644 index 0000000..bf507ba --- /dev/null +++ b/omc/plat/public_bak/src/uwav/numgrp.c @@ -0,0 +1,176 @@ +/* + * public/uwav/numgrp.c + * + * Copyright (C) 2008 ADC, Inc + * Written by: Xinyu Yan + * + * Description: number group lookup algorithm + */ + +#include +#include +#include +#include +#include "numgrp.h" + +static struct numgrp_table group_table[MAX_NUMBER_GROUP_TABLE]; + +struct numgrp_table *assign_numgrp_table(char *name, int size) +{ + int i; + + assert(size <= MAX_NUMBER_GROUP_TABLE_SIZE); + + for(i = 0; i < MAX_NUMBER_GROUP_TABLE; i++) + { + if(group_table[i].size == 0) + { + strncpy(group_table[i].name, name, 32); + group_table[i].size = size; + group_table[i].len = 0; + group_table[i].item = malloc(sizeof(struct number_group) * size); + return &group_table[i]; + } + } + return NULL; +} + +int delete_numgrp_table(struct numgrp_table *table) +{ + int i; + + for(i = 0; i < MAX_NUMBER_GROUP_TABLE; i++) + { + if(&group_table[i] == table) + { + free(group_table[i].item); + memset(&group_table[i], 0, sizeof(struct numgrp_table)); + return 1; + } + } + return 0; +} + +/*Return an integer greater than, equal to, or less than 0, if the number pointed to + by n1 is greater than, equal to, or less than the number pointed to by n2, respectively*/ +static int numcmp(const num16_t *n1, const num16_t *n2) +{ + int i; + + if(n1->num_of_digit > n2->num_of_digit) + return 1; + else if(n1->num_of_digit < n2->num_of_digit) + return -1; + for(i = 0; i < n1->num_of_digit; i++) + { + if(n1->digit[i] > n2->digit[i]) + return 1; + else if(n1->digit[i] < n2->digit[i]) + return -1; + } + return 0; +} + +/*Return an integer greater than, equal to, or less than 0, if the number pointed to + by n is greater than, equal to, or less than the group pointed to by start and end, respectively*/ +static int numgrpcmp(const num16_t *start, const num16_t *end, const num16_t *n) +{ + int ret1, ret2; + + ret1 = numcmp(n, start); + ret2 = numcmp(n, end); + if((ret1 >= 0) && (ret2 <= 0)) + return 0; + else if(ret2 > 0) + return 1; + else + return -1; +} + +/* n: max items of table + * num: number being searched + * m: the position of value which is found or will be inserted + * ret: return 1 if found, otherwise 0 +*/ +static int bisearch(struct number_group *item, int n, num16_t *num, int *m) +{ + int i = 0; + int j = n - 1; + int ret; + + *m = 0; + while(i <= j) + { + *m = (i+j) / 2; + ret = numgrpcmp(&item[*m].start, &item[*m].end, num); + if(ret == 0) + return 1; + else if(ret > 0) + i = *m + 1; + else + j = *m - 1; + } + *m = i; + return 0; +} + +int numgrp_search(int *index, struct numgrp_table *table, num16_t *num) +{ + int m; + + if(table == NULL) + return 0; + if(bisearch(table->item, table->len, num, &m)) + { + *index = table->item[m].index; + return 1; + } + return 0; +} + +int numgrp_insert(struct numgrp_table *table, num16_t *start, num16_t *end, int index) +{ + int m, m2; + + if(numcmp(start, end) > 0) + { + printf("Start number > end number\n"); + return 0; + } + if(bisearch(table->item, table->len, start, &m)) + { + printf("Start number in exist group\n"); + return 0; + } + if(bisearch(table->item, table->len, end, &m2)) + { + printf("End number in exist group\n"); + return 0; + } + if(m != m2) + { + printf("Start-end contains other group\n"); + return 0; + } + memmove(&table->item[m+1], &table->item[m], sizeof(struct number_group)*(table->len-m)); + memcpy(&table->item[m].start, start, sizeof(num16_t)); + memcpy(&table->item[m].end, end, sizeof(num16_t)); + table->item[m].index = index; + table->len++; + return 1; +} + +int numgrp_delete(struct numgrp_table *table, num16_t *num) +{ + int m; + + if(bisearch(table->item, table->len, num, &m)) + { + memmove(&table->item[m], &table->item[m+1], sizeof(struct number_group)*(table->len-m-1)); + memset(&table->item[table->len-1], 0, sizeof(struct number_group)); + table->len--; + return 1; + } + return 0; +} + diff --git a/omc/plat/public_bak/src/uwav/numgrp.h b/omc/plat/public_bak/src/uwav/numgrp.h new file mode 100644 index 0000000..1be50a2 --- /dev/null +++ b/omc/plat/public_bak/src/uwav/numgrp.h @@ -0,0 +1,29 @@ +#ifndef _UWAV_NUMGRP_H_ +#define _UWAV_NUMGRP_H_ + +#include "number.h" + +#define MAX_NUMBER_GROUP_TABLE 32 +#define MAX_NUMBER_GROUP_TABLE_SIZE 1024 + +struct number_group { + num16_t start; + num16_t end; + int index; +}; + +struct numgrp_table { + char name[32]; + int size; + int len; + struct number_group *item; +}; + +extern struct numgrp_table *assign_numgrp_table(char *name, int size);/* size: capability of table in unit of records */ +extern int delete_numgrp_table(struct numgrp_table *table); +extern int numgrp_search(int *index, struct numgrp_table *table, num16_t *num); +extern int numgrp_insert(struct numgrp_table *table, num16_t *start, num16_t *end, int index); +extern int numgrp_delete(struct numgrp_table *table, num16_t *num); + +#endif + diff --git a/omc/plat/public_bak/ut/.copyarea.db b/omc/plat/public_bak/ut/.copyarea.db new file mode 100644 index 0000000..9dce3f7 --- /dev/null +++ b/omc/plat/public_bak/ut/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut +2 +8 +9:debug_api|2|0|0|0|83b97213bfa511dc85ad001c23e19543|0 +a:function.c|1|11d70a42de6|668|cbb8c74|832971f7bfa511dc85ad001c23e19543|0 +5:timer|2|0|0|0|7a396fffbfa511dc85ad001c23e19543|0 +4:main|2|0|0|0|7d2970a7bfa511dc85ad001c23e19543|0 +8:bisearch|2|0|0|0|85897267bfa511dc85ad001c23e19543|0 +b:public_test|2|0|0|0|81f971bfbfa511dc85ad001c23e19543|0 +5:asn.1|2|0|0|0|8029714fbfa511dc85ad001c23e19543|0 +4:inet|2|0|0|0|80c97187bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/asn.1/.copyarea.db b/omc/plat/public_bak/ut/asn.1/.copyarea.db new file mode 100644 index 0000000..4ad7d33 --- /dev/null +++ b/omc/plat/public_bak/ut/asn.1/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\asn.1 +2 +1 +9:asntest.c|1|11d70a43112|2613|a2fcc583|8029716bbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/asn.1/asntest.c b/omc/plat/public_bak/ut/asn.1/asntest.c new file mode 100644 index 0000000..4b13d35 --- /dev/null +++ b/omc/plat/public_bak/ut/asn.1/asntest.c @@ -0,0 +1,429 @@ +#include "./include/asn1.h" +#include +#include +#include +int test1(); +int test2(); +int test3(); +int test4(); +int test5(); +int test6(); +int test7(); +int test8(); +int test9(); +int test10(); +int test11(); +int test12(); +int showtlv(const char *tag_seq,ASN_BUF *asnbuf); +int main(int argc,char *argv[]) +{ + if(argc==2) + { + switch(atoi(argv[1])) + { + case 1: + test1(); + break; + case 2: + test2(); + break; + case 3: + test3(); + break; + case 4: + test4(); + break; + case 5: + test5(); + break; + case 6: + test6(); + break; + case 7: + test7(); + break; + case 8: + test8(); + break; + case 9: + test9(); + break; + case 10: + test10(); + break; + case 11: + test11(); + break; + case 12: + test12(); + break; + default: + printf("Out of range!\n"); + } + } + else + printf("Usage:asntest number\n"); + return 0; +} + +int test1() //Tag encoding/decoding test +{ + u_char msg_buf[50]; + int len; + ASN_BUF asnbuf; + + asn_encode(msg_buf,&asnbuf); + + len=add_null("2",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("2",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("32",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("32",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("129",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("129",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("2",0x80,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("2",&asnbuf)==1) + printf("decoding correctly\n"); + + asn_encode(msg_buf,&asnbuf); + + len=add_null("32",0xC0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + if(get_null("32",&asnbuf)==1) + printf("decoding correctly\n"); + + return 1; +} + +int test2() +{ + u_char msg_buf[1024],pvalue[1024]; + ASN_BUF asnbuf; + + memset(pvalue,0xFF,1024); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",0,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",2,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",128,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",129,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + add_tlv("1",257,pvalue,0,&asnbuf); + showbuf(msg_buf,5); + asn_decode(msg_buf,1,&asnbuf); + printf("len=%d\n",get_tlv("1",pvalue,&asnbuf)); + return 1; +} +int test3() +{ + u_char msg_buf[256]; + ASN_BUF asnbuf; + char oid[20]; + int len; + + //Boolean-----> + asn_encode(msg_buf,&asnbuf); + len=add_bool("1",0,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_bool("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_bool("1",1,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_bool("1",&asnbuf)); + //Integer-----> + asn_encode(msg_buf,&asnbuf); + len=add_int("1",2,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",257,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",-2,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + asn_encode(msg_buf,&asnbuf); + len=add_int("1",-259,0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + printf("decoded value:%d\n",get_int("1",&asnbuf)); + + //Object Identifier-----> + asn_encode(msg_buf,&asnbuf); + len=add_oid("1","2.100.6",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + get_oid("1",oid,&asnbuf); + printf("decoded value:%s\n",oid); + + asn_encode(msg_buf,&asnbuf); + len=add_oid("1","0.39.6",0,&asnbuf); + showbuf(msg_buf,len); + asn_decode(msg_buf,1,&asnbuf); + get_oid("1",oid,&asnbuf); + printf("decoded value:%s\n",oid); + return 1; +} +int test4() //encoding test +{ + u_char msg_buf[256]; + int c1=0,c2=1; + u_char d1[2]={0x22,0x22}; + u_char d2[2]={0x33,0x33}; + u_char b3[2]={0x44,0x44}; + u_char a2[2]={0x55,0x55}; + u_char a3[2]={0x66,0x66}; + int len; + ASN_BUF asnbuf; + + asn_encode_v3(msg_buf,128,&asnbuf); + len=add_int("1.0.2-1",c1,0,&asnbuf); + len=add_int("1.0.2-2",c2,0,&asnbuf); + len=add_tlv("1.0.1-3.0",2,d1,0x80,&asnbuf); + len=add_tlv("1.0.1-3.1",2,d2,0x80,&asnbuf); + len=add_tlv("1.1",2,b3,0x80,&asnbuf); + len=add_tlv("2",2,a2,0x80,&asnbuf); + len=add_tlv("3",2,a3,0x80,&asnbuf); + showbuf(msg_buf,len); + printf("decode......\n"); + asn_decode(msg_buf,3,&asnbuf); + showtlv("1.0.2-1",&asnbuf); + showtlv("1.0.2-2",&asnbuf); + showtlv("1.0.1-3.0",&asnbuf); + showtlv("1.0.1-3.1",&asnbuf); + showtlv("1.1",&asnbuf); + showtlv("2",&asnbuf); + showtlv("3",&asnbuf); + return 1; +} + +int test5() //decoding test(long length) +{ + u_char msg_buf[256]={0xA5,0x80, + 0x82,0x80, + 0x83,0x02,0x00,0x00, + 0x00,0x00, + 0x00,0x00, + 0xA6,0x80,0x82,0x02,0x11,0x11,0x00,0x00}; + ASN_BUF asnbuf; + asn_decode(msg_buf,2,&asnbuf); + showtlv("5.2.3",&asnbuf); + showtlv("6.2",&asnbuf); + showtlv("5.2",&asnbuf); + showtlv("6",&asnbuf); + return 1; +} + +int test6() //decoding test(indefinite length) +{ + u_char msg_buf[256]={0xA5,0x80, + 0xA2,0x81,0x82, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A, + 0xA3,0x02,0x01,0x01, + 0x00,0x00, + 0xA6,0x80,0x82,0x02,0x11,0x11,0x00,0x00}; + ASN_BUF asnbuf; + int temp; + asn_decode_v3(msg_buf,256,&temp,&asnbuf); + + showtlv("5.2",&asnbuf); + showtlv("5.3",&asnbuf); + showtlv("5",&asnbuf); + showtlv("6.2",&asnbuf); + return 1; +} + + + +int showtlv(const char *tag_seq,ASN_BUF *asnbuf) +{ + u_char tlvbuf[256]; + int len; + len=get_tlv(tag_seq,tlvbuf,asnbuf); + showbuf(tlvbuf,len); + return 1; +} + +int test7() //decoding test(long length) +{ + u_char msg_buf[256]={0x60,0x80, + 0x80,0x02,0x07,0x80, + 0xa1,0x80, + 0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x01,0x02, + 0x00,0x00, + 0x00,0x00}; + ASN_BUF asnbuf; + asn_decode(msg_buf,1,&asnbuf); + showtlv("0",&asnbuf); + showtlv("0.0",&asnbuf); + showtlv("0.1",&asnbuf); + showtlv("0.1.6",&asnbuf); + return 1; +} + +int test8() //decoding test(long length) +{ + u_char msg_buf[256]={0x10,0x03,0xaa,0xbb,0xcc}; + ASN_BUF asnbuf; + asn_decode(msg_buf,1,&asnbuf); + printf("tlvcount=%d\n",asnbuf.tlvcount); + showtlv("16",&asnbuf); + return 1; +} + +int test9() +{ + u_char msg_buf[256]={0x02,0x01,0xaa, + 0x04,0x02,0xbb,0xbb, + 0x04,0x02,0xcc,0xcc, + 0x04,0x02,0xdd,0xdd, + 0x02,0x01,0xaa, + 0x05,0x02,0x55,0xbb, + 0x05,0x02,0x55,0xcc, + 0x05,0x02,0x55,0xdd}; +// u_char mybuf[64]; +// int len; + int temp; + ASN_BUF asnbuf; + asn_decode_v3(msg_buf,30,&temp,&asnbuf); + + showtlv("2",&asnbuf); + showtlv("4-2",&asnbuf); + showtlv("4-3",&asnbuf); + showtlv("4-4",&asnbuf); + return 1; +} + +int test10() +{ + u_char msg_buf[256]={0xA0,0x80, + 0x04,0x01,0x21, + 0x30,0x80, + 0x30,0x80, + 0x83,0x01,0x11, + 0x84,0x01,0x07, + 0x85,0x05,0x81,0x21,0x84,0x00,0x94, + 0x86,0x01,0x00, + 0x00,0x00, + 0x00,0x00, + 0x00,0x00}; + u_char mybuf[64]; + int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + + len=get_tlv("0",mybuf,&asnbuf); + printf("0:"); + showbuf(mybuf,len); + + len=get_tlv("0.4",mybuf,&asnbuf); + printf("0.4:"); + showbuf(mybuf,len); + + len=get_tlv("0.16",mybuf,&asnbuf); + printf("0.16:"); + showbuf(mybuf,len); + + len=get_tlv("0.16.16.5",mybuf,&asnbuf); + printf("0.16.5:"); + showbuf(mybuf,len); + return 1; +} + +int test11() +{ + u_char msg_buf[256]={0x64,0x6A,0x49 + ,0x04,0x01,0x62,0x00,0x60,0x6B,0x80,0x28,0x80,0x06,0x07,0x00,0x11 + ,0x86,0x05,0x01,0x01,0x01,0xA0,0x80,0x61,0x80,0x80,0x02,0x07,0x80 + ,0xA1,0x80,0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x05,0x02,0x00,0x00 + ,0xA2,0x80,0x02,0x01,0x00,0x00,0x00,0xA3,0x80,0xA1,0x80,0x02,0x01 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x6C,0x26,0xA2,0x80,0x02,0x01,0x00,0x30,0x80,0x02,0x01,0x16,0x30 + ,0x80,0x04,0x08,0x64,0x00,0x92,0x00,0x00,0x00,0x00,0xF1,0x04,0x08 + ,0x91,0x44,0x57,0x25,0x31,0x06,0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 + }; +// u_char mybuf[64]; +// int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + return 1; +} + +int test12() +{ + u_char msg_buf[256]={0xA1,0x0E, + 0x01,0x01,0x01, + 0x02,0x80,0x02,0x01,0x01,0x00,0x00, + 0x02,0x02,0x01,0x02 + }; +// u_char mybuf[64]; +// int len; + ASN_BUF asnbuf; + if(asn_decode(msg_buf,1,&asnbuf)==-1) + printf("decode error\n"); + return 1; +} + diff --git a/omc/plat/public_bak/ut/bisearch/.copyarea.db b/omc/plat/public_bak/ut/bisearch/.copyarea.db new file mode 100644 index 0000000..e51800d --- /dev/null +++ b/omc/plat/public_bak/ut/bisearch/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\bisearch +2 +1 +f:bisearch_test.c|1|11d70a43392|108c|cca11073|86197283bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/bisearch/bisearch_test.c b/omc/plat/public_bak/ut/bisearch/bisearch_test.c new file mode 100644 index 0000000..d9ec9ff --- /dev/null +++ b/omc/plat/public_bak/ut/bisearch/bisearch_test.c @@ -0,0 +1,149 @@ + +/******************************************/ +/*Title : bisearch.h */ +/*Descr : BiSearch arithmetic Tester */ +/*Author : Liu Wei */ +/*Create : 2006-12-13 */ +/*Version : R1V00_01 */ +/*Modify : 2006-12-13 */ +/******************************************/ +#include "../../iptrans/src/include/iptrans.h" +#include "./include/bisearch.h" + +FILE *fp = NULL; +BiSearchArray bsearch_array; + + +int GetIdleNode(int *nDUIndex) +{ + if( bsearch_array.nArrayCount >= bsearch_array.nArrayTotalLen ) + return 0; + *nDUIndex = (rand()*19)%bsearch_array.nArrayTotalLen; + return 1; +} + +void logarray ( BiSearchArray * pBiArray, char *op ) +{ + BiSearch *pBS; + LL lastkey = 0; + int nPos = -1; + char buf[4096]; + char tmp_str[512]; + int i; + buf[0] = '\0'; + + sprintf ( buf, "Array Contents:[total :%d]\n" , pBiArray->nArrayCount); + for ( i = 0; i < pBiArray->nArrayTotalLen; i++ ) + { + pBS = pBiArray->pBiArray + i; + sprintf ( tmp_str, "{%-3u,(%-3llu,%-3u)} ", i, pBS->llKey, pBS->nDUPosIndex ); + strcat ( buf, tmp_str ); + if( i % 6 == 5 ) + { + strcat ( buf, "\n" ); + } + if( lastkey > pBS->llKey && i < pBiArray->nArrayCount ) + nPos = i; + lastkey = pBS->llKey; + } + //if( nPos != -1 ) + { + sprintf ( tmp_str, "\nERR Pos: %d\n\n", nPos ); + strcat ( buf, tmp_str ); + fprintf ( fp, buf ); + } +} + +#define log() logarray( &bsearch_array , op) + +int main ( int argc, char *argv[] ) +{ + + char op[32]; + char buff[64]; + int i; + srand((int)time(0)); + + if( ( fp = fopen ( "./log.txt", "w" ) ) == NULL ) + { + printf ( "Open File Fail\n" ); + return 0; + } + fprintf ( fp, "======================\n" ); + fprintf ( fp, "|| BiSearch Test ||\n" ); + fprintf ( fp, "======================\n\n\n" ); + + for ( i = 0; i < 32; i++ ) + { + op[i] = 'A' + ( i * 3 + 11 ) % 26; + buff[i] = op[i] + ( i * 7 + 19 ) % 26; + } + + BISearchReg ( &bsearch_array, 64 ,GetIdleNode ); + + for ( i = 0; i < 30; i++ ) + { + int key = ( ( i * 11 ) % 5 ) * ( i % 5 ) - 3 * ( i % 11 ) + 39; + int value = (3 * i + 1)%bsearch_array.nArrayTotalLen; + + fprintf ( fp, "Insert(%-3d, %-3d)\n", key, value ); + BISInsert ( &bsearch_array, key, value ); + log(); + } + log(); + + for ( i = 0; i < 128; i++ ) + { + int k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + + k = k % 999; + fprintf ( fp, "=====>>Insert(%d, %d)\n", k, 2 * i ); + BISInsert ( &bsearch_array, k, (2 * i+rand() % 13 * 19 + i*19)%bsearch_array.nArrayTotalLen); + fprintf ( fp, "\n" ); + log(); + + k = ( ( 20 - i ) % 3 ) * 9 - ( 3 * ( 20 - i ) ) + 9*128; + k = k % 999; + fprintf ( fp, "search index: %d" , k ); + if( -1 != GetDUIndex( &bsearch_array ,k ) ) + { + fprintf ( fp, "<<=====Delete Key %d\n", k ); + BISDelete ( &bsearch_array , k ); + } + else + fprintf ( fp, "<<=====Delete Fail , not found [%d]", k ); + fprintf ( fp, "\n" ); + log(); + + } + + for( i = 0 ; i < 128 ; i++ ) + { + int nDUIndex = 0; + int k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + + k = k % 999; + BISSearchMng( &bsearch_array , BIS_INSERT , k , &nDUIndex ); + fprintf ( fp, "=====>>Insert(%d, %d)\n", k, nDUIndex ); + fprintf ( fp, "\n" ); + log(); + + k = ( ( i * 11 ) % 7 ) * ( i % 9 ) - 3 * ( i % 13 ) + i * ( rand ( ) % 13 * 19 ) + 61; + k = k % 999; + fprintf ( fp, "search index: %d" , k ); + if( -1 != GetDUIndex( &bsearch_array ,k ) ) + { + fprintf ( fp, "<<=====Delete Key %d\n", k ); + BISSearchMng( &bsearch_array , BIS_DELETE , k ,&nDUIndex); + } + else + fprintf ( fp, "<<=====Delete Fail , not found [%d]", k ); + + fprintf ( fp, "\n" ); + log(); + + } + //fclose ( fp ); + BISearchUnReg ( &bsearch_array); + return 0; +} diff --git a/omc/plat/public_bak/ut/debug_api/.copyarea.db b/omc/plat/public_bak/ut/debug_api/.copyarea.db new file mode 100644 index 0000000..e6cab1e --- /dev/null +++ b/omc/plat/public_bak/ut/debug_api/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\debug_api +2 +2 +5:debug|1|11d70a432e6|2e60|abcdd68a|8459722fbfa511dc85ad001c23e19543|0 +10:wxc_debug_test.c|1|11d70a43306|96f|ee1769f1|84e9724bbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/debug_api/debug b/omc/plat/public_bak/ut/debug_api/debug new file mode 100644 index 0000000..53d4011 Binary files /dev/null and b/omc/plat/public_bak/ut/debug_api/debug differ diff --git a/omc/plat/public_bak/ut/debug_api/wxc_debug_test.c b/omc/plat/public_bak/ut/debug_api/wxc_debug_test.c new file mode 100644 index 0000000..e1e18e5 --- /dev/null +++ b/omc/plat/public_bak/ut/debug_api/wxc_debug_test.c @@ -0,0 +1,125 @@ +////////////////////////////////////////////////// +//Title : wxc_debug.c +//Auhtor : Liu Wei +//Desc : wxc debug api implemetation +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#include "stdio.h" +#include "assert.h" +#include "string.h" +#include "stdlib.h" +#include +#include + +void dump(int signo) +{ + char buf[1024]; + char cmd[1024]; + FILE *fh; + + snprintf(buf, sizeof(buf), "/proc/%d/cmdline", getpid()); + if(!(fh = fopen(buf, "r"))) + exit(0); + if(!fgets(buf, sizeof(buf), fh)) + exit(0); + fclose(fh); + if(buf[strlen(buf) - 1] == '\n') + buf[strlen(buf) - 1] = '\0'; + snprintf(cmd, sizeof(cmd), "gdb %s %d", buf, getpid()); + system(cmd); + + exit(0); +} + +void WxcBackTrace() +{ + int i; + void * array[25]; + int nSize = backtrace(array, 25); + char ** symbols = backtrace_symbols(array, nSize); + + for (i = 0; i < nSize; i++) + { + printf("%s \n" , symbols[i]); + } + free(symbols); +} + +typedef unsigned char BYTE; + +#define WxcAssert(uVal,pStr) \ + if(!(uVal)) \ + { \ + WxcBackTrace(); \ + } \ + assert( uVal && pStr ); \ + +void sprintf_bcd( const BYTE *pBcdBuff , int nBcdLen , char *pStrBuff , int nStrBuffSize ) +{ + int i ,len = 0; + int nChar; + + nChar = ( nBcdLen % 8 )* 3 + ( nBcdLen / 8 ) * 25 + 1 ; + + WxcAssert((nChar < nStrBuffSize),"sprint bcd string buffer flow"); + + for( i = 1 ; i <= nBcdLen; i ++ ) + { + sprintf ( pStrBuff + len , "%02X ", pBcdBuff[i-1] ); + len += 3; + if( 0 == (i % 16) ) + { + strcat ( pStrBuff , "\n"); + len++; + } + else if( 0 == (i % 8) ) + { + strcat ( pStrBuff , " "); + len++; + } + } + if( 0 != (len % 50) ) + { + strcat ( pStrBuff , "\n"); + } +} + +void testdump(char *p) +{ + *p =0; +} + +void main() +{ + BYTE aBCDBuff[128]; + char temp[256] ; + int i , j; + char *p ; + + p = NULL; + + signal(SIGSEGV, &dump); + + for( i = 0 ; i < 128 ; i ++ ) + { + if( i < 80 ) + aBCDBuff[i] = (BYTE)(1 + i) ; + else + aBCDBuff[i] = (BYTE)(256 - i*2) ; + } + + for( j = 30 ; j < 100 ; j+=7 ) + { + sprintf_bcd(aBCDBuff , j , temp , 256 ); + printf("BCD:\r\n%s\r\n", temp); + } + + testdump(p); + getchar(); +} diff --git a/omc/plat/public_bak/ut/function.c b/omc/plat/public_bak/ut/function.c new file mode 100644 index 0000000..668baf8 --- /dev/null +++ b/omc/plat/public_bak/ut/function.c @@ -0,0 +1,87 @@ +/* public function c file */ +/* written by Liu Zhiguo 2002-03-26 */ +/* version 1.0 */ +/* -------------------------------- */ + +#include "./include/includes.h" +#include "./include/public.h" +#include "./include/pub_debug.h" + +# ifndef S_SPLINT_S +/*@ignore@*/ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer ascii code to bcd code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* +void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len) +{ + int i; + char ch; + char flag=0; + + if (ascii_buf == NULL) + { + for (i=0;i='a') + ch -= 'a' - 10; + else if (ch>='A') + ch -= 'A' - 10; + else + ch -= '0'; + if (flag) + { + if (i & 1) + *bcd_buf = ch << 4; + else + *(bcd_buf++) |= ch & 0x0f; + } + else + { + if (i & 1) + *(bcd_buf++) |= ch & 0x0f; + else + *bcd_buf = ch << 4; + } + } +} +*/ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* transfer bcd code to ascii code */ +/* ++++++++++++++++++++++++++++++++++++++ */ +/* +void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len) +{ + int i; + char ch; + + if (bcd_buf == NULL) + { + for (i=0;i> 4; + ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0'); + } + ascii_buf[i] = '\0'; +} +*/ + +/*@end@*/ +#endif diff --git a/omc/plat/public_bak/ut/inet/.copyarea.db b/omc/plat/public_bak/ut/inet/.copyarea.db new file mode 100644 index 0000000..aef0bf6 --- /dev/null +++ b/omc/plat/public_bak/ut/inet/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\inet +2 +1 +f:pub_inet_test.c|1|11d70a431ae|39db|347d6bfe|815971a3bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/inet/pub_inet_test.c b/omc/plat/public_bak/ut/inet/pub_inet_test.c new file mode 100644 index 0000000..789ea3f --- /dev/null +++ b/omc/plat/public_bak/ut/inet/pub_inet_test.c @@ -0,0 +1,646 @@ +////////////////////////////////////////////////// +//Title : pub_inet_test.c +//Auhtor : Liu Wei +//Desc : public ipnet function test +//Created : 2007-06-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef unsigned char u8; +typedef unsigned int u32; +typedef unsigned short u16; + +#define MAXINTERFACES 16 + +typedef struct EIF +{ + u32 dIfIP; + u8 uIfState; +} +EIF; + +typedef struct IF_ADDR +{ + EIF tIfEntity[MAXINTERFACES]; + u8 uIfNum; +} +IfAddr; + +int GetNetIfInfo ( IfAddr * pIfAddr ) +{ + int fd; + struct ifreq buf[MAXINTERFACES]; + struct arpreq arp; + struct ifconf ifc; + + pIfAddr->uIfNum = 0; + + if( ( fd = socket ( AF_INET, SOCK_DGRAM, 0 ) ) >= 0 ) + { + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = ( caddr_t ) buf; + if( !ioctl ( fd, SIOCGIFCONF, ( char * ) &ifc ) ) + { + int i; + + pIfAddr->uIfNum = ifc.ifc_len / sizeof ( struct ifreq ); + pIfAddr->uIfNum = pIfAddr->uIfNum % MAXINTERFACES; + for ( i = 0; i < pIfAddr->uIfNum; i++ ) + { + ioctl ( fd, SIOCGIFFLAGS, ( char * ) &buf[i] ); + pIfAddr->tIfEntity[i].uIfState = buf[i].ifr_flags & IFF_UP; + if( !( ioctl ( fd, SIOCGIFADDR, ( char * ) &buf[i] ) ) ) + { + pIfAddr->tIfEntity[i].dIfIP = ( ( struct sockaddr_in * ) + ( &buf[i].ifr_addr ) )->sin_addr.s_addr; + } + } + } + + } + close ( fd ); + return pIfAddr->uIfNum; +} + + +#define PACKET_SIZE 4096 +#define MAX_NO_PACKETS 3 + +struct sockaddr_in dest_addr; +struct sockaddr_in from; +struct timeval tvrecv; + +typedef void PingCallBack( int nPingResult ); + +typedef struct ICMP_SERVICE +{ + u8 uSrvState; + u8 uPingResult; + u8 uIcmpState; + u8 uPackNo; + u8 uDataLen; + u8 nPackNumSend; + u8 nPackNumRecv; + u8 aSendBuff[PACKET_SIZE]; + u8 aRecvBuff[PACKET_SIZE]; + u32 wSockfd; + pid_t tPid; + struct protoent *pProtoent; + PingCallBack *fCallBack; +} +IcmpSrv; + +IcmpSrv tIcmpSrvEntity; + +//校验和算法 +u16 IcmpCheckSum ( u16 *addr, int len ) +{ + int nleft = len; + int sum = 0; + u16 *w = addr; + u16 answer = 0; + + //把ICMP报头二进制数据以2字节为单位累加起来 + while ( nleft > 1 ) + { + sum += *w++; + nleft -= 2; + } + + //若ICMP报头为奇数个字节,会剩下最后一字节。 + //把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加 + if( nleft == 1 ) + { + *( unsigned char * ) ( &answer ) = *( unsigned char * ) w; + sum += answer; + } + + sum = ( sum >> 16 ) + ( sum & 0xffff ); + sum += ( sum >> 16 ); + answer = ~sum; + + return answer; +} + +//设置ICMP报头 +int IcmpPacking ( IcmpSrv *pIS ) +{ + int i, packsize; + struct icmp *icmp; + struct timeval *tval; + + icmp = ( struct icmp * ) pIS->aSendBuff; + icmp->icmp_type = ICMP_ECHO; + icmp->icmp_code = 0; + icmp->icmp_cksum = 0; + icmp->icmp_seq = pIS->nPackNumSend; + icmp->icmp_id = pIS->tPid; + packsize = 8 + pIS->uDataLen; + + //记录发送时间 + tval = ( struct timeval * ) icmp->icmp_data; + gettimeofday ( tval, NULL ); + + icmp->icmp_cksum = IcmpCheckSum ( (u16 *)icmp, packsize ); + + return packsize; +} + +//剥去ICMP报头 +int IcmpUnPack ( u8 *buf, int len , IcmpSrv *pIS ) +{ + int i, nIpHdrLen; + struct ip *pIP; + struct icmp *icmp; + struct timeval *tvSend; + struct timeval tvRecv; + double rtt; + + + gettimeofday ( &tvRecv, NULL ); + pIP = ( struct ip * ) buf; + //求ip报头长度,即ip报头的长度标志乘4 + nIpHdrLen = pIP->ip_hl << 2; + + //越过ip报头,指向ICMP报头 + icmp = ( struct icmp * ) ( buf + nIpHdrLen ); + + //ICMP报头及ICMP数据报的总长度 + len -= nIpHdrLen; + + if( len < 8 ) + //小于ICMP报头长度则不合理 + { + printf ( "ICMP packets's length is less than 8 " ); + return 0; + } + + //确保所接收的是我所发的的ICMP的回应 + if( ( icmp->icmp_type == ICMP_ECHOREPLY ) && ( icmp->icmp_id == pIS->tPid ) ) + { + tvSend = ( struct timeval * ) icmp->icmp_data; + + rtt = ( tvRecv.tv_sec * 1000 + tvRecv.tv_usec / 1000 ) - + ( tvSend->tv_sec * 1000 + tvSend->tv_usec / 1000 ); + + printf ( "%d byte from %s: icmp_seq=%u ttl=%d rtt=%.3f ms \n" + , len, inet_ntoa ( from.sin_addr ) + , icmp->icmp_seq, pIP->ip_ttl, rtt + ); + return 1; + } + return 0; +} + +void IcmpStatis ( IcmpSrv *pIS ) +{ + int nSend , nRecv ; + + nSend = pIS->nPackNumSend; + nRecv = pIS->nPackNumRecv; + + printf ( " --------------------PING statistics------------------- \n" ); + printf ( "%d packets transmitted, %d received , %%%d lost \n\n" + , nSend, nRecv, ( nSend - nRecv ) / nSend * 100 ); + close ( pIS->wSockfd ); + pIS->uSrvState = 0; +} + +//发送三个ICMP报文 +int IcmpSend ( IcmpSrv *pIS ) +{ + int nSize; + + if ( pIS->nPackNumSend < MAX_NO_PACKETS ) + { + pIS->nPackNumSend++; + nSize = IcmpPacking ( pIS ); + + //设置ICMP报头 + if( sendto ( pIS->wSockfd, pIS->aSendBuff, nSize, 0, + ( struct sockaddr * ) &dest_addr, sizeof ( dest_addr ) ) < 0 ) + { + perror ( "sendto error" ); + return 0; + } + printf("[IcmpSend] : Send icmp Pack %d \n" , pIS->nPackNumSend); + return 1; + } + return 0; +} + +//接收所有ICMP报文 +void IcmpRecv ( IcmpSrv *pIS ) +{ + int n, fromlen; + extern int errno; + + + fromlen = sizeof ( from ); + while ( pIS->nPackNumRecv < pIS->nPackNumSend ) + { + if( ( n = recvfrom ( pIS->wSockfd, pIS->aRecvBuff, sizeof ( pIS->aRecvBuff ), + 0, ( struct sockaddr * ) &from, &fromlen ) ) < 0 ) + + { + if( errno == EINTR ) + continue; + perror ( "recvfrom error" ); + continue; + } + if( IcmpUnPack ( pIS->aRecvBuff, n , pIS ) == -1 ) + continue; + pIS->nPackNumRecv++; + } +} + +int PingInit ( IcmpSrv *pIS , int nDataLen ) +{ + memset( pIS , 0 , sizeof(IcmpSrv) ); + pIS->uSrvState = 0; + + pIS->uDataLen = 56; + + + if( ( pIS->pProtoent = getprotobyname ( "icmp" ) ) == NULL ) + { + perror ( "getprotobyname" ); + exit ( 1 ); + } + + // 回收root权限,设置当前用户权限 + setuid ( getuid ( ) ); + + //获取main的进程id,用于设置ICMP的标志符 + pIS->tPid = getpid ( ); + +} + + +int PingTimer ( IcmpSrv *pIS ) +{ + if( pIS->uSrvState ) + { + IcmpRecv( pIS ); + switch( pIS->uIcmpState ) + { + case 1: + case 2: + case 3: + IcmpSend( pIS ); + pIS->uIcmpState++; + break; + default: + if( pIS->nPackNumRecv >= 3 ) + { + IcmpStatis( pIS ); + pIS->fCallBack( 1 ); + } + if( pIS->uIcmpState++ > 200 ) + { + IcmpStatis( pIS ); + pIS->fCallBack( 0 ); + } + break; + } + } +} + +int PingStart( IcmpSrv *pIS , char *sIP , PingCallBack fCallBack ) +{ + int nSize; + struct hostent *pHost; + //struct in_addr *pInAddr; + u32 nInetAddr; + + + if( pIS->uSrvState ) + { + return 0; + } + + pIS->fCallBack = fCallBack; + + //生成使用ICMP的原始套接字,这种套接字只有root才能生成 + if( ( pIS->wSockfd = socket ( AF_INET, SOCK_RAW, pIS->pProtoent->p_proto ) ) < 0 ) + { + perror ( "socket error" ); + exit ( 1 ); + } + + //扩大套接字接收缓冲区到50K这样做主要为了减小接收缓冲区溢出的 + //的可能性, 若无意中ping会引来大量应答 + setsockopt ( pIS->wSockfd, SOL_SOCKET, SO_RCVBUF, &nSize, sizeof ( nSize ) ); + bzero ( &dest_addr, sizeof ( dest_addr ) ); + dest_addr.sin_family = AF_INET; + + //判断是主机名还是ip地址 + nInetAddr = inet_addr ( sIP ) ; + if( nInetAddr == INADDR_NONE ) + { + if( ( pHost = gethostbyname ( sIP ) ) == NULL ) //是主机名 + { + perror ( "gethostbyname error" ); + exit ( 1 ); + } + memcpy ( ( char * ) &dest_addr.sin_addr, pHost->h_addr, pHost->h_length ); + } + else //是ip地址 + { + dest_addr.sin_addr.s_addr = nInetAddr; + //memcpy( (char *)&dest_addr,(char *)&nInetAddr,host->h_length); + } + printf ( "PING %s(%s): %d bytes data in ICMP packets. \n", sIP + , inet_ntoa ( dest_addr.sin_addr ) , pIS->uDataLen ); + + pIS->uSrvState = 1 ; + pIS->uIcmpState = 1; + +} + +//打印ip报文的信息 +void printIP ( char *packet, int len ) +{ + struct sockaddr_in addr_src, addr_dst; + struct ip *pip = ( struct ip * ) packet; + + printf ( "ip head len:%d ", pip->ip_hl << 2 ); + printf ( "ip len:%d ", ntohs ( pip->ip_len ) ); + printf ( "ip pro id:%d ", pip->ip_p ); + printf ( "ip ttl:%d ", pip->ip_ttl ); + printf ( "ip offset:%d ", ntohs ( pip->ip_off ) & IP_OFFMASK ); + + memset ( &addr_src, 0, sizeof ( struct sockaddr_in ) ); + memset ( &addr_dst, 0, sizeof ( struct sockaddr_in ) ); + memcpy ( &addr_src, &pip->ip_src, sizeof ( struct sockaddr_in ) ); + memcpy ( &addr_dst, &pip->ip_dst, sizeof ( struct sockaddr_in ) ); + printf ( "src ip:%x ", addr_src.sin_addr ); + printf ( "dst ip:%x ", addr_dst.sin_addr ); +} + +void NetCapPing( int nRet ) +{ + if( nRet ) + { + printf("Host is rearchable\n"); + } + else + { + printf("Host is not rearchable\n"); + } +} + +static char *pStrEqTok = NULL; +static u8 uStrEqState = 0; + +#define CNULL '\0' +#define STR_CHECK_END(str,ch) ( str[strlen(str)-1] == ch ) +#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL ) + +void StrTrimMoreSpace(char *pStr ) +{ + char *pSrc , *pDst , *pCh; + + pDst = pStr; + pCh = pSrc = strdup( pStr ); + + for( ; *pSrc ; pSrc++ ) + { + if( !( isspace(*pSrc) && isspace( *(pSrc+1) ) ) ) + { + *pDst++ = *pSrc; + } + } + *pDst = CNULL; +} + +char *StrEqTok( char *pStr ) +{ + char *p, *pCh; + char *pDel = " "; + + pCh = NULL; + + if( pStr == NULL ) + { + pStr = pStrEqTok; + } + else + { + pStr += strspn (pStr, pDel); + if (*pStr == '\0') + { + pStrEqTok = NULL; + return NULL; + } + StrTrimMoreSpace( pStr ); + } + + if( pStr == NULL ) + { + return NULL; + } + + uStrEqState = uStrEqState > 2 ? 0 : uStrEqState; + + pCh = strpbrk (pStr, pDel ); + if( pCh == NULL ) + { + pStrEqTok = NULL; + pCh = pStr; + } + else + { + pStrEqTok = pCh + 1; + *pCh = CNULL; + pCh = pStr; + } + + p = strchr( pCh , '='); + if( p == NULL ) + { + if( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + + if( uStrEqState == 0 || uStrEqState == 2 ) + { //expres left and right + uStrEqState++; + return pCh; + } + else + { //Miss '=' + goto STREQTOK_CLEAN_UP; + } + } + else + { + if( uStrEqState == 0 && STR_CHECK_END( pCh , '=') ) + { //expres left and '=' + uStrEqState+=2; + STR_CUT_LAST(pCh); + return pCh; + } + else if( uStrEqState == 1 && pCh[0] == '=') + { //'=' meet + if( pCh[1] == CNULL ) + { + if( pStrEqTok == NULL ) + { + goto STREQTOK_CLEAN_UP; + } + pStr = pStrEqTok; + pCh = strpbrk (pStr, pDel); + if( pCh == NULL ) + { + pStrEqTok = NULL; + pCh = pStr; + } + else + { + pStrEqTok = pCh + 1; + *pCh = CNULL; + pCh = pStr; + } + uStrEqState = 3; + return pCh; + + } + else + { //expres '=' and right + uStrEqState = 3; //all meet + return ++pCh; + } + } + else if( uStrEqState == 0 ) + { //expres left and '=' and right + if( pStrEqTok != NULL ) + { + *(pStrEqTok -1) = ' '; + } + pStrEqTok = p + 1; + *p = CNULL; + uStrEqState = 2; + return pCh; + } + else + { + goto STREQTOK_CLEAN_UP; + } + } +STREQTOK_CLEAN_UP: + pStrEqTok = NULL; + uStrEqState = 0; + return NULL; +} + + +int main ( ) +{ + int i, ret = 0; + IfAddr tIfAddr; + IcmpSrv tIcmpSrv; + char tmpStr[80]; + + ret = GetNetIfInfo ( &tIfAddr ); + + printf ( "Interface num :%d \n\n", ret ); + for ( i = 0; i < ret; i++ ) + { + printf ( "If %d : state : %d ip : %s \n\n" + , i, tIfAddr.tIfEntity[i].uIfState + , inet_ntoa ( *((struct in_addr* )&tIfAddr.tIfEntity[i].dIfIP )) + ); + } + + #define STR(s) #s + printf(STR(if(NOTSO(a)) return 0\n)); + + #define FPOS( type, field ) /*lint -e545 */ ( (u32) &(( type *) 0)-> field ) /*lint +e545 */ + + + #define FSIZ( type, field ) sizeof( ((type *) 0)->field ) + + printf("Pos : %ld \n" , FPOS(IfAddr ,uIfNum ) ); + printf("Size : %ld \n" , FSIZ(IfAddr ,uIfNum ) ); + printf("Pos : %ld \n" , FPOS(IfAddr ,tIfEntity ) ); + printf("Size : %ld \n" , FSIZ(IfAddr ,tIfEntity ) ); + printf("Pos : %ld \n" , FPOS(EIF ,dIfIP ) ); + printf("Size : %ld \n" , FSIZ(EIF ,dIfIP ) ); + printf("Pos : %ld \n" , FPOS(EIF ,uIfState ) ); + printf("Size : %ld \n" , FSIZ(EIF ,uIfState ) ); + printf("Pos : %ld \n" , FPOS(IcmpSrv ,nPackNumSend ) ); + printf("Size : %ld \n" , FSIZ(IcmpSrv ,nPackNumSend ) ); + printf("Pos : %ld \n" , FPOS(IcmpSrv ,aSendBuff ) ); + printf("Size : %ld \n" , FSIZ(IcmpSrv ,aSendBuff ) ); + + printf("Please input ip and port : "); + + fgets( tmpStr, 80 ,stdin ); + + printf("%s\n", tmpStr); + if( STR_CHECK_END(tmpStr , '\n' ) ) + { + STR_CUT_LAST(tmpStr ); + } + //StrTrimMoreSpace(tmpStr); + //printf("trim space : \n%s\n" ,tmpStr ); + + { + char *p = NULL; + u8 uFlag = 0; + + p = StrEqTok(tmpStr); + printf( "Name: %-20s " , p); + for( ; p = StrEqTok(NULL); ) + { + uFlag = uFlag ? 0 : 1; + if( uFlag ) + { + printf( "Valu: %-20s \n" , p); + } + else + { + printf( "Name: %-20s " , p); + } + } + } + printf("\n\n"); + PingInit( &tIcmpSrv , 56 ); + + ret = PingStart( &tIcmpSrv , "172.18.99.1" , NetCapPing ); + if( !ret ) + { + printf("ping is processing\n"); + } + + while(1) + { + PingTimer( &tIcmpSrv ); + sleep ( 1 ); + //每隔一秒发送一个ICMP报文 + } + return 1; +} diff --git a/omc/plat/public_bak/ut/main/.copyarea.db b/omc/plat/public_bak/ut/main/.copyarea.db new file mode 100644 index 0000000..3718749 --- /dev/null +++ b/omc/plat/public_bak/ut/main/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\main +2 +4 +3:obj|2|0|0|0|7f997133bfa511dc85ad001c23e19543|0 +3:bin|2|0|0|0|7e5970fbbfa511dc85ad001c23e19543|0 +3:src|2|0|0|0|7d2970c3bfa511dc85ad001c23e19543|0 +8:Makefile|1|11d70a42fba|b37|96ac37a|7ef97117bfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/main/Makefile b/omc/plat/public_bak/ut/main/Makefile new file mode 100644 index 0000000..6c0aba1 --- /dev/null +++ b/omc/plat/public_bak/ut/main/Makefile @@ -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 = publictest +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = exef +CFG = debug + +PLT_LIB = public +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../../../plat +APP_PATH = ../../../../mss + +OBJ_ADD = +TEST_OBJ_PATH = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = on +COVER_NEED = +COVER_REPORT_PATH = ./ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules + + + diff --git a/omc/plat/public_bak/ut/main/src/.copyarea.db b/omc/plat/public_bak/ut/main/src/.copyarea.db new file mode 100644 index 0000000..a9661eb --- /dev/null +++ b/omc/plat/public_bak/ut/main/src/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\main\src +2 +1 +6:main.c|1|11d70a43066|17c|99d76577|7dc970dfbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/main/src/main.c b/omc/plat/public_bak/ut/main/src/main.c new file mode 100644 index 0000000..9a82b94 --- /dev/null +++ b/omc/plat/public_bak/ut/main/src/main.c @@ -0,0 +1,19 @@ +////////////////////////////////////////////////// +//Title : main.c +//Auhtor : Liu Wei +//Desc : public function test +//Created : 2007-06-24 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "../../src/include/includes.h" +#include "../../src/include/public.h" +#include "../../src/include/function.h" + +int main() +{ + return 1; +} diff --git a/omc/plat/public_bak/ut/public_test/.copyarea.db b/omc/plat/public_bak/ut/public_test/.copyarea.db new file mode 100644 index 0000000..c629b00 --- /dev/null +++ b/omc/plat/public_bak/ut/public_test/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\public_test +2 +1 +d:public_test.c|1|11d70a4325a|ff|b2a744c6|828971dbbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/public_test/public_test.c b/omc/plat/public_bak/ut/public_test/public_test.c new file mode 100644 index 0000000..e91d7c7 --- /dev/null +++ b/omc/plat/public_bak/ut/public_test/public_test.c @@ -0,0 +1,15 @@ +/* public test c file */ +/* Written by Liu Zhiguo 2002-03-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "./include/includes.h" +#include "./include/public.h" +#include "./include/function.h" + + + +int main() +{ + return 1; +} diff --git a/omc/plat/public_bak/ut/timer/.copyarea.db b/omc/plat/public_bak/ut/timer/.copyarea.db new file mode 100644 index 0000000..129456b --- /dev/null +++ b/omc/plat/public_bak/ut/timer/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\public\ut\timer +2 +5 +3:doc|2|0|0|0|7ac97037bfa511dc85ad001c23e19543|0 +2:ut|2|0|0|0|7ac9701bbfa511dc85ad001c23e19543|0 +3:bin|2|0|0|0|7b697053bfa511dc85ad001c23e19543|0 +8:Makefile|1|11d70a42ed0|681|ff89a13d|7bf9706fbfa511dc85ad001c23e19543|0 +c:wxc_tmtest.c|1|11d70a42eff|b53|1a60310a|7c99708bbfa511dc85ad001c23e19543|0 diff --git a/omc/plat/public_bak/ut/timer/Makefile b/omc/plat/public_bak/ut/timer/Makefile new file mode 100644 index 0000000..b1b556c --- /dev/null +++ b/omc/plat/public_bak/ut/timer/Makefile @@ -0,0 +1,72 @@ + +##----------------------------------------------------------## +## ## +## Universal Makefile for wxc2 module ## +## --By Wei Liu 2007/04/11 ## +## ## +##----------------------------------------------------------## + + +##-------------------------------------- +## +## Project correlation(Customer define) +## +##-------------------------------------- + +##Module Name +MODULE = tmtest + +#BUILD = lib/exef +BUILD = exef + +#CFG = debug / release +CFG = debug + +#Source file path +SRC_PATH= ./ + +#include file path +INC_PATH= ./ + +#extend wxc2plat module lib need +WXC2_PLT_LIB= public + +#extend wxc2plat module lib need +WXC2_APP_LIB= + +#extend wxc2plat path default to ./wxc2plat +WXC2_PLT_PATH = ../../../../wxc2plat + +#extend wxc2plat path default to ./wxc2app +WXC2_APP_PATH = + +#extend obj needed +CFG_OBJ = + +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +#gcc flag show on/off +CCFLAG_SWITCH = on + +#customer debug version flag add for compile +DEBUG_CFLAGS_ADD = -D_MSCR83 -D_DEVELOPER + +#customer release version flag add for compile +RELEASE_CFLAGS_ADD = -D_MSCR83 + +#need cover fucntion of PTF for test = YES/NO +COVER_NEED = + +#cover fucntion output path of PTF for test +COVER_REPORT_PATH = ./ut/ut_doc/output + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/public_bak/ut/timer/wxc_tmtest.c b/omc/plat/public_bak/ut/timer/wxc_tmtest.c new file mode 100644 index 0000000..17c74e3 --- /dev/null +++ b/omc/plat/public_bak/ut/timer/wxc_tmtest.c @@ -0,0 +1,155 @@ + +#include "assert.h" +#include "../../src/include/includes.h" +#include "../../src/include/public.h" +#include "../../src/include/wxc_timer.h" + + +u32 hlr_timer_flag; +u32 hlr_20ms_flag; + +void system_init ( void ) +{ + sleep ( 3 ); + hlr_timer_flag = 0; + hlr_20ms_flag = 0; +} + +void timer_callback ( ) +{ + hlr_20ms_flag++; + hlr_timer_flag++; + printf("10 ms call back : %d\n" , hlr_timer_flag); +} + +void set_timer ( ) +{ + struct sigaction act; + struct itimerval value; + struct itimerval old_value; + + value.it_interval.tv_sec = 0; + value.it_interval.tv_usec = 10000; // 10 ms + value.it_value.tv_sec = 0; + value.it_value.tv_usec = 10000; // 10 ms + act.sa_handler = timer_callback; + sigemptyset ( &act.sa_mask ); + act.sa_flags = 0; + if( sigaction ( SIGALRM, &act, NULL ) == -1 ) + { + printf ( "Timer error\n" ); + exit ( 0 ); + } + setitimer ( ITIMER_REAL, &value, &old_value ); + iopl ( 3 ); +} + +void tm_app_callback_10ms ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_1s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_50s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + +void tm_app_callback_5000s ( u16 dSuitId, u16 dData ) +{ + printf("10 ms call back\n"); +} + + +void tm_app_init ( ) +{ + +} + +int app_state; +WxcTimer tTimer10ms; +WxcTimer tTimer1s; +WxcTimer tTimer50s; +WxcTimer tTimer5000s; + +typedef enum TMTEST_STATE +{ + APP_REGSITER, + APP_START, + APP_TIMEROUT, + APP_STOP, +} +TM_STATE; + + +void tm_app_test ( ) +{ + + + switch ( app_state ) + { + case APP_REGSITER: + tTimer10ms.dExpires = 1; + tTimer10ms.dSuitNumber = 1; + tTimer10ms.pFunc = &tm_app_callback_10ms; + tTimer10ms.dData = 0; + TimerAdd ( &tTimer10ms ); + + tTimer1s.dExpires = 100; + tTimer1s.dSuitNumber = 10; + tTimer1s.pFunc = &tm_app_callback_1s; + tTimer1s.dData = 0; + TimerAdd ( &tTimer1s ); + + tTimer50s.dExpires = 5000; + tTimer50s.dSuitNumber = 100; + tTimer50s.pFunc = &tm_app_callback_50s; + tTimer50s.dData = 0; + TimerAdd ( &tTimer50s ); + + tTimer5000s.dExpires = 5000000; + tTimer5000s.dSuitNumber = 10; + tTimer5000s.pFunc = &tm_app_callback_5000s; + tTimer5000s.dData = 0; + TimerAdd ( &tTimer5000s ); + app_state++; + break; + + case APP_START: + app_state++; + break; + + case APP_TIMEROUT: + + TimerAdd ( &tTimer50s ); + app_state++; + break; + case APP_STOP: + + TimerAdd ( &tTimer50s ); + app_state++; + break; + default: + break; + } +} + + +int main ( int argc, char *argv[] ) +{ + + system_init ( ); + + set_timer ( ); + + while ( 1 ) + { + usleep ( 1 ); + tm_app_test ( ); + } + return 1; +} diff --git a/omc/plat/rtp/.copyarea.db b/omc/plat/rtp/.copyarea.db new file mode 100644 index 0000000..421098b --- /dev/null +++ b/omc/plat/rtp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\rtp +2 +5 +3:doc|2|0|0|0|89b96bc8bfa511dc85d9001c23e19543|0 +2:ut|2|0|0|0|92096d50bfa511dc85d9001c23e19543|0 +3:src|2|0|0|0|8b796c1cbfa511dc85d9001c23e19543|0 +8:Makefile|1|11d70a4342e|b30|84a2bfc7|8ae96c00bfa511dc85d9001c23e19543|0 +3:lib|2|0|0|0|8a496be4bfa511dc85d9001c23e19543|0 diff --git a/omc/plat/rtp/Makefile b/omc/plat/rtp/Makefile new file mode 100644 index 0000000..ed316cb --- /dev/null +++ b/omc/plat/rtp/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = rtp +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/rtp/lib/librtp.a b/omc/plat/rtp/lib/librtp.a new file mode 100644 index 0000000..e17d9b5 Binary files /dev/null and b/omc/plat/rtp/lib/librtp.a differ diff --git a/omc/plat/rtp/obj/rtp.o b/omc/plat/rtp/obj/rtp.o new file mode 100644 index 0000000..752aaee Binary files /dev/null and b/omc/plat/rtp/obj/rtp.o differ diff --git a/omc/plat/rtp/obj/rtp_msg.o b/omc/plat/rtp/obj/rtp_msg.o new file mode 100644 index 0000000..4cdcfda Binary files /dev/null and b/omc/plat/rtp/obj/rtp_msg.o differ diff --git a/omc/plat/rtp/src/.copyarea.db b/omc/plat/rtp/src/.copyarea.db new file mode 100644 index 0000000..ea14062 --- /dev/null +++ b/omc/plat/rtp/src/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\rtp\src +2 +3 +5:rtp.c|1|11d70a434ea|21cb|e12a575c|a3d47f36e04911dc8167001c23e19543|0 +7:include|2|0|0|0|8ca96c54bfa511dc85d9001c23e19543|0 +9:rtp_msg.c|1|11d70a43538|d6f|7ba31f4c|170574fea3f011dd8f4b001c23e19543|0 diff --git a/omc/plat/rtp/src/include/.copyarea.db b/omc/plat/rtp/src/include/.copyarea.db new file mode 100644 index 0000000..e331589 --- /dev/null +++ b/omc/plat/rtp/src/include/.copyarea.db @@ -0,0 +1,11 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\rtp\src\include +2 +7 +9:rtp_ext.h|1|11d70a436af|1fb|91cca451|90496cfcbfa511dc85d9001c23e19543|0 +b:rtp_const.h|1|11d70a43603|ae|d5853214|cbc07327ceff11dc829f001c23e19543|0 +9:rtp_msg.h|1|11d70a43632|49|74dd17af|8dd96ca8bfa511dc85d9001c23e19543|0 +5:rtp.h|1|11d70a4368f|61a|7adceb50|8fa96ce0bfa511dc85d9001c23e19543|0 +9:rtp_pub.h|1|11d70a436dd|3cf|4c4e4455|90d96d18bfa511dc85d9001c23e19543|0 +9:rtp_def.h|1|11d70a43651|20f|576fa202|cc507328ceff11dc82a0001c23e19543|0 +c:rtp_struct.h|1|11d70a435c4|33f|ac26f5b2|8ca96c70bfa511dc85d9001c23e19543|0 diff --git a/omc/plat/rtp/src/include/rtp.h b/omc/plat/rtp/src/include/rtp.h new file mode 100644 index 0000000..c738087 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp.h @@ -0,0 +1,56 @@ +#ifndef _RTP__H +#define _RTP__H + +#define RTP_MAX_NUM_OF_SAP 4 +#define RTP_MAX_NUM_OF_PORT 1024 +#define RTP_MAX_NUM_OF_PORT_1 1023 + +#define RTP_MAX_USER_NAME_LEN 16 +#define RTP_MAX_PAYLOAD_SIZE 1024 + +#define RTP_MODE_INACTIVE 0 +#define RTP_MODE_RECVONLY 1 +#define RTP_MODE_SENDONLY 2 +#define RTP_MODE_SENDRECV 3 + +typedef struct _RTP_SAP +{ + char name[RTP_MAX_USER_NAME_LEN]; // User name + + // Having received a RTP packet, the RTP module calls this function to send payloads to the user + // If the user doesn't need to receive RTP packets, can leave the pointer to be NULL + int (*rtp_recv)(WORD usrPort, WORD hdlPort, BYTE pt, WORD sn, BYTE *payload, WORD len); + // Handshake every 10 seconds + int (*rtp_handshake)(WORD usrPort, WORD hdlPort, WORD rtpPort); +}RTP_SAP; + +typedef struct _RTP_SESSION +{ + DWORD dstIp; + WORD dstPort; + + BYTE plType; // Payload type + BYTE interval; // RTP interval in ms +}RTP_SESSION; + +typedef struct _RTP_PAYLOAD +{ + BYTE padding[12]; + BYTE payload[RTP_MAX_PAYLOAD_SIZE]; +}RTP_PAYLOAD; + +void rtp_init(void); +void rtp_timer(void); + +int rtp_bind(RTP_SAP *sap); +int rtp_unbind(RTP_SAP *sap, BYTE sapIndex); + +int rtp_set_mode(BYTE sapIndex, WORD usrPort, WORD hdlPort, BYTE mode); +int rtp_sess_update(BYTE sapIndex, WORD usrPort, WORD hdlPort, RTP_SESSION *sess); + +int rtp_allocate_port(BYTE sapIndex, WORD usrPort, WORD *rtpPort); +int rtp_release_port(BYTE sapIndex, WORD usrPort, WORD rtpPort, WORD hdlPort); + +int rtp_send(BYTE sapIndex, WORD usrPort, WORD hdlPort, WORD sn, RTP_PAYLOAD *payload, WORD len); + +#endif diff --git a/omc/plat/rtp/src/include/rtp_const.h b/omc/plat/rtp/src/include/rtp_const.h new file mode 100644 index 0000000..f4fe727 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_const.h @@ -0,0 +1,9 @@ +#ifndef _RTP_CONST__H +#define _RTP_CONST__H + +#define RTP_BASE_UDP_PORT_CONST 25000 +#define RTP_MAX_UDP_MSG_LEN 1500 + +#define RTP_HANDSHAKE_TIMER 1000 // 10 seconds + +#endif diff --git a/omc/plat/rtp/src/include/rtp_def.h b/omc/plat/rtp/src/include/rtp_def.h new file mode 100644 index 0000000..7918cb1 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_def.h @@ -0,0 +1,26 @@ +#ifndef _RTP_DEF__H +#define _RTP_DEF__H + +#include "rtp_pub.h" +#include "rtp.h" +#include "rtp_const.h" +#include "rtp_struct.h" + +RTP_SAP rtpSap[RTP_MAX_NUM_OF_SAP]; +RTP_PORT rtpHdlPort[RTP_MAX_NUM_OF_PORT]; +WORD rtpHdlPortSelect; +DWORD rtpPort[RTP_MAX_NUM_OF_PORT/32]; +WORD rtpPortSelect; + +int rtpHdlPortFd[RTP_MAX_NUM_OF_PORT]; + +DWORD rtpHostIp; + +WORD RTP_BASE_UDP_PORT; + +struct sockaddr_in rtpSrcInAddr; +struct sockaddr_in rtpDstInAddr; + +BYTE rtpMsgRvBuf[RTP_MAX_UDP_MSG_LEN]; + +#endif diff --git a/omc/plat/rtp/src/include/rtp_ext.h b/omc/plat/rtp/src/include/rtp_ext.h new file mode 100644 index 0000000..e1dd716 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_ext.h @@ -0,0 +1,22 @@ +#ifndef _RTP_EXT__H +#define _RTP_EXT__H + +#include "rtp_pub.h" +#include "rtp.h" +#include "rtp_const.h" +#include "rtp_struct.h" + +extern RTP_SAP rtpSap[RTP_MAX_NUM_OF_SAP]; +extern RTP_PORT rtpHdlPort[RTP_MAX_NUM_OF_PORT]; +extern WORD rtpHdlPortSelect; +extern DWORD rtpPort[RTP_MAX_NUM_OF_PORT/32]; +extern WORD rtpPortSelect; + +extern DWORD rtpHostIp; + +extern struct sockaddr_in rtpSrcInAddr; +extern struct sockaddr_in rtpDstInAddr; + +extern BYTE rtpMsgRvBuf[RTP_MAX_UDP_MSG_LEN]; + +#endif diff --git a/omc/plat/rtp/src/include/rtp_msg.h b/omc/plat/rtp/src/include/rtp_msg.h new file mode 100644 index 0000000..7e1eebf --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_msg.h @@ -0,0 +1,6 @@ +#ifndef _RTP_MSG__H +#define _RTP_MSG__H + +int rtp_recv_udp_msg(); + +#endif diff --git a/omc/plat/rtp/src/include/rtp_pub.h b/omc/plat/rtp/src/include/rtp_pub.h new file mode 100644 index 0000000..e7c01b1 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_pub.h @@ -0,0 +1,55 @@ +#ifndef _RTP_PUB__H +#define _RTP_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//by simon at 23/9/22 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/omc/plat/rtp/src/include/rtp_struct.h b/omc/plat/rtp/src/include/rtp_struct.h new file mode 100644 index 0000000..a1723a1 --- /dev/null +++ b/omc/plat/rtp/src/include/rtp_struct.h @@ -0,0 +1,33 @@ +#ifndef _RTP_STRUCT__H +#define _RTP_STRUCT__H + +#include "rtp.h" +#include "rtp_const.h" + +typedef struct _RTP_PORT +{ + BYTE flag; + BYTE sapIndex; + WORD usrPort; + WORD rtpPort; + int fd; + BYTE mode; // inactive/recv/send/sendrecv + DWORD timer; // handshake timer + BYTE times; // handshake times + DWORD timeStamp; // current time stamp + WORD inc; // timestamp increment + + RTP_SESSION sess; +}RTP_PORT; + +typedef struct _RTP_PACKET +{ + BYTE ver __attribute__((packed)); // version + BYTE pt __attribute__((packed)); // payload type + WORD sn __attribute__((packed)); // sequence number + DWORD timeStamp __attribute__((packed)); + DWORD ssrc __attribute__((packed)); // synchronization src + BYTE payload[RTP_MAX_PAYLOAD_SIZE] __attribute__((packed)); +}RTP_PACKET; + +#endif diff --git a/omc/plat/rtp/src/rtp.c b/omc/plat/rtp/src/rtp.c new file mode 100644 index 0000000..079c863 --- /dev/null +++ b/omc/plat/rtp/src/rtp.c @@ -0,0 +1,358 @@ +/****************************************************************/ +/* RTP Implementation Program */ +/* Version 9.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2007-3-19 */ +/****************************************************************/ + +#include "./include/rtp_pub.h" +#include "./include/rtp.h" +#include "./include/rtp_const.h" +#include "./include/rtp_def.h" +#include "./include/rtp_struct.h" +#include "./include/rtp_msg.h" + +int rtp_get_local_ip(void) +{ + struct hostent *host; + char hostName[64]; + char hostIp[32]; + + if (gethostname(hostName, 50) == -1) + { + printf("RTP gethostname fail!\n"); + exit(3); + } + + if ((host = gethostbyname(hostName)) == NULL) + { + printf("RTP 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]); + rtpHostIp = inet_addr(hostIp); // Network byte order host_ip, like 0xE60012AC + printf("RTP host IP: %s (0x%lX)\n", hostIp, rtpHostIp); + } + + return 0; +} + +void rtp_init(void) +{ + WORD i; + + printf("RTP Init Start!\n"); + + rtp_get_local_ip(); + + memset((BYTE *) rtpSap, 0, sizeof(RTP_SAP) * RTP_MAX_NUM_OF_SAP); + memset((BYTE *) rtpPort, 0, RTP_MAX_NUM_OF_PORT / 8); + memset((BYTE *) rtpHdlPort, 0, sizeof(RTP_PORT) * RTP_MAX_NUM_OF_PORT); + memset((BYTE *) rtpHdlPortFd, -1, sizeof(int) * RTP_MAX_NUM_OF_PORT); + for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++) + rtpHdlPort[i].fd = -1; + + rtpHdlPortSelect = 0; + rtpPortSelect = 0; + RTP_BASE_UDP_PORT = RTP_BASE_UDP_PORT_CONST; + /* + { + FILE *fp=NULL; + unsigned short base_port=25000; + char s[80]=""; + + fp = fopen("./conf/rtp.conf","r"); + if(fp != NULL) + { + while(fgets(s,1024,fp) !=(char *)0) + { + if( (int *)strchr(s,'#') !=NULL) continue; + if( !strlen(s) ) continue; + if(strncasecmp(s,"base port=",10)==0) + { + base_port = atoi(&s[10]); + if(base_port>1000 && base_port<32768) + RTP_BASE_UDP_PORT = base_port; + else + break; + } + else + break; + } + fclose(fp); + } + + } */ + printf("RTP Init Complete!\n"); +} + +// Called every 10 ms +void rtp_timer(void) +{ + rtp_recv_udp_msg(); +} + +void rtp_sap_init(BYTE sapIndex) +{ + memset((BYTE *) &rtpSap[sapIndex], 0, sizeof(RTP_SAP)); +} + +void rtp_port_init(WORD port) +{ + memset((BYTE *) &rtpHdlPort[port], 0, sizeof(RTP_PORT)); + rtpHdlPort[port].fd = -1; + rtpHdlPortFd[port] = -1; +} + +int rtp_init_udp_socket(struct sockaddr_in saddr, int multicast) +{ + int sock; + long sockBuf = 40*1024; + int on = 1, timeout = 20; + + sock = socket(AF_INET, SOCK_DGRAM, 0); + + if (sock < 0) + { + fprintf(stderr, "Socket() failed\n"); + return -3; + } + + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &sockBuf, sizeof(sockBuf)) != 0) + { + fprintf(stderr, "RTP set socket buffer failed\n"); + return -4; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + &on,sizeof(on)) != 0) + { + fprintf(stderr, "RTP set addr reusable failed\n"); + return -5; + } + + if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, + &timeout, sizeof(timeout)) != 0) + { + fprintf(stderr, "RTP set keepalive failed\n"); + return -6; + } + + if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr, "RTP set nonblock failed\n"); + return -7; + } + + if (bind(sock, (struct sockaddr *) &saddr, sizeof(struct sockaddr)) < 0) + { + fprintf(stderr, "RTP binding failed, port: %d\n", htons(saddr.sin_port)); + close(sock); + return -2; + } + + return sock; +} + +int rtp_init_socket(WORD hdlPort, WORD udpPort) +{ + struct sockaddr_in sinAddr; + int fd; + + memset(&sinAddr, 0, sizeof(struct sockaddr)); + sinAddr.sin_family = AF_INET; + sinAddr.sin_port = htons(udpPort); + sinAddr.sin_addr.s_addr = rtpHostIp; // INADDR_ANY; + memset(&(sinAddr.sin_zero), 0, 8); + + fd = rtp_init_udp_socket(sinAddr, 0); + if (fd < 0) + { + printf("RTP UDP Socket(%d) failed\n", udpPort); + return -1; + } + + rtpHdlPort[hdlPort].fd = fd; + rtpHdlPortFd[hdlPort] = fd; + + return 0; +} + +int rtp_get_udp_port(WORD hdlPort) +{ + WORD port = rtpPortSelect; + WORD i, index1, index2; + + for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++) + { + index1 = port / 32; + index2 = port % 32; + + if (((rtpPort[index1] >> index2) & 1) == 1) + { + if (++port >= RTP_MAX_NUM_OF_PORT) + port = 0; + continue; + } + + if (rtp_init_socket(hdlPort, port * 2 + RTP_BASE_UDP_PORT) < 0) + return -1; + + rtpPort[index1] |= 1 << index2; + rtpPortSelect = (port + 1) & RTP_MAX_NUM_OF_PORT_1; + + rtpHdlPort[hdlPort].rtpPort = port; + return port; + } + + return -1; +} + +int rtp_release_udp_port(WORD hdlPort) +{ + WORD port = rtpHdlPort[hdlPort].rtpPort; + int fd = rtpHdlPort[hdlPort].fd; + WORD index1, index2; + + if (port >= RTP_MAX_NUM_OF_PORT) + return -1; + + index1 = port / 32; + index2 = port % 32; + rtpPort[index1] = rtpPort[index1] & (~(1 << index2)); + + if (fd >= 0) + close(fd); + + return 0; +} + +int rtp_get_hdl_port() +{ + WORD port = rtpHdlPortSelect; + WORD i; + + for (i = 0; i < RTP_MAX_NUM_OF_PORT; i++) + { + if (rtpHdlPort[port].flag != 0) + { + if (++port >= RTP_MAX_NUM_OF_PORT) + port = 0; + continue; + } + return port; + } + + return -1; +} + +int rtp_allocate_port(BYTE sapIndex, WORD usrPort, WORD *rtpPort) +{ + int hdlPort, udpPort; + + if (sapIndex >= RTP_MAX_NUM_OF_SAP) + return -1; + + if ((hdlPort = rtp_get_hdl_port()) < 0) + return -1; + + if ((udpPort = rtp_get_udp_port(hdlPort)) < 0) + return -1; + + rtpHdlPort[hdlPort].flag = 1; + rtpHdlPort[hdlPort].sapIndex = sapIndex; + rtpHdlPort[hdlPort].usrPort = usrPort; + rtpHdlPort[hdlPort].timer = RTP_HANDSHAKE_TIMER; + + rtpHdlPortSelect = (hdlPort + 1) & RTP_MAX_NUM_OF_PORT_1; + + *rtpPort = udpPort * 2 + RTP_BASE_UDP_PORT; + return hdlPort; +} + +int rtp_release_port(BYTE sapIndex, WORD usrPort, WORD rtpPort, WORD hdlPort) +{ + if (hdlPort >= RTP_MAX_NUM_OF_PORT) + return -1; + + if (rtpHdlPort[hdlPort].sapIndex != sapIndex) + return -2; + else if (rtpHdlPort[hdlPort].usrPort != usrPort) + return -3; + else if ((rtpHdlPort[hdlPort].rtpPort * 2 + RTP_BASE_UDP_PORT) != rtpPort) + return -4; + + rtp_release_udp_port(hdlPort); + + rtp_port_init(hdlPort); + + return 0; +} + +int rtp_sess_update(BYTE sapIndex, WORD usrPort, WORD hdlPort, RTP_SESSION *sess) +{ + if (hdlPort >= RTP_MAX_NUM_OF_PORT) + return -1; + + if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) || + (rtpHdlPort[hdlPort].usrPort != usrPort)) + return -1; + + memcpy((BYTE *) &rtpHdlPort[hdlPort].sess, (BYTE *) sess, sizeof(RTP_SESSION)); + + rtpHdlPort[hdlPort].inc = rtpHdlPort[hdlPort].sess.interval * 8; + + return 0; +} + +int rtp_set_mode(BYTE sapIndex, WORD usrPort, WORD hdlPort, BYTE mode) +{ + if ((hdlPort >= RTP_MAX_NUM_OF_PORT) || (mode > RTP_MODE_SENDRECV)) + return -1; + + if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) || + (rtpHdlPort[hdlPort].usrPort != usrPort)) + return -1; + + rtpHdlPort[hdlPort].mode = mode; + return 0; +} + +int rtp_bind(RTP_SAP *sap) +{ + BYTE i; + + if ((sap == NULL) || (sap->rtp_handshake == NULL)) + return -1; + + for (i = 0; i < RTP_MAX_NUM_OF_SAP; i++) + { + if (rtpSap[i].rtp_handshake != NULL) + continue; + memcpy((BYTE *) &rtpSap[i], sap, sizeof(RTP_SAP)); + rtpSap[i].name[RTP_MAX_USER_NAME_LEN - 1] = '\0'; + return i; + } + + return -1; +} + +int rtp_unbind(RTP_SAP *sap, BYTE sapIndex) +{ + if ((sap == NULL) || (sapIndex >= RTP_MAX_NUM_OF_SAP)) + return -1; + + if (strcmp(sap->name, rtpSap[sapIndex].name) != 0) + return -1; + + rtp_sap_init(sapIndex); + + return 0; +} diff --git a/omc/plat/rtp/src/rtp_msg.c b/omc/plat/rtp/src/rtp_msg.c new file mode 100644 index 0000000..a89a11d --- /dev/null +++ b/omc/plat/rtp/src/rtp_msg.c @@ -0,0 +1,148 @@ +#include "./include/rtp_pub.h" +#include "./include/rtp.h" +#include "./include/rtp_const.h" +#include "./include/rtp_def.h" +#include "./include/rtp_struct.h" + +extern void rtp_port_init(WORD port); +extern int rtp_release_udp_port(WORD hdlPort); + +int rtp_recv_msg_handling(WORD hdlPort, BYTE *rtpMsgRvBuf, WORD len) +{ + RTP_PACKET *packet = (RTP_PACKET *) rtpMsgRvBuf; + RTP_PORT *port = &rtpHdlPort[hdlPort]; + RTP_SAP *sap; + BYTE cc, csLen; + WORD sn; + + if ((port->mode != RTP_MODE_RECVONLY) && + (port->mode != RTP_MODE_SENDRECV)) + return -1; + + if (port->sapIndex >= RTP_MAX_NUM_OF_SAP) + return -1; + + sap = &rtpSap[port->sapIndex]; + + if (sap->rtp_recv == NULL) + return -1; + + cc = packet->ver & 0x0F; + csLen = cc * 4; + + sn = ntohs(packet->sn); + + return (sap->rtp_recv(port->usrPort, hdlPort, packet->pt & 0x7F, packet->sn, rtpMsgRvBuf + 12 + csLen, len - 12 - csLen)); +} + +int rtp_handshake_proc(WORD hdlPort) +{ + RTP_PORT *port = &rtpHdlPort[hdlPort]; + RTP_SAP *sap; + + if (port->sapIndex >= RTP_MAX_NUM_OF_SAP) + return -1; + + sap = &rtpSap[port->sapIndex]; + if (sap->rtp_handshake == NULL) + return -1; + + if (sap->rtp_handshake(port->usrPort, hdlPort, port->rtpPort * 2 + RTP_BASE_UDP_PORT) == -1) + { + if (++port->times >= 3) + { + rtp_release_udp_port(hdlPort); + rtp_port_init(hdlPort); + return -1; + } + } + + port->timer = RTP_HANDSHAKE_TIMER; + + return 0; +} + +int rtp_recv_udp_msg() +{ + int port, i, len, addrLen = sizeof(struct sockaddr); + + for (port = 0; port < RTP_MAX_NUM_OF_PORT; port++) + { + if (rtpHdlPort[port].flag == 0) + continue; + + if (rtpHdlPort[port].timer > 0) + { + if (--rtpHdlPort[port].timer == 0) + rtp_handshake_proc(port); + } + + if (rtpHdlPort[port].fd == -1) + continue; + + if (rtpHdlPortFd[port] != rtpHdlPort[port].fd) + { + printf("fd has been changed: fd: %d, HdlPortFd: %d\n", rtpHdlPort[port].fd, rtpHdlPortFd[port]); + continue; + } + + for (i = 0; i < 5; i++) + { + len = recvfrom(rtpHdlPort[port].fd, rtpMsgRvBuf, RTP_MAX_UDP_MSG_LEN, + 0, (struct sockaddr *)&rtpSrcInAddr, &addrLen); + if (len < 0) + break; + + if (len >= RTP_MAX_UDP_MSG_LEN) + continue; + + rtp_recv_msg_handling(port, rtpMsgRvBuf, len); + } + } + + return 0; +} + +int rtp_send_udp_msg(WORD hdlPort, BYTE *msg, WORD len) +{ + int ret, fd = rtpHdlPort[hdlPort].fd; + + if (len >= RTP_MAX_PAYLOAD_SIZE) + return -1; + + if (fd < 0) + return -1; + + rtpDstInAddr.sin_addr.s_addr = rtpHdlPort[hdlPort].sess.dstIp; + rtpDstInAddr.sin_port = htons(rtpHdlPort[hdlPort].sess.dstPort); + + ret = sendto(fd, msg, len, 0, (struct sockaddr *) &rtpDstInAddr, sizeof(rtpDstInAddr)); + + return ret; +} + +int rtp_send(BYTE sapIndex, WORD usrPort, WORD hdlPort, WORD sn, RTP_PAYLOAD *payload, WORD len) +{ + RTP_PACKET *packet = (RTP_PACKET *) payload; + + if ((hdlPort >= RTP_MAX_NUM_OF_PORT) || + (len > RTP_MAX_PAYLOAD_SIZE) || + (payload == NULL)) + return -1; + + if ((rtpHdlPort[hdlPort].sapIndex != sapIndex) || + (rtpHdlPort[hdlPort].usrPort != usrPort)) + return -1; + + if (rtpHdlPort[hdlPort].mode < RTP_MODE_SENDONLY) + return -1; + + packet->ver = 0x80; + packet->pt = rtpHdlPort[hdlPort].sess.plType; + packet->sn = htons(sn); + rtpHdlPort[hdlPort].timeStamp += rtpHdlPort[hdlPort].inc; + packet->timeStamp = htonl(rtpHdlPort[hdlPort].timeStamp); + packet->ssrc = htonl(sapIndex + usrPort + hdlPort); + + return rtp_send_udp_msg(hdlPort, (BYTE *) packet, len + 12); +} diff --git a/omc/plat/sccp/.copyarea.db b/omc/plat/sccp/.copyarea.db new file mode 100644 index 0000000..537cb7f --- /dev/null +++ b/omc/plat/sccp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp +2 +5 +3:doc|2|0|0|0|62e881bfc44711dc9634001c23e19543|0 +2:ut|2|0|0|0|65d881d2c44711dc9638001c23e19543|0 +3:src|2|0|0|0|641881c4c44711dc9636001c23e19543|0 +8:Makefile|1|11d70a4377a|b8a|eadd81e|96c96c97bfa511dc85e0001c23e19543|0 +3:lib|2|0|0|0|96396c7bbfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/Makefile b/omc/plat/sccp/Makefile new file mode 100644 index 0000000..f6789c6 --- /dev/null +++ b/omc/plat/sccp/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = sccp +TYPE = plat + +DBUG_FLAGS_ADD = -D_CDMA_SNMP -DDEBUG ##-DMEMWATCH -DMEMWATCH_STDIO ##-D_WXC_FSM_TEST +RELS_FLAGS_ADD = -D_CDMA_SNMP -DDEBUG + +##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 = ../../app + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/sccp/lib/libsccp.a b/omc/plat/sccp/lib/libsccp.a new file mode 100644 index 0000000..5a47909 Binary files /dev/null and b/omc/plat/sccp/lib/libsccp.a differ diff --git a/omc/plat/sccp/obj/sccp.o b/omc/plat/sccp/obj/sccp.o new file mode 100644 index 0000000..c56d636 Binary files /dev/null and b/omc/plat/sccp/obj/sccp.o differ diff --git a/omc/plat/sccp/obj/sccp_debug.o b/omc/plat/sccp/obj/sccp_debug.o new file mode 100644 index 0000000..a305a6b Binary files /dev/null and b/omc/plat/sccp/obj/sccp_debug.o differ diff --git a/omc/plat/sccp/obj/sccp_func.o b/omc/plat/sccp/obj/sccp_func.o new file mode 100644 index 0000000..d6630f0 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_func.o differ diff --git a/omc/plat/sccp/obj/sccp_gtt.o b/omc/plat/sccp/obj/sccp_gtt.o new file mode 100644 index 0000000..f2ed607 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_gtt.o differ diff --git a/omc/plat/sccp/obj/sccp_log.o b/omc/plat/sccp/obj/sccp_log.o new file mode 100644 index 0000000..0068e64 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_log.o differ diff --git a/omc/plat/sccp/obj/sccp_mib.o b/omc/plat/sccp/obj/sccp_mib.o new file mode 100644 index 0000000..bcc7cd5 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_mib.o differ diff --git a/omc/plat/sccp/obj/sccp_msg.o b/omc/plat/sccp/obj/sccp_msg.o new file mode 100644 index 0000000..7538e17 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_msg.o differ diff --git a/omc/plat/sccp/obj/sccp_param.o b/omc/plat/sccp/obj/sccp_param.o new file mode 100644 index 0000000..882d037 Binary files /dev/null and b/omc/plat/sccp/obj/sccp_param.o differ diff --git a/omc/plat/sccp/obj/sclc.o b/omc/plat/sccp/obj/sclc.o new file mode 100644 index 0000000..ec8c1a7 Binary files /dev/null and b/omc/plat/sccp/obj/sclc.o differ diff --git a/omc/plat/sccp/obj/scmg.o b/omc/plat/sccp/obj/scmg.o new file mode 100644 index 0000000..2a2a256 Binary files /dev/null and b/omc/plat/sccp/obj/scmg.o differ diff --git a/omc/plat/sccp/obj/scoc.o b/omc/plat/sccp/obj/scoc.o new file mode 100644 index 0000000..340ef69 Binary files /dev/null and b/omc/plat/sccp/obj/scoc.o differ diff --git a/omc/plat/sccp/obj/scoc_fsm.o b/omc/plat/sccp/obj/scoc_fsm.o new file mode 100644 index 0000000..54b8039 Binary files /dev/null and b/omc/plat/sccp/obj/scoc_fsm.o differ diff --git a/omc/plat/sccp/obj/scoc_func.o b/omc/plat/sccp/obj/scoc_func.o new file mode 100644 index 0000000..ba1ff42 Binary files /dev/null and b/omc/plat/sccp/obj/scoc_func.o differ diff --git a/omc/plat/sccp/obj/scoc_if.o b/omc/plat/sccp/obj/scoc_if.o new file mode 100644 index 0000000..91cf6e7 Binary files /dev/null and b/omc/plat/sccp/obj/scoc_if.o differ diff --git a/omc/plat/sccp/obj/scoc_pool.o b/omc/plat/sccp/obj/scoc_pool.o new file mode 100644 index 0000000..1d051f8 Binary files /dev/null and b/omc/plat/sccp/obj/scoc_pool.o differ diff --git a/omc/plat/sccp/obj/scoc_pri.o b/omc/plat/sccp/obj/scoc_pri.o new file mode 100644 index 0000000..0a50221 Binary files /dev/null and b/omc/plat/sccp/obj/scoc_pri.o differ diff --git a/omc/plat/sccp/obj/scrc.o b/omc/plat/sccp/obj/scrc.o new file mode 100644 index 0000000..f3282e9 Binary files /dev/null and b/omc/plat/sccp/obj/scrc.o differ diff --git a/omc/plat/sccp/src/.copyarea.db b/omc/plat/sccp/src/.copyarea.db new file mode 100644 index 0000000..e2cafb0 --- /dev/null +++ b/omc/plat/sccp/src/.copyarea.db @@ -0,0 +1,22 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\src +2 +12 +6:sccp.c|1|11d8b0aa7f3|234c|38b00492|01855b34afd811dd8b66001c23e19543|0 +c:sccp_debug.c|1|11d70a43835|5a9c|a2e0bac5|97696ccfbfa511dc85e0001c23e19543|0 +a:sccp_log.c|1|11d70a439bc|3132|cce2e116|9e896de7bfa511dc85e0001c23e19543|0 +6:scoc.c|1|11d70a43b13|fa5|859b38ab|a8196f6fbfa511dc85e0001c23e19543|0 +7:include|2|0|0|0|654881cdc44711dc9637001c23e19543|0 +b:scoc_pool.c|1|11d70a43a77|1666|cf4a3298|a1896e57bfa511dc85e0001c23e19543|0 +9:scoc_if.c|1|11d70a43ae4|1f84|3a95b205|a7896f53bfa511dc85e0001c23e19543|0 +a:scoc_fsm.c|1|11d70a4392f|7f89|36762e52|9cc96d93bfa511dc85e0001c23e19543|0 +6:scrc.c|1|11d70a4398d|81b5|8a846dc5|ee7485866cf311dd91a5001c23e19543|0 +a:sccp_mib.c|1|11d8b0aa776|1e3f|6249e2df|00f55b31afd811dd8b65001c23e19543|0 +6:sclc.c|1|11d70a438e1|4bdb|f5a2ec98|ee74856e6cf311dd91a5001c23e19543|0 +a:sccp_gtt.c|1|11d70a4395e|2f83|62008ed2|9d596dafbfa511dc85e0001c23e19543|0 +c:sccp_param.c|1|11d70a439ea|51df|eda792a6|58a648fa9a8611dd8b36001c23e19543|0 +b:sccp_func.c|1|11d70a43b42|ba6|6f53e1f2|a8b96f8bbfa511dc85e0001c23e19543|0 +6:scmg.c|1|11d70a43a19|3d0c|c6908349|9fc96e1fbfa511dc85e0001c23e19543|0 +a:sccp_msg.c|1|11d70a43a38|6563|c4ffae0c|a0596e3bbfa511dc85e0001c23e19543|0 +b:scoc_func.c|1|11d70a43910|6e7f|6b018863|9b996d77bfa511dc85e0001c23e19543|0 +a:scoc_pri.c|1|11d70a438b2|23e7|65affdc2|9a696d3fbfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/src/include/.copyarea.db b/omc/plat/sccp/src/include/.copyarea.db new file mode 100644 index 0000000..bc12bf0 --- /dev/null +++ b/omc/plat/sccp/src/include/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\src\include +2 +6 +6:sccp.h|1|11d9047abf1|171b|129691b3|0db8dec8b05e11dd8512001c23e19543|0 +b:sccpconst.h|1|11d8a87d240|4c43|144d7cae|4234cffaafc311dd8a8d001c23e19543|0 +6:scoc.h|1|11d70a43cb9|1146|32e1d2e0|a5196effbfa511dc85e0001c23e19543|0 +9:scoc_if.h|1|11d70a43c8a|371b|dd0495fc|a4896ee3bfa511dc85e0001c23e19543|0 +a:sccp_pub.h|1|11d70a43d07|258|b7cbaac1|a5b96f1bbfa511dc85e0001c23e19543|0 +b:sccp_func.h|1|11d70a43d36|1836|bf10e086|a6e96f37bfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/src/include/sccp.h b/omc/plat/sccp/src/include/sccp.h new file mode 100644 index 0000000..1105025 --- /dev/null +++ b/omc/plat/sccp/src/include/sccp.h @@ -0,0 +1,324 @@ + +/******************************************************/ +/*Title: sccp.h */ +/*Descr: Definition of SCCP */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/******************************************************/ + +#ifndef _SCCP_HEAD_FILE +#define _SCCP_HEAD_FILE + +#include "../../../public/src/include/pub_wnet.h" +#include "../../../snmp/src/include/heartbeat.h" +#include "../../../snmp/src/include/snmp.h" +#include "../../../debug/src/include/debug.h" +#include "../../../mtp3/src/include/mtp3.h" +#include "sccpconst.h" + +#ifdef _WXC_FSM_TEST +#define spLogFsm printf +#define spWxcBackTrace() WxcBackTrace() +#else +#define spLogFsm +#define spWxcBackTrace() +#endif + +#define MAX_SCLC_BUF 4 + +#define SCCP_VERSION { 9,1,5} + +////////////////////////////////////////////////////////////////// +#define SEG_RS_LEN 3 + +typedef struct SCCP_Segmnt +{ + unsigned RSBits:4; + unsigned SpaceBits:2; + unsigned CBit:1; + unsigned FBit:1; + u8 SegLR[SEG_RS_LEN]; +} +SCCP_Segmnt; + +typedef struct SCCP_SegUnID +{ + int OPC; + int DPC; + u8 SLS; + SCCP_ADDR CGA; + u8 SegLR[SEG_RS_LEN]; +} +SCCP_SegUnID; + +#define MAX_SEGBLOCK_LEN 256 + +typedef struct SCCP_SegStream +{ + u8 SegDataLen; + u8 SegDataBlock[MAX_SEGBLOCK_LEN]; +} +SCCP_SegStream; + +#define MAX_SEGSTREAM_SIZE 10 +#define MAX_SEGMSG_TIMER 2000 +#define SEGSTREAM_IDLE 0x00 +#define SEGSTREAM_BUSY 0x01 + +typedef struct SCCP_SegMsgBuf +{ + u8 MsgState; + u8 MsgClass; + u8 MsgTotal; + DWORD SegMsgTimer; + u8 RSE; + + SCCP_SegUnID SegID; + SCCP_SegStream SegStream[MAX_SEGSTREAM_SIZE]; + +} +SCCP_SegMsgBuf; + +#define MAX_SEGMSG_BUF 256 +/* by simon at 23/9/26 */ +//SCCP_SegMsgBuf sccp_segmsgbuf[MAX_SEGMSG_BUF]; + +typedef struct Intra_Message +{ + u8 msgsource; //FROM_MTP:0,FROM_SCLC:1,FROM_SCOC:2,FROM_SCMG:3 + u8 msgtype; + u8 msgclass; + + u8 msgMNP; /* mnp flag , added by pierre , 11-07 */ + int OPC; + int DPC; + u8 SLS; + u8 link; + u8 NetID; + SCCP_ADDR CGA; + SCCP_ADDR CDA; + BOOL EOD; + u8 aSLR[SP_REF_LEN]; + u8 aDLR[SP_REF_LEN]; + u_short msglen; + u8 data[SCCP_MSG_MAXLEN]; + u8 PS; + u8 PR; + u8 RO; + u8 cause; + u8 Hop; + SCCP_Segmnt Segmnt; // + u8 SegPresent; + u8 redirectFlag; + u8 sequenceFlag; +} +Intra_Msg; + +//Intra_Msg CurMsg; + +typedef struct SCCP_OPT +{ + DWORD ip; + long spc[4]; + u8 spclen[4]; + u8 version[3]; + u8 status; + u8 RegSSN[32]; + u8 RegNum; + u8 CO_SSN; + long T_reset; + DWORD OMCIP[2]; +} +SCCP_OPT; + +/* by simon at 23/9/26 */ +// SCCP_OPT SCCP_Param; + +typedef struct _SCOC_BUF +{ + short rcvsub[2]; + short sndsub[2]; + up_message msgin[SS_MSG_NUM]; + up_message msgout[SS_MSG_NUM]; +} +SCOC_BUF; + +/* by simon at 23/9/26 */ +// SCOC_BUF ScocBuf; + +#define MAX_SCLCMSG_LEN 256 + +typedef struct SCLC_MSG +{ + u8 primitive; + u8 msg[MAX_SCLCMSG_LEN]; + u_short msglen; + u8 sls; + u8 sequence_control; //Class 0: The basic connectionless class without guaranteed in-sequence delivery + //Class 1: The in-sequence delivery connectionless class with guaranteed in-sequence delivery + u8 ret_reason; + SCCP_ADDR src_addr; + SCCP_ADDR dst_addr; +} +SCLC_MSG; + +typedef struct _SCLC_BUF +{ + short readsub; + short writesub; + SCLC_MSG msglist[SS_MSG_NUM]; +} +SCLC_BUF; + +typedef struct LOCAL_SSN +{ + u8 msisdn[MAX_DIGITS]; + u8 status[2]; //0:no 1:equipped(disable) 2:congest 3:enable 4:local&equipped(disable) 5:local&congest 6:local&enable + u8 nbuf; + u8 local; + u8 NetID; + u8 RegFlag; + DWORD ip[2]; + short timeout[2]; + u8 msisdn_len; +} +LOCAL_SSN; + +/* by simon at 23/9/26 */ +// LOCAL_SSN LocalSSN[256]; +// u8 ExistSSN[64]; +// u8 ExistSSNNum; + +// u8 MNP_Flag[2]; + +/* by simon at 23/9/26 */ +// struct _dpc2sls +// { +// int dpc; +// u8 sls; +// }dpc2sls[256]; //used for sequence control, add by Roy Jiang, 2007-09-17 + +/* u80:0/1/2=not support MNP/IN_based/MNP_SRF */ +/* u81:0-1/2=direct/indirect routing */ +/* added by Pierre, 2005-11-07 for MNP */ + +/*===================================*/ +//MIB===================> + +/*===================================*/ + +typedef struct SCCP_ROUTE +{ + u8 avail; + u8 NP; + u8 TT; + u8 StartDigits[MAX_DIGITS]; + u8 EndDigits[MAX_DIGITS]; + u8 NetID; + u8 DPC[3]; + u8 SSN; + u8 RI; + u8 AI; //Address indicator,indicate the Address include GT,DPC,SSN or not,BIT0:point code, bit1:ssn, bit2:GT + u8 ReplaceStart; + u8 ReplaceEnd; + u8 OutNP; + u8 ReplaceDigits[MAX_DIGITS]; + u8 acn_ver[48]; + u8 convert; + u8 len; + u8 replace_len; +} +SCCP_ROUTE; + +/* by simon at 23/9/26 */ +// SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; + +typedef struct SCCP_ROUTE_NODE +{ + u_short nItem; + struct SCCP_ROUTE_NODE *psub[10]; +} +SCCP_ROUTE_NODE; + +typedef struct RL_SSN +{ + BOOL status; //0 NULL + u8 SST; + u8 NetID; + u8 SSN; + int DPC; + int timeout; +} +RL_SSN; + +/* by simon at 23/09/26 */ +// int RelatedSSNNum; +// RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; + +typedef struct RL_SPC +{ + int DPC; + u8 NetID; + BOOL status; //0 NULL +} +RL_SPC; + +/* by simon at 23/09/26 */ +// int RelatedSPCNum; +// RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; + +#define SCCP_MAX_GTT_ATTRIBUTE 16 +typedef struct GTTATT_OMC +{ + u8 attribute[SCCP_MAX_GTT_ATTRIBUTE]; +} +GTTATT_OMC; +/* by simon at 23/9/26 */ +// GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; + +typedef struct SCCP_FILTER +{ + u8 flag; + u8 src_ssn; + u8 dst_ssn; + int opc; + int dpc; +} +SCCP_FILTER; + +typedef struct SCCP_CSTA +{ + DWORD timestamp; + DWORD error[21]; //.1.1.? + DWORD avail[12]; //.1.2.? + DWORD utilization[12]; //.1.3.? + DWORD quality[20]; //.1.4.? +} +SCCP_CSTA; + +/* by simon at 23/9/26 */ +// SCCP_CSTA SccpCsta[96]; +// DWORD SccpCstaInd; + +/* by simon at 23/9/26 */ +// struct sccp_msg_statistic +// { +// DWORD msg_mtp_scoc; +// DWORD msg_scoc_up; +// DWORD mnp_send; +// DWORD mnp_route; +// } +// sccpmsg_st; + +typedef struct SCCP_Capture_Buf +{ + u8 Pointer; + u8 Buffer[2560]; + u8 watch_dog[256]; +} +SCCP_Capture_Buf; +/* by simon at 23/9/26 */ +// SCCP_Capture_Buf SCCPCapBuf; + + +#endif diff --git a/omc/plat/sccp/src/include/sccp_func.h b/omc/plat/sccp/src/include/sccp_func.h new file mode 100644 index 0000000..a59e6f9 --- /dev/null +++ b/omc/plat/sccp/src/include/sccp_func.h @@ -0,0 +1,165 @@ +////////////////////////////////////////////////// +//Title : sccp_func.h +//Auhtor : Liu Wei +//Desc : SCCP function decl +//Created : 2007-04-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +/* sccp.c */ +void sccp_init(void); +void sccp_init_serial_number(BYTE *Serial); +void sccp_timer(void); +void sccp_reset(void); +int AddToIpList(DWORD ip, BYTE ssn); +int CollectLocalInfo(void); +int sccp_mnp_register(BYTE flag, BYTE routing_method, BYTE usertype); +int spSetGttAddr(u8 uGtType, u8 uSSN, u8 *uGtNum, struct SCCP_ADDRESS *pSpAddr); + +/* sccp_debug.c */ +void spLogDebug_setup(void); +void spLogDebug_timer(void); +int parsecmd(char *cmdstr); +int sccp_filter_msg(SCCP_ADDR *pSrcAddr, SCCP_ADDR *pDstAddr); +void spLogDebug_info(BYTE npage, BYTE nline, BYTE *pt, BYTE len); +void spLogDebug_csta(BYTE npage, int instance); +void spLogDebug_local(BYTE npage, BYTE nline); +void spLogDebug_related(BYTE npage, BYTE nline); +void spLogDebug_buffer(BYTE npage); +void spLogDebug_errorCapture(BYTE npage, BYTE nline); +void spLogDebug_WatchDog(BYTE npage); +void sccp_list_route(void); +void sccp_put_capture_logs(BYTE person, BYTE *pictures, int len); + +/* sccp_func.c */ +int ParseLine(char *str, char (*row)[128], int maxrow); +int GetEnt(FILE *fp, char *key, char *str); +BOOL isco(Intra_Msg *intramsg); +BOOL iscl(Intra_Msg *intramsg); +BOOL iscr(Intra_Msg *intramsg); + +/* sccp_gtt.c */ +int BuildRouteIndex(void); +u_short SelectRoute(BYTE *pDigits, BYTE DigitsLen); +int GetACNInfo(SCCP_ADDR *pAddr, BYTE **pAcnInfo); +void TranslateGT(SCCP_ADDR *pAddr, SCCP_ROUTE *pRoute); +int AddRoute(BYTE *pStartDigits, BYTE *pEndDigits, BYTE DigitsLen, u_short index); +int AddLargerNode(SCCP_ROUTE_NODE *pNode, BYTE *pDigits, BYTE DigitsLen, u_short index); +int AddLessNode(SCCP_ROUTE_NODE *pNode, BYTE *pDigits, BYTE DigitsLen, u_short index); +SCCP_ROUTE_NODE *NewNode(void); +int CheckGT(BYTE np, BYTE tt, BYTE *gt, BYTE gt_len); + +/* sccp_mib.c */ +void sccpmib_init(void); +void sccp_sethb(void); +int sccp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen); +int sccp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype); +void sccp_OMCIP_detect(DWORD ip); +void sccp_trapcallback(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD len, snmp_addr *addr); + +/* sccp_msg.c */ +int build_msg(BYTE *buf, Intra_Msg *intramsg, BYTE NetID, BYTE ansi_flag); +int parse_msg(BYTE *buf, Intra_Msg *intramsg, int len, BYTE NetID, BYTE ansi_flag); +int parse_oparam(BYTE *buf, int len, Intra_Msg *intramsg, BYTE NetID, BYTE ansi_flag); +int encode_int(BYTE *buf, unsigned int val, BYTE len); +unsigned int decode_int(BYTE *buf, BYTE len); +int encode_addr(BYTE *buf, SCCP_ADDR *addr, BYTE NetID); +int decode_addr(BYTE *buf, SCCP_ADDR *addr, BYTE NetID); +int encode_addr_Ansi(BYTE *buf, SCCP_ADDR *addr); +int decode_addr_Ansi(BYTE *buf, SCCP_ADDR *addr); + +/* sclc.c */ +int scrc2sclc(Intra_Msg *pIntraMsg); +int sclc_rf(Intra_Msg *pIntraMsg); +int scmg2sclc(Intra_Msg *pIntraMsg); +int sclc_send(SCLC_MSG *pmsg); +int sclc_receive(SCLC_MSG *pmsg, BYTE usertype); +void sclc_timer(void); +int sclc_mnp_send(SCLC_MSG *pmsg); +int SegmentingMsg(Intra_Msg *pIntraMsg); +int RecvXUDTMsg(Intra_Msg *pIntraMsg, BYTE nbuf); +int CheckSegUnID(Intra_Msg *pIntraMsg); +int RsmRegMsg(SCLC_MSG *pmsg, SCCP_SegMsgBuf *pSegMsgbuf, Intra_Msg *pIntraMsg); + +/* sccp_param.c */ +int GetMSISDNOfSSN(BYTE ssn, BYTE *msisdn); +int sccp_GetSSNType(BYTE ssn); +int sccp_loadparam(void); +void sccp_saveparam(void); +int sccp_setparam(DWORD *oid, BYTE *pdata, WORD datalen); +int sccp_getparam(DWORD *oid, BYTE *pdata, BYTE *vartype); +int SccpGetLocalIP(void); +int ParseLocalNode(char *str); +void ParseRouteInfo(char *str); +void ParseRLSSN(char *str); + +/* scmg.c */ +void localssn_timer(void); +int sclc2scmg(Intra_Msg *intramsg); +BOOL CheckAvail(SCCP_ADDR *addr); +BYTE ssn_status(int spc, BYTE ssn, BYTE NetID); +void spac(int spc, BYTE NetID); +void sppc(int spc, BYTE NetID); +void spcc(int spc, BYTE NetID); +int register_ssn(BYTE ssn, BYTE usertype); +void ssac(int spc, BYTE ssn, BYTE NetID, BOOL relay); +void sscc(int spc, BYTE ssn, BYTE NetID); +int stop_ssn(BYTE ssn); +void sspc(int spc, BYTE ssn, BYTE NetID, BOOL relay); +void sst_timer(void); +void lcst(int spc, BYTE ssn, BYTE ntype, BYTE NetID); +void bcst(BYTE ssn, BYTE ntype); +void bcst_relay(int spc, BYTE ssn, BYTE ntype, BYTE NetID); +int build_scmgmsg(BYTE *data, BYTE type, int spc, BYTE ssn, BYTE NetID); +int parse_scmgmsg(BYTE *data, BYTE *type, int *spc, BYTE *ssn, BYTE NetID); + +/* scrc.c */ +void scrc_timer(void); +int scrc_route(Intra_Msg *pIntraMsg, BOOL ForceAnsi); +int scrc_mnp_route(Intra_Msg *pIntraMsg, BOOL ForceAnsi); +int send_msg(Intra_Msg *pIntraMsg, BYTE ansi_flag); +int scrc_rf(Intra_Msg *pIntraMsg, BYTE AnsiFlag); +DWORD SelectIPOfSSN(BYTE ssn, BYTE sls, BOOL from_mtp); + +/* scoc_fsm.c */ +void coFsm ( ); + +/* scoc_func.c */ +void coInit ( u32 sysID, u32 localIP, u32 alterIP ); +void cr2coFailHandle(Intra_Msg *pIntraMsg, u8 uAnsiFlag, u8 uMsgtype); +int cr2co(Intra_Msg *pIntraMsg, u8 uAnsiFlag); +void co2cr(u16 wConnId, u8 uMsgType); +void co2ul(u16 wConnId, u8 uPri); +void co2scmg(void); +void co2co(u16 wConnId, u8 uPri); +int spCheckAudit(void); +int coNewCS(u16 wConnId, SCCP_ADDR *pAddr); +void coFreeCS(u16 wConnId); +void coFillCS(SP_PriPoolEle *pPri); +int coCheckCS(u16 wConnId, u8 uCState, u8 uSide); +void coTimerOut(u16 wConnId, u8 uPri); +void coTimerMng(void); +int coNewConnId(u8 uPri); +int coGetConnId(u8 *pSLR); +extern inline int coCheckResource ( ); +void spWatchDogStatic(u8 uDebugStaticMask); + +/* sccp_log.c */ +void spLog(char *info); +void spShowAddr(SCCP_ADDR *pAddr, const char *sAddrName); +void spLogDebug(DWORD mask, const char *fmt, ...); +void spShowBCD(DWORD mask, BYTE *buf, int len); +void spLogSeg(SCCP_SegMsgBuf *pSegMsgbuf); +void spShowMsg(DWORD mask, const char *pDesc, Intra_Msg *pIntraMsg); +void spShowPrimitive(SP_UiPriPara *pUiPriParam, u8 uDirection); +void spLogStateError(u16 wConnId, u8 uErrCode); +void spLogTimerOut(u16 wConnId, u8 uTimerID); +void spShowUserData(SP_UiPriPara *pPri); + +/* scoc_pool.c */ +void spPoolInit(void); +int spPoolGet(SP_PriPoolEle *pPri, CO_Pool *pCoPool); +int spPoolPut(SP_PriPoolEle *pPri, CO_Pool *pCoPool); diff --git a/omc/plat/sccp/src/include/sccp_pub.h b/omc/plat/sccp/src/include/sccp_pub.h new file mode 100644 index 0000000..de9d877 --- /dev/null +++ b/omc/plat/sccp/src/include/sccp_pub.h @@ -0,0 +1,27 @@ +////////////////////////////////////////////////// +//Title : sccp_pub.h +//Auhtor : Liu Wei +//Desc : SCCP public header +//Created : 2007-05-07 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _SCCP_PUB_H_ +#define _SCCP_PUB_H_ + +#include "../../../public/src/include/includes.h" +#include "../../../public/src/include/public.h" +#include "../../../public/src/include/pub_debug.h" +#include "../../../public/src/include/pub_wnet.h" +#include "../../../public/src/include/pub_fmt.h" +#include "sccp.h" +#include "scoc.h" +#include "sccp_func.h" + +#endif + + + diff --git a/omc/plat/sccp/src/include/sccpconst.h b/omc/plat/sccp/src/include/sccpconst.h new file mode 100644 index 0000000..c5cce34 --- /dev/null +++ b/omc/plat/sccp/src/include/sccpconst.h @@ -0,0 +1,510 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "scoc_if.h" +#include "../../../public/src/include/includes.h" + +#ifndef _SCCP_CONST_DEF +#define _SCCP_CONST_DEF + +#define SCCP_CONF_FILE "./conf/sccp.conf" +#define SINGLE_MODE 1 +#define spLogDebug_MASK 0xFFFFFFFF + + +#define GetValueString(i,p,Maxtrix,IdMax) \ + { \ + if( (i) >= (IdMax) ) \ + { \ + (p) = Maxtrix[(IdMax)].pStr; \ + } \ + else \ + { \ + (p) = Maxtrix[(i)].pStr; \ + } \ + } + + +typedef enum SCCP_WATCH_DOG +{ + WDS_RECV_PRI, + +} +SP_WatchDog; + +#define SCCP_SHM_KEY 0x00116688 +#define SCCP_SHM_PERM 0666 +//#define SCCP_OID {1,3,6,1,4,1,1373,1,3,2,2,3} +#define SCCP_OID {1,3,6,1,4,1,1373,2,3,2,3} +#define SCCP_OIDLEN 11 +#define SCCP_SERNUM_LEN 4 + +/*Message type-----> */ +#define CR_MSG 1 +#define CC_MSG 2 +#define CREF_MSG 3 +#define RLSD_MSG 4 +#define RLC_MSG 5 +#define DT1_MSG 6 +#define DT2_MSG 7 +#define AK_MSG 8 +#define UDT_MSG 9 +#define UDTS_MSG 10 +#define ED_MSG 11 +#define EA_MSG 12 +#define RSR_MSG 13 +#define RSC_MSG 14 +#define ERR_MSG 15 +#define IT_MSG 16 +#define XUDT_MSG 17 +#define XUDTS_MSG 18 +#define LUDT_MSG 19 +#define LUDTS_MSG 20 +//Intra message type +#define RF_MSG 100 +/*SCMG Message */ +#define SSA_MSG 1 //subsystem allowed +#define SSP_MSG 2 //subsystem prohibited +#define SST_MSG 3 //subsystem status test +#define SOR_MSG 4 //subsystem out of service request +#define SOG_MSG 5 //subsystem out of service grant +#define SSC_MSG 6 //SCCP/subsystem congested +/*SCCP parameter name codes */ +#define P_EOP 0 +#define P_DLR 1 +#define P_SLR 2 +#define P_CDA 3 +#define P_CGA 4 +#define P_PLC 5 +#define P_EOD 6 +#define P_PR 7 +#define P_SEQ 8 +#define P_Credit 9 +#define P_RLC 10 +#define P_RTC 11 +#define P_RSC 12 +#define P_ERC 13 +#define P_RFC 14 +#define P_Data 15 +#define P_SEG 16 +#define P_HC 17 +#define P_Importance 18 +#define P_Ldata 19 +////////////////////////////////////////////////// +#define SCCP_SSN_NUM 256 +#define SCCP_RLSSN_NUM 128 +#define SCCP_RLSPC_NUM 64 +#define SCCP_ROUTE_NUM 1024 +#define SCCP_ROUTE_NODE_NUM 65535 + +#define LR_NUM 1024 +#define LR_MSG_NUM 50 +#define SS_MSG_NUM 1024 +#define SLS_NUM 16 +#define SCCP_MSG_MAXLEN 256 +#define MAX_HC 15 +#define SCOC_SSN 10 + +#define Unrestricted 1 +#define Restricted 0 + +#define RI_GT 0 //Route on GT +#define RI_SSN 1 //Route on SSN + +#define NP_IMSI 6 +#define NP_MSISDN 1 +#define NP_GT 7 + +#define TT_0 0 +#define TT_1 1 +#define TT_4 4 +//message source----> +#define FROM_MTP 1 +#define FROM_SCLC 2 +#define FROM_SCOC 3 +#define FROM_SCMG 4 +//subsystem number +#define SSN_NOTUSE 0 +#define SSN_SCMG 1 +#define SSN_ITU 2 //reserved for ITU-T allocation +#define SSN_ISUP 3 +#define SSN_OMC 4 +#define SSN_MAP 5 +#define SSN_HLR 6 +#define SSN_VLR 7 +#define SSN_MSC 8 +#define SSN_EIC 9 //Equipment Identifier Certer + +//scoc state +#define SCOC_IDLE 0 +#define SCOC_CPO 1 //connection pending outgoing +#define SCOC_CPI 2 //connection pending incoming +#define SCOC_CPMID 3 //connection pending(intermediate node) +#define SCOC_WCC 4 //Wait connection confirm +#define SCOC_ACTIVE 5 //Active +#define SCOC_MID 6 //Active(intermediate node) +#define SCOC_DP 7 //disconnect pending +#define SCOC_DPMID 8 //disconnect pending(intermediate node) + +#define SCOC_Interval 20*1000 //20ms +//Timer (SCMG) +#define T_idle 30 //(s) +#define T_sst 2 //20s interval = 10s +#define T_hbrecv 3 //30s interval = 10s + +//#define SST_Start 0 +//#define SST_Pend 1 +//#define SST_Stop 2 + +//SP/SCCP/SS status +#define ST_Disable 1 +#define ST_Congest 2 +#define ST_Enable 3 + +#define SCCPDB_TCAP 0x01 +#define SCCPDB_UDT 0x02 +#define SCCPDB_AIF 0x04 +#define SCCPDB_ERR 0x08 +#define SCCPDB_SCMG 0x10 +#define SCCPDB_TIME 0x20 +#define SCCPDB_SNMP 0x40 +#define SCCPDB_MSG 0x80 +#define SCCPDB_ADDR 0x100 +#define SCCPDB_STP 0x1000 +#define SCCPDB_USER 0x2000 +#define SCCPDB_MTP3 0x4000 +#define SCCPDB_XUDT 0x8000 + +/*******************Release cause*******************/ +#define RL_EUO 0 //end user originated +#define RL_EUC 1 //end user congestion +#define RL_EUF 2 //end user failure +#define RL_SUO 3 //SCCP user originated +#define RL_RPL 4 //remote procedure error +#define RL_ICD 5 //inconsistent connection data +#define RL_AF 6 //access failure +#define RL_AC 7 //access congestion +#define RL_SF 8 //subsystem failure +#define RL_SC 9 //subsystem congestion +#define RL_MF 10 //MTP failure +#define RL_NC 11 //network congestion +#define RL_EORT 12 //expiration of reset timer +#define RL_EORIT 13 //expriation of receive inactivity timer +#define RL_R 14 //reserved +#define RL_U 15 //unqualified +#define RL_SCCPF 16 //SCCP failure + +/*******************return cause*******************/ +#define RT_NTFN 0 //no translation for an address of such nature +#define RT_NTFA 1 //no translation for this specific address +#define RT_SC 2 //subsystem congestion +#define RT_SF 3 //subsystem failure +#define RT_UU 4 //unequipped user +#define RT_MF 5 //MTP failure +#define RT_NF 6 //network congestion +#define RT_U 7 //unqulified +#define RT_EIMT 8 //error in message transport +#define RT_EILP 9 //error in local processing +#define RT_DCPR 10 //destination cannot perform reassembly +#define RT_SCCPF 11 //SCCP failure +#define RT_HCV 12 //hop counter violation +#define RT_SNS 13 //segmentation not supported +#define RT_SMTF 14 //segmentation failure + +/*******************reset cause*******************/ +#define RS_EUO 0 //end user originated +#define RS_SUO 1 //SCCP user originated +#define RS_IPS 2 //incorrect P(S) +#define RS_IPR 3 //incorrect P(R) +#define RS_OFW 4 //remote procedure error-message out of window +#define RS_IPSAI 5 //remote procedure error-incorrect P(S) after initialization +#define RS_G 6 //remote procedure error-general +#define RS_REUO 7 //remote end user operational +#define RS_NO 8 //network operational +#define RS_AO 9 //access operational +#define RS_NC 10 //network congestion +#define RS_R 11 //reserved +#define RS_U 12 //unqualified + +#endif + +static const StringVal spUlPrimitiveStr[] = +{ + {N_UNITDATA_REQ , "N-Unit Data Request "}, + {N_UNITDATA_IND , "N-Unit Data Indicate "}, + {N_NOTICE_IND , "N-Notice Indicate "}, + {N_CONNECT_REQ , "N-Connect Request "}, + {N_CONNECT_IND , "N-Connect Indicate "}, + {N_CONNECT_RSP , "N-Connect Response "}, + {N_CONNECT_CFM , "N-Connect Confirm "}, + {N_DISCONNECT_REQ, "N-Disconnect Request "}, + {N_DISCONNECT_IND, "N-Disconnect Indicate"}, + {N_DATA_REQ , "N-DATA Request "}, + {N_DATA_IND , "N-DATA Indicate "}, + {N_DATAAK_REQ , "N-DataAk Request "}, + {N_DATAAK_IND , "N-DataAk Indicate "}, + {N_EDATA_REQ , "N-EData Request "}, + {N_EDATA_IND , "N-EData Indicate "}, + {N_RESET_REQ , "N-Reset Request "}, + {N_RESET_IND , "N-Reset Indicate "}, + {N_RESET_RSP , "N-Reset Response "}, + {N_RESET_CFM , "N-Reset Confirm "}, + {N_INFORM_REQ , "N-Inform Request "}, + {N_INFORM_IND , "N-Inform Indicate "}, + {SPUI_PRI_MAX , "Unknow SCCP Primitive"}, +}; + +#define spGetUlPrimitiveStr(e,p)\ + WxcAssert( (e) < SP_PRI_MAX ,\ + "spGetUlPrimitiveStr Primitive id error" );\ + GetValueString(e,p,spUlPrimitiveStr,SPUI_PRI_MAX) + +typedef enum SCOC_MESSAGE_TYPE +{ + SP_MSG0_RESERVED, /* Reserved */ + SP_MSG_CR = 1, /* connection request */ + SP_MSG_CC = 2, /* connection confirm */ + SP_MSG_CREF = 3, /* connection refused */ + SP_MSG_RLSD = 4, /* release request */ + SP_MSG_RLC = 5, /* release confirm */ + SP_MSG_DT1 = 6, /* Data Form 1 */ + SP_MSG_DT2 = 7, /* Data Form 2 */ + SP_MSG_AK = 8, /* Data acknowledge */ + SP_MSG_UDT = 9, /* Unit data */ + SP_MSG_UDTS = 10, /* Unit data */ + SP_MSG_ED = 11, /* Expedited data */ + SP_MSG_EA = 12, /* Expedited data acknowledge */ + SP_MSG_RSR = 13, /* Reset request */ + SP_MSG_RSC = 14, /* Reset confirm */ + SP_MSG_ERR = 15, /* PDU error */ + SP_MSG_IT = 16, /* Inactivity test */ + SP_MSG_XUDT = 17, /* XUDT */ + SP_MSG_XUDTS= 18, /* XUDTS */ + SP_MSG_LUDT = 19, /* LUDT */ + SP_MSG_LUDTS= 20, /* LUDTS */ + SP_MSG_RF = 21, /* Routing Fail */ + SP_MSG_MAX , /* MAX message type undefine */ +} +CO_MsgType; + +static const StringVal sp_messagetype_str[] = +{ + {SP_MSG0_RESERVED, " Message Reserved" }, + {SP_MSG_CR, " Connection request" }, + {SP_MSG_CC, " Connection confirm" }, + {SP_MSG_CREF, " Connection refused" }, + {SP_MSG_RLSD, " Release request" }, + {SP_MSG_RLC, " Release confirm" }, + {SP_MSG_DT1, " Data Form 1" }, + {SP_MSG_DT2, " Data Form 2" }, + {SP_MSG_AK, " Data acknowledge" }, + {SP_MSG_UDT, " Unit data" }, + {SP_MSG_UDTS, " Unit data service" }, + {SP_MSG_ED, " Data acknowledge" }, + {SP_MSG_EA, " EData acknowledge" }, + {SP_MSG_RSR, " Reset request" }, + {SP_MSG_RSC, " Reset confirm" }, + {SP_MSG_ERR, " PDU error" }, + {SP_MSG_IT, " Inactivity test" }, + {SP_MSG_XUDT, " XUDT" }, + {SP_MSG_XUDTS, " XUDTS" }, + {SP_MSG_LUDT, " LUDT" }, + {SP_MSG_LUDTS, " LUDTS" }, + {SP_MSG_RF , " Routing Fail" }, + {SP_MSG_MAX, " Undefine" }, +}; + +#define spGetMsgStr(MsgId,pStr)\ + WxcAssert( (MsgId) >= SP_MSG_CR && (MsgId) < SP_MSG_MAX ,\ + "spGetMsgStr MsgId error" );\ + GetValueString(MsgId,pStr,sp_messagetype_str,SP_MSG_MAX) + +//temp define , define in pub_base.h +#define STR(s) #s +#define FILL_VALSTR(n) {n,#n} + +static const StringVal spTimerOutStr[] = +{ + FILL_VALSTR(T_CONNEST_OUT), + FILL_VALSTR(T_IAS_OUT), + FILL_VALSTR(T_IAR_OUT), + FILL_VALSTR(T_REPEATE_RLS_OUT), + FILL_VALSTR(T_RLS_OUT), + FILL_VALSTR(T_RESET_OUT), + FILL_VALSTR(T_GUARD_OUT), + FILL_VALSTR(T_INTERNAL_OUT), + FILL_VALSTR(SPTM_PRI_MAX), +}; + +#define spGetTimerOutStr(MsgId,pStr)\ + WxcAssert( (MsgId) >= T_CONNEST_OUT && (MsgId) < SPTM_PRI_MAX ,\ + "spGetTimerOutStr MsgId error" );\ + GetValueString(((MsgId)-SPCR_PRI_MAX-1),pStr,spTimerOutStr,SPTM_PRI_MAX) + + +#define T_UNDEFINE 100000 + +#define T_SP_10ms 1 +#define T_SP_1s T_SP_10ms*100 +#define T_SP_1MIN T_SP_1s*60 +#define T_CONNEST_MAX T_SP_1s*2 //1~2 sec +#define T_IAS_MAX T_SP_1MIN*5 //5~10 mins +#define T_IAR_MAX T_SP_1MIN*11 //11~21 mins +#define T_RLS_MAX T_SP_1s*15 //10~20 sec +#define T_REPEATE_RLS_MAX T_SP_1s*15 //10~20 sec +#define T_RESET_MAX T_SP_1s*15 //10~20 sec +#define T_GUARD_MAX T_SP_1MIN*24 //23~25 mins +#define T_INTERNAL_MAX T_SP_1MIN //1 mins + +typedef enum SCOC_TRANSITION_STATUS +{ + CO_STATUS_INIT, //Transtion initialed + CO_STATUS_IDLE, //status Idle + CO_STATUS_WTCC, //Wait Connection confirm + CO_STATUS_ACTV, //Active + CO_STATUS_CONP, //Connection pending + CO_STATUS_CPIC, //Connection pending incoming + CO_STATUS_CPOG, //Connection pending outgoing + CO_STATUS_DSCP, //Disconnect pending + CO_STATUS_DPIC, //Disconnect pending incoming + CO_STATUS_DPOG, //Disconnect pending outgoing + CO_STATUS_DPBH, //Disconnect pending both + CO_STATUS_NMOP, //Normal operation + CO_STATUS_WSEA, //Wait for sending EA Message + CO_STATUS_RSIC, //Reset outgoing + CO_STATUS_RSOG, //Reset incoming + CO_STATUS_RSBH, //Reset both + CO_STATUS_MTBK, //Maintenance blocking + CO_STATUS_RSTA, //Restart + CO_STATUS_MAX, +} +CO_Status; + +static const StringVal sp_co_state_str[] = +{ + {CO_STATUS_INIT, "Transtion initialed" }, + {CO_STATUS_IDLE, "status Idle" }, + {CO_STATUS_WTCC, "Wait Connection confirm" }, + {CO_STATUS_ACTV, "Active" }, + {CO_STATUS_CONP, "Connection pending " }, + {CO_STATUS_CPIC, "Connection pending incoming"}, + {CO_STATUS_CPOG, "Connection pending outgoing"}, + {CO_STATUS_DSCP, "Disconnect pending" }, + {CO_STATUS_DPIC, "Disconnect pending incoming"}, + {CO_STATUS_DPOG, "Disconnect pending outgoing"}, + {CO_STATUS_DPBH, "Disconnect pending both" }, + {CO_STATUS_NMOP, "Normal operation" }, + {CO_STATUS_WSEA, "Wait for sending EA Message"}, + {CO_STATUS_RSIC, "Reset outgoing" }, + {CO_STATUS_RSOG, "Reset incoming" }, + {CO_STATUS_RSBH, "Reset both" }, + {CO_STATUS_MTBK, "Maintenance blocking" }, + {CO_STATUS_RSTA, "Restart" }, + {CO_STATUS_MAX, "Error Transtion state" }, +}; + +#define spGetCoStateStr(s,p)\ + WxcAssert( (s) < CO_STATUS_MAX ,\ + "spGetCoStateStr co status error" );\ + GetValueString(s,p,sp_co_state_str,CO_STATUS_MAX) + +typedef enum CO_INSTANCE_SIDE +{ + CO_INST_SIDE_ORG, + CO_INST_SIDE_DST, + CO_INST_SIDE_MID, + CO_INST_SIDE_MAX, +} +CO_InstSide; + +static const StringVal sp_co_instanceside_str[] = +{ + {CO_INST_SIDE_ORG, "Originating node side" }, + {CO_INST_SIDE_DST, "Destination node side" }, + {CO_INST_SIDE_MID, "intermidediate node side"}, + {CO_INST_SIDE_MAX, "Undefine Node Side" }, +}; + +#define spGetCoInstanceSide(s,p)\ + WxcAssert( (s) < CO_INST_SIDE_MAX ,\ + "spGetCoInstanceSide co sideid error" );\ + GetValueString(s,p,sp_co_instanceside_str,CO_INST_SIDE_MAX) + +static const StringVal co_reason_str[] = { + //reason : originated network serice provider + {REA_PDISC_ACNN, + "disconnection –abnormal condition(non-transient nature)" }, + {REA_PDISC_ACTN, "disconnection –abnormal condition of transient nature"}, + {REA_PDISC_IS, "disconnection –invalid state1" }, + {REA_PDISC_RIP, "disconnection –release in progress1" }, + {REA_PCREF_DAU, "CREF2 –destination address unknown " }, + {REA_PCREF_DINC, + "CREF2 –destination inaccessible/non-transient condition" }, + {REA_PCREF_DITCs, "CREF2 –destination inaccessible/transient condition" }, + {REA_PCREF_QNANC, "CREF2 –QOS not available/non-transient condition" }, + {REA_PCREF_QNATC, "CREF2 –QOS not available/transient condition" }, + {REA_PCREF_RUNC, "CREF2 –reason unspecified/non-transient condition" }, + {REA_PCREF_RUTC, "CREF2 –reason unspecified/transient condition" }, + {REA_PCREF_LE, "CREF2 –local error1" }, + {REA_PCREF_IS, "CREF2 –invalid state1" }, + {REA_PCREF_NT, "CREF2 –no translation1" }, + {REA_PCREF_IRP, "CREF2 –in restart phase1" }, + {REA_PCREF_HCV, "CREF2 –hop counter violation" }, + + //reason : originated network serice user + {REA_UDISC_NC, "disconnection –normal condition" }, + {REA_UDISC_ABC, "disconnection –abnormal condition" }, + {REA_UDISC_EUC, "disconnection –end user congestion" }, + {REA_UDISC_EUF, "disconnection –end user failure" }, + {REA_UDISC_SUO, "disconnection –SCCP user originated" }, + {REA_UDISC_ACC, "disconnection –access congestion" }, + {REA_UDISC_AF, "disconnection –access failure" }, + {REA_UDISC_SC, "disconnection –subsystem congestion" }, + {REA_UCREF_NTC, "CREF2–non-transient condition" }, + {REA_UCREF_TC, "CREF2–transient condition" }, + {REA_UCREF_IIIN, "CREF2–incompatible information in NSDUs" }, + {REA_UCREF_EUO, "CREF2–end user originated" }, + {REA_UCREF_EUC, "CREF2–end user congestion" }, + {REA_UCREF_EUF, "CREF2–end user failure" }, + {REA_UCREF_SUO, "CREF2 –SCCP user originated" }, + {REA_UCREF_ACC, "CREF2 –access congestion" }, + {REA_UCREF_AF, "CREF2 –access failure" }, + {REA_UCREF_SC, "CREF2 –subsystem congestion" }, + + //Notice service reason : N-inform values + {REA_NINFO_FAIL, "work service provider failure" }, + {REA_NINFO_CONG, "work service congestion" }, + {REA_NINFO_PQC, "work service provider QOS change" }, + {REA_UINFO_FAIL, "work service user failure" }, + {REA_UINFO_CONG, "work service user congestion" }, + {REA_UINFO_PQC, "work service user QOS change" }, + {REA_INFO_USPC, "reason unspecified" }, + + {REA_UNDEFINED, "Undefined" }, +}; + +#define coGetReasonStr(r,p)\ + WxcAssert( (r) >= REA_PDISC_ACNN && (r) < REA_UNDEFINED ,\ + "coGetReasonStr reason id error" );\ + GetValueString(r,p,co_reason_str,REA_UNDEFINED) + + +typedef enum SCOC_INTERNAL_ERROR +{ + CO_FATAL_STATE, + CO_FATAL_SIDE, +} +CO_InterErr; + diff --git a/omc/plat/sccp/src/include/scoc.h b/omc/plat/sccp/src/include/scoc.h new file mode 100644 index 0000000..a65ec88 --- /dev/null +++ b/omc/plat/sccp/src/include/scoc.h @@ -0,0 +1,274 @@ +////////////////////////////////////////////////// +//Title : scoc.h +//Auhtor : Liu Wei +//Desc : SCCP Connection-Oriented Control +//Created : 2007-04-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _SCOC_H_ +#define _SCOC_H_ + +#include "scoc_if.h" +#include "../../../public/src/include/pub_list.h" + +#define spLogDebug_STATIC + +typedef struct SCCP_PRIMITIVE_CR_PRIMITIVE +{ + u8 uUiPri; + u8 uAnsiFlag; + u16 wConnId; + Intra_Msg tIntraMsg; +} +SP_CrPriPara; + +typedef union SCCP_PRIMITVE_POOL_Elemnet +{ + SP_UiPriPara tUiPri; + SP_CrPriPara tCrPri; +} +SP_PriPoolEle; + +typedef enum SCOC_FSM_ERROR +{ + ERR_NONE, //show state string + ERR_FSM_DISCARD, + ERR_FSM_ERROR, + ERR_FSM_FATAL, + ERR_FSM_UNEXPECT_SIDE, + ERR_FSM_RESERVED, + ERR_FSM_UNEXPECT_PRI, + ERR_FSM_UNKOWN_ERROR_CODE, + ERR_TIMER_OUT, +} +CO_FsmErr; + +typedef struct SCOC_QOS +{ + u8 uInSequence; + u8 uReturnOnErr; + u8 uImportance; + u8 uHopcount; + u8 uMbit; + u8 uRecvSequnce; + u8 uSendSequnce; +} +CO_Qos; + +typedef struct SCOC_CAUSE +{ + u8 uRelCause; + u8 uReturnCause; + u8 uResetCause; + u8 uErrorCause; + u8 uRejectCause; +} +CO_Cause; + +#define MAX_SCCP_MSG 256 + +typedef struct SCOC_Message +{ + u8 uMsgType; + u8 uMsgClass; + u8 uMsgFlag; + u8 aSLR[SP_REF_LEN]; // 0x01 SLR present + u8 aDLR[SP_REF_LEN]; // 0x02 DLR present + SCCP_ADDR tCDA; // 0x04 CDA present + SCCP_ADDR tCGA; // 0x08 CGA present + CO_Qos tQos; // 0x10 QOS present + CO_Cause tCause; // 0x20 CAUSE present + u8 aMsgConent[MAX_SCCP_MSG]; // 0x40 DATA present +} +CO_Msg; + +typedef struct CO_TIMER +{ + u32 tmConnEst; + u32 tmIas; + u32 tmIar; + u32 tmRepeatRel; + u32 tmRel; + u32 tmReset; //unsupportted now + u32 tmGuard; //unsupportted now + //u32 tmIas; + //u32 tmIar; + //u32 tmIT; + u32 tmInternal; +} +CO_Timer; + +typedef struct CO_CONNECTION_Section +{ + CO_Status uCState; + SP_Pri uPri; + u8 uAnsiFlag; + CO_InstSide uSide; + + u8 uSLS; + + u8 uNetId; + int nDPC; + int nOPC; + u8 aSLR[SP_REF_LEN]; + u8 aDLR[SP_REF_LEN]; + u8 uClass; + u8 uCredit; + u8 eREA; + u8 eOR; + + SCCP_ADDR tCDA; + SCCP_ADDR tCGA; + SCCP_ADDR tSPA; + + SP_UD tUD; + + CO_Timer tmSCOC; +} +CO_ConnSection; + +typedef struct SCOC_POOL_PRIMITIVE_IN +{ + +} +CO_PoolPriIn; + + +typedef struct SCLC_DATA_BLOCK +{ + +} +CL_DataBlock; + +typedef struct SCRC_DATA_BLOCK +{ + +} +CR_DataBlock; + +typedef struct SCMG_DATA_BLOCK +{ + +} +CM_DataBlock; + +#define CO_CS_MPORT 8192 + +#ifdef DEBUG + +typedef enum SCOC_DEBUG_STATIC_VALUE +{ + GET_IN_POOL = 30, + PUT_IN_POOL, + READ_IN_POOL, + WRITE_IN_POOL, + GET_OUT_POOL, + PUT_OUT_POOL, + PUT_ELE_APT, + PUT_ELE_SUC, + UL_POST_CO_APT, + UL_POST_CO, + CO_SUBMIT_UL_APT, + CO_SUBMIT_UL, + CO_TO_CR_APT, + CO_TO_CR, + CR_TO_CO_APT, + CR_TO_CO, + SP_TIMER_OUT, +} +CO_DebugStaticVal; + + +typedef struct SCOC_DEBUG_STATIC +{ + u32 dGetInPool; + u32 dPutInPool; + u32 dReadInPool; + u32 dWriteInPool; + + u32 dGetOutPool; + u32 dPutOutPool; + u32 dPutEleApt; + u32 dPutEleSuc; + + u32 dCoSubmitUlApt; + u32 dCoSubmitUl; + u32 dUlPostCoApt; + u32 dUlPostCo; + + u32 dCo2CrApt; + u32 dCo2Cr; + u32 dCr2CoApt; + u32 dCr2Co; + + u32 dTimerOut; + u32 dbusyElem; +} +CO_DebugStatic; +#endif + + + +typedef struct SCOC_DATA_BLOCK +{ + u32 wConnIdCount; + CO_ConnSection tCSInst[CO_CS_MPORT]; + CO_DebugStatic tCoDebugStatic; +} +CO_DataBlock; + +typedef struct SCCP_ENTITY +{ + u32 dLocalIP; + u32 dAlterIP; + u32 dSysID; + CL_DataBlock tCl; + CO_DataBlock tCo; + CR_DataBlock tCr; + CM_DataBlock tCm; +} +SP_Entity; + +/* by simon at 23/9/26 */ +extern SP_Entity tSpEntity; +extern SP_Entity *pSp; + + +typedef enum SCOC_POOL_OP +{ + CO_GET_POOL, + CO_READ_POOL, + CO_PUT_POOL, + CO_WRITE_POOL, +} +CO_PoolOp; + +typedef struct SCOC_POOL_ELEMENT +{ + POOL_ENTRY ( SCOC_POOL_ELEMENT ) tPointer; + SP_PriPoolEle tPri; + BYTE flag; +} +CO_PoolEle; + +typedef struct SCOC_POOL +{ + POOL_HEAD ( CO_PriPool, SCOC_POOL_ELEMENT ) tPoolHead; + struct CO_PriPool *pPoolHead; + int uMaxPoolSize; + int uPoolCount; +} +CO_Pool; + +#define MAX_IN_POOL 1024 +#define MAX_OUT_POOL 512 + +extern CO_Pool *pInCoPool; +extern CO_Pool *pOutCoPool; + + +#endif diff --git a/omc/plat/sccp/src/include/scoc_if.h b/omc/plat/sccp/src/include/scoc_if.h new file mode 100644 index 0000000..077abed --- /dev/null +++ b/omc/plat/sccp/src/include/scoc_if.h @@ -0,0 +1,559 @@ +////////////////////////////////////////////////// +//Title : SCCP_if.h +//Auhtor : Liu Wei +//Desc : SCOC interface header +//Created : 2007-05-07 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#ifndef _SCCP_IF_H_ +#define _SCCP_IF_H_ + +#include "../../../public/src/include/public.h" + +#define MAX_DIGITS 10 +#define SP_REF_LEN 3 + +/////////////////////////////////////////////////// +typedef struct SCCP_ADDRESS +{ + DWORD ip; + int DPC; + BYTE NetID; + BYTE SSN; + BYTE RI; + BYTE GTI; + BYTE TT; + BYTE NP; + BYTE ES; + BYTE NAI; + BYTE len; + BYTE GTAI[MAX_DIGITS]; + BYTE AI; +} +SCCP_ADDR; + +typedef enum SCCP_LI_MTP_PRIMITIVE +{ + MTP_TARNSFER, + MTP_RESUME, + MTP_STATUS, + MTP_UPU, +} +SP_LiMTPPri; + +typedef enum SCCP_UI_N_PRIMITIVE +{ + N_UNITDATA_REQ, + N_UNITDATA_IND, + N_NOTICE_IND, + N_CONNECT_REQ, + N_CONNECT_IND, + N_CONNECT_RSP, + N_CONNECT_CFM, + N_DISCONNECT_REQ, + N_DISCONNECT_IND, + N_DATA_REQ, + N_DATA_IND, + N_DATAAK_REQ, + N_DATAAK_IND, + N_EDATA_REQ, + N_EDATA_IND, + N_RESET_REQ, + N_RESET_IND, + N_RESET_RSP, + N_RESET_CFM, + N_INFORM_REQ, + N_INFORM_IND, + SPUI_PRI_MAX, + + R_CR , /* connection request */ + R_CC , /* connection confirm */ + R_CREF , /* connection refused */ + R_RLSD , /* release request */ + R_RLC , /* release confirm */ + R_DT1 , /* Data Form 1 */ + R_DT2 , /* Data Form 2 */ + R_AK , /* Data acknowledge */ + R_UDT , /* Unit data */ + R_UDTS , /* Unit data */ + R_ED , /* Expedited data */ + R_EA , /* Expedited data acknowledge */ + R_RSR , /* Reset request */ + R_RSC , /* Reset confirm */ + R_ERR , /* PDU error */ + R_IT , /* Inactivity test */ + R_XUDT , /* XUDT */ + R_XUDTS, /* XUDTS */ + R_LUDT , /* LUDT */ + R_LUDTS, /* LUDTS */ + R_RF , /* Routing Fail */ + R_RLS_ERR, /* Release err */ + R_CR2 , /* connection request type 2 */ + SPCR_PRI_MAX , /* MAX CR2CO Primitive */ + + T_CONNEST_OUT, + T_IAS_OUT, + T_IAR_OUT, + T_REPEATE_RLS_OUT, + T_RLS_OUT, + T_RESET_OUT, + T_GUARD_OUT, + T_INTERNAL_OUT, + SPTM_PRI_MAX, + + N_CONNECT_T1, + RELAY, + TRAFFIC, + NO_TRAFFIC, + I_DISCONNECT, + I_RESET, + I_CONGESTED, + I_UNCONGESTED, + I_RESET_REQ, + SP_PRI_MAX, +} +SP_Pri; + +/* + * /SCOC upper layer primitive parameters + * + * /CDA : Called address CGA : Calling address + * /CI : Connection identification + * /CRS : Confirm request slecttion + * /EDS : Expedited data selection + * /QOS : Quality of service parameter set + * /OR : Originator RA : Responding address + * /RCS : Receipt confirmation selection + * /REA : Reason OR : Originator + * /RR : Return Resaon SEQ : Sequence Control + * /UD : User data RO : Return Optinal selection + * + */ + +typedef struct SCCP_QUALITY_OF_SERVICE +{ + //reserved + u8 uQOS; +} +SP_QOS; //Quality of service parameter set + +typedef enum SCCP_ORIGINATOR +{ + NSP, //the network service provider + NSU, //the network service user + UNDEFINED, //undefined +} +SP_OR; //Originator + +typedef struct SCCP_REQUEST_CONFIRM_SELECTION +{ + //reserved + u8 uRCS; +} +SP_RCS; //Confirm request slecttion + +/* + * Reason parameter + * + * Note: coGetReasonStr(u8 Reason , char *pReasonStr) + * + */ + +typedef enum SCCP_REASON +{ + //reason : originated network serice provider + REA_PDISC_ACNN, //Disconn –abnormal condition of non-transient nature + REA_PDISC_ACTN, //Disconn –abnormal condition of transient nature + REA_PDISC_IS, //Disconn –invalid state1 + REA_PDISC_RIP, //Disconn -release in progress1 + REA_PCREF_DAU, //CREF –destination address unknown(non-transient condition) + REA_PCREF_DINC, //CREF2 –destination inaccessible/non-transient condition + REA_PCREF_DITCs, //CREF2 –destination inaccessible/transient condition + REA_PCREF_QNANC, //CREF2 –QOS not available/non-transient condition + REA_PCREF_QNATC, //CREF2 –QOS not available/transient condition; + REA_PCREF_RUNC, //CREF2 –reason unspecified/non-transient condition + REA_PCREF_RUTC, //CREF2 –reason unspecified/transient condition; + REA_PCREF_LE, //CREF2 –local error1; + REA_PCREF_IS, //CREF2 –invalid state1; + REA_PCREF_NT, //CREF2 –no translation1; + REA_PCREF_IRP, //CREF2 –in restart phase1; + REA_PCREF_HCV, //CREF2 –hop counter violation. + + //reason : originated network serice user + REA_UDISC_NC, //Disconn –normal condition; + REA_UDISC_ABC, //Disconn –abnormal condition; + REA_UDISC_EUC, //Disconn –end user congestion; + REA_UDISC_EUF, //Disconn –end user failure; + REA_UDISC_SUO, //Disconn –SCCP user originated; + REA_UDISC_ACC, //Disconn –access congestion; + REA_UDISC_AF, //Disconn –access failure; + REA_UDISC_SC, //Disconn –subsystem congestion; + REA_UCREF_NTC, //CREF2 -non-transient condition; + REA_UCREF_TC, //CREF2 -transient condition; + REA_UCREF_IIIN, //CREF2 -incompatible information in NSDUs; + REA_UCREF_EUO, //CREF2 -end user originated; + REA_UCREF_EUC, //CREF2 -end user congestion; + REA_UCREF_EUF, //CREF2 -end user failure; + REA_UCREF_SUO, //CREF2 –SCCP user originated; + REA_UCREF_ACC, //CREF2 –access congestion; + REA_UCREF_AF, //CREF2 –access failure; + REA_UCREF_SC, //CREF2 –subsystem congestion. + + //Notice service reason : N-inform values + REA_NINFO_FAIL, //N-Inform – network service provider failure; + REA_NINFO_CONG, //N-Inform – network service congestion; + REA_NINFO_PQC, //N-Inform – network service provider QOS change; + REA_UINFO_FAIL, //N-Inform – network service user failure; + REA_UINFO_CONG, //N-Inform – network service user congestion; + REA_UINFO_PQC, //N-Inform – network service user QOS change; + REA_INFO_USPC, //N-Inform – reason unspecified. + + REA_UNDEFINED, //undefined +} +SP_REA; //Reason + +typedef struct SCCP_RETURN_OPTINAL +{ + //reserved + u8 uRO; +} +SP_RO; //return Optinal + +typedef struct SCCP_RETURN_REASON +{ + //reserved + u8 uRR; +} +SP_RR; //Return Reason + +typedef struct SCCP_SEQUENCE +{ + //reserved + u8 uSEQ; +} +SP_SEQ; //Sequence control + +#define SP_MAX_UD 256 + +typedef struct SCCP_USER_DATA +{ + u8 uDataLen; + u8 aUserData[SP_MAX_UD]; +} +SP_UD; //User data + +typedef union SCCP_UI_PRIMITIVE_UNION +{ + struct PriNUnitDataReq //reserved for sclc ,not used now + { + u8 uSLS; + SP_SEQ tSEQ; + SCCP_ADDR tCDA; + SCCP_ADDR tCGA; + SP_RO tRO; + SP_UD tUD; + } + tPriNUDataReq; + + struct PriNUnitDataInd //reserved for sclc ,not used now + { + u8 uSLS; + SP_UD tUD; + SCCP_ADDR tCDA; + SCCP_ADDR tCGA; + } + tPriNUDataInd; + + struct PriNNoticeInd //reserved for sclc ,not used now + { + SP_RR tRR; + SP_UD tUD; + SCCP_ADDR tCDA; + SCCP_ADDR tCGA; + } + tPriNNoticeInd; + + struct PriNConnectReq + { + //Mandatory + SCCP_ADDR tCDA; + SP_QOS tQOS; + //Optianal + u8 uOptFlag; + u8 tEDS; + u8 uImp; + SCCP_ADDR tCGA; + SP_UD tUD; + } + tPriNConnReq; + + struct PriNConnectInd + { + //Mandatory + SCCP_ADDR tCDA; + SP_QOS tQOS; + u8 aSLR[SP_REF_LEN]; + u8 uSLS; + u32 OPC; + u8 NetID; + + //Optianal + u8 uOptFlag; + u8 uImp; + SCCP_ADDR tCGA; + SP_UD tUD; + } + tPriNConnInd; + + struct PriNConnectRsp + { + //Mandatory + SP_QOS tQOS; + + //Optianal + u8 uOptFlag; + u8 tEDS; + u8 uImp; + SCCP_ADDR tRA; + SP_UD tUD; + } + tPriNConnRsp; + + struct PriNConnectCfm + { + //Mandatory + SP_QOS tQOS; + + //Optianal + u8 uOptFlag; + u8 uImp; + SCCP_ADDR tRA; + SP_UD tUD; + } + tPriNConnCfm; + + struct PriNDisconnectReq + { + //Mandatory + //SP_OR eOR; //always NSU + SP_REA eREA; + + //Optianal + u8 uOptFlag; + u8 uImp; + SCCP_ADDR tRA; + SP_UD tUD; + } + tPriNDisconnReq; + + struct PriNDisconnectInd + { + //Mandatory + SP_OR eOR; + SP_REA eREA; + + //Optianal + u8 uOptFlag; + u8 uImp; + SCCP_ADDR tRA; + SP_UD tUD; + } + tPriNDisconnInd; + + struct PriNDataReq + { + //Mandatory + SP_UD tUD; + + //Optianal + u8 uImp; + } + tPriNDataReq; + + struct PriNDataInd + { + //Mandatory + SP_UD tUD; + + //Optianal + u8 uImp; + } + tPriNDataInd; + + struct PriNDataAkReq + { + } + tPriNDataAkReq; + + struct PriNDataAkInd + { + } + tPriNDataAkInd; + + struct PriNEDataReq + { + SP_UD tUD; + } + tPriNEDataReq; + + struct PriNEDataInd + { + SP_UD tUD; + } + tPriNEDataInd; + + struct PriNResetReq + { + //SP_OR tOR; //always NSU + SP_REA eREA; + } + tPriNResetReq; + + struct PriNResetInd + { + SP_REA eREA; + SP_OR tOR; + } + tPriNResetInd; + + struct PriNResetRsp + { + } + tPriNResetRsp; + + struct PriNResetCfm + { + } + tPriNResetCfm; + + struct PriNInformReq + { + SP_SEQ tQOS; + SP_REA eREA; + } + tPriNInformRsp; + + struct PriNInformInd + { + SP_SEQ tQOS; + SP_REA eREA; + } + tPriNInformInd; +} +SP_UiPriUnion; + +typedef struct SCCP_UI_PRIMITIVE_PARAMETERS +{ + u8 uUiPri; + u8 uAnsiFlag; + u16 wConnId; //return by SCCP while PostSp for N_CONN_REQ + SP_UiPriUnion tPriUnion; +} +SP_UiPriPara; + +/////////////////////////////////////////////////////////////////////////// +// +// Name : PostSp +// Function : Upper layer post request/response primitive to sccp +// Parameter: pUiPriParam [sccp UL primitive buffer pointer] +// Note : Sccp Connid is implicit returned in "pUiPriParam" buffer +// : while N-Connect requesing +// Return : 0 Post Fail 1 Post Successful +// +/////////////////////////////////////////////////////////////////////////// +int PostSp ( SP_UiPriPara * pUiPriParam ); + +/////////////////////////////////////////////////////////////////////////// +// +// Name : SpSubmit +// Function : Upper layer fetch indicate/confirm primitive submited form sccp +// Parameter: pUiPriParam [sccp UL primitive buffer pointer] +// Return : 0 Fetch Fail 1 Fetch Successful +// +/////////////////////////////////////////////////////////////////////////// +int SpSubmit ( SP_UiPriPara * pUiPriParam, u8 uUlSapId ); + +/////////////////////Below is reserved, do not need to read///////////////////// + +/* + * \Inter-Layer Communication interface mode + * \ + * \Loose coupling mode : + * interface implementation based on message pool engine + * \Tight coupling mode : + * interface implementation based on function call and callback + * + * \Note : In order to be compatible with old user , use Loose coupling mode now + * + */ + +#define LOOSE_COUPLING_MODE 0 //Loose coupling mode +//#define TIGHT_COUPING_MODE + +#ifdef LOOSE_COUPLING_MODE //Loose coupling mode + +#else + +#ifdef TIGHT_COUPING_MODE //Tight coupling mode + +#error "Do not support Tight coupling mode ,please use \"LOOSE_COUPLING_MODE\" flag \n" + +/* + * \CFS(CallBack function Set) for SCCP sumbit primitives to SCCP user + * + * \The following Callback Fucntion set define the mapping of the primitives + * \which is submited to SCCP serivce user(s). It is used in tight coupling mode. + * + * \User A : Reserved for ISUP + * \User B : Q.711 Page 2 user part B not define + * \User C : Other SCCCP user e.g. AIF + */ + +typedef struct SCCP_SUBMIT_USERA_CFS +{ + //For Isup ,Not supported now +} +SP_UserA_CFS; + +typedef struct SCCP_SUBMIT_USERB_CFS +{ + //NULL Undefined in Q.711 +} +SP_UserB_CFS; + +typedef struct SCCP_SUBMIT_USERC_CFS +{ + void ( *spCBUi_N_UnitDataInd ) ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_UD * pUD ); + + void ( *spCBUi_N_NoticeInd ) ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_RR * pRR, SP_UD * pUD ); + + void ( *spCBUi_N_ConnectInd ) ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI ); + + void ( *spCBUi_N_ConnectCfm ) ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI ); + + void ( *spCBUi_N_DisconnectInd ) ( SP_OR * pOR, SP_OR * pRA, SP_REA * pREA, SP_UD * pUD, u8 uCI ); + + void ( *spCBUi_N_DataInd ) ( ); + + void ( *spCBUi_N_DataAkInd ) ( ); + + void ( *spCBUi_N_EDataInd ) ( ); + + void ( *spCBUi_N_ResetInd ) ( SP_OR * pOR, SP_REA * pREA, u8 uCI ); + + void ( *spCBUi_N_ResetCfm ) ( ); + + void ( *spCBUi_N_InformInd ) ( ); +} +SP_UserC_CFS; + +#endif + +#endif +/////////////////////Above is reserved, do not need to read///////////////////// + +#endif diff --git a/omc/plat/sccp/src/sccp.c b/omc/plat/sccp/src/sccp.c new file mode 100644 index 0000000..7d3857d --- /dev/null +++ b/omc/plat/sccp/src/sccp.c @@ -0,0 +1,390 @@ + +/**********************************************/ +/*Title: sccp.c */ +/*Descr: SCCP common procedure */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2002-7-18 */ + +/**********************************************/ + +#include "./include/sccp.h" +extern BYTE sccpDebugFull; + +ull SCCPSerialNumber; + +/*===========export================*/ +void sccp_reset ( ); + +/*===========import================*/ +extern void scrc_timer ( void ); +extern void sclc_timer ( void ); +extern void sccpmib_init ( void ); //sccpmib.c +extern void sccp_sethb ( void ); //sccpmib.c +extern void spLogDebug_setup ( void ); //sccpdebug.c +extern void spLogDebug_timer ( void ); //sccpdebug.c +extern void spLogDebug_csta ( BYTE npage, int instance ); //sccpdebug.c +extern void spLogDebug_local ( BYTE npage, BYTE nline ); +extern void localssn_timer ( void ); //scmg.c +extern void sst_timer ( void ); //scmg.c +extern int sccp_loadparam ( void ); //sccpparam.c +extern int BuildRouteIndex ( void ); +extern int GetMSISDNOfSSN(BYTE ssn, BYTE *msisdn); +extern int sccp_GetSSNType(BYTE ssn); +extern void coInit( ); +extern void coFsm( ); +extern void coTimerMng ( ); + +/* by simon at 23/9/25 */ +extern DWORD ExistIP[64]; +extern DWORD ExistIPNum; +SCOC_BUF ScocBuf; +LOCAL_SSN LocalSSN[256]; +u8 ExistSSN[64]; +u8 ExistSSNNum; +struct _dpc2sls +{ + int dpc; + u8 sls; +} dpc2sls[256]; // used for sequence control, add by Roy Jiang, 2007-09-17 + +struct sccp_msg_statistic +{ + DWORD msg_mtp_scoc; + DWORD msg_scoc_up; + DWORD mnp_send; + DWORD mnp_route; +} sccpmsg_st; + +SCCP_OPT SCCP_Param; +u8 MNP_Flag[2]; +SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +int RelatedSSNNum; +RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +int RelatedSPCNum; +RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; +GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; +SCCP_CSTA SccpCsta[96]; +DWORD SccpCstaInd; +SCCP_Capture_Buf SCCPCapBuf; + +/*===========private================*/ +int CollectLocalInfo ( ); +extern u32 dAlterIpBackup; //for protection +void sccp_init ( u32 sysID, u32 localIP, u32 alterIP ) +{ + time_t l_time; + struct tm *t; + static BYTE initonce = 0; + int i; + BYTE version[3] = SCCP_VERSION; + + if( initonce == 1 ) + return; + memcpy ( SCCP_Param.version, version, 3 ); + SCCPSerialNumber = 0; + sccp_reset ( ); + + /*initialize global parameter */ + memset(dpc2sls, 0xFF, sizeof(dpc2sls)); + + LocalSSN[1].ip[0] = INADDR_NONE; + LocalSSN[1].status[0] = ST_Enable; + + for ( i = 0; i < 256; i++ ) + LocalSSN[i].RegFlag = 0; + + l_time = time ( NULL ); + t = localtime ( &l_time ); + if( t == NULL ) + { + assert( 0 && "syscall: localtime fail "); + exit(0); + } + SccpCstaInd = t->tm_hour * 4 + t->tm_min / 15; + SccpCsta[SccpCstaInd].timestamp = l_time; + + coInit ( sysID, localIP, alterIP ); + dAlterIpBackup = alterIP; + sccpmib_init ( ); + + spLogDebug_setup ( ); + spLogDebug_csta ( 1, SccpCstaInd ); + + printf ( "%ld-%d-%d %d:%d:%d\n", l_time, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec ); + printf ( "SCCP Version R%dV%d_%02d ...... Finish initialization!\n", SCCP_Param.version[0], SCCP_Param.version[1], SCCP_Param.version[2] ); + initonce = 1; +} + +void sccp_init_serial_number ( BYTE * Serial ) +{ + SCCPSerialNumber = Str2Ull ( Serial ); +} + +void sccp_timer ( ) //called per 10ms +{ + static WORD m_state = 0, ch = 0; + struct tm *t; + time_t l_time; + + // BYTE flag; + + // flag = inb(0x0378); + // outb((flag | 0x04), 0x0378); + + //20ms task===> + sccpDebugFull = 0; + sclc_timer ( ); + scrc_timer ( ); + + coFsm ( ); + + spLogDebug_timer ( ); + + + coTimerMng(); + + if( SCCP_Param.T_reset > 0 ) + SCCP_Param.T_reset--; + else if( SCCP_Param.T_reset == 0 ) + { + spLogDebug_local ( 2, 1 ); + BuildRouteIndex ( ); + CollectLocalInfo ( ); + + SCCP_Param.T_reset = -1; + } + //10s task===> + switch ( ( m_state++ ) % 500 ) + { + case 0: //switch csta buffer + l_time = time ( NULL ); + t = localtime ( &l_time ); + if( t == NULL ) + { + assert( 0 && "syscall: localtime fail "); + exit(0); + } + if( ch == 0 && t->tm_min % 15 == 0 ) + { + SccpCstaInd = t->tm_hour * 4 + t->tm_min / 15; + + memset ( &SccpCsta[SccpCstaInd], 0, sizeof ( SCCP_CSTA ) ); + SccpCsta[SccpCstaInd].timestamp = l_time; + + spLogDebug_csta ( 1, SccpCstaInd ); + ch = 1; + } + if( t->tm_min % 15 != 0 ) + ch = 0; + break; + case 100: //SST + sst_timer ( ); + break; + case 200: + sccp_sethb ( ); + break; + case 300: + localssn_timer ( ); + break; + case 400: + break; + } + // outb(flag & 0xFB,0x0378); +} + +void sccp_reset ( ) +{ + DWORD oid[20] = { 1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 2, 2, 2, 0, 0 };//MTP3_OID + BYTE msg[64]; + BYTE spclen, temp; + int i, len; + + //get parameter from mtp3 + SCCP_Param.status = 2; + + if( get_response ( 14, oid, msg, &temp ) < 0 ) + { + SCCP_Param.status = 0; + return; + } + spclen = msg[0]; + SCCP_Param.spclen[0] = ( spclen & 0x01 ) == 0x01 ? 3 : 2; + SCCP_Param.spclen[1] = ( spclen & 0x02 ) == 0x02 ? 3 : 2; + SCCP_Param.spclen[2] = ( spclen & 0x04 ) == 0x04 ? 3 : 2; + SCCP_Param.spclen[3] = ( spclen & 0x08 ) == 0x08 ? 3 : 2; + + oid[12] = 3; + + for ( i = 0; i < 4; i++ ) + { + if( SCCP_Param.spclen[i] == 2 ) + { + oid[13] = i + 1; + } + else + { + oid[13] = i + 5; + } + if( ( len = get_response ( 15, oid, msg, &temp ) ) < 0 ) + { + SCCP_Param.status = 0; + return; + } + SCCP_Param.spc[i] = decode_integer ( msg, len ); + } + + SCCP_Param.OMCIP[0] = 0; + SCCP_Param.OMCIP[1] = 0; + + sccp_loadparam ( ); + + CollectLocalInfo ( ); + + spLogDebug_local ( 2, 1 ); + BuildRouteIndex ( ); + SCCP_Param.T_reset = -1; +} + +int AddToIpList ( DWORD ip, BYTE ssn ) +{ + int i; + + if( ip == SCCP_Param.ip && ssn != 4 ) + return 0; + for ( i = 0; i < ExistIPNum; i++ ) + { + if( ExistIP[i] == ip ) + return 0; + } + ExistIP[ExistIPNum] = ip; + ExistIPNum = ( ExistIPNum + 1 ) % 64; + return 1; +} + +int CollectLocalInfo ( ) +{ + int i; + BYTE RegNum = 0; + + SCCP_Param.OMCIP[0] = 0; + SCCP_Param.OMCIP[1] = 0; + ExistSSNNum = 0; + ExistIPNum = 0; + + for ( i = 2; i < 256; i++ ) + { + if( i != 4 ) + { + if( LocalSSN[i].status[0] ) + AddToIpList ( LocalSSN[i].ip[0], i ); + else if( LocalSSN[i].status[1] == 0 ) + continue; + if( LocalSSN[i].status[1] ) + AddToIpList ( LocalSSN[i].ip[1], i ); + } + + if( LocalSSN[i].RegFlag && LocalSSN[i].local ) + { + LocalSSN[i].status[( LocalSSN[i].local - 1 ) % 2] = 3; + SCCP_Param.RegSSN[RegNum] = i; + RegNum = ( RegNum + 1 ) % 32; + } + ExistSSN[ExistSSNNum++] = i; + } + + SCCP_Param.RegNum = RegNum; + return 1; +} + +/*int LocalSSN_ANSIFlag(BYTE SSN) + { + return LocalSSN[SSN].ANSIFlag; + } */ + +int sccp_mnp_register ( BYTE flag, BYTE routing_method, BYTE usertype ) +{ + MNP_Flag[0] = flag % 3; + MNP_Flag[1] = routing_method % 3; + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +// spSetGttAddr /// +// uGtType : 0 Setting by SSN /// +// 1 Setting by GtNum [MSISDN] /// +// 2 Setting by GtNum [IMSI ] /// +// /// +/////////////////////////////////////////////////////////////////////////// + +int spSetGttAddr ( u8 uGtType , u8 uSSN, u8 *uGtNum , struct SCCP_ADDRESS *pSpAddr ) +{ + int nFlag; + + pSpAddr->SSN = uSSN; + pSpAddr->DPC = 0; // set SCCP address + pSpAddr->NetID = 4; // dedicate by GT table + pSpAddr->RI = 0; // Routing by GT + pSpAddr->NAI = 4; // + pSpAddr->ip = 0; + + nFlag = sccp_GetSSNType ( uSSN ); //0=ITU,1=ANSI + pSpAddr->ip = 0; + + if( nFlag == 1 ) //ANSI SCCP + { + if( uGtType < 2 ) + { + pSpAddr->NP = 0; // MSISDN + pSpAddr->TT = 14; + } + else + { + pSpAddr->NP = 6; // IMSI + pSpAddr->TT = 9; + } + pSpAddr->GTI = 0x02; + } + else if( nFlag == 0 ) //ITU SCCP + { + pSpAddr->TT = 0; + if( uGtType < 2 ) + { + pSpAddr->NP = 1; // MSISDN + } + else + { + pSpAddr->NP = 6; // IMSI + } + pSpAddr->GTI = 0x04; + } + + + if( 0 == uGtType ) + { + u8 aGTT[ISDN_LEN]; + + if( GetMSISDNOfSSN ( uSSN, aGTT ) ) + { + u8 aISDN[ISDN_LEN]; + + GttToIsdn ( aISDN, aGTT ); + pSpAddr->len = IsdnToGtai( pSpAddr->GTAI ,aISDN ); + return pSpAddr->len; + } + } + else if( 1 == uGtType ) + { + pSpAddr->len = IsdnToGtai ( pSpAddr->GTAI, uGtNum ); + return pSpAddr->len; + } + else if( 2 == uGtType ) + { + ImsiNtoA( pSpAddr->GTAI , uGtNum); + pSpAddr->len = IMSI_LEN; + return pSpAddr->len; + } + return 0; +} + diff --git a/omc/plat/sccp/src/sccp_debug.c b/omc/plat/sccp/src/sccp_debug.c new file mode 100644 index 0000000..5cb311b --- /dev/null +++ b/omc/plat/sccp/src/sccp_debug.c @@ -0,0 +1,684 @@ + +/**************************************************/ +/*Title: sccpdebug.c */ +/*Descr: SCCP Debug Tool */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-5-9 */ + +/**************************************************/ +#include "./include/sccp.h" +#include "./include/scoc.h" + +int sccp_send_netcap = 0; +char sccp_debug_buf[5120]; +static char asc_in[256]; +static DWORD title_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 8, 1 }; +unsigned long spLogDebug_mask = 0; +static char sccp_ver[16]; + +/* by simon at 23/9/26 */ +extern struct sccp_msg_statistic +{ + DWORD msg_mtp_scoc; + DWORD msg_scoc_up; + DWORD mnp_send; + DWORD mnp_route; +} sccpmsg_st; +extern SCCP_Capture_Buf SCCPCapBuf; +extern DWORD SccpCstaInd; +extern LOCAL_SSN LocalSSN[256]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; + +extern void spLog ( char *info ); + +void spLogDebug_WatchDog ( BYTE npage ); +SCCP_FILTER sccpFilter[8]; +BYTE sccpFilterIndex = 0; +int spLog_fd = -1; +static char help_info[] = "Commands provided now:\r\n\ +help\r\n\ +log all Output all debug information\r\n\ +log none Turn off all information\r\n\ +log error on/off Show error information\r\n\ +log addr on/off Show address of sccp message\r\n\ +log data on/off Show data party of sccp message\r\n\ +log time on/off Show time when generate log\r\n\ +log udt on/off Show UDT message\r\n\ +log user on/off Show (UDT) message from user\r\n\ +log mtp3 on/off Show (UDT) message from mtp3\r\n\ +log aif on/off Show AIF message\r\n\ +log scmg on/of Show SCMG message\r\n\ +log snmp on/off Show SNMP message\r\n\ +log cond1 (and cond2...) Show message due to specified condition\r\n\ + One or more conditions could be taken:\r\n\ + src ssn=xx/dst ssn=xx/opc=xx/dpc=xx.\r\n\ + For example:log src ssn=7 and dst ssn=6\r\n\ +list route.x Print GTT Table, start from x, default 0 if not specified\r\n\ +list spc Print SPC of local node\r\n\ +save Save parameter\r\n\ +reset Reset SCCP Module\ +"; + +/*===========export===============*/ +void spLogDebug_setup ( ); +void spLogDebug_timer ( ); +void spLogDebug_csta ( BYTE npage, int instance ); +void spLogDebug_local ( BYTE npage, BYTE nline ); +/* by simon at 23/09/26 */ +extern SCCP_CSTA SccpCsta[96]; + +/*===========import================*/ +extern void sccp_saveparam ( ); +extern void sccp_reset ( ); +extern int ParseLine ( char *str, char ( *row )[128], int maxrow ); +//extern int Bcd2Str ( char *pStr, const BYTE * pBcd, int len ); +extern int Digits2Str ( char *pStr, BYTE * pDigits, int DigitsLen ); + +/*===========private===============*/ +static int parsecmd ( char *cmdstr ); +static void spLogDebug_info ( BYTE npage, BYTE nline, BYTE * pt, BYTE len ); +static void spLogDebug_related ( BYTE npage, BYTE nline ); +static void spLogDebug_buffer ( BYTE npage ); +static void spLogDebug_errorCapture ( BYTE npage, BYTE nline ); +static void sccp_list_route ( int pos ); + +void spLogDebug_setup ( ) +{ + DWORD ascout_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 4 }; + DWORD ascin_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 3 }; + DWORD status_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 1 }; + DWORD name_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 2 }; + BYTE debug_status = 1; + + sprintf ( sccp_ver, "R%dV%d_%02d", SCCP_Param.version[0], SCCP_Param.version[1], SCCP_Param.version[2] ); + debug_set_response ( 15, ascout_id, sccp_debug_buf, 4096 ); + debug_set_response ( 15, ascin_id, asc_in, 1 ); + debug_set_response ( 15, status_id, &debug_status, 1 ); + debug_set_response ( 15, name_id, sccp_ver, strlen ( sccp_ver ) ); + + spLogDebug_local ( 2, 1 ); + spLogDebug_related ( 3, 0 ); + spLogDebug_buffer ( 4 ); + spLogDebug_errorCapture ( 5, 0 ); + spLogDebug_WatchDog ( 6 ); +} + +void spLogDebug_timer ( ) +{ + BYTE npage, nline; + + if( strlen ( asc_in ) <= 1 ) + return; + sccp_debug_buf[0] = '\0'; + npage = asc_in[0] - 1; + if( npage == 0 ) + { + parsecmd ( asc_in + 1 ); + asc_in[0] = '\0'; + return; + } + else if( asc_in[1] == 'c' || asc_in[1] == 'C' ) + { + memset ( &sccpmsg_st, 0, sizeof ( sccpmsg_st ) ); + memset ( &SCCPCapBuf, 0, sizeof ( SCCP_Capture_Buf ) ); + } + else + nline = atoi ( asc_in + 1 ); + + switch ( npage ) + { + case 1: //csta + spLogDebug_csta ( npage, nline ); + break; + case 2: //local subsystem + spLogDebug_local ( npage, nline ); + break; + case 3: //related subsystem + spLogDebug_related ( npage, nline ); + break; + case 5: //capture buffer + spLogDebug_errorCapture ( npage, nline ); + break; + } + asc_in[0] = '\0'; +} + +static int str2value ( char *str ) +{ + BYTE i = 0; + char *pHead = str, xstr[8] = "0"; + + while ( !isxdigit ( *pHead ) ) //8 lead-space max + { + if( i++ >= 8 ) + return -1; + pHead++; + } + i = 0; + while ( isxdigit ( pHead[i] ) && i < 6 ) + { + xstr[i] = pHead[i]; + i++; + } + xstr[6] = 0; + + return strtoul ( xstr, NULL, 16 ); +} + +static int parsecond ( char *cmdstr ) +{ + char *pKey = cmdstr, *pEQ, info[256] = "log ", tmpStr[64]; + + sccpFilter[sccpFilterIndex].flag = 0; + + if( ( pKey = strstr ( cmdstr, "opc" ) ) != NULL && ( pEQ = strchr ( pKey, '=' ) ) != NULL ) + { + sccpFilter[sccpFilterIndex].opc = str2value ( pEQ + 1 ); + if( sccpFilter[sccpFilterIndex].flag > 0 ) + strcat ( info, " and " ); + sprintf ( tmpStr, "opc = 0x%06x", sccpFilter[sccpFilterIndex].opc ); + strcat ( info, tmpStr ); + sccpFilter[sccpFilterIndex].flag |= 0x01; + } + if( ( pKey = strstr ( cmdstr, "dpc" ) ) != NULL && ( pEQ = strchr ( pKey, '=' ) ) != NULL ) + { + sccpFilter[sccpFilterIndex].dpc = str2value ( pEQ + 1 ); + if( sccpFilter[sccpFilterIndex].flag > 0 ) + strcat ( info, " and " ); + sprintf ( tmpStr, "dpc = 0x%06x", sccpFilter[sccpFilterIndex].opc ); + strcat ( info, tmpStr ); + sccpFilter[sccpFilterIndex].flag |= 0x02; + } + if( ( pKey = strstr ( cmdstr, "src ssn" ) ) != NULL && ( pEQ = strchr ( pKey, '=' ) ) != NULL ) + { + sccpFilter[sccpFilterIndex].src_ssn = str2value ( pEQ + 1 ); + if( sccpFilter[sccpFilterIndex].flag > 0 ) + strcat ( info, " and " ); + sprintf ( tmpStr, "src ssn = 0x%02x", sccpFilter[sccpFilterIndex].src_ssn ); + strcat ( info, tmpStr ); + sccpFilter[sccpFilterIndex].flag |= 0x04; + } + if( ( pKey = strstr ( cmdstr, "dst ssn" ) ) != NULL && ( pEQ = strchr ( pKey, '=' ) ) != NULL ) + { + sccpFilter[sccpFilterIndex].dst_ssn = str2value ( pEQ + 1 ); + if( sccpFilter[sccpFilterIndex].flag > 0 ) + strcat ( info, " and " ); + sprintf ( tmpStr, "dst ssn = 0x%02x", sccpFilter[sccpFilterIndex].dst_ssn ); + strcat ( info, tmpStr ); + sccpFilter[sccpFilterIndex].flag |= 0x08; + } + + if( sccpFilter[sccpFilterIndex].flag == 0 ) + { + spLog ( "Wrong condition" ); + return 0; + } + + sccpFilterIndex++; + spLog ( info ); + spLog ( "command OK" ); + return 1; +} + +int parsecmd ( char *cmdstr ) +{ + int i; + char info[256], *pCh; + + if( strstr ( cmdstr, "list route" ) != NULL ){ + int i = 0; + const int start_pos = 11; + while(isdigit(cmdstr[start_pos+i++])){ + if(i > 3){ + break; + } + } + + if (i > 0) + { + cmdstr[start_pos + i] = '\0'; + i = strtoul(cmdstr+start_pos, NULL, 10); + if (i > SCCP_ROUTE_NUM){ + char tmp_str[128]; + sprintf(tmp_str, "Invalid parameter value %d, max %d. replace with default 0", i, SCCP_ROUTE_NUM); + spLog ( tmp_str ); + i = 0; + } + } + sccp_list_route ( i ); + } + else if( strstr ( cmdstr, "help" ) != NULL || strstr ( cmdstr, "?" ) != NULL ) + spLog ( help_info ); + else if( strstr ( cmdstr, "save" ) != NULL ) + sccp_saveparam ( ); + else if( strstr ( cmdstr, "reset" ) != NULL ) + sccp_reset ( ); + else if( strstr ( cmdstr, "log all" ) != NULL ) + { + sccpFilterIndex = 0; + spLogDebug_mask = 0xFFFFFFFF; + } + else if( strstr ( cmdstr, "log none" ) != NULL ) + { + sccpFilterIndex = 0; + spLogDebug_mask = 0; + } + else if( strstr ( cmdstr, "log error on" ) != NULL ) + spLogDebug_mask |= SCCPDB_ERR; + else if( strstr ( cmdstr, "log error off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_ERR ); + else if( strstr ( cmdstr, "log udt on" ) != NULL ) + spLogDebug_mask |= SCCPDB_UDT; + else if( strstr ( cmdstr, "log udt off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_UDT ); + else if( strstr ( cmdstr, "log aif on" ) != NULL ) + spLogDebug_mask |= SCCPDB_AIF; + else if( strstr ( cmdstr, "log aif off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_AIF ); + else if( strstr ( cmdstr, "log mtp3 on" ) != NULL ) + spLogDebug_mask |= SCCPDB_MTP3; + else if( strstr ( cmdstr, "log mtp3 off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_MTP3 ); + else if( strstr ( cmdstr, "log user on" ) != NULL ) + spLogDebug_mask |= SCCPDB_USER; + else if( strstr ( cmdstr, "log user off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_USER ); + + else if( strstr ( cmdstr, "log scmg on" ) != NULL ) + spLogDebug_mask |= SCCPDB_SCMG; + else if( strstr ( cmdstr, "log scmg off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_SCMG ); + else if( strstr ( cmdstr, "log snmp on" ) != NULL ) + spLogDebug_mask |= SCCPDB_SNMP; + else if( strstr ( cmdstr, "log snmp off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_SNMP ); + else if( strstr ( cmdstr, "log data on" ) != NULL ) + spLogDebug_mask |= SCCPDB_MSG; + else if( strstr ( cmdstr, "log data off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_MSG ); + else if( strstr ( cmdstr, "log addr on" ) != NULL ) + spLogDebug_mask |= SCCPDB_ADDR; + else if( strstr ( cmdstr, "log addr off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_ADDR ); + else if( strstr ( cmdstr, "log time on" ) != NULL ) + spLogDebug_mask |= SCCPDB_TIME; + else if( strstr ( cmdstr, "log time off" ) != NULL ) + spLogDebug_mask &= ( ~SCCPDB_TIME ); + else if( strstr(cmdstr, "net cap start") !=NULL ) + { + sccp_send_netcap = 1; + spLog("sccp send netcap start"); + } + else if( strstr(cmdstr, "net cap stop") !=NULL ) + { + sccp_send_netcap = 0; + spLog("sccp send netcap end"); + } + else if( strncasecmp ( cmdstr, "log file on", 11 ) == 0 ) + { + if( spLog_fd != -1 ) + { + close ( spLog_fd ); + } + spLog_fd = open ( "./sccp.log", O_WRONLY | O_CREAT | O_TRUNC ); + } + else if( strncasecmp ( cmdstr, "log file off", 12 ) == 0 ) + { + if( spLog_fd != -1 ) + { + close ( spLog_fd ); + spLog_fd = -1; + } + } + else if( ( pCh = strstr ( cmdstr, "log" ) ) != NULL && strstr ( cmdstr, "=" ) != NULL ) + { + if( sccpFilterIndex >= 8 ) + { + spLog ( "Only 8 conditions can be set" ); + return 0; + } + return parsecond ( pCh + 4 ); + } + else if( strstr ( cmdstr, "list spc" ) != NULL ) + { + spLog ( "NI SPC_Len SPC" ); + for ( i = 0; i < 4; i++ ) + { + sprintf ( info, "%d %d %06lx", i, SCCP_Param.spclen[i], SCCP_Param.spc[i] ); + spLog ( info ); + } + } + else + { + spLog ( "Invalid command/parameter(s)." ); + return 0; + } + spLog ( "Command OK." ); + return 1; +} + +int sccp_filter_msg ( SCCP_ADDR * pSrcAddr, SCCP_ADDR * pDstAddr ) +{ + int i; + + for ( i = 0; i < sccpFilterIndex % 9; i++ ) + { + if( sccpFilter[i].flag & 0x01 ) + { + if( sccpFilter[i].opc != pSrcAddr->DPC ) + continue; + } + if( sccpFilter[i].flag & 0x02 ) + { + if( sccpFilter[i].dpc != pDstAddr->DPC ) + continue; + } + if( sccpFilter[i].flag & 0x04 ) + { + if( sccpFilter[i].src_ssn != pSrcAddr->SSN ) + continue; + } + if( sccpFilter[i].flag & 0x08 ) + { + if( sccpFilter[i].dst_ssn != pDstAddr->SSN ) + continue; + } + return 1; + } + return 0; +} + +void spLogDebug_info ( BYTE npage, BYTE nline, BYTE * pt, BYTE len ) +{ + DWORD oid[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 4, 5, 2, 2 }; + + oid[14] = 5 + npage; + oid[15] = 2 + nline; + debug_set_response ( 17, oid, pt, len ); +} + +/*-----------------------------------------------*/ + +/*-------------------CSTA------------------------*/ + +/*-----------------------------------------------*/ +void spLogDebug_csta ( BYTE npage, int instance ) +{ + char title[256]; + SCCP_CSTA *pcsta = &SccpCsta[SccpCstaInd % 96]; + + sprintf ( title, "\tSCCP-%s\tPage %02d\t\tMIB-CSTA(ID:1 Instance:%d)\r\n" + " [----1----] [----2----] [----3----] [----4----] [----5----]\r\n" + "Error(1)\r\n" "\r\n" "\r\n" "\r\n" "\r\n" "availability(2)\r\n" "\r\n" "\r\n" "Utilization(3)\r\n" "\r\n" "\r\n" "Quality(4)\r\n" "\r\n" "\r\n" "\r\n", sccp_ver, npage, instance ); + + title_id[14] = 5 + npage; + debug_set_response ( 16, title_id, title, strlen ( title ) ); + + spLogDebug_info ( npage, 0, ( BYTE * ) pcsta->error, 20 ); + spLogDebug_info ( npage, 1, ( BYTE * ) pcsta->error + 20, 20 ); + spLogDebug_info ( npage, 2, ( BYTE * ) pcsta->error + 40, 20 ); + spLogDebug_info ( npage, 3, ( BYTE * ) pcsta->error + 60, 20 ); + spLogDebug_info ( npage, 4, ( BYTE * ) pcsta->error + 80, 4 ); + spLogDebug_info ( npage, 5, ( BYTE * ) pcsta->avail, 20 ); + spLogDebug_info ( npage, 6, ( BYTE * ) pcsta->avail + 20, 20 ); + spLogDebug_info ( npage, 7, ( BYTE * ) pcsta->avail + 40, 8 ); + spLogDebug_info ( npage, 8, ( BYTE * ) pcsta->utilization, 20 ); + spLogDebug_info ( npage, 9, ( BYTE * ) pcsta->utilization + 20, 20 ); + spLogDebug_info ( npage, 10, ( BYTE * ) pcsta->utilization + 40, 16 ); + spLogDebug_info ( npage, 11, ( BYTE * ) pcsta->quality, 20 ); + spLogDebug_info ( npage, 12, ( BYTE * ) pcsta->quality + 20, 20 ); + spLogDebug_info ( npage, 13, ( BYTE * ) pcsta->quality + 40, 20 ); + spLogDebug_info ( npage, 14, ( BYTE * ) pcsta->quality + 60, 20 ); +} + +/*-----------------------------------------------*/ + +/*-------------------Local subsystem-------------*/ + +/*-----------------------------------------------*/ +void spLogDebug_local ( BYTE npage, BYTE nline ) +{ + short loop, ssnindex = 0; + char str[256], digits[24]; + char title[1024], *pCh = NULL; + + nline = nline % 256; + if( nline < 2 ) + nline = 2; + + spLog ( "Refresh Local Node List..." ); + sprintf ( title, "\tSCCP-%s\tPage %02d\tMIB-Status Of Local Subsystem\r\n\ +[ SSN ] S1 S2 N Lc NI RG [ IP1 ] [ IP2 ] F\r\n", sccp_ver, npage ); + + for ( loop = nline; ssnindex < 22 && loop < 256; loop++ ) + { + if( LocalSSN[loop].status[0] == 0 && LocalSSN[loop].status[1] == 0 ) + continue; + + Bcd2Str ( digits, LocalSSN[loop].msisdn, LocalSSN[loop].msisdn_len % ( MAX_DIGITS + 1 ) ); + if( ( pCh = strchr ( digits, 'F' ) ) != NULL ) + *pCh = 0; + if( strlen ( digits ) == 0 ) + strcpy ( digits, " " ); + + sprintf ( str, "%02X-%-18s\n\r", loop, digits ); + strcat ( title, str ); + + spLogDebug_info ( npage, ssnindex++, LocalSSN[loop].status, 14 ); + } + + while ( ssnindex < 22 ) + spLogDebug_info ( npage, ssnindex++, LocalSSN[0].status, 0 ); + + title_id[14] = 5 + npage; + debug_set_response ( 16, title_id, title, strlen ( title ) ); + + return; +} + +void spLogDebug_related ( BYTE npage, BYTE nline ) +{ + short loop; + char str[64]; + char title[500]; + + nline = nline % SCCP_RLSSN_NUM; + + sprintf ( title, "\tSCCP-%s\tPage %02d\tMIB-Status Of Related Subsystem(Num=%d)\r\n" " S SST ID SN [ SPC ] [Timeoute]\r\n", sccp_ver, npage, RelatedSSNNum ); + for ( loop = nline; loop < nline + 20 && loop < SCCP_RLSSN_NUM; loop++ ) + { + sprintf ( str, "Instance=%d\r\n", loop ); + strcat ( title, str ); + } + + title_id[14] = 5 + npage; + debug_set_response ( 16, title_id, title, strlen ( title ) ); + + for ( loop = nline; loop < nline + 20 && loop < RelatedSSNNum; loop++ ) + spLogDebug_info ( npage, loop - nline, ( BYTE * ) & RelatedSSN[loop], 12 ); +} + +void spLogDebug_buffer ( BYTE npage ) +{ + char title[500]; + + sprintf ( title, "\tSCCP-%s\tPage %02d\t\tBuffer\r\n" + " [ R ] [ W ]\r\n" "SCLC(in-0)\r\n" "SCLC(in-1)\r\n" "SCLC(in-2)\r\n" "SCLC(out)\r\n" "SCOC\r\n" "AIF Msg\r\n" "\r\n" "OMCIP\r\n", sccp_ver, npage ); + + title_id[14] = 5 + npage; + debug_set_response ( 16, title_id, title, strlen ( title ) ); + + // spLogDebug_info(npage,0,(BYTE *)&SCLC_InBuf[0].readsub, 4); + // spLogDebug_info(npage,1,(BYTE *)&SCLC_InBuf[1].readsub, 4); + // spLogDebug_info(npage,2,(BYTE *)&SCLC_InBuf[2].readsub, 4); + // spLogDebug_info(npage,3,(BYTE *)&SCLC_OutBuf.readsub, 4); + spLogDebug_info ( npage, 4, ( BYTE * ) ScocBuf.rcvsub, 4 ); + spLogDebug_info ( npage, 5, ( BYTE * ) & sccpmsg_st.msg_mtp_scoc, 8 ); + spLogDebug_info ( npage, 6, NULL, 0 ); + spLogDebug_info ( npage, 7, ( BYTE * ) & SCCP_Param.OMCIP, 8 ); +} + +void spLogDebug_errorCapture ( BYTE npage, BYTE nline ) +{ + char title[500]; + int i; + static BYTE subpage; + int base; + + subpage = nline % 10; + + sprintf ( title, "\tSCCP-%s\tPage %02d\tSubPage %02d\tErrCap\r\n" + " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r" + "Pointer\n\r" + "ErrCap\r\n" "01\r\n" "02\r\n" "03\r\n" "04\r\n" "05\r\n" "06\r\n" "07\r\n" "08\r\n" "09\r\n" "10\r\n" "11\r\n" "12\r\n" "13\r\n" "14\r\n" "15\r\n" "Dog\r\n", sccp_ver, npage, subpage ); + + title_id[14] = 5 + npage; + debug_set_response ( 16, title_id, title, strlen ( title ) ); + + spLogDebug_info ( npage, 0, ( BYTE * ) & SCCPCapBuf.Pointer, 1 ); + base = subpage * 256; + for ( i = 1; i < 17; i++ ) + { + spLogDebug_info ( npage, i, ( BYTE * ) & SCCPCapBuf.Buffer[base + ( i - 1 ) * 16], 16 ); + } + for ( i = 17; i < 22; i++ ) + { + spLogDebug_info ( npage, i, ( BYTE * ) & SCCPCapBuf.watch_dog[( i - 17 ) * 16], 16 ); + } +} + +void spLogDebug_WatchDog ( BYTE npage ) +{ + char title[500]; + CO_DebugStatic *pDs = &pSp->tCo.tCoDebugStatic; + + sprintf ( title, "\tSCCP-%s\tPage %02d\t\tDebug watchdog\r\n\r\n" + "Get InPool\r\n" + "Put InPool\r\n" + "Read InPool\r\n" + "Write InPool\r\n" + "Get OutPool\r\n" + "Put OutPool\r\n" + "Put element atp\r\n" + "Put element suc\r\n" + "CoSubmitUl attempt\r\n" + "CoSubmitUl \r\n" + "UlPostCo attempt\r\n" + "UlPostCo \r\n" + "Co2Cr attempt\r\n" + "Co2Cr \r\n" + "Cr2Co attempt\r\n" + "Cr2Co \r\n" + "Timer Out\r\n" + "Busy element\r\n" + "Busy connection\r\n", sccp_ver, npage ); + + title_id[14] = 5 + npage; + debug_set_response ( 17, title_id, title, strlen ( title ) ); + + spLogDebug_info ( npage, 0, ( BYTE * ) & pDs->dGetInPool, 4 ); + spLogDebug_info ( npage, 1, ( BYTE * ) & pDs->dPutInPool, 4 ); + spLogDebug_info ( npage, 2, ( BYTE * ) & pDs->dReadInPool, 4 ); + spLogDebug_info ( npage, 3, ( BYTE * ) & pDs->dWriteInPool, 4 ); + spLogDebug_info ( npage, 4, ( BYTE * ) & pDs->dGetOutPool, 4 ); + spLogDebug_info ( npage, 5, ( BYTE * ) & pDs->dPutOutPool, 4 ); + spLogDebug_info ( npage, 6, ( BYTE * ) & pDs->dPutEleApt, 4 ); + spLogDebug_info ( npage, 7, ( BYTE * ) & pDs->dPutEleSuc, 4 ); + spLogDebug_info ( npage, 8, ( BYTE * ) & pDs->dCoSubmitUlApt, 4 ); + spLogDebug_info ( npage, 9, ( BYTE * ) & pDs->dCoSubmitUl, 4 ); + spLogDebug_info ( npage, 10, ( BYTE * ) & pDs->dUlPostCoApt, 4 ); + spLogDebug_info ( npage, 11, ( BYTE * ) & pDs->dUlPostCo, 4 ); + spLogDebug_info ( npage, 12, ( BYTE * ) & pDs->dCo2CrApt, 4 ); + spLogDebug_info ( npage, 13, ( BYTE * ) & pDs->dCo2Cr, 4 ); + spLogDebug_info ( npage, 14, ( BYTE * ) & pDs->dCr2CoApt, 4 ); + spLogDebug_info ( npage, 15, ( BYTE * ) & pDs->dCr2Co, 4 ); + spLogDebug_info ( npage, 16, ( BYTE * ) & pDs->dTimerOut, 4 ); + spLogDebug_info ( npage, 17, ( BYTE * ) & pDs->dbusyElem, 4 ); + spLogDebug_info ( npage, 18, ( BYTE * ) & pSp->tCo.wConnIdCount, 4 ); +} + +void sccp_list_route ( int pos ) +{ + SCCP_ROUTE *pRoute; + int i; + char tempstr[1024], str1[64], str2[256], *pCh = NULL; + char cNP[8], cTT[8]; + if(pos >= SCCP_ROUTE_NUM) + return; + + spLog ( "#No NP TT StartDigits EndDigits NI SPC SSN RI AI S E N Rep" ); + for ( i = pos; i < SCCP_ROUTE_NUM; i++ ) + { + if( RouteList[i].avail == 0 ) + continue; + pRoute = &RouteList[i]; + if( pRoute->len > 0 ) + { + Bcd2Str ( str1, pRoute->StartDigits, pRoute->len % MAX_DIGITS ); + if( ( pCh = strchr ( str1, 'F' ) ) != NULL ) + *pCh = 0; + Bcd2Str ( str2, pRoute->EndDigits, pRoute->len % MAX_DIGITS ); + if( ( pCh = strchr ( str2, 'F' ) ) != NULL ) + *pCh = 0; + } + else + { + strcpy ( str1, "-" ); + strcpy ( str2, "-" ); + } + + if( pRoute->NP == 0 ) + sprintf ( cNP, "-" ); + else + sprintf ( cNP, "%d", pRoute->NP ); + + if( pRoute->TT == 0 ) + sprintf ( cTT, "-" ); + else + sprintf ( cTT, "%d", pRoute->TT ); + + sprintf ( tempstr, "%-3d %s %s %-15s %-15s %d %02X%02x%02X %d %d %d ", i, cNP, cTT, str1, str2, pRoute->NetID, pRoute->DPC[0], pRoute->DPC[1], pRoute->DPC[2], pRoute->SSN, pRoute->RI, + pRoute->AI ); + if( pRoute->convert ) + { + Bcd2Str ( str1, pRoute->ReplaceDigits, pRoute->replace_len % MAX_DIGITS ); + if( ( pCh = strchr ( str1, 'F' ) ) != NULL ) + *pCh = 0; + sprintf ( str2, "%-1d% -1d %-1d %-15s", pRoute->ReplaceStart, pRoute->ReplaceEnd, pRoute->OutNP, str1 ); + strcat ( tempstr, str2 ); + } + spLog ( tempstr ); + } + +} + +void sccp_put_capture_logs ( BYTE person, BYTE * pictures, int len ) +{ + int base; + + if( len >= 512 ) + return; + + base = SCCPCapBuf.Pointer * 16; + + SCCPCapBuf.Buffer[base + 0] = person; + SCCPCapBuf.Buffer[base + 1] = len; + base = base + 16; + SCCPCapBuf.Pointer = SCCPCapBuf.Pointer + 1; + + if( SCCPCapBuf.Pointer >= 128 ) + SCCPCapBuf.Pointer = 0; + + memcpy ( &SCCPCapBuf.Buffer[base], pictures, len ); + + SCCPCapBuf.Pointer = ( SCCPCapBuf.Pointer ) + ( ( len + 15 ) / 16 ); + + if( SCCPCapBuf.Pointer >= 128 ) + SCCPCapBuf.Pointer = 0; + +} diff --git a/omc/plat/sccp/src/sccp_func.c b/omc/plat/sccp/src/sccp_func.c new file mode 100644 index 0000000..d3db97e --- /dev/null +++ b/omc/plat/sccp/src/sccp_func.c @@ -0,0 +1,113 @@ + +/******************************************************/ +/*Title: sccpfun.c */ +/*Descr: Common Function */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-5-9 */ + +/******************************************************/ +//All the funtions base on following assuming: +//BCD: 0x123456 +//Digits: 0x214356 +//Str: "123456" +//Ull: 123456 +//Array: {0x01,0x02,0x03,0x04,0x05,0x06}; +#include "./include/sccp.h" + +int ParseLine ( char *str, char ( *row )[128], int maxrow ) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen ( str ); + for ( i = 0; i < len && index < maxrow; i++ ) + { + if( isspace ( str[i] ) ) + { + if( black == 0 ) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if( strlen ( pstr ) > 128 ) + pstr[127] = 0; + sprintf ( row[index++], "%s", pstr ); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if( black == 1 ) + { + if( strlen ( pstr ) > 128 ) + pstr[127] = 0; + sprintf ( row[index++], "%s", pstr ); + } + return index; +} + +int GetEnt ( FILE * fp, char *key, char *str ) +{ + char *pval, *pkey, *pchr; + int i = 1, len; + + fseek ( fp, 0, SEEK_SET ); + pval = NULL; + while ( fgets ( str, 200, fp ) != NULL ) + { + if( ( pchr = strchr ( str, '#' ) ) != NULL ) + pchr[0] = '\0'; + if( ( pkey = strstr ( str, key ) ) != NULL ) + { + if( ( pval = strchr ( str, '=' ) ) == NULL || pkey >= pval ) + continue; + else + break; + } + } + if( pval == NULL ) + return -1; + pval++; + len = strlen ( pval ); + + while ( isspace ( pval[len - i] ) && i <= len ) + { + pval[len - i] = '\n'; + pval[len - i + 1] = '\0'; + i++; + } + + i = 0; + while ( isspace ( pval[i++] ) && i < len ); + sprintf ( str, "%s", pval + i - 1 ); + return 1; +} + +BOOL isco ( Intra_Msg * intramsg ) +{ + if( intramsg->msgtype == 9 || intramsg->msgtype == 10 || intramsg->msgtype == 17 || intramsg->msgtype == 18 || intramsg->msgtype == 19 || intramsg->msgtype == 20 ) + return 0; + else if( intramsg->msgtype > 0 && intramsg->msgtype <= 20 ) + return 1; + return 0; +} + +BOOL iscl ( Intra_Msg * intramsg ) +{ + if( intramsg->msgtype == 9 || intramsg->msgtype == 10 || intramsg->msgtype == 17 || intramsg->msgtype == 18 || intramsg->msgtype == 19 || intramsg->msgtype == 20 ) + return 1; + else + return 0; +} + +BOOL iscr ( Intra_Msg * intramsg ) +{ + if( intramsg->msgtype == 1 || intramsg->msgtype == 2 ) + return 1; + else + return 0; +} diff --git a/omc/plat/sccp/src/sccp_gtt.c b/omc/plat/sccp/src/sccp_gtt.c new file mode 100644 index 0000000..8e80110 --- /dev/null +++ b/omc/plat/sccp/src/sccp_gtt.c @@ -0,0 +1,417 @@ +/****************************************************/ +/*Title: gtt.c */ +/*Descr: GTT Table Management */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-4-30 */ +/****************************************************/ +#include "./include/sccp.h" + +/*===========export================*/ +int BuildRouteIndex ( ); +u_short SelectRoute ( BYTE * pDigits, BYTE DigitsLen ); +void TranslateGT ( SCCP_ADDR * addr, SCCP_ROUTE * pRoute ); + +/*===========import================*/ +extern void spLog ( char *info ); +extern int ParseLine ( char *str, char ( *row )[128], int maxrow ); +extern int Digits2Array ( BYTE * pArray, BYTE * pDigits, int DigitsLen ); +extern int Bcd2Array ( BYTE * pArray, BYTE * pBcd, int BcdLen ); +extern int Array2Digits ( BYTE * pDigits, BYTE * pArray, int ArrayLen ); + +/* by simon at 23/9/26*/ +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern LOCAL_SSN LocalSSN[256]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; + +/*===========private================*/ +static int AddRoute ( BYTE * pStartDigits, BYTE * pEndDigits, BYTE DigitsLen, u_short index ); +static int AddLargerNode ( SCCP_ROUTE_NODE * pNode, BYTE * pDigits, BYTE DigitsLen, u_short index ); +static int AddLessNode ( SCCP_ROUTE_NODE * pNode, BYTE * pDigits, BYTE DigitsLen, u_short index ); +static SCCP_ROUTE_NODE *NewNode ( ); + +static SCCP_ROUTE_NODE RouteNode[SCCP_ROUTE_NODE_NUM]; +static SCCP_ROUTE_NODE *pHead = &RouteNode[0]; +static u_short heap_index = 1, item_index = 0; + +int BuildRouteIndex ( ) +{ + int i; + BYTE StartNum[32], EndNum[32], NumLen; + BYTE TTmod10, TTdiv10, TTdiv100; + BYTE field = 0; + + TTmod10 = TTdiv10 = TTdiv100 = 0; + spLog ( "Build GTT Index..." ); + memset ( &RouteNode[0], 0, SCCP_ROUTE_NODE_NUM * sizeof ( SCCP_ROUTE_NODE ) ); + heap_index = 1; + item_index = 0; + + for ( i = 2; i < 256; i++ ) + { + field = 0; + if( LocalSSN[i].status[0] == 0 && LocalSSN[i].status[1] == 0 ) + continue; + if( LocalSSN[i].msisdn_len < 1 ) + continue; + // if (mtp3_ansiFlag(LocalSSN[i].NetID) != 1)/* ITU */ + StartNum[field++] = NP_MSISDN; + // else + { //ANSI + StartNum[field++] = TT_0; + StartNum[field++] = TT_1; + StartNum[field++] = TT_4; + } + NumLen = Bcd2Array ( StartNum + field, LocalSSN[i].msisdn, LocalSSN[i].msisdn_len % MAX_DIGITS ) + field; + if( NumLen < 2 || NumLen > 26 ) + continue; + if( StartNum[NumLen - 1] > 9 ) + NumLen--; + + if( AddRoute ( StartNum, StartNum, NumLen, 1024 + i ) == 0 ) + spLog ( "Error: Fail to add local node, resource limit..." ); + } + + field = 0; + for ( i = 0; i < SCCP_ROUTE_NUM; i++ ) + { + if( RouteList[i].avail == 0 ) + continue; + + TTmod10 = RouteList[i].TT % 10; + TTdiv10 = ( RouteList[i].TT / 10 ) % 10; + TTdiv100 = RouteList[i].TT / 100; + + field = 0; + if( RouteList[i].NP != 0 ) + StartNum[field++] = RouteList[i].NP; + else + StartNum[field++] = NP_MSISDN; + if( RouteList[i].TT != 0 ) + { + StartNum[field++] = TTdiv100; + StartNum[field++] = TTdiv10; + StartNum[field++] = TTmod10; + } + else + { + StartNum[field++] = TT_0; + StartNum[field++] = TT_1; + StartNum[field++] = TT_4; + } + + field = 0; + if( RouteList[i].NP != 0 ) + EndNum[field++] = RouteList[i].NP; + else + EndNum[field++] = NP_MSISDN; + if( RouteList[i].TT != 0 ) + { + EndNum[field++] = TTdiv100; + EndNum[field++] = TTdiv10; + EndNum[field++] = TTmod10; + } + else + { + EndNum[field++] = TT_0; + EndNum[field++] = TT_1; + EndNum[field++] = TT_4; + } + + NumLen = Bcd2Array ( StartNum + field, RouteList[i].StartDigits, RouteList[i].len % MAX_DIGITS ) + field; + if( NumLen < 2 || NumLen > 26 ) + continue; + if( StartNum[NumLen - 1] > 9 ) + NumLen--; + Bcd2Array ( EndNum + field, RouteList[i].EndDigits, RouteList[i].len ); + + if( AddRoute ( StartNum, EndNum, NumLen, i ) == 0 ){ + spLog ( "Error: Fail to add route, resource limit..." ); + break; + } + } + return 1; +} + +u_short SelectRoute ( BYTE * pDigits, BYTE DigitsLen ) +{ + SCCP_ROUTE_NODE *pNode = pHead; + int i; + u_short result = 0xFFFF; + BYTE num; + + for ( i = 0; i < DigitsLen; i++ ) + { + num = pDigits[i]; + if( pNode->psub[num] >= &RouteNode[0] && pNode->psub[num] <= &RouteNode[SCCP_ROUTE_NODE_NUM-1] ) + { + pNode = pNode->psub[num]; + if( pNode->nItem != 0xFFFF ) + result = pNode->nItem; + } + else + { + return result; + } + } + return result; +} + +int GetACNInfo ( SCCP_ADDR * pAddr, BYTE ** pAcnInfo ) +{ + DWORD spc; + u_short nRoute = 0xFFFF; + BYTE Num[MAX_DIGITS * 2], NumLen; + BYTE NetID; + BYTE field = 0; + + if( pAddr->NP > 0 ) + Num[field++] = pAddr->NP; + else + Num[field++] = NP_MSISDN; + if( pAddr->TT > 0 ) + { + Num[field++] = pAddr->TT / 100; + Num[field++] = ( pAddr->TT / 10 ) % 10; + Num[field++] = pAddr->TT % 10; + } + else + { + Num[field++] = TT_0; + Num[field++] = TT_1; + Num[field++] = TT_4; + } + NumLen = pAddr->len % ( MAX_DIGITS * 2 ); + Digits2Array ( Num + field, pAddr->GTAI, ( NumLen + 1 ) / 2 ); + if( pAddr->GTI ) + { + nRoute = SelectRoute ( Num, NumLen + field ); + if( nRoute < SCCP_ROUTE_NUM ) + { + if( pAddr->NetID > 3 ) + NetID = RouteList[nRoute].NetID; + else + NetID = pAddr->NetID; + + spc = RouteList[nRoute].DPC[0] * 0x10000 + RouteList[nRoute].DPC[1] * 0x100 + RouteList[nRoute].DPC[2]; + } + else if( nRoute >= 1024 && nRoute < 1024 + 256 ) + { + if( pAddr->NetID > 3 ) + NetID = LocalSSN[nRoute - 1024].NetID % 4; + else + NetID = pAddr->NetID; + + spc = SCCP_Param.spc[NetID]; + } + else + return 0; + } + else + { + NetID = pAddr->NetID; + spc = pAddr->DPC; + } + + *pAcnInfo = spc_to_acn ( NetID, spc ); + if( *pAcnInfo == NULL ) + return 0; + return 36; +} + +void TranslateGT ( SCCP_ADDR * pAddr, SCCP_ROUTE * pRoute ) +{ + BYTE swap[MAX_DIGITS * 2], temp[MAX_DIGITS * 2]; + BYTE ReplaceNum[MAX_DIGITS * 2], len; + BYTE ReplaceEnd; + + len = Bcd2Array ( ReplaceNum, pRoute->ReplaceDigits, pRoute->replace_len % MAX_DIGITS ); + + Digits2Array ( temp, pAddr->GTAI, ( ( pAddr->len + 1 ) / 2 ) % MAX_DIGITS ); + + pAddr->NP = NP_GT; + if( pRoute->ReplaceStart > 1 ) + { + memcpy ( swap, temp, pRoute->ReplaceStart - 1 ); + } + + memcpy ( swap + pRoute->ReplaceStart - 1, ReplaceNum, len ); + + ReplaceEnd = pRoute->ReplaceEnd; + if( pAddr->len < ReplaceEnd ) + ReplaceEnd = pAddr->len; + + memcpy ( swap + pRoute->ReplaceStart - 1 + len, temp + ReplaceEnd, ( pAddr->len - ReplaceEnd ) % 16 ); + + pAddr->len = pRoute->ReplaceStart - 1 + len + pAddr->len - ReplaceEnd; + pAddr->NP = pRoute->OutNP; + Array2Digits ( pAddr->GTAI, swap, pAddr->len ); +} + +int AddRoute ( BYTE * pStartDigits, BYTE * pEndDigits, BYTE DigitsLen, u_short index ) +{ + SCCP_ROUTE_NODE *pNode = pHead; + int i, j; + BYTE startNum, endNum; + + for ( i = 0; i < DigitsLen; i++ ) + { + startNum = pStartDigits[i] % 10; + endNum = pEndDigits[i] % 10; + if( startNum < endNum ) + { + for ( j = startNum + 1; j < endNum; j++ ) + { + if( pNode->psub[j] == NULL && ( pNode->psub[j] = NewNode ( ) ) == NULL ) + return 0; + + /* add by daniel on 2006-5-15 */ + if( pNode->psub[j]->nItem == 0xFFFF ) //if this node has empty index then mark it with the new index, else do nothing + /* add by daniel on 2006-5-15 */ + pNode->psub[j]->nItem = index; + } + if( pNode->psub[startNum] == NULL && ( pNode->psub[startNum] = NewNode ( ) ) == NULL ) + return 0; + if( pNode->psub[endNum] == NULL && ( pNode->psub[endNum] = NewNode ( ) ) == NULL ) + return 0; + if( AddLargerNode ( pNode->psub[startNum], pStartDigits + i + 1, DigitsLen - i - 1, index ) == 0 ) + return 0; + + if( AddLessNode ( pNode->psub[endNum], pEndDigits + i + 1, DigitsLen - i - 1, index ) == 0 ) + return 0; + return 1; + } + else if( startNum == endNum ) + { + if( pNode->psub[startNum] == NULL && ( pNode->psub[startNum] = NewNode ( ) ) == NULL ) + { + //send alarm here + pNode = NULL; + return 0; + } + pNode = pNode->psub[startNum]; + + if( i >= DigitsLen - 1 ) + { + pNode->nItem = index; + return 1; + } + continue; + } + else if( startNum > endNum ) + return 0; + } + return 1; +} + +int AddLargerNode ( SCCP_ROUTE_NODE * pNode, BYTE * pDigits, BYTE DigitsLen, u_short index ) +{ + int i, j; + BYTE startNum; + + for ( i = 0; i < DigitsLen; i++ ) + { + startNum = pDigits[i] % 10; + for ( j = startNum + 1; j <= 9; j++ ) + { + if( pNode->psub[j] == NULL && ( pNode->psub[j] = NewNode ( ) ) == NULL ) + return 0; + /* add by daniel on 2006-5-15 */ + if( pNode->psub[j]->nItem == 0xFFFF ) //if this node has empty index then mark it with the new index, else do nothing + /* add by daniel on 2006-5-15 */ + pNode->psub[j]->nItem = index; + } + if( pNode->psub[startNum] == NULL && ( pNode->psub[startNum] = NewNode ( ) ) == NULL ) + return 0; + pNode = pNode->psub[startNum]; + } + + pNode->nItem = index; + return 1; +} + +int AddLessNode ( SCCP_ROUTE_NODE * pNode, BYTE * pDigits, BYTE DigitsLen, u_short index ) +{ + int i, j; + BYTE endNum; + + for ( i = 0; i < DigitsLen; i++ ) + { + endNum = pDigits[i] % 10; + for ( j = 0; j < endNum; j++ ) + { + if( pNode->psub[j] == NULL && ( pNode->psub[j] = NewNode ( ) ) == NULL ) + return 0; + /* add by daniel on 2006-5-15 */ + if( pNode->psub[j]->nItem == 0xFFFF ) //if this node has empty index then mark it with the new index, else do nothing + /* add by daniel on 2006-5-15 */ + pNode->psub[j]->nItem = index; + } + if( pNode->psub[endNum] == NULL && ( pNode->psub[endNum] = NewNode ( ) ) == NULL ) + return 0; + + pNode = pNode->psub[endNum]; + } + pNode->nItem = index; + return 1; +} + +SCCP_ROUTE_NODE *NewNode ( ) +{ + if( heap_index >= SCCP_ROUTE_NODE_NUM ){ + spLog ( "Fatal Error: Fail to add GT node, no resource" ); + return NULL; + } + + RouteNode[heap_index].nItem = 0xFFFF; + return &RouteNode[heap_index++]; +} + +/* +*Purpose: check whether a GT is in the SCCP GT table +*Param: np: Number Plan +* tt: Translation Type +* gt: Global title +* gt_len: length of gt +*Return: 0 - the GT is not in SCCP GTT +* 1 - the GT is in SCCP GTT +*/ +int CheckGT(BYTE np, BYTE tt, BYTE *gt, BYTE gt_len) +{ + BYTE Num[32], NumLen; + BYTE field = 0; + int nRoute; + + assert(gt_len < 32); + assert(gt != NULL); + + if( np > 0 ) + Num[field++] = np; + else + Num[field++] = NP_MSISDN; + + if( tt > 0 ) + { + Num[field++] = tt / 100; + Num[field++] = ( tt / 10 ) % 10; + Num[field++] = tt % 10; + } + else + { + Num[field++] = TT_0; + Num[field++] = TT_1; + Num[field++] = TT_4; + } + NumLen = gt_len % ( MAX_DIGITS * 2 ); + Digits2Array ( Num + field, gt, ( NumLen + 1 ) / 2 ); + + nRoute = SelectRoute ( Num, NumLen + field ); + if( nRoute < SCCP_ROUTE_NUM ) + return 1; + else + return 0; +} diff --git a/omc/plat/sccp/src/sccp_log.c b/omc/plat/sccp/src/sccp_log.c new file mode 100644 index 0000000..7724e43 --- /dev/null +++ b/omc/plat/sccp/src/sccp_log.c @@ -0,0 +1,415 @@ +////////////////////////////////////////////////// +//Title : spLog.c +//Auhtor : Liu Wei +//Desc : sccp log implementation +//Created : 2007-05-19 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/sccp.h" +#include "./include/sccp_pub.h" +#include "./include/sccp_func.h" + +BYTE sccpDebugFull = 0; +/* by simon at 23/9/26 */ +extern SCCP_SegMsgBuf sccp_segmsgbuf[MAX_SEGMSG_BUF]; + +extern void spWatchDogStatic ( u8 uDebugStaticMask ); +extern char sccp_debug_buf[5120]; +extern int spLog_fd; +extern unsigned long spLogDebug_mask; + +void spLog ( char *info ) +{ +#ifdef DEBUG_TEST + if( strlen ( info ) < 2048 ) + { + printf ( "[SCCP]: %s\n", info ); + } +#else + if( strlen ( sccp_debug_buf ) + strlen ( info ) > 2048 ) + { + sccpDebugFull = 1; + return; + } + strncat ( sccp_debug_buf, info, 2048 ); + strcat ( sccp_debug_buf, "\r\n" ); + + if( spLog_fd != -1 ) + { + write ( spLog_fd, info, strlen ( info ) ); + write ( spLog_fd, "\r\n", 2 ); + } + + if( strlen ( sccp_debug_buf ) > 2050 ) + { + printf ( "sccp debug buffer overflow, len=%d\n", strlen ( sccp_debug_buf ) ); + } +#endif + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spShowAddr ( SCCP_ADDR * pAddr, const char *sAddrName ) +{ + char srcAddr[128], digits[24]; + + Digits2Str ( digits, pAddr->GTAI, ( ( pAddr->len + 1 ) / 2 ) % MAX_DIGITS ); + digits[pAddr->len] = 0; + sprintf ( srcAddr, "%s: SPC=%06X SSN=%d RI=%d GTI=%d NP=%d TT=%d GT=%s", sAddrName, pAddr->DPC, pAddr->SSN, pAddr->RI, pAddr->GTI, pAddr->NP, pAddr->TT, digits ); + spLog ( srcAddr ); +} + +/////////////////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////////////////// +void spLogDebug ( DWORD mask, const char *fmt, ... ) +{ + va_list ap; + char buf[1024]; + + if( ( mask & spLogDebug_mask ) == 0 || sccpDebugFull ) + { + return; + } + + if( spLogDebug_mask & SCCPDB_TIME ) + { + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[32]; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + if( t == NULL ) + { + assert( 0 && "syscall : localtime fail"); + exit(0); + } + sprintf ( timestr, "(%d:%d:%d.%ld):", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + spLog ( timestr ); + } + + if( ( mask & SCCPDB_ERR ) && ( strlen ( sccp_debug_buf ) + 5 < 2048 ) ) + { + strcat ( sccp_debug_buf, "\33[31m" ); + } + + va_start ( ap, fmt ); + vsnprintf ( buf, 1024, fmt, ap ); + va_end ( ap ); + strcat ( buf, "\33[37m" ); + spLog ( buf ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spShowBCD ( DWORD mask, BYTE * buf, int len ) +{ +// int i = 0, j = 0, linemax = 24; + char info[1024]; + + if( ( spLogDebug_mask & SCCPDB_MSG ) == 0 || ( spLogDebug_mask & mask ) == 0 || sccpDebugFull ) + { + return; + } + + if( len >= 256 ) + { + len = 256; + } + + MsgToFmtLog ( buf, len, info, 1024 ); + spLog ( info ); +} + +void spLogSeg ( SCCP_SegMsgBuf * pSegMsgbuf ) +{ + char digits[24], info[256]; + + spShowAddr ( &pSegMsgbuf->SegID.CGA, "spShowAddr" ); + + BcdToAscii ( digits, pSegMsgbuf->SegID.SegLR, 6 ); + digits[6] = 0; + sprintf ( info, "Seginfo: Total=%d RSE=%d DPC=%06X SLS=%d Class=%d SegLR=0x%s", pSegMsgbuf->MsgTotal, pSegMsgbuf->RSE, pSegMsgbuf->SegID.DPC, pSegMsgbuf->SegID.SLS, pSegMsgbuf->MsgClass, digits ); + spLog ( info ); + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spShowMsg ( DWORD mask, const char *pDesc, Intra_Msg * pIntraMsg ) +{ +// int i = 0, j = 0, linemax = 24; + int len; +// char srcAddr[128], dstAddr[128]; + char digits[24], info[1024]; + char *pStr; + + if( ( mask & spLogDebug_mask ) == 0 && ( sccp_filter_msg ( &pIntraMsg->CGA, &pIntraMsg->CDA ) == 0 || mask >= SCCPDB_STP ) ) + { + return; + } + if( sccpDebugFull ) + { + return; + } + if( strlen ( sccp_debug_buf ) + 2 < 2048 ) + { + strcat ( sccp_debug_buf, "\r\n" ); + } + if( spLogDebug_mask & SCCPDB_TIME ) + { + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[32]; + + gettimeofday ( &tv, &tz ); + t = localtime ( &tv.tv_sec ); + if( t == NULL ) + { + assert( 0 && "syscall : localtime fail"); + exit(0); + } + sprintf ( timestr, "(%d:%d:%d.%ld):", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec ); + spLog ( timestr ); + } + + if( mask & SCCPDB_ERR && ( strlen ( sccp_debug_buf ) + 5 < 2048 ) ) + { + strcat ( sccp_debug_buf, "\33[31m" ); + } + + spGetMsgStr ( pIntraMsg->msgtype, pStr ); + sprintf ( info, "%s %s[%d->%d], SLS=%02x, NetID=%d, msglen=%d\33[37m", pDesc, pStr, pIntraMsg->CGA.SSN, pIntraMsg->CDA.SSN, pIntraMsg->SLS, pIntraMsg->NetID, pIntraMsg->msglen ); + + spLog ( info ); + + if( ( spLogDebug_mask & SCCPDB_ADDR ) || ( mask & SCCPDB_ERR ) ) + { + spShowAddr ( &pIntraMsg->CGA, "SrcAddr" ); + spShowAddr ( &pIntraMsg->CDA, "DstAddr" ); + } + + if( mask & SCCPDB_AIF ) + { + char digits1[24], digits2[24]; + + BcdToAscii ( digits1, pIntraMsg->aSLR, 6 ); + digits1[6] = 0; + BcdToAscii ( digits2, pIntraMsg->aDLR, 6 ); + digits2[6] = 0; + sprintf ( info, "SLR = %s DLR = %s ", digits1, digits2 ); + spLog ( info ); + } + + if( mask & SCCPDB_XUDT ) + { + BcdToAscii ( digits, pIntraMsg->Segmnt.SegLR, 6 ); + digits[6] = 0; + sprintf ( info, "Seginfo: RS=%d SegLR=0x%s", pIntraMsg->Segmnt.RSBits, digits ); + spLog ( info ); + } + + if( ( spLogDebug_mask & SCCPDB_MSG ) == 0 ) + { + return; + } + + len = pIntraMsg->msglen % 256; + MsgToFmtLog ( pIntraMsg->data, len, info, 1024 ); + spLog ( info ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spShowPrimitive ( SP_UiPriPara * pUiPriParam, u8 uDirection ) +{ + u8 *pStr; + + spGetUlPrimitiveStr ( pUiPriParam->uUiPri, pStr ); + if( uDirection ) + { + spLogDebug ( SCCPDB_TIME, "AIF ==> SCCP : %s", pStr ); + } + else + { + spLogDebug ( SCCPDB_TIME, "SCCP ==> AIF : %s", pStr ); + } + + spShowUserData ( pUiPriParam ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLogStateError ( u16 wConnId, u8 uErrCode ) +{ + CO_ConnSection *pCS; + u8 *pStateStr; + u8 *pPriStr; + u8 *pSideStr; + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP spLogStateError unexpected connection id" ); + + pCS = &pSp->tCo.tCSInst[wConnId]; + + spGetCoStateStr ( pCS->uCState, pStateStr ); + spGetUlPrimitiveStr ( pCS->uPri, pPriStr ); + spGetCoInstanceSide ( pCS->uSide, pSideStr ); + + switch ( uErrCode ) + { + case ERR_NONE: + { +#ifdef _WXC_FSM_TEST + char str[512]; + + sprintf ( str, "]coFsm[: call back state %s , side :%s \n", pStateStr, pSideStr ); + spLog ( str ); +#endif + } + break; + case ERR_FSM_UNEXPECT_SIDE: + spLogDebug ( SCCPDB_ERR, "Recieve unexpected side: %s ", pSideStr ); + spWatchDogStatic ( ERR_FSM_UNEXPECT_SIDE ); + break; + case ERR_FSM_UNEXPECT_PRI: + spLogDebug ( SCCPDB_ERR, "Recieve unexpected primitive in the state machine ," "Discard the primtive . \nstate: %s primtive :%s side :%s\n", pStateStr, pPriStr, pSideStr ); + spWatchDogStatic ( ERR_FSM_UNEXPECT_PRI ); + break; + case ERR_FSM_DISCARD: + spLogDebug ( SCCPDB_ERR, "Unexpected state machine ,Discard the state : %s side :%s", pStateStr, pSideStr ); + spWatchDogStatic ( ERR_FSM_DISCARD ); + break; + case ERR_FSM_ERROR: + spLogDebug ( SCCPDB_ERR, "Unexpected state machine ,error state : %s side :%s", pStateStr, pSideStr ); + spWatchDogStatic ( ERR_FSM_ERROR ); + break; + case ERR_FSM_FATAL: + spLogDebug ( SCCPDB_ERR, "Unexpected state machine ,fatal error : %s side :%s", pStateStr, pSideStr ); + spWatchDogStatic ( ERR_FSM_FATAL ); + case ERR_FSM_RESERVED: + spLogDebug ( SCCPDB_ERR, "Unexpected reserved state machine, unsupported now state : %s side :%s", pStateStr, pSideStr ); + spWatchDogStatic ( ERR_FSM_RESERVED ); + break; + default: + spLogDebug ( SCCPDB_ERR, "SCCP log state error , but unkonw eror code" ); + spWatchDogStatic ( ERR_FSM_UNKOWN_ERROR_CODE ); + break; + } +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLogTimerOut ( u16 wConnId, u8 uTimerID ) +{ + u8 *pTimerStr; + + spGetTimerOutStr ( uTimerID, pTimerStr ); + spLogDebug ( SCCPDB_ERR, "SCCP Timer Out Timer ID : %s ConnID : %d ", pTimerStr, wConnId ); + spWatchDogStatic ( SP_TIMER_OUT ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spShowUserData ( SP_UiPriPara * pPri ) +{ + SP_UD *pUd; + SP_UiPriUnion *pPriUn; + + pPriUn = &pPri->tPriUnion; + + switch ( pPri->uUiPri ) + { + case N_CONNECT_REQ: + if( !( pPriUn->tPriNConnReq.uOptFlag & 0x08 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Connect Req primitive Flag :0x%X ", pPriUn->tPriNConnReq.uOptFlag ); + pUd = &pPriUn->tPriNConnReq.tUD; + break; + case N_CONNECT_IND: + if( !( pPriUn->tPriNConnInd.uOptFlag & 0x04 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Connect Ind primitive Flag :0x%X NetID : %d " + "RI : %d SSN : %d" , pPriUn->tPriNConnInd.uOptFlag + ,pPriUn->tPriNConnInd.tCDA.NetID + ,pPriUn->tPriNConnInd.tCDA.RI + ,pPriUn->tPriNConnInd.tCDA.SSN ); + pUd = &pPriUn->tPriNConnInd.tUD; + break; + case N_CONNECT_CFM: + if( !( pPriUn->tPriNConnCfm.uOptFlag & 0x04 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Connect Cfm primitive Flag :0x%X ", pPriUn->tPriNConnCfm.uOptFlag ); + pUd = &pPriUn->tPriNConnCfm.tUD; + break; + case N_CONNECT_RSP: + if( !( pPriUn->tPriNConnRsp.uOptFlag & 0x04 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Connect Rsp primitive Flag :0x%X ", pPriUn->tPriNConnRsp.uOptFlag ); + pUd = &pPriUn->tPriNConnRsp.tUD; + break; + case N_DISCONNECT_REQ: + if( !( pPriUn->tPriNDisconnReq.uOptFlag & 0x04 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Disconnect Req primitive Flag :0x%X ", pPriUn->tPriNDisconnReq.uOptFlag ); + pUd = &pPriUn->tPriNDisconnReq.tUD; + break; + case N_DISCONNECT_IND: + if( !( pPriUn->tPriNDisconnInd.uOptFlag & 0x04 ) ) + { + return; + } + spLogDebug ( SCCPDB_AIF, "Disconnect Ind primitive Flag :0x%X ", pPriUn->tPriNDisconnInd.uOptFlag ); + pUd = &pPriUn->tPriNDisconnInd.tUD; + break; + case N_DATA_REQ: + pUd = &pPriUn->tPriNDataReq.tUD; + break; + case N_DATA_IND: + pUd = &pPriUn->tPriNDataInd.tUD; + break; + case N_DATAAK_REQ: + case N_EDATA_REQ: + case N_RESET_REQ: + case N_RESET_RSP: + case N_INFORM_REQ: + return; + default: + return; + } + if( pUd->uDataLen > 0 ) + { + spShowBCD ( SCCPDB_AIF, pUd->aUserData, ( pUd->uDataLen ) % 256 ); + } +} diff --git a/omc/plat/sccp/src/sccp_mib.c b/omc/plat/sccp/src/sccp_mib.c new file mode 100644 index 0000000..2678ee9 --- /dev/null +++ b/omc/plat/sccp/src/sccp_mib.c @@ -0,0 +1,241 @@ + +/*********************************************************/ +/*Title: sccpmib.c */ +/*Descr: SCCP Management information Base Interface */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-16 */ +/*Modify: */ + +/*********************************************************/ + +#include "./include/sccp.h" + +/*===========import================*/ +extern int BuildRouteIndex ( ); //gtt.c +extern int sccp_loadparam ( ); //sccpparam.c +extern void sccp_saveparam ( ); +extern int sccp_setparam ( DWORD * oid, BYTE * pdata, WORD datalen ); +extern int sccp_getparam ( DWORD * oid, BYTE * pdata, BYTE * vartype ); +extern void sccp_reset ( ); //sccp.c +extern void DWORD2BYTE ( BYTE * pdword, BYTE * pbyte, int len ); //sccpfun.c +extern void spLogDebug ( DWORD mask, const char *fmt, ... ); +/* by simon at 23/9/26 */ +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +/* by simon at 23/9/26*/ +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern LOCAL_SSN LocalSSN[256]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; + +/*===========export================*/ +void sccpmib_init ( ); +void sccp_sethb ( ); + +/*===========private===============*/ +int sccp_setmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD datalen ); +int sccp_getmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, BYTE * vartype ); +void sccp_trapcallback ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD len, snmp_addr * addr ); + +void sccpmib_init ( ) +{ + DWORD oid[20] = SCCP_OID; + + inquire_setmsg ( SCCP_OIDLEN, oid, sccp_setmib ); + inquire_getmsg ( SCCP_OIDLEN, oid, sccp_getmib ); + inquire_trapmsg ( sccp_trapcallback ); +} + +void sccp_sethb ( ) +{ + set_status ( 2, 4 + SCCP_Param.RegNum, SCCP_Param.version ); + set_led ( 4, 9 ); +} + +/************************************************/ +//MIB Interface=================================> + +/************************************************/ +int sccp_setmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD datalen ) +{ + switch ( oid[SCCP_OIDLEN] ) + { + case 1: //CSTA, read only + return -1; + case 2: //Paramter + return sccp_setparam ( &oid[SCCP_OIDLEN + 1], pdata, datalen ); + case 3: //Status + switch ( oid[SCCP_OIDLEN + 1] ) + { + case 1: //version, read only + return -1; + case 2: //command + switch ( pdata[0] ) + { + case 0: //reset + spLogDebug ( SCCPDB_SNMP, "Reset SCCP..." ); + sccp_reset ( ); + break; + case 1: //load + return -1; + case 2: //save + spLogDebug ( SCCPDB_SNMP, "Save Parameter..." ); + sccp_saveparam ( ); + break; + } + return 1; + case 3: //status, read only + return -1; + } + break; + } + return -1; +} + +int sccp_getmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, BYTE * vartype ) +{ + DWORD instance; + SCCP_CSTA *pcsta; + + spLogDebug ( SCCPDB_SNMP, "get sccp mib..." ); + switch ( oid[SCCP_OIDLEN] ) + { + case 1: //CSTA + instance = oid[SCCP_OIDLEN + 1]; + if( instance == SccpCstaInd || instance > 95 ) + { + *vartype = NosuchInstance; + spLogDebug ( SCCPDB_SNMP, "csta message not ready. instance=%d", instance ); + return 0; + } + pcsta = &SccpCsta[instance]; + if( pcsta->timestamp == 0 ) + { + spLogDebug ( SCCPDB_SNMP, "csta message is expired" ); + *vartype = 5; + return 0; + } + *vartype = 4; + spLogDebug ( SCCPDB_SNMP, "Respond csta message" ); + DWORD2BYTE ( ( BYTE * ) & pcsta->timestamp, pdata, sizeof ( SCCP_CSTA ) ); + return sizeof ( SCCP_CSTA ); + case 2: //Config + return sccp_getparam ( &oid[SCCP_OIDLEN + 1], pdata, vartype ); + case 3: //Status + switch ( oid[SCCP_OIDLEN + 1] ) + { + case 1: //version + spLogDebug ( SCCPDB_SNMP, "Get SCCP Version" ); + memcpy ( pdata, SCCP_Param.version, 3 ); + *vartype = 4; + return 3; + case 2: //command, write only + return -1; + case 3: //status + pdata[0] = SCCP_Param.status; + *vartype = 2; + return 1; + } + break; + } + return -1; +} + +//#define OMC_HB_OID {1,3,6,1,4,1,1373,1,4,1,1} +#define OMC_HB_OID {1,3,6,1,4,1,1373,2,4,1} +#define OMC_HB_OIDLEN 10 +int AddToIpList ( DWORD ip, BYTE ssn ); + +void sccp_OMCIP_detect ( DWORD ip ) +{ + int i; + BYTE index = 0; + + for ( i = 0; i <= 1; i++ ) + { + if( SCCP_Param.OMCIP[i] == ip ) + return; + else if( SCCP_Param.OMCIP[i] == 0 ) + index = i; + } + SCCP_Param.OMCIP[index] = ip; + AddToIpList ( ip, 4 ); +} + +extern ull SCCPSerialNumber; + +void sccp_trapcallback ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD len, snmp_addr * addr ) +{ + DWORD ObjID[20] = FLATFORM_HB_OID; + BYTE ssn; + short infolen, i, pos = 2; //component_id=0:iptrans + heartbeat_msg *phbmsg = ( heartbeat_msg * ) pdata; + BYTE *pstatus = phbmsg->info; + DWORD OMCHLObjID[20] = OMC_HB_OID; + BYTE newHeartbeat = 0; + + if( memcmp ( &oid[7], &OMCHLObjID[7], ( OMC_HB_OIDLEN - 7 ) * 4 ) == 0 ) //omc heartbeat + { //automatic add omc ip into ip list, + //if receive omc heartbeat and the omc serial number is equial to the local serial number, + //then the platform will send heartbeat if received omc heartbeat + if( ( SCCPSerialNumber == 0 ) || //support old version, do not have serial number + ( Bcd2Ull ( &pdata[39], SCCP_SERNUM_LEN ) == SCCPSerialNumber ) ) + sccp_OMCIP_detect ( addr->remote_ip ); + } + + if( memcmp ( &oid[9], &ObjID[9], ( FLATFORM_HB_OIDLEN - 9 ) * 4 ) != 0 || addr->remote_ip == SCCP_Param.ip ) + return; + + if( sizeof ( struct heartbeat_msg ) > ( INFO_LEN + 18 ) ) + newHeartbeat = 1; + + if( !newHeartbeat ) + { //old version heartbeat, length and component_id are one octet + pos = 1; + pos += pstatus[pos] + 1; //length of iptrans status + pos++; //component_id=1:mtp3 + pos += pstatus[pos] + 1; //length of mtp3 + pos++; //component_id=2:sccp + } + else + { //new version heartbeat, length and component_id are 2 octets + pos++; //length is 2 octets + pos += pstatus[pos] + 1; //length of iptrans status + pos++; //component_id=1:mtp3 + pos++; //component_id is 2 octets + + pos++; //length is 2 octets + pos += pstatus[pos] + 1; //length of mtp3 + + pos++; //component_id=2:sccp + pos++; //component_id is 2 octets + + pos++; //sccp length 1 + } + infolen = pstatus[pos++]; + + if( infolen <= 4 || infolen > 32 ) + return; + + for ( i = pos + 4; i < pos + infolen; i++ ) + { + ssn = pstatus[i]; + // printf("beat recieve,ssn=%d\n",ssn); + if( ssn <= 1 ) + continue; + if( addr->remote_ip == LocalSSN[ssn].ip[0] ) + { + LocalSSN[ssn].status[0] = ST_Enable; + LocalSSN[ssn].timeout[0] = T_hbrecv; + } + else if( addr->remote_ip == LocalSSN[ssn].ip[1] ) + { + LocalSSN[ssn].status[1] = ST_Enable; + LocalSSN[ssn].timeout[1] = T_hbrecv; + } + } + +} diff --git a/omc/plat/sccp/src/sccp_msg.c b/omc/plat/sccp/src/sccp_msg.c new file mode 100644 index 0000000..331b4d1 --- /dev/null +++ b/omc/plat/sccp/src/sccp_msg.c @@ -0,0 +1,777 @@ + +/*****************************************/ +/*Title:sccpmsg.c */ +/*Descr:SCCP message Procedure */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-5-9 */ + +/*****************************************/ +#include "./include/sccp.h" +/* =========== export ================ */ +int build_msg ( BYTE * buf, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ); +int parse_msg ( BYTE * buf, Intra_Msg * intramsg, int len, BYTE NetID, BYTE ansi_flag ); + +/* =========== private ================ */ +static int parse_oparam ( BYTE * buf, int len, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ); +static int encode_addr ( BYTE * buf, SCCP_ADDR * addr, BYTE NetID ); +static int decode_addr ( BYTE * buf, SCCP_ADDR * addr, BYTE NetID ); + +/* ansi */ +static int encode_addr_Ansi ( BYTE * buf, SCCP_ADDR * addr ); +static int decode_addr_Ansi ( BYTE * buf, SCCP_ADDR * addr ); + +/* ansi */ +//static int encode_int ( BYTE * buf, unsigned int val, BYTE len ); +//static unsigned int decode_int ( BYTE * buf, BYTE len ); + +extern void spLogDebug ( DWORD mask, const char *fmt, ... ); + +/* by simon at 23/9/26 */ +extern SCCP_Capture_Buf SCCPCapBuf; +extern DWORD SccpCstaInd; +extern LOCAL_SSN LocalSSN[256]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; + +//////////////////////////////////////////////////////////// + +int build_msg ( BYTE * buf, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ) +{ + int msglen = 0, vnum = 0, vlen = 0; + + buf[msglen++] = intramsg->msgtype; + + if( intramsg->msglen > 256 ) + { + intramsg->msglen = 256; + } + + switch ( intramsg->msgtype ) + { + case CR_MSG: + vnum = 1 + 1; + memcpy ( buf + msglen, &intramsg->aSLR, 3 ); //SLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aSLR, 3 ); //SLR + buf[msglen++] = intramsg->msgclass; //protocol class + /*Mandatory variable part */ + buf[msglen++] = vnum--; //pointer of CDA + if( !ansi_flag ) + vlen += encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CDA ), NetID ); + else + vlen += encode_addr_Ansi ( buf + msglen + vnum + vlen, &( intramsg->CDA ) ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of optional part + msglen += vlen; + /*optional part */ + /* + buf[msglen++] = P_CGA; //codes of CGA + msglen += encode_addr(buf + msglen, &(intramsg->CGA), NetID); + */ + buf[msglen++] = P_Data; + if( intramsg->msglen > 0 ) + { + buf[msglen++] = intramsg->msglen; + memcpy ( buf + msglen, intramsg->data, intramsg->msglen ); + msglen += intramsg->msglen; + } + buf[msglen++] = P_EOP; + break; + case CC_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + memcpy ( buf + msglen, &intramsg->aSLR, 3 ); //SLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aSLR, 3 ); + buf[msglen++] = intramsg->msgclass; + buf[msglen++] = 1; // pointer ot end of optional + buf[msglen++] = 0; // end of optional + break; + case CREF_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + buf[msglen++] = intramsg->cause; + buf[msglen++] = 1; // pointer ot end of optional + buf[msglen++] = 0; // end of optional + break; + case UDT_MSG: + vnum = 3; + buf[msglen++] = intramsg->msgclass; + /*mandatory variable part */ + buf[msglen++] = vnum--; //pointer of CDA + if( !ansi_flag ) + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CDA ), NetID ) % 64 ); + else + vlen += ( encode_addr_Ansi ( buf + msglen + vnum + vlen, &( intramsg->CDA ) ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of CGA + if( !ansi_flag ) + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CGA ), NetID ) % 64 ); + else + vlen += ( encode_addr_Ansi ( buf + msglen + vnum + vlen, &( intramsg->CGA ) ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of Data + buf[msglen + vnum + vlen] = intramsg->msglen; //Length of Data + memcpy ( buf + msglen + vnum + vlen + 1, intramsg->data, intramsg->msglen ); + vlen = vlen + intramsg->msglen + 1; + + msglen += vlen; + break; + case UDTS_MSG: + vnum = 3; + buf[msglen++] = intramsg->cause; + /*mandatory variable part */ + buf[msglen++] = vnum--; //pointer of CDA + if( !ansi_flag ) + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CDA ), NetID ) % 64 ); + else + vlen += ( encode_addr_Ansi ( buf + msglen + vnum + vlen, &( intramsg->CDA ) ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of CGA + if( !ansi_flag ) + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CGA ), NetID ) % 64 ); + else + vlen += ( encode_addr_Ansi ( buf + msglen + vnum + vlen, &( intramsg->CGA ) ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of Data + buf[msglen + vnum + vlen] = intramsg->msglen; //Length of Data + memcpy ( buf + msglen + vnum + vlen + 1, intramsg->data, intramsg->msglen ); + vlen = vlen + intramsg->msglen + 1; + + msglen += vlen; + break; + case XUDT_MSG: + vnum = intramsg->SegPresent ? 4 : 3; + buf[msglen++] = intramsg->msgclass; + buf[msglen++] = intramsg->Hop; + /*mandatory variable part */ + buf[msglen++] = vnum--; //pointer of CDA + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CDA ), NetID ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of CGA + vlen += ( encode_addr ( buf + msglen + vnum + vlen, &( intramsg->CGA ), NetID ) % 64 ); + + buf[msglen++] = ( vnum-- ) + vlen; //Pointer of Data + buf[msglen + vnum + vlen] = intramsg->msglen; //Length of Data + memcpy ( buf + msglen + vnum + vlen + 1, intramsg->data, intramsg->msglen ); + vlen = vlen + intramsg->msglen + 1; + + if( intramsg->SegPresent ) + { + buf[msglen++] = ( vnum-- ) + vlen; //Pointer to Segmentation + buf[msglen + vnum + vlen] = P_SEG; //Segmentation tag + buf[msglen + vnum + vlen + 1] = 4; //Segmentation len + memcpy ( buf + msglen + vnum + vlen + 2, &intramsg->Segmnt, 4 ); + msglen += 6; + } + msglen += vlen; + break; + case DT1_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + buf[msglen++] = intramsg->EOD; + + buf[msglen++] = 1; //Pointer of Data + buf[msglen++] = intramsg->msglen; //Length of Data + memcpy ( buf + msglen, intramsg->data, intramsg->msglen ); + msglen += intramsg->msglen; + break; + case DT2_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + buf[msglen++] = 2 * intramsg->PS; + buf[msglen++] = 2 * intramsg->PR + intramsg->EOD; + + buf[msglen++] = 1; //Pointer of Data + buf[msglen++] = intramsg->msglen; //Length of Data + memcpy ( buf + msglen, intramsg->data, intramsg->msglen ); + msglen += intramsg->msglen; + break; + case RLSD_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + memcpy ( buf + msglen, &intramsg->aSLR, 3 ); //SLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + //msglen += encode_int ( buf + msglen, intramsg->aSLR, 3 ); + buf[msglen++] = intramsg->cause; + buf[msglen++] = 1; // pointer ot end of optional + buf[msglen++] = 0; // end of optional + break; + case RLC_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + memcpy ( buf + msglen, &intramsg->aSLR, 3 ); //SLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + //msglen += encode_int ( buf + msglen, intramsg->aSLR, 3 ); + break; + case IT_MSG: + memcpy ( buf + msglen, &intramsg->aDLR, 3 ); //DLR + msglen += 3; + memcpy ( buf + msglen, &intramsg->aSLR, 3 ); //SLR + msglen += 3; + //msglen += encode_int ( buf + msglen, intramsg->aDLR, 3 ); + //msglen += encode_int ( buf + msglen, intramsg->aSLR, 3 ); + buf[msglen++] = 2; //class = 2 + buf[msglen++] = 0; //Sequencing/segmenting octet 0 + buf[msglen++] = 0; //Sequencing/segmenting octet 1 + buf[msglen++] = 0; //Credit + break; + } + //buf[0] = msglen-1; + return msglen; +} + +int parse_msg ( BYTE * buf, Intra_Msg * intramsg, int len, BYTE NetID, BYTE ansi_flag ) +{ + int pos = 0; + BYTE ptv, vlen; + + intramsg->msgtype = buf[pos++]; + switch ( intramsg->msgtype ) + { + case CR_MSG: + if( len < 4 ) + SCCPCapBuf.watch_dog[2]++; //invalid CR message + + memcpy ( &intramsg->aSLR, buf + pos, 3 ); //SLR + pos += 3; + //intramsg->aSLR = decode_int ( buf + pos, 3 ); + intramsg->msgclass = buf[pos++]; + + ptv = pos + buf[pos]; + pos++; + if( !ansi_flag ) + vlen = decode_addr ( buf + ptv, &( intramsg->CDA ), NetID ); + else + vlen = decode_addr_Ansi ( buf + ptv, &( intramsg->CDA ) ); + + if( vlen + ptv >= len ) + return 1; + ptv = pos + buf[pos]; + pos++; + parse_oparam ( buf + ptv, len - ptv, intramsg, NetID, ansi_flag ); + break; + case CC_MSG: + if( len < 8 ) + SCCPCapBuf.watch_dog[3]++; //invalid CC message + + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + memcpy ( &intramsg->aSLR, buf + pos, 3 ); //SLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + //intramsg->aSLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->msgclass = buf[pos++]; + + ptv = pos + buf[pos]; +/* if (buf[ptv++] == 0x0F) + { + intramsg->msglen = buf[ptv++]; + memcpy ( intramsg->data, buf + ptv, intramsg->msglen ); + } +*/ + parse_oparam ( buf + ptv, len - ptv, intramsg, NetID, ansi_flag ); + break; + case CREF_MSG: + if( len < 5 ) + SCCPCapBuf.watch_dog[4]++; //invalid CREF message + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->cause = buf[pos++]; + ptv = pos + buf[pos]; + parse_oparam ( buf + ptv, len - ptv, intramsg, NetID, ansi_flag ); + break; + case UDT_MSG: + if( len < 2 ) + SCCPCapBuf.watch_dog[5]++; //invalid UDT message + + intramsg->msgclass = buf[pos++]; + ptv = pos + buf[pos]; + pos++; + if( !ansi_flag ) + vlen = decode_addr ( buf + ptv, &( intramsg->CDA ), NetID ); + else + vlen = decode_addr_Ansi ( buf + ptv, &( intramsg->CDA ) ); + ptv = pos + buf[pos]; + pos++; + if( !ansi_flag ) + vlen = decode_addr ( buf + ptv, &( intramsg->CGA ), NetID ); + else + vlen = decode_addr_Ansi ( buf + ptv, &( intramsg->CGA ) ); + + ptv = pos + buf[pos]; + pos++; + intramsg->msglen = buf[ptv]; + memcpy ( intramsg->data, buf + ptv + 1, intramsg->msglen ); + break; + case UDTS_MSG: + if( len < 2 ) + SCCPCapBuf.watch_dog[6]++; //invalid UDTs message + + intramsg->cause = buf[pos++]; + ptv = pos + buf[pos]; + pos++; + if( !ansi_flag ) + vlen = decode_addr ( buf + ptv, &( intramsg->CDA ), NetID ); + else + vlen = decode_addr_Ansi ( buf + ptv, &( intramsg->CDA ) ); + ptv = pos + buf[pos]; + pos++; + if( !ansi_flag ) + vlen = decode_addr ( buf + ptv, &( intramsg->CGA ), NetID ); + else + vlen = decode_addr_Ansi ( buf + ptv, &( intramsg->CGA ) ); + + ptv = pos + buf[pos]; + pos++; + intramsg->msglen = buf[ptv]; + memcpy ( intramsg->data, buf + ptv + 1, intramsg->msglen ); + break; + case XUDT_MSG: + //if (len < 2) + // SCCPCapBuf.watch_dog[5]++;//invalid XUDT message + + intramsg->msgclass = buf[pos++]; + intramsg->Hop = buf[pos++]; + ptv = pos + buf[pos]; + pos++; + vlen = decode_addr ( buf + ptv, &( intramsg->CDA ), NetID ); + ptv = pos + buf[pos]; + pos++; + vlen = decode_addr ( buf + ptv, &( intramsg->CGA ), NetID ); + + if( vlen + ptv >= len ) + return 1; + ptv = pos + buf[pos]; + pos = ptv; + intramsg->msglen = buf[pos++]; + memcpy ( intramsg->data, buf + pos, intramsg->msglen ); + pos += intramsg->msglen; + parse_oparam ( buf + pos, len - pos, intramsg, NetID, ansi_flag ); + break; + case DT1_MSG: + if( len < 5 ) + SCCPCapBuf.watch_dog[7]++; //invalid DT1 message + + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->EOD = buf[pos++]; + + ptv = pos + buf[pos]; + pos++; + intramsg->msglen = buf[ptv]; + memcpy ( intramsg->data, buf + ptv + 1, intramsg->msglen ); + break; + case DT2_MSG: + if( len < 7 ) + SCCPCapBuf.watch_dog[8]++; //invalid DT2 message + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->PS = buf[pos++] / 2; + intramsg->PR = buf[pos] / 2; + intramsg->EOD = buf[pos++] % 2; + + ptv = pos + buf[pos]; + pos++; + intramsg->msglen = buf[ptv]; + memcpy ( intramsg->data, buf + ptv + 1, intramsg->msglen ); + break; + case RLSD_MSG: + if( len < 8 ) + SCCPCapBuf.watch_dog[9]++; //invalid RLSD message + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + memcpy ( &intramsg->aSLR, buf + pos, 3 ); //SLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + //intramsg->aSLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->cause = buf[pos++]; + break; + case RLC_MSG: + if( len < 7 ) + SCCPCapBuf.watch_dog[10]++; //invalid RLC message + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + memcpy ( &intramsg->aSLR, buf + pos, 3 ); //SLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + //intramsg->aSLR = decode_int ( buf + pos, 3 ); + //pos += 3; + break; + case IT_MSG: + if( len < 8 ) + SCCPCapBuf.watch_dog[11]++; //invalid IT message + memcpy ( &intramsg->aDLR, buf + pos, 3 ); //DLR + pos += 3; + memcpy ( &intramsg->aSLR, buf + pos, 3 ); //SLR + pos += 3; + //intramsg->aDLR = decode_int ( buf + pos, 3 ); + //pos += 3; + //intramsg->aSLR = decode_int ( buf + pos, 3 ); + //pos += 3; + intramsg->msgclass = buf[pos++]; + break; + } + return 1; +} + +int parse_oparam ( BYTE * buf, int len, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ) +{ + int pos = 0; + BYTE nparam; + + while ( pos < len ) + { + nparam = buf[pos++]; + switch ( nparam ) + { + case P_EOP: + return 1; + case P_CDA: + /* if (!ansi_flag) + pos += decode_addr(buf + pos, &(intramsg->CDA), NetID); + else + pos += decode_addr_Ansi(buf + pos, &(intramsg->CDA)); */ + break; + case P_CGA: + if( !ansi_flag ) + pos += decode_addr ( buf + pos, &( intramsg->CGA ), NetID ); + else + pos += decode_addr_Ansi ( buf + pos, &( intramsg->CGA ) ); + break; + case P_Data: + intramsg->msglen = buf[pos++]; + memcpy ( intramsg->data, buf + pos, intramsg->msglen ); + pos += intramsg->msglen; + break; + case P_SEG: + if( buf[pos] != 4 ) + { + spLogDebug ( SCCPDB_USER, "SCCP XUDT Msg Segmentaion Parameters length error!" ); + } + pos++; + memcpy ( &intramsg->Segmnt, &buf[pos], 4 ); + intramsg->SegPresent = 1; + pos += 4; + break; + case P_DLR: + case P_SLR: + case P_PLC: + case P_EOD: + case P_PR: + case P_SEQ: + case P_Credit: + case P_RLC: + case P_RTC: + case P_RSC: + case P_ERC: + case P_RFC: + case P_HC: + case P_Importance: + case P_Ldata: + break; + } + } + return 1; +} +/* +int encode_int ( BYTE * buf, unsigned int val, BYTE len ) +{ + BYTE temp[4]; + + temp[0] = ( BYTE ) ( ( val & 0xFF000000 ) >> 24 ); + temp[1] = ( BYTE ) ( ( val & 0xFF0000 ) >> 16 ); + temp[2] = ( BYTE ) ( ( val & 0xFF00 ) >> 8 ); + temp[3] = ( BYTE ) ( val & 0xFF ); + memcpy ( buf, temp + 4 - len, len ); + + return len; +} + +unsigned int decode_int ( BYTE * buf, BYTE len ) +{ + unsigned int rtn = 0, i; + + for ( i = 0; i < len; i++ ) + rtn = rtn << 8 | buf[i]; + return rtn; +} +*/ +int encode_addr ( BYTE * buf, SCCP_ADDR * addr, BYTE NetID ) +{ + BYTE len = 0, cp_len; + BYTE RI_MASK = 0x40, SSN_MASK = 0x02, DPC_MASK = 0x01, GT_MASK = 0x04; + + /*GTI*/ len = 2; + //if(addr->RI == RI_SSN && addr->SSN > 0) + // addr->GTI = 0; + + buf[1] = ( RI_MASK * addr->RI ) | ( SSN_MASK ) | ( DPC_MASK & ( addr->DPC > 0 ? 1 : 0 ) & ( addr->AI & 1 ) ) | ( GT_MASK * addr->GTI ); + + if( ( addr->DPC > 0 ) & ( addr->AI & 1 ) ) + { + memcpy ( buf + len, ( BYTE * ) & addr->DPC, SCCP_Param.spclen[NetID] ); + len += SCCP_Param.spclen[NetID]; + } + buf[len++] = addr->SSN; + switch ( addr->GTI ) + { + case 0: //no global title included + break; + case 1: //global title includes nature of address indicator only + buf[len++] = addr->NAI; + memcpy ( buf + len, addr->GTAI, ( addr->len + 1 ) / 2 ); + len += ( addr->len + 1 ) / 2; + + break; + case 2: //global title includes translation type only + buf[len++] = addr->TT; + memcpy ( buf + len, addr->GTAI, ( addr->len + 1 ) / 2 ); + len += ( addr->len + 1 ) / 2; + break; + case 3: //global title includes translation type, NP, EC + buf[len++] = addr->TT; + cp_len = ( addr->len + 1 ) / 2; + if( addr->len & 1 ) //odd number of address signals + { + addr->ES = 1; + addr->GTAI[cp_len - 1] = addr->GTAI[cp_len - 1] & 0x0F; + } + else + addr->ES = 2; + + buf[len++] = addr->NP * 16 + addr->ES; + addr->GTAI[len] = 0; + memcpy ( buf + len, addr->GTAI, cp_len ); + len += cp_len; + break; + case 4: //global title includes translation type, NP, EC, NAI + buf[len++] = addr->TT; + + addr->len %= 18; + cp_len = ( addr->len + 1 ) / 2; + if( addr->len & 1 ) //odd number of address signals + { + addr->ES = 1; + addr->GTAI[cp_len - 1] = addr->GTAI[cp_len - 1] & 0x0F; + } + else + addr->ES = 2; + + buf[len++] = addr->NP * 16 + addr->ES; + buf[len++] = addr->NAI; + memcpy ( buf + len, addr->GTAI, cp_len ); + len += cp_len; + break; + } + buf[0] = len - 1; + return len; +} + +int decode_addr ( BYTE * buf, SCCP_ADDR * addr, BYTE NetID ) +{ + BYTE len, pos, nbyte; + BYTE RI_MASK = 0x40, SSN_MASK = 0x02, DPC_MASK = 0x01, GT_MASK = 0x3C; + BYTE DPCI; + + len = buf[0] + 1; + addr->RI = ( buf[1] & RI_MASK ) >> 6; + addr->GTI = ( buf[1] & GT_MASK ) >> 2; + DPCI = ( buf[1] & DPC_MASK ); + addr->SSN = ( buf[1] & SSN_MASK ) >> 1; + pos = 2; + if( DPCI ) + { + memcpy ( ( BYTE * ) & addr->DPC, buf + pos, SCCP_Param.spclen[NetID] ); + pos += SCCP_Param.spclen[NetID]; + } + if( addr->SSN ) + addr->SSN = buf[pos++]; + + switch ( addr->GTI ) + { + case 0: //no global title included + break; + case 1: //global title includes nature of address indicator only + addr->NAI = buf[pos++] & 0x7F; + nbyte = len - pos; + addr->len = 2 * nbyte; + if( ( buf[pos - 1] & 0x80 ) == 0x80 ) //odd number of address signals + addr->len--; + + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + case 2: //global title includes translation type only + addr->TT = buf[pos++]; + nbyte = len - pos; + addr->len = 2 * nbyte; + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + case 3: //global title includes translation type, NP, EC + addr->TT = buf[pos++]; + addr->NP = buf[pos] / 16; + addr->ES = buf[pos++] % 16; + nbyte = len - pos; + addr->len = 2 * nbyte; + if( addr->ES == 1 ) + addr->len--; + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + case 4: //global title includes translation type, NP, EC, NAI + addr->TT = buf[pos++]; + addr->NP = buf[pos] / 16; + addr->ES = buf[pos++] % 16; + addr->NAI = buf[pos++] & 0x7F; + nbyte = len - pos; + addr->len = 2 * nbyte; + if( addr->ES == 1 ) + addr->len--; + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + } + return len; +} + +//----->ansi + +int encode_addr_Ansi ( BYTE * buf, SCCP_ADDR * addr ) +{ + BYTE len = 0, cp_len; + BYTE NAT_MASK = 0x80, RI_MASK = 0x40, DPC_MASK = 0x02, SSN_MASK = 0x01, GT_MASK = 0x04; + BYTE spclen = 3; //ansi is always 24 bit,3 bytes + + /*GTI*/ len = 2; + //if(addr->RI == RI_SSN && addr->SSN > 0) + // addr->GTI = 0; + + switch ( addr->GTI ) + { + case 4: + addr->GTI = 2; + break; + default: + break; + } + + buf[1] = NAT_MASK | ( RI_MASK * addr->RI ) | ( SSN_MASK ) | ( DPC_MASK & ( ( addr->DPC > 0 ? 1 : 0 ) * 2 ) & ( ( addr->AI & 1 ) * 2 ) ) | ( GT_MASK * addr->GTI ); + + buf[len++] = addr->SSN; + + if( addr->DPC > 0 && ( addr->AI & 1 ) ) + { + /* memcpy(buf + len, (BYTE *)&addr->DPC, SCCP_Param.spclen[NetID]); + len += SCCP_Param.spclen[NetID]; */ + memcpy ( buf + len, ( BYTE * ) & addr->DPC, spclen ); + len += spclen; + } + + switch ( addr->GTI ) + { + case 0: //no global title included + break; + case 1: //global title includes translation type, NP, EC + buf[len++] = addr->TT; + cp_len = ( addr->len + 1 ) / 2; + if( addr->len & 1 ) //odd number of address signals + { + addr->ES = 1; + addr->GTAI[cp_len - 1] = addr->GTAI[cp_len - 1] & 0x0F; + } + else + addr->ES = 2; + + buf[len++] = addr->NP * 16 + addr->ES; + addr->GTAI[len] = 0; + memcpy ( buf + len, addr->GTAI, cp_len ); + len += cp_len; + break; + case 2: //global title includes translation type only + buf[len++] = addr->TT; + /* added by Pierre, 2006-09-30 for the filler */ + cp_len = ( addr->len + 1 ) / 2; + if( addr->len & 1 ) //odd number of address signals + { + addr->GTAI[cp_len - 1] = addr->GTAI[cp_len - 1] & 0x0F; + } + /* above lines added by Pierre */ + + memcpy ( buf + len, addr->GTAI, ( addr->len + 1 ) / 2 ); + len += ( addr->len + 1 ) / 2; + break; + default: + break; + } + buf[0] = len - 1; + return len; +} + +int decode_addr_Ansi ( BYTE * buf, SCCP_ADDR * addr ) +{ + BYTE len, pos, nbyte; + BYTE RI_MASK = 0x40, DPC_MASK = 0x02, SSN_MASK = 0x01, GT_MASK = 0x3C; + BYTE DPCI; + BYTE spclen = 3; //ansi is always 24 bit,3 bytes + + len = buf[0] + 1; + addr->RI = ( buf[1] & RI_MASK ) >> 6; + addr->GTI = ( buf[1] & GT_MASK ) >> 2; + DPCI = ( buf[1] & DPC_MASK ) >> 1; + addr->SSN = ( buf[1] & SSN_MASK ); + pos = 2; + + if( addr->SSN ) + addr->SSN = buf[pos++]; + if( DPCI ) + { + /* memcpy((BYTE *)&addr->DPC, buf + pos, SCCP_Param.spclen[NetID]); + pos += SCCP_Param.spclen[NetID]; */ + memcpy ( ( BYTE * ) & addr->DPC, buf + pos, spclen ); + pos += spclen; + } + + switch ( addr->GTI ) + { + case 0: //no global title included + break; + case 1: //global title includes translation type, NP, EC + addr->TT = buf[pos++]; + addr->NP = buf[pos] / 16; + addr->ES = buf[pos++] % 16; + nbyte = len - pos; + addr->len = 2 * nbyte; + if( addr->ES == 1 ) + addr->len--; + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + case 2: //global title includes translation type only + addr->TT = buf[pos++]; + nbyte = len - pos; + addr->len = 2 * nbyte; + memcpy ( addr->GTAI, buf + pos, nbyte % ( MAX_DIGITS + 1 ) ); + break; + default: + break; + } + return len; +} diff --git a/omc/plat/sccp/src/sccp_param.c b/omc/plat/sccp/src/sccp_param.c new file mode 100644 index 0000000..3eb3bd5 --- /dev/null +++ b/omc/plat/sccp/src/sccp_param.c @@ -0,0 +1,705 @@ + +/**************************************************/ +/*Title: sccpparam.c */ +/*Descr: sccp parameter management */ +/*Author: Liang Hanxi */ +/*Create: 2002-5-7 */ + +/**************************************************/ +#include "./include/sccp.h" + +/*===========export================*/ +int sccp_loadparam ( ); +void sccp_saveparam ( ); +int sccp_setparam ( DWORD * oid, BYTE * pdata, WORD datalen ); +int sccp_getparam ( DWORD * oid, BYTE * pdata, BYTE * vartype ); + +/*===========import================*/ +extern int Str2Digits ( BYTE * pDigits, char *pStr, int DigitsLen ); +extern int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen ); +extern int Str2Array ( BYTE * pArray, char *str, int ArrayLen ); +extern int Bcd2Digits ( BYTE * pDigits, BYTE * pBcd, int maxLen ); +extern int BcdLen ( BYTE * pBcd, int maxLen ); +extern int ParseLine ( char *str, char ( *row )[128], int maxrow ); + +extern void spLogDebug ( DWORD mask, const char *fmt, ... ); + +/*===========private================*/ +static int SccpGetLocalIP ( ); +int ParseLocalNode ( char *str ); +static void ParseRouteInfo ( char *str ); +static void ParseRLSSN ( char *str ); +static void ParseGTTAttributeOMC ( char *str ); + +/* by simon at 23/9/26 */ +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern LOCAL_SSN LocalSSN[256]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; +extern int RelatedSPCNum; +extern RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; +extern GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern SCCP_Capture_Buf SCCPCapBuf; + +int GetMSISDNOfSSN ( BYTE ssn, BYTE * msisdn ) +{ + int len; + + len = Bcd2Digits ( msisdn, LocalSSN[ssn].msisdn, MAX_DIGITS ) % ( MAX_DIGITS + 1 ); +// memset ( msisdn + len, 0xFF, MAX_DIGITS - len ); + memset ( msisdn + len, 0xFF, 8 - len ); + return len; +} + +int sccp_GetSSNType ( BYTE ssn ) +{ + return mtp3_ansiFlag ( LocalSSN[ssn].NetID ); +} + +int sccp_loadparam ( ) +{ + FILE *fp; + int i, j; + char str[200] = "\0", *pChr, *pKey; + BYTE state = 0; + + SccpGetLocalIP ( ); + for ( i = 0; i < 256; i++ ) + { + LocalSSN[i].status[0] = LocalSSN[i].status[1] = 0; + LocalSSN[i].ip[0] = LocalSSN[i].ip[1] = 0xFFFFFFFF; + LocalSSN[i].local = 0; + LocalSSN[i].NetID = 0; + memset ( LocalSSN[i].msisdn, 0xFF, MAX_DIGITS ); + } + for ( i = 0; i < SCCP_ROUTE_NUM; i++) + { + memset ( &RouteList[i], 0, sizeof ( SCCP_ROUTE ) ); + memset ( RouteList[i].StartDigits, 0xFF, MAX_DIGITS * 2 ); + memset ( RouteList[i].ReplaceDigits, 0xFF, MAX_DIGITS ); + memset ( RouteList[i].acn_ver, 0x02, 48 ); + } + + RelatedSSNNum = 0; + + fp = fopen ( SCCP_CONF_FILE, "r" ); + if( fp == NULL ) + { + printf ( "GTT Initializing: Config File %s not found\n", SCCP_CONF_FILE ); + return -1; + } + + while ( fgets ( str, 200, fp ) != NULL ) + { + if( ( pChr = strchr ( str, '#' ) ) != NULL ) + pChr[0] = '\0'; + + if( ( pKey = strstr ( str, "[" ) ) != NULL ) + { + if( ( pKey = strstr ( str, "[Local Node]" ) ) != NULL ) + state = 1; + else if( ( pKey = strstr ( str, "[GTT_Table]" ) ) != NULL ) + state = 2; + else if( ( pKey = strstr ( str, "[RL_SSN]" ) ) != NULL ) + state = 3; + else if( ( pKey = strstr ( str, "[GTT_ATTRIBUTE]" ) ) != NULL ) + state = 4; + continue; + } + switch ( state ) + { + case 0: + continue; + case 1: + if( strlen ( str ) < 8 ) + continue; + ParseLocalNode ( str ); + break; + case 2: + if( strlen ( str ) < 15 ) + continue; + ParseRouteInfo ( str ); + break; + case 3: + if( strlen ( str ) < 3 ) + continue; + ParseRLSSN ( str ); + break; + case 4: + ParseGTTAttributeOMC ( str ); + break; + } + } + fclose ( fp ); + + //Load Related SPC===========> + RelatedSPCNum = 0; + for ( i = 0; i < RelatedSSNNum; i++ ) + { + for ( j = 0; j < RelatedSPCNum && j < SCCP_RLSPC_NUM; j++ ) + { + if( RelatedSPC[j].DPC == RelatedSSN[i].DPC && RelatedSPC[j].NetID == RelatedSSN[i].NetID ) + continue; + + RelatedSPC[RelatedSPCNum].DPC = RelatedSSN[i].DPC; + RelatedSPC[RelatedSPCNum].NetID = RelatedSSN[i].NetID; + RelatedSPC[RelatedSPCNum].status = 1; + RelatedSPCNum++; + } + } + + return 1; +} + +void sccp_saveparam ( ) +{ + struct in_addr addr; + SCCP_ROUTE *pRoute; + FILE *fp; + int i; + char str1[128], str2[64], host0[24], host1[24], *pCh = NULL; + char cNP[8], cTT[8]; + + if( ( fp = fopen ( SCCP_CONF_FILE, "w" ) ) == NULL ) + return; + + fprintf ( fp, "#SCCP Config file (R%dV%d_%02d)\r\n\r\n", SCCP_Param.version[0], SCCP_Param.version[1], SCCP_Param.version[2] ); + + fprintf ( fp, "[Local Node]\r\n\ +#ssn NetID msisdn ip0 ip1\r\n" ); + for ( i = 2; i < 256; i++ ) + { + if( LocalSSN[i].status[0] == 0 && LocalSSN[i].status[1] == 0 ) + continue; + + if( LocalSSN[i].ip[0] > 0 && LocalSSN[i].ip[0] != 0xFFFFFFFF ) + { + /* if (LocalSSN[i].ip[0] == SCCP_Param.ip) + { + sprintf(host0,"localhost"); + } + else */ + { + addr.s_addr = LocalSSN[i].ip[0]; + strcpy ( host0, inet_ntoa ( addr ) ); + } + } + else + strcpy ( host0, "-" ); + if( LocalSSN[i].ip[1] > 0 && LocalSSN[i].ip[1] != 0xFFFFFFFF ) + { + /* if (LocalSSN[i].ip[1] == SCCP_Param.ip) + { + sprintf(host1,"localhost"); + } + else */ + { + addr.s_addr = LocalSSN[i].ip[1]; + strcpy ( host1, inet_ntoa ( addr ) ); + } + } + else + strcpy ( host1, "-" ); + + Bcd2Str ( str1, LocalSSN[i].msisdn, LocalSSN[i].msisdn_len % MAX_DIGITS ); + if( ( pCh = strchr ( str1, 'F' ) ) != NULL ) + *pCh = 0; + + if( strlen ( str1 ) == 0 ) + strcpy ( str1, "-" ); + + fprintf ( fp, "%-4d %-5d %-15s %-15s %-15s\r\n", i, LocalSSN[i].NetID, str1, host0, host1 ); + } + + fprintf ( fp, "[GTT_Table]\r\n" "#No EN NP TT StartDigits EndDigits NI SPC SSN RI AI S E N Rep\r\n" ); + for ( i = 0; i < SCCP_ROUTE_NUM; i++ ) + { +//Commented by Roy Jiang for the disabled GTT entries +// if( RouteList[i].avail == 0 ) +// continue; + pRoute = &RouteList[i]; + if( pRoute->len > 0 ) + { + + Bcd2Str ( str1, pRoute->StartDigits, pRoute->len % MAX_DIGITS ); + if( ( pCh = strchr ( str1, 'F' ) ) != NULL ) + *pCh = 0; + Bcd2Str ( str2, pRoute->EndDigits, pRoute->len % MAX_DIGITS ); + if( ( pCh = strchr ( str2, 'F' ) ) != NULL ) + *pCh = 0; + } + else + { + strcpy ( str1, "-" ); + strcpy ( str2, "-" ); + } + + if( pRoute->NP == 0 ) + sprintf ( cNP, "-" ); + else + sprintf ( cNP, "%d", pRoute->NP ); + + if( pRoute->TT == 0 ) + sprintf ( cTT, "-" ); + else + sprintf ( cTT, "%d", pRoute->TT ); + + fprintf ( fp, "%-3d %d %s %s %-15s %-15s %d %02X%02X%02X %d %d %d ", i, RouteList[i].avail, cNP, cTT, str1, str2, pRoute->NetID, pRoute->DPC[0], pRoute->DPC[1], pRoute->DPC[2], pRoute->SSN, pRoute->RI, + pRoute->AI ); + if( pRoute->convert ) + { + Bcd2Str ( str1, pRoute->ReplaceDigits, pRoute->replace_len % MAX_DIGITS ); + if( ( pCh = strchr ( str1, 'F' ) ) != NULL ) + *pCh = 0; + fprintf ( fp, "%-1d% -1d %-1d %-15s\r\n", pRoute->ReplaceStart, pRoute->ReplaceEnd, pRoute->OutNP, str1 ); + } + else + fprintf ( fp, "\r\n" ); + } + + fprintf ( fp, "\r\n[RL_SSN]\r\n#NetID DPC SSN\r\n " ); + for ( i = 0; i < RelatedSSNNum; i++ ) + { + if( RelatedSSN[i].status == 0 ) + continue; + fprintf ( fp, "%-5d 0x%-6X %-d\r\n", RelatedSSN[i].NetID, RelatedSSN[i].DPC, RelatedSSN[i].SSN ); + } + + fprintf ( fp, "\r\n[GTT_ATTRIBUTE]\r\nIdx\r\n " ); + for ( i = 0; i < 256; i++ ) + { + if( RouteList[i].avail == 0 ) + continue; + Bcd2Str ( str1, GTTAttribute[i].attribute, SCCP_MAX_GTT_ATTRIBUTE * 2 ); + fprintf ( fp, "%-3d %s\r\n", i, str1 ); + } + fclose ( fp ); + +} + +int sccp_setparam ( DWORD * oid, BYTE * pdata, WORD datalen ) +{ + SCCP_ROUTE *pRoute; + RL_SSN *pRLSSN; + LOCAL_SSN *pLocalSSN; + LOCAL_SSN OldLocalSSN; + u_short instance, i; + + instance = oid[1]; + switch ( oid[0] ) + { + case 1: + spLogDebug ( SCCPDB_SNMP, "Set Local Node. ssn = %d", instance ); + if( instance >= 256 ) + return -1; + + pLocalSSN = &LocalSSN[instance]; + + /* copy the old important parameter */ + OldLocalSSN.NetID = pLocalSSN->NetID; + OldLocalSSN.ip[0] = pLocalSSN->ip[0]; + OldLocalSSN.ip[1] = pLocalSSN->ip[1]; + /* copy the old important parameter */ + + pLocalSSN->NetID = pdata[0]; + memcpy ( &pLocalSSN->msisdn, pdata + 1, MAX_DIGITS ); + memcpy ( &pLocalSSN->ip[0], pdata + MAX_DIGITS + 1, 8 ); + LocalSSN[instance].msisdn_len = ( BcdLen ( LocalSSN[instance].msisdn, MAX_DIGITS ) + 1 ) / 2; + + /* if old and new important parameter are same then return */ + if( OldLocalSSN.NetID == pLocalSSN->NetID && OldLocalSSN.ip[0] == pLocalSSN->ip[0] && OldLocalSSN.ip[1] == pLocalSSN->ip[1] ) + return 19; + /* if old and new important parameter are same then return */ + + LocalSSN[instance].local = 0; + LocalSSN[instance].status[0] = LocalSSN[instance].status[1] = 0; + if( LocalSSN[instance].ip[0] > 0 && LocalSSN[instance].ip[0] != 0xFFFFFFFF ) + { + if( LocalSSN[instance].ip[0] == SCCP_Param.ip ) + { + LocalSSN[instance].status[0] = 1; + LocalSSN[instance].local = 1; + } + else + { + LocalSSN[instance].status[0] = 3; + LocalSSN[instance].timeout[0] = T_hbrecv; + } + } + if( LocalSSN[instance].ip[1] > 0 && LocalSSN[instance].ip[1] != 0xFFFFFFFF ) + { + if( LocalSSN[instance].ip[1] == SCCP_Param.ip ) + { + LocalSSN[instance].status[1] = 1; + LocalSSN[instance].local = 2; + } + else + { + LocalSSN[instance].status[1] = 3; + LocalSSN[instance].timeout[1] = T_hbrecv; + } + } + + SCCP_Param.T_reset = 100; + return 19; + case 2: //GTT Table + spLogDebug ( SCCPDB_SNMP, "Set GTT Table.instance=%d", instance ); + if( instance >= SCCP_ROUTE_NUM ) + return -1; + + SCCP_Param.T_reset = 100; //2s + + pRoute = &RouteList[instance]; + memcpy ( pRoute, pdata, 43 ); + + pRoute->len = ( BcdLen ( pRoute->StartDigits, MAX_DIGITS ) + 1 ) / 2; + pRoute->replace_len = ( BcdLen ( pRoute->ReplaceDigits, MAX_DIGITS ) + 1 ) / 2; + if( pRoute->ReplaceStart >= 1 && pRoute->ReplaceStart <= pRoute->ReplaceEnd ) + pRoute->convert = 1; + else + pRoute->convert = 0; + SCCP_Param.T_reset = 100; + return 43; + case 3: + spLogDebug ( SCCPDB_SNMP, "Set related subsystem.instance=%d", instance ); + if( instance >= SCCP_RLSSN_NUM ) + return -1; + pRLSSN = &RelatedSSN[instance]; + if( pdata[0] > 0 ) + { + pRLSSN->status = 1; + pRLSSN->NetID = pdata[1]; + pRLSSN->DPC = pdata[2] * 0x10000 + pdata[3] * 0x100 + pdata[4]; + pRLSSN->SSN = pdata[5]; + + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( RelatedSPC[i].DPC == pRLSSN->DPC && RelatedSPC[i].NetID == pRLSSN->NetID ) + continue; + + RelatedSPC[RelatedSPCNum].DPC = pRLSSN->DPC; + RelatedSPC[RelatedSPCNum].NetID = pRLSSN->NetID; + RelatedSPC[RelatedSPCNum].status = 1; + RelatedSPCNum++; + } + + if( instance + 1 > RelatedSSNNum ) + RelatedSSNNum = instance + 1; + } + else + { + pRLSSN->status = 0; + if( instance == RelatedSSNNum - 1 ) + while ( RelatedSSN[RelatedSSNNum - 1].status == 0 && RelatedSSNNum > 0 ) + RelatedSSNNum--; + } + return 6; + case 4: //GTT Attribute for omc + if( instance >= SCCP_ROUTE_NUM ) + return -1; + memcpy ( >TAttribute[instance], pdata, SCCP_MAX_GTT_ATTRIBUTE ); + return SCCP_MAX_GTT_ATTRIBUTE; + default: + break; + } + return -1; +} + +int sccp_getparam ( DWORD * oid, BYTE * pdata, BYTE * vartype ) +{ + SCCP_ROUTE *pRoute; + RL_SSN *pRLSSN; + LOCAL_SSN *pLocalSSN; + int instance; + + instance = oid[1]; + switch ( oid[0] ) + { + case 1: + spLogDebug ( SCCPDB_SNMP, "get Local Node.ssn=%ld\n", instance ); + if( instance >= 256 ) + return -1; + pLocalSSN = &LocalSSN[instance]; + pdata[0] = pLocalSSN->NetID; + memcpy ( pdata + 1, &pLocalSSN->msisdn, MAX_DIGITS ); + memcpy ( pdata + MAX_DIGITS + 1, &pLocalSSN->ip[0], 8 ); + *vartype = 4; + return 19; + case 2: //GTT Table + spLogDebug ( SCCPDB_SNMP, "get gtt table.instance=%ld\n", instance ); + if( instance >= SCCP_ROUTE_NUM ) + return -1; + *vartype = 4; + + pRoute = &RouteList[instance]; + memcpy ( pdata, pRoute, 43 ); + return 43; + case 3: + spLogDebug ( SCCPDB_SNMP, "Get related subsystem.instance=%d", instance ); + if( instance > RelatedSSNNum ) + return -1; + pRLSSN = &RelatedSSN[instance]; + *vartype = 4; + if( pRLSSN->status == 0 ) + return -1; + pdata[0] = 1; + pdata[1] = pRLSSN->NetID; + pdata[2] = ( pRLSSN->DPC >> 16 ) & 0xFF; + pdata[3] = ( pRLSSN->DPC >> 8 ) & 0xFF; + pdata[4] = pRLSSN->DPC & 0xFF; + pdata[5] = pRLSSN->SSN; + return 6; + case 4: //GTT Attribute + spLogDebug ( SCCPDB_SNMP, "get gtt attribute table.instance=%ld\n", instance ); + if( instance >= SCCP_ROUTE_NUM ) + return -1; + *vartype = 4; + + memcpy ( pdata, >TAttribute[instance], SCCP_MAX_GTT_ATTRIBUTE ); + return SCCP_MAX_GTT_ATTRIBUTE; + default: + break; + } + return -1; +} + +/*+++++++++++++++++++++++++++++++++++++++ */ +//Private function========================> +/*+++++++++++++++++++++++++++++++++++++++ */ +int SccpGetLocalIP ( ) +{ + struct hostent *hptr; + struct in_addr *inaddr; + char hostname[40] = "\0"; + + if( ( gethostname ( hostname, -1 ) ) != 0 ) + return -1; + + if( ( hptr = gethostbyname ( hostname ) ) == NULL ) + return -1; + + if( hptr->h_addr_list[0] != NULL ) + { + inaddr = ( struct in_addr * ) hptr->h_addr_list[0]; + SCCP_Param.ip = inaddr->s_addr; + } + return 1; +} + +int ParseLocalNode ( char *str ) +{ + char info[5][128]; + int rtn; + BYTE ssn; + + rtn = ParseLine ( str, info, 5 ); + if( rtn < 3 ) + { + spLogDebug ( SCCPDB_ERR, "<001>Invalid line in Local_Node Table, field count = %d", rtn ); + return 0; + } + + ssn = atoi ( info[0] ); + LocalSSN[ssn].NetID = atoi ( info[1] ) % 4; + LocalSSN[ssn].msisdn_len = Str2Bcd ( LocalSSN[ssn].msisdn, info[2], MAX_DIGITS ); + + if( rtn < 4 || strstr ( info[3], "-" ) != NULL ) + LocalSSN[ssn].ip[0] = 0xFFFFFFFF; + /* else if (strstr(info[3],"localhost") != NULL) + LocalSSN[ssn].ip[0] = SCCP_Param.ip; */ + else + LocalSSN[ssn].ip[0] = inet_addr ( info[3] ); + + if( rtn < 5 || strstr ( info[4], "-" ) != NULL ) + LocalSSN[ssn].ip[1] = 0xFFFFFFFF; + /* else if (strstr(info[4],"localhost") != NULL) + LocalSSN[ssn].ip[1] = SCCP_Param.ip; */ + else + LocalSSN[ssn].ip[1] = inet_addr ( info[4] ); + + /* if (rtn >= 5) + LocalSSN[ssn].ANSIFlag = atoi(info[5]); */ + + LocalSSN[ssn].local = 0; + LocalSSN[ssn].status[0] = LocalSSN[ssn].status[1] = 0; + if( LocalSSN[ssn].ip[0] > 0 && LocalSSN[ssn].ip[0] != 0xFFFFFFFF ) + { + if( LocalSSN[ssn].ip[0] == SCCP_Param.ip ) + { + LocalSSN[ssn].status[0] = 1; + LocalSSN[ssn].local = 1; + } + else + { + LocalSSN[ssn].status[0] = 3; + LocalSSN[ssn].timeout[0] = T_hbrecv; + } + } + + if( LocalSSN[ssn].ip[1] > 0 && LocalSSN[ssn].ip[1] != 0xFFFFFFFF ) + { + if( LocalSSN[ssn].ip[1] == SCCP_Param.ip ) + { + LocalSSN[ssn].status[1] = 1; + LocalSSN[ssn].local = 2; + } + else + { + LocalSSN[ssn].status[1] = 3; + LocalSSN[ssn].timeout[1] = T_hbrecv; + } + } + else + { + LocalSSN[ssn].status[1] = 0; + } + + return 1; +} + +void ParseRouteInfo ( char *str ) +{ + int spc; + char info[15][128]; + u_short index, rtn; + BYTE offset = 0; + BYTE ConfVer; //configure file version + + SCCP_ROUTE *pRoute; + + rtn = ParseLine ( str, info, 15 ); + if( rtn < 8 ) + { + spLogDebug ( SCCPDB_ERR, "<002>Invalid line in GTT Table, field count = %d", rtn ); + return; + } + + if ( (rtn == 11 ) || ( rtn == 15 ) ) + ConfVer = 3; //has EN + else if( ( rtn == 10 ) || ( rtn == 14 ) ) + ConfVer = 2; //has TT and AI + else if( ( rtn == 9 ) || ( rtn == 13 ) ) + ConfVer = 1; //has AI + else + ConfVer = 0; //without TT and AI + + index = atoi ( info[offset++] ); //0 + if( index >= SCCP_ROUTE_NUM ) + { + spLogDebug ( SCCPDB_ERR, "<003>invalid index in GTT Table, index = %d", index ); + return; + } + pRoute = &RouteList[index]; + if ( ConfVer == 3 ) + pRoute->avail = atoi ( info[offset++] ); //1 + else + pRoute->avail = 1; + + if( strstr ( info[offset], "-" ) != NULL ) //2 + pRoute->NP = 0; + else + pRoute->NP = atoi ( info[offset] ); //2 + offset++; + if( ConfVer >= 2 ) + { + if( strstr ( info[offset], "-" ) != NULL ) //3 + pRoute->TT = 0; + else + pRoute->TT = atoi ( info[offset] ); //3 + offset++; + } + else + pRoute->TT = 0; + + memset ( pRoute->StartDigits, 0xFF, MAX_DIGITS * 2 ); + Str2Bcd ( pRoute->StartDigits, info[offset++], MAX_DIGITS ); //4 + pRoute->len = Str2Bcd ( pRoute->EndDigits, info[offset++], MAX_DIGITS ); //5 + + pRoute->NetID = atoi ( info[offset++] ) % 4; //6 + spc = strtol ( info[offset++], NULL, 16 ); //7 + pRoute->DPC[0] = spc >> 16; + pRoute->DPC[1] = spc >> 8; + pRoute->DPC[2] = spc; + + pRoute->SSN = atoi ( info[offset++] ); //8 + pRoute->RI = atoi ( info[offset++] ); //9 + + /* daniel */ + if( ConfVer > 0 ) + pRoute->AI = atoi ( info[offset++] ) & 7; //10 + else + pRoute->AI = 7; + + if( rtn < 13 ) + { + pRoute->convert = 0; + return; + } + + /* daniel */ + pRoute->ReplaceStart = atoi ( info[offset++] ); //11 + pRoute->ReplaceEnd = atoi ( info[offset++] ); //12 + pRoute->OutNP = atoi ( info[offset++] ); //13 + if( pRoute->ReplaceStart < 1 || pRoute->ReplaceStart > pRoute->ReplaceEnd ) + pRoute->convert = 0; + else + { + memset ( pRoute->ReplaceDigits, 0xFF, MAX_DIGITS ); + pRoute->replace_len = Str2Bcd ( pRoute->ReplaceDigits, info[offset++], MAX_DIGITS ); //14 + pRoute->convert = 1; + } + + return; +} + +void ParseRLSSN ( char *str ) +{ + RL_SSN *pRLSSN = NULL; + char info[3][128]; + int rtn; + BYTE NetID; + int spc; + + rtn = ParseLine ( str, info, 3 ); + if( rtn < 3 ) + { + spLogDebug ( SCCPDB_ERR, "<004>Invalid line in RL_SSN Table, field count = %d", rtn ); + return; + } + + pRLSSN = &RelatedSSN[RelatedSSNNum]; + + pRLSSN->status = 0; + NetID = pRLSSN->NetID = atoi ( info[0] ) % 4; + spc = pRLSSN->DPC = strtol ( info[1], NULL, 16 ); + pRLSSN->SSN = atoi ( info[2] ); + pRLSSN->SST = 1; + pRLSSN->timeout = T_sst; + if( SCCP_Param.spc[NetID] == spc ) + return; + pRLSSN->status = ST_Disable; + RelatedSSNNum = ( RelatedSSNNum + 1 ) % SCCP_RLSSN_NUM; +} + +static void ParseGTTAttributeOMC ( char *str ) +{ + GTTATT_OMC *pGTTAtt = NULL; + char info[3][128]; + int rtn; + BYTE index; + + rtn = ParseLine ( str, info, 3 ); + if( rtn < 2 ) + { + spLogDebug ( SCCPDB_ERR, "<004>Invalid line in GTT Attribute Table, field count = %d", rtn ); + return; + } + index = atoi ( info[0] ); + pGTTAtt = >TAttribute[index]; + Str2Bcd ( pGTTAtt->attribute, info[1], SCCP_MAX_GTT_ATTRIBUTE * 2 ); +} diff --git a/omc/plat/sccp/src/sclc.c b/omc/plat/sccp/src/sclc.c new file mode 100644 index 0000000..aca59b3 --- /dev/null +++ b/omc/plat/sccp/src/sclc.c @@ -0,0 +1,615 @@ + +/*******************************************/ +/*Title: sclc.c */ +/*Descr: SCCP Connectionless Control */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ + +/*******************************************/ + +#include "./include/sccp.h" + +/*===========export================*/ +int scrc2sclc ( Intra_Msg * pIntraMsg ); +int sclc_rf ( Intra_Msg * pIntraMsg ); +/* by simon at 23/9/26 */ +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern LOCAL_SSN LocalSSN[256]; +SCCP_SegMsgBuf sccp_segmsgbuf[MAX_SEGMSG_BUF]; +extern struct sccp_msg_statistic +{ + DWORD msg_mtp_scoc; + DWORD msg_scoc_up; + DWORD mnp_send; + DWORD mnp_route; +} sccpmsg_st; +extern SCCP_Capture_Buf SCCPCapBuf; +extern LOCAL_SSN LocalSSN[256]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; +extern u8 MNP_Flag[2]; + +/*===========import================*/ +extern int sclc2scmg ( Intra_Msg * intramsg ); //scmg.c +extern int scrc_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); //scrc.c +extern int scrc_mnp_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); //scrc.c +extern int send_msg ( Intra_Msg * pIntraMsg ); //scrc.c +extern void spLogDebug ( DWORD mask, const char *fmt, ... ); +extern void spShowBCD(DWORD mask, BYTE *buf, int len); +extern void spShowMsg(DWORD mask, const char *pDesc, Intra_Msg *pIntraMsg); +extern void spLog ( char *info ); + +static SCLC_BUF SCLC_OutBuf; +static SCLC_BUF SCLC_InBuf[MAX_SCLC_BUF]; + +/* buffer changed from 3 to 4, Pierre , 11-07 */ + +int RecvXUDTMsg ( Intra_Msg * pIntraMsg, BYTE nbuf ); +int CheckSegUnID ( Intra_Msg * pIntraMsg ); +int RsmRegMsg ( SCLC_MSG * pmsg, SCCP_SegMsgBuf * pSegMsgbuf, Intra_Msg * pIntraMsg ); +extern void spLogSeg ( SCCP_SegMsgBuf * pSegMsgbuf ); + +int scrc2sclc ( Intra_Msg * pIntraMsg ) +{ + SCLC_MSG *pmsg; + short writesub, readsub; + BYTE nbuf; + + SccpCsta[SccpCstaInd].utilization[4 - 3]++; + if( pIntraMsg->msgMNP ) + { + nbuf = 1; + sccpmsg_st.mnp_route++; + if(pIntraMsg->msgsource == FROM_MTP) + { + pIntraMsg->SLS = LocalSSN[pIntraMsg->CDA.SSN].local+1; + } + } /* added by pierre for MNP , 2005-11-07 */ + else + { + nbuf = LocalSSN[pIntraMsg->CDA.SSN].nbuf % 4; + } + + switch ( pIntraMsg->msgtype ) + { + case UDT_MSG: + break; + case XUDT_MSG: + switch ( RecvXUDTMsg ( pIntraMsg, nbuf ) ) + { + case 0: + break; + case 1: + break; + case 2: + break; + case 3: + break; + + } + return 0; + case LUDT_MSG: + spLogDebug ( SCCPDB_UDT | SCCPDB_ERR, "<005>LUDT/XUDT message is not supported" ); + return 0; + case UDTS_MSG: + break; + case XUDTS_MSG: + case LUDTS_MSG: + spLogDebug ( SCCPDB_UDT | SCCPDB_ERR, "<005>LUDTS/XUDTS message is not supported" ); + return 0; + } + if( pIntraMsg->CDA.SSN == SSN_SCMG ) + return sclc2scmg ( pIntraMsg ); + else + { + writesub = SCLC_InBuf[nbuf].writesub; + readsub = SCLC_InBuf[nbuf].readsub; + pmsg = &SCLC_InBuf[nbuf].msglist[writesub]; + + pmsg->msglen = pIntraMsg->msglen % SCCP_MSG_MAXLEN; + memcpy ( pmsg->msg, pIntraMsg->data, pmsg->msglen ); + memcpy ( &( pmsg->src_addr ), &( pIntraMsg->CGA ), sizeof ( SCCP_ADDR ) ); + memcpy ( &( pmsg->dst_addr ), &( pIntraMsg->CDA ), sizeof ( SCCP_ADDR ) ); + pmsg->sls = pIntraMsg->SLS; + + if( ( SCLC_InBuf[nbuf].writesub + 1 ) == SCLC_InBuf[nbuf].readsub ) + spShowMsg ( SCCPDB_UDT, "USER <== SCCP: buf overflow!!!!!!!", pIntraMsg ); + + SCLC_InBuf[nbuf].writesub = ( writesub + 1 ) % SS_MSG_NUM; + if( SCLC_InBuf[nbuf].writesub == readsub ) + SCLC_InBuf[nbuf].readsub = ( readsub + 1 ) % SS_MSG_NUM; + + if (pIntraMsg->msgtype == UDTS_MSG) + { + pmsg->primitive = N_NOTICE_IND; + spShowMsg ( SCCPDB_UDT, "USER <== SCCP: N-NOTICE", pIntraMsg ); + } + else + { + pmsg->primitive = N_UNITDATA_IND; + spShowMsg ( SCCPDB_UDT, "USER <== SCCP: UDT Message", pIntraMsg ); + } + } + return 1; +} + +int sclc_rf ( Intra_Msg * pIntraMsg ) +{ + SCCP_ADDR swapaddr; + + spShowMsg ( SCCPDB_UDT | SCCPDB_ERR, "<006>Route Failure", pIntraMsg ); + switch ( pIntraMsg->msgtype ) + { + case UDT_MSG: + if( pIntraMsg->msgsource == FROM_MTP || pIntraMsg->msgsource == FROM_SCLC ) + { + memcpy ( &swapaddr, &( pIntraMsg->CDA ), sizeof ( SCCP_ADDR ) ); + memcpy ( &( pIntraMsg->CDA ), &( pIntraMsg->CGA ), sizeof ( SCCP_ADDR ) ); + memcpy ( &( pIntraMsg->CGA ), &swapaddr, sizeof ( SCCP_ADDR ) ); + pIntraMsg->CDA.ip = 0xFFFFFFFF; + if( pIntraMsg->CDA.RI == RI_SSN ) + { + if( pIntraMsg->CDA.DPC == 0 ) + pIntraMsg->CDA.DPC = pIntraMsg->CGA.DPC; + } + pIntraMsg->msgsource = FROM_SCLC; + pIntraMsg->msgtype = UDTS_MSG; + return scrc_route ( pIntraMsg, 0 ); + } + break; + case XUDT_MSG: + case LUDT_MSG: + //unsupported now + break; + case UDTS_MSG: + break; + case XUDTS_MSG: + case LUDTS_MSG: + //unsupported now + break; + } + return -1; +} + +int scmg2sclc ( Intra_Msg * pIntraMsg ) +{ + return scrc_route ( pIntraMsg, 0 ); +} + +/******************************************************************/ + +/*================== User Interface-----> ================*/ + +/******************************************************************/ +int sclc_send ( SCLC_MSG * pmsg ) +{ + if( pmsg->msglen > 256 ) + { + spLogDebug ( SCCPDB_ERR | SCCPDB_UDT, "<007>User ==> SCCP: Message's Length exceed 256" ); + spShowBCD ( SCCPDB_ERR, pmsg->msg, pmsg->msglen % 256 ); + return 0; + } + SccpCsta[SccpCstaInd].utilization[0]++; + + memcpy ( &SCLC_OutBuf.msglist[SCLC_OutBuf.writesub], pmsg, sizeof ( SCLC_MSG ) ); + SCLC_OutBuf.writesub = ( SCLC_OutBuf.writesub + 1 ) % SS_MSG_NUM; + if( SCLC_OutBuf.writesub == SCLC_OutBuf.readsub ) + { + spLogDebug ( SCCPDB_ERR | SCCPDB_UDT, "<008>SCLC Out Buffer Overflow" ); + SCLC_OutBuf.readsub = ( SCLC_OutBuf.readsub + 1 ) % SS_MSG_NUM; + } + + return 1; +} + +int sclc_receive ( SCLC_MSG * pmsg, BYTE usertype ) +{ + short readsub; + + usertype %= MAX_SCLC_BUF; /* revised by pierre */ + readsub = SCLC_InBuf[usertype].readsub % SS_MSG_NUM; + if( SCLC_InBuf[usertype].writesub == readsub ) + return 0; + + memcpy ( pmsg, &SCLC_InBuf[usertype].msglist[readsub], sizeof ( SCLC_MSG ) ); + SCLC_InBuf[usertype].readsub = ( readsub + 1 ) % SS_MSG_NUM; + + return 1; +} + +void sclc_timer ( ) +{ + Intra_Msg outmsg; + SCLC_MSG *pmsg; + int loop = 128; + short readsub; + + int SegMsgIndex; + + for ( SegMsgIndex = 0; SegMsgIndex < MAX_SEGMSG_BUF; SegMsgIndex++ ) + { + if( sccp_segmsgbuf[SegMsgIndex].SegMsgTimer && sccp_segmsgbuf[SegMsgIndex].SegMsgTimer++ > MAX_SEGMSG_TIMER ) + { + spLogDebug ( SCCPDB_ERR, "SCCP XUDT Msg Timer Out. " ); + spLogSeg ( &sccp_segmsgbuf[SegMsgIndex] ); + memset ( &sccp_segmsgbuf[SegMsgIndex], 0, sizeof ( SCCP_SegMsgBuf ) ); + } + } + + while ( loop-- > 0 ) + { + if( SCLC_OutBuf.readsub == SCLC_OutBuf.writesub ) + return; + + readsub = SCLC_OutBuf.readsub % SS_MSG_NUM; + pmsg = &SCLC_OutBuf.msglist[readsub]; + SCLC_OutBuf.readsub = ( readsub + 1 ) % SS_MSG_NUM; + + outmsg.msgsource = FROM_SCLC; + outmsg.msgtype = UDT_MSG; + outmsg.msgclass = 0; + outmsg.SLS = pmsg->sls; + outmsg.sequenceFlag = pmsg->sequence_control; + + memcpy ( &( outmsg.CDA ), &pmsg->dst_addr, sizeof ( SCCP_ADDR ) ); + memcpy ( &( outmsg.CGA ), &pmsg->src_addr, sizeof ( SCCP_ADDR ) ); + + outmsg.NetID = outmsg.CGA.NetID = outmsg.CDA.NetID; + // outmsg.CDA.TT = 0; + outmsg.CDA.ip = 0xFFFFFFFF; + outmsg.msglen = pmsg->msglen % 256; + memcpy ( outmsg.data, pmsg->msg, pmsg->msglen % 256 ); + + if( MNP_Flag[0] != 0 && outmsg.CDA.NP == 1 && outmsg.CDA.SSN == 6 && pmsg->msg[0] == 0x62 ) + { + /* MNP supported */ + if( MNP_Flag[1] != 2 ) /* Direct routing */ + { + if( MNP_Flag[0] == 1 && outmsg.CDA.TT != 0 ) + { + /* IN_based call related message */ + spLogDebug ( SCCPDB_UDT, "User ==> SCCP: IN_based MNP and Call_related message, routed to HLR" ); + //spShowMsg(SCCPDB_USER, "User ==> SCCP: UDT Message", &outmsg); + //scrc_route(&outmsg); + } + else if( outmsg.CGA.SSN != 10 ) + { + spShowMsg ( SCCPDB_USER, "User ==> SCCP ==> MNP_SRF : UDT Message", &outmsg ); + + outmsg.msgMNP = 1; + scrc2sclc ( &outmsg ); + continue; + } + } + } + + spShowMsg ( SCCPDB_USER, "User ==> SCCP: UDT Message", &outmsg ); + scrc_route ( &outmsg, 0 ); + } + return; +} + +/* added by Pierre for MNP, 2005-11-07 */ +int sclc_mnp_send ( SCLC_MSG * pmsg ) +{ + Intra_Msg outmsg; + + if( pmsg->msglen > 256 ) + { + spLogDebug ( SCCPDB_ERR | SCCPDB_UDT, "<007>User ==> SCCP: Message's Length exceed 256" ); + spShowBCD ( SCCPDB_ERR, pmsg->msg, pmsg->msglen % 256 ); + return 0; + } + SccpCsta[SccpCstaInd].utilization[0]++; + + sccpmsg_st.mnp_send++; + outmsg.msgsource = FROM_SCLC; + outmsg.msgtype = UDT_MSG; + outmsg.msgclass = 0; + outmsg.SLS = pmsg->sls; + + memcpy ( &( outmsg.CDA ), &pmsg->dst_addr, sizeof ( SCCP_ADDR ) ); + memcpy ( &( outmsg.CGA ), &pmsg->src_addr, sizeof ( SCCP_ADDR ) ); + + outmsg.NetID = outmsg.CGA.NetID = outmsg.CDA.NetID; + //outmsg.CDA.TT = 0; + outmsg.CDA.ip = 0xFFFFFFFF; + outmsg.msglen = pmsg->msglen % 256; + memcpy ( outmsg.data, pmsg->msg, pmsg->msglen % 256 ); + + spShowMsg ( SCCPDB_USER, "User ==> SCCP: UDT Message", &outmsg ); + + return scrc_mnp_route ( &outmsg, 0 ); + +} + +//add for UDT SegmentingMsg to XUDT --lw 2007/03/20 +int SegmentingMsg ( Intra_Msg * pIntraMsg ) +{ + Intra_Msg pIntraMsgSeg1, pIntraMsgSeg2; + int ret1, ret2; + BYTE sSegLR[4]; + + ret1 = ret2 = 0; + + memcpy ( &pIntraMsgSeg1, pIntraMsg, sizeof ( Intra_Msg ) ); + memcpy ( &pIntraMsgSeg2, pIntraMsg, sizeof ( Intra_Msg ) ); + + pIntraMsgSeg1.msglen = pIntraMsg->msglen / 2; + pIntraMsgSeg2.msglen = pIntraMsg->msglen - pIntraMsgSeg1.msglen; + + memset ( &pIntraMsgSeg1.data[pIntraMsgSeg1.msglen], 0, SCCP_MSG_MAXLEN - pIntraMsgSeg1.msglen ); + memcpy ( &pIntraMsgSeg2.data[0], &pIntraMsg->data[pIntraMsgSeg1.msglen], pIntraMsgSeg2.msglen ); + memset ( &pIntraMsgSeg2.data[pIntraMsgSeg2.msglen], 0, SCCP_MSG_MAXLEN - pIntraMsgSeg2.msglen ); + + pIntraMsgSeg1.msgtype = pIntraMsgSeg2.msgtype = XUDT_MSG; + pIntraMsgSeg1.SegPresent = pIntraMsgSeg2.SegPresent = 1; + pIntraMsgSeg1.Segmnt.CBit = pIntraMsgSeg2.Segmnt.CBit = 1; //sequence + pIntraMsgSeg1.Segmnt.FBit = 1; + pIntraMsgSeg2.Segmnt.FBit = 0; + pIntraMsgSeg1.Segmnt.RSBits = 1; + pIntraMsgSeg2.Segmnt.RSBits = 0; + pIntraMsgSeg1.Hop = pIntraMsgSeg1.Hop = 0; + sSegLR[0] = ( SCCP_Param.ip >> 16 ) & 0x0001; //plant number + sSegLR[1] = pIntraMsg->SLS; + sSegLR[2] = SCCPCapBuf.watch_dog[128]++; + memcpy ( pIntraMsgSeg1.Segmnt.SegLR, sSegLR, SEG_RS_LEN ); + memcpy ( pIntraMsgSeg2.Segmnt.SegLR, sSegLR, SEG_RS_LEN ); + + spLogDebug ( SCCPDB_UDT, "SCCP =>SCCP_RegProc=> SCCP : Length [%d Bytes] [%d Bytes]\r\n", pIntraMsgSeg1.msglen, pIntraMsgSeg2.msglen ); + + ret1 = send_msg ( &pIntraMsgSeg1 ); + + ret2 = send_msg ( &pIntraMsgSeg2 ); + + return ( ret1 > 0 && ret2 > 0 ); +} + +int RecvXUDTMsg ( Intra_Msg * pIntraMsg, BYTE nbuf ) +{ + SCLC_MSG *pmsg; + short writesub, readsub; + int SegMsgIndex; + + if( !pIntraMsg->SegPresent ) //Not Include Segmentation Paramenters + { + return -1; + } + + if( pIntraMsg->Segmnt.FBit == 1 && pIntraMsg->Segmnt.RSBits == 0 ) //Single Segmetaion + { + return -1; + } + + SegMsgIndex = CheckSegUnID ( pIntraMsg ); + + if( SegMsgIndex == MAX_SEGMSG_BUF + 1 ) //check CGA SLR MTP3 routing lable is idle + { + return 0; + } + + else if( SegMsgIndex == MAX_SEGMSG_BUF ) //first Segmentation + { + if( pIntraMsg->Segmnt.FBit != 1 ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Recv new XUDT Msg but the Fbit is not 1." ); + return 0; + } + + for ( SegMsgIndex = 0; SegMsgIndex < MAX_SEGMSG_BUF; SegMsgIndex++ ) + { + if( sccp_segmsgbuf[SegMsgIndex].MsgState == SEGSTREAM_IDLE ) + { + int SegBlockIndex; + SCCP_SegStream *pSegStream; + SCCP_SegMsgBuf *pSegMsgbuf = &sccp_segmsgbuf[SegMsgIndex]; + + pSegMsgbuf->MsgClass = pIntraMsg->Segmnt.CBit; + pSegMsgbuf->MsgTotal = pIntraMsg->Segmnt.RSBits + 1; + pSegMsgbuf->RSE = pIntraMsg->Segmnt.RSBits - 1; + + pSegMsgbuf->SegID.DPC = pIntraMsg->DPC; + pSegMsgbuf->SegID.OPC = pIntraMsg->OPC; + pSegMsgbuf->SegID.SLS = pIntraMsg->SLS; + memcpy ( &pSegMsgbuf->SegID.CGA, &pIntraMsg->CGA, sizeof ( SCCP_ADDR ) ); + memcpy ( &pSegMsgbuf->SegID.SegLR, &pIntraMsg->Segmnt.SegLR, SEG_RS_LEN ); + + SegBlockIndex = pSegMsgbuf->MsgTotal - ( pIntraMsg->Segmnt.RSBits + 1 ); + pSegStream = &pSegMsgbuf->SegStream[SegBlockIndex]; + pSegStream->SegDataLen = pIntraMsg->msglen; + memcpy ( &pSegStream->SegDataBlock, &pIntraMsg->data, pIntraMsg->msglen ); + + pSegMsgbuf->SegMsgTimer = 1; + pSegMsgbuf->MsgState = SEGSTREAM_BUSY; + + return 1; + } + } + + if( SegMsgIndex == MAX_SEGMSG_BUF ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Recv new XUDT but SCCP SegMsg buf is not enough" ); + return 0; + } + } + else //not first Segmentation + { + int SegBlockIndex; + int i, j, linemax; + char info[2560 * 3 + 512], temp_str[128]; + SCCP_SegStream *pSegStream; + SCCP_SegMsgBuf *pSegMsgbuf = &sccp_segmsgbuf[SegMsgIndex]; + + if( pIntraMsg->Segmnt.RSBits != pSegMsgbuf->RSE ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Recv unexpect RS XUDT Msg , discard it" ); + return 0; + } + + if( pIntraMsg->Segmnt.FBit == 1 ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Recv XUDT Msg dupulicate first segment. discard it" ); + return 0; + } + + SegBlockIndex = pSegMsgbuf->MsgTotal - ( pIntraMsg->Segmnt.RSBits + 1 ); + pSegStream = &pSegMsgbuf->SegStream[SegBlockIndex]; + + if( pSegStream->SegDataLen ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Recv XUDT Msg dupulicate segment, discard it[RS :%d]", pIntraMsg->Segmnt.RSBits ); + return 0; + } + pSegStream->SegDataLen = pIntraMsg->msglen; + memcpy ( &pSegStream->SegDataBlock, &pIntraMsg->data, pIntraMsg->msglen ); + + if( pSegMsgbuf->RSE ) + { + pSegMsgbuf->RSE--; + return 1; + } + + //last segment + pSegMsgbuf->SegMsgTimer = 0; + writesub = SCLC_InBuf[nbuf].writesub; + readsub = SCLC_InBuf[nbuf].readsub; + pmsg = &SCLC_InBuf[nbuf].msglist[writesub]; + + if( !RsmRegMsg ( pmsg, pSegMsgbuf, pIntraMsg ) ) + { + return 0; + } + + if( ( SCLC_InBuf[nbuf].writesub + 1 ) == SCLC_InBuf[nbuf].readsub ) + spShowMsg ( SCCPDB_UDT, "USER <== SCCP: buf overflow!!!!!!!", pIntraMsg ); + + SCLC_InBuf[nbuf].writesub = ( writesub + 1 ) % SS_MSG_NUM; + if( SCLC_InBuf[nbuf].writesub == readsub ) + SCLC_InBuf[nbuf].readsub = ( readsub + 1 ) % SS_MSG_NUM; + + spLog ( "\r\n\r\nUser <== SCCP_RegProc. XUDT Message" ); + spLogSeg ( pSegMsgbuf ); + info[0] = '\0'; + sprintf ( temp_str, "Segmentaion Length info: \r\n" ); + strcat ( info, temp_str ); + for ( i = 0; i < pSegMsgbuf->MsgTotal; i++ ) + { + sprintf ( temp_str, "[%02d]:%d ", i, pSegMsgbuf->SegStream[i].SegDataLen ); + strcat ( info, temp_str ); + if( i == 7 ) + { + strcat ( info, "\r\n" ); + } + } + spLog ( info ); + + memset ( info, 0, 2560 * 3 + 512 ); + i = j = linemax = 0; + while ( i * 16 < pmsg->msglen ) + { + if( ( linemax = pmsg->msglen - 16 * i ) > 16 ) + linemax = 16; + for ( j = 0; j < linemax; j++ ) + { + sprintf ( info + 3 * j + ( j > 7 ? 1 : 0 ), "%02X ", pmsg->msg[16 * i + j] ); + if( j == 7 ) + { + sprintf ( info + 3 * 8, " " ); + } + } + spLog ( info ); + i++; + } + + memset ( pSegMsgbuf, 0, sizeof ( SCCP_SegMsgBuf ) ); + return 1; + } + + return 0; +} + +int CheckSegUnID ( Intra_Msg * pIntraMsg ) +{ + int SegMsgIndex, nCheckFlag; + SCCP_SegUnID *pSegId; + + nCheckFlag = 0; + for ( SegMsgIndex = 0; SegMsgIndex < MAX_SEGMSG_BUF; SegMsgIndex++ ) + { + pSegId = &sccp_segmsgbuf[SegMsgIndex].SegID; + if( memcmp ( &pSegId->SegLR, &pIntraMsg->Segmnt.SegLR, SEG_RS_LEN ) ) + { + continue; + } + + if( pSegId->DPC != pIntraMsg->DPC ) //have routed , equal of course + { + spLogDebug ( SCCPDB_ERR, "SCCP XUDT Msg check MTP3 routing lable fail , DPC is not matched!" ); + nCheckFlag = 1;; + } + if( pSegId->OPC != pIntraMsg->OPC ) + { + spLogDebug ( SCCPDB_ERR, "SCCP XUDT Msg check MTP3 routing lable fail , OPC is not matched!" ); + nCheckFlag = 1; + } + if( pSegId->SLS != pIntraMsg->SLS ) + { + spLogDebug ( SCCPDB_ERR, "SCCP XUDT Msg check MTP3 routing lable fail , SLS is not matched!" ); + nCheckFlag = 1; + } + if( memcmp ( &pSegId->CGA, &pIntraMsg->CGA, sizeof ( SCCP_ADDR ) ) ) + { + spLogDebug ( SCCPDB_ERR, "SCCP XUDT Msg check MTP3 routing lable fail , CGA is not matched!" ); + nCheckFlag = 1; + } + + if( nCheckFlag ) //act as a new segmention start + { + if( pIntraMsg->Segmnt.FBit == 1 && pIntraMsg->Segmnt.RSBits != 0 ) + { + return MAX_SEGMSG_BUF; + } + return MAX_SEGMSG_BUF + 1; + } + + return SegMsgIndex; + } + return SegMsgIndex; +} + +int RsmRegMsg ( SCLC_MSG * pmsg, SCCP_SegMsgBuf * pSegMsgbuf, Intra_Msg * pIntraMsg ) +{ + int SegBlockIndex, XUDTMsgLen; + SCCP_SegStream *pSegStream; + + XUDTMsgLen = 0; + for ( SegBlockIndex = 0; SegBlockIndex < pSegMsgbuf->MsgTotal; SegBlockIndex++ ) + { + pSegStream = &pSegMsgbuf->SegStream[SegBlockIndex]; + XUDTMsgLen += pSegStream->SegDataLen; + } + + if( XUDTMsgLen > MAX_SCLCMSG_LEN ) + { + spLogDebug ( SCCPDB_ERR, "SCCP Reassemble XUDT Msg is too long ,discard it" ); + return 0; + } + + XUDTMsgLen = 0; + for ( SegBlockIndex = 0; SegBlockIndex < pSegMsgbuf->MsgTotal; SegBlockIndex++ ) + { + pSegStream = &pSegMsgbuf->SegStream[SegBlockIndex]; + memcpy ( pmsg->msg + XUDTMsgLen, pSegStream->SegDataBlock, pSegStream->SegDataLen ); + XUDTMsgLen += pSegStream->SegDataLen; + } + pmsg->msglen = XUDTMsgLen; + memcpy ( &( pmsg->src_addr ), &( pIntraMsg->CGA ), sizeof ( SCCP_ADDR ) ); + memcpy ( &( pmsg->dst_addr ), &( pIntraMsg->CDA ), sizeof ( SCCP_ADDR ) ); + + return 1; +} + diff --git a/omc/plat/sccp/src/scmg.c b/omc/plat/sccp/src/scmg.c new file mode 100644 index 0000000..97e35cb --- /dev/null +++ b/omc/plat/sccp/src/scmg.c @@ -0,0 +1,560 @@ + +/************************************************************/ +/*Title: scmg.c */ +/*Descr: SCCP Management */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2002-5-7 */ + +/************************************************************/ + +#include "./include/sccp.h" + +/*===========export================*/ +void localssn_timer ( ); +void sst_timer ( ); +int sclc2scmg ( Intra_Msg * intramsg ); +BOOL CheckAvail ( SCCP_ADDR * addr ); + +/*===========import================*/ +extern int scrc_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); +extern int send_msg ( Intra_Msg * pIntraMsg, BYTE ansi_flag ); +extern void sccp_sethb ( ); +extern int CollectLocalInfo ( ); +extern int AddToIpList ( DWORD ip, BYTE ssn ); +extern void snmpLogInfo ( char *logInfo ); +extern void spLogDebug ( DWORD mask, const char *fmt, ... ); +/*===========private================*/ +static BYTE ssn_status ( int spc, BYTE ssn, BYTE NetID ); +void spac ( int spc, BYTE NetID ); +void sppc ( int spc, BYTE NetID ); +void spcc ( int spc, BYTE NetID ); +static void ssac ( int spc, BYTE ssn, BYTE NetID, BOOL relay ); +static void sscc ( int spc, BYTE ssn, BYTE NetID ); +static void sspc ( int spc, BYTE ssn, BYTE NetID, BOOL relay ); +static void lcst ( int spc, BYTE ssn, BYTE ntype, BYTE NetID ); +static void bcst ( BYTE ssn, BYTE ntype ); +static void bcst_relay ( int spc, BYTE ssn, BYTE ntype, BYTE NetID ); +static int build_scmgmsg ( BYTE * intramsg, BYTE type, int spc, BYTE ssn, BYTE NetID ); +static int parse_scmgmsg ( BYTE * data, BYTE * type, int *spc, BYTE * ssn, BYTE NetID ); + +/* by simon at 23/9/25 */ +extern DWORD ExistIP[64]; +extern DWORD ExistIPNum; +extern SCOC_BUF ScocBuf; +extern LOCAL_SSN LocalSSN[256]; +extern u8 ExistSSN[64]; +extern u8 ExistSSNNum; +extern struct _dpc2sls +{ + int dpc; + u8 sls; +} dpc2sls[256]; // used for sequence control, add by Roy Jiang, 2007-09-17 +extern SCCP_OPT SCCP_Param; +extern u8 MNP_Flag[2]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern int RelatedSPCNum; +extern RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; +extern GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern SCCP_Capture_Buf SCCPCapBuf; + +void localssn_timer ( ) //called per 1s +{ + int i; + LOCAL_SSN *pSSN; + + for ( i = 0; i < ExistSSNNum; i++ ) + { + pSSN = &LocalSSN[ExistSSN[i]]; + if( pSSN->status[0] == ST_Enable && pSSN->local != 1 && pSSN->timeout[0]-- <= 0 ) + pSSN->status[0] = ST_Disable; + if( pSSN->status[1] == ST_Enable && pSSN->local != 2 && pSSN->timeout[1]-- <= 0 ) + pSSN->status[1] = ST_Disable; + } +} + +int sclc2scmg ( Intra_Msg * intramsg ) +{ + BYTE *pmsg; + BYTE ntype, ssn; + int spc; + BOOL relay = 0; + + intramsg->msgsource = FROM_SCMG; + pmsg = intramsg->data; + parse_scmgmsg ( intramsg->data, &ntype, &spc, &ssn, intramsg->NetID ); + + snmpLogInfo ( "sclc2scmg (): start..." ); + + spLogDebug ( SCCPDB_SCMG, "Receive %s Message.ssn=%d,src_spc=%X", ntype == SSA_MSG ? "SSA" : ( ntype == SSP_MSG ? "SSP" : ( ntype == SST_MSG ? "SST" : "SCMG" ) ), ssn, spc ); + switch ( ntype ) + { + case SSA_MSG: + //to enable subsystem + SccpCsta[SccpCstaInd].avail[11]++; + if( intramsg->OPC != SCCP_Param.spc[intramsg->NetID] && intramsg->CGA.DPC != SCCP_Param.spc[intramsg->NetID] ) + { + lcst ( spc, ssn, SSA_MSG, intramsg->NetID ); + if( spc == intramsg->CGA.DPC ) + relay = 1; + } + ssac ( spc, ssn, intramsg->NetID, relay ); + + break; + case SSC_MSG: + SccpCsta[SccpCstaInd].avail[7]++; + sscc ( spc, ssn, intramsg->NetID ); + break; + case SSP_MSG: + SccpCsta[SccpCstaInd].avail[10]++; + if( intramsg->OPC != SCCP_Param.spc[intramsg->NetID] && intramsg->CGA.DPC != SCCP_Param.spc[intramsg->NetID] ) + { + lcst ( spc, ssn, SSP_MSG, intramsg->NetID ); + if( spc == intramsg->CGA.DPC ) + relay = 1; + } + sspc ( spc, ssn, intramsg->NetID, relay ); + + break; + case SST_MSG: + if( LocalSSN[ssn].status[0] == ST_Enable || LocalSSN[ssn].status[1] == ST_Enable ) + pmsg[0] = SSA_MSG; + else + return 1; + + memcpy ( &intramsg->CDA, &intramsg->CGA, sizeof ( SCCP_ADDR ) ); + intramsg->CGA.DPC = SCCP_Param.spc[intramsg->NetID]; + intramsg->CGA.GTI = 0; + intramsg->CGA.SSN = 1; + intramsg->CGA.RI = RI_SSN; + intramsg->CGA.len = 0; + + spLogDebug ( SCCPDB_SCMG, "Send %s Message.ssn=%d,dst_spc=%X", ( pmsg[0] == SSA_MSG ) ? "SSA" : ( ( pmsg[0] == SSP_MSG ) ? "SSP" : "SSC" ), ssn, intramsg->CDA.DPC ); + send_msg ( intramsg, mtp3_ansiFlag ( intramsg->NetID ) ); + break; + case SOR_MSG: + //to send SOG + pmsg[0] = SOG_MSG; //to send SOG + memcpy ( &intramsg->CDA, &intramsg->CGA, sizeof ( SCCP_ADDR ) ); + scrc_route ( intramsg, 0 ); + break; + case SOG_MSG: + //to disable local subsystem + break; + } + snmpLogInfo ( "sclc2scmg (): end..." ); + return 1; +} + +BOOL CheckAvail ( SCCP_ADDR * addr ) +{ + BYTE status; + + status = ssn_status ( addr->DPC, addr->SSN, addr->NetID ); + if( status == ST_Disable ) + { + spLogDebug ( SCCPDB_ERR, "<009>Subsystem Failure.NetID=%d,SPC=%x,SSN=%d", addr->NetID, addr->DPC, addr->SSN ); + SccpCsta[SccpCstaInd].error[4]++; + return 0; + } + else if( status == ST_Congest ) + { + spLogDebug ( SCCPDB_ERR, "<010>Subsystem Congest.NetID=%d,SPC=%x,SSN=%d", addr->NetID, addr->DPC, addr->SSN ); + SccpCsta[SccpCstaInd].error[5]++; + return 0; + } + //else if(sccp_status(addr->DPC,addr->NetID)==ST_Disable) + // return 0; + else + return 1; +} + +BYTE ssn_status ( int spc, BYTE ssn, BYTE NetID ) +//related subsystem +{ + int i; + + for ( i = 0; i < RelatedSSNNum; i++ ) + { + if( RelatedSSN[i].status == 0 ) + continue; + if( RelatedSSN[i].DPC != spc || RelatedSSN[i].SSN != ssn || RelatedSSN[i].NetID != NetID ) + continue; + + return RelatedSSN[i].status; + } + return ST_Enable; +} + +///////////////////////// +/*SPAC Module----------> */ +///////////////////////// +void spac ( int spc, BYTE NetID ) +{ + int i, j; + + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( spc == RelatedSPC[i].DPC && NetID == RelatedSPC[i].NetID ) + { + RelatedSPC[i].status = ST_Enable; + for ( j = 0; j < RelatedSSNNum; j++ ) + { + if( RelatedSSN[j].status == 0 ) + continue; + if( spc == RelatedSSN[j].DPC && NetID == RelatedSSN[j].NetID ) + { + if( RelatedSPC[i].status == ST_Disable ) + RelatedSSN[j].SST = 1; + RelatedSSN[j].status = ST_Enable; + } + } + } + } + +} + +///////////////////////// +/*SPPC Module----------> */ +///////////////////////// +void sppc ( int spc, BYTE NetID ) +{ + int i, j; + + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( spc == RelatedSPC[i].DPC && NetID == RelatedSPC[i].NetID ) + { + RelatedSPC[i].status = ST_Disable; + for ( j = 0; j < RelatedSSNNum; j++ ) + { + if( RelatedSSN[j].status == 0 ) + continue; + if( spc == RelatedSSN[j].DPC && NetID == RelatedSSN[j].NetID ) + { + RelatedSSN[j].SST = 0; + RelatedSSN[j].status = ST_Disable; + } + } + } + } + +} + +///////////////////////// +/*SPCC Module----------> */ +///////////////////////// +void spcc ( int spc, BYTE NetID ) +{ + int i; + + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( spc == RelatedSSN[i].DPC && NetID == RelatedSSN[i].NetID ) + RelatedSSN[i].status = ST_Congest; + } +} + +///////////////////////// +/*SSAC Module----------> */ +///////////////////////// + +int register_ssn ( BYTE ssn, BYTE usertype ) //enable local subsystem +{ + BYTE localindex = LocalSSN[ssn].local % 3; + + LocalSSN[ssn].RegFlag = 1; + if( localindex > 0 ) + { + CollectLocalInfo ( ); + LocalSSN[ssn].status[localindex - 1] = ST_Enable; + } + else + { + printf ( "Subsystem %d not equiped.check your GTT Table.\n", ssn ); + return 0; + } + + if( usertype == 3 ) + SCCP_Param.CO_SSN = ssn; + + SccpCsta[SccpCstaInd].avail[8]++; + LocalSSN[ssn].nbuf = usertype % 4; + if( LocalSSN[ssn].nbuf == 3 ) + SCCP_Param.CO_SSN = ssn; + bcst ( ssn, SSA_MSG ); + + return 1; +} + +void ssac ( int spc, BYTE ssn, BYTE NetID, BOOL relay ) //enable remote subsystem +{ + int i; + + for ( i = 0; i < RelatedSSNNum; i++ ) + { + if( RelatedSSN[i].status == 0 ) + continue; + if( RelatedSSN[i].DPC != spc || RelatedSSN[i].SSN != ssn || RelatedSSN[i].NetID != NetID ) + continue; + + if( RelatedSSN[i].status == ST_Disable && relay ) //Disable->Enable + bcst_relay ( spc, ssn, SSA_MSG, NetID ); + RelatedSSN[i].SST = 0; + RelatedSSN[i].status = ST_Enable; + + } +} + +void sscc ( int spc, BYTE ssn, BYTE NetID ) //enable remote subsystem +{ + int i; + + for ( i = 0; i < RelatedSSNNum; i++ ) + { + if( RelatedSSN[i].status == 0 ) + continue; + if( RelatedSSN[i].DPC != spc || RelatedSSN[i].SSN != ssn || RelatedSSN[i].NetID != NetID ) + continue; + + RelatedSSN[i].status = ST_Congest; + } +} + +///////////////////////// +/*SSPC Module----------> */ +///////////////////////// +int stop_ssn ( BYTE ssn ) //disable local subsystem +{ + BYTE localindex = LocalSSN[ssn].local % 3; + int i; + + LocalSSN[ssn].RegFlag = 0; + spLogDebug ( SCCPDB_SCMG, "Disable local subsystem. ssn=%d", ssn ); + + if( localindex > 0 ) + { + CollectLocalInfo ( ); + /* add by daniel on 2005-9-15 */ + for ( i = 0; i <= 1; i++ ) + { + if( SCCP_Param.OMCIP[i] > 0 ) + AddToIpList ( SCCP_Param.OMCIP[i], ssn ); + } + /* add by daniel on 2005-9-15 */ + LocalSSN[ssn].status[localindex - 1] = ST_Disable; + } + else + return -1; + + sccp_sethb ( ); + SccpCsta[SccpCstaInd].avail[9]++; + bcst ( ssn, SSP_MSG ); + return 1; +} + +void sspc ( int spc, BYTE ssn, BYTE NetID, BOOL relay ) //disable remote subsystem +{ + int i; + + for ( i = 0; i < RelatedSSNNum; i++ ) + { + if( RelatedSSN[i].status == 0 ) + continue; + if( RelatedSSN[i].DPC != spc || RelatedSSN[i].SSN != ssn || RelatedSSN[i].NetID != NetID ) + continue; + + if( RelatedSSN[i].status == ST_Enable ) //Enable->Disable + { + RelatedSSN[i].timeout = T_sst; + RelatedSSN[i].SST = 1; + if( relay ) + bcst_relay ( spc, ssn, SSP_MSG, NetID ); + } + + RelatedSSN[i].status = ST_Disable; + } +} + +///////////////////////// +/*SSTC Module----------> */ +///////////////////////// +void sst_timer ( ) +{ + Intra_Msg outmsg; + RL_SSN *pSSN; + int i; + + for ( i = 0; i < RelatedSSNNum; i++ ) + { + pSSN = &RelatedSSN[i]; + if( !pSSN->SST ) + continue; + if( pSSN->timeout-- > 0 ) + continue; + if( pSSN->DPC == SCCP_Param.spc[pSSN->NetID] ) + continue; + + outmsg.msgtype = UDT_MSG; + outmsg.msgsource = FROM_SCMG; + + outmsg.CGA.DPC = SCCP_Param.spc[pSSN->NetID]; + outmsg.CGA.SSN = 1; + outmsg.CGA.GTI = 0; + outmsg.CGA.RI = RI_SSN; + outmsg.CGA.len = 0; + + outmsg.CDA.DPC = pSSN->DPC; + outmsg.CDA.SSN = 1; //SCMG + outmsg.CDA.GTI = 0; //No GT + outmsg.CDA.RI = 1; + outmsg.CDA.len = 0; + + outmsg.NetID = pSSN->NetID; + + outmsg.CDA.ip = INADDR_NONE; + + outmsg.msglen = build_scmgmsg ( outmsg.data, SST_MSG, pSSN->DPC, pSSN->SSN, pSSN->NetID ); + spLogDebug ( SCCPDB_SCMG, "SST spc=%X,ssn=%d", pSSN->DPC, pSSN->SSN ); + send_msg ( &outmsg, mtp3_ansiFlag ( pSSN->NetID ) ); + pSSN->timeout = T_sst; + } +} + +///////////////////////// +/*LCST Module----------> */ +///////////////////////// + +void lcst ( int spc, BYTE ssn, BYTE ntype, BYTE NetID ) +{ + Intra_Msg outmsg; + int i; + + spLogDebug ( SCCPDB_SCMG, "Start Local Broatcast.spc=%X,ssn=%d,ntype=%d", spc, ssn, ntype ); + outmsg.msgtype = UDT_MSG; + outmsg.msgsource = FROM_SCMG; + outmsg.CGA.SSN = 1; + outmsg.CGA.GTI = 0; + outmsg.CGA.len = 0; + outmsg.CGA.RI = 1; + outmsg.CGA.DPC = SCCP_Param.spc[NetID]; + outmsg.CDA.GTI = 0; + outmsg.NetID = outmsg.CDA.NetID = outmsg.CGA.NetID = NetID; + + outmsg.CDA.DPC = SCCP_Param.spc[NetID]; + outmsg.CDA.SSN = 1; + outmsg.CDA.RI = 1; + outmsg.CDA.len = 0; + + outmsg.msglen = build_scmgmsg ( outmsg.data, ntype, spc, ssn, NetID ); + + for ( i = 2; i < 256; i++ ) + { + if( LocalSSN[i].status[0] > 0 && LocalSSN[i].local != 1 ) + { + outmsg.CDA.ip = LocalSSN[i].ip[0]; + send_msg ( &outmsg, mtp3_ansiFlag ( NetID ) ); + } + if( LocalSSN[i].status[1] > 0 && LocalSSN[i].local != 2 ) + { + outmsg.CDA.ip = LocalSSN[i].ip[1]; + send_msg ( &outmsg, mtp3_ansiFlag ( NetID ) ); + } + } +} + +///////////////////////// +/*BCST Module----------> */ +///////////////////////// +void bcst ( BYTE ssn, BYTE ntype ) +{ + Intra_Msg outmsg; + int i; + + spLogDebug ( SCCPDB_SCMG, "Start Remote Broadcase ssn=%d,ntype=%d", ssn, ntype ); + outmsg.msgtype = UDT_MSG; + outmsg.msgsource = FROM_SCMG; + outmsg.CDA.GTI = 0; + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( RelatedSPC[i].status != ST_Enable ) + continue; + outmsg.CGA.SSN = 1; + outmsg.CGA.GTI = 0; + outmsg.CGA.len = 0; + outmsg.CGA.RI = 1; + outmsg.CGA.DPC = SCCP_Param.spc[RelatedSPC[i].NetID]; + outmsg.CDA.ip = INADDR_NONE; + outmsg.CDA.DPC = RelatedSPC[i].DPC; + outmsg.CDA.SSN = 1; + outmsg.CDA.RI = 1; + outmsg.CDA.len = 0; + outmsg.NetID = outmsg.CDA.NetID = outmsg.CGA.NetID = RelatedSPC[i].NetID; + + outmsg.msglen = build_scmgmsg ( outmsg.data, ntype, SCCP_Param.spc[outmsg.NetID], ssn, outmsg.NetID ); + send_msg ( &outmsg, mtp3_ansiFlag ( outmsg.NetID ) ); + } +} + +void bcst_relay ( int spc, BYTE ssn, BYTE ntype, BYTE NetID ) +{ + Intra_Msg outmsg; + int i; + + spLogDebug ( SCCPDB_SCMG, "relay Broadcase spc:%X,ssn%d,ntype:%d", spc, ssn, ntype ); + outmsg.msgtype = UDT_MSG; + outmsg.msgsource = FROM_SCMG; + outmsg.CDA.GTI = 0; + outmsg.CGA.SSN = 1; + outmsg.CGA.GTI = 0; + outmsg.CGA.len = 0; + outmsg.CGA.RI = 1; + outmsg.NetID = outmsg.CGA.NetID = outmsg.CDA.NetID = NetID; + for ( i = 0; i < RelatedSPCNum; i++ ) + { + if( NetID != RelatedSPC[i].NetID ) + return; + if( RelatedSPC[i].status == ST_Disable || spc == RelatedSPC[i].DPC ) + continue; + + outmsg.CGA.DPC = SCCP_Param.spc[RelatedSPC[i].NetID]; + outmsg.CDA.ip = INADDR_NONE; + outmsg.CDA.DPC = RelatedSPC[i].DPC; + outmsg.CDA.SSN = 1; + outmsg.CDA.RI = 1; + outmsg.CDA.len = 0; + + outmsg.msglen = build_scmgmsg ( outmsg.data, ntype, spc, ssn, NetID ); + send_msg ( &outmsg, mtp3_ansiFlag ( NetID ) ); + } +} + +int build_scmgmsg ( BYTE * data, BYTE type, int spc, BYTE ssn, BYTE NetID ) +{ + int pos = 0; + + data[pos++] = type; + data[pos++] = ssn; + memcpy ( data + pos, ( BYTE * ) & spc, SCCP_Param.spclen[NetID] ); + pos += SCCP_Param.spclen[NetID]; + data[pos++] = 0; + if( type == SSC_MSG ) + data[pos++] = 0; + return pos; +} + +int parse_scmgmsg ( BYTE * data, BYTE * type, int *spc, BYTE * ssn, BYTE NetID ) +{ + int pos = 0; + + *type = data[pos++]; + *ssn = data[pos++]; + *spc = 0; + memcpy ( ( BYTE * ) spc, data + pos, SCCP_Param.spclen[NetID] ); + pos += SCCP_Param.spclen[NetID]; + return 1; +} diff --git a/omc/plat/sccp/src/scoc.c b/omc/plat/sccp/src/scoc.c new file mode 100644 index 0000000..64a78ce --- /dev/null +++ b/omc/plat/sccp/src/scoc.c @@ -0,0 +1,126 @@ + +/********************************************************************/ +/*Title: scoc.c */ +/*Descr: SCCP Connection-Oriented Control */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-5-9 */ + +/********************************************************************/ +#include "./include/sccp.h" + +/*===========import================*/ +extern int scrc_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); +extern int build_msg ( BYTE * buf, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ); //sccpmsg.c +extern int parse_msg ( BYTE * buf, Intra_Msg * intramsg, int len, BYTE NetID, BYTE ansi_flag ); //sccpmsg.c + +/*===========export================*/ +int scrc2scoc ( Intra_Msg * intramsg, BYTE AnsiFlag ); +int scoc_store ( up_message * sccpmsg ); + +/* +int scrc2scoc ( Intra_Msg * intramsg, BYTE AnsiFlag ) +{ + up_message mtp3msg; + + mtp3msg.len = build_msg ( mtp3msg.msgList, intramsg, intramsg->NetID, AnsiFlag ); + mtp3msg.dest_ip = intramsg->CDA.ip; + mtp3msg.dpc = intramsg->DPC; + mtp3msg.opc = intramsg->OPC; + mtp3msg.sio = intramsg->NetID * 0x40 + 3; + mtp3msg.cic[0] = intramsg->SLS; + mtp3msg.link = intramsg->link; + + scoc_store ( &mtp3msg ); + return 1; +} +*/ +/* + int scoc_store ( up_message * sccpmsg ) + { + up_message *pmsg; + + SccpCsta[SccpCstaInd].utilization[4 - 3]++; + spLogDebug ( SCCPDB_AIF, "MSC <== SCCP: CO Message. opc=%x,sio=%02x", sccpmsg->opc, sccpmsg->sio ); + spShowBCD ( SCCPDB_AIF, ( BYTE * ) sccpmsg, ( sccpmsg->len + 17 ) % 256 ); + + pmsg = &ScocBuf.msgin[ScocBuf.rcvsub[0]]; + memcpy ( pmsg, sccpmsg, sizeof ( up_message ) ); + + ScocBuf.rcvsub[0] = ( ScocBuf.rcvsub[0] + 1 ) % SS_MSG_NUM; + if( ScocBuf.rcvsub[0] == ScocBuf.rcvsub[1] ) + ScocBuf.rcvsub[1] = ( ScocBuf.rcvsub[1] + 1 ) % SS_MSG_NUM; + + sccpmsg_st.msg_mtp_scoc++; + return 1; + } + */ + +/******************************************************************/ + +/*================== User Interface-----> ================*/ + +/******************************************************************/ +/* + int scoc_send ( up_message * pmsg ) + { + BYTE ntype; + BOOL ForceAnsi = 0; + + ntype = pmsg->msgList[0]; + + spLogDebug ( SCCPDB_AIF, "MSC ==> SCCP: CO/UDT Message. opc=%x,sio=%02x,type=%d", pmsg->opc, pmsg->sio, ntype ); + spShowBCD ( SCCPDB_AIF, ( BYTE * ) pmsg, ( pmsg->len + 17 ) % 256 ); + SccpCsta[SccpCstaInd].utilization[0]++; + switch ( ntype ) + { + case CR_MSG: + SccpCsta[SccpCstaInd].quality[4]++; + break; + case CC_MSG: + break; + case DT1_MSG: + SccpCsta[SccpCstaInd].utilization[10 - 3]++; + break; + case DT2_MSG: + SccpCsta[SccpCstaInd].utilization[12 - 3]++; + break; + } + if( ntype == CR_MSG || ntype == UDT_MSG ) + { + Intra_Msg outmsg; + BYTE NetID = pmsg->sio / 0x40; + + memset ( &outmsg, 0, sizeof ( Intra_Msg ) ); + + ForceAnsi = ( pmsg->sio >> 4 ) & 1; + parse_msg ( pmsg->msgList, &outmsg, pmsg->len, NetID, ForceAnsi ); + + outmsg.CDA.ip = INADDR_NONE; + outmsg.OPC = pmsg->opc; + outmsg.DPC = pmsg->dpc; + outmsg.SLS = pmsg->cic[0]; + + outmsg.NetID = outmsg.CGA.NetID = outmsg.CDA.NetID = NetID; + return scrc_route ( &outmsg, ForceAnsi ); + } + else + { + return sccp_to_mtp3 ( pmsg ); + } + + } + + int scoc_receive ( up_message * sccpmsg ) + { + up_message *pmsg; + + if( ScocBuf.rcvsub[0] == ScocBuf.rcvsub[1] ) + return 0; + pmsg = &ScocBuf.msgin[ScocBuf.rcvsub[1]]; + memcpy ( sccpmsg, pmsg, sizeof ( up_message ) ); + ScocBuf.rcvsub[1] = ( ScocBuf.rcvsub[1] + 1 ) % SS_MSG_NUM; + sccpmsg_st.msg_scoc_up++; + return 1; + } + */ diff --git a/omc/plat/sccp/src/scoc_fsm.c b/omc/plat/sccp/src/scoc_fsm.c new file mode 100644 index 0000000..599f53c --- /dev/null +++ b/omc/plat/sccp/src/scoc_fsm.c @@ -0,0 +1,1068 @@ +////////////////////////////////////////////////// +//Title : scoc_fsm.c +//Auhtor : Liu Wei +//Desc : SCOC fsm implementation +//Created : 2007-04-22 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/sccp_pub.h" +#include "./include/sccp_func.h" + +/////////////////////////////////////////////////////////////////////////// +// SCOC special State Machine +/////////////////////////////////////////////////////////////////////////// + +extern void spLogStateError ( u16 wConnId, u8 uErrCode ); + +void coFsmDiscard ( u16 wConnId ) +{ + spLogStateError ( wConnId, ERR_FSM_DISCARD ); +} + +void coFsmError ( u16 wConnId ) +{ + spLogStateError ( wConnId, ERR_FSM_ERROR ); +} + +void coFsmFatal ( u16 wConnId ) +{ + spLogStateError ( wConnId, ERR_FSM_FATAL ); +} + +void coFsmReserved ( u16 wConnId ) +{ + spLogStateError ( wConnId, ERR_FSM_RESERVED ); +} + +/////////////////////////////////////////////////////////////////////////// +// SCOC State Machine declare --Q.714 Page 85 - Page 127 +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// SCOC State Machine implementation --Q.714 Page 85 - Page 127 +/////////////////////////////////////////////////////////////////////////// + +void _Below_fsm_is_supported_ ( ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// origination node connection establishment procedures +// -- IDLE State +/////////////////////////////////////////////////////////////////////////// + +void coOCEP_IDLE ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case N_CONNECT_REQ: + if( !coNewCS ( wConnId, &pCS->tCDA ) ) + { + //have check resource in coNewConnId + goto Err_Resource_Limited; + } + pCS->tmSCOC.tmConnEst = 1; + co2cr ( wConnId, SP_MSG_CR ); + pCS->uCState = CO_STATUS_CPOG; + return; + case N_CONNECT_T1: + //not supported now for ISUP + WxcAssert ( 0, "coOCEP_IDLE unexpected event, not supported now" ); + if( !coNewCS ( wConnId, &pCS->tCDA ) ) + { + goto Err_Resource_Limited; + } + co2ul ( wConnId, RELAY ); + pCS->tmSCOC.tmConnEst = 1; + pCS->uCState = CO_STATUS_CPOG; + return; + case R_RLSD: + //have handled in cr2co + //co2cr ( wConnId, SP_MSG_RLC ); + //pCS->uCState = CO_STATUS_INIT; + WxcAssert ( 0, "coOCEP_IDLE unexpected event" ); + return; + case R_RLC: + case R_IT: + //have handled in cr2co + //pCS->uCState = CO_STATUS_INIT; + WxcAssert ( 0, "coOCEP_IDLE unexpected event" ); + return; + default: + //have handled in cr2co + //if( coGetConnId ( pCS->aSLR ) < 0 ) + //{ + // co2cr ( wConnId, SP_MSG_ERR ); + //} + //pCS->uCState = CO_STATUS_INIT; + WxcAssert ( 0, "coOCEP_IDLE unexpected event" ); + return; + } + Err_Resource_Limited: + { + pCS->eREA = REA_PDISC_ACNN; + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->uCState = CO_STATUS_INIT; + } + return; +} + +/////////////////////////////////////////////////////////////////////////// +// origination node connection establishment procedures +// -- Connection pending outgoing state +/////////////////////////////////////////////////////////////////////////// + +void coOCEP_CPOG ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case N_DISCONNECT_REQ: + pCS->uCState = CO_STATUS_WTCC; + return; + case T_CONNEST_OUT: + goto Release_Resource_1; + case R_RF: + goto Release_Resource_0; + case R_RLSD: + co2cr ( wConnId, SP_MSG_RLC ); + goto Release_Resource_0; + case R_CC: + pCS->tmSCOC.tmConnEst = 0; + pCS->tmSCOC.tmIar = 1; + //class credit dlr fill in coFillCS + + co2ul ( wConnId, N_CONNECT_CFM ); + pCS->uCState = CO_STATUS_ACTV; + return; + case R_CREF: + pCS->tmSCOC.tmConnEst = 0; + goto Release_Resource_1; + default: + goto Release_Resource_0; + } + Release_Resource_0: + { + pCS->tmSCOC.tmConnEst = 0; + } + Release_Resource_1: + //freeze local reference P86 + { + co2ul ( wConnId, N_DISCONNECT_IND ); + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + } + + return; +} + +/////////////////////////////////////////////////////////////////////////// +// origination node connection establishment procedures +// -- Wait Connection confirm state +/////////////////////////////////////////////////////////////////////////// + +void coOCEP_WTCC ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case R_RLSD: + co2cr ( wConnId, SP_MSG_RLC ); + goto Early_Release; + case R_CC: + pCS->tmSCOC.tmConnEst = 0; + //dlr fill in coFillCS + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + return; + case R_CREF: + case R_RF: + goto Early_Release; + case T_CONNEST_OUT: + //freeze local reference P87 + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + default: + //freeze local reference P87 + goto Early_Release; + } + Early_Release: + { + pCS->tmSCOC.tmConnEst = 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + } + return; +} + +/////////////////////////////////////////////////////////////////////////// +// origination node connection release procedures +// -- active state +/////////////////////////////////////////////////////////////////////////// + +void coOCRP_ACTV ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case I_DISCONNECT: + goto Disconnect_Pending_0; + case N_DISCONNECT_REQ: + goto Disconnect_Pending_1; + case R_CC: + case R_CREF: + case R_RLC: + return; + case R_RLSD: + co2ul ( wConnId, N_DISCONNECT_IND ); + //Freeze local reference P89 + pCS->tmSCOC.tmIar = 0; + co2cr ( wConnId, SP_MSG_RLC ); + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case R_ERR: + if( pCS->uClass == 2 ) + { + goto Disconnect_Pending_0; + } + //Freeze local reference P89 + + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case T_IAR_OUT: + goto Disconnect_Pending_0; + case R_RF: + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + return; + default: + return; + } + Disconnect_Pending_0: + { + co2ul ( wConnId, N_DISCONNECT_IND ); + } + Disconnect_Pending_1: + { + pCS->tmSCOC.tmIar = 0; + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + } + return; +} + +/////////////////////////////////////////////////////////////////////////// +// origination node connection release procedures +// -- disconnection pending state +/////////////////////////////////////////////////////////////////////////// + +void coOCRP_DSCP ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case R_RLC: + case R_RLS_ERR: + goto Release; + case R_RF: + return; + case T_RLS_OUT: + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmInternal = 1; + pCS->tmSCOC.tmRepeatRel = 1; + return; + case T_INTERNAL_OUT: + //unsupported now + co2scmg ( ); + goto Release; + case T_REPEATE_RLS_OUT: + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRepeatRel = 1; + return; + default: + //discard message + return; + } + Release: + { + //Freeze local reference P90 + pCS->tmSCOC.tmRel = 0; + pCS->tmSCOC.tmInternal = 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + } + return; + +} + +/////////////////////////////////////////////////////////////////////////// +// distination node connection establishment procedures +// -- idle state +/////////////////////////////////////////////////////////////////////////// + +void coDCEP_IDLE ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case R_CR: + if( !coCheckResource ( ) ) + { + goto Refuse_Connection; + } + goto Connecting; + case R_RF: + goto Refuse_Connection; + case R_CR2: + //not supported now + WxcAssert ( 0, "coDCEP_IDLE unexpected event, not supported now" ); + //if( set CREF ind ) + if( 1 ) + { + goto Refuse_Connection; + } + if( coCheckResource ( ) ) + { + goto Connecting; + } + co2ul ( wConnId, N_DISCONNECT_IND ); + goto Refuse_Connection; + case R_RLSD: + //have handled in cr2co + //co2cr ( wConnId, SP_MSG_RLSD ); + pCS->uCState = CO_STATUS_INIT; + WxcAssert ( 0, "coDCEP_IDLE unexpected event" ); + return; + case R_RLC: + case R_IT: + //have handled in cr2co + pCS->uCState = CO_STATUS_INIT; + WxcAssert ( 0, "coDCEP_IDLE unexpected event" ); + return; + default: + //have handled in cr2co + WxcAssert ( 0, "coDCEP_IDLE unexpected event" ); + //if( coGetConnId ( pCS->aSLR ) < 0 ) + //{ + // co2cr ( wConnId, SP_MSG_ERR ); + //} + pCS->uCState = CO_STATUS_INIT; + return; + + } + Refuse_Connection: + { + pCS->eREA = REA_PDISC_ACNN; + co2cr ( wConnId, SP_MSG_CREF ); + pCS->uCState = CO_STATUS_INIT; + return; + } + Connecting: + { + coNewCS ( wConnId, &pCS->tCDA ); + co2ul ( wConnId, N_CONNECT_IND ); + pCS->uCState = CO_STATUS_CPIC; + } + return; +} + +/////////////////////////////////////////////////////////////////////////// +// destination node connection establishment procedures +// -- connection pending incoming state +/////////////////////////////////////////////////////////////////////////// + +void coDCEP_CPIC ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case N_CONNECT_RSP: + //coNewCS ( wConnId , &pCS->tCDA ); + co2cr ( wConnId, SP_MSG_CC ); + pCS->tmSCOC.tmIar = 1; + pCS->uCState = CO_STATUS_ACTV; + return; + case N_DISCONNECT_REQ: + //P93 + co2cr ( wConnId, SP_MSG_CREF ); + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + + default: + //discard message + return; + } + +} + +/////////////////////////////////////////////////////////////////////////// +// distination node connection release procedures +// -- active state +/////////////////////////////////////////////////////////////////////////// + +void coDCRP_ACTV ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case N_DISCONNECT_REQ: + goto Disconnect_1; + case I_DISCONNECT: + goto Disconnect_0; + case R_CC: + case R_CREF: + case R_RLC: + return; + case R_RLSD: + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + co2cr ( wConnId, SP_MSG_RLC ); + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case R_ERR: + if( pCS->uClass == 2 ) + { + goto Disconnect_0; + } + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case R_RF: + goto Disconnect_0; + case T_IAR_OUT: + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + return; + default: + return; + } + Disconnect_0: + { + co2ul ( wConnId, N_DISCONNECT_IND ); + } + Disconnect_1: + { + pCS->tmSCOC.tmIar = 0; + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + } + + return; +} + +/////////////////////////////////////////////////////////////////////////// +// distination node connection release procedures +// -- disconnect pending state +/////////////////////////////////////////////////////////////////////////// + +void coDCRP_DSCP ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case R_RLC: + case R_ERR: + pCS->tmSCOC.tmRel= 0; + pCS->tmSCOC.tmInternal = 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case R_RF: + return; + case T_INTERNAL_OUT: + //notify management + //inform maintaenance + co2scmg ( ); + + pCS->tmSCOC.tmRel = 0; + pCS->tmSCOC.tmInternal= 0; + coFreeCS ( wConnId ); + pCS->uCState = CO_STATUS_INIT; + return; + case T_RLS_OUT: + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRepeatRel = 1; + pCS->tmSCOC.tmInternal = 1; + return; + case T_REPEATE_RLS_OUT: + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRepeatRel = 1; + return; + default: + //discare message + return; + } + +} + +/////////////////////////////////////////////////////////////////////////// +// origination and distination node data transfer procedures +// -- active state +/////////////////////////////////////////////////////////////////////////// + +void coODDT_ACTV ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + switch ( pCS->uPri ) + { + case N_DATA_REQ: + co2cr ( wConnId, SP_MSG_DT1 ); + pCS->tmSCOC.tmIas = 1; + return; + case R_DT1: + pCS->tmSCOC.tmIar = 1; + co2ul ( wConnId, N_DATA_IND ); + return; + case R_DT2: + WxcAssert ( 0, "coODDT_ACTV unsupport R_DT2 now" ); + //do not supported now + return; + case R_AK: + WxcAssert ( 0, "coODDT_ACTV unsupport R_AK now" ); + //do not supported now + return; + case T_IAS_OUT: + co2cr ( wConnId, SP_MSG_IT ); + pCS->tmSCOC.tmIas = 1; + return; + case R_IT: + //P101 + if( !( pCS->uClass < 3 && coGetConnId ( pCS->aSLR ) >= 0 ) ) + { + co2ul ( wConnId, N_DISCONNECT_IND ); + pCS->tmSCOC.tmIar = 0; + co2cr ( wConnId, SP_MSG_RLSD ); + pCS->tmSCOC.tmRel = 1; + pCS->uCState = CO_STATUS_DSCP; + return; + } + else if( pCS->uClass == 2 ) + { + pCS->tmSCOC.tmIar = 1; + } + else if( spCheckAudit ( ) ) + { + pCS->tmSCOC.tmIar = 1; + } + else + { + co2co ( wConnId, I_RESET_REQ ); + } + return; + case I_CONGESTED: + case I_UNCONGESTED: + WxcAssert ( 0, "coODDT_ACTV unsupport I_CONGESTED/I_UNCONGESTED now" ); + //do not supported now + return; + default: + WxcAssert ( 0, "coODDT_ACTV unexpected primitive now" ); + return; + } + +} + +static void coODED_ACTV ( u16 wConnId ); +static void coODRS_ACTV ( u16 wConnId ); + +/////////////////////////////////////////////////////////////////////////// +// Active FSM on origination , distination and intermedia node +// -- include establishment, data transfer , release procedures +/////////////////////////////////////////////////////////////////////////// + +void coODMP_ACTV ( u16 wConnId ) +{ + CO_ConnSection *pCS; + + pCS = &pSp->tCo.tCSInst[wConnId]; + switch ( pCS->uPri ) + { + case N_DISCONNECT_REQ: //User->SCOC : N-DISCONNECT Request + case I_DISCONNECT: //internal disconnect + case R_CREF: //SCRC->SCOC Connection refused + case R_CC: //SCRC->SCOC Connection confirm + case R_RLC: //SCRC->SCOC Release complete + case R_RLSD: //SCRC->SCOC Released + case R_ERR: //SCRC->SCOC Error + case T_IAR_OUT: //Recieve inactivity timer expires + case R_RF: //Routing Fail + switch ( pCS->uSide ) + { + case CO_INST_SIDE_ORG: + coOCRP_ACTV ( wConnId ); + return; + case CO_INST_SIDE_DST: + coDCRP_ACTV ( wConnId ); + return; + //case CO_INST_SDIE_MID: //do not supported middle node side now + default: + coFsmReserved ( wConnId ); + return; + } + case N_DATA_REQ: //User->SCOC : N-Data Request + case R_DT1: //SCRC->SCOC DT1 + case R_DT2: //SCRC->SCOC DT2 + case R_AK: //SCRC->SCOC Data acknowledg + case T_IAS_OUT: //Send inactivity timer expires + case R_IT: //SCRC->SCOC IT + case I_CONGESTED: //Congested + case I_UNCONGESTED: //Uncongested + switch ( pCS->uSide ) + { + case CO_INST_SIDE_ORG: + case CO_INST_SIDE_DST: + coODDT_ACTV ( wConnId ); + return; + //case CO_INST_SDIE_MID: //do not supported middle node side now + default: + coFsmReserved ( wConnId ); + return; + } + case N_EDATA_REQ: //User->SCOC : N-Data Request + case R_EA: //SCRC->SCOC EData acknowledg + case R_ED: //SCRC->SCOC ED + switch ( pCS->uSide ) + { + case CO_INST_SIDE_ORG: + case CO_INST_SIDE_DST: + coODED_ACTV ( wConnId ); + return; + //case CO_INST_SDIE_MID: //do not supported middle node side now + default: + coFsmReserved ( wConnId ); + return; + } + + case N_RESET_REQ: //User->SCOC : N-Reset Request + case I_RESET_REQ: //SCRC->SCOC Reset Request + case R_RSC: //SCRC->SCOC Reset confirm + case R_RSR: //internal reset Request + switch ( pCS->uSide ) + { + case CO_INST_SIDE_ORG: + case CO_INST_SIDE_DST: + coODRS_ACTV ( wConnId ); + return; + //case CO_INST_SDIE_MID: //do not supported middle node side now + default: + coFsmReserved ( wConnId ); + return; + } + //coODRS_ACTV ( wConnId ); + default: + coFsmDiscard ( wConnId ); + return; + } + +} + +void _Above_fsm_is_supported_ ( ) +{ + +} + +void _Below_fsm_is_Unsupported_ ( ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// The Fsm below is not supporte now(SCCP R9.0.0) +/////////////////////////////////////////////////////////////////////////// + +void coODED_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODED_WSEA ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODRS_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODRS_RSIC ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODRS_RSOG ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODRS_RSBH ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCEP_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCEP_CONP ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCRP_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCRP_DPOG ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCRP_DPIC ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMCRP_DPBH ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMDTP_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMEDP_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMEDP_WSEA ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMRSP_ACTV ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMRSP_RSOG ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMRSP_RSIC ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coMRSP_RSBH ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coODMP_RSTA ( u16 wConnId ) +{ + coFsmReserved ( wConnId ); + return; +} + +void _Above_fsm_is_Unsupported_ ( ) +{ + +} + +/////////////////////////////////////////////////////////////////////////// +// SCOC State Machine Matricies +/////////////////////////////////////////////////////////////////////////// + +typedef void ( *coFsmFunc ) ( u16 wConnId ); + +#define CO_NODE_STYLE_MAX 3 //node type : origination,destination,intermediate + +static const coFsmFunc coFsmFuncSuit[][CO_STATUS_MAX + 1] = { + { //origination node stat machine + coFsmDiscard, //CO_STATUS_INIT : Transtion initialed + coOCEP_IDLE, //CO_STATUS_IDLE : status Idle + coOCEP_WTCC, //CO_STATUS_WTCC : Wait Connection confirm + coODMP_ACTV, //CO_STATUS_ACTV : Active + coFsmError, //CO_STATUS_CONP : Connection pending + coFsmError, //CO_STATUS_CPIC : Connection pending incoming + coOCEP_CPOG, //CO_STATUS_CPOG : Connection pending outgoing + coOCRP_DSCP, //CO_STATUS_DSCP : Disconnect pending + coFsmError, //CO_STATUS_DPIC : Disconnect pending incoming + coFsmError, //CO_STATUS_DPOG : Disconnect pending outgoing + coFsmError, //CO_STATUS_DPBH : Disconnect pending both + coFsmError, //CO_STATUS_NMOP : Normal operation + coODED_WSEA, //CO_STATUS_WSEA : Wait for sending EA Message + coODRS_RSOG, //CO_STATUS_RSIC : Reset outgoing + coODRS_RSIC, //CO_STATUS_RSOG : Reset incoming + coODRS_RSBH, //CO_STATUS_RSBH : Reset both + coFsmError, //CO_STATUS_MTBK : Maintenance blocking + coODMP_RSTA, //CO_STATUS_RSTA : Restart + coFsmFatal, //CO_STATUS_MAX + }, + { //destination node stat machine + coFsmDiscard, //CO_STATUS_INIT : Transtion initialed + coDCEP_IDLE, //CO_STATUS_IDLE : status Idle + coFsmError, //CO_STATUS_WTCC : Wait Connection confirm + coODMP_ACTV, //CO_STATUS_ACTV : Active + coFsmError, //CO_STATUS_CONP : Connection pending + coDCEP_CPIC, //CO_STATUS_CPIC : Connection pending incoming + coFsmError, //CO_STATUS_CPOG : Connection pending outgoing + coDCRP_DSCP, //CO_STATUS_DSCP : Disconnect pending + coFsmError, //CO_STATUS_DPIC : Disconnect pending incoming + coFsmError, //CO_STATUS_DPOG : Disconnect pending outgoing + coFsmError, //CO_STATUS_DPBH : Disconnect pending both + coFsmError, //CO_STATUS_NMOP : Normal operation + coODED_WSEA, //CO_STATUS_WSEA : Wait for sending EA Message + coODRS_RSOG, //CO_STATUS_RSIC : Reset outgoing + coODRS_RSIC, //CO_STATUS_RSOG : Reset incoming + coODRS_RSBH, //CO_STATUS_RSBH : Reset both + coFsmError, //CO_STATUS_MTBK : Maintenance blocking + coODMP_RSTA, //CO_STATUS_RSTA : Restart + coFsmFatal, //CO_STATUS_MAX + }, + { //intermedia node stat machine + coFsmDiscard, //CO_STATUS_INIT : Transtion initialed + coFsmError, //CO_STATUS_IDLE : status Idle + coFsmError, //CO_STATUS_WTCC : Wait Connection confirm + coODMP_ACTV, //CO_STATUS_ACTV : Active + coMCEP_CONP, //CO_STATUS_CONP : Connection pending + coFsmError, //CO_STATUS_CPIC : Connection pending incoming + coFsmError, //CO_STATUS_CPOG : Connection pending outgoing + coFsmError, //CO_STATUS_DSCP : Disconnect pending + coFsmError, //CO_STATUS_DPIC : Disconnect pending incoming + //coMCEP_DPIC, //CO_STATUS_DPIC : Disconnect pending incoming + coFsmError, //CO_STATUS_DPOG : Disconnect pending outgoing + //coMCEP_DPOG, //CO_STATUS_DPOG : Disconnect pending outgoing + coFsmError, //CO_STATUS_DPBH : Disconnect pending both + //coMCEP_DPBH, //CO_STATUS_DPBH : Disconnect pending both + coFsmError, //CO_STATUS_NMOP : Normal operation + coMEDP_WSEA, //CO_STATUS_WSEA : Wait for sending EA Message + coMRSP_RSOG, //CO_STATUS_RSIC : Reset outgoing + coMRSP_RSIC, //CO_STATUS_RSOG : Reset incoming + coMRSP_RSBH, //CO_STATUS_RSBH : Reset both + coFsmError, //CO_STATUS_MTBK : Maintenance blocking + coODMP_RSTA, //CO_STATUS_RSTA : Restart + coFsmFatal, //CO_STATUS_MAX + }, +}; + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// +int coCheckStatus( u32 wConnId) +{ + int stat = pSp->tCo.tCSInst[wConnId].uCState; + + WxcAssert(stat < CO_STATUS_MAX, "SCOC Fatal error, unexpected status"); + return (stat < CO_STATUS_MAX); +} + +void coFsm ( ) +{ +// u8 nLoop; + u16 wConnId; + SP_PriPoolEle tPri; + CO_ConnSection *pCS; + +// for ( nLoop = 0; nLoop < 16; nLoop++ ) + while ( spPoolGet ( &tPri, pInCoPool ) ) + { +// if( !spPoolGet ( &tPri, pInCoPool ) ) +// { +// break; +// } + + coFillCS ( &tPri ); + + pCS = &pSp->tCo.tCSInst[tPri.tCrPri.wConnId]; + + if( CO_STATUS_INIT == pCS->uCState || + !coCheckCS ( tPri.tCrPri.wConnId, pCS->uCState, pCS->uSide ) ) + { + continue; + } + + if( pCS->uPri ) + { + if ( coCheckStatus(tPri.tCrPri.wConnId) ) + ( *coFsmFuncSuit[pCS->uSide][pCS->uCState] ) ( tPri.tCrPri.wConnId ); + else{ + coFreeCS(tPri.tCrPri.wConnId); + } + } + pCS->uPri = 0; + } + + for ( wConnId = 0; wConnId < CO_CS_MPORT; wConnId++ ) + { + pCS = &pSp->tCo.tCSInst[wConnId]; + + if( CO_STATUS_INIT == pCS->uCState || !coCheckCS ( wConnId, pCS->uCState, pCS->uSide ) ) + { + continue; + } + + if( pCS->uPri ) + { + if ( coCheckStatus(tPri.tCrPri.wConnId) ) + ( *coFsmFuncSuit[pCS->uSide][pCS->uCState] ) ( wConnId ); + else{ + coFreeCS(tPri.tCrPri.wConnId); + } + } + pCS->uPri = 0; + } +} diff --git a/omc/plat/sccp/src/scoc_func.c b/omc/plat/sccp/src/scoc_func.c new file mode 100644 index 0000000..2d254bd --- /dev/null +++ b/omc/plat/sccp/src/scoc_func.c @@ -0,0 +1,931 @@ +////////////////////////////////////////////////// +//Title : scoc_if.c +//Auhtor : Liu Wei +//Desc : SCOC interface implementation +//Created : 2007-05-07 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/sccp_pub.h" +#include "./include/scoc_if.h" +#include "./include/sccp_func.h" + +/* by simon at 23/9/25 */ +extern DWORD ExistIP[64]; +extern DWORD ExistIPNum; +extern SCOC_BUF ScocBuf; +extern LOCAL_SSN LocalSSN[256]; +extern u8 ExistSSN[64]; +extern u8 ExistSSNNum; +extern struct _dpc2sls +{ + int dpc; + u8 sls; +} dpc2sls[256]; // used for sequence control, add by Roy Jiang, 2007-09-17 +extern SCCP_OPT SCCP_Param; +extern u8 MNP_Flag[2]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern int RelatedSPCNum; +extern RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; +extern GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern SCCP_Capture_Buf SCCPCapBuf; + +/* by simon at 23/9/26 */ +SP_Entity tSpEntity; +SP_Entity *pSp; + +void spWatchDogStatic ( u8 uDebugStaticMask ); + +void coInit ( u32 sysID, u32 localIP, u32 alterIP ) +{ + pSp = &tSpEntity; + + memset ( pSp, 0, sizeof ( SP_Entity ) ); + spPoolInit ( ); + pSp->dLocalIP = localIP; + pSp->dAlterIP = alterIP; + pSp->dSysID = sysID + 1; +} + +void cr2coFailHandle ( Intra_Msg * pIntraMsg, u8 uAnsiFlag, u8 uMsgtype ) +{ + Intra_Msg tCo2CrMsg; + + memset ( &tCo2CrMsg, 0, sizeof ( Intra_Msg ) ); + switch ( uMsgtype ) + { + case SP_MSG_RLSD: + pIntraMsg->cause = REA_PCREF_IS; + case SP_MSG_RLC: + memcpy ( &tCo2CrMsg.aDLR, &pIntraMsg->aSLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aSLR, &pIntraMsg->aDLR, SP_REF_LEN ); + break; + case SP_MSG_ERR: + tCo2CrMsg.cause = REA_PDISC_IS; + break; + case SP_MSG_CREF: + tCo2CrMsg.cause = REA_PCREF_LE; + break; + default: + WxcAssert ( 0, "cr2coFailHandle internal error" ); + break; + } + + tCo2CrMsg.msgsource = FROM_SCOC; + tCo2CrMsg.msgtype = uMsgtype; + tCo2CrMsg.msgclass = pIntraMsg->msgclass; + tCo2CrMsg.NetID = pIntraMsg->CDA.NetID; + tCo2CrMsg.OPC = SCCP_Param.spc[tCo2CrMsg.NetID]; + + //scrc_route ( &tCo2CrMsg, uAnsiFlag ); + + tCo2CrMsg.CDA.DPC = tCo2CrMsg.DPC = pIntraMsg->OPC; + + tCo2CrMsg.SLS = pIntraMsg->SLS; + tCo2CrMsg.CDA.ip = 0xffffffff; + send_msg ( &tCo2CrMsg, uAnsiFlag); + spWatchDogStatic ( CO_TO_CR ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int cr2co ( Intra_Msg * pIntraMsg, u8 uAnsiFlag ) +{ + int nRet; + char *pStr; + SP_PriPoolEle pPri; + + spWatchDogStatic ( CR_TO_CO_APT ); + + WxcAssert ( pIntraMsg->msgtype < SP_MSG_MAX, "SCCP cr2co unexpected msgtype" ); + + spGetMsgStr ( pIntraMsg->msgtype, pStr ); + + switch ( pIntraMsg->msgtype ) + { + case SP_MSG_CR: +// if( ( coGetConnId ( pIntraMsg->aSLR ) >= 0 ) || ( ( nRet = coNewConnId ( R_CR ) ) < 0 ) ) + if( (nRet = coNewConnId ( R_CR )) < 0 ) + { + spLogDebug ( SCCPDB_ERR, "[cr2co]No resourece for %s", pStr ); + cr2coFailHandle ( pIntraMsg, uAnsiFlag, SP_MSG_CREF ); + return 0 ; + } + break; + case SP_MSG_RLSD: + nRet = coGetConnId ( pIntraMsg->aDLR ); + if( nRet < 0 ) + { + spLogDebug ( SCCPDB_ERR, "[sr2co]recv %s msg in init state, cr2co return error ", pStr ); + cr2coFailHandle ( pIntraMsg, uAnsiFlag, SP_MSG_RLC ); + return 0 ; + } + break; + case SP_MSG_RF: + nRet = coGetConnId ( pIntraMsg->aDLR ); + if( nRet < 0 ) + { + spLogDebug ( SCCPDB_ERR, "[sr2co]recv RF msg in init state, co2cr return cref ", pStr ); + cr2coFailHandle ( pIntraMsg, uAnsiFlag, SP_MSG_CREF ); + return 0 ; + } + break; + case SP_MSG_IT: + nRet = coGetConnId ( pIntraMsg->aDLR ); + if( nRet < 0 ) + { + spLogDebug ( SCCPDB_ERR, "[sr2co]recv IT msg in init state,discard " ); + cr2coFailHandle ( pIntraMsg, uAnsiFlag, SP_MSG_RLSD ); + return 0 ; + } + break; + case SP_MSG_RLC: + nRet = coGetConnId ( pIntraMsg->aDLR ); + if( nRet < 0 ) + return 0 ; + break; + default: + nRet = coGetConnId ( pIntraMsg->aDLR ); + if( nRet < 0 ) + { + spLogDebug ( SCCPDB_ERR, "[sr2co]recv %s msg in init state", pStr ); + if( memcmp ( pIntraMsg->aSLR, "/0/0/0", SP_REF_LEN ) ) + { + spLogDebug ( SCCPDB_ERR, "[sr2co]recv %s msg in init state, co2cr return error ", pStr ); +// cr2coFailHandle ( pIntraMsg, uAnsiFlag, SP_MSG_RLSD ); + } + return 0 ; + } + break; + } + pPri.tCrPri.wConnId = nRet; + pPri.tCrPri.uUiPri = pIntraMsg->msgtype + SPUI_PRI_MAX; + pPri.tCrPri.uAnsiFlag = uAnsiFlag; + memcpy ( &pPri.tCrPri.tIntraMsg, pIntraMsg, sizeof ( Intra_Msg ) ); + + spPoolPut ( &pPri, pInCoPool ); + spWatchDogStatic ( CR_TO_CO ); + return 1; + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void co2cr ( u16 wConnId, u8 uMsgType ) +{ + CO_ConnSection *pCS; + Intra_Msg tCo2CrMsg; + + spWatchDogStatic ( CO_TO_CR_APT ); + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP co2cr unexpected connection id" ); + WxcAssert ( uMsgType < SP_MSG_MAX, "SCCP cr2co unexpected msgtype" ); + + pCS = &pSp->tCo.tCSInst[wConnId]; + + memset ( &tCo2CrMsg, 0, sizeof ( Intra_Msg ) ); + tCo2CrMsg.msgsource = FROM_SCOC; + tCo2CrMsg.msgtype = uMsgType; + tCo2CrMsg.msgclass = pCS->uClass; + tCo2CrMsg.NetID = pCS->uNetId; + + switch ( uMsgType ) + { + case SP_MSG_CR: + + tCo2CrMsg.msglen = 0; + + if( pCS->tUD.uDataLen ) + { + tCo2CrMsg.msglen = pCS->tUD.uDataLen % 256; + memcpy ( &tCo2CrMsg.data, pCS->tUD.aUserData, tCo2CrMsg.msglen ); + } + memcpy( &tCo2CrMsg.CDA , &pCS->tCDA , sizeof(SCCP_ADDR) ); + tCo2CrMsg.CGA.NetID = tCo2CrMsg.CDA.NetID = tCo2CrMsg.NetID ; + WxcAssert ( tCo2CrMsg.NetID <= 3, "co2cr: NetID is error " ); + tCo2CrMsg.OPC = SCCP_Param.spc[tCo2CrMsg.NetID]; + tCo2CrMsg.CDA.DPC = tCo2CrMsg.DPC = pCS->nDPC; + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + tCo2CrMsg.SLS = pCS->uSLS; + scrc_route ( &tCo2CrMsg, pCS->uAnsiFlag ); + spWatchDogStatic ( CO_TO_CR ); + return; + case SP_MSG_CC: + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + break; + case SP_MSG_CREF: + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + tCo2CrMsg.cause = pCS->eREA; + break; + case SP_MSG_RLSD: + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + tCo2CrMsg.cause = pCS->eREA; + break; + case SP_MSG_RLC: + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + break; + case SP_MSG_DT1: + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + tCo2CrMsg.EOD = 0; + tCo2CrMsg.msglen = 0; + if( pCS->tUD.uDataLen ) + { + tCo2CrMsg.msglen = pCS->tUD.uDataLen % 256; + memcpy ( &tCo2CrMsg.data, pCS->tUD.aUserData, tCo2CrMsg.msglen ); + } + break; + case SP_MSG_IT: + memcpy ( &tCo2CrMsg.aSLR, &pCS->aSLR, SP_REF_LEN ); + memcpy ( &tCo2CrMsg.aDLR, &pCS->aDLR, SP_REF_LEN ); + break; + case SP_MSG_ERR: + spLogDebug ( SCCPDB_ERR, "Need to supported SP_MSG_ERR now!" ); + break; + case SP_MSG_DT2: + case SP_MSG_AK: + case SP_MSG_ED: + case SP_MSG_EA: + case SP_MSG_RSR: + case SP_MSG_RSC: + spLogDebug ( SCCPDB_ERR, "do not supported now!" ); + break; + } + + tCo2CrMsg.CGA.NetID = tCo2CrMsg.CDA.NetID = tCo2CrMsg.NetID ; + tCo2CrMsg.OPC = SCCP_Param.spc[tCo2CrMsg.NetID]; + if( pCS->uSide == CO_INST_SIDE_ORG ) + tCo2CrMsg.CDA.DPC = tCo2CrMsg.DPC = pCS->nDPC; + else if( pCS->uSide == CO_INST_SIDE_DST ) + tCo2CrMsg.CDA.DPC = tCo2CrMsg.DPC = pCS->nOPC; + + tCo2CrMsg.SLS = pCS->uSLS; + WxcAssert ( tCo2CrMsg.NetID <= 3, "co2cr: NetID is error " ); + tCo2CrMsg.OPC = SCCP_Param.spc[tCo2CrMsg.NetID]; + tCo2CrMsg.CDA.ip = 0xffffffff; + send_msg ( &tCo2CrMsg, pCS->uAnsiFlag); + spWatchDogStatic ( CO_TO_CR ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void co2ul ( u16 wConnId, u8 uPri ) +{ + char *pStr; + CO_ConnSection *pCS; + SP_UiPriUnion *pUnPri; + SP_PriPoolEle tPoolEle, *pPri; + + spWatchDogStatic ( CO_SUBMIT_UL_APT ); + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP co2cr unexpected connection id" ); + + pPri = &tPoolEle; + pUnPri = ( SP_UiPriUnion * ) & pPri->tUiPri.tPriUnion; + + pCS = &pSp->tCo.tCSInst[wConnId]; + pPri->tUiPri.uUiPri = uPri; + pPri->tUiPri.uAnsiFlag = pCS->uAnsiFlag; + pPri->tUiPri.wConnId = wConnId; + + spGetUlPrimitiveStr ( uPri, pStr ); + + switch ( uPri ) + { + case N_UNITDATA_IND: + case N_NOTICE_IND: + spLogDebug ( SCCPDB_ERR, "SP=>UL: Unsupported UDT primitive now :%s", pStr ); + break; + case N_CONNECT_IND: + pUnPri->tPriNConnInd.tUD.uDataLen = 0; + if( pCS->tUD.uDataLen ) + { + pUnPri->tPriNConnInd.uOptFlag = 0x04; + memcpy ( &pUnPri->tPriNConnInd.tUD, &pCS->tUD, sizeof ( SP_UD ) ); + } + else + pUnPri->tPriNConnInd.uOptFlag = 0; + memcpy ( &pUnPri->tPriNConnInd.tCDA, &pCS->tCDA, sizeof ( SCCP_ADDR ) ); + memcpy ( &pUnPri->tPriNConnInd.aSLR, &pCS->aDLR, SP_REF_LEN ); + pUnPri->tPriNConnInd.uSLS = pCS->uSLS; + pUnPri->tPriNConnInd.OPC = pCS->nOPC; + pUnPri->tPriNConnInd.NetID = pCS->uNetId; + break; + case N_CONNECT_CFM: + pUnPri->tPriNConnCfm.tUD.uDataLen = 0; + if( pCS->tUD.uDataLen ) + { + pUnPri->tPriNConnCfm.uOptFlag = 0x04; + memcpy ( &pUnPri->tPriNConnCfm.tUD, &pCS->tUD, sizeof ( SP_UD ) ); + } + else + pUnPri->tPriNConnCfm.uOptFlag = 0; + break; + case N_DISCONNECT_IND: + pUnPri->tPriNDisconnInd.tUD.uDataLen = 0; + if( pCS->tUD.uDataLen ) + { + pUnPri->tPriNDisconnInd.uOptFlag = 0x04; + memcpy ( &pUnPri->tPriNDisconnInd.tUD, &pCS->tUD, sizeof ( SP_UD ) ); + } + else + pUnPri->tPriNDisconnInd.uOptFlag = 0; + pUnPri->tPriNDisconnInd.eOR = pCS->eOR; + pUnPri->tPriNDisconnInd.eREA = pCS->eREA; + break; + case N_DATA_IND: + memcpy ( &pUnPri->tPriNDataInd.tUD, &pCS->tUD, sizeof ( SP_UD ) ); + break; + case N_DATAAK_IND: + case N_EDATA_IND: + case N_RESET_IND: + case N_RESET_CFM: + case N_INFORM_IND: + case RELAY: + spLogDebug ( SCCPDB_ERR, "SP=>UL: Unsupported the primitive now :%s", pStr ); + break; + default: + spLogDebug ( SCCPDB_ERR, "SP=>UL: Unknow primtive :%s", pStr ); + break; + } + + spShowPrimitive ( &pPri->tUiPri, 0 ); + spWatchDogStatic ( WDS_RECV_PRI ); + + spPoolPut ( &tPoolEle, pOutCoPool ); + spWatchDogStatic ( CO_SUBMIT_UL ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void co2scmg ( ) +{ + +} + +void co2co ( u16 wConnId, u8 uPri ) +{ + SP_PriPoolEle pPri; + + memset ( &pPri, 0, sizeof ( SP_PriPoolEle ) ); + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP coTimerOut unexpected connection id" ); + WxcAssert ( ( uPri > SPCR_PRI_MAX && uPri < SPTM_PRI_MAX ), "SCCP coTimerOut unexpected msgtype" ); + + pPri.tUiPri.uUiPri = uPri; + pPri.tUiPri.wConnId = wConnId; + + spPoolPut ( &pPri, pInCoPool ); +} + +int spCheckAudit ( ) +{ + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coAssignSLS ( u8 wConnId ) +{ + return ( wConnId & 0x0F ); +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + void coAssignLR ( u16 wConnId, u8 * pLR ) +{ + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP coNewCS unexpected connection id" ); + + *( pLR ) = pSp->dSysID; + *( pLR + 1 ) = wConnId >> 8; + *( pLR + 2 ) = wConnId & 0xFF; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coAssignClass ( u8 wConnId ) +{ + //do not support class 3 now + return 2; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coAssignCredit ( u8 wConnId ) +{ + //credit not supported now + return 0; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coNewCS ( u16 wConnId, SCCP_ADDR * pAddr ) +{ + CO_ConnSection *pCS; + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP coNewCS unexpected connection id" ); + + pCS = &pSp->tCo.tCSInst[wConnId]; + pCS->uSLS = coAssignSLS ( wConnId ); + coAssignLR ( wConnId, pCS->aSLR ); + memcpy ( &pCS->tCDA, pAddr, sizeof ( SCCP_ADDR ) ); + pCS->uClass = coAssignClass ( wConnId ); + pCS->uCredit = coAssignCredit ( wConnId ); + + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coFreeCS ( u16 wConnId ) +{ + CO_DataBlock *pCo; + CO_ConnSection *pCS = &pSp->tCo.tCSInst[wConnId]; + + pCo = &pSp->tCo; + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP coNewCS un expected connection id" ); + memset ( pCS, 0, sizeof ( CO_ConnSection ) ); + pCo->wConnIdCount--; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// +void coFillCS ( SP_PriPoolEle * pPri ) +{ + SP_CrPriPara *pCrPri; + CO_ConnSection *pCS; + + pCrPri = ( SP_CrPriPara * ) & pPri->tCrPri; + + WxcAssert ( ( pCrPri->wConnId < CO_CS_MPORT ), "SCCP coFillCS unexpect connection id" ); + WxcAssert ( ( pCrPri->uUiPri < SPTM_PRI_MAX ), "SCCP coFillCS unexpect primitive" ); + + pCS = &pSp->tCo.tCSInst[pCrPri->wConnId]; + + pCS->uPri = pCrPri->uUiPri; + pCS->uAnsiFlag = pCrPri->uAnsiFlag; + + if( pCS->uPri > SPCR_PRI_MAX ) //Internal primitive + { + return; + } + else if( pCS->uPri > SPUI_PRI_MAX ) //CR/SCMG message primitive + { + Intra_Msg *pMsg; + + pMsg = &pCrPri->tIntraMsg; + if( pMsg->msglen ) + { + WxcAssert ( pMsg->msglen < 255, "coFillCS Message length overflow" ); + pCS->tUD.uDataLen = pMsg->msglen % 256; + memcpy ( &pCS->tUD.aUserData, &pMsg->data, pCS->tUD.uDataLen ); + } + else + pCS->tUD.uDataLen = 0; + + switch ( pCS->uPri ) + { + case R_CR: /* connection request */ + memcpy ( &pCS->tCDA, &pMsg->CDA, sizeof ( SCCP_ADDR ) ); + //memcpy ( &pCS->tCGA, &pMsg->CGA, sizeof ( SCCP_ADDR ) ); + pCS->nDPC = pMsg->DPC; + pCS->nOPC = pMsg->OPC; + pCS->uNetId = pMsg->NetID; + pCS->uSLS = pMsg->SLS; + memcpy ( &pCS->aDLR, &pMsg->aSLR, SP_REF_LEN ); + break; + case R_CR2: /* connection request type 2 */ + break; + case R_CC: /* connection confirm */ + pCS->uClass = pMsg->msgclass; + memcpy ( &pCS->aDLR, &pMsg->aSLR, SP_REF_LEN ); + break; + case R_CREF: /* connection refused */ + pCS->eREA = pMsg->cause; + break; + case R_RLSD: /* release request */ + pCS->eREA = pMsg->cause; + break; + case R_RLC: /* release confirm */ + break; + case R_DT1: /* Data Form 1 */ + break; + case R_DT2: /* Data Form 2 */ + break; + case R_AK: /* Data acknowledge */ + break; + case R_ED: /* Expedited data */ + break; + case R_EA: /* Expedited data acknowledge */ + break; + case R_RSR: /* Reset request */ + break; + case R_RSC: /* Reset confirm */ + break; + case R_ERR: /* PDU error */ + break; + case R_IT: /* Inactivity test */ + break; + case R_RF: /* Routing Fail */ + break; + case R_RLS_ERR: /* Release err */ + break; + default: + break; + } + } + else //upper layer primitive + { + SP_UiPriUnion *pUnPri; + + pUnPri = ( SP_UiPriUnion * ) & pPri->tUiPri.tPriUnion; + switch ( pCS->uPri ) + { + case N_CONNECT_REQ: + memcpy ( &pCS->tCDA, &pUnPri->tPriNConnReq.tCDA, sizeof ( SCCP_ADDR ) ); + if( pUnPri->tPriNConnReq.uOptFlag & 0x08 ) + { + memcpy ( &pCS->tUD, &pUnPri->tPriNConnReq.tUD, sizeof ( SP_UD ) ); + } + pCS->nDPC = pCS->tCDA.DPC; + pCS->uNetId = pUnPri->tPriNConnReq.tCDA.NetID; + break; + case N_CONNECT_RSP: + break; + case N_DISCONNECT_REQ: + pCS->eREA = pUnPri->tPriNDisconnReq.eREA; + pCS->eOR = NSU; + break; + case N_DATA_REQ: + memcpy ( &pCS->tUD, &pUnPri->tPriNDataReq.tUD, sizeof ( SP_UD ) ); + break; + case N_DATAAK_REQ: + case N_EDATA_REQ: + case N_RESET_REQ: + case N_RESET_RSP: + case N_INFORM_REQ: + break; + default: + break; + } + } +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// +int coCheckCS ( u16 wConnId, u8 uCState, u8 uSide ) +{ +#ifdef DEBUG + WxcAssert ( ( uCState < CO_STATUS_MAX ), "SCCP coFsm unexpect connection section state" ); + + WxcAssert ( ( uSide < CO_INST_SIDE_MAX ), "SCCP coFsm unexpect connection section state" ); +#else + if( uCState >= CO_STATUS_MAX ) + { + spLogStateError ( wConnId, ERR_FSM_DISCARD ); + //spCoRecover ( wConnId, CO_FATAL_STATE ); + return 0; + } + + if( uSide >= CO_INST_SIDE_MAX ) + { + spLogStateError ( wConnId, ERR_FSM_UNEXPECT_SIDE ); + //spCoRecover ( wConnId, CO_FATAL_SIDE ); + return 0; + } +#endif + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coTimerOut ( u16 wConnId, u8 uPri ) +{ + SP_PriPoolEle pPri; + + WxcAssert ( wConnId < CO_CS_MPORT, "SCCP coTimerOut unexpected connection id" ); + WxcAssert ( ( uPri > SPCR_PRI_MAX && uPri < SPTM_PRI_MAX ), "SCCP coTimerOut unexpected msgtype" ); + + + spLogTimerOut( wConnId , uPri ); + memset ( &pPri, 0, sizeof ( SP_PriPoolEle ) ); + + pPri.tUiPri.uUiPri = uPri; + pPri.tUiPri.wConnId = wConnId; + + spPoolPut ( &pPri, pInCoPool ); + +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void coTimerMng ( ) +{ + u16 wConnId; + CO_ConnSection *pCS; + CO_Timer *pTmSet; + // u8 uPri; + + + for ( wConnId = 0; wConnId < CO_CS_MPORT; wConnId++ ) + { + pCS = &pSp->tCo.tCSInst[wConnId]; + + if( CO_STATUS_INIT == pCS->uCState ) + { + continue; + } + + pTmSet = &pCS->tmSCOC; + + if( pTmSet->tmConnEst && ++pTmSet->tmConnEst > T_CONNEST_MAX ) + { + pTmSet->tmConnEst = 0; + coTimerOut ( wConnId, T_CONNEST_OUT ); + } + if( pTmSet->tmIas && ++pTmSet->tmIas > T_IAS_MAX ) + { + pTmSet->tmIas = 0; + coTimerOut ( wConnId, T_IAS_OUT ); + } + if( pTmSet->tmIar && ++pTmSet->tmIar > T_IAR_MAX ) + { + pTmSet->tmIar = 0; + coTimerOut ( wConnId, T_IAR_OUT ); + } + if( pTmSet->tmRepeatRel && ++pTmSet->tmRepeatRel > T_REPEATE_RLS_MAX ) + { + pTmSet->tmRepeatRel = 0; + coTimerOut ( wConnId, T_REPEATE_RLS_OUT ); + } + if( pTmSet->tmRel && ++pTmSet->tmRel > T_RLS_MAX ) + { + pTmSet->tmRel = 0; + coTimerOut ( wConnId, T_RLS_OUT ); + } + if( pTmSet->tmReset && ++pTmSet->tmReset > T_RESET_MAX ) + { + pTmSet->tmReset = 0; + coTimerOut ( wConnId, T_RESET_OUT ); + } + if( pTmSet->tmGuard && ++pTmSet->tmGuard > T_GUARD_MAX ) + { + pTmSet->tmGuard = 0; + coTimerOut ( wConnId, T_GUARD_OUT ); + } + if( pTmSet->tmInternal && ++pTmSet->tmInternal > T_INTERNAL_MAX ) + { + pTmSet->tmInternal = 0; + coTimerOut ( wConnId, T_INTERNAL_OUT ); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coNewConnId ( u8 uPri ) +{ + static u16 wConnId = 0; + CO_DataBlock *pCo; + CO_ConnSection *pCS; + u16 tmpConnId = wConnId; + + pCo = &pSp->tCo; + + if( pCo->wConnIdCount >= CO_CS_MPORT ) + { + spLogDebug ( SCCPDB_ERR, "No resource for new connection" ); + return -1; + } + + WxcAssert ( ( uPri == N_CONNECT_REQ || uPri == R_CR ), "Unexpect primitive while allocating new connection" ); + + // for ( wConnId = 0; wConnId < CO_CS_MPORT; wConnId++ ) + while (++wConnId != tmpConnId) + { + if (wConnId >= CO_CS_MPORT) + wConnId = 0; + + pCS = &pSp->tCo.tCSInst[wConnId]; + + if( CO_STATUS_INIT == pCS->uCState ) + { + memset ( pCS, 0, sizeof ( CO_ConnSection ) ); + pCS->uCState = CO_STATUS_IDLE; + + if( R_CR == uPri ) + { + pCS->uSide = CO_INST_SIDE_DST; + } + else if( N_CONNECT_REQ == uPri ) + { + pCS->uSide = CO_INST_SIDE_ORG; + } + pCo->wConnIdCount++; + return wConnId; + } + } + + spLogDebug ( SCCPDB_ERR, "No resource for new connection" ); + return -1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +int coGetConnId ( u8 *pSLR ) +{ + u16 wConnId; + CO_ConnSection *pCS; + + for ( wConnId = 0; wConnId < CO_CS_MPORT; wConnId++ ) + { + pCS = &pSp->tCo.tCSInst[wConnId]; + if( memcmp ( pSLR, "\0\0\0", SP_REF_LEN ) && !memcmp ( &pCS->aSLR, pSLR, SP_REF_LEN ) ) + { + return wConnId; + } + } + return -1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +inline int coCheckConnId ( SP_UiPriPara * pUiPriParam ) +{ + WxcAssert ( ( pUiPriParam->wConnId < CO_CS_MPORT ), "SCCP coCheckConnId unexpect connection id" ); + + if( pSp->tCo.tCSInst[pUiPriParam->wConnId].uCState > 0 ) + { + return 1; + } + return 0; +} + +/////////////////////////////////////////////////////////////////////////// +// Name : coCheckResource /// +// Function : Check Resouce for a coming connection /// +// Return : Have been check in cr2co function, so always return 1 /// +/////////////////////////////////////////////////////////////////////////// +inline int coCheckResource ( ) +{ + //Have been check in cr2co function, so always return 1 + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spWatchDogStatic ( u8 uDebugStaticMask ) +{ + CO_DebugStatic *pDs = &pSp->tCo.tCoDebugStatic; + + switch ( uDebugStaticMask ) + { + case GET_IN_POOL: + pDs->dGetInPool++; + break; + case PUT_IN_POOL: + pDs->dPutInPool++; + break; + case READ_IN_POOL: + pDs->dReadInPool++; + break; + case WRITE_IN_POOL: + pDs->dWriteInPool++; + break; + case GET_OUT_POOL: + pDs->dGetOutPool++; + break; + case PUT_OUT_POOL: + pDs->dPutOutPool++; + break; + case PUT_ELE_APT: + pDs->dPutEleApt++; + break; + case PUT_ELE_SUC: + pDs->dPutEleSuc++; + break; + case UL_POST_CO_APT: + pDs->dUlPostCoApt++; + break; + case UL_POST_CO: + pDs->dUlPostCo++; + break; + case CO_SUBMIT_UL_APT: + pDs->dCoSubmitUlApt++; + break; + case CO_SUBMIT_UL: + pDs->dCoSubmitUl++; + break; + case CO_TO_CR_APT: + pDs->dCo2CrApt++; + break; + case CO_TO_CR: + pDs->dCo2Cr++; + break; + case CR_TO_CO_APT: + pDs->dCr2CoApt++; + break; + case CR_TO_CO: + pDs->dCr2Co++; + break; + case SP_TIMER_OUT: + pDs->dTimerOut++; + break; + default: + break; + } +} + +//add by Roy for dual server message redirect +void coRedirect(SP_UiPriPara * pUiPriParam) +{ + Intra_Msg tmpMsg; + + memset (&tmpMsg, 0, sizeof(Intra_Msg)); + tmpMsg.msglen = 0; + + if (pUiPriParam->uUiPri == N_UNITDATA_IND) + { + if( pUiPriParam->tPriUnion.tPriNUDataInd.tUD.uDataLen ) + { + tmpMsg.msglen = pUiPriParam->tPriUnion.tPriNUDataInd.tUD.uDataLen % 256; + memcpy ( &tmpMsg.data, pUiPriParam->tPriUnion.tPriNUDataInd.tUD.aUserData, tmpMsg.msglen ); + } + memcpy( &tmpMsg.CDA , &pUiPriParam->tPriUnion.tPriNUDataInd.tCDA , sizeof(SCCP_ADDR) ); + memcpy( &tmpMsg.CGA , &pUiPriParam->tPriUnion.tPriNUDataInd.tCGA , sizeof(SCCP_ADDR) ); + WxcAssert ( tmpMsg.NetID <= 3, "co2cr: NetID is error " ); + tmpMsg.OPC = pUiPriParam->tPriUnion.tPriNUDataInd.tCGA.DPC; + tmpMsg.SLS = pUiPriParam->tPriUnion.tPriNUDataInd.uSLS; + tmpMsg.msgtype = UDT_MSG; + } + else{ + if( pUiPriParam->tPriUnion.tPriNConnInd.tUD.uDataLen ) + { + tmpMsg.msglen = pUiPriParam->tPriUnion.tPriNConnInd.tUD.uDataLen % 256; + memcpy ( &tmpMsg.data, pUiPriParam->tPriUnion.tPriNConnInd.tUD.aUserData, tmpMsg.msglen ); + } + memcpy( &tmpMsg.CDA , &pUiPriParam->tPriUnion.tPriNConnInd.tCDA , sizeof(SCCP_ADDR) ); + memcpy ( &tmpMsg.aSLR, &pUiPriParam->tPriUnion.tPriNConnInd.aSLR, SP_REF_LEN ); + WxcAssert ( tmpMsg.NetID <= 3, "co2cr: NetID is error " ); + tmpMsg.OPC = pUiPriParam->tPriUnion.tPriNConnInd.OPC; + tmpMsg.SLS = pUiPriParam->tPriUnion.tPriNConnInd.uSLS; + tmpMsg.msgtype = CR_MSG; + + //remove the connection + memset(&pSp->tCo.tCSInst[pUiPriParam->wConnId], 0, sizeof(CO_ConnSection)); + pSp->tCo.wConnIdCount--; + } + tmpMsg.NetID = tmpMsg.CDA.NetID; + tmpMsg.CDA.ip = pSp->dAlterIP; + tmpMsg.msgsource = FROM_MTP; + tmpMsg.redirectFlag = 1; + + spLogDebug ( SCCPDB_TIME, "AIF ==> SCCP : Message redirect request" ); + send_msg ( &tmpMsg, pUiPriParam->uAnsiFlag); +} diff --git a/omc/plat/sccp/src/scoc_if.c b/omc/plat/sccp/src/scoc_if.c new file mode 100644 index 0000000..0202763 --- /dev/null +++ b/omc/plat/sccp/src/scoc_if.c @@ -0,0 +1,307 @@ +////////////////////////////////////////////////// +//Title : scoc_if.c +//Auhtor : Liu Wei +//Desc : SCOC interface implementation +//Created : 2007-05-07 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/sccp_pub.h" + +#ifdef LOOSE_COUPLING_MODE //Loose coupling mode + +extern inline int coCheckConnId ( SP_UiPriPara * pUiPriParam ); +extern void coRedirect(SP_UiPriPara * pUiPriParam); + +/* by simon at 23/9/25 */ +extern DWORD ExistIP[64]; +extern DWORD ExistIPNum; +extern SCOC_BUF ScocBuf; +extern LOCAL_SSN LocalSSN[256]; +extern u8 ExistSSN[64]; +extern u8 ExistSSNNum; +extern struct _dpc2sls +{ + int dpc; + u8 sls; +} dpc2sls[256]; // used for sequence control, add by Roy Jiang, 2007-09-17 +extern SCCP_OPT SCCP_Param; +extern u8 MNP_Flag[2]; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern int RelatedSPCNum; +extern RL_SPC RelatedSPC[SCCP_RLSPC_NUM]; +extern GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM]; +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern SCCP_Capture_Buf SCCPCapBuf; + +/////////////////////////////////////////////////////////////////////////// +// +// Name : PostSp +// Function : Upper layer post request/response primitive to sccp +// Parameter: pUiPriParam [sccp UL primitive buffer pointer] +// Note : Sccp Connid is implicit returned in "pUiPriParam" buffer +// : while N-Connect requesing +// Return : 0 Post Fail 1 Post Successful +// +/////////////////////////////////////////////////////////////////////////// + +int PostSp ( SP_UiPriPara * pUiPriParam ) +{ + int nRet; + u8 *pPriStr; + + spShowPrimitive ( pUiPriParam, 1 ); + + spWatchDogStatic ( UL_POST_CO_APT ); + + switch ( pUiPriParam->uUiPri ) + { + case N_UNITDATA_REQ: + { + SCLC_MSG tClMsg; + + tClMsg.msglen = pUiPriParam->tPriUnion.tPriNUDataReq.tUD.uDataLen; + memcpy ( &tClMsg.msg, &pUiPriParam->tPriUnion.tPriNUDataReq.tUD.aUserData, tClMsg.msglen ); + memcpy ( &tClMsg.src_addr, &pUiPriParam->tPriUnion.tPriNUDataReq.tCGA, sizeof ( SCCP_ADDR ) ); + memcpy ( &tClMsg.dst_addr, &pUiPriParam->tPriUnion.tPriNUDataReq.tCDA, sizeof ( SCCP_ADDR ) ); + tClMsg.src_addr.DPC = SCCP_Param.spc[tClMsg.src_addr.NetID]; + tClMsg.sequence_control = 0; + sclc_send ( &tClMsg ); + spWatchDogStatic ( UL_POST_CO ); + return 1; + } + //break; + case N_UNITDATA_IND: + case N_CONNECT_IND: + //redirect to alternative server, add by Roy + coRedirect(pUiPriParam); + spWatchDogStatic ( UL_POST_CO ); + return 1; + break; + case N_CONNECT_REQ: + nRet = coNewConnId ( N_CONNECT_REQ ); + if( nRet < 0 ) + { + spLogDebug ( SCCPDB_ERR, "No resouces available !\n" ); + return 0; + } + pUiPriParam->wConnId = nRet; + break; + case N_CONNECT_RSP: + case N_DISCONNECT_REQ: + case N_DATA_REQ: + if( !coCheckConnId ( pUiPriParam ) ) + { + spLogDebug ( SCCPDB_ERR, "Invalid SCCP connection ID : %d", pUiPriParam->wConnId ); + return 0; + } + break; + case N_DATAAK_REQ: + case N_EDATA_REQ: + case N_RESET_REQ: + case N_RESET_RSP: + case N_INFORM_REQ: + spGetUlPrimitiveStr ( pUiPriParam->uUiPri, pPriStr ); + spLogDebug ( SCCPDB_ERR, "Unsupported the primitive now :%s", pPriStr ); + return 0; + default: + spGetUlPrimitiveStr ( pUiPriParam->uUiPri, pPriStr ); + spLogDebug ( SCCPDB_ERR, "Invalid primivtive recieved :%s ", pPriStr ); + return 0; + } + + spWatchDogStatic ( UL_POST_CO ); + + { + SP_PriPoolEle tPoolEle; + + memset ( &tPoolEle, 0, sizeof ( SP_PriPoolEle ) ); + memcpy ( &tPoolEle.tUiPri, pUiPriParam, sizeof ( SP_UiPriPara ) ); + spPoolPut ( &tPoolEle, pInCoPool ); + } + + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// +// Name : SpSubmit +// Function : Upper layer fetch indicate/confirm primitive submited form sccp +// Parameter: pUiPriParam [sccp UL primitive buffer pointer] +// uUlSapId [upper layer sap id [0 tcap 1 pps 2 smsc 3 aif ] ] +// Return : 0 Fetch Fail 1 Fetch Successful +// +/////////////////////////////////////////////////////////////////////////// + +int SpSubmit ( SP_UiPriPara * pUiPriParam, u8 uUlSapId ) +{ + int nRet = 0; + + SCLC_MSG tClMsg; + + nRet = sclc_receive ( &tClMsg, uUlSapId ); + if( nRet ) + { + pUiPriParam->tPriUnion.tPriNUDataInd.uSLS = tClMsg.sls; + pUiPriParam->wConnId = 0xFFFF; + pUiPriParam->uUiPri = N_UNITDATA_IND; + pUiPriParam->tPriUnion.tPriNUDataInd.tUD.uDataLen = tClMsg.msglen; + memcpy ( &pUiPriParam->tPriUnion.tPriNUDataInd.tUD.aUserData, &tClMsg.msg, tClMsg.msglen ); + memcpy ( &pUiPriParam->tPriUnion.tPriNUDataInd.tCGA, &tClMsg.src_addr, sizeof ( SCCP_ADDR ) ); + memcpy ( &pUiPriParam->tPriUnion.tPriNUDataInd.tCDA, &tClMsg.dst_addr, sizeof ( SCCP_ADDR ) ); + return nRet; + } + + if( 3 == uUlSapId ) + { + SP_PriPoolEle tPoolEle; + + + nRet = spPoolGet ( &tPoolEle, pOutCoPool ); + memcpy ( pUiPriParam, &tPoolEle.tUiPri, sizeof ( SP_UiPriPara ) ); + + return nRet; + } + return nRet; +} + +#else + +/////////////////////Below is reserved, do not need to read///////////////////// + +#ifdef TIGHT_COUPING_MODE //Tight coupling mode + +#error "Do not support Tight coupling mode ,please use \"LOOSE_COUPLING_MODE\" flag \n" + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void Ul_Post_Sp ( SP_UiPriPara * pUiPriParam ) +{ + SP_UiPriUnion *pPriUn; + + pPriUn = &pUlPri->tPriUnion; + + switch ( pUiPriParam->uUi_Pri ) + { + case N_UNITDATA_REQ: //reserved for sclc + spUi_N_UnitDataReq ( &pPriUn->tPriNUDataReq.tCDA, &pPriUn->tPriNUDataReq.tCGA, &pPriUn->tPriNUDataReq.tSEQ, &pPriUn->tPriNUDataReq.tRO, &pPriUn->tPriNUDataReq.tUD ); + break; + + case N_CONNECT_REQ: + spUi_N_ConnectReq ( &pPriUn->tPriNConnReq.tCDA, &pPriUn->tPriNConnReq.tCGA, &pPriUn->tPriNConnReq.tRCS, &pPriUn->tPriNConnReq.tEDS ); + break; + + case N_CONNECT_RSP: + spUi_N_ConnectRsp ( &pPriUn->tPriNConnRsp.tRA, &pPriUn->tPriNConnRsp.tRCS, &pPriUn->tPriNConnRsp.tEDS ); + break; + + case N_DISCONNECT_REQ: + spUi_N_DisconnectReq ( &pPriUn->tPriNDisconnReq.tRA, &pPriUn->tPriNDisconnReq.tREA, &pPriUn->tPriNDisconnReq.tUC, pPriUn->tPriNDisconnReq.tCI ); + break; + + case N_DATA_REQ: + spUi_N_DataReq ( &pPriUn->tPriNDataReq.tCR, &pPriUn->tPriNDataReq.tUD, pPriUn->tPriNDataReq.tCI ); + break; + + case N_DATAAK_REQ: + spUi_N_DataAkReq ( pPriUn->tPriNDataAkReq.tCI ); + break; + + case N_EDATA_REQ: + spUi_N_EDataReq ( pPriUn->tPriNEDataReq.tCI, &pPriUn->tPriNEDataReq.tUD ); + break; + + case N_RESET_REQ: + spUi_N_ResetReq ( &pPriUn->tPriNResetReq.tREA, pPriUn->tPriNResetReq.tCI ); + break; + + case N_RESET_RSP: + spUi_N_ResetRsp ( pPriUn->tPriNResetRsp.tCI ); + break; + + case N_INFORM_REQ: + spUi_N_InformReq ( &pPriUn->tPriNInformReq.tREA, &pPriUn->tPriNInformReq.tQOS, pPriUn->tPriNInformReq.tCI ); + break; + + default: + spShowMsg ( SCCPDB_ERR, "SCCP <== AIF. UnKnow Primitive %s", GetUiPriStr ( pPriUn->uUi_Pri ) ); + return; + break; + + } + spShowMsg ( SCCPDB_AIF, "SCCP <== AIF. Primitive %s", GetUiPriStr ( pPriUn->uUi_Pri ) ); + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void Sp_Submit_Ul ( SP_UiPriPara * pUiPriParam ) +{ + switch ( Ui_Pri ) + { + case N_UNITDATA_IND: //reserved for sclc + + break; + + case N_NOTICE_IND: + + break; + + case N_CONNECT_IND: + + break; + + case N_CONNECT_CFM: + + break; + + case N_DISCONNECT_IND: + + break; + + case N_DATA_IND: + + break; + + case N_DATAAK_IND: + + break; + + case N_EDATA_IND: + + break; + + case N_RESET_IND: + + break; + + case N_RESET_CFM: + + break; + + case N_INFORM_IND: + + break; + + default: + + break; + + } + return 0; +} +#endif + +/////////////////////Above is reserved, do not need to read///////////////////// + +#endif diff --git a/omc/plat/sccp/src/scoc_pool.c b/omc/plat/sccp/src/scoc_pool.c new file mode 100644 index 0000000..1fed3f3 --- /dev/null +++ b/omc/plat/sccp/src/scoc_pool.c @@ -0,0 +1,227 @@ +////////////////////////////////////////////////// +//Title : pool.c +//Auhtor : Liu Wei +//Desc : List and Pool Queue struct implement +//Created : 2007-05-01 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +#include "./include/sccp_pub.h" + +/*@ignore@*/ +/////////////////////////////////////////////////////////////////////////// +// Reserved for Pool Test -- Start +/////////////////////////////////////////////////////////////////////////// +/* + #include "stdio.h" + #include "string.h" + #include "malloc.h" + + typedef struct SP_PriPoolEle + { + char ch; + } + SP_PriPoolEle; + */ +/////////////////////////////////////////////////////////////////////////// +// Reserved for Pool Test -- End +/////////////////////////////////////////////////////////////////////////// +#define SP_MAX_ELEMENT 512 + +CO_Pool tInCoPool; +CO_Pool *pInCoPool; +CO_Pool tOutCoPool; +CO_Pool *pOutCoPool; + +//add by roy jiang for a replacement of dynamic memory allocation +CO_PoolEle SpEleBuf[SP_MAX_ELEMENT]; + +void spPoolInit ( ) +{ + + pInCoPool = &tInCoPool; + pOutCoPool = &tOutCoPool; + memset ( pInCoPool, 0, sizeof ( CO_Pool ) ); + memset ( pOutCoPool, 0, sizeof ( CO_Pool ) ); + memset ( SpEleBuf, 0, sizeof ( CO_PoolEle ) * SP_MAX_ELEMENT ); + POOL_INIT ( &pInCoPool->tPoolHead ); + POOL_INIT ( &pOutCoPool->tPoolHead ); + + pInCoPool->pPoolHead = &pInCoPool->tPoolHead; + pOutCoPool->pPoolHead = &pOutCoPool->tPoolHead; + pOutCoPool->uMaxPoolSize = MAX_OUT_POOL; + pInCoPool->uMaxPoolSize = MAX_IN_POOL; +} + +static int busyCount = 0; + CO_PoolEle *spMallocEle() +{ + static int i = 0; + int j = i; + + if (busyCount >= SP_MAX_ELEMENT) + return NULL; + + while (++i != j) + { + if (i >= SP_MAX_ELEMENT) + i = 0; + + if (SpEleBuf[i].flag == 0) + { + busyCount++; + SpEleBuf[i].flag = 1; + pSp->tCo.tCoDebugStatic.dbusyElem = busyCount; + return &SpEleBuf[i]; + } + } + + return NULL; +} + +void spFreeEle(CO_PoolEle *elem) +{ + if (elem->flag != 0) + { + busyCount--; + pSp->tCo.tCoDebugStatic.dbusyElem = busyCount; + memset ( elem, 0, sizeof ( CO_PoolEle ) ); + } + return; +} + +int spPoolGet ( SP_PriPoolEle *pPri, CO_Pool *pCoPool ) +{ + CO_PoolEle *pPoolEle; + + spWatchDogStatic ( CO_GET_POOL ); + + if( pCoPool->uPoolCount <= 0 || ( POOL_EMPTY ( pCoPool->pPoolHead ) ) ) + { + //spLogDebug ( SCCPDB_ERR ,"SCCP get primitive pool fail ,empty" ); + return 0; + } + + memcpy ( pPri, &pCoPool->pPoolHead->pPoolFirst->tPri, sizeof ( SP_PriPoolEle ) ); + pPoolEle = pCoPool->pPoolHead->pPoolFirst; + POOL_REMOVE ( pCoPool->pPoolHead, pPoolEle, tPointer ); + pCoPool->uPoolCount--; + // free ( pPoolEle ); + spFreeEle (pPoolEle); + spWatchDogStatic ( CO_READ_POOL ); + + return 1; +} + +int spPoolPut ( SP_PriPoolEle * pPri, CO_Pool * pCoPool ) +{ + CO_PoolEle *pPoolEle; + + spWatchDogStatic ( PUT_ELE_APT ); + + if( pCoPool->uPoolCount > pCoPool->uMaxPoolSize ) + { + spLogDebug ( SCCPDB_ERR, "SCCP put Primitive Pool fail , pool full" ); + return 0; + } + +//commentted by roy jiang to disable dynamic memory allocation, 07-11-16 +// pPoolEle = ( CO_PoolEle * ) malloc ( sizeof ( CO_PoolEle ) ); + pPoolEle = spMallocEle(); + if( NULL == pPoolEle ) + { + spLogDebug ( SCCPDB_ERR, "SCCP put Primitive Pool fail ,allocate memery fail" ); + return 0; + } + + memcpy ( &pPoolEle->tPri, pPri, sizeof ( SP_PriPoolEle ) ); + POOL_INSERT_TAIL ( pCoPool->pPoolHead, pPoolEle, tPointer ); + pCoPool->uPoolCount++; + + spWatchDogStatic ( PUT_ELE_SUC ); + return 1; +} + +/////////////////////////////////////////////////////////////////////////// +// Reserved for Pool Test -- Start +/////////////////////////////////////////////////////////////////////////// +/* + FILE *fp; + + int main() + { + int nCh; + CO_PoolEle pOutGetPri; + CO_PoolEle pInGetPri; + CO_PoolEle pOutPutPri; + CO_PoolEle pInPutPri; + CO_PoolEle *pPri; + + fp = fopen("log.txt" ,"w+"); + if( NULL ==fp ) + { + return 0; + } + spPoolInit(); + + pOutGetPri.tPri.ch = pInGetPri.tPri.ch = '0'; + + for( nCh = 0 ; nCh < 32 ; nCh ++ ) + { + memset(&pOutGetPri , 0 , sizeof(CO_PoolEle)); + memset(&pInGetPri , 0 , sizeof(CO_PoolEle)); + memset(&pOutPutPri , 0 , sizeof(CO_PoolEle)); + memset(&pInPutPri , 0 , sizeof(CO_PoolEle)); + + pOutPutPri.tPri.ch = 'A' + nCh; + spPoolPut( &pOutPutPri.tPri , pOutCoPool); + + pInPutPri.tPri.ch = 'Z' - nCh; + spPoolPut( &pInPutPri.tPri , pInCoPool); + + if( nCh && (nCh % 4 == 0) ) + { + spPoolGet( &pOutGetPri.tPri , pOutCoPool); + } + + if( nCh && (nCh % 6 == 0 ) ) + { + spPoolGet( &pInGetPri.tPri , pInCoPool); + } + + fprintf( fp ,"\npOutPoolHead: [%d]\n" , pOutCoPool->uPoolCount); + fprintf( fp ," Out Put : %c\n" , pOutPutPri.tPri.ch); + fprintf( fp ," Out Get : %c\n" , pOutGetPri.tPri.ch); + fprintf( fp ," List :"); + + POOL_FOREACH( pPri , pOutCoPool->pPoolHead , tPointer ) + { + fprintf( fp ,"%c " ,pPri->tPri.ch ); + } + fprintf( fp ,"\n"); + + fprintf( fp ,"\npInPoolHead: [%d]\n" , pInCoPool->uPoolCount); + fprintf( fp ," Put : %c\n" , pInPutPri.tPri.ch); + fprintf( fp ," Get : %c\n" , pInGetPri.tPri.ch); + fprintf( fp ," List :"); + POOL_FOREACH( pPri , pInCoPool->pPoolHead , tPointer ) + { + fprintf( fp ,"%c " ,pPri->tPri.ch ); + } + fprintf( fp ,"\n\n\n"); + + } + fclose(fp); + getchar(); + return 1; + + } + */ +/////////////////////////////////////////////////////////////////////////// +// Reserved for Pool Test -- End +/////////////////////////////////////////////////////////////////////////// + +/*@end@*/ diff --git a/omc/plat/sccp/src/scoc_pri.c b/omc/plat/sccp/src/scoc_pri.c new file mode 100644 index 0000000..92fae5a --- /dev/null +++ b/omc/plat/sccp/src/scoc_pri.c @@ -0,0 +1,283 @@ +////////////////////////////////////////////////// +//Title : scoc_pri.c +//Auhtor : Liu Wei +//Desc : SCOC Primitive implemetation +//Created : 2007-05-07 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// Note: The file is reserved , discard in Loose coupling mode now +/////////////////////////////////////////////////////////////////////////// + +#include "./include/sccp_pub.h" + +#ifdef LOOSE_COUPLING_MODE //Loose coupling mode + +#else + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_UnitDataReq ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_SEQ * pSEQ, SP_RO * pRO, SP_UD * pUD ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_UnitDataInd ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_UD * pUD ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_NoticeInd ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_RR * pRR, SP_UD * pUD ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ConnectReq ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_RCS * pRCS, SP_EDS * pEDS ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ConnectInd ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ConnectRsp ( SP_RA * pRA, SP_RCS * pRCS, SP_EDS * pEDS ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ConnectCfm ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DisconnectReq ( SP_RA * pRA, SP_REA * pREA, SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DisconnectInd ( SP_OR * pOR, SP_RA * pRA, SP_REA * pREA, SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DataReq ( CR SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DataInd ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DataAkReq ( u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_DataAkInd ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_EDataReq ( SP_UD * pUD, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_EDataInd ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ResetReq ( SP_REA * pREA, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ResetInd ( SP_OR * pOR, SP_REA * pREA, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ResetRsp ( u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_ResetCfm ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_InformReq ( SP_REA * pREA, SP_QOS * pQOS, u8 uCI ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_N_InformInd ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLi_MTP_TransferReq ( sccpmsg ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLi_MTP_TransferInd ( sccpmsg ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLi_MTP_ResumeInd ( PC ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLi_MTP_StatusInd ( PC ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spLi_MTP_UPUInd ( PC ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_ISUP_ReqType1 ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_ISUP_ReqType2 ( ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////// +// /// +/////////////////////////////////////////////////////////////////////////// + +void spUi_ISUP_Relay ( ) +{ + return; +} + +#endif diff --git a/omc/plat/sccp/src/scrc.c b/omc/plat/sccp/src/scrc.c new file mode 100644 index 0000000..ab79aef --- /dev/null +++ b/omc/plat/sccp/src/scrc.c @@ -0,0 +1,1007 @@ + +/***************************************************************/ +/*Title: scrc.c */ +/*Descr: SCCP Routing Control Procedure */ +/*Author: Liang Hanxi */ +/*Create: 2002-2-19 */ +/*Modify: 2003-5-9 */ + +/***************************************************************/ +#include "./include/sccp.h" +#include "./include/sccp_pub.h" +#include "../../public/src/include/pub_netcap.h" + +extern int sccp_send_netcap ; + +/*===========export================*/ +void scrc_timer ( ); +int scrc_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); +int scrc_mnp_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ); +int send_msg ( Intra_Msg * pIntraMsg, BYTE ansi_flag ); +int scrc_rf ( Intra_Msg * pIntraMsg, BYTE AnsiFlag ); +DWORD SelectIPOfSSN ( BYTE ssn, BYTE sls, BOOL from_mtp ); + +/*===========import================*/ +extern int SegmentingMsg ( Intra_Msg * pIntraMsg ); //sclc.c +extern int build_msg ( BYTE * buf, Intra_Msg * intramsg, BYTE NetID, BYTE ansi_flag ); +extern int parse_msg ( BYTE * buf, Intra_Msg * intramsg, int len, BYTE NetID, BYTE ansi_flag ); //sccpmsg.c +extern int scrc2scoc ( Intra_Msg * intramsg, BYTE AnsiFlag ); +extern int scoc_store ( up_message * sccpmsg ); +extern int Digits2Array ( BYTE * pArray, BYTE * pDigits, int DigitsLen ); +extern u_short SelectRoute ( BYTE * pDigits, BYTE DigitsLen ); +extern void TranslateGT ( SCCP_ADDR * addr, SCCP_ROUTE * pRoute ); +extern int sclc2scmg ( Intra_Msg * intramsg ); +extern BOOL CheckAvail ( SCCP_ADDR * addr ); +extern int scrc2sclc ( Intra_Msg * pIntraMsg ); +extern int sclc_rf ( Intra_Msg * pIntraMsg ); +extern BOOL isco ( Intra_Msg * intramsg ); +extern void snmpLogInfo ( char *logInfo ); + +/* by simon at 23/9/26 */ +extern SCCP_CSTA SccpCsta[96]; +extern DWORD SccpCstaInd; +extern LOCAL_SSN LocalSSN[256]; +extern SCCP_SegMsgBuf sccp_segmsgbuf[MAX_SEGMSG_BUF]; +extern struct sccp_msg_statistic +{ + DWORD msg_mtp_scoc; + DWORD msg_scoc_up; + DWORD mnp_send; + DWORD mnp_route; +} sccpmsg_st; +extern struct _dpc2sls +{ + int dpc; + u8 sls; +} dpc2sls[256]; // used for sequence control, add by Roy Jiang, 2007-09-17 +extern SCCP_Capture_Buf SCCPCapBuf; +extern LOCAL_SSN LocalSSN[256]; +extern int RelatedSSNNum; +extern RL_SSN RelatedSSN[SCCP_RLSSN_NUM]; +extern SCOC_BUF ScocBuf; +extern SCCP_ROUTE RouteList[SCCP_ROUTE_NUM]; +extern SCCP_OPT SCCP_Param; +extern u8 MNP_Flag[2]; + +/*===========private================*/ +static int mtp2scrc ( up_message * pMsgFromMTP ); +void sccp_put_capture_logs ( BYTE person, BYTE * pictures, int len ); +int get_sls(int dpc); +/******************************************************************/ + +/*==================Interface function----->================*/ + +/******************************************************************/ +void scrc_timer ( ) //called per 20ms +//read messge from mtp buffer +{ + up_message MsgFromMTP3; + BYTE loop = 128; + + while ( loop-- > 0 ) + { + if( sccp_GetMsg ( &MsgFromMTP3 ) > 0 ) + mtp2scrc ( &MsgFromMTP3 ); + else + break; + } +} + +u32 dAlterIpBackup; //for protection +int mtp2scrc ( up_message * pMsgFromMTP ) +{ + Intra_Msg msgin; + BOOL ForceAnsi = 0; + int mask; + char *pStr; + + SccpCsta[SccpCstaInd].utilization[0]++; + + memset ( &msgin, 0, sizeof ( Intra_Msg ) ); + msgin.NetID = msgin.CGA.NetID = msgin.CDA.NetID = pMsgFromMTP->sio >> 6; + msgin.DPC = pMsgFromMTP->dpc; + msgin.OPC = pMsgFromMTP->opc; + msgin.SLS = pMsgFromMTP->cic[0] & 0x0F; + msgin.link = pMsgFromMTP->link; + + ForceAnsi = ( pMsgFromMTP->sio >> 4 ) & 1; + parse_msg ( pMsgFromMTP->msgList, &msgin, pMsgFromMTP->len, msgin.NetID, ForceAnsi ); + + if( msgin.CDA.len > ( MAX_DIGITS * 2 ) ) + { + SCCPCapBuf.watch_dog[14]++; + sccp_put_capture_logs ( 03, ( BYTE * ) pMsgFromMTP, sizeof ( up_message ) ); + spLogDebug ( SCCPDB_ERR, "SCCP RV Invalid Message from MTP3,CDA.len=%d, len is over range, the Message was captured", msgin.CDA.len ); + } + + msgin.msgsource = FROM_MTP; + + if( msgin.CGA.DPC == SCCP_Param.spc[msgin.NetID] ) + msgin.CGA.ip = pMsgFromMTP->dest_ip; + else + msgin.CGA.ip = INADDR_NONE; + msgin.CDA.ip = INADDR_NONE; + + switch ( msgin.msgtype ) + { + case UDT_MSG: + SccpCsta[SccpCstaInd].quality[2]++; + spShowMsg ( SCCPDB_MTP3, "SCCP <== MTP3. UDT Message", &msgin ); + return scrc_route ( &msgin, ForceAnsi ); + case UDTS_MSG: + SccpCsta[SccpCstaInd].quality[3]++; + spShowMsg ( SCCPDB_MTP3, "SCCP <== MTP3. UDTS Message", &msgin ); + return scrc_route ( &msgin, ForceAnsi ); + case XUDT_MSG: + //SccpCsta[SccpCstaInd].quality[3]++; + mask = 0; + if( msgin.SegPresent == 1 ) + { + mask |= SCCPDB_XUDT; + } + + spShowMsg ( SCCPDB_MTP3 | mask, "SCCP_RegProc <== SCCP <== MTP3. XUDT Message", &msgin ); + return scrc_route ( &msgin, ForceAnsi ); + case XUDTS_MSG: + //SccpCsta[SccpCstaInd].quality[3]++; + spShowMsg ( SCCPDB_MTP3, "SCCP <== MTP3. XUDTS Message", &msgin ); + return scrc_route ( &msgin, ForceAnsi ); + case CR_MSG: + SccpCsta[SccpCstaInd].quality[6]++; + spShowMsg ( SCCPDB_AIF, "SCCP <== MTP3. CR Message", &msgin ); + return scrc_route ( &msgin, ForceAnsi ); + case DT1_MSG: + case CC_MSG: + case DT2_MSG: + case RLSD_MSG: + case RLC_MSG: + case CREF_MSG: + case AK_MSG: + case IT_MSG: + //message redirect, add by Roy Jiang + if (msgin.aDLR[0] != pSp->dSysID //not local system + && msgin.aDLR[0] <= 2 && msgin.aDLR[0] != 0) //only system 1 & system 2 + { + //dual server mode and the message is to the other server + if(pSp->dAlterIP == 0) + { + if (dAlterIpBackup != 0){ + spLogDebug ( SCCPDB_ERR, "Fatal error, memory corrupted, pSp->dAlterIp = 0."); + pSp->dAlterIP = dAlterIpBackup; + } + else + return 0; + } + msgin.CDA.ip = pSp->dAlterIP; + msgin.msgsource = FROM_MTP; + msgin.redirectFlag = 1; + //send_msg ( &msgin, 0 ); //uAnsiFlag = 0; + pMsgFromMTP->dest_ip = pSp->dAlterIP; + pMsgFromMTP->link = 0xff; + sccp_redirect(pMsgFromMTP); + spGetMsgStr ( msgin.msgtype, pStr ); + spShowMsg(SCCPDB_MTP3, "Message redirected. SCCP ==> MTP3.", &msgin); +// spLogDebug ( SCCPDB_AIF, "Message redirected. CO-%s, NetID=%d, msglen=%d", pStr, msgin.NetID, msgin.msglen ); + return 0; + } + if( msgin.msgtype == DT1_MSG ) + SccpCsta[SccpCstaInd].utilization[9 - 3]++; + else if( msgin.msgtype == DT1_MSG ) + SccpCsta[SccpCstaInd].utilization[11 - 3]++; + + spGetMsgStr ( msgin.msgtype, pStr ); + spLogDebug ( SCCPDB_AIF, "SCCP <== MTP3. CO-%s, NetID=%d, msglen=%d ", pStr, msgin.NetID, msgin.msglen ); + + { + char digits1[24], digits2[24]; //, info[256]; + + BcdToAscii ( digits1, msgin.aSLR, 6 ); + digits1[6] = 0; + BcdToAscii ( digits2, msgin.aDLR, 6 ); + digits2[6] = 0; + spLogDebug ( SCCPDB_AIF,"SLR = %s DLR = %s ", digits1, digits2 ); + } + spShowBCD ( SCCPDB_AIF, ( BYTE * ) pMsgFromMTP, ( pMsgFromMTP->len + 17 ) % 256 ); + +#ifndef _WXC_TEST +/* + if( SCCP_Param.CO_SSN <= 1 ) + return scrc_rf ( &msgin, ForceAnsi ); + + msgin.CDA.ip = SelectIPOfSSN ( SCCP_Param.CO_SSN, msgin.SLS, 1 ); + + if( msgin.CDA.ip == SCCP_Param.ip ) + { + return scoc_store ( pMsgFromMTP ); + } + else if( msgin.CDA.ip == 0 ) + return scrc_rf ( &msgin, ForceAnsi ); + else + return send_msg ( &msgin, ForceAnsi ); +*/ +#endif + //need to modify + cr2co ( &msgin, ForceAnsi ); + return 1; + //break; + default: + spLogDebug ( SCCPDB_ERR, "SCCP <== MTP3. Not support Message(type=%02x), NetID=%d, msglen=%d", msgin.msgtype, msgin.NetID, msgin.msglen ); + spShowBCD ( SCCPDB_ERR, ( BYTE * ) pMsgFromMTP, ( pMsgFromMTP->len + 17 ) % 256 ); + SCCPCapBuf.watch_dog[12]++; //invalid message + SCCPCapBuf.watch_dog[13] = msgin.msgtype; //invalid message + + } + return 0; +} + +/******************************************************************/ + +/*========== Routing Control Procedure-----> ===========*/ + +/******************************************************************/ +int scrc_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ) +{ + SCCP_ADDR *pAddr = NULL, DstAddr; + SCCP_ROUTE *pRoute = NULL; + int LocalSPC; + u_short nRoute = 0xFFFF; + BYTE Num[32], NumLen; + BYTE routeAI; + BYTE field = 0; + + SccpCsta[SccpCstaInd].utilization[0]++; + pIntraMsg->msgMNP = 0; + + pAddr = &pIntraMsg->CDA; + /* daniel */ + pAddr->AI = 1; //default to include DPC + pIntraMsg->CGA.AI = 1; //default to include DPC + /* daniel */ + memcpy ( &DstAddr, pAddr, sizeof ( SCCP_ADDR ) ); + + if( pAddr->RI == RI_SSN && pAddr->DPC == 0 ) + { + if( pAddr->NetID > 3 ) + { + spLogDebug ( SCCPDB_ERR, "<011>SCCP Translation:SPC not available" ); + SccpCsta[SccpCstaInd].error[0]++; + return -1; + } + DstAddr.DPC = SCCP_Param.spc[pAddr->NetID]; + } + //Route On GT + if( DstAddr.RI == RI_GT || DstAddr.DPC == 0 || DstAddr.SSN == 0 || DstAddr.NetID > 3 ) + { + SccpCsta[SccpCstaInd].utilization[5 - 3]++; + if( pIntraMsg->CDA.GTI == 0 ) + { + pIntraMsg->cause = RT_NTFN; + spLogDebug ( SCCPDB_ERR, "<011>SCCP Translation:GTI == 0 (4 is recommended)" ); + SccpCsta[SccpCstaInd].error[1]++; + return -1; + } + /* if(pIntraMsg->CDA.TT != 0) + { + spLogDebug(SCCPDB_ERR, "<012>SCCP Translation:no translation for an address of such nature(TT=%d)", pIntraMsg->CDA.TT); + pIntraMsg->cause = RT_NTFN; + SccpCsta[SccpCstaInd].error[0] ++; + return -1; + } */ + + if( pAddr->len > ( MAX_DIGITS * 2 ) ) + { + SCCPCapBuf.watch_dog[0]++; + sccp_put_capture_logs ( 01, ( BYTE * ) pIntraMsg, sizeof ( Intra_Msg ) ); + spLogDebug ( SCCPDB_ERR, "<014>SCCP Receive Invalid Message,GTT len=%d, the Message was discarded and captured", pAddr->len ); + return -2; + } + + if( pAddr->NP > 0 ) + Num[field++] = pAddr->NP; + else + Num[field++] = NP_MSISDN; + if( pAddr->TT > 0 ) + { + Num[field++] = pAddr->TT / 100; + Num[field++] = ( pAddr->TT / 10 ) % 10; + Num[field++] = pAddr->TT % 10; + } + else + { + Num[field++] = TT_0; + Num[field++] = TT_1; + Num[field++] = TT_4; + } + NumLen = pAddr->len % ( MAX_DIGITS * 2 ); + Digits2Array ( Num + field, pAddr->GTAI, ( NumLen + 1 ) / 2 ); + nRoute = SelectRoute ( Num, NumLen + field ); + + if( nRoute < SCCP_ROUTE_NUM ) + { + pRoute = &RouteList[nRoute]; + + if( DstAddr.NetID != pRoute->NetID ) + pIntraMsg->CGA.RI = RI_GT; + /* daniel */ + else if( pIntraMsg->msgsource != FROM_MTP ) + pIntraMsg->CGA.RI = pRoute->RI; + /* daniel */ + DstAddr.NetID = pRoute->NetID; + + if( pRoute->SSN > 0 ) + pAddr->SSN = DstAddr.SSN = pRoute->SSN; + + pAddr->RI = pRoute->RI; + DstAddr.DPC = pRoute->DPC[0] * 0x10000 + pRoute->DPC[1] * 0x100 + pRoute->DPC[2]; + + if(( pIntraMsg->CGA.SSN != 10 ) && ( DstAddr.SSN == 6 && DstAddr.NP == 1 && pIntraMsg->data[0] == 0x62 ) && (MNP_Flag[0] != 0)) + {// MNP neednot convert GT + if(!((pRoute->ReplaceStart == 1) && (pRoute->ReplaceEnd == pAddr->len))) + { + if( pRoute->convert ) + { + DstAddr.RI = pAddr->RI; + TranslateGT ( &DstAddr, pRoute ); + memcpy ( pAddr, &DstAddr, sizeof ( SCCP_ADDR ) ); + } + } + } + else if( pRoute->convert ) + { + DstAddr.RI = pAddr->RI; + TranslateGT ( &DstAddr, pRoute ); + memcpy ( pAddr, &DstAddr, sizeof ( SCCP_ADDR ) ); + } + + /* daniel */ + routeAI = pRoute->AI; + //set calling address + if( pIntraMsg->CGA.RI == 0 ) //route on GT + { + if( ( routeAI & 1 ) == 0 ) //point code no need + pIntraMsg->CGA.AI &= ~1; //set dpc=0 + } + else //route on DPC+SSN + { + if( ( routeAI & 4 ) == 0 ) //GT no need + pIntraMsg->CGA.GTI = 0; //set GT=0 + } + + //set called address + if( pAddr->RI == 0 ) //route on GT + { + if( ( routeAI & 1 ) == 0 ) //point code no need + pAddr->AI &= ~1; //set dpc=0 + } + else //route on DPC+SSN + { + if( ( routeAI & 4 ) == 0 ) //GT no need + pAddr->GTI = 0; //set GTI=0 + } + /* daniel */ + + } + else if( nRoute >= 1024 && nRoute < 1024 + 256 ) //local Node + { + pAddr->SSN = DstAddr.SSN = nRoute - 1024; + if( DstAddr.NetID > 3 ) + DstAddr.NetID = LocalSSN[DstAddr.SSN].NetID; + + pAddr->RI = RI_SSN; + DstAddr.DPC = SCCP_Param.spc[DstAddr.NetID & 3]; + } + else + { + pIntraMsg->cause = RT_NTFA; + SccpCsta[SccpCstaInd].avail[1]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + } + if( !CheckAvail ( &DstAddr ) ) + { + pIntraMsg->cause = RT_SF; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + + pIntraMsg->NetID = DstAddr.NetID % 4; //0~3 + pIntraMsg->DPC = pAddr->DPC = DstAddr.DPC; + LocalSPC = SCCP_Param.spc[pIntraMsg->NetID]; + + if (pIntraMsg->CGA.RI == RI_SSN) + { + if (pIntraMsg->CGA.DPC == 0) + { + pIntraMsg->CGA.DPC = pIntraMsg->OPC; + } + } + + if (pIntraMsg->CGA.RI == RI_SSN) + { + if (pIntraMsg->CGA.DPC == 0) + { + pIntraMsg->CGA.DPC = pIntraMsg->OPC; + } + } + + if( DstAddr.DPC != LocalSPC ) + { + snmpLogInfo ( "scrc_route(): start.... 266" ); + + if (pIntraMsg->sequenceFlag == 1 && pIntraMsg->msgtype == UDT_MSG){ + pIntraMsg->SLS = get_sls(pIntraMsg->DPC); //in-sequence delivery, add by Roy Jiang, 07-09-26 + pIntraMsg->msgclass = 1; + } + if( ForceAnsi ) + return send_msg ( pIntraMsg, 1 ); + else + return send_msg ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else if( pIntraMsg->msgtype == UDTS_MSG && pIntraMsg->msgsource == FROM_MTP) //discast UDTS message to local node + return 1; + + if( DstAddr.SSN == 0 ) + { + pIntraMsg->cause = RT_UU; + spLogDebug ( SCCPDB_ERR, "<013>Invalid SSN(0)" ); + SccpCsta[SccpCstaInd].error[2]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + + if( DstAddr.SSN == 1 ) //scmg message + return sclc2scmg ( pIntraMsg ); + +#ifdef _WXC_SPTEST_TEMP + //just for test , delete it for normal + if( pAddr->ip == INADDR_NONE && pIntraMsg->msgsource == FROM_MTP ) + { + if( ( pIntraMsg->msgtype >= CR_MSG && pIntraMsg->msgtype <= AK_MSG ) ) + { + if( ForceAnsi ) + return cr2co ( pIntraMsg, 1 ); + else + return cr2co ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else + { + if( MNP_Flag[0] == 0 || pIntraMsg->msgsource != FROM_MTP ) /* MNP not supported */ + return scrc2sclc ( pIntraMsg ); + + /* SCCP Steering Function */ + /* message received or sent */ + /* MNP supported */ + /* routing method */ + pIntraMsg->msgMNP = 0; + + if( DstAddr.SSN == 6 && DstAddr.NP == 1 && pIntraMsg->data[0] == 0x62 ) + { + /* IN_Based and SRI for voice call */ + if( MNP_Flag[0] == 1 && DstAddr.TT != 0 ) + { + pIntraMsg->msgMNP = 0; + } + else if( pIntraMsg->CGA.SSN != 10 ) + { + pIntraMsg->msgMNP = 1; + } + return scrc2sclc ( pIntraMsg ); + } + else + { + return scrc2sclc ( pIntraMsg ); + } + } + } +#endif + + pAddr->ip = SelectIPOfSSN ( DstAddr.SSN, pIntraMsg->SLS, ( pIntraMsg->msgsource == FROM_MTP ) ); + + if( pAddr->ip == SCCP_Param.ip ) //local Node + + { + if( ( pIntraMsg->msgtype >= CR_MSG && pIntraMsg->msgtype <= AK_MSG ) ) + { + if( ForceAnsi ) + return cr2co ( pIntraMsg, 1 ); + else + return cr2co ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else + { + if( sccp_send_netcap) + { + int len; + up_message MsgToMTP; + int ansi_flag ; + if( ForceAnsi ) + ansi_flag = 1; + else + ansi_flag = mtp3_ansiFlag(DstAddr.NetID); + + len = build_msg ( MsgToMTP.msgList, pIntraMsg, pIntraMsg->NetID ,ansi_flag ); + MsgToMTP.len = len%256; + NcSccpSend( MsgToMTP.msgList , MsgToMTP.len , (u8 *)pIntraMsg , ansi_flag); + } + + + if( MNP_Flag[0] == 0 || pIntraMsg->msgsource != FROM_MTP ) /* MNP not supported */ + return scrc2sclc ( pIntraMsg ); + + /* SCCP Steering Function */ + /* message received or sent */ + /* MNP supported */ + /* routing method */ + pIntraMsg->msgMNP = 0; + + if( DstAddr.SSN == 6 && DstAddr.NP == 1 && pIntraMsg->data[0] == 0x62 ) + { + /* IN_Based and SRI for voice call */ + if( MNP_Flag[0] == 1 && DstAddr.TT != 0 ) + { + pIntraMsg->msgMNP = 0; + } + else if( pIntraMsg->CGA.SSN != 10 ) + { + pIntraMsg->msgMNP = 1; + } + return scrc2sclc ( pIntraMsg ); + } + else + { + return scrc2sclc ( pIntraMsg ); + } + } + } + else if( pAddr->ip == 0 ) //none subsystem is reachable + { + pIntraMsg->cause = RT_SF; + SccpCsta[SccpCstaInd].error[3]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else //relay to specify subsystem + { + snmpLogInfo ( "scrc_route(): start... 327" ); + if( ForceAnsi ) + return send_msg ( pIntraMsg, 1 ); + else + return send_msg ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } +} + +int scrc_mnp_route ( Intra_Msg * pIntraMsg, BOOL ForceAnsi ) +{ + SCCP_ADDR *pAddr = NULL, DstAddr; + SCCP_ROUTE *pRoute = NULL; + int LocalSPC; + u_short nRoute = 0xFFFF; + BYTE Num[32], NumLen; + BYTE routeAI; + BYTE field = 0; + + SccpCsta[SccpCstaInd].utilization[0]++; + + pAddr = &pIntraMsg->CDA; + /* daniel */ + pAddr->AI = 1; //default to include DPC + pIntraMsg->CGA.AI = 1; //default to include DPC + /* daniel */ + memcpy ( &DstAddr, pAddr, sizeof ( SCCP_ADDR ) ); + + if( pAddr->RI == RI_SSN && pAddr->DPC == 0 ) + { + if( pAddr->NetID > 3 ) + { + spLogDebug ( SCCPDB_ERR, "<021>SCCP Translation:SPC not available" ); + SccpCsta[SccpCstaInd].error[0]++; + return -1; + } + DstAddr.DPC = SCCP_Param.spc[pAddr->NetID]; + } + //Route On GT + if( DstAddr.RI == RI_GT || DstAddr.DPC == 0 || DstAddr.SSN == 0 || DstAddr.NetID > 3 ) + { + SccpCsta[SccpCstaInd].utilization[5 - 3]++; + if( pIntraMsg->CDA.GTI == 0 ) + { + pIntraMsg->cause = RT_NTFN; + spLogDebug ( SCCPDB_ERR, "<021>SCCP Translation:GTI == 0 (4 is recommended)" ); + SccpCsta[SccpCstaInd].error[1]++; + return -1; + } + /* if(pIntraMsg->CDA.TT != 0) + { + spLogDebug(SCCPDB_ERR, "<012>SCCP Translation:no translation for an address of such nature(TT=%d)", pIntraMsg->CDA.TT); + pIntraMsg->cause = RT_NTFN; + SccpCsta[SccpCstaInd].error[0] ++; + return -1; + } */ + + if( pAddr->len > ( MAX_DIGITS * 2 ) ) + { + SCCPCapBuf.watch_dog[0]++; + sccp_put_capture_logs ( 01, ( BYTE * ) pIntraMsg, sizeof ( Intra_Msg ) ); + spLogDebug ( SCCPDB_ERR, "<024>SCCP Receive Invalid Message,GTT len=%d, the Message was discarded and captured", pAddr->len ); + return -2; + } + + if( pAddr->NP > 0 ) + Num[field++] = pAddr->NP; + else + Num[field++] = NP_MSISDN; + if( pAddr->TT > 0 ) + { + Num[field++] = pAddr->TT / 100; + Num[field++] = ( pAddr->TT / 10 ) % 10; + Num[field++] = pAddr->TT % 10; + } + else + { + Num[field++] = TT_0; + Num[field++] = TT_1; + Num[field++] = TT_4; + } + NumLen = pAddr->len % ( MAX_DIGITS * 2 ); + Digits2Array ( Num + field, pAddr->GTAI, ( NumLen + 1 ) / 2 ); + nRoute = SelectRoute ( Num, NumLen + field ); + + if( nRoute < SCCP_ROUTE_NUM ) + { + pRoute = &RouteList[nRoute]; + + if( DstAddr.NetID != pRoute->NetID ) + pIntraMsg->CGA.RI = RI_GT; + /* daniel */ + else if( pIntraMsg->msgsource != FROM_MTP ) + pIntraMsg->CGA.RI = pRoute->RI; + /* daniel */ + DstAddr.NetID = pRoute->NetID; + + if( pRoute->SSN > 0 ) + pAddr->SSN = DstAddr.SSN = pRoute->SSN; + + pAddr->RI = pRoute->RI; + DstAddr.DPC = pRoute->DPC[0] * 0x10000 + pRoute->DPC[1] * 0x100 + pRoute->DPC[2]; + + if( pRoute->convert ) + { + DstAddr.RI = pAddr->RI; + TranslateGT ( &DstAddr, pRoute ); + memcpy ( pAddr, &DstAddr, sizeof ( SCCP_ADDR ) ); + } + + /* daniel */ + routeAI = pRoute->AI; + //set calling address + if( pIntraMsg->CGA.RI == 0 ) //route on GT + { + if( ( routeAI & 1 ) == 0 ) //point code no need + pIntraMsg->CGA.AI &= ~1; //set dpc=0 + } + else //route on DPC+SSN + { + if( ( routeAI & 4 ) == 0 ) //GT no need + pIntraMsg->CGA.GTI = 0; //set GT=0 + } + + //set called address + if( pAddr->RI == 0 ) //route on GT + { + if( ( routeAI & 1 ) == 0 ) //point code no need + pAddr->AI &= ~1; //set dpc=0 + } + else //route on DPC+SSN + { + if( ( routeAI & 4 ) == 0 ) //GT no need + pAddr->GTI = 0; //set GTI=0 + } + /* daniel */ + + } + else if( nRoute >= 1024 && nRoute < 1024 + 256 ) //local Node + { + pAddr->SSN = DstAddr.SSN = nRoute - 1024; + if( DstAddr.NetID > 3 ) + DstAddr.NetID = LocalSSN[DstAddr.SSN].NetID; + + pAddr->RI = RI_SSN; + DstAddr.DPC = SCCP_Param.spc[DstAddr.NetID & 3]; + } + else + { + pIntraMsg->cause = RT_NTFA; + SccpCsta[SccpCstaInd].avail[1]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + } + if( !CheckAvail ( &DstAddr ) ) + { + pIntraMsg->cause = RT_SF; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + + pIntraMsg->NetID = DstAddr.NetID % 4; //0~3 + pIntraMsg->DPC = pAddr->DPC = DstAddr.DPC; + LocalSPC = SCCP_Param.spc[pIntraMsg->NetID]; + + if( DstAddr.DPC != LocalSPC ) + { + snmpLogInfo ( "mnp_scrc_route(): start... 471" ); + + if (pIntraMsg->sequenceFlag == 1 && pIntraMsg->msgtype == UDT_MSG){ + pIntraMsg->SLS = get_sls(pIntraMsg->DPC); //in-sequence delivery, add by Roy Jiang, 07-09-26 + } + + if( ForceAnsi ) + return send_msg ( pIntraMsg, 1 ); + else + return send_msg ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + //snmpLogInfo ( "mnp_scrc_route(): end... 471" ); + } + else if( pIntraMsg->msgtype == UDTS_MSG ) //discast UDTS message to local node + return 1; + + if( DstAddr.SSN == 0 ) + { + pIntraMsg->cause = RT_UU; + spLogDebug ( SCCPDB_ERR, "<023>Invalid SSN(0)" ); + SccpCsta[SccpCstaInd].error[2]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + + if( DstAddr.SSN == 1 ) //scmg message + return sclc2scmg ( pIntraMsg ); + + pAddr->ip = SelectIPOfSSN ( DstAddr.SSN, pIntraMsg->SLS, ( pIntraMsg->msgsource == FROM_MTP ) ); + + pIntraMsg->msgMNP = 0; + if( pAddr->ip == 0 ) //none subsystem is reachable + { + pIntraMsg->cause = RT_SF; + SccpCsta[SccpCstaInd].error[3]++; + if( ForceAnsi ) + return scrc_rf ( pIntraMsg, 1 ); + else + return scrc_rf ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else if( pAddr->ip == SCCP_Param.ip ) //local Node + { + if( pIntraMsg->msgtype == CR_MSG || ( DstAddr.SSN == SCCP_Param.CO_SSN && SCCP_Param.CO_SSN > 1 ) ) + { + if( ForceAnsi ) + return cr2co ( pIntraMsg, 1 ); + else + return cr2co ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } + else + return scrc2sclc ( pIntraMsg ); + } + else //relay to specify subsystem + { + snmpLogInfo ( "scrc_route(): start... 327" ); + if( ForceAnsi ) + return send_msg ( pIntraMsg, 1 ); + else + return send_msg ( pIntraMsg, mtp3_ansiFlag ( DstAddr.NetID ) ); + } +} + +int send_msg ( Intra_Msg * pIntraMsg, BYTE ansi_flag ) +//pass message to mtp module +{ + int retval = 0; + int len = 0; + up_message MsgToMTP; + + pIntraMsg->DPC = pIntraMsg->CDA.DPC; + + if( pIntraMsg->msgsource != FROM_MTP && ( pIntraMsg->SLS & 0x80 ) == 0 ) + { + if( pIntraMsg->NetID > 3 ) + { + return 0; + } + pIntraMsg->CGA.DPC = SCCP_Param.spc[pIntraMsg->NetID]; + pIntraMsg->OPC = SCCP_Param.spc[pIntraMsg->NetID]; + } + + snmpLogInfo ( "send_msg(), build_msg: start..." ); + + if( pIntraMsg->msglen > 256 ) + return 0; + len = build_msg ( MsgToMTP.msgList, pIntraMsg, pIntraMsg->NetID, ansi_flag ); + + /* + MsgToMTP.len = build_msg ( MsgToMTP.msgList, pIntraMsg, pIntraMsg->NetID ); + if( MsgToMTP.len > 256 ) MsgToMTP.len is a BYTE + { + return 0; //added by Pierre, 01-19-05 for core at following line + } + + */ + + //add for UDT SegmentingMsg to XUDT + if( len < 272 && ( len + 8 ) > 0xfd && pIntraMsg->msgtype == UDT_MSG && pIntraMsg->msgsource == FROM_SCLC + && pIntraMsg->CDA.ip != 0 && pIntraMsg->CDA.ip != SCCP_Param.ip && pIntraMsg->CDA.ip != INADDR_NONE ) + { //relay to special system msg too long ,need cut to segment -- add by lw 2007/03/20 + spLogDebug ( SCCPDB_UDT, "UDT Message form upper layer is too long, [ %d Bytes(len=%d if include MTP3)]! " "Need to be segmented!\r\n ", pIntraMsg->msglen, len ); + retval = SegmentingMsg ( pIntraMsg ); + return retval; + } + + if( len >= 256 ) + { + spLogDebug ( SCCPDB_ERR, "Build SCCP Message too long! " ); + return 0; + } + MsgToMTP.len = len % 256; + snmpLogInfo ( "send_msg(), type message: start..." ); + switch ( pIntraMsg->msgsource ) + { + case FROM_MTP: + spShowMsg ( SCCPDB_STP, "SCCP ==> MTP3: STP", pIntraMsg ); + break; + case FROM_SCLC: + switch ( pIntraMsg->msgtype ) + { + case UDT_MSG: + SccpCsta[SccpCstaInd].quality[0]++; + spShowMsg ( SCCPDB_UDT, "SCCP ==> MTP3:", pIntraMsg ); + break; + case UDTS_MSG: + SccpCsta[SccpCstaInd].quality[1]++; + spShowMsg ( SCCPDB_UDT, "SCCP ==> MTP3:", pIntraMsg ); + break; + case XUDT_MSG: //add for UDT SegmentingMsg to XUDT + spShowMsg ( SCCPDB_XUDT, "SCCP ==> MTP3:", pIntraMsg ); + break; + case XUDTS_MSG: //add for UDT SegmentingMsg to XUDT + spShowMsg ( SCCPDB_XUDT, "SCCP ==> MTP3:", pIntraMsg ); + break; + } + break; + case FROM_SCOC: + spShowMsg ( SCCPDB_AIF, "SCCP ==> MTP3: AIF", pIntraMsg ); + break; + case FROM_SCMG: + spShowMsg ( SCCPDB_SCMG, "SCCP ==> MTP3: SCMG", pIntraMsg ); + break; + } + + MsgToMTP.dest_ip = pIntraMsg->CDA.ip; + MsgToMTP.dpc = pIntraMsg->DPC; + MsgToMTP.opc = pIntraMsg->OPC; + MsgToMTP.sio = pIntraMsg->NetID * 0x40 + 3; + MsgToMTP.cic[0] = pIntraMsg->SLS & 0x0F; + MsgToMTP.link = 0xff; + + if(pIntraMsg->redirectFlag == 1 && pIntraMsg->CDA.ip != 0xFFFFFFFF) //add by Roy to support sccp dual server message redirect, 07-09-12 + retval = sccp_redirect ( &MsgToMTP ); + else + retval = sccp_to_mtp3 ( &MsgToMTP ); + + if( sccp_send_netcap) + { + NcSccpSend( MsgToMTP.msgList , MsgToMTP.len , (u8 *)pIntraMsg , ansi_flag ); + } + + return retval; + // return sccp_to_mtp3(&MsgToMTP); //depend on mtp module +} + +int scrc_rf ( Intra_Msg * pIntraMsg, BYTE AnsiFlag ) +{ +#ifdef _WXC_TEST + WxcAssert ( 0, "routing fail" ); +#endif + if( isco ( pIntraMsg ) ) + { + + pIntraMsg->msgtype = SP_MSG_RF; + cr2co ( pIntraMsg, AnsiFlag ); + spShowMsg ( SCCPDB_ERR, "<006>Route Failure", pIntraMsg ); + return -1; + } + else + return sclc_rf ( pIntraMsg ); +} + +DWORD SelectIPOfSSN ( BYTE ssn, BYTE sls, BOOL from_mtp ) +{ + LOCAL_SSN *pssn = &LocalSSN[ssn]; + + switch ( pssn->status[0] ) + { + case ST_Enable: + switch ( pssn->status[1] ) + { + case ST_Enable: + if( pssn->local == 0 ) + return pssn->ip[sls & 0x01]; + else if( from_mtp ) + return pssn->ip[( pssn->local - 1 ) & 0x01]; + else if( ( sls & 0x80 ) == 0x80 ) + return pssn->ip[pssn->local & 0x01]; + else + return pssn->ip[sls & 0x01]; + //break; + default: + if( ( sls & 0x80 ) == 0x80 && pssn->local == 1 ) + { + spLogDebug ( SCCPDB_ERR, "<014>Message was refused by subsystem_%d_0 and subsystem_%d_1 inaccessible", ssn, ssn ); + return 0; + } + else + return pssn->ip[0]; + //break; + } + //break; + default: + switch ( pssn->status[1] ) + { + case ST_Enable: + if( ( sls & 0x80 ) == 0x80 && pssn->local == 2 ) + { + spLogDebug ( SCCPDB_ERR, "<015>Message was refused by subsystem_%d_1 and subsystem_%d_0 inaccessible", ssn, ssn ); + return 0; + } + else + return pssn->ip[1]; + //break; + default: + spLogDebug ( SCCPDB_ERR, "<016>Subsystem_%d is inaccessible", ssn ); + + } + } + + return 0; + +} + + +//sequence control functions -- add by Roy Jiang 2007-09-17 +int get_sls(int dpc) +{ + static int pos = 0; //end position of dpc2sls array + static u8 next_sls = 0; //sls for new dpc + int i; + + for(i=0; i= 256) + return next_sls; + + dpc2sls[i].dpc = dpc; + dpc2sls[i].sls = next_sls; + next_sls = (next_sls + 1) & 0x0F; + pos++; + + return dpc2sls[i].sls; +} +//end of sequence control functions -- add by Roy Jiang 2007-09-17 + diff --git a/omc/plat/sccp/ut/.copyarea.db b/omc/plat/sccp/ut/.copyarea.db new file mode 100644 index 0000000..8eeb263 --- /dev/null +++ b/omc/plat/sccp/ut/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\ut +2 +3 +6:ut_doc|2|0|0|0|a9e96fdfbfa511dc85e0001c23e19543|0 +7:fsmtest|2|0|0|0|670881dbc44711dc9639001c23e19543|0 +4:pool|2|0|0|0|a9e96fc3bfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/ut/fsmtest/.copyarea.db b/omc/plat/sccp/ut/fsmtest/.copyarea.db new file mode 100644 index 0000000..f06fe9e --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\ut\fsmtest +2 +5 +b:scoc_test.c|1|11d70a43f0a|486d|63291a83|ec097acfbfa511dc85e0001c23e19543|0 +3:obj|2|0|0|0|eca97aebbfa511dc85e0001c23e19543|0 +3:bin|2|0|0|0|683881e0c44711dc963b001c23e19543|0 +b:sccp_test.c|1|11d70a43e7e|f68|fd7f3d88|bf59735fbfa511dc85e0001c23e19543|0 +8:Makefile|1|11d70a43edb|bc5|2253d117|d6997733bfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/ut/fsmtest/Makefile b/omc/plat/sccp/ut/fsmtest/Makefile new file mode 100644 index 0000000..b4de194 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/Makefile @@ -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 Makefile.rules diff --git a/omc/plat/sccp/ut/fsmtest/bin/.copyarea.db b/omc/plat/sccp/ut/fsmtest/bin/.copyarea.db new file mode 100644 index 0000000..977154f --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\ut\fsmtest\bin +2 +1 +4:conf|2|0|0|0|697881e9c44711dc963c001c23e19543|0 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/.copyarea.db b/omc/plat/sccp/ut/fsmtest/bin/conf/.copyarea.db new file mode 100644 index 0000000..15449d7 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/.copyarea.db @@ -0,0 +1,28 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\ut\fsmtest\bin\conf +2 +18 +9:help_page|1|11d70a440ee|21d|76e388e2|c3897423bfa511dc85e0001c23e19543|0 +11:hlr_parambit.conf|1|11d70a4442a|5104|45018cef|d009761bbfa511dc85e0001c23e19543|0 +9:sccp.conf|1|11d70a44081|45c|70f1cec3|c25973ebbfa511dc85e0001c23e19543|0 +12:cap_operation.conf|1|11d70a4438e|4ec|138764f3|ce3975c7bfa511dc85e0001c23e19543|0 +10:conv_prefix.conf|1|11d70a44208|1200|4a8a0577|c7a974cbbfa511dc85e0001c23e19543|0 +c:cap_acn.conf|1|11d70a44236|f4|79044b6f|c84974e7bfa511dc85e0001c23e19543|0 +e:smsc_csta.conf|1|11d70a444d6|16b|27e474c8|d1d9766fbfa511dc85e0001c23e19543|0 +c:map_acn.conf|1|11d70a441d9|605|8729d67f|c71974afbfa511dc85e0001c23e19543|0 +d:wxc2_sys.conf|1|11d70a4411d|13|32e20463|c419743fbfa511dc85e0001c23e19543|0 +c:iptrans.conf|1|11d70a44534|1c2|5d6d4a|d4c976dfbfa511dc85e0001c23e19543|0 +7:profile|1|11d70a443fb|303|f498ea9e|cf6975ffbfa511dc85e0001c23e19543|0 +9:menu_page|1|11d70a44043|2da|b80578ca|c12973b3bfa511dc85e0001c23e19543|0 +b:ppsConf.txt|1|11d70a440c0|6eb4|7ddbb6ab|c2e97407bfa511dc85e0001c23e19543|0 +a:system.ini|1|11d70a44505|d4|c2920d14|d39976a7bfa511dc85e0001c23e19543|0 +a:HlrSysPara|1|11d70a443bd|1c4c|4897e7b6|ced975e3bfa511dc85e0001c23e19543|0 +9:mtp3.conf|1|11d70a4415c|17450|6f04775|c549745bbfa511dc85e0001c23e19543|0 +d:smsc_sys.conf|1|11d70a444a7|56|7f8e17d8|d1397653bfa511dc85e0001c23e19543|0 +12:smsc_parambit.conf|1|11d70a44350|b14|e71da7cc|cd0975abbfa511dc85e0001c23e19543|0 +d:cc_table.conf|1|11d70a44285|1156|31d07a59|c9797503bfa511dc85e0001c23e19543|0 +c:wxc2exit.txt|1|11d70a442b3|4a|51411549|ca19751fbfa511dc85e0001c23e19543|0 +11:xap_sysparam.conf|1|11d70a442e2|d|246d0664|cb497557bfa511dc85e0001c23e19543|0 +e:sccp_test.conf|1|11d70a44469|12|20b80338|d0a97637bfa511dc85e0001c23e19543|0 +12:map_operation.conf|1|11d70a44311|c11|26bf7744|cbd97573bfa511dc85e0001c23e19543|0 +c:hae_sys.conf|1|11d70a4419a|74|a5dc1e78|c6797493bfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/HlrSysPara b/omc/plat/sccp/ut/fsmtest/bin/conf/HlrSysPara new file mode 100644 index 0000000..6104688 Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/HlrSysPara differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/cap_acn.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/cap_acn.conf new file mode 100644 index 0000000..03de193 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/cap_acn.conf @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/cap_operation.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/cap_operation.conf new file mode 100644 index 0000000..e6f21e1 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/cap_operation.conf @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/cc_table.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/cc_table.conf new file mode 100644 index 0000000..72da771 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/cc_table.conf @@ -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 + diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/conv_prefix.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/conv_prefix.conf new file mode 100644 index 0000000..bcd6108 Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/conv_prefix.conf differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/hae_sys.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/hae_sys.conf new file mode 100644 index 0000000..500a027 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/hae_sys.conf @@ -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; diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/help_page b/omc/plat/sccp/ut/fsmtest/bin/conf/help_page new file mode 100644 index 0000000..f384302 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/help_page @@ -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". + +$ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/hlr_parambit.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/hlr_parambit.conf new file mode 100644 index 0000000..8497c6f Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/hlr_parambit.conf differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/iptrans.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/iptrans.conf new file mode 100644 index 0000000..c314bdb --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/iptrans.conf @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/map_acn.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/map_acn.conf new file mode 100644 index 0000000..f6167c0 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/map_acn.conf @@ -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 + diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/map_operation.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/map_operation.conf new file mode 100644 index 0000000..a802790 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/map_operation.conf @@ -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 \ No newline at end of file diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/menu_page b/omc/plat/sccp/ut/fsmtest/bin/conf/menu_page new file mode 100644 index 0000000..a68cefb --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/menu_page @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/mtp3.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/mtp3.conf new file mode 100644 index 0000000..d236db3 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/mtp3.conf @@ -0,0 +1,1408 @@ +#MTP3 CONFIGURE FILE + +[SERVICE NETWORK SP LEN] +[00] + +[LOCAL SP] +[000000] [000000] [000028] [000000] +[000000] [000000] [000000] [000000] + +[LINK ATTRIBUTE] +[00.00.ea] [11.00.62] [80.10.ff] [10.00.62] +[14.00.62] [08.00.62] [4e.00.62] [80.10.ff] +[80.10.ff] [12.00.62] [80.10.ff] [0a.00.62] +[0b.00.62] [0c.00.62] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [11.01.63] [80.10.ff] [10.01.63] +[14.01.63] [08.02.63] [4f.00.63] [80.10.ff] +[80.10.ff] [12.01.63] [80.10.ff] [0a.01.63] +[0b.01.63] [0c.01.63] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] + +[LINKSET ATTRIBUTE] +[000028.02] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] + +[NATIONAL NETWORK SP] +[000028.00.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000008.08.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[NATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[LOCAL ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 + +[INTERNATIONAL NETWORK ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[INTERNATIONAL NETWORK SPARE ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[NATIONAL NETWORK ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +010303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[NATIONAL NETWORK SPARE ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/ppsConf.txt b/omc/plat/sccp/ut/fsmtest/bin/conf/ppsConf.txt new file mode 100644 index 0000000..b556699 Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/ppsConf.txt differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/profile b/omc/plat/sccp/ut/fsmtest/bin/conf/profile new file mode 100644 index 0000000..de17bc9 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/profile @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/sccp.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/sccp.conf new file mode 100644 index 0000000..d8397e6 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/sccp.conf @@ -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 + diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/sccp_test.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/sccp_test.conf new file mode 100644 index 0000000..94ea0ec --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/sccp_test.conf @@ -0,0 +1,2 @@ +172.18.199.1 +2000 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_csta.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_csta.conf new file mode 100644 index 0000000..b38d7f7 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_csta.conf @@ -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 diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_parambit.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_parambit.conf new file mode 100644 index 0000000..cc4473d Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_parambit.conf differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_sys.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_sys.conf new file mode 100644 index 0000000..a6081a9 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/smsc_sys.conf @@ -0,0 +1,5 @@ +#SMSC system configure file + +#IP info of SMSC +wxc2-0=172.18.98.1; +wxc2-1=172.18.99.1; diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/system.ini b/omc/plat/sccp/ut/fsmtest/bin/conf/system.ini new file mode 100644 index 0000000..775a1a3 Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/system.ini differ diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2_sys.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2_sys.conf new file mode 100644 index 0000000..fe6ec83 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2_sys.conf @@ -0,0 +1 @@ +pps-1=172.18.98.1; diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2exit.txt b/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2exit.txt new file mode 100644 index 0000000..fc9e7d6 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/bin/conf/wxc2exit.txt @@ -0,0 +1,4 @@ +WXC2 procedure exit log + Time: Fri Nov 5 05:27:51 2004 + +Now module: MSC diff --git a/omc/plat/sccp/ut/fsmtest/bin/conf/xap_sysparam.conf b/omc/plat/sccp/ut/fsmtest/bin/conf/xap_sysparam.conf new file mode 100644 index 0000000..2bc914e Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/bin/conf/xap_sysparam.conf differ diff --git a/omc/plat/sccp/ut/fsmtest/obj/.copyarea.db b/omc/plat/sccp/ut/fsmtest/obj/.copyarea.db new file mode 100644 index 0000000..7ae86d2 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/obj/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sccp\ut\fsmtest\obj +2 +4 +e:sccp_test.gcno|1|11d70a4466c|1388|6e120937|ef097b5bbfa511dc85e0001c23e19543|0 +b:scoc_test.o|1|11d70a4462e|bed0|14b598f2|ee697b3fbfa511dc85e0001c23e19543|0 +e:scoc_test.gcno|1|11d70a445ff|36a8|a2ae2b78|edd97b23bfa511dc85e0001c23e19543|0 +b:sccp_test.o|1|11d70a445d0|6f68|f2935f7b|ed397b07bfa511dc85e0001c23e19543|0 diff --git a/omc/plat/sccp/ut/fsmtest/obj/sccp_test.gcno b/omc/plat/sccp/ut/fsmtest/obj/sccp_test.gcno new file mode 100644 index 0000000..e233aef Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/obj/sccp_test.gcno differ diff --git a/omc/plat/sccp/ut/fsmtest/obj/scoc_test.gcno b/omc/plat/sccp/ut/fsmtest/obj/scoc_test.gcno new file mode 100644 index 0000000..9d14421 Binary files /dev/null and b/omc/plat/sccp/ut/fsmtest/obj/scoc_test.gcno differ diff --git a/omc/plat/sccp/ut/fsmtest/sccp_test.c b/omc/plat/sccp/ut/fsmtest/sccp_test.c new file mode 100644 index 0000000..1813a89 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/sccp_test.c @@ -0,0 +1,192 @@ + +#include "../../src/include/sccp.h" +#include "signal.h" +#include + +#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" ); +} + diff --git a/omc/plat/sccp/ut/fsmtest/scoc_test.c b/omc/plat/sccp/ut/fsmtest/scoc_test.c new file mode 100644 index 0000000..98e8a13 --- /dev/null +++ b/omc/plat/sccp/ut/fsmtest/scoc_test.c @@ -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 ( ) +{ + +} diff --git a/omc/plat/scf/.copyarea.db b/omc/plat/scf/.copyarea.db new file mode 100644 index 0000000..f349f5f --- /dev/null +++ b/omc/plat/scf/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\scf +2 +5 +3:doc|2|0|0|0|f3396e8bbfa511dc8664001c23e19543|0 +2:ut|2|0|0|0|faf96ff7bfa511dc8664001c23e19543|0 +3:src|2|0|0|0|f4696edfbfa511dc8664001c23e19543|0 +8:Makefile|1|11d70a44727|b34|fa13c392|f3c96ec3bfa511dc8664001c23e19543|0 +3:lib|2|0|0|0|f3396ea7bfa511dc8664001c23e19543|0 diff --git a/omc/plat/scf/Makefile b/omc/plat/scf/Makefile new file mode 100644 index 0000000..b08238e --- /dev/null +++ b/omc/plat/scf/Makefile @@ -0,0 +1,92 @@ + +##----------------------------------------------------------## +## ## +## 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 = scf +TYPE = plat + +DBUG_FLAGS_ADD = -D_REENTRANT +RELS_FLAGS_ADD = -D_REENTRANT + +##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 = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = /ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/scf/lib/libscf.a b/omc/plat/scf/lib/libscf.a new file mode 100644 index 0000000..c7e719a Binary files /dev/null and b/omc/plat/scf/lib/libscf.a differ diff --git a/omc/plat/scf/obj/scfmsg.o b/omc/plat/scf/obj/scfmsg.o new file mode 100644 index 0000000..a81c225 Binary files /dev/null and b/omc/plat/scf/obj/scfmsg.o differ diff --git a/omc/plat/scf/obj/scsm.o b/omc/plat/scf/obj/scsm.o new file mode 100644 index 0000000..f887b4e Binary files /dev/null and b/omc/plat/scf/obj/scsm.o differ diff --git a/omc/plat/scf/src/.copyarea.db b/omc/plat/scf/src/.copyarea.db new file mode 100644 index 0000000..983b49c --- /dev/null +++ b/omc/plat/scf/src/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\scf\src +2 +6 +8:scfdef.h|1|11d70a44841|158|64be5fb7|f6296f33bfa511dc8664001c23e19543|0 +6:scsm.c|1|11d70a44812|6654|6a2a980b|ed09abf1abb711dd8553001c23e19543|0 +8:scfmsg.h|1|11d70a448cd|da2|13bffc80|fa596fdbbfa511dc8664001c23e19543|0 +8:scfpub.h|1|11d70a4487f|50|fac618e1|f6c96f4fbfa511dc8664001c23e19543|0 +7:include|2|0|0|0|f7f96f6bbfa511dc8664001c23e19543|0 +8:scfmsg.c|1|11d70a447d3|116b|b0f381f1|f4f96efbbfa511dc8664001c23e19543|0 diff --git a/omc/plat/scf/src/include/.copyarea.db b/omc/plat/scf/src/include/.copyarea.db new file mode 100644 index 0000000..10197d4 --- /dev/null +++ b/omc/plat/scf/src/include/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\scf\src\include +2 +3 +8:scfdef.h|1|11d70a44969|158|64be5fb7|f7f96f87bfa511dc8664001c23e19543|0 +8:scfmsg.h|1|11d70a449c7|da2|13bffc80|f9296fbfbfa511dc8664001c23e19543|0 +8:scfpub.h|1|11d70a44998|50|fac618e1|f8896fa3bfa511dc8664001c23e19543|0 diff --git a/omc/plat/scf/src/include/scfdef.h b/omc/plat/scf/src/include/scfdef.h new file mode 100644 index 0000000..479f4ba --- /dev/null +++ b/omc/plat/scf/src/include/scfdef.h @@ -0,0 +1,12 @@ +#ifndef _SCF_HEAD +#define _SCF_HEAD + +#define TB_SCF 100 /* timer basis is 10ms */ +#define TIMER_INIT (TB_SCF*2) +/*2s timer after tcap_begin , the first operation should be received or sent*/ +#define TIMER_SHORT (TB_SCF*10) +#define TIMER_MEDIUM (TB_SCF*30) +#define TIMER_LONG (TB_SCF*600) + +#define SSN_SCF 0x93 +#endif diff --git a/omc/plat/scf/src/include/scfmsg.h b/omc/plat/scf/src/include/scfmsg.h new file mode 100644 index 0000000..cbe9a99 --- /dev/null +++ b/omc/plat/scf/src/include/scfmsg.h @@ -0,0 +1,105 @@ +/************************************************/ +/*Title: scfmsg.h */ +/*Descr: WXC2R7.0-XAP Specification */ +/*Author: Liang Hongbin */ +/*Create: 2003-9-17 */ +/*Modify: */ +/************************************************/ + +#include "../../../xapp/src/capp/cap_head.h" +#include "../../../tcap/src/include/tcap_public.h" + +#ifndef _SCF_MESSAGE +#define _SCF_MESSAGE + +#define SCF_MAX_DLG_NUM MAX_DIALOGUEID +#define SCF_OPEN_LEN 128 +#define SCF_PORT_LEN 4 +#define CAP_CONTENT_LEN 256 +/*************************************/ +/*Macro----------------------------->*/ +/*************************************/ + +typedef struct _CAP_Message +{ + unsigned char msgLength[2]; /* unsigned char0 is the higher part */ + unsigned char msgServiceCode; /* fixed as 0xAF */ + unsigned char port_id[3]; /* unsigned char 0 is the higher part,unsigned char 1 is the lower part ,and unsigned char 2 is reserved */ + unsigned char dialogue_id[3]; + unsigned char msgOperaCode; /* message type code ,e.g , InitialDP = 0x00 */ + unsigned char msgOperaType; /* 1/2/3/4 = request, indicate, response, confirm */ + unsigned char msgContent[CAP_CONTENT_LEN]; + /* if the message if cap operation ,then the first unsigned char of msgContent is invoke id */ +}CAP_Message, *PCAP_Message; + +typedef struct _SCF_Open_Buffer +{ + unsigned char msgReadSub; + unsigned char msgWriteSub; + CAP_Message msgList[SCF_OPEN_LEN]; +}SCF_Open_Buffer, *PSCF_Open_Buffer; + +typedef struct _SCF_HPort_Buffer +{ + unsigned char msgReadSub; + unsigned char msgWriteSub; + CAP_Message msgList[SCF_PORT_LEN]; +}SCF_HPort_Buffer, *PSCF_HPort_Buffer; + +typedef struct _SCF_Port_Buffer +{ + SCF_HPort_Buffer inBuffer; /* PPS-SCSM */ + SCF_HPort_Buffer outBuffer; /* SCSM-PPS */ +}SCF_Port_Buffer, *PSCF_Port_Buffer; + +typedef struct _SCF_Buffer +{ + SCF_Open_Buffer openBuffer; + SCF_Port_Buffer portBuffer[SCF_MAX_DLG_NUM]; +}SCF_Buffer, *PSCF_Buffer; + + +enum _SCSM_STATE +{ + SCF_IDLE=0, + SCF_INIT, + SCF_PREPARING_SSF_INSTRUCTIONS, + SCF_QUEUING_FSM, + SCF_WAITING_NOTIFICATION_OR_REQUEST, + SCF_DETERMINE_MODE, + SCF_WAITING_DISCONNECT_FORWARD_CONNECT, + SCF_WAITING_PLAYANNOUNCEMENT, + SCF_VPS_PROC, + SCF_SEND_END, +}SCSM_STATE; + +//#define MAX_EDP_NUM 19 + +typedef struct _SCSM_DATA +{ + unsigned char State; + unsigned short portid; /* PPS port id */ + unsigned int Tinit; /* Timer waiting for InitialDP */ + unsigned int Twm; /* Timer waiting for message */ + unsigned int Tscf_ssf; + unsigned int Tassist; + unsigned char FirstResponse; + unsigned char endFlag; + unsigned char acn; + unsigned char acn_v; + unsigned char Tscf_ssfExpiryTimes; + unsigned char Pending; + unsigned char EDPs; + unsigned char EDP_flag[MAX_EDP_NUM]; + unsigned char invokeid; +}SCSM_DATA; + +/*** functions provided by SCSM ***/ +int PutScfOpen(CAP_Message cap_message); +int GetScfOpen(PCAP_Message pcap_message); +int PutScfMsg(CAP_Message cap_message); /* SCSM -> PPS */ +int GetScfMsg(PCAP_Message pcap_message, unsigned short dlgid); /* SCSM <- PPS*/ +int WriteScfMsg(CAP_Message cap_message); /* PPS -> SCSM */ +int ReadScfMsg(PCAP_Message pcap_message, unsigned short dlgid); /* PPS <- SCSM */ +int ClearPortSub(unsigned short dlgid); +#endif diff --git a/omc/plat/scf/src/include/scfpub.h b/omc/plat/scf/src/include/scfpub.h new file mode 100644 index 0000000..7f17a44 --- /dev/null +++ b/omc/plat/scf/src/include/scfpub.h @@ -0,0 +1,5 @@ +#ifndef _SCF_PUBLIC_H +#define _SCF_PUBLIC_H +int scsm_init(); +int scsm(); +#endif diff --git a/omc/plat/scf/src/scfdef.h b/omc/plat/scf/src/scfdef.h new file mode 100644 index 0000000..479f4ba --- /dev/null +++ b/omc/plat/scf/src/scfdef.h @@ -0,0 +1,12 @@ +#ifndef _SCF_HEAD +#define _SCF_HEAD + +#define TB_SCF 100 /* timer basis is 10ms */ +#define TIMER_INIT (TB_SCF*2) +/*2s timer after tcap_begin , the first operation should be received or sent*/ +#define TIMER_SHORT (TB_SCF*10) +#define TIMER_MEDIUM (TB_SCF*30) +#define TIMER_LONG (TB_SCF*600) + +#define SSN_SCF 0x93 +#endif diff --git a/omc/plat/scf/src/scfmsg.c b/omc/plat/scf/src/scfmsg.c new file mode 100644 index 0000000..158fabd --- /dev/null +++ b/omc/plat/scf/src/scfmsg.c @@ -0,0 +1,169 @@ +/* Title: SCF msgfunction c file */ +/* Writer: Liang Hongbin */ +/* Version: 1.0 */ +/* Date: 2003-09-18 */ +/* ------------------------------ */ +#include +//#include "scfdef.h" +#include "./include/scfmsg.h" + + +SCF_Buffer scf_buffer; +/*-----------------------------------------------------------*/ +/* Functions invoked by SCSM to put/get message from/to buffer for PPS */ +int PutScfOpen(CAP_Message cap_message) +{ + unsigned char msgWriteSub; + PSCF_Open_Buffer popen_ptr; + + popen_ptr = &scf_buffer.openBuffer; + msgWriteSub = popen_ptr->msgWriteSub%SCF_OPEN_LEN; + memcpy(&popen_ptr->msgList[msgWriteSub], + &cap_message, + sizeof(CAP_Message)); + popen_ptr->msgWriteSub = + (popen_ptr->msgWriteSub+1)%SCF_OPEN_LEN; + if(popen_ptr->msgWriteSub == popen_ptr->msgReadSub){ + popen_ptr->msgReadSub = + (popen_ptr->msgReadSub+1)%SCF_OPEN_LEN; + + } + return 1; +} + +int GetScfOpen(PCAP_Message pcap_message) +{ + unsigned char msgReadSub, msgWriteSub; + PSCF_Open_Buffer popen_ptr; + + popen_ptr = &scf_buffer.openBuffer; + msgReadSub = popen_ptr->msgReadSub%SCF_OPEN_LEN; + msgWriteSub = popen_ptr->msgWriteSub; + + if(msgReadSub == msgWriteSub) + return 0; + memcpy(pcap_message, + &popen_ptr->msgList[msgReadSub], + sizeof(CAP_Message)); + popen_ptr->msgReadSub = + (popen_ptr->msgReadSub + 1)%SCF_OPEN_LEN; + return 1; +} + +int PutScfMsg(CAP_Message cap_message) +{ + int writesub,readsub; + int did; + PSCF_HPort_Buffer pOutBuf; + + did = (cap_message.dialogue_id[0] *256) + + cap_message.dialogue_id[1]; + if(did >= SCF_MAX_DLG_NUM) + return 0; + if (cap_message.msgOperaCode == CAP_O_OPEN + && cap_message.msgOperaType == 0x02)//INDICATE + { + // + } + pOutBuf = &scf_buffer.portBuffer[did].outBuffer; + writesub = pOutBuf->msgWriteSub%SCF_PORT_LEN; + readsub = pOutBuf->msgReadSub; + memcpy(&pOutBuf->msgList[writesub], + &cap_message, + sizeof(CAP_Message)); + pOutBuf->msgWriteSub = + (pOutBuf->msgWriteSub + 1) % SCF_PORT_LEN; + if (pOutBuf->msgReadSub == pOutBuf->msgWriteSub) + pOutBuf->msgReadSub = + (pOutBuf->msgReadSub + 1) % SCF_PORT_LEN; + return 1; +} + +int GetScfMsg(PCAP_Message pcap_message,unsigned short dlgid) +{ + int readsub,writesub; + PSCF_HPort_Buffer pInBuf; + + if(dlgid>=SCF_MAX_DLG_NUM) return 0; + pInBuf = &scf_buffer.portBuffer[dlgid].inBuffer; + readsub = pInBuf->msgReadSub % SCF_PORT_LEN; + writesub = pInBuf->msgWriteSub; + + if(readsub == writesub) + return 0; + memcpy(pcap_message, + &pInBuf->msgList[readsub], + sizeof(CAP_Message)); + pInBuf->msgReadSub = + (pInBuf->msgReadSub + 1) % SCF_PORT_LEN; + return 1; +} +/* Functions invoked by SCSM to put/get message from/to buffer for PPS */ +int ReadScfMsg(PCAP_Message pcap_message, unsigned short dlgid) +{ + PSCF_HPort_Buffer pOutBuf; + + if(dlgid>=SCF_MAX_DLG_NUM) return 0; + pOutBuf = &scf_buffer.portBuffer[dlgid].outBuffer; + if (pOutBuf->msgReadSub == pOutBuf->msgWriteSub) + return 0; + memcpy(pcap_message, + &pOutBuf->msgList[pOutBuf->msgReadSub%SCF_PORT_LEN], + sizeof(CAP_Message)); + pOutBuf->msgReadSub = + (pOutBuf->msgReadSub + 1) % SCF_PORT_LEN; + + return 1; +} + +int WriteScfOpen(CAP_Message cap_message) +{ + unsigned char msgReadSub, msgWriteSub; + PSCF_Open_Buffer popen_ptr; + + popen_ptr = &scf_buffer.openBuffer; + msgReadSub = popen_ptr->msgReadSub; + msgWriteSub = popen_ptr->msgWriteSub%SCF_OPEN_LEN; + + memcpy(&popen_ptr->msgList[msgWriteSub], + &cap_message, + sizeof(CAP_Message)); + popen_ptr->msgWriteSub = + (popen_ptr->msgWriteSub + 1)%SCF_OPEN_LEN; + return 1; +} + +int WriteScfMsg(CAP_Message cap_message) +{ + unsigned int did; + PSCF_HPort_Buffer pInBuf; + + did = cap_message.dialogue_id[0]*256 + + cap_message.dialogue_id[1]; + + if(did >= SCF_MAX_DLG_NUM) + return 0; + + pInBuf = &scf_buffer.portBuffer[did].inBuffer; + + memcpy(&pInBuf->msgList[pInBuf->msgWriteSub%SCF_PORT_LEN], + &cap_message, + sizeof(CAP_Message)); + pInBuf->msgWriteSub = + (pInBuf->msgWriteSub + 1) % SCF_PORT_LEN; + if (pInBuf->msgReadSub == pInBuf->msgWriteSub) + pInBuf->msgReadSub = + (pInBuf->msgReadSub + 1) % SCF_PORT_LEN; + return 1; +} + +int ClearPortSub(unsigned short dlgid) +{ + if(dlgid>=SCF_MAX_DLG_NUM) return 0; + scf_buffer.portBuffer[dlgid].inBuffer.msgWriteSub = 0; + scf_buffer.portBuffer[dlgid].inBuffer.msgReadSub = 0; + scf_buffer.portBuffer[dlgid].outBuffer.msgWriteSub = 0; + scf_buffer.portBuffer[dlgid].outBuffer.msgReadSub = 0; + return 1; +} +/*-----------------------------------------------------------*/ diff --git a/omc/plat/scf/src/scfmsg.h b/omc/plat/scf/src/scfmsg.h new file mode 100644 index 0000000..cbe9a99 --- /dev/null +++ b/omc/plat/scf/src/scfmsg.h @@ -0,0 +1,105 @@ +/************************************************/ +/*Title: scfmsg.h */ +/*Descr: WXC2R7.0-XAP Specification */ +/*Author: Liang Hongbin */ +/*Create: 2003-9-17 */ +/*Modify: */ +/************************************************/ + +#include "../../../xapp/src/capp/cap_head.h" +#include "../../../tcap/src/include/tcap_public.h" + +#ifndef _SCF_MESSAGE +#define _SCF_MESSAGE + +#define SCF_MAX_DLG_NUM MAX_DIALOGUEID +#define SCF_OPEN_LEN 128 +#define SCF_PORT_LEN 4 +#define CAP_CONTENT_LEN 256 +/*************************************/ +/*Macro----------------------------->*/ +/*************************************/ + +typedef struct _CAP_Message +{ + unsigned char msgLength[2]; /* unsigned char0 is the higher part */ + unsigned char msgServiceCode; /* fixed as 0xAF */ + unsigned char port_id[3]; /* unsigned char 0 is the higher part,unsigned char 1 is the lower part ,and unsigned char 2 is reserved */ + unsigned char dialogue_id[3]; + unsigned char msgOperaCode; /* message type code ,e.g , InitialDP = 0x00 */ + unsigned char msgOperaType; /* 1/2/3/4 = request, indicate, response, confirm */ + unsigned char msgContent[CAP_CONTENT_LEN]; + /* if the message if cap operation ,then the first unsigned char of msgContent is invoke id */ +}CAP_Message, *PCAP_Message; + +typedef struct _SCF_Open_Buffer +{ + unsigned char msgReadSub; + unsigned char msgWriteSub; + CAP_Message msgList[SCF_OPEN_LEN]; +}SCF_Open_Buffer, *PSCF_Open_Buffer; + +typedef struct _SCF_HPort_Buffer +{ + unsigned char msgReadSub; + unsigned char msgWriteSub; + CAP_Message msgList[SCF_PORT_LEN]; +}SCF_HPort_Buffer, *PSCF_HPort_Buffer; + +typedef struct _SCF_Port_Buffer +{ + SCF_HPort_Buffer inBuffer; /* PPS-SCSM */ + SCF_HPort_Buffer outBuffer; /* SCSM-PPS */ +}SCF_Port_Buffer, *PSCF_Port_Buffer; + +typedef struct _SCF_Buffer +{ + SCF_Open_Buffer openBuffer; + SCF_Port_Buffer portBuffer[SCF_MAX_DLG_NUM]; +}SCF_Buffer, *PSCF_Buffer; + + +enum _SCSM_STATE +{ + SCF_IDLE=0, + SCF_INIT, + SCF_PREPARING_SSF_INSTRUCTIONS, + SCF_QUEUING_FSM, + SCF_WAITING_NOTIFICATION_OR_REQUEST, + SCF_DETERMINE_MODE, + SCF_WAITING_DISCONNECT_FORWARD_CONNECT, + SCF_WAITING_PLAYANNOUNCEMENT, + SCF_VPS_PROC, + SCF_SEND_END, +}SCSM_STATE; + +//#define MAX_EDP_NUM 19 + +typedef struct _SCSM_DATA +{ + unsigned char State; + unsigned short portid; /* PPS port id */ + unsigned int Tinit; /* Timer waiting for InitialDP */ + unsigned int Twm; /* Timer waiting for message */ + unsigned int Tscf_ssf; + unsigned int Tassist; + unsigned char FirstResponse; + unsigned char endFlag; + unsigned char acn; + unsigned char acn_v; + unsigned char Tscf_ssfExpiryTimes; + unsigned char Pending; + unsigned char EDPs; + unsigned char EDP_flag[MAX_EDP_NUM]; + unsigned char invokeid; +}SCSM_DATA; + +/*** functions provided by SCSM ***/ +int PutScfOpen(CAP_Message cap_message); +int GetScfOpen(PCAP_Message pcap_message); +int PutScfMsg(CAP_Message cap_message); /* SCSM -> PPS */ +int GetScfMsg(PCAP_Message pcap_message, unsigned short dlgid); /* SCSM <- PPS*/ +int WriteScfMsg(CAP_Message cap_message); /* PPS -> SCSM */ +int ReadScfMsg(PCAP_Message pcap_message, unsigned short dlgid); /* PPS <- SCSM */ +int ClearPortSub(unsigned short dlgid); +#endif diff --git a/omc/plat/scf/src/scfpub.h b/omc/plat/scf/src/scfpub.h new file mode 100644 index 0000000..7f17a44 --- /dev/null +++ b/omc/plat/scf/src/scfpub.h @@ -0,0 +1,5 @@ +#ifndef _SCF_PUBLIC_H +#define _SCF_PUBLIC_H +int scsm_init(); +int scsm(); +#endif diff --git a/omc/plat/scf/src/scsm.c b/omc/plat/scf/src/scsm.c new file mode 100644 index 0000000..6ba96c2 --- /dev/null +++ b/omc/plat/scf/src/scsm.c @@ -0,0 +1,970 @@ +/* Title: SCF fsm c file */ +/* Writter: Liang Hongbin */ +/* Version: 1.0 */ +/* Date: 2003-09-18 */ +/* ------------------------------ */ +#include "../../public/src/include/includes.h" +#include "../../xapp/src/ixap.h" +#include "../../xapp/src/capp/cap_msg.h" +#include "./include/scfdef.h" +#include "./include/scfmsg.h" +#include "./include/scfpub.h" + +extern SCF_Buffer scf_buffer; +SCSM_DATA scsm_data[SCF_MAX_DLG_NUM]; + +CAP_Message scfOpenResponse={ + {0,16}, + CAP_FLAG, + {0,0,0}, + {0,0,0}, + 0xff,//CAP_O_OPEN, + 0x03,//RESPONSE, + {2, //RESULT=accept + 1, // + 1, //acn tag + 2, //len + 50, //acn + 2, //acn version + 0,} //end flag +}; + +CAP_Message scfEnd={ + {0,12}, + CAP_FLAG, + {0,0,0}, + {0,0,0}, + 0xfe,//CAP_O_END, + 0x01,//REQUEST, + {1, //release method + 0, //optional part + 0,} +}; + +CAP_Message scfPAbort={ + {0,11}, + CAP_FLAG, + {0,0,0}, + {0,0,0}, + CAP_O_PABORT, + 0x02,//INDICATE, + {0, //provider reason + 0,} // +}; + +CAP_Message scfUAbort={ + {0,12}, + CAP_FLAG, + {0,0,0}, + {0,0,0}, + CAP_O_UABORT, + 0x01,//request, + {1, //user error + 0,0,} // +}; +/*---------------------------------------------------------*/ +void scfSendOpenResponse(unsigned char acn,unsigned char acn_v,unsigned short dlgid) +{ + CAP_Message capmsg; + + //tcap_change_local_ssn(dlgid,147,146); + memcpy(&capmsg,&scfOpenResponse,18); + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + capmsg.msgContent[4] = acn; + capmsg.msgContent[5] = acn_v; + cap_send_comdata((unsigned char *)&capmsg); +} + +void scfSendOprDataToXAP(unsigned short dlgid,unsigned char *dataflow) +{ + SCSM_DATA *scf_ptr; + + if(dlgid >= SCF_MAX_DLG_NUM) + return; + scf_ptr = &scsm_data[dlgid]; + if(!scf_ptr->FirstResponse){ + scfSendOpenResponse(scf_ptr->acn,scf_ptr->acn_v,dlgid); + scf_ptr->FirstResponse = 1; + } + if(scf_ptr->endFlag) + { + + } + cap_send_oprdata(dataflow); +} +/*---------------------------------------------------------*/ +void ResetTscf_ssf(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + + if(dlgid >= SCF_MAX_DLG_NUM) + return; + scf_ptr = &scsm_data[dlgid]; + scf_ptr->Tscf_ssf = 0; +} + +void ResetTscf_ssfExpiryTime(unsigned int dlgid) +{ + SCSM_DATA *scf_ptr; + + if(dlgid >= SCF_MAX_DLG_NUM) + return; + scf_ptr = &scsm_data[dlgid]; + scf_ptr->Tscf_ssfExpiryTimes = 0; +} + +void SendPAbortToSL(unsigned short dlgid) +{ + CAP_Message capmsg; + + memcpy(&capmsg,&scfPAbort, 14); + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + PutScfMsg(capmsg); +} + +void SendUAbortToXAP(unsigned short dlgid,u_char u_error) +{ + CAP_Message capmsg; + + memcpy(&capmsg,&scfUAbort, 14); + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + capmsg.msgContent[0] = u_error; +// capmsg.msgContent[0] = 1; + cap_send_comdata((unsigned char *)&capmsg); +} + +void SendEndToXAP(unsigned short dlgid) +{ + CAP_Message capmsg; + + memcpy(&capmsg,&scfEnd,14); + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + cap_send_comdata((unsigned char *)&capmsg); +} +/*-------------------------------------------------*/ +int scfWaitingNotificationOrRequest(unsigned short dlgid) +{ + int edp,endflag=0; + int retval,msglen,ocode=0; + SCSM_DATA *scf_ptr; + CAP_Message capmsg; + CapArg capArg; + + if(dlgid>=SCF_MAX_DLG_NUM) return SCF_IDLE; + + scf_ptr = &scsm_data[dlgid]; + retval = scf_ptr->State; + if (cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA) + { + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + + if (GetScfMsg(&capmsg,dlgid)) + { + switch(capmsg.msgOperaCode) + { + case CAP_OC_ActivityTest: + case CAP_OC_Connect: + break; + case CAP_OC_ApplyCharging: + scf_ptr->Pending ++; + break; + case CAP_OC_ReleaseCall: + case CAP_OC_ReleaseSMS: + endflag = 1; + retval = SCF_IDLE; + break; + default: //release call ,,, + break; + //scfDebugMsg("Received error operation in WaitingNotificationOrRequest"); + //SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; + break; + } + capmsg.msgContent[0] = cap_get_invokeid(dlgid); + scfSendOprDataToXAP(dlgid,(unsigned char *)&capmsg); + if (endflag) + { + SendEndToXAP(dlgid); + retval = SCF_IDLE; + } + } + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode != 0xFA) + { + PutScfMsg(capmsg); + retval = SCF_IDLE; + } + }else if(cap_get_oprdata((unsigned char *)&capmsg,dlgid)) + { + + PutScfMsg(capmsg); + ocode = capmsg.msgOperaCode; + msglen = capmsg.msgContent[3]*256+capmsg.msgContent[4]; + if(msglen>256){ + retval = SCF_IDLE; + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return retval; + } + switch(ocode) + { + case CAP_OC_ApplyChargingReport: + scf_ptr->Pending --; + if (scf_ptr->Pending == 0 && scf_ptr->EDPs == 0){ + endflag = 1; + retval = SCF_IDLE; + } + break; + case CAP_OC_EventReportBCSM: + //revised later, liang hongbin 2002-09-26 + // if more EDP requested more EDPs should be taken into account + if(decode_capmsg(&capmsg.msgContent[5],msglen,ocode,3,&capArg)<=0) + break; + edp = capArg.msg_list.eventReportBCSMArg.eventTypeBCSM; + scf_ptr->EDPs --; + + if(scf_ptr->EDP_flag[edp] == (0xF0 | capp_interrupted)) + { + ResetTscf_ssf(dlgid); + ResetTscf_ssfExpiryTime(dlgid); + retval = SCF_PREPARING_SSF_INSTRUCTIONS; + } + else + { + if(scf_ptr->Pending == 0 && scf_ptr->EDPs == 0){ + endflag = 1; + retval = SCF_IDLE; + } + } + + break; + case CAP_OC_EventReportSMS: + if(decode_capmsg(&capmsg.msgContent[5],msglen,ocode,3,&capArg)<=0) + break; + edp = capArg.msg_list.eventReportSMSArg.eventTypeSMS; + + scf_ptr->EDPs --; + if(scf_ptr->EDP_flag[edp] == (0xF0 | capp_interrupted)) + { + ResetTscf_ssf(dlgid); + ResetTscf_ssfExpiryTime(dlgid); + retval = SCF_PREPARING_SSF_INSTRUCTIONS; + } + else + { + if(scf_ptr->Pending == 0 && scf_ptr->EDPs == 0){ + endflag = 1; + retval = SCF_IDLE; + } + + } + + break; + case CAP_OC_ActivityTest: + break; + default: + endflag = 1; + retval = SCF_IDLE; + //scfDebugMsg("Receive error operation in capWaitingNotificationOrRequest"); + break; + } + if(endflag){ + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + } + } + return retval; +} + +int scfPreparingSsfInstructions(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + CAP_Message capmsg,*pcapmsg; + CapArg capArg; + int retval,len,i,endflag=0, + edp,edp_flag=0x00,edpnum=0x00; + CapRequestReportBCSMEvent *capRRE; + CapRequestReportSMSEvent *capRRSE; + + if(dlgid>=SCF_MAX_DLG_NUM) return 0; + scf_ptr = &scsm_data[dlgid]; + retval = scf_ptr->State; + + if (scf_ptr->Tscf_ssf ++ > TIMER_SHORT) + { + ResetTscf_ssf(dlgid); + if (scf_ptr->Tscf_ssfExpiryTimes ++ >= 2) + { + //scfDebugMsg("SCF timer expires while preparing ssf instructions!"); + //send cap_p_about to PPS + //send cap_p_about to XAP + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; //end + } + } + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode != 0xFA) + { + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + if(!cap_check_sendopr(dlgid)) return retval; + pcapmsg = &capmsg; + if(GetScfMsg(pcapmsg,dlgid)) + { + switch (pcapmsg->msgOperaCode) + { + case CAP_OC_ApplyCharging: + scf_ptr->Pending ++; + break; + case CAP_OC_RequestReportBCSMEvent: + len = pcapmsg->msgContent[3]*256 + pcapmsg->msgContent[4]; + if(decode_capmsg(&pcapmsg->msgContent[5], + len, + CAP_OC_RequestReportBCSMEvent, + 3, + &capArg)<=0) + break; + capRRE = &capArg.msg_list.requestReportBCSMEventArg; + edpnum = capRRE->bcsmEvents_num; + + for (i = 0;i < edpnum;i ++) + { + edp = capRRE->bcsmEvents[i].eventTypeBCSM; + switch(edp) + { + case capp_oAnswer: + case capp_tAnswer: + scf_ptr->EDPs ++; + break; + default: + edp_flag = 0x01; + break; + } + if (edp == capp_oDisconnect || edp == capp_tDisconnect) + scf_ptr->EDP_flag[edp] = 0xF0 | capp_interrupted; + else + scf_ptr->EDP_flag[edp] = 0xF0 | capRRE->bcsmEvents[i].monitorMode; + } + scf_ptr->EDPs += edp_flag; + + break; + case CAP_OC_RequestReportSMSEvent: + len = pcapmsg->msgContent[3]*256 + pcapmsg->msgContent[4]; + if(decode_capmsg(&pcapmsg->msgContent[5], + len, + CAP_OC_RequestReportSMSEvent, + 3, + &capArg)<=0) + break; + capRRSE = &capArg.msg_list.requestReportSMSEventArg; + edpnum = capRRSE->sMSEvents_num; + + for (i = 0;i < edpnum;i ++) + { + edp = capRRSE->sMSEvents[i].eventTypeSMS; + switch(edp) + { + case capp_osmsFailure: + case capp_osmsSubmitted: + scf_ptr->EDPs = 1; + break; + } + scf_ptr->EDP_flag[edp] = + 0xF0 | capRRSE->sMSEvents[i].monitorMode; + } + + break; + case CAP_OC_Continue: + case CAP_OC_ContinueSMS: + if (scf_ptr->EDPs > 0 || scf_ptr->Pending > 0) + retval = SCF_WAITING_NOTIFICATION_OR_REQUEST; + else + { + endflag = 1; + retval = SCF_IDLE; + } + break; + case CAP_OC_ReleaseCall: + case CAP_OC_ReleaseSMS: + //if (scf_ptr->EDPs > 0 || scf_ptr->Pending > 0) + // retval = SCF_WAITING_NOTIFICATION_OR_REQUEST; + //else{ + endflag = 1; + retval = SCF_IDLE; + //} + break; + case CAP_OC_Cancel: + retval = SCF_IDLE; + break; + case CAP_OC_ActivityTest: + break; + case CAP_OC_EstablishTemporaryConnection: + retval = SCF_WAITING_DISCONNECT_FORWARD_CONNECT; + break; + case CAP_O_UABORT: + SendUAbortToXAP(dlgid,pcapmsg->msgContent[0]); + return SCF_IDLE; + break; + case CAP_OC_InitialDP: + endflag = 1; + retval = SCF_IDLE; + break; + case CAP_OC_Connect: + if (scf_ptr->EDPs > 0 || scf_ptr->Pending > 0) + retval = SCF_WAITING_NOTIFICATION_OR_REQUEST; + else + { + endflag = 1; + retval = SCF_IDLE; + } + break; + case CAP_O_END: + SendEndToXAP(dlgid); + return (retval = SCF_IDLE); + break; + default: + // SendEndToXAP(dlgid); + // return (retval = SCF_IDLE); + break; + } + if (endflag) + { + if(pcapmsg->msgContent[2] == 0x02) + pcapmsg->msgContent[0]=scf_ptr->invokeid; + else + pcapmsg->msgContent[0]=cap_get_invokeid(dlgid); + scf_ptr->endFlag = 1; + scfSendOprDataToXAP(dlgid,(unsigned char *)pcapmsg); +// SendEndToXAP(dlgid); + // retval = SCF_IDLE; + retval = SCF_SEND_END; + } + else + { + if(pcapmsg->msgContent[2] == 0x02) + pcapmsg->msgContent[0]=scf_ptr->invokeid; + else + pcapmsg->msgContent[0]=cap_get_invokeid(dlgid); + scfSendOprDataToXAP(dlgid,(unsigned char *)pcapmsg); + } + + ResetTscf_ssf(dlgid); + //ResetTimer(dlgid); + } + return retval; +} + +int scfVPSProc(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + CAP_Message *pcapmsg,capmsg; + + if(dlgid>=SCF_MAX_DLG_NUM) return SCF_IDLE; + scf_ptr = &scsm_data[dlgid]; + + if (scf_ptr->Tinit++ >= TIMER_INIT) + { + //scfDebugMsg("SCF timer expires while waiting + //send cap_p_about to PPS + //send cap_p_about to XAP + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; //end + } + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA){ + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + pcapmsg = &capmsg; + if(GetScfMsg(pcapmsg,dlgid)) + { + if (pcapmsg->msgOperaCode != CAP_OC_PlayAnnouncement + && pcapmsg->msgOperaCode != 0xb1) + { + //scfDebugMsg("Receive error msg from uplayer in VPS proc"); + return SCF_IDLE; + } + pcapmsg->msgContent[0] = cap_get_invokeid(dlgid); + scfSendOprDataToXAP(dlgid,(unsigned char *)pcapmsg); + return SCF_SEND_END; + } + return SCF_VPS_PROC; +} + +int scfInitProc(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + CAP_Message capmsg; + int retval; + + + scf_ptr = &scsm_data[dlgid]; + + retval = scf_ptr->State; + if (scf_ptr->Tinit++ >= TIMER_INIT) + { + //scfDebugMsg("SCF timer expires while waiting for Initial Message!"); + //send cap_p_about to PPS + //send cap_p_about to XAP + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; //end + } + + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA){ + PutScfMsg(capmsg); + return SCF_IDLE; + } + }else if(cap_get_oprdata((unsigned char *)&capmsg,dlgid)) + { + scf_ptr->invokeid = capmsg.msgContent[0]; + switch(capmsg.msgOperaCode) + { + case CAP_OC_InitialDP: + case CAP_OC_InitialDPSMS: + PutScfMsg(capmsg); + ResetTscf_ssf(dlgid); + retval = SCF_PREPARING_SSF_INSTRUCTIONS; + break; + case CAP_OC_VPSOprRequest: + PutScfMsg(capmsg); + retval = SCF_VPS_PROC; + break; + case CAP_OC_AssistRequestInstructions: + PutScfMsg(capmsg); + retval = SCF_WAITING_PLAYANNOUNCEMENT;//??? + break; + default: + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + retval = SCF_IDLE; + break; + } + }else if(GetScfMsg(&capmsg,dlgid)) + { + capmsg.msgContent[0] = cap_get_invokeid(dlgid); + cap_send_comdata((unsigned char *)&capmsg); + return SCF_IDLE; + } + return retval; +} + +/* +int scfDetermineMode(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + int retval, len; + int invokeid, DisconnectFromSRF=0; + CAP_Message capmsg; + CapArg capArg; + CapPlayAnnouncement *capPA; + CapPromptAndCollectUserInformation *capPCUI; + + if(dlgid>=SCF_MAX_DLG_NUM) return SCF_IDLE; + scf_ptr = &scsm_data[dlgid]; + retval = scf_ptr->State; + + if(scf_ptr->Twm++>TIMER_SHORT){ + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; + } + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA){ + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + if(GetScfMsg(&capmsg,dlgid)) + { + switch(capmsg.msgOperaCode) + { + case CAP_OC_ConnectToResource: + break; + case CAP_OC_PlayAnnouncement: + len = capmsg.msgContent[3]*256 + capmsg.msgContent[4]; + decode_capmsg(&capmsg.msgContent[5], + len, + CAP_OC_PlayAnnouncement, + 3, + &capArg); + capPA = &capArg.msg_list.playAnnouncementArg; + if(capPA->optional_flag & 0x01) + { + DisconnectFromSRF = + 1 - capPA->disconnectFromIPForbidden; + }else{ + DisconnectFromSRF = 0; + } + break; + case CAP_OC_PromptAndCollectUserInformation: + len = capmsg.msgContent[3]*256 + capmsg.msgContent[4]; + decode_capmsg(&capmsg.msgContent[5], + len, + CAP_OC_PromptAndCollectUserInformation, + 3, + &capArg); + capPCUI = &capArg.msg_list.promptAndCollectUserInformationArg; + if(capPCUI->optional_flag & 0x01) + { + DisconnectFromSRF = + 1 - capPCUI->disconnectFromIPForbidden; + }else{ + DisconnectFromSRF = 0; + } + +// retval = SCF_WAITING_RESPONSE_FROM_SRF; + break; + case CAP_OC_EstablishTemporaryConnection: + scf_ptr->Twm = 0; + scf_ptr->Tassist = 0; + //correlationID = dlgid; + retval = SCF_WAITING_DISCONNECT_FORWARD_CONNECT; + break; + case CAP_OC_Connect: + break; + default: + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; + break; + } + invokeid = cap_get_invokeid(dlgid); + capmsg.msgContent[0] = invokeid; + scfSendOprDataToXAP(dlgid,(unsigned char *)&capmsg); + + if(DisconnectFromSRF) + { + scf_ptr->DisconnectFromSRF = 1; + scf_ptr->DisconnectLinkID = invokeid; + } + } + + return retval; +} +*/ +int scfWaitinDisconnectForwardConnection(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + int retval, + invokeid; + int ocode,endflag=0; + CAP_Message capmsg; + + + if(dlgid>=SCF_MAX_DLG_NUM) return SCF_IDLE; + scf_ptr = &scsm_data[dlgid]; + retval = scf_ptr->State; + + if(scf_ptr->Tassist++>(TIMER_SHORT*8)){ + return SCF_PREPARING_SSF_INSTRUCTIONS; + } + + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA) + { + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + + if(GetScfMsg(&capmsg,dlgid)) + { + switch(capmsg.msgOperaCode) + { + case CAP_OC_DisconnectForwardConnection: + retval = SCF_PREPARING_SSF_INSTRUCTIONS; + break; + case CAP_OC_ActivityTest: + scf_ptr->Tassist=0; + break; + case CAP_OC_ReleaseCall: + endflag = 1; + retval = SCF_IDLE; + break; + case CAP_O_UABORT: + SendUAbortToXAP(dlgid,capmsg.msgContent[0]); + return SCF_IDLE; + break; + default: + break; + //SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + return SCF_IDLE; + break; + } + invokeid = cap_get_invokeid(dlgid); +// capmsg.dialogue_id[0] = dlgid>>8; +// capmsg.dialogue_id[1] = dlgid; + capmsg.msgContent[0] = invokeid; + if(endflag){ + scfSendOprDataToXAP(dlgid,(unsigned char *)&capmsg); + SendEndToXAP(dlgid); + retval = SCF_IDLE; + }else{ + scfSendOprDataToXAP(dlgid,(unsigned char *)&capmsg); + } + } + endflag = 0; + if(cap_get_oprdata((unsigned char *)&capmsg,dlgid)) + { + + PutScfMsg(capmsg); + ocode = capmsg.msgOperaCode; + switch(ocode) + { + case CAP_OC_EventReportBCSM: + //revised later, liang hongbin 2002-09-26 + // if more EDP requested more EDPs should be taken into account + /* + decode_capmsg(&capmsg.msgContent[5],msglen,ocode,3,&capArg); + edp = capArg.msg_list.eventReportBCSMArg.eventTypeBCSM; + scf_ptr->EDPs --; + if(scf_ptr->EDP_flag[edp] == (0xF0 | capp_interrupted)) + { + ResetTscf_ssf(dlgid); + ResetTscf_ssfExpiryTime(dlgid); + retval = SCF_PREPARING_SSF_INSTRUCTIONS; + } + else + { + if(scf_ptr->Pending == 0 && scf_ptr->EDPs == 0){ + endflag = 1; + retval = SCF_IDLE; + } + } + */ + break; + case CAP_OC_ActivityTest: + case CAP_OC_EstablishTemporaryConnection: + scf_ptr->Tassist=0; + break; + default: + endflag = 1; + retval = SCF_IDLE; + break; + } + if(endflag){ + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + } + } + return retval; +} + +/*-----------------------------------------------------*/ +int scfWaitingPlayAnnouncement(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + int retval; + int invokeid; + CAP_Message capmsg; + + if(dlgid>=SCF_MAX_DLG_NUM) return SCF_IDLE; + scf_ptr = &scsm_data[dlgid]; + retval = scf_ptr->State; + + if(scf_ptr->Tassist++>TIMER_LONG) + { + SendPAbortToSL(dlgid); + SendEndToXAP(dlgid); + scf_ptr->endFlag = 1; + return SCF_IDLE; + } + if(cap_get_comdata((unsigned char *)&capmsg,dlgid)) + { + if(capmsg.msgOperaCode !=0xFA) + { + PutScfMsg(capmsg); + return SCF_IDLE; + } + } + + + if(cap_get_oprdata((unsigned char *)&capmsg,dlgid)) + { + scf_ptr->Tassist = 0; + switch(capmsg.msgOperaCode) + { + case CAP_OC_SpecializedResourceReport: + break; + case CAP_OC_PromptAndCollectUserInformation: + break; + default: + return retval; + break; + } + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + PutScfMsg(capmsg); + }else if(GetScfMsg(&capmsg,dlgid)) + { + scf_ptr->Tassist = 0; + switch(capmsg.msgOperaCode) + { + case CAP_O_UABORT: + SendUAbortToXAP(dlgid,capmsg.msgContent[0]); + scf_ptr->endFlag = 1; + return SCF_IDLE; + break; + case CAP_O_END: + SendEndToXAP(dlgid); + scf_ptr->endFlag = 1; + return SCF_IDLE; + break; + default: + break; + } + if(capmsg.msgContent[2] == 0x02) //u_error + { + invokeid = scf_ptr->invokeid; + } + else + invokeid = cap_get_invokeid(dlgid); + capmsg.dialogue_id[0] = dlgid>>8; + capmsg.dialogue_id[1] = dlgid; + capmsg.msgContent[0] = invokeid; + scfSendOprDataToXAP(dlgid,(unsigned char *)&capmsg); + } + + return retval; +} + +int scfSendTCEnd(u_short dlgid) +{ + int retval = 0; + CAP_Message *pcapmsg,capmsg; + + if(cap_check_sendcom(dlgid)) + { + pcapmsg = &capmsg; + memcpy(pcapmsg,&scfEnd,14); + pcapmsg->dialogue_id[0] = dlgid>>8; + pcapmsg->dialogue_id[1] = dlgid; + cap_send_comdata((unsigned char *)pcapmsg); + retval = 1; + } + return retval; +} +/*-----------------------------------------------------*/ + +int scsm_init() +{ + icap_reg_ssn(SSN_SCF); + return 1; +} + +int ClearThreadData(unsigned short dlgid) +{ + if(dlgid>=SCF_MAX_DLG_NUM) return 0; + memset(&scsm_data[dlgid],0,sizeof(SCSM_DATA)); + return 1; +} + + +int scsmGetOpen() +{ + register int id; + unsigned short dlgid; + CAP_Message capmsg; + + for(id=0;id<64;id++) + { + if(!cap_get_open((unsigned char *)&capmsg,SSN_SCF)) + return 1; +/* + if(capmsg.msgOperaCode != CAP_O_OPEN) + continue; +*/ + dlgid = capmsg.dialogue_id[0]*256+capmsg.dialogue_id[1]; + if(dlgid>=SCF_MAX_DLG_NUM) + continue; + if(scsm_data[dlgid].State != SCF_IDLE) + continue; + + ClearPortSub(dlgid); + ClearThreadData(dlgid); + + PutScfOpen(capmsg); + + scsm_data[dlgid].State = SCF_INIT; + scsm_data[dlgid].acn = capmsg.msgContent[0]; + scsm_data[dlgid].acn_v = capmsg.msgContent[1]; + } + return 1; +} + + +int scf_fsm(unsigned short dlgid) +{ + SCSM_DATA *scf_ptr; + + scf_ptr = &scsm_data[dlgid]; + + switch (scf_ptr->State) + { + case SCF_IDLE: + break; + case SCF_INIT: + scf_ptr->State = scfInitProc(dlgid); + break; + case SCF_PREPARING_SSF_INSTRUCTIONS: + scf_ptr->State = scfPreparingSsfInstructions(dlgid); + break; + case SCF_WAITING_NOTIFICATION_OR_REQUEST: + scf_ptr->State = scfWaitingNotificationOrRequest(dlgid); + break; + case SCF_WAITING_DISCONNECT_FORWARD_CONNECT: + scf_ptr->State = scfWaitinDisconnectForwardConnection(dlgid); + break; + case SCF_WAITING_PLAYANNOUNCEMENT: + scf_ptr->State = scfWaitingPlayAnnouncement(dlgid); + break; + case SCF_VPS_PROC: + scf_ptr->State = scfVPSProc(dlgid); + break; + case SCF_SEND_END: + scfSendTCEnd(dlgid); + scf_ptr->State = SCF_IDLE; + break; + default: + scf_ptr->State = SCF_IDLE; + break; + } + return 0; +} + +int scsm() +{ + register int id; + + scsmGetOpen(); + + for(id=0;id 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 = sip +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = -lm + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../app + +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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/sip/lib/libsip.a b/omc/plat/sip/lib/libsip.a new file mode 100644 index 0000000..a742a53 Binary files /dev/null and b/omc/plat/sip/lib/libsip.a differ diff --git a/omc/plat/sip/obj/sip.o b/omc/plat/sip/obj/sip.o new file mode 100644 index 0000000..8c4643f Binary files /dev/null and b/omc/plat/sip/obj/sip.o differ diff --git a/omc/plat/sip/obj/sip_debug.o b/omc/plat/sip/obj/sip_debug.o new file mode 100644 index 0000000..8c17bc5 Binary files /dev/null and b/omc/plat/sip/obj/sip_debug.o differ diff --git a/omc/plat/sip/obj/sip_msg.o b/omc/plat/sip/obj/sip_msg.o new file mode 100644 index 0000000..f0eb845 Binary files /dev/null and b/omc/plat/sip/obj/sip_msg.o differ diff --git a/omc/plat/sip/obj/sip_msg_encode.o b/omc/plat/sip/obj/sip_msg_encode.o new file mode 100644 index 0000000..6b914d2 Binary files /dev/null and b/omc/plat/sip/obj/sip_msg_encode.o differ diff --git a/omc/plat/sip/obj/sip_msg_parse.o b/omc/plat/sip/obj/sip_msg_parse.o new file mode 100644 index 0000000..4be2b1a Binary files /dev/null and b/omc/plat/sip/obj/sip_msg_parse.o differ diff --git a/omc/plat/sip/obj/sip_transaction.o b/omc/plat/sip/obj/sip_transaction.o new file mode 100644 index 0000000..333505c Binary files /dev/null and b/omc/plat/sip/obj/sip_transaction.o differ diff --git a/omc/plat/sip/obj/sip_transport.o b/omc/plat/sip/obj/sip_transport.o new file mode 100644 index 0000000..57600a7 Binary files /dev/null and b/omc/plat/sip/obj/sip_transport.o differ diff --git a/omc/plat/sip/obj/sip_ua.o b/omc/plat/sip/obj/sip_ua.o new file mode 100644 index 0000000..37f1d28 Binary files /dev/null and b/omc/plat/sip/obj/sip_ua.o differ diff --git a/omc/plat/sip/obj/sip_ua_dialog.o b/omc/plat/sip/obj/sip_ua_dialog.o new file mode 100644 index 0000000..ac45e3f Binary files /dev/null and b/omc/plat/sip/obj/sip_ua_dialog.o differ diff --git a/omc/plat/sip/obj/sip_ua_fsm.o b/omc/plat/sip/obj/sip_ua_fsm.o new file mode 100644 index 0000000..985ba53 Binary files /dev/null and b/omc/plat/sip/obj/sip_ua_fsm.o differ diff --git a/omc/plat/sip/obj/sip_ua_msg.o b/omc/plat/sip/obj/sip_ua_msg.o new file mode 100644 index 0000000..76b957a Binary files /dev/null and b/omc/plat/sip/obj/sip_ua_msg.o differ diff --git a/omc/plat/sip/src/.copyarea.db b/omc/plat/sip/src/.copyarea.db new file mode 100644 index 0000000..4abbf50 --- /dev/null +++ b/omc/plat/sip/src/.copyarea.db @@ -0,0 +1,16 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sip\src +2 +c +c:sip_ua_fsm.c|1|11d70c3d925|4c51|d85939ab|513a4fa8abd011dd8639001c23e19543|0 +c:sip_ua_msg.c|1|11d70c3d993|8589|2c7f377b|55fa4fc8abd011dd863c001c23e19543|0 +8:sip_ua.c|1|11d70c3d83b|5863|ce6c57b9|500a4fa1abd011dd8638001c23e19543|0 +9:sip_msg.c|1|11d70c3d608|adb0|d0f9f939|4eda4f96abd011dd8637001c23e19543|0 +11:sip_transaction.c|1|11d70c3d7ae|9a06|aaf1e8e1|526a4fb3abd011dd8639001c23e19543|0 +f:sip_msg_parse.c|1|11d70c3d712|1afaf|a163b5b0|5a2a4fe5abd011dd863e001c23e19543|0 +f:sip_ua_dialog.c|1|11d70c3d8a8|2ae5|57b2e600|543a4fbaabd011dd863a001c23e19543|0 +7:include|2|0|0|0|e0e2282a7fad11dd863a001c23e19543|0 +5:sip.c|1|11d70a490ea|1b09|f1fe8a16|1d1231c07faf11dd8601001c23e19543|0 +10:sip_msg_encode.c|1|11d70c3d694|c0fa|92d76863|b8ea7aa3abd611dd869a001c23e19543|0 +b:sip_debug.c|1|11d70a49118|1674|6cdc7efa|f345817fa3f111dd8f7b001c23e19543|0 +f:sip_transport.c|1|11d70a49232|12f2|5c19ee92|1be231487faf11dd8601001c23e19543|0 diff --git a/omc/plat/sip/src/include/.copyarea.db b/omc/plat/sip/src/include/.copyarea.db new file mode 100644 index 0000000..55fca36 --- /dev/null +++ b/omc/plat/sip/src/include/.copyarea.db @@ -0,0 +1,24 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\sip\src\include +2 +14 +c:sip_ua_def.h|1|11d70a49696|20c|7b08a79c|20a233707faf11dd8601001c23e19543|0 +9:sip_def.h|1|11d70a49445|49e|822376ed|1e4232687faf11dd8601001c23e19543|0 +11:sip_transaction.h|1|11d70a495bb|1a6|cebc9201|1e4232807faf11dd8601001c23e19543|0 +b:sip_const.h|1|11d70a493d7|16c7|620c3467|1f7232c87faf11dd8601001c23e19543|0 +9:sip_msg.h|1|11d70a494a2|83f|eac0d691|1ed232987faf11dd8601001c23e19543|0 +8:sip_ua.h|1|11d70a49629|47a|66f878bd|20a233887faf11dd8601001c23e19543|0 +10:sip_msg_encode.h|1|11d70a494e1|3d0|1ad92a7d|201233287faf11dd8601001c23e19543|0 +c:sip_ua_ext.h|1|11d70a49723|258|68ffc5aa|1ed232b07faf11dd8601001c23e19543|0 +9:sip_pub.h|1|11d70a4954e|3cd|aa104401|1da232207faf11dd8601001c23e19543|0 +9:sip_ext.h|1|11d70a49473|4fa|d9a013|214233a07faf11dd8601001c23e19543|0 +f:sip_msg_parse.h|1|11d70a4951f|1d8|351da001|1d1231d87faf11dd8601001c23e19543|0 +b:sip_debug.h|1|11d70a49406|ea|4dcc4c61|20a233587faf11dd8601001c23e19543|0 +c:sip_struct.h|1|11d70a4958d|443|cfaf4480|201233107faf11dd8601001c23e19543|0 +c:sip_ua_pub.h|1|11d70a497a0|3d4|3e8145f5|1da232387faf11dd8601001c23e19543|0 +c:sip_ua_msg.h|1|11d70c3da9d|85d|aa21d0ee|57ca4fd3abd011dd863c001c23e19543|0 +f:sip_ua_dialog.h|1|11d70a496c5|8ed|a01f5fb7|1da232087faf11dd8601001c23e19543|0 +f:sip_ua_struct.h|1|11d70a497de|318|d1ecdbc7|1d1231f07faf11dd8601001c23e19543|0 +5:sip.h|1|11d70c3da20|48c9|58ae7a2b|ba1a7aa4abd611dd869b001c23e19543|0 +e:sip_ua_const.h|1|11d70a49667|70d|fc94c446|1f7232e07faf11dd8601001c23e19543|0 +f:sip_transport.h|1|11d70a495fa|129|1b65a8|201233407faf11dd8601001c23e19543|0 diff --git a/omc/plat/sip/src/include/sip.h b/omc/plat/sip/src/include/sip.h new file mode 100644 index 0000000..45e1ef9 --- /dev/null +++ b/omc/plat/sip/src/include/sip.h @@ -0,0 +1,720 @@ +#ifndef _SIP__H +#define _SIP__H + +#include "sip_pub.h" + +// SIP general constant +#define SIP_MAX_USER_NAME_LEN 64//128 +#define SIP_MAX_PASSWORD_LEN 16 +#define SIP_MAX_DOMAIN_NAME_LEN 128//256 +#define SIP_MAX_REASON_PHRASE_LEN 128 +#define SIP_MAX_HDR_FLAG_NUM 2 +#define SIP_MAX_BODY_LEN 1500 +#define SIP_MAX_DISPLAY_NAME_LEN 64 +#define SIP_MAX_CALL_ID_LEN 128 +#define SIP_MAX_GEN_PARA_NUM 8 +#define SIP_MAX_PARA_STRING_LEN 64//128 +#define SIP_MAX_PARA_VAL_LEN 4 +#define SIP_MAX_PARA_NUM 4//8 +#define SIP_MAX_NUM_OF_TRANS 4096//8192 +#define SIP_MAX_NUM_OF_VIAS 8//32 +#define SIP_MAX_NUM_OF_CONTACTS 4 +#define SIP_MAX_NUM_OF_RECORD_ROUTES 8//32 +#define SIP_MAX_NUM_OF_ROUTES 8//32 +#define SIP_MAX_NUM_OF_ALLOW 8//32 +#define SIP_MAX_NUM_OF_ACCEPT 8 +#define SIP_MAX_NUM_OF_ACCEPT_ENCODING 4 +#define SIP_MAX_NUM_OF_ACCEPT_LANGUAGE 8 +#define SIP_MAX_LENGTH_OF_EVENT 32 +#define SIP_MAX_LENGTH_OF_USER_AGENT 64 +#define SIP_MAX_LENGTH_OF_SUBJECT 128 +#define SIP_MAX_LENGTH_OF_SUB_STATE 128 +#define SIP_MAX_VIA_DOMAIN_NAME_LEN 64 + +#define SIP_MAX_NUM_OF_SIP_SUB_BODY 2 + +#define SIP_URI_TYPE_SIP 1 +#define SIP_URI_TYPE_SIPS 2 +#define SIP_URI_TYPE_TEL 3 + +#define SIP_API_TYPE_REQUEST 1 +#define SIP_API_TYPE_RESPONSE 2 +#define SIP_API_TYPE_MANAGEMENT 3 + +#define SIP_API_PNAME_TAG 1 +#define SIP_API_PNAME_BRANCH 2 +#define SIP_API_PNAME_EXPIRES 3 +#define SIP_API_PNAME_USER 4 +#define SIP_API_PNAME_LR 5 +#define SIP_API_PNAME_BOUNDARY 6 +#define SIP_API_PNAME_HANDLING 7 +#define SIP_API_PNAME_TRANSPORT 8 +#define SIP_API_PNAME_RPOTR 9 +#define SIP_API_PNAME_VERSION 10 +#define SIP_API_PNAME_BASE 11 + +#define SIP_API_PTYPE_STRING 1 +#define SIP_API_PTYPE_VALUE 2 +#define SIP_API_PTYPE_TAG 3 + +#define SIP_API_PROTO_UDP 1 +#define SIP_API_PROTO_TCP 2 +#define SIP_API_PROTO_SCTP 3 + +#define SIP_NULL_TRANS_ID 0xFFFF +#define SIP_NULL_UP_PORT 0xFFFF + +#define SIP_TRANSPORT_LAYER 1 +#define SIP_TRANSACTION_LAYER 2 + +#define SIP_API_REQ_MSG 1 +#define SIP_API_RES_MSG 2 +#define SIP_API_MANAGE_MSG 3 + +#define SIP_TRANS_CLIENT 1 +#define SIP_TRANS_SERVER 2 + +#define SIP_TRANS_INVITE 1 +#define SIP_TRANS_NON_INVITE 2 + +#define SIP_ACCEPT_TYPE_APPLICATION 1 +#define SIP_ACCEPT_TYPE_MULTIPART 2 +#define SIP_ACCEPT_TYPE_WILDCARD 3 + +#define SIP_ACCEPT_SUB_TYPE_SDP 1 +#define SIP_ACCEPT_SUB_TYPE_ISUP 2 +#define SIP_ACCEPT_SUB_TYPE_MIXED 3 +#define SIP_ACCEPT_SUB_TYPE_WILDCARD 4 + +#define SIP_ACCEPT_ENCODING_IDENTITY 1 +#define SIP_ACCEPT_ENCODING_GZIP 2 +#define SIP_ACCEPT_ENCODING_TAR 3 + +#define SIP_ACCEPT_LANGUAGE_EN 1 + +#define SIP_CONTENT_TYPE_APPLICATION 1 +#define SIP_CONTENT_TYPE_MULTIPART 2 +#define SIP_CONTENT_TYPE_TEXT 3 +#define SIP_CONTENT_TYPE_IMAGE 4 +#define SIP_CONTENT_TYPE_AUDIO 5 +#define SIP_CONTENT_TYPE_VEDIO 6 + +#define SIP_CONTENT_SUB_TYPE_SDP 1 +#define SIP_CONTENT_SUB_TYPE_ISUP 2 +#define SIP_CONTENT_SUB_TYPE_MIXED 3 +#define SIP_CONTENT_SUB_TYPE_MESSAGE 4 +#define SIP_CONTENT_SUB_TYPE_SIGNED 5 +#define SIP_CONTENT_SUB_TYPE_PKCS7_MIME 6 + +#define SIP_CONTENT_DISPOSITION_SIGNAL 1 + +#define SIP_CONTENT_ENCODING_IDENTITY 1 +#define SIP_CONTENT_ENCODING_GZIP 2 +#define SIP_CONTENT_ENCODING_TAR 3 + +#define SIP_CONTENT_LANGUAGE_EN 1 + +#define SIP_DATE_TYPE_GMT 1 + +#define SIP_DATE_WEEK_DAY_SUN 1 +#define SIP_DATE_WEEK_DAY_MON 2 +#define SIP_DATE_WEEK_DAY_TUE 3 +#define SIP_DATE_WEEK_DAY_WED 4 +#define SIP_DATE_WEEK_DAY_THU 5 +#define SIP_DATE_WEEK_DAY_FRI 6 +#define SIP_DATE_WEEK_DAY_SAT 7 + +#define SIP_DATE_MONTH_JAN 1 +#define SIP_DATE_MONTH_FEB 2 +#define SIP_DATE_MONTH_MAR 3 +#define SIP_DATE_MONTH_APR 4 +#define SIP_DATE_MONTH_MAY 5 +#define SIP_DATE_MONTH_JUN 6 +#define SIP_DATE_MONTH_JUL 7 +#define SIP_DATE_MONTH_AUG 8 +#define SIP_DATE_MONTH_SEP 9 +#define SIP_DATE_MONTH_OCT 10 +#define SIP_DATE_MONTH_NOV 11 +#define SIP_DATE_MONTH_DEC 12 + +#define SIP_OPTION_TAG_100_REL 1 +#define SIP_OPTION_TAG_FOO 2 + +#define SIP_TRANSACTION_TIMEOUT 99 +#define SIP_TRANSPORT_ERROR 98 + +// SIP general headers mask +#define SIP_HDR_ACCEPT_MASK 0x00000001 +#define SIP_HDR_ACCEPT_ENCODING_MASK 0x00000002 +#define SIP_HDR_ACCEPT_LANGUAGE_MASK 0x00000004 +#define SIP_HDR_ALLOW_MASK 0x00000008 +#define SIP_HDR_CALL_ID_MASK 0x00000010 +#define SIP_HDR_CONTACT_MASK 0x00000020 +#define SIP_HDR_CSEQ_MASK 0x00000040 +#define SIP_HDR_DATE_MASK 0x00000080 +#define SIP_HDR_EXPIRES_MASK 0x00000100 +#define SIP_HDR_FROM_MASK 0x00000200 +#define SIP_HDR_TO_MASK 0x00000400 +#define SIP_HDR_VIA_MASK 0x00000800 +#define SIP_HDR_CONTENT_DISPOSITION_MASK 0x00001000 +#define SIP_HDR_CONTENT_TYPE_MASK 0x00002000 +#define SIP_HDR_CONTENT_ENCODING_MASK 0x00004000 +#define SIP_HDR_CONTENT_LANGUAGE_MASK 0x00008000 +#define SIP_HDR_CONTENT_LENGTH_MASK 0x00010000 +#define SIP_HDR_RECORD_ROUTE_MASK 0x00020000 +#define SIP_HDR_TIMESTAMP_MASK 0x00040000 +#define SIP_HDR_MIME_VERSION_MASK 0x00080000 +#define SIP_HDR_SUPPORTED_MASK 0x00100000 +#define SIP_HDR_USER_AGENT_MASK 0x00200000 + +// SIP request headers mask +#define SIP_HDR_MAX_FORWARDS_MASK 0x00000001 +#define SIP_HDR_ROUTE_MASK 0x00000002 +#define SIP_HDR_PROXY_REQUIRE_MASK 0x00000004 +#define SIP_HDR_SUBJECT_MASK 0x00000008 +#define SIP_HDR_REQUIRE_MASK 0x00000010 +#define SIP_HDR_REFER_TO_MASK 0x00000020 +#define SIP_HDR_EVENT_MASK 0x00000040 +#define SIP_HDR_SUBSCRIPTION_STATE_MASK 0x00000080 + +//SIP response headers mask +#define SIP_HDR_UNSUPPORTED_MASK 0x00000001//just used in 420 response +#define SIP_HDR_SERVER_MASK 0x00000002 + +#define SIP_METHOD_REGISTER 1 +#define SIP_METHOD_INVITE 2 +#define SIP_METHOD_ACK 3 +#define SIP_METHOD_CANCEL 4 +#define SIP_METHOD_BYE 5 +#define SIP_METHOD_OPTIONS 6 +#define SIP_METHOD_INFO 7 +#define SIP_METHOD_PRACK 8 +#define SIP_METHOD_UPDATE 9 +#define SIP_METHOD_REFER 10 +#define SIP_METHOD_NOTIFY 11 +#define SIP_METHOD_RE_INVITE 12 + +#define SIP_METHOD_RESPONSE_INV_RINGING 30 +#define SIP_METHOD_RESPONSE_INV_PROGRESS 31 +#define SIP_METHOD_RESPONSE_INV_CONFIRM 32 +#define SIP_METHOD_RESPONSE_INV_REDIR 33 +#define SIP_METHOD_RESPONSE_INV_REL 34 +#define SIP_METHOD_RESPONSE_CANCEL 35 +#define SIP_METHOD_RESPONSE_BYE 36 +#define SIP_METHOD_RESPONSE_CONFIRM 37//just for other method response +#define SIP_METHOD_RESPONSE_REL 38//just for other method response +#define SIP_METHOD_RESPONSE_TIMEOUT 39 +#define SIP_METHOD_RESPONSE_RE_INV_RINGING 40 +#define SIP_METHOD_RESPONSE_RE_INV_PROGRESS 41 +#define SIP_METHOD_RESPONSE_RE_INV_CONFIRM 43 +#define SIP_METHOD_RESPONSE_RE_INV_RETRANSMIT 44 +#define SIP_METHOD_RESPONSE_RE_INV_FAILED 45 +#define SIP_METHOD_RESPONSE_RE_INV_RELEASE 46 +#define SIP_METHOD_RESPONSE_UPDATE_CONFIRM 47 +#define SIP_METHOD_RESPONSE_UPDATE_FAILED 48 + +#define SIP_PROXY_TYPE_NONE 0 +#define SIP_PROXY_TYPE_STATEFUL 1 +#define SIP_PROXY_TYPE_STATELESS 2 + +// SIP general parameters struct + +typedef struct _SIP_GEN_PARA +{ + BYTE paraName; + BYTE paraType; +// char paraStr[SIP_MAX_PARA_STRING_LEN]; +// DWORD paraVal[SIP_MAX_PARA_VAL_LEN]; + union + { + char paraStr[SIP_MAX_PARA_STRING_LEN]; + DWORD paraVal[SIP_MAX_PARA_VAL_LEN]; + }para; + +}SIP_GEN_PARA; + +typedef struct _SIP_GEN_PARAMS +{ + BYTE paraNum; + SIP_GEN_PARA para[SIP_MAX_PARA_NUM]; +}SIP_GEN_PARAMS; + +// SIP URI struct +typedef struct _SIP_URI +{ + BYTE uriType; + char userName[SIP_MAX_USER_NAME_LEN]; + char password[SIP_MAX_PASSWORD_LEN]; + struct + { + BYTE type; + union + { + DWORD ipV4; + DWORD ipV6[4]; + char domain[SIP_MAX_DOMAIN_NAME_LEN]; + }addr; + }host; + WORD port; + BYTE transport; + SIP_GEN_PARAMS params; +}SIP_URI; + +typedef struct _SIP_VIA_URI +{ + char domain[SIP_MAX_VIA_DOMAIN_NAME_LEN]; + WORD port; +// SIP_GEN_PARAMS params; +}SIP_VIA_URI; + +// SIP general header struct + +typedef struct _SIP_HDR_ACCEPT +{ + BYTE type; + BYTE subType; + SIP_GEN_PARAMS params; +}SIP_HDR_ACCEPT; + +typedef struct _SIP_HDR_ACCEPT_ENCODING +{ + BYTE acceptEncoding; + SIP_GEN_PARAMS params; +}SIP_HDR_ACCEPT_ENCODING; + +typedef struct _SIP_HDR_ACCEPT_LANGUAGE +{ + BYTE acceptLanguage; + SIP_GEN_PARAMS params; +}SIP_HDR_ACCEPT_LANGUAGE; + +typedef struct _SIP_HDR_CALL_ID +{ + char value[SIP_MAX_CALL_ID_LEN]; + char host[SIP_MAX_DOMAIN_NAME_LEN]; +}SIP_HDR_CALL_ID; + +typedef struct _SIP_HDR_CONTACT +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_CONTACT; + +typedef struct _SIP_HDR_CONTACTS +{ + BYTE num; + BYTE head; + SIP_HDR_CONTACT contacts[SIP_MAX_NUM_OF_CONTACTS]; +}SIP_HDR_CONTACTS; + +typedef struct _SIP_HDR_CSEQ +{ + DWORD value; + BYTE method; +}SIP_HDR_CSEQ; + +typedef struct _SIP_HDR_DATE +{ + BYTE wkDay; + BYTE mDay; + BYTE mon; + DWORD year; + BYTE hour; + BYTE min; + BYTE sec; + BYTE dateType; + +}SIP_HDR_DATE; + +typedef struct _SIP_HDR_MIME_VERSION +{ + BYTE mimeVersion; +}SIP_HDR_MIME_VERSION; + +typedef struct _SIP_HDR_ENCRYPTION +{ +}SIP_HDR_ENCRYPTION; + +typedef struct _SIP_HDR_EXPIRES +{ + DWORD value; +}SIP_HDR_EXPIRES; + +typedef struct _SIP_HDR_FROM +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_FROM; + +typedef struct _SIP_HDR_ORGANIZATION +{ +}SIP_HDR_ORGANIZATION; + +typedef struct _SIP_HDR_RECORD_ROUTE +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_RECORD_ROUTE; + +typedef struct _SIP_HDR_RECORD_ROUTES +{ + BYTE num; + BYTE head; + SIP_HDR_RECORD_ROUTE recRoutes[SIP_MAX_NUM_OF_RECORD_ROUTES]; +}SIP_HDR_RECORD_ROUTES; + +typedef struct _SIP_HDR_TIMESTAMP +{ + DWORD timeStamp; +}SIP_HDR_TIMESTAMP; + +typedef struct _SIP_HDR_TO +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_TO; + +typedef struct _SIP_HDR_USER_AGENT +{ + BYTE agent[SIP_MAX_LENGTH_OF_USER_AGENT]; +}SIP_HDR_USER_AGENT; + +typedef struct _SIP_HDR_VIA +{ + BYTE version; + BYTE protocol; +// SIP_URI url; + SIP_VIA_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_VIA; + +typedef struct _SIP_HDR_VIAS +{ + BYTE num; + BYTE head; + SIP_HDR_VIA vias[SIP_MAX_NUM_OF_VIAS]; +}SIP_HDR_VIAS; + +// SIP request header struct +typedef struct _SIP_HDR_AUTHORIZATION +{ +}SIP_HDR_AUTHORIZATION; + +typedef struct _SIP_HDR_HIDE +{ +}SIP_HDR_HIDE; + +typedef struct _SIP_HDR_MAX_FORWARDS +{ + WORD value; +}SIP_HDR_MAX_FORWARDS; + +typedef struct _SIP_HDR_PRIORITY +{ +}SIP_HDR_PRIORITY; + +typedef struct _SIP_HDR_PROXY_AUTHORIZATION +{ +}SIP_HDR_PROXY_AUTHORIZATION; + +typedef struct _SIP_HDR_PROXY_REQUIRE +{ + BYTE optionTag; +}SIP_HDR_PROXY_REQUIRE; + +typedef struct _SIP_HDR_ROUTE +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_ROUTE; + +typedef struct _SIP_HDR_ROUTES +{ + BYTE num; + BYTE head; + SIP_HDR_ROUTE routes[SIP_MAX_NUM_OF_ROUTES]; +}SIP_HDR_ROUTES; + +typedef struct _SIP_HDR_REFER_TO +{ + char dispName[SIP_MAX_DISPLAY_NAME_LEN]; + SIP_URI url; + SIP_GEN_PARAMS params; +}SIP_HDR_REFER_TO; + +typedef struct _SIP_HDR_SUBSCRIPTION_STATE +{ + char subscriptionState[SIP_MAX_LENGTH_OF_SUB_STATE]; +}SIP_HDR_SUBSCRIPTION_STATE; + +typedef struct _SIP_HDR_EVENT +{ + char event[SIP_MAX_LENGTH_OF_EVENT]; +}SIP_HDR_EVENT; + +typedef struct _SIP_HDR_REQUIRE +{ + BYTE optionTag; +}SIP_HDR_REQUIRE; + +typedef struct _SIP_HDR_RESPONSE_KEY +{ +}SIP_HDR_RESPONSE_KEY; + +typedef struct _SIP_HDR_SUBJECT +{ + BYTE subject[SIP_MAX_LENGTH_OF_SUBJECT]; +}SIP_HDR_SUBJECT; + +typedef struct _SIP_HDR_SUPPORTED +{ + BYTE optionTag; +}SIP_HDR_SUPPORTED; + +// SIP response header struct +typedef struct _SIP_HDR_ALLOW +{ + BYTE num; + BYTE allowMethod[SIP_MAX_NUM_OF_ALLOW]; +}SIP_HDR_ALLOW; + +typedef struct _SIP_HDR_PROXY_AUTHENTICATE +{ +}SIP_HDR_PROXY_AUTHENTICATE; + +typedef struct _SIP_HDR_RETRY_AFTER +{ +}SIP_HDR_RETRY_AFTER; + +typedef struct _SIP_HDR_SERVER +{ + BYTE server[64]; +}SIP_HDR_SERVER; + +typedef struct _SIP_HDR_UNSUPPORTED +{ + BYTE optionTag; +}SIP_HDR_UNSUPPORTED; + +typedef struct _SIP_HDR_WARNING +{ +}SIP_HDR_WARNING; + +typedef struct _SIP_HDR_WWW_AUTHENTICATE +{ +}SIP_HDR_WWW_AUTHENTICATE; + +// SIP message struct +typedef struct _SIP_START_LINE +{ + BYTE sipVersion; // Public + + BYTE sipMethod; // Request + SIP_URI requestUri; + + int statusCode; // Response + char reasonPhrase[SIP_MAX_REASON_PHRASE_LEN]; +}SIP_START_LINE; + +typedef struct _SIP_CONTENT_TYPE +{ + BYTE type; + BYTE subType; + SIP_GEN_PARAMS params; +}SIP_CONTENT_TYPE; + +typedef struct _SIP_CONTENT_DISPOSITION +{ + BYTE contentDisposition; + SIP_GEN_PARAMS params; +}SIP_CONTENT_DISPOSITION; + +typedef struct _SIP_MESSAGE_BODY +{ + DWORD sipBodyHdrFlg[SIP_MAX_HDR_FLAG_NUM]; + SIP_CONTENT_TYPE sipBodyContentType; + SIP_CONTENT_DISPOSITION sipBodyContentDisposition; + BYTE msgBody[SIP_MAX_BODY_LEN]; +}SIP_MESSAGE_BODY; + +typedef struct _SIP_MESSAGE_BODYS +{ + BYTE sipBodyNum; + SIP_MESSAGE_BODY sipBody[SIP_MAX_NUM_OF_SIP_SUB_BODY]; +}SIP_MESSAGE_BODYS; + +typedef struct _SIP_ENTITY +{ + DWORD sipEntityHdrFlag[SIP_MAX_HDR_FLAG_NUM]; + BYTE sipHdrContentEncoding; + SIP_CONTENT_DISPOSITION sipHdrContentDisposition; + WORD sipHdrContentLength; + SIP_CONTENT_TYPE sipHdrContentType; + BYTE sipHdrContentLanguage; +// BYTE sipBody[SIP_MAX_BODY_LEN]; + SIP_MESSAGE_BODYS sipBodys; +}SIP_ENTITY; + +typedef struct _SIP_REQUEST_HDR +{ + SIP_HDR_AUTHORIZATION sipHdrAuthorization; + SIP_HDR_HIDE sipHdrHide; + SIP_HDR_MAX_FORWARDS sipHdrMaxForwards; + SIP_HDR_PRIORITY sipHdrPriority; + SIP_HDR_PROXY_AUTHORIZATION sipHdrProxyAuthorization; + SIP_HDR_PROXY_REQUIRE sipHdrProxyRequire; + SIP_HDR_ROUTES sipHdrRoutes; + SIP_HDR_REQUIRE sipHdrRequire; + SIP_HDR_RESPONSE_KEY sipHdrResKey; + SIP_HDR_SUBJECT sipHdrSubject; + SIP_HDR_REFER_TO sipHdrReferTo; + SIP_HDR_SUBSCRIPTION_STATE sipHdrSubscriptionState; + SIP_HDR_EVENT sipHdrEvent; +}SIP_REQUEST_HDR; + +typedef struct _SIP_RESPONSE_HDR +{ + SIP_HDR_PROXY_AUTHENTICATE sipHdrProxyAuthenticate; + SIP_HDR_RETRY_AFTER sipHdrRetryAfter; + SIP_HDR_SERVER sipHdrServer; + SIP_HDR_UNSUPPORTED sipHdrUnsupported; + SIP_HDR_WARNING sipHdrWarning; + SIP_HDR_WWW_AUTHENTICATE sipHdrWWWAuthenticate; +}SIP_RESPONSE_HDR; + +typedef struct _SIP_MSG +{ + SIP_START_LINE sipStartLine; + + // General Headers + DWORD sipGenHdrFlag[SIP_MAX_HDR_FLAG_NUM]; + SIP_HDR_ACCEPT sipHdrAccept; + SIP_HDR_ALLOW sipHdrAllow; + SIP_HDR_ACCEPT_ENCODING sipHdrAcceptEncoding; + SIP_HDR_ACCEPT_LANGUAGE sipHdrAcceptLanguage; + SIP_HDR_CALL_ID sipHdrCallId; + SIP_HDR_CONTACTS sipHdrContacts; + SIP_HDR_CSEQ sipHdrCseq; + SIP_HDR_DATE sipHdrDate; + SIP_HDR_MIME_VERSION sipHdrMimeVer; + SIP_HDR_ENCRYPTION sipHdrEncryption; + SIP_HDR_EXPIRES sipHdrExpires; + SIP_HDR_FROM sipHdrFrom; + SIP_HDR_ORGANIZATION sipHdrOrganization; + SIP_HDR_RECORD_ROUTES sipHdrRecordRoutes; + SIP_HDR_TIMESTAMP sipHdrStamp; + SIP_HDR_SUPPORTED sipHdrSupported; + SIP_HDR_TO sipHdrTo; + SIP_HDR_VIAS sipHdrVias; + SIP_HDR_USER_AGENT sipHdrUserAgent; + + struct + { + DWORD sipReHdrFlag[SIP_MAX_HDR_FLAG_NUM]; + union + { + SIP_REQUEST_HDR sipReqHdr; + SIP_RESPONSE_HDR sipRspHdr; + }sipReHdr; + }sipReStruct; + + SIP_ENTITY sipEntity; +}SIP_MSG; + +typedef struct _SIP_MANAGE +{ + BYTE cmd; +}SIP_MANAGE; + +typedef struct _SIP_TRANSPORT_ADDR +{ + BYTE type; + WORD port; + union + { + DWORD ipV4; + DWORD ipV6[4]; + }addr; +}SIP_TRANSPORT_ADDR; + +typedef struct _SIP_API_STRUCT +{ + BYTE sipApiType; // SIP_API_REQ_MSG/SIP_API_RES_MSG/SIP_API_MANAGE_MSG + SIP_TRANSPORT_ADDR sipTransAddr; // Transport address of the SIP message + union + { + SIP_MSG sipMsg; // Including request and response + SIP_MANAGE sipManage; + }sipApiMsg; +}SIP_API_STRUCT; + +typedef struct _SIP_CR_MSG +{ + SIP_TRANSPORT_ADDR sipTransAddr; + SIP_START_LINE sipCrStartLine; + SIP_HDR_VIA sipCrHdrVia; + SIP_HDR_CSEQ sipCrHdrCseq; + SIP_HDR_TO sipCrHdrTo; + SIP_HDR_FROM sipCrHdrFrom; + SIP_HDR_CALL_ID sipCrHdrCallId; +}SIP_CR_MSG; + +// SIP USER struct +/* The upper layer register recv_proc call-back function to receive sip messages + upPort: destination UP port the message will be sent to, if unknown, it should be set to 0xFFFF. + sipPort: source SIP port the UP message is sent from, if no sip_port is maintained, it's set to 0xFFFF + transFlag: indicates whether this message sent from SIP transport layer directly or sent from SIP transaction layer. + sipApiMsg: a pointer to the message pointer that is pointing to the message struct of the upper layer, so the received message can be accessed at that address + returns 0 if succeeds, otherwise returns -1 +*/ +typedef struct _SIP_USER +{ + BYTE proxyType; + char userName[16]; + char domain[SIP_MAX_DOMAIN_NAME_LEN]; + int (*recv_proc)(WORD sipPort, WORD upPort, BYTE transFlag, SIP_API_STRUCT *sipApiMsg); +}SIP_USER; + +/*typedef struct _SIP_SIP_UA_USER +{ + char domain[SIP_MAX_DOMAIN_NAME_LEN]; +}SIP_SIP_UA_USER;*/ + +// Should be called in the main program when system starts up, +// Returns 0 if succeeds, otherwise returns -1 +int sip_init(); + +// Should be called every 10 ms in the platform section of the main program +void sip_timer(); +void sip_t10ms(); + +/* The upper layer uses this function to send sip message to the peer + sipTransId: destination SIP port the UP message will be sent to, if unknown, it should be set to 0xFFFF + upPort: source UP port the message is sent from + transFlag: indicates whether this message will be sent within SIP transaction layer (stateful proxy or user agent), + or directly goes to the SIP transport layer (stateless proxy) + sipApiMsg: a pointer pointing to the actual struct of the message to be sent to the SIP module + if succeeds, returns sip_port, otherwise return a negative value + if succeeds, and no sip_port is maintained for this message, returns 0xFFFF +*/ +int sip_send_msg(WORD sipTransId, WORD upPort, BYTE transFlag, SIP_API_STRUCT *sipApiMsg); + +/* The upper layer register its domain name and message receive callback function to the SIP module + if succeeds, returns 0, otherwise returns -1 +*/ +int sip_register_user(SIP_USER *sipUser); + +/* The upper layer use this function to create trascation + client: clent/server + method: invite/non-invite +*/ +int sip_create_transaction(BYTE client, BYTE method, BYTE userIndex, WORD upPort, SIP_API_STRUCT *msg); + +int sip_create_trans_branch(WORD transId, SIP_GEN_PARA *branch); + +#endif diff --git a/omc/plat/sip/src/include/sip_const.h b/omc/plat/sip/src/include/sip_const.h new file mode 100644 index 0000000..e9323fa --- /dev/null +++ b/omc/plat/sip/src/include/sip_const.h @@ -0,0 +1,154 @@ +#ifndef _SIP_CONST__H +#define _SIP_CONST__H + +#define SIP_TCP_BACKLOG 64 + +#define SIP_MAX_NUM_OF_TCP_SOCK 512 + +#define SIP_MAX_NUM_OF_USERS 4 + +#define SIP_MAX_NUM_OF_SIP_UA_USER 4 + +#define SIP_MAX_NUM_OF_TRANS_1 4095//8191 + +#define SIP_MAX_TCP_MSG_LEN 1500 + +#define SIP_MAX_UDP_MSG_LEN 1500 +#define SIP_MAX_UDP_MSG_GET_TIMES 64 + +#define SIP_MAX_ESCAPE_BUF_LEN 64 + +#define SIP_STR_TO_API 1 +#define SIP_API_TO_STR 2 + +#define SIP_MESSAGE_BODY_FLAG 1 +#define SIP_SUB_BODY_FLAG 2 + +#define SIP_COMMAND_IDLE 0 + +#define SIP_VERSION_2_0 20 + +#define SIP_MIME_VERSION_1_0 10 + +#define SIP_HASH_TABLE_SIZE 200 // 150 is the first size where no conflicts occur +#define SIP_MAX_NUM_OF_HEADERS 48 + +#define SIP_HNAME_ACCEPT "accept" +#define SIP_HNAME_ACCEPT_ENCODING "accept-encoding" +#define SIP_HNAME_ACCEPT_LANGUAGE "accept-language" +#define SIP_HNAME_ALERT_INFO "alert-info" +#define SIP_HNAME_ALLOW "allow" +#define SIP_HNAME_AUTHENTICATION_INFO "authentication-info" +#define SIP_HNAME_AUTHORIZATION "authorization" +#define SIP_HNAME_CALL_ID "call-id" +#define SIP_HNAME_CALL_ID_SHORT "i" +#define SIP_HNAME_CALL_INFO "call-info" +#define SIP_HNAME_CONTACT "contact" +#define SIP_HNAME_CONTACT_SHORT "m" +#define SIP_HNAME_CONTENT_DISPOSITION "content-disposition" +#define SIP_HNAME_CONTENT_ENCODING_SHORT "e" +#define SIP_HNAME_CONTENT_ENCODING "content-encoding" +#define SIP_HNAME_CONTENT_LANGUAGE "content-language" +#define SIP_HNAME_CONTENT_LENGTH_SHORT "l" +#define SIP_HNAME_CONTENT_LENGTH "content-length" +#define SIP_HNAME_CONTENT_TYPE_SHORT "c" +#define SIP_HNAME_CONTENT_TYPE "content-type" +#define SIP_HNAME_CSEQ "cseq" +#define SIP_HNAME_SIPDATE "date" +#define SIP_HNAME_ERROR_INFO "error-info" +#define SIP_HNAME_EVENT "event" +#define SIP_HNAME_EXPIRES "expires" +#define SIP_HNAME_FROM "from" +#define SIP_HNAME_FROM_SHORT "f" +#define SIP_HNAME_IN_REPLY_TO "in-reply-to" +#define SIP_HNAME_MAX_FORWARDS "max-forwards" +#define SIP_HNAME_MIME_VERSION "mime-version" +#define SIP_HNAME_MIN_EXPIRES "min-expires" +#define SIP_HNAME_ORGANIZATION "organization" +#define SIP_HNAME_PRIORITY "priority" +#define SIP_HNAME_PROXY_AUTHENTICATE "proxy-authenticate" +#define SIP_HNAME_PROXY_AUTHENTICATION_INFO "proxy-authentication-info" +#define SIP_HNAME_PROXY_AUTHORIZATION "proxy-authorization" +#define SIP_HNAME_PROXY_REQUIRE "proxy-require" +#define SIP_HNAME_RECORD_ROUTE "record-route" +#define SIP_HNAME_REFER_TO "refer-to" +#define SIP_HNAME_REFER_TO_SHORT "r" +#define SIP_HNAME_REPLY_TO "reply-to" +#define SIP_HNAME_REQUIRE "require" +#define SIP_HNAME_RETRY_AFTER "retry-after" +#define SIP_HNAME_ROUTE "route" +#define SIP_HNAME_SERVER "server" +#define SIP_HNAME_SUBJECT "subject" +#define SIP_HNAME_SUBJECT_SHORT "s" +#define SIP_HNAME_SUPPORTED "supported" +#define SIP_HNAME_SUPPORTED_SHORT "k" +#define SIP_HNAME_SUBSCRIPTION_STATE "subscription-state" +#define SIP_HNAME_TIMESTAMP "timestamp" +#define SIP_HNAME_TO "to" +#define SIP_HNAME_TO_SHORT "t" +#define SIP_HNAME_UNSUPPORTED "unsupported" +#define SIP_HNAME_USER_AGENT "user-agent" +#define SIP_HNAME_VIA "via" +#define SIP_HNAME_VIA_SHORT "v" +#define SIP_HNAME_WARNING "warning" +#define SIP_HNAME_WWW_AUTHENTICATE "www-authenticate" +#define SIP_HNAME_MAX_FORWARDS "max-forwards" + +#define SIP_TRANS_MAIN_STATE_INIT 0 +#define SIP_TRANS_MAIN_STATE_SVR_NON_INV 1 +#define SIP_TRANS_MAIN_STATE_SVR_INV 2 +#define SIP_TRANS_MAIN_STATE_CLT_NON_INV 3 +#define SIP_TRANS_MAIN_STATE_CLT_INV 4 + +#define SIP_TRANS_STATE_IDLE 0 +#define SIP_TRANS_STATE_TRYING 1 +#define SIP_TRANS_STATE_CALLING 2 +#define SIP_TRANS_STATE_PROCEEDING 3 +#define SIP_TRANS_STATE_COMPLETED 4 +#define SIP_TRANS_STATE_CONFIRMED 5 +#define SIP_TRANS_STATE_TERMINATED 6 + +#define SIP_PNAME_TAG "tag" +#define SIP_PNAME_BRANCH "branch" +#define SIP_PNAME_EXPIRES "expires" +#define SIP_PNAME_USER "user" +#define SIP_PNAME_LR "lr" +#define SIP_PNAME_BOUNDARY "boundary" +#define SIP_PNAME_HANDLING "handling" +#define SIP_PNAME_TRANSPORT "transport" +#define SIP_PNAME_RPORT "rport" +#define SIP_PNAME_VERSION "version" +#define SIP_PNAME_BASE "base" + +#define SIP_TIMER_T1 25 // default: 500 ms +#define SIP_TIMER_T2 400 // default: 4 s +#define SIP_TIMER_T4 500 // default: 5 s +#define SIP_TIMER_A SIP_TIMER_T1 +#define SIP_TIMER_B (128 * SIP_TIMER_T1)//(64 * SIP_TIMER_T1) +#define SIP_TIMER_D (32 *SIP_TIMER_T1)//(64 * SIP_TIMER_T1)// +#define SIP_TIMER_E_INITIAL SIP_TIMER_T1 +#define SIP_TIMER_F (32 * SIP_TIMER_T1)//(64 * SIP_TIMER_T1)// +#define SIP_TIMER_G SIP_TIMER_T1 +#define SIP_TIMER_H (32 * SIP_TIMER_T1)//(64 * SIP_TIMER_T1)// +#define SIP_TIMER_I 2//SIP_TIMER_T4 +#define SIP_TIMER_J (32 * SIP_TIMER_T1)//(64 * SIP_TIMER_T1)// +#define SIP_TIMER_K 2//SIP_TIMER_T4 +#define SIP_TIMER_200MS 20 + +#define SIP_ENCODE_URL_ALL 0x00 +#define SIP_ENCODE_URL_NO_BRACKETS 0x01 +#define SIP_ENCODE_URL_NO_USER_PART 0x02 + +#define SIP_BRANCH_BASE_TRANS_ID 10000 +#define SIP_BRANCH_BASE_TRANS_ID_LEN 5 + +#define SIP_MAX_ASCIIIN_LEN 4096 +#define SIP_MAX_ASCIIOUT_LEN 4096 +#define SIP_MAX_ASCITMP_LEN 4096 + +#define SIP_MONITOR_NONE 0x0000 +#define MONITOR_SIP_MSG 0x0001 +#define SIP_MONITOR_ERROR 0x0002 +#define SIP_MONITOR_ALL 0xffff + +#endif diff --git a/omc/plat/sip/src/include/sip_debug.h b/omc/plat/sip/src/include/sip_debug.h new file mode 100644 index 0000000..07179ee --- /dev/null +++ b/omc/plat/sip/src/include/sip_debug.h @@ -0,0 +1,10 @@ +#ifndef _SIP_DEBUG__H +#define _SIP_DEBUG__H + +void sip_mon(void); +int sip_debug_set(void); +int sip_asciout_proc(BYTE *outStr); +int sip_hex_to_ascii(BYTE *fromHex, BYTE fromLen, BYTE *toAsc); +int sip_log_err(BYTE *errMsg); + +#endif diff --git a/omc/plat/sip/src/include/sip_def.h b/omc/plat/sip/src/include/sip_def.h new file mode 100644 index 0000000..918911a --- /dev/null +++ b/omc/plat/sip/src/include/sip_def.h @@ -0,0 +1,49 @@ +#ifndef _SIP_DEF__H +#define _SIP_DEF__H + +#include "sip_pub.h" +#include "sip.h" +#include "sip_const.h" +#include "sip_struct.h" + +int sipUdpSocketFd; +int sipTcpServerSocketFd; + +char sipHostName[50]; +char sipDottedHostIp[20]; +DWORD sipHostIp; + +BYTE sipUdpMsgSdBuf[SIP_MAX_UDP_MSG_LEN]; +BYTE sipUdpMsgRvBuf[SIP_MAX_UDP_MSG_LEN]; +BYTE sipTcpMsgRvBuf[SIP_MAX_TCP_MSG_LEN]; + +BYTE sipEncBuf[SIP_MAX_UDP_MSG_LEN]; +char sipEscapeBuf[SIP_MAX_ESCAPE_BUF_LEN]; + +SIP_TCP_SOCK sipTcpSock[SIP_MAX_NUM_OF_TCP_SOCK]; + +SIP_API_STRUCT sipRecvMsg; +SIP_API_STRUCT sipSendMsg; + +SIP_API_STRUCT sipToUpMsg; + +struct sockaddr_in sipSrcInAddr; +struct sockaddr_in sipDstInAddr; + +int sipHdrRefTable[SIP_HASH_TABLE_SIZE]; // the hash table contains indices to the sipParseConfig table +SIP_HDR_CONFIG sipParseConfig[SIP_MAX_NUM_OF_HEADERS]; + +SIP_USERS_STRUCT sipUsers; +SIP_TRANSACTION sipTrans[SIP_MAX_NUM_OF_TRANS]; + +//SIP_SIP_UA_USER sipSipUaUser[SIP_MAX_NUM_OF_SIP_UA_USER]; + +WORD sipTransHead; +WORD sipDlgSelect; + +BYTE sipAsciInBuf[SIP_MAX_ASCIIIN_LEN]; +BYTE sipAsciOutBuf[SIP_MAX_ASCIIOUT_LEN]; +BYTE sipAsciTempBuf[SIP_MAX_ASCITMP_LEN]; +WORD sipMonitorFg; + +#endif diff --git a/omc/plat/sip/src/include/sip_ext.h b/omc/plat/sip/src/include/sip_ext.h new file mode 100644 index 0000000..4c8c568 --- /dev/null +++ b/omc/plat/sip/src/include/sip_ext.h @@ -0,0 +1,48 @@ +#ifndef _SIP_EXT__H +#define _SIP_EXT__H + +#include "sip_pub.h" +#include "sip.h" +#include "sip_const.h" +#include "sip_struct.h" + +extern int sipUdpSocketFd; +extern int sipTcpServerSocketFd; + +extern char sipHostName[50]; +extern char sipDottedHostIp[20]; +extern DWORD sipHostIp; + +extern BYTE sipUdpMsgSdBuf[SIP_MAX_UDP_MSG_LEN]; +extern BYTE sipUdpMsgRvBuf[SIP_MAX_UDP_MSG_LEN]; +extern BYTE sipTcpMsgRvBuf[SIP_MAX_TCP_MSG_LEN]; + +extern BYTE sipEncBuf[SIP_MAX_UDP_MSG_LEN]; +extern char sipEscapeBuf[SIP_MAX_ESCAPE_BUF_LEN]; + +extern SIP_TCP_SOCK sipTcpSock[SIP_MAX_NUM_OF_TCP_SOCK]; + +extern SIP_API_STRUCT sipRecvMsg; +extern SIP_API_STRUCT sipSendMsg; + +extern SIP_API_STRUCT sipToUpMsg; + +extern struct sockaddr_in sipSrcInAddr; +extern struct sockaddr_in sipDstInAddr; + +extern int sipHdrRefTable[SIP_HASH_TABLE_SIZE]; +extern SIP_HDR_CONFIG sipParseConfig[SIP_MAX_NUM_OF_HEADERS]; + +extern SIP_USERS_STRUCT sipUsers; +extern SIP_TRANSACTION sipTrans[SIP_MAX_NUM_OF_TRANS]; + +//extern SIP_SIP_UA_USER sipSipUaUser[SIP_MAX_NUM_OF_SIP_UA_USER]; + +extern WORD sipTransHead; + +extern BYTE sipAsciInBuf[SIP_MAX_ASCIIIN_LEN]; +extern BYTE sipAsciOutBuf[SIP_MAX_ASCIIOUT_LEN]; +extern BYTE sipAsciTempBuf[SIP_MAX_ASCITMP_LEN]; +extern WORD sipMonitorFg; + +#endif diff --git a/omc/plat/sip/src/include/sip_msg.h b/omc/plat/sip/src/include/sip_msg.h new file mode 100644 index 0000000..4783eda --- /dev/null +++ b/omc/plat/sip/src/include/sip_msg.h @@ -0,0 +1,36 @@ +#ifndef _SIP_MSG__H +#define _SIP_MSG__H + +#define sip_generic_param_add(LIST,NAME,VALUE) sip_uri_param_add(LIST,NAME,VALUE) +#define sip_uri_uparam_add(url,name,value) sip_uri_param_add((&(url)->params),name,value) + +int sip_recv_msg_handling(char *msg, WORD len, int tcpSockIndex); +int sip_method_api_conv(char *str, BYTE *method, BYTE flag); +int sip_uri_type_api_conv(char *str, BYTE *uriType, BYTE flag); +int sip_ver_api_conv(char *str, BYTE *ver, BYTE flag); +int sip_proto_api_conv(char *str, BYTE *proto, BYTE flag); +int sip_content_type_api_conv(char *str, BYTE *contentType, BYTE flag); +int sip_content_sub_type_api_conv(char *str, BYTE *contentSubType, BYTE flag); +int sip_accept_type_api_conv(char *str, BYTE *acceptType, BYTE flag); +int sip_accept_sub_type_api_conv(char *str, BYTE *acceptSubType, BYTE flag); +int sip_accept_encoding_api_conv(char *str, BYTE *acceptEncoding, BYTE flag); +int sip_accept_language_api_conv(char *str, BYTE *acceptLanguage, BYTE flag) ; +int sip_allow_api_conv(char *str, BYTE *allowMethod, BYTE flag); +int sip_option_tag_api_conv(char *str, BYTE *option, BYTE flag); +int sip_mime_version_api_conv(char *str, BYTE *mimeVersion, BYTE flag); +int sip_date_weekday_api_conv(char *str, BYTE *weekday, BYTE flag); +int sip_date_month_api_conv(char *str, BYTE *month, BYTE flag); +int sip_date_type_api_conv(char *str, BYTE *dateType, BYTE flag); +int sip_content_disposition_api_conv(char *str, BYTE *contentDisposition, BYTE flag); +int sip_content_encoding_api_conv(char *str, BYTE *contentEncoding, BYTE flag); +int sip_content_language_api_conv(char *str, BYTE *contentLanguage, BYTE flag); +void sip_fill_msg_with_cr(SIP_MSG *sipMsg, SIP_CR_MSG *sipCrMsg); +void sip_fill_cr_msg(SIP_CR_MSG *sipCrMsg, SIP_API_STRUCT *sipApiMsg); +int sip_send_ack(SIP_API_STRUCT *ackMsg, SIP_TRANSACTION *trans); +int sip_send_100(SIP_CR_MSG *ackMsg, SIP_TRANSACTION *trans); +int sip_send_option_rsp(SIP_API_STRUCT *sipApiMsg); +BYTE sip_search_user_by_domain(SIP_URI *sipUri); +int sip_send_call_not_exit_rsp(SIP_API_STRUCT *sipApiMsg); +int sip_send_not_find_rsp(SIP_API_STRUCT *sipApiMsg); + +#endif diff --git a/omc/plat/sip/src/include/sip_msg_encode.h b/omc/plat/sip/src/include/sip_msg_encode.h new file mode 100644 index 0000000..30064e1 --- /dev/null +++ b/omc/plat/sip/src/include/sip_msg_encode.h @@ -0,0 +1,24 @@ +#ifndef _SIP_MSG_ENCODE__H +#define _SIP_MSG_ENCODE__H + +#define _ALPHANUM_ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\0" +#define _RESERVED_ ";/?:@&=+$\0" +#define _MARK_ "-_.!~*'()\0" + +#define _MARK__USER_UNRESERVED_ "-_.!~*'()&=+$,;?/\0" +#define _MARK__PWORD_UNRESERVED_ "-_.!~*'()&=+$,\0" +#define _MARK__URI_PARAM_UNRESERVED_ "-_.!~*'()[]/:&+$\0" +#define _MARK__HEADER_PARAM_UNRESERVED_ "-_.!~*'()[]/?:+$\0" + +#define sip_is_alphanum(in) ( \ + (in >= 'a' && in <= 'z') || \ + (in >= 'A' && in <= 'Z') || \ + (in >= '0' && in <= '9')) + +int sip_transport_encode_start_line(char *dest, SIP_API_STRUCT *sipApiMsg); +int sip_transport_encode_headers(char *dest, SIP_API_STRUCT *sipApiMsg); +int sip_transport_encode_body(char *dest, SIP_API_STRUCT *sipApiMsg); +int sip_transport_set_addr(struct sockaddr_in *dstAddr, SIP_API_STRUCT *sipApiMsg); +int sip_transport_set_sd_addr(struct sockaddr_in *dstAddr, SIP_TRANSPORT_ADDR *sipTransAddr); + +#endif diff --git a/omc/plat/sip/src/include/sip_msg_parse.h b/omc/plat/sip/src/include/sip_msg_parse.h new file mode 100644 index 0000000..cb94947 --- /dev/null +++ b/omc/plat/sip/src/include/sip_msg_parse.h @@ -0,0 +1,12 @@ +#ifndef _SIP_MSG_PARSE__H +#define _SIP_MSG_PARSE__H + +void sip_util_replace_all_lws(char *msg); +int sip_set_next_token(char **dest, char *buf, int endSeparator, char **next); +int sip_msg_start_line_parse(SIP_API_STRUCT *dest, char *buf, char **nextHeader); +int sip_uri_parse(SIP_URI *sipUri, char *buf); +int sip_msg_headers_parse(SIP_API_STRUCT *sip, char *buf, char **body); +int sip_body_parse(SIP_API_STRUCT *sip, char *buf, WORD len); +int sip_parser_init(void); + +#endif diff --git a/omc/plat/sip/src/include/sip_pub.h b/omc/plat/sip/src/include/sip_pub.h new file mode 100644 index 0000000..c851197 --- /dev/null +++ b/omc/plat/sip/src/include/sip_pub.h @@ -0,0 +1,55 @@ +#ifndef _SIP_PUB__H +#define _SIP_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//by simon at 23/9/22 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/omc/plat/sip/src/include/sip_struct.h b/omc/plat/sip/src/include/sip_struct.h new file mode 100644 index 0000000..e56aaad --- /dev/null +++ b/omc/plat/sip/src/include/sip_struct.h @@ -0,0 +1,62 @@ +#ifndef _SIP_STRUCT__H +#define _SIP_STRUCT__H + +#include "sip_pub.h" +#include "sip.h" +#include "sip_const.h" + +// Internal type for parser's config +typedef struct _SIP_HDR_CONFIG +{ + char *hname; + int (*setheader)(SIP_API_STRUCT *, char *); +}SIP_HDR_CONFIG; + +typedef struct _SIP_USER_STRUCT +{ + BYTE flag; + SIP_USER sipUser; +}SIP_USER_STRUCT; + +typedef struct _SIP_USERS_STRUCT +{ + BYTE proxyIndex; + SIP_USER_STRUCT sipUsers[SIP_MAX_NUM_OF_USERS]; +}SIP_USERS_STRUCT; + +typedef struct _SIP_TRANS_SD_MSG +{ + SIP_TRANSPORT_ADDR sipSdAddr; + BYTE sdMsg[SIP_MAX_UDP_MSG_LEN]; +}SIP_TRANS_SD_MSG; + +typedef struct _SIP_TRANSACTION +{ + BYTE flag; + BYTE userIndex; + BYTE tcpSockIndex; + BYTE client; + BYTE method; + BYTE mainState; + BYTE state; + WORD upPort; + WORD rvCmd; + WORD sdCmd; + DWORD timer; + DWORD timer2; + BYTE retransTimes; + + SIP_CR_MSG crMsg; +// SIP_API_STRUCT sdMsg; + + SIP_TRANS_SD_MSG transSdMsg; +}SIP_TRANSACTION; + +typedef struct _SIP_TCP_SOCK +{ + BYTE flag; + int sendRecvSock; + struct sockaddr_in remoteAddr; +}SIP_TCP_SOCK; + +#endif diff --git a/omc/plat/sip/src/include/sip_transaction.h b/omc/plat/sip/src/include/sip_transaction.h new file mode 100644 index 0000000..822c2d6 --- /dev/null +++ b/omc/plat/sip/src/include/sip_transaction.h @@ -0,0 +1,11 @@ +#ifndef _SIP_TRANSACTION__H +#define _SIP_TRANSACTION_H + +void sip_transaction_proc(WORD transid); +void sip_trans_init(WORD trans_id); +WORD sip_request_match_server_trans(SIP_API_STRUCT *recvMsg); +WORD sip_response_match_client_trans(SIP_API_STRUCT *recvMsg); +int sip_set_trans_send_cmd(SIP_TRANSACTION *trans, SIP_API_STRUCT *sipApiMsg); +int sip_msg_transport_to_transaction(SIP_API_STRUCT *recvMsg, WORD transId); + +#endif diff --git a/omc/plat/sip/src/include/sip_transport.h b/omc/plat/sip/src/include/sip_transport.h new file mode 100644 index 0000000..9309cab --- /dev/null +++ b/omc/plat/sip/src/include/sip_transport.h @@ -0,0 +1,9 @@ +#ifndef _SIP_TRANSPORT__H +#define _SIP_TRANSPORT_H + +void sip_transport_proc(); +int sip_transport_encode_trans_msg(SIP_TRANSACTION *trans, SIP_API_STRUCT *sipApiMsg); +int sip_transport_send_msg(SIP_API_STRUCT *sipApiMsg); +int sip_transport_send_trans_msg(SIP_TRANS_SD_MSG *transSdMsg); + +#endif diff --git a/omc/plat/sip/src/include/sip_ua.h b/omc/plat/sip/src/include/sip_ua.h new file mode 100644 index 0000000..f235694 --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua.h @@ -0,0 +1,39 @@ +#ifndef _SIP_UA_H +#define _SIP_UA_H + +#include "sip_ua_pub.h" +#include "sip.h" +#include "../../../pal/pal.h" + +#define sip_response_match_ua_dialog(sipMsg) sip_ua_match_dialog_with_rsp(sipMsg) + +typedef struct _SIP_UA_SAP +{ + BYTE proxyType; + char userName[16]; + char domain[SIP_MAX_DOMAIN_NAME_LEN]; + int (*recv_req)(WORD sipUaPort, WORD usrPort, WORD dialogId, BYTE method, SIP_API_STRUCT *sipApiMsg, pal_cg_struct *cg); + int (*recv_resp)(WORD usrPort, WORD dialogId, WORD statusCode, SIP_API_STRUCT *sipApiMsg); +}SIP_UA_SAP; + +typedef struct _SIP_EVENTHANDLE_STRUCT +{ + int (*recv_req)(WORD sipUaPort, WORD usrPort, WORD dialogId, BYTE method, SIP_API_STRUCT *sipApiMsg, pal_cg_struct *cg); + int (*recv_resp)(WORD usrPort, WORD dialogId, WORD statusCode, SIP_API_STRUCT *sipApiMsg); +}SIP_EVENTHANDLE_STRUCT; + +int sip_ua_init(); +//int sip_ua_bind(SIP_UA_SAP *sap); +int sip_ua_init_port(WORD port); +int sip_ua_init_dialog(WORD dialogId); + +int sip_ua_get_port(); + + +WORD sip_ua_match_dialog_with_req(SIP_API_STRUCT *request); +WORD sip_ua_match_dialog_with_rsp(SIP_API_STRUCT *response); + +int sip_query_sip_ua_users(SIP_URI *sipUri); + +#endif + diff --git a/omc/plat/sip/src/include/sip_ua_const.h b/omc/plat/sip/src/include/sip_ua_const.h new file mode 100644 index 0000000..aaeece8 --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_const.h @@ -0,0 +1,57 @@ +#ifndef _SIP_UA_CONST_H +#define _SIP_UA_CONST_H + +#define SIP_UA_MAX_NUM_OF_PORT 4096//8192 + +#define SIP_UA_MAX_NUM_OF_DIALOG 4096//8192 + +#define SIP_UA_MAX_NUM_OF_SAP 4 + +#define SIP_UA_NULL_DIALOG 0xFFFF + +#define SIP_UA_NULL_PORT 0xFFFF + +#define SIP_UA_NULL_UP_PORT 0xFFFF + +#define SIP_UA_SEND_COM_NULL 0 + +#define SIP_UA_RECV_COM_NULL 0 + +#define SIP_UA_FSM_STATE_INDICATE 1 +#define SIP_UA_FSM_STATE_REQUEST 2 + +#define SIP_UA_MAIN_STATE_IDLE 0 +#define SIP_UA_MAIN_STATE_INVITE_REQ 1 +#define SIP_UA_MAIN_STATE_NON_INVITE_REQ 2 +#define SIP_UA_MAIN_STATE_INVITE_RSP 3 +#define SIP_UA_MAIN_STATE_NON_INVITE_RSP 4 +#define SIP_UA_MAIN_STATE_INIT 5 + +#define SIP_UA_SEND_REQUEST 1 +#define SIP_UA_REQ_WAIT_FOR_RSP 2 +#define SIP_UA_INV_REQ_TERMINATED 3 +#define SIP_UA_SEND_RESPONSE 4 +#define SIP_UA_INV_200_RSP_WAIT_FOR_ACK 5 +#define SIP_UA_INV_RSP_TERMINATED 6 + +#define WAIT_200_ACK_TIME_OUT 97 +#define WAIT_RSP_TIME_OUT 98 + +#define SIP_UA_TIMER_RETRANSMIT_200 50 +#define SIP_UA_TIMER_WAIT_INV_RSP 3300 +#define SIP_UA_TIMER_WAIT_INV_200_RSP 5000 +#define SIP_UA_TIMER_WAIT_NON_INV_RSP 1000 +#define SIP_UA_TIMER_WAIT_ACK 1000 +#define SIP_UA_TIMER_T1 300//3200 +#define SIP_UA_TIMER_TIME_OUT 18000 + +#define SIP_UA_TIMER_T2 5 +#define SIP_UA_TIMER_T3 20 + +#define SIP_UA_FSM_TIMER 3300//SIP_UA_TIMER_T1; + +#define SIP_UA_MAX_TAG_LEN 64//128 +#define SIP_UA_MAX_BRANCH_LEN 64 + +#endif + diff --git a/omc/plat/sip/src/include/sip_ua_def.h b/omc/plat/sip/src/include/sip_ua_def.h new file mode 100644 index 0000000..a3a3a9d --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_def.h @@ -0,0 +1,28 @@ +#ifndef _SIP_UA_DEF_H +#define _SIP_UA_DEF_H + +#include "sip_ua_pub.h" +#include "sip.h" +#include "sip_ua_struct.h" +#include "sip_ua_const.h" +#include "sip_ua_dialog.h" + +char sipUaHostName[50]; +char sipUaDottedHostIp[20]; +DWORD sipUaHostIp; + +int sipUaSipIndex; +SIP_USER sipUaSipUser; + +SIP_UA_SAPS sipUaSaps[SIP_UA_MAX_NUM_OF_SAP]; + +SIP_DIALOG sipUaDialog[SIP_UA_MAX_NUM_OF_DIALOG]; + +SIP_UA_PORT sipUaPort[SIP_UA_MAX_NUM_OF_PORT]; + +SIP_API_STRUCT sipUaRecvMsg; + +WORD sipUaPortSelect; +WORD sipUaDialogSelect; + +#endif diff --git a/omc/plat/sip/src/include/sip_ua_dialog.h b/omc/plat/sip/src/include/sip_ua_dialog.h new file mode 100644 index 0000000..47e6dbf --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_dialog.h @@ -0,0 +1,72 @@ +#ifndef _SIP_UA_DIALOG_H +#define _SIP_UA_DIALOG_H + +#include "sip_ua_pub.h" +#include "sip.h" +#include "sip_ua_const.h" + +#define SIP_CALLEE 1 +#define SIP_CALLER 2 + +#define SIP_UA_DIALOG_IDLE 0 +#define SIP_UA_DIALOG_EARLY 1 +#define SIP_UA_DIALOG_WAIT_ACK_FOR_200 2 +#define SIP_UA_DIALOG_CONFIRMED 3 +#define SIP_UA_DIALOG_DESTROY 4 + +#define SIP_UA_DIALOG_REMOTE_TARGET_FLAG 0x0001 +#define SIP_UA_DIALOG_RECORD_ROUTE_SEND_FLAG 0x0002 + +typedef struct _SIP_UA_URI +{ + BYTE uriType; + char userName[SIP_MAX_USER_NAME_LEN]; + char password[SIP_MAX_PASSWORD_LEN]; + + char domain[SIP_MAX_DOMAIN_NAME_LEN]; + +}SIP_UA_URI; + +typedef struct _SIP_DIALOG +{ + BYTE flag; + BYTE cgId;//BYTE userIndex; + WORD usrPort; + BYTE type; + BYTE state; + + union + { + WORD rvInvUaPort; + WORD sdInvUaPort; + }invUaPort; + + WORD sipUaPort; + + WORD uaPort;//only used to store the ua port of sending invite rsp + WORD uaAckPort;//only used to store the ua port of sending ACK for invite 200 + DWORD invCSeq; + DWORD remoteInvCseq; + + char invBranch[SIP_UA_MAX_BRANCH_LEN]; + + WORD paramFlag; + SIP_HDR_CALL_ID callId; + char localTag[SIP_UA_MAX_TAG_LEN]; + char remoteTag[SIP_UA_MAX_TAG_LEN]; + SIP_HDR_CSEQ localCseq; + SIP_HDR_CSEQ remoteCseq; + SIP_UA_URI localURI; + SIP_UA_URI remoteURI; + SIP_UA_URI remoteTarget; + SIP_HDR_RECORD_ROUTES routeSets; + int secure; +}SIP_DIALOG; + +int sip_ua_update_dialog_with_req(WORD dialogId, SIP_API_STRUCT *sipApiMsg); + +int sip_ua_init_dialog_as_client_with_inv(BYTE cgId, WORD usrPort, SIP_MSG *sipMsg);//BYTE sapIndex +int sip_ua_init_dialog_as_server_with_inv(BYTE cgId, WORD hdlPort, WORD usrPort, SIP_MSG *sipMsg);//BYTE cgId + +int sip_ua_free_dialog(DWORD usrPort, WORD dialogId); +#endif diff --git a/omc/plat/sip/src/include/sip_ua_ext.h b/omc/plat/sip/src/include/sip_ua_ext.h new file mode 100644 index 0000000..b6a3d3a --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_ext.h @@ -0,0 +1,29 @@ +#ifndef _SIP_UA_EXT_H +#define _SIP_UA_EXT_H + +#include "sip_ua_pub.h" +#include "sip.h" +#include "sip_ua_struct.h" +#include "sip_ua_const.h" +#include "sip_ua_dialog.h" + +extern char sipUaHostName[50]; +extern char sipUaDottedHostIp[20]; +extern DWORD sipUaHostIp; + +extern int sipUaSipIndex; +extern SIP_USER sipUaSipUser; + +extern SIP_UA_SAPS sipUaSaps[SIP_UA_MAX_NUM_OF_SAP]; + +extern SIP_DIALOG sipUaDialog[SIP_UA_MAX_NUM_OF_DIALOG]; + +extern SIP_UA_PORT sipUaPort[SIP_UA_MAX_NUM_OF_PORT]; + +extern SIP_API_STRUCT sipUaRecvMsg; + +extern WORD sipUaPortSelect; +extern WORD sipUaDialogSelect; + +#endif + diff --git a/omc/plat/sip/src/include/sip_ua_msg.h b/omc/plat/sip/src/include/sip_ua_msg.h new file mode 100644 index 0000000..bba9389 --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_msg.h @@ -0,0 +1,31 @@ +#ifndef _SIP_UA_MSG_H +#define _SIP_UA_MSG_H + +#include "sip_ua_pub.h" + +#define sip_ua_send_update(cgId, dialogId, usrPort, method, sdMsg) sip_ua_send_non_inv(cgId, dialogId, usrPort, method, sdMsg) +#define sip_ua_send_cancel(cgId, dialogId, usrPort, method, sdMsg) sip_ua_send_non_inv(cgId, dialogId, usrPort, method, sdMsg) +#define sip_ua_send_bye(cgId, dialogId, usrPort, method, sdMsg) sip_ua_send_non_inv(cgId, dialogId, usrPort, method, sdMsg) +#define sip_ua_send_200_ack(cgId, dialogId, usrPort, method, sdMsg) sip_ua_send_non_inv(cgId, dialogId, usrPort, method, sdMsg) +#define sip_ua_send_info(cgId, dialogId, usrPort, method, sdMsg) sip_ua_send_non_inv(cgId, dialogId, usrPort, method, sdMsg) +#define sip_ua_send_bye_inv_rsp(cgId, dialogId, usrPort, sdMsg) sip_ua_send_cancel_inv_rsp(cgId, dialogId, usrPort, sdMsg) + +int sip_ua_send_invite(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_re_invite(BYTE cgId, WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_non_inv(BYTE cgId,WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); +int sip_ua_send_cancel(BYTE cgId,WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); +int sip_ua_send_bye(BYTE sapIncgIddex,WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); +int sip_ua_send_200_ack(BYTE cgId,WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); +int sip_ua_send_info(BYTE cgId,WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); + +int sip_ua_send_options(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_refer(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); + +int sip_ua_set_inv_temp_rsp(WORD uaPort,SIP_API_STRUCT *sdMsg); + +int sip_ua_send_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_cancel_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_re_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg); +int sip_ua_send_non_inv_rsp(BYTE cgId, WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg); + +#endif diff --git a/omc/plat/sip/src/include/sip_ua_pub.h b/omc/plat/sip/src/include/sip_ua_pub.h new file mode 100644 index 0000000..e861052 --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_pub.h @@ -0,0 +1,56 @@ +#ifndef _SIP_UA_PUB__H +#define _SIP_UA_PUB__H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// by simon at 23/9/22 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 + diff --git a/omc/plat/sip/src/include/sip_ua_struct.h b/omc/plat/sip/src/include/sip_ua_struct.h new file mode 100644 index 0000000..90aa2dc --- /dev/null +++ b/omc/plat/sip/src/include/sip_ua_struct.h @@ -0,0 +1,47 @@ +#ifndef _SIP_UA_STRUCT_H +#define _SIP_UA_STRUCT_H + +#include "sip_ua_pub.h" +#include "sip_ua.h" +#include "sip.h" + +typedef struct _SIP_UA_CALL_STRUCT +{ + SIP_HDR_CALL_ID callId; + char fromTag[128]; +}SIP_UA_CALL_STRUCT; + +typedef struct _SIP_UA_PORT +{ + BYTE flag; + BYTE cgId;//BYTE sapIndex; + WORD dialogId; + WORD usrPort; + WORD llPort; + + SIP_UA_CALL_STRUCT callStruct; + + BYTE sipuafState; + DWORD sipuafTimer; + + BYTE mainState; + BYTE state; + WORD rcvCmd; + WORD sdCmd; + + DWORD timer; + DWORD timer2; + DWORD waitAckTimer; + BYTE retrans200Times; + + SIP_API_STRUCT sdSipMsg; +}SIP_UA_PORT; + +typedef struct _SIP_UA_SAPS +{ + BYTE flag; + SIP_UA_SAP sipUaSap; +}SIP_UA_SAPS; + +#endif + diff --git a/omc/plat/sip/src/sip.c b/omc/plat/sip/src/sip.c new file mode 100644 index 0000000..5d0ff4b --- /dev/null +++ b/omc/plat/sip/src/sip.c @@ -0,0 +1,280 @@ +/****************************************************************/ +/* SIP Implementation Program */ +/* Version 10.0.1 */ +/* Designed By Ying Min */ +/* Last Update: 2006-10-19 */ +/****************************************************************/ + +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_def.h" +#include "./include/sip_transaction.h" +#include "./include/sip_transport.h" +#include "./include/sip_msg_parse.h" +#include "./include/sip_debug.h" + +int sip_get_local_ip(void) +{ + struct hostent *host; + + if (gethostname(sipHostName, 50) == -1) + { + printf("SIP gethostname fail!\n"); + return -1; + } + + if ((host = gethostbyname(sipHostName)) == NULL) + { + printf("SIP gethostbyname fail!\n"); + return -1; + } + else + { + sprintf(sipDottedHostIp, "%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]); + sipHostIp = inet_addr(sipDottedHostIp); // Network byte order sipHostIp, like 0xE60012AC + printf("sipHostName: %s, sipHostIp: %s (0x%lX)\n", sipHostName, sipDottedHostIp, sipHostIp); + } + + return 0; +} + +int sip_init_udp_socket(struct sockaddr_in saddr, int multicast) +{ + int sock; + long sockBuf = 40*1024; + int on = 1, timeout = 20; + + sock = socket(AF_INET, SOCK_DGRAM, 0); + + if (sock < 0) + { + fprintf(stderr, "Socket() failed\n"); + return -3; + } + + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &sockBuf, sizeof(sockBuf)) != 0) + { + fprintf(stderr, "SIP set socket buffer failed\n"); + close(sock); + return -4; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + &on,sizeof(on)) != 0) + { + fprintf(stderr, "SIP set addr reusable failed\n"); + close(sock); + return -5; + } + + if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, + &timeout, sizeof(timeout)) != 0) + { + fprintf(stderr, "SIP set keepalive failed\n"); + close(sock); + return -6; + } + + if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr, "SIP set nonblock failed\n"); + close(sock); + return -7; + } + + if (bind(sock, (struct sockaddr *) &saddr, sizeof(struct sockaddr)) < 0) + { + fprintf(stderr, "SIP binding failed, port: %d\n", htons(saddr.sin_port)); + close(sock); + return -2; + } + + sip_debug_set(); + + return sock; +} + +int sip_init_tcp_server_socket(struct sockaddr_in saddr, int multicast) +{ + int sock; + int on = 1, timeout = 20; + + sock = socket(AF_INET, SOCK_STREAM, 0); + + if (sock < 0) + { + fprintf(stderr, "TCP Socket() failed\n"); + return -3; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + &on,sizeof(on)) != 0) + { + fprintf(stderr, "SIP set tcp addr reusable failed\n"); + close(sock); + return -4; + } + + if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, + &timeout, sizeof(timeout)) != 0) + { + fprintf(stderr, "SIP set tcp keepalive failed\n"); + close(sock); + return -5; + } + + if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) + { + fprintf(stderr, "SIP set tcp nonblock failed\n"); + close(sock); + return -6; + } + + if (bind(sock, (struct sockaddr *) &saddr, sizeof(struct sockaddr)) < 0) + { + fprintf(stderr, "SIP tcp binding failed, port: %d\n", htons(saddr.sin_port)); + close(sock); + return -2; + } + + if (listen(sock, SIP_TCP_BACKLOG) < 0) + { + fprintf(stderr, "listen error\n"); + return -1; + } + + return sock; +} + +int sip_init_socket() +{ + struct sockaddr_in sinAddr; + WORD port = 5060; + + memset(&sinAddr, 0, sizeof(struct sockaddr)); + sinAddr.sin_family = AF_INET; + sinAddr.sin_port = htons(port); + sinAddr.sin_addr.s_addr = INADDR_ANY; + memset(&(sinAddr.sin_zero), 0, 8); + + sipUdpSocketFd = sip_init_udp_socket(sinAddr, 0); + if (sipUdpSocketFd < 0) + { + printf("SIP UDP Socket(%d) failed\n", port); + return -1; + } + + sipTcpServerSocketFd = sip_init_tcp_server_socket(sinAddr, 0); + if (sipTcpServerSocketFd < 0) + { + printf("SIP TCP Socket(%d) failed\n", port); + return -1; + } + + return 0; +} + +int sip_init() +{ + int i; + + printf("SIP Module Init Start!\n"); + + if (sip_get_local_ip() < 0) + exit(1); + + if (sip_init_socket() < 0) + exit(2); + +// memset((BYTE *)sipSipUaUser, 0, sizeof(SIP_SIP_UA_USER)); + memset((BYTE *)&sipRecvMsg, 0, sizeof(SIP_API_STRUCT)); + memset((BYTE *)&sipUsers, 0, sizeof(SIP_USERS_STRUCT)); + sipUsers.proxyIndex = SIP_MAX_NUM_OF_USERS; + + sipTransHead = 0; + for (i = 0; i < SIP_MAX_NUM_OF_TRANS; i++) + sip_trans_init(i); + + sip_parser_init(); + + printf("SIP Module Init Complete!\n"); + + return 0; +} + +void sip_t10ms() +{ + static DWORD cnt_10ms = 0; + + if (!(++cnt_10ms % 10)) + { // 100 ms + sip_mon(); + } +} + +void sip_timer() +{ + WORD transId; + + sip_transport_proc(); + + for (transId = 0; transId < SIP_MAX_NUM_OF_TRANS; transId++) + { + if (sipTrans[transId].flag == 0) + continue; + sip_transaction_proc(transId); + } + + sip_t10ms(); +} + +int sip_register_user(SIP_USER *sipUser) +{ + BYTE i; + + for (i = 0; i < SIP_MAX_NUM_OF_USERS; i++) + { // Search for already registered user + if ((sipUsers.sipUsers[i].flag == 1) && + (strcmp(sipUsers.sipUsers[i].sipUser.userName, sipUser->userName) == 0)) + { + memcpy(&sipUsers.sipUsers[i].sipUser, sipUser, sizeof(SIP_USER)); + if (sipUser->proxyType != SIP_PROXY_TYPE_NONE) + sipUsers.proxyIndex = i; + return i; + } + } + + for (i = 0; i < SIP_MAX_NUM_OF_USERS; i++) + { + if (sipUsers.sipUsers[i].flag == 0) + { + memcpy(&sipUsers.sipUsers[i].sipUser, sipUser, sizeof(SIP_USER)); + sipUsers.sipUsers[i].flag = 1; + if (sipUser->proxyType != SIP_PROXY_TYPE_NONE) + sipUsers.proxyIndex = i; + return i; + } + } + + sprintf(sipAsciTempBuf, "SIP register user fail\r\n"); + sip_log_err(sipAsciTempBuf); + + return -1; +} + +/*int sip_store_sip_ua_user(BYTE index, char *domain) +{ + if ((domain == NULL) || (index >= SIP_MAX_NUM_OF_SIP_UA_USER)) + return -1; + + strcpy(sipSipUaUser[index].domain, domain); + + return 0; +}*/ diff --git a/omc/plat/sip/src/sip_debug.c b/omc/plat/sip/src/sip_debug.c new file mode 100644 index 0000000..a81a863 --- /dev/null +++ b/omc/plat/sip/src/sip_debug.c @@ -0,0 +1,272 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "../../debug/src/include/debug.h" + +#define SIP_DEBUG_ID 29 +#define SIP_VER_DEBUG "R9V2_01" + +static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + +static BYTE log_help[] = { +"SIP 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\n\r\ +4.[log sip on/off] display sip msg 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,SIP_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,SIP_DEBUG_ID + 2,2 + }; + +static DWORD debug_ascin_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SIP_DEBUG_ID + 2,3 + }; + +static DWORD debug_ascout_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SIP_DEBUG_ID + 2,4 + }; + +static DWORD debug_page_title[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SIP_DEBUG_ID + 2,1,1 + }; + +static DWORD debug_page_line[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SIP_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[] = +{ + " SIP Page 01 Transaction Status\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +Subpage\n\r\ +Trans_Status\n\r" +}; + +BYTE sip_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 + disp_ptr = (BYTE *) &sipTrans[disp_page[page]]; + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +void sip_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 = sip_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 sip_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, SIP_VER_DEBUG, 10); + debug_set_response(BASE_ID_LEN, debug_ascin_id, sipAsciInBuf, 4096); + debug_set_response(BASE_ID_LEN, debug_ascout_id, sipAsciOutBuf, 4096); + + for (page = 1; page < 2; page++) + { + switch (page) + { + case 1: //page 1 + ptr = title1_p; + break; + default: + break; + } + + debug_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr)); + sip_disp_page(page); + } + + return 1; +} + +int sip_asciout_proc(BYTE *outStr) +{ + int outLen; + + outLen = strlen(outStr); + + if (outLen + strlen(sipAsciOutBuf) > SIP_MAX_ASCIIOUT_LEN - 2) + { + strcpy(sipAsciOutBuf, outStr); + } + else + strcat(sipAsciOutBuf, outStr); + + return 1; +} + +void sip_mon(void) +{ + BYTE inPage, errFg = 0; + BYTE *asciiInPtr = NULL; + BYTE *strStart = NULL; + WORD strLen, num; + + if ((strLen = strlen(sipAsciInBuf)) > 0) + { + inPage = sipAsciInBuf[0] - 1; + asciiInPtr = sipAsciInBuf + 1; + + if (inPage > 7) + errFg = 1; + else if (strcmp(asciiInPtr,"c") == 0) + { + } + else if (strcmp(asciiInPtr,"log error on") == 0) + { + sipMonitorFg = sipMonitorFg | SIP_MONITOR_ERROR; + } + else if (strcmp(asciiInPtr,"log error off") == 0) + { + sipMonitorFg = sipMonitorFg & (~SIP_MONITOR_ERROR); + } + else if (strcmp(asciiInPtr,"log sip on") == 0) + { + sipMonitorFg = sipMonitorFg | MONITOR_SIP_MSG; + } + else if (strcmp(asciiInPtr,"log sip off") == 0) + { + sipMonitorFg = sipMonitorFg & (~MONITOR_SIP_MSG); + } + else if (strcmp(asciiInPtr,"log all") == 0) + { + sipMonitorFg = SIP_MONITOR_ALL; + } + else if (strcmp(asciiInPtr,"log none") == 0) + { + sipMonitorFg = SIP_MONITOR_NONE; + } + else if (strcmp(asciiInPtr,"help") == 0) + { + sip_asciout_proc(log_help); + } + else if (isdigit(asciiInPtr[0])) + { + num = strtoul(asciiInPtr, NULL, 10); + disp_page[inPage] = num; + sip_disp_page(inPage); + } + else if ((strStart = strstr(asciiInPtr, ">")) != NULL) + { + num = strtoul(strStart + 1, NULL, 10); + disp_page[inPage] += num; + sip_disp_page(inPage); + } + else if ((strStart = strstr(asciiInPtr, "<"))!= NULL) + { + num = strtoul(strStart + 1, NULL, 10); + disp_page[inPage] -= num; + sip_disp_page(inPage); + } + else + errFg = 1; + + if (errFg == 0) + sip_asciout_proc("Command OK!\n\r"); + else + sip_asciout_proc("Command Error!\n\r"); + + strcpy(sipAsciInBuf, "\0"); + } +} + +int sip_hex_to_ascii(BYTE *fromHex, BYTE fromLen, BYTE *toAsc) +{ + int i, j; + + j = 0; + + for (i = 0; i< fromLen; i++) + { + toAsc[j] = ascii[fromHex[i] >> 4]; + j++; + toAsc[j] = ascii[fromHex[i] & 0x0F]; + j++; + toAsc[j] = ' '; + j++; + } + + toAsc[j] = '\0'; + + return 1; +} + +int sip_log_err(BYTE *errMsg) +{ + if ((sipMonitorFg & SIP_MONITOR_ERROR) == SIP_MONITOR_ERROR) + { + sip_asciout_proc("\33[31m"); + if (strlen(errMsg) >= SIP_MAX_ASCITMP_LEN) + sprintf(sipAsciTempBuf, "log msg is too long: %d\n\r", strlen(errMsg)); + else + sprintf(sipAsciTempBuf, "%s\n\r", errMsg); + strcat(sipAsciTempBuf, "\33[37m"); + sip_asciout_proc(sipAsciTempBuf); + } + + return 1; +} diff --git a/omc/plat/sip/src/sip_msg.c b/omc/plat/sip/src/sip_msg.c new file mode 100644 index 0000000..b5807ba --- /dev/null +++ b/omc/plat/sip/src/sip_msg.c @@ -0,0 +1,1508 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "./include/sip_msg.h" +#include "./include/sip_msg_parse.h" +#include "./include/sip_transaction.h" +#include "./include/sip_transport.h" +#include "./include/sip_debug.h" +#include "./include/sip_ua.h" +#include "./include/sip_ua_const.h" + +BYTE sip_search_user_by_domain(SIP_URI *sipUri) +{ + BYTE i; + + if (sipUri == NULL) + return SIP_MAX_NUM_OF_USERS; + + for (i = 0; i < SIP_MAX_NUM_OF_USERS; i++) + { // Search for registered user + if ((sipUsers.sipUsers[i].flag == 1) + && (strcmp(sipUsers.sipUsers[i].sipUser.domain, sipUri->host.addr.domain) == 0) + && (strcmp(sipUsers.sipUsers[i].sipUser.userName, "SIP_UA") != 0)) + return i; + } + + return SIP_MAX_NUM_OF_USERS; +} + +int sip_match_ua_user_by_domain(SIP_API_STRUCT *sipApiMsg) +{ + pal_cg_struct *cg; + char *localDomain; + char *destDomain; + +/* for (i = 0; i < SIP_MAX_NUM_OF_SIP_UA_USER; i++) + { + if (strcmp(sipSipUaUser[i].domain, domain) == 0) + return i; + }*/ + + if (sipApiMsg == NULL) + return -1; + + localDomain = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.requestUri.host.addr.domain; + destDomain = sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.head].url.domain; + + if ((cg = (pal_cg_struct *)pal_sip_find_cg(localDomain, destDomain)) == NULL) + return -1; + + return 0; +} + +BYTE sip_search_ua_user_by_domain(SIP_API_STRUCT *sipApiMsg)//SIP_URI sipUri +{ + BYTE i; + + if (sipApiMsg == NULL) + return SIP_MAX_NUM_OF_USERS; + + for (i = 0; i < SIP_MAX_NUM_OF_USERS; i++) + { + if ((sipUsers.sipUsers[i].flag == 1) + && (strcmp(sipUsers.sipUsers[i].sipUser.userName, "SIP_UA") == 0)) + { + if (sip_match_ua_user_by_domain(sipApiMsg) < 0)//sipUri->host.addr.domain + return SIP_MAX_NUM_OF_USERS; + + return i; + } + } + + return SIP_MAX_NUM_OF_USERS; +} + +BYTE sip_find_ua_user() +{ + BYTE i; + + for (i = 0; i < SIP_MAX_NUM_OF_USERS; i++) + { + if ((sipUsers.sipUsers[i].flag == 1) + && (strcmp(sipUsers.sipUsers[i].sipUser.userName, "SIP_UA") == 0)) + return i; + } + + return SIP_MAX_NUM_OF_USERS; +} + +BYTE sip_request_user_select(SIP_API_STRUCT *sipRecvMsg) +{ + BYTE userIndex; + SIP_URI *sipUri = &sipRecvMsg->sipApiMsg.sipMsg.sipStartLine.requestUri; + + if ((userIndex = sip_search_user_by_domain(sipUri)) < SIP_MAX_NUM_OF_USERS) + return userIndex; + + if ((userIndex = sip_search_ua_user_by_domain(sipRecvMsg)) < SIP_MAX_NUM_OF_USERS)//sipUri + return userIndex; + + if ((sipUsers.proxyIndex < SIP_MAX_NUM_OF_USERS) + && (sipUsers.sipUsers[sipUsers.proxyIndex].flag == 1)) + return sipUsers.proxyIndex; + + return SIP_MAX_NUM_OF_USERS; +} + +BYTE sip_response_user_select() +{ + if ((sipUsers.proxyIndex < SIP_MAX_NUM_OF_USERS) + && (sipUsers.sipUsers[sipUsers.proxyIndex].sipUser.proxyType == SIP_PROXY_TYPE_STATELESS)) + return sipUsers.proxyIndex; + + return SIP_MAX_NUM_OF_USERS; +} + +int sip_method_api_conv(char *str, BYTE *method, BYTE flag) +{ + if ((str == NULL) || (method == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_method_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strncmp(str, "REGISTER", 8) == 0) + *method = SIP_METHOD_REGISTER; + else if (strncmp(str, "INVITE", 6) == 0) + *method = SIP_METHOD_INVITE; + else if (strncmp(str, "ACK", 3) == 0) + *method = SIP_METHOD_ACK; + else if (strncmp(str, "CANCEL", 6) == 0) + *method = SIP_METHOD_CANCEL; + else if (strncmp(str, "BYE", 3) == 0) + *method = SIP_METHOD_BYE; + else if (strncmp(str, "OPTIONS", 7) == 0) + *method = SIP_METHOD_OPTIONS; + else if (strncmp(str, "INFO", 4) == 0) + *method = SIP_METHOD_INFO; + else if (strncmp(str, "PRACK", 5) == 0) + *method = SIP_METHOD_PRACK; + else if (strncmp(str, "UPDATE", 6) == 0) + *method = SIP_METHOD_UPDATE; + else if (strncmp(str, "REFER", 5) == 0) + *method = SIP_METHOD_REFER; + else if (strncmp(str, "re-INVITE", 9) == 0) + *method = SIP_METHOD_RE_INVITE; + else + return -1; + + return 0; + } + else + { + switch (*method) + { + case SIP_METHOD_REGISTER: + strcpy(str, "REGISTER"); + break; + case SIP_METHOD_INVITE: + strcpy(str, "INVITE"); + break; + case SIP_METHOD_ACK: + strcpy(str, "ACK"); + break; + case SIP_METHOD_CANCEL: + strcpy(str, "CANCEL"); + break; + case SIP_METHOD_BYE: + strcpy(str, "BYE"); + break; + case SIP_METHOD_OPTIONS: + strcpy(str, "OPTIONS"); + break; + case SIP_METHOD_INFO: + strcpy(str, "INFO"); + break; + case SIP_METHOD_PRACK: + strcpy(str, "PRACK"); + break; + case SIP_METHOD_UPDATE: + strcpy(str, "UPDATE"); + break; + case SIP_METHOD_REFER: + strcpy(str, "REFER"); + break; + case SIP_METHOD_RE_INVITE: + strcpy(str, "re-INVITE"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_ver_api_conv(char *str, BYTE *ver, BYTE flag) +{ + if ((str == NULL) || (ver== NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_ver_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "SIP/2.0") == 0) + *ver = SIP_VERSION_2_0; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong version number\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + else + { + switch (*ver) + { + case SIP_VERSION_2_0: + strcpy(str, "SIP/2.0"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_mime_version_api_conv(char *str, BYTE *mimeVersion, BYTE flag) +{ + if ((str == NULL) || (mimeVersion == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_mime_version_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcmp(str, "1.0") == 0) + *mimeVersion = SIP_MIME_VERSION_1_0; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong mime version number\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch(*mimeVersion) + { + case SIP_MIME_VERSION_1_0: + strcpy(str, "1.0"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_date_weekday_api_conv(char *str, BYTE *weekday, BYTE flag) +{ + if ((str == NULL) || (weekday == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_date_weekday_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcmp(str, "Sun") == 0) + *weekday = SIP_DATE_WEEK_DAY_SUN; + else if (strcmp (str, "Mon") == 0) + *weekday = SIP_DATE_WEEK_DAY_MON; + else if (strcmp (str, "Tue") == 0) + *weekday = SIP_DATE_WEEK_DAY_TUE; + else if (strcmp (str, "Wed") == 0) + *weekday = SIP_DATE_WEEK_DAY_WED; + else if (strcmp (str, "Thu") == 0) + *weekday = SIP_DATE_WEEK_DAY_THU; + else if (strcmp (str, "Fri") == 0) + *weekday = SIP_DATE_WEEK_DAY_FRI; + else if (strcmp (str, "Sat") == 0) + *weekday = SIP_DATE_WEEK_DAY_SAT; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong date weekday\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch (*weekday) + { + case SIP_DATE_WEEK_DAY_SUN: + strcpy(str, "Sun"); + break; + case SIP_DATE_WEEK_DAY_MON: + strcpy(str, "Mon"); + break; + case SIP_DATE_WEEK_DAY_TUE: + strcpy(str, "Tue"); + break; + case SIP_DATE_WEEK_DAY_WED: + strcpy(str, "Wed"); + break; + case SIP_DATE_WEEK_DAY_THU: + strcpy(str, "Thu"); + break; + case SIP_DATE_WEEK_DAY_FRI: + strcpy(str, "Fri"); + break; + case SIP_DATE_WEEK_DAY_SAT: + strcpy(str, "Sat"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_date_month_api_conv(char *str, BYTE *month, BYTE flag) +{ + if ((str == NULL) || (month== NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_date_month_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcmp(str, "Jan") == 0) + *month = SIP_DATE_MONTH_JAN; + else if (strcmp(str, "Feb") == 0) + *month = SIP_DATE_MONTH_FEB; + else if (strcmp(str, "Mar") == 0) + *month = SIP_DATE_MONTH_MAR; + else if (strcmp(str, "Apr") == 0) + *month = SIP_DATE_MONTH_APR; + else if (strcmp(str, "May") == 0) + *month = SIP_DATE_MONTH_MAY; + else if (strcmp(str, "Jun") == 0) + *month = SIP_DATE_MONTH_JUN; + else if (strcmp(str, "Jul") == 0) + *month = SIP_DATE_MONTH_JUL; + else if (strcmp(str, "Aug") == 0) + *month = SIP_DATE_MONTH_AUG; + else if (strcmp(str, "Sep") == 0) + *month = SIP_DATE_MONTH_SEP; + else if (strcmp(str, "Oct") == 0) + *month = SIP_DATE_MONTH_OCT; + else if (strcmp(str, "Nov") == 0) + *month = SIP_DATE_MONTH_NOV; + else if (strcmp(str, "Dec") == 0) + *month = SIP_DATE_MONTH_DEC; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong date month\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch(*month) + { + case SIP_DATE_MONTH_JAN: + strcpy(str, "Jan"); + break; + case SIP_DATE_MONTH_FEB: + strcpy(str, "Feb"); + break; + case SIP_DATE_MONTH_MAR: + strcpy(str, "Mar"); + break; + case SIP_DATE_MONTH_APR: + strcpy(str, "Apr"); + break; + case SIP_DATE_MONTH_MAY: + strcpy(str, "May"); + break; + case SIP_DATE_MONTH_JUN: + strcpy(str, "Jun"); + break; + case SIP_DATE_MONTH_JUL: + strcpy(str, "Jul"); + break; + case SIP_DATE_MONTH_AUG: + strcpy(str, "Aug"); + break; + case SIP_DATE_MONTH_SEP: + strcpy(str, "Sep"); + break; + case SIP_DATE_MONTH_OCT: + strcpy(str, "Oct"); + break; + case SIP_DATE_MONTH_NOV: + strcpy(str, "Nov"); + break; + case SIP_DATE_MONTH_DEC: + strcpy(str, "Dec"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_date_type_api_conv(char *str, BYTE *dateType, BYTE flag) +{ + if ((str == NULL) || (dateType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_date_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcmp(str, "GMT") == 0) + *dateType = SIP_DATE_TYPE_GMT; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong date month\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch (*dateType) + { + case SIP_DATE_TYPE_GMT: + strcpy(str, "GMT"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_proto_api_conv(char *str, BYTE *proto, BYTE flag) +{ + if ((str == NULL) || (proto == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_proto_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "UDP") == 0) + *proto = SIP_API_PROTO_UDP; + else if (strcasecmp(str, "TCP") == 0) + *proto = SIP_API_PROTO_TCP; + else if (strcasecmp(str, "SCTP") == 0) + *proto = SIP_API_PROTO_SCTP; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong protocol type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + else + { + switch (*proto) + { + case SIP_API_PROTO_UDP: + strcpy(str, "UDP"); + break; + case SIP_API_PROTO_TCP: + strcpy(str, "TCP"); + break; + case SIP_API_PROTO_SCTP: + strcpy(str, "SCTP"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_uri_type_api_conv(char *str, BYTE *uriType, BYTE flag) +{ + if ((str == NULL) || (uriType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strncasecmp (str, "SIPS", 4) == 0) + *uriType = SIP_URI_TYPE_SIPS; + else if (strncasecmp (str, "SIP", 3) == 0) + *uriType = SIP_URI_TYPE_SIP; + else if (strncasecmp (str, "TEL", 3) == 0) + *uriType = SIP_URI_TYPE_TEL; + else + { + sprintf((char *)sipAsciTempBuf, "Unsupported URI type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + else + { + switch (*uriType) + { + case SIP_URI_TYPE_SIP: + strcpy(str, "SIP"); + break; + case SIP_URI_TYPE_SIPS: + strcpy(str, "SIPS"); + break; + case SIP_URI_TYPE_TEL: + strcpy(str, "TEL"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_accept_type_api_conv(char *str, BYTE *acceptType, BYTE flag) +{ + if ((str == NULL) || (acceptType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "application") == 0) + *acceptType = SIP_ACCEPT_TYPE_APPLICATION; + else if (strcasecmp(str, "multipart") == 0) + *acceptType = SIP_ACCEPT_TYPE_MULTIPART; + else if (strcasecmp(str, "*") == 0) + *acceptType = SIP_ACCEPT_TYPE_WILDCARD; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong accept type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + else + { + switch (*acceptType) + { + case SIP_ACCEPT_TYPE_APPLICATION: + strcpy(str, "application"); + break; + case SIP_ACCEPT_TYPE_MULTIPART: + strcpy(str, "multipart"); + break; + case SIP_ACCEPT_TYPE_WILDCARD: + strcpy(str, "*"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_accept_sub_type_api_conv(char *str, BYTE *acceptSubType, BYTE flag) +{ + if ((str == NULL) || (acceptSubType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_sub_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "sdp") == 0) + *acceptSubType = SIP_ACCEPT_SUB_TYPE_SDP; + else if (strcasecmp(str, "isup") == 0) + *acceptSubType = SIP_ACCEPT_SUB_TYPE_ISUP; + else if (strcasecmp(str, "mixed") == 0) + *acceptSubType = SIP_ACCEPT_SUB_TYPE_MIXED; + else if (strcasecmp(str, "*") == 0) + *acceptSubType = SIP_ACCEPT_SUB_TYPE_WILDCARD; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong accept sub type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + return 0; + } + else + { + switch (*acceptSubType) + { + case SIP_ACCEPT_SUB_TYPE_SDP: + strcpy(str, "sdp"); + break; + case SIP_ACCEPT_SUB_TYPE_ISUP: + strcpy(str, "isup"); + break; + case SIP_ACCEPT_SUB_TYPE_MIXED: + strcpy(str, "mixed"); + break; + case SIP_ACCEPT_SUB_TYPE_WILDCARD: + strcpy(str, "*"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_accept_encoding_api_conv(char *str, BYTE *acceptEncoding, BYTE flag) +{ + if ((str == NULL) || (acceptEncoding == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_encoding_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "identity") == 0) + *acceptEncoding = SIP_ACCEPT_ENCODING_IDENTITY; + else if (strcasecmp(str, "gzip") == 0) + *acceptEncoding = SIP_ACCEPT_ENCODING_GZIP; + else if (strcasecmp(str, "tar") == 0) + *acceptEncoding = SIP_ACCEPT_ENCODING_TAR; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong accept encoding\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + return 0; + } + else + { + switch (*acceptEncoding) + { + case SIP_ACCEPT_ENCODING_IDENTITY: + strcpy(str, "identity"); + break; + case SIP_ACCEPT_ENCODING_GZIP: + strcpy(str, "gzip"); + break; + case SIP_ACCEPT_ENCODING_TAR: + strcpy(str, "tar"); + break; + default: + return -1; + } + + return 0; + } + + return -1; +} + +int sip_accept_language_api_conv(char *str, BYTE *acceptLanguage, BYTE flag) +{ + if ((str == NULL) || (acceptLanguage == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_language_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "en") == 0) + *acceptLanguage = SIP_ACCEPT_LANGUAGE_EN; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong accept language\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch (*acceptLanguage) + { + case SIP_ACCEPT_LANGUAGE_EN: + strcpy(str, "en"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_content_type_api_conv(char *str, BYTE *contentType, BYTE flag) +{ + if ((str == NULL) || (contentType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_content_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "application") == 0) + *contentType = SIP_CONTENT_TYPE_APPLICATION; + else if (strcasecmp(str, "multipart") == 0) + *contentType = SIP_CONTENT_TYPE_MULTIPART; + else if (strcasecmp(str, "text") == 0) + *contentType = SIP_CONTENT_TYPE_TEXT; + else if (strcasecmp(str, "image") == 0) + *contentType = SIP_CONTENT_TYPE_IMAGE; + else if (strcasecmp(str, "audio") == 0) + *contentType = SIP_CONTENT_TYPE_AUDIO; + else if (strcasecmp(str, "vedio") == 0) + *contentType = SIP_CONTENT_TYPE_VEDIO; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong content type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + else + { + switch (*contentType) + { + case SIP_CONTENT_TYPE_APPLICATION: + strcpy(str, "application"); + break; + case SIP_CONTENT_TYPE_MULTIPART: + strcpy(str, "multipart"); + break; + case SIP_CONTENT_TYPE_TEXT: + strcpy(str, "text"); + break; + case SIP_CONTENT_TYPE_IMAGE: + strcpy(str, "image"); + break; + case SIP_CONTENT_TYPE_AUDIO: + strcpy(str, "audio"); + break; + case SIP_CONTENT_TYPE_VEDIO: + strcpy(str, "vedio"); + break; + default: + return -1; + } + return 0; + } + + return -1; +} + +int sip_content_sub_type_api_conv(char *str, BYTE *contentSubType, BYTE flag) +{ + if ((str == NULL) || (contentSubType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_content_sub_type_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "sdp") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_SDP; + else if (strcasecmp(str, "isup") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_ISUP; + else if (strcasecmp(str, "mixed") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_MIXED; + else if (strcasecmp(str, "message") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_MESSAGE; + else if (strcasecmp(str, "signed") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_SIGNED; + else if (strcasecmp(str, "pkcs7-mime") == 0) + *contentSubType = SIP_CONTENT_SUB_TYPE_PKCS7_MIME; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong content sub type\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + return 0; + } + else + { + switch (*contentSubType) + { + case SIP_CONTENT_SUB_TYPE_SDP: + strcpy(str, "sdp"); + break; + case SIP_CONTENT_SUB_TYPE_ISUP: + strcpy(str, "isup"); + break; + case SIP_CONTENT_SUB_TYPE_MIXED: + strcpy(str, "mixed"); + break; + case SIP_CONTENT_SUB_TYPE_MESSAGE: + strcpy(str, "message"); + break; + case SIP_CONTENT_SUB_TYPE_SIGNED: + strcpy(str, "signed"); + break; + case SIP_CONTENT_SUB_TYPE_PKCS7_MIME: + strcpy(str, "pkcs7-mime"); + break; + default: + return -1; + } + return 0; + } + return -1; +} + +int sip_content_disposition_api_conv(char *str, BYTE *contentDisposition, BYTE flag) +{ + if ((str == NULL) || (contentDisposition == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_content_disposition_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "signal") == 0) + { + *contentDisposition = SIP_CONTENT_DISPOSITION_SIGNAL; + } + else + { + sprintf((char *)sipAsciTempBuf, "Wrong content disposition\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch (*contentDisposition) + { + case SIP_CONTENT_DISPOSITION_SIGNAL: + strcpy(str, "signal"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_content_encoding_api_conv(char *str, BYTE *contentEncoding, BYTE flag) +{ + if ((str == NULL) || (contentEncoding == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_content_encoding_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "identity") == 0) + *contentEncoding = SIP_CONTENT_ENCODING_IDENTITY; + else if (strcasecmp(str, "gzip") == 0) + *contentEncoding = SIP_CONTENT_ENCODING_GZIP; + else if (strcasecmp(str, "tar") == 0) + *contentEncoding = SIP_CONTENT_ENCODING_TAR; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong content encoding\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch (*contentEncoding) + { + case SIP_CONTENT_ENCODING_IDENTITY: + strcpy(str, "identity"); + break; + case SIP_CONTENT_ENCODING_GZIP: + strcpy(str, "gzip"); + break; + case SIP_CONTENT_ENCODING_TAR: + strcpy(str, "tar"); + break; + default: + return -1; + } + } + return 0; +} + +int sip_content_language_api_conv(char *str, BYTE *contentLanguage, BYTE flag) +{ + if ((str == NULL) || (contentLanguage == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_content_language_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "en") == 0) + *contentLanguage = SIP_CONTENT_LANGUAGE_EN; + else + { + sprintf((char *)sipAsciTempBuf, "Wrong content language\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + switch(*contentLanguage) + { + case SIP_CONTENT_LANGUAGE_EN: + strcpy(str, "en"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_allow_api_conv(char *str, BYTE *allowMethod, BYTE flag) +{ + if ((str == NULL) || (allowMethod == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_allow_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcmp(str, "REGISTER") == 0) + *allowMethod = SIP_METHOD_REGISTER; + else if (strcmp(str, "INVITE") == 0) + *allowMethod = SIP_METHOD_INVITE; + else if (strcmp(str, "ACK") == 0) + *allowMethod = SIP_METHOD_ACK; + else if (strcmp(str, "CANCEL") == 0) + *allowMethod = SIP_METHOD_CANCEL; + else if (strcmp(str, "BYE") == 0) + *allowMethod = SIP_METHOD_BYE; + else if (strcmp(str, "OPTIONS") == 0) + *allowMethod = SIP_METHOD_OPTIONS; + else if (strcmp(str, "INFO") == 0) + *allowMethod = SIP_METHOD_INFO; + else if (strcmp(str, "PRACK") == 0) + *allowMethod = SIP_METHOD_PRACK; + else if (strcmp(str, "UPDATE") == 0) + *allowMethod = SIP_METHOD_UPDATE; + else if (strcmp(str, "REFER") == 0) + *allowMethod = SIP_METHOD_REFER; + else + return -2; + } + else + { + switch (*allowMethod) + { + case SIP_METHOD_REGISTER: + strcpy(str, "REGISTER"); + break; + case SIP_METHOD_INVITE: + strcpy(str, "INVITE"); + break; + case SIP_METHOD_ACK: + strcpy(str, "ACK"); + break; + case SIP_METHOD_CANCEL: + strcpy(str, "CANCEL"); + break; + case SIP_METHOD_BYE: + strcpy(str, "BYE"); + break; + case SIP_METHOD_OPTIONS: + strcpy(str, "OPTIONS"); + break; + case SIP_METHOD_INFO: + strcpy(str, "INFO"); + break; + case SIP_METHOD_PRACK: + strcpy(str, "PRACK"); + break; + case SIP_METHOD_UPDATE: + strcpy(str, "UPDATE"); + break; + case SIP_METHOD_REFER: + strcpy(str, "REFER"); + break; + default: + return -1;//return -1; + } + } + + return 0; +} + +int sip_option_tag_api_conv(char *str, BYTE *option, BYTE flag) +{ + if ((str == NULL) || (option == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_option_tag_api_conv: point is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (flag == SIP_STR_TO_API) + { + if (strcasecmp(str, "100rel") == 0) + *option = SIP_OPTION_TAG_100_REL; + else if (strcasecmp(str, "foo") == 0) + *option = SIP_OPTION_TAG_FOO; + else + return 0; + } + else + { + switch (*option) + { + case SIP_OPTION_TAG_100_REL: + strcpy(str, "100rel"); + break; + case SIP_OPTION_TAG_FOO: + strcpy(str, "foo"); + break; + default: + return -1; + } + } + + return 0; +} + +int sip_recv_msg_handling(char *msg, WORD len, int tcpSockIndex) +{ + char *nextHeader; + BYTE user; + WORD transId; + SIP_ENTITY *sipEntity; + + sip_util_replace_all_lws(msg); + + if (sip_msg_start_line_parse(&sipRecvMsg, msg, &nextHeader) < 0) + return -1; + + if (sip_msg_headers_parse(&sipRecvMsg, nextHeader, &nextHeader) < 0) + return -1; + + sipEntity = &sipRecvMsg.sipApiMsg.sipMsg.sipEntity; + + if (nextHeader[0] == '\0' || nextHeader[1] == '\0' || nextHeader[2] == '\0') + { // No body found + if (sipEntity->sipHdrContentLength > 0) + return -1; + } + else if (sipEntity->sipHdrContentLength > 0) + { + if ((nextHeader[0] == '\r') && (nextHeader[1] == '\n')) + nextHeader = nextHeader + 2; + else + nextHeader = nextHeader + 1; + + if (sip_body_parse(&sipRecvMsg, nextHeader, len - (nextHeader - msg - 2)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_recv_msg_handling:sip_body_parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if (sipRecvMsg.sipApiType == SIP_API_REQ_MSG) + { + if (sipRecvMsg.sipApiMsg.sipMsg.sipStartLine.sipMethod == SIP_METHOD_OPTIONS) + { + sip_send_option_rsp(&sipRecvMsg); + return 0; + } + + if ((transId = sip_request_match_server_trans(&sipRecvMsg)) >= SIP_MAX_NUM_OF_TRANS) + { + if ((user = sip_request_user_select(&sipRecvMsg)) < SIP_MAX_NUM_OF_USERS) + sipUsers.sipUsers[user].sipUser.recv_proc(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sipRecvMsg); + else + { +// sip_process_invalid_req(&sipRecvMsg); + if (sipRecvMsg.sipApiMsg.sipMsg.sipStartLine.sipMethod == SIP_METHOD_CANCEL) + { + sip_send_call_not_exit_rsp(&sipRecvMsg); + } + else + { + sip_send_not_find_rsp(&sipRecvMsg); + } + return -1; + } + } + else + sip_msg_transport_to_transaction(&sipRecvMsg, transId); + } + else + { + if ((transId = sip_response_match_client_trans(&sipRecvMsg)) >= SIP_MAX_NUM_OF_TRANS) + { + if ((sipRecvMsg.sipApiMsg.sipMsg.sipHdrCseq.method == SIP_METHOD_INVITE) + && (sipRecvMsg.sipApiMsg.sipMsg.sipStartLine.statusCode == 200) + && ((user = sip_find_ua_user(&sipRecvMsg)) < SIP_MAX_NUM_OF_USERS)) + { + if (sip_response_match_ua_dialog(&sipRecvMsg) < SIP_UA_MAX_NUM_OF_DIALOG) + { + sipUsers.sipUsers[user].sipUser.recv_proc(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sipRecvMsg); + return 0; + } + else + { + sprintf((char *)sipAsciTempBuf, "sip_recv_msg_handling:invite 200 can not find dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + } + } + + if ((user = sip_response_user_select()) < SIP_MAX_NUM_OF_USERS) + sipUsers.sipUsers[user].sipUser.recv_proc(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sipRecvMsg); + else + return -1; + } + else + sip_msg_transport_to_transaction(&sipRecvMsg, transId); + } + + return 0; +} + +/* The upper layer uses this function to send sip message to the peer + sipTransId: destination SIP transcation ID the UP message will be sent to, if unknown, it should be set to 0xFFFF + upPort: source UP port the message is sent from + transFlag: indicates whether this message will be sent within SIP transaction layer (stateful proxy or user agent), + or directly goes to the SIP transport layer (stateless proxy) + sipApiMsg: a pointer pointing to the actual struct of the message to be sent to the SIP module + if succeeds, returns sip_port, otherwise return a negative value + if succeeds, and no sip_port is maintained for this message, returns 0xFFFF +*/ + +void sip_fill_msg_with_cr(SIP_MSG *sipMsg, SIP_CR_MSG *sipCrMsg) +{ + if ((sipMsg == NULL) || (sipCrMsg == NULL)) + { + return; + } + + memcpy(&sipMsg->sipStartLine, &sipCrMsg->sipCrStartLine, sizeof(SIP_START_LINE)); + memcpy(&sipMsg->sipHdrTo, &sipCrMsg->sipCrHdrTo, sizeof(SIP_HDR_TO)); + memcpy(&sipMsg->sipHdrFrom, &sipCrMsg->sipCrHdrFrom, sizeof(SIP_HDR_FROM)); + memcpy(&sipMsg->sipHdrCseq, &sipCrMsg->sipCrHdrCseq, sizeof(SIP_HDR_CSEQ)); + memcpy(&sipMsg->sipHdrCallId, &sipCrMsg->sipCrHdrCallId, sizeof(SIP_HDR_CALL_ID)); + sipMsg->sipHdrVias.num = 1; + sipMsg->sipHdrVias.head = 1; + memcpy(&sipMsg->sipHdrVias.vias[1], &sipCrMsg->sipCrHdrVia, sizeof(SIP_HDR_VIA)); +} + +void sip_fill_cr_msg(SIP_CR_MSG *sipCrMsg, SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sipMsg; + BYTE head; + + if ((sipCrMsg == NULL) || (sipApiMsg == NULL)) + { + return; + } + + memcpy(&sipCrMsg->sipTransAddr, &sipApiMsg->sipTransAddr, sizeof(SIP_TRANSPORT_ADDR)); + + sipMsg = &sipApiMsg->sipApiMsg.sipMsg; + + memcpy(&sipCrMsg->sipCrStartLine, &sipMsg->sipStartLine, sizeof(SIP_START_LINE)); + memcpy(&sipCrMsg->sipCrHdrTo, &sipMsg->sipHdrTo, sizeof(SIP_HDR_TO)); + memcpy(&sipCrMsg->sipCrHdrFrom, &sipMsg->sipHdrFrom, sizeof(SIP_HDR_FROM)); + memcpy(&sipCrMsg->sipCrHdrCseq, &sipMsg->sipHdrCseq, sizeof(SIP_HDR_CSEQ)); + memcpy(&sipCrMsg->sipCrHdrCallId, &sipMsg->sipHdrCallId, sizeof(SIP_HDR_CALL_ID)); + head = sipMsg->sipHdrVias.head; + memcpy(&sipCrMsg->sipCrHdrVia, &sipMsg->sipHdrVias.vias[head], sizeof(SIP_HDR_VIA)); +} + +void sip_fill_allow_header(SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sdMsg; + BYTE num = 0; + + if (sipApiMsg == NULL) + { + return; + } + + sdMsg = &sipApiMsg->sipApiMsg.sipMsg; + + if (sipApiMsg->sipApiType == SIP_API_REQ_MSG) + { + sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ALLOW_MASK; + + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_REGISTER; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_INVITE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_ACK; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_CANCEL; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_BYE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_OPTIONS; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_UPDATE; + + sdMsg->sipHdrAllow.num = num; + + return; + } + else + { + if ((sipApiMsg->sipApiMsg.sipMsg.sipStartLine.statusCode > 100) + && (sipApiMsg->sipApiMsg.sipMsg.sipStartLine.statusCode < 300)) + { + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_REGISTER; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_INVITE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_ACK; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_CANCEL; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_BYE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_OPTIONS; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_INFO; + + sdMsg->sipHdrAllow.num = num; + } + + return; + } +} + +int sip_send_msg(WORD sipTransId, WORD upPort, BYTE transFlag, SIP_API_STRUCT *sipApiMsg) +{ + SIP_TRANSACTION *trans; + + if (transFlag == SIP_TRANSACTION_LAYER) + { + if (sipTransId >= SIP_MAX_NUM_OF_TRANS) + return -1; + + trans = &sipTrans[sipTransId]; + + sip_fill_allow_header(sipApiMsg); + + if (sip_transport_encode_trans_msg(trans, sipApiMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_send_msg:encode sip msg failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + +// memcpy((BYTE *)&trans->sdMsg, (BYTE *)sipApiMsg, sizeof(SIP_API_STRUCT)); // backup, for retransmission + sip_set_trans_send_cmd(trans, sipApiMsg); + sip_transaction_proc(sipTransId); + } + else + { + sip_transport_send_msg(sipApiMsg); + } + + return 0; +} + +int sip_send_ack(SIP_API_STRUCT *ackMsg, SIP_TRANSACTION *trans) +{ + SIP_MSG *sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + + if ((ackMsg == NULL) || (trans == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_send_ack:msg or transaction is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy((BYTE *) &sipSendMsg, (BYTE *) ackMsg, sizeof(SIP_API_STRUCT)); + memcpy((BYTE *) &sdMsg->sipStartLine, (BYTE *) &trans->crMsg.sipCrStartLine, sizeof(SIP_START_LINE)); +// memcpy((BYTE *) &sdMsg->sipStartLine, (BYTE *) &srcMsg->sipStartLine, sizeof(SIP_START_LINE)); + + sipSendMsg.sipApiType = SIP_API_REQ_MSG; + sdMsg->sipStartLine.sipMethod = SIP_METHOD_ACK; + sdMsg->sipHdrCseq.method = SIP_METHOD_ACK; + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + + sdMsg->sipReStruct.sipReHdrFlag[0] = SIP_HDR_MAX_FORWARDS_MASK; + sdMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +int sip_send_100(SIP_CR_MSG *ackMsg, SIP_TRANSACTION *trans) +{ + SIP_MSG *sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + + if ((ackMsg == NULL) || (trans == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_send_100:msg or transaction is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy((BYTE *)&sipSendMsg.sipTransAddr, &ackMsg->sipTransAddr, sizeof(SIP_TRANSPORT_ADDR)); + sip_fill_msg_with_cr(sdMsg, ackMsg); + + sipSendMsg.sipApiType = SIP_API_RES_MSG; + sdMsg->sipStartLine.statusCode = 100; + strcpy(sdMsg->sipStartLine.reasonPhrase, "Trying"); + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + sdMsg->sipReStruct.sipReHdrFlag[0] = 0; + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +int sip_send_504(SIP_API_STRUCT *ackMsg, SIP_TRANSACTION *trans) +{ + SIP_MSG *sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + + if ((ackMsg == NULL) || (trans == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_send_504:msg or transaction is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy((BYTE *) &sipSendMsg, (BYTE *) ackMsg, sizeof(SIP_API_STRUCT)); + + sipSendMsg.sipApiType = SIP_API_RES_MSG; + sdMsg->sipStartLine.statusCode = 504; + strcpy(sdMsg->sipStartLine.reasonPhrase, "Server Time-out"); + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + sdMsg->sipReStruct.sipReHdrFlag[0] = 0; + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +int sip_send_option_rsp(SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sdMsg; + BYTE num = 0; + + if (sipApiMsg == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_send_option_rsp:sipApiMsg is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + + memcpy((BYTE *) &sipSendMsg, (BYTE *) sipApiMsg, sizeof(SIP_API_STRUCT)); + + sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + sipSendMsg.sipApiType = SIP_API_RES_MSG; + sdMsg->sipStartLine.statusCode = 200; + strcpy(sdMsg->sipStartLine.reasonPhrase, "OK"); + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK | SIP_HDR_ALLOW_MASK; + + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_REGISTER; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_INVITE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_ACK; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_CANCEL; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_BYE; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_OPTIONS; + sdMsg->sipHdrAllow.allowMethod[num++] = SIP_METHOD_INFO; + + sdMsg->sipHdrAllow.num = num; + + sdMsg->sipReStruct.sipReHdrFlag[0] = 0; + + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +int sip_send_call_not_exit_rsp(SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + + if (sipApiMsg == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_send_call_not_exit_rsp:sipApiMsg is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + + memcpy((BYTE *) &sipSendMsg, (BYTE *) sipApiMsg, sizeof(SIP_API_STRUCT)); + + sipSendMsg.sipApiType = SIP_API_RES_MSG; + sdMsg->sipStartLine.statusCode = 481; + strcpy(sdMsg->sipStartLine.reasonPhrase, "Call/Transaction Does Not Exist"); + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + + sdMsg->sipReStruct.sipReHdrFlag[0] = 0; + + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +int sip_send_not_find_rsp(SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sdMsg = &sipSendMsg.sipApiMsg.sipMsg; + + if (sipApiMsg == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_send_not_find_rsp:sipApiMsg is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + memset((BYTE *) &sipSendMsg, 0, sizeof(SIP_API_STRUCT)); + + memcpy((BYTE *) &sipSendMsg, (BYTE *) sipApiMsg, sizeof(SIP_API_STRUCT)); + + sipSendMsg.sipApiType = SIP_API_RES_MSG; + sdMsg->sipStartLine.statusCode = 404; + strcpy(sdMsg->sipStartLine.reasonPhrase, "Not Found"); + sdMsg->sipEntity.sipHdrContentLength = 0; + sdMsg->sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + + sdMsg->sipReStruct.sipReHdrFlag[0] = 0; + + sip_transport_send_msg(&sipSendMsg); + + return 0; +} + +/*int sip_send_allow() +{ +}*/ diff --git a/omc/plat/sip/src/sip_msg_encode.c b/omc/plat/sip/src/sip_msg_encode.c new file mode 100644 index 0000000..f72d8b1 --- /dev/null +++ b/omc/plat/sip/src/sip_msg_encode.c @@ -0,0 +1,1676 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "./include/sip_msg.h" +#include "./include/sip_msg_encode.h" +#include "./include/sip_debug.h" + +char *sip_uri_escape_nonascii_and_nondef(char *string, char *def) +{ + WORD alloc = strlen(string) + 1; + WORD length; + BYTE in; + WORD newLen = alloc; + int index = 0; + char *tmp; + int i; + + length = alloc - 1; + while (length--) + { + in = *string; + + i = 0; + tmp = NULL; + if (sip_is_alphanum(in)) + tmp = string; + else + { + for (; def[i] != '\0' && def[i] != in; i++) + { + } + if (def[i] != '\0') + tmp = string; + } + if (tmp == NULL) + { + // encode it + newLen += 2; // the size grows with two, since this'll become a %XX + if (newLen > alloc) + { + alloc *= 2; + } + sprintf (&sipEscapeBuf[index], "%%%02X", in); + index += 3; + } + else + { + // just copy this + sipEscapeBuf[index++] = in; + } + string++; + } + sipEscapeBuf[index] = 0; // terminate it + + return sipEscapeBuf; +} + +/* user = *( unreserved / escaped / user-unreserved ) */ +char *userInfoDef = /* implied _ALPHANUM_ */ _MARK__USER_UNRESERVED_; + +char *sip_uri_escape_user_info(char *string) +{ + return sip_uri_escape_nonascii_and_nondef(string, userInfoDef); +} + +/* user = *( unreserved / escaped / user-unreserved ) */ +char *passwordDef = _MARK__PWORD_UNRESERVED_; + +char *sip_uri_escape_password(char *string) +{ + return sip_uri_escape_nonascii_and_nondef(string, passwordDef); +} + +char *uriParamDef = _MARK__URI_PARAM_UNRESERVED_; + +char *sip_uri_escape_uri_param(char *string) +{ + return sip_uri_escape_nonascii_and_nondef(string, uriParamDef); +} + +char *headerParamDef = _MARK__HEADER_PARAM_UNRESERVED_; + +char *sip_uri_escape_header_param(char *string) +{ + return sip_uri_escape_nonascii_and_nondef (string, headerParamDef); +} + +int sip_encode_para_name(char *dest, BYTE pname) +{ + if (dest == NULL) + { + return 0; + } + + switch (pname) + { + case SIP_API_PNAME_TAG: + sprintf(dest, "%s", SIP_PNAME_TAG); + break; + case SIP_API_PNAME_BRANCH: + sprintf(dest, "%s", SIP_PNAME_BRANCH); + break; + case SIP_API_PNAME_EXPIRES: + sprintf(dest, "%s", SIP_PNAME_EXPIRES); + break; + case SIP_API_PNAME_USER: + sprintf(dest, "%s", SIP_PNAME_USER); + break; + case SIP_API_PNAME_LR: + sprintf(dest, "%s", SIP_PNAME_LR); + break; + case SIP_API_PNAME_BOUNDARY: + sprintf(dest, "%s", SIP_PNAME_BOUNDARY); + break; + case SIP_API_PNAME_HANDLING: + sprintf(dest, "%s", SIP_PNAME_HANDLING); + break; + case SIP_API_PNAME_TRANSPORT: + sprintf(dest, "%s", SIP_PNAME_TRANSPORT); + break; + case SIP_API_PNAME_RPOTR: + sprintf(dest, "%s", SIP_PNAME_RPORT); + break; + case SIP_API_PNAME_VERSION: + sprintf(dest, "%s", SIP_PNAME_VERSION); + break; + case SIP_API_PNAME_BASE: + sprintf(dest, "%s", SIP_PNAME_BASE); + break; + default: + return 0;//return -1 + } + + return 0; +} + +int sip_encode_para(char *dest, SIP_GEN_PARA *para, BYTE last, BYTE escape) +{ + char param[128] = ""; + char name[128]= ""; + char value[128] = ""; + char *pname, *pvalue; + + if ((dest == NULL) || (para == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_para: dest or para is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_para_name(name, para->paraName) < 0) + return -1; + + if (escape) + pname = sip_uri_escape_uri_param(name); + else + pname = name; + + strcpy(param, pname); + + if (para->paraType == SIP_API_PTYPE_STRING) + sprintf(value, "%s", para->para.paraStr); + else if (para->paraType == SIP_API_PTYPE_VALUE) + { + if (para->para.paraVal[0] == 0xFFFFFFFF) + strcpy(value, ""); + else + sprintf(value, "%ld", para->para.paraVal[0]); + } + + if ((para->paraType == SIP_API_PTYPE_STRING) || + (para->paraType == SIP_API_PTYPE_VALUE)) + { + if (escape) + pvalue = sip_uri_escape_uri_param(value); + else + pvalue = value; + } + + if ((para->paraType == SIP_API_PTYPE_STRING) || + (para->paraType == SIP_API_PTYPE_VALUE)) + { + if (pvalue[0] != '\0') + { + strcat(param, "="); + strcat(param, pvalue); + } + } + + if (last == 0)//((last == 0) && (param[0] != '\0')) + strcat(param, ";"); + + strcat(dest, param); + + return 0; +} + +int sip_encode_params(char *dest, SIP_GEN_PARAMS *params, BYTE escape) +{ + BYTE i, last = 0; + + if ((dest == NULL) || (params == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_params: dest or params is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcpy(dest, ""); + + if (params->paraNum == 0) + return -2; + + for (i = 0; i < params->paraNum; i++) + { + if (i == (params->paraNum - 1)) + last = 1; + if (sip_encode_para(dest, ¶ms->para[i], last, escape) < 0) + return -1; + + } + + return 0; +} + +int sip_encode_url(char *dest, SIP_URI *url, BYTE flag) +{ + char params[128]; + char port[16]; + int result; + char *userName; + + if ((dest == NULL) || (url == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_url: dest or url is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((result = sip_encode_params(params, &url->params, 0)) == -1) + return -1; + + strcpy(port, ""); + if (url->port != 0) + sprintf(port, ":%d", url->port); + + if ((flag & SIP_ENCODE_URL_NO_USER_PART) == SIP_ENCODE_URL_NO_USER_PART) + { + if ((flag & SIP_ENCODE_URL_NO_BRACKETS) == SIP_ENCODE_URL_NO_BRACKETS) + { + if (result == 0) + sprintf(dest, "%s%s;%s", url->host.addr.domain, port, params); + else + sprintf(dest, "%s%s", url->host.addr.domain, port); + } + else + { + if (result == 0) + sprintf(dest, "", url->host.addr.domain, port, params); + else + sprintf(dest, "", url->host.addr.domain, port); + } + } + else + { + userName = sip_uri_escape_user_info (url->userName); + if ((flag & SIP_ENCODE_URL_NO_BRACKETS) == SIP_ENCODE_URL_NO_BRACKETS) + { + if (result == 0) + { + if (*userName == '\0') + sprintf(dest, "sip:%s%s;%s", url->host.addr.domain, port, params); + else + sprintf(dest, "sip:%s@%s%s;%s", userName, url->host.addr.domain, port, params); + } + else + { + if (*userName == '\0') + sprintf(dest, "sip:%s%s", url->host.addr.domain, port); + else + sprintf(dest, "sip:%s@%s%s", userName, url->host.addr.domain, port); + } + } + else + { + if (result == 0) + { + if (*userName == '\0') + sprintf(dest, "", url->host.addr.domain, port, params); + else + sprintf(dest, "", userName, url->host.addr.domain, port, params); + } + else + { + if (*userName == '\0') + sprintf(dest, "", url->host.addr.domain, port); + else + sprintf(dest, "", userName, url->host.addr.domain, port); + } + } + } + + return 0; +} + +int sip_encode_via_url(char *dest, SIP_VIA_URI *url, BYTE flag) +{ + char port[16]; + + if ((dest == NULL) || (url == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_url: dest or url is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcpy(port, ""); + if (url->port != 0) + sprintf(port, ":%d", url->port); + + if ((flag & SIP_ENCODE_URL_NO_BRACKETS) == SIP_ENCODE_URL_NO_BRACKETS) + { + sprintf(dest, "%s%s", url->domain, port); + } + else + { + sprintf(dest, "", url->domain, port); + } + + return 0; +} + +int sip_transport_encode_start_line(char *dest, SIP_API_STRUCT *sipApiMsg) +{ + char ver[8]; + char statusCode[8]; + char method[16]; + char uri[128]; + SIP_START_LINE *startLine; + + if ((dest == NULL) || (sipApiMsg == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_start_line: dest or sipApiMsg is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startLine = &sipApiMsg->sipApiMsg.sipMsg.sipStartLine; + + if (sipApiMsg->sipApiType == SIP_API_RES_MSG) + { + if (sip_ver_api_conv(ver, &startLine->sipVersion, SIP_API_TO_STR) < 0) + return -1; + sprintf(statusCode, "%d", startLine->statusCode); + sprintf((char *)sipEncBuf, "%s %s %s\r\n", ver, statusCode, startLine->reasonPhrase); + } + else + { + if (sip_method_api_conv(method, &startLine->sipMethod, SIP_API_TO_STR) < 0) + return -1; + sip_encode_url(uri, &startLine->requestUri, SIP_ENCODE_URL_NO_BRACKETS); + if (sip_ver_api_conv(ver, &startLine->sipVersion, SIP_API_TO_STR) < 0) + return -1; + sprintf((char *)sipEncBuf, "%s %s %s\r\n", method, uri, ver); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_call_id(char *dest, SIP_HDR_CALL_ID *callId) +{ + if ((dest == NULL) || (callId == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_call_id: dest or callId is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + callId->value[SIP_MAX_CALL_ID_LEN - 1] = '\0'; + if (callId->host[0] != '\0') + sprintf((char *)sipEncBuf, "Call-ID: %s@%s\r\n", callId->value, callId->host); + else + sprintf((char *)sipEncBuf, "Call-ID: %s\r\n", callId->value); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_cseq(char *dest, SIP_HDR_CSEQ *cseq) +{ + char method[32]; + + if ((dest == NULL) || (cseq == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_cseq: dest or cseq is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_method_api_conv(method, &cseq->method, SIP_API_TO_STR) < 0) + return -1; + + sprintf((char *)sipEncBuf, "CSeq: %ld %s\r\n", cseq->value, method); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_accept(char *dest, SIP_HDR_ACCEPT *accept) +{ + char type[32]; + char subType[32]; + char params[64]; + + if ((dest == NULL) || (accept == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_accept: dest or accept is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_accept_type_api_conv(type, &accept->type, SIP_API_TO_STR) < 0) + return -1; + + if (sip_accept_sub_type_api_conv(subType, &accept->subType, SIP_API_TO_STR) < 0) + return -1; + + if (sip_encode_params(params, &accept->params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Accept: %s/%s\r\n", type, subType); + } + else + { + sprintf((char *)sipEncBuf, "Accept: %s/%s;%s\r\n", type, subType, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_accept_encoding(char *dest, SIP_HDR_ACCEPT_ENCODING*accept_encoding) +{ + char encoding[32]; + char params[64]; + + if ((dest == NULL) || (accept_encoding == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_accept_encoding: dest or accept_encoding is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_accept_encoding_api_conv(encoding, &accept_encoding->acceptEncoding, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode accept encoding failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_params(params, &accept_encoding->params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Accept-Encoding: %s\r\n", encoding); + } + else + { + sprintf((char *)sipEncBuf, "Accept-Encoding: %s;%s\r\n", encoding, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_accept_language(char *dest, SIP_HDR_ACCEPT_LANGUAGE *accept_language) +{ + char language[32]; + char params[64]; + + if ((dest == NULL) || (accept_language == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_accept_language: dest or accept_language is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_accept_language_api_conv(language, &accept_language->acceptLanguage, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode accept language failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_params(params,&accept_language->params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Accept-Language: %s\r\n", language); + } + else + { + sprintf((char *)sipEncBuf, "Accept-Language: %s;%s\r\n", language, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_allow(char *dest, SIP_HDR_ALLOW *allow) +{ + int i; + char tmp[32]; + char buf[64] = ""; + + if ((dest == NULL) || (allow == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_allow: dest or allow is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + for (i = 0; i < allow->num; i++) + { + if (i > 0) + strcat(buf, ","); + + if (sip_allow_api_conv(tmp, &allow->allowMethod[i], SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "wrong allow method\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcat(buf, tmp); + } + + sprintf((char *)sipEncBuf, "Allow: %s\r\n", buf); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_subject(char *dest, SIP_HDR_SUBJECT *subject) +{ + if ((dest == NULL) || (subject == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_subject: dest or subject is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Subject: %s\r\n", subject->subject); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_server(char *dest, SIP_HDR_SERVER *server) +{ + if ((dest == NULL) || (server == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_server: dest or server is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Server: %s\r\n", server->server); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_user_agent(char *dest, SIP_HDR_USER_AGENT *userAgent) +{ + if ((dest == NULL) || (userAgent == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_user_agent: dest or userAgent is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "User-Agent: %s\r\n", userAgent->agent); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_supported(char *dest, SIP_HDR_SUPPORTED *supported) +{ + char option[64]; + + if ((dest == NULL) || (supported == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_supported: dest or supported is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_option_tag_api_conv(option, &supported->optionTag, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode supported option tag failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Supported: %s\r\n", option); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_mime_version(char *dest, SIP_HDR_MIME_VERSION *mimeVer) +{ + char version[16]; + + if ((dest == NULL) || (mimeVer == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_mime_version: dest or mimeVer is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_mime_version_api_conv(version, &mimeVer->mimeVersion, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode mime vesion failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Mime-Version: %s\r\n", version); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_date(char *dest, SIP_HDR_DATE *date) +{ + char wkDay[32]; + char month[32]; + char dateType[16]; + + if ((dest == NULL) || (date == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_date: dest or accept_encoding is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_date_weekday_api_conv(wkDay, &date->wkDay, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode date weekday failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_date_month_api_conv(month, &date->mon, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode date month failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_date_type_api_conv(dateType, &date->dateType, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode date type failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Date: %s, %02d %s %ld %02d:%02d:%02d %s\r\n", wkDay, date->mDay, month, date->year, date->hour, date->min, date->sec, dateType); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_expires(char *dest, SIP_HDR_EXPIRES *expires) +{ + if ((dest == NULL) || (expires == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_expires: dest or expires is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Expires: %ld\r\n", expires->value); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_time_stamp(char *dest, SIP_HDR_TIMESTAMP *stamp) +{ + if ((dest == NULL) || (stamp == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_time_stamp: dest or stamp is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf ((char *)sipEncBuf, "Timestamp: %ld\r\n", stamp->timeStamp); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_contacts(char *dest, SIP_HDR_CONTACTS *contacts) +{ + char url[64]; + char params[256]; + BYTE i, head; + SIP_HDR_CONTACT *contact; + + if ((dest == NULL) || (contacts == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_contacts: dest or contacts is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((contacts->num == 0) || (contacts->num > SIP_MAX_NUM_OF_CONTACTS)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_contacts: contacts num wrong\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + head = contacts->head; + + for (i = 0; i < contacts->num; i++, contact++) + { + contact = &contacts->contacts[head]; + + sip_encode_url(url, &contact->url, SIP_ENCODE_URL_ALL); + if (sip_encode_params(params, &contact->params, 0) < 0) + sprintf((char *)sipEncBuf, "Contact: %s\r\n", url); + else + sprintf((char *)sipEncBuf, "Contact: %s;%s\r\n", url, params); + + strcat(dest, (char *)sipEncBuf); + + if (++head >= contacts->num) + head = 0; + } + + return 0; +} + +int sip_encode_hdr_from(char *dest, SIP_HDR_FROM *from) +{ + char url[64]; + char params[256]; + + if ((dest == NULL) || (from == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_from: dest or from is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_encode_url(url, &from->url, SIP_ENCODE_URL_ALL); + if (sip_encode_params(params, &from->params, 0) < 0) + { + if (from->dispName[0] == '\0') + sprintf((char *)sipEncBuf, "From: %s\r\n", url); + else + sprintf((char *)sipEncBuf, "From: %s %s\r\n", from->dispName, url); + } + else + { + if (from->dispName[0] == '\0') + sprintf((char *)sipEncBuf, "From: %s;%s\r\n", url, params); + else + sprintf((char *)sipEncBuf, "From: %s %s;%s\r\n", from->dispName, url, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_proxy_require(char *dest, SIP_HDR_PROXY_REQUIRE *proxyRequire) +{ + char option[64]; + + if ((dest == NULL) || (proxyRequire == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_proxy_require: dest or proxyRequire is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_option_tag_api_conv(option, &proxyRequire->optionTag, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode proxy require option tag failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Proxy-Require: %s\r\n", option); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_to(char *dest, SIP_HDR_TO *to) +{ + char url[256]; + char params[256]; + + if ((dest == NULL) || (to == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_to: dest or to is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_encode_url(url, &to->url, SIP_ENCODE_URL_ALL); + + if (sip_encode_params(params, &to->params, 0) < 0) + { + if (to->dispName[0] == '\0') + sprintf((char *)sipEncBuf, "To: %s\r\n", url); + else + sprintf((char *)sipEncBuf, "To: %s %s\r\n", to->dispName, url); + } + else + { + if (to->dispName[0] == '\0') + sprintf((char *)sipEncBuf, "To: %s;%s\r\n", url, params); + else + sprintf((char *)sipEncBuf, "To: %s %s;%s\r\n", to->dispName, url, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_record_routes(char *dest, SIP_HDR_RECORD_ROUTES *recRoutes) +{ + BYTE i, head; + char url[64]; + SIP_HDR_RECORD_ROUTE *recRoute; + + if ((dest == NULL) || (recRoutes == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_record_routes: dest or recRoutes is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((recRoutes->num == 0) || (recRoutes->num > SIP_MAX_NUM_OF_RECORD_ROUTES)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_record_routes: record routes num wrong\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + head = recRoutes->head; + + for (i = 0; i < recRoutes->num; i++, recRoute++) + { + recRoute = &recRoutes->recRoutes[head]; + + sip_encode_url(url, &recRoute->url, SIP_ENCODE_URL_NO_USER_PART); + sprintf((char *)sipEncBuf, "Record-Route: %s\r\n", url); + + strcat(dest, (char *)sipEncBuf); + + if (++head >= recRoutes->num) + head = 0; + } + + return 0; +} + +int sip_encode_hdr_require(char *dest, SIP_HDR_REQUIRE *require) +{ + char option[64]; + + if ((dest == NULL) || (require == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_require: dest or require is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_option_tag_api_conv(option, &require->optionTag, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode require option tag failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Require: %s\r\n", option); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_routes(char *dest, SIP_HDR_ROUTES *routes) +{ + BYTE i, head; + char url[64]; + SIP_HDR_ROUTE *route; + + if ((dest == NULL) || (routes == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_routes: dest or routes is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((routes->num == 0) || (routes->num > SIP_MAX_NUM_OF_ROUTES)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_routes: routes num wrong\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + head = routes->head; + + for (i = 0; i < routes->num; i++) + { + route = &routes->routes[head]; + + sip_encode_url(url, &route->url, SIP_ENCODE_URL_ALL);//SIP_ENCODE_URL_NO_USER_PART + sprintf((char *)sipEncBuf, "Route: %s\r\n", url); + + strcat(dest, (char *)sipEncBuf); + + if (++head >= SIP_MAX_NUM_OF_ROUTES) + head = 0; + } + + return 0; +} + +int sip_encode_hdr_unsupported(char *dest, SIP_HDR_UNSUPPORTED *unsupported) +{ + char option[64]; + + if ((dest == NULL) || (unsupported == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_unsupported: dest or unsupported is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_option_tag_api_conv(option, &unsupported->optionTag, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode unsupported option tag failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Unsupported: %s\r\n", option); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_vias(char *dest, SIP_HDR_VIAS *vias) +{ + BYTE i, head, count = 0; + char ver[8], proto[8]; + char url[128],params[256]; + SIP_HDR_VIA *via; + + if ((dest == NULL) || (vias == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_vias: dest or vias is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((vias->num == 0) || (vias->num > SIP_MAX_NUM_OF_VIAS)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_vias: vias num wrong\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + head = vias->head; + + for (i = 0; i < SIP_MAX_NUM_OF_VIAS; i++, via++) + { + via = &vias->vias[head]; + + if (via->version == 0) + { + if (++head >= vias->num) + head = 0; + + if (++count >= vias->num) + break; + + continue; + } + + if (sip_ver_api_conv(ver, &via->version, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode via version failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_proto_api_conv(proto, &via->protocol, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode via protocal failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_encode_via_url(url, &via->url, SIP_ENCODE_URL_NO_USER_PART | SIP_ENCODE_URL_NO_BRACKETS); + + if (sip_encode_params(params, &via->params, 0) < 0) + sprintf((char *)sipEncBuf, "Via: %s/%s %s\r\n", ver, proto, url); + else + sprintf((char *)sipEncBuf, "Via: %s/%s %s;%s\r\n", ver, proto, url, params); + + strcat(dest, (char *)sipEncBuf); + + if (++head >= vias->num) + head = 0; + + if (++count >= vias->num) + break; + } + + return 0; +} + +int sip_encode_hdr_max_forwards(char *dest, SIP_HDR_MAX_FORWARDS *maxForwards) +{ + if ((dest == NULL) || (maxForwards == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_max_forwards: dest or maxForwards is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Max-Forwards: %d\r\n", maxForwards->value); + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_transport_encode_headers(char *dest, SIP_API_STRUCT *sipApiMsg) +{ + SIP_MSG *sipMsg; + + if ((dest == NULL) || (sipApiMsg == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: dest or sipApiMsg is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipMsg = &sipApiMsg->sipApiMsg.sipMsg; + + // General headers encoding + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_VIA_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip api without Via header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_vias(dest, &sipMsg->sipHdrVias) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Via header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_TO_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip api without To header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_to(dest, &sipMsg->sipHdrTo) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers:encode To header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_FROM_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip api without From header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_from(dest, &sipMsg->sipHdrFrom) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers:encode From header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_CALL_ID_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip api without Call-ID header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_call_id(dest, &sipMsg->sipHdrCallId) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers:encode Call-ID header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_CSEQ_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip api without Cseq header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_cseq(dest, &sipMsg->sipHdrCseq) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Cseq header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_CONTACT_MASK) == SIP_HDR_CONTACT_MASK) + { + if (sip_encode_hdr_contacts(dest, &sipMsg->sipHdrContacts) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Contact header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_ALLOW_MASK) == SIP_HDR_ALLOW_MASK) + { + if (sip_encode_hdr_allow(dest, &sipMsg->sipHdrAllow) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode allow header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_SUPPORTED_MASK) == SIP_HDR_SUPPORTED_MASK) + { + if (sip_encode_hdr_supported(dest, &sipMsg->sipHdrSupported) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Supported header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_ACCEPT_MASK) == SIP_HDR_ACCEPT_MASK) + { + if (sip_encode_hdr_accept(dest, &sipMsg->sipHdrAccept) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Accept header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_ACCEPT_ENCODING_MASK) == SIP_HDR_ACCEPT_ENCODING_MASK) + { + if (sip_encode_hdr_accept_encoding(dest, &sipMsg->sipHdrAcceptEncoding) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Accept-Encoding header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_ACCEPT_LANGUAGE_MASK) == SIP_HDR_ACCEPT_LANGUAGE_MASK) + { + if (sip_encode_hdr_accept_language(dest, &sipMsg->sipHdrAcceptLanguage) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode accept-language header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_TIMESTAMP_MASK) == SIP_HDR_TIMESTAMP_MASK) + { + if (sip_encode_hdr_time_stamp(dest, &sipMsg->sipHdrStamp) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Timestamp header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_MIME_VERSION_MASK) == SIP_HDR_MIME_VERSION_MASK) + { + if (sip_encode_hdr_mime_version(dest, &sipMsg->sipHdrMimeVer) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Mime-Version header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_DATE_MASK) == SIP_HDR_DATE_MASK) + { + if (sip_encode_hdr_date(dest, &sipMsg->sipHdrDate) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Date header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_EXPIRES_MASK) == SIP_HDR_EXPIRES_MASK) + { + if (sip_encode_hdr_expires(dest, &sipMsg->sipHdrExpires) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Expires header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_RECORD_ROUTE_MASK) == SIP_HDR_RECORD_ROUTE_MASK) + { + if (sip_encode_hdr_record_routes(dest, &sipMsg->sipHdrRecordRoutes) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Record-Route header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_USER_AGENT_MASK) == SIP_HDR_USER_AGENT_MASK) + { + if (sip_encode_hdr_user_agent(dest, &sipMsg->sipHdrUserAgent) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Agent header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if (sipApiMsg->sipApiType == SIP_API_RES_MSG) + { + // Response headers encoding + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_SERVER_MASK) == SIP_HDR_SERVER_MASK) + { + if (sip_encode_hdr_server(dest, &sipMsg->sipReStruct.sipReHdr.sipRspHdr.sipHdrServer) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Server header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_UNSUPPORTED_MASK) == SIP_HDR_UNSUPPORTED_MASK) + { + if (sip_encode_hdr_unsupported(dest, &sipMsg->sipReStruct.sipReHdr.sipRspHdr.sipHdrUnsupported) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Unsupported header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + } + else + { + // Request headers encoding + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_MAX_FORWARDS_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: sip request api without Max-Forwards header\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_hdr_max_forwards(dest, &sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Max-Forwards header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_ROUTE_MASK) == SIP_HDR_ROUTE_MASK) + { + if (sip_encode_hdr_routes(dest, &sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Route header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_REQUIRE_MASK) == SIP_HDR_REQUIRE_MASK) + { + if (sip_encode_hdr_require(dest, &sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRequire) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Require header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_PROXY_REQUIRE_MASK) == SIP_HDR_PROXY_REQUIRE_MASK) + { + if (sip_encode_hdr_proxy_require(dest, &sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrProxyRequire) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Proxy-Require header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipMsg->sipReStruct.sipReHdrFlag[0] & SIP_HDR_SUBJECT_MASK) == SIP_HDR_SUBJECT_MASK) + { + if (sip_encode_hdr_subject(dest, &sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrSubject) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_headers: encode Subject header failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + } + + return 0; +} + +int sip_encode_hdr_content_disposition(char *dest, SIP_CONTENT_DISPOSITION *sipBodyContentDisposition) +{ + char disposition[32]; + char params[64]; + + if ((dest == NULL) || (sipBodyContentDisposition == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_content_disposition: dest or sipBodyContentDisposition is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_content_disposition_api_conv(disposition, &sipBodyContentDisposition->contentDisposition, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode Content-Disposition failed\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_params(params, &sipBodyContentDisposition->params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Content-Disposition: %s\r\n", disposition); + } + else + { + sprintf((char *)sipEncBuf, "Content-Disposition: %s;%s\r\n", disposition, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_content_encoding(char *dest, BYTE *sipContentEncoding) +{ + char tmp[32]; + + if ((dest == NULL) || (sipContentEncoding == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_content_encoding: dest or sipContentEncoding is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_content_encoding_api_conv(tmp, sipContentEncoding, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode Content-Encoding failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf ((char *)sipEncBuf, "Content-Encoding: %s\r\n", tmp); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_hdr_content_language(char *dest, BYTE *sipContentLanguage) +{ + char tmp[32]; + + if ((dest == NULL) || (sipContentLanguage == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_hdr_content_language: dest or sipContentLanguage is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_content_language_api_conv(tmp, sipContentLanguage, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode Content-Language failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sprintf((char *)sipEncBuf, "Content-Language: %s\r\n", tmp); + + strcat (dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_sub_body_hdr_content_type(char *dest, SIP_CONTENT_TYPE *sipBodyContentType) +{ + char type[32]; + char subType[32]; + char params[64]; + + if ((dest == NULL) || (sipBodyContentType == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_sub_body_hdr_content_type: dest or sipBodyContentType is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_content_type_api_conv(type, &sipBodyContentType->type, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode sub Content-Type failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_content_sub_type_api_conv(subType, &sipBodyContentType->subType, SIP_API_TO_STR) < 0) + { + sprintf((char *)sipAsciTempBuf, "encode sub Content-Type subType failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (sip_encode_params(params, &sipBodyContentType->params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Content-Type: %s/%s\r\n", type, subType); + } + else + { + sprintf((char *)sipEncBuf, "Content-Type: %s/%s;%s\r\n", type, subType, params); + } + + strcat(dest, (char *)sipEncBuf); + + return 0; +} + +int sip_encode_sub_body(char *dest, SIP_MSG sipMsg, SIP_MESSAGE_BODYS sipBodys) +{ + int i; + char boundary[32]; + + if (dest == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_sub_body: dest is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + for (i = 0; i < sipMsg.sipEntity.sipHdrContentType.params.paraNum; i++) + { + if (sipMsg.sipEntity.sipHdrContentType.params.para[i].paraName== SIP_API_PNAME_BOUNDARY) + { + sprintf(boundary, "--%s", sipMsg.sipEntity.sipHdrContentType.params.para[i].para.paraStr); + break; + } + } + + if (i == sipMsg.sipEntity.sipHdrContentType.params.paraNum) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_sub_body:encode sub boundary failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + for (i = 0; i < sipBodys.sipBodyNum; i++) + { + if ((sipBodys.sipBody[i].sipBodyHdrFlg[0] & SIP_HDR_CONTENT_TYPE_MASK) == 0) + { + sprintf((char *)sipAsciTempBuf, "sip_encode_sub_body:no content type flag\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (((sipBodys.sipBody[i].sipBodyHdrFlg[0] & SIP_HDR_CONTENT_DISPOSITION_MASK) == 0) + && (sipBodys.sipBody[i].sipBodyContentType.subType == SIP_CONTENT_SUB_TYPE_ISUP)) + { + sprintf((char *)sipAsciTempBuf, "isup sub body without disposition\r\n"); + sip_log_err(sipAsciTempBuf); + return -2; + } + + strcat (dest, boundary); + + strcat (dest, "\r\n"); + + if ((sipBodys.sipBody[i].sipBodyHdrFlg[0] & SIP_HDR_CONTENT_DISPOSITION_MASK) == SIP_HDR_CONTENT_DISPOSITION_MASK) + { + sip_encode_hdr_content_disposition(dest, &sipBodys.sipBody[i].sipBodyContentDisposition); + } + + sip_encode_sub_body_hdr_content_type(dest, &sipBodys.sipBody[i].sipBodyContentType); + + strcat (dest, "\r\n"); + + strcat (dest, (char *)sipBodys.sipBody[i].msgBody); + + if (i < sipBodys.sipBodyNum -1) + strcat (dest, "\r\n\r\n"); + else + strcat(dest, "\r\n"); + } + + strcat (dest, boundary); + strcat (dest, "--\r\n"); + + return 0; +} + +int sip_encode_body(char *dest, SIP_MSG sipMsg, SIP_MESSAGE_BODYS sipBodys) +{ + char buffer[SIP_MAX_BODY_LEN] = ""; + + switch (sipMsg.sipEntity.sipHdrContentType.subType) + { + case SIP_CONTENT_SUB_TYPE_MIXED: + if (sip_encode_sub_body(buffer, sipMsg, sipBodys) < 0) + return -1; + + strcat(dest, buffer); + break; + + default : + strcat(dest, (char *)sipBodys.sipBody[0].msgBody); + break; + } + + return 0; + +} + +int sip_transport_encode_body(char *dest, SIP_API_STRUCT *sipApiMsg) +{ + char type[32]; + char subType[32]; + char params[64]; + + SIP_ENTITY *sipEntity; + + if ((dest ==NULL) || (sipApiMsg == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_transport_encode_body: dest or sipApiMsg is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipEntity = &sipApiMsg->sipApiMsg.sipMsg.sipEntity; + + if (sipEntity->sipHdrContentLength > 0) + { + if (sip_content_type_api_conv(type, &sipEntity->sipHdrContentType.type, SIP_API_TO_STR) < 0) + return -1; + if (sip_content_sub_type_api_conv(subType, &sipEntity->sipHdrContentType.subType, SIP_API_TO_STR) < 0) + return -1; + + if (sip_encode_params(params, &sipEntity->sipHdrContentType.params, 0) < 0) + { + sprintf((char *)sipEncBuf, "Content-Type: %s/%s\r\n", type, subType); + } + else + { + sprintf((char *)sipEncBuf, "Content-Type: %s/%s;%s\r\n", type, subType, params); + } + + strcat(dest, (char *)sipEncBuf); + + if ((sipEntity->sipEntityHdrFlag[0] & SIP_HDR_CONTENT_DISPOSITION_MASK) == SIP_HDR_CONTENT_DISPOSITION_MASK) + { + if (sip_encode_hdr_content_disposition(dest, &sipEntity->sipHdrContentDisposition) < 0) + { + sprintf((char *)sipAsciTempBuf, "wrong content disposition\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipEntity->sipEntityHdrFlag[0] & SIP_HDR_CONTENT_ENCODING_MASK) == SIP_HDR_CONTENT_ENCODING_MASK) + { + if (sip_encode_hdr_content_encoding(dest, &sipEntity->sipHdrContentEncoding) < 0) + { + sprintf((char *)sipAsciTempBuf, "wrong content encoding\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((sipEntity->sipEntityHdrFlag[0] & SIP_HDR_CONTENT_LANGUAGE_MASK) == SIP_HDR_CONTENT_LANGUAGE_MASK) + { + if (sip_encode_hdr_content_language(dest, &sipEntity->sipHdrContentLanguage) < 0) + { + sprintf((char *)sipAsciTempBuf, "wrong content language\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + sprintf((char *)sipEncBuf, "Content-Length: %d\r\n\r\n", sipEntity->sipHdrContentLength); + } + else + sprintf((char *)sipEncBuf, "Content-Length: %d\r\n\r\n", sipEntity->sipHdrContentLength); + + strcat(dest, (char *)sipEncBuf); + + if (sipEntity->sipHdrContentLength > 0) + { + sip_encode_body(dest, sipApiMsg->sipApiMsg.sipMsg, sipEntity->sipBodys); + } + + return 0; +} + +int sip_transport_set_addr(struct sockaddr_in *dstAddr, SIP_API_STRUCT *sipApiMsg) +{ + SIP_TRANSPORT_ADDR *sipTransAddr = &sipApiMsg->sipTransAddr; + + memset(dstAddr, 0, sizeof(struct sockaddr)); + dstAddr->sin_family = AF_INET; + dstAddr->sin_port = htons(sipTransAddr->port); + dstAddr->sin_addr.s_addr = sipTransAddr->addr.ipV4; + memset(&(dstAddr->sin_zero), 0, 8); + + return 0; +} + +int sip_transport_set_sd_addr(struct sockaddr_in *dstAddr, SIP_TRANSPORT_ADDR *sipTransAddr) +{ + memset(dstAddr, 0, sizeof(struct sockaddr)); + dstAddr->sin_family = AF_INET; + dstAddr->sin_port = htons(sipTransAddr->port); + dstAddr->sin_addr.s_addr = sipTransAddr->addr.ipV4; + memset(&(dstAddr->sin_zero), 0, 8); + + return 0; +} diff --git a/omc/plat/sip/src/sip_msg_parse.c b/omc/plat/sip/src/sip_msg_parse.c new file mode 100644 index 0000000..1c86373 --- /dev/null +++ b/omc/plat/sip/src/sip_msg_parse.c @@ -0,0 +1,4027 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "./include/sip_msg.h" +#include "./include/sip_debug.h" + +// Utility code start + +char *sip_strncpy(char *dest, const char *src, WORD length) +{ + if ((dest == NULL) || (src == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_strncpy: dest or src is NULL\n"); + sip_log_err(sipAsciTempBuf); + return NULL; + } + + strncpy(dest, src, length); + dest[length] = '\0'; + return dest; +} + +// remove SPACE before and after the content +int sip_clrspace(char *word) +{ + char *pbeg; + char *pend; + WORD len; + + if (word == NULL) + return -1; + if (*word == '\0') + return 0; + len = strlen (word); + + pbeg = word; + while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg)) + pbeg++; + + pend = word + len - 1; + while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend)) + { + pend--; + if (pend < pbeg) + { + *word = '\0'; + return 0; + } + } + + // Add terminating NULL only if we've cleared room for it + if (pend + 1 <= word + (len - 1)) + pend[1] = '\0'; + + if (pbeg != word) + memcpy(word, pbeg, pend - pbeg + 2); + + return 0; +} + +char *sip_clrncpy(char *dst, char *src, WORD len) +{ + char *pbeg; + char *pend; + char *p; + WORD spaceless_length; + + if ((dst == NULL) || (src == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_clrncpy: dst or src is NULL\n"); + sip_log_err(sipAsciTempBuf); + return NULL; + } + + // find the start of relevant text + pbeg = src; + while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg)) + pbeg++; + + // find the end of relevant text + pend = src + len - 1; + while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend)) + { + pend--; + if (pend < pbeg) + { + *dst = '\0'; + return dst; + } + } + + // if pend == pbeg there is only one char to copy + spaceless_length = pend - pbeg + 1; // excluding any '\0' + memcpy(dst, pbeg, spaceless_length); + p = dst + spaceless_length; + + // terminate the string and pad dest with zeros until len + do + { + *p = '\0'; + p++; + spaceless_length++; + } + while (spaceless_length < len); + + return dst; +} + +int sip_set_next_token(char *dest, char *buf, int endSeparator, char **next) +{ + char *sep; // separator + + if ((dest == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_set_next_token: dest or buf is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + *next = NULL; + + sep = buf; + while ((*sep != endSeparator) && (*sep != '\0') && (*sep != '\r') + && (*sep != '\n')) + sep++; + if ((*sep == '\r') || (*sep == '\n')) + { // we should continue normally only if this is the separator asked! + if (*sep != endSeparator) + return -1; + } + if (*sep == '\0') + return -1; // value must not end with this separator! + if (sep == buf) + return -1; // empty value (or several space!) + + sip_strncpy(dest, buf, sep - buf); + + *next = sep + 1; // return the position right after the separator + + return 0; +} + +void sip_util_replace_all_lws(char *msg) +{ + char *tmp; + + if (msg == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_util_replace_all_lws: msg is NULL\n"); + sip_log_err(sipAsciTempBuf); + return; + } + + tmp = msg; + + for (; tmp[0] != '\0'; tmp++) + { + if (('\0' == tmp[0]) || ('\0' == tmp[1]) || + ('\0' == tmp[2]) || ('\0' == tmp[3])) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ('\r' == tmp[2]) && ('\n' == tmp[3])) || + (('\r' == tmp[0]) && ('\r' == tmp[1])) || + (('\n' == tmp[0]) && ('\n' == tmp[1]))) + return; + + if ((('\r' == tmp[0]) && ('\n' == tmp[1]) && + ((' ' == tmp[2]) || ('\t' == tmp[2]))) || + (('\r' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1]))) || + (('\n' == tmp[0]) && + ((' ' == tmp[1]) || ('\t' == tmp[1])))) + { + // Replace line end and TAB symbols by SP + tmp[0] = ' '; + tmp[1] = ' '; + tmp = tmp + 2; + // Replace all following TAB symbols + for (; ('\t' == tmp[0] || ' ' == tmp[0]); ) + { + tmp[0] = ' '; + tmp++; + } + } + } +} + +// this method search for the separator and +// return it only if it is located before the +// second separator +char *sip_next_separator(char *ch, int separatorToFind, int beforeSeparator) +{ + char *ind; + char *tmp; + + if (ch == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_next_separator: ch is NULL\n"); + sip_log_err(sipAsciTempBuf); + return NULL; + } + + ind = strchr (ch, separatorToFind); + if (ind == NULL) + return NULL; + + tmp = NULL; + if (beforeSeparator != 0) + tmp = strchr(ch, beforeSeparator); + + if (tmp != NULL) + { + if (ind < tmp) + return ind; + } + else + return ind; + + return NULL; +} + +void sip_uri_unescape(char *string) +{ + int alloc = strlen (string) + 1; + unsigned char in; + int index = 0; + unsigned int hex; + char *ptr; + + if (string == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_unescape: string is NULL\n"); + sip_log_err(sipAsciTempBuf); + return; + } + + ptr = string; + while (--alloc > 0) + { + in = *ptr; + if ('%' == in) + { + // encoded part + if (sscanf (ptr + 1, "%02X", &hex) == 1) + { + in = (unsigned char) hex; + if (*(ptr + 2) && + ((*(ptr + 2) >= '0' && *(ptr + 2) <= '9') || + (*(ptr + 2) >= 'a' && *(ptr + 2) <= 'f') || + (*(ptr + 2) >= 'A' && *(ptr + 2) <= 'F'))) + { + alloc -= 2; + ptr += 2; + } + else + { + alloc -= 1; + ptr += 1; + } + } + } + string[index++] = in; + ptr++; + } + string[index] = 0; // terminate it +} + +// in quoted-string, many characters can be escaped... +// sip_quote_find returns the next quote that is not escaped +char *sip_quote_find(char *qstring) +{ + char *quote; + int i = 1; + + if (qstring == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_quote_find: qstring is NULL\n"); + sip_log_err(sipAsciTempBuf); + return NULL; + } + + quote = strchr(qstring, '"'); + if (quote == qstring) // the first char matches and is not escaped... + return quote; + + if (quote == NULL) + return NULL; // no quote at all... + + /* this is now the nasty cases where '"' is escaped + '" jonathan ros \\\""' + | | + '" jonathan ros \\"' + | | + '" jonathan ros \""' + | | + we must count the number of preceeding '\' */ + + for (;;) + { + if (0 == strncmp(quote - i, "\\", 1)) + i++; + else + { + if (i % 2 == 1) // the '"' was not escaped + return quote; + + // else continue with the next '"' + quote = strchr (quote + 1, '"'); + if (quote == NULL) + return NULL; + i = 1; + } + if (quote - i == qstring - 1) + // example: "\"john" + // example: "\\"jack" + { + // special case where the string start with '\' + if (*qstring == '\\') + i++; // an escape char was not counted + if (i % 2 == 0) // the '"' was not escaped + return quote; + else + { // else continue with the next '"' + qstring = quote + 1; // reset qstring because + // (*quote+1) may be also == to '\\' + quote = strchr(quote + 1, '"'); + if (quote == NULL) + return NULL; + i = 1; + } + } + } + + return NULL; +} + +int sip_uri_param_set(SIP_GEN_PARA *urlParam, char *pname, char *pvalue) +{ + BYTE flag = 0; + + if ((urlParam == NULL) || (pname == NULL) || (pvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_param_set: urlParm pname or pvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrspace(pname); + sip_clrspace(pvalue); + + if (strcmp(pname, SIP_PNAME_TAG) == 0) + { + urlParam->paraName = SIP_API_PNAME_TAG; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_BRANCH) == 0) + { + urlParam->paraName = SIP_API_PNAME_BRANCH; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_EXPIRES) == 0) + { + urlParam->paraName = SIP_API_PNAME_EXPIRES; + urlParam->paraType = flag = SIP_API_PTYPE_VALUE; + urlParam->para.paraVal[0] = atol(pvalue); + } + else if (strcasecmp(pname, SIP_PNAME_USER) == 0) + { + urlParam->paraName = SIP_API_PNAME_USER; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_LR) == 0) + { + urlParam->paraName = SIP_API_PNAME_LR; + urlParam->paraType = flag = SIP_API_PTYPE_TAG; + } + else if (strcmp(pname, SIP_PNAME_BOUNDARY) == 0) + { + urlParam->paraName = SIP_API_PNAME_BOUNDARY; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_HANDLING) == 0) + { + urlParam->paraName = SIP_API_PNAME_HANDLING; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_TRANSPORT) == 0) + { + urlParam->paraName = SIP_API_PNAME_TRANSPORT; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_RPORT) == 0) + { + urlParam->paraName = SIP_API_PNAME_RPOTR; + urlParam->paraType = flag = SIP_API_PTYPE_VALUE; + if (pvalue[0] == '\0') + urlParam->para.paraVal[0] = 0xFFFFFFFF; + else + urlParam->para.paraVal[0] = atol(pvalue); + } + else if (strcmp(pname, SIP_PNAME_VERSION) == 0) + { + urlParam->paraName = SIP_API_PNAME_VERSION; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + else if (strcmp(pname, SIP_PNAME_BASE) == 0) + { + urlParam->paraName = SIP_API_PNAME_BASE; + urlParam->paraType = flag = SIP_API_PTYPE_STRING; + } + + if (flag) + { + if (flag == SIP_API_PTYPE_STRING) + strcpy(urlParam->para.paraStr, pvalue); + return 0; + } + + return -1; +} + +int sip_uri_param_add(SIP_GEN_PARAMS *urlParams, char *pname, char *pvalue) +{ + SIP_GEN_PARA *urlParam; + + if ((urlParams == NULL) || (pname == NULL) || (pvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_param_add: urlParms pname or pvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (urlParams->paraNum > SIP_MAX_PARA_NUM) + return -1; + + urlParam = &urlParams->para[urlParams->paraNum]; + + if (sip_uri_param_set(urlParam, pname, pvalue) < 0) + return -1; + + urlParams->paraNum++; + + return 0; +} + +int sip_uri_parse_params(SIP_URI *sipUri, char *params) +{ + char pname[64]; + char pvalue[128]; + + char *comma; + char *equal; + + if ((sipUri == NULL) || (params == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_parse_params: sipUri or params is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + // find '=' which is the separator for one param + // find ';' which is the separator for multiple params + + equal = sip_next_separator(params + 1, '=', ';'); + comma = strchr(params + 1, ';'); + + while (comma != NULL) + { + if (equal == NULL) + { + equal = comma; + pvalue[0] = '\0'; + } + else + { + if ((comma - equal < 2) || (comma - equal > 128)) + { + sprintf((char *)sipAsciTempBuf, "uri param value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_strncpy(pvalue, equal + 1, comma - equal - 1); + sip_uri_unescape(pvalue); + } + + if ((equal - params < 2) || (equal - params > 64)) + { + sprintf((char *)sipAsciTempBuf, "uri param name length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_strncpy(pname, params + 1, equal - params - 1); + sip_uri_unescape(pname); + + sip_uri_uparam_add(sipUri, pname, pvalue); + + params = comma; + equal = sip_next_separator(params + 1, '=', ';'); + comma = strchr(params + 1, ';'); + } + + // this is the last header (comma==NULL) + comma = params + strlen (params); + + if (equal == NULL) + { + equal = comma; /* at the end */ + pvalue[0] = '\0'; + } + else + { + if ((comma - equal < 2) || (comma - equal > 128)) + { + sprintf((char *)sipAsciTempBuf, "uri last param value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_strncpy(pvalue, equal + 1, comma - equal - 1); + } + + if ((equal - params < 2) || (equal - params > 64)) + { + sprintf((char *)sipAsciTempBuf, "uri last param name length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_strncpy(pname, params + 1, equal - params - 1); + + sip_uri_uparam_add(sipUri, pname, pvalue); + + return 0; +} + +int sip_generic_param_parseall(SIP_GEN_PARAMS *genParams, char *params) +{ + char pname[32]; + char pvalue[64]; + char *comma; + char *equal; + char *tmp; + + if ((genParams == NULL) || (params == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_generic_param_parseall: genParams or params is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + // find '=' which is the separator for one param + // find ';' which is the separator for multiple params + + equal = sip_next_separator(params + 1, '=', ';'); + comma = strchr(params + 1, ';'); + + while (comma != NULL) + { + if (equal == NULL) + { + equal = comma; + pvalue[0] = '\0'; + } + else + { + // check for NULL param with an '=' character + tmp = equal + 1; + + for (; *tmp == '\t' || *tmp == ' '; tmp++) + { + } + + pvalue[0] = '\0'; + + if ((*tmp != ',') && (*tmp != '\0')) + { + if ((comma - equal < 2) || (comma - equal > 64))//comma - equal >128 + { + sprintf((char *)sipAsciTempBuf, "param value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(pvalue, equal + 1, comma - equal - 1); + } + } + + if ((equal - params < 2) || (equal - params > 32)) + { + sprintf((char *)sipAsciTempBuf, "param name length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(pname, params + 1, equal - params - 1); + + sip_generic_param_add(genParams, pname, pvalue); + + params = comma; + + equal = sip_next_separator(params + 1, '=', ';'); + comma = strchr(params + 1, ';'); + } + + // this is the last header (comma==NULL) + comma = params + strlen (params); + + if (equal == NULL) + { + equal = comma; /* at the end */ + pvalue[0] = '\0'; + } + else + { + // check for NULL param with an '=' character + tmp = equal + 1; + + for (; *tmp == '\t' || *tmp == ' '; tmp++) + { + } + + pvalue[0] = '\0'; + + if (*tmp != ',' && *tmp != '\0') + { + if ((comma - equal < 2) || (comma - equal > 64))//comma - equal >128 + { + sprintf((char *)sipAsciTempBuf, "last param value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(pvalue, equal + 1, comma - equal - 1); + } + } + + if ((equal - params < 2) || (equal - params > 32)) + { + sprintf((char *)sipAsciTempBuf, "last param name length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(pname, params + 1, equal - params - 1); + + sip_generic_param_add(genParams, pname, pvalue); + + return 0; +} + +// Parse code start + +int sip_uri_parse(SIP_URI *sipUri, char *buf) +{ + char *userName; + char *password; + char *host; + char *port; + char *params; + char *headers; + char *tmp; + char temp[128]; + BYTE len; + + // basic tests + if ((sipUri == NULL) || (buf == NULL) || (buf[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_uri_parse: sipUri or buf is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + tmp = strchr(buf, ':'); + if (tmp == NULL) + return -1; + + len = tmp - buf; + + if ((len < 2) || (len > 128)) + { + sprintf((char *)sipAsciTempBuf, "uri type length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(temp, buf, len); + if (sip_uri_type_api_conv(temp, &sipUri->uriType, SIP_STR_TO_API) < 0) + return -1; + + /* law number 1: + if ('?' exists && is_located_after '@') + or if ('?' exists && '@' is not there -no userName-) + =====> HEADER_PARAM EXIST + =====> start at index(?) + =====> end at the end of url + */ + + // find the beginning of host + userName = strchr(tmp, ':');//userName = strchr(buf, ':'); + // if ':' does not exist, the url is not valid + if (userName == NULL) + return -1; + + host = strchr(tmp, '@');//host = strchr(buf, '@'); + + if (host == NULL) + host = userName; + else if (userName[1] == '@') // userName is empty + host = userName + 1; + else + { // userName exists + password = sip_next_separator(userName + 1, ':', '@'); + + if (password == NULL) + password = host; + else + { // password exists + if ((host - password < 2) || (host - password > 16)) + { + sprintf((char *)sipAsciTempBuf, "password length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(sipUri->password, password + 1, host - password - 1); + sip_uri_unescape(sipUri->password); + } + + if ((password - userName < 2) || (password - userName > 64))//password - userName > 128 + { + sprintf((char *)sipAsciTempBuf, "uri userName length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(sipUri->userName, userName + 1, password - userName - 1); + sip_uri_unescape(sipUri->userName); + } + + // search for header after host + headers = strchr (host, '?'); + + if (headers == NULL) + headers = buf + strlen(buf); + else + { + // headers exist + // sip_uri_parse_headers(url, headers); + } + + // search for params after host + params = strchr(host, ';'); /* search for params after host */ + if (params == NULL) + params = headers; + else + { /* params exist */ + if ((headers - params + 1 < 2) || (headers - params + 1 > 128)) + { + sprintf((char *)sipAsciTempBuf, "uri params length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(temp, params, headers - params); + sip_uri_parse_params(sipUri, temp); + } + + port = params - 1; + while (port > host && *port != ']' && *port != ':') + port--; + if (*port == ':') + { + if (host == port) + port = params; + else + { + if ((params - port < 2) || (params - port > 8)) + { + sprintf((char *)sipAsciTempBuf, "port length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; // error cases + } + sip_clrncpy(temp, port + 1, params - port - 1); + sipUri->port = strtoul(temp, NULL, 10); + } + } + else + port = params; + + // adjust port for ipv6 address + tmp = port; + while (tmp > host && *tmp != ']') + tmp--; + if (*tmp == ']') + { + port = tmp; + while (host < port && *host != '[') + host++; + if (host >= port) + return -1; + } + + if ((port - host < 2) || (port - host > 128))//port - host > 256 + { + sprintf((char *)sipAsciTempBuf, "uri domain length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(sipUri->host.addr.domain, host + 1, port - host - 1); + + return 0; +} + +int sip_from_parse(SIP_HDR_FROM *from, char *hvalue) +{ + char *dispName; + char *url; + char *urlEnd; + char *genParams; + char *first; + char *second; + char *host; + char tmp[256]; + WORD len; + + if ((from == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_from_parse: from or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + /* How to parse: + we'll place the pointers: + dispName => beginning of displayname + url => beginning of url + url_end => end of url + gen_params => beginning of params + + examples: + + jack ;tag=34erZ + ^ ^ ^ ^ + + sip:jack@atosc.org;tag=34erZ + ^ ^^ + */ + + dispName = strchr(hvalue, '"'); + + url = strchr (hvalue, '<'); + if (url != NULL) + { + urlEnd = strchr (url, '>'); + if (urlEnd == NULL) + return -1; + } + + /* SIPit day2: this case was not supported + first '"' is placed after '<' and after '>' + ;description="OPEN";expires=28800 + if the fisrt quote is after '<' then + this is not a quote for a dispName. + */ + + if (dispName != NULL) + { + if (dispName > url) + dispName = NULL; + } + + if ((dispName == NULL) && (url != NULL)) + {// dispName IS A '*token' (not a quoted-string) + if (hvalue != url) // dispName exists + { + len = url - hvalue; + + if ((len + 1 < 2) || len > 64) + { + sprintf((char *)sipAsciTempBuf, "uri dispName length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(from->dispName, hvalue, len); + } + + url++; // place pointer on the beginning of url + } + else + { + if ((dispName != NULL) && (url != NULL)) + { // dispName IS A quoted-string (not a '*token') + // search for quotes + first = sip_quote_find (hvalue); + second = sip_quote_find (first + 1); + + if (second == NULL) + return -1; // if there is only 1 quote: failure + + if ((first > url)) + return -1; + + len = second - first + 1; + + if ((len + 1) >= 2) + { + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "dispName length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(from->dispName, first, len); + } + // else dispName is empty? + url = strchr (second + 1, '<'); + + if (url == NULL) + return -1; // '<' MUST exist + + url++; + } + else + url = hvalue; // field does not contains '<' and '>' + } + + // DISPLAY-NAME SET + // START of URL KNOWN + + urlEnd = strchr(url, '>'); + + if (urlEnd == NULL) // sip:jack@atosc.org;tag=023 + { // We are sure ';' is the delimiter for from-parameters + host = strchr(url, '@'); + + if (host != NULL) + genParams = strchr(host, ';'); + else + genParams = strchr(url, ';'); + + if (genParams != NULL) + urlEnd = genParams - 1; + else + urlEnd = url + strlen(url); + } + else // jack ;tag=azer + { + genParams = strchr(urlEnd, ';'); + urlEnd--; // place pointer on the beginning of url + } + + if (genParams != NULL) // now we are sure a param exist + { + if (sip_generic_param_parseall(&from->params, genParams) == -1) + return -1; + } + + // set the url + len = urlEnd - url + 1; + + if ((len + 1 < 7) || len > 256) + { + sprintf((char *)sipAsciTempBuf, "uri length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, url, len); + + if (sip_uri_parse(&from->url, tmp) < 0) + return -1; + + return 0; +} + +int sip_contact_parse(SIP_HDR_CONTACT *contact, char *hvalue) +{ + return sip_from_parse((SIP_HDR_FROM *)contact, hvalue); +} + +int sip_via_parse(SIP_HDR_VIA *via, char *hvalue) +{ + char *version; + char *protocol; + char *host; + char *port; + char *viaParams; + char tmp[128]; + char *comment; + char *ipv6host; + + if ((via == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_via_parse: via or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + version = strchr(hvalue, '/'); + if (version == NULL) + return -1; + + protocol = strchr(version + 1, '/'); + if (protocol == NULL) + return -1; + + // set the version + if ((protocol - version < 2) || (protocol - version > 128)) + { + sprintf((char *)sipAsciTempBuf, "via version length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, version - 3, protocol - version + 3); + + if (sip_ver_api_conv(tmp, &via->version, SIP_STR_TO_API) < 0) + return -1; + + // Here: we avoid matching an additionnal space + host = strchr(protocol + 1, ' '); + + if (host == NULL) + return -1; + if (host == protocol + 1) + { // there are extra SPACE characters + while (0 == strncmp(host, " ", 1)) + { + host++; + + if (strlen(host) == 1) + return -1; // via is malformed + } + // here, we match the real space located after the protocol name + host = strchr(host + 1, ' '); + + if (host == NULL) + return -1; + } + + // set the protocol + if ((host - protocol < 2) || (host - protocol > 128)) + { + sprintf((char *)sipAsciTempBuf, "via protocol length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, protocol + 1, host - protocol - 1); + + if (sip_proto_api_conv(tmp, &via->protocol, SIP_STR_TO_API) < 0) + return -1; + + // comments in Via are not allowed any more in the latest draft (09) + comment = strchr(host, '('); + + if (comment != NULL) + { + /* + char *end_comment; + + end_comment = strchr (host, ')'); + if (end_comment == NULL) + return -1; // if '(' exist ')' MUST exist + if (end_comment - comment < 2) + return -1; + via->comment = (char *) osip_malloc (end_comment - comment); + if (via->comment == NULL) + return -1; + sip_strncpy (via->comment, comment + 1, end_comment - comment - 1); + comment--; + */ + return -1; + } + else + comment = host + strlen(host); + + viaParams = strchr(host, ';'); + + if ((viaParams != NULL) && (viaParams < comment)) + { + if (comment - viaParams + 1 < 2) + return -1; + sip_strncpy(tmp, viaParams, comment - viaParams); + sip_generic_param_parseall(&via->params, tmp); + } + + if (viaParams == NULL) + viaParams = comment; + + // add ipv6 support (0.8.4) + // Via: SIP/2.0/UDP [mlke::zeezf:ezfz:zef:zefzf]:port;.... + ipv6host = strchr(host, '['); + if (ipv6host != NULL && ipv6host < viaParams) + { + /* + port = strchr (ipv6host, ']'); + if (port == NULL || port > via_params) + return -1; + + if (port - ipv6host < 2) + return -1; + via->host = (char *) osip_malloc (port - ipv6host); + if (via->host == NULL) + return -1; + sip_clrncpy (via->host, ipv6host + 1, port - ipv6host - 1); + + port = strchr (port, ':'); + */ + return -1; + } + else + { + port = strchr(host, ':'); + ipv6host = NULL; + } + + if ((port != NULL) && (port < viaParams)) + { + if ((viaParams - port < 2) || (viaParams - port > 128)) + { + sprintf((char *)sipAsciTempBuf, "via port length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, port + 1, viaParams - port - 1); + via->url.port = atol(tmp); + } + else + port = viaParams; + + // host is already set in the case of ipv6 + if (ipv6host != NULL) + return 0; + + if ((port - host < 2) || (port - host > 64)) + { + sprintf((char *)sipAsciTempBuf, "via domain length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(via->url.domain, host + 1, port - host - 1); + + return 0; +} + +int sip_to_parse(SIP_HDR_TO *to, char *hvalue) +{ + return sip_from_parse((SIP_HDR_FROM *)to, hvalue); +} + +int sip_proxy_require_parse(SIP_HDR_PROXY_REQUIRE *proxyRequire, char *hvalue) +{ + int len; + char tmp[64]; + + if (proxyRequire == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_via_parse: proxyRequire or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "proxy require value is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_option_tag_api_conv(tmp, &proxyRequire->optionTag, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_record_route_parse(SIP_HDR_RECORD_ROUTE *recRoute, char *hvalue) +{ + return sip_from_parse((SIP_HDR_FROM *)recRoute, hvalue); +} + +int sip_require_parse(SIP_HDR_REQUIRE *require, char *hvalue) +{ + int len; + char tmp[64]; + + if (require == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_require_parse: require or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "require value is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_option_tag_api_conv(tmp, &require->optionTag, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_route_parse(SIP_HDR_ROUTE *route, char *hvalue) +{ + return sip_from_parse((SIP_HDR_FROM *)route, hvalue); +} + +int sip_call_id_parse(SIP_HDR_CALL_ID *callId, char *hvalue) +{ + char *host; + char *end; + WORD len; + + if ((callId == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_call_id_parse: callId or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcpy(callId->value, ""); + strcpy(callId->host, ""); + + host = strchr(hvalue, '@'); /* SEARCH FOR '@' */ + end = hvalue + strlen (hvalue); + + if (host == NULL) + host = end; + else + { + len = end - host - 1; + + if ((len + 2 < 2) || (len > 256)) + { + sprintf((char *)sipAsciTempBuf, "callId host length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(callId->host, host + 1, len); + } + + len = host - hvalue; + + if ((len + 1 < 2) || (len > 128)) + { + sprintf((char *)sipAsciTempBuf, "callId value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(callId->value, hvalue, len); + + return 0; /* ok */ +} + +int sip_cseq_parse(SIP_HDR_CSEQ *cseq, char *hvalue) +{ + char *method = NULL; + char *end = NULL; + BYTE tmp[128], len; + + if ((cseq == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_cseq_parse: cseq or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + cseq->value = 0; + cseq->method = 0; + + method = strchr(hvalue, ' '); /* SEARCH FOR SPACE */ + end = hvalue + strlen (hvalue); + + if (method == NULL) + return -1; + + len = method - hvalue; + if ((len + 1 < 2) || (len > 128)) + { + sprintf((char *)sipAsciTempBuf, "cseq value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy((char *)tmp, hvalue, len); + cseq->value = atol((char *)tmp); + + len = end - method; + + if ((len + 1 < 2) || (len > 128)) + { + sprintf((char *)sipAsciTempBuf, "cseq method length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy((char *)tmp, method + 1, len); + + if (sip_method_api_conv((char *)tmp, &cseq->method, SIP_STR_TO_API) < 0) + return -1; + + return 0; /* ok */ +} + +int sip_expires_parse(SIP_HDR_EXPIRES *expires, char *hvalue) +{ + if ((expires == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_expires_parse: expires or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + expires->value = atol(hvalue); + + return 0; +} + +int sip_mime_version_parse(SIP_HDR_MIME_VERSION *mimiVer, char *hvalue) +{ + int len; + BYTE *mimeVersion; + char tmp[64]; + + if ((mimiVer == NULL) || (hvalue == NULL || hvalue[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_mime_version_parse: mimiVer or value is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "mime version value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + mimeVersion = &mimiVer ->mimeVersion; + + sip_clrncpy(tmp, hvalue, len); + + if (sip_mime_version_api_conv(tmp, mimeVersion, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_time_stamp_parse(SIP_HDR_TIMESTAMP *hdrTimeStamp, char *hvalue) +{ + if (hdrTimeStamp == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_time_stamp_parse: hdrTimeStamp is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + hdrTimeStamp->timeStamp = atoll(hvalue); + + return 0; +} + +int sip_max_forwards_parse(SIP_HDR_MAX_FORWARDS *maxForwards, char *hvalue) +{ + if ((maxForwards == NULL) || (hvalue == NULL) || (hvalue[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_max_forwards_parse: maxForwards or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + maxForwards->value = atol(hvalue); + + return 0; +} + +int sip_user_agent_parse(SIP_HDR_USER_AGENT *userAgent, char *hvalue) +{ + if (userAgent == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_user_agent_parse: userAgent is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + strcpy ((char *)userAgent->agent, hvalue); + + return 0; +} + +int sip_server_parse( SIP_HDR_SERVER *server, char *hvalue) +{ + if (server == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_server_parse: server is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + strcpy ((char *)server->server, hvalue); + + return 0; +} + +int sip_subject_parse(SIP_HDR_SUBJECT *subject, char *hvalue) +{ + if (subject == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_subject_parse: subject is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + strcpy ((char *)subject->subject, hvalue); + + return 0; +} + +int sip_supported_parse(SIP_HDR_SUPPORTED *supported, char *hvalue) +{ + int len; + char tmp[64]; + + if (supported == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_supported_parse: supported is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "supported value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_option_tag_api_conv(tmp, &supported->optionTag, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_unsupported_parse(SIP_HDR_UNSUPPORTED *unsupported, char *hvalue) +{ + int len; + char tmp[64]; + + if (unsupported == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_unsupported_parse: unsupported is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "unsupported value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_option_tag_api_conv(tmp, &unsupported->optionTag, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_content_type_parse(SIP_CONTENT_TYPE *contentType, char *hvalue) +{ + char *subType; + char *sipContentTypeParams; + char tmp[64]; + + if (contentType == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_content_type_parse: contentType is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + /* How to parse: + + we'll place the pointers: + subType => beginning of subtype + sipContentTypeParams => beginning of params + + examples: + + application/multipart ; boundary= + ^ ^ + */ + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + subType = strchr(hvalue, '/'); + sipContentTypeParams = strchr(hvalue, ';'); + + if (subType == NULL) + return -1; + + if (sipContentTypeParams != NULL) + { + if (sip_generic_param_parseall(&contentType->params, sipContentTypeParams) == -1) + return -1; + } + else + sipContentTypeParams = subType + strlen(subType); + + if ((subType - hvalue + 1 < 2) || (subType - hvalue > 64)) + { + sprintf((char *)sipAsciTempBuf, "content type value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, subType - hvalue); + + if (sip_content_type_api_conv(tmp, &contentType->type, SIP_STR_TO_API) < 0) + return -1; + + if ((sipContentTypeParams - subType < 2) || (sipContentTypeParams - subType > 64)) + { + sprintf((char *)sipAsciTempBuf, "content type params length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, subType + 1, sipContentTypeParams - subType - 1); + + if (sip_content_sub_type_api_conv(tmp, &contentType->subType, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_content_disposition_parse(SIP_CONTENT_DISPOSITION *contentDisposition, char *hvalue) +{ + char *sipContentDispositionParams; + char tmp[64]; + + if (contentDisposition == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_content_disposition_parse: contentDisposition is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hvalue == NULL || hvalue[0] == '\0') + return 0; + + sipContentDispositionParams = strchr(hvalue, ';'); + + if (sipContentDispositionParams != NULL) + { + if (sip_generic_param_parseall(&contentDisposition->params, sipContentDispositionParams) == -1) + return -1; + } + else + sipContentDispositionParams = hvalue + strlen(hvalue); + + if ((sipContentDispositionParams - hvalue < 2) || (sipContentDispositionParams - hvalue > 64)) + { + sprintf((char *)sipAsciTempBuf, "content disposition value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, sipContentDispositionParams - hvalue); + + if (sip_content_disposition_api_conv(tmp, &contentDisposition->contentDisposition, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_content_language_parse(BYTE *contentLanguage, char *hvalue) +{ + int len; + char tmp[64]; + + if (contentLanguage == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_content_language_parse: contentLanguage is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "content language value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_content_language_api_conv(tmp, contentLanguage, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_content_encoding_parse(BYTE *contentEncoding, char *hvalue) +{ + int len; + char tmp[64]; + + if (contentEncoding == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_content_encoding_parse: contentEncoding is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + len = strlen(hvalue); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "content encoding value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, len); + + if (sip_content_encoding_api_conv(tmp, contentEncoding, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_content_length_parse(SIP_ENTITY *sipEntity, char *hvalue) +{ + if (sipEntity == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_content_length_parse: sipEntity is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + sipEntity->sipHdrContentLength = atol(hvalue); + + return 0; +} + +int sip_accept_parse(SIP_HDR_ACCEPT *accept, char *hvalue) +{ + char *subType; + char *sipAccepttTypeParams; + char tmp[64]; + + if (accept == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_parse: accept is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + subType = strchr(hvalue, '/'); + sipAccepttTypeParams = strchr(hvalue, ';'); + + if (subType == NULL) + return -1; + + if (sipAccepttTypeParams != NULL) + { + if (sip_generic_param_parseall(&accept->params, sipAccepttTypeParams) == -1) + return -1; + } + else + sipAccepttTypeParams = subType + strlen(subType); + + if ((subType - hvalue + 1 < 2) || (subType - hvalue > 64)) + { + sprintf((char *)sipAsciTempBuf, "accept type length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, subType - hvalue); + + if (sip_accept_type_api_conv(tmp, &accept->type, SIP_STR_TO_API) < 0) + return -1; + + if ((sipAccepttTypeParams - subType < 2) || (sipAccepttTypeParams - subType > 64)) + { + sprintf((char *)sipAsciTempBuf, "accept sub type length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, subType + 1, sipAccepttTypeParams - subType - 1); + + if (sip_accept_sub_type_api_conv(tmp, &accept->subType, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_accept_encoding_parse(SIP_HDR_ACCEPT_ENCODING *encoding, char *hvalue) +{ + char *sipAcceptEncodingParams; + char tmp[64]; + + if (encoding == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_encoding_parse: encoding is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + sipAcceptEncodingParams = strchr(hvalue, ';'); + + if (sipAcceptEncodingParams != NULL) + { + if (sip_generic_param_parseall(&encoding->params, sipAcceptEncodingParams) == -1) + return -1; + } + else + sipAcceptEncodingParams = hvalue + strlen(hvalue); + + if ((sipAcceptEncodingParams - hvalue < 2) || (sipAcceptEncodingParams - hvalue > 64)) + { + sprintf((char *)sipAsciTempBuf, "accept encoding length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, sipAcceptEncodingParams - hvalue); + + if (sip_accept_encoding_api_conv(tmp, &encoding->acceptEncoding, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_accept_language_parse(SIP_HDR_ACCEPT_LANGUAGE *language, char *hvalue) +{ + char *sipAcceptLanguageParams; + char tmp[64]; + + if (language == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_accept_language_parse: language is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + sipAcceptLanguageParams = strchr(hvalue, ';'); + + if (sipAcceptLanguageParams != NULL) + { + if (sip_generic_param_parseall(&language->params, sipAcceptLanguageParams) == -1) + return -1; + } + else + sipAcceptLanguageParams = hvalue + strlen(hvalue); + + if ((sipAcceptLanguageParams - hvalue < 2) || (sipAcceptLanguageParams - hvalue > 64)) + { + sprintf((char *)sipAsciTempBuf, "accept language value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, sipAcceptLanguageParams - hvalue); + + if (sip_accept_language_api_conv(tmp, &language->acceptLanguage, SIP_STR_TO_API) < 0) + return -1; + + return 0; +} + +int sip_allow_parse(SIP_HDR_ALLOW *allow, char *hvalue) +{ + char *comma; + char *buf = hvalue; + char tmp[64]; + int ret; + + if (allow == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_allow_parse: allow is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + allow->num = 0; + + for (;;) + { + comma = strchr(buf, ','); + + if (comma == NULL) + { + comma = buf + strlen(buf); + break; + } + + if ((comma - buf < 2) || (comma - buf > 64)) + { + sprintf((char *)sipAsciTempBuf, "allow method length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, comma - buf); + + if ((ret = sip_allow_api_conv(tmp, &allow->allowMethod[allow->num], SIP_STR_TO_API)) == -1) + return -1; + + if (ret == 0) + allow->num = allow->num + 1; + + buf = comma + 1; + } + + if ((comma - buf < 2) || (comma - buf > 64)) + { + sprintf((char *)sipAsciTempBuf, "allow last method length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, comma - buf); + + if ((ret = sip_allow_api_conv(tmp, &allow->allowMethod[allow->num], SIP_STR_TO_API)) == -1) + return -1; + + if (ret == 0) + allow->num = allow->num + 1; + + return 0; +} + +int sip_date_time_parse(SIP_HDR_DATE *date, char *time) +{ + int i; + int len; + char *buf; + char *colon; + char tmp[64]; + + if (date == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_date_time_parse: date is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((time == NULL) || (time[0] == '\0')) + return 0; + + buf = time; + + for (i = 0; i < 2; i++) + { + if (((colon = strchr(buf, ':')) == NULL) || (colon < buf)) + { + sprintf((char *)sipAsciTempBuf, "Malformed date time\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (colon - buf > 64) + { + sprintf((char *)sipAsciTempBuf, "date time length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, colon - buf); + + switch (i) + { + case 0: + date->hour = atoi(tmp); + break; + case 1: + date->min = atoi(tmp); + break; + default: + return -1; + } + + buf = colon + 1; + } + + len = strlen(buf); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "date time second length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, len); + + date->sec = atoi(tmp); + + return 0; +} + +int sip_date_parse(SIP_HDR_DATE *date, char *hvalue) +{ + int i; + int len; + char *comma; + char *sp; + char *nextSp; + char tmp[64]; + + if (date == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_date_time_parse: date is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + if (((comma = strchr(hvalue, ',')) == NULL) || (comma <= hvalue)) + return -1; + + if (comma - hvalue > 64) + { + sprintf((char *)sipAsciTempBuf, "date weekday length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, hvalue, comma - hvalue); + + sip_date_weekday_api_conv(tmp, &date->wkDay, SIP_STR_TO_API); + + if (comma[1] == ' ') + sp = comma + 2; + else + sp = comma + 1; + + for (i = 0; i < 4; i++) + { + if (((nextSp = strchr(sp, ' ')) == NULL) || (nextSp < sp)) + { + sprintf((char *)sipAsciTempBuf, "Malformed sip date\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (nextSp - sp > 64) + { + sprintf((char *)sipAsciTempBuf, "date length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, sp, nextSp - sp); + + switch (i) + { + case 0: + date->mDay = atoi(tmp); + break; + case 1: + if (sip_date_month_api_conv(tmp, &date->mon, SIP_STR_TO_API) < 0) + { + return -1; + } + break; + case 2: + date->year = atol(tmp); + break; + case 3: + sip_date_time_parse(date, tmp); + break; + default: + return -1; + } + + sp = nextSp + 1; + } + + len = strlen(sp); + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "date type length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, sp, len); + + if (sip_date_type_api_conv(tmp, &date->dateType, SIP_STR_TO_API) < 0) + { + return -1; + } + + return 0; +} + +int sip_refer_to_parse(SIP_HDR_REFER_TO *referTo, char *hvalue) +{ + return sip_from_parse((SIP_HDR_FROM *)referTo, hvalue); +} + +int sip_envet_parse(SIP_HDR_EVENT *event, char *hvalue) +{ + if ((event == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_envet_parse: event or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcpy(event->event, hvalue); + + return 0; +} + +int sip_subscription_state_parse(SIP_HDR_SUBSCRIPTION_STATE *subscriptionState, char *hvalue) +{ + if ((subscriptionState == NULL) || (hvalue == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_subscription_state_parse: subscriptionState or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strcpy(subscriptionState->subscriptionState, hvalue); + + return 0; +} + +int sip_message_set_accept(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_ACCEPT *accept; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_accept: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + { +// sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ACCEPT_EMPTY_MASK; + return 0; + } + + accept = &sip->sipApiMsg.sipMsg.sipHdrAccept; + + if (sip_accept_parse(accept, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip accept parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ACCEPT_MASK; + + return 0; +} + +int sip_message_set_accept_encoding(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_ACCEPT_ENCODING *encoding; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_accept_encoding: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + encoding = &sip->sipApiMsg.sipMsg.sipHdrAcceptEncoding; + + if (sip_accept_encoding_parse(encoding, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip accept encoding parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ACCEPT_ENCODING_MASK; + + return 0; +} + +int sip_message_set_accept_language(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_ACCEPT_LANGUAGE *language; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_accept_language: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + language = &sip->sipApiMsg.sipMsg.sipHdrAcceptLanguage; + + if (sip_accept_language_parse(language, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip accept language failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ACCEPT_LANGUAGE_MASK; + + return 0; +} + +int sip_message_set_alert_info(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_allow(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_ALLOW *allow; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_allow: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + allow = &sip->sipApiMsg.sipMsg.sipHdrAllow; + + if (sip_allow_parse(allow, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip allow parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_ALLOW_MASK; + + return 0; +} + +int sip_message_set_authentication_info(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_authorization(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_content_type(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_CONTENT_TYPE *contentType; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_content_type: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + contentType = &sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentType; + + if (sip_content_type_parse(contentType, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip content type parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipEntity.sipEntityHdrFlag[0] |= SIP_HDR_CONTENT_TYPE_MASK; + + return 0; +} + +int sip_message_set_content_disposition(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_CONTENT_DISPOSITION *contentDisposition; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_content_disposition: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + contentDisposition= &sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentDisposition; + + if (sip_content_disposition_parse(contentDisposition, hvalue) < 0) + { + sprintf((char *)sipEncBuf, "sip content disposition parse failed\r\n"); + sip_log_err(sipEncBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipEntity.sipEntityHdrFlag[0] |= SIP_HDR_CONTENT_DISPOSITION_MASK; + + return 0; +} + +int sip_message_set_content_encoding(SIP_API_STRUCT *sip, char *hvalue) +{ + BYTE *contentEncoding; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_content_encoding: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + contentEncoding = &sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentEncoding; + + if (sip_content_encoding_parse(contentEncoding, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip content encoding parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipEntity.sipEntityHdrFlag[0] |= SIP_HDR_CONTENT_ENCODING_MASK; + + return 0; +} + +int sip_message_set_content_language(SIP_API_STRUCT *sip, char *hvalue) +{ + BYTE *contentLanguage; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_content_language: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + contentLanguage = &sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentLanguage; + + if (sip_content_language_parse(contentLanguage, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip content language parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipEntity.sipEntityHdrFlag[0] |= SIP_HDR_CONTENT_LANGUAGE_MASK; + + return 0; +} + +int sip_message_set_content_length(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_ENTITY *sipEntity; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_content_length: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + sipEntity = &sip->sipApiMsg.sipMsg.sipEntity; + + if (sip_content_length_parse(sipEntity, hvalue) < 0) + return -1; + + sip->sipApiMsg.sipMsg.sipEntity.sipEntityHdrFlag[0] |= SIP_HDR_CONTENT_LENGTH_MASK; + + return 0; +} + +int sip_message_set_call_id(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_CALL_ID *hdrCallId; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_call_id: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrCallId = &sip->sipApiMsg.sipMsg.sipHdrCallId; + + if (sip_call_id_parse(hdrCallId, hvalue) < 0) + { + strcpy(hdrCallId->value, ""); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_CALL_ID_MASK; + + return 0; +} + +int sip_message_set_cseq(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_CSEQ *hdrCseq; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_cseq: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrCseq = &sip->sipApiMsg.sipMsg.sipHdrCseq; + + if (sip_cseq_parse(hdrCseq, hvalue) < 0) + { + hdrCseq->value = 0; + hdrCseq->method = 0; + sprintf((char *)sipAsciTempBuf, "sip cseq parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_CSEQ_MASK; + + return 0; +} + +int sip_message_set_date(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_DATE *date; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_date: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + date = &sip->sipApiMsg.sipMsg.sipHdrDate; + + if (sip_date_parse(date, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip date parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_DATE_MASK; + + return 0; +} + +int sip_message_set_expires(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_EXPIRES *expires; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_expires: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + expires = &sip->sipApiMsg.sipMsg.sipHdrExpires; + + if (sip_expires_parse(expires, hvalue) < 0) + return -1; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_EXPIRES_MASK; + + return 0; +} + +int sip_message_set_call_info(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_error_info(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_event(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_EVENT *event; + + if ((sip == NULL) || (hvalue == NULL) || (hvalue[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_event: sip or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + event = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrEvent; + + if (sip_envet_parse(event, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip event parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_EVENT_MASK; + + return 0; +} + +int sip_message_set_from(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_FROM *hdrFrom; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_from: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrFrom = &sip->sipApiMsg.sipMsg.sipHdrFrom; + + if (sip_from_parse(hdrFrom, hvalue) < 0) + return -1; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_FROM_MASK; + + return 0; +} + +int sip_message_set_contact(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_CONTACTS *contacts; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_contact: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + contacts = &sip->sipApiMsg.sipMsg.sipHdrContacts; + + if (contacts->num >= SIP_MAX_NUM_OF_CONTACTS) + return -1; + + if (sip_contact_parse(&contacts->contacts[contacts->num], hvalue) < 0) + return -1; + + contacts->head = 0; + contacts->num++; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_CONTACT_MASK; + + return 0; +} + +int sip_message_set_mime_version(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_MIME_VERSION *mimeVer; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_mime_version: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + mimeVer = &sip->sipApiMsg.sipMsg.sipHdrMimeVer; + + if (sip_mime_version_parse(mimeVer, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip mime version parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_MIME_VERSION_MASK; + + return 0; +} + +int sip_message_set_proxy_authenticate(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_proxy_authentication_info(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_proxy_authorization(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_proxy_require(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_PROXY_REQUIRE *proxyRequire; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_proxy_require: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + proxyRequire = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrProxyRequire; + + if (sip_proxy_require_parse(proxyRequire, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip proxy require parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |=SIP_HDR_PROXY_REQUIRE_MASK; + + return 0; +} + +int sip_message_set_record_route(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_RECORD_ROUTES *recRoutes; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_record_route: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + recRoutes = &sip->sipApiMsg.sipMsg.sipHdrRecordRoutes; + + if (recRoutes->num >= SIP_MAX_NUM_OF_RECORD_ROUTES) + return -1; + + if (sip_record_route_parse(&recRoutes->recRoutes[recRoutes->num + 1], hvalue) < 0) + return -1; + + if (recRoutes->num == 0) + recRoutes->head = 1; + + recRoutes->num++; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_RECORD_ROUTE_MASK; + + return 0; +} + +int sip_message_set_refer_to(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_REFER_TO *referTo; + + if ((sip == NULL) || (hvalue == NULL) || (hvalue[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_refer_to: sip or hvalue is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + referTo = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrReferTo; + + if (sip_refer_to_parse(referTo, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip refer-to parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_REFER_TO_MASK; + + return 0; +} + +int sip_message_set_require(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_REQUIRE *require; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_require: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + require = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrRequire; + + if (sip_require_parse(require, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip require parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_REQUIRE_MASK; + + return 0; +} + +int sip_message_set_route(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_ROUTES *routes; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_route: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + routes = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes; + + if (routes->num >= SIP_MAX_NUM_OF_RECORD_ROUTES) + return -1; + + if (sip_route_parse(&routes->routes[routes->num + 1], hvalue) < 0) + return -1; + + if (routes->num == 0) + routes->head = 1; + + routes->num++; + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_ROUTE_MASK; + + return 0; +} + +int sip_message_set_server(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_SERVER *server; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_server: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + server = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipRspHdr.sipHdrServer; + + if (sip_server_parse(server, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip server parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_SERVER_MASK; + + return 0; +} + +int sip_message_set_subject(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_SUBJECT *subject; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_subject: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + subject = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrSubject; + + if (sip_subject_parse(subject, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip subject parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_SUBJECT_MASK; + + return 0; +} + +int sip_message_set_subscription_state(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_SUBSCRIPTION_STATE *subscriptionState; + + if ((sip == NULL) || (hvalue == NULL) || (hvalue[0] == '\0')) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_subscription_state: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + subscriptionState = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrSubscriptionState; + + if (sip_subscription_state_parse(subscriptionState, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip subscription state parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_SUBSCRIPTION_STATE_MASK; + + return 0; +} + +int sip_message_set_supported(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_SUPPORTED *supported; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_supported: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + supported = &sip->sipApiMsg.sipMsg.sipHdrSupported; + + if (sip_supported_parse(supported, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip supported parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_SUPPORTED_MASK; + + return 0; +} + +int sip_message_set_to(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_TO *hdrTo; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_to: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrTo = &sip->sipApiMsg.sipMsg.sipHdrTo; + + if (sip_to_parse(hdrTo, hvalue) < 0) + return -1; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_TO_MASK; + + return 0; +} + +int sip_message_set_time_stamp(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_TIMESTAMP *hdrTimeStamp; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_time_stamp: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrTimeStamp = &sip->sipApiMsg.sipMsg.sipHdrStamp; + + if (sip_time_stamp_parse(hdrTimeStamp, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip time stamp parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_TIMESTAMP_MASK; + + return 0; +} + +int sip_message_set_unsupported(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_UNSUPPORTED *unsupported; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_unsupported: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + unsupported = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipRspHdr.sipHdrUnsupported; + + if (sip_unsupported_parse(unsupported, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip unsupported parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_UNSUPPORTED_MASK; + + return 0; +} + +int sip_message_set_user_agent(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_USER_AGENT *userAgent; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_user_agent: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + userAgent = &sip->sipApiMsg.sipMsg.sipHdrUserAgent; + + if (sip_user_agent_parse(userAgent, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip user agent parse failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_USER_AGENT_MASK; + + return 0; +} + +int sip_message_set_via(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_VIAS *vias; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_via: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + vias = &sip->sipApiMsg.sipMsg.sipHdrVias; + + if (vias->num >= SIP_MAX_NUM_OF_VIAS) + return -1; + + if (sip_via_parse(&vias->vias[vias->num + 1], hvalue) < 0) + return -1; + + if (vias->num == 0) + vias->head = 1; + + vias->num++; + + sip->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_VIA_MASK; + + return 0; +} + +int sip_message_set_www_authenticate(SIP_API_STRUCT *sip, char *hvalue) +{ + return 0; +} + +int sip_message_set_max_forwards(SIP_API_STRUCT *sip, char *hvalue) +{ + SIP_HDR_MAX_FORWARDS *hdrMaxForwards; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_max_forwards: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((hvalue == NULL) || (hvalue[0] == '\0')) + return 0; + + hdrMaxForwards = &sip->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards; + + if (sip_max_forwards_parse(hdrMaxForwards, hvalue) < 0) + return -1; + + sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + + return 0; +} + +void sip_tolower(char *str) +{ + int i; + int len; + + if (str == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_tolower: str is NULL\n"); + sip_log_err(sipAsciTempBuf); + return; + } + + len = strlen(str); + + for (i = 0; i <= len - 1; i++) + { + if ('A' <= str[i] && str[i] <= 'Z') + str[i] = str[i] + 32; + } +} + +int sip_find_next_crlf(char *startOfHeader, char **endOfHeader) +{ + char *soh = startOfHeader; + + *endOfHeader = NULL; + + while (('\r' != *soh) && ('\n' != *soh)) + { + if (*soh) + soh++; + else + { + sprintf((char *)sipAsciTempBuf, "Final CRLF is missing\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + // case 1: CRLF is the separator + // case 2 or 3: CR or LF is the separator + if (('\r' == soh[0]) && ('\n' == soh[1])) + soh = soh + 1; + + // VERIFY if TMP is the end of header or LWS. + // LWS are extra SP, HT, CR and LF contained in headers. + if ((' ' == soh[1]) || ('\t' == soh[1])) + { + // incoming message that potentially + // contains LWS must be processed with + // sip_util_replace_all_lws(char *) + sprintf((char *)sipAsciTempBuf, "Message that contains LWS must be processed with sip_util_replace_all_lws(char *tmp) before being parsed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + *endOfHeader = soh + 1; + + return 0; +} + +// For better performance +// Calculates a hash value for the given string +DWORD sip_hash(char *str) +{ + DWORD hash = 5373;//5381 + int c; + + if (str == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_hash: str is NULL\n"); + sip_log_err(sipAsciTempBuf); + } + + while ((c = *str++) != '\0') + hash = (hash << 4) + hash + c;//5 + + return hash; +} + +// This method must be called before using the parser +int sip_parser_init(void) +{ + int i = 0; + int count = 0; + DWORD hash; + + sipParseConfig[i].hname = SIP_HNAME_ACCEPT; + sipParseConfig[i++].setheader = (&sip_message_set_accept); + sipParseConfig[i].hname = SIP_HNAME_ACCEPT_ENCODING; + sipParseConfig[i++].setheader = (&sip_message_set_accept_encoding); + sipParseConfig[i].hname = SIP_HNAME_ACCEPT_LANGUAGE; + sipParseConfig[i++].setheader = (&sip_message_set_accept_language); + sipParseConfig[i].hname = SIP_HNAME_ALERT_INFO; + sipParseConfig[i++].setheader = (&sip_message_set_alert_info); + sipParseConfig[i].hname = SIP_HNAME_ALLOW; + sipParseConfig[i++].setheader = (&sip_message_set_allow); +/* sipParseConfig[i].hname = SIP_HNAME_AUTHENTICATION_INFO; + sipParseConfig[i++].setheader = (&sip_message_set_authentication_info); + sipParseConfig[i].hname = SIP_HNAME_AUTHORIZATION; + sipParseConfig[i++].setheader = (&sip_message_set_authorization);*/ + sipParseConfig[i].hname = SIP_HNAME_CONTENT_TYPE_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_content_type); + sipParseConfig[i].hname = SIP_HNAME_CALL_ID; + sipParseConfig[i++].setheader = (&sip_message_set_call_id); + sipParseConfig[i].hname = SIP_HNAME_CALL_INFO; + sipParseConfig[i++].setheader = (&sip_message_set_call_info); + sipParseConfig[i].hname = SIP_HNAME_CONTACT; + sipParseConfig[i++].setheader = (&sip_message_set_contact); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_ENCODING; + sipParseConfig[i++].setheader = (&sip_message_set_content_encoding); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_LENGTH; + sipParseConfig[i++].setheader = (&sip_message_set_content_length); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_TYPE; + sipParseConfig[i++].setheader = (&sip_message_set_content_type); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_DISPOSITION; + sipParseConfig[i++].setheader =(&sip_message_set_content_disposition); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_LANGUAGE; + sipParseConfig[i++].setheader =(&sip_message_set_content_language); + sipParseConfig[i].hname = SIP_HNAME_CSEQ; + sipParseConfig[i++].setheader = (&sip_message_set_cseq); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_ENCODING_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_content_encoding); + sipParseConfig[i].hname = SIP_HNAME_SIPDATE; + sipParseConfig[i++].setheader = (&sip_message_set_date); + sipParseConfig[i].hname = SIP_HNAME_EXPIRES; + sipParseConfig[i++].setheader = (&sip_message_set_expires); + sipParseConfig[i].hname = SIP_HNAME_ERROR_INFO; + sipParseConfig[i++].setheader = (&sip_message_set_error_info); + sipParseConfig[i].hname = SIP_HNAME_EVENT; + sipParseConfig[i++].setheader = (&sip_message_set_event); + sipParseConfig[i].hname = SIP_HNAME_FROM_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_from); + sipParseConfig[i].hname = SIP_HNAME_FROM; + sipParseConfig[i++].setheader = (&sip_message_set_from); + sipParseConfig[i].hname = SIP_HNAME_CALL_ID_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_call_id); + sipParseConfig[i].hname = SIP_HNAME_CONTENT_LENGTH_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_content_length); + sipParseConfig[i].hname = SIP_HNAME_CONTACT_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_contact); + sipParseConfig[i].hname = SIP_HNAME_MIME_VERSION; + sipParseConfig[i++].setheader = (&sip_message_set_mime_version); + sipParseConfig[i].hname = SIP_HNAME_PROXY_AUTHENTICATE; + sipParseConfig[i++].setheader = (&sip_message_set_proxy_authenticate); +/* sipParseConfig[i].hname = SIP_HNAME_PROXY_AUTHENTICATION_INFO; + sipParseConfig[i++].setheader = (&sip_message_set_proxy_authentication_info); + sipParseConfig[i].hname = SIP_HNAME_PROXY_AUTHORIZATION; + sipParseConfig[i++].setheader = (&sip_message_set_proxy_authorization);*/ + sipParseConfig[i].hname = SIP_HNAME_PROXY_REQUIRE; + sipParseConfig[i++].setheader = (&sip_message_set_proxy_require); + sipParseConfig[i].hname = SIP_HNAME_RECORD_ROUTE; + sipParseConfig[i++].setheader = (&sip_message_set_record_route); + sipParseConfig[i].hname = SIP_HNAME_REQUIRE; + sipParseConfig[i++].setheader = (&sip_message_set_require); + sipParseConfig[i].hname = SIP_HNAME_ROUTE; + sipParseConfig[i++].setheader = (&sip_message_set_route); + sipParseConfig[i].hname = SIP_HNAME_REFER_TO_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_refer_to); + sipParseConfig[i].hname = SIP_HNAME_REFER_TO; + sipParseConfig[i++].setheader = (&sip_message_set_refer_to); + sipParseConfig[i].hname = SIP_HNAME_SERVER; + sipParseConfig[i++].setheader = (&sip_message_set_server); + sipParseConfig[i].hname = SIP_HNAME_SUBJECT; + sipParseConfig[i++].setheader = (&sip_message_set_subject); + sipParseConfig[i].hname = SIP_HNAME_SUBJECT_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_subject); + sipParseConfig[i].hname = SIP_HNAME_SUPPORTED_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_supported); + sipParseConfig[i].hname = SIP_HNAME_SUPPORTED; + sipParseConfig[i++].setheader = (&sip_message_set_supported); + sipParseConfig[i].hname = SIP_HNAME_TO_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_to); + sipParseConfig[i].hname = SIP_HNAME_TO; + sipParseConfig[i++].setheader = (&sip_message_set_to); + sipParseConfig[i].hname = SIP_HNAME_TIMESTAMP; + sipParseConfig[i++].setheader = (&sip_message_set_time_stamp); + sipParseConfig[i].hname = SIP_HNAME_USER_AGENT; + sipParseConfig[i++].setheader = (&sip_message_set_user_agent); + sipParseConfig[i].hname = SIP_HNAME_UNSUPPORTED; + sipParseConfig[i++].setheader = (&sip_message_set_unsupported); + sipParseConfig[i].hname = SIP_HNAME_SUBSCRIPTION_STATE; + sipParseConfig[i++].setheader = (&sip_message_set_subscription_state); + sipParseConfig[i].hname = SIP_HNAME_VIA_SHORT; + sipParseConfig[i++].setheader = (&sip_message_set_via); + sipParseConfig[i].hname = SIP_HNAME_VIA; + sipParseConfig[i++].setheader = (&sip_message_set_via); + sipParseConfig[i].hname = SIP_HNAME_WWW_AUTHENTICATE; + sipParseConfig[i++].setheader = (&sip_message_set_www_authenticate); + sipParseConfig[i].hname = SIP_HNAME_MAX_FORWARDS; + sipParseConfig[i++].setheader = (&sip_message_set_max_forwards); + + // build up hash table for fast header lookup + + // initialize the table + for (i = 0; i < SIP_HASH_TABLE_SIZE; i++) + { + sipHdrRefTable[i] = -1; // no entry + } + + for (i = 0; i < SIP_MAX_NUM_OF_HEADERS; i++) + { + // Calculate hash value using lower case + hash = sip_hash(sipParseConfig[i].hname); + hash = hash%SIP_HASH_TABLE_SIZE; + + while(sipHdrRefTable[hash] != -1) + { + hash = (hash+1)%SIP_HASH_TABLE_SIZE; + if (++count >= SIP_HASH_TABLE_SIZE) + { + printf("Conflict with current hash table size\r\n"); + return -1; + } + } + + sipHdrRefTable[hash] = i; + + } + + return 0; +} + +// improved look-up mechanism +// precondition: hname is all lowercase +int sip_message_is_known_header (char *hname) +{ + unsigned int hash; + int index; + int count = 0; + + hash = sip_hash(hname); + hash = hash % SIP_HASH_TABLE_SIZE; + index = sipHdrRefTable[hash]; + + while ((index == -1) || (strcmp(sipParseConfig[index].hname, hname) != 0)) + { + hash = (hash+1) % SIP_HASH_TABLE_SIZE; + index = sipHdrRefTable[hash]; + if (++count >= SIP_HASH_TABLE_SIZE) + return -1; + } + + return index; +} + +// This method calls the method that is able to parse the header +int sip_message_call_method(int i, SIP_API_STRUCT *sip, char *hvalue) +{ + return sipParseConfig[i].setheader(sip, hvalue); +} + +int sip_message_set_header(SIP_API_STRUCT *sip, char *hname, char *hvalue) +{ + int index; + + if (sip == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_message_set_header: sip is NULL\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (hname == NULL) + return -1; + + // some headers are analysed completely + // this method is used for selective parsing + index = sip_message_is_known_header(hname); + if (index >= 0) + { + if (sip_message_call_method(index, sip, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "Could not set header: \"%s\" %s\r\n", hname, hvalue); + sip_log_err(sipAsciTempBuf); + return -1; + } + return 0; + } + + // Doesn't support unknown header parsing for the moment + + return 0; +} + +int sip_message_set_multiple_header(SIP_API_STRUCT *sip, char *hname, char *hvalue) +{ + char *ptr; // current location of the search + char *comma; // This is the separator we are elooking for + //char *beg; // beg of a header + //char *end; // end of a header + //char *quote1; // first quote of a pair of quotes + //char *quote2; // second quuote of a pair of quotes + size_t hname_len; + + // Find header based upon lowercase comparison + sip_tolower(hname); + + if (hvalue == NULL) + { + if (sip_message_set_header(sip, hname, hvalue) < 0) + return -1; + + return 0; + } + + ptr = hvalue; + comma = strchr(ptr, ','); + + hname_len = strlen(hname); + + if (comma == NULL + || (hname_len == 4 && strncmp (hname, "date", 4) == 0) + || (hname_len == 5 && strncmp (hname, "allow", 5) == 0) + || (hname_len == 2 && strncmp (hname, "to", 2) == 0) + || (hname_len == 4 && strncmp (hname, "from", 4) == 0) + || (hname_len == 3 && strncmp (hname, "via", 3) == 0) + || (hname_len == 7 && strncmp (hname, "call-id", 7) == 0) + || (hname_len == 4 && strncmp (hname, "cseq", 4) == 0) + || (hname_len == 7 && strncmp (hname, "subject", 7) == 0) + || (hname_len == 7 && strncmp (hname, "expires", 7) == 0) + || (hname_len == 7 && strncmp (hname, "contact", 7) == 0) + || (hname_len == 6 && strncmp (hname, "server", 6) == 0) + || (hname_len == 9 && strncmp (hname, "supported", 9) == 0) + || (hname_len == 6 && strncmp (hname, "accept", 6) == 0) + || (hname_len == 11 && strncmp (hname, "unsupported", 11) == 0) + || (hname_len == 15 && strncmp (hname, "accept-language", 15) == 0) + || (hname_len == 15 && strncmp (hname, "accept-encoding", 15) == 0) + || (hname_len == 10 && strncmp (hname, "user-agent", 10) == 0) + || (hname_len == 16 && strncmp (hname, "www-authenticate", 16) == 0) + || (hname_len == 19 && strncmp (hname, "authentication-info", 19) == 0) + || (hname_len == 18 && strncmp (hname, "proxy-authenticate", 18) == 0) + || (hname_len == 19 && strncmp (hname, "proxy-authorization", 19) == 0) + || (hname_len == 25 && strncmp (hname, "proxy-authentication-info", 25) == 0) + || (hname_len == 12 && strncmp (hname, "organization", 12) == 0) + || (hname_len == 13 && strncmp (hname, "authorization", 13) == 0) + || (hname_len == 12 && strncmp (hname, "max-forwards", 12) == 0) + || (hname_len == 12 && strncmp (hname, "content-type", 12) == 0) + || (hname_len == 14 && strncmp (hname, "content-length", 14) == 0)) + // there is no multiple header! likely + // to happen most of the time... + // or hname is a TEXT-UTF8-TRIM and may + // contain a comma. this is not a separator + // THIS DOES NOT WORK FOR UNKNOWN HEADER!!!! + { + if ((sip->sipApiType == SIP_API_REQ_MSG) + && ((hname_len == 11 && strncmp (hname, "unsupported", 11) == 0) + || (hname_len == 6 && strncmp (hname, "server", 6) == 0))) + { + sprintf((char *)sipAsciTempBuf, "sip request msg have res header\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + else if ((sip->sipApiType == SIP_API_RES_MSG) + && (((hname_len == 12) && (strncmp (hname, "max-forwards", 12) == 0)) + || ((hname_len == 13) && (strncmp (hname, "proxy-require", 13) == 0)) + || ((hname_len == 5) && (strncmp (hname, "route", 5) == 0)) + || ((hname_len == 7) && (strncmp (hname, "require", 7) == 0)) +// || ((hname_len == 10) && (strncmp (hname, "user-agent", 10) == 0)) + || ((hname_len == 7) && (strncmp (hname, "subject", 7) == 0)) + || ((hname_len == 5) && (strncmp (hname, "event", 5) == 0)) + || ((hname_len == 8) && (strncmp (hname, "refer-to", 8) == 0)) + || ((hname_len == 18) && (strncmp (hname, "subscription-state", 18) == 0)))) + { + sprintf((char *)sipAsciTempBuf, "sip response msg have req header\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + + if ((strncmp (hname, "refer-to", 8) == 0) && ((sip->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] & SIP_HDR_REFER_TO_MASK) == SIP_HDR_REFER_TO_MASK)) + { + //sip_send_400(); + return -1; + } + + if (sip_message_set_header(sip, hname, hvalue) < 0) + return -1; + + return 0; + } + + // Doesn't support multiple headers per line for the moment + return 0; +} + +int sip_msg_headers_parse(SIP_API_STRUCT *sip, char *buf, char **body) +{ + char *colonIndex; + char hname[64]; + char hvalue[256]; + char *startOfHeader; + char *endOfHeader; + char *end; + WORD len; + + if ((sip == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_msg_headers_parse: sip or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startOfHeader = buf; + + for (;;) + { + if (startOfHeader[0] == '\0') + { + sprintf((char *)sipAsciTempBuf, "SIP message does not end with CRLFCRLF\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + + if (sip_find_next_crlf(startOfHeader, &endOfHeader) < 0) + { + sprintf((char *)sipAsciTempBuf, "End of header Not found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + // the list of headers MUST always end with + // CRLFCRLF (also CRCR and LFLF are allowed) + if ((startOfHeader[0] == '\r') || (startOfHeader[0] == '\n')) + { + *body = startOfHeader; + return 0; + } + + // find the header name + colonIndex = strchr(startOfHeader, ':'); + if (colonIndex == NULL) + { + sprintf((char *)sipAsciTempBuf, "colon Not found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + if (colonIndex - startOfHeader + 1 < 2) + return -1; + if (endOfHeader <= colonIndex) + { + sprintf((char *)sipAsciTempBuf, "Malformed message\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((len = colonIndex - startOfHeader) > 64) + { + sprintf((char *)sipAsciTempBuf, "header name length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(hname, startOfHeader, len); + + // END of header is (end_of_header-2) if header separation is CRLF + // END of header is (end_of_header-1) if header separation is CR or LF + if ((endOfHeader[-2] == '\r') || (endOfHeader[-2] == '\n')) + end = endOfHeader - 2; + else + end = endOfHeader - 1; + if ((end - colonIndex) < 2) + strcpy(hvalue, ""); // some headers (subject) can be empty + else + { + if ((len = end - colonIndex - 1) > 256) + { + sprintf((char *)sipAsciTempBuf, "header value length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(hvalue, colonIndex + 1, len); + } + + // hvalue MAY contains multiple value. In this case, they + // are separated by commas. But, a comma may be part of a + // quoted-string ("here, and there" is an example where the + // comma is not a separator!) + if (sip_message_set_multiple_header(sip, hname, hvalue) < 0) + { + sprintf((char *)sipAsciTempBuf, "End of header Not found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + // continue on the next header + startOfHeader = endOfHeader; + } + + return -1; +} + +int sip_msg_start_line_parse_req(SIP_MSG *dest, char *buf, char **nextHeader) +{ + char *p1, *p2, *hp; + char tmp[256]; + SIP_START_LINE *startLine; + WORD len; + + if ((dest == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_msg_start_line_parse_req: dest or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startLine = &dest->sipStartLine; + *nextHeader = buf; + + // The first token is the method name + p2 = strchr(buf, ' '); + if (p2 == NULL) + return -1; + if (*(p2 + 1) == '\0' || *(p2 + 2) == '\0') + return -1; + if (p2 - buf == 0) + { + sprintf((char *)sipAsciTempBuf, "No space is allowed here\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((len = p2 - buf) > 256) + { + sprintf((char *)sipAsciTempBuf, "request method length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, len); + if (sip_method_api_conv(tmp, &startLine->sipMethod, SIP_STR_TO_API) < 0) + return -2; + + // The second token is a sip-url or a uri + p1 = strchr(p2 + 2, ' '); // no space allowed inside sip-url + if (p1 == NULL) + { + sprintf((char *)sipAsciTempBuf, "Uncompliant request-uri\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (p1 - p2 < 2) + return -1; + + if ((len = p1 - p2 - 1) > 256) + { + sprintf((char *)sipAsciTempBuf, "request uri length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, p2 + 1, len); + if (sip_uri_parse(&startLine->requestUri, tmp) < 0) + return -1; + + // find the the version and the beginning of headers + hp = p1; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + sprintf((char *)sipAsciTempBuf, "No crlf found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if (hp - p1 < 2) + return -1; + + if ((len = hp - p1 - 1) > 256) + { + sprintf((char *)sipAsciTempBuf, "request startLine version length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, p1 + 1, len); + + if (sip_ver_api_conv(tmp, &startLine->sipVersion, SIP_STR_TO_API) < 0) + return -1; + + hp++; + + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + + (*nextHeader) = hp; + + return 0; +} + +int sip_msg_start_line_parse_resp(SIP_MSG *dest, char *buf, char **nextHeader) +{ + char *hp; + char tmp[128]; + char *statuscode; + char *reasonphrase; + BYTE len; + SIP_START_LINE *startLine; + + if ((dest == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_msg_start_line_parse_req: dest or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startLine = &dest->sipStartLine; + *nextHeader = buf; + + statuscode = strchr(buf, ' '); // Search for first SPACE + if (statuscode == NULL) + return -1; + + if ((len = statuscode - buf) > 128) + { + sprintf((char *)sipAsciTempBuf, "response startLine vesion length out of range\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(tmp, buf, len); + + if (sip_ver_api_conv(tmp, &startLine->sipVersion, SIP_STR_TO_API) < 0) + return -1; + + reasonphrase = strchr(statuscode + 1, ' '); + + if (reasonphrase == NULL) + return -1; + + if (sscanf(statuscode + 1, "%d", &startLine->statusCode) != 1) + return -1; + + if (startLine->statusCode == 0) + return -1; + + hp = reasonphrase; + while ((*hp != '\r') && (*hp != '\n')) + { + if (*hp) + hp++; + else + { + sprintf((char *)sipAsciTempBuf, "No crlf found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((len = hp - reasonphrase - 1) > 128) + len =128; + + sip_clrncpy(startLine->reasonPhrase, reasonphrase + 1, len); + + hp++; + if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0])) + hp++; + + (*nextHeader) = hp; + + return 0; +} + +int sip_msg_start_line_parse(SIP_API_STRUCT *dest, char *buf, char **nextHeader) +{ + int ret; + + if ((dest == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_msg_start_line_parse: dest or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (strncmp(buf, "SIP/", 4) == 0) + { + dest->sipApiType = SIP_API_RES_MSG; + if (sip_msg_start_line_parse_resp(&dest->sipApiMsg.sipMsg, buf, nextHeader) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_msg_start_line_parse: parse resp failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + dest->sipApiType = SIP_API_REQ_MSG; + if ((ret = sip_msg_start_line_parse_req(&dest->sipApiMsg.sipMsg, buf, nextHeader)) < 0) + { + if (ret == -2) + { + //sip_send_allow(buf); + } + sprintf((char *)sipAsciTempBuf, "sip_msg_start_line_parse: parse req failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + return dest->sipApiType; +} + +int sip_sub_body_headers_pars(SIP_MESSAGE_BODYS *sipBodys, char *buf, char **body) +{ + char *colonIndex; + char hname[64]; + char hvalue[128]; + char *startOfHeader; + char *endOfHeader; + char *end; + BYTE len; + SIP_CONTENT_TYPE *contentType; + SIP_CONTENT_DISPOSITION *contentDisposition; + + if ((sipBodys == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_sub_body_headers_pars: sipBodys or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startOfHeader = buf; + + for (;;) + { + if (startOfHeader[0] == '\0') + { + sprintf((char *)sipAsciTempBuf, "SIP message does not end with CRLFCRLF\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + + if (sip_find_next_crlf(startOfHeader, &endOfHeader) < 0) + { + sprintf((char *)sipAsciTempBuf, "End of header Not found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + // the list of headers MUST always end with + // CRLFCRLF (also CRCR and LFLF are allowed) + if ((startOfHeader[0] == '\r') || (startOfHeader[0] == '\n')) + { + *body = startOfHeader; + return 0; + } + + // find the header name + if ((colonIndex = strchr(startOfHeader, ':')) == NULL) + { + sprintf((char *)sipAsciTempBuf, "End of header Not found\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (colonIndex - startOfHeader + 1 < 2) + return -1; + + if (endOfHeader <= colonIndex) + { + sprintf((char *)sipAsciTempBuf, "Malformed message\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + len = colonIndex - startOfHeader; + + if (len > 64) + { + sprintf((char *)sipAsciTempBuf, "sub body header name length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(hname, startOfHeader, len); + + // END of header is (end_of_header-2) if header separation is CRLF + // END of header is (end_of_header-1) if header separation is CR or LF + if ((endOfHeader[-2] == '\r') || (endOfHeader[-2] == '\n')) + end = endOfHeader - 2; + else + end = endOfHeader - 1; + + if ((end - colonIndex) < 2) + strcpy(hvalue, ""); // some headers (subject) can be empty + else + { + len = end - colonIndex - 1; + + if (len > 128) + { + sprintf((char *)sipAsciTempBuf, "sub body header value length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy(hvalue, colonIndex + 1, len); + } + + // hvalue MAY contains multiple value. In this case, they + // are separated by commas. But, a comma may be part of a + // quoted-string ("here, and there" is an example where the + // comma is not a separator!) + if ( (strcasecmp(hname, "c") == 0) || (strcasecmp(hname, "content-type") == 0)) + { + contentType = &sipBodys->sipBody[sipBodys->sipBodyNum].sipBodyContentType; + + sip_content_type_parse(contentType, hvalue); + + sipBodys->sipBody[sipBodys->sipBodyNum].sipBodyHdrFlg[0] |= SIP_HDR_CONTENT_TYPE_MASK; + } + else if (strcasecmp(hname, "content-disposition") == 0) + { + contentDisposition = &sipBodys->sipBody[sipBodys->sipBodyNum].sipBodyContentDisposition; + + sip_content_disposition_parse(contentDisposition, hvalue); + + sipBodys->sipBody[sipBodys->sipBodyNum].sipBodyHdrFlg[0] |= SIP_HDR_CONTENT_DISPOSITION_MASK; + } + + // continue on the next header + startOfHeader = endOfHeader; + } + + return -1; +} + +int sip_sub_body_parse(SIP_MESSAGE_BODYS *sipBodys, char *buf, char *boundary) +{ + BYTE boundaryLen; + char *subBody; + char *nextBoundary; + char endBoundary[64] = ""; + + if ((buf == NULL) || (boundary == NULL) || (sipBodys == NULL)) + { + sprintf((char *)sipAsciTempBuf, "buff boundary or sipBodys is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + +// memset((BYTE *)sipBodys, 0, sizeof(SIP_MESSAGE_BODYS)); + + subBody = buf; + boundaryLen = strlen(boundary); + sprintf(endBoundary, "%s--", boundary); + + if ((strncmp(subBody, boundary, boundaryLen) != 0) + || (strncmp(subBody, endBoundary, boundaryLen + 2) == 0) ||(strstr(subBody, endBoundary) == NULL)) + { + sprintf((char *)sipAsciTempBuf, "malformed message body\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + for (;;) + { + if (strncmp(subBody, endBoundary, boundaryLen + 2) == 0) + { + return 0; + } + + while (('\r' != *subBody) && ('\n' != *subBody)) + { + if (*subBody) + subBody++; + else + { + sprintf((char *)sipAsciTempBuf, "Final CRLF is missing\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if (('\r' == subBody[0]) && ('\n' == subBody[1])) + subBody = subBody + 2; + else + subBody = subBody + 1; + + if (((nextBoundary = strstr(subBody, boundary)) == NULL) + || (nextBoundary < subBody)) + { + sprintf((char *)sipAsciTempBuf, "message end without boundary\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_sub_body_headers_pars(sipBodys, subBody, &subBody); + + if (nextBoundary-subBody > SIP_MAX_BODY_LEN) + { + sprintf((char *)sipAsciTempBuf, "sub body message length is too long\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sip_clrncpy((char *)sipBodys->sipBody[sipBodys->sipBodyNum].msgBody, subBody, nextBoundary-subBody); + + sipBodys->sipBodyNum++; + + subBody = nextBoundary; + } + + return 0; +} + +int sip_body_parse(SIP_API_STRUCT *sip, char *buf, WORD len) +{ + int i; + char boundary[32]; + SIP_MESSAGE_BODYS *sipBodys; + SIP_CONTENT_TYPE *contentType; + WORD contentLength; + + if ((sip == NULL) || (buf == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip_body_parse: sip or buf is NULL\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipBodys = &sip->sipApiMsg.sipMsg.sipEntity.sipBodys; + contentType = &sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentType; + contentLength = sip->sipApiMsg.sipMsg.sipEntity.sipHdrContentLength; + + if ((contentType->type == SIP_CONTENT_TYPE_APPLICATION) + && (contentType->subType == SIP_CONTENT_SUB_TYPE_SDP)) + { + if (contentLength > len) + { + sprintf((char *)sipAsciTempBuf, "sip_body_parse:contentLength wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + strncpy((char *)sip->sipApiMsg.sipMsg.sipEntity.sipBodys.sipBody[0].msgBody, buf, contentLength + 2); + sip->sipApiMsg.sipMsg.sipEntity.sipBodys.sipBodyNum = 1; + + return 0; + } + else if ((contentType->type == SIP_CONTENT_TYPE_APPLICATION) + && (contentType->subType == SIP_CONTENT_SUB_TYPE_ISUP)) + { + if (contentLength > len) + return -1; + + strncpy((char *)sip->sipApiMsg.sipMsg.sipEntity.sipBodys.sipBody[0].msgBody, buf, contentLength + 2); + sip->sipApiMsg.sipMsg.sipEntity.sipBodys.sipBodyNum = 1; + + return 0; + } + else if ((contentType->type == SIP_CONTENT_TYPE_MULTIPART) + && (contentType->subType == SIP_CONTENT_SUB_TYPE_MIXED)) + { + if (contentLength > len) + return -1; + + for (i = 0; i < contentType->params.paraNum; i++) + { + if (contentType->params.para[i].paraName == SIP_API_PNAME_BOUNDARY) + { + sprintf(boundary, "--%s", contentType->params.para[i].para.paraStr); + break; + } + } + + sip_sub_body_parse(sipBodys, buf, boundary); + + return 0; + } + + return -1; +} diff --git a/omc/plat/sip/src/sip_transaction.c b/omc/plat/sip/src/sip_transaction.c new file mode 100644 index 0000000..a1baf41 --- /dev/null +++ b/omc/plat/sip/src/sip_transaction.c @@ -0,0 +1,1002 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "./include/sip_transport.h" +#include "./include/sip_msg.h" + +int sip_create_trans_branch(WORD transId, SIP_GEN_PARA *branch) +{ + branch->paraName = SIP_API_PNAME_BRANCH; + branch->paraType = SIP_API_PTYPE_STRING; + sprintf(branch->para.paraStr, "z9hG4bk-%d-%ld", SIP_BRANCH_BASE_TRANS_ID + transId, time(NULL)); + + return 0; +} + +DWORD sip_min(DWORD A, DWORD B) +{ + if (A <= B) + return A; + + return B; +} + +void sip_trans_init(WORD trans_id) +{ + memset((BYTE *)&sipTrans[trans_id], 0, sizeof(SIP_TRANSACTION)); +} + +int sip_request_uri_match(SIP_URI *uriFirst, SIP_URI *uriSecond) +{ + if (strcmp(uriFirst->userName, uriSecond->userName) != 0) + return -1; + + if (strcmp(uriFirst->host.addr.domain, uriSecond->host.addr.domain) != 0) + return -1; + + return 0; +} + +int sip_call_id_match(SIP_HDR_CALL_ID *callIdFirst, SIP_HDR_CALL_ID *callIdSecond) +{ + if (strcmp(callIdFirst->value, callIdSecond->value) !=0) + return -1; + + if (strcmp(callIdFirst->host, callIdSecond->host) != 0) + return -1; + + return 0; +} + +int sip_top_via_match(SIP_HDR_VIA *viaFirst, SIP_HDR_VIA *viaSecond) +{ + if (strcmp(viaFirst->url.domain, viaSecond->url.domain) != 0) + return -1; + + return 0; +} + +WORD sip_request_match_server_trans(SIP_API_STRUCT *recvMsg) +{ + WORD transId; + char *branchRecvd, *branchCreated; + char *sentByRecvd, *sentByCreated; + char methodRecvd, methodCreated; + SIP_MSG *sipMsgRecvd; + SIP_CR_MSG *sipMsgCreated; + SIP_URI *requestUriRecvd, *requestUriCreated; + char *toTagRecvd, *toTagCreated;//, *toTagResponse;//improve + char *fromTagRecvd, *fromTagCreated; + SIP_HDR_CALL_ID *callIdRecvd, *callIdCreated; + SIP_HDR_CSEQ *cseqRecvd, *cseqCreated; + SIP_HDR_VIA *viaRecvd, *viaCreated; + + sipMsgRecvd = &recvMsg->sipApiMsg.sipMsg; + methodRecvd = sipMsgRecvd->sipStartLine.sipMethod; + viaRecvd = &sipMsgRecvd->sipHdrVias.vias[1]; + branchRecvd = viaRecvd->params.para[0].para.paraStr; + + if (strncmp(branchRecvd, "z9hG4bK", 7) == 0) + { // RFC 3261 + sentByRecvd = sipMsgRecvd->sipHdrVias.vias[1].url.domain; + + for (transId = 0; transId < SIP_MAX_NUM_OF_TRANS; transId++) + { + if ((sipTrans[transId].flag != 1) || + (sipTrans[transId].client != SIP_TRANS_SERVER)) + continue; + + sipMsgCreated = &sipTrans[transId].crMsg; + branchCreated = sipMsgCreated->sipCrHdrVia.params.para[0].para.paraStr; + sentByCreated = sipMsgCreated->sipCrHdrVia.url.domain; + methodCreated = sipMsgCreated->sipCrStartLine.sipMethod; + + if ((strcmp(branchRecvd, branchCreated) == 0) && + (strcmp(sentByRecvd, sentByCreated) == 0))// + { + if (methodRecvd == SIP_METHOD_ACK) + return transId; + else if (methodRecvd == methodCreated) + return transId; + } + } + } + + // RFC 2543 + + requestUriRecvd = &sipMsgRecvd->sipStartLine.requestUri; + toTagRecvd = sipMsgRecvd->sipHdrTo.params.para[0].para.paraStr; + fromTagRecvd = sipMsgRecvd->sipHdrFrom.params.para[0].para.paraStr; + callIdRecvd = &sipMsgRecvd->sipHdrCallId; + cseqRecvd = &sipMsgRecvd->sipHdrCseq; + + for (transId = 0; transId < SIP_MAX_NUM_OF_TRANS; transId++) + { + if ((sipTrans[transId].flag != 1) || + (sipTrans[transId].client != SIP_TRANS_SERVER)) + continue; + + sipMsgCreated = &sipTrans[transId].crMsg; + requestUriCreated = &sipMsgCreated->sipCrStartLine.requestUri; + toTagCreated = sipMsgCreated->sipCrHdrTo.params.para[0].para.paraStr; +// toTagResponse = sipTrans[transId].sdMsg.sipApiMsg.sipMsg.sipHdrTo.params.para[0].para.paraStr;//improve + fromTagCreated = sipMsgCreated->sipCrHdrFrom.params.para[0].para.paraStr; + callIdCreated = &sipMsgCreated->sipCrHdrCallId; + cseqCreated = &sipMsgCreated->sipCrHdrCseq; + viaCreated = &sipMsgCreated->sipCrHdrVia; + + if ((sip_request_uri_match(requestUriRecvd, requestUriCreated) == 0) && + (strcmp(fromTagRecvd, fromTagCreated) == 0) && + (sip_call_id_match(callIdRecvd, callIdCreated) == 0) && + (cseqRecvd->value == cseqCreated->value) && + (sip_top_via_match(viaRecvd, viaCreated) == 0)) + { + if (methodRecvd == SIP_METHOD_ACK) + { + if (strcmp(toTagRecvd, toTagCreated) == 0)//if (strcmp(toTagRecvd, toTagResponse) == 0)//improve + return transId; + } + else + { + if ((strcmp(toTagRecvd, toTagCreated) == 0) && + (cseqRecvd->method == cseqCreated->method)) + return transId; + } + } + } + + return SIP_MAX_NUM_OF_TRANS; +} + +WORD sip_response_match_client_trans(SIP_API_STRUCT *recvMsg) +{ + char *first; + char *second; + char tmp[8] = ""; + char *branchRecvd, *branchCreated; + BYTE methodRecvd, methodCreated; + WORD transId; + + branchRecvd = recvMsg->sipApiMsg.sipMsg.sipHdrVias.vias[1].params.para[0].para.paraStr; + + first = strchr(branchRecvd, '-'); + if (first == NULL) + return SIP_MAX_NUM_OF_TRANS; + + second = strchr(first + 1, '-'); + if (second == NULL) + return SIP_MAX_NUM_OF_TRANS; + + if ((second - first - 1) != SIP_BRANCH_BASE_TRANS_ID_LEN) + return SIP_MAX_NUM_OF_TRANS; + strncpy(tmp, first + 1, SIP_BRANCH_BASE_TRANS_ID_LEN); + + transId = atol(tmp); + transId = transId - SIP_BRANCH_BASE_TRANS_ID; + if (transId >= SIP_MAX_NUM_OF_TRANS) + return SIP_MAX_NUM_OF_TRANS; + + methodRecvd = recvMsg->sipApiMsg.sipMsg.sipHdrCseq.method; + + methodCreated = sipTrans[transId].crMsg.sipCrHdrCseq.method; + branchCreated = sipTrans[transId].crMsg.sipCrHdrVia.params.para[0].para.paraStr; + + if ((strcmp(branchRecvd, branchCreated) == 0) && + (methodRecvd == methodCreated)) + return transId; + else + { + for (transId = 0; transId < SIP_MAX_NUM_OF_TRANS; transId++) + { + if ((sipTrans[transId].flag != 1) || + (sipTrans[transId].client != SIP_TRANS_CLIENT)) + continue; + + methodCreated = sipTrans[transId].crMsg.sipCrHdrCseq.method; + branchCreated = sipTrans[transId].crMsg.sipCrHdrVia.params.para[0].para.paraStr; + + if ((strcmp(branchRecvd, branchCreated) == 0) && + (methodRecvd == methodCreated)) + return transId; + } + } + + return SIP_MAX_NUM_OF_TRANS; +} + +int sip_trans_srv_non_inv_proc(WORD transId) +{ + SIP_TRANSACTION *sipTransPtr; + WORD sdCmd; + WORD rvCmd; + SIP_USER *sipUser; + + sipTransPtr = &sipTrans[transId]; + sdCmd = sipTransPtr->sdCmd; + rvCmd = sipTransPtr->rvCmd; + sipUser = &sipUsers.sipUsers[sipTransPtr->userIndex].sipUser; + + switch (sipTransPtr->state) + { + case SIP_TRANS_STATE_IDLE: + // Request received, pass to TU + sipTransPtr->state = SIP_TRANS_STATE_TRYING; + sipTransPtr->timer = (18 * SIP_TIMER_T4); + return sip_trans_srv_non_inv_proc(transId); + case SIP_TRANS_STATE_TRYING: + if (sdCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->sdCmd = SIP_COMMAND_IDLE; + if ((sdCmd >= 100) && (sdCmd <= 199)) + { // If 1XX from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->state = SIP_TRANS_STATE_PROCEEDING; + sipTransPtr->timer = (18 * SIP_TIMER_T4); + } + else if ((sdCmd >= 200) && (sdCmd <= 699)) + { // If 200-699 from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_J; + } + } + + if ((SIP_TRANS_STATE_TRYING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + { + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_PROCEEDING: + if (sdCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->sdCmd = SIP_COMMAND_IDLE; + if ((sdCmd >= 100) && (sdCmd <= 199)) + { // If 1XX from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + } + else if ((sdCmd >= 200) && (sdCmd <= 699)) + { // If 200-699 from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_J; + return 0; + } + } + + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if (rvCmd == SIP_TRANSPORT_ERROR) + { // If transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else + { // If request, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + } + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + { + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + + break; + case SIP_TRANS_STATE_COMPLETED: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + // Request, send response + if (rvCmd == SIP_TRANSPORT_ERROR) + { // If transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else + { // If request, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + } + } + + if (sipTransPtr->timer > 0) + sipTransPtr->timer--; + + if (sipTransPtr->timer == 0) + { // if timer J fires + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + break; + default: + sipTransPtr->state = SIP_TRANS_STATE_IDLE; + break; + } + + return 0; +} + +int sip_trans_srv_inv_proc(WORD transId) +{ + SIP_TRANSACTION *sipTransPtr; + WORD sdCmd; + WORD rvCmd; + SIP_USER *sipUser; + + sipTransPtr = &sipTrans[transId]; + sdCmd = sipTransPtr->sdCmd; + rvCmd = sipTransPtr->rvCmd; + sipUser = &sipUsers.sipUsers[sipTransPtr->userIndex].sipUser; + + switch (sipTransPtr->state) + { + case SIP_TRANS_STATE_IDLE: + // INVITE received, pass to TU + sipTransPtr->timer2= SIP_TIMER_200MS; + sipTransPtr->timer = (18 * SIP_TIMER_T4); + sipTransPtr->state = SIP_TRANS_STATE_PROCEEDING; + return sip_trans_srv_inv_proc(transId); + break; + case SIP_TRANS_STATE_PROCEEDING: + if (sdCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->sdCmd = SIP_COMMAND_IDLE; + if ((sdCmd >= 101) && (sdCmd <= 199)) + { // if 101-199 from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->timer2 = 0; + } + else if ((sdCmd >= 200) && (sdCmd <= 299)) + { // if 2xx from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->timer2 = 0; + sipTransPtr->timer = 0; + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if ((sdCmd >= 300) && (sdCmd <= 699)) + { // if 300-699 from TU, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer2 = SIP_TIMER_G; + sipTransPtr->timer = SIP_TIMER_H; + return 0; + } + } + + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if (rvCmd == SIP_TRANSPORT_ERROR) + { // If transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if (rvCmd == SIP_METHOD_INVITE) + { // If INVITE, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + } + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer2 > 0)) + { + if (--sipTransPtr->timer2== 0) + sip_send_100(&sipTransPtr->crMsg, sipTransPtr); + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + { + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_COMPLETED: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if (rvCmd == SIP_TRANSPORT_ERROR) + { // If transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if (rvCmd == SIP_METHOD_ACK) + { // If ACK + sipTransPtr->state = SIP_TRANS_STATE_CONFIRMED; + sipTransPtr->timer = SIP_TIMER_I; + return 0; + } + else if (rvCmd == SIP_METHOD_INVITE) + { // If INVITE, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + } + } + + if ((SIP_TRANS_STATE_COMPLETED == sipTransPtr->state) && (sipTransPtr->timer2 > 0)) + { + if (--sipTransPtr->timer2 == 0) + {// If timer G fires, send response + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->retransTimes++; + sipTransPtr->timer2 = sip_min((1 << sipTransPtr->retransTimes) * SIP_TIMER_E_INITIAL, SIP_TIMER_T2); + } + } + + if ((SIP_TRANS_STATE_COMPLETED == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + { // If timer H fires + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_CONFIRMED: + if (sipTransPtr->timer > 0) + sipTransPtr->timer--; + + if (sipTransPtr->timer == 0) + { // If timer I fires + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + break; + default: + sipTransPtr->state = SIP_TRANS_STATE_IDLE; + break; + } + + return 0; +} + +int sip_trans_clt_non_inv_proc(WORD transId) +{ + SIP_TRANSACTION *sipTransPtr; + SIP_USER *sipUser; + WORD sdCmd; + WORD rvCmd; + + sipTransPtr = &sipTrans[transId]; + sdCmd = sipTransPtr->sdCmd; + rvCmd = sipTransPtr->rvCmd; + sipUser = &sipUsers.sipUsers[sipTransPtr->userIndex].sipUser; + + switch (sipTransPtr->state) + { + case SIP_TRANS_STATE_IDLE: + if (sdCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->sdCmd = SIP_COMMAND_IDLE; + if (sdCmd != SIP_METHOD_INVITE) + { // Request from TU, send request +// sip_fill_cr_msg(&sipTransPtr->crMsg, &sipTransPtr->sdMsg);//improve + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + + if (sdCmd == SIP_METHOD_ACK) + { + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else + { + sipTransPtr->timer = SIP_TIMER_F; + sipTransPtr->timer2 = SIP_TIMER_E_INITIAL; + sipTransPtr->retransTimes = 0; + sipTransPtr->state = SIP_TRANS_STATE_TRYING; + } + } + else + return 1; + } + break; + case SIP_TRANS_STATE_TRYING: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if ((rvCmd >= 200) & (rvCmd <= 699)) + { // 200-699, resp. to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_K; + return 0; + } + else if (rvCmd == SIP_TRANSPORT_ERROR) + { // Transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if ((rvCmd >= 100) & (rvCmd <= 199)) + { // 1xx, 1xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_PROCEEDING; + sipTransPtr->timer = SIP_TIMER_F; +// sipTransPtr->timer2 = SIP_TIMER_T2;//?? + return 0; + } + } + + if ((SIP_TRANS_STATE_TRYING == sipTransPtr->state) && (sipTransPtr->timer2 > 0)) + { + if (--sipTransPtr->timer2 == 0) + {// Timer E fires, send request + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->retransTimes++; + sipTransPtr->timer2 = sip_min((1 << sipTransPtr->retransTimes) * SIP_TIMER_E_INITIAL, SIP_TIMER_T2); + } + } + + if ((SIP_TRANS_STATE_TRYING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + {// If timer F fires, inform TU +/* memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sipToUpMsg, &sipTransPtr->sdMsg, sizeof(SIP_API_STRUCT)); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); +*///improve + memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + sip_fill_msg_with_cr(&sipToUpMsg.sipApiMsg.sipMsg, &sipTransPtr->crMsg); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_PROCEEDING: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if ((rvCmd >= 200) & (rvCmd <= 699)) + { // 100-699, resp. to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_K; + return 0; + } + else if (rvCmd == SIP_TRANSPORT_ERROR) + { // Transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if ((rvCmd >= 100) & (rvCmd <= 199)) + { // 1xx, 1xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + } + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer2 > 0)) + { + if (--sipTransPtr->timer2 == 0) + {// Timer E fires, send request + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->retransTimes++; + sipTransPtr->timer2 = SIP_TIMER_T2; + } + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + {// If timer F fires, inform TU +/* memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sipToUpMsg, &sipTransPtr->sdMsg, sizeof(SIP_API_STRUCT)); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); +*///improve + memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + sip_fill_msg_with_cr(&sipToUpMsg.sipApiMsg.sipMsg, &sipTransPtr->crMsg); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_COMPLETED: + if (sipTransPtr->timer > 0) + sipTransPtr->timer--; + + if (sipTransPtr->timer == 0) + { // if timer K fires + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + break; + default: + sipTransPtr->state = SIP_TRANS_STATE_IDLE; + break; + } + + return 0; +} + +int sip_trans_clt_inv_proc(WORD transId) +{ + SIP_TRANSACTION *sipTransPtr; + SIP_USER *sipUser; + WORD sdCmd; + WORD rvCmd; + + sipTransPtr = &sipTrans[transId]; + sdCmd = sipTransPtr->sdCmd; + rvCmd = sipTransPtr->rvCmd; + sipUser = &sipUsers.sipUsers[sipTransPtr->userIndex].sipUser; + + switch (sipTransPtr->state) + { + case SIP_TRANS_STATE_IDLE: + if (sdCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->sdCmd = SIP_COMMAND_IDLE; + if ((sdCmd == SIP_METHOD_INVITE) || (sdCmd == SIP_METHOD_RE_INVITE)) + { // INVITE from TU, INVITE sent +// sip_fill_cr_msg(&sipTransPtr->crMsg, &sipTransPtr->sdMsg);//improve + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->timer = SIP_TIMER_B; + sipTransPtr->timer2 = SIP_TIMER_A; + sipTransPtr->state = SIP_TRANS_STATE_CALLING; + } + else + return 1; + } + break; + case SIP_TRANS_STATE_CALLING: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if ((rvCmd >= 300) & (rvCmd <= 699)) + { // 300-699, ACK sent, resp. to TU + sip_send_ack(&sipRecvMsg, sipTransPtr); + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_D; + sipTransPtr->timer2 = 0; + return 0; + } + else if ((rvCmd >= 200) & (rvCmd <= 299)) + { // 2xx, 2xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + sipTransPtr->timer2 = 0; + return 1; + } + else if ((rvCmd >= 100) & (rvCmd <= 199)) + { // 1xx, 1xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_PROCEEDING; + sipTransPtr->timer2 = 0; + sipTransPtr->timer = (7 * SIP_TIMER_T4); + return 0; + } + else if (rvCmd == SIP_TRANSPORT_ERROR) + { // transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + sipTransPtr->timer2 = 0; + return 1; + } + } + + if (sipTransPtr->timer2 > 0) + { + if (--sipTransPtr->timer2 == 0) + { // If timer A fires, reset A, INVITE sent + sip_transport_send_trans_msg(&sipTransPtr->transSdMsg); +// sip_transport_send_msg(&sipTransPtr->sdMsg);//improve + sipTransPtr->retransTimes++; + sipTransPtr->timer2 = sip_min((1 << sipTransPtr->retransTimes) * SIP_TIMER_E_INITIAL, SIP_TIMER_B); + } + } + + if ((SIP_TRANS_STATE_CALLING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (--sipTransPtr->timer == 0) + {// If timer B fires, inform TU +/* memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sipToUpMsg, &sipTransPtr->sdMsg, sizeof(SIP_API_STRUCT)); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); +*///improve + memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + sip_fill_msg_with_cr(&sipToUpMsg.sipApiMsg.sipMsg, &sipTransPtr->crMsg); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_PROCEEDING: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if ((rvCmd >= 300) & (rvCmd <= 699)) + { // 300-699, ACK sent, resp. to TU + sip_send_ack(&sipRecvMsg, sipTransPtr); + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_COMPLETED; + sipTransPtr->timer = SIP_TIMER_D; + } + else if ((rvCmd >= 200) & (rvCmd <= 299)) + { // 2xx, 2xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + else if ((rvCmd >= 100) & (rvCmd <= 199)) + { // 1xx, 1xx to TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + } + } + + if ((SIP_TRANS_STATE_PROCEEDING == sipTransPtr->state) && (sipTransPtr->timer > 0)) + { + if (-- sipTransPtr->timer == 0) + { +/* memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sipToUpMsg, &sipTransPtr->sdMsg, sizeof(SIP_API_STRUCT)); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); +*///improve + memset(&sipToUpMsg, 0, sizeof(SIP_API_STRUCT)); + sip_fill_msg_with_cr(&sipToUpMsg.sipApiMsg.sipMsg, &sipTransPtr->crMsg); + sipToUpMsg.sipApiType = SIP_API_RES_MSG; + sipToUpMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = SIP_TRANSACTION_TIMEOUT; + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipToUpMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + break; + case SIP_TRANS_STATE_COMPLETED: + if (rvCmd != SIP_COMMAND_IDLE) + { + sipTransPtr->rvCmd = SIP_COMMAND_IDLE; + if ((rvCmd >= 300) & (rvCmd <= 699)) + { // 300-699, ACK sent + sip_send_ack(&sipRecvMsg, sipTransPtr); + } + else if (rvCmd == SIP_TRANSPORT_ERROR) + { // if transport error, inform TU + sipUser->recv_proc(transId, sipTransPtr->upPort, SIP_TRANSACTION_LAYER, &sipRecvMsg); + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + } + + if (sipTransPtr->timer > 0) + sipTransPtr->timer--; + + if (sipTransPtr->timer == 0) + { // if timer D fires + sipTransPtr->state = SIP_TRANS_STATE_TERMINATED; + return 1; + } + break; + default: + sipTransPtr->state = SIP_TRANS_STATE_IDLE; + break; + } + + return 0; +} + +void sip_transaction_proc(WORD transid) +{ + switch (sipTrans[transid].mainState) + { + case SIP_TRANS_MAIN_STATE_INIT: + sip_trans_init(transid); + break; + case SIP_TRANS_MAIN_STATE_SVR_NON_INV: + switch (sip_trans_srv_non_inv_proc(transid)) + { + case 0: + break; + case 1: + sipTrans[transid].mainState = SIP_TRANS_MAIN_STATE_INIT; + sip_transaction_proc(transid); + break; + default: + break; + } + break; + case SIP_TRANS_MAIN_STATE_SVR_INV: + switch (sip_trans_srv_inv_proc(transid)) + { + case 0: + break; + case 1: + sipTrans[transid].mainState = SIP_TRANS_MAIN_STATE_INIT; + sip_transaction_proc(transid); + break; + default: + break; + } + break; + case SIP_TRANS_MAIN_STATE_CLT_NON_INV: + switch (sip_trans_clt_non_inv_proc(transid)) + { + case 0: + break; + case 1: + sipTrans[transid].mainState = SIP_TRANS_MAIN_STATE_INIT; + sip_transaction_proc(transid); + break; + default: + break; + } + break; + case SIP_TRANS_MAIN_STATE_CLT_INV: + switch (sip_trans_clt_inv_proc(transid)) + { + case 0: + break; + case 1: + sipTrans[transid].mainState = SIP_TRANS_MAIN_STATE_INIT; + sip_transaction_proc(transid); + break; + default: + break; + } + break; + default: + sipTrans[transid].mainState = SIP_TRANS_MAIN_STATE_INIT; + break; + } +} + +int sip_msg_transport_to_transaction(SIP_API_STRUCT *recvMsg, WORD transId) +{ + SIP_TRANSACTION *sipTransPtr = &sipTrans[transId]; + + if (recvMsg->sipApiType == SIP_API_TYPE_RESPONSE) + sipTransPtr->rvCmd = recvMsg->sipApiMsg.sipMsg.sipStartLine.statusCode; + else if (recvMsg->sipApiType == SIP_API_TYPE_REQUEST) + sipTransPtr->rvCmd = recvMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod; + + sip_transaction_proc(transId); + + return 0; +} + +int sip_set_trans_send_cmd(SIP_TRANSACTION *trans, SIP_API_STRUCT *sipApiMsg) +{ + SIP_START_LINE *startLine; + + startLine = &sipApiMsg->sipApiMsg.sipMsg.sipStartLine; + + if (sipApiMsg->sipApiType == SIP_API_REQ_MSG) + trans->sdCmd = startLine->sipMethod; + else if (sipApiMsg->sipApiType == SIP_API_RES_MSG) + trans->sdCmd = startLine->statusCode; + else + return -1; + + return 0; +} + +int sip_create_transaction(BYTE client, BYTE method, BYTE userIndex, WORD upPort, SIP_API_STRUCT *msg) +{ + WORD i; + WORD transId = sipTransHead; + SIP_TRANSACTION *trans; + + + if (msg == NULL) + { +// sip_trans_init(transId); + return -1; + }//improve + + if (transId>= SIP_MAX_NUM_OF_TRANS) + { + transId = 0; + } + + for (i = 0; i < SIP_MAX_NUM_OF_TRANS; i++) + { + trans = &sipTrans[transId]; + + if (trans->flag != 0) + { + if (++transId >= SIP_MAX_NUM_OF_TRANS) + { + transId = 0; + } + + continue; + } + else + { + sip_trans_init(transId); + trans->flag = 1; + trans->client = client; + trans->method = method; + trans->userIndex = userIndex; + trans->upPort = upPort; +/* if (client == SIP_TRANS_SERVER) + { + if (msg == NULL) + { + sip_trans_init(transId); + return -1; + } + + sip_fill_cr_msg(&trans->crMsg, msg); + } +*///improve + sipTransHead = (transId+ 1) & SIP_MAX_NUM_OF_TRANS_1; + + if (client == SIP_TRANS_SERVER) + { + if (method == SIP_TRANS_NON_INVITE) + trans->mainState = SIP_TRANS_MAIN_STATE_SVR_NON_INV; + else + trans->mainState = SIP_TRANS_MAIN_STATE_SVR_INV; + } + else + { + if (method == SIP_TRANS_NON_INVITE) + trans->mainState = SIP_TRANS_MAIN_STATE_CLT_NON_INV; + else + trans->mainState = SIP_TRANS_MAIN_STATE_CLT_INV; + + if (msg->sipApiMsg.sipMsg.sipStartLine.sipMethod != SIP_METHOD_CANCEL) + { + sip_create_trans_branch(transId, &msg->sipApiMsg.sipMsg.sipHdrVias.vias[msg->sipApiMsg.sipMsg.sipHdrVias.head].params.para[0]); + msg->sipApiMsg.sipMsg.sipHdrVias.vias[msg->sipApiMsg.sipMsg.sipHdrVias.head].params.paraNum++; + } + } + trans->state = SIP_TRANS_STATE_IDLE; + + sip_fill_cr_msg(&trans->crMsg, msg);//improve + + return transId; + } + } + + return SIP_MAX_NUM_OF_TRANS; +} diff --git a/omc/plat/sip/src/sip_transport.c b/omc/plat/sip/src/sip_transport.c new file mode 100644 index 0000000..2794d32 --- /dev/null +++ b/omc/plat/sip/src/sip_transport.c @@ -0,0 +1,192 @@ +#include "./include/sip_pub.h" +#include "./include/sip.h" +#include "./include/sip_const.h" +#include "./include/sip_struct.h" +#include "./include/sip_ext.h" +#include "./include/sip_msg.h" +#include "./include/sip_msg_encode.h" +#include "./include/sip_debug.h" + +int sip_transport_send_udp_msg() +{ + int ret, len; + + sipUdpMsgSdBuf[SIP_MAX_UDP_MSG_LEN - 1] = '\0'; + len = strlen(sipUdpMsgSdBuf); + if (len >= SIP_MAX_UDP_MSG_LEN) + return -1; + + ret = sendto(sipUdpSocketFd, sipUdpMsgSdBuf, len, 0, (struct sockaddr *) &sipDstInAddr, sizeof(sipDstInAddr)); + + if (ret >= 0) + { + sipUdpMsgSdBuf[len] = '\0'; + if ((sipMonitorFg & MONITOR_SIP_MSG) == MONITOR_SIP_MSG) + { + sprintf(sipAsciTempBuf, "Send SIP Msg (UDP) ===> dest port: %d, dest ipV4: %s\r\n", ntohs(sipDstInAddr.sin_port), inet_ntoa(sipDstInAddr.sin_addr)); + sip_asciout_proc(sipAsciTempBuf); + sip_asciout_proc(sipUdpMsgSdBuf); + sip_asciout_proc("\r\n"); + } + } + else + { + sprintf(sipAsciTempBuf, "Send SIP Msg (UDP) Failed ===> dest port: %d, dest ipV4: %s\r\n", ntohs(sipDstInAddr.sin_port), inet_ntoa(sipDstInAddr.sin_addr)); + sip_log_err(sipAsciTempBuf); + } + + return ret; +} + +int sip_transport_recv_udp_msg() +{ + int i, len, addrLen = sizeof(struct sockaddr); + + for (i = 0; i < SIP_MAX_UDP_MSG_GET_TIMES; i++) + { + len = recvfrom(sipUdpSocketFd, sipUdpMsgRvBuf, SIP_MAX_UDP_MSG_LEN, + 0, (struct sockaddr *)&sipSrcInAddr, &addrLen); + if (len < 0) + break; + + if (len >= SIP_MAX_UDP_MSG_LEN) + continue; + + sipUdpMsgRvBuf[len] = '\0'; + + memset((BYTE *)&sipRecvMsg, 0, sizeof(SIP_API_STRUCT)); + + sipRecvMsg.sipTransAddr.type = 0; // ipv4 & udp + sipRecvMsg.sipTransAddr.port = ntohs(sipSrcInAddr.sin_port); + sipRecvMsg.sipTransAddr.addr.ipV4 = sipSrcInAddr.sin_addr.s_addr; + + if ((sipMonitorFg & MONITOR_SIP_MSG) == MONITOR_SIP_MSG) + { + sprintf(sipAsciTempBuf, "Receive SIP Msg (UDP) <=== src port: %d, src ipV4: %s\r\n", sipRecvMsg.sipTransAddr.port, inet_ntoa(sipSrcInAddr.sin_addr)); + sip_asciout_proc(sipAsciTempBuf); + sip_asciout_proc(sipUdpMsgRvBuf); + sip_asciout_proc("\r\n"); + } + + sip_recv_msg_handling(sipUdpMsgRvBuf, len, -1); + } + + return 0; +} + +/*int sip_transport_recv_tcp_msg() +{ + int i, newSock, len; + struct sockaddr_in remote_addr; + + for (i = 0; i < SIP_MAX_NUM_OF_TCP_SOCK; i++) + { + if (sipTcpSock[i].flag != 1) + continue; + + len = recv(sipTcpSock[i].sendRecvSock, sipTcpMsgRvBuf, SIP_MAX_TCP_MSG_LEN, 0); + + if (len < 0) + break; + + sip_recv_msg_handling(sipTcpMsgRvBuf, len, i); + } + + len = sizeof(remote_addr); + bzero((char *)&remote_addr, len); + + if ((newSock = accept(sipTcpServerSocketFd, (struct sockaddr *)&remote_addr, (int *)&len)) < 0) + return 0; + + for (i = 0; i < SIP_MAX_NUM_OF_TCP_SOCK; i++) + { + if (sipTcpSock[i].flag == 1) + continue; + + sipTcpSock[i].sendRecvSock = newSock; + memcpy(&sipTcpSock[i].remoteAddr, &remote_addr, sizeof(struct sockaddr_in)); + + len = recv(sipTcpSock[i].sendRecvSock, sipTcpMsgRvBuf, SIP_MAX_TCP_MSG_LEN, 0); + + if (len < 0) + break; + + sip_recv_msg_handling(sipTcpMsgRvBuf, len, i); + } + + return 0; +}*/ + +int sip_transport_encode_trans_msg(SIP_TRANSACTION *trans, SIP_API_STRUCT *sipApiMsg) +{ + char dest[SIP_MAX_UDP_MSG_LEN] = ""; + + if (sip_transport_encode_start_line(dest, sipApiMsg) < 0) + return -1; + + if (sip_transport_encode_headers(dest, sipApiMsg) < 0) + return -1; + + if (sip_transport_encode_body(dest, sipApiMsg) < 0) + return -1; + + memcpy(&trans->transSdMsg.sipSdAddr, &sipApiMsg->sipTransAddr, sizeof(SIP_TRANSPORT_ADDR)); + + strcpy(trans->transSdMsg.sdMsg, dest); + trans->transSdMsg.sdMsg[SIP_MAX_UDP_MSG_LEN - 1] = '\0'; + + return 0; +} + +int sip_transport_encode_msg(SIP_API_STRUCT *sipApiMsg) +{ + char *dest = sipUdpMsgSdBuf; + + strcpy(dest, ""); + + if (sip_transport_encode_start_line(dest, sipApiMsg) < 0) + return -1; + + if (sip_transport_encode_headers(dest, sipApiMsg) < 0) + return -1; + + if (sip_transport_encode_body(dest, sipApiMsg) < 0) + return -1; + + if (sip_transport_set_addr(&sipDstInAddr, sipApiMsg) < 0) + return -1; + + return 0; +} + +int sip_transport_send_trans_msg(SIP_TRANS_SD_MSG *transSdMsg) +{ + strcpy(sipUdpMsgSdBuf, transSdMsg->sdMsg); + + if (sip_transport_set_sd_addr(&sipDstInAddr, &transSdMsg->sipSdAddr) < 0) + return -1; + + sip_transport_send_udp_msg(); + + return 0; +} + +int sip_transport_send_msg(SIP_API_STRUCT *sipApiMsg) +{ + if ((sipApiMsg->sipApiType != SIP_API_REQ_MSG) + && (sipApiMsg->sipApiType != SIP_API_RES_MSG)) + return -1; + + if (sip_transport_encode_msg(sipApiMsg) < 0) + return -1; + + sip_transport_send_udp_msg(); + + return 0; +} + +void sip_transport_proc() +{ + sip_transport_recv_udp_msg(); +// sip_transport_recv_tcp_msg(); +} diff --git a/omc/plat/sip/src/sip_ua.c b/omc/plat/sip/src/sip_ua.c new file mode 100644 index 0000000..585c642 --- /dev/null +++ b/omc/plat/sip/src/sip_ua.c @@ -0,0 +1,678 @@ +/****************************************************************/ +/* SIP UA Implementation Program */ +/* Version 9.0.1 */ +/* Designed By Francis */ +/* Last Update: 2008-5-21 */ +/****************************************************************/ + +#include "./include/sip_ua_pub.h" +#include "./include/sip_ua_def.h" +#include "./include/sip_ua_dialog.h" +#include "./include/sip_ua_const.h" +#include "./include/sip.h" +#include "./include/sip_ext.h" +#include "./include/sip_debug.h" +#include "./include/sip_ua_msg.h" + +extern void sip_ua_fsm(WORD port); + +int sip_ua_get_local_ip(void) +{ + struct hostent *host; + + if (gethostname(sipUaHostName, 50) == -1) + { + printf("SIP gethostname fail!\n"); + return -1; + } + + if ((host = gethostbyname(sipUaHostName)) == NULL) + { + printf("SIP gethostbyname fail!\n"); + return -1; + } + else + { + sprintf(sipUaDottedHostIp, "%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]); + sipUaHostIp = inet_addr(sipUaDottedHostIp); // Network byte order sipHostIp, like 0xE60012AC + printf("sipHostName: %s, sipHostIp: %s (0x%lX)\n", sipUaHostName, sipUaDottedHostIp, sipUaHostIp); + } + + return 0; +} + +int sip_ua_get_port() +{ + int i; + int port = sipUaPortSelect; + + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_get_port:port select have been changed\r\n"); + sip_log_err(sipAsciTempBuf); + port = 0; + } + + for (i = 0; i < SIP_UA_MAX_NUM_OF_PORT; i++) + { + if (sipUaPort[port].flag == 1) + { + if (++port >= SIP_UA_MAX_NUM_OF_PORT) + port = 0; + + continue; + } + + sip_ua_init_port(port); + + sipUaPort[port].flag = 1; + + sipUaPortSelect = (port + 1)%SIP_UA_MAX_NUM_OF_PORT; + + return port; + } + + return -1; +} + +WORD sip_ua_match_dialog_with_req(SIP_API_STRUCT *request) +{ + WORD i; + BYTE method; + SIP_HDR_CALL_ID *callId; + char *toTag; + char *fromTag; + SIP_DIALOG *sipDlgPtr; + char *branchRecv; + + if (request == NULL) + { + return SIP_UA_MAX_NUM_OF_DIALOG; + } + + method = request->sipApiMsg.sipMsg.sipStartLine.sipMethod; + branchRecv = request->sipApiMsg.sipMsg.sipHdrVias.vias[1].params.para[0].para.paraStr; + callId = &request->sipApiMsg.sipMsg.sipHdrCallId; + toTag = request->sipApiMsg.sipMsg.sipHdrTo.params.para[0].para.paraStr; + fromTag = request->sipApiMsg.sipMsg.sipHdrFrom.params.para[0].para.paraStr; + +/* if (method == SIP_METHOD_INVITE) + return SIP_UA_MAX_NUM_OF_DIALOG;*/ + + for (i = 0; i < SIP_UA_MAX_NUM_OF_DIALOG; i++) + { + sipDlgPtr = &sipUaDialog[i]; + + if ((sipDlgPtr->flag == 0) || (sipDlgPtr->state == SIP_UA_DIALOG_DESTROY) || (strcmp(sipDlgPtr->callId.value, callId->value) != 0) + || (strcmp(sipDlgPtr->remoteTag, fromTag) != 0)) + continue; + + if (method == SIP_METHOD_INVITE) + return i; + + if (method == SIP_METHOD_CANCEL) + { + if ((sipDlgPtr->state < SIP_UA_DIALOG_WAIT_ACK_FOR_200) && (strcmp(sipDlgPtr->invBranch, branchRecv) == 0)) + return i; + else + continue; + } + else + { + if (strcmp(sipDlgPtr->localTag, toTag) != 0) + continue; + + return i; + } + } + + return SIP_UA_MAX_NUM_OF_DIALOG; +} + +WORD sip_ua_match_dialog_with_rsp(SIP_API_STRUCT *response) +{ + WORD i; + SIP_HDR_CALL_ID *callId; + char *toTag; + char *fromTag; + + if (response == NULL) + { + return SIP_UA_MAX_NUM_OF_DIALOG; + } + + callId = &response->sipApiMsg.sipMsg.sipHdrCallId; + toTag = response->sipApiMsg.sipMsg.sipHdrTo.params.para[0].para.paraStr; + fromTag = response->sipApiMsg.sipMsg.sipHdrFrom.params.para[0].para.paraStr; + + for (i = 0; i < SIP_UA_MAX_NUM_OF_DIALOG; i++) + { + if ((sipUaDialog[i].flag == 0) + || (strcmp(sipUaDialog[i].callId.value, callId->value) != 0) + || (strcmp(sipUaDialog[i].localTag, fromTag) != 0)) + continue; + + if (sipUaDialog[i].state < SIP_UA_DIALOG_WAIT_ACK_FOR_200) + { + return i; + } + else + { + if (strcmp(sipUaDialog[i].remoteTag, toTag) != 0) + continue; + + return i; + } + } + + return SIP_UA_MAX_NUM_OF_DIALOG; +} + +int sip_ua_select_user_by_domain(SIP_API_STRUCT *sipApiMsg) +{ + int i; + SIP_URI *sipUri; + + if (sipApiMsg == NULL) + return -1; + + sipUri = &sipApiMsg->sipApiMsg.sipMsg.sipStartLine.requestUri; + + for (i = 0; i < SIP_UA_MAX_NUM_OF_SAP; i++) + { + if ((sipUaSaps[i].flag == 1) + && (strcmp(sipUaSaps[i].sipUaSap.domain, sipUri->host.addr.domain) == 0)) + return i; + } + + return -1; +} + +int sip_ua_check_retransmit_invit(SIP_API_STRUCT *sipApiMsg) +{ + SIP_HDR_CALL_ID *callId; + char *fromTag; + int i; + + callId = &sipApiMsg->sipApiMsg.sipMsg.sipHdrCallId; + fromTag = sipApiMsg->sipApiMsg.sipMsg.sipHdrFrom.params.para[0].para.paraStr; + + for (i = 0; i < SIP_UA_MAX_NUM_OF_PORT; i++) + { + if (sipUaPort[i].flag != 1) + continue; + + if ((strcmp(sipUaPort[i].callStruct.callId.value, callId->value) == 0) + && (strcmp(sipUaPort[i].callStruct.callId.host, callId->host) == 0) + && (strcmp(sipUaPort[i].callStruct.fromTag, fromTag) == 0)) + return i; + } + + return -1; +} + +int sip_ua_allocate_port_for_req(BYTE method, SIP_API_STRUCT *sipApiMsg) +{ + int port; + + if (((sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] & SIP_HDR_EXPIRES_MASK) == SIP_HDR_EXPIRES_MASK) + && (sipApiMsg->sipApiMsg.sipMsg.sipHdrExpires.value == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_allocate_port_for_req:expier value is 0\r\n"); + sip_log_err(sipAsciTempBuf); + return -2; + } + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_allocate_port_for_req:no enough resource\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_INDICATE; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_IDLE; + + if ((sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] & SIP_HDR_EXPIRES_MASK) == SIP_HDR_EXPIRES_MASK) + { + sipUaPort[port].sipuafTimer = (sipApiMsg->sipApiMsg.sipMsg.sipHdrExpires.value * 100); + } + else + { + sipUaPort[port].sipuafTimer = SIP_UA_FSM_TIMER; + } + + sipUaPort[port].rcvCmd = method; + + return port; +} + +int sip_ua_sip_recv_proc(WORD sipPort, WORD upPort, BYTE transFlag, SIP_API_STRUCT *sipApiMsg) +{ + int ret; +// int sapIndex; + WORD dialogId; + BYTE method; + int statusCode; + SIP_API_STRUCT sdSipMsg; + int port; + DWORD usrPort; + pal_cg_struct *cg; + char *localDomain; + char *destDomain; + SIP_EVENTHANDLE_STRUCT *event_handle = NULL; + + if (sipApiMsg == NULL) + return -1; + + localDomain = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.requestUri.host.addr.domain; + destDomain = sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.head].url.domain; + + memset(&sipUaRecvMsg, 0, sizeof(SIP_API_STRUCT)); + + switch(transFlag) + { + case SIP_TRANSPORT_LAYER: + if (sipApiMsg->sipApiType == SIP_API_REQ_MSG) + { +/* if ((sapIndex = sip_ua_select_user_by_domain(sipApiMsg)) < 0) + { + sprintf(sipAsciTempBuf, "sip ua recv msg can not find user\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + }*/ + + if ((cg = (pal_cg_struct *)pal_sip_find_cg(localDomain, destDomain)) == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv: can not find cg!\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if ((dialogId = sip_ua_match_dialog_with_req(sipApiMsg)) >= SIP_UA_MAX_NUM_OF_DIALOG) + dialogId = SIP_UA_NULL_DIALOG; + + method = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod; + + if ((method == SIP_METHOD_INVITE) && (dialogId <= SIP_UA_MAX_NUM_OF_DIALOG)) + { + sprintf((char *)sipAsciTempBuf, "sip ua recv retransmitted invite\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + + if (((method == SIP_METHOD_RE_INVITE) || (method == SIP_METHOD_CANCEL) || (method == SIP_METHOD_ACK) || (method == SIP_METHOD_BYE) || (method == SIP_METHOD_INFO)) + && (dialogId == SIP_UA_NULL_DIALOG)) + { + if (method != SIP_METHOD_ACK) + { + memcpy(&sdSipMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + sdSipMsg.sipApiType = SIP_API_RES_MSG; + sdSipMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = 481; + strcpy(sdSipMsg.sipApiMsg.sipMsg.sipStartLine.reasonPhrase, "Call/Transaction Does Not Exist"); + sdSipMsg.sipApiMsg.sipMsg.sipEntity.sipHdrContentLength = 0; + sdSipMsg.sipApiMsg.sipMsg.sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK + | SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + + sdSipMsg.sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] = 0; + sip_send_msg(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sdSipMsg); + } + + sprintf((char *)sipAsciTempBuf, "sip ua recv a inside msg without relational dialog\r\n"); + sip_log_err(sipAsciTempBuf); + return -7; + } + + if (dialogId < SIP_UA_NULL_DIALOG) + { + if ((method != SIP_METHOD_ACK) && (method != SIP_METHOD_CANCEL)) + { + if ((ret =sip_ua_update_dialog_with_req(dialogId, sipApiMsg)) < 0) + { + if (ret == -2) + { + //need forward develop + memset(&sdSipMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sdSipMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + sdSipMsg.sipApiType = SIP_API_RES_MSG; + sdSipMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = 500; + strcpy( sdSipMsg.sipApiMsg.sipMsg.sipStartLine.reasonPhrase, "Server Internal Error"); + sdSipMsg.sipApiMsg.sipMsg.sipEntity.sipHdrContentLength = 0; + sdSipMsg.sipApiMsg.sipMsg.sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + sdSipMsg.sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] = 0; + sip_send_msg(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sdSipMsg); + } + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:update dialog with req failed, ret=%d\r\n", ret); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + else + { + if (sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.value != sipUaDialog[dialogId].remoteInvCseq) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:ack or cancel cseq is not equal to invite\r\n"); + sip_log_err(sipAsciTempBuf); + return -6; + } + } + } + + if (method != SIP_METHOD_ACK) + { + if (method == SIP_METHOD_INVITE) + { + if (sip_ua_check_retransmit_invit(sipApiMsg) >= 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:retransmit invit already in progress\r\n"); + sip_log_err(sipAsciTempBuf); + return 0; + } + } + + if ((port = sip_ua_allocate_port_for_req(method, sipApiMsg)) < 0) + { + if (port == -2) + { + memset(&sdSipMsg, 0, sizeof(SIP_API_STRUCT)); + memcpy(&sdSipMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + sdSipMsg.sipApiType = SIP_API_RES_MSG; + sdSipMsg.sipApiMsg.sipMsg.sipStartLine.statusCode = 487; + strcpy(sdSipMsg.sipApiMsg.sipMsg.sipStartLine.reasonPhrase, "Request Terminated"); + sdSipMsg.sipApiMsg.sipMsg.sipEntity.sipHdrContentLength = 0; + sdSipMsg.sipApiMsg.sipMsg.sipGenHdrFlag[0] = SIP_HDR_CALL_ID_MASK | SIP_HDR_CSEQ_MASK | + SIP_HDR_FROM_MASK | SIP_HDR_TO_MASK | SIP_HDR_VIA_MASK; + sdSipMsg.sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] = 0; + sip_send_msg(SIP_NULL_TRANS_ID, SIP_NULL_UP_PORT, SIP_TRANSPORT_LAYER, &sdSipMsg); + } + else + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:no enough resource\r\n"); + sip_log_err(sipAsciTempBuf); + } + return -1; + } + + if (method == SIP_METHOD_INVITE) + { + memcpy(&sipUaPort[port].callStruct.callId, &sipApiMsg->sipApiMsg.sipMsg.sipHdrCallId, sizeof(SIP_HDR_CALL_ID)); + strcpy(sipUaPort[port].callStruct.fromTag, sipApiMsg->sipApiMsg.sipMsg.sipHdrFrom.params.para[0].para.paraStr); + +/* cg = pal_sip_find_cg(sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.head].url.host.addr.domain); + + if (cg == NULL) + { + sprintf(sipAsciTempBuf, "sip_ua_sip_recv: Invite req can not find cg!\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + }*/ + + sip_ua_set_inv_temp_rsp(port, sipApiMsg); + + usrPort = SIP_UA_NULL_UP_PORT; + } + else + { + if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + usrPort = sipUaDialog[dialogId].usrPort; + sipUaDialog[dialogId].sipUaPort = port; + } + else + { + usrPort = SIP_UA_NULL_UP_PORT; + } +// cg = NULL; + } + + event_handle = (SIP_EVENTHANDLE_STRUCT *)pal_get_handler(cg->id); + event_handle->recv_req(port, usrPort, dialogId, method, sipApiMsg, cg); +// sipUaSaps[sapIndex].sipUaSap.recv_req(port, usrPort, dialogId, method, sipApiMsg, cg); + } + else + { + if (sipUaDialog[dialogId].uaPort >= SIP_UA_MAX_NUM_OF_PORT) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:recv ack, but no port in dialog to proc inv rsp\r\n"); + sip_log_err(sipAsciTempBuf); + return -3; + } + + sipUaPort[sipUaDialog[dialogId].uaPort].rcvCmd = SIP_METHOD_ACK; + + memcpy(&sipUaRecvMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_fsm(sipUaDialog[dialogId].uaPort); + } + + } + else + { + if ((sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.method == SIP_METHOD_INVITE) && (sipApiMsg->sipApiMsg.sipMsg.sipStartLine.statusCode == 200) + && ((dialogId = sip_ua_match_dialog_with_rsp(sipApiMsg)) < SIP_UA_MAX_NUM_OF_DIALOG)) + { + if (sipUaDialog[dialogId].uaAckPort >= SIP_UA_MAX_NUM_OF_PORT) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:recv retransmitted 200, no ack proc port in dialog\r\n"); + sip_log_err(sipAsciTempBuf); + return -5; + } + + sipUaPort[sipUaDialog[dialogId].uaAckPort].rcvCmd = 200; + + memcpy(&sipUaRecvMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_fsm(sipUaDialog[dialogId].uaAckPort); + } + else + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:recv rsp from transport layer\r\n"); + sip_log_err(sipAsciTempBuf); + return -4; + } + } + + break; + case SIP_TRANSACTION_LAYER: + if ((upPort >= SIP_UA_MAX_NUM_OF_PORT) || (sipUaPort[upPort].flag != 1)) + { + return -1; + } + + if (sipApiMsg->sipApiType == SIP_API_REQ_MSG) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:recv req from transaction layer\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + else + { + if ((dialogId = sip_ua_match_dialog_with_rsp(sipApiMsg)) >= SIP_UA_MAX_NUM_OF_DIALOG) + dialogId = SIP_UA_NULL_DIALOG; + + if (sipUaPort[upPort].dialogId != dialogId) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv:find dialog wrong\r\n"); + sip_log_err(sipAsciTempBuf); + dialogId = sipUaPort[upPort].dialogId; +// return -1; + } + + if ((dialogId < SIP_UA_MAX_NUM_OF_DIALOG) && (sipUaPort[upPort].cgId != sipUaDialog[dialogId].cgId))//sipUaPort[upPort].sapIndex != sipUaDialog[dialogId].userIndex + { + sprintf((char *)sipAsciTempBuf, "sip_ua_sip_recv: cg id wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + statusCode = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.statusCode; + + sipUaPort[upPort].rcvCmd= statusCode; + + memcpy(&sipUaRecvMsg, sipApiMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_fsm(upPort); + } + + break; + default: + return -1; + } + + return 0; +} + +int sip_ua_init_dialog(WORD dialogId) +{ + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + return -1; + } + + memset(&sipUaDialog[dialogId], 0, sizeof(SIP_DIALOG)); + sipUaDialog[dialogId].uaPort = 0xFFFF; + sipUaDialog[dialogId].uaAckPort = 0xFFFF; + + return 0; +} + +int sip_ua_init_port(WORD port) +{ + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return -1; + } + + memset(&sipUaPort[port], 0, sizeof(SIP_UA_PORT)); + sipUaPort[port].dialogId = SIP_UA_NULL_DIALOG; + sipUaPort[port].llPort = 0xFFFF; + sipUaPort[port].usrPort = 0xFFFF; + + return 0; +} + +void sip_ua_timer() +{ + WORD port; + + for (port = 0; port < SIP_UA_MAX_NUM_OF_PORT; port++) + { + if (sipUaPort[port].flag == 0) + continue; + + sip_ua_fsm(port); + } + + sip_t10ms(); +} + +int sip_ua_regist_in_sip() +{ + sipUaSipUser.proxyType= SIP_PROXY_TYPE_NONE; + strcpy(sipUaSipUser.userName, "SIP_UA"); + strcpy(sipUaSipUser.domain, sipUaDottedHostIp); + sipUaSipUser.recv_proc = sip_ua_sip_recv_proc; + + if ((sipUaSipIndex = sip_register_user(&sipUaSipUser)) < 0) + { + printf("SIP UA Module register in SIP Module Failed\r\n"); + return -1; + } + + return 0; +} + +int sip_ua_init() +{ + WORD i; + + printf("SIP UA Module Init Start!\n"); + + if (sip_ua_get_local_ip() < 0) + exit(1); + + if (sip_ua_regist_in_sip() < 0) + { + printf("SIP UA Module regist in sip fail\r\n"); + } + + sipUaPortSelect = 0; + sipUaDialogSelect = 0; + + for (i = 0; i < SIP_UA_MAX_NUM_OF_DIALOG; i++) + { + sip_ua_init_dialog(i); + } + + for (i = 0; i < SIP_UA_MAX_NUM_OF_PORT; i++) + { + sip_ua_init_port(i); + } + + memset((BYTE *)&sipUaSaps[0], 0, sizeof(SIP_UA_SAPS) * SIP_UA_MAX_NUM_OF_SAP); + + memset((BYTE *)&sipUaRecvMsg, 0, sizeof(SIP_API_STRUCT)); + + printf("SIP UA Module Init Complete!\n"); + + return 0; +} + +/*int sip_ua_bind(SIP_UA_SAP *sap) +{ + BYTE sapIndex; + + if ((sap == NULL) || (sap->recv_req == NULL) || (sap->recv_resp == NULL) + || (sap->proxyType != SIP_PROXY_TYPE_NONE)) + { + sprintf(sipAsciTempBuf, "sip_ua_bind:sap malformed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + for (sapIndex = 0; sapIndex < SIP_UA_MAX_NUM_OF_SAP; sapIndex++) + { + if ((sipUaSaps[sapIndex].flag == 1) && + (strcmp(sipUaSaps[sapIndex].sipUaSap.userName, sap->userName) == 0)) + { + memcpy(&sipUaSaps[sapIndex].sipUaSap, sap, sizeof(SIP_UA_SAP)); + + if (sip_store_sip_ua_user(sapIndex, sap->domain) < 0) + { + sprintf(sipAsciTempBuf, "sip_ua_bind:sip store sip ua user failed!\r\n"); + sip_log_err(sipAsciTempBuf); + } + + return sapIndex; + } + } + + for (sapIndex = 0; sapIndex < SIP_UA_MAX_NUM_OF_SAP; sapIndex++) + { + if (sipUaSaps[sapIndex].flag != 0) + continue; + + sipUaSaps[sapIndex].flag = 1; + + memcpy((BYTE *)&sipUaSaps[sapIndex].sipUaSap, sap, sizeof(SIP_UA_SAP)); + + if (sip_store_sip_ua_user(sapIndex, sap->domain) < 0) + { + sprintf(sipAsciTempBuf, "sip_ua_bind:sip store sip ua user failed\r\n"); + sip_log_err(sipAsciTempBuf); + } + + return sapIndex; + } + + sprintf(sipAsciTempBuf, "sip ua user bind fail\r\n"); + sip_log_err(sipAsciTempBuf); + + return -1; +}*/ diff --git a/omc/plat/sip/src/sip_ua_dialog.c b/omc/plat/sip/src/sip_ua_dialog.c new file mode 100644 index 0000000..00fe1b3 --- /dev/null +++ b/omc/plat/sip/src/sip_ua_dialog.c @@ -0,0 +1,336 @@ +#include "./include/sip_ua_pub.h" +#include "./include/sip.h" +#include "./include/sip_ua_dialog.h" +#include "./include/sip_ua_const.h" +#include "./include/sip_ua_ext.h" +#include "./include/sip_ext.h" +#include "./include/sip_debug.h" + +int sip_ua_create_tag(WORD dialogId) +{ + struct timeval tv; + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + return -1; + + gettimeofday(&tv, NULL); + + sprintf(sipUaDialog[dialogId].localTag, "%X%lX%lX", dialogId, tv.tv_sec, tv.tv_usec); + + return 0; +} + +int sip_ua_create_call_id(WORD usrPort, WORD dialogId) +{ + struct timeval tv; + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + return -1; + + gettimeofday(&tv, NULL); + + sprintf(sipUaDialog[dialogId].callId.value, "%X%lX%lX", usrPort, tv.tv_usec, tv.tv_sec); + strcpy(sipUaDialog[dialogId].callId.host, sipUaDottedHostIp); + + return 0; +} + +void sip_ua_fill_dialog_uri(SIP_UA_URI *sipUaUri, SIP_URI *sipUri) +{ + if ((sipUaUri == NULL) || (sipUri == NULL)) + return; + + sipUaUri->uriType = sipUri->uriType; + strcpy(sipUaUri->userName, sipUri->userName); + strcpy(sipUaUri->password, sipUri->password); + strcpy(sipUaUri->domain, sipUri->host.addr.domain); +} + +int sip_ua_set_dialog_state(WORD dialogId, BYTE state) +{ + if ((dialogId>= SIP_UA_MAX_NUM_OF_DIALOG) || (sipUaDialog[dialogId].flag == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_set_dialog_state: dialogId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipUaDialog[dialogId].state = state; + + return 0; +} + +int sip_ua_update_dialog_with_req(WORD dialogId, SIP_API_STRUCT *sipApiMsg) +{ + SIP_DIALOG *sipUaDlgPtr; + BYTE method; + + if (sipApiMsg == NULL) + { + return -1; + } + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sipUaDialog[dialogId].flag == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_update_dialog_with_req:dialogId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipUaDlgPtr = &sipUaDialog[dialogId]; + method = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod; + +/* if (method == SIP_METHOD_INVITE) + { + strcpy(sipUaDlgPtr->invBranch, sipApiMsg->sipApiMsg.sipMsg.sipHdrVias.vias[1].params.para[0].para.paraStr); + }//for cancel*/ + + if ((method != SIP_METHOD_ACK) && (method != SIP_METHOD_CANCEL)) + { + if (sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.value <= sipUaDlgPtr->remoteCseq.value) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_update_dialog_with_req:req seq is less than seq in dialog\r\n"); + sip_log_err(sipAsciTempBuf); + return -2; + } + + sipUaDlgPtr->remoteCseq.value = sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.value; + } + + if ((method == SIP_METHOD_RE_INVITE) + || ((method == SIP_METHOD_ACK) && ((sipUaDlgPtr->paramFlag & SIP_UA_DIALOG_REMOTE_TARGET_FLAG) != SIP_UA_DIALOG_REMOTE_TARGET_FLAG))) + { + if ((sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] & SIP_HDR_CONTACT_MASK) == SIP_HDR_CONTACT_MASK) + { + sip_ua_fill_dialog_uri(&sipUaDlgPtr->remoteTarget, &sipApiMsg->sipApiMsg.sipMsg.sipHdrContacts.contacts[sipApiMsg->sipApiMsg.sipMsg.sipHdrContacts.head].url); + sipUaDlgPtr->paramFlag |= SIP_UA_DIALOG_REMOTE_TARGET_FLAG; + } + } + + return 0; +} + +int sip_ua_update_dialog_with_rsp(WORD dialogId, SIP_API_STRUCT * sipApiMsg, BYTE flag) +{ + SIP_DIALOG *sipUaDlgPtr; + BYTE head; + BYTE num; + int i; + BYTE method; + BYTE endHead; + + if (sipApiMsg == NULL) + { + return -1; + } + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sipUaDialog[dialogId].flag == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_update_dialog_with_rsp: dialogId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + method = sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.method; + sipUaDlgPtr = &sipUaDialog[dialogId]; + + if (sipApiMsg->sipApiMsg.sipMsg.sipHdrCseq.value != sipUaDlgPtr->localCseq.value) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_update_dialog_with_rsp: rsp seq is not equal to seq in dialog\r\n"); + sip_log_err(sipAsciTempBuf); + return -2; + } + + if ((method != SIP_METHOD_INVITE) && (method != SIP_METHOD_RE_INVITE)) + { + return -1; + } + + if (flag == 1) + strcpy(sipUaDlgPtr->remoteTag, sipApiMsg->sipApiMsg.sipMsg.sipHdrTo.params.para[0].para.paraStr); + + if ((method == SIP_METHOD_INVITE) && ((sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] & SIP_HDR_RECORD_ROUTE_MASK) == SIP_HDR_RECORD_ROUTE_MASK)) + { + head = sipApiMsg->sipApiMsg.sipMsg.sipHdrRecordRoutes.head; + sipUaDlgPtr->routeSets.num = endHead = num = sipApiMsg->sipApiMsg.sipMsg.sipHdrRecordRoutes.num; + + for (i = 0; i < num; i++) + { + --endHead; + + memcpy(&sipUaDlgPtr->routeSets.recRoutes[endHead], &sipApiMsg->sipApiMsg.sipMsg.sipHdrRecordRoutes.recRoutes[head], sizeof(SIP_HDR_RECORD_ROUTE)); + + if (++head >= SIP_MAX_NUM_OF_RECORD_ROUTES) + head = 0; + } + + sipUaDlgPtr->routeSets.head = 0; + } + + if ((sipApiMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] & SIP_HDR_CONTACT_MASK) == SIP_HDR_CONTACT_MASK) + { + sip_ua_fill_dialog_uri(&sipUaDlgPtr->remoteTarget, &sipApiMsg->sipApiMsg.sipMsg.sipHdrContacts.contacts[sipApiMsg->sipApiMsg.sipMsg.sipHdrContacts.head].url); + sipUaDlgPtr->paramFlag |= SIP_UA_DIALOG_REMOTE_TARGET_FLAG; + } + + return 0; +} + +int sip_ua_init_dialog_as_client_with_inv(BYTE cgId, WORD usrPort, SIP_MSG *sipMsg)//sapIndex +{ + WORD dialogId = sipUaDialogSelect; + int i; + + if (sipMsg == NULL)//if ((sapIndex >= SIP_UA_MAX_NUM_OF_SAP) || (sipMsg == NULL)) + { + return -1; + } + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + dialogId = 0; + } + + for (i = 0; i < SIP_UA_MAX_NUM_OF_DIALOG; i++) + { + if (sipUaDialog[dialogId].flag == 1) + { + if (++dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + dialogId = 0; + + continue; + } + + sip_ua_init_dialog(dialogId); + sipUaDialog[dialogId].flag = 1; + sipUaDialog[dialogId].type = SIP_CALLER; + sipUaDialog[dialogId].cgId = cgId;//sipUaDialog[dialogId].userIndex = sapIndex; + sipUaDialog[dialogId].usrPort = usrPort; + sipUaDialog[dialogId].state = SIP_UA_DIALOG_IDLE; + + sip_ua_create_tag(dialogId); + sip_ua_create_call_id(usrPort, dialogId); + sipUaDialog[dialogId].invCSeq = sipUaDialog[dialogId].localCseq.value= 0; + sipUaDialog[dialogId].remoteCseq.value = 0; + + sip_ua_fill_dialog_uri(&sipUaDialog[dialogId].localURI, &sipMsg->sipHdrFrom.url); + sip_ua_fill_dialog_uri(&sipUaDialog[dialogId].remoteURI, &sipMsg->sipHdrTo.url); + + sipUaDialogSelect = (dialogId + 1) % SIP_UA_MAX_NUM_OF_DIALOG; + + return dialogId; + } + + sprintf((char *)sipAsciTempBuf, "client initial dialog with inv failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; +} + +int sip_ua_init_dialog_as_server_with_inv(BYTE cgId, WORD hdlPort, WORD usrPort, SIP_MSG *sipMsg)//BYTE sapIndex +{ + WORD dialogId = sipUaDialogSelect; + int i; + int j; + BYTE head; + + if (sipMsg == NULL)//if ((sapIndex >= SIP_UA_MAX_NUM_OF_SAP) || (sipMsg == NULL)) + { + return -1; + } + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + dialogId = 0; + } + + for (i = 0; i < SIP_UA_MAX_NUM_OF_DIALOG; i++) + { + if (sipUaDialog[dialogId].flag == 1) + { + if (++dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + dialogId = 0; + + continue; + } + + sip_ua_init_dialog(dialogId); + sipUaDialog[dialogId].flag = 1; + sipUaDialog[dialogId].type = SIP_CALLEE; + sipUaDialog[dialogId].cgId = cgId;//sipUaDialog[dialogId].userIndex = sapIndex; + sipUaDialog[dialogId].usrPort = usrPort; + sipUaDialog[dialogId].sipUaPort = hdlPort; + sipUaDialog[dialogId].invUaPort.rvInvUaPort = hdlPort; + sipUaDialog[dialogId].state = SIP_UA_DIALOG_IDLE; + + if (sipMsg->sipHdrTo.params.para[0].paraName == SIP_API_PNAME_TAG) + { + strcpy(sipUaDialog[dialogId].localTag, sipMsg->sipHdrTo.params.para[0].para.paraStr); + } + else + { + sip_ua_create_tag(dialogId); + } + + strcpy(sipUaDialog[dialogId].invBranch, sipMsg->sipHdrVias.vias[1].params.para[0].para.paraStr); + sipUaDialog[dialogId].invCSeq = sipUaDialog[dialogId].localCseq.value = 0; + sipUaDialog[dialogId].remoteCseq.value = sipUaDialog[dialogId].remoteInvCseq = sipMsg->sipHdrCseq.value; + memcpy(&sipUaDialog[dialogId].callId, &sipMsg->sipHdrCallId, sizeof(SIP_HDR_CALL_ID)); + sip_ua_fill_dialog_uri(&sipUaDialog[dialogId].localURI, &sipMsg->sipHdrTo.url); + sip_ua_fill_dialog_uri(&sipUaDialog[dialogId].remoteURI, &sipMsg->sipHdrFrom.url); + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_CONTACT_MASK) == SIP_HDR_CONTACT_MASK) + { + sip_ua_fill_dialog_uri(&sipUaDialog[dialogId].remoteTarget, &sipMsg->sipHdrContacts.contacts[sipMsg->sipHdrContacts.head].url); + sipUaDialog[dialogId].paramFlag |= SIP_UA_DIALOG_REMOTE_TARGET_FLAG; + } + + strcpy(sipUaDialog[dialogId].remoteTag, sipMsg->sipHdrFrom.params.para[0].para.paraStr); + + if ((sipMsg->sipGenHdrFlag[0] & SIP_HDR_RECORD_ROUTE_MASK) == SIP_HDR_RECORD_ROUTE_MASK) + { + sipUaDialog[dialogId].routeSets.num = sipMsg->sipHdrRecordRoutes.num; + sipUaDialog[dialogId].routeSets.head = 0; + head = sipMsg->sipHdrRecordRoutes.head; + + for (j = 0; j < sipMsg->sipHdrRecordRoutes.num; j++) + { + memcpy(&sipUaDialog[dialogId].routeSets.recRoutes[j], &sipMsg->sipHdrRecordRoutes.recRoutes[head], sizeof(SIP_HDR_RECORD_ROUTES)); + + if (++head >= SIP_MAX_NUM_OF_RECORD_ROUTES) + head = 0; + } + } + + sipUaDialogSelect = (dialogId + 1) % SIP_UA_MAX_NUM_OF_DIALOG; + + return dialogId; + } + + sprintf((char *)sipAsciTempBuf, "server initial dialog with inv failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; +} + +int sip_ua_free_dialog(DWORD usrPort, WORD dialogId) +{ + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + return -1; + } + + if (sipUaDialog[dialogId].flag != 1) + { + return -1; + } + + if (sipUaDialog[dialogId].usrPort != usrPort) + { + return -1; + } + + memset(&sipUaDialog[dialogId], 0, sizeof(SIP_DIALOG)); + sipUaDialog[dialogId].uaPort = 0xFFFF; + sipUaDialog[dialogId].uaAckPort = 0xFFFF; + + return 0; +} diff --git a/omc/plat/sip/src/sip_ua_fsm.c b/omc/plat/sip/src/sip_ua_fsm.c new file mode 100644 index 0000000..fcdf6e9 --- /dev/null +++ b/omc/plat/sip/src/sip_ua_fsm.c @@ -0,0 +1,628 @@ +#include "./include/sip_ua_pub.h" +#include "./include/sip.h" +#include "./include/sip_ua_const.h" +#include "./include/sip_ua_struct.h" +#include "./include/sip_ua_ext.h" +#include "./include/sip_ua_dialog.h" +#include "./include/sip_ua.h" +#include "./include/sip_ext.h" +#include "./include/sip_debug.h" + +extern int sip_ua_set_dialog_state(WORD dialogId, BYTE state); +extern int sip_ua_update_dialog_with_rsp(WORD dialogId, SIP_API_STRUCT * sipApiMsg, BYTE flag); + +WORD sip_ua_find_rsp_method(BYTE method, WORD resp) +{ + + switch(method) + { + case SIP_METHOD_INVITE: + if (resp == 180) + return SIP_METHOD_RESPONSE_INV_RINGING; + else if ((resp > 100) && (resp < 200)) + return SIP_METHOD_RESPONSE_INV_PROGRESS; + else if ((resp >= 200) && (resp < 300)) + return SIP_METHOD_RESPONSE_INV_CONFIRM; + else if ((resp >= 300) && (resp < 400)) + return SIP_METHOD_RESPONSE_INV_REDIR; + else + return SIP_METHOD_RESPONSE_INV_REL; + break; + case SIP_METHOD_RE_INVITE: + if (resp == 180) + return SIP_METHOD_RESPONSE_RE_INV_RINGING; + else if ((resp > 100) && (resp < 200)) + return SIP_METHOD_RESPONSE_RE_INV_PROGRESS; + else if ((resp >= 200) && (resp < 300)) + return SIP_METHOD_RESPONSE_RE_INV_CONFIRM; + else if (resp == 491) + return SIP_METHOD_RESPONSE_RE_INV_RETRANSMIT; + else if ((481 == resp) || (408 == resp) || (99 == resp)) + return SIP_METHOD_RESPONSE_RE_INV_RELEASE; + else + return SIP_METHOD_RESPONSE_RE_INV_FAILED; + break; + case SIP_METHOD_UPDATE: + if ((resp >= 200) && (resp < 300)) + return SIP_METHOD_RESPONSE_UPDATE_CONFIRM; + else + return SIP_METHOD_RESPONSE_UPDATE_FAILED; + break; + case SIP_METHOD_CANCEL: + return SIP_METHOD_RESPONSE_CANCEL; + break; + case SIP_METHOD_BYE: + return SIP_METHOD_RESPONSE_BYE; + break; + default: + if ((resp >= 200) && (resp < 300)) + return SIP_METHOD_RESPONSE_CONFIRM; + else + return SIP_METHOD_RESPONSE_REL; + break; + } + + return 0; +} + +void sip_ua_fsm(WORD port); + +DWORD sip_ua_min(DWORD A, DWORD B) +{ + if (A <= B) + return A; + + return B; +} + +int sip_ua_inv_req_proc(WORD port) +{ + WORD rvCmd; + WORD rspMethod; + WORD sdCmd; + SIP_UA_PORT *sipUaPortPtr; + BYTE cgId;//BYTE sapIndex; + WORD usrPort; + WORD dialogId; + WORD sipTransId; + BYTE sdMethod; + SIP_API_STRUCT *sipApiMsg; + SIP_EVENTHANDLE_STRUCT *event_handle = NULL; + + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return -1; + } + + sipUaPortPtr = &sipUaPort[port]; + rvCmd = sipUaPortPtr->rcvCmd; + sipTransId = sipUaPortPtr->llPort; + sdCmd = sipUaPortPtr->sdCmd; + cgId = sipUaPortPtr->cgId;//sapIndex = sipUaPortPtr->sapIndex; + dialogId = sipUaPortPtr->dialogId; + usrPort = sipUaPortPtr->usrPort; + + if ((event_handle = (SIP_EVENTHANDLE_STRUCT *)pal_get_handler(cgId)) == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_inv_req_proc: can not find handle function!\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + switch (sipUaPortPtr->state) + { + case SIP_UA_SEND_REQUEST: + if (sdCmd != SIP_UA_SEND_COM_NULL) + { + sipUaPortPtr->sdCmd = SIP_UA_SEND_COM_NULL; + sipApiMsg = &sipUaPortPtr->sdSipMsg; + + if (sip_send_msg(sipTransId, port, SIP_TRANSACTION_LAYER, sipApiMsg) < 0) + return 1; + + sipUaPortPtr->state = SIP_UA_REQ_WAIT_FOR_RSP; + sipUaPortPtr->timer = SIP_UA_TIMER_WAIT_INV_RSP; + } + break; + case SIP_UA_REQ_WAIT_FOR_RSP: + if (rvCmd != SIP_UA_RECV_COM_NULL) + { + sdMethod = sipUaPortPtr->sdSipMsg.sipApiMsg.sipMsg.sipStartLine.sipMethod; + + sipUaPortPtr->rcvCmd = SIP_UA_RECV_COM_NULL; + +/* if (sapIndex >= SIP_UA_MAX_NUM_OF_SAP) + { + return 1; + }*/ + + rspMethod = sip_ua_find_rsp_method(sdMethod, rvCmd); + + if ((rvCmd >= 200) && (rvCmd < 300)) + { + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_CONFIRMED); + sip_ua_update_dialog_with_rsp(dialogId, &sipUaRecvMsg, 1); + event_handle->recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); + return 1; + } + else if ((rvCmd >= 100) && (rvCmd < 200)) + { + if (rvCmd != 100) + { + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_EARLY); + sip_ua_update_dialog_with_rsp(dialogId, &sipUaRecvMsg, 1); + sipUaPortPtr->timer = SIP_UA_TIMER_WAIT_INV_200_RSP; + event_handle->recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); + } + + return 0; + } + else + { + if ((sdMethod == SIP_METHOD_RE_INVITE) && (rspMethod != SIP_METHOD_RESPONSE_RE_INV_RELEASE)) + { + return 1; + } + + sipUaPortPtr->state = SIP_UA_INV_REQ_TERMINATED; + sipUaPortPtr->timer = SIP_UA_TIMER_T3; + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_DESTROY); + event_handle->recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); + return 0; + } + } + + if (sipUaPortPtr->timer > 0) + { + if (--sipUaPortPtr->timer == 0) + { + event_handle->recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); + sip_ua_init_dialog(dialogId); + return 1; + } + } + break; + case SIP_UA_INV_REQ_TERMINATED: + if (sipUaPortPtr->timer > 0) + { + if (--sipUaPortPtr->timer == 0) + { + sip_ua_init_dialog(dialogId); + return 1; + } + } + break; + default: + return 1; + } + + return 0; +} + +int sip_ua_non_inv_req_proc(WORD port) +{ + WORD rvCmd; + WORD rspMethod; + WORD sdCmd; + SIP_UA_PORT *sipUaPortPtr; + BYTE cgId;//BYTE sapIndex; + WORD usrPort; + WORD dialogId; + WORD sipTransId; + SIP_API_STRUCT *sipApiMsg; + BYTE sdMethod; + SIP_EVENTHANDLE_STRUCT *event_handle = NULL; + + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return -1; + } + + sipUaPortPtr = &sipUaPort[port]; + sdCmd = sipUaPortPtr->sdCmd; + rvCmd = sipUaPortPtr->rcvCmd; + sipTransId = sipUaPortPtr->llPort; + cgId = sipUaPortPtr->cgId;//sapIndex = sipUaPortPtr->sapIndex; + dialogId = sipUaPortPtr->dialogId; + usrPort = sipUaPortPtr->usrPort; + + if ((event_handle = (SIP_EVENTHANDLE_STRUCT *)pal_get_handler(cgId)) == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_non_inv_req_proc: can not find handle function!\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + switch (sipUaPortPtr->state) + { + case SIP_UA_SEND_REQUEST: + if (sdCmd != SIP_UA_SEND_COM_NULL) + { + sipApiMsg = &sipUaPortPtr->sdSipMsg; + sipUaPortPtr->sdCmd = SIP_UA_SEND_COM_NULL; + + if (sip_send_msg(sipTransId, port, SIP_TRANSACTION_LAYER, sipApiMsg) < 0) + return 1; + + if (sipApiMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod == SIP_METHOD_ACK) + { + sipUaPortPtr->timer2 = SIP_UA_TIMER_T1; + } + + sipUaPortPtr->state = SIP_UA_REQ_WAIT_FOR_RSP; + sipUaPortPtr->timer = SIP_UA_TIMER_WAIT_NON_INV_RSP; + } + break; + case SIP_UA_REQ_WAIT_FOR_RSP: + sdMethod = sipUaPortPtr->sdSipMsg.sipApiMsg.sipMsg.sipStartLine.sipMethod; + + if (rvCmd != SIP_UA_RECV_COM_NULL) + { + sipUaPortPtr->rcvCmd = SIP_UA_RECV_COM_NULL; + +/* if (sapIndex >= SIP_UA_MAX_NUM_OF_SAP) + { + return 1; + }*/ + + rspMethod = sip_ua_find_rsp_method(sdMethod, rvCmd); + + if (sdMethod == SIP_METHOD_ACK) + { + if ((rvCmd == 200) && (sipUaRecvMsg.sipApiMsg.sipMsg.sipHdrCseq.method == SIP_METHOD_INVITE)) + { + sip_ua_update_dialog_with_rsp(dialogId, &sipUaRecvMsg, 1);//need forward + sip_ua_update_retransmit_para(dialogId, &sipUaPortPtr->sdSipMsg); + sip_send_msg(sipTransId, port, SIP_TRANSPORT_LAYER, &sipUaPortPtr->sdSipMsg); + } + } + else if (sdMethod == SIP_METHOD_BYE) + { + event_handle->recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); + sip_ua_init_dialog(dialogId); + return 1; + } + else if ((rvCmd >= 200) || (rvCmd <= SIP_TRANSACTION_TIMEOUT)) + { + event_handle->recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, rspMethod, &sipUaRecvMsg); + return 1; + } + } + + if (sdMethod == SIP_METHOD_ACK) + { + if ((sipUaPortPtr->timer2 > 0)) + { + if (--sipUaPortPtr->timer2 == 0) + return 1; + } + + return 0; + } + + if (sipUaPortPtr->timer > 0) + { + if (--sipUaPortPtr->timer == 0) + { + event_handle->recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); + + if (sdMethod == SIP_METHOD_BYE) + sip_ua_init_dialog(dialogId); + + return 1; + } + } + break; + default: + return 1; + } + + return 0; +} + +int sip_ua_inv_rsp_proc(WORD port) +{ + WORD rvCmd; + WORD sdCmd; + SIP_UA_PORT *sipUaPortPtr; + BYTE cgId;//BYTE sapIndex; + WORD usrPort; + WORD dialogId; + WORD sipTransId; + BYTE sdMethod; + SIP_API_STRUCT *sipApiMsg; + SIP_EVENTHANDLE_STRUCT *event_handle = NULL; + + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return -1; + } + + sipUaPortPtr = &sipUaPort[port]; + cgId = sipUaPortPtr->cgId;//sapIndex = sipUaPortPtr->sapIndex; + usrPort = sipUaPortPtr->usrPort; + rvCmd = sipUaPortPtr->rcvCmd; + sdCmd = sipUaPortPtr->sdCmd; + sipTransId = sipUaPortPtr->llPort; + sipApiMsg = &sipUaPortPtr->sdSipMsg; + dialogId = sipUaPortPtr->dialogId; + + if ((event_handle = (SIP_EVENTHANDLE_STRUCT *)pal_get_handler(cgId)) == NULL) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_non_inv_req_proc: can not find handle function!\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + switch (sipUaPortPtr->state) + { + case SIP_UA_SEND_RESPONSE: + if (sdCmd != SIP_UA_SEND_COM_NULL) + { + sipUaPortPtr->sdCmd = SIP_UA_SEND_COM_NULL; + sdMethod = sipApiMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod; + + if (sip_send_msg(sipTransId, port, SIP_TRANSACTION_LAYER, sipApiMsg) < 0) + return 1; + + if ((sdCmd > 100) && (sdCmd < 200)) + { + if (sdMethod == SIP_METHOD_INVITE) + { + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_EARLY); + } + } + else if ((sdCmd >= 200) && (sdCmd < 300)) + { + if (sdMethod == SIP_METHOD_INVITE) + { + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_CONFIRMED); + } + sipUaPortPtr->state = SIP_UA_INV_200_RSP_WAIT_FOR_ACK; + + sipUaPortPtr->retrans200Times = 0; + sipUaPortPtr->timer = SIP_UA_TIMER_WAIT_ACK; + sipUaPortPtr->waitAckTimer = SIP_UA_TIMER_RETRANSMIT_200; + } + else if (sdCmd >= 300) + { + if ((sdMethod == SIP_METHOD_RE_INVITE) && (sdCmd != 481) && (sdCmd != 408)) + { + return 1; + } + else + { + sipUaPortPtr->state = SIP_UA_INV_RSP_TERMINATED; + sipUaPortPtr->timer = SIP_UA_TIMER_T2; + sip_ua_set_dialog_state(dialogId, SIP_UA_DIALOG_DESTROY); + } + } + } + + if ((sipUaPortPtr->state == SIP_UA_SEND_RESPONSE) && (sipUaPortPtr->timer > 0)) + { + if (--sipUaPortPtr->timer == 0) + { + sip_ua_init_dialog(dialogId); + return 1; + } + } + break; + case SIP_UA_INV_200_RSP_WAIT_FOR_ACK: + if (rvCmd != SIP_UA_RECV_COM_NULL) + { + sipUaPortPtr->rcvCmd= SIP_UA_RECV_COM_NULL; + +/* if (sapIndex >= SIP_UA_MAX_NUM_OF_SAP) + { + return -1; + }*/ + + if (rvCmd == SIP_METHOD_ACK) + { + event_handle->recv_req(port, usrPort, dialogId, rvCmd, &sipUaRecvMsg, NULL); +// sipUaSaps[sapIndex].sipUaSap.recv_req(port, usrPort, dialogId, rvCmd, &sipUaRecvMsg, NULL); + return 1; + } + } + + if (sipUaPortPtr->waitAckTimer > 0) + { + if (--sipUaPortPtr->waitAckTimer == 0) + { + sip_send_msg(sipTransId, port, SIP_TRANSPORT_LAYER, sipApiMsg); + sipUaPortPtr->retrans200Times++; + sipUaPortPtr->waitAckTimer = sip_ua_min((1 << sipUaPortPtr->retrans200Times) * SIP_UA_TIMER_RETRANSMIT_200, SIP_UA_TIMER_T1); + } + } + + if (sipUaPortPtr->timer > 0) + { + if (--sipUaPortPtr->timer == 0) + { + //need forward develop send bye + event_handle->recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); +// sipUaSaps[sapIndex].sipUaSap.recv_resp(usrPort, dialogId, SIP_METHOD_RESPONSE_TIMEOUT, NULL); + return 1; + } + } + break; + case SIP_UA_INV_RSP_TERMINATED: + if (sipUaPortPtr->timer > 0) + { + if (--sipUaPortPtr->timer == 0) + { + sip_ua_init_dialog(dialogId); + return 1; + } + } + break; + default: + return 1; + } + + return 0; + +} + +int sip_ua_non_inv_rsp_proc(WORD port) +{ + WORD rvCmd; + WORD sdCmd; + SIP_UA_PORT *sipUaPortPtr; + WORD sipTransId; + SIP_API_STRUCT *sipApiMsg; + + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return -1; + } + + sipUaPortPtr = &sipUaPort[port]; + rvCmd = sipUaPortPtr->rcvCmd; + sdCmd = sipUaPortPtr->sdCmd; + sipTransId = sipUaPortPtr->llPort; + sipApiMsg = &sipUaPortPtr->sdSipMsg; + + switch (sipUaPortPtr->state) + { + case SIP_UA_SEND_RESPONSE: + if (sdCmd != SIP_UA_SEND_COM_NULL) + { + sipUaPortPtr->sdCmd = SIP_UA_SEND_COM_NULL; + + sip_send_msg(sipTransId, port, SIP_TRANSACTION_LAYER, sipApiMsg); + + return 1; + } + break; + default: + return 1; + } + return 0; +} + +void sip_ua_fsm_request(WORD port) +{ + switch (sipUaPort[port].mainState) + { + case SIP_UA_MAIN_STATE_INVITE_REQ: + switch (sip_ua_inv_req_proc(port)) + { + case 0: + break; + case 1: + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INIT; + sip_ua_fsm(port); + break; + default: + break; + } + break; + case SIP_UA_MAIN_STATE_NON_INVITE_REQ: + switch (sip_ua_non_inv_req_proc(port)) + { + case 0: + break; + case 1: + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INIT; + sip_ua_fsm(port); + break; + default: + break; + } + break; + case SIP_UA_MAIN_STATE_INIT: + sip_ua_init_port(port); + break; + } +} + +void sip_ua_fsm_indicate(WORD port) +{ + switch (sipUaPort[port].mainState) + { + case SIP_UA_MAIN_STATE_IDLE: + if (sipUaPort[port].sdCmd != 0) + { + if ((sipUaPort[port].rcvCmd == SIP_METHOD_INVITE) || (sipUaPort[port].rcvCmd == SIP_METHOD_RE_INVITE)) + { + sipUaPort[port].rcvCmd = SIP_UA_RECV_COM_NULL; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INVITE_RSP; + } + else + { + sipUaPort[port].rcvCmd = SIP_UA_RECV_COM_NULL; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_NON_INVITE_RSP; + } + sip_ua_fsm(port); + break; + } + + if (sipUaPort[port].sipuafTimer > 0) + { + if (--sipUaPort[port].sipuafTimer == 0) + { + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INIT; + sip_ua_fsm(port); + } + } + break; + case SIP_UA_MAIN_STATE_INVITE_RSP: + switch (sip_ua_inv_rsp_proc(port)) + { + case 0: + break; + case 1: + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INIT; + sip_ua_fsm(port); + break; + default: + break; + } + break; + case SIP_UA_MAIN_STATE_NON_INVITE_RSP: + switch (sip_ua_non_inv_rsp_proc(port)) + { + case 0: + break; + case 1: + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INIT; + sip_ua_fsm(port); + break; + default: + break; + } + break; + case SIP_UA_MAIN_STATE_INIT: + sip_ua_init_port(port); + break; + } +} + +void sip_ua_fsm(WORD port) +{ + if (port >= SIP_UA_MAX_NUM_OF_PORT) + { + return; + } + + switch(sipUaPort[port].sipuafState) + { + case SIP_UA_FSM_STATE_REQUEST: + sip_ua_fsm_request(port); + break; + case SIP_UA_FSM_STATE_INDICATE: + sip_ua_fsm_indicate(port); + break; + default: + sip_ua_init_port(port); + break; + } +} diff --git a/omc/plat/sip/src/sip_ua_msg.c b/omc/plat/sip/src/sip_ua_msg.c new file mode 100644 index 0000000..a06e97f --- /dev/null +++ b/omc/plat/sip/src/sip_ua_msg.c @@ -0,0 +1,1022 @@ +#include "./include/sip_ua_pub.h" +#include "./include/sip_ua_const.h" +#include "./include/sip_ua_struct.h" +#include "./include/sip_ua_msg.h" +#include "./include/sip_ua_ext.h" +#include "./include/sip_ua_dialog.h" +#include "./include/sip_ua.h" +#include "./include/sip_const.h" +#include "./include/sip_ext.h" +#include "./include/sip_debug.h" + +extern void sip_ua_fsm(WORD port); + +int sip_ua_create_register_tag(int port, SIP_GEN_PARA *tagPara) +{ + struct timeval tv; + + if ((port < 0) || (port >= SIP_UA_MAX_NUM_OF_PORT)) + return -1; + + gettimeofday(&tv, NULL); + + tagPara->paraName = SIP_API_PNAME_TAG; + tagPara->paraType = SIP_API_PTYPE_STRING; + sprintf(tagPara->para.paraStr, "%X%lX%lX", port, tv.tv_sec, tv.tv_usec); + + return 0; +} + +int sip_ua_create_register_call_id(WORD usrPort, SIP_HDR_CALL_ID *callId) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + sprintf(callId->value, "%X%lX%lX", usrPort, tv.tv_usec, tv.tv_sec); + strcpy(callId->host, sipUaDottedHostIp); + + return 0; +} + +int sip_ua_set_send_cmd(SIP_UA_PORT *sipUaPortPtr, SIP_API_STRUCT *sipApiMsg) +{ + SIP_START_LINE *startLine; + + if ((sipUaPortPtr == NULL) || (sipApiMsg == NULL)) + { + sprintf((char *)sipAsciTempBuf, "sip ua set send cmd failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + startLine = &sipApiMsg->sipApiMsg.sipMsg.sipStartLine; + + if (sipApiMsg->sipApiType == SIP_API_REQ_MSG) + sipUaPortPtr->sdCmd = startLine->sipMethod; + else if (sipApiMsg->sipApiType == SIP_API_RES_MSG) + sipUaPortPtr->sdCmd = startLine->statusCode; + else + return -1; + + return 0; +} + +void sip_ua_fill_uri_in_dialog(SIP_URI *sipUri, SIP_UA_URI *sipUaUri) +{ + if ((sipUri == NULL) || (sipUaUri == NULL)) + { + return; + } + + sipUri->uriType = sipUaUri->uriType; + strcpy(sipUri->userName, sipUaUri->userName); + strcpy(sipUri->password, sipUaUri->password); + strcpy(sipUri->host.addr.domain, sipUaUri->domain); +} + +int sip_ua_fill_tag_in_dialog(SIP_GEN_PARA *tagPara, char *tagOrg) +{ + if ((tagPara == NULL) || (tagOrg == NULL)) + { + return 0; + } + + if (*tagOrg != '\0') + { + tagPara->paraName = SIP_API_PNAME_TAG; + tagPara->paraType = SIP_API_PTYPE_STRING; + strcpy(tagPara->para.paraStr, tagOrg); + return 1; + } + + return 0; +} + +int sip_ua_fill_msg_with_dialog(WORD dialogId, SIP_API_STRUCT *sdMsg) +{ + SIP_DIALOG *sipUaDlgPtr; + SIP_MSG *sipMsg; +// SIP_URI url; + + if (sdMsg == NULL) + return -1; + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sipUaDialog[dialogId].flag == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_fill_msg_with_dialog:dialogId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipUaDlgPtr = &sipUaDialog[dialogId]; + sipMsg = &sdMsg->sipApiMsg.sipMsg; + + if (sdMsg->sipApiType == SIP_API_REQ_MSG) + { + sip_ua_fill_uri_in_dialog(&sipMsg->sipHdrFrom.url, &sipUaDlgPtr->localURI); + if (sip_ua_fill_tag_in_dialog(&sipMsg->sipHdrFrom.params.para[0], sipUaDlgPtr->localTag) == 1) + sipMsg->sipHdrFrom.params.paraNum++; + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_FROM_MASK; + + sip_ua_fill_uri_in_dialog(&sipMsg->sipHdrTo.url, &sipUaDlgPtr->remoteURI); + if (sip_ua_fill_tag_in_dialog(&sipMsg->sipHdrTo.params.para[0], sipUaDlgPtr->remoteTag) == 1) + sipMsg->sipHdrTo.params.paraNum++; + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_TO_MASK; + + memcpy(&sipMsg->sipHdrCallId, &sipUaDlgPtr->callId, sizeof(SIP_HDR_CALL_ID)); + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_CALL_ID_MASK; + + if (sipMsg->sipStartLine.sipMethod != SIP_METHOD_INVITE) + { + if ((sipUaDlgPtr->paramFlag & SIP_UA_DIALOG_REMOTE_TARGET_FLAG) == SIP_UA_DIALOG_REMOTE_TARGET_FLAG) + { + sip_ua_fill_uri_in_dialog(&sipMsg->sipStartLine.requestUri, &sipUaDlgPtr->remoteTarget); + } + } + + if ((sipMsg->sipStartLine.sipMethod == SIP_METHOD_INVITE) || (sipMsg->sipStartLine.sipMethod == SIP_METHOD_CANCEL)) + { + if (sipMsg->sipStartLine.sipMethod == SIP_METHOD_INVITE) + sipUaDlgPtr->invCSeq = sipUaDlgPtr->localCseq.value= sipMsg->sipHdrCseq.value = 1; + else + sipMsg->sipHdrCseq.value = sipUaDlgPtr->invCSeq; + } + else + { + if ((sipUaDlgPtr->type == SIP_CALLER) && (sipUaDlgPtr->invCSeq == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_fill_msg_with_dialog:caller send other req before sending invite\r\n"); + sip_log_err(sipAsciTempBuf); + return -2; + } + + if (sipMsg->sipStartLine.sipMethod != SIP_METHOD_ACK) + { + sipUaDlgPtr->localCseq.value = sipUaDlgPtr->localCseq.value + 1; + sipMsg->sipHdrCseq.value = sipUaDlgPtr->localCseq.value; + } + else + { + sipMsg->sipHdrCseq.value = sipUaDlgPtr->invCSeq; + } + } + + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_CSEQ_MASK; + + if (sipUaDlgPtr->routeSets.num != 0) + { + memcpy(&sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes, (SIP_HDR_ROUTES *)&sipUaDlgPtr->routeSets, sizeof(SIP_HDR_ROUTES)); + + if (sipUaDlgPtr->routeSets.recRoutes[0].url.params.para[0].paraName != SIP_API_PNAME_LR)//if (sipUaDlgPtr->routeSets.recRoutes[0].params.para[0].paraName != SIP_API_PNAME_LR) + { + if (sipUaDlgPtr->routeSets.num >= SIP_MAX_NUM_OF_RECORD_ROUTES) + { + memcpy(&sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes.routes[0].url, &sipMsg->sipStartLine.requestUri, sizeof(SIP_URI)); + } + else + { + memcpy(&sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes.routes[sipUaDlgPtr->routeSets.num].url, &sipMsg->sipStartLine.requestUri, sizeof(SIP_URI));//0 + } + + memcpy(&sipMsg->sipStartLine.requestUri, &sipUaDlgPtr->routeSets.recRoutes[0].url, sizeof(SIP_URI)); + + sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes.head = 1; + } + + sdMsg->sipTransAddr.addr.ipV4 = inet_addr(sipUaDlgPtr->routeSets.recRoutes[0].url.host.addr.domain); + if (sipUaDlgPtr->routeSets.recRoutes[0].url.port != 0) + sdMsg->sipTransAddr.port = sipUaDlgPtr->routeSets.recRoutes[0].url.port; + else + sdMsg->sipTransAddr.port = 5060; +//need forward develop + sipMsg->sipReStruct.sipReHdrFlag[0] |= SIP_HDR_ROUTE_MASK; + } + + + } + else + { + sip_ua_fill_uri_in_dialog(&sipMsg->sipHdrFrom.url, &sipUaDlgPtr->remoteURI); + if (sip_ua_fill_tag_in_dialog(&sipMsg->sipHdrFrom.params.para[0], sipUaDlgPtr->remoteTag) == 1) + sipMsg->sipHdrFrom.params.paraNum++; + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_FROM_MASK; + + sip_ua_fill_uri_in_dialog(&sipMsg->sipHdrTo.url, &sipUaDlgPtr->localURI); + if (sip_ua_fill_tag_in_dialog(&sipMsg->sipHdrTo.params.para[0], sipUaDlgPtr->localTag) == 1) + sipMsg->sipHdrTo.params.paraNum++; + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_TO_MASK; + + memcpy(&sipMsg->sipHdrCallId, &sipUaDlgPtr->callId, sizeof(SIP_HDR_CALL_ID)); + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_CALL_ID_MASK; + + if (sipMsg->sipHdrCseq.method == SIP_METHOD_INVITE) + { + sipMsg->sipHdrCseq.value = sipUaDlgPtr->remoteInvCseq; + } + else + { + sipMsg->sipHdrCseq.value = sipUaDlgPtr->remoteCseq.value; + } + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_CSEQ_MASK; + + if ((sipUaDlgPtr->routeSets.num != 0) +// && ((sipUaDlgPtr->paramFlag & SIP_UA_DIALOG_RECORD_ROUTE_SEND_FLAG) != SIP_UA_DIALOG_RECORD_ROUTE_SEND_FLAG) + && (sipUaDlgPtr->type == SIP_CALLEE) && (sipMsg->sipHdrCseq.method == SIP_METHOD_INVITE)) + { + memcpy(&sipMsg->sipHdrRecordRoutes, &sipUaDlgPtr->routeSets, sizeof(SIP_HDR_RECORD_ROUTES)); +// sipUaDlgPtr->paramFlag |= SIP_UA_DIALOG_RECORD_ROUTE_SEND_FLAG; + sipMsg->sipGenHdrFlag[0] |= SIP_HDR_RECORD_ROUTE_MASK; + } + } + + return 0; +} + +int sip_ua_update_retransmit_para(WORD dialogId, SIP_API_STRUCT *sdMsg) +{ + SIP_DIALOG *sipUaDlgPtr; + SIP_MSG *sipMsg; +// SIP_URI url; + + if (sdMsg == NULL) + return -1; + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sipUaDialog[dialogId].flag == 0)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_update_retransmit_para:dialogId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + sipUaDlgPtr = &sipUaDialog[dialogId]; + sipMsg = &sdMsg->sipApiMsg.sipMsg; + + if (sdMsg->sipApiType == SIP_API_REQ_MSG) + { + if (sipUaDlgPtr->routeSets.num != 0) + { + memcpy(&sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes, (SIP_HDR_ROUTES *)&sipUaDlgPtr->routeSets, sizeof(SIP_HDR_ROUTES)); + + if (sipUaDlgPtr->routeSets.recRoutes[0].url.params.para[0].paraName != SIP_API_PNAME_LR)//if (sipUaDlgPtr->routeSets.recRoutes[0].params.para[0].paraName != SIP_API_PNAME_LR) + { + memcpy(&sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes.routes[0].url, &sipMsg->sipStartLine.requestUri, sizeof(SIP_URI)); + + memcpy(&sipMsg->sipStartLine.requestUri, &sipUaDlgPtr->routeSets.recRoutes[0].url, sizeof(SIP_URI)); + + sipMsg->sipReStruct.sipReHdr.sipReqHdr.sipHdrRoutes.head = 1; + } + + sdMsg->sipTransAddr.addr.ipV4 = inet_addr(sipUaDlgPtr->routeSets.recRoutes[0].url.host.addr.domain); + if (sipUaDlgPtr->routeSets.recRoutes[0].url.port != 0) + sdMsg->sipTransAddr.port = sipUaDlgPtr->routeSets.recRoutes[0].url.port; + else + sdMsg->sipTransAddr.port = 5060; +//need forward develop + sipMsg->sipReStruct.sipReHdrFlag[0] |= SIP_HDR_ROUTE_MASK; + } + } + + return 0; +} + +int sip_ua_send_invite(BYTE cgId, WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + int port; + BYTE client; + BYTE method; + int ret; + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sdMsg == NULL)) + { + return -1; + } + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_invite:allocate port failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_CLIENT; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_REQ_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_INVITE; + + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_invite:fill msg with dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, port, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_invite:fill create transaction in sip failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + strcpy(sipUaDialog[dialogId].invBranch, sdMsg->sipApiMsg.sipMsg.sipHdrVias.vias[0].params.para[0].para.paraStr); + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_REQUEST; + sipUaPort[port].dialogId = dialogId; + sipUaPort[port].usrPort = usrPort; + sipUaPort[port].cgId = cgId;//sipUaPort[port].sapIndex = sapIndex; + sipUaPort[port].llPort = ret; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INVITE_REQ; + sipUaPort[port].state = SIP_UA_SEND_REQUEST; + + memcpy(&sipUaPort[port].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[port], sdMsg); + + sipUaDialog[dialogId].sipUaPort = port; + sipUaDialog[dialogId].invUaPort.sdInvUaPort = port; + + sip_ua_fsm(port); + + return 0; +} + +int sip_ua_send_re_invite(BYTE cgId, WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + int port; + BYTE client; + BYTE method; + int ret; + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sdMsg == NULL)) + { + return -1; + } + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_invite:allocate port failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_CLIENT; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_REQ_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_RE_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_RE_INVITE; + + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_invite:fill msg with dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, port, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_invite:fill create transaction in sip failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_REQUEST; + sipUaPort[port].dialogId = dialogId; + sipUaPort[port].usrPort = usrPort; + sipUaPort[port].cgId = cgId;//sipUaPort[port].sapIndex = sapIndex; + sipUaPort[port].llPort = ret; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_INVITE_REQ; + sipUaPort[port].state = SIP_UA_SEND_REQUEST; + + memcpy(&sipUaPort[port].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[port], sdMsg); + + sipUaDialog[dialogId].sipUaPort = port; + + sip_ua_fsm(port); + + return 0; +} + +int sip_ua_send_non_inv(BYTE cgId, WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + int port; + BYTE client; + BYTE sipMethod; + int ret; + + if ((dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) || (sdMsg == NULL)) + { + return -1; + } + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv:allocate port failed, method = %d\r\n", method); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_CLIENT; + sipMethod = SIP_TRANS_NON_INVITE; + + sdMsg->sipApiType = SIP_API_REQ_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = method; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = method; + + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv:fill msg with dialog failed, method = %d\r\n", method); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + if (method == SIP_METHOD_CANCEL) + { + sdMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sdMsg->sipApiMsg.sipMsg.sipHdrVias.head].params.para[0].paraName = SIP_API_PNAME_BRANCH; + sdMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sdMsg->sipApiMsg.sipMsg.sipHdrVias.head].params.para[0].paraType = SIP_API_PTYPE_STRING; + strcpy(sdMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sdMsg->sipApiMsg.sipMsg.sipHdrVias.head].params.para[0].para.paraStr, sipUaDialog[dialogId].invBranch); + sdMsg->sipApiMsg.sipMsg.sipHdrVias.vias[sdMsg->sipApiMsg.sipMsg.sipHdrVias.head].params.paraNum++; + } + + if ((ret = sip_create_transaction(client, sipMethod, sipUaSipIndex, port, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv:create transaction is sip failed, method = %d\r\n", method); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_REQUEST; + sipUaPort[port].dialogId = dialogId; + sipUaPort[port].usrPort = usrPort; + sipUaPort[port].cgId = cgId;//sipUaPort[port].sapIndex = sapIndex; + sipUaPort[port].llPort = ret; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_NON_INVITE_REQ; + sipUaPort[port].state = SIP_UA_SEND_REQUEST; + + if (SIP_METHOD_ACK == method) + { + sipUaDialog[dialogId].uaAckPort = port; + } + + memcpy(&sipUaPort[port].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[port], sdMsg); + + sipUaDialog[dialogId].sipUaPort = port; + + sip_ua_fsm(port); + + return 0; +} + +int sip_ua_send_options(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + int port; + BYTE client; + BYTE method; + int ret; + + if (sdMsg == NULL) + return -1; + + if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + if (cgId != sipUaDialog[dialogId].cgId) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:userIndex is wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + } + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:allocate port failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_CLIENT; + method = SIP_TRANS_NON_INVITE; + + sdMsg->sipApiType = SIP_API_REQ_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_OPTIONS; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_OPTIONS; + + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + + if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:fille msg with dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaDialog[dialogId].sipUaPort = port; + } + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, port, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:create transaction in sip failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_REQUEST; + sipUaPort[port].dialogId = dialogId; + sipUaPort[port].usrPort = usrPort; + sipUaPort[port].cgId = cgId;//sipUaPort[port].sapIndex = sapIndex; + sipUaPort[port].llPort = ret; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_NON_INVITE_REQ; + sipUaPort[port].state = SIP_UA_SEND_REQUEST; + + memcpy(&sipUaPort[port].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[port], sdMsg); + + sip_ua_fsm(port); + + return 0; +} + +int sip_ua_send_register(BYTE cgId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + int port; + BYTE client; + BYTE method; + int ret; + + if (sdMsg == NULL) + return -1; + + if ((port = sip_ua_get_port()) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:allocate port failed\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_CLIENT; + method = SIP_TRANS_NON_INVITE; + + sdMsg->sipApiType = SIP_API_REQ_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_REGISTER; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_REGISTER; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.value = time(NULL); + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_CSEQ_MASK; + + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdr.sipReqHdr.sipHdrMaxForwards.value = 70; + sdMsg->sipApiMsg.sipMsg.sipReStruct.sipReHdrFlag[0] |= SIP_HDR_MAX_FORWARDS_MASK; + + if (sip_ua_create_register_tag(port, &sdMsg->sipApiMsg.sipMsg.sipHdrFrom.params.para[0]) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_create_register_tag:create tag failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sdMsg->sipApiMsg.sipMsg.sipHdrFrom.params.paraNum++; + sdMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_FROM_MASK; + + if (sip_ua_create_register_call_id(usrPort, &sdMsg->sipApiMsg.sipMsg.sipHdrCallId) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_create_register_tag:create call id failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sdMsg->sipApiMsg.sipMsg.sipGenHdrFlag[0] |= SIP_HDR_CALL_ID_MASK; + +/* if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf(sipAsciTempBuf, "sip_ua_send_options:fille msg with dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaDialog[dialogId].sipUaPort = port; + }*/ + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, port, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_options:create transaction in sip failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(port); + return -1; + } + + sipUaPort[port].sipuafState = SIP_UA_FSM_STATE_REQUEST; + sipUaPort[port].dialogId = SIP_UA_NULL_DIALOG;//dialogId + sipUaPort[port].usrPort = usrPort; + sipUaPort[port].cgId = cgId;//sipUaPort[port].sapIndex = sapIndex; + sipUaPort[port].llPort = ret; + sipUaPort[port].mainState = SIP_UA_MAIN_STATE_NON_INVITE_REQ; + sipUaPort[port].state = SIP_UA_SEND_REQUEST; + + memcpy(&sipUaPort[port].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[port], sdMsg); + + sip_ua_fsm(port); + + return 0; +} + + +int sip_ua_set_inv_temp_rsp(WORD uaPort,SIP_API_STRUCT *sdMsg) +{ + BYTE client; + BYTE method; + int ret; + + if (sdMsg == NULL) + return -1; + + if ((uaPort >= SIP_UA_MAX_NUM_OF_PORT) || (sipUaPort[uaPort].flag != 1)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_temp_rsp:ua port wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_SERVER; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_RES_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_INVITE; + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, uaPort, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:create transaction in sip failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + sipUaPort[uaPort].llPort = ret; + + return 0; +} + +int sip_ua_send_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE cgId +{ + BYTE client; + BYTE method; + int ret; + WORD uaPort; + + if (sdMsg == NULL) + return -1; + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + return -1; + } + + if (cgId != sipUaDialog[dialogId].cgId)//if (sapIndex != sipUaDialog[dialogId].userIndex) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:cgId wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + uaPort = sipUaDialog[dialogId].sipUaPort; + + if ((uaPort >= SIP_UA_MAX_NUM_OF_PORT) || (sipUaPort[uaPort].flag != 1)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:ua port wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (!((sipUaDialog[dialogId].uaPort == 0xFFFF) || (sipUaDialog[dialogId].uaPort == uaPort))) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:dialog ua port not match\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_SERVER; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_RES_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_INVITE; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:fill msg with dialog failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + if (sipUaPort[uaPort].llPort == 0xFFFF) + { + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, uaPort, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:create transaction in sip failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].llPort = ret; + } + + if (sipUaPort[uaPort].usrPort == 0xFFFF)//if (sipUaDialog[dialogId].uaPort == 0xFFFF) + { + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].state = SIP_UA_SEND_RESPONSE; + sipUaPort[uaPort].timer = SIP_UA_TIMER_TIME_OUT; + } + + memcpy(&sipUaPort[uaPort].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[uaPort], sdMsg); + + sipUaDialog[dialogId].uaPort = uaPort; + + sip_ua_fsm(uaPort); + + return 0; +} + +int sip_ua_send_cancel_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + BYTE client; + BYTE method; + int ret; + WORD uaPort; + + if (sdMsg == NULL) + return -1; + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + return -1; + } + + if (cgId != sipUaDialog[dialogId].cgId)//if (sapIndex != sipUaDialog[dialogId].userIndex) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_cancel_inv_rsp:userIndex wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + uaPort = sipUaDialog[dialogId].invUaPort.rvInvUaPort; + + if ((uaPort >= SIP_UA_MAX_NUM_OF_PORT) || (sipUaPort[uaPort].flag != 1)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_cancel_inv_rsp:ua port wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + if (!((sipUaDialog[dialogId].uaPort == 0xFFFF) || (sipUaDialog[dialogId].uaPort == uaPort))) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_cancel_inv_rsp:dialog ua port not match\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_SERVER; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_RES_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_INVITE; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_cancel_inv_rsp:fill msg with dialog failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + if (sipUaPort[uaPort].llPort == 0xFFFF) + { + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, uaPort, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_inv_rsp:create transaction in sip failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].llPort = ret; + } + + if (sipUaPort[uaPort].usrPort == 0xFFFF)//if (sipUaDialog[dialogId].uaPort == 0xFFFF) + { + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].state = SIP_UA_SEND_RESPONSE; + sipUaPort[uaPort].timer = SIP_UA_TIMER_TIME_OUT; + } + + memcpy(&sipUaPort[uaPort].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[uaPort], sdMsg); + + sipUaDialog[dialogId].uaPort = uaPort; + + sip_ua_fsm(uaPort); + + return 0; +} + +int sip_ua_send_re_inv_rsp(BYTE cgId,WORD dialogId, WORD usrPort, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + BYTE client; + BYTE method; + int ret; + WORD uaPort; + + if (sdMsg == NULL) + return -1; + + if (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG) + { + return -1; + } + + if (cgId != sipUaDialog[dialogId].cgId)//if (sapIndex != sipUaDialog[dialogId].userIndex) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_inv_rsp:userIndex wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + uaPort = sipUaDialog[dialogId].sipUaPort; + + if ((uaPort >= SIP_UA_MAX_NUM_OF_PORT) || (sipUaPort[uaPort].flag != 1)) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_inv_rsp:ua port wrong\r\n"); + sip_log_err(sipAsciTempBuf); + return -1; + } + + client = SIP_TRANS_SERVER; + method = SIP_TRANS_INVITE; + + sdMsg->sipApiType = SIP_API_RES_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = SIP_METHOD_RE_INVITE; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = SIP_METHOD_RE_INVITE; + + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_inv_rsp:fill msg with dialog failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + if ((ret = sip_create_transaction(client, method, sipUaSipIndex, uaPort, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_re_inv_rsp:create transaction in sip failed no proc port\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].llPort = ret; + sipUaPort[uaPort].state = SIP_UA_SEND_RESPONSE; + sipUaPort[uaPort].timer = SIP_UA_TIMER_TIME_OUT; + + memcpy(&sipUaPort[uaPort].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[uaPort], sdMsg); + + sipUaDialog[dialogId].uaPort = uaPort; + + sip_ua_fsm(uaPort); + + return 0; +} + +int sip_ua_send_non_inv_rsp(BYTE cgId, WORD dialogId, WORD usrPort, BYTE method, SIP_API_STRUCT *sdMsg)//BYTE sapIndex +{ + BYTE client; + BYTE sipMethod; + int ret; + WORD uaPort=0xFFFF; + + if (sdMsg == NULL) + return -1; + + if ((method != SIP_METHOD_OPTIONS) && (dialogId >= SIP_UA_MAX_NUM_OF_DIALOG)) + { + return -1; + } + + if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + if (cgId != sipUaDialog[dialogId].cgId) + return -1; + } + + client = SIP_TRANS_SERVER; + sipMethod = SIP_TRANS_NON_INVITE; + + sdMsg->sipApiType = SIP_API_RES_MSG; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipMethod = method; + sdMsg->sipApiMsg.sipMsg.sipStartLine.sipVersion = SIP_VERSION_2_0; + sdMsg->sipApiMsg.sipMsg.sipHdrCseq.method = method; + + if (dialogId < SIP_UA_MAX_NUM_OF_DIALOG) + { + if (sip_ua_fill_msg_with_dialog(dialogId, sdMsg) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv_rsp:fill msg with dialog failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + uaPort = sipUaDialog[dialogId].sipUaPort; + } + + if (uaPort >= SIP_UA_MAX_NUM_OF_PORT) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv_rsp:uaPort wrong\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + if ((ret = sip_create_transaction(client, sipMethod, sipUaSipIndex, uaPort, sdMsg)) < 0) + { + sprintf((char *)sipAsciTempBuf, "sip_ua_send_non_inv_rsp:create transaction in sip failed\r\n"); + sip_log_err(sipAsciTempBuf); + sip_ua_init_port(uaPort); + return -1; + } + + sipUaPort[uaPort].dialogId = dialogId; + sipUaPort[uaPort].usrPort = usrPort; + sipUaPort[uaPort].cgId = cgId;//sipUaPort[uaPort].sapIndex = sapIndex; + sipUaPort[uaPort].llPort = ret; + sipUaPort[uaPort].state = SIP_UA_SEND_RESPONSE; + + memcpy(&sipUaPort[uaPort].sdSipMsg, sdMsg, sizeof(SIP_API_STRUCT)); + + sip_ua_set_send_cmd(&sipUaPort[uaPort], sdMsg); + + sip_ua_fsm(uaPort); + + return 0; +} diff --git a/omc/plat/smpp/.copyarea.db b/omc/plat/smpp/.copyarea.db new file mode 100644 index 0000000..a9f32b4 --- /dev/null +++ b/omc/plat/smpp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp +2 +5 +2:ut|2|0|0|0|08a970f7bfa611dc866b001c23e19543|0 +3:src|2|0|0|0|00496f8bbfa611dc866b001c23e19543|0 +8:Makefile|1|127d644ee8a|b93|f44dc52b|ffb96f6fbfa511dc866b001c23e19543|0 +3:doc|2|0|0|0|fc296ec7bfa511dc866b001c23e19543|0 +3:lib|2|0|0|0|ff196f53bfa511dc866b001c23e19543|0 diff --git a/omc/plat/smpp/Makefile b/omc/plat/smpp/Makefile new file mode 100644 index 0000000..a4ee62a --- /dev/null +++ b/omc/plat/smpp/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = smpp +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/smpp/doc/.copyarea.db b/omc/plat/smpp/doc/.copyarea.db new file mode 100644 index 0000000..4363483 --- /dev/null +++ b/omc/plat/smpp/doc/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\doc +2 +4 +13:SMPP_R9V0_01P14.doc|1|127d644f197|ec00|d642859|fd596effbfa511dc866b001c23e19543|0 +13:SMPP_R9V0_01P13.doc|1|127d644f263|ee00|35df93d7|fde96f1bbfa511dc866b001c23e19543|0 +13:SMPP_R9V0_01P15.doc|1|127d644f32e|e200|cce4080f|fe896f37bfa511dc866b001c23e19543|0 +13:SMPP_R9V0_01P12.doc|1|127d644f11a|ea00|d917f48d|fcb96ee3bfa511dc866b001c23e19543|0 diff --git a/omc/plat/smpp/doc/SMPP_R9V0_01P12.doc b/omc/plat/smpp/doc/SMPP_R9V0_01P12.doc new file mode 100644 index 0000000..55d3426 Binary files /dev/null and b/omc/plat/smpp/doc/SMPP_R9V0_01P12.doc differ diff --git a/omc/plat/smpp/doc/SMPP_R9V0_01P13.doc b/omc/plat/smpp/doc/SMPP_R9V0_01P13.doc new file mode 100644 index 0000000..dccfee8 Binary files /dev/null and b/omc/plat/smpp/doc/SMPP_R9V0_01P13.doc differ diff --git a/omc/plat/smpp/doc/SMPP_R9V0_01P14.doc b/omc/plat/smpp/doc/SMPP_R9V0_01P14.doc new file mode 100644 index 0000000..8636ec3 Binary files /dev/null and b/omc/plat/smpp/doc/SMPP_R9V0_01P14.doc differ diff --git a/omc/plat/smpp/doc/SMPP_R9V0_01P15.doc b/omc/plat/smpp/doc/SMPP_R9V0_01P15.doc new file mode 100644 index 0000000..21e8041 Binary files /dev/null and b/omc/plat/smpp/doc/SMPP_R9V0_01P15.doc differ diff --git a/omc/plat/smpp/lib/libsmpp.a b/omc/plat/smpp/lib/libsmpp.a new file mode 100644 index 0000000..f291945 Binary files /dev/null and b/omc/plat/smpp/lib/libsmpp.a differ diff --git a/omc/plat/smpp/obj/smpp_debug.o b/omc/plat/smpp/obj/smpp_debug.o new file mode 100644 index 0000000..df734d5 Binary files /dev/null and b/omc/plat/smpp/obj/smpp_debug.o differ diff --git a/omc/plat/smpp/obj/smpp_fsm.o b/omc/plat/smpp/obj/smpp_fsm.o new file mode 100644 index 0000000..9b0cfa4 Binary files /dev/null and b/omc/plat/smpp/obj/smpp_fsm.o differ diff --git a/omc/plat/smpp/obj/smpp_func.o b/omc/plat/smpp/obj/smpp_func.o new file mode 100644 index 0000000..276759c Binary files /dev/null and b/omc/plat/smpp/obj/smpp_func.o differ diff --git a/omc/plat/smpp/obj/smpp_mib.o b/omc/plat/smpp/obj/smpp_mib.o new file mode 100644 index 0000000..cee4b0c Binary files /dev/null and b/omc/plat/smpp/obj/smpp_mib.o differ diff --git a/omc/plat/smpp/obj/smpp_msg.o b/omc/plat/smpp/obj/smpp_msg.o new file mode 100644 index 0000000..2388f3f Binary files /dev/null and b/omc/plat/smpp/obj/smpp_msg.o differ diff --git a/omc/plat/smpp/src/.copyarea.db b/omc/plat/smpp/src/.copyarea.db new file mode 100644 index 0000000..36dd7b0 --- /dev/null +++ b/omc/plat/smpp/src/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\src +2 +6 +7:include|2|0|0|0|02196fdfbfa611dc866b001c23e19543|0 +a:smpp_msg.c|1|127d644f466|2fa89|454147fb|4d56b878e5ff11de967d001ec9cf72cd|0 +a:smpp_mib.c|1|127d644f810|518a|95f85926|1f6f6ed641e311df8afa001ec9cf72cd|0 +c:smpp_debug.c|1|128a46bade2|2cc6|e11eaa3c|7e05559e42c511df9b33001ec9cf72cd|0 +b:smpp_func.c|1|130683a6ba5|7636|6d690ddb|5926781190ba11e09df5001ec9cf72cd|0 +a:smpp_fsm.c|1|127d644f4d4|532e|4a10af47|1edf6e7641e311df8afa001ec9cf72cd|0 diff --git a/omc/plat/smpp/src/include/.copyarea.db b/omc/plat/smpp/src/include/.copyarea.db new file mode 100644 index 0000000..99b1e03 --- /dev/null +++ b/omc/plat/smpp/src/include/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\src\include +2 +6 +d:smpp_public.h|1|127d644fafe|37a|a138006f|4f26b898e5ff11de967d001ec9cf72cd|0 +6:smpp.h|1|127d644fa23|14ea|b27ef32b|1f6f6e8e41e311df8afa001ec9cf72cd|0 +a:smpp_ext.h|1|127d644fd60|43c|3b73642e|5056b8b0e5ff11de967d001ec9cf72cd|0 +a:smpp_msg.h|1|127d644f997|33e7|7b1ed86|4df6b888e5ff11de967d001ec9cf72cd|0 +a:smpp_def.h|1|127d644fbc9|38c|ebd8231c|4f26b8a0e5ff11de967d001ec9cf72cd|0 +c:smpp_const.h|1|128a46baf68|1e31|48241e9b|2159c61258e311df80dc001ec9cf72cd|0 diff --git a/omc/plat/smpp/src/include/smpp.h b/omc/plat/smpp/src/include/smpp.h new file mode 100644 index 0000000..778b546 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp.h @@ -0,0 +1,189 @@ +/* +** CDMA 2000 project, SMPP module +** +** File name: smpp.h +** Written by Li Long at 2004-11-25 +** CVS $Id: smpp.h,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ +#ifndef _SMPP_h +#define _SMPP_h + + +#include "smpp_public.h" +#include "smpp_const.h" +#include "../../../debug/src/include/debug.h" +#include "../../../sccp/src/include/sccp.h" +#include "../../../iptrans/src/include/iptrans.h" +#include "../../../mtp3/src/include/mtp3.h" +#include "../../../snmp/src/include/snmp.h" +#include "../../../public/src/include/public.h" + +#include "smpp_msg.h" + +enum SMPP_State_Constant {INIT, IDLE, WAITING, ESTABLISHED, SUSPEND}; +enum SMPP_APIEvent {APIEventReversed, Register, Setup, Close}; +enum SMPP_InterEvent {InterEventReserved, Outbind, Unbind, UnbindResp, + BindTransmitter, BindReceiver, BindTransceiver, //4 + BindTransmitterResp, BindReceiverResp, BindTransceiverResp, //7 + EnquireLink, EnquireLinkResp, //10 + SubmitSM, SubmitSMResp, //12 + SubmitMulti, SubmitMultiResp, //14 + DeliverSM, DeliverSMResp, //16 + DataSM, DataSMResp, //18 + GenericNak, //20 + SessionInitTimeout, EnquireLinkTimeout, InactivityTimeout, ResponseTimeOut, //21 + QuerySM, QuerySMResp, //25 + CancelSM, CancelSMResp, //27 + ReplaceSM, ReplaceSMResp, //29 + AlertNotification, //31 + UnknownCommandID}; //32 + +typedef struct SMPP_LINK +{ + DWORD seq_num; + DWORD command_status; +}SMPP_LINK; + +typedef struct SMPP_DEBUG_STRUCT +{ + BYTE debug_switch; + BYTE link_switch[MAX_SMPP_LINK]; +}SMPP_DEBUG_STRUCT; + +typedef struct SMPP_PARAM +{ + BYTE link_no; //0~31 + BYTE link_enable; //0-Disable, 1-Enable + BYTE link_type; //0-UDP 1-TCP + BYTE server_type; //0-SMPP_CLIENT; 1-SMPP_SERVER + BYTE session_type; //0-BIND_TX; 1-BIND_RX; 2-BIND_TRX + char sys_id[16]; + char password[9]; + char system_type[13]; + char localGTT[16]; + char remoteGTT[16]; + DWORD local_ip; + DWORD remote_ip; + DWORD session_init_timer; + DWORD enquire_link_timer; + DWORD inactivity_timer; + DWORD response_timer; + char service_number[8]; + BYTE localSSN; + BYTE remoteSSN; + BYTE message_mode; +} SMPP_PARAM; + +// Inter-Function define +int smpp_Register(BYTE); +void smpp_PrimitiveSend(int linkNo, int command_id); + +void smpp_initTCPClient(); +void smpp_initTCPServer(); +void smpp_tcp_connect(int link); +void smpp_debugInit(); +void smpp_stateInit(); +void smpp_msgInit(); +void smpp_debugTimer(); +char *smpp_getLocalIP(); +void smpp_setupTCPLink(int); +void smpp_rvMsgOverSCCP(BYTE sccp_usertype); +void smpp_rvMsgOverTCP(); +WORD smpp_getServerPort(); +DWORD smpp_getSequenceNumber(int); +int smpp_decode_msg(int, SMPP_GENERAL*, int); +int smpp_closeTCPConnection(int); +int smpp_encode_msg(int, SMPP_MSG *, int); +void smpp_setSccpAddr(int, SCCP_ADDR *, SCCP_ADDR *); +BYTE smpp_ascii2GTAI(BYTE *pGTAI, char *pGTT); +void smpp_GTAI2ascii(char *, BYTE *, BYTE); +void smpp_send_ascout(char *); +void smpp_send_error(char *); +void smpp_display_hex_msg(BYTE* disp_ptr, int len); +void smpp_command_id_to_string(char *comm_str, DWORD command_id); +void smpp_command_status_to_string(char* status_str, DWORD command_status); +void smpp_ton_to_string(char* ton_str, BYTE ton); +void smpp_npi_to_string(char* npi_str, BYTE npi); + +void smpp_sendBindResp(int, int, DWORD command_status); +void smpp_sendUnbind(int); +void smpp_sendUnbindResp(int); +void smpp_sendEnquireLink(int); +void smpp_sendEnquireLinkResp(int); +void smpp_sendOutbind(int); +void smpp_sendBind(int, int); +void smpp_sendGenericNack(int, DWORD, DWORD); +void smpp_sendResponse(int , DWORD , DWORD , DWORD ); + +void smpp_addTLV(BYTE *, WORD, BYTE *, WORD); + +int smpp_loadParam(); +int smpp_writeParam(); +void smpp_checkParam(); +int smpp_setParam(DWORD *oid, BYTE *pdata, WORD datalen); +void smpp_reset(); +void smpp_debug(DWORD mask, const char *fmt, ...); +void smpp_close(BYTE linkNo); +void smpp_mibInit(); +int smpp_decode_optional_parameter(SMPP_OPTIONAL_PARAMETER* opt_ptr, BYTE* msg_ptr, int t_len); +int smpp_check_sysid_route(char* sysid_rv, BYTE sysidlen_rv, BYTE server_type, BYTE session_type); +int smpp_decode_setup(BYTE link_type, int tcp_linkNo, BYTE src_ref, SMPP_GENERAL *pData, int len); + +/* TCP connection */ +typedef struct SocketsMsg +{ + int AcceptNum; + int ReadNum; + int ReadQueue[MAX_SMPP_LINK]; + int WriteNum; + int WriteQueue[MAX_SMPP_LINK]; + int ExceptNum; + int ExceptQueue[MAX_SMPP_LINK]; +}SocketsMsg; + +typedef struct SocketsInUse +{ + int DaemonSock; + int SockNum; + int Sockets[MAX_SMPP_LINK]; + int client_sock[MAX_SMPP_LINK]; + int server_sock[MAX_SMPP_LINK]; + u32 remote_ip[MAX_SMPP_LINK]; + fd_set readfds,writefds,exceptfds; + int Port; +}SocketsInUse; + +/* by simon at 23/9/26 */ +// SocketsMsg SockMsg; + +int QuerySocketsMsg(); + +// Call back function define +//param1:linkNo; param2:msg mode; param3: pData; param4:pDataLen +typedef int (*smpp_callBack_dataProc) (BYTE, SMPP_MSG*, WORD); +//param1:linkNo; param2:link status +typedef int (*smpp_callBack_linkProc) (BYTE, BYTE); + +typedef struct SMPP_CALLBACK +{ + smpp_callBack_dataProc data_proc; + smpp_callBack_linkProc link_proc; +} SMPP_CALLBACK; + +// API +int smpp_init_new(u8 sys_id); //call in main program. +void smpp_fsm_new(); +BYTE smpp_registerLink(BYTE server_type, BYTE session_type, char* service_number_ptr, BYTE message_mode); +void smpp_attach_link(BYTE linkNo, + smpp_callBack_dataProc onDataRecv, + smpp_callBack_linkProc onLinkStateChange); + +/* return sequence number */ +WORD smpp_send(BYTE linkNo, SMPP_MSG* pMsg, WORD dataLen); + +void init_link(u32 link); + +#endif + + diff --git a/omc/plat/smpp/src/include/smpp_const.h b/omc/plat/smpp/src/include/smpp_const.h new file mode 100644 index 0000000..cfff820 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp_const.h @@ -0,0 +1,240 @@ +//public constant define +#ifndef _SMPP_CONST_h +#define _SMPP_CONST_h + + +#define MAX_SMPP_LINK 32 +#define SMPP_LINK_QUEUE_NUM 32 //queue number per link +#define MAX_PACKET_SIZE 1500 +#define MAX_MSG_SIZE 1300 +#define SMPP_MSG_LEN 512 +#define MAX_ASCOUT_BUF_LEN 4096 +#define MAX_ASCIN_BUF_LEN 1024 +#define SMPP_MAX_MULTI_ADDRESS 5 +#define CMD_BUF_SIZE 8 +#define SMPP_PORT 2775 +#define SMPP_MODULE_VERSION "V1.0.01"//merge R9v0_02 p4 ot R90v0_12 p4 +#define SMPP_MODULE_PATCH 2 +#define TITLE_CHAR 2048 +#define SMPP_PPS_SSN 19 +#define SMPP_SMSC_SSN 20 +#define SMPP_PPS_USERTYPE 1 +#define SMPP_SMSC_USERTYPE 2 +#define SMPP_CONF_FILE "./conf/smpp.conf" +#define SMPP_CONF_FILE_w "./conf/smpp_w.conf" +#define SMPP_UDP 0 +#define SMPP_TCP 1 +#define SMPP_OID {1,3,6,1,4,1,1373,1,3,2,3,4} +#define SMPP_OIDLEN 12 +#define MAX_SME 1 +#define SMPP_VERSION 0x34 +#define SMPP_OPT_PARAM_NUM 64 + +#define SMPP_SYSID_LEN 16 +#define SMPP_PASSWD_LEN 9 +#define SMPP_SYSTYPE_LEN 13 +#define SMPP_GTT_LEN 16 + +/* time interval */ +#define SESSION_INIT_INTERVAL (50*5) /* 5s */ + +/* debug id */ +#define SMPP_DEBUG_ID 15 +#define SMPP_HEARTBEAT_COMPONENT_ID 9 + +// define if print screen and debug needed. +//#define SMPP_PRINT_SCREEN TRUE +#define SMPP_DEBUG true + +/* Define server mode */ +#define SMPP_CLIENT 0 +#define SMPP_SERVER 1 + +/* Define session type */ +#define BIND_TX 0 +#define BIND_RX 1 +#define BIND_TRX 2 + +/* Define message mode */ +#define STORE_AND_FORWARD 0 +#define DATAGRAM 1 +#define TRANSACTION 2 + +//command ID define +#define GENERIC_NAK 0x80000000 +#define BIND_RECEIVER 0x00000001 +#define BIND_RECEIVER_RESP 0x80000001 +#define BIND_TRANSMITTER 0x00000002 +#define BIND_TRANSMITTER_RESP 0x80000002 +#define QUERY_SM 0x00000003 +#define QUERY_SM_RESP 0x80000003 +#define SUBMIT_SM 0x00000004 +#define SUBMIT_SM_RESP 0x80000004 +#define DELIVER_SM 0x00000005 +#define DELIVER_SM_RESP 0x80000005 +#define UNBIND 0x00000006 +#define UNBIND_RESP 0x80000006 +#define REPLACE_SM 0x00000007 +#define REPLACE_SM_RESP 0x80000007 +#define CANCEL_SM 0x00000008 +#define CANCEL_SM_RESP 0x80000008 +#define BIND_TRANSCEIVER 0x00000009 +#define BIND_TRANSCEIVER_RESP 0x80000009 +#define OUTBIND 0x0000000B +#define ENQUIRE_LINK 0x00000015 +#define ENQUIRE_LINK_RESP 0x80000015 +#define SUBMIT_MULTI 0x00000021 +#define SUBMIT_MULTI_RESP 0x80000021 +#define ALERT_NOTIFICATION 0x00000102 +#define DATA_SM 0x00000103 +#define DATA_SM_RESP 0x80000103 + +/* Optional parameter tag definitions */ +#define DEST_ADDR_SUBUNIT 0x0005 +#define DEST_NETWORK_TYPE 0x0006 +#define DEST_BEARER_TYPE 0x0007 +#define DEST_TELEMATICS_ID 0x0008 +#define SOURCE_ADDR_SUBUNIT 0x000D +#define SOURCE_NETWORK_TYPE 0x000E +#define SOURCE_BEARER_TYPE 0x000F +#define SOURCE_TELEMATICS_ID 0x0010 +#define QOS_TIME_TO_LIVE 0x0017 +#define PAYLOAD_TYPE 0x0019 +#define ADDITIONAL_STATUS_INFO_TEXT 0x001D +#define RECEIPTED_MESSAGE_ID 0x001E +#define MS_MSG_WAIT_FACILITIES 0x0030 +#define PRIVACY_INDICATOR 0x0201 +#define SOURCE_SUBADDRESS 0x0202 +#define DEST_SUBADDRESS 0x0203 +#define USER_MESSAGE_REFERENCE 0x0204 +#define USER_RESPONSE_CODE 0x0205 +#define SOURCE_PORT 0x020A +#define DESTINATION_PORT 0x020B +#define SAR_MSG_REF_NUM 0x020C +#define LANGUAGE_INDICATOR 0x020D +#define SAR_TOTAL_SEGMENTS 0x020E +#define SAR_SEGMENT_SEQNUM 0x020F +#define SC_INTERFACE_VERSION 0x0210 +#define CALLBACK_NUM_PRES_IND 0x0302 +#define CALLBACK_NUM_ATAG 0x0303 +#define NUMBER_OF_MESSAGES 0x0304 +#define CALLBACK_NUM 0x0381 +#define DPF_RESULT 0x0420 +#define SET_DPF 0x0421 +#define MS_AVAILABILITY_STATUS 0x0422 +#define NETWORK_ERROR_CODE 0x0423 +#define MESSAGE_PAYLOAD 0x0424 +#define DELIVERY_FAILURE_REASON 0x0425 +#define MORE_MESSAGES_TO_SEND 0x0426 +#define MESSAGE_STATE 0x0427 +#define USSD_SERVICE_OP 0x0501 +#define DISPLAY_TIME 0x1201 +#define SMS_SIGNAL 0x1203 +#define MS_VALIDITY 0x1204 +#define ALERT_ON_MESSAGE_DELIVERY 0x130C +#define ITS_REPLY_TYPE 0x1380 +#define ITS_SESSION_INFO 0x1383 + +/* Command status definition. */ +#define ESME_ROK 0x00000000 +#define ESME_RINVMSGLEN 0x00000001 +#define ESME_RINVCMDLEN 0x00000002 +#define ESME_RINVCMDID 0x00000003 +#define ESME_RINVBNDSTS 0x00000004 +#define ESME_RALYBND 0x00000005 +#define ESME_RINVPRTFLG 0x00000006 +#define ESME_RINVREGDLVFLG 0x00000007 +#define ESME_RSYSERR 0x00000008 +/* #define Reserved 0x00000009 */ +#define ESME_RINVSRCADR 0x0000000A +#define ESME_RINVDSTADR 0x0000000B +#define ESME_RINVMSGID 0x0000000C +#define ESME_RBINDFAIL 0x0000000D +#define ESME_RINVPASWD 0x0000000E +#define ESME_RINVSYSID 0x0000000F +/* #define Reserved 0x00000010 */ +#define ESME_RCANCELFAIL 0x00000011 +/*#define Reserved 0x00000012 */ +#define ESME_RREPLACEFAIL 0x00000013 +#define ESME_RMSGQFUL 0x00000014 +#define ESME_RINVSERTYP 0x00000015 +/* #define Reserved 0x00000016-0x00000032 */ +#define ESME_RINVNUMDESTS 0x00000033 +#define ESME_RINVDLNAME 0x00000034 +/* #define Reserved 0x00000035-0x0000003F */ +#define ESME_RINVDESTFLAG 0x00000040 +/* #define Reserved 0x00000041 */ +#define ESME_RINVSUBREP 0x00000042 +#define ESME_RINVESMCLASS 0x00000043 +#define ESME_RCNTSUBDL 0x00000044 +#define ESME_RSUBMITFAIL 0x00000045 +/* #define Reserved 0x00000046-0x00000047 */ +#define ESME_RINVSRCTON 0x00000048 +#define ESME_RINVSRCNPI 0x00000049 +/* #define Reserved 0x0000004A-0x0000004F */ +#define ESME_RINVDSTTON 0x00000050 +#define ESME_RINVDSTNPI 0x00000051 +/* #define Reserved 0x00000052 */ +#define ESME_RINVSYSTYP 0x00000053 +#define ESME_RINVREPFLAG 0x00000054 +#define ESME_RINVNUMMSGS 0x00000055 +/* #define Reserved 0x00000056-0x00000057 */ +#define ESME_RTHROTTLED 0x00000058 +/* #define Reserved 0x00000059-0x00000060 */ +#define ESME_RINVSCHED 0x00000061 +#define ESME_RINVEXPIRY 0x00000062 +#define ESME_RINVDFTMSGID 0x00000063 +#define ESME_RX_T_APPN 0x00000064 +#define ESME_RX_P_APPN 0x00000065 +#define ESME_RX_R_APPN 0x00000066 +#define ESME_RQUERYFAIL 0x00000067 +/* #define Reserved 0x00000068-0x000000BF */ +#define ESME_RINVOPTPARSTREAM 0x000000C0 +#define ESME_ROPTPARNOTALLWD 0x000000C1 +#define ESME_RINVPARSLEN 0x000000C2 +#define ESME_RMISSINGOPTPARAM 0x000000C3 +#define ESME_RINVOPTPARAMVAL 0x000000C4 +/* #define Reserved 0x000000C5-0x000000FD */ +#define ESME_RDELIVERYFAILURE 0x000000FE +#define ESME_RUNKNOWNERR 0x000000FF +/* #define Reserved_for_SMPP_extention 0x00000100-0x000003FF */ +/* #define Reserved_for_SMSC_vendor_specific_errors 0x00000100-0x000003FF */ +/* #define Reserved 0x00000500-0xFFFFFFFF */ + +/* define dest_network_type optional parameters */ +#define DEST_NETWORK_TYPE_UNKNOWN 0x00 +#define DEST_NETWORK_TYPE_GSM 0x01 +#define DEST_NETWORK_TYPE_ANSI136_TDMA 0x02 +#define DEST_NETWORK_TYPE_IS95_CDMA 0x03 +#define DEST_NETWORK_TYPE_PDC 0x04 +#define DEST_NETWORK_TYPE_PHS 0x05 +#define DEST_NETWORK_TYPE_IDEN 0x06 +#define DEST_NETWORK_TYPE_AMPS 0x07 +#define DEST_NETWORK_TYPE_PAGING_NETWORK 0x08 + +/* define destination address type */ +#define DESTINATION_ADDRESS_SME_ADDRESS 0x01 +#define DESTINATION_ADDRESS_DISTRIBUTION_LIST_NAME 0x02 + +/* define Type of Number(TON) */ +#define TON_UNKNOWN 0x0 +#define TON_INTERNATIONAL 0x1 +#define TON_NATIONAL 0x2 +#define TON_NETWORK_SPECIFIC 0x3 +#define TON_SUBSCRIBER_NUMBER 0x4 +#define TON_ALPHANUMERIC 0x5 +#define TON_ABBREVIATE 0x6 + +/* define Numeric Plan Indicator(NPI) */ +#define NPI_UNKNOWN 0x0 +#define NPI_ISDN 0x1 +#define NPI_DATA 0x3 +#define NPI_TELEX 0x4 +#define NPI_LAND_MOBILE 0x6 +#define NPI_NATIONAL 0x8 +#define NPI_PRIVATE 0x9 +#define NPI_ERMES 0xa +#define NPI_INTERNET 0xe + +#endif + diff --git a/omc/plat/smpp/src/include/smpp_def.h b/omc/plat/smpp/src/include/smpp_def.h new file mode 100644 index 0000000..3ef63a3 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp_def.h @@ -0,0 +1,39 @@ + +#ifndef _SMPP_DEF_h +#define _SMPP_DEF_h + +SMPP_CALLBACK callBackFunc[MAX_SMPP_LINK]; +SMPP_PARAM smpp_param[MAX_SMPP_LINK]; +SMPP_LINK smpp_link[MAX_SMPP_LINK]; +struct SocketsInUse Mysock; +SMPP_DEBUG_STRUCT smppDebug; + +BYTE exterEvent[MAX_SMPP_LINK][CMD_BUF_SIZE]; +BYTE interEvent[MAX_SMPP_LINK][CMD_BUF_SIZE]; +BYTE exter_head[MAX_SMPP_LINK]; +BYTE exter_tail[MAX_SMPP_LINK]; +BYTE inter_head[MAX_SMPP_LINK]; +BYTE inter_tail[MAX_SMPP_LINK]; + +BYTE smpp_state[MAX_SMPP_LINK]; +BYTE smpp_hearbeat_status[MAX_SMPP_LINK/4]; +BYTE interface_mode[MAX_SMPP_LINK]; +BYTE data_mode[MAX_SMPP_LINK]; + +BYTE linkAttachFlag[MAX_SMPP_LINK]; +BYTE smpp_TCPClientFlag[MAX_SMPP_LINK]; +char smpp_debug_asciiIn[MAX_ASCIN_BUF_LEN]; +char smpp_debug_asciiOut[MAX_ASCOUT_BUF_LEN]; +BYTE smppDebugFull = 0; + +BYTE src_ref[MAX_SMPP_LINK]; +BYTE dst_ref[MAX_SMPP_LINK]; + +BYTE smpp_msg[MAX_PACKET_SIZE]; + +BYTE smpp_system_no; + +#endif + + + diff --git a/omc/plat/smpp/src/include/smpp_ext.h b/omc/plat/smpp/src/include/smpp_ext.h new file mode 100644 index 0000000..4dd9604 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp_ext.h @@ -0,0 +1,38 @@ +#ifndef _SMPP_EXT_h +#define _SMPP_EXT_h + +extern SMPP_CALLBACK callBackFunc[MAX_SMPP_LINK]; +extern SMPP_PARAM smpp_param[MAX_SMPP_LINK]; +extern SMPP_LINK smpp_link[MAX_SMPP_LINK]; +extern struct SocketsInUse Mysock; +extern SMPP_DEBUG_STRUCT smppDebug; + +extern BYTE exterEvent[MAX_SMPP_LINK][CMD_BUF_SIZE]; +extern BYTE interEvent[MAX_SMPP_LINK][CMD_BUF_SIZE]; +extern BYTE exter_head[MAX_SMPP_LINK]; +extern BYTE exter_tail[MAX_SMPP_LINK]; +extern BYTE inter_head[MAX_SMPP_LINK]; +extern BYTE inter_tail[MAX_SMPP_LINK]; + +extern BYTE smpp_state[MAX_SMPP_LINK]; +extern BYTE smpp_hearbeat_status[MAX_SMPP_LINK/4]; +extern BYTE interface_mode[MAX_SMPP_LINK]; +extern BYTE data_mode[MAX_SMPP_LINK]; + +extern BYTE linkAttachFlag[MAX_SMPP_LINK]; +extern BYTE smpp_TCPClientFlag[MAX_SMPP_LINK]; +extern char smpp_debug_asciiIn[MAX_ASCIN_BUF_LEN]; +extern char smpp_debug_asciiOut[MAX_ASCOUT_BUF_LEN]; +extern BYTE smppDebugFull; + +extern BYTE src_ref[MAX_SMPP_LINK]; +extern BYTE dst_ref[MAX_SMPP_LINK]; + +extern BYTE smpp_msg[MAX_PACKET_SIZE]; + +extern BYTE smpp_system_no; + +#endif + + + diff --git a/omc/plat/smpp/src/include/smpp_msg.h b/omc/plat/smpp/src/include/smpp_msg.h new file mode 100644 index 0000000..ff9f5d1 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp_msg.h @@ -0,0 +1,466 @@ + +#ifndef _SMPP_MSG_h +#define _SMPP_MSG_h + + +typedef struct SMPP_HEAD +{ + DWORD command_length; + DWORD command_id; + DWORD command_status; + DWORD sequence_number; +}SMPP_HEAD; + +typedef struct SMPP_GENERAL +{ + SMPP_HEAD head; + BYTE msg[SMPP_MSG_LEN]; +}SMPP_GENERAL; + +typedef struct PDU_BIND +{ + SMPP_HEAD head; + char system_id[16]; + char password[9]; + char system_type[13]; + BYTE interface_version; + BYTE addr_ton; + BYTE addr_npi; + char address_range[41]; +}PDU_BIND; + +typedef struct PDU_BIND_RESP +{ + SMPP_HEAD head; + char system_id[16]; + /* optional parameter */ + BYTE sc_interface_version; +}PDU_BIND_RESP; + +typedef struct PDU_OUTBIND +{ + SMPP_HEAD head; + char system_id[16]; + char password[9]; +}PDU_OUTBIND; + +typedef struct PDU_UNBIND +{ + SMPP_HEAD head; +}PDU_UNBIND; + +typedef struct PDU_UNBIND_RESP +{ + SMPP_HEAD head; +}PDU_UNBIND_RESP; + +typedef struct PDU_GENERIC_NACK +{ + SMPP_HEAD head; +}PDU_GENERIC_NACK; + +typedef struct PDU_SUBMIT_SM +{ + SMPP_HEAD head; + + /* define mandatory parameters */ + char service_type[6]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[21]; + BYTE esm_class; + BYTE protocol_id; + BYTE priority_flag; + char schedule_delivery_time[17]; + char validity_period[17]; + BYTE registered_delivery; + BYTE replace_if_present_flag; + BYTE data_coding; + BYTE sm_default_msg_id; + BYTE sm_length; + BYTE short_message[254]; + + /* define optional parameters */ + /* total: 28 parameters. */ /* param_flag1 */ + WORD user_message_reference; /* 0x0000 0001 */ + WORD source_port; /* 0x0000 0002 */ + BYTE source_addr_subunit; /* 0x0000 0004 */ + WORD destination_port; /* 0x0000 0008 */ + BYTE dest_addr_subunit; /* 0x0000 0010 */ + WORD sar_msg_ref_num; /* 0x0000 0020 */ + BYTE sar_total_segments; /* 0x0000 0040 */ + BYTE sar_segment_seqnum; /* 0x0000 0080 */ + BYTE more_messages_to_send; /* 0x0000 0100 */ + BYTE payload_type; /* 0x0000 0200 */ + char message_payload[MAX_MSG_SIZE]; /* 0x0000 0400 */ + BYTE privacy_indicator; /* 0x0000 0800 */ + char callback_num[19]; /* 0x0000 1000 */ + BYTE callback_num_pres_ind; /* 0x0000 2000 */ + char callback_num_atag[65]; /* 0x0000 4000 */ + char source_subaddress[23]; /* 0x0000 8000 */ + char dest_subaddress[23]; /* 0x0001 0000 */ + BYTE user_response_code; /* 0x0002 0000 */ + BYTE display_time; /* 0x0004 0000 */ + WORD sms_signal; /* 0x0008 0000 */ + BYTE ms_validity; /* 0x0010 0000 */ + BYTE ms_msg_wait_facilities; /* 0x0020 0000 */ + BYTE number_of_messages; /* 0x0040 0000 */ + BYTE alert_on_message_delivery; /* 0 byte. */ /* 0x0080 0000 */ + BYTE language_indicator; /* 0x0100 0000 */ + BYTE its_reply_type; /* 0x0200 0000 */ + BYTE its_session_info[2]; /* 0x0400 0000 */ + BYTE ussd_service_op; /* 0x0800 0000 */ + BYTE dest_network_type; /* 0x1000 0000 */ /* smpp v5.0 */ +}PDU_SUBMIT_SM; + +typedef struct PDU_SUBMIT_SM_RESP +{ + SMPP_HEAD head; + char message_id[65]; +}PDU_SUBMIT_SM_RESP; + +typedef struct SME_DEST_ADDRESS +{ + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[21]; +}SME_DEST_ADDRESS; + +typedef struct DL_NAME +{ + char dl_name[21]; +}DL_NAME; + +typedef union DEST_ADDR +{ + SME_DEST_ADDRESS sme_dest_address; + DL_NAME dl_name; +}DEST_ADDR; + +typedef struct DESTINATION_ADDRESS_DEFINITION +{ + BYTE dest_flag; + DEST_ADDR dest_addr; +}DESTINATION_ADDRESS_DEFINITIAON; + +typedef struct PDU_SUBMIT_MULTI +{ + SMPP_HEAD head; + + /* define mandatory parameters */ + char service_type[6]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; + BYTE number_of_dests; + DESTINATION_ADDRESS_DEFINITIAON dest_address[SMPP_MAX_MULTI_ADDRESS]; + BYTE esm_class; + BYTE protocol_id; + BYTE priority_flag; + char schedule_delivery_time[17]; + char validity_period[17]; + BYTE registered_delivery; + BYTE replace_if_present_flag; /* set to NULL */ + BYTE data_coding; + BYTE sm_default_msg_id; + BYTE sm_length; + BYTE short_message[254]; + + /* define optional parameters */ + /* total: 22 parameters. */ /* param_flag1 */ + WORD user_message_reference; /* 0x0000 0001 */ + WORD source_port; /* 0x0000 0002 */ + BYTE source_addr_subunit; /* 0x0000 0004 */ + WORD destination_port; /* 0x0000 0008 */ + BYTE dest_addr_subunit; /* 0x0000 0010 */ + WORD sar_msg_ref_num; /* 0x0000 0020 */ + BYTE sar_total_segments; /* 0x0000 0040 */ + BYTE sar_segment_seqnum; /* 0x0000 0080 */ + BYTE payload_type; /* 0x0000 0100 */ + char message_payload[MAX_MSG_SIZE]; /* 0x0000 0200 */ + BYTE privacy_indicator; /* 0x0000 0400 */ + char callback_num[19]; /* 0x0000 0800 */ + BYTE callback_num_pres_ind; /* 0x0000 1000 */ + char callback_num_atag[65]; /* 0x0000 2000 */ + char source_subaddress[23]; /* 0x0000 4000 */ + char dest_subaddress[23]; /* 0x0000 8000 */ + BYTE display_time; /* 0x0001 0000 */ + WORD sms_signal; /* 0x0002 0000 */ + BYTE ms_validity; /* 0x0004 0000 */ + BYTE ms_msg_wait_facilities; /* 0x0008 0000 */ + BYTE alert_on_message_delivery;/* 0byte */ /* 0x0010 0000 */ + BYTE language_indicator; /* 0x0020 0000 */ + BYTE dest_network_type; /* 0x0040 0000 */ +}PDU_SUBMIT_MULTI; + +typedef struct UNSUCCESS_SME +{ + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[21]; + DWORD error_status_code; +}UNSUCCESS_SME; + +typedef struct PDU_SUBMIT_MULTI_RESP +{ + SMPP_HEAD head; + char message_id[65]; + BYTE no_unsuccess; + UNSUCCESS_SME unsuccess_sme[MAX_SME]; +}PDU_SUBMIT_MULTI_RESP; + +typedef struct PDU_DELIVER_SM +{ + SMPP_HEAD head; + + /* define mandatory parameter. */ + char service_type[6]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[21]; + BYTE esm_class; + BYTE protocol_id; + BYTE priority_flag; + char schedule_delivery_time; /* set to NULL */ + char validity_period; /* set to NULL */ + BYTE registered_delivery; + BYTE replace_if_present_flag; /* set to NULL */ + BYTE data_coding; + BYTE sm_default_msg_id; /* set to NULL */ + BYTE sm_length; + BYTE short_message[254]; + + /* define optional parameter. */ + /* total: 19 parameters. */ /* param_flag1 */ + WORD user_message_reference; /* 0x0000 0001 */ + WORD source_port; /* 0x0000 0002 */ + WORD destination_port; /* 0x0000 0004 */ + WORD sar_msg_ref_num; /* 0x0000 0008 */ + BYTE sar_total_segments; /* 0x0000 0010 */ + BYTE sar_segment_seqnum; /* 0x0000 0020 */ + BYTE user_response_code; /* 0x0000 0040 */ + BYTE privacy_indicator; /* 0x0000 0080 */ + BYTE payload_type; /* 0x0000 0100 */ + char message_payload[MAX_MSG_SIZE]; /* 0x0000 0200 */ + char callback_num[49]; /* 0x0000 0400 */ + char source_subaddress[23]; /* 0x0000 0800 */ + char dest_subaddress[23]; /* 0x0000 1000 */ + BYTE language_indicator; /* 0x0000 2000 */ + BYTE its_session_info[2]; /* 0x0000 4000 */ + char network_error_code[3]; /* 0x0000 8000 */ + BYTE message_state; /* 0x0001 0000 */ + char receipted_message_id[65]; /* 0x0002 0000 */ + BYTE ussd_service_op; /* 0x0004 0000 */ /* smpp v5.0 */ +}PDU_DELIVER_SM; + +typedef struct PDU_DELIVER_SM_RESP +{ + SMPP_HEAD head; + char message_id; +}PDU_DELIVER_SM_RESP; + +typedef struct PDU_DATA_SM +{ + SMPP_HEAD head; + + /* define mandatory paramter. */ + char service_type[6]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[65]; + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[65]; + BYTE esm_class; + BYTE registered_delivery; + BYTE data_coding; + + /* define optional parameter. */ + /* total: 38 paramters. */ /* param_flag */ + WORD source_port; /* 0x0000 0001 */ /* param_flag1 start. */ + BYTE source_addr_subunit; /* 0x0000 0002 */ + BYTE source_network_type; /* 0x0000 0004 */ + BYTE source_bearer_type; /* 0x0000 0008 */ + WORD source_telematics_id; /* 0x0000 0010 */ + WORD destination_port; /* 0x0000 0020 */ + BYTE dest_addr_subunit; /* 0x0000 0040 */ + BYTE dest_network_type; /* 0x0000 0080 */ + BYTE dest_bearer_type; /* 0x0000 0100 */ + WORD dest_telematics_id; /* 0x0000 0200 */ + WORD sar_msg_ref_num; /* 0x0000 0400 */ + BYTE sar_total_segments; /* 0x0000 0800 */ + BYTE sar_segment_seqnum; /* 0x0000 1000 */ + BYTE more_messages_to_send; /* 0x0000 2000 */ + DWORD qos_time_to_live; /* 0x0000 4000 */ + BYTE payload_type; /* 0x0000 8000 */ + char message_payload[MAX_MSG_SIZE]; /* 0x0001 0000 */ + BYTE set_dpf; /* 0x0002 0000 */ + char receipted_message_id[65]; /* 0x0004 0000 */ + BYTE message_state; /* 0x0008 0000 */ + char network_error_code[3]; /* 0x0010 0000 */ + WORD user_message_reference; /* 0x0020 0000 */ + BYTE privacy_indicator; /* 0x0040 0000 */ + char callback_num[19]; /* 0x0080 0000 */ + BYTE callback_num_pres_ind; /* 0x0100 0000 */ + char callback_num_atag[65]; /* 0x0200 0000 */ + char source_subaddress[23]; /* 0x0400 0000 */ + char dest_subaddress[23]; /* 0x0800 0000 */ + BYTE user_response_code; /* 0x1000 0000 */ + BYTE display_time; /* 0x2000 0000 */ + WORD sms_signal; /* 0x4000 0000 */ + BYTE ms_validity; /* 0x8000 0000 */ /* param_flag1 end. */ + BYTE ms_msg_wait_facilities; /* 0x0000 0001 */ /* param_flag2 start. */ + BYTE number_of_messages; /* 0x0000 0002 */ + BYTE alert_on_message_delivery;/* 0byte */ /* 0x0000 0004 */ + BYTE language_indicator; /* 0x0000 0008 */ + BYTE its_reply_type; /* 0x0000 0010 */ + BYTE its_session_info[2]; /* 0x0000 0020 */ +}PDU_DATA_SM; + +typedef struct PDU_DATA_SM_RESP +{ + SMPP_HEAD head; + char message_id[65]; +}PDU_DATA_SM_RESP; + +typedef struct PDU_QUERY_SM +{ + SMPP_HEAD head; + char message_id[65]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; +}PDU_QUERY_SM; + +typedef struct PDU_QUERY_SM_RESP +{ + SMPP_HEAD head; + char message_id[65]; + char final_date[17]; + BYTE message_state; + BYTE error_code; +}PDU_QUERY_SM_RESP; + +typedef struct PDU_CANCEL_SM +{ + SMPP_HEAD head; + char service_type[6]; + char message_id[65]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; + BYTE dest_addr_ton; + BYTE dest_addr_npi; + char destination_addr[21]; +}PDU_CANCEL_SM; + +typedef struct PDU_CANCEL_SM_RESP +{ + SMPP_HEAD head; +}PDU_CANCEL_SM_RESP; + +typedef struct PDU_REPLACE_SM +{ + SMPP_HEAD head; + + /* define mandatory parameter */ + char message_id[65]; + BYTE source_addr_ton; + BYTE source_addr_npi; + char source_addr[21]; + char schedule_delivery_time[17]; + char validity_period[17]; + BYTE registered_delivery; + BYTE sm_default_msg_id; + BYTE sm_length; + BYTE short_message[254]; +}PDU_REPLACE_SM; + +typedef struct PDU_REPLACE_SM_RESP +{ + SMPP_HEAD head; +}PDU_REPLACE_SM_RESP; + +typedef struct PDU_ENQUIRE_LINK +{ + SMPP_HEAD head; +}PDU_ENQUIRE_LINK; + +typedef struct PDU_ENQUIRE_LINK_RESP +{ + SMPP_HEAD head; +}PDU_ENQUIRE_LINK_RESP; + +typedef struct PDU_ALERT_NOTIFICATION +{ + SMPP_HEAD head; + BYTE source_addr_ton; + BYTE source_addr_npi; + BYTE source_addr[65]; + BYTE esme_addr_ton; + BYTE esme_addr_npi; + BYTE esme_addr[65]; + BYTE ms_availability_status; +}PDU_ALERT_NOTIFICATION; + +typedef union SMPP_PDU +{ + PDU_BIND bind_transmitter; /* message_type = 0x01 */ + PDU_BIND_RESP bind_transmitter_resp; /* message_type = 0x02 */ + PDU_BIND bind_receiver; /* message_type = 0x03 */ + PDU_BIND_RESP bind_receiver_resp; /* message_type = 0x04 */ + PDU_BIND bind_transceiver; /* message_type = 0x05 */ + PDU_BIND_RESP bind_transceiver_resp; /* message_type = 0x06 */ + PDU_OUTBIND outbind; /* message_type = 0x07 */ + PDU_UNBIND unbind; /* message_type = 0x08 */ + PDU_UNBIND_RESP unbind_resp; /* message_type = 0x09 */ + PDU_GENERIC_NACK generic_nack; /* message_type = 0x0A */ + PDU_SUBMIT_SM submit_sm; /* message_type = 0x0B */ + PDU_SUBMIT_SM_RESP submit_sm_resp; /* message_type = 0x0C */ + PDU_SUBMIT_MULTI submit_multi; /* message_type = 0x0D */ + PDU_SUBMIT_MULTI_RESP submit_multi_resp; /* message_type = 0x0E */ + PDU_DELIVER_SM deliver_sm; /* message_type = 0x0F */ + PDU_DELIVER_SM_RESP deliver_sm_resp; /* message_type = 0x10 */ + PDU_DATA_SM data_sm; /* message_type = 0x11 */ + PDU_DATA_SM_RESP data_sm_resp; /* message_type = 0x12 */ + PDU_QUERY_SM query_sm; /* message_type = 0x13 */ + PDU_QUERY_SM_RESP query_sm_resp; /* message_type = 0x14 */ + PDU_CANCEL_SM cancel_sm; /* message_type = 0x15 */ + PDU_CANCEL_SM_RESP cancel_sm_resp; /* message_type = 0x16 */ + PDU_REPLACE_SM replace_sm; /* message_type = 0x17 */ + PDU_REPLACE_SM_RESP replace_sm_resp; /* message_type = 0x18 */ + PDU_ENQUIRE_LINK enquire_link; /* message_type = 0x19 */ + PDU_ENQUIRE_LINK_RESP enquire_link_resp; /* message_type = 0x1A */ + PDU_ALERT_NOTIFICATION alert_notification; /* message_type = 0x1B */ +}SMPP_PDU; + +typedef struct SMPP_MSG +{ + BYTE message_type; + DWORD optional_param_flag1; /* for optional parameter 1~32 */ + DWORD optional_param_flag2; /* for optional parameter 33~64 */ + SMPP_PDU pdu; +}SMPP_MSG; + +typedef struct SMPP_OPTIONAL_PARAMETER +{ + WORD tag; + WORD len; + BYTE value[MAX_MSG_SIZE]; +}SMPP_OPTIONAL_PARAMETER; + +/* by simon at 23/9/26 */ +// BYTE smpp_msg_buf[MAX_SMPP_LINK][MAX_PACKET_SIZE]; +// int smpp_msg_buf_len[MAX_SMPP_LINK]; + +#endif + + + + diff --git a/omc/plat/smpp/src/include/smpp_public.h b/omc/plat/smpp/src/include/smpp_public.h new file mode 100644 index 0000000..eec27e7 --- /dev/null +++ b/omc/plat/smpp/src/include/smpp_public.h @@ -0,0 +1,62 @@ +/* +** CDMA 2000 project, SMPP module +** +** File name: public.h +** Written by Li Long at 2004-11-25 +** CVS $Id: public.h,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ +#ifndef _SMPP_PUBLIC_h +#define _SMPP_PUBLIC_h + + +#include +#include +#include +#include +#include +#include + +#ifndef NULL +#define NULL 0 +#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 + +#ifndef _T_BOOL +#define _T_BOOL +typedef int BOOL; +#endif + +#ifndef SUCCESS +#define SUCCESS (0) +#endif + +#ifndef FAILURE +#define FAILURE (-1) +#endif + +#ifndef TRUE +#define TRUE (1) +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#endif + + diff --git a/omc/plat/smpp/src/smpp_debug.c b/omc/plat/smpp/src/smpp_debug.c new file mode 100644 index 0000000..8fc1dbb --- /dev/null +++ b/omc/plat/smpp/src/smpp_debug.c @@ -0,0 +1,471 @@ +/* +** CDMA 2000 project, smpp module +** +** File name: smpp_debug.c +** Written by Li Long at 2004-11-25 +** CVS $Id: smpp_debug.c,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ + +#include "./include/smpp.h" +#include "./include/smpp_ext.h" + +static char smpp_debug_status = 1; +static WORD disp_page[10]; +static char *disp_ptr = (char *) disp_page; + +static DWORD smpp_status_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,1 + }; + +static DWORD smpp_version_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,2 + }; + +static DWORD smpp_ascii_in_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,3 + }; + +static DWORD smpp_ascii_out_id[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,4 + }; + +static DWORD smpp_page_title[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,1,1 + }; + +static DWORD smpp_page_line[20] = + { + 1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_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 char title1_p[] = +{ + " SMPP R9 Page 01 link status (32 links)\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +link_status\n\r\ +\n\r\ +daemon sock\r\n\ +tcp_client_flag\r\n\ +\r\n\ +sock_fd\r\n\ +\r\n\ +\r\n\ +\r\n\ +\r\n\ +\r\n\ +\r\n\ +\r\n\ +\r\n\ +\tLink status:\r\n\ +\t\t00 -- Not init\r\n\ +\t\t01 -- IDLE\r\n\ +\t\t02 -- WAITING\r\n\ +\t\t03 -- ESTABLISHED\r\n\ +\t\t04 -- SUSPEND" +}; + +static char title2_p[] = +{ + " SMPP R9 Page 02 debug struct (32 links)\n\r\ + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\ +debug_switch\n\r\ +link_switch\n\r" +}; + +static char title3_p[] = +{ + " SMPP R9 Page 03 link type (link 0~21)\n\r\ + type\t\t00 -- UDP,\t01 -- TCP\n\r\ +link 0\n\r\ +link 1\n\r\ +link 2\n\r\ +link 3\n\r\ +link 4\n\r\ +link 5\n\r\ +link 6\n\r\ +link 7\n\r\ +link 8\n\r\ +link 9\n\r\ +link 10\n\r\ +link 11\n\r\ +link 12\n\r\ +link 13\n\r\ +link 14\n\r\ +link 15\n\r\ +link 16\n\r\ +link 17\n\r\ +link 18\n\r\ +link 19\n\r\ +link 20\n\r\ +link 21\n\r" +}; + +static char title4_p[] = +{ + " SMPP R9 Page 04 link type (link 22~31)\n\r\ + type\t\t00 -- UDP,\t01 -- TCP\n\r\ +link 22\n\r\ +link 23\n\r\ +link 24\n\r\ +link 25\n\r\ +link 26\n\r\ +link 27\n\r\ +link 28\n\r\ +link 29\n\r\ +link 30\n\r\ +link 31\n\r" +}; + +static char title5_p[] = +{ + " SMPP R9 Page 05 server_sock & client_sock\n\r\ + \r\n\ +server_sock\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +\n\r\ +client_sock\n\r\ +\n\r" +}; + +BYTE smpp_disp_line(BYTE page, BYTE line) +{ + BYTE disp_length; + + disp_length = 16; + disp_ptr = (char *) disp_page; + + switch (page) + { + case 1: + switch (line) + { + case 0: + case 1: + disp_ptr = (char *) &smpp_state[disp_page[page]] + (line * 16); + break; + case 2: + disp_ptr = (char *) &(Mysock.DaemonSock); + disp_length = 1; + break; + case 3: + case 4: + disp_ptr = (char *) &smpp_TCPClientFlag[disp_page[page]]+(line-3)*16; + break; + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + disp_ptr = (char *) &(Mysock.Sockets[disp_page[page]]) + ((line-5)*16); + break; + default: + disp_length = 0; + break; + } + break; + case 2: // Page 2: link debug status + if (line == 0) + { + disp_ptr = (char *) &smppDebug.debug_switch; + disp_length = 1; + } + else if (line < 3) + disp_ptr = (char *) &smppDebug.link_switch[disp_page[page]] + ((line - 1) * 16); + else + disp_length = 0; + break; + case 3: //page 3: link type + if (line<22) + { + disp_ptr = (char *) &smpp_param[line].link_type; + disp_length = 1; + } + break; + case 4: //page 3: link type(0~21) + if (line<10) + { + disp_ptr = (char *) &smpp_param[line+22].link_type; + disp_length = 1; + }else + disp_length = 0; + break; + case 5: //page 5: server_socket and client_sockets + switch (line) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + disp_ptr = (char *) &Mysock.server_sock[disp_page[page]] + line*16; + break; + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + disp_ptr = (char *) &Mysock.client_sock[disp_page[page]] + (line-8)*16; + break; + default: + disp_length = 0; + break; + } + break; + default: + disp_length = 0; + break; + } + + return disp_length; +} + +void smpp_disp_page(BYTE page) +{ + BYTE disp_line; + BYTE disp_length; + + smpp_page_line[PAGE_POINT] = page + 5; + + for (disp_line = 0; disp_line < 22; disp_line++) + { + disp_length = smpp_disp_line(page, disp_line); + smpp_page_line[LINE_POINT] = disp_line + 2; + smpp_page_line[LINE_POINT + 1] = 2; // Data Pointer + debug_set_response(BASE_ID_LEN + 2, smpp_page_line, disp_ptr, disp_length); + } +} + +void smpp_debugInit() +{ + int page; + char* ptr; + + smppDebug.debug_switch = 0; + + debug_set_response(15, smpp_status_id, &smpp_debug_status, 1);//smpp status + debug_set_response(15, smpp_version_id, SMPP_MODULE_VERSION, strlen(SMPP_MODULE_VERSION)); + debug_set_response(15, smpp_ascii_in_id, smpp_debug_asciiIn, MAX_ASCIN_BUF_LEN); + debug_set_response(15, smpp_ascii_out_id, smpp_debug_asciiOut, MAX_ASCOUT_BUF_LEN); + + for (page=1; page<=5; page++) + { + switch (page) + { + case 1: + ptr = title1_p; + break; + case 2: + ptr = title2_p; + break; + case 3: + ptr = title3_p; + break; + case 4: + ptr = title4_p; + break; + case 5: + ptr = title5_p; + break; + default: + break; + } + smpp_page_title[PAGE_POINT] = 5 + page; + debug_set_response(BASE_ID_LEN + 1, smpp_page_title, ptr, strlen(ptr)); + smpp_disp_page(page); + } + + #ifdef SMPP_DEBUG + printf("smpp debug init.\n"); + #endif //end ifdef SMPP_DEBUG +} + +void smpp_list_linkparam(int linkNo) { + char debug_str[256]; + struct in_addr addr; + + if (linkNo >= MAX_SMPP_LINK) + { + smpp_send_error("Link number is too big.\n\r"); + return; + } + + sprintf(debug_str, "\r\nLink %d parameter:\r\n", linkNo); + smpp_send_ascout(debug_str); + sprintf(debug_str, "link_enable: %d\r\n", smpp_param[linkNo].link_enable); + smpp_send_ascout(debug_str); + sprintf(debug_str, "link_type: %d\r\n", smpp_param[linkNo].link_type); + smpp_send_ascout(debug_str); + sprintf(debug_str, "server_type: %d\r\n", smpp_param[linkNo].server_type); + smpp_send_ascout(debug_str); + sprintf(debug_str, "session_type: %d\r\n", smpp_param[linkNo].session_type); + smpp_send_ascout(debug_str); + sprintf(debug_str, "system_id: %s\r\n", smpp_param[linkNo].sys_id); + smpp_send_ascout(debug_str); + sprintf(debug_str, "password: %s\r\n", smpp_param[linkNo].password); + smpp_send_ascout(debug_str); + sprintf(debug_str, "system_type: %s\r\n", smpp_param[linkNo].system_type); + smpp_send_ascout(debug_str); + sprintf(debug_str, "localGTT: %s\r\n", smpp_param[linkNo].localGTT); + smpp_send_ascout(debug_str); + sprintf(debug_str, "remoteGTT: %s\r\n", smpp_param[linkNo].remoteGTT); + smpp_send_ascout(debug_str); + addr.s_addr = smpp_param[linkNo].local_ip; + sprintf(debug_str, "local_ip: %s\r\n", inet_ntoa(addr)); + smpp_send_ascout(debug_str); + addr.s_addr = smpp_param[linkNo].remote_ip; + sprintf(debug_str, "remote_ip: %s\r\n", inet_ntoa(addr)); + smpp_send_ascout(debug_str); + sprintf(debug_str, "session_init_timer: %ld\r\n", smpp_param[linkNo].session_init_timer); + smpp_send_ascout(debug_str); + sprintf(debug_str, "enquire_link_timer: %ld\r\n", smpp_param[linkNo].enquire_link_timer); + smpp_send_ascout(debug_str); + sprintf(debug_str, "inactivity_timer: %ld\r\n", smpp_param[linkNo].inactivity_timer); + smpp_send_ascout(debug_str); + sprintf(debug_str, "response_timer: %ld\r\n", smpp_param[linkNo].response_timer); + smpp_send_ascout(debug_str); + sprintf(debug_str, "service_number: %s\r\n", smpp_param[linkNo].service_number); + smpp_send_ascout(debug_str); + sprintf(debug_str, "localSSN: %d\r\n", smpp_param[linkNo].localSSN); + smpp_send_ascout(debug_str); + sprintf(debug_str, "remoteSSN: %d\r\n", smpp_param[linkNo].remoteSSN); + smpp_send_ascout(debug_str); +} + +void smpp_debugTimer() +{ + int i, linkNo = 0; + char debugBuf[1024]; + + if (strlen(smpp_debug_asciiIn) > 0) + { + if (strcmp(smpp_debug_asciiIn+1, "help") == 0) + { + smpp_send_ascout("SMPP Debug Monitor Help:\n\r\n\r"); + smpp_send_ascout("log none Turn off all log items\n\r"); + smpp_send_ascout("log all Turn on all log items\n\r"); + smpp_send_ascout("log link=\x1b[34mxx\x1b[0m on/off Turn on/off link x messages\n\r"); + smpp_send_ascout("list par.\x1b[34mxx\x1b[0m List link x parameter\r\n"); + sprintf(debugBuf, "ver. %s T%03d\r\n",SMPP_MODULE_VERSION,SMPP_MODULE_PATCH); + smpp_send_ascout(debugBuf); + }else if (strcmp(smpp_debug_asciiIn+1, "log none") == 0) + { + smppDebug.debug_switch = 0; + for (i=0; i= '0') && (smpp_debug_asciiIn[10] <= '9')) { + linkNo = smpp_debug_asciiIn[10] - '0'; + if ((smpp_debug_asciiIn[11] >= '0') && (smpp_debug_asciiIn[11] <= '9')) { + linkNo = linkNo*10+(smpp_debug_asciiIn[11]-'0'); +// if (linkNo > MAX_SMPP_LINK) +// smpp_send_error("Link number is too big.\n\r"); + smpp_list_linkparam(linkNo); + } + else + smpp_list_linkparam(linkNo); + } + else + smpp_send_error("Link number is error"); + } + else if (strncmp(smpp_debug_asciiIn+1, "save", 4) == 0) { + smpp_writeParam(); + } + else if (strncmp(smpp_debug_asciiIn+1, "log link=", 9) == 0) { + if ((smpp_debug_asciiIn[10] >= '0') && (smpp_debug_asciiIn[10] <= '9')) + { + linkNo = smpp_debug_asciiIn[10] - '0'; + if ((smpp_debug_asciiIn[11] >= '0') && (smpp_debug_asciiIn[11] <= '9')) + { + linkNo = linkNo*10+(smpp_debug_asciiIn[11]-'0'); + if (linkNo > MAX_SMPP_LINK) + { + smpp_send_error("Link number is too big.\n\r"); + } + else if (strncmp(smpp_debug_asciiIn+13, "on", 2) == 0) + { + smppDebug.link_switch[linkNo] = 1; + sprintf(debugBuf, "Link %d debug on.\n\r", linkNo); + smpp_send_ascout(debugBuf); + }else if (strncmp(smpp_debug_asciiIn+13, "off", 3) == 0) + { + smppDebug.link_switch[linkNo] = 0; + sprintf(debugBuf, "Link %d debug off.\n\r", linkNo); + smpp_send_ascout(debugBuf); + }else + { + smpp_send_error("Command Error.\n\r"); + } + }else if (strncmp(smpp_debug_asciiIn+12, "on", 2) == 0) + { + smppDebug.link_switch[linkNo] = 1; + sprintf(debugBuf, "Link %d debug on.\n\r", linkNo); + smpp_send_ascout(debugBuf); + }else if (strncmp(smpp_debug_asciiIn+12, "off", 3) == 0) + { + smppDebug.link_switch[linkNo] = 0; + sprintf(debugBuf, "Link %d debug off.\n\r", linkNo); + smpp_send_ascout(debugBuf); + }else + { + smpp_send_error("Command Error.\n\r"); + } + } + else + smpp_send_error("Link number error.\n\r"); + }else + { + smpp_send_error("Command Error.\n\r"); + } + + smpp_debug_asciiIn[0] = '\0'; + } +} + +void smpp_send_ascout(char *sdBuf) +{ + if (strlen(sdBuf)+strlen(smpp_debug_asciiOut) < MAX_ASCOUT_BUF_LEN) + { + strcat(smpp_debug_asciiOut, sdBuf); + } +} + +void smpp_send_error(char *sdBuf) +{ + if (smppDebug.debug_switch == 1) + { + smpp_send_ascout("\x1b[31m"); + smpp_send_ascout(sdBuf); + smpp_send_ascout("\x1b[0m"); + } +} diff --git a/omc/plat/smpp/src/smpp_fsm.c b/omc/plat/smpp/src/smpp_fsm.c new file mode 100644 index 0000000..1ed767b --- /dev/null +++ b/omc/plat/smpp/src/smpp_fsm.c @@ -0,0 +1,673 @@ +/* +** CDMA 2000 project, SMPP module +** +** File name: smpp_fsm.c +** Written by Li Long at 2004-11-25 +** CVS $Id: smpp_fsm.c,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ + +#include "./include/smpp.h" +#include "./include/smpp_ext.h" +static int smpp_timerCount = 0; +//static int flag=-1; + +/* Timer variable definitions. */ +static BYTE session_init_flag[MAX_SMPP_LINK]; +static WORD session_init_timer[MAX_SMPP_LINK]; +static BYTE enquire_link_flag[MAX_SMPP_LINK]; +static WORD enquire_link_timer[MAX_SMPP_LINK]; +static BYTE inactivity_flag[MAX_SMPP_LINK]; +static WORD inactivity_timer[MAX_SMPP_LINK]; +static BYTE response_flag[MAX_SMPP_LINK]; +static WORD response_timer[MAX_SMPP_LINK]; +static BYTE init_tcp_client_timeout[MAX_SMPP_LINK]={0}; +static WORD suspend_timer = 0; +/* by simon at 23/9/26 */ +int smpp_msg_buf_len[MAX_SMPP_LINK]; + +void smpp_stateInit() +{ + int i; + + for (i=0; i1000)//1000*10ms=10s + { + smpp_checkParam(); + smpp_timerCount = 0; + } + + smpp_rvMsgOverTCP(); +// smpp_rvMsgOverSCCP(SMPP_PPS_USERTYPE); + smpp_rvMsgOverSCCP(SMPP_SMSC_USERTYPE); + smpp_debugTimer(); + for(link=0; link 0) init_tcp_client_timeout[link]--; + + /* Session init timer */ + if (TRUE == session_init_flag[link]) + { + session_init_timer[link]++; + if (session_init_timer[link] > 100*smpp_param[link].session_init_timer) + { + session_init_timer[link] = 0; + inter_head[link] = (inter_head[link]+1)&0x7; + interEvent[link][inter_head[link]] = SessionInitTimeout; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1)) + { + sprintf(debugBuf, "link %d session_init_timer TIMEOUT.\n", link); + smpp_send_ascout(debugBuf); + } + #endif + } + } + /* Enquire link timer */ + if (TRUE == enquire_link_flag[link]) + { + enquire_link_timer[link]++; + if (enquire_link_timer[link] > 100*smpp_param[link].enquire_link_timer) + { + enquire_link_timer[link] = 0; + inter_head[link] = (inter_head[link]+1)&0x7; + interEvent[link][inter_head[link]] = EnquireLinkTimeout; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1)) + { + sprintf(debugBuf, "link %d T1 (Enquire link timer) TIMEOUT.\n", link); + smpp_send_ascout(debugBuf); + } + #endif + } + } + /* Inactivity timer */ + if (TRUE == inactivity_flag[link]) + { + inactivity_timer[link]++; + if (inactivity_timer[link] > 100*smpp_param[link].inactivity_timer) + { + inactivity_timer[link] = 0; + inter_head[link] = (inter_head[link]+1)&0x7; + interEvent[link][inter_head[link]] = InactivityTimeout; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1)) + { + sprintf(debugBuf, "link %d T2 (Inactivity timer) TIMEOUT.\n", link); + smpp_send_ascout(debugBuf); + } + #endif + } + } + } + + for(link=0; link 0) + { + if (TRUE == linkUseFlag[link]) + smpp_state[link] = IDLE; + } + */ + break; + case IDLE: + //IDLE state:: external event start. + switch (exterEvent[link][exter_tail[link]]) { + case Setup: + switch (smpp_param[link].server_type) { + case SMPP_SERVER: + switch (smpp_param[link].session_type) { + case BIND_RX: + smpp_state[link] = WAITING; + smpp_PrimitiveSend(link, Outbind); + session_init_flag[link] = TRUE; + //flag = 2; + //smpp_state[link] = WAITING;//ch:if smpp_PrimitiveSend failed,that would be error + temp_status = WAITING;//ch:if smpp_PrimitiveSend failed,that would be error + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + /* + case BIND_TRX: + smpp_PrimitiveSend(link, BindTransceiver); + session_init_flag[link] = TRUE; + flag = 1; + smpp_state[link] = WAITING; + temp_status = WAITING; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + */ + default: + break; + } + break; + case SMPP_CLIENT: + switch (smpp_param[link].session_type) { + case BIND_TX: + smpp_state[link] = WAITING; + smpp_PrimitiveSend(link, BindTransmitter); + session_init_flag[link] = TRUE; + //flag = 1; + //smpp_state[link] = WAITING; + temp_status = WAITING; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + /* + case BIND_RX: + smpp_PrimitiveSend(link, BindReceiver); + session_init_flag[link] = TRUE; + flag = 0; + smpp_state[link] = WAITING; + temp_status = WAITING; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + */ + case BIND_TRX: + smpp_state[link] = WAITING; + smpp_PrimitiveSend(link, BindTransceiver); + session_init_flag[link] = TRUE; + //flag = 1; + //smpp_state[link] = WAITING; + temp_status = WAITING; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + default: + break; + } + break; + default: + break; + } + break; + default: + break; + } + exterEvent[link][exter_tail[link]] = 0; + exter_tail[link] = (exter_tail[link]+1)&0x7; + //IDLE state:: external event end. + //IDLE state:: internal event start. + switch (interEvent[link][inter_tail[link]]) { + case Outbind: + smpp_state[link] = WAITING; + smpp_PrimitiveSend(link, BindReceiver); + session_init_flag[link] = TRUE; + //flag = 0; + //smpp_state[link] = WAITING; + temp_status = WAITING; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case BindTransmitter: + smpp_state[link] = ESTABLISHED; + smpp_PrimitiveSend(link, BindTransmitterResp); + enquire_link_flag[link] = TRUE; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + + break; + case BindTransceiver: + smpp_state[link] = ESTABLISHED; + smpp_PrimitiveSend(link, BindTransceiverResp); + enquire_link_flag[link] = TRUE; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + + break;//fixed 2008-1-11 + case BindReceiver: + smpp_state[link] = ESTABLISHED; + smpp_PrimitiveSend(link, BindReceiverResp); + session_init_flag[link] = FALSE; + enquire_link_flag[link] = TRUE; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + + break; + default: + break; + } + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + //IDLE state:: internal event end. + break; + case WAITING: + switch (exterEvent[link][exter_tail[link]]) { + case Close: + smpp_state[link] = IDLE; + temp_status = IDLE; + dst_ref[link] = 0; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + default: + break; + } + exterEvent[link][exter_tail[link]] = 0; + exter_tail[link] = (exter_tail[link]+1)&0x7; + //WAITING state:: external event end. + //WAITING state:: Internal event start. + switch (interEvent[link][inter_tail[link]]) + { + case SessionInitTimeout: + session_init_flag[link] = FALSE; + smpp_state[link] = IDLE; + temp_status = IDLE; + dst_ref[link] = 0; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case BindReceiverResp: + //if (0 == flag) { + session_init_flag[link] = FALSE; + enquire_link_flag[link] = TRUE; + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + + /* + } + else + smpp_state[link] = WAITING; + */ + break; + case BindTransmitterResp: + case BindTransceiverResp: + //if (1 == flag) { + session_init_flag[link] = FALSE; + enquire_link_flag[link] = TRUE; + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + + /* + } + else + smpp_state[link] = WAITING; + */ + break; + case BindReceiver: + //if (2 == flag) { + smpp_PrimitiveSend(link, BindReceiverResp); + session_init_flag[link] = FALSE; + enquire_link_flag[link] = TRUE; + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,TRUE); + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + return; + /* + } + else + smpp_state[link] = WAITING; + */ + break; + default: + break; + } + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + //WAITING state:: internal event end. + break; + case ESTABLISHED: + switch (exterEvent[link][exter_tail[link]]) + { + case Close: + smpp_state[link] = SUSPEND; + smpp_PrimitiveSend(link, Unbind); + //smpp_state[link] = SUSPEND; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + default: + break; + } + exterEvent[link][exter_tail[link]] = 0; + exter_tail[link] = (exter_tail[link]+1)&0x7; + //ESTABLISHED state:: external event end. + //ESTABLISHED state:: internal event start. + switch (interEvent[link][inter_tail[link]]) + { + //normal messages + case Unbind: + smpp_PrimitiveSend(link, UnbindResp); + dst_ref[link] = 0; + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + return; + break; + case SubmitSM: + case SubmitSMResp: + case SubmitMulti: + case SubmitMultiResp: + case DeliverSM: + case DeliverSMResp: + case DataSM: + case DataSMResp: + case QuerySM: + case QuerySMResp: + case CancelSM: + case CancelSMResp: + case ReplaceSM: + case ReplaceSMResp: + enquire_link_timer[link] = 0; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case EnquireLinkTimeout: + smpp_state[link] = ESTABLISHED; + smpp_PrimitiveSend(link, EnquireLink); + inactivity_flag[link] = TRUE; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case EnquireLink: + smpp_state[link] = ESTABLISHED; + smpp_PrimitiveSend(link, EnquireLinkResp); + enquire_link_timer[link] = 0; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case EnquireLinkResp: + enquire_link_timer[link] = 0; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case InactivityTimeout: + //smpp_PrimitiveSend(link, Unbind); + //smpp_state[link] = SUSPEND; + dst_ref[link] = 0; + if (smpp_param[link].link_type == SMPP_TCP) + { + smpp_closeTCPConnection(link); + } + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + return; + break; + /* error handing messages */ + case BindTransmitter: + smpp_state[link] = ESTABLISHED; +// smpp_sendBindResp(link, BindTransmitterResp, ESME_RALYBND); + smpp_sendBindResp(link, BindTransmitterResp, 0); + enquire_link_timer[link] = 0; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case BindReceiver: + smpp_state[link] = ESTABLISHED; +// smpp_sendBindResp(link, BindReceiverResp, ESME_RALYBND); + smpp_sendBindResp(link, BindReceiverResp, 0); + enquire_link_timer[link] = 0; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case BindTransceiver: + smpp_state[link] = ESTABLISHED; +// smpp_sendBindResp(link, BindTransceiverResp, ESME_RALYBND); + smpp_sendBindResp(link, BindTransceiverResp, 0); + enquire_link_timer[link] = 0; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + //smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + default: + smpp_state[link] = ESTABLISHED; + temp_status = ESTABLISHED; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + } + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + //ESTABLISHED state:: internal event end. + break; + case SUSPEND: + //SUSPEND state:: internal event start. + suspend_timer ++; + switch (interEvent[link][inter_tail[link]]) + { + case UnbindResp: + suspend_timer = 0; + dst_ref[link] = 0; + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + return; + break; +/* case InactivityTimeout://ch + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + dst_ref[link] = 0; + if (smpp_param[link].link_type == SMPP_TCP) + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; + case SessionInitTimeout://ch + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + dst_ref[link] = 0; + if (smpp_param[link].link_type == SMPP_TCP) + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + break; */ + default: + break; + } + interEvent[link][inter_tail[link]] = 0; + inter_tail[link] = (inter_tail[link]+1)&0x7; + if( suspend_timer++ > smpp_param[link].inactivity_timer) + { + suspend_timer = 0; + dst_ref[link] = 0; + if (smpp_param[link].link_type == SMPP_TCP) + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + return; + } + //SUSPEND state:: internal event end. + break; + default: + break; + } //end switch(state) + } //end for(froc... + + //platform heartbeat + platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4); + set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status); +} + +void init_link(u32 link) +{ + BYTE temp_status; + dst_ref[link] = 0; + smpp_closeTCPConnection(link); + enquire_link_flag[link] = FALSE; + inactivity_flag[link] = FALSE; + inactivity_timer[link] = 0; + smpp_state[link] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((link%4)*2); + smpp_hearbeat_status[link/4] |= temp_status; + if(callBackFunc[link].link_proc!= NULL) + callBackFunc[link].link_proc(link,FALSE); + return; +} + diff --git a/omc/plat/smpp/src/smpp_func.c b/omc/plat/smpp/src/smpp_func.c new file mode 100644 index 0000000..2d9bdb7 --- /dev/null +++ b/omc/plat/smpp/src/smpp_func.c @@ -0,0 +1,1167 @@ +/* +** CDMA 2000 project, SMPP module +** +** File name: smpp_func.c +** Written by Li Long at 2004-11-25 +** CVS $Id: smpp_func.c,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ + +#include "./include/smpp.h" +#include "./include/smpp_def.h" + +extern int register_ssn(BYTE ssn, BYTE usertype); +/* by simon at 23/9/26 */ +SocketsMsg SockMsg; + +int smpp_init_new(u8 sys_id) +{ + smpp_system_no = sys_id & 0x01; + #ifdef SMPP_DEBUG + smpp_debugInit(); + #endif //end ifdef SMPP_DEBUG + smpp_mibInit(); + smpp_loadParam(); + smpp_writeParam(); + + heartbeat_init(0xffff); + + smpp_initTCPClient(); + smpp_initTCPServer(); + smpp_stateInit(); + smpp_msgInit(); + +// if (FALSE == register_ssn(SMPP_PPS_SSN, SMPP_PPS_USERTYPE)) + if (FALSE == register_ssn(SMPP_PPS_SSN, SMPP_SMSC_USERTYPE)) + printf("SMPP register PPS SSN %d fail!\n", SMPP_PPS_SSN); + if (FALSE == register_ssn(SMPP_SMSC_SSN, SMPP_SMSC_USERTYPE)) + printf("SMPP register SMSC SSN %d fail!\n", SMPP_SMSC_SSN); + printf("SMPP init........ Complete.\n"); + + return TRUE; +} + +void smpp_reset() +{ + int i; + for (i=0; i0x00 && smpp_param[i].local_ip != GetLocalIP()) continue; + + len_get = strlen(service_number_ptr); + if (len_get > 8) { + service_number_ptr[8] = 0; + len_get = 8; + } + len_in_para = strlen(smpp_param[i].service_number); + if (len_in_para < len_get) { + if (strncmp(service_number_ptr, smpp_param[i].service_number, len_in_para) == 0) { + smpp_param[i].message_mode = message_mode; + return (BYTE)((i&0x7F)|0x80); + } + } + else { + if (strcmp(service_number_ptr, smpp_param[i].service_number) == 0) { + smpp_param[i].message_mode = message_mode; + return (BYTE)((i&0x7F)|0x80); + } + } + } + + sprintf(debugBuf,"smpp_registerLink(server_type:%d,session_type:%d,service_number:%s,message_mode:%d) fail\r\n\r\n",server_type,session_type,service_number_ptr,message_mode); + smpp_send_error(debugBuf); + return 0; +} + +void smpp_attach_link(BYTE linkNo, smpp_callBack_dataProc onDataRecv, + smpp_callBack_linkProc onLinkStateChange) +{ + BYTE temp_status; + + if(linkNo>=MAX_SMPP_LINK) return; + + // removed by simon, 2023/11/04 + //printf("[smpp]link %d attached.\n", linkNo); + if(smpp_state[linkNo] == ESTABLISHED || + smpp_state[linkNo] == SUSPEND) + { + if(callBackFunc[linkNo].link_proc!= NULL) + callBackFunc[linkNo].link_proc(linkNo,TRUE); + return; + } + else if(smpp_state[linkNo] == WAITING) + { + if(callBackFunc[linkNo].link_proc!= NULL) + callBackFunc[linkNo].link_proc(linkNo,FALSE); + return; + } + + linkAttachFlag[linkNo] = TRUE; + smpp_state[linkNo] = IDLE; + temp_status = IDLE; + temp_status = temp_status<<((linkNo%4)*2); + smpp_hearbeat_status[linkNo/4] |= temp_status; + callBackFunc[linkNo].data_proc = onDataRecv; + callBackFunc[linkNo].link_proc = onLinkStateChange; + exterEvent[linkNo][exter_head[linkNo]] = Setup; + exter_head[linkNo] = (exter_head[linkNo]+1)&0x7; + + if(SMPP_TCP == smpp_param[linkNo].link_type) + { + switch (smpp_param[linkNo].session_type) { + case BIND_TX: + case BIND_TRX: + if (smpp_param[linkNo].server_type == SMPP_CLIENT) + smpp_TCPClientFlag[linkNo] = 1; + break; + case BIND_RX: + if (smpp_param[linkNo].server_type == SMPP_SERVER) + smpp_TCPClientFlag[linkNo] = 1; + break; + } + } +} + +WORD smpp_send(BYTE linkNo, SMPP_MSG* pMsg, WORD dataLen) +{ + PDU_SUBMIT_SM *pSubmitSM; + PDU_SUBMIT_MULTI *pSubmitMulti; + PDU_DELIVER_SM *pDeliverSM; + PDU_DATA_SM *pDataSM; + PDU_QUERY_SM *pQuerySM; + PDU_CANCEL_SM *pCancelSM; + PDU_REPLACE_SM *pReplaceSM; + DWORD seqNum; + +// printf("\33[32mlink %d call smpp_send, message_type=%d\33[0m\n", linkNo, pMsg->message_type); + switch (pMsg->message_type) + { + case 0x0B: /* SUBMIT SM */ + pSubmitSM = &pMsg->pdu.submit_sm; + pSubmitSM->head.command_id = htonl(SUBMIT_SM); + pSubmitSM->head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pSubmitSM->head.sequence_number = htonl(seqNum); + pSubmitSM->head.sequence_number = htonl(pSubmitSM->head.sequence_number); + + smpp_encode_msg(linkNo, pMsg, SubmitSM); + break; + case 0x0C: /* SUBMIT SM RESP */ + pMsg->pdu.submit_sm_resp.head.command_id = htonl(SUBMIT_SM_RESP); + seqNum = ntohl(pMsg->pdu.submit_sm_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, SubmitSMResp); + break; + case 0x0D: /* SUBMIT MULTI */ + pSubmitMulti = &pMsg->pdu.submit_multi; + pMsg->pdu.submit_multi.head.command_id = htonl(SUBMIT_MULTI); + pMsg->pdu.submit_multi.head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pMsg->pdu.submit_multi.head.sequence_number = htonl(seqNum); + pSubmitMulti->head.sequence_number = htonl(pSubmitMulti->head.sequence_number); + + smpp_encode_msg(linkNo, pMsg, SubmitMulti); + break; + case 0x0E: /* SUBMIT MULTI RESP */ + pMsg->pdu.submit_multi_resp.head.command_id = htonl(SUBMIT_MULTI_RESP); + seqNum = ntohl(pMsg->pdu.submit_multi_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, SubmitMultiResp); + break; + case 0x0F: /* DELIVER SM */ + pDeliverSM = &pMsg->pdu.deliver_sm; + pDeliverSM->head.command_id = htonl(DELIVER_SM); + pDeliverSM->head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pDeliverSM->head.sequence_number = htonl(seqNum); + pDeliverSM->head.sequence_number = htonl(pDeliverSM->head.sequence_number); + + pDeliverSM->schedule_delivery_time = 0; + pDeliverSM->validity_period = 0; + pDeliverSM->replace_if_present_flag = 0; + pDeliverSM->sm_default_msg_id = 0; + + smpp_encode_msg(linkNo, pMsg, DeliverSM); + break; + case 0x10: /* DELIVER SM RESP */ + pMsg->pdu.deliver_sm.head.command_id = htonl(DELIVER_SM_RESP); + seqNum = ntohl(pMsg->pdu.deliver_sm.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, DeliverSMResp); + break; + case 0x11: /* DATA SM */ + pDataSM = &pMsg->pdu.data_sm; + pDataSM->head.command_id = htonl(DATA_SM); + pDataSM->head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pDataSM->head.sequence_number = htonl(seqNum); + pDataSM->head.sequence_number = htonl(pDataSM->head.sequence_number); + + smpp_encode_msg(linkNo, pMsg, DataSM); + break; + case 0x12: /* DATA SM RESP */ + pMsg->pdu.data_sm_resp.head.command_id = htonl(DATA_SM_RESP); + seqNum = ntohl(pMsg->pdu.data_sm_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, DataSMResp); + break; + case 0x13: /* QUERY SM */ + pQuerySM = &pMsg->pdu.query_sm; + pMsg->pdu.query_sm.head.command_id = htonl(QUERY_SM); + pMsg->pdu.query_sm.head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pMsg->pdu.query_sm.head.sequence_number = htonl(seqNum); + pQuerySM->head.sequence_number = htonl(pQuerySM->head.sequence_number); + + smpp_encode_msg(linkNo, pMsg, QuerySM); + break; + case 0x14: /* QUERY SM RESP */ + pMsg->pdu.query_sm_resp.head.command_id = htonl(QUERY_SM_RESP); + seqNum = ntohl(pMsg->pdu.query_sm_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, QuerySMResp); + break; + case 0x15: /* CANCEL SM */ + pCancelSM = &pMsg->pdu.cancel_sm; + pMsg->pdu.cancel_sm.head.command_id = htonl(CANCEL_SM); + pMsg->pdu.cancel_sm.head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pMsg->pdu.cancel_sm.head.sequence_number = htonl(seqNum); + pCancelSM->head.sequence_number = htonl(pCancelSM->head.sequence_number); + + smpp_encode_msg(linkNo, pMsg, CancelSM); + break; + case 0x16: /* CANCEL SM RESP */ + pMsg->pdu.cancel_sm_resp.head.command_id = htonl(CANCEL_SM_RESP); + seqNum = ntohl(pMsg->pdu.cancel_sm_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, CancelSMResp); + break; + case 0x17: /* REPLACE SM */ + pReplaceSM = &pMsg->pdu.replace_sm; + pMsg->pdu.replace_sm.head.command_id = htonl(REPLACE_SM); + pMsg->pdu.replace_sm.head.command_status = 0x0; + //seqNum = smpp_getSequenceNumber(linkNo); + //pMsg->pdu.replace_sm.head.sequence_number = htonl(seqNum); + pReplaceSM->head.sequence_number = htonl(pReplaceSM->head.sequence_number); + smpp_encode_msg(linkNo, pMsg, ReplaceSM); + break; + case 0x18: /* REPLACE SM RESP */ + pMsg->pdu.replace_sm_resp.head.command_id = htonl(REPLACE_SM_RESP); + seqNum = ntohl(pMsg->pdu.replace_sm_resp.head.sequence_number); + smpp_encode_msg(linkNo, pMsg, ReplaceSMResp); + break; + default: +// printf("[ERROR]link %d no such message type!(=%02x)\n", linkNo, pMsg->message_type); + return 0; + } + + return seqNum; +} + +void smpp_close(BYTE linkNo) +{ + exterEvent[linkNo][exter_head[linkNo]] = Close; + exter_head[linkNo] = (exter_head[linkNo]+1)&0x7; +} + +void smpp_PrimitiveSend(int linkNo, int event_id) +{ + switch (event_id) + { + case BindTransmitter: + smpp_sendBind(linkNo, BindTransmitter); + break; + case BindTransmitterResp: + smpp_sendBindResp(linkNo, BindTransmitterResp, 0); + break; + case BindReceiver: + smpp_sendBind(linkNo, BindReceiver); + break; + case BindReceiverResp: + smpp_sendBindResp(linkNo, BindReceiverResp, 0); + break; + case BindTransceiver: + smpp_sendBind(linkNo, BindTransceiver); + break; + case BindTransceiverResp: + smpp_sendBindResp(linkNo, BindTransceiverResp, 0); + break; + case Unbind: + smpp_sendUnbind(linkNo); + break; + case UnbindResp: + smpp_sendUnbindResp(linkNo); + break; + case EnquireLink: + smpp_sendEnquireLink(linkNo); + break; + case EnquireLinkResp: + smpp_sendEnquireLinkResp(linkNo); + break; + case Outbind: + smpp_sendOutbind(linkNo); + break; + default: + break; + } +} + +void smpp_initTCPClintByLink(unsigned int linkNo) +{ + int on=1, flag=1; + struct sockaddr_in local_addr; + + if(linkNo>=MAX_SMPP_LINK) return; + + if (((smpp_param[linkNo].link_enable & 0x01) == 0) || (smpp_param[linkNo].link_type == SMPP_UDP)) + { + return; + } + if ((Mysock.client_sock[linkNo] = socket(AF_INET, SOCK_STREAM, 0))<0) + { + return; + } + if (setsockopt(Mysock.client_sock[linkNo], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) + { + close(Mysock.client_sock[linkNo]); + return; + } + if (setsockopt(Mysock.client_sock[linkNo], SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) == -1) + { + close(Mysock.client_sock[linkNo]); + return; + } + if (fcntl(Mysock.client_sock[linkNo], F_SETFL, O_NONBLOCK) == -1) + { + close(Mysock.client_sock[linkNo]); + return; + } + /* Set this sockets as a Non-blocking sockets. */ + if (ioctl(Mysock.client_sock[linkNo], FIONBIO, &flag) == -1) + { + close(Mysock.client_sock[linkNo]); + return; + } + + bzero(&local_addr, sizeof(local_addr)); + local_addr.sin_family = AF_INET; + local_addr.sin_addr.s_addr = GetLocalIP();//htonl(INADDR_ANY); + local_addr.sin_port = 0; + memset(local_addr.sin_zero, 0, sizeof(local_addr.sin_zero)); + if (bind(Mysock.client_sock[linkNo], (struct sockaddr *)&local_addr, sizeof(local_addr)) < 0) + { + perror("init TCP Client By Link: bind error"); + exit(1); + } +} + +void smpp_initTCPClient() +{ + int i; + + for (i=0; ih_addr_list))->s_addr = GetLocalIP(); + host_ip = inet_ntoa(*(struct in_addr *)(*host->h_addr_list)); + } + else + { + perror("[smpp] gethostbyname"); + exit(2); + } + } + + return host_ip; +} + +int smpp_closeTCPConnection(int linkNo) +{ + int retcode; + + if ( (linkNo>=MAX_SMPP_LINK) || (linkNo<0) || (Mysock.Sockets[linkNo]<=0) ) + return (0); + retcode = close(Mysock.Sockets[linkNo]); + + FD_CLR(Mysock.Sockets[linkNo], &Mysock.readfds); + FD_CLR(Mysock.Sockets[linkNo], &Mysock.writefds); + FD_CLR(Mysock.Sockets[linkNo], &Mysock.exceptfds); + Mysock.Sockets[linkNo] = 0; + + #ifdef SMPP_PRINT_SCREEN +// printf("link %d close TCP connection.\n", linkNo); + #endif + return (retcode); +} + +int QuerySocketsMsg() +{ + fd_set rfds,wfds,efds; + int retcode,i; + struct timeval TimeOut; + + rfds = Mysock.readfds; + wfds = Mysock.writefds; + efds = Mysock.exceptfds; + TimeOut.tv_sec = 0; + TimeOut.tv_usec = 0; + bzero((char *)&SockMsg, sizeof(SockMsg)); + if ((retcode = select(MAX_SMPP_LINK, &rfds, &wfds, &efds, &TimeOut)) == 0) + { + return (0); + } + if (FD_ISSET(Mysock.DaemonSock, &rfds)) + { + SockMsg.AcceptNum = 1; + } + for (i=0; i0) && (FD_ISSET(Mysock.Sockets[i],&rfds))) + { + SockMsg.ReadQueue[SockMsg.ReadNum++] = i; + } + } + for (i=0; i0) && (FD_ISSET(Mysock.Sockets[i],&wfds))) + { + SockMsg.WriteQueue[SockMsg.WriteNum++] = i; + } + } + if (FD_ISSET(Mysock.DaemonSock, &efds)) + { + SockMsg.AcceptNum = -1; + } + for (i=0; i0) && (FD_ISSET(Mysock.Sockets[i],&efds))) + { + SockMsg.WriteQueue[SockMsg.ExceptNum++] = i; + } + } + + return (retcode); +} + +int smpp_check_sysid_route(char* sysid_rv, BYTE sysidlen_rv, BYTE server_type, BYTE session_type) +{ + int i; + char debugBuf[256]; + + for (i=0; iRI = 0; + pSrcAddr->GTI = 4; + pSrcAddr->TT = 0; + pSrcAddr->NP = 1; /* MSISDN */ + pSrcAddr->NAI = 4; + pDstAddr->SSN = smpp_param[linkNo].localSSN; + pSrcAddr->len = smpp_ascii2GTAI(pSrcAddr->GTAI, smpp_param[linkNo].localGTT); + + /* set SCCP destination address. */ + pDstAddr->RI = 0; + pDstAddr->GTI = 4; + pDstAddr->TT = 0; + pDstAddr->NP = 1; /* MSISDN */ + pDstAddr->NAI = 4; + pDstAddr->SSN = smpp_param[linkNo].remoteSSN; + pDstAddr->len = smpp_ascii2GTAI(pDstAddr->GTAI, smpp_param[linkNo].remoteGTT); +} + +BYTE smpp_ascii2GTAI(BYTE *pGTAI, char *pGTT) +{ + BYTE len, bcd; + int i; + char debugBuf[1024]; + + len = strlen(pGTT); + if (len < 1) return 0; + if (len==16) len = 15;//last BYTE is ssn + for (i=0; i>4) == 0xf) + { + pGTT[i*2+1] = '\0'; + } + else + { + pGTT[i*2+1] = ((pGTAI[i]>>4)&0xf) + '0'; + } + } + pGTT[len] = '\0'; +} + +void smpp_addTLV(BYTE *smpp_msg, WORD optionTag, BYTE *pMsg, WORD len) +{ + WORD ns_optionTag; + WORD ns_len; + + ns_optionTag = htons(optionTag); + switch (optionTag) + { + /* value 0 byte */ + case ALERT_ON_MESSAGE_DELIVERY: + memcpy(smpp_msg, &ns_optionTag, 2); + len = 0; + memcpy(smpp_msg+2, &len, 2); + break; + /* value 1 byte for integer. */ + case DEST_ADDR_SUBUNIT: + case SOURCE_ADDR_SUBUNIT: + case DEST_NETWORK_TYPE: + case SOURCE_NETWORK_TYPE: + case DEST_BEARER_TYPE: + case SOURCE_BEARER_TYPE: + case PRIVACY_INDICATOR: + case PAYLOAD_TYPE: + case LANGUAGE_INDICATOR: + case USER_RESPONSE_CODE: + case MS_MSG_WAIT_FACILITIES: + case SAR_TOTAL_SEGMENTS: + case SAR_SEGMENT_SEQNUM: + case SC_INTERFACE_VERSION: + case DISPLAY_TIME: + case MS_VALIDITY: + case DPF_RESULT: + case SET_DPF: + case MS_AVAILABILITY_STATUS: + case DELIVERY_FAILURE_REASON: + case MORE_MESSAGES_TO_SEND: + case MESSAGE_STATE: + case CALLBACK_NUM_PRES_IND: + case NUMBER_OF_MESSAGES: + case ITS_REPLY_TYPE: + case USSD_SERVICE_OP: + memcpy(smpp_msg, &ns_optionTag, 2); + len = 1; + ns_len = htons(len); + memcpy(smpp_msg+2, &ns_len, 2); + *(smpp_msg+4) = *pMsg; + break; + /* value 2 bytes for integer */ + case DEST_TELEMATICS_ID: + case SOURCE_TELEMATICS_ID: + case USER_MESSAGE_REFERENCE: + case SOURCE_PORT: + case DESTINATION_PORT: + case SAR_MSG_REF_NUM: + case SMS_SIGNAL: + case ITS_SESSION_INFO: + memcpy(smpp_msg, &ns_optionTag, 2); + len = 2; + ns_len = htons(len); + memcpy(smpp_msg+2, &ns_len, 2); + memcpy(smpp_msg+4, pMsg, 2); + break; + /* value 3 bytes for octet string */ + case NETWORK_ERROR_CODE: + memcpy(smpp_msg, &ns_optionTag, 2); + len = 3; + ns_len = htons(len); + memcpy(smpp_msg+2, &ns_len, 2); + memcpy(smpp_msg+4, pMsg, 3); + break; + /* value 4 bytes for integer */ + case QOS_TIME_TO_LIVE: + memcpy(smpp_msg, &ns_optionTag, 2); + len = 4; + ns_len = htons(len); + memcpy(smpp_msg+2, &ns_len, 2); + memcpy(smpp_msg+4, pMsg, 4); + break; + /* variable length */ + case ADDITIONAL_STATUS_INFO_TEXT: + case RECEIPTED_MESSAGE_ID: + case SOURCE_SUBADDRESS: + case DEST_SUBADDRESS: + case MESSAGE_PAYLOAD: + case CALLBACK_NUM: + case CALLBACK_NUM_ATAG: + memcpy(smpp_msg, &ns_optionTag, 2); + ns_len = htons(len); + memcpy(smpp_msg+2, &ns_len, 2); + memcpy(smpp_msg+4, pMsg, len+1); + break; + } +} + +void smpp_display_hex_msg(BYTE* disp_ptr, int len) +{ + int i; + char debugBuf[4096]; + + for (i=0; i MAX_SMPP_LINK) return -1; + pParam = &smpp_param[instance]; + switch(oid[SMPP_OIDLEN+1]) { + case 1: + pParam->link_enable = pData[0]; + len = 1; + //link type + pParam->link_type = pData[1]; + len += 1; + //server type + pParam->server_type = pData[2]; + len += 1; + //session type + pParam->session_type = pData[3]; + len += 1; + //system id + memset(pParam->sys_id, 0, SMPP_SYSID_LEN); //16 + memcpy(pParam->sys_id, pData+len, SMPP_SYSID_LEN); + pParam->sys_id[SMPP_SYSID_LEN] = '\0'; + len += SMPP_SYSID_LEN; + //password + memset(pParam->password, 0, SMPP_PASSWD_LEN); //9 + memcpy(pParam->password, pData+len, SMPP_PASSWD_LEN); + pParam->password[SMPP_PASSWD_LEN] = '\0'; + len += SMPP_PASSWD_LEN; + //system type + memset(pParam->system_type, 0, SMPP_SYSTYPE_LEN); //13 + memcpy(pParam->system_type, pData+len, SMPP_SYSTYPE_LEN); + pParam->system_type[SMPP_SYSTYPE_LEN] = '\0'; + len += SMPP_SYSTYPE_LEN; + //local gtt + memset(pParam->localGTT, 0, SMPP_GTT_LEN); //16 + memcpy(pParam->localGTT, pData+len, SMPP_GTT_LEN); + pParam->localGTT[SMPP_GTT_LEN] = '\0'; + len += SMPP_GTT_LEN; + //remote gtt + memset(pParam->remoteGTT, 0, SMPP_GTT_LEN); + memcpy(pParam->remoteGTT, pData+len, SMPP_GTT_LEN); + pParam->remoteGTT[SMPP_GTT_LEN] = '\0'; + len += SMPP_GTT_LEN; + //local ip + memcpy(&pParam->local_ip, pData+len, 4); + len += 4; + //remote ip + memcpy(&pParam->remote_ip, pData+len, 4); + len += 4; + //session init timer + pParam->session_init_timer = bcdtou32(pData+len, 4); + len += 4; + // enquire link timer + pParam->enquire_link_timer = bcdtou32(pData+len, 4); + len += 4; + //inactivity timer + pParam->inactivity_timer = bcdtou32(pData+len, 4); + len += 4; + //response timer + pParam->response_timer = bcdtou32(pData+len, 4); + len += 4; + //remote service number + memset(pParam->service_number, 0, 8); + memcpy(pParam->service_number, pData+len, 8); + len += 8; + pParam->localSSN = pData[len]; + len += 1; + pParam->remoteSSN = pData[len]; + len += 1; + break; + default: + return (-1); + } + break; + case 3: //Status + switch (oid[SMPP_OIDLEN + 1]) { + case 1: //version, read only + return -1; + case 2: //command + switch (pData[0]) { + case 0: //reset + smpp_reset(); + break; + case 1: //load + smpp_loadParam(); + break; + case 2: //save + smpp_writeParam(); + break; + } + return 1; + case 3: //status, read only + return -1; + } + break; + default: + break; + } + return datalen; +} + +int smpp_getMib(BYTE oidlen, DWORD *oid, BYTE *pData, BYTE *vartype) +{ + int len=0, datalen = -1; + DWORD instance; + SMPP_PARAM *pParam; + + switch(oid[SMPP_OIDLEN]) + { + case 1: //Measurement + break; + case 2: //Configuration + instance = oid[SMPP_OIDLEN+2]; + if (instance > MAX_SMPP_LINK) return -1; + pParam = &smpp_param[instance]; + switch(oid[SMPP_OIDLEN+1]) + { + case 1: //smpp parameter + //link enable + pData[0] = pParam->link_enable; + len = 1; + //link type + pData[1] = pParam->link_type; + len += 1; + //server type + pData[2] = pParam->server_type; + len += 1; + //session type + pData[3] = pParam->session_type; + len += 1; + //system id + memcpy(pData+len, pParam->sys_id, SMPP_SYSID_LEN); + len += SMPP_SYSID_LEN; + //password + memcpy(pData+len, pParam->password, SMPP_PASSWD_LEN); + len += SMPP_PASSWD_LEN; + //system type + memcpy(pData+len, pParam->system_type, SMPP_SYSTYPE_LEN); + len += SMPP_SYSTYPE_LEN; + //local gtt + memcpy(pData+len, pParam->localGTT, SMPP_GTT_LEN); + len += SMPP_GTT_LEN; + //remote gtt + memcpy(pData+len, pParam->remoteGTT, SMPP_GTT_LEN); + len += SMPP_GTT_LEN; + //local ip + memcpy(pData+len, &pParam->local_ip, 4); + len += 4; + //remote ip + memcpy(pData+len, &pParam->remote_ip, 4); + len += 4; + //session init timer + u32tobyte(pData+len, pParam->session_init_timer); + len += 4; + //enquire link timer + u32tobyte(pData+len, pParam->enquire_link_timer); + len += 4; + //inactivity timer + u32tobyte(pData+len, pParam->inactivity_timer); + len += 4; + //response timer + u32tobyte(pData+len, pParam->response_timer); + len += 4; + //remote service number + memcpy(pData+len, &pParam->service_number, 8); + len += 8; + pData[len] = pParam->localSSN; + len += 1; + pData[len] = pParam->remoteSSN; + len += 1; + *vartype = 4; + datalen = len; + break; + default: + break; + } + break; + case 3: //Status + break; + default: + break; + } + + return datalen; +} + +int smpp_parseLine(char *str, char (*row)[128], int maxrow) +{ + char *pstr = str; + int len, index = 0, i; + BOOL black = 0; + + len = strlen(str); + for(i = 0; i < len && index < maxrow; i++) + { + if(isspace(str[i])) + { + if(black == 0) + pstr = str + i + 1; + else + { + str[i] = '\0'; + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + pstr = str + i + 1; + } + black = 0; + } + else + black = 1; + } + if(black == 1) + { + if(strlen(pstr) > 128) + pstr[127] = 0; + sprintf(row[index++], "%s", pstr); + } + return index; +} + +int smpp_loadParam() +{ + FILE *fp; + char str[512] = "\0", *pChr; + char info[19][128]; + int rtn; + int ver[3] = {0}; + BYTE linkNo; + + fp = fopen(SMPP_CONF_FILE, "r"); + if (fp == NULL) + { + printf("SMPP init parameters....search %s FAILED\n",SMPP_CONF_FILE); + return FAILURE; + } + + while (fgets(str, 512, fp) != NULL) { + if ((pChr = strchr(str, '#')) != NULL) { + if((pChr = strstr(pChr,"SMPP Config file"))!=NULL) + { + if ((pChr = strchr(pChr, 'R')) != NULL) + { + ver[0] = atoi(pChr+1); + ver[1] = atoi(pChr+3); + ver[2] = atoi(pChr+5); + } + } + continue; + } + + rtn = smpp_parseLine(str, info, 19); + if (rtn < 17) { + //smpp_debug(SCCPDB_ERR, "<001>Invalid line in Local_Node Table, field count = %d", rtn); + printf("Invalid line in ./conf/smpp.conf table, field count = %d\n", rtn); + return FALSE; + } + else if(rtn < 19) + { + sprintf(info[17],"0"); + sprintf(info[18],"0"); + } + + linkNo = atoi(info[0]); + smpp_param[linkNo].link_enable = atoi(info[1]); + smpp_param[linkNo].link_type = atoi(info[2]); + smpp_param[linkNo].server_type = atoi(info[3]); + smpp_param[linkNo].session_type = atoi(info[4]); + + if (strncmp(info[5], "--", 2) == 0) + strcpy(smpp_param[linkNo].sys_id, ""); + else + sprintf(smpp_param[linkNo].sys_id, "%s", info[5]); + + if (strncmp(info[6], "--", 2) == 0) + strcpy(smpp_param[linkNo].password, ""); + else + sprintf(smpp_param[linkNo].password, "%s", info[6]); + + if (strncmp(info[7], "--", 2) == 0) + strcpy(smpp_param[linkNo].system_type, ""); + else + sprintf(smpp_param[linkNo].system_type, "%s", info[7]); + + if (strncmp(info[8], "--", 2) == 0) + strcpy(smpp_param[linkNo].localGTT, ""); + else + sprintf(smpp_param[linkNo].localGTT, "%s", info[8]); + + if (strncmp(info[9], "--", 2) == 0) + strcpy(smpp_param[linkNo].remoteGTT, ""); + else + sprintf(smpp_param[linkNo].remoteGTT, "%s", info[9]); + + smpp_param[linkNo].local_ip = inet_addr(info[10]); + smpp_param[linkNo].remote_ip = inet_addr(info[11]); + smpp_param[linkNo].session_init_timer = atol(info[12]); + smpp_param[linkNo].enquire_link_timer = atol(info[13]); + smpp_param[linkNo].inactivity_timer = atol(info[14]); + smpp_param[linkNo].response_timer = atol(info[15]); + + if (strncmp(info[16], "--", 2) == 0) + strcpy(smpp_param[linkNo].service_number, ""); + else + sprintf(smpp_param[linkNo].service_number, "%s", info[16]); + + smpp_param[linkNo].localSSN = atoi(info[17]); + smpp_param[linkNo].remoteSSN = atoi(info[18]); + + if(ver[2] == 1) + if(smpp_param[linkNo].link_enable & 0x01) + smpp_param[linkNo].link_enable = 0x81; + /* + printf("link %d: link_enable=%d, link_type=%d; session_type=%d; sys_id=%s; password=%s; \ + system_type=%s; localGTT=%s; retmoteGTT=%s; local_ip=%s; remote ip=%s; \ + session init timer=%d; enquire link timer=%d; inactivity timer=%d; response timer=%d \ + remote service number: %s\n", + linkNo, smpp_param[linkNo].link_enable, smpp_param[linkNo].link_type, smpp_param[linkNo].session_type, smpp_param[linkNo].sys_id, smpp_param[linkNo].password, + smpp_param[linkNo].system_type, smpp_param[linkNo].localGTT, smpp_param[linkNo].remoteGTT, info[8], info[9], + smpp_param[linkNo].session_init_timer, smpp_param[linkNo].enquire_link_timer, smpp_param[linkNo].inactivity_timer, smpp_param[linkNo].response_timer, + smpp_param[linkNo].service_number + ); + */ + } + fclose(fp); + return TRUE; +} + +int smpp_writeParam() +{ + FILE *fp; + int i; + struct in_addr addr; + + if((fp = fopen(SMPP_CONF_FILE,"w")) == NULL) + return FAILURE; + + fprintf(fp,"#SMPP Config file (%s)\n",SMPP_MODULE_VERSION); + fprintf(fp,"#Copy this file to ./conf/smpp.conf to set global options\n"); + fprintf(fp,"#No lkEn lkType serverType sessionType sysID pwd sysType LGTT RGTT LIP RIP sessionTimer enqTimer inactTimer rspTimer ServiceNum localSSN remoteSSN\n"); + for(i=0; i< MAX_SMPP_LINK; i++) + { + fprintf(fp,"%d ", i); + fprintf(fp,"%d ", smpp_param[i].link_enable); + fprintf(fp,"%d ", smpp_param[i].link_type); + fprintf(fp,"%d ", smpp_param[i].server_type); + fprintf(fp,"%d ", smpp_param[i].session_type); + + if (smpp_param[i].sys_id[0] == 0) + strcpy(smpp_param[i].sys_id, "--"); + + fprintf(fp,"%s ", smpp_param[i].sys_id); + + if (smpp_param[i].password[0] == 0) + strcpy(smpp_param[i].password, "--"); + + fprintf(fp,"%s ", smpp_param[i].password); + + if (smpp_param[i].system_type[0] == 0) + fprintf(fp,"%s ", "--"); + else + fprintf(fp,"%s ", smpp_param[i].system_type); + + if (smpp_param[i].localGTT[0] == 0) + strcpy(smpp_param[i].localGTT, "--"); + fprintf(fp,"%s ", smpp_param[i].localGTT); + + if (smpp_param[i].remoteGTT[0] == 0) + strcpy(smpp_param[i].remoteGTT, "--"); + fprintf(fp,"%s ", smpp_param[i].remoteGTT); + + addr.s_addr = smpp_param[i].local_ip; + fprintf(fp,"%s ", inet_ntoa(addr)); + + addr.s_addr = smpp_param[i].remote_ip; + fprintf(fp,"%s ", inet_ntoa(addr)); + + fprintf(fp,"%ld ", smpp_param[i].session_init_timer); + fprintf(fp,"%ld ", smpp_param[i].enquire_link_timer); + fprintf(fp,"%ld ", smpp_param[i].inactivity_timer); + fprintf(fp,"%ld ", smpp_param[i].response_timer); + + if (smpp_param[i].service_number[0] == 0) + strcpy(smpp_param[i].service_number, "--"); + fprintf(fp, "%s ", smpp_param[i].service_number); + + fprintf(fp,"%d ", smpp_param[i].localSSN); + fprintf(fp,"%d\n", smpp_param[i].remoteSSN); + } + fclose(fp); + + return TRUE; +} + +void smpp_checkParam() +{ + if(smpp_param_flag) + { + smpp_writeParam(); + smpp_param_flag=0; + } +} + + +int smpp_enable_link() +{ + int i; + for (i=0; i= MAX_SMPP_LINK) + return -1; + pParam = &smpp_param[instance[0]]; + + switch(column) + { + case 2: //remote service number + if (datalen > 8) + return -1; + memset(pParam->service_number,0,8); + SET_OCTETSTRING(pParam->service_number, datalen); + break; + case 3: //link type + SET_INTEGER(pParam->link_type); + break; + case 4: //server type + SET_INTEGER(pParam->server_type); + break; + case 5: //session type + SET_INTEGER(pParam->session_type); + break; + case 6: //system id + if (datalen > SMPP_SYSID_LEN) + return -1; + memset(pParam->sys_id,0,SMPP_SYSID_LEN); + SET_OCTETSTRING(pParam->sys_id, datalen); + break; + case 7: //password + if (datalen > SMPP_PASSWD_LEN) + return -1; + memset(pParam->password,0,SMPP_PASSWD_LEN); + SET_OCTETSTRING(pParam->password, datalen); + break; + case 8: //system type + if (datalen > SMPP_SYSTYPE_LEN) + return -1; + memset(pParam->system_type,0,SMPP_SYSTYPE_LEN); + SET_OCTETSTRING(pParam->system_type, datalen); + break; + case 9: //local gtt + if (datalen > SMPP_GTT_LEN) + return -1; + memset(pParam->localGTT,0,SMPP_GTT_LEN); + SET_OCTETSTRING(pParam->localGTT, datalen); + break; + case 10: //remote gtt + if (datalen > SMPP_GTT_LEN) + return -1; + memset(pParam->remoteGTT,0,SMPP_GTT_LEN); + SET_OCTETSTRING(pParam->remoteGTT, datalen); + break; + case 11: //local ip + SET_IP(&pParam->local_ip); + break; + case 12: //remote ip + SET_IP(&pParam->remote_ip); + break; + case 13: //session init timer + SET_INTEGER(pParam->session_init_timer); + break; + case 14: // enquire link timer + SET_INTEGER(pParam->enquire_link_timer); + break; + case 15: //inactivity timer + SET_INTEGER(pParam->inactivity_timer); + break; + case 16: //response timer + SET_INTEGER(pParam->response_timer); + break; + case 17: + SET_INTEGER(pParam->localSSN); + break; + case 18: + SET_INTEGER(pParam->remoteSSN); + break; + case 19://enable/disable flag + { + u8 temp8; + SET_U8(temp8); + temp8 &= 0x01; + if(temp8 == 1)//enable + pParam->link_enable |= 0x01; + else + { + pParam->link_enable &= ~0x01; + init_link(instance[0]); + } + break; + } + case 20://delete + { + u8 temp8; + SET_U8(temp8); + if(temp8 == 6)//delete + { + pParam->link_enable = 0; + init_link(instance[0]); + } + break; + } + default: + break; + } + return datalen; +} + +int smpp_get_link(u32 column, u32 *instance, u8 *pdata, u8 *vartype) +{ + int datalen = -1; + SMPP_PARAM *pParam; + + if (instance[0] >= MAX_SMPP_LINK) + return -1; + pParam = &smpp_param[instance[0]]; + switch(column) + { + case 1: //index + GET_INTEGER(instance[0]); + break; + case 2: //remote service number (LinkAlias) + if((datalen = strlen(pParam->service_number)) > 8) + datalen = 8; + GET_OCTETSTRING(pParam->service_number, datalen); + break; + case 3: //link type + GET_INTEGER(pParam->link_type); + break; + case 4: //server type + GET_INTEGER(pParam->server_type); + break; + case 5: //session type + GET_INTEGER(pParam->session_type); + break; + case 6: //system id + if((datalen = strlen(pParam->sys_id)) > SMPP_SYSID_LEN) + datalen = SMPP_SYSID_LEN; + GET_OCTETSTRING(pParam->sys_id, datalen); + break; + case 7: //password + if((datalen = strlen(pParam->password)) > SMPP_PASSWD_LEN) + datalen = SMPP_PASSWD_LEN; + GET_OCTETSTRING(pParam->password, datalen); + break; + case 8: //system type + if((datalen = strlen(pParam->system_type)) > SMPP_SYSTYPE_LEN) + datalen = SMPP_SYSTYPE_LEN; + GET_OCTETSTRING(pParam->system_type, datalen); + break; + case 9: //local gtt + if((datalen = strlen(pParam->localGTT)) > SMPP_GTT_LEN) + datalen = SMPP_GTT_LEN; + GET_OCTETSTRING(pParam->localGTT, datalen); + break; + case 10: //remote gtt + if((datalen = strlen(pParam->remoteGTT)) > SMPP_GTT_LEN) + datalen = SMPP_GTT_LEN; + GET_OCTETSTRING(pParam->remoteGTT, datalen); + break; + case 11: //local ip + GET_IP(&pParam->local_ip); + break; + case 12: //remote ip + GET_IP(&pParam->remote_ip); + break; + case 13: //session init timer + GET_INTEGER(pParam->session_init_timer); + break; + case 14: //enquire link timer + GET_INTEGER(pParam->enquire_link_timer); + break; + case 15: //inactivity timer + GET_INTEGER(pParam->inactivity_timer); + break; + case 16: //response timer + GET_INTEGER(pParam->response_timer); + break; + case 17: + GET_INTEGER(pParam->localSSN); + break; + case 18: + GET_INTEGER(pParam->remoteSSN); + break; + case 19: //enable flag + GET_U8(pParam->link_enable&0x01); + break; + case 20: //link enable + GET_U8(1); + break; + default: + break; + } + return datalen; +} +int smpp_get_system(u32 column, u32 *instance, u8 *pdata, u8 *vartype) +{ + int datalen = -1; + + GET_OCTETSTRING(" ",1); + return datalen; +} + +int smpp_set_system(u32 column, u32 *instance, u8 *pdata, u16 datalen) +{ + switch(column) + { + case 1: + switch (pdata[0]) + { + case 0: //reset + smpp_reset(); + break; + case 1: //load + smpp_loadParam(); + break; + case 2: //save + smpp_writeParam(); + break; + } + } + return datalen; +} + +static struct snmp_table_profile smpp_tables[] = { + /****** Parameter table ******/ + { + .name = "system", + .index.len = 13, + .index.oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18, 2, 1},//1.3.6.1.4.1.1373.2.3.2.18.2.1 + .column = {0}, + .level = 0, + .get_instance = NULL, + .get_resp = smpp_get_system, + .set_resp = smpp_set_system + }, + { + .name = "smpp link", + .index.len = 14, + .index.oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18, 2, 2, 1},//1.3.6.1.4.1.1373.2.3.2.18.2.2.1 + .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0}, + .level = 1, + .get_instance = smpp_getnext_link, + .get_resp = smpp_get_link, + .set_resp = smpp_set_link + }, +}; + +static struct snmp_register smpp_register = { + .name = "SMPP", + .prefix_len = 11, + .prefix_oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18}, + .num_of_table = sizeof(smpp_tables)/sizeof(struct snmp_table_profile), + .table = smpp_tables, + .default_get_resp = smpp_getMib, + .default_set_resp = smpp_setMib +}; + + +void smpp_mibInit() +{ + int i; +// DWORD oid[20] = SMPP_OID; + + for (i=0; i 0) { + //printf("Mysock.server_sock[%d]=%d.\n", i, Mysock.server_sock[i]); + len = recv(Mysock.server_sock[i], smpp_msg, sizeof(smpp_msg), 0); + if (len > 0) { +// printf("TCP link receive setup SMPP link.\n"); + if ((retcode = smpp_decode_setup(SMPP_TCP, i, 0, (SMPP_GENERAL *)smpp_msg, len)) != -1) { +// printf("[smpp] tcp link %d find smpp link %d\n", i, retcode); + } + } + else if(len == 0 ) + { + close(Mysock.server_sock[i]); + Mysock.server_sock[i] = 0; + } + } + + // i = physical smpp link. + if (Mysock.Sockets[i] > 0) + { +/* len = recv(Mysock.Sockets[i], smpp_msg, sizeof(smpp_msg), 0); + if (len > 0) + { + printf("[TCP received packets]linkNo = %d, len = %d\n", i, len); + retcode = smpp_decode_msg(i, (SMPP_GENERAL *)smpp_msg, len); + }*/ + if(smpp_msg_buf_len[i] < 4) //recv command_length in smpp msg + { + len = recv(Mysock.Sockets[i], smpp_msg_buf[i]+smpp_msg_buf_len[i], 4-smpp_msg_buf_len[i],MSG_NOSIGNAL|MSG_DONTWAIT); + if (len == -1 && errno != EAGAIN) + { + sprintf(temp_buf,"SMPP receive 4 BYTE from tcp socket error:%s",strerror(errno)); + smpp_send_error(temp_buf); + continue; + } + else if(len >0) + { + smpp_msg_buf_len[i] += len; + } + } + if(smpp_msg_buf_len[i] >= 4) //recv remain of smpp msg + { + cmd_len = bcdtou32(smpp_msg_buf[i],4); + if ( cmd_len > MAX_PACKET_SIZE ) + { + recv(Mysock.Sockets[i], temp_buf, 4096,MSG_NOSIGNAL|MSG_DONTWAIT); + sprintf(temp_buf,"SMPP MSG CMD_LEN Error,Clear TCP Socket Buffer."); + smpp_send_error(temp_buf); + smpp_msg_buf_len[i] = 0; + continue; + } + if (smpp_msg_buf_len[i]0) + { + smpp_msg_buf_len[i] += len; + if(smpp_msg_buf_len[i] >= cmd_len) + { + //printf("[TCP received packets]linkNo = %d, len = %d\n", i, cmd_len); + retcode = smpp_decode_msg(i, (SMPP_GENERAL *)smpp_msg_buf[i], cmd_len); + smpp_msg_buf_len[i] = 0; + } + } + } + } + /*else if (len > 0) + { + cmd_len = bcdtou32(smpp_msg,4); + if ( cmd_len > sizeof(smpp_msg) ) + { + recv(Mysock.Sockets[i], temp_buf, 4096,MSG_NOSIGNAL|MSG_DONTWAIT); + sprintf(temp_buf,"SMPP MSG CMD_LEN Error,Clear TCP Socket Buffer."); + smpp_send_error(temp_buf); + fp = fopen("smpp_log","a"); + if (fp != NULL) + { + fprintf(fp,"%s\n",temp_buf); + fclose(fp); + } + continue; + } + else + { + len = recv(Mysock.Sockets[i], smpp_msg+4, cmd_len-4 ,MSG_NOSIGNAL|MSG_DONTWAIT); + if (len == -1) + { + sprintf(temp_buf,"SMPP receive cmd_len(%d)-4 BYTE from tcp socket error:%s",cmd_len,strerror(errno)); + smpp_send_error(temp_buf); + fp = fopen("smpp_log","a"); + if (fp != NULL) + { + fprintf(fp,"%s\n",temp_buf); + fclose(fp); + } + continue; + } + else + { + printf("[TCP received packets]linkNo = %d, len = %d\n", i, cmd_len); + retcode = smpp_decode_msg(i, (SMPP_GENERAL *)smpp_msg, cmd_len); + } + } + }*/ + } + } + + len = sizeof(remote_addr); + bzero((char *)&remote_addr, len); + newsock = accept(Mysock.DaemonSock, (struct sockaddr *)&remote_addr, (socklen_t *)&len); + if (newsock == -1) return; + ioctl(newsock, FIONBIO, &flag); + for (i=0; i 0) { + //printf("Mysock.server_sock[%d] = %d > 0, CONTINUE.\n", i, Mysock.server_sock[i]); + continue; + } + else { + Mysock.server_sock[i] = newsock; + Mysock.remote_ip[i] = remote_addr.sin_addr.s_addr; +// printf("link %d accept %d.\n", i, newsock); + return; + } + } + close(newsock); + return; +} + +//void smpp_rvMsgOverSCCP(BYTE sccp_usertype) +//{ +// int i, linkNo; +// SCLC_MSG sclcMsg; +// +// if (sclc_receive(&sclcMsg, sccp_usertype) != FALSE) { +// /* +// if (sccp_usertype == SMPP_PPS_USERTYPE) +// printf("receive to PPS sclc message.\n"); +// else if (sccp_usertype == SMPP_SMSC_USERTYPE) +// printf("receive to SMSC sclc message.\n"); +// */ +// for (i=0; ipdu.bind_transmitter.head.command_id); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { +// if(command_id!=ENQUIRE_LINK && command_id!=ENQUIRE_LINK_RESP) + { + smpp_command_id_to_string(comm_str, ntohl(pMsg->pdu.bind_transmitter.head.command_id)); + sprintf(debugBuf, "\nSMPP==> %s\tlink: %d\n", comm_str, linkNo); + smpp_send_ascout(debugBuf); + } + } + #endif + + if (smpp_param[linkNo].link_type == SMPP_UDP) + { + offset = 2; + tLen = tLen + offset; + smpp_msg[0] = dst_ref[linkNo]; + smpp_msg[1] = src_ref[linkNo]; + } + switch (event_id) + { + case SubmitSM: + /* mandatory parameter. */ + pSubmitSM = (PDU_SUBMIT_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pSubmitSM, 16); + len = strlen(pSubmitSM->service_type); + memcpy(smpp_msg+tLen, pSubmitSM->service_type, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitSM->source_addr_ton; + *(smpp_msg+tLen++) = pSubmitSM->source_addr_npi; + len = strlen(pSubmitSM->source_addr); + memcpy(smpp_msg+tLen, pSubmitSM->source_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitSM->dest_addr_ton; + *(smpp_msg+tLen++) = pSubmitSM->dest_addr_npi; + len = strlen(pSubmitSM->destination_addr); + memcpy(smpp_msg+tLen, pSubmitSM->destination_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitSM->esm_class; + *(smpp_msg+tLen++) = pSubmitSM->protocol_id; + *(smpp_msg+tLen++) = pSubmitSM->priority_flag; + len = strlen(pSubmitSM->schedule_delivery_time); + if (len > 0) { len = 16; } + memcpy(smpp_msg+tLen, pSubmitSM->schedule_delivery_time, len+1); + tLen = tLen+len+1; + len = strlen(pSubmitSM->validity_period); + if (len > 0) { len = 16; } + memcpy(smpp_msg+tLen, pSubmitSM->validity_period, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitSM->registered_delivery; + *(smpp_msg+tLen++) = pSubmitSM->replace_if_present_flag; + *(smpp_msg+tLen++) = pSubmitSM->data_coding; + *(smpp_msg+tLen++) = pSubmitSM->sm_default_msg_id; +// len = strlen(pSubmitSM->short_message); + len = pSubmitSM->sm_length; + *(smpp_msg+tLen++) = len; + if (len > 0) + { + memcpy(smpp_msg+tLen, pSubmitSM->short_message, len); + tLen = tLen+len; + } + /* optional paramter */ + optionalParamFlag = pMsg->optional_param_flag1; + #ifdef SMPP_PRINT_SCREEN +// printf("param_flag in SUBMIT SM = 0x%08x\n", optionalParamFlag); + #endif /* endif ifdef SMPP_PRINT_SCREEN */ + if ((optionalParamFlag&0x0001) == 0x0001) + { + smpp_addTLV(smpp_msg+tLen, USER_MESSAGE_REFERENCE, + (BYTE *)&(pSubmitSM->user_message_reference), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0002) == 0x0002) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_PORT, + (BYTE *)&(pSubmitSM->source_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0004) == 0x0004) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_ADDR_SUBUNIT, + (BYTE *)&(pSubmitSM->source_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, DESTINATION_PORT, + (BYTE *)&(pSubmitSM->destination_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0010) == 0x0010) + { + smpp_addTLV(smpp_msg+tLen, DEST_ADDR_SUBUNIT, + (BYTE *)&(pSubmitSM->dest_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0020) == 0x0020) + { + smpp_addTLV(smpp_msg+tLen, SAR_MSG_REF_NUM, + (BYTE *)&(pSubmitSM->sar_msg_ref_num), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0040) == 0x0040) + { + smpp_addTLV(smpp_msg+tLen, SAR_TOTAL_SEGMENTS, + (BYTE *)&(pSubmitSM->sar_total_segments), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, SAR_SEGMENT_SEQNUM, + (BYTE *)&(pSubmitSM->sar_segment_seqnum), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0100) == 0x0100) + { + smpp_addTLV(smpp_msg+tLen, MORE_MESSAGES_TO_SEND, + (BYTE *)&(pSubmitSM->more_messages_to_send), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0200) == 0x0200) + { + smpp_addTLV(smpp_msg+tLen, PAYLOAD_TYPE, + (BYTE *)&(pSubmitSM->payload_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0400) == 0x0400) + { + us_valueLen = strlen(pSubmitSM->message_payload); + smpp_addTLV(smpp_msg+tLen, MESSAGE_PAYLOAD, + (BYTE *)&(pSubmitSM->message_payload), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x0800) == 0x0800) + { + smpp_addTLV(smpp_msg+tLen, PRIVACY_INDICATOR, + (BYTE *)&(pSubmitSM->privacy_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x1000) == 0x1000) + { + us_valueLen = strlen(pSubmitSM->callback_num); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM, + (BYTE *)&(pSubmitSM->callback_num), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x2000) == 0x2000) + { + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_PRES_IND, + (BYTE *)&(pSubmitSM->callback_num_pres_ind), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x4000) == 0x4000) + { + us_valueLen = strlen(pSubmitSM->callback_num_atag); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_ATAG, + (BYTE *)&(pSubmitSM->callback_num_atag), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x8000) == 0x8000) + { + us_valueLen = strlen(pSubmitSM->source_subaddress); + smpp_addTLV(smpp_msg+tLen, SOURCE_SUBADDRESS, + (BYTE *)&(pSubmitSM->source_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00010000) == 0x00010000) + { + us_valueLen = strlen(pSubmitSM->dest_subaddress); + smpp_addTLV(smpp_msg+tLen, DEST_SUBADDRESS, + (BYTE *)&(pSubmitSM->dest_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00020000) == 0x00020000) + { + smpp_addTLV(smpp_msg+tLen, USER_RESPONSE_CODE, + (BYTE *)&(pSubmitSM->user_response_code), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00040000) == 0x00040000) + { + smpp_addTLV(smpp_msg+tLen, DISPLAY_TIME, + (BYTE *)&(pSubmitSM->display_time), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00080000) == 0x00080000) + { + smpp_addTLV(smpp_msg+tLen, SMS_SIGNAL, + (BYTE *)&(pSubmitSM->sms_signal), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x00100000) == 0x00100000) + { + smpp_addTLV(smpp_msg+tLen, MS_VALIDITY, + (BYTE *)&(pSubmitSM->ms_validity), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00200000) == 0x00200000) + { + smpp_addTLV(smpp_msg+tLen, MS_MSG_WAIT_FACILITIES, + (BYTE *)&(pSubmitSM->ms_msg_wait_facilities), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00400000) == 0x00400000) + { + smpp_addTLV(smpp_msg+tLen, NUMBER_OF_MESSAGES, + (BYTE *)&(pSubmitSM->number_of_messages), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00800000) == 0x00800000) + { + smpp_addTLV(smpp_msg+tLen, ALERT_ON_MESSAGE_DELIVERY, + (BYTE *)&(pSubmitSM->alert_on_message_delivery), 1); + tLen = tLen+4; + } + if ((optionalParamFlag&0x01000000) == 0x01000000) + { + smpp_addTLV(smpp_msg+tLen, LANGUAGE_INDICATOR, + (BYTE *)&(pSubmitSM->language_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x02000000) == 0x02000000) + { + smpp_addTLV(smpp_msg+tLen, ITS_REPLY_TYPE, + (BYTE *)&(pSubmitSM->its_reply_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x04000000) == 0x04000000) + { + smpp_addTLV(smpp_msg+tLen, ITS_SESSION_INFO, + (BYTE *)pSubmitSM->its_session_info, 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x08000000) == 0x08000000) + { + smpp_addTLV(smpp_msg+tLen, USSD_SERVICE_OP, + (BYTE *)&(pSubmitSM->ussd_service_op), 1); + tLen = tLen+5; + } + /* all the other param_flag values reserved. */ + /* command_length */ + pSubmitSM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pSubmitSM->head.command_length, 4); + break; + case SubmitSMResp: + pSubmitSMResp = (PDU_SUBMIT_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pSubmitSMResp, 16); + len = strlen(pSubmitSMResp->message_id); + memcpy(smpp_msg+tLen, pSubmitSMResp->message_id, len+1); + tLen = tLen+len+1; + pSubmitSMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pSubmitSMResp->head.command_length, 4); + break; + case SubmitMulti: + pSubmitMulti = (PDU_SUBMIT_MULTI *)&pMsg->pdu; + memcpy(smpp_msg+offset, pSubmitMulti, 16); + /* mandatory parameters. */ + len = strlen(pSubmitMulti->service_type); + memcpy(smpp_msg+tLen, pSubmitMulti->service_type, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitMulti->source_addr_ton; + *(smpp_msg+tLen++) = pSubmitMulti->source_addr_npi; + len = strlen(pSubmitMulti->source_addr); + memcpy(smpp_msg+tLen, pSubmitMulti->source_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitMulti->number_of_dests; + for (i=0; inumber_of_dests; i++) + { + switch(pSubmitMulti->dest_address[i].dest_flag) + { + case 1: //SME address + *(smpp_msg+tLen++) = pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_ton; + *(smpp_msg+tLen++) = pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_npi; + len = strlen(pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.destination_addr); + memcpy(smpp_msg+tLen, + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.destination_addr, len+1); + tLen = tLen+len+1; + break; + case 2: //Distribution List Name + len = strlen(pSubmitMulti->dest_address[i].dest_addr.dl_name.dl_name); + memcpy(smpp_msg+tLen, + pSubmitMulti->dest_address[i].dest_addr.dl_name.dl_name, len+1); + tLen = tLen+len+1; + break; + default: + break; + } + } + *(smpp_msg+tLen++) = pSubmitMulti->esm_class; + *(smpp_msg+tLen++) = pSubmitMulti->protocol_id; + *(smpp_msg+tLen++) = pSubmitMulti->priority_flag; + len = strlen(pSubmitMulti->schedule_delivery_time); + if (len > 0) { len = 16; } + memcpy(smpp_msg+tLen, pSubmitMulti->schedule_delivery_time, len+1); + tLen = tLen+len+1; + len = strlen(pSubmitMulti->validity_period); + if (len > 0) { len = 16; } + memcpy(smpp_msg+tLen, pSubmitMulti->validity_period, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitMulti->registered_delivery; + *(smpp_msg+tLen++) = pSubmitMulti->replace_if_present_flag; + *(smpp_msg+tLen++) = pSubmitMulti->data_coding; + *(smpp_msg+tLen++) = pSubmitMulti->sm_default_msg_id; + *(smpp_msg+tLen++) = pSubmitMulti->sm_length; +// len = strlen(pSubmitMulti->short_message); + len = pSubmitMulti->sm_length; + memcpy(smpp_msg+tLen, pSubmitMulti->short_message, len+1); + tLen = tLen+len+1; + /* optional parameters. */ + optionalParamFlag = pMsg->optional_param_flag1; + #ifdef SMPP_PRINT_SCREEN +// printf("param_flag in SUBMIT MULTI = 0x%08x\n", optionalParamFlag); + #endif /* endif ifdef SMPP_PRINT_SCREEN */ + if ((optionalParamFlag&0x0001) == 0x0001) + { + smpp_addTLV(smpp_msg+tLen, USER_MESSAGE_REFERENCE, + (BYTE *)&(pSubmitMulti->user_message_reference), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0002) == 0x0002) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_PORT, + (BYTE *)&(pSubmitMulti->source_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0004) == 0x0004) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_ADDR_SUBUNIT, + (BYTE *)&(pSubmitMulti->source_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, DESTINATION_PORT, + (BYTE *)&(pSubmitMulti->destination_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0010) == 0x0010) + { + smpp_addTLV(smpp_msg+tLen, DEST_ADDR_SUBUNIT, + (BYTE *)&(pSubmitMulti->dest_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0020) == 0x0020) + { + smpp_addTLV(smpp_msg+tLen, SAR_MSG_REF_NUM, + (BYTE *)&(pSubmitMulti->sar_msg_ref_num), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0040) == 0x0040) + { + smpp_addTLV(smpp_msg+tLen, SAR_TOTAL_SEGMENTS, + (BYTE *)&(pSubmitMulti->sar_total_segments), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, SAR_SEGMENT_SEQNUM, + (BYTE *)&(pSubmitMulti->sar_segment_seqnum), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0100) == 0x0100) + { + smpp_addTLV(smpp_msg+tLen, PAYLOAD_TYPE, + (BYTE *)&(pSubmitMulti->payload_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0200) == 0x0200) + { + us_valueLen = strlen(pSubmitMulti->message_payload); + smpp_addTLV(smpp_msg+tLen, MESSAGE_PAYLOAD, + (BYTE *)&(pSubmitMulti->message_payload), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x0400) == 0x0400) + { + smpp_addTLV(smpp_msg+tLen, PRIVACY_INDICATOR, + (BYTE *)&(pSubmitMulti->privacy_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0800) == 0x0800) + { + us_valueLen = strlen(pSubmitMulti->callback_num); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM, + (BYTE *)&(pSubmitMulti->callback_num), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x1000) == 0x1000) + { + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_PRES_IND, + (BYTE *)&(pSubmitMulti->callback_num_pres_ind), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x2000) == 0x2000) + { + us_valueLen = strlen(pSubmitMulti->callback_num_atag); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_ATAG, + (BYTE *)&(pSubmitMulti->callback_num_atag), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x4000) == 0x4000) + { + us_valueLen = strlen(pSubmitMulti->source_subaddress); + smpp_addTLV(smpp_msg+tLen, SOURCE_SUBADDRESS, + (BYTE *)&(pSubmitMulti->source_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x8000) == 0x8000) + { + us_valueLen = strlen(pSubmitMulti->dest_subaddress); + smpp_addTLV(smpp_msg+tLen, DEST_SUBADDRESS, + (BYTE *)&(pSubmitMulti->dest_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00010000) == 0x00010000) + { + smpp_addTLV(smpp_msg+tLen, DISPLAY_TIME, + (BYTE *)&(pSubmitMulti->display_time), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00020000) == 0x00020000) + { + smpp_addTLV(smpp_msg+tLen, SMS_SIGNAL, + (BYTE *)&(pSubmitMulti->sms_signal), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x00040000) == 0x00040000) + { + smpp_addTLV(smpp_msg+tLen, MS_VALIDITY, + (BYTE *)&(pSubmitMulti->ms_validity), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00080000) == 0x00080000) + { + smpp_addTLV(smpp_msg+tLen, MS_MSG_WAIT_FACILITIES, + (BYTE *)&(pSubmitMulti->ms_msg_wait_facilities), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00100000) == 0x00100000) + { + smpp_addTLV(smpp_msg+tLen, ALERT_ON_MESSAGE_DELIVERY, + (BYTE *)&(pSubmitMulti->alert_on_message_delivery), 1); + tLen = tLen+4; + } + if ((optionalParamFlag&0x00200000) == 0x00200000) + { + smpp_addTLV(smpp_msg+tLen, LANGUAGE_INDICATOR, + (BYTE *)&(pSubmitMulti->language_indicator), 1); + tLen = tLen+5; + } + /* all the other param_flag values reserved. */ + /* command_length */ + pSubmitMulti->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pSubmitMulti->head.command_length, 4); + break; + case SubmitMultiResp: + pSubmitMultiResp = (PDU_SUBMIT_MULTI_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pSubmitMultiResp, 16); + /* body */ + len = strlen(pSubmitMultiResp->message_id); + memcpy(smpp_msg+tLen, pSubmitMultiResp->message_id, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pSubmitMultiResp->no_unsuccess; + num = pSubmitMultiResp->no_unsuccess; + for (i=0; iunsuccess_sme[i].dest_addr_ton; + *(smpp_msg+tLen++) = pSubmitMultiResp->unsuccess_sme[i].dest_addr_npi; + len = strlen(pSubmitMultiResp->unsuccess_sme[i].destination_addr); + memcpy(smpp_msg+tLen, pSubmitMultiResp->unsuccess_sme[i].destination_addr, len+1); + tLen = tLen+len+1; + memcpy(smpp_msg+tLen, &(pSubmitMultiResp->unsuccess_sme[i].error_status_code), 4); + tLen = tLen+4; + } + /* command_length */ + pSubmitMultiResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pSubmitMultiResp->head.command_length, 4); + break; + case DeliverSM: + pDeliverSM = (PDU_DELIVER_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pDeliverSM, 16); + len = strlen(pDeliverSM->service_type); + memcpy(smpp_msg+tLen, pDeliverSM->service_type, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDeliverSM->source_addr_ton; + *(smpp_msg+tLen++) = pDeliverSM->source_addr_npi; + len = strlen(pDeliverSM->source_addr); + memcpy(smpp_msg+tLen, pDeliverSM->source_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDeliverSM->dest_addr_ton; + *(smpp_msg+tLen++) = pDeliverSM->dest_addr_npi; + len = strlen(pDeliverSM->destination_addr); + memcpy(smpp_msg+tLen, pDeliverSM->destination_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDeliverSM->esm_class; + *(smpp_msg+tLen++) = pDeliverSM->protocol_id; + *(smpp_msg+tLen++) = pDeliverSM->priority_flag; + *(smpp_msg+tLen++) = pDeliverSM->schedule_delivery_time; + *(smpp_msg+tLen++) = pDeliverSM->validity_period; + *(smpp_msg+tLen++) = pDeliverSM->registered_delivery; + *(smpp_msg+tLen++) = pDeliverSM->replace_if_present_flag; + *(smpp_msg+tLen++) = pDeliverSM->data_coding; + *(smpp_msg+tLen++) = pDeliverSM->sm_default_msg_id; +// len = strlen(pDeliverSM->short_message); + len = pDeliverSM->sm_length; + *(smpp_msg+tLen++) = len; + memcpy(smpp_msg+tLen, pDeliverSM->short_message, len); + tLen = tLen+len; + /* optional parameters */ + optionalParamFlag = pMsg->optional_param_flag1; + #ifdef SMPP_PRINT_SCREEN +// printf("param_flag in DELIVER SM = 0x%08x\n", optionalParamFlag); + #endif /* endif ifdef SMPP_PRINT_SCREEN */ + if ((optionalParamFlag&0x0001) == 0x0001) + { + smpp_addTLV(smpp_msg+tLen, USER_MESSAGE_REFERENCE, + (BYTE *)&(pDeliverSM->user_message_reference), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0002) == 0x0002) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_PORT, + (BYTE *)&(pDeliverSM->source_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0004) == 0x0004) + { + smpp_addTLV(smpp_msg+tLen, DESTINATION_PORT, + (BYTE *)&(pDeliverSM->destination_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, SAR_MSG_REF_NUM, + (BYTE *)&(pDeliverSM->sar_msg_ref_num), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0010) == 0x0010) + { + smpp_addTLV(smpp_msg+tLen, SAR_TOTAL_SEGMENTS, + (BYTE *)&(pDeliverSM->sar_total_segments), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0020) == 0x0020) + { + smpp_addTLV(smpp_msg+tLen, SAR_SEGMENT_SEQNUM, + (BYTE *)&(pDeliverSM->sar_segment_seqnum), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0040) == 0x0040) + { + smpp_addTLV(smpp_msg+tLen, USER_RESPONSE_CODE, + (BYTE *)&(pDeliverSM->user_response_code), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, PRIVACY_INDICATOR, + (BYTE *)&(pDeliverSM->privacy_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0100) == 0x0100) + { + smpp_addTLV(smpp_msg+tLen, PAYLOAD_TYPE, + (BYTE *)&(pDeliverSM->payload_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0200) == 0x0200) { + us_valueLen = strlen(pDeliverSM->message_payload); + smpp_addTLV(smpp_msg+tLen, MESSAGE_PAYLOAD, + (BYTE *)&(pDeliverSM->message_payload), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x0400) == 0x0400) + { + us_valueLen = strlen(pDeliverSM->callback_num); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM, + (BYTE *)&(pDeliverSM->callback_num), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x0800) == 0x0800) + { + us_valueLen = strlen(pDeliverSM->source_subaddress); + smpp_addTLV(smpp_msg+tLen, SOURCE_SUBADDRESS, + (BYTE *)&(pDeliverSM->source_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x1000) == 0x1000) + { + us_valueLen = strlen(pDeliverSM->dest_subaddress); + smpp_addTLV(smpp_msg+tLen, DEST_SUBADDRESS, + (BYTE *)&(pDeliverSM->dest_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x2000) == 0x2000) + { + smpp_addTLV(smpp_msg+tLen, LANGUAGE_INDICATOR, + (BYTE *)&(pDeliverSM->language_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x4000) == 0x4000) + { + smpp_addTLV(smpp_msg+tLen, ITS_SESSION_INFO, + (BYTE *)pDeliverSM->its_session_info, 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x8000) == 0x8000) + { + us_valueLen = strlen(pDeliverSM->network_error_code); + smpp_addTLV(smpp_msg+tLen, NETWORK_ERROR_CODE, + (BYTE *)&(pDeliverSM->network_error_code), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00010000) == 0x00010000) + { + smpp_addTLV(smpp_msg+tLen, MESSAGE_STATE, + (BYTE *)&(pDeliverSM->message_state), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00020000) == 0x00020000) + { + us_valueLen = strlen(pDeliverSM->receipted_message_id); + smpp_addTLV(smpp_msg+tLen, RECEIPTED_MESSAGE_ID, + (BYTE *)&(pDeliverSM->receipted_message_id), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00040000) == 0x00040000) + { + smpp_addTLV(smpp_msg+tLen, USSD_SERVICE_OP, + (BYTE *)&(pDeliverSM->ussd_service_op), 1); + tLen = tLen+5; + } + /* all the other param_flag values reserved. */ + /* command_length */ + pDeliverSM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pDeliverSM->head.command_length, 4); + break; + case DeliverSMResp: + pDeliverSMResp = (PDU_DELIVER_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pDeliverSMResp, 16); + *(smpp_msg+tLen++) = pDeliverSMResp->message_id; + pDeliverSMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pDeliverSMResp->head.command_length, 4); + break; + case DataSM: + pDataSM = (PDU_DATA_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pDataSM, 16); + /* mandatory parameter. */ + len = strlen(pDataSM->service_type); + memcpy(smpp_msg+tLen, pDataSM->service_type, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDataSM->source_addr_ton; + *(smpp_msg+tLen++) = pDataSM->source_addr_npi; + len = strlen(pDataSM->source_addr); + memcpy(smpp_msg+tLen, pDataSM->source_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDataSM->dest_addr_ton; + *(smpp_msg+tLen++) = pDataSM->dest_addr_npi; + len = strlen(pDataSM->destination_addr); + memcpy(smpp_msg+tLen, pDataSM->destination_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pDataSM->esm_class; + *(smpp_msg+tLen++) = pDataSM->registered_delivery; + *(smpp_msg+tLen++) = pDataSM->data_coding; + /* Optional parameter */ + optionalParamFlag = pMsg->optional_param_flag1; + #ifdef SMPP_PRINT_SCREEN +// printf("optional_param_flag1 in DATA SM = 0x%08x\n", optionalParamFlag); + #endif /* endif ifdef SMPP_PRINT_SCREEN */ + if ((optionalParamFlag&0x0001) == 0x0001) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_PORT, + (BYTE *)&(pDataSM->source_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0002) == 0x0002) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_ADDR_SUBUNIT, + (BYTE *)&(pDataSM->source_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0004) == 0x0004) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_NETWORK_TYPE, + (BYTE *)&(pDataSM->source_network_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_BEARER_TYPE, + (BYTE *)&(pDataSM->source_bearer_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0010) == 0x0010) + { + smpp_addTLV(smpp_msg+tLen, SOURCE_TELEMATICS_ID, + (BYTE *)&(pDataSM->source_telematics_id), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0020) == 0x0020) + { + smpp_addTLV(smpp_msg+tLen, DESTINATION_PORT, + (BYTE *)&(pDataSM->destination_port), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0040) == 0x0040) + { + smpp_addTLV(smpp_msg+tLen, DEST_ADDR_SUBUNIT, + (BYTE *)&(pDataSM->dest_addr_subunit), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0080) == 0x0080) + { + smpp_addTLV(smpp_msg+tLen, DEST_NETWORK_TYPE, + (BYTE *)&(pDataSM->dest_network_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0100) == 0x0100) + { + smpp_addTLV(smpp_msg+tLen, DEST_BEARER_TYPE, + (BYTE *)&(pDataSM->dest_bearer_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0200) == 0x0200) + { + smpp_addTLV(smpp_msg+tLen, DEST_TELEMATICS_ID, + (BYTE *)&(pDataSM->dest_telematics_id), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0400) == 0x0400) + { + smpp_addTLV(smpp_msg+tLen, SAR_MSG_REF_NUM, + (BYTE *)&(pDataSM->sar_msg_ref_num), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x0800) == 0x0800) + { + smpp_addTLV(smpp_msg+tLen, SAR_TOTAL_SEGMENTS, + (BYTE *)&(pDataSM->sar_total_segments), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x1000) == 0x1000) + { + smpp_addTLV(smpp_msg+tLen, SAR_SEGMENT_SEQNUM, + (BYTE *)&(pDataSM->sar_segment_seqnum), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x2000) == 0x2000) + { + smpp_addTLV(smpp_msg+tLen, MORE_MESSAGES_TO_SEND, + (BYTE *)&(pDataSM->more_messages_to_send), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x4000) == 0x4000) + { + smpp_addTLV(smpp_msg+tLen, QOS_TIME_TO_LIVE, + (BYTE *)&(pDataSM->qos_time_to_live), 4); + tLen = tLen+8; + } + if ((optionalParamFlag&0x8000) == 0x8000) + { + smpp_addTLV(smpp_msg+tLen, PAYLOAD_TYPE, + (BYTE *)&(pDataSM->payload_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00010000) == 0x00010000) + { + us_valueLen = strlen(pDataSM->message_payload); + smpp_addTLV(smpp_msg+tLen, MESSAGE_PAYLOAD, + (BYTE *)&(pDataSM->message_payload), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00020000) == 0x00020000) + { + smpp_addTLV(smpp_msg+tLen, SET_DPF, + (BYTE *)&(pDataSM->set_dpf), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00040000) == 0x00040000) + { + us_valueLen = strlen(pDataSM->receipted_message_id); + smpp_addTLV(smpp_msg+tLen, RECEIPTED_MESSAGE_ID, + (BYTE *)&(pDataSM->receipted_message_id), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x00080000) == 0x00080000) + { + smpp_addTLV(smpp_msg+tLen, MESSAGE_STATE, + (BYTE *)&(pDataSM->message_state), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00100000) == 0x00100000) + { + smpp_addTLV(smpp_msg+tLen, NETWORK_ERROR_CODE, + (BYTE *)&(pDataSM->network_error_code), 3); + tLen = tLen+7; + } + if ((optionalParamFlag&0x00200000) == 0x00200000) + { + smpp_addTLV(smpp_msg+tLen, USER_MESSAGE_REFERENCE, + (BYTE *)&(pDataSM->user_message_reference), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x00400000) == 0x00400000) + { + smpp_addTLV(smpp_msg+tLen, PRIVACY_INDICATOR, + (BYTE *)&(pDataSM->privacy_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x00800000) == 0x00800000) + { + us_valueLen = strlen(pDataSM->callback_num); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM, + (BYTE *)&(pDataSM->callback_num), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x01000000) == 0x01000000) + { + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_PRES_IND, + (BYTE *)&(pDataSM->callback_num_pres_ind), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x02000000) == 0x02000000) + { + us_valueLen = strlen(pDataSM->callback_num_atag); + smpp_addTLV(smpp_msg+tLen, CALLBACK_NUM_ATAG, + (BYTE *)&(pDataSM->callback_num_atag), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x04000000) == 0x04000000) + { + us_valueLen = strlen(pDataSM->source_subaddress); + smpp_addTLV(smpp_msg+tLen, SOURCE_SUBADDRESS, + (BYTE *)&(pDataSM->source_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x08000000) == 0x08000000) + { + us_valueLen = strlen(pDataSM->dest_subaddress); +// printf("dest subaddress len = %d\n", us_valueLen); + smpp_addTLV(smpp_msg+tLen, DEST_SUBADDRESS, + (BYTE *)&(pDataSM->dest_subaddress), us_valueLen); + tLen = tLen+4+us_valueLen; + } + if ((optionalParamFlag&0x10000000) == 0x10000000) + { + smpp_addTLV(smpp_msg+tLen, USER_RESPONSE_CODE, + (BYTE *)&(pDataSM->user_response_code), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x20000000) == 0x20000000) + { + smpp_addTLV(smpp_msg+tLen, DISPLAY_TIME, + (BYTE *)&(pDataSM->display_time), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x40000000) == 0x40000000) + { + smpp_addTLV(smpp_msg+tLen, SMS_SIGNAL, + (BYTE *)&(pDataSM->sms_signal), 2); + tLen = tLen+6; + } + if ((optionalParamFlag&0x80000000) == 0x80000000) + { + smpp_addTLV(smpp_msg+tLen, MS_VALIDITY, + (BYTE *)&(pDataSM->ms_validity), 1); + tLen = tLen+5; + } + optionalParamFlag = pMsg->optional_param_flag2; + #ifdef SMPP_PRINT_SCREEN +// printf("optional_param_flag2 in DATA SM = 0x%08x\n", optionalParamFlag); + #endif /* endif ifdef SMPP_PRINT_SCREEN */ + if ((optionalParamFlag&0x0001) == 0x0001) + { + smpp_addTLV(smpp_msg+tLen, MS_MSG_WAIT_FACILITIES, + (BYTE *)&(pDataSM->ms_msg_wait_facilities), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0002) == 0x0002) + { + smpp_addTLV(smpp_msg+tLen, NUMBER_OF_MESSAGES, + (BYTE *)&(pDataSM->number_of_messages), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0004) == 0x0004) + { + smpp_addTLV(smpp_msg+tLen, ALERT_ON_MESSAGE_DELIVERY, + (BYTE *)&(pDataSM->alert_on_message_delivery), 1); + tLen = tLen+4; + } + if ((optionalParamFlag&0x0008) == 0x0008) + { + smpp_addTLV(smpp_msg+tLen, LANGUAGE_INDICATOR, + (BYTE *)&(pDataSM->language_indicator), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0010) == 0x0010) + { + smpp_addTLV(smpp_msg+tLen, ITS_REPLY_TYPE, + (BYTE *)&(pDataSM->its_reply_type), 1); + tLen = tLen+5; + } + if ((optionalParamFlag&0x0020) == 0x0020) + { + smpp_addTLV(smpp_msg+tLen, ITS_SESSION_INFO, + (BYTE *)pDataSM->its_session_info, 2); + tLen = tLen+6; + } + /* all the other param_flag values reserved. */ + /* command_length */ + pDataSM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pDataSM->head.command_length, 4); + break; + case DataSMResp: + pDataSMResp = (PDU_DATA_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pDataSMResp, 16); + len = strlen(pDataSMResp->message_id); + memcpy(smpp_msg+tLen, pDataSMResp->message_id, len+1); + tLen = tLen+len+1; + pDataSMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pDataSMResp->head.command_length, 4); + break; + case QuerySM: + pQuerySM = (PDU_QUERY_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pQuerySM, 16); + /* mandatory parameter. */ + len = strlen(pQuerySM->message_id); + memcpy(smpp_msg+tLen, pQuerySM->message_id, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pQuerySM->source_addr_ton; + *(smpp_msg+tLen++) = pQuerySM->source_addr_npi; + len = strlen(pQuerySM->source_addr); + memcpy(smpp_msg+tLen, pQuerySM->source_addr, len+1); + tLen = tLen+len+1; + /* command_length */ + pQuerySM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pQuerySM->head.command_length, 4); + break; + case QuerySMResp: + pQuerySMResp = (PDU_QUERY_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pQuerySMResp, 16); + /* mandatory parameter. */ + len = strlen(pQuerySMResp->message_id); + memcpy(smpp_msg+tLen, pQuerySMResp->message_id, len+1); + tLen = tLen+len+1; + len = strlen(pQuerySMResp->final_date); + if (len > 0) { len = 16;} + memcpy(smpp_msg+tLen, pQuerySMResp->final_date, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pQuerySMResp->message_state; + *(smpp_msg+tLen++) = pQuerySMResp->error_code; + /* command_length */ + pQuerySMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pQuerySMResp->head.command_length, 4); + break; + case CancelSM: + pCancelSM = (PDU_CANCEL_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pCancelSM, 16); + /* mandatory parameter. */ + len = strlen(pCancelSM->service_type); + memcpy(smpp_msg+tLen, pCancelSM->service_type, len+1); + tLen = tLen+len+1; + len = strlen(pCancelSM->message_id); + memcpy(smpp_msg+tLen, pCancelSM->message_id, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pCancelSM->source_addr_ton; + *(smpp_msg+tLen++) = pCancelSM->source_addr_npi; + len = strlen(pCancelSM->source_addr); + memcpy(smpp_msg+tLen, pCancelSM->source_addr, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pCancelSM->dest_addr_ton; + *(smpp_msg+tLen++) = pCancelSM->dest_addr_npi; + len = strlen(pCancelSM->destination_addr); + memcpy(smpp_msg+tLen, pCancelSM->destination_addr, len+1); + tLen = tLen+len+1; + /* command_length */ + pCancelSM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pCancelSM->head.command_length, 4); + break; + case CancelSMResp: + pCancelSMResp = (PDU_CANCEL_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pCancelSMResp, 16); + pCancelSMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pCancelSMResp->head.command_length, 4); + break; + case ReplaceSM: + pReplaceSM = (PDU_REPLACE_SM *)&pMsg->pdu; + memcpy(smpp_msg+offset, pReplaceSM, 16); + /* mandatory parameter. */ + len = strlen(pReplaceSM->message_id); + memcpy(smpp_msg+tLen, pReplaceSM->message_id, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pReplaceSM->source_addr_ton; + *(smpp_msg+tLen++) = pReplaceSM->source_addr_npi; + len = strlen(pReplaceSM->source_addr); + memcpy(smpp_msg+tLen, pReplaceSM->source_addr, len+1); + tLen = tLen+len+1; + len = strlen(pReplaceSM->schedule_delivery_time); + memcpy(smpp_msg+tLen, pReplaceSM->schedule_delivery_time, len+1); + tLen = tLen+len+1; + len = strlen(pReplaceSM->validity_period); + memcpy(smpp_msg+tLen, pReplaceSM->validity_period, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pReplaceSM->registered_delivery; + *(smpp_msg+tLen++) = pReplaceSM->sm_default_msg_id; + *(smpp_msg+tLen++) = pReplaceSM->sm_length; +// len = strlen(pReplaceSM->short_message); + len = pReplaceSM->sm_length; + memcpy(smpp_msg+tLen, pReplaceSM->short_message, len+1); + tLen = tLen+len+1; + /* command_length */ + pReplaceSM->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pReplaceSM->head.command_length, 4); + break; + case ReplaceSMResp: + pReplaceSMResp = (PDU_REPLACE_SM_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pReplaceSMResp, 16); + pReplaceSMResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pReplaceSMResp->head.command_length, 4); + break; + case Outbind: + pOutbind = (PDU_OUTBIND *)&pMsg->pdu; + memcpy(smpp_msg+offset, pOutbind, 16); + len = strlen(pOutbind->system_id); + memcpy(smpp_msg+tLen, pOutbind->system_id, len+1); + tLen = tLen+len+1; + len = strlen(pOutbind->password); + memcpy(smpp_msg+tLen, pOutbind->password, len+1); + tLen = tLen+len+1; + pOutbind->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pOutbind->head.command_length, 4); + break; + case BindTransmitter: + case BindReceiver: + case BindTransceiver: + pBind = (PDU_BIND *)&pMsg->pdu; + memcpy(smpp_msg+offset, pBind, 16); + len = strlen(pBind->system_id); + memcpy(smpp_msg+tLen, pBind->system_id, len+1); + tLen = tLen+len+1; + len = strlen(pBind->password); + memcpy(smpp_msg+tLen, pBind->password, len+1); + tLen = tLen+len+1; + len = strlen(pBind->system_type); + memcpy(smpp_msg+tLen, pBind->system_type, len+1); + tLen = tLen+len+1; + *(smpp_msg+tLen++) = pBind->interface_version; + *(smpp_msg+tLen++) = pBind->addr_ton; + *(smpp_msg+tLen++) = pBind->addr_npi; + len = strlen(pBind->address_range); + memcpy(smpp_msg+tLen, pBind->address_range, len+1); + tLen = tLen+len+1; + pBind->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pBind->head.command_length, 4); + break; + case BindTransmitterResp: + case BindReceiverResp: + case BindTransceiverResp: + pBindResp = (PDU_BIND_RESP *)&pMsg->pdu; + memcpy(smpp_msg+offset, pBindResp, 16); + + len = strlen(pBindResp->system_id); + memcpy(smpp_msg+tLen, pBindResp->system_id, len+1); + tLen = tLen+len+1; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory Parameters]\n"); + sprintf(debugBuf, "system_id: %s\n", pBindResp->system_id); + smpp_send_ascout(debugBuf); + } + #endif + + /* sc_interface_version */ + smpp_addTLV(smpp_msg+tLen, SC_INTERFACE_VERSION, + &pBindResp->sc_interface_version, 1); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional Parameters]\n"); + sprintf(debugBuf, "sc_interface_version: 0x%02X\n", pBindResp->sc_interface_version); + smpp_send_ascout(debugBuf); + } + #endif + + tLen = tLen + 5; + pBindResp->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pBindResp->head.command_length, 4); + break; + case Unbind: + case UnbindResp: + case EnquireLink: + case EnquireLinkResp: + pUnbind = (PDU_UNBIND *)&pMsg->pdu; + memcpy(smpp_msg+offset, pUnbind, 16); + pUnbind->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pUnbind->head.command_length, 4); + break; + case UnknownCommandID: + pGenericNack = (PDU_GENERIC_NACK *)&pMsg->pdu; + memcpy(smpp_msg+offset, pGenericNack, 16); + pGenericNack->head.command_length = htonl(tLen-offset); + memcpy(smpp_msg+offset, &pGenericNack->head.command_length, 4); + break; + default: + break; + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("ENCODE:\n"); + smpp_display_hex_msg((BYTE*) smpp_msg+offset, tLen); + } + #endif + + if (smpp_param[linkNo].link_type == 0) //send message over SCCP + { +// printf("link %d send sccp message. dst_ref=%d, src_ref=%d\n", linkNo, smpp_msg[0], smpp_msg[1]); + memset(&sclcMsg,0,sizeof(sclcMsg)); + smpp_setSccpAddr(linkNo, &sclcMsg.src_addr, &sclcMsg.dst_addr); + sclcMsg.msglen = tLen; + memcpy(sclcMsg.msg, smpp_msg, tLen); + sclcMsg.sls = smpp_system_no; + //sclcMsg.sls += 1; + //sclcMsg.sls &= 0x0f; + + sclc_send(&sclcMsg); + } + else if (smpp_param[linkNo].link_type == 1) //send message over TCP + { + if (Mysock.Sockets[linkNo] < 0) + { +// printf("[FAIL]socket %d number = %d\n", linkNo, Mysock.Sockets[linkNo]); + return (-1); + } + if ((actlen = send(Mysock.Sockets[linkNo], smpp_msg, tLen, MSG_NOSIGNAL)) < 0) + { + smpp_state[linkNo] = SUSPEND;//ch + sprintf(debugBuf, "link %d Socket Send Error: %s\n",linkNo,strerror(errno)); + smpp_send_error(debugBuf); + return (-2); + } + } + + return tLen; +} + +//return smpp link no. (-1) -- error +//link_type: 0-UDP, 1-TCP +int smpp_decode_setup(BYTE link_type, int tcp_linkNo, BYTE src_ref, SMPP_GENERAL *pData, int len) +{ + int i, linkNo; + int current_len, c_octet_string_len=0; + struct in_addr addr; + + BYTE *pMsg; + char ton_str[32], npi_str[32], debugBuf[512]; + DWORD command_length, command_id, command_status, sequence_number; + + SMPP_MSG smppMsg; + PDU_BIND *pBind; + PDU_OUTBIND *pOutbind; + + command_length = ntohl(pData->head.command_length); + command_id = ntohl(pData->head.command_id); + command_status = ntohl(pData->head.command_status); + sequence_number = ntohl(pData->head.sequence_number); + memset(&smppMsg,0,sizeof(smppMsg)); + switch (command_id) + { + case BIND_TRANSMITTER: + pMsg = pData->msg; + pBind = &smppMsg.pdu.bind_transmitter; + +// printf("receive bind_transmitter.\n"); + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + // find out link no + linkNo = smpp_check_sysid_route(pBind->system_id, c_octet_string_len, SMPP_CLIENT, BIND_TX); + if (linkNo == -1) + { + sprintf(debugBuf, "[smpp BIND_TRANSMITTER]can't not find system id %s in smpp parameter table.\r\n", pBind->system_id); + smpp_send_error(debugBuf); + if (link_type == SMPP_TCP) + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } + return (-1); + } + if (link_type == SMPP_TCP) + { + if (smpp_param[linkNo].remote_ip != Mysock.remote_ip[tcp_linkNo]) + { + addr.s_addr = Mysock.remote_ip[tcp_linkNo]; + sprintf(debugBuf, "[Remote ip error]remote_ip is: %s\r\n", inet_ntoa(addr)); + smpp_send_error(debugBuf); + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } +// if(smpp_state[linkNo] != IDLE) +// { +// close(Mysock.server_sock[tcp_linkNo]); +// Mysock.server_sock[tcp_linkNo] = -1; +// return (-1); +// } + if(Mysock.Sockets[linkNo] > 0) + close(Mysock.Sockets[linkNo]); + Mysock.Sockets[linkNo] = Mysock.server_sock[tcp_linkNo]; + Mysock.server_sock[tcp_linkNo] = -1; + } + else if (link_type == SMPP_UDP) + dst_ref[linkNo] = src_ref; + smpp_link[linkNo].seq_num = sequence_number; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* system type */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* interface version */ + pBind->interface_version = *(pMsg+current_len); + current_len += 1; + + /* addr_ton */ + pBind->addr_ton = *(pMsg+current_len); + current_len += 1; + + /* addr_npi */ + pBind->addr_npi = *(pMsg+current_len); + current_len += 1; + + /* address_range */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->address_range, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSMITTER: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return (-1); + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSMITTER: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return (-1); + } + + if (strcmp(pBind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSMITTER: system_id = %s, sys_id in param=%s\n", + linkNo, + pBind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransmitterResp, ESME_RINVSYSID); + return (-1); + } + + if (strcmp(pBind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive BIND_TRANSMITTER: password = %s, password in param=%s\n", + linkNo, + pBind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransmitterResp, ESME_RINVPASWD); + return (-1); + } + + if (strcmp(pBind->system_type, smpp_param[linkNo].system_type) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive BIND_TRANSMITTER: system_type = %s, system_type in param=%s\n", + linkNo, + pBind->system_type, + smpp_param[linkNo].system_type); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransmitterResp, ESME_RINVSYSTYP); + return (-1); + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_ton_to_string(ton_str, pBind->addr_ton); + smpp_npi_to_string(npi_str, pBind->addr_npi); + sprintf(debugBuf, "[Mandatory parameters]\nsystem_id:%s, password:%s, system_type:%s, interface_version:0x%x, addr_ton: 0x%x - %s, addr_npi: 0x%x - %s\n", + pBind->system_id, + pBind->password, + pBind->system_type, + pBind->interface_version, + pBind->addr_ton, ton_str, + pBind->addr_npi, npi_str + ); + smpp_send_ascout(debugBuf); + } + #endif + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindTransmitter; +// printf("link %d receive bind_transmitter.\n", linkNo); + break; + case BIND_TRANSCEIVER: + pMsg = pData->msg; + pBind = &smppMsg.pdu.bind_transmitter; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + // find out link no + linkNo = smpp_check_sysid_route(pBind->system_id, c_octet_string_len, SMPP_CLIENT, BIND_TRX); + if (linkNo == -1) + { + sprintf(debugBuf, "[smpp BIND_TRANSCEIVER]can't not find system id %s in smpp parameter table.\r\n", pBind->system_id); + smpp_send_error(debugBuf); + if (link_type == SMPP_TCP) + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } + return (-1); + } + if (link_type == SMPP_TCP) + { + if (smpp_param[linkNo].remote_ip != Mysock.remote_ip[tcp_linkNo]) + { + addr.s_addr = Mysock.remote_ip[tcp_linkNo]; + sprintf(debugBuf, "[smpp BIND_TRANSCEIVER]Remote ip error,remote_ip is: %s\r\n", inet_ntoa(addr)); + smpp_send_error(debugBuf); + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } +// if(smpp_state[linkNo] != IDLE) +// { +// close(Mysock.server_sock[tcp_linkNo]); +// Mysock.server_sock[tcp_linkNo] = -1; +// return (-1); +// } + if(Mysock.Sockets[linkNo] > 0) + close(Mysock.Sockets[linkNo]); + Mysock.Sockets[linkNo] = Mysock.server_sock[tcp_linkNo]; + Mysock.server_sock[tcp_linkNo] = -1; + } + if (link_type == SMPP_UDP) dst_ref[linkNo] = src_ref; + smpp_link[linkNo].seq_num = sequence_number; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* system type */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* interface version */ + pBind->interface_version = *(pMsg+current_len); + current_len += 1; + + /* addr_ton */ + pBind->addr_ton = *(pMsg+current_len); + current_len += 1; + + /* addr_npi */ + pBind->addr_npi = *(pMsg+current_len); + current_len += 1; + + /* address_range */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->address_range, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSCEIVER: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return (-1); + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSCEIVER: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return (-1); + } + + if (strcmp(pBind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive BIND_TRANSCEIVER: system_id = %s, sys_id in param=%s\n", + linkNo, + pBind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransceiverResp, ESME_RINVSYSID); + return (-1); + } + + if (strcmp(pBind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive BIND_TRANSCEIVER: password = %s, password in param=%s\n", + linkNo, + pBind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransceiverResp, ESME_RINVPASWD); + return (-1); + } + + if (strcmp(pBind->system_type, smpp_param[linkNo].system_type) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive BIND_TRANSCEIVER: system_type = %s, system_type in param=%s\n", + linkNo, + pBind->system_type, + smpp_param[linkNo].system_type); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindTransceiverResp, ESME_RINVSYSTYP); + return (-1); + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_ton_to_string(ton_str, pBind->addr_ton); + smpp_npi_to_string(npi_str, pBind->addr_npi); + sprintf(debugBuf, "[Mandatory parameters]\nsystem_id:%s, password:%s, system_type:%s, interface_version:0x%x, addr_ton: 0x%x - %s, addr_npi: 0x%x - %s\n", + pBind->system_id, + pBind->password, + pBind->system_type, + pBind->interface_version, + pBind->addr_ton, ton_str, + pBind->addr_npi, npi_str + ); + smpp_send_ascout(debugBuf); + } + #endif + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindTransceiver; +// printf("link %d receive BIND_TRANCEIVER", linkNo); + break; + case OUTBIND: + pMsg = pData->msg; + pOutbind = &smppMsg.pdu.outbind; + + /* mandatory parameter */ + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pOutbind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + // find out link no + linkNo = smpp_check_sysid_route(pOutbind->system_id, c_octet_string_len, SMPP_SERVER, BIND_RX); + if (linkNo == -1) + { + addr.s_addr = Mysock.remote_ip[tcp_linkNo]; + sprintf(debugBuf, "remote_ip: %s\r\n", inet_ntoa(addr)); + smpp_send_error(debugBuf); + sprintf(debugBuf, "[smpp OUTBIND]can't not find system id %s in smpp parameter table.\r\n", pOutbind->system_id); + smpp_send_error(debugBuf); + if (link_type == SMPP_TCP) + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } + return (-1); + } + if (link_type == SMPP_TCP) + { + if (smpp_param[linkNo].remote_ip != Mysock.remote_ip[tcp_linkNo]) + { + addr.s_addr = Mysock.remote_ip[tcp_linkNo]; + sprintf(debugBuf, "[smpp OUTBIND]Remote ip error,remote_ip is: %s\r\n", inet_ntoa(addr)); + smpp_send_error(debugBuf); + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } +// if(smpp_state[linkNo] != IDLE) +// { +// close(Mysock.server_sock[tcp_linkNo]); +// Mysock.server_sock[tcp_linkNo] = -1; +// return (-1); +// } + if(Mysock.Sockets[linkNo] > 0) + close(Mysock.Sockets[linkNo]); + Mysock.Sockets[linkNo] = Mysock.server_sock[tcp_linkNo]; + Mysock.server_sock[tcp_linkNo] = -1; + } + if (link_type == SMPP_UDP) dst_ref[linkNo] = src_ref; + smpp_link[linkNo].seq_num = sequence_number; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pOutbind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive OUTBIND: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return (-1); + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive OUTBIND: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return (-1); + } + + if (strcmp(pOutbind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive OUTBIND: system_id = %s, sys_id in param=%s\n", + linkNo, + pOutbind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif +// smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSID); + return (-1); + } + + if (strcmp(pOutbind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive OUTBIND: password = %s, password in param=%s\n", + linkNo, + pOutbind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif + return (-1); + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = Outbind; +// printf("link %d receive OUTBIND, inter_head=%d.\n", linkNo, inter_head[linkNo]); + break; + case BIND_RECEIVER: + pMsg = pData->msg; + pBind = &smppMsg.pdu.bind_receiver; + +// printf("receive bind_receiver.\n"); + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + // find out link no + linkNo = smpp_check_sysid_route(pBind->system_id, c_octet_string_len, SMPP_CLIENT, BIND_RX); + if (linkNo == -1) + { + sprintf(debugBuf, "[smpp bind_receiver]can't not find system id %s in smpp parameter table.\r\n", pBind->system_id); + smpp_send_error(debugBuf); + if (link_type == SMPP_TCP) + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } + return (-1); + } + if (link_type == SMPP_TCP) + { + if (smpp_param[linkNo].remote_ip != Mysock.remote_ip[tcp_linkNo]) + { + addr.s_addr = Mysock.remote_ip[tcp_linkNo]; + sprintf(debugBuf, "[smpp bind_receiver]Remote ip error,remote_ip is: %s\r\n", inet_ntoa(addr)); + smpp_send_error(debugBuf); + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + } + if(smpp_state[linkNo]!=IDLE && smpp_state[linkNo]!=WAITING)//send out bind wating state + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = -1; + return (-1); + } + if(Mysock.Sockets[linkNo] > 0) + close(Mysock.Sockets[linkNo]); + Mysock.Sockets[linkNo] = Mysock.server_sock[tcp_linkNo]; + Mysock.server_sock[tcp_linkNo] = -1; + } + else if (link_type == SMPP_UDP) + dst_ref[linkNo] = src_ref; + smpp_link[linkNo].seq_num = sequence_number; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* system type */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* interface version */ + pBind->interface_version = *(pMsg+current_len); + current_len += 1; + + /* addr_ton */ + pBind->addr_ton = *(pMsg+current_len); + current_len += 1; + + /* addr_npi */ + pBind->addr_npi = *(pMsg+current_len); + current_len += 1; + + /* address_range */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->address_range, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive bind_receiver: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return (-1); + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive bind_receiver: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return (-1); + } + + if (strcmp(pBind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup] link %d receive bind_receiver: system_id = %s, sys_id in param=%s\n", + linkNo, + pBind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSID); + return (-1); + } + + if (strcmp(pBind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive bind_receiver: password = %s, password in param=%s\n", + linkNo, + pBind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVPASWD); + return (-1); + } + + if (strcmp(pBind->system_type, smpp_param[linkNo].system_type) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_setup]link %d receive bind_receiver: system_type = %s, system_type in param=%s\n", + linkNo, + pBind->system_type, + smpp_param[linkNo].system_type); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSTYP); + return (-1); + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_ton_to_string(ton_str, pBind->addr_ton); + smpp_npi_to_string(npi_str, pBind->addr_npi); + sprintf(debugBuf, "[Mandatory parameters]\nsystem_id:%s, password:%s, system_type:%s, interface_version:0x%x, addr_ton: 0x%x - %s, addr_npi: 0x%x - %s\n", + pBind->system_id, + pBind->password, + pBind->system_type, + pBind->interface_version, + pBind->addr_ton, ton_str, + pBind->addr_npi, npi_str + ); + smpp_send_ascout(debugBuf); + } + #endif + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindReceiver; +// printf("link %d receive bind_transmitter.\n", linkNo); + break; + default: + sprintf(debugBuf, "receive error command:%ld",command_id); + smpp_send_error(debugBuf); + if (link_type == SMPP_TCP) + { + close(Mysock.server_sock[tcp_linkNo]); + Mysock.server_sock[tcp_linkNo] = 0; + } + return (-1); + } + return linkNo; +} + +int smpp_decode_msg(int linkNo, SMPP_GENERAL *pData, int len) +{ + DWORD command_length, command_id, command_status, sequence_number; + char debugBuf[1024]; + int i, j, current_len, c_octet_string_len=0; + SMPP_MSG smppMsg; + PDU_BIND *pBind; + PDU_BIND_RESP *pBindResp; + PDU_OUTBIND *pOutbind; + PDU_SUBMIT_SM *pSubmitSM; + PDU_SUBMIT_SM_RESP *pSubmitSMResp; + PDU_SUBMIT_MULTI *pSubmitMulti; + PDU_SUBMIT_MULTI_RESP *pSubmitMultiResp; + PDU_DELIVER_SM *pDeliverSM; + PDU_DELIVER_SM_RESP *pDeliverSMResp; + PDU_DATA_SM *pDataSM; + PDU_DATA_SM_RESP *pDataSMResp; + PDU_QUERY_SM *pQuerySM; + PDU_QUERY_SM_RESP *pQuerySMResp; + PDU_CANCEL_SM *pCancelSM; + PDU_CANCEL_SM_RESP *pCancelSMResp; + PDU_REPLACE_SM *pReplaceSM; + PDU_REPLACE_SM_RESP *pReplaceSMResp; + PDU_ALERT_NOTIFICATION *pAlertNotification; + BYTE *pMsg; + char comm_str[32], status_str[128], ton_str[32], npi_str[32]; + BYTE opt_num; + + command_length = ntohl(pData->head.command_length); + command_id = ntohl(pData->head.command_id); + command_status = ntohl(pData->head.command_status); + sequence_number = ntohl(pData->head.sequence_number); + memset(&smppMsg,0,sizeof(smppMsg)); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { +// if(command_id!=ENQUIRE_LINK && command_id!=ENQUIRE_LINK_RESP) + { + smpp_command_id_to_string(comm_str, command_id); + sprintf(debugBuf, "\n==>SMPP %s\tlink: %d\n", comm_str, linkNo); + smpp_send_ascout(debugBuf); + smpp_display_hex_msg((BYTE*) pData, len); + smpp_command_status_to_string(status_str, command_status); + sprintf(debugBuf, "DECODE:\n[Header]\ncommand_length=0x%lx(hex), command_id=0x%lx(hex), command_status=0x%lx(%s), sequence_number=%ld(dec)\n", + command_length, + command_id, + command_status, status_str, + sequence_number); + smpp_send_ascout(debugBuf); + // printf("%s\n",debugBuf); + } + } + #endif + + switch (command_id) + { + case BIND_TRANSMITTER: + break; + case BIND_TRANSMITTER_RESP: + pMsg = pData->msg; + pBindResp = &smppMsg.pdu.bind_transmitter_resp; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBindResp->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[Mandatory Parameters]\nsystem_id: %s\n", + pBindResp->system_id); + smpp_send_ascout(debugBuf); + } + #endif + + /* Optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; isc_interface_version, &opt_param[i].value, opt_param[i].len); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sc_interface_version: 0x%02X\n", pBindResp->sc_interface_version); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in BIND_TRANSMITTER_RESP. tag=0x%02X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + return 0; + } + } + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindTransmitterResp; + break; + case BIND_RECEIVER: + pMsg = pData->msg; + pBind = &smppMsg.pdu.bind_transmitter; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* system type */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->system_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* interface version */ + pBind->interface_version = *(pMsg+current_len); + current_len += 1; + + /* addr_ton */ + pBind->addr_ton = *(pMsg+current_len); + current_len += 1; + + /* addr_npi */ + pBind->addr_npi = *(pMsg+current_len); + current_len += 1; + + /* address_range */ + c_octet_string_len = 1; + for (i=0; i<13; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBind->address_range, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive BIND_RECEIVER: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive BIND_RECEIVER: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + if (strcmp(pBind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive BIND_RECEIVER: system_id = %s, sys_id in param=%s\n", + linkNo, + pBind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSID); + return 0; + } + + if (strcmp(pBind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg]link %d receive BIND_RECEIVER: password = %s, password in param=%s\n", + linkNo, + pBind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVPASWD); + return 0; + } + + if (strcmp(pBind->system_type, smpp_param[linkNo].system_type) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg]link %d receive BIND_RECEIVER: system_type = %s, system_type in param=%s\n", + linkNo, + pBind->system_type, + smpp_param[linkNo].system_type); + smpp_send_error(debugBuf); + } + #endif + smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSTYP); + return 0; + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_ton_to_string(ton_str, pBind->addr_ton); + smpp_npi_to_string(npi_str, pBind->addr_npi); + sprintf(debugBuf, "[Mandatory parameters]\nsystem_id:%s, password:%s, system_type:%s, interface_version:0x%x, addr_ton: 0x%x - %s, addr_npi: 0x%x - %s\n", + pBind->system_id, + pBind->password, + pBind->system_type, + pBind->interface_version, + pBind->addr_ton, ton_str, + pBind->addr_npi, npi_str + ); + smpp_send_ascout(debugBuf); + } + #endif + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindReceiver; +// printf("[smpp] link %d receiver BindReceiver. inter_head=%d\n", linkNo, inter_head[linkNo]); + break; + case BIND_RECEIVER_RESP: + pMsg = pData->msg; + pBindResp = &smppMsg.pdu.bind_receiver_resp; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBindResp->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[Mandatory Parameters]\nsystem_id: %s\n", + pBindResp->system_id); + smpp_send_ascout(debugBuf); + } + #endif + + /* Optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; isc_interface_version, &opt_param[i].value, opt_param[i].len); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sc_interface_version: 0x%02X\n", pBindResp->sc_interface_version); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in BIND_RECEIVER_RESP. tag=0x%02X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + return 0; + } + } + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindReceiverResp; + break; + case BIND_TRANSCEIVER: + break; + case BIND_TRANSCEIVER_RESP: + pMsg = pData->msg; + pBindResp = &smppMsg.pdu.bind_receiver_resp; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pBindResp->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[Mandatory Parameters]\nsystem_id: %s\n", + pBindResp->system_id); + smpp_send_ascout(debugBuf); + } + #endif + + /* Optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; isc_interface_version, &opt_param[i].value, opt_param[i].len); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sc_interface_version: 0x%02X\n", pBindResp->sc_interface_version); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in BIND_TRANSCEIVER_RESP. tag=0x%02X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + return 0; + } + } + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = BindTransceiverResp; + break; + case ENQUIRE_LINK: + if (16 != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ENQUIRE_LINK: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (16 != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ENQUIRE_LINK: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + smpp_link[linkNo].seq_num = sequence_number; + interEvent[linkNo][inter_head[linkNo]] = EnquireLink; + break; + case ENQUIRE_LINK_RESP: + if (16 != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ENQUIRE_LINK_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (16 != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ENQUIRE_LINK_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = EnquireLinkResp; + break; + case SUBMIT_SM: +// printf("\33[32mlink %d receive SUBMIT_SM.\33[0m\n", linkNo); + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = SubmitSM; + smpp_link[linkNo].seq_num = sequence_number; + /* fill with SMPP_MSG data structure. */ + pMsg = pData->msg; + pSubmitSM = &smppMsg.pdu.submit_sm; + smppMsg.message_type = 0x0B; + /* head */ + memcpy(&pSubmitSM->head, &pData->head, 16); + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSM->service_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitSM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pSubmitSM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitSM->dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pSubmitSM->dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSM->destination_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitSM->esm_class = *(pMsg+current_len); + current_len += 1; + pSubmitSM->protocol_id = *(pMsg+current_len); + current_len += 1; + pSubmitSM->priority_flag = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSM->schedule_delivery_time, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSM->validity_period, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitSM->registered_delivery = *(pMsg+current_len); + current_len += 1; + pSubmitSM->replace_if_present_flag = *(pMsg+current_len); + current_len += 1; + pSubmitSM->data_coding = *(pMsg+current_len); + current_len += 1; + pSubmitSM->sm_default_msg_id = *(pMsg+current_len); + current_len += 1; + pSubmitSM->sm_length = *(pMsg+current_len); + current_len += 1; + memcpy(pSubmitSM->short_message, pMsg+current_len, pSubmitSM->sm_length); + current_len += pSubmitSM->sm_length; + pSubmitSM->short_message[pSubmitSM->sm_length] = 0; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pSubmitSM->source_addr_ton); + smpp_npi_to_string(npi_str, pSubmitSM->source_addr_npi); + sprintf(debugBuf, "service_type: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pSubmitSM->service_type, + pSubmitSM->source_addr_ton, ton_str, + pSubmitSM->source_addr_npi, npi_str, + pSubmitSM->source_addr); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pSubmitSM->dest_addr_ton); + smpp_npi_to_string(npi_str, pSubmitSM->dest_addr_npi); + sprintf(debugBuf, "dest_addr_ton: 0x%x - %s,\tdest_addr_npi: 0x%x - %s,\tdestination_addr: %s\t", + pSubmitSM->dest_addr_ton, ton_str, + pSubmitSM->dest_addr_npi, npi_str, + pSubmitSM->destination_addr); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "esm_class: 0x%x,\tprotocol_id: 0x%x,\tpriority_flag: 0x%x,\tschedule_delivery_time: %s,\tvalidity_period: %s,\tregistered_delivery: 0x%x\t", + pSubmitSM->esm_class, + pSubmitSM->protocol_id, + pSubmitSM->priority_flag, + pSubmitSM->schedule_delivery_time, + pSubmitSM->validity_period, + pSubmitSM->registered_delivery); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "replace_if_present_flag: 0x%x,\tdata_coding: 0x%x,\tsm_default_msg_id: 0x%x,\tsm_length: 0x%x,\tshort_message: %s\n", + pSubmitSM->replace_if_present_flag, + pSubmitSM->data_coding, + pSubmitSM->sm_default_msg_id, + pSubmitSM->sm_length, + pSubmitSM->short_message); + smpp_send_ascout(debugBuf); + } + #endif + + /* optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; iuser_message_reference, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_message_reference: 0x%04X\n", pSubmitSM->user_message_reference); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_PORT: + memcpy(&pSubmitSM->source_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_port: 0x%04X\n", pSubmitSM->source_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_ADDR_SUBUNIT: + memcpy(&pSubmitSM->source_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_addr_subunit: 0x%02X\n", pSubmitSM->source_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DESTINATION_PORT: + memcpy(&pSubmitSM->destination_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "destination_port: 0x%04X\n", pSubmitSM->destination_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_ADDR_SUBUNIT: + memcpy(&pSubmitSM->dest_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_addr_subunit: 0x%02X\n", pSubmitSM->dest_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_MSG_REF_NUM: + memcpy(&pSubmitSM->sar_msg_ref_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_msg_ref_num: 0x%04X\n", pSubmitSM->sar_msg_ref_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_TOTAL_SEGMENTS: + memcpy(&pSubmitSM->sar_total_segments, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_total_segments: 0x%02X\n", pSubmitSM->sar_total_segments); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_SEGMENT_SEQNUM: + memcpy(&pSubmitSM->sar_segment_seqnum, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_segment_seqnum: 0x%02X\n", pSubmitSM->sar_segment_seqnum); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MORE_MESSAGES_TO_SEND: + memcpy(&pSubmitSM->more_messages_to_send, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "more_messages_to_send: 0x%02X\n", pSubmitSM->more_messages_to_send); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PAYLOAD_TYPE: + memcpy(&pSubmitSM->payload_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "payload_type: 0x%02X\n", pSubmitSM->payload_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_PAYLOAD: + memcpy(pSubmitSM->message_payload, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_payload: %s\n", pSubmitSM->message_payload); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PRIVACY_INDICATOR: + memcpy(&pSubmitSM->privacy_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "privacy_indicator: 0x%02X\n", pSubmitSM->privacy_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM: + memcpy(pSubmitSM->callback_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num: %s\n", pSubmitSM->callback_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_PRES_IND: + memcpy(&pSubmitSM->callback_num_pres_ind, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_pres_ind: 0x%02X\n", pSubmitSM->callback_num_pres_ind); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_ATAG: + memcpy(pSubmitSM->callback_num_atag, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_atag: %s\n", pSubmitSM->callback_num_atag); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_SUBADDRESS: + memcpy(pSubmitSM->source_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_subaddress: %s\n", pSubmitSM->source_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_SUBADDRESS: + memcpy(pSubmitSM->dest_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_subaddress: %s\n", pSubmitSM->dest_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USER_RESPONSE_CODE: + memcpy(&pSubmitSM->user_response_code, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_response_code: 0x%02X\n", pSubmitSM->user_response_code); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DISPLAY_TIME: + memcpy(&pSubmitSM->display_time, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "display_time: 0x%02X\n", pSubmitSM->display_time); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SMS_SIGNAL: + memcpy(&pSubmitSM->sms_signal, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sms_signal: 0x%04X\n", pSubmitSM->sms_signal); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_VALIDITY: + memcpy(&pSubmitSM->ms_validity, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_validity: 0x%02X\n", pSubmitSM->ms_validity); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_MSG_WAIT_FACILITIES: + memcpy(&pSubmitSM->ms_msg_wait_facilities, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_msg_wait_facilities: 0x%02X\n", pSubmitSM->ms_msg_wait_facilities); + smpp_send_ascout(debugBuf); + } + #endif + break; + case NUMBER_OF_MESSAGES: + memcpy(&pSubmitSM->number_of_messages, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "number_of_messages: 0x%02X\n", pSubmitSM->number_of_messages); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ALERT_ON_MESSAGE_DELIVERY: + current_len = current_len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "alert_on_message_delivery: 0x%02X\n", pSubmitSM->alert_on_message_delivery); + smpp_send_ascout(debugBuf); + } + #endif + break; + case LANGUAGE_INDICATOR: + memcpy(&pSubmitSM->language_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "language_indicator: 0x%02X\n", pSubmitSM->language_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ITS_REPLY_TYPE: + memcpy(&pSubmitSM->its_reply_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "its_reply_type: 0x%02X\n", pSubmitSM->its_reply_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ITS_SESSION_INFO: + memcpy(pSubmitSM->its_session_info, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "its_session_info: 0x%02X%02X\n", + pSubmitSM->its_session_info[0], pSubmitSM->its_session_info[1]); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USSD_SERVICE_OP: + memcpy(&pSubmitSM->ussd_service_op, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ussd_service_op: 0x%04X\n", pSubmitSM->ussd_service_op); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_NETWORK_TYPE: + memcpy(&pSubmitSM->dest_network_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_network_type: 0x%04X\n", pSubmitSM->dest_network_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in SUBMIT_SM. tag=0x%04X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + return 0; + } + } + } + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_SUBMIT_SM)); + break; + case SUBMIT_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = SubmitSMResp; + + pMsg = pData->msg; + pSubmitSMResp = &smppMsg.pdu.submit_sm_resp; + smppMsg.message_type = 0x0C; + + memcpy(&pSubmitSMResp->head, &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitSMResp->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[Mandatory Parameters]\nmessage_id: %s\n", + pSubmitSMResp->message_id); + smpp_send_ascout(debugBuf); + } + #endif + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_SM_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_SM_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_SUBMIT_SM_RESP)); + break; + case SUBMIT_MULTI: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = SubmitMulti; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pSubmitMulti = &smppMsg.pdu.submit_multi; + smppMsg.message_type = 0x0D; + + memcpy(&pSubmitMulti->head, &pData->head, 16); + + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->service_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitMulti->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitMulti->number_of_dests = *(pMsg+current_len); + current_len += 1; + for (i=0; inumber_of_dests; i++) + { + switch(*(pMsg+current_len)) + { + case 1: //SME address + pSubmitMulti->dest_address[i].dest_flag = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (j=0; j<21; j++) + { + if (*(pMsg+current_len+j) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.destination_addr, + pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + break; + case 2: //Distribution List Name + pSubmitMulti->dest_address[i].dest_flag = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (j=0; j<21; j++) + { + if (*(pMsg+current_len+j) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->dest_address[i].dest_addr.dl_name.dl_name, + pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + break; + default: + break; + } + } + pSubmitMulti->esm_class = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->protocol_id = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->priority_flag = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->schedule_delivery_time, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMulti->validity_period, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitMulti->registered_delivery = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->replace_if_present_flag= *(pMsg+current_len); + current_len += 1; + pSubmitMulti->data_coding = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->sm_default_msg_id = *(pMsg+current_len); + current_len += 1; + pSubmitMulti->sm_length = *(pMsg+current_len); + current_len += 1; + memcpy(pSubmitMulti->short_message, pMsg+current_len, pSubmitMulti->sm_length); + pSubmitMulti->short_message[pSubmitMulti->sm_length] = 0; + current_len += pSubmitMulti->sm_length; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pSubmitMulti->source_addr_ton); + smpp_npi_to_string(npi_str, pSubmitMulti->source_addr_npi); + sprintf(debugBuf, "service_type: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pSubmitMulti->service_type, + pSubmitMulti->source_addr_ton, ton_str, + pSubmitMulti->source_addr_npi, npi_str, + pSubmitMulti->source_addr); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "number_of_dests: %d,\t", + pSubmitMulti->number_of_dests); + smpp_send_ascout(debugBuf); + for (i=0; inumber_of_dests; i++) + { + if (0 == pSubmitMulti->number_of_dests) break; + if (pSubmitMulti->dest_address[i].dest_flag == 1) + { + sprintf(debugBuf, "destination address %d flag: 0x01 - %s", + i, "SME address"); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_ton); + smpp_npi_to_string(npi_str, pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_npi); + sprintf(debugBuf, "ton: 0x%02X - %s,\tnpi: 0x%02X - %s,\tdestination_addr: %s,\t", + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_ton, ton_str, + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.dest_addr_npi, npi_str, + pSubmitMulti->dest_address[i].dest_addr.sme_dest_address.destination_addr); + smpp_send_ascout(debugBuf); + }else if (pSubmitMulti->dest_address[i].dest_flag == 2) + { + sprintf(debugBuf, "destination address %d flag: 0x02 - %s,\tdl_name: %s,\t", + i, "Distribution List Name", + pSubmitMulti->dest_address[i].dest_addr.dl_name.dl_name); + smpp_send_ascout(debugBuf); + } + } + sprintf(debugBuf, "esm_class: 0x%x,\tprotocol_id: 0x%x,\tpriority_flag: 0x%x,\tschedule_delivery_time: %s,\tvalidity_period: %s,\tregistered_delivery: 0x%x\t", + pSubmitMulti->esm_class, + pSubmitMulti->protocol_id, + pSubmitMulti->priority_flag, + pSubmitMulti->schedule_delivery_time, + pSubmitMulti->validity_period, + pSubmitMulti->registered_delivery); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "replace_if_present_flag: 0x%x,\tdata_coding: 0x%x,\tsm_default_msg_id: 0x%x,\tsm_length: 0x%x,\tshort_message: %s\n", + pSubmitMulti->replace_if_present_flag, + pSubmitMulti->data_coding, + pSubmitMulti->sm_default_msg_id, + pSubmitMulti->sm_length, + pSubmitMulti->short_message); + smpp_send_ascout(debugBuf); + } + #endif + + /* optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; iuser_message_reference, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_message_reference: 0x%04X\n", pSubmitMulti->user_message_reference); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_PORT: + memcpy(&pSubmitMulti->source_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_port: 0x%04X\n", pSubmitMulti->source_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_ADDR_SUBUNIT: + memcpy(&pSubmitMulti->source_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_addr_subunit: 0x%02X\n", pSubmitMulti->source_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DESTINATION_PORT: + memcpy(&pSubmitMulti->destination_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "destination_port: 0x%04X\n", pSubmitMulti->destination_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_ADDR_SUBUNIT: + memcpy(&pSubmitMulti->dest_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_addr_subunit: 0x%02X\n", pSubmitMulti->dest_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_MSG_REF_NUM: + memcpy(&pSubmitMulti->sar_msg_ref_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_msg_ref_num: 0x%04X\n", pSubmitMulti->sar_msg_ref_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_TOTAL_SEGMENTS: + memcpy(&pSubmitMulti->sar_total_segments, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_total_segments: 0x%02X\n", pSubmitMulti->sar_total_segments); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_SEGMENT_SEQNUM: + memcpy(&pSubmitMulti->sar_segment_seqnum, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_segment_seqnum: 0x%02X\n", pSubmitMulti->sar_segment_seqnum); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PAYLOAD_TYPE: + memcpy(&pSubmitMulti->payload_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "payload_type: 0x%02X\n", pSubmitMulti->payload_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_PAYLOAD: + memcpy(pSubmitMulti->message_payload, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_payload: %s\n", pSubmitMulti->message_payload); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PRIVACY_INDICATOR: + memcpy(&pSubmitMulti->privacy_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "privacy_indicator: 0x%02X\n", pSubmitMulti->privacy_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM: + memcpy(pSubmitMulti->callback_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num: %s\n", pSubmitMulti->callback_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_PRES_IND: + memcpy(&pSubmitMulti->callback_num_pres_ind, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_pres_ind: 0x%02X\n", pSubmitMulti->callback_num_pres_ind); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_ATAG: + memcpy(pSubmitMulti->callback_num_atag, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_atag: %s\n", pSubmitMulti->callback_num_atag); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_SUBADDRESS: + memcpy(pSubmitMulti->source_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_subaddress: %s\n", pSubmitMulti->source_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_SUBADDRESS: + memcpy(pSubmitMulti->dest_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_subaddress: %s\n", pSubmitMulti->dest_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DISPLAY_TIME: + memcpy(&pSubmitMulti->display_time, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "display_time: 0x%02X\n", pSubmitMulti->display_time); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SMS_SIGNAL: + memcpy(&pSubmitMulti->sms_signal, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sms_signal: 0x%04X\n", pSubmitMulti->sms_signal); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_VALIDITY: + memcpy(&pSubmitMulti->ms_validity, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_validity: 0x%02X\n", pSubmitMulti->ms_validity); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_MSG_WAIT_FACILITIES: + memcpy(&pSubmitMulti->ms_msg_wait_facilities, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_msg_wait_facilities: 0x%02X\n", pSubmitMulti->ms_msg_wait_facilities); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ALERT_ON_MESSAGE_DELIVERY: + current_len = current_len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "alert_on_message_delivery: 0x%02X\n", pSubmitMulti->alert_on_message_delivery); + smpp_send_ascout(debugBuf); + } + #endif + break; + case LANGUAGE_INDICATOR: + memcpy(&pSubmitMulti->language_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "language_indicator: 0x%02X\n", pSubmitMulti->language_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_NETWORK_TYPE: + memcpy(&pSubmitMulti->dest_network_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_network_type: 0x%04X\n", pSubmitMulti->dest_network_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in SUBMIT_MULTI. tag=0x%04X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + smpp_sendResponse(linkNo, SUBMIT_SM_RESP, ESME_ROPTPARNOTALLWD, sequence_number); + return 0; + } + } + } + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_MULTI: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive SUBMIT_MULTI: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_SUBMIT_MULTI)); + break; + case SUBMIT_MULTI_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = SubmitMultiResp; + + pMsg = pData->msg; + pSubmitMultiResp = &smppMsg.pdu.submit_multi_resp; + smppMsg.message_type = 0x0E; + + memcpy(&(pSubmitMultiResp->head), &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMultiResp->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pSubmitMultiResp->no_unsuccess = *(pMsg+current_len); + current_len += 1; + for (i=0; ino_unsuccess; i++) + { + pSubmitMultiResp->unsuccess_sme[i].dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pSubmitMultiResp->unsuccess_sme[i].dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pSubmitMultiResp->unsuccess_sme[i].destination_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + memcpy(&pSubmitMultiResp->unsuccess_sme[i].error_status_code, pMsg+current_len, 4); + } + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + sprintf(debugBuf, "message_id: %s\nno_unsuccess: %d\n", + pSubmitMultiResp->message_id, + pSubmitMultiResp->no_unsuccess); + for (i=0; ino_unsuccess; i++) + { + if (pSubmitMultiResp->no_unsuccess == 0) break; + smpp_ton_to_string(ton_str, pSubmitMultiResp->unsuccess_sme[i].dest_addr_ton); + smpp_npi_to_string(npi_str, pSubmitMultiResp->unsuccess_sme[i].dest_addr_npi); + smpp_command_status_to_string(status_str, pSubmitMultiResp->unsuccess_sme[i].error_status_code); + sprintf(debugBuf, "[unsuccess dest %d] ton: 0x%x - %s, npi: 0x%x - %s, destination_addr: %s, error_status_code: %ld - %s\n", + i, + pSubmitMultiResp->unsuccess_sme[i].dest_addr_ton, ton_str, + pSubmitMultiResp->unsuccess_sme[i].dest_addr_npi, npi_str, + pSubmitMultiResp->unsuccess_sme[i].destination_addr, + pSubmitMultiResp->unsuccess_sme[i].error_status_code, status_str); + } + } + #endif + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_SUBMIT_MULTI_RESP)); + break; + case DELIVER_SM: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = DeliverSM; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pDeliverSM = &smppMsg.pdu.deliver_sm; + smppMsg.message_type = 0x0F; + + memcpy(&pDeliverSM->head, &pData->head, 16); + + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDeliverSM->service_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDeliverSM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pDeliverSM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDeliverSM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDeliverSM->dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pDeliverSM->dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDeliverSM->destination_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDeliverSM->esm_class = *(pMsg+current_len); + current_len += 1; + pDeliverSM->protocol_id = *(pMsg+current_len); + current_len += 1; + pDeliverSM->priority_flag = *(pMsg+current_len); + current_len += 1; + pDeliverSM->schedule_delivery_time = *(pMsg+current_len); + current_len += 1; + pDeliverSM->validity_period = *(pMsg+current_len); + current_len += 1; + pDeliverSM->registered_delivery = *(pMsg+current_len); + current_len += 1; + pDeliverSM->replace_if_present_flag = *(pMsg+current_len); + current_len += 1; + pDeliverSM->data_coding = *(pMsg+current_len); + current_len += 1; + pDeliverSM->sm_default_msg_id = *(pMsg+current_len); + current_len += 1; + pDeliverSM->sm_length = *(pMsg+current_len); + current_len += 1; + memcpy(pDeliverSM->short_message, pMsg+current_len, pDeliverSM->sm_length); + current_len += pDeliverSM->sm_length; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pDeliverSM->source_addr_ton); + smpp_npi_to_string(npi_str, pDeliverSM->source_addr_npi); + sprintf(debugBuf, "service_type: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pDeliverSM->service_type, + pDeliverSM->source_addr_ton, ton_str, + pDeliverSM->source_addr_npi, npi_str, + pDeliverSM->source_addr); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pDeliverSM->dest_addr_ton); + smpp_npi_to_string(npi_str, pDeliverSM->dest_addr_npi); + sprintf(debugBuf, "dest_addr_ton: 0x%x - %s,\tdest_addr_npi: 0x%x - %s,\tdestination_addr: %s\t", + pDeliverSM->dest_addr_ton, ton_str, + pDeliverSM->dest_addr_npi, npi_str, + pDeliverSM->destination_addr); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "esm_class: 0x%x,\tprotocol_id: 0x%x,\tpriority_flag: 0x%x,\tschedule_delivery_time: 0x%02X,\tvalidity_period: 0x%02X,\tregistered_delivery: 0x%x\t", + pDeliverSM->esm_class, + pDeliverSM->protocol_id, + pDeliverSM->priority_flag, + pDeliverSM->schedule_delivery_time, + pDeliverSM->validity_period, + pDeliverSM->registered_delivery); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "replace_if_present_flag: 0x%x,\tdata_coding: 0x%x,\tsm_default_msg_id: 0x%x,\tsm_length: 0x%x,\tshort_message: %s\n", + pDeliverSM->replace_if_present_flag, + pDeliverSM->data_coding, + pDeliverSM->sm_default_msg_id, + pDeliverSM->sm_length, + pDeliverSM->short_message); + smpp_send_ascout(debugBuf); + } + #endif + + /* optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; iuser_message_reference, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_message_reference: 0x%04X\n", pDeliverSM->user_message_reference); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_PORT: + memcpy(&pDeliverSM->source_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_port: 0x%04X\n", pDeliverSM->source_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DESTINATION_PORT: + memcpy(&pDeliverSM->destination_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "destination_port: 0x%04X\n", pDeliverSM->destination_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_MSG_REF_NUM: + memcpy(&pDeliverSM->sar_msg_ref_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_msg_ref_num: 0x%04X\n", pDeliverSM->sar_msg_ref_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_TOTAL_SEGMENTS: + memcpy(&pDeliverSM->sar_total_segments, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_total_segments: 0x%02X\n", pDeliverSM->sar_total_segments); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_SEGMENT_SEQNUM: + memcpy(&pDeliverSM->sar_segment_seqnum, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_segment_seqnum: 0x%02X\n", pDeliverSM->sar_segment_seqnum); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USER_RESPONSE_CODE: + memcpy(&pDeliverSM->user_response_code, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_response_code: 0x%02X\n", pDeliverSM->user_response_code); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PRIVACY_INDICATOR: + memcpy(&pDeliverSM->privacy_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "privacy_indicator: 0x%02X\n", pDeliverSM->privacy_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PAYLOAD_TYPE: + memcpy(&pDeliverSM->payload_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "payload_type: 0x%02X\n", pDeliverSM->payload_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_PAYLOAD: + memcpy(pDeliverSM->message_payload, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_payload: %s\n", pDeliverSM->message_payload); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM: + memcpy(pDeliverSM->callback_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num: %s\n", pDeliverSM->callback_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_SUBADDRESS: + memcpy(pDeliverSM->source_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_subaddress: %s\n", pDeliverSM->source_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_SUBADDRESS: + memcpy(pDeliverSM->dest_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_subaddress: %s\n", pDeliverSM->dest_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case LANGUAGE_INDICATOR: + memcpy(&pDeliverSM->language_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "language_indicator: 0x%02X\n", pDeliverSM->language_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ITS_SESSION_INFO: + memcpy(pDeliverSM->its_session_info, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "its_session_info: 0x%02X%02X\n", + pDeliverSM->its_session_info[0], pDeliverSM->its_session_info[1]); + smpp_send_ascout(debugBuf); + } + #endif + break; + case NETWORK_ERROR_CODE: + memcpy(&pDeliverSM->network_error_code, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "network_error_code: 0x%02X%02X%02X\n", + pDeliverSM->network_error_code[0], + pDeliverSM->network_error_code[1], + pDeliverSM->network_error_code[2]); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_STATE: + memcpy(&pDeliverSM->message_state, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_state: 0x%02X\n", pDeliverSM->message_state); + smpp_send_ascout(debugBuf); + } + #endif + break; + case RECEIPTED_MESSAGE_ID: + memcpy(&pDeliverSM->receipted_message_id, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "receipted_message_id: %s\n", pDeliverSM->receipted_message_id); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USSD_SERVICE_OP: + memcpy(&pDeliverSM->ussd_service_op, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ussd_service_op: 0x%04X\n", pDeliverSM->ussd_service_op); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in DELIVER_SM. tag=0x%04X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + smpp_sendResponse(linkNo, DATA_SM_RESP, ESME_ROPTPARNOTALLWD, sequence_number); + return 0; + } + } + } + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DELIVER_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DELIVER_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, &smppMsg, sizeof(PDU_DELIVER_SM)); + break; + case DELIVER_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = DeliverSMResp; + /* fill with SMPP_MSG data structure. */ + pMsg = pData->msg; + pDeliverSMResp = &smppMsg.pdu.deliver_sm_resp; + smppMsg.message_type = 0x10; + + memcpy(&pDeliverSMResp->head, &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + //lw modify here 06/10/08 decode code byte sequence error + pDeliverSMResp->head.command_length = ntohl(pData->head.command_length); + pDeliverSMResp->head.command_id = ntohl(pData->head.command_id); + pDeliverSMResp->head.command_status = ntohl(pData->head.command_status); + pDeliverSMResp->head.sequence_number = ntohl(pData->head.sequence_number); +// for (i=0; i<65; i++) +// { +// if (*(pMsg+current_len+i) != 0) c_octet_string_len++; +// else break; +// } +// comment patch 20 + memcpy(&pDeliverSMResp->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DELIVER_SM_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DELIVER_SM_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_DELIVER_SM_RESP)); + break; + case DATA_SM: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = DataSM; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pDataSM = &smppMsg.pdu.data_sm; + smppMsg.message_type = 0x11; + + memcpy(&pDataSM->head, &pData->head, 16); + + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDataSM->service_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDataSM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pDataSM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDataSM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDataSM->dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pDataSM->dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDataSM->destination_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pDataSM->esm_class = *(pMsg+current_len); + current_len += 1; + pDataSM->registered_delivery = *(pMsg+current_len); + current_len += 1; + pDataSM->data_coding = *(pMsg+current_len); + current_len += 1; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pDataSM->source_addr_ton); + smpp_npi_to_string(npi_str, pDataSM->source_addr_npi); + sprintf(debugBuf, "service_type: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pDataSM->service_type, + pDataSM->source_addr_ton, ton_str, + pDataSM->source_addr_npi, npi_str, + pDataSM->source_addr); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pDataSM->dest_addr_ton); + smpp_npi_to_string(npi_str, pDataSM->dest_addr_npi); + sprintf(debugBuf, "dest_addr_ton: 0x%x - %s,\tdest_addr_npi: 0x%x - %s,\tdestination_addr: %s\t", + pDataSM->dest_addr_ton, ton_str, + pDataSM->dest_addr_npi, npi_str, + pDataSM->destination_addr); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "esm_class: 0x%x,\tregistered_delivery: 0x%x\tdata_coding: 0x%x, current_len=%d\n", + pDataSM->esm_class, + pDataSM->registered_delivery, + pDataSM->data_coding, + current_len); + smpp_send_ascout(debugBuf); + } + #endif + + /* optional parameter */ + + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; isource_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_port: 0x%04X\n", pDataSM->source_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_ADDR_SUBUNIT: + memcpy(&pDataSM->source_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_addr_subunit: 0x%02X\n", pDataSM->source_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_NETWORK_TYPE: + memcpy(&pDataSM->source_network_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_network_type: 0x%02X\n", pDataSM->source_network_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_BEARER_TYPE: + memcpy(&pDataSM->source_bearer_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_bearer_type: 0x%02X\n", pDataSM->source_bearer_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_TELEMATICS_ID: + memcpy(&pDataSM->source_telematics_id, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_telematics_id: 0x%04X\n", pDataSM->source_telematics_id); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DESTINATION_PORT: + memcpy(&pDataSM->destination_port, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "destination_port: 0x%04X\n", pDataSM->destination_port); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_ADDR_SUBUNIT: + memcpy(&pDataSM->dest_addr_subunit, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_addr_subunit: 0x%02X\n", pDataSM->dest_addr_subunit); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_NETWORK_TYPE: + memcpy(&pDataSM->dest_network_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_network_type: 0x%02X\n", pDataSM->dest_network_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_BEARER_TYPE: + memcpy(&pDataSM->dest_bearer_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_bearer_type: 0x%02X\n", pDataSM->dest_bearer_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_TELEMATICS_ID: + memcpy(&pDataSM->dest_telematics_id, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_telematics_id: 0x%02X\n", pDataSM->dest_telematics_id); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_MSG_REF_NUM: + memcpy(&pDataSM->sar_msg_ref_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_msg_ref_num: 0x%04X\n", pDataSM->sar_msg_ref_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_TOTAL_SEGMENTS: + memcpy(&pDataSM->sar_total_segments, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_total_segments: 0x%02X\n", pDataSM->sar_total_segments); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SAR_SEGMENT_SEQNUM: + memcpy(&pDataSM->sar_segment_seqnum, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sar_segment_seqnum: 0x%02X\n", pDataSM->sar_segment_seqnum); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MORE_MESSAGES_TO_SEND: + memcpy(&pDataSM->more_messages_to_send, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "more_messages_to_send: 0x%02X\n", pDataSM->more_messages_to_send); + smpp_send_ascout(debugBuf); + } + #endif + break; + case QOS_TIME_TO_LIVE: + memcpy(&pDataSM->qos_time_to_live, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "qos_time_to_live: 0x%lx\n", pDataSM->qos_time_to_live); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PAYLOAD_TYPE: + memcpy(&pDataSM->payload_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "payload_type: 0x%02X\n", pDataSM->payload_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_PAYLOAD: + memcpy(pDataSM->message_payload, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_payload: %s\n", pDataSM->message_payload); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SET_DPF: + memcpy(&pDataSM->set_dpf, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "set_dpf: 0x%02X\n", pDataSM->set_dpf); + smpp_send_ascout(debugBuf); + } + #endif + break; + case RECEIPTED_MESSAGE_ID: + memcpy(pDataSM->receipted_message_id, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "receipted_message_id: %s\n", pDataSM->receipted_message_id); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MESSAGE_STATE: + memcpy(&pDataSM->message_state, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "message_state: 0x%02X\n", pDataSM->message_state); + smpp_send_ascout(debugBuf); + } + #endif + break; + case NETWORK_ERROR_CODE: + memcpy(pDataSM->network_error_code, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "network_error_code: 0x%02X%02X%02X\n", + pDataSM->network_error_code[0], + pDataSM->network_error_code[1], + pDataSM->network_error_code[2]); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USER_MESSAGE_REFERENCE: + memcpy(&pDataSM->user_message_reference, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_message_reference: 0x%02X\n", pDataSM->user_message_reference); + smpp_send_ascout(debugBuf); + } + #endif + break; + case PRIVACY_INDICATOR: + memcpy(&pDataSM->privacy_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "privacy_indicator: 0x%02X\n", pDataSM->privacy_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM: + memcpy(pDataSM->callback_num, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num: %s\n", pDataSM->callback_num); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_PRES_IND: + memcpy(&pDataSM->callback_num_pres_ind, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_pres_ind: 0x%02X\n", pDataSM->callback_num_pres_ind); + smpp_send_ascout(debugBuf); + } + #endif + break; + case CALLBACK_NUM_ATAG: + memcpy(&pDataSM->callback_num_atag, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "callback_num_atag: %s\n", pDataSM->callback_num_atag); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SOURCE_SUBADDRESS: + memcpy(pDataSM->source_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "source_subaddress: %s\n", pDataSM->source_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DEST_SUBADDRESS: + memcpy(pDataSM->dest_subaddress, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "dest_subaddress: %s\n", pDataSM->dest_subaddress); + smpp_send_ascout(debugBuf); + } + #endif + break; + case USER_RESPONSE_CODE: + memcpy(&pDataSM->user_response_code, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "user_response_code: 0x%02X\n", pDataSM->user_response_code); + smpp_send_ascout(debugBuf); + } + #endif + break; + case DISPLAY_TIME: + memcpy(&pDataSM->display_time, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "display_time: 0x%02X\n", pDataSM->display_time); + smpp_send_ascout(debugBuf); + } + #endif + break; + case SMS_SIGNAL: + memcpy(&pDataSM->sms_signal, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "sms_signal: 0x%04X\n", pDataSM->sms_signal); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_VALIDITY: + memcpy(&pDataSM->ms_validity, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_validity: 0x%02X\n", pDataSM->ms_validity); + smpp_send_ascout(debugBuf); + } + #endif + break; + case MS_MSG_WAIT_FACILITIES: + memcpy(&pDataSM->ms_msg_wait_facilities, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_msg_wait_facilities: 0x%02X\n", pDataSM->ms_msg_wait_facilities); + smpp_send_ascout(debugBuf); + } + #endif + break; + case NUMBER_OF_MESSAGES: + memcpy(&pDataSM->number_of_messages, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "number_of_messages: 0x%02X\n", pDataSM->number_of_messages); + smpp_send_ascout(debugBuf); + } + #endif + break; + case LANGUAGE_INDICATOR: + memcpy(&pDataSM->language_indicator, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "language_indicator: 0x%02X\n", pDataSM->language_indicator); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ALERT_ON_MESSAGE_DELIVERY: + current_len = current_len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "alert_on_message_delivery: 0x%02X\n", pDataSM->alert_on_message_delivery); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ITS_REPLY_TYPE: + memcpy(&pDataSM->its_reply_type, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "its_reply_type: 0x%02X\n", pDataSM->its_reply_type); + smpp_send_ascout(debugBuf); + } + #endif + break; + case ITS_SESSION_INFO: + memcpy(pDataSM->its_session_info, &opt_param[i].value, opt_param[i].len); + current_len = current_len + opt_param[i].len + 4; + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "its_session_info: 0x%02X%02X\n", + pDataSM->its_session_info[0], pDataSM->its_session_info[1]); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in DATA_SM. tag=0x%04X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + smpp_sendResponse(linkNo, DATA_SM_RESP, ESME_ROPTPARNOTALLWD, sequence_number); + return 0; + } + } + } + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DATA_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DATA_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_DATA_SM)); + break; + case DATA_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = DataSMResp; + + pMsg = pData->msg; + pDataSMResp = &smppMsg.pdu.data_sm_resp; + smppMsg.message_type = 0x12; + + memcpy(&pDataSMResp->head, &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pDataSMResp->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DATA_SM_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive DATA_SM_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_DATA_SM_RESP)); + break; + case QUERY_SM: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = QuerySM; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pQuerySM = &smppMsg.pdu.query_sm; + smppMsg.message_type = 0x13; + + memcpy(&pQuerySM->head, &pData->head, 16); + + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pQuerySM->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pQuerySM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pQuerySM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pQuerySM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pQuerySM->source_addr_ton); + smpp_npi_to_string(npi_str, pQuerySM->source_addr_npi); + sprintf(debugBuf, "message_id: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pQuerySM->message_id, + pQuerySM->source_addr_ton, ton_str, + pQuerySM->source_addr_npi, npi_str, + pQuerySM->source_addr); + smpp_send_ascout(debugBuf); + } + #endif + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive QUERY_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive QUERY_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_QUERY_SM)); + break; + case QUERY_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = QuerySMResp; + + pMsg = pData->msg; + pQuerySMResp = &smppMsg.pdu.query_sm_resp; + smppMsg.message_type = 0x14; + + memcpy(&pQuerySMResp->head, &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pQuerySMResp->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pQuerySMResp->final_date, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pQuerySMResp->message_state = *(pMsg+current_len); + current_len += 1; + pQuerySMResp->error_code = *(pMsg+current_len); + current_len += 1; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + sprintf(debugBuf, "message_id: %s,\tfinal_date: %s,\tmessage_state: 0x%x,\terror_code: 0x%02X\t", + pQuerySMResp->message_id, + pQuerySMResp->final_date, + pQuerySMResp->message_state, + pQuerySMResp->error_code); + smpp_send_ascout(debugBuf); + } + #endif + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive QUERY_SM_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive QUERY_SM_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_QUERY_SM_RESP)); + break; + case CANCEL_SM: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = CancelSM; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pCancelSM = &smppMsg.pdu.cancel_sm; + smppMsg.message_type = 0x15; + + memcpy(&(pCancelSM->head), &pData->head, 16); + + /* mandatory parameter */ + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pCancelSM->service_type, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pCancelSM->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pCancelSM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pCancelSM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pCancelSM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pCancelSM->dest_addr_ton = *(pMsg+current_len); + current_len += 1; + pCancelSM->dest_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pCancelSM->destination_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pCancelSM->source_addr_ton); + smpp_npi_to_string(npi_str, pCancelSM->source_addr_npi); + sprintf(debugBuf, "service_type: %s,\tmessage_id: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pCancelSM->service_type, + pCancelSM->message_id, + pCancelSM->source_addr_ton, ton_str, + pCancelSM->source_addr_npi, npi_str, + pCancelSM->source_addr); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pCancelSM->dest_addr_ton); + smpp_npi_to_string(npi_str, pCancelSM->dest_addr_npi); + sprintf(debugBuf, "dest_addr_ton: 0x%x - %s,\tdest_addr_npi: 0x%x - %s,\tdestination_addr: %s\t", + pCancelSM->dest_addr_ton, ton_str, + pCancelSM->dest_addr_npi, npi_str, + pCancelSM->destination_addr); + smpp_send_ascout(debugBuf); + } + #endif + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive CANCEL_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive CANCEL_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_CANCEL_SM)); + break; + case CANCEL_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = CancelSMResp; + /* fill with SMPP_MSG data structure. */ + pCancelSMResp = &smppMsg.pdu.cancel_sm_resp; + smppMsg.message_type = 0x16; + + memcpy(&pCancelSMResp->head, &pData->head, 16); + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive CANCEL_SM_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive CANCEL_SM_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_CANCEL_SM_RESP)); + break; + case REPLACE_SM: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = ReplaceSM; + smpp_link[linkNo].seq_num = sequence_number; + + pMsg = pData->msg; + pReplaceSM = &smppMsg.pdu.replace_sm; + smppMsg.message_type = 0x17; + + memcpy(&pReplaceSM->head, &pData->head, 16); + + current_len = 0; + c_octet_string_len = 1; + for (i=0; i<6; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pReplaceSM->message_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pReplaceSM->source_addr_ton = *(pMsg+current_len); + current_len += 1; + pReplaceSM->source_addr_npi = *(pMsg+current_len); + current_len += 1; + c_octet_string_len = 1; + for (i=0; i<21; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pReplaceSM->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pReplaceSM->schedule_delivery_time, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + c_octet_string_len = 1; + for (i=0; i<17; i++) + { + if (*(pMsg+current_len+i) != 0) c_octet_string_len++; + else break; + } + memcpy(pReplaceSM->validity_period, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + pReplaceSM->registered_delivery = *(pMsg+current_len); + current_len += 1; + pReplaceSM->sm_default_msg_id = *(pMsg+current_len); + current_len += 1; + pReplaceSM->sm_length = *(pMsg+current_len); + current_len += 1; + memcpy(pReplaceSM->short_message, pMsg+current_len, pReplaceSM->sm_length); + current_len += pReplaceSM->sm_length; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Mandatory parameters]\n"); + smpp_ton_to_string(ton_str, pReplaceSM->source_addr_ton); + smpp_npi_to_string(npi_str, pReplaceSM->source_addr_npi); + sprintf(debugBuf, "message_id: %s,\tsource_addr_ton: 0x%x - %s,\tsource_addr_npi: 0x%x - %s,\tsource_addr: %s\t", + pReplaceSM->message_id, + pReplaceSM->source_addr_ton, ton_str, + pReplaceSM->source_addr_npi, npi_str, + pReplaceSM->source_addr); + smpp_send_ascout(debugBuf); + sprintf(debugBuf, "schedule_delivery_time: %s,\tvalidity_period: %s,\tregistered_delivery: 0x%02X,\tsm_default_msg_id: 0x%02X, sm_length: 02%02X, short_message: %s\n", + pReplaceSM->schedule_delivery_time, + pReplaceSM->validity_period, + pReplaceSM->registered_delivery, + pReplaceSM->sm_default_msg_id, + pReplaceSM->sm_length, + pReplaceSM->short_message); + smpp_send_ascout(debugBuf); + } + #endif + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive REPLACE_SM: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive REPLACE_SM: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_REPLACE_SM)); + break; + case REPLACE_SM_RESP: + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = ReplaceSMResp; + /* fill with SMPP_MSG data structure. */ + pReplaceSMResp = &smppMsg.pdu.replace_sm_resp; + smppMsg.message_type = 0x18; + memcpy(&pReplaceSMResp->head, &pData->head, 16); + if(callBackFunc[linkNo].data_proc!= NULL) + callBackFunc[linkNo].data_proc(linkNo, (SMPP_MSG *)&smppMsg, sizeof(PDU_REPLACE_SM_RESP)); + break; + case UNBIND: + if (16 != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive UNBIND: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (16 != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive UNBIND: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = Unbind; + smpp_link[linkNo].seq_num = sequence_number; + break; + case UNBIND_RESP: + if (16 != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive UNBIND_RESP: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (16 != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive UNBIND_RESP: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = UnbindResp; + break; + case GENERIC_NAK: + if (16 != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive GENERIC_NAK: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (16 != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive GENERIC_NAK: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = GenericNak; + smpp_link[linkNo].seq_num = sequence_number; + break; + case OUTBIND: + pMsg = pData->msg; + pOutbind = &smppMsg.pdu.outbind; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* system id */ + c_octet_string_len = 1; + for (i=0; i<16; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pOutbind->system_id, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* password */ + c_octet_string_len = 1; + for (i=0; i<9; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pOutbind->password, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive OUTBIND: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive OUTBIND: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + if (strcmp(pOutbind->system_id, smpp_param[linkNo].sys_id) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive OUTBIND: system_id = %s, sys_id in param=%s\n", + linkNo, + pOutbind->system_id, + smpp_param[linkNo].sys_id); + smpp_send_error(debugBuf); + } + #endif +// smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVSYSID); + return 0; + } + + if (strcmp(pOutbind->password, smpp_param[linkNo].password) != 0) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg]link %d receive OUTBIND: password = %s, password in param=%s\n", + linkNo, + pOutbind->password, + smpp_param[linkNo].password); + smpp_send_error(debugBuf); + } + #endif +// smpp_sendBindResp(linkNo, BindReceiverResp, ESME_RINVPASWD); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = Outbind; + break; + case ALERT_NOTIFICATION: + pMsg = pData->msg; + pAlertNotification = &smppMsg.pdu.alert_notification; + smpp_link[linkNo].seq_num = sequence_number; + + /* mandatory parameter */ + + current_len = 0; + + /* addr_ton */ + pAlertNotification->source_addr_ton = *(pMsg+current_len); + current_len += 1; + + /* addr_npi */ + pAlertNotification->source_addr_npi = *(pMsg+current_len); + current_len += 1; + + /* source_addr */ + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pAlertNotification->source_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + /* esme_addr_ton */ + pAlertNotification->esme_addr_ton = *(pMsg+current_len); + current_len += 1; + + /* esme_addr_npi */ + pAlertNotification->esme_addr_npi = *(pMsg+current_len); + current_len += 1; + + /* esme_addr */ + c_octet_string_len = 1; + for (i=0; i<65; i++) + { + if (pMsg[current_len+i] != 0) c_octet_string_len++; + else break; + } + memcpy(pAlertNotification->esme_addr, pMsg+current_len, c_octet_string_len); + current_len += c_octet_string_len; + + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_ton_to_string(ton_str, pAlertNotification->source_addr_ton); + smpp_npi_to_string(npi_str, pAlertNotification->source_addr_npi); + sprintf(debugBuf, "[Mandatory parameters]\nsource_addr_ton: 0x%x - %s, source_addr_npi: 0x%x - %s, source_addr: %s", + pAlertNotification->source_addr_ton, ton_str, + pAlertNotification->source_addr_npi, npi_str, + pAlertNotification->source_addr + ); + smpp_send_ascout(debugBuf); + smpp_ton_to_string(ton_str, pAlertNotification->esme_addr_ton); + smpp_npi_to_string(npi_str, pAlertNotification->esme_addr_npi); + sprintf(debugBuf, "esme_addr_ton: 0x%x - %s, esme_addr_npi: 0x%x - %s, esme_addr: %s\n", + pAlertNotification->esme_addr_ton, ton_str, + pAlertNotification->esme_addr_npi, npi_str, + pAlertNotification->esme_addr); + smpp_send_ascout(debugBuf); + } + #endif + + /* Optional parameter */ + if (current_len < command_length - 16) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + smpp_send_ascout("[Optional parameters]\n"); + } + #endif + + memset(opt_param, 0, sizeof(SMPP_OPTIONAL_PARAMETER) * SMPP_OPT_PARAM_NUM); + opt_num = smpp_decode_optional_parameter(opt_param, pMsg+current_len, command_length - current_len - 16); + for (i=0; ims_availability_status, &opt_param[i].value, opt_param[i].len); + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "ms_availability_status: 0x%02X\n", pAlertNotification->ms_availability_status); + smpp_send_ascout(debugBuf); + } + #endif + break; + default: + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, + "Optional parameter not allowed in ALERT_NOTIFICATION. tag=0x%02X", + opt_param[i].tag); + smpp_send_error(debugBuf); + } + #endif + return 0; + } + } + } + + current_len += 16; + if (current_len != command_length) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ALERT_NOTIFICATION: decode length = %d, command length=%ld\n", + linkNo, + current_len, + command_length); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVCMDLEN, 0); + return 0; + } + else if (current_len != len) + { + #ifdef SMPP_DEBUG + if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[linkNo] == 1)) + { + sprintf(debugBuf, "[smpp_decode_msg] link %d receive ALERT_NOTIFICATION: decode length = %d, message length=%d\n", + linkNo, + current_len, + len); + smpp_send_error(debugBuf); + } + #endif + smpp_sendGenericNack(linkNo, ESME_RINVMSGLEN, 0); + return 0; + } + + inter_head[linkNo] = (inter_head[linkNo]+1)&0x7; + interEvent[linkNo][inter_head[linkNo]] = AlertNotification; + break; + default: + smpp_sendGenericNack(linkNo, ESME_RINVCMDID, sequence_number); + break; + } + + #ifdef SMPP_PRINT_SCREEN +// printf("link %d interEvent[%d] = %d, exterEvent[%d] = %d\n", +// linkNo, +// inter_head[linkNo], +// interEvent[linkNo][inter_head[linkNo]], +// exter_head[linkNo], +// exterEvent[linkNo][inter_head[linkNo]]); + #endif //end ifdef SMPP_PRINT_SCREEN + + return 1; +} + +void smpp_sendBind(int linkNo, int event_id) +{ + SMPP_MSG smppMsg; + PDU_BIND *pBind; + + switch (event_id) + { + case BindTransmitter: + pBind = &smppMsg.pdu.bind_transmitter; + pBind->head.command_id = htonl(BIND_TRANSMITTER); + pBind->head.command_status = 0; + pBind->head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); + + memcpy(pBind->system_id, smpp_param[linkNo].sys_id, 16); + memcpy(pBind->password, smpp_param[linkNo].password, 9); + memcpy(pBind->system_type, smpp_param[linkNo].system_type, 13); + pBind->interface_version = 0x34; + pBind->addr_ton = 0x1; + pBind->addr_npi = 0x1; + memcpy(pBind->address_range,"888",sizeof(pBind->address_range)); +// printf("[smpp]link %d send bind transmitter.\n", linkNo); + break; + case BindReceiver: + pBind = &smppMsg.pdu.bind_receiver; + pBind->head.command_id = htonl(BIND_RECEIVER); + pBind->head.command_status = 0; + pBind->head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); + + memcpy(pBind->system_id, smpp_param[linkNo].sys_id, 16); + memcpy(pBind->password, smpp_param[linkNo].password, 9); + memcpy(pBind->system_type, smpp_param[linkNo].system_type, 13); + pBind->interface_version = 0x34; + pBind->addr_ton = 0x1; + pBind->addr_npi = 0x1; + memcpy(pBind->address_range,"888",sizeof(pBind->address_range)); +// printf("[smpp]link %d send bind receiver.\n", linkNo); + break; + case BindTransceiver: + pBind = &smppMsg.pdu.bind_transceiver; + pBind->head.command_id = htonl(BIND_TRANSCEIVER); + pBind->head.command_status = 0; + pBind->head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); + + memcpy(pBind->system_id, smpp_param[linkNo].sys_id, 16); + memcpy(pBind->password, smpp_param[linkNo].password, 9); + memcpy(pBind->system_type, smpp_param[linkNo].system_type, 13); + pBind->interface_version = 0x34; + pBind->addr_ton = 0x1; + pBind->addr_npi = 0x1; + memcpy(pBind->address_range,"888",sizeof(pBind->address_range)); +// printf("[smpp]link %d send bind transceiver.\n", linkNo); + break; + default: + return; + } + smpp_encode_msg(linkNo, &smppMsg, event_id); +} + +void smpp_sendBindResp(int linkNo, int event_id, DWORD command_status) +{ + SMPP_MSG smppMsg; + + switch (event_id) + { + case BindTransmitterResp: + smppMsg.pdu.bind_transmitter_resp.head.command_id = htonl(BIND_TRANSMITTER_RESP); + smppMsg.pdu.bind_transmitter_resp.head.command_status = htonl(command_status); + smppMsg.pdu.bind_transmitter_resp.head.sequence_number = htonl(smpp_link[linkNo].seq_num); + memcpy(smppMsg.pdu.bind_transmitter_resp.system_id, smpp_param[linkNo].sys_id, 16); + smppMsg.pdu.bind_transmitter_resp.sc_interface_version = SMPP_VERSION; +// printf("link %d send BindTransmitterResp.\n", linkNo); + break; + case BindReceiverResp: + smppMsg.pdu.bind_receiver_resp.head.command_id = htonl(BIND_RECEIVER_RESP); + smppMsg.pdu.bind_receiver_resp.head.command_status = htonl(command_status); + smppMsg.pdu.bind_receiver_resp.head.sequence_number = htonl(smpp_link[linkNo].seq_num); + memcpy(smppMsg.pdu.bind_receiver_resp.system_id, smpp_param[linkNo].sys_id, 16); + smppMsg.pdu.bind_transmitter_resp.sc_interface_version = SMPP_VERSION; +// printf("link %d send BindReceiverResp.\n", linkNo); + break; + case BindTransceiverResp: + smppMsg.pdu.bind_transceiver_resp.head.command_id = htonl(BIND_TRANSCEIVER_RESP); + smppMsg.pdu.bind_transceiver_resp.head.command_status = htonl(command_status); + smppMsg.pdu.bind_transceiver_resp.head.sequence_number = htonl(smpp_link[linkNo].seq_num); + memcpy(smppMsg.pdu.bind_transceiver_resp.system_id, smpp_param[linkNo].sys_id, 16); + smppMsg.pdu.bind_transmitter_resp.sc_interface_version = SMPP_VERSION; +// printf("link %d send BindTransceiverResp.\n", linkNo); + break; + default: +// printf("[ERROR]send bind resp. no such command id.(=%d)\n", event_id); + break; + } + smpp_encode_msg(linkNo, &smppMsg, event_id); +} + +void smpp_sendUnbind(int linkNo) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.unbind.head.command_length = htonl(sizeof(PDU_UNBIND)); + smppMsg.pdu.unbind.head.command_id = htonl(UNBIND); + smppMsg.pdu.unbind.head.command_status = 0; + smppMsg.pdu.unbind.head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); + + smpp_encode_msg(linkNo, &smppMsg, Unbind); +} + +void smpp_sendUnbindResp(int linkNo) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.unbind_resp.head.command_length = htonl(sizeof(PDU_UNBIND_RESP)); + smppMsg.pdu.unbind_resp.head.command_id = htonl(UNBIND_RESP); + smppMsg.pdu.unbind_resp.head.command_status = 0; + smppMsg.pdu.unbind_resp.head.sequence_number = htonl(smpp_link[linkNo].seq_num); + + smpp_encode_msg(linkNo, &smppMsg, UnbindResp); +} + +void smpp_sendEnquireLink(int linkNo) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.enquire_link.head.command_length = htonl(sizeof(PDU_ENQUIRE_LINK)); + smppMsg.pdu.enquire_link.head.command_id = htonl(ENQUIRE_LINK); + smppMsg.pdu.enquire_link.head.command_status = 0; + smppMsg.pdu.enquire_link.head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); +// printf("link %d send enquire link.\n", linkNo); + smpp_encode_msg(linkNo, &smppMsg, EnquireLink); +} + +void smpp_sendEnquireLinkResp(int linkNo) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.enquire_link_resp.head.command_length = htonl(sizeof(PDU_ENQUIRE_LINK_RESP)); + smppMsg.pdu.enquire_link_resp.head.command_id = htonl(ENQUIRE_LINK_RESP); + smppMsg.pdu.enquire_link_resp.head.command_status = htonl(ESME_ROK); + smppMsg.pdu.enquire_link_resp.head.sequence_number = htonl(smpp_link[linkNo].seq_num); + //printf("link %d send enquire link resp.\n", linkNo); + smpp_encode_msg(linkNo, &smppMsg, EnquireLinkResp); +} + +void smpp_sendOutbind(int linkNo) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.outbind.head.command_length = htonl(sizeof(PDU_OUTBIND)); + smppMsg.pdu.outbind.head.command_id = htonl(OUTBIND); + smppMsg.pdu.outbind.head.command_status = 0; + smppMsg.pdu.outbind.head.sequence_number = htonl(smpp_getSequenceNumber(linkNo)); + + strcpy(smppMsg.pdu.outbind.system_id,smpp_param[linkNo].sys_id); + memcpy(smppMsg.pdu.outbind.password,smpp_param[linkNo].password,sizeof(smppMsg.pdu.outbind.password)); + + //printf("link %d send OUTBIND.\n", linkNo); + smpp_encode_msg(linkNo, &smppMsg, Outbind); +} + +void smpp_sendGenericNack(int linkNo, DWORD command_status, DWORD sequence_number) +{ + SMPP_MSG smppMsg; + + smppMsg.pdu.generic_nack.head.command_length = htonl(sizeof(PDU_GENERIC_NACK)); + smppMsg.pdu.generic_nack.head.command_id = htonl(GENERIC_NAK); + smppMsg.pdu.generic_nack.head.command_status = htonl(command_status); + smppMsg.pdu.generic_nack.head.sequence_number = htonl(sequence_number); + + smpp_encode_msg(linkNo, &smppMsg, UnknownCommandID); +} + +void smpp_sendResponse(int linkNo, DWORD command_id, DWORD command_status, DWORD sequence_number) +{ + SMPP_MSG smppMsg; + + switch (command_id) + { + case SUBMIT_SM_RESP: + smppMsg.pdu.submit_sm_resp.head.command_length = htonl(16); + smppMsg.pdu.submit_sm_resp.head.command_id = htonl(SUBMIT_SM_RESP); + smppMsg.pdu.submit_sm_resp.head.command_status = htonl(command_status); + smppMsg.pdu.submit_sm_resp.head.sequence_number = htonl(sequence_number); + + smpp_encode_msg(linkNo, &smppMsg, SubmitSMResp); + break; + case DELIVER_SM_RESP: + smppMsg.pdu.deliver_sm_resp.head.command_length = htonl(16); + smppMsg.pdu.deliver_sm_resp.head.command_id = htonl(DELIVER_SM_RESP); + smppMsg.pdu.deliver_sm_resp.head.command_status = htonl(command_status); + smppMsg.pdu.deliver_sm_resp.head.sequence_number= htonl(sequence_number); + + smpp_encode_msg(linkNo, &smppMsg, DeliverSMResp); + break; + case DATA_SM_RESP: + smppMsg.pdu.data_sm_resp.head.command_length = htonl(16); + smppMsg.pdu.data_sm_resp.head.command_id = htonl(DATA_SM_RESP); + smppMsg.pdu.data_sm_resp.head.command_status = htonl(command_status); + smppMsg.pdu.data_sm_resp.head.sequence_number = htonl(sequence_number); + + smpp_encode_msg(linkNo, &smppMsg, DataSMResp); + break; + default: + break; + } +} diff --git a/omc/plat/smpp/ut/.copyarea.db b/omc/plat/smpp/ut/.copyarea.db new file mode 100644 index 0000000..b2d8b11 --- /dev/null +++ b/omc/plat/smpp/ut/.copyarea.db @@ -0,0 +1,7 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\ut +2 +3 +e:smpp_ussd_test|2|0|0|0|09d9714bbfa611dc866b001c23e19543|0 +4:conf|2|0|0|0|0ba9719fbfa611dc866b001c23e19543|0 +9:smpp_test|2|0|0|0|08a97113bfa611dc866b001c23e19543|0 diff --git a/omc/plat/smpp/ut/conf/.copyarea.db b/omc/plat/smpp/ut/conf/.copyarea.db new file mode 100644 index 0000000..3b2d639 --- /dev/null +++ b/omc/plat/smpp/ut/conf/.copyarea.db @@ -0,0 +1,14 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\ut\conf +2 +a +9:smpp.conf|1|127d64506c7|ca9|7a6043f8|0f397247bfa611dc866b001c23e19543|0 +9:menu_page|1|127d645032d|258|68f60b8|0ba971bbbfa611dc866b001c23e19543|0 +c:iptrans.conf|1|127d64509e4|1c2|f6956d3e|1bb9745bbfa611dc866b001c23e19543|0 +1b:.guess_number_test.conf.swp|1|127d645087c|11000|801a9722|1069727fbfa611dc866b001c23e19543|0 +9:mtp3.conf|1|127d6450511|17450|17f78bc5|0e09720fbfa611dc866b001c23e19543|0 +9:help_page|1|127d6450455|192|15015d77|0d6971f3bfa611dc866b001c23e19543|0 +16:guess_number_test.conf|1|127d64507a1|d|12da0283|0fc97263bfa611dc866b001c23e19543|0 +e:.smpp.conf.swp|1|127d64505ec|3000|db6a7a0a|0e99722bbfa611dc866b001c23e19543|0 +9:sccp.conf|1|127d645038a|330|6fa7b29c|0cd971d7bfa611dc866b001c23e19543|0 +9:MIB_files|2|0|0|0|1109729bbfa611dc866b001c23e19543|0 diff --git a/omc/plat/smpp/ut/conf/MIB_files/.copyarea.db b/omc/plat/smpp/ut/conf/MIB_files/.copyarea.db new file mode 100644 index 0000000..acde53b --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/.copyarea.db @@ -0,0 +1,19 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\ut\conf\MIB_files +2 +f +10:WXC2-MSS-MIB.txt|1|127d6450f53|52e|d7e257dd|1529735fbfa611dc866b001c23e19543|0 +11:mib_list_file.txt|1|127d6450e97|103|c80b4c14|14997343bfa611dc866b001c23e19543|0 +10:WXC2-PPS-MIB.txt|1|127d6451406|5f38c|7440987d|19f97407bfa611dc866b001c23e19543|0 +d:menu_tree.txt|1|127d645100e|812e|981faf7b|1659737bbfa611dc866b001c23e19543|0 +10:WXC2-MSC-MIB.txt|1|127d6450dcc|191c0|4c9942b2|13f97327bfa611dc866b001c23e19543|0 +10:WXC2-SS7-MIB.txt|1|127d6450cf1|16cb7|4d147c17|1369730bbfa611dc866b001c23e19543|0 +13:Special_App-SMI.txt|1|127d64511d4|3a4|cf48f6f3|178973b3bfa611dc866b001c23e19543|0 +9:menu_page|1|127d6450b7a|210|74ae5530|123972d3bfa611dc866b001c23e19543|0 +12:System_IP_List.txt|1|127d645159c|378|3a5de1c2|1b29743fbfa611dc866b001c23e19543|0 +10:WXC2-HLR-MIB.txt|1|127d645127f|caba|19ccf150|182973cfbfa611dc866b001c23e19543|0 +10:WXC2-AUC-MIB.txt|1|127d6450afd|274a|b7ed001d|119972b7bfa611dc866b001c23e19543|0 +b:IWV-SMI.txt|1|127d6450c36|40c|a1951d1d|12c972efbfa611dc866b001c23e19543|0 +11:WXC2-SMSC-MIB.txt|1|127d64514c2|16bf|1710a8e8|1a897423bfa611dc866b001c23e19543|0 +12:mib_write_tree.txt|1|127d6451118|9c3e4|7b54ced8|16f97397bfa611dc866b001c23e19543|0 +c:WXC2-SMI.txt|1|127d645133b|453|cda920a7|195973ebbfa611dc866b001c23e19543|0 diff --git a/omc/plat/smpp/ut/conf/MIB_files/IWV-SMI.txt b/omc/plat/smpp/ut/conf/MIB_files/IWV-SMI.txt new file mode 100644 index 0000000..f35678c --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/IWV-SMI.txt @@ -0,0 +1,40 @@ +-- ***************************************************************** +-- IWV-SMI: interWAVE Enterprise Structure of Management Information +-- +-- draft November 2000, Huang qilong +-- 1st November 2004, Sheng Xueqiang +-- +-- Copyright (c) 2000 by interWAVE, Inc. +-- All rights reserved. +-- +-- ***************************************************************** +-- + +IWV-SMI DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, + OBJECT-IDENTITY, + enterprises + FROM SNMPv2-SMI; + +IWV MODULE-IDENTITY + LAST-UPDATED "0411170000Z" + ORGANIZATION "interWAVE, Inc." + CONTACT-INFO + "http://www.iwv.com" + DESCRIPTION + "The Structure of Management Information for the interWAVE enterprise." + REVISION "200411170000Z" + DESCRIPTION + "1st version of this MIB module." + ::= { enterprises 1373 } -- assigned by IANA + + +IWV_Products OBJECT-IDENTITY + STATUS current + DESCRIPTION + "iwvProducts is the root OBJECT IDENTIFIER from which sysObjectID values are assigned. Actual values are defined in IWV-PRODUCTS-MIB." + ::= { IWV 1 } + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/Special_App-SMI.txt b/omc/plat/smpp/ut/conf/MIB_files/Special_App-SMI.txt new file mode 100644 index 0000000..36d2a55 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/Special_App-SMI.txt @@ -0,0 +1,43 @@ +-- ***************************************************************** +-- Special_App-SMI: WXC2 Structure of Management Information +-- +-- draft November 2004, Sheng Xueqiang +-- +-- Copyright (c) 2004 by interWAVE, Inc. +-- All rights reserved. +-- +-- ***************************************************************** +-- + +Special_App-SMI DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, + OBJECT-IDENTITY, + FROM SNMPv2-SMI + IWV_Products + FROM IWV-SMI; + +Special_App MODULE-IDENTITY + LAST-UPDATED "0411180000Z" + ORGANIZATION "interWAVE, Inc." + CONTACT-INFO + "http://www.iwv.com" + DESCRIPTION + "The Structure of Management Information for the Special Application of interWAVE enterprise." + REVISION "200411180000Z" + DESCRIPTION + "1st version of this MIB module." + ::= { IWV_Products 2 } + +-- CNF Center +-- IWF +IWF OBJECT-IDENTITY + STATUS current + DESCRIPTION + "IWF " + ::= { Special_App 8 } + +-- PPP Route + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/System_IP_List.txt b/omc/plat/smpp/ut/conf/MIB_files/System_IP_List.txt new file mode 100644 index 0000000..bd237ea --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/System_IP_List.txt @@ -0,0 +1,26 @@ +// host ip +// "//" is the annotation characters; ";" is the septation characters; +// Please put the localhost subsystem ip at the first of the group ip on one subsystem +MTP3_0_0 mss-0 ; LocalHost; +MTP3_1_0 mss-1 ; 172.18.133.1; +MTP3_2_0 -- ; 172.18.123.1; +MTP3_3_0 -- ; 172.18.143.1; +SCCP_0_0 mss-0 ; LOCALHOST; +SCCP_1_0 mss-1 ; 172.18.133.1; +XAPP_0_0 MSS-0 ; localhost; +XAPP_1_0 MSS-1 ; 172.18.133.1; +SMPP_0_0 SMPP-0; LocalHost; +MSC_0_0 -- ; LocalHost; +MSC_1_0 -- ; 172.18.133.1; +CCF(MSC)_0_0 --; LocalHost; +CCF(MSC)_0_1 --; 172.18.133.1; +VLR_0_0 VLR-0 ; LocalHost; +VLR_1_0 VLR-1 ; 172.18..1; +HLR_0_0 -- ; LocalHost; +HLR_1_0 -- ; 172.18.234.230; +AUC_0_0 -- ; LocalHost; +AUC_1_0 -- ; 172.18.234.230; +SMSC_0_0 -- ; LocalHost; +SMSC_1_0 -- ; 172.18.234.230; +PPS_0_0 -- ; LocalHost; +PPS_1_0 -- ; 172.18.234.230; diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-AUC-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-AUC-MIB.txt new file mode 100644 index 0000000..d9acb18 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-AUC-MIB.txt @@ -0,0 +1,437 @@ +alvr1188-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +AUC OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for AUC . + " + ::= { App 4 } + +Configuration OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Configuration for AUC . + " + ::= { AUC 2 } + +Public_parameter OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Public_parameter for AUC . + " + ::= { Configuration 1 } + + +SSD OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: [1]share SSD + { + [u]0.0-0.7 + [u]select + [v]0[opt]not share + [v]1[opt]share + } + + [2]Update SSD timer + { + [u]1.0-2.7 + [u]input + [v]toDec-high-0 + } + [3]reserved + { + [u]3.0-7.7 + [u]select + } + Remark: SSD + [End] + " + ::= { Public_parameter 2 } + +Count OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: [1]Count Match Range + { + [u]0.0-0.7 + [u]input + [v]toDec-high-0 + } + + [2]reserved + { + [u]1.0-7.7 + [u]select + } + Remark: Count. + [End] + " + ::= { Public_parameter 3 } + +Failures OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: + [1]AUTHR Mismatch + { + [u]0.0-0.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + [v]2[opt]Unique Challenge + } + + [2]Count Mismatch + { + [u]1.0-1.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + + [3]Unique Challenge Failure + { + [u]2.0-2.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + + [4]SSD Update Failure + { + [u]3.0-3.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + + [5]Count Update Failure + { + [u]4.0-4.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + + [6]Missing AUTH Parameters + { + [u]5.0-5.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + [v]2[opt]Unique Challenge + } + + [7]reserved + { + [u]6.0-7.7 + [u]select + } + + Remark: Count. + [End] + " + ::= { Public_parameter 4 } + +Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Management . + " + ::= { Configuration 2 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag: S1.2 + Field: [1]Save parameters to HD + { + [u]00.0-00.2 + [u]select + [v]00[opt]Idle + [v]01[opt]Save + [v]01[opt]Saving + [v]02[opt]Save succeeds + [v]03[opt]Save fails + } + [2]Save user data to HD&OMC + { + [u]00.3-00.5 + [u]select + [v]00[opt]Idle + [v]01[opt]Save + [v]01[opt]Saving + [v]02[opt]Save succeeds + [v]03[opt]Save fails + } + [3]Reserved + { + [u]00.6-00.7 + [u]select + } + Remark: Command for AUC paramters and user data operation, and the result of command. + [End] + " + ::= { Management 2 } + +License_Control OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: [1]Licenses + { + [u]00.0-15.7 + [u]input + [v]keepHex-high-0 + } + Remark: 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of AUC subscribers for service provider. The new license can not support less AUC subscribers than what the old license supports. + [End] + " + ::= { Management 3 } + +MAX_License OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Max Licenses + { + [u]0.0-3.7 + [u]input + [v]toDec-high-0 + } + Remark: The maximum quantity of approved AUC subscribers determined by License control Read only. + [End] + " + ::= { Management 11 } + +Used_License OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Used Licenses + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The quantity of currently registered EIR subscribers (Read only). + [End] + " + ::= { Management 12 } + +User_information OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + User Information . + " + ::= { Management 13 } + +Provisioned_Users OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 000000 + Field: [1]Provisioned users + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The quantity of service enabled AUC subscribers (Read only). + [End] + " + ::= { User_information 1 } + +Version OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Version . + " + ::= { Management 14 } + +Software OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]System + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Module + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Test + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: Version of AUC software (Read only). + System: System release version, based on basic function and structure. + Module: Software module version, based on software module. + Test: Test version, 0=Release version. 1=Test version. + [End] + " + ::= { Version 1 } + +User_data OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]System + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]User data + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Test + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: Version of AUC subscriber data (Read only). + System: System release version, based on basic function and structure. + User data: Subscriber profile version, based on software module. + Test: Test version, 0=Release version. 1=Test version. + [End] + " + ::= { Version 2 } + +IMSI_Segment OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1000 + Length: 4 + Default: 00000000 + Field: [1]IMSI segment + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: IMSI segment table (Read only): + 100,000 IMSIs are subdivided into 1000 segments, each IMSI segment use the 8 most significant digits (from the 6th digit to 13th digit of 15-digit of IMSI) as the segment number. + IMSI=MCC(3)+MNC(2)+MSIN(10) + Segment number=the 8 most significant digits of the MSIN, each segment has 100 subscribers (00-99). + e.g. If IMSI=460002356090098 then it belongs to IMSI segemt 23560900 and its account number in that segment=98. 0=empty segment. + [End] + " + ::= { Management 15 } + +Status OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Status for AUC . + " + ::= { AUC 3 } + +Import_status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 12 + Default: 000000000000000000000000 + Field: + Remark: Import status. + [End] + " + ::= { Status 2 } +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-HLR-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-HLR-MIB.txt new file mode 100644 index 0000000..37406d2 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-HLR-MIB.txt @@ -0,0 +1,2431 @@ +WXC2-HLR-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +HLR OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for HLR . + " + ::= { App 3 } + +Config OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Configuration for HLR . + " + ::= { HLR 2 } + +Public_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Public parameter . + " + ::= { Config 1 } + +HPLMN OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 17 + Default: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + Field: [1]CC + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + [2]NDC + { + [u]02.0-04.7 + [u]input + [v]keepHex-low-E + } + [3]Start SN + { + [u]05.0-10.7 + [u]input + [v]keepHex-low-E + } + [4]End SN + { + [u]11.0-16.7 + [u]input + [v]keepHex-low-E + } + Remark: Define the SN (VLR phone number) range of the VLR in the HPLMN (home PLMN) by specifying the start and end phone number of the range. + MSISDN=CC(country code)+NDC(National Destination Code)+SN. + All VLRs within a HPLMN have the same CC and NDC but the different SN. The SN of all VLR in a HPLMN must lie within the defined SN range. + Byte0-1=Country code. + Byte2-3=National destination code. + Byte4-9=Start SN of the VLR SN. + Byte10-15=End SN of the VLR SN. + e.g. For China country code=86, Shanghai national destination code=21, VLR SN=26060888: + Byte0-1=86EE, + Byte2-3=21EE, + SN=26060888, + Else=E. + [End] + " + ::= { Public_Param 11 } + +VPLMNs OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 17 + Default: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + Field: [1]CC + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + [2]NDC + { + [u]02.0-04.7 + [u]input + [v]keepHex-low-E + } + [3]Start SN + { + [u]05.0-10.7 + [u]input + [v]keepHex-low-E + } + [4]End SN + { + [u]11.0-16.7 + [u]input + [v]keepHex-low-E + } + Remark: Define all connected VPLMNs (up tp 256) by specifying all VLR zones included in these VPLMNs. Each VLR zone is defined by its VLR MSISDN. MSISDN=CC+NDC+SN. All VLRs within a same VPLMN have the CC and NDC but the different SN. A VPLMN contains a group of VLRs whose SN is included in the defined SN range, E=random digit. + This parameter also define two ranges of VLR CSRR (Country specific roaming restrictionszones) zones for each VPLMN. In these defined VLR CSRR zones all HPLMN subscribers may be subjected to country specific roaming restrictions. + For each VPLMN setup, the format is: + byte0=ISDN numbering plan, default=91. + byte1-2=country code, EEEE. + byte3-4=national destination code, EEEE. + byte5-10=start SN (SN prefix or whole SN) of VPLMNs, EEEEEEEEEEEE. + byte11-16=end SN (SN prefix or whole SN) of VPLMNs, EEEEEEEEEEEE. + byte17-22=start SN (SN prefix or whole SN) of range 0 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. + byte23-28=end SN (SN prefix or whole SN) of range 0 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. + byte29-34=start SN (SN prefix or whole SN) of range 1 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. + byte35-40=end SN (SN prefix or whole SN) of range 1 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. + E=random digit. + [End] + " + ::= { Public_Param 12 } + +CSRR_List OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 8 + Length: 32 + Default: 0000000000000000000000000000000000000000000000000000000000000000 + Field: [1]VPLMN0 Roaming allowed + { + [u]31.0-31.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [2]VPLMN1 Roaming allowed + { + [u]31.1-31.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [3]VPLMN2 Roaming allowed + { + [u]31.2-31.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [4]VPLMN3 Roaming allowed + { + [u]31.3-31.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [5]VPLMN4 Roaming allowed + { + [u]31.4-31.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [6]VPLMN5 Roaming allowed + { + [u]31.5-31.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [7]VPLMN6 Roaming allowed + { + [u]31.6-31.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [8]VPLMN7 Roaming allowed + { + [u]31.7-31.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [9]VPLMN8 Roaming allowed + { + [u]30.0-30.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [10]VPLMN9 Roaming allowed + { + [u]30.1-30.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [11]VPLMN10 Roaming allowed + { + [u]30.2-30.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [12]VPLMN11 Roaming allowed + { + [u]30.3-30.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [13]VPLMN12 Roaming allowed + { + [u]30.4-30.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [14]VPLMN13 Roaming allowed + { + [u]30.5-30.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [15]VPLMN14 Roaming allowed + { + [u]30.6-30.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [16]VPLMN15 Roaming allowed + { + [u]30.7-30.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [17]VPLMN16 Roaming allowed + { + [u]29.0-29.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [18]VPLMN17 Roaming allowed + { + [u]29.1-29.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [19]VPLMN18 Roaming allowed + { + [u]29.2-29.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [20]VPLMN19 Roaming allowed + { + [u]29.3-29.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [21]VPLMN20 Roaming allowed + { + [u]29.4-29.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [22]VPLMN21 Roaming allowed + { + [u]29.5-29.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [23]VPLMN22 Roaming allowed + { + [u]29.6-29.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [24]VPLMN23 Roaming allowed + { + [u]29.7-29.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [25]VPLMN24 Roaming allowed + { + [u]28.0-28.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [26]VPLMN25 Roaming allowed + { + [u]28.1-28.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [27]VPLMN26 Roaming allowed + { + [u]28.2-28.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [28]VPLMN27 Roaming allowed + { + [u]28.3-28.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [29]VPLMN28 Roaming allowed + { + [u]28.4-28.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [30]VPLMN29 Roaming allowed + { + [u]28.5-28.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [31]VPLMN30 Roaming allowed + { + [u]28.6-28.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [32]VPLMN31 Roaming allowed + { + [u]28.7-28.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [33]VPLMN32 Roaming allowed + { + [u]27.0-27.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [34]VPLMN33 Roaming allowed + { + [u]27.1-27.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [35]VPLMN34 Roaming allowed + { + [u]27.2-27.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [36]VPLMN35 Roaming allowed + { + [u]27.3-27.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [37]VPLMN36 Roaming allowed + { + [u]27.4-27.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [38]VPLMN37 Roaming allowed + { + [u]27.5-27.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [39]VPLMN38 Roaming allowed + { + [u]27.6-27.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [40]VPLMN39 Roaming allowed + { + [u]27.7-27.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [41]VPLMN40 Roaming allowed + { + [u]26.0-26.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [42]VPLMN41 Roaming allowed + { + [u]26.1-26.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [43]VPLMN42 Roaming allowed + { + [u]26.2-26.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [44]VPLMN43 Roaming allowed + { + [u]26.3-26.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [45]VPLMN44 Roaming allowed + { + [u]26.4-26.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [46]VPLMN45 Roaming allowed + { + [u]26.5-26.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [47]VPLMN46 Roaming allowed + { + [u]26.6-26.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [48]VPLMN47 Roaming allowed + { + [u]26.7-26.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [49]VPLMN48 Roaming allowed + { + [u]25.0-25.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [50]VPLMN49 Roaming allowed + { + [u]25.1-25.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [51]VPLMN50 Roaming allowed + { + [u]25.2-25.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [52]VPLMN51 Roaming allowed + { + [u]25.3-25.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [53]VPLMN52 Roaming allowed + { + [u]25.4-25.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [54]VPLMN53 Roaming allowed + { + [u]25.5-25.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [55]VPLMN54 Roaming allowed + { + [u]25.6-25.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [56]VPLMN55 Roaming allowed + { + [u]25.7-25.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [57]VPLMN56 Roaming allowed + { + [u]24.0-24.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [58]VPLMN57 Roaming allowed + { + [u]24.1-24.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [59]VPLMN58 Roaming allowed + { + [u]24.2-24.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [60]VPLMN59 Roaming allowed + { + [u]24.3-24.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [61]VPLMN60 Roaming allowed + { + [u]24.4-24.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [62]VPLMN61 Roaming allowed + { + [u]24.5-24.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [63]VPLMN62 Roaming allowed + { + [u]24.6-24.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [64]VPLMN63 Roaming allowed + { + [u]24.7-24.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [65]VPLMN64 Roaming allowed + { + [u]23.0-23.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [66]VPLMN65 Roaming allowed + { + [u]23.1-23.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [67]VPLMN66 Roaming allowed + { + [u]23.2-23.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [68]VPLMN67 Roaming allowed + { + [u]23.3-23.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [69]VPLMN68 Roaming allowed + { + [u]23.4-23.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [70]VPLMN69 Roaming allowed + { + [u]23.5-23.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [71]VPLMN70 Roaming allowed + { + [u]23.6-23.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [72]VPLMN71 Roaming allowed + { + [u]23.7-23.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [73]VPLMN72 Roaming allowed + { + [u]22.0-22.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [74]VPLMN73 Roaming allowed + { + [u]22.1-22.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [75]VPLMN74 Roaming allowed + { + [u]22.2-22.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [76]VPLMN75 Roaming allowed + { + [u]22.3-22.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [77]VPLMN76 Roaming allowed + { + [u]22.4-22.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [78]VPLMN77 Roaming allowed + { + [u]22.5-22.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [79]VPLMN78 Roaming allowed + { + [u]22.6-22.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [80]VPLMN79 Roaming allowed + { + [u]22.7-22.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [81]VPLMN80 Roaming allowed + { + [u]21.0-21.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [82]VPLMN81 Roaming allowed + { + [u]21.1-21.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [83]VPLMN82 Roaming allowed + { + [u]21.2-21.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [84]VPLMN83 Roaming allowed + { + [u]21.3-21.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [85]VPLMN84 Roaming allowed + { + [u]21.4-21.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [86]VPLMN85 Roaming allowed + { + [u]21.5-21.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [87]VPLMN86 Roaming allowed + { + [u]21.6-21.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [88]VPLMN87 Roaming allowed + { + [u]21.7-21.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [89]VPLMN88 Roaming allowed + { + [u]20.0-20.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [90]VPLMN89 Roaming allowed + { + [u]20.1-20.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [91]VPLMN90 Roaming allowed + { + [u]20.2-20.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [92]VPLMN91 Roaming allowed + { + [u]20.3-20.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [93]VPLMN92 Roaming allowed + { + [u]20.4-20.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [94]VPLMN93 Roaming allowed + { + [u]20.5-20.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [95]VPLMN94 Roaming allowed + { + [u]20.6-20.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [96]VPLMN95 Roaming allowed + { + [u]20.7-20.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [97]VPLMN96 Roaming allowed + { + [u]19.0-19.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [98]VPLMN97 Roaming allowed + { + [u]19.1-19.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [99]VPLMN98 Roaming allowed + { + [u]19.2-19.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [100]VPLMN99 Roaming allowed + { + [u]19.3-19.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [101]VPLMN100 Roaming allowed + { + [u]19.4-19.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [102]VPLMN101 Roaming allowed + { + [u]19.5-19.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [103]VPLMN102 Roaming allowed + { + [u]19.6-19.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [104]VPLMN103 Roaming allowed + { + [u]19.7-19.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [105]VPLMN104 Roaming allowed + { + [u]18.0-18.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [106]VPLMN105 Roaming allowed + { + [u]18.1-18.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [107]VPLMN106 Roaming allowed + { + [u]18.2-18.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [108]VPLMN107 Roaming allowed + { + [u]18.3-18.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [109]VPLMN108 Roaming allowed + { + [u]18.4-18.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [110]VPLMN109 Roaming allowed + { + [u]18.5-18.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [111]VPLMN110 Roaming allowed + { + [u]18.6-18.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [112]VPLMN111 Roaming allowed + { + [u]18.7-18.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [113]VPLMN112 Roaming allowed + { + [u]17.0-17.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [114]VPLMN113 Roaming allowed + { + [u]17.1-17.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [115]VPLMN114 Roaming allowed + { + [u]17.2-17.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [116]VPLMN115 Roaming allowed + { + [u]17.3-17.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [117]VPLMN116 Roaming allowed + { + [u]17.4-17.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [118]VPLMN117 Roaming allowed + { + [u]17.5-17.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [119]VPLMN118 Roaming allowed + { + [u]17.6-17.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [120]VPLMN119 Roaming allowed + { + [u]17.7-17.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [121]VPLMN120 Roaming allowed + { + [u]16.0-16.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [122]VPLMN121 Roaming allowed + { + [u]16.1-16.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [123]VPLMN122 Roaming allowed + { + [u]16.2-16.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [124]VPLMN123 Roaming allowed + { + [u]16.3-16.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [125]VPLMN124 Roaming allowed + { + [u]16.4-16.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [126]VPLMN125 Roaming allowed + { + [u]16.5-16.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [127]VPLMN126 Roaming allowed + { + [u]16.6-16.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [128]VPLMN127 Roaming allowed + { + [u]16.7-16.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [129]VPLMN128 Roaming allowed + { + [u]15.0-15.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [130]VPLMN129 Roaming allowed + { + [u]15.1-15.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [131]VPLMN130 Roaming allowed + { + [u]15.2-15.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [132]VPLMN131 Roaming allowed + { + [u]15.3-15.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [133]VPLMN132 Roaming allowed + { + [u]15.4-15.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [134]VPLMN133 Roaming allowed + { + [u]15.5-15.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [135]VPLMN134 Roaming allowed + { + [u]15.6-15.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [136]VPLMN135 Roaming allowed + { + [u]15.7-15.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [137]VPLMN136 Roaming allowed + { + [u]14.0-14.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [138]VPLMN137 Roaming allowed + { + [u]14.1-14.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [139]VPLMN138 Roaming allowed + { + [u]14.2-14.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [140]VPLMN139 Roaming allowed + { + [u]14.3-14.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [141]VPLMN140 Roaming allowed + { + [u]14.4-14.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [142]VPLMN141 Roaming allowed + { + [u]14.5-14.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [143]VPLMN142 Roaming allowed + { + [u]14.6-14.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [144]VPLMN143 Roaming allowed + { + [u]14.7-14.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [145]VPLMN144 Roaming allowed + { + [u]13.0-13.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [146]VPLMN145 Roaming allowed + { + [u]13.1-13.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [147]VPLMN146 Roaming allowed + { + [u]13.2-13.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [148]VPLMN147 Roaming allowed + { + [u]13.3-13.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [149]VPLMN148 Roaming allowed + { + [u]13.4-13.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [150]VPLMN149 Roaming allowed + { + [u]13.5-13.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [151]VPLMN150 Roaming allowed + { + [u]13.6-13.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [152]VPLMN151 Roaming allowed + { + [u]13.7-13.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [153]VPLMN152 Roaming allowed + { + [u]12.0-12.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [154]VPLMN153 Roaming allowed + { + [u]12.1-12.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [155]VPLMN154 Roaming allowed + { + [u]12.2-12.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [156]VPLMN155 Roaming allowed + { + [u]12.3-12.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [157]VPLMN156 Roaming allowed + { + [u]12.4-12.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [158]VPLMN157 Roaming allowed + { + [u]12.5-12.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [159]VPLMN158 Roaming allowed + { + [u]12.6-12.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [160]VPLMN159 Roaming allowed + { + [u]12.7-12.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [161]VPLMN160 Roaming allowed + { + [u]11.0-11.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [162]VPLMN161 Roaming allowed + { + [u]11.1-11.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [163]VPLMN162 Roaming allowed + { + [u]11.2-11.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [164]VPLMN163 Roaming allowed + { + [u]11.3-11.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [165]VPLMN164 Roaming allowed + { + [u]11.4-11.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [166]VPLMN165 Roaming allowed + { + [u]11.5-11.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [167]VPLMN166 Roaming allowed + { + [u]11.6-11.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [168]VPLMN167 Roaming allowed + { + [u]11.7-11.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [169]VPLMN168 Roaming allowed + { + [u]10.0-10.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [170]VPLMN169 Roaming allowed + { + [u]10.1-10.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [171]VPLMN170 Roaming allowed + { + [u]10.2-10.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [172]VPLMN171 Roaming allowed + { + [u]10.3-10.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [173]VPLMN172 Roaming allowed + { + [u]10.4-10.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [174]VPLMN173 Roaming allowed + { + [u]10.5-10.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [175]VPLMN174 Roaming allowed + { + [u]10.6-10.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [176]VPLMN175 Roaming allowed + { + [u]10.7-10.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [177]VPLMN176 Roaming allowed + { + [u]09.0-09.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [178]VPLMN177 Roaming allowed + { + [u]09.1-09.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [179]VPLMN178 Roaming allowed + { + [u]09.2-09.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [180]VPLMN179 Roaming allowed + { + [u]09.3-09.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [181]VPLMN180 Roaming allowed + { + [u]09.4-09.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [182]VPLMN181 Roaming allowed + { + [u]09.5-09.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [183]VPLMN182 Roaming allowed + { + [u]09.6-09.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [184]VPLMN183 Roaming allowed + { + [u]09.7-09.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [185]VPLMN184 Roaming allowed] + { + [u]08.0-08.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [186]VPLMN185 Roaming allowed + { + [u]08.1-08.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [187]VPLMN186 Roaming allowed + { + [u]08.2-08.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [188]VPLMN187 Roaming allowed + { + [u]08.3-08.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [189]VPLMN188 Roaming allowed + { + [u]08.4-08.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [190]VPLMN189 Roaming allowed + { + [u]08.5-08.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [191]VPLMN190 Roaming allowed + { + [u]08.6-08.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [192]VPLMN191 Roaming allowed + { + [u]08.7-08.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [193]VPLMN192 Roaming allowed + { + [u]07.0-07.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [194]VPLMN193 Roaming allowed + { + [u]07.1-07.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [195]VPLMN194 Roaming allowed + { + [u]07.2-07.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [196]VPLMN195 Roaming allowed + { + [u]07.3-07.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [197]VPLMN196 Roaming allowed + { + [u]07.4-07.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [198]VPLMN197 Roaming allowed + { + [u]07.5-07.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [199]VPLMN198 Roaming allowed + { + [u]07.6-07.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [200]VPLMN199 Roaming allowed + { + [u]07.7-07.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [201]VPLMN200 Roaming allowed + { + [u]06.0-06.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [202]VPLMN201 Roaming allowed + { + [u]06.1-06.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [203]VPLMN202 Roaming allowed + { + [u]06.2-06.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [204]VPLMN203 Roaming allowed + { + [u]06.3-06.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [205]VPLMN204 Roaming allowed + { + [u]06.4-06.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [206]VPLMN205 Roaming allowed + { + [u]06.5-06.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [207]VPLMN206 Roaming allowed + { + [u]06.6-06.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [208]VPLMN207 Roaming allowed + { + [u]06.7-06.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [209]VPLMN208 Roaming allowed + { + [u]05.0-05.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [210]VPLMN209 Roaming allowed + { + [u]05.1-05.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [211]VPLMN210 Roaming allowed + { + [u]05.2-05.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [212]VPLMN211 Roaming allowed + { + [u]05.3-05.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [213]VPLMN212 Roaming allowed + { + [u]05.4-05.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [214]VPLMN213 Roaming allowed + { + [u]05.5-05.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [215]VPLMN214 Roaming allowed + { + [u]05.6-05.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [216]VPLMN215 Roaming allowed + { + [u]05.7-05.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [217]VPLMN216 Roaming allowed + { + [u]04.0-04.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [218]VPLMN217 Roaming allowed + { + [u]04.1-04.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [219]VPLMN218 Roaming allowed + { + [u]04.2-04.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [220]VPLMN219 Roaming allowed + { + [u]04.3-04.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [221]VPLMN220 Roaming allowed + { + [u]04.4-04.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [222]VPLMN221 Roaming allowed + { + [u]04.5-04.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [223]VPLMN222 Roaming allowed + { + [u]04.6-04.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [224]VPLMN223 Roaming allowed + { + [u]04.7-04.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [225]VPLMN224 Roaming allowed + { + [u]03.0-03.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [226]VPLMN225 Roaming allowed + { + [u]03.1-03.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [227]VPLMN226 Roaming allowed + { + [u]03.2-03.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [228]VPLMN227 Roaming allowed + { + [u]03.3-03.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [229]VPLMN228 Roaming allowed + { + [u]03.4-03.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [230]VPLMN229 Roaming allowed + { + [u]03.5-03.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [231]VPLMN230 Roaming allowed + { + [u]03.6-03.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [232]VPLMN231 Roaming allowed + { + [u]03.7-03.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [233]VPLMN232 Roaming allowed + { + [u]02.0-02.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [234]VPLMN233 Roaming allowed + { + [u]02.1-02.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [235]VPLMN234 Roaming allowed + { + [u]02.2-02.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [236]VPLMN235 Roaming allowed + { + [u]02.3-02.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [237]VPLMN236 Roaming allowed + { + [u]02.4-02.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [238]VPLMN237 Roaming allowed + { + [u]02.5-02.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [239]VPLMN238 Roaming allowed + { + [u]02.6-02.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [240]VPLMN239 Roaming allowed + { + [u]02.7-02.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [241]VPLMN240 Roaming allowed + { + [u]01.0-01.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [242]VPLMN241 Roaming allowed + { + [u]01.1-01.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [243]VPLMN242 Roaming allowed + { + [u]01.2-01.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [244]VPLMN243 Roaming allowed + { + [u]01.3-01.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [245]VPLMN244 Roaming allowed + { + [u]01.4-01.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [246]VPLMN245 Roaming allowed + { + [u]01.5-01.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [247]VPLMN246 Roaming allowed + { + [u]01.6-01.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [248]VPLMN247 Roaming allowed + { + [u]01.7-01.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [249]VPLMN248 Roaming allowed + { + [u]00.0-00.0 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [250]VPLMN249 Roaming allowed + { + [u]00.1-00.1 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [251]VPLMN250 Roaming allowed + { + [u]00.2-00.2 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [252]VPLMN251 Roaming allowed + { + [u]00.3-00.3 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [253]VPLMN252 Roaming allowed + { + [u]00.4-00.4 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [254]VPLMN253 Roaming allowed + { + [u]00.5-00.5 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [255]VPLMN254 Roaming allowed + { + [u]00.6-00.6 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + [256]VPLMN255 Roaming allowed + { + [u]00.7-00.7 + [u]select + [v]00[opt]Not allowed + [v]01[opt]Allowed + } + Remark: Define 8 CSRR (country specific roaming restriction) lists to confine the roaming range of a subscriber. + Each CSRR list defines the roaming restriction for 256 VPLMN ranges. + [End] + " + ::= { Public_Param 13 } + +Regional_Subs_List OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 255 + Length: 7 + Default: EEEEEEEEEEEEEE + Field: [1]Country Code + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + [2]National Destination Code + { + [u]02.0-04.7 + [u]input + [v]keepHex-low-E + } + [3]Zone Code + { + [u]05.0-06.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the regional subscription zone code list. HLR supports up to 256 regional subscription zone code. + Regional subscription code = CC+NDC+zone code + [End] + " + ::= { Public_Param 14 } + +Licenses_Control OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: [1]Licenses + { + [u]00.0-07.7 + [u]input + [v]keepHex-high-0 + } + Remark: 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of HLR subscribers for service provider: + The new license can not support less HLR subscribers than what the old license supports. + [End] + " + ::= { Public_Param 15 } + +CDR_Control OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]CDR control + { + [u]00.0-00.7 + [u]select + [v]00[opt]Off + [v]01[opt]On + } + Remark: HLR CDR generation flag: + Off=Not generate HLR CDR. + On=Generate HLR CDR. + [End] + " + ::= { Public_Param 16 } + +Feature_Code OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 64 + Default: 90EE68EE72EE92EE70EE000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Field: [1]CFB + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + [2]CFD + { + [u]02.0-03.7 + [u]input + [v]keepHex-low-E + } + [3]CFNA + { + [u]04.0-05.7 + [u]input + [v]keepHex-low-E + } + [4]CFU + { + [u]06.0-07.7 + [u]input + [v]keepHex-low-E + } + [5]Call waiting + { + [u]08.0-09.7 + [u]input + [v]keepHex-low-E + } + [6]Reserved + { + [u]10.0-63.7 + [u]select + } + Remark: None. + [End] + " + ::= { Public_Param 27 } + + +Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Management . + " + ::= { Config 2 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag: S1.2 + Field: [1]Save parameter to HD + { + [u]00.0-00.2 + [u]select + [v]00[opt]Idle + [v]01[opt]Save + } + [2]Save subscriber data to HD&OMC + { + [u]00.3-00.5 + [u]select + [v]00[opt]Idle + [v]01[opt]Save + } + [3]Reserved + { + [u]00.6-00.7 + [u]select + } + Remark: Bit0-2: HLR paramter save control: + Idle=no operation. + Save=Save parameters from HLR memory to HLR hard disk. + Bit3-5: HLR subscriber data save control: + Idle=no operation. + Save=Save HLR subscriber data from HLR memory to both HLR hard disk and OMC database. + Bit6-7: Reserved. + [End] + " + ::= { Management 2 } + +Subscriber_Import OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 7 + Default: 00000000000000 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]0[opt]No operation + [v]1[opt]Send command + [v]2[opt]Begin loading + [v]3[opt]Loading OK + [v]4[opt]Loading Failed + } + [2]Total subscriber requested + { + [u]01.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]Total imported subscribers + { + [u]04.0-06.7 + [u]input + [v]toDec-high-0 + } + Remark: Progress and result of HLR subscriber import. + Byte0: Progress of HLR subscriber import. + Byte1-3: Total quantity of HLR subscribers requesting import. + Byte4-7: Quantity of successfully imported HLR subscribers. + [End] + " + ::= { Management 3 } + +Max_Licenses OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Max Licenses + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The maximum quantity of approved HLR subscribers determined by License control (Read Only). + [End] + " + ::= { Management 11 } + +Used_Licenses OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Used Licenses + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The quantity of currently registered HLR subscribers (Read Only). + [End] + " + ::= { Management 12 } + +Subscriber_Info OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Subscriber information . + " + ::= { Management 13 } + +Provisioned_Subs OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Provisioned Subs + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The quantity of service provisioned and active HLR subscribers (Read Only). + [End] + " + ::= { Subscriber_Info 1 } + +Registered_Subs OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Registered Subs + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: The quantity of registered (both active and inactive) HLR subscribers (Read Only). + [End] + " + ::= { Subscriber_Info 2 } + +Roaming_Subs OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00000000 + Field: [1]Roaming Subs + { + [u]00.0-03.7[u]input + [v]toDec-high-0 + } + Remark: The quantity of provisioned HLR subscribers currently roaming to VPLMNs (Read Only). + [End] + " + ::= { Subscriber_Info 3 } + +Version OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Version . + " + ::= { Management 14 } + +Software OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Release + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Version + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Slice + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: Version of HLR software (Read Only): + Byte0: System release version number: + - Based on basic function and structure. + Byte1: Software module version number: + - Based on software module. + Byte2: Test version: + - 0=Release version number. + - 1=Test version number. + [End] + " + ::= { Version 1 } + +User_Data OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Release + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Version + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Slice + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: Version of AUC subscriber data (Read Only): + System release version: Based on basic function and structure. + Subscriber data version: Based on software module. + Test version: 0=Release version 1=Test version + [End] + " + ::= { Version 2 } + +IMSI_Segment OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1000 + Length: 4 + Default: 00000000 + Field: [1]IMSI segment + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: MSISDN segment table (Read Only): + Use SN of MSISDN (MSISDN=CC+NDC+SN) excluding the last three digits to divide the MSISDN into 200 segments. + [End] + " + ::= { Management 15 } + +MSISDN_Segment OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1000 + Length: 4 + Default: 00000000 + Field: [1]MSISDN segment + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: MSISDN segment table (Read Only): + Use SN of MSISDN (MSISDN=CC+NDC+SN) excluding the last three digits to divide the MSISDN into 200 segments. + [End] + " + ::= { Management 16 } + +CNF_Applicant_Info OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 9 + Default: 000000000000000000 + Field: [1]Charge Type + { + [u]00.0-00.7 + [u]select + [v]00[opt]Invalid user + [v]01[opt]Post-pay user + [v]02[opt]Prepaid user + } + [2]IMSI + { + [u]01.0-08.7 + [u]input + [v]keepHex-low-E + } + Remark: Display the IMSI and charge type of the latest conference applicant (Read Only). + [End] + " + ::= { Management 27 } +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSC-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSC-MIB.txt new file mode 100644 index 0000000..785f78d --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSC-MIB.txt @@ -0,0 +1,4084 @@ +WXC2-MSC-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +MSC OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Subsystems for msc . + " + ::= { App 2 } +-- +-- sub system CCF(MSC) +-- + +CCF(MSC) OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for msc . + " + ::= { MSC 2 } + +CCF_Config OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Configuration for CCF . + " + ::= { CCF(MSC) 2 } + +-- +-- CCF -> Configuration -> Call Routing +-- + +Call_Routing OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Call Routing . + " + ::= { CCF_Config 1 } + +Prefix_Assignment OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 8 + Default : EEEEEEEEEEEEEEEE + Field : [1]Prefix + { + [u]0.0-7.7 + [u]input + [v]keepHex-low-E + } + Remark: 4 bytes are used to set a 8-digit prefix for dialed number. + Prefix is the first layer for dialed number based call routing. If the dialed number of a call matches a pre-programmed prefix in this table, this call will be routed to a certain trunk group, subsequently that trunk group will route this call via a dedicated E1 port.This system has totally 256 prefixes. + Dialed number without matching a pre-programmed prefix will be routed to the default trunk group 0. + Prefix 252 is for default international call, all internation calls unable to be routed out will be routed from the trunk group assigned to prefix 252, keep default EEEEEEEE. + Prefix 253 is for default national call, all national calls unable to be routed out will be routed from the trunk group assigned to prefix 253, keep default EEEEEEEE. + Prefix 254 is for default subscriber call, all dialed MSISDN unable to be routed out will be routed from the trunk group assigned to prefix 254, keep default EEEEEEEE. + Prefix 255 is for unknown call, all unknown calls unable to be routed out will be routed from the trunk group assigned to prefix 255, keep default EEEEEEEE. + E=End tag, C='#', B='*'. + Default=0xEEEEEEEE. + [End] + " + ::= { Call_Routing 1 } + +Prefix_Attributes OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 18 + Default : 2200EEEEEEEEEEEEEEEE010800EEEEEEEE03 + Flag : E10 + Field : [1]TON incoming call + { + [u]0.0-0.3 + [u]select + [v]0[opt]Spare + [v]1[opt]MSISDN + [v]2[opt]Unkown + [v]3[opt]NDD + [v]4[opt]IDD + [v]5[opt]Spare + } + [2]TON outgoing call + { + [u]0.4-0.7 + [u]select + [v]0[opt]Spare + [v]1[opt]MSISDN + [v]2[opt]Unkown + [v]3[opt]NDD + [v]4[opt]IDD + [v]5[opt]Spare + } + [3]Out trunk deletion count + { + [u]1.0-1.3 + [u]select + [v]0[opt]Delete none + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + [4]Out trunk insertion count + { + [u]1.4-1.7 + [u]select + [v]0[opt]Insert none + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + [5]Out trunk inserted digits + { + [u]2.0-9.7 + [u]input + [v]keepHex-low-E + } + [6]CDR on/off + { + [u]10.0-10.0 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [7]Reserved + { + [u]10.1-10.1 + [u]select + } + [8]Properties + { + [u]10.2-10.3 + [u]select + [v]0[opt]Trunk + [v]1[opt]MSISDN + [v]2[opt]MSRN + [v]3[opt]MSC + } + [9]Call type + { + [u]10.4-10.6 + [u]select + [v]0[opt]Normal Call + [v]1[opt]Emergency + [v]2[opt]MCT + [v]3[opt]VMS + [v]4[opt]IN + } + [10]Enable + { + [u]10.7-10.7 + [u]select + [v]0[opt]N + [v]1[opt]Y + } + [11]Length of dialed number + { + [u]11.0-11.7 + [u]input + [v]toDec-high-0 + } + [12]E.164 International deletion count + { + [u]12.0-12.3 + [u]select + [v]0[opt]Delete none + [v]1[opt]Delete first one + [v]2[opt]Delete first two + [v]3[opt]Delete first three + [v]4[opt]Delete first four + [v]5[opt]Delete first five + [v]6[opt]Delete first six + [v]7[opt]Delete first seven + [v]8[opt]Delete first eight + } + [13]E.164 International insertion count + { + [u]12.4-12.7 + [u]select + [v]0[opt]Insert none + [v]1[opt]Insert first one + [v]2[opt]Insert first two + [v]3[opt]Insert first three + [v]4[opt]Insert first four + [v]5[opt]Insert first five + [v]6[opt]Insert first six + [v]7[opt]Insert first seven + [v]8[opt]Insert first eight + } + [14]E.164 international inserted digits + { + [u]13.0-16.7 + [u]input + [v]keepHex-low-E + } + [15]Cli-type + { + [u]17.0-17.7 + [u]select + [v]0[opt]Sub + [v]1[opt]NDD + [v]2[opt]IDD + [v]3[opt]Unknown(local) + [v]4[opt]Unknown(NDD) + [v]5[opt]Unknown(IDD) + } + Remark: Enable: Y=prefix enable, N=prefix disable. + TON incoming call: Type of number for incoming call, include unknown, MSISDN, NDD and IDD. It is specified by originating node for terminating node to route this call with proper dialed number manipulation. + For system subscriber dialed prefix, always use unknown for In-TON except the prefix of international prefix beginning with a . For this kind of prefix (such as 86755832) we should set the In-TON as IDD to support dialing. + TON outgoing call: Type of number for outgoing call, include unknown, MSISDN, NDD and IDD. It specifies the type of an outgoing call for terminating node to route this call with proper dialed number manipulation. Generally the MSC uses IDD for outgoing call. + Out trunk deletion count: Quantity of deleted digit of a dialed number beginning with this prefix. It ranges from 0 to 8. 0=no deletion, 1-8=delete first 1-8 digits. + Out trunk insertion count: Quantity of inserted digit for a dialed number beginning with this prefix. It ranges from 0 to 8. 0=no insertion, 1-8=insert 1-8 digits from the beginning of this number. + Out trunk inserted digits: 8 digits ranging from EEEEEEEE to 99999999, E=any decimal number. + CDR on/off: Turn on/off the CDR of dialed numbers beginning with this prefix. + Properties: Specify the properties of a prefix. Trunk=to PSTN, MSISDN=to A interface, MSRN=MS roaming number, MSC=to peer MSC. + Call type: Normal=no verification for MT, Emergency call=no verification for MO (free call), MCT=Malicious Call Trace, VMS call=send signaling carried DTMF to VMS. + Length of dialed number: Length of dialed number (1-32). + E.164 international deletion count: Quantity of deleted digit of E164 international number, always use IDD for outgoing call for PPS debiting. + E.164 international insertion count: Quantity of inserted digit of E164 international number, always use IDD for outgoing call for PPS debiting. + E.164 international inserted digits: Inserted digit to the E164 international number, 8 digits ranging from EEEEEEEE to 99999999, E=any decimal number, always use IDD for outgoing call for PPS debiting. + [End] + " + ::= { Call_Routing 2 } + +Prefix_TG OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field: + [1]Assign TG to prefix + { + [u]0.0-0.7 + [u]input + [v]toDec-high-0 + } + Remark: Assign a trunk group for each prefix for call routing, a single prefix points to only one trunk group, multiple prefix can be assigned the same trunk group, default is the no. of the prefix. + [End] + " + ::= { Call_Routing 3 } + +TG_Attributes OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 10 + Default : 00000000000000000000000000 + Flag : E2 + Field: [1]DPC + { + [u]0.0-3.7 + [u]input + [v]keepHex-high-0 + } + [2]TG flag + { + [u]4.0-4.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]CDR on/off + { + [u]4.1-4.1 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [4]Announcement + { + [u]4.2-4.2 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [5]TG category + { + [u]4.3-4.5 + [u]select + [v]0[opt]PSTN + [v]1[opt]HPLMN + [v]2[opt]VHLMN + [v]3[opt]SUB + [v]4[opt]IP + [v]5[opt]Intercept + } + [6]Alternative TG flag + { + [u]4.6-4.6 + [u]select + [v]0[opt]Disable + [v]1[opt]enable + } + [7]Loopback + { + [u]4.7-4.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [8]Network indicator + { + [u]5.0-5.7 + [u]select + [v]0[opt]International + [v]1[opt]International spare + [v]2[opt]National + [v]3[opt]National spare + } + [9]Circuit selection + { + [u]6.0-6.1 + [u]select + [v]0[opt]Clockwise + [v]1[opt]Anti-clockwise + [v]2[opt]Odd + [v]3[opt]Even + } + [10]Back off + { + [u]6.2-6.2 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [11]Reserved + { + [u]6.3-6.4 + [u]select + } + [12]MPTY + { + [u]6.5-6.5 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [13]Location + { + [u]6.6-6.7 + [u]select + [v]0[opt]MSC-0 + [v]1[opt]MSC-1 + [v]2[opt]Both + [v]3[opt]Spare + } + [14]Alternative TG + { + [u]7.0-7.7 + [u]input + [v]toDec-high-0 + } + [15]Tandem restriction + { + [u]8.0-8.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [16]Incoming Call type + { + [u]9.0-9.7 + [u]select + [v]0[opt]Normal + [v]1[opt]IN + } + Remark: DPC: Destination point code of this trunk group. + TG flag: enable or disable this trunk group. + CDR on/off: CDR on or off option for this trunk group. + Announcement: Voice announcement enable or disable for this trunk group. + TG category: PSTN=to PSTN, IP=to VMS and VPS, HPLMN=to HPLMN, VPLMN=to VPLMN, SUB=to BSC, Intercept=to intercept LEA + Alternative TG flag: Alternative trunk group enable or disable option. + Alternative TG: Alternative trunk group for backup purpose. + Loop back: Incoming call loop back enable or disable, used for MSC loop back. + Network indicator: Specify network type, International, International spare , National, National spare. + Circuit selection: Preferred circuit selection mode, include clockwise, anti-clockwise, odd and even. + Back off: Back off on or off when simultaneously select the same channel with the opposite side. + Location: For normal trunk group, select Both. For a trunk group to a VPS, configure this trunk group as MSC0 or MSC1. + MPTY: Multi-party call enable or disable. For all trunk groups to BSC, select Enable. + Tandem restriction:Y: Tandem disabled. Not support transit call from PSTN to PSTN via this trunk group. + N: Tandem enabled. Support transit call from PSTN to PSTN via this trunk group. + [End] + " + ::= { Call_Routing 4 } + +Call_Routing_CDR_Flag OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 2 + Default : 03FF + Field : [1]Reserved + { + [u]0.3-0.7 + [u]select + } + [2]Redirection + { + [u]0.3-0.3 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [3]Feature Request + { + [u]0.2-0.2 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [4]Sorm + { + [u]0.1-0.1 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [5]MCT + { + [u]0.0-0.0 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [6]MT SM + { + [u]1.7-1.7 + [u]select + [v]0[opt]off + [v]1[opt]on + + } + [7]MO SM + { + [u]1.6-1.6 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [8]Transit call + { + [u]1.5-1.5 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [9]Gateway outgoing call + { + [u]1.4-1.4 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [10]Gateway incoming call + { + [u]1.3-1.3 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [11]Roaming call + { + [u]1.2-1.2 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [12]MT call + { + [u]1.1-1.1 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [13]MO call + { + [u]1.0-1.0 + [u]select + [v]0[opt]off + [v]1[opt]on + } + Remark: Sorm: call intercept MCT: malicious call trace + Default=CDR of MO call and MT call is enabled, CDR of roaming call, gateway incoming call, gateway outgoing call, transit call, MO SMS and MT SMS is disabled. + [End] + " + ::= { Call_Routing 5 } + +Voice_Prompt_Announcement_option OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance : 1 + Length : 16 + Default : 00000000000000000000000000000000 + Field : [1]Announcement 0 + { + [u]0.0-0.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [2]Announcement 1 + { + [u]1.0-1.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [3]Announcement 2 + { + [u]2.0-2.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + + [4]Announcement 3 + { + [u]3.0-3.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + + + [5]Announcement 4 + { + [u]4.0-4.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + + [6]Announcement 5 + { + [u]5.0-5.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + + [7]Announcement 6 + { + [u]6.0-6.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + [8]Announcement 7 + { + [u]7.0-7.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + + [9]Announcement 8 + { + [u]8.0-8.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + [10]Announcement 9 + { + [u]9.0-9.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [11]Announcement 10 + { + [u]10.0-10.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [12]Announcement 11 + { + [u]11.0-11.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + + [13]Announcement 12 + { + [u]12.0-12.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [14]Announcement 13 + { + [u]13.0-13.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [15]Announcement 14 + { + [u]14.0-14.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + [16]Announcement 15 + { + [u]15.0-15.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + Remark : Set to play either announcement or tone indicating call unattainable reason for subscribers. System has total 8 announcements and tones that can be independently set. + Announcement 0: The dialed number is invalid. + Announcement 1: The subscriber dialed is not activated. + Announcement 2: The subscriber is busy. + Announcement 3: The network is busy. + Announcement 4: Caller's account was deactivated. + Announcement 5: The subscriber dialed was deactivated. + Announcement 6: Feature not available to caller. + Announcement 7: The subscriber dialed is not available. + [End] + " + ::= { Call_Routing 6 } + +Call_Routing_Warning OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 32 + Field : [1]Remanent time for warning tone + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark :Set time to play prompt tone for reaching zero balance prepaid subscriber when a call is in progress, unit is second. e.g. if set as 60, the system will play prompt tone one minute before a subscriber uses up his balance. + [End] + " + ::= { Call_Routing 7 } + + + +-- +-- CCF -> Configuration -> MSC +-- + + +CCF_MSC OBJECT-IDENTITY + STATUS current + DESCRIPTION + "CCF Configuration MSC ." + ::= { CCF_Config 2 } + +Emergency_Call OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 21 + Default : 0000000000EEEEEEEEEEEEEEEE112EEEEEEEEEEEEE + Flag : E1 + Field : [1]Enable flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]LAC + { + [u]01.0-02.7 + [u]input + [v]toDec-high-0 + } + [3]CI + { + [u]03.0-04.7 + [u]input + [v]toDec-high-0 + } + [4]Dial number + { + [u]05.0-12.7 + [u]input + [v]keepHex-low-E + } + [5]Local emergency number + { + [u]13.0-20.7 + [u]input + [v]keepHex-low-E + } + Remark: Emergency call number. Default=112. + [End] + " + ::= { CCF_MSC 5 } + +Location_Management OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 8 + Default : 0000000000000000 + Flag : E1 + Field : [1]Enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]N + [v]1[opt]Y + } + [2]TG + { + [u]01.0-01.7 + [u]input + [v]toDec-high-0 + } + [3]LAC + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [4]CI + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + [5]Zone Code + { + [u]06.0-07.7 + [u]input + [v]toDec-high-0 + } + Remark :Manage the MS location by correlate TG (trunk group), LAC (location area code, cell ID and zone code, totally 256 location management. + [End] + " + ::= { CCF_MSC 8 } + + + +-- +-- CCF -> Configuration -> CPC Management +-- + + +CPC OBJECT-IDENTITY + STATUS current + DESCRIPTION + "CPC Management." + ::= { CCF_Config 3 } + +SRF_Address OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 8 + Default : 8675500000000009 + Field : [1]EIR number + { + [u]00.0-07.7 + [u]input + [v]keepHex-low-E + } + Remark: E.164 number of HLR server:HLR MSISDN used for SCCP addressing, F=end tag. + Default=91867555950502FFFF=91867555950502. + [End] + " + ::= { CPC 3 } + +Max_Call_Duration OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 3C + Field : [1]Max. call duration + { + [u]0.0-0.7 + [u]input + [v]toDec-high-0 + } + Remark : Define the permitted maximum call duration. Any ongoing call reaching this duration threshold will be compulsively cut off. byte value: 0=disable this function, 1-255=max. call duration, unit=minute. Default=0. + [End] + " + ::= { CPC 7 } + +-- +-- CCF -> Configuration -> E1 Port +-- + + +E1_Port OBJECT-IDENTITY + STATUS current + DESCRIPTION + "E1 Port." + ::= { CCF_Config 4 } + +E1_Interface OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]E1 interface + { + [u]0.0-0.7 + [u]select + [v]0[opt]TUP + [v]1[opt]ISUP + [v]2[opt]AIF + [v]3[opt]AIF CDMA2K + [v]4[opt]BICC + [v]5[opt]CI-CNF + [v]6[opt]CI-loopback + } + Remark: Set the type of E1 interface for 256 E1 ports. + [End] + " + ::= { E1_Port 1 } + +E1_TG OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : EE + Field : [1]Assign TG + { + [u]0.0-0.7 + [u]input + [v]toDec-high-0 + } + Remark :Assign a trunk group to each E1 port for call routing. A single E1 port points to only one trunk group, multiple E1 port can be assigned the same trunk group. Default=number of the E1 port. + [End] + " + ::= { E1_Port 2 } + +E1_CIC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 4 + Default : 00000000 + Field : [1]E1 CIC + { + [u]0.0-3.7 + [u]input + [v]toDec-high-0 + } + Remark :Circuit identity code, uniquely identify each circuit within a trunk group. CIC of both ends of a circuit must be identical. 256 CIC for dual MSC platform 256 E1 ports. + [End] + " + ::= { E1_Port 3 } + +E1_Media_Control_Attributes OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 4 + Default : 00000000 + Field : [1]E1 Control Protocol Type + { + [u]0.0-0.7 + [u]select + [v]0[opt]Internal + [v]1[opt]MGCP + } + [2]E1 Enable + { + [u]1.0-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]MG Number + { + [u]2.0-2.7 + [u]input + [v]toDec-high-0 + } + [4]Trunk Number + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + Remark :E1 Media Control Attributes + [End] + " + ::= { E1_Port 4 } + +-- +-- CCF -> Configuration -> Channel attributes +-- + + +Channel_Attributes OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Channel attributes." + ::= { CCF_Config 5 } + +Card0_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 1 } + +Card1_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 2 } + +Card2_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 3 } + +Card3_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 4 } + +Card4_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 5 } + +Card5_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 6 } + +Card6_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 7 } + +Card7_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 8 } + +Card8_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 9 } + +Card9_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 10 } + +Card10_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 11 } + +Card11_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 12 } + +Card12_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 13 } + +Card13_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 14 } + +Card14_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 15 } + +Card15_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 16 } + +Card16_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 17 } + +Card17_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 18 } + +Card18_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 19 } + +Card19_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 20 } + +Card20_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 21 } + +Card21_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 22 } + +Card22_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 23 } + +Card23_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 24 } + +Card24_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 25 } + +Card25_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 26 } + +Card26_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 27 } + +Card27_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 28 } + +Card28_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 29 } + +Card29_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 30 } + +Card30_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 31 } + +Card31_Channel OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 3 + Default : 05EEEE + Flag : E1 + Field : [1]Channel flag + { + [u]00.0-00.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]00.1-00.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } + [3]Reserved + { + [u]00.3-00.7 + [u]select + } + [4]LCCP card (0-15) + { + [u]01.0-01.3 + [u]input + [v]toDec-high-0 + } + [5]Reserved + { + [u]01.4-01.7 + [u]select + } + [6]LCCP timeslot (1-15, 17-31) + { + [u]02.0-02.4 + [u]input + [v]toDec-high-0 + } + [7]LCCP E1 (0-7) + { + [u]02.5-02.7 + [u]input + [v]toDec-high-0 + } + Remark: Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. + LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). + LCCP E1 (0-7)=Lease circuit connected E1 (0-7). + LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). + Default=0x05EEEE. + [End] + " + ::= { Channel_Attributes 32 } +-- +--CCF -> CPC_attributes +-- + +CPC_attributes OBJECT-IDENTITY + STATUS current + DESCRIPTION + "CPC attributes." + ::= { CCF_Config 6 } +MSCID OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 3 + Default : 000000 + Field : [1]Market ID + { + [u]0.0-1.7 + [u]input + [v]toDec-high-0 + } + [2]Switch Number + { + [u]2.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: MSCID + [End] + " + ::= { CPC_attributes 3 } + +-- +-- CCF -> Media_gateway +-- + +Media_gateway OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Media_gateway ." + ::= { CCF_Config 7 } + +MG_Attribute OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 53 + Default : 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Field : [1]MG Enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]MG IP Address + { + [u]1.0-4.7 + [u]input + [v]keepHex-high-0 + } + [3]MG Name + { + [u]5.0-52.7 + [u]input + [v]toAscii-low-0 + } + Remark: MG Attributes + [End] + " + ::= { Media_gateway 1 } + +-- +-- CCF -> CCF_Status +-- + +CCF_Status OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Status for CCF ." + ::= { CCF(MSC) 3 } + +Version OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 3 + Default : 000000 + Field : + Remark : Version of MSC software (Read only).
+ Byte0: System release version number, based on basic function and structure.
+ Byte1: Software module version number, based on software module.
+ Byte2: Test version, 0=Release version number, 1=Test version number.. + [End] + " + ::= { CCF_Status 1 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : EE + Flag : S1.3 + Field : [1]Command + { + [u]0.0-0.7 + [u]select + [v]90[opt]Reset + [v]165[opt]Initialize + [v]181[opt]Save parameter + [v]238[opt]No command + } + Remark: Control command for MSC-CPC. + Reset: Used for CPC status initialization. + Initialize: Restore the parameter setup to the default factory setting. + Save parameter: Save the parameters residing in CPC's memory into CPC's harddisk. + [End] + " + ::= { CCF_Status 2 } + +E1_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 128 + Length : 1 + Default : EE + Field : [1]Quantity of occupied timeslot + { + [u]0.0-0.4 + [u]input + [v]toDec-high-0 + } + + [2]E1 type + { + [u]0.5-0.7 + [u]select + [v]0[opt]TUP + [v]1[opt]ISUP + [v]2[opt]AIF + [v]3[opt]AIF_CDMA2K + [v]4[opt]BICC + } + Remark : E1 status (read only). + [End] + " + ::= { CCF_Status 4 } + +Channel_Status OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Channel status (read only)." + ::= { CCF_Status 5 } + +Card0_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 1 } + +Card1_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 2 } + +Card2_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 3 } + +Card3_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 4 } + +Card4_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 5 } + +Card5_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 6 } + +Card6_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 7 } + +Card7_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 8 } + +Card8_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 9 } + +Card9_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 10 } + +Card10_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 11 } + +Card11_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 12 } + +Card12_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 13 } + +Card13_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 14 } + +Card14_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 15 } + +Card15_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length : 1 + Default : 00 + Field : [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + Remark: Card Channel status (read only). + [End] + " + ::= { Channel_Status 16 } + +-- +-- sub system VLR +-- + +VLR OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]sub for VLR . + " + ::= { MSC 5 } + +-- +-- VLR -> Configuration +-- + +VLR_Config OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Configuration for VLR . + " + ::= { VLR 2 } + +Public_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Public parameters . " + ::= { VLR_Config 1 } + +OptAuthReq OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance : 1 + Length : 1 + Default : 00 + Field : [1]Update Location + { + [u]00.0-00.0 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } + [2]MO + { + [u]00.1-00.1 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } + [3]MT + { + [u]00.2-00.2 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } + [4]Spare + { + [u]00.3-00.7 + [u]input + [v]toDec-high-0 + } + Remark :Flag of SIM authentication on MS poweron and MO/MT call. + [End] + " + ::= { Public_Param 1 } + +OptReuseTriplets OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 00 + Field : [1]OptReuseTriplets + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]double authentication + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Spare + { + [u]00.2-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Flag of reusing authentication triplets in VLR in the case that authentication to HLR is not available. Default=disable. + [End] + " + ::= { Public_Param 2 } + +OptCipReq OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 00 + Field : [1]OptCipReq + { + [u]00.0-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + Remark : Flag of voice ciphering over air interface by MS. Default=Disable. + [End] + " + ::= { Public_Param 3 } + +OptCiphAlgo OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 4 + Default : 00000000 + Field : [1]OptCiphAlgo + { + [u]00.0-00.7 + [u]select + [v]0[opt]None + [v]1[opt]A5_1 + [v]2[opt]A5_2 + [v]3[opt]A5_3 + [v]4[opt]A5_4 + [v]5[opt]A5_5 + [v]6[opt]A5_6 + [v]7[opt]A5_7 + } + Remark : Voice ciphering algorithm selection. Default=no ciphering. + [End] + " + ::= { Public_Param 4 } + +OptTmsiAlloc OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 01 + Field : [1]TMSI Allocation Option + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Allocate TMSI + [v]2[opt]Reallocate TMSI + } + Remark :Flag of allocating a new TMSI every time a call management service is requested. Default=Disable. + [End] + " + ::= { Public_Param 5 } + +OptEcSetUpAllow OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 01 + Field : [1]OptEcSetUpAllow + { + [u]00.0-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + Remark : Flag of making emergency call for non-registered MS or MS without SIM. Default=Enable. + [End] + " + ::= { Public_Param 7 } + +OptCheckIMEI OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 00 + Field : [1]Update Location + { + [u]00.0-00.0 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } + [2]MO + { + [u]00.1-00.1 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } + [3]MT + { + [u]00.2-00.2 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } + [4]Spare + { + [u]00.3-00.7 + [u]input + [v]toDec-high-0 + } + Remark : Flag of IMEI verification via EIR. Default=no IMEI verification. + [End] + " + ::= { Public_Param 8 } + +OptVlrPurge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 00 + Field : [1]OptVlrPurge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + Remark : Flag of VLR purge. Default=Off. + [End] + " + ::= { Public_Param 9 } + +IdlePeriod2Purge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 3C + Field : [1]IdlePeriod2Purge + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark : Set the threshold of idle time to purge. If a mobile's idle time reaches this threshold, VLR will purge all records of this MS, unit=6 minute. Default=60minutes. + [End] + " + ::= { Public_Param 10 } + +CDR_Flag OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 01 + Field : [1]CDR on/off + { + [u]00.0-00.7 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + Remark : VLR CDR flag. Default=On. + [End] + " + ::= { Public_Param 11 } + +MSRN OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 16 + Default : 8675531240000FFF8675531241000FFF + Field : [3]Start number + { + [u]00.0-07.7 + [u]input + [v]keepHex-low-F + } + [4]End number + { + [u]08.0-15.7 + [u]input + [v]keepHex-low-F + } + Remark : Mobile station roaming number, use 16 bytes (32 digits) to define a range of MSRN. The length of start MSRN and end MSRN must be identical. F=end tag. + [End] + " + ::= { Public_Param 13 } + +-- +-- VLR -> Management +-- + +VLR_Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Management for VLR . + " + ::= { VLR 3 } + +Version OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 3 + Default : 000000 + Field : + Remark : Version of VLR software (Read only). + Byte0: System release version number, based on basic function and structure. + Byte1: Software module version number, based on software module. + Byte2: Test version, 0=Release version number, 1=Test version number. + [End] + " + ::= { VLR_Management 2 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : EE + Flag : S1.2 + Field : [1]Management + { + [u]00.0-00.7 + [u]select + [v]0[opt]Reset VLR + [v]1[opt]Save parameters + } + Remark : Control command for VLR. + Reset: Used to initialize the status of VLR. + Save parameters: Save the parameters residing in memory into harddisk. + [End] + " + ::= { VLR_Management 3 } + +Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length : 1 + Default : 00 + Field : + Remark :Basic status of VLR. + [End] + " + ::= { VLR_Management 4 } + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSS-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSS-MIB.txt new file mode 100644 index 0000000..5b7f92a --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-MSS-MIB.txt @@ -0,0 +1,54 @@ +WXC2-MSS-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +MSS OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Subsystems for MSS . " + ::= { App 16 } + +Configuration OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Configuration for MSS . " + ::= { MSS 2 } + +Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Management for MSS . " + ::= { Configuration 1 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance : 1 + Length : 1 + Default : 00 + Field : [1]Command + { + [u]00.0-00.7 + [u]select + [v]4[opt]Shutdown + [v]5[opt]Undefine value + } + Remark : Safely shut down MSS server by stoping MSS process, saving subscriber data to harddisk and shut down the server. + Operation procedures: + 1. Select -Shutdown- at above pulldown menu. + 2. Click -Set- button in this set window. + 3. Click -SET- button on operation page. + [End] + " + ::= { Management 1 } + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-PPS-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-PPS-MIB.txt new file mode 100644 index 0000000..24ea584 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-PPS-MIB.txt @@ -0,0 +1,13090 @@ +WXC2-PPS-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +PPS OBJECT-IDENTITY + STATUS current + DESCRIPTION + "[SubSystem_Module]Subsystems for PPS . " + ::= { App 6 } + +Public_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + " public parameters for MSS . " + ::= { PPS 2 } + +Configuration OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Configuration for PPS . " + ::= { Public_Param 1 } + +Service_Control OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Service Control . " + ::= { Configuration 1 } + +CDR_Flag OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]CDR flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + Remark: PPS CDR generation enable or disable. Default=PPS generate CDR. + [End] + " + ::= { Service_Control 1 } + +Blacklist_Threshold OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 05 + Field: [1]Blacklist threshold + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Legal recharge failure, subsciber who breaks the threshold will be marked in black list and suspended from service provisioning. Default=5. + [End] + " + ::= { Service_Control 2 } + +Maximum_Balance OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 00100000 + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This value is for overflow prevention. Normally operator doesn't need to change this value. e.g. 5000, and the smallest unit is cent then the maximum allowed balance is 5000 cents. + [End] + " + ::= { Service_Control 3 } + +License_Control OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 0000000000000000 + Field: [1]License + { + [u]00.0-07.7 + [u]input + [v]keepHex-low-E + } + Remark: 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of PPS subscribers for service provider. The new license can not support less PPS subscribers than what the old license supports. + [End] + " + ::= { Service_Control 4 } + +Prompt_Resolution OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Currency resolution + { + [u]00.0-00.1 + [u]select + [v]0[opt]1 + [v]1[opt]10 + [v]2[opt]100 + } + [2]Date format + { + [u]00.2-00.3 + [u]select + [v]0[opt]YYYY-MM-DD + [v]1[opt]DD-MM-YYYY + [v]2[opt]MM-DD-YYYY + } + [3]Currency symbol position + { + [u]00.4-00.4[u]select + [v]0[opt]Front + [v]1[opt]Rear + } + [4]Reserved + { + [u]00.5-00.7 + [u]select + } + Remark: Currency style: Set the number of decimals in account balance SM display format. If account balance=55555 in smallest currency unit: + 1=account balance display in SM is 55555. + 10=account balance display in SM is 5555.5. + 100=account balance display in SM is 555.55. + Default=100. + Date style: Set the date format displayed in SM or announcement. Default=YYYY-MM-DD. + Currency symbol position: Set the position of the currency symbol. + There are two types: at the front of the amount (e.g. $5) or at the rear of the amount (e.g. 5Fr). Default=at the front. + [End] + " + ::= { Service_Control 5 } + +SMS_Sentence OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 5 + Length: 112 + Default: 00596F7572206163636F756E742062616C616E63652069733A000000000000004578706972656420696E3A000000000000000000000000000000000000000000506C6561736520726563686172676520796F7572206163636F756E740000000000000000000000000000000000000000 + Field: [1]SM encode type + { + [u]00.0-00.7 + [u]select + [v]0[opt]7 bit + [v]4[opt]octet + [v]8[opt]unicode + } + [2]Account balance + { + [u]01.0-31.7 + [u]input + [v]toAscii-low-0 + } + [3]expired in + { + [u]32.0-63.7 + [u]input + [v]toAscii-low-0 + } + [4]recharge in time + { + [u]64.0-111.7 + [u]input + [v]toAscii-low-0 + } + Remark: The # of sentence(0-4) refers to differenct language type; + [End] + " + ::= { Service_Control 6 } + +Last_Call_Info OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 5 + Length: 88 + Default: 4C6173742063616C6C2073656E74206F6E3A00000000000000000000000000004C6173742063616C6C207265636569766564206F6E3A200000000000000000004174000000000000546F00000000000046726F6D00000000 + Field: [1]Last call sent on + { + [u]00.0-31.7 + [u]input + [v]toAscii-low-0 + } + [2]Last call received on + { + [u]32.0-63.7 + [u]input + [v]toAscii-low-0 + } + [3]At + { + [u]64.0-71.7 + [u]input + [v]toAscii-low-0 + } + [4]To + { + [u]72.0-79.7 + [u]input + [v]toAscii-low-0 + } + [5]From + { + [u]80.0-87.7 + [u]input + [v]toAscii-low-0 + } + Remark: The # of sentence(0-4) refers to differenct language type. + [End] + " + ::= { Service_Control 7 } + +Currency_Symbol OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 8 + Default: 2400000000000000 + Field: [1]Currency symbol + { + [u]00.0-07.7 + [u]input + [v]toAscii-low-0 + } + Remark: Set the symbol of the local currency in SMS amount display. e.g. $, RMB, EUR, US$, FR$. default=$. In the set window, type the currency symbol. The input symbol will be converted to ASCII code. + Do not input any symbol that not listed on the ASCII code table. ASCII table: 'A'=0x41, 'B'=0x42 ... 'I'=0x49, 'J'=0x4a, 'K'=0x4b ... 'Z'=0x5A, '$'=0x24 + e.g. RMB=0x52 0x4d 0x42, US$=0x55 0x53 0x24 + [End] + " + ::= { Service_Control 8 } + +Third_Party_Info OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 8 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Service ID + { + [u]00.0-07.7 + [u]input + [v]toAscii-low-0 + } + [2]Service password + { + [u]08.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: This parameter is a verification for third party ESME when the third party ESME sends a billing request to PPS server. For example, if a subscriber sends a short message via a ESME (e.g. website), the ESME will send a billing request to PPS to debit this subscriber. This billing request must contains a service ID and password to pass the verification. After verification, the subscriber will be debited by the PPS. PPS supports 8 ESME connections. + [End] + " + ::= { Service_Control 9 } + +Basic_Tariff_Zone OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 64 + Length: 9 + Default: 000000000000000000 + Field: [1]MCC + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-F + } + [2]MNC + { + [u]02.0-02.7 + [u]input + [v]keepHex-low-F + } + [3]LAC + { + [u]03.0-04.7 + [u]input + [v]toDec-high-0 + } + [4]Cell ID + { + [u]05.0-06.7 + [u]input + [v]toDec-high-0 + } + [5]MO tariff ID + { + [u]07.0-07.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + [6]MT tariff ID + { + [u]08.0-08.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: The basic tariff is applied for each calling or called number prefix. The WXC2 System supports 16 MO and MT tariffs (0-15) and 256 billing zones. This parameter defines basic tariff for each billing zone. Each parameter is a combination of MCC, MNC, cell ID, LAC and MO/MT tariff ID. The billing zone may be set as a cell, a LAC or a zone. Normally a single billing zone deploys only one basic tariff. + Each PPS subscriber profile also contains its tariff setup specifying which tariff should be applied for this subscriber. Using either basic tariff zone (location dependent) or tariff in subscriber profile (subscriber dependent) is determined by a parameter -Tariff subscription-. + LAC: If LAC=65536, all LACs in the MCC and MNC use the same basic tariff. + Cell ID: If cell ID=65536, all cells in the LAC use the same basic tariff. + [End] + " + ::= { Service_Control 10 } + +SRF_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SRF parameters . " + ::= { Configuration 2 } + +SRF_Number OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SRF Number. " + ::= { SRF_Param 1 } + +SRF_0_Number OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]SRF 0 number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: E.164 number of SRF 0 (Special Resource Function) entity. + [End] + " + ::= { SRF_Number 1 } + +SRF_1_Number OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]SRF 1 number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: E.164 number of SRF 1 (Special Resource Function) entity. + [End] + " + ::= { SRF_Number 2 } + +Service_Number OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Service number . " + ::= { SRF_Param 2 } + +Hotline OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Hotline + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: PPS service center number. Subscriber dials this number to recharge, enquire their account and modify favorite numbers. + [End] + " + ::= { Service_Number 1 } + +Inquiry OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Inquiry number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated PPS number for account (balance and validity) inquiry. + [End] + " + ::= { Service_Number 2 } + +Scratch_Card_Recharge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Recharge via scratch card + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated shortcut number for recharge via scratch card. + [End] + " + ::= { Service_Number 3 } + +Credit_Card_Recharge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Recharge via credit card + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated shortcut number for recharge via credit card. + [End] + " + ::= { Service_Number 4 } + +Third_Party_Recharge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Recharge other account + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated shortcut number for recharging other account from MS or PSTN. + [End] + " + ::= { Service_Number 5 } + +Customer_Care_Center OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Customer care center number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated shortcut number to connect customer care center. + [End] + " + ::= { Service_Number 6 } + +Rechareg_Number OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]Recharge number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Dedicated shortcut number for recharge via scratch card or credit card. + [End] + " + ::= { Service_Number 7 } + +Service_Key OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Service key . " + ::= { SRF_Param 3 } + +Inquiry OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Key for inquiry + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the function key to enquire account balance after entering the PPS service center. + [End] + " + ::= { Service_Key 2 } + +Scratch_Card_Recharge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 02 + Field: [1]Key for recharging via scratch card + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the key to recharge account via scratch card after entering the PPS service center. + [End] + " + ::= { Service_Key 3 } + +Credit_Card_Recharge OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Key for recharging via credit card + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the key for recharging account via credit card after entering the PPS service center. + [End] + " + ::= { Service_Key 4 } + +Set_Favorite_Number OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 04 + Field: [1]Key to set favorite number + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the key to set favorite number after entering the PPS service center. + [End] + " + ::= { Service_Key 5 } + +Language_Selection OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 05 + Field: [1]Key for language selection + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the key to select system language (from 5 available candidates) after entering the PPS service center. All announcements in the PPS service center is played in the system language. + [End] + " + ::= { Service_Key 6 } + +SetPasswd OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 06 + Field: [1]PPS account password + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Define the key to set account password after entering the PPS service center. When recharging account] selecting language] modifying favorite number or seting password] subscriber is asked to pass the password verification. + [End] + " + ::= { Service_Key 7 } + +File_Operation OBJECT-IDENTITY + STATUS current + DESCRIPTION + " File operation . " + ::= { Configuration 3 } + +Import_User_Data OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 7 + Default: 00000000000000 + Field: [1]Command status + { + [u]00.0-00.7 + [u]select + [v]0[opt]No operation + [v]1[opt]Send command + [v]2[opt]Begin loading + [v]3[opt]Loading OK + [v]4[opt]Loading failed + } + [2]Total number sent + { + [u]01.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]Records loaded + { + [u]04.0-06.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. Progress and result of PPS subscriber import. + Total number sent: Total quantity of PPS subscribers requesting import. + Records loaded: Quantity of successfully imported PPS subscribers. + [End] + " + ::= { File_Operation 1 } + +Import_Recharge_Card OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Import recharge card + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. Result of uploading recharge card to PPS. 0=unsuccessful. 1=successful. + [End] + " + ::= { File_Operation 2 } + +New_Tariff_Flag OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { File_Operation 3 } + +New_Tariff_Start_Time OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 7 + Default: 20050101000000 + Field: [1]Year + { + [u]00.0-01.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]03.0-03.7 + [u]input + [v]keepHex-high-0 + } + [4]Hour + { + [u]04.0-04.7 + [u]input + [v]keepHex-high-0 + } + [5]Minute + { + [u]05.0-05.7 + [u]input + [v]keepHex-high-0 + } + [6]Second + { + [u]06.0-06.7 + [u]input + [v]keepHex-high-0 + } + Remark: Read only. Set start time for new tariff plan. + [End] + " + ::= { File_Operation 4 } + +COS_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS parameters . " + ::= { Configuration 4 } + +COS_0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 0 Parameters. " + ::= { COS_Param 1 } + +Recharge_Promotion_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_0 1 } + +Start_Date_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS0 1 } + +End_Date_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS0 2 } + +Promotion_Bonus_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS0 3 } + +Tariff_Resolution_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_0 2 } + +MO_Tariff_ID_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS0 1 } + +MT_Tariff_ID_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS0 2 } + +Tariff_Subscription_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS0 3 } + +Recharge_Card_Validity_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS0 4 } + +Account_Control_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_0 3 } + +Min_balance_MO_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS0 1 } + +Maximum_Validity_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS0 2 } + +Release_Day_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS0 3 } + +MT_Control_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_0 4 } + +Charge_Flag_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS0 1 } + +Zero_Balance_Control_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS0 2 } + +Validity_Solution_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_0 5 } + +Clear_Balance_Option_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS0 1 } + +Validity_Recharge_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS0 2 } + +Validity_Zero_Balance_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS0 3 } + +Activated_Account_Validity_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS0 4 } + +FF_Number_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS0 5 } + +Support_Credit_Card_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS0 + [End] + " + ::= { Validity_Solution_COS0 6 } + +Credit_Vault_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS0 7 } + +SM_Inquiry_COS0 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_0 6 } + +Feedback_SM_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS0 1 } + +Inquiry_SM_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS0 2 } + +SM_Expiry_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS0 3 } + +SM_Low_Balance_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS0 4 } + +COS_1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 1 Parameters. " + ::= { COS_Param 2 } + +Recharge_Promotion_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_1 1 } + +Start_Date_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS1 1 } + +End_Date_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS1 2 } + +Promotion_Bonus_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS1 3 } + +Tariff_Resolution_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_1 2 } + +MO_Tariff_ID_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS1 1 } + +MT_Tariff_ID_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS1 2 } + +Tariff_Subscription_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS1 3 } + +Recharge_Card_Validity_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS1 4 } + +Account_Control_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_1 3 } + +Min_balance_MO_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS1 1 } + +Maximum_Validity_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS1 2 } + +Release_Day_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS1 3 } + +MT_Control_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_1 4 } + +Charge_Flag_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS1 1 } + +Zero_Balance_Control_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS1 2 } + +Validity_Solution_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_1 5 } + +Clear_Balance_Option_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS1 1 } + +Validity_Recharge_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS1 2 } + +Validity_Zero_Balance_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS1 3 } + +Activated_Account_Validity_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS1 4 } + +FF_Number_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS1 5 } + +Support_Credit_Card_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS1 6 } + +Credit_Vault_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS1 7 } + +SM_Inquiry_COS1 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_1 6 } + +Feedback_SM_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS1 1 } + +Inquiry_SM_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS1 2 } + +SM_Expiry_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS1 3 } + +SM_Low_Balance_COS1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS1 4 } + +COS_2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 2 Parameters. " + ::= { COS_Param 3 } + +Recharge_Promotion_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_2 1 } + +Start_Date_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS2 1 } + +End_Date_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS2 2 } + +Promotion_Bonus_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS2 3 } + +Tariff_Resolution_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_2 2 } + +MO_Tariff_ID_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS2 1 } + +MT_Tariff_ID_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS2 2 } + +Tariff_Subscription_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS2 3 } + +Recharge_Card_Validity_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS2 4 } + +Account_Control_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_2 3 } + +Min_balance_MO_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS2 1 } + +Maximum_Validity_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS2 2 } + +Release_Day_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS2 3 } + +MT_Control_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_2 4 } + +Charge_Flag_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS2 1 } + +Zero_Balance_Control_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS2 2 } + +Validity_Solution_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_2 5 } + +Clear_Balance_Option_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS2 1 } + +Validity_Recharge_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS2 2 } + +Validity_Zero_Balance_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS2 3 } + +Activated_Account_Validity_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS2 4 } + +FF_Number_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Free times of changing: set total times of free change for family number if charge is enabled. Maximum is 15. + [End] + " + ::= { Validity_Solution_COS2 5 } + +Support_Credit_Card_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS2 6 } + +Credit_Vault_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS2 7 } + +SM_Inquiry_COS2 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_2 6 } + +Feedback_SM_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS2 1 } + +Inquiry_SM_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS2 2 } + +SM_Expiry_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS2 3 } + +SM_Low_Balance_COS2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS2 4 } + +COS_3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 3 Parameters. " + ::= { COS_Param 4 } + +Recharge_Promotion_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_3 1 } + +Start_Date_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS3 1 } + +End_Date_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS3 2 } + +Promotion_Bonus_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS3 3 } + +Tariff_Resolution_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_3 2 } + +MO_Tariff_ID_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS3 1 } + +MT_Tariff_ID_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS3 2 } + +Tariff_Subscription_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS3 3 } + +Recharge_Card_Validity_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS3 4 } + +Account_Control_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_3 3 } + +Min_balance_MO_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS3 1 } + +Maximum_Validity_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS3 2 } + +Release_Day_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS3 3 } + +MT_Control_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_3 4 } + +Charge_Flag_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS3 1 } + +Zero_Balance_Control_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS3 2 } + +Validity_Solution_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_3 5 } + +Clear_Balance_Option_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS3 1 } + +Validity_Recharge_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS3 2 } + +Validity_Zero_Balance_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS3 3 } + +Activated_Account_Validity_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS3 4 } + +FF_Number_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS3 5 } + +Support_Credit_Card_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS3 6 } + +Credit_Vault_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS3 7 } + +SM_Inquiry_COS3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_3 6 } + +Feedback_SM_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS3 1 } + +Inquiry_SM_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS3 2 } + +SM_Expiry_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS3 3 } + +SM_Low_Balance_COS3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS3 4 } + +COS_4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 4 Parameters. " + ::= { COS_Param 5 } + +Recharge_Promotion_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_4 1 } + +Start_Date_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS4 1 } + +End_Date_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS4 2 } + +Promotion_Bonus_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS4 3 } + +Tariff_Resolution_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_4 2 } + +MO_Tariff_ID_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS4 1 } + +MT_Tariff_ID_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS4 2 } + +Tariff_Subscription_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS4 3 } + +Recharge_Card_Validity_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS4 4 } + +Account_Control_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_4 3 } + +Min_balance_MO_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS4 1 } + +Maximum_Validity_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS4 2 } + +Release_Day_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS4 3 } + +MT_Control_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_4 4 } + +Charge_Flag_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS4 1 } + +Zero_Balance_Control_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS4 2 } + +Validity_Solution_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_4 5 } + +Clear_Balance_Option_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS4 1 } + +Validity_Recharge_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS4 2 } + +Validity_Zero_Balance_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS4 3 } + +Activated_Account_Validity_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS4 4 } + +FF_Number_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS4 5 } + +Support_Credit_Card_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS4 6 } + +Credit_Vault_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS4 7 } + +SM_Inquiry_COS4 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_4 6 } + +Feedback_SM_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS4 1 } + +Inquiry_SM_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS4 2 } + +SM_Expiry_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS4 3 } + +SM_Low_Balance_COS4 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS4 4 } + +COS_5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 5 Parameters. " + ::= { COS_Param 6 } + +Recharge_Promotion_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_5 1 } + +Start_Date_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS5 1 } + +End_Date_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS5 2 } + +Promotion_Bonus_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS5 3 } + +Tariff_Resolution_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_5 2 } + +MO_Tariff_ID_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS5 1 } + +MT_Tariff_ID_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] Select a MT tariff for this COS. The COS ID is included in subscriber profile for MT call charge. Total 16 MT tariffs available. + " + ::= { Tariff_Resolution_COS5 2 } + +Tariff_Subscription_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS5 3 } + +Recharge_Card_Validity_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS5 4 } + +Account_Control_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_5 3 } + +Min_balance_MO_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS5 1 } + +Maximum_Validity_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS5 2 } + +Release_Day_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS5 3 } + +MT_Control_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_5 4 } + +Charge_Flag_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS5 1 } + +Zero_Balance_Control_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS5 2 } + +Validity_Solution_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_5 5 } + +Clear_Balance_Option_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS5 1 } + +Validity_Recharge_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS5 2 } + +Validity_Zero_Balance_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS5 3 } + +Activated_Account_Validity_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS5 4 } + +FF_Number_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS5 5 } + +Support_Credit_Card_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS5 6 } + +Credit_Vault_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS5 7 } + +SM_Inquiry_COS5 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_5 6 } + +Feedback_SM_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS5 1 } + +Inquiry_SM_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS5 2 } + +SM_Expiry_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS5 3 } + +SM_Low_Balance_COS5 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS5 4 } + +COS_6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 6 Parameters. " + ::= { COS_Param 7 } + +Recharge_Promotion_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_6 1 } + +Start_Date_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS6 1 } + +End_Date_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS6 2 } + +Promotion_Bonus_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS6 3 } + +Tariff_Resolution_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_6 2 } + +MO_Tariff_ID_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS6 1 } + +MT_Tariff_ID_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS6 2 } + +Tariff_Subscription_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS6 3 } + +Recharge_Card_Validity_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS6 4 } + +Account_Control_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_6 3 } + +Min_balance_MO_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS6 1 } + +Maximum_Validity_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS6 2 } + +Release_Day_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS6 3 } + +MT_Control_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_6 4 } + +Charge_Flag_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS6 1 } + +Zero_Balance_Control_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS6 2 } + +Validity_Solution_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_6 5 } + +Clear_Balance_Option_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS6 1 } + +Validity_Recharge_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS6 2 } + +Validity_Zero_Balance_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS6 3 } + +Activated_Account_Validity_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS6 4 } + +FF_Number_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS6 5 } + +Support_Credit_Card_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS6 6 } + +Credit_Vault_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS6 7 } + +SM_Inquiry_COS6 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_6 6 } + +Feedback_SM_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS6 1 } + +Inquiry_SM_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS6 2 } + +SM_Expiry_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS6 3 } + +SM_Low_Balance_COS6 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS6 4 } + +COS_7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 7 Parameters. " + ::= { COS_Param 8 } + +Recharge_Promotion_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_7 1 } + +Start_Date_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS7 1 } + +End_Date_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS7 2 } + +Promotion_Bonus_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS7 3 } + +Tariff_Resolution_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_7 2 } + +MO_Tariff_ID_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS7 1 } + +MT_Tariff_ID_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS7 2 } + +Tariff_Subscription_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS7 3 } + +Recharge_Card_Validity_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS7 4 } + +Account_Control_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_7 3 } + +Min_balance_MO_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS7 1 } + +Maximum_Validity_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS7 2 } + +Release_Day_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS7 3 } + +MT_Control_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_7 4 } + +Charge_Flag_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS7 1 } + +Zero_Balance_Control_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS7 2 } + +Validity_Solution_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_7 5 } + +Clear_Balance_Option_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS7 1 } + +Validity_Recharge_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS7 2 } + +Validity_Zero_Balance_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS7 3 } + +Activated_Account_Validity_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS7 4 } + +FF_Number_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS7 5 } + +Support_Credit_Card_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS7 6 } + +Credit_Vault_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS7 7 } + +SM_Inquiry_COS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_7 6 } + +Feedback_SM_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS7 1 } + +Inquiry_SM_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS7 2 } + +SM_Expiry_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS7 3 } + +SM_Low_Balance_COS7 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS7 4 } + +COS_8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 8 Parameters. " + ::= { COS_Param 9 } + +Recharge_Promotion_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_8 1 } + +Start_Date_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS8 1 } + +End_Date_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS8 2 } + +Promotion_Bonus_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS8 3 } + +Tariff_Resolution_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_8 2 } + +MO_Tariff_ID_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS8 1 } + +MT_Tariff_ID_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS8 2 } + +Tariff_Subscription_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS8 3 } + +Recharge_Card_Validity_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS8 4 } + +Account_Control_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_8 3 } + +Min_balance_MO_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS8 1 } + +Maximum_Validity_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS8 2 } + +Release_Day_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS8 3 } + +MT_Control_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_8 4 } + +Charge_Flag_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS8 1 } + +Zero_Balance_Control_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS8 2 } + +Validity_Solution_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_8 5 } + +Clear_Balance_Option_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS8 1 } + +Validity_Recharge_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS8 2 } + +Validity_Zero_Balance_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS8 3 } + +Activated_Account_Validity_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS8 4 } + +FF_Number_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS8 5 } + +Support_Credit_Card_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS8 6 } + +Credit_Vault_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS8 7 } + +SM_Inquiry_COS8 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_8 6 } + +Feedback_SM_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS8 1 } + +Inquiry_SM_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS8 2 } + +SM_Expiry_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS8 3 } + +SM_Low_Balance_COS8 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS8 4 } + +COS_9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 9 Parameters. " + ::= { COS_Param 10 } + +Recharge_Promotion_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_9 1 } + +Start_Date_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS9 1 } + +End_Date_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS9 2 } + +Promotion_Bonus_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS9 3 } + +Tariff_Resolution_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_9 2 } + +MO_Tariff_ID_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS9 1 } + +MT_Tariff_ID_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS9 2 } + +Tariff_Subscription_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS9 3 } + +Recharge_Card_Validity_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS9 4 } + +Account_Control_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_9 3 } + +Min_balance_MO_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS9 1 } + +Maximum_Validity_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS9 2 } + +Release_Day_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS9 3 } + +MT_Control_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_9 4 } + +Charge_Flag_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS9 1 } + +Zero_Balance_Control_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS9 2 } + +Validity_Solution_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_9 5 } + +Clear_Balance_Option_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS9 1 } + +Validity_Recharge_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS9 2 } + +Validity_Zero_Balance_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS9 3 } + +Activated_Account_Validity_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS9 4 } + +FF_Number_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS9 5 } + +Support_Credit_Card_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS9 6 } + +Credit_Vault_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS9 7 } + +SM_Inquiry_COS9 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_9 6 } + +Feedback_SM_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS9 1 } + +Inquiry_SM_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS9 2 } + +SM_Expiry_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS9 3 } + +SM_Low_Balance_COS9 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS9 4 } + +COS_10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 10 Parameters. " + ::= { COS_Param 11 } + +Recharge_Promotion_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_10 1 } + +Start_Date_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS10 1 } + +End_Date_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS10 2 } + +Promotion_Bonus_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS10 3 } + +Tariff_Resolution_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_10 2 } + +MO_Tariff_ID_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS10 1 } + +MT_Tariff_ID_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS10 2 } + +Tariff_Subscription_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS10 3 } + +Recharge_Card_Validity_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS10 4 } + +Account_Control_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_10 3 } + +Min_balance_MO_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS10 1 } + +Maximum_Validity_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS10 2 } + +Release_Day_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS10 3 } + +MT_Control_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_10 4 } + +Charge_Flag_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS10 1 } + +Zero_Balance_Control_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS10 2 } + +Validity_Solution_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_10 5 } + +Clear_Balance_Option_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS10 1 } + +Validity_Recharge_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS10 2 } + +Validity_Zero_Balance_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS10 3 } + +Activated_Account_Validity_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS10 4 } + +FF_Number_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS10 5 } + +Support_Credit_Card_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS10 6 } + +Credit_Vault_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS10 7 } + +SM_Inquiry_COS10 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_10 6 } + +Feedback_SM_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS10 1 } + +Inquiry_SM_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS10 2 } + +SM_Expiry_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS10 3 } + +SM_Low_Balance_COS10 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS10 4 } + +COS_11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 11 Parameters. " + ::= { COS_Param 12 } + +Recharge_Promotion_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_11 1 } + +Start_Date_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS11 1 } + +End_Date_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS11 2 } + +Promotion_Bonus_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS11 3 } + +Tariff_Resolution_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_11 2 } + +MO_Tariff_ID_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS11 1 } + +MT_Tariff_ID_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS11 2 } + +Tariff_Subscription_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS11 3 } + +Recharge_Card_Validity_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS11 4 } + +Account_Control_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_11 3 } + +Min_balance_MO_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS11 1 } + +Maximum_Validity_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS11 2 } + +Release_Day_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS11 3 } + +MT_Control_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_11 4 } + +Charge_Flag_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS11 1 } + +Zero_Balance_Control_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS11 2 } + +Validity_Solution_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_11 5 } + +Clear_Balance_Option_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS11 1 } + +Validity_Recharge_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS11 2 } + +Validity_Zero_Balance_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS11 3 } + +Activated_Account_Validity_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS11 4 } + +FF_Number_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS11 5 } + +Support_Credit_Card_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS11 6 } + +Credit_Vault_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS11 7 } + +SM_Inquiry_COS11 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_11 6 } + +Feedback_SM_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS11 1 } + +Inquiry_SM_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS11 2 } + +SM_Expiry_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS11 3 } + +SM_Low_Balance_COS11 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS11 4 } + +COS_12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 12 Parameters. " + ::= { COS_Param 13 } + +Recharge_Promotion_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_12 1 } + +Start_Date_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS12 1 } + +End_Date_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS12 2 } + +Promotion_Bonus_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS12 3 } + +Tariff_Resolution_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_12 2 } + +MO_Tariff_ID_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS12 1 } + +MT_Tariff_ID_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS12 2 } + +Tariff_Subscription_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS12 3 } + +Recharge_Card_Validity_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS12 4 } + +Account_Control_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_12 3 } + +Min_balance_MO_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS12 1 } + +Maximum_Validity_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS12 2 } + +Release_Day_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS12 3 } + +MT_Control_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_12 4 } + +Charge_Flag_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS12 1 } + +Zero_Balance_Control_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS12 2 } + +Validity_Solution_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_12 5 } + +Clear_Balance_Option_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS12 1 } + +Validity_Recharge_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS12 2 } + +Validity_Zero_Balance_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS12 3 } + +Activated_Account_Validity_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS12 4 } + +FF_Number_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS12 5 } + +Support_Credit_Card_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS12 6 } + +Credit_Vault_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS12 7 } + +SM_Inquiry_COS12 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_12 6 } + +Feedback_SM_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS12 1 } + +Inquiry_SM_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS12 2 } + +SM_Expiry_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS12 3 } + +SM_Low_Balance_COS12 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS12 4 } + +COS_13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 13 Parameters. " + ::= { COS_Param 14 } + +Recharge_Promotion_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_13 1 } + +Start_Date_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS13 1 } + +End_Date_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS13 2 } + +Promotion_Bonus_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS13 3 } + +Tariff_Resolution_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_13 2 } + +MO_Tariff_ID_COS0 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS13 1 } + +MT_Tariff_ID_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS13 2 } + +Tariff_Subscription_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS13 3 } + +Recharge_Card_Validity_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS13 4 } + +Account_Control_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_13 3 } + +Min_balance_MO_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS13 1 } + +Maximum_Validity_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS13 2 } + +Release_Day_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS13 3 } + +MT_Control_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_13 4 } + +Charge_Flag_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS13 1 } + +Zero_Balance_Control_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS13 2 } + +Validity_Solution_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_13 5 } + +Clear_Balance_Option_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS13 1 } + +Validity_Recharge_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS13 2 } + +Validity_Zero_Balance_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS13 3 } + +Activated_Account_Validity_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS13 4 } + +FF_Number_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS13 5 } + +Support_Credit_Card_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS13 6 } + +Credit_Vault_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS13 7 } + +SM_Inquiry_COS13 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_13 6 } + +Feedback_SM_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS13 1 } + +Inquiry_SM_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS13 2 } + +SM_Expiry_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS13 3 } + +SM_Low_Balance_COS13 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS13 4 } + +COS_14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 14 Parameters. " + ::= { COS_Param 15 } + +Recharge_Promotion_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_14 1 } + +Start_Date_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS14 1 } + +End_Date_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS14 2 } + +Promotion_Bonus_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS14 3 } + +Tariff_Resolution_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_14 2 } + +MO_Tariff_ID_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS14 1 } + +MT_Tariff_ID_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS14 2 } + +Tariff_Subscription_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS14 3 } + +Recharge_Card_Validity_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS14 4 } + +Account_Control_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_14 3 } + +Min_balance_MO_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS14 1 } + +Maximum_Validity_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS14 2 } + +Release_Day_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS14 3 } + +MT_Control_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_14 4 } + +Charge_Flag_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS14 1 } + +Zero_Balance_Control_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS14 2 } + +Validity_Solution_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_14 5 } + +Clear_Balance_Option_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS14 1 } + +Validity_Recharge_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS14 2 } + +Validity_Zero_Balance_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS14 3 } + +Activated_Account_Validity_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS14 4 } + +FF_Number_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS14 5 } + +Support_Credit_Card_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS14 6 } + +Credit_Vault_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS14 7 } + +SM_Inquiry_COS14 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_14 6 } + +Feedback_SM_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS14 1 } + +Inquiry_SM_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS14 2 } + +SM_Expiry_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS14 3 } + +SM_Low_Balance_COS14 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS14 4 } + +COS_15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " COS 15 Parameters. " + ::= { COS_Param 16 } + +Recharge_Promotion_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Recharge Promotion. " + ::= { COS_15 1 } + +Start_Date_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is + valid. Operator defines the promotion period by specifying the start and end + date. Each COS may have its own promotion period. Subscriber recharges his + account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS15 1 } + +End_Date_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Year: 20 + { + [u]00.0-00.7 + [u]input + [v]keepHex-high-0 + } + [2]Month + { + [u]01.0-01.7 + [u]input + [v]keepHex-high-0 + } + [3]Day + { + [u]02.0-02.7 + [u]input + [v]keepHex-high-0 + } + Remark: The promotion period is the period of time in which the recharge promotion is valid. Operator + defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. + Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. + To turn off the recharge promotion, set the start and end date as 000000. + [End] + " + ::= { Recharge_Promotion_COS15 2 } + +Promotion_Bonus_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 9 + Default: 000000000000000000 + Field: [1]Recharge card credit + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + [2]Promotion bonus + { + [u]04.0-07.7 + [u]input + [v]toDec-high-0 + } + [3]Bonus validity + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + Remark: Promotion bonus is the extra credit that a subscriber will get when he recharges his account + in the promotion period. The amount of the bonus is determined by the recharge card credit. + Operator may set the bonus for four types of recharge card of each COS. Generally the recharge + card with higher credit is awarded more bonus. + Please note that the promotion bonus is only applicable for paying call charging. It can't be + used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be + deducted prior to the recharge card credit. + Promotion bonus validity is the period of time that the bonus is valid. Bonus over the + validity period will be obsolete and deleted from account balance. That means the subscriber + must consume his entire promotion bonus within the time frame set by the operator. The operator + has the total freedom to design the validity period - shorter, same or longer than the validity + period of the recharge credit. + [End] + " + ::= { Recharge_Promotion_COS15 3 } + +Tariff_Resolution_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Tariff Resolution. " + ::= { COS_15 2 } + +MO_Tariff_ID_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk + to PPS memory after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS15 1 } + +MT_Tariff_ID_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT tariff ID + { + [u]00.0-00.7 + [u]select + [v]00[opt]00 + [v]01[opt]01 + [v]02[opt]02 + [v]03[opt]03 + [v]04[opt]04 + [v]05[opt]05 + [v]06[opt]06 + [v]07[opt]07 + [v]08[opt]08 + [v]09[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + Remark: Select a MT tariff for this COS. The COS ID is included in subscriber profile + for MT call charge. Total 16 MT tariffs available. + [End] + " + ::= { Tariff_Resolution_COS15 2 } + +Tariff_Subscription_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Charge by + { + [u]00.0-00.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + Remark: PPS basic tariff may be applied on either area (parameter Basic tariff zone) + or subscriber (Tariff ID in subscriber profile) basis. This parameter defines + which one is preference when debiting a subscriber. + [End] + " + ::= { Tariff_Resolution_COS15 3 } + +Recharge_Card_Validity_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 4 + Length: 6 + Default: 000000000000 + Field: [1]Face value + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + [2]MO validity + { + [u]02.0-03.7 + [u]input + [v]toDec-high-0 + } + [3]MT validity + { + [u]04.0-05.7 + [u]input + [v]toDec-high-0 + } + Remark: Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory + after submitting the new tariff to the PPS harddisk + consequently enable the new tariff startup. + [End] + " + ::= { Tariff_Resolution_COS15 4 } + +Account_Control_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Account control . " + ::= { COS_15 3 } + +Min_balance_MO_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0000 + Field: [1]Set threshold for MO call + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } + [2]Minimum balance for MO call + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Set a minimum balance for MO call. The subscriber whose balance is below this + threshold can't make MO call. The unit of the minimum balance is the smallest + unit of currency. + [End] + " + ::= { Account_Control_COS15 1 } + +Maximum_Validity_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Maximum account balance + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Specify the legal maximum balance, unit is the minimum currency unit. This + value is for overflow prevention. Normally operator doesn't need to change + this value. e.g. 5000, and the smallest unit is cent then the maximum allowed + balance is 5000 cents. + [End] + " + ::= { Account_Control_COS15 2 } + +Release_Day_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 02DA + Field: [1]Release day + { + [u]00.0-01.7 + [u]input + [v]toDec-high-0 + } + Remark: Number of days to hold an expiried prepaid account. After these release days, + if the expired prepaid user does't recharge his account, his account will be released. After + released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + [End] + " + ::= { Account_Control_COS15 3 } + +MT_Control_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MT control . " + ::= { COS_15 4 } + +Charge_Flag_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + Remark: Enable or disable MT call charge for prepaid subscriber. + [End] + " + ::= { MT_Control_COS15 1 } + +Zero_Balance_Control_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Field: [1]Zero balance MT call + { + [u]00.0-00.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + Remark: Enable or disable (MT) incoming calls when balance reaches zero. + [End] + " + ::= { MT_Control_COS15 2 } + +Validity_Solution_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Validity solution . " + ::= { COS_15 5 } + +Clear_Balance_Option_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]When account expires + { + [u]00.0-00.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]00.1-00.1[u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if clear off balance when an account expires or released. + If the balance is cleared] the balance will not be reused anyway. + [End] + " + ::= { Validity_Solution_COS15 1 } + +Validity_Recharge_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity after recharge + { + [u]00.0-00.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + Remark: Set account validity increasement mode after a successful recharge. Accumulate: + the validity of the recharged money will be accumulated to the recharged account. + Replace: if the validity of the recharged money is more than the current account + validity, the account validity will be replaced by the validity of recharged money, + if the validity of the recharged money is less than the current account validity] the + account validity will not be changed after a successful recharge. + [End] + " + ::= { Validity_Solution_COS15 2 } + +Validity_Zero_Balance_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Validity on zero balance + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } + [2]Days + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the + validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity + to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for + a zero balance account. If a zero balance account's current validity is less than the preset adjustment + validity] the system will keep this account's current validity. e.g. If this function is enabled] + and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] + his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter + Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + [End] + " + ::= { Validity_Solution_COS15 3 } + +Activated_Account_Validity_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Activation by inquiring + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Validity of activated account with zero balance + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Set validity for an account who is activated from fresh status by dialing inquiry + number. The unit is day. Defaul=30 days. + [End] + " + ::= { Validity_Solution_COS15 4 } + +FF_Number_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: f5 + Field: [1]CUG serivce flag + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]00.6-00.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]00.5-00.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [4]Reserved + { + [u]00.4-00.4 + [u]select + } + [5]Free times of changing + { + [u]00.0-00.3 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge for changing family number. Free times of changing: set total times + of free change for family number if charge is enabled. Maximum is 15 + [End] + " + ::= { Validity_Solution_COS15 5 } + +Support_Credit_Card_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Support credit card flag + { + [u]00.0-00.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + Remark: Support_Credit_Card_COS + [End] + " + ::= { Validity_Solution_COS15 6 } + +Credit_Vault_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1064 + Field: [1]Support credit vault + { + [u]01.7-01.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } + [2]Credit vault + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: When a subscriber is rejected to make a call because of the insufficient balance, he may select + to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft + (credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + [End] + " + ::= { Validity_Solution_COS15 7 } + +SM_Inquiry_COS15 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SM inquiry notification . " + ::= { COS_15 6 } + +Feedback_SM_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]Send SM for recharge result + { + [u]00.0-00.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]00.1-00.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Reserved + { + [u]00.2-00.7 + [u]select + } + Remark: Set if send feedback short message for balance inquiry or recharge operation. + [End] + " + ::= { SM_Inquiry_COS15 1 } + +Inquiry_SM_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 83 + Field: [1]Charge on inquiry SM + { + [u]00.7-00.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } + [2]Free SM every day + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) + to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if + charge is enabled. Maximum is 128. + [End] + " + ::= { SM_Inquiry_COS15 2 } + +SM_Expiry_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 8a + Field: [1]Send SM notification + { + [u]00.7-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Days prior to expiry date + { + [u]00.0-00.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account is going to expire. If the Days + is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire + in five days. + [End] + " + ::= { SM_Inquiry_COS15 3 } + +SM_Low_Balance_COS15 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 81F4 + Field: [1]Send SM notification + { + [u]01.7-01.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Balance level to send SM + { + [u]00.0-01.6 + [u]input + [v]toDec-high-0 + } + Remark: Enable or disable sending notification short message when an account's balance is too low. + Balance level to send SM: set a low balance for short message notification. PPS will send + a notification short message to an subscriber whose balance is no more than the preset low + balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, + the PPS will send the notification SM to this subscriber indicating low balance. + [End] + " + ::= { SM_Inquiry_COS15 4 } + +Call_Routing_VMS OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Call routing to VMS . " + ::= { Configuration 5 } + +VMS_PLMN_Maintenance OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]VMS service number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + [End] + " + ::= { Call_Routing_VMS 1 } + +VMS_PSTN_Maintenance OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]VMS service number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + [End] + " + ::= { Call_Routing_VMS 2 } + +--VMS_Deposit_Number OBJECT-TYPE +-- SYNTAX OCTET STRING +-- MAX-ACCESS read-only +-- STATUS current +-- DESCRIPTION +-- " Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. +-- " +-- ::= { Call_Routing_VMS 3 } + +VMS_leave_msg_No OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 16 + Default: 00000000000000000000000000000000 + Field: [1]VMS deposit number + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + Remark: Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + [End] + " + ::= { Call_Routing_VMS 3 } + +--Access_VoiceBox OBJECT-TYPE +-- SYNTAX OCTET STRING +-- MAX-ACCESS read-only +-- STATUS current +-- DESCRIPTION +-- " Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. +-- " +-- ::= { Call_Routing_VMS 4 } + +Rule OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]Route by + { + [u]00.0-00.0 + [u]select + [v]0[opt]Prefix + [v]1[opt]Whole number + } + [2]Route + { + [u]00.1-00.1 + [u]select + [v]0[opt]Caller number + [v]1[opt]Called number + } + [3]Reserved + { + [u]00.2-00.7 + [u]input + [v]toDec-high-0 + } + Remark: rule + [End] + " + ::= { Call_Routing_VMS 4 } + +VMS_User_Segments OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 128 + Length: 80 + Default: 3836373535393030303030000000000038363735353939393939390000000000383637353539393830300000000000003836373535393938303100000000000038363735353939383032000000000000 + Field: [1]Start MSISDN + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + [2]End MSISDN + { + [u]16.0-31.7 + [u]input + [v]toAscii-low-0 + } + [3]VMS service number - PLMN + { + [u]32.0-47.7 + [u]input + [v]toAscii-low-0 + } + [4]VMS service number - PSTN + { + [u]48.0-63.7 + [u]input + [v]toAscii-low-0 + } + [5]Leave message deposit number + { + [u]64.0-79.7 + [u]input + [v]toAscii-low-0 + } + Remark: VMS user segments + [End] + " + ::= { Call_Routing_VMS 5 } + +Status OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Status. " + ::= { Configuration 6 } + +Activation OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]System status + { + [u]00.0-00.7 + [u]select + [v]0[opt]Normal + } + Remark: Set PPS system status. 0=normal. After initial PPS installation, if the PPS system doesn't has subscriber profiles, its status is suspended. In this case operator may set this parameter (normal) to activate the PPS server. + [End] + " + ::= { Status 1 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag : S1.1 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]1[opt]Save parameters + [v]2[opt]Save user data + } + Remark: PPS management command. + Save parameters: Save PPS parameters in PPS memory to PPS hard disk. + Save user data: Save PPS subscriber data in PPS memory to PPS hard disk. + [End] + " + ::= { Status 2 } + +END \ No newline at end of file diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMI.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMI.txt new file mode 100644 index 0000000..2e3727b --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMI.txt @@ -0,0 +1,57 @@ +-- ***************************************************************** +-- WXC2-SMI: WXC2 Structure of Management Information +-- +-- draft November 2000, Huang qilong +-- 1st November 2004, Sheng Xueqiang +-- +-- Copyright (c) 2004 by interWAVE, Inc. +-- All rights reserved. +-- +-- ***************************************************************** +-- + +WXC2-SMI DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, + OBJECT-IDENTITY, + FROM SNMPv2-SMI + IWV_Products + FROM IWV-SMI; + +WXC2 MODULE-IDENTITY + LAST-UPDATED "200506050000Z" + ORGANIZATION "interWAVE, Inc." + CONTACT-INFO + "http://www.iwv.com" + DESCRIPTION + "The Structure of Management Information for the WXC2 of interWAVE enterprise." + REVISION "200506050000Z" + DESCRIPTION + "1st version of this MIB module." + ::= { IWV_Products 3 } + +-- WXC2_PCM +PCM OBJECT-IDENTITY + STATUS current + DESCRIPTION + "PCM " + ::= { WXC2 1 } + + +-- WXC2_platform +Platform OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Platform " + ::= { WXC2 2 } + +-- WXC2_App + +App OBJECT-IDENTITY + STATUS current + DESCRIPTION + "App platform" + ::= { WXC2 3 } + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMSC-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMSC-MIB.txt new file mode 100644 index 0000000..330fef9 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SMSC-MIB.txt @@ -0,0 +1,259 @@ +WXC2-SMSC-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + App + FROM WXC2-SMI; + +SMSC OBJECT-IDENTITY + STATUS current + DESCRIPTION + "[SubSystem_Module]Subsystems for SMSC . " + ::= { App 5 } + +Configuration OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Configuration for SMSC . " + ::= { SMSC 2 } + +System_Param OBJECT-IDENTITY + STATUS current + DESCRIPTION + " system parameter . " + ::= { Configuration 1 } + + + +CDR_Flag OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 03 + Field: [1]SMSC CDR + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not generate + [v]1[opt]Generate + } + [2]SMSC LOG + { + [u]0.1-0.1 + [u]select + [v]0[opt]Not generate + [v]1[opt]Generate + } + [3]Reserved + { + [u]0.2-0.7 + [u]select + } + + Remark: SMSC CDR generation enable or disable. + [End] + " + ::= { System_Param 1 } + +SM_Validity OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 4 + Default: 0000A8C0 + Field: [1]SM validity + { + [u]00.0-03.7 + [u]input + [v]toDec-high-0 + } + Remark: Period of validity of short message, define a threshold how long an awaiting sending message should be kept in sending array till sent to MS, unit is second, default=0c0a8h seconds=12 hours. + [End] + " + ::= { System_Param 2 } + +MSISDN_Segment OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 16 + Length: 19 + Default: 8675557127000EEEEE8675557127999EEEEE00 + Field: [1]Start MSISDN + { + [u]00.0-08.7 + [u]input + [v]keepHex-low-E + } + [2]End MSISDN + { + [u]09.0-17.7 + [u]input + [v]keepHex-low-E + } + [3]Number Type + { + [u]18.0-18.7 + [u]select + [v]0[opt]GSM + [v]1[opt]CDMA + } + Remark: Specify the beginning MSISDN for the range of provisioned subscriber. F=end tag. + [End] + " + ::= { System_Param 3 } + +SMPP_parameters OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 32 + Length: 12 + Default: 000000000000000000000000 + Field: [1]Enable flag + { + [u]00.0-00.7 + [u]select + [v]00[opt]Disable + [v]01[opt]Enable + } + [2]Session type + { + [u]01.0-01.7 + [u]select + [v]00[opt]BIND_TX + [v]01[opt]BIND_RX + [v]02[opt]BIND_TRX + } + [3]Service number + { + [u]02.0-9.7 + [u]input + [v]toAscii-low-0 + } + [4]Message mode + { + [u]10.0-10.7 + [u]select + [v]00[opt]Store and forward + [v]01[opt]Datagram + [v]02[opt]Transaction + } + [5]Data Coding Scheme + { + [u]11.0-11.7 + [u]select + [v]00[opt]To smpp=7bit,default=7bit + [v]01[opt]To smpp=8bit,default=7bit + [v]16[opt]To smpp=7bit,default=8bit + [v]17[opt]To smpp=8bit,default=8bit + } + Remark: Name: Can be any name, generally use the name of the connected device. + Service number: SMPP connected party MSISDN used for display on MT MS, + e.g. for a SMPP to PPS, set the service number as MSISDN of PPS. + Data coding scheme: + 00:smsc to smpp=7bit,when dcs = 0,smsc to smpp default = 7bit + 01:smsc to smpp=8bit,when dcs = 0,smsc to smpp default = 7bit + 10:smsc to smpp=7bit,when dcs = 0,smsc to smpp default = 8bit + 11:smsc to smpp=8bit,when dcs = 0,smsc to smpp default = 8bit + Default=0. + [End] + " + ::= { Configuration 2 } + +Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Management for SMSC . + " + ::= { SMSC 3 } + +SMSC_ID OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]SMSC ID + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-E + } + Remark: SMSC ID + [End] + " + ::= { Management 1 } + +Software_Version OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 7 + Default: 00000000000000 + Field: [1]Version + { + [u]00.0-02.7 + [u]input + [v]keepHex-low-E + } + Remark: Software version + [End] + " + ::= { Management 2 } + +Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 01 + Flag: S1.1 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]01[opt]Save parameters + [v]04[opt]Reset system + [v]05[opt]Delete pending SM + } + Remark: SMSC system command. + Save parameters: Save the SMSC parameters in memory to SMSC harddisk. + Delete pending SM: Delete the pending SM in awaiting array. + [End] + " + ::= { Management 3 } + + + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/WXC2-SS7-MIB.txt b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SS7-MIB.txt new file mode 100644 index 0000000..dcbc749 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/WXC2-SS7-MIB.txt @@ -0,0 +1,3729 @@ +WXC2-SS7-MIB DEFINITIONS ::= BEGIN +IMPORTS + OBJECT-TYPE, Integer32, Opaque + FROM SNMPv2-SMI + TEXTUAL-CONVENTION, DisplayString, TruthValue + FROM SNMPv2-TC + Platform + FROM WXC2-SMI; + +SS7 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Subsystems for SS7 . + " + ::= { Platform 2 } + + +-- +-- sub system MTP3 +-- + +MTP3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for MTP3 . + " + ::= { SS7 2 } + +Config_MTP3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MTP3 Configuration. " + ::= { MTP3 2 } + +Network_Indicator OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Field: [1]International network + { + [u]0.0-0.0 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [2]International network spare + { + [u]0.1-0.1 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [3]National network + { + [u]0.2-0.2 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [4]National network spare + { + [u]0.3-0.3 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [5]International network + { + [u]0.4-0.4 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [6]International network spare + { + [u]0.5-0.5 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [7]National network + { + [u]0.6-0.6 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [8]National network spare + { + [u]0.7-0.7 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + Remark: MTP3 network indicator. + [End] + " + ::= { Config_MTP3 2 } + + + + +OPC OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Originating point code. " + ::= { Config_MTP3 3 } + +International_14bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 14-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 1 } + +International_Spare_14bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 14-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 2 } + +National_14bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 14-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 3 } + +National_Spare_14bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 14-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 4 } + +International_24bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 24-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 5 } + +International_Spare_24bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 24-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 6} + +National_24bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 24-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 7 } + +National_Spare_24bit OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: [1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + Remark: 24-bit originating point code (OPC) in an international network. Default=0. + [End] + " + ::= { OPC 8 } + +Linkset OBJECT-IDENTITY + STATUS current + DESCRIPTION + " linkset. " + ::= { Config_MTP3 4 } + +Linkset_Attributes OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 128 + Length: 4 + Default: 00000000 + Field: [1]Linkset DPC + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + [2]Network indicator + { + [u]3.0-3.1 + [u]select + [v]0[opt]International + [v]1[opt]International spare + [v]2[opt]National + [v]3[opt]National spare + } + [3]Reserved + { + [u]3.2-3.2 + [u]select + } + [4]Linkset loopback + { + [u]3.3-3.3 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [5]Reserved + { + [u]3.4-3.7 + [u]select + } + Remark: Opposite point code: The opposite point code of the linkset. + Network indicator: The network type of the opposite point code. + Loop back: Loop back enable or disable, used for MSC loop back link. + [End] + " + ::= { Linkset 1 } + +Link OBJECT-IDENTITY + STATUS current + DESCRIPTION + " link. " + ::= { Config_MTP3 5 } + +Link_Attributes OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 15 + Default: 8010FFFFFFFF000000000000000000 + Field: [1]Linkset no. + { + [u]00.0-00.7 + [u]input + [v]toDec-high-0 + } + [2]SLC no. + { + [u]01.0-01.7 + [u]input + [v]toDec-high-0 + } + [3]CPC IP + { + [u]02.0-05.7 + [u]input + [v]keepHex-high-0 + } + [4]Link Type + { + [u]06.0-06.0 + [u]select + [v]0[opt]Non-sigtran + [v]1[opt]Sigtran + } + [5]Link Enable + { + [u]06.1-06.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [6]MTP3-Lite Enable + { + [u]06.2-06.2 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [7]Reserved + { + [u]06.3-06.7 + [u]select + } + [8]SG no. + { + [u]07.0-07.7 + [u]input + [v]toDec-high-0 + } + [9]M2UA Interface ID + { + [u]08.0-08.7 + [u]input + [v]toDec-high-0 + } + [10]MTP3-Lite Remote IP + { + [u]09.0-12.7 + [u]input + [v]keepHex-high-0 + } + [11]MTP3-Lite Inactivity Timeout + { + [u]13.0-13.7 + [u]input + [v]toDec-high-0 + } + [12]MTP3-Lite Allowed Inactivity Timeouts + { + [u]14.0-14.7 + [u]input + [v]toDec-high-0 + } + Remark: E1 link attributes. + Linkset no.: Assign linkset to E1 link, MSC has up to 128 linksets (0-127). 128=TCH E1. + SLC no.: Assign SLC to each E1 link of a linkset, each linkset has up to 13 E1 links (0-15). + IP: E1 link management IP. The third byte of CPC IP: + 98=E1 link 0-127, 99=E1 link 128-255. + Default=0x000032. + [End] + " + ::= { Link 1 } + +Link_Command OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 01 + Field: [1]E1 link + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + [v]2[opt]Inhibit + [v]3[opt]Uninhibit + } + Remark: Used for E1 link control, not affect call traffic. + Disable=Disable E1 link MTP2 layer. + Enable=Enable a disabled E1 link MTP2 layer. + Inhibit=Inhibit E1 link MTP3 layer. + Uninhibit=Uninhibit a inhibited E1 link MTP3 layer. + Default=Enable a disabled E1 link MTP2 layer. + [End] + " + ::= { Link 2 } + +TCP_Port OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-writed + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 1388 + Field: [1]TCP Port + { + [u]0.0-1.7 + [u]input + [v]toDec-high-0 + } + Remark: TCP server port for SCCP-Lite. + [End] + " + ::= { Link 3 } + +Routing OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Routing. " + ::= { Config_MTP3 6 } + +International OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 5 + Default: 0000008080 + Field: [1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + [2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + [3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec-high-0 + } + Remark: Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + [End] + " + ::= { Routing 1 } + +International_Spare OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 5 + Default: 0000008080 + Field: [1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + [2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + [3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec-high-0 + } + Remark: Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + [End] + " + ::= { Routing 2 } + +National OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 5 + Default: 0000008080 + Field: [1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + [2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + [3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec-high-0 + } + Remark: Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + [End] + " + ::= { Routing 3 } + +National_Spare OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 5 + Default: 0000008080 + Field: [1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec-high-0 + } + [2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + [3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec-high-0 + } + Remark: Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + [End] + " + ::= { Routing 4 } + +SPC_to_ACN OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SPC to ACN. " + ::= { Config_MTP3 7 } + +Local_ACN OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 36 + Default: 030303030202020202030302020303020303020303030303030303030303030302020202 + Field: [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + Remark: The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + [End] + " + ::= { SPC_to_ACN 1 } + +International OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 36 + Default: 030303030202020202030302020303020303020303030303030303030303030302020202 + Field: [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + Remark: The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + [End] + " + ::= { SPC_to_ACN 2 } + +International_Spare OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 36 + Default: 030303030202020202030302020303020303020303030303030303030303030302020202 + Field: [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + Remark: The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + [End] + " + ::= { SPC_to_ACN 3 } + +National OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 36 + Default: 030303030202020202030302020303020303020303030303030303030303030302020202 + Field: [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + Remark: The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + [End] + " + ::= { SPC_to_ACN 4 } + +National_Spare OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 36 + Default: 030303030202020202030302020303020303020303030303030303030303030302020202 + Field: [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + Remark: The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + [End] + " + ::= { SPC_to_ACN 5 } + +Signaling_Gateway OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 7 + Default: 00000000000000 + Field: [1]Enable + { + [u]00.0-00.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Server + { + [u]01.0-01.7 + [u]select + [v]0[opt]Client + [v]1[opt]Server + } + [3]ACK + { + [u]02.0-02.7 + [u]select + [v]0[opt]no ACK + [v]1[opt]ACK + } + [4]IP + { + [u]03.0-06.7 + [u]input + [v]keepHex-high-0 + } + Remark: SG attributes + [End] + " + ::= { Config_MTP3 9 } + +Status_MTP3 OBJECT-IDENTITY + STATUS current + DESCRIPTION + " MTP3 Status. " + ::= { MTP3 3 } + +Link_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 01 + Field: [1]Link status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Unavailable + [v]1[opt]Available + [v]2[opt]Inhibited + } + Remark: E1 link MTP3 status (Read Only). + [End] + " + ::= { Status_MTP3 1 } + +Linkset_Status OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 128 + Length: 1 + Default: 01 + Field: [1]Linkset status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Unavailable + [v]1[opt]Available + [v]2[opt]Reserved + } + Remark: Linkset status (Read only). + [End] + " + ::= { Status_MTP3 2 } + +International_Routing OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 8A + Field: [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + Remark: Normal linkset status (bit0-1): + - 0=Available + - 1=Reserved + - 2=Unavailable + Alternative linkset status (bit2-3): + - 0=Available + - 1=Reserved + - 2=Unavailable + DPC accessibility (bit4): + - 0=Inaccessible + - 1=Accessible + Current route (bit3-7): + - 0=Normal linkset + - 1=Alternative linkset + - 2=No route. + [End] + " + ::= { Status_MTP3 3 } + +International_Spare_Routing OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 8a + Field: [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + + Remark: Normal linkset status (bit0-1): + - 0=Available + - 1=Reserved + - 2=Unavailable + Alternative linkset status (bit2-3): + - 0=Available + - 1=Reserved + - 2=Unavailable + DPC accessibility (bit4): + - 0=Inaccessible + - 1=Accessible + Current route (bit3-7): + - 0=Normal linkset + - 1=Alternative linkset + - 2=No route. + [End] + " + ::= { Status_MTP3 4 } + +National_Routing OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 8a + Field: [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + Remark: Normal linkset status (bit0-1): + - 0=Available + - 1=Reserved + - 2=Unavailable + Alternative linkset status (bit2-3): + - 0=Available + - 1=Reserved + - 2=Unavailable + DPC accessibility (bit4): + - 0=Inaccessible + - 1=Accessible + Current route (bit3-7): + - 0=Normal linkset + - 1=Alternative linkset + - 2=No route. + [End] + " + ::= { Status_MTP3 5 } + +National_Spare_Routing OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 1 + Default: 8a + Field: [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + Remark: Normal linkset status (bit0-1): + - 0=Available + - 1=Reserved + - 2=Unavailable + Alternative linkset status (bit2-3): + - 0=Available + - 1=Reserved + - 2=Unavailable + DPC accessibility (bit4): + - 0=Inaccessible + - 1=Accessible + Current route (bit3-7): + - 0=Normal linkset + - 1=Alternative linkset + - 2=No route. + [End] + " + ::= { Status_MTP3 6 } + + + +Command_MTP3 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag :S1.3 + Field: [1]command + { + [u]0.0-0.7 + [u]select + [v]0[opt]No command + [v]1[opt]Reset + [v]2[opt]Save parameter + } + Remark: Control command for MTP3 platform. + Reset=status initialization. + Save parameter=save parameters residing in memory into harddisk. + [End] + " + ::= { Status_MTP3 7 } + +-- +-- sub system SCCP +-- + +SCCP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for SCCP . + " + ::= { SS7 3 } + +Config_SCCP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SCCP Configuration. " + ::= { SCCP 2 } + +Local_Node OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Local Node. " + ::= { Config_SCCP 1 } + +OMC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: OMC E.134 number. + IP0: OMC0 IP, 172.18.128.1. + IP1: OMC1 IP, 172.18.129.1. + [End] + " + ::= { Local_Node 4 } + +HLR OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: HLR E.134 number. + IP0: HLR0 IP, 172.18.98.1. + IP1: HLR1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 6 } + +VLR OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: VLR E.134 number. + IP0: VLR0 IP, 172.18.98.1. + IP1: VLR1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 7 } + +MSC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: MSC E.134 number. + IP0: MSC0 IP, 172.18.98.1. + IP1: MSC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 8 } + +EIR OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: EIR E.134 number. + IP0: EIR0 IP, 172.18.98.1. + IP1: EIR1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 9 } + +AUC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: AUC E.134 number. + IP0: AUC0 IP, 172.18.98.1. + IP1: AUC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 10 } + +SMSC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: SMSC E.134 number. + IP0: OMC0 IP, 172.18.98.1. + IP1: OMC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 11 } + +SMPP_EMSE OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: VMS-SMPP E.134 number. + IP0: VMS0 IP, 172.18.147.1. + IP1: VMS1 IP, 172.18.148.1. + [End] + " + ::= { Local_Node 19 } + +SMPP_SMSC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: SMSC-SMPP E.134 number. + IP0: SMSC0 IP, 172.18.98.1. + IP1: SMSC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 20 } + +SMPP_OMC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: OMC-SMPP E.134 number. + IP0: OMC0 IP, 172.18.128.1. + IP1: OMC1 IP, 172.18.129.1. + [End] + " + ::= { Local_Node 21 } + +SRF OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: VMS SRF E.134 number. + IP0: VMS0 IP, 172.18.147.1. + IP1: VMS1 IP, 172.18.148.1. + [End] + " + ::= { Local_Node 22 } + +SSF OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: MSC SSF E.134 number. + IP0: MSC0 IP, 172.18.98.1. + IP1: MSC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 143 } + +SCF OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: PPS SCF E.134 number. + IP0: PPS0 IP, 172.18.98.1. + IP1: PPS1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 147 } + +AIF OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 19 + Default: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + Field: [1]NI + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-F + } + [2]MSISDN + { + [u]01.0-10.7 + [u]input + [v]keepHex-low-F + } + [3]IP0 + { + [u]11.0-14.7 + [u]input + [v]keepHex-low-F + } + [4]IP1 + { + [u]15.0-18.7 + [u]input + [v]keepHex-low-F + } + Remark: NI: Network indicator. + 0=International network. + 1=International network spare. + 2=National network. + 3=National network spare. + MSISDN: AIF E.134 number. + IP0: MSC0 IP, 172.18.98.1. + IP1: MSC1 IP, 172.18.99.1. + [End] + " + ::= { Local_Node 254 } + +GTT_Table OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 43 + Default: 000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000007000000FFFFFFFFFFFFFFFFFFFF + Field: [1]On/off + { + [u]00.0-00.7 + [u]select + [v]1[opt]On + [v]0[opt]Off + } + [2]Numbering plan + { + [u]01.0-01.7 + [u]select + [v]0[opt]0 + [v]1[opt]MSISDN + [v]6[opt]IMSI + [v]7[opt]GT + } + [3]TT + { + [u]02.0-02.7 + [u]input + [v]keepHex-low-F + } + [4]Start GT number + { + [u]03.0-12.7 + [u]input + [v]keepHex-low-F + } + [4]End GT number + { + [u]13.0-22.7 + [u]input + [v]keepHex-low-F + } + [5]Network indicator + { + [u]23.0-23.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + } + [6]DPC + { + [u]24.0-26.7 + [u]input + [v]toDec-high-0 + } + [7]SSN + { + [u]27.0-27.7 + [u]input + [v]toDec-high-0 + } + [8]Route indicator + { + [u]28.0-28.7 + [u]select + [v]0[opt]Route on GT + [v]1[opt]Route on SSN + } + [9]Address indicator + { + [u]29.0-29.7 + [u]select + [v]0[opt]NULL + [v]3[opt]DPC+SSN + [v]6[opt]GT+SSN + [v]7[opt]GT+DPC+SSN + } + [10]Replaced start digit + { + [u]30.0-30.7 + [u]input + [v]keepHex-high-0 + } + [11]Replaced end digit + { + [u]31.0-31.7 + [u]input + [v]keepHex-high-0 + } + [12]Outgoing number plan + { + [u]32.0-32.7 + [u]select + [v]1[opt]MSISDN + [v]6[opt]IMSI + [v]7[opt]GT + } + [13]Replacing digits + { + [u]33.0-42.7 + [u]input + [v]keepHex-low-F + } + Remark: On/off: GTT flag, off=disable, on=enable. + Numbering plan: 1=MSISDN, 3=IMSI, 7=GT. + Specify the beginning number of a group of consecutive numbers routed by GTT, for single-number GTT route, the start number is same as the end number. + End GT number: Specify the end number of a group of consecutive number routed by GT. If there are some inconsecutive numbers for a same destination, a different GTT record should be set. + Network indicator (NI): 0=International network, 1=International network spare, 2=National network, 3=National network spare, + DPC: Destination point code. + SSN: Subsystem number. + 2=Reserved for ITU-T allocation. + 3=ISDN user part. + 4=OMC. + 5=MAP. + 3=HLR. + 7=VLR. + 8=MSC. + 9=EIR. + 10=AUC. + 11=SMSC. + 147=PPS. + 254=BSSMAP. + Route indicator: For IMSI and MSISDN, select Route on SSN. For the record of the connected network, select Route on GT. + Address indicator: select the contribution of SCCP Address. + Replaced start digit: Specify the beginning digit of a segment of digits to be replaced within a GT number, the replacement is for changing number and numbering plan. + Replaced end digit: Specify the end digit of a segment of digits to be replaced within a GT number, the replacement is for changing number and numbering plan. + Outgoing number plan: Outgoing number plan, include MSISDN, IMSI and GT. + Replacing digits: Replacing digits, the length of replacing digits and replaced digits may be different. + [End] + " + ::= { Config_SCCP 2 } + +Management OBJECT-IDENTITY + STATUS current + DESCRIPTION + " Management. " + ::= { SCCP 3 } + +Version OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: + Remark: Version of SCCP platform software (Read Only). + Byte0: System release version number, based on basic function and structure. + Byte1: Software module version number, based on software module. + Byte2: Test version, 0=Release version number, 1=Test version number. + [End] + " + ::= { Management 1 } + +Command_SCCP OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag : S1.2 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]0[opt]Reset + [v]2[opt]Save parameters + } + Remark: Control command for SCCP. + Reset: Used for SCCP status initialization. + Load parameter: Load the parameters from device's harddisk to device's memory. + Save parameter: Save the parameters residing in device's memory into device's harddisk. + [End] + " + ::= { Management 2 } + +-- +-- sub system XAPP +-- + +XAPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for XAPP . + " + ::= { SS7 5 } + +Config_XAPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " XAPP Configuration. " + ::= { XAPP 2 } + +MCC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 460E + Field: [1]MCC + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + + Remark: Mobile country code. + [End] + " + ::= { Config_XAPP 1 } + +MNC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 02 + Field: [1]MNC + { + [u]00.0-00.7 + [u]input + [v]keepHex-low-E + } + Remark: Mobile network code. + [End] + " + ::= { Config_XAPP 2 } + +CC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 86EE + Field: [1]CC + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + Remark: Country code. + [End] + " + ::= { Config_XAPP 3 } + +NDC OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 755EEE + Field: [1]NDC + { + [u]00.0-02.7 + [u]input + [v]keepHex-low-E + } + Remark: National destination code. + [End] + " + ::= { Config_XAPP 4 } + +International_Prefix OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 00ee + Field: [1]International prefix + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + Remark: International call prefix. + [End] + " + ::= { Config_XAPP 5 } + +National_Prefix OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: 0EEE + Field: [1]National prefix + { + [u]00.0-01.7 + [u]input + [v]keepHex-low-E + } + + Remark: National call prefix. + [End] + " + ::= { Config_XAPP 6 } + +Local_Prefix OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 2 + Default: EEEE + Field: + Remark: Local prefix. + [End] + " + ::= { Config_XAPP 7 } + +Conv_Prefix OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 128 + Length: 35 + Default: 0000000000000000000000000000000000000000000000000000000000000000000000 + Field: [1]Prefix + { + [u]00.0-15.7 + [u]input + [v]toAscii-low-0 + } + [2]Delete length + { + [u]16.0-16.7[u]input + [v]toDec-high-0 + } + [3]Add length + { + [u]17.0-17.7 + [u]input + [v]toDec-high-0 + } + [4]Add digits + { + [u]18.0-33.7 + [u]input + [v]toAscii-low-0 + } + [5]Valid length + { + [u]34.0-34.7 + [u]input + [v]toDec-high-0 + } + Remark: Conv prefix . + [End] + " + ::= { Config_XAPP 8 } + +CLI_Conv_Prefix OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 8 + Length: 37 + Default: 0000000000000000000000000000000000000000000000000000000000000000000000 + Field: [1]In property + { + [u]00.0-00.7 + [u]select + [v]1[opt]IDD + [v]2[opt]NDD + [v]3[opt]Unknown + } + [2]Prefix + { + [u]01.0-16.7 + [u]input + [v]toAscii-low-0 + } + [3]Delete length + { + [u]17.0-17.7 + [u]input + [v]toDec-high-0 + } + [4]Out property + { + [u]18.0-18.7 + [u]select + [v]1[opt]IDD + [v]2[opt]NDD + [v]3[opt]Unknown + } + [5]Add length + { + [u]19.0-19.7 + [u]input + [v]toDec-high-0 + } + [6]Add digits + { + [u]20.0-35.7 + [u]input + [v]toAscii-low-0 + + } + [7]Valid length + { + [u]36.0-36.7 + [u]input + [v]toDec-high-0 + } + Remark: CLI_Conv prefix . + [End] + " + ::= { Config_XAPP 9 } + +mscid_to_number OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 256 + Length: 12 + Default: 00000000EEEEEEEEEEEEEEEE + Field: + + [1]Market ID + { + [u]0.0-1.7 + [u]input + [v]toDec-high-0 + } + [2]Switch Number + { + [u]2.0-2.7 + [u]input + [v]toDec-high-0 + } + [3]SSN + { + [u]3.0-3.7 + [u]input + [v]toDec-high-0 + } + [4]Number + { + [u]04.0-11.7 + [u]input + [v]keepHex-low-E + } + Remark: Conv prefix . + [End] + " + ::= { Config_XAPP 10 } + +Status_XAPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " XAPP Status. " + ::= { XAPP 3 } + +Version_XAPP OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 3 + Default: 000000 + Field: + Remark: Version of XAPP module (Read Only). + Byte0: System release version number, based on basic function and structure. + Byte1: Software module version number, based on software module. + Byte2: Test version, 0=Release version number, 1=Test version number. + [End] + " + ::= { Status_XAPP 1 } + +Command_XAPP OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 00 + Flag: S1.1 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]01[opt]Save parameters + } + Remark: Control command for XAPP. + Save parameter: Save the parameters in memory into local harddisk. + [End] + " + ::= { Status_XAPP 2 } + +Maplat OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + Subsystems for Maplat . + " + ::= { Platform 3 } +-- +-- sub system SMPP +-- + +SMPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " + [SubSystem_Module]Subsystems for SMPP . + " + ::= { Maplat 4 } + +Config_SMPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " SMPP Configuration. " + ::= { SMPP 2 } +SMPP_Link_Parameter OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + " + [Begin] + Instance: 32 + Length: 106 + Default: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Field:[1]Link enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Link type + { + [u]1.0-1.7 + [u]select + [v]0[opt]UDP + [v]1[opt]TCP + } + [3]Server type + { + [u]2.0-2.7 + [u]select + [v]0[opt]SMPP_CLIENT + [v]1[opt]SMPP_SERVER + } + [4]Session type + { + [u]3.0-3.7 + [u]select + [v]00[opt]BIND_TX + [v]01[opt]BIND_RX + [v]02[opt]BIND_TRX + } + [5]System ID + { + [u]4.0-19.7 + [u]input + [v]toAscii-low-0 + } + [6]Password + { + [u]20.0-28.7 + [u]input + [v]toAscii-low-0 + } + [7]System type + { + [u]29.0-41.7 + [u]input + [v]toAscii-low-0 + } + [8]Local GTT + { + [u]42.0-57.7 + [u]input + [v]toAscii-low-0 + } + [9]Remote GTT + { + [u]58.0-73.7 + [u]input + [v]toAscii-low-0 + } + [10]Local IP + { + [u]74.0-77.7 + [u]input + [v]keepHex-low-F + } + [11]Remote IP + { + [u]78.0-81.7 + [u]input + [v]keepHex-low-F + } + [12]Session init timer + { + [u]82.0-85.7 + [u]input + [v]toDec-high-0 + } + [13]Enquire link timer + { + [u]86.0-89.7 + [u]input + [v]toDec-high-0 + } + [14]Inactivity timer + { + [u]90.0-93.7 + [u]input + [v]toDec-high-0 + } + [15]Response timer + { + [u]94.0-97.7 + [u]input + [v]toDec-high-0 + } + [16]Remote service number + { + [u]98.0-105.7 + [u]input + [v]toAscii-low-0 + } + + Remark: Session type: BIND_TX-bind as transmitter, BIND_RX-bind as receiver, BIND_TRX-bind as transceiver. + System ID: using in BIND and OUTBIND. + Password: The password parameter is used by the SMSC to authenticate the identity of the binding ESME. The Service Provider may require ESME’s to provide a password when binding to the SMSC. This password is normally issued by the SMSC system administrator. + The password parameter may also be used by the ESME to authenticate the identity of the binding SMSC (e.g. in the case of the outbind operation). + System type: The system_type may be used to categorise the system, e.g., “EMAIL”, “WWW”, etc. + The system_type parameter is used to categorize the type of ESME that is binding to the SMSC. Examples include “VMS” (voice mail system) and “OTA” (over-the-air activation system). + Specification of the system_type is optional - some SMSC’s may not require ESME’s to provide this detail. In this case, the ESME can set the system_type to NULL. + IP: Specify the IP addresses of 16 SMPP connected devices.
e.g. 0xAC127001=172.18.112.1.
+ Session init timer: This timer specifies the time lapse allowed between a network connection being established and a bind_transmitter or bind_receiver request being sent to SMSC. This timer should be active on the SMSC. + Enquire link timer: This timer specifies the time lapse allowed between operations after which an SMPP entity should interrogate whether it's peer still has an active session. + The scale is second. + Inactivity timer: This timer specifies the maximum time lapse allowed between transactions, after which period of inactivity, an SMPP entity may assume that the session is no longer active. This timer may be active on either commnicating SMPP entity(i.e. SMSC or ESME) + Response timer: This timer specifies the maximum time lapse allowed between transactions, after which period of inactivity, an SMPP entity may assume that the session is no longer active. This timer may be active on either commnicating SMPP entity(i.e. SMSC or ESME) + Local service number: compare with application's service number while bind as TX or TRX. + remote service number: compare with application's service number while bind as RX + [End] + " + ::= { Config_SMPP 1 } + + +Status_SMPP OBJECT-IDENTITY + STATUS current + DESCRIPTION + " XAPP Status. " + ::= { SMPP 3 } + +Command_SMPP OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS write-only + STATUS current + DESCRIPTION + " + [Begin] + Instance: 1 + Length: 1 + Default: 02 + Flag :S1.1 + Field: [1]Command + { + [u]00.0-00.7 + [u]select + [v]2[opt]save parameter + } + Remark: Control command for SMPP. + [End] + " + ::= { Status_SMPP 2 } + + +END diff --git a/omc/plat/smpp/ut/conf/MIB_files/menu_page b/omc/plat/smpp/ut/conf/MIB_files/menu_page new file mode 100644 index 0000000..f7d1b26 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/menu_page @@ -0,0 +1,13 @@ + + ******************* + * Module Page * + ******************* + + a -- IPTR i -- HLR + b -- MTP3 j -- SMSC + c -- SCCP k -- PPS + d -- TCAP l -- SNMP + e -- XAPP m -- M2UA + f -- MSC n -- DEBUG + g -- VLR o -- AUC + h -- SSF p -- EIR diff --git a/omc/plat/smpp/ut/conf/MIB_files/menu_tree.txt b/omc/plat/smpp/ut/conf/MIB_files/menu_tree.txt new file mode 100644 index 0000000..ef78494 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/menu_tree.txt @@ -0,0 +1,908 @@ +############## The debug menu tree config file root=wxc2 root_oid={1.3.6.1.4.1.1373.1.3} +#(0)(1)(2)(9) ip group +#/ the layer +#.1.1.3. menu_id +#{3.2.2.1.2} the last oid from the root +#[name] menu name +#M:8 the id of the menu in the current object +############## all the line must end for ';',and menu id and last oid must do not contain space + +##WXC2 +/. (9); + +M:1 [MSC] {3.2}; +M:2 [VLR] {3.2.5}; +M:3 [HLR] {3.3}; +M:4 [PPS] {3.6}; +M:5 [SMSC] {3.5}; +M:6 [AUC] {3.4}; +##M:7 [EIR] {3.8}; + +##MSC +/ /.1. (9); + +M:1 [Prefix Assignment] {3.2.2.2.1.1}; +M:2 [Prefix Attributes] {3.2.2.2.1.2}; +M:3 [Assign TG to Prefix] {3.2.2.2.1.3}; +M:4 [TG attributes] {3.2.2.2.1.4}; +M:5 [CDR Flag] {3.2.2.2.1.5}; +M:6 [Announcement Option] {3.2.2.2.1.6}; +M:7 [Warning tone] {3.2.2.2.1.7}; +M:8 [Emergency call] {3.2.2.2.2.5}; +M:9 [Location management] {3.2.2.2.2.8}; +M:10 [Max. call duration] {3.2.2.2.3.7}; +M:11 [E1 Port] {3.2.2.2.4}; +M:12 [channel attributes] {3.2.2.2.5}; +M:13 [Platform] {2}; +M:14 [MSC0] (1) {3.2}; +M:15 [MSC1] (2) {3.2}; + +##MSC->E1 Port +/ / /.1.11. (9); + +M:1 [E1 interface] {3.2.2.2.4.1}; +M:2 [Assign TG to E1] {3.2.2.2.4.2}; +M:3 [CIC of E1] {3.2.2.2.4.3}; + +##MSC->channel attributes->8K card 0-31 +/ / /.1.12. (9); + +M:1 [Card 0 channel attributes] {3.2.2.2.5.1}; +M:2 [Card 1 channel attributes] {3.2.2.2.5.2}; +M:3 [Card 2 channel attributes] {3.2.2.2.5.3}; +M:4 [Card 3 channel attributes] {3.2.2.2.5.4}; +M:5 [Card 4 channel attributes] {3.2.2.2.5.5}; +M:6 [Card 5 channel attributes] {3.2.2.2.5.6}; +M:7 [Card 6 channel attributes] {3.2.2.2.5.7}; +M:8 [Card 7 channel attributes] {3.2.2.2.5.8}; +M:9 [Card 8 channel attributes] {3.2.2.2.5.9}; +M:10 [Card 9 channel attributes] {3.2.2.2.5.10}; +M:11 [Card 10 channel attributes] {3.2.2.2.5.11}; +M:12 [Card 11 channel attributes] {3.2.2.2.5.12}; +M:13 [Card 12 channel attributes] {3.2.2.2.5.13}; +M:14 [Card 13 channel attributes] {3.2.2.2.5.14}; +M:15 [Card 14 channel attributes] {3.2.2.2.5.15}; +M:16 [Card 15 channel attributes] {3.2.2.2.5.16}; +M:17 [Card 16 channel attributes] {3.2.2.2.5.17}; +M:18 [Card 17 channel attributes] {3.2.2.2.5.18}; +M:19 [Card 18 channel attributes] {3.2.2.2.5.19}; +M:20 [Card 19 channel attributes] {3.2.2.2.5.20}; +M:21 [Card 20 channel attributes] {3.2.2.2.5.21}; +M:22 [Card 21 channel attributes] {3.2.2.2.5.22}; +M:23 [Card 22 channel attributes] {3.2.2.2.5.23}; +M:24 [Card 23 channel attributes] {3.2.2.2.5.24}; +M:25 [Card 24 channel attributes] {3.2.2.2.5.25}; +M:26 [Card 25 channel attributes] {3.2.2.2.5.26}; +M:27 [Card 26 channel attributes] {3.2.2.2.5.27}; +M:28 [Card 27 channel attributes] {3.2.2.2.5.28}; +M:29 [Card 28 channel attributes] {3.2.2.2.5.29}; +M:30 [Card 29 channel attributes] {3.2.2.2.5.30}; +M:31 [Card 30 channel attributes] {3.2.2.2.5.31}; +M:32 [Card 31 channel attributes] {3.2.2.2.5.32}; + + +##MSC->Platform +/ / /.1.13. (9); + +M:1 [MTP3] {2.2.2}; +M:2 [SCCP] {2.2.3}; +M:3 [XAPP] {2.2.5}; + +##MSC->Platform->MTP3 +/ / /.1.13.1. (9); + +M:1 [Network Indicator] {2.2.2.2.2}; +M:2 [Originating Point code] {2.2.2.2.3}; +M:3 [Link Set] {2.2.2.2.4}; +M:4 [Link] {2.2.2.2.5}; +M:5 [Routing] {2.2.2.2.6}; +M:6 [ACN] {2.2.2.2.7}; +M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##MSC->Platform->MTP3->Status +/ / /.1.13.1.7. (9); + +M:1 [Link status] {2.2.2.3.1}; +M:2 [Link set status] {2.2.2.3.2}; +M:3 [International routing] {2.2.2.3.3}; +M:4 [International spare] {2.2.2.3.4}; +M:5 [National routing] {2.2.2.3.5}; +M:6 [National spare routing] {2.2.2.3.6}; +M:7 [Command] {2.2.2.3.7}; + +##MSC->Platform->SCCP +/ / /.1.13.2. (9); + +M:1 [Local node] {2.2.3.2.1}; +M:2 [GTT] {2.2.3.2.2}; +M:3 [Command] {2.2.3.3.2}; + +##MSC->Platform->XAPP +/ / /.1.13.3. (9); + +M:1 [MCC] {2.2.5.2.1}; +M:2 [MNC] {2.2.5.2.2}; +M:3 [CC] {2.2.5.2.3}; +M:4 [NDC] {2.2.5.2.4}; +M:5 [International prefix] {2.2.5.2.5}; +M:6 [National Prefix] {2.2.5.2.6}; +M:7 [Local Prefix] {2.2.5.2.7}; +M:8 [Convert Prefix] {2.2.5.2.8}; +M:9 [Command] {2.2.5.3.2}; + + +##MSC->MSC0->E1 status +/ / /.1.14. (1); + +M:1 [E1 Status] {3.2.2.3.4}; +M:2 [Channel Status] {3.2.2.3.5}; +##M:3 [CSU0] {1.1}; + + +##MSC->MSC1->E1 status +/ / /.1.15. (2); + +M:1 [E1 Status] {3.2.2.3.4}; +M:2 [Channel Status] {3.2.2.3.5}; +##M:3 [CSU1] {1.1}; + + +##MSC->MSC0->Channel Status +/ / / /.1.14.2. (1); + +M:1 [8K Card 0] {3.2.2.3.5.1}; +M:2 [8K Card 1] {3.2.2.3.5.2}; +M:3 [8K Card 2] {3.2.2.3.5.3}; +M:4 [8K Card 3] {3.2.2.3.5.4}; +M:5 [8K Card 4] {3.2.2.3.5.5}; +M:6 [8K Card 5] {3.2.2.3.5.6}; +M:7 [8K Card 6] {3.2.2.3.5.7}; +M:8 [8K Card 7] {3.2.2.3.5.8}; +M:9 [8K Card 8] {3.2.2.3.5.9}; +M:10 [8K Card 9] {3.2.2.3.5.10}; +M:11 [8K Card 10] {3.2.2.3.5.11}; +M:12 [8K Card 11] {3.2.2.3.5.12}; +M:13 [8K Card 12] {3.2.2.3.5.13}; +M:14 [8K Card 13] {3.2.2.3.5.14}; +M:15 [8K Card 14] {3.2.2.3.5.15}; +M:16 [8K Card 15] {3.2.2.3.5.16}; + + +##MSC->MSC1->channel status +/ / / /.1.15.2. (2); + +M:1 [8K Card 0] {3.2.2.3.5.1}; +M:2 [8K Card 1] {3.2.2.3.5.2}; +M:3 [8K Card 2] {3.2.2.3.5.3}; +M:4 [8K Card 3] {3.2.2.3.5.4}; +M:5 [8K Card 4] {3.2.2.3.5.5}; +M:6 [8K Card 5] {3.2.2.3.5.6}; +M:7 [8K Card 6] {3.2.2.3.5.7}; +M:8 [8K Card 7] {3.2.2.3.5.8}; +M:9 [8K Card 8] {3.2.2.3.5.9}; +M:10 [8K Card 9] {3.2.2.3.5.10}; +M:11 [8K Card 10] {3.2.2.3.5.11}; +M:12 [8K Card 11] {3.2.2.3.5.12}; +M:13 [8K Card 12] {3.2.2.3.5.13}; +M:14 [8K Card 13] {3.2.2.3.5.14}; +M:15 [8K Card 14] {3.2.2.3.5.15}; +M:16 [8K Card 15] {3.2.2.3.5.16}; + + +##MSC->MSC0->CSU0 +##/ / / / /.1.14.3. (1); + +##M:1 [E1 enable] {1.1.1.2.1}; +##M:2 [MTP alarm on/off] {1.1.1.2.2}; +##M:3 [Link type] {1.1.1.2.3}; +##M:4 [NT/LT] {1.1.1.2.4}; +##M:5 [DPLL priority] {1.1.1.2.5}; +##M:6 [CRC4 flag] {1.1.1.2.6}; +##M:7 [Ringback Tone] {1.1.1.2.7.1}; +##M:8 [Busy Tone] {1.1.1.2.7.2}; +##M:9 [Unavailable Tone] {1.1.1.2.7.3}; +##M:10 [Congestion Tone] {1.1.1.2.7.4}; +##M:11 [Proceeding Tone] {1.1.1.2.7.5}; +##M:12 [Warning tone] {1.1.1.2.7.6}; +##M:13 [Tone assignment] {1.1.1.2.7.9}; +##M:14 [DTMF mark&space] {1.1.1.2.7.10}; +##M:15 [8KE1_0] (0) {1.1.1.3}; +##M:16 [8KE1_1] (0) {1.1.1.3}; +##M:17 [8KE1_2] (0) {1.1.1.3}; +##M:18 [8KE1_3] (0) {1.1.1.3}; +##M:19 [8KE1_4] (0) {1.1.1.3}; +##M:20 [8KE1_5] (0) {1.1.1.3}; +##M:21 [8KE1_6] (0) {1.1.1.3}; +##M:22 [8KE1_7] (0) {1.1.1.3}; +##M:23 [8KE1_8] (0) {1.1.1.3}; +##M:24 [8KE1_9] (0) {1.1.1.3}; +##M:25 [8KE1_10] (0) {1.1.1.3}; +##M:26 [8KE1_11] (0) {1.1.1.3}; +##M:27 [8KE1_12] (0) {1.1.1.3}; +##M:28 [8KE1_13] (0) {1.1.1.3}; +##M:29 [8KE1_14] (0) {1.1.1.3}; +##M:30 [8KE1_15] (0) {1.1.1.3}; + + +##MSC->MSC1->CSU1 +##/ / / / /.1.15.3. (2); + +##M:1 [E1 enable] {1.1.1.2.1}; +##M:2 [MTP alarm on/off] {1.1.1.2.2}; +##M:3 [Link type] {1.1.1.2.3}; +##M:4 [NT/LT] {1.1.1.2.4}; +##M:5 [DPLL priority] {1.1.1.2.5}; +##M:6 [CRC4 flag] {1.1.1.2.6}; +##M:7 [Ringback Tone] {1.1.1.2.7.1}; +##M:8 [Busy Tone] {1.1.1.2.7.2}; +##M:9 [Unavailable Tone] {1.1.1.2.7.3}; +##M:10 [Congestion Tone] {1.1.1.2.7.4}; +##M:11 [Proceeding Tone] {1.1.1.2.7.5}; +##M:12 [Warning tone] {1.1.1.2.7.6}; +##M:13 [Tone assignment] {1.1.1.2.7.9}; +##M:14 [DTMF mark&space] {1.1.1.2.7.10}; +##M:15 [8KE1_0] (0) {1.1.1.3}; +##M:16 [8KE1_1] (0) {1.1.1.3}; +##M:17 [8KE1_2] (0) {1.1.1.3}; +##M:18 [8KE1_3] (0) {1.1.1.3}; +##M:19 [8KE1_4] (0) {1.1.1.3}; +##M:20 [8KE1_5] (0) {1.1.1.3}; +##M:21 [8KE1_6] (0) {1.1.1.3}; +##M:22 [8KE1_7] (0) {1.1.1.3}; +##M:23 [8KE1_8] (0) {1.1.1.3}; +##M:24 [8KE1_9] (0) {1.1.1.3}; +##M:25 [8KE1_10] (0) {1.1.1.3}; +##M:26 [8KE1_11] (0) {1.1.1.3}; +##M:27 [8KE1_12] (0) {1.1.1.3}; +##M:28 [8KE1_13] (0) {1.1.1.3}; +##M:29 [8KE1_14] (0) {1.1.1.3}; +##M:30 [8KE1_15] (0) {1.1.1.3}; + +##VLR +/ / /.2. (9); + +M:1 [OptAuthReq] {3.2.5.2.1.1}; +M:2 [OpReuseTriplets] {3.2.5.2.1.2}; +M:3 [OptCipReq] {3.2.5.2.1.3}; +M:4 [OptCiphAlgo] {3.2.5.2.1.4}; +M:5 [OptTmsiAlloc] {3.2.5.2.1.5}; +M:6 [OptEcsSetUpAllow] {3.2.5.2.1.7}; +M:7 [OptCheckIMEI] {3.2.5.2.1.8}; +M:8 [OptVlrPurge] {3.2.5.2.1.9}; +M:9 [idlePeriod2Purge] {3.2.5.2.1.10}; +M:10 [CDR flag] {3.2.5.2.1.11}; +M:11 [MSRN] {3.2.5.2.1.13}; +M:12 [VLR0] {3.2.5}; +M:13 [VLR1] {3.2.5}; + +##VLR->VLR0 + +/ / /.2.12. (1); + +M:1 [Version] {3.2.5.3.2}; +M:2 [Command] {3.2.5.3.3}; +M:3 [Status] {3.2.5.3.4}; + +##VLR->VLR0 + +/ / /.2.13. (2); + +M:1 [Version] {3.2.5.3.2}; +M:2 [Command] {3.2.5.3.3}; +M:3 [Status] {3.2.5.3.4}; + + +##HLR +/ / /.3. (9); + +M:1 [HPLMN] {3.3.2.1.11}; +M:2 [VPLMNs] {3.3.2.1.12}; +M:3 [CSRR list] {3.3.2.1.13}; +M:4 [Regional Subscription] {3.3.2.1.14}; +M:5 [License control] {3.3.2.1.15}; +M:6 [CDR control] {3.3.2.1.16}; +M:7 [Feature Code] {3.3.2.1.27}; +M:8 [Platform] {2}; +M:9 [HLR0] {3.3}; +M:10 [HLR1] {3.3}; + +##HLR->Platform +/ / /.3.8. (9); + +M:1 [MTP3] {2.2.2}; +M:2 [SCCP] {2.2.3}; +M:3 [XAPP] {2.2.5}; + +##HLR->Platform->MTP3 +/ / /.3.8.1. (9); + +M:1 [Network Indicator] {2.2.2.2.2}; +M:2 [Originating Point code] {2.2.2.2.3}; +M:3 [Link Set] {2.2.2.2.4}; +M:4 [Link] {2.2.2.2.5}; +M:5 [Routing] {2.2.2.2.6}; +M:6 [ACN] {2.2.2.2.7}; +M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##HLR->Platform->MTP3->Status +/ / /.3.8.1.7. (9); + +M:1 [Link status] {2.2.2.3.1}; +M:2 [Link set status] {2.2.2.3.2}; +M:3 [International routing] {2.2.2.3.3}; +M:4 [International spare] {2.2.2.3.4}; +M:5 [National routing] {2.2.2.3.5}; +M:6 [National spare routing] {2.2.2.3.6}; +M:7 [Command] {2.2.2.3.7}; + +##HLR->Platform->SCCP +/ / /.3.8.2. (9); + +M:1 [Local node] {2.2.3.2.1}; +M:2 [GTT] {2.2.3.2.2}; +M:3 [Command] {2.2.3.3.2}; + +##HLR->Platform->XAPP +/ / /.3.8.3. (9); + +M:1 [MCC] {2.2.5.2.1}; +M:2 [MNC] {2.2.5.2.2}; +M:3 [CC] {2.2.5.2.3}; +M:4 [NDC] {2.2.5.2.4}; +M:5 [International prefix] {2.2.5.2.5}; +M:6 [National Prefix] {2.2.5.2.6}; +M:7 [Local Prefix] {2.2.5.2.7}; +M:8 [Convert Prefix] {2.2.5.2.8}; +M:9 [Command] {2.2.5.3.2}; + +##HLR->HLR0 + +/ / /.3.9. (1); + +M:1 [Command] {3.3.2.2.2}; +M:2 [Subscriber import] {3.3.2.2.3}; +M:3 [Max Licenses] {3.3.2.2.11}; +M:4 [Used Licenses] {3.3.2.2.12}; +M:5 [Subscriber information] {3.3.2.2.13}; +M:6 [Version] {3.3.2.2.14}; +M:7 [IMSI segment] {3.3.2.2.15}; +M:8 [MSISDN segment] {3.3.2.2.16}; +M:9 [CNF applicant info] {3.3.2.2.27}; +##M:10 [Contry code] {3.3.2.2.10}; + +##HLR->HLR0->Subscriber information + +/ / /.3.9.5. (1); + +M:1 [Provisioned subscribers] {3.3.2.2.13.1}; +M:2 [Registered subscribers] {3.3.2.2.13.2}; +M:3 [Roaming subscribers] {3.3.2.2.13.3}; + +##HLR->HLR0->Version +/ / /.3.9.6. (1); + +M:1 [Software] {3.3.2.2.14.1}; +M:2 [User data] {3.3.2.2.14.2}; + + +##HLR->HLR1 + +/ / /.3.10. (2); + +M:1 [Command] {3.3.2.2.2}; +M:2 [Subscriber import] {3.3.2.2.3}; +M:3 [Max Licenses] {3.3.2.2.11}; +M:4 [Used Licenses] {3.3.2.2.12}; +M:5 [Subscriber information] {3.3.2.2.13}; +M:6 [Version] {3.3.2.2.14}; +M:7 [IMSI segment] {3.3.2.2.15}; +M:8 [MSISDN segment] {3.3.2.2.16}; +M:9 [CNF applicant info] {3.3.2.2.27}; +##M:10 [Contry code] {3.3.2.2.10}; + +##HLR->HLR1->Subscriber information +/ / /.3.10.5. (2); + +M:1 [Provisioned subscribers] {3.3.2.2.13.1}; +M:2 [Registered subscribers] {3.3.2.2.13.2}; +M:3 [Roaming subscribers] {3.3.2.2.13.3}; + +##HLR->HLR1->Version +/ / /.3.10.6. (2); + +M:1 [Software] {3.3.2.2.14.1}; +M:2 [User data] {3.3.2.2.14.2}; + +##PPS +/ / /.4. (9); + +M:1 [Service control] {3.6.2.1.1}; +M:2 [SRF Number] {3.6.2.1.2.1}; +M:3 [Service number] {3.6.2.1.2.2}; +M:4 [Service key] {3.6.2.1.2.3}; +M:5 [COS Parameter] {3.6.2.1.4}; +M:6 [Call routing to VMS] {3.6.2.1.5}; +M:7 [Status] {3.6.2.1.6}; +M:8 [Platform] {2}; + +##PPS->Service control +/ / /.4.1. (9); + +M:1 [CDR flag] {3.6.2.1.1.1}; +M:2 [Blacklist threshhold] {3.6.2.1.1.2}; +M:3 [Maximun balance] {3.6.2.1.1.3}; +M:4 [license control] {3.6.2.1.1.4}; +M:5 [Prompt resolution] {3.6.2.1.1.5}; +M:6 [SMS Sentence] {3.6.2.1.1.6}; +M:7 [Last call info] {3.6.2.1.1.7}; +M:8 [Currency Symbol] {3.6.2.1.1.8}; +M:9 [Third party info] {3.6.2.1.1.9}; +M:10 [Basic Tariff Zone] {3.6.2.1.1.10}; + +##PPS->Service number +/ / /.4.3. (9); + +M:1 [Hotline] {3.6.2.1.2.2.1}; +M:2 [Inquiry] {3.6.2.1.2.2.2}; +M:3 [Scratch card rechagne] {3.6.2.1.2.2.3}; +M:4 [Credit card recharge] {3.6.2.1.2.2.4}; +M:5 [Third party recharge] {3.6.2.1.2.2.5}; +M:6 [Customer care center] {3.6.2.1.2.2.6}; +M:7 [Recharge] {3.6.2.1.2.2.7}; + +##PPS->Service key +/ / /.4.4. (9); + +M:1 [Inquiry] {3.6.2.1.2.3.2}; +M:2 [Scratch card rechagne] {3.6.2.1.2.3.3}; +M:3 [Credit card recharge] {3.6.2.1.2.3.4}; +M:4 [Set favorite number] {3.6.2.1.2.3.5}; +M:5 [Set password] {3.6.2.1.2.3.6}; + + +##PPS->COS Parameter +/ / /.4.5. (9); + +M:1 [COS0] {3.6.2.1.4.1}; +M:2 [COS1] {3.6.2.1.4.2}; +M:3 [COS2] {3.6.2.1.4.3}; +M:4 [COS3] {3.6.2.1.4.4}; +M:5 [COS4] {3.6.2.1.4.5}; +M:6 [COS5] {3.6.2.1.4.6}; +M:7 [COS6] {3.6.2.1.4.7}; +M:8 [COS7] {3.6.2.1.4.8}; +M:9 [COS8] {3.6.2.1.4.9}; +M:10 [COS9] {3.6.2.1.4.10}; +M:11 [COS10] {3.6.2.1.4.11}; +M:12 [COS11] {3.6.2.1.4.12}; +M:13 [COS12] {3.6.2.1.4.13}; +M:14 [COS13] {3.6.2.1.4.14}; +M:15 [COS14] {3.6.2.1.4.15}; +M:16 [COS15] {3.6.2.1.4.16}; + + +##PPS->COS Parameter->COS 0-15 +/ / /.4.5.1. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.1.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.1.2}; +M:3 [Account control] {3.6.2.1.4.1.3}; +M:4 [MT Call control] {3.6.2.1.4.1.4}; +M:5 [Validity control] {3.6.2.1.4.1.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.1.6}; + +/ / /.4.5.2. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.2.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.2.2}; +M:3 [Account control] {3.6.2.1.4.2.3}; +M:4 [MT Call control] {3.6.2.1.4.2.4}; +M:5 [Validity control] {3.6.2.1.4.2.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.2.6}; + +/ / /.4.5.3. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.3.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.3.2}; +M:3 [Account control] {3.6.2.1.4.3.3}; +M:4 [MT Call control] {3.6.2.1.4.3.4}; +M:5 [Validity control] {3.6.2.1.4.3.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.3.6}; + +/ / /.4.5.4. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.4.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.4.2}; +M:3 [Account control] {3.6.2.1.4.4.3}; +M:4 [MT Call control] {3.6.2.1.4.4.4}; +M:5 [Validity control] {3.6.2.1.4.4.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.4.6}; + +/ / /.4.5.5. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.5.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.5.2}; +M:3 [Account control] {3.6.2.1.4.5.3}; +M:4 [MT Call control] {3.6.2.1.4.5.4}; +M:5 [Validity control] {3.6.2.1.4.5.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.5.6}; + +/ / /.4.5.6. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.6.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.6.2}; +M:3 [Account control] {3.6.2.1.4.6.3}; +M:4 [MT Call control] {3.6.2.1.4.6.4}; +M:5 [Validity control] {3.6.2.1.4.6.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.6.6}; + +/ / /.4.5.7. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.7.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.7.2}; +M:3 [Account control] {3.6.2.1.4.7.3}; +M:4 [MT Call control] {3.6.2.1.4.7.4}; +M:5 [Validity control] {3.6.2.1.4.7.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.7.6}; + +/ / /.4.5.8. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.8.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.8.2}; +M:3 [Account control] {3.6.2.1.4.8.3}; +M:4 [MT Call control] {3.6.2.1.4.8.4}; +M:5 [Validity control] {3.6.2.1.4.8.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.8.6}; + +/ / /.4.5.9. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.9.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.9.2}; +M:3 [Account control] {3.6.2.1.4.9.3}; +M:4 [MT Call control] {3.6.2.1.4.9.4}; +M:5 [Validity control] {3.6.2.1.4.9.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.9.6}; + +/ / /.4.5.10. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.10.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.10.2}; +M:3 [Account control] {3.6.2.1.4.10.3}; +M:4 [MT Call control] {3.6.2.1.4.10.4}; +M:5 [Validity control] {3.6.2.1.4.10.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.10.6}; + +/ / /.4.5.11. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.11.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.11.2}; +M:3 [Account control] {3.6.2.1.4.11.3}; +M:4 [MT Call control] {3.6.2.1.4.11.4}; +M:5 [Validity control] {3.6.2.1.4.11.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.11.6}; + +/ / /.4.5.12. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.12.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.12.2}; +M:3 [Account control] {3.6.2.1.4.12.3}; +M:4 [MT Call control] {3.6.2.1.4.12.4}; +M:5 [Validity control] {3.6.2.1.4.12.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.12.6}; + +/ / /.4.5.13. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.13.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.13.2}; +M:3 [Account control] {3.6.2.1.4.13.3}; +M:4 [MT Call control] {3.6.2.1.4.13.4}; +M:5 [Validity control] {3.6.2.1.4.13.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.13.6}; + +/ / /.4.5.14. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.14.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.14.2}; +M:3 [Account control] {3.6.2.1.4.14.3}; +M:4 [MT Call control] {3.6.2.1.4.14.4}; +M:5 [Validity control] {3.6.2.1.4.14.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.14.6}; + +/ / /.4.5.15. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.15.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.15.2}; +M:3 [Account control] {3.6.2.1.4.15.3}; +M:4 [MT Call control] {3.6.2.1.4.15.4}; +M:5 [Validity control] {3.6.2.1.4.15.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.15.6}; + +/ / /.4.5.16. (9); + +M:1 [Recharge Promotion] {3.6.2.1.4.16.1}; +M:2 [Tariff Resolution] {3.6.2.1.4.16.2}; +M:3 [Account control] {3.6.2.1.4.16.3}; +M:4 [MT Call control] {3.6.2.1.4.16.4}; +M:5 [Validity control] {3.6.2.1.4.16.5}; +M:6 [SM Inquiry Notification] {3.6.2.1.4.16.6}; + + +##PPS->call routing to VMS +/ / /.4.6. (9); + +M:1 [VMS service number-PLMN] {3.6.2.1.5.1}; +M:2 [VMS service number-PSTN] {3.6.2.1.5.2}; +M:3 [VMS leave message number] {3.6.2.1.5.3}; +M:4 [Routing rule] {3.6.2.1.5.4}; +M:5 [VMS user segments] {3.6.2.1.5.5}; + +##PPS->Status +/ / /.4.7. (9); + +M:1 [Activaion] {3.6.2.1.6.1}; +M:2 [Command] {3.6.2.1.6.2}; + + +##PPS->Platform +/ / /.4.8. (9); + +M:1 [MTP3] {2.2.2}; +M:2 [SCCP] {2.2.3}; +M:3 [XAPP] {2.2.5}; +M:4 [SMPP] {2.3.4} + +##PPS->Platform->MTP3 +/ / /.4.8.1. (9); + +M:1 [Network Indicator] {2.2.2.2.2}; +M:2 [Originating Point code] {2.2.2.2.3}; +M:3 [Link Set] {2.2.2.2.4}; +M:4 [Link] {2.2.2.2.5}; +M:5 [Routing] {2.2.2.2.6}; +M:6 [CAN] {2.2.2.2.7}; +M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##PPS->Platform->MTP3->Status +/ / /.4.8.1.7. (9); + +M:1 [Link status] {2.2.2.3.1}; +M:2 [Link set status] {2.2.2.3.2}; +M:3 [International routing] {2.2.2.3.3}; +M:4 [International spare] {2.2.2.3.4}; +M:5 [National routing] {2.2.2.3.5}; +M:6 [National spare routing] {2.2.2.3.6}; +M:7 [Command] {2.2.2.3.7}; + +##PPS->Platform->SCCP +/ / /.4.8.2. (9); + +M:1 [Local node] {2.2.3.2.1}; +M:2 [GTT] {2.2.3.2.2}; +M:3 [Command] {2.2.3.3.2}; + +##PPS->Platform->XAPP +/ / /.4.8.3. (9); + +M:1 [MCC] {2.2.5.2.1}; +M:2 [MNC] {2.2.5.2.2}; +M:3 [CC] {2.2.5.2.3}; +M:4 [NDC] {2.2.5.2.4}; +M:5 [International prefix] {2.2.5.2.5}; +M:6 [National Prefix] {2.2.5.2.6}; +M:7 [Local Prefix] {2.2.5.2.7}; +M:8 [Convert Prefix] {2.2.5.2.8}; +M:9 [Command] {2.2.5.3.2}; + +##PPS-->Platform->SMPP +/ / /.4.8.4. (9); + +M:1 [SMPP_Link_Param] {2.3.4.2.1}; +M:2 [Command] {2.3.4.3.2}; + + +## SMSC +/ / /.5. (9); + +M:1 [CDR flag] {3.5.2.1.1}; +M:2 [SM Validity] {3.5.2.1.2}; +M:3 [MSISDN Segment] {3.5.2.1.3}; +M:4 [SMPP parameters] {3.5.2.2}; +M:5 [Command] {3.5.3.3}; +M:6 [Platform] {2}; +M:7 [SMSC0] {3.5}; +M:8 [SMSC1] {3.5}; + + +##SMSC->Platform +/ / /.5.6. (9); + +M:1 [MTP3] {2.2.2}; +M:2 [SCCP] {2.2.3}; +M:3 [XAPP] {2.2.5}; +M:4 [SMPP] {2.3.4}; + +##SMSC->Platform->MTP3 +/ / /.5.6.1. (9); + +M:1 [Network Indicator] {2.2.2.2.2}; +M:2 [Originating Point code] {2.2.2.2.3}; +M:3 [Link Set] {2.2.2.2.4}; +M:4 [Link] {2.2.2.2.5}; +M:5 [Routing] {2.2.2.2.6}; +M:6 [CAN] {2.2.2.2.7}; +M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##SMSC->Platform->MTP3->Status +/ / /.5.6.1.7. (9); + +M:1 [Link status] {2.2.2.3.1}; +M:2 [Link set status] {2.2.2.3.2}; +M:3 [International routing] {2.2.2.3.3}; +M:4 [International spare] {2.2.2.3.4}; +M:5 [National routing] {2.2.2.3.5}; +M:6 [National spare routing] {2.2.2.3.6}; +M:7 [Command] {2.2.2.3.7}; + +##SMSC->Platform->SCCP +/ / /.5.6.2. (9); + +M:1 [Local node] {2.2.3.2.1}; +M:2 [GTT] {2.2.3.2.2}; +M:3 [Command] {2.2.3.3.2}; + +##SMSC->Platform->XAPP +/ / /.5.6.3. (9); + +M:1 [MCC] {2.2.5.2.1}; +M:2 [MNC] {2.2.5.2.2}; +M:3 [CC] {2.2.5.2.3}; +M:4 [NDC] {2.2.5.2.4}; +M:5 [International prefix] {2.2.5.2.5}; +M:6 [National Prefix] {2.2.5.2.6}; +M:7 [Local Prefix] {2.2.5.2.7}; +M:8 [Convert Prefix] {2.2.5.2.8}; +M:9 [Command] {2.2.5.3.2}; + +##SMSC->Platform->SMPP +/ / /.5.6.4. (9); + +M:1 [SMPP_Link_Param] {2.3.4.2.1}; +M:2 [Command] {2.3.4.3.2}; + + +##SMSC->SMSC0 +/ / /.5.7. (1); + +M:1 [SMSC ID] {3.5.3.1}; +M:2 [Software version] {3.5.3.2}; + +##SMSC->SMSC1 +/ / /.5.8. (2); + +M:1 [SMSC ID] {3.5.3.1}; +M:2 [Software version] {3.5.3.2}; + +##AUC +/ / /.6. (9); + +M:1 [Platform] {2}; +M:2 [AUC0] (1) {3.4}; +M:3 [AUC1] (2) {3.4}; + + +##AUC->Platform +/ / /.6.1. (9); + +M:1 [MTP3] {2.2.2}; +M:2 [SCCP] {2.2.3}; +M:3 [XAPP] {2.2.5}; + +##AUC->Platform->MTP3 +/ / /.6.1.1. (9); + +M:1 [Network Indicator] {2.2.2.2.2}; +M:2 [Originating Point code] {2.2.2.2.3}; +M:3 [Link Set] {2.2.2.2.4}; +M:4 [Link] {2.2.2.2.5}; +M:5 [Routing] {2.2.2.2.6}; +M:6 [CAN] {2.2.2.2.7}; +M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##AUC->Platform->MTP3->Status +/ / /.6.1.1.7. (9); + +M:1 [Link status] {2.2.2.3.1}; +M:2 [Link set status] {2.2.2.3.2}; +M:3 [International routing] {2.2.2.3.3}; +M:4 [International spare] {2.2.2.3.4}; +M:5 [National routing] {2.2.2.3.5}; +M:6 [National spare routing] {2.2.2.3.6}; +M:7 [Command] {2.2.2.3.7}; + +##AUC->Platform->SCCP +/ / /.6.1.2. (9); + +M:1 [Local node] {2.2.3.2.1}; +M:2 [GTT] {2.2.3.2.2}; +M:3 [Command] {2.2.3.3.2}; + +##AUC->Platform->XAPP +/ / /.6.1.3. (9); + +M:1 [MCC] {2.2.5.2.1}; +M:2 [MNC] {2.2.5.2.2}; +M:3 [CC] {2.2.5.2.3}; +M:4 [NDC] {2.2.5.2.4}; +M:5 [International prefix] {2.2.5.2.5}; +M:6 [National Prefix] {2.2.5.2.6}; +M:7 [Local Prefix] {2.2.5.2.7}; +M:8 [Convert Prefix] {2.2.5.2.8}; +M:9 [Command] {2.2.5.3.2}; + + +##EIR +##/ / /.7. (9); + +##M:1 [Platform] {2}; +##M:2 [EIR0] (1) {3.8}; +##M:3 [EIR1] (2) {3.8}; + +##EIR->Platform +##/ / /.7.1. (9); + +##M:1 [MTP3] {2.2.2}; +##M:2 [SCCP] {2.2.3}; +##M:3 [XAPP] {2.2.5}; + +##EIR->Platform->MTP3 +##/ / /.7.1.1. (9); + +##M:1 [Network Indicator] {2.2.2.2.2}; +##M:2 [Originating Point code] {2.2.2.2.3}; +##M:3 [Link Set] {2.2.2.2.4}; +##M:4 [Link] {2.2.2.2.5}; +##M:5 [Routing] {2.2.2.2.6}; +##M:6 [CAN] {2.2.2.2.7}; +##M:7 [Status] {2.2.2.3}; +M:8 [Signaling GateWay] {2.2.2.2.9}; + + +##EIR->Platform->MTP3->Status +##/ / /.7.1.1.7. (9); + +####M:1 [Link status] {2.2.2.3.1}; +##M:2 [Link set status] {2.2.2.3.2}; +##M:3 [International routing] {2.2.2.3.3}; +##M:4 [International spare] {2.2.2.3.4}; +##M:5 [National routing] {2.2.2.3.5}; +##M:6 [National spare routing] {2.2.2.3.6}; +##M:7 [Command] {2.2.2.3.7}; + +##EIR->Platform->SCCP +##/ / /.7.1.2. (9); + +##M:1 [Local node] {2.2.3.2.1}; +##M:2 [GTT] {2.2.3.2.2}; +##M:3 [Command] {2.2.3.3.2}; + +##EIR->Platform->XAPP +##/ / /.7.1.3. (9); + +##M:1 [MCC] {2.2.5.2.1}; +##M:2 [MNC] {2.2.5.2.2}; +##M:3 [CC] {2.2.5.2.3}; +##M:5 [International prefix] {2.2.5.2.5}; +##M:6 [National Prefix] {2.2.5.2.6}; +##M:7 [Local Prefix] {2.2.5.2.7}; +##M:8 [Convert Prefix] {2.2.5.2.8}; +##M:9 [Command] {2.2.5.3.2}; diff --git a/omc/plat/smpp/ut/conf/MIB_files/mib_list_file.txt b/omc/plat/smpp/ut/conf/MIB_files/mib_list_file.txt new file mode 100644 index 0000000..42938ca --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/mib_list_file.txt @@ -0,0 +1,14 @@ +// "//" is the annotation characters; +IWV-SMI.txt +Special_App-SMI.txt +//PPPRT-MIB.txt +WXC2-SMI.txt +//WXC2-CSU-MIB.txt +WXC2-SS7-MIB.txt +WXC2-MSC-MIB.txt +WXC2-HLR-MIB.txt +WXC2-AUC-MIB.txt +//WXC2-EIR-MIB.txt +WXC2-SMSC-MIB.txt +WXC2-PPS-MIB.txt +WXC2-MSS-MIB.txt diff --git a/omc/plat/smpp/ut/conf/MIB_files/mib_write_tree.txt b/omc/plat/smpp/ut/conf/MIB_files/mib_write_tree.txt new file mode 100644 index 0000000..23813b8 --- /dev/null +++ b/omc/plat/smpp/ut/conf/MIB_files/mib_write_tree.txt @@ -0,0 +1,25897 @@ +Create node: IWV(OID: 1.3.6.1.4.1.1373) +-> father_name = [enterprises] +-> -> IWV(0) + + +Create node: IWV_Products(OID: 1.3.6.1.4.1.1373.1) +-> father_name = [IWV] +-> -> IWV_Products(0) + + +Remark: iwvProducts is the root OBJECT IDENTIFIER from which sysObjectID values are assigned. Actual values are defined in IWV-PRODUCTS-MIB. + + +Create node: Special_App(OID: 1.3.6.1.4.1.1373.1.2) +-> father_name = [IWV_Products] +-> -> Special_App(0) + + +Create node: IWF(OID: 1.3.6.1.4.1.1373.1.2.8) +-> father_name = [Special_App] +-> -> IWF(0) + + +Remark: IWF + + +Create node: WXC2(OID: 1.3.6.1.4.1.1373.1.3) +-> father_name = [IWV_Products] +-> -> Special_App(0) +-> -> WXC2(1) + + +Create node: PCM(OID: 1.3.6.1.4.1.1373.1.3.1) +-> father_name = [WXC2] +-> -> PCM(0) + + +Remark: PCM + + +Create node: Platform(OID: 1.3.6.1.4.1.1373.1.3.2) +-> father_name = [WXC2] +-> -> PCM(0) +-> -> Platform(1) + + +Remark: Platform + + +Create node: App(OID: 1.3.6.1.4.1.1373.1.3.3) +-> father_name = [WXC2] +-> -> PCM(0) +-> -> Platform(1) +-> -> App(2) + + +Remark: App platform + + +Create node: SS7(OID: 1.3.6.1.4.1.1373.1.3.2.2) +-> father_name = [Platform] +-> -> SS7(0) + + +Remark: + Subsystems for SS7 . + + +Create node: MTP3(OID: 1.3.6.1.4.1.1373.1.3.2.2.2) +-> father_name = [SS7] +-> -> MTP3(0) + + +Remark: Subsystems for MTP3 . + + +Create node: Config_MTP3(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2) +-> father_name = [MTP3] +-> -> Config_MTP3(0) + + +Remark: MTP3 Configuration. + + +Create node: Network_Indicator(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.2) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) + + +Register leaf node: Network_Indicator. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : MTP3 network indicator. + +Field : total(8) +Access : read-write [1]International network + { + [u]0.0-0.0 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [2]International network spare + { + [u]0.1-0.1 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [3]National network + { + [u]0.2-0.2 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [4]National network spare + { + [u]0.3-0.3 + [u]select + [v]0[opt]14bit + [v]1[opt]24bit + } + [5]International network + { + [u]0.4-0.4 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [6]International network spare + { + [u]0.5-0.5 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [7]National network + { + [u]0.6-0.6 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + [8]National network spare + { + [u]0.7-0.7 + [u]select + [v]0[opt]ITU + [v]1[opt]ANSI + } + + +Create node: OPC(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) + + +Remark: Originating point code. + + +Create node: International_14bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.1) +-> father_name = [OPC] +-> -> International_14bit(0) + + +Register leaf node: International_14bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 14-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: International_Spare_14bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.2) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) + + +Register leaf node: International_Spare_14bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 14-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: National_14bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.3) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) + + +Register leaf node: National_14bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 14-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: National_Spare_14bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.4) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) +-> -> National_Spare_14bit(3) + + +Register leaf node: National_Spare_14bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 14-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: International_24bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.5) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) +-> -> National_Spare_14bit(3) +-> -> International_24bit(4) + + +Register leaf node: International_24bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 24-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: International_Spare_24bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.6) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) +-> -> National_Spare_14bit(3) +-> -> International_24bit(4) +-> -> International_Spare_24bit(5) + + +Register leaf node: International_Spare_24bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 24-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: National_24bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.7) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) +-> -> National_Spare_14bit(3) +-> -> International_24bit(4) +-> -> International_Spare_24bit(5) +-> -> National_24bit(6) + + +Register leaf node: National_24bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 24-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: National_Spare_24bit(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.3.8) +-> father_name = [OPC] +-> -> International_14bit(0) +-> -> International_Spare_14bit(1) +-> -> National_14bit(2) +-> -> National_Spare_14bit(3) +-> -> International_24bit(4) +-> -> International_Spare_24bit(5) +-> -> National_24bit(6) +-> -> National_Spare_24bit(7) + + +Register leaf node: National_Spare_24bit. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : 24-bit originating point code (OPC) in an international network. Default=0. + +Field : total(1) +Access : read-write[1]Originating point code + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Linkset(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.4) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) +-> -> Linkset(2) + + +Remark: linkset. + + +Create node: Linkset_Attributes(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.4.1) +-> father_name = [Linkset] +-> -> Linkset_Attributes(0) + + +Register leaf node: Linkset_Attributes. +Instance: 128 +Length : 4 +Flag : 255 +Default : +Remark : Opposite point code: The opposite point code of the linkset. +Network indicator: The network type of the opposite point code. +Loop back: Loop back enable or disable, used for MSC loop back link. + +Field : total(5) +Access : read-write[1]Linkset DPC + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } + [2]Network indicator + { + [u]3.0-3.1 + [u]select + [v]0[opt]International + [v]1[opt]International spare + [v]2[opt]National + [v]3[opt]National spare + } + [4]Linkset loopback + { + [u]3.3-3.3 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Link(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.5) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) +-> -> Linkset(2) +-> -> Link(3) + + +Remark: link. + + +Create node: Link_Attributes(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.5.1) +-> father_name = [Link] +-> -> Link_Attributes(0) + + +Register leaf node: Link_Attributes. +Instance: 256 +Length : 15 +Flag : 255 +Default :  +Remark : E1 link attributes. +Linkset no.: Assign linkset to E1 link, MSC has up to 128 linksets (0-127). 128=TCH E1. +SLC no.: Assign SLC to each E1 link of a linkset, each linkset has up to 13 E1 links (0-15). +IP: E1 link management IP. The third byte of CPC IP: +98=E1 link 0-127, 99=E1 link 128-255. +Default=0x000032. + +Field : total(12) +Access : read-write[1]Linkset no. + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } +[2]SLC no. + { + [u]1.0-1.7 + [u]input + [v]toDec high 0 + } +[3]CPC IP + { + [u]2.0-5.7 + [u]input + [v]KeepHex high 0 + } + [4]Link Type + { + [u]6.0-6.0 + [u]select + [v]0[opt]Non-sigtran + [v]1[opt]Sigtran + } + [5]Link Enable + { + [u]6.1-6.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [6]MTP3-Lite Enable + { + [u]6.2-6.2 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[8]SG no. + { + [u]7.0-7.7 + [u]input + [v]toDec high 0 + } +[9]M2UA Interface ID + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } +[10]MTP3-Lite Remote IP + { + [u]9.0-12.7 + [u]input + [v]KeepHex high 0 + } +[11]MTP3-Lite Inactivity Timeout + { + [u]13.0-13.7 + [u]input + [v]toDec high 0 + } +[12]MTP3-Lite Allowed Inactivity Timeouts + { + [u]14.0-14.7 + [u]input + [v]toDec high 0 + } + + +Create node: Link_Command(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.5.2) +-> father_name = [Link] +-> -> Link_Attributes(0) +-> -> Link_Command(1) + + +Register leaf node: Link_Command. +Instance: 256 +Length : 1 +Flag : 255 +Default :  +Remark : Used for E1 link control, not affect call traffic. +Disable=Disable E1 link MTP2 layer. +Enable=Enable a disabled E1 link MTP2 layer. +Inhibit=Inhibit E1 link MTP3 layer. +Uninhibit=Uninhibit a inhibited E1 link MTP3 layer. +Default=Enable a disabled E1 link MTP2 layer. + +Field : total(1) +Access : write-only [1]E1 link + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + [v]2[opt]Inhibit + [v]3[opt]Uninhibit + } + + +Create node: TCP_Port(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.5.3) +-> father_name = [Link] +-> -> Link_Attributes(0) +-> -> Link_Command(1) +-> -> TCP_Port(2) + + +Register leaf node: TCP_Port. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : TCP server port for SCCP-Lite. + +Field : total(1) +Access : read-write[1]TCP Port + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: Routing(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.6) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) +-> -> Linkset(2) +-> -> Link(3) +-> -> Routing(4) + + +Remark: Routing. + + +Create node: International(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.6.1) +-> father_name = [Routing] +-> -> International(0) + + +Register leaf node: International. +Instance: 256 +Length : 5 +Flag : 255 +Default : +Remark : Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + +Field : total(3) +Access : read-write[1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } +[2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec high 0 + } + + +Create node: International_Spare(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.6.2) +-> father_name = [Routing] +-> -> International(0) +-> -> International_Spare(1) + + +Register leaf node: International_Spare. +Instance: 256 +Length : 5 +Flag : 255 +Default : +Remark : Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + +Field : total(3) +Access : read-write[1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } +[2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec high 0 + } + + +Create node: National(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.6.3) +-> father_name = [Routing] +-> -> International(0) +-> -> International_Spare(1) +-> -> National(2) + + +Register leaf node: National. +Instance: 256 +Length : 5 +Flag : 255 +Default : +Remark : Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + +Field : total(3) +Access : read-write[1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } +[2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec high 0 + } + + +Create node: National_Spare(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.6.4) +-> father_name = [Routing] +-> -> International(0) +-> -> International_Spare(1) +-> -> National(2) +-> -> National_Spare(3) + + +Register leaf node: National_Spare. +Instance: 256 +Length : 5 +Flag : 255 +Default : +Remark : Assign a normal linkset and an alternative linkset for each destination point code for signaling addressing. Basically the normal linkset is always used. The alternative linkset can only be used when the normal linkset is not available. Default=0x0000008080. + +Field : total(3) +Access : read-write[1]DPC + { + [u]0.0-2.7 + [u]input + [v]toDec high 0 + } +[2]Normal linkset + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Alternative linkset + { + [u]4.0-4.7 + [u]input + [v]toDec high 0 + } + + +Create node: SPC_to_ACN(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) +-> -> Linkset(2) +-> -> Link(3) +-> -> Routing(4) +-> -> SPC_to_ACN(5) + + +Remark: SPC to ACN. + + +Create node: Local_ACN(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7.1) +-> father_name = [SPC_to_ACN] +-> -> Local_ACN(0) + + +Register leaf node: Local_ACN. +Instance: 1 +Length : 36 +Flag : 255 +Default :  +Remark : The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + +Field : total(36) +Access : read-write [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + + +Create node: International(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7.2) +-> father_name = [SPC_to_ACN] +-> -> Local_ACN(0) +-> -> International(1) + + +Register leaf node: International. +Instance: 256 +Length : 36 +Flag : 255 +Default :  +Remark : The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + +Field : total(36) +Access : read-write [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + + +Create node: International_Spare(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7.3) +-> father_name = [SPC_to_ACN] +-> -> Local_ACN(0) +-> -> International(1) +-> -> International_Spare(2) + + +Register leaf node: International_Spare. +Instance: 256 +Length : 36 +Flag : 255 +Default :  +Remark : The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + +Field : total(36) +Access : read-write [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + + +Create node: National(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7.4) +-> father_name = [SPC_to_ACN] +-> -> Local_ACN(0) +-> -> International(1) +-> -> International_Spare(2) +-> -> National(3) + + +Register leaf node: National. +Instance: 256 +Length : 36 +Flag : 255 +Default :  +Remark : The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + +Field : total(36) +Access : read-write [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + + +Create node: National_Spare(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.7.5) +-> father_name = [SPC_to_ACN] +-> -> Local_ACN(0) +-> -> International(1) +-> -> International_Spare(2) +-> -> National(3) +-> -> National_Spare(4) + + +Register leaf node: National_Spare. +Instance: 256 +Length : 36 +Flag : 255 +Default :  +Remark : The ACN facility enables the version negotiation for the above messages, which make the WXC2 System more compatible with the other networks by means of flexible message version adjustment. The adjustable version includes Version 1, Version 2 and Version 3. + +Field : total(36) +Access : read-write [1]Network Location Update + { + [u]0.0-0.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [2]Location Cancel + { + [u]1.0-1.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [3]Roaming number nequiry + { + [u]2.0-2.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [4]Location Info Retrieval + { + [u]3.0-3.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [5]Reset Context + { + [u]4.0-4.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [6]Handover Control + { + [u]5.0-5.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [7]Equipment management + { + [u]6.0-6.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [8]Info Retrieval + { + [u]7.0-7.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [9]Inter VLR Info Retrieval + { + [u]8.0-8.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [10]Subscriber Data Management + { + [u]9.0-9.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [11]Tracing + { + [u]10.0-10.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [12]Network Functional SS + { + [u]11.0-11.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [13]Network Unstructured SS + { + [u]12.0-12.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [14]Short Message Gateway + { + [u]13.0-13.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [15]Short Messsage MO Relay + { + [u]14.0-14.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [16]Short Message Alert + { + [u]15.0-15.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [17]Short Message Waiting Data Management + { + [u]16.0-16.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [18]Mobile Terminating Short Message Relay + { + [u]17.0-17.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [19]IMSI Retrieval + { + [u]18.0-18.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [20]MS purging + { + [u]19.0-19.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [21]Subscriber Info Enquiry + { + [u]20.0-20.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [22]Any Time Info Enquiry + { + [u]21.0-21.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [23]Call Control Transfer + { + [u]22.0-22.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [24]Invocation Notification + { + [u]23.0-23.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [25]SIWFS Allocation + { + [u]24.0-24.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [26]Group Call Control + { + [u]25.0-25.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [27]GPRS Location Update + { + [u]26.0-26.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [28]GPRS Location Info Retrieval + { + [u]27.0-27.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [29]Failure Report + { + [u]28.0-28.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [30]GPRS Notify + { + [u]29.0-29.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [31]Reporting + { + [u]30.0-30.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [32]Call Completion + { + [u]31.0-31.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [33]Security Triplets + { + [u]32.0-32.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [34]Subscriber Interrogate + { + [u]33.0-33.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [35]HLR Subscriber Management + { + [u]34.0-34.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + [36]HLR Ping AUC + { + [u]35.0-35.7 + [u]select + [v]2[opt]Version 2 + [v]3[opt]Version 3 + } + + +Create node: Signaling_Gateway(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.2.9) +-> father_name = [Config_MTP3] +-> -> Network_Indicator(0) +-> -> OPC(1) +-> -> Linkset(2) +-> -> Link(3) +-> -> Routing(4) +-> -> SPC_to_ACN(5) +-> -> Signaling_Gateway(6) + + +Register leaf node: Signaling_Gateway. +Instance: 256 +Length : 7 +Flag : 255 +Default : +Remark : SG attributes + +Field : total(4) +Access : read-write [1]Enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Server + { + [u]1.0-1.7 + [u]select + [v]0[opt]Client + [v]1[opt]Server + } + [3]ACK + { + [u]2.0-2.7 + [u]select + [v]0[opt]no ACK + [v]1[opt]ACK + } +[4]IP + { + [u]3.0-6.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Status_MTP3(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3) +-> father_name = [MTP3] +-> -> Config_MTP3(0) +-> -> Status_MTP3(1) + + +Remark: MTP3 Status. + + +Create node: Link_Status(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.1) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) + + +Register leaf node: Link_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default :  +Remark : E1 link MTP3 status (Read Only). + +Field : total(1) +Access : read-only [1]Link status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Unavailable + [v]1[opt]Available + [v]2[opt]Inhibited + } + + +Create node: Linkset_Status(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.2) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) + + +Register leaf node: Linkset_Status. +Instance: 128 +Length : 1 +Flag : 255 +Default :  +Remark : Linkset status (Read only). + +Field : total(1) +Access : read-only [1]Linkset status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Unavailable + [v]1[opt]Available + [v]2[opt]Reserved + } + + +Create node: International_Routing(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.3) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) +-> -> International_Routing(2) + + +Register leaf node: International_Routing. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Normal linkset status (bit0-1): +- 0=Available +- 1=Reserved +- 2=Unavailable +Alternative linkset status (bit2-3): +- 0=Available +- 1=Reserved +- 2=Unavailable +DPC accessibility (bit4): +- 0=Inaccessible +- 1=Accessible +Current route (bit3-7): +- 0=Normal linkset +- 1=Alternative linkset +- 2=No route. + +Field : total(4) +Access : read-only [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + + +Create node: International_Spare_Routing(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.4) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) +-> -> International_Routing(2) +-> -> International_Spare_Routing(3) + + +Register leaf node: International_Spare_Routing. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Normal linkset status (bit0-1): +- 0=Available +- 1=Reserved +- 2=Unavailable +Alternative linkset status (bit2-3): +- 0=Available +- 1=Reserved +- 2=Unavailable +DPC accessibility (bit4): +- 0=Inaccessible +- 1=Accessible +Current route (bit3-7): +- 0=Normal linkset +- 1=Alternative linkset +- 2=No route. + +Field : total(4) +Access : read-only [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + + +Create node: National_Routing(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.5) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) +-> -> International_Routing(2) +-> -> International_Spare_Routing(3) +-> -> National_Routing(4) + + +Register leaf node: National_Routing. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Normal linkset status (bit0-1): +- 0=Available +- 1=Reserved +- 2=Unavailable +Alternative linkset status (bit2-3): +- 0=Available +- 1=Reserved +- 2=Unavailable +DPC accessibility (bit4): +- 0=Inaccessible +- 1=Accessible +Current route (bit3-7): +- 0=Normal linkset +- 1=Alternative linkset +- 2=No route. + +Field : total(4) +Access : read-only [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + + +Create node: National_Spare_Routing(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.6) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) +-> -> International_Routing(2) +-> -> International_Spare_Routing(3) +-> -> National_Routing(4) +-> -> National_Spare_Routing(5) + + +Register leaf node: National_Spare_Routing. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Normal linkset status (bit0-1): +- 0=Available +- 1=Reserved +- 2=Unavailable +Alternative linkset status (bit2-3): +- 0=Available +- 1=Reserved +- 2=Unavailable +DPC accessibility (bit4): +- 0=Inaccessible +- 1=Accessible +Current route (bit3-7): +- 0=Normal linkset +- 1=Alternative linkset +- 2=No route. + +Field : total(4) +Access : read-only [1]Normal linkset + { + [u]0.0-0.1 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [2]Alternative linkset + { + [u]0.2-0.3 + [u]select + [v]0[opt]available + [v]1[opt]reserved + [v]2[opt]unavailable + } + [3]DPC accessibility + { + [u]0.4-0.4 + [u]select + [v]0[opt]inaccessible + [v]1[opt]accessible + } + [4]Current route + { + [u]0.6-0.7 + [u]select + [v]0[opt]normal linkset + [v]1[opt]alternative linkset + [v]2[opt]no route + } + + +Create node: Command_MTP3(OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.7) +-> father_name = [Status_MTP3] +-> -> Link_Status(0) +-> -> Linkset_Status(1) +-> -> International_Routing(2) +-> -> International_Spare_Routing(3) +-> -> National_Routing(4) +-> -> National_Spare_Routing(5) +-> -> Command_MTP3(6) + + +Register leaf node: Command_MTP3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Control command for MTP3 platform. +Reset=status initialization. +Save parameter=save parameters residing in memory into harddisk. + +Field : total(1) +Access : read-write [1]command + { + [u]0.0-0.7 + [u]select + [v]0[opt]No command + [v]1[opt]Reset + [v]2[opt]Save parameter + } + + +Create node: SCCP(OID: 1.3.6.1.4.1.1373.1.3.2.2.3) +-> father_name = [SS7] +-> -> MTP3(0) +-> -> SCCP(1) + + +Remark: Subsystems for SCCP . + + +Create node: Config_SCCP(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2) +-> father_name = [SCCP] +-> -> Config_SCCP(0) + + +Remark: SCCP Configuration. + + +Create node: Local_Node(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1) +-> father_name = [Config_SCCP] +-> -> Local_Node(0) + + +Remark: Local Node. + + +Create node: OMC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.4) +-> father_name = [Local_Node] +-> -> OMC(0) + + +Register leaf node: OMC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: OMC E.134 number. +IP0: OMC0 IP, 172.18.128.1. +IP1: OMC1 IP, 172.18.129.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: HLR(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.6) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) + + +Register leaf node: HLR. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: HLR E.134 number. +IP0: HLR0 IP, 172.18.98.1. +IP1: HLR1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: VLR(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.7) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) + + +Register leaf node: VLR. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: VLR E.134 number. +IP0: VLR0 IP, 172.18.98.1. +IP1: VLR1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: MSC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.8) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) + + +Register leaf node: MSC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: MSC E.134 number. +IP0: MSC0 IP, 172.18.98.1. +IP1: MSC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: EIR(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.9) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) + + +Register leaf node: EIR. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: EIR E.134 number. +IP0: EIR0 IP, 172.18.98.1. +IP1: EIR1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: AUC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.10) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) + + +Register leaf node: AUC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: AUC E.134 number. +IP0: AUC0 IP, 172.18.98.1. +IP1: AUC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SMSC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.11) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) + + +Register leaf node: SMSC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: SMSC E.134 number. +IP0: OMC0 IP, 172.18.98.1. +IP1: OMC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SMPP_EMSE(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.19) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) + + +Register leaf node: SMPP_EMSE. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: VMS-SMPP E.134 number. +IP0: VMS0 IP, 172.18.147.1. +IP1: VMS1 IP, 172.18.148.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SMPP_SMSC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.20) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) + + +Register leaf node: SMPP_SMSC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: SMSC-SMPP E.134 number. +IP0: SMSC0 IP, 172.18.98.1. +IP1: SMSC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SMPP_OMC(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.21) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) +-> -> SMPP_OMC(9) + + +Register leaf node: SMPP_OMC. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: OMC-SMPP E.134 number. +IP0: OMC0 IP, 172.18.128.1. +IP1: OMC1 IP, 172.18.129.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SRF(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.22) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) +-> -> SMPP_OMC(9) +-> -> SRF(10) + + +Register leaf node: SRF. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: VMS SRF E.134 number. +IP0: VMS0 IP, 172.18.147.1. +IP1: VMS1 IP, 172.18.148.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SSF(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.143) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) +-> -> SMPP_OMC(9) +-> -> SRF(10) +-> -> SSF(11) + + +Register leaf node: SSF. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: MSC SSF E.134 number. +IP0: MSC0 IP, 172.18.98.1. +IP1: MSC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: SCF(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.147) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) +-> -> SMPP_OMC(9) +-> -> SRF(10) +-> -> SSF(11) +-> -> SCF(12) + + +Register leaf node: SCF. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: PPS SCF E.134 number. +IP0: PPS0 IP, 172.18.98.1. +IP1: PPS1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: AIF(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.1.254) +-> father_name = [Local_Node] +-> -> OMC(0) +-> -> HLR(1) +-> -> VLR(2) +-> -> MSC(3) +-> -> EIR(4) +-> -> AUC(5) +-> -> SMSC(6) +-> -> SMPP_EMSE(7) +-> -> SMPP_SMSC(8) +-> -> SMPP_OMC(9) +-> -> SRF(10) +-> -> SSF(11) +-> -> SCF(12) +-> -> AIF(13) + + +Register leaf node: AIF. +Instance: 1 +Length : 19 +Flag : 255 +Default : +Remark : NI: Network indicator. +0=International network. +1=International network spare. +2=National network. +3=National network spare. +MSISDN: AIF E.134 number. +IP0: MSC0 IP, 172.18.98.1. +IP1: MSC1 IP, 172.18.99.1. + +Field : total(4) +Access : read-write[1]NI + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low F + } +[2]MSISDN + { + [u]1.0-10.7 + [u]input + [v]KeepHex Low F + } +[3]IP0 + { + [u]11.0-14.7 + [u]input + [v]KeepHex Low F + } +[4]IP1 + { + [u]15.0-18.7 + [u]input + [v]KeepHex Low F + } + + +Create node: GTT_Table(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.2.2) +-> father_name = [Config_SCCP] +-> -> Local_Node(0) +-> -> GTT_Table(1) + + +Register leaf node: GTT_Table. +Instance: 256 +Length : 43 +Flag : 255 +Default : +Remark : On/off: GTT flag, off=disable, on=enable. +Numbering plan: 1=MSISDN, 3=IMSI, 7=GT. +Specify the beginning number of a group of consecutive numbers routed by GTT, for single-number GTT route, the start number is same as the end number. +End GT number: Specify the end number of a group of consecutive number routed by GT. If there are some inconsecutive numbers for a same destination, a different GTT record should be set. +Network indicator (NI): 0=International network, 1=International network spare, 2=National network, 3=National network spare, +DPC: Destination point code. +SSN: Subsystem number. +2=Reserved for ITU-T allocation. +3=ISDN user part. +4=OMC. +5=MAP. +3=HLR. +7=VLR. +8=MSC. +9=EIR. +10=AUC. +11=SMSC. +147=PPS. +254=BSSMAP. +Route indicator: For IMSI and MSISDN, select Route on SSN. For the record of the connected network, select Route on GT. +Address indicator: select the contribution of SCCP Address. +Replaced start digit: Specify the beginning digit of a segment of digits to be replaced within a GT number, the replacement is for changing number and numbering plan. +Replaced end digit: Specify the end digit of a segment of digits to be replaced within a GT number, the replacement is for changing number and numbering plan. +Outgoing number plan: Outgoing number plan, include MSISDN, IMSI and GT. +Replacing digits: Replacing digits, the length of replacing digits and replaced digits may be different. + +Field : total(14) +Access : read-write [1]On/off + { + [u]0.0-0.7 + [u]select + [v]1[opt]On + [v]0[opt]Off + } + [2]Numbering plan + { + [u]1.0-1.7 + [u]select + [v]0[opt]0 + [v]1[opt]MSISDN + [v]6[opt]IMSI + [v]7[opt]GT + } +[3]TT + { + [u]2.0-2.7 + [u]input + [v]KeepHex Low F + } +[4]Start GT number + { + [u]3.0-12.7 + [u]input + [v]KeepHex Low F + } +[4]End GT number + { + [u]13.0-22.7 + [u]input + [v]KeepHex Low F + } + [5]Network indicator + { + [u]23.0-23.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + } +[6]DPC + { + [u]24.0-26.7 + [u]input + [v]toDec high 0 + } +[7]SSN + { + [u]27.0-27.7 + [u]input + [v]toDec high 0 + } + [8]Route indicator + { + [u]28.0-28.7 + [u]select + [v]0[opt]Route on GT + [v]1[opt]Route on SSN + } + [9]Address indicator + { + [u]29.0-29.7 + [u]select + [v]0[opt]NULL + [v]3[opt]DPC+SSN + [v]6[opt]GT+SSN + [v]7[opt]GT+DPC+SSN + } +[10]Replaced start digit + { + [u]30.0-30.7 + [u]input + [v]KeepHex high 0 + } +[11]Replaced end digit + { + [u]31.0-31.7 + [u]input + [v]KeepHex high 0 + } + [12]Outgoing number plan + { + [u]32.0-32.7 + [u]select + [v]1[opt]MSISDN + [v]6[opt]IMSI + [v]7[opt]GT + } +[13]Replacing digits + { + [u]33.0-42.7 + [u]input + [v]KeepHex Low F + } + + +Create node: Management(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.3) +-> father_name = [SCCP] +-> -> Config_SCCP(0) +-> -> Management(1) + + +Remark: Management. + + +Create node: Version(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.3.1) +-> father_name = [Management] +-> -> Version(0) + + +Register leaf node: Version. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of SCCP platform software (Read Only). +Byte0: System release version number, based on basic function and structure. +Byte1: Software module version number, based on software module. +Byte2: Test version, 0=Release version number, 1=Test version number. + +Field : total(0) +Access : read-write + +Create node: Command_SCCP(OID: 1.3.6.1.4.1.1373.1.3.2.2.3.3.2) +-> father_name = [Management] +-> -> Version(0) +-> -> Command_SCCP(1) + + +Register leaf node: Command_SCCP. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Control command for SCCP. +Reset: Used for SCCP status initialization. +Load parameter: Load the parameters from device's harddisk to device's memory. +Save parameter: Save the parameters residing in device's memory into device's harddisk. + +Field : total(1) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]0[opt]Reset + [v]2[opt]Save parameters + } + + +Create node: XAPP(OID: 1.3.6.1.4.1.1373.1.3.2.2.5) +-> father_name = [SS7] +-> -> MTP3(0) +-> -> SCCP(1) +-> -> XAPP(2) + + +Remark: Subsystems for XAPP . + + +Create node: Config_XAPP(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2) +-> father_name = [XAPP] +-> -> Config_XAPP(0) + + +Remark: XAPP Configuration. + + +Create node: MCC(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.1) +-> father_name = [Config_XAPP] +-> -> MCC(0) + + +Register leaf node: MCC. +Instance: 1 +Length : 2 +Flag : 255 +Default : F +Remark : Mobile country code. + +Field : total(1) +Access : read-write[1]MCC + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } + + +Create node: MNC(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.2) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) + + +Register leaf node: MNC. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Mobile network code. + +Field : total(1) +Access : read-write[1]MNC + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low E + } + + +Create node: CC(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.3) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) + + +Register leaf node: CC. +Instance: 1 +Length : 2 +Flag : 255 +Default : 嗩 +Remark : Country code. + +Field : total(1) +Access : read-write[1]CC + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } + + +Create node: NDC(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.4) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) + + +Register leaf node: NDC. +Instance: 1 +Length : 3 +Flag : 255 +Default : u^ +Remark : National destination code. + +Field : total(1) +Access : read-write[1]NDC + { + [u]0.0-2.7 + [u]input + [v]KeepHex Low E + } + + +Create node: International_Prefix(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.5) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) + + +Register leaf node: International_Prefix. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : International call prefix. + +Field : total(1) +Access : read-write[1]International prefix + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } + + +Create node: National_Prefix(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.6) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) +-> -> National_Prefix(5) + + +Register leaf node: National_Prefix. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : National call prefix. + +Field : total(1) +Access : read-write[1]National prefix + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Local_Prefix(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.7) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) +-> -> National_Prefix(5) +-> -> Local_Prefix(6) + + +Register leaf node: Local_Prefix. +Instance: 1 +Length : 2 +Flag : 255 +Default : 铑 +Remark : Local prefix. + +Field : total(0) +Access : read-write + +Create node: Conv_Prefix(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.8) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) +-> -> National_Prefix(5) +-> -> Local_Prefix(6) +-> -> Conv_Prefix(7) + + +Register leaf node: Conv_Prefix. +Instance: 128 +Length : 35 +Flag : 255 +Default : +Remark : Conv prefix . + +Field : total(5) +Access : read-write[1]Prefix + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } +[2]Delete length + { + [u]0.0-0.0 + [u]input + [v]toDec high 0 + } +[3]Add length + { + [u]17.0-17.7 + [u]input + [v]toDec high 0 + } +[4]Add digits + { + [u]18.0-33.7 + [u]input + [v]ToAscii Low 0 + } +[5]Valid length + { + [u]34.0-34.7 + [u]input + [v]toDec high 0 + } + + +Create node: CLI_Conv_Prefix(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.9) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) +-> -> National_Prefix(5) +-> -> Local_Prefix(6) +-> -> Conv_Prefix(7) +-> -> CLI_Conv_Prefix(8) + + +Register leaf node: CLI_Conv_Prefix. +Instance: 8 +Length : 37 +Flag : 255 +Default : +Remark : CLI_Conv prefix . + +Field : total(7) +Access : read-write [1]In property + { + [u]0.0-0.7 + [u]select + [v]1[opt]IDD + [v]2[opt]NDD + [v]3[opt]Unknown + } +[2]Prefix + { + [u]1.0-16.7 + [u]input + [v]ToAscii Low 0 + } +[3]Delete length + { + [u]17.0-17.7 + [u]input + [v]toDec high 0 + } + [4]Out property + { + [u]18.0-18.7 + [u]select + [v]1[opt]IDD + [v]2[opt]NDD + [v]3[opt]Unknown + } +[5]Add length + { + [u]19.0-19.7 + [u]input + [v]toDec high 0 + } +[6]Add digits + { + [u]20.0-35.7 + [u]input + [v]ToAscii Low 0 + } +[7]Valid length + { + [u]36.0-36.7 + [u]input + [v]toDec high 0 + } + + +Create node: mscid_to_number(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.2.10) +-> father_name = [Config_XAPP] +-> -> MCC(0) +-> -> MNC(1) +-> -> CC(2) +-> -> NDC(3) +-> -> International_Prefix(4) +-> -> National_Prefix(5) +-> -> Local_Prefix(6) +-> -> Conv_Prefix(7) +-> -> CLI_Conv_Prefix(8) +-> -> mscid_to_number(9) + + +Register leaf node: mscid_to_number. +Instance: 256 +Length : 12 +Flag : 255 +Default : +Remark : Conv prefix . + +Field : total(4) +Access : read-write[1]Market ID + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]Switch Number + { + [u]2.0-2.7 + [u]input + [v]toDec high 0 + } +[3]SSN + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } +[4]Number + { + [u]4.0-11.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Status_XAPP(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.3) +-> father_name = [XAPP] +-> -> Config_XAPP(0) +-> -> Status_XAPP(1) + + +Remark: XAPP Status. + + +Create node: Version_XAPP(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.3.1) +-> father_name = [Status_XAPP] +-> -> Version_XAPP(0) + + +Register leaf node: Version_XAPP. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of XAPP module (Read Only). +Byte0: System release version number, based on basic function and structure. +Byte1: Software module version number, based on software module. +Byte2: Test version, 0=Release version number, 1=Test version number. + +Field : total(0) +Access : read-only + +Create node: Command_XAPP(OID: 1.3.6.1.4.1.1373.1.3.2.2.5.3.2) +-> father_name = [Status_XAPP] +-> -> Version_XAPP(0) +-> -> Command_XAPP(1) + + +Register leaf node: Command_XAPP. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Control command for XAPP. +Save parameter: Save the parameters in memory into local harddisk. + +Field : total(1) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]1[opt]Save parameters + } + + +Create node: Maplat(OID: 1.3.6.1.4.1.1373.1.3.2.3) +-> father_name = [Platform] +-> -> SS7(0) +-> -> Maplat(1) + + +Remark: + Subsystems for Maplat . + + +Create node: SMPP(OID: 1.3.6.1.4.1.1373.1.3.2.3.4) +-> father_name = [Maplat] +-> -> SMPP(0) + + +Remark: Subsystems for SMPP . + + +Create node: Config_SMPP(OID: 1.3.6.1.4.1.1373.1.3.2.3.4.2) +-> father_name = [SMPP] +-> -> Config_SMPP(0) + + +Remark: SMPP Configuration. + + +Create node: SMPP_Link_Parameter(OID: 1.3.6.1.4.1.1373.1.3.2.3.4.2.1) +-> father_name = [Config_SMPP] +-> -> SMPP_Link_Parameter(0) + + +Register leaf node: SMPP_Link_Parameter. +Instance: 32 +Length : 106 +Flag : 255 +Default : +Remark : Session type: BIND_TX-bind as transmitter, BIND_RX-bind as receiver, BIND_TRX-bind as transceiver. +System ID: using in BIND and OUTBIND. +Password: The password parameter is used by the SMSC to authenticate the identity of the binding ESME. The Service Provider may require ESME’s to provide a password when binding to the SMSC. This password is normally issued by the SMSC system administrator. +The password parameter may also be used by the ESME to authenticate the identity of the binding SMSC (e.g. in the case of the outbind operation). +System type: The system_type may be used to categorise the system, e.g., “EMAIL”, “WWW”, etc. +The system_type parameter is used to categorize the type of ESME that is binding to the SMSC. Examples include “VMS” (voice mail system) and “OTA” (over-the-air activation system). +Specification of the system_type is optional - some SMSC’s may not require ESME’s to provide this detail. In this case, the ESME can set the system_type to NULL. +IP: Specify the IP addresses of 16 SMPP connected devices.
e.g. 0xAC127001=172.18.112.1.
+Session init timer: This timer specifies the time lapse allowed between a network connection being established and a bind_transmitter or bind_receiver request being sent to SMSC. This timer should be active on the SMSC. +Enquire link timer: This timer specifies the time lapse allowed between operations after which an SMPP entity should interrogate whether it's peer still has an active session. +The scale is second. +Inactivity timer: This timer specifies the maximum time lapse allowed between transactions, after which period of inactivity, an SMPP entity may assume that the session is no longer active. This timer may be active on either commnicating SMPP entity(i.e. SMSC or ESME) +Response timer: This timer specifies the maximum time lapse allowed between transactions, after which period of inactivity, an SMPP entity may assume that the session is no longer active. This timer may be active on either commnicating SMPP entity(i.e. SMSC or ESME) +Local service number: compare with application's service number while bind as TX or TRX. +remote service number: compare with application's service number while bind as RX + +Field : total(16) +Access : read-write [1]Link enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Link type + { + [u]1.0-1.7 + [u]select + [v]0[opt]UDP + [v]1[opt]TCP + } + [3]Server type + { + [u]2.0-2.7 + [u]select + [v]0[opt]SMPP_CLIENT + [v]1[opt]SMPP_SERVER + } + [4]Session type + { + [u]3.0-3.7 + [u]select + [v]0[opt]BIND_TX + [v]1[opt]BIND_RX + [v]2[opt]BIND_TRX + } +[5]System ID + { + [u]4.0-19.7 + [u]input + [v]ToAscii Low 0 + } +[6]Password + { + [u]20.0-28.7 + [u]input + [v]ToAscii Low 0 + } +[7]System type + { + [u]29.0-41.7 + [u]input + [v]ToAscii Low 0 + } +[8]Local GTT + { + [u]42.0-57.7 + [u]input + [v]ToAscii Low 0 + } +[9]Remote GTT + { + [u]58.0-73.7 + [u]input + [v]ToAscii Low 0 + } +[10]Local IP + { + [u]74.0-77.7 + [u]input + [v]KeepHex Low F + } +[11]Remote IP + { + [u]78.0-81.7 + [u]input + [v]KeepHex Low F + } +[12]Session init timer + { + [u]82.0-85.7 + [u]input + [v]toDec high 0 + } +[13]Enquire link timer + { + [u]86.0-89.7 + [u]input + [v]toDec high 0 + } +[14]Inactivity timer + { + [u]90.0-93.7 + [u]input + [v]toDec high 0 + } +[15]Response timer + { + [u]94.0-97.7 + [u]input + [v]toDec high 0 + } +[16]Remote service number + { + [u]98.0-105.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Status_SMPP(OID: 1.3.6.1.4.1.1373.1.3.2.3.4.3) +-> father_name = [SMPP] +-> -> Config_SMPP(0) +-> -> Status_SMPP(1) + + +Remark: XAPP Status. + + +Create node: Command_SMPP(OID: 1.3.6.1.4.1.1373.1.3.2.3.4.3.2) +-> father_name = [Status_SMPP] +-> -> Command_SMPP(0) + + +Register leaf node: Command_SMPP. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Control command for SMPP. + +Field : total(1) +Access : write-only [1]Command + { + [u]0.0-0.7 + [u]select + [v]2[opt]save parameter + } + + +Create node: MSC(OID: 1.3.6.1.4.1.1373.1.3.3.2) +-> father_name = [App] +-> -> MSC(0) + + +Remark: + Subsystems for msc . + + +Create node: CCF(MSC)(OID: 1.3.6.1.4.1.1373.1.3.3.2.2) +-> father_name = [MSC] +-> -> CCF(MSC)(0) + + +Remark: Subsystems for msc . + + +Create node: CCF_Config(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2) +-> father_name = [CCF(MSC)] +-> -> CCF_Config(0) + + +Remark: + Configuration for CCF . + + +Create node: Call_Routing(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) + + +Remark: + Call Routing . + + +Create node: Prefix_Assignment(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.1) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) + + +Register leaf node: Prefix_Assignment. +Instance: 256 +Length : 8 +Flag : 255 +Default : 铑铑铑铑 +Remark : 4 bytes are used to set a 8-digit prefix for dialed number. +Prefix is the first layer for dialed number based call routing. If the dialed number of a call matches a pre-programmed prefix in this table, this call will be routed to a certain trunk group, subsequently that trunk group will route this call via a dedicated E1 port.This system has totally 256 prefixes. +Dialed number without matching a pre-programmed prefix will be routed to the default trunk group 0. +Prefix 252 is for default international call, all internation calls unable to be routed out will be routed from the trunk group assigned to prefix 252, keep default EEEEEEEE. +Prefix 253 is for default national call, all national calls unable to be routed out will be routed from the trunk group assigned to prefix 253, keep default EEEEEEEE. +Prefix 254 is for default subscriber call, all dialed MSISDN unable to be routed out will be routed from the trunk group assigned to prefix 254, keep default EEEEEEEE. +Prefix 255 is for unknown call, all unknown calls unable to be routed out will be routed from the trunk group assigned to prefix 255, keep default EEEEEEEE. +E=End tag, C='#', B='*'. +Default=0xEEEEEEEE. + +Field : total(1) +Access : read-write[1]Prefix + { + [u]0.0-7.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Prefix_Attributes(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.2) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) + + +Register leaf node: Prefix_Attributes. +Instance: 256 +Length : 18 +Flag : 9 +Default : " +Remark : Enable: Y=prefix enable, N=prefix disable. +TON incoming call: Type of number for incoming call, include unknown, MSISDN, NDD and IDD. It is specified by originating node for terminating node to route this call with proper dialed number manipulation. +For system subscriber dialed prefix, always use unknown for In-TON except the prefix of international prefix beginning with a . For this kind of prefix (such as 86755832) we should set the In-TON as IDD to support dialing. +TON outgoing call: Type of number for outgoing call, include unknown, MSISDN, NDD and IDD. It specifies the type of an outgoing call for terminating node to route this call with proper dialed number manipulation. Generally the MSC uses IDD for outgoing call. +Out trunk deletion count: Quantity of deleted digit of a dialed number beginning with this prefix. It ranges from 0 to 8. 0=no deletion, 1-8=delete first 1-8 digits. +Out trunk insertion count: Quantity of inserted digit for a dialed number beginning with this prefix. It ranges from 0 to 8. 0=no insertion, 1-8=insert 1-8 digits from the beginning of this number. +Out trunk inserted digits: 8 digits ranging from EEEEEEEE to 99999999, E=any decimal number. +CDR on/off: Turn on/off the CDR of dialed numbers beginning with this prefix. +Properties: Specify the properties of a prefix. Trunk=to PSTN, MSISDN=to A interface, MSRN=MS roaming number, MSC=to peer MSC. +Call type: Normal=no verification for MT, Emergency call=no verification for MO (free call), MCT=Malicious Call Trace, VMS call=send signaling carried DTMF to VMS. +Length of dialed number: Length of dialed number (1-32). +E.164 international deletion count: Quantity of deleted digit of E164 international number, always use IDD for outgoing call for PPS debiting. +E.164 international insertion count: Quantity of inserted digit of E164 international number, always use IDD for outgoing call for PPS debiting. +E.164 international inserted digits: Inserted digit to the E164 international number, 8 digits ranging from EEEEEEEE to 99999999, E=any decimal number, always use IDD for outgoing call for PPS debiting. + +Field : total(15) +Access : read-write [1]TON incoming call + { + [u]0.0-0.3 + [u]select + [v]0[opt]Spare + [v]1[opt]MSISDN + [v]2[opt]Unkown + [v]3[opt]NDD + [v]4[opt]IDD + [v]5[opt]Spare + } + [2]TON outgoing call + { + [u]0.4-0.7 + [u]select + [v]0[opt]Spare + [v]1[opt]MSISDN + [v]2[opt]Unkown + [v]3[opt]NDD + [v]4[opt]IDD + [v]5[opt]Spare + } + [3]Out trunk deletion count + { + [u]1.0-1.3 + [u]select + [v]0[opt]Delete none + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + [4]Out trunk insertion count + { + [u]1.4-1.7 + [u]select + [v]0[opt]Insert none + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } +[5]Out trunk inserted digits + { + [u]2.0-9.7 + [u]input + [v]KeepHex Low E + } + [6]CDR on/off + { + [u]10.0-10.0 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [8]Properties + { + [u]10.2-10.3 + [u]select + [v]0[opt]Trunk + [v]1[opt]MSISDN + [v]2[opt]MSRN + [v]3[opt]MSC + } + [9]Call type + { + [u]10.4-10.6 + [u]select + [v]0[opt]Normal Call + [v]1[opt]Emergency + [v]2[opt]MCT + [v]3[opt]VMS + [v]4[opt]IN + } + [10]Enable + { + [u]10.7-10.7 + [u]select + [v]0[opt]N + [v]1[opt]Y + } +[11]Length of dialed number + { + [u]11.0-11.7 + [u]input + [v]toDec high 0 + } + [12]E.164 International deletion count + { + [u]12.0-12.3 + [u]select + [v]0[opt]Delete none + [v]1[opt]Delete first one + [v]2[opt]Delete first two + [v]3[opt]Delete first three + [v]4[opt]Delete first four + [v]5[opt]Delete first five + [v]6[opt]Delete first six + [v]7[opt]Delete first seven + [v]8[opt]Delete first eight + } + [13]E.164 International insertion count + { + [u]12.4-12.7 + [u]select + [v]0[opt]Insert none + [v]1[opt]Insert first one + [v]2[opt]Insert first two + [v]3[opt]Insert first three + [v]4[opt]Insert first four + [v]5[opt]Insert first five + [v]6[opt]Insert first six + [v]7[opt]Insert first seven + [v]8[opt]Insert first eight + } +[14]E.164 international inserted digits + { + [u]13.0-16.7 + [u]input + [v]KeepHex Low E + } + [15]Cli-type + { + [u]17.0-17.7 + [u]select + [v]0[opt]Sub + [v]1[opt]NDD + [v]2[opt]IDD + [v]3[opt]Unknown(local) + [v]4[opt]Unknown(NDD) + [v]5[opt]Unknown(IDD) + } + + +Create node: Prefix_TG(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.3) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) +-> -> Prefix_TG(2) + + +Register leaf node: Prefix_TG. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Assign a trunk group for each prefix for call routing, a single prefix points to only one trunk group, multiple prefix can be assigned the same trunk group, default is the no. of the prefix. + +Field : total(1) +Access : read-write[1]Assign TG to prefix + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: TG_Attributes(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.4) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) +-> -> Prefix_TG(2) +-> -> TG_Attributes(3) + + +Register leaf node: TG_Attributes. +Instance: 256 +Length : 10 +Flag : 1 +Default : +Remark : DPC: Destination point code of this trunk group. +TG flag: enable or disable this trunk group. +CDR on/off: CDR on or off option for this trunk group. +Announcement: Voice announcement enable or disable for this trunk group. +TG category: PSTN=to PSTN, IP=to VMS and VPS, HPLMN=to HPLMN, VPLMN=to VPLMN, SUB=to BSC, Intercept=to intercept LEA +Alternative TG flag: Alternative trunk group enable or disable option. +Alternative TG: Alternative trunk group for backup purpose. +Loop back: Incoming call loop back enable or disable, used for MSC loop back. +Network indicator: Specify network type, International, International spare , National, National spare. +Circuit selection: Preferred circuit selection mode, include clockwise, anti-clockwise, odd and even. +Back off: Back off on or off when simultaneously select the same channel with the opposite side. +Location: For normal trunk group, select Both. For a trunk group to a VPS, configure this trunk group as MSC0 or MSC1. +MPTY: Multi-party call enable or disable. For all trunk groups to BSC, select Enable. +Tandem restriction:Y: Tandem disabled. Not support transit call from PSTN to PSTN via this trunk group. +N: Tandem enabled. Support transit call from PSTN to PSTN via this trunk group. + +Field : total(16) +Access : read-write[1]DPC + { + [u]0.0-3.7 + [u]input + [v]KeepHex high 0 + } + [2]TG flag + { + [u]4.0-4.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]CDR on/off + { + [u]4.1-4.1 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [4]Announcement + { + [u]4.2-4.2 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [5]TG category + { + [u]4.3-4.5 + [u]select + [v]0[opt]PSTN + [v]1[opt]HPLMN + [v]2[opt]VHLMN + [v]3[opt]SUB + [v]4[opt]IP + [v]5[opt]Intercept + } + [6]Alternative TG flag + { + [u]4.6-4.6 + [u]select + [v]0[opt]Disable + [v]1[opt]enable + } + [7]Loopback + { + [u]4.7-4.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [8]Network indicator + { + [u]5.0-5.7 + [u]select + [v]0[opt]International + [v]1[opt]International spare + [v]2[opt]National + [v]3[opt]National spare + } + [9]Circuit selection + { + [u]6.0-6.1 + [u]select + [v]0[opt]Clockwise + [v]1[opt]Anti-clockwise + [v]2[opt]Odd + [v]3[opt]Even + } + [10]Back off + { + [u]6.2-6.2 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + [12]MPTY + { + [u]6.5-6.5 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [13]Location + { + [u]6.6-6.7 + [u]select + [v]0[opt]MSC-0 + [v]1[opt]MSC-1 + [v]2[opt]Both + [v]3[opt]Spare + } +[14]Alternative TG + { + [u]7.0-7.7 + [u]input + [v]toDec high 0 + } + [15]Tandem restriction + { + [u]8.0-8.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [16]Incoming Call type + { + [u]9.0-9.7 + [u]select + [v]0[opt]Normal + [v]1[opt]IN + } + + +Create node: Call_Routing_CDR_Flag(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.5) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) +-> -> Prefix_TG(2) +-> -> TG_Attributes(3) +-> -> Call_Routing_CDR_Flag(4) + + +Register leaf node: Call_Routing_CDR_Flag. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Sorm: call intercept MCT: malicious call trace +Default=CDR of MO call and MT call is enabled, CDR of roaming call, gateway incoming call, gateway outgoing call, transit call, MO SMS and MT SMS is disabled. + +Field : total(13) +Access : read-write [2]Redirection + { + [u]0.3-0.3 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [3]Feature Request + { + [u]0.2-0.2 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [4]Sorm + { + [u]0.1-0.1 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [5]MCT + { + [u]0.0-0.0 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [6]MT SM + { + [u]1.7-1.7 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [7]MO SM + { + [u]1.6-1.6 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [8]Transit call + { + [u]1.5-1.5 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [9]Gateway outgoing call + { + [u]1.4-1.4 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [10]Gateway incoming call + { + [u]1.3-1.3 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [11]Roaming call + { + [u]1.2-1.2 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [12]MT call + { + [u]1.1-1.1 + [u]select + [v]0[opt]off + [v]1[opt]on + } + [13]MO call + { + [u]1.0-1.0 + [u]select + [v]0[opt]off + [v]1[opt]on + } + + +Create node: Voice_Prompt_Announcement_option(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.6) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) +-> -> Prefix_TG(2) +-> -> TG_Attributes(3) +-> -> Call_Routing_CDR_Flag(4) +-> -> Voice_Prompt_Announcement_option(5) + + +Register leaf node: Voice_Prompt_Announcement_option. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Set to play either announcement or tone indicating call unattainable reason for subscribers. System has total 8 announcements and tones that can be independently set. +Announcement 0: The dialed number is invalid. +Announcement 1: The subscriber dialed is not activated. +Announcement 2: The subscriber is busy. +Announcement 3: The network is busy. +Announcement 4: Caller's account was deactivated. +Announcement 5: The subscriber dialed was deactivated. +Announcement 6: Feature not available to caller. +Announcement 7: The subscriber dialed is not available. + +Field : total(16) +Access : read-write [1]Announcement 0 + { + [u]0.0-0.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [2]Announcement 1 + { + [u]1.0-1.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [3]Announcement 2 + { + [u]2.0-2.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [4]Announcement 3 + { + [u]3.0-3.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [5]Announcement 4 + { + [u]4.0-4.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [6]Announcement 5 + { + [u]5.0-5.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [7]Announcement 6 + { + [u]6.0-6.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [8]Announcement 7 + { + [u]7.0-7.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [9]Announcement 8 + { + [u]8.0-8.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [10]Announcement 9 + { + [u]9.0-9.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [11]Announcement 10 + { + [u]10.0-10.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [12]Announcement 11 + { + [u]11.0-11.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [13]Announcement 12 + { + [u]12.0-12.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [14]Announcement 13 + { + [u]13.0-13.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [15]Announcement 14 + { + [u]14.0-14.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + [16]Announcement 15 + { + [u]15.0-15.7 + [u]select + [v]0[opt]None + [v]1[opt]Tone + [v]2[opt]Voice + [v]3[opt]lease line + } + + +Create node: Call_Routing_Warning(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.1.7) +-> father_name = [Call_Routing] +-> -> Prefix_Assignment(0) +-> -> Prefix_Attributes(1) +-> -> Prefix_TG(2) +-> -> TG_Attributes(3) +-> -> Call_Routing_CDR_Flag(4) +-> -> Voice_Prompt_Announcement_option(5) +-> -> Call_Routing_Warning(6) + + +Register leaf node: Call_Routing_Warning. +Instance: 1 +Length : 1 +Flag : 255 +Default : 2 +Remark : Set time to play prompt tone for reaching zero balance prepaid subscriber when a call is in progress, unit is second. e.g. if set as 60, the system will play prompt tone one minute before a subscriber uses up his balance. + +Field : total(1) +Access : read-write[1]Remanent time for warning tone + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: CCF_MSC(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.2) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) + + +Remark: CCF Configuration MSC . + + +Create node: Emergency_Call(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.2.5) +-> father_name = [CCF_MSC] +-> -> Emergency_Call(0) + + +Register leaf node: Emergency_Call. +Instance: 256 +Length : 21 +Flag : 0 +Default : +Remark : Emergency call number. Default=112. + +Field : total(5) +Access : read-write [1]Enable flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]LAC + { + [u]1.0-2.7 + [u]input + [v]toDec high 0 + } +[3]CI + { + [u]3.0-4.7 + [u]input + [v]toDec high 0 + } +[4]Dial number + { + [u]5.0-12.7 + [u]input + [v]KeepHex Low E + } +[5]Local emergency number + { + [u]13.0-20.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Location_Management(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.2.8) +-> father_name = [CCF_MSC] +-> -> Emergency_Call(0) +-> -> Location_Management(1) + + +Register leaf node: Location_Management. +Instance: 256 +Length : 8 +Flag : 0 +Default : +Remark : Manage the MS location by correlate TG (trunk group), LAC (location area code, cell ID and zone code, totally 256 location management. + +Field : total(5) +Access : read-write [1]Enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]N + [v]1[opt]Y + } +[2]TG + { + [u]1.0-1.7 + [u]input + [v]toDec high 0 + } +[3]LAC + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[4]CI + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } +[5]Zone Code + { + [u]6.0-7.7 + [u]input + [v]toDec high 0 + } + + +Create node: CPC(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.3) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) +-> -> CPC(2) + + +Remark: CPC Management. + + +Create node: SRF_Address(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.3.3) +-> father_name = [CPC] +-> -> SRF_Address(0) + + +Register leaf node: SRF_Address. +Instance: 1 +Length : 8 +Flag : 255 +Default : 唘P +Remark : E.164 number of HLR server:HLR MSISDN used for SCCP addressing, F=end tag. +Default=91867555950502FFFF=91867555950502. + +Field : total(1) +Access : read-write[1]EIR number + { + [u]0.0-7.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Max_Call_Duration(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.3.7) +-> father_name = [CPC] +-> -> SRF_Address(0) +-> -> Max_Call_Duration(1) + + +Register leaf node: Max_Call_Duration. +Instance: 1 +Length : 1 +Flag : 255 +Default : < +Remark : Define the permitted maximum call duration. Any ongoing call reaching this duration threshold will be compulsively cut off. byte value: 0=disable this function, 1-255=max. call duration, unit=minute. Default=0. + +Field : total(1) +Access : read-write[1]Max. call duration + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: E1_Port(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.4) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) +-> -> CPC(2) +-> -> E1_Port(3) + + +Remark: E1 Port. + + +Create node: E1_Interface(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.4.1) +-> father_name = [E1_Port] +-> -> E1_Interface(0) + + +Register leaf node: E1_Interface. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Set the type of E1 interface for 256 E1 ports. + +Field : total(1) +Access : read-write [1]E1 interface + { + [u]0.0-0.7 + [u]select + [v]0[opt]TUP + [v]1[opt]ISUP + [v]2[opt]AIF + [v]3[opt]AIF CDMA2K + [v]4[opt]BICC + [v]5[opt]CI-CNF + [v]6[opt]CI-loopback + } + + +Create node: E1_TG(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.4.2) +-> father_name = [E1_Port] +-> -> E1_Interface(0) +-> -> E1_TG(1) + + +Register leaf node: E1_TG. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Assign a trunk group to each E1 port for call routing. A single E1 port points to only one trunk group, multiple E1 port can be assigned the same trunk group. Default=number of the E1 port. + +Field : total(1) +Access : read-write[1]Assign TG + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: E1_CIC(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.4.3) +-> father_name = [E1_Port] +-> -> E1_Interface(0) +-> -> E1_TG(1) +-> -> E1_CIC(2) + + +Register leaf node: E1_CIC. +Instance: 256 +Length : 4 +Flag : 255 +Default : +Remark : Circuit identity code, uniquely identify each circuit within a trunk group. CIC of both ends of a circuit must be identical. 256 CIC for dual MSC platform 256 E1 ports. + +Field : total(1) +Access : read-write[1]E1 CIC + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: E1_Media_Control_Attributes(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.4.4) +-> father_name = [E1_Port] +-> -> E1_Interface(0) +-> -> E1_TG(1) +-> -> E1_CIC(2) +-> -> E1_Media_Control_Attributes(3) + + +Register leaf node: E1_Media_Control_Attributes. +Instance: 256 +Length : 4 +Flag : 255 +Default : +Remark : E1 Media Control Attributes + +Field : total(4) +Access : read-write [1]E1 Control Protocol Type + { + [u]0.0-0.7 + [u]select + [v]0[opt]Internal + [v]1[opt]MGCP + } + [2]E1 Enable + { + [u]1.0-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[3]MG Number + { + [u]2.0-2.7 + [u]input + [v]toDec high 0 + } +[4]Trunk Number + { + [u]3.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Channel_Attributes(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) +-> -> CPC(2) +-> -> E1_Port(3) +-> -> Channel_Attributes(4) + + +Remark: Channel attributes. + + +Create node: Card0_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.1) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) + + +Register leaf node: Card0_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card1_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.2) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) + + +Register leaf node: Card1_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card2_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.3) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) + + +Register leaf node: Card2_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card3_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.4) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) + + +Register leaf node: Card3_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card4_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.5) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) + + +Register leaf node: Card4_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card5_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.6) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) + + +Register leaf node: Card5_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card6_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.7) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) + + +Register leaf node: Card6_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card7_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.8) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) + + +Register leaf node: Card7_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card8_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.9) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) + + +Register leaf node: Card8_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card9_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.10) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) + + +Register leaf node: Card9_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card10_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.11) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) + + +Register leaf node: Card10_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card11_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.12) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) + + +Register leaf node: Card11_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card12_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.13) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) + + +Register leaf node: Card12_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card13_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.14) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) + + +Register leaf node: Card13_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card14_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.15) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) + + +Register leaf node: Card14_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card15_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.16) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) + + +Register leaf node: Card15_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card16_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.17) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) + + +Register leaf node: Card16_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card17_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.18) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) + + +Register leaf node: Card17_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card18_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.19) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) + + +Register leaf node: Card18_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card19_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.20) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) + + +Register leaf node: Card19_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card20_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.21) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) + + +Register leaf node: Card20_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card21_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.22) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) + + +Register leaf node: Card21_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card22_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.23) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) + + +Register leaf node: Card22_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card23_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.24) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) + + +Register leaf node: Card23_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card24_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.25) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) + + +Register leaf node: Card24_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card25_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.26) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) + + +Register leaf node: Card25_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card26_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.27) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) + + +Register leaf node: Card26_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card27_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.28) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) +-> -> Card27_Channel(27) + + +Register leaf node: Card27_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card28_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.29) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) +-> -> Card27_Channel(27) +-> -> Card28_Channel(28) + + +Register leaf node: Card28_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card29_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.30) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) +-> -> Card27_Channel(27) +-> -> Card28_Channel(28) +-> -> Card29_Channel(29) + + +Register leaf node: Card29_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card30_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.31) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) +-> -> Card27_Channel(27) +-> -> Card28_Channel(28) +-> -> Card29_Channel(29) +-> -> Card30_Channel(30) + + +Register leaf node: Card30_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Card31_Channel(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.5.32) +-> father_name = [Channel_Attributes] +-> -> Card0_Channel(0) +-> -> Card1_Channel(1) +-> -> Card2_Channel(2) +-> -> Card3_Channel(3) +-> -> Card4_Channel(4) +-> -> Card5_Channel(5) +-> -> Card6_Channel(6) +-> -> Card7_Channel(7) +-> -> Card8_Channel(8) +-> -> Card9_Channel(9) +-> -> Card10_Channel(10) +-> -> Card11_Channel(11) +-> -> Card12_Channel(12) +-> -> Card13_Channel(13) +-> -> Card14_Channel(14) +-> -> Card15_Channel(15) +-> -> Card16_Channel(16) +-> -> Card17_Channel(17) +-> -> Card18_Channel(18) +-> -> Card19_Channel(19) +-> -> Card20_Channel(20) +-> -> Card21_Channel(21) +-> -> Card22_Channel(22) +-> -> Card23_Channel(23) +-> -> Card24_Channel(24) +-> -> Card25_Channel(25) +-> -> Card26_Channel(26) +-> -> Card27_Channel(27) +-> -> Card28_Channel(28) +-> -> Card29_Channel(29) +-> -> Card30_Channel(30) +-> -> Card31_Channel(31) + + +Register leaf node: Card31_Channel. +Instance: 256 +Length : 3 +Flag : 0 +Default : 铑 +Remark : Set lease circuit of MSC. Each 8K E1 Card has 256 configurable channels. +LCCP card (0-15)=Lease circuit connected 8K E1 Card (0-15). +LCCP E1 (0-7)=Lease circuit connected E1 (0-7). +LCCP timeslot=Lease circuit connected timeslot (1-15,17-31). +Default=0x05EEEE. + +Field : total(7) +Access : read-write [1]Channel flag + { + [u]0.0-0.0 + [u]select + [v]0[opt]disable + [v]1[opt]enable + } + [2]Channel type + { + [u]0.1-0.2 + [u]select + [v]0[opt]incoming + [v]1[opt]outgoing + [v]2[opt]bi-direction + [v]3[opt]lease + } +[4]LCCP card (0-15) + { + [u]1.0-1.3 + [u]input + [v]toDec high 0 + } +[6]LCCP timeslot (1-15, 17-31) + { + [u]2.0-2.4 + [u]input + [v]toDec high 0 + } +[7]LCCP E1 (0-7) + { + [u]2.5-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: CPC_attributes(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.6) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) +-> -> CPC(2) +-> -> E1_Port(3) +-> -> Channel_Attributes(4) +-> -> CPC_attributes(5) + + +Remark: CPC attributes. + + +Create node: MSCID(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.6.3) +-> father_name = [CPC_attributes] +-> -> MSCID(0) + + +Register leaf node: MSCID. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : MSCID + +Field : total(2) +Access : read-write[1]Market ID + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]Switch Number + { + [u]2.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Media_gateway(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.7) +-> father_name = [CCF_Config] +-> -> Call_Routing(0) +-> -> CCF_MSC(1) +-> -> CPC(2) +-> -> E1_Port(3) +-> -> Channel_Attributes(4) +-> -> CPC_attributes(5) +-> -> Media_gateway(6) + + +Remark: Media_gateway . + + +Create node: MG_Attribute(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.2.7.1) +-> father_name = [Media_gateway] +-> -> MG_Attribute(0) + + +Register leaf node: MG_Attribute. +Instance: 256 +Length : 53 +Flag : 255 +Default : +Remark : MG Attributes + +Field : total(3) +Access : read-only [1]MG Enable + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]MG IP Address + { + [u]1.0-4.7 + [u]input + [v]KeepHex high 0 + } +[3]MG Name + { + [u]5.0-52.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: CCF_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3) +-> father_name = [CCF(MSC)] +-> -> CCF_Config(0) +-> -> CCF_Status(1) + + +Remark: Status for CCF . + + +Create node: Version(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.1) +-> father_name = [CCF_Status] +-> -> Version(0) + + +Register leaf node: Version. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of MSC software (Read only).
+Byte0: System release version number, based on basic function and structure.
+Byte1: Software module version number, based on software module.
+Byte2: Test version, 0=Release version number, 1=Test version number.. + +Field : total(0) +Access : read-only + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.2) +-> father_name = [CCF_Status] +-> -> Version(0) +-> -> Command(1) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Control command for MSC-CPC. +Reset: Used for CPC status initialization. +Initialize: Restore the parameter setup to the default factory setting. +Save parameter: Save the parameters residing in CPC's memory into CPC's harddisk. + +Field : total(1) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]90[opt]Reset + [v]165[opt]Initialize + [v]181[opt]Save parameter + [v]238[opt]No command + } + + +Create node: E1_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.4) +-> father_name = [CCF_Status] +-> -> Version(0) +-> -> Command(1) +-> -> E1_Status(2) + + +Register leaf node: E1_Status. +Instance: 128 +Length : 1 +Flag : 255 +Default : +Remark : E1 status (read only). + +Field : total(2) +Access : read-only[1]Quantity of occupied timeslot + { + [u]0.0-0.4 + [u]input + [v]toDec high 0 + } + [2]E1 type + { + [u]0.5-0.7 + [u]select + [v]0[opt]TUP + [v]1[opt]ISUP + [v]2[opt]AIF + [v]3[opt]AIF_CDMA2K + [v]4[opt]BICC + } + + +Create node: Channel_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5) +-> father_name = [CCF_Status] +-> -> Version(0) +-> -> Command(1) +-> -> E1_Status(2) +-> -> Channel_Status(3) + + +Remark: Channel status (read only). + + +Create node: Card0_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.1) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) + + +Register leaf node: Card0_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card1_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.2) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) + + +Register leaf node: Card1_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card2_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.3) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) + + +Register leaf node: Card2_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card3_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.4) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) + + +Register leaf node: Card3_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card4_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.5) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) + + +Register leaf node: Card4_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card5_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.6) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) + + +Register leaf node: Card5_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card6_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.7) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) + + +Register leaf node: Card6_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card7_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.8) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) + + +Register leaf node: Card7_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card8_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.9) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) + + +Register leaf node: Card8_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card9_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.10) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) + + +Register leaf node: Card9_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card10_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.11) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) + + +Register leaf node: Card10_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card11_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.12) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) +-> -> Card11_Status(11) + + +Register leaf node: Card11_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card12_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.13) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) +-> -> Card11_Status(11) +-> -> Card12_Status(12) + + +Register leaf node: Card12_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card13_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.14) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) +-> -> Card11_Status(11) +-> -> Card12_Status(12) +-> -> Card13_Status(13) + + +Register leaf node: Card13_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card14_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.15) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) +-> -> Card11_Status(11) +-> -> Card12_Status(12) +-> -> Card13_Status(13) +-> -> Card14_Status(14) + + +Register leaf node: Card14_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: Card15_Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.5.16) +-> father_name = [Channel_Status] +-> -> Card0_Status(0) +-> -> Card1_Status(1) +-> -> Card2_Status(2) +-> -> Card3_Status(3) +-> -> Card4_Status(4) +-> -> Card5_Status(5) +-> -> Card6_Status(6) +-> -> Card7_Status(7) +-> -> Card8_Status(8) +-> -> Card9_Status(9) +-> -> Card10_Status(10) +-> -> Card11_Status(11) +-> -> Card12_Status(12) +-> -> Card13_Status(13) +-> -> Card14_Status(14) +-> -> Card15_Status(15) + + +Register leaf node: Card15_Status. +Instance: 256 +Length : 1 +Flag : 255 +Default : +Remark : Card Channel status (read only). + +Field : total(1) +Access : read-only [1]Timeslot status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Idle + [v]2[opt]Busy + [v]3[opt]Local blocked + [v]4[opt]Remote blocked + } + + +Create node: VLR(OID: 1.3.6.1.4.1.1373.1.3.3.2.5) +-> father_name = [MSC] +-> -> CCF(MSC)(0) +-> -> VLR(1) + + +Remark: sub for VLR . + + +Create node: VLR_Config(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2) +-> father_name = [VLR] +-> -> VLR_Config(0) + + +Remark: + Configuration for VLR . + + +Create node: Public_Param(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1) +-> father_name = [VLR_Config] +-> -> Public_Param(0) + + +Remark: Public parameters . + + +Create node: OptAuthReq(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.1) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) + + +Register leaf node: OptAuthReq. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Flag of SIM authentication on MS poweron and MO/MT call. + +Field : total(4) +Access : read-write [1]Update Location + { + [u]0.0-0.0 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } + [2]MO + { + [u]0.1-0.1 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } + [3]MT + { + [u]0.2-0.2 + [u]select + [v]0[opt]No authetication + [v]1[opt]Authetication + } +[4]Spare + { + [u]0.3-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: OptReuseTriplets(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.2) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) + + +Register leaf node: OptReuseTriplets. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Flag of reusing authentication triplets in VLR in the case that authentication to HLR is not available. Default=disable. + +Field : total(3) +Access : read-write [1]OptReuseTriplets + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]double authentication + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[3]Spare + { + [u]0.2-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: OptCipReq(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.3) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) + + +Register leaf node: OptCipReq. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Flag of voice ciphering over air interface by MS. Default=Disable. + +Field : total(1) +Access : read-write [1]OptCipReq + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: OptCiphAlgo(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.4) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) + + +Register leaf node: OptCiphAlgo. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : Voice ciphering algorithm selection. Default=no ciphering. + +Field : total(1) +Access : read-write [1]OptCiphAlgo + { + [u]0.0-0.7 + [u]select + [v]0[opt]None + [v]1[opt]A5_1 + [v]2[opt]A5_2 + [v]3[opt]A5_3 + [v]4[opt]A5_4 + [v]5[opt]A5_5 + [v]6[opt]A5_6 + [v]7[opt]A5_7 + } + + +Create node: OptTmsiAlloc(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.5) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) + + +Register leaf node: OptTmsiAlloc. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Flag of allocating a new TMSI every time a call management service is requested. Default=Disable. + +Field : total(1) +Access : read-write [1]TMSI Allocation Option + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Allocate TMSI + [v]2[opt]Reallocate TMSI + } + + +Create node: OptEcSetUpAllow(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.7) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) + + +Register leaf node: OptEcSetUpAllow. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Flag of making emergency call for non-registered MS or MS without SIM. Default=Enable. + +Field : total(1) +Access : read-write [1]OptEcSetUpAllow + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: OptCheckIMEI(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.8) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) +-> -> OptCheckIMEI(6) + + +Register leaf node: OptCheckIMEI. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Flag of IMEI verification via EIR. Default=no IMEI verification. + +Field : total(4) +Access : read-write [1]Update Location + { + [u]0.0-0.0 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } + [2]MO + { + [u]0.1-0.1 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } + [3]MT + { + [u]0.2-0.2 + [u]select + [v]0[opt]No IMEI verification + [v]1[opt]IMEI verification + } +[4]Spare + { + [u]0.3-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: OptVlrPurge(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.9) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) +-> -> OptCheckIMEI(6) +-> -> OptVlrPurge(7) + + +Register leaf node: OptVlrPurge. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Flag of VLR purge. Default=Off. + +Field : total(1) +Access : read-write [1]OptVlrPurge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + + +Create node: IdlePeriod2Purge(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.10) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) +-> -> OptCheckIMEI(6) +-> -> OptVlrPurge(7) +-> -> IdlePeriod2Purge(8) + + +Register leaf node: IdlePeriod2Purge. +Instance: 1 +Length : 1 +Flag : 255 +Default : < +Remark : Set the threshold of idle time to purge. If a mobile's idle time reaches this threshold, VLR will purge all records of this MS, unit=6 minute. Default=60minutes. + +Field : total(1) +Access : read-write[1]IdlePeriod2Purge + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: CDR_Flag(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.11) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) +-> -> OptCheckIMEI(6) +-> -> OptVlrPurge(7) +-> -> IdlePeriod2Purge(8) +-> -> CDR_Flag(9) + + +Register leaf node: CDR_Flag. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : VLR CDR flag. Default=On. + +Field : total(1) +Access : read-write [1]CDR on/off + { + [u]0.0-0.7 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + + +Create node: MSRN(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.2.1.13) +-> father_name = [Public_Param] +-> -> OptAuthReq(0) +-> -> OptReuseTriplets(1) +-> -> OptCipReq(2) +-> -> OptCiphAlgo(3) +-> -> OptTmsiAlloc(4) +-> -> OptEcSetUpAllow(5) +-> -> OptCheckIMEI(6) +-> -> OptVlrPurge(7) +-> -> IdlePeriod2Purge(8) +-> -> CDR_Flag(9) +-> -> MSRN(10) + + +Register leaf node: MSRN. +Instance: 1 +Length : 16 +Flag : 255 +Default : 唘S@ +Remark : Mobile station roaming number, use 16 bytes (32 digits) to define a range of MSRN. The length of start MSRN and end MSRN must be identical. F=end tag. + +Field : total(2) +Access : read-write[3]Start number + { + [u]0.0-7.7 + [u]input + [v]KeepHex Low F + } +[4]End number + { + [u]8.0-15.7 + [u]input + [v]KeepHex Low F + } + + +Create node: VLR_Management(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.3) +-> father_name = [VLR] +-> -> VLR_Config(0) +-> -> VLR_Management(1) + + +Remark: + Management for VLR . + + +Create node: Version(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.3.2) +-> father_name = [VLR_Management] +-> -> Version(0) + + +Register leaf node: Version. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of VLR software (Read only). +Byte0: System release version number, based on basic function and structure. +Byte1: Software module version number, based on software module. +Byte2: Test version, 0=Release version number, 1=Test version number. + +Field : total(0) +Access : read-only + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.3.3) +-> father_name = [VLR_Management] +-> -> Version(0) +-> -> Command(1) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Control command for VLR. +Reset: Used to initialize the status of VLR. +Save parameters: Save the parameters residing in memory into harddisk. + +Field : total(1) +Access : write-only [1]Management + { + [u]0.0-0.7 + [u]select + [v]0[opt]Reset VLR + [v]1[opt]Save parameters + } + + +Create node: Status(OID: 1.3.6.1.4.1.1373.1.3.3.2.5.3.4) +-> father_name = [VLR_Management] +-> -> Version(0) +-> -> Command(1) +-> -> Status(2) + + +Register leaf node: Status. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Basic status of VLR. + +Field : total(0) +Access : read-only + +Create node: HLR(OID: 1.3.6.1.4.1.1373.1.3.3.3) +-> father_name = [App] +-> -> MSC(0) +-> -> HLR(1) + + +Remark: Subsystems for HLR . + + +Create node: Config(OID: 1.3.6.1.4.1.1373.1.3.3.3.2) +-> father_name = [HLR] +-> -> Config(0) + + +Remark: + Configuration for HLR . + + +Create node: Public_Param(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1) +-> father_name = [Config] +-> -> Public_Param(0) + + +Remark: + Public parameter . + + +Create node: HPLMN(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.11) +-> father_name = [Public_Param] +-> -> HPLMN(0) + + +Register leaf node: HPLMN. +Instance: 1 +Length : 17 +Flag : 255 +Default : 铑铑铑铑铑铑铑铑 +Remark : Define the SN (VLR phone number) range of the VLR in the HPLMN (home PLMN) by specifying the start and end phone number of the range. +MSISDN=CC(country code)+NDC(National Destination Code)+SN. +All VLRs within a HPLMN have the same CC and NDC but the different SN. The SN of all VLR in a HPLMN must lie within the defined SN range. +Byte0-1=Country code. +Byte2-3=National destination code. +Byte4-9=Start SN of the VLR SN. +Byte10-15=End SN of the VLR SN. +e.g. For China country code=86, Shanghai national destination code=21, VLR SN=26060888: +Byte0-1=86EE, +Byte2-3=21EE, +SN=26060888, +Else=E. + +Field : total(4) +Access : read-write[1]CC + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } +[2]NDC + { + [u]2.0-4.7 + [u]input + [v]KeepHex Low E + } +[3]Start SN + { + [u]5.0-10.7 + [u]input + [v]KeepHex Low E + } +[4]End SN + { + [u]11.0-16.7 + [u]input + [v]KeepHex Low E + } + + +Create node: VPLMNs(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.12) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) + + +Register leaf node: VPLMNs. +Instance: 256 +Length : 17 +Flag : 255 +Default : 铑铑铑铑铑铑铑铑 +Remark : Define all connected VPLMNs (up tp 256) by specifying all VLR zones included in these VPLMNs. Each VLR zone is defined by its VLR MSISDN. MSISDN=CC+NDC+SN. All VLRs within a same VPLMN have the CC and NDC but the different SN. A VPLMN contains a group of VLRs whose SN is included in the defined SN range, E=random digit. +This parameter also define two ranges of VLR CSRR (Country specific roaming restrictionszones) zones for each VPLMN. In these defined VLR CSRR zones all HPLMN subscribers may be subjected to country specific roaming restrictions. +For each VPLMN setup, the format is: +byte0=ISDN numbering plan, default=91. +byte1-2=country code, EEEE. +byte3-4=national destination code, EEEE. +byte5-10=start SN (SN prefix or whole SN) of VPLMNs, EEEEEEEEEEEE. +byte11-16=end SN (SN prefix or whole SN) of VPLMNs, EEEEEEEEEEEE. +byte17-22=start SN (SN prefix or whole SN) of range 0 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. +byte23-28=end SN (SN prefix or whole SN) of range 0 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. +byte29-34=start SN (SN prefix or whole SN) of range 1 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. +byte35-40=end SN (SN prefix or whole SN) of range 1 of VLR CSRR zones of a VPLMN, EEEEEEEEEEEE. +E=random digit. + +Field : total(4) +Access : read-write[1]CC + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } +[2]NDC + { + [u]2.0-4.7 + [u]input + [v]KeepHex Low E + } +[3]Start SN + { + [u]5.0-10.7 + [u]input + [v]KeepHex Low E + } +[4]End SN + { + [u]11.0-16.7 + [u]input + [v]KeepHex Low E + } + + +Create node: CSRR_List(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.13) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) +-> -> CSRR_List(2) + + +Register leaf node: CSRR_List. +Instance: 8 +Length : 32 +Flag : 255 +Default : +Remark : Define 8 CSRR (country specific roaming restriction) lists to confine the roaming range of a subscriber. +Each CSRR list defines the roaming restriction for 256 VPLMN ranges. + +Field : total(256) +Access : read-write [1]VPLMN0 Roaming allowed + { + [u]31.0-31.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [2]VPLMN1 Roaming allowed + { + [u]31.1-31.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [3]VPLMN2 Roaming allowed + { + [u]31.2-31.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [4]VPLMN3 Roaming allowed + { + [u]31.3-31.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [5]VPLMN4 Roaming allowed + { + [u]31.4-31.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [6]VPLMN5 Roaming allowed + { + [u]31.5-31.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [7]VPLMN6 Roaming allowed + { + [u]31.6-31.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [8]VPLMN7 Roaming allowed + { + [u]31.7-31.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [9]VPLMN8 Roaming allowed + { + [u]30.0-30.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [10]VPLMN9 Roaming allowed + { + [u]30.1-30.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [11]VPLMN10 Roaming allowed + { + [u]30.2-30.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [12]VPLMN11 Roaming allowed + { + [u]30.3-30.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [13]VPLMN12 Roaming allowed + { + [u]30.4-30.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [14]VPLMN13 Roaming allowed + { + [u]30.5-30.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [15]VPLMN14 Roaming allowed + { + [u]30.6-30.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [16]VPLMN15 Roaming allowed + { + [u]30.7-30.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [17]VPLMN16 Roaming allowed + { + [u]29.0-29.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [18]VPLMN17 Roaming allowed + { + [u]29.1-29.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [19]VPLMN18 Roaming allowed + { + [u]29.2-29.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [20]VPLMN19 Roaming allowed + { + [u]29.3-29.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [21]VPLMN20 Roaming allowed + { + [u]29.4-29.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [22]VPLMN21 Roaming allowed + { + [u]29.5-29.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [23]VPLMN22 Roaming allowed + { + [u]29.6-29.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [24]VPLMN23 Roaming allowed + { + [u]29.7-29.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [25]VPLMN24 Roaming allowed + { + [u]28.0-28.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [26]VPLMN25 Roaming allowed + { + [u]28.1-28.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [27]VPLMN26 Roaming allowed + { + [u]28.2-28.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [28]VPLMN27 Roaming allowed + { + [u]28.3-28.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [29]VPLMN28 Roaming allowed + { + [u]28.4-28.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [30]VPLMN29 Roaming allowed + { + [u]28.5-28.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [31]VPLMN30 Roaming allowed + { + [u]28.6-28.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [32]VPLMN31 Roaming allowed + { + [u]28.7-28.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [33]VPLMN32 Roaming allowed + { + [u]27.0-27.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [34]VPLMN33 Roaming allowed + { + [u]27.1-27.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [35]VPLMN34 Roaming allowed + { + [u]27.2-27.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [36]VPLMN35 Roaming allowed + { + [u]27.3-27.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [37]VPLMN36 Roaming allowed + { + [u]27.4-27.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [38]VPLMN37 Roaming allowed + { + [u]27.5-27.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [39]VPLMN38 Roaming allowed + { + [u]27.6-27.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [40]VPLMN39 Roaming allowed + { + [u]27.7-27.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [41]VPLMN40 Roaming allowed + { + [u]26.0-26.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [42]VPLMN41 Roaming allowed + { + [u]26.1-26.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [43]VPLMN42 Roaming allowed + { + [u]26.2-26.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [44]VPLMN43 Roaming allowed + { + [u]26.3-26.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [45]VPLMN44 Roaming allowed + { + [u]26.4-26.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [46]VPLMN45 Roaming allowed + { + [u]26.5-26.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [47]VPLMN46 Roaming allowed + { + [u]26.6-26.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [48]VPLMN47 Roaming allowed + { + [u]26.7-26.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [49]VPLMN48 Roaming allowed + { + [u]25.0-25.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [50]VPLMN49 Roaming allowed + { + [u]25.1-25.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [51]VPLMN50 Roaming allowed + { + [u]25.2-25.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [52]VPLMN51 Roaming allowed + { + [u]25.3-25.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [53]VPLMN52 Roaming allowed + { + [u]25.4-25.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [54]VPLMN53 Roaming allowed + { + [u]25.5-25.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [55]VPLMN54 Roaming allowed + { + [u]25.6-25.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [56]VPLMN55 Roaming allowed + { + [u]25.7-25.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [57]VPLMN56 Roaming allowed + { + [u]24.0-24.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [58]VPLMN57 Roaming allowed + { + [u]24.1-24.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [59]VPLMN58 Roaming allowed + { + [u]24.2-24.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [60]VPLMN59 Roaming allowed + { + [u]24.3-24.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [61]VPLMN60 Roaming allowed + { + [u]24.4-24.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [62]VPLMN61 Roaming allowed + { + [u]24.5-24.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [63]VPLMN62 Roaming allowed + { + [u]24.6-24.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [64]VPLMN63 Roaming allowed + { + [u]24.7-24.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [65]VPLMN64 Roaming allowed + { + [u]23.0-23.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [66]VPLMN65 Roaming allowed + { + [u]23.1-23.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [67]VPLMN66 Roaming allowed + { + [u]23.2-23.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [68]VPLMN67 Roaming allowed + { + [u]23.3-23.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [69]VPLMN68 Roaming allowed + { + [u]23.4-23.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [70]VPLMN69 Roaming allowed + { + [u]23.5-23.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [71]VPLMN70 Roaming allowed + { + [u]23.6-23.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [72]VPLMN71 Roaming allowed + { + [u]23.7-23.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [73]VPLMN72 Roaming allowed + { + [u]22.0-22.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [74]VPLMN73 Roaming allowed + { + [u]22.1-22.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [75]VPLMN74 Roaming allowed + { + [u]22.2-22.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [76]VPLMN75 Roaming allowed + { + [u]22.3-22.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [77]VPLMN76 Roaming allowed + { + [u]22.4-22.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [78]VPLMN77 Roaming allowed + { + [u]22.5-22.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [79]VPLMN78 Roaming allowed + { + [u]22.6-22.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [80]VPLMN79 Roaming allowed + { + [u]22.7-22.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [81]VPLMN80 Roaming allowed + { + [u]21.0-21.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [82]VPLMN81 Roaming allowed + { + [u]21.1-21.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [83]VPLMN82 Roaming allowed + { + [u]21.2-21.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [84]VPLMN83 Roaming allowed + { + [u]21.3-21.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [85]VPLMN84 Roaming allowed + { + [u]21.4-21.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [86]VPLMN85 Roaming allowed + { + [u]21.5-21.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [87]VPLMN86 Roaming allowed + { + [u]21.6-21.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [88]VPLMN87 Roaming allowed + { + [u]21.7-21.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [89]VPLMN88 Roaming allowed + { + [u]20.0-20.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [90]VPLMN89 Roaming allowed + { + [u]20.1-20.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [91]VPLMN90 Roaming allowed + { + [u]20.2-20.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [92]VPLMN91 Roaming allowed + { + [u]20.3-20.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [93]VPLMN92 Roaming allowed + { + [u]20.4-20.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [94]VPLMN93 Roaming allowed + { + [u]20.5-20.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [95]VPLMN94 Roaming allowed + { + [u]20.6-20.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [96]VPLMN95 Roaming allowed + { + [u]20.7-20.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [97]VPLMN96 Roaming allowed + { + [u]19.0-19.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [98]VPLMN97 Roaming allowed + { + [u]19.1-19.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [99]VPLMN98 Roaming allowed + { + [u]19.2-19.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [100]VPLMN99 Roaming allowed + { + [u]19.3-19.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [101]VPLMN100 Roaming allowed + { + [u]19.4-19.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [102]VPLMN101 Roaming allowed + { + [u]19.5-19.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [103]VPLMN102 Roaming allowed + { + [u]19.6-19.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [104]VPLMN103 Roaming allowed + { + [u]19.7-19.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [105]VPLMN104 Roaming allowed + { + [u]18.0-18.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [106]VPLMN105 Roaming allowed + { + [u]18.1-18.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [107]VPLMN106 Roaming allowed + { + [u]18.2-18.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [108]VPLMN107 Roaming allowed + { + [u]18.3-18.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [109]VPLMN108 Roaming allowed + { + [u]18.4-18.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [110]VPLMN109 Roaming allowed + { + [u]18.5-18.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [111]VPLMN110 Roaming allowed + { + [u]18.6-18.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [112]VPLMN111 Roaming allowed + { + [u]18.7-18.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [113]VPLMN112 Roaming allowed + { + [u]17.0-17.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [114]VPLMN113 Roaming allowed + { + [u]17.1-17.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [115]VPLMN114 Roaming allowed + { + [u]17.2-17.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [116]VPLMN115 Roaming allowed + { + [u]17.3-17.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [117]VPLMN116 Roaming allowed + { + [u]17.4-17.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [118]VPLMN117 Roaming allowed + { + [u]17.5-17.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [119]VPLMN118 Roaming allowed + { + [u]17.6-17.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [120]VPLMN119 Roaming allowed + { + [u]17.7-17.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [121]VPLMN120 Roaming allowed + { + [u]16.0-16.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [122]VPLMN121 Roaming allowed + { + [u]16.1-16.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [123]VPLMN122 Roaming allowed + { + [u]16.2-16.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [124]VPLMN123 Roaming allowed + { + [u]16.3-16.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [125]VPLMN124 Roaming allowed + { + [u]16.4-16.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [126]VPLMN125 Roaming allowed + { + [u]16.5-16.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [127]VPLMN126 Roaming allowed + { + [u]16.6-16.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [128]VPLMN127 Roaming allowed + { + [u]16.7-16.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [129]VPLMN128 Roaming allowed + { + [u]15.0-15.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [130]VPLMN129 Roaming allowed + { + [u]15.1-15.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [131]VPLMN130 Roaming allowed + { + [u]15.2-15.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [132]VPLMN131 Roaming allowed + { + [u]15.3-15.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [133]VPLMN132 Roaming allowed + { + [u]15.4-15.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [134]VPLMN133 Roaming allowed + { + [u]15.5-15.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [135]VPLMN134 Roaming allowed + { + [u]15.6-15.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [136]VPLMN135 Roaming allowed + { + [u]15.7-15.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [137]VPLMN136 Roaming allowed + { + [u]14.0-14.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [138]VPLMN137 Roaming allowed + { + [u]14.1-14.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [139]VPLMN138 Roaming allowed + { + [u]14.2-14.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [140]VPLMN139 Roaming allowed + { + [u]14.3-14.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [141]VPLMN140 Roaming allowed + { + [u]14.4-14.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [142]VPLMN141 Roaming allowed + { + [u]14.5-14.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [143]VPLMN142 Roaming allowed + { + [u]14.6-14.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [144]VPLMN143 Roaming allowed + { + [u]14.7-14.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [145]VPLMN144 Roaming allowed + { + [u]13.0-13.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [146]VPLMN145 Roaming allowed + { + [u]13.1-13.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [147]VPLMN146 Roaming allowed + { + [u]13.2-13.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [148]VPLMN147 Roaming allowed + { + [u]13.3-13.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [149]VPLMN148 Roaming allowed + { + [u]13.4-13.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [150]VPLMN149 Roaming allowed + { + [u]13.5-13.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [151]VPLMN150 Roaming allowed + { + [u]13.6-13.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [152]VPLMN151 Roaming allowed + { + [u]13.7-13.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [153]VPLMN152 Roaming allowed + { + [u]12.0-12.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [154]VPLMN153 Roaming allowed + { + [u]12.1-12.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [155]VPLMN154 Roaming allowed + { + [u]12.2-12.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [156]VPLMN155 Roaming allowed + { + [u]12.3-12.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [157]VPLMN156 Roaming allowed + { + [u]12.4-12.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [158]VPLMN157 Roaming allowed + { + [u]12.5-12.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [159]VPLMN158 Roaming allowed + { + [u]12.6-12.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [160]VPLMN159 Roaming allowed + { + [u]12.7-12.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [161]VPLMN160 Roaming allowed + { + [u]11.0-11.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [162]VPLMN161 Roaming allowed + { + [u]11.1-11.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [163]VPLMN162 Roaming allowed + { + [u]11.2-11.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [164]VPLMN163 Roaming allowed + { + [u]11.3-11.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [165]VPLMN164 Roaming allowed + { + [u]11.4-11.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [166]VPLMN165 Roaming allowed + { + [u]11.5-11.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [167]VPLMN166 Roaming allowed + { + [u]11.6-11.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [168]VPLMN167 Roaming allowed + { + [u]11.7-11.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [169]VPLMN168 Roaming allowed + { + [u]10.0-10.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [170]VPLMN169 Roaming allowed + { + [u]10.1-10.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [171]VPLMN170 Roaming allowed + { + [u]10.2-10.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [172]VPLMN171 Roaming allowed + { + [u]10.3-10.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [173]VPLMN172 Roaming allowed + { + [u]10.4-10.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [174]VPLMN173 Roaming allowed + { + [u]10.5-10.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [175]VPLMN174 Roaming allowed + { + [u]10.6-10.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [176]VPLMN175 Roaming allowed + { + [u]10.7-10.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [177]VPLMN176 Roaming allowed + { + [u]9.0-9.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [178]VPLMN177 Roaming allowed + { + [u]9.1-9.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [179]VPLMN178 Roaming allowed + { + [u]9.2-9.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [180]VPLMN179 Roaming allowed + { + [u]9.3-9.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [181]VPLMN180 Roaming allowed + { + [u]9.4-9.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [182]VPLMN181 Roaming allowed + { + [u]9.5-9.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [183]VPLMN182 Roaming allowed + { + [u]9.6-9.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [184]VPLMN183 Roaming allowed + { + [u]9.7-9.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [185]VPLMN184 Roaming allowed] + { + [u]8.0-8.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [186]VPLMN185 Roaming allowed + { + [u]8.1-8.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [187]VPLMN186 Roaming allowed + { + [u]8.2-8.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [188]VPLMN187 Roaming allowed + { + [u]8.3-8.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [189]VPLMN188 Roaming allowed + { + [u]8.4-8.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [190]VPLMN189 Roaming allowed + { + [u]8.5-8.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [191]VPLMN190 Roaming allowed + { + [u]8.6-8.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [192]VPLMN191 Roaming allowed + { + [u]8.7-8.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [193]VPLMN192 Roaming allowed + { + [u]7.0-7.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [194]VPLMN193 Roaming allowed + { + [u]7.1-7.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [195]VPLMN194 Roaming allowed + { + [u]7.2-7.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [196]VPLMN195 Roaming allowed + { + [u]7.3-7.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [197]VPLMN196 Roaming allowed + { + [u]7.4-7.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [198]VPLMN197 Roaming allowed + { + [u]7.5-7.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [199]VPLMN198 Roaming allowed + { + [u]7.6-7.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [200]VPLMN199 Roaming allowed + { + [u]7.7-7.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [201]VPLMN200 Roaming allowed + { + [u]6.0-6.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [202]VPLMN201 Roaming allowed + { + [u]6.1-6.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [203]VPLMN202 Roaming allowed + { + [u]6.2-6.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [204]VPLMN203 Roaming allowed + { + [u]6.3-6.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [205]VPLMN204 Roaming allowed + { + [u]6.4-6.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [206]VPLMN205 Roaming allowed + { + [u]6.5-6.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [207]VPLMN206 Roaming allowed + { + [u]6.6-6.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [208]VPLMN207 Roaming allowed + { + [u]6.7-6.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [209]VPLMN208 Roaming allowed + { + [u]5.0-5.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [210]VPLMN209 Roaming allowed + { + [u]5.1-5.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [211]VPLMN210 Roaming allowed + { + [u]5.2-5.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [212]VPLMN211 Roaming allowed + { + [u]5.3-5.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [213]VPLMN212 Roaming allowed + { + [u]5.4-5.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [214]VPLMN213 Roaming allowed + { + [u]5.5-5.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [215]VPLMN214 Roaming allowed + { + [u]5.6-5.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [216]VPLMN215 Roaming allowed + { + [u]5.7-5.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [217]VPLMN216 Roaming allowed + { + [u]4.0-4.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [218]VPLMN217 Roaming allowed + { + [u]4.1-4.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [219]VPLMN218 Roaming allowed + { + [u]4.2-4.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [220]VPLMN219 Roaming allowed + { + [u]4.3-4.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [221]VPLMN220 Roaming allowed + { + [u]4.4-4.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [222]VPLMN221 Roaming allowed + { + [u]4.5-4.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [223]VPLMN222 Roaming allowed + { + [u]4.6-4.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [224]VPLMN223 Roaming allowed + { + [u]4.7-4.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [225]VPLMN224 Roaming allowed + { + [u]3.0-3.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [226]VPLMN225 Roaming allowed + { + [u]3.1-3.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [227]VPLMN226 Roaming allowed + { + [u]3.2-3.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [228]VPLMN227 Roaming allowed + { + [u]3.3-3.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [229]VPLMN228 Roaming allowed + { + [u]3.4-3.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [230]VPLMN229 Roaming allowed + { + [u]3.5-3.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [231]VPLMN230 Roaming allowed + { + [u]3.6-3.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [232]VPLMN231 Roaming allowed + { + [u]3.7-3.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [233]VPLMN232 Roaming allowed + { + [u]2.0-2.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [234]VPLMN233 Roaming allowed + { + [u]2.1-2.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [235]VPLMN234 Roaming allowed + { + [u]2.2-2.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [236]VPLMN235 Roaming allowed + { + [u]2.3-2.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [237]VPLMN236 Roaming allowed + { + [u]2.4-2.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [238]VPLMN237 Roaming allowed + { + [u]2.5-2.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [239]VPLMN238 Roaming allowed + { + [u]2.6-2.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [240]VPLMN239 Roaming allowed + { + [u]2.7-2.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [241]VPLMN240 Roaming allowed + { + [u]1.0-1.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [242]VPLMN241 Roaming allowed + { + [u]1.1-1.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [243]VPLMN242 Roaming allowed + { + [u]1.2-1.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [244]VPLMN243 Roaming allowed + { + [u]1.3-1.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [245]VPLMN244 Roaming allowed + { + [u]1.4-1.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [246]VPLMN245 Roaming allowed + { + [u]1.5-1.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [247]VPLMN246 Roaming allowed + { + [u]1.6-1.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [248]VPLMN247 Roaming allowed + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [249]VPLMN248 Roaming allowed + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [250]VPLMN249 Roaming allowed + { + [u]0.1-0.1 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [251]VPLMN250 Roaming allowed + { + [u]0.2-0.2 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [252]VPLMN251 Roaming allowed + { + [u]0.3-0.3 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [253]VPLMN252 Roaming allowed + { + [u]0.4-0.4 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [254]VPLMN253 Roaming allowed + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [255]VPLMN254 Roaming allowed + { + [u]0.6-0.6 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + [256]VPLMN255 Roaming allowed + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Regional_Subs_List(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.14) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) +-> -> CSRR_List(2) +-> -> Regional_Subs_List(3) + + +Register leaf node: Regional_Subs_List. +Instance: 255 +Length : 7 +Flag : 255 +Default : 铑铑铑 +Remark : Define the regional subscription zone code list. HLR supports up to 256 regional subscription zone code. +Regional subscription code = CC+NDC+zone code + +Field : total(3) +Access : read-write[1]Country Code + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } +[2]National Destination Code + { + [u]2.0-4.7 + [u]input + [v]KeepHex Low E + } +[3]Zone Code + { + [u]5.0-6.7 + [u]input + [v]toDec high 0 + } + + +Create node: Licenses_Control(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.15) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) +-> -> CSRR_List(2) +-> -> Regional_Subs_List(3) +-> -> Licenses_Control(4) + + +Register leaf node: Licenses_Control. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of HLR subscribers for service provider: +The new license can not support less HLR subscribers than what the old license supports. + +Field : total(1) +Access : write-only[1]Licenses + { + [u]0.0-7.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: CDR_Control(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.16) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) +-> -> CSRR_List(2) +-> -> Regional_Subs_List(3) +-> -> Licenses_Control(4) +-> -> CDR_Control(5) + + +Register leaf node: CDR_Control. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : HLR CDR generation flag: +Off=Not generate HLR CDR. +On=Generate HLR CDR. + +Field : total(1) +Access : read-write [1]CDR control + { + [u]0.0-0.7 + [u]select + [v]0[opt]Off + [v]1[opt]On + } + + +Create node: Feature_Code(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.1.27) +-> father_name = [Public_Param] +-> -> HPLMN(0) +-> -> VPLMNs(1) +-> -> CSRR_List(2) +-> -> Regional_Subs_List(3) +-> -> Licenses_Control(4) +-> -> CDR_Control(5) +-> -> Feature_Code(6) + + +Register leaf node: Feature_Code. +Instance: 1 +Length : 64 +Flag : 255 +Default : 愵h顁顠頿 +Remark : None. + +Field : total(6) +Access : read-write[1]CFB + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low E + } +[2]CFD + { + [u]2.0-3.7 + [u]input + [v]KeepHex Low E + } +[3]CFNA + { + [u]4.0-5.7 + [u]input + [v]KeepHex Low E + } +[4]CFU + { + [u]6.0-7.7 + [u]input + [v]KeepHex Low E + } +[5]Call waiting + { + [u]8.0-9.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Management(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2) +-> father_name = [Config] +-> -> Public_Param(0) +-> -> Management(1) + + +Remark: + Management . + + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.2) +-> father_name = [Management] +-> -> Command(0) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Bit0-2: HLR paramter save control: +Idle=no operation. +Save=Save parameters from HLR memory to HLR hard disk. +Bit3-5: HLR subscriber data save control: +Idle=no operation. +Save=Save HLR subscriber data from HLR memory to both HLR hard disk and OMC database. +Bit6-7: Reserved. + +Field : total(3) +Access : read-write [1]Save parameter to HD + { + [u]0.0-0.2 + [u]select + [v]0[opt]Idle + [v]1[opt]Save + } + [2]Save subscriber data to HD&OMC + { + [u]0.3-0.5 + [u]select + [v]0[opt]Idle + [v]1[opt]Save + } + + +Create node: Subscriber_Import(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.3) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) + + +Register leaf node: Subscriber_Import. +Instance: 1 +Length : 7 +Flag : 255 +Default : +Remark : Progress and result of HLR subscriber import. +Byte0: Progress of HLR subscriber import. +Byte1-3: Total quantity of HLR subscribers requesting import. +Byte4-7: Quantity of successfully imported HLR subscribers. + +Field : total(3) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]0[opt]No operation + [v]1[opt]Send command + [v]2[opt]Begin loading + [v]3[opt]Loading OK + [v]4[opt]Loading Failed + } +[2]Total subscriber requested + { + [u]1.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Total imported subscribers + { + [u]4.0-6.7 + [u]input + [v]toDec high 0 + } + + +Create node: Max_Licenses(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.11) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) + + +Register leaf node: Max_Licenses. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The maximum quantity of approved HLR subscribers determined by License control (Read Only). + +Field : total(1) +Access : read-only[1]Max Licenses + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Used_Licenses(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.12) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) + + +Register leaf node: Used_Licenses. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of currently registered HLR subscribers (Read Only). + +Field : total(1) +Access : read-only[1]Used Licenses + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Subscriber_Info(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.13) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) +-> -> Subscriber_Info(4) + + +Remark: + Subscriber information . + + +Create node: Provisioned_Subs(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.13.1) +-> father_name = [Subscriber_Info] +-> -> Provisioned_Subs(0) + + +Register leaf node: Provisioned_Subs. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of service provisioned and active HLR subscribers (Read Only). + +Field : total(1) +Access : read-only[1]Provisioned Subs + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Registered_Subs(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.13.2) +-> father_name = [Subscriber_Info] +-> -> Provisioned_Subs(0) +-> -> Registered_Subs(1) + + +Register leaf node: Registered_Subs. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of registered (both active and inactive) HLR subscribers (Read Only). + +Field : total(1) +Access : read-only[1]Registered Subs + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Roaming_Subs(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.13.3) +-> father_name = [Subscriber_Info] +-> -> Provisioned_Subs(0) +-> -> Registered_Subs(1) +-> -> Roaming_Subs(2) + + +Register leaf node: Roaming_Subs. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of provisioned HLR subscribers currently roaming to VPLMNs (Read Only). + +Field : total(1) +Access : read-only[1]Roaming Subs + { + [u]0.0-0.0 + [u]input + [v]toDec high 0 + } + + +Create node: Version(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.14) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) +-> -> Subscriber_Info(4) +-> -> Version(5) + + +Remark: + Version . + + +Create node: Software(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.14.1) +-> father_name = [Version] +-> -> Software(0) + + +Register leaf node: Software. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of HLR software (Read Only): +Byte0: System release version number: +- Based on basic function and structure. +Byte1: Software module version number: +- Based on software module. +Byte2: Test version: +- 0=Release version number. +- 1=Test version number. + +Field : total(3) +Access : read-only[1]Release + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Version + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Slice + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: User_Data(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.14.2) +-> father_name = [Version] +-> -> Software(0) +-> -> User_Data(1) + + +Register leaf node: User_Data. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of AUC subscriber data (Read Only): +System release version: Based on basic function and structure. +Subscriber data version: Based on software module. +Test version: 0=Release version 1=Test version + +Field : total(3) +Access : read-only[1]Release + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Version + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Slice + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: IMSI_Segment(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.15) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) +-> -> Subscriber_Info(4) +-> -> Version(5) +-> -> IMSI_Segment(6) + + +Register leaf node: IMSI_Segment. +Instance: 1000 +Length : 4 +Flag : 255 +Default : +Remark : MSISDN segment table (Read Only): +Use SN of MSISDN (MSISDN=CC+NDC+SN) excluding the last three digits to divide the MSISDN into 200 segments. + +Field : total(1) +Access : read-only[1]IMSI segment + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: MSISDN_Segment(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.16) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) +-> -> Subscriber_Info(4) +-> -> Version(5) +-> -> IMSI_Segment(6) +-> -> MSISDN_Segment(7) + + +Register leaf node: MSISDN_Segment. +Instance: 1000 +Length : 4 +Flag : 255 +Default : +Remark : MSISDN segment table (Read Only): +Use SN of MSISDN (MSISDN=CC+NDC+SN) excluding the last three digits to divide the MSISDN into 200 segments. + +Field : total(1) +Access : read-only[1]MSISDN segment + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: CNF_Applicant_Info(OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.27) +-> father_name = [Management] +-> -> Command(0) +-> -> Subscriber_Import(1) +-> -> Max_Licenses(2) +-> -> Used_Licenses(3) +-> -> Subscriber_Info(4) +-> -> Version(5) +-> -> IMSI_Segment(6) +-> -> MSISDN_Segment(7) +-> -> CNF_Applicant_Info(8) + + +Register leaf node: CNF_Applicant_Info. +Instance: 1 +Length : 9 +Flag : 255 +Default : +Remark : Display the IMSI and charge type of the latest conference applicant (Read Only). + +Field : total(2) +Access : read-only [1]Charge Type + { + [u]0.0-0.7 + [u]select + [v]0[opt]Invalid user + [v]1[opt]Post-pay user + [v]2[opt]Prepaid user + } +[2]IMSI + { + [u]1.0-8.7 + [u]input + [v]KeepHex Low E + } + + +Create node: AUC(OID: 1.3.6.1.4.1.1373.1.3.3.4) +-> father_name = [App] +-> -> MSC(0) +-> -> HLR(1) +-> -> AUC(2) + + +Remark: Subsystems for AUC . + + +Create node: Configuration(OID: 1.3.6.1.4.1.1373.1.3.3.4.2) +-> father_name = [AUC] +-> -> Configuration(0) + + +Remark: + Configuration for AUC . + + +Create node: Public_parameter(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.1) +-> father_name = [Configuration] +-> -> Public_parameter(0) + + +Remark: + Public_parameter for AUC . + + +Create node: SSD(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.1.2) +-> father_name = [Public_parameter] +-> -> SSD(0) + + +Register leaf node: SSD. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : SSD + +Field : total(3) +Access : read-write [1]share SSD + { + [u]0.0-0.7 + [u]select + [v]0[opt]not share + [v]1[opt]share + } +[2]Update SSD timer + { + [u]1.0-2.7 + [u]input + [v]toDec high 0 + } + + +Create node: Count(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.1.3) +-> father_name = [Public_parameter] +-> -> SSD(0) +-> -> Count(1) + + +Register leaf node: Count. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : Count. + +Field : total(2) +Access : read-write[1]Count Match Range + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Failures(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.1.4) +-> father_name = [Public_parameter] +-> -> SSD(0) +-> -> Count(1) +-> -> Failures(2) + + +Register leaf node: Failures. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : Count. + +Field : total(7) +Access : read-write [1]AUTHR Mismatch + { + [u]0.0-0.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + [v]2[opt]Unique Challenge + } + [2]Count Mismatch + { + [u]1.0-1.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + [3]Unique Challenge Failure + { + [u]2.0-2.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + [4]SSD Update Failure + { + [u]3.0-3.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + [5]Count Update Failure + { + [u]4.0-4.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + } + [6]Missing AUTH Parameters + { + [u]5.0-5.7 + [u]select + [v]0[opt]Allow Access + [v]1[opt]Deny Access + [v]2[opt]Unique Challenge + } + + +Create node: Management(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2) +-> father_name = [Configuration] +-> -> Public_parameter(0) +-> -> Management(1) + + +Remark: + Management . + + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.2) +-> father_name = [Management] +-> -> Command(0) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Command for AUC paramters and user data operation, and the result of command. + +Field : total(3) +Access : read-write [1]Save parameters to HD + { + [u]0.0-0.2 + [u]select + [v]0[opt]Idle + [v]1[opt]Save + [v]1[opt]Saving + [v]2[opt]Save succeeds + [v]3[opt]Save fails + } + [2]Save user data to HD&OMC + { + [u]0.3-0.5 + [u]select + [v]0[opt]Idle + [v]1[opt]Save + [v]1[opt]Saving + [v]2[opt]Save succeeds + [v]3[opt]Save fails + } + + +Create node: License_Control(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.3) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) + + +Register leaf node: License_Control. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of AUC subscribers for service provider. The new license can not support less AUC subscribers than what the old license supports. + +Field : total(1) +Access : write-only[1]Licenses + { + [u]0.0-15.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: MAX_License(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.11) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) +-> -> MAX_License(2) + + +Register leaf node: MAX_License. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The maximum quantity of approved AUC subscribers determined by License control Read only. + +Field : total(1) +Access : write-only[1]Max Licenses + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Used_License(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.12) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) +-> -> MAX_License(2) +-> -> Used_License(3) + + +Register leaf node: Used_License. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of currently registered EIR subscribers (Read only). + +Field : total(1) +Access : read-only[1]Used Licenses + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: User_information(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.13) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) +-> -> MAX_License(2) +-> -> Used_License(3) +-> -> User_information(4) + + +Remark: + User Information . + + +Create node: Provisioned_Users(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.13.1) +-> father_name = [User_information] +-> -> Provisioned_Users(0) + + +Register leaf node: Provisioned_Users. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : The quantity of service enabled AUC subscribers (Read only). + +Field : total(1) +Access : read-only[1]Provisioned users + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Version(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.14) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) +-> -> MAX_License(2) +-> -> Used_License(3) +-> -> User_information(4) +-> -> Version(5) + + +Remark: + Version . + + +Create node: Software(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.14.1) +-> father_name = [Version] +-> -> Software(0) + + +Register leaf node: Software. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of AUC software (Read only). +System: System release version, based on basic function and structure. +Module: Software module version, based on software module. +Test: Test version, 0=Release version. 1=Test version. + +Field : total(3) +Access : read-only[1]System + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Module + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Test + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: User_data(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.14.2) +-> father_name = [Version] +-> -> Software(0) +-> -> User_data(1) + + +Register leaf node: User_data. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Version of AUC subscriber data (Read only). +System: System release version, based on basic function and structure. +User data: Subscriber profile version, based on software module. +Test: Test version, 0=Release version. 1=Test version. + +Field : total(3) +Access : read-only[1]System + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]User data + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Test + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: IMSI_Segment(OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.15) +-> father_name = [Management] +-> -> Command(0) +-> -> License_Control(1) +-> -> MAX_License(2) +-> -> Used_License(3) +-> -> User_information(4) +-> -> Version(5) +-> -> IMSI_Segment(6) + + +Register leaf node: IMSI_Segment. +Instance: 1000 +Length : 4 +Flag : 255 +Default : +Remark : IMSI segment table (Read only): +100,000 IMSIs are subdivided into 1000 segments, each IMSI segment use the 8 most significant digits (from the 6th digit to 13th digit of 15-digit of IMSI) as the segment number. +IMSI=MCC(3)+MNC(2)+MSIN(10) +Segment number=the 8 most significant digits of the MSIN, each segment has 100 subscribers (00-99). +e.g. If IMSI=460002356090098 then it belongs to IMSI segemt 23560900 and its account number in that segment=98. 0=empty segment. + +Field : total(1) +Access : read-only[1]IMSI segment + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Status(OID: 1.3.6.1.4.1.1373.1.3.3.4.3) +-> father_name = [AUC] +-> -> Configuration(0) +-> -> Status(1) + + +Remark: + Status for AUC . + + +Create node: Import_status(OID: 1.3.6.1.4.1.1373.1.3.3.4.3.2) +-> father_name = [Status] +-> -> Import_status(0) + + +Register leaf node: Import_status. +Instance: 1 +Length : 12 +Flag : 255 +Default : +Remark : Import status. + +Field : total(0) +Access : read-write + +Create node: SMSC(OID: 1.3.6.1.4.1.1373.1.3.3.5) +-> father_name = [App] +-> -> MSC(0) +-> -> HLR(1) +-> -> AUC(2) +-> -> SMSC(3) + + +Remark: Subsystems for SMSC . + + +Create node: Configuration(OID: 1.3.6.1.4.1.1373.1.3.3.5.2) +-> father_name = [SMSC] +-> -> Configuration(0) + + +Remark: Configuration for SMSC . + + +Create node: System_Param(OID: 1.3.6.1.4.1.1373.1.3.3.5.2.1) +-> father_name = [Configuration] +-> -> System_Param(0) + + +Remark: system parameter . + + +Create node: CDR_Flag(OID: 1.3.6.1.4.1.1373.1.3.3.5.2.1.1) +-> father_name = [System_Param] +-> -> CDR_Flag(0) + + +Register leaf node: CDR_Flag. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : SMSC CDR generation enable or disable. + +Field : total(3) +Access : read-write [1]SMSC CDR + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not generate + [v]1[opt]Generate + } + [2]SMSC LOG + { + [u]0.1-0.1 + [u]select + [v]0[opt]Not generate + [v]1[opt]Generate + } + + +Create node: SM_Validity(OID: 1.3.6.1.4.1.1373.1.3.3.5.2.1.2) +-> father_name = [System_Param] +-> -> CDR_Flag(0) +-> -> SM_Validity(1) + + +Register leaf node: SM_Validity. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : Period of validity of short message, define a threshold how long an awaiting sending message should be kept in sending array till sent to MS, unit is second, default=0c0a8h seconds=12 hours. + +Field : total(1) +Access : read-write[1]SM validity + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: MSISDN_Segment(OID: 1.3.6.1.4.1.1373.1.3.3.5.2.1.3) +-> father_name = [System_Param] +-> -> CDR_Flag(0) +-> -> SM_Validity(1) +-> -> MSISDN_Segment(2) + + +Register leaf node: MSISDN_Segment. +Instance: 16 +Length : 19 +Flag : 255 +Default : 唘Uq' +Remark : Specify the beginning MSISDN for the range of provisioned subscriber. F=end tag. + +Field : total(3) +Access : read-write[1]Start MSISDN + { + [u]0.0-8.7 + [u]input + [v]KeepHex Low E + } +[2]End MSISDN + { + [u]9.0-17.7 + [u]input + [v]KeepHex Low E + } + [3]Number Type + { + [u]18.0-18.7 + [u]select + [v]0[opt]GSM + [v]1[opt]CDMA + } + + +Create node: SMPP_parameters(OID: 1.3.6.1.4.1.1373.1.3.3.5.2.2) +-> father_name = [Configuration] +-> -> System_Param(0) +-> -> SMPP_parameters(1) + + +Register leaf node: SMPP_parameters. +Instance: 32 +Length : 12 +Flag : 255 +Default : +Remark : Name: Can be any name, generally use the name of the connected device. +Service number: SMPP connected party MSISDN used for display on MT MS, +e.g. for a SMPP to PPS, set the service number as MSISDN of PPS. +Data coding scheme: +00:smsc to smpp=7bit,when dcs = 0,smsc to smpp default = 7bit +01:smsc to smpp=8bit,when dcs = 0,smsc to smpp default = 7bit +10:smsc to smpp=7bit,when dcs = 0,smsc to smpp default = 8bit +11:smsc to smpp=8bit,when dcs = 0,smsc to smpp default = 8bit +Default=0. + +Field : total(5) +Access : read-write [1]Enable flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Session type + { + [u]1.0-1.7 + [u]select + [v]0[opt]BIND_TX + [v]1[opt]BIND_RX + [v]2[opt]BIND_TRX + } +[3]Service number + { + [u]2.0-9.7 + [u]input + [v]ToAscii Low 0 + } + [4]Message mode + { + [u]10.0-10.7 + [u]select + [v]0[opt]Store and forward + [v]1[opt]Datagram + [v]2[opt]Transaction + } + [5]Data Coding Scheme + { + [u]11.0-11.7 + [u]select + [v]0[opt]To smpp=7bit,default=7bit + [v]1[opt]To smpp=8bit,default=7bit + [v]16[opt]To smpp=7bit,default=8bit + [v]17[opt]To smpp=8bit,default=8bit + } + + +Create node: Management(OID: 1.3.6.1.4.1.1373.1.3.3.5.3) +-> father_name = [SMSC] +-> -> Configuration(0) +-> -> Management(1) + + +Remark: + Management for SMSC . + + +Create node: SMSC_ID(OID: 1.3.6.1.4.1.1373.1.3.3.5.3.1) +-> father_name = [Management] +-> -> SMSC_ID(0) + + +Register leaf node: SMSC_ID. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : SMSC ID + +Field : total(1) +Access : read-write[1]SMSC ID + { + [u]0.0-0.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Software_Version(OID: 1.3.6.1.4.1.1373.1.3.3.5.3.2) +-> father_name = [Management] +-> -> SMSC_ID(0) +-> -> Software_Version(1) + + +Register leaf node: Software_Version. +Instance: 1 +Length : 7 +Flag : 255 +Default : +Remark : Software version + +Field : total(1) +Access : write-only[1]Version + { + [u]0.0-2.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.5.3.3) +-> father_name = [Management] +-> -> SMSC_ID(0) +-> -> Software_Version(1) +-> -> Command(2) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : SMSC system command. +Save parameters: Save the SMSC parameters in memory to SMSC harddisk. +Delete pending SM: Delete the pending SM in awaiting array. + +Field : total(1) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]1[opt]Save parameters + [v]4[opt]Reset system + [v]5[opt]Delete pending SM + } + + +Create node: PPS(OID: 1.3.6.1.4.1.1373.1.3.3.6) +-> father_name = [App] +-> -> MSC(0) +-> -> HLR(1) +-> -> AUC(2) +-> -> SMSC(3) +-> -> PPS(4) + + +Remark: Subsystems for PPS . + + +Create node: Public_Param(OID: 1.3.6.1.4.1.1373.1.3.3.6.2) +-> father_name = [PPS] +-> -> Public_Param(0) + + +Remark: public parameters for MSS . + + +Create node: Configuration(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1) +-> father_name = [Public_Param] +-> -> Configuration(0) + + +Remark: Configuration for PPS . + + +Create node: Service_Control(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1) +-> father_name = [Configuration] +-> -> Service_Control(0) + + +Remark: Service Control . + + +Create node: CDR_Flag(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.1) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) + + +Register leaf node: CDR_Flag. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : PPS CDR generation enable or disable. Default=PPS generate CDR. + +Field : total(1) +Access : read-write [1]CDR flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Blacklist_Threshold(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.2) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) + + +Register leaf node: Blacklist_Threshold. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Legal recharge failure, subsciber who breaks the threshold will be marked in black list and suspended from service provisioning. Default=5. + +Field : total(1) +Access : read-write[1]Blacklist threshold + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Balance(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.3) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) + + +Register leaf node: Maximum_Balance. +Instance: 1 +Length : 4 +Flag : 255 +Default : +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This value is for overflow prevention. Normally operator doesn't need to change this value. e.g. 5000, and the smallest unit is cent then the maximum allowed balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: License_Control(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.4) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) + + +Register leaf node: License_Control. +Instance: 1 +Length : 8 +Flag : 255 +Default : +Remark : 8-byte encrypted license provided by interWAVE used to provision an approved quantiy of PPS subscribers for service provider. The new license can not support less PPS subscribers than what the old license supports. + +Field : total(1) +Access : read-write[1]License + { + [u]0.0-7.7 + [u]input + [v]KeepHex Low E + } + + +Create node: Prompt_Resolution(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.5) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) + + +Register leaf node: Prompt_Resolution. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Currency style: Set the number of decimals in account balance SM display format. If account balance=55555 in smallest currency unit: +1=account balance display in SM is 55555. +10=account balance display in SM is 5555.5. +100=account balance display in SM is 555.55. +Default=100. +Date style: Set the date format displayed in SM or announcement. Default=YYYY-MM-DD. +Currency symbol position: Set the position of the currency symbol. +There are two types: at the front of the amount (e.g. $5) or at the rear of the amount (e.g. 5Fr). Default=at the front. + +Field : total(4) +Access : read-write [1]Currency resolution + { + [u]0.0-0.1 + [u]select + [v]0[opt]1 + [v]1[opt]10 + [v]2[opt]100 + } + [2]Date format + { + [u]0.2-0.3 + [u]select + [v]0[opt]YYYY-MM-DD + [v]1[opt]DD-MM-YYYY + [v]2[opt]MM-DD-YYYY + } + [3]Currency symbol position + { + [u]0.0-0.0 + [u]select + [v]0[opt]Front + [v]1[opt]Rear + } + + +Create node: SMS_Sentence(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.6) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) +-> -> SMS_Sentence(5) + + +Register leaf node: SMS_Sentence. +Instance: 5 +Length : 112 +Flag : 255 +Default : +Remark : The # of sentence(0-4) refers to differenct language type; + +Field : total(4) +Access : read-write [1]SM encode type + { + [u]0.0-0.7 + [u]select + [v]0[opt]7 bit + [v]4[opt]octet + [v]8[opt]unicode + } +[2]Account balance + { + [u]1.0-31.7 + [u]input + [v]ToAscii Low 0 + } +[3]expired in + { + [u]32.0-63.7 + [u]input + [v]ToAscii Low 0 + } +[4]recharge in time + { + [u]64.0-111.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Last_Call_Info(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.7) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) +-> -> SMS_Sentence(5) +-> -> Last_Call_Info(6) + + +Register leaf node: Last_Call_Info. +Instance: 5 +Length : 88 +Flag : 255 +Default : Last call sent on: +Remark : The # of sentence(0-4) refers to differenct language type. + +Field : total(5) +Access : read-write[1]Last call sent on + { + [u]0.0-31.7 + [u]input + [v]ToAscii Low 0 + } +[2]Last call received on + { + [u]32.0-63.7 + [u]input + [v]ToAscii Low 0 + } +[3]At + { + [u]64.0-71.7 + [u]input + [v]ToAscii Low 0 + } +[4]To + { + [u]72.0-79.7 + [u]input + [v]ToAscii Low 0 + } +[5]From + { + [u]80.0-87.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Currency_Symbol(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.8) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) +-> -> SMS_Sentence(5) +-> -> Last_Call_Info(6) +-> -> Currency_Symbol(7) + + +Register leaf node: Currency_Symbol. +Instance: 1 +Length : 8 +Flag : 255 +Default : $ +Remark : Set the symbol of the local currency in SMS amount display. e.g. $, RMB, EUR, US$, FR$. default=$. In the set window, type the currency symbol. The input symbol will be converted to ASCII code. +Do not input any symbol that not listed on the ASCII code table. ASCII table: 'A'=0x41, 'B'=0x42 ... 'I'=0x49, 'J'=0x4a, 'K'=0x4b ... 'Z'=0x5A, '$'=0x24 +e.g. RMB=0x52 0x4d 0x42, US$=0x55 0x53 0x24 + +Field : total(1) +Access : read-write[1]Currency symbol + { + [u]0.0-7.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Third_Party_Info(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.9) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) +-> -> SMS_Sentence(5) +-> -> Last_Call_Info(6) +-> -> Currency_Symbol(7) +-> -> Third_Party_Info(8) + + +Register leaf node: Third_Party_Info. +Instance: 8 +Length : 16 +Flag : 255 +Default : +Remark : This parameter is a verification for third party ESME when the third party ESME sends a billing request to PPS server. For example, if a subscriber sends a short message via a ESME (e.g. website), the ESME will send a billing request to PPS to debit this subscriber. This billing request must contains a service ID and password to pass the verification. After verification, the subscriber will be debited by the PPS. PPS supports 8 ESME connections. + +Field : total(2) +Access : read-write[1]Service ID + { + [u]0.0-7.7 + [u]input + [v]ToAscii Low 0 + } +[2]Service password + { + [u]8.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Basic_Tariff_Zone(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.1.10) +-> father_name = [Service_Control] +-> -> CDR_Flag(0) +-> -> Blacklist_Threshold(1) +-> -> Maximum_Balance(2) +-> -> License_Control(3) +-> -> Prompt_Resolution(4) +-> -> SMS_Sentence(5) +-> -> Last_Call_Info(6) +-> -> Currency_Symbol(7) +-> -> Third_Party_Info(8) +-> -> Basic_Tariff_Zone(9) + + +Register leaf node: Basic_Tariff_Zone. +Instance: 64 +Length : 9 +Flag : 255 +Default : +Remark : The basic tariff is applied for each calling or called number prefix. The WXC2 System supports 16 MO and MT tariffs (0-15) and 256 billing zones. This parameter defines basic tariff for each billing zone. Each parameter is a combination of MCC, MNC, cell ID, LAC and MO/MT tariff ID. The billing zone may be set as a cell, a LAC or a zone. Normally a single billing zone deploys only one basic tariff. +Each PPS subscriber profile also contains its tariff setup specifying which tariff should be applied for this subscriber. Using either basic tariff zone (location dependent) or tariff in subscriber profile (subscriber dependent) is determined by a parameter -Tariff subscription-. +LAC: If LAC=65536, all LACs in the MCC and MNC use the same basic tariff. +Cell ID: If cell ID=65536, all cells in the LAC use the same basic tariff. + +Field : total(6) +Access : read-write[1]MCC + { + [u]0.0-1.7 + [u]input + [v]KeepHex Low F + } +[2]MNC + { + [u]2.0-2.7 + [u]input + [v]KeepHex Low F + } +[3]LAC + { + [u]3.0-4.7 + [u]input + [v]toDec high 0 + } +[4]Cell ID + { + [u]5.0-6.7 + [u]input + [v]toDec high 0 + } + [5]MO tariff ID + { + [u]7.0-7.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + [6]MT tariff ID + { + [u]8.0-8.7 + [u]select + [v]0[opt]0 + [v]1[opt]1 + [v]2[opt]2 + [v]3[opt]3 + [v]4[opt]4 + [v]5[opt]5 + [v]6[opt]6 + [v]7[opt]7 + [v]8[opt]8 + [v]9[opt]9 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: SRF_Param(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2) +-> father_name = [Configuration] +-> -> Service_Control(0) +-> -> SRF_Param(1) + + +Remark: SRF parameters . + + +Create node: SRF_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.1) +-> father_name = [SRF_Param] +-> -> SRF_Number(0) + + +Remark: SRF Number. + + +Create node: SRF_0_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.1.1) +-> father_name = [SRF_Number] +-> -> SRF_0_Number(0) + + +Register leaf node: SRF_0_Number. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : E.164 number of SRF 0 (Special Resource Function) entity. + +Field : total(1) +Access : read-write[1]SRF 0 number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: SRF_1_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.1.2) +-> father_name = [SRF_Number] +-> -> SRF_0_Number(0) +-> -> SRF_1_Number(1) + + +Register leaf node: SRF_1_Number. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : E.164 number of SRF 1 (Special Resource Function) entity. + +Field : total(1) +Access : read-write[1]SRF 1 number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Service_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2) +-> father_name = [SRF_Param] +-> -> SRF_Number(0) +-> -> Service_Number(1) + + +Remark: Service number . + + +Create node: Hotline(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.1) +-> father_name = [Service_Number] +-> -> Hotline(0) + + +Register leaf node: Hotline. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : PPS service center number. Subscriber dials this number to recharge, enquire their account and modify favorite numbers. + +Field : total(1) +Access : read-write[1]Hotline + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Inquiry(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.2) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) + + +Register leaf node: Inquiry. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated PPS number for account (balance and validity) inquiry. + +Field : total(1) +Access : read-write[1]Inquiry number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Scratch_Card_Recharge(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.3) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) +-> -> Scratch_Card_Recharge(2) + + +Register leaf node: Scratch_Card_Recharge. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated shortcut number for recharge via scratch card. + +Field : total(1) +Access : read-write[1]Recharge via scratch card + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Credit_Card_Recharge(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.4) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) +-> -> Scratch_Card_Recharge(2) +-> -> Credit_Card_Recharge(3) + + +Register leaf node: Credit_Card_Recharge. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated shortcut number for recharge via credit card. + +Field : total(1) +Access : read-write[1]Recharge via credit card + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Third_Party_Recharge(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.5) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) +-> -> Scratch_Card_Recharge(2) +-> -> Credit_Card_Recharge(3) +-> -> Third_Party_Recharge(4) + + +Register leaf node: Third_Party_Recharge. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated shortcut number for recharging other account from MS or PSTN. + +Field : total(1) +Access : read-write[1]Recharge other account + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Customer_Care_Center(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.6) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) +-> -> Scratch_Card_Recharge(2) +-> -> Credit_Card_Recharge(3) +-> -> Third_Party_Recharge(4) +-> -> Customer_Care_Center(5) + + +Register leaf node: Customer_Care_Center. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated shortcut number to connect customer care center. + +Field : total(1) +Access : read-write[1]Customer care center number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Rechareg_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.2.7) +-> father_name = [Service_Number] +-> -> Hotline(0) +-> -> Inquiry(1) +-> -> Scratch_Card_Recharge(2) +-> -> Credit_Card_Recharge(3) +-> -> Third_Party_Recharge(4) +-> -> Customer_Care_Center(5) +-> -> Rechareg_Number(6) + + +Register leaf node: Rechareg_Number. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Dedicated shortcut number for recharge via scratch card or credit card. + +Field : total(1) +Access : read-write[1]Recharge number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Service_Key(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3) +-> father_name = [SRF_Param] +-> -> SRF_Number(0) +-> -> Service_Number(1) +-> -> Service_Key(2) + + +Remark: Service key . + + +Create node: Inquiry(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.2) +-> father_name = [Service_Key] +-> -> Inquiry(0) + + +Register leaf node: Inquiry. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Define the function key to enquire account balance after entering the PPS service center. + +Field : total(1) +Access : read-write[1]Key for inquiry + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Scratch_Card_Recharge(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.3) +-> father_name = [Service_Key] +-> -> Inquiry(0) +-> -> Scratch_Card_Recharge(1) + + +Register leaf node: Scratch_Card_Recharge. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Define the key to recharge account via scratch card after entering the PPS service center. + +Field : total(1) +Access : read-write[1]Key for recharging via scratch card + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Credit_Card_Recharge(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.4) +-> father_name = [Service_Key] +-> -> Inquiry(0) +-> -> Scratch_Card_Recharge(1) +-> -> Credit_Card_Recharge(2) + + +Register leaf node: Credit_Card_Recharge. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Define the key for recharging account via credit card after entering the PPS service center. + +Field : total(1) +Access : read-write[1]Key for recharging via credit card + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Set_Favorite_Number(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.5) +-> father_name = [Service_Key] +-> -> Inquiry(0) +-> -> Scratch_Card_Recharge(1) +-> -> Credit_Card_Recharge(2) +-> -> Set_Favorite_Number(3) + + +Register leaf node: Set_Favorite_Number. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Define the key to set favorite number after entering the PPS service center. + +Field : total(1) +Access : read-write[1]Key to set favorite number + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: Language_Selection(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.6) +-> father_name = [Service_Key] +-> -> Inquiry(0) +-> -> Scratch_Card_Recharge(1) +-> -> Credit_Card_Recharge(2) +-> -> Set_Favorite_Number(3) +-> -> Language_Selection(4) + + +Register leaf node: Language_Selection. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Define the key to select system language (from 5 available candidates) after entering the PPS service center. All announcements in the PPS service center is played in the system language. + +Field : total(1) +Access : read-write[1]Key for language selection + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: SetPasswd(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.2.3.7) +-> father_name = [Service_Key] +-> -> Inquiry(0) +-> -> Scratch_Card_Recharge(1) +-> -> Credit_Card_Recharge(2) +-> -> Set_Favorite_Number(3) +-> -> Language_Selection(4) +-> -> SetPasswd(5) + + +Register leaf node: SetPasswd. +Instance: 1 +Length : 3 +Flag : 255 +Default :  +Remark : Define the key to set account password after entering the PPS service center. When recharging account] selecting language] modifying favorite number or seting password] subscriber is asked to pass the password verification. + +Field : total(1) +Access : read-write[1]PPS account password + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: File_Operation(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.3) +-> father_name = [Configuration] +-> -> Service_Control(0) +-> -> SRF_Param(1) +-> -> File_Operation(2) + + +Remark: File operation . + + +Create node: Import_User_Data(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.3.1) +-> father_name = [File_Operation] +-> -> Import_User_Data(0) + + +Register leaf node: Import_User_Data. +Instance: 1 +Length : 7 +Flag : 255 +Default : +Remark : Read only. Progress and result of PPS subscriber import. +Total number sent: Total quantity of PPS subscribers requesting import. +Records loaded: Quantity of successfully imported PPS subscribers. + +Field : total(3) +Access : read-only [1]Command status + { + [u]0.0-0.7 + [u]select + [v]0[opt]No operation + [v]1[opt]Send command + [v]2[opt]Begin loading + [v]3[opt]Loading OK + [v]4[opt]Loading failed + } +[2]Total number sent + { + [u]1.0-3.7 + [u]input + [v]toDec high 0 + } +[3]Records loaded + { + [u]4.0-6.7 + [u]input + [v]toDec high 0 + } + + +Create node: Import_Recharge_Card(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.3.2) +-> father_name = [File_Operation] +-> -> Import_User_Data(0) +-> -> Import_Recharge_Card(1) + + +Register leaf node: Import_Recharge_Card. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Read only. Result of uploading recharge card to PPS. 0=unsuccessful. 1=successful. + +Field : total(1) +Access : read-only[1]Import recharge card + { + [u]0.0-0.7 + [u]input + [v]toDec high 0 + } + + +Create node: New_Tariff_Flag(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.3.3) +-> father_name = [File_Operation] +-> -> Import_User_Data(0) +-> -> Import_Recharge_Card(1) +-> -> New_Tariff_Flag(2) + + +Register leaf node: New_Tariff_Flag. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-only [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: New_Tariff_Start_Time(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.3.4) +-> father_name = [File_Operation] +-> -> Import_User_Data(0) +-> -> Import_Recharge_Card(1) +-> -> New_Tariff_Flag(2) +-> -> New_Tariff_Start_Time(3) + + +Register leaf node: New_Tariff_Start_Time. +Instance: 1 +Length : 7 +Flag : 255 +Default :  +Remark : Read only. Set start time for new tariff plan. + +Field : total(6) +Access : read-only[1]Year + { + [u]0.0-1.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]3.0-3.7 + [u]input + [v]KeepHex high 0 + } +[4]Hour + { + [u]4.0-4.7 + [u]input + [v]KeepHex high 0 + } +[5]Minute + { + [u]5.0-5.7 + [u]input + [v]KeepHex high 0 + } +[6]Second + { + [u]6.0-6.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: COS_Param(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4) +-> father_name = [Configuration] +-> -> Service_Control(0) +-> -> SRF_Param(1) +-> -> File_Operation(2) +-> -> COS_Param(3) + + +Remark: COS parameters . + + +Create node: COS_0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1) +-> father_name = [COS_Param] +-> -> COS_0(0) + + +Remark: COS 0 Parameters. + + +Create node: Recharge_Promotion_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.1) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.1.1) +-> father_name = [Recharge_Promotion_COS0] +-> -> Start_Date_COS0(0) + + +Register leaf node: Start_Date_COS0. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.1.2) +-> father_name = [Recharge_Promotion_COS0] +-> -> Start_Date_COS0(0) +-> -> End_Date_COS0(1) + + +Register leaf node: End_Date_COS0. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.1.3) +-> father_name = [Recharge_Promotion_COS0] +-> -> Start_Date_COS0(0) +-> -> End_Date_COS0(1) +-> -> Promotion_Bonus_COS0(2) + + +Register leaf node: Promotion_Bonus_COS0. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.2) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) +-> -> Tariff_Resolution_COS0(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.2.1) +-> father_name = [Tariff_Resolution_COS0] +-> -> MO_Tariff_ID_COS0(0) + + +Register leaf node: MO_Tariff_ID_COS0. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.2.2) +-> father_name = [Tariff_Resolution_COS0] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS0(1) + + +Register leaf node: MT_Tariff_ID_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.2.3) +-> father_name = [Tariff_Resolution_COS0] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS0(1) +-> -> Tariff_Subscription_COS0(2) + + +Register leaf node: Tariff_Subscription_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.2.4) +-> father_name = [Tariff_Resolution_COS0] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS0(1) +-> -> Tariff_Subscription_COS0(2) +-> -> Recharge_Card_Validity_COS0(3) + + +Register leaf node: Recharge_Card_Validity_COS0. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.3) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) +-> -> Tariff_Resolution_COS0(1) +-> -> Account_Control_COS0(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.3.1) +-> father_name = [Account_Control_COS0] +-> -> Min_balance_MO_COS0(0) + + +Register leaf node: Min_balance_MO_COS0. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.3.2) +-> father_name = [Account_Control_COS0] +-> -> Min_balance_MO_COS0(0) +-> -> Maximum_Validity_COS0(1) + + +Register leaf node: Maximum_Validity_COS0. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.3.3) +-> father_name = [Account_Control_COS0] +-> -> Min_balance_MO_COS0(0) +-> -> Maximum_Validity_COS0(1) +-> -> Release_Day_COS0(2) + + +Register leaf node: Release_Day_COS0. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.4) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) +-> -> Tariff_Resolution_COS0(1) +-> -> Account_Control_COS0(2) +-> -> MT_Control_COS0(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.4.1) +-> father_name = [MT_Control_COS0] +-> -> Charge_Flag_COS0(0) + + +Register leaf node: Charge_Flag_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.4.2) +-> father_name = [MT_Control_COS0] +-> -> Charge_Flag_COS0(0) +-> -> Zero_Balance_Control_COS0(1) + + +Register leaf node: Zero_Balance_Control_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) +-> -> Tariff_Resolution_COS0(1) +-> -> Account_Control_COS0(2) +-> -> MT_Control_COS0(3) +-> -> Validity_Solution_COS0(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.1) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) + + +Register leaf node: Clear_Balance_Option_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.2) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) + + +Register leaf node: Validity_Recharge_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.3) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) +-> -> Validity_Zero_Balance_COS0(2) + + +Register leaf node: Validity_Zero_Balance_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.4) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) +-> -> Validity_Zero_Balance_COS0(2) +-> -> Activated_Account_Validity_COS0(3) + + +Register leaf node: Activated_Account_Validity_COS0. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.5) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) +-> -> Validity_Zero_Balance_COS0(2) +-> -> Activated_Account_Validity_COS0(3) +-> -> FF_Number_COS0(4) + + +Register leaf node: FF_Number_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.6) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) +-> -> Validity_Zero_Balance_COS0(2) +-> -> Activated_Account_Validity_COS0(3) +-> -> FF_Number_COS0(4) +-> -> Support_Credit_Card_COS0(5) + + +Register leaf node: Support_Credit_Card_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS0 + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.5.7) +-> father_name = [Validity_Solution_COS0] +-> -> Clear_Balance_Option_COS0(0) +-> -> Validity_Recharge_COS0(1) +-> -> Validity_Zero_Balance_COS0(2) +-> -> Activated_Account_Validity_COS0(3) +-> -> FF_Number_COS0(4) +-> -> Support_Credit_Card_COS0(5) +-> -> Credit_Vault_COS0(6) + + +Register leaf node: Credit_Vault_COS0. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.6) +-> father_name = [COS_0] +-> -> Recharge_Promotion_COS0(0) +-> -> Tariff_Resolution_COS0(1) +-> -> Account_Control_COS0(2) +-> -> MT_Control_COS0(3) +-> -> Validity_Solution_COS0(4) +-> -> SM_Inquiry_COS0(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.6.1) +-> father_name = [SM_Inquiry_COS0] +-> -> Feedback_SM_COS0(0) + + +Register leaf node: Feedback_SM_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.6.2) +-> father_name = [SM_Inquiry_COS0] +-> -> Feedback_SM_COS0(0) +-> -> Inquiry_SM_COS0(1) + + +Register leaf node: Inquiry_SM_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.6.3) +-> father_name = [SM_Inquiry_COS0] +-> -> Feedback_SM_COS0(0) +-> -> Inquiry_SM_COS0(1) +-> -> SM_Expiry_COS0(2) + + +Register leaf node: SM_Expiry_COS0. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.1.6.4) +-> father_name = [SM_Inquiry_COS0] +-> -> Feedback_SM_COS0(0) +-> -> Inquiry_SM_COS0(1) +-> -> SM_Expiry_COS0(2) +-> -> SM_Low_Balance_COS0(3) + + +Register leaf node: SM_Low_Balance_COS0. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) + + +Remark: COS 1 Parameters. + + +Create node: Recharge_Promotion_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.1) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.1.1) +-> father_name = [Recharge_Promotion_COS1] +-> -> Start_Date_COS1(0) + + +Register leaf node: Start_Date_COS1. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.1.2) +-> father_name = [Recharge_Promotion_COS1] +-> -> Start_Date_COS1(0) +-> -> End_Date_COS1(1) + + +Register leaf node: End_Date_COS1. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.1.3) +-> father_name = [Recharge_Promotion_COS1] +-> -> Start_Date_COS1(0) +-> -> End_Date_COS1(1) +-> -> Promotion_Bonus_COS1(2) + + +Register leaf node: Promotion_Bonus_COS1. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.2) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) +-> -> Tariff_Resolution_COS1(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.2.1) +-> father_name = [Tariff_Resolution_COS1] +-> -> MO_Tariff_ID_COS1(0) + + +Register leaf node: MO_Tariff_ID_COS1. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.2.2) +-> father_name = [Tariff_Resolution_COS1] +-> -> MO_Tariff_ID_COS1(0) +-> -> MT_Tariff_ID_COS1(1) + + +Register leaf node: MT_Tariff_ID_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.2.3) +-> father_name = [Tariff_Resolution_COS1] +-> -> MO_Tariff_ID_COS1(0) +-> -> MT_Tariff_ID_COS1(1) +-> -> Tariff_Subscription_COS1(2) + + +Register leaf node: Tariff_Subscription_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.2.4) +-> father_name = [Tariff_Resolution_COS1] +-> -> MO_Tariff_ID_COS1(0) +-> -> MT_Tariff_ID_COS1(1) +-> -> Tariff_Subscription_COS1(2) +-> -> Recharge_Card_Validity_COS1(3) + + +Register leaf node: Recharge_Card_Validity_COS1. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.3) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) +-> -> Tariff_Resolution_COS1(1) +-> -> Account_Control_COS1(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.3.1) +-> father_name = [Account_Control_COS1] +-> -> Min_balance_MO_COS1(0) + + +Register leaf node: Min_balance_MO_COS1. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.3.2) +-> father_name = [Account_Control_COS1] +-> -> Min_balance_MO_COS1(0) +-> -> Maximum_Validity_COS1(1) + + +Register leaf node: Maximum_Validity_COS1. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.3.3) +-> father_name = [Account_Control_COS1] +-> -> Min_balance_MO_COS1(0) +-> -> Maximum_Validity_COS1(1) +-> -> Release_Day_COS1(2) + + +Register leaf node: Release_Day_COS1. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.4) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) +-> -> Tariff_Resolution_COS1(1) +-> -> Account_Control_COS1(2) +-> -> MT_Control_COS1(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.4.1) +-> father_name = [MT_Control_COS1] +-> -> Charge_Flag_COS1(0) + + +Register leaf node: Charge_Flag_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.4.2) +-> father_name = [MT_Control_COS1] +-> -> Charge_Flag_COS1(0) +-> -> Zero_Balance_Control_COS1(1) + + +Register leaf node: Zero_Balance_Control_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) +-> -> Tariff_Resolution_COS1(1) +-> -> Account_Control_COS1(2) +-> -> MT_Control_COS1(3) +-> -> Validity_Solution_COS1(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.1) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) + + +Register leaf node: Clear_Balance_Option_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.2) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) + + +Register leaf node: Validity_Recharge_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.3) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) +-> -> Validity_Zero_Balance_COS1(2) + + +Register leaf node: Validity_Zero_Balance_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.4) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) +-> -> Validity_Zero_Balance_COS1(2) +-> -> Activated_Account_Validity_COS1(3) + + +Register leaf node: Activated_Account_Validity_COS1. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.5) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) +-> -> Validity_Zero_Balance_COS1(2) +-> -> Activated_Account_Validity_COS1(3) +-> -> FF_Number_COS1(4) + + +Register leaf node: FF_Number_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.6) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) +-> -> Validity_Zero_Balance_COS1(2) +-> -> Activated_Account_Validity_COS1(3) +-> -> FF_Number_COS1(4) +-> -> Support_Credit_Card_COS1(5) + + +Register leaf node: Support_Credit_Card_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.5.7) +-> father_name = [Validity_Solution_COS1] +-> -> Clear_Balance_Option_COS1(0) +-> -> Validity_Recharge_COS1(1) +-> -> Validity_Zero_Balance_COS1(2) +-> -> Activated_Account_Validity_COS1(3) +-> -> FF_Number_COS1(4) +-> -> Support_Credit_Card_COS1(5) +-> -> Credit_Vault_COS1(6) + + +Register leaf node: Credit_Vault_COS1. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.6) +-> father_name = [COS_1] +-> -> Recharge_Promotion_COS1(0) +-> -> Tariff_Resolution_COS1(1) +-> -> Account_Control_COS1(2) +-> -> MT_Control_COS1(3) +-> -> Validity_Solution_COS1(4) +-> -> SM_Inquiry_COS1(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.6.1) +-> father_name = [SM_Inquiry_COS1] +-> -> Feedback_SM_COS1(0) + + +Register leaf node: Feedback_SM_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.6.2) +-> father_name = [SM_Inquiry_COS1] +-> -> Feedback_SM_COS1(0) +-> -> Inquiry_SM_COS1(1) + + +Register leaf node: Inquiry_SM_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.6.3) +-> father_name = [SM_Inquiry_COS1] +-> -> Feedback_SM_COS1(0) +-> -> Inquiry_SM_COS1(1) +-> -> SM_Expiry_COS1(2) + + +Register leaf node: SM_Expiry_COS1. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS1(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.2.6.4) +-> father_name = [SM_Inquiry_COS1] +-> -> Feedback_SM_COS1(0) +-> -> Inquiry_SM_COS1(1) +-> -> SM_Expiry_COS1(2) +-> -> SM_Low_Balance_COS1(3) + + +Register leaf node: SM_Low_Balance_COS1. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) + + +Remark: COS 2 Parameters. + + +Create node: Recharge_Promotion_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.1) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.1.1) +-> father_name = [Recharge_Promotion_COS2] +-> -> Start_Date_COS2(0) + + +Register leaf node: Start_Date_COS2. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.1.2) +-> father_name = [Recharge_Promotion_COS2] +-> -> Start_Date_COS2(0) +-> -> End_Date_COS2(1) + + +Register leaf node: End_Date_COS2. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.1.3) +-> father_name = [Recharge_Promotion_COS2] +-> -> Start_Date_COS2(0) +-> -> End_Date_COS2(1) +-> -> Promotion_Bonus_COS2(2) + + +Register leaf node: Promotion_Bonus_COS2. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.2) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) +-> -> Tariff_Resolution_COS2(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.2.1) +-> father_name = [Tariff_Resolution_COS2] +-> -> MO_Tariff_ID_COS2(0) + + +Register leaf node: MO_Tariff_ID_COS2. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.2.2) +-> father_name = [Tariff_Resolution_COS2] +-> -> MO_Tariff_ID_COS2(0) +-> -> MT_Tariff_ID_COS2(1) + + +Register leaf node: MT_Tariff_ID_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.2.3) +-> father_name = [Tariff_Resolution_COS2] +-> -> MO_Tariff_ID_COS2(0) +-> -> MT_Tariff_ID_COS2(1) +-> -> Tariff_Subscription_COS2(2) + + +Register leaf node: Tariff_Subscription_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.2.4) +-> father_name = [Tariff_Resolution_COS2] +-> -> MO_Tariff_ID_COS2(0) +-> -> MT_Tariff_ID_COS2(1) +-> -> Tariff_Subscription_COS2(2) +-> -> Recharge_Card_Validity_COS2(3) + + +Register leaf node: Recharge_Card_Validity_COS2. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.3) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) +-> -> Tariff_Resolution_COS2(1) +-> -> Account_Control_COS2(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.3.1) +-> father_name = [Account_Control_COS2] +-> -> Min_balance_MO_COS2(0) + + +Register leaf node: Min_balance_MO_COS2. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.3.2) +-> father_name = [Account_Control_COS2] +-> -> Min_balance_MO_COS2(0) +-> -> Maximum_Validity_COS2(1) + + +Register leaf node: Maximum_Validity_COS2. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.3.3) +-> father_name = [Account_Control_COS2] +-> -> Min_balance_MO_COS2(0) +-> -> Maximum_Validity_COS2(1) +-> -> Release_Day_COS2(2) + + +Register leaf node: Release_Day_COS2. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.4) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) +-> -> Tariff_Resolution_COS2(1) +-> -> Account_Control_COS2(2) +-> -> MT_Control_COS2(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.4.1) +-> father_name = [MT_Control_COS2] +-> -> Charge_Flag_COS2(0) + + +Register leaf node: Charge_Flag_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.4.2) +-> father_name = [MT_Control_COS2] +-> -> Charge_Flag_COS2(0) +-> -> Zero_Balance_Control_COS2(1) + + +Register leaf node: Zero_Balance_Control_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) +-> -> Tariff_Resolution_COS2(1) +-> -> Account_Control_COS2(2) +-> -> MT_Control_COS2(3) +-> -> Validity_Solution_COS2(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.1) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) + + +Register leaf node: Clear_Balance_Option_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.2) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) + + +Register leaf node: Validity_Recharge_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.3) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) +-> -> Validity_Zero_Balance_COS2(2) + + +Register leaf node: Validity_Zero_Balance_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.4) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) +-> -> Validity_Zero_Balance_COS2(2) +-> -> Activated_Account_Validity_COS2(3) + + +Register leaf node: Activated_Account_Validity_COS2. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.5) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) +-> -> Validity_Zero_Balance_COS2(2) +-> -> Activated_Account_Validity_COS2(3) +-> -> FF_Number_COS2(4) + + +Register leaf node: FF_Number_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Free times of changing: set total times of free change for family number if charge is enabled. Maximum is 15. + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.6) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) +-> -> Validity_Zero_Balance_COS2(2) +-> -> Activated_Account_Validity_COS2(3) +-> -> FF_Number_COS2(4) +-> -> Support_Credit_Card_COS2(5) + + +Register leaf node: Support_Credit_Card_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.5.7) +-> father_name = [Validity_Solution_COS2] +-> -> Clear_Balance_Option_COS2(0) +-> -> Validity_Recharge_COS2(1) +-> -> Validity_Zero_Balance_COS2(2) +-> -> Activated_Account_Validity_COS2(3) +-> -> FF_Number_COS2(4) +-> -> Support_Credit_Card_COS2(5) +-> -> Credit_Vault_COS2(6) + + +Register leaf node: Credit_Vault_COS2. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.6) +-> father_name = [COS_2] +-> -> Recharge_Promotion_COS2(0) +-> -> Tariff_Resolution_COS2(1) +-> -> Account_Control_COS2(2) +-> -> MT_Control_COS2(3) +-> -> Validity_Solution_COS2(4) +-> -> SM_Inquiry_COS2(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.6.1) +-> father_name = [SM_Inquiry_COS2] +-> -> Feedback_SM_COS2(0) + + +Register leaf node: Feedback_SM_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.6.2) +-> father_name = [SM_Inquiry_COS2] +-> -> Feedback_SM_COS2(0) +-> -> Inquiry_SM_COS2(1) + + +Register leaf node: Inquiry_SM_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.6.3) +-> father_name = [SM_Inquiry_COS2] +-> -> Feedback_SM_COS2(0) +-> -> Inquiry_SM_COS2(1) +-> -> SM_Expiry_COS2(2) + + +Register leaf node: SM_Expiry_COS2. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS2(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.3.6.4) +-> father_name = [SM_Inquiry_COS2] +-> -> Feedback_SM_COS2(0) +-> -> Inquiry_SM_COS2(1) +-> -> SM_Expiry_COS2(2) +-> -> SM_Low_Balance_COS2(3) + + +Register leaf node: SM_Low_Balance_COS2. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) + + +Remark: COS 3 Parameters. + + +Create node: Recharge_Promotion_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.1) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.1.1) +-> father_name = [Recharge_Promotion_COS3] +-> -> Start_Date_COS3(0) + + +Register leaf node: Start_Date_COS3. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.1.2) +-> father_name = [Recharge_Promotion_COS3] +-> -> Start_Date_COS3(0) +-> -> End_Date_COS3(1) + + +Register leaf node: End_Date_COS3. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.1.3) +-> father_name = [Recharge_Promotion_COS3] +-> -> Start_Date_COS3(0) +-> -> End_Date_COS3(1) +-> -> Promotion_Bonus_COS3(2) + + +Register leaf node: Promotion_Bonus_COS3. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.2) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) +-> -> Tariff_Resolution_COS3(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.2.1) +-> father_name = [Tariff_Resolution_COS3] +-> -> MO_Tariff_ID_COS3(0) + + +Register leaf node: MO_Tariff_ID_COS3. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.2.2) +-> father_name = [Tariff_Resolution_COS3] +-> -> MO_Tariff_ID_COS3(0) +-> -> MT_Tariff_ID_COS3(1) + + +Register leaf node: MT_Tariff_ID_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.2.3) +-> father_name = [Tariff_Resolution_COS3] +-> -> MO_Tariff_ID_COS3(0) +-> -> MT_Tariff_ID_COS3(1) +-> -> Tariff_Subscription_COS3(2) + + +Register leaf node: Tariff_Subscription_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.2.4) +-> father_name = [Tariff_Resolution_COS3] +-> -> MO_Tariff_ID_COS3(0) +-> -> MT_Tariff_ID_COS3(1) +-> -> Tariff_Subscription_COS3(2) +-> -> Recharge_Card_Validity_COS3(3) + + +Register leaf node: Recharge_Card_Validity_COS3. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.3) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) +-> -> Tariff_Resolution_COS3(1) +-> -> Account_Control_COS3(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.3.1) +-> father_name = [Account_Control_COS3] +-> -> Min_balance_MO_COS3(0) + + +Register leaf node: Min_balance_MO_COS3. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.3.2) +-> father_name = [Account_Control_COS3] +-> -> Min_balance_MO_COS3(0) +-> -> Maximum_Validity_COS3(1) + + +Register leaf node: Maximum_Validity_COS3. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.3.3) +-> father_name = [Account_Control_COS3] +-> -> Min_balance_MO_COS3(0) +-> -> Maximum_Validity_COS3(1) +-> -> Release_Day_COS3(2) + + +Register leaf node: Release_Day_COS3. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.4) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) +-> -> Tariff_Resolution_COS3(1) +-> -> Account_Control_COS3(2) +-> -> MT_Control_COS3(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.4.1) +-> father_name = [MT_Control_COS3] +-> -> Charge_Flag_COS3(0) + + +Register leaf node: Charge_Flag_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.4.2) +-> father_name = [MT_Control_COS3] +-> -> Charge_Flag_COS3(0) +-> -> Zero_Balance_Control_COS3(1) + + +Register leaf node: Zero_Balance_Control_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) +-> -> Tariff_Resolution_COS3(1) +-> -> Account_Control_COS3(2) +-> -> MT_Control_COS3(3) +-> -> Validity_Solution_COS3(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.1) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) + + +Register leaf node: Clear_Balance_Option_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.2) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) + + +Register leaf node: Validity_Recharge_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.3) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) +-> -> Validity_Zero_Balance_COS3(2) + + +Register leaf node: Validity_Zero_Balance_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.4) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) +-> -> Validity_Zero_Balance_COS3(2) +-> -> Activated_Account_Validity_COS3(3) + + +Register leaf node: Activated_Account_Validity_COS3. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.5) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) +-> -> Validity_Zero_Balance_COS3(2) +-> -> Activated_Account_Validity_COS3(3) +-> -> FF_Number_COS3(4) + + +Register leaf node: FF_Number_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.6) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) +-> -> Validity_Zero_Balance_COS3(2) +-> -> Activated_Account_Validity_COS3(3) +-> -> FF_Number_COS3(4) +-> -> Support_Credit_Card_COS3(5) + + +Register leaf node: Support_Credit_Card_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.5.7) +-> father_name = [Validity_Solution_COS3] +-> -> Clear_Balance_Option_COS3(0) +-> -> Validity_Recharge_COS3(1) +-> -> Validity_Zero_Balance_COS3(2) +-> -> Activated_Account_Validity_COS3(3) +-> -> FF_Number_COS3(4) +-> -> Support_Credit_Card_COS3(5) +-> -> Credit_Vault_COS3(6) + + +Register leaf node: Credit_Vault_COS3. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.6) +-> father_name = [COS_3] +-> -> Recharge_Promotion_COS3(0) +-> -> Tariff_Resolution_COS3(1) +-> -> Account_Control_COS3(2) +-> -> MT_Control_COS3(3) +-> -> Validity_Solution_COS3(4) +-> -> SM_Inquiry_COS3(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.6.1) +-> father_name = [SM_Inquiry_COS3] +-> -> Feedback_SM_COS3(0) + + +Register leaf node: Feedback_SM_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.6.2) +-> father_name = [SM_Inquiry_COS3] +-> -> Feedback_SM_COS3(0) +-> -> Inquiry_SM_COS3(1) + + +Register leaf node: Inquiry_SM_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.6.3) +-> father_name = [SM_Inquiry_COS3] +-> -> Feedback_SM_COS3(0) +-> -> Inquiry_SM_COS3(1) +-> -> SM_Expiry_COS3(2) + + +Register leaf node: SM_Expiry_COS3. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS3(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.4.6.4) +-> father_name = [SM_Inquiry_COS3] +-> -> Feedback_SM_COS3(0) +-> -> Inquiry_SM_COS3(1) +-> -> SM_Expiry_COS3(2) +-> -> SM_Low_Balance_COS3(3) + + +Register leaf node: SM_Low_Balance_COS3. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) + + +Remark: COS 4 Parameters. + + +Create node: Recharge_Promotion_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.1) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.1.1) +-> father_name = [Recharge_Promotion_COS4] +-> -> Start_Date_COS4(0) + + +Register leaf node: Start_Date_COS4. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.1.2) +-> father_name = [Recharge_Promotion_COS4] +-> -> Start_Date_COS4(0) +-> -> End_Date_COS4(1) + + +Register leaf node: End_Date_COS4. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.1.3) +-> father_name = [Recharge_Promotion_COS4] +-> -> Start_Date_COS4(0) +-> -> End_Date_COS4(1) +-> -> Promotion_Bonus_COS4(2) + + +Register leaf node: Promotion_Bonus_COS4. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.2) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) +-> -> Tariff_Resolution_COS4(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.2.1) +-> father_name = [Tariff_Resolution_COS4] +-> -> MO_Tariff_ID_COS4(0) + + +Register leaf node: MO_Tariff_ID_COS4. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.2.2) +-> father_name = [Tariff_Resolution_COS4] +-> -> MO_Tariff_ID_COS4(0) +-> -> MT_Tariff_ID_COS4(1) + + +Register leaf node: MT_Tariff_ID_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.2.3) +-> father_name = [Tariff_Resolution_COS4] +-> -> MO_Tariff_ID_COS4(0) +-> -> MT_Tariff_ID_COS4(1) +-> -> Tariff_Subscription_COS4(2) + + +Register leaf node: Tariff_Subscription_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.2.4) +-> father_name = [Tariff_Resolution_COS4] +-> -> MO_Tariff_ID_COS4(0) +-> -> MT_Tariff_ID_COS4(1) +-> -> Tariff_Subscription_COS4(2) +-> -> Recharge_Card_Validity_COS4(3) + + +Register leaf node: Recharge_Card_Validity_COS4. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.3) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) +-> -> Tariff_Resolution_COS4(1) +-> -> Account_Control_COS4(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.3.1) +-> father_name = [Account_Control_COS4] +-> -> Min_balance_MO_COS4(0) + + +Register leaf node: Min_balance_MO_COS4. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.3.2) +-> father_name = [Account_Control_COS4] +-> -> Min_balance_MO_COS4(0) +-> -> Maximum_Validity_COS4(1) + + +Register leaf node: Maximum_Validity_COS4. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.3.3) +-> father_name = [Account_Control_COS4] +-> -> Min_balance_MO_COS4(0) +-> -> Maximum_Validity_COS4(1) +-> -> Release_Day_COS4(2) + + +Register leaf node: Release_Day_COS4. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.4) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) +-> -> Tariff_Resolution_COS4(1) +-> -> Account_Control_COS4(2) +-> -> MT_Control_COS4(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.4.1) +-> father_name = [MT_Control_COS4] +-> -> Charge_Flag_COS4(0) + + +Register leaf node: Charge_Flag_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.4.2) +-> father_name = [MT_Control_COS4] +-> -> Charge_Flag_COS4(0) +-> -> Zero_Balance_Control_COS4(1) + + +Register leaf node: Zero_Balance_Control_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) +-> -> Tariff_Resolution_COS4(1) +-> -> Account_Control_COS4(2) +-> -> MT_Control_COS4(3) +-> -> Validity_Solution_COS4(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.1) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) + + +Register leaf node: Clear_Balance_Option_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.2) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) + + +Register leaf node: Validity_Recharge_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.3) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) +-> -> Validity_Zero_Balance_COS4(2) + + +Register leaf node: Validity_Zero_Balance_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.4) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) +-> -> Validity_Zero_Balance_COS4(2) +-> -> Activated_Account_Validity_COS4(3) + + +Register leaf node: Activated_Account_Validity_COS4. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.5) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) +-> -> Validity_Zero_Balance_COS4(2) +-> -> Activated_Account_Validity_COS4(3) +-> -> FF_Number_COS4(4) + + +Register leaf node: FF_Number_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.6) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) +-> -> Validity_Zero_Balance_COS4(2) +-> -> Activated_Account_Validity_COS4(3) +-> -> FF_Number_COS4(4) +-> -> Support_Credit_Card_COS4(5) + + +Register leaf node: Support_Credit_Card_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.5.7) +-> father_name = [Validity_Solution_COS4] +-> -> Clear_Balance_Option_COS4(0) +-> -> Validity_Recharge_COS4(1) +-> -> Validity_Zero_Balance_COS4(2) +-> -> Activated_Account_Validity_COS4(3) +-> -> FF_Number_COS4(4) +-> -> Support_Credit_Card_COS4(5) +-> -> Credit_Vault_COS4(6) + + +Register leaf node: Credit_Vault_COS4. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.6) +-> father_name = [COS_4] +-> -> Recharge_Promotion_COS4(0) +-> -> Tariff_Resolution_COS4(1) +-> -> Account_Control_COS4(2) +-> -> MT_Control_COS4(3) +-> -> Validity_Solution_COS4(4) +-> -> SM_Inquiry_COS4(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.6.1) +-> father_name = [SM_Inquiry_COS4] +-> -> Feedback_SM_COS4(0) + + +Register leaf node: Feedback_SM_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.6.2) +-> father_name = [SM_Inquiry_COS4] +-> -> Feedback_SM_COS4(0) +-> -> Inquiry_SM_COS4(1) + + +Register leaf node: Inquiry_SM_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.6.3) +-> father_name = [SM_Inquiry_COS4] +-> -> Feedback_SM_COS4(0) +-> -> Inquiry_SM_COS4(1) +-> -> SM_Expiry_COS4(2) + + +Register leaf node: SM_Expiry_COS4. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS4(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.5.6.4) +-> father_name = [SM_Inquiry_COS4] +-> -> Feedback_SM_COS4(0) +-> -> Inquiry_SM_COS4(1) +-> -> SM_Expiry_COS4(2) +-> -> SM_Low_Balance_COS4(3) + + +Register leaf node: SM_Low_Balance_COS4. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) + + +Remark: COS 5 Parameters. + + +Create node: Recharge_Promotion_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.1) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.1.1) +-> father_name = [Recharge_Promotion_COS5] +-> -> Start_Date_COS5(0) + + +Register leaf node: Start_Date_COS5. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.1.2) +-> father_name = [Recharge_Promotion_COS5] +-> -> Start_Date_COS5(0) +-> -> End_Date_COS5(1) + + +Register leaf node: End_Date_COS5. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.1.3) +-> father_name = [Recharge_Promotion_COS5] +-> -> Start_Date_COS5(0) +-> -> End_Date_COS5(1) +-> -> Promotion_Bonus_COS5(2) + + +Register leaf node: Promotion_Bonus_COS5. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.2) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) +-> -> Tariff_Resolution_COS5(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.2.1) +-> father_name = [Tariff_Resolution_COS5] +-> -> MO_Tariff_ID_COS5(0) + + +Register leaf node: MO_Tariff_ID_COS5. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.2.2) +-> father_name = [Tariff_Resolution_COS5] +-> -> MO_Tariff_ID_COS5(0) +-> -> MT_Tariff_ID_COS5(1) + + +Register leaf node: MT_Tariff_ID_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.2.3) +-> father_name = [Tariff_Resolution_COS5] +-> -> MO_Tariff_ID_COS5(0) +-> -> MT_Tariff_ID_COS5(1) +-> -> Tariff_Subscription_COS5(2) + + +Register leaf node: Tariff_Subscription_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.2.4) +-> father_name = [Tariff_Resolution_COS5] +-> -> MO_Tariff_ID_COS5(0) +-> -> MT_Tariff_ID_COS5(1) +-> -> Tariff_Subscription_COS5(2) +-> -> Recharge_Card_Validity_COS5(3) + + +Register leaf node: Recharge_Card_Validity_COS5. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.3) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) +-> -> Tariff_Resolution_COS5(1) +-> -> Account_Control_COS5(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.3.1) +-> father_name = [Account_Control_COS5] +-> -> Min_balance_MO_COS5(0) + + +Register leaf node: Min_balance_MO_COS5. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.3.2) +-> father_name = [Account_Control_COS5] +-> -> Min_balance_MO_COS5(0) +-> -> Maximum_Validity_COS5(1) + + +Register leaf node: Maximum_Validity_COS5. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.3.3) +-> father_name = [Account_Control_COS5] +-> -> Min_balance_MO_COS5(0) +-> -> Maximum_Validity_COS5(1) +-> -> Release_Day_COS5(2) + + +Register leaf node: Release_Day_COS5. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.4) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) +-> -> Tariff_Resolution_COS5(1) +-> -> Account_Control_COS5(2) +-> -> MT_Control_COS5(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.4.1) +-> father_name = [MT_Control_COS5] +-> -> Charge_Flag_COS5(0) + + +Register leaf node: Charge_Flag_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.4.2) +-> father_name = [MT_Control_COS5] +-> -> Charge_Flag_COS5(0) +-> -> Zero_Balance_Control_COS5(1) + + +Register leaf node: Zero_Balance_Control_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) +-> -> Tariff_Resolution_COS5(1) +-> -> Account_Control_COS5(2) +-> -> MT_Control_COS5(3) +-> -> Validity_Solution_COS5(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.1) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) + + +Register leaf node: Clear_Balance_Option_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.2) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) + + +Register leaf node: Validity_Recharge_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.3) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) +-> -> Validity_Zero_Balance_COS5(2) + + +Register leaf node: Validity_Zero_Balance_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.4) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) +-> -> Validity_Zero_Balance_COS5(2) +-> -> Activated_Account_Validity_COS5(3) + + +Register leaf node: Activated_Account_Validity_COS5. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.5) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) +-> -> Validity_Zero_Balance_COS5(2) +-> -> Activated_Account_Validity_COS5(3) +-> -> FF_Number_COS5(4) + + +Register leaf node: FF_Number_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.6) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) +-> -> Validity_Zero_Balance_COS5(2) +-> -> Activated_Account_Validity_COS5(3) +-> -> FF_Number_COS5(4) +-> -> Support_Credit_Card_COS5(5) + + +Register leaf node: Support_Credit_Card_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.5.7) +-> father_name = [Validity_Solution_COS5] +-> -> Clear_Balance_Option_COS5(0) +-> -> Validity_Recharge_COS5(1) +-> -> Validity_Zero_Balance_COS5(2) +-> -> Activated_Account_Validity_COS5(3) +-> -> FF_Number_COS5(4) +-> -> Support_Credit_Card_COS5(5) +-> -> Credit_Vault_COS5(6) + + +Register leaf node: Credit_Vault_COS5. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.6) +-> father_name = [COS_5] +-> -> Recharge_Promotion_COS5(0) +-> -> Tariff_Resolution_COS5(1) +-> -> Account_Control_COS5(2) +-> -> MT_Control_COS5(3) +-> -> Validity_Solution_COS5(4) +-> -> SM_Inquiry_COS5(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.6.1) +-> father_name = [SM_Inquiry_COS5] +-> -> Feedback_SM_COS5(0) + + +Register leaf node: Feedback_SM_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.6.2) +-> father_name = [SM_Inquiry_COS5] +-> -> Feedback_SM_COS5(0) +-> -> Inquiry_SM_COS5(1) + + +Register leaf node: Inquiry_SM_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.6.3) +-> father_name = [SM_Inquiry_COS5] +-> -> Feedback_SM_COS5(0) +-> -> Inquiry_SM_COS5(1) +-> -> SM_Expiry_COS5(2) + + +Register leaf node: SM_Expiry_COS5. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS5(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.6.6.4) +-> father_name = [SM_Inquiry_COS5] +-> -> Feedback_SM_COS5(0) +-> -> Inquiry_SM_COS5(1) +-> -> SM_Expiry_COS5(2) +-> -> SM_Low_Balance_COS5(3) + + +Register leaf node: SM_Low_Balance_COS5. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) + + +Remark: COS 6 Parameters. + + +Create node: Recharge_Promotion_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.1) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.1.1) +-> father_name = [Recharge_Promotion_COS6] +-> -> Start_Date_COS6(0) + + +Register leaf node: Start_Date_COS6. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.1.2) +-> father_name = [Recharge_Promotion_COS6] +-> -> Start_Date_COS6(0) +-> -> End_Date_COS6(1) + + +Register leaf node: End_Date_COS6. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.1.3) +-> father_name = [Recharge_Promotion_COS6] +-> -> Start_Date_COS6(0) +-> -> End_Date_COS6(1) +-> -> Promotion_Bonus_COS6(2) + + +Register leaf node: Promotion_Bonus_COS6. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.2) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) +-> -> Tariff_Resolution_COS6(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.2.1) +-> father_name = [Tariff_Resolution_COS6] +-> -> MO_Tariff_ID_COS6(0) + + +Register leaf node: MO_Tariff_ID_COS6. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.2.2) +-> father_name = [Tariff_Resolution_COS6] +-> -> MO_Tariff_ID_COS6(0) +-> -> MT_Tariff_ID_COS6(1) + + +Register leaf node: MT_Tariff_ID_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.2.3) +-> father_name = [Tariff_Resolution_COS6] +-> -> MO_Tariff_ID_COS6(0) +-> -> MT_Tariff_ID_COS6(1) +-> -> Tariff_Subscription_COS6(2) + + +Register leaf node: Tariff_Subscription_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.2.4) +-> father_name = [Tariff_Resolution_COS6] +-> -> MO_Tariff_ID_COS6(0) +-> -> MT_Tariff_ID_COS6(1) +-> -> Tariff_Subscription_COS6(2) +-> -> Recharge_Card_Validity_COS6(3) + + +Register leaf node: Recharge_Card_Validity_COS6. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.3) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) +-> -> Tariff_Resolution_COS6(1) +-> -> Account_Control_COS6(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.3.1) +-> father_name = [Account_Control_COS6] +-> -> Min_balance_MO_COS6(0) + + +Register leaf node: Min_balance_MO_COS6. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.3.2) +-> father_name = [Account_Control_COS6] +-> -> Min_balance_MO_COS6(0) +-> -> Maximum_Validity_COS6(1) + + +Register leaf node: Maximum_Validity_COS6. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.3.3) +-> father_name = [Account_Control_COS6] +-> -> Min_balance_MO_COS6(0) +-> -> Maximum_Validity_COS6(1) +-> -> Release_Day_COS6(2) + + +Register leaf node: Release_Day_COS6. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.4) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) +-> -> Tariff_Resolution_COS6(1) +-> -> Account_Control_COS6(2) +-> -> MT_Control_COS6(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.4.1) +-> father_name = [MT_Control_COS6] +-> -> Charge_Flag_COS6(0) + + +Register leaf node: Charge_Flag_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.4.2) +-> father_name = [MT_Control_COS6] +-> -> Charge_Flag_COS6(0) +-> -> Zero_Balance_Control_COS6(1) + + +Register leaf node: Zero_Balance_Control_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) +-> -> Tariff_Resolution_COS6(1) +-> -> Account_Control_COS6(2) +-> -> MT_Control_COS6(3) +-> -> Validity_Solution_COS6(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.1) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) + + +Register leaf node: Clear_Balance_Option_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.2) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) + + +Register leaf node: Validity_Recharge_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.3) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) +-> -> Validity_Zero_Balance_COS6(2) + + +Register leaf node: Validity_Zero_Balance_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.4) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) +-> -> Validity_Zero_Balance_COS6(2) +-> -> Activated_Account_Validity_COS6(3) + + +Register leaf node: Activated_Account_Validity_COS6. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.5) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) +-> -> Validity_Zero_Balance_COS6(2) +-> -> Activated_Account_Validity_COS6(3) +-> -> FF_Number_COS6(4) + + +Register leaf node: FF_Number_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.6) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) +-> -> Validity_Zero_Balance_COS6(2) +-> -> Activated_Account_Validity_COS6(3) +-> -> FF_Number_COS6(4) +-> -> Support_Credit_Card_COS6(5) + + +Register leaf node: Support_Credit_Card_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.5.7) +-> father_name = [Validity_Solution_COS6] +-> -> Clear_Balance_Option_COS6(0) +-> -> Validity_Recharge_COS6(1) +-> -> Validity_Zero_Balance_COS6(2) +-> -> Activated_Account_Validity_COS6(3) +-> -> FF_Number_COS6(4) +-> -> Support_Credit_Card_COS6(5) +-> -> Credit_Vault_COS6(6) + + +Register leaf node: Credit_Vault_COS6. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.6) +-> father_name = [COS_6] +-> -> Recharge_Promotion_COS6(0) +-> -> Tariff_Resolution_COS6(1) +-> -> Account_Control_COS6(2) +-> -> MT_Control_COS6(3) +-> -> Validity_Solution_COS6(4) +-> -> SM_Inquiry_COS6(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.6.1) +-> father_name = [SM_Inquiry_COS6] +-> -> Feedback_SM_COS6(0) + + +Register leaf node: Feedback_SM_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.6.2) +-> father_name = [SM_Inquiry_COS6] +-> -> Feedback_SM_COS6(0) +-> -> Inquiry_SM_COS6(1) + + +Register leaf node: Inquiry_SM_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.6.3) +-> father_name = [SM_Inquiry_COS6] +-> -> Feedback_SM_COS6(0) +-> -> Inquiry_SM_COS6(1) +-> -> SM_Expiry_COS6(2) + + +Register leaf node: SM_Expiry_COS6. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS6(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.7.6.4) +-> father_name = [SM_Inquiry_COS6] +-> -> Feedback_SM_COS6(0) +-> -> Inquiry_SM_COS6(1) +-> -> SM_Expiry_COS6(2) +-> -> SM_Low_Balance_COS6(3) + + +Register leaf node: SM_Low_Balance_COS6. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) + + +Remark: COS 7 Parameters. + + +Create node: Recharge_Promotion_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.1) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.1.1) +-> father_name = [Recharge_Promotion_COS7] +-> -> Start_Date_COS7(0) + + +Register leaf node: Start_Date_COS7. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.1.2) +-> father_name = [Recharge_Promotion_COS7] +-> -> Start_Date_COS7(0) +-> -> End_Date_COS7(1) + + +Register leaf node: End_Date_COS7. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.1.3) +-> father_name = [Recharge_Promotion_COS7] +-> -> Start_Date_COS7(0) +-> -> End_Date_COS7(1) +-> -> Promotion_Bonus_COS7(2) + + +Register leaf node: Promotion_Bonus_COS7. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.2) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) +-> -> Tariff_Resolution_COS7(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.2.1) +-> father_name = [Tariff_Resolution_COS7] +-> -> MO_Tariff_ID_COS7(0) + + +Register leaf node: MO_Tariff_ID_COS7. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.2.2) +-> father_name = [Tariff_Resolution_COS7] +-> -> MO_Tariff_ID_COS7(0) +-> -> MT_Tariff_ID_COS7(1) + + +Register leaf node: MT_Tariff_ID_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.2.3) +-> father_name = [Tariff_Resolution_COS7] +-> -> MO_Tariff_ID_COS7(0) +-> -> MT_Tariff_ID_COS7(1) +-> -> Tariff_Subscription_COS7(2) + + +Register leaf node: Tariff_Subscription_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.2.4) +-> father_name = [Tariff_Resolution_COS7] +-> -> MO_Tariff_ID_COS7(0) +-> -> MT_Tariff_ID_COS7(1) +-> -> Tariff_Subscription_COS7(2) +-> -> Recharge_Card_Validity_COS7(3) + + +Register leaf node: Recharge_Card_Validity_COS7. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.3) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) +-> -> Tariff_Resolution_COS7(1) +-> -> Account_Control_COS7(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.3.1) +-> father_name = [Account_Control_COS7] +-> -> Min_balance_MO_COS7(0) + + +Register leaf node: Min_balance_MO_COS7. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.3.2) +-> father_name = [Account_Control_COS7] +-> -> Min_balance_MO_COS7(0) +-> -> Maximum_Validity_COS7(1) + + +Register leaf node: Maximum_Validity_COS7. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.3.3) +-> father_name = [Account_Control_COS7] +-> -> Min_balance_MO_COS7(0) +-> -> Maximum_Validity_COS7(1) +-> -> Release_Day_COS7(2) + + +Register leaf node: Release_Day_COS7. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.4) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) +-> -> Tariff_Resolution_COS7(1) +-> -> Account_Control_COS7(2) +-> -> MT_Control_COS7(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.4.1) +-> father_name = [MT_Control_COS7] +-> -> Charge_Flag_COS7(0) + + +Register leaf node: Charge_Flag_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.4.2) +-> father_name = [MT_Control_COS7] +-> -> Charge_Flag_COS7(0) +-> -> Zero_Balance_Control_COS7(1) + + +Register leaf node: Zero_Balance_Control_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) +-> -> Tariff_Resolution_COS7(1) +-> -> Account_Control_COS7(2) +-> -> MT_Control_COS7(3) +-> -> Validity_Solution_COS7(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.1) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) + + +Register leaf node: Clear_Balance_Option_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.2) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) + + +Register leaf node: Validity_Recharge_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.3) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) +-> -> Validity_Zero_Balance_COS7(2) + + +Register leaf node: Validity_Zero_Balance_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.4) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) +-> -> Validity_Zero_Balance_COS7(2) +-> -> Activated_Account_Validity_COS7(3) + + +Register leaf node: Activated_Account_Validity_COS7. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.5) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) +-> -> Validity_Zero_Balance_COS7(2) +-> -> Activated_Account_Validity_COS7(3) +-> -> FF_Number_COS7(4) + + +Register leaf node: FF_Number_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.6) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) +-> -> Validity_Zero_Balance_COS7(2) +-> -> Activated_Account_Validity_COS7(3) +-> -> FF_Number_COS7(4) +-> -> Support_Credit_Card_COS7(5) + + +Register leaf node: Support_Credit_Card_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.5.7) +-> father_name = [Validity_Solution_COS7] +-> -> Clear_Balance_Option_COS7(0) +-> -> Validity_Recharge_COS7(1) +-> -> Validity_Zero_Balance_COS7(2) +-> -> Activated_Account_Validity_COS7(3) +-> -> FF_Number_COS7(4) +-> -> Support_Credit_Card_COS7(5) +-> -> Credit_Vault_COS7(6) + + +Register leaf node: Credit_Vault_COS7. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.6) +-> father_name = [COS_7] +-> -> Recharge_Promotion_COS7(0) +-> -> Tariff_Resolution_COS7(1) +-> -> Account_Control_COS7(2) +-> -> MT_Control_COS7(3) +-> -> Validity_Solution_COS7(4) +-> -> SM_Inquiry_COS7(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.6.1) +-> father_name = [SM_Inquiry_COS7] +-> -> Feedback_SM_COS7(0) + + +Register leaf node: Feedback_SM_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.6.2) +-> father_name = [SM_Inquiry_COS7] +-> -> Feedback_SM_COS7(0) +-> -> Inquiry_SM_COS7(1) + + +Register leaf node: Inquiry_SM_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.6.3) +-> father_name = [SM_Inquiry_COS7] +-> -> Feedback_SM_COS7(0) +-> -> Inquiry_SM_COS7(1) +-> -> SM_Expiry_COS7(2) + + +Register leaf node: SM_Expiry_COS7. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS7(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.8.6.4) +-> father_name = [SM_Inquiry_COS7] +-> -> Feedback_SM_COS7(0) +-> -> Inquiry_SM_COS7(1) +-> -> SM_Expiry_COS7(2) +-> -> SM_Low_Balance_COS7(3) + + +Register leaf node: SM_Low_Balance_COS7. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) + + +Remark: COS 8 Parameters. + + +Create node: Recharge_Promotion_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.1) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.1.1) +-> father_name = [Recharge_Promotion_COS8] +-> -> Start_Date_COS8(0) + + +Register leaf node: Start_Date_COS8. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.1.2) +-> father_name = [Recharge_Promotion_COS8] +-> -> Start_Date_COS8(0) +-> -> End_Date_COS8(1) + + +Register leaf node: End_Date_COS8. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.1.3) +-> father_name = [Recharge_Promotion_COS8] +-> -> Start_Date_COS8(0) +-> -> End_Date_COS8(1) +-> -> Promotion_Bonus_COS8(2) + + +Register leaf node: Promotion_Bonus_COS8. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.2) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) +-> -> Tariff_Resolution_COS8(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.2.1) +-> father_name = [Tariff_Resolution_COS8] +-> -> MO_Tariff_ID_COS8(0) + + +Register leaf node: MO_Tariff_ID_COS8. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.2.2) +-> father_name = [Tariff_Resolution_COS8] +-> -> MO_Tariff_ID_COS8(0) +-> -> MT_Tariff_ID_COS8(1) + + +Register leaf node: MT_Tariff_ID_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.2.3) +-> father_name = [Tariff_Resolution_COS8] +-> -> MO_Tariff_ID_COS8(0) +-> -> MT_Tariff_ID_COS8(1) +-> -> Tariff_Subscription_COS8(2) + + +Register leaf node: Tariff_Subscription_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.2.4) +-> father_name = [Tariff_Resolution_COS8] +-> -> MO_Tariff_ID_COS8(0) +-> -> MT_Tariff_ID_COS8(1) +-> -> Tariff_Subscription_COS8(2) +-> -> Recharge_Card_Validity_COS8(3) + + +Register leaf node: Recharge_Card_Validity_COS8. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.3) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) +-> -> Tariff_Resolution_COS8(1) +-> -> Account_Control_COS8(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.3.1) +-> father_name = [Account_Control_COS8] +-> -> Min_balance_MO_COS8(0) + + +Register leaf node: Min_balance_MO_COS8. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.3.2) +-> father_name = [Account_Control_COS8] +-> -> Min_balance_MO_COS8(0) +-> -> Maximum_Validity_COS8(1) + + +Register leaf node: Maximum_Validity_COS8. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.3.3) +-> father_name = [Account_Control_COS8] +-> -> Min_balance_MO_COS8(0) +-> -> Maximum_Validity_COS8(1) +-> -> Release_Day_COS8(2) + + +Register leaf node: Release_Day_COS8. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.4) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) +-> -> Tariff_Resolution_COS8(1) +-> -> Account_Control_COS8(2) +-> -> MT_Control_COS8(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.4.1) +-> father_name = [MT_Control_COS8] +-> -> Charge_Flag_COS8(0) + + +Register leaf node: Charge_Flag_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.4.2) +-> father_name = [MT_Control_COS8] +-> -> Charge_Flag_COS8(0) +-> -> Zero_Balance_Control_COS8(1) + + +Register leaf node: Zero_Balance_Control_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) +-> -> Tariff_Resolution_COS8(1) +-> -> Account_Control_COS8(2) +-> -> MT_Control_COS8(3) +-> -> Validity_Solution_COS8(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.1) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) + + +Register leaf node: Clear_Balance_Option_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.2) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) + + +Register leaf node: Validity_Recharge_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.3) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) +-> -> Validity_Zero_Balance_COS8(2) + + +Register leaf node: Validity_Zero_Balance_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.4) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) +-> -> Validity_Zero_Balance_COS8(2) +-> -> Activated_Account_Validity_COS8(3) + + +Register leaf node: Activated_Account_Validity_COS8. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.5) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) +-> -> Validity_Zero_Balance_COS8(2) +-> -> Activated_Account_Validity_COS8(3) +-> -> FF_Number_COS8(4) + + +Register leaf node: FF_Number_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.6) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) +-> -> Validity_Zero_Balance_COS8(2) +-> -> Activated_Account_Validity_COS8(3) +-> -> FF_Number_COS8(4) +-> -> Support_Credit_Card_COS8(5) + + +Register leaf node: Support_Credit_Card_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.5.7) +-> father_name = [Validity_Solution_COS8] +-> -> Clear_Balance_Option_COS8(0) +-> -> Validity_Recharge_COS8(1) +-> -> Validity_Zero_Balance_COS8(2) +-> -> Activated_Account_Validity_COS8(3) +-> -> FF_Number_COS8(4) +-> -> Support_Credit_Card_COS8(5) +-> -> Credit_Vault_COS8(6) + + +Register leaf node: Credit_Vault_COS8. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.6) +-> father_name = [COS_8] +-> -> Recharge_Promotion_COS8(0) +-> -> Tariff_Resolution_COS8(1) +-> -> Account_Control_COS8(2) +-> -> MT_Control_COS8(3) +-> -> Validity_Solution_COS8(4) +-> -> SM_Inquiry_COS8(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.6.1) +-> father_name = [SM_Inquiry_COS8] +-> -> Feedback_SM_COS8(0) + + +Register leaf node: Feedback_SM_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.6.2) +-> father_name = [SM_Inquiry_COS8] +-> -> Feedback_SM_COS8(0) +-> -> Inquiry_SM_COS8(1) + + +Register leaf node: Inquiry_SM_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.6.3) +-> father_name = [SM_Inquiry_COS8] +-> -> Feedback_SM_COS8(0) +-> -> Inquiry_SM_COS8(1) +-> -> SM_Expiry_COS8(2) + + +Register leaf node: SM_Expiry_COS8. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS8(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.9.6.4) +-> father_name = [SM_Inquiry_COS8] +-> -> Feedback_SM_COS8(0) +-> -> Inquiry_SM_COS8(1) +-> -> SM_Expiry_COS8(2) +-> -> SM_Low_Balance_COS8(3) + + +Register leaf node: SM_Low_Balance_COS8. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) + + +Remark: COS 9 Parameters. + + +Create node: Recharge_Promotion_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.1) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.1.1) +-> father_name = [Recharge_Promotion_COS9] +-> -> Start_Date_COS9(0) + + +Register leaf node: Start_Date_COS9. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.1.2) +-> father_name = [Recharge_Promotion_COS9] +-> -> Start_Date_COS9(0) +-> -> End_Date_COS9(1) + + +Register leaf node: End_Date_COS9. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.1.3) +-> father_name = [Recharge_Promotion_COS9] +-> -> Start_Date_COS9(0) +-> -> End_Date_COS9(1) +-> -> Promotion_Bonus_COS9(2) + + +Register leaf node: Promotion_Bonus_COS9. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.2) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) +-> -> Tariff_Resolution_COS9(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.2.1) +-> father_name = [Tariff_Resolution_COS9] +-> -> MO_Tariff_ID_COS9(0) + + +Register leaf node: MO_Tariff_ID_COS9. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.2.2) +-> father_name = [Tariff_Resolution_COS9] +-> -> MO_Tariff_ID_COS9(0) +-> -> MT_Tariff_ID_COS9(1) + + +Register leaf node: MT_Tariff_ID_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.2.3) +-> father_name = [Tariff_Resolution_COS9] +-> -> MO_Tariff_ID_COS9(0) +-> -> MT_Tariff_ID_COS9(1) +-> -> Tariff_Subscription_COS9(2) + + +Register leaf node: Tariff_Subscription_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.2.4) +-> father_name = [Tariff_Resolution_COS9] +-> -> MO_Tariff_ID_COS9(0) +-> -> MT_Tariff_ID_COS9(1) +-> -> Tariff_Subscription_COS9(2) +-> -> Recharge_Card_Validity_COS9(3) + + +Register leaf node: Recharge_Card_Validity_COS9. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.3) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) +-> -> Tariff_Resolution_COS9(1) +-> -> Account_Control_COS9(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.3.1) +-> father_name = [Account_Control_COS9] +-> -> Min_balance_MO_COS9(0) + + +Register leaf node: Min_balance_MO_COS9. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.3.2) +-> father_name = [Account_Control_COS9] +-> -> Min_balance_MO_COS9(0) +-> -> Maximum_Validity_COS9(1) + + +Register leaf node: Maximum_Validity_COS9. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.3.3) +-> father_name = [Account_Control_COS9] +-> -> Min_balance_MO_COS9(0) +-> -> Maximum_Validity_COS9(1) +-> -> Release_Day_COS9(2) + + +Register leaf node: Release_Day_COS9. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.4) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) +-> -> Tariff_Resolution_COS9(1) +-> -> Account_Control_COS9(2) +-> -> MT_Control_COS9(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.4.1) +-> father_name = [MT_Control_COS9] +-> -> Charge_Flag_COS9(0) + + +Register leaf node: Charge_Flag_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.4.2) +-> father_name = [MT_Control_COS9] +-> -> Charge_Flag_COS9(0) +-> -> Zero_Balance_Control_COS9(1) + + +Register leaf node: Zero_Balance_Control_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) +-> -> Tariff_Resolution_COS9(1) +-> -> Account_Control_COS9(2) +-> -> MT_Control_COS9(3) +-> -> Validity_Solution_COS9(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.1) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) + + +Register leaf node: Clear_Balance_Option_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.2) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) + + +Register leaf node: Validity_Recharge_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.3) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) +-> -> Validity_Zero_Balance_COS9(2) + + +Register leaf node: Validity_Zero_Balance_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.4) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) +-> -> Validity_Zero_Balance_COS9(2) +-> -> Activated_Account_Validity_COS9(3) + + +Register leaf node: Activated_Account_Validity_COS9. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.5) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) +-> -> Validity_Zero_Balance_COS9(2) +-> -> Activated_Account_Validity_COS9(3) +-> -> FF_Number_COS9(4) + + +Register leaf node: FF_Number_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.6) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) +-> -> Validity_Zero_Balance_COS9(2) +-> -> Activated_Account_Validity_COS9(3) +-> -> FF_Number_COS9(4) +-> -> Support_Credit_Card_COS9(5) + + +Register leaf node: Support_Credit_Card_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.5.7) +-> father_name = [Validity_Solution_COS9] +-> -> Clear_Balance_Option_COS9(0) +-> -> Validity_Recharge_COS9(1) +-> -> Validity_Zero_Balance_COS9(2) +-> -> Activated_Account_Validity_COS9(3) +-> -> FF_Number_COS9(4) +-> -> Support_Credit_Card_COS9(5) +-> -> Credit_Vault_COS9(6) + + +Register leaf node: Credit_Vault_COS9. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.6) +-> father_name = [COS_9] +-> -> Recharge_Promotion_COS9(0) +-> -> Tariff_Resolution_COS9(1) +-> -> Account_Control_COS9(2) +-> -> MT_Control_COS9(3) +-> -> Validity_Solution_COS9(4) +-> -> SM_Inquiry_COS9(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.6.1) +-> father_name = [SM_Inquiry_COS9] +-> -> Feedback_SM_COS9(0) + + +Register leaf node: Feedback_SM_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.6.2) +-> father_name = [SM_Inquiry_COS9] +-> -> Feedback_SM_COS9(0) +-> -> Inquiry_SM_COS9(1) + + +Register leaf node: Inquiry_SM_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.6.3) +-> father_name = [SM_Inquiry_COS9] +-> -> Feedback_SM_COS9(0) +-> -> Inquiry_SM_COS9(1) +-> -> SM_Expiry_COS9(2) + + +Register leaf node: SM_Expiry_COS9. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS9(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.10.6.4) +-> father_name = [SM_Inquiry_COS9] +-> -> Feedback_SM_COS9(0) +-> -> Inquiry_SM_COS9(1) +-> -> SM_Expiry_COS9(2) +-> -> SM_Low_Balance_COS9(3) + + +Register leaf node: SM_Low_Balance_COS9. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) + + +Remark: COS 10 Parameters. + + +Create node: Recharge_Promotion_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.1) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.1.1) +-> father_name = [Recharge_Promotion_COS10] +-> -> Start_Date_COS10(0) + + +Register leaf node: Start_Date_COS10. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.1.2) +-> father_name = [Recharge_Promotion_COS10] +-> -> Start_Date_COS10(0) +-> -> End_Date_COS10(1) + + +Register leaf node: End_Date_COS10. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.1.3) +-> father_name = [Recharge_Promotion_COS10] +-> -> Start_Date_COS10(0) +-> -> End_Date_COS10(1) +-> -> Promotion_Bonus_COS10(2) + + +Register leaf node: Promotion_Bonus_COS10. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.2) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) +-> -> Tariff_Resolution_COS10(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.2.1) +-> father_name = [Tariff_Resolution_COS10] +-> -> MO_Tariff_ID_COS10(0) + + +Register leaf node: MO_Tariff_ID_COS10. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.2.2) +-> father_name = [Tariff_Resolution_COS10] +-> -> MO_Tariff_ID_COS10(0) +-> -> MT_Tariff_ID_COS10(1) + + +Register leaf node: MT_Tariff_ID_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.2.3) +-> father_name = [Tariff_Resolution_COS10] +-> -> MO_Tariff_ID_COS10(0) +-> -> MT_Tariff_ID_COS10(1) +-> -> Tariff_Subscription_COS10(2) + + +Register leaf node: Tariff_Subscription_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.2.4) +-> father_name = [Tariff_Resolution_COS10] +-> -> MO_Tariff_ID_COS10(0) +-> -> MT_Tariff_ID_COS10(1) +-> -> Tariff_Subscription_COS10(2) +-> -> Recharge_Card_Validity_COS10(3) + + +Register leaf node: Recharge_Card_Validity_COS10. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.3) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) +-> -> Tariff_Resolution_COS10(1) +-> -> Account_Control_COS10(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.3.1) +-> father_name = [Account_Control_COS10] +-> -> Min_balance_MO_COS10(0) + + +Register leaf node: Min_balance_MO_COS10. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.3.2) +-> father_name = [Account_Control_COS10] +-> -> Min_balance_MO_COS10(0) +-> -> Maximum_Validity_COS10(1) + + +Register leaf node: Maximum_Validity_COS10. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.3.3) +-> father_name = [Account_Control_COS10] +-> -> Min_balance_MO_COS10(0) +-> -> Maximum_Validity_COS10(1) +-> -> Release_Day_COS10(2) + + +Register leaf node: Release_Day_COS10. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.4) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) +-> -> Tariff_Resolution_COS10(1) +-> -> Account_Control_COS10(2) +-> -> MT_Control_COS10(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.4.1) +-> father_name = [MT_Control_COS10] +-> -> Charge_Flag_COS10(0) + + +Register leaf node: Charge_Flag_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.4.2) +-> father_name = [MT_Control_COS10] +-> -> Charge_Flag_COS10(0) +-> -> Zero_Balance_Control_COS10(1) + + +Register leaf node: Zero_Balance_Control_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) +-> -> Tariff_Resolution_COS10(1) +-> -> Account_Control_COS10(2) +-> -> MT_Control_COS10(3) +-> -> Validity_Solution_COS10(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.1) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) + + +Register leaf node: Clear_Balance_Option_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.2) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) + + +Register leaf node: Validity_Recharge_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.3) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) +-> -> Validity_Zero_Balance_COS10(2) + + +Register leaf node: Validity_Zero_Balance_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.4) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) +-> -> Validity_Zero_Balance_COS10(2) +-> -> Activated_Account_Validity_COS10(3) + + +Register leaf node: Activated_Account_Validity_COS10. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.5) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) +-> -> Validity_Zero_Balance_COS10(2) +-> -> Activated_Account_Validity_COS10(3) +-> -> FF_Number_COS10(4) + + +Register leaf node: FF_Number_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.6) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) +-> -> Validity_Zero_Balance_COS10(2) +-> -> Activated_Account_Validity_COS10(3) +-> -> FF_Number_COS10(4) +-> -> Support_Credit_Card_COS10(5) + + +Register leaf node: Support_Credit_Card_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.5.7) +-> father_name = [Validity_Solution_COS10] +-> -> Clear_Balance_Option_COS10(0) +-> -> Validity_Recharge_COS10(1) +-> -> Validity_Zero_Balance_COS10(2) +-> -> Activated_Account_Validity_COS10(3) +-> -> FF_Number_COS10(4) +-> -> Support_Credit_Card_COS10(5) +-> -> Credit_Vault_COS10(6) + + +Register leaf node: Credit_Vault_COS10. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.6) +-> father_name = [COS_10] +-> -> Recharge_Promotion_COS10(0) +-> -> Tariff_Resolution_COS10(1) +-> -> Account_Control_COS10(2) +-> -> MT_Control_COS10(3) +-> -> Validity_Solution_COS10(4) +-> -> SM_Inquiry_COS10(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.6.1) +-> father_name = [SM_Inquiry_COS10] +-> -> Feedback_SM_COS10(0) + + +Register leaf node: Feedback_SM_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.6.2) +-> father_name = [SM_Inquiry_COS10] +-> -> Feedback_SM_COS10(0) +-> -> Inquiry_SM_COS10(1) + + +Register leaf node: Inquiry_SM_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.6.3) +-> father_name = [SM_Inquiry_COS10] +-> -> Feedback_SM_COS10(0) +-> -> Inquiry_SM_COS10(1) +-> -> SM_Expiry_COS10(2) + + +Register leaf node: SM_Expiry_COS10. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS10(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.11.6.4) +-> father_name = [SM_Inquiry_COS10] +-> -> Feedback_SM_COS10(0) +-> -> Inquiry_SM_COS10(1) +-> -> SM_Expiry_COS10(2) +-> -> SM_Low_Balance_COS10(3) + + +Register leaf node: SM_Low_Balance_COS10. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) +-> -> COS_11(11) + + +Remark: COS 11 Parameters. + + +Create node: Recharge_Promotion_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.1) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.1.1) +-> father_name = [Recharge_Promotion_COS11] +-> -> Start_Date_COS11(0) + + +Register leaf node: Start_Date_COS11. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.1.2) +-> father_name = [Recharge_Promotion_COS11] +-> -> Start_Date_COS11(0) +-> -> End_Date_COS11(1) + + +Register leaf node: End_Date_COS11. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.1.3) +-> father_name = [Recharge_Promotion_COS11] +-> -> Start_Date_COS11(0) +-> -> End_Date_COS11(1) +-> -> Promotion_Bonus_COS11(2) + + +Register leaf node: Promotion_Bonus_COS11. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.2) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) +-> -> Tariff_Resolution_COS11(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.2.1) +-> father_name = [Tariff_Resolution_COS11] +-> -> MO_Tariff_ID_COS11(0) + + +Register leaf node: MO_Tariff_ID_COS11. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.2.2) +-> father_name = [Tariff_Resolution_COS11] +-> -> MO_Tariff_ID_COS11(0) +-> -> MT_Tariff_ID_COS11(1) + + +Register leaf node: MT_Tariff_ID_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.2.3) +-> father_name = [Tariff_Resolution_COS11] +-> -> MO_Tariff_ID_COS11(0) +-> -> MT_Tariff_ID_COS11(1) +-> -> Tariff_Subscription_COS11(2) + + +Register leaf node: Tariff_Subscription_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.2.4) +-> father_name = [Tariff_Resolution_COS11] +-> -> MO_Tariff_ID_COS11(0) +-> -> MT_Tariff_ID_COS11(1) +-> -> Tariff_Subscription_COS11(2) +-> -> Recharge_Card_Validity_COS11(3) + + +Register leaf node: Recharge_Card_Validity_COS11. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.3) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) +-> -> Tariff_Resolution_COS11(1) +-> -> Account_Control_COS11(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.3.1) +-> father_name = [Account_Control_COS11] +-> -> Min_balance_MO_COS11(0) + + +Register leaf node: Min_balance_MO_COS11. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.3.2) +-> father_name = [Account_Control_COS11] +-> -> Min_balance_MO_COS11(0) +-> -> Maximum_Validity_COS11(1) + + +Register leaf node: Maximum_Validity_COS11. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.3.3) +-> father_name = [Account_Control_COS11] +-> -> Min_balance_MO_COS11(0) +-> -> Maximum_Validity_COS11(1) +-> -> Release_Day_COS11(2) + + +Register leaf node: Release_Day_COS11. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.4) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) +-> -> Tariff_Resolution_COS11(1) +-> -> Account_Control_COS11(2) +-> -> MT_Control_COS11(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.4.1) +-> father_name = [MT_Control_COS11] +-> -> Charge_Flag_COS11(0) + + +Register leaf node: Charge_Flag_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.4.2) +-> father_name = [MT_Control_COS11] +-> -> Charge_Flag_COS11(0) +-> -> Zero_Balance_Control_COS11(1) + + +Register leaf node: Zero_Balance_Control_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) +-> -> Tariff_Resolution_COS11(1) +-> -> Account_Control_COS11(2) +-> -> MT_Control_COS11(3) +-> -> Validity_Solution_COS11(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.1) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) + + +Register leaf node: Clear_Balance_Option_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.2) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) + + +Register leaf node: Validity_Recharge_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.3) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) +-> -> Validity_Zero_Balance_COS11(2) + + +Register leaf node: Validity_Zero_Balance_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.4) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) +-> -> Validity_Zero_Balance_COS11(2) +-> -> Activated_Account_Validity_COS11(3) + + +Register leaf node: Activated_Account_Validity_COS11. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.5) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) +-> -> Validity_Zero_Balance_COS11(2) +-> -> Activated_Account_Validity_COS11(3) +-> -> FF_Number_COS11(4) + + +Register leaf node: FF_Number_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.6) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) +-> -> Validity_Zero_Balance_COS11(2) +-> -> Activated_Account_Validity_COS11(3) +-> -> FF_Number_COS11(4) +-> -> Support_Credit_Card_COS11(5) + + +Register leaf node: Support_Credit_Card_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.5.7) +-> father_name = [Validity_Solution_COS11] +-> -> Clear_Balance_Option_COS11(0) +-> -> Validity_Recharge_COS11(1) +-> -> Validity_Zero_Balance_COS11(2) +-> -> Activated_Account_Validity_COS11(3) +-> -> FF_Number_COS11(4) +-> -> Support_Credit_Card_COS11(5) +-> -> Credit_Vault_COS11(6) + + +Register leaf node: Credit_Vault_COS11. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.6) +-> father_name = [COS_11] +-> -> Recharge_Promotion_COS11(0) +-> -> Tariff_Resolution_COS11(1) +-> -> Account_Control_COS11(2) +-> -> MT_Control_COS11(3) +-> -> Validity_Solution_COS11(4) +-> -> SM_Inquiry_COS11(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.6.1) +-> father_name = [SM_Inquiry_COS11] +-> -> Feedback_SM_COS11(0) + + +Register leaf node: Feedback_SM_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.6.2) +-> father_name = [SM_Inquiry_COS11] +-> -> Feedback_SM_COS11(0) +-> -> Inquiry_SM_COS11(1) + + +Register leaf node: Inquiry_SM_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.6.3) +-> father_name = [SM_Inquiry_COS11] +-> -> Feedback_SM_COS11(0) +-> -> Inquiry_SM_COS11(1) +-> -> SM_Expiry_COS11(2) + + +Register leaf node: SM_Expiry_COS11. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS11(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.12.6.4) +-> father_name = [SM_Inquiry_COS11] +-> -> Feedback_SM_COS11(0) +-> -> Inquiry_SM_COS11(1) +-> -> SM_Expiry_COS11(2) +-> -> SM_Low_Balance_COS11(3) + + +Register leaf node: SM_Low_Balance_COS11. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) +-> -> COS_11(11) +-> -> COS_12(12) + + +Remark: COS 12 Parameters. + + +Create node: Recharge_Promotion_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.1) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.1.1) +-> father_name = [Recharge_Promotion_COS12] +-> -> Start_Date_COS12(0) + + +Register leaf node: Start_Date_COS12. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.1.2) +-> father_name = [Recharge_Promotion_COS12] +-> -> Start_Date_COS12(0) +-> -> End_Date_COS12(1) + + +Register leaf node: End_Date_COS12. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.1.3) +-> father_name = [Recharge_Promotion_COS12] +-> -> Start_Date_COS12(0) +-> -> End_Date_COS12(1) +-> -> Promotion_Bonus_COS12(2) + + +Register leaf node: Promotion_Bonus_COS12. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.2) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) +-> -> Tariff_Resolution_COS12(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.2.1) +-> father_name = [Tariff_Resolution_COS12] +-> -> MO_Tariff_ID_COS12(0) + + +Register leaf node: MO_Tariff_ID_COS12. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.2.2) +-> father_name = [Tariff_Resolution_COS12] +-> -> MO_Tariff_ID_COS12(0) +-> -> MT_Tariff_ID_COS12(1) + + +Register leaf node: MT_Tariff_ID_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.2.3) +-> father_name = [Tariff_Resolution_COS12] +-> -> MO_Tariff_ID_COS12(0) +-> -> MT_Tariff_ID_COS12(1) +-> -> Tariff_Subscription_COS12(2) + + +Register leaf node: Tariff_Subscription_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.2.4) +-> father_name = [Tariff_Resolution_COS12] +-> -> MO_Tariff_ID_COS12(0) +-> -> MT_Tariff_ID_COS12(1) +-> -> Tariff_Subscription_COS12(2) +-> -> Recharge_Card_Validity_COS12(3) + + +Register leaf node: Recharge_Card_Validity_COS12. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.3) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) +-> -> Tariff_Resolution_COS12(1) +-> -> Account_Control_COS12(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.3.1) +-> father_name = [Account_Control_COS12] +-> -> Min_balance_MO_COS12(0) + + +Register leaf node: Min_balance_MO_COS12. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.3.2) +-> father_name = [Account_Control_COS12] +-> -> Min_balance_MO_COS12(0) +-> -> Maximum_Validity_COS12(1) + + +Register leaf node: Maximum_Validity_COS12. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.3.3) +-> father_name = [Account_Control_COS12] +-> -> Min_balance_MO_COS12(0) +-> -> Maximum_Validity_COS12(1) +-> -> Release_Day_COS12(2) + + +Register leaf node: Release_Day_COS12. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.4) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) +-> -> Tariff_Resolution_COS12(1) +-> -> Account_Control_COS12(2) +-> -> MT_Control_COS12(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.4.1) +-> father_name = [MT_Control_COS12] +-> -> Charge_Flag_COS12(0) + + +Register leaf node: Charge_Flag_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.4.2) +-> father_name = [MT_Control_COS12] +-> -> Charge_Flag_COS12(0) +-> -> Zero_Balance_Control_COS12(1) + + +Register leaf node: Zero_Balance_Control_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) +-> -> Tariff_Resolution_COS12(1) +-> -> Account_Control_COS12(2) +-> -> MT_Control_COS12(3) +-> -> Validity_Solution_COS12(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.1) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) + + +Register leaf node: Clear_Balance_Option_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.2) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) + + +Register leaf node: Validity_Recharge_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.3) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) +-> -> Validity_Zero_Balance_COS12(2) + + +Register leaf node: Validity_Zero_Balance_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.4) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) +-> -> Validity_Zero_Balance_COS12(2) +-> -> Activated_Account_Validity_COS12(3) + + +Register leaf node: Activated_Account_Validity_COS12. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.5) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) +-> -> Validity_Zero_Balance_COS12(2) +-> -> Activated_Account_Validity_COS12(3) +-> -> FF_Number_COS12(4) + + +Register leaf node: FF_Number_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.6) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) +-> -> Validity_Zero_Balance_COS12(2) +-> -> Activated_Account_Validity_COS12(3) +-> -> FF_Number_COS12(4) +-> -> Support_Credit_Card_COS12(5) + + +Register leaf node: Support_Credit_Card_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.5.7) +-> father_name = [Validity_Solution_COS12] +-> -> Clear_Balance_Option_COS12(0) +-> -> Validity_Recharge_COS12(1) +-> -> Validity_Zero_Balance_COS12(2) +-> -> Activated_Account_Validity_COS12(3) +-> -> FF_Number_COS12(4) +-> -> Support_Credit_Card_COS12(5) +-> -> Credit_Vault_COS12(6) + + +Register leaf node: Credit_Vault_COS12. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.6) +-> father_name = [COS_12] +-> -> Recharge_Promotion_COS12(0) +-> -> Tariff_Resolution_COS12(1) +-> -> Account_Control_COS12(2) +-> -> MT_Control_COS12(3) +-> -> Validity_Solution_COS12(4) +-> -> SM_Inquiry_COS12(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.6.1) +-> father_name = [SM_Inquiry_COS12] +-> -> Feedback_SM_COS12(0) + + +Register leaf node: Feedback_SM_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.6.2) +-> father_name = [SM_Inquiry_COS12] +-> -> Feedback_SM_COS12(0) +-> -> Inquiry_SM_COS12(1) + + +Register leaf node: Inquiry_SM_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.6.3) +-> father_name = [SM_Inquiry_COS12] +-> -> Feedback_SM_COS12(0) +-> -> Inquiry_SM_COS12(1) +-> -> SM_Expiry_COS12(2) + + +Register leaf node: SM_Expiry_COS12. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS12(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.13.6.4) +-> father_name = [SM_Inquiry_COS12] +-> -> Feedback_SM_COS12(0) +-> -> Inquiry_SM_COS12(1) +-> -> SM_Expiry_COS12(2) +-> -> SM_Low_Balance_COS12(3) + + +Register leaf node: SM_Low_Balance_COS12. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) +-> -> COS_11(11) +-> -> COS_12(12) +-> -> COS_13(13) + + +Remark: COS 13 Parameters. + + +Create node: Recharge_Promotion_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.1) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.1.1) +-> father_name = [Recharge_Promotion_COS13] +-> -> Start_Date_COS13(0) + + +Register leaf node: Start_Date_COS13. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.1.2) +-> father_name = [Recharge_Promotion_COS13] +-> -> Start_Date_COS13(0) +-> -> End_Date_COS13(1) + + +Register leaf node: End_Date_COS13. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.1.3) +-> father_name = [Recharge_Promotion_COS13] +-> -> Start_Date_COS13(0) +-> -> End_Date_COS13(1) +-> -> Promotion_Bonus_COS13(2) + + +Register leaf node: Promotion_Bonus_COS13. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.2) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) +-> -> Tariff_Resolution_COS13(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS0(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.2.1) +-> father_name = [Tariff_Resolution_COS13] +-> -> MO_Tariff_ID_COS0(0) + + +Register leaf node: MO_Tariff_ID_COS0. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.2.2) +-> father_name = [Tariff_Resolution_COS13] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS13(1) + + +Register leaf node: MT_Tariff_ID_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.2.3) +-> father_name = [Tariff_Resolution_COS13] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS13(1) +-> -> Tariff_Subscription_COS13(2) + + +Register leaf node: Tariff_Subscription_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.2.4) +-> father_name = [Tariff_Resolution_COS13] +-> -> MO_Tariff_ID_COS0(0) +-> -> MT_Tariff_ID_COS13(1) +-> -> Tariff_Subscription_COS13(2) +-> -> Recharge_Card_Validity_COS13(3) + + +Register leaf node: Recharge_Card_Validity_COS13. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.3) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) +-> -> Tariff_Resolution_COS13(1) +-> -> Account_Control_COS13(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.3.1) +-> father_name = [Account_Control_COS13] +-> -> Min_balance_MO_COS13(0) + + +Register leaf node: Min_balance_MO_COS13. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.3.2) +-> father_name = [Account_Control_COS13] +-> -> Min_balance_MO_COS13(0) +-> -> Maximum_Validity_COS13(1) + + +Register leaf node: Maximum_Validity_COS13. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.3.3) +-> father_name = [Account_Control_COS13] +-> -> Min_balance_MO_COS13(0) +-> -> Maximum_Validity_COS13(1) +-> -> Release_Day_COS13(2) + + +Register leaf node: Release_Day_COS13. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.4) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) +-> -> Tariff_Resolution_COS13(1) +-> -> Account_Control_COS13(2) +-> -> MT_Control_COS13(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.4.1) +-> father_name = [MT_Control_COS13] +-> -> Charge_Flag_COS13(0) + + +Register leaf node: Charge_Flag_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.4.2) +-> father_name = [MT_Control_COS13] +-> -> Charge_Flag_COS13(0) +-> -> Zero_Balance_Control_COS13(1) + + +Register leaf node: Zero_Balance_Control_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) +-> -> Tariff_Resolution_COS13(1) +-> -> Account_Control_COS13(2) +-> -> MT_Control_COS13(3) +-> -> Validity_Solution_COS13(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.1) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) + + +Register leaf node: Clear_Balance_Option_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.2) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) + + +Register leaf node: Validity_Recharge_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.3) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) +-> -> Validity_Zero_Balance_COS13(2) + + +Register leaf node: Validity_Zero_Balance_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.4) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) +-> -> Validity_Zero_Balance_COS13(2) +-> -> Activated_Account_Validity_COS13(3) + + +Register leaf node: Activated_Account_Validity_COS13. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.5) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) +-> -> Validity_Zero_Balance_COS13(2) +-> -> Activated_Account_Validity_COS13(3) +-> -> FF_Number_COS13(4) + + +Register leaf node: FF_Number_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.6) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) +-> -> Validity_Zero_Balance_COS13(2) +-> -> Activated_Account_Validity_COS13(3) +-> -> FF_Number_COS13(4) +-> -> Support_Credit_Card_COS13(5) + + +Register leaf node: Support_Credit_Card_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.5.7) +-> father_name = [Validity_Solution_COS13] +-> -> Clear_Balance_Option_COS13(0) +-> -> Validity_Recharge_COS13(1) +-> -> Validity_Zero_Balance_COS13(2) +-> -> Activated_Account_Validity_COS13(3) +-> -> FF_Number_COS13(4) +-> -> Support_Credit_Card_COS13(5) +-> -> Credit_Vault_COS13(6) + + +Register leaf node: Credit_Vault_COS13. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.6) +-> father_name = [COS_13] +-> -> Recharge_Promotion_COS13(0) +-> -> Tariff_Resolution_COS13(1) +-> -> Account_Control_COS13(2) +-> -> MT_Control_COS13(3) +-> -> Validity_Solution_COS13(4) +-> -> SM_Inquiry_COS13(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.6.1) +-> father_name = [SM_Inquiry_COS13] +-> -> Feedback_SM_COS13(0) + + +Register leaf node: Feedback_SM_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.6.2) +-> father_name = [SM_Inquiry_COS13] +-> -> Feedback_SM_COS13(0) +-> -> Inquiry_SM_COS13(1) + + +Register leaf node: Inquiry_SM_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.6.3) +-> father_name = [SM_Inquiry_COS13] +-> -> Feedback_SM_COS13(0) +-> -> Inquiry_SM_COS13(1) +-> -> SM_Expiry_COS13(2) + + +Register leaf node: SM_Expiry_COS13. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS13(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.14.6.4) +-> father_name = [SM_Inquiry_COS13] +-> -> Feedback_SM_COS13(0) +-> -> Inquiry_SM_COS13(1) +-> -> SM_Expiry_COS13(2) +-> -> SM_Low_Balance_COS13(3) + + +Register leaf node: SM_Low_Balance_COS13. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) +-> -> COS_11(11) +-> -> COS_12(12) +-> -> COS_13(13) +-> -> COS_14(14) + + +Remark: COS 14 Parameters. + + +Create node: Recharge_Promotion_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.1) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.1.1) +-> father_name = [Recharge_Promotion_COS14] +-> -> Start_Date_COS14(0) + + +Register leaf node: Start_Date_COS14. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.1.2) +-> father_name = [Recharge_Promotion_COS14] +-> -> Start_Date_COS14(0) +-> -> End_Date_COS14(1) + + +Register leaf node: End_Date_COS14. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.1.3) +-> father_name = [Recharge_Promotion_COS14] +-> -> Start_Date_COS14(0) +-> -> End_Date_COS14(1) +-> -> Promotion_Bonus_COS14(2) + + +Register leaf node: Promotion_Bonus_COS14. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.2) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) +-> -> Tariff_Resolution_COS14(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.2.1) +-> father_name = [Tariff_Resolution_COS14] +-> -> MO_Tariff_ID_COS14(0) + + +Register leaf node: MO_Tariff_ID_COS14. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.2.2) +-> father_name = [Tariff_Resolution_COS14] +-> -> MO_Tariff_ID_COS14(0) +-> -> MT_Tariff_ID_COS14(1) + + +Register leaf node: MT_Tariff_ID_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.2.3) +-> father_name = [Tariff_Resolution_COS14] +-> -> MO_Tariff_ID_COS14(0) +-> -> MT_Tariff_ID_COS14(1) +-> -> Tariff_Subscription_COS14(2) + + +Register leaf node: Tariff_Subscription_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.2.4) +-> father_name = [Tariff_Resolution_COS14] +-> -> MO_Tariff_ID_COS14(0) +-> -> MT_Tariff_ID_COS14(1) +-> -> Tariff_Subscription_COS14(2) +-> -> Recharge_Card_Validity_COS14(3) + + +Register leaf node: Recharge_Card_Validity_COS14. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.3) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) +-> -> Tariff_Resolution_COS14(1) +-> -> Account_Control_COS14(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.3.1) +-> father_name = [Account_Control_COS14] +-> -> Min_balance_MO_COS14(0) + + +Register leaf node: Min_balance_MO_COS14. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.3.2) +-> father_name = [Account_Control_COS14] +-> -> Min_balance_MO_COS14(0) +-> -> Maximum_Validity_COS14(1) + + +Register leaf node: Maximum_Validity_COS14. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.3.3) +-> father_name = [Account_Control_COS14] +-> -> Min_balance_MO_COS14(0) +-> -> Maximum_Validity_COS14(1) +-> -> Release_Day_COS14(2) + + +Register leaf node: Release_Day_COS14. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.4) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) +-> -> Tariff_Resolution_COS14(1) +-> -> Account_Control_COS14(2) +-> -> MT_Control_COS14(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.4.1) +-> father_name = [MT_Control_COS14] +-> -> Charge_Flag_COS14(0) + + +Register leaf node: Charge_Flag_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.4.2) +-> father_name = [MT_Control_COS14] +-> -> Charge_Flag_COS14(0) +-> -> Zero_Balance_Control_COS14(1) + + +Register leaf node: Zero_Balance_Control_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) +-> -> Tariff_Resolution_COS14(1) +-> -> Account_Control_COS14(2) +-> -> MT_Control_COS14(3) +-> -> Validity_Solution_COS14(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.1) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) + + +Register leaf node: Clear_Balance_Option_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.2) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) + + +Register leaf node: Validity_Recharge_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.3) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) +-> -> Validity_Zero_Balance_COS14(2) + + +Register leaf node: Validity_Zero_Balance_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.4) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) +-> -> Validity_Zero_Balance_COS14(2) +-> -> Activated_Account_Validity_COS14(3) + + +Register leaf node: Activated_Account_Validity_COS14. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.5) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) +-> -> Validity_Zero_Balance_COS14(2) +-> -> Activated_Account_Validity_COS14(3) +-> -> FF_Number_COS14(4) + + +Register leaf node: FF_Number_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.6) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) +-> -> Validity_Zero_Balance_COS14(2) +-> -> Activated_Account_Validity_COS14(3) +-> -> FF_Number_COS14(4) +-> -> Support_Credit_Card_COS14(5) + + +Register leaf node: Support_Credit_Card_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.5.7) +-> father_name = [Validity_Solution_COS14] +-> -> Clear_Balance_Option_COS14(0) +-> -> Validity_Recharge_COS14(1) +-> -> Validity_Zero_Balance_COS14(2) +-> -> Activated_Account_Validity_COS14(3) +-> -> FF_Number_COS14(4) +-> -> Support_Credit_Card_COS14(5) +-> -> Credit_Vault_COS14(6) + + +Register leaf node: Credit_Vault_COS14. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.6) +-> father_name = [COS_14] +-> -> Recharge_Promotion_COS14(0) +-> -> Tariff_Resolution_COS14(1) +-> -> Account_Control_COS14(2) +-> -> MT_Control_COS14(3) +-> -> Validity_Solution_COS14(4) +-> -> SM_Inquiry_COS14(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.6.1) +-> father_name = [SM_Inquiry_COS14] +-> -> Feedback_SM_COS14(0) + + +Register leaf node: Feedback_SM_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.6.2) +-> father_name = [SM_Inquiry_COS14] +-> -> Feedback_SM_COS14(0) +-> -> Inquiry_SM_COS14(1) + + +Register leaf node: Inquiry_SM_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.6.3) +-> father_name = [SM_Inquiry_COS14] +-> -> Feedback_SM_COS14(0) +-> -> Inquiry_SM_COS14(1) +-> -> SM_Expiry_COS14(2) + + +Register leaf node: SM_Expiry_COS14. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS14(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.15.6.4) +-> father_name = [SM_Inquiry_COS14] +-> -> Feedback_SM_COS14(0) +-> -> Inquiry_SM_COS14(1) +-> -> SM_Expiry_COS14(2) +-> -> SM_Low_Balance_COS14(3) + + +Register leaf node: SM_Low_Balance_COS14. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: COS_15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16) +-> father_name = [COS_Param] +-> -> COS_0(0) +-> -> COS_1(1) +-> -> COS_2(2) +-> -> COS_3(3) +-> -> COS_4(4) +-> -> COS_5(5) +-> -> COS_6(6) +-> -> COS_7(7) +-> -> COS_8(8) +-> -> COS_9(9) +-> -> COS_10(10) +-> -> COS_11(11) +-> -> COS_12(12) +-> -> COS_13(13) +-> -> COS_14(14) +-> -> COS_15(15) + + +Remark: COS 15 Parameters. + + +Create node: Recharge_Promotion_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.1) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) + + +Remark: Recharge Promotion. + + +Create node: Start_Date_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.1.1) +-> father_name = [Recharge_Promotion_COS15] +-> -> Start_Date_COS15(0) + + +Register leaf node: Start_Date_COS15. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is +valid. Operator defines the promotion period by specifying the start and end +date. Each COS may have its own promotion period. Subscriber recharges his +account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: End_Date_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.1.2) +-> father_name = [Recharge_Promotion_COS15] +-> -> Start_Date_COS15(0) +-> -> End_Date_COS15(1) + + +Register leaf node: End_Date_COS15. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : The promotion period is the period of time in which the recharge promotion is valid. Operator +defines the promotion period by specifying the start and end date. Each COS may have its own promotion period. +Subscriber recharges his account within the promotion period of his COS will receive a promotion bonus. +To turn off the recharge promotion, set the start and end date as 000000. + +Field : total(3) +Access : read-write[1]Year: 20 + { + [u]0.0-0.7 + [u]input + [v]KeepHex high 0 + } +[2]Month + { + [u]1.0-1.7 + [u]input + [v]KeepHex high 0 + } +[3]Day + { + [u]2.0-2.7 + [u]input + [v]KeepHex high 0 + } + + +Create node: Promotion_Bonus_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.1.3) +-> father_name = [Recharge_Promotion_COS15] +-> -> Start_Date_COS15(0) +-> -> End_Date_COS15(1) +-> -> Promotion_Bonus_COS15(2) + + +Register leaf node: Promotion_Bonus_COS15. +Instance: 4 +Length : 9 +Flag : 255 +Default : +Remark : Promotion bonus is the extra credit that a subscriber will get when he recharges his account +in the promotion period. The amount of the bonus is determined by the recharge card credit. +Operator may set the bonus for four types of recharge card of each COS. Generally the recharge +card with higher credit is awarded more bonus. +Please note that the promotion bonus is only applicable for paying call charging. It can't be +used to pay the rental fee. (e.g. monthly rental). In addition, the bonus will always be +deducted prior to the recharge card credit. +Promotion bonus validity is the period of time that the bonus is valid. Bonus over the +validity period will be obsolete and deleted from account balance. That means the subscriber +must consume his entire promotion bonus within the time frame set by the operator. The operator +has the total freedom to design the validity period - shorter, same or longer than the validity +period of the recharge credit. + +Field : total(3) +Access : read-write[1]Recharge card credit + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } +[2]Promotion bonus + { + [u]4.0-7.7 + [u]input + [v]toDec high 0 + } +[3]Bonus validity + { + [u]8.0-8.7 + [u]input + [v]toDec high 0 + } + + +Create node: Tariff_Resolution_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.2) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) +-> -> Tariff_Resolution_COS15(1) + + +Remark: Tariff Resolution. + + +Create node: MO_Tariff_ID_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.2.1) +-> father_name = [Tariff_Resolution_COS15] +-> -> MO_Tariff_ID_COS15(0) + + +Register leaf node: MO_Tariff_ID_COS15. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk +to PPS memory after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(1) +Access : read-write [1]New tariff flag + { + [u]0.0-0.7 + [u]select + [v]1[opt]Set + } + + +Create node: MT_Tariff_ID_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.2.2) +-> father_name = [Tariff_Resolution_COS15] +-> -> MO_Tariff_ID_COS15(0) +-> -> MT_Tariff_ID_COS15(1) + + +Register leaf node: MT_Tariff_ID_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Select a MT tariff for this COS. The COS ID is included in subscriber profile +for MT call charge. Total 16 MT tariffs available. + +Field : total(1) +Access : read-write [1]MT tariff ID + { + [u]0.0-0.7 + [u]select + [v]0[opt]00 + [v]1[opt]01 + [v]2[opt]02 + [v]3[opt]03 + [v]4[opt]04 + [v]5[opt]05 + [v]6[opt]06 + [v]7[opt]07 + [v]8[opt]08 + [v]9[opt]09 + [v]10[opt]10 + [v]11[opt]11 + [v]12[opt]12 + [v]13[opt]13 + [v]14[opt]14 + [v]15[opt]15 + } + + +Create node: Tariff_Subscription_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.2.3) +-> father_name = [Tariff_Resolution_COS15] +-> -> MO_Tariff_ID_COS15(0) +-> -> MT_Tariff_ID_COS15(1) +-> -> Tariff_Subscription_COS15(2) + + +Register leaf node: Tariff_Subscription_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS basic tariff may be applied on either area (parameter Basic tariff zone) +or subscriber (Tariff ID in subscriber profile) basis. This parameter defines +which one is preference when debiting a subscriber. + +Field : total(1) +Access : read-write [1]Charge by + { + [u]0.0-0.7 + [u]select + [v]0[opt]Tariff set in subscriber profile + [v]1[opt]Parameter 'Basic tariff zone' + } + + +Create node: Recharge_Card_Validity_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.2.4) +-> father_name = [Tariff_Resolution_COS15] +-> -> MO_Tariff_ID_COS15(0) +-> -> MT_Tariff_ID_COS15(1) +-> -> Tariff_Subscription_COS15(2) +-> -> Recharge_Card_Validity_COS15(3) + + +Register leaf node: Recharge_Card_Validity_COS15. +Instance: 4 +Length : 6 +Flag : 255 +Default : +Remark : Read only. This flag is used to upload the new tariff stored in PPS harddisk to PPS memory +after submitting the new tariff to the PPS harddisk +consequently enable the new tariff startup. + +Field : total(3) +Access : read-write[1]Face value + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } +[2]MO validity + { + [u]2.0-3.7 + [u]input + [v]toDec high 0 + } +[3]MT validity + { + [u]4.0-5.7 + [u]input + [v]toDec high 0 + } + + +Create node: Account_Control_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.3) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) +-> -> Tariff_Resolution_COS15(1) +-> -> Account_Control_COS15(2) + + +Remark: Account control . + + +Create node: Min_balance_MO_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.3.1) +-> father_name = [Account_Control_COS15] +-> -> Min_balance_MO_COS15(0) + + +Register leaf node: Min_balance_MO_COS15. +Instance: 1 +Length : 2 +Flag : 255 +Default : +Remark : Set a minimum balance for MO call. The subscriber whose balance is below this +threshold can't make MO call. The unit of the minimum balance is the smallest +unit of currency. + +Field : total(2) +Access : read-write [1]Set threshold for MO call + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not set + [v]1[opt]Set + } +[2]Minimum balance for MO call + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Maximum_Validity_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.3.2) +-> father_name = [Account_Control_COS15] +-> -> Min_balance_MO_COS15(0) +-> -> Maximum_Validity_COS15(1) + + +Register leaf node: Maximum_Validity_COS15. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Specify the legal maximum balance, unit is the minimum currency unit. This +value is for overflow prevention. Normally operator doesn't need to change +this value. e.g. 5000, and the smallest unit is cent then the maximum allowed +balance is 5000 cents. + +Field : total(1) +Access : read-write[1]Maximum account balance + { + [u]0.0-3.7 + [u]input + [v]toDec high 0 + } + + +Create node: Release_Day_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.3.3) +-> father_name = [Account_Control_COS15] +-> -> Min_balance_MO_COS15(0) +-> -> Maximum_Validity_COS15(1) +-> -> Release_Day_COS15(2) + + +Register leaf node: Release_Day_COS15. +Instance: 1 +Length : 2 +Flag : 255 +Default :  +Remark : Number of days to hold an expiried prepaid account. After these release days, +if the expired prepaid user does't recharge his account, his account will be released. After +released, the MSISDN of the released account can be reuse by other subscribers. Dedault=30. + +Field : total(1) +Access : read-write[1]Release day + { + [u]0.0-1.7 + [u]input + [v]toDec high 0 + } + + +Create node: MT_Control_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.4) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) +-> -> Tariff_Resolution_COS15(1) +-> -> Account_Control_COS15(2) +-> -> MT_Control_COS15(3) + + +Remark: MT control . + + +Create node: Charge_Flag_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.4.1) +-> father_name = [MT_Control_COS15] +-> -> Charge_Flag_COS15(0) + + +Register leaf node: Charge_Flag_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable MT call charge for prepaid subscriber. + +Field : total(1) +Access : read-write [1]MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not charged + [v]1[opt]Charged + } + + +Create node: Zero_Balance_Control_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.4.2) +-> father_name = [MT_Control_COS15] +-> -> Charge_Flag_COS15(0) +-> -> Zero_Balance_Control_COS15(1) + + +Register leaf node: Zero_Balance_Control_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Enable or disable (MT) incoming calls when balance reaches zero. + +Field : total(1) +Access : read-write [1]Zero balance MT call + { + [u]0.0-0.7 + [u]select + [v]0[opt]Not allowed + [v]1[opt]Allowed + } + + +Create node: Validity_Solution_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) +-> -> Tariff_Resolution_COS15(1) +-> -> Account_Control_COS15(2) +-> -> MT_Control_COS15(3) +-> -> Validity_Solution_COS15(4) + + +Remark: Validity solution . + + +Create node: Clear_Balance_Option_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.1) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) + + +Register leaf node: Clear_Balance_Option_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set if clear off balance when an account expires or released. +If the balance is cleared] the balance will not be reused anyway. + +Field : total(3) +Access : read-write [1]When account expires + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + [2]When account is released + { + [u]0.0-0.0 + [u]select + [v]0[opt]Not clear balance + [v]1[opt]Clear balance + } + + +Create node: Validity_Recharge_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.2) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) + + +Register leaf node: Validity_Recharge_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set account validity increasement mode after a successful recharge. Accumulate: +the validity of the recharged money will be accumulated to the recharged account. +Replace: if the validity of the recharged money is more than the current account +validity, the account validity will be replaced by the validity of recharged money, +if the validity of the recharged money is less than the current account validity] the +account validity will not be changed after a successful recharge. + +Field : total(1) +Access : read-write [1]Validity after recharge + { + [u]0.0-0.7 + [u]select + [v]0[opt]Accumulate + [v]1[opt]Replace + } + + +Create node: Validity_Zero_Balance_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.3) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) +-> -> Validity_Zero_Balance_COS15(2) + + +Register leaf node: Validity_Zero_Balance_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable account validity ajustment when balance reaches zero,and if enabled, preset the +validity ajustment days. Disable=not change validity when balance reaches zero. Enable=change validity +to a preset period (see below) when balance reaches zero. Days: preset a validity ajustment period for +a zero balance account. If a zero balance account's current validity is less than the preset adjustment +validity] the system will keep this account's current validity. e.g. If this function is enabled] +and validity ajustment is set as 30 days] when a subscriber with 40 days' validity reaches zero balance] +his validity will be changed to 30 days. He will can receive incoming call for 30 days given the parameter +Zero balance MT call is enabled. Defaut=not change] validity adjustment disable. + +Field : total(2) +Access : read-write [1]Validity on zero balance + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not change + [v]1[opt]Change + } +[2]Days + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: Activated_Account_Validity_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.4) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) +-> -> Validity_Zero_Balance_COS15(2) +-> -> Activated_Account_Validity_COS15(3) + + +Register leaf node: Activated_Account_Validity_COS15. +Instance: 1 +Length : 3 +Flag : 255 +Default : +Remark : Set validity for an account who is activated from fresh status by dialing inquiry +number. The unit is day. Defaul=30 days. + +Field : total(2) +Access : read-write [1]Activation by inquiring + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Validity of activated account with zero balance + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: FF_Number_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.5) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) +-> -> Validity_Zero_Balance_COS15(2) +-> -> Activated_Account_Validity_COS15(3) +-> -> FF_Number_COS15(4) + + +Register leaf node: FF_Number_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge for changing family number. Free times of changing: set total times +of free change for family number if charge is enabled. Maximum is 15 + +Field : total(5) +Access : read-write [1]CUG serivce flag + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]F & F service flag + { + [u]0.6-0.6 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [3]Edition F & F list charge flag + { + [u]0.5-0.5 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[5]Free times of changing + { + [u]0.0-0.3 + [u]input + [v]toDec high 0 + } + + +Create node: Support_Credit_Card_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.6) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) +-> -> Validity_Zero_Balance_COS15(2) +-> -> Activated_Account_Validity_COS15(3) +-> -> FF_Number_COS15(4) +-> -> Support_Credit_Card_COS15(5) + + +Register leaf node: Support_Credit_Card_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Support_Credit_Card_COS + +Field : total(1) +Access : read-write [1]Support credit card flag + { + [u]0.0-0.7 + [u]select + [v]0[opt]Support + [v]1[opt]Not support + } + + +Create node: Credit_Vault_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.5.7) +-> father_name = [Validity_Solution_COS15] +-> -> Clear_Balance_Option_COS15(0) +-> -> Validity_Recharge_COS15(1) +-> -> Validity_Zero_Balance_COS15(2) +-> -> Activated_Account_Validity_COS15(3) +-> -> FF_Number_COS15(4) +-> -> Support_Credit_Card_COS15(5) +-> -> Credit_Vault_COS15(6) + + +Register leaf node: Credit_Vault_COS15. +Instance: 1 +Length : 2 +Flag : 255 +Default : d +Remark : When a subscriber is rejected to make a call because of the insufficient balance, he may select +to set the credit vault to get a preset amount of overdraft to make call. The amount of the overdraft +(credit vault) is set by network operator. The system will deduct this overdraft by debiting his account balance at the next recharge. + +Field : total(2) +Access : read-write [1]Support credit vault + { + [u]1.7-1.7 + [u]select + [v]0[opt]Not support + [v]1[opt]Support + } +[2]Credit vault + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Inquiry_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.6) +-> father_name = [COS_15] +-> -> Recharge_Promotion_COS15(0) +-> -> Tariff_Resolution_COS15(1) +-> -> Account_Control_COS15(2) +-> -> MT_Control_COS15(3) +-> -> Validity_Solution_COS15(4) +-> -> SM_Inquiry_COS15(5) + + +Remark: SM inquiry notification . + + +Create node: Feedback_SM_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.6.1) +-> father_name = [SM_Inquiry_COS15] +-> -> Feedback_SM_COS15(0) + + +Register leaf node: Feedback_SM_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default :  +Remark : Set if send feedback short message for balance inquiry or recharge operation. + +Field : total(3) +Access : read-write [1]Send SM for recharge result + { + [u]0.0-0.0 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + [2]Send SM for inquiry result + { + [u]0.1-0.1 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } + + +Create node: Inquiry_SM_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.6.2) +-> father_name = [SM_Inquiry_COS15] +-> -> Feedback_SM_COS15(0) +-> -> Inquiry_SM_COS15(1) + + +Register leaf node: Inquiry_SM_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable charge on inquiry short message. Subscriber may inquire his account by sending a SM (may be vacant) +to the inquiry service number. Free SMs for every day: set quantity of free inquiry short message on a daily basis if +charge is enabled. Maximum is 128. + +Field : total(2) +Access : read-write [1]Charge on inquiry SM + { + [u]0.7-0.7 + [u]select + [v]0[opt]Not charge + [v]1[opt]Charge + } +[2]Free SM every day + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Expiry_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.6.3) +-> father_name = [SM_Inquiry_COS15] +-> -> Feedback_SM_COS15(0) +-> -> Inquiry_SM_COS15(1) +-> -> SM_Expiry_COS15(2) + + +Register leaf node: SM_Expiry_COS15. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Enable or disable sending notification short message when an account is going to expire. If the Days +is set as 5, the PPS will send the notification SM to a subscriber whose account validity will expire +in five days. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]0.7-0.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Days prior to expiry date + { + [u]0.0-0.6 + [u]input + [v]toDec high 0 + } + + +Create node: SM_Low_Balance_COS15(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.4.16.6.4) +-> father_name = [SM_Inquiry_COS15] +-> -> Feedback_SM_COS15(0) +-> -> Inquiry_SM_COS15(1) +-> -> SM_Expiry_COS15(2) +-> -> SM_Low_Balance_COS15(3) + + +Register leaf node: SM_Low_Balance_COS15. +Instance: 1 +Length : 2 +Flag : 255 +Default : 侓 +Remark : Enable or disable sending notification short message when an account's balance is too low. +Balance level to send SM: set a low balance for short message notification. PPS will send +a notification short message to an subscriber whose balance is no more than the preset low +balance value. e.g. if set bit0-14 as 100, when a subscriber'sbalance becomes less than 100, +the PPS will send the notification SM to this subscriber indicating low balance. + +Field : total(2) +Access : read-write [1]Send SM notification + { + [u]1.7-1.7 + [u]select + [v]0[opt]Disable + [v]1[opt]Enable + } +[2]Balance level to send SM + { + [u]0.0-1.6 + [u]input + [v]toDec high 0 + } + + +Create node: Call_Routing_VMS(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5) +-> father_name = [Configuration] +-> -> Service_Control(0) +-> -> SRF_Param(1) +-> -> File_Operation(2) +-> -> COS_Param(3) +-> -> Call_Routing_VMS(4) + + +Remark: Call routing to VMS . + + +Create node: VMS_PLMN_Maintenance(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5.1) +-> father_name = [Call_Routing_VMS] +-> -> VMS_PLMN_Maintenance(0) + + +Register leaf node: VMS_PLMN_Maintenance. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + +Field : total(1) +Access : read-only[1]VMS service number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: VMS_PSTN_Maintenance(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5.2) +-> father_name = [Call_Routing_VMS] +-> -> VMS_PLMN_Maintenance(0) +-> -> VMS_PSTN_Maintenance(1) + + +Register leaf node: VMS_PSTN_Maintenance. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + +Field : total(1) +Access : read-only[1]VMS service number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: VMS_leave_msg_No(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5.3) +-> father_name = [Call_Routing_VMS] +-> -> VMS_PLMN_Maintenance(0) +-> -> VMS_PSTN_Maintenance(1) +-> -> VMS_leave_msg_No(2) + + +Register leaf node: VMS_leave_msg_No. +Instance: 1 +Length : 16 +Flag : 255 +Default : +Remark : Voice mail service center number. It is used by the PPS to route the VMS calls to the VMS. + +Field : total(1) +Access : read-only[1]VMS deposit number + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Rule(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5.4) +-> father_name = [Call_Routing_VMS] +-> -> VMS_PLMN_Maintenance(0) +-> -> VMS_PSTN_Maintenance(1) +-> -> VMS_leave_msg_No(2) +-> -> Rule(3) + + +Register leaf node: Rule. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : rule + +Field : total(3) +Access : read-only [1]Route by + { + [u]0.0-0.0 + [u]select + [v]0[opt]Prefix + [v]1[opt]Whole number + } + [2]Route + { + [u]0.1-0.1 + [u]select + [v]0[opt]Caller number + [v]1[opt]Called number + } + + +Create node: VMS_User_Segments(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.5.5) +-> father_name = [Call_Routing_VMS] +-> -> VMS_PLMN_Maintenance(0) +-> -> VMS_PSTN_Maintenance(1) +-> -> VMS_leave_msg_No(2) +-> -> Rule(3) +-> -> VMS_User_Segments(4) + + +Register leaf node: VMS_User_Segments. +Instance: 128 +Length : 80 +Flag : 255 +Default : 86755900000 +Remark : VMS user segments + +Field : total(5) +Access : read-only[1]Start MSISDN + { + [u]0.0-15.7 + [u]input + [v]ToAscii Low 0 + } +[2]End MSISDN + { + [u]16.0-31.7 + [u]input + [v]ToAscii Low 0 + } +[3]VMS service number - PLMN + { + [u]32.0-47.7 + [u]input + [v]ToAscii Low 0 + } +[4]VMS service number - PSTN + { + [u]48.0-63.7 + [u]input + [v]ToAscii Low 0 + } +[5]Leave message deposit number + { + [u]64.0-79.7 + [u]input + [v]ToAscii Low 0 + } + + +Create node: Status(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.6) +-> father_name = [Configuration] +-> -> Service_Control(0) +-> -> SRF_Param(1) +-> -> File_Operation(2) +-> -> COS_Param(3) +-> -> Call_Routing_VMS(4) +-> -> Status(5) + + +Remark: Status. + + +Create node: Activation(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.6.1) +-> father_name = [Status] +-> -> Activation(0) + + +Register leaf node: Activation. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Set PPS system status. 0=normal. After initial PPS installation, if the PPS system doesn't has subscriber profiles, its status is suspended. In this case operator may set this parameter (normal) to activate the PPS server. + +Field : total(1) +Access : read-only [1]System status + { + [u]0.0-0.7 + [u]select + [v]0[opt]Normal + } + + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.6.2) +-> father_name = [Status] +-> -> Activation(0) +-> -> Command(1) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : PPS management command. +Save parameters: Save PPS parameters in PPS memory to PPS hard disk. +Save user data: Save PPS subscriber data in PPS memory to PPS hard disk. + +Field : total(1) +Access : read-write [1]Command + { + [u]0.0-0.7 + [u]select + [v]1[opt]Save parameters + [v]2[opt]Save user data + } + + +Create node: MSS(OID: 1.3.6.1.4.1.1373.1.3.3.16) +-> father_name = [App] +-> -> MSC(0) +-> -> HLR(1) +-> -> AUC(2) +-> -> SMSC(3) +-> -> PPS(4) +-> -> MSS(5) + + +Remark: Subsystems for MSS . + + +Create node: Configuration(OID: 1.3.6.1.4.1.1373.1.3.3.16.2) +-> father_name = [MSS] +-> -> Configuration(0) + + +Remark: Configuration for MSS . + + +Create node: Management(OID: 1.3.6.1.4.1.1373.1.3.3.16.2.1) +-> father_name = [Configuration] +-> -> Management(0) + + +Remark: Management for MSS . + + +Create node: Command(OID: 1.3.6.1.4.1.1373.1.3.3.16.2.1.1) +-> father_name = [Management] +-> -> Command(0) + + +Register leaf node: Command. +Instance: 1 +Length : 1 +Flag : 255 +Default : +Remark : Safely shut down MSS server by stoping MSS process, saving subscriber data to harddisk and shut down the server. +Operation procedures: +1. Select -Shutdown- at above pulldown menu. +2. Click -Set- button in this set window. +3. Click -SET- button on operation page. + +Field : total(1) +Access : write-only [1]Command + { + [u]0.0-0.7 + [u]select + [v]4[opt]Shutdown + [v]5[opt]Undefine value + } + + + + + +SubSystem Module +Index:0 OID: 1.3.6.1.4.1.1373.1.3.2.2.2. name:MTP3 MaxGroup:3 +Index:1 OID: 1.3.6.1.4.1.1373.1.3.2.2.3. name:SCCP MaxGroup:1 +Index:2 OID: 1.3.6.1.4.1.1373.1.3.2.2.5. name:XAPP MaxGroup:1 +Index:3 OID: 1.3.6.1.4.1.1373.1.3.2.3.4. name:SMPP MaxGroup:0 +Index:4 OID: 1.3.6.1.4.1.1373.1.3.3.2.2. name:CCF(MSC) MaxGroup:0 +Index:5 OID: 1.3.6.1.4.1.1373.1.3.3.2.5. name:VLR MaxGroup:1 +Index:6 OID: 1.3.6.1.4.1.1373.1.3.3.3. name:HLR MaxGroup:1 +Index:7 OID: 1.3.6.1.4.1.1373.1.3.3.4. name:AUC MaxGroup:1 +Index:8 OID: 1.3.6.1.4.1.1373.1.3.3.5. name:SMSC MaxGroup:1 +Index:9 OID: 1.3.6.1.4.1.1373.1.3.3.6. name:PPS MaxGroup:1 + + + + + + +Host IP +Index:0 Group index:0 Membre index:0 Host name:MTP3_0_0 mss-0 Host ip:172.54.240.80. +Index:1 Group index:1 Membre index:0 Host name:MTP3_1_0 mss-1 Host ip:172.18.133.1. +Index:2 Group index:2 Membre index:0 Host name:MTP3_2_0 -- Host ip:172.18.123.1. +Index:3 Group index:3 Membre index:0 Host name:MTP3_3_0 -- Host ip:172.18.143.1. +Index:4 Group index:0 Membre index:0 Host name:SCCP_0_0 mss-0 Host ip:172.54.240.80. +Index:5 Group index:1 Membre index:0 Host name:SCCP_1_0 mss-1 Host ip:172.18.133.1. +Index:6 Group index:0 Membre index:0 Host name:XAPP_0_0 MSS-0 Host ip:172.54.240.80. +Index:7 Group index:1 Membre index:0 Host name:XAPP_1_0 MSS-1 Host ip:172.18.133.1. +Index:8 Group index:0 Membre index:0 Host name:SMPP_0_0 SMPP-0 Host ip:172.54.240.80. +Index:9 Group index:0 Membre index:0 Host name:MSC_0_0 -- Host ip:172.54.240.80. +Index:10 Group index:1 Membre index:0 Host name:MSC_1_0 -- Host ip:172.18.133.1. +Index:11 Group index:0 Membre index:0 Host name:CCF(MSC)_0_0 -- Host ip:172.54.240.80. +Index:12 Group index:0 Membre index:1 Host name:CCF(MSC)_0_1 -- Host ip:172.18.133.1. +Index:13 Group index:0 Membre index:0 Host name:VLR_0_0 VLR-0 Host ip:172.54.240.80. +Index:14 Group index:1 Membre index:0 Host name:VLR_1_0 VLR-1 Host ip:172.18.0.1. +Index:15 Group index:0 Membre index:0 Host name:HLR_0_0 -- Host ip:172.54.240.80. +Index:16 Group index:1 Membre index:0 Host name:HLR_1_0 -- Host ip:172.18.234.230. +Index:17 Group index:0 Membre index:0 Host name:AUC_0_0 -- Host ip:172.54.240.80. +Index:18 Group index:1 Membre index:0 Host name:AUC_1_0 -- Host ip:172.18.234.230. +Index:19 Group index:0 Membre index:0 Host name:SMSC_0_0 -- Host ip:172.54.240.80. +Index:20 Group index:1 Membre index:0 Host name:SMSC_1_0 -- Host ip:172.18.234.230. +Index:21 Group index:0 Membre index:0 Host name:PPS_0_0 -- Host ip:172.54.240.80. +Index:22 Group index:1 Membre index:0 Host name:PPS_1_0 -- Host ip:172.18.234.230. + + + + + + +Module Save flag +Module Index:0 OID: 1.3.6.1.4.1.1373.1.3.2.2.2.3.7. oid len:14 select id:3 field id:1 +Module Index:1 OID: 1.3.6.1.4.1.1373.1.3.2.2.3.3.2. oid len:14 select id:2 field id:1 +Module Index:2 OID: 1.3.6.1.4.1.1373.1.3.2.2.5.3.2. oid len:14 select id:1 field id:1 +Module Index:3 OID: 1.3.6.1.4.1.1373.1.3.2.3.4.3.2. oid len:14 select id:1 field id:1 +Module Index:4 OID: 1.3.6.1.4.1.1373.1.3.3.2.2.3.2. oid len:14 select id:3 field id:1 +Module Index:5 OID: 1.3.6.1.4.1.1373.1.3.3.2.5.3.3. oid len:14 select id:2 field id:1 +Module Index:6 OID: 1.3.6.1.4.1.1373.1.3.3.3.2.2.2. oid len:14 select id:2 field id:1 +Module Index:7 OID: 1.3.6.1.4.1.1373.1.3.3.4.2.2.2. oid len:14 select id:2 field id:1 +Module Index:8 OID: 1.3.6.1.4.1.1373.1.3.3.5.3.3. oid len:13 select id:1 field id:1 +Module Index:9 OID: 1.3.6.1.4.1.1373.1.3.3.6.2.1.6.2. oid len:15 select id:1 field id:1 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 +Module Index:0 OID: oid len:0 select id:0 field id:0 + + + diff --git a/omc/plat/smpp/ut/conf/guess_number_test.conf b/omc/plat/smpp/ut/conf/guess_number_test.conf new file mode 100644 index 0000000..8d6f1d1 --- /dev/null +++ b/omc/plat/smpp/ut/conf/guess_number_test.conf @@ -0,0 +1 @@ +594694911035 diff --git a/omc/plat/smpp/ut/conf/help_page b/omc/plat/smpp/ut/conf/help_page new file mode 100644 index 0000000..f367182 --- /dev/null +++ b/omc/plat/smpp/ut/conf/help_page @@ -0,0 +1,16 @@ + + ****************** + * 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. +$ diff --git a/omc/plat/smpp/ut/conf/iptrans.conf b/omc/plat/smpp/ut/conf/iptrans.conf new file mode 100644 index 0000000..8357ca8 --- /dev/null +++ b/omc/plat/smpp/ut/conf/iptrans.conf @@ -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,0,BUFFER +4957=UDP,4,BUFFER +4958=UDP,0,BUFFER +4959=UDP,0,BUFFER +4960=UDP,0,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,0,BUFFER +4968=UDP,0,BUFFER +4969=UDP,0,BUFFER +4970=UDP,0,BUFFER +4971=UDP,0,BUFFER +4972=UDP,0,BUFFER +4973=UDP,0,BUFFER diff --git a/omc/plat/smpp/ut/conf/menu_page b/omc/plat/smpp/ut/conf/menu_page new file mode 100644 index 0000000..474f4a9 --- /dev/null +++ b/omc/plat/smpp/ut/conf/menu_page @@ -0,0 +1,22 @@ + + ********************************* + * SUB MODULE SELECTION PAGE * + ********************************* + + a -- IPTR i -- HLR + b -- MTP3 j -- SMSC + c -- SCCP k -- SCF + d -- TCAP l -- SNMP + e -- XAP-P m -- DATA SYNC + f -- CCF n -- DEBUG + g -- VLR o -- reserved + h -- SSF p -- SMPP + + + + + + + + + diff --git a/omc/plat/smpp/ut/conf/mtp3.conf b/omc/plat/smpp/ut/conf/mtp3.conf new file mode 100644 index 0000000..8306832 --- /dev/null +++ b/omc/plat/smpp/ut/conf/mtp3.conf @@ -0,0 +1,1408 @@ +#MTP3 CONFIGURE FILE + +[SERVICE NETWORK SP LEN] +[04] + +[LOCAL SP] +[000000] [000000] [001fd3] [002ee0] +[000000] [000000] [888888] [000202] + +[LINK ATTRIBUTE] +[00.00.00] [03.00.62] [08.00.62] [05.00.62] +[7e.00.62] [14.00.62] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [15.00.62] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [0a.00.62] +[01.00.62] [00.00.00] [07.00.62] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [0b.00.62] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [03.01.63] [08.01.63] [05.01.63] +[7f.00.63] [14.01.63] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [15.01.63] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [0a.01.63] +[00.00.00] [00.00.00] [07.01.63] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [0b.01.63] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] +[00.00.00] [00.00.00] [00.00.00] [00.00.00] + +[LINKSET ATTRIBUTE] +[000000.00] [000b03.02] [000000.00] [002eea.02] +[000000.00] [002eeb.02] [000000.00] [001fe7.02] +[001fe8.02] [000000.00] [0032d2.02] [0032d3.02] +[000000.00] [000000.00] [0032dc.03] [0032dd.03] +[000000.00] [000000.00] [000000.00] [000000.00] +[000003.02] [000004.02] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [00007e.0b] [00007f.0b] + +[NATIONAL NETWORK SP] +[0032d2.0a.7e] [000b03.01.7f] [002081.01.7f] [000000.80.80] +[000003.14.7e] [000004.15.7e] [000000.80.80] [002eea.03.7e] +[000000.80.80] [000000.80.80] [001fe7.07.7e] [001fe8.08.7e] +[000000.80.80] [000000.80.80] [0032d3.0b.7e] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[00001c.1c.80] [00001d.1d.80] [000000.80.80] [00001f.1f.80] +[002eeb.05.7e] [000000.80.80] [00003c.22.00] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[NATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [00007e.7e.7f] +[00007f.7f.7e] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[LOCAL ACN] +030303030202020202030302020202020202020203030303030303030303030302020202 + +[INTERNATIONAL NETWORK ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[INTERNATIONAL NETWORK SPARE ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[NATIONAL NETWORK ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + +[NATIONAL NETWORK SPARE ACN] +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202020202020202020202 + diff --git a/omc/plat/smpp/ut/conf/sccp.conf b/omc/plat/smpp/ut/conf/sccp.conf new file mode 100644 index 0000000..c2ab7f1 --- /dev/null +++ b/omc/plat/smpp/ut/conf/sccp.conf @@ -0,0 +1,22 @@ +#SCCP Config file (R3_V1_T07) +#copy this file to /etc/sccp.conf to set global options +[Local Node] +#ssn NetID msisdn ip0 ip1 +4 2 236060011 172.18.128.1 172.18.129.1 +10 2 2360620103 172.18.98.1 172.18.99.1 +21 2 2360620104 172.18.166.1 172.18.167.1 +62 2 100 172.18.145.1 172.18.128.1 + +[GTT_Table] +#No NP StartDigits EndDigits NetID SPC SSN RI S E N ReplaceDigits +0 1 236060000 236069999 2 002808 6 1 +1 1 236090000 236099999 2 002808 6 1 +2 6 623045200000000 623045299999999 2 002808 6 1 +3 1 236060013 236060013 3 222222 22 1 +4 1 236060014 236060014 3 232323 22 1 +5 1 100 299 2 888888 62 0 + +[RL_SSN] +#Subsystems needed to be detected frequently +#NetID DPC SSN + diff --git a/omc/plat/smpp/ut/conf/smpp.conf b/omc/plat/smpp/ut/conf/smpp.conf new file mode 100644 index 0000000..c9e58c6 --- /dev/null +++ b/omc/plat/smpp/ut/conf/smpp.conf @@ -0,0 +1,35 @@ +#SMPP Config file (R10V0_13) +#Copy this file to ./conf/smpp.conf to set global options +#No lkEn lkType serverType sessionType sysID pwd sysType LGTT RGTT LIP RIP sessionTimer enqTimer inactTimer rspTimer ServiceNum +0 1 1 0 2 Test1 123456 -- -- -- 172.18.128.1 172.18.98.1 5 10 5 5 86755001 +1 1 1 1 2 Test2 123456 -- -- -- 172.18.128.1 172.18.98.1 5 10 5 5 86755002 +2 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +3 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +4 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +5 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +6 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +7 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +8 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +9 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +10 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +11 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +12 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +13 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +14 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +15 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +16 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +17 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +18 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +19 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +20 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +21 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +22 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +23 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +24 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +25 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +26 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +27 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +28 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +29 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +30 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- +31 0 0 0 0 Test 123456 GSM -- -- 0.0.0.0 0.0.0.0 5 10 5 5 -- diff --git a/omc/plat/smpp/ut/smpp_test/.copyarea.db b/omc/plat/smpp/ut/smpp_test/.copyarea.db new file mode 100644 index 0000000..e0a1462 --- /dev/null +++ b/omc/plat/smpp/ut/smpp_test/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\ut\smpp_test +2 +1 +b:smpp_test.c|1|127d64500ac|5abd|bc186382|0949712fbfa611dc866b001c23e19543|0 diff --git a/omc/plat/smpp/ut/smpp_test/smpp_test.c b/omc/plat/smpp/ut/smpp_test/smpp_test.c new file mode 100644 index 0000000..19eb665 --- /dev/null +++ b/omc/plat/smpp/ut/smpp_test/smpp_test.c @@ -0,0 +1,688 @@ +/* +** CDMA 2000 project, SMPP module +** +** File name: smpp_test.c +** Written by Li Long at 2004-11-25 +** CVS $Id: smpp_test.c,v0.1 2004/11/25 17:03:14 lilong Exp $ +** +*/ + +#include "./include/smpp.h" + +#define SD_PKT_NUM 10 +#define STORE_MSG_ITEM 5 + +typedef struct SMPP_MSG_STORE_STRUCT +{ + BYTE short_message[SMPP_MSG_LEN]; + BYTE message_id[65]; +} SMPP_MSG_STORE_STRUCT; + +typedef struct SMPP_LINK_ATTRIBUTE +{ + BYTE enable; + BYTE session_type; //BIND_TX/BIND_RX/BIND_TRX + BYTE message_mode; //STORE AND FORWARD/DATAGRAM/TRANSACTION + BYTE terminal_type; //SMPP_CLIENT/SMPP_SERVER +} SMPP_LINK_ATTRIBUTE; +static struct itimerval itimer,old_itimer; +static int timer_counter[MAX_SMPP_LINK]; +static int stateFlag[MAX_SMPP_LINK]; +static int msg_count[MAX_SMPP_LINK]; +static int msg_pointer[MAX_SMPP_LINK]; +static SMPP_MSG_STORE_STRUCT store_msg_buf[MAX_SMPP_LINK][STORE_MSG_ITEM]; +static SMPP_LINK_ATTRIBUTE smpp_link_attr[MAX_SMPP_LINK]; + +static void On_Timer(); +static void SetTimer(); +static void smpp_test_init(); +static void sendTestSM(int, int); +static int smpp_onDataRecv(BYTE linkNo, SMPP_MSG *pData, WORD dataLen); +static int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate); + +void smpp_test_init() +{ + int i; + + for (i=0; imessage_type) + { + case 0x0B: /* SUBMIT SM */ + printf("[TEST PROGRAM]Link %d received SUBMIT SM:\n", linkNo); + + /* store smpp message */ + if (smpp_link_attr[linkNo].message_mode == STORE_AND_FORWARD) + { + //if (pMsg->pdu.submit_sm.sm_length < SMPP_MSG_LEN) + { + pointer = (msg_pointer[linkNo]+1)%STORE_MSG_ITEM; + memcpy(&store_msg_buf[linkNo][pointer].short_message, + pMsg->pdu.submit_sm.short_message, pMsg->pdu.submit_sm.sm_length); + sprintf(store_msg_buf[linkNo][pointer].message_id, + "%ld", pMsg->pdu.submit_sm.head.sequence_number); + } + } + + /* fill with SUBMIT SM RESP structure. */ + smpp_msg.message_type = 0x0C; + smpp_msg.pdu.submit_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.submit_sm_resp.head.sequence_number = pMsg->pdu.submit_sm.head.sequence_number; + sprintf(smpp_msg.pdu.submit_sm_resp.message_id, "%ld", + smpp_msg.pdu.submit_sm_resp.head.sequence_number); + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x0C: /* SUBMIT SM RESP */ + printf("[TEST PROGRAM]Link %d received SUBMIT SM RESP.\n", linkNo); + break; + case 0x0D: /* SUBMIT MULTI */ + printf("[TEST PROGRAM]Link %d received SUBMIT MULTI.\n", linkNo); + /* store smpp message */ + if (smpp_link_attr[linkNo].message_mode == STORE_AND_FORWARD) + { + //if (pMsg->pdu.submit_multi.sm_length < SMPP_MSG_LEN) + { + pointer = (msg_pointer[linkNo]+1)%STORE_MSG_ITEM; + memcpy(&store_msg_buf[linkNo][pointer].short_message, + pMsg->pdu.submit_sm.short_message, pMsg->pdu.submit_multi.sm_length); + sprintf(store_msg_buf[linkNo][pointer].message_id, + "%ld", pMsg->pdu.submit_multi.head.sequence_number); + } + } + + /* fill with SUBMIT MULTI RESP structure. */ + smpp_msg.message_type = 0x0E; + smpp_msg.pdu.submit_multi_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.submit_multi_resp.head.sequence_number = pMsg->pdu.submit_multi.head.sequence_number; + sprintf(smpp_msg.pdu.submit_multi_resp.message_id, "%ld", + smpp_msg.pdu.submit_multi_resp.head.sequence_number); + smpp_msg.pdu.submit_multi_resp.no_unsuccess = 0; + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x0E: /* SUBMIT MULTI RESP */ + printf("[TEST PROGRAM]Link %d received SUBMIT MULTI RESP.\n", linkNo); + break; + case 0x0F: /* DELIVER SM */ + printf("[TEST PROGRAM]Link %d received DELIVER SM.\n", linkNo); + + /* store smpp message */ + if (smpp_link_attr[linkNo].message_mode == STORE_AND_FORWARD) + { + //if (pMsg->pdu.deliver_sm.sm_length < SMPP_MSG_LEN) + { + pointer = (msg_pointer[linkNo]+1)%STORE_MSG_ITEM; + memcpy(&store_msg_buf[linkNo][pointer].short_message, + pMsg->pdu.deliver_sm.short_message, pMsg->pdu.deliver_sm.sm_length); + sprintf(store_msg_buf[linkNo][pointer].message_id, + "%ld", pMsg->pdu.deliver_sm.head.sequence_number); + } + } + + /* fill with DELIVER SM RESP structure. */ + smpp_msg.message_type = 0x10; + smpp_msg.pdu.deliver_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.deliver_sm_resp.head.sequence_number = pMsg->pdu.deliver_sm.head.sequence_number; + smpp_msg.pdu.deliver_sm_resp.message_id = 0x0; + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x10: /* DELIVER SM RESP */ + printf("[TEST PROGRAM]Link %d received DELIVER SM RESP.\n", linkNo); + break; + case 0x11: /* DATA SM */ + printf("[TEST PROGRAM]Link %d received DATA SM.\n", linkNo); + + /* store smpp message */ + if (smpp_link_attr[linkNo].message_mode == STORE_AND_FORWARD) + { + if (strlen(pMsg->pdu.data_sm.message_payload) < SMPP_MSG_LEN) + { + pointer = (msg_pointer[linkNo]+1)%STORE_MSG_ITEM; + memcpy(&store_msg_buf[linkNo][pointer].short_message, + pMsg->pdu.data_sm.message_payload, strlen(pMsg->pdu.data_sm.message_payload)); + sprintf(store_msg_buf[linkNo][pointer].message_id, + "%ld", pMsg->pdu.data_sm.head.sequence_number); + } + } + + /* fill with DATA SM RESP structure. */ + smpp_msg.message_type = 0x12; + smpp_msg.pdu.data_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.data_sm_resp.head.sequence_number = pMsg->pdu.data_sm.head.sequence_number; + sprintf(smpp_msg.pdu.data_sm_resp.message_id, "%ld", + smpp_msg.pdu.data_sm_resp.head.sequence_number); + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x12: /* DATA SM RESP */ + printf("[TEST PROGRAM]Link %d received DATA SM RESP.\n", linkNo); + break; + case 0x13: /* QUERY SM */ + printf("[TEST PROGRAM]Link %d received QUERY SM.\n", linkNo); + + pointer = -1; + for (i=0; ipdu.query_sm.message_id) == 0) + { + pointer = i; + break; + } + } + + /* fill with QUERY SM RESP structure */ + smpp_msg.message_type = 0x14; + smpp_msg.pdu.query_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.query_sm_resp.head.sequence_number = pMsg->pdu.query_sm.head.sequence_number; + sprintf(smpp_msg.pdu.query_sm_resp.message_id, "%ld", + smpp_msg.pdu.query_sm_resp.head.sequence_number); + smpp_msg.pdu.query_sm_resp.final_date[0] = 0x0; + if (pointer == -1) + { + smpp_msg.pdu.query_sm_resp.message_state = 0x04; + } + else + { + smpp_msg.pdu.query_sm_resp.message_state = 0x02; + } + + smpp_msg.pdu.query_sm_resp.error_code = 0x0; + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x14: /* QUERY SM RESP */ + printf("[TEST PROGRAM]Link %d received QUERY SM RESP.\n", linkNo); + break; + case 0x15: /* CANCEL SM */ + printf("[TEST PROGRAM]Link %d received CANCEL SM RESP.\n", linkNo); + pointer = -1; + if (pMsg->pdu.cancel_sm.message_id[0] == 0){ + memset(store_msg_buf[linkNo], 0, sizeof(SMPP_MSG_STORE_STRUCT)*STORE_MSG_ITEM); + msg_pointer[linkNo] = 0; + smpp_msg.pdu.cancel_sm_resp.head.command_status = htonl(ESME_ROK); + }else{ + for (i=0; ipdu.cancel_sm.message_id, store_msg_buf[linkNo][i].message_id); + if (strcmp(store_msg_buf[linkNo][i].message_id, pMsg->pdu.cancel_sm.message_id) == 0) + { + pointer = i; + break; + } + } + if (pointer == -1) + { + smpp_msg.pdu.cancel_sm_resp.head.command_status = htonl(ESME_RCANCELFAIL); + }else{ + smpp_msg.pdu.cancel_sm_resp.head.command_status = htonl(ESME_ROK); + } + } + + /* fill with CANCEL SM RESP structure */ + smpp_msg.message_type = 0x16; + smpp_msg.pdu.cancel_sm_resp.head.sequence_number = pMsg->pdu.cancel_sm.head.sequence_number; + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x16: /* CANCEL SM RESP */ + printf("[TEST PROGRAM]Link %d received CANCEL RESP.\n", linkNo); + break; + case 0x17: /* REPLACE SM */ + printf("[TEST PROGRAM]Link %d received REPLACE SM.\n", linkNo); + pointer = -1; + for (i=0; ipdu.replace_sm.message_id) == 0) + { + pointer = i; + break; + } + } + + /* store new smpp message */ + if (pointer != -1) + { + //if (pMsg->pdu.replace_sm.sm_length < SMPP_MSG_LEN) + { + memcpy(&store_msg_buf[linkNo][pointer].short_message, + pMsg->pdu.replace_sm.short_message, pMsg->pdu.replace_sm.sm_length); + } + } + + /* fill with REPLACE SM RESP structure */ + smpp_msg.message_type = 0x18; + if (pointer == -1) + { + smpp_msg.pdu.replace_sm_resp.head.command_status = htonl(ESME_RREPLACEFAIL); + } + else + { + smpp_msg.pdu.replace_sm_resp.head.command_status = htonl(ESME_ROK); + } + smpp_msg.pdu.replace_sm_resp.head.sequence_number = pMsg->pdu.replace_sm.head.sequence_number; + smpp_send(linkNo, &smpp_msg, dataLen); + break; + case 0x18: /* REPLACE SM RESP */ + printf("[TEST PROGRAM]Link %d received REPLACE SM RESP.\n", linkNo); + break; + default: + return 0; + } + + return sequence_number; +} + +int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate) +{ + printf("[TEST PROGRAM]link %d state change to %d\n",linkNo, linkstate); + if (linkstate == 1) + stateFlag[linkNo] = TRUE; + else + stateFlag[linkNo] = FALSE; + + return linkNo; +} + +//0-submit_sm, 1-deliver_sm, 2-data_sm +void sendTestSM(int linkNo, int msg_type) +{ + SMPP_MSG smpp_msg; + WORD dataLen; + + memset(&smpp_msg, 0, sizeof(SMPP_MSG)); + switch (msg_type) + { + case 0: //send submit sm + smpp_msg.message_type = 0x0B; + smpp_msg.optional_param_flag1 = 0x0FF67FFF; + smpp_msg.optional_param_flag2 = 0x0; + + //Mandatory parameters. + strcpy(smpp_msg.pdu.submit_sm.service_type, "USSD"); + smpp_msg.pdu.submit_sm.source_addr_ton = 0x2; //National + smpp_msg.pdu.submit_sm.source_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.submit_sm.source_addr, "172.18.166.1"); + smpp_msg.pdu.submit_sm.dest_addr_ton = 0x2; //National + smpp_msg.pdu.submit_sm.dest_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.submit_sm.destination_addr, "13923482085"); + smpp_msg.pdu.submit_sm.esm_class = 0x00; + smpp_msg.pdu.submit_sm.protocol_id = 0x0; + smpp_msg.pdu.submit_sm.priority_flag = 0x3; + strcpy(smpp_msg.pdu.submit_sm.schedule_delivery_time, "041231151200000R"); + strcpy(smpp_msg.pdu.submit_sm.validity_period, "041231151200000+"); + smpp_msg.pdu.submit_sm.registered_delivery = 0x11; + smpp_msg.pdu.submit_sm.replace_if_present_flag = 0x01; + smpp_msg.pdu.submit_sm.data_coding = 0x07; + smpp_msg.pdu.submit_sm.sm_default_msg_id = 0x01; + smpp_msg.pdu.submit_sm.sm_length = 0x0; + strcpy(smpp_msg.pdu.submit_sm.short_message, ""); + //Optional parameters. + smpp_msg.pdu.submit_sm.user_message_reference = 0x00; + smpp_msg.pdu.submit_sm.source_port = 0x6666; + smpp_msg.pdu.submit_sm.source_addr_subunit = 0x01; + smpp_msg.pdu.submit_sm.destination_port = 0x8888; + smpp_msg.pdu.submit_sm.dest_addr_subunit = 0x02; + smpp_msg.pdu.submit_sm.sar_msg_ref_num = 0x7700; + smpp_msg.pdu.submit_sm.sar_total_segments = 0x01; + smpp_msg.pdu.submit_sm.sar_segment_seqnum = 0x01; + smpp_msg.pdu.submit_sm.more_messages_to_send = 0x01; + smpp_msg.pdu.submit_sm.payload_type = 0x00; + strcpy(smpp_msg.pdu.submit_sm.message_payload, "messae in submit sm optional"); + smpp_msg.pdu.submit_sm.privacy_indicator = 0x03; + + //strcpy(smpp_msg.pdu.submit_sm.callback_num, "F0453245"); + smpp_msg.pdu.submit_sm.callback_num[0] = 0x01; //ASCII + smpp_msg.pdu.submit_sm.callback_num[1] = 0x02; //National + smpp_msg.pdu.submit_sm.callback_num[2] = 0x03; //Data + strcpy(smpp_msg.pdu.submit_sm.callback_num+3, "F0453245"); + smpp_msg.pdu.submit_sm.callback_num_pres_ind = 0x06; + strcpy(smpp_msg.pdu.submit_sm.callback_num_atag, "callback_num_atag"); + //strcpy(smpp_msg.pdu.submit_sm.source_subaddress, "123"); + //smpp_msg.pdu.submit_sm.source_subaddress[0] = 0x88; + //strcpy(smpp_msg.pdu.submit_sm.source_subaddress+1,"123"); + + //smpp_msg.pdu.submit_sm.dest_subaddress[0] = 0x88; + //strcpy(smpp_msg.pdu.submit_sm.dest_subaddress+1, "789"); + smpp_msg.pdu.submit_sm.user_response_code = 0x03; + smpp_msg.pdu.submit_sm.display_time = 0x02; + //smpp_msg.pdu.submit_sm.sms_signal = 0x03; + + smpp_msg.pdu.submit_sm.ms_validity = 0x03; + smpp_msg.pdu.submit_sm.ms_msg_wait_facilities = 0x03; + smpp_msg.pdu.submit_sm.number_of_messages = 0x03; + smpp_msg.pdu.submit_sm.alert_on_message_delivery = 0x03; + + smpp_msg.pdu.submit_sm.language_indicator = 0x01; + smpp_msg.pdu.submit_sm.its_reply_type = 0x03; + smpp_msg.pdu.submit_sm.its_session_info[0] = 0x01; + smpp_msg.pdu.submit_sm.its_session_info[1] = 0x53; + smpp_msg.pdu.submit_sm.ussd_service_op = 0x03; + + break; + case 1: //send deliver sm + smpp_msg.message_type = 0x0F; + smpp_msg.optional_param_flag1 = 0x000167FF; + smpp_msg.optional_param_flag2 = 0x0; + + //Mandatory parameters. + strcpy(smpp_msg.pdu.deliver_sm.service_type, "USSD"); + smpp_msg.pdu.deliver_sm.source_addr_ton = 0x2; //National + smpp_msg.pdu.deliver_sm.source_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.deliver_sm.source_addr, "172.18.166.1"); + smpp_msg.pdu.deliver_sm.dest_addr_ton = 0x2; //National + smpp_msg.pdu.deliver_sm.dest_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.deliver_sm.destination_addr, "13923482085"); + smpp_msg.pdu.deliver_sm.esm_class = 0x00; + smpp_msg.pdu.deliver_sm.protocol_id = 0x0; + smpp_msg.pdu.deliver_sm.priority_flag = 0x3; + smpp_msg.pdu.deliver_sm.schedule_delivery_time = 0x0; + smpp_msg.pdu.deliver_sm.validity_period = 0x0; + smpp_msg.pdu.deliver_sm.registered_delivery = 0x12; + smpp_msg.pdu.deliver_sm.replace_if_present_flag = 0x01; + smpp_msg.pdu.deliver_sm.data_coding = 0x07; + smpp_msg.pdu.deliver_sm.sm_default_msg_id = 0x01; + smpp_msg.pdu.deliver_sm.sm_length = 0x0; + strcpy(smpp_msg.pdu.deliver_sm.short_message, ""); + + //Optional parameters. + smpp_msg.pdu.deliver_sm.user_message_reference = 0x00; + smpp_msg.pdu.deliver_sm.source_port = 0x6666; + smpp_msg.pdu.deliver_sm.destination_port = 0x8888; + smpp_msg.pdu.deliver_sm.sar_msg_ref_num = 0x7700; + + smpp_msg.pdu.deliver_sm.sar_total_segments = 0x01; + smpp_msg.pdu.deliver_sm.sar_segment_seqnum = 0x01; + smpp_msg.pdu.deliver_sm.user_response_code = 0x03; + smpp_msg.pdu.deliver_sm.privacy_indicator = 0x03; + + smpp_msg.pdu.deliver_sm.payload_type = 0x00; + strcpy(smpp_msg.pdu.deliver_sm.message_payload, "messae in deliver sm optional"); + smpp_msg.pdu.deliver_sm.callback_num[0] = 0x01; //ASCII + smpp_msg.pdu.deliver_sm.callback_num[1] = 0x02; //National + smpp_msg.pdu.deliver_sm.callback_num[2] = 0x03; //Data + strcpy(smpp_msg.pdu.deliver_sm.callback_num+3, "F0453245"); + //smpp_msg.pdu.deliver_sm.source_subaddress[0] = 0xA0; + //smpp_msg.pdu.deliver_sm.source_subaddress[1] = 0x01; + //strcpy(smpp_msg.pdu.deliver_sm.source_subaddress+1, "123"); + + //smpp_msg.pdu.deliver_sm.dest_subaddress[0] = 0xA0; + //smpp_msg.pdu.deliver_sm.dest_subaddress[1] = 0x01; + //strcpy(smpp_msg.pdu.deliver_sm.dest_subaddress+1, "321"); + smpp_msg.pdu.deliver_sm.language_indicator = 0x01; + smpp_msg.pdu.deliver_sm.its_session_info[0] = 0x01; + smpp_msg.pdu.deliver_sm.its_session_info[1] = 0x53; + //smpp_msg.pdu.deliver_sm.network_error_code[0] = 0x03; + //smpp_msg.pdu.deliver_sm.network_error_code[1] = 0x03; + //smpp_msg.pdu.deliver_sm.network_error_code[2] = 0x00; + + smpp_msg.pdu.deliver_sm.message_state = 0x01; + //strcpy(smpp_msg.pdu.deliver_sm.receipted_message_id, "receipted message id in deliver sm"); + break; + case 2: //data_sm + smpp_msg.message_type = 0x11; + smpp_msg.optional_param_flag1 = 0xB3EBFFFF; + smpp_msg.optional_param_flag2 = 0x0000003F; + //smpp_msg.optional_param_flag1 = 0x0C000000; + //smpp_msg.optional_param_flag2 = 0x0; + + //Mandatory parameters. + strcpy(smpp_msg.pdu.data_sm.service_type, "USSD"); + smpp_msg.pdu.data_sm.source_addr_ton = 0x2; //National + smpp_msg.pdu.data_sm.source_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.data_sm.source_addr, "172.18.166.1"); + smpp_msg.pdu.data_sm.dest_addr_ton = 0x2; //National + smpp_msg.pdu.data_sm.dest_addr_npi = 0x1; //ISDN + strcpy(smpp_msg.pdu.data_sm.destination_addr, "13923482085"); + smpp_msg.pdu.data_sm.esm_class = 0x00; + smpp_msg.pdu.data_sm.registered_delivery = 0x11; + smpp_msg.pdu.data_sm.data_coding = 0x07; + + //Optional parameters. + smpp_msg.pdu.data_sm.source_port = 0x6666; + smpp_msg.pdu.data_sm.source_addr_subunit = 0x01; + smpp_msg.pdu.data_sm.source_network_type = 0x01; + smpp_msg.pdu.data_sm.source_bearer_type = 0x03; + + smpp_msg.pdu.data_sm.source_telematics_id = 0x0003; + smpp_msg.pdu.data_sm.destination_port = 0x8888; + smpp_msg.pdu.data_sm.dest_addr_subunit = 0x03; + smpp_msg.pdu.data_sm.dest_network_type = 0x03; + + smpp_msg.pdu.data_sm.dest_bearer_type = 0x03; + smpp_msg.pdu.data_sm.dest_telematics_id = 0x0003; + smpp_msg.pdu.data_sm.sar_msg_ref_num = 0x7700; + smpp_msg.pdu.data_sm.sar_total_segments = 0x01; + + smpp_msg.pdu.data_sm.sar_segment_seqnum = 0x01; + smpp_msg.pdu.data_sm.more_messages_to_send = 0x01; + smpp_msg.pdu.data_sm.qos_time_to_live = 0x000000FF; + smpp_msg.pdu.data_sm.payload_type = 0x00; + + strcpy(smpp_msg.pdu.data_sm.message_payload, "smpp message in data sm optional"); + smpp_msg.pdu.data_sm.set_dpf = 0x01; + //strcpy(smpp_msg.pdu.data_sm.receipted_message_id, "receipted message id"); + smpp_msg.pdu.data_sm.message_state = 0x01; + + //smpp_msg.pdu.data_sm.network_error_code[0] = 0x03; + //smpp_msg.pdu.data_sm.network_error_code[1] = 0x03; + //smpp_msg.pdu.data_sm.network_error_code[2] = 0x00; + smpp_msg.pdu.data_sm.user_message_reference = 0x00; + smpp_msg.pdu.data_sm.privacy_indicator = 0x03; + smpp_msg.pdu.data_sm.callback_num[0] = 0x01; + smpp_msg.pdu.data_sm.callback_num[1] = 0x02; + smpp_msg.pdu.data_sm.callback_num[2] = 0x03; + strcpy(smpp_msg.pdu.data_sm.callback_num+3, "call back num"); + + smpp_msg.pdu.data_sm.callback_num_pres_ind = 0x06; + strcpy(smpp_msg.pdu.data_sm.callback_num_atag, "callback num atag in data sm"); + smpp_msg.pdu.data_sm.source_subaddress[0] = 0xA0; + smpp_msg.pdu.data_sm.source_subaddress[1] = 0x01; + //strcpy(smpp_msg.pdu.data_sm.source_subaddress+1, "123"); + smpp_msg.pdu.data_sm.dest_subaddress[0] = 0xA0; + smpp_msg.pdu.data_sm.dest_subaddress[1] = 0x01; + //strcpy(smpp_msg.pdu.data_sm.dest_subaddress+1, "321"); + + smpp_msg.pdu.data_sm.user_response_code = 0x03; + smpp_msg.pdu.data_sm.display_time = 0x02; + //smpp_msg.pdu.data_sm.sms_signal = 0x03; + smpp_msg.pdu.data_sm.ms_validity = 0x03; + + smpp_msg.pdu.data_sm.ms_msg_wait_facilities = 0x03; + smpp_msg.pdu.data_sm.number_of_messages = 0x03; + smpp_msg.pdu.data_sm.alert_on_message_delivery = 0x03; + smpp_msg.pdu.data_sm.language_indicator = 0x01; + + smpp_msg.pdu.data_sm.its_reply_type = 0x03; + smpp_msg.pdu.data_sm.its_session_info[0] = 0x01; + smpp_msg.pdu.data_sm.its_session_info[1] = 0x53; + break; + } + + smpp_send(linkNo, &smpp_msg, dataLen); +} diff --git a/omc/plat/smpp/ut/smpp_ussd_test/.copyarea.db b/omc/plat/smpp/ut/smpp_ussd_test/.copyarea.db new file mode 100644 index 0000000..e1668e8 --- /dev/null +++ b/omc/plat/smpp/ut/smpp_ussd_test/.copyarea.db @@ -0,0 +1,6 @@ +ClearCase CopyAreaDB|4 +vobs\MNS\r9\plat\smpp\ut\smpp_ussd_test +2 +2 +9:pppchat.c|1|127d6450167|576a|515471ea|0a797167bfa611dc866b001c23e19543|0 +e:guess_number.c|1|127d64501f4|793c|c28a2f2d|0b097183bfa611dc866b001c23e19543|0 diff --git a/omc/plat/smpp/ut/smpp_ussd_test/guess_number.c b/omc/plat/smpp/ut/smpp_ussd_test/guess_number.c new file mode 100644 index 0000000..7642d61 --- /dev/null +++ b/omc/plat/smpp/ut/smpp_ussd_test/guess_number.c @@ -0,0 +1,948 @@ +//-------------------------------------- +// USSD EAE write for ussd test +// Author: lw 2006/7/10 +//-------------------------------------- + +#include "./include/smpp.h" + +#define ISDN_LEN 8 + +typedef struct GameSession +{ + BYTE LinkNo; + BYTE flag; + BYTE ussd_ref; + BYTE seed[4]; + BYTE ssm_state; + BYTE shmsg[256]; + BYTE us_prm; + BYTE input[4]; + BYTE history[512]; + BYTE count; + char msisdn[(ISDN_LEN+1)*2+2]; +} +GameSession; + + + +typedef enum _USSD_OP +{ + PSSDR = 0 , // MAP_Process_USS_Data request operation + PSSRR = 1 , // MAP_Process_USS_Request request operation + USSRR = 2 , // MAP_USS_Request Request operation + USSNR = 3 , // MAP_USS_Notify Request operation + OPENR = 4 , // open request operation + RELR = 5 , // Release request operation + + PSSDA = 6 , // MAP_Process_USS_Data Answer operation + PSSDE = 7 , // MAP_Process_USS_Data error operation + + PSSRA = 8 , // MAP_Process_USS_Request Answer operation + PSSRE = 9 , // MAP_Process_USS_Request error operation + + USSRA = 10 , // MAP_USS_Request Answer operation + USSRE = 11, // MAP_USS_Request Error operation + + USSNA = 12, // MAP_USS_Notify Answer operation + USSNE = 13, // MAP_USS_Notify Error operation + + OPENE = 14, // open error operation + RELE = 15, // Release error operation + + PSSDS = 16, // MAP_Process_USS_Data confirm operation + PSSRS = 17, // MAP_Process_USS_Request confirm operation + USSRC = 18, // MAP_USS_Request Confirm operation + USSNC = 19, // MAP_USS_Notify Confirm operation + + USSRS = 20, // MAP_USS_Request response operation + USSNS = 21, // MAP_USS_Notify response operation + PSSRC = 22, // MAP_Process_USS_Request confirm operation + OPENC = 23, // open confirm operation + RELC = 24, // Release confirm operation +} +USSD_OP; + +struct ussd_op +{ + char *s; + USSD_OP v; +}; + +#define USSD_OP_NUM 25 +#define USSD_OP_LEN 5 + +static const struct ussd_op op_map_name[25] = { + { "PSSDR" , PSSDR }, // 0 MAP_Process_USS_Data request operation + { "PSSRR" , PSSRR }, // 1 MAP_Process_USS_Request request operation + { "USSRR" , USSRR }, // 2 MAP_USS_Request Request operation + { "USSNR" , USSNR }, // 3 MAP_USS_Notify Request operation + { "OPENR" , OPENR }, // 4 open request operation + { "RELR " , RELR }, // 5 Release request operation + + { "PSSAE" , PSSDA }, // 6 MAP_Process_USS_Data Answer operation + { "PSSDE" , PSSDE }, // 7 MAP_Process_USS_Data error operation + + { "PSSRE" , PSSRA }, // 8 MAP_Process_USS_Request Answer operation + { "PSSRE" , PSSRE }, // 9 MAP_Process_USS_Request error operation + + { "USSRA" , USSRA }, // 10 MAP_USS_Request Answer operation + { "USSRE" , USSRE }, // 11 MAP_USS_Request Error operation + + { "USSNA" , USSNA }, // 12 MAP_USS_Notify Answer operation + { "USSNE" , USSNE }, // 13 MAP_USS_Notify Error operation + + { "OPENE" , OPENE }, // 14 open error operation + { "RELE " , RELE }, // 15 Release error operation + + { "PSSDS" , PSSDS }, // 16 MAP_Process_USS_Data confirm operation + { "PSSRS" , PSSRS }, // 17 MAP_Process_USS_Request confirm operation + { "USSRC" , USSRC }, // 18 MAP_USS_Request Confirm operation + { "USSNC" , USSNC }, // 19 MAP_USS_Notify Confirm operation + + { "USSRS" , USSRS }, // 20 MAP_USS_Request response operation + { "USSNS" , USSNS }, // 21 MAP_USS_Notify response operation + { "PSSRC" , PSSRC }, // 22 MAP_Process_USS_Request confirm operation + { "OPENC" , OPENC }, // 23 open confirm operation + { "RELC " , RELC }, // 24 Release confirm operation +}; + +typedef enum US_STATE +{ + US_IDLE=0, + US_OPENR, + US_OPENC, + US_OPENE, + US_PSSRR, + US_PSSRA, + US_PSSRE, + US_PSSRC, + US_PSSRS, + US_USSRR, + US_USSRC, + US_USSRS, + US_USSNR, + US_USSNC, + US_USSNS, + US_RELER, + US_RELEC, + US_RELES, + US_RELEE, +} +US_STATE; + +#define MAX_GAME_SESSION 255 + +typedef struct GuessGame +{ + BYTE wxc2_hlr_number[8]; + char service_number[8]; + BYTE link_enable; + BYTE link; +}GuessGame; + +GuessGame gg; + + +struct GameSession ssm_data[MAX_GAME_SESSION]; + +#define SD_PKT_NUM 10 +#define STORE_MSG_ITEM 60 + +typedef struct SMPP_MSG_STORE_STRUCT +{ + BYTE short_message[SMPP_MSG_LEN]; + BYTE message_id[65]; +} SMPP_MSG_STORE_STRUCT; + + +#define MAX_GAME_LINK 1 + +static struct itimerval itimer,old_itimer; +static int timer_counter[MAX_GAME_LINK]; +static int stateFlag[MAX_GAME_LINK]; +static int msg_count[MAX_GAME_LINK]; +static int msg_pointer[MAX_GAME_LINK]; +static SMPP_MSG_STORE_STRUCT store_msg_buf[MAX_GAME_LINK][STORE_MSG_ITEM]; + +static void On_Timer(); +static void SetTimer(); +static void smpp_test_init(); +static int smpp_onDataRecv(BYTE linkNo, SMPP_MSG *pData, WORD dataLen); +static int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate); + +BYTE hae_isdn_ston(BYTE *normal_isdn,BYTE *str_isdn) +{ + BYTE ii; + BYTE len; + + len = strlen(str_isdn); + if (len > ISDN_LEN*2-2) + return 0; + if ((len % 2) == 1) // odd number + { + AsciiToBcd(normal_isdn+1,str_isdn,len-1); + ii = len/2 + 1; + normal_isdn[ii] = (str_isdn[len-1] - '0') << 4; + normal_isdn[ii] |= 0x0E; + } + else + { + AsciiToBcd(normal_isdn+1,str_isdn,len); + ii = len/2; + } + memset(normal_isdn+ii+1,0xEE,ISDN_LEN-ii-1); + normal_isdn[0] = 0x91; // default value + return 1; +} + + +void hae_isdn_ntos(BYTE *str_isdn,BYTE *normal_isdn) +{ + BYTE len = 0; + BYTE ii,jj; + + for (ii = 1;ii < ISDN_LEN;ii ++) + { + jj = (normal_isdn[ii] >> 4) & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + jj = normal_isdn[ii] & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + } + str_isdn[len] = '\0'; +} + +int register_link() +{ + BYTE ret; + + strcpy( gg.service_number , "86755001"); + + if( gg.link == MAX_SMPP_LINK+1 ) + { + ret = smpp_registerLink(SMPP_CLIENT, BIND_TRX, gg.service_number, TRANSACTION); + if ((ret&0x80) == 0x80) + { + gg.link = ret&0x7f; + printf("Get link for GuessGame EAE .link:%d", gg.link); + smpp_attach_link(gg.link, smpp_onDataRecv, smpp_onLinkStateChange); + return 1; + } + } + else + { + smpp_attach_link(gg.link, smpp_onDataRecv, smpp_onLinkStateChange); + return 1; + } + return 0; +} + +void smpp_test_init(int flag) +{ + int i; + + FILE *fp; + char line[32]; + char test_file[] = "./conf/guess_number_test.conf"; + + gg.link_enable = 0; + gg.link = MAX_SMPP_LINK+1; + for (i=0; i 6 ; i -- ) + { + if( line[i] == ' ' || line[i] == '\t' || line[i] == '\r' || line[i] == '\n') + { + continue; + } + else if( isdigit( line[i] ) ) + { + break; + } + } + if( i < 16 && i > 6 ) + { + line[i+1] = '\0'; + } + line[16] = '\0'; + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + + if( !ssm_data[i].flag ) + { + ssm_data[i].flag = 1; + ssm_data[i].ssm_state =6; + printf("read msisdn :%s\n",line); + strcpy ( ssm_data[i].msisdn, line ); + //hae_isdn_ston ( temp_isdn, temp_msisdn ); + //memcpy( ssm_data[i].msisdn , temp_isdn , ISDN_LEN); + break; + } + } + } + } +} + +extern int iptrMainInit(); + + +int main(int argc,char *argv[]) +{ + int i; + char ret; + + heartbeat_init(0xFFFF); + debug_init(); + iptrMainInit(); + snmp_init(SMPP_PORT); + mtp_shm_init(); + sccp_init(); + + smpp_init_new(); + while ((ret = getopt(argc,argv,"n")) != -1) + { + switch (ret) + { + case 'n': + printf("\n\n\nNetwork initial ussd to ms\n\n\n"); + smpp_test_init(1); + break; + default: + smpp_test_init(0); + break; + } + } + + + for (i=0; imessage_type) + { + + case 0x0C: /* SUBMIT SM RESP */ + printf("[TEST PROGRAM]Link %d received SUBMIT SM RESP.\n", linkNo); + break; + case 0x0F: /* DELIVER SM */ + printf("[TEST PROGRAM]Link %d received DELIVER SM. op:%d \n", linkNo , pMsg->pdu.deliver_sm.ussd_service_op); + switch( pMsg->pdu.deliver_sm.ussd_service_op ) + { + case PSSRR: + smpp_send_ascout("\33[32mGuess Game Recv PSSRR\33[0m\n"); + if( pMsg->pdu.deliver_sm.user_message_reference >= MAX_GAME_SESSION ) + { + smpp_send_ascout("\33[32mThe session id is too large!\33[0m\n"); + return -1; + } + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( pMsg->pdu.deliver_sm.user_message_reference == ssm_data[i].ussd_ref ) + { + if( ssm_data[i].flag == 1) + { + smpp_send_ascout("\33[32mThe session id is in used!\33[0m\n"); + return -1; + } + } + } + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( ssm_data[i].flag == 0) + { + break; + } + } + ssm_data[i].flag = 1; + ssm_data[i].ssm_state =1; + ssm_data[i].ussd_ref = pMsg->pdu.deliver_sm.user_message_reference; + strcpy ( ssm_data[i].msisdn, pMsg->pdu.deliver_sm.source_addr ); + break; + case USSRC: + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( strcmp( pMsg->pdu.deliver_sm.source_addr ,ssm_data[i].msisdn ) == 0 ) + { + break; + } + } + if( i == MAX_GAME_SESSION ) + { + printf( "unkown USSRC msisdn :%s \n",pMsg->pdu.deliver_sm.source_addr ); + SendMsgToSMPP( pMsg->pdu.deliver_sm.user_message_reference ,ssm_ptr->shmsg , RELR ); + ssm_ptr->us_prm = US_RELER; + return -1; + } + ssm_ptr = &ssm_data[i]; + ssm_ptr->us_prm = US_USSRC; + smpp_send_ascout("\33[32mGuess Game Recv USSRC\33[0m\n"); + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , pMsg->pdu.deliver_sm.user_message_reference); + smpp_send_ascout(temp_str); + if( pMsg->pdu.deliver_sm.sm_length == 4 ) + { + memcpy( &ssm_ptr->input , &pMsg->pdu.deliver_sm.short_message ,4); + ssm_ptr->input[0] -= '0'; + ssm_ptr->input[1] -= '0'; + ssm_ptr->input[2] -= '0'; + ssm_ptr->input[3] -= '0'; + } + strcpy( ssm_ptr->shmsg , pMsg->pdu.deliver_sm.short_message ); + ssm_ptr->shmsg[pMsg->pdu.deliver_sm.sm_length] = '\0'; + break; + case USSNC: + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( strcmp( pMsg->pdu.deliver_sm.source_addr ,ssm_data[i].msisdn ) == 0 ) + { + break; + } + } + if( i == MAX_GAME_SESSION ) + { + printf( "unkown USSRC msisdn :%s \n",pMsg->pdu.deliver_sm.source_addr ); + if( pMsg->pdu.deliver_sm.user_message_reference < MAX_GAME_SESSION ) + { + ssm_ptr = &ssm_data[i]; + strcpy( ssm_ptr->shmsg , " incorrect user msg reference " ); + SendMsgToSMPP( pMsg->pdu.deliver_sm.user_message_reference ,ssm_ptr->shmsg , RELR ); + } + return -1; + } + ssm_ptr = &ssm_data[i]; + ssm_ptr->us_prm = US_USSNC; + smpp_send_ascout("\33[32mGuess Game Recv USSNC\33[0m\n"); + break; + case RELR: + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( strcmp( pMsg->pdu.deliver_sm.source_addr ,ssm_data[i].msisdn ) == 0 ) + { + break; + } + } + if( i == MAX_GAME_SESSION ) + { + + //sprintf( ssm_ptr->shmsg ,"unkown RELR msisdn :%s \n",pMsg->pdu.deliver_sm.source_addr ); + //SendMsgToSMPP( pMsg->pdu.deliver_sm.user_message_reference ,ssm_ptr->shmsg , RELR ); + return -1; + } + ssm_ptr = &ssm_data[i]; + ssm_ptr->us_prm = US_RELEC; + smpp_send_ascout("\33[32mGuess Game Recv RELR\33[0m\n"); + break; + case RELC: + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( strcmp( pMsg->pdu.deliver_sm.source_addr ,ssm_data[i].msisdn ) == 0 ) + { + break; + } + } + if( i == MAX_GAME_SESSION ) + { + printf( "unkown RELC msisdn :%s \n",pMsg->pdu.deliver_sm.source_addr ); + SendMsgToSMPP( pMsg->pdu.deliver_sm.user_message_reference ,ssm_ptr->shmsg , RELR ); + return -1; + } + ssm_ptr = &ssm_data[i]; + ssm_ptr->us_prm = US_RELES; + smpp_send_ascout("\33[32mGuess Game Recv RELR\33[0m\n"); + break; + default: + break; + } + + /* fill with DELIVER SM RESP structure. */ + smpp_msg.message_type = 0x10; + smpp_msg.pdu.deliver_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.deliver_sm_resp.head.sequence_number = pMsg->pdu.deliver_sm.head.sequence_number; + smpp_msg.pdu.deliver_sm_resp.message_id = 0x0; + smpp_send(linkNo, &smpp_msg, dataLen); + smpp_send_ascout("Send deliver_sm_resp\n"); + call_flag = 0; + break; + } + return sequence_number; +} + +int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate) +{ + printf("[TEST PROGRAM]link %d state change to %d\n",linkNo, linkstate); + if (linkstate == 1) + gg.link_enable = 1; + else + gg.link_enable = 0; + + return linkNo; +} + +int RandomNum(BYTE *seed) +{ + int count , i , j; + i = j = count = 0 ; + while( count < 4 ) + { + j = 1 +(int)(10.0*rand()/(RAND_MAX+1.0)); + if( j >= 10 ) + { + continue; + } + for( i = count ; i > 0 ; i-- ) + { + if( j == seed[i] ) + { + break; + } + } + if( !count || j != seed[i]) + { + seed[count] = j; + count++; + } + } + return (count == 4 ? 1 : 0); +} + + +int CheckInput(BYTE *input) +{ + int input_index ,index; + + for( input_index = 0 ; input_index < 4 ; input_index++ ) + { + for( index = 0 ; index < 4 ; index++ ) + { + if( index != input_index && input[input_index] == input[index] ) + { + return 0; + } + } + } + return 1; +} + +int GuessNumber(BYTE* input,BYTE* seed) +{ + BYTE seed_index , input_index ; + BYTE rt_a , rt_b ; + + rt_a = rt_b = 0; + for( input_index = 0 ; input_index < 4 ; input_index++ ) + { + for( seed_index = 0 ; seed_index < 4 ; seed_index++ ) + { + if( input[(int)input_index] == seed[(int)seed_index] ) + { + if( input_index == seed_index ) + { + rt_a++; + } + else + { + rt_b++; + } + } + } + } + return (rt_a << 4) + rt_b; +} + +void SendMsgToSMPP(int sid , BYTE* msg , BYTE ussd_op) +{ + SMPP_MSG pMsg; + int data_len; + PDU_SUBMIT_SM *submit_sm; + struct GameSession *ssm_ptr; + char temp_str[256]; + + if( sid >= MAX_GAME_SESSION ) + { + ssm_ptr = &ssm_data[sid - MAX_GAME_SESSION]; + } + else + { + ssm_ptr = &ssm_data[sid]; + } + memset( &pMsg , 0 , sizeof(SMPP_MSG)); + + submit_sm = &pMsg.pdu.submit_sm; + pMsg.message_type = 0x0B; + pMsg.optional_param_flag1 = 0x08000001; + if( sid < MAX_GAME_SESSION ) + submit_sm->user_message_reference = ssm_ptr->ussd_ref; + else + submit_sm->user_message_reference = 0xFFFF; + submit_sm->ussd_service_op = ussd_op; + strcpy( submit_sm->service_type , "USSD" ); + strcpy( submit_sm->destination_addr , ssm_ptr->msisdn ); + strcpy( submit_sm->source_addr , gg.service_number ); + //hae_isdn_ntos( submit_sm->destination_addr , ssm_ptr->msisdn ); + sprintf(temp_str, "\33[32mGuessGame send smpp msg: ussd_op :%s ssm_ptr->msisdn :%s user_refer : %d\33[0m\n" + , op_map_name[submit_sm->ussd_service_op].s ,ssm_ptr->msisdn , submit_sm->user_message_reference); + smpp_send_ascout(temp_str); + submit_sm->sm_length = strlen( msg ); + strcpy( submit_sm->short_message , msg ); + smpp_send( gg.link , &pMsg , data_len ); +} + + +void GameFsm() +{ + int rt; + int i; + char temp_str[1024]; + struct GameSession *ssm_ptr; + + if( !gg.link_enable && !register_link() ) + { + smpp_send_ascout("Try to connect to WXC2 HLR fail\n"); + printf("Try to connect to WXC2 HLR fail\n"); + return; + } + //sprintf(debugBuf,); + //smpp_send_ascout("The session id is in used!\n"); + + for( i = 0 ;i < MAX_GAME_SESSION ; i++) + { + ssm_ptr = &ssm_data[i]; + if( ssm_ptr->flag == 0 ) + { + continue; + } + if( ssm_ptr->us_prm == US_RELES ) + { + ssm_ptr->ssm_state = 7; + } + else if( ssm_ptr->us_prm == US_RELEC ) + { + strcpy( ssm_ptr->shmsg , "Release ack!\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , RELC ); + ssm_ptr->ssm_state = 7; + } + switch( ssm_ptr->ssm_state ) + { + case 0: + continue; + case 1: + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + if( !RandomNum( ssm_ptr->seed ) ) + { + //"Create random number fail" + return; + } + //sid = pMsg->pdu.deliver_sm.user_message_reference ; + //if( sid > MAX_GAME_SESSION ) + //{ + // //"Game EAE do no support so much session .sid :%d",sid + // return; + //} + sprintf( ssm_ptr->shmsg ," WellCome to WXC2 Online Guess Number Game System!\n Please input you guess nubmer:\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 2; + break; + case 2: + switch( ssm_ptr->us_prm ) + { + case US_IDLE: + break; + case US_RELER: + break; + case US_USSRC: + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + if( strlen(ssm_ptr->shmsg) != 4 ) + { + sprintf(temp_str, "\33[32mThe input string length is not 4. input again.\33[0m\n"); + smpp_send_ascout(temp_str); + strcpy ( ssm_ptr->shmsg , "The input string length is not 4. input again."); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->shmsg[0] = '\0'; + ssm_ptr->us_prm = US_IDLE; + return; + } + if( !CheckInput( ssm_ptr->input ) ) + { + sprintf( ssm_ptr->shmsg ,"Input is Error! Please input four difference numbers.\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + } + rt = GuessNumber( ssm_ptr->input , ssm_ptr->seed ) & 0xFF ; + ssm_ptr->count ++; + if( ssm_ptr->count >= 8 ) + { + sprintf ( ssm_ptr->shmsg ,"Game Over!\n"); + sprintf ( temp_str , "NO%d:%d%d%d%d ",ssm_ptr->count , ssm_ptr->input[0],ssm_ptr->input[1],ssm_ptr->input[2],ssm_ptr->input[3]); + strcat ( ssm_ptr->history , temp_str ); + sprintf ( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + //strcat ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 3; + ssm_ptr->us_prm = US_IDLE; + return ; + } + sprintf( temp_str , "NO%d:%d%d%d%d ",ssm_ptr->count , ssm_ptr->input[0],ssm_ptr->input[1],ssm_ptr->input[2],ssm_ptr->input[3]); + if( rt != 0x40 ) + { + strcat ( ssm_ptr->history , temp_str ); + sprintf( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->us_prm = US_IDLE; + } + else + { + strcat ( ssm_ptr->history , temp_str ); + sprintf( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 3; + ssm_ptr->us_prm = US_IDLE; + } + break; + } + break; + case 3: + if( ssm_ptr->us_prm == US_USSNC ) + { + switch( ssm_ptr->count ) + { + case 1: + sprintf ( ssm_ptr->shmsg ," So Luck!\n"); + break; + case 2: + sprintf ( ssm_ptr->shmsg ," Luck\n"); + break; + case 3: + sprintf ( ssm_ptr->shmsg ," Perfect\n"); + break; + case 4: + sprintf ( ssm_ptr->shmsg ," Very Good\n"); + break; + case 5: + sprintf ( ssm_ptr->shmsg ," Good\n"); + break; + case 6: + case 7: + case 8: + sprintf ( ssm_ptr->shmsg ," Correct\n"); + break; + default: + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 4; + return; + break; + } + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 4; + } + case 4: + if( ssm_ptr->us_prm == US_USSNC ) + { + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + sprintf( ssm_ptr->shmsg ," Guess Number\n1 . Restart game \n 2 . exit\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + ssm_ptr->ssm_state = 5; + ssm_ptr->count =0; + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + } + break; + case 5: + if( ssm_ptr->us_prm == US_USSRC ) + { + if( ssm_ptr->shmsg[0] == '1' ) + { + if( !RandomNum( ssm_ptr->seed ) ) + { + //"Create random number fail" + return; + } + sprintf( ssm_ptr->shmsg ," Game Restart.input four difference numbers: \n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + ssm_ptr->history[0]= '\0'; + ssm_ptr->ssm_state = 2; + } + else if( ssm_ptr->shmsg[0] == '2' ) + { + sprintf( ssm_ptr->shmsg ," Game Exit.GoodBye! Wellcome to use WXC2 system!\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + memset( ssm_ptr , 0 , sizeof(GameSession )); + + } + else + { + sprintf( ssm_ptr->shmsg ," Unexpeced menu selection!\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + ssm_ptr->ssm_state = 7; + } + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + } + break; + case 6: + if( gg.link_enable ) + { + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + if( !RandomNum( ssm_ptr->seed ) ) + { + //"Create random number fail" + return; + } + sprintf( ssm_ptr->shmsg ," WellCome to WXC2 Online Guess Number Game System!\n Please input you guess nubmer:\n"); + SendMsgToSMPP( i+MAX_GAME_SESSION ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 2; + sprintf(temp_str, "\33[32mGame Fsm change to state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + } + break; + case 7: //release + if( ssm_ptr->us_prm == US_USSNC ) + { + strcpy( ssm_ptr->shmsg , "session is closed"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , RELR ); + } + sprintf(temp_str, "\33[32mRecv Release command ! sid: %d ussd_ref: %d\33[0m\n" , i ,ssm_ptr->ussd_ref); + smpp_send_ascout(temp_str); + memset( ssm_ptr , 0 , sizeof(GameSession )); + break; + } + } +} + diff --git a/omc/plat/smpp/ut/smpp_ussd_test/pppchat.c b/omc/plat/smpp/ut/smpp_ussd_test/pppchat.c new file mode 100644 index 0000000..5309955 --- /dev/null +++ b/omc/plat/smpp/ut/smpp_ussd_test/pppchat.c @@ -0,0 +1,704 @@ +//-------------------------------------- +// USSD EAE write for ussd test +// Author: lw 2006/7/10 +//-------------------------------------- + +#include "./include/smpp.h" + +#define ISDN_LEN 8 + +typedef struct PPPChatSession +{ + BYTE LinkNo; + BYTE flag; + BYTE sid; + BYTE link_sid; + BYTE link_flag; + BYTE seed[4]; + BYTE ssm_state; + BYTE shmsg[256]; + BYTE us_prm; + BYTE input[4]; + BYTE history[512]; + BYTE count; + char msisdn[ISDN_LEN*2+1]; + char mt_msisdn[ISDN_LEN*2+1]; + char buf[256]; +} +PPPChatSession; + +typedef enum _USSD_OP +{ + PSSDR = 0 , // MAP_Process_USS_Data request operation + PSSRR = 1 , // MAP_Process_USS_Request request operation + USSRR = 2 , // MAP_USS_Request Request operation + USSNR = 3 , // MAP_USS_Notify Request operation + OPENR = 5 , // open request operation + RELR = 6 , // Release request operation + + PSSDE = 7 , // MAP_Process_USS_Data error operation + PSSRE = 8 , // MAP_Process_USS_Request error operation + USSRA = 9 , // MAP_USS_Request Answer operation + USSRE = 10, // MAP_USS_Request Error operation + USSNE = 11, // MAP_USS_Notify Error operation + USSNA = 12, // MAP_USS_Notify Answer operation + OPENE = 13, // open error operation + RELE = 14, // Release error operation + UTEST = 15, // USSD TEST Message + + PSSDS = 16, // MAP_Process_USS_Data confirm operation + PSSRS = 17, // MAP_Process_USS_Request confirm operation + USSRC = 18, // MAP_USS_Request Confirm operation + USSNC = 19, // MAP_USS_Notify Confirm operation + PSSRC = 20, // MAP_Process_USS_Request confirm operation + OPENC = 21, // open confirm operation + RELC = 22, // Release confirm operation +} +USSD_OP; + +typedef enum US_STATE +{ + US_IDLE=0, + US_OPENR, + US_OPENC, + US_OPENE, + US_PSSRR, + US_PSSRA, + US_PSSRE, + US_PSSRC, + US_PSSRS, + US_USSRR, + US_USSRC, + US_USSRS, + US_USSNR, + US_USSNC, + US_USSNS, + US_RELER, + US_RELEC, + US_RELEE, +} +US_STATE; + +#define MAX_GAME_SESSION 255 + +typedef struct GuessGame +{ + BYTE wxc2_hlr_number[8]; + BYTE link_enable; + BYTE link; +}GuessGame; + +GuessGame gg; + + +struct PPPChatSession ssm_data[MAX_GAME_SESSION]; + +#define SD_PKT_NUM 10 +#define STORE_MSG_ITEM 60 + +typedef struct SMPP_MSG_STORE_STRUCT +{ + BYTE short_message[SMPP_MSG_LEN]; + BYTE message_id[65]; +} SMPP_MSG_STORE_STRUCT; + + +#define MAX_GAME_LINK 1 + +static struct itimerval itimer,old_itimer; +static int timer_counter[MAX_GAME_LINK]; +static int stateFlag[MAX_GAME_LINK]; +static int msg_count[MAX_GAME_LINK]; +static int msg_pointer[MAX_GAME_LINK]; +static SMPP_MSG_STORE_STRUCT store_msg_buf[MAX_GAME_LINK][STORE_MSG_ITEM]; + +static void On_Timer(); +static void SetTimer(); +static void smpp_test_init(); +static int smpp_onDataRecv(BYTE linkNo, SMPP_MSG *pData, WORD dataLen); +static int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate); + +BYTE hae_isdn_ston(BYTE *normal_isdn,BYTE *str_isdn) +{ + BYTE ii; + BYTE len; + + len = strlen(str_isdn); + if (len > ISDN_LEN*2-2) + return 0; + if ((len % 2) == 1) // odd number + { + AsciiToBcd(normal_isdn+1,str_isdn,len-1); + ii = len/2 + 1; + normal_isdn[ii] = (str_isdn[len-1] - '0') << 4; + normal_isdn[ii] |= 0x0E; + } + else + { + AsciiToBcd(normal_isdn+1,str_isdn,len); + ii = len/2; + } + memset(normal_isdn+ii+1,0xEE,ISDN_LEN-ii-1); + normal_isdn[0] = 0x91; // default value + return 1; +} + + +void hae_isdn_ntos(BYTE *str_isdn,BYTE *normal_isdn) +{ + BYTE len = 0; + BYTE ii,jj; + + for (ii = 1;ii < ISDN_LEN;ii ++) + { + jj = (normal_isdn[ii] >> 4) & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + jj = normal_isdn[ii] & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + } + str_isdn[len] = '\0'; +} + +int register_link() +{ + BYTE ret; + + if( gg.link == MAX_SMPP_LINK+1 ) + { + ret = smpp_registerLink(SMPP_CLIENT, BIND_TRX, gg.wxc2_hlr_number, TRANSACTION); + if ((ret&0x80) == 0x80) + { + gg.link = ret&0x7f; + printf("Get link for GuessGame EAE .link:%d", gg.link); + smpp_attach_link(gg.link, smpp_onDataRecv, smpp_onLinkStateChange); + return 1; + } + } + else + { + smpp_attach_link(gg.link, smpp_onDataRecv, smpp_onLinkStateChange); + return 1; + } + return 0; +} + +void smpp_test_init(int flag) +{ + int i; + + FILE *fp; + char line[32]; + BYTE temp_isdn[ISDN_LEN+1]; + BYTE temp_msisdn[65]; + char test_file[] = "./conf/guess_number_test.conf"; + + gg.link_enable = 0; + gg.link = MAX_SMPP_LINK+1; + for (i=0; i 6 ; i -- ) + { + if( line[i] == ' ' || line[i] == '\t' || line[i] == '\r' || line[i] == '\n') + { + continue; + } + else if( isdigit( line[i] ) ) + { + break; + } + } + if( i < 16 && i > 6 ) + { + line[i+1] = '\0'; + } + line[16] = '\0'; + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + + if( !ssm_data[i].flag ) + { + ssm_data[i].flag = 1; + ssm_data[i].ssm_state =6; + printf("read msisdn :%s\n",line); + strcpy ( temp_msisdn, line ); + hae_isdn_ston ( temp_isdn, temp_msisdn ); + memcpy( ssm_data[i].msisdn , temp_isdn , ISDN_LEN); + break; + } + } + } + } +} + + + +int main(int argc,char *argv[]) +{ + int i; + char ret; + + heartbeat_init(0xFFFF); + debug_init(); + iptrMainInit(); + snmp_init(SMPP_PORT); + mtp_shm_init(); + sccp_init(); + + smpp_init_new(); + while ((ret = getopt(argc,argv,"n")) != -1) + { + switch (ret) + { + case 'n': + printf("\n\n\nNetwork initial ussd to ms\n\n\n"); + smpp_test_init(1); + break; + default: + smpp_test_init(0); + break; + } + } + + + for (i=0; imessage_type) + { + + case 0x0C: /* SUBMIT SM RESP */ + printf("[TEST PROGRAM]Link %d received SUBMIT SM RESP.\n", linkNo); + break; + case 0x0F: /* DELIVER SM */ + printf("[TEST PROGRAM]Link %d received DELIVER SM. op:%d \n", linkNo , pMsg->pdu.deliver_sm.ussd_service_op); + switch( pMsg->pdu.deliver_sm.ussd_service_op ) + { + case PSSRR: + smpp_send_ascout("\33[32mPPP Chat Recv PSSRR\33[0m\n"); + if( pMsg->pdu.deliver_sm.user_message_reference >= MAX_GAME_SESSION ) + { + smpp_send_ascout("\33[32mThe session id is too large!\33[0m\n"); + return -1; + } + for( i = 0 ; i < MAX_GAME_SESSION ; i ++ ) + { + if( pMsg->pdu.deliver_sm.user_message_reference == ssm_data[i].sid || pMsg->pdu.deliver_sm.user_message_reference == ssm_data[i].link_sid ) + { + if( ssm_data[i].flag == 1) + { + smpp_send_ascout("\33[32mThe session id is in used!\33[0m\n"); + return -1; + } + ssm_data[i].flag = 1; + ssm_data[i].ssm_state =1; + strcpy ( temp_msisdn, pMsg->pdu.submit_sm.source_addr ); + hae_isdn_ston ( temp_isdn, temp_msisdn ); + memcpy( ssm_data[i].msisdn , temp_isdn , ISDN_LEN); + if( pMsg->pdu.deliver_sm.short_message_len <= ISDN*2 ) + { + memcpy( ssm_data[i].mt_msisdn , pMsg->pdu.deliver_sm.short_message , pMsg->pdu.deliver_sm.short_message_len ); + } + break; + } + } + + break; + case USSRC: + ssm_ptr = &ssm_data[pMsg->pdu.deliver_sm.user_message_reference]; + ssm_ptr->us_prm = US_USSRC; + smpp_send_ascout("\33[32mGuess Game Recv USSRC\33[0m\n"); + if( pMsg->pdu.deliver_sm.sm_length == 4 ) + { + memcpy( &ssm_ptr->input , &pMsg->pdu.deliver_sm.short_message ,4); + ssm_ptr->input[0] -= '0'; + ssm_ptr->input[1] -= '0'; + ssm_ptr->input[2] -= '0'; + ssm_ptr->input[3] -= '0'; + } + strcpy( ssm_ptr->shmsg , pMsg->pdu.deliver_sm.short_message ); + ssm_ptr->shmsg[pMsg->pdu.deliver_sm.sm_length] = '\0'; + break; + case USSNC: + ssm_ptr->us_prm = US_USSNC; + smpp_send_ascout("\33[32mGuess Game Recv USSNC\33[0m\n"); + break; + default: + break; + } + + /* fill with DELIVER SM RESP structure. */ + smpp_msg.message_type = 0x10; + smpp_msg.pdu.deliver_sm_resp.head.command_status = htonl(ESME_ROK); + smpp_msg.pdu.deliver_sm_resp.head.sequence_number = pMsg->pdu.deliver_sm.head.sequence_number; + smpp_msg.pdu.deliver_sm_resp.message_id = 0x0; + smpp_send(linkNo, &smpp_msg, dataLen); + smpp_send_ascout("Send deliver_sm_resp\n"); + call_flag = 0; + break; + } + return sequence_number; +} + +int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate) +{ + printf("[TEST PROGRAM]link %d state change to %d\n",linkNo, linkstate); + if (linkstate == 1) + gg.link_enable = 1; + else + gg.link_enable = 0; + + return linkNo; +} + +void SendMsgToSMPP(int sid , BYTE* msg , BYTE ussd_op) +{ + SMPP_MSG pMsg; + int data_len; + PDU_SUBMIT_SM *submit_sm; + struct PPPChatSession *ssm_ptr; + + if( sid >= MAX_GAME_SESSION ) + { + ssm_ptr = &ssm_data[sid - MAX_GAME_SESSION]; + } + else + { + ssm_ptr = &ssm_data[sid]; + } + memset( &pMsg , 0 , sizeof(SMPP_MSG)); + + submit_sm = &pMsg.pdu.submit_sm; + pMsg.message_type = 0x0B; + pMsg.optional_param_flag1 = 0x08000001; + if( sid < MAX_GAME_SESSION ) + submit_sm->user_message_reference = sid; + else + submit_sm->user_message_reference = 0xFFFF; + submit_sm->ussd_service_op = ussd_op; + strcpy( submit_sm->service_type , "USSD" ); + hae_isdn_ntos( submit_sm->destination_addr , ssm_ptr->msisdn ); + submit_sm->sm_length = strlen( msg ); + strcpy( submit_sm->short_message , msg ); + smpp_send( gg.link , &pMsg , data_len ); +} + + +void ChatFsm() +{ + int rt; + int i; + char temp_str[1024]; + struct PPPChatSession *ssm_ptr; + + if( !gg.link_enable && !register_link() ) + { + smpp_send_ascout("Try to connect to WXC2 HLR fail\n"); + printf("Try to connect to WXC2 HLR fail\n"); + return; + } + //sprintf(debugBuf,); + //smpp_send_ascout("The session id is in used!\n"); + + for( i = 0 ;i < MAX_GAME_SESSION ; i++) + { + ssm_ptr = &ssm_data[i]; + if( ssm_ptr->flag == 0 ) + { + continue; + } + switch( ssm_ptr->ssm_state ) + { + case 0: + continue; + case 1: + sprintf(temp_str, "\33[32mPPP Chat recv PSSR MO:%s MT:%s \nFsm state :% d sid : %d\33[0m\n" + , ssm_ptr->ssm_state , i , ssm_data[i].msisdn , ssm_data[i].mt_msisdn ); + smpp_send_ascout(temp_str); + sprintf( ssm_ptr->shmsg ," Mobile Phone request to chat with you: 1 : Accept ;\n2 : Reject:\n "); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 2; + break; + case 2: + switch( ssm_ptr->us_prm ) + { + case US_IDLE: + break; + case US_RELER: + break; + case US_USSRC: + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + if( strlen(ssm_ptr->shmsg) != 4 ) + { + sprintf(temp_str, "\33[32mThe input string length is not 4.\33[0m\n"); + smpp_send_ascout(temp_str); + return; + } + if( !CheckInput( ssm_ptr->input ) ) + { + sprintf( ssm_ptr->shmsg ,"Input is Error! Please input four difference numbers.\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + } + rt = GuessNumber( ssm_ptr->input , ssm_ptr->seed ) & 0xFF ; + ssm_ptr->count ++; + if( ssm_ptr->count >= 8 ) + { + sprintf ( ssm_ptr->shmsg ,"Game Over!\n"); + sprintf ( temp_str , "NO%d:%d%d%d%d ",ssm_ptr->count , ssm_ptr->input[0],ssm_ptr->input[1],ssm_ptr->input[2],ssm_ptr->input[3]); + strcat ( ssm_ptr->history , temp_str ); + sprintf ( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + //strcat ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 3; + ssm_ptr->us_prm = US_IDLE; + return ; + } + sprintf( temp_str , "NO%d:%d%d%d%d ",ssm_ptr->count , ssm_ptr->input[0],ssm_ptr->input[1],ssm_ptr->input[2],ssm_ptr->input[3]); + if( rt != 0x40 ) + { + strcat ( ssm_ptr->history , temp_str ); + sprintf( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->us_prm = US_IDLE; + } + else + { + strcat ( ssm_ptr->history , temp_str ); + sprintf( temp_str , "->%dA%dB\n" , rt>>4 , rt&0x0F); + strcat ( ssm_ptr->history , temp_str ); + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 3; + ssm_ptr->us_prm = US_IDLE; + } + break; + } + break; + case 3: + if( ssm_ptr->us_prm == US_USSNC ) + { + switch( ssm_ptr->count ) + { + case 1: + sprintf ( ssm_ptr->shmsg ," So Luck!\n"); + break; + case 2: + sprintf ( ssm_ptr->shmsg ," Luck\n"); + break; + case 3: + sprintf ( ssm_ptr->shmsg ," Perfect\n"); + break; + case 4: + sprintf ( ssm_ptr->shmsg ," Very Good\n"); + break; + case 5: + sprintf ( ssm_ptr->shmsg ," Good\n"); + break; + case 6: + case 7: + case 8: + sprintf ( ssm_ptr->shmsg ," Correct\n"); + break; + default: + strcpy ( ssm_ptr->shmsg , ssm_ptr->history ); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 4; + return; + break; + } + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 4; + } + case 4: + if( ssm_ptr->us_prm == US_USSNC ) + { + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + sprintf( ssm_ptr->shmsg ," Guess Number\n1 . Restart game \n 2 . exit\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + ssm_ptr->ssm_state = 5; + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + } + break; + case 5: + if( ssm_ptr->us_prm == US_USSNC ) + { + if( ssm_ptr->shmsg[0] == '1' ) + { + if( !RandomNum( ssm_ptr->seed ) ) + { + //"Create random number fail" + return; + } + sprintf( ssm_ptr->shmsg ," Game Restart.input four difference numbers: \n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSRR ); + ssm_ptr->ssm_state = 2; + } + else if( ssm_ptr->shmsg[0] == '2' ) + { + sprintf( ssm_ptr->shmsg ," Game Exit.GoodBye! Wellcome to use WXC2 system!\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + ssm_ptr->ssm_state = 0; + ssm_ptr->flag = 0; + } + else + { + sprintf( ssm_ptr->shmsg ," Unexpeced menu selection!\n"); + SendMsgToSMPP( i ,ssm_ptr->shmsg , USSNR ); + } + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + } + break; + case 6: + if( gg.link_enable ) + { + sprintf(temp_str, "\33[32mGame Fsm state :% d sid : %d\33[0m\n" , ssm_ptr->ssm_state , i); + smpp_send_ascout(temp_str); + if( !RandomNum( ssm_ptr->seed ) ) + { + //"Create random number fail" + return; + } + sprintf( ssm_ptr->shmsg ," WellCome to WXC2 Online Guess Number Game System!\n Please input you guess nubmer:\n"); + SendMsgToSMPP( i+MAX_GAME_SESSION ,ssm_ptr->shmsg , USSRR ); + sprintf(temp_str , "\n\n\33[32mSend Game Info :\n%s\33[0m\n\n" , ssm_ptr->shmsg ); + smpp_send_ascout(temp_str); + ssm_ptr->ssm_state = 2; + } + break; + } + } +} + diff --git a/omc/plat/snmp/.copyarea.db b/omc/plat/snmp/.copyarea.db new file mode 100644 index 0000000..0fc30f5 --- /dev/null +++ b/omc/plat/snmp/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\snmp +2 +5 +3:doc|2|0|0|0|1eb96fadbfa611dc868f001c23e19543|0 +2:ut|2|0|0|0|2a0971c1bfa611dc868f001c23e19543|0 +3:src|2|0|0|0|23706adb9e6b11dd978e001c23e19543|0 +8:Makefile|1|11d70a45936|b49|74cfc733|1f496fe5bfa611dc868f001c23e19543|0 +3:lib|2|0|0|0|1eb96fc9bfa611dc868f001c23e19543|0 diff --git a/omc/plat/snmp/Makefile b/omc/plat/snmp/Makefile new file mode 100644 index 0000000..ee8f04e --- /dev/null +++ b/omc/plat/snmp/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = snmp +TYPE = plat + +DBUG_FLAGS_ADD = -D_CDMA_SNMP +RELS_FLAGS_ADD = -D_CDMA_SNMP + +##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 + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/snmp/lib/libsnmp.a b/omc/plat/snmp/lib/libsnmp.a new file mode 100644 index 0000000..13642f9 Binary files /dev/null and b/omc/plat/snmp/lib/libsnmp.a differ diff --git a/omc/plat/snmp/obj/heartbeat.o b/omc/plat/snmp/obj/heartbeat.o new file mode 100644 index 0000000..c19e628 Binary files /dev/null and b/omc/plat/snmp/obj/heartbeat.o differ diff --git a/omc/plat/snmp/obj/snmp.o b/omc/plat/snmp/obj/snmp.o new file mode 100644 index 0000000..ed64d83 Binary files /dev/null and b/omc/plat/snmp/obj/snmp.o differ diff --git a/omc/plat/snmp/obj/snmp_mib.o b/omc/plat/snmp/obj/snmp_mib.o new file mode 100644 index 0000000..170cb14 Binary files /dev/null and b/omc/plat/snmp/obj/snmp_mib.o differ diff --git a/omc/plat/snmp/obj/snmp_mib_api.o b/omc/plat/snmp/obj/snmp_mib_api.o new file mode 100644 index 0000000..87737a6 Binary files /dev/null and b/omc/plat/snmp/obj/snmp_mib_api.o differ diff --git a/omc/plat/snmp/obj/snmpdebug.o b/omc/plat/snmp/obj/snmpdebug.o new file mode 100644 index 0000000..bfc5132 Binary files /dev/null and b/omc/plat/snmp/obj/snmpdebug.o differ diff --git a/omc/plat/snmp/obj/snmpmib.o b/omc/plat/snmp/obj/snmpmib.o new file mode 100644 index 0000000..d0a0c44 Binary files /dev/null and b/omc/plat/snmp/obj/snmpmib.o differ diff --git a/omc/plat/snmp/obj/snmptable.o b/omc/plat/snmp/obj/snmptable.o new file mode 100644 index 0000000..fb54c7c Binary files /dev/null and b/omc/plat/snmp/obj/snmptable.o differ diff --git a/omc/plat/snmp/obj/snmptest.o b/omc/plat/snmp/obj/snmptest.o new file mode 100644 index 0000000..f43ed21 Binary files /dev/null and b/omc/plat/snmp/obj/snmptest.o differ diff --git a/omc/plat/snmp/obj/sysctrl.o b/omc/plat/snmp/obj/sysctrl.o new file mode 100644 index 0000000..a791d50 Binary files /dev/null and b/omc/plat/snmp/obj/sysctrl.o differ diff --git a/omc/plat/snmp/src/.copyarea.db b/omc/plat/snmp/src/.copyarea.db new file mode 100644 index 0000000..41c4fb7 --- /dev/null +++ b/omc/plat/snmp/src/.copyarea.db @@ -0,0 +1,13 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\snmp\src +2 +9 +9:snmpmib.c|1|11d8b0aa861|15cb|92c1a774|98554452afd411dd8b28001c23e19543|0 +9:sysctrl.c|1|11d70a45b59|11d2|c1767c02|26797119bfa611dc868f001c23e19543|0 +a:snmptest.c|1|11d70a45a30|13e9|2011514e|2079701dbfa611dc868f001c23e19543|0 +b:snmpdebug.c|1|11d70a45aec|35d7|d88ee6df|22497071bfa611dc868f001c23e19543|0 +7:include|2|0|0|0|25406ae19e6b11dd9790001c23e19543|0 +6:snmp.c|1|11d70a45b1b|b090|73752cc6|2379708dbfa611dc868f001c23e19543|0 +b:snmptable.c|1|11d70a45b98|169b|26063315|4ed6995aa1b911dd8ad8001c23e19543|0 +a:mib_parser|2|0|0|0|27097135bfa611dc868f001c23e19543|0 +b:heartbeat.c|1|11d70a45aad|1a09|e7a2eb58|21b97055bfa611dc868f001c23e19543|0 diff --git a/omc/plat/snmp/src/heartbeat.c b/omc/plat/snmp/src/heartbeat.c new file mode 100644 index 0000000..5c02ca6 --- /dev/null +++ b/omc/plat/snmp/src/heartbeat.c @@ -0,0 +1,309 @@ +/*****************************************************/ +/*Title: heartbeat.c */ +/*Descr: Generate flatform's heartbeart */ +/*Author: Liang Hanxi */ +/*Create: 2002-06-24 */ +/*Modify: */ +/*****************************************************/ +#include "./include/heartbeat.h" + +// by simon at 23/9/25 +DWORD ExistIP[64]; +DWORD ExistIPNum; + +heartbeat_shm *HbShm=NULL; +static DWORD ObjID[20]=FLATFORM_HB_OID; +static snmp_addr HBAddr; +static BYTE InitOnce=0; +static DWORD latestAlmCmp=0; +static BYTE latestAlmCod=0; + + +static void send_alarm(); +static void send_heartbeat(); + +void heartbeat_init(u_short sys_id) +{ + int shmid; + struct shmid_ds shm_info; + memset(&shm_info, 0, sizeof(struct shmid_ds)); + if(InitOnce == 0) + { + ExistIPNum = 0; + HBAddr.local_port = HBAddr.remote_port = HB_PORT; + HBAddr.remote_ip = inet_addr(HB_IP); + HBAddr.broadcast = 1; + sysctrl_init(); + } + + if(HbShm==NULL) + { + /*open share memory*/ + if((shmid=shmget(HEARTBEAT_SHM_KEY,sizeof(heartbeat_shm),HEARTBEAT_SHM_PERM))==-1) + { + if((shmid=shmget(HEARTBEAT_SHM_KEY,sizeof(heartbeat_shm),HEARTBEAT_SHM_PERM|IPC_CREAT))==-1) + { + printf("fail to open share memory"); + exit(1); + } + } + if((HbShm=(heartbeat_shm *)shmat(shmid,0,0))==(heartbeat_shm *)-1) + { + printf("fail to attach share memory"); + exit(1); + } + + shmctl(shmid,IPC_STAT,&shm_info); + if(shm_info.shm_nattch==1) + { + memset(HbShm,0,sizeof(heartbeat_shm)); + HbShm->msg.sys_id=0xFF; + HbShm->msg.subsys_id=0xFF; + } + } + + if((sys_id & 0xFF)!=0xFF) + { + HbShm->msg.sys_id =HbShm->sys_id=sys_id>>8; + HbShm->msg.subsys_id =HbShm->subsys_id=sys_id & 0xFF; + snmp_debug_hb(2); + } + + InitOnce=1; +} + +void heartbeat_timer() //called per 20ms +{ + static time_t l_oldtime = 0,l_time; + static int counter=0; + + l_time = time(NULL); + + if(l_time - l_oldtime >= 10) + counter = 500; + + system_report(); + switch(counter) + { + case 500: + + send_heartbeat(); + counter=0; + l_oldtime = l_time; + break; + default: + + if(HbShm->alarm_num >0) + { + //system_report(); + send_alarm(); + counter=0; + } + else + counter++; + break; + } +} + + +void send_heartbeat() +{ + int i; + short len,msglen=0; + snmp_pdu pdu; + DWORD curtime; + curtime=htonl(time(NULL)); + memcpy(HbShm->msg.timestamp,(BYTE *)&curtime,4); + for(i=0;i<8;i++) + HbShm->msg.led_color[i]=(HbShm->led[2*i]<<4) | HbShm->led[2*i+1]; + + for(i=0;imsg.info[msglen++]=0; +#endif + HbShm->msg.info[msglen++]=i; + len=HbShm->component[i].status_len; +#if _CDMA_SNMP + HbShm->msg.info[msglen++]=len >> 8; +#endif + HbShm->msg.info[msglen++]=len & 255; + memcpy(HbShm->msg.info+msglen,HbShm->component[i].status,len); + msglen+=len; + } +#if _CDMA_SNMP + HbShm->msg.length[0] = msglen >> 8; + HbShm->msg.length[1] = msglen & 255; + msglen++; + msglen+=19; +#else + HbShm->msg.length =msglen; + msglen+=18; +#endif + +#if _CDMA_SNMP +/* daniel modify on 2005-7-24 */ + HbShm->msg.component_id[0]=latestAlmCmp >> 8; + HbShm->msg.component_id[1]=latestAlmCmp & 255; +/* daniel modify on 2005-7-24 */ +#else + HbShm->msg.component_id=latestAlmCmp; +#endif + HbShm->msg.alarm_code =latestAlmCod; + /*send out---->*/ + pdu.error_index =pdu.error_status =0; + pdu.pdu_type =PDU_TRAP; + pdu.request_id =0; + memcpy(pdu.var[0].msg,(BYTE *)&HbShm->msg,msglen); + pdu.var_num=1; + pdu.var[0].msglen =msglen; + pdu.var[0].vartype =4; + memcpy(pdu.var[0].oid,ObjID,14*sizeof(DWORD)); + pdu.var[0].oidlen =14; + + HBAddr.local_port =HBAddr.remote_port =HB_PORT; + HBAddr.remote_ip =inet_addr(HB_IP); + + for(i = 0; i < ExistIPNum; i++) + { + HBAddr.remote_ip = ExistIP[i]; + HBAddr.broadcast = 0; + snmp_plat_send(&pdu, &HBAddr); + } +} + +void send_alarm() +{ + int i; + short len,msglen=0; + snmp_pdu pdu; + DWORD curtime; + curtime=htonl(time(NULL)); + memcpy(HbShm->msg.timestamp,(BYTE *)&curtime,4); + for(i=0;i<8;i++) + HbShm->msg.led_color[i]=(HbShm->led[2*i]<<4) | HbShm->led[2*i+1]; + + if(HbShm->alarm_num<=0) + return; + + for(i=0;ialarm[i].flag) + { +#if _CDMA_SNMP + HbShm->msg.component_id[0] = i >> 8; + HbShm->msg.component_id[1] = i & 255; +#else + HbShm->msg.component_id= i; +#endif + HbShm->msg.alarm_code =HbShm->alarm[i].alarm_code; + + HbShm->alarm[i].flag =0; + +/* daniel add on 2005-7-24 */ + latestAlmCmp = i; + latestAlmCod = HbShm->msg.alarm_code; +/* daniel add on 2005-7-24 */ + break; + } + } + + for(i=0;imsg.info[msglen++]=0; +#endif + HbShm->msg.info[msglen++]=i; + len=HbShm->component[i].status_len; +#if _CDMA_SNMP + HbShm->msg.info[msglen++]=len >> 8; +#endif + HbShm->msg.info[msglen++]=len&255; + memcpy(HbShm->msg.info+msglen,HbShm->component[i].status,len); + msglen+=len; + } + +#if _CDMA_SNMP + HbShm->msg.length[0] = msglen >> 8; + HbShm->msg.length[1] = msglen & 255; + msglen++; + msglen+=19; +#else + HbShm->msg.length =msglen; + msglen+=18; +#endif + + if(HbShm->alarm_num >=1) + HbShm->alarm_num--; + + /*send out---->*/ + pdu.error_index =pdu.error_status =0; + pdu.pdu_type =PDU_TRAP; + pdu.request_id =0; + memcpy(pdu.var[0].msg,(BYTE *)&HbShm->msg,msglen); + pdu.var_num=1; + pdu.var[0].msglen =msglen; + pdu.var[0].vartype =4; + memcpy(pdu.var[0].oid,ObjID,14*sizeof(DWORD)); + pdu.var[0].oidlen =14; + + HBAddr.local_port =HBAddr.remote_port =HB_PORT; + HBAddr.remote_ip =inet_addr(HB_IP); + + for(i = 0; i < ExistIPNum; i++) + { + HBAddr.broadcast = 0; + HBAddr.remote_ip = ExistIP[i]; + + snmp_plat_send(&pdu, &HBAddr); + } +} + + +void set_led(BYTE nled,BYTE ncolor) +{ + if(HbShm==NULL) + heartbeat_init(0xFF); + HbShm->led[nled]=ncolor; +} + +void set_alarm(WORD component_id,BYTE alarm_code) +{ + if(HbShm==NULL) + heartbeat_init(0xFF); + if(component_id>ALARM_COMPONENT_NUM) + { + snmp_debug(SNMPDB_ALARM | SNMPDB_ERR, "Fail to send Alarm:No Such component id(%d)",component_id); + return; + } + snmp_debug(SNMPDB_ALARM, "set alarm.component id=%d,alarm_code=%d",component_id,alarm_code); + + if(HbShm->alarm[component_id].alarm_code !=alarm_code) + { + HbShm->alarm[component_id].flag=1; + HbShm->alarm_num ++; + } + HbShm->alarm[component_id].alarm_code =alarm_code; +} + +void set_status(BYTE component_id,BYTE info_len,BYTE *info) +{ + if(HbShm == NULL) + heartbeat_init(0xFF); + + if(component_id > COMPONENT_NUM) + { + snmp_debug(SNMPDB_ERR, "Fail to set status of component %d:No Such component id",component_id); + return; + } + /* + if(info_len>=256) + { + snmp_debug(SNMPDB_ERR, "Fail to set status of component %d:the length(%d) of status part exceed limit(256Byte)",component_id,info_len); + return; + }*/ + HbShm->component[component_id].status_len =info_len; + memcpy(HbShm->component[component_id].status,info,info_len); +} + + diff --git a/omc/plat/snmp/src/include/.copyarea.db b/omc/plat/snmp/src/include/.copyarea.db new file mode 100644 index 0000000..f15e98b --- /dev/null +++ b/omc/plat/snmp/src/include/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\snmp\src\include +2 +5 +b:heartbeat.h|1|11d8a87d39b|715|44da0811|20b39a67af9511dd892a001c23e19543|0 +7:macro.h|1|11d70a45cd0|7d4|fc7c68ec|28d06af69e6b11dd9792001c23e19543|0 +6:snmp.h|1|11d70a45c53|1f9a|361481b4|b4a0b617a0d811dd9cba001c23e19543|0 +9:sysctrl.h|1|11d70a45c14|3a4|c073efbf|241970c5bfa611dc868f001c23e19543|0 +7:table.h|1|11d70a45cff|573|30b3d287|b530b614a0d811dd9cbb001c23e19543|0 diff --git a/omc/plat/snmp/src/include/heartbeat.h b/omc/plat/snmp/src/include/heartbeat.h new file mode 100644 index 0000000..9a47c4b --- /dev/null +++ b/omc/plat/snmp/src/include/heartbeat.h @@ -0,0 +1,87 @@ +/*************************************************/ +/*Title: heartbeat.h */ +/*Descr: heartbeat processor(Head File) */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-5 */ +/*Modify: 2002-6-25 */ +/*************************************************/ +#ifndef __HEART_BEAT__H +#define __HEART_BEAT__H + +#include "snmp.h" +#include "time.h" +#include "sysctrl.h" + + +#define HEARTBEAT_SHM_KEY 0x01112233 +#define HEARTBEAT_SHM_PERM 0666 +#define COMPONENT_NUM 10 +#define ALARM_COMPONENT_NUM 1024 +#define LED_NUM 16 + +#define FLATFORM_HB_OID {1,3,6,1,4,1,1373,2,3,2,0} +#define FLATFORM_HB_OIDLEN 11 + +#define HB_PORT 4957 +#define HB_IP "172.18.255.255" +#define INFO_LEN 1024 + +#define MasterSubSysID 0 +#define MasterSysID 0 + +// by simon at 23/9/25 +//DWORD ExistIP[64]; +//DWORD ExistIPNum; + +typedef struct component_buf{ + BOOL flag; + BYTE alarm_code; + BYTE status_len; + BYTE status[256]; +}component_buf; + +typedef struct alarm_buf{ + BOOL flag; + BYTE alarm_code; +}alarm_buf; + +typedef struct heartbeat_msg{ + BYTE sys_id; + BYTE subsys_id; + BYTE timestamp[4]; + BYTE led_color[8]; +#if _CDMA_SNMP + BYTE component_id[2]; +#else + BYTE component_id; +#endif + BYTE alarm_code; +#if _CDMA_SNMP + BYTE length[2]; +#else + BYTE reserved; + BYTE length; +#endif + BYTE info[INFO_LEN]; +}heartbeat_msg; + +typedef struct heartbeat_shm{ + BYTE sys_id; + BYTE subsys_id; + BYTE led[LED_NUM]; + component_buf component[COMPONENT_NUM]; + alarm_buf alarm[ALARM_COMPONENT_NUM]; + BYTE alarm_num; + heartbeat_msg msg; +}heartbeat_shm; + +void set_led(BYTE nled,BYTE ncolor); +void set_alarm(WORD component_id,BYTE alarm_code); +void set_status(BYTE component_id,BYTE info_len,BYTE *info); +void heartbeat_init(u_short sys_id); +void heartbeat_timer(); + +#endif + + + diff --git a/omc/plat/snmp/src/include/macro.h b/omc/plat/snmp/src/include/macro.h new file mode 100644 index 0000000..6245160 --- /dev/null +++ b/omc/plat/snmp/src/include/macro.h @@ -0,0 +1,100 @@ +#ifndef _SNMP_MACRO_H +#define _SNMP_MACRO_H + +#define SyntaxInteger 0x02 +#define SyntaxOctetString 0x04 +#define SyntaxIpAddress 0x40 +#define SyntaxCounter 0x41 +#define SyntaxTimeTicks 0x43 +#define SyntaxOpaque 0x44 + +#define Create_Object_Cloumn 1 +#define Create_Sub_Object_Command 1 + +#define GET_NULL() do { \ + *pdata = 0; \ + *vartype = SyntaxInteger; \ + datalen = 1; \ +} while(0) + +#define GET_INTEGER(integer) do { \ + *((int *)pdata) = htonl(integer); \ + *vartype = SyntaxInteger; \ + datalen = 4; \ +} while(0) + +#define SET_INTEGER(integer) do { \ + int i; \ + if(datalen > 4) \ + return -1; \ + for(i = 0, integer = 0; i < datalen; i++) \ + { \ + integer = integer << 8; \ + integer += pdata[i]; \ + } \ +} while(0) + +#define RETURN_INTEGER(integer) do { \ + int i; \ + if(datalen > 4) \ + datalen = 4; \ + for(i = 0; i < datalen; i++) \ + { \ + pdata[datalen-i-1] = ((u8 *)&integer)[i]; \ + } \ +} while(0) + +#undef GET_U8 /* undefine the "public" macro */ +#define GET_U8(byte) do { \ + *pdata = byte; \ + *vartype = SyntaxInteger; \ + datalen = 1; \ +} while(0) + +#define SET_U8(byte) do { \ + byte = pdata[datalen-1]; \ +} while(0) + +#define GET_STRING(string) do { \ + strcpy(pdata, string); \ + *vartype = SyntaxOctetString; \ + datalen = strlen(string); \ +} while(0) + +#define SET_STRING(string) do { \ + memcpy(string, pdata, datalen); \ + string[datalen] = 0; \ +} while(0) + +#define GET_OCTETSTRING(octets, count) do { \ + memcpy(pdata, octets, count); \ + *vartype = SyntaxOctetString; \ + datalen = count; \ +} while(0) + +#define SET_OCTETSTRING(octets, count) do { \ + memcpy(octets, pdata, count); \ +} while(0) + +#define GET_OPAQUE(octets, count) do { \ + memcpy(pdata, octets, count); \ + *vartype = SyntaxOpaque; \ + datalen = count; \ +} while(0) + +#define SET_OPAQUE(octets, count) do { \ + memcpy(octets, pdata, count); \ +} while(0) + +#define GET_IP(ip) do { \ + memcpy(pdata, ip, 4); \ + *vartype = SyntaxIpAddress; \ + datalen = 4; \ +} while(0) + +#define SET_IP(ip) do { \ + memcpy(ip, pdata, 4); \ +} while(0) + +#endif + diff --git a/omc/plat/snmp/src/include/snmp.h b/omc/plat/snmp/src/include/snmp.h new file mode 100644 index 0000000..1790ee9 --- /dev/null +++ b/omc/plat/snmp/src/include/snmp.h @@ -0,0 +1,330 @@ +/*************************************************/ +/*Title: snmp.h */ +/*Descr: SNMP Agent(Head File) */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-1 */ +/*Modify: 2002-6-25 */ +/*************************************************/ + +#ifndef _SNMP_HEAD_FILE +#define _SNMP_HEAD_FILE +#include "../../../debug/src/include/debug.h" +#include "../../../iptrans/src/include/iptrans.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define SNMP_DEBUG_MASK 0 +#define SNMP_DEBUG_LOG 0 + +#define SNMP_VERSION {9, 0, 1} +#define SNMP_V1 0 +#define SNMP_V2 1 +#define COMMUNITY "public" +#define SNMP_ANY_COMMUNITY 0 //Should be set to 1 if snmp module is invoked in OMC +#define BIND_MAX 50 +#define OID_MAXLEN 32 +//#define FIX_OID {0x2b,0x06,0x01,0x04,0x01,0x8a,0x5d,0x01,0x01} +#define FIX_OID {1,3,6,1,4,1,1373,1,3} +//{iso(1).org(3).dod(6).internet(1).private(4).enterprises(1).interWAVE(1373).1.1} +#define FIX_OIDLEN 8 +#define SNMP_OID {1,3,6,1,4,1,1373,1,3,2,3,3} +#define SNMP_OIDLEN 12 + +#define HEAP_SIZE 500*1024 +#define SNMP_PORT 4957 +#define SNMP_VAR_MAX 1600 +//PDU +#define PDU_GET 0 +#define PDU_GETNEXT 1 +#define PDU_RSP 2 +#define PDU_SET 3 +#define PDU_GETBULK 5 +#define PDU_INFORM 6 +#define PDU_TRAP 7 +#define PDU_REPORT 8 +//variable type +#define NoSuchObject 0x80 +#define NosuchInstance 0x81 +#define EndOfMibView 0x82 + +//Debug +#define SNMPDB_IN 0x00 +#define SNMPDB_OUT 0x01 +#define SNMPDB_ERR 0x02 +#define SNMPDB_NOREG 0x04 +#define SNMPDB_VALUE 0x10 +#define SNMPDB_ALARM 0x20 +#define SNMPDB_MIB 0x40 +#define SNMPDB_SYS 0x80 + +#ifndef _T_BYTE +#define _T_BYTE + typedef unsigned char BYTE; +#endif + +#ifndef _T_BOOL +#define _T_BOOL + typedef unsigned char BOOL; +#endif + +#ifndef _T_DWORD +#define _T_DWORD + typedef unsigned int DWORD; +#endif + +#ifndef _T_WORD +#define _T_WORD + typedef unsigned short WORD; +#endif + +// by simon at 23/9/25 +//char SnmpVer[16]; + +typedef struct var_list{ + DWORD oid[OID_MAXLEN]; + BYTE oidlen; + BYTE vartype; + short msglen; + BYTE msg[SNMP_VAR_MAX]; +}var_list; + +typedef struct snmp_pdu //protocol data unit +{ + BYTE pdu_type; //0-get request 2-get(set) respond 3-set request 7-trap + DWORD request_id; + char community[16]; + BYTE var_num; + var_list var[BIND_MAX]; + BYTE error_status; //0:no error 1:too big 2:nosuchname 3:badvalue 4:readonly 5:generr + BYTE error_index; + //add by yizane start + DWORD non_repeaters; //in getbulk replace error_status + DWORD max_repetitions; //in getbulk replace error_index + //add by yizane end +} snmp_pdu; + +typedef struct snmp_addr +{ + unsigned int remote_ip; //DWORD remote_ip; + unsigned int local_ip; //DWORD local_ip; + WORD remote_port; + WORD local_port; + BYTE broadcast; +} snmp_addr; + +typedef struct snmp_msg +{ + snmp_addr addr; + message_list msglist; +}snmp_msg; + +typedef struct snmp_buf +{ + snmp_msg msgout[256]; + BYTE readsub, writesub; +}snmp_buf; + +//snmp_buf snmp_outbuf; + +typedef struct snmp_filter +{ + BYTE flag; + BYTE type; + BYTE oidlen; + DWORD ip; + DWORD oid[OID_MAXLEN]; + short local_port; + short remote_port; + + +}snmp_filter; + +#define MAX_SNMP_RECORD 32 +#define SNMP_SHM_KEY 0x60000001 +#define SNMP_SHM_PERM 0666 + +typedef struct snmp_log_info +{ + BYTE currentNo; /*from 0-MAX_SNMP_RECORD-1 */ + char log_info[MAX_SNMP_RECORD][512]; +}snmp_log_info; + + +/*---------------------------------------*/ +typedef void (*trapcall)(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD len,snmp_addr *addr); +typedef int (*setcall)(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD len); +typedef int (*getcall)(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +//add by yizane start +typedef int (*getnextcall)(BYTE in_oidlen, DWORD *in_oid, BYTE *oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +//add by yizane end +typedef void (*rspcall)(snmp_pdu *pdu,snmp_addr *addr); +typedef int (*snmpcall)(snmp_pdu *pdu,snmp_addr *addr); + +typedef struct mib_nod{ + DWORD id; + trapcall trap_proc; + setcall set_proc; + getcall get_proc; + //add by yizane start + getnextcall getnext_proc; + //add by yizane end + rspcall rsp_proc; + snmpcall snmp_proc; + struct mib_nod *pnext; + struct mib_nod *psub; +}mib_nod; + +typedef struct snmp_csta{ + DWORD timestamp; + DWORD trap_in; + DWORD trap_out; + DWORD set_in; + DWORD set_out; + DWORD get_in; + DWORD get_out; + //add by yizane start + DWORD getnext_in; + DWORD getnext_out; + DWORD getbulk_in; + DWORD getbulk_out; + //add by yizane end + DWORD rsp_in; + DWORD rsp_out; + DWORD fail_parse; + DWORD not_register; + DWORD fail_build; +}snmp_csta; + +typedef struct snmp_mib{ + BYTE sysid[2]; + BYTE setpasswd[10]; + BYTE getpasswd[10]; + DWORD set_oid[64][20]; + DWORD get_oid[64][20]; + DWORD trap_oid[64][20]; + DWORD rsp_oid[64][20]; +}snmp_mib; + +/********************************************************************/ +/* Macros For ASN.1 Encoding */ +/********************************************************************/ +#define insert_length(buf,pos,len) {\ + if(len<0)\ + {\ + snmp_debug(SNMPDB_ERR,"length should be larger than zero.");\ + return 0;\ + }\ + else if(len<0x80)\ + *(buf+pos--)=len;\ + else if(len<0x100)\ + {\ + *(buf+pos--)=len;\ + *(buf+pos--)=0x81;\ + }\ + else if(len<1600)\ + {\ + *(buf+pos--)=len & 0xFF;\ + *(buf+pos--)=len >>8;\ + *(buf+pos--)=0x82;\ + }\ + else\ + {\ + snmp_debug(SNMPDB_ERR,"Length(%d) exceed limit.varindex=%d",len,var_num);\ + return 0;\ + }\ +} + +#define enc_integer(buf,pos,val) {\ + if(val<0)\ + {\ + snmp_debug(SNMPDB_ERR,"integer should larger than zero.val=%d",val);\ + return -1;\ + }\ + else if(val<0x80)\ + {\ + *(buf+pos--)=(BYTE)val;\ + *(buf+pos--)=1;\ + }\ + else if(val<0x8000)\ + {\ + *(buf+pos--)=val & 0xFF;\ + *(buf+pos--)=val>>8;\ + *(buf+pos--)=2;\ + }\ + else if(val<0x800000)\ + {\ + *(buf+pos--)= val & 0xFF;\ + *(buf+pos--)=(val & 0xFFFF)>>8;\ + *(buf+pos--)=val>>16;\ + *(buf+pos--)=3;\ + }\ + else if(val<0x80000000)\ + {\ + *(buf+pos--)= val & 0xFF;\ + *(buf+pos--)=(val & 0xFFFF)>>8;\ + *(buf+pos--)=(val & 0xFFFFFF)>>16;\ + *(buf+pos--)=val>>24;\ + *(buf+pos--)=4;\ + }\ + else if(val<0xFFFFFFFF)\ + {\ + *(buf+pos--)= val & 0xFF;\ + *(buf+pos--)=(val & 0xFFFF)>>8;\ + *(buf+pos--)=(val & 0xFFFFFF)>>16;\ + *(buf+pos--)=val>>24;\ + *(buf+pos--)=0;\ + *(buf+pos--)=5;\ + }\ + else\ + {\ + snmp_debug(SNMPDB_ERR,"Integer's value exceed limit.val=%d",val);\ + return -1;\ + }\ +} + +void snmp_init(WORD nport); +void snmpmib_init(); +void snmp_timer(); +int snmp_send(snmp_pdu *msgbuf,snmp_addr *addr); +int snmp_plat_send(snmp_pdu *msgbuf,snmp_addr *addr); +int snmp_receive(snmp_pdu *msgbuf,snmp_addr *addr); +int get_response(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +int set_response(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen); +//add by yizane start +int getnext_response(BYTE pr_oidlen, DWORD *pre_oid, BYTE *oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +//add by yizane end +void inquire_trapmsg(trapcall trap_proc); +void inquire_setmsg(BYTE oidlen,DWORD *oid,setcall set_proc); +void inquire_getmsg(BYTE oidlen,DWORD *oid,getcall get_proc); +void inquire_rspmsg(BYTE oidlen,DWORD *oid,rspcall rsp_proc); +void inquire_snmpmsg(BYTE oidlen,DWORD *oid,snmpcall snmp_proc); +//add by yizane start +void inquire_getnextmsg(BYTE oidlen,DWORD *oid,getnextcall getnext_proc); +//add by yizane end +void rob_trapmsg(BYTE oidlen,DWORD *oid,trapcall trap_proc); +BYTE encode_integer(BYTE *buf,DWORD val); +DWORD decode_integer(BYTE *buf,BYTE len); +void snmp_log(char *info); +void snmp_debug(DWORD mask, const char *fmt,...); +void snmp_showbuf(DWORD mask, BYTE *buf, int len); +void snmp_logmsg(DWORD mask, snmp_pdu *pdu, snmp_addr *addr); +void snmp_debug_setup(); +void snmp_debug_timer(); +void snmp_debug_csta(BYTE npage,int instance); +void snmp_debug_hb(BYTE npage); +void snmp_init_serial_number(BYTE *Serial); +void snmp_set_timenosync();//call of this function will tell snmp module do not sync the omc time + +#include "table.h" + +/********************************************************************/ +#endif + diff --git a/omc/plat/snmp/src/include/sysctrl.h b/omc/plat/snmp/src/include/sysctrl.h new file mode 100644 index 0000000..b058f83 --- /dev/null +++ b/omc/plat/snmp/src/include/sysctrl.h @@ -0,0 +1,61 @@ +/*************************************************/ +/*Title: sysctrl.h */ +/*Descr: */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-5 */ +/*Modify: 2002-6-25 */ +/*************************************************/ + +#ifndef __SYSCTRL__H +#define __SYSCTRL__H + +#include "time.h" +#include +#include +#include +#include +#include "heartbeat.h" + +#define SYS_T_report 50*60*1 //1min + + +/* fj added 2018-01-03 omcMain 上报设备信息 */ +#pragma pack(1) +#define MAX_PARTITION_NUM 16 +typedef struct partition +{ + BYTE num; // 路径长度 + BYTE pos; // 路径值, + // char mountpoint_path[16]; + DWORD used_space; + DWORD total_space; +}partition; +typedef struct hb_sysinfo3{ + DWORD up_time; + BYTE idle_cpu_rate; + DWORD ram_total_used; + DWORD ram_total; + DWORD ram_swap_used; + DWORD ram_swap_total; + DWORD ram_buffers; + DWORD ram_cached; + BYTE pt_count; + partition pt[MAX_PARTITION_NUM]; +}hb_sysinfo3; +#pragma pack() + +typedef struct mnt_list +{ + char mnt_fsname[50]; + char mnt_dir[50]; + DWORD total; + DWORD free; + DWORD limit; +}mnt_list; + +void sysctrl_init(); +void system_report(); +#endif + + + diff --git a/omc/plat/snmp/src/include/table.h b/omc/plat/snmp/src/include/table.h new file mode 100644 index 0000000..8290408 --- /dev/null +++ b/omc/plat/snmp/src/include/table.h @@ -0,0 +1,42 @@ +#ifndef _SNMP_TABLE_H +#define _SNMP_TABLE_H + +#define MAX_COLUMNAR_OF_TABLE 48 + +typedef struct table_index { + u8 len; + u32 oid[32]; +} table_index; + +/* Get an exist instance from the inclusive one pointed to by address 'instance' */ +typedef int (*table_get_instance)(u32 *instance); +typedef int (*table_get_resp)(u32 column, u32 *instance, u8 *pdata, u8 *vartype); +typedef int (*table_set_resp)(u32 column, u32 *instance, u8 *pdata, u16 datalen); + +struct snmp_table_profile { + char name[32]; + table_index index; /* oid of table with entry exclusive */ + u32 column[MAX_COLUMNAR_OF_TABLE]; /* define all columns of a table, use '0' indicating the end */ + u8 level; /* level of instance in order to identify a row */ + table_get_instance get_instance; + table_get_resp get_resp; + table_set_resp set_resp; +}; + +struct snmp_register { + char name[32]; + u8 prefix_len; /* Module prefix len */ + u32 prefix_oid[32]; /* Module prefix oid */ + u8 num_of_table; /* how many tables being registered, such tables is pointed to by address 'table' */ + struct snmp_table_profile *table; + + /* In case no table is matched, default callback function is invoked if it is not NULL. Hence, + you can implement get/set in much the same way before, i.e. traveling all branches of MIB */ + getcall default_get_resp; + setcall default_set_resp; +}; + +extern int register_snmp_table(struct snmp_register *reg); + +#endif + diff --git a/omc/plat/snmp/src/mib_parser/.copyarea.db b/omc/plat/snmp/src/mib_parser/.copyarea.db new file mode 100644 index 0000000..5245af3 --- /dev/null +++ b/omc/plat/snmp/src/mib_parser/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\snmp\src\mib_parser +2 +4 +a:snmp_mib.h|1|11d70a45e37|13fe|db25ab6d|18e22ff87faf11dd8601001c23e19543|0 +e:snmp_mib_api.c|1|11d70a45e08|c54|97af7302|28d97189bfa611dc868f001c23e19543|0 +e:snmp_mib_api.h|1|11d70a45dd9|4b9|c03b75b8|2839716dbfa611dc868f001c23e19543|0 +a:snmp_mib.c|1|11d70a45d9b|1ef8e|61e6fb94|27a97151bfa611dc868f001c23e19543|0 diff --git a/omc/plat/snmp/src/mib_parser/snmp_mib.c b/omc/plat/snmp/src/mib_parser/snmp_mib.c new file mode 100644 index 0000000..697af39 --- /dev/null +++ b/omc/plat/snmp/src/mib_parser/snmp_mib.c @@ -0,0 +1,4152 @@ +/*********************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: snmp_mib.h +Description: header file of snmp mib parser +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-6-9 + +History: +2007-6-9 v9.0.0 Create + +BEWARE: Portions of this file are subject to the copyrights of + open-source project Net-SNMP. See the Net-SNMP's COPYING file + for more details +***********************************************************************/ +#include +#include +#include +#include +#include +#include "snmp_mib.h" + +//Macro definition---------------------------------------------------------------- +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#define SYNTAX_MASK 0x80 +/* + * types of tokens + * Tokens wiht the SYNTAX_MASK bit set are syntax tokens + */ +#define CONTINUE -1 +#define ENDOFFILE 0 +#define LABEL 1 +#define SUBTREE 2 +#define SYNTAX 3 +#define OBJID (4 | SYNTAX_MASK) +#define OCTETSTR (5 | SYNTAX_MASK) +#define INTEGER (6 | SYNTAX_MASK) +#define NETADDR (7 | SYNTAX_MASK) +#define IPADDR (8 | SYNTAX_MASK) +#define COUNTER (9 | SYNTAX_MASK) +#define GAUGE (10 | SYNTAX_MASK) +#define TIMETICKS (11 | SYNTAX_MASK) +#define KW_OPAQUE (12 | SYNTAX_MASK) +#define NUL (13 | SYNTAX_MASK) +#define SEQUENCE 14 +#define OF 15 /* SEQUENCE OF */ +#define OBJTYPE 16 +#define ACCESS 17 +#define READONLY 18 +#define READWRITE 19 +#define WRITEONLY 20 +#ifdef NOACCESS +#undef NOACCESS /* agent 'NOACCESS' token */ +#endif +#define NOACCESS 21 +#define STATUS 22 +#define MANDATORY 23 +#define KW_OPTIONAL 24 +#define OBSOLETE 25 +/* + * #define RECOMMENDED 26 + */ +#define PUNCT 27 +#define EQUALS 28 +#define NUMBER 29 +#define LEFTBRACKET 30 +#define RIGHTBRACKET 31 +#define LEFTPAREN 32 +#define RIGHTPAREN 33 +#define COMMA 34 +#define DESCRIPTION 35 +#define QUOTESTRING 36 +#define INDEX 37 +#define DEFVAL 38 +#define DEPRECATED 39 +#define SIZE 40 +#define BITSTRING (41 | SYNTAX_MASK) +#define NSAPADDRESS (42 | SYNTAX_MASK) +#define COUNTER64 (43 | SYNTAX_MASK) +#define OBJGROUP 44 +#define NOTIFTYPE 45 +#define AUGMENTS 46 +#define COMPLIANCE 47 +#define READCREATE 48 +#define UNITS 49 +#define REFERENCE 50 +#define NUM_ENTRIES 51 +#define MODULEIDENTITY 52 +#define LASTUPDATED 53 +#define ORGANIZATION 54 +#define CONTACTINFO 55 +#define UINTEGER32 (56 | SYNTAX_MASK) +#define CURRENT 57 +#define DEFINITIONS 58 +#define END 59 +#define SEMI 60 +#define TRAPTYPE 61 +#define ENTERPRISE 62 +/* + * #define DISPLAYSTR (63 | SYNTAX_MASK) + */ +#define BEGIN 64 +#define IMPORTS 65 +#define EXPORTS 66 +#define ACCNOTIFY 67 +#define BAR 68 +#define RANGE 69 +#define CONVENTION 70 +#define DISPLAYHINT 71 +#define FROM 72 +#define AGENTCAP 73 +#define MACRO 74 +#define IMPLIED 75 +#define SUPPORTS 76 +#define INCLUDES 77 +#define VARIATION 78 +#define REVISION 79 +#define NOTIMPL 80 +#define OBJECTS 81 +#define NOTIFICATIONS 82 +#define MODULE 83 +#define MINACCESS 84 +#define PRODREL 85 +#define WRSYNTAX 86 +#define CREATEREQ 87 +#define NOTIFGROUP 88 +#define MANDATORYGROUPS 89 +#define GROUP 90 +#define OBJECT 91 +#define IDENTIFIER 92 +#define CHOICE 93 +#define LEFTSQBRACK 95 +#define RIGHTSQBRACK 96 +#define IMPLICIT 97 +#define APPSYNTAX (98 | SYNTAX_MASK) +#define OBJSYNTAX (99 | SYNTAX_MASK) +#define SIMPLESYNTAX (100 | SYNTAX_MASK) +#define OBJNAME (101 | SYNTAX_MASK) +#define NOTIFNAME (102 | SYNTAX_MASK) +#define VARIABLES 103 +#define UNSIGNED32 (104 | SYNTAX_MASK) +#define INTEGER32 (105 | SYNTAX_MASK) +#define OBJIDENTITY 106 + +#define MODULE_NOT_FOUND 0 +#define MODULE_LOADED_OK 1 +#define MODULE_ALREADY_LOADED 2 +#define MODULE_LOAD_FAILED MODULE_NOT_FOUND +//for hash table +#define HASHSIZE 32 +#define BUCKET(x) (x & (HASHSIZE-1)) + +#define NHASHSIZE 128 +#define NBUCKET(x) (x & (NHASHSIZE-1)) + +#define NUMBER_OF_ROOT_NODES 1 + +#define label_compare strcmp +#define SNMP_FREE(s) do { if (s) { free((void *)s); s=NULL; } } while(0) +/* + * Beware of reaching SYNTAX_MASK (0x80) + */ +//end of macro definition--------------------------------------------------------- + +//public var definition----------------------------------------------------------- +int mibLine = 0; +const char *File = "(none)"; + +/* + * A linked list of nodes. + */ +struct node { + struct node *next; + char *label; /* This node's (unique) textual name */ + unsigned int subid; /* This node's integer subidentifier */ + int modid; /* The module containing this node */ + char *parent; /* The parent's textual name */ + int tc_index; /* index into tclist (-1 if NA) */ + int type; /* The type of object this represents */ + int access; + int status; + struct enum_list *enums; /* (optional) list of enumerated integers */ + struct range_list *ranges; + struct index_list *indexes; + char *augments; + struct varbind_list *varbinds; + char *hint; + char *units; + char *description; /* description (a quoted string) */ + char *reference; /* references (a quoted string) */ + char *defaultValue; + char *filename; + int lineno; +}; + +struct tree *tree_head = NULL; +struct node *orphan_nodes = NULL; + +#define MAXTC 4096 +struct tc { /* textual conventions */ + int type; + int modid; + char *descriptor; + char *hint; + struct enum_list *enums; + struct range_list *ranges; + char *description; +} tclist[MAXTC]; + +struct tok { + const char *name; /* token name */ + int len; /* length not counting nul */ + int token; /* value */ + int hash; /* hash of name */ + struct tok *next; /* pointer to next in hash table */ +}; +static struct tok tokens[] = { + {"obsolete", sizeof("obsolete") - 1, OBSOLETE} + , + {"Opaque", sizeof("Opaque") - 1, KW_OPAQUE} + , + {"optional", sizeof("optional") - 1, KW_OPTIONAL} + , + {"LAST-UPDATED", sizeof("LAST-UPDATED") - 1, LASTUPDATED} + , + {"ORGANIZATION", sizeof("ORGANIZATION") - 1, ORGANIZATION} + , + {"CONTACT-INFO", sizeof("CONTACT-INFO") - 1, CONTACTINFO} + , + {"MODULE-IDENTITY", sizeof("MODULE-IDENTITY") - 1, MODULEIDENTITY} + , + {"MODULE-COMPLIANCE", sizeof("MODULE-COMPLIANCE") - 1, COMPLIANCE} + , + {"DEFINITIONS", sizeof("DEFINITIONS") - 1, DEFINITIONS} + , + {"END", sizeof("END") - 1, END} + , + {"AUGMENTS", sizeof("AUGMENTS") - 1, AUGMENTS} + , + {"not-accessible", sizeof("not-accessible") - 1, NOACCESS} + , + {"write-only", sizeof("write-only") - 1, WRITEONLY} + , + {"NsapAddress", sizeof("NsapAddress") - 1, NSAPADDRESS} + , + {"UNITS", sizeof("Units") - 1, UNITS} + , + {"REFERENCE", sizeof("REFERENCE") - 1, REFERENCE} + , + {"NUM-ENTRIES", sizeof("NUM-ENTRIES") - 1, NUM_ENTRIES} + , + {"BITSTRING", sizeof("BITSTRING") - 1, BITSTRING} + , + {"BIT", sizeof("BIT") - 1, CONTINUE} + , + {"BITS", sizeof("BITS") - 1, BITSTRING} + , + {"Counter64", sizeof("Counter64") - 1, COUNTER64} + , + {"TimeTicks", sizeof("TimeTicks") - 1, TIMETICKS} + , + {"NOTIFICATION-TYPE", sizeof("NOTIFICATION-TYPE") - 1, NOTIFTYPE} + , + {"OBJECT-GROUP", sizeof("OBJECT-GROUP") - 1, OBJGROUP} + , + {"OBJECT-IDENTITY", sizeof("OBJECT-IDENTITY") - 1, OBJIDENTITY} + , + {"IDENTIFIER", sizeof("IDENTIFIER") - 1, IDENTIFIER} + , + {"OBJECT", sizeof("OBJECT") - 1, OBJECT} + , + {"NetworkAddress", sizeof("NetworkAddress") - 1, NETADDR} + , + {"Gauge", sizeof("Gauge") - 1, GAUGE} + , + {"Gauge32", sizeof("Gauge32") - 1, GAUGE} + , + {"Unsigned32", sizeof("Unsigned32") - 1, UNSIGNED32} + , + {"read-write", sizeof("read-write") - 1, READWRITE} + , + {"read-create", sizeof("read-create") - 1, READCREATE} + , + {"OCTETSTRING", sizeof("OCTETSTRING") - 1, OCTETSTR} + , + {"OCTET", sizeof("OCTET") - 1, CONTINUE} + , + {"OF", sizeof("OF") - 1, OF} + , + {"SEQUENCE", sizeof("SEQUENCE") - 1, SEQUENCE} + , + {"NULL", sizeof("NULL") - 1, NUL} + , + {"IpAddress", sizeof("IpAddress") - 1, IPADDR} + , + {"UInteger32", sizeof("UInteger32") - 1, UINTEGER32} + , + {"INTEGER", sizeof("INTEGER") - 1, INTEGER} + , + {"Integer32", sizeof("Integer32") - 1, INTEGER32} + , + {"Counter", sizeof("Counter") - 1, COUNTER} + , + {"Counter32", sizeof("Counter32") - 1, COUNTER} + , + {"read-only", sizeof("read-only") - 1, READONLY} + , + {"DESCRIPTION", sizeof("DESCRIPTION") - 1, DESCRIPTION} + , + {"INDEX", sizeof("INDEX") - 1, INDEX} + , + {"DEFVAL", sizeof("DEFVAL") - 1, DEFVAL} + , + {"deprecated", sizeof("deprecated") - 1, DEPRECATED} + , + {"SIZE", sizeof("SIZE") - 1, SIZE} + , + {"MAX-ACCESS", sizeof("MAX-ACCESS") - 1, ACCESS} + , + {"ACCESS", sizeof("ACCESS") - 1, ACCESS} + , + {"mandatory", sizeof("mandatory") - 1, MANDATORY} + , + {"current", sizeof("current") - 1, CURRENT} + , + {"STATUS", sizeof("STATUS") - 1, STATUS} + , + {"SYNTAX", sizeof("SYNTAX") - 1, SYNTAX} + , + {"OBJECT-TYPE", sizeof("OBJECT-TYPE") - 1, OBJTYPE} + , + {"TRAP-TYPE", sizeof("TRAP-TYPE") - 1, TRAPTYPE} + , + {"ENTERPRISE", sizeof("ENTERPRISE") - 1, ENTERPRISE} + , + {"BEGIN", sizeof("BEGIN") - 1, BEGIN} + , + {"IMPORTS", sizeof("IMPORTS") - 1, IMPORTS} + , + {"EXPORTS", sizeof("EXPORTS") - 1, EXPORTS} + , + {"accessible-for-notify", sizeof("accessible-for-notify") - 1, ACCNOTIFY} + , + {"TEXTUAL-CONVENTION", sizeof("TEXTUAL-CONVENTION") - 1, CONVENTION} + , + {"NOTIFICATION-GROUP", sizeof("NOTIFICATION-GROUP") - 1, NOTIFGROUP} + , + {"DISPLAY-HINT", sizeof("DISPLAY-HINT") - 1, DISPLAYHINT} + , + {"FROM", sizeof("FROM") - 1, FROM} + , + {"AGENT-CAPABILITIES", sizeof("AGENT-CAPABILITIES") - 1, AGENTCAP} + , + {"MACRO", sizeof("MACRO") - 1, MACRO} + , + {"IMPLIED", sizeof("IMPLIED") - 1, IMPLIED} + , + {"SUPPORTS", sizeof("SUPPORTS") - 1, SUPPORTS} + , + {"INCLUDES", sizeof("INCLUDES") - 1, INCLUDES} + , + {"VARIATION", sizeof("VARIATION") - 1, VARIATION} + , + {"REVISION", sizeof("REVISION") - 1, REVISION} + , + {"not-implemented", sizeof("not-implemented") - 1, NOTIMPL} + , + {"OBJECTS", sizeof("OBJECTS") - 1, OBJECTS} + , + {"NOTIFICATIONS", sizeof("NOTIFICATIONS") - 1, NOTIFICATIONS} + , + {"MODULE", sizeof("MODULE") - 1, MODULE} + , + {"MIN-ACCESS", sizeof("MIN-ACCESS") - 1, MINACCESS} + , + {"PRODUCT-RELEASE", sizeof("PRODUCT-RELEASE") - 1, PRODREL} + , + {"WRITE-SYNTAX", sizeof("WRITE-SYNTAX") - 1, WRSYNTAX} + , + {"CREATION-REQUIRES", sizeof("CREATION-REQUIRES") - 1, CREATEREQ} + , + {"MANDATORY-GROUPS", sizeof("MANDATORY-GROUPS") - 1, MANDATORYGROUPS} + , + {"GROUP", sizeof("GROUP") - 1, GROUP} + , + {"CHOICE", sizeof("CHOICE") - 1, CHOICE} + , + {"IMPLICIT", sizeof("IMPLICIT") - 1, IMPLICIT} + , + {"ObjectSyntax", sizeof("ObjectSyntax") - 1, OBJSYNTAX} + , + {"SimpleSyntax", sizeof("SimpleSyntax") - 1, SIMPLESYNTAX} + , + {"ApplicationSyntax", sizeof("ApplicationSyntax") - 1, APPSYNTAX} + , + {"ObjectName", sizeof("ObjectName") - 1, OBJNAME} + , + {"NotificationName", sizeof("NotificationName") - 1, NOTIFNAME} + , + {"VARIABLES", sizeof("VARIABLES") - 1, VARIABLES} + , + {NULL} +}; + +/* + * This is one element of an object identifier with either an integer + * subidentifier, or a textual string label, or both. + * The subid is -1 if not present, and label is NULL if not present. + */ +struct subid_s { + int subid; + int modid; + char *label; +}; + +struct objgroup { + char *name; + int line; + struct objgroup *next; +}*objgroups = NULL, *objects = NULL, *notifs = NULL; + +static struct tok *buckets[HASHSIZE]; +static struct node *nbuckets[NHASHSIZE]; +static struct tree *tbuckets[NHASHSIZE]; + +struct module *module_head = NULL; + +static int current_module = 0; +static int max_module = 0; +static int anonymous = 0; +static char *last_err_module = 0; /* no repeats on "Cannot find module..." */ + +static struct module_import root_imports[NUMBER_OF_ROOT_NODES]; + +//end of public var definition---------------------------------------------------- + +//forward function declearation--------------------------------------------------- +struct tree *read_mib(const char *filename); +struct tree *read_module(const char *name); +static int read_module_internal(const char *name); +int get_token(FILE * fp, char *token, int maxtlen); +void new_module(const char *name, const char *file); +static int is_labelchar(int ich); +static void print_error(const char *str, const char *token, int type); +static int name_hash(const char *name); +void init_mib_internals(void); +static void build_translation_table(); +static void init_tree_roots(); +static struct node *parse(FILE * fp, struct node *root); +void print_nodes(FILE * fp, struct node *root); +static void scan_objlist(struct node *root, struct objgroup *list, const char *error); +static void do_linkup(struct module *mp, struct node *np); +static void init_node_hash(struct node *nodes); +static int get_tc_index(const char *descriptor, int modid); +static void do_subtree(struct tree *root, struct node **nodes); +static void tree_from_node(struct tree *tp, struct node *np); +static void free_node(struct node *np); +void free_tree(struct tree *Tree); +static void free_indexes(struct index_list **spp); +static void free_varbinds(struct varbind_list **spp); +static void free_enums(struct enum_list **spp); +static void free_ranges(struct range_list **spp); +static void unlink_tbucket(struct tree *tp); +static void unlink_tree(struct tree *tp); +static void merge_anon_children(struct tree *tp1, struct tree *tp2); +static void free_partial_tree(struct tree *tp, int keep_label); +int which_module(const char *name); +static struct node *parse_macro(FILE * fp, char *name); +static struct node *alloc_node(int modid); +static struct node *parse_objecttype(FILE * fp, char *name); +static int get_tc(const char *descriptor, int modid, int *tc_index, + struct enum_list **ep, struct range_list **rp, char **hint); +static struct index_list *getIndexes(FILE * fp, struct index_list **retp); +static int tossObjectIdentifier(FILE * fp); +static struct node *merge_parse_objectid(struct node *np, FILE * fp, char *name); +static struct node *parse_objectid(FILE * fp, char *name); +static int getoid(FILE * fp, struct subid_s *id, int length); +static struct node *parse_objectgroup(FILE * fp, char *name, int what, struct objgroup **ol); +static struct varbind_list *getVarbinds(FILE * fp, struct varbind_list **retp); +static struct node *parse_trapDefinition(FILE * fp, char *name); +static struct node *parse_notificationDefinition(FILE * fp, char *name); +static struct node *parse_compliance(FILE * fp, char *name); +static int compliance_lookup(const char *name, int modid); +char *module_name(int modid, char *cp); +struct tree *find_tree_node(const char *name, int modid); +static int eat_syntax(FILE * fp, char *token, int maxtoken); +static struct node *parse_capabilities(FILE * fp, char *name); +static struct node *parse_moduleIdentity(FILE * fp, char *name); +static struct node *parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken); +static void parse_imports(FILE * fp); +static void check_utc(const char *utc); +static void print_module_not_found(const char *cp); +void print_subtree(FILE * f, struct tree *tree, int count); +static int parseQuoteString(FILE * fp, char *token, int maxtlen); +//end of forward function declearation-------------------------------------------- + +//TOP LAYER FUNCTION DEFINITIONS-------------------------------------------------------- +//Returns the root of the whole tree +struct tree *read_mib(const char *filename) +{ + FILE *fp; + char token[MAXTOKEN]; + + fp = fopen(filename, "r"); + if (fp == NULL) { +// snmp_log_perror(filename); + return NULL; + } + mibLine = 1; + File = filename; + get_token(fp, token, MAXTOKEN); + fclose(fp); + new_module(token, filename); + (void) read_module(token); + printf("Parsing MIB file: %s", filename); + printf(".........................................OK\n"); + + return tree_head; +} + +struct tree *read_module(const char *name) +{ + if (read_module_internal(name) == MODULE_NOT_FOUND) + print_error("Cannot find module", name, CONTINUE); + return tree_head; +} + +struct tree *get_tree(int *objid, int objidlen, struct tree *subtree) +{ + struct tree *return_tree = NULL; + + for (; subtree; subtree = subtree->next_peer) { + if (*objid == subtree->subid) + goto found; + } + + return NULL; + + found: + while (subtree->next_peer && subtree->next_peer->subid == *objid) + subtree = subtree->next_peer; + + if (objidlen > 1) + return_tree = + get_tree(objid + 1, objidlen - 1, subtree->child_list); + + if (return_tree != NULL) + return return_tree; + else + return subtree; +} +//END OF TOP LAYER FUNCTION DEFINITIONS------------------------------------------------- + +//support function definition----------------------------------------------------- +/* + * Parses a token from the file. The type of the token parsed is returned, + * and the text is placed in the string pointed to by token. + * Warning: this method may recurse. + */ +int get_token(FILE * fp, char *token, int maxtlen) +{ + register int ch, ch_next; + register char *cp = token; + register int hash = 0; + register struct tok *tp; + int too_long = 0; + + /* + * skip all white space + */ + do { + ch = getc(fp); + if (ch == '\n') + mibLine++; + } + while (isspace(ch) && ch != EOF); + *cp++ = ch; + *cp = '\0'; + switch (ch) { + case EOF: + return ENDOFFILE; + case '"': + return parseQuoteString(fp, token, maxtlen); + case '\'': /* binary or hex constant */ + while ((ch = getc(fp)) != EOF && ch != '\'' + && cp - token < maxtlen - 2) + *cp++ = ch; + if (ch == '\'') { + unsigned int val = 0; + *cp++ = '\''; + *cp++ = ch = getc(fp); + *cp = 0; + cp = token + 1; + switch (ch) { + case EOF: + return ENDOFFILE; + case 'b': + case 'B': + while ((ch = *cp++) != '\'') + if (ch != '0' && ch != '1') + return LABEL; + else + val = val * 2 + ch - '0'; + break; + case 'h': + case 'H': + while ((ch = *cp++) != '\'') + if ('0' <= ch && ch <= '9') + val = val * 16 + ch - '0'; + else if ('a' <= ch && ch <= 'f') + val = val * 16 + ch - 'a' + 10; + else if ('A' <= ch && ch <= 'F') + val = val * 16 + ch - 'A' + 10; + else + return LABEL; + break; + default: + return LABEL; + } + sprintf(token, "%ld", val); + return NUMBER; + } else + return LABEL; + case '(': + return LEFTPAREN; + case ')': + return RIGHTPAREN; + case '{': + return LEFTBRACKET; + case '}': + return RIGHTBRACKET; + case '[': + return LEFTSQBRACK; + case ']': + return RIGHTSQBRACK; + case ';': + return SEMI; + case ',': + return COMMA; + case '|': + return BAR; + case '.': + ch_next = getc(fp); + if (ch_next == '.') + return RANGE; + ungetc(ch_next, fp); + return LABEL; + case ':': + ch_next = getc(fp); + if (ch_next != ':') { + ungetc(ch_next, fp); + return LABEL; + } + ch_next = getc(fp); + if (ch_next != '=') { + ungetc(ch_next, fp); + return LABEL; + } + return EQUALS; + case '-': + ch_next = getc(fp); + if (ch_next == '-') { + #if 0 + if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, + NETSNMP_DS_LIB_MIB_COMMENT_TERM)) { + /* + * Treat the rest of this line as a comment. + */ + while ((ch_next != EOF) && (ch_next != '\n')) + ch_next = getc(fp); + } else + #endif + { + + /* + * Treat the rest of the line or until another '--' as a comment + */ + /* + * (this is the "technically" correct way to parse comments) + */ + ch = ' '; + ch_next = getc(fp); + while (ch_next != EOF && ch_next != '\n' && + (ch != '-' || ch_next != '-')) { + ch = ch_next; + ch_next = getc(fp); + } + } + if (ch_next == EOF) + return ENDOFFILE; + if (ch_next == '\n') + mibLine++; + return get_token(fp, token, maxtlen); + } + ungetc(ch_next, fp); + default: + /* + * Accumulate characters until end of token is found. Then attempt to + * match this token as a reserved word. If a match is found, return the + * type. Else it is a label. + */ + if (!is_labelchar(ch)) + return LABEL; + hash += tolower(ch); + more: + while (is_labelchar(ch_next = getc(fp))) { + hash += tolower(ch_next); + if (cp - token < maxtlen - 1) + *cp++ = ch_next; + else + too_long = 1; + } + ungetc(ch_next, fp); + *cp = '\0'; + + if (too_long) + print_error("Warning: token too long", token, CONTINUE); + for (tp = buckets[BUCKET(hash)]; tp; tp = tp->next) { + if ((tp->hash == hash) && (!label_compare(tp->name, token))) + break; + } + if (tp) { + if (tp->token != CONTINUE) + return (tp->token); + while (isspace((ch_next = getc(fp)))) + if (ch_next == '\n') + mibLine++; + if (ch_next == EOF) + return ENDOFFILE; + if (isalnum(ch_next)) { + *cp++ = ch_next; + hash += tolower(ch_next); + goto more; + } + } + if (token[0] == '-' || isdigit(token[0])) { + for (cp = token + 1; *cp; cp++) + if (!isdigit(*cp)) + return LABEL; + return NUMBER; + } + return LABEL; + } +} + +void new_module(const char *name, const char *file) +{ + struct module *mp; + + for (mp = module_head; mp; mp = mp->next) + if (!label_compare(mp->name, name)) + return; + + /* + * Add this module to the list + */ + mp = (struct module *) calloc(1, sizeof(struct module)); + if (mp == NULL) + return; + mp->name = strdup(name); + mp->file = strdup(file); + mp->imports = NULL; + mp->no_imports = -1; /* Not yet loaded */ + mp->modid = max_module; + ++max_module; + + mp->next = module_head; /* Or add to the *end* of the list? */ + module_head = mp; +} + +/* + * Read in the named module + * Returns the root of the whole tree + * (by analogy with 'read_mib') + */ +static int read_module_internal(const char *name) +{ + struct module *mp; + FILE *fp; + struct node *np; + + init_mib_internals(); + + for (mp = module_head; mp; mp = mp->next){ + if (!label_compare(mp->name, name)) { + const char *oldFile = File; + int oldLine = mibLine; + int oldModule = current_module; + + if (mp->no_imports != -1) { + return MODULE_ALREADY_LOADED; + } + if ((fp = fopen(mp->file, "r")) == NULL) { + printf("ERROR: can not open file: %s", mp->file); + return MODULE_LOAD_FAILED; + } + mp->no_imports = 0; /* Note that we've read the file */ + File = mp->file; + mibLine = 1; + current_module = mp->modid; + /* + * Parse the file + */ + // printf("Parsing MIB file: %s\n", mp->file); + np = parse(fp, NULL); + fclose(fp); + File = oldFile; + mibLine = oldLine; + current_module = oldModule; + return MODULE_LOADED_OK; + } + } + + return MODULE_NOT_FOUND; +} + +void init_mib_internals(void) +{ + register struct tok *tp; + register int b; +// int max_modc; + + if (tree_head) + return; + + /* + * Set up hash list of pre-defined tokens + */ + memset(buckets, 0, sizeof(buckets)); + for (tp = tokens; tp->name; tp++) { + tp->hash = name_hash(tp->name); + b = BUCKET(tp->hash); + if (buckets[b]) + tp->next = buckets[b]; /* BUG ??? */ + buckets[b] = tp; + } + + /* + * Initialise other internal structures + */ + memset(nbuckets, 0, sizeof(nbuckets)); + memset(tbuckets, 0, sizeof(tbuckets)); + memset(tclist, 0, MAXTC * sizeof(struct tc)); + build_translation_table(); + init_tree_roots(); /* Set up initial roots */ + /* + * Relies on 'add_mibdir' having set up the modules + */ +} + +static void init_tree_roots() +{ + struct tree *tp, *lasttp; + int base_modid; + int hash; + + base_modid = which_module("SNMPv2-SMI"); + + /* + * build root node + */ + tp = (struct tree *) calloc(1, sizeof(struct tree)); + if (tp == NULL) + return; + tp->label = strdup("joint-iso-ccitt"); + tp->modid = base_modid; + tp->number_modules = 1; + tp->module_list = &(tp->modid); + tp->subid = 2; + tp->oid[tp->oid_len++] = tp->subid; + tp->tc_index = -1; +// set_function(tp); /* from mib.c */ + hash = NBUCKET(name_hash(tp->label)); + tp->next = tbuckets[hash]; + tbuckets[hash] = tp; + lasttp = tp; + root_imports[0].label = strdup(tp->label); + root_imports[0].modid = base_modid; + + /* + * build root node + */ + tp = (struct tree *) calloc(1, sizeof(struct tree)); + if (tp == NULL) + return; + tp->next_peer = lasttp; + tp->label = strdup("ccitt"); + tp->modid = base_modid; + tp->number_modules = 1; + tp->module_list = &(tp->modid); + tp->subid = 0; + tp->oid[tp->oid_len++] = tp->subid; + tp->tc_index = -1; +// set_function(tp); /* from mib.c */ + hash = NBUCKET(name_hash(tp->label)); + tp->next = tbuckets[hash]; + tbuckets[hash] = tp; + lasttp = tp; + root_imports[1].label = strdup(tp->label); + root_imports[1].modid = base_modid; + + /* + * build root node + */ + tp = (struct tree *) calloc(1, sizeof(struct tree)); + if (tp == NULL) + return; + tp->next_peer = lasttp; + tp->label = strdup("iso"); + tp->modid = base_modid; + tp->number_modules = 1; + tp->module_list = &(tp->modid); + tp->subid = 1; + tp->oid[tp->oid_len++] = tp->subid; + tp->tc_index = -1; +// set_function(tp); /* from mib.c */ + hash = NBUCKET(name_hash(tp->label)); + tp->next = tbuckets[hash]; + tbuckets[hash] = tp; + lasttp = tp; + root_imports[2].label = strdup(tp->label); + root_imports[2].modid = base_modid; + + tree_head = tp; +} + +/* + * Parses a mib file and returns a linked list of nodes found in the file. + * Returns NULL on error. + */ +#define BETWEEN_MIBS 1 +#define IN_MIB 2 +static struct node *parse(FILE * fp, struct node *root) +{ + char token[MAXTOKEN]; + char name[MAXTOKEN]; + int type = LABEL; + int lasttype = LABEL; + int state = BETWEEN_MIBS; + struct node *np, *nnp; + struct objgroup *oldgroups = NULL, *oldobjects = NULL, *oldnotifs = + NULL; + +// if (last_err_module) +// free(last_err_module); +// last_err_module = 0; + + np = root; + if (np != NULL) { + /* + * now find end of chain + */ + while (np->next) + np = np->next; + } + + while (type != ENDOFFILE) { + if (lasttype == CONTINUE) + lasttype = type; + else + type = lasttype = get_token(fp, token, MAXTOKEN); + + switch (type) { + case END: + if (state != IN_MIB) { + print_error("Error, END before start of MIB", NULL, type); + return NULL; + } else { + struct module *mp; +#ifdef _TEST_ + printf("\nNodes for Module %s:\n", name); + print_nodes(stdout, root); +#endif + scan_objlist(root, objgroups, "Undefined OBJECT-GROUP"); + scan_objlist(root, objects, "Undefined OBJECT"); + scan_objlist(root, notifs, "Undefined NOTIFICATION"); + objgroups = oldgroups; + objects = oldobjects; + notifs = oldnotifs; + for (mp = module_head; mp; mp = mp->next) + if (mp->modid == current_module) + break; + do_linkup(mp, root); + np = root = NULL; + } + state = BETWEEN_MIBS; + continue; + case IMPORTS: + parse_imports(fp); + continue; + case EXPORTS: + while (type != SEMI && type != ENDOFFILE) + type = get_token(fp, token, MAXTOKEN); + continue; + case LABEL: + case INTEGER: + case INTEGER32: + case UINTEGER32: + case UNSIGNED32: + case COUNTER: + case COUNTER64: + case GAUGE: + case IPADDR: + case NETADDR: + case NSAPADDRESS: + case OBJSYNTAX: + case APPSYNTAX: + case SIMPLESYNTAX: + case OBJNAME: + case NOTIFNAME: + case KW_OPAQUE: + case TIMETICKS: + break; + case ENDOFFILE: + continue; + default: + strcpy(name, token); + type = get_token(fp, token, MAXTOKEN); + nnp = NULL; + if (type == MACRO) { + nnp = parse_macro(fp, name); + if (nnp == NULL) { + print_error("Bad parse of MACRO", NULL, type); + /* + * return NULL; + */ + } + free_node(nnp); /* IGNORE */ + nnp = NULL; + } else + print_error(name, "is a reserved word", lasttype); + continue; /* see if we can parse the rest of the file */ + } + strcpy(name, token); + type = get_token(fp, token, MAXTOKEN); + nnp = NULL; + + /* + * Handle obsolete method to assign an object identifier to a + * module + */ + if (lasttype == LABEL && type == LEFTBRACKET) { + while (type != RIGHTBRACKET && type != ENDOFFILE) + type = get_token(fp, token, MAXTOKEN); + if (type == ENDOFFILE) { + print_error("Expected \"}\"", token, type); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + } + + switch (type) { + case DEFINITIONS: + if (state != BETWEEN_MIBS) { + print_error("Error, nested MIBS", NULL, type); + return NULL; + } + state = IN_MIB; + current_module = which_module(name); + oldgroups = objgroups; + objgroups = NULL; + oldobjects = objects; + objects = NULL; + oldnotifs = notifs; + notifs = NULL; + if (current_module == -1) { + new_module(name, File); + current_module = which_module(name); + } + + while ((type = get_token(fp, token, MAXTOKEN)) != ENDOFFILE) + if (type == BEGIN) + break; + break; + case OBJTYPE: + nnp = parse_objecttype(fp, name); + if (nnp == NULL) { + print_error("Bad parse of OBJECT-TYPE", NULL, type); + return NULL; + } + break; + case OBJGROUP: + nnp = parse_objectgroup(fp, name, OBJECTS, &objects); + if (nnp == NULL) { + print_error("Bad parse of OBJECT-GROUP", NULL, type); + return NULL; + } + break; + case NOTIFGROUP: + nnp = parse_objectgroup(fp, name, NOTIFICATIONS, ¬ifs); + if (nnp == NULL) { + print_error("Bad parse of NOTIFICATION-GROUP", NULL, type); + return NULL; + } + break; + case TRAPTYPE: + nnp = parse_trapDefinition(fp, name); + if (nnp == NULL) { + print_error("Bad parse of TRAP-TYPE", NULL, type); + return NULL; + } + break; + case NOTIFTYPE: + nnp = parse_notificationDefinition(fp, name); + if (nnp == NULL) { + print_error("Bad parse of NOTIFICATION-TYPE", NULL, type); + return NULL; + } + break; + case COMPLIANCE: + nnp = parse_compliance(fp, name); + if (nnp == NULL) { + print_error("Bad parse of MODULE-COMPLIANCE", NULL, type); + return NULL; + } + break; + case AGENTCAP: + nnp = parse_capabilities(fp, name); + if (nnp == NULL) { + print_error("Bad parse of AGENT-CAPABILITIES", NULL, type); + return NULL; + } + break; + case MACRO: + nnp = parse_macro(fp, name); + if (nnp == NULL) { + print_error("Bad parse of MACRO", NULL, type); + /* + * return NULL; + */ + } + free_node(nnp); /* IGNORE */ + nnp = NULL; + break; + case MODULEIDENTITY: + nnp = parse_moduleIdentity(fp, name); + if (nnp == NULL) { + print_error("Bad parse of MODULE-IDENTITY", NULL, type); + return NULL; + } + break; + case OBJIDENTITY: + nnp = parse_objectgroup(fp, name, OBJECTS, &objects); + if (nnp == NULL) { + print_error("Bad parse of OBJECT-IDENTITY", NULL, type); + return NULL; + } + break; + case OBJECT: + type = get_token(fp, token, MAXTOKEN); + if (type != IDENTIFIER) { + print_error("Expected IDENTIFIER", token, type); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + if (type != EQUALS) { + print_error("Expected \"::=\"", token, type); + return NULL; + } + nnp = parse_objectid(fp, name); + if (nnp == NULL) { + print_error("Bad parse of OBJECT IDENTIFIER", NULL, type); + return NULL; + } + break; + case EQUALS: + nnp = parse_asntype(fp, name, &type, token); + lasttype = CONTINUE; + break; + case ENDOFFILE: + break; + default: + print_error("Bad operator", token, type); + return NULL; + } + if (nnp) { + if (np) + np->next = nnp; + else + np = root = nnp; + while (np->next) + np = np->next; + if (np->type == TYPE_OTHER) + np->type = type; + } + } + return root; +} + +static void scan_objlist(struct node *root, struct objgroup *list, const char *error) +{ + int oLine = mibLine; + + while (list) { + struct objgroup *gp = list; + struct node *np; + list = list->next; + np = root; + while (np) + if (label_compare(np->label, gp->name)) + np = np->next; + else + break; + if (!np) { + mibLine = gp->line; + print_error(error, gp->name, QUOTESTRING); + } + free(gp->name); + free(gp); + } + mibLine = oLine; +} + +static void do_linkup(struct module *mp, struct node *np) +{ + struct module_import *mip; + struct node *onp, *oldp, *newp; + struct tree *tp; + int i, more; + /* + * All modules implicitly import + * the roots of the tree + */ + if (mp->no_imports == 0) { + mp->no_imports = NUMBER_OF_ROOT_NODES; + mp->imports = root_imports; + } + + /* + * Build the tree + */ + init_node_hash(np); + for (i = 0, mip = mp->imports; i < mp->no_imports; ++i, ++mip) { + char modbuf[256]; + if (get_tc_index(mip->label, mip->modid) != -1) + continue; + tp = find_tree_node(mip->label, mip->modid); + if (!tp) { + printf("Did not find '%s' in module %s (%s)\n", + mip->label, module_name(mip->modid, modbuf),File); + continue; + } + do_subtree(tp, &np); + } + + /* + * If any nodes left over, + * check that they're not the result of a "fully qualified" + * name, and then add them to the list of orphans + */ + + if (!np) + return; + for (tp = tree_head; tp; tp = tp->next_peer) + do_subtree(tp, &np); + if (!np) + return; + + /* + * quietly move all internal references to the orphan list + */ + oldp = orphan_nodes; + do { + for (i = 0; i < NHASHSIZE; i++) + for (onp = nbuckets[i]; onp; onp = onp->next) { + struct node *op = NULL; + int hash = NBUCKET(name_hash(onp->label)); + np = nbuckets[hash]; + while (np) { + if (label_compare(onp->label, np->parent)) { + op = np; + np = np->next; + } else { + if (op) + op->next = np->next; + else + nbuckets[hash] = np->next; + np->next = orphan_nodes; + orphan_nodes = np; + op = NULL; + np = nbuckets[hash]; + } + } + } + newp = orphan_nodes; + more = 0; + for (onp = orphan_nodes; onp != oldp; onp = onp->next) { + struct node *op = NULL; + int hash = NBUCKET(name_hash(onp->label)); + np = nbuckets[hash]; + while (np) { + if (label_compare(onp->label, np->parent)) { + op = np; + np = np->next; + } else { + if (op) + op->next = np->next; + else + nbuckets[hash] = np->next; + np->next = orphan_nodes; + orphan_nodes = np; + op = NULL; + np = nbuckets[hash]; + more = 1; + } + } + } + oldp = newp; + } while (more); + + /* + * complain about left over nodes + */ + for (np = orphan_nodes; np && np->next; np = np->next); /* find the end of the orphan list */ + for (i = 0; i < NHASHSIZE; i++) + if (nbuckets[i]) { + if (orphan_nodes) + onp = np->next = nbuckets[i]; + else + onp = orphan_nodes = nbuckets[i]; + nbuckets[i] = NULL; + while (onp) { + printf("Unlinked OID in %s: %s ::= { %s %d }\n", + (mp->name ? mp->name : ""), + (onp->label ? onp->label : ""), + (onp->parent ? onp->parent : ""), + onp->subid); + printf("Undefined identifier: %s near line %d of %s\n", + (onp->parent ? onp->parent : ""), + onp->lineno, onp->filename); + np = onp; + onp = onp->next; + } + } + return; +} + +/* + * Find all the children of root in the list of nodes. Link them into the + * tree and out of the nodes list. + */ +static void do_subtree(struct tree *root, struct node **nodes) +{ + struct tree *tp, *anon_tp = NULL; + struct tree *xroot = root; + struct node *np, **headp; + struct node *oldnp = NULL, *child_list = NULL, *childp = NULL; + int hash; + int *int_p; + + while (xroot->next_peer && xroot->next_peer->subid == root->subid) { + xroot = xroot->next_peer; + } + + tp = root; + headp = &nbuckets[NBUCKET(name_hash(tp->label))]; + /* + * Search each of the nodes for one whose parent is root, and + * move each into a separate list. + */ + for (np = *headp; np; np = np->next) { + if (!label_compare(tp->label, np->parent)) { + /* + * take this node out of the node list + */ + if (oldnp == NULL) { + *headp = np->next; /* fix root of node list */ + } else { + oldnp->next = np->next; /* link around this node */ + } + if (child_list) + childp->next = np; + else + child_list = np; + childp = np; + } else { + oldnp = np; + } + + } + if (childp) + childp->next = NULL; + /* + * Take each element in the child list and place it into the tree. + */ + for (np = child_list; np; np = np->next) { + struct tree *otp = NULL; + struct tree *xxroot = xroot; + anon_tp = NULL; + tp = xroot->child_list; + + if (np->subid == -1) { + /* + * name ::= { parent } + */ + np->subid = xroot->subid; + tp = xroot; + xxroot = xroot->parent; + } + + while (tp) { + if (tp->subid == np->subid) + break; + else { + otp = tp; + tp = tp->next_peer; + } + } + if (tp) { + if (!label_compare(tp->label, np->label)) { + /* + * Update list of modules + */ + int_p = + (int *) malloc((tp->number_modules + 1) * sizeof(int)); + if (int_p == NULL) + return; + memcpy(int_p, tp->module_list, + tp->number_modules * sizeof(int)); + int_p[tp->number_modules] = np->modid; + if (tp->number_modules > 1) + free((char *) tp->module_list); + ++tp->number_modules; + tp->module_list = int_p; + + /* + * Handle children + */ + do_subtree(tp, nodes); + continue; + } + if (!strncmp(np->label, ANON, ANON_LEN) || + !strncmp(tp->label, ANON, ANON_LEN)) { + anon_tp = tp; /* Need to merge these two trees later */ + } + } + + tp = (struct tree *) calloc(1, sizeof(struct tree)); + if (tp == NULL) + return; + tp->parent = xxroot; + tp->modid = np->modid; + tp->number_modules = 1; + tp->module_list = &(tp->modid); + tree_from_node(tp, np); + tp->next_peer = otp ? otp->next_peer : xxroot->child_list; + if (otp) + otp->next_peer = tp; + else + xxroot->child_list = tp; + hash = NBUCKET(name_hash(tp->label)); + tp->next = tbuckets[hash]; + tbuckets[hash] = tp; + do_subtree(tp, nodes); + + if (anon_tp) { + if (!strncmp(tp->label, ANON, ANON_LEN)) { + /* + * The new node is anonymous, + * so merge it with the existing one. + */ + merge_anon_children(tp, anon_tp); + + /* + * unlink and destroy tp + */ + unlink_tree(tp); + free_tree(tp); + } else if (!strncmp(anon_tp->label, ANON, ANON_LEN)) { + struct tree *ntp; + /* + * The old node was anonymous, + * so merge it with the existing one, + * and fill in the full information. + */ + merge_anon_children(anon_tp, tp); + + /* + * unlink anon_tp from the hash + */ + unlink_tbucket(anon_tp); + + /* + * get rid of old contents of anon_tp + */ + free_partial_tree(anon_tp, FALSE); + + /* + * put in the current information + */ + anon_tp->label = tp->label; + anon_tp->child_list = tp->child_list; + anon_tp->modid = tp->modid; + anon_tp->tc_index = tp->tc_index; + anon_tp->type = tp->type; + anon_tp->enums = tp->enums; + anon_tp->indexes = tp->indexes; + anon_tp->augments = tp->augments; + anon_tp->varbinds = tp->varbinds; + anon_tp->ranges = tp->ranges; + anon_tp->hint = tp->hint; + anon_tp->units = tp->units; + anon_tp->description = tp->description; + anon_tp->reference = tp->reference; + anon_tp->defaultValue = tp->defaultValue; + anon_tp->parent = tp->parent; + + // set_function(anon_tp); + + /* + * update parent pointer in moved children + */ + ntp = anon_tp->child_list; + while (ntp) { + ntp->parent = anon_tp; + ntp = ntp->next_peer; + } + + /* + * hash in anon_tp in its new place + */ + hash = NBUCKET(name_hash(anon_tp->label)); + anon_tp->next = tbuckets[hash]; + tbuckets[hash] = anon_tp; + + /* + * unlink and destroy tp + */ + unlink_tbucket(tp); + unlink_tree(tp); + free(tp); + } + anon_tp = NULL; + } + } + /* + * free all nodes that were copied into tree + */ + oldnp = NULL; + for (np = child_list; np; np = np->next) { + if (oldnp) + free_node(oldnp); + oldnp = np; + } + if (oldnp) + free_node(oldnp); +} + +static void merge_anon_children(struct tree *tp1, struct tree *tp2) +/* + * NB: tp1 is the 'anonymous' node + */ +{ + struct tree *child1, *child2, *previous; + + for (child1 = tp1->child_list; child1;) { + + for (child2 = tp2->child_list, previous = NULL; + child2; previous = child2, child2 = child2->next_peer) { + + if (child1->subid == child2->subid) { + /* + * Found 'matching' children, + * so merge them + */ + if (!strncmp(child1->label, ANON, ANON_LEN)) { + merge_anon_children(child1, child2); + + child1->child_list = NULL; + previous = child1; /* Finished with 'child1' */ + child1 = child1->next_peer; + free_tree(previous); + goto next; + } + + else if (!strncmp(child2->label, ANON, ANON_LEN)) { + merge_anon_children(child2, child1); + + if (previous) + previous->next_peer = child2->next_peer; + else + tp2->child_list = child2->next_peer; + free_tree(child2); + + previous = child1; /* Move 'child1' to 'tp2' */ + child1 = child1->next_peer; + previous->next_peer = tp2->child_list; + tp2->child_list = previous; + for (previous = tp2->child_list; + previous; previous = previous->next_peer) + previous->parent = tp2; + goto next; + } else if (!label_compare(child1->label, child2->label)) { + continue; + } else { + /* + * Two copies of the same node. + * 'child2' adopts the children of 'child1' + */ + + if (child2->child_list) { + for (previous = child2->child_list; previous->next_peer; previous = previous->next_peer); /* Find the end of the list */ + previous->next_peer = child1->child_list; + } else + child2->child_list = child1->child_list; + for (previous = child1->child_list; + previous; previous = previous->next_peer) + previous->parent = child2; + child1->child_list = NULL; + + previous = child1; /* Finished with 'child1' */ + child1 = child1->next_peer; + free_tree(previous); + goto next; + } + } + } + /* + * If no match, move 'child1' to 'tp2' child_list + */ + if (child1) { + previous = child1; + child1 = child1->next_peer; + previous->parent = tp2; + previous->next_peer = tp2->child_list; + tp2->child_list = previous; + } + next:; + } +} + +/* + * Parses a MACRO definition + * Expect BEGIN, discard everything to end. + * Returns 0 on error. + */ +static struct node *parse_macro(FILE * fp, char *name) +{ + register int type; + char token[MAXTOKEN]; + struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, sizeof(token)); + while (type != EQUALS && type != ENDOFFILE) { + type = get_token(fp, token, sizeof(token)); + } + if (type != EQUALS) { + if (np) + free_node(np); + return NULL; + } + while (type != BEGIN && type != ENDOFFILE) { + type = get_token(fp, token, sizeof(token)); + } + if (type != BEGIN) { + if (np) + free_node(np); + return NULL; + } + while (type != END && type != ENDOFFILE) { + type = get_token(fp, token, sizeof(token)); + } + if (type != END) { + if (np) + free_node(np); + return NULL; + } + +// printf("%s MACRO (lines %d..%d parsed and ignored).\n", name,iLine, mibLine); + + return np; +} + +/* + * Parses an enumeration list of the form: + * { label(value) label(value) ... } + * The initial { has already been parsed. + * Returns NULL on error. + */ +static struct enum_list *parse_enumlist(FILE * fp, struct enum_list **retp) +{ + register int type; + char token[MAXTOKEN]; + struct enum_list *ep = NULL, **epp = &ep; + + free_enums(retp); + + while ((type = get_token(fp, token, MAXTOKEN)) != ENDOFFILE) { + if (type == RIGHTBRACKET) + break; + if (type == LABEL) { + /* + * this is an enumerated label + */ + *epp = + (struct enum_list *) calloc(1, sizeof(struct enum_list)); + if (*epp == NULL) + return (NULL); + /* + * a reasonable approximation for the length + */ + (*epp)->label = strdup(token); + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTPAREN) { + print_error("Expected \"(\"", token, type); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + if (type != NUMBER) { + print_error("Expected integer", token, type); + return NULL; + } + (*epp)->value = strtol(token, NULL, 10); + type = get_token(fp, token, MAXTOKEN); + if (type != RIGHTPAREN) { + print_error("Expected \")\"", token, type); + return NULL; + } + epp = &(*epp)->next; + } + } + if (type == ENDOFFILE) { + print_error("Expected \"}\"", token, type); + return NULL; + } + *retp = ep; + return ep; +} + +static struct range_list *parse_ranges(FILE * fp, struct range_list **retp) +{ + int low, high; + char nexttoken[MAXTOKEN]; + int nexttype; + struct range_list *rp = NULL, **rpp = &rp; + int size = 0, taken = 1; + + free_ranges(retp); + + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == SIZE) { + size = 1; + taken = 0; + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype != LEFTPAREN) + print_error("Expected \"(\" after SIZE", nexttoken, nexttype); + } + + do { + if (!taken) + nexttype = get_token(fp, nexttoken, MAXTOKEN); + else + taken = 0; + high = low = strtol(nexttoken, NULL, 10); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == RANGE) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + errno = 0; + high = strtol(nexttoken, NULL, 10); + if ( errno == ERANGE ) { + printf("Warning: Upper bound not handled correctly (%s != %d): At line %d in %s\n", + nexttoken, high, mibLine, File); + } + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } + *rpp = (struct range_list *) calloc(1, sizeof(struct range_list)); + if (*rpp == NULL) + break; + (*rpp)->low = low; + (*rpp)->high = high; + rpp = &(*rpp)->next; + + } while (nexttype == BAR); + if (size) { + if (nexttype != RIGHTPAREN) + print_error("Expected \")\" after SIZE", nexttoken, nexttype); + nexttype = get_token(fp, nexttoken, nexttype); + } + if (nexttype != RIGHTPAREN) + print_error("Expected \")\"", nexttoken, nexttype); + + *retp = rp; + return rp; +} + +/* + * Parses a module import clause + * loading any modules referenced + */ +#define MAX_IMPORTS 256 +static void parse_imports(FILE * fp) +{ + register int type; + char token[MAXTOKEN]; + char modbuf[256]; + struct module_import import_list[MAX_IMPORTS]; + int this_module; + struct module *mp; + + int import_count = 0; /* Total number of imported descriptors */ + int i = 0, old_i; /* index of first import from each module */ + + type = get_token(fp, token, MAXTOKEN); + + /* + * Parse the IMPORTS clause + */ + while (type != SEMI && type != ENDOFFILE) { + if (type == LABEL) { + if (import_count == MAX_IMPORTS) { + print_error("Too many imported symbols", token, type); + do { + type = get_token(fp, token, MAXTOKEN); + } while (type != SEMI && type != ENDOFFILE); + return; + } + import_list[import_count++].label = strdup(token); + } else if (type == FROM) { + type = get_token(fp, token, MAXTOKEN); + if (import_count == i) { /* All imports are handled internally */ + type = get_token(fp, token, MAXTOKEN); + continue; + } + this_module = which_module(token); + + for (old_i = i; i < import_count; ++i) + import_list[i].modid = this_module; + + /* + * Recursively read any pre-requisite modules + */ + if (read_module_internal(token) == MODULE_NOT_FOUND) { + int found = 0; +// for (; old_i < import_count; ++old_i) { +// found += read_import_replacements(token, &import_list[old_i]); +// } + if (!found) + print_module_not_found(token); + } + } + type = get_token(fp, token, MAXTOKEN); + } + + /* + * Save the import information + * in the global module table + */ + for (mp = module_head; mp; mp = mp->next) + if (mp->modid == current_module) { + if (import_count == 0) + return; + if (mp->imports && (mp->imports != root_imports)) { + /* + * this can happen if all modules are in one source file. + */ + for (i = 0; i < mp->no_imports; ++i) { + free((char *) mp->imports[i].label); + } + free((char *) mp->imports); + } + mp->imports = (struct module_import *) + calloc(import_count, sizeof(struct module_import)); + if (mp->imports == NULL) + return; + for (i = 0; i < import_count; ++i) { + mp->imports[i].label = import_list[i].label; + mp->imports[i].modid = import_list[i].modid; + } + mp->no_imports = import_count; + return; + } + + /* + * Shouldn't get this far + */ + print_module_not_found(module_name(current_module, modbuf)); + return; +} + +/* + * Parses an OBJECT TYPE macro. + * Returns 0 on error. + */ +static struct node *parse_objecttype(FILE * fp, char *name) +{ + register int type; + char token[MAXTOKEN]; + char nexttoken[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + int nexttype, tctype; + register struct node *np; + + type = get_token(fp, token, MAXTOKEN); + if (type != SYNTAX) { + print_error("Bad format for OBJECT-TYPE", token, type); + return NULL; + } + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + if (type == OBJECT) { + type = get_token(fp, token, MAXTOKEN); + if (type != IDENTIFIER) { + print_error("Expected IDENTIFIER", token, type); + free_node(np); + return NULL; + } + type = OBJID; + } + if (type == LABEL) { + int tmp_index; + tctype = get_tc(token, current_module, &tmp_index, + &np->enums, &np->ranges, &np->hint); + type = tctype; + np->tc_index = tmp_index; /* store TC for later reference */ + } + np->type = type; + nexttype = get_token(fp, nexttoken, MAXTOKEN); + switch (type) { + case SEQUENCE: + if (nexttype == OF) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } + break; + case INTEGER: + case INTEGER32: + case UINTEGER32: + case UNSIGNED32: + case COUNTER: + case GAUGE: + case BITSTRING: + case LABEL: + if (nexttype == LEFTBRACKET) { + /* + * if there is an enumeration list, parse it + */ + np->enums = parse_enumlist(fp, &np->enums); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } else if (nexttype == LEFTPAREN) { + /* + * if there is a range list, parse it + */ + np->ranges = parse_ranges(fp, &np->ranges); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } + break; + case OCTETSTR: + case KW_OPAQUE: + /* + * parse any SIZE specification + */ + if (nexttype == LEFTPAREN) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == SIZE) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == LEFTPAREN) { + np->ranges = parse_ranges(fp, &np->ranges); + nexttype = get_token(fp, nexttoken, MAXTOKEN); /* ) */ + if (nexttype == RIGHTPAREN) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + break; + } + } + } + print_error("Bad SIZE syntax", token, type); + free_node(np); + return NULL; + } + break; + case OBJID: + case NETADDR: + case IPADDR: + case TIMETICKS: + case NUL: + case NSAPADDRESS: + case COUNTER64: + break; + default: + print_error("Bad syntax", token, type); + free_node(np); + return NULL; + } + if (nexttype == UNITS) { + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad UNITS", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->units = strdup(quoted_string_buffer); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } + if (nexttype != ACCESS) { + print_error("Should be ACCESS", nexttoken, nexttype); + free_node(np); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + if (type != READONLY && type != READWRITE && type != WRITEONLY + && type != NOACCESS && type != READCREATE && type != ACCNOTIFY) { + print_error("Bad ACCESS type", token, type); + free_node(np); + return NULL; + } + np->access = type; + type = get_token(fp, token, MAXTOKEN); + if (type != STATUS) { + print_error("Should be STATUS", token, type); + free_node(np); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + if (type != MANDATORY && type != CURRENT && type != KW_OPTIONAL && + type != OBSOLETE && type != DEPRECATED) { + print_error("Bad STATUS", token, type); + free_node(np); + return NULL; + } + np->status = type; + /* + * Optional parts of the OBJECT-TYPE macro + */ + type = get_token(fp, token, MAXTOKEN); + while (type != EQUALS && type != ENDOFFILE) { + switch (type) { + case DESCRIPTION: + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->description = strdup(quoted_string_buffer); + break; + + case REFERENCE: + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->reference = strdup(quoted_string_buffer); + break; + case INDEX: + if (np->augments) { + print_error("Cannot have both INDEX and AUGMENTS", token, + type); + free_node(np); + return NULL; + } + np->indexes = getIndexes(fp, &np->indexes); + if (np->indexes == NULL) { + print_error("Bad INDEX list", token, type); + free_node(np); + return NULL; + } + break; + case AUGMENTS: + if (np->indexes) { + print_error("Cannot have both INDEX and AUGMENTS", token, + type); + free_node(np); + return NULL; + } + np->indexes = getIndexes(fp, &np->indexes); + if (np->indexes == NULL) { + print_error("Bad AUGMENTS list", token, type); + free_node(np); + return NULL; + } + np->augments = strdup(np->indexes->ilabel); + free_indexes(&np->indexes); + break; + case DEFVAL: + /* + * Mark's defVal section + */ + type = get_token(fp, quoted_string_buffer, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Bad DEFAULTVALUE", quoted_string_buffer, + type); + free_node(np); + return NULL; + } + + { + int level = 1; + char defbuf[512]; + + defbuf[0] = 0; + while (1) { + type = get_token(fp, quoted_string_buffer, MAXTOKEN); + if ((type == RIGHTBRACKET && --level == 0) + || type == ENDOFFILE) + break; + else if (type == LEFTBRACKET) + level++; + if (type == QUOTESTRING) { + if (strlen(defbuf)+2 < sizeof(defbuf)) { + defbuf[ strlen(defbuf)+2 ] = 0; + defbuf[ strlen(defbuf)+1 ] = '"'; + defbuf[ strlen(defbuf) ] = '\\'; + } + defbuf[ sizeof(defbuf)-1 ] = 0; + } + strncat(defbuf, quoted_string_buffer, + sizeof(defbuf)-strlen(defbuf)); + defbuf[ sizeof(defbuf)-1 ] = 0; + if (type == QUOTESTRING) { + if (strlen(defbuf)+2 < sizeof(defbuf)) { + defbuf[ strlen(defbuf)+2 ] = 0; + defbuf[ strlen(defbuf)+1 ] = '"'; + defbuf[ strlen(defbuf) ] = '\\'; + } + defbuf[ sizeof(defbuf)-1 ] = 0; + } + if (strlen(defbuf)+1 < sizeof(defbuf)) { + defbuf[ strlen(defbuf)+1 ] = 0; + defbuf[ strlen(defbuf) ] = ' '; + } + } + + if (type != RIGHTBRACKET) { + print_error("Bad DEFAULTVALUE", quoted_string_buffer, + type); + free_node(np); + return NULL; + } + + defbuf[strlen(defbuf) - 1] = 0; + np->defaultValue = strdup(defbuf); + } + + break; + + case NUM_ENTRIES: + if (tossObjectIdentifier(fp) != OBJID) { + print_error("Bad Object Identifier", token, type); + free_node(np); + return NULL; + } + break; + + default: + print_error("Bad format of optional clauses", token, type); + free_node(np); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + } + if (type != EQUALS) { + print_error("Bad format", token, type); + free_node(np); + return NULL; + } + return merge_parse_objectid(np, fp, name); +} + +/* + * Parse a sequence of object subidentifiers for the given name. + * The "label OBJECT IDENTIFIER ::=" portion has already been parsed. + * + * The majority of cases take this form : + * label OBJECT IDENTIFIER ::= { parent 2 } + * where a parent label and a child subidentifier number are specified. + * + * Variations on the theme include cases where a number appears with + * the parent, or intermediate subidentifiers are specified by label, + * by number, or both. + * + * Here are some representative samples : + * internet OBJECT IDENTIFIER ::= { iso org(3) dod(6) 1 } + * mgmt OBJECT IDENTIFIER ::= { internet 2 } + * rptrInfoHealth OBJECT IDENTIFIER ::= { snmpDot3RptrMgt 0 4 } + * + * Here is a very rare form : + * iso OBJECT IDENTIFIER ::= { 1 } + * + * Returns NULL on error. When this happens, memory may be leaked. + */ +static struct node *parse_objectid(FILE * fp, char *name) +{ + register int count; + register struct subid_s *op, *nop; + int length; + struct subid_s loid[32]; + struct node *np, *root = NULL, *oldnp = NULL; + struct tree *tp; + + if ((length = getoid(fp, loid, 32)) == 0) { + print_error("Bad object identifier", NULL, CONTINUE); + return NULL; + } + + /* + * Handle numeric-only object identifiers, + * by labelling the first sub-identifier + */ + op = loid; + if (!op->label) { + if (length == 1) { + print_error("Attempt to define a root oid", name, OBJECT); + return NULL; + } + for (tp = tree_head; tp; tp = tp->next_peer) + if ((int) tp->subid == op->subid) { + op->label = strdup(tp->label); + break; + } + } + + /* + * Handle "label OBJECT-IDENTIFIER ::= { subid }" + */ + if (length == 1) { + op = loid; + np = alloc_node(op->modid); + if (np == NULL) + return (NULL); + np->subid = op->subid; + np->label = strdup(name); + np->parent = op->label; + return np; + } + + /* + * For each parent-child subid pair in the subid array, + * create a node and link it into the node list. + */ + for (count = 0, op = loid, nop = loid + 1; count < (length - 1); + count++, op++, nop++) { + /* + * every node must have parent's name and child's name or number + */ + /* + * XX the next statement is always true -- does it matter ?? + */ + if (op->label && (nop->label || (nop->subid != -1))) { + np = alloc_node(nop->modid); + if (np == NULL) + return (NULL); + if (root == NULL) + root = np; + + np->parent = strdup(op->label); + if (count == (length - 2)) { + /* + * The name for this node is the label for this entry + */ + np->label = strdup(name); + } else { + if (!nop->label) { + nop->label = (char *) malloc(20 + ANON_LEN); + if (nop->label == NULL) + return (NULL); + sprintf(nop->label, "%s%d", ANON, anonymous++); + } + np->label = strdup(nop->label); + } + if (nop->subid != -1) + np->subid = nop->subid; + else + print_error("Warning: This entry is pretty silly", + np->label, CONTINUE); + + /* + * set up next entry + */ + if (oldnp) + oldnp->next = np; + oldnp = np; + } /* end if(op->label... */ + } + + /* + * free the loid array + */ + for (count = 0, op = loid; count < length; count++, op++) { + if (op->label) + free(op->label); + } + + return root; +} + +/* + * Parses an OBJECT GROUP macro. + * Returns 0 on error. + * + * Also parses object-identity, since they are similar (ignore STATUS). + * - WJH 10/96 + */ +static struct node *parse_objectgroup(FILE * fp, char *name, int what, struct objgroup **ol) +{ + int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + if (type == what) { + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Expected \"{\"", token, type); + goto skip; + } + do { + struct objgroup *o; + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad identifier", token, type); + goto skip; + } + o = (struct objgroup *) malloc(sizeof(struct objgroup)); + if (!o) { + print_error("Resource failure", token, type); + goto skip; + } + o->line = mibLine; + o->name = strdup(token); + o->next = *ol; + *ol = o; + type = get_token(fp, token, MAXTOKEN); + } while (type == COMMA); + if (type != RIGHTBRACKET) { + print_error("Expected \"}\" after list", token, type); + goto skip; + } + type = get_token(fp, token, type); + } + if (type != STATUS) { + print_error("Expected STATUS", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != CURRENT && type != DEPRECATED && type != OBSOLETE) { + print_error("Bad STATUS value", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->description = strdup(quoted_string_buffer); + type = get_token(fp, token, MAXTOKEN); + if (type == REFERENCE) { + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->reference = strdup(quoted_string_buffer); + type = get_token(fp, token, MAXTOKEN); + } + if (type != EQUALS) + print_error("Expected \"::=\"", token, type); + skip: + while (type != EQUALS && type != ENDOFFILE) + type = get_token(fp, token, MAXTOKEN); + + return merge_parse_objectid(np, fp, name); +} + +static int parseQuoteString(FILE * fp, char *token, int maxtlen) +{ + register int ch; + int count = 0; + int too_long = 0; + char *token_start = token; + + for (ch = getc(fp); ch != EOF; ch = getc(fp)) { + if (ch == '\r') + continue; + if (ch == '\n') { + mibLine++; + } else if (ch == '"') { + *token = '\0'; + if (too_long) + { + /* + * show short form for brevity sake + */ + char ch_save = *(token_start + 50); + *(token_start + 50) = '\0'; + print_error("Warning: string too long", + token_start, QUOTESTRING); + *(token_start + 50) = ch_save; + } + return QUOTESTRING; + } + /* + * maximum description length check. If greater, keep parsing + * but truncate the string + */ + if (++count < maxtlen) + *token++ = ch; + else + too_long = 1; + } + + return 0; +} + +/* + * Parses a TRAP-TYPE macro. + * Returns 0 on error. + */ +static struct node *parse_trapDefinition(FILE * fp, char *name) +{ + register int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + register struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + while (type != EQUALS && type != ENDOFFILE) { + switch (type) { + case DESCRIPTION: + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->description = strdup(quoted_string_buffer); + break; + case REFERENCE: + /* I'm not sure REFERENCEs are legal in smiv1 traps??? */ + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->reference = strdup(quoted_string_buffer); + break; + case ENTERPRISE: + type = get_token(fp, token, MAXTOKEN); + if (type == LEFTBRACKET) { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad Trap Format", token, type); + free_node(np); + return NULL; + } + np->parent = strdup(token); + /* + * Get right bracket + */ + type = get_token(fp, token, MAXTOKEN); + } else if (type == LABEL) + np->parent = strdup(token); + break; + case VARIABLES: + np->varbinds = getVarbinds(fp, &np->varbinds); + if (!np->varbinds) { + print_error("Bad VARIABLES list", token, type); + free_node(np); + return NULL; + } + break; + default: + /* + * NOTHING + */ + break; + } + type = get_token(fp, token, MAXTOKEN); + } + type = get_token(fp, token, MAXTOKEN); + + np->label = strdup(name); + + if (type != NUMBER) { + print_error("Expected a Number", token, type); + free_node(np); + return NULL; + } + np->subid = strtoul(token, NULL, 10); + np->next = alloc_node(current_module); + if (np->next == NULL) { + free_node(np); + return (NULL); + } + np->next->parent = np->parent; + np->parent = (char *) malloc(strlen(np->parent) + 2); + if (np->parent == NULL) { + free_node(np->next); + free_node(np); + return (NULL); + } + strcpy(np->parent, np->next->parent); + strcat(np->parent, "#"); + np->next->label = strdup(np->parent); + return np; +} + +/* + * Parses a NOTIFICATION-TYPE macro. + * Returns 0 on error. + */ +static struct node *parse_notificationDefinition(FILE * fp, char *name) +{ + register int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + register struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + while (type != EQUALS && type != ENDOFFILE) { + switch (type) { + case DESCRIPTION: + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->description = strdup(quoted_string_buffer); + break; + case REFERENCE: + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", quoted_string_buffer, type); + free_node(np); + return NULL; + } + np->reference = strdup(quoted_string_buffer); + break; + case OBJECTS: + np->varbinds = getVarbinds(fp, &np->varbinds); + if (!np->varbinds) { + print_error("Bad OBJECTS list", token, type); + free_node(np); + return NULL; + } + break; + default: + /* + * NOTHING + */ + break; + } + type = get_token(fp, token, MAXTOKEN); + } + return merge_parse_objectid(np, fp, name); +} + +static struct node *parse_compliance(FILE * fp, char *name) +{ + int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + if (type != STATUS) { + print_error("Expected STATUS", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != CURRENT && type != DEPRECATED && type != OBSOLETE) { + print_error("Bad STATUS", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + goto skip; + } + np->description = strdup(quoted_string_buffer); + type = get_token(fp, token, MAXTOKEN); + if (type == REFERENCE) { + type = get_token(fp, quoted_string_buffer, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", quoted_string_buffer, type); + goto skip; + } + np->reference = strdup(quoted_string_buffer); + type = get_token(fp, token, MAXTOKEN); + } + if (type != MODULE) { + print_error("Expected MODULE", token, type); + goto skip; + } + while (type == MODULE) { + int modid = -1; + char modname[MAXTOKEN]; + type = get_token(fp, token, MAXTOKEN); + if (type == LABEL + && strcmp(token, module_name(current_module, modname))) { + modid = read_module_internal(token); + if (modid != MODULE_LOADED_OK + && modid != MODULE_ALREADY_LOADED) { + print_error("Unknown module", token, type); + goto skip; + } + modid = which_module(token); + type = get_token(fp, token, MAXTOKEN); + } + if (type == MANDATORYGROUPS) { + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Expected \"{\"", token, type); + goto skip; + } + do { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad group name", token, type); + goto skip; + } + if (!compliance_lookup(token, modid)) + print_error("Unknown group", token, type); + type = get_token(fp, token, MAXTOKEN); + } while (type == COMMA); + if (type != RIGHTBRACKET) { + print_error("Expected \"}\"", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + while (type == GROUP || type == OBJECT) { + if (type == GROUP) { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad group name", token, type); + goto skip; + } + if (!compliance_lookup(token, modid)) + print_error("Unknown group", token, type); + type = get_token(fp, token, MAXTOKEN); + } else { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad object name", token, type); + goto skip; + } + if (!compliance_lookup(token, modid)) + print_error("Unknown group", token, type); + type = get_token(fp, token, MAXTOKEN); + if (type == SYNTAX) + type = eat_syntax(fp, token, MAXTOKEN); + if (type == WRSYNTAX) + type = eat_syntax(fp, token, MAXTOKEN); + if (type == MINACCESS) { + type = get_token(fp, token, MAXTOKEN); + if (type != NOACCESS && type != ACCNOTIFY + && type != READONLY && type != WRITEONLY + && type != READCREATE && type != READWRITE) { + print_error("Bad MIN-ACCESS spec", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + } + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + } + skip: + while (type != EQUALS && type != ENDOFFILE) + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + + return merge_parse_objectid(np, fp, name); +} + +/* + * Parses a capabilities macro + * Returns 0 on error. + */ +static struct node *parse_capabilities(FILE * fp, char *name) +{ + int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + if (type != PRODREL) { + print_error("Expected PRODUCT-RELEASE", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Expected STRING after PRODUCT-RELEASE", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != STATUS) { + print_error("Expected STATUS", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != CURRENT && type != OBSOLETE) { + print_error("STATUS should be current or obsolete", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", token, type); + goto skip; + } + np->description = strdup(token); + type = get_token(fp, token, MAXTOKEN); + if (type == REFERENCE) { + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad REFERENCE", token, type); + goto skip; + } + np->reference = strdup(token); + type = get_token(fp, token, type); + } + while (type == SUPPORTS) { + int modid; + struct tree *tp; + + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad module name", token, type); + goto skip; + } + modid = read_module_internal(token); + if (modid != MODULE_LOADED_OK && modid != MODULE_ALREADY_LOADED) { + print_error("Module not found", token, type); + goto skip; + } + modid = which_module(token); + type = get_token(fp, token, MAXTOKEN); + if (type != INCLUDES) { + print_error("Expected INCLUDES", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Expected \"{\"", token, type); + goto skip; + } + do { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Expected group name", token, type); + goto skip; + } + tp = find_tree_node(token, modid); + if (!tp) + print_error("Group not found in module", token, type); + type = get_token(fp, token, MAXTOKEN); + } while (type == COMMA); + if (type != RIGHTBRACKET) { + print_error("Expected \"}\" after group list", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + while (type == VARIATION) { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad object name", token, type); + goto skip; + } + tp = find_tree_node(token, modid); + if (!tp) + print_error("Object not found in module", token, type); + type = get_token(fp, token, MAXTOKEN); + if (type == SYNTAX) { + type = eat_syntax(fp, token, MAXTOKEN); + } + if (type == WRSYNTAX) { + type = eat_syntax(fp, token, MAXTOKEN); + } + if (type == ACCESS) { + type = get_token(fp, token, MAXTOKEN); + if (type != ACCNOTIFY && type != READONLY + && type != READWRITE && type != READCREATE + && type != WRITEONLY && type != NOTIMPL) { + print_error("Bad ACCESS", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + if (type == CREATEREQ) { + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Expected \"{\"", token, type); + goto skip; + } + do { + type = get_token(fp, token, MAXTOKEN); + if (type != LABEL) { + print_error("Bad object name in list", token, + type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } while (type == COMMA); + if (type != RIGHTBRACKET) { + print_error("Expected \"}\" after list", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + if (type == DEFVAL) { + int level = 1; + type = get_token(fp, token, MAXTOKEN); + if (type != LEFTBRACKET) { + print_error("Expected \"{\" after DEFVAL", token, + type); + goto skip; + } + do { + type = get_token(fp, token, MAXTOKEN); + if (type == LEFTBRACKET) + level++; + else if (type == RIGHTBRACKET) + level--; + } while (type != RIGHTBRACKET && type != ENDOFFILE + && level != 0); + if (type != RIGHTBRACKET) { + print_error("Missing \"}\" after DEFVAL", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + } + if (type != EQUALS) + print_error("Expected \"::=\"", token, type); + skip: + while (type != EQUALS && type != ENDOFFILE) { + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + } + return merge_parse_objectid(np, fp, name); +} + +static struct node *parse_moduleIdentity(FILE * fp, char *name) +{ + register int type; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + register struct node *np; + + np = alloc_node(current_module); + if (np == NULL) + return (NULL); + type = get_token(fp, token, MAXTOKEN); + if (type != LASTUPDATED) { + print_error("Expected LAST-UPDATED", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Need STRING for LAST-UPDATED", token, type); + goto skip; + } + check_utc(token); + type = get_token(fp, token, MAXTOKEN); + if (type != ORGANIZATION) { + print_error("Expected ORGANIZATION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad ORGANIZATION", token, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != CONTACTINFO) { + print_error("Expected CONTACT-INFO", token, type); + goto skip; + } + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad CONTACT-INFO", quoted_string_buffer, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + goto skip; + } + np->description = strdup(quoted_string_buffer); + type = get_token(fp, token, MAXTOKEN); + while (type == REVISION) { + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) { + print_error("Bad REVISION", token, type); + goto skip; + } + check_utc(token); + type = get_token(fp, token, MAXTOKEN); + if (type != DESCRIPTION) { + print_error("Expected DESCRIPTION", token, type); + goto skip; + } + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) { + print_error("Bad DESCRIPTION", quoted_string_buffer, type); + goto skip; + } + type = get_token(fp, token, MAXTOKEN); + } + if (type != EQUALS) + print_error("Expected \"::=\"", token, type); + skip: + while (type != EQUALS && type != ENDOFFILE) { + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + } + return merge_parse_objectid(np, fp, name); +} + +/* + * Parses an asn type. Structures are ignored by this parser. + * Returns NULL on error. + */ +static struct node *parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken) +{ + int type, i; + char token[MAXTOKEN]; + char quoted_string_buffer[MAXQUOTESTR]; + char *hint = NULL; + char *descr = NULL; + struct tc *tcp; + int level; + + type = get_token(fp, token, MAXTOKEN); + if (type == SEQUENCE || type == CHOICE) { + level = 0; + while ((type = get_token(fp, token, MAXTOKEN)) != ENDOFFILE) { + if (type == LEFTBRACKET) { + level++; + } else if (type == RIGHTBRACKET && --level == 0) { + *ntype = get_token(fp, ntoken, MAXTOKEN); + return NULL; + } + } + print_error("Expected \"}\"", token, type); + return NULL; + } else if (type == LEFTBRACKET) { + struct node *np; + int ch_next = '{'; + ungetc(ch_next, fp); + np = parse_objectid(fp, name); + if (np != NULL) { + *ntype = get_token(fp, ntoken, MAXTOKEN); + return np; + } + return NULL; + } else if (type == LEFTSQBRACK) { + int size = 0; + do { + type = get_token(fp, token, MAXTOKEN); + } while (type != ENDOFFILE && type != RIGHTSQBRACK); + if (type != RIGHTSQBRACK) { + print_error("Expected \"]\"", token, type); + return NULL; + } + type = get_token(fp, token, MAXTOKEN); + if (type == IMPLICIT) + type = get_token(fp, token, MAXTOKEN); + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype == LEFTPAREN) { + switch (type) { + case OCTETSTR: + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype != SIZE) { + print_error("Expected SIZE", ntoken, *ntype); + return NULL; + } + size = 1; + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype != LEFTPAREN) { + print_error("Expected \"(\" after SIZE", ntoken, + *ntype); + return NULL; + } + /* + * fall through + */ + case INTEGER: + *ntype = get_token(fp, ntoken, MAXTOKEN); + do { + if (*ntype != NUMBER) + print_error("Expected NUMBER", ntoken, *ntype); + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype == RANGE) { + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype != NUMBER) + print_error("Expected NUMBER", ntoken, *ntype); + *ntype = get_token(fp, ntoken, MAXTOKEN); + } + } while (*ntype == BAR); + if (*ntype != RIGHTPAREN) { + print_error("Expected \")\"", ntoken, *ntype); + return NULL; + } + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (size) { + if (*ntype != RIGHTPAREN) { + print_error("Expected \")\" to terminate SIZE", + ntoken, *ntype); + return NULL; + } + *ntype = get_token(fp, ntoken, MAXTOKEN); + } + } + } + return NULL; + } else { + if (type == CONVENTION) { + while (type != SYNTAX && type != ENDOFFILE) { + if (type == DISPLAYHINT) { + type = get_token(fp, token, MAXTOKEN); + if (type != QUOTESTRING) + print_error("DISPLAY-HINT must be string", token, + type); + else + hint = strdup(token); + } else if (type == DESCRIPTION) { + type = get_token(fp, quoted_string_buffer, MAXQUOTESTR); + if (type != QUOTESTRING) + print_error("DESCRIPTION must be string", token, + type); + else + descr = strdup(quoted_string_buffer); + } else + type = + get_token(fp, quoted_string_buffer, MAXQUOTESTR); + } + type = get_token(fp, token, MAXTOKEN); + if (type == OBJECT) { + type = get_token(fp, token, MAXTOKEN); + if (type != IDENTIFIER) { + print_error("Expected IDENTIFIER", token, type); + SNMP_FREE(hint); + return NULL; + } + type = OBJID; + } + } else if (type == OBJECT) { + type = get_token(fp, token, MAXTOKEN); + if (type != IDENTIFIER) { + print_error("Expected IDENTIFIER", token, type); + return NULL; + } + type = OBJID; + } + + if (type == LABEL) { + type = get_tc(token, current_module, NULL, NULL, NULL, NULL); + } + + /* + * textual convention + */ + for (i = 0; i < MAXTC; i++) { + if (tclist[i].type == 0) + break; + } + + if (i == MAXTC) { + print_error("Too many textual conventions", token, type); + SNMP_FREE(hint); + return NULL; + } + if (!(type & SYNTAX_MASK)) { + print_error("Textual convention doesn't map to real type", + token, type); + SNMP_FREE(hint); + return NULL; + } + tcp = &tclist[i]; + tcp->modid = current_module; + tcp->descriptor = strdup(name); + tcp->hint = hint; + tcp->description = descr; + tcp->type = type; + *ntype = get_token(fp, ntoken, MAXTOKEN); + if (*ntype == LEFTPAREN) { + tcp->ranges = parse_ranges(fp, &tcp->ranges); + *ntype = get_token(fp, ntoken, MAXTOKEN); + } else if (*ntype == LEFTBRACKET) { + /* + * if there is an enumeration list, parse it + */ + tcp->enums = parse_enumlist(fp, &tcp->enums); + *ntype = get_token(fp, ntoken, MAXTOKEN); + } + return NULL; + } +} + +/* + * Parses a compliance macro + * Returns 0 on error. + */ +static int eat_syntax(FILE * fp, char *token, int maxtoken) +{ + int type, nexttype; + struct node *np = alloc_node(current_module); + char nexttoken[MAXTOKEN]; + + type = get_token(fp, token, maxtoken); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + switch (type) { + case INTEGER: + case INTEGER32: + case UINTEGER32: + case UNSIGNED32: + case COUNTER: + case GAUGE: + case BITSTRING: + case LABEL: + if (nexttype == LEFTBRACKET) { + /* + * if there is an enumeration list, parse it + */ + np->enums = parse_enumlist(fp, &np->enums); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } else if (nexttype == LEFTPAREN) { + /* + * if there is a range list, parse it + */ + np->ranges = parse_ranges(fp, &np->ranges); + nexttype = get_token(fp, nexttoken, MAXTOKEN); + } + break; + case OCTETSTR: + case KW_OPAQUE: + /* + * parse any SIZE specification + */ + if (nexttype == LEFTPAREN) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == SIZE) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + if (nexttype == LEFTPAREN) { + np->ranges = parse_ranges(fp, &np->ranges); + nexttype = get_token(fp, nexttoken, MAXTOKEN); /* ) */ + if (nexttype == RIGHTPAREN) { + nexttype = get_token(fp, nexttoken, MAXTOKEN); + break; + } + } + } + print_error("Bad SIZE syntax", token, type); + free_node(np); + return nexttype; + } + break; + case OBJID: + case NETADDR: + case IPADDR: + case TIMETICKS: + case NUL: + case NSAPADDRESS: + case COUNTER64: + break; + default: + print_error("Bad syntax", token, type); + free_node(np); + return nexttype; + } + free_node(np); + return nexttype; +} + +/* + * Parses a module identity macro + * Returns 0 on error. + */ +static void check_utc(const char *utc) +{ + int len, year, month, day, hour, minute; + + len = strlen(utc); + if (utc[len - 1] != 'Z' && utc[len - 1] != 'z') { + print_error("Timestamp should end with Z", utc, QUOTESTRING); + return; + } + if (len == 11) { + len = + sscanf(utc, "%2d%2d%2d%2d%2dZ", &year, &month, &day, &hour, + &minute); + year += 1900; + } else if (len == 13) + len = + sscanf(utc, "%4d%2d%2d%2d%2dZ", &year, &month, &day, &hour, + &minute); + else { + print_error("Bad timestamp format (11 or 13 characters)", + utc, QUOTESTRING); + return; + } + if (len != 5) { + print_error("Bad timestamp format", utc, QUOTESTRING); + return; + } + if (month < 1 || month > 12) + print_error("Bad month in timestamp", utc, QUOTESTRING); + if (day < 1 || day > 31) + print_error("Bad day in timestamp", utc, QUOTESTRING); + if (hour < 0 || hour > 23) + print_error("Bad hour in timestamp", utc, QUOTESTRING); + if (minute < 0 || minute > 59) + print_error("Bad minute in timestamp", utc, QUOTESTRING); +} +//end of support function definition---------------------------------------------- + +//tools definition---------------------------------------------------------------- +/* + * return zero if character is not a label character. + */ +static int is_labelchar(int ich) +{ + if ((isalnum(ich)) || (ich == '-')) + return 1; + + return 0; +} + +static void print_error(const char *str, const char *token, int type) +{ +// erroneousMibs++; + if (type == ENDOFFILE) + printf("%s (EOF): At line %d in %s\n", str, mibLine, File); + else if (token && *token) + printf("%s (%s): At line %d in %s\n", str, token, mibLine, File); + else + printf("%s: At line %d in %s\n", str, mibLine, File); +} + +static int name_hash(const char *name) +{ + int hash = 0; + const char *cp; + + if (!name) + return 0; + for (cp = name; *cp; cp++) + hash += tolower(*cp); + return (hash); +} + +static int translation_table[256]; +static void build_translation_table() +{ + int count; + + for (count = 0; count < 256; count++) { + switch (count) { + case OBJID: + translation_table[count] = TYPE_OBJID; + break; + case OCTETSTR: + translation_table[count] = TYPE_OCTETSTR; + break; + case INTEGER: + translation_table[count] = TYPE_INTEGER; + break; + case NETADDR: + translation_table[count] = TYPE_NETADDR; + break; + case IPADDR: + translation_table[count] = TYPE_IPADDR; + break; + case COUNTER: + translation_table[count] = TYPE_COUNTER; + break; + case GAUGE: + translation_table[count] = TYPE_GAUGE; + break; + case TIMETICKS: + translation_table[count] = TYPE_TIMETICKS; + break; + case KW_OPAQUE: + translation_table[count] = TYPE_OPAQUE; + break; + case NUL: + translation_table[count] = TYPE_NULL; + break; + case COUNTER64: + translation_table[count] = TYPE_COUNTER64 ; + break; + case BITSTRING: + translation_table[count] = TYPE_BITSTRING; + break; + case NSAPADDRESS: + translation_table[count] = TYPE_NSAPADDRESS; + break; + case INTEGER32: + translation_table[count] = TYPE_INTEGER32; + break; + case UINTEGER32: + translation_table[count] = TYPE_UINTEGER; + break; + case UNSIGNED32: + translation_table[count] = TYPE_UNSIGNED32; + break; + case TRAPTYPE: + translation_table[count] = TYPE_TRAPTYPE; + break; + case NOTIFTYPE: + translation_table[count] = TYPE_NOTIFTYPE; + break; + case NOTIFGROUP: + translation_table[count] = TYPE_NOTIFGROUP; + break; + case OBJGROUP: + translation_table[count] = TYPE_OBJGROUP; + break; + case MODULEIDENTITY: + translation_table[count] = TYPE_MODID; + break; + case OBJIDENTITY: + translation_table[count] = TYPE_OBJIDENTITY; + break; + case AGENTCAP: + translation_table[count] = TYPE_AGENTCAP; + break; + case COMPLIANCE: + translation_table[count] = TYPE_MODCOMP; + break; + default: + translation_table[count] = TYPE_OTHER; + break; + } + } +} + +void print_nodes(FILE * fp, struct node *root) +{ + extern void xmalloc_stats(FILE *); + struct enum_list *ep; + struct index_list *ip; + struct range_list *rp; + struct varbind_list *vp; + struct node *np; + + for (np = root; np; np = np->next) { + fprintf(fp, "%s ::= { %s %d } (%d)\n", np->label, np->parent, + np->subid, np->type); + if (np->tc_index >= 0) + fprintf(fp, " TC = %s\n", tclist[np->tc_index].descriptor); + if (np->enums) { + fprintf(fp, " Enums: \n"); + for (ep = np->enums; ep; ep = ep->next) { + fprintf(fp, " %s(%d)\n", ep->label, ep->value); + } + } + if (np->ranges) { + fprintf(fp, " Ranges: \n"); + for (rp = np->ranges; rp; rp = rp->next) { + fprintf(fp, " %d..%d\n", rp->low, rp->high); + } + } + if (np->indexes) { + fprintf(fp, " Indexes: \n"); + for (ip = np->indexes; ip; ip = ip->next) { + fprintf(fp, " %s\n", ip->ilabel); + } + } + if (np->augments) + fprintf(fp, " Augments: %s\n", np->augments); + if (np->varbinds) { + fprintf(fp, " Varbinds: \n"); + for (vp = np->varbinds; vp; vp = vp->next) { + fprintf(fp, " %s\n", vp->vblabel); + } + } + if (np->hint) + fprintf(fp, " Hint: %s\n", np->hint); + if (np->units) + fprintf(fp, " Units: %s\n", np->units); + if (np->defaultValue) + fprintf(fp, " DefaultValue: %s\n", np->defaultValue); + } +} + +static void init_node_hash(struct node *nodes) +{ + struct node *np, *nextp; + int hash; + + memset(nbuckets, 0, sizeof(nbuckets)); + for (np = nodes; np;) { + nextp = np->next; + hash = NBUCKET(name_hash(np->parent)); + np->next = nbuckets[hash]; + nbuckets[hash] = np; + np = nextp; + } +} + +/* + * return index into tclist of given TC descriptor + * return -1 if not found + */ +static int get_tc_index(const char *descriptor, int modid) +{ + int i; + struct tc *tcp; + struct module *mp; + struct module_import *mip; + + /* + * Check that the descriptor isn't imported + * by searching the import list + */ + + for (mp = module_head; mp; mp = mp->next) + if (mp->modid == modid) + break; + if (mp) + for (i = 0, mip = mp->imports; i < mp->no_imports; ++i, ++mip) { + if (!label_compare(mip->label, descriptor)) { + /* + * Found it - so amend the module ID + */ + modid = mip->modid; + break; + } + } + + + for (i = 0, tcp = tclist; i < MAXTC; i++, tcp++) { + if (tcp->type == 0) + break; + if (!label_compare(descriptor, tcp->descriptor) && + ((modid == tcp->modid) || (modid == -1))) { + return i; + } + } + return -1; +} + +static void free_indexes(struct index_list **spp) +{ + if (spp && *spp) { + struct index_list *pp, *npp; + + pp = *spp; + *spp = NULL; + + while (pp) { + npp = pp->next; + if (pp->ilabel) + free(pp->ilabel); + free(pp); + pp = npp; + } + } +} + +static void free_varbinds(struct varbind_list **spp) +{ + if (spp && *spp) { + struct varbind_list *pp, *npp; + + pp = *spp; + *spp = NULL; + + while (pp) { + npp = pp->next; + if (pp->vblabel) + free(pp->vblabel); + free(pp); + pp = npp; + } + } +} + +static void free_ranges(struct range_list **spp) +{ + if (spp && *spp) { + struct range_list *pp, *npp; + + pp = *spp; + *spp = NULL; + + while (pp) { + npp = pp->next; + free(pp); + pp = npp; + } + } +} + +static void free_enums(struct enum_list **spp) +{ + if (spp && *spp) { + struct enum_list *pp, *npp; + + pp = *spp; + *spp = NULL; + + while (pp) { + npp = pp->next; + if (pp->label) + free(pp->label); + free(pp); + pp = npp; + } + } +} + +static void free_partial_tree(struct tree *tp, int keep_label) +{ + if (!tp) + return; + + /* + * remove the data from this tree node + */ + free_enums(&tp->enums); + free_ranges(&tp->ranges); + free_indexes(&tp->indexes); + free_varbinds(&tp->varbinds); + if (!keep_label) + SNMP_FREE(tp->label); + SNMP_FREE(tp->hint); + SNMP_FREE(tp->units); + SNMP_FREE(tp->description); + SNMP_FREE(tp->reference); + SNMP_FREE(tp->augments); + SNMP_FREE(tp->defaultValue); +} + +/* + * transfer data to tree from node + * + * move pointers for alloc'd data from np to tp. + * this prevents them from being freed when np is released. + * parent member is not moved. + * + * CAUTION: nodes may be repeats of existing tree nodes. + * This can happen especially when resolving IMPORT clauses. + * + */ +static void tree_from_node(struct tree *tp, struct node *np) +{ + free_partial_tree(tp, FALSE); + + tp->label = np->label; + np->label = NULL; + tp->enums = np->enums; + np->enums = NULL; + tp->ranges = np->ranges; + np->ranges = NULL; + tp->indexes = np->indexes; + np->indexes = NULL; + tp->augments = np->augments; + np->augments = NULL; + tp->varbinds = np->varbinds; + np->varbinds = NULL; + tp->hint = np->hint; + np->hint = NULL; + tp->units = np->units; + np->units = NULL; + tp->description = np->description; + np->description = NULL; + tp->reference = np->reference; + np->reference = NULL; + tp->defaultValue = np->defaultValue; + np->defaultValue = NULL; + tp->subid = np->subid; + tp->oid_len = tp->parent->oid_len; + memcpy(tp->oid, tp->parent->oid, tp->oid_len * sizeof(int)); + tp->oid[tp->oid_len++] = np->subid; + tp->tc_index = np->tc_index; + tp->type = translation_table[np->type]; + tp->access = np->access; + tp->status = np->status; + +// set_function(tp); +} + +static void free_node(struct node *np) +{ + if (!np) + return; + + free_enums(&np->enums); + free_ranges(&np->ranges); + free_indexes(&np->indexes); + free_varbinds(&np->varbinds); + if (np->label) + free(np->label); + if (np->hint) + free(np->hint); + if (np->units) + free(np->units); + if (np->description) + free(np->description); + if (np->reference) + free(np->reference); + if (np->defaultValue) + free(np->defaultValue); + if (np->parent) + free(np->parent); + if (np->augments) + free(np->augments); + if (np->filename) + free(np->filename); + free((char *) np); +} + +/* + * free a tree node. Note: the node must already have been unlinked + * from the tree when calling this routine + */ +void free_tree(struct tree *Tree) +{ + if (!Tree) + return; + + unlink_tbucket(Tree); + free_partial_tree(Tree, FALSE); + if (Tree->number_modules > 1) + free((char *) Tree->module_list); + free((char *) Tree); +} + +static struct enum_list *copy_enums(struct enum_list *sp) +{ + struct enum_list *xp = NULL, **spp = &xp; + + while (sp) { + *spp = (struct enum_list *) calloc(1, sizeof(struct enum_list)); + if (!*spp) + break; + (*spp)->label = strdup(sp->label); + (*spp)->value = sp->value; + spp = &(*spp)->next; + sp = sp->next; + } + return (xp); +} + +static struct range_list *copy_ranges(struct range_list *sp) +{ + struct range_list *xp = NULL, **spp = &xp; + + while (sp) { + *spp = (struct range_list *) calloc(1, sizeof(struct range_list)); + if (!*spp) + break; + (*spp)->low = sp->low; + (*spp)->high = sp->high; + spp = &(*spp)->next; + sp = sp->next; + } + return (xp); +} + +static void unlink_tbucket(struct tree *tp) +{ + int hash = NBUCKET(name_hash(tp->label)); + struct tree *otp = NULL, *ntp = tbuckets[hash]; + + while (ntp && ntp != tp) { + otp = ntp; + ntp = ntp->next; + } + if (!ntp) + printf("Can't find %s in tbuckets\n", tp->label); + else if (otp) + otp->next = ntp->next; + else + tbuckets[hash] = tp->next; +} + +static void unlink_tree(struct tree *tp) +{ + struct tree *otp = NULL, *ntp = tp->parent; + + if (ntp){ + ntp = ntp->child_list; + + while (ntp && ntp != tp) { + otp = ntp; + ntp = ntp->next_peer; + } + if (!ntp) + printf("Can't find %s in %s's children\n", + tp->label, tp->parent->label); + else if (otp) + otp->next_peer = ntp->next_peer; + else + tp->parent->child_list = tp->next_peer; + } + + if (tree_head == tp) + tree_head = tp->next_peer; +} + +int which_module(const char *name) +{ + struct module *mp; + + for (mp = module_head; mp; mp = mp->next) + if (!label_compare(mp->name, name)) + return (mp->modid); + + return (-1); +} + +static struct node *alloc_node(int modid) +{ + struct node *np; + np = (struct node *) calloc(1, sizeof(struct node)); + if (np) { + np->tc_index = -1; + np->modid = modid; + np->filename = strdup(File); + np->lineno = mibLine; + } + return np; +} + +static int get_tc(const char *descriptor, int modid, int *tc_index, + struct enum_list **ep, struct range_list **rp, char **hint) +{ + int i; + struct tc *tcp; + + i = get_tc_index(descriptor, modid); + if (tc_index) + *tc_index = i; + if (i != -1) { + tcp = &tclist[i]; + if (ep) { + free_enums(ep); + *ep = copy_enums(tcp->enums); + } + if (rp) { + free_ranges(rp); + *rp = copy_ranges(tcp->ranges); + } + if (hint) { + if (*hint) + free(*hint); + *hint = (tcp->hint ? strdup(tcp->hint) : NULL); + } + return tcp->type; + } + return LABEL; +} + +/* + * struct index_list * + * getIndexes(FILE *fp): + * This routine parses a string like { blah blah blah } and returns a + * list of the strings enclosed within it. + * + */ +static struct index_list *getIndexes(FILE * fp, struct index_list **retp) +{ + int type; + char token[MAXTOKEN]; + char nextIsImplied = 0; + + struct index_list *mylist = NULL; + struct index_list **mypp = &mylist; + + free_indexes(retp); + + type = get_token(fp, token, MAXTOKEN); + + if (type != LEFTBRACKET) { + return NULL; + } + + type = get_token(fp, token, MAXTOKEN); + while (type != RIGHTBRACKET && type != ENDOFFILE) { + if ((type == LABEL) || (type & SYNTAX_MASK)) { + *mypp = + (struct index_list *) calloc(1, sizeof(struct index_list)); + if (*mypp) { + (*mypp)->ilabel = strdup(token); + (*mypp)->isimplied = nextIsImplied; + mypp = &(*mypp)->next; + nextIsImplied = 0; + } + } else if (type == IMPLIED) { + nextIsImplied = 1; + } + type = get_token(fp, token, MAXTOKEN); + } + + *retp = mylist; + return mylist; +} + +/* + * This routine parses a string like { blah blah blah } and returns OBJID if + * it is well formed, and NULL if not. + */ +static int tossObjectIdentifier(FILE * fp) +{ + int type; + char token[MAXTOKEN]; + int bracketcount = 1; + + type = get_token(fp, token, MAXTOKEN); + + if (type != LEFTBRACKET) + return 0; + while ((type != RIGHTBRACKET || bracketcount > 0) && type != ENDOFFILE) { + type = get_token(fp, token, MAXTOKEN); + if (type == LEFTBRACKET) + bracketcount++; + else if (type == RIGHTBRACKET) + bracketcount--; + } + + if (type == RIGHTBRACKET) + return OBJID; + else + return 0; +} + +/* + * Merge the parsed object identifier with the existing node. + * If there is a problem with the identifier, release the existing node. + */ +static struct node *merge_parse_objectid(struct node *np, FILE * fp, char *name) +{ + struct node *nnp; + /* + * printf("merge defval --> %s\n",np->defaultValue); + */ + nnp = parse_objectid(fp, name); + if (nnp) { + + /* + * apply last OID sub-identifier data to the information + */ + /* + * already collected for this node. + */ + struct node *headp, *nextp; + int ncount = 0; + nextp = headp = nnp; + while (nnp->next) { + nextp = nnp; + ncount++; + nnp = nnp->next; + } + + np->label = nnp->label; + np->subid = nnp->subid; + np->modid = nnp->modid; + np->parent = nnp->parent; + if (nnp->filename != NULL) { + free(nnp->filename); + } + free(nnp); + + if (ncount) { + nextp->next = np; + np = headp; + } + } else { + free_node(np); + np = NULL; + } + + return np; +} + +/* + * Takes a list of the form: + * { iso org(3) dod(6) 1 } + * and creates several nodes, one for each parent-child pair. + * Returns 0 on error. + */ +static int getoid(FILE * fp, struct subid_s *id, /* an array of subids */ + int length) /* the length of the array */ +{ + register int count; + int type; + char token[MAXTOKEN]; + + if ((type = get_token(fp, token, MAXTOKEN)) != LEFTBRACKET) { + print_error("Expected \"{\"", token, type); + return 0; + } + type = get_token(fp, token, MAXTOKEN); + for (count = 0; count < length; count++, id++) { + id->label = NULL; + id->modid = current_module; + id->subid = -1; + if (type == RIGHTBRACKET){ + return count; + } + if (type == LABEL) { + /* + * this entry has a label + */ + id->label = strdup(token); + type = get_token(fp, token, MAXTOKEN); + if (type == LEFTPAREN) { + type = get_token(fp, token, MAXTOKEN); + if (type == NUMBER) { + id->subid = strtoul(token, NULL, 10); + if ((type = + get_token(fp, token, MAXTOKEN)) != RIGHTPAREN) { + print_error("Expected a closing parenthesis", + token, type); + return 0; + } + } else { + print_error("Expected a number", token, type); + return 0; + } + } else { + continue; + } + } else if (type == NUMBER) { + /* + * this entry has just an integer sub-identifier + */ + id->subid = strtoul(token, NULL, 10); + } else { + print_error("Expected label or number", token, type); + return 0; + } + type = get_token(fp, token, MAXTOKEN); + } + print_error("Too long OID", token, type); + return 0; +} + +static struct varbind_list *getVarbinds(FILE * fp, struct varbind_list **retp) +{ + int type; + char token[MAXTOKEN]; + + struct varbind_list *mylist = NULL; + struct varbind_list **mypp = &mylist; + + free_varbinds(retp); + + type = get_token(fp, token, MAXTOKEN); + + if (type != LEFTBRACKET) { + return NULL; + } + + type = get_token(fp, token, MAXTOKEN); + while (type != RIGHTBRACKET && type != ENDOFFILE) { + if ((type == LABEL) || (type & SYNTAX_MASK)) { + *mypp = + (struct varbind_list *) calloc(1, + sizeof(struct + varbind_list)); + if (*mypp) { + (*mypp)->vblabel = strdup(token); + mypp = &(*mypp)->next; + } + } + type = get_token(fp, token, MAXTOKEN); + } + + *retp = mylist; + return mylist; +} + +static int compliance_lookup(const char *name, int modid) +{ + if (modid == -1) { + struct objgroup *op = + (struct objgroup *) malloc(sizeof(struct objgroup)); + if (!op) + return 0; + op->next = objgroups; + op->name = strdup(name); + op->line = mibLine; + objgroups = op; + return 1; + } else + return find_tree_node(name, modid) != NULL; +} + +/* + * module_name - copy module name to user buffer, return ptr to same. + */ +char *module_name(int modid, char *cp) +{ + struct module *mp; + + for (mp = module_head; mp; mp = mp->next) + if (mp->modid == modid) { + strcpy(cp, mp->name); + return (cp); + } + + sprintf(cp, "#%d", modid); + return (cp); +} + +struct tree *find_tree_node(const char *name, int modid) +{ + struct tree *tp, *headtp; + int count, *int_p; + + if (!name || !*name) + return (NULL); + + headtp = tbuckets[NBUCKET(name_hash(name))]; + for (tp = headtp; tp; tp = tp->next) { + if (tp->label && !label_compare(tp->label, name)) { + + if (modid == -1) /* Any module */ + return (tp); + + for (int_p = tp->module_list, count = 0; + count < tp->number_modules; ++count, ++int_p) + if (*int_p == modid) + return (tp); + } + } + + return (NULL); +} + +static void print_module_not_found(const char *cp) +{ + if (!last_err_module || strcmp(cp, last_err_module)) + print_error("Cannot find module", cp, CONTINUE); + if (last_err_module) + free(last_err_module); + last_err_module = strdup(cp); +} + +void print_subtree(FILE * f, struct tree *tree, int count) +{ + struct tree *tp; + int i; + char modbuf[256]; + + for (i = 0; i < count; i++) + fprintf(f, " "); + + fprintf(f, "Children of %s(%d):\n", tree->label, tree->subid); + count++; + + for (tp = tree->child_list; tp; tp = tp->next_peer) { + for (i = 0; i < count; i++) + fprintf(f, " "); + + fprintf(f, "%s:%s(%d) type=%d", + module_name(tp->module_list[0], modbuf), + tp->label, tp->subid, tp->type); + if (tp->tc_index != -1) + fprintf(f, " tc=%d", tp->tc_index); + if (tp->hint) + fprintf(f, " hint=%s", tp->hint); + if (tp->units) + fprintf(f, " units=%s", tp->units); + + if (tp->number_modules > 1) { + fprintf(f, " modules:"); + for (i = 1; i < tp->number_modules; i++) + fprintf(f, " %s", module_name(tp->module_list[i], modbuf)); + } + fprintf(f, " OID: %d", tp->oid[0]); + for(i = 1; i < tp->oid_len; i++) + fprintf(f, ".%d", tp->oid[i]); + + fprintf(f, "\n"); + } + + for (tp = tree->child_list; tp; tp = tp->next_peer) { + if (tp->child_list) + print_subtree(f, tp, count); + } +} + +//end of tools definition--------------------------------------------------------- + diff --git a/omc/plat/snmp/src/mib_parser/snmp_mib.h b/omc/plat/snmp/src/mib_parser/snmp_mib.h new file mode 100644 index 0000000..1c8c2a3 --- /dev/null +++ b/omc/plat/snmp/src/mib_parser/snmp_mib.h @@ -0,0 +1,171 @@ +/******************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: snmp_mib.h +Description: header file of snmp mib parser +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-6-9 + +History: +2007-6-9 v9.0.0 Create + +BEWARE: Portions of this file are subject to the copyrights of + open-source project Net-SNMP.See the Net-SNMP's COPYING file + for more details +*********************************************************************/ +#ifndef __WXC2_SNMP_MIB_H_ +#define __WXC2_SNMP_MIB_H_ + +#define MAXLABEL 64 /* maximum characters in a label */ +#define MAXTOKEN 128 /* maximum characters in a token */ +#define MAXQUOTESTR 20480 /* maximum characters in a quoted string */ + +struct variable_list; + +/* + * A linked list of tag-value pairs for enumerated integers. + */ +struct enum_list { + struct enum_list *next; + int value; + char *label; +}; + +/* + * A linked list of ranges + */ +struct range_list { + struct range_list *next; + int low, high; +}; + +/* + * A linked list of indexes + */ +struct index_list { + struct index_list *next; + char *ilabel; + char isimplied; +}; + +/* + * A linked list of varbinds + */ +struct varbind_list { + struct varbind_list *next; + char *vblabel; +}; + +/* + * A tree in the format of the tree structure of the MIB. + */ +struct tree { + struct tree *child_list; /* list of children of this node */ + struct tree *next_peer; /* Next node in list of peers */ + struct tree *next; /* Next node in hashed list of names */ + struct tree *parent; + char *label; /* This node's textual name */ + int subid; /* This node's integer subidentifier */ + int modid; /* The module containing this node */ + int number_modules; + int *module_list; /* To handle multiple modules */ + int tc_index; /* index into tclist (-1 if NA) */ + int type; /* This node's object type */ + int access; /* This nodes access */ + int status; /* This nodes status */ + struct enum_list *enums; /* (optional) list of enumerated integers */ + struct range_list *ranges; + struct index_list *indexes; + char *augments; + struct varbind_list *varbinds; + char *hint; + char *units; + char *description; /* description (a quoted string) */ + char *reference; /* references (a quoted string) */ + int reported; /* 1=report started in print_subtree... */ + char *defaultValue; + int oid[32]; + int oid_len; +}; + +/* + * Information held about each MIB module + */ +struct module_import { + char *label; /* The descriptor being imported */ + int modid; /* The module imported from */ +}; + +struct module { + char *name; /* This module's name */ + char *file; /* The file containing the module */ + struct module_import *imports; /* List of descriptors being imported */ + int no_imports; /* The number of such import descriptors */ + /* + * -1 implies the module hasn't been read in yet + */ + int modid; /* The index number of this module */ + struct module *next; /* Linked list pointer */ +}; + +struct module_compatability { + const char *old_module; + const char *new_module; + const char *tag; /* NULL implies unconditional replacement, + * otherwise node identifier or prefix */ + size_t tag_len; /* 0 implies exact match (or unconditional) */ + struct module_compatability *next; /* linked list */ +}; + + +/* + * non-aggregate types for tree end nodes + */ +#define TYPE_OTHER 0 +#define TYPE_OBJID 1 +#define TYPE_OCTETSTR 2 +#define TYPE_INTEGER 3 +#define TYPE_NETADDR 4 +#define TYPE_IPADDR 5 +#define TYPE_COUNTER 6 +#define TYPE_GAUGE 7 +#define TYPE_TIMETICKS 8 +#define TYPE_OPAQUE 9 +#define TYPE_NULL 10 +#define TYPE_COUNTER64 11 +#define TYPE_BITSTRING 12 +#define TYPE_NSAPADDRESS 13 +#define TYPE_UINTEGER 14 +#define TYPE_UNSIGNED32 15 +#define TYPE_INTEGER32 16 + +#define TYPE_SIMPLE_LAST 16 + +#define TYPE_TRAPTYPE 20 +#define TYPE_NOTIFTYPE 21 +#define TYPE_OBJGROUP 22 +#define TYPE_NOTIFGROUP 23 +#define TYPE_MODID 24 +#define TYPE_AGENTCAP 25 +#define TYPE_MODCOMP 26 +#define TYPE_OBJIDENTITY 27 + +#define MIB_ACCESS_READONLY 18 +#define MIB_ACCESS_READWRITE 19 +#define MIB_ACCESS_WRITEONLY 20 +#define MIB_ACCESS_NOACCESS 21 +#define MIB_ACCESS_NOTIFY 67 +#define MIB_ACCESS_CREATE 48 + +#define MIB_STATUS_MANDATORY 23 +#define MIB_STATUS_OPTIONAL 24 +#define MIB_STATUS_OBSOLETE 25 +#define MIB_STATUS_DEPRECATED 39 +#define MIB_STATUS_CURRENT 57 + +#define ANON "anonymous#" +#define ANON_LEN strlen(ANON) + + + +#endif diff --git a/omc/plat/snmp/src/mib_parser/snmp_mib_api.c b/omc/plat/snmp/src/mib_parser/snmp_mib_api.c new file mode 100644 index 0000000..fe49bd7 --- /dev/null +++ b/omc/plat/snmp/src/mib_parser/snmp_mib_api.c @@ -0,0 +1,122 @@ +/*********************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: snmp_mib_api.c +Description: API for SNMP MIB parser +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-6-19 + +History: +2007-6-9 v9.0.0 Create +***********************************************************************/ +#include +#include +#include "snmp_mib.h" +#include "snmp_mib_api.h" + +const char *mib_dir = "./mib"; +const char *index_file = "index"; + +extern struct tree *tree_head; +extern struct module *module_head; +extern void new_module(const char *name, const char *file); +extern struct tree *read_module(const char *name); +extern int get_token(FILE * fp, char *token, int maxtlen); +extern void print_subtree(FILE * f, struct tree *tree, int count); +extern struct tree *find_tree_node(const char *name, int modid); +extern void free_tree(struct tree *Tree); + +//return 0 on success +int init_mib() +{ + //open dir and check mib files in the dir + { + FILE *ip, *fp; + char tmpstr[300]; + int count = 0; + char token[MAXTOKEN]; + char newline; + struct stat dir_stat, idx_stat; + char tmpstr1[300]; + + printf("Scanning directory %s\n", mib_dir); + + snprintf(token, sizeof(token), "%s/%s", mib_dir, index_file); + token[ sizeof(token)-1 ] = 0; + if (stat(token, &idx_stat) == 0 && stat(mib_dir, &dir_stat) == 0) { + if ((ip = fopen(token, "r")) != NULL) { + while (fscanf(ip, "%256s%c", tmpstr, &newline) == 2) + { + /* + * If an overflow of the token or tmpstr buffers has been + * found log a message and break out of the while loop, + * thus the rest of the file tokens will be ignored. + */ + if (newline != '\n') { + printf("add_mibdir: strings scanned in from %s/%s " \ + "are too large. count = %d\n ", mib_dir, + ".index", count); + break; + } + + snprintf(tmpstr1, sizeof(tmpstr1), "%s/%s", mib_dir, tmpstr); + tmpstr1[ sizeof(tmpstr1)-1 ] = 0; + fp = fopen(tmpstr1, "r"); + if (fp == NULL) { + printf("Can not open mib file: %s\n", tmpstr1); + continue; + } + get_token(fp, token, MAXTOKEN); + fclose(fp); + new_module(token, tmpstr1); + count++; + } + fclose(ip); + } + else + printf("Can't read index\n"); + } + else + printf("No index\n"); + } + + //read all mibs + { + struct module *mp; + for (mp = module_head; mp; mp = mp->next) + if (mp->no_imports == -1) + read_module(mp->name); + } + +#ifdef _TEST_ +{ + //for debug + // print_subtree(stdout, tree_head, 0); +} +#endif + + return 0; +} + +struct tree *getLGCroot() +{ + return find_tree_node("lgcNS", -1); +} + +void close_mib() +{ + free_tree(tree_head); + return; +} + +//test---------------------------------------------------------------------------- +#ifdef _TEST_ +int main(int argc, char *argv[]) +{ + init_mib(); + + return 0; +} +#endif +//end of test--------------------------------------------------------------------- + diff --git a/omc/plat/snmp/src/mib_parser/snmp_mib_api.h b/omc/plat/snmp/src/mib_parser/snmp_mib_api.h new file mode 100644 index 0000000..9596288 --- /dev/null +++ b/omc/plat/snmp/src/mib_parser/snmp_mib_api.h @@ -0,0 +1,49 @@ +/*********************************************************************** +Copyright ?2007 LGC Wireless, Inc. All rights reserved +File Name: snmp_mib.h +Description: header file of snmp mib parser +Version: v9.0.0 +Author: Roy Jiang +Create Date: 2007-6-9 + +History: +2007-6-9 v9.0.0 Create +***********************************************************************/ +#ifndef _WXC2_SNMP_MIB_API_H_ +#define _WXC2_SNMP_MIB_API_H_ + +#include "snmp_mib.h" + +/* +*Purpose: Init mib parser, read all mib files listed in ./mib/index, +* you should config which mib file you want to parse in the file./mib/index +*Input: None +*Output: None +*/ +extern int init_mib(); + +/* +*Purpose: get the LGC root node of mib tree +*Input: None +*Output: LGC root tree node +*/ +extern struct tree *getLGCroot(); + +/* +*Purpose: Close mib parser and release all resources used in parsing mib files +*Input: None +*Output: None +*/ +extern void close_mib(); + +/* +*Purpose: Get tree node from oid +*Input: const int oid: oid of the tree node to get + int oidlen: the length of the oid + struct tree *subtree: tree node from which the search start +*Output: tree node +*/ +extern struct tree *get_tree(const int *oid, int oidlen, struct tree *subtree); + +#endif + diff --git a/omc/plat/snmp/src/snmp.c b/omc/plat/snmp/src/snmp.c new file mode 100644 index 0000000..394482d --- /dev/null +++ b/omc/plat/snmp/src/snmp.c @@ -0,0 +1,2022 @@ +/****************************************/ +/*Title: snmp.c */ +/*Descr: SNMP Agent */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-1 */ +/*Modify: 2003-5-16 */ +/****************************************/ +#include "./include/heartbeat.h" + +// by simon at 23/9/25 +char SnmpVer[16]; +extern BYTE snmpDebugFull; +static BYTE initonce = 0; +static BYTE fun_num = 0; +static trapcall trap_proc[100]; +static mib_nod *phead = NULL; +static BYTE setcall_num = 0, getcall_num = 0, trapcall_num = 0, rspcall_num = 0; +static short SnmpPort = 4957; +snmp_csta SnmpCsta[96]; +int snmp_ins; +snmp_mib SnmpMib; +static snmp_csta *pCsta; +snmp_log_info *pLogInfo; +extern struct timeval tvnow; + +//Private Functions------------------> +static int get_len(BYTE *asnbuf, int *len); +static int parse_snmpmsg(BYTE *msgin, int msglen, snmp_pdu *psnmp); +static int build_snmpmsg(BYTE *pbuf, snmp_pdu *psnmp); +static DWORD assign_rid(); +static BYTE *getmem(int nsize); +static int trap_handle(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen, snmp_addr *addr); +static int rsp_handle(BYTE oidlen, DWORD *oid, snmp_pdu *pdu, snmp_addr *addr); +static int snmp_handle(BYTE oidlen, DWORD *oid, snmp_pdu *pdu, snmp_addr *addr); +static void snmp_hb_init(); +/*-----------------------------------------*/ + +#ifdef _EWS_H_ +extern void ews_proc_heartbeat(BYTE oidLen,DWORD *oid, WORD dataLen,BYTE *pdata); +#endif + +void snmp_log_init() +{ + int shm_id,loop; + FILE *fpLog; + + shm_id = shmget(SNMP_SHM_KEY,32*1024,SNMP_SHM_PERM | IPC_CREAT); + if(shm_id == -1) + { + printf("Failed to create snmp shmmem\n"); + exit(1); + } + pLogInfo = (snmp_log_info *)shmat(shm_id,(char *)0,0); + if(pLogInfo == (void *)-1) + { + printf("Failed to shmat snmp shmmem\n"); + exit(2); + } + + fpLog = fopen("../log/snmp_log.txt","w"); + if(fpLog == NULL) return; + + fprintf(fpLog,"-------- SNMP log info -------\n"); + fprintf(fpLog,"----------------------------------\n"); + fprintf(fpLog,"---> Lastest log No. = %02d <-----\n", + (pLogInfo->currentNo+MAX_SNMP_RECORD-1)%MAX_SNMP_RECORD); + for(loop=0;looplog_info[loop]); + } + fprintf(fpLog,"------------- End --------------\n"); + memset(pLogInfo,0,sizeof(snmp_log_info)); + fclose(fpLog); +} + +void snmpLogInfo(char *logInfo) +{ + static int currentNo=0; + sprintf(pLogInfo->log_info[currentNo]," %02d->%s", + currentNo,logInfo); + currentNo ++; + currentNo %= MAX_SNMP_RECORD; + pLogInfo->currentNo = currentNo; +} + +unsigned long long SNMPSerialNumber; +BYTE snmp_synctime_flag; + +void snmp_init(WORD nport) +{ + unsigned long l_time; + struct tm *t; + BYTE version[3] = SNMP_VERSION; + + SnmpPort = nport; + if(initonce == 1) + return; + sprintf(SnmpVer, "R%dV%d_%02d", version[0], version[1], version[2]); + + memset(trap_proc, 0, 100 * sizeof(trapcall)); + + l_time = time(NULL); + t = localtime(&l_time); + snmp_ins = t->tm_hour * 4 + t->tm_min/15; + memset(&SnmpCsta[0], 0, sizeof(snmp_csta) * 96); + pCsta = &SnmpCsta[snmp_ins]; + pCsta->timestamp = time(NULL); + + snmpmib_init(); + snmp_debug_setup(); + snmp_debug_csta(1, snmp_ins); + snmp_log_init(); + + SNMPSerialNumber = 0; + snmp_synctime_flag = 1;//default to sync omc time + + printf("SNMP Agent Version %s ...... Finish initialization!\n", SnmpVer); + initonce = 1; +} + +unsigned long long Str2Ull(char *pStr); +void snmp_init_serial_number(BYTE *Serial) +{ + SNMPSerialNumber = Str2Ull(Serial); +} + +void snmp_set_timenosync()//call of this function will tell snmp module do not sync the omc time +{ + snmp_synctime_flag = 0; +} + +void snmp_timer() +{ + static message_list msgin; + static snmp_pdu snmpmsg; + static snmp_addr addr; + static var_list *pvar; + static int len; + static DWORD *poid; + static BYTE idlen; + int i, j, loop = 10; + struct tm *t; + unsigned long l_time; + static BYTE m_state = 0, ch; +#if SNMP_DEBUG_LOG + char debugBuf[512]; +#endif + //add by yizane start + DWORD in_oid[OID_MAXLEN]; + //add by yizane end + + snmpDebugFull = 0; + snmp_debug_timer(); + if(m_state++ == 25) //switch csta buffer + { + l_time = time(NULL); + t = localtime(&l_time); + if(ch == 0 && t->tm_min%15 == 0) + { + snmp_ins = t->tm_hour * 4 + t->tm_min/15; + pCsta = &SnmpCsta[snmp_ins]; + memset(pCsta, 0, sizeof(snmp_csta)); + pCsta->timestamp = l_time; + snmp_debug_csta(1, snmp_ins); + ch = 1; + } + if(t->tm_min%15 == 1) + ch = 0; + m_state = 0; + } + + while(loop-- > 0) + { + if(iptrGetMessage(&msgin, SnmpPort) != 1) + return; + + strcpy(snmpmsg.community, "public"); + snmpmsg.error_status = snmpmsg.error_index = 0; + +#if SNMP_DEBUG_LOG + snmpLogInfo("snmp_timer() entering parse_snmpmsg()"); +#endif + + if(parse_snmpmsg(msgin.msgContent, msgin.msgLength, &snmpmsg) == -1) + { + pCsta->fail_parse++; + snmp_debug(SNMPDB_ERR, "Fail to parse message.Give up dealing with it!"); + snmp_showbuf(SNMPDB_ERR, msgin.msgContent, msgin.msgLength); + continue; + } + + //store address + addr.remote_ip = msgin.msgSrcIP; + addr.remote_port = msgin.msgSrcPort; + addr.local_ip = msgin.msgDstIP; + addr.local_port = msgin.msgDstPort; + + snmp_logmsg(SNMPDB_IN, &snmpmsg, &addr); + +#if SNMP_DEBUG_LOG + sprintf(debugBuf,"msgIN type: %d , %08lx.%04d from %08lx.%04d", + snmpmsg.pdu_type, + msgin.msgSrcIP,msgin.msgSrcPort, + msgin.msgDstIP,msgin.msgDstPort); + snmpLogInfo(debugBuf); + sprintf(debugBuf,"oidLen: %d, lastest 8 oid=%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + snmpmsg.var[0].oidlen, + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-9], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-8], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-7], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-6], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-5], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-4], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-3], + snmpmsg.var[0].oid[snmpmsg.var[0].oidlen-2]); + snmpLogInfo(debugBuf); + printf("%s\n",debugBuf); +#endif + switch(snmpmsg.pdu_type) + { + case PDU_RSP: + pCsta->rsp_in++; + rsp_handle(snmpmsg.var[0].oidlen, snmpmsg.var[0].oid, &snmpmsg, &addr); + continue; + break; + case PDU_SET: + pCsta->set_in++; + if(snmpmsg.error_status != 0 ) + continue; + if(snmp_handle(snmpmsg.var[0].oidlen, snmpmsg.var[0].oid, &snmpmsg, &addr)>0) + continue; + break; + case PDU_GET: + pCsta->get_in++; + if(snmpmsg.error_status != 0 ) + continue; + if(snmp_handle(snmpmsg.var[0].oidlen, snmpmsg.var[0].oid, &snmpmsg, &addr)>0) + continue; + break; + case PDU_TRAP: + pCsta->trap_in++; + break; + case PDU_GETNEXT: + //add by yizane start + pCsta->getnext_in++; + if(snmpmsg.error_status != 0 ) + continue; + if(snmp_handle(snmpmsg.var[0].oidlen, snmpmsg.var[0].oid, &snmpmsg, &addr)>0) + continue; + break; + case PDU_GETBULK: + pCsta->getbulk_in++; + if(snmpmsg.error_status != 0 ) + continue; + if(snmp_handle(snmpmsg.var[0].oidlen, snmpmsg.var[0].oid, &snmpmsg, &addr)>0) + continue; + break; + //add by yizane end + default: + snmp_debug(SNMPDB_ERR, "Unknow PDU type(%d)!", snmpmsg.pdu_type); + snmp_logmsg(SNMPDB_ERR, &snmpmsg, &addr); + continue; + } + + //deal with each variable in var_list + for(i = 0; i < snmpmsg.var_num; i++) + { + pvar = &snmpmsg.var[i]; + poid = pvar->oid; + idlen = pvar->oidlen; + switch(snmpmsg.pdu_type) + { + case PDU_TRAP: + if(trap_handle(idlen, poid, pvar->msg, pvar->msglen, &addr) == 1) + continue; + for(j = 0; j < fun_num; j++) + { + if(trap_proc[j] != NULL) + trap_proc[j](idlen, poid, pvar->msg, pvar->msglen, &addr); + } + continue; + case PDU_GETNEXT: + //add by yizane start + memset(in_oid,0,OID_MAXLEN*sizeof(DWORD)); + memcpy(in_oid,poid,idlen*sizeof(DWORD)); + len = getnext_response(idlen, in_oid, &pvar->oidlen, poid, pvar->msg, &pvar->vartype); + if(len >= 0){ + pvar->msglen = len; //L + } + else if(len == -1) + { + snmp_debug(SNMPDB_NOREG, "EndOfMibView"); + snmp_logmsg(SNMPDB_NOREG, &snmpmsg, &addr); + pvar->vartype = EndOfMibView; + pvar->msglen = 0; + } + else + { + snmpmsg.error_status=3; + snmpmsg.error_index = i + 1; + pvar->vartype = 4; + pvar->msg[128] = 0; + pvar->msglen = strlen(pvar->msg); + } + break; + //add by yizane end + + case PDU_GET: + len = get_response(idlen, poid, pvar->msg, &pvar->vartype); + + if(len >= 0) + pvar->msglen = len; //L + else if(len == -1) + { + snmp_debug(SNMPDB_NOREG, "NoSuchObject or NoSuchInstance:"); + snmp_logmsg(SNMPDB_NOREG, &snmpmsg, &addr); + if(poid[idlen-1] == 0) + pvar->vartype = NoSuchObject; + else + pvar->vartype = NosuchInstance; + pvar->msglen = 0; + } + else + { + snmpmsg.error_status=3; + snmpmsg.error_index = i + 1; + pvar->vartype = 4; + pvar->msg[128] = 0; + pvar->msglen = strlen(pvar->msg); + } + break; + case PDU_SET: + len = set_response(idlen, poid, pvar->msg, pvar->msglen); + if(len >= 0) + { + pvar->msglen = len; //L + } + else if(len == -1) + { + snmp_debug(SNMPDB_NOREG, "NoSuchObject or NoSuchInstance:"); + snmp_logmsg(SNMPDB_NOREG, &snmpmsg, &addr); + if(poid[idlen-1] == 0) + pvar->vartype = NoSuchObject; + else + pvar->vartype = NosuchInstance; + pvar->msglen = 0; + } + else + { + snmpmsg.error_status=3; + snmpmsg.error_index = i + 1; + pvar->vartype = 4; + pvar->msg[128] = 0; + pvar->msglen = strlen(pvar->msg); + } + break; + }/* switch */ + } /* for */ + +//add by yizane start + if(snmpmsg.pdu_type == PDU_GETBULK){ + int n,m,r,end_count,index; + static DWORD *pre_poid; + m = snmpmsg.max_repetitions; + + if (snmpmsg.non_repeaters < snmpmsg.var_num) { + n = snmpmsg.non_repeaters; + } else { + n = snmpmsg.var_num; + } + if ((r = snmpmsg.var_num - n) < 0) { + r = 0; + } + + snmpmsg.var_num=0; + for(i = 0; i < n; i++){ + if(i>=BIND_MAX){ + break; + } + pvar = &snmpmsg.var[i]; + poid = pvar->oid; + idlen = pvar->oidlen; + + memset(in_oid,0,OID_MAXLEN*sizeof(DWORD)); + memcpy(in_oid,poid,idlen*sizeof(DWORD)); + len = getnext_response(idlen, in_oid, &pvar->oidlen, poid, pvar->msg, &pvar->vartype); + if(len >= 0) + pvar->msglen = len; //L + else if(len == -1) + { + snmp_debug(SNMPDB_NOREG, "EndOfMibView"); + snmp_logmsg(SNMPDB_NOREG, &snmpmsg, &addr); + pvar->vartype = EndOfMibView; + pvar->msglen = 0; + } + else + { + snmpmsg.error_status=3; + snmpmsg.error_index = i + 1; + pvar->vartype = 4; + pvar->msg[128] = 0; + pvar->msglen = strlen(pvar->msg); + } + snmpmsg.var_num++; + } + + + + for(i = 0; i < m; i++){ + end_count=0; + for(j = 0; j < r; j++){ + index = n+i*r+j; + if(index>=BIND_MAX){ + end_count = r ; + break; + } + pvar = &snmpmsg.var[index]; + poid = pvar->oid; + + memset(in_oid,0,OID_MAXLEN*sizeof(DWORD)); + if(i==0) + { + pre_poid = pvar->oid; + idlen = pvar->oidlen; + memcpy(in_oid,pre_poid,idlen*sizeof(DWORD)); + } + else + { + pre_poid = snmpmsg.var[n+i*r+j-r].oid; + idlen = snmpmsg.var[n+i*r+j-r].oidlen; + memcpy(in_oid,pre_poid,idlen*sizeof(DWORD)); + } + + len = getnext_response(idlen, in_oid, &pvar->oidlen, poid, pvar->msg, &pvar->vartype); + if(len >= 0) + pvar->msglen = len; //L + else if(len == -1) + { + snmp_debug(SNMPDB_NOREG, "EndOfMibView"); + snmp_logmsg(SNMPDB_NOREG, &snmpmsg, &addr); + pvar->vartype = EndOfMibView; + pvar->msglen = 0; + end_count++; + } + else + { + snmpmsg.error_index = i + 1; + pvar->vartype = 4; + pvar->msg[128] = 0; + pvar->msglen = strlen(pvar->msg); + } + snmpmsg.var_num++; + + } + if(end_count==r) + break; + } + + if(snmpmsg.var_num>BIND_MAX) + snmpmsg.var_num=BIND_MAX; + } + + //response----------------> + //response----------------> + if(snmpmsg.pdu_type == PDU_SET || snmpmsg.pdu_type == PDU_GET + || snmpmsg.pdu_type == PDU_GETNEXT|| snmpmsg.pdu_type == PDU_GETBULK ) +//add by yizane end + { + snmpmsg.pdu_type = PDU_RSP; + /* + if(len != -2) + { + snmpmsg.error_index = 0; + } + if(len == -2) + { + snmpmsg.error_status = 3; + snmpmsg.error_index = 1; + } + else + { + snmpmsg.error_index = 0; + } + */ + + len = build_snmpmsg(msgin.msgContent, &snmpmsg); + msgin.msgLength = len; + + msgin.msgDstIP = addr.remote_ip; + msgin.msgDstPort = addr.remote_port; + msgin.msgSrcPort = addr.local_port; + snmp_logmsg(SNMPDB_OUT, &snmpmsg, &addr); + iptrPlatPutMessage(msgin); + } + } +} + +int get_response(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype) +{ + BYTE i = 0; + mib_nod *p1; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf, + "get_response(), oidlen: %d, lastest 8 oid:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + oidlen,oid[oidlen-9], + oid[oidlen-8],oid[oidlen-7],oid[oidlen-6],oid[oidlen-5], + oid[oidlen-4],oid[oidlen-3],oid[oidlen-2]); + snmpLogInfo(debugBuf); +#endif + + p1 = phead; + while(i < oidlen) + { + if(p1 == NULL) + { + pCsta->not_register++; + return -1; + } + if(p1->id == oid[i]) + { + if(p1->get_proc != NULL) + return p1->get_proc(oidlen, oid, pdata, vartype); + if(ipsub; + } + else + { + if(p1->pnext == NULL) + { + pCsta->not_register++; + return -1; + } + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + pCsta->not_register++; + return -1; +} + +//add by yizane start +int getnext_response(BYTE in_oidlen, DWORD *in_oid, BYTE *oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ + BYTE i = 0; + mib_nod *p1; + p1 = phead; + + + while(i < in_oidlen) + { + if(p1 == NULL) + { + pCsta->not_register++; + return -1; + } + if(p1->id == in_oid[i]) + { + if(p1->getnext_proc != NULL) + return p1->getnext_proc(in_oidlen, in_oid, oidlen, oid, pdata, vartype); + if(ipsub; + } + else + { + if(p1->pnext == NULL) + { + pCsta->not_register++; + return -1; + } + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + pCsta->not_register++; + return -1; +} +//add by yizane end + +int set_response(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen) +{ + BYTE i = 0; + mib_nod *p1; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf, + "set_response(), oidlen: %d, lastest 8 oid:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + oidlen,oid[oidlen-9], + oid[oidlen-8],oid[oidlen-7],oid[oidlen-6],oid[oidlen-5], + oid[oidlen-4],oid[oidlen-3],oid[oidlen-2]); + snmpLogInfo(debugBuf); +#endif + p1 = phead; + while(i < oidlen) + { + if(p1 == NULL) + { + pCsta->not_register++; + return -1; + } + if(p1->id == oid[i]) + { + if(p1->set_proc != NULL) + return p1->set_proc(oidlen, oid, pdata, datalen); + if(i < oidlen-1) + p1 = p1->psub; + } + else + { + if(p1->pnext == NULL) + { + pCsta->not_register++; + return -1; + } + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + pCsta->not_register++; + return -1; +} + +int trap_handle(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen, snmp_addr *addr) +{ + BYTE i = 0; + mib_nod *p1; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf, + "trap_handle(), oidlen: %d, lastest 8 oid:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + oidlen,oid[oidlen-9], + oid[oidlen-8],oid[oidlen-7],oid[oidlen-6],oid[oidlen-5], + oid[oidlen-4],oid[oidlen-3],oid[oidlen-2]); + snmpLogInfo(debugBuf); +#endif + + p1 = phead; + while(i < oidlen) + { + if(p1 == NULL) + return -1; + if(p1->id == oid[i]) + { + if(p1->trap_proc != NULL) + { + p1->trap_proc(oidlen, oid, pdata, datalen, addr); + return 1; + } + if(i < oidlen-1) + p1 = p1->psub; + } + else + { + if(p1->pnext == NULL) + return -1; + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + return -1; +} + +int rsp_handle(BYTE oidlen, DWORD *oid, snmp_pdu *pdu, snmp_addr *addr) +{ + BYTE i = 0; + mib_nod *p1; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf, + "rsp_handle(), oidlen: %d, lastest 8 oid:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + oidlen,oid[oidlen-9], + oid[oidlen-8],oid[oidlen-7],oid[oidlen-6],oid[oidlen-5], + oid[oidlen-4],oid[oidlen-3],oid[oidlen-2]); + snmpLogInfo(debugBuf); +#endif + + p1 = phead; + while(i < oidlen) + { + if(p1 == NULL) + { + pCsta->not_register++; + return -1; + } + if(p1->id == oid[i]) + { + if(p1->rsp_proc != NULL) + { + p1->rsp_proc(pdu, addr); + return 1; + } + if(i < oidlen-1) + p1 = p1->psub; + } + else + { + if(p1->pnext == NULL) + { + pCsta->not_register++; + return -1; + } + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + pCsta->not_register++; + return -1; +} + +int snmp_handle(BYTE oidlen, DWORD *oid, snmp_pdu *pdu, snmp_addr *addr) +{ + BYTE i = 0; + mib_nod *p1; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf, + "snmp_handle(), oidlen: %d, lastest 8 oid:%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld", + oidlen,oid[oidlen-9], + oid[oidlen-8],oid[oidlen-7],oid[oidlen-6],oid[oidlen-5], + oid[oidlen-4],oid[oidlen-3],oid[oidlen-2]); + snmpLogInfo(debugBuf); +#endif + + p1 = phead; + while(i < oidlen) + { + if(p1 == NULL) + return -1; + if(p1->id == oid[i]) + { + if(p1->snmp_proc != NULL) + { + p1->snmp_proc(pdu, addr); + return 1; + } + if(i < oidlen-1) + p1 = p1->psub; + } + else + { + if(p1->pnext == NULL) + return -1; + else + { + p1 = p1->pnext; + continue; + } + } + i++; + } + return -1; +} + +void snmp_hb_init() +{ + BYTE status[64] = {3, 3, 2, 1}; + status[4] = trapcall_num; + status[5] = setcall_num; + status[6] = getcall_num; + status[7] = rspcall_num; + set_status(4, 8, status); +} +/********************************************************************/ + +void inquire_trapmsg(trapcall func) +{ + BYTE i; + for(i = 0; i < fun_num && i < 100; i++) + { + if(trap_proc[i] == NULL) + { + trap_proc[i] = func; + fun_num = i+1; + return; + } + if(trap_proc[i] == func) + return; + } + if(fun_num >= 100) + return; + trap_proc[fun_num++] = func; + trapcall_num++; + snmp_hb_init(); +} + +void rob_trapmsg(BYTE oidlen, DWORD *oid, trapcall trap_proc) +{ + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(i < oidlen) + { + if(p1->id == oid[i]) + { + if(i == oidlen-1) + p1->trap_proc = trap_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + trapcall_num++; + snmp_hb_init(); +} + +void inquire_setmsg(BYTE oidlen, DWORD *oid, setcall set_proc) +{ + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(i < oidlen) + { + if(p1->id == oid[i]) + { + if(i == oidlen-1) + p1->set_proc = set_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + setcall_num++; + snmp_hb_init(); +} + +void inquire_getmsg(BYTE oidlen, DWORD *oid, getcall get_proc) +{ + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(i < oidlen) + { + if(p1->id == oid[i]) + { + if(i == oidlen - 1) + p1->get_proc = get_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + getcall_num++; + snmp_hb_init(); +} + +//add by yizane start +void inquire_getnextmsg(BYTE oidlen, DWORD *oid, getnextcall getnext_proc) +{ + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(i < oidlen) + { + if(p1->id == oid[i]) + { + if(i == oidlen - 1) + p1->getnext_proc = getnext_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + getcall_num++; + snmp_hb_init(); +} +//add by yizane end + +void inquire_rspmsg(BYTE oidlen, DWORD *oid, rspcall rsp_proc) +{ + + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(iid == oid[i]) + { + if(i == oidlen - 1) + p1->rsp_proc = rsp_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + rspcall_num++; + snmp_hb_init(); +} + +void inquire_snmpmsg(BYTE oidlen, DWORD *oid, snmpcall snmp_proc) +{ + + BYTE i = 0; + mib_nod *p1, *p2; + if(phead == NULL) + { + phead = (mib_nod *)getmem(sizeof(mib_nod)); + phead->id = oid[0]; + } + p1 = phead; + while(i < oidlen) + { + if(p1->id == oid[i]) + { + if(i == oidlen-1) + p1->snmp_proc = snmp_proc; + else + { + if(p1->psub == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i+1]; + p1->psub = p2; + p1 = p2; + } + else + p1 = p1->psub; + } + } + else + { + if(p1->pnext == NULL) + { + p2 = (mib_nod *)getmem(sizeof(mib_nod)); + p2->id = oid[i]; + p1->pnext = p2; + p1 = p2; + } + else + p1 = p1->pnext; + continue; + } + i++; + } + //rspcall_num++; + //snmp_hb_init(); +} +/********************************************************************/ + +int snmp_send(snmp_pdu *msgbuf, snmp_addr *addr) +{ + message_list msgout; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; +#endif + snmp_logmsg(SNMPDB_OUT, msgbuf, addr); + if(msgbuf->var_num == 0 || msgbuf->var_num > BIND_MAX) + { + snmp_debug(SNMPDB_ERR, "var_num = %d, exceed limit(%d)", msgbuf->var_num, BIND_MAX); + snmp_logmsg(SNMPDB_ERR, msgbuf, addr); + return 0; + } + +#if SNMP_DEBUG_LOG + sprintf(debugBuf,"snmp_send() pdu_type: %d",msgbuf->pdu_type); + snmpLogInfo(debugBuf); +#endif + + switch(msgbuf->pdu_type) + { + case PDU_SET: + pCsta->set_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0) + msgbuf->request_id = assign_rid(); + break; + case PDU_GET: + pCsta->get_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + //add by yizane start + case PDU_GETNEXT: + pCsta->getnext_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + case PDU_GETBULK: + pCsta->getbulk_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + //add by yizane end + case PDU_TRAP: + pCsta->trap_out++; + msgbuf->request_id = 1; + +#ifdef _EWS_H_ + if(addr->local_port == 4957 && addr->remote_port == 4957) + { + ews_proc_heartbeat(msgbuf->var[0].oidlen, + msgbuf->var[0].oid, + msgbuf->var[0].msglen, + msgbuf->var[0].msg); + } +#endif + break; + case PDU_RSP: + pCsta->rsp_out++; + break; + default: + return 0; + } +#if SNMP_DEBUG_LOG + sprintf(debugBuf,"snmp_send->msginfo: %08lx.%04d to %08lx.%04d", + addr->local_ip,addr->local_port, + addr->remote_ip,addr->remote_port); + snmpLogInfo(debugBuf); +#endif + + msgout.msgLength = build_snmpmsg(msgout.msgContent, msgbuf); + if(msgout.msgLength == 0 || msgout.msgLength > 1500) + { + snmp_debug(SNMPDB_ERR, "Encoding Failure or Message length exceed limit"); + snmp_logmsg(SNMPDB_ERR, msgbuf, addr); + return 0; + } + + msgout.msgDstIP = addr->remote_ip ; + msgout.msgDstPort = addr->remote_port ; + msgout.msgSrcIP = addr->local_ip ; + msgout.msgSrcPort = addr->local_port ; + msgout.msgBroadcast = addr->broadcast ; + +#if SNMP_DEBUG_LOG + snmpLogInfo("end of snmp_send()"); +#endif + if(iptrPutMessage(msgout) == 0) + return 0; + else + return msgbuf->request_id; +} + +int snmp_plat_send(snmp_pdu *msgbuf, snmp_addr *addr) +{ + message_list msgout; + + snmp_logmsg(SNMPDB_OUT, msgbuf, addr); + if(msgbuf->var_num == 0 || msgbuf->var_num >BIND_MAX) + { + snmp_debug(SNMPDB_ERR, "var_num = %d, exceed limit(%d)", msgbuf->var_num, BIND_MAX); + snmp_logmsg(SNMPDB_ERR, msgbuf, addr); + return 0; + } + + switch(msgbuf->pdu_type) + { + case PDU_SET: + pCsta->set_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + case PDU_GET: + pCsta->get_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + //add by yizane start + case PDU_GETNEXT: + pCsta->getnext_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + case PDU_GETBULK: + pCsta->getbulk_out++; + msgbuf->error_index = msgbuf->error_status = 0; + if(msgbuf->request_id == 0 ) + msgbuf->request_id = assign_rid(); + break; + //add by yizane end + case PDU_TRAP: + pCsta->trap_out++; + msgbuf->request_id = 1; +#ifdef _EWS_H_ + if(addr->local_port == 4957 && addr->remote_port == 4957) + { + ews_proc_heartbeat(msgbuf->var[0].oidlen, + msgbuf->var[0].oid, + msgbuf->var[0].msglen, + msgbuf->var[0].msg); + } +#endif + break; + case PDU_RSP: + pCsta->rsp_out++; + break; + default: + return 0; + } + + msgout.msgLength = build_snmpmsg(msgout.msgContent , msgbuf); + if(msgout.msgLength == 0 || msgout.msgLength > 1500) + { + snmp_debug(SNMPDB_ERR, "Encoding Failure or Messages length exceed limit"); + snmp_logmsg(SNMPDB_ERR, msgbuf, addr); + return 0; + } + + msgout.msgDstIP = addr->remote_ip ; + msgout.msgDstPort = addr->remote_port ; + msgout.msgSrcIP = addr->local_ip ; + msgout.msgSrcPort = addr->local_port ; + msgout.msgBroadcast = addr->broadcast ; + + if(iptrPlatPutMessage(msgout) == 0) + return 0; + else + return msgbuf->request_id; +} + + +int snmp_receive(snmp_pdu *msgbuf, snmp_addr *addr) +{ + message_list msgin; +#if SNMP_DEBUG_SNMP + char debugBuf[512]; +#endif + + if(iptrGetMessage(&msgin, addr->local_port) == 1) + { +#if SNMP_DEBUG_SNMP + sprintf(debugBuf,"snmp_receive(),len=%d, %08x.%04d from %08x.%04d entering parse_shmpmsg()", + msgin.msgLength, + msgin.msgSrcIP,msgin.msgSrcPort, + msgin.msgDstIP,msgin.msgDstPort); + snmpLogInfo(debugBuf); +#endif + if(parse_snmpmsg(msgin.msgContent, msgin.msgLength, msgbuf) == 1 && msgbuf->var_num>0) + { + addr->remote_ip = msgin.msgSrcIP; + addr->remote_port = msgin.msgSrcPort; + addr->local_port = msgin.msgDstPort; + addr->local_ip = msgin.msgDstIP; + + snmp_logmsg(SNMPDB_IN, msgbuf, addr); + return 1; + } + else + { + snmp_debug(SNMPDB_ERR, "Fail to parse message, Give up dealing with it"); + snmp_showbuf(SNMPDB_ERR, msgin.msgContent, msgin.msgLength); + } + } + return 0; +} + +/********************************************************************/ + +int build_snmpmsg(BYTE *pbuf, snmp_pdu *psnmp) +{ + BYTE msg[2000]; + short pos = 1900, len; + var_list *pvar; + BYTE var_num; + BYTE idlen; + DWORD *poid, val; + short stack[10]; + BYTE pstack = 0; + BOOL error_status = 0; +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf,"build_snmpmsg(): var_num: %d",psnmp->var_num); + snmpLogInfo(debugBuf); +#endif + + + var_num = psnmp->var_num; + for(pstack = 0; pstack < 5; pstack++) + stack[pstack] = pos; //push + + while(var_num-- >0) + { + stack[pstack++] = pos; //push + pvar = &psnmp->var[var_num]; + //add by yizane start + if(psnmp->pdu_type == PDU_GET|| + psnmp->pdu_type == PDU_GETBULK|| + psnmp->pdu_type == PDU_GETNEXT) + //add by yizane end + { + pvar->vartype = 5; + pvar->msglen = 0; + } + else + { + switch(pvar->vartype) + { + case 5: //NULL + case NoSuchObject: + case NosuchInstance: + case EndOfMibView: + pvar->msglen = 0; + } + } + poid = pvar->oid; + //Value + if(pvar->msglen > SNMP_VAR_MAX) + { + if(psnmp->error_status == 0) + { + psnmp->error_status = 1; //Too big + psnmp->error_index = var_num; + } + snmp_debug(SNMPDB_ERR, "Variable's length(%d) exceed limit:varindex = %d", pvar->msglen, SNMP_VAR_MAX, var_num); + pvar->msglen = 0; + error_status = 1; + return 0; + } + else if((pos - pvar->msglen) < 500) + { + if(psnmp->error_status == 0) + { + psnmp->error_status = 1; //Too big + psnmp->error_index = var_num; + } + snmp_debug(SNMPDB_ERR, "Totol length(%d) exceed limit(1500):current varindex = %d", 1900-pos+pvar->msglen, var_num); + pstack--; + pvar->msglen = 0; +// error_status = 1; +// return 0; + break; + } + else if(pvar->msglen > 0) + { + memcpy(msg + pos - pvar->msglen + 1, pvar->msg, pvar->msglen); //V + } + pos -= pvar->msglen; + + insert_length(msg, pos, pvar->msglen); //L + msg[pos--] = pvar->vartype; //T + //Object ID + stack[pstack++] = pos; //push + + idlen = pvar->oidlen; + if(idlen >= OID_MAXLEN) + { +// snmp_debug(SNMPDB_ERR, "OID's Length(%d) is Invalid.", idlen); + return 0; + } + + while(idlen-- > 2) //V + { + val = poid[idlen]; + if(val < 0x80) //1byte + *(msg + (pos--)) = val; + else if(val < 0x4000) //2byte + { + *(msg + (pos--)) = val & 0x7F; + *(msg + (pos--)) = ((val & 0x3FFF) >> 7) | 0x80; + } + else if(val < 0x200000) //3byte + { + *(msg + (pos--)) = val & 0x7F; + *(msg + (pos--)) = ((val & 0x3FFF) >> 7) | 0x80; + *(msg + (pos--)) = (val >> 14) | 0x80; + } + else if(val < 0x10000000) //4byte + { + *(msg + (pos--)) = val & 0x7F; + *(msg + (pos--)) = ((val & 0x3FFF) >> 7) | 0x80; + *(msg + (pos--)) = ((val & 0x1FFFFF) >> 14) | 0x80; + *(msg + (pos--)) = (val >> 21) | 0x80; + } + else //5byte + { + *(msg+(pos--)) = val & 0x7F; + *(msg+(pos--)) = ((val & 0x3FFF) >> 7) | 0x80; + *(msg+(pos--)) = ((val & 0x1FFFFF) >> 14) | 0x80; + *(msg+(pos--)) = ((val & 0x0FFFFFFF) >> 21) | 0x80; + *(msg+(pos--)) = (val>>28) | 0x80; + } + } + if(poid[0] > 3 || (poid[0] < 3 && poid[1] >= 40)) + { +// snmp_debug(SNMPDB_ERR, "Wrong oid, varindex = %d, oid = %ld.%ld...\n", var_num, poid[0], poid[1]); + return 0; + } + *(msg + (pos--)) = poid[idlen] + poid[idlen - 1] * 40; + + + len = stack[--pstack] - pos; //pop + insert_length(msg, pos, len); //L + msg[pos--] = 0x06; + //Variable + len = stack[--pstack] - pos; //pop + insert_length(msg, pos, len); //L + msg[pos--] = 0x30; //T + }; + + //Variable Binding + len = stack[--pstack] - pos; //pop + insert_length(msg, pos, len); //L + msg[pos--] = 0x30; //T + //add by yizane start + if(psnmp->pdu_type == PDU_GETBULK) + { + //max-repeaters + msg[pos--] = psnmp->max_repetitions; //V + msg[pos--] = 1; //L + msg[pos--] = 0x02; //T + //Non-repeaters + msg[pos--] = psnmp->non_repeaters; //V + msg[pos--] = 1; //L + msg[pos--] = 0x02; //T + } + else + { + //error index + msg[pos--] = psnmp->error_index; //V + msg[pos--] = 1; //L + msg[pos--] = 0x02; //T + //error status + msg[pos--] = psnmp->error_status ; //V + msg[pos--] = 1; //L + msg[pos--] = 0x02; //T + } + //add by yizane end + //request-id + enc_integer(msg, pos, psnmp->request_id); //V L + msg[pos--] = 0x02; //T + //PDU + len = stack[--pstack] - pos; //pop + insert_length(msg, pos, len); //L + msg[pos--] = psnmp->pdu_type | 0xA0; //T + //community + + if(psnmp->pdu_type == PDU_TRAP) + { + memcpy(msg + pos - 5, (BYTE *)COMMUNITY, 6); //V + pos -= 6; + msg[pos--] = 6; + } + else + { +#if SNMP_ANY_COMMUNITY + psnmp->community[15] = 0; //max length = 15 + comm_len = strlen(psnmp->community); + + memcpy(msg + pos - comm_len + 1, (BYTE *)psnmp->community, comm_len); //V + pos -= comm_len; + msg[pos--] = comm_len; +#else //use "public" as community + memcpy(msg + pos - 5, (BYTE *)COMMUNITY, 6); //V + pos -= 6; + msg[pos--] = 6; +#endif + } + if(pos<4) return 0; + /*added by LHB, Oct. 30 04 */ + if(pstack<2) return 0; + /*added by LHB, Oct. 30 04 */ + //L + msg[pos--] = 0x04; //T + //version + msg[pos--] = SNMP_V2; //V + msg[pos--] = 1; //L + msg[pos--] = 0x02; //T + //head + len = stack[--pstack] - pos; //pop + if(len<0) return 0; + /*added by LHB, Oct. 30 04 */ + insert_length(msg, pos, len); //L + msg[pos--] = 0x30; //T + len = stack[--pstack] - pos; //pop + if(len<0) return 0; + /*added by LHB, Oct. 30 04 */ + memcpy(pbuf, msg + pos + 1, len); + //if(error_status) + // return 0; + //else +#if SNMP_DEBUG_LOG + snmpLogInfo("end of build_snmpmsg()"); +#endif + return len; +} + +int parse_snmpmsg(BYTE *msgin, int msglen, snmp_pdu *psnmp) +{ + u_int pos = 0, idend; + u_int len, tmplen; + BYTE idlen, varindex = 0; + var_list *pvar; + DWORD *poid; + +#if SNMP_DEBUG_LOG + char debugBuf[512]; + sprintf(debugBuf,"parse_snmpmsg(), msg len = %d",msglen); + snmpLogInfo(debugBuf); +#endif + + if(msglen > 1536 || msglen < 0) + { + return -1; + } + + if(msgin[pos++] != 0x30) //T + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of SNMP Message. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + pos += tmplen; + + if(pos + len > msglen) //check length + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Message's length check error"); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + else //correct length + { + msglen = pos + len; + } + +//version------> + if(msgin[pos] != 2 || msgin[pos + 1] != 1) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of SNMP Message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += 2; + + if(msgin[pos] != SNMP_V1 && msgin[pos] != SNMP_V2) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Version check error, Version = %d", msgin[pos]); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos++; +//community------> + + if(msgin[pos++] != 4) //T + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of SNMP Message. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + + if(len > 32) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Invalid Length of community. pos = %d, len = %d", pos - tmplen, len); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + if((msgin[pos + len] & 0x1F) != PDU_TRAP) + { +#if SNMP_ANY_COMMUNITY + if(memcmp(msgin + pos, psnmp->community, len) != 0) //V + { + //authorization error + psnmp->error_status = 16; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Authorization error. COMMUNITY(%s):", psnmp->community); + snmp_showbuf(SNMPDB_ERR, msgin + pos, len); + } +#else //"public" as community + if(memcmp(msgin + pos, COMMUNITY, len) != 0) //V + { + //authorization error + psnmp->error_status = 16; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Authorization error. COMMUNITY(%s):", COMMUNITY); + snmp_showbuf(SNMPDB_ERR, msgin + pos, len); + } +#endif + } + pos += len; + +//PDU------> + psnmp->pdu_type = msgin[pos++] & 0x1F; //T + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + + if(pos + len != msglen) //check length + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Length check error"); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + //request-id------> + if(msgin[pos++] != 2) //T + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + if(len > 5) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: ASN.1 encoding error.pos = %d", pos - 4); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + psnmp->request_id = decode_integer(msgin + pos, len); //V + pos += len; + //error status------> + //add by yizane start + if(psnmp->pdu_type==PDU_GETBULK) + { + if(msgin[pos++] != 2) //T + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + if(len > 5) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: ASN.1 encoding error.pos = %d", pos - 4); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + idend = pos + len; + psnmp->non_repeaters = 0; + do //V + { + if((msgin[pos] & 0x80) == 0) + psnmp->non_repeaters |= msgin[pos]; + else + psnmp->non_repeaters = (psnmp->non_repeaters | (msgin[pos] & 0x7F)) << 7; + pos++; + }while(pos < idend); + } + else + { + if(msgin[pos] != 2 || msgin[pos + 1] != 1) //T L + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + pos += 2; + + if(psnmp->error_status == 0){ + psnmp->error_status = msgin[pos++]; //V + }else + pos++; + } + + //error index------> + if(psnmp->pdu_type==PDU_GETBULK) + { + if(msgin[pos++] != 2) //T + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + if(len > 5) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: ASN.1 encoding error.pos = %d", pos - 4); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + idend = pos + len; + psnmp->max_repetitions =0; + do //V + { + if((msgin[pos] & 0x80) == 0) + psnmp->max_repetitions |= msgin[pos]; + else + psnmp->max_repetitions = (psnmp->max_repetitions | (msgin[pos] & 0x7F)) << 7; + pos++; + }while(pos < idend); + } + else + { + if(msgin[pos] != 2 || msgin[pos + 1] != 1) //T L + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + pos += 2; + psnmp->error_index = msgin[pos++]; //V + } + //add by yizane end + + //variable-binding list------> + if(msgin[pos++] != 0x30) //T + { + //wrong encoding + if(psnmp->error_status == 0) + psnmp->error_status = 9; + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + } + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + + if(pos + len != msglen) //check length + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Message's Length check error"); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + //variable------> + varindex = 0; + do + { + pvar = &psnmp->var[varindex]; + + poid = pvar->oid; + if(msgin[pos++] != 0x30) //T + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong encoding of SNMP message. pos = %d", pos); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + //OID------> + if((msgin[pos++] & 0x3F) != 0x06) //T + { + if(psnmp->error_status == 0) + { + psnmp->error_status = 9; + } + } + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + + if(len > OID_MAXLEN) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: OID length exceed limit. oidlen = %d", len); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + + memset(poid, 0, sizeof(DWORD) * OID_MAXLEN); + idend = pos + len; + poid[0] = msgin[pos] / 40; + poid[1] = msgin[pos++] % 40; + idlen = 2; + do //V + { + if((msgin[pos] & 0x80) == 0) + poid[idlen++] |= msgin[pos]; + else + poid[idlen] = (poid[idlen] | (msgin[pos] & 0x7F)) << 7; + pos++; + }while(pos < idend && idlen < OID_MAXLEN); + + pvar->oidlen = idlen; + //value + pvar->vartype = msgin[pos++]; //T + + if((tmplen = get_len(msgin + pos, &len)) < 0) //L + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Wrong Encoding of Length. pos = %d", pos - 1); + snmp_showbuf(SNMPDB_ERR, msgin, msglen); + return -1; + } + pos += tmplen; + + if(len > 1500 || len > msglen-pos) + { + snmp_debug(SNMPDB_ERR, "parse_snmpmsg: Error length of variant.varindex = %d, length = %d", varindex, len); + return -1; + } + else if(len > 0) + { + memcpy(pvar->msg, msgin + pos, len); //V + } + pos += len; + pvar->msglen = len; + varindex++; + }while(pos < msglen); + + psnmp->var_num = varindex; + +#if SNMP_DEBUG_LOG + snmpLogInfo("end of parse_snmpmsg()"); +#endif + return 1; +} + +/********************************************************************/ +DWORD assign_rid() +{ + static DWORD rid = 1; + + rid = (rid-1)%0x10000000+2; + return rid; +} + +BYTE *getmem(int nsize) +{ + static BYTE heap[HEAP_SIZE]; //500K + static int heap_pos = 0; + if(heap_pos+nsize>HEAP_SIZE) + return NULL; + else + { + memset(heap+heap_pos, 0, nsize); + heap_pos+= nsize; + //printf("assigned memory = %d Byte\n", heap_pos); + return &heap[heap_pos-nsize]; + } +} +/********************************************************************/ + +int get_len(BYTE *asnbuf, int *len) +{ + u_int pos = 0, lenbyte; + + if((asnbuf[pos] & 0x80) == 0) + *len = asnbuf[pos++] & 0x7F; + else + { + *len = 0; + lenbyte = asnbuf[pos++] & 0x7F; + if(lenbyte > 4 || lenbyte < 0) + return -1; + + if(lenbyte == 0) + { + *len = -1; + return 1; + } + else + { + while(lenbyte-- > 0) + *len = (*len) * 0x100 + asnbuf[pos++]; + } + } + return pos; +} + +BYTE encode_integer(BYTE *buf, DWORD val) +{ + if(val < 128) + { + buf[0] = val; + return 1; + } + else if(val < 0x8000) + { + buf[0] = val >> 8; + buf[1] = val; + return 2; + } + else if(val < 0x800000) + { + buf[0] = val >> 16; + buf[1] = val >> 8; + buf[2] = val; + return 3; + } + else if(val < 0x80000000) + { + buf[0] = val >> 24; + buf[1] = val >> 16; + buf[2] = val >> 8; + buf[3] = val; + return 4; + } + else + { + buf[0] = 0; + buf[1] = val >> 24; + buf[2] = val >> 16; + buf[3] = val >> 8; + buf[4] = val; + return 5; + } +} + +DWORD decode_integer(BYTE *buf, BYTE len) +{ + BYTE i = 0; + DWORD val = 0; + while(i < len) + val = (val << 8) | buf[i++]; + return val; +} + + + + + diff --git a/omc/plat/snmp/src/snmpdebug.c b/omc/plat/snmp/src/snmpdebug.c new file mode 100644 index 0000000..a143fe8 --- /dev/null +++ b/omc/plat/snmp/src/snmpdebug.c @@ -0,0 +1,496 @@ +/**************************************************/ +/*Title: snmpdebug.c */ +/*Descr: Debug Module of SNMP Agent */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-1 */ +/*Modify: */ +/**************************************************/ +#include "./include/heartbeat.h" + +static char debug_buf[4096]; +static char asc_in[256]; +static DWORD title_id[20]={1,3,6,1,4,1,1373,1,3,2,3,1,2,13,8,1}; + +//private function +BYTE snmpDebugFull = 0; +static snmp_filter SnmpFilter[8]; +static BYTE SnmpFilterIndex = 0; +static DWORD debug_mask = SNMP_DEBUG_MASK; +extern snmp_csta SnmpCsta[96]; +extern heartbeat_shm *HbShm; +static char Type_Name[9][16] = {"Get", "GetNext" +, "Response", "Set", "Trap-V1", "GetBulk", "Inform", "Trap-V2", "Report"}; +static char help_info[] = "Commands provided now:\r\n\ +help\r\n\ +log all Output all debug information\r\n\ +log none Turn off all information\r\n\ +log error on/off Show error information\r\n\ +log noreg on/off Alarm if oid is not registered\r\n\ +log value on/off Show value party of snmp message\r\n\ +log alarm on/off Show alarm information of platform\r\n\ +log sys on/off Show system information\r\n\ +log type cond1 (and cond2...) Show message due to specified condition\r\n\ + type should be snmp/trap/set/get/rsp\r\n\ + One or more conditions could be taken:\r\n\ + oid=x.x../ip=xx/local port=xx/remote port=xx\r\n\ + For example:log trap oid=1.3.6.1.4.1373 and ip=172.18.98.1\r\n\ +list register List all registered oid\r\n\ +list status List system status\ +"; + +int snmp_filter_msg(snmp_pdu *pMsg, snmp_addr *pAddr); +extern int Str2Oid(DWORD *pOid, char *pStr, BYTE maxLen); + +/* by simon at 23/9/25 */ +extern char SnmpVer[16]; + +void snmp_debug_setup() +{ + DWORD asc_id[20]={1,3,6,1,4,1,1373,1,1,2,3,1,2,13,4}; + DWORD ascin_id[20]={1,3,6,1,4,1,1373,1,1,2,3,1,2,13,3}; + DWORD status_id[20]={1,3,6,1,4,1,1373,1,1,2,3,1,2,13,1}; + DWORD name_id[20]={1,3,6,1,4,1,1373,1,1,2,3,1,2,13,2}; + + static BYTE debug_status=1; + + debug_set_response(15,asc_id,debug_buf,1); + debug_set_response(15,ascin_id,asc_in,1); + debug_set_response(15,status_id,&debug_status,1); + debug_set_response(15,name_id, SnmpVer, strlen(SnmpVer)); +} + +void snmp_log(char *info) +{ + if(strlen(debug_buf) + strlen(info) > 4096) + { + snmpDebugFull = 1; + return; + } + + strncat(debug_buf, info, 4094); + strcat(debug_buf, "\r\n"); + return; +} + +int snmp_filter_msg(snmp_pdu *pMsg, snmp_addr *pAddr) +{ + int i; + for(i = 0; i < SnmpFilterIndex % 9; i++) + { + if(SnmpFilter[i].type != pMsg->pdu_type && pMsg->pdu_type != 0xFF) + continue; + if(SnmpFilter[i].flag & 0x01) + { + if(SnmpFilter[i].ip != pAddr->remote_ip) + continue; + } + if(SnmpFilter[i].flag & 0x02) + { + if(memcmp(SnmpFilter[i].oid, pMsg->var[0].oid, SnmpFilter[i].oidlen * 4) != 0) + continue; + } + if(SnmpFilter[i].flag & 0x04) + { + if(SnmpFilter[i].local_port != pAddr->local_port) + continue; + } + if(SnmpFilter[i].flag & 0x08) + { + if(SnmpFilter[i].remote_port != pAddr->remote_port) + continue; + } + return 1; + } + return 0; +} + +void snmp_debug(DWORD mask, const char *fmt, ...) +{ + va_list ap; + char buf[1024]; + + if((mask & debug_mask) == 0 || snmpDebugFull) + return; + + if(mask & SNMPDB_ERR) + strcat(debug_buf, "\33[31m"); + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + strcat(buf,"\33[37m"); + snmp_log(buf); +} + +void snmp_showbuf(DWORD mask, BYTE *buf, int len) +{ + int i = 0, j = 0, linemax = 24; + char info[1024]; + + if((debug_mask & SNMPDB_VALUE) == 0 || (debug_mask & mask) == 0 || snmpDebugFull) + return; + + if(len >= 256) + len = 256; + + while(i * 24 < len) + { + if((linemax = len - 24 * i) > 24) + linemax = 24; + for(j = 0; j < linemax; j ++) + { + sprintf(info + 3 * j, "%02X ", buf[24 * i + j]); + } + snmp_log(info); + i ++; + } +} +int oid2str(char *pStr, DWORD *oid, BYTE oidlen) +{ + int i; + char tmpstr[16]; + + pStr[0] = 0; + if(oidlen > OID_MAXLEN) oidlen = OID_MAXLEN; + + for(i = 0; i < oidlen - 1; i++) + { + sprintf(tmpstr, "%ld.", oid[i]); + strcat(pStr, tmpstr); + } + sprintf(tmpstr, "%ld", oid[oidlen - 1]); + strcat(pStr, tmpstr); + return 1; +} + +void snmp_logvalue(BYTE *msgbuf, short msglen) +{ + int len, i = 0, j, linemax; + char info[1024]; + + len = msglen % 256; + while(i * 24 < len) + { + if((linemax = len - 24 * i) > 24) + linemax = 24; + for(j = 0; j < linemax; j ++) + { + sprintf(info + 3 * j, "%02X ", msgbuf[24 * i + j]); + } + snmp_log(info); + i ++; + } +} + +void snmp_logmsg(DWORD mask, snmp_pdu *pdu, snmp_addr *addr) +{ + struct in_addr inaddr; + int i = 0; + char info[1024], oidstr[64], desc[64] = "\0"; + + if((debug_mask & mask) == 0 && snmp_filter_msg(pdu, addr) == 0) + return; + + if(snmpDebugFull) + return; + + if(mask & SNMPDB_ERR) + strcat(debug_buf, "\33[31m"); + + inaddr.s_addr = addr->remote_ip; + if(mask & SNMPDB_IN) + sprintf(desc, "\r\nlocal:%d <== %s:%d ", addr->local_port, inet_ntoa(inaddr), addr->remote_port); + else if(mask & SNMPDB_OUT) + sprintf(desc, "\r\nlocal:%d ==> %s:%d ", addr->local_port, inet_ntoa(inaddr), addr->remote_port); + else + sprintf(desc, "\r\nlocal:%d <=> %s:%d ", addr->local_port, inet_ntoa(inaddr), addr->remote_port); + + sprintf(info, "%sType=%s, RID=%ld, Error=%d, Bind=%d\33[37m", desc, Type_Name[pdu->pdu_type], pdu->request_id + , pdu->error_status, pdu->var_num); + snmp_log(info); + + for(i = 0; i < pdu->var_num % 16; i++) + { + oid2str(oidstr, pdu->var[i].oid, pdu->var[i].oidlen); + sprintf(info, "oid[%d]=%s, vartype=%02x, msglen=%d", i, oidstr, pdu->var[i].vartype, pdu->var[i].msglen); + snmp_log(info); + + if((debug_mask & SNMPDB_VALUE) == 0) + return; + snmp_logvalue(pdu->var[i].msg, pdu->var[i].msglen); + } + +} + +static int get_word(char *pWord, char *pInStr, BYTE max) +{ + char *pStart = pInStr, *pCh = NULL; + + while(*pStart == ' ' || *pStart == '\t') + pStart ++; + + strncpy(pWord, pStart, max); + pCh = strchr(pWord, ' '); + if(pCh != NULL) + *pCh = 0; + return 1; +} + +static int parsecond(char *cmdstr, BYTE type) +{ + char *pKey = cmdstr, *pEQ, info[256], tmpStr[64], valStr[32]; + + if(SnmpFilterIndex >= 8) + { + snmp_log("only 8 pieces of condition can be set"); + return 0; + } + + sprintf(info, "type = 0x%02X", type); + SnmpFilter[SnmpFilterIndex].type = type; + SnmpFilter[SnmpFilterIndex].flag = 0; + + if((pKey = strstr(cmdstr, "ip")) != NULL && (pEQ = strchr(pKey, '=')) != NULL) + { + get_word(valStr, pEQ + 1, 32); + SnmpFilter[SnmpFilterIndex].ip = inet_addr(valStr); + sprintf(tmpStr, " and ip = %s", valStr); + strcat(info, tmpStr); + SnmpFilter[SnmpFilterIndex].flag |= 0x01; + } + if((pKey = strstr(cmdstr, "oid")) != NULL && (pEQ = strchr(pKey, '=')) != NULL) + { + get_word(valStr, pEQ + 1, 32); + if(SnmpFilter[SnmpFilterIndex].flag > 0) strcat(info, " and "); + sprintf(tmpStr, " and oid = %s", valStr); + strcat(info, tmpStr); + SnmpFilter[SnmpFilterIndex].oidlen = Str2Oid(SnmpFilter[SnmpFilterIndex].oid, valStr, OID_MAXLEN) % OID_MAXLEN; + SnmpFilter[SnmpFilterIndex].flag |= 0x02; + } + if((pKey = strstr(cmdstr, "local port")) != NULL && (pEQ = strchr(pKey, '=')) != NULL) + { + get_word(valStr, pEQ + 1, 32); + SnmpFilter[SnmpFilterIndex].local_port = atoi(valStr); + if(SnmpFilter[SnmpFilterIndex].flag > 0) strcat(info, " and "); + sprintf(tmpStr, " and local port = %d", SnmpFilter[SnmpFilterIndex].local_port); + strcat(info, tmpStr); + SnmpFilter[SnmpFilterIndex].flag |= 0x04; + } + if((pKey = strstr(cmdstr, "remote port")) != NULL && (pEQ = strchr(pKey, '=')) != NULL) + { + get_word(valStr, pEQ + 1, 32); + SnmpFilter[SnmpFilterIndex].remote_port = atoi(valStr); + if(SnmpFilter[SnmpFilterIndex].flag > 0) strcat(info, " and "); + sprintf(tmpStr, " and remote port = %d", SnmpFilter[SnmpFilterIndex].remote_port); + strcat(info, tmpStr); + SnmpFilter[SnmpFilterIndex].flag |= 0x08; + } + + SnmpFilterIndex ++; + snmp_log(info); + snmp_log("command OK"); + return 1; +} + +void snmp_debug_timer() +{ + BYTE npage, nline; + char *cmdstr = asc_in + 1; + if(strlen(asc_in) <= 1) + return; + debug_buf[0] = '\0'; + npage = asc_in[0] - 1; + + if(npage > 0) + { + nline = atoi(asc_in + 1); + switch(npage) + { + case 1: //csta + snmp_debug_csta(1,nline); + break; + } + asc_in[0]='\0'; + return; + } + + asc_in[0]='\0'; + if(strstr(cmdstr, "help") != NULL || strstr(cmdstr, "?") != NULL) + { + snmp_log(help_info); + return; + } + else if(strstr(cmdstr, "log all") != NULL) + { + SnmpFilterIndex = 0; + debug_mask = 0xFFFFFFFF; + } + else if(strstr(cmdstr, "log none") != NULL) + { + SnmpFilterIndex = 0; + debug_mask = 0; + } + else if(strstr(cmdstr, "log error on") != NULL) + debug_mask |= SNMPDB_ERR; + else if(strstr(cmdstr, "log error off") != NULL) + debug_mask &= (~SNMPDB_ERR); + else if(strstr(cmdstr, "log onreg on") != NULL) + debug_mask |= SNMPDB_NOREG; + else if(strstr(cmdstr, "log onreg off") != NULL) + debug_mask &= (~SNMPDB_NOREG); + else if(strstr(cmdstr, "log value on") != NULL) + debug_mask |= SNMPDB_VALUE; + else if(strstr(cmdstr, "log value off") != NULL) + debug_mask &= (~SNMPDB_VALUE); + else if(strstr(cmdstr, "log alarm on") != NULL) + debug_mask |= SNMPDB_ALARM; + else if(strstr(cmdstr, "log alarm off") != NULL) + debug_mask &= (~SNMPDB_ALARM); + else if(strstr(cmdstr, "log mib on") != NULL) + debug_mask |= SNMPDB_MIB; + else if(strstr(cmdstr, "log mib off") != NULL) + debug_mask &= (~SNMPDB_MIB); + else if(strstr(cmdstr, "log sys on") != NULL) + debug_mask |= SNMPDB_SYS; + else if(strstr(cmdstr, "log sys off") != NULL) + debug_mask &= (~SNMPDB_SYS); + else if(strstr(cmdstr, "log snmp") != NULL) + { + parsecond(cmdstr + 8, 0xFF); + return; + } + else if(strstr(cmdstr, "log get") != NULL) + { + parsecond(cmdstr + 7, 0); + return; + } + else if(strstr(cmdstr, "log set") != NULL) + { + parsecond(cmdstr + 7, 3); + return; + } + else if(strstr(cmdstr, "log rsp") != NULL) + { + parsecond(cmdstr + 7, 2); + return; + } + else if(strstr(cmdstr, "log trap") != NULL) + { + parsecond(cmdstr + 8, 7); + return; + } + else + { + snmp_log("Invalid command/parameter(s)."); + return; + } + + snmp_log("Command OK"); + return; +} + +void snmp_debug_info(BYTE npage, BYTE nline, BYTE *pt, BYTE len) +{ + DWORD oid[20]={1,3,6,1,4,1,1373,1,1,2,3,1,2,13,5,2,2}; + oid[14] = 5 + npage; + oid[15] = 2 + nline; + debug_set_response(17, oid, pt, len); +} + +/*-----------------------------------------------*/ +/*-------------------CSTA------------------------*/ +/*-----------------------------------------------*/ +void snmp_debug_csta(BYTE npage,int instance) +{ + char title[256]; + snmp_csta *pcsta; + + instance=instance%96; + pcsta=&SnmpCsta[instance]; + + sprintf(title,"\tSNMP-%s\tPage %02d\t\tMIB-CSTA(ID:1 Instance:%d)\r\n\r\n"\ + "trap in\r\n"\ + "trap out\r\n"\ + "set in\r\n"\ + "set out\r\n"\ + "get in\r\n"\ + "get out\r\n"\ + "rsp in\r\n"\ + "rsp out\r\n"\ + "fail to parse\r\n"\ + "OID Not registered\r\n"\ + "fail to build\r\n", SnmpVer, npage, instance); + + title_id[14]=5+npage; + debug_set_response(16,title_id,title,strlen(title)); + + snmp_debug_info(npage,0,(BYTE *)&pcsta->trap_in,4); + snmp_debug_info(npage,1,(BYTE *)&pcsta->trap_out,4); + snmp_debug_info(npage,2,(BYTE *)&pcsta->set_in,4); + snmp_debug_info(npage,3,(BYTE *)&pcsta->set_out,4); + snmp_debug_info(npage,4,(BYTE *)&pcsta->get_in,4); + snmp_debug_info(npage,5,(BYTE *)&pcsta->get_out,4); + snmp_debug_info(npage,6,(BYTE *)&pcsta->rsp_in,4); + snmp_debug_info(npage,7,(BYTE *)&pcsta->rsp_out,4); + snmp_debug_info(npage,8,(BYTE *)&pcsta->fail_parse,4); + snmp_debug_info(npage,9,(BYTE *)&pcsta->not_register,4); + snmp_debug_info(npage,10,(BYTE *)&pcsta->fail_build,4); + +} + +void snmp_debug_hb(BYTE npage) +{ + char title[512]; + sprintf(title,"\tSNMP-%s\tPage %02d\t\tHeartBeat\r\n"\ + "\r\n"\ + "subsys id\r\n"\ + "LED\r\n"\ + "Component 0\r\n"\ + "\r\n"\ + "Component 1\r\n"\ + "\r\n"\ + "Component 2\r\n"\ + "\r\n"\ + "Component 3\r\n"\ + "\r\n"\ + "Component 4\r\n"\ + "\r\n"\ + "Component 5\r\n"\ + "\r\n"\ + "Component 6\r\n"\ + "\r\n"\ + "alarm num\r\n"\ + "HB message\r\n\r\n", SnmpVer, npage); + + title_id[14]=5+npage; + + debug_set_response(16,title_id,title,strlen(title)); + + snmp_debug_info(npage,0,(BYTE *)&HbShm->sys_id,2); + snmp_debug_info(npage,1,(BYTE *)HbShm->led,LED_NUM); + snmp_debug_info(npage,2,(BYTE *)&HbShm->component[0],20); + snmp_debug_info(npage,3,(BYTE *)&HbShm->component[0]+20,20); + snmp_debug_info(npage,4,(BYTE *)&HbShm->component[1],20); + snmp_debug_info(npage,5,(BYTE *)&HbShm->component[1]+20,20); + snmp_debug_info(npage,6,(BYTE *)&HbShm->component[2],20); + snmp_debug_info(npage,7,(BYTE *)&HbShm->component[2]+20,20); + snmp_debug_info(npage,8,(BYTE *)&HbShm->component[3],20); + snmp_debug_info(npage,9,(BYTE *)&HbShm->component[3]+20,20); + snmp_debug_info(npage,10,(BYTE *)&HbShm->component[4],20); + snmp_debug_info(npage,11,(BYTE *)&HbShm->component[4]+20,20); + snmp_debug_info(npage,12,(BYTE *)&HbShm->component[5],20); + snmp_debug_info(npage,13,(BYTE *)&HbShm->component[5]+20,20); + snmp_debug_info(npage,14,(BYTE *)&HbShm->component[6],20); + snmp_debug_info(npage,15,(BYTE *)&HbShm->component[6]+20,20); + + snmp_debug_info(npage,16,(BYTE *)&HbShm->alarm_num,1); + snmp_debug_info(npage,17,(BYTE *)&HbShm->msg,20); + snmp_debug_info(npage,18,(BYTE *)&HbShm->msg+20,20); + snmp_debug_info(npage,19,(BYTE *)&HbShm->msg+40,20); + snmp_debug_info(npage,20,(BYTE *)&HbShm->msg+60,20); + snmp_debug_info(npage,21,(BYTE *)&HbShm->msg+80,20); + +} + + + diff --git a/omc/plat/snmp/src/snmpmib.c b/omc/plat/snmp/src/snmpmib.c new file mode 100644 index 0000000..49a00f2 --- /dev/null +++ b/omc/plat/snmp/src/snmpmib.c @@ -0,0 +1,270 @@ +/**************************************************/ +/*Title: snmpdebug.c */ +/*Descr: Debug Module of SNMP Agent */ +/*Author: Liang Hanxi */ +/*Create: 2002-4-1 */ +/*Modify: */ +/**************************************************/ +#include "./include/heartbeat.h" +static unsigned long l_starttime; +extern snmp_csta SnmpCsta[96]; +extern int snmp_ins; +extern heartbeat_shm *HbShm; + +int snmp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen); +int snmp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +int snmp_getsys(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +void time_sync(BYTE oidlen,DWORD *oid,BYTE *pdata,WORD len,snmp_addr *addr); +static void submit_snmpcsta(BYTE *pdword,BYTE *pbyte,int len); +/* by simon at 23/9/25 */ +extern char SnmpVer[16]; + +void snmpmib_init() +{ + DWORD oid[OID_MAXLEN]=SNMP_OID; + DWORD sysoid[8]={1,3,6,1,2,1,1}; + l_starttime=time(NULL); + inquire_getmsg(SNMP_OIDLEN,oid,snmp_getmib); + inquire_setmsg(SNMP_OIDLEN,oid,snmp_setmib); + inquire_getmsg(7,sysoid,snmp_getsys); + inquire_trapmsg(time_sync); +} + +int snmp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen) +{ + return -1; + switch(oid[SNMP_OIDLEN]) + { + case 1: //Measure + return -1; //read only + case 2: //Configuration + switch(oid[SNMP_OIDLEN+1]) + { + case 1: //SNMP Parameter + switch(oid[SNMP_OIDLEN+2]) + { + case 1: //Port + return -1; //not allow + case 2: //password + return -1; //not provide now + } + break; + case 2: + break; + + case 3: + break; + } + break; + case 3: + break; + } +} + + +int snmp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ + int instance; + snmp_csta *pcsta; + switch(oid[SNMP_OIDLEN]) + { + case 1: //csta + if(oidlen!=SNMP_OIDLEN+2) + return -1; + instance=oid[SNMP_OIDLEN+1]; + if(instance==snmp_ins || instance>95) + { + *vartype=NosuchInstance; + snmp_debug(SNMPDB_MIB,"csta message not ready.instance=%d",instance); + return -1; + } + pcsta=&SnmpCsta[instance]; + if(pcsta->timestamp ==0) + { + snmp_debug(SNMPDB_MIB,"csta message is expired"); + *vartype=5; + return 0; + } + *vartype=4; + snmp_debug(SNMPDB_MIB, "Respond csta message"); + submit_snmpcsta((BYTE *)&pcsta->timestamp,pdata,sizeof(snmp_csta)); + //memcpy(pdata,(BYTE *)&pcsta->timestamp,sizeof(snmp_csta)); + return sizeof(snmp_csta); + default: + return -1; + } + return -1; +} + + +int snmp_getsys(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ + unsigned long l_time; + char contact[50]="InterWAVE"; + char sysname[50]; + + switch(oid[oidlen - 1]) + { + case 1: + *vartype = 4; + memcpy(pdata, SnmpVer, strlen(SnmpVer)); + return strlen(SnmpVer); + case 3: + l_time=time(NULL); + *vartype=0x43; + return encode_integer(pdata,(l_time-l_starttime)*100); + case 4: + *vartype=4; + memcpy(pdata,contact,strlen(contact)); + return strlen(contact); + case 5: + *vartype=4; + sprintf(sysname,"SNMP Agent %d.%d",HbShm->sys_id,HbShm->subsys_id); + memcpy(pdata,sysname,strlen(sysname)); + return strlen(sysname); + } + return -1; +} + +#define SNMP_OMC_HB_OID {1,3,6,1,4,1,1373,2,4,1} +#define SNMP_OMC_HB_OIDLEN 10 +#define SNMP_SERNUM_LEN 4 + +unsigned long long Bcd2Ull(BYTE *pBcd, int BcdLen); + +extern unsigned long long SNMPSerialNumber; +extern BYTE snmp_synctime_flag; +void time_sync(BYTE oidlen,DWORD *oid,BYTE *pdata,WORD len,snmp_addr *addr) +{ + //DWORD ObjID[20]=FLATFORM_HB_OID; + DWORD OMCHBObjID[20] = SNMP_OMC_HB_OID; + heartbeat_msg *pmsg=(heartbeat_msg *)pdata; + struct timeval tv; + struct timezone tz; + int l_time,l_temp; + static int master_host=0,master_timeout; + + char oidstring[256]; + char tmpstr[64]; + oidstring[0]=0; + int i; + + if (!snmp_synctime_flag) + return; + + if(memcmp(&oid[7], &OMCHBObjID[7], (SNMP_OMC_HB_OIDLEN - 7) * 4) == 0)//omc heartbeat + {//automatic add omc ip into ip list, + //if receive omc heartbeat and the omc serial number is equial to the local serial number, + //then the platform will send heartbeat if received omc heartbeat + if ((SNMPSerialNumber==0) ||//support old version, do not have serial number + (Bcd2Ull(&pdata[39],SNMP_SERNUM_LEN)==SNMPSerialNumber) ) + {} + else + return; + + } + else// if it is not omc heartbeat then return + return; + + if(pmsg->subsys_id ==HbShm->subsys_id && pmsg->sys_id ==HbShm->sys_id) + return; + +/* + if(memcmp(&oid[9],&ObjID[9],(FLATFORM_HB_OIDLEN-9)*4)!=0) + { + return; + } +*/ +/* + if(pmsg->sys_id!=MasterSysID || pmsg->subsys_id!=MasterSubSysID) + return; +*/ + + if(SNMPSerialNumber!=0){//New version + if(pdata[26]!=5&&pdata[26]!=7)//not the master omc + return; + }else{//Old version + if(pdata[21]!=5&&pdata[21]!=7)//not the master omc + return; + } + + memcpy((BYTE *)&l_temp,pmsg->timestamp,4); + l_time=htonl(l_temp); //timestamp in heartbeat + gettimeofday(&tv,&tz); //local time + + if(master_host==0 || master_timeout<=0) + { + snmp_debug(SNMPDB_SYS, "change master host to %lX",htonl(addr->remote_ip)); + master_host=addr->remote_ip; + master_timeout=8; + } + + if(addr->remote_ip != master_host) + { + master_timeout--; + snmp_debug(SNMPDB_SYS, "Found another master,ip=%lX.current master=%lX,timeout=%ld\n",htonl(addr->remote_ip),htonl(master_host),master_timeout); + return; + } + else + master_timeout=8; + + if(abs(l_time-tv.tv_sec)<2) //compare + { + return; + } + timeSync_log("system's time's second is :%ld",tv.tv_sec); + tv.tv_sec =l_time; + settimeofday(&tv,&tz); + for(i=0;iremote_ip)); + + snmp_debug(SNMPDB_SYS, "system's time is changed by %lX\n",htonl(addr->remote_ip)); +} + +void submit_snmpcsta(BYTE *pdword,BYTE *pbyte,int len) +{ + int i; + DWORD *p1,*p2; + for(i=0;itm_year+1900,t->tm_mon+1,t->tm_mday); + fp=fopen(logFile,"a"); + if(fp!=NULL) + { + va_start(ap,fmt); + vsprintf(buf,fmt,ap); + sprintf(timestr,"%02d:%02d:%02d: ",t->tm_hour,t->tm_min,t->tm_sec); + fputs(timestr,fp); + fputs(buf,fp); + fputs("\n",fp); + fflush(fp); + va_end(ap); + fclose(fp); + } +//#endif +} \ No newline at end of file diff --git a/omc/plat/snmp/src/snmptable.c b/omc/plat/snmp/src/snmptable.c new file mode 100644 index 0000000..0f5af7d --- /dev/null +++ b/omc/plat/snmp/src/snmptable.c @@ -0,0 +1,269 @@ +/* + * snmp/snmptable.c + * + * Copyright (C) 2008 ADC, Inc + * Written by: Xinyu Yan + * + * Description: provide a mechanism to register and maintain snmp table, simplify app programing + */ + +#include "./include/snmp.h" + + +#define MAX_SNMP_REGISTER 32 /* Maximum of modules registering snmp table */ + +/* It's great chance that next object and current one in same table, so cache improves searching efficiency */ +static struct snmp_table_profile *cache; +static struct snmp_register *reg_cache; +static struct snmp_register snmpregister[MAX_SNMP_REGISTER]; + +//#define PRINT_OID + +#ifdef PRINT_OID +static void printoid(u32 *oid, u8 len) +{ + int i; + + if(len == 0) + printf("OID length is 0!\n"); + + printf("%ld", oid[0]); + for(i = 1; i < len; i++) + { + printf(".%ld", oid[i]); + } + printf("\n"); +} +#endif + +/* To check if oid matches oid prefix */ +static int oid_match_prefix(u8 prefix_len, u32 *prefix, u8 oid_len, u32 *oid) +{ + if(prefix_len == 0) + return 0; + if(oid_len < prefix_len) + return 0; + if(!memcmp(prefix, oid, prefix_len*sizeof(u32))) + return 1; + else + return 0; +} + +static struct snmp_register *find_snmp_register(u8 oid_len, u32 *oid) +{ + int i; + struct snmp_register *reg; + + if(reg_cache != NULL) + { + if(oid_match_prefix(reg_cache->prefix_len, reg_cache->prefix_oid, oid_len, oid) == 1) + return reg_cache; + } + + for(i = 0; i < MAX_SNMP_REGISTER; i++) + { + reg = &snmpregister[i]; + if(oid_match_prefix(reg->prefix_len, reg->prefix_oid, oid_len, oid) == 1) + { + reg_cache = reg; + return reg; + } + } + return NULL; +} + +/* Check cache first, otherwise check all snmp tables by matching oid with table index */ +static struct snmp_table_profile *find_snmp_table(u8 oid_len, u32 *oid) +{ + int i; + struct snmp_register *reg; + struct snmp_table_profile *t; + + if(cache != NULL) + { + if(oid_match_prefix(cache->index.len, cache->index.oid, oid_len, oid) == 1) + return cache; + } + + if((reg = find_snmp_register(oid_len, oid)) == NULL) + return NULL; + + for(i = 0; i < reg->num_of_table; i++) + { + t = ®->table[i]; + if(oid_match_prefix(t->index.len, t->index.oid, oid_len, oid) == 1) + { + cache = t; + return t; + } + } + return NULL; +} + +static u32 find_next_column(u32 current_column, u32 *columns) +{ + int i; + + for(i = 0; i < MAX_COLUMNAR_OF_TABLE-1; i++) + { + if(current_column == columns[i]) + return columns[i+1]; + } + return 0; +} + +static void point_to_column_and_instance(u32 **column, u32 **instance, u32 *oid, struct snmp_table_profile *t) +{ + if(t->level != 0) + { + *column = oid + t->index.len + 1; /* count the entry, hence plus 1 */ + } + else + { + *column = oid + t->index.len; + } + *instance = *column + 1; +} + +static int table_set_response(u8 oidlen, u32 *oid, u8 *pdata, u16 datalen) +{ + struct snmp_table_profile *t; + struct snmp_register *reg; + u32 *column; + u32 *instance; + + if((t = find_snmp_table(oidlen, oid)) == NULL) + { + if((reg = find_snmp_register(oidlen, oid)) == NULL) + return -1; + if(reg->default_set_resp == NULL) + return -1; + else + return reg->default_set_resp(oidlen, oid, pdata, datalen); + } + + point_to_column_and_instance(&column, &instance, oid, t); + + if(t->set_resp == NULL) + return -1; + else + return t->set_resp(*column, instance, pdata, datalen); +} + +static int table_get_response(u8 oidlen, u32 *oid, u8 *pdata, u8 *vartype) +{ + struct snmp_table_profile *t; + struct snmp_register *reg; + u32 *column; + u32 *instance; + + if((t = find_snmp_table(oidlen, oid)) == NULL) + { + if((reg = find_snmp_register(oidlen, oid)) == NULL) + return -1; + if(reg->default_get_resp == NULL) + return -1; + else + return reg->default_get_resp(oidlen, oid, pdata, vartype); + } + + point_to_column_and_instance(&column, &instance, oid, t); + + if(t->get_resp == NULL) + return -1; + else + return t->get_resp(*column, instance, pdata, vartype); +} + +static int get_next_oid(u8 *oidlen, u32 *oid) +{ + struct snmp_table_profile *t; + u32 *entry; + u8 entry_oid_len; + u32 *column; + u8 column_oid_len; + u32 *instance; + u8 full_oid_len; + u8 plus_one_suppress = 0; + + if((t = find_snmp_table(*oidlen, oid)) == NULL) + return 0; + if(t->level == 0) /* If MIB is not table basis, do not support get next */ + return 0; + + entry = oid + t->index.len; + entry_oid_len = t->index.len + 1; + column = entry + 1; + column_oid_len = entry_oid_len + 1; + instance = column + 1; + full_oid_len = column_oid_len + t->level; + + if(*oidlen < full_oid_len) + { + memset(oid+*oidlen, 0, (full_oid_len-*oidlen)*sizeof(u32)); + if(*oidlen < entry_oid_len) + *entry = 1; + if(*oidlen < column_oid_len) + *column = t->column[0]; + *oidlen = full_oid_len; + plus_one_suppress = 1; + } + for(; *column != 0; *column = find_next_column(*column, t->column)) + { + if(plus_one_suppress == 0) + instance[t->level-1]++; + + if(t->get_instance(instance) == 1) + return 1; + else + { + memset(instance, 0, t->level*sizeof(u32)); + plus_one_suppress = 1; + } + } + return 0; +} + +static int table_getnext_response(u8 prev_oidlen, u32 *prev_oid, u8 *oidlen, u32 *oid, u8 *pdata, u8 *vartype) +{ + memcpy(oid, prev_oid, prev_oidlen*sizeof(u32)); + *oidlen = prev_oidlen; +#ifdef PRINT_OID + printf("Prev oid: "); + printoid(oid, *oidlen); +#endif + if(get_next_oid(oidlen, oid) == 1) + { +#ifdef PRINT_OID + printf("Next oid: "); + printoid(oid, *oidlen); +#endif + return table_get_response(*oidlen, oid, pdata, vartype); + } + else + return -1; +} + +int register_snmp_table(struct snmp_register *reg) +{ + int i; + struct snmp_register *r; + + /* TODO: check table validation */ + + for(i = 0; i < MAX_SNMP_REGISTER; i++) + { + r = &snmpregister[i]; + if(r->prefix_len == 0) + { + memcpy(r, reg, sizeof(struct snmp_register)); + inquire_getmsg(r->prefix_len, r->prefix_oid, table_get_response); + inquire_setmsg(r->prefix_len, r->prefix_oid, table_set_response); + inquire_getnextmsg(r->prefix_len, r->prefix_oid, table_getnext_response); + return 1; + } + } + return 0; +} + + diff --git a/omc/plat/snmp/src/snmptest.c b/omc/plat/snmp/src/snmptest.c new file mode 100644 index 0000000..f22c0da --- /dev/null +++ b/omc/plat/snmp/src/snmptest.c @@ -0,0 +1,254 @@ +#include "./include/snmp.h" +#include "./include/heartbeat.h" + +static struct itimerval itimer,old_itimer; +int intval; +char strval[50]="hello!"; +static void On_Timer(); +static void SetTimer(); +static int get_rsp(BYTE object_id_len, DWORD *object_id, BYTE *data_ptr,BYTE *vartype); +static int getnext_rsp(BYTE in_oidlen, DWORD in_oid[], BYTE *oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype); +static int set_rsp(BYTE object_id_len, DWORD *object_id, BYTE *data_ptr,WORD len); +static void pro_rsp(snmp_pdu *pdata,snmp_addr *addr); +//static int atoi_hex(char* input); + + static DWORD oid[10] ={1,3,6,1,4,1,12189,2,2,50}; +//static DWORD oid[11] ={1,3,6,1,4,1,12189,2,1,50,6}; + static int table_len = 9; + static int row_len = 11; + static int table_id = 50; + +void showbuf(BYTE *buf,int len) +{ + int i; + for(i=0;i0 && i%25==0) + printf("\n"); + else + printf(" "); + } + printf("\n"); +} + +static void showid(DWORD *buf,int len) +{ + int i; + for(i=0;i0 && i%25==0) + printf("\n"); + } + printf("\n"); +} +static void trap_callback(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD len,snmp_addr *addr) +{ + //printf("Receive trap message,oid:"); + //showid(oid,oidlen); + //showbuf(pdata,len); +} + + +int main() +{ + intval=123456; + snmp_init(4961); + heartbeat_init(0x1234); + SetTimer(); + inquire_trapmsg(trap_callback); + inquire_setmsg(1,oid,set_rsp); + inquire_getmsg(1,oid,get_rsp); + inquire_rspmsg(10,oid,pro_rsp); + inquire_getnextmsg(10,oid,getnext_rsp); + //cls; + set_led(0,8); + set_alarm(0,1); + +{ + + DWORD request_id; + snmp_pdu request_msg; + snmp_addr request_addr; +// iptrans_init(); + iptrMainInit(); + + request_msg.pdu_type = PDU_GETBULK; + request_msg.max_repetitions = 199900; + request_msg.non_repeaters = 0; + request_msg.request_id = 10; + request_msg.var_num = 1; + sprintf(request_msg.community, "public"); + + memcpy(request_msg.var[0].oid, oid, 4 * 10); + + request_msg.var[0].oidlen = 10; + + + + request_addr.remote_ip =inet_addr("127.0.0.1"); + request_addr.local_ip =inet_addr("172.48.234.128"); + request_addr.remote_port =4961; + request_addr.local_port =4961; + request_addr.broadcast =1; + + + request_id = snmp_send(&request_msg, &request_addr); + printf("%ld\n",request_id); + sleep(2); + +} + while(1) + { + usleep(50); + } + + return 1; + +} + + +int getnext_rsp(BYTE in_oidlen, DWORD *in_oid, BYTE *oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ + memcpy(oid,in_oid,in_oidlen*sizeof(DWORD)); + //printf("receive command\n"); + if(in_oidlen<12) + { + oid[10]=1; + oid[11]=1; + oid[12]=0; + in_oidlen=13; + } + else + { + oid[in_oidlen-1] =in_oid[in_oidlen-1]+1; + } + if(oid[in_oidlen-1]>12) + { + oid[in_oidlen-1]=0; + oid[in_oidlen-2]=in_oid[in_oidlen-2]+1; + if(oid[in_oidlen-2]>20) + return -1; + } + pdata[0] = oid[in_oidlen-1]; + *vartype=2; + *oidlen = in_oidlen; + return 1; +} + + +void pro_rsp(snmp_pdu *pdata,snmp_addr *addr) +{ + int i,getflag,value=0; + static int old_oid=0; + DWORD request_id; + snmp_pdu request_msg; + snmp_addr request_addr; + getflag = 1; + for(i=0;ivar_num;i++) + { + if(pdata->var[i].oid[table_len]!=table_id||pdata->var[i].vartype==EndOfMibView) + { + printf("\n"); + getflag = 0; + break; + } + if(pdata->var[i].oid[row_len]!=old_oid) + printf("\n"); + + old_oid = pdata->var[i].oid[row_len]; + value = decode_integer(pdata->var[i].msg,pdata->var[i].msglen); + printf("%-5d",value); + } + + if(getflag) + { + request_msg.pdu_type = PDU_GETBULK; + request_msg.max_repetitions = 10; + request_msg.non_repeaters = 0; + request_msg.var_num = 1; + sprintf(request_msg.community, "public"); + memcpy(request_msg.var[0].oid, pdata->var[pdata->var_num-1].oid, 4 * pdata->var[pdata->var_num-1].oidlen); + request_msg.var[0].oidlen = pdata->var[pdata->var_num-1].oidlen; + + request_addr.remote_ip =addr->remote_ip; + request_addr.remote_port =addr->remote_port; + request_addr.local_port =addr->local_port; + request_id = snmp_send(&request_msg, &request_addr); + } + return; +} + +void On_Timer() +{ + + snmp_timer(); + iptrans_timer(); + //heartbeat_timer(); +} + +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=1000; + itimer.it_value.tv_sec=0; + itimer.it_value.tv_usec=1000; + + if (setitimer(ITIMER_REAL,&itimer,&old_itimer) !=0 ) + { + printf("Setting Timer error! \n"); + exit(1); + } +} + + + +int get_rsp(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) +{ + printf("I Receive get message,oid:"); + showid(oid,oidlen); + /* + if(object_id[1]==2) + { + memcpy(data_ptr,(BYTE *)&intval,4); + return 4; + } + else + { + memcpy(data_ptr,(BYTE *)&strval,strlen(strval)); + return strlen(strval); + } + */ + return -1; +} + +int set_rsp(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD len) +{ + printf("I Receive set message,oid:"); + showid(oid,oidlen); + showbuf(pdata,len); + /* + if(object_id[1]==2) + { + memcpy((BYTE *)&intval,data_ptr,4); + return 4; + } + else + { + memcpy((BYTE *)&strval,data_ptr,len); + return len; + } + */ + return -1; +} diff --git a/omc/plat/snmp/src/sysctrl.c b/omc/plat/snmp/src/sysctrl.c new file mode 100644 index 0000000..c68f619 --- /dev/null +++ b/omc/plat/snmp/src/sysctrl.c @@ -0,0 +1,235 @@ +/*****************************************************/ +/*Title: sysctrl.c */ +/*Descr: report operation system status */ +/*Author: Liang Hanxi */ +/*Create: 2002-06-24 */ +/*Modify: */ +/*****************************************************/ + +#include "./include/sysctrl.h" + +#define MAX_MNT_FILESYS 255 //in CC client >16 + +static mnt_list MntInfo[MAX_MNT_FILESYS]; +static BYTE MntNum=0; +static hb_sysinfo3 SysInfo3; + +static FILE *stat_fp; +extern int errno; + +static void get_mntinfo(); +static BOOL get_diskinfo(long *p_total,long *p_free); +static void get_idlecpu(); +static int parse_infoline(char *str,char (*row)[64],int maxrow); + +void sysctrl_init() +{ + struct sysinfo info; + + if((stat_fp=fopen("/proc/stat","r"))==NULL) + { + printf("Fail to open /proc/stat\n"); + exit(1); + } + + #if 0 + sysinfo(&info); + SysInfo.totalram = htonl(info.totalram/1024); + SysInfo.freeram = htonl(info.freeram/1024); + SysInfo.up_time = htonl(time(NULL)); + #endif + SysInfo3.up_time = htonl(time(NULL)); + + get_idlecpu(); + //get_mntinfo(); + fclose(stat_fp); +} + +void system_report() +{ + static int m_state=0; + struct sysinfo info; + unsigned long totaldisk,freedisk; + + switch(m_state) + { + case 50*60*10: //10min + m_state=0; + #if 0 + sysinfo(&info); + SysInfo.totalram = htonl(info.totalram/1024); + SysInfo.freeram = htonl(info.freeram/1024); + + SysInfo3.ram_total_used = htonl(info.totalram - info.freeram); + SysInfo3.ram_total = htonl(info.totalram); + // set_status(8,22,(BYTE *)&SysInfo.cpu_idle); + set_status(8,38,(BYTE *)&SysInfo2.start_time); + break; + #endif + default: + m_state++; + if(m_state%(50*30)==0) //30s + { + sysinfo(&info); + + SysInfo3.ram_total_used = htonl((info.totalram - info.freeram)>>10); + SysInfo3.ram_total = htonl(info.totalram>>10); + SysInfo3.ram_swap_used = htonl((info.totalswap - info.freeswap)>>10); + SysInfo3.ram_swap_total = htonl(info.totalswap>>10); + SysInfo3.ram_buffers = htonl(info.bufferram>>10); + SysInfo3.ram_cached = htonl((info.freeram * info.mem_unit + info.bufferram * info.mem_unit)>>10); + + get_diskinfo(&totaldisk,&freedisk); + + SysInfo3.pt_count = 1; + SysInfo3.pt[0].num = 1; + SysInfo3.pt[0].pos = 0x2f; + SysInfo3.pt[0].used_space = htonl(totaldisk - freedisk); + SysInfo3.pt[0].total_space = htonl(totaldisk); + + get_idlecpu(); + + // set_status(8,22,(BYTE *)&SysInfo.cpu_idle); + set_status(8,40,(BYTE *)&SysInfo3); + } + break; + } +} + +void get_idlecpu() +{ + char buf[128],row[5][64]; + DWORD timeofuser,timeofsys,timeofnice,timeofidle; + static DWORD oldusertime=0,oldsystime=0,oldnicetime=0,oldidletime=0; + + double idlecpu,totalcpu; + u_short idlerate; + + if(fseek(stat_fp,0,SEEK_SET)!=0) + { + snmp_debug(SNMPDB_ERR|SNMPDB_SYS, "Fail to seek to beginning of /proc/stat"); + return; + } + if(fgets(buf,128,stat_fp)==NULL) + { + snmp_debug(SNMPDB_ERR|SNMPDB_SYS, "Fail to Read information from /proc/stat"); + return;; + } + + if(parse_infoline(buf,row,5)<5) + return; + + timeofuser=strtoul(row[1],NULL,10); + timeofnice=strtoul(row[2],NULL,10); + timeofsys=strtoul(row[3],NULL,10); + timeofidle=strtoul(row[4],NULL,10); + + //if((pinfo=strstr(buf,"cpu "))==NULL) + // return; + //sscanf(pinfo,"cpu %lu %lu %lu %lu",&timeofuser,&timeofnice,&timeofsys,&timeofidle); + //printf("CPU Time:%ld,%ld,%ld,%ld\n",timeofuser,timeofnice,timeofsys,timeofidle); + + totalcpu=timeofuser-oldusertime+timeofnice-oldnicetime+timeofsys-oldsystime+timeofidle-oldidletime; + + if(totalcpu==0) + return; + + idlecpu=timeofidle-oldidletime; + + idlerate=(u_short)((idlecpu/totalcpu)*1000); + //store current time + oldusertime=timeofuser; + oldnicetime=timeofnice; + oldsystime=timeofsys; + oldidletime=timeofidle; + + if(idlerate<=1000) + { + SysInfo3.idle_cpu_rate = (u_short)(idlecpu * 100 / totalcpu); + } +} + + + + +void get_mntinfo() +{ + FILE *mntfp; + struct mntent *pmnt; + struct statfs statbuf; + + mntfp = setmntent("/etc/mtab", "r"); + while ((pmnt = getmntent(mntfp))!=NULL && MntNummnt_fsname,&statbuf)!=0) + continue; + strcpy(MntInfo[MntNum].mnt_fsname,pmnt->mnt_fsname); + strcpy(MntInfo[MntNum].mnt_dir,pmnt->mnt_dir); + MntInfo[MntNum++].limit =20*1024; + } + endmntent(mntfp); + //free(pmnt); getmntent return static pointer , not need to free +} + +BOOL get_diskinfo(long *p_total,long *p_free) +{ + int i; + struct statfs statbuf; + mnt_list *pmnt; + *p_total=0; + *p_free=0; + for(i=0;imnt_dir,&statbuf)!=0) + continue; + + pmnt->total=statbuf.f_blocks*(statbuf.f_bsize/1024); + *p_total+=pmnt->total; + pmnt->free=statbuf.f_bfree*(statbuf.f_bsize/1024); + *p_free+=pmnt->free; + + if(pmnt->free<=pmnt->limit) + set_alarm(8,3); + //printf("%-15s%-15s%-10ld%-10ld\n",pmnt->mnt_fsname,pmnt->mnt_dir,pmnt->total,pmnt->free); + } + + + return 1; +} + +int parse_infoline(char *str,char (*row)[64],int maxrow) +{ + char *pstr=str; + int len,index=0,i; + BOOL black=0; + len=strlen(str); + for(i=0;i64) + pstr[63]=0; + sprintf(row[index++],"%s",pstr); + pstr=str+i+1; + } + black=0; + } + else + black=1; + } + if(black==1) + { + if(strlen(pstr)>64) + pstr[63]=0; + sprintf(row[index++],"%s",pstr); + } + return index; +} + + diff --git a/omc/plat/tcap/.copyarea.db b/omc/plat/tcap/.copyarea.db new file mode 100644 index 0000000..5ccc9ca --- /dev/null +++ b/omc/plat/tcap/.copyarea.db @@ -0,0 +1,9 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\tcap +2 +5 +3:doc|2|0|0|0|2c697008bfa611dc869a001c23e19543|0 +2:ut|2|0|0|0|368971e4bfa611dc869a001c23e19543|0 +3:src|2|0|0|0|2d99705cbfa611dc869a001c23e19543|0 +8:Makefile|1|11d70a45ee3|b31|9a1cc019|2d097040bfa611dc869a001c23e19543|0 +3:lib|2|0|0|0|2c697024bfa611dc869a001c23e19543|0 diff --git a/omc/plat/tcap/Makefile b/omc/plat/tcap/Makefile new file mode 100644 index 0000000..3ba98eb --- /dev/null +++ b/omc/plat/tcap/Makefile @@ -0,0 +1,98 @@ + +##----------------------------------------------------------## +## ## +## 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 = tcap +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + + +PLT_LIB = + +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../mss + +OBJ_ADD = +TEST_OBJ_PATH = + +PREPROC_CMD = +POSTPROC_CMD = + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = no +COVER_REPORT_PATH = ./output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/tcap/lib/libtcap.a b/omc/plat/tcap/lib/libtcap.a new file mode 100644 index 0000000..1615865 Binary files /dev/null and b/omc/plat/tcap/lib/libtcap.a differ diff --git a/omc/plat/tcap/obj/idmanage.o b/omc/plat/tcap/obj/idmanage.o new file mode 100644 index 0000000..8ac5a27 Binary files /dev/null and b/omc/plat/tcap/obj/idmanage.o differ diff --git a/omc/plat/tcap/obj/itcap.o b/omc/plat/tcap/obj/itcap.o new file mode 100644 index 0000000..fb3644a Binary files /dev/null and b/omc/plat/tcap/obj/itcap.o differ diff --git a/omc/plat/tcap/obj/tcap_coding.o b/omc/plat/tcap/obj/tcap_coding.o new file mode 100644 index 0000000..910748f Binary files /dev/null and b/omc/plat/tcap/obj/tcap_coding.o differ diff --git a/omc/plat/tcap/obj/tcap_fsm.o b/omc/plat/tcap/obj/tcap_fsm.o new file mode 100644 index 0000000..9fc45ee Binary files /dev/null and b/omc/plat/tcap/obj/tcap_fsm.o differ diff --git a/omc/plat/tcap/obj/tcap_m.o b/omc/plat/tcap/obj/tcap_m.o new file mode 100644 index 0000000..61c4887 Binary files /dev/null and b/omc/plat/tcap/obj/tcap_m.o differ diff --git a/omc/plat/tcap/src/.copyarea.db b/omc/plat/tcap/src/.copyarea.db new file mode 100644 index 0000000..0d41b07 --- /dev/null +++ b/omc/plat/tcap/src/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\tcap\src +2 +6 +8:tcap_m.c|1|11d70a45fbe|41b6|f212816e|2e397078bfa611dc869a001c23e19543|0 +7:itcap.c|1|11d70a46098|5b46|ee3a2096|f04485fe6cf311dd91a5001c23e19543|0 +7:include|2|0|0|0|2ff970ccbfa611dc869a001c23e19543|0 +a:tcap_fsm.c|1|11d70a46069|16b55|125a598b|355971acbfa611dc869a001c23e19543|0 +d:tcap_coding.c|1|11d70a45fec|11993|48dc6c43|f4b348a6339011dd9fa7001c23e19543|0 +a:idmanage.c|1|11d70a4601b|17e1|137c4b9c|efa485e66cf311dd91a5001c23e19543|0 diff --git a/omc/plat/tcap/src/idmanage.c b/omc/plat/tcap/src/idmanage.c new file mode 100644 index 0000000..1c5a5bc --- /dev/null +++ b/omc/plat/tcap/src/idmanage.c @@ -0,0 +1,269 @@ +/* ID management c file */ +/* written by Liu zhiguo 2002-08-06 */ +/* version 2.0 */ +/* ----------------------------- */ + +#include "../../sccp/src/include/sccp.h" +#include "./include/tcap_public.h" +#include "./include/tcap_struct.h" + +/*@ignore@*/ +#define ID_VM_KEY 0xa0800000 +#define ID_VM_PERM 0664 + +typedef struct id_struct +{ + u32 current_did; + u32 count_did; + u32 count_did_occupied; + u32 count_did_max; + u32 count_did_tmp; + u8 dialogue_id[MAX_DIALOGUEID]; + u8 current_iid[MAX_DIALOGUEID]; + u8 invoke_id[MAX_DIALOGUEID][MAX_INVOKEID]; +}id_struct; + +struct id_struct *ID_ptr; + +typedef struct _did_queunce_struct +{ + u32 head; + u32 tail; + u32 idle_did[MAX_DIALOGUEID*2]; +}did_queunce_struct; + +did_queunce_struct tcap_did_queunce; + +void init_id(int grantdid) // init the ID share memory +{ + int shm_id,i; + + /* tcap state machine share memory */ + if ((shm_id = shmget(ID_VM_KEY,sizeof(id_struct),ID_VM_PERM|IPC_CREAT)) == -1) + { + printf("can not init ID share memory"); + exit(0); + } + if ((ID_ptr = (id_struct *)shmat(shm_id,(char *)0,0)) == (id_struct *) -1) + { + printf("can not init ID share memory"); + exit(0); + } + memset(ID_ptr,0,sizeof(id_struct)); + + memset(&tcap_did_queunce,0,sizeof(did_queunce_struct)); + for(i=1;icount_did; +} + +u32 chkcount_did_occupied(void) +{ + return ID_ptr->count_did_occupied; +} + +u32 chkcount_did_max(void) +{ + return ID_ptr->count_did_max; +} + +void clrcount_did_max(void) +{ + ID_ptr->count_did_max = 0; +} + +u8 xapp_check_did_state(u32 did); + +u32 assign_did(void) +{ + u32 tmp_did=0; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + if(tcap_did_queunce.head != tcap_did_queunce.tail) + { + + tmp_did = tcap_did_queunce.idle_did[tcap_did_queunce.tail++]; + tcap_did_queunce.tail %= (MAX_DIALOGUEID*2); + + if(ID_ptr->dialogue_id[tmp_did]) + { + debug_ptr->watch_dog[218] ++; + assign_did(); + } + + ID_ptr->dialogue_id[tmp_did] = 1; + ID_ptr->count_did ++; + debug_ptr->watch_dog[223]++; + } + else + { + debug_ptr->watch_dog[218] ++; + } + + return tmp_did%MAX_DIALOGUEID; +} + +u32 assign_did1(void) // assign dialogue id +{ + u32 ii; + u32 jj; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + for (ii = 1;ii < (tcap_ptr->grantdid);ii++) + { + jj = (ID_ptr->current_did++) % (tcap_ptr->grantdid); + if ((jj != 0) && (ID_ptr->dialogue_id[jj] == 0) && (xapp_check_did_state(jj))) + { + ID_ptr->dialogue_id[jj] = 1; + ID_ptr->count_did ++; + ID_ptr->current_did = ID_ptr->current_did % (tcap_ptr->grantdid); + debug_ptr->watch_dog[223]++; + return jj; + } + } + debug_ptr->watch_dog[218] ++; + return 0; +} + +void free_did(u32 did) +{ + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + if (did == 0 || did >= (tcap_ptr->grantdid)) + { + debug_ptr->watch_dog[219] ++; + return; + } + if (ID_ptr->dialogue_id[did] == 1) + { + ID_ptr->dialogue_id[did] = 0; + if (ID_ptr->count_did != 0) + ID_ptr->count_did --; + memset(ID_ptr->invoke_id[did],0,MAX_INVOKEID); // free all invoke id + debug_ptr->watch_dog[213] ++; + + tcap_did_queunce.idle_did[tcap_did_queunce.head++] = did; + tcap_did_queunce.head %= (MAX_DIALOGUEID*2); + } + debug_ptr->watch_dog[220] ++; + + +} + +void free_did1(u32 did) // free dialogue id +{ + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + if (did == 0 || did >= (tcap_ptr->grantdid)) + { + debug_ptr->watch_dog[219] ++; + return; + } + if (ID_ptr->dialogue_id[did] == 1) + { + ID_ptr->dialogue_id[did] = 0; + if (ID_ptr->count_did != 0) + ID_ptr->count_did --; + memset(ID_ptr->invoke_id[did],0,MAX_INVOKEID); // free all invoke id + debug_ptr->watch_dog[213] ++; + } + debug_ptr->watch_dog[220] ++; +} + +int check_did(u32 did) +{ + if (did == 0 || did >= (tcap_ptr->grantdid)) + return 0; + if (ID_ptr->dialogue_id[did] == 0) // dialogue id is not assigned + return 0; + else + return 1; +} + +u8 assign_iid(u32 did) // assign invoke id,need know the dialogue id +{ + u32 ii, iid=64; + u8 current_iid; + //char buf[128]; + + if (did == 0 || did >= (tcap_ptr->grantdid)) + return 0xff; + current_iid = ID_ptr->current_iid[did]; + for (ii = 0;ii < MAX_INVOKEID;ii ++) + { + iid = (ii + 64 + current_iid) % MAX_INVOKEID;// % MAX_INVOKEID; + if (ID_ptr->invoke_id[did][iid] == 0) + { + //sprintf(buf,"assign iid: iid=%d, ii=%d, current_iid=%d\n", + // iid,ii,current_iid); + // tcap_send_ascout(buf); + ID_ptr->invoke_id[did][iid] = 1; + ID_ptr->current_iid[did]++; + return iid; + } + } + //tcap_send_ascout("assign iid failed\n"); + memset(ID_ptr->invoke_id[did],0,MAX_INVOKEID); + return assign_iid(did); +} + +void free_iid(u32 did,u8 iid) // free invoke id +{ + //u8 info[1024]; + //u8 suc = 0; + + if (did >= 0 && did < (tcap_ptr->grantdid)) + { + ID_ptr->invoke_id[did][iid] = 0; + //suc = 1; + } + + //sprintf(info, "free_iid: did: %d, iid: %d suc: %d\r\n", did, iid, suc); + //tcap_send_ascout(info); +} + +int check_iid(u32 did,u8 iid) // check invoke id +{ + if (did == 0 || did >= (tcap_ptr->grantdid)) + return 0; + if (ID_ptr->invoke_id[did][iid] == 0) + return 0; + else + return 1; +} + +u8 store_iid(u32 did,u8 iid) // store invoke id +{ + //u8 info[1024]; + + //sprintf(info, "store_iid: did: %d, iid: %d\r\n", did, iid); + //tcap_send_ascout(info); + + if (did == 0 || did >= (tcap_ptr->grantdid)) + return 0; + //if (iid == 0) + // memset(ID_ptr->invoke_id[did],0,MAX_INVOKEID); + + //Change by daniel on 2006-6-19 + ////tcap do not has state machine for receiving invoke, so no need to look at the iid state everytime, + ////just set it to be occupied everytime + + //if (ID_ptr->invoke_id[did][iid] == 1) + // return 0; + ID_ptr->invoke_id[did][iid] = 1; + ID_ptr->current_iid[did]++; + return 1; +} + +void SetCurrentDid(u_short did) +{ + ID_ptr->current_did = did % (tcap_ptr->grantdid); +} +/*@end@*/ diff --git a/omc/plat/tcap/src/include/.copyarea.db b/omc/plat/tcap/src/include/.copyarea.db new file mode 100644 index 0000000..85894f8 --- /dev/null +++ b/omc/plat/tcap/src/include/.copyarea.db @@ -0,0 +1,11 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\tcap\src\include +2 +7 +d:tcap_struct.h|1|11d70a461b1|24b0|bd200439|31c97120bfa611dc869a001c23e19543|0 +b:tcap_proc.h|1|11d70a4627c|82|6d8d2c30|34c97190bfa611dc869a001c23e19543|0 +d:tcap_public.h|1|11d70a4621f|853|b18f6d13|6c81ed33ca7311dc926f001c23e19543|0 +8:tcap_m.h|1|11d70a46134|20f|8aeaa39b|309970e8bfa611dc869a001c23e19543|0 +7:itcap.h|1|11d70a461e0|252|de5acccc|3269713cbfa611dc869a001c23e19543|0 +b:tcap_head.h|1|11d70a4625d|22d8|c703b517|34297174bfa611dc869a001c23e19543|0 +a:idmanage.h|1|11d70a46163|1a7|2bbc7a1d|31297104bfa611dc869a001c23e19543|0 diff --git a/omc/plat/tcap/src/include/idmanage.h b/omc/plat/tcap/src/include/idmanage.h new file mode 100644 index 0000000..c82704b --- /dev/null +++ b/omc/plat/tcap/src/include/idmanage.h @@ -0,0 +1,16 @@ +/* ID manage head file */ +/* written by Liu Zhiguo 2002-08-06 */ +/* Version 2.0 */ +/* -------------------------------- */ + +void init_id(); +u32 chkcount_did(void); +u32 chkcount_did_occupied(void); +u32 chkcount_did_max(void); +u32 assign_did(); +void free_did(u32 did); +u8 check_did(u32 did); +u8 assign_iid(u32 did); +void free_iid(u32 did,u8 iid); +u8 check_iid(u32 did,u8 iid); +u8 store_iid(u32 did,u8 iid); diff --git a/omc/plat/tcap/src/include/itcap.h b/omc/plat/tcap/src/include/itcap.h new file mode 100644 index 0000000..401a28e --- /dev/null +++ b/omc/plat/tcap/src/include/itcap.h @@ -0,0 +1,18 @@ +/* itcap head file */ +#ifdef _ITCAP_H_ +#define _ITCAP_H_ + +#include "../../../public/src/include/public.h" +#include "tcap_public.h" +#include "tcap_struct.h" + +void tcap_disp_dlg(struct CSLdlg_struct *dha_ptr,u8 disp_flag); +void tcap_disp_cmp(struct CSLcmp_struct *cha_ptr,u8 disp_flag); + +u8 RecvTcapDlg(struct CSLdlg_struct *dha_ptr,u32 dlg_flag); +u8 RecvTcapCmp(struct CSLcmp_struct *cha_ptr,u32 dlg_flag); +u8 SendTcapDlg(struct CSLdlg_struct *dha_ptr); +u8 SendTcapCmp(struct CSLcmp_struct *cha_ptr); +int itcap_reg_ssn(u8 ssn); +void tcap_change_local_ssn(u32 proc,u8 src_ssn,u8 dst_ssn); +#endif diff --git a/omc/plat/tcap/src/include/tcap_head.h b/omc/plat/tcap/src/include/tcap_head.h new file mode 100644 index 0000000..8298491 --- /dev/null +++ b/omc/plat/tcap/src/include/tcap_head.h @@ -0,0 +1,256 @@ +/* TCAP head file */ +/* Written by Liu Zhiguo 2002-08-06 */ +/* Version 2.0 */ +/* --------------------------------- */ +#ifndef _TCAP_HEAD +#define _TCAP_HEAD + +/* TC or TR dialogue portion */ +/* TC or TR message type tag */ +#define Unidirectional 0x61 +#define Begin 0x62 +#define End 0x64 +#define Continue 0x65 +#define P_Abort 0x66 // terminated by service provider +#define U_Abort 0x67 // terminated by TC user +#define Abort 0x67 +#define Notice 0x68 // Network Service Provider inform + +#define Unidirectional_Ansi 0xE1 +#define Query_WithPerm_Ansi 0xE2 +#define Query_WithoutPerm_Ansi 0xE3 +#define Response_Ansi 0xE4 +#define Conversation_WithPerm_Ansi 0xE5 +#define Conversation_WithoutPerm_Ansi 0xE6 +#define Abort_Ansi 0xF6 +#define P_Abort_Ansi 0xF5 // terminated by service provider +#define U_Abort_Ansi 0xF6 // terminated by TC user + +/* transaction ID tags */ +#define Org_TID 0x48 // originating transaction ID tag +#define Dst_TID 0x49 // destination transaction ID tag + +/* P-Abort cause tag */ +#define P_Abort_Cause 0x4a + +/* coding of P-Abort Cause values */ +#define P_Abort_UMT 0x00 // unrecognized message type +#define P_Abort_UTID 0x01 // unrecognized transaction ID +#define P_Abort_BFTP 0x02 // badly formatted transaction portion +#define P_Abort_ITP 0x03 // incorrect transaction portion +#define P_Abort_RL 0x04 // resource limitation +#define P_Abort_ADLG 0x05 // abnormal dialogue +#define P_Abort_NCDP 0x06 // no common dialogue portion + +#define P_Abort_UMT_Ansi 0x01 // unrecognized message type +#define P_Abort_ITP_Ansi 0x02 // incorrect transaction portion +#define P_Abort_BFTP_Ansi 0x03 // badly formatted transaction portion +#define P_Abort_UTID_Ansi 0x04 // unrecognized transaction ID +#define P_Abort_PTRP_Ansi 0x05 // permission to release problem +#define P_Abort_RL_Ansi 0x06 // resource limitation +#define P_Abort_UDPID_Ansi 0x07 // unrecognized dialogue portion id +#define P_Abort_BSDP_Ansi 0x08 // badly structured dialogue portion +#define P_Abort_MDP_Ansi 0x09 // missing dialogue portion +#define P_Abort_IDP_Ansi 0x0A // inconsistent dialogue portion + +/* dialogue portion tag */ +#define Dialogue_Portion 0x6b + +/* component portion tag */ +#define Component_Portion 0x6c + +/* TC Component portion */ +/* component type tag */ +#define Invoke 0xa1 +#define Result_L 0xa2 // return result last +#define Error 0xa3 // indicate operation execution failed +#define U_Error 0xa3 +#define Reject 0xa4 +#define U_Reject 0xa4 // reject by TC user +#define L_Reject 0xa5 // local reject +#define R_Reject 0xa6 // remote reject +#define Result_NL 0xa7 // return result not last +#define L_Cancel 0xa8 // inform TC user local terminated by timeout +#define U_Cancel 0xa8 // local terminate by TC user + +#define Invoke_L_Ansi 0xe9 // Invoke Last +#define Result_L_Ansi 0xea // return result last +#define Error_Ansi 0xeb // indicate operation execution failed +#define U_Error_Ansi 0xeb +#define Reject_Ansi 0xec // Reject +#define U_Reject_Ansi 0xec // reject by TC user +#define L_Reject_Ansi 0xe8 // local reject +#define R_Reject_Ansi 0xe7 // remote reject +#define Invoke_NL_Ansi 0xed // Invoke not last +#define Result_NL_Ansi 0xee // return result not last + +/* component ID tag */ +#define Invoke_ID 0x02 +#define Linked_ID 0x80 + +/* coding of NULL tag */ +#define Invoke_ID_NULL 0x05 + +/* operation code tag */ +#define Local_Operation_Code 0x02 +#define Global_Operation_Code 0x06 + +/* parameter tag */ +#define Sequence 0x30 +#define Set 0x31 + +/* error code tag */ +#define Local_Error_Code 0x02 +#define Global_Error_Code 0x06 + +/* coding of problem type tag */ +#define General_Problem 0x80 +#define Invoke_Problem 0x81 +#define Return_Result 0x82 +#define Return_Error 0x83 + +#define General_Problem_Ansi 0x01 +#define Invoke_Problem_Ansi 0x02 +#define Return_Result_Ansi 0x03 +#define Return_Error_Ansi 0x04 +#define Transaction_Ansi 0x05 + +/* coding of general problem */ +#define General_Problem_UC 0x00 // unrecognized component +#define General_Problem_MC 0x01 // mistyped component +#define General_Problem_BSC 0x02 // badly structured component + +#define General_Problem_UC_Ansi 0x01 // unrecognized component +#define General_Problem_MC_Ansi 0x02 // mistyped component/incorrect component portion +#define General_Problem_BSC_Ansi 0x03 // badly structured component +#define General_Problem_ICC_Ansi 0x04 // incorrect component coding + +/* coding of invoke problem */ +#define Invoke_Problem_DIID 0x00 // duplicate invoke ID +#define Invoke_Problem_UO 0x01 // unrecognized operation +#define Invoke_Problem_MP 0x02 // mistyped parameter +#define Invoke_Problem_RL 0x03 // resource limitation +#define Invoke_Problem_IR 0x04 // initiating release +#define Invoke_Problem_ULID 0x05 // unrecognized linked ID +#define Invoke_Problem_LRU 0x06 // linked response unexpected +#define Invoke_Problem_ULO 0x07 // unexpected linked operation + +#define Invoke_Problem_DIID_Ansi 0x01 // duplicate invoke ID +#define Invoke_Problem_UO_Ansi 0x02 // unrecognized operation +#define Invoke_Problem_MP_Ansi 0x03 // mistyped parameter +#define Invoke_Problem_ULID_Ansi 0x04 // unrecognized linked ID + +/* coding of return result problem */ +#define Return_Result_UIID 0x00 // unrecognized invoke ID +#define Return_Result_RRU 0x01 // return result unexpected +#define Return_Result_MP 0x02 // mistyped parameter + +#define Return_Result_UIID_Ansi 0x01 // unrecognized invoke ID +#define Return_Result_RRU_Ansi 0x02 // return result unexpected +#define Return_Result_MP_Ansi 0x03 // mistyped parameter + +/* coding of return error problem */ +#define Return_Error_UIID 0x00 // unrecognized invoke ID +#define Return_Error_REU 0x01 // return error unexpected +#define Return_Error_URE 0x02 // unrecognized error +#define Return_Error_UEE 0x03 // unexpected error +#define Return_Error_MP 0x04 // mistyped parameter + +#define Return_Error_UIID_Ansi 0x01 // unrecognized invoke ID +#define Return_Error_REU_Ansi 0x02 // return error unexpected +#define Return_Error_URE_Ansi 0x03 // unrecognized error +#define Return_Error_UEE_Ansi 0x04 // unexpected error +#define Return_Error_MP_Ansi 0x05 // mistyped parameter + +/* Dialogue Portion */ +/* external tag */ +#define External 0x28 + +/* object identifier */ +#define Object_Identifier 0x06 +#define Integer 0x02 + +/* dialogue tag */ +#define PDU_AARQ 0x60 +#define PDU_AARE 0x61 +#define PDU_ABRT 0x64 +/* protocol version tag */ +#define Protocol_Version 0x80 + +/* application context name tag */ +#define Application_Context_Name 0xa1 + +/* user information tag */ +#define User_Information 0xbe + +/* abort source tag */ +#define Abort_Source 0x80 + +/* result tag in Q.773 this tag is 0x82 */ +//#define Result 0xa2 + +/* result source diagnostic tag */ +#define Result_Source_Diagnostic 0xa3 + +/* encoding tag */ +#define Single_ASN1_type 0xa0 +#define Octet_Aligned 0x81 // maybe 0xa1 +#define Arbitrary 0x82 // maybe 0xa2 + +/* result value */ +#define Accepted 0x00 +#define Reject_permanent 0x01 + +/* dialogue service diagnostic tag in Q.773,value is 0x21 and 0x22 */ +#define Dialogue_Service_Provider 0x02 +#define Dialogue_Service_User 0x01 + +/* dialogue service user diagnostic tag */ +#define DSU_N 0x00 // null +#define DSU_NRG 0x01 // no reason given +#define DSU_ACNNS 0x02 // application context name not supplied + +/* dialogue service provider diagnostic tag */ +#define DSP_N 0x00 // null +#define DSP_NRG 0x01 // no reason given +#define DSP_NCDP 0x02 // no common dialogue portion + +/* abort source */ + +#define ABRTDlg_Service_User 0x00 +#define ABRTDlg_Service_Provider 0x01 + +/* unidirectional dialogue tag */ +#define PDU_AUDT 0x65 +#define PDU_ASUDT 0x66 + +#define REQUEST 1 +#define INDICATE 2 +#define RESPONSE 3 +#define CONFIRM 4 + +#define PRE_END 1 // pre arranged end +#define BASIC_END 2 // basic end + +#define DERR_ASN1 0x01 // decode error: asn1 decode error +#define DERR_UNTYPE 0x02 // decode error: unknown message type +#define DERR_UNTID 0x03 // decode error: lack transaction id +#define DERR_OTHER 0x04 // decode error: other reason + +#define UABORT_NULL 0x00 // uabort reason:no +#define UABORT_SPEC 0x01 // uabort reason:specific reason +#define UABORT_ACNNS 0x02 // uabort reason:application context name not supplied + +#define ANSI_TAG_CLASS_CONS 0xE0 +#define ANSI_TAG_CLASS_PRIM 0xC0 + +#define ITU_TCAP 0 +#define ANSI_TCAP 1 + +#define TYPE_NATIONAL 0 +#define TYPE_PRIVATE 1 + +#define TYPE_INT 0 +#define TYPE_OID 1 + +#endif diff --git a/omc/plat/tcap/src/include/tcap_m.h b/omc/plat/tcap/src/include/tcap_m.h new file mode 100644 index 0000000..04afebc --- /dev/null +++ b/omc/plat/tcap/src/include/tcap_m.h @@ -0,0 +1,21 @@ +/* TCAP monitor head file */ +/* written by Liu Zhiguo 2001-10-19 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "../../../public/src/include/pub_include.h" + +#ifndef _TCAP_M +#define _TCAP_M + +/* in the m.c */ +void init_m(); +void tcap_set_local_ip(); +void tcap_monitor(); +void tcap_send_ascout(char *asc_str); +void tcap_send_error(char *err_str); +void tcap_send_alarm(u8 alarm_code,u8 alarm_level); +void HexToDisplay(u8 *to_asc, u8 *from_hex, u8 from_len); +void tcap_send_info(char *info); + +#endif diff --git a/omc/plat/tcap/src/include/tcap_proc.h b/omc/plat/tcap/src/include/tcap_proc.h new file mode 100644 index 0000000..4ca13dc --- /dev/null +++ b/omc/plat/tcap/src/include/tcap_proc.h @@ -0,0 +1,3 @@ +void tcap_fsm(void); // TCAP state machine, 10ms +void tcap_init(int didgrant,DWORD localip, DWORD peerip); // init TCAP system + diff --git a/omc/plat/tcap/src/include/tcap_public.h b/omc/plat/tcap/src/include/tcap_public.h new file mode 100644 index 0000000..5470b66 --- /dev/null +++ b/omc/plat/tcap/src/include/tcap_public.h @@ -0,0 +1,68 @@ +/* TCAP public define head file */ +/* written by Liu Zhiguo 2002-08-06 */ +/* Version 2.0 */ +/* ------------------------------- */ + +#ifndef _TCAP_PUBLIC +#define _TCAP_PUBLIC + +#include "../../../public/src/include/includes.h" +#include "tcap_head.h" + +#define MAX_DIALOGUEID 4096 +#define MAX_INVOKEID 256 +#define TCAP_ASCIN_LEN 80 +#define TCAP_ASCOUT_LEN 4096 +#define TCAP_UTILIZE_COUNT 97 +#define TCAP_UTILIZE_LEN 76 +#define TCAP_HB_LEN 8 +#define TCAP_DLG_LEN 128 // max dialogue length +#define TCAP_CMP_LEN 256 // max component length +#define TCAP_ACN_LEN 10 // max context name length +#define TCAP_USERINFO_LEN 64 // max user infomation length +#define TCAP_UABORT_INFO_LEN 64 // max user abort infomation length +#define TCAP_SECURITY_CONTEXT_LEN 64 // max security context infomation length +#define TCAP_CONFIDENTIAL_INFO_LEN 64 // max confidentiality infomation length +#define MAX_TEMPINVOKEID 8 +#define TCAP_BUF_LEN 256 +#define TCAP_SLS_NUM 16 +//#define TCAP_PARAM_LEN 170 // max parameter length when has dialogue portion +#define TCAP_PARAM_LEN 210 // max parameter length when has dialogue portion +#define TCAP_PARAM_LEN_1 210 // max parameter length when has not dialogue portion + +#define MAX_TSL_BUF 4 +#define MAX_CSL_BUF 4 + +#define TCAP_MODULE_ID 3 +#define TCAP_SYSTEM_ID 4 +#define TCAP_LED_CODE 5 + +/* the state of TSM or DSM */ +#define TCAP_INIT 0 +#define TCAP_IDLE 1 +#define TCAP_IR 2 // initiation received +#define TCAP_IS 3 // initiation send +#define TCAP_ACTIVE 4 // active state +#define TCAP_SUSPEND 7 // suspend state +/* the state of ISM */ +#define SENT_STATE1 2 +#define SENT_STATE2 3 +#define SENT_STATE3 4 +#define SENT_STATE4 5 +#define WAIT_REJECT_STATE 6 + +/* the class of ISM */ +#define OPERATION_CLASS1 1 // operation class 1 +#define OPERATION_CLASS2 2 // operation class 2 +#define OPERATION_CLASS3 3 // operation class 3 +#define OPERATION_CLASS4 4 // operation class 4 + +#define INVOKE_TIMER 10 +#define REJECT_TIMER 2 +#define SUSPEND_TIMER 2 +#define IDLE_TIMER 60 +#define EXPIRE_TIMER 240 +#define TCAP_TIMERHZ 50 +#define ISM_TIMERHZ 50 + +#endif diff --git a/omc/plat/tcap/src/include/tcap_struct.h b/omc/plat/tcap/src/include/tcap_struct.h new file mode 100644 index 0000000..9f03ce1 --- /dev/null +++ b/omc/plat/tcap/src/include/tcap_struct.h @@ -0,0 +1,391 @@ +/* TCAP structure head file */ +/* written by Liu Zhiguo 2002-08-06 */ +/* Version 2.0 */ +/* ------------------------------- */ + +#ifndef _TCAP_STRUCT +#define _TCAP_STRUCT + +#define TCAP_KEY 0xa0100000 +#define TCAP_PERM 0664 + +typedef struct tcapdebug_struct // tcap debug structure +{ + u8 default_invtime; // default invoke time, init is 10s + u8 default_rejtime; // default reject time, init is 1s + u8 error_switch; // show error record switch + u8 sccp_switch; // show receive data from sccp switch + u8 tcu_switch; // show send data to TC-User switch + u8 send_control; // control if can send out tcap message + u8 start_time[6]; + u8 current_time[6]; + u32 monitor_did; + u32 local_ip; + u32 peer_ip; + u8 watch_dog[256]; + u8 ascin_buf[TCAP_ASCIN_LEN]; + u8 ascout_buf[TCAP_ASCOUT_LEN]; + u8 current_csta; + u32 csta_time[TCAP_UTILIZE_COUNT]; + u32 tc_utilize[TCAP_UTILIZE_COUNT][TCAP_UTILIZE_LEN]; + u8 hb_status[TCAP_HB_LEN]; +} tcapdebug_struct; + +/* +++++++++++++++++++++++++++++++ */ +/* Transaction sub-layer structure */ +/* +++++++++++++++++++++++++++++++ */ +typedef struct TRUni_struct // transaction unidirectional struct +{ + u8 dialogue_len; + u8 components_len; + u8 dialogue[TCAP_DLG_LEN]; + u8 components[TCAP_CMP_LEN]; +} TRUni_struct; + +typedef struct TRBegin_struct // transaction begin struct +{ + u8 tid_flag; + u32 transaction_id; + u8 dialogue_len; + u8 components_len; + u8 dialogue[TCAP_DLG_LEN]; + u8 components[TCAP_CMP_LEN]; +} TRBegin_struct; + +typedef struct TRContinue_struct // transaction continue struct +{ + u8 ltid_flag; + u8 ptid_flag; + u32 local_tid; + u32 peer_tid; + u8 dialogue_len; + u8 components_len; + u8 dialogue[TCAP_DLG_LEN]; + u8 components[TCAP_CMP_LEN]; +} TRContinue_struct; + +typedef struct TREnd_struct // transaction end struct +{ + u8 tid_flag; + u32 transaction_id; + u8 termination; + u8 dialogue_len; + u8 components_len; + u8 dialogue[TCAP_DLG_LEN]; + u8 components[TCAP_CMP_LEN]; +} TREnd_struct; + +typedef struct TRUAbort_struct // transaction u-abort struct +{ + u8 tid_flag; + u32 transaction_id; + u8 dialogue_len; + u8 dialogue[TCAP_DLG_LEN]; + u8 uabort_info_len; + u8 uabort_info[TCAP_UABORT_INFO_LEN]; +} TRUAbort_struct; + +typedef struct TRPAbort_struct // transaction p-abort struct +{ + u8 tid_flag; + u32 transaction_id; + u8 abort_reason; +} TRPAbort_struct; + +typedef struct TRNotice_struct // transcation notice struct +{ + u8 tid_flag; + u32 transaction_id; + u8 report_cause; +} TRNotice_struct; + +typedef struct TSL_struct +{ + u8 message_type; + u8 message_flag; + u8 peer_tid_len; /* added by Pierre, 2006-08-19 */ + struct SCCP_ADDRESS local_add; + struct SCCP_ADDRESS peer_add; + union + { + struct TRUni_struct tr_uni; + struct TRBegin_struct tr_begin; + struct TRContinue_struct tr_continue; + struct TREnd_struct tr_end; + struct TRUAbort_struct tr_uabort; + struct TRPAbort_struct tr_pabort; + struct TRNotice_struct tr_notice; + } tsl_prim; +} TSL_struct; + +/* +++++++++++++++++++++++++++++++ */ +/* Component sub-layer structure */ +/* +++++++++++++++++++++++++++++++ */ + +/* define dialogue handing primitive structure */ +typedef struct AARQ_struct +{ + u8 version[2]; + u8 acn_len; + u8 acn[TCAP_ACN_LEN]; + u8 user_info_len; + u8 user_info[TCAP_USERINFO_LEN]; +} AARQ_struct; + +typedef struct AARE_struct +{ + u8 version[2]; + u8 acn_len; + u8 acn[TCAP_ACN_LEN]; + u8 result; + u8 diagnostic_flag; // user or provider + u8 diagnostic_type; // reason + u8 user_info_len; + u8 user_info[TCAP_USERINFO_LEN]; +} AARE_struct; + +typedef struct ABRT_struct +{ + u8 abort_source; + u8 user_info_len; + u8 user_info[TCAP_USERINFO_LEN]; +} ABRT_struct; + +typedef struct ASUDT_struct +{ + u8 version; + u8 acn_type; + u8 acn_len; + u8 acn[TCAP_ACN_LEN]; + u8 user_info_len; + u8 user_info[TCAP_USERINFO_LEN]; + u8 security_context_type; + u8 security_context_len; + u8 security_context[TCAP_SECURITY_CONTEXT_LEN]; + u8 confidential_info_len; + u8 confidential_info[TCAP_CONFIDENTIAL_INFO_LEN]; +} ASUDT_struct; + +typedef struct dlgPDU_struct +{ + u8 dialogue_type; + union + { + struct AARQ_struct aarq; + struct AARE_struct aare; + struct ABRT_struct abrt; + struct ASUDT_struct asudt; + } pdu_union; +} dlgPDU_struct; + +typedef struct dlgport_struct // dialogue portion in the TC +{ + u8 acn_type; + u8 acn_len; + u8 acn[TCAP_ACN_LEN]; + u8 user_info_len; + u8 user_info[TCAP_USERINFO_LEN]; + u8 security_context_type; + u8 security_context_len; + u8 security_context[TCAP_SECURITY_CONTEXT_LEN]; + u8 confidential_info_len; + u8 confidential_info[TCAP_CONFIDENTIAL_INFO_LEN]; +} dlgport_struct; + +typedef struct TCUni_struct // component unidirectional struct +{ + struct SCCP_ADDRESS local_add; + struct SCCP_ADDRESS peer_add; + u8 dialogue_flag; + struct dlgport_struct dlg_data; + u8 component_present; +} TCUni_struct; + +typedef struct TCBegin_struct +{ + struct SCCP_ADDRESS local_add; + struct SCCP_ADDRESS peer_add; + u8 dialogue_flag; + struct dlgport_struct dlg_data; + u8 component_present; +} TCBegin_struct; + +typedef struct TCContinue_struct +{ + u8 dialogue_flag; + struct dlgport_struct dlg_data; + u8 component_present; +} TCContinue_struct; + +typedef struct TCEnd_struct +{ + u8 dialogue_flag; + struct dlgport_struct dlg_data; + u8 component_present; + u8 termination; +} TCEnd_struct; + +typedef struct TCUAbort_struct +{ + u8 uabort_reason; + u8 dialogue_flag; + struct dlgport_struct dlg_data; + u8 uabort_info_len; + u8 uabort_info[TCAP_UABORT_INFO_LEN]; +} TCUAbort_struct; + +typedef struct TCPAbort_struct +{ + u8 pabort_reason; +} TCPAbort_struct; + +typedef struct TCNotice_struct +{ + u8 report_reason; +} TCNotice_struct; + +typedef struct CSLdlg_struct // dialogue primitive in CSL +{ + u32 dialogue_id; + u8 message_type; + u8 message_flag; + union + { + struct TCUni_struct tc_uni; + struct TCBegin_struct tc_begin; + struct TCContinue_struct tc_continue; + struct TCEnd_struct tc_end; + struct TCUAbort_struct tc_uabort; + struct TCPAbort_struct tc_pabort; + struct TCNotice_struct tc_notice; + } dlg_prim; +} CSLdlg_struct; + +/* define component handing primitive structure */ +typedef struct TCInvoke_struct +{ + u8 linkedid_flag; + u8 linked_id; + u8 operation_domain; + u8 operation_family; + u8 operation_code; + u8 parameter_len; + u8 parameter[TCAP_CMP_LEN]; + u8 operation_class; + u32 timer; +} TCInvoke_struct; + +typedef struct TCResult_struct +{ + u8 operation_flag; // the flag indicate if has operation code + u8 operation_domain; + u8 operation_family; + u8 operation_code; + u8 parameter_len; + u8 parameter[TCAP_CMP_LEN]; +} TCResult_struct; + +typedef struct TCUError_struct +{ + u8 error_type; // error tag + u8 error_code; // error code + u8 parameter_len; + u8 parameter[TCAP_CMP_LEN]; +} TCUError_struct; + +typedef struct TCReject_struct +{ + u8 problem_type; + u8 problem_code; + u8 parameter_len; + u8 parameter[TCAP_CMP_LEN]; +} TCReject_struct; + +typedef struct CSLcmp_struct +{ + u32 dialogue_id; // dialogue id + u8 invoke_id; // invoke id + u8 message_type; + u8 message_flag; + u8 last_flag; + union + { + struct TCInvoke_struct tc_invoke; + struct TCResult_struct tc_result; + struct TCUError_struct tc_uerror; + struct TCReject_struct tc_reject; + } cmp_prim; +} CSLcmp_struct; + +/* +++++++++++++++++++++++++++++++ */ +/* TCAP virtue machine structure */ +/* +++++++++++++++++++++++++++++++ */ +typedef struct ismvm_data +{ + u8 used_flag; + u8 linked_iid; + u8 ism_state; + u8 ism_msgtype; + u8 ism_msgflag; + u8 ism_msgclass; + u8 ism_oper_domain; + u8 ism_oper_family; + u8 ism_oper_code; + u32 ism_timer; +} ismvm_data; + +typedef struct tcapvm_struct +{ + struct SCCP_ADDRESS local_add; + struct SCCP_ADDRESS peer_add; + u8 peer_tid_len; + u32 peer_tid; + u32 tcap_timer; + u8 tcap_state; + u8 ac_mode; + u8 proto_type; + u8 tcaprecv_head; + u8 tcaprecv_tail; + struct ismvm_data ism_data[MAX_TEMPINVOKEID]; + struct TSL_struct tsl_data[MAX_TSL_BUF]; +} tcapvm_struct; + +typedef struct tcapint_struct // tcap interface structure +{ + u8 dlgrecv_head; + u8 dlgrecv_tail; + u8 dlgsend_head; + u8 dlgsend_tail; + struct CSLdlg_struct dlg_recv[MAX_TSL_BUF]; + struct CSLdlg_struct dlg_send[MAX_TSL_BUF]; + u8 cmprecv_head; + u8 cmprecv_tail; + u8 cmpsend_head; + u8 cmpsend_tail; + struct CSLcmp_struct cmp_recv[MAX_CSL_BUF]; + struct CSLcmp_struct cmp_send[MAX_CSL_BUF]; +} tcapint_struct; + +typedef struct tcapbuf_struct // TCAP buffer structure +{ + int grantdid; + struct tcapvm_struct tcapvm_data[MAX_DIALOGUEID]; + struct tcapint_struct tcapint_data[MAX_DIALOGUEID]; + struct tcapdebug_struct tcap_debug; +} tcapbuf_struct; + +struct tcapbuf_struct *tcap_ptr; + +u8 tsl_message_decode(struct SCLC_MSG *sccp_ptr,struct TSL_struct *dst_ptr,u8 *err_code);// tsl decode +u8 tsl_message_encode(struct SCLC_MSG *sccp_ptr,struct TSL_struct *tsl_ptr,u8 flag);// tsl encode +u8 extract_dp(struct dlgPDU_struct *pdu_ptr,u8 *databuf,int datalen,u8 proto_type); // extract dialogue portion +u8 build_dp(u8 *content,struct dlgPDU_struct *dlg_ptr,u8 un_flag,u8 proto_type); // build dialogue portion +int extract_component(struct CSLcmp_struct *cmp_ptr,u8 *data_buf,u32 proc,int *section_len); // extract component portion +int assemble_component(u8 *string,struct CSLcmp_struct *cha_ptr); // assemble component portion +void tcapvm_init(); // init share memory +u8 write_ism(CSLcmp_struct *cmp_ptr); +void tco_program(void); // transaction coordinator +void tsm_program(u32 proc); +void ism_program(u32 proc); // invocation state machine + +#endif diff --git a/omc/plat/tcap/src/itcap.c b/omc/plat/tcap/src/itcap.c new file mode 100644 index 0000000..b755020 --- /dev/null +++ b/omc/plat/tcap/src/itcap.c @@ -0,0 +1,758 @@ +/* interface c file */ +/* written by Liu zhiguo 2002-08-16 */ +/* version 2.0 */ +/* ----------------------------- */ +#include "../../sccp/src/include/sccp.h" +#include "./include/tcap_public.h" +#include "./include/tcap_struct.h" +#include "./include/idmanage.h" +#include "./include/tcap_m.h" + +/*@ignore@*/ +static u8 t10ms_flag; +static u32 tcap_proc; + +u32 tcap_dlg_h[MAX_DIALOGUEID]; +u32 tcap_dlg_t[MAX_DIALOGUEID]; +u32 tcap_dlg_stats[MAX_DIALOGUEID]; + +typedef struct id_struct +{ + u32 current_did; + u32 count_did; + u32 count_did_occupied; + u32 count_did_max; + u32 count_did_tmp; + u8 dialogue_id[MAX_DIALOGUEID]; + u8 current_iid[MAX_DIALOGUEID]; + u8 invoke_id[MAX_DIALOGUEID][MAX_INVOKEID]; +}id_struct; + +extern struct id_struct *ID_ptr; + +void tcap_disp_dlg(struct CSLdlg_struct *dha_ptr,u8 disp_flag) +{ + char temp_buf[1024],temp_data[1024]; + char info_str[1024]; + char *cur_time; + struct TCUni_struct *uni_ptr; + struct TCBegin_struct *begin_ptr; + struct TCContinue_struct *con_ptr; + struct TCEnd_struct *end_ptr; + struct TCUAbort_struct *uabrt_ptr; + struct TCPAbort_struct *pabrt_ptr; + u8 proto_type; + + if (tcap_ptr->tcap_debug.send_control == 1) + return; + if (tcap_ptr->tcap_debug.tcu_switch == 0 && dha_ptr->dialogue_id != tcap_ptr->tcap_debug.monitor_did) + return; + if (disp_flag == 1) // send data to tc-user + strcpy(info_str,"Dialogue tcap->tc user, time: "); + else + strcpy(info_str,"Dialogue tc user->tcap, time: "); + cur_time = GetAsciiTime(); + strcat(info_str,cur_time); + strcat(info_str,"\rType: "); + if (dha_ptr->message_flag == REQUEST) + sprintf(temp_buf,"\tFlag: Request\tDialogue id: %ld\r\n",dha_ptr->dialogue_id); + else + sprintf(temp_buf,"\tFlag: Indicate\tDialogue id: %ld\r\n",dha_ptr->dialogue_id); + if ((dha_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + switch (dha_ptr->message_type) + { + case Unidirectional: + case Unidirectional_Ansi: + if (dha_ptr->message_type == Unidirectional) + strcat(info_str,"Unidirectional"); + else + strcat(info_str,"Unidirectional_Ansi"); + strcat(info_str,temp_buf); + uni_ptr = (TCUni_struct *) &dha_ptr->dlg_prim.tc_uni; + if (uni_ptr->dialogue_flag == 1) + { + if (uni_ptr->dlg_data.acn_len > 0) + { + HexToDisplay(temp_buf,uni_ptr->dlg_data.acn,uni_ptr->dlg_data.acn_len); + sprintf(temp_data,"ACN is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (uni_ptr->dlg_data.user_info_len > 0) + { + HexToDisplay(temp_buf,uni_ptr->dlg_data.user_info,uni_ptr->dlg_data.user_info_len); + sprintf(temp_data,"User info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (proto_type) + { + if (uni_ptr->dlg_data.security_context_len > 0) + { + HexToDisplay(temp_buf,uni_ptr->dlg_data.security_context,uni_ptr->dlg_data.security_context_len); + sprintf(temp_data,"Security context is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (uni_ptr->dlg_data.confidential_info_len > 0) + { + HexToDisplay(temp_buf,uni_ptr->dlg_data.confidential_info,uni_ptr->dlg_data.confidential_info_len); + sprintf(temp_data,"Confidential info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + } + if (uni_ptr->component_present != 0) + strcat(info_str,"Has component\r\n"); + strcat(info_str,"\r\n"); + break; + case Begin: + case Query_WithPerm_Ansi: + case Query_WithoutPerm_Ansi: + if (dha_ptr->message_type == Begin) + strcat(info_str,"Begin"); + else if (dha_ptr->message_type == Query_WithPerm_Ansi) + strcat(info_str,"Query_WithPerm_Ansi"); + else + strcat(info_str,"Query_WithoutPerm_Ansi"); + strcat(info_str,temp_buf); + begin_ptr = (TCBegin_struct *) &dha_ptr->dlg_prim.tc_begin; + if (begin_ptr->dialogue_flag == 1) + { + if (begin_ptr->dlg_data.acn_len > 0) + { + HexToDisplay(temp_buf,begin_ptr->dlg_data.acn,begin_ptr->dlg_data.acn_len); + sprintf(temp_data,"ACN is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (begin_ptr->dlg_data.user_info_len != 0) + { + HexToDisplay(temp_buf,begin_ptr->dlg_data.user_info,begin_ptr->dlg_data.user_info_len); + sprintf(temp_data,"User info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (proto_type) + { + if (begin_ptr->dlg_data.security_context_len > 0) + { + HexToDisplay(temp_buf,begin_ptr->dlg_data.security_context,begin_ptr->dlg_data.security_context_len); + sprintf(temp_data,"Security context is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (begin_ptr->dlg_data.confidential_info_len > 0) + { + HexToDisplay(temp_buf,begin_ptr->dlg_data.confidential_info,begin_ptr->dlg_data.confidential_info_len); + sprintf(temp_data,"Confidential info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + } + if (begin_ptr->component_present != 0) + strcat(info_str,"Has component\r\n"); + strcat(info_str,"\r\n"); + break; + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + if (dha_ptr->message_type == Continue) + strcat(info_str,"Continue"); + else if (dha_ptr->message_type == Conversation_WithPerm_Ansi) + strcat(info_str,"Conversation_WithPerm_Ansi"); + else + strcat(info_str,"Conversation_WithoutPerm_Ansi"); + strcat(info_str,temp_buf); + con_ptr = (TCContinue_struct *) &dha_ptr->dlg_prim.tc_continue; + if (con_ptr->dialogue_flag == 1) + { + if (con_ptr->dlg_data.acn_len > 0) + { + HexToDisplay(temp_buf,con_ptr->dlg_data.acn,con_ptr->dlg_data.acn_len); + sprintf(temp_data,"ACN is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (con_ptr->dlg_data.user_info_len != 0) + { + HexToDisplay(temp_buf,con_ptr->dlg_data.user_info,con_ptr->dlg_data.user_info_len); + sprintf(temp_data,"User info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (proto_type) + { + if (con_ptr->dlg_data.security_context_len > 0) + { + HexToDisplay(temp_buf,con_ptr->dlg_data.security_context,con_ptr->dlg_data.security_context_len); + sprintf(temp_data,"Security context is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (con_ptr->dlg_data.confidential_info_len > 0) + { + HexToDisplay(temp_buf,con_ptr->dlg_data.confidential_info,con_ptr->dlg_data.confidential_info_len); + sprintf(temp_data,"Confidential info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + } + if (con_ptr->component_present != 0) + strcat(info_str,"Has component\r\n"); + strcat(info_str,"\r\n"); + break; + case End: + case Response_Ansi: + if (dha_ptr->message_type == End) + strcat(info_str,"End"); + else + strcat(info_str,"Response"); + strcat(info_str,temp_buf); + end_ptr = (TCEnd_struct *) &dha_ptr->dlg_prim.tc_end; + if (end_ptr->dialogue_flag == 1) + { + if (end_ptr->dlg_data.acn_len > 0) + { + HexToDisplay(temp_buf,end_ptr->dlg_data.acn,end_ptr->dlg_data.acn_len); + sprintf(temp_data,"ACN is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (proto_type) + { + if (end_ptr->dlg_data.user_info_len != 0) + { + HexToDisplay(temp_buf,end_ptr->dlg_data.user_info,end_ptr->dlg_data.user_info_len); + sprintf(temp_data,"User info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (end_ptr->dlg_data.security_context_len > 0) + { + HexToDisplay(temp_buf,end_ptr->dlg_data.security_context,end_ptr->dlg_data.security_context_len); + sprintf(temp_data,"Security context is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (end_ptr->dlg_data.confidential_info_len > 0) + { + HexToDisplay(temp_buf,end_ptr->dlg_data.confidential_info,end_ptr->dlg_data.confidential_info_len); + sprintf(temp_data,"Confidential info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + } + if (end_ptr->component_present != 0) + strcat(info_str,"Has component\r\n"); + strcat(info_str,"\r\n"); + break; + case U_Abort: + case U_Abort_Ansi: + if (dha_ptr->message_type == U_Abort) + strcat(info_str,"U_Abort"); + else + strcat(info_str,"U_Abort_Ansi"); + strcat(info_str,temp_buf); + uabrt_ptr = (TCUAbort_struct *) &dha_ptr->dlg_prim.tc_uabort; + if (uabrt_ptr->dialogue_flag == 1) + { + if (uabrt_ptr->dlg_data.acn_len != 0) + { + HexToDisplay(temp_buf,uabrt_ptr->dlg_data.acn,uabrt_ptr->dlg_data.acn_len); + sprintf(temp_data,"ACN is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (proto_type) + { + if (uabrt_ptr->dlg_data.user_info_len != 0) + { + HexToDisplay(temp_buf,uabrt_ptr->dlg_data.user_info,uabrt_ptr->dlg_data.user_info_len); + sprintf(temp_data,"User info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (uabrt_ptr->dlg_data.security_context_len > 0) + { + HexToDisplay(temp_buf,uabrt_ptr->dlg_data.security_context,uabrt_ptr->dlg_data.security_context_len); + sprintf(temp_data,"Security context is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + if (uabrt_ptr->dlg_data.confidential_info_len > 0) + { + HexToDisplay(temp_buf,uabrt_ptr->dlg_data.confidential_info,uabrt_ptr->dlg_data.confidential_info_len); + sprintf(temp_data,"Confidential info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + } + if (!proto_type) + { + sprintf(temp_buf,"User abort reason: %d\r\n",uabrt_ptr->uabort_reason); + strcat(info_str,temp_buf); + } + else + { + if (uabrt_ptr->uabort_info_len != 0) + { + HexToDisplay(temp_buf,uabrt_ptr->uabort_info,uabrt_ptr->uabort_info_len); + sprintf(temp_data,"User abort info is: %s\r\n",temp_buf); + strcat(info_str,temp_data); + } + } + strcat(info_str, "\r\n"); + break; + case P_Abort: + case P_Abort_Ansi: + if (dha_ptr->message_type == P_Abort) + strcat(info_str,"P_Abort"); + else + strcat(info_str,"P_Abort_Ansi"); + strcat(info_str,temp_buf); + pabrt_ptr = (TCPAbort_struct *) &dha_ptr->dlg_prim.tc_pabort; + sprintf(temp_buf,"Provider abort reason: %d\r\n",pabrt_ptr->pabort_reason); + strcat(info_str,temp_buf); + strcat(info_str, "\r\n"); + break; + default: + break; + } + tcap_send_ascout(info_str); +} + +void tcap_disp_cmp(struct CSLcmp_struct *cha_ptr,u8 disp_flag) +{ + int ii=0; + char temp_buf[1024]; + char info_str[1024]; + char *cur_time; + u8 proto_type; + struct TCInvoke_struct *invoke_ptr; + struct TCResult_struct *result_ptr; + struct TCUError_struct *uerror_ptr; + struct TCReject_struct *reject_ptr; + + if (tcap_ptr->tcap_debug.send_control == 1) + return; + if (tcap_ptr->tcap_debug.tcu_switch == 0 && cha_ptr->dialogue_id != tcap_ptr->tcap_debug.monitor_did) + return; + if (disp_flag == 1) // send data to tc-user + strcpy(info_str,"Component tcap->tc user, time: "); + else + strcpy(info_str,"Component tc user->tcap, time: "); + cur_time = GetAsciiTime(); + strcat(info_str,cur_time); + strcat(info_str,"\rType: "); + if (cha_ptr->message_flag == REQUEST) + sprintf(temp_buf,"\tFlag: Request\tDialogue id: %ld, Invoke id: %d\r\n",cha_ptr->dialogue_id,cha_ptr->invoke_id); + else + sprintf(temp_buf,"\tFlag: Indicate\tDialogue id: %ld, Invoke id: %d\r\n",cha_ptr->dialogue_id,cha_ptr->invoke_id); + if ((cha_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + switch (cha_ptr->message_type) + { + case Invoke: + case Invoke_L_Ansi: + case Invoke_NL_Ansi: + if (cha_ptr->message_type == Invoke) + strcat(info_str,"Invoke"); + else if (cha_ptr->message_type == Invoke_L_Ansi) + strcat(info_str,"Invoke_L_Ansi"); + else + strcat(info_str,"Invoke_NL_Ansi"); + strcat(info_str,temp_buf); + invoke_ptr = (TCInvoke_struct *) &cha_ptr->cmp_prim.tc_invoke; + ii = invoke_ptr->parameter_len; + if (cha_ptr->message_type == Invoke) + sprintf(temp_buf,"Operation code: %d\tParameter len: %d\r\n",invoke_ptr->operation_code,ii); + else + sprintf(temp_buf,"Operation family: %d\tOperation code: %d\tParameter len: %d\r\n",invoke_ptr->operation_family,invoke_ptr->operation_code,ii); + strcat(info_str,temp_buf); + if (ii != 0) + { + strcat(info_str,"Parameter: "); + HexToDisplay(temp_buf,invoke_ptr->parameter,ii); + strcat(info_str,temp_buf); + strcat(info_str,"\r\n"); + } + strcat(info_str, "\r\n"); + break; + case Result_L: + case Result_NL: + case Result_L_Ansi: + case Result_NL_Ansi: + if (cha_ptr->message_type == Result_L) + strcat(info_str,"Result_L"); + else if (cha_ptr->message_type == Result_NL) + strcat(info_str,"Result_NL"); + else if (cha_ptr->message_type == Result_L_Ansi) + strcat(info_str,"Result_L_Ansi"); + else + strcat(info_str,"Result_NL_Ansi"); + strcat(info_str,temp_buf); + result_ptr = (TCResult_struct *) &cha_ptr->cmp_prim.tc_result; + ii = result_ptr->parameter_len; + if (ii != 0) + { + if ((cha_ptr->message_type == Result_L_Ansi) || + (cha_ptr->message_type == Result_NL_Ansi)) + sprintf(temp_buf,"Operation family: %d\tOperation code: %d\tParameter len: %d\r\n",result_ptr->operation_family,result_ptr->operation_code,ii); + else + sprintf(temp_buf,"Operation code: %d\tParameter len: %d\r\n",result_ptr->operation_code,ii); + strcat(info_str,temp_buf); + strcat(info_str,"Parameter: "); + HexToDisplay(temp_buf,result_ptr->parameter,ii); + strcat(info_str,temp_buf); + strcat(info_str,"\r\n"); + } + strcat(info_str, "\r\n"); + break; + case U_Error: + case U_Error_Ansi: + if (cha_ptr->message_type == U_Error) + strcat(info_str,"U_Error"); + else + strcat(info_str,"U_Error_Ansi"); + strcat(info_str,temp_buf); + uerror_ptr = (TCUError_struct *) &cha_ptr->cmp_prim.tc_uerror; + ii = uerror_ptr->parameter_len; + sprintf(temp_buf,"Error code: %d\tParameter len: %d\r\n",uerror_ptr->error_code,ii); + strcat(info_str,temp_buf); + if (ii != 0) + { + strcat(info_str,"Parameter: "); + HexToDisplay(temp_buf,uerror_ptr->parameter,ii); + strcat(info_str,temp_buf); + strcat(info_str,"\r\n"); + } + strcat(info_str, "\r\n"); + break; + case U_Reject: + case L_Reject: + case R_Reject: + case U_Reject_Ansi: + case L_Reject_Ansi: + case R_Reject_Ansi: + switch (cha_ptr->message_type) + { + case U_Reject: + strcat(info_str,"U_Reject"); + break; + case L_Reject: + strcat(info_str,"L_Reject"); + break; + case R_Reject: + strcat(info_str,"R_Reject"); + break; + case U_Reject_Ansi: + strcat(info_str,"U_Reject_Ansi"); + break; + case L_Reject_Ansi: + strcat(info_str,"L_Reject_Ansi"); + break; + case R_Reject_Ansi: + strcat(info_str,"R_Reject_Ansi"); + break; + } + strcat(info_str,temp_buf); + reject_ptr = (TCReject_struct *) &cha_ptr->cmp_prim.tc_reject; + sprintf(temp_buf,"Problem type: %d\tProblem code: %d",reject_ptr->problem_type,reject_ptr->problem_code); + strcat(info_str,temp_buf); + if (proto_type) + { + ii = reject_ptr->parameter_len; + if (ii != 0) + { + sprintf(temp_buf,"\tParameter len: %d\r\n",ii); + strcat(info_str,temp_buf); + strcat(info_str,"Parameter: "); + HexToDisplay(temp_buf,reject_ptr->parameter,ii); + strcat(info_str,temp_buf); + } + } + strcat(info_str,"\r\n\r\n"); + break; + default: + if (cha_ptr->message_type == L_Cancel) + strcat(info_str,"Local cancel"); + else if (cha_ptr->message_type == U_Cancel) + strcat(info_str,"User cancel"); + strcat(info_str,temp_buf); + strcat(info_str,"\r\n"); + break; + } + tcap_send_ascout(info_str); +} + +u8 RecvTcapDlg(struct CSLdlg_struct *dha_ptr,u32 dlg_flag) // receive the dialogue portion +{ + struct tcapint_struct *int_ptr; + u8 ii; + + if (dlg_flag >= (tcap_ptr->grantdid)) + return 0; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[dlg_flag]; + ii = int_ptr->dlgrecv_tail; + if (ii == int_ptr->dlgrecv_head) + return 0; + memcpy(dha_ptr,&int_ptr->dlg_recv[ii],sizeof(CSLdlg_struct)); + int_ptr->dlgrecv_tail = (ii + 1) % MAX_TSL_BUF; + tcap_disp_dlg(dha_ptr,1); + return 1; +} + +u8 RecvTcapCmp(struct CSLcmp_struct *cha_ptr,u32 dlg_flag) // receive the component portion +{ + struct tcapint_struct *int_ptr; + u8 ii; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + if (dlg_flag >= (tcap_ptr->grantdid)) + { + debug_ptr->watch_dog[247]++; + return 0; + } + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[dlg_flag]; + ii = int_ptr->cmprecv_tail; + if (ii == int_ptr->cmprecv_head) + return 0; + memcpy(cha_ptr,&int_ptr->cmp_recv[ii],sizeof(CSLcmp_struct)); + int_ptr->cmprecv_tail = (ii + 1) % MAX_CSL_BUF; + tcap_disp_cmp(cha_ptr,1); + debug_ptr->watch_dog[246]++; + return 1; +} + +u8 SendTcapDlg(struct CSLdlg_struct *dha_ptr) // send the dialogue portion +{ + struct tcapint_struct *int_ptr; + u32 dlg_flag; + u8 ii; + char info_str[1024]; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + dlg_flag = dha_ptr->dialogue_id; + if (dlg_flag >= (tcap_ptr->grantdid)) + { + debug_ptr->watch_dog[194]++; + return 0; + } + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[dlg_flag]; + ii = int_ptr->dlgsend_head; + + if (tcap_dlg_h[dlg_flag] != int_ptr->dlgsend_head) + { + debug_ptr->watch_dog[192] ++; + //printf("h: %d-%d\n", tcap_dlg_h[dlg_flag], int_ptr->dlgsend_head); + } + + if (((ii + 1) % MAX_TSL_BUF) == int_ptr->dlgsend_tail) // buffer is full + { + tcap_send_error("TCAP error. TCU to TCAP buffer is full"); + debug_ptr->watch_dog[193]++; + return 0; + } + memcpy(&int_ptr->dlg_send[ii],dha_ptr,sizeof(CSLdlg_struct)); + int_ptr->dlgsend_head = (ii + 1) % MAX_TSL_BUF; + + tcap_dlg_h[dlg_flag] = int_ptr->dlgsend_head; + + switch (dha_ptr->message_type) + { + case U_Abort: + case U_Abort_Ansi: + if (tcap_ptr->tcap_debug.error_switch) + { + if (dha_ptr->message_type == U_Abort) + sprintf(info_str,"CSL warning. Receive U_Abort from TC-user. Did: %ld",dlg_flag); + else + sprintf(info_str,"CSL warning. Receive U_Abort_Ansi from TC-user. Did: %ld",dlg_flag); + tcap_send_error(info_str); + } + break; + case P_Abort: + case P_Abort_Ansi: + if (tcap_ptr->tcap_debug.error_switch) + { + if (dha_ptr->message_type == P_Abort) + sprintf(info_str,"CSL warning. Receive P_Abort from TC-user. Did: %ld",dlg_flag); + else + sprintf(info_str,"CSL warning. Receive P_Abort_Ansi from TC-user. Did: %ld",dlg_flag); + tcap_send_error(info_str); + } + break; + default: + break; + } + tcap_disp_dlg(dha_ptr,2); + if (dha_ptr->message_type == Begin) + { + if (ID_ptr->dialogue_id[dlg_flag] == 0) + debug_ptr->watch_dog[183]++; + if (++tcap_dlg_stats[dlg_flag] > 1) + debug_ptr->watch_dog[182]++; + debug_ptr->watch_dog[196]++; + } + debug_ptr->watch_dog[195]++; + + return 1; +} + +u8 SendTcapCmp(struct CSLcmp_struct *cha_ptr) // send the component portion +{ + struct tcapint_struct *int_ptr; + u32 dlg_flag; + u8 inv_flag; + u8 ii,jj,kk; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + + dlg_flag = cha_ptr->dialogue_id; + inv_flag = cha_ptr->invoke_id; + if (dlg_flag >= (tcap_ptr->grantdid)) + { + debug_ptr->watch_dog[253]++; + return 0; + } + +//add by daniel on 2006-06-19, to release invoke id propery, if the component is not invoke, then the iid will be released + if ((cha_ptr->message_type != Invoke ) && + (cha_ptr->message_type != Result_NL)) + { + free_iid(dlg_flag,inv_flag); + //tcap_send_ascout("sendTcapCmp free_iid\r\n"); + } +//add by daniel on 2006-06-19, to release invoke id propery, if the component is not invoke, then the iid will be released + + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[dlg_flag]; + tcap_disp_cmp(cha_ptr,2); + if (cha_ptr->message_type == U_Cancel) + { + ii = int_ptr->cmpsend_tail; + while (ii != int_ptr->cmpsend_head) // search any INV component for this DID and TID + { + if (int_ptr->cmp_send[ii].invoke_id == inv_flag) // has data which is not sent out + { + jj = ii; + kk = (ii + 1) % MAX_CSL_BUF; + while (kk != int_ptr->cmpsend_head) + { + memcpy(&int_ptr->cmp_send[jj],&int_ptr->cmp_send[kk],sizeof(CSLcmp_struct)); + jj = (jj + 1) % MAX_CSL_BUF; + kk = (kk + 1) % MAX_CSL_BUF; + } + if (int_ptr->cmpsend_head == 0) + int_ptr->cmpsend_head = MAX_CSL_BUF - 1; + else + int_ptr->cmpsend_head -= 1; + if (int_ptr->cmpsend_head == ii) + { + write_ism(cha_ptr); + debug_ptr->watch_dog[238]++; + debug_ptr->watch_dog[255]++; + return 1; + } + } + ii = (ii + 1) % MAX_CSL_BUF; + debug_ptr->watch_dog[235]++; + } + write_ism(cha_ptr); + debug_ptr->watch_dog[240]++; + debug_ptr->watch_dog[255]++; + return 1; + } + ii = int_ptr->cmpsend_head; + if (((ii + 1) % MAX_CSL_BUF) == int_ptr->cmpsend_tail) // buffer full + { + tcap_send_alarm(3,1); + tcap_send_error("CSL warning. ISM buffer is full"); + debug_ptr->watch_dog[254]++; + return 0; + } + memcpy(&int_ptr->cmp_send[ii],cha_ptr,sizeof(CSLcmp_struct)); + int_ptr->cmpsend_head = (ii + 1) % MAX_CSL_BUF; + if ((cha_ptr->message_type == U_Reject) || + (cha_ptr->message_type == U_Reject_Ansi) || + (cha_ptr->message_type == Invoke) || + (cha_ptr->message_type == Invoke_L_Ansi) || + (cha_ptr->message_type == Invoke_NL_Ansi)) + { + debug_ptr->watch_dog[239]++; + write_ism(cha_ptr); + } + else + { + debug_ptr->watch_dog[237]++; + if (cha_ptr->message_type != Result_L) + { + debug_ptr->watch_dog[236]++; +// printf("tcap: %d\n", cha_ptr->message_type); + } + } + debug_ptr->watch_dog[255]++; + return 1; +} + +void tcap_fsm(void) // TCAP state machine +{ + register u32 proc; + struct tcapdebug_struct *debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + +// write_paralport(TCAP_LED_CODE,1); + t10ms_flag ++; + if (t10ms_flag >= 2) // 20ms circle + { + t10ms_flag = 0; + tcap_monitor(); + } + for (proc = 0;proc < 64;proc++) + tco_program(); + for (proc = 0;proc < (tcap_ptr->grantdid)/2;proc ++) + { + ism_program(tcap_proc); + tsm_program(tcap_proc); + if (tcap_proc != 0) + { + if (check_did(tcap_proc) || !xapp_check_did(tcap_proc)) + ID_ptr->count_did_tmp++; + } + if (tcap_proc == (tcap_ptr->grantdid - 1)) + { + if ((ID_ptr->count_did_occupied = ID_ptr->count_did_tmp) > ID_ptr->count_did_max) + ID_ptr->count_did_max = ID_ptr->count_did_occupied; + ID_ptr->count_did_tmp = 0; + memcpy(&debug_ptr->watch_dog[160], (BYTE *) &ID_ptr->count_did, sizeof(u32)); + memcpy(&debug_ptr->watch_dog[164], (BYTE *) &ID_ptr->count_did_occupied, sizeof(u32)); + memcpy(&debug_ptr->watch_dog[168], (BYTE *) &ID_ptr->count_did_max, sizeof(u32)); + } + tcap_proc = (tcap_proc + 1) % (tcap_ptr->grantdid); + } +// write_paralport(TCAP_LED_CODE,0); +} + +int itcap_reg_ssn(u8 ssn) +{ + return register_ssn(ssn,0); +} + +int tcap_get_grantdid() +{ + return ((tcap_ptr->grantdid>MAX_DIALOGUEID) \ + ? MAX_DIALOGUEID: tcap_ptr->grantdid); +} + +void tcap_init(int didgrant,DWORD localip,DWORD peerip) // init TCAP system +{ + printf("Tcap init start!\n"); + if( didgrant <= 0 || didgrant > MAX_DIALOGUEID) + { + printf( "unexpect tcap did grant number!\r\n"); + exit(0); + } + init_id(didgrant); + tcapvm_init(localip,peerip); + tcap_ptr->grantdid = didgrant; + init_m(); + t10ms_flag = 0; + tcap_proc = 0; + + memset(tcap_dlg_h, 0, sizeof(u32) * MAX_DIALOGUEID); + memset(tcap_dlg_t, 0, sizeof(u32) * MAX_DIALOGUEID); + memset(tcap_dlg_stats, 0, sizeof(u32) * MAX_DIALOGUEID); + + printf("Tcap init complete!\n"); +} +/*@end@*/ diff --git a/omc/plat/tcap/src/tcap_coding.c b/omc/plat/tcap/src/tcap_coding.c new file mode 100644 index 0000000..4a15410 --- /dev/null +++ b/omc/plat/tcap/src/tcap_coding.c @@ -0,0 +1,2265 @@ +/* TCAP code/decode c file */ +/* written by Liu Zhiguo 2002-08-08 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "../../public/src/include/asn1.h" +#include "../../sccp/src/include/sccp.h" +#include "./include/tcap_public.h" +#include "./include/tcap_struct.h" +#include "./include/tcap_m.h" + +/*@ignore@*/ +/* protocol version */ +static u8 Version_1[2] = {0x07,0x80}; + +/* Undialogue-As-ID value */ +static u8 Undialogue_As_ID[7] = {0x00,0x11,0x86,0x05,0x01,0x02,0x01}; +/* Dialogue-As-ID value */ +static u8 Dialogue_As_ID[7] = {0x00,0x11,0x86,0x05,0x01,0x01,0x01}; + +void print_msg(u8 *ptr, u16 len) +{ + int i; + + for (i = 0; i < len; i++) + printf("%02X ", ptr[i]); + + printf("\n"); +} + +u8 tsl_message_decode(struct SCLC_MSG *src_ptr,struct TSL_struct *dst_ptr, u8 *err_code)// tsl decode +{ + #define TMPBUFSIZE 512 + ASN_BUF asn_buf; + struct TRUni_struct *uni_ptr; + struct TRBegin_struct *begin_ptr; + struct TRContinue_struct *con_ptr; + struct TREnd_struct *end_ptr; + struct TRUAbort_struct *uabort_ptr; + struct TRPAbort_struct *pabort_ptr; + int len=0; + u32 temp_tid=0; + u8 temp_buf[TMPBUFSIZE]; + u8 tag_class; + u16 tag_code; + u8 uabort_flag; + + memcpy(&dst_ptr->peer_add,&src_ptr->src_addr,sizeof(SCCP_ADDR)); + memcpy(&dst_ptr->local_add,&src_ptr->dst_addr,sizeof(SCCP_ADDR)); + + len = asn_decode(src_ptr->msg,1,&asn_buf); + if (len == -1) + tcap_send_error("TSL decode error. ASN.1 structure has problem"); + + len = GetAnyTLV("1",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is Unidirectional/Unidirectional_Ansi + if (len != -1) // message_type is Unidirectional/Unidirectional_Ansi + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + dst_ptr->message_type = Unidirectional_Ansi; + tcap_send_info("Unidirectional_Ansi received from sccp"); + } + else + { + dst_ptr->message_type = Unidirectional; + tcap_send_info("Unidirectional received from sccp"); + } + dst_ptr->message_flag = INDICATE; + uni_ptr = (TRUni_struct *) &dst_ptr->tsl_prim.tr_uni; + uni_ptr->dialogue_len = uni_ptr->components_len = 0; + if (tag_class == ANSI_TAG_CLASS_CONS) + { + len = get_tlv("1.7",temp_buf,&asn_buf); + if (len != 0) + { + tcap_send_error("TSL decode error. Lacks transaction id"); + *err_code = DERR_OTHER; + return 0; + } + } + if (tag_class == ANSI_TAG_CLASS_CONS) + len = get_tlv("1.25",temp_buf,&asn_buf); // get dialogue portion + else + len = get_tlv("1.11",temp_buf,&asn_buf); + if (len != -1) + { + if (len <= TCAP_DLG_LEN) + { + uni_ptr->dialogue_len = len; + memcpy(uni_ptr->dialogue,temp_buf,len); + } + else + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + if (tag_class == ANSI_TAG_CLASS_CONS) + len = get_tlv("1.8",uni_ptr->components,&asn_buf); + else + len = get_tlv("1.12",uni_ptr->components,&asn_buf); + if ((len == -1) || (len > TCAP_CMP_LEN)) + { + if (len == -1) + tcap_send_error("TSL decode error. Lacks component portion"); + else + tcap_send_error("TSL decode error. Component portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + uni_ptr->components_len = len; + sprintf(temp_buf, "dialogue portion len: %02X, component portion len: %02X\r\n", uni_ptr->dialogue_len, uni_ptr->components_len); + tcap_send_info(temp_buf); + return 1; + } + + len = GetAnyTLV("2",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is begin/query with permission + if (len == -1) + len = GetAnyTLV("3",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is query without permission + if (len != -1) // message_type is begin/query + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 2) + { + dst_ptr->message_type = Query_WithPerm_Ansi; + tcap_send_info("Query_WithPerm_Ansi received from sccp"); + } + else + { + dst_ptr->message_type = Query_WithoutPerm_Ansi; + tcap_send_info("Query_WithoutPerm_Ansi received from sccp"); + } + } + else + { + dst_ptr->message_type = Begin; + tcap_send_info("Begin received from sccp"); + } + dst_ptr->message_flag = INDICATE; + begin_ptr = (TRBegin_struct *) &dst_ptr->tsl_prim.tr_begin; + begin_ptr->dialogue_len = begin_ptr->components_len = 0; + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 2) // get otid + len = get_tlv("2.7",temp_buf,&asn_buf); + else + len = get_tlv("3.7",temp_buf,&asn_buf); + if (len != 4) + { + tcap_send_error("TSL decode error. Lacks originating transaction id"); + begin_ptr->tid_flag = 0; + *err_code = DERR_OTHER; + return 0; + } + } + else + { + len = get_tlv("2.8",temp_buf,&asn_buf); // get otid + if ((len == -1) || (len > 4) || (len == 0)) + { + tcap_send_error("TSL decode error. Lacks originating transaction id"); + begin_ptr->tid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + } + + dst_ptr->peer_tid_len = len; /* added by Pierre, 2006-08-19 */ + + begin_ptr->transaction_id = bcdtou32(temp_buf,len); + begin_ptr->tid_flag = 1; + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 2) + len = get_tlv("2.25",temp_buf,&asn_buf); + else + len = get_tlv("3.25",temp_buf,&asn_buf); + } + else + len = get_tlv("2.11",temp_buf,&asn_buf); + if (len != -1) // has dialogue portion + { + if (len <= TCAP_DLG_LEN) + { + begin_ptr->dialogue_len = len; + memcpy(begin_ptr->dialogue,temp_buf,len); + } + else + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 2) + len = get_tlv("2.8",begin_ptr->components,&asn_buf); + else + len = get_tlv("3.8",begin_ptr->components,&asn_buf); + } + else + len = get_tlv("2.12",begin_ptr->components,&asn_buf); + if (((len == -1) || (len > TCAP_CMP_LEN)) && (tag_class == ANSI_TAG_CLASS_CONS)) // has components portion + { + if (len == -1) + tcap_send_error("TSL decode error. Lacks component portion"); + else + tcap_send_error("TSL decode error. Component portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + if (len != -1 && len <= TCAP_CMP_LEN) + begin_ptr->components_len = len; + sprintf(temp_buf, "otid: %08lX, dialogue portion len: %02X, component portion len: %02X\r\n", + begin_ptr->transaction_id, begin_ptr->dialogue_len, begin_ptr->components_len); + tcap_send_info(temp_buf); + return 1; + } + + len = GetAnyTLV("4",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is end/response + if (len != -1) // message_type is end/response + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + dst_ptr->message_type = Response_Ansi; + tcap_send_info("Response_Ansi received from sccp"); + } + else + { + dst_ptr->message_type = End; + tcap_send_info("End received from sccp"); + } + dst_ptr->message_flag = INDICATE; + end_ptr = (TREnd_struct *) &dst_ptr->tsl_prim.tr_end; + end_ptr->dialogue_len = end_ptr->components_len = 0; + if (tag_class == ANSI_TAG_CLASS_CONS) + { + len = get_tlv("4.7",temp_buf,&asn_buf); // get dtid + if (len != 4) + { + tcap_send_error("TSL decode error. Lacks responding transaction id"); + end_ptr->tid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + } + else + { + len = get_tlv("4.9",temp_buf,&asn_buf); // get dtid + if ((len == -1) || (len > 4) || (len == 0)) + { + tcap_send_error("TSL decode error. Lacks destination transaction id"); + end_ptr->tid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + } + end_ptr->transaction_id = bcdtou32(temp_buf,len); + end_ptr->tid_flag = 1; + if (tag_class == ANSI_TAG_CLASS_CONS) + len = get_tlv("4.25",temp_buf,&asn_buf); + else + len = get_tlv("4.11",temp_buf,&asn_buf); + if (len != -1) // has dialogue portion + { + if (len <= TCAP_DLG_LEN) + { + end_ptr->dialogue_len = len; + memcpy(end_ptr->dialogue,temp_buf,len); + } + else + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + if (tag_class == ANSI_TAG_CLASS_CONS) + len = get_tlv("4.8",end_ptr->components,&asn_buf); + else + len = get_tlv("4.12",end_ptr->components,&asn_buf); + if (((len == -1) || (len > TCAP_CMP_LEN)) && (tag_class == ANSI_TAG_CLASS_CONS)) // has components portion + { + if (len == -1) + tcap_send_error("TSL decode error. Lacks component portion"); + else + tcap_send_error("TSL decode error. Component portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + if (len != -1 && len <= TCAP_CMP_LEN) + end_ptr->components_len = len; + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X, component portion len: %02X\r\n", + end_ptr->transaction_id, end_ptr->dialogue_len, end_ptr->components_len); + tcap_send_info(temp_buf); + return 1; + } + + len = GetAnyTLV("5",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is continue/conversation with permission + if (len == -1) + len = GetAnyTLV("6",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is conversation without permission + if (len != -1) // message_type is continue/conversation + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 5) + { + dst_ptr->message_type = Conversation_WithPerm_Ansi; + tcap_send_info("Conversation_WithPerm_Ansi received from sccp"); + } + else + { + dst_ptr->message_type = Conversation_WithoutPerm_Ansi; + tcap_send_info("Conversation_WithoutPerm_Ansi received from sccp"); + } + } + else + { + dst_ptr->message_type = Continue; + tcap_send_info("Continue received from sccp"); + } + dst_ptr->message_flag = INDICATE; + con_ptr = (TRContinue_struct *) &dst_ptr->tsl_prim.tr_continue; + con_ptr->dialogue_len = con_ptr->components_len = 0; + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 5) + len = get_tlv("5.7",temp_buf,&asn_buf); // get tid + else + len = get_tlv("6.7",temp_buf,&asn_buf); + if (len != 8) + { + tcap_send_error("TSL decode error. Lacks transaction id"); + con_ptr->ltid_flag = 0; + con_ptr->ptid_flag = 0; + *err_code = DERR_OTHER; + return 0; + } + dst_ptr->peer_tid_len = len; /* added by Pierre , 2006-08-19 */ + + con_ptr->peer_tid = bcdtou32(temp_buf,4); + con_ptr->ptid_flag = 1; + con_ptr->local_tid = bcdtou32(temp_buf + 4,4); + con_ptr->ltid_flag = 1; + } + else + { + len = get_tlv("5.8",temp_buf,&asn_buf); // get otid + if ((len == -1) || (len > 4) || (len == 0)) + { + tcap_send_error("TSL decode error. Lacks originating transaction id"); + con_ptr->ptid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + dst_ptr->peer_tid_len = len; /* added by Pierre, 2006-08-19 */ + con_ptr->peer_tid = bcdtou32(temp_buf,len); + con_ptr->ptid_flag = 1; + len = get_tlv("5.9",temp_buf,&asn_buf); // get dtid + if ((len == -1) || (len > 4) || (len == 0)) + { + tcap_send_error("TSL decode error. Lacks destination transaction id"); + con_ptr->ltid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + con_ptr->local_tid = bcdtou32(temp_buf,len); + con_ptr->ltid_flag = 1; + } + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 5) + len = get_tlv("5.25",temp_buf,&asn_buf); + else + len = get_tlv("6.25",temp_buf,&asn_buf); + } + else + len = get_tlv("5.11",temp_buf,&asn_buf); + if (len != -1) // has dialogue portion + { + if (len <= TCAP_DLG_LEN) + { + con_ptr->dialogue_len = len; + memcpy(con_ptr->dialogue,temp_buf,len); + } + else + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tag_code == 5) + len = get_tlv("5.8",con_ptr->components,&asn_buf); + else + len = get_tlv("6.8",con_ptr->components,&asn_buf); + } + else + len = get_tlv("5.12",con_ptr->components,&asn_buf); + if (((len == -1) || (len > TCAP_CMP_LEN)) && (tag_class == ANSI_TAG_CLASS_CONS)) // has components portion + { + if (len == -1) + tcap_send_error("TSL decode error. Lacks component portion"); + else + tcap_send_error("TSL decode error. Component portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + if (len != -1 && len <= TCAP_CMP_LEN) + con_ptr->components_len = len; + sprintf(temp_buf, "otid: %08lX, dtid: %08lX\r\ndialogue portion len: %02X, component portion len: %02X\r\n", + con_ptr->peer_tid, con_ptr->local_tid, con_ptr->dialogue_len, con_ptr->components_len); + tcap_send_info(temp_buf); + return 1; + } + + len = GetAnyTLV("7",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is abort + if (len != -1) // message_type is abort + { + dst_ptr->message_type = U_Abort; + tcap_send_info("Abort received from sccp"); + dst_ptr->message_flag = INDICATE; + uabort_ptr = (TRUAbort_struct *) &dst_ptr->tsl_prim.tr_uabort; + uabort_ptr->dialogue_len = 0; + uabort_ptr->uabort_info_len = 0; + len = get_tlv("7.9",temp_buf,&asn_buf); // get dtid + if (len == -1 || len > 4 || len == 0) + { + tcap_send_error("TSL decode error. Lacks destination transaction id"); + uabort_ptr->tid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + temp_tid = bcdtou32(temp_buf,len); + uabort_ptr->tid_flag = 1; + uabort_ptr->transaction_id = temp_tid; + len = get_tlv("7.11",temp_buf,&asn_buf); + if (len != -1 && len <= TCAP_DLG_LEN) // has dialogue portion + { + uabort_ptr->dialogue_len = len; + memcpy(uabort_ptr->dialogue,temp_buf,len); + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X\r\n", + uabort_ptr->transaction_id, uabort_ptr->dialogue_len); + tcap_send_info(temp_buf); + return 1; + } + else if (len > TCAP_DLG_LEN) + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + len = get_tlv("7.10",temp_buf,&asn_buf); + if (len != -1) // has P_Abort_Cause + { + dst_ptr->message_type = P_Abort; + pabort_ptr = (TRPAbort_struct *) &dst_ptr->tsl_prim.tr_pabort; + pabort_ptr->tid_flag = 1; + pabort_ptr->transaction_id = temp_tid; + if (len != 1) + { + tcap_send_error("TSL decode error. P_Abort lacks abort reason"); + *err_code = DERR_OTHER; + return 0; + } + pabort_ptr->abort_reason = temp_buf[0]; + sprintf(temp_buf, "dtid: %08lX, pabort reason: %02X\r\n", + pabort_ptr->transaction_id, pabort_ptr->abort_reason); + tcap_send_info(temp_buf); + return 1; + } + } + + len = GetAnyTLV("22",TMPBUFSIZE,temp_buf,&tag_class,&tag_code,&asn_buf); // check if is ansi abort + if (len != -1) // message_type is ansi abort + { + dst_ptr->message_type = U_Abort_Ansi; + tcap_send_info("Abort_Ansi received from sccp"); + dst_ptr->message_flag = INDICATE; + uabort_ptr = (TRUAbort_struct *) &dst_ptr->tsl_prim.tr_uabort; + uabort_ptr->dialogue_len = 0; + uabort_ptr->uabort_info_len = 0; + uabort_flag = 0; + len = get_tlv("22.7",temp_buf,&asn_buf); // get dtid + if (len != 4) + { + tcap_send_error("TSL decode error. Lacks responding transaction id"); + uabort_ptr->tid_flag = 0; + *err_code = DERR_UNTID; + return 0; + } + temp_tid = bcdtou32(temp_buf,4); + uabort_ptr->tid_flag = 1; + uabort_ptr->transaction_id = temp_tid; + len = get_tlv("22.25",temp_buf,&asn_buf); + if (len != -1) // has dialogue portion + { + uabort_flag = 1; + if (len <= TCAP_DLG_LEN) + { + uabort_ptr->dialogue_len = len; + memcpy(uabort_ptr->dialogue,temp_buf,len); + } + else + { + tcap_send_error("TSL decode error. Dialogue portion is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + len = get_tlv("22.24",temp_buf,&asn_buf); + if (len >= 0) // has user abort info + { + if (len <= TCAP_UABORT_INFO_LEN) + { + uabort_ptr->uabort_info_len = len; + memcpy(uabort_ptr->uabort_info,temp_buf,len); + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X, uabort info len: %02X\r\n", + uabort_ptr->transaction_id, uabort_ptr->dialogue_len, uabort_ptr->uabort_info_len); + tcap_send_info(temp_buf); + return 1; + } + else + { + tcap_send_error("TSL decode error. Uabort info is too long"); + *err_code = DERR_OTHER; + return 0; + } + } + else if (uabort_flag) + { + *err_code = DERR_OTHER; + tcap_send_error("TSL decode error. U_Abort lacks uabort info"); + return 0; + } + len = get_tlv("22.23",temp_buf,&asn_buf); + if (len != -1) // has P_Abort_Cause + { + dst_ptr->message_type = P_Abort_Ansi; + pabort_ptr = (TRPAbort_struct *) &dst_ptr->tsl_prim.tr_pabort; + pabort_ptr->tid_flag = 1; + pabort_ptr->transaction_id = temp_tid; + if (len != 1) + { + tcap_send_error("TSL decode error. P_Abort lacks abort reason"); + *err_code = DERR_OTHER; + return 0; + } + pabort_ptr->abort_reason = temp_buf[0]; + sprintf(temp_buf, "dtid: %08lX, pabort reason: %02X\r\n", + pabort_ptr->transaction_id, pabort_ptr->abort_reason); + tcap_send_info(temp_buf); + return 1; + } + } + + tcap_send_error("TSL decode error. Can not recognize package type"); + return 0; +} + +u8 tsl_message_encode(struct SCLC_MSG *sccp_ptr,struct TSL_struct *tsl_ptr,u8 flag)// tsl encode +{ + ASN_BUF asn_buf; + u8 temp_buf[512]; + u8 tag_class; + u32 len = 0; + u32 temp_tid=0; + struct TRUni_struct *uni_ptr; + struct TRBegin_struct *begin_ptr; + struct TRContinue_struct *con_ptr; + struct TREnd_struct *end_ptr; + struct TRUAbort_struct *uabort_ptr; + struct TRPAbort_struct *pabort_ptr; + + if (flag) // resend + { + memcpy(&sccp_ptr->dst_addr,&tsl_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&sccp_ptr->src_addr,&tsl_ptr->peer_add,sizeof(SCCP_ADDR)); + } + else + { + memcpy(&sccp_ptr->dst_addr,&tsl_ptr->peer_add,sizeof(SCCP_ADDR)); + memcpy(&sccp_ptr->src_addr,&tsl_ptr->local_add,sizeof(SCCP_ADDR)); + } + asn_encode(sccp_ptr->msg,&asn_buf); + tag_class = tsl_ptr->message_type & 0xE0; + switch (tsl_ptr->message_type) + { + case Unidirectional: + case Unidirectional_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + sccp_ptr->msglen = add_tlv("1",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Unidirectional_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("1",0,temp_buf,0x60,&asn_buf); + tcap_send_info("Unidirectional sent to sccp"); + } + uni_ptr = (TRUni_struct *) &tsl_ptr->tsl_prim.tr_uni; + if (tag_class == ANSI_TAG_CLASS_CONS) // Transaction ID + sccp_ptr->msglen = add_tlv("1.7-1",0,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + if (uni_ptr->dialogue_len != 0) // dialogue portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("1.25-2",uni_ptr->dialogue_len,uni_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("1.11",uni_ptr->dialogue_len,uni_ptr->dialogue,0x60,&asn_buf); + } + if (uni_ptr->components_len != 0) // component portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("1.8-3",uni_ptr->components_len,uni_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("1.12",uni_ptr->components_len,uni_ptr->components,0x60,&asn_buf); + } + sprintf(temp_buf, "dialogue portion len: %02X, component portion len: %02X\r\n", uni_ptr->dialogue_len, uni_ptr->components_len); + tcap_send_info(temp_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][0] ++; + break; + case Begin: + case Query_WithPerm_Ansi: + case Query_WithoutPerm_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Query_WithPerm_Ansi) + { + sccp_ptr->msglen = add_tlv("2",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Query_WithPerm_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("3",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Query_WithoutPerm_Ansi sent to sccp"); + } + } + else + { + sccp_ptr->msglen = add_tlv("2",0,temp_buf,0x60,&asn_buf); + tcap_send_info("Begin sent to sccp"); + } + begin_ptr = (TRBegin_struct *) &tsl_ptr->tsl_prim.tr_begin; + temp_tid = (tcap_ptr->tcap_debug.local_ip & 0xffff0000) + begin_ptr->transaction_id; + len = u32tobcd(temp_buf,temp_tid); //encode orig TID + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Query_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("2.7-1",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("3.7-1",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + } + else + sccp_ptr->msglen = add_tlv("2.8",len,temp_buf,0x40,&asn_buf); + if (begin_ptr->dialogue_len != 0) // dialogue portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Query_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("2.25-2",begin_ptr->dialogue_len,begin_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("3.25-2",begin_ptr->dialogue_len,begin_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + } + else + sccp_ptr->msglen = add_tlv("2.11",begin_ptr->dialogue_len,begin_ptr->dialogue,0x60,&asn_buf); + } + if (begin_ptr->components_len != 0) // component portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Query_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("2.8-3",begin_ptr->components_len,begin_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("3.8-3",begin_ptr->components_len,begin_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + } + else + sccp_ptr->msglen = add_tlv("2.12",begin_ptr->components_len,begin_ptr->components,0x60,&asn_buf); + } + sprintf(temp_buf, "otid: %08lX, dialogue portion len: %02X, component portion len: %02X\r\n", begin_ptr->transaction_id, begin_ptr->dialogue_len, begin_ptr->components_len); + tcap_send_info(temp_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][1] ++; + break; + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Conversation_WithPerm_Ansi) + { + sccp_ptr->msglen = add_tlv("5",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Conversation_WithPerm_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("6",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Conversation_WithoutPerm_Ansi sent to sccp"); + } + } + else + { + sccp_ptr->msglen = add_tlv("5",0,temp_buf,0x60,&asn_buf); + tcap_send_info("Continue sent to sccp"); + } + con_ptr = (TRContinue_struct *) &tsl_ptr->tsl_prim.tr_continue; + if (flag) //resend + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + u32tobcd(temp_buf,con_ptr->peer_tid); + temp_tid = con_ptr->local_tid | 0x8000; + u32tobcd(temp_buf + 4,temp_tid); + if (tsl_ptr->message_type == Conversation_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("5.7-1",8,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("6.7-1",8,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + } + else + { + len = u32tobcd(temp_buf,con_ptr->peer_tid); + len = tsl_ptr->peer_tid_len%5; /* added by Pierre, 2006-08-19 */ + sccp_ptr->msglen = add_tlv("5.8",len,&temp_buf[4-len],0x40,&asn_buf); + temp_tid = con_ptr->local_tid ;//| 0x8000; + len = u32tobcd(temp_buf,temp_tid); + if(len == 0) len = 4; + sccp_ptr->msglen = add_tlv("5.9",len,temp_buf,0x40,&asn_buf); + } + } + else + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + temp_tid = (tcap_ptr->tcap_debug.local_ip & 0xffff0000) + con_ptr->local_tid; + u32tobcd(temp_buf,temp_tid); + u32tobcd(temp_buf + 4,con_ptr->peer_tid); + if (tsl_ptr->message_type == Conversation_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("5.7-1",8,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("6.7-1",8,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + } + else + { + temp_tid = (tcap_ptr->tcap_debug.local_ip & 0xffff0000) + con_ptr->local_tid; + len = u32tobcd(temp_buf,temp_tid); //encode orig TID + sccp_ptr->msglen = add_tlv("5.8",len,temp_buf,0x40,&asn_buf); + len = u32tobcd(temp_buf,con_ptr->peer_tid); // encode dst TID + len = tsl_ptr->peer_tid_len%5; /* added by Pierre, 2006-08-19 */ + if(len == 0) len = 4; + sccp_ptr->msglen = add_tlv("5.9",len,&temp_buf[4-len],0x40,&asn_buf); + } + } + if (con_ptr->dialogue_len != 0) // dialogue portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Conversation_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("5.25-2",con_ptr->dialogue_len,con_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("6.25-2",con_ptr->dialogue_len,con_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + } + else + sccp_ptr->msglen = add_tlv("5.11",con_ptr->dialogue_len,con_ptr->dialogue,0x60,&asn_buf); + } + if (con_ptr->components_len != 0) // component portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + { + if (tsl_ptr->message_type == Conversation_WithPerm_Ansi) + sccp_ptr->msglen = add_tlv("5.8-3",con_ptr->components_len,con_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("6.8-3",con_ptr->components_len,con_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + } + else + sccp_ptr->msglen = add_tlv("5.12",con_ptr->components_len,con_ptr->components,0x60,&asn_buf); + } + sprintf(temp_buf, "otid: %08lX, dtid: %08lX\r\ndialogue portion len: %02X, component portion len: %02X\r\n", con_ptr->local_tid, con_ptr->peer_tid, con_ptr->dialogue_len, con_ptr->components_len); + tcap_send_info(temp_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][2] ++; + break; + case End: + case Response_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + sccp_ptr->msglen = add_tlv("4",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("Response_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("4",0,temp_buf,0x60,&asn_buf); + tcap_send_info("End sent to sccp"); + } + end_ptr = (TREnd_struct *) &tsl_ptr->tsl_prim.tr_end; +// if (flag) +// temp_tid = end_ptr->transaction_id | 0x8000; +// else + temp_tid = end_ptr->transaction_id; + len = u32tobcd(temp_buf,temp_tid); //encode dst TID + + if(!flag) + len = tsl_ptr->peer_tid_len%5; /* added by Pierre, 2006-08-19 */ + if(len == 0) len = 4; + + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("4.7-1",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("4.9",len,&temp_buf[4-len],0x40,&asn_buf); + if (end_ptr->dialogue_len != 0) // dialogue portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("4.25-2",end_ptr->dialogue_len,end_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("4.11",end_ptr->dialogue_len,end_ptr->dialogue,0x60,&asn_buf); + } + if (end_ptr->components_len != 0) // component portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("4.8-3",end_ptr->components_len,end_ptr->components,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("4.12",end_ptr->components_len,end_ptr->components,0x60,&asn_buf); + } + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X, component portion len: %02X\r\n", end_ptr->transaction_id, end_ptr->dialogue_len, end_ptr->components_len); + tcap_send_info(temp_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][3] ++; + break; + case P_Abort: + case P_Abort_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + sccp_ptr->msglen = add_tlv("22",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("P_Abort_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("7",0,temp_buf,0x60,&asn_buf); + tcap_send_info("P_Abort sent to sccp"); + } + pabort_ptr = (TRPAbort_struct *) &tsl_ptr->tsl_prim.tr_pabort; +// if (flag) +// temp_tid = pabort_ptr->transaction_id | 0x8000; +// else + temp_tid = pabort_ptr->transaction_id; + len = u32tobcd(temp_buf,temp_tid); //encode dst TID + + if(!flag) + len = tsl_ptr->peer_tid_len%5; /* added by Pierre, 2006-08-19 */ + if(len == 0) len = 4; + + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("22.7-1",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("7.9",len,temp_buf,0x40,&asn_buf); + temp_buf[0] = pabort_ptr->abort_reason; + len = 1; + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("22.23-2",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("7.10",len,temp_buf,0x40,&asn_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][4] ++; + switch (pabort_ptr->abort_reason) + { + case P_Abort_UMT: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][48] ++; + break; + case P_Abort_ITP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][49] ++; + break; + case P_Abort_BFTP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][50] ++; + break; + case P_Abort_UTID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][51] ++; + break; + case P_Abort_RL: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][52] ++; + break; + default: + break; + } + sprintf(temp_buf, "dtid: %08lX, pabort reason: %02X\r\n", pabort_ptr->transaction_id, pabort_ptr->abort_reason); + tcap_send_info(temp_buf); + break; + case U_Abort: + case U_Abort_Ansi: + if (tag_class == ANSI_TAG_CLASS_CONS) + { + sccp_ptr->msglen = add_tlv("22",0,temp_buf,ANSI_TAG_CLASS_CONS,&asn_buf); + tcap_send_info("mU_Abort_Ansi sent to sccp"); + } + else + { + sccp_ptr->msglen = add_tlv("7",0,temp_buf,0x60,&asn_buf); + tcap_send_info("U_Abort sent to sccp"); + } + uabort_ptr = (TRUAbort_struct *) &tsl_ptr->tsl_prim.tr_uabort; +// if (flag) +// temp_tid = uabort_ptr->transaction_id | 0x8000; +// else + temp_tid = uabort_ptr->transaction_id; + len = u32tobcd(temp_buf,temp_tid); //encode dst TID + if(!flag) + len = tsl_ptr->peer_tid_len%5; /* added by Pierre, 2006-08-19 */ + if(len == 0) len = 4; + + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("22.7-1",len,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + sccp_ptr->msglen = add_tlv("7.9",len,temp_buf,0x40,&asn_buf); + if (uabort_ptr->dialogue_len != 0) // dialogue portion + { + if (tag_class == ANSI_TAG_CLASS_CONS) + sccp_ptr->msglen = add_tlv("22.25-2",uabort_ptr->dialogue_len,uabort_ptr->dialogue,ANSI_TAG_CLASS_CONS,&asn_buf); + else + sccp_ptr->msglen = add_tlv("7.11",uabort_ptr->dialogue_len,uabort_ptr->dialogue,0x60,&asn_buf); + } + if (tag_class == ANSI_TAG_CLASS_CONS) + { + sccp_ptr->msglen = add_tlv("22.24-3",uabort_ptr->uabort_info_len,uabort_ptr->uabort_info,ANSI_TAG_CLASS_PRIM,&asn_buf); + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X, uabort info len: %02X\r\n", uabort_ptr->transaction_id, uabort_ptr->dialogue_len, uabort_ptr->uabort_info_len); + } + else + sprintf(temp_buf, "dtid: %08lX, dialogue portion len: %02X\r\n", uabort_ptr->transaction_id, uabort_ptr->dialogue_len); + tcap_send_info(temp_buf); + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][4] ++; + break; + default: //unknown message type + tcap_send_error("TSL encode error. Can not recognize package type"); + return 0; + break; + } + return 1; +} + +int extract_acn(u8 *acn,u8 *data,int data_len) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[TCAP_BUF_LEN]; + + len = asn_decode(data,1,&asn_buf); + if (len != data_len) // data length is wrong + { + tcap_send_error("CSL dialogue decode error. ACN structure is error"); + return 0; + } + len = get_tlv("6",temp_buf,&asn_buf); // get Object_Identifier + if (len == -1 || len > TCAP_ACN_LEN) + { + tcap_send_error("CSL dialogue decode error. dialogue portion lack ACN"); + return 0; + } + memcpy(acn,temp_buf,len); + return len; +} + +u8 extract_result(u8 *result,u8 *data,int data_len) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[TCAP_BUF_LEN]; + + len = asn_decode(data,1,&asn_buf); + if (len != data_len) + { + tcap_send_error("CSL dialogue decode error. Result structure is error"); + return 0; + } + len = get_tlv("2",temp_buf,&asn_buf); // get Integer + if (len != 1) + { + tcap_send_error("CSL dialogue decode error. Result structure is error"); + return 0; + } + *result = temp_buf[0]; + return 1; +} + +u8 extract_diag(u8 *result,u8 *data,int data_len) // extract diagnostic +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[TCAP_BUF_LEN]; + u8 result_type; + + len = asn_decode(data,1,&asn_buf); + if (len != data_len) + { + tcap_send_error("CSL dialogue decode error. ASN.1 structure is error"); + return 0; + } + len = get_tlv("1",temp_buf,&asn_buf); // check dialogue service user + if (len != -1) + { + result_type = Dialogue_Service_User; + len = get_tlv("1.2",temp_buf,&asn_buf); + if (len == 0) + *result = 0; + else + *result = temp_buf[0]; + return result_type; + } + len = get_tlv("2",temp_buf,&asn_buf); // check dialogue service provider + if (len != -1) + { + result_type = Dialogue_Service_Provider; + len = get_tlv("2.2",temp_buf,&asn_buf); + if (len == 0) + *result = 0; + else + *result = temp_buf[0]; + return result_type; + } + tcap_send_error("CSL dialogue decode error. Can not recognize diagnostic service type"); + return 0; +} + +u8 extract_dp(struct dlgPDU_struct *pdu_ptr,u8 *databuf,int datalen,u8 proto_type) // extract dialogue portion +{ + ASN_BUF asn_buf; + int len; + int result; + u8 id_value_flag = 0; + struct AARQ_struct *aarq_ptr; + struct AARE_struct *aare_ptr; + struct ABRT_struct *abrt_ptr; + struct ASUDT_struct *asudt_ptr; + u8 asn_data[TCAP_BUF_LEN]; + u8 temp_data[TCAP_BUF_LEN]; + + memset(pdu_ptr,0,sizeof(dlgPDU_struct)); + if (!proto_type) + len = asn_decode(databuf,1,&asn_buf); + else + len = asn_decode(databuf,5,&asn_buf); + if (len == -1) // asn1 decode error + { + tcap_send_error("CSL dialogue decode error. ASN.1 structure has error"); + return 0; + } + + if (proto_type) + { + result = 0; + asudt_ptr = (ASUDT_struct *) &pdu_ptr->pdu_union.asudt; + len = get_tlv("26",temp_data,&asn_buf); // get protocol version + if (len == 1) + { + asudt_ptr->version = temp_data[0]; + result = 1; + } + len = get_tlv("28",temp_data,&asn_buf); // get object identifier ACN + if (len != -1) + asudt_ptr->acn_type = TYPE_OID; + else + { + len = get_tlv("27",temp_data,&asn_buf); // get integer ACN + if (len != -1) + asudt_ptr->acn_type = TYPE_INT; + } + if (len > 0) + { + asudt_ptr->acn_len = len; + memcpy(asudt_ptr->acn,temp_data,len); + result = 1; + } + len = get_tlv("29",temp_data,&asn_buf); // get user information + if (len != -1) + { + asudt_ptr->user_info_len = len; + memcpy(asudt_ptr->user_info,temp_data,len); + result = 1; + } + len = get_tlv("1",temp_data,&asn_buf); // get object id security context + if (len != -1) + asudt_ptr->security_context_type = TYPE_OID; + else + { + len = get_tlv("0",temp_data,&asn_buf); // get integer security context + if (len != -1) + asudt_ptr->security_context_type = TYPE_INT; + } + if (len != -1) + { + asudt_ptr->security_context_len = len; + memcpy(asudt_ptr->security_context,temp_data,len); + result = 1; + } + len = get_tlv("2",temp_data,&asn_buf); // get confidentiality information + if (len != -1) + { + asudt_ptr->confidential_info_len = len; + memcpy(asudt_ptr->confidential_info,temp_data,len); + result = 1; + } + if (result) + { + pdu_ptr->dialogue_type = PDU_ASUDT; + return 1; + } + else + return 0; + } + else + { + len = get_tlv("8",temp_data,&asn_buf); // get External + if (len == -1) + { + tcap_send_error("CSL dialogue decode error. Lack External structure"); + return 0; + } + len = get_tlv("8.6",temp_data,&asn_buf); // get Object_Identifier + if (len == -1) // dialogue-as-ID portion + { + tcap_send_error("CSL dialogue decode error. Lack Object identifier"); + return 0; + } + if (memcmp(Undialogue_As_ID,temp_data,len) == 0) // undialogue as id value + id_value_flag = 2; + else if (memcmp(Dialogue_As_ID,temp_data,len) == 0) // dialogue as id value + id_value_flag = 1; + else // unknwn data + { + tcap_send_error("CSL dialogue decode error. Dialogue-as-ID value error"); + return 0; + } + len = get_tlv("8.0",asn_data,&asn_buf); // get Single ASN.1 type + if (len == -1) + { + tcap_send_error("CSL dialogue decode error. Lack single ASN.1 structure"); + return 0; + } + len = asn_decode(asn_data,1,&asn_buf); + if (len == -1) + { + tcap_send_error("CSL dialogue decode error. ASN.1 structure is error"); + return 0; + } + len = get_tlv("0",temp_data,&asn_buf); // get AARQ dialogue + if (len != -1) // has AARQ + { + pdu_ptr->dialogue_type = PDU_AARQ; + aarq_ptr = (AARQ_struct *) &pdu_ptr->pdu_union.aarq; + memcpy(aarq_ptr->version,Version_1,2); + len = get_tlv("0.0",temp_data,&asn_buf); // get protocol version + if (len != 2) // lack protocol version or version is error + { + temp_data[0] = 0x07; + temp_data[1] = 0x80; + tcap_send_error("CSL dialogue decode error. AARQ lack protocol version"); + //return 0; + } + memcpy(aarq_ptr->version,temp_data,2); + len = get_tlv("0.1",temp_data,&asn_buf); // get ACN + if (len == -1 || len > TCAP_ACN_LEN) + { + tcap_send_error("CSL dialogue decode error. AARQ lack ACN"); + return 0; + } + aarq_ptr->acn_len = extract_acn(aarq_ptr->acn,temp_data,len); + len = get_tlv("0.30",temp_data,&asn_buf); // get user info + if (len != -1 && len <= TCAP_USERINFO_LEN) // has user information + { + aarq_ptr->user_info_len = len; + memcpy(aarq_ptr->user_info,temp_data,len); + } + return 1; + } + len = get_tlv("1",temp_data,&asn_buf); // get AARE dialogue + if (len != -1) // has AARE + { + pdu_ptr->dialogue_type = PDU_AARE; + aare_ptr = (AARE_struct *) &pdu_ptr->pdu_union.aare; + memcpy(aare_ptr->version,Version_1,2); + len = get_tlv("1.0",temp_data,&asn_buf); // get protocol version + if (len != 2) // lack protocol version or version is error + { + temp_data[0] = 0x07; + temp_data[1] = 0x80; + tcap_send_error("CSL dialogue decode error. AARE lack protocol version"); + //return 0; + } + memcpy(aare_ptr->version,temp_data,2); + len = get_tlv("1.1",temp_data,&asn_buf); // get ACN + if (len == -1) + { + tcap_send_error("CSL dialogue decode error. AARE lack ACN"); + return 0; + } + aare_ptr->acn_len = extract_acn(aare_ptr->acn,temp_data,len); + len = get_tlv("1.2",temp_data,&asn_buf); // get result + if (len == -1) // has no result + { + tcap_send_error("CSL dialogue decode error. AARE lack result"); + return 0; + } + if (!extract_result(&aare_ptr->result,temp_data,len)) + return 0; + len = get_tlv("1.3",temp_data,&asn_buf); // get source diagnostic + if (len == -1) + { + tcap_send_error("CSL dialogue decode error. AARE lack source diagnostic"); + return 0; + } + result = extract_diag(&aare_ptr->diagnostic_type,temp_data,len); + if (result == 0) + return 0; + else + aare_ptr->diagnostic_flag = result; + len = get_tlv("1.30",temp_data,&asn_buf); // get user info + if (len != -1 && len <= TCAP_USERINFO_LEN) // has user information + { + aare_ptr->user_info_len = len; + memcpy(aare_ptr->user_info,temp_data,len); + } + return 1; + } + len = get_tlv("4",temp_data,&asn_buf); // get ABRT dialogue + if (len != -1) // has ABRT + { + pdu_ptr->dialogue_type = PDU_ABRT; + abrt_ptr = (ABRT_struct *) &pdu_ptr->pdu_union.abrt; + len = get_tlv("4.0",temp_data,&asn_buf); // get reason + if (len != 1) // lack reason + { + tcap_send_error("CSL dialogue decode error. ABRT lack reason"); + return 0; + } + abrt_ptr->abort_source = temp_data[0]; + len = get_tlv("4.30",temp_data,&asn_buf); // get user info + if (len != -1 && len <= TCAP_USERINFO_LEN) // has user information + { + abrt_ptr->user_info_len = len; + memcpy(abrt_ptr->user_info,temp_data,len); + } + return 1; + } + tcap_send_error("CSL dialogue decode error. Can not recognize dialogue type"); + return 0; + } +} + +u8 build_dp(u8 *content,struct dlgPDU_struct *dlg_ptr,u8 un_flag,u8 proto_type) // build dialogue portion +{ + ASN_BUF asn_buf; + u8 temp_data[TCAP_BUF_LEN]; + u32 len = 0,len1 = 0; + struct AARQ_struct *aarq_ptr; + struct AARE_struct *aare_ptr; + struct ABRT_struct *abrt_ptr; + struct ASUDT_struct *asudt_ptr; + + if (proto_type) + asn_encode(content,&asn_buf); + else + asn_encode(temp_data,&asn_buf); + switch (dlg_ptr->dialogue_type) // encode the content of dialogue portion + { + case PDU_AARQ: + aarq_ptr = (AARQ_struct *) &dlg_ptr->pdu_union.aarq; + len1 = add_tlv("0",0,temp_data,0x60,&asn_buf); + len1 = add_tlv("0.0",2,aarq_ptr->version,0x80,&asn_buf); + if (aarq_ptr->acn_len != 0) + { + len1 = add_tlv("0.1",0,aarq_ptr->acn,0x0a0,&asn_buf); + len1 = add_tlv("0.1.6",aarq_ptr->acn_len,aarq_ptr->acn,0x00,&asn_buf); + } + if (aarq_ptr->user_info_len != 0) + len1 = add_tlv("0.30",aarq_ptr->user_info_len,aarq_ptr->user_info,0x0a0,&asn_buf); + break; + case PDU_AARE: + aare_ptr = (AARE_struct *) &dlg_ptr->pdu_union.aare; + len1 = add_tlv("1",0,temp_data,0x60,&asn_buf); + len1 = add_tlv("1.0",2,aare_ptr->version,0x80,&asn_buf); + if (aare_ptr->acn_len != 0) // encode acn portion + { + len1 = add_tlv("1.1",0,aare_ptr->acn,0x0a0,&asn_buf); + len1 = add_tlv("1.1.6",aare_ptr->acn_len,aare_ptr->acn,0x00,&asn_buf); + } + len1 = add_tlv("1.2",0,&aare_ptr->result,0x0a0,&asn_buf);// encode result + len1 = add_tlv("1.2.2",1,&aare_ptr->result,0x00,&asn_buf); + len1 = add_tlv("1.3",0,&aare_ptr->diagnostic_flag,0x0a0,&asn_buf); // encode diagnostic + if (aare_ptr->diagnostic_flag == Dialogue_Service_Provider) + { + len1 = add_tlv("1.3.2",0,&aare_ptr->diagnostic_flag,0x0a0,&asn_buf); + len1 = add_tlv("1.3.2.2",1,&aare_ptr->diagnostic_type,0x00,&asn_buf); + } + else + { + len1 = add_tlv("1.3.1",0,&aare_ptr->diagnostic_flag,0x0a0,&asn_buf); + len1 = add_tlv("1.3.1.2",1,&aare_ptr->diagnostic_type,0x00,&asn_buf); + } + if (aare_ptr->user_info_len != 0) + len1 = add_tlv("1.30",aare_ptr->user_info_len,aare_ptr->user_info,0x0a0,&asn_buf); + break; + case PDU_ABRT: + abrt_ptr = (ABRT_struct *) &dlg_ptr->pdu_union.abrt; + len1 = add_tlv("4",0,temp_data,0x60,&asn_buf); + len1 = add_tlv("4.0",1,&abrt_ptr->abort_source,0x80,&asn_buf); + if (abrt_ptr->user_info_len != 0) + len1 = add_tlv("4.30",abrt_ptr->user_info_len,abrt_ptr->user_info,0x0a0,&asn_buf); + break; + case PDU_ASUDT: + asudt_ptr = (ASUDT_struct *) &dlg_ptr->pdu_union.asudt; + len1 = add_tlv("26-1",1,&asudt_ptr->version,ANSI_TAG_CLASS_PRIM,&asn_buf); + if (asudt_ptr->acn_len > 0) + { + if (asudt_ptr->acn_type == TYPE_OID) // object id acn + len1 = add_tlv("28-2",asudt_ptr->acn_len,asudt_ptr->acn,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + len1 = add_tlv("27-2",asudt_ptr->acn_len,asudt_ptr->acn,ANSI_TAG_CLASS_PRIM,&asn_buf); + } + if (asudt_ptr->user_info_len > 0) + len1 = add_tlv("29-3",asudt_ptr->user_info_len,asudt_ptr->user_info,ANSI_TAG_CLASS_PRIM,&asn_buf); + if (asudt_ptr->security_context_len > 0) + { + if (asudt_ptr->security_context_type == TYPE_OID) // object id security context + len1 = add_tlv("1-4",asudt_ptr->security_context_len,asudt_ptr->security_context,0x80,&asn_buf); + else + len1 = add_tlv("0-4",asudt_ptr->security_context_len,asudt_ptr->security_context,0x80,&asn_buf); + } + if (asudt_ptr->confidential_info_len > 0) + len1 = add_tlv("2-5",asudt_ptr->confidential_info_len,asudt_ptr->confidential_info,0xA0,&asn_buf); + return len1; + break; + default: + tcap_send_error("CSL dialogue encode error. Can not recognize dialogue type"); + return 0; + break; + } + asn_encode(content,&asn_buf); + len = add_tlv("8",0,temp_data,0x20,&asn_buf); + if (un_flag == 1) // unidirectional dialogue + len = add_tlv("8.6-1",7,Undialogue_As_ID,0x00,&asn_buf); + else + len = add_tlv("8.6-1",7,Dialogue_As_ID,0x00,&asn_buf); + len = add_tlv("8.0-2",len1,temp_data,0x0a0,&asn_buf); + return len; +} + +int extract_component(struct CSLcmp_struct *cmp_ptr,u8 *data_buf,u32 proc,int *section_len) // extract component portion +{ + ASN_BUF asn_buf; + int len,len1=0,len2=0; + u8 temp_buf[TCAP_BUF_LEN],temp_buf1[TCAP_BUF_LEN]; + u8 tag1; + char tlv1[32]; + struct TCInvoke_struct *invoke_ptr; + struct TCResult_struct *result_ptr; + struct TCUError_struct *uerror_ptr; + struct TCReject_struct *reject_ptr; + int result; + u8 tag_class; + u16 tag_code; + + cmp_ptr->dialogue_id = proc; + cmp_ptr->invoke_id = 0xff; + cmp_ptr->message_flag = INDICATE; + result = asn_decode_v2(data_buf,1,section_len,&asn_buf); + if (*section_len == -1) + { + tcap_send_error("CSL component decode length error. ASN.1 structure is error"); + return 0; // 0 indicate that the syntax is error + } + if (result == -1) + tcap_send_error("CSL component decode error. ASN.1 structure is error"); + + len1 = GetAnyTLV("1",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get invoke + if (len1 == -1) + { + len1 = GetAnyTLV("9",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Invoke_L_Ansi + if (len1 == -1) + len1 = GetAnyTLV("13",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Invoke_NL_Ansi + } + if (len1 != -1) // has invoke + { + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][15] ++; + if (tag_code == 1) + cmp_ptr->message_type = Invoke; + else if (tag_code == 9) + cmp_ptr->message_type = Invoke_L_Ansi; + else + cmp_ptr->message_type = Invoke_NL_Ansi; + invoke_ptr = (TCInvoke_struct *) &cmp_ptr->cmp_prim.tc_invoke; + if (tag_class != ANSI_TAG_CLASS_CONS) + { + len = get_tlv("1.2-1",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Invoke primitive lack invoke id"); + return 0; + } + len2 += 3; + cmp_ptr->invoke_id = temp_buf[0]; + tag1 = 2; + len = get_tlv("1.0",temp_buf,&asn_buf); // get linked id + if (len != -1) + { + if (len != 1) + { + tcap_send_error("CSL component decode error. Invoke primitive has error linked id"); + return 0; + } + invoke_ptr->linkedid_flag = 1; + invoke_ptr->linked_id = temp_buf[0]; + tag1 ++; + len2 += 3; + } + sprintf(tlv1,"1.2-%d\n",tag1); + len = get_tlv(tlv1,temp_buf,&asn_buf); // get operation code + if (len != 1) // has no operation code + { + len = get_tlv("1.6",temp_buf,&asn_buf); + if (len != 1) + { + tcap_send_error("CSL component decode error. Invoke primitive lack operation code"); + return 0; + } + } + invoke_ptr->operation_code = temp_buf[0]; + len2 += 3; + } + else + { + if (tag_code == 9) + len = get_tlv("9.15",temp_buf,&asn_buf); // get invoke id + else + len = get_tlv("13.15",temp_buf,&asn_buf); + if (len == -1) // has no invoke id + { // Mandatory when Correlation ID present or if reply expected + tcap_send_error("CSL component decode error. Ansi Invoke primitive lack invoke id"); + return 0; + } + else + { + len2 += 3; + cmp_ptr->invoke_id = temp_buf[0]; + if (len == 2) + { + invoke_ptr->linkedid_flag = 1; + invoke_ptr->linked_id = temp_buf[1]; + len2++; + } + } + if (tag_code == 9) + { + len = get_tlv("9.17",temp_buf,&asn_buf); // get private operation code + if (len != -1) + invoke_ptr->operation_domain = TYPE_PRIVATE; + else + { + len = get_tlv("9.16",temp_buf,&asn_buf); // get national operation code + if (len != -1) + invoke_ptr->operation_domain = TYPE_NATIONAL; + } + } + else + { + len = get_tlv("13.17",temp_buf,&asn_buf); // get private operation code + if (len != -1) + invoke_ptr->operation_domain = TYPE_PRIVATE; + else + { + len = get_tlv("13.16",temp_buf,&asn_buf); // get national operation code + if (len != -1) + invoke_ptr->operation_domain = TYPE_NATIONAL; + } + } + if (len == -1) + { + tcap_send_error("CSL component decode error. Ansi Invoke primitive lack operation code"); + return 0; + } + invoke_ptr->operation_family = temp_buf[0]; + invoke_ptr->operation_code = temp_buf[1]; + len2 += 4; + } + if (len1 > len2) + { + invoke_ptr->parameter_len = len1 - len2; + memcpy(invoke_ptr->parameter,temp_buf1+len2,len1-len2); + } + else + invoke_ptr->parameter_len = 0; + return 1; + } + + len = GetAnyTLV("2",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get return result + if (len == -1) + { + len = GetAnyTLV("7",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get return result not last + if (len == -1) + { + len = GetAnyTLV("10",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Result_L_Ansi + if (len == -1) + len = GetAnyTLV("14",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Result_NL_Ansi + } + } + if (len != -1) // has return result + { + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][16] ++; + if (tag_code == 2) + cmp_ptr->message_type = Result_L; + else if (tag_code == 7) + cmp_ptr->message_type = Result_NL; + else if (tag_code == 10) + cmp_ptr->message_type = Result_L_Ansi; + else + cmp_ptr->message_type = Result_NL_Ansi; + result_ptr = (TCResult_struct *) &cmp_ptr->cmp_prim.tc_result; + if (tag_class != ANSI_TAG_CLASS_CONS) + { + len = get_tlv("2.2",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Result last primitive lack invoke id"); + return 0; + } + cmp_ptr->invoke_id = temp_buf[0]; + len1 = get_tlv("2.16",temp_buf,&asn_buf); // get SEQUENCE + if (len1 != -1) + { + len = get_tlv("2.16.2",temp_buf,&asn_buf); // operation code, just one byte + if (len != 1) + { + len = get_tlv("2.16.6",temp_buf,&asn_buf); + if (len != 1) + { + tcap_send_error("CSL component decode error. Result primitive lack operation code"); + return 0; + } + } + result_ptr->operation_flag = 1; + result_ptr->operation_code = temp_buf[0]; + if (len1 <= 3) + { + result_ptr->parameter_len = 0; + tcap_send_error("CSL component decode error. Result primitive lack parameter"); + return 0; + } + len = len1 - 3; + result_ptr->parameter_len = len; + memcpy(result_ptr->parameter,temp_buf+3,len); + } + return 1; + } + else + { + if (tag_code == 10) + len1 = get_tlv("10.15",temp_buf,&asn_buf); // get invoke id + else + len1 = get_tlv("14.15",temp_buf,&asn_buf); + if (len1 != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Ansi return result primitive lack invoke id"); + return 0; + } + else + { + cmp_ptr->invoke_id = temp_buf[0]; + len2 += 3; + } + if (len > len2) + { + result_ptr->parameter_len = len - len2; + memcpy(result_ptr->parameter,temp_buf1+len2,len-len2); + } + return 1; + } + } + + len1 = GetAnyTLV("3",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get return error + if (len1 == -1) + len1 = GetAnyTLV("11",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Error_Ansi + if (len1 != -1) // has return error + { + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][17] ++; + if (tag_code == 3) + cmp_ptr->message_type = Error; + else + cmp_ptr->message_type = Error_Ansi; + uerror_ptr = (TCUError_struct *) &cmp_ptr->cmp_prim.tc_uerror; + if (tag_class != ANSI_TAG_CLASS_CONS) + { + len = get_tlv("3.2-1",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Error primitive lack invoke id"); + return 0; + } + cmp_ptr->invoke_id = temp_buf[0]; + len2 = 3; + len = get_tlv("3.2-2",temp_buf,&asn_buf); // get error code + if (len == 1) // success + uerror_ptr->error_type = Local_Error_Code; + else + { + len = get_tlv("3.6",temp_buf,&asn_buf); + if (len != 1) + { + tcap_send_error("CSL component decode error. Error primitive lack error code"); + return 0; + } + uerror_ptr->error_type = Global_Error_Code; + } + uerror_ptr->error_code = temp_buf[0]; + len2 = 3; + if (len1 > len2) + { + uerror_ptr->parameter_len = len1 - len2; + memcpy(uerror_ptr->parameter,temp_buf1+len2,len1-len2); + } + else + uerror_ptr->parameter_len = 0; + return 1; + } + else + { + len = get_tlv("11.15",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Ansi return error primitive lack invoke id"); + return 0; + } + else + { + cmp_ptr->invoke_id = temp_buf[0]; + len2 += 3; + } + len = get_tlv("11.20",temp_buf,&asn_buf); // get private error code + if (len != -1) + uerror_ptr->error_type = TYPE_PRIVATE; + else + { + len = get_tlv("11.19",temp_buf,&asn_buf); // get national error code + if (len != -1) + uerror_ptr->error_type = TYPE_NATIONAL; + } + if (len != 1) + { + tcap_send_error("CSL component decode error. Ansi Error primitive lack error code"); + return 0; + } + else + { + uerror_ptr->error_code = temp_buf[0]; + len2 += 3; + } + if (len1 > len2) + { + uerror_ptr->parameter_len = len1 - len2; + memcpy(uerror_ptr->parameter,temp_buf1+len2,len1-len2); + } + else + uerror_ptr->parameter_len = 0; + return 1; + } + } + + len1 = GetAnyTLV("4",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get reject + if (len1 == -1) + len1 = GetAnyTLV("12",TCAP_BUF_LEN,temp_buf1,&tag_class,&tag_code,&asn_buf); // get Reject_Ansi + if (len1 != -1) // has reject + { + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][18] ++; + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][74] ++; + if (tag_code == 4) + cmp_ptr->message_type = Reject; + else + cmp_ptr->message_type = Reject_Ansi; + reject_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + if (tag_class != ANSI_TAG_CLASS_CONS) + { + len = get_tlv("4.2-1",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + len = get_tlv("4.5",temp_buf,&asn_buf); // get Invoke_ID_NULL + if (len != 1) + { + tcap_send_error("CSL component decode error. Reject primitive lack invoke id"); + return 0; + } + temp_buf[0] = 0xff; + } + cmp_ptr->invoke_id = temp_buf[0]; + len = get_tlv("4.0",temp_buf,&asn_buf); // get general problem + if (len == 1) + { + reject_ptr->problem_type = General_Problem; + reject_ptr->problem_code = temp_buf[0]; + switch (temp_buf[0]) + { + case General_Problem_UC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][30] ++; + break; + case General_Problem_MC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][31] ++; + break; + case General_Problem_BSC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][32] ++; + break; + default: + break; + } + return 1; + } + len = get_tlv("4.1",temp_buf,&asn_buf); // get invoke problem + if (len == 1) + { + reject_ptr->problem_type = Invoke_Problem; + reject_ptr->problem_code = temp_buf[0]; + switch (temp_buf[0]) + { + case Invoke_Problem_ULID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][33] ++; + break; + case Invoke_Problem_DIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][38] ++; + break; + case Invoke_Problem_UO: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][39] ++; + break; + case Invoke_Problem_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][40] ++; + break; + case Invoke_Problem_IR: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][41] ++; + break; + case Invoke_Problem_LRU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][42] ++; + break; + case Invoke_Problem_ULO: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][43] ++; + break; + default: + break; + } + return 1; + } + len = get_tlv("4.2-2",temp_buf,&asn_buf); // get return result problem + if (len == 1) + { + reject_ptr->problem_type = Return_Result; + reject_ptr->problem_code = temp_buf[0]; + switch (temp_buf[0]) + { + case Return_Result_UIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][34] ++; + break; + case Return_Result_RRU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][35] ++; + break; + case Return_Result_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][46] ++; + break; + default: + break; + } + return 1; + } + len = get_tlv("4.3",temp_buf,&asn_buf); // get return error problem + if (len == 1) + { + reject_ptr->problem_type = Return_Error; + reject_ptr->problem_code = temp_buf[0]; + switch (temp_buf[0]) + { + case Return_Error_UIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][36] ++; + break; + case Return_Error_REU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][37] ++; + break; + case Return_Error_URE: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][44] ++; + break; + case Return_Error_UEE: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][45] ++; + break; + case Return_Error_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][47] ++; + break; + default: + break; + } + return 1; + } + tcap_send_error("CSL component decode error. Reject primitive lack problem type"); + return 0; + } + else + { + len = get_tlv("12.15",temp_buf,&asn_buf); // get invoke id + if (len != 1) // has no invoke id + { + tcap_send_error("CSL component decode error. Ansi Reject primitive lack invoke id"); + return 0; + } + else + { + cmp_ptr->invoke_id = temp_buf[0]; + len2 += 3; + } + len = get_tlv("12.21",temp_buf,&asn_buf); // get problem code + if (len != 2) + { + tcap_send_error("CSL component decode error. Ansi reject primitive lack problem code"); + return 0; + } + else + { + reject_ptr->problem_type = temp_buf[0]; + reject_ptr->problem_code = temp_buf[1]; + len2 += 4; + } + if (len1 > len2) + { + reject_ptr->parameter_len = len1 - len2; + memcpy(reject_ptr->parameter,temp_buf1+len2,len1-len2); + } + else + reject_ptr->parameter_len = 0; + switch (temp_buf[0]) + { + case General_Problem_Ansi: + switch (temp_buf[1]) + { + case General_Problem_UC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][30] ++; + break; + case General_Problem_MC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][31] ++; + break; + case General_Problem_BSC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][32] ++; + break; + default: + break; + } + return 1; + break; + case Invoke_Problem_Ansi: + switch (temp_buf[1]) + { + case Invoke_Problem_ULID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][33] ++; + break; + case Invoke_Problem_DIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][38] ++; + break; + case Invoke_Problem_UO_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][39] ++; + break; + case Invoke_Problem_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][40] ++; + break; + default: + break; + } + return 1; + break; + case Return_Result_Ansi: + switch (temp_buf[1]) + { + case Return_Result_UIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][34] ++; + break; + case Return_Result_RRU_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][35] ++; + break; + case Return_Result_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][46] ++; + break; + default: + break; + } + return 1; + break; + case Return_Error_Ansi: + switch (temp_buf[1]) + { + case Return_Error_UIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][36] ++; + break; + case Return_Error_REU_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][37] ++; + break; + case Return_Error_URE_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][44] ++; + break; + case Return_Error_UEE_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][45] ++; + break; + case Return_Error_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][47] ++; + break; + default: + break; + } + return 1; + break; + case Transaction_Ansi: + return 1; + break; + } + tcap_send_error("CSL component decode error. Ansi Reject primitive lack problem type"); + return 0; + } + } + + tcap_send_error("CSL component decode error. Can not recognize message type"); + return 0; +} + +u8 assemble_param(u8 *data_buf,u8 *string,u8 str_len,u8 opr_code,u8 opr_family,u8 opr_domain,u8 proto_type) +{ + ASN_BUF asn_buf; + int len = 0; + u8 temp_buf[8]; + + asn_encode(data_buf,&asn_buf); + if (!proto_type) + len = add_tlv("2",1,&opr_code,0x00,&asn_buf); + else + { + temp_buf[0] = opr_family; + temp_buf[1] = opr_code; + if (opr_domain) + len = add_tlv("17",2,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + len = add_tlv("16",2,temp_buf,ANSI_TAG_CLASS_PRIM,&asn_buf); + } + if (str_len != 0) + { + memcpy(data_buf+len,string,str_len); + len += str_len; + } + return len; +} + +int assemble_component(u8 *string,struct CSLcmp_struct *cha_ptr) // assemble component portion +{ + ASN_BUF asn_buf; + u8 temp_data[TCAP_BUF_LEN],temp_str[TCAP_BUF_LEN]; + u32 len = 0,temp_len; + struct TCInvoke_struct *invoke_ptr; + struct TCResult_struct *result_ptr; + struct TCUError_struct *uerror_ptr; + struct TCReject_struct *reject_ptr; + u8 proto_type; + + if ((cha_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + switch (cha_ptr->message_type) + { + case Invoke: + case Invoke_L_Ansi: + case Invoke_NL_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][10] ++; + invoke_ptr = (TCInvoke_struct *) &cha_ptr->cmp_prim.tc_invoke; + asn_encode(temp_data,&asn_buf); + if (!proto_type) + { + temp_len = add_tlv("2-1",1,&cha_ptr->invoke_id,0x00,&asn_buf); + if (invoke_ptr->linkedid_flag ==1) // has linked id + temp_len = add_tlv("0-2",1,&invoke_ptr->linked_id,0x80,&asn_buf); + len = assemble_param(string,invoke_ptr->parameter,invoke_ptr->parameter_len, + invoke_ptr->operation_code,invoke_ptr->operation_family,invoke_ptr->operation_domain,proto_type); + memcpy(temp_data+temp_len,string,len); + temp_len += len; + asn_encode(string,&asn_buf); + len = add_tlv("1",temp_len,temp_data,0x0a0,&asn_buf); + } + else + { + temp_len = add_tlv("15",1,&cha_ptr->invoke_id,ANSI_TAG_CLASS_PRIM,&asn_buf); + len = assemble_param(string,invoke_ptr->parameter,invoke_ptr->parameter_len, + invoke_ptr->operation_code,invoke_ptr->operation_family,invoke_ptr->operation_domain,proto_type); + memcpy(temp_data+temp_len,string,len); + temp_len += len; + asn_encode(string,&asn_buf); + if (cha_ptr->message_type == Invoke_L_Ansi) + len = add_tlv("9",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + else + len = add_tlv("13",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + } + break; + case Result_L: + case Result_NL: + case Result_L_Ansi: + case Result_NL_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][11] ++; + result_ptr = (TCResult_struct *) &cha_ptr->cmp_prim.tc_result; + asn_encode(temp_data,&asn_buf); + if (!proto_type) + { + temp_len = add_tlv("2",1,&cha_ptr->invoke_id,0x00,&asn_buf); + if (result_ptr->parameter_len > 0) + { + len = assemble_param(temp_str,result_ptr->parameter,result_ptr->parameter_len, + result_ptr->operation_code,result_ptr->operation_family,result_ptr->operation_domain,proto_type); + asn_encode(string,&asn_buf); + len = add_tlv("16",len,temp_str,0x20,&asn_buf); + } + memcpy(temp_data+temp_len,string,len); + temp_len += len; + asn_encode(string,&asn_buf); + if (cha_ptr->message_type == Result_L) + len = add_tlv("2",temp_len,temp_data,0x0a0,&asn_buf); // add result last + else + len = add_tlv("7",temp_len,temp_data,0x0a0,&asn_buf); // add result not last + } + else + { + temp_len = add_tlv("15",1,&cha_ptr->invoke_id,ANSI_TAG_CLASS_PRIM,&asn_buf); + memcpy(temp_data+temp_len,result_ptr->parameter,result_ptr->parameter_len); + temp_len += result_ptr->parameter_len; + asn_encode(string,&asn_buf); + if (cha_ptr->message_type == Result_L_Ansi) + len = add_tlv("10",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + else + len = add_tlv("14",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + } + break; + case Error: + case Error_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][12] ++; + uerror_ptr = (TCUError_struct *) &cha_ptr->cmp_prim.tc_uerror; + asn_encode(temp_data,&asn_buf); + if (!proto_type) + { + temp_len = add_tlv("2",1,&cha_ptr->invoke_id,0x00,&asn_buf); + asn_encode(string,&asn_buf); + if (uerror_ptr->error_type == Local_Error_Code) + len = add_tlv("2",1,&uerror_ptr->error_code,0x00,&asn_buf); + else + len = add_tlv("6",1,&uerror_ptr->error_code,0x00,&asn_buf); + if (uerror_ptr->parameter_len != 0) + { + memcpy(string+len,uerror_ptr->parameter,uerror_ptr->parameter_len); + len += uerror_ptr->parameter_len; + } + memcpy(temp_data+temp_len,string,len); + temp_len += len; + asn_encode(string,&asn_buf); + len = add_tlv("3",temp_len,temp_data,0x0a0,&asn_buf); // add result error + } + else + { + temp_len = add_tlv("15",1,&cha_ptr->invoke_id,ANSI_TAG_CLASS_PRIM,&asn_buf); + if (uerror_ptr->error_type) + temp_len = add_tlv("20",1,&uerror_ptr->error_code,ANSI_TAG_CLASS_PRIM,&asn_buf); + else + temp_len = add_tlv("19",1,&uerror_ptr->error_code,ANSI_TAG_CLASS_PRIM,&asn_buf); + memcpy(temp_data+temp_len,uerror_ptr->parameter,uerror_ptr->parameter_len); + temp_len += uerror_ptr->parameter_len; + asn_encode(string,&asn_buf); + len = add_tlv("11",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + } + break; + case Reject: + case Reject_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][13] ++; + reject_ptr = (TCReject_struct *) &cha_ptr->cmp_prim.tc_reject; + if (!proto_type) + asn_encode(string,&asn_buf); + else + asn_encode(temp_data,&asn_buf); + if (!proto_type) + { + len = add_tlv("4",0,temp_data,0x0a0,&asn_buf); // add result reject + if (cha_ptr->invoke_id != 0xff) + len = add_tlv("4.2-1",1,&cha_ptr->invoke_id,0x00,&asn_buf); + else + len = add_null("4.5-1",0x00,&asn_buf); + switch (reject_ptr->problem_type) + { + case General_Problem: + len = add_tlv("4.0-2",1,&reject_ptr->problem_code,0x80,&asn_buf); + switch (reject_ptr->problem_code) + { + case General_Problem_UC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][53] ++; + break; + case General_Problem_MC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][54] ++; + break; + case General_Problem_BSC: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][55] ++; + break; + default: + break; + } + break; + case Invoke_Problem: + len = add_tlv("4.1-2",1,&reject_ptr->problem_code,0x80,&asn_buf); + switch (reject_ptr->problem_code) + { + case Invoke_Problem_DIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][61] ++; + break; + case Invoke_Problem_UO: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][62] ++; + break; + case Invoke_Problem_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][63] ++; + break; + case Invoke_Problem_IR: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][64] ++; + break; + case Invoke_Problem_ULID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][56] ++; + break; + case Invoke_Problem_LRU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][65] ++; + break; + case Invoke_Problem_ULO: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][66] ++; + break; + default: + break; + } + break; + case Return_Result: + len = add_tlv("4.2-2",1,&reject_ptr->problem_code,0x80,&asn_buf); + switch (reject_ptr->problem_code) + { + case Return_Result_UIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][57] ++; + break; + case Return_Result_RRU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][58] ++; + break; + case Return_Result_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][69] ++; + break; + default: + break; + } + break; + default: + len = add_tlv("4.3-2",1,&reject_ptr->problem_code,0x80,&asn_buf); + switch (reject_ptr->problem_code) + { + case Return_Error_UIID: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][59] ++; + break; + case Return_Error_REU: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][60] ++; + break; + case Return_Error_URE: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][67] ++; + break; + case Return_Error_UEE: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][68] ++; + break; + case Return_Error_MP: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][70] ++; + break; + default: + break; + } + break; + } + } + else + { + temp_len = add_tlv("15",1,&cha_ptr->invoke_id,ANSI_TAG_CLASS_PRIM,&asn_buf); + temp_str[0] = reject_ptr->problem_type; + temp_str[1] = reject_ptr->problem_code; + temp_len = add_tlv("21",2,temp_str,ANSI_TAG_CLASS_PRIM,&asn_buf); + memcpy(temp_data+temp_len,reject_ptr->parameter,reject_ptr->parameter_len); + temp_len += reject_ptr->parameter_len; + asn_encode(string,&asn_buf); + len = add_tlv("12",temp_len,temp_data,ANSI_TAG_CLASS_CONS,&asn_buf); + switch (reject_ptr->problem_type) + { + case General_Problem_Ansi: + switch (reject_ptr->problem_code) + { + case General_Problem_UC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][53] ++; + break; + case General_Problem_MC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][54] ++; + break; + case General_Problem_BSC_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][55] ++; + break; + default: + break; + } + break; + case Invoke_Problem_Ansi: + switch (reject_ptr->problem_code) + { + case Invoke_Problem_DIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][61] ++; + break; + case Invoke_Problem_UO_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][62] ++; + break; + case Invoke_Problem_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][63] ++; + break; + case Invoke_Problem_ULID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][56] ++; + break; + default: + break; + } + break; + case Return_Result_Ansi: + switch (reject_ptr->problem_code) + { + case Return_Result_UIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][57] ++; + break; + case Return_Result_RRU_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][58] ++; + break; + case Return_Result_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][69] ++; + break; + default: + break; + } + break; + default: + switch (reject_ptr->problem_code) + { + case Return_Error_UIID_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][59] ++; + break; + case Return_Error_REU_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][60] ++; + break; + case Return_Error_URE_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][67] ++; + break; + case Return_Error_UEE_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][68] ++; + break; + case Return_Error_MP_Ansi: + tcap_ptr->tcap_debug.tc_utilize[TCAP_UTILIZE_COUNT-1][70] ++; + break; + default: + break; + } + break; + } + } + break; + default: + tcap_send_error("CSL component encode error. Can not recognize component type"); + return 0; + break; + } + return len; +} +/*@end@*/ diff --git a/omc/plat/tcap/src/tcap_fsm.c b/omc/plat/tcap/src/tcap_fsm.c new file mode 100644 index 0000000..13e9e65 --- /dev/null +++ b/omc/plat/tcap/src/tcap_fsm.c @@ -0,0 +1,3003 @@ +/* TCAP c program file */ +/* written by Liu Zhiguo 2002-08-06 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "../../sccp/src/include/sccp.h" +#include "./include/tcap_public.h" +#include "./include/idmanage.h" +#include "./include/tcap_struct.h" +#include "./include/tcap_m.h" + +typedef struct id_struct +{ + u32 current_did; + u32 count_did; + u32 count_did_occupied; + u32 count_did_max; + u32 count_did_tmp; + u8 dialogue_id[MAX_DIALOGUEID]; + u8 current_iid[MAX_DIALOGUEID]; + u8 invoke_id[MAX_DIALOGUEID][MAX_INVOKEID]; +}id_struct; + +extern struct id_struct *ID_ptr; + +/*@ignore@*/ +static struct tcapdebug_struct *debug_ptr; +void print_msg(u8 *ptr, u16 len); + +extern u32 tcap_dlg_h[MAX_DIALOGUEID]; +extern u32 tcap_dlg_t[MAX_DIALOGUEID]; + +/* protocol version */ +static u8 Version_1[2] = {0x07,0x80}; +static u8 Version_Ansi = 0x01; + +void tcap_set_local_ip() +{ + char hostname[64]; + struct hostent *pcn; + struct in_addr *hostip_add; + + if ((gethostname(hostname,-1)) == -1) + { + printf("get host name fail\n"); + exit(0); + } + pcn = gethostbyname(hostname); + if (pcn == NULL) + { + printf("get host name fail!\n"); + exit(0); + } + hostip_add = (struct in_addr *) (*pcn->h_addr_list); + debug_ptr->local_ip = hostip_add->s_addr; + //debug_ptr->peer_ip = debug_ptr->local_ip + 0x10000; + /* like : mss0=172.18.98.1-0x016212ac, mss1=172.18.99.1-0x016312ac */ +} + +void tcapvm_init(DWORD localip, DWORD peerip) // init share memory +{ + int shm_id; + + /* init share memory */ + if ((shm_id = shmget(TCAP_KEY,sizeof(tcapbuf_struct),TCAP_PERM|IPC_CREAT)) == -1) + { + printf("can not init tcap share memory"); + exit(0); + } + if ((tcap_ptr = (tcapbuf_struct *)shmat(shm_id,(char *)0,0)) == (tcapbuf_struct *) -1) + { + printf("can not init tcap share memory"); + exit(0); + } + memset(tcap_ptr,0,sizeof(tcapbuf_struct)); + debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + if(localip>0) + { + debug_ptr->local_ip = localip; + debug_ptr->peer_ip = peerip; + } + else + { + tcap_set_local_ip(); + } +} + + +void get_dlgpdu(struct dlgPDU_struct *pdu_ptr,struct dlgport_struct *port_ptr) +{ + switch (pdu_ptr->dialogue_type) + { + case PDU_AARQ: + port_ptr->acn_len = pdu_ptr->pdu_union.aarq.acn_len; + memcpy(port_ptr->acn,pdu_ptr->pdu_union.aarq.acn,port_ptr->acn_len); + port_ptr->user_info_len = pdu_ptr->pdu_union.aarq.user_info_len; + memcpy(port_ptr->user_info,pdu_ptr->pdu_union.aarq.user_info,port_ptr->user_info_len); + break; + case PDU_AARE: + port_ptr->acn_len = pdu_ptr->pdu_union.aare.acn_len; + memcpy(port_ptr->acn,pdu_ptr->pdu_union.aare.acn,port_ptr->acn_len); + port_ptr->user_info_len = pdu_ptr->pdu_union.aare.user_info_len; + memcpy(port_ptr->user_info,pdu_ptr->pdu_union.aare.user_info,port_ptr->user_info_len); + break; + case PDU_ABRT: + port_ptr->acn_len = 0; + port_ptr->user_info_len = pdu_ptr->pdu_union.abrt.user_info_len; + memcpy(port_ptr->user_info,pdu_ptr->pdu_union.abrt.user_info,port_ptr->user_info_len); + break; + case PDU_ASUDT: + port_ptr->acn_type = pdu_ptr->pdu_union.asudt.acn_type; + port_ptr->acn_len = pdu_ptr->pdu_union.asudt.acn_len; + memcpy(port_ptr->acn,pdu_ptr->pdu_union.asudt.acn,port_ptr->acn_len); + port_ptr->user_info_len = pdu_ptr->pdu_union.asudt.user_info_len; + memcpy(port_ptr->user_info,pdu_ptr->pdu_union.asudt.user_info,port_ptr->user_info_len); + port_ptr->security_context_type = pdu_ptr->pdu_union.asudt.security_context_type; + port_ptr->security_context_len = pdu_ptr->pdu_union.asudt.security_context_len; + memcpy(port_ptr->security_context,pdu_ptr->pdu_union.asudt.security_context,port_ptr->security_context_len); + port_ptr->confidential_info_len = pdu_ptr->pdu_union.asudt.confidential_info_len; + memcpy(port_ptr->confidential_info,pdu_ptr->pdu_union.asudt.confidential_info,port_ptr->confidential_info_len); + break; + default: + tcap_send_error("CSL error. Dialogue PDU type error"); + break; + } +} + +void set_dlgpdu(struct dlgPDU_struct *pdu_ptr,struct dlgport_struct *port_ptr) +{ + if (port_ptr->user_info_len > TCAP_USERINFO_LEN) + port_ptr->user_info_len = TCAP_USERINFO_LEN; + if (port_ptr->acn_len > TCAP_ACN_LEN) + port_ptr->acn_len = TCAP_ACN_LEN; + if (port_ptr->security_context_len > TCAP_SECURITY_CONTEXT_LEN) + port_ptr->security_context_len = TCAP_SECURITY_CONTEXT_LEN; + if (port_ptr->confidential_info_len > TCAP_CONFIDENTIAL_INFO_LEN) + port_ptr->confidential_info_len = TCAP_CONFIDENTIAL_INFO_LEN; + + switch (pdu_ptr->dialogue_type) + { + case PDU_AARQ: + pdu_ptr->pdu_union.aarq.acn_len = port_ptr->acn_len; + memcpy(pdu_ptr->pdu_union.aarq.acn,port_ptr->acn,port_ptr->acn_len); + pdu_ptr->pdu_union.aarq.user_info_len = port_ptr->user_info_len; + memcpy(pdu_ptr->pdu_union.aarq.user_info,port_ptr->user_info,port_ptr->user_info_len); + break; + case PDU_AARE: + pdu_ptr->pdu_union.aare.acn_len = port_ptr->acn_len; + memcpy(pdu_ptr->pdu_union.aare.acn,port_ptr->acn,port_ptr->acn_len); + pdu_ptr->pdu_union.aare.user_info_len = port_ptr->user_info_len; + memcpy(pdu_ptr->pdu_union.aare.user_info,port_ptr->user_info,port_ptr->user_info_len); + break; + case PDU_ABRT: + pdu_ptr->pdu_union.abrt.user_info_len = port_ptr->user_info_len; + memcpy(pdu_ptr->pdu_union.abrt.user_info,port_ptr->user_info,port_ptr->user_info_len); + break; + case PDU_ASUDT: + pdu_ptr->pdu_union.asudt.acn_type = port_ptr->acn_type; + pdu_ptr->pdu_union.asudt.acn_len = port_ptr->acn_len; + memcpy(pdu_ptr->pdu_union.asudt.acn,port_ptr->acn,port_ptr->acn_len); + pdu_ptr->pdu_union.asudt.user_info_len = port_ptr->user_info_len; + memcpy(pdu_ptr->pdu_union.asudt.user_info,port_ptr->user_info,port_ptr->user_info_len); + pdu_ptr->pdu_union.asudt.security_context_type = port_ptr->security_context_type; + pdu_ptr->pdu_union.asudt.security_context_len = port_ptr->security_context_len; + memcpy(pdu_ptr->pdu_union.asudt.security_context,port_ptr->security_context,port_ptr->security_context_len); + pdu_ptr->pdu_union.asudt.confidential_info_len = port_ptr->confidential_info_len; + memcpy(pdu_ptr->pdu_union.asudt.confidential_info,port_ptr->confidential_info,port_ptr->confidential_info_len); + break; + default: + memset(pdu_ptr,0,sizeof(dlgPDU_struct)); + break; + } +} + +void ism_terminate(u32 did,u8 iid) +{ + struct tcapvm_struct *vm_ptr; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[did]; + vm_ptr->ism_data[iid].ism_state = TCAP_INIT; +} + +void tcap_terminate(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + memset(&vm_ptr->ism_data,0,MAX_TEMPINVOKEID*sizeof(ismvm_data)); + int_ptr->cmprecv_head = int_ptr->cmprecv_tail = 0; + int_ptr->cmpsend_head = int_ptr->cmpsend_tail = 0; +} + +void tcap_clear_fsm(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + vm_ptr->peer_tid = 0; + vm_ptr->tcap_timer = 0; + vm_ptr->ac_mode = 0; + vm_ptr->proto_type = 0; + + ID_ptr->current_iid[proc] = 0; //added by yingmin 2007-12-6 + + vm_ptr->tcaprecv_head = vm_ptr->tcaprecv_tail = 0; + int_ptr->dlgrecv_head = int_ptr->dlgrecv_tail = 0; + int_ptr->dlgsend_head = int_ptr->dlgsend_tail = 0; + tcap_dlg_h[proc] = 0; + tcap_dlg_t[proc] = 0; + debug_ptr->watch_dog[190]++; + tcap_terminate(proc); +} + +u8 tcap_from_sccp(struct SCLC_MSG *data_ptr) //receive data from sccp +{ + char buf[4*TCAP_BUF_LEN]; + char *cur_time; + + if (!sclc_receive(data_ptr,0)) + return 0; + if (debug_ptr->sccp_switch == 1 && debug_ptr->send_control == 0) + { + cur_time = GetAsciiTime(); + sprintf(buf,"sccp->tcap, len: %d, time: %s\r",data_ptr->msglen,cur_time); + HexToDisplay(buf+strlen(buf),data_ptr->msg,data_ptr->msglen); + strcat(buf,"\r\n\r\n"); + tcap_send_ascout(buf); + } + debug_ptr->watch_dog[0] ++; + return 1; +} + +u8 tcap_get_sls(u32 tid) +{ + u8 ii; + u8 sls; + + ii = (tid >> 16) & 0xff; + if (ii % 2) // odd + sls = (((tid + 1)/2) * 2 + 1) % TCAP_SLS_NUM; + else + sls = (((tid + 1)/2) * 2) % TCAP_SLS_NUM; + return sls; +} + +void tcap_to_sccp(struct TSL_struct *tsl_data,u8 sls,u8 flag) // send data to sccp +{ + struct SCLC_MSG sccp_data; + char buf[4*TCAP_BUF_LEN]; + char *cur_time; + + if (!tsl_message_encode(&sccp_data,tsl_data,flag)) // encode the tsl message + { + debug_ptr->watch_dog[1] ++; + return; + } + if (debug_ptr->sccp_switch == 1 && debug_ptr->send_control == 0) + { + cur_time = GetAsciiTime(); + sprintf(buf,"tcap->sccp, len: %d, time: %s\r",sccp_data.msglen,cur_time); + HexToDisplay(buf+strlen(buf),sccp_data.msg,sccp_data.msglen); + strcat(buf,"\r\n\r\n"); + tcap_send_ascout(buf); + } + if (flag == 1) + sccp_data.sls = 0x80; + else{ + sccp_data.sls = sls % TCAP_SLS_NUM; + sccp_data.sequence_control = 1; + } + sclc_send(&sccp_data); + debug_ptr->watch_dog[2] ++; +} + +u8 check_resend(struct TSL_struct *tsl_ptr,u32 tid) +{ + u32 ii; + + ii = tid & 0xffff0000; + if (ii == (debug_ptr->local_ip & 0xffff0000))// owner data, do not need resend + return 0; + if(ii == (debug_ptr->peer_ip & 0xffff0000)) + { + ii = tid & 0x8000; + if (ii == 0) // resend data + tcap_to_sccp(tsl_ptr,0x80,1); + } + else + { + tcap_send_error("local ip chanage it back\r\n"); + tcap_set_local_ip(); + } + return 1; +} + +void tco_to_tsm(struct TSL_struct *tsl_data,u32 tid_flag) // send data to TSM +{ + struct tcapvm_struct *vm_ptr; + u8 head_flag; + u8 tail_flag; + u8 info_buf[1024]; + + if (tid_flag >= (tcap_ptr->grantdid)) + return; + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[tid_flag]; + head_flag = vm_ptr->tcaprecv_head; + tail_flag = vm_ptr->tcaprecv_tail; + if (((head_flag + 1) % MAX_TSL_BUF) == tail_flag) // buffer is full + { + if (debug_ptr->error_switch) + { + sprintf(info_buf,"TSL error. TCO -> TSM buffer is full, dialogue id: %ld",tid_flag); + tcap_send_error(info_buf); + } + return; + } + /*added by Pierre, 2006-08-19 */ + if(tsl_data->message_type == Begin || + tsl_data->message_type == Continue) + { + vm_ptr->peer_tid_len = tsl_data->peer_tid_len; + } + memcpy(&vm_ptr->tsl_data[head_flag],tsl_data,sizeof(TSL_struct)); + vm_ptr->tcaprecv_head = (head_flag + 1) % MAX_TSL_BUF; +} + +void send_pabort_sccp(u8 tid_len,u32 tid,u8 reason,SCCP_ADDR *local_add,SCCP_ADDR *peer_add,u8 proto_type) +{ + struct TSL_struct tsl_data; + struct TRPAbort_struct *pabort_ptr; + u8 sls; + + if (tid == 0) + return; + if (proto_type == ANSI_TCAP) + tsl_data.message_type = P_Abort_Ansi; + else + tsl_data.message_type = P_Abort; + tsl_data.message_flag = REQUEST; + memcpy(&tsl_data.local_add,local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,peer_add,sizeof(SCCP_ADDR)); + pabort_ptr = (TRPAbort_struct *) &tsl_data.tsl_prim.tr_pabort; + pabort_ptr->transaction_id = tid; + pabort_ptr->abort_reason = reason; + sls = tcap_get_sls(tid); + tsl_data.peer_tid_len = tid_len; + tcap_to_sccp(&tsl_data,sls,0); +} + +void send_pabort_tsm(u32 tid,u8 reason,u8 proto_type) +{ + struct TSL_struct tsl_data; + struct TRPAbort_struct *pabort_ptr; + + if (proto_type == ANSI_TCAP) + tsl_data.message_type = P_Abort_Ansi; + else + tsl_data.message_type = P_Abort; + tsl_data.message_flag = INDICATE; + pabort_ptr = (TRPAbort_struct *) &tsl_data.tsl_prim.tr_pabort; + pabort_ptr->transaction_id = tid; + pabort_ptr->abort_reason = reason; + + tco_to_tsm(&tsl_data,tid); +} + +void send_pabort_tcu(u32 did,u8 reason,u8 data_flag,u8 proto_type) +{ + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[did]; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[data_flag]; + if (proto_type) + csl_ptr->message_type = P_Abort_Ansi; + else + csl_ptr->message_type = P_Abort; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = did; + csl_ptr->dlg_prim.tc_pabort.pabort_reason = reason; + int_ptr->dlgrecv_head = (data_flag + 1) % MAX_TSL_BUF; +} + +void send_uabort_sccp(u32 proc,struct dlgPDU_struct *pdu_ptr,u8 proto_type,u8 uabort_info_len, u8 *uabort_info) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct tsl_data; + struct TRUAbort_struct *uabort_ptr; + u8 sls; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + if (vm_ptr->peer_tid == 0) + return; + if (!proto_type) + tsl_data.message_type = U_Abort; + else + tsl_data.message_type = U_Abort_Ansi; + tsl_data.message_flag = REQUEST; + memcpy(&tsl_data.local_add,&vm_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,&vm_ptr->peer_add,sizeof(SCCP_ADDR)); + uabort_ptr = (TRUAbort_struct *) &tsl_data.tsl_prim.tr_uabort; + uabort_ptr->transaction_id = vm_ptr->peer_tid; + uabort_ptr->dialogue_len = 0; + uabort_ptr->dialogue_len = build_dp(uabort_ptr->dialogue,pdu_ptr,0,proto_type); + if (proto_type) + { + uabort_ptr->uabort_info_len = uabort_info_len; + memcpy(uabort_ptr->uabort_info,uabort_info,uabort_info_len); + } + sls = tcap_get_sls(vm_ptr->peer_tid); + tsl_data.peer_tid_len = vm_ptr->peer_tid_len; //modified by Pierre, 06-08-19 + tcap_to_sccp(&tsl_data,sls,0); +} + +u8 check_csldata(u32 proc) +{ + struct tcapint_struct *int_ptr; + char info_str[1024]; + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + if (int_ptr->dlgrecv_head == int_ptr->dlgrecv_tail) // dlg recv buffer is empty + { + if (int_ptr->cmprecv_head == int_ptr->cmprecv_tail) + return 1; + debug_ptr->watch_dog[159]++; + //printf("check_csldata, cmprecv: %d, did: %d\n", int_ptr->cmp_recv[int_ptr->cmprecv_tail].message_type, proc); + sprintf(info_str, "check_csldata, cmprecv: %d, did: %ld\n", int_ptr->cmp_recv[int_ptr->cmprecv_tail].message_type, proc); + tcap_send_error(info_str); + } + else + { + debug_ptr->watch_dog[158]++; + //printf("check_csldata, dlgrecv: %d, did: %d\n", int_ptr->dlg_recv[int_ptr->dlgrecv_tail].message_type, proc); + sprintf(info_str, "check_csldata, dlgrecv: %d, did: %ld\n", int_ptr->dlg_recv[int_ptr->dlgrecv_tail].message_type, proc); + tcap_send_error(info_str); + } + + return 0; +} + +void tco_program(void) // transaction coordinator +{ + struct SCLC_MSG sccp_data; + struct TSL_struct tsl_data; + struct TRBegin_struct *begin_ptr; + struct TRContinue_struct *con_ptr; + struct TREnd_struct *end_ptr; + struct TRUAbort_struct *uabort_ptr; + struct TRPAbort_struct *pabort_ptr; + struct TRNotice_struct *notice_ptr; + u8 decode_result; + u8 decode_error; + u8 proto_type, pabort_cause; + u32 temp_tid; + u32 ii; + char info_str[1024]; + + if (tcap_from_sccp(&sccp_data)) // get data from sccp buffer + { + memset(&tsl_data,0,sizeof(TSL_struct)); + decode_result = tsl_message_decode(&sccp_data,&tsl_data,&decode_error); + if ((tsl_data.message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + switch (tsl_data.message_type) + { + case Unidirectional: + case Unidirectional_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][5] ++; + debug_ptr->watch_dog[32] ++; + if (decode_result == 1) + { + debug_ptr->watch_dog[33] ++; + temp_tid = assign_did(); + if (temp_tid != 0) + { + debug_ptr->watch_dog[222] ++; + tco_to_tsm(&tsl_data,temp_tid); + } + } + break; + case Begin: + case Query_WithPerm_Ansi: + case Query_WithoutPerm_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][6] ++; + debug_ptr->watch_dog[34] ++; + begin_ptr = (TRBegin_struct *) &tsl_data.tsl_prim.tr_begin; + if (decode_result == 0) // message format is wrong + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][75] ++; + debug_ptr->watch_dog[35] ++; + if (begin_ptr->tid_flag == 1) // ptid derivable + { + debug_ptr->watch_dog[36] ++; + if (proto_type) + pabort_cause = P_Abort_ITP_Ansi; + else + pabort_cause = P_Abort_ITP; + send_pabort_sccp(tsl_data.peer_tid_len, //modified by Pierre, 06-08-19 */ + begin_ptr->transaction_id,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + } + return; + } + temp_tid = assign_did(); + if (temp_tid == 0) // can not assign a dialogue id + { + tcap_send_alarm(5,1); + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][72] ++; + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][24]++; + tcap_send_error("TSL error. Can not assign transaction id"); + debug_ptr->watch_dog[37] ++; + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_sccp(tsl_data.peer_tid_len,//modified by Pierre, 06-08-19 + begin_ptr->transaction_id,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + return; + } + debug_ptr->watch_dog[221] ++; + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][20]++; + tco_to_tsm(&tsl_data,temp_tid); + break; + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][7] ++; + debug_ptr->watch_dog[38] ++; + con_ptr = (TRContinue_struct *) &tsl_data.tsl_prim.tr_continue; + if (decode_result == 0) // message format is wrong + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][75] ++; + debug_ptr->watch_dog[39] ++; + if (con_ptr->ptid_flag == 1) // ptid derivable + { + if (con_ptr->ltid_flag == 0) // DTID not assigned + { + debug_ptr->watch_dog[40] ++; + if (proto_type) + pabort_cause = P_Abort_ITP_Ansi; + else + pabort_cause = P_Abort_ITP; + send_pabort_sccp(tsl_data.peer_tid_len, //modified by Pierre, 06-08-19 + con_ptr->peer_tid,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + } + else + { + ii = con_ptr->local_tid; + if (check_resend(&tsl_data,ii)) + return; + ii = ii & 0x7fff; + if (!check_did(ii)) + { + debug_ptr->watch_dog[40] ++; + if (proto_type) + pabort_cause = P_Abort_ITP_Ansi; + else + pabort_cause = P_Abort_ITP; + send_pabort_sccp(tsl_data.peer_tid_len, //modified by Pierre, 06-08-19 + con_ptr->peer_tid,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + } + else + { + debug_ptr->watch_dog[41] ++; + if (decode_error == DERR_UNTID || decode_error == DERR_OTHER) + { + if (proto_type) + pabort_cause = P_Abort_ITP_Ansi; + else + pabort_cause = P_Abort_ITP; + } + else + { + if (proto_type) + pabort_cause = P_Abort_BFTP_Ansi; + else + pabort_cause = P_Abort_BFTP; + } + send_pabort_sccp(tsl_data.peer_tid_len, //modified by Pierre, 06-08-19 + con_ptr->peer_tid,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + send_pabort_tsm(ii,pabort_cause,proto_type); + } + } + } + return; + } + ii = con_ptr->local_tid; + if (check_resend(&tsl_data,ii)) + return; + con_ptr->local_tid = ii & 0x7fff; + if (!check_did(con_ptr->local_tid)) // DTID not assigned + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][72] ++; + sprintf(info_str, "TSL error. Can not check out transaction id, did: %ld, type: %d, continue", temp_tid, tsl_data.message_type); + tcap_send_error(info_str); + debug_ptr->watch_dog[230]++; + //tcap_send_error("TSL error. Can not check out transaction id"); + debug_ptr->watch_dog[42] ++; + if (con_ptr->peer_tid != 0) // ptid derivable + { + debug_ptr->watch_dog[43] ++; + if (proto_type) + pabort_cause = P_Abort_UTID_Ansi; + else + pabort_cause = P_Abort_UTID; + send_pabort_sccp(tsl_data.peer_tid_len, //modified by Pierre, 06-08-19 + con_ptr->peer_tid,pabort_cause,&tsl_data.local_add,&tsl_data.peer_add,proto_type); + } + return; + } + tco_to_tsm(&tsl_data,con_ptr->local_tid); + break; + case End: + case Response_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][8] ++; + debug_ptr->watch_dog[44] ++; + end_ptr = (TREnd_struct *) &tsl_data.tsl_prim.tr_end; + if (check_resend(&tsl_data,end_ptr->transaction_id)) + return; + end_ptr->transaction_id &= 0x7fff; + temp_tid = end_ptr->transaction_id; + if (decode_result == 0) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][75] ++; + debug_ptr->watch_dog[45] ++; + if (end_ptr->tid_flag == 0 || !check_did(temp_tid)) + debug_ptr->watch_dog[46] ++; + else + { + if (proto_type) + pabort_cause = P_Abort_BFTP_Ansi; + else + pabort_cause = P_Abort_BFTP; + send_pabort_tsm(temp_tid,pabort_cause,proto_type); + } + return; + } + if (!check_did(temp_tid)) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][72] ++; + sprintf(info_str, "TSL error. Can not check out transaction id, did: %ld, type: %d, end", temp_tid, tsl_data.message_type); + tcap_send_error(info_str); + //printf("TSL error. Can not check out transaction id, did: %ld, type: %d, end\n", temp_tid, tsl_data.message_type); + debug_ptr->watch_dog[229]++; + //tcap_send_error("TSL error. Can not check out transaction id"); + return; + } + tco_to_tsm(&tsl_data,temp_tid); + break; + case U_Abort: + case U_Abort_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][9] ++; + debug_ptr->watch_dog[47] ++; + uabort_ptr = (TRUAbort_struct *) &tsl_data.tsl_prim.tr_uabort; + if (check_resend(&tsl_data,uabort_ptr->transaction_id)) + return; + uabort_ptr->transaction_id &= 0x7fff; + temp_tid = uabort_ptr->transaction_id; + if (decode_result == 0) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][75] ++; + debug_ptr->watch_dog[48] ++; + if (uabort_ptr->tid_flag == 0 || !check_did(temp_tid)) + { + debug_ptr->watch_dog[49] ++; + if (proto_type) + pabort_cause = P_Abort_BFTP_Ansi; + else + pabort_cause = P_Abort_BFTP; + send_pabort_tsm(temp_tid,pabort_cause,proto_type); + } + return; + } + if (!check_did(temp_tid)) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][72] ++; + sprintf(info_str, "TSL error. Can not check out transaction id, did: %ld, type: %d, uabort", temp_tid, tsl_data.message_type); + tcap_send_error(info_str); + debug_ptr->watch_dog[228]++; + //tcap_send_error("TSL error. Can not check out transaction id"); + return; + } + if (debug_ptr->error_switch) + { + if (!proto_type) + sprintf(info_str,"TSL warning. Receive U_Abort from other machine. Tid= %ld",temp_tid); + else + sprintf(info_str,"TSL warning. Receive U_Abort_Ansi from other machine. Tid= %ld",temp_tid); + tcap_send_error(info_str); + } + tco_to_tsm(&tsl_data,temp_tid); + break; + case P_Abort: + case P_Abort_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][9] ++; + debug_ptr->watch_dog[50] ++; + pabort_ptr = (TRPAbort_struct *) &tsl_data.tsl_prim.tr_pabort; + if (check_resend(&tsl_data,pabort_ptr->transaction_id)) + return; + pabort_ptr->transaction_id &= 0x7fff; + temp_tid = pabort_ptr->transaction_id; + if (decode_result == 0) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][75] ++; + debug_ptr->watch_dog[51] ++; + if (pabort_ptr->tid_flag == 0 || !check_did(temp_tid)) + debug_ptr->watch_dog[52] ++; + else + { + if (proto_type) + pabort_cause = P_Abort_BFTP_Ansi; + else + pabort_cause = P_Abort_BFTP; + send_pabort_tsm(temp_tid,pabort_cause,proto_type); + } + return; + } + if (!check_did(temp_tid)) + { + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][72] ++; + sprintf(info_str, "TSL error. Can not check out transaction id, did: %ld, type: %d, pabort", temp_tid, tsl_data.message_type); + tcap_send_error(info_str); + debug_ptr->watch_dog[227]++; + //tcap_send_error("TSL error. Can not check out transaction id"); + return; + } + tco_to_tsm(&tsl_data,temp_tid); + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][73] ++; + if (!proto_type) + { + switch (pabort_ptr->abort_reason) + { + case P_Abort_UMT: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][25] ++; + break; + case P_Abort_ITP: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][26] ++; + break; + case P_Abort_BFTP: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][27] ++; + break; + case P_Abort_UTID: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][28] ++; + break; + case P_Abort_RL: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][29] ++; + break; + default: + break; + } + } + else + { + switch (pabort_ptr->abort_reason) + { + case P_Abort_UMT_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][25] ++; + break; + case P_Abort_ITP_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][26] ++; + break; + case P_Abort_BFTP_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][27] ++; + break; + case P_Abort_UTID_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][28] ++; + break; + case P_Abort_RL_Ansi: + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][29] ++; + break; + default: + break; + } + } + if (debug_ptr->error_switch) + { + if (!proto_type) + sprintf(info_str,"TSL warning. Receive P_Abort from other machine. Tid= %ld",temp_tid); + else + sprintf(info_str,"TSL warning. Receive P_Abort_Ansi from other machine. Tid= %ld",temp_tid); + tcap_send_error(info_str); + } + break; + case Notice: + debug_ptr->watch_dog[53] ++; + notice_ptr = (TRNotice_struct *) &tsl_data.tsl_prim.tr_notice; + temp_tid = notice_ptr->transaction_id; + if (!check_did(temp_tid)) + { + sprintf(info_str, "TSL error. Can not check out transaction id, did: %ld, type: %d, notice", temp_tid, tsl_data.message_type); + tcap_send_error(info_str); + debug_ptr->watch_dog[226]++; + //tcap_send_error("TSL error. Can not check out transaction id"); + return; + } + tco_to_tsm(&tsl_data,temp_tid); + tcap_send_error("TSL error. Receive Notice from lower layer"); + break; + default: + debug_ptr->watch_dog[54] ++; + break; + } + } +} + +int get_from_cha(u8 *content,u32 proc,u8 *temp,u8 data_count,u8 level) // build component primitive +{ + struct tcapint_struct *int_ptr; + int len = 0; + int ii,jj,aa; + u8 default_len,send_count=0; + u8 temp_buf[TCAP_BUF_LEN]; + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + *temp = 0; + if (level == 1) + default_len = TCAP_PARAM_LEN_1; + else + default_len = TCAP_PARAM_LEN; + for (ii = 0;ii < data_count;ii ++) + { + jj = int_ptr->cmpsend_tail; + if (jj == int_ptr->cmpsend_head) + break; + aa = assemble_component(temp_buf,&int_ptr->cmp_send[jj]); + if ((len+aa) > default_len) // components data is too long + { + tcap_send_error("CSL warning.components length is larger than expected"); + *temp = send_count; + debug_ptr->watch_dog[250]++; + break; + } + else + { + memcpy(content+len,temp_buf,aa); + int_ptr->cmpsend_tail = (jj + 1) % MAX_CSL_BUF; + len += aa; + send_count ++; + debug_ptr->watch_dog[251]++; + } + } + return len; +} + +void send_cancel_tcu(u32 proc,u8 invid) +{ + struct tcapint_struct *int_ptr; + struct CSLcmp_struct *cmp_ptr; + u8 ii; + u8 info_buf[1024]; + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->cmprecv_head; + if ((ii + 1) % MAX_CSL_BUF == int_ptr->cmprecv_tail) // buffer is full + { + if (debug_ptr->error_switch) + { + sprintf(info_buf,"ISM error. component buffer is full:%ld",proc); + tcap_send_error(info_buf); + } + return; + } + cmp_ptr = (CSLcmp_struct *) &int_ptr->cmp_recv[ii]; + cmp_ptr->message_type = L_Cancel; + cmp_ptr->message_flag = INDICATE; + cmp_ptr->dialogue_id = proc; + cmp_ptr->invoke_id = invid; + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + debug_ptr->watch_dog[156]++; +} + +void send_reject_tcu(u32 proc,u8 invid,u8 err_type,u8 err_code,u8 proto_type) +{ + struct tcapint_struct *int_ptr; + struct CSLcmp_struct *cmp_ptr; + struct TCReject_struct *reject_ptr; + u8 ii; + u8 flag=0; + + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->cmprecv_tail; + while(ii != int_ptr->cmprecv_head) + { + if (int_ptr->cmp_recv[ii].invoke_id == invid) // find exist data + { + flag = 1; + break; + } + ii = (ii + 1) % MAX_CSL_BUF; + } + if (flag == 0) + { + ii = int_ptr->cmprecv_head; + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + } + cmp_ptr = (CSLcmp_struct *) &int_ptr->cmp_recv[ii]; + if (proto_type) + cmp_ptr->message_type = L_Reject_Ansi; + else + cmp_ptr->message_type = L_Reject; + cmp_ptr->message_flag = INDICATE; + cmp_ptr->dialogue_id = proc; + cmp_ptr->invoke_id = invid; + cmp_ptr->last_flag = 1; + reject_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + reject_ptr->problem_type = err_type; + reject_ptr->problem_code = err_code; // badly structured component +} + +u8 find_tempiid(u32 did,u8 iid,u8 flag) +{ + struct tcapvm_struct *vm_ptr; + struct ismvm_data *ism_ptr; + u8 ii; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[did]; + if (flag == 1) //apply for new iid + { + for (ii = 0;ii < MAX_TEMPINVOKEID;ii ++) + { + ism_ptr = (ismvm_data *) &vm_ptr->ism_data[ii]; + if (ism_ptr->used_flag == 0) // empty temp iid + { + ism_ptr->used_flag = 1; + ism_ptr->linked_iid = iid; + return ii; + } + } + } + else //search assigned iid + { + for (ii = 0;ii < MAX_TEMPINVOKEID;ii ++) + { + ism_ptr = (ismvm_data *) &vm_ptr->ism_data[ii]; + if ((ism_ptr->used_flag==1)&&(ism_ptr->linked_iid==iid)) + return ii; + } + } + tcap_send_error("CSL warning.Can not assign a temp invoke id"); + return 0xff; +} + +u8 write_ism(CSLcmp_struct *cmp_ptr) +{ + struct tcapvm_struct *vm_ptr; + struct ismvm_data *ism_ptr; + u8 iid,temp_iid; + u32 did; + + did = cmp_ptr->dialogue_id; + iid = cmp_ptr->invoke_id; + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[did]; + + if (((cmp_ptr->message_type == Invoke) || + (cmp_ptr->message_type == Invoke_L_Ansi) || + (cmp_ptr->message_type == Invoke_NL_Ansi)) && + (cmp_ptr->message_flag == REQUEST)) + temp_iid = find_tempiid(did,iid,1); + else + temp_iid = find_tempiid(did,iid,0); + if (temp_iid == 0xff) // can not find temp iid + { + debug_ptr->watch_dog[252]++; + return 0; + } + ism_ptr = (ismvm_data *) &vm_ptr->ism_data[temp_iid]; + ism_ptr->ism_msgtype = cmp_ptr->message_type; + ism_ptr->ism_msgflag = cmp_ptr->message_flag; + if (((cmp_ptr->message_type == Invoke) || + (cmp_ptr->message_type == Invoke_L_Ansi) || + (cmp_ptr->message_type == Invoke_NL_Ansi)) && + (cmp_ptr->message_flag == REQUEST)) + { + ism_ptr->ism_msgclass = cmp_ptr->cmp_prim.tc_invoke.operation_class; + ism_ptr->ism_oper_domain = cmp_ptr->cmp_prim.tc_invoke.operation_domain; + ism_ptr->ism_oper_family = cmp_ptr->cmp_prim.tc_invoke.operation_family; + ism_ptr->ism_oper_code = cmp_ptr->cmp_prim.tc_invoke.operation_code; + if (cmp_ptr->cmp_prim.tc_invoke.timer != 0) // has invoke time + ism_ptr->ism_timer = cmp_ptr->cmp_prim.tc_invoke.timer*ISM_TIMERHZ; + else + ism_ptr->ism_timer = debug_ptr->default_invtime*ISM_TIMERHZ; + } + else if ((cmp_ptr->message_type == U_Cancel) && (cmp_ptr->message_flag == REQUEST)) + { + debug_ptr->watch_dog[157]++; + ism_ptr->ism_state = TCAP_INIT; + } + else if (((cmp_ptr->message_type == U_Reject) || + (cmp_ptr->message_type == U_Reject_Ansi)) && + (cmp_ptr->message_flag == REQUEST)) + { + if ((cmp_ptr->cmp_prim.tc_reject.problem_type != Invoke_Problem) && + (cmp_ptr->cmp_prim.tc_reject.problem_type != Invoke_Problem_Ansi)) + ism_ptr->ism_state = TCAP_INIT; + } + return 1; +} + +void send_to_cha(u32 proc,u8 *content,u8 data_len) // analyse the component primitive +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLcmp_struct *cmp_ptr; + struct ismvm_data *state_ptr=NULL; + struct TCInvoke_struct *invoke_ptr; + struct TCReject_struct *reject_ptr; + u8 ii; + u8 temp_invid; + u8 flag; + u8 proto_type; + int len = 0; + int sec_len; + int result; + char info_str[1024]; + u8 problem_type,problem_code; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + while (len < data_len) + { + ii = int_ptr->cmprecv_head; + if (((ii + 1) % MAX_CSL_BUF) == int_ptr->cmprecv_tail) + { + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM error. Component buffer is full: %ld",proc); + tcap_send_error(info_str); + } + int_ptr->cmp_recv[ii].last_flag = 1; + return; + } + cmp_ptr = (CSLcmp_struct *) &int_ptr->cmp_recv[ii]; + memset(cmp_ptr,0,sizeof(CSLcmp_struct)); + result = extract_component(cmp_ptr,content+len,proc,&sec_len); + if (sec_len == -1) // structure length is error + { + debug_ptr->watch_dog[249]++; + return; + } + if (result != 0) // syntax is right + { + debug_ptr->watch_dog[248]++; + len += sec_len; + } + if (len == data_len) // this component is the last one + cmp_ptr->last_flag = 1; + temp_invid = cmp_ptr->invoke_id; + if ((cmp_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + switch (cmp_ptr->message_type) + { + case Invoke: + case Invoke_L_Ansi: + case Invoke_NL_Ansi: + if (result == 0) // syntax error + { + if (!proto_type) + { + problem_type = General_Problem; + problem_code = General_Problem_MC; + } + else + { + problem_type = General_Problem_Ansi; + problem_code = General_Problem_MC_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + return; + } + if (!store_iid(proc,temp_invid)) + { + tcap_send_error("CSL error. Duplicate invoke id"); + if (!proto_type) + { + problem_type = Invoke_Problem; + problem_code = Invoke_Problem_DIID; + } + else + { + problem_type = Invoke_Problem_Ansi; + problem_code = Invoke_Problem_DIID_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + return; + } + invoke_ptr = (TCInvoke_struct *) &cmp_ptr->cmp_prim.tc_invoke; + if (invoke_ptr->linkedid_flag == 1) // linked other operation + { + flag = find_tempiid(proc,invoke_ptr->linked_id,0); + if (flag != 0xff) // find temp invoke id + state_ptr = (ismvm_data *) &vm_ptr->ism_data[flag]; + if ((flag == 0xff)||(state_ptr->ism_state!=SENT_STATE1&&state_ptr->ism_state!=SENT_STATE2&&state_ptr->ism_state!=SENT_STATE3&&state_ptr->ism_state!=SENT_STATE4))// the linked ISM is not in sent state + { + tcap_send_error("CSL error. Linked ID is not in use"); + if (!proto_type) + { + problem_type = Invoke_Problem; + problem_code = Invoke_Problem_ULID; + } + else + { + problem_type = Invoke_Problem_Ansi; + problem_code = Invoke_Problem_ULID_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + } + else + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + } + else + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + break; + case Result_NL: + case Result_L: + case Error: + case Result_NL_Ansi: + case Result_L_Ansi: + case Error_Ansi: + if (result == 0) + { + if (check_iid(proc,temp_invid)) // invoke id can search + { + flag = find_tempiid(proc,temp_invid,0); + if (flag != 0xff) + ism_terminate(proc,flag); + if (!proto_type) + { + problem_type = General_Problem; + problem_code = General_Problem_MC; + } + else + { + problem_type = General_Problem_Ansi; + problem_code = General_Problem_MC_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + } + return; + } + flag = find_tempiid(proc,temp_invid,0); + if (flag != 0xff) + state_ptr = (ismvm_data *) &vm_ptr->ism_data[flag]; + if ((flag == 0xff)||(state_ptr->ism_state == TCAP_IDLE)) // invoke id is not active + { + if ((cmp_ptr->message_type == Result_NL) || + (cmp_ptr->message_type == Result_L) || + (cmp_ptr->message_type == Result_NL_Ansi) || + (cmp_ptr->message_type == Result_L_Ansi)) + { + if (!proto_type) + { + problem_type = Return_Result; + problem_code = Return_Result_RRU; + tcap_send_error("CSL error. Return Result is not expected"); + } + else + { + problem_type = Return_Result_Ansi; + problem_code = Return_Result_RRU_Ansi; + tcap_send_error("CSL error. Return Result Ansi is not expected"); + } + } + else + { + if (!proto_type) + { + problem_type = Return_Error; + problem_code = Return_Error_UEE; + tcap_send_error("CSL error. Return Error is not expected"); + } + else + { + problem_type = Return_Error_Ansi; + problem_code = Return_Error_UEE_Ansi; + tcap_send_error("CSL error. Return Error Ansi is not expected"); + } + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + return; + } + if (((cmp_ptr->message_type == Error) || + (cmp_ptr->message_type == Error_Ansi)) && + (debug_ptr->error_switch)) + { + if (cmp_ptr->message_type == Error) + sprintf(info_str,"CSL warning. Return Error received from other machine. Did is %ld, Iid is %d",proc,temp_invid); + else + sprintf(info_str,"CSL warning. Return Error Ansi received from other machine. Did is %ld, Iid is %d",proc,temp_invid); + tcap_send_error(info_str); + } + if (proto_type) + { + if ((cmp_ptr->message_type == Result_NL_Ansi) || + (cmp_ptr->message_type == Result_L_Ansi)) + { + cmp_ptr->cmp_prim.tc_result.operation_flag = 1; + cmp_ptr->cmp_prim.tc_result.operation_domain = state_ptr->ism_oper_domain; + cmp_ptr->cmp_prim.tc_result.operation_family = state_ptr->ism_oper_family; + cmp_ptr->cmp_prim.tc_result.operation_code = state_ptr->ism_oper_code; + } + } + if (!write_ism(cmp_ptr)) + debug_ptr->watch_dog[230] ++; + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + break; + case Reject: + case Reject_Ansi: + reject_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + if (result == 0) // syntax error + { + if (!proto_type) + { + problem_type = General_Problem; + problem_code = General_Problem_MC; + } + else + { + problem_type = General_Problem_Ansi; + problem_code = General_Problem_MC_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + return; + } + if ((reject_ptr->problem_type == Invoke_Problem) || + (reject_ptr->problem_type == Invoke_Problem_Ansi)) // invoke problem type + { + flag = find_tempiid(proc,temp_invid,0); + if (flag != 0xff) + state_ptr = (ismvm_data *) &vm_ptr->ism_data[flag]; + if ((flag == 0xff)||(state_ptr->ism_state == TCAP_IDLE)) // the ism is not active + { + if (proto_type) + cmp_ptr->message_type = R_Reject_Ansi; + else + cmp_ptr->message_type = R_Reject; + } + else + { + ism_terminate(proc,flag); + if ((reject_ptr->problem_code == Invoke_Problem_ULID) || + (reject_ptr->problem_code == Invoke_Problem_ULID_Ansi)) + { + if (proto_type) + cmp_ptr->message_type = R_Reject_Ansi; + else + cmp_ptr->message_type = R_Reject; + } + else + { + if (proto_type) + cmp_ptr->message_type = U_Reject_Ansi; + else + cmp_ptr->message_type = U_Reject; + } + } + } + else + { + if ((reject_ptr->problem_type == General_Problem) || + (reject_ptr->problem_type == General_Problem_Ansi)) + { + if (proto_type) + cmp_ptr->message_type = R_Reject_Ansi; + else + cmp_ptr->message_type = R_Reject; + } + else if ((reject_ptr->problem_type == Return_Result) || + (reject_ptr->problem_type == Return_Result_Ansi)) + { + if ((reject_ptr->problem_code == Return_Result_MP) || + (reject_ptr->problem_code == Return_Result_MP_Ansi)) + { + if (proto_type) + cmp_ptr->message_type = U_Reject_Ansi; + else + cmp_ptr->message_type = U_Reject; + } + else + { + if (proto_type) + cmp_ptr->message_type = R_Reject_Ansi; + else + cmp_ptr->message_type = R_Reject; + } + } + else + { + if ((reject_ptr->problem_code == Return_Error_UIID) || + (reject_ptr->problem_code == Return_Error_UIID_Ansi) || + (reject_ptr->problem_code == Return_Error_REU) || + (reject_ptr->problem_code == Return_Error_REU_Ansi)) + { + if (proto_type) + cmp_ptr->message_type = R_Reject_Ansi; + else + cmp_ptr->message_type = R_Reject; + } + else + { + if (proto_type) + cmp_ptr->message_type = U_Reject_Ansi; + else + cmp_ptr->message_type = U_Reject; + } + } + } + if (debug_ptr->error_switch) + { + if (!proto_type) + sprintf(info_str,"CSL warning. Reject Received from other machine. Did is %ld, Iid is %d",proc,temp_invid); + else + sprintf(info_str,"CSL warning. Reject Ansi Received from other machine. Did is %ld, Iid is %d",proc,temp_invid); + tcap_send_error(info_str); + } + int_ptr->cmprecv_head = (ii + 1) % MAX_CSL_BUF; + break; + default: + if (result == 0) + { + if (!proto_type) + { + problem_type = General_Problem; + problem_code = General_Problem_MC; + } + else + { + problem_type = General_Problem_Ansi; + problem_code = General_Problem_MC_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + return; + } + if (check_iid(proc,temp_invid)) // invoke id can search + { + flag = find_tempiid(proc,temp_invid,0); + if (flag != 0xff) + ism_terminate(proc,flag); + } + if (!proto_type) + { + problem_type = General_Problem; + problem_code = General_Problem_UC; + } + else + { + problem_type = General_Problem_Ansi; + problem_code = General_Problem_UC_Ansi; + } + send_reject_tcu(proc,temp_invid,problem_type,problem_code,proto_type); + break; + } + } +} + +void tcap_uni_request(u32 proc,u8 data_flag) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCUni_struct *tcuni_ptr; + struct TSL_struct tsl_data; + struct TRUni_struct *truni_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type; + u8 temp=0; + u8 cmp_level,sls; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[data_flag]; + tcuni_ptr = (TCUni_struct *) &csl_ptr->dlg_prim.tc_uni; + tsl_data.message_type = csl_ptr->message_type; + tsl_data.message_flag = REQUEST; + if ((csl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + memcpy(&tsl_data.local_add,&tcuni_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,&tcuni_ptr->peer_add,sizeof(SCCP_ADDR)); + truni_ptr = (TRUni_struct *) &tsl_data.tsl_prim.tr_uni; + truni_ptr->dialogue_len = truni_ptr->components_len = 0; + if (tcuni_ptr->dialogue_flag == 1) // has dialogue portion + { + if (!proto_type) + { + pdu_data.dialogue_type = PDU_AUDT; + memcpy(pdu_data.pdu_union.aarq.version,Version_1,2); + } + else + { + pdu_data.dialogue_type = PDU_ASUDT; + pdu_data.pdu_union.asudt.version = Version_Ansi; + } + set_dlgpdu(&pdu_data,&tcuni_ptr->dlg_data); + truni_ptr->dialogue_len = build_dp(truni_ptr->dialogue,&pdu_data,1,proto_type); + cmp_level = 0; + } + else + cmp_level = 1; + ii = tcuni_ptr->component_present; + if (ii != 0) + truni_ptr->components_len = get_from_cha(truni_ptr->components,proc,&temp,ii,cmp_level); + if (temp == 0) // components is not too long + { + vm_ptr->proto_type = proto_type; + sls = proc % TCAP_SLS_NUM; + tcap_to_sccp(&tsl_data,sls,0); + } + else + tcap_send_error("CSL error. Component is too long"); +} + +u8 tcap_uni_indicate(u32 proc,u8 data_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRUni_struct *truni_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCUni_struct *tcuni_ptr; + struct dlgPDU_struct pdu_data; + u8 ii, proto_type; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + truni_ptr = (TRUni_struct *) &tsl_ptr->tsl_prim.tr_uni; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->dlgrecv_head; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + tcuni_ptr = (TCUni_struct *) &csl_ptr->dlg_prim.tc_uni; + memcpy(&tcuni_ptr->local_add,&tsl_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tcuni_ptr->peer_add,&tsl_ptr->peer_add,sizeof(SCCP_ADDR)); + if (truni_ptr->dialogue_len != 0) + { + if ((!proto_type && !extract_dp(&pdu_data,truni_ptr->dialogue,truni_ptr->dialogue_len,proto_type)) || + (!proto_type && (pdu_data.dialogue_type != PDU_AUDT))) + { + tcap_send_error("CSL error. Unidirectional primitive has error PDU type"); + return 0; + } + if ((proto_type && (pdu_data.pdu_union.asudt.version != 0) && + (pdu_data.pdu_union.asudt.version != Version_Ansi)) || + (!proto_type && (memcmp(pdu_data.pdu_union.aarq.version,Version_1,2) != 0))) + { + tcap_send_error("CSL error. Unidirectional primitive has error protocol version"); + return 0; + } + tcuni_ptr->dialogue_flag = 1; + get_dlgpdu(&pdu_data,&tcuni_ptr->dlg_data); + } + if (truni_ptr->components_len > 0) + { + send_to_cha(proc,truni_ptr->components,truni_ptr->components_len); + tcuni_ptr->component_present = 1; + } + else + tcuni_ptr->component_present = 0; + vm_ptr->proto_type = proto_type; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return 1; +} + +u8 tcap_begin_request(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCBegin_struct *tcbegin_ptr; + struct TSL_struct tsl_data; + struct TRBegin_struct *trbegin_ptr; + struct dlgPDU_struct pdu_data; + u8 data_flag; + u8 cmp_level; + u8 ii,proto_type,pabort_cause; + u8 temp=0,sls; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + data_flag = int_ptr->dlgsend_tail; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + int_ptr->dlgsend_tail = (data_flag + 1) % MAX_TSL_BUF; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[data_flag]; + tcbegin_ptr = (TCBegin_struct *) &csl_ptr->dlg_prim.tc_begin; + memcpy(&vm_ptr->local_add,&tcbegin_ptr->local_add,sizeof(SCCP_ADDR)); + tsl_data.message_type = csl_ptr->message_type; + tsl_data.message_flag = REQUEST; + if ((csl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + memcpy(&tsl_data.local_add,&tcbegin_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,&tcbegin_ptr->peer_add,sizeof(SCCP_ADDR)); + trbegin_ptr = (TRBegin_struct *) &tsl_data.tsl_prim.tr_begin; + trbegin_ptr->transaction_id = proc; + trbegin_ptr->dialogue_len = trbegin_ptr->components_len = 0; + if (tcbegin_ptr->dialogue_flag == 1) // has dialogue portion + { + if (!proto_type) + { + vm_ptr->ac_mode = 1; // set AC mode + pdu_data.dialogue_type = PDU_AARQ; + memcpy(pdu_data.pdu_union.aarq.version,Version_1,2); + } + else + { + vm_ptr->ac_mode = 0; + pdu_data.dialogue_type = PDU_ASUDT; + pdu_data.pdu_union.asudt.version = Version_Ansi; + } + set_dlgpdu(&pdu_data,&tcbegin_ptr->dlg_data); + trbegin_ptr->dialogue_len = build_dp(trbegin_ptr->dialogue,&pdu_data,0,proto_type); + } + else + cmp_level = 1; + ii = tcbegin_ptr->component_present; + if (ii != 0) + trbegin_ptr->components_len = get_from_cha(trbegin_ptr->components,proc,&temp,ii,cmp_level); + if (temp != 0) // components is too long + { + tcap_send_error("CSL error. Component is too long"); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_head,proto_type); + debug_ptr->watch_dog[187] ++; + return 0; + } + vm_ptr->proto_type = proto_type; + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][20]++; + if (tcbegin_ptr->peer_add.ip != 0) // has set the SLS by uplayer + { + sls = tcbegin_ptr->peer_add.ip % TCAP_SLS_NUM; + debug_ptr->watch_dog[188] ++; + } + else + sls = proc % TCAP_SLS_NUM; + tcap_to_sccp(&tsl_data,sls,0); + debug_ptr->watch_dog[189] ++; + return 1; +} + +u8 tcap_begin_indicate(u32 proc,u8 data_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRBegin_struct *trbegin_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCBegin_struct *tcbegin_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type; + u8 acn_len=0; + u8 acn[TCAP_ACN_LEN]; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + trbegin_ptr = (TRBegin_struct *) &tsl_ptr->tsl_prim.tr_begin; + memcpy(&vm_ptr->peer_add,&tsl_ptr->peer_add,sizeof(SCCP_ADDR)); + memcpy(&vm_ptr->local_add,&tsl_ptr->local_add,sizeof(SCCP_ADDR)); + vm_ptr->peer_tid = trbegin_ptr->transaction_id; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->dlgrecv_head; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + tcbegin_ptr = (TCBegin_struct *) &csl_ptr->dlg_prim.tc_begin; + memcpy(&tcbegin_ptr->local_add,&vm_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tcbegin_ptr->peer_add,&vm_ptr->peer_add,sizeof(SCCP_ADDR)); + if (trbegin_ptr->dialogue_len != 0) // has dialogue portion + { + if (!proto_type) + { + if (!extract_dp(&pdu_data,trbegin_ptr->dialogue,trbegin_ptr->dialogue_len,proto_type) || pdu_data.dialogue_type != PDU_AARQ) + { + tcap_send_error("CSL error. Begin primitive has error dialogue portion"); + pdu_data.dialogue_type = PDU_ABRT; // build ABORT apdu + pdu_data.pdu_union.abrt.abort_source = ABRTDlg_Service_Provider; + pdu_data.pdu_union.abrt.user_info_len = 0; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + return 0; + } + if (memcmp(pdu_data.pdu_union.aarq.version,Version_1,2) != 0) // protocol is error + { + tcap_send_error("CSL error. Begin primitive has error protocol version"); + acn_len = pdu_data.pdu_union.aarq.acn_len; + memcpy(acn,pdu_data.pdu_union.aarq.acn,acn_len); + pdu_data.dialogue_type = PDU_AARE; + pdu_data.pdu_union.aare.acn_len = acn_len; + memcpy(pdu_data.pdu_union.aare.acn,acn,acn_len); + pdu_data.pdu_union.aare.result = Reject_permanent; + pdu_data.pdu_union.aare.diagnostic_flag = Dialogue_Service_Provider; + pdu_data.pdu_union.aare.diagnostic_type = DSP_NCDP; + pdu_data.pdu_union.aare.user_info_len = 0; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + return 0; + } + } + else + { + extract_dp(&pdu_data,trbegin_ptr->dialogue,trbegin_ptr->dialogue_len,proto_type); + if ((pdu_data.pdu_union.asudt.version != 0) && + (pdu_data.pdu_union.asudt.version != Version_Ansi)) + { + tcap_send_error("CSL error. Ansi Query has error protocol version"); + return 0; + } + } + vm_ptr->ac_mode = 1; + tcbegin_ptr->dialogue_flag = 1; + get_dlgpdu(&pdu_data,&tcbegin_ptr->dlg_data); + } + else + { + tcbegin_ptr->dialogue_flag = 0; + vm_ptr->ac_mode = 0; + } + if (trbegin_ptr->components_len != 0) // has components + { + send_to_cha(proc,trbegin_ptr->components,trbegin_ptr->components_len); + tcbegin_ptr->component_present = 1; + } + else + tcbegin_ptr->component_present = 0; + vm_ptr->proto_type = proto_type; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return 1; +} + +void tcap_con_request(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCContinue_struct *tccon_ptr; + struct TSL_struct tsl_data; + struct TRContinue_struct *trcon_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type; + u8 cmp_level; + u8 temp=0; + u8 data_flag,sls; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + data_flag = int_ptr->dlgsend_tail; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[data_flag]; + tccon_ptr = (TCContinue_struct *) &csl_ptr->dlg_prim.tc_continue; + tsl_data.message_type = csl_ptr->message_type; + tsl_data.message_flag = REQUEST; + if ((csl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + memcpy(&tsl_data.local_add,&vm_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,&vm_ptr->peer_add,sizeof(SCCP_ADDR)); + trcon_ptr = (TRContinue_struct *) &tsl_data.tsl_prim.tr_continue; + trcon_ptr->local_tid = proc; + trcon_ptr->peer_tid = vm_ptr->peer_tid; + trcon_ptr->dialogue_len = trcon_ptr->components_len = 0; + if (tccon_ptr->dialogue_flag == 1) // has dialogue portion + { + if (!proto_type) + { + pdu_data.dialogue_type = PDU_AARE; + memcpy(pdu_data.pdu_union.aarq.version,Version_1,2); + pdu_data.pdu_union.aare.result = Accepted; + pdu_data.pdu_union.aare.diagnostic_flag = Dialogue_Service_User; + pdu_data.pdu_union.aare.diagnostic_type = DSU_N; + } + else + { + pdu_data.dialogue_type = PDU_ASUDT; + pdu_data.pdu_union.asudt.version = Version_Ansi; + } + set_dlgpdu(&pdu_data,&tccon_ptr->dlg_data); + trcon_ptr->dialogue_len = build_dp(trcon_ptr->dialogue,&pdu_data,0,proto_type); + cmp_level = 0; + } + else + cmp_level = 1; + ii = tccon_ptr->component_present; + if (ii != 0) + trcon_ptr->components_len = get_from_cha(trcon_ptr->components,proc,&temp,ii,cmp_level); + if (temp != 0) // components is too long + { + tccon_ptr->component_present -= temp; + tccon_ptr->dialogue_flag = 0; + tcap_send_error("CSL error. component is too long"); + } + else + { + if (data_flag != tcap_dlg_t[proc]) + { + data_flag = tcap_dlg_t[proc]; + debug_ptr->watch_dog[186] ++; + } + int_ptr->dlgsend_tail = (data_flag + 1) % MAX_TSL_BUF; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + } + sls = tcap_get_sls(vm_ptr->peer_tid); + tsl_data.peer_tid_len = vm_ptr->peer_tid_len; //modified by Pierre, 06-08-19 + tcap_to_sccp(&tsl_data,sls,0); +} + +u8 tcap_con_indicate(u32 proc,u8 data_flag,u8 state_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRContinue_struct *trcon_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCContinue_struct *tccon_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type,pabort_cause; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + trcon_ptr = (TRContinue_struct *) &tsl_ptr->tsl_prim.tr_continue; + if (state_flag == TCAP_IS) + { + memcpy(&vm_ptr->peer_add,&tsl_ptr->peer_add,sizeof(SCCP_ADDR)); + vm_ptr->peer_tid = trcon_ptr->peer_tid; + } + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->dlgrecv_head; + if (((ii+1) %MAX_TSL_BUF) == int_ptr->dlgrecv_tail) // buffer is full + { + tcap_send_error("TCAP error. TCAP to TCU buffer is full"); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_tail,proto_type); + send_pabort_sccp(vm_ptr->peer_tid_len, //modified by Pierre, 06-08-19 + vm_ptr->peer_tid,pabort_cause,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + return 0; + } + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + tccon_ptr = (TCContinue_struct *) &csl_ptr->dlg_prim.tc_continue; + if (trcon_ptr->dialogue_len != 0) + { + if (!proto_type) + { + if (state_flag == TCAP_ACTIVE || vm_ptr->ac_mode == 0) + { + tcap_send_error("CSL error. Continue primitive has dialogue portion, but do not need it"); + pdu_data.dialogue_type = PDU_ABRT; + pdu_data.pdu_union.abrt.abort_source = ABRTDlg_Service_Provider; + pdu_data.pdu_union.abrt.user_info_len = 0; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return 0; + } + if (!extract_dp(&pdu_data,trcon_ptr->dialogue,trcon_ptr->dialogue_len,proto_type) || pdu_data.dialogue_type != PDU_AARE) + { + tcap_send_error("CSL error. Continue primitive has error dialogue portion"); + pdu_data.dialogue_type = PDU_ABRT; + pdu_data.pdu_union.abrt.abort_source = ABRTDlg_Service_Provider; + pdu_data.pdu_union.abrt.user_info_len = 0; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return 0; + } + } + else + { + extract_dp(&pdu_data,trcon_ptr->dialogue,trcon_ptr->dialogue_len,proto_type); + if ((pdu_data.pdu_union.asudt.version != 0) && + (pdu_data.pdu_union.asudt.version != Version_Ansi)) + { + tcap_send_error("CSL error. Ansi Conversation has error protocol version"); + return 0; + } + } + tccon_ptr->dialogue_flag = 1; + get_dlgpdu(&pdu_data,&tccon_ptr->dlg_data); + if (trcon_ptr->components_len != 0) + { + send_to_cha(proc,trcon_ptr->components,trcon_ptr->components_len); + tccon_ptr->component_present = 1; + } + else + tccon_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return 1; + } + else + { + tccon_ptr->dialogue_flag = 0; + if (!proto_type) + { + if (state_flag == TCAP_ACTIVE || vm_ptr->ac_mode == 0) + { + if (trcon_ptr->components_len != 0) + { + send_to_cha(proc,trcon_ptr->components,trcon_ptr->components_len); + tccon_ptr->component_present = 1; + } + else + tccon_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return 1; + } + else + { + tcap_send_error("CSL error. Continue primitive has not dialogue portion, but need it"); + pdu_data.dialogue_type = PDU_ABRT; + pdu_data.pdu_union.abrt.abort_source = ABRTDlg_Service_Provider; + pdu_data.pdu_union.abrt.user_info_len = 0; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return 0; + } + } + else + { + if (trcon_ptr->components_len != 0) + { + send_to_cha(proc,trcon_ptr->components,trcon_ptr->components_len); + tccon_ptr->component_present = 1; + } + else + tccon_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return 1; + } + } +} + +u8 tcap_end_request(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCEnd_struct *tcend_ptr; + struct TSL_struct tsl_data; + struct TSL_struct temp_tsl; + struct TRContinue_struct *trcon_ptr; + struct TREnd_struct *trend_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type; + u8 cmp_level; + u8 temp=0; + u8 data_flag,sls; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + data_flag = int_ptr->dlgsend_tail; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[data_flag]; + tcend_ptr = (TCEnd_struct *) &csl_ptr->dlg_prim.tc_end; + if (tcend_ptr->termination == PRE_END) + { + if (data_flag != tcap_dlg_t[proc]) + { + data_flag = tcap_dlg_t[proc]; + debug_ptr->watch_dog[185] ++; + } + int_ptr->dlgsend_tail = (data_flag + 1) % MAX_TSL_BUF; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + return 1; + } + tsl_data.message_type = csl_ptr->message_type; + tsl_data.message_flag = REQUEST; + if ((csl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + memcpy(&tsl_data.local_add,&vm_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&tsl_data.peer_add,&vm_ptr->peer_add,sizeof(SCCP_ADDR)); + trend_ptr = (TREnd_struct *) &tsl_data.tsl_prim.tr_end; + trend_ptr->transaction_id = vm_ptr->peer_tid; + trend_ptr->dialogue_len = trend_ptr->components_len = 0; + if (tcend_ptr->dialogue_flag == 1) // has dialogue portion + { + if (!proto_type) + { + pdu_data.dialogue_type = PDU_AARE; + memcpy(pdu_data.pdu_union.aarq.version,Version_1,2); + pdu_data.pdu_union.aare.result = Accepted; + pdu_data.pdu_union.aare.diagnostic_flag = Dialogue_Service_User; + pdu_data.pdu_union.aare.diagnostic_type = DSU_N; + } + else + { + pdu_data.dialogue_type = PDU_ASUDT; + pdu_data.pdu_union.asudt.version = Version_Ansi; + } + set_dlgpdu(&pdu_data,&tcend_ptr->dlg_data); + trend_ptr->dialogue_len = build_dp(trend_ptr->dialogue,&pdu_data,0,proto_type); + cmp_level = 0; + } + else + cmp_level = 1; + ii = tcend_ptr->component_present; + if (ii != 0) + trend_ptr->components_len = get_from_cha(trend_ptr->components,proc,&temp,ii,cmp_level); + if (temp != 0) // components is too long + { + tcap_send_error("CSL error. component is too long"); + if (!proto_type) + temp_tsl.message_type = Continue; + else + temp_tsl.message_type = Conversation_WithPerm_Ansi; + temp_tsl.message_flag = REQUEST; + memcpy(&temp_tsl.local_add,&vm_ptr->local_add,sizeof(SCCP_ADDR)); + memcpy(&temp_tsl.peer_add,&vm_ptr->peer_add,sizeof(SCCP_ADDR)); + trcon_ptr = (TRContinue_struct *) &temp_tsl.tsl_prim.tr_continue; + trcon_ptr->local_tid = proc; + trcon_ptr->peer_tid = vm_ptr->peer_tid; + trcon_ptr->dialogue_len = trend_ptr->dialogue_len; + memcpy(trcon_ptr->dialogue,trend_ptr->dialogue,trend_ptr->dialogue_len); + trcon_ptr->components_len = trend_ptr->components_len; + memcpy(trcon_ptr->components,trend_ptr->components,trend_ptr->components_len); + tcend_ptr->dialogue_flag = 0; + tcend_ptr->component_present -= temp; + sls = tcap_get_sls(vm_ptr->peer_tid); + tsl_data.peer_tid_len = vm_ptr->peer_tid_len; + tcap_to_sccp(&temp_tsl,sls,0); + return 0; + } + else + { + sls = tcap_get_sls(vm_ptr->peer_tid); + tsl_data.peer_tid_len = vm_ptr->peer_tid_len; + tcap_to_sccp(&tsl_data,sls,0); + if (data_flag != tcap_dlg_t[proc]) + { + data_flag = tcap_dlg_t[proc]; + debug_ptr->watch_dog[184] ++; + } + int_ptr->dlgsend_tail = (data_flag + 1) % MAX_TSL_BUF; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + return 1; + } +} + +void tcap_end_indicate(u32 proc,u8 data_flag,u8 state_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TREnd_struct *trend_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCEnd_struct *tcend_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type,pabort_cause; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + trend_ptr = (TREnd_struct *) &tsl_ptr->tsl_prim.tr_end; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + ii = int_ptr->dlgrecv_head; + if (((ii+1) % MAX_TSL_BUF) == int_ptr->dlgrecv_tail) // buffer is full + { + tcap_send_error("TCAP error. TCAP to TCU buffer is full"); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_tail,proto_type); + return; + } + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + tcend_ptr = (TCEnd_struct *) &csl_ptr->dlg_prim.tc_end; + if (trend_ptr->dialogue_len != 0) + { + if (!proto_type) + { + if (vm_ptr->ac_mode == 0) + { + tcap_send_error("CSL error. End primitive has dialogue portion, but do not need it"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + if (!extract_dp(&pdu_data,trend_ptr->dialogue,trend_ptr->dialogue_len,proto_type) || pdu_data.dialogue_type != PDU_AARE) + { + tcap_send_error("CSL error. End primitive has error dialogue portion"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + } + else + { + extract_dp(&pdu_data,trend_ptr->dialogue,trend_ptr->dialogue_len,proto_type); + if ((pdu_data.pdu_union.asudt.version != 0) && + (pdu_data.pdu_union.asudt.version != Version_Ansi)) + { + tcap_send_error("CSL error. Ansi Response has error protocol version"); + return; + } + } + tcend_ptr->dialogue_flag = 1; + get_dlgpdu(&pdu_data,&tcend_ptr->dlg_data); + if (trend_ptr->components_len != 0) + { + send_to_cha(proc,trend_ptr->components,trend_ptr->components_len); + tcend_ptr->component_present = 1; + } + else + tcend_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return; + } + else + { + tcend_ptr->dialogue_flag = 0; + if (!proto_type) + { + if (state_flag == TCAP_ACTIVE || vm_ptr->ac_mode == 0) + { + if (trend_ptr->components_len != 0) + { + send_to_cha(proc,trend_ptr->components,trend_ptr->components_len); + tcend_ptr->component_present = 1; + } + else + tcend_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return; + } + else + { + tcap_send_error("CSL error. End primitive has not dialogue portion, but need it"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + } + else + { + if (trend_ptr->components_len != 0) + { + send_to_cha(proc,trend_ptr->components,trend_ptr->components_len); + tcend_ptr->component_present = 1; + } + else + tcend_ptr->component_present = 0; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + return; + } + } +} + +void tcap_uabort_request(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCUAbort_struct *tcuabort_ptr; + struct dlgPDU_struct pdu_data; + u8 data_flag; + u8 proto_type; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + data_flag = int_ptr->dlgsend_tail; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + int_ptr->dlgsend_tail = (data_flag + 1) % MAX_TSL_BUF; + tcap_dlg_t[proc] = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[data_flag]; + tcuabort_ptr = (TCUAbort_struct *) &csl_ptr->dlg_prim.tc_uabort; + if ((csl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + if (!proto_type) + { + if (vm_ptr->ac_mode == 1) + { + if (tcuabort_ptr->uabort_reason == UABORT_ACNNS) + { + pdu_data.dialogue_type = PDU_AARE; + memcpy(pdu_data.pdu_union.aare.version,Version_1,2); + set_dlgpdu(&pdu_data,&tcuabort_ptr->dlg_data); + pdu_data.pdu_union.aare.result = Reject_permanent; + pdu_data.pdu_union.aare.diagnostic_flag = Dialogue_Service_User; + pdu_data.pdu_union.aare.diagnostic_type = DSU_ACNNS; + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + } + else if (tcuabort_ptr->dlg_data.user_info_len != 0) + { + pdu_data.dialogue_type = PDU_ABRT; + pdu_data.pdu_union.abrt.abort_source = ABRTDlg_Service_User; + set_dlgpdu(&pdu_data,&tcuabort_ptr->dlg_data); + send_uabort_sccp(proc,&pdu_data,ITU_TCAP,0,NULL); + } + else + send_pabort_sccp(vm_ptr->peer_tid_len, + vm_ptr->peer_tid,P_Abort_NCDP,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + } + else + send_pabort_sccp(vm_ptr->peer_tid_len, + vm_ptr->peer_tid,P_Abort_NCDP,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + } + else + { + pdu_data.dialogue_type = PDU_ASUDT; + pdu_data.pdu_union.asudt.version = Version_Ansi; + set_dlgpdu(&pdu_data,&tcuabort_ptr->dlg_data); + send_uabort_sccp(proc,&pdu_data,proto_type,tcuabort_ptr->uabort_info_len,tcuabort_ptr->uabort_info); + } +} + +void tcap_uabort_indicate(u32 proc,u8 data_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRUAbort_struct *truabort_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCUAbort_struct *tcuabort_ptr; + struct dlgPDU_struct pdu_data; + u8 ii,proto_type,pabort_cause; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + truabort_ptr = (TRUAbort_struct *) &tsl_ptr->tsl_prim.tr_uabort; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + ii = int_ptr->dlgrecv_head; + if (((ii+1) %MAX_TSL_BUF) == int_ptr->dlgrecv_tail) // buffer is full + { + tcap_send_error("TCAP error. TCAP to TCU buffer is full"); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_tail,proto_type); + return; + } + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + tcuabort_ptr = (TCUAbort_struct *) &csl_ptr->dlg_prim.tc_uabort; + if (truabort_ptr->dialogue_len != 0) + { + if (!proto_type) + { + if (vm_ptr->ac_mode == 0) + { + tcap_send_error("CSL error. U_Abort primitive has dialogue portion, but do not need it"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + if (!extract_dp(&pdu_data,truabort_ptr->dialogue,truabort_ptr->dialogue_len,proto_type)) + { + tcap_send_error("CSL error. U_Abort primitive has error dialogue portion"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + } + else + { + extract_dp(&pdu_data,truabort_ptr->dialogue,truabort_ptr->dialogue_len,proto_type); + if ((pdu_data.pdu_union.asudt.version != 0) && + (pdu_data.pdu_union.asudt.version != Version_Ansi)) + { + tcap_send_error("CSL error. Ansi Uabort has error protocol version"); + return; + } + } + tcuabort_ptr->dialogue_flag = 1; + get_dlgpdu(&pdu_data,&tcuabort_ptr->dlg_data); + if (!proto_type) + { + if (pdu_data.dialogue_type == PDU_AARE) + tcuabort_ptr->uabort_reason = UABORT_ACNNS; + else if (pdu_data.dialogue_type == PDU_ABRT) + { + if (pdu_data.pdu_union.abrt.abort_source == ABRTDlg_Service_User) + tcuabort_ptr->uabort_reason = UABORT_NULL; + else + { + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + } + else + { + tcap_send_error("CSL error. U_Abort primitive has error dialogue portion"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + } + } + else + { + if (!proto_type) + { + if (vm_ptr->ac_mode == 1) + { + tcap_send_error("CSL error. U_Abort primitive has not dialogue portion, but need it"); + send_pabort_tcu(proc,P_Abort_ADLG,ii,proto_type); + return; + } + tcuabort_ptr->uabort_reason = UABORT_SPEC; + } + tcuabort_ptr->dialogue_flag = 0; + } + if (proto_type) + { + tcuabort_ptr->uabort_info_len = truabort_ptr->uabort_info_len; + memcpy(tcuabort_ptr->uabort_info, truabort_ptr->uabort_info, truabort_ptr->uabort_info_len); + } + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; +} + +void tcap_pabort_indicate(u32 proc,u8 data_flag) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRPAbort_struct *trpabort_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCPAbort_struct *tcpabort_ptr; + u8 ii,proto_type,pabort_cause; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + trpabort_ptr = (TRPAbort_struct *) &tsl_ptr->tsl_prim.tr_pabort; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + if ((tsl_ptr->message_type & 0xE0) == ANSI_TAG_CLASS_CONS) + proto_type = ANSI_TCAP; + else + proto_type = ITU_TCAP; + ii = int_ptr->dlgrecv_head; + if (((ii+1) %MAX_TSL_BUF) == int_ptr->dlgrecv_tail) // buffer is full + { + tcap_send_error("TCAP error. TCAP to TCU buffer is full"); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_tail,proto_type); + } + else + { + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = tsl_ptr->message_type; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + tcpabort_ptr = (TCPAbort_struct *) &csl_ptr->dlg_prim.tc_pabort; + tcpabort_ptr->pabort_reason = trpabort_ptr->abort_reason; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + } +} + +void tcap_notice_indicate(u32 proc,u8 data_flag,u8 proto_type) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct TRNotice_struct *trnotice_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + struct TCNotice_struct *tcnotice_ptr; + u8 ii,pabort_reason; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[data_flag]; + trnotice_ptr = (TRNotice_struct *) &tsl_ptr->tsl_prim.tr_notice; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + ii = int_ptr->dlgrecv_head; + if (((ii+1) %MAX_TSL_BUF) == int_ptr->dlgrecv_tail) // buffer is full + { + tcap_send_error("TCAP error. TCAP to TCU buffer is full"); + if (!proto_type) + pabort_reason = P_Abort_RL; + else + pabort_reason = P_Abort_RL_Ansi; + send_pabort_tcu(proc,pabort_reason,int_ptr->dlgrecv_tail,proto_type); + } + else + { + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_recv[ii]; + csl_ptr->message_type = Notice; + csl_ptr->message_flag = INDICATE; + csl_ptr->dialogue_id = proc; + tcnotice_ptr = (TCNotice_struct *) &csl_ptr->dlg_prim.tc_notice; + tcnotice_ptr->report_reason = trnotice_ptr->report_cause; + int_ptr->dlgrecv_head = (ii + 1) % MAX_TSL_BUF; + } +} + +void tsm_program(u32 proc) +{ + struct tcapvm_struct *vm_ptr; + struct TSL_struct *tsl_ptr; + struct tcapint_struct *int_ptr; + struct CSLdlg_struct *csl_ptr; + u8 ii,pabort_cause,proto_type; + u8 info[128]; + char info_str[1024]; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + int_ptr = (tcapint_struct *) &tcap_ptr->tcapint_data[proc]; + proto_type = vm_ptr->proto_type; + + switch (vm_ptr->tcap_state) + { + case TCAP_INIT: + tcap_clear_fsm(proc); + free_did(proc); + debug_ptr->watch_dog[217] ++; + vm_ptr->tcap_state = TCAP_IDLE; + break; + case TCAP_IDLE: + if (vm_ptr->tcaprecv_head != vm_ptr->tcaprecv_tail) + { + ii = vm_ptr->tcaprecv_tail; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[ii]; + vm_ptr->tcaprecv_tail = (ii + 1) % MAX_TSL_BUF; + switch (tsl_ptr->message_type) + { + case Begin: + case Query_WithPerm_Ansi: + case Query_WithoutPerm_Ansi: + if (tcap_begin_indicate(proc,ii)) + vm_ptr->tcap_state = TCAP_IR; + else + { + debug_ptr->watch_dog[212] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + vm_ptr->tcap_timer = 0; + break; + case Unidirectional: + case Unidirectional_Ansi: + if (tcap_uni_indicate(proc,ii)) + { + debug_ptr->watch_dog[211] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + else + { + debug_ptr->watch_dog[210] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + vm_ptr->tcap_timer = 0; + break; + default: + sprintf(info, "TSL error. Improper message Received from lower layer in idle state, did: %ld, type: %d", proc, tsl_ptr->message_type); + tcap_send_error(info); + //printf("TSL error. Improper message Received from lower layer in idle state, did: %ld, type: %d", proc, tsl_ptr->message_type); + debug_ptr->watch_dog[225]++; + debug_ptr->watch_dog[73] ++; + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + } + } + else + { + if (int_ptr->dlgsend_head != int_ptr->dlgsend_tail) + { + ii = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[ii]; + switch (csl_ptr->message_type) + { + case Begin: + case Query_WithPerm_Ansi: + case Query_WithoutPerm_Ansi: + debug_ptr->watch_dog[71] ++; + if (tcap_begin_request(proc)) + vm_ptr->tcap_state = TCAP_IS; + else + { + debug_ptr->watch_dog[209] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + vm_ptr->tcap_timer = 0; + break; + case Unidirectional: + case Unidirectional_Ansi: + tcap_uni_request(proc,ii); + vm_ptr->tcap_timer = 0; + debug_ptr->watch_dog[208] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + default: + sprintf(info, "TSL error. Improper message Received from tc user in idle state, did: %ld, type: %d", proc, csl_ptr->message_type); + tcap_send_error(info); + //printf("TSL error. Improper message Received from tc user in idle state, did: %ld, type: %d\n", proc, csl_ptr->message_type); + debug_ptr->watch_dog[224]++; + debug_ptr->watch_dog[73] ++; + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + } + } + } + if (check_did(proc)) + { + if ((vm_ptr->tcap_timer++) >= IDLE_TIMER*TCAP_TIMERHZ) + { + vm_ptr->tcap_timer = 0; + debug_ptr->watch_dog[216] ++; + vm_ptr->tcap_state = TCAP_INIT; + } + } + break; + case TCAP_IR: + if (int_ptr->dlgsend_head != int_ptr->dlgsend_tail) + { + ii = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[ii]; + switch (csl_ptr->message_type) + { + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + debug_ptr->watch_dog[74] ++; + tcap_con_request(proc); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_ACTIVE; + break; + case End: + case Response_Ansi: + debug_ptr->watch_dog[75] ++; + vm_ptr->tcap_timer = 0; + if (tcap_end_request(proc)) + { + debug_ptr->watch_dog[207] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + else + vm_ptr->tcap_state = TCAP_ACTIVE; + break; + case U_Abort: + case U_Abort_Ansi: + debug_ptr->watch_dog[78] ++; + tcap_uabort_request(proc); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + default: + break; + } + } + if ((vm_ptr->tcap_timer++) >= EXPIRE_TIMER*TCAP_TIMERHZ) + { + sprintf(info, "TSL error. timer expired in TCAP_IR state, did: %ld", proc); + tcap_send_error(info); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_sccp(vm_ptr->peer_tid_len, + vm_ptr->peer_tid,pabort_cause,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_head,proto_type); + vm_ptr->tcap_timer = 0; + debug_ptr->watch_dog[206] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + break; + case TCAP_IS: + if (vm_ptr->tcaprecv_head != vm_ptr->tcaprecv_tail) + { + ii = vm_ptr->tcaprecv_tail; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[ii]; + vm_ptr->tcaprecv_tail = (ii + 1) % MAX_TSL_BUF; + switch (tsl_ptr->message_type) + { + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + debug_ptr->watch_dog[80] ++; + vm_ptr->tcap_timer = 0; + if (tcap_con_indicate(proc,ii,TCAP_IS)) + vm_ptr->tcap_state = TCAP_ACTIVE; + else + { + debug_ptr->watch_dog[205] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + break; + case End: + case Response_Ansi: + debug_ptr->watch_dog[81] ++; + tcap_end_indicate(proc,ii,TCAP_IS); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + case U_Abort: + case U_Abort_Ansi: + debug_ptr->watch_dog[82] ++; + tcap_uabort_indicate(proc,ii); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + case P_Abort: + case P_Abort_Ansi: + debug_ptr->watch_dog[83] ++; + tcap_pabort_indicate(proc,ii); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + case Notice: + tcap_notice_indicate(proc,ii,proto_type); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + debug_ptr->watch_dog[204] ++; + break; + default: + break; + } + } + else + { + if (int_ptr->dlgsend_head != int_ptr->dlgsend_tail) + { + ii = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[ii]; + switch (csl_ptr->message_type) + { + case End: + case Response_Ansi: + debug_ptr->watch_dog[75] ++; + vm_ptr->tcap_timer = 0; + if (tcap_end_request(proc)) + { + debug_ptr->watch_dog[203] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + else + vm_ptr->tcap_state = TCAP_ACTIVE; + break; + case U_Abort: + case U_Abort_Ansi: + tcap_uabort_request(proc); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + debug_ptr->watch_dog[202] ++; + break; + default: + break; + } + } + } + if ((vm_ptr->tcap_timer++) >= EXPIRE_TIMER*TCAP_TIMERHZ) + { + sprintf(info, "TSL error. timer expired in TCAP_IS state, did: %ld", proc); + tcap_send_error(info); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; +// send_pabort_sccp(vm_ptr->peer_tid_len,vm_ptr->peer_tid,pabort_cause,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_head,proto_type); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + debug_ptr->watch_dog[201] ++; + } + break; + case TCAP_ACTIVE: + if (vm_ptr->tcaprecv_head != vm_ptr->tcaprecv_tail) + { + ii = vm_ptr->tcaprecv_tail; + tsl_ptr = (TSL_struct *) &vm_ptr->tsl_data[ii]; + vm_ptr->tcaprecv_tail = (ii + 1) % MAX_TSL_BUF; + switch (tsl_ptr->message_type) + { + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + debug_ptr->watch_dog[84] ++; + if (!tcap_con_indicate(proc,ii,TCAP_ACTIVE)) + { + debug_ptr->watch_dog[200] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + vm_ptr->tcap_timer = 0; + break; + case End: + case Response_Ansi: + debug_ptr->watch_dog[86] ++; + tcap_end_indicate(proc,ii,TCAP_ACTIVE); + vm_ptr->tcap_state = TCAP_SUSPEND; + vm_ptr->tcap_timer = 0; + break; + case U_Abort: + case U_Abort_Ansi: + debug_ptr->watch_dog[88] ++; + tcap_uabort_indicate(proc,ii); + vm_ptr->tcap_state = TCAP_SUSPEND; + vm_ptr->tcap_timer = 0; + break; + case P_Abort: + case P_Abort_Ansi: + debug_ptr->watch_dog[90] ++; + tcap_pabort_indicate(proc,ii); + vm_ptr->tcap_state = TCAP_SUSPEND; + vm_ptr->tcap_timer = 0; + break; + case Notice: + tcap_notice_indicate(proc,ii,proto_type); + vm_ptr->tcap_state = TCAP_SUSPEND; + vm_ptr->tcap_timer = 0; + debug_ptr->watch_dog[199] ++; + break; + default: + break; + } + } + else + { + if (int_ptr->dlgsend_head != int_ptr->dlgsend_tail) + { + ii = int_ptr->dlgsend_tail; + csl_ptr = (CSLdlg_struct *) &int_ptr->dlg_send[ii]; + switch (csl_ptr->message_type) + { + case Continue: + case Conversation_WithPerm_Ansi: + case Conversation_WithoutPerm_Ansi: + debug_ptr->watch_dog[85] ++; + vm_ptr->tcap_timer = 0; + tcap_con_request(proc); + break; + case End: + case Response_Ansi: + debug_ptr->watch_dog[87] ++; + vm_ptr->tcap_timer = 0; + if (tcap_end_request(proc)) + { + debug_ptr->watch_dog[198] ++; + vm_ptr->tcap_state = TCAP_SUSPEND; + } + break; + case U_Abort: + case U_Abort_Ansi: + debug_ptr->watch_dog[89] ++; + tcap_uabort_request(proc); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + break; + default: + break; + } + } + } + if ((vm_ptr->tcap_timer++) >= EXPIRE_TIMER*TCAP_TIMERHZ) + { + sprintf(info, "TSL error. timer expired in TCAP_ACTIVE state, did: %ld", proc); + tcap_send_error(info); + if (proto_type) + pabort_cause = P_Abort_RL_Ansi; + else + pabort_cause = P_Abort_RL; + send_pabort_sccp(vm_ptr->peer_tid_len, + vm_ptr->peer_tid,pabort_cause,&vm_ptr->local_add,&vm_ptr->peer_add,proto_type); + send_pabort_tcu(proc,pabort_cause,int_ptr->dlgrecv_head,proto_type); + vm_ptr->tcap_timer = 0; + vm_ptr->tcap_state = TCAP_SUSPEND; + debug_ptr->watch_dog[197] ++; + } + break; + case TCAP_SUSPEND: +// if (check_csldata(proc)) +// vm_ptr->tcap_state = TCAP_INIT; + //if ((vm_ptr->tcap_timer++) >= SUSPEND_TIMER*TCAP_TIMERHZ) + if ((vm_ptr->tcap_timer++) >= 10 ) + { + if (!check_csldata(proc)) + { + sprintf(info_str, "TCAP_SUSPEND error. did: %ld", proc); + tcap_send_error(info_str); + } + vm_ptr->tcap_state = TCAP_INIT; + debug_ptr->watch_dog[215] ++; + } + break; + default: + vm_ptr->tcap_state = TCAP_INIT; + debug_ptr->watch_dog[214] ++; + break; + } +} + +void ism_program(u32 proc) // invocation state machine +{ + register u8 inv_proc,total_iid; + struct tcapvm_struct *vm_ptr; + struct ismvm_data *shm_ptr; + char info_str[1024]; + u8 proto_type,problem_type,problem_code; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + /* + total_iid = (vm_ptr->total_iid+1) ; + if(total_iid> MAX_TEMPINVOKEID) + */ + total_iid = MAX_TEMPINVOKEID ; + + proto_type = vm_ptr->proto_type; + for (inv_proc = 0;inv_proc < total_iid;inv_proc++) + { + shm_ptr = (ismvm_data *) &vm_ptr->ism_data[inv_proc]; + switch (shm_ptr->ism_state) + { + case TCAP_INIT: + free_iid(proc,shm_ptr->linked_iid); //add by daniel on 2006-6-15 + //this problem(call will drop after 4600s) was found in OMT + //it is because of the invoke id occupation do not release after assigned + + //tcap_send_ascout("tcap init free linked_did\r\n"); + memset(shm_ptr,0,sizeof(ismvm_data)); + shm_ptr->ism_state = TCAP_IDLE; + break; + case TCAP_IDLE: + if ((shm_ptr->ism_msgtype == Invoke) || + (shm_ptr->ism_msgtype == Invoke_L_Ansi) || + (shm_ptr->ism_msgtype == Invoke_NL_Ansi)) + { + shm_ptr->ism_msgtype = 0; + switch (shm_ptr->ism_msgclass) + { + case OPERATION_CLASS1: + shm_ptr->ism_state = SENT_STATE1; + break; + case OPERATION_CLASS2: + shm_ptr->ism_state = SENT_STATE2; + break; + case OPERATION_CLASS3: + shm_ptr->ism_state = SENT_STATE3; + break; + case OPERATION_CLASS4: + shm_ptr->ism_state = SENT_STATE4; + break; + default: + shm_ptr->ism_state = SENT_STATE4; + break; + } + } + break; + case SENT_STATE1: + if ((shm_ptr->ism_timer--) == 0) // invocation timer expiry + { + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Invoke timer expired 1. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + send_cancel_tcu(proc,shm_ptr->linked_iid); + shm_ptr->ism_state = TCAP_INIT; + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][71] ++; + debug_ptr->watch_dog[234]++; + } + switch (shm_ptr->ism_msgtype) + { + case Result_L: + case Result_L_Ansi: + case Error: + case Error_Ansi: + shm_ptr->ism_timer = 0; + shm_ptr->ism_state = WAIT_REJECT_STATE; + shm_ptr->ism_msgtype = 0; + break; + case Result_NL: + case Result_NL_Ansi: + case Invoke_NL_Ansi: + shm_ptr->ism_msgtype = 0; + break; + default: + break; + } + break; + case SENT_STATE2: + if ((shm_ptr->ism_timer--) == 0) // invocation timer expiry + { + if (debug_ptr->error_switch) + { + // sprintf(info_str,"ISM warning. Invoke timer expired 2. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + // tcap_send_error(info_str); + } + send_cancel_tcu(proc,shm_ptr->linked_iid); + shm_ptr->ism_state = TCAP_INIT; + debug_ptr->watch_dog[233]++; + } + switch (shm_ptr->ism_msgtype) + { + case Error: + case Error_Ansi: + shm_ptr->ism_timer = 0; + shm_ptr->ism_state = WAIT_REJECT_STATE; + shm_ptr->ism_msgtype = 0; + break; + case Result_L: + case Result_NL: + case Result_L_Ansi: + case Result_NL_Ansi: + if (proto_type) + { + problem_type = Return_Result_Ansi; + problem_code = Return_Result_RRU_Ansi; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Result_Ansi not expected 1. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + else + { + problem_type = Return_Result; + problem_code = Return_Result_RRU; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Result not expected 1. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + send_reject_tcu(proc,shm_ptr->linked_iid,problem_type,problem_code,proto_type); + shm_ptr->ism_state = TCAP_INIT; + break; + default: + break; + } + break; + case SENT_STATE3: + if ((shm_ptr->ism_timer--) == 0) // invocation timer expiry + { + if (debug_ptr->error_switch) + { + // sprintf(info_str,"ISM warning. Invoke timer expire. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + // tcap_send_error(info_str); + } + send_cancel_tcu(proc,shm_ptr->linked_iid); + shm_ptr->ism_state = TCAP_INIT; + debug_ptr->watch_dog[232]++; + } + switch (shm_ptr->ism_msgtype) + { + case Result_L: + case Result_L_Ansi: + shm_ptr->ism_timer = 0; + shm_ptr->ism_state = WAIT_REJECT_STATE; + shm_ptr->ism_msgtype = 0; + break; + case Result_NL: + case Result_NL_Ansi: + shm_ptr->ism_msgtype = 0; + break; + case Error: + case Error_Ansi: + if (proto_type) + { + problem_type = Return_Error_Ansi; + problem_code = Return_Error_REU_Ansi; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Error_Ansi not expected 1. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + else + { + problem_type = Return_Error; + problem_code = Return_Error_REU; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Error not expected 1. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + send_reject_tcu(proc,shm_ptr->linked_iid,problem_type,problem_code,proto_type); + shm_ptr->ism_state = TCAP_INIT; + break; + default: + break; + } + break; + case SENT_STATE4: + if ((shm_ptr->ism_timer--) == 0) // invocation timer expiry + { + if (debug_ptr->error_switch) + { + // sprintf(info_str,"ISM warning. Invoke timer expired 4. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + // tcap_send_error(info_str); + } + send_cancel_tcu(proc,shm_ptr->linked_iid); + shm_ptr->ism_state = TCAP_INIT; + debug_ptr->watch_dog[231]++; + } + switch (shm_ptr->ism_msgtype) + { + case Result_NL: + case Result_L: + case Result_NL_Ansi: + case Result_L_Ansi: + if (proto_type) + { + problem_type = Return_Result_Ansi; + problem_code = Return_Result_RRU_Ansi; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Result_Ansi not expected 2. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + else + { + problem_type = Return_Result; + problem_code = Return_Result_RRU; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Result not expected 2. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + send_reject_tcu(proc,shm_ptr->linked_iid,problem_type,problem_code,proto_type); + shm_ptr->ism_state = TCAP_INIT; + break; + case Error: + case Error_Ansi: + if (proto_type) + { + problem_type = Return_Error_Ansi; + problem_code = Return_Error_REU_Ansi; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Error_Ansi not expected 2. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + else + { + problem_type = Return_Error; + problem_code = Return_Error_REU; + if (debug_ptr->error_switch) + { + sprintf(info_str,"ISM warning. Return_Error not expected 2. Did: %ld, Iid: %d",proc,shm_ptr->linked_iid); + tcap_send_error(info_str); + } + } + send_reject_tcu(proc,shm_ptr->linked_iid,problem_type,problem_code,proto_type); + shm_ptr->ism_state = TCAP_INIT; + break; + default: + break; + } + break; + case WAIT_REJECT_STATE: + if ((shm_ptr->ism_timer++) >= debug_ptr->default_rejtime * ISM_TIMERHZ) + shm_ptr->ism_state = TCAP_INIT; + break; + default: + shm_ptr->ism_state = TCAP_INIT; + break; + } + } +} + +void tcap_change_local_ssn(u32 proc,u8 src_ssn,u8 dst_ssn) +{ + struct tcapvm_struct *vm_ptr; + + if (proc >= (tcap_ptr->grantdid)) + return; + + vm_ptr = (tcapvm_struct *) &tcap_ptr->tcapvm_data[proc]; + if (src_ssn == vm_ptr->local_add.SSN) + vm_ptr->local_add.SSN = dst_ssn; +} +/*@end@*/ diff --git a/omc/plat/tcap/src/tcap_m.c b/omc/plat/tcap/src/tcap_m.c new file mode 100644 index 0000000..0c4dd8d --- /dev/null +++ b/omc/plat/tcap/src/tcap_m.c @@ -0,0 +1,603 @@ +/* TCAP monitor c file */ +/* Written by Liu Zhiguo 2002-05-06 */ +/* Version 1.0 */ +/* ----------------------------------- */ +#include "../../public/src/include/pub_include.h" +#include "../../sccp/src/include/sccp.h" +#include "../../debug/src/include/debug.h" +#include "../../snmp/src/include/snmp.h" +#include "../../snmp/src/include/heartbeat.h" +#include "./include/tcap_public.h" +#include "./include/tcap_struct.h" +#include "./include/idmanage.h" + + +/*@ignore@*/ +#define LED_GREEN 9 +#define LED_YELLOW 10 +#define LED_RED 11 +#define MAX_PAGE 8 +#define MAX_LINE 22 +#define STATE_LINE 20 +#define TCAP_CSTA_INTERVAL 15 // tcap CDR interval time:15 minutes +#define TCAP_PREOBJ_LEN 12 // tcap prefix object id length +#define TCAP_HBOBJ_LEN 14 // tcap heartbeat led object id length +#define TCAP_ID_LEN 15 +#define TCAP_TITLE_LEN 16 +#define TCAP_LINE_LEN 17 +#define TCAP_PAGE_POINT 14 +#define TCAP_LINE_POINT 15 +#define TCAP_VERSION_LEN 3 + +static struct tcapdebug_struct *debug_ptr; +extern u32 tcap_dlg_stats[MAX_DIALOGUEID]; + +static u8 tcap_1s_flag; +static u8 tcap_10s_flag; +static u8 sec_page; +static u8 *disp_ptr; +static u8 tcap_status = 1; +static u32 tcap_object_id[] = {1,3,6,1,4,1,1373,1,3,2,2,4}; +static u32 tcap_status_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,1}; +static u32 tcap_version_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,2}; +static u32 tcap_ascin_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,3}; +static u32 tcap_ascout_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,4}; +static u32 tcap_page_title[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,5,1}; +static u32 tcap_page_line[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,TCAP_MODULE_ID + 2,5,2,2}; +//static u8 tcap_ver[] = {6,5,10}; +static u8 tcap_ver[] = {9,0,6}; +static u8 title1[] = {"Page 01\t\tTCAP module information\r\n\nStart time\r\nCurrent time\r\nInvoke timer\r\nReject timer\r\nMonitor did\r\nTcap status\r\n"}; +static u8 title2[] = {"Page 02\t\tTCAP watch_dog page\r\n\t\t 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15\r\n"}; +static u8 title3[] = {"Page 03\t\tTCAP CSTA information\r\n\t\t 00\t 01\t 02\t 03\t 04\r\nSection page\r\n"}; + +static u8 ascii[16] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, + 0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; + +void HexToDisplay(u8 *to_asc, u8 *from_hex, u8 from_len) +{ + int i, 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'; +} + +void tcap_send_ascout(char *asc_str) +{ + if (debug_ptr->send_control == 1) + return; + if ((strlen(asc_str) + strlen(debug_ptr->ascout_buf)) > TCAP_ASCOUT_LEN/2) // buffer is full + { + debug_ptr->send_control = 1; +// strcat(debug_ptr->ascout_buf,"\r\n--\r\n"); +// strcpy(debug_ptr->ascout_buf,asc_str); + } + else + strcat(debug_ptr->ascout_buf,asc_str); +} + +void tcap_send_error(char *err_str) +{ + char info_str[1024]; + + if (debug_ptr->error_switch == 0 || debug_ptr->send_control == 1) + return; + sprintf(info_str,"\33[31m%s\33[0m\n\r\n\r",err_str); + tcap_send_ascout(info_str); +} + +void tcap_send_info(char *info) +{ + char info_str[1024]; + + if (debug_ptr->sccp_switch == 0 || debug_ptr->send_control == 1) + return; + sprintf(info_str,"%s\n\r",info); + tcap_send_ascout(info_str); +} + +u8 tcap_disp_line(u8 page,u8 line) +{ + u8 line_len=0; + u32 ii; + + disp_ptr = tcap_ver; + switch (page) + { + case 1: // page 1 + switch (line) + { + case 0: + disp_ptr = debug_ptr->start_time; + line_len = 6; + break; + case 1: + disp_ptr = debug_ptr->current_time; + line_len = 6; + break; + case 2: // invoke time + disp_ptr = &debug_ptr->default_invtime; + line_len = 1; + break; + case 3: // reject time + disp_ptr = &debug_ptr->default_rejtime; + line_len = 1; + break; + case 4: // monitor dialogue id + disp_ptr = (u8 *) &debug_ptr->monitor_did; + line_len = 4; + break; + case 5: // heartbeat status + disp_ptr = debug_ptr->hb_status; + line_len = TCAP_HB_LEN; + break; + case 6: + line_len = 8; + disp_ptr = (u8 *)&debug_ptr->local_ip; + break; + default: + line_len = 0; + break; + } + break; + case 2: // page 2 + if (line < 16) + { + disp_ptr = debug_ptr->watch_dog + line * 16; + line_len = 16; + } + break; + case 3: // page 3 + if (line == 0) + { + disp_ptr = &sec_page; + line_len = 1; + } + else if (line < TCAP_UTILIZE_LEN/5+1) + { + ii = sec_page % (TCAP_UTILIZE_COUNT-1); + disp_ptr = (char *)&debug_ptr->tc_utilize[ii][(line-1)*5]; + line_len = 20; + } + break; + case 4: // tcap state + if (line < STATE_LINE) + { + ii = (sec_page * STATE_LINE + line) % (tcap_ptr->grantdid); + disp_ptr = (u8 *) &tcap_ptr->tcapvm_data[ii].peer_tid; + line_len = 20; + } + else if (line == STATE_LINE+1) + { + disp_ptr = &sec_page; + line_len = 1; + } + break; + case 5: // ism state + if (line < MAX_TEMPINVOKEID) + { + ii = sec_page % (tcap_ptr->grantdid); + disp_ptr = (u8 *) &tcap_ptr->tcapvm_data[ii].ism_data[line].used_flag; + line_len = 20; + } + else if (line == MAX_TEMPINVOKEID+1) + { + disp_ptr = &sec_page; + line_len = 1; + } + break; + default: + line_len = 0; + break; + } + return line_len; +} + +void tcap_disp_page(u8 page) +{ + u8 line; + u8 line_len; + + tcap_page_line[TCAP_PAGE_POINT] = page + 5; + for (line = 0;line < MAX_LINE;line ++) + { + line_len = tcap_disp_line(page,line); + tcap_page_line[TCAP_LINE_POINT] = line + 2; + debug_set_response(TCAP_LINE_LEN,tcap_page_line,disp_ptr,line_len); + } +} + +int tcap_snmp_set(u8 oid_len,u32 *oid,u8 *data_buf,u16 data_len) +{ + u8 ii; + + ii = TCAP_PREOBJ_LEN; + if (oid_len < ii+2) + return -1; + switch (oid[ii]) + { + case 2: // set timer + switch (oid[ii+1]) + { + case 1: // set invoke timer + if (data_len == 1) // only one octet + { + debug_ptr->default_invtime = data_buf[0]; + return 1; + } + break; + case 2: // set reject timer + if (data_len == 1) + { + debug_ptr->default_rejtime = data_buf[0]; + return 1; + } + break; + case 3: // set monitor switch + switch (oid[ii+2]) + { + case 1: // monitor SCCP + if (data_len == 1) + { + debug_ptr->sccp_switch = data_buf[0]; + return 1; + } + break; + case 2: // monitor tcu + if (data_len == 1) + { + debug_ptr->tcu_switch = data_buf[0]; + return 1; + } + break; + case 3: // monitor error + if (data_len == 1) + { + debug_ptr->error_switch = data_buf[0]; + return 1; + } + break; + case 4: // monitor dialogue id + if (data_len <= 4) + { + debug_ptr->monitor_did = bcdtou32(data_buf,data_len); + return data_len; + } + break; + default: + break; + } + break; + default: + break; + } + break; + default: + break; + } + return -1; // set fail +} + +int tcap_snmp_get(u8 oid_len,u32 *oid,u8 *data_buf,u8 *data_type) +{ + u8 ii,jj,kk; + int data_len=-1; + + ii = TCAP_PREOBJ_LEN; + if (oid_len <= ii+1) + return -1; + switch (oid[ii]) // judge object id + { + case 1: // measure + if (oid_len != ii + 2) // reach instance, get total measure data + return -1; // not support + if (oid[ii+1] > TCAP_UTILIZE_COUNT-2) + return -1; + if (oid[ii+1] == debug_ptr->current_csta) + return -1; + jj = oid[ii+1]; + if (debug_ptr->csta_time[jj] == 0) + return 0; + u32tobyte(data_buf,debug_ptr->csta_time[jj]); + data_len = 4; + for (kk = 0;kk < TCAP_UTILIZE_LEN;kk ++) + u32tobyte(data_buf+(kk+1)*4,debug_ptr->tc_utilize[jj][kk]); + data_len += TCAP_UTILIZE_LEN * 4; + *data_type = 4; + break; + case 2: // configure + switch (oid[ii+1]) + { + case 1: // invoke timer + data_len = 1; + data_buf[0] = debug_ptr->default_invtime; + *data_type = 2; + break; + case 2: // reject timer + data_len = 1; + data_buf[0] = debug_ptr->default_rejtime; + *data_type = 2; + break; + case 3: // monitro switch + switch (oid[ii+2]) + { + case 1: // sccp switch + data_buf[0] = debug_ptr->sccp_switch; + data_len = 1; + *data_type = 2; + break; + case 2: // tcu switch + data_buf[0] = debug_ptr->tcu_switch; + data_len = 1; + *data_type = 2; + break; + case 3: // error switch + data_buf[0] = debug_ptr->error_switch; + data_len = 1; + *data_type = 2; + break; + case 4: // dialogue id switch + u32tobyte(data_buf,debug_ptr->monitor_did); + data_len = 4; + *data_type = 4; + break; + default: + break; + } + break; + default: + break; + } + break; + case 3: // status + switch (oid[ii+1]) + { + case 1: // get version + data_len = TCAP_VERSION_LEN; + memcpy(data_buf,tcap_ver,data_len); + *data_type = 4; + break; + case 2: // get tcap status + data_len = TCAP_HB_LEN; + memcpy(data_buf,debug_ptr->hb_status,data_len); + *data_type = 4; + break; + default: + break; + } + break; + default: // can not recognize object id + break; + } + return data_len; // get fail +} + +void init_m(void) +{ + u8 page,ii; + char info_str[1024]; + char temp_str[256]; + char *cur_time; + u32 str_len; + + debug_ptr = (tcapdebug_struct *) &tcap_ptr->tcap_debug; + tcap_1s_flag = 0; + tcap_10s_flag = 0; + sec_page = 0; + GetCurrentTime(debug_ptr->start_time); + debug_ptr->ascin_buf[0] = '\0'; + debug_ptr->ascout_buf[0] = '\0'; + debug_set_response(TCAP_ID_LEN,tcap_status_id,&tcap_status,1); // set status id + sprintf(info_str,"R%dV%d_%02d",tcap_ver[0],tcap_ver[1],tcap_ver[2]); + debug_set_response(TCAP_ID_LEN,tcap_version_id,info_str,strlen(info_str)); // set module description + debug_set_response(TCAP_ID_LEN,tcap_ascin_id,debug_ptr->ascin_buf,TCAP_ASCIN_LEN); + debug_set_response(TCAP_ID_LEN,tcap_ascout_id,debug_ptr->ascout_buf,TCAP_ASCOUT_LEN); + for (page = 1;page < MAX_PAGE;page ++) + { + switch (page) + { + case 1: + sprintf(info_str,"Version:R%dV%dT%d\t%s",tcap_ver[0],tcap_ver[1],tcap_ver[2],title1); + str_len = strlen(info_str); + break; + case 2: + sprintf(info_str,"Version:R%dV%dT%d\t%s",tcap_ver[0],tcap_ver[1],tcap_ver[2],title2); + for (ii = 0;ii < 16;ii ++) + { + sprintf(temp_str,"watch_dog%d\r\n",ii*16); + strcat(info_str,temp_str); + } + str_len = strlen(info_str); + break; + case 3: + sprintf(info_str,"Version:R%dV%dT%d\t%s",tcap_ver[0],tcap_ver[1],tcap_ver[2],title3); + for (ii = 0;ii < TCAP_UTILIZE_LEN/5;ii ++) + { + sprintf(temp_str,"Data%d--%d\r\n",ii*5,ii*5+4); + strcat(info_str,temp_str); + } + str_len = strlen(info_str); + break; + case 4: + sprintf(info_str,"Version:R%dV%dT%d\tTCAP state\r\n\n",tcap_ver[0],tcap_ver[1],tcap_ver[2]); + for (ii = 0;ii < STATE_LINE;ii ++) + { + sprintf(temp_str,"TCAP %d\r\n",ii); + strcat(info_str,temp_str); + } + strcat(info_str,"\nCurrent_page\r\n"); + str_len = strlen(info_str); + break; + case 5: + sprintf(info_str,"Version:R%dV%dT%d\tISM state\r\n\n",tcap_ver[0],tcap_ver[1],tcap_ver[2]); + for (ii = 0;ii < MAX_TEMPINVOKEID;ii ++) + { + sprintf(temp_str,"ISM %d\r\n",ii); + strcat(info_str,temp_str); + } + strcat(info_str,"\nCurrent_page\r\n"); + str_len = strlen(info_str); + break; + default: + strcpy(info_str,title1); + str_len = 0; + break; + } + tcap_page_title[TCAP_PAGE_POINT] = page + 5; + debug_set_response(TCAP_TITLE_LEN,tcap_page_title,info_str,str_len); + tcap_disp_page(page); + } + +// init snmp portion +// heartbeat_init(TCAP_SYSTEM_ID); // register tcap heartbeat + inquire_setmsg(TCAP_PREOBJ_LEN,tcap_object_id,tcap_snmp_set); + inquire_getmsg(TCAP_PREOBJ_LEN,tcap_object_id,tcap_snmp_get); + debug_ptr->default_invtime = INVOKE_TIMER; + debug_ptr->default_rejtime = REJECT_TIMER; + + cur_time = GetAsciiTime(); + sprintf(info_str,"TCAP init process completed. Init time is:%s\r",cur_time); + tcap_send_ascout(info_str); +// init_paralport(); // init parallel port +// write_paralport(TCAP_LED_CODE,1); +} + +void tcap_monitor(void) +{ +// u8 page_n; + u32 ii,jj; + u8 *time_ptr; + u16 used_id; + char info_str[1024],temp_info[1024]; + + debug_ptr->send_control = 0; + if (strlen(debug_ptr->ascin_buf) > 0) // has command + { + if (strcmp(debug_ptr->ascin_buf+1,"clear") == 0) + { + memset(debug_ptr->watch_dog,0,256); + memset(tcap_dlg_stats, 0, sizeof(u32) * MAX_DIALOGUEID); + clrcount_did_max(); + } + else if (strncmp(debug_ptr->ascin_buf+1,"go to ",6) == 0) // change section page + { + ii = atol(debug_ptr->ascin_buf+7); + sec_page = ii; + } + else if (strncmp(debug_ptr->ascin_buf+1,"log port ",9) == 0) // monitor the did + { + ii = atol(debug_ptr->ascin_buf+10); + if (ii >= (tcap_ptr->grantdid)) + tcap_send_ascout("The appointed dialogue id is not expected\r\n"); + else + debug_ptr->monitor_did = ii; + } + else if (strcmp(debug_ptr->ascin_buf+1,"list para") == 0)// display parameter + { + tcap_send_ascout("The TCAP system parameters are:\r\n"); + sprintf(info_str,"Invoke timer:%d s\r\nReject timer:%d s\r\n",debug_ptr->default_invtime,debug_ptr->default_rejtime); + tcap_send_ascout(info_str); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log none") == 0)// close all switch + { + debug_ptr->error_switch = 0; + debug_ptr->sccp_switch = 0; + debug_ptr->tcu_switch = 0; + } + else if (strcmp(debug_ptr->ascin_buf+1,"log error on") == 0) + { + debug_ptr->error_switch = 1; + } + else if (strcmp(debug_ptr->ascin_buf+1,"log error off") == 0) + { + debug_ptr->error_switch = 0; + } + else if (strcmp(debug_ptr->ascin_buf+1,"log all") == 0) + { + debug_ptr->error_switch = 1; + debug_ptr->sccp_switch = 1; + debug_ptr->tcu_switch = 1; + } + else if (strcmp(debug_ptr->ascin_buf+1,"log sccp") == 0) + { + debug_ptr->sccp_switch = 1; + tcap_send_ascout("tcap monitoring sccp message switch open\n\r"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log tcu") == 0) + { + debug_ptr->tcu_switch = 1; + } + else if (strncmp(debug_ptr->ascin_buf+1,"help",6) == 0) // display help message + { + sprintf(temp_info,"%d-%02d-%02d %02d:%02d:%02d",debug_ptr->start_time[0]+2000,debug_ptr->start_time[1],debug_ptr->start_time[2],debug_ptr->start_time[3],debug_ptr->start_time[4],debug_ptr->start_time[5]); + sprintf(info_str,"TCAP module R%dV%d_%02d, start time: %s\r\n\n",tcap_ver[0],tcap_ver[1],tcap_ver[2],temp_info); + tcap_send_ascout(info_str); + tcap_send_ascout("Command list:\r\n"); + tcap_send_ascout("log all --------- Turn on all log items\r\n"); + tcap_send_ascout("log none --------- Turn off all log items\r\n"); + tcap_send_ascout("log error on/off --------- Turn on/off error log item\r\n"); + tcap_send_ascout("log tcu --------- Turn on TCAP<->TCUser log item\r\n"); + tcap_send_ascout("log sccp --------- Turn on TCAP<->SCCP log item\r\n"); + tcap_send_ascout("log port [did] ---- Monitor the specified dialogue id\r\n"); + tcap_send_ascout("list para --------- Display TCAP system parameters\r\n"); + } + debug_ptr->ascin_buf[0] = '\0'; + } +/* for (page_n = 1;page_n < MAX_PAGE;page_n ++) + tcap_disp_page(page_n);*/ + if (++tcap_1s_flag > 24) + tcap_1s_flag = 0; + if (tcap_1s_flag == 0) + { + GetCurrentTime(debug_ptr->current_time); + time_ptr = debug_ptr->current_time; + jj = (time_ptr[3]*60+time_ptr[4])/TCAP_CSTA_INTERVAL; + for (ii = 0;ii < TCAP_UTILIZE_LEN;ii ++) + { + if ((time_ptr[4] % TCAP_CSTA_INTERVAL)==0 && time_ptr[5]==0) // clear CDR + { + debug_ptr->tc_utilize[jj][ii] = 0; + debug_ptr->csta_time[jj] = time(NULL); + debug_ptr->current_csta = jj; + } + debug_ptr->tc_utilize[jj][ii] += debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][ii]; + debug_ptr->tc_utilize[TCAP_UTILIZE_COUNT-1][ii] = 0; + } + used_id = chkcount_did_occupied(); + debug_ptr->tc_utilize[jj][21] += used_id; + if (debug_ptr->tc_utilize[jj][23] < used_id) + debug_ptr->tc_utilize[jj][23] = used_id; + if (++tcap_10s_flag > 9) + tcap_10s_flag = 0; + if (tcap_10s_flag == 0) // 10s timer, set tcap status + { + set_led(TCAP_LED_CODE,LED_GREEN); + memcpy(debug_ptr->hb_status,tcap_ver,TCAP_VERSION_LEN); + debug_ptr->hb_status[TCAP_VERSION_LEN] = tcap_status; + debug_ptr->hb_status[TCAP_VERSION_LEN+1] = used_id >> 8; + debug_ptr->hb_status[TCAP_VERSION_LEN+2] = used_id; + used_id = chkcount_did_max(); + debug_ptr->hb_status[TCAP_VERSION_LEN+3] = used_id >> 8; + debug_ptr->hb_status[TCAP_VERSION_LEN+4] = used_id; + set_status(TCAP_MODULE_ID,TCAP_HB_LEN,debug_ptr->hb_status); + //clrcount_did_max(); + } + } +} + +void tcap_send_alarm(u8 alarm_code,u8 alarm_level) +{ + if (alarm_level == 1) // mini alarm + set_led(TCAP_LED_CODE,LED_YELLOW); + else if (alarm_level == 2) // critical alarm + set_led(TCAP_LED_CODE,LED_RED); + set_alarm(TCAP_MODULE_ID,alarm_code); +} +/*@end@*/ diff --git a/omc/plat/xapp/.copyarea.db b/omc/plat/xapp/.copyarea.db new file mode 100644 index 0000000..ebbe1fd --- /dev/null +++ b/omc/plat/xapp/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp +2 +6 +3:doc|2|0|0|0|3be970e4bfa611dc86a4001c23e19543|0 +4:conf|2|0|0|0|38597058bfa611dc86a4001c23e19543|0 +2:ut|2|0|0|0|63497758bfa611dc86a4001c23e19543|0 +3:src|2|0|0|0|3d197138bfa611dc86a4001c23e19543|0 +8:Makefile|1|11d70a46328|b33|2962c360|3c89711cbfa611dc86a4001c23e19543|0 +3:lib|2|0|0|0|3be97100bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/Makefile b/omc/plat/xapp/Makefile new file mode 100644 index 0000000..62f4a5b --- /dev/null +++ b/omc/plat/xapp/Makefile @@ -0,0 +1,95 @@ + +##----------------------------------------------------------## +## ## +## 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 = xapp +TYPE = plat + +DBUG_FLAGS_ADD = +RELS_FLAGS_ADD = + +##Default commonly as below + +BUILD = lib +CFG = debug + +PLT_LIB = +APP_LIB = +LIB_ADD = + +SRC_PATH = ./src/capp ./src/mapp ./src +INC_PATH = ./src/include +PLT_PATH = ../../plat +APP_PATH = ../../app + +OBJ_ADD = +TEST_OBJ_PATH = ../../obj + +##---------------------------------------------------------------------## +##-------------------------------------- +## +## Make configuration(Customer define) +## +##-------------------------------------- + +## CCFLAG_SWITCH = on/off => gcc flag show on/off +## COVER_NEED = yes/no => PTF cover report needed +## COVER_REPORT_PATH = [path ] => PTF cover report path + +CCFLAG_SWITCH = off +COVER_NEED = +COVER_REPORT_PATH = ./ut/ut_doc/output + +##---------------------------------------------------------------------## + + +##-------------------------------------- +## +## include makefile.rules (Do not change) +## +##-------------------------------------- +include Makefile.rules diff --git a/omc/plat/xapp/conf/.copyarea.db b/omc/plat/xapp/conf/.copyarea.db new file mode 100644 index 0000000..830c456 --- /dev/null +++ b/omc/plat/xapp/conf/.copyarea.db @@ -0,0 +1,8 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\conf +2 +4 +12:cap_operation.conf|1|11d70a464dd|4ec|f4364f0|3b5970c8bfa611dc86a4001c23e19543|0 +12:map_operation.conf|1|11d70a464af|c12|5e0a7764|3a2970acbfa611dc86a4001c23e19543|0 +c:cap_acn.conf|1|11d70a46470|f4|779e4b69|39897090bfa611dc86a4001c23e19543|0 +c:map_acn.conf|1|11d70a46422|605|7e51d67d|38e97074bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/conf/cap_acn.conf b/omc/plat/xapp/conf/cap_acn.conf new file mode 100644 index 0000000..b4c3603 --- /dev/null +++ b/omc/plat/xapp/conf/cap_acn.conf @@ -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 00 // assist handoff gsmSSF to gsmSCF +No.3:52 00 // gsmSRF to gsmSCF +No.4:128 00 // gsmSRF to gsmSCF diff --git a/omc/plat/xapp/conf/cap_operation.conf b/omc/plat/xapp/conf/cap_operation.conf new file mode 100644 index 0000000..9a2f118 --- /dev/null +++ b/omc/plat/xapp/conf/cap_operation.conf @@ -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 01 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 diff --git a/omc/plat/xapp/conf/map_acn.conf b/omc/plat/xapp/conf/map_acn.conf new file mode 100644 index 0000000..8e55496 --- /dev/null +++ b/omc/plat/xapp/conf/map_acn.conf @@ -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 01 // 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 + diff --git a/omc/plat/xapp/conf/map_operation.conf b/omc/plat/xapp/conf/map_operation.conf new file mode 100644 index 0000000..16a853c --- /dev/null +++ b/omc/plat/xapp/conf/map_operation.conf @@ -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 \ No newline at end of file diff --git a/omc/plat/xapp/lib/libxapp.a b/omc/plat/xapp/lib/libxapp.a new file mode 100644 index 0000000..a2d7234 Binary files /dev/null and b/omc/plat/xapp/lib/libxapp.a differ diff --git a/omc/plat/xapp/obj/Map_opr.o b/omc/plat/xapp/obj/Map_opr.o new file mode 100644 index 0000000..31c209b Binary files /dev/null and b/omc/plat/xapp/obj/Map_opr.o differ diff --git a/omc/plat/xapp/obj/cap_msg.o b/omc/plat/xapp/obj/cap_msg.o new file mode 100644 index 0000000..7e1a0eb Binary files /dev/null and b/omc/plat/xapp/obj/cap_msg.o differ diff --git a/omc/plat/xapp/obj/cap_msgtype.o b/omc/plat/xapp/obj/cap_msgtype.o new file mode 100644 index 0000000..f45466a Binary files /dev/null and b/omc/plat/xapp/obj/cap_msgtype.o differ diff --git a/omc/plat/xapp/obj/cap_public.o b/omc/plat/xapp/obj/cap_public.o new file mode 100644 index 0000000..eec0811 Binary files /dev/null and b/omc/plat/xapp/obj/cap_public.o differ diff --git a/omc/plat/xapp/obj/conv_prefix.o b/omc/plat/xapp/obj/conv_prefix.o new file mode 100644 index 0000000..20a3ea3 Binary files /dev/null and b/omc/plat/xapp/obj/conv_prefix.o differ diff --git a/omc/plat/xapp/obj/is41_code_auc.o b/omc/plat/xapp/obj/is41_code_auc.o new file mode 100644 index 0000000..7a44987 Binary files /dev/null and b/omc/plat/xapp/obj/is41_code_auc.o differ diff --git a/omc/plat/xapp/obj/is41_code_ms.o b/omc/plat/xapp/obj/is41_code_ms.o new file mode 100644 index 0000000..9a32f5e Binary files /dev/null and b/omc/plat/xapp/obj/is41_code_ms.o differ diff --git a/omc/plat/xapp/obj/is41_code_sms.o b/omc/plat/xapp/obj/is41_code_sms.o new file mode 100644 index 0000000..71848e1 Binary files /dev/null and b/omc/plat/xapp/obj/is41_code_sms.o differ diff --git a/omc/plat/xapp/obj/is41_code_win.o b/omc/plat/xapp/obj/is41_code_win.o new file mode 100644 index 0000000..16bb6d0 Binary files /dev/null and b/omc/plat/xapp/obj/is41_code_win.o differ diff --git a/omc/plat/xapp/obj/is41_coding.o b/omc/plat/xapp/obj/is41_coding.o new file mode 100644 index 0000000..d80e75e Binary files /dev/null and b/omc/plat/xapp/obj/is41_coding.o differ diff --git a/omc/plat/xapp/obj/is41_debug.o b/omc/plat/xapp/obj/is41_debug.o new file mode 100644 index 0000000..9342eca Binary files /dev/null and b/omc/plat/xapp/obj/is41_debug.o differ diff --git a/omc/plat/xapp/obj/is41_init.o b/omc/plat/xapp/obj/is41_init.o new file mode 100644 index 0000000..3ffdebb Binary files /dev/null and b/omc/plat/xapp/obj/is41_init.o differ diff --git a/omc/plat/xapp/obj/map_LCSCode.o b/omc/plat/xapp/obj/map_LCSCode.o new file mode 100644 index 0000000..8738321 Binary files /dev/null and b/omc/plat/xapp/obj/map_LCSCode.o differ diff --git a/omc/plat/xapp/obj/map_code_auc.o b/omc/plat/xapp/obj/map_code_auc.o new file mode 100644 index 0000000..dbb60da Binary files /dev/null and b/omc/plat/xapp/obj/map_code_auc.o differ diff --git a/omc/plat/xapp/obj/map_code_ch.o b/omc/plat/xapp/obj/map_code_ch.o new file mode 100644 index 0000000..18f152d Binary files /dev/null and b/omc/plat/xapp/obj/map_code_ch.o differ diff --git a/omc/plat/xapp/obj/map_code_dlgpdu.o b/omc/plat/xapp/obj/map_code_dlgpdu.o new file mode 100644 index 0000000..5edff0d Binary files /dev/null and b/omc/plat/xapp/obj/map_code_dlgpdu.o differ diff --git a/omc/plat/xapp/obj/map_code_ms.o b/omc/plat/xapp/obj/map_code_ms.o new file mode 100644 index 0000000..a84638f Binary files /dev/null and b/omc/plat/xapp/obj/map_code_ms.o differ diff --git a/omc/plat/xapp/obj/map_code_om.o b/omc/plat/xapp/obj/map_code_om.o new file mode 100644 index 0000000..4788279 Binary files /dev/null and b/omc/plat/xapp/obj/map_code_om.o differ diff --git a/omc/plat/xapp/obj/map_code_sms.o b/omc/plat/xapp/obj/map_code_sms.o new file mode 100644 index 0000000..7596a40 Binary files /dev/null and b/omc/plat/xapp/obj/map_code_sms.o differ diff --git a/omc/plat/xapp/obj/map_code_ss.o b/omc/plat/xapp/obj/map_code_ss.o new file mode 100644 index 0000000..5f98602 Binary files /dev/null and b/omc/plat/xapp/obj/map_code_ss.o differ diff --git a/omc/plat/xapp/obj/map_coding.o b/omc/plat/xapp/obj/map_coding.o new file mode 100644 index 0000000..1a8a189 Binary files /dev/null and b/omc/plat/xapp/obj/map_coding.o differ diff --git a/omc/plat/xapp/obj/map_public.o b/omc/plat/xapp/obj/map_public.o new file mode 100644 index 0000000..3b3e1ef Binary files /dev/null and b/omc/plat/xapp/obj/map_public.o differ diff --git a/omc/plat/xapp/obj/xap_cdmacdr.o b/omc/plat/xapp/obj/xap_cdmacdr.o new file mode 100644 index 0000000..744f5c0 Binary files /dev/null and b/omc/plat/xapp/obj/xap_cdmacdr.o differ diff --git a/omc/plat/xapp/obj/xap_interface.o b/omc/plat/xapp/obj/xap_interface.o new file mode 100644 index 0000000..176d559 Binary files /dev/null and b/omc/plat/xapp/obj/xap_interface.o differ diff --git a/omc/plat/xapp/obj/xap_monitor.o b/omc/plat/xapp/obj/xap_monitor.o new file mode 100644 index 0000000..f1d8e96 Binary files /dev/null and b/omc/plat/xapp/obj/xap_monitor.o differ diff --git a/omc/plat/xapp/obj/xap_provider.o b/omc/plat/xapp/obj/xap_provider.o new file mode 100644 index 0000000..05a9ab1 Binary files /dev/null and b/omc/plat/xapp/obj/xap_provider.o differ diff --git a/omc/plat/xapp/src/.copyarea.db b/omc/plat/xapp/src/.copyarea.db new file mode 100644 index 0000000..1e9a568 --- /dev/null +++ b/omc/plat/xapp/src/.copyarea.db @@ -0,0 +1,18 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\src +2 +e +6:ixap.h|1|11d70a4672f|98b|cdf03166|5ae975ecbfa611dc86a4001c23e19543|0 +b:include.bak|2|0|0|0|51597464bfa611dc86a4001c23e19543|0 +4:capp|2|0|0|0|5d49765cbfa611dc86a4001c23e19543|0 +f:xap_interfunc.h|1|11d70a46625|101|63c54522|57597560bfa611dc86a4001c23e19543|0 +d:xap_monitor.h|1|11d70a465b8|1ea|89569a8f|55897528bfa611dc86a4001c23e19543|0 +d:xap_cdmacdr.c|1|11d70a46654|b483|29a8c0f8|57e9757cbfa611dc86a4001c23e19543|0 +e:xap_provider.h|1|11d70a465f7|1405|1f611f64|56b97544bfa611dc86a4001c23e19543|0 +d:conv_prefix.h|1|11d70a4679c|7d7|3073a435|189e7b93aa0d11dd9db8001c23e19543|0 +f:xap_interface.c|1|11d70a467db|5fb2|5fe03eb7|520f0675e90311dc9871001c23e19543|0 +d:conv_prefix.c|1|11d9047ad2a|67ae|eae796e0|d83ac08bb0a511dd86b5001c23e19543|0 +e:xap_provider.c|1|11d70a46693|1800e|8d8f8e3|302fce00cee611dc81e7001c23e19543|0 +d:xap_monitor.c|1|11d9047ae05|80c5|b432942d|d83ac088b0a511dd86b6001c23e19543|0 +4:mapp|2|0|0|0|87cefb9fac8211dd893a001c23e19543|0 +d:xap_cdmacdr.h|1|11d70a466c2|53ca|d7babf63|591975b4bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/src/capp/.copyarea.db b/omc/plat/xapp/src/capp/.copyarea.db new file mode 100644 index 0000000..fa5227c --- /dev/null +++ b/omc/plat/xapp/src/capp/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\src\capp +2 +8 +d:cap_msgtype.c|1|11d70a4722a|83e9|3ea8ad20|61797704bfa611dc86a4001c23e19543|0 +6:icap.h|1|11d70a471ec|258|2193a696|604976e8bfa611dc86a4001c23e19543|0 +c:cap_public.h|1|11d70a47140|252|3aaac56|5e797694bfa611dc86a4001c23e19543|0 +9:cap_msg.h|1|11d70a4717e|6832|83bf1e6d|5f1976b0bfa611dc86a4001c23e19543|0 +a:cap_head.h|1|11d70a471bd|1325|678a9aaa|5fa976ccbfa611dc86a4001c23e19543|0 +9:cap_msg.c|1|11d70a472a7|d08d|d8d8777c|62a9773cbfa611dc86a4001c23e19543|0 +c:cap_coding.h|1|11d70a47269|8d9|26cdd9b3|62197720bfa611dc86a4001c23e19543|0 +c:cap_public.c|1|11d70a47111|4853|a5a1c16e|5de97678bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/src/capp/cap_coding.h b/omc/plat/xapp/src/capp/cap_coding.h new file mode 100644 index 0000000..3d517fe --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_coding.h @@ -0,0 +1,39 @@ +/* CAP message coding/decoding head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#ifndef _CAP_CODING +#define _CAP_CODING + +#ifndef _SRF_RELEVANT +#define _SRF_RELEVANT +#endif + +int encSubscriberState(u_char sel, char *tagprefix, CapSubscriberState arg, ASN_BUF * asnbuf); +int decSubscriberState(char *tagprefix, CapSubscriberState * parg, ASN_BUF * asnbuf); +int encExt_BasicServiceCode(u_char sel, char *tagprefix, CapExt_BasicServiceCode arg, ASN_BUF * asnbuf); +int decExt_BasicServiceCode(char *tagprefix, CapExt_BasicServiceCode * parg, ASN_BUF * asnbuf); +int encLocationInformation(char *tagprefix, CapLocationInformation arg, ASN_BUF * asnbuf); +int decLocationInformation(char *tagprefix, CapLocationInformation * parg, ASN_BUF * asnbuf); +int encACBCC(struct CapACBCC arg, char *msgbuf, int maxlen); +int decACBCC(char *msgbuf, int msglen, CapACBCC * parg); +int encLegID(u_char sel, char *tagprefix, CapLegID arg, ASN_BUF * asnbuf); +int decLegID(char *tagprefix, CapLegID * parg, ASN_BUF * asnbuf); +int encESIBCSM(char *tagprefix, CapESIBCSM arg, ASN_BUF * asnbuf); +int decESIBCSM(char *tagprefix, CapESIBCSM * parg, ASN_BUF * asnbuf); +int encLocationInformationGPRS(char *tagprefix, CapLocationInformationGPRS arg, ASN_BUF * asnbuf); +int decLocationInformationGPRS(char *tagprefix, CapLocationInformationGPRS * parg, ASN_BUF * asnbuf); +int encESISMS(char *tagprefix, CapESISMS arg, ASN_BUF * asnbuf); +int decESISMS(char *tagprefix, CapESISMS * parg, ASN_BUF * asnbuf); + +#ifdef _SRF_RELEVANT +int encServiceInteractionIndicatorsTwo(char *tagprefix, CapServiceInteractionIndicatorsTwo arg, ASN_BUF * asnbuf); +int decServiceInteractionIndicatorsTwo(char *tagprefix, CapServiceInteractionIndicatorsTwo * parg, ASN_BUF * asnbuf); +int encInformationToSend(char *tagprefix, CapInformationToSend arg, ASN_BUF * asnbuf); +int decInformationToSend(char *tagprefix, CapInformationToSend * parg, ASN_BUF * asnbuf); +int encCollectedInfo(char *tagprefix, CapCollectedInfo arg, ASN_BUF * asnbuf); +int decCollectedInfo(char *tagprefix, CapCollectedInfo * parg, ASN_BUF * asnbuf); +#endif + +#endif diff --git a/omc/plat/xapp/src/capp/cap_head.h b/omc/plat/xapp/src/capp/cap_head.h new file mode 100644 index 0000000..36f5b9c --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_head.h @@ -0,0 +1,151 @@ +#ifndef _CAP_HEAD +#define _CAP_HEAD + +#ifndef _SRF_RELEVANT +#define _SRF_RELEVANT +#endif + +#define CAP_FLAG 0x8a + +#ifndef MAX_ACN_LEN +#define MAX_ACN_LEN TCAP_ACN_LEN +#endif + +#define TV_SSF 100 +#define TV_Wait_Open TV_SSF//1s +#define TV_Wait_Continue (TV_SSF * 5)//5s +#define TV_Wait_Request (TV_SSF * 10)//10s +#define TV_Non_User_Interaction (TV_SSF * 30)//30s +#define TV_Reset TV_SSF +#define TV_Interaction (TV_SSF * 10)//10s +#define TV_TCE 12*(TV_SSF*10) +#define TV_Pending (TV_SSF * 1/2) + +#define ONE_SECOND_TICKS TV_SSF +#define WTRESPONSE_TIMER (10*ONE_SECOND_TICKS) // 10s +#define WTSSF_TIMER (11*ONE_SECOND_TICKS) // 11s + +#define minAChBillingChargingLength 5 +#define maxAChBillingChargingLength 177 +#define minAttributesLength 2 +#define maxAttributesLength 10 +#define maxBearerCapabilityLength 11 +#define minCallResultLength 12 +#define maxCallResultLength 24 +#define minCalledPartyBCDNumberLength 1 +#define maxCalledPartyBCDNumberLength 41 +#define minCalledPartyNumberLength 3 +#define maxCalledPartyNumberLength 12 +#define minCallingPartyNumberLength 2 +#define maxCallingPartyNumberLength 10 +#define minCauseLength 2 +#define maxCauseLength 2 +#define minDigitsLength 2 +#define maxDigitsLength 16 +#define minFCIBillingChargingDataLength 1 +#define maxFCIBillingChargingDataLength 40 +#define minFCIBillingChargingLength 5 +#define maxFCIBillingChargingLength 49 +#define minGenericNumberLength 3 +#define maxGenericNumberLength 11 +#define minIPSSPCapabilitiesLength 1 +#define maxIPSSPCapabilitiesLength 4 +#define minLocationNumberLength 2 +#define maxLocationNumberLength 10 +#define minMessageContentLength 1 +#define maxMessageContentLength 127 +#define minOriginalCalledPartyIDLength 2 +#define maxOriginalCalledPartyIDLength 10 +#define minRedirectingPartyIDLength 2 +#define maxRedirectingPartyIDLength 10 +#define minScfIDLength 2 +#define maxScfIDLength 10 +#define minSCIBillingChargingLength 4 +#define maxSCIBillingChargingLength 69 +#define minTimeAndTimezoneLength 8 +#define maxTimeAndTimezoneLength 8 +#define numOfBCSMEvents 10 +#define numOfExtensions 10 +#define numOfGenericNumbers 5 +#define numOfInfoItems 4 +#define numOfMessageIDs 5 + +#define maxIMSILength 8 +#define maxISDNAddressLength 9 +#define maxcallReferenceNumberLength 8 +#define numOfSMSEvents 10 +#define MAX_EDP_NUM (18+1) +#define MAX_DP_NUM 32 +#define CAP_CONTENT_LEN 256 + +//Operation Code +#define CAP_MSG_TYPE CAP_FLAG + +#define CAP_O_OPEN 0xff +#define CAP_O_END 0xfe +#define CAP_O_UABORT 0xfd +#define CAP_O_PABORT 0xfc +#define CAP_O_NOTICE 0xfb +#define CAP_O_DELIMETER 0xfa +#define CAP_O_ERROR 0xf0 +#define CAP_O_LINK 0xef +#define CAP_O_REFUSE_AC 0xE0 +#define CAP_O_AC_ERROR 0xE1 +#define CAP_OC_Release 0xfe +#define CAP_OC_Error 0xf0 + +#define CAP_OC_InitialDP 0 +#define CAP_OC_AssistRequestInstructions 16 +#define CAP_OC_EstablishTemporaryConnection 17 +#define CAP_OC_DisconnectForwardConnection 18 +#define CAP_OC_ConnectToResource 19 +#define CAP_OC_Connect 20 +#define CAP_OC_ReleaseCall 22 +#define CAP_OC_RequestReportBCSMEvent 23 +#define CAP_OC_EventReportBCSM 24 +#define CAP_OC_Continue 31 +#define CAP_OC_ResetTimer 33 +#define CAP_OC_FurnishChargingInformation 34 +#define CAP_OC_ApplyCharging 35 +#define CAP_OC_ApplyChargingReport 36 +#define CAP_OC_CallInformationReport 44 +#define CAP_OC_CallInformationRequest 45 +#define CAP_OC_SendChargingInformation 46 +#define CAP_OC_PlayAnnouncement 47 +#define CAP_OC_PromptAndCollectUserInformation 48 +#define CAP_OC_SpecializedResourceReport 49 +#define CAP_OC_Cancel 53 +#define CAP_OC_ActivityTest 55 +#define CAP_OC_ApplyWarningTone 128 //self define +#define CAP_OC_CCF_Continue 129 //self define + +#define CAP_OC_InitialDPSMS 60 +#define CAP_OC_FurnishChargingInformationSMS 61 +#define CAP_OC_ConnectSMS 62 +#define CAP_OC_RequestReportSMSEvent 63 +#define CAP_OC_EventReportSMS 64 +#define CAP_OC_ContinueSMS 65 +#define CAP_OC_ReleaseSMS 66 +#define CAP_OC_ResetTimerSMS 67 + +#ifdef _SRF_RELEVANT +//CAP Operation Type +#define CAP_REQUEST 0x01 +#define CAP_INDICATE 0x02 +#define CAP_RESPONSE 0x03 +#define CAP_CONFIRM 0x04 +#endif + +/* defined for VPS interface */ +#define CAP_OC_VPSOprRequest 0xb0 +#ifndef _SRF_RELEVANT +#define CAP_OC_PlayAnnouncement 0xb1 +#endif + +#define maxVPSCallingLen 8 +#define maxVPSCalledLen 16 +#define maxVPSInfoLen 64 + +#define CAP_ACN_VPSREQUEST 0x80 + +#endif diff --git a/omc/plat/xapp/src/capp/cap_msg.c b/omc/plat/xapp/src/capp/cap_msg.c new file mode 100644 index 0000000..a3bed09 --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_msg.c @@ -0,0 +1,1513 @@ + +/************************************************/ +/*Title: capmsg.c */ +/*Descr: Encode/Decode Cap Message */ +/*Author: Liang Hanxi */ +/*Create: 2002-10-31 */ +/*Modify: 2002-12-4 */ + +/************************************************/ + +#include "../../../public/src/include/pub_include.h" +#include "cap_head.h" +#include "cap_msg.h" +#include "cap_coding.h" + +/*++++++++++++++++++++++++++++++++++++++ */ +/*Cancel-------------------------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eCancel(struct CapCancel caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + + AsnEncode(msgbuf, maxlen, &asnbuf); + switch (caparg.ch) + { + case 0: + return AddInteger("2", caparg.invokeID, 0, &asnbuf); + case 1: + return add_null("5", 0, &asnbuf); + default: + return -1; + } +} + +int dCancel(char *msgbuf, int msglen, PCapCancel pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if(GetInteger("2", (int *)&pcaparg->invokeID, 0, &asnbuf) >= 0) + { + pcaparg->ch = 0; + return 1; + } + else if(GetTLV("5", 1, &pcaparg->allRequest, 0, &asnbuf) >= 0) + { + pcaparg->ch = 1; + return 1; + } + return -1; +} + +/*************************************/ +/*InitialDP-------------------------> */ + +/*************************************/ +int eInitialDP(struct CapInitialDP caparg, char *msgbuf, int maxlen,u8 version) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + retval = AddInteger("16.0", caparg.serviceKey, 0x80, &asnbuf); + //optional part + if(check_bit(caparg.optional_flag, 0)) + { + if((retval = AddTLV("16.2", caparg.calledPartyNumber[0], caparg.calledPartyNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = AddTLV("16.3", caparg.callingPartyNumber[0], caparg.callingPartyNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 2)) + { + if((retval = AddTLV("16.5", 1, &caparg.callingPartysCategory, 0x80, &asnbuf)) < 0) + return -1; + } + if( version > 1 ) + { + if(check_bit(caparg.optional_flag, 3)) + { + if((retval = AddTLV("16.8", caparg.iPSSPCapabilities[0], caparg.iPSSPCapabilities + 1, 0x80, &asnbuf)) < 0) + return -1; + } + } + if(check_bit(caparg.optional_flag, 4)) + { + if((retval = AddTLV("16.10", caparg.locationNumber[0], caparg.locationNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 5)) + { + if((retval = AddTLV("16.12", caparg.originalCalledPartyID[0], caparg.originalCalledPartyID + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 7)) + { + if((retval = AddTLV("16.23", caparg.highLayerCompatibility[0], caparg.highLayerCompatibility + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 8)) + { + if((retval = AddTLV("16.25", caparg.additionalCallingPartyNumber[0], caparg.additionalCallingPartyNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 9)) + { + if((retval = AddTLV("16.27.0", caparg.bearerCapability.bearerCap[0], caparg.bearerCapability.bearerCap + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 10)) + { + if((retval = AddInteger("16.28", caparg.eventTypeBCSM, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 11)) + { + if((retval = AddTLV("16.29", caparg.redirectingPartyID[0], caparg.redirectingPartyID + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 12)) + { + if((retval = AddTLV("16.30", caparg.redirectionInformation[0], caparg.redirectionInformation + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 13)) + { + if((retval = AddTLV("16.50", caparg.iMSI[0], caparg.iMSI + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 14)) + { + if((retval = encSubscriberState(caparg.subscriberState_ch, "16.51", caparg.subscriberState, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 15)) + { + if((retval = encLocationInformation("16.52", caparg.locationInformation, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 16)) + { + if((retval = encExt_BasicServiceCode(caparg.ext_basicServiceCode_ch, "16.53", caparg.ext_basicServiceCode, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 17)) + { + if((retval = AddTLV("16.54", caparg.callReferenceNumber[0], caparg.callReferenceNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if( version >1 ) + { + if(check_bit(caparg.optional_flag, 18)) + { + if((retval = AddTLV("16.55", caparg.mscAddress[0], caparg.mscAddress + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 19)) + { + if((retval = AddTLV("16.56", caparg.calledPartyBCDNumber[0], caparg.calledPartyBCDNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 20)) + { + if((retval = AddTLV("16.57", caparg.timeAndTimezone[0], caparg.timeAndTimezone + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 21)) + { + if((retval = AddTLV("16.58", 0, &caparg.gsm_ForwardingPending, 0x80, &asnbuf)) < 0) + return -1; + } + } + return retval; +} + +int dInitialDP(char *msgbuf, int msglen, PCapInitialDP pcaparg , u8 version ) +{ + ASN_BUF asnbuf; + int temp, sel, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &temp, &asnbuf)) < 0) + { + return -1; + } + if(GetInteger("16.0", &pcaparg->serviceKey, 0x80, &asnbuf) < 0) //serviceKey + return -1; + //optional part + //called party number============> + if((len = GetTLV("16.2", maxCalledPartyNumberLength, pcaparg->calledPartyNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + pcaparg->calledPartyNumber[0] = len; + } + //calling party number============> + if((len = GetTLV("16.3", maxCallingPartyNumberLength, pcaparg->callingPartyNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 1); + pcaparg->callingPartyNumber[0] = len; + } + //calling party category============> + if((len = GetTLV("16.5", 1, &pcaparg->callingPartysCategory, 0x80, &asnbuf)) > 0) + set_bit(pcaparg->optional_flag, 2); + if( version >1 ) + { + //IPSSPCapabilities============> + if((len = GetTLV("16.8", maxIPSSPCapabilitiesLength, pcaparg->iPSSPCapabilities + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 3); + pcaparg->iPSSPCapabilities[0] = len; + } + } + //LocationNumber============> + if((len = GetTLV("16.10", maxLocationNumberLength, pcaparg->locationNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 4); + pcaparg->locationNumber[0] = len; + } + //OriginalCalledPartyID============> + if((len = GetTLV("16.12", maxOriginalCalledPartyIDLength, pcaparg->originalCalledPartyID + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 5); + pcaparg->originalCalledPartyID[0] = len; + } + //highLayerCompatibility============> + if((len = GetTLV("16.23", 2, pcaparg->highLayerCompatibility + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 7); + pcaparg->highLayerCompatibility[0] = len; + } + //additionalCallingPartyNumber============> + if((len = GetTLV("16.25", maxDigitsLength, pcaparg->additionalCallingPartyNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 8); + pcaparg->additionalCallingPartyNumber[0] = len; + } + //bearerCapability============> + if((len = GetTLV("16.27.0", maxBearerCapabilityLength, pcaparg->bearerCapability.bearerCap + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 9); + pcaparg->bearerCapability.bearerCap[0] = len; + } + //eventTypeBCSM============> + if((len = GetInteger("16.28", (int *)&pcaparg->eventTypeBCSM, 0x80, &asnbuf)) > 0) + set_bit(pcaparg->optional_flag, 10); + //redirectingPartyID============> + if((len = GetTLV("16.29", maxRedirectingPartyIDLength, pcaparg->redirectingPartyID + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 11); + pcaparg->redirectingPartyID[0] = len; + } + //redirectingPartyID============> + if((len = GetTLV("16.30", 2, pcaparg->redirectionInformation + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 12); + pcaparg->redirectionInformation[0] = len; + } + //iMSI============> + if((len = GetTLV("16.50", maxIMSILength, pcaparg->iMSI + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 13); + pcaparg->iMSI[0] = len; + } + //subscriberState============> + if((sel = decSubscriberState("16.51", &pcaparg->subscriberState, &asnbuf)) >= 0) + { + set_bit(pcaparg->optional_flag, 14); + pcaparg->subscriberState_ch = sel; + } + //locationInformation============> + if(decLocationInformation("16.52", &pcaparg->locationInformation, &asnbuf) >= 0) + set_bit(pcaparg->optional_flag, 15); + //ext_basicServiceCode============> + if((sel = decExt_BasicServiceCode("16.53", &pcaparg->ext_basicServiceCode, &asnbuf)) >= 0) + { + set_bit(pcaparg->optional_flag, 16); + pcaparg->ext_basicServiceCode_ch = sel; + } + //callReferenceNumber============> + if((len = GetTLV("16.54", maxcallReferenceNumberLength, pcaparg->callReferenceNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 17); + pcaparg->callReferenceNumber[0] = len; + } + if( version >1 ) + { + //mscAddress============> + if((len = GetTLV("16.55", maxISDNAddressLength, pcaparg->mscAddress + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 18); + pcaparg->mscAddress[0] = len; + } + //calledPartyBCDNumber============> + if((len = GetTLV("16.56", maxCalledPartyBCDNumberLength, pcaparg->calledPartyBCDNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 19); + pcaparg->calledPartyBCDNumber[0] = len; + } + //timeAndTimezone============> + if((len = GetTLV("16.57", maxTimeAndTimezoneLength, pcaparg->timeAndTimezone + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 20); + pcaparg->timeAndTimezone[0] = len; + } + //gsm_ForwardingPending============> + if((len = GetTLV("16.58", 1, &pcaparg->gsm_ForwardingPending, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 21); + } + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*ApplyCharging------------------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eApplyCharging(struct CapApplyCharging caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1, len; + u_char bill_info[256]; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((len = encACBCC(caparg.ACBCC, bill_info, 256)) < 0) + return -1; + if((retval = AddTLV("16.0", len, bill_info, 0x80, &asnbuf)) < 0) + return -1; + if((retval = AddTLV("16.2.0", 1, &caparg.partyToCharge, 0x80, &asnbuf)) < 0) + return -1; + return retval; +} + +int dApplyCharging(char *msgbuf, int msglen, PCapApplyCharging pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + u_char bill_info[256]; + + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetTLV("16.0", 256, bill_info, 0x80, &asnbuf)) < 0) + return -1; + if(decACBCC(bill_info, len, &pcaparg->ACBCC) < 0) + return -1; + if((len = GetTLV("16.2.0", 1, &pcaparg->partyToCharge, 0x80, &asnbuf)) < 0) + return -1; + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*RequestReportBCSMEvent--------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eRequestReportBCSMEvent(struct CapRequestReportBCSMEvent caparg, char *msgbuf, int maxlen, int version) +{ + ASN_BUF asnbuf; + int retval = -1, index = 0; + char tagseq[32]; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + for(index = 0; index < caparg.bcsmEvents_num; index++) + { + sprintf(tagseq, "16.0.16-%d", index + 1); + add_null(tagseq, 0x20, &asnbuf); + sprintf(tagseq, "16.0.16-%d.0", index + 1); //eventTypeBCSM + if((retval = AddInteger(tagseq, caparg.bcsmEvents[index].eventTypeBCSM, 0x80, &asnbuf)) < 0) + return -1; + sprintf(tagseq, "16.0.16-%d.1", index + 1); //monitorMode + if((retval = AddInteger(tagseq, caparg.bcsmEvents[index].monitorMode, 0x80, &asnbuf)) < 0) + return -1; + sprintf(tagseq, "16.0.16-%d.2", index + 1); //LegID + if(check_bit(caparg.bcsmEvents[index].optional_flag, 0)) //LegID + { + if((retval = encLegID(caparg.bcsmEvents[index].legID_ch, tagseq, caparg.bcsmEvents[index].legID, &asnbuf)) < 0) + return -1; + } + if(version != 1) + { + sprintf(tagseq, "16.0.16-%d.30.1", index + 1); //dPSpecificCriteria(applicationTimer) + if(check_bit(caparg.bcsmEvents[index].optional_flag, 1)) //LegID + { + if((retval = AddInteger(tagseq, caparg.bcsmEvents[index].dPSpecificCriteria.applicationTimer, 0x80, &asnbuf)) < 0) + return -1; + } + } + } + return retval; +} + +int dRequestReportBCSMEvent(char *msgbuf, int msglen, PCapRequestReportBCSMEvent pcaparg, int version) +{ + ASN_BUF asnbuf; + int errpos, sel, len, index = 0; + char tagseq[32]; + CapBCSMEvent *pevent; + + pcaparg->bcsmEvents_num = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + do + { + pevent = &pcaparg->bcsmEvents[index]; + pevent->optional_flag = 0; + sprintf(tagseq, "16.0.16-%d.0", index + 1); //eventTypeBCSM + if((len = GetInteger(tagseq, (int *)&pevent->eventTypeBCSM, 0x80, &asnbuf)) < 0) + break; + sprintf(tagseq, "16.0.16-%d.1", index + 1); //monitorMode + if((len = GetInteger(tagseq, (int *)&pevent->monitorMode, 0x80, &asnbuf)) < 0) + break; + sprintf(tagseq, "16.0.16-%d.2", index + 1); //LegID + if((sel = decLegID(tagseq, &pevent->legID, &asnbuf)) >= 0) + { + set_bit(pevent->optional_flag, 0); + pevent->legID_ch = sel; + } + if(version != 1) + { + sprintf(tagseq, "16.0.16-%d.30.1", index + 1); //dPSpecificCriteria(applicationTimer) + if((len = GetInteger(tagseq, (int *)&pevent->dPSpecificCriteria.applicationTimer, 0x80, &asnbuf)) > 0) + { + set_bit(pevent->optional_flag, 1); + } + } + } + while(++index < numOfBCSMEvents); + if((pcaparg->bcsmEvents_num = index) < 1) + return -1; + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*EventReportBCSM--------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eEventReportBCSM(struct CapEventReportBCSM caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((retval = AddInteger("16.0", caparg.eventTypeBCSM, 0x80, &asnbuf)) < 0) + return -1; + if(check_bit(caparg.optional_flag, 0)) //eventSpecificInformationBCSM + { + if((retval = encESIBCSM("16.2", caparg.eventSpecificInformationBCSM, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) //legID + { + if((retval = AddTLV("16.3.1", 1, &caparg.legID, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 2)) //legID + { + if((retval = AddInteger("16.4.0", caparg.miscCallInfo.messageType, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dEventReportBCSM(char *msgbuf, int msglen, PCapEventReportBCSM pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetInteger("16.0", (int *)&pcaparg->eventTypeBCSM, 0x80, &asnbuf)) < 0) + return -1; + if((len = decESIBCSM("16.2", &pcaparg->eventSpecificInformationBCSM, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + //pcaparg->eventSpecificInformationBCSM_ch = sel; + } + if((len = GetTLV("16.3.1", 1, &pcaparg->legID, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 1); + + if((len = GetInteger("16.4.0", (int *)&pcaparg->miscCallInfo.messageType, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 2); + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*Apply Charging Report-------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eApplyChargingReport(CapApplyChargingReport caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int len = -1; + u_char callresult[256]; + + //CAMEL-CallResult-timeDurationCharging + AsnEncode(callresult, 256, &asnbuf); + if((len = AddTLV("0.0.1", 1, &caparg.partyToCharge, 0x80, &asnbuf)) < 0) + return -1; + switch (caparg.timeInformation_ch) + { + case 0: + if((len = AddInteger("0.1.0", caparg.timeInformation.timeIfNoTariffSwitch, 0x80, &asnbuf)) < 0) + return -1; + break; + case 1: + if((len = AddInteger("0.1.1.0", caparg.timeInformation.timeIfTariffSwitch.timeSinceTariffSwitch, 0x80, &asnbuf)) < 0) + return -1; + if((len = AddInteger("0.1.1.1", caparg.timeInformation.timeIfTariffSwitch.tariffSwitchInterval, 0x80, &asnbuf)) < 0) + return -1; + break; + } + if((len = AddTLV("0.2", 1, &caparg.callActive, 0x80, &asnbuf)) < 0) + return -1; + //ApplyChargingReportArg + AsnEncode(msgbuf, maxlen, &asnbuf); + if((len = AddTLV("4", len, callresult, 0, &asnbuf)) < 0) + return -1; + return len; +} + +int dApplyChargingReport(char *msgbuf, int msglen, PCapApplyChargingReport pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + short tagcode; + u_char callresult[256], temp[64]; + + //ApplyChargingReportArg + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetTLV("4", 256, callresult, 0, &asnbuf)) < 0) + return -1; + //CAMEL-CallResult-timeDurationCharging + if(AsnDecode(callresult, len, 1, &errpos, &asnbuf) < 0) + { + return -1; + } + if((len = GetTLV("0.0.1", 1, &pcaparg->partyToCharge, 0x80, &asnbuf)) < 0) + return -1; + + if((len = GetAnyTLV("0.1.-1", 64, temp, NULL, &tagcode, &asnbuf)) < 0) + return -1; + + switch (tagcode) + { + case 0: + pcaparg->timeInformation_ch = 0; + if((len = GetInteger("0.1.0", (int *)&pcaparg->timeInformation.timeIfNoTariffSwitch, 0x80, &asnbuf)) < 0) + return -1; + break; + case 1: + pcaparg->timeInformation_ch = 1; + if((len = GetInteger("0.1.1.0", (int *)&pcaparg->timeInformation.timeIfTariffSwitch.timeSinceTariffSwitch, 0x80, &asnbuf)) < 0) + return -1; + if((len = GetInteger("0.1.1.1", (int *)&pcaparg->timeInformation.timeIfTariffSwitch.tariffSwitchInterval, 0x80, &asnbuf)) < 0) + return -1; + break; + } + if((len = GetTLV("0.2", 1, &pcaparg->callActive, 0x80, &asnbuf)) < 0) + return -1; + return 1; +} + +int eReleaseCall(CapReleaseCall caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int reval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + reval = AddTLV("4", caparg.cause[0], caparg.cause + 1, 0, &asnbuf); + return reval; +} + +int dReleaseCall(char *msgbuf, int msglen, PCapReleaseCall pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + if(AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf) < 0) + { + return -1; + } + if((len = GetTLV("4", maxCauseLength, pcaparg->cause + 1, 0, &asnbuf)) > 0) + { + pcaparg->cause[0] = len; + return 1; + } + else + return -1; +} + +/*************************************/ +/*InitialDPSMS----------------------> */ + +/*************************************/ +int eInitialDPSMS(struct CapInitialDPSMS caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + retval = AddInteger("16.0", caparg.serviceKey, 0x80, &asnbuf); + //optional part + if(check_bit(caparg.optional_flag, 0)) + { + if((retval = AddTLV("16.1", caparg.destinationSubscriberNumber[0], caparg.destinationSubscriberNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = AddTLV("16.2", caparg.callingPartyNumber[0], caparg.callingPartyNumber + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 2)) + { + if((retval = AddInteger("16.3", caparg.eventTypeSMS, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 3)) + { + if((retval = AddTLV("16.4", caparg.iMSI[0], caparg.iMSI + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 4)) + { + if((retval = encLocationInformation("16.5", caparg.locationInformation, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 5)) + { + if((retval = encLocationInformationGPRS("16.6", caparg.locationInformationGPRS, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 6)) + { + if((retval = AddTLV("16.7", caparg.sMSCAddress[0], caparg.sMSCAddress + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 7)) + { + if((retval = AddTLV("16.8", caparg.timeAndTimezone[0], caparg.timeAndTimezone + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 8)) + { + if((retval = AddTLV("16.9", 1, &caparg.tPShortMessageSubmissionInfo, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 9)) + { + if((retval = AddTLV("16.10", 1, &caparg.tPProtocolIdentifier, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 10)) + { + if((retval = AddTLV("16.11", 1, &caparg.tPDataCodingScheme + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 11)) + { + if((retval = AddTLV("16.12", caparg.tPValidityPeriod[0], caparg.tPValidityPeriod + 1, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dInitialDPSMS(char *msgbuf, int msglen, PCapInitialDPSMS pcaparg) +{ + ASN_BUF asnbuf; + int temp, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &temp, &asnbuf)) < 0) + return -1; + //serviceKey==============> + if(GetInteger("16.0", &pcaparg->serviceKey, 0x80, &asnbuf) < 0) + return -1; + //optional part + //destinationSubscriberNumber============> + if((len = GetTLV("16.1", maxCalledPartyBCDNumberLength, pcaparg->destinationSubscriberNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + pcaparg->destinationSubscriberNumber[0] = len; + } + //calling party number============> + if((len = GetTLV("16.2", maxISDNAddressLength, pcaparg->callingPartyNumber + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 1); + pcaparg->callingPartyNumber[0] = len; + } + //eventTypeSMS============> + if((len = GetInteger("16.3", (int *)&pcaparg->eventTypeSMS, 0x80, &asnbuf)) > 0) + set_bit(pcaparg->optional_flag, 2); + //iMSI============> + if((len = GetTLV("16.4", maxIMSILength, pcaparg->iMSI + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 3); + pcaparg->iMSI[0] = len; + } + //locationInformation============> + if(decLocationInformation("16.5", &pcaparg->locationInformation, &asnbuf) >= 0) + set_bit(pcaparg->optional_flag, 4); + //locationInformationGPRS============> + if(decLocationInformationGPRS("16.6", &pcaparg->locationInformationGPRS, &asnbuf) >= 0) + set_bit(pcaparg->optional_flag, 5); + //sMSCAddress============> + if((len = GetTLV("16.7", maxISDNAddressLength, pcaparg->sMSCAddress + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 6); + pcaparg->sMSCAddress[0] = len; + } + //timeAndTimezone============> + if((len = GetTLV("16.8", maxTimeAndTimezoneLength, pcaparg->timeAndTimezone + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 7); + pcaparg->timeAndTimezone[0] = len; + } + //tPShortMessageSubmissionInfo============> + if((len = GetTLV("16.9", 1, &pcaparg->tPShortMessageSubmissionInfo, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 8); + //tPProtocolIdentifier============> + if((len = GetTLV("16.10", 1, &pcaparg->tPProtocolIdentifier, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 9); + //tPDataCodingScheme============> + if((len = GetTLV("16.11", 1, &pcaparg->tPDataCodingScheme, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 10); + //tPDataCodingScheme============> + if((len = GetTLV("16.12", 7, pcaparg->tPValidityPeriod + 1, 0x80, &asnbuf)) >= 0) + { + set_bit(pcaparg->optional_flag, 11); + pcaparg->tPValidityPeriod[0] = len; + } + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*RequestReportSMSEvent--------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eRequestReportSMSEvent(struct CapRequestReportSMSEvent caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1, index = 0; + char tagseq[32]; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + for(index = 0; index < caparg.sMSEvents_num; index++) + { + sprintf(tagseq, "16.0.16-%d", index + 1); + add_null(tagseq, 0x20, &asnbuf); + sprintf(tagseq, "16.0.16-%d.0", index + 1); //eventTypeSMS + if((retval = AddInteger(tagseq, caparg.sMSEvents[index].eventTypeSMS, 0x80, &asnbuf)) < 0) + return -1; + sprintf(tagseq, "16.0.16-%d.1", index + 1); //monitorMode + if((retval = AddInteger(tagseq, caparg.sMSEvents[index].monitorMode, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dRequestReportSMSEvent(char *msgbuf, int msglen, PCapRequestReportSMSEvent pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len, index = 0; + char tagseq[32]; + CapSMSEvent *pevent; + + pcaparg->sMSEvents_num = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + return -1; + do + { + pevent = &pcaparg->sMSEvents[index]; + sprintf(tagseq, "16.0.16-%d.0", index + 1); //eventTypeSMS + if((len = GetInteger(tagseq, (int *)&pevent->eventTypeSMS, 0x80, &asnbuf)) < 0) + break; + sprintf(tagseq, "16.0.16-%d.1", index + 1); //monitorMode + if((len = GetInteger(tagseq, (int *)&pevent->monitorMode, 0x80, &asnbuf)) < 0) + break; + } + while(++index < numOfSMSEvents); + if((pcaparg->sMSEvents_num = index) < 1) + return -1; + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*EventReportSMS--------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eEventReportSMS(struct CapEventReportSMS caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((retval = AddInteger("16.0", caparg.eventTypeSMS, 0x80, &asnbuf)) < 0) + return -1; + if(check_bit(caparg.optional_flag, 0)) //eventSpecificInformationSMS + { + if((retval = encESISMS("16.1", caparg.eventSpecificInformationSMS, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) //miscCallInfo + { + if((retval = AddInteger("16.2.0", caparg.miscCallInfo.messageType, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dEventReportSMS(char *msgbuf, int msglen, PCapEventReportSMS pcaparg) +{ + ASN_BUF asnbuf; + int errpos, sel, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + return -1; + if((len = GetInteger("16.0", (int *)&pcaparg->eventTypeSMS, 0x80, &asnbuf)) < 0) + return -1; + if((sel = decESISMS("16.1", &pcaparg->eventSpecificInformationSMS, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 0); + if((len = GetInteger("16.2.0", (int *)&pcaparg->miscCallInfo.messageType, 0x80, &asnbuf)) >= 0) + set_bit(pcaparg->optional_flag, 1); + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++ */ +/*ReleaseSMS-------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +int eReleaseSMS(CapReleaseSMS caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + + AsnEncode(msgbuf, maxlen, &asnbuf); + return AddTLV("4", 1, &caparg.cause, 0, &asnbuf); +} + +int dReleaseSMS(char *msgbuf, int msglen, PCapReleaseSMS pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + if(AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf) < 0) + return -1; + if((len = GetTLV("4", 1, &pcaparg->cause, 0, &asnbuf)) > 0) + return 1; + else + return -1; +} + +int dVPSRequst(char *msgbuf, int msglen, CapVPSRequest * vpsreq) +{ + ASN_BUF asn_buf; + int errpos, len; + u8 temp_buf[1024]; + + if(AsnDecode(msgbuf, msglen, 1, &errpos, &asn_buf) < 0) + return -1; + len = get_tlv("16.0", temp_buf, &asn_buf); + if(len == maxVPSCallingLen) + memcpy(vpsreq->calling_num, temp_buf, maxVPSCallingLen); + else + return -1; + len = get_tlv("16.1", temp_buf, &asn_buf); + if(len == maxVPSCalledLen) + memcpy(vpsreq->called_num, temp_buf, maxVPSCalledLen); + else + return -1; + return 1; +} + +int eVPSPlayAnnounce(CapVPSPlayAnnounce * vps_ptr, char *msgbuf, int maxlen) +{ + int temp_len; + ASN_BUF asnbuf; + + AsnEncode(msgbuf, maxlen, &asnbuf); + temp_len = add_null("16", 0x20, &asnbuf); + temp_len = add_tlv("16.0", vps_ptr->info_len, vps_ptr->send_info, 0x80, &asnbuf); + return temp_len; +} + +#ifdef _SRF_RELEVANT +int eAssistRequestInstructions(struct CapAssistRequestInstructions caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((retval = AddTLV("16.0", caparg.correlationID[0], caparg.correlationID + 1, 0x80, &asnbuf)) < 0) + return -1; + if((retval = AddTLV("16.2", caparg.iPSSPCapabilities[0], caparg.iPSSPCapabilities + 1, 0x80, &asnbuf)) < 0) + return -1; + return retval; +} + +int dAssistRequestInstructions(char *msgbuf, int msglen, PCapAssistRequestInstructions pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetTLV("16.0", maxDigitsLength, pcaparg->correlationID + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->correlationID[0] = len; + } + if((len = GetTLV("16.2", maxIPSSPCapabilitiesLength, pcaparg->iPSSPCapabilities + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->iPSSPCapabilities[0] = len; + } + return 1; +} + +int eEstablishTemporaryConnection(CapEstablishTemporaryConnection caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((retval = AddTLV("16.0", caparg.assistingSSPIPRoutingAddress[0], caparg.assistingSSPIPRoutingAddress + 1, 0x80, &asnbuf)) < 0) + return -1; + if(check_bit(caparg.optional_flag, 0)) + { + if((retval = AddTLV("16.1", caparg.correlationID[0], caparg.correlationID + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = AddTLV("16.3", caparg.scfID[0], caparg.scfID + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 3)) + { + if((retval = encServiceInteractionIndicatorsTwo("16.7", caparg.serviceInteractionIndicatorsTwo, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dEstablishTemporaryConnection(char *msgbuf, int msglen, PCapEstablishTemporaryConnection pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetTLV("16.0", maxDigitsLength, pcaparg->assistingSSPIPRoutingAddress + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->assistingSSPIPRoutingAddress[0] = len; + } + if((len = GetTLV("16.1", maxDigitsLength, pcaparg->correlationID + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + pcaparg->correlationID[0] = len; + } + if((len = GetTLV("16.3", maxScfIDLength, pcaparg->scfID + 1, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 1); + pcaparg->scfID[0] = len; + } + if(decServiceInteractionIndicatorsTwo("16.7", &pcaparg->serviceInteractionIndicatorsTwo, &asnbuf) >= 0) + { + set_bit(pcaparg->optional_flag, 3); + } + return 1; +} + +int eConnectToResource(CapConnectToResource caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + switch (caparg.resourceAddress.choice_id) + { + case 0: + if((retval = AddTLV("16.0", caparg.resourceAddress.ipRoutingAddress[0], caparg.resourceAddress.ipRoutingAddress + 1, 0x80, &asnbuf)) < 0) + return -1; + break; + case 1: + if((retval = add_bool("16.3", caparg.resourceAddress.none, 0x80, &asnbuf)) < 0) + return -1;; + break; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = encServiceInteractionIndicatorsTwo("16.7", caparg.serviceInteractionIndicatorsTwo, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dConnectToResource(char *msgbuf, int msglen, PCapConnectToResource pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if((len = GetTLV("16.0", maxCalledPartyNumberLength, pcaparg->resourceAddress.ipRoutingAddress + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->resourceAddress.ipRoutingAddress[0] = len; + pcaparg->resourceAddress.choice_id = 0; + } + else if((len = GetTLV("16.3", 1, &pcaparg->resourceAddress.none, 0x80, &asnbuf)) > 0) + { + pcaparg->resourceAddress.choice_id = 1; + } + if(decServiceInteractionIndicatorsTwo("16.7", &pcaparg->serviceInteractionIndicatorsTwo, &asnbuf) >= 0) + { + set_bit(pcaparg->optional_flag, 1); + } + return 1; +} + +int eConnect(CapConnect caparg, char *msgbuf, int maxlen , u8 version) +{ + ASN_BUF asnbuf; + int retval = -1; + int index=0; + char tagseq[16]; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + sprintf(tagseq, "16.0.4"); + if((retval = AddTLV(tagseq, caparg.destinationRoutingAddress[0], caparg.destinationRoutingAddress + 1, 0x00, &asnbuf)) < 0) + return -1; + + if( version >1 ) + { + if(check_bit(caparg.optional_flag, 0)) + { + sprintf(tagseq, "16.1"); + if((retval = AddTLV("16.1", 3, caparg.alertingPattern, 0x80, &asnbuf)) < 0) + return -1; + } + } + + if(check_bit(caparg.optional_flag, 1)) + { + sprintf(tagseq, "16.6.4"); + if((retval = AddTLV(tagseq, caparg.originalCalledPartyID[0], caparg.originalCalledPartyID + 1, 0x00, &asnbuf)) < 0) + return -1; + } + + if( version == 1 ) + { + if(check_bit(caparg.optional_flag, 6)) + { + for(index = 0; index < caparg.genericNumbers.num; index++) + { + sprintf(tagseq, "16.14"); + if((retval = AddTLV(tagseq, caparg.genericNumbers.genericNumber[index][0], caparg.genericNumbers.genericNumber[index] + 1, 0x80, &asnbuf)) < 0) + return -1; + } + } + + + if(check_bit(caparg.optional_flag, 9)) + { + sprintf(tagseq, "16.27.4"); + if((retval = AddTLV("16.27.4", caparg.callingpartynum.callingpartyNmuber_len, caparg.callingpartynum.callingPartyNumber, 0x80, &asnbuf)) < 0) + return -1; + } + } + + if(check_bit(caparg.optional_flag, 3)) + { + sprintf(tagseq, "16.28-%d",index+1); + if((retval = AddTLV("16.28", 1, &caparg.callingPartysCategory, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 4)) + { + sprintf(tagseq, "16.29-%d",index+1); + if((retval = AddTLV("16.29", caparg.redirectingPartyID[0], caparg.redirectingPartyID + 1, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 5)) + { + + sprintf(tagseq, "16.30-%d",index+1); + if((retval = AddTLV("16.30", caparg.redirectionInformation[0], caparg.redirectionInformation + 1, 0x80, &asnbuf)) < 0) + return -1; + } + + if( version >1 ) + { + + if(check_bit(caparg.optional_flag, 6)) + { + for(index = 0; index < caparg.genericNumbers.num; index++) + { + sprintf(tagseq, "16.14-%d", index + 1); + if((retval = AddTLV(tagseq, caparg.genericNumbers.genericNumber[index][0], caparg.genericNumbers.genericNumber[index] + 1, 0x80, &asnbuf)) < 0) + return -1; + } + } + } + + if(check_bit(caparg.optional_flag, 7)) + { + sprintf(tagseq, "16.55-%d",index+1); + if((retval = AddTLV("16.55", 1, &caparg.suppressionOfAnnouncement, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 8)) + { + sprintf(tagseq, "16.56-%d",index+1); + if((retval = AddTLV("16.56", 1, &caparg.oCSIApplicable, 0x80, &asnbuf)) < 0) + return -1; + } + + return retval; +} + +int dConnect(char *msgbuf, int msglen, PCapConnect pcaparg , u8 version) +{ + ASN_BUF asnbuf; + int errpos, len; + char tagseq[16]; + int index; + u8 temp_buf[256]; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + + if((len = GetTLV("16.0.4", maxCalledPartyNumberLength, pcaparg->destinationRoutingAddress + 1, 0x00, &asnbuf)) > 0) + { + pcaparg->destinationRoutingAddress[0] = len; + } + if((len = GetTLV("16.1", 3, pcaparg->alertingPattern, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + } + if((len = GetTLV("16.6.4", maxOriginalCalledPartyIDLength, pcaparg->originalCalledPartyID + 1, 0x00, &asnbuf)) > 0) + { + pcaparg->originalCalledPartyID[0] = len; + set_bit(pcaparg->optional_flag, 1); + } + + + pcaparg->genericNumbers.num = 0; + for(index = 0; index < numOfGenericNumbers; index++) //refer to decVariablePart(to be modified) + { + sprintf(tagseq, "16.14-%d", index + 1); + if((len = GetTLV(tagseq, maxGenericNumberLength, pcaparg->genericNumbers.genericNumber[index] + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->genericNumbers.genericNumber[index][0] = len; + pcaparg->genericNumbers.num++; + } + else + { + if(pcaparg->genericNumbers.num > 0) + { + set_bit(pcaparg->optional_flag, 6); + } + break; + } + } + + if((len = GetTLV("16.28", 1, &pcaparg->callingPartysCategory, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 3); + } + if((len = GetTLV("16.29", maxRedirectingPartyIDLength, pcaparg->redirectingPartyID + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->redirectingPartyID[0] = len; + set_bit(pcaparg->optional_flag, 4); + } + if((len = GetTLV("16.30", 2, pcaparg->redirectionInformation + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->redirectionInformation[0] = len; + set_bit(pcaparg->optional_flag, 5); + } + + if((len = GetTLV("16,55", 1, &pcaparg->suppressionOfAnnouncement, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 7); + } + if((len = GetTLV("16.56", 1, &pcaparg->oCSIApplicable, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 8); + } + + if((len = get_tlv("16.27.4", temp_buf, &asnbuf)) != -1) + { + pcaparg->callingpartynum.callingpartyNmuber_len = len; + memcpy(pcaparg->callingpartynum.callingPartyNumber, temp_buf, len); + set_bit(pcaparg->optional_flag, 9); + } + return 1; +} + +int ePlayAnnouncement(CapPlayAnnouncement caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + if((retval = encInformationToSend("16.0", caparg.informationToSend, &asnbuf)) < 0) + return -1; + if(check_bit(caparg.optional_flag, 0)) + { + if((retval = AddTLV("16.1", 1, &caparg.disconnectFromIPForbidden, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = AddTLV("16.2", 1, &caparg.requestAnnouncementComplete, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int dPlayAnnouncement(char *msgbuf, int msglen, PCapPlayAnnouncement pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + pcaparg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if(decInformationToSend("16.0", &pcaparg->informationToSend, &asnbuf) < 0) + return -1; + if((len = GetTLV("16.1", 1, &pcaparg->disconnectFromIPForbidden, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 0); + } + if((len = GetTLV("16.2", 1, &pcaparg->requestAnnouncementComplete, 0x80, &asnbuf)) > 0) + { + set_bit(pcaparg->optional_flag, 1); + } + return 1; +} + +int ePromptAndCollectUserInformation(u8 otype, CapPromptAndCollectUserInformation caparg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + add_null("16", 0x20, &asnbuf); + + if(otype == CAP_REQUEST) //invoke + { + if((retval = encCollectedInfo("16.0", caparg.collectedInfo, &asnbuf)) < 0) + return -1; + if(check_bit(caparg.optional_flag, 0)) + { + if((retval = AddTLV("16.1", 1, &caparg.disconnectFromIPForbidden, 0x80, &asnbuf)) < 0) + return -1; + } + if(check_bit(caparg.optional_flag, 1)) + { + if((retval = encInformationToSend("16.2", caparg.informationToSend, &asnbuf)) < 0) + return -1; + } + } + else if(otype == CAP_RESPONSE) //return result + { + if(caparg.choice_id == 0) + { + if((retval = AddTLV("16.0", caparg.digitsResponse[0], caparg.digitsResponse + 1, 0x80, &asnbuf)) < 0) + return -1; + } + } + return retval; +} + +int dPromptAndCollectUserInformation(u8 otype, char *msgbuf, int msglen, PCapPromptAndCollectUserInformation pcaparg) +{ + ASN_BUF asnbuf; + int errpos, len; + + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + return -1; + } + if(otype == CAP_INDICATE) + { + pcaparg->optional_flag = 0; + if(decCollectedInfo("16.0", &pcaparg->collectedInfo, &asnbuf) < 0) + return -1; + if(GetTLV("16.1", 1, &pcaparg->disconnectFromIPForbidden, 0x80, &asnbuf) >= 0) + { + set_bit(pcaparg->optional_flag, 0); + } + if(decInformationToSend("16.2", &pcaparg->informationToSend, &asnbuf) >= 0) + { + set_bit(pcaparg->optional_flag, 1); + } + } + else if(otype == CAP_CONFIRM) + { + if((len = GetTLV("16.0", maxDigitsLength, pcaparg->digitsResponse + 1, 0x80, &asnbuf)) > 0) + { + pcaparg->digitsResponse[0] = len; + pcaparg->choice_id = 0; + } + else + { + return -1; + } + } + return 1; +} +#endif + +int encode_capmsg(struct CapArg caparg, u8 * msgbuf, u16 maxlen) +{ //return the length of byte flow, if failed return -1 + int retval = -1; + +#ifdef _SRF_RELEVANT + u8 otype; +#endif + + switch (caparg.ocode) + { + case CAP_OC_ActivityTest: + retval = 0; + break; + case CAP_OC_Cancel: + retval = eCancel(caparg.msg_list.cancelArg, msgbuf, maxlen); + break; + case CAP_OC_Continue: + retval = 0; + break; + case CAP_OC_EventReportBCSM: + retval = eEventReportBCSM(caparg.msg_list.eventReportBCSMArg, msgbuf, maxlen); + break; + case CAP_OC_InitialDP: + retval = eInitialDP(caparg.msg_list.initialDPArg, msgbuf, maxlen,caparg.version+1); + break; + case CAP_OC_ApplyCharging: + retval = eApplyCharging(caparg.msg_list.applyChargingArg, msgbuf, maxlen); + break; + case CAP_OC_ApplyChargingReport: + retval = eApplyChargingReport(caparg.msg_list.applyChargingReportArg, msgbuf, maxlen); + break; + case CAP_OC_RequestReportBCSMEvent: + retval = eRequestReportBCSMEvent(caparg.msg_list.requestReportBCSMEventArg, msgbuf, maxlen, caparg.version+1); + break; + case CAP_OC_ReleaseCall: + retval = eReleaseCall(caparg.msg_list.releaseCallArg, msgbuf, maxlen); + break; + case CAP_OC_ContinueSMS: + retval = 0; + break; + case CAP_OC_EventReportSMS: + retval = eEventReportSMS(caparg.msg_list.eventReportSMSArg, msgbuf, maxlen); + break; + case CAP_OC_InitialDPSMS: + retval = eInitialDPSMS(caparg.msg_list.initialDPSMSArg, msgbuf, maxlen); + break; + case CAP_OC_RequestReportSMSEvent: + retval = eRequestReportSMSEvent(caparg.msg_list.requestReportSMSEventArg, msgbuf, maxlen); + break; + case CAP_OC_ReleaseSMS: + retval = eReleaseSMS(caparg.msg_list.releaseSMSArg, msgbuf, maxlen); + break; + case 0xb1: + retval = eVPSPlayAnnounce(&caparg.msg_list.vpsPlayAnnounce, msgbuf, maxlen); + break; +#ifdef _SRF_RELEVANT + case CAP_OC_AssistRequestInstructions: + retval = eAssistRequestInstructions(caparg.msg_list.assistRequestInstructionsArg, msgbuf, maxlen); + break; + case CAP_OC_EstablishTemporaryConnection: + retval = eEstablishTemporaryConnection(caparg.msg_list.establishTemporaryConnectionArg, msgbuf, maxlen); + break; + case CAP_OC_DisconnectForwardConnection: + retval = 0; + break; + case CAP_OC_ConnectToResource: + retval = eConnectToResource(caparg.msg_list.connectToResourceArg, msgbuf, maxlen); + break; + case CAP_OC_Connect: + retval = eConnect(caparg.msg_list.connectArg, msgbuf, maxlen, caparg.version+1); + break; + case CAP_OC_PlayAnnouncement: + retval = ePlayAnnouncement(caparg.msg_list.playAnnouncementArg, msgbuf, maxlen); + break; + case CAP_OC_PromptAndCollectUserInformation: + otype = caparg.message_flag; + retval = ePromptAndCollectUserInformation(otype, caparg.msg_list.promptAndCollectUserInformationArg, msgbuf, maxlen); + break; + case CAP_OC_SpecializedResourceReport: + retval = 0; + break; +#endif + default: + break; + } + return retval; +} + +#ifdef _SRF_RELEVANT +int decode_capmsg(char *msgbuf, u16 msglen, u8 ocode, u8 otype, struct CapArg *pcaparg) +#else +int decode_capmsg(char *msgbuf, u16 msglen, u8 ocode, struct CapArg *pcaparg) +#endif +{ + int retval = 0; + + switch (ocode) + { + case CAP_OC_ActivityTest: + break; + case CAP_OC_Cancel: + retval = dCancel(msgbuf, msglen, &pcaparg->msg_list.cancelArg); + break; + case CAP_OC_Continue: + break; + case CAP_OC_EventReportBCSM: + retval = dEventReportBCSM(msgbuf, msglen, &pcaparg->msg_list.eventReportBCSMArg); + break; + case CAP_OC_InitialDP: + retval = dInitialDP(msgbuf, msglen, &pcaparg->msg_list.initialDPArg,pcaparg->version+1); + break; + case CAP_OC_ApplyCharging: + retval = dApplyCharging(msgbuf, msglen, &pcaparg->msg_list.applyChargingArg); + break; + case CAP_OC_ApplyChargingReport: + retval = dApplyChargingReport(msgbuf, msglen, &pcaparg->msg_list.applyChargingReportArg); + break; + case CAP_OC_RequestReportBCSMEvent: + retval = dRequestReportBCSMEvent(msgbuf, msglen, &pcaparg->msg_list.requestReportBCSMEventArg, pcaparg->version+1); + break; + case CAP_OC_ReleaseCall: + retval = dReleaseCall(msgbuf, msglen, &pcaparg->msg_list.releaseCallArg); + break; + case CAP_OC_ContinueSMS: + break; + case CAP_OC_EventReportSMS: + retval = dEventReportSMS(msgbuf, msglen, &pcaparg->msg_list.eventReportSMSArg); + break; + case CAP_OC_InitialDPSMS: + retval = dInitialDPSMS(msgbuf, msglen, &pcaparg->msg_list.initialDPSMSArg); + break; + case CAP_OC_RequestReportSMSEvent: + retval = dRequestReportSMSEvent(msgbuf, msglen, &pcaparg->msg_list.requestReportSMSEventArg); + break; + case CAP_OC_ReleaseSMS: + retval = dReleaseSMS(msgbuf, msglen, &pcaparg->msg_list.releaseSMSArg); + break; + case 0xb0: + retval = dVPSRequst(msgbuf, msglen, &pcaparg->msg_list.vpsRequest); + break; +#ifdef _SRF_RELEVANT + case CAP_OC_AssistRequestInstructions: + retval = dAssistRequestInstructions(msgbuf, msglen, &pcaparg->msg_list.assistRequestInstructionsArg); + break; + case CAP_OC_EstablishTemporaryConnection: + retval = dEstablishTemporaryConnection(msgbuf, msglen, &pcaparg->msg_list.establishTemporaryConnectionArg); + break; + case CAP_OC_DisconnectForwardConnection: + break; + case CAP_OC_ConnectToResource: + retval = dConnectToResource(msgbuf, msglen, &pcaparg->msg_list.connectToResourceArg); + break; + case CAP_OC_Connect: + retval = dConnect(msgbuf, msglen, &pcaparg->msg_list.connectArg,pcaparg->version+1); + break; + case CAP_OC_PlayAnnouncement: + retval = dPlayAnnouncement(msgbuf, msglen, &pcaparg->msg_list.playAnnouncementArg); + break; + case CAP_OC_PromptAndCollectUserInformation: + retval = dPromptAndCollectUserInformation(otype, msgbuf, msglen, &pcaparg->msg_list.promptAndCollectUserInformationArg); + break; + case CAP_OC_SpecializedResourceReport: + break; +#endif + default: + break; + } + pcaparg->ocode = ocode; + return retval; +} diff --git a/omc/plat/xapp/src/capp/cap_msg.h b/omc/plat/xapp/src/capp/cap_msg.h new file mode 100644 index 0000000..1ad17d4 --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_msg.h @@ -0,0 +1,873 @@ + +/************************************************/ +/*Title: smsmsg.h */ +/*Descr: CAP-DataTypes(ETSI TS 101046 6.3) */ +/*Author: Liang Hanxi */ +/*Create: 2002-9-11 */ +/*Modify: */ + +/************************************************/ + +#ifndef _CAP_MESSAGE +#define _CAP_MESSAGE + +#ifndef _SRF_RELEVANT +#define _SRF_RELEVANT +#endif + +#define check_bit(flag,pos) ((flag & (1< */ + +/*************************************/ +typedef enum CapEventTypeBCSM +{ + capp_collectedInfo = 2, + capp_routeSelectFailure = 4, + capp_oBusy = 5, + capp_oCalledPartyBusy = 5, + capp_oNoAnswer = 6, + capp_oAnswer = 7, + capp_oDisconnect = 9, + capp_oAbandon = 10, + capp_termAttemptAuthorized = 12, + capp_tBusy = 13, + capp_tNoAnswer = 14, + capp_tAnswer = 15, + capp_tDisconnect = 17, + capp_tAbandon = 18, + //self define==> + Int_Rel = 24, + capp_activetest = 25, + Int_TCE = 26, + Int_ETC_Failed = 27, + Int_TC_Released = 28, + Int_SRFConnected = 29, + Int_CTR_Failed = 30, + Int_SRFReleased = 31 +} +CapEventTypeBCSM; + +typedef enum CapNotReachableReason +{ + capp_msPurged = 0, + capp_imsiDetached = 1, + capp_restrictedArea = 2, + capp_notRegistered = 3 +} +CapNotReachableReason; + +typedef enum CapCriticalityType +{ + capp_ignore = 0, + capp_abort = 1 +} +CapCriticalityType; + +typedef union CapBearerCapability +{ //CAP-DataTypes + u8 bearerCap[maxBearerCapabilityLength + 1]; +} +CapBearerCapability; + +typedef struct CapExtensionField +{ //CAP-DataTypes + u32 type; + CapCriticalityType criticality; + u8 *value; +} +CapExtensionField; + +typedef union CapSubscriberState +{ //MAP-MS-DataTypes + u8 assumedIdle; + u8 camelBusy; + CapNotReachableReason netDetNotReachable; + u8 notProvidedFromVLR; +} +CapSubscriberState; + +typedef union CapCellIdOrLAI +{ //MAP-CH-DataTypes + u8 cellIdFixedLength[7 + 1]; + u8 laiFixedLength[5 + 1]; +} +CapCellIdOrLAI; + +typedef struct CapLocationInformation +{ //MAP-MS-DataTypes + u32 optional_flag; + int ageOfLocationInformation; + u8 geographicalInformation[8 + 1]; + u8 vlr_number[maxISDNAddressLength + 1]; + u8 locationNumber[maxLocationNumberLength + 1]; + u8 cellIdOrLAI_ch; + CapCellIdOrLAI cellIdOrLAI; +} +CapLocationInformation; + +typedef union CapExt_BasicServiceCode +{ //MAP-CommonDataTypes + u8 ext_BearerService[5 + 1]; + u8 ext_Teleservice[5 + 1]; +} +CapExt_BasicServiceCode; + +typedef struct CapNACarrierInformation +{ //CAP-DataTypes + u8 naCarrierId[3 + 1]; + u8 naCICSelectionType; +} +CapNACarrierInformation; + +typedef struct CapInitialDPArgExtension +{ + u32 optional_flag; + CapNACarrierInformation naCarrierInformation; + u8 gmscAddress[9 + 1]; +} +CapInitialDPArgExtension; + +typedef struct CapInitialDP //V1 GSM 09.78 18 TS 101 046 V5.0.1 Page 19 //GSM 09.78 version 7.1.0 (2000-07) Page 37 +{ + int serviceKey; /*tag 0 */ + u32 optional_flag; + u8 calledPartyNumber[maxCalledPartyNumberLength + 1]; /*Version 1 0[0x01],2 *//*Version 2 *//*0 */ + u8 callingPartyNumber[maxCallingPartyNumberLength + 1]; /*Version 1 1[0x02],3 *//*Version 2 *//*1 */ + u8 callingPartysCategory; /*Version 1 2[0x04],5 *//*Version 2 *//*2 */ + u8 iPSSPCapabilities[maxIPSSPCapabilitiesLength + 1]; /*Version 2 *//*3 */ + u8 locationNumber[maxLocationNumberLength + 1]; /*Version 1 3[0x08],10 *//*Version 2 *//*4 */ + u8 originalCalledPartyID[maxOriginalCalledPartyIDLength + 1]; /*Version 1 4[0x10],12 *//*Version 2 *//*5 */ + // CapExtensionField extensions[numOfExtensions]; /*Version 1 5[0x20],15*/ /*Version 2*//*6*/ + u8 highLayerCompatibility[2 + 1]; /*Version 1 6[0x40],23 *//*Version 2 *//*7 */ + u8 additionalCallingPartyNumber[maxDigitsLength + 1]; /*Version 1 7[0x80],25 *//*Version 2 *//*8 */ + CapBearerCapability bearerCapability; /*Version 1 8[0x100],27 *//*Version 2 *//*9 */ + CapEventTypeBCSM eventTypeBCSM; /*Version 1 9[0x200],28 *//*Version 2 *//*10 */ + u8 redirectingPartyID[maxRedirectingPartyIDLength + 1]; /*Version 1 10[0x400],29 *//*Version 2 *//*11 */ + u8 redirectionInformation[2 + 1]; /*Version 1 11[0x800],30 *//*Version 2 *//*12 */ + u8 iMSI[maxIMSILength + 1]; /*Version 1 12[0x1000],50 *//*Version 2 *//*13 */ + u8 subscriberState_ch; + CapSubscriberState subscriberState; /*Version 1 13[0x2000],51 *//*Version 2 *//*14 */ + CapLocationInformation locationInformation; /*Version 1 14[0x4000],52 *//*Version 2 *//*15 */ + u8 ext_basicServiceCode_ch; + CapExt_BasicServiceCode ext_basicServiceCode; /*Version 1 15[0x8000],53 *//*Version 2 *//*16 */ + u8 callReferenceNumber[maxcallReferenceNumberLength + 1]; /*Version 1 16[0x10000],54 *//*Version 2 *//*17 */ + + u8 mscAddress[maxISDNAddressLength + 1]; /*Version 2 *//*18 */ + u8 calledPartyBCDNumber[maxCalledPartyBCDNumberLength + 1]; /*Version 2 *//*19 */ + u8 timeAndTimezone[maxTimeAndTimezoneLength + 1]; /*Version 2 *//*20 */ + u8 gsm_ForwardingPending; /*Version 2 *//*21 */ + CapInitialDPArgExtension initialDPArgExtension; /*Version 2 *//*22 */ +} +CapInitialDP, *PCapInitialDP; + +/*++++++++++++++++++++++++++ */ +/*Cancel--------------> */ +/*++++++++++++++++++++++++++ */ +typedef struct CapCancel +{ + u8 ch; //ch=0:invokeID;ch=1:allRequest + u8 invokeID; //ch=0 + u8 allRequest; //ch=1 +} +CapCancel, *PCapCancel; + +/*++++++++++++++++++++++++++++++++++++++ */ +/*ApplyCharging--------------> */ +/*++++++++++++++++++++++++++++++++++++++ */ +typedef struct CapReleaseIfDurationExceeded +{ + u8 tone; +} +CapReleaseIfDurationExceeded; + +typedef struct CapACBCC +{ //aChbillingChargingCharacteristics + int maxCallPeriodDuration; + u32 optional_flag; + CapReleaseIfDurationExceeded releaseIfdurationExceeded; /*0 */ + int tariffSwitchInterval; /*1 */ +} +CapACBCC; + +typedef struct CapApplyCharging +{ + u8 partyToCharge; + CapACBCC ACBCC; +} +CapApplyCharging, *PCapApplyCharging; + +/*************************************/ +/*Apply Charging Report-------------> */ + +/*************************************/ +typedef struct CapTimeIfTariffSwitch +{ + int timeSinceTariffSwitch; + int tariffSwitchInterval; +} +CapTimeIfTariffSwitch; + +typedef union CAP_TimeInformation +{ + int timeIfNoTariffSwitch; + CapTimeIfTariffSwitch timeIfTariffSwitch; +} +CapTimeInformation; + +typedef struct CAMEL_CallResult +{ + u8 partyToCharge; + u8 timeInformation_ch; + CapTimeInformation timeInformation; + u8 callActive; +} +CAMEL_CallResult; + +typedef CAMEL_CallResult CapApplyChargingReport; +typedef CAMEL_CallResult *PCapApplyChargingReport; + +/*************************************/ +/*Request Report BCSM Event---------> */ + +/*************************************/ +typedef enum CapMonitorMode +{ + capp_interrupted = 0, + capp_notifyAndContinue = 1, + capp_transparent = 2 +} +CapMonitorMode; + +typedef union CapLegID +{ + u8 sendingSideID; + u8 receivingSideID; +} +CapLegID; + +typedef union CapDPSpecificCriteria +{ + int applicationTimer; +} +CapDPSpecificCriteria; + +typedef struct CapBCSMEvent +{ + CapEventTypeBCSM eventTypeBCSM; + CapMonitorMode monitorMode; + u32 optional_flag; + u8 legID_ch; + CapLegID legID; + CapDPSpecificCriteria dPSpecificCriteria; +} +CapBCSMEvent; + +typedef struct CapRequestReportBCSMEvent +{ + u8 bcsmEvents_num; + CapBCSMEvent bcsmEvents[numOfBCSMEvents]; + // ExtensionField extensions[numOfExtensions]; +} +CapRequestReportBCSMEvent, *PCapRequestReportBCSMEvent; + +/*************************************/ +/*Event Report BCSM-----------------> */ + +/*************************************/ +typedef struct CapESIBCSM +{ //EventSpecificInformationBCSM + u8 infotype; + //2:route select failure + //3:oCalledPartyBusy + //4:oNoAnswer + //5:oAnswer + //7:oDisconnect + //8:tBusy + //9:tNoAnswer + //10:tAnswer + //12:tDisconnect + u8 cause[maxCauseLength + 1]; + //cause[0] as length,if no cause is provided,cause[0]=0,or cause[0]=maxCauseLength(2) + u8 callForwarded; + //Boolean value(1/0) +} +CapESIBCSM; + +typedef union CapMiscCallInfo +{ + enum + { + capp_request = 0, + capp_notification = 1 + } + messageType; +} +CapMiscCallInfo; + +typedef struct CapEventReportBCSM +{ + CapEventTypeBCSM eventTypeBCSM; + u_int optional_flag; + u8 legID; /*0 */ + CapESIBCSM eventSpecificInformationBCSM; /*1 */ + CapMiscCallInfo miscCallInfo; /*2 */ +} +CapEventReportBCSM, *PCapEventReportBCSM; + +/*************************************/ +/*Furnish Charging Information------> */ + +/*************************************/ +//FCIBCC<==>FCIBillingChargingCharacteristics +typedef struct CAP_CAMEL_FCIBCC +{ + u8 freeFormatData[maxFCIBillingChargingDataLength]; + u8 partyToCharge; +} +CAMEL_FCIBCC; + +CAMEL_FCIBCC FurnishChargingInformationArg; + +/*************************************/ +/*ReleaseCall-----------------------> */ + +/*************************************/ +typedef struct CapReleaseCall +{ + u8 cause[maxCauseLength + 1]; +} +CapReleaseCall, *PCapReleaseCall; + +/*************************************/ +/*InitialDPSMS----------------------> */ + +/*************************************/ +typedef enum CapEventTypeSMS +{ + capp_smsCollectedInfo = 1, + capp_osmsFailure = 2, + capp_osmsSubmitted = 3, +} +CapEventTypeSMS; + +typedef struct CapLocationInformationGPRS +{ //MAP-MS-DataTypes + u32 optional_flag; + u8 cellGlobalIdOrServiceAreaIdOrLAI[7 + 1]; + u8 routeingAreaIdentity[7 + 1]; + u8 geographicalInformation[8 + 1]; + u8 sgsn_Number[maxISDNAddressLength + 1]; + u8 selectedLSAIdentity[3 + 1]; + u8 sai_Present; +} +CapLocationInformationGPRS; + +typedef struct CapInitialDPSMS +{ + int serviceKey; + u32 optional_flag; + u8 destinationSubscriberNumber[maxCalledPartyBCDNumberLength + 1]; /*0 */ + u8 callingPartyNumber[maxISDNAddressLength + 1]; /*1 */ + CapEventTypeSMS eventTypeSMS; /*2 */ + u8 iMSI[maxIMSILength + 1]; /*3 */ + CapLocationInformation locationInformation; /*4 */ + CapLocationInformationGPRS locationInformationGPRS; /*5 */ + u8 sMSCAddress[maxISDNAddressLength + 1]; /*6 */ + u8 timeAndTimezone[maxTimeAndTimezoneLength + 1]; /*7 */ + u8 tPShortMessageSubmissionInfo; /*8 */ + u8 tPProtocolIdentifier; /*9 */ + u8 tPDataCodingScheme; /*10 */ + u8 tPValidityPeriod[7 + 1]; /*11 */ +} +CapInitialDPSMS, *PCapInitialDPSMS; + +/*************************************/ +/*Request Report SMS Event---------> */ + +/*************************************/ +typedef struct CapSMSEvent +{ + CapEventTypeSMS eventTypeSMS; + CapMonitorMode monitorMode; +} +CapSMSEvent; + +typedef struct CapRequestReportSMSEvent +{ + u8 sMSEvents_num; + CapSMSEvent sMSEvents[numOfSMSEvents]; +} +CapRequestReportSMSEvent, *PCapRequestReportSMSEvent; + +/*************************************/ +/*Event Report SMS------------------> */ + +/*************************************/ +typedef enum CapSMSCause +{ + capp_systemFailure = 0, + capp_unexpectedDataValue = 1, + capp_facilityNotSupported = 2, + capp_sMDeliveryFailure = 3, + releaseFromRadioInterface = 4, +} +CapSMSCause; + +typedef struct CapESISMS +{ //EventSpecificInformationSMS + u8 infotype; //0:o-smsFailureSpecificInfo 1:o-smsSubmittedSpecificInfo + u8 cause_flag; + CapSMSCause cause; +} +CapESISMS; + +typedef struct CapEventReportSMS +{ + CapEventTypeSMS eventTypeSMS; + u32 optional_flag; + CapESISMS eventSpecificInformationSMS; /*0 */ + CapMiscCallInfo miscCallInfo; /*1 */ +} +CapEventReportSMS, *PCapEventReportSMS; + +/*************************************/ +/*ReleaseSMS------------------------> */ + +/*************************************/ +typedef struct CapReleaseSMS +{ + u8 cause; +} +CapReleaseSMS, *PCapReleaseSMS; + +/*************************************/ +/*ResetTimerSMS------> */ + +/*************************************/ +typedef enum CapTimerID +{ + Cap_Tssf = 0, +} +CapTimerID; + +typedef struct CapResetTimerSMS +{ + CapTimerID timerID; + u_int timerValue; +} +CapResetTimerSMS; + +typedef struct CapVPSRequest +{ + u8 calling_num[maxVPSCallingLen]; + u8 called_num[maxVPSCalledLen]; +} +CapVPSRequest; + +typedef struct CapVPSPlayAnnounce +{ + u8 info_len; + u8 send_info[maxVPSInfoLen]; +} +CapVPSPlayAnnounce; + +/******************************************/ + +/************** SRF Relevant **************/ + +/******************************************/ +#ifdef _SRF_RELEVANT + +/************************/ + +/** Common Data Type **/ + +/************************/ +#if 0 +typedef struct CapNACarrierInformation +{ + u32 optional_flag; + u8 naCarrierId[3]; /*0 */ + u8 naCICSelectionType; /*1 */ +} +CapNACarrierInformation; + +typedef struct CapNA_Info +{ + u32 optional_flag; + CapNACarrierInformation naCarrierInformation; /*0 */ + u8 naOliInfo; /*1 */ + u8 naChargeNumber[7 + 1]; /*2 */ +} +CapNA_Info; + +typedef struct CapResourceAddress +{ + u8 choice_id; + u8 ipRoutingAddress[maxCalledPartyNumberLength + 1]; /*0,0 */ + u8 none; /*1,3 */ +} +CapResourceAddress; +#endif + +typedef struct CapServiceInteractionIndicatorsTwo +{ + u32 optional_flag; + u8 bothwayThroughConnectionInd; /*0,2 */ +} +CapServiceInteractionIndicatorsTwo; + +typedef struct CapVariablePart +{ + u32 choice_id; + u32 integer; /*0,0 */ + u8 number[maxDigitsLength + 1]; /*1,1 */ + u8 time[2]; /*2,2 */ + u8 date[4]; /*3,3 */ + u8 price[4]; /*4,4 */ +} +CapVariablePart; + +typedef struct CapMessageID +{ + u8 choice_id; + u32 elementaryMessageID; /*0,0 */ + // text /*1,1*/ + struct CapElementaryMessageIDs + { + u8 num; + u32 elementaryMessageID[numOfMessageIDs]; + } + elementaryMessageIDs; /*2,29 */ + struct CapVariableMessage + { + + u32 elementaryMessageID; /*-,0*/ + struct CapVariableParts + { + u8 num; + CapVariablePart variablePart[5]; + } + + variableParts; /*-,1*/ + } + variableMessage; /*3,30 */ +} +CapMessageID; + +typedef struct CapInbandInfo +{ + + CapMessageID messageID; /*-,0*/ + u32 optional_flag; + int numberOfRepetitions; /*0,1 */ + int duration; /*1,2 */ + int interval; /*2,3 */ +} +CapInbandInfo; + +typedef struct CapTone +{ + + u32 toneID; /*-,0*/ + u32 optional_flag; + u32 duration; /*0,1 */ +} +CapTone; + +typedef struct CapInformationToSend +{ + u8 choice_id; + CapInbandInfo inbandInfo; /*0,0 */ + CapTone tone; /*1,1 */ +} +CapInformationToSend; + +typedef enum CapErrorTreatment +{ + stdErrorAndInfo = 0, + help = 1, + repeatPrompt = 2, +} +CapErrorTreatment; + +typedef struct CapCollectedDigits +{ + + u8 minimumNbOfDigits; /*-,0*/ + + u8 maximumNbOfDigits; /*-,1*/ + u32 optional_flag; + u8 endOfReplyDigit[2 + 1]; /*0,2 */ + u8 cancelDigit[2 + 1]; /*1,3 */ + u8 startDigit[2 + 1]; /*2,4 */ + u8 firstDigitTimeOut; /*3,5 */ + u8 interDigitTimeOut; /*4,6 */ + CapErrorTreatment errorTreatment; /*5,7 */ + u8 interruptableAnnInd; /*6,8 */ + u8 voiceInformation; /*7,9 */ + u8 voiceBack; /*8,10 */ +} +CapCollectedDigits; + +typedef struct CapCollectedInfo +{ + u8 choice_id; + CapCollectedDigits collectedDigits; /*0,0 */ +} +CapCollectedInfo; + +/************************/ + +/** Argument Data Type **/ + +/************************/ +typedef struct CapAssistRequestInstructions +{ + + u8 correlationID[maxDigitsLength + 1]; /*-,0*/ + + u8 iPSSPCapabilities[maxIPSSPCapabilitiesLength + 1]; /*-,2*/ +} +CapAssistRequestInstructions, *PCapAssistRequestInstructions; + +typedef struct CapConnect +{ + u8 destinationRoutingAddress[maxCalledPartyNumberLength + 1]; /*-,0*/ + u32 optional_flag; + u8 alertingPattern[3]; /*Versinon2 0[0x01],1 */ + u8 originalCalledPartyID[maxOriginalCalledPartyIDLength + 1]; /*Versinon 1 0[0x01],6 *//*Versinon2 1[0x02],6 */ + // CapExtensionField extensions[numOfExtensions]; /*Versinon 1 1[0x02],10*/ /*Versinon2 2[0x04],10*/ + u8 callingPartysCategory; /*Versinon 1 4[0x10],28 *//*Versinon2 3[0x08],28 */ + u8 redirectingPartyID[maxRedirectingPartyIDLength + 1]; /*Versinon 1 5[0x20],29 *//*Versinon2 4[0x10],29 */ + u8 redirectionInformation[2 + 1]; /*Versinon 1 6[0x40],30 *//*Versinon2 5[0x20],30 */ + struct + { + u8 num; + u8 genericNumber[numOfGenericNumbers][maxGenericNumberLength + 1]; + } + genericNumbers; /*Versinon2 6[0x40],14 */ + u8 suppressionOfAnnouncement; /*Versinon 1 7[0x80],55 *//*Versinon2 7[0x80],14 */ + u8 oCSIApplicable; /*Versinon 1 8[0x100],56 *//*Versinon2 8[0x100],14 */ + //CapNA_Info na_Info; + struct + { + u8 callingpartyNmuber_len; + u8 callingPartyNumber[maxCallingPartyNumberLength]; /*Versinon 1 3[0x08],27 */ + } + callingpartynum; /*Versinon2 9[0x200],57*/ +}CapConnect, *PCapConnect; + +typedef struct CapConnectToResource +{ + // CapResourceAddress resourceAddress; + struct + { + u8 choice_id; + u8 ipRoutingAddress[maxCalledPartyNumberLength + 1]; /*0,0 */ + u8 none; /*1,3 */ + } + resourceAddress; + u32 optional_flag; + // CapExtensionField extensions[numOfExtensions]; /*0,4*/ + CapServiceInteractionIndicatorsTwo serviceInteractionIndicatorsTwo; /*1,7 */ +} +CapConnectToResource, *PCapConnectToResource; + +typedef struct CapDisconnectForwardConnection +{ +} +CapDisconnectForwardConnection, *PCapDisconnectForwardConnection; + +typedef struct CapEstablishTemporaryConnection +{ + + u8 assistingSSPIPRoutingAddress[maxDigitsLength + 1]; /*-,0*/ + u32 optional_flag; + u8 correlationID[maxDigitsLength + 1]; /*0,1 */ + u8 scfID[maxScfIDLength + 1]; /*1,3 */ + // CapExtensionField extensions[numOfExtensions]; /*2,4*/ + CapServiceInteractionIndicatorsTwo serviceInteractionIndicatorsTwo; /*3,7 */ + // CapNA_Info na_Info; /*4,50*/ +} +CapEstablishTemporaryConnection, *PCapEstablishTemporaryConnection; + +typedef struct CapPlayAnnouncement +{ + + CapInformationToSend informationToSend; /*-,0*/ + u32 optional_flag; + u8 disconnectFromIPForbidden; /*0,1 */ + u8 requestAnnouncementComplete; /*1,2 */ + // CapExtensionField extensions[numOfExtensions]; /*2,3*/ +} +CapPlayAnnouncement, *PCapPlayAnnouncement; + +typedef struct CapPromptAndCollectUserInformation +{ + + CapCollectedInfo collectedInfo; /*-,0*/ + u32 optional_flag; + u8 disconnectFromIPForbidden; /*0,1 */ + CapInformationToSend informationToSend; /*1,2 */ + // CapExtensionField extensions[numOfExtensions]; /*2,3*/ + + u8 choice_id; + + u8 digitsResponse[maxDigitsLength + 1]; /*-,0*///CapReceivedInformation +} +CapPromptAndCollectUserInformation, *PCapPromptAndCollectUserInformation; + +/*typedef union CapReceivedInformation + { + u8 digitsResponse[maxDigitsLength+1]; + }CapReceivedInformation; */ + +typedef struct CapSpecializedResourceReport +{ +} +CapSpecializedResourceReport, *PCapSpecializedResourceReport; + +#endif + +/*************************************/ +/*Cap Structure---------------------> */ + +/*************************************/ +typedef struct CapArg +{ + u8 ocode; + u8 message_flag; + u16 port_id; + u16 dialogue_id; + u8 invoke_id; + u8 version; + union + { + CapInitialDP initialDPArg; + CapApplyCharging applyChargingArg; + CapApplyChargingReport applyChargingReportArg; + CapRequestReportBCSMEvent requestReportBCSMEventArg; + CapCancel cancelArg; + CapEventReportBCSM eventReportBCSMArg; + CapReleaseCall releaseCallArg; + CapInitialDPSMS initialDPSMSArg; + CapRequestReportSMSEvent requestReportSMSEventArg; + CapEventReportSMS eventReportSMSArg; + CapReleaseSMS releaseSMSArg; + CapResetTimerSMS resetTimerArg; + CapVPSRequest vpsRequest; + CapVPSPlayAnnounce vpsPlayAnnounce; + CapAssistRequestInstructions assistRequestInstructionsArg; + CapConnect connectArg; + //CapConnect_v1 connectArg_v1; + CapConnectToResource connectToResourceArg; + CapDisconnectForwardConnection disconnectForwardConnectionArg; + CapEstablishTemporaryConnection establishTemporaryConnectionArg; + CapPlayAnnouncement playAnnouncementArg; + CapPromptAndCollectUserInformation promptAndCollectUserInformationArg; + //CapReceivedInformation receivedInformationArg; // RR of P&C + CapSpecializedResourceReport specializedResourceReportArg; + } + msg_list; +} +CapArg, *PCapArg; + +/* + typedef struct _CAP_Message + { + u8 msgLength[2]; // u80 is the higher part + u8 msgServiceCode; // fixed as 0xAF + u8 port_id[3]; // u8 0 is the higher part,u8 1 is the lower part ,and u8 2 is reserved + u8 dialogue_id[3]; + u8 msgOperaCode; // message type code ,e.g , InitialDP = 0x00 + u8 msgOperaType; // 1/2/3/4 = request, indicate, response, confirm + u8 msgContent[CAP_CONTENT_LEN]; + // if the message if cap operation ,then the first u8 of msgContent is invoke id + }CAP_Message, *PCAP_Message; + + typedef struct DestCriteria + { + u8 DestNumber[maxISDNAddressLength+1]; + u8 Type; //0:unknown 1:enable 2:inhibit + }DestCriteria; + + typedef struct CapCSI + { + int ServiceKey; + u8 SCFAddress[maxISDNAddressLength+1]; + u8 DefaultHandle; //The Default Call Handling indicates whether the call shall be released or + //continued as requested in case of error in the gsmSSF to gsmSCF dialogue. + //0:release 1:continue + CapEventTypeBCSM TDP; //TDP_R + //O-CSI:capp_collectedInfo = 2, + //T-CSI:capp_termAttemptAuthorized = 12, + u8 DstNum; + DestCriteria DstList[10]; //The DP criteria indicate whether the gsmSSF shall request the gsmSCF for instructions. + u8 BSNum; + u32 BSCode[5]; //Basic service triggering criteria + u8 FWCriteria; //Forwarding triggering criteria + //1:enabling 0:inhibiting + }CapCSI; + */ + +#endif diff --git a/omc/plat/xapp/src/capp/cap_msgtype.c b/omc/plat/xapp/src/capp/cap_msgtype.c new file mode 100644 index 0000000..aafe476 --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_msgtype.c @@ -0,0 +1,1064 @@ + +/************************************************/ +/*Title: common_type.c */ +/*Descr: CAP Provide */ +/*Author: Liang Hanxi */ +/*Create: 2002-5-7 */ +/************************************************/ + +#include "../../../public/src/include/pub_include.h" +#include "cap_head.h" +#include "cap_msg.h" + +/*++++++++++++++++++++++++ */ +//SubscriberState===========> +/*++++++++++++++++++++++++ */ +int encSubscriberState(u_char sel, char *tagprefix, CapSubscriberState arg, ASN_BUF * asnbuf) +{ //return length if success,or -1 is returned + char tagseq[16]; + + switch (sel) + { + case 0: //assumedIdle--->(NULL) + sprintf(tagseq, "%s.0", tagprefix); + return add_null(tagseq, 0x80, asnbuf); + case 1: //camelBusy--->(NULL) + sprintf(tagseq, "%s.1", tagprefix); + return add_null(tagseq, 0x80, asnbuf); + case 2: //netDetNotReachable + sprintf(tagseq, "%s.10", tagprefix); + return AddInteger(tagseq, arg.netDetNotReachable, 0, asnbuf); + case 3: //notProvidedFromVLR--->(NULL) + sprintf(tagseq, "%s.2", tagprefix); + return add_null(tagseq, 0x80, asnbuf); + } + return -1; +} + +int decSubscriberState(char *tagprefix, CapSubscriberState * parg, ASN_BUF * asnbuf) +//return choice indicator,-1 if none. +{ + char tagseq[16]; + int len; + + //-------(0)assumedIdle--->(NULL) + sprintf(tagseq, "%s.0", tagprefix); + if((len = GetTLV(tagseq, 1, &parg->assumedIdle, 0x80, asnbuf)) >= 0) + return 0; + //-------(1)camelBusy--->(NULL) + sprintf(tagseq, "%s.1", tagprefix); + if((len = GetTLV(tagseq, 1, &parg->camelBusy, 0x80, asnbuf)) >= 0) + return 1; + //-------(2)netDetNotReachable---> + sprintf(tagseq, "%s.10", tagprefix); + if((len = GetInteger(tagseq, (int *)&parg->netDetNotReachable, 0, asnbuf)) > 0) + return 2; + //-------(3)notProvidedFromVLR--->(NULL) + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, 1, &parg->notProvidedFromVLR, 0x80, asnbuf)) >= 0) + return 3; + return -1; +} + +/*++++++++++++++++++++++++ */ +//CellIdOrLAI==============> +/*++++++++++++++++++++++++ */ +int encCellIdOrLAI(u_char sel, char *tagprefix, CapCellIdOrLAI arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + + switch (sel) + { + case 0: //cellIdFixedLength + sprintf(tagseq, "%s.0", tagprefix); + return AddTLV(tagseq, arg.cellIdFixedLength[0], arg.cellIdFixedLength + 1, 0x80, asnbuf); + case 1: //laiFixedLength + sprintf(tagseq, "%s.1", tagprefix); + return AddTLV(tagseq, arg.cellIdFixedLength[0], arg.laiFixedLength + 1, 0x80, asnbuf); + } + return -1; +} + +int decCellIdOrLAI(char *tagprefix, CapCellIdOrLAI * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int len; + + //-------(0)cellIdFixedLength---> + sprintf(tagseq, "%s.0", tagprefix); + if((len = GetTLV(tagseq, 7, parg->cellIdFixedLength + 1, 0x80, asnbuf)) > 0) + { + parg->cellIdFixedLength[0] = len; + return 0; + } + //-------(1)laiFixedLength---> + sprintf(tagseq, "%s.1", tagprefix); + if((len = GetTLV(tagseq, 5, parg->laiFixedLength + 1, 0x80, asnbuf)) > 0) + { + parg->laiFixedLength[0] = len; + return 1; + } + return -1; +} + +/*+++++++++++++++++++++++++ */ +//Ext_BasicServiceCode======> +/*+++++++++++++++++++++++++ */ +int encExt_BasicServiceCode(u_char sel, char *tagprefix, CapExt_BasicServiceCode arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + + switch (sel) + { + case 0: //ext_BearerService + sprintf(tagseq, "%s.2", tagprefix); + return AddTLV(tagseq, arg.ext_BearerService[0], arg.ext_BearerService + 1, 0x80, asnbuf); + case 1: //ext_Teleservice + sprintf(tagseq, "%s.3", tagprefix); + return AddTLV(tagseq, arg.ext_Teleservice[0], arg.ext_Teleservice + 1, 0x80, asnbuf); + } + return -1; +} + +int decExt_BasicServiceCode(char *tagprefix, CapExt_BasicServiceCode * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int len; + + //-------(0)ext_BearerService---> + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, 5, parg->ext_BearerService + 1, 0x80, asnbuf)) > 0) + { + parg->ext_BearerService[0] = len; + return 0; + } + //-------(1)ext_Teleservice---> + sprintf(tagseq, "%s.3", tagprefix); + if((len = GetTLV(tagseq, 5, parg->ext_Teleservice + 1, 0x80, asnbuf)) > 0) + { + parg->ext_Teleservice[0] = len; + return 1; + } + return -1; +} + +/*++++++++++++++++++++++++ */ +//LocationInformation======> +/*++++++++++++++++++++++++ */ +int encLocationInformation(char *tagprefix, CapLocationInformation arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = -1; + + if(check_bit(arg.optional_flag, 0)) //ageOfLocationInformation----> + { + sprintf(tagseq, "%s.2-1", tagprefix); + if((retval = AddInteger(tagseq, arg.ageOfLocationInformation, 0, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 1)) //geographicalInformation----> + { + sprintf(tagseq, "%s.0-2", tagprefix); + if((retval = AddTLV(tagseq, arg.geographicalInformation[0], arg.geographicalInformation + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 2)) //vlr_number----> + { + sprintf(tagseq, "%s.1-3", tagprefix); + if((retval = AddTLV(tagseq, arg.vlr_number[0], arg.vlr_number + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 3)) //locationNumber----> + { + sprintf(tagseq, "%s.2-4", tagprefix); + if((retval = AddTLV(tagseq, arg.locationNumber[0], arg.locationNumber + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 4)) //cellIdOrLAI----> + { + sprintf(tagseq, "%s.3-5", tagprefix); + if((retval = encCellIdOrLAI(arg.cellIdOrLAI_ch, tagseq, arg.cellIdOrLAI, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decLocationInformation(char *tagprefix, CapLocationInformation * parg, ASN_BUF * asnbuf) +{ + int retval = -1, len, sel; + char tagseq[16]; + + parg->optional_flag = 0; + + //ageOfLocationInformation----> + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetInteger(tagseq, &parg->ageOfLocationInformation, 0, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 0); + retval = 1; + } + //geographicalInformation----> + sprintf(tagseq, "%s.0", tagprefix); + if((len = GetTLV(tagseq, 8, parg->geographicalInformation + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 1); + parg->geographicalInformation[0] = len; + retval = 1; + } + //vlr_number----> + sprintf(tagseq, "%s.1", tagprefix); + if((len = GetTLV(tagseq, maxISDNAddressLength, parg->vlr_number + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 2); + parg->vlr_number[0] = len; + retval = 1; + } + //locationNumber----> + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, maxLocationNumberLength, parg->locationNumber + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 3); + parg->locationNumber[0] = len; + retval = 1; + } + //cellIdOrLAI----> + sprintf(tagseq, "%s.3", tagprefix); + if((sel = decCellIdOrLAI(tagseq, &parg->cellIdOrLAI, asnbuf)) >= 0) + { + set_bit(parg->optional_flag, 4); + parg->cellIdOrLAI_ch = sel; + retval = 1; + } + return retval; +} + +/*++++++++++++++++++++++++++++ */ +//LocationInformationGPRS======> +/*++++++++++++++++++++++++++++ */ +int encLocationInformationGPRS(char *tagprefix, CapLocationInformationGPRS arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = -1; + + if(check_bit(arg.optional_flag, 0)) //cellGlobalIdOrServiceAreaIdOrLAI ----> + { + sprintf(tagseq, "%s.0", tagprefix); + if((retval = AddTLV(tagseq, arg.cellGlobalIdOrServiceAreaIdOrLAI[0], arg.cellGlobalIdOrServiceAreaIdOrLAI + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 1)) //routeingAreaIdentity ----> + { + sprintf(tagseq, "%s.1", tagprefix); + if((retval = AddTLV(tagseq, arg.routeingAreaIdentity[0], arg.routeingAreaIdentity + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 2)) //geographicalInformation----> + { + sprintf(tagseq, "%s.2", tagprefix); + if((retval = AddTLV(tagseq, arg.geographicalInformation[0], arg.geographicalInformation + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 3)) //sgsn_Number----> + { + sprintf(tagseq, "%s.3", tagprefix); + if((retval = AddTLV(tagseq, arg.sgsn_Number[0], arg.sgsn_Number + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 4)) //cellIdOrLAI----> + { + sprintf(tagseq, "%s.4", tagprefix); + if((retval = AddTLV(tagseq, arg.selectedLSAIdentity[0], arg.selectedLSAIdentity + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 6)) //cellIdOrLAI----> + { + sprintf(tagseq, "%s.6", tagprefix); + if((retval = add_null(tagseq, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decLocationInformationGPRS(char *tagprefix, CapLocationInformationGPRS * parg, ASN_BUF * asnbuf) +{ + int retval = -1, len; + char tagseq[16]; + + parg->optional_flag = 0; + + //cellGlobalIdOrServiceAreaIdOrLAI----> + sprintf(tagseq, "%s.0", tagprefix); + if((len = GetTLV(tagseq, 7, parg->cellGlobalIdOrServiceAreaIdOrLAI + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 0); + parg->cellGlobalIdOrServiceAreaIdOrLAI[0] = len; + retval = 1; + } + //routeingAreaIdentity----> + sprintf(tagseq, "%s.1", tagprefix); + if((len = GetTLV(tagseq, 7, parg->routeingAreaIdentity + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 1); + parg->routeingAreaIdentity[0] = len; + retval = 1; + } + //geographicalInformation----> + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, 8, parg->geographicalInformation + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 2); + parg->geographicalInformation[0] = len; + retval = 1; + } + //sgsn_Number----> + sprintf(tagseq, "%s.3", tagprefix); + if((len = GetTLV(tagseq, maxISDNAddressLength, parg->sgsn_Number + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 3); + parg->sgsn_Number[0] = len; + retval = 1; + } + //selectedLSAIdentity----> + sprintf(tagseq, "%s.4", tagprefix); + if((len = GetTLV(tagseq, 3, parg->selectedLSAIdentity + 1, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 4); + parg->selectedLSAIdentity[0] = len; + retval = 1; + } + //selectedLSAIdentity----> + sprintf(tagseq, "%s.6", tagprefix); + if((len = GetTLV(tagseq, 1, &parg->sai_Present, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 5); + retval = 1; + } + return retval; +} + +/*++++++++++++++++++++++++++++++++++++++++++++ */ +//CAMEL-aChbillingChargingCharacteristics======> +/*++++++++++++++++++++++++++++++++++++++++++++ */ +int encACBCC(struct CapACBCC arg, char *msgbuf, int maxlen) +{ + ASN_BUF asnbuf; + int retval = -1; + + AsnEncode(msgbuf, maxlen, &asnbuf); + if((retval = AddInteger("0.0", arg.maxCallPeriodDuration, 0x80, &asnbuf)) < 0) + return -1; + if(check_bit(arg.optional_flag, 0)) + { + if((retval = AddTLV("0.1.1", 1, &arg.releaseIfdurationExceeded.tone, 0, &asnbuf)) < 0) + /* no reason, why code as following lines */ + // if((retval=AddTLV("0.1",1,&arg.releaseIfdurationExceeded.tone,0x80,&asnbuf))<0) + return -1; + } + if(check_bit(arg.optional_flag, 1)) + { + if((retval = AddInteger("0.2", arg.tariffSwitchInterval, 0x80, &asnbuf)) < 0) + return -1; + } + return retval; +} + +int decACBCC(char *msgbuf, int msglen, CapACBCC * parg) +{ + ASN_BUF asnbuf; + int errpos, len; + + parg->optional_flag = 0; + if((len = AsnDecode(msgbuf, msglen, 1, &errpos, &asnbuf)) < 0) + { + printf("Decode error:%s", asnbuf.errmsg); + return -1; + } + if(GetInteger("0.0", &parg->maxCallPeriodDuration, 0x80, &asnbuf) < 0) + return -1; + if((len = GetTLV("0.1.1", 1, &parg->releaseIfdurationExceeded.tone, 0, &asnbuf)) > 0) + set_bit(parg->optional_flag, 0); + if((len = GetInteger("0.2", &parg->tariffSwitchInterval, 0x80, &asnbuf)) > 0) + set_bit(parg->optional_flag, 1); + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++++++++ */ +//LegID======> +/*++++++++++++++++++++++++++++++++++++++++++++ */ +int encLegID(u_char sel, char *tagprefix, CapLegID arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + + switch (sel) + { + case 0: //sendingSideID + sprintf(tagseq, "%s.0", tagprefix); + return AddTLV(tagseq, 1, &arg.sendingSideID, 0x80, asnbuf); + case 1: //receivingSideID + sprintf(tagseq, "%s.1", tagprefix); + return AddTLV(tagseq, 1, &arg.receivingSideID, 0x80, asnbuf); + } + return -1; +} + +int decLegID(char *tagprefix, CapLegID * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int len; + + sprintf(tagseq, "%s.0", tagprefix); //sendingSideID + if((len = GetTLV(tagseq, 1, &parg->sendingSideID, 0x80, asnbuf)) >= 0) + return 0; + sprintf(tagseq, "%s.1", tagprefix); //receivingSideID + if((len = GetTLV(tagseq, 1, &parg->receivingSideID, 0x80, asnbuf)) >= 0) + return 1; + return -1; +} + +/*++++++++++++++++++++++++++++++++++++++++++++ */ +//EventSpecificInformationBCSM======> +/*++++++++++++++++++++++++++++++++++++++++++++ */ +int encESIBCSM(char *tagprefix, CapESIBCSM arg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = -1; + + if(arg.infotype < 2 || arg.infotype > 12) + return -1; + sprintf(tagseq, "%s.%d", tagprefix, arg.infotype); + if((retval = add_null(tagseq, 0xA0, asnbuf)) < 0) + return -1; + if(arg.cause[0] > 0) + { + sprintf(tagseq, "%s.%d.0", tagprefix, arg.infotype); + if((retval = AddTLV(tagseq, arg.cause[0], arg.cause + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(arg.callForwarded) + { + sprintf(tagseq, "%s.%d.50", tagprefix, arg.infotype); + if((retval = add_null(tagseq, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decESIBCSM(char *tagprefix, CapESIBCSM * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + u_char msgbuf[64]; + int len; + u_short tagcode; + + sprintf(tagseq, "%s.-1", tagprefix); //get first tlv + if(GetAnyTLV(tagseq, 64, msgbuf, NULL, &tagcode, asnbuf) < 0) + return -1; + parg->infotype = tagcode; + parg->callForwarded = 0; + switch (tagcode) + { + case 2: + case 3: + case 7: + case 12: + sprintf(tagseq, "%s.-1.0", tagprefix); + if((len = GetTLV(tagseq, maxCauseLength, parg->cause + 1, 0x80, asnbuf)) > 0) + parg->cause[0] = len; + else + parg->cause[0] = 0; + break; + case 8: + sprintf(tagseq, "%s.-1.0", tagprefix); + if((len = GetTLV(tagseq, maxCauseLength, parg->cause + 1, 0x80, asnbuf)) > 0) + parg->cause[0] = len; + else + parg->cause[0] = 0; + sprintf(tagseq, "%s.-1.50", tagprefix); + if((len = GetTLV(tagseq, 0, &parg->callForwarded, 0x80, asnbuf)) >= 0) + parg->callForwarded = 1; + break; + case 9: + sprintf(tagseq, "%s.-1.50", tagprefix); + if(GetTLV(tagseq, 0, &parg->callForwarded, 0x80, asnbuf) >= 0) + parg->callForwarded = 1; + break; + case 4: + case 5: + case 10: + break; + default: + return -1; + } + return 1; +} + +/*++++++++++++++++++++++++++++++++++++++++++++ */ +//EventSpecificInformationSMS======> +/*++++++++++++++++++++++++++++++++++++++++++++ */ +int encESISMS(char *tagprefix, CapESISMS arg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = -1; + + if(arg.infotype > 1) + return -1; + sprintf(tagseq, "%s.%d", tagprefix, arg.infotype); + if((retval = add_null(tagseq, 0xA0, asnbuf)) < 0) + return -1; + if(arg.infotype == 0 && arg.cause_flag) + { + sprintf(tagseq, "%s.%d.0", tagprefix, arg.infotype); + if((retval = AddInteger(tagseq, arg.cause, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decESISMS(char *tagprefix, CapESISMS * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + u_char msgbuf[64]; + int len; + u_short tagcode; + + sprintf(tagseq, "%s.-1", tagprefix); //get first tlv + if(GetAnyTLV(tagseq, 64, msgbuf, NULL, &tagcode, asnbuf) < 0) + return -1; + parg->infotype = tagcode; + if(tagcode == 0) + { + sprintf(tagseq, "%s.-1.0", tagprefix); + if((len = GetInteger(tagseq, (int *)&parg->cause, 0x80, asnbuf)) > 0) + parg->cause_flag = 1; + else + parg->cause_flag = 0; + } + return 1; +} + +#ifdef _SRF_RELEVANT +int encServiceInteractionIndicatorsTwo(char *tagprefix, CapServiceInteractionIndicatorsTwo arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = 0; + + if(check_bit(arg.optional_flag, 0)) + { + sprintf(tagseq, "%s.2", tagprefix); + if((retval = add_bool(tagseq, arg.bothwayThroughConnectionInd, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decServiceInteractionIndicatorsTwo(char *tagprefix, CapServiceInteractionIndicatorsTwo * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = -1; + int len; + + parg->optional_flag = 0; + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, 1, &parg->bothwayThroughConnectionInd, 0x80, asnbuf)) >= 0) + { + set_bit(parg->optional_flag, 0); + retval = 1; + } + return retval; +} + +int encVariablePart(char seq, char *tagprefix, CapVariablePart arg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = 0; + + switch (arg.choice_id) + { + case 0: + sprintf(tagseq, "%s.0-%d", tagprefix, seq); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.integer, 0x80, asnbuf)) < 0) + return -1; + break; + case 1: + sprintf(tagseq, "%s.1-%d", tagprefix, seq); + if((retval = AddTLV(tagseq, arg.number[0], arg.number + 1, 0x80, asnbuf)) < 0) + return -1; + break; + case 2: + sprintf(tagseq, "%s.2-%d", tagprefix, seq); + if((retval = AddTLV(tagseq, 2, (u8 *) & arg.time, 0x80, asnbuf)) < 0) + return -1; + break; + case 3: + sprintf(tagseq, "%s.3-%d", tagprefix, seq); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.date, 0x80, asnbuf)) < 0) + return -1; + break; + case 4: + sprintf(tagseq, "%s.4-%d", tagprefix, seq); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.price, 0x80, asnbuf)) < 0) + return -1; + break; + } + return retval; +} + +int decVariablePart(char *tagprefix, CapVariablePart * parg, ASN_BUF * asnbuf) +{ + //char tagseq[32]; + int len; + char msgbuf[64]; + u_short tagcode; + + /*char tagseq[16]; + u_char msgbuf[64]; + int len; + u_short tagcode; + + sprintf(tagseq, "%s.-1", tagprefix); //get first tlv + if(GetAnyTLV(tagseq, 64, msgbuf, NULL, &tagcode, asnbuf) < 0) */ + + if((len = GetAnyTLV(tagprefix, 64, msgbuf, NULL, &tagcode, asnbuf)) > 0) + { + switch (tagcode) + { + case 0: + memcpy(&parg->integer, msgbuf, len); + parg->choice_id = 0; + return 1; + case 1: + memcpy(parg->number + 1, msgbuf, len); + parg->number[0] = len; + parg->choice_id = 1; + return 1; + case 2: + memcpy(parg->time, msgbuf, len); + parg->choice_id = 2; + return 1; + case 3: + memcpy(parg->date, msgbuf, len); + parg->choice_id = 3; + return 1; + case 4: + memcpy(parg->price, msgbuf, len); + parg->choice_id = 4; + return 1; + } + } + return -1; + /*sprintf(tagseq, "%s.0", tagprefix); + if(GetTLV(tagseq,4,(u8 *)&parg->integer,0x80,asnbuf)>0) + { + parg->choice_id = 0; + return 1; + } + sprintf(tagseq, "%s.1", tagprefix); + if((len=GetTLV(tagseq,maxDigitsLength,parg->number+1,0x80,asnbuf))>0) + { + parg->number[0] = len; + parg->choice_id = 1; + return 1; + } + sprintf(tagseq, "%s.2", tagprefix); + if(GetTLV(tagseq,2,(u8 *)&parg->time,0x80,asnbuf)>0) + { + parg->choice_id = 2; + return 1; + } + sprintf(tagseq, "%s.3", tagprefix); + if(GetTLV(tagseq,4,(u8 *)&parg->date,0x80,asnbuf)>0) + { + parg->choice_id = 3; + return 1; + } + sprintf(tagseq, "%s.4", tagprefix); + if(GetTLV(tagseq,4,(u8 *)&parg->price,0x80,asnbuf)>0) + { + parg->choice_id = 4; + return 1; + } + return -1; */ +} + +int encMessageID(char *tagprefix, CapMessageID arg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = 0; + int index; + + switch (arg.choice_id) + { + case 0: + sprintf(tagseq, "%s.0", tagprefix); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.elementaryMessageID, 0x80, asnbuf)) < 0) + return -1; + break; + case 1: //text + break; + case 2: + for(index = 0; index < arg.elementaryMessageIDs.num; index++) + { + sprintf(tagseq, "%s.29-%d", tagprefix, index + 1); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.elementaryMessageIDs.elementaryMessageID[index], 0x80, asnbuf)) < 0) + return -1; + } + break; + case 3: + sprintf(tagseq, "%s.30.0", tagprefix); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.variableMessage.elementaryMessageID, 0x80, asnbuf)) < 0) + return -1; + for(index = 0; index < arg.variableMessage.variableParts.num; index++) + { + sprintf(tagseq, "%s.30.1", tagprefix); + if((retval = encVariablePart(index + 1, tagseq, arg.variableMessage.variableParts.variablePart[index], asnbuf)) < 0) + return -1; + } + break; + } + return retval; +} + +int decMessageID(char *tagprefix, CapMessageID * parg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int index , ret = 0 ; + + sprintf(tagseq, "%s.0", tagprefix); + if(GetTLV(tagseq, 4, (u8 *) & parg->elementaryMessageID, 0x80, asnbuf) > 0) + { + parg->choice_id = 0; + return 1; + } + + parg->elementaryMessageIDs.num = 0; + for(index = 0; index < numOfMessageIDs; index++) + { + sprintf(tagseq, "%s.29-%d", tagprefix, index + 1); + if(GetTLV(tagseq, 4, (u8 *) & parg->elementaryMessageIDs.elementaryMessageID[index], 0x80, asnbuf) > 0) + { + parg->elementaryMessageIDs.num++; + ret = 1; + } + } + if( ret ) + { + parg->choice_id = 2; + return 1; + } + + sprintf(tagseq, "%s.30.0", tagprefix); + if(GetTLV(tagseq, 4, (u8 *) & parg->variableMessage.elementaryMessageID, 0x80, asnbuf) < 0) + return -1; + parg->variableMessage.variableParts.num = 0; + for(index = 0; index < 5; index++) + { + sprintf(tagseq, "%s.30.1.-%d", tagprefix, index + 1); + if(decVariablePart(tagseq, &parg->variableMessage.variableParts.variablePart[index], asnbuf) >= 0) + { + parg->variableMessage.variableParts.num++; + ret = 1; + } + } + if( ret ) + { + parg->choice_id = 3; + return 1; + } + return -1; +} + +int encInbandInfo(char *tagprefix, CapInbandInfo arg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = 0; + + sprintf(tagseq, "%s.0", tagprefix); + if((retval = encMessageID(tagseq, arg.messageID, asnbuf)) < 0) + return -1; + if(check_bit(arg.optional_flag, 0)) + { + sprintf(tagseq, "%s.1", tagprefix); + if((retval = AddInteger(tagseq, arg.numberOfRepetitions, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 1)) + { + sprintf(tagseq, "%s.2", tagprefix); + if((retval = AddInteger(tagseq, arg.duration, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 2)) + { + sprintf(tagseq, "%s.3", tagprefix); + if((retval = AddInteger(tagseq, arg.interval, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decInbandInfo(char *tagprefix, CapInbandInfo * parg, ASN_BUF * asnbuf) +{ + char tagseq[32]; + int retval = -1; + + parg->optional_flag = 0; + sprintf(tagseq, "%s.0", tagprefix); + if(decMessageID(tagseq, &parg->messageID, asnbuf) >= 0) + { + retval = 1; + } + sprintf(tagseq, "%s.1", tagprefix); + if((GetInteger(tagseq, &parg->numberOfRepetitions, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 0); + } + sprintf(tagseq, "%s.2", tagprefix); + if((GetInteger(tagseq, &parg->duration, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 1); + } + sprintf(tagseq, "%s.3", tagprefix); + if((GetInteger(tagseq, &parg->interval, 0x80, asnbuf)) > 0) + { + set_bit(parg->optional_flag, 2); + } + return retval; +} + +int encTone(char *tagprefix, CapTone arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = 0; + + sprintf(tagseq, "%s.0", tagprefix); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.toneID, 0x80, asnbuf)) < 0) + return -1; + if(check_bit(arg.optional_flag, 0)) + { + sprintf(tagseq, "%s.1", tagprefix); + if((retval = AddTLV(tagseq, 4, (u8 *) & arg.duration, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decTone(char *tagprefix, CapTone * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval = -1; + + parg->optional_flag = 0; + sprintf(tagseq, "%s.0", tagprefix); + if(GetTLV(tagseq, 4, (u8 *) & parg->toneID, 0x80, asnbuf) > 0) + { + retval = 1; + } + sprintf(tagseq, "%s.1", tagprefix); + if(GetTLV(tagseq, 4, (u8 *) & parg->duration, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 0); + } + return retval; +} + +int encInformationToSend(char *tagprefix, CapInformationToSend arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval; + + switch (arg.choice_id) + { + case 0: + sprintf(tagseq, "%s.0", tagprefix); + if((retval = encInbandInfo(tagseq, arg.inbandInfo, asnbuf)) < 0) + return -1; + break; + case 1: + sprintf(tagseq, "%s.1", tagprefix); + if((retval = encTone(tagseq, arg.tone, asnbuf)) < 0) + return -1; + break; + } + return retval; +} + +int decInformationToSend(char *tagprefix, CapInformationToSend * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + + sprintf(tagseq, "%s.0", tagprefix); + if(decInbandInfo(tagseq, &parg->inbandInfo, asnbuf) >= 0) + { + parg->choice_id = 0; + return 1; + } + sprintf(tagseq, "%s.1", tagprefix); + if(decTone(tagseq, &parg->tone, asnbuf) >= 0) + { + parg->choice_id = 1; + return 1; + } + return -1; +} + +int encCollectedDigits(char *tagprefix, CapCollectedDigits arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval; + + sprintf(tagseq, "%s.0", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.minimumNbOfDigits, 0x80, asnbuf)) < 0) + return -1; + sprintf(tagseq, "%s.1", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.maximumNbOfDigits, 0x80, asnbuf)) < 0) + return -1; + + if(check_bit(arg.optional_flag, 0)) + { + sprintf(tagseq, "%s.2", tagprefix); + if((retval = AddTLV(tagseq, arg.endOfReplyDigit[0], arg.endOfReplyDigit + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 1)) + { + sprintf(tagseq, "%s.3", tagprefix); + if((retval = AddTLV(tagseq, arg.cancelDigit[0], arg.cancelDigit + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 2)) + { + sprintf(tagseq, "%s.4", tagprefix); + if((retval = AddTLV(tagseq, arg.startDigit[0], arg.startDigit + 1, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 3)) + { + sprintf(tagseq, "%s.5", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.firstDigitTimeOut, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 4)) + { + sprintf(tagseq, "%s.6", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.interDigitTimeOut, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 5)) + { + sprintf(tagseq, "%s.7", tagprefix); + if((retval = AddTLV(tagseq, 1, (u8 *) & arg.errorTreatment, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 6)) + { + sprintf(tagseq, "%s.8", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.interruptableAnnInd, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 7)) + { + sprintf(tagseq, "%s.9", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.voiceInformation, 0x80, asnbuf)) < 0) + return -1; + } + if(check_bit(arg.optional_flag, 8)) + { + sprintf(tagseq, "%s.10", tagprefix); + if((retval = AddTLV(tagseq, 1, &arg.voiceBack, 0x80, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decCollectedDigits(char *tagprefix, CapCollectedDigits * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int len; + + parg->optional_flag = 0; + sprintf(tagseq, "%s.0", tagprefix); + if(GetTLV(tagseq, 1, &parg->minimumNbOfDigits, 0x80, asnbuf) < 0) + ; //return -1; + sprintf(tagseq, "%s.1", tagprefix); + if(GetTLV(tagseq, 1, &parg->maximumNbOfDigits, 0x80, asnbuf) < 0) + return -1; + + sprintf(tagseq, "%s.2", tagprefix); + if((len = GetTLV(tagseq, 3, parg->endOfReplyDigit + 1, 0x80, asnbuf)) > 0) + { + parg->endOfReplyDigit[0] = len; + set_bit(parg->optional_flag, 0); + } + sprintf(tagseq, "%s.3", tagprefix); + if((len = GetTLV(tagseq, 3, parg->cancelDigit + 1, 0x80, asnbuf)) > 0) + { + parg->cancelDigit[0] = len; + set_bit(parg->optional_flag, 1); + } + sprintf(tagseq, "%s.4", tagprefix); + if((len = GetTLV(tagseq, 3, parg->startDigit + 1, 0x80, asnbuf)) > 0) + { + parg->startDigit[0] = len; + set_bit(parg->optional_flag, 2); + } + sprintf(tagseq, "%s.5", tagprefix); + if(GetTLV(tagseq, 1, &parg->firstDigitTimeOut, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 3); + } + sprintf(tagseq, "%s.6", tagprefix); + if(GetTLV(tagseq, 1, &parg->interDigitTimeOut, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 4); + } + sprintf(tagseq, "%s.7", tagprefix); + if(GetTLV(tagseq, 1, (u8 *) & parg->errorTreatment, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 5); + } + sprintf(tagseq, "%s.8", tagprefix); + if(GetTLV(tagseq, 1, &parg->interruptableAnnInd, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 6); + } + sprintf(tagseq, "%s.9", tagprefix); + if(GetTLV(tagseq, 1, &parg->voiceInformation, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 7); + } + sprintf(tagseq, "%s.10", tagprefix); + if(GetTLV(tagseq, 1, &parg->voiceBack, 0x80, asnbuf) > 0) + { + set_bit(parg->optional_flag, 8); + } + return 1; +} + +int encCollectedInfo(char *tagprefix, CapCollectedInfo arg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + int retval; + + if(arg.choice_id == 0) + { + sprintf(tagseq, "%s.0", tagprefix); + if((retval = encCollectedDigits(tagseq, arg.collectedDigits, asnbuf)) < 0) + return -1; + } + return retval; +} + +int decCollectedInfo(char *tagprefix, CapCollectedInfo * parg, ASN_BUF * asnbuf) +{ + char tagseq[16]; + + sprintf(tagseq, "%s.0", tagprefix); + if(decCollectedDigits(tagseq, &parg->collectedDigits, asnbuf) >= 0) + { + parg->choice_id = 0; + return 1; + } + return -1; +} + +#endif diff --git a/omc/plat/xapp/src/capp/cap_public.c b/omc/plat/xapp/src/capp/cap_public.c new file mode 100644 index 0000000..3710f47 --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_public.c @@ -0,0 +1,497 @@ +/* CAP public function c file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "../../../public/src/include/pub_include.h" +#include "../../../sccp/src/include/sccp.h" +#include "../mapp/map_const.h" +#include "../mapp/map_code.h" +#include "../mapp/map_struct.h" +#include "cap_head.h" + +void cap_get_sccpadd(struct SCCP_ADDRESS *add_ptr, u8 * data) +{ + u8 temp_len; + + add_ptr->ip = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]; + add_ptr->DPC = (data[4] << 24) + (data[5] << 16) + (data[6] << 8) + data[7]; + add_ptr->NetID = data[8]; + add_ptr->SSN = data[9]; + add_ptr->RI = data[10]; + add_ptr->GTI = data[11]; + add_ptr->TT = data[12]; + add_ptr->NP = data[13]; + add_ptr->ES = data[14]; + add_ptr->NAI = data[15]; + add_ptr->len = data[16]; + temp_len = (data[16] + 1) / 2; + memcpy(add_ptr->GTAI, data + 17, temp_len); +} + +void cap_set_sccpadd(struct SCCP_ADDRESS *add_ptr, u8 * data) +{ + u8 temp_len; + + data[0] = add_ptr->ip >> 24; + data[1] = add_ptr->ip >> 16; + data[2] = add_ptr->ip >> 8; + data[3] = add_ptr->ip; + data[4] = add_ptr->DPC >> 24; + data[5] = add_ptr->DPC >> 16; + data[6] = add_ptr->DPC >> 8; + data[7] = add_ptr->DPC; + data[8] = add_ptr->NetID; + data[9] = add_ptr->SSN; + data[10] = add_ptr->RI; + data[11] = add_ptr->GTI; + data[12] = add_ptr->TT; + data[13] = add_ptr->NP; + data[14] = add_ptr->ES; + data[15] = add_ptr->NAI; + data[16] = add_ptr->len; + temp_len = (add_ptr->len + 1) / 2; + memcpy(data + 17, add_ptr->GTAI, temp_len); +} + +u8 cap_com_ftos(struct MapComSrv_struct *map_com, u8 * data_flow) +{ // common service data flow to structure + u32 aa; + u32 len; + u8 ii; + u8 delimiter_flag = 0; + struct MapOpen_Arg *open_arg; + struct MapOpen_Res *open_res; + struct MapClose_Arg *close_ptr; + struct MapUAbort_Arg *uabrt_ptr; + struct MapPAbort_Arg *pabrt_ptr; + + len = (data_flow[0] << 8) + data_flow[1]; + if(len < 9) // data flow is too short + return 0; + if(data_flow[2] != CAP_FLAG) + return 0; + map_com->port_id = (data_flow[3] << 8) + data_flow[4]; + map_com->dialogue_id = (data_flow[6] << 8) + data_flow[7]; + map_com->message_type = data_flow[9]; + map_com->message_flag = data_flow[10]; + switch (map_com->message_type) + { + case MAP_OPEN: + if(map_com->message_flag == MAP_REQUEST || map_com->message_flag == MAP_INDICATE) + { + open_arg = (MapOpen_Arg *) & map_com->dlg_list.open_arg; + open_arg->acn_data.acn = data_flow[11]; + open_arg->acn_data.acn_ver = data_flow[12]; + cap_get_sccpadd(&open_arg->peer_add, data_flow + 13); + cap_get_sccpadd(&open_arg->local_add, data_flow + 41); + open_arg->param_flag = 0x0b; + aa = 70; + for(ii = 0; ii < 3; ii++) + { + if(data_flow[aa] == 0x00) + break; + else if(data_flow[aa] == 0x01) // peer reference + { + len = data_flow[aa + 1]; + if(len > ISDN_LEN) + return 0; + open_arg->peerref_len = len; + memcpy(open_arg->peer_reference, &data_flow[aa + 2], len); + aa += len + 2; + open_arg->param_flag |= 0x04; + } + else if(data_flow[aa] == 0x02) // local reference + { + len = data_flow[aa + 1]; + if(len > ISDN_LEN) + return 0; + open_arg->localref_len = len; + memcpy(open_arg->local_reference, &data_flow[aa + 2], len); + aa += len + 2; + open_arg->param_flag |= 0x10; + } + else if(data_flow[aa] == 0x03) // specific info + { + len = data_flow[aa + 1]; + if(len >= MAX_SPCINFO_LEN) + return 0; + open_arg->specific_info.info_len = len; + memcpy(open_arg->specific_info.info_data, &data_flow[aa + 2], len); + open_arg->param_flag |= 0x20; + aa += 2 + len; + } + else if(data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + } + } + } + else if(map_com->message_flag == MAP_RESPONSE || map_com->message_flag == MAP_CONFIRM) + { + open_res = (MapOpen_Res *) & map_com->dlg_list.open_res; + open_res->result = data_flow[11]; + open_res->param_flag = 0x08; + aa = 13; + for(ii = 0; ii < 4; ii++) + { + if(data_flow[aa] == 0x00) + break; + else if(data_flow[aa] == 0x01) // acn + { + open_res->acn_data.acn = data_flow[aa + 2]; + open_res->acn_data.acn_ver = data_flow[aa + 3]; + aa += 4; + open_res->param_flag |= 0x01; + } + else if(data_flow[aa] == 0x02) // specific info + { + len = data_flow[aa + 1]; + if(len >= MAX_SPCINFO_LEN) + return 0; + open_res->specific_info.info_len = len; + memcpy(open_res->specific_info.info_data, &data_flow[aa + 2], len); + open_res->param_flag |= 0x02; + aa += 2 + len; + } + else if(data_flow[aa] == 0x03) // refuse reason + { + open_res->refuse_reason = data_flow[aa + 2]; + open_res->param_flag |= 0x10; + aa += 3; + } + else if(data_flow[aa] == 0x04) // provider error + { + open_res->provider_error = data_flow[aa + 2]; + open_res->param_flag |= 0x20; + aa += 3; + } + else if(data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + } + } + } + else + return 0; + break; + case MAP_CLOSE: + close_ptr = (MapClose_Arg *) & map_com->dlg_list.close_arg; + close_ptr->release_method = data_flow[11]; + close_ptr->param_flag = 0x01; + if(data_flow[13] == 0x01) + { + len = data_flow[14]; + if(len >= MAX_SPCINFO_LEN) + return 0; + close_ptr->specific_info.info_len = len; + memcpy(close_ptr->specific_info.info_data, &data_flow[15], len); + close_ptr->param_flag |= 0x02; + } + break; + case MAP_U_ABORT: + uabrt_ptr = (MapUAbort_Arg *) & map_com->dlg_list.uabort_arg; + uabrt_ptr->user_reason = data_flow[11]; + uabrt_ptr->param_flag = 0x01; + aa = 13; + for(ii = 0; ii < 2; ii++) + { + if(data_flow[aa] == 0) + break; + else if(data_flow[aa] == 0x01) // diagnostic flag + { + uabrt_ptr->diag_info = data_flow[aa + 2]; + uabrt_ptr->param_flag |= 0x02; + aa += 3; + } + else if(data_flow[aa] == 0x02) // specific info + { + len = data_flow[aa + 1]; + if(len >= MAX_SPCINFO_LEN) + return 0; + uabrt_ptr->specific_info.info_len = len; + memcpy(uabrt_ptr->specific_info.info_data, &data_flow[aa + 2], len); + uabrt_ptr->param_flag |= 0x04; + aa += 2 + len; + } + } + break; + case MAP_P_ABORT: + pabrt_ptr = (MapPAbort_Arg *) & map_com->dlg_list.pabort_arg; + pabrt_ptr->provider_reason = data_flow[11]; + pabrt_ptr->source = data_flow[12]; + pabrt_ptr->param_flag = 0x03; + break; + case MAP_NOTICE: + map_com->dlg_list.notice_arg.problem = data_flow[11]; + map_com->dlg_list.notice_arg.param_flag = 0x01; + break; + case MAP_DELIMITER: + case MAP_LINK: + break; + default: + return 0; + break; + } + if(delimiter_flag == 1) + return 2; + else + return 1; +} + +void cap_com_stof(struct MapComSrv_struct *com_ptr, u8 * data_flow, u8 delimiter_flag) +{ // transfer common structure to data flow + u32 ii; + u32 len; + struct MapOpen_Arg *open_arg; + struct MapOpen_Res *open_res; + struct MapClose_Arg *close_arg; + struct MapUAbort_Arg *uabrt_arg; + + data_flow[2] = CAP_FLAG; + data_flow[3] = com_ptr->port_id >> 8; + data_flow[4] = com_ptr->port_id; + data_flow[6] = com_ptr->dialogue_id >> 8; + data_flow[7] = com_ptr->dialogue_id; + data_flow[9] = com_ptr->message_type; + data_flow[10] = com_ptr->message_flag; + ii = 11; + switch (com_ptr->message_type) + { + case MAP_OPEN: + if(com_ptr->message_flag == MAP_INDICATE || com_ptr->message_flag == MAP_REQUEST) + { + open_arg = (MapOpen_Arg *) & com_ptr->dlg_list.open_arg; + data_flow[ii++] = open_arg->acn_data.acn; + data_flow[ii++] = open_arg->acn_data.acn_ver; + cap_set_sccpadd(&open_arg->peer_add, data_flow + ii); + ii += 28; + cap_set_sccpadd(&open_arg->local_add, data_flow + ii); + ii += 28; + data_flow[ii++] = 1; // optional point + if((open_arg->param_flag & 0x04)) // has peer reference address + { + data_flow[ii++] = 0x01; + len = open_arg->peerref_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, open_arg->peer_reference, len); + ii += len; + } + if((open_arg->param_flag & 0x10)) // has local reference address + { + data_flow[ii++] = 0x02; + len = open_arg->localref_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, open_arg->local_reference, len); + ii += len; + } + if((open_arg->param_flag & 0x20)) + { + data_flow[ii++] = 0x03; + len = open_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, open_arg->specific_info.info_data, len); + ii += len; + } + if(delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + } + data_flow[ii++] = 0x00; + } + else if(com_ptr->message_flag == MAP_RESPONSE || com_ptr->message_flag == MAP_CONFIRM) + { + open_res = (MapOpen_Res *) & com_ptr->dlg_list.open_res; + data_flow[ii++] = open_res->result; + data_flow[ii++] = 0x01; // optional point + if((open_res->param_flag & 0x01)) // has ACN + { + data_flow[ii++] = 0x01; + data_flow[ii++] = 2; + data_flow[ii++] = open_res->acn_data.acn; + data_flow[ii++] = open_res->acn_data.acn_ver; + } + if((open_res->param_flag & 0x02)) // has specific info + { + data_flow[ii++] = 0x02; + len = open_res->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, open_res->specific_info.info_data, len); + ii += len; + } + if((open_res->param_flag & 0x10)) // has refuse reason + { + data_flow[ii++] = 0x03; + data_flow[ii++] = 1; + data_flow[ii++] = open_res->refuse_reason; + } + if((open_res->param_flag & 0x20)) // has provider error + { + data_flow[ii++] = 0x04; + data_flow[ii++] = 1; + data_flow[ii++] = open_res->provider_error; + } + if(delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + } + data_flow[ii++] = 0x00; + } + break; + case MAP_CLOSE: + close_arg = (MapClose_Arg *) & com_ptr->dlg_list.close_arg; + data_flow[ii++] = close_arg->release_method; + data_flow[ii++] = 0x01; // optional point + if((close_arg->param_flag & 0x02)) // has specific info + { + data_flow[ii++] = 0x01; + len = close_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, close_arg->specific_info.info_data, len); + ii += len; + } + data_flow[ii++] = 0x00; + break; + case MAP_U_ABORT: + uabrt_arg = (MapUAbort_Arg *) & com_ptr->dlg_list.uabort_arg; + data_flow[ii++] = uabrt_arg->user_reason; + data_flow[ii++] = 0x01; // optional point + if((uabrt_arg->param_flag & 0x02)) + { + data_flow[ii++] = 0x01; + data_flow[ii++] = 1; + data_flow[ii++] = uabrt_arg->diag_info; + } + if((uabrt_arg->param_flag & 0x04)) // has specific info + { + data_flow[ii++] = 0x02; + len = uabrt_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow + ii, uabrt_arg->specific_info.info_data, len); + ii += len; + } + data_flow[ii++] = 0x00; + break; + case MAP_P_ABORT: + data_flow[ii++] = com_ptr->dlg_list.pabort_arg.provider_reason; + data_flow[ii++] = com_ptr->dlg_list.pabort_arg.source; + break; + case MAP_NOTICE: + data_flow[ii++] = com_ptr->dlg_list.notice_arg.problem; + break; + default: + break; + } + ii -= 2; + data_flow[0] = ii >> 8; + data_flow[1] = ii; +} + +u8 cap_opr_ftos(struct MapOprData_struct *opr_ptr, u8 * data_flow) +{ // transfer opration data flow to structure + u32 aa; + u32 len; + u8 ii; + u8 delimiter_flag = 0; + + len = (data_flow[0] << 8) + data_flow[1]; + if(len < 10) + return 0; + if(data_flow[2] != CAP_FLAG) + return 0; + opr_ptr->port_id = (data_flow[3] << 8) + data_flow[4]; + opr_ptr->dialogue_id = (data_flow[6] << 8) + data_flow[7]; + opr_ptr->message_type = data_flow[9]; + opr_ptr->message_flag = data_flow[10]; + opr_ptr->invoke_id = data_flow[11]; + opr_ptr->param_flag = 0x1f; + opr_ptr->param_len = 0; + aa = 13; + for(ii = 0; ii < 2; ii++) + { + if(data_flow[aa] == 0x00) + break; + else if(data_flow[aa] == 0x01) // parameter + { + len = (data_flow[aa + 1] << 8) + data_flow[aa + 2]; + if(len > MAX_MAPPOPR_LEN) + return 0; + opr_ptr->param_len = len; + memcpy(opr_ptr->param, &data_flow[aa + 3], len); + aa += len + 3; + opr_ptr->param_flag |= 0x20; + } + else if(data_flow[aa] == 0x02) // user error + { + opr_ptr->user_error = data_flow[aa + 2]; + opr_ptr->param_flag |= 0x40; + aa += 3; + } + else if(data_flow[aa] == 0x03) // provider error + { + opr_ptr->provider_error = data_flow[aa + 2]; + opr_ptr->param_flag |= 0x80; + aa += 3; + } + else if(data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + } + } + if(delimiter_flag == 1) + return 2; + else + return 1; +} + +void cap_opr_stof(struct MapOprData_struct *opr_ptr, u8 * data_flow, u8 delimiter_flag) +{ // transfer opration structure to data flow + u32 ii; + u32 len; + + data_flow[2] = CAP_FLAG; + data_flow[3] = opr_ptr->port_id >> 8; + data_flow[4] = opr_ptr->port_id; + data_flow[6] = opr_ptr->dialogue_id >> 8; + data_flow[7] = opr_ptr->dialogue_id; + data_flow[9] = opr_ptr->message_type; + data_flow[10] = opr_ptr->message_flag; + data_flow[11] = opr_ptr->invoke_id; + data_flow[12] = 1; + ii = 13; + if((opr_ptr->param_flag & 0x20)) // has component + { + data_flow[ii++] = 0x01; + len = opr_ptr->param_len; + data_flow[ii++] = len >> 8; + data_flow[ii++] = len; + memcpy(data_flow + ii, opr_ptr->param, len); + ii += len; + } + if((opr_ptr->param_flag & 0x40)) // has user error + { + data_flow[ii++] = 0x02; + data_flow[ii++] = 1; + data_flow[ii++] = opr_ptr->user_error; + } + if((opr_ptr->param_flag & 0x80)) // has provider error + { + data_flow[ii++] = 0x03; + data_flow[ii++] = 1; + data_flow[ii++] = opr_ptr->provider_error; + } + if(delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + } + data_flow[ii++] = 0; + ii -= 2; + data_flow[0] = ii >> 8; + data_flow[1] = ii; +} diff --git a/omc/plat/xapp/src/capp/cap_public.h b/omc/plat/xapp/src/capp/cap_public.h new file mode 100644 index 0000000..7ea157f --- /dev/null +++ b/omc/plat/xapp/src/capp/cap_public.h @@ -0,0 +1,14 @@ +/* CAP public function head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _CAP_PUBLIC +#define _CAP_PUBLIC + +u8 cap_com_ftos(struct MapComSrv_struct *map_com, u8 * data_flow); +void cap_com_stof(struct MapComSrv_struct *com_ptr, u8 * data_flow, u8 delimiter_flag); +u8 cap_opr_ftos(struct MapOprData_struct *opr_ptr, u8 * data_flow); +void cap_opr_stof(struct MapOprData_struct *opr_ptr, u8 * data_flow, u8 delimiter_flag); + +#endif diff --git a/omc/plat/xapp/src/capp/icap.h b/omc/plat/xapp/src/capp/icap.h new file mode 100644 index 0000000..0ad3d4b --- /dev/null +++ b/omc/plat/xapp/src/capp/icap.h @@ -0,0 +1,20 @@ +/* CAP message interface head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _CAP_INTERFACE +#define _CAP_INTERFACE + +#include "cap_head.h" +#include "cap_msg.h" + +int encode_capmsg(struct CapArg caparg, u8 * msgbuf, u16 maxlen); + +#ifdef _SRF_RELEVANT +int decode_capmsg(char *msgbuf, u16 msglen, u8 ocode, u8 otype, struct CapArg *pcaparg); +#else +int decode_capmsg(char *msgbuf, u16 msglen, u8 ocode, struct CapArg *pcaparg); +#endif + +#endif diff --git a/omc/plat/xapp/src/conv_prefix.c b/omc/plat/xapp/src/conv_prefix.c new file mode 100644 index 0000000..3f4f76f --- /dev/null +++ b/omc/plat/xapp/src/conv_prefix.c @@ -0,0 +1,1054 @@ +#include +#include +#include +#include + +#include "../../snmp/src/include/snmp.h" +#include "../../snmp/src/include/macro.h" + +#include "conv_prefix.h" +#include "../../public/src/uwav/numgrp.h" +#include "../../public/src/uwav/number.h" + +_conv_prefix conv_prefix; + +#define ASN_1_OCTET_STRING 4 +#define ASN_1_INTEGER 1 + + +struct numgrp_table *xapp_grptab_ptr=NULL; + +extern int xap_get_response(u8 oidlen,u32 *oid,u8 *pdata,u8 *vartype); +extern int xap_set_response(u8 oidlen,u32 *oid,u8 *pdata,u16 datalen); + +/*------------------------------------------------------------------*/ + +int readConvPrefixConf() +{ + char filename[]="./conf/conv_prefix.conf"; + FILE *fpConf = NULL; + + fpConf = fopen(filename,"r"); + if(fpConf == NULL) return 0; + fread(&conv_prefix,sizeof(_conv_prefix),1,fpConf); + fclose(fpConf); +/* + for(i=0;i=MAX_CONV_PREFIX) return 0; + if(datalen<19) return 0; + + conv_prefix.conv_prefix[instance].used_flag = 1; + memcpy(conv_prefix.conv_prefix[instance].prefix,pdata,16); + conv_prefix.conv_prefix[instance].delete_length = pdata[16]; + conv_prefix.conv_prefix[instance].add_length = pdata[17]; + memcpy(conv_prefix.conv_prefix[instance].add_digits,&pdata[18],16); + conv_prefix.conv_prefix[instance].valid_length = pdata[34]; + if(datalen==43) + { + memset(conv_prefix.conv_name[instance],0,MAX_NAME_LEN); + memcpy(conv_prefix.conv_name[instance],&pdata[35],MAX_NAME_LEN); + } + if(instance == MAX_CONV_PREFIX-1) saveConvPrefix(); + return datalen; +} + +int snmpGetConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype) +{ + DWORD instance; + + *vartype = 0x04; + if(oidlen<16) return 0; + instance = oid[15]; + memcpy(pdata,conv_prefix.conv_prefix[instance].prefix,16); + pdata[16] = conv_prefix.conv_prefix[instance].delete_length; + pdata[17] = conv_prefix.conv_prefix[instance].add_length; + memcpy(&pdata[18],conv_prefix.conv_prefix[instance].add_digits,16); + pdata[34] = conv_prefix.conv_prefix[instance].valid_length; + memcpy(&pdata[35],conv_prefix.conv_name[instance],MAX_NAME_LEN); + return 35+8; +} + +int snmpSetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen) +{ + DWORD instance; + + if(oidlen<15) return 0; + instance = oid[14]; + if(instance>=MAX_CLI_PREFIX) return 0; + if(datalen<19) return 0; + + conv_prefix.cli_prefix[instance].in_property = pdata[0]; + memcpy(conv_prefix.cli_prefix[instance].prefix,&pdata[1],16); + conv_prefix.cli_prefix[instance].delete_length = pdata[17]; + conv_prefix.cli_prefix[instance].out_property = pdata[18]; + conv_prefix.cli_prefix[instance].add_length = pdata[19]; + memcpy(conv_prefix.cli_prefix[instance].add_digits,&pdata[20],16); + conv_prefix.cli_prefix[instance].valid_length = pdata[36]; + if(datalen == 45) + { + memset(conv_prefix.cli_name[instance],0,MAX_NAME_LEN); + memcpy(conv_prefix.cli_name[instance],&pdata[37],MAX_NAME_LEN); + } + if(instance == MAX_CLI_PREFIX-1) saveConvPrefix(); + return datalen; +} + +int snmpGetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype) +{ + DWORD instance; + + *vartype = 0x04; + if(oidlen<15) return 0; + instance = oid[14]; + if(instance>=MAX_CLI_PREFIX) return 0; + pdata[0] = conv_prefix.cli_prefix[instance].in_property; + memcpy(&pdata[1],conv_prefix.cli_prefix[instance].prefix,16); + pdata[17] = conv_prefix.cli_prefix[instance].delete_length; + pdata[18] = conv_prefix.cli_prefix[instance].out_property; + pdata[19] = conv_prefix.cli_prefix[instance].add_length; + memcpy(&pdata[20],conv_prefix.cli_prefix[instance].add_digits,16); + pdata[36] = conv_prefix.cli_prefix[instance].valid_length; + memcpy(&pdata[37],conv_prefix.cli_name[instance],MAX_NAME_LEN); + return 37+8; +} + +int msisdnUnkToInt(char *msisdn_unk, char *msisdn_int) +/* return value: + -1 = error length; + 0 = cannn't find appropriate prefix; + 1 = conv. succeed +*/ +{ + int retval = 0, index = -1; + int loop,len=0,max_len=0,old_len; + int delete_len,add_len; + + index = xappSearchGroupTable(msisdn_unk); + if(index>=0) + { + char tmpStart[17],tmpEnd[17]; + + strcpy(tmpStart,msisdn_unk); + tmpStart[conv_prefix.group_conv_prefix[index].repStartDigit] = 0; + + strcpy(tmpEnd,&msisdn_unk[conv_prefix.group_conv_prefix[index].repEndDigit]); + + sprintf(msisdn_int,"%s%s%s", + tmpStart, + conv_prefix.group_conv_prefix[index].repDigitWith, + tmpEnd); + + return 1; + } + for(loop=0;loop0) + { + if(len>max_len) + if(strncasecmp(msisdn_unk, + conv_prefix.conv_prefix[loop].prefix, + len)==0) + { + max_len = len; + index = loop; + }//cmp + }//len>0 + }//used + } + + if(index>=0 && index24) len = 24; + old_len = len; + + /* + len = strlen(msisdn_unk); + + if(len>24) len = 24; + old_len = len; + for(loop=len-1;loop>2;loop--) + { + if(toupper(msisdn_unk[loop])>'C') + len --; + else + break; + } + */ + if(conv_prefix.conv_prefix[index].valid_length>0) + { + if(len != conv_prefix.conv_prefix[index].valid_length) + { + strcpy(msisdn_int,msisdn_unk); + return -1; + } + } + delete_len = conv_prefix.conv_prefix[index].delete_length; + if(delete_len>len) + { + strcpy(msisdn_int,msisdn_unk); + return -1; + } + + add_len = conv_prefix.conv_prefix[index].add_length; + if(add_len != strlen(conv_prefix.conv_prefix[index].add_digits)) + { + strcpy(msisdn_int,msisdn_unk); + return -1; + } + strcpy(msisdn_int, + conv_prefix.conv_prefix[index].add_digits); + strcat(msisdn_int, + &msisdn_unk[delete_len]); + msisdn_int[add_len+old_len-delete_len] = 0; + retval = 1; + } + return retval; +} + +int cliUptoCalled(char *caller, char *called) +{ + char callerBuf[128],tmpBuf[128];//tmpBuf1[128]; + int loop0=0,loop=0,index=-1,index1=-1;/*1=91 IDD,2=A1 NDD,3=81 UNK*/ + int len=0,maxlen=0,delete_len=0, add_len=0; + int times = 1; + + if(called != NULL) + times = 2; + + strcpy(callerBuf,caller); +// msisdnUnkToInt(callerBuf,caller); + for(loop0=0;loop00 && len>maxlen) + { + if(loop0==0) + { + if(strncasecmp(caller, + tmpBuf, + len)==0) + { + index1 = loop; + maxlen = len; + }//cmp + }else + { + if(strncasecmp(called, + tmpBuf, + len)==0) + { + index = loop; + maxlen = len; + }//cmp + } + }//len>0 + } + } + + if(index1>=0) + { + len = strlen(caller); + delete_len = conv_prefix.cli_prefix[index1].delete_length; + if(delete_len>len) + { + return -1; + } + add_len = conv_prefix.cli_prefix[index1].add_length; + if(add_len != strlen(conv_prefix.cli_prefix[index1].add_digits)) + { + return -1; + } + if(conv_prefix.cli_prefix[index1].out_property == 1) + { + sprintf(caller,"91"); + }else if(conv_prefix.cli_prefix[index1].out_property == 2) + { + sprintf(caller,"a1"); + }else if(conv_prefix.cli_prefix[index1].out_property == 3) + { + sprintf(caller,"81"); + }else + sprintf(caller,"81"); + strcat(caller, + conv_prefix.cli_prefix[index1].add_digits); + strcat(caller, + &callerBuf[delete_len+2]); + len = strlen(callerBuf); + caller[add_len+len-delete_len] = 0; + } + return 1; +} + + +int snmpSetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen) +{ + DWORD instance; + + if(oidlen<15) return 0; + instance = oid[14]; + if(instance>=MAX_PLAT_NAME_INSTANCE) return 0; + if(datalen != MAX_PLAT_NAME_LEN) return 0; + memcpy(conv_prefix.plat_name[instance],pdata,MAX_PLAT_NAME_LEN); + if(instance == MAX_PLAT_NAME_INSTANCE-1) + saveConvPrefix(); + + return datalen; +} + + +int snmpGetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype) +{ + DWORD instance; + + *vartype = 0x04; + if(oidlen<15) return 0; + instance = oid[14]; + if(instance>=MAX_PLAT_NAME_INSTANCE) return 0; + + memcpy(pdata,conv_prefix.plat_name[instance],MAX_PLAT_NAME_LEN); + return MAX_PLAT_NAME_LEN; +} + + +int snmpSetGroupConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen) +{ + DWORD instance; + int len=0, invalid_flag=0; + _xapp_group_prefix tempGroupPrefix; + + if(oidlen<16) return 0; + instance = oid[15]; + if(instance>=MAX_CONV_PREFIX) return 0; + if(datalen<50) return 0; + + memset(&tempGroupPrefix,0,sizeof(_xapp_group_prefix)); + + len = 0; + memcpy(tempGroupPrefix.startNumber,&pdata[len],MAX_PREFIX_LEN); + len += MAX_PREFIX_LEN; + memcpy(tempGroupPrefix.endNumber,&pdata[len],MAX_PREFIX_LEN); + len += MAX_PREFIX_LEN; + tempGroupPrefix.repStartDigit = pdata[len]; + len += 1; + tempGroupPrefix.repEndDigit = pdata[len]; + len += 1; + memcpy(tempGroupPrefix.repDigitWith,&pdata[len],MAX_PREFIX_LEN); + //check validity + if(tempGroupPrefix.repStartDigit>tempGroupPrefix.repEndDigit) + invalid_flag = 1; + if(strcmp(tempGroupPrefix.startNumber,tempGroupPrefix.endNumber)>0) + { + invalid_flag = 1; + } + if(invalid_flag) + { + sprintf(pdata,"Error parameter, start>end!"); + return -2; + } + + memcpy(&conv_prefix.group_conv_prefix[instance],&tempGroupPrefix,sizeof(_xapp_group_prefix)); + + if(instance == MAX_CONV_PREFIX-1){ + saveConvPrefix(); + xappCreateGroupPrefixTable(); + } + + return datalen; +} + +int snmpGetGroupConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype) +{ + DWORD instance; + int len = 0; + + *vartype = 0x04; + if(oidlen<16) return 0; + instance = oid[15]; + if(instance>=MAX_CONV_PREFIX) return 0; + + memcpy(&pdata[len],conv_prefix.group_conv_prefix[instance].startNumber,MAX_PREFIX_LEN); + len += MAX_PREFIX_LEN; + memcpy(&pdata[len],conv_prefix.group_conv_prefix[instance].endNumber,MAX_PREFIX_LEN); + len += MAX_PREFIX_LEN; + pdata[len] = conv_prefix.group_conv_prefix[instance].repStartDigit; + len += 1; + pdata[len] = conv_prefix.group_conv_prefix[instance].repEndDigit; + len += 1; + memcpy(&pdata[len],conv_prefix.group_conv_prefix[instance].repDigitWith,MAX_PREFIX_LEN); + len += MAX_PREFIX_LEN; + return len; +} + +int xappCreateGroupPrefixTable() +{ + int i,len; + struct number_group tmp_num_grp; + + if(xapp_grptab_ptr != NULL) + delete_numgrp_table(xapp_grptab_ptr); + + xapp_grptab_ptr = assign_numgrp_table("xapp",MAX_CONV_PREFIX); + for(i=0;iMAX_PREFIX_LEN) + continue; + len = strlen(conv_prefix.group_conv_prefix[i].startNumber); + tmp_num_grp.start.num_of_digit = len; + memcpy(tmp_num_grp.start.digit,conv_prefix.group_conv_prefix[i].startNumber,len); + + len = strlen(conv_prefix.group_conv_prefix[i].endNumber); + tmp_num_grp.end.num_of_digit = len; + memcpy(tmp_num_grp.end.digit,conv_prefix.group_conv_prefix[i].endNumber,len); + tmp_num_grp.index = i; + + numgrp_insert(xapp_grptab_ptr, + &tmp_num_grp.start, + &tmp_num_grp.end, + tmp_num_grp.index); + } +} + +int xappSearchGroupTable(char *msisdn_unk) +{ + num16_t num16_tmp; + int tmpResult; + int len; + char tmp_number[32]; + + if(xapp_grptab_ptr==NULL) return -1; + + strcpy(tmp_number,msisdn_unk); + StringCut(tmp_number,'E'); + len = strlen(tmp_number); + + if(len==0) return -1; + if(len>MAX_PREFIX_LEN) len = MAX_PREFIX_LEN; + num16_tmp.num_of_digit = len; + memcpy(num16_tmp.digit,tmp_number,len); + if(numgrp_search(&tmpResult,xapp_grptab_ptr,&num16_tmp)) + return tmpResult; + return -1; + +} + +/* -----------------------------------------------------------------------------------------*/ +/* -- following codes support XAPP mib structrue, refer to XAPP mib definition for detail --*/ +/* -- record @2008-10-29 --*/ +/* -----------------------------------------------------------------------------------------*/ + +/* ---------------------------------------------------------------------------*/ +/* ------------------------ function: xap_get_idle_index() -------------------*/ +/* -- type1=manipulation prefix, type2=manipulation group, type3=cli prefix --*/ +/* -- return =0 ,failed, otherwise succeed -----------------------------------*/ +/* ---------------------------------------------------------------------------*/ +int xap_get_idle_index(int type, int *newID) +{ + int i; + + switch(type) + { + case 1: + for(i=1;i= MAX_CONV_PREFIX + || conv_prefix.conv_prefix[index].used_flag == FALSE) + return -1; + + *vartype = ASN_1_OCTET_STRING; + switch(column) + { + case 1: /* index */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = index; + break; + case 2: /* title */ + datalen = strlen(conv_prefix.conv_name[index]); + memcpy(pdata,conv_prefix.conv_name[index],datalen); + break; + case 3: /* prefix */ + datalen = strlen(conv_prefix.conv_prefix[index].prefix); + memcpy(pdata,conv_prefix.conv_prefix[index].prefix,datalen); + break; + case 4: /* delete count */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.conv_prefix[index].delete_length; + break; + case 5:/* insert count */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.conv_prefix[index].add_length; + break; + case 6: /* insert digits */ + datalen = strlen(conv_prefix.conv_prefix[index].add_digits); + memcpy(pdata,conv_prefix.conv_prefix[index].add_digits,datalen); + break; + case 7: /* number length */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.conv_prefix[index].valid_length; + break; + case 8: /* status */ + *vartype = ASN_1_INTEGER; + pdata[0] = 1; /* active */ + datalen = 1; + break; + default: + return -1; + break; + } + return datalen; +} + +int xap_set_manPrefix(DWORD column, DWORD *instance, u_char *pdata, unsigned short datalen) +{ + int index; + int newId; + + if(datalen == 0) + return -1; + + index = instance[0]; + if(index < 0 || index >= MAX_CONV_PREFIX) + return -1; + + switch(column) + { + case 1:/* create */ + if(xap_get_idle_index(1, &newId)) + { + conv_prefix.conv_prefix[index].used_flag = TRUE; + return newId; + } + else + return -1; + break; + case 2: /* title */ + if(datalen>=MAX_NAME_LEN) + return -1; + memset(conv_prefix.conv_name[index], 0, MAX_NAME_LEN); + memcpy(conv_prefix.conv_name[index], pdata, datalen); + break; + case 3: /* prefix */ + if(datalen>=MAX_PREFIX_LEN) + return -1; + memset(conv_prefix.conv_prefix[index].prefix, 0, MAX_PREFIX_LEN); + memcpy(conv_prefix.conv_prefix[index].prefix, pdata, datalen); + break; + case 4: /* delete count */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.conv_prefix[index].delete_length = pdata[0]; + break; + case 5: /* insert count */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.conv_prefix[index].add_length = pdata[0]; + break; + case 6: /* insert digits */ + if(datalen>=MAX_PREFIX_LEN) + return -1; + memset(conv_prefix.conv_prefix[index].add_digits, 0, MAX_PREFIX_LEN); + memcpy(conv_prefix.conv_prefix[index].add_digits, pdata, datalen); + break; + case 7: /* number length */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.conv_prefix[index].valid_length = pdata[0]; + break; + case 8: /* status */ + if(pdata[0] == 6) /* 6==delete */ + { + memset(&conv_prefix.conv_prefix[index],0,sizeof(_conv_prefix_record)); + memset(conv_prefix.conv_name[index], 0, MAX_NAME_LEN); + } + break; + default: + return -1; + break; + } + return datalen; +} + +/*------------------*/ +/*-- group routines --*/ +/*------------------*/ + +int xap_getnext_groupPrefix(DWORD *index_id) +{ + int i; + + if(*index_id == 0) + *index_id = 1; + + for(i = *index_id; i < MAX_CONV_PREFIX; i++) + { + if( strlen(conv_prefix.group_conv_prefix[i].startNumber)) + { + *index_id = i; + return 1; + } + } + *index_id = 0; + return 0; +} + +int xap_get_groupPrefix(DWORD column, DWORD *instance, u_char *pdata, u_char *vartype) +{ + int datalen = 0,index; + + index = instance[0]; + if(index < 0 || index >= MAX_CONV_PREFIX + || strlen(conv_prefix.group_conv_prefix[index].startNumber) == 0) + return -1; + + *vartype = ASN_1_OCTET_STRING; + switch(column) + { + case 1: /* index */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = index; + break; + case 2: /* title, this define inhert...not reasonable */ + datalen = strlen(conv_prefix.plat_name[index]); + memcpy(pdata,conv_prefix.plat_name[index],datalen); + break; + case 3: /* start number */ + datalen = strlen(conv_prefix.group_conv_prefix[index].startNumber); + memcpy(pdata,conv_prefix.group_conv_prefix[index].startNumber,datalen); + break; + case 4: /* end number */ + datalen = strlen(conv_prefix.group_conv_prefix[index].endNumber); + memcpy(pdata,conv_prefix.group_conv_prefix[index].endNumber,datalen); + break; + case 5:/* replace digit start */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.group_conv_prefix[index].repStartDigit; + break; + case 6: /* replace digit end */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.group_conv_prefix[index].repEndDigit; + break; + case 7: /* replace digit with */ + datalen = strlen(conv_prefix.group_conv_prefix[index].repDigitWith); + memcpy(pdata,conv_prefix.group_conv_prefix[index].repDigitWith,datalen); + break; + case 8: /* lock flag */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.group_conv_prefix[index].status; + break; + case 9: /* status */ + *vartype = ASN_1_INTEGER; + pdata[0] = 1; /* active */ + datalen = 1; + break; + default: + return -1; + break; + } + return datalen; +} + +int xap_set_groupPrefix(DWORD column, DWORD *instance, u_char *pdata, unsigned short datalen) +{ + int index; + int newId; + + if(datalen == 0) + return -1; + + index = instance[0]; + if(index < 0 || index >= MAX_CONV_PREFIX) + return -1; + + switch(column) + { + case 1:/* create */ + if(xap_get_idle_index(2, &newId)) + { + return newId; + } + else + return -1; + break; + case 2: /* title */ + if(datalen>=MAX_NAME_LEN) + return -1; + memset(conv_prefix.plat_name[index], 0, MAX_NAME_LEN); + memcpy(conv_prefix.plat_name[index], pdata, datalen); + break; + case 3: /* start number */ + if(datalen>MAX_PREFIX_LEN) return -1; + memset(conv_prefix.group_conv_prefix[index].startNumber, 0, MAX_PREFIX_LEN+1); + memcpy(conv_prefix.group_conv_prefix[index].startNumber,pdata,datalen); + break; + case 4: /* end number */ + if(datalen>MAX_PREFIX_LEN) return -1; + memset(conv_prefix.group_conv_prefix[index].endNumber, 0, MAX_PREFIX_LEN+1); + memcpy(conv_prefix.group_conv_prefix[index].endNumber,pdata,datalen); + break; + case 5:/* replace digit start */ + if(datalen>=MAX_PREFIX_LEN) return -1; + conv_prefix.group_conv_prefix[index].repStartDigit = pdata[0]; + break; + case 6: /* replace digit end */ + if(datalen>=MAX_PREFIX_LEN) return -1; + conv_prefix.group_conv_prefix[index].repEndDigit = pdata[0]; + break; + case 7: /* replace digit with */ + if(datalen>MAX_PREFIX_LEN) return -1; + memset(conv_prefix.group_conv_prefix[index].repDigitWith, 0, MAX_PREFIX_LEN+1); + memcpy(conv_prefix.group_conv_prefix[index].repDigitWith,pdata,datalen); + break; + case 8: /* lock flag */ /* here, create table should be more technical, but... */ + conv_prefix.group_conv_prefix[index].status = pdata[0] ; + xappCreateGroupPrefixTable(); + break; + case 9: /* status */ + if(pdata[0] == 6) /* 6==delete */ + { + memset(&conv_prefix.group_conv_prefix[index],0,sizeof(_xapp_group_prefix)); + memset(conv_prefix.plat_name[index], 0, MAX_NAME_LEN); + xappCreateGroupPrefixTable(); + } + break; + default: + return -1; + break; + } + return datalen; +} + +/*------------------*/ +/*-- cli routines --*/ +/*------------------*/ + +int xap_getnext_cliPrefix(DWORD *index_id) +{ + int i; + + if(*index_id == 0) + *index_id = 1; + for(i = *index_id; i < MAX_CLI_PREFIX; i++) + { + if( strlen(conv_prefix.cli_prefix[i].prefix)) + { + *index_id = i; + return 1; + } + } + *index_id = 0; + return 0; +} + +int xap_get_cliPrefix(DWORD column, DWORD *instance, u_char *pdata, u_char *vartype) +{ + int datalen = 0,index; + + index = instance[0]; + if(index < 0 || index >= MAX_CLI_PREFIX + || strlen(conv_prefix.cli_prefix[index].prefix) == 0) + return -1; + + *vartype = ASN_1_OCTET_STRING; + switch(column) + { + case 1: /* index */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = index; + break; + case 2: /* title */ + datalen = strlen(conv_prefix.cli_name[index]); + memcpy(pdata,conv_prefix.cli_name[index],datalen); + break; + case 3: /* o nai */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.cli_prefix[index].in_property; + break; + case 4: /* prefix */ + datalen = strlen(conv_prefix.cli_prefix[index].prefix); + memcpy(pdata,conv_prefix.cli_prefix[index].prefix,datalen); + break; + case 5: /* delete count */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.cli_prefix[index].delete_length; + break; + case 6: + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.cli_prefix[index].out_property; + break; + case 7:/* add count */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.cli_prefix[index].add_length; + break; + case 8: /* insert digits */ + datalen = strlen(conv_prefix.cli_prefix[index].add_digits); + memcpy(pdata,conv_prefix.cli_prefix[index].add_digits,datalen); + break; + case 9: /* number length */ + *vartype = ASN_1_INTEGER; + datalen = 1; + pdata[0] = conv_prefix.cli_prefix[index].valid_length; + break; + case 10: /* status */ + *vartype = ASN_1_INTEGER; + pdata[0] = 1; /* active */ + datalen = 1; + break; + default: + return -1; + break; + } + return datalen; +} + +int xap_set_cliPrefix(DWORD column, DWORD *instance, u_char *pdata, unsigned short datalen) +{ + int index; + int newId; + + if(datalen == 0) + return -1; + + index = instance[0]; + if(index < 0 || index >= MAX_CLI_PREFIX) + return -1; + + switch(column) + { + case 1:/* create */ + if(xap_get_idle_index(3, &newId)) + { + return newId; + } + else + return -1; + break; + case 2: /* title */ + if(datalen>=MAX_NAME_LEN) + return -1; + memset(conv_prefix.cli_name[index], 0, MAX_NAME_LEN); + memcpy(conv_prefix.cli_name[index], pdata, datalen); + break; + case 3: /* in nai */ + conv_prefix.cli_prefix[index].in_property = pdata[0] ; + break; + case 4: /* prefix */ + if(datalen>=MAX_PREFIX_LEN) + return -1; + memset(conv_prefix.cli_prefix[index].prefix, 0, MAX_PREFIX_LEN); + memcpy(conv_prefix.cli_prefix[index].prefix, pdata, datalen); + break; + case 5: /* delete count */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.cli_prefix[index].delete_length = pdata[0]; + break; + case 6: /* out nai */ + conv_prefix.cli_prefix[index].out_property = pdata[0] ; + break; + case 7: /* insert count */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.cli_prefix[index].add_length = pdata[0]; + break; + case 8: /* insert digits */ + if(datalen>=MAX_PREFIX_LEN) + return -1; + memset(conv_prefix.cli_prefix[index].add_digits, 0, MAX_PREFIX_LEN); + memcpy(conv_prefix.cli_prefix[index].add_digits, pdata, datalen); + break; + case 9: /* number length */ + if(pdata[0]>=MAX_PREFIX_LEN) + return -1; + conv_prefix.cli_prefix[index].valid_length = pdata[0]; + break; + case 10: /* status */ + if(pdata[0] == 6) /* 6==delete */ + { + memset(&conv_prefix.cli_prefix[index],0,sizeof(_cli_prefix)); + memset(conv_prefix.cli_name[index], 0, MAX_NAME_LEN); + } + break; + default: + return -1; + break; + } + return datalen; +} + + +static struct snmp_table_profile xapp_tables[] = { + { + .name = "xappManPrefix", + .index.len = 11+2, + .index.oid = {1,3,6,1,4,1,1373,2,3,2,5,2,2}, + .column = {1, 2, 3, 4, 5, 6, 7, 8, 0}, + .level = 1, + .get_instance = xap_getnext_manPrefix, + .get_resp = xap_get_manPrefix, + .set_resp = xap_set_manPrefix + }, + { + .name = "xappManGroup", + .index.len = 11+2, + .index.oid = {1,3,6,1,4,1,1373,2,3,2,5,2,3}, + .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + .level = 1, + .get_instance = xap_getnext_groupPrefix, + .get_resp = xap_get_groupPrefix, + .set_resp = xap_set_groupPrefix + }, + { + .name = "xappCliPrefix", + .index.len = 11+2, + .index.oid = {1,3,6,1,4,1,1373,2,3,2,5,2,4}, + .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0}, + .level = 1, + .get_instance = xap_getnext_cliPrefix, + .get_resp = xap_get_cliPrefix, + .set_resp = xap_set_cliPrefix + } +}; + +static struct snmp_register xapp_register = { + .name = "XAPP", + .prefix_len = 11, + .prefix_oid = {1,3,6,1,4,1,1373,2,3,2,5}, + .num_of_table = 3, + .table = xapp_tables, + .default_get_resp = (getcall)xap_get_response, + .default_set_resp = (setcall)xap_set_response +}; + +void xap_snmp_registration(void) +{ + register_snmp_table(&xapp_register); +} diff --git a/omc/plat/xapp/src/conv_prefix.h b/omc/plat/xapp/src/conv_prefix.h new file mode 100644 index 0000000..deb49e7 --- /dev/null +++ b/omc/plat/xapp/src/conv_prefix.h @@ -0,0 +1,72 @@ +#ifndef _CONV_PREFIX_H +#define _CONV_PREFIX_H + +#include + +#define MAX_CONV_PREFIX 128 +#define MAX_CLI_PREFIX 64 +#define MAX_PREFIX_LEN 16 +#define MAX_NAME_LEN 8 + +#define MAX_PLAT_NAME_LEN 24 +#define MAX_PLAT_NAME_INSTANCE 256 + +typedef struct conv_prefix_record +{ + u_char used_flag; + char prefix[MAX_PREFIX_LEN]; + char delete_length; + char add_length; + char add_digits[MAX_PREFIX_LEN]; + u_char valid_length; +}_conv_prefix_record; + +typedef struct cli_prefix +{ + u_char in_property; + char prefix[MAX_PREFIX_LEN]; + char delete_length; + u_char out_property; + char add_length; + char add_digits[MAX_PREFIX_LEN]; + u_char valid_length; +}_cli_prefix; + +typedef struct xapp_group_prefix +{ + char startNumber[MAX_PREFIX_LEN+1]; + char endNumber[MAX_PREFIX_LEN+1]; + u_char repStartDigit; + u_char repEndDigit; + char repDigitWith[MAX_PREFIX_LEN+1]; + u_char status; /* 0=unlock, 1=lock */ + char cReserved[MAX_PREFIX_LEN]; +}_xapp_group_prefix; + +typedef struct conv_prefix +{ + _conv_prefix_record conv_prefix[MAX_CONV_PREFIX]; + _cli_prefix cli_prefix[MAX_CLI_PREFIX]; + char conv_name[MAX_CONV_PREFIX][MAX_NAME_LEN]; + char cli_name[MAX_CLI_PREFIX][MAX_NAME_LEN]; + char plat_name[MAX_PLAT_NAME_INSTANCE][MAX_PLAT_NAME_LEN]; + _xapp_group_prefix group_conv_prefix[MAX_CONV_PREFIX]; +}_conv_prefix; + +int snmpSetConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int msisdnUnkToInt(char *msisdn_unk, char *msisdn_int); +int cliUptoCalled(char *caller, char *called); +int saveConvPrefix(); + +/* return value: + -1 = error length; + 0 = cannn't find appropriate prefix; + 1 = conv. succeed +*/ + +#endif diff --git a/omc/plat/xapp/src/include.bak/.copyarea.db b/omc/plat/xapp/src/include.bak/.copyarea.db new file mode 100644 index 0000000..c406400 --- /dev/null +++ b/omc/plat/xapp/src/include.bak/.copyarea.db @@ -0,0 +1,10 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\src\include.bak +2 +6 +6:ixap.h|1|11d70a47046|798|72fb818c|545974f0bfa611dc86a4001c23e19543|0 +e:xap_provider.h|1|11d70a46f9a|1406|69bb1fdd|5299749cbfa611dc86a4001c23e19543|0 +d:conv_prefix.h|1|11d70a47075|678|f50c3072|54f9750cbfa611dc86a4001c23e19543|0 +f:xap_interfunc.h|1|11d70a46fd9|101|63c54522|532974b8bfa611dc86a4001c23e19543|0 +d:xap_monitor.h|1|11d70a46f6b|1ea|89569a8f|51597480bfa611dc86a4001c23e19543|0 +d:xap_cdmacdr.h|1|11d70a47008|53ca|d7babf63|53c974d4bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/src/include.bak/conv_prefix.h b/omc/plat/xapp/src/include.bak/conv_prefix.h new file mode 100644 index 0000000..e7fcd0a --- /dev/null +++ b/omc/plat/xapp/src/include.bak/conv_prefix.h @@ -0,0 +1,60 @@ +#ifndef _CONV_PREFIX_H +#define _CONV_PREFIX_H + +#include + +#define MAX_CONV_PREFIX 128 +#define MAX_CLI_PREFIX 64 +#define MAX_PREFIX_LEN 16 +#define MAX_NAME_LEN 8 + +#define MAX_PLAT_NAME_LEN 24 +#define MAX_PLAT_NAME_INSTANCE 256 + +typedef struct conv_prefix_record +{ + u_char used_flag; + char prefix[MAX_PREFIX_LEN]; + char delete_length; + char add_length; + char add_digits[MAX_PREFIX_LEN]; + u_char valid_length; +}_conv_prefix_record; + +typedef struct cli_prefix +{ + u_char in_property; + char prefix[MAX_PREFIX_LEN]; + char delete_length; + u_char out_property; + char add_length; + char add_digits[MAX_PREFIX_LEN]; + u_char valid_length; +}_cli_prefix; + +typedef struct conv_prefix +{ + _conv_prefix_record conv_prefix[MAX_CONV_PREFIX]; + _cli_prefix cli_prefix[MAX_CLI_PREFIX]; + char conv_name[MAX_CONV_PREFIX][MAX_NAME_LEN]; + char cli_name[MAX_CLI_PREFIX][MAX_NAME_LEN]; + char plat_name[MAX_PLAT_NAME_INSTANCE][MAX_PLAT_NAME_LEN]; +}_conv_prefix; + +int snmpSetConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetConvPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int snmpGetPlatName(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int msisdnUnkToInt(char *msisdn_unk, char *msisdn_int); +int cliUptoCalled(char *caller, char *called); +int saveConvPrefix(); + +/* return value: + -1 = error length; + 0 = cannn't find appropriate prefix; + 1 = conv. succeed +*/ + +#endif diff --git a/omc/plat/xapp/src/include.bak/ixap.h b/omc/plat/xapp/src/include.bak/ixap.h new file mode 100644 index 0000000..3910752 --- /dev/null +++ b/omc/plat/xapp/src/include.bak/ixap.h @@ -0,0 +1,59 @@ +/* XAP provider interface head file */ +/* Written by Liu Zhiguo 2003-03-13 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _XAP_INTERFACE +#define _XAP_INTERFACE + +#include "mapp/imap.h" +#include "capp/icap.h" + +/* defined in xap_interface.c */ +void xap_get_mcc(u8 *mcc); +void xap_get_mnc(u8 *mnc); +void xap_get_cc(u8 *cc); +void xap_get_ndc(u8 *ndc); +void xap_get_interprefix(u8 *inter_prefix); +void xap_get_nationalprefix(u8 *national_prefix); +void xap_get_localprefix(u8 *local_prefix); +int xap_mscid_to_num(u8 *mscid,u8 ssn, u8 *num); + +int imap_reg_ssn(u8 ssn); +u8 map_check_sendcom(u32 did); +u8 map_send_comdata(u8 *data_flow); // send map common service data +u8 map_check_sendopr(u32 did); +u8 map_send_oprdata(u8 *data_flow); // send map operation service data +u8 map_get_comdata(u8 *data_flow,u32 did); +u8 map_get_open(u8 *data_flow,u8 ssn); +u8 map_get_oprdata(u8 *data_flow,u32 did); +u32 map_get_dialogueid(u8 ssn); +u8 map_get_invokeid(u32 did); +u8 map_check_map_flag(u32 did); + +u32 is41_get_dialogueid(u8 ssn); + +int icap_reg_ssn(u8 ssn); +u8 cap_check_sendcom(u32 did); +u8 cap_send_comdata(u8 *data_flow); // send cap common service data +u8 cap_check_sendopr(u32 did); +u8 cap_send_oprdata(u8 *data_flow); // send cap operation service data +u8 cap_get_comdata(u8 *data_flow,u32 did); +u8 cap_get_open(u8 *data_flow,u8 ssn); +u8 cap_get_oprdata(u8 *data_flow,u32 did); +u32 cap_get_dialogueid(u8 ssn); +u8 cap_get_invokeid(u32 did); + +/* defined in xap_provider.c */ +u8 map_get_acnver(SCCP_ADDR *sccp_ptr,u8 acn); +u8 map_set_acnver(SCCP_ADDR *sccp_ptr,u8 acn,u8 acn_ver); +void xap_init( int grantdid ); +void xap_fsm(); + +int snmpGetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int saveConvPrefix(); +u8 init_mappconst(void); +u8 init_cappconst(void); +void wxc2_trace_xapp(u32 did); +#endif diff --git a/omc/plat/xapp/src/include.bak/xap_cdmacdr.h b/omc/plat/xapp/src/include.bak/xap_cdmacdr.h new file mode 100644 index 0000000..caf9611 --- /dev/null +++ b/omc/plat/xapp/src/include.bak/xap_cdmacdr.h @@ -0,0 +1,898 @@ +/* HLR CDMA cdr structure */ +/* Created by daniel:2005-06-21 */ +/* Modify by daniel:2005-06-21 */ +/* -------------------------------- */ + +#define DMHPAR_ASWID 0 +#define DMHPAR_AUDSN 1 +#define DMHPAR_AUDSUB 2 +#define DMHPAR_BIN 6 +#define DMHPAR_BILLIND 7 +#define DMHPAR_CDDGTS 8 +#define DMHPAR_CDLOC 9 +#define DMHPAR_CGDGTS 10 +#define DMHPAR_CGLOC 11 +#define DMHPAR_CHRGAMT 12 +#define DMHPAR_CNVDUR 13 +#define DMHPAR_CNVUSG 14 +#define DMHPAR_DATE 15 +#define DMHPAR_DIALDGTS 16 +#define DMHPAR_DUR 17 +#define DMHPAR_IDSUB 18 +#define DMHPAR_LNUM 19 +#define DMHPAR_MODIND 20 +#define DMHPAR_OSWID 21 +#define DMHPAR_RLEG 22 +#define DMHPAR_SEGNUM 23 +#define DMHPAR_SSWID 24 +#define DMHPAR_SWNO 25 +#define DMHPAR_SID 26 +#define DMHPAR_TOD 27 +#define DMHPAR_TKNUM 29 +#define DMHPAR_ACTIND 32 +#define DMHPAR_AJCKT 33 +#define DMHPAR_ACTSUB 34 +#define DMHPAR_ACHDUR 37 +#define DMHPAR_ACHUSG 38 +#define DMHPAR_AIRSSUB 39 +#define DMHPAR_AUTHCNT 42 +#define DMHPAR_AUTHDEN 43 +#define DMHPAR_AUTHTYP 44 +#define DMHPAR_CJCKT 47 +#define DMHPAR_CELLID 49 +#define DMHPAR_CHRGIND 50 +#define DMHPAR_CHRGSUB 51 +#define DMHPAR_CHRGTAX 52 +#define DMHPAR_CHRGTIND 53 +#define DMHPAR_CHRGUNIT 54 +#define DMHPAR_DENACC 56 +#define DMHPAR_DESTDGTS 57 +#define DMHPAR_ESN 58 +#define DMHPAR_EVTIND 60 +#define DMHPAR_FPARM 61 +#define DMHPAR_FBDUR 62 +#define DMHPAR_FBIND 64 +#define DMHPAR_FBUSG 65 +#define DMHPAR_FEATIND 66 +#define DMHPAR_FEATOPN 67 +#define DMHPAR_FRIND 68 +#define DMHPAR_HCOORD 69 +#define DMHPAR_HSWID 70 +#define DMHPAR_IECCDUR 71 +#define DMHPAR_INCDUR 73 +#define DMHPAR_INCUSG 74 +#define DMHPAR_LLIND 78 +#define DMHPAR_LJCKT 81 +#define DMHPAR_MIN 84 +#define DMHPAR_MRPI 85 +#define DMHPAR_NPANXX 86 +#define DMHPAR_NUMACT 87 +#define DMHPAR_NUMCHRG 89 +#define DMHPAR_NUMEVT 90 +#define DMHPAR_NUMLEG 91 +#define DMHPAR_NUMSEG 93 +#define DMHPAR_OLSUB 94 +#define DMHPAR_OGTDUR 95 +#define DMHPAR_OGTUSG 96 +#define DMHPAR_PLNAM 97 +#define DMHPAR_RCHNUM 99 +#define DMHPAR_RPI 100 +#define DMHPAR_REDIND 101 +#define DMHPAR_RLSUB 102 +#define DMHPAR_RBIN 103 +#define DMHPAR_RELIND 104 +#define DMHPAR_RIN 106 +#define DMHPAR_SRT 109 +#define DMHPAR_SJCKT 110 +#define DMHPAR_SPNAM 112 +#define DMHPAR_TSSUB 113 +#define DMHPAR_TSWID 114 +#define DMHPAR_TLSUB 115 +#define DMHPAR_TDO 116 +#define DMHPAR_TTIND 117 +#define DMHPAR_VCOORD 118 +#define DMHPAR_BINR 128 +#define DMHPAR_BRI 129 +#define DMHPAR_EJCKT 142 +#define DMHPAR_EVTSUB 143 +#define DMHPAR_FALSUB 146 +#define DMHPAR_PACAIND 150 +#define DMHPAR_PACASUB 151 +#define DMHPAR_AUXLSUB 161 +#define DMHPAR_IMEI 165 +#define DMHPAR_IMSI 166 +#define DMHPAR_LATA 167 +#define DMHPAR_NUMOCT 168 +#define DMHPAR_NUMPKT 169 +#define DMHPAR_TEXIND 170 +#define DMHPAR_CHRGTCOD 171 +#define DMHPAR_CHRGTTBL 172 +#define DMHPAR_FILLIND 178 +#define DMHPAR_FILLIC 179 +#define DMHPAR_MDN 184 +#define DMHPAR_NEICLNP 186 +#define DMHPAR_NUMFAL 188 +#define DMHPAR_NUMRED 189 +#define DMHPAR_NUMORG 190 +#define DMHPAR_NUMTRM 191 +#define DMHPAR_SELUSE 193 +#define DMHPAR_SUCOD 194 +#define DMHPAR_MYTYP 196 +#define DMHPAR_NUMAUX 199 +#define DMHPAR_NEIIP 200 +#define DMHPAR_IWFDUR 202 +#define DMHPAR_RETIND 207 +#define DMHPAR_RICODE 208 +#define DMHPAR_RSEG 209 +#define DMHPAR_WCNTRY 214 + +#define EVTIND_authorizationGranted 1 +#define EVTIND_authorizationExpired 2 +#define EVTIND_authorizationDenied 3 +#define EVTIND_securityViolationReport 4 +#define EVTIND_inactive 5 +#define EVTIND_deregistration 6 +#define EVTIND_registrationCanceled 7 +#define EVTIND_profileUpdated 8 +#define EVTIND_qualificationUpdated 9 +#define EVTIND_terminationDeniedInvalid 10 +#define EVTIND_terminationDeniedUnassigned 11 +#define EVTIND_terminationDeniedInactive 12 +#define EVTIND_terminationDeniedUnregistered 13 +#define EVTIND_terminationDeniedNoPageResponse 14 +#define EVTIND_terminationDeniedBusy 15 +#define EVTIND_terminationDeniedSCA 16 +#define EVTIND_terminationDeniedDND 17 +#define EVTIND_terminationDeniedCD 18 +#define EVTIND_terminationDeniedCS 19 +#define EVTIND_terminationDeniedOther 20 +#define EVTIND_callDelivered 21 +#define EVTIND_callForwarded 22 +#define EVTIND_callForwardingNotification 23 +#define EVTIND_messageWaitingNotification 24 +#define EVTIND_originationDeniedNoTrunk 25 +#define EVTIND_originationDeniedUnrecognized 26 +#define EVTIND_originationDeniedCB 27 +#define EVTIND_originationDeniedOther 28 +#define EVTIND_unspecifiedHourlyEvent 29 +#define EVTIND_unspecifiedDailyEvent 30 +#define EVTIND_unspecifiedWeeklyEvent 31 +#define EVTIND_unspecifiedMonthlyEvent 32 +#define EVTIND_unspecifiedQuarterlyEvent 33 +#define EVTIND_unspecifiedSemi_annualEvent 34 +#define EVTIND_unspecifiedAnnualEvent 35 +#define EVTIND_featureAccessAttempted 36 +#define EVTIND_SMSMO 37 +#define EVTIND_SMSMT 38 +#define EVTIND_SMSNOT 39 + +#define ACTIND_unspecified 0 +#define ACTIND_locallyDeniedRegistration 1 +#define ACTIND_homeDeniedRegistration 2 +#define ACTIND_powerOnRegistration 3 +#define ACTIND_autonomousRegistration 4 +#define ACTIND_missedAutonomousRegistration 5 +#define ACTIND_movementRegistration 6 +#define ACTIND_movementDetected 7 +#define ACTIND_powerDownDeregistration 8 +#define ACTIND_pageResponse 0 +#define ACTIND_noPageResponse 10 +#define ACTIND_messageWaiting 11 +#define ACTIND_abbreviatedAlert 12 +#define ACTIND_alert 13 +#define ACTIND_alertWithInformation 14 +#define ACTIND_alertingAnswered 15 +#define ACTIND_pACARequest 16 +#define ACTIND_originationRequest 17 +#define ACTIND_flashRequestWithoutInformation 18 +#define ACTIND_flashRequestWithInformation 19 +#define ACTIND_callModeChanged 20 +#define ACTIND_lostRadioContact 21 +#define ACTIND_measurementRequest 22 +#define ACTIND_mAHORequest 23 +#define ACTIND_intraSystemHandoff 24 +#define ACTIND_interSystemHandoff 25 +#define ACTIND_powerControlProblem 26 +#define ACTIND_protocolError 27 +#define ACTIND_spuriousEmissions 28 +#define ACTIND_orderedRegistration 29 +#define ACTIND_trafficChannelRegistration 30 +#define ACTIND_dataBurst_ShortMessage 31 +#define ACTIND_featureNotification 32 +#define ACTIND_lock 33 +#define ACTIND_unlock 34 +#define ACTIND_maintenanceRequired 35 +#define ACTIND_intrasystemSoftHandoffBegin 36 +#define ACTIND_intersystemSoftHandoffBegin 37 +#define ACTIND_packetDataRegistrationOnly 38 + +#define FEATIND_callForwarding_Unconditional 1 +#define FEATIND_callForwarding_Busy 2 +#define FEATIND_callForwarding_NoAnswer 3 +#define FEATIND_callForwarding_Other 4 +#define FEATIND_callWaiting 5 +#define FEATIND_threeWayCalling 6 +#define FEATIND_callDelivery 7 +#define FEATIND_doNotDisturb 8 +#define FEATIND_conferenceCalling 9 +#define FEATIND_callTransfer 10 +#define FEATIND_callingNumberIdentificationRestriction 11 +#define FEATIND_selectiveCallAcceptance 12 +#define FEATIND_authorizationCode 13 +#define FEATIND_speedDialing 14 +#define FEATIND_adviceOfCharging 15 +#define FEATIND_voiceMail 16 +#define FEATIND_callForwardDefault 17 +#define FEATIND_callingNumberIdentificationPresentation 18 +#define FEATIND_flexibleAlerting 19 +#define FEATIND_messageWaitingNotification 20 +#define FEATIND_mobileAccessHunting 21 +#define FEATIND_passwordCallAcceptance 22 +#define FEATIND_preferredLanguageService 23 +#define FEATIND_priorityAccessAndChannelAssignment 24 +#define FEATIND_remoteFeatureControl 25 +#define FEATIND_subscriberPINAccess 26 +#define FEATIND_subscriberPINIntercept 27 +#define FEATIND_voicePrivacy 28 +#define FEATIND_shortMessageDeliveryPoint_ToPointBearer 29 +#define FEATIND_shortMessageDeliveryBroadcast 30 +#define FEATIND_cellularPagingTeleservice 31 +#define FEATIND_cellularMessagingTeleservice 32 +#define FEATIND_intersystemCall 33 +#define FEATIND_voiceMailDelete 34 +#define FEATIND_voiceMailSend 35 +#define FEATIND_voiceMailDeposit 36 +#define FEATIND_answerHold 37 +#define FEATIND_userSelectiveCallForwarding 38 + +#define FEATOPN_featureRegistration 1 +#define FEATOPN_featureDeregistration 2 +#define FEATOPN_featureActivation 3 +#define FEATOPN_featureDeactivation 4 +#define FEATOPN_featureInvocation 5 +#define FEATOPN_featurePerCallActivation 6 +#define FEATOPN_featurePerCallDeactivation 7 +#define FEATOPN_featureRegistrationAndActivation 8 +#define FEATOPN_featureInterrogation 9 +#define FEATOPN_featureTesting 10 +#define FEATOPN_screenListEditing 11 + +#define FRIND_timerExpiry 1 +#define FRIND_networkFailure 2 +#define FRIND_operationError 3 +#define FRIND_operationReject 4 +#define FRIND_unspecified 5 +#define FRIND_unsuccessful 6 +#define FRIND_successful 7 + +typedef struct DMH_CallLocation +{ + u32 param_flag; + + u8 HcoordinateLen; + u8 Hcoordinate[3]; + + u8 NPANXX[3]; + + u8 PlaceNameLen; + u8 PlaceName[20]; + + u8 StateProvinceName[2]; + + u8 VcoordinateLen; + u8 Vcoordinate[3]; + + u8 LocalAccessTransportAreaLen; + u8 LocalAccessTransportArea[4]; + + u8 WorldCountry[3]; +}DMH_CallLocation; + +typedef struct DMH_ReturnIndicator +{ + u32 param_flag; + + u8 ReturnIndicatorCode; + +//optional part + struct + { + u8 ParameterIdentifierLen; + u8 ParameterIdentifier[16]; + } FaultyParameter; + +}DMH_ReturnIndicator; + +typedef struct DMH_FillIndicator +{ + struct + { + u8 ParameterIdentifierLen; + u8 ParameterIdentifier[16]; + } FaultyParameter; + + u8 FillIndicatorCode; +}DMH_FillIndicator; + +typedef struct DMH_AuditSubrecord +{ + u32 param_flag; + + u8 audsnLen; + u8 audsn[4];//AuditSequenceNumber + +//optional part + u8 achdurLen; + u8 achdur[4];//AirChannelDuration + u8 cnvdurLen; + u8 cnvdur[4];//ConversationDuration + u8 fbdurLen; + u8 fbdur[4];//FeatureBridgeDuration + u8 ieccdurLen; + u8 ieccdur[4];//IECConnectDuration + u8 incdurLen; + u8 incdur[4];//IncomingTrunkDuration + u8 numactLen; + u8 numact[4];//NumberOfActivities + u8 numchrgLen; + u8 numchrg[4];//NumberOfCharges + u8 numevtLen; + u8 numevt[4];//NumberOfEvents + u8 numlegLen; + u8 numleg[4];//NumberOfLegs + u8 numsegLen; + u8 numseg[4];//NumberOfSegments + u8 ogtdurLen; + u8 ogtdur[4];//OutgoingTrunkDuration + u8 numfalLen; + u8 numfal[4];//NumberOfFeatureActivationLegs + u8 numorgLen; + u8 numorg[8];//NumberOfOriginationLegs + u8 numredLen; + u8 numred[4];//NumberOfRedirectionLegs + u8 numtrmLen; + u8 numtrm[4];//NumberOfTerminationLegs + u8 numauxLen; + u8 numaux[4];//NumberOfAuxiliaryLegs + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets + u8 iwfdurLen; + u8 iwfdur[4];//IWFDuration + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_AuditSubrecord; + +typedef struct DMH_SwitchID +{ + u32 param_flag; + + u8 swno;//SwitchNumber + u8 sid[2];//SystemIdentifier + u8 bri[2];//BusinessRelationIdentifier + u8 mytyp;//SystemMyTypeCode +}DMH_SwitchID; + +typedef struct DMH_IdentitySubrecord +{ + u32 param_flag; + + u8 Date[3]; + struct + { + u8 ChoiceFlag; + + u8 esn[4]; + u8 imei[5]; + } Choice1; + + struct + { + u8 ChoiceFlag; + + u8 min[5]; + u8 imsi[8]; + u8 neiclnp[19]; + u8 neiip[4]; + } Choice2; + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + + struct + { + u8 ChoiceFlag; + + DMH_SwitchID aswid;//AnchorSWID + DMH_SwitchID oswid;//OriginatingSWID + DMH_SwitchID sswid;//ServingSWID + } Choice3; + + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + + DMH_SwitchID hswid;//HomeSWID + + u8 mdnLen; + u8 mdn[8]; + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; + +}DMH_IdentitySubrecord; + +typedef struct DMH_EventSubrecord +{ + u32 param_flag; + + u8 evtind;//EventIndicator + u8 rinLen; + u8 rin[4];//ReportIdentificationNumber + +//optional part + DMH_SwitchID aswid;//AnchorSWID + + u8 authcnt;//AuthorizationCount + u8 authden;//AuthorizationDenied + u8 authtyp;//AuthorizationType + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + u8 Date[3]; + u8 denacc;//DenyAccess + u8 featind;//FeatureIndicator + u8 featopn;//FeatureOperation + u8 frind;//FeatureResultIndicator + + DMH_SwitchID oswid;//OriginatingSWID + + u8 rbinLen; + u8 rbin[4];//RelatedBillingIdentificationNumber + u8 srt;//SecurityReportType + + DMH_SwitchID sswid;//ServingSWID + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_EventSubrecord; + +typedef struct DMH_ChargeSubrecord +{ + u32 param_flag; + + u8 chrgamtLen; + u8 chrgamt[4];//ChargeAmount + u8 chrgind;//ChargeIndicator + +//optional part + u8 chrgtaxLen; + u8 chrgtax[4];//ChargeTax + u8 chrgtind;//ChargeTaxIndicator + u8 chrgunit;//ChargeUnits + u8 durLen; + u8 dur[4];//Duration + u8 mrpi;//MultipleRatePeriodIndicator,len=0 + u8 plnamLen; + u8 plnam[20];//PlaceName + u8 rpi;//RatePeriodIndicator + u8 spnam[2];//StateProvinceName + u8 ttind;//TollTariffIndicator + u8 wcntry[3];//WorldCountry + + struct + { + u8 ChoiceFlag; + + u8 lnum;//LegNumber + u8 segnum;//SegmentNumber + } Choice; + + u8 chrgtcodLen; + u8 chrgtcod[2];//ChargeTaxCode + u8 chrgttbl;//ChargeTaxTable + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets + u8 seluseLen; + u8 seluse[100];//SelectiveUse + u8 sucod;//SelectiveUseCode + u8 texind;//TaxExemptIndicator + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_ChargeSubrecord; + +typedef struct DMH_BeginForwardPath +{ + u32 param_flag; + + u8 cellidLen; + u8 cellid[2];//CellIdentifier + u8 modind;//ModulationIndicator + u8 rchnumLen; + u8 rchnum[2];//RadioChannelNumber + u8 tknumLen; + u8 tknum[2];//TrunkNumber + +//optional part + u8 bearind;//BearerIndicator + u8 locidLen; + u8 locid[2];//LocationAreaIdentifier + u8 radattr[2];//RadioAttributes + u8 trnsnumLen; + u8 trnsnum[2];//TransceiverNumber + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + + struct + { + u8 ChoiceFlag; + //will add encode in the future + + } Choice; + + u8 cellnamLen; + u8 cellnam[8];//CellName + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName + u8 uzLen; + u8 uz[3];//UserZoneNumber + u8 bndclsLen; + u8 bndcls[63];//BandClass + u8 freqind;//FrequencyIndicator +}DMH_BeginForwardPath;//BeginForwardPath + +typedef struct DMH_EndForwardPath +{ + u32 param_flag; +}DMH_EndForwardPath;//BeginForwardPath + +typedef struct DMH_ActivitySubrecord +{ + u32 param_flag; + + u8 actind;//ActivityIndicator + u8 rinLen; + u8 rin[4];//ReportIdentificationNumber + +//optional part + u8 authden;//AuthorizationDenied + + DMH_BeginForwardPath bfpath; + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + u8 Date[3]; + u8 denacc;//DenyAccess + u8 srt;//SecurityReportType + + DMH_SwitchID sswid;//ServingSWID + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + DMH_FillIndicator fillind; + u8 rsegLen; + u8 rseg[3];//RelatedSegmentNumber + DMH_ReturnIndicator retind; +}DMH_ActivitySubrecord; + +typedef struct DMH_FeatureBridgeUsage +{ + u32 param_flag; + + u8 fbind; //FeatureBridgeIndicator + u8 durLen; + u8 dur[4];//Duration + u8 rlegLen; + u8 rleg[3];//RelatedLegNumber + u8 todLen; + u8 tod[3];//TimeOfDay + +}DMH_FeatureBridgeUsage; + +typedef struct DMH_IncomingTrunkUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 tknumLen; + u8 tknum[2];//TrunkNumber + + u8 cardgts[2];//CarrierDigits + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName +}DMH_IncomingTrunkUsage; + +typedef struct DMH_OutgoingTrunkUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 tknumLen; + u8 tknum[2];//TrunkNumber + + u8 cardgts[2];//CarrierDigits + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName +}DMH_OutgoingTrunkUsage; + +typedef struct DMH_AirChannelUsage +{ + u32 param_flag; + + DMH_BeginForwardPath bfpath; + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 Date[3]; + +//optional part + DMH_EndForwardPath efpath; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset +}DMH_AirChannelUsage; + +typedef struct DMH_AirSegmentSubrecord +{ + u32 param_flag; + + DMH_AirChannelUsage achusg;//AirChannelUsage + u8 segnum;//SegmentNumber + +//optional part + struct + { + u32 param_flag; + + u8 latLen; + u8 lat[3];//Latitude + u8 LONGLen; + u8 LONG[3];//Longitude + u8 resolLen; + u8 resol[3];//Resolution + }begloc;//BeginLocation + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage + u8 lsind;//LastSegmentIndicator,len=0 + DMH_SwitchID sswid;//ServingSWID + u8 cgblind;//ChargeableIndicator + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; + +}DMH_AirSegmentSubrecord; + +typedef struct DMH_FeatureActivationLegSubrecord +{ + u32 param_flag; + + u8 dialdgtsLen; + u8 dialdgts[32];//DialedDigits + u8 lnum;//LegNumber + +//optional part will be encoded in the future + u8 frind;//FeatureResultIndicator, BIT13 + u8 llind;//LastLegIndicator, BIT15 +}DMH_FeatureActivationLegSubrecord; + +typedef struct DMH_ConversationUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + +//optional part + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets +}DMH_ConversationUsage; + +typedef struct DMH_OriginationLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 dialdgtsLen; + u8 dialdgts[32];//DialedDigits + u8 lnum;//LegNumber + + DMH_CallLocation CalledLocation;//BIT8 + + DMH_CallLocation CallingLocation;//BIT11 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT14 + DMH_FeatureBridgeUsage fbusg;//FeatureBridgeUsage,BIT16 + u8 llind;//LastLegIndicator,len=0,BIT19 + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage.BIT20 + +}DMH_OriginationLegSubrecord; + +typedef struct DMH_PACASegmentSubrecord +{ + u32 param_flag; + + u8 cellidLen; + u8 cellid[2];//CellIdentifier + u8 durLen; + u8 dur[4];//Duration + u8 pacaind;//PACAIndicator + u8 segnum;//SegmentNumber +}DMH_PACASegmentSubrecord; + +typedef struct DMH_RedirectionLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 cddgtsLen; + u8 cddgts[9];//CalledDigits + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage + u8 lnum;//LegNumber + u8 redind;//RedirectionIndicator + +//optional part + DMH_CallLocation CalledLocation;//BIT6 + + u8 cgdgtsLen; + u8 cgdgts[9];//CallingDigits, BIT8 + + DMH_CallLocation CallingLocation;//BIT9 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT12 + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,BIT13 + u8 llind;//LastLegIndicator,len=0,BIT18 + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage.BIT19 + +}DMH_RedirectionLegSubrecord; + +typedef struct DMH_TandemSegmentSubrecord +{ + u32 param_flag; + + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage + u8 segnum;//SegmentNumber + DMH_SwitchID tswid;//ServingSWID + +//optional part will be added in the future +}DMH_TandemSegmentSubrecord; + +typedef struct DMH_TerminationLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 lnum;//LegNumber + +//optional part + DMH_CallLocation CalledLocation;//BIT6 + + u8 cgdgtsLen; + u8 cgdgts[9];//CallingDigits,BIT9 + + DMH_CallLocation CallingLocation;//BIT10 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT13 + DMH_FeatureBridgeUsage fbusg;//FeatureBridgeUsage,BIT16 + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage,BIT17 + u8 llind;//LastLegIndicator,len=0,BIT19 + +}DMH_TerminationLegSubrecord; + +typedef struct DMH_AuxiliaryLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 lnum;//LegNumber +}DMH_AuxiliaryLegSubrecord; + +typedef struct DMH_EventJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + DMH_EventSubrecord evtsub; + DMH_ChargeSubrecord chrgsub; +}DMH_EventJacket; + +typedef struct DMH_ActivityJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + DMH_ActivitySubrecord actsub; + DMH_ChargeSubrecord chrgsub; +}DMH_ActivityJacket; + +typedef struct DMH_CallJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + + DMH_ActivitySubrecord actsub; + DMH_AirSegmentSubrecord airssub; + DMH_ChargeSubrecord chrgsub; + DMH_FeatureActivationLegSubrecord falsub; + DMH_OriginationLegSubrecord olsub; + DMH_PACASegmentSubrecord pacasub; + DMH_RedirectionLegSubrecord rlsub; + DMH_TandemSegmentSubrecord tssub; + DMH_TerminationLegSubrecord tlsub; + DMH_AuxiliaryLegSubrecord auxlsub; +}DMH_CallJacket; + +typedef struct DMH_LegJacket +{ + u32 param_flag; + + DMH_IdentitySubrecord idsub; + + DMH_ChargeSubrecord chrgsub; + DMH_FeatureActivationLegSubrecord falsub; + DMH_OriginationLegSubrecord olsub; + DMH_RedirectionLegSubrecord rlsub; + DMH_TerminationLegSubrecord tlsub; + DMH_AuxiliaryLegSubrecord auxlsub; +}DMH_LegJacket; + +typedef struct DMH_SegmentJacket +{ + u32 param_flag; + + DMH_IdentitySubrecord idsub; + + DMH_ActivitySubrecord actsub; + DMH_AirSegmentSubrecord airssub; + DMH_ChargeSubrecord chrgsub; + DMH_PACASegmentSubrecord pacasub; + DMH_TandemSegmentSubrecord tssub; +}DMH_SegmentJacket; + + + +int assign_DMHEventJacket(DMH_EventJacket *ptr,u8 *buf); +int assign_DMH_ActivityJacket(DMH_ActivityJacket *ptr,u8 *buf); +int assign_DMH_CallJacket(DMH_CallJacket *ptr,u8 *buf); +int assign_DMH_LegJacket(DMH_LegJacket *ptr,u8 *buf); +int assign_DMH_SegmentJacket(DMH_SegmentJacket *ptr,u8 *buf); +void encode_DMH_date(u8 *date); +u8 encode_DMH_TimeDateOffset(u8 *TimeDateOffset); +u8 encode_DMH_TimeOfDay(u8 *TimeOfDay); + diff --git a/omc/plat/xapp/src/include.bak/xap_interfunc.h b/omc/plat/xapp/src/include.bak/xap_interfunc.h new file mode 100644 index 0000000..15c1c2a --- /dev/null +++ b/omc/plat/xapp/src/include.bak/xap_interfunc.h @@ -0,0 +1,11 @@ +/* XAP interface for map/cap use head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* --------------------------------------- */ + +#ifndef _XAP_INTER_FUNC +#define _XAP_INTER_FUNC + +void xap_send_error(const char *fmt,...); + +#endif diff --git a/omc/plat/xapp/src/include.bak/xap_monitor.h b/omc/plat/xapp/src/include.bak/xap_monitor.h new file mode 100644 index 0000000..ffa8176 --- /dev/null +++ b/omc/plat/xapp/src/include.bak/xap_monitor.h @@ -0,0 +1,19 @@ +/* XAP monitor head file */ +/* Written by Liu Zhiguo 2003-03-13 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _XAP_MONITOR +#define _XAP_MONITOR + +void xap_init_m(void); +void xap_monitor(void); + +void xap_send_error(const char *fmt,...); +void xap_msg_display(u8 *info_str); +void xap_dlg_display(struct CSLdlg_struct *dha_ptr); +void xap_cmp_display(struct CSLcmp_struct *cha_ptr); +void xap_watch_dog(u32 wd_site); +void xap_logdebug(const char *fmt,...); + +#endif diff --git a/omc/plat/xapp/src/include.bak/xap_provider.h b/omc/plat/xapp/src/include.bak/xap_provider.h new file mode 100644 index 0000000..c27f060 --- /dev/null +++ b/omc/plat/xapp/src/include.bak/xap_provider.h @@ -0,0 +1,182 @@ +/* XAP provider head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "../../public/src/include/includes.h" +#include "../../public/src/include/function.h" +#include "../../sccp/src/include/sccp.h" +#include "../../tcap/src/include/tcap_head.h" +#include "../../tcap/src/include/tcap_public.h" +#include "../../tcap/src/include/tcap_struct.h" +#include "ixap.h" +#include "mapp/map_const.h" +#include "mapp/map_public.h" +#include "mapp/map_code.h" +#include "mapp/map_coding.h" +#include "mapp/is41_code.h" +#include "mapp/map_struct.h" +#include "mapp/map_acn.h" +#include "mapp/map_dlgpdu.h" + +#ifndef _PROVIDER_H +#define _PROVIDER_H + +#define XAP_MAP_SSN 1 // ssn is used for map +#define XAP_CAP_SSN 2 // ssn is used for cap +#define XAP_IS41_SSN 3 // ssn is used for is41 + +#define XAP_VM_KEY 0xa0e00000 +#define XAP_VM_PERM 0664 +#define XAP_INTER_KEY 0xa0f00000 +#define XAP_INTER_PERM 0664 + +#define MAX_XAP_SSN 16 +#define XAP_OPEN_LEN 128 +#define XAP_ACN_LEN 7 // xap acn length +#define XAP_ACN_NUM 50 // acn buffer length +#define XAP_OPR_NUM 80 // operation length + +#define XAP_ASCIN_LEN 1024 +#define XAP_ASCOUT_LEN 4096 +#define XAP_WTDOG_LEN 256 + +#define XAP_INIT 0x00 +#define XAP_IDLE 0x01 +#define XAP_WFUR 0x02 // wait for user requests +#define XAP_WFCBI 0x03 // wait for check begin indicate +#define XAP_DLG_INITIATED 0x05 +#define XAP_DLG_PENDING 0x04 // dialogue pending +#define XAP_DLG_ACCEPTED 0x06 +#define XAP_DLG_ESTABLISHED 0x07 +#define XAP_DLG_SUSPEND 0x08 +#define XAP_DLG_HALT 0x09 + +/* the state of SSM */ +#define SSM_IDLE 0x00 +#define SSM_WFRESPONSE 0x01 // wait for response +#define SSM_WFCONFIRM 0x02 + +/* the flag of requesting map SSM */ +#define SERVICE_INVOKED 0x01 +#define RESULT_RECEIVED 0x02 +#define PARTIAL_RESULT_RECEIVED 0x03 +#define NEGATIVE_RESULT_RECEIVED 0x04 +#define LINKED_REQUEST_RECEIVED 0x05 +#define LINKED_SERVICE_INVOKED 0x06 +#define USER_REJECT_RECEIVED 0x07 +#define PROVIDER_REJECT_RECEIVED 0x08 +#define TIMER_EXPIRY 0x09 +#define TERMINATED 0x0a + +/* the flag of performing map SSM */ +#define SERVICE_INVOCATION_RECEIVED 0x01 +#define RESPONSE_ISSUED 0x02 +#define GUARD_TIMER 0x03 + +#define SUSPEND_TIME 1 +#define DLGPEND_TIME 180 +#define XAPP_TIMERHZ 100 + +#define XAPP_PRIVATE_TCAP 1 +#define XAPP_OPER_FAMILY 9 + +typedef struct xap_acn_info // store info about application context name +{ + u8 buf_len; + u8 acn[XAP_ACN_NUM]; // acn buffer + u8 acn_ver[XAP_ACN_NUM]; // acn version buffer +} xap_acn_info; + +typedef struct xap_opr_info // store info about opration code +{ + u8 buf_len; + u8 opr_code[XAP_OPR_NUM]; // operation code buffer + u8 opr_class[XAP_OPR_NUM]; // operation class buffer + u32 opr_timer[XAP_OPR_NUM]; // operation timer buffer +} xap_opr_info; + + +typedef struct xap_inter_struct // xap interface structure +{ + u8 mcc[2]; + u8 mnc0; + u8 cc[2]; + u8 ndc[3]; + u8 inter_prefix[2]; + u8 national_prefix[2]; + u8 local_prefix[2]; + u8 mnc[2];//expend mnc from 1 byte to 2 bytes + +/* mscid is special use for CDMA */ + u8 mscidToNum[256][14]; +/* mscid is special use for CDMA */ + + // define for the ssn control + u8 regssn_len; + u8 reg_ssn[MAX_XAP_SSN]; + u8 regssn_flag[MAX_XAP_SSN]; // indicate if the register SSN is MAP or CAP ssn + u8 open_head[MAX_XAP_SSN]; + u8 open_tail[MAX_XAP_SSN]; + u32 open_did[MAX_XAP_SSN][XAP_OPEN_LEN]; +} xap_inter_struct; + +typedef struct xap_debug_struct +{ + char *start_time; // time of module start + u32 monitor_did; // the dialogue id for monitored + u8 error_switch; + u8 map_switch; + u8 cap_switch; + u8 send_control; // control if can send xap message + u8 ascin_buf[XAP_ASCIN_LEN]; + u8 ascout_buf[XAP_ASCOUT_LEN]; + u32 watch_dog[XAP_WTDOG_LEN]; +} xap_debug_struct; + +typedef struct psmvm_data // xap provider state machine data +{ + u8 xap_flag; // 0: empty; 1: map primitive; 2: cap primitive + u8 psm_state; + u8 sub_state1; + u8 delimiter_flag; + u8 acn; + u8 acn_ver; + u8 msg_type; + u8 msg_flag; + u32 port_id; + u32 suspend_timer; + u8 data_count; + u8 recv_bsa_count; + u8 opr_state[MAX_INVOKEID]; + u8 opr_code[MAX_INVOKEID]; + u8 opr_class[MAX_INVOKEID]; +} psmvm_data; + +typedef struct xapp_vm_data // XAP provider virtue machine structure +{ + struct psmvm_data psm_data; + u8 recvcom_flag; // USER=>XAPP + u8 recvopr_flag; // USER=>XAPP 0: has not data 1: has data 2: has partial data + u8 sendcom_flag; // XAPP=>USER + u8 sendopr_flag; // XAPP=>USER + u32 recvopr_site; // USER=>XAPP 0: has not data 1: has data 2: has partial data + struct MapComSrv_struct recvcom_data; + struct MapOprData_struct recvopr_data; + struct MapComSrv_struct sendcom_data; + struct MapOprData_struct sendopr_data; + struct CSLdlg_struct tcap_data; + struct MapDlg_struct map_dlg; +} xapp_vm_data; + +typedef struct xap_vm_struct +{ + int grantdid; + struct xapp_vm_data xap_data[MAX_DIALOGUEID]; + struct xap_debug_struct debug_data; +} xap_vm_struct; + +struct xap_vm_struct *xap_vm_ptr; +struct xap_inter_struct *xap_inter_ptr; + +#endif diff --git a/omc/plat/xapp/src/ixap.h b/omc/plat/xapp/src/ixap.h new file mode 100644 index 0000000..1170cb2 --- /dev/null +++ b/omc/plat/xapp/src/ixap.h @@ -0,0 +1,66 @@ +/* XAP provider interface head file */ +/* Written by Liu Zhiguo 2003-03-13 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _XAP_INTERFACE +#define _XAP_INTERFACE + +#include "mapp/imap.h" +#include "capp/icap.h" + +/* defined in xap_interface.c */ +void xap_get_mcc(u8 *mcc); +void xap_get_mnc(u8 *mnc); +void xap_get_cc(u8 *cc); +void xap_get_ndc(u8 *ndc); +void xap_get_interprefix(u8 *inter_prefix); +void xap_get_nationalprefix(u8 *national_prefix); +void xap_get_localprefix(u8 *local_prefix); +int xap_mscid_to_num(u8 *mscid,u8 ssn, u8 *num); + +int imap_reg_ssn(u8 ssn); +u8 map_check_sendcom(u32 did); +u8 map_send_comdata(u8 *data_flow); // send map common service data +u8 map_check_sendopr(u32 did); +u8 map_send_oprdata(u8 *data_flow); // send map operation service data +u8 map_get_comdata(u8 *data_flow,u32 did); +u8 map_get_open(u8 *data_flow,u8 ssn); +u8 map_get_oprdata(u8 *data_flow,u32 did); +u32 map_get_dialogueid(u8 ssn); +u8 map_get_invokeid(u32 did); +u8 map_check_map_flag(u32 did); +u8 map_send_oprsrv( MapOprSrv_struct *srv_ptr, u8 DelimiterFlag , u8 *data_flow); +u8 map_send_comsrv(MapComSrv_struct *com_ptr,u8 uDelimiterFlag,u8 *data_flow); +u8 map_send_open( MapOpenArgParam *pOpenParam , u8 *uDataFlow ); +u8 map_send_close( u32 pid , u32 did , u8 uCloseReasion ); +u8 map_extract_param(MapOprSrv_struct *srv_ptr,MapOprData_struct *data_ptr , int ver); +u8 map_get_comdata_struct(MapComSrv_struct *map_com,u32 did); +u8 map_get_oprdata_struct(MapOprData_struct *map_opr,u32 did); + +u32 is41_get_dialogueid(u8 ssn); + +int icap_reg_ssn(u8 ssn); +u8 cap_check_sendcom(u32 did); +u8 cap_send_comdata(u8 *data_flow); // send cap common service data +u8 cap_check_sendopr(u32 did); +u8 cap_send_oprdata(u8 *data_flow); // send cap operation service data +u8 cap_get_comdata(u8 *data_flow,u32 did); +u8 cap_get_open(u8 *data_flow,u8 ssn); +u8 cap_get_oprdata(u8 *data_flow,u32 did); +u32 cap_get_dialogueid(u8 ssn); +u8 cap_get_invokeid(u32 did); + +/* defined in xap_provider.c */ +u8 map_get_acnver(SCCP_ADDR *sccp_ptr,u8 acn); +u8 map_set_acnver(SCCP_ADDR *sccp_ptr,u8 acn,u8 acn_ver); +void xap_init( int grantdid ); +void xap_fsm(); + +int snmpGetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_char *vartype); +int snmpSetCliPrefix(u_char oidlen,DWORD *oid,u_char *pdata,u_short datalen); +int saveConvPrefix(); +u8 init_mappconst(void); +u8 init_cappconst(void); +void wxc2_trace_xapp(u32 did); +#endif diff --git a/omc/plat/xapp/src/mapp/.copyarea.db b/omc/plat/xapp/src/mapp/.copyarea.db new file mode 100644 index 0000000..81fce06 --- /dev/null +++ b/omc/plat/xapp/src/mapp/.copyarea.db @@ -0,0 +1,35 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\src\mapp +2 +1f +d:map_code_om.c|1|11d70a46d1a|1683|8533b312|4d3973bcbfa611dc86a4001c23e19543|0 +c:map_coding.h|1|11d758d2276|764e|72d0f1a4|91eefbe7ac8211dd893c001c23e19543|0 +d:map_LCSCode.h|1|11d8a87d487|c82|89c1de71|34b017a0af0f11dd8895001c23e19543|0 +f:is41_code_auc.c|1|11d70a46a4b|98c0|4f5117ba|43a97250bfa611dc86a4001c23e19543|0 +b:map_const.h|1|11d758d2218|5e17|19fde9ff|8a2e6809ac6c11dd8812001c23e19543|0 +c:map_public.c|1|11d70a46c6e|6433|a97cc9ba|4ad97368bfa611dc86a4001c23e19543|0 +e:map_includes.h|1|11d70a469a0|1ee|bcce8b46|41e971fcbfa611dc86a4001c23e19543|0 +c:map_dlgpdu.h|1|11d70a468e4|b4a|63d576dd|3f7971a8bfa611dc86a4001c23e19543|0 +c:map_coding.c|1|11d758d2228|f398|ddb9308d|8e5efbc8ac8211dd893c001c23e19543|0 +11:map_code_dlgpdu.c|1|11d70a46b55|1706|46d6fc5a|473972dcbfa611dc86a4001c23e19543|0 +6:imap.h|1|11d70a46c10|2c3|dc9fe4aa|49997330bfa611dc86a4001c23e19543|0 +d:is41_coding.c|1|11d70a46ab9|49ab|423152d3|45797288bfa611dc86a4001c23e19543|0 +c:win_struct.h|1|11d70a46df5|3e48|1f57596c|4f99742cbfa611dc86a4001c23e19543|0 +9:Map_opr.c|1|11d70a46e81|52d6|2ac4a191|6f2f82226e9911dd9a39001c23e19543|0 +f:is41_code_win.c|1|11d70a46971|11614|f8b47ad7|414971e0bfa611dc86a4001c23e19543|0 +e:is41_code_ms.c|1|11d70a46b93|1e110|ec432a25|47d972f8bfa611dc86a4001c23e19543|0 +d:map_code_ss.c|1|11d70a46877|a3b6|2318f99e|3e497170bfa611dc86a4001c23e19543|0 +f:is41_code_sms.c|1|11d70a469de|8385|11db6fb8|42797218bfa611dc86a4001c23e19543|0 +d:map_code_ch.c|1|11d70a46a0d|b630|627641d|43197234bfa611dc86a4001c23e19543|0 +e:map_opr_func.h|1|11d70a46eb0|913|7bcf3496|705f82296e9911dd9a3a001c23e19543|0 +9:map_acn.h|1|11d758d2257|9e9|a849ef3d|90befbd6ac8211dd893c001c23e19543|0 +b:is41_code.h|1|11d70a468a6|e0a|568eb710|3ee9718cbfa611dc86a4001c23e19543|0 +c:map_struct.h|1|11d758d2295|16b5a|28a4e1b4|93befbeaac8211dd893d001c23e19543|0 +e:map_code_auc.c|1|11d70a46e52|1981|58069302|50c97448bfa611dc86a4001c23e19543|0 +a:map_code.h|1|11d758d2247|2d56|f984c4d4|67ef017fac8311dd8958001c23e19543|0 +c:is41_debug.c|1|11d70a46ae8|1216c|76dd9cc8|460972a4bfa611dc86a4001c23e19543|0 +e:map_code_sms.c|1|11d70a46d78|812b|d2e2b0bd|406a3fb9ce1311dc9f39001c23e19543|0 +d:map_LCSCode.c|1|11d8a87d419|12ae|c754bc51|342017a3af0f11dd8894001c23e19543|0 +d:map_code_ms.c|1|11d70a46cdb|1ddbf|620185bb|6953d7e6e4f611dc8b3a001c23e19543|0 +b:is41_init.c|1|11d70a46923|1bc|4e4683d7|401971c4bfa611dc86a4001c23e19543|0 +c:map_public.h|1|11d70a46a6b|406|ff725524|4449726cbfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/src/mapp/Map_opr.c b/omc/plat/xapp/src/mapp/Map_opr.c new file mode 100644 index 0000000..70ab190 --- /dev/null +++ b/omc/plat/xapp/src/mapp/Map_opr.c @@ -0,0 +1,942 @@ + #include "map_includes.h" + + /**************** vlr inquery opr ********************/ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MapDetermineOprUser Arg argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_MapDetermineOprUserArg(struct MapDetermineOprUser_Arg *dou_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = dou_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,dou_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapDetermineOprUserArg loss IMSI"); + return RER; + } + if (flag & 0x02) // has imei + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,IMEI_LEN,dou_ptr->imei,0x80,&asn_buf);//add imei parameter + } + else + { + mapp_log_debug("assign MapDetermineOprUserArg loss IMEI"); + return RER; + } + if (flag & 0x04) //has roamingRestraintFlag + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&dou_ptr->roamingRestraintFlag,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapDetermineOprUserArg loss roamingRestraintFlag"); + return RER; + } + dou_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapDetermineOprUserArg(struct MapDetermineOprUser_Arg *dou_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + dou_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapDetermineOprUserArg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(dou_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDetermineOprUserArg:loss IMSI"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len == IMEI_LEN) // get imei + { + flag |= 0x02; + memcpy(dou_ptr->imei,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDetermineOprUserArg:loss IMEI"); + return RER; + } + + len = get_tlv("2",temp_buf,&asn_buf); //get roamingRestraintFlag + if (len == 1) + { + dou_ptr->roamingRestraintFlag = temp_buf[0]; + flag |= 0x04; + } + else + { + mapp_log_debug("extract MapDetermineOprUserArg:loss roamingRestraintFlag"); + return RER; + } + dou_ptr->param_flag = flag; + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MapDetermineOprUser Response */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_MapDetermineOprUserRes(struct MapDetermineOprUser_Res *dou_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = dou_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,dou_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapDetermineOprUserRes loss IMSI"); + return RER; + } + if (flag & 0x02) // has imei + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,IMEI_LEN,dou_ptr->imei,0x80,&asn_buf);//add imei parameter + } + else + { + mapp_log_debug("assign MapDetermineOprUserRes loss IMEI"); + return RER; + } + if (flag & 0x04) //has oprFlag + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&dou_ptr->oprflag,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapDetermineOprUserRes loss oprFlag"); + return RER; + } + if (flag & 0x08) //has msisdn + { + sprintf(tlv1,"3-%d",tag1++); + buf_len = add_tlv(tlv1,dou_ptr->msisdn[0],dou_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + dou_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapDetermineOprUserRes(struct MapDetermineOprUser_Res *dou_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + dou_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapDetermineOprUserRes param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(dou_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDetermineOprUserRes:loss IMSI"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len == IMEI_LEN) // get imei + { + flag |= 0x02; + memcpy(dou_ptr->imei,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDetermineOprUserRes:loss IMEI"); + return RER; + } + + len = get_tlv("2",temp_buf,&asn_buf); //get oprflag + if (len == 1) + { + dou_ptr->oprflag = temp_buf[0]; + flag |= 0x04; + } + else + { + mapp_log_debug("extract MapDetermineOprUserRes:loss oprflag"); + return RER; + } + len = get_tlv("3",temp_buf,&asn_buf); //get msisdn + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x08; + dou_ptr->msisdn[0] = len; + memcpy(dou_ptr->msisdn+1,temp_buf,len); + } + + dou_ptr->param_flag = flag; + return buf_len; +} + +/**************** opr updataLocation vlr ********************/ +int assign_MapVlrUpdateLocationArg(struct MapVlrUpdateLocation_Arg *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapVlrUpdateLocationArg loss IMSI"); + return RER; + } + if (flag & 0x02) // has oprflag + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->status,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapVlrUpdateLocationArg loss status"); + return RER; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + + +int extract_MapVlrUpdateLocationArg(struct MapVlrUpdateLocation_Arg *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapVlrUpdateLocationArg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapVlrUpdateLocationArg:loss IMSI"); + return RER; + } + len = get_tlv("1",temp_buf,&asn_buf);/* get status */ + if (len == 1) + { + flag |= 0x02; + cuwm_ptr->status = temp_buf[0]; + } + else + { + mapp_log_debug("extract MapVlrUpdateLocationArg:loss status"); + return RER; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + +int assign_MapVlrUpdateLocationRes(struct MapVlrUpdateLocation_Res *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + + if (flag & 0x02) // has status + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->status,0x80,&asn_buf);//add msisdn parameter + } + + if (flag & 0x04) //has error + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->error,0x80,&asn_buf); + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapVlrUpdateLocationRes(struct MapVlrUpdateLocation_Res *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapVlrUpdateLocationRes param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + + + len = get_tlv("1",temp_buf,&asn_buf); + if (len == 1) + { + flag |= 0x02; + cuwm_ptr->status = temp_buf[0]; + } + + len = get_tlv("2",temp_buf,&asn_buf); //get reult + if (len == 1) + { + cuwm_ptr->error = temp_buf[0]; + flag |= 0x04; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + + +/**************** opr create hlr ********************/ +int assign_MapCreateUserWithMsisdnImsiArg(struct MapCreateUserWithMsisdnImsi_Arg *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiArg loss IMSI"); + return RER; + } + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,cuwm_ptr->msisdn[0],cuwm_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiArg loss MSISDN"); + return RER; + } + + if (flag & 0x04) //has imsiFlag + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->imsiflag,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiArg loss imsiFlag"); + return RER; + } + + if (flag & 0x08) //has camelFlag + { + sprintf(tlv1,"3-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->camelflag,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiArg loss camelflag"); + return RER; + } + cuwm_ptr->param_flag = flag; + return buf_len; +} + + +int extract_MapCreateUserWithMsisdnImsiArg(struct MapCreateUserWithMsisdnImsi_Arg *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapCreateUserWithMsisdnImsiArg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapCreateUserWithMsisdnImsiArg:loss IMSI"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + cuwm_ptr->msisdn[0] = len; + memcpy(cuwm_ptr->msisdn+1,temp_buf,len); + } + else + { + mapp_log_debug("extract MapCreateUserWithMsisdnImsiArg:msisdn length error"); + return RER; + } + + len = get_tlv("2",temp_buf,&asn_buf); //get imsiflag + if (len == 1) + { + cuwm_ptr->imsiflag = temp_buf[0]; + flag |= 0x04; + } + else + { + mapp_log_debug("extract MapCreateUserWithMsisdnImsiArg:loss roamingRestraintFlag"); + return RER; + } + len = get_tlv("3",temp_buf,&asn_buf); //get camelflag + if (len == 1) + { + cuwm_ptr->camelflag = temp_buf[0]; + flag |= 0x08; + } + else + { + mapp_log_debug("extract MapCreateUserWithMsisdnImsiArg:loss camelflag"); + return RER; + } + cuwm_ptr->param_flag = flag; + return buf_len; +} + +int assign_MapCreateUserWithMsisdnImsiRes(struct MapCreateUserWithMsisdnImsi_Res *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,cuwm_ptr->msisdn[0],cuwm_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + + + if (flag & 0x04) //has result + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->result,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiRes loss result"); + return RER; + } + + if (flag & 0x08) //has cause + { + sprintf(tlv1,"3-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->cause,0x80,&asn_buf); + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapCreateUserWithMsisdnImsiRes(struct MapCreateUserWithMsisdnImsi_Res *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapCreateUserWithMsisdnImsiRes param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + cuwm_ptr->msisdn[0] = len; + memcpy(cuwm_ptr->msisdn+1,temp_buf,len); + } + + + len = get_tlv("2",temp_buf,&asn_buf); //get reult + if (len == 1) + { + cuwm_ptr->result = temp_buf[0]; + flag |= 0x04; + } + else + { + mapp_log_debug("extract MapCreateUserWithMsisdnImsiArg:loss result"); + return RER; + } + + len = get_tlv("3",temp_buf,&asn_buf); //get cause + if (len == 1) + { + cuwm_ptr->cause = temp_buf[0]; + flag |= 0x08; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + + + +/*********** opr delete hlr ***************************/ +int assign_MapDeleteOprUserArg(struct MapDeleteOprUser_Arg *dou_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = dou_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,dou_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapDeleteOprUserArg loss IMSI"); + return RER; + } + + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,dou_ptr->msisdn[0],dou_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapDeleteOprUserArg loss MSISDN"); + return RER; + } + + dou_ptr->param_flag = flag; + return buf_len; +} + + +int extract_MapDeleteOprUserArg(struct MapDeleteOprUser_Arg *dou_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + dou_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapDeleteOprUserArg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(dou_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDeleteOprUserArg:loss IMSI"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + dou_ptr->msisdn[0] = len; + memcpy(dou_ptr->msisdn+1,temp_buf,len); + } + else + { + mapp_log_debug("extract MapDeleteOprUserArg:msisdn length error"); + return RER; + } + + dou_ptr->param_flag = flag; + return buf_len; +} + +int assign_MapDeleteOprUserRes(struct MapDeleteOprUser_Res *dou_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = dou_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,dou_ptr->imsi,0x80,&asn_buf);//add msisdn parameter + } + + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,dou_ptr->msisdn[0],dou_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + + + if (flag & 0x04) //has result + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&dou_ptr->result,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapDeleteOprUserRes loss result"); + return RER; + } + + if (flag & 0x08) //has cause + { + sprintf(tlv1,"3-%d",tag1++); + buf_len = add_tlv(tlv1,1,&dou_ptr->cause,0x80,&asn_buf); + } + + dou_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapDeleteOprUserRes(struct MapDeleteOprUser_Res *dou_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + dou_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapDeleteOprUserRes param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(dou_ptr->imsi,temp_buf,len); + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + dou_ptr->msisdn[0] = len; + memcpy(dou_ptr->msisdn+1,temp_buf,len); + } + + + len = get_tlv("2",temp_buf,&asn_buf); //get reult + if (len == 1) + { + dou_ptr->result = temp_buf[0]; + flag |= 0x04; + } + else + { + mapp_log_debug("extract MapDeleteOprUserRes:loss result"); + return RER; + } + + len = get_tlv("3",temp_buf,&asn_buf); //get cause + if (len == 1) + { + dou_ptr->cause = temp_buf[0]; + flag |= 0x08; + } + + dou_ptr->param_flag = flag; + return buf_len; +} + + +int assign_MapVlrEnquiryIMDM_Arg(struct MapVlrEnquiryIMDM_Arg *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add imsi parameter + } + else + { + mapp_log_debug("assign MapVlrEnquiryIMDM_Arg loss IMSI"); + return RER; + } + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,cuwm_ptr->msisdn[0],cuwm_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("assign MapCreateUserWithMsisdnImsiArg loss MSISDN"); + return RER; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + + +int assign_MapVlrEnquiryIMDM_Res(struct MapVlrEnquiryIMDM_Res *cuwm_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = cuwm_ptr->param_flag; + if (flag & 0x01) // has imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,cuwm_ptr->imsi,0x80,&asn_buf);//add imsi parameter + } + + if (flag & 0x02) // has msisdn + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,cuwm_ptr->msisdn[0],cuwm_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + + if (flag & 0x04) // has status + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cuwm_ptr->status,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign MapVlrEnquiryIMDM_Arg loss staus"); + return RER; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + + +int extract_MapVlrEnquiryIMDM_Arg(struct MapVlrEnquiryIMDM_Arg *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapVlrEnquiryIMDM_Arg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract MapVlrEnquiryIMDM_Arg:loss IMSI"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + cuwm_ptr->msisdn[0] = len; + memcpy(cuwm_ptr->msisdn+1,temp_buf,len); + } + else + { + mapp_log_debug("extract MapVlrEnquiryIMDM_Arg:msisdn length error"); + return RER; + } + + cuwm_ptr->param_flag = flag; + return buf_len; +} + +int extract_MapVlrEnquiryIMDM_Res(struct MapVlrEnquiryIMDM_Res *cuwm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + cuwm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("extract_MapVlrEnquiryIMDM_Res param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN) + { + flag |= 0x01; + memcpy(cuwm_ptr->imsi,temp_buf,len); + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x02; + cuwm_ptr->msisdn[0] = len; + memcpy(cuwm_ptr->msisdn+1,temp_buf,len); + } + + len = get_tlv("2",temp_buf,&asn_buf);/* status */ + if (len == 1) + { + flag |= 0x04; + cuwm_ptr->status = temp_buf[0]; + } + else + { + mapp_log_debug("extract MapVlrEnquiryIMDM_Res:status loss"); + return RER; + } + + + cuwm_ptr->param_flag = flag; + return buf_len; +} + diff --git a/omc/plat/xapp/src/mapp/imap.h b/omc/plat/xapp/src/mapp/imap.h new file mode 100644 index 0000000..4fc6b31 --- /dev/null +++ b/omc/plat/xapp/src/mapp/imap.h @@ -0,0 +1,22 @@ +/* MAP message interface head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _MAP_INTERFACE +#define _MAP_INTERFACE + +#include "../../../sccp/src/include/sccp.h" +#include "map_const.h" +#include "map_struct.h" + +int build_mapparam(struct MapOprSrv_struct *opr_ptr,u8 *buf); +u8 extract_mapparam(struct MapOprSrv_struct *opr_ptr,u8 opr_code,u8 opr_flag,u32 pre_param_len,u8 *pre_param); + +int build_is41param(struct MapOprSrv_struct *opr_ptr,u8 *buf); // build is41 service paramter +u8 extract_is41param(struct MapOprSrv_struct *opr_ptr,u8 opr_code,u8 opr_flag,u32 pre_param_len,u8 *pre_param); + +void is41_init(); +void is41_timer(); + +#endif diff --git a/omc/plat/xapp/src/mapp/is41_code.h b/omc/plat/xapp/src/mapp/is41_code.h new file mode 100644 index 0000000..628296a --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_code.h @@ -0,0 +1,110 @@ +/* IS41 code define */ +/* Created by daniel on 2005-05-27 */ +/* Modified by daniel on 2005-05-27 */ +/* -------------------------------------*/ +#ifndef _IS41_CODE +#define _IS41_CODE + +//Authorization Denied reason +#define AUTHDEN_DELINQUENT_ACCOUNT 1 +#define AUTHDEN_INVALID_SERIAL_NUMBER 2 +#define AUTHDEN_STOLEN_UNIT 3 +#define AUTHDEN_DUPLICATE_UNIT 4 +#define AUTHDEN_UNASSIGNED_DIRECTORY_NUMBER 5 +#define AUTHDEN_UNSPECIFIED 6 +#define AUTHDEN_MULTIPLE_ACCESS 7 +#define AUTHDEN_NOT_AUTHORIZED_FOR_THE_MSC 8 +#define AUTHDEN_MISSING_AUTHENTICATION_PARAMETERS 9 +#define AUTHDEN_TERMINALTYPE_MISMATCH 10 + +#define WXC_SYSTEM_MY_TYPE_CODE 0 + +#define CANTYP_SERVING_SYSTEM_OPTION 1 +#define CANTYP_REPORTINCALL 2 +#define CANTYP_DISCONTINUE 3 + +//type of digits +#define TOD_CALLED_PARTY_NUMBER 1 +#define TOD_CALLING_PARTY_NUMBER 2 +#define TOD_CALLER_INTERACTION 3 +#define TOD_ROUTING_NUMBER 4 +#define TOD_BILLING_NUMBER 5 +#define TOD_DESTINATION_NUMBER 6//This is the network address of the called party +#define TOD_LATA 7 +#define TOD_CARRIER 8//In North America the three, four, or five digits represent an interexchange or international carrier + +#define QUALCODE_VALIDATION_ONLY 2 +#define QUALCODE_VALIDATION_AND_PROFILE 3 +#define QUALCODE_PROFILE_ONLY 4 + +#define ACCDEN_UNASSIGNED_DIRECTORY_NUMBER 1 +#define ACCDEN_INACTIVE 2 +#define ACCDEN_BUSY 3 +#define ACCDEN_TERMINATION_DENIED 4 +#define ACCDEN_NO_PAGE_RESPONSE 5 +#define ACCDEN_UNAVAILABLE 6 + +//DMH_RedirectionIndicator +#define REDIND_CFU 1 +#define REDIND_CFB 2 +#define REDIND_CFNA 3 +#define REDIND_CFO 4 +#define REDIND_CD_UNSPECIFIED 5 +#define REDIND_CD_PSTN 6 +#define REDIND_CD_PRIVATE 7 +#define REDIND_PSTN_TANDEM 8 +#define REDIND_PRIVATE_TANDEM 9 +#define REDIND_BUSY 10 +#define REDIND_INACTIVE 11 +#define REDIND_UNASSIGNED 12 +#define REDIND_TERMINATION_DENIED 13 +#define REDIND_CD_FAILURE 14 +#define REDIND_ECT 15 +#define REDIND_MAH 16 +#define REDIND_FA 17 +#define REDIND_ABANDONED_CALL_LEG 18 +#define REDIND_PCA_CALL_REFUSED 19 +#define REDIND_SCA_CALL_REFUSED 20 +#define REDIND_DIALOGUE 21 +#define REDIND_CFD 22 +#define REDIND_CD_LOCAL 23 +#define REDIND_VOICE_MAIL_RETRIEVAL 24 + +//RedirectionReason +#define REDREASON_BUSY 1 +#define REDREASON_NO_ANSWER 2 +#define REDREASON_UNCONDITIONAL 3 +#define REDREASON_NO_PAGE_RESPONSE 4 +#define REDREASON_UNAVAILABLE 5 +#define REDREASON_UNROUTABLE 6 +#define REDREASON_CALL_ACCEPTED 7 +#define REDREASON_CALL_REFUSED 8 + +#define ORIGIND_Prior_agreement 1 +#define ORIGIND_Origination_denied 2 +#define ORIGIND_Local_calls_only 3 +#define ORIGIND_Selected_ldigits 4 +#define ORIGIND_Selected_ldigits_and_local_call 5 +#define ORIGIND_National_long_distance 6 +#define ORIGIND_International_calls 7 +#define ORIGIND_Single_directory_number 8 + +#define AUTHPER_Per_Call 1 +#define AUTHPER_Hours 2 +#define AUTHPER_Days 3 +#define AUTHPER_Weeks 4 +#define AUTHPER_Per_Agreement 5 +#define AUTHPER_Indefinite 6 +#define AUTHPER_Number_of_calls 7 + + +#define ACCTYPE_FLASHREQ 2 +#define ACCTYPE_REGISTRATION 3 +#define ACCTYPE_ORIGINATION 4 +#define ACCTYPE_TERMINATION 5 +#define ACCTYPE_NOACCESS 6 +#define ACCTYPE_POWERDOWN 7 +#define ACCTYPE_SMS_PAGERESPONSE 8 + + +#endif diff --git a/omc/plat/xapp/src/mapp/is41_code_auc.c b/omc/plat/xapp/src/mapp/is41_code_auc.c new file mode 100644 index 0000000..c8c258b --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_code_auc.c @@ -0,0 +1,1345 @@ +/* is41 coding auc service file */ +/* written by daniel zhang 2004-06-16 */ +/* modified by daniel on 2004-07-09 */ +/* -------------------------------- */ + +#include "map_includes.h" + +/* external functions */ +void is41_log(char *info); +void is41_debug(DWORD mask, const char *fmt, ...); +void is41_showbuf(DWORD mask, BYTE *buf, int len); +int decode_Is41Parameter(char *tag,int len,BYTE *value,ASN_BUF *asn_buf); +char *is41_sequenceTag(char *tag,int sequence); + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding security triplets argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_is41AuthenticationDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_AUTHDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.authdir_arg; + + + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Starting...ESN=%lx%lx%lx%lx,MIN=%ld%ld%ld%ld", + ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3], + ptr->min[0],ptr->min[1], + ptr->min[2],ptr->min[3],ptr->min[4]); + +// optional part---> + if((flag & BIT2_TRUE)>0) //AuthenticationAlgorithmVersion + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AAV,3),1,&ptr->aav,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //AuthenticationResponseUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHU,4),3,ptr->authu,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,5),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //DenyAccess + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENACC,6),1,&ptr->denacc,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //LocationAreaID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,7),2,ptr->locid,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //RandomVariableSSD + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDSSD,8),7,ptr->randssd,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //RandomVariableUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDU,9),3,ptr->randu,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,10),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //SharedSecretData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SSD,11),16,ptr->ssd,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //SSDNotShared + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NOSSD,12),1,&ptr->nossd,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //UpdateCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_UPDCOUNT,13),1,&ptr->updcount,0x80,&asn_buf); + + + return buf_len; +} + +int assign_is41AuthenticationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_AUTHDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.authdir_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(IS41PAR_COUNT,1,(BYTE*)&ptr->count,0x80,&asn_buf); + else + return 0; + + return buf_len; +} + +int extract_is41AuthenticationDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 len; + + struct IS41_AUTHDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.authdir_arg; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_AAV,1,&ptr->aav,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHU,3,ptr->authu,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter(IS41PAR_DENACC,1,&ptr->denacc,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_LOCID,2,ptr->locid,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDSSD,7,ptr->randssd,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDU,8,ptr->randu,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT9_TRUE; + } + if (decode_Is41Parameter(IS41PAR_SSD,16,ptr->ssd,&asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if (decode_Is41Parameter(IS41PAR_NOSSD,1,&ptr->nossd,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if (decode_Is41Parameter(IS41PAR_UPDCOUNT,1,&ptr->updcount,&asn_buf)) + ptr->param_flag |= BIT12_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int extract_is41AuthenticationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_AUTHDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.authdir_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,1,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationDirectiveForward_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41AucDirectiveForward_arg *ptr; + + ptr = &opr_ptr->msg_list.AUCDirForw_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //inter MSC CircuitID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_IMSCCID,1),2,ptr->InterMSCCircuitID,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSC CID absent!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->MobileIdentificationNumber,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!"); + return 0; + } + + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Starting...MSC CID=%x.%x,MIN=%ld%ld%ld%ld", + ptr->InterMSCCircuitID[0],ptr->InterMSCCircuitID[1], + ptr->MobileIdentificationNumber[0],ptr->MobileIdentificationNumber[1], + ptr->MobileIdentificationNumber[2],ptr->MobileIdentificationNumber[3],ptr->MobileIdentificationNumber[4]); + +// optional part---> + if((flag & BIT2_TRUE)>0) //AuthenticationAlgorithmVersion + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHU,3),3,ptr->AuthenticationResponseUniqueChallenge,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //RandomVariableUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDU,4),3,ptr->RandomVariableUniqueChallenge,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41AuthenticationDirectiveForward_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41AucDirectiveForward_arg *ptr; + + ptr = &opr_ptr->msg_list.AUCDirForw_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,4,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_IMSCCID,2,(BYTE*)&ptr->InterMSCCircuitID,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSC ID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->MobileIdentificationNumber,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +//optional part + if (decode_Is41Parameter(IS41PAR_AUTHU,3,ptr->AuthenticationResponseUniqueChallenge,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDU,3,ptr->RandomVariableUniqueChallenge,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationFailureReport_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_AFREPORT_ARG *ptr; + + ptr = &opr_ptr->msg_list.afreport_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //reportType + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RPTTYP,3),1,&ptr->rpttyp1,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:reportType absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //system access type + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCTYPE,4),1,&ptr->sysacctype,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:system access type absent!"); + return 0; + } + + if((flag & BIT4_TRUE)>0) //system capabilities + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSCAP,5),1,&ptr->syscap,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:system access type absent!"); + return 0; + } + + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Starting...ESN=%lx%lx%lx%lx,MIN=%ld%ld%ld%ld,ReportType=%d,sysAccType=%d,sysCap=%d", + ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3], + ptr->min[0],ptr->min[1], + ptr->min[2],ptr->min[3],ptr->min[4], + ptr->rpttyp1,ptr->sysacctype,ptr->syscap); + +// optional part---> + if((flag & BIT5_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,6),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //CallHistoryCountExpected + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNTEx,7),1,&ptr->countex,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,8),3,ptr->mscid,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //reportType + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RPTTYP,9),1,&ptr->rpttyp2,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,10),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41AuthenticationFailureReport_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 len; + + struct IS41_AFREPORT_ARG *ptr; + + ptr = &opr_ptr->msg_list.afreport_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,10,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(is41_sequenceTag(IS41PAR_RPTTYP,3),1,&ptr->rpttyp1,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ReportType absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_SYSACCTYPE,1,&ptr->sysacctype,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SystemAccessType absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_SYSCAP,1,&ptr->syscap,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SystemCapabilities absent!"); + return 0; + } + +// optional part---> + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNTEx,1,&ptr->countex,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(is41_sequenceTag(IS41PAR_RPTTYP,9),1,&ptr->rpttyp2,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT9_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationFailureReport_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_AFREPORT_RSP *ptr; + + ptr = &opr_ptr->msg_list.afreport_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +// optional part---> + if((flag & BIT0_TRUE)>0) //AuthenticationAlgorithmVersion + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AAV,1),1,&ptr->aav,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //AuthenticationResponseUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHU,2),3,ptr->authu,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,3),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //DenyAccess + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENACC,4),1,&ptr->denacc,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //RandomVariableSSD + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDSSD,5),7,ptr->randssd,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //RandomVariableUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDU,6),3,ptr->randu,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //SharedSecretData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SSD,7),16,ptr->ssd,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //SSDNotShared + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NOSSD,8),1,&ptr->nossd,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //TerminalType + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTYP,9),1,&ptr->termtyp,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //UpdateCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_UPDCOUNT,10),1,&ptr->updcount,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41AuthenticationFailureReport_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_AFREPORT_RSP *ptr; + + ptr = &opr_ptr->msg_list.afreport_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,10,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_AAV,1,&ptr->aav,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHU,3,ptr->authu,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_DENACC,1,&ptr->denacc,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDSSD,7,ptr->randssd,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDU,8,ptr->randu,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_SSD,16,ptr->ssd,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_NOSSD,1,&ptr->nossd,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_TERMTYP,1,&ptr->termtyp,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if (decode_Is41Parameter(IS41PAR_UPDCOUNT,1,&ptr->updcount,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_AUTHREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.authreq_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //system access type + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCTYPE,4),1,&ptr->sysacctype,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:system access type absent!"); + return 0; + } + + if((flag & BIT4_TRUE)>0) //system capabilities + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSCAP,5),1,&ptr->syscap,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:system access type absent!"); + return 0; + } + + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Starting...ESN=%lx%lx%lx%lx,MIN=%ld%ld%ld%ld,MSCID=%d,sysAccType=%d,sysCap=%d", + ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3], + ptr->min[0],ptr->min[1], + ptr->min[2],ptr->min[3],ptr->min[4], + ptr->mscid,ptr->sysacctype,ptr->syscap); + +//optional part---> + if((flag & BIT5_TRUE)>0) //AuthenticationData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHDATA,6),3,ptr->authdata,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) //AuthenticationResponse + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHR,7),3,ptr->authr,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,8),1,&ptr->count,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) //ConfidentialityModes + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CMODES,9),1,&ptr->cmodes,0x80,&asn_buf); + if((flag & BIT9_TRUE)>0) //Digits + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,10),ptr->DigitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); + if((flag & BIT10_TRUE)>0) //PC_SSN + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,11),5,ptr->pcssn,0x80,&asn_buf); + if((flag & BIT11_TRUE)>0) //RandomVariable + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RAND,12),4,ptr->rand,0x80,&asn_buf); + if((flag & BIT12_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,13),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + if((flag & BIT13_TRUE)>0) //TerminalType + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTYP,14),1,&ptr->termtyp,0x80,&asn_buf); + + return buf_len; + +} + +int extract_is41AuthenticationRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_AUTHREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.authreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,14,&decErr,&asn_buf) == -1) + { + return 0; + } + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + { + ptr->param_flag |= BIT2_TRUE; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_SYSACCTYPE,1,&ptr->sysacctype,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SystemAccessType absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_SYSCAP,1,&ptr->syscap,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SystemCapabilities absent!"); + return 0; + } + +// optional part---> + if (decode_Is41Parameter(IS41PAR_AUTHDATA,3,ptr->authdata,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHR,3,ptr->authr,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_CMODES,1,&ptr->cmodes,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + len = decode_Is41Parameter(IS41PAR_DIGITS,32,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->DigitsLen = len; + } + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if (decode_Is41Parameter(IS41PAR_RAND,4,ptr->rand,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT12_TRUE; + } + len = decode_Is41Parameter(IS41PAR_TERMTYP,1,&ptr->termtyp,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT13_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41AuthenticationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_AUTHREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.authreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +// optional part---> + if((flag & BIT0_TRUE)>0) //AuthenticationAlgorithmVersion + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AAV,1),1,&ptr->aav,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //AuthenticationResponseUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHU,2),3,ptr->authu,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,3),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //CDMAPrivateLongCodeMask + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CDMAPLCM,4),6,ptr->cdmaplcm,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //DenyAccess + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENACC,5),1,&ptr->denacc,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //RandomVariableSSD + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDSSD,6),7,ptr->randssd,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //RandomVariableUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDU,7),3,ptr->randu,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //SharedSecretData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SSD,8),16,ptr->ssd,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //SharedSecretData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMEKEY,9),8,ptr->smekey,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SSDNotShared + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NOSSD,10),1,&ptr->nossd,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //UpdateCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_UPDCOUNT,11),1,&ptr->updcount,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //VoicePrivacyMask + buf_len = AddTLV(is41_sequenceTag(IS41PAR_VPMASK,12),66,ptr->vpmask,0x80,&asn_buf); + + + return buf_len; +} + +int extract_is41AuthenticationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_AUTHREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.authreq_rsp; + ptr->param_flag = 0; + + if (buf_len == 0) + { +// is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 1; + } + if(AsnDecode(buf,buf_len,12,&decErr,&asn_buf) == -1) + return 0; + + if (decode_Is41Parameter(IS41PAR_AAV,1,&ptr->aav,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHU,3,ptr->authu,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_CDMAPLCM,6,ptr->cdmaplcm,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter(IS41PAR_DENACC,1,&ptr->denacc,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDSSD,7,ptr->randssd,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDU,3,ptr->randu,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_SSD,16,ptr->ssd,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_SMEKEY,8,ptr->smekey,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if (decode_Is41Parameter(IS41PAR_NOSSD,1,&ptr->nossd,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if (decode_Is41Parameter(IS41PAR_UPDCOUNT,1,&ptr->updcount,&asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if (decode_Is41Parameter(IS41PAR_VPMASK,66,ptr->vpmask,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationStatusReport_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_ASREPORT_ARG *ptr; + + ptr = &opr_ptr->msg_list.asreport_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //system capabilities + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSCAP,3),1,&ptr->syscap,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:system access type absent!"); + return 0; + } + + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Starting...ESN=%lx%lx%lx%lx,MIN=%ld%ld%ld%ld,sysCap=%d", + ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3], + ptr->min[0],ptr->min[1], + ptr->min[2],ptr->min[3],ptr->min[4], + ptr->syscap); + +//optional part---> + if((flag & BIT3_TRUE)>0) //CountUpdateReport + { + if (ptr->CntUpdRepLen > 32) + { + ptr->CntUpdRepLen = 32; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNTRPT,4),ptr->CntUpdRepLen,ptr->countrpt,0x80,&asn_buf); + } + + if((flag & BIT4_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,5),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //SSDUpdateReport + { + if (ptr->SSDUpdRepLen > 32) + { + ptr->SSDUpdRepLen = 32; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SSDURPT,6),ptr->SSDUpdRepLen,ptr->ssdurpt,0x80,&asn_buf); + } + + if((flag & BIT6_TRUE)>0) //UniqueChallengeReport + { + if (ptr->UniChaRepLen > 32) + { + ptr->UniChaRepLen = 32; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_UCHALRPT,7),ptr->UniChaRepLen,ptr->uchalrpt,0x80,&asn_buf); + } + + return buf_len; + +} + +int extract_is41AuthenticationStatusReport_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_ASREPORT_ARG *ptr; + + ptr = &opr_ptr->msg_list.asreport_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,7,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_SYSCAP,1,&ptr->syscap,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SystemCapabilities absent!"); + return 0; + } + +// optional part---> + len = decode_Is41Parameter(IS41PAR_COUNTRPT,32,ptr->countrpt,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->CntUpdRepLen = len; + } + + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT4_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_SSDURPT,32,ptr->ssdurpt,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->SSDUpdRepLen = len; + } + + len = decode_Is41Parameter(IS41PAR_UCHALRPT,32,ptr->uchalrpt,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->UniChaRepLen = len; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41AuthenticationStatusReport_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_ASREPORT_RSP *ptr; + + ptr = &opr_ptr->msg_list.asreport_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +//optional part---> + if((flag & BIT0_TRUE)>0) //AuthenticationAlgorithmVersion + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AAV,1),1,&ptr->aav,0x80,&asn_buf); + if((flag & BIT1_TRUE)>0) //AuthenticationResponseUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHU,2),3,ptr->authu,0x80,&asn_buf); + if((flag & BIT2_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,3),1,&ptr->count,0x80,&asn_buf); + if((flag & BIT3_TRUE)>0) //DenyAccess + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENACC,4),1,&ptr->denacc,0x80,&asn_buf); + if((flag & BIT4_TRUE)>0) //RandomVariableSSD + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDSSD,5),7,ptr->randssd,0x80,&asn_buf); + if((flag & BIT5_TRUE)>0) //RandomVariableUniqueChallenge + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDU,6),3,ptr->randu,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) //SharedSecretData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SSD,7),16,ptr->ssd,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //SSDNotShared + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NOSSD,8),1,&ptr->nossd,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) //UpdateCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_UPDCOUNT,9),1,&ptr->updcount,0x80,&asn_buf); + + return buf_len; + +} + +int extract_is41AuthenticationStatusReport_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_ASREPORT_RSP *ptr; + + ptr = &opr_ptr->msg_list.asreport_rsp; + ptr->param_flag = 0; + + if (buf_len == 0) + { +// is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 1; + } + if(AsnDecode(buf,buf_len,9,&decErr,&asn_buf) == -1) + return 0; + + + +// optional part---> + if (decode_Is41Parameter(IS41PAR_AAV,1,&ptr->aav,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHU,3,ptr->authu,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_DENACC,1,&ptr->denacc,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDSSD,7,ptr->randssd,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter(IS41PAR_RANDU,8,ptr->randu,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_SSD,16,ptr->ssd,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_NOSSD,1,&ptr->nossd,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_UPDCOUNT,1,&ptr->updcount,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41BaseStationChallenge_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_BSCHALL_ARG *ptr; + + ptr = &opr_ptr->msg_list.bschall_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //randbs + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RANDBS,3),4,ptr->randbs,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:RANDBS absent!!"); + return 0; + } + +//optional part---> + if((flag & BIT3_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,13),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + return buf_len; + +} + +int extract_is41BaseStationChallenge_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 len; + + struct IS41_BSCHALL_ARG *ptr; + + ptr = &opr_ptr->msg_list.bschall_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,14,&decErr,&asn_buf) == -1) + { + return 0; + } + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_RANDBS,4,ptr->randbs,&asn_buf)) + { + ptr->param_flag |= BIT2_TRUE; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + + +// optional part---> + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0); + { + ptr->senderinLen = len; + ptr->param_flag |= BIT3_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41BaseStationChallenge_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_BSCHALL_RSP *ptr; + + ptr = &opr_ptr->msg_list.bschall_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //authbs + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHBS,1),3,(BYTE*)&ptr->authbs,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:AUTHBS absent!!"); + return 0; + } + + + return buf_len; +} + +int extract_is41BaseStationChallenge_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_BSCHALL_RSP *ptr; + + ptr = &opr_ptr->msg_list.bschall_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,12,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_AUTHBS,4,(BYTE*)&ptr->authbs,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:AUTHBS absent!"); + return 0; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41CountRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_COUNTREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.countreq_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,(BYTE*)&ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + + +//optional part---> + if((flag & BIT2_TRUE)>0) //SenderIdentificationNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,3),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + return buf_len; + +} + +int extract_is41CountRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 len; + + struct IS41_COUNTREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.countreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,14,&decErr,&asn_buf) == -1) + { + return 0; + } + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,(BYTE*)&ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +// optional part---> + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT2_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41CountRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_COUNTREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.countreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +// optional part---> + if((flag & BIT0_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,1),1,&ptr->count,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41CountRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_COUNTREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.countreq_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,12,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} diff --git a/omc/plat/xapp/src/mapp/is41_code_ms.c b/omc/plat/xapp/src/mapp/is41_code_ms.c new file mode 100644 index 0000000..90ce0d8 --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_code_ms.c @@ -0,0 +1,3968 @@ +/* is41 coding auc service file */ +/* written by daniel zhang 2004-06-16 */ +/* modified by daniel on 2004-07-09 */ +/* -------------------------------- */ + +#include "map_includes.h" +/* external functions */ +void is41_log(char *info); +void is41_debug(DWORD mask, const char *fmt, ...); +void is41_showbuf(DWORD mask, BYTE *buf, int len); +int decode_Is41Parameter(char *tag,int len,BYTE *value,ASN_BUF *asn_buf); +char *is41_sequenceTag(char *tag,int sequence); + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding security triplets argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_is41RegistrationNotification_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + struct IS41_REGNOT_ARG *ptr; + struct IS41_PAR_WIN_CAP *ptr1; + char tag[64]; + + ptr = &opr_ptr->msg_list.regnot_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //QualificationInformationCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_QUALCODE,4),1,&ptr->qualcode,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:QUALCODE absent!!"); + return 0; + } + + if((flag & BIT4_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,5),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT5_TRUE)>0) //Availability Type + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AVTYP,6),1,&ptr->avtyp,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //BorderCellAccess + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BORDACC,7),1,&ptr->bordacc,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //ControlChannelData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCDATA,8),4,ptr->ccdata,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //ExtendedMSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_EXTMSCID,9),4,ptr->extmscid,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //LocationAreaID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,10),2,ptr->locid,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //pcssn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,11),5,ptr->pcssn,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //ReceivedSignalQuality + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSIGQUAL,12),1,&ptr->rsigqual,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //rpttyp + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RPTTYP,13),1,&ptr->rpttyp,0x80,&asn_buf); + + if((flag & BIT13_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,14),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT14_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSADDR,15),ptr->smsaddrLen & MAX_IS41_VARPAR_LEN_1,ptr->smsaddr,0x80,&asn_buf); + + if((flag & BIT15_TRUE)>0) //smsmwi + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSMWI,16),0,&ptr->smsmwi,0x80,&asn_buf); + + if((flag & BIT16_TRUE)>0) //sysaccdata + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCDATA,16),5,ptr->sysaccdata,0x80,&asn_buf); + + if((flag & BIT17_TRUE)>0) //sysacctype + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCTYPE,17),1,&ptr->sysacctype,0x80,&asn_buf); + + if((flag & BIT18_TRUE)>0) //syscap + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSCAP,18),1,&ptr->syscap,0x80,&asn_buf); + + if((flag & BIT19_TRUE)>0) //termtyp + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTYP,19),1,&ptr->termtyp,0x80,&asn_buf); + + if((flag & BIT20_TRUE)>0) //transcap + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,20),ptr->transcapLen & MAX_IS41_VARPAR_LEN_1,ptr->transcap,0x80,&asn_buf); + + if((flag & BIT21_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + if (!(flag1 & 0x03)) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:wincap no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_WINCAP,21),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_TRIGCAP); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->triggercapLen & MAX_IS41_VARPAR_LEN_1,ptr1->triggercap,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_WINOPRCAP); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->winoprcapLen & MAX_IS41_VARPAR_LEN_1,ptr1->winoprcap,0x80,&asn_buf); + } + } + + return buf_len; +} + +int decode_param_profile(IS41_PAR_PROFILE *ptr,ASN_BUF *asn_buf) +{ + int len,i,count; + char tag[64]; + IS41_PAR_TRIGGER_LIST *ptr1; + + ptr->param_flag = 0; + + len = decode_Is41Parameter(IS41PAR_AUTHCAP,MAX_IS41_VARPAR_LEN,ptr->authcap,asn_buf); + if (len > 0) + { + ptr->authcapLen = len; + ptr->param_flag |= BIT0_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_CFI,MAX_IS41_VARPAR_LEN,ptr->cfi,asn_buf); + if (len > 0) + { + ptr->cfiLen = len; + ptr->param_flag |= BIT1_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_CARDGTS,MAX_IS41_VARPAR_LEN,ptr->cardgts,asn_buf); + if (len > 0) + { + ptr->cardgtsLen = len; + ptr->param_flag |= BIT2_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_ACDGTS,MAX_IS41_VARPAR_LEN,ptr->acdgts,asn_buf); + if (len > 0) + { + ptr->acdgtsLen = len; + ptr->param_flag |= BIT3_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_ABDGTS,MAX_IS41_VARPAR_LEN,ptr->abdgts,asn_buf); + if (len > 0) + { + ptr->abdgtsLen = len; + ptr->param_flag |= BIT4_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_BILLDGTS,MAX_IS41_VARPAR_LEN,ptr->billdgts,asn_buf); + if (len > 0) + { + ptr->billdgtsLen = len; + ptr->param_flag |= BIT5_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_GEOAUTH,MAX_IS41_VARPAR_LEN,ptr->geoauth,asn_buf); + if (len > 0) + { + ptr->geoauthLen = len; + ptr->param_flag |= BIT6_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_MWNCOUNT,MAX_IS41_VARPAR_LEN,ptr->mwncount,asn_buf); + if (len > 0) + { + ptr->mwncountLen = len; + ptr->param_flag |= BIT7_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_MWNCOUNT,MAX_IS41_VARPAR_LEN,ptr->mwncount,asn_buf); + if (len > 0) + { + ptr->mwncountLen = len; + ptr->param_flag |= BIT8_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,asn_buf); + if (len > 0) + { + ptr->mdnLen = len; + ptr->param_flag |= BIT9_TRUE; + } + + if (decode_Is41Parameter(IS41PAR_ORIGIND,1,&ptr->origind,asn_buf)) + ptr->param_flag |= BIT10_TRUE; + + len = decode_Is41Parameter(IS41PAR_ORIGTRIG,MAX_IS41_VARPAR_LEN,ptr->origtrig,asn_buf); + if (len > 0) + { + ptr->origtrigLen = len; + ptr->param_flag |= BIT11_TRUE; + } + + if (decode_Is41Parameter(IS41PAR_PACAIND,1,&ptr->pacaind,asn_buf)) + ptr->param_flag |= BIT12_TRUE; + + if (decode_Is41Parameter(IS41PAR_PLIND,1,&ptr->plind,asn_buf)) + ptr->param_flag |= BIT13_TRUE; + + len = decode_Is41Parameter(IS41PAR_RESDGTS,MAX_IS41_VARPAR_LEN,ptr->resdgts,asn_buf); + if (len > 0) + { + ptr->resdgtsLen = len; + ptr->param_flag |= BIT14_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_ROUTDGTS,MAX_IS41_VARPAR_LEN,ptr->routdgts,asn_buf); + if (len > 0) + { + ptr->routdgtsLen = len; + ptr->param_flag |= BIT15_TRUE; + } + + if (decode_Is41Parameter(IS41PAR_SMSORGRES,1,&ptr->smsorgres,asn_buf)) + ptr->param_flag |= BIT16_TRUE; + + if (decode_Is41Parameter(IS41PAR_SMSTERMRES,1,&ptr->smstermres,asn_buf)) + ptr->param_flag |= BIT17_TRUE; + + len = decode_Is41Parameter(IS41PAR_SPINIPIN,MAX_IS41_VARPAR_LEN,ptr->spinipin,asn_buf); + if (len > 0) + { + ptr->spinipinLen = len; + ptr->param_flag |= BIT18_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_SPINITRIG,MAX_IS41_VARPAR_LEN,ptr->spinitrig,asn_buf); + if (len > 0) + { + ptr->spinitrigLen = len; + ptr->param_flag |= BIT19_TRUE; + } + + if (decode_Is41Parameter(IS41PAR_TERMRES,1,&ptr->termres,asn_buf)) + ptr->param_flag |= BIT20_TRUE; + + len = decode_Is41Parameter(IS41PAR_TERMTRIG,MAX_IS41_VARPAR_LEN,ptr->termtrig,asn_buf); + if (len > 0) + { + ptr->termtrigLen = len; + ptr->param_flag |= BIT21_TRUE; + } + + ptr->triggerlistnum = 0; + for (i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++) + { + ptr1 = &ptr->triggerlist[i]; + count = 0; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->destaddr,asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT0_TRUE; + ptr1->destaddrLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + if (get_null(tag,asn_buf)) + { + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->wintriglist,asn_buf); + if (len >= 0) + { + ptr1->param_flag |= BIT1_TRUE; + ptr1->wintriglistLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + } + if (count == 2) + { + ptr->triggerlistnum++; + ptr->param_flag |= BIT22_TRUE; + } + else if (count == 1) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + else if (!count) + break; + } + + if (ptr->param_flag>0) + return 1; + return 0; +} + +int encode_param_profile(struct IS41_PAR_PROFILE *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len) +{ + u32 flag1; + struct IS41_PAR_TRIGGER_LIST *ptr1; + u8 i,triglistnum; + char tag[64]; + + if((flag & BIT0_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHCAP,1),ptr->authcapLen & MAX_IS41_VARPAR_LEN_1,ptr->authcap,0x80,asn_buf); + if((flag & BIT1_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_CFI,2),ptr->cfiLen & MAX_IS41_VARPAR_LEN_1,ptr->cfi,0x80,asn_buf); + if((flag & BIT2_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,3),ptr->cardgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->cardgts,0x80,asn_buf); + if((flag & BIT3_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,4),ptr->acdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->acdgts,0x80,asn_buf); + if((flag & BIT4_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,5),ptr->abdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->abdgts,0x80,asn_buf); + if((flag & BIT5_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,6),ptr->billdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->billdgts,0x80,asn_buf); + if((flag & BIT6_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_GEOAUTH,7),ptr->geoauthLen & MAX_IS41_VARPAR_LEN_1,ptr->geoauth,0x80,asn_buf); + if((flag & BIT7_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_MWNCOUNT,8),ptr->mwncountLen & MAX_IS41_VARPAR_LEN_1,ptr->mwncount,0x80,asn_buf); + if((flag & BIT8_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_MWNTYPE,9),ptr->mwntypeLen & MAX_IS41_VARPAR_LEN_1,ptr->mwntype,0x80,asn_buf); + if((flag & BIT9_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,10),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,asn_buf); + if((flag & BIT10_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_ORIGIND,11),1,&ptr->origind,0x80,asn_buf); + if((flag & BIT11_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_ORIGTRIG,12),ptr->origtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->origtrig,0x80,asn_buf); + if((flag & BIT12_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_PACAIND,13),1,&ptr->pacaind,0x80,asn_buf); + if((flag & BIT13_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,14),1,&ptr->plind,0x80,asn_buf); + if((flag & BIT14_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESDGTS,15),ptr->resdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->resdgts,0x80,asn_buf); + if((flag & BIT15_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,16),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,asn_buf); + if((flag & BIT16_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSORGRES,17),1,&ptr->smsorgres,0x80,asn_buf); + if((flag & BIT17_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTERMRES,18),1,&ptr->smstermres,0x80,asn_buf); + if((flag & BIT18_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_SPINIPIN,19),ptr->spinipinLen & MAX_IS41_VARPAR_LEN_1,ptr->spinipin,0x80,asn_buf); + if((flag & BIT19_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_SPINITRIG,20),ptr->spinitrigLen & MAX_IS41_VARPAR_LEN_1,ptr->spinitrig,0x80,asn_buf); + if((flag & BIT20_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMRES,21),1,&ptr->termres,0x80,asn_buf); + if((flag & BIT21_TRUE)>0) + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,22),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,asn_buf); + + if((flag & BIT22_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + if (!triglistnum) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!"); + return 0; + } + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGADRLIST,23),0,NULL,0xA0,asn_buf); + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + if ((flag1 & 0x03) != 0x03) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + sprintf(tag,"%s.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST); + *buf_len = AddTLV(is41_sequenceTag(tag,i+1),0,NULL,0xA0,asn_buf); + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_GLOBALTITLE); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->destaddrLen & MAX_IS41_VARPAR_LEN_1,ptr1->destaddr,0x80,asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_WINTRIGLIST); + *buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->wintriglistLen & MAX_IS41_VARPAR_LEN_1,ptr1->wintriglist,0x80,asn_buf); + } + } + } + + return 1; +} + +int encode_param_isterm(struct IS41_PAR_ISTERM *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len) +{ + char tag[64]; + + if((flag & BIT0_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_DESTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->destdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->destdgts,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:DestinationDigits absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //MSCID + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MSCID); + *buf_len = AddTLV(is41_sequenceTag(tag,2),3,ptr->mscid,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT2_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ACCDEN); + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->accden,0x80,asn_buf); + } + if((flag & BIT3_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_CARDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->cardgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->cardgts,0x80,asn_buf); + } + if((flag & BIT4_TRUE)>0) //esn + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ESN); + *buf_len = AddTLV(is41_sequenceTag(tag,5),ESN_LEN,ptr->esn,0x80,asn_buf); + } + if((flag & BIT5_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_LEGINFO); + *buf_len = AddTLV(is41_sequenceTag(tag,6),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,asn_buf); + } + if((flag & BIT6_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MDN); + *buf_len = AddTLV(is41_sequenceTag(tag,7),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,asn_buf); + } + if((flag & BIT7_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MSCIN); + *buf_len = AddTLV(is41_sequenceTag(tag,8),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,asn_buf); + } + if((flag & BIT8_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ROUTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,9),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,asn_buf); + } + if((flag & BIT9_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_TERMTRIG); + *buf_len = AddTLV(is41_sequenceTag(tag,10),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,asn_buf); + } + return 1; +} + +int encode_param_locterm(struct IS41_PAR_LOCTERM *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len) +{ + char tag[64]; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ESN); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ESN_LEN,ptr->esn,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_MIN); + *buf_len = AddTLV(is41_sequenceTag(tag,2),MIN_LEN,ptr->min,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + if((flag & BIT2_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_TERMTRMT); + *buf_len = AddTLV(is41_sequenceTag(tag,3),ptr->termtrmtLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrmt,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:termtrmt absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT3_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ALRTCODE); + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->alrtcodeLen & MAX_IS41_VARPAR_LEN_1,ptr->alrtcode,0x80,asn_buf); + } + if((flag & BIT4_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_CARDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,5),ptr->cardgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->cardgts,0x80,asn_buf); + } + if((flag & BIT5_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_DESTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,6),ptr->destdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->destdgts,0x80,asn_buf); + } + if((flag & BIT6_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_LEGINFO); + *buf_len = AddTLV(is41_sequenceTag(tag,7),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,asn_buf); + } + if((flag & BIT7_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_MDN); + *buf_len = AddTLV(is41_sequenceTag(tag,8),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,asn_buf); + } + if((flag & BIT8_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_OTFI); + *buf_len = AddTLV(is41_sequenceTag(tag,9),ptr->otfiLen & MAX_IS41_VARPAR_LEN_1,ptr->otfi,0x80,asn_buf); + } + if((flag & BIT9_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ROUTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,10),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,asn_buf); + } + if((flag & BIT10_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_TERMTRIG); + *buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,11),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,asn_buf); + } + if((flag & BIT11_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_VMSPIN); + *buf_len = AddTLV(is41_sequenceTag(tag,12),ptr->vmspinLen & MAX_IS41_VARPAR_LEN_1,ptr->vmspin,0x80,asn_buf); + } + if((flag & BIT12_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_VMBOX); + *buf_len = AddTLV(is41_sequenceTag(tag,13),ptr->vmboxLen & MAX_IS41_VARPAR_LEN_1,ptr->vmbox,0x80,asn_buf); + } + return 1; +} + +int encode_param_pstnterm(struct IS41_PAR_PSTNTERM *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len) +{ + char tag[64]; + + if((flag & BIT0_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_DESTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->destdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->destdgts,0x80,asn_buf); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:DestinationDigits absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT1_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_CARDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,2),ptr->cardgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->cardgts,0x80,asn_buf); + } + + if((flag & BIT2_TRUE)>0) //esn + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_ESN); + *buf_len = AddTLV(is41_sequenceTag(tag,3),ESN_LEN,ptr->esn,0x80,asn_buf); + } + if((flag & BIT3_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_LEGINFO); + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,asn_buf); + } + + if((flag & BIT4_TRUE)>0) //min + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_MIN); + *buf_len = AddTLV(is41_sequenceTag(tag,5),MIN_LEN,ptr->min,0x80,asn_buf); + } + if((flag & BIT5_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_ROUTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,6),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,asn_buf); + } + if((flag & BIT6_TRUE)>0) + { + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_TERMTRIG); + *buf_len = AddTLV(is41_sequenceTag(tag,7),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,asn_buf); + } + + return 1; +} + +int encode_param_termlist(struct IS41_PAR_TERMLIST *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len) +{ + if ((flag & BIT0_TRUE) > 0) + { + if (!encode_param_isterm(&ptr->isterm,ptr->isterm.param_flag,asn_buf,buf_len)) + return 0; + } + + if ((flag & BIT1_TRUE) > 0) + { + if (!encode_param_locterm(&ptr->locterm,ptr->locterm.param_flag,asn_buf,buf_len)) + return 0; + } + + if ((flag & BIT2_TRUE) > 0) + { + if (!encode_param_pstnterm(&ptr->pstnterm,ptr->pstnterm.param_flag,asn_buf,buf_len)) + return 0; + } + + return 1; +} + +int decode_param_isterm(IS41_PAR_ISTERM *ptr,ASN_BUF *asn_buf) +{ + int len; + char tag[64]; + + ptr->param_flag = 0; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_DESTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->destdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT0_TRUE; + ptr->destdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:DestinationDigits absent!"); + return 0; + } + + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MSCID); + if (decode_Is41Parameter(tag,3,ptr->mscid,asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + +//optional + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ACCDEN); + if (decode_Is41Parameter(tag,1,&ptr->accden,asn_buf)) + ptr->param_flag |= BIT2_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_BILLID); + if (decode_Is41Parameter(tag,7,ptr->billid,asn_buf)) + ptr->param_flag |= BIT3_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_CARDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->cardgts,asn_buf); + if (len > 0) + { + ptr->cardgtsLen = len; + ptr->param_flag |= BIT4_TRUE; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ESN); + if (decode_Is41Parameter(tag,ESN_LEN,ptr->esn,asn_buf)) + ptr->param_flag |= BIT5_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_LEGINFO); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->leginfo,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MDN); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->mdn,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->mdnLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MIN); + if (decode_Is41Parameter(tag,MIN_LEN,ptr->min,asn_buf)) + ptr->param_flag |= BIT8_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_MSCIN); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->mscin,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_ROUTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->routdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->routdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_ISTERM,IS41PAR_TERMTRIG); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->termtrig,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (ptr->param_flag>0) + return 1; + return 0; +} + +int decode_param_locterm(IS41_PAR_LOCTERM *ptr,ASN_BUF *asn_buf) +{ + int len; + char tag[64]; + + ptr->param_flag = 0; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ESN); + if (decode_Is41Parameter(tag,ESN_LEN,ptr->esn,asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_MIN); + if (decode_Is41Parameter(tag,MIN_LEN,ptr->min,asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_TERMTRMT); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->termtrmt,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->termtrmtLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:termtrmt absent!"); + return 0; + } + +//optional + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ALRTCODE); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->alrtcode,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->alrtcodeLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_CARDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->cardgts,asn_buf); + if (len > 0) + { + ptr->cardgtsLen = len; + ptr->param_flag |= BIT4_TRUE; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_DESTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->destdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->destdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_LEGINFO); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->leginfo,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_MDN); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->mdn,asn_buf); + if (len > 0) + { + ptr->mdnLen = len; + ptr->param_flag |= BIT7_TRUE; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_OTFI); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->otfi,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->otfiLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_ROUTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->routdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->routdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_TERMTRIG); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->termtrig,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_VMSPIN); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->vmspin,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->vmspinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_LOCTERM,IS41PAR_VMBOX); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->vmbox,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->vmboxLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (ptr->param_flag>0) + return 1; + return 0; +} + +int decode_param_pstnterm(IS41_PAR_PSTNTERM *ptr,ASN_BUF *asn_buf) +{ + int len; + char tag[64]; + + ptr->param_flag = 0; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_DESTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->destdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT0_TRUE; + ptr->destdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:DestinationDigits absent!"); + return 0; + } + +//optional + + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_CARDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->cardgts,asn_buf); + if (len > 0) + { + ptr->cardgtsLen = len; + ptr->param_flag |= BIT1_TRUE; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_ESN); + if (decode_Is41Parameter(tag,ESN_LEN,ptr->esn,asn_buf)) + ptr->param_flag |= BIT2_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_LEGINFO); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->leginfo,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_MIN); + if (decode_Is41Parameter(tag,MIN_LEN,ptr->min,asn_buf)) + ptr->param_flag |= BIT4_TRUE; + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_ROUTDGTS); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->routdgts,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->routdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + sprintf(tag,"%s.%s.%s",IS41PAR_TERMLIST,IS41PAR_PSTNTERM,IS41PAR_TERMTRIG); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->termtrig,asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (ptr->param_flag>0) + return 1; + return 0; +} + +int decode_param_termlist(IS41_PAR_TERMLIST *ptr,ASN_BUF *asn_buf) +{ + u8 count=0; + + ptr->param_flag = 0; + + if (decode_param_isterm(&ptr->isterm,asn_buf) > 0) + ptr->param_flag |= BIT0_TRUE; + else + count ++; + + if (decode_param_locterm(&ptr->locterm,asn_buf) > 0) + ptr->param_flag |= BIT1_TRUE; + else + count ++; + + if (decode_param_pstnterm(&ptr->pstnterm,asn_buf) > 0) + ptr->param_flag |= BIT2_TRUE; + else + count ++; + + if (count > 0) + return 1; + return 0; +} + + +int assign_is41RegistrationNotification_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + u32 flag; + ASN_BUF asn_buf; + int buf_len=0; + struct IS41_REGNOT_RSP *ptr; + + ptr = &opr_ptr->msg_list.regnot_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,1),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT1_TRUE)>0) //AuthorizationDenied + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHDEN,2),1,&ptr->authden,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //AuthorizationPeriod + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHPER,3),2,ptr->authper,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //ControlChannelData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCDATA,4),4,ptr->ccdata,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //DeniedAuthorizationPeriod + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENAUTHPER,5),ptr->denauthperLen & MAX_IS41_VARPAR_LEN_1,ptr->denauthper,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //Digits carrier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,6),ptr->digitsCarrierLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsCarrier,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //Digits Destination + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,7),ptr->digitsDestLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsDest,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,8),3,ptr->mscid,0x80,&asn_buf); + +/* Profile **macro** */ + if ((flag & BIT8_TRUE) > 0) + { + if (!encode_param_profile(&ptr->profile,ptr->profile.param_flag,&asn_buf,&buf_len)) + return 0; + } +/* Profile **macro** */ + + if((flag & BIT9_TRUE)>0) //ReceivedSignalQuality + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSIGQUAL,9),1,&ptr->rsigqual,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,10),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //smsmwi + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSMWI,11),0,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //sysaccdata + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCDATA,12),5,ptr->sysaccdata,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41RegistrationNotification_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_REGNOT_ARG *ptr; + int len; + char tag[64]; + + ptr = &opr_ptr->msg_list.regnot_arg; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_QUALCODE,1,&ptr->qualcode,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:QUALCODE absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_AVTYP,1,&ptr->avtyp,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter(IS41PAR_BORDACC,1,&ptr->bordacc,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter(IS41PAR_CCDATA,4,ptr->ccdata,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter(IS41PAR_EXTMSCID,4,ptr->extmscid,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if (decode_Is41Parameter(IS41PAR_LOCID,2,ptr->locid,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if (decode_Is41Parameter(IS41PAR_RSIGQUAL,1,&ptr->rsigqual,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if (decode_Is41Parameter(IS41PAR_RPTTYP,1,&ptr->rpttyp,&asn_buf)) + ptr->param_flag |= BIT12_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT13_TRUE; + } + len = decode_Is41Parameter(IS41PAR_SMSADDR,MAX_IS41_VARPAR_LEN,ptr->smsaddr,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT14_TRUE; + ptr->smsaddrLen = len & MAX_IS41_VARPAR_LEN_1; + } + + //smsmwi + + if (decode_Is41Parameter(IS41PAR_SYSACCDATA,5,ptr->sysaccdata,&asn_buf)) + ptr->param_flag |= BIT16_TRUE; + if (decode_Is41Parameter(IS41PAR_SYSACCTYPE,1,&ptr->sysacctype,&asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if (decode_Is41Parameter(IS41PAR_SYSCAP,1,&ptr->syscap,&asn_buf)) + ptr->param_flag |= BIT18_TRUE; + if (decode_Is41Parameter(IS41PAR_TERMTYP,1,&ptr->termtyp,&asn_buf)) + ptr->param_flag |= BIT19_TRUE; + len = decode_Is41Parameter(IS41PAR_TRANSCAP,MAX_IS41_VARPAR_LEN,ptr->transcap,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT20_TRUE; + ptr->transcapLen = len & MAX_IS41_VARPAR_LEN_1; + } + + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_TRIGCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.triggercap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT0_TRUE; + ptr->wincap.triggercapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT21_TRUE; + } + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_WINOPRCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.winoprcap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT1_TRUE; + ptr->wincap.winoprcapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT21_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int extract_is41RegistrationNotification_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_REGNOT_RSP *ptr; + int len; + + ptr = &opr_ptr->msg_list.regnot_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + + if(AsnDecode(buf,buf_len,43,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_AUTHDEN,1,&ptr->authden,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHPER,2,ptr->authper,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_CCDATA,4,ptr->ccdata,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + len = decode_Is41Parameter(IS41PAR_DENAUTHPER,MAX_IS41_VARPAR_LEN,ptr->denauthper,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->denauthperLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsCarrier,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->digitsCarrierLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsDest,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->digitsDestLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + +/* Profile **macro** */ + if (decode_param_profile(&ptr->profile,&asn_buf) > 0) + ptr->param_flag |= BIT8_TRUE; +/* Profile **macro** */ + + + if (decode_Is41Parameter(IS41PAR_RSIGQUAL,1,&ptr->rsigqual,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT10_TRUE; + } + + //smsmwi + + if (decode_Is41Parameter(IS41PAR_SYSACCDATA,5,ptr->sysaccdata,&asn_buf)) + ptr->param_flag |= BIT12_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41RegistrationCancellation_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_REGCANC_ARG *ptr; + + ptr = &opr_ptr->msg_list.regcanc_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT2_TRUE)>0) //Cancellation Type + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CANTP,3),ptr->canctyplen & 3,ptr->canctyp,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //ControlChannelData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCDATA,4),4,ptr->ccdata,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //ReceivedSignalQuality + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSIGQUAL,5),1,&ptr->rsigqual,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,6),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //sysaccdata + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCDATA,7),5,ptr->sysaccdata,0x80,&asn_buf); + + return buf_len; +} + +int assign_is41RegistrationCancellation_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + u32 flag; + ASN_BUF asn_buf; + int buf_len=0; + struct IS41_REGCANC_RSP *ptr; + + ptr = &opr_ptr->msg_list.regcanc_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +// optional part---> + if((flag & BIT0_TRUE)>0) //CallHistoryCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,3),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //CancellationDenied + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CANCD,3),1,&ptr->cancdenied,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //ControlChannelData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCDATA,4),4,ptr->ccdata,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //ReceivedSignalQuality + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSIGQUAL,5),1,&ptr->rsigqual,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //smsmwi + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSMWI,16),0,&ptr->smsmwi,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //sysaccdata + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SYSACCDATA,7),5,ptr->sysaccdata,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41RegistrationCancellation_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_REGCANC_ARG *ptr; + int len; + + ptr = &opr_ptr->msg_list.regcanc_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_CANTP,4,ptr->canctyp,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter(IS41PAR_CCDATA,4,ptr->ccdata,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter(IS41PAR_RSIGQUAL,1,&ptr->rsigqual,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT5_TRUE; + } + if (decode_Is41Parameter(IS41PAR_SYSACCDATA,5,ptr->sysaccdata,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int extract_is41RegistrationCancellation_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_REGCANC_RSP *ptr; + + ptr = &opr_ptr->msg_list.regcanc_rsp; + + if(AsnDecode(buf,buf_len,43,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + +//optional par---> + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if (decode_Is41Parameter(IS41PAR_CANCD,2,&ptr->cancdenied,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if (decode_Is41Parameter(IS41PAR_CCDATA,4,ptr->ccdata,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + + if (decode_Is41Parameter(IS41PAR_RSIGQUAL,1,&ptr->rsigqual,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + if (decode_Is41Parameter(IS41PAR_SMSMWI,0,ptr->sysaccdata,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + + if (decode_Is41Parameter(IS41PAR_SYSACCDATA,5,ptr->sysaccdata,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41LocationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + struct IS41_LOCREQ_ARG *ptr; + struct IS41_PAR_WIN_CAP *ptr1; + char tag[64]; + + ptr = &opr_ptr->msg_list.locreq_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1),7,ptr->billid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:BILLID absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,2),ptr->digitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:Digits absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,4),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,5),ptr->cpndgts1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts1,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,6),ptr->cpndgts2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts2,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,7),ptr->cpsubLen & MAX_IS41_VARPAR_LEN_1,ptr->cpsub,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,8),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,9),5,ptr->pcssn,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,10),ptr->rndgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->rndgts,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,11),ptr->rsubLen & MAX_IS41_VARPAR_LEN_1,ptr->rsub,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,12),1,&ptr->tat,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,13),ptr->transcapLen & MAX_IS41_VARPAR_LEN_1,ptr->transcap,0x80,&asn_buf); + + if((flag & BIT13_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + if (!(flag1 & 0x03)) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:wincap no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_WINCAP,14),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_TRIGCAP); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->triggercapLen & MAX_IS41_VARPAR_LEN_1,ptr1->triggercap,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_WINOPRCAP); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->winoprcapLen & MAX_IS41_VARPAR_LEN_1,ptr1->winoprcap,0x80,&asn_buf); + } + } + + return buf_len; +} + +int extract_is41LocationRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_LOCREQ_ARG *ptr; + int len; + char tag[64]; + + ptr = &opr_ptr->msg_list.locreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,17,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:BILLID absent!"); + return 0; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->digitsLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:Digits absent!!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + +//optional par---> + len = decode_Is41Parameter(IS41PAR_CPNDGTS1,MAX_IS41_VARPAR_LEN,ptr->cpndgts1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->cpndgts1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNDGTS2,MAX_IS41_VARPAR_LEN,ptr->cpndgts2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->cpndgts2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPSUB,MAX_IS41_VARPAR_LEN,ptr->cpsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + + len = decode_Is41Parameter(IS41PAR_RNDGTS,MAX_IS41_VARPAR_LEN,ptr->rndgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->rndgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RSUB,MAX_IS41_VARPAR_LEN,ptr->rsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->rsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_TAT,1,&ptr->tat,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + + len = decode_Is41Parameter(IS41PAR_TRANSCAP,MAX_IS41_VARPAR_LEN,ptr->transcap,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->transcapLen = len & MAX_IS41_VARPAR_LEN_1; + } + + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_TRIGCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.triggercap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT0_TRUE; + ptr->wincap.triggercapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT13_TRUE; + } + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_WINOPRCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.winoprcap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT1_TRUE; + ptr->wincap.winoprcapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT14_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41LocationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + struct IS41_LOCREQ_RSP *ptr; + struct IS41_PAR_TRIGGER_LIST *ptr1; + u8 i,triglistnum; + char tag[64]; + + ptr = &opr_ptr->msg_list.locreq_rsp; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,4),1,&ptr->accden,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,5),ptr->annlistLen & MAX_IS41_VARPAR_LEN_1,ptr->annlist,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG1,6),ptr->cpnstrg1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg1,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG2,7),ptr->cpnstrg2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg2,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8),ptr->digitsCarrierLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsCarrier,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,9),ptr->digitsDestLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsDest,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,10),ptr->acdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->acdgts,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,11),ptr->abdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->abdgts,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,12),ptr->billdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->billdgts,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,13),ptr->redindLen & MAX_IS41_VARPAR_LEN_1,ptr->redind,0x80,&asn_buf); + + if((flag & BIT13_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,14),ptr->grpinfoLen & MAX_IS41_VARPAR_LEN_1,ptr->grpinfo,0x80,&asn_buf); + +// if((flag & BIT11_TRUE)>0) + // buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,12),1,&ptr->tat,0x80,&asn_buf); + + if((flag & BIT14_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,15),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,&asn_buf); + + if((flag & BIT15_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,16),ptr->natimeLen & MAX_IS41_VARPAR_LEN_1,ptr->natime,0x80,&asn_buf); + + if((flag & BIT16_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,17),ptr->otfiLen & MAX_IS41_VARPAR_LEN_1,ptr->otfi,0x80,&asn_buf); + + if((flag & BIT17_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,18),5,ptr->pcssn,0x80,&asn_buf); + + if((flag & BIT18_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,19),ptr->rndgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->rndgts,0x80,&asn_buf); + + if((flag & BIT19_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,20),ptr->rnstringLen & MAX_IS41_VARPAR_LEN_1,ptr->rnstring,0x80,&asn_buf); + + if((flag & BIT20_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,21),ptr->rsubLen & MAX_IS41_VARPAR_LEN_1,ptr->rsub,0x80,&asn_buf); + + if((flag & BIT21_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,22),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,&asn_buf); + + if ((flag & BIT22_TRUE) > 0) + { + if (!encode_param_termlist(&ptr->termlist,ptr->termlist.param_flag,&asn_buf,&buf_len)) + return 0; + } + + if((flag & BIT23_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,24),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,&asn_buf); + + if((flag & BIT24_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + if (!triglistnum) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGADRLIST,25),0,NULL,0xA0,&asn_buf); + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + if ((flag1 & 0x03) != 0x03) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + sprintf(tag,"%s.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,i+1),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_GLOBALTITLE); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->destaddrLen & MAX_IS41_VARPAR_LEN_1,ptr1->destaddr,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_WINTRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->wintriglistLen & MAX_IS41_VARPAR_LEN_1,ptr1->wintriglist,0x80,&asn_buf); + } + } + } + + return buf_len; +} + +int extract_is41LocationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_LOCREQ_RSP *ptr; + IS41_PAR_TRIGGER_LIST *ptr1; + int len,i,count; + char tag[64]; + + ptr = &opr_ptr->msg_list.locreq_rsp; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,33,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ACCDEN,1,&ptr->accden,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + len = decode_Is41Parameter(IS41PAR_ANNLIST,MAX_IS41_VARPAR_LEN,ptr->annlist,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->annlistLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG1,MAX_IS41_VARPAR_LEN,ptr->cpnstrg1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->cpnstrg1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG2,MAX_IS41_VARPAR_LEN,ptr->cpnstrg2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpnstrg2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsCarrier,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->digitsCarrierLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsDest,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->digitsDestLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ACDGTS,MAX_IS41_VARPAR_LEN,ptr->acdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->acdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ABDGTS,MAX_IS41_VARPAR_LEN,ptr->abdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->abdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_BILLDGTS,MAX_IS41_VARPAR_LEN,ptr->billdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->billdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_REDIND,MAX_IS41_VARPAR_LEN,ptr->redind,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->redindLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_GRPINFO,MAX_IS41_VARPAR_LEN,ptr->grpinfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT13_TRUE; + ptr->grpinfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT14_TRUE; + ptr->mdnLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_NATIME,MAX_IS41_VARPAR_LEN,ptr->natime,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT15_TRUE; + ptr->natimeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_OTFI,MAX_IS41_VARPAR_LEN,ptr->otfi,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT16_TRUE; + ptr->otfiLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT17_TRUE; + + len = decode_Is41Parameter(IS41PAR_RNDGTS,MAX_IS41_VARPAR_LEN,ptr->rndgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT18_TRUE; + ptr->rndgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RNSTRING,MAX_IS41_VARPAR_LEN,ptr->rnstring,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT19_TRUE; + ptr->rnstringLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RSUB,MAX_IS41_VARPAR_LEN,ptr->rsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT20_TRUE; + ptr->rsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ROUTDGTS,MAX_IS41_VARPAR_LEN,ptr->routdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT21_TRUE; + ptr->routdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_param_termlist(&ptr->termlist,&asn_buf) > 0) + ptr->param_flag |= BIT22_TRUE; + + len = decode_Is41Parameter(IS41PAR_TERMTRIG,MAX_IS41_VARPAR_LEN,ptr->termtrig,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT23_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + ptr->triggerlistnum = 0; + for (i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++) + { + ptr1 = &ptr->triggerlist[i]; + count = 0; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->destaddr,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT0_TRUE; + ptr1->destaddrLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->wintriglist,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT1_TRUE; + ptr1->wintriglistLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + if (count == 2) + { + ptr->triggerlistnum++; + ptr->param_flag |= BIT24_TRUE; + } + else if (count == 1) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + else if (!count) + break; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41RoutingRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_ROUTREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.routreq_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1),7,ptr->billid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:BILLID absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT2_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,3),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,4),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + + if((flag & BIT4_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,5),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ALRTCODE,6),ptr->alrtcodeLen & MAX_IS41_VARPAR_LEN_1,ptr->alrtcode,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG1,7),ptr->cpnstrg1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg1,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG2,8),ptr->cpnstrg2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg2,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,9),ptr->cpsubLen & MAX_IS41_VARPAR_LEN_1,ptr->cpsub,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,10),ptr->destdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->destdgts,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,11),ptr->acdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->acdgts,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,12),ptr->abdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->abdgts,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,13),ptr->billdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->billdgts,0x80,&asn_buf); + + if((flag & BIT13_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LEGINFO,14),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,&asn_buf); + + if((flag & BIT14_TRUE)>0) //LocationAreaID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,15),2,ptr->locid,0x80,&asn_buf); + + if((flag & BIT15_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,16),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,&asn_buf); + + if((flag & BIT16_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,17),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + + if((flag & BIT17_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,18),ptr->natimeLen & MAX_IS41_VARPAR_LEN_1,ptr->natime,0x80,&asn_buf); + + if((flag & BIT18_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,19),ptr->otfiLen & MAX_IS41_VARPAR_LEN_1,ptr->otfi,0x80,&asn_buf); + + if((flag & BIT19_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,20),5,ptr->pcssn,0x80,&asn_buf); + + if((flag & BIT20_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOTBID,21),7,ptr->pilotbid,0x80,&asn_buf); + + if((flag & BIT21_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOT,22),ptr->pilotLen & MAX_IS41_VARPAR_LEN_1,ptr->pilot,0x80,&asn_buf); + + if((flag & BIT22_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,23),ptr->rnstringLen & MAX_IS41_VARPAR_LEN_1,ptr->rnstring,0x80,&asn_buf); + + if((flag & BIT23_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,24),ptr->rsubLen & MAX_IS41_VARPAR_LEN_1,ptr->rsub,0x80,&asn_buf); + + if((flag & BIT24_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,25),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT25_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRMT,26),ptr->termtrmtLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrmt,0x80,&asn_buf); + + if((flag & BIT26_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,27),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,&asn_buf); + + if((flag & BIT27_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_VMBOX,28),ptr->vmboxLen & MAX_IS41_VARPAR_LEN_1,ptr->vmbox,0x80,&asn_buf); + + if((flag & BIT28_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_VMSPIN,29),ptr->vmspinLen & MAX_IS41_VARPAR_LEN_1,ptr->vmspin,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41RoutingRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ROUTREQ_ARG *ptr; + int len; + + ptr = &opr_ptr->msg_list.routreq_arg; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,29,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:BILLID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + +//optional par---> + len = decode_Is41Parameter(IS41PAR_ALRTCODE,MAX_IS41_VARPAR_LEN,ptr->alrtcode,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->alrtcodeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG1,MAX_IS41_VARPAR_LEN,ptr->cpnstrg1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpnstrg1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG2,MAX_IS41_VARPAR_LEN,ptr->cpnstrg2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->cpnstrg2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPSUB,MAX_IS41_VARPAR_LEN,ptr->cpsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->cpsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DESTDGTS,MAX_IS41_VARPAR_LEN,ptr->destdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->destdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ACDGTS,MAX_IS41_VARPAR_LEN,ptr->acdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->acdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ABDGTS,MAX_IS41_VARPAR_LEN,ptr->abdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->abdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_BILLDGTS,MAX_IS41_VARPAR_LEN,ptr->billdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->billdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_LEGINFO,MAX_IS41_VARPAR_LEN,ptr->leginfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT13_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_LOCID,2,ptr->locid,&asn_buf)) + ptr->param_flag |= BIT14_TRUE; + + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT15_TRUE; + ptr->mdnLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT16_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_NATIME,MAX_IS41_VARPAR_LEN,ptr->natime,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT17_TRUE; + ptr->natimeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_OTFI,MAX_IS41_VARPAR_LEN,ptr->otfi,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT18_TRUE; + ptr->otfiLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT19_TRUE; + + if (decode_Is41Parameter(IS41PAR_PILOTBID,7,ptr->pilotbid,&asn_buf)) + ptr->param_flag |= BIT20_TRUE; + + len = decode_Is41Parameter(IS41PAR_PILOT,MAX_IS41_VARPAR_LEN,ptr->pilot,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT21_TRUE; + ptr->pilotLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RNSTRING,MAX_IS41_VARPAR_LEN,ptr->rnstring,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT22_TRUE; + ptr->rnstringLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RSUB,MAX_IS41_VARPAR_LEN,ptr->rsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT23_TRUE; + ptr->rsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT24_TRUE; + } + + len = decode_Is41Parameter(IS41PAR_TERMTRMT,MAX_IS41_VARPAR_LEN,ptr->termtrmt,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT25_TRUE; + ptr->termtrmtLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_TERMTRIG,MAX_IS41_VARPAR_LEN,ptr->termtrig,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT26_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_VMBOX,MAX_IS41_VARPAR_LEN,ptr->vmbox,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT27_TRUE; + ptr->vmboxLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_VMSPIN,MAX_IS41_VARPAR_LEN,ptr->vmspin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT28_TRUE; + ptr->vmspinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41RoutingRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_ROUTREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.routreq_rsp; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,1),3,ptr->mscid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MSCID absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT1_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,2),1,&ptr->accden,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,3),7,ptr->billid,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CDEN,4),1,&ptr->cden,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,5),ptr->digitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,6),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,7),5,ptr->pcssn,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41RoutingRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ROUTREQ_RSP *ptr; + int len; + + ptr = &opr_ptr->msg_list.routreq_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + + if(AsnDecode(buf,buf_len,7,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MSCID absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ACCDEN,1,&ptr->accden,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + + if (decode_Is41Parameter(IS41PAR_CDEN,1,&ptr->cden,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->digitsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41MSInactive_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_MSINACT_ARG *ptr; + + ptr = &opr_ptr->msg_list.msinact_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT2_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_COUNT,3),1,&ptr->count,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DEREG,4),1,&ptr->dereg,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //LocationAreaID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,5),2,ptr->locid,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,6),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41MSInactive_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_MSINACT_ARG *ptr; + u8 len; + + ptr = &opr_ptr->msg_list.msinact_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + + if(AsnDecode(buf,buf_len,6,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_COUNT,1,&ptr->count,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + + if (decode_Is41Parameter(IS41PAR_DEREG,1,&ptr->dereg,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + if (decode_Is41Parameter(IS41PAR_LOCID,2,ptr->locid,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT5_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41MSInactive_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_MSINACT_RSP *ptr; + + ptr = &opr_ptr->msg_list.msinact_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + return buf_len; +} + +int extract_is41MSInactive_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + struct IS41_MSINACT_RSP *ptr; + + ptr = &opr_ptr->msg_list.msinact_rsp; + ptr->param_flag = 0; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41QualificationDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_QUALDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.qualdir_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //QualificationInformationCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_QUALCODE,3),1,&ptr->qualcode,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:QUALCODE absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,4),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT4_TRUE)>0) //AuthorizationDenied + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHDEN,5),1,&ptr->authden,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //AuthorizationPeriod + buf_len = AddTLV(is41_sequenceTag(IS41PAR_AUTHPER,6),2,ptr->authper,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) //DeniedAuthorizationPeriod + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DENAUTHPER,7),ptr->denauthperLen & MAX_IS41_VARPAR_LEN_1,ptr->denauthper,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //Digits carrier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8),ptr->digitsCarrierLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsCarrier,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) //Digits Destination + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,9),ptr->digitsDestLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsDest,0x80,&asn_buf); + if((flag & BIT9_TRUE)>0) //LocationAreaID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,10),2,ptr->locid,0x80,&asn_buf); + +/* Profile **macro** */ + if ((flag & BIT10_TRUE) > 0) + { + if (!encode_param_profile(&ptr->profile,ptr->profile.param_flag,&asn_buf,&buf_len)) + return 0; + } +/* Profile **macro** */ + + if((flag & BIT11_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,11),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41QualificationDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_QUALDIR_ARG *ptr; + int len; + + ptr = &opr_ptr->msg_list.qualdir_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_QUALCODE,1,&ptr->qualcode,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:QUALCODE absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_AUTHDEN,1,&ptr->authden,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter(IS41PAR_AUTHPER,2,ptr->authper,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + len = decode_Is41Parameter(IS41PAR_DENAUTHPER,MAX_IS41_VARPAR_LEN,ptr->denauthper,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->denauthperLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsCarrier,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->digitsCarrierLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsDest,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->digitsDestLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_LOCID,2,ptr->locid,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + +/* Profile **macro** */ + if (decode_param_profile(&ptr->profile,&asn_buf) > 0) + ptr->param_flag |= BIT10_TRUE; +/* Profile **macro** */ + + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT11_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41QualificationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_QUALDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.qualdir_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + return buf_len; +} + +int extract_is41QualificationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + struct IS41_QUALDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.qualdir_rsp; + ptr->param_flag = 0; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41FeatureRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_FEATREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.featreq_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //Dialed Digits + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,1),ptr->digitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,3),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + +//optional + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,4),7,ptr->billid,0x80,&asn_buf); + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,5),ptr->cpndgts1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts1,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,6),ptr->cpndgts2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts2,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,7),ptr->cpsubLen & MAX_IS41_VARPAR_LEN_1,ptr->cpsub,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,8),ptr->cciLen & MAX_IS41_VARPAR_LEN_1,ptr->cci,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,9),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,10),3,ptr->mscid,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,11),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,12),ptr->otfiLen & MAX_IS41_VARPAR_LEN_1,ptr->otfi,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //pcssn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,13),5,ptr->pcssn,0x80,&asn_buf); + + if((flag & BIT13_TRUE)>0) //senderin + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,14),ptr->senderinLen & MAX_IS41_VARPAR_LEN_1,ptr->senderin,0x80,&asn_buf); + + if((flag & BIT14_TRUE)>0) //transcap + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,15),ptr->transcapLen & MAX_IS41_VARPAR_LEN_1,ptr->transcap,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41FeatureRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_FEATREQ_ARG *ptr; + int len; + + ptr = &opr_ptr->msg_list.featreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT0_TRUE; + ptr->digitsLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:Digits absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + +//optional + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + len = decode_Is41Parameter(IS41PAR_CPNDGTS1,MAX_IS41_VARPAR_LEN,ptr->cpndgts1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->cpndgts1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNDGTS2,MAX_IS41_VARPAR_LEN,ptr->cpndgts2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->cpndgts2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPSUB,MAX_IS41_VARPAR_LEN,ptr->cpsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_CCI,MAX_IS41_VARPAR_LEN,ptr->cci,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->cciLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,&asn_buf); + if (len > 0) + { + ptr->mdnLen = len; + ptr->param_flag |= BIT8_TRUE; + } + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_OTFI,MAX_IS41_VARPAR_LEN,ptr->otfi,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->otfiLen = len & MAX_IS41_VARPAR_LEN_1; + } + if (decode_Is41Parameter(IS41PAR_PCSSN,5,ptr->pcssn,&asn_buf)) + ptr->param_flag |= BIT12_TRUE; + len = decode_Is41Parameter(IS41PAR_SENDERIN,MAX_IS41_VARPAR_LEN,ptr->senderin,&asn_buf); + if (len > 0) + { + ptr->senderinLen = len; + ptr->param_flag |= BIT13_TRUE; + } + len = decode_Is41Parameter(IS41PAR_TRANSCAP,MAX_IS41_VARPAR_LEN,ptr->transcap,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT14_TRUE; + ptr->transcapLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41FeatureRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + u8 i,triglistnum; + IS41_PAR_TRIGGER_LIST *ptr1; + char tag[64]; + + struct IS41_FEATREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.featreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //feature result + buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATRESULT,1),1,&ptr->featresult,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:Feature result absent!!"); + return 0; + } + +//optional + if((flag & BIT1_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,2),1,&ptr->accden,0x80,&asn_buf); + if((flag & BIT2_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,3),ptr->actcodeLen & MAX_IS41_VARPAR_LEN_1,ptr->actcode,0x80,&asn_buf); + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,4),ptr->annlistLen & MAX_IS41_VARPAR_LEN_1,ptr->annlist,0x80,&asn_buf); + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,5),ptr->cpndgts1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts1,0x80,&asn_buf); + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,6),ptr->cpndgts2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpndgts2,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,7),ptr->cpsubLen & MAX_IS41_VARPAR_LEN_1,ptr->cpsub,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //Digits carrier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8),ptr->digitsCarrierLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsCarrier,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) //ConferenceCallingIndicator + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,9),ptr->cciLen & MAX_IS41_VARPAR_LEN_1,ptr->cci,0x80,&asn_buf); + if((flag & BIT9_TRUE)>0) //Digits carrier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,10),ptr->digitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); +/* if((flag & BIT10_TRUE)>0) //display text + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,11),ptr->disptextLen & MAX_IS41_VARPAR_LEN_1,ptr->disptext,0x80,&asn_buf);*/ + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,12),ptr->acdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->acdgts,0x80,&asn_buf); + if((flag & BIT12_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,13),ptr->abdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->abdgts,0x80,&asn_buf); + if((flag & BIT13_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,14),ptr->billdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->billdgts,0x80,&asn_buf); + if((flag & BIT14_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,15),ptr->redindLen & MAX_IS41_VARPAR_LEN_1,ptr->redind,0x80,&asn_buf); + if((flag & BIT15_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,16),ptr->grpinfoLen & MAX_IS41_VARPAR_LEN_1,ptr->grpinfo,0x80,&asn_buf); + if((flag & BIT16_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,17),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,&asn_buf); + if((flag & BIT17_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,18),ptr->natimeLen & MAX_IS41_VARPAR_LEN_1,ptr->natime,0x80,&asn_buf); + if((flag & BIT18_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,19),ptr->otfiLen & MAX_IS41_VARPAR_LEN_1,ptr->otfi,0x80,&asn_buf); + if((flag & BIT19_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PACAIND,20),1,&ptr->pacaind,0x80,&asn_buf); + if((flag & BIT20_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOT,21),ptr->pilotLen & MAX_IS41_VARPAR_LEN_1,ptr->pilot,0x80,&asn_buf); + if((flag & BIT21_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,22),ptr->rndgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->rndgts,0x80,&asn_buf); + if((flag & BIT22_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,23),ptr->rnstringLen & MAX_IS41_VARPAR_LEN_1,ptr->rnstring,0x80,&asn_buf); + if((flag & BIT23_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,24),ptr->rsubLen & MAX_IS41_VARPAR_LEN_1,ptr->rsub,0x80,&asn_buf); + if((flag & BIT24_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESUMEPIC,25),1,&ptr->resumepic,0x80,&asn_buf); + if((flag & BIT25_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,26),ptr->routdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->routdgts,0x80,&asn_buf); + if ((flag & BIT26_TRUE) > 0) + { + if (!encode_param_termlist(&ptr->termlist,ptr->termlist.param_flag,&asn_buf,&buf_len)) + return 0; + } + if((flag & BIT27_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,28),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,&asn_buf); + + if((flag & BIT28_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + if (!triglistnum) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGADRLIST,29),0,NULL,0xA0,&asn_buf); + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + if ((flag1 & 0x03) != 0x03) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + sprintf(tag,"%s.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,i+1),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_GLOBALTITLE); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->destaddrLen & MAX_IS41_VARPAR_LEN_1,ptr1->destaddr,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_WINTRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->wintriglistLen & MAX_IS41_VARPAR_LEN_1,ptr1->wintriglist,0x80,&asn_buf); + } + } + } + + return buf_len; +} + +int extract_is41FeatureRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_FEATREQ_RSP *ptr; + IS41_PAR_TRIGGER_LIST *ptr1; + int len,i,count; + char tag[64]; + + ptr = &opr_ptr->msg_list.featreq_rsp; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,33,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_FEATRESULT,1,&ptr->featresult,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ACCDEN,1,&ptr->accden,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + + len = decode_Is41Parameter(IS41PAR_ACTCODE,MAX_IS41_VARPAR_LEN,ptr->actcode,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->actcodeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ANNLIST,MAX_IS41_VARPAR_LEN,ptr->annlist,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->annlistLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNDGTS1,MAX_IS41_VARPAR_LEN,ptr->cpndgts1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->cpndgts1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNDGTS2,MAX_IS41_VARPAR_LEN,ptr->cpndgts2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->cpndgts2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPSUB,MAX_IS41_VARPAR_LEN,ptr->cpsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsCarrier,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->digitsCarrierLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CCI,MAX_IS41_VARPAR_LEN,ptr->cci,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->cciLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->digitsLen = len & MAX_IS41_VARPAR_LEN_1; + } + +/* len = decode_Is41Parameter(IS41PAR_DISPTEXT,MAX_IS41_VARPAR_LEN,ptr->disptext,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->disptextLen = len & MAX_IS41_VARPAR_LEN_1; + }*/ + + len = decode_Is41Parameter(IS41PAR_ACDGTS,MAX_IS41_VARPAR_LEN,ptr->acdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->acdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ABDGTS,MAX_IS41_VARPAR_LEN,ptr->abdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->abdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_BILLDGTS,MAX_IS41_VARPAR_LEN,ptr->billdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT13_TRUE; + ptr->billdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_REDIND,MAX_IS41_VARPAR_LEN,ptr->redind,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT14_TRUE; + ptr->redindLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_GRPINFO,MAX_IS41_VARPAR_LEN,ptr->grpinfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT15_TRUE; + ptr->grpinfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT16_TRUE; + ptr->mdnLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_NATIME,MAX_IS41_VARPAR_LEN,ptr->natime,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT17_TRUE; + ptr->natimeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_OTFI,MAX_IS41_VARPAR_LEN,ptr->otfi,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT18_TRUE; + ptr->otfiLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PACAIND,1,&ptr->pacaind,&asn_buf)) + ptr->param_flag |= BIT19_TRUE; + + len = decode_Is41Parameter(IS41PAR_PILOT,MAX_IS41_VARPAR_LEN,ptr->pilot,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT20_TRUE; + ptr->pilotLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RNDGTS,MAX_IS41_VARPAR_LEN,ptr->rndgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT21_TRUE; + ptr->rndgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RNSTRING,MAX_IS41_VARPAR_LEN,ptr->rnstring,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT22_TRUE; + ptr->rnstringLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RSUB,MAX_IS41_VARPAR_LEN,ptr->rsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT23_TRUE; + ptr->rsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_RESUMEPIC,1,&ptr->resumepic,&asn_buf)) + ptr->param_flag |= BIT24_TRUE; + + len = decode_Is41Parameter(IS41PAR_ROUTDGTS,MAX_IS41_VARPAR_LEN,ptr->routdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT25_TRUE; + ptr->routdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_param_termlist(&ptr->termlist,&asn_buf) > 0) + ptr->param_flag |= BIT26_TRUE; + + len = decode_Is41Parameter(IS41PAR_TERMTRIG,MAX_IS41_VARPAR_LEN,ptr->termtrig,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT27_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + ptr->triggerlistnum = 0; + for (i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++) + { + ptr1 = &ptr->triggerlist[i]; + count = 0; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->destaddr,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT0_TRUE; + ptr1->destaddrLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->wintriglist,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT1_TRUE; + ptr1->wintriglistLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + if (count == 2) + { + ptr->triggerlistnum++; + ptr->param_flag |= BIT28_TRUE; + } + else if (count == 1) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + else if (!count) + break; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + + +int assign_is41TransferToNumberRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + struct IS41_TRANUMREQ_ARG *ptr; + struct IS41_PAR_WIN_CAP *ptr1; + char tag[64]; + + ptr = &opr_ptr->msg_list.tranumreq_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //REDIRECTION REASON + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDREASON,3),1,&ptr->redreason,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:redreason absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //SystemMyTypeCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,4),1,&ptr->mytyp,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MYTYP absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,5),7,ptr->billid,0x80,&asn_buf); + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,6),ptr->grpinfoLen & MAX_IS41_VARPAR_LEN_1,ptr->grpinfo,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LEGINFO,7),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //MSCID + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,8),3,ptr->mscid,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,9),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + if((flag & BIT9_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOTBID,10),7,ptr->pilotbid,0x80,&asn_buf); + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOT,11),ptr->pilotLen & MAX_IS41_VARPAR_LEN_1,ptr->pilot,0x80,&asn_buf); + if((flag & BIT11_TRUE)>0) //transcap + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,12),ptr->transcapLen & MAX_IS41_VARPAR_LEN_1,ptr->transcap,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + if (!(flag1 & 0x03)) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:wincap no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_WINCAP,21),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_TRIGCAP); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->triggercapLen & MAX_IS41_VARPAR_LEN_1,ptr1->triggercap,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s",IS41PAR_WINCAP,IS41PAR_WINOPRCAP); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->winoprcapLen & MAX_IS41_VARPAR_LEN_1,ptr1->winoprcap,0x80,&asn_buf); + } + } + + return buf_len; +} + +int extract_is41TransferToNumberRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_TRANUMREQ_ARG *ptr; + int len; + char tag[64]; + + ptr = &opr_ptr->msg_list.tranumreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_REDREASON,1,&ptr->redreason,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:redreason absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MYTYP,1,&ptr->mytyp,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MYTYP absent!"); + return 0; + } + +//optional par---> + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + len = decode_Is41Parameter(IS41PAR_GRPINFO,MAX_IS41_VARPAR_LEN,ptr->grpinfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->grpinfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_LEGINFO,MAX_IS41_VARPAR_LEN,ptr->leginfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + if (decode_Is41Parameter(IS41PAR_MSCID,3,ptr->mscid,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + if (decode_Is41Parameter(IS41PAR_PILOTBID,7,ptr->pilotbid,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + + len = decode_Is41Parameter(IS41PAR_PILOT,MAX_IS41_VARPAR_LEN,ptr->pilot,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->pilotLen = len & MAX_IS41_VARPAR_LEN_1; + } + len = decode_Is41Parameter(IS41PAR_TRANSCAP,MAX_IS41_VARPAR_LEN,ptr->transcap,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->transcapLen = len & MAX_IS41_VARPAR_LEN_1; + } + + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_TRIGCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.triggercap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT0_TRUE; + ptr->wincap.triggercapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT12_TRUE; + } + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_WINOPRCAP); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr->wincap.winoprcap,&asn_buf); + if (len > 0) + { + ptr->wincap.param_flag |= BIT1_TRUE; + ptr->wincap.winoprcapLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT12_TRUE; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41TransferToNumberRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag,flag1; + u8 i,triglistnum; + IS41_PAR_TRIGGER_LIST *ptr1; + char tag[64]; + + struct IS41_TRANUMREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.tranumreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //Digits(Destination) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,1),ptr->digitsLen & MAX_IS41_VARPAR_LEN_1,ptr->digits,0x80,&asn_buf); +/* else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:Feature result absent!!"); + return 0; + }*/ + +//optional + if((flag & BIT1_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,2),1,&ptr->accden,0x80,&asn_buf); + if((flag & BIT2_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,3),ptr->actcodeLen & MAX_IS41_VARPAR_LEN_1,ptr->actcode,0x80,&asn_buf); + if((flag & BIT3_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,4),ptr->annlistLen & MAX_IS41_VARPAR_LEN_1,ptr->annlist,0x80,&asn_buf); + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG1,5),ptr->cpnstrg1Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg1,0x80,&asn_buf); + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG2,6),ptr->cpnstrg2Len & MAX_IS41_VARPAR_LEN_1,ptr->cpnstrg2,0x80,&asn_buf); + if((flag & BIT6_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,7),ptr->cpsubLen & MAX_IS41_VARPAR_LEN_1,ptr->cpsub,0x80,&asn_buf); + if((flag & BIT7_TRUE)>0) //Digits carrier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8),ptr->digitsCarrierLen & MAX_IS41_VARPAR_LEN_1,ptr->digitsCarrier,0x80,&asn_buf); + if((flag & BIT8_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,9),ptr->acdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->acdgts,0x80,&asn_buf); + if((flag & BIT9_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,10),ptr->abdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->abdgts,0x80,&asn_buf); + if((flag & BIT10_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,11),ptr->billdgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->billdgts,0x80,&asn_buf); + if((flag & BIT11_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,12),ptr->redindLen & MAX_IS41_VARPAR_LEN_1,ptr->redind,0x80,&asn_buf); + if((flag & BIT12_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,13),ptr->dmh_svcidLen & MAX_IS41_VARPAR_LEN_1,ptr->dmh_svcid,0x80,&asn_buf); + if((flag & BIT13_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,14),ptr->grpinfoLen & MAX_IS41_VARPAR_LEN_1,ptr->grpinfo,0x80,&asn_buf); + if((flag & BIT14_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,15),ptr->mdnLen & MAX_IS41_VARPAR_LEN_1,ptr->mdn,0x80,&asn_buf); + if((flag & BIT15_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,16),ptr->natimeLen & MAX_IS41_VARPAR_LEN_1,ptr->natime,0x80,&asn_buf); + if((flag & BIT16_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,17),1,&ptr->plind,0x80,&asn_buf); + + if((flag & BIT17_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,18),ptr->rndgtsLen & MAX_IS41_VARPAR_LEN_1,ptr->rndgts,0x80,&asn_buf); + if((flag & BIT18_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,19),ptr->rnstringLen & MAX_IS41_VARPAR_LEN_1,ptr->rnstring,0x80,&asn_buf); + if((flag & BIT19_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,20),ptr->rsubLen & MAX_IS41_VARPAR_LEN_1,ptr->rsub,0x80,&asn_buf); + + if ((flag & BIT20_TRUE) > 0) + { + if (!encode_param_termlist(&ptr->termlist,ptr->termlist.param_flag,&asn_buf,&buf_len)) + return 0; + } + if((flag & BIT21_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,22),ptr->termtrigLen & MAX_IS41_VARPAR_LEN_1,ptr->termtrig,0x80,&asn_buf); + + if((flag & BIT22_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + if (!triglistnum) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!"); + return 0; + } + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGADRLIST,23),0,NULL,0xA0,&asn_buf); + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + if ((flag1 & 0x03) != 0x03) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + sprintf(tag,"%s.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,i+1),0,NULL,0xA0,&asn_buf); + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_GLOBALTITLE); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr1->destaddrLen & MAX_IS41_VARPAR_LEN_1,ptr1->destaddr,0x80,&asn_buf); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + sprintf(tag,"%s.%s-%d.%s",IS41PAR_TRIGADRLIST,IS41PAR_TRIGLIST,i+1,IS41PAR_WINTRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr1->wintriglistLen & MAX_IS41_VARPAR_LEN_1,ptr1->wintriglist,0x80,&asn_buf); + } + } + } + + return buf_len; +} + +int extract_is41TransferToNumberRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_TRANUMREQ_RSP *ptr; + IS41_PAR_TRIGGER_LIST *ptr1; + int len,i,count; + char tag[64]; + + ptr = &opr_ptr->msg_list.tranumreq_rsp; + + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,33,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digits,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT0_TRUE; + ptr->digitsLen = len & MAX_IS41_VARPAR_LEN_1; + } +/* else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:Digits absent!"); + return 0; + }*/ + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ACCDEN,1,&ptr->accden,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + + len = decode_Is41Parameter(IS41PAR_ACTCODE,MAX_IS41_VARPAR_LEN,ptr->actcode,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->actcodeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ANNLIST,MAX_IS41_VARPAR_LEN,ptr->annlist,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->annlistLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG1,MAX_IS41_VARPAR_LEN,ptr->cpnstrg1,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->cpnstrg1Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPNSTRG2,MAX_IS41_VARPAR_LEN,ptr->cpnstrg2,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->cpnstrg2Len = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_CPSUB,MAX_IS41_VARPAR_LEN,ptr->cpsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->cpsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DIGITS,MAX_IS41_VARPAR_LEN,ptr->digitsCarrier,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->digitsCarrierLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ACDGTS,MAX_IS41_VARPAR_LEN,ptr->acdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->acdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_ABDGTS,MAX_IS41_VARPAR_LEN,ptr->abdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->abdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_BILLDGTS,MAX_IS41_VARPAR_LEN,ptr->billdgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->billdgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_REDIND,MAX_IS41_VARPAR_LEN,ptr->redind,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->redindLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_DMH_SVCID,MAX_IS41_VARPAR_LEN,ptr->dmh_svcid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->dmh_svcidLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_GRPINFO,MAX_IS41_VARPAR_LEN,ptr->grpinfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT13_TRUE; + ptr->grpinfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MDN,MAX_IS41_VARPAR_LEN,ptr->mdn,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT14_TRUE; + ptr->mdnLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_NATIME,MAX_IS41_VARPAR_LEN,ptr->natime,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT15_TRUE; + ptr->natimeLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_Is41Parameter(IS41PAR_PLIND,1,&ptr->plind,&asn_buf)) + ptr->param_flag |= BIT16_TRUE; + + len = decode_Is41Parameter(IS41PAR_RNDGTS,MAX_IS41_VARPAR_LEN,ptr->rndgts,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT17_TRUE; + ptr->rndgtsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RNSTRING,MAX_IS41_VARPAR_LEN,ptr->rnstring,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT18_TRUE; + ptr->rnstringLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_RSUB,MAX_IS41_VARPAR_LEN,ptr->rsub,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT19_TRUE; + ptr->rsubLen = len & MAX_IS41_VARPAR_LEN_1; + } + + if (decode_param_termlist(&ptr->termlist,&asn_buf) > 0) + ptr->param_flag |= BIT20_TRUE; + + len = decode_Is41Parameter(IS41PAR_TERMTRIG,MAX_IS41_VARPAR_LEN,ptr->termtrig,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT21_TRUE; + ptr->termtrigLen = len & MAX_IS41_VARPAR_LEN_1; + } + + ptr->triggerlistnum = 0; + for (i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++) + { + ptr1 = &ptr->triggerlist[i]; + count = 0; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->destaddr,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT0_TRUE; + ptr1->destaddrLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + len = decode_Is41Parameter(tag,MAX_IS41_VARPAR_LEN,ptr1->wintriglist,&asn_buf); + if (len > 0) + { + ptr1->param_flag |= BIT1_TRUE; + ptr1->wintriglistLen = len & MAX_IS41_VARPAR_LEN_1; + count++; + } + if (count == 2) + { + ptr->triggerlistnum++; + ptr->param_flag |= BIT22_TRUE; + } + else if (count == 1) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + else if (!count) + break; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41RedirectionRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + struct IS41_REDREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.redreq_arg; + + flag = ptr->param_flag; + + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1),7,ptr->billid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:BILLID absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,3),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //REDIRECTION REASON + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDREASON,4),1,&ptr->redreason,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:redreason absent!!"); + return 0; + } + + +// optional part---> + if((flag & BIT4_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LEGINFO,5),ptr->leginfoLen & MAX_IS41_VARPAR_LEN_1,ptr->leginfo,0x80,&asn_buf); + if((flag & BIT5_TRUE)>0) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,6),ptr->mscinLen & MAX_IS41_VARPAR_LEN_1,ptr->mscin,0x80,&asn_buf); + + return buf_len; +} + +int extract_is41RedirectionRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_REDREQ_ARG *ptr; + int len; + + ptr = &opr_ptr->msg_list.redreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,24,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_BILLID,7,ptr->billid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:BILLID absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + return 0; + } + + if (decode_Is41Parameter(IS41PAR_REDREASON,1,&ptr->redreason,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:redreason absent!"); + return 0; + } + + +//optional par---> + len = decode_Is41Parameter(IS41PAR_LEGINFO,MAX_IS41_VARPAR_LEN,ptr->leginfo,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->leginfoLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_MSCIN,MAX_IS41_VARPAR_LEN,ptr->mscin,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->mscinLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_is41RedirectionRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_REDREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.redreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + return buf_len; +} + +int extract_is41RedirectionRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + struct IS41_REDREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.redreq_rsp; + ptr->param_flag = 0; + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} diff --git a/omc/plat/xapp/src/mapp/is41_code_sms.c b/omc/plat/xapp/src/mapp/is41_code_sms.c new file mode 100644 index 0000000..aa5a15d --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_code_sms.c @@ -0,0 +1,1134 @@ +/* is41 coding smsc service file */ +/* written by daniel zhang 2004-07-10 */ +/* modified by daniel on 2004-07-10 */ +/* -------------------------------- */ + +#include "map_includes.h" + +/* external functions */ +void is41_log(char *info); +void is41_debug(DWORD mask, const char *fmt, ...); +void is41_showbuf(DWORD mask, BYTE *buf, int len); +int decode_Is41Parameter(char *tag,int len,BYTE *value,ASN_BUF *asn_buf); +char *is41_sequenceTag(char *tag,int sequence); + +int encode_Is41ParBearerData(IS41ParBearerData *ptr, u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if ((flag & BIT0_TRUE) > 0) + buf_len = AddTLV("0",3,ptr->MessageId,0x80,&asn_buf); + + if ((flag & BIT1_TRUE) > 0) + buf_len = AddTLV("1",ptr->UserDataLen & 31,ptr->UserData,0x80,&asn_buf); + + if ((flag & BIT2_TRUE) > 0) + buf_len = AddTLV("2",1,&ptr->UserRespondingCode,0x80,&asn_buf); + + if ((flag & BIT3_TRUE) > 0) + buf_len = AddTLV("3",6,ptr->MessageCenterTimeStamp,0x80,&asn_buf); + + if ((flag & BIT4_TRUE) > 0) + buf_len = AddTLV("4",6,ptr->ValidityPeriod_Absolute,0x80,&asn_buf); + if ((flag & BIT5_TRUE) > 0) + buf_len = AddTLV("5",1,&ptr->ValidityPeriod_Relative,0x80,&asn_buf); + if ((flag & BIT6_TRUE) > 0) + buf_len = AddTLV("6",6,ptr->DeferredDeliveryTime_Absolute,0x80,&asn_buf); + if ((flag & BIT7_TRUE) > 0) + buf_len = AddTLV("7",1,&ptr->DeferredDeliveryTime_Relative,0x80,&asn_buf); + if ((flag & BIT8_TRUE) > 0) + buf_len = AddTLV("8",1,&ptr->PriorityIndicator,0x80,&asn_buf); + if ((flag & BIT9_TRUE) > 0) + buf_len = AddTLV("9",1,&ptr->PrivacyIndicator,0x80,&asn_buf); + if ((flag & BIT10_TRUE) > 0) + buf_len = AddTLV("10",1,&ptr->ReplyOption,0x80,&asn_buf); + if ((flag & BIT11_TRUE) > 0) + buf_len = AddTLV("11",1,&ptr->NumberOfMessages,0x80,&asn_buf); + if ((flag & BIT12_TRUE) > 0) + buf_len = AddTLV("12",1,&ptr->AlertOnMessageDelivery,0x80,&asn_buf); + if ((flag & BIT13_TRUE) > 0) + buf_len = AddTLV("13",1,&ptr->LanguageIndicator,0x80,&asn_buf); + if ((flag & BIT14_TRUE) > 0) + buf_len = AddTLV("14",ptr->CallBackNumberLen & 31,ptr->CallBackNumber,0x80,&asn_buf); + if ((flag & BIT15_TRUE) > 0) + buf_len = AddTLV("15",1,&ptr->MessageDisplayMode,0x80,&asn_buf); + if ((flag & BIT16_TRUE) > 0) + buf_len = AddTLV("16",ptr->MultipleEncodingUserDataLen & 31,ptr->MultipleEncodingUserData,0x80,&asn_buf); + + if ((flag & BIT17_TRUE) > 0) + buf_len = AddTLV("20",1,&ptr->MessageStatus,0x80,&asn_buf); + if ((flag & BIT18_TRUE) > 0) + buf_len = AddTLV("21",1,&ptr->TPFailureCause,0x80,&asn_buf); + + + return buf_len; +} + +int decode_Is41ParBearerData(IS41ParBearerData *ptr, u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + if(AsnDecode(buf,buf_len,19,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter("0",3,ptr->MessageId,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + + len = decode_Is41Parameter("1",128,ptr->UserData,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->UserDataLen = len & 127; + } + if (decode_Is41Parameter("2",1,&ptr->UserRespondingCode,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if (decode_Is41Parameter("3",6,ptr->MessageCenterTimeStamp,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if (decode_Is41Parameter("4",6,ptr->ValidityPeriod_Absolute,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if (decode_Is41Parameter("5",1,&ptr->ValidityPeriod_Relative,&asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if (decode_Is41Parameter("6",6,ptr->DeferredDeliveryTime_Absolute,&asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if (decode_Is41Parameter("7",1,&ptr->DeferredDeliveryTime_Relative,&asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if (decode_Is41Parameter("8",1,&ptr->PriorityIndicator,&asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if (decode_Is41Parameter("9",1,&ptr->PrivacyIndicator,&asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if (decode_Is41Parameter("10",1,&ptr->ReplyOption,&asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if (decode_Is41Parameter("11",1,&ptr->NumberOfMessages,&asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if (decode_Is41Parameter("12",1,&ptr->AlertOnMessageDelivery,&asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if (decode_Is41Parameter("13",1,&ptr->LanguageIndicator,&asn_buf)) + ptr->param_flag |= BIT13_TRUE; + len = decode_Is41Parameter("14",MAX_IS41_VARPAR_LEN,ptr->CallBackNumber,&asn_buf); + if (len > 0) + { + ptr->CallBackNumberLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT14_TRUE; + } + if (decode_Is41Parameter("15",1,&ptr->MessageDisplayMode,&asn_buf)) + ptr->param_flag |= BIT15_TRUE; + len = decode_Is41Parameter("16",MAX_IS41_VARPAR_LEN,ptr->MultipleEncodingUserData,&asn_buf); + if (len > 0) + { + ptr->MultipleEncodingUserDataLen = len & MAX_IS41_VARPAR_LEN_1; + ptr->param_flag |= BIT16_TRUE; + } + if (decode_Is41Parameter("20",1,&ptr->MessageStatus,&asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if (decode_Is41Parameter("21",1,&ptr->TPFailureCause,&asn_buf)) + ptr->param_flag |= BIT18_TRUE; + return 1; + +} + +int assign_Is41SmsDeliveryBackward_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMDBACK_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdback_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_IMSCCID,1),2,(BYTE*)&ptr->imsccid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:InterMSCCID absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,3),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_BearerData absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //SMS_TeleserviceIdentifier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,4),ptr->smstidLen & MAX_IS41_VARPAR_LEN_1,ptr->smstid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_TeleserviceIdentifier absent!!"); + return 0; + } + + +// optional part---> + if((flag & BIT4_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,5),ESN_LEN,ptr->esn,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //SMS_ChargeIndicator + { + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCID,6),ptr->smscidLen & MAX_IS41_VARPAR_LEN_1,ptr->smscid,0x80,&asn_buf); + } + + if((flag & BIT6_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSDA,7),ptr->smsdaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsda,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //SMS_OriginalDestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODA,8),ptr->smsodaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoda,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //SMS_OriginalDestinationSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODS,9),ptr->smsodsLen & MAX_IS41_VARPAR_LEN_1,ptr->smsods,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SMS_OriginalOriginatingAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOA,10),ptr->smsooaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsooa,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //SMS_OriginalOriginatingSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOS,11),ptr->smsoosLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoos,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //smsoa + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOA,12),ptr->smsoaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoa,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsDeliveryBackward_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDBACK_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdback_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_IMSCCID,2,ptr->imsccid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:InterMSCCID absent!"); + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT2_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSTID,MAX_IS41_VARPAR_LEN,ptr->smstid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->smstidLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:IS41PAR_SMSTID absent!"); + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + + len = decode_Is41Parameter(IS41PAR_SMSCID,MAX_IS41_VARPAR_LEN,ptr->smscid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->smscidLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSDA,MAX_IS41_VARPAR_LEN,ptr->smsda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->smsdaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODA,MAX_IS41_VARPAR_LEN,ptr->smsoda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->smsodaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODS,MAX_IS41_VARPAR_LEN,ptr->smsods,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->smsodsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOA,MAX_IS41_VARPAR_LEN,ptr->smsooa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->smsooaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOS,MAX_IS41_VARPAR_LEN,ptr->smsoos,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->smsoosLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOA,MAX_IS41_VARPAR_LEN,ptr->smsoa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->smsoaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsDeliveryBackward_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMDBACK_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdback_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,1),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_BearerData absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //SMS_CauseCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCC,2),ptr->smsccLen & MAX_IS41_VARPAR_LEN_1,ptr->smscc,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_CauseCode absent!!"); + return 0; + } + + return buf_len; +} + + +int extract_Is41SmsDeliveryBackward_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDBACK_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdback_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSCC,MAX_IS41_VARPAR_LEN,ptr->smscc,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->smsccLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_CauseCode absent!"); + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsDeliveryForward_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMDFWD_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdfwd_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + if((flag & BIT0_TRUE)>0) //esn + buf_len = AddTLV(is41_sequenceTag(IS41PAR_IMSCCID,1),2,(BYTE*)&ptr->imsccid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:InterMSCCID absent!!"); + return 0; + } + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + + if((flag & BIT2_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,3),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_BearerData absent!!"); + return 0; + } + + if((flag & BIT3_TRUE)>0) //SMS_TeleserviceIdentifier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,4),ptr->smstidLen & MAX_IS41_VARPAR_LEN_1,ptr->smstid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_TeleserviceIdentifier absent!!"); + return 0; + } + + +// optional part---> + if((flag & BIT4_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,5),ESN_LEN,ptr->esn,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //SMS_ChargeIndicator + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCID,6),ptr->smscidLen & MAX_IS41_VARPAR_LEN_1,ptr->smscid,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSDA,7),ptr->smsdaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsda,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //SMS_OriginalDestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODA,8),ptr->smsodaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoda,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //SMS_OriginalDestinationSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODS,9),ptr->smsodsLen & MAX_IS41_VARPAR_LEN_1,ptr->smsods,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SMS_OriginalOriginatingAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOA,10),ptr->smsooaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsooa,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //SMS_OriginalOriginatingSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOS,11),ptr->smsoosLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoos,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //SMS_OriginatingAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOA,12),ptr->smsoaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoa,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsDeliveryForward_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDFWD_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdfwd_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_IMSCCID,2,ptr->imsccid,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:InterMSCCID absent!"); + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT2_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSTID,MAX_IS41_VARPAR_LEN,ptr->smstid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->smstidLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:IS41PAR_SMSTID absent!"); + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT4_TRUE; + + len = decode_Is41Parameter(IS41PAR_SMSCID,MAX_IS41_VARPAR_LEN,ptr->smscid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->smscidLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSDA,MAX_IS41_VARPAR_LEN,ptr->smsda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->smsdaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODA,MAX_IS41_VARPAR_LEN,ptr->smsoda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->smsodaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODS,MAX_IS41_VARPAR_LEN,ptr->smsods,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->smsodsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOA,MAX_IS41_VARPAR_LEN,ptr->smsooa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->smsooaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOS,MAX_IS41_VARPAR_LEN,ptr->smsoos,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->smsoosLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOA,MAX_IS41_VARPAR_LEN,ptr->smsoa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->smsoaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsDeliveryForward_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + + struct IS41_SMDFWD_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdfwd_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,1),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_BearerData absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //SMS_CauseCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCC,2),ptr->smsccLen & MAX_IS41_VARPAR_LEN_1,ptr->smscc,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_CauseCode absent!!"); + return 0; + } + + return buf_len; +} + + +int extract_Is41SmsDeliveryForward_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDFWD_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdfwd_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSCC,MAX_IS41_VARPAR_LEN,ptr->smscc,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->smsccLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_CauseCode absent!"); + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsDeliveryPointToPoint_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMDPP_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdpp_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,1),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_BearerData absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //SMS_TeleserviceIdentifier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,2),ptr->smstidLen & MAX_IS41_VARPAR_LEN_1,ptr->smstid,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_TeleserviceIdentifier absent!!"); + return 0; + } + + +// optional part---> + if((flag & BIT2_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,3),ESN_LEN,ptr->esn,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,4),MIN_LEN,ptr->min,0x80,&asn_buf); + + if((flag & BIT4_TRUE)>0) //SMS_ChargeIndicator + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCID,5),ptr->smscidLen & MAX_IS41_VARPAR_LEN_1,ptr->smscid,0x80,&asn_buf); + + if((flag & BIT5_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSDA,6),ptr->smsdaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsda,0x80,&asn_buf); + + if((flag & BIT6_TRUE)>0) //SMS_MessageCount + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSMSGCNT,7),ptr->smsmsgcntLen & MAX_IS41_VARPAR_LEN_1,ptr->smsmsgcnt,0x80,&asn_buf); + + if((flag & BIT7_TRUE)>0) //SMS_NotificationIndicator + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSNOTIND,8),ptr->smsnotindLen & MAX_IS41_VARPAR_LEN_1,ptr->smsnotind,0x80,&asn_buf); + + if((flag & BIT8_TRUE)>0) //SMS_OriginalDestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODA,9),ptr->smsodaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoda,0x80,&asn_buf); + + if((flag & BIT9_TRUE)>0) //SMS_OriginalDestinationSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODS,10),ptr->smsodsLen & MAX_IS41_VARPAR_LEN_1,ptr->smsods,0x80,&asn_buf); + + if((flag & BIT10_TRUE)>0) //SMS_OriginalOriginatingAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOA,11),ptr->smsooaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsooa,0x80,&asn_buf); + + if((flag & BIT11_TRUE)>0) //SMS_OriginalOriginatingSubaddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOS,12),ptr->smsoosLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoos,0x80,&asn_buf); + + if((flag & BIT12_TRUE)>0) //SMS_OriginatingAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOA,13),ptr->smsoaLen & MAX_IS41_VARPAR_LEN_1,ptr->smsoa,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsDeliveryPointToPoint_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDPP_ARG *ptr; + + ptr = &opr_ptr->msg_list.smdpp_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSTID,MAX_IS41_VARPAR_LEN,ptr->smstid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->smstidLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:IS41PAR_SMSTID absent!"); + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT2_TRUE; + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT3_TRUE; + + len = decode_Is41Parameter(IS41PAR_SMSCID,MAX_IS41_VARPAR_LEN,ptr->smscid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT4_TRUE; + ptr->smscidLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSDA,MAX_IS41_VARPAR_LEN,ptr->smsda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT5_TRUE; + ptr->smsdaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSMSGCNT,MAX_IS41_VARPAR_LEN,ptr->smsmsgcnt,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT6_TRUE; + ptr->smsmsgcntLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSNOTIND,MAX_IS41_VARPAR_LEN,ptr->smsnotind,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT7_TRUE; + ptr->smsnotindLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODA,MAX_IS41_VARPAR_LEN,ptr->smsoda,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT8_TRUE; + ptr->smsodaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSODS,MAX_IS41_VARPAR_LEN,ptr->smsods,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT9_TRUE; + ptr->smsodsLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOA,MAX_IS41_VARPAR_LEN,ptr->smsooa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT10_TRUE; + ptr->smsooaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOOS,MAX_IS41_VARPAR_LEN,ptr->smsoos,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT11_TRUE; + ptr->smsoosLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSOA,MAX_IS41_VARPAR_LEN,ptr->smsoa,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT12_TRUE; + ptr->smsoaLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsDeliveryPointToPoint_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMDPP_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdpp_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //SMS_BearerData + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,1),ptr->BearerDataLen,ptr->BearerData,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //SMS_CauseCode + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCC,2),ptr->smsccLen & MAX_IS41_VARPAR_LEN_1,ptr->smscc,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:SMS_CauseCode absent!!"); + return 0; + } + + return buf_len; +} + + +int extract_Is41SmsDeliveryPointToPoint_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMDPP_RSP *ptr; + + ptr = &opr_ptr->msg_list.smdpp_rsp; + ptr->param_flag = 0; + + if (buf_len == 0) + return 1; + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + + if ((ptr->BearerDataLen=decode_Is41Parameter(IS41PAR_SMSBD,256,ptr->BearerData,&asn_buf))>0) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_BearerData absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSCC,MAX_IS41_VARPAR_LEN,ptr->smscc,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->smsccLen = len & MAX_IS41_VARPAR_LEN_1; + } + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:SMS_CauseCode absent!"); + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsNotification_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMSNOT_ARG *ptr; + + ptr = &opr_ptr->msg_list.smsnot_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:ESN absent!!"); + return 0; + } + + if((flag & BIT1_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,2),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + +// optional part---> + + if((flag & BIT2_TRUE)>0) //SMS_AccessDeniedReason + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSACCDEN,3),ptr->smsaccdenLen & MAX_IS41_VARPAR_LEN_1,ptr->smsaccden,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSADDR,4),ptr->smsaddrLen & MAX_IS41_VARPAR_LEN_1,ptr->smsaddr,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsNotification_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMSNOT_ARG *ptr; + + ptr = &opr_ptr->msg_list.smsnot_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + +//optional par---> + len = decode_Is41Parameter(IS41PAR_SMSACCDEN,MAX_IS41_VARPAR_LEN,ptr->smsaccden,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->smsaccdenLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSADDR,MAX_IS41_VARPAR_LEN,ptr->smsaddr,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->smsaddrLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsNotification_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMSNOT_RSP *ptr; + + ptr = &opr_ptr->msg_list.smsnot_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsNotification_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + + struct IS41_SMSNOT_RSP *ptr; + + ptr = &opr_ptr->msg_list.smsnot_rsp; + + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMSREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.smsreq_arg; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + if((flag & BIT0_TRUE)>0) //min + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MIN,1),MIN_LEN,ptr->min,0x80,&asn_buf); + else + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:MIN absent!!"); + return 0; + } + +// optional part---> + if((flag & BIT1_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2),ESN_LEN,ptr->esn,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //SMS_NotificationIndicator + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSNOTIND,3),ptr->smsnotindLen & MAX_IS41_VARPAR_LEN_1,ptr->smsnotind,0x80,&asn_buf); + + if((flag & BIT3_TRUE)>0) //SMS_TeleserviceIdentifier + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,4),ptr->smstidLen & MAX_IS41_VARPAR_LEN_1,ptr->smstid,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMSREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.smsreq_arg; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + if (decode_Is41Parameter(IS41PAR_MIN,MIN_LEN,ptr->min,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:MIN absent!"); + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSNOTIND,MAX_IS41_VARPAR_LEN,ptr->smsnotind,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->smsnotindLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSTID,MAX_IS41_VARPAR_LEN,ptr->smstid,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT3_TRUE; + ptr->smstidLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} + +int assign_Is41SmsRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + struct IS41_SMSREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.smsreq_rsp; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + +// optional part---> + if((flag & BIT0_TRUE)>0) //ElectronicSerialNumber + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,1),ESN_LEN,ptr->esn,0x80,&asn_buf); + + if((flag & BIT1_TRUE)>0) //SMS_AccessDeniedReason + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSACCDEN,2),ptr->smsaccdenLen & MAX_IS41_VARPAR_LEN_1,ptr->smsaccden,0x80,&asn_buf); + + if((flag & BIT2_TRUE)>0) //SMS_DestinationAddress + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSADDR,3),ptr->smsaddrLen & MAX_IS41_VARPAR_LEN_1,ptr->smsaddr,0x80,&asn_buf); + + return buf_len; +} + +int extract_Is41SmsRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + + struct IS41_SMSREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.smsreq_rsp; + + if (buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf,buf_len,13,&decErr,&asn_buf) == -1) + return 0; + ptr->param_flag = 0; + + +//optional par---> + if (decode_Is41Parameter(IS41PAR_ESN,ESN_LEN,ptr->esn,&asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:ESN absent!"); + + len = decode_Is41Parameter(IS41PAR_SMSACCDEN,MAX_IS41_VARPAR_LEN,ptr->smsaccden,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT1_TRUE; + ptr->smsaccdenLen = len & MAX_IS41_VARPAR_LEN_1; + } + + len = decode_Is41Parameter(IS41PAR_SMSADDR,MAX_IS41_VARPAR_LEN,ptr->smsaddr,&asn_buf); + if (len > 0) + { + ptr->param_flag |= BIT2_TRUE; + ptr->smsaddrLen = len & MAX_IS41_VARPAR_LEN_1; + } + + is41_debug(IS41DB_DECODE,"[IS41-Decode]Completed, flag=0x%lx",ptr->param_flag); + + return 1; +} diff --git a/omc/plat/xapp/src/mapp/is41_code_win.c b/omc/plat/xapp/src/mapp/is41_code_win.c new file mode 100644 index 0000000..24127a8 --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_code_win.c @@ -0,0 +1,1871 @@ +/* ------------------------------------*/ +/* IS41 codec for WIN */ +/* created by Xinyu Yan 2006-04-14 */ +/* ------------------------------------*/ +#include "map_includes.h" + +extern void is41_debug(DWORD mask, const char *fmt, ...); +extern int encode_param_termlist(struct IS41_PAR_TERMLIST *ptr,u32 flag,ASN_BUF *asn_buf,int *buf_len); +extern int decode_param_termlist(IS41_PAR_TERMLIST *ptr,ASN_BUF *asn_buf); + +#define BIT30_TRUE 0x40000000 + +void is41enc_print_absent(char *param_str) +{ + is41_debug(IS41DB_ERR, "[IS41-Encode]: %s absent!", param_str); +} + +void is41dec_print_absent(char *param_str) +{ + is41_debug(IS41DB_ERR, "[IS41-Decode]: %s absent!", param_str); +} + +int decode_Is41Param(char *tag, int maxlen, u8 *len, u8 *value, ASN_BUF *asn_buf) +{ + int decodeLen; + + decodeLen = GetTLV(tag, maxlen, value, 0x80, asn_buf); + if(decodeLen > 0) + { + if(len != NULL) + *len = decodeLen; + return decodeLen; + } + return 0; +} + +u32 is41enc_MSID(u8 seq, IS41_PAR_MSID *ptr, ASN_BUF *asn_buf) +{ + if(ptr->choice_flag == 0) + return AddTLV(is41_sequenceTag(IS41PAR_MIN, seq), MIN_LEN, ptr->min, 0x80, asn_buf); + else if(ptr->choice_flag == 1) + return AddTLV(is41_sequenceTag(IS41PAR_IMSI, seq), IMSI_LEN, ptr->imsi, 0x80, asn_buf); + else + return 0; +} + +u32 is41dec_MSID(IS41_PAR_MSID *ptr, ASN_BUF *asn_buf) +{ + if(decode_Is41Param(IS41PAR_MIN, MIN_LEN, NULL, ptr->min, asn_buf)) + ptr->choice_flag = 0; + else if(decode_Is41Param(IS41PAR_IMSI, IMSI_LEN, NULL, ptr->imsi, asn_buf)) + ptr->choice_flag = 1; + else + return 0; + return 1; +} + +u32 is41enc_WINCAP(u8 seq, IS41_PAR_WIN_CAP *ptr, ASN_BUF *asn_buf) +{ + u32 buf_len = 0; + char tag[32]; + + if(!(ptr->param_flag & 0x03)) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:wincap no content!!"); + return 0; + } + if(ptr->param_flag & BIT0_TRUE) + { + sprintf(tag, "%s-%d.%s", IS41PAR_WINCAP, seq, IS41PAR_TRIGCAP); + buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->triggercapLen & MAX_IS41_VARPAR_LEN_1,ptr->triggercap,0x80,asn_buf); + } + if(ptr->param_flag & BIT1_TRUE) + { + sprintf(tag, "%s-%d.%s", IS41PAR_WINCAP, seq, IS41PAR_WINOPRCAP); + buf_len = AddTLV(is41_sequenceTag(tag,2),ptr->winoprcapLen & MAX_IS41_VARPAR_LEN_1,ptr->winoprcap,0x80,asn_buf); + } + return buf_len; +} + +u32 is41dec_WINCAP(IS41_PAR_WIN_CAP *ptr, ASN_BUF *asn_buf) +{ + char tag[32]; + + ptr->param_flag = 0; + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_TRIGCAP); + if(decode_Is41Param(tag, 32, &ptr->triggercapLen, ptr->triggercap, asn_buf)) + ptr->param_flag |= BIT0_TRUE; + sprintf(tag, "%s.%s", IS41PAR_WINCAP, IS41PAR_WINOPRCAP); + if(decode_Is41Param(tag, 32, &ptr->winoprcapLen, ptr->winoprcap, asn_buf)); + ptr->param_flag |= BIT1_TRUE; + + if(ptr->param_flag != 0) + return 1; + else + return 0; +} + +u32 is41enc_triggerlist(u8 seq, u8 triggerlistnum, IS41_PAR_TRIGGER_LIST *ptr, ASN_BUF *asn_buf) +{ + u32 buf_len = 0; + int i; + char tag[64]; + u32 flag1; + IS41_PAR_TRIGGER_LIST *ptr1; + + if(!triggerlistnum) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:TriggerAddressList no content!!"); + return 0; + } + for(i = 0; i < triggerlistnum; i++) + { + ptr1 = ptr + i; + flag1 = ptr1->param_flag; + if((flag1 & 0x03) != 0x03) + { + is41_debug(IS41DB_ERR,"[IS41-Encode] Stopped,reason:triggerlist lacks mandatory info!!"); + return 0; + } + if(flag1 & BIT0_TRUE) + { + sprintf(tag, "%s-%d.%s-%d.%s", IS41PAR_TRIGADRLIST, seq, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + buf_len = AddTLV(is41_sequenceTag(tag,1), ptr1->destaddrLen, ptr1->destaddr, 0x80, asn_buf); + } + if(flag1 & BIT1_TRUE) + { + sprintf(tag, "%s-%d.%s-%d.%s", IS41PAR_TRIGADRLIST, seq, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + buf_len = AddTLV(is41_sequenceTag(tag,2), ptr1->wintriglistLen, ptr1->wintriglist, 0x80, asn_buf); + } + } + return buf_len; +} + +u32 is41dec_triggerlist(u8 *triggerlistnum, IS41_PAR_TRIGGER_LIST *ptr, ASN_BUF *asn_buf) +{ + int i; + char tag[64]; + IS41_PAR_TRIGGER_LIST *ptr1; + + *triggerlistnum = 0; + for(i = 0; i < MAX_IS41_TRIG_LIST_NUM; i++) + { + ptr1 = ptr + i; + ptr1->param_flag = 0; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_GLOBALTITLE); + if(decode_Is41Param(tag, 32, &ptr1->destaddrLen, ptr1->destaddr, asn_buf)) + ptr1->param_flag |= BIT0_TRUE; + sprintf(tag, "%s.%s-%d.%s", IS41PAR_TRIGADRLIST, IS41PAR_TRIGLIST, i+1, IS41PAR_WINTRIGLIST); + if(decode_Is41Param(tag, 32, &ptr1->wintriglistLen, ptr->wintriglist, asn_buf)) + ptr1->param_flag |= BIT1_TRUE; + if(ptr1->param_flag == 0x03) + (*triggerlistnum)++; + else if(ptr1->param_flag == 0) + break; + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:triggerlist lacks mandatory info!!"); + break; + } + } + if(*triggerlistnum != 0) + return 1; + else + return 0; +} + +u32 is41enc_exescr(u8 seq, IS41_PAR_EXESCR *ptr, ASN_BUF *asn_buf) +{ + u32 buf_len = 0; + char tag[32]; + + if(ptr->param_flag & BIT0_TRUE) + { + sprintf(tag, "%s-%d.%s", IS41PAR_EXESCR, seq, IS41PAR_SCRNAME); + buf_len = AddTLV(is41_sequenceTag(tag,1), ptr->scrnameLen, ptr->scrname, 0x80, asn_buf); + } + else + is41_debug(IS41DB_ERR,"[IS41-Encode] Warning,reason:exescr lacks mandatory info!!"); + if(ptr->param_flag & BIT1_TRUE) + { + sprintf(tag, "%s-%d.%s", IS41PAR_EXESCR, seq, IS41PAR_SCRARG); + buf_len = AddTLV(is41_sequenceTag(tag,2), ptr->scrargLen, ptr->scrarg, 0x80, asn_buf); + } + return buf_len; +} + +u32 is41dec_exescr(IS41_PAR_EXESCR *ptr, ASN_BUF *asn_buf) +{ + char tag[32]; + + ptr->param_flag = 0; + sprintf(tag, "%s.%s", IS41PAR_EXESCR, IS41PAR_SCRNAME); + if(decode_Is41Param(tag, 32, &ptr->scrnameLen, ptr->scrname, asn_buf)) + ptr->param_flag |= BIT0_TRUE; + sprintf(tag, "%s.%s", IS41PAR_EXESCR, IS41PAR_SCRARG); + if(decode_Is41Param(tag, 96, &ptr->scrargLen, ptr->scrarg, asn_buf)); + ptr->param_flag |= BIT1_TRUE; + + if(ptr->param_flag&BIT0_TRUE) + return 1; + else + return 0; +} + +/****************************************************************************************/ +int assign_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ORREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.orreq_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,2), ptr->digitsLen, ptr->digits, 0x80, &asn_buf); + else + is41enc_print_absent("Digits"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,3), 4, ptr->esn, 0x80, &asn_buf); + else + is41enc_print_absent("ESN"); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,4), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT4_TRUE) + buf_len = is41enc_MSID(5, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ORIGTRIG,6), ptr->origtrigLen, ptr->origtrig, 0x80, &asn_buf); + else + is41enc_print_absent("OriginationTriggers"); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,7), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf); + else + is41enc_print_absent("TransactionCapability"); + //optional + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNAME,8), ptr->cpnameLen, ptr->cpname, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,9), ptr->cpndgts1Len, ptr->cpndgts1, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,10), ptr->cpndgts2Len, ptr->cpndgts2, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,11), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,12), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,13), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,14), ptr->featindLen, ptr->featind, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,15), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,16), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf); + if(flag & BIT16_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PCSSN,17), 5, ptr->pc_ssn, 0x80, &asn_buf); + if(flag & BIT17_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,18), 1, &ptr->plind, 0x80, &asn_buf); + if(flag & BIT18_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SENDERIN,19), ptr->senderinLen, ptr->senderin, 0x80, &asn_buf); + if(flag & BIT19_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,20), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT20_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,21), 1, &ptr->triggertype, 0x80, &asn_buf); + if(flag & BIT21_TRUE) + buf_len = is41enc_WINCAP(22, &ptr->wincap, &asn_buf); + return buf_len; +} + +int assign_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ORREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.orreq_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,1), 1, &ptr->accden, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,2), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,3), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG1,4), ptr->cpnstrg1Len, ptr->cpnstrg1, 0x80, &asn_buf); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNSTRG2,5), ptr->cpnstrg2Len, ptr->cpnstrg2, 0x80, &asn_buf); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,6), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,7), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,8), ptr->digitsLen, ptr->digits, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,9), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,10), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,11), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,12), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,13), ptr->redindLen, ptr->redind, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,14), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_GRPINFO,15), ptr->grpinfoLen, ptr->grpinfo, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,16), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT16_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,17), ptr->natimeLen, ptr->natime, 0x80, &asn_buf); + if(flag & BIT17_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,18), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf); + if(flag & BIT18_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PILOT,19), ptr->pilotLen, ptr->pilot, 0x80, &asn_buf); + if(flag & BIT19_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,20), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf); + if(flag & BIT20_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNSTRING,21), ptr->rnstringLen, ptr->rnstring, 0x80, &asn_buf); + if(flag & BIT21_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,22), ptr->rsubLen, ptr->rsub, 0x80, &asn_buf); + if(flag & BIT22_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESUMEPIC,23), 1, &ptr->resumepic, 0x80, &asn_buf); + if(flag & BIT23_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,24), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf); + if(flag & BIT24_TRUE) + encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len); + if(flag & BIT25_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,26), ptr->termtrigLen, ptr->termtrig, 0x80, &asn_buf); + if(flag & BIT26_TRUE) + buf_len = is41enc_triggerlist(27, ptr->triggerlistnum, ptr->triggerlist, &asn_buf); + return buf_len; +} + +int extract_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ORREQ_ARG *ptr; + + ptr = &opr_ptr->msg_list.orreq_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("Digits"); + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("ESN"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("MSID"); + if(decode_Is41Param(IS41PAR_ORIGTRIG, 32, &ptr->origtrigLen, ptr->origtrig, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("OriginationTriggers"); + if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + else + is41dec_print_absent("TransactionCapability"); + //optional + if(decode_Is41Param(IS41PAR_CPNAME, 32, &ptr->cpnameLen, ptr->cpname, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_CPNDGTS1, 32, &ptr->cpndgts1Len, ptr->cpndgts1, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_CPNDGTS2, 32, &ptr->cpndgts2Len, ptr->cpndgts2, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + if(decode_Is41Param(IS41PAR_PCSSN, 5, NULL, ptr->pc_ssn, &asn_buf)) + ptr->param_flag |= BIT16_TRUE; + if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if(decode_Is41Param(IS41PAR_SENDERIN, 32, &ptr->senderinLen, ptr->senderin, &asn_buf)) + ptr->param_flag |= BIT18_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT19_TRUE; + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT20_TRUE; + if(is41dec_WINCAP(&ptr->wincap, &asn_buf)) + ptr->param_flag |= BIT21_TRUE; + return 1; +} + +int extract_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ORREQ_RSP *ptr; + + ptr = &opr_ptr->msg_list.orreq_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_ACCDEN, 1, NULL, &ptr->accden, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if(decode_Is41Param(IS41PAR_CPNSTRG1, 32, &ptr->cpnstrg1Len, ptr->cpnstrg1, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if(decode_Is41Param(IS41PAR_CPNSTRG2, 32, &ptr->cpnstrg2Len, ptr->cpnstrg2, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_GRPINFO, 32, &ptr->grpinfoLen, ptr->grpinfo, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + if(decode_Is41Param(IS41PAR_NATIME, 32, &ptr->natimeLen, ptr->natime, &asn_buf)) + ptr->param_flag |= BIT16_TRUE; + if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if(decode_Is41Param(IS41PAR_PILOT, 32, &ptr->pilotLen, ptr->pilot, &asn_buf)) + ptr->param_flag |= BIT18_TRUE; + if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf)) + ptr->param_flag |= BIT19_TRUE; + if(decode_Is41Param(IS41PAR_RNSTRING, 32, &ptr->rnstringLen, ptr->rnstring, &asn_buf)) + ptr->param_flag |= BIT20_TRUE; + if(decode_Is41Param(IS41PAR_RSUB, 32, &ptr->rsubLen, ptr->rsub, &asn_buf)) + ptr->param_flag |= BIT21_TRUE; + if(decode_Is41Param(IS41PAR_RESUMEPIC, 1, NULL, &ptr->resumepic, &asn_buf)) + ptr->param_flag |= BIT22_TRUE; + if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, NULL, ptr->routdgts, &asn_buf)) + ptr->param_flag |= BIT23_TRUE; + if(decode_param_termlist(&ptr->termlist, &asn_buf)) + ptr->param_flag |= BIT24_TRUE; + if(decode_Is41Param(IS41PAR_TERMTRIG, 32, &ptr->termtrigLen, ptr->termtrig, &asn_buf)) + ptr->param_flag |= BIT25_TRUE; + if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf)) + ptr->param_flag |= BIT26_TRUE; + return 1; +} + +int assign_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ANLYZD_ARG *ptr; + + ptr = &opr_ptr->msg_list.anlyzd_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,2), ptr->digitsLen, ptr->digits, 0x80, &asn_buf); + else + is41enc_print_absent("Digits"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,4), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf); + else + is41enc_print_absent("TransactionCapability"); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,5), 1, &ptr->triggertype, 0x80, &asn_buf); + else + is41enc_print_absent("TriggerType"); + if(flag & BIT5_TRUE) + buf_len = is41enc_WINCAP(6, &ptr->wincap, &asn_buf); + else + is41enc_print_absent("WINCapability"); + //optional + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNAME,7), ptr->cpnameLen, ptr->cpname, 0x80, &asn_buf); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS1,8), ptr->cpndgts1Len, ptr->cpndgts1, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPNDGTS2,9), ptr->cpndgts2Len, ptr->cpndgts2, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CPSUB,10), ptr->cpsubLen, ptr->cpsub, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,11), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,12), ptr->cciLen, ptr->cci, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,13), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,14), ptr->redindLen, ptr->redind, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,15), 4, ptr->esn, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,16), ptr->featindLen, ptr->featind, 0x80, &asn_buf); + if(flag & BIT16_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,17), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT17_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,18), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT18_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,19), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT19_TRUE) + buf_len = is41enc_MSID(20, &ptr->msid, &asn_buf); + if(flag & BIT20_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,21), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf); + if(flag & BIT21_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,22), 1, &ptr->plind, 0x80, &asn_buf); + if(flag & BIT22_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,23), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf); + if(flag & BIT23_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RDNAME,24), ptr->rdnameLen, ptr->rdname, 0x80, &asn_buf); + if(flag & BIT24_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RSUB,25), ptr->rsubLen, ptr->rsub, 0x80, &asn_buf); + if(flag & BIT25_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,26), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf); + if(flag & BIT26_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,27), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT27_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,28), 1, &ptr->mytyp, 0x80, &asn_buf); + if(flag & BIT28_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,29), 1, &ptr->tat, 0x80, &asn_buf); + if(flag & BIT29_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,30), 2, ptr->tdo, 0x80, &asn_buf); + if(flag & BIT30_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,31), 3, ptr->tod, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ANLYZD_RSP *ptr; + + ptr = &opr_ptr->msg_list.anlyzd_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACCDEN,1), 1, &ptr->accden, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,2), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,3), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,4), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CCI,5), ptr->cciLen, ptr->cci, 0x80, &asn_buf); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,6), ptr->digitsLen, ptr->digits, 0x80, &asn_buf); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,7), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,8), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,9), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,10), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,11), ptr->redindLen, ptr->redind, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,12), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_NATIME,13), ptr->natimeLen, ptr->natime, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_OTFI,14), ptr->otfiLen, ptr->otfi, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RNDGTS,15), ptr->rndgtsLen, ptr->rndgts, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RESUMEPIC,16), 1, &ptr->resumepic, 0x80, &asn_buf); + if(flag & BIT16_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,17), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf); + if(flag & BIT17_TRUE) + encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len); + if(flag & BIT18_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TERMTRIG,19), ptr->termtrigLen, ptr->termtrig, 0x80, &asn_buf); + if(flag & BIT19_TRUE) + buf_len = is41enc_triggerlist(20, ptr->triggerlistnum, ptr->triggerlist, &asn_buf); + return buf_len; +} + +int extract_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ANLYZD_ARG *ptr; + + ptr = &opr_ptr->msg_list.anlyzd_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("Digits"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSCID"); + if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("TransactionCapability"); + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("TriggerType"); + if(is41dec_WINCAP(&ptr->wincap, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("WINCapability"); + //optional + if(decode_Is41Param(IS41PAR_CPNAME, 32, &ptr->cpnameLen, ptr->cpname, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if(decode_Is41Param(IS41PAR_CPNDGTS1, 32, &ptr->cpndgts1Len, ptr->cpndgts1, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_CPNDGTS2, 32, &ptr->cpndgts2Len, ptr->cpndgts2, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_CPSUB, 32, &ptr->cpsubLen, ptr->cpsub, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_CCI, 32, &ptr->cciLen, ptr->cci, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT16_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT18_TRUE; + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT19_TRUE; + if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf)) + ptr->param_flag |= BIT20_TRUE; + if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf)) + ptr->param_flag |= BIT21_TRUE; + if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf)) + ptr->param_flag |= BIT22_TRUE; + if(decode_Is41Param(IS41PAR_RDNAME, 32, &ptr->rdnameLen, ptr->rdname, &asn_buf)) + ptr->param_flag |= BIT23_TRUE; + if(decode_Is41Param(IS41PAR_RSUB, 32, &ptr->rsubLen, ptr->rsub, &asn_buf)) + ptr->param_flag |= BIT24_TRUE; + if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf)) + ptr->param_flag |= BIT25_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT26_TRUE; + if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf)) + ptr->param_flag |= BIT27_TRUE; + if(decode_Is41Param(IS41PAR_TAT, 1, NULL, &ptr->tat, &asn_buf)) + ptr->param_flag |= BIT28_TRUE; + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT29_TRUE; + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT30_TRUE; + return 1; +} + +int extract_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ANLYZD_RSP *ptr; + + ptr = &opr_ptr->msg_list.anlyzd_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_ACCDEN, 1, NULL, &ptr->accden, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if(decode_Is41Param(IS41PAR_CCI, 32, &ptr->cciLen, ptr->cci, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_NATIME, 32, &ptr->natimeLen, ptr->natime, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_OTFI, 32, &ptr->otfiLen, ptr->otfi, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_RNDGTS, 32, &ptr->rndgtsLen, ptr->rndgts, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_RESUMEPIC, 1, NULL, &ptr->resumepic, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf)) + ptr->param_flag |= BIT16_TRUE; + if(decode_param_termlist(&ptr->termlist, &asn_buf)) + ptr->param_flag |= BIT17_TRUE; + if(decode_Is41Param(IS41PAR_TERMTRIG, 32, &ptr->termtrigLen, ptr->termtrig, &asn_buf)) + ptr->param_flag |= BIT18_TRUE; + if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf)) + ptr->param_flag |= BIT19_TRUE; + return 1; +} + +int assign_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_OANSWER_ARG *ptr; + + ptr = &opr_ptr->msg_list.oanswer_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf); + else + is41enc_print_absent("ESN"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT3_TRUE) + buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf); + else + is41enc_print_absent("TimeDateOffset"); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf); + else + is41enc_print_absent("TimeOfDay"); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,7), 1, &ptr->triggertype, 0x80, &asn_buf); + else + is41enc_print_absent("TriggerType"); + //optional + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,8), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,9), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,10), ptr->featindLen, ptr->featind, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,11), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,12), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,13), 1, &ptr->mytyp, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_OANSWER_ARG *ptr; + + ptr = &opr_ptr->msg_list.oanswer_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("ESN"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("MSID"); + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("TimeDateOffset"); + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("TimeOfDay"); + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + else + is41dec_print_absent("TriggerType"); + //optional + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + return 1; +} + +int assign_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ODISCONNECT_ARG *ptr; + + ptr = &opr_ptr->msg_list.odisconnect_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf); + else + is41enc_print_absent("ESN"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT3_TRUE) + buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RELCAUSE,5), 1, &ptr->relcause, 0x80, &asn_buf); + else + is41enc_print_absent("ReleaseCause"); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,6), 2, ptr->tdo, 0x80, &asn_buf); + else + is41enc_print_absent("TimeDateOffset"); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,7), 3, ptr->tod, 0x80, &asn_buf); + else + is41enc_print_absent("TimeOfDay"); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,8), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf); + else + is41enc_print_absent("TransactionCapability"); + if(flag & BIT8_TRUE) + buf_len = is41enc_WINCAP(9, &ptr->wincap, &asn_buf); + else + is41enc_print_absent("WINCapability"); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,10), 1, &ptr->triggertype, 0x80, &asn_buf); + else + is41enc_print_absent("TriggerType"); + //optional + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,11), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,12), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,13), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,14), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,15), 1, &ptr->mytyp, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_ODISCONNECT_RSP *ptr; + + ptr = &opr_ptr->msg_list.odisconnect_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,1), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,2), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ODISCONNECT_ARG *ptr; + + ptr = &opr_ptr->msg_list.odisconnect_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("ESN"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("MSID"); + if(decode_Is41Param(IS41PAR_RELCAUSE, 1, NULL, &ptr->relcause, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("ReleaseCause"); + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("TimeDateOffset"); + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + else + is41dec_print_absent("TimeOfDay"); + if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + else + is41dec_print_absent("TransactionCapability"); + if(is41dec_WINCAP(&ptr->wincap, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + else + is41dec_print_absent("WINCapability"); + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + else + is41dec_print_absent("TriggerType"); + //optional + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + return 1; +} + +int extract_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_ODISCONNECT_RSP *ptr; + + ptr = &opr_ptr->msg_list.odisconnect_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + return 1; +} + +int assign_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_TANSWER_ARG *ptr; + + ptr = &opr_ptr->msg_list.tanswer_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf); + else + is41enc_print_absent("ESN"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT3_TRUE) + buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf); + else + is41enc_print_absent("TimeDateOffset"); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf); + else + is41enc_print_absent("TimeOfDay"); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRANSCAP,7), ptr->transcapLen, ptr->transcap, 0x80, &asn_buf); + else + is41enc_print_absent("TransactionCapability"); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,8), 1, &ptr->triggertype, 0x80, &asn_buf); + else + is41enc_print_absent("TriggerType"); + if(flag & BIT8_TRUE) + buf_len = is41enc_WINCAP(9, &ptr->wincap, &asn_buf); + else + is41enc_print_absent("WINCapability"); + //optional + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,10), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,11), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_FEATIND,12), ptr->featindLen, ptr->featind, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,13), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,14), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,15), 1, &ptr->mytyp, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,16), 1, &ptr->tat, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_TANSWER_ARG *ptr; + + ptr = &opr_ptr->msg_list.tanswer_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("ESN"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("MSID"); + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("TimeDateOffset"); + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("TimeOfDay"); + if(decode_Is41Param(IS41PAR_TRANSCAP, 32, &ptr->transcapLen, ptr->transcap, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + else + is41dec_print_absent("TransactionCapability"); + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + else + is41dec_print_absent("TriggerType"); + if(is41dec_WINCAP(&ptr->wincap, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + else + is41dec_print_absent("WINCapability"); + //optional + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_FEATIND, 32, &ptr->featindLen, ptr->featind, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_TAT, 1, NULL, &ptr->tat, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + return 1; +} + +int assign_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_TDISCONNECT_ARG *ptr; + + ptr = &opr_ptr->msg_list.tdisconnect_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,2), 4, ptr->esn, 0x80, &asn_buf); + else + is41enc_print_absent("ESN"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,3), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT3_TRUE) + buf_len = is41enc_MSID(4, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,5), 2, ptr->tdo, 0x80, &asn_buf); + else + is41enc_print_absent("TimeDateOffset"); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,6), 3, ptr->tod, 0x80, &asn_buf); + else + is41enc_print_absent("TimeOfDay"); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TRIGERTYPE,7), 1, &ptr->triggertype, 0x80, &asn_buf); + else + is41enc_print_absent("TriggerType"); + //optional + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_LOCID,8), 2, ptr->locid, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,9), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCIN,10), ptr->mscinLen, ptr->mscin, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_RELCAUSE,11), 1, &ptr->relcause, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCID,12), 2, ptr->scellid, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MYTYP,13), 1, &ptr->mytyp, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_TDISCONNECT_RSP *ptr; + + ptr = &opr_ptr->msg_list.tdisconnect_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,1), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_TDISCONNECT_ARG *ptr; + + ptr = &opr_ptr->msg_list.tdisconnect_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("ESN"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("MSID"); + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + else + is41dec_print_absent("TimeDateOffset"); + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + else + is41dec_print_absent("TimeOfDay"); + if(decode_Is41Param(IS41PAR_TRIGERTYPE, 1, NULL, &ptr->triggertype, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + else + is41dec_print_absent("TriggerType"); + //optional + if(decode_Is41Param(IS41PAR_LOCID, 2, NULL, ptr->locid, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_MSCIN, 32, &ptr->mscinLen, ptr->mscin, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_RELCAUSE, 1, NULL, &ptr->relcause, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_SCID, 2, NULL, ptr->scellid, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_MYTYP, 1, NULL, &ptr->mytyp, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + return 1; +} + +int extract_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_TDISCONNECT_RSP *ptr; + + ptr = &opr_ptr->msg_list.tdisconnect_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + return 1; +} + +int assign_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_CCDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.ccdir_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLID,1), 7, ptr->billid, 0x80, &asn_buf); + else + is41enc_print_absent("BillingID"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MSCID,2), 3, ptr->mscid, 0x80, &asn_buf); + else + is41enc_print_absent("MSCID"); + if(flag & BIT2_TRUE) + buf_len = is41enc_MSID(3, &ptr->msid, &asn_buf); + else + is41enc_print_absent("MSID"); + //optional + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACTCODE,4), ptr->actcodeLen, ptr->actcode, 0x80, &asn_buf); + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,5), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,6), ptr->disptextLen, ptr->disptext, 0x80, &asn_buf); + if(flag & BIT6_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ACDGTS,7), ptr->acdgtsLen, ptr->acdgts, 0x80, &asn_buf); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ABDGTS,8), ptr->abdgtsLen, ptr->abdgts, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_BILLDGTS,9), ptr->billdgtsLen, ptr->billdgts, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_REDIND,10), ptr->redindLen, ptr->redind, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,11), 4, ptr->esn, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,12), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,13), 1, &ptr->plind, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + encode_param_termlist(&ptr->termlist, ptr->termlist.param_flag, &asn_buf, &buf_len); + if(flag & BIT14_TRUE) + buf_len = is41enc_triggerlist(15, ptr->triggerlistnum, ptr->triggerlist, &asn_buf); + return buf_len; +} + +int assign_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_CCDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.ccdir_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CALLSTATUS,1), ptr->callstatusLen, ptr->callstatus, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_CCDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.ccdir_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_BILLID, 7, NULL, ptr->billid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("BillingID"); + if(decode_Is41Param(IS41PAR_MSCID, 3, NULL, ptr->mscid, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("MSCID"); + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("MSID"); + //optional + if(decode_Is41Param(IS41PAR_ACTCODE, 32, &ptr->actcodeLen, ptr->actcode, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if(decode_Is41Param(IS41PAR_DISPTEXT, 32, &ptr->disptextLen, ptr->disptext, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if(decode_Is41Param(IS41PAR_ACDGTS, 32, &ptr->acdgtsLen, ptr->acdgts, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if(decode_Is41Param(IS41PAR_ABDGTS, 32, &ptr->abdgtsLen, ptr->abdgts, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_BILLDGTS, 32, &ptr->billdgtsLen, ptr->billdgts, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_REDIND, 32, &ptr->redindLen, ptr->redind, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_param_termlist(&ptr->termlist, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(is41dec_triggerlist(&ptr->triggerlistnum, ptr->triggerlist, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + return 1; +} + +int extract_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_CCDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.ccdir_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_CALLSTATUS, 32, &ptr->callstatusLen, ptr->callstatus, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + return 1; +} + +int assign_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SEIZERES_ARG *ptr; + + ptr = &opr_ptr->msg_list.seizeres_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PLIND,1), 1, &ptr->plind, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_PSR,2), ptr->psrLen, ptr->psr, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SR,3), ptr->srLen, ptr->sr, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SEIZERES_RSP *ptr; + + ptr = &opr_ptr->msg_list.seizeres_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,1), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf); + else + is41enc_print_absent("DestinationDigits"); + return buf_len; +} + +int extract_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SEIZERES_ARG *ptr; + + ptr = &opr_ptr->msg_list.seizeres_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_PLIND, 1, NULL, &ptr->plind, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_PSR, 32, &ptr->psrLen, ptr->psr, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(decode_Is41Param(IS41PAR_SR, 32, &ptr->srLen, ptr->sr, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + return 1; +} + +int extract_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SEIZERES_RSP *ptr; + + ptr = &opr_ptr->msg_list.seizeres_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("DestinationDigits"); + return 1; +} + +int assign_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_CONNRES_ARG *ptr; + + ptr = &opr_ptr->msg_list.connres_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DESTDGTS,1), ptr->destdgtsLen, ptr->destdgts, 0x80, &asn_buf); + else + is41enc_print_absent("DestinationDigits"); + //optional + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_CARDGTS,2), ptr->cardgtsLen, ptr->cardgts, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ROUTDGTS,3), ptr->routdgtsLen, ptr->routdgts, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_CONNRES_ARG *ptr; + + ptr = &opr_ptr->msg_list.connres_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_DESTDGTS, 32, &ptr->destdgtsLen, ptr->destdgts, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("DestinationDigits"); + //optional + if(decode_Is41Param(IS41PAR_CARDGTS, 32, &ptr->cardgtsLen, ptr->cardgts, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(decode_Is41Param(IS41PAR_ROUTDGTS, 32, &ptr->routdgtsLen, ptr->routdgts, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + return 1; +} + +int assign_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SRFDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.srfdir_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ANNLIST,1), ptr->annlistLen, ptr->annlist, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITCC,2), ptr->dgtccLen, ptr->dgtcc, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = is41enc_exescr(3, &ptr->exescr, &asn_buf); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,4), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SRFDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.srfdir_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DIGITS,1), ptr->digitsLen, ptr->digits, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SCRRESULT,2), ptr->scrresultLen, ptr->scrresult, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SRFDIR_ARG *ptr; + + ptr = &opr_ptr->msg_list.srfdir_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_ANNLIST, 32, &ptr->annlistLen, ptr->annlist, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_DIGITCC, 32, &ptr->dgtccLen, ptr->dgtcc, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(is41dec_exescr(&ptr->exescr, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + return 1; +} + +int extract_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SRFDIR_RSP *ptr; + + ptr = &opr_ptr->msg_list.srfdir_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_DIGITS, 32, &ptr->digitsLen, ptr->digits, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_SCRRESULT, 32, &ptr->scrresultLen, ptr->scrresult, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + return 1; +} + +int assign_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SM_ANLYZD_ARG *ptr; + + ptr = &opr_ptr->msg_list.smanlyzd_arg; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBRLEN,1), 2, ptr->sms_brlen, 0x80, &asn_buf); + else + is41enc_print_absent("SMS_BearerLength"); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBILLID,2), ptr->sms_billidLen, ptr->sms_billid, 0x80, &asn_buf); + else + is41enc_print_absent("SMS_BillingID"); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSEVENT,3), 1, &ptr->sms_event, 0x80, &asn_buf); + else + is41enc_print_absent("SMS_Event"); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSTID,4), ptr->smstidLen, ptr->smstid, 0x80, &asn_buf); + else + is41enc_print_absent("SMS_TeleserviceIdentifier"); + //optional + if(flag & BIT4_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_ESN,5), 4, ptr->esn, 0x80, &asn_buf); + if(flag & BIT5_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_MDN,6), ptr->mdnLen, ptr->mdn, 0x80, &asn_buf); + if(flag & BIT6_TRUE) + buf_len = is41enc_MSID(7, &ptr->msid, &asn_buf); + if(flag & BIT7_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCID,8), ptr->smscidLen, ptr->smscid, 0x80, &asn_buf); + if(flag & BIT8_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSDA,9), ptr->smsdaLen, ptr->smsda, 0x80, &asn_buf); + if(flag & BIT9_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSPMCNT,10), 4, ptr->sms_pmcnt, 0x80, &asn_buf); + if(flag & BIT10_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODA,11), ptr->smsodaLen, ptr->smsoda, 0x80, &asn_buf); + if(flag & BIT11_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSODS,12), ptr->smsodsLen, ptr->smsods, 0x80, &asn_buf); + if(flag & BIT12_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOA,13), ptr->smsooaLen, ptr->smsooa, 0x80, &asn_buf); + if(flag & BIT13_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOOS,14), ptr->smsoosLen, ptr->smsoos, 0x80, &asn_buf); + if(flag & BIT14_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSOA,15), ptr->smsoaLen, ptr->smsoa, 0x80, &asn_buf); + if(flag & BIT15_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TDO,16), 2, ptr->tdo, 0x80, &asn_buf); + if(flag & BIT16_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_TOD,17), 3, ptr->tod, 0x80, &asn_buf); + return buf_len; +} + +int assign_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len = 0; + u32 flag; + IS41_SM_ANLYZD_RSP *ptr; + + ptr = &opr_ptr->msg_list.smanlyzd_rsp; + flag = ptr->param_flag; + AsnEncode(buf, 256, &asn_buf); + //optional + if(flag & BIT0_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DMH_SVCID,1), ptr->dmh_svcidLen, ptr->dmh_svcid, 0x80, &asn_buf); + if(flag & BIT1_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSBD,2), ptr->smsbdLen, ptr->smsbd, 0x80, &asn_buf); + if(flag & BIT2_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSCC,3), ptr->smscauseLen, ptr->smscause, 0x80, &asn_buf); + if(flag & BIT3_TRUE) + buf_len = AddTLV(is41_sequenceTag(IS41PAR_SMSEVENTNOT,4), ptr->sms_eventnotLen, ptr->sms_eventnot, 0x80, &asn_buf); + return buf_len; +} + +int extract_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SM_ANLYZD_ARG *ptr; + + ptr = &opr_ptr->msg_list.smanlyzd_arg; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + if(decode_Is41Param(IS41PAR_SMSBRLEN, 2, NULL, ptr->sms_brlen, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + else + is41dec_print_absent("SMS_BearerLength"); + if(decode_Is41Param(IS41PAR_SMSBILLID, 32, &ptr->sms_billidLen, ptr->sms_billid, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + else + is41dec_print_absent("SMS_BillingID"); + if(decode_Is41Param(IS41PAR_SMSEVENT, 1, NULL, &ptr->sms_event, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + else + is41dec_print_absent("SMS_Event"); + if(decode_Is41Param(IS41PAR_SMSTID, MAX_IS41_VARPAR_LEN, &ptr->smstidLen, ptr->smstid, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + else + is41dec_print_absent("SMS_TeleserviceIdentifier"); + //optional + if(decode_Is41Param(IS41PAR_ESN, 4, NULL, ptr->esn, &asn_buf)) + ptr->param_flag |= BIT4_TRUE; + if(decode_Is41Param(IS41PAR_MDN, 32, &ptr->mdnLen, ptr->mdn, &asn_buf)) + ptr->param_flag |= BIT5_TRUE; + if(is41dec_MSID(&ptr->msid, &asn_buf)) + ptr->param_flag |= BIT6_TRUE; + if(decode_Is41Param(IS41PAR_SMSCID, MAX_IS41_VARPAR_LEN , &ptr->smscidLen, ptr->smscid, &asn_buf)) + ptr->param_flag |= BIT7_TRUE; + if(decode_Is41Param(IS41PAR_SMSDA, MAX_IS41_VARPAR_LEN, &ptr->smsdaLen, ptr->smsda, &asn_buf)) + ptr->param_flag |= BIT8_TRUE; + if(decode_Is41Param(IS41PAR_SMSPMCNT, 4, NULL, ptr->sms_pmcnt, &asn_buf)) + ptr->param_flag |= BIT9_TRUE; + if(decode_Is41Param(IS41PAR_SMSODA, MAX_IS41_VARPAR_LEN, &ptr->smsodaLen, ptr->smsoda, &asn_buf)) + ptr->param_flag |= BIT10_TRUE; + if(decode_Is41Param(IS41PAR_SMSODS, MAX_IS41_VARPAR_LEN, &ptr->smsodsLen, ptr->smsods, &asn_buf)) + ptr->param_flag |= BIT11_TRUE; + if(decode_Is41Param(IS41PAR_SMSOOA, MAX_IS41_VARPAR_LEN, &ptr->smsooaLen, ptr->smsooa, &asn_buf)) + ptr->param_flag |= BIT12_TRUE; + if(decode_Is41Param(IS41PAR_SMSOOS, MAX_IS41_VARPAR_LEN, &ptr->smsoosLen, ptr->smsoos, &asn_buf)) + ptr->param_flag |= BIT13_TRUE; + if(decode_Is41Param(IS41PAR_SMSOA, MAX_IS41_VARPAR_LEN, &ptr->smsoaLen, ptr->smsoa, &asn_buf)) + ptr->param_flag |= BIT14_TRUE; + if(decode_Is41Param(IS41PAR_TDO, 2, NULL, ptr->tdo, &asn_buf)) + ptr->param_flag |= BIT15_TRUE; + if(decode_Is41Param(IS41PAR_TOD, 3, NULL, ptr->tod, &asn_buf)) + ptr->param_flag |= BIT16_TRUE; + return 1; +} + +int extract_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + struct IS41_SM_ANLYZD_RSP *ptr; + + ptr = &opr_ptr->msg_list.smanlyzd_rsp; + ptr->param_flag = 0; + if(buf_len == 0) + { + is41_debug(IS41DB_ERR,"[IS41-Decode] Stopped,reason:buffer len=0!"); + return 0; + } + if(AsnDecode(buf, buf_len, 1, &decErr, &asn_buf) == -1) + return 0; + //optional + if(decode_Is41Param(IS41PAR_DMH_SVCID, 32, &ptr->dmh_svcidLen, ptr->dmh_svcid, &asn_buf)) + ptr->param_flag |= BIT0_TRUE; + if(decode_Is41Param(IS41PAR_SMSBD, 256, &ptr->smsbdLen, ptr->smsbd, &asn_buf)) + ptr->param_flag |= BIT1_TRUE; + if(decode_Is41Param(IS41PAR_SMSCC, 32, &ptr->smscauseLen, ptr->smscause, &asn_buf)) + ptr->param_flag |= BIT2_TRUE; + if(decode_Is41Param(IS41PAR_SMSEVENTNOT, 32, &ptr->sms_eventnotLen, ptr->sms_eventnot, &asn_buf)) + ptr->param_flag |= BIT3_TRUE; + return 1; +} + diff --git a/omc/plat/xapp/src/mapp/is41_coding.c b/omc/plat/xapp/src/mapp/is41_coding.c new file mode 100644 index 0000000..27ea87e --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_coding.c @@ -0,0 +1,490 @@ +/* MAP Update Location c file */ +/* created by daniel zhang 2004-06-17 */ +/* last modufy by xinyu yan 2006-05-15 */ +/* ------------------------------------ */ + +#include "map_includes.h" +#include "map_code.h" + +/* external functions */ +void is41_debug(DWORD mask, const char *fmt, ...); +void is41_showbuf(DWORD mask, BYTE *buf, int len); + +static int (*is41_assign_arg[128]) (); +static int (*is41_assign_rsp[128]) (); +static int (*is41_extract_arg[128]) (); +static int (*is41_extract_rsp[128]) (); +static char is41_opr_string[128][48] = { + "", + "HandoffMeasurementRequest", + "FacilitiesDirective", + "MobileOnChannel", + "HandoffBack", + "FacilitiesRelease", + "QualificationRequest", + "QualificationDirective", + "Blocking", + "Unblocking", + "ResetCircuit", + "TrunkTest", + "TrunkTestDisconnect", + "RegistrationNotification", + "RegistrationCancellation", + "LocationRequest", + "RoutingRequest", + "FeatureRequest", + "ServiceProfileRequest", + "ServiceProfileDirective", + "UnreliableRoamerDataDirective", + "CallDataREquest", + "MSInactive", + "TransferToNumberRequest", + "RedirectionRequest", + "HandoffToThird", + "FlashRequest", + "AuthenticationDirective", + "AuthenticationRequest", + "BaseStationChallenge", + "AuthenticationFailureReport", + "CountRequest", + "InterSystemPage", + "UnsolicitedResponse", + "BulkDeregistration", + "HandoffMeasurementRequest2", + "FacilitiesDirective2", + "HandoffBack2", + "HandoffToThird2", + "AuthenticationDirectiveForward", + "AuthenticationStatusReport", + "InformationBackward", + "InformationDirective", + "InformationForward", + "InterSystemAnswer", + "InterSystemPage2", + "InterSystemSetup", + "OriginationRequest", + "RandomVariableRequest", + "RedirectionDirective", + "RemoteUserInteractionDirective", + "SMSDeliveryBackward", + "SMSDeliveryForward", + "SMSDeliveryPointToPoint", + "SMSNotification", + "SMSRequest", + "", "", "", "", "", "", "", "", + "AnalyzedInformation", + "ConnectionFailureReport", + "ConnectResource", + "DisconnectResource", + "FacilitySelectedAndAvailable", + "InstructionRequest", + "Modify", + "ResetTimer", + "Search", + "SeizeResource", + "SRFDirective", + "TBusy", + "TNoAnswer", + "", "", "", + "BulkDisconnection", + "CallControlDirective", + "OAnswer", + "ODisconnect", + "CallRecoveryReport", + "TAnswer", + "TDisconnect", + "UnreliableCallData", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "ShortMessageAnalyzed", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" +}; + +void is41_register_encode_arg(u8 opr_code, int (*func)()) +{ + is41_assign_arg[opr_code] = func; +} + +void is41_register_encode_rsp(u8 opr_code, int (*func)()) +{ + is41_assign_rsp[opr_code] = func; +} + +void is41_register_decode_arg(u8 opr_code, int (*func)()) +{ + is41_extract_arg[opr_code] = func; +} + +void is41_register_decode_rsp(u8 opr_code, int (*func)()) +{ + is41_extract_rsp[opr_code] = func; +} + +void init_assignFunc_pointer() +{ + is41_register_encode_arg(IS41OPR_AuthenticationDirective, assign_is41AuthenticationDirective_arg); + is41_register_encode_rsp(IS41OPR_AuthenticationDirective, assign_is41AuthenticationDirective_rsp); + + is41_register_encode_arg(IS41OPR_AuthenticationFailureReport, assign_is41AuthenticationFailureReport_arg); + is41_register_encode_rsp(IS41OPR_AuthenticationFailureReport, assign_is41AuthenticationFailureReport_rsp); + + is41_register_encode_arg(IS41OPR_AuthenticationRequest, assign_is41AuthenticationRequest_arg); + is41_register_encode_rsp(IS41OPR_AuthenticationRequest, assign_is41AuthenticationRequest_rsp); + + is41_register_encode_arg(IS41OPR_AuthenticationStatusReport, assign_is41AuthenticationStatusReport_arg); + is41_register_encode_rsp(IS41OPR_AuthenticationStatusReport, assign_is41AuthenticationStatusReport_rsp); + + is41_register_encode_arg(IS41OPR_AuthenticationDirectiveForward, assign_is41AuthenticationDirectiveForward_arg); + + is41_register_encode_arg(IS41OPR_BaseStationChallenge, assign_is41BaseStationChallenge_arg); + is41_register_encode_rsp(IS41OPR_BaseStationChallenge, assign_is41BaseStationChallenge_rsp); + + is41_register_encode_arg(IS41OPR_CountRequest, assign_is41CountRequest_arg); + is41_register_encode_rsp(IS41OPR_CountRequest, assign_is41CountRequest_rsp); + + is41_register_encode_arg(IS41OPR_SMSDeliveryBackward, assign_Is41SmsDeliveryBackward_arg); + is41_register_encode_rsp(IS41OPR_SMSDeliveryBackward, assign_Is41SmsDeliveryBackward_rsp); + + is41_register_encode_arg(IS41OPR_SMSDeliveryForward, assign_Is41SmsDeliveryForward_arg); + is41_register_encode_rsp(IS41OPR_SMSDeliveryForward, assign_Is41SmsDeliveryForward_rsp); + + is41_register_encode_arg(IS41OPR_SMSDeliveryPointToPoint, assign_Is41SmsDeliveryPointToPoint_arg); + is41_register_encode_rsp(IS41OPR_SMSDeliveryPointToPoint, assign_Is41SmsDeliveryPointToPoint_rsp); + + is41_register_encode_arg(IS41OPR_SMSNotification, assign_Is41SmsNotification_arg); + is41_register_encode_rsp(IS41OPR_SMSNotification, assign_Is41SmsNotification_rsp); + + is41_register_encode_arg(IS41OPR_SMSRequest, assign_Is41SmsRequest_arg); + is41_register_encode_rsp(IS41OPR_SMSRequest, assign_Is41SmsRequest_rsp); + + is41_register_encode_arg(IS41OPR_RegistrationNotification, assign_is41RegistrationNotification_arg); + is41_register_encode_rsp(IS41OPR_RegistrationNotification, assign_is41RegistrationNotification_rsp); + is41_register_encode_arg(IS41OPR_RegistrationCancellation, assign_is41RegistrationCancellation_arg); + is41_register_encode_rsp(IS41OPR_RegistrationCancellation, assign_is41RegistrationCancellation_rsp); + is41_register_encode_arg(IS41OPR_LocationRequest, assign_is41LocationRequest_arg); + is41_register_encode_rsp(IS41OPR_LocationRequest, assign_is41LocationRequest_rsp); + is41_register_encode_arg(IS41OPR_RoutingRequest, assign_is41RoutingRequest_arg); + is41_register_encode_rsp(IS41OPR_RoutingRequest, assign_is41RoutingRequest_rsp); + is41_register_encode_arg(IS41OPR_MSInactive, assign_is41MSInactive_arg); + is41_register_encode_rsp(IS41OPR_MSInactive, assign_is41MSInactive_rsp); + + is41_register_encode_arg(IS41OPR_FeatureRequest, assign_is41FeatureRequest_arg); + is41_register_encode_rsp(IS41OPR_FeatureRequest, assign_is41FeatureRequest_rsp); + + is41_register_encode_arg(IS41OPR_QualificationDirective, assign_is41QualificationDirective_arg); + is41_register_encode_rsp(IS41OPR_QualificationDirective, assign_is41QualificationDirective_rsp); + + is41_register_encode_arg(IS41OPR_TransferToNumberRequest, assign_is41TransferToNumberRequest_arg); + is41_register_encode_rsp(IS41OPR_TransferToNumberRequest, assign_is41TransferToNumberRequest_rsp); + + is41_register_encode_arg(IS41OPR_RedirectionRequest, assign_is41RedirectionRequest_arg); + is41_register_encode_rsp(IS41OPR_RedirectionRequest, assign_is41RedirectionRequest_rsp); + + is41_register_encode_arg(IS41OPR_OriginationRequest, assign_is41OriginationRequest_arg); + is41_register_encode_rsp(IS41OPR_OriginationRequest, assign_is41OriginationRequest_rsp); + + is41_register_encode_arg(IS41OPR_AnalyzedInformation, assign_is41AnalyzedInformation_arg); + is41_register_encode_rsp(IS41OPR_AnalyzedInformation, assign_is41AnalyzedInformation_rsp); + + is41_register_encode_arg(IS41OPR_OAnswer, assign_is41OAnswer_arg); + + is41_register_encode_arg(IS41OPR_ODisconnect, assign_is41ODisconnect_arg); + is41_register_encode_rsp(IS41OPR_ODisconnect, assign_is41ODisconnect_rsp); + + is41_register_encode_arg(IS41OPR_TAnswer, assign_is41TAnswer_arg); + + is41_register_encode_arg(IS41OPR_TDisconnect, assign_is41TDisconnect_arg); + is41_register_encode_rsp(IS41OPR_TDisconnect, assign_is41TDisconnect_rsp); + + is41_register_encode_arg(IS41OPR_CallControlDirective, assign_is41CallControlDirective_arg); + is41_register_encode_rsp(IS41OPR_CallControlDirective, assign_is41CallControlDirective_rsp); + + is41_register_encode_arg(IS41OPR_SeizeResource, assign_is41SeizeResource_arg); + is41_register_encode_rsp(IS41OPR_SeizeResource, assign_is41SeizeResource_rsp); + + is41_register_encode_arg(IS41OPR_ConnectResource, assign_is41ConnectResource_arg); + + is41_register_encode_arg(IS41OPR_SRFDirective, assign_is41SRFDirective_arg); + is41_register_encode_rsp(IS41OPR_SRFDirective, assign_is41SRFDirective_rsp); + + is41_register_encode_arg(IS41OPR_ShortMessageAnalyzed, assign_is41ShortMessageAnalyzed_arg); + is41_register_encode_rsp(IS41OPR_ShortMessageAnalyzed, assign_is41ShortMessageAnalyzed_rsp); +} + +void init_extractFunc_pointer() +{ + is41_register_decode_arg(IS41OPR_AuthenticationDirective, extract_is41AuthenticationDirective_arg); + is41_register_decode_rsp(IS41OPR_AuthenticationDirective, extract_is41AuthenticationDirective_rsp); + + is41_register_decode_arg(IS41OPR_AuthenticationFailureReport, extract_is41AuthenticationFailureReport_arg); + is41_register_decode_rsp(IS41OPR_AuthenticationFailureReport, extract_is41AuthenticationFailureReport_rsp); + + is41_register_decode_arg(IS41OPR_AuthenticationRequest, extract_is41AuthenticationRequest_arg); + is41_register_decode_rsp(IS41OPR_AuthenticationRequest, extract_is41AuthenticationRequest_rsp); + + is41_register_decode_arg(IS41OPR_AuthenticationStatusReport, extract_is41AuthenticationStatusReport_arg); + is41_register_decode_rsp(IS41OPR_AuthenticationStatusReport, extract_is41AuthenticationStatusReport_rsp); + + is41_register_decode_arg(IS41OPR_AuthenticationDirectiveForward, extract_is41AuthenticationDirectiveForward_arg); + + is41_register_decode_arg(IS41OPR_BaseStationChallenge, extract_is41BaseStationChallenge_arg); + is41_register_decode_rsp(IS41OPR_BaseStationChallenge, extract_is41BaseStationChallenge_rsp); + + is41_register_decode_arg(IS41OPR_CountRequest, extract_is41CountRequest_arg); + is41_register_decode_rsp(IS41OPR_CountRequest, extract_is41CountRequest_rsp); + + is41_register_decode_arg(IS41OPR_SMSDeliveryBackward, extract_Is41SmsDeliveryBackward_arg); + is41_register_decode_rsp(IS41OPR_SMSDeliveryBackward, extract_Is41SmsDeliveryBackward_rsp); + + is41_register_decode_arg(IS41OPR_SMSDeliveryForward, extract_Is41SmsDeliveryForward_arg); + is41_register_decode_rsp(IS41OPR_SMSDeliveryForward, extract_Is41SmsDeliveryForward_rsp); + + is41_register_decode_arg(IS41OPR_SMSDeliveryPointToPoint, extract_Is41SmsDeliveryPointToPoint_arg); + is41_register_decode_rsp(IS41OPR_SMSDeliveryPointToPoint, extract_Is41SmsDeliveryPointToPoint_rsp); + + is41_register_decode_arg(IS41OPR_SMSNotification, extract_Is41SmsNotification_arg); + is41_register_decode_rsp(IS41OPR_SMSNotification, extract_Is41SmsNotification_rsp); + + is41_register_decode_arg(IS41OPR_SMSRequest, extract_Is41SmsRequest_arg); + is41_register_decode_rsp(IS41OPR_SMSRequest, extract_Is41SmsRequest_rsp); + + is41_register_decode_arg(IS41OPR_RegistrationNotification, extract_is41RegistrationNotification_arg); + is41_register_decode_rsp(IS41OPR_RegistrationNotification, extract_is41RegistrationNotification_rsp); + is41_register_decode_arg(IS41OPR_RegistrationCancellation, extract_is41RegistrationCancellation_arg); + is41_register_decode_rsp(IS41OPR_RegistrationCancellation, extract_is41RegistrationCancellation_rsp); + is41_register_decode_arg(IS41OPR_LocationRequest, extract_is41LocationRequest_arg); + is41_register_decode_rsp(IS41OPR_LocationRequest, extract_is41LocationRequest_rsp); + is41_register_decode_arg(IS41OPR_RoutingRequest, extract_is41RoutingRequest_arg); + is41_register_decode_rsp(IS41OPR_RoutingRequest, extract_is41RoutingRequest_rsp); + is41_register_decode_arg(IS41OPR_MSInactive, extract_is41MSInactive_arg); + is41_register_decode_rsp(IS41OPR_MSInactive, extract_is41MSInactive_rsp); + + is41_register_decode_arg(IS41OPR_FeatureRequest, extract_is41FeatureRequest_arg); + is41_register_decode_rsp(IS41OPR_FeatureRequest, extract_is41FeatureRequest_rsp); + + is41_register_decode_arg(IS41OPR_QualificationDirective, extract_is41QualificationDirective_arg); + is41_register_decode_rsp(IS41OPR_QualificationDirective, extract_is41QualificationDirective_rsp); + + is41_register_decode_arg(IS41OPR_TransferToNumberRequest, extract_is41TransferToNumberRequest_arg); + is41_register_decode_rsp(IS41OPR_TransferToNumberRequest, extract_is41TransferToNumberRequest_rsp); + + is41_register_decode_arg(IS41OPR_RedirectionRequest, extract_is41RedirectionRequest_arg); + is41_register_decode_rsp(IS41OPR_RedirectionRequest, extract_is41RedirectionRequest_rsp); + + is41_register_decode_arg(IS41OPR_OriginationRequest, extract_is41OriginationRequest_arg); + is41_register_decode_rsp(IS41OPR_OriginationRequest, extract_is41OriginationRequest_rsp); + + is41_register_decode_arg(IS41OPR_AnalyzedInformation, extract_is41AnalyzedInformation_arg); + is41_register_decode_rsp(IS41OPR_AnalyzedInformation, extract_is41AnalyzedInformation_rsp); + + is41_register_decode_arg(IS41OPR_OAnswer, extract_is41OAnswer_arg); + + is41_register_decode_arg(IS41OPR_ODisconnect, extract_is41ODisconnect_arg); + is41_register_decode_rsp(IS41OPR_ODisconnect, extract_is41ODisconnect_rsp); + + is41_register_decode_arg(IS41OPR_TAnswer, extract_is41TAnswer_arg); + + is41_register_decode_arg(IS41OPR_TDisconnect, extract_is41TDisconnect_arg); + is41_register_decode_rsp(IS41OPR_TDisconnect, extract_is41TDisconnect_rsp); + + is41_register_decode_arg(IS41OPR_CallControlDirective, extract_is41CallControlDirective_arg); + is41_register_decode_rsp(IS41OPR_CallControlDirective, extract_is41CallControlDirective_rsp); + + is41_register_decode_arg(IS41OPR_SeizeResource, extract_is41SeizeResource_arg); + is41_register_decode_rsp(IS41OPR_SeizeResource, extract_is41SeizeResource_rsp); + + is41_register_decode_arg(IS41OPR_ConnectResource, extract_is41ConnectResource_arg); + + is41_register_decode_arg(IS41OPR_SRFDirective, extract_is41SRFDirective_arg); + is41_register_decode_rsp(IS41OPR_SRFDirective, extract_is41SRFDirective_rsp); + + is41_register_decode_arg(IS41OPR_ShortMessageAnalyzed, extract_is41ShortMessageAnalyzed_arg); + is41_register_decode_rsp(IS41OPR_ShortMessageAnalyzed, extract_is41ShortMessageAnalyzed_rsp); +} + +int is41_u8Type_to_charType(u8 type,char *cType) +{ + if(type >= 128) + return 0; + else if(strlen(is41_opr_string[type]) == 0) + return 0; + strcpy(cType, is41_opr_string[type]); + return 1; +} + +/*int is41_u8Type_to_charType(u8 type,char *cType) +{ + switch (type) + { + // Authentication service operation + case IS41OPR_AuthenticationDirective: + sprintf(cType,"AuthenticationDirective"); + break; + case IS41OPR_AuthenticationFailureReport: + sprintf(cType,"AuthenticationFailureReport"); + break; + case IS41OPR_AuthenticationRequest: + sprintf(cType,"AuthenticationRequest"); + break; + case IS41OPR_AuthenticationStatusReport: + sprintf(cType,"AuthenticationStatusReport"); + break; + case IS41OPR_AuthenticationDirectiveForward: + sprintf(cType,"AuthenticationDirectiveForward"); + break; + case IS41OPR_CountRequest: + sprintf(cType,"CountRequest"); + break; + case IS41OPR_BaseStationChallenge: + sprintf(cType,"BaseStationChallenge"); + break; + case IS41OPR_SMSDeliveryBackward: + sprintf(cType,"SMSDeliveryBackward"); + break; + case IS41OPR_SMSDeliveryForward: + sprintf(cType,"SMSDeliveryForward"); + break; + case IS41OPR_SMSDeliveryPointToPoint: + sprintf(cType,"SMSDeliveryPointToPoint"); + break; + case IS41OPR_SMSNotification: + sprintf(cType,"IS41OPR_SMSNotification"); + break; + case IS41OPR_SMSRequest: + sprintf(cType,"SMSRequest"); + break; + + case IS41OPR_RegistrationNotification: + sprintf(cType,"REGNOT"); + break; + case IS41OPR_RegistrationCancellation: + sprintf(cType,"REGCANC"); + break; + case IS41OPR_LocationRequest: + sprintf(cType,"LOCREQ"); + break; + case IS41OPR_RoutingRequest: + sprintf(cType,"ROUTREQ"); + break; + case IS41OPR_MSInactive: + sprintf(cType,"MSINACT"); + break; + case IS41OPR_FeatureRequest: + sprintf(cType,"FEATREQ"); + break; + case IS41OPR_QualificationDirective: + sprintf(cType,"QUALDIR"); + break; + case IS41OPR_TransferToNumberRequest: + sprintf(cType,"TRANUMREQ"); + break; + case IS41OPR_RedirectionRequest: + sprintf(cType,"REDREQ"); + break; + + default: // unknown operation +// sprintf(info_str,"MAPP error:the operation is unknown:%d",opr_ptr->message_type); +// xap_send_error(info_str); + return 0; + } + return 1; +}*/ + +int build_is41param(struct MapOprSrv_struct *opr_ptr,u8 *buf) // build is41 service paramter +{ + ASN_BUF asn_buf; + u8 seq_flag=1; + int param_len = 0; + u8 info_str[1024]; + char charName[128]; + + if (opr_ptr == NULL || buf == NULL) + return 0; + if (!is41_u8Type_to_charType(opr_ptr->message_type,charName)) + { + is41_debug(IS41DB_ENCODE,"[IS41-Encode]Building param,Operation code:%d not correct",opr_ptr->message_type); + return 0; + } + + if (opr_ptr->message_flag == MAP_REQUEST) + { + is41_debug(IS41DB_ENCODE,"[IS41-Encode] MAP_REQUEST,OPRType=%s",charName); + param_len = (*is41_assign_arg[opr_ptr->message_type]) (opr_ptr,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + is41_debug(IS41DB_ENCODE,"[IS41-Encode] MAP_RESPONSE,OPRType=%s",charName); + param_len = (*is41_assign_rsp[opr_ptr->message_type])(opr_ptr,buf); + } + else + return 0; + + if (seq_flag == 1 && param_len > 0) + { + memcpy(info_str,buf,param_len%1024); + AsnEncode(buf,256,&asn_buf); + param_len = AddTLV(SET_NATIONAL,param_len,info_str,0xe0,&asn_buf); + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Completed,len=%d",param_len); + is41_showbuf(IS41DB_ENCODE,buf,param_len); + } + else + { + AsnEncode(buf,256,&asn_buf); + param_len = AddTLV(SET_NATIONAL,0,info_str,0xc0,&asn_buf); + is41_debug(IS41DB_ENCODE,"[IS41-Encode] Completed,paramlen=0"); + is41_showbuf(IS41DB_ENCODE,buf,param_len); + } + return param_len; +} + +u8 extract_is41param(struct MapOprSrv_struct *opr_ptr,u8 opr_code,u8 opr_flag,u32 pre_param_len,u8 *pre_param) +{ + ASN_BUF asn_buf; +// u8 info_str[1024]; + u8 param[1024]; + int param_len; + char charName[128]; + + asn_decode(pre_param,1,&asn_buf); + param_len = get_tlv(SET_NATIONAL,param,&asn_buf); + + if (param_len == -1) // not has sequence id + { + param_len = pre_param_len; + memcpy(param,pre_param,param_len); + } + + if (!is41_u8Type_to_charType(opr_code,charName)) + { + is41_debug(IS41DB_ENCODE,"[IS41-Encode]Extracting param,Operation code:%d not correct",opr_code); + return 0; + } + + if (opr_flag == MAP_INDICATE) + { + is41_debug(IS41DB_DECODE,"[IS41-Decode]USER->IS41P,IS41_INDICATE,OPRType=%s",charName); + is41_showbuf(IS41DB_DECODE,param,param_len); + if (*is41_extract_arg[opr_code] != NULL) + { + return (*is41_extract_arg[opr_code])(opr_ptr,param_len,param); + } + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode]No decode function for IS41_INDICATE opr_code=%d",opr_code); + return 0; + } + } + else if (opr_flag == MAP_CONFIRM) + { + is41_debug(IS41DB_DECODE,"[IS41-Decode]USER->IS41P,MAP_CONFIRM,OPRType=%s",charName); + is41_showbuf(IS41DB_DECODE,param,param_len); + if (*is41_extract_rsp[opr_code] != NULL) + return (*is41_extract_rsp[opr_code])(opr_ptr,param_len,param); + else + { + is41_debug(IS41DB_ERR,"[IS41-Decode]No decode function for IS41_CONFIRM opr_code=%d",opr_code); + return 0; + } + } + + return 1; +} diff --git a/omc/plat/xapp/src/mapp/is41_debug.c b/omc/plat/xapp/src/mapp/is41_debug.c new file mode 100644 index 0000000..5b102b5 --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_debug.c @@ -0,0 +1,3650 @@ +/* IS41 debug function c file */ +/* created by daniel zhang 2004-06-18 */ +/* last modufy by daniel zhang 2004-06-18 */ +/* version 1.0 */ +/* ------------------------------------ */ + +#include "../../../debug/src/include/debug.h" +#include "map_includes.h" +#include "is41_code.h" + +static char debug_buf[5120]; +BYTE is41DebugFull = 0; +static unsigned long debug_mask = 0; + +static char help_info[] = "Commands provided now:\r\n\ +help\r\n\ +log all Output all debug information\r\n\ +log none Turn off all information\r\n\ +log error on/off Show error information\r\n\ +"; + + +void is41_debug_setup() +{ +#if MAP_CODE_DEBUG + DWORD ascout_id[20] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,17,4}; + DWORD ascin_id[20] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,17,3}; + DWORD status_id[20] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,17,1}; + DWORD name_id[20] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,17,2}; + BYTE debug_status = 1; + + sprintf(is41_ver, "R9V00_T1"); + debug_set_response(15, ascout_id, debug_buf, 1); + debug_set_response(15, ascin_id, asc_in, 1); + debug_set_response(15, status_id, &debug_status, 1); + debug_set_response(15, name_id, is41_ver, strlen(is41_ver)); + +#endif +} + +void is41_log(char *info) +{ + if(strlen(debug_buf) + strlen(info) > 2048) + { + is41DebugFull = 1; + return; + } +// printf("send log\n"); + strncat(debug_buf, info, 2048); + strcat(debug_buf, "\r\n"); + return; +} + +void is41_debug(DWORD mask, const char *fmt, ...) +{ +#if MAP_CODE_DEBUG + va_list ap; + char buf[1024]; + + if((mask & debug_mask) == 0) + return; + +/* if(debug_mask & SCCPDB_TIME) + { + struct timeval tv; + struct timezone tz; + struct tm *t; + char timestr[32]; + gettimeofday(&tv, &tz); + t=localtime(&tv.tv_sec); + sprintf(timestr, "(%d:%d:%d.%ld):",t->tm_hour,t->tm_min,t->tm_sec,tv.tv_usec); + is41_log(timestr); + }*/ + + if(mask & IS41DB_ERR) + strcat(debug_buf, "\33[31m"); + + va_start(ap, fmt); + vsnprintf(buf, 1024, fmt, ap); + va_end(ap); + strcat(buf,"\33[37m"); + is41_log(buf); +#endif +} + +void is41_showbuf(DWORD mask, BYTE *buf, int len) +{ +#if MAP_CODE_DEBUG + int i = 0, j = 0, linemax = 24; + char info[1024]; + +/* if((debug_mask & SCCPDB_MSG) == 0 || (debug_mask & mask) == 0 || sccpDebugFull) + return;*/ + + if(len >= 256) + len = 256; + + while(i * 24 < len) + { + if((linemax = len - 24 * i) > 24) + linemax = 24; + for(j = 0; j < linemax; j ++) + { + sprintf(info + 3 * j, "%02X ", buf[24 * i + j]); + } + is41_log(info); + i ++; + } +#endif +} + + +int parsecmd(char *cmdstr) +{ + if(strstr(cmdstr,"help") != NULL || strstr(cmdstr,"?")!=NULL) + is41_log(help_info); + else if(strstr(cmdstr, "log all") != NULL) + { +// sccpFilterIndex = 0; + debug_mask = 0xFFFFFFFF; + } + else if(strstr(cmdstr, "log none") != NULL) + { +// sccpFilterIndex = 0; + debug_mask = 0; + } + else if(strstr(cmdstr, "log error on") != NULL) + debug_mask |= IS41DB_ERR; + else if(strstr(cmdstr, "log error off") != NULL) + debug_mask &= (~IS41DB_ERR); + else if(strstr(cmdstr, "Test Auc") != NULL) + { + printf("CMD OK\n"); + } + is41_log("Command OK."); + return 1; +} + + +void is41_debug_timer() +{ +#if MAP_CODE_DEBUG + BYTE npage, nline; + + if(strlen(asc_in) <= 1) + return; + debug_buf[0] = '\0'; + npage = asc_in[0] - 1; + if(npage == 0) + { + parsecmd(asc_in + 1); + asc_in[0] = '\0'; + return; + } + else + nline = atoi(asc_in + 1); + switch(npage) + { + case 1: //csta +// sccp_debug_csta(npage, nline); + break; + case 2: //local subsystem +// sccp_debug_local(npage, nline); + break; + case 3: //related subsystem +// sccp_debug_related(npage, nline); + break; + } + asc_in[0] = '\0'; +#endif +} + + +int debug_show_REGNOT_ARG(IS41_REGNOT_ARG *ptr,char *buf) +{ + u32 flag,flag1; + struct IS41_PAR_WIN_CAP *ptr1; + int i; + char tempchar[512]; + + flag = ptr->param_flag; + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) //QualificationInformationCode + { + sprintf(tempchar,"QUALCODE=%02x,",ptr->qualcode); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) //SystemMyTypeCode + { + sprintf(tempchar,"MYTYP=%02x,",ptr->mytyp); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT5_TRUE)>0) //Availability Type + { + sprintf(tempchar,"AVTYP=%02x,",ptr->avtyp); + strcat(buf,tempchar); + } + + if((flag & BIT6_TRUE)>0) //BorderCellAccess + { + sprintf(tempchar,"BORDACC=%02x,",ptr->bordacc); + strcat(buf,tempchar); + } + + if((flag & BIT7_TRUE)>0) //ControlChannelData + { + sprintf(tempchar,"CCDATA=%02x%02x%02x%02x,",ptr->ccdata[0],ptr->ccdata[1],ptr->ccdata[2],ptr->ccdata[3]); + strcat(buf,tempchar); + } + + if((flag & BIT8_TRUE)>0) //ExtendedMSCID + { + sprintf(tempchar,"EXTMSCID=%02x%02x%02x%02x,",ptr->extmscid[0],ptr->extmscid[1],ptr->extmscid[2],ptr->extmscid[3]); + strcat(buf,tempchar); + } + + if((flag & BIT9_TRUE)>0) //LocationAreaID + { + sprintf(tempchar,"LOCID=%02x%02x,",ptr->locid[0],ptr->locid[1]); + strcat(buf,tempchar); + } + + if((flag & BIT10_TRUE)>0) //pcssn + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if((flag & BIT11_TRUE)>0) //ReceivedSignalQuality + { + sprintf(tempchar,"RSIGQUAL=%02x,",ptr->rsigqual); + strcat(buf,tempchar); + } + + if((flag & BIT12_TRUE)>0) //rpttyp + { + sprintf(tempchar,"RPTTYP=%02x,",ptr->rpttyp); + strcat(buf,tempchar); + } + + if((flag & BIT13_TRUE)>0) //senderin + { + strcat(buf,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ptr->senderin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT14_TRUE)>0) //SMS_DestinationAddress + { + strcat(buf,"SMSADDR="); + for (i=0;ismsaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr->smsaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT15_TRUE)>0) //smsmwi + strcat(buf,"SMSMWI,"); + + if((flag & BIT16_TRUE)>0) //sysaccdata + { + sprintf(tempchar,"SYSACCDATA=%02x%02x%02x%02x%02x,",ptr->sysaccdata[0],ptr->sysaccdata[1],ptr->sysaccdata[2],ptr->sysaccdata[3],ptr->sysaccdata[4]); + strcat(buf,tempchar); + } + + if((flag & BIT17_TRUE)>0) //sysacctype + { + sprintf(tempchar,"SYSACCTYPE=%02x,",ptr->sysacctype); + strcat(buf,tempchar); + } + + if((flag & BIT18_TRUE)>0) //syscap + { + sprintf(tempchar,"SYSCAP=%02x,",ptr->syscap); + strcat(buf,tempchar); + } + + if((flag & BIT19_TRUE)>0) //termtyp + { + sprintf(tempchar,"TERMTYP=%02x,",ptr->termtyp); + strcat(buf,tempchar); + } + + if((flag & BIT20_TRUE)>0) //transcap + { + strcat(buf,"TRANSCAP="); + for (i=0;itranscapLen;i++) + { + sprintf(tempchar,"%02x",ptr->transcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT21_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + strcat(buf,"WINCAP-TRIGGERCAP="); + for (i=0;itriggercapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->triggercap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"WINCAP-WINOPRCAP="); + for (i=0;iwinoprcapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->winoprcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + if (flag > 0) + return 1; + return 0; +} + +int debug_show_profile(struct IS41_PAR_PROFILE *ptr,u8 *buf) +{ + u32 flag1; + struct IS41_PAR_TRIGGER_LIST *ptr1; + u32 flag; + u8 i,triglistnum; + char tempchar[512]; + + flag = ptr->param_flag; + + if((flag & BIT0_TRUE)>0) + { + strcat(buf,"AUTHCAP="); + for (i=0;iauthcapLen;i++) + { + sprintf(tempchar,"%02x",ptr->authcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT1_TRUE)>0) + { + strcat(buf,"CFI="); + for (i=0;icfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->cfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT2_TRUE)>0) + { + strcat(buf,"CARDGTS="); + for (i=0;icardgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->cardgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"ACDGTS="); + for (i=0;iacdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->acdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"ABDGTS="); + for (i=0;iabdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->abdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"BILLDGTS="); + for (i=0;ibilldgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->billdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"GEOAUTH="); + for (i=0;igeoauthLen;i++) + { + sprintf(tempchar,"%02x",ptr->geoauth[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"MWNCOUNT="); + for (i=0;imwncountLen;i++) + { + sprintf(tempchar,"%02x",ptr->mwncount[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"MWNTYPE="); + for (i=0;imwntypeLen;i++) + { + sprintf(tempchar,"%02x",ptr->mwntype[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT10_TRUE)>0) + { + sprintf(tempchar,"ORIGIND=%02x,",ptr->origind); + strcat(buf,tempchar); + } + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"ORIGTRIG="); + for (i=0;iorigtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->origtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT12_TRUE)>0) + { + sprintf(tempchar,"PACAIND=%02x,",ptr->pacaind); + strcat(buf,tempchar); + } + if((flag & BIT13_TRUE)>0) + { + sprintf(tempchar,"PLIND=%02x,",ptr->plind); + strcat(buf,tempchar); + } + if((flag & BIT14_TRUE)>0) + { + strcat(buf,"RESDGTS="); + for (i=0;iresdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->resdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT15_TRUE)>0) + { + strcat(buf,"ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT16_TRUE)>0) + { + sprintf(tempchar,"SMSORGRES=%02x,",ptr->smsorgres); + strcat(buf,tempchar); + } + if((flag & BIT17_TRUE)>0) + { + sprintf(tempchar,"SMSTERMRES=%02x,",ptr->smstermres); + strcat(buf,tempchar); + } + if((flag & BIT18_TRUE)>0) + { + strcat(buf,"SPINIPIN="); + for (i=0;ispinipinLen;i++) + { + sprintf(tempchar,"%02x",ptr->spinipin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT19_TRUE)>0) + { + strcat(buf,"SPINITRIG="); + for (i=0;ispinitrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->spinitrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT20_TRUE)>0) + { + sprintf(tempchar,"SMSTERMRES=%02x,",ptr->termres); + strcat(buf,tempchar); + } + if((flag & BIT21_TRUE)>0) + { + strcat(buf,"TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT22_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + strcat(buf,"TRIGADRLIST-TRIGLIST-DESTADDR="); + for (i=0;idestaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr1->destaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"TRIGADRLIST-TRIGLIST-WINTRIGLIST="); + for (i=0;iwintriglistLen;i++) + { + sprintf(tempchar,"%02x",ptr1->wintriglist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_REGNOT_RSP(struct IS41_REGNOT_RSP *ptr,char *buf) +{ + u32 flag; + int i; + char tempchar[512]; + + buf[0] = 0; + + flag = ptr->param_flag; + + if((flag & BIT0_TRUE)>0) //SystemMyTypeCode + { + sprintf(tempchar,"MYTYP=%02x,",ptr->mytyp); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT1_TRUE)>0) //AuthorizationDenied + { + sprintf(tempchar,"AUTHDEN=%02x,",ptr->authden); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //AuthorizationPeriod + { + sprintf(tempchar,"AUTHPER=%02x%02x,",ptr->authper[0],ptr->authper[1]); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) //ControlChannelData + { + sprintf(tempchar,"CCDATA=%02x%02x%02x%02x,",ptr->ccdata[0],ptr->ccdata[1],ptr->ccdata[2],ptr->ccdata[3]); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) //DeniedAuthorizationPeriod + { + strcat(buf,"DENAUTHPER="); + for (i=0;idenauthperLen;i++) + { + sprintf(tempchar,"%02x",ptr->denauthper[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT5_TRUE)>0) //Digits carrier + { + strcat(buf,"DIGITS CARRIER="); + for (i=0;idigitsCarrierLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsCarrier[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) //Digits Destination + { + strcat(buf,"DIGITS DEST="); + for (i=0;idigitsDestLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsDest[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT7_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + +/* Profile **macro** */ + if ((flag & BIT8_TRUE) > 0) + { + debug_show_profile(&ptr->profile,buf); + } +/* Profile **macro** */ + +/* if((flag & BIT9_TRUE)>0) //ReceivedSignalQuality + { + sprintf(tempchar,"RSIGQUAL=%02x,",ptr->rsigqual); + strcat(buf,tempchar); + }*/ + + if((flag & BIT10_TRUE)>0) //senderin + { + strcat(buf,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ptr->senderin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT11_TRUE)>0) + strcat(buf,"SMSMWI"); + + + if((flag & BIT12_TRUE)>0) //sysaccdata + { + sprintf(tempchar,"SYSACCDATA=%02x%02x%02x%02x%02x,",ptr->sysaccdata[0],ptr->sysaccdata[1],ptr->sysaccdata[2],ptr->sysaccdata[3],ptr->sysaccdata[4]); + strcat(buf,tempchar); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_LOCREQ_ARG(struct IS41_LOCREQ_ARG *ptr,char *buf) +{ + int i; + u32 flag,flag1; + struct IS41_PAR_WIN_CAP *ptr1; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) + { + strcat(buf,"BILLID="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",ptr->billid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT1_TRUE)>0) + { + strcat(buf,"DIGITS="); + for (i=0;idigitsLen;i++) + { + sprintf(tempchar,"%02x",ptr->digits[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT2_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) //SystemMyTypeCode + { + sprintf(tempchar,"MYTYP=%02x,",ptr->mytyp); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"CPNDGTS1="); + for (i=0;icpndgts1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"CPNDGTS2="); + for (i=0;icpndgts2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPSUB="); + for (i=0;icpsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->cpsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT8_TRUE)>0) + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"RNDGTS="); + for (i=0;irndgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->rndgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"RSUB="); + for (i=0;irsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->rsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT11_TRUE)>0) + { + sprintf(tempchar,"TAT=%02x,",ptr->tat); + strcat(buf,tempchar); + } + + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"TRANSCAP="); + for (i=0;itranscapLen;i++) + { + sprintf(tempchar,"%02x",ptr->transcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT13_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + strcat(buf,"WINCAP-TRIGGERCAP="); + for (i=0;itriggercapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->triggercap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"WINCAP-WINOPRCAP="); + for (i=0;iwinoprcapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->winoprcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_param_isterm(struct IS41_PAR_ISTERM *ptr,u8 *buf) +{ + u32 flag; + u8 i; + char tempchar[512]; + + flag = ptr->param_flag; + + if((flag & BIT0_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-DESTDGTS="); + for (i=0;idestdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->destdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT1_TRUE)>0) //MSCID + { + strcat(buf,"TERMLIST-ISTERM-MSCID="); + for (i=0;i<3;i++) + { + sprintf(tempchar,"%02x",ptr->mscid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + +// optional part---> + if((flag & BIT2_TRUE)>0) + { + sprintf(tempchar,"TERMLIST-ISTERM-ACCDEN=%02x,",ptr->accden); + strcat(buf,tempchar); + } + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-CARDGTS="); + for (i=0;icardgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->cardgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) //esn + { + sprintf(tempchar,"TERMLIST-ISTERM-ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-LEGINFO="); + for (i=0;ileginfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->leginfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"TERMLIST-ISTERM-TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if (flag > 0) + return 1; + return 0; +} + +int debug_show_param_locterm(struct IS41_PAR_LOCTERM *ptr,u8 *buf) +{ + u32 flag; + u8 i; + char tempchar[512]; + + flag = ptr->param_flag; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tempchar,"TERMLIST-LOCTERM-ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tempchar,"TERMLIST-LOCTERM-MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + if((flag & BIT2_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-TERMTRMT="); + for (i=0;itermtrmtLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrmt[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + +// optional part---> + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-ALRTCODE="); + for (i=0;ialrtcodeLen;i++) + { + sprintf(tempchar,"%02x",ptr->alrtcode[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-CARDGTS="); + for (i=0;icardgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->cardgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-DESTDGTS="); + for (i=0;idestdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->destdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-LEGINFO="); + for (i=0;ileginfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->leginfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-OTFI="); + for (i=0;iotfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->otfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-VMSPIN="); + for (i=0;ivmspinLen;i++) + { + sprintf(tempchar,"%02x",ptr->vmspin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"TERMLIST-LOCTERM-VMBOX="); + for (i=0;ivmboxLen;i++) + { + sprintf(tempchar,"%02x",ptr->vmbox[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + + +int debug_show_param_pstnterm(struct IS41_PAR_PSTNTERM *ptr,u8 *buf) +{ + u32 flag; + u8 i; + char tempchar[512]; + + flag = ptr->param_flag; + + if((flag & BIT0_TRUE)>0) + { + strcat(buf,"TERMLIST-PSTNTERM-DESTDGTS="); + for (i=0;idestdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->destdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + +// optional part---> + if((flag & BIT1_TRUE)>0) + { + strcat(buf,"TERMLIST-PSTNTERM-CARDGTS="); + for (i=0;icardgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->cardgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT2_TRUE)>0) //esn + { + sprintf(tempchar,"TERMLIST-PSTNTERM-ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"TERMLIST-PSTNTERM-LEGINFO="); + for (i=0;ileginfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->leginfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT4_TRUE)>0) //min + { + sprintf(tempchar,"TERMLIST-PSTNTERM-MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"TERMLIST-PSTNTERM-ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"TERMLIST-PSTNTERM-TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + + +int debug_show_param_termlist(struct IS41_PAR_TERMLIST *ptr,u8 *buf) +{ + u32 flag; + + flag = ptr->param_flag; + + if ((flag & BIT0_TRUE) > 0) + { + debug_show_param_isterm(&ptr->isterm,buf); + } + + if ((flag & BIT1_TRUE) > 0) + { + debug_show_param_locterm(&ptr->locterm,buf); + } + + if ((flag & BIT2_TRUE) > 0) + { + debug_show_param_pstnterm(&ptr->pstnterm,buf); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_LOCREQ_RSP(struct IS41_LOCREQ_RSP *ptr,char *buf) +{ + u32 flag,flag1; + struct IS41_PAR_TRIGGER_LIST *ptr1; + u8 i,triglistnum; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT3_TRUE)>0) + { + sprintf(tempchar,"ACCDEN=%02x,",ptr->accden); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"ANNLIST="); + for (i=0;iannlistLen;i++) + { + sprintf(tempchar,"%02x",ptr->annlist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"CPNSTRG1="); + for (i=0;icpnstrg1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPNSTRG2="); + for (i=0;icpnstrg2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"DIGITS CARRIER="); + for (i=0;idigitsCarrierLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsCarrier[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"DIGITS DEST="); + for (i=0;idigitsDestLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsDest[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"ACDGTS="); + for (i=0;iacdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->acdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"ABDGTS="); + for (i=0;iabdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->abdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"BILLDGTS="); + for (i=0;ibilldgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->billdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"REDIND="); + for (i=0;iredindLen;i++) + { + sprintf(tempchar,"%02x",ptr->redind[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT13_TRUE)>0) + { + strcat(buf,"GRPINFO="); + for (i=0;igrpinfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->grpinfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + +// if((flag & BIT11_TRUE)>0) + // buf_len = AddTLV(is41_sequenceTag(IS41PAR_TAT,12),1,&ptr->tat,0x80,&asn_buf); + + if((flag & BIT14_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT15_TRUE)>0) + { + strcat(buf,"NATIME="); + for (i=0;inatimeLen;i++) + { + sprintf(tempchar,"%02x",ptr->natime[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT16_TRUE)>0) + { + strcat(buf,"OTFI="); + for (i=0;iotfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->otfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT17_TRUE)>0) + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if((flag & BIT18_TRUE)>0) + { + strcat(buf,"RNDGTS="); + for (i=0;irndgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->rndgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT19_TRUE)>0) + { + strcat(buf,"RNSTRING="); + for (i=0;irnstringLen;i++) + { + sprintf(tempchar,"%02x",ptr->rnstring[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT20_TRUE)>0) + { + strcat(buf,"RSUB="); + for (i=0;irsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->rsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT21_TRUE)>0) + { + strcat(buf,"ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if ((flag & BIT22_TRUE) > 0) + { + debug_show_param_termlist(&ptr->termlist,buf); + } + + if((flag & BIT23_TRUE)>0) + { + strcat(buf,"TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT24_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + strcat(buf,"TRIGADRLIST-TRIGLIST-DESTADDR="); + for (i=0;idestaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr1->destaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"TRIGADRLIST-TRIGLIST-WINTRIGLIST="); + for (i=0;iwintriglistLen;i++) + { + sprintf(tempchar,"%02x",ptr1->wintriglist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_ROUTREQ_ARG(struct IS41_ROUTREQ_ARG *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) + { + strcat(buf,"BILLID="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",ptr->billid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT1_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) //SystemMyTypeCode + { + sprintf(tempchar,"MYTYP=%02x,",ptr->mytyp); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"ALRTCODE="); + for (i=0;ialrtcodeLen;i++) + { + sprintf(tempchar,"%02x",ptr->alrtcode[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPNSTRG1="); + for (i=0;icpnstrg1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"CPNSTRG2="); + for (i=0;icpnstrg2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"CPSUB="); + for (i=0;icpsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->cpsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"DESTDGTS="); + for (i=0;idestdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->destdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"ACDGTS="); + for (i=0;iacdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->acdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"ABDGTS="); + for (i=0;iabdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->abdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"BILLDGTS="); + for (i=0;ibilldgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->billdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT13_TRUE)>0) + { + strcat(buf,"LEGINFO="); + for (i=0;ileginfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->leginfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT14_TRUE)>0) //LocationAreaID + { + sprintf(tempchar,"LOCID=%02x%02x,",ptr->locid[0],ptr->locid[1]); + strcat(buf,tempchar); + } + + if((flag & BIT15_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT16_TRUE)>0) + { + strcat(buf,"MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT17_TRUE)>0) + { + strcat(buf,"NATIME="); + for (i=0;inatimeLen;i++) + { + sprintf(tempchar,"%02x",ptr->natime[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT18_TRUE)>0) + { + strcat(buf,"OTFI="); + for (i=0;iotfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->otfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT19_TRUE)>0) + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if((flag & BIT20_TRUE)>0) + { + sprintf(tempchar,"PILOTBID=%02x%02x%02x%02x%02x%02x%02x,",ptr->pilotbid[0],ptr->pilotbid[1],ptr->pilotbid[2],ptr->pilotbid[3],ptr->pilotbid[4],ptr->pilotbid[5],ptr->pilotbid[6]); + strcat(buf,tempchar); + } + + if((flag & BIT21_TRUE)>0) + { + strcat(buf,"PILOT="); + for (i=0;ipilotLen;i++) + { + sprintf(tempchar,"%02x",ptr->pilot[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT22_TRUE)>0) + { + strcat(buf,"RNSTRING="); + for (i=0;irnstringLen;i++) + { + sprintf(tempchar,"%02x",ptr->rnstring[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT23_TRUE)>0) + { + strcat(buf,"RSUB="); + for (i=0;irsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->rsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT24_TRUE)>0) //senderin + { + strcat(buf,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ptr->senderin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT25_TRUE)>0) + { + strcat(buf,"TERMTRMT="); + for (i=0;itermtrmtLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrmt[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT26_TRUE)>0) + { + strcat(buf,"TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT27_TRUE)>0) + { + strcat(buf,"VMBOX="); + for (i=0;ivmboxLen;i++) + { + sprintf(tempchar,"%02x",ptr->vmbox[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT28_TRUE)>0) + { + strcat(buf,"VMSPIN="); + for (i=0;ivmspinLen;i++) + { + sprintf(tempchar,"%02x",ptr->vmspin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_ROUTREQ_RSP(struct IS41_ROUTREQ_RSP *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT1_TRUE)>0) + { + sprintf(tempchar,"ACCDEN=%02x,",ptr->accden); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) + { + strcat(buf,"BILLID="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",ptr->billid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT3_TRUE)>0) + { + sprintf(tempchar,"CDEN=%02x,",ptr->cden); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"DIGITS="); + for (i=0;idigitsLen;i++) + { + sprintf(tempchar,"%02x",ptr->digits[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_TRANUMREQ_ARG(struct IS41_TRANUMREQ_ARG *ptr,char *buf) +{ + int i; + u32 flag,flag1; + char tempchar[512]; + struct IS41_PAR_WIN_CAP *ptr1; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //REDIRECTION REASON + { + sprintf(tempchar,"REDREASON=%02x,",ptr->redreason); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) //SystemMyTypeCode + { + sprintf(tempchar,"MYTYP=%02x,",ptr->mytyp); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"BILLID="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",ptr->billid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"GRPINFO="); + for (i=0;igrpinfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->grpinfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"LEGINFO="); + for (i=0;ileginfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->leginfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) + { + sprintf(tempchar,"PILOTBID=%02x%02x%02x%02x%02x%02x%02x,",ptr->pilotbid[0],ptr->pilotbid[1],ptr->pilotbid[2],ptr->pilotbid[3],ptr->pilotbid[4],ptr->pilotbid[5],ptr->pilotbid[6]); + strcat(buf,tempchar); + } + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"PILOT="); + for (i=0;ipilotLen;i++) + { + sprintf(tempchar,"%02x",ptr->pilot[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT11_TRUE)>0) //transcap + { + strcat(buf,"TRANSCAP="); + for (i=0;itranscapLen;i++) + { + sprintf(tempchar,"%02x",ptr->transcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT12_TRUE)>0) //wincap + { + ptr1 = &ptr->wincap; + flag1 = ptr1->param_flag; + + if((flag1 & BIT0_TRUE)>0) //triggercapability + { + strcat(buf,"WINCAP-TRIGGERCAP="); + for (i=0;itriggercapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->triggercap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"WINCAP-WINOPRCAP="); + for (i=0;iwinoprcapLen;i++) + { + sprintf(tempchar,"%02x",ptr1->winoprcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_TRANUMREQ_RSP(struct IS41_TRANUMREQ_RSP *ptr,char *buf) +{ + int i,triglistnum; + u32 flag,flag1; + char tempchar[512]; + IS41_PAR_TRIGGER_LIST *ptr1; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //Digits(Destination) + { + strcat(buf,"DIGITS="); + for (i=0;idigitsLen;i++) + { + sprintf(tempchar,"%02x",ptr->digits[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + +//optional + if((flag & BIT1_TRUE)>0) + { + sprintf(tempchar,"TERMLIST-ISTERM-ACCDEN=%02x,",ptr->accden); + strcat(buf,tempchar); + } + if((flag & BIT2_TRUE)>0) + { + strcat(buf,"ACTCODE="); + for (i=0;iactcodeLen;i++) + { + sprintf(tempchar,"%02x",ptr->actcode[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"ANNLIST="); + for (i=0;iannlistLen;i++) + { + sprintf(tempchar,"%02x",ptr->annlist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"CPNSTRG1="); + for (i=0;icpnstrg1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"CPNSTRG2="); + for (i=0;icpnstrg2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpnstrg2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPSUB="); + for (i=0;icpsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->cpsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) //Digits carrier + { + strcat(buf,"DIGITS CARRIER="); + for (i=0;idigitsCarrierLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsCarrier[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"ACDGTS="); + for (i=0;iacdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->acdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) + { + strcat(buf,"ABDGTS="); + for (i=0;iabdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->abdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"BILLDGTS="); + for (i=0;ibilldgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->billdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"REDIND="); + for (i=0;iredindLen;i++) + { + sprintf(tempchar,"%02x",ptr->redind[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"DMH_SVCID="); + for (i=0;idmh_svcidLen;i++) + { + sprintf(tempchar,"%02x",ptr->dmh_svcid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT13_TRUE)>0) + { + strcat(buf,"GRPINFO="); + for (i=0;igrpinfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->grpinfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT14_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT15_TRUE)>0) + { + strcat(buf,"NATIME="); + for (i=0;inatimeLen;i++) + { + sprintf(tempchar,"%02x",ptr->natime[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT16_TRUE)>0) + { + sprintf(tempchar,"PLIND=%02x,",ptr->plind); + strcat(buf,tempchar); + } + + if((flag & BIT17_TRUE)>0) + { + strcat(buf,"RNDGTS="); + for (i=0;irndgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->rndgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT18_TRUE)>0) + { + strcat(buf,"RNSTRING="); + for (i=0;irnstringLen;i++) + { + sprintf(tempchar,"%02x",ptr->rnstring[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT19_TRUE)>0) + { + strcat(buf,"RSUB="); + for (i=0;irsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->rsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if ((flag & BIT20_TRUE) > 0) + { + debug_show_param_termlist(&ptr->termlist,buf); + } + if((flag & BIT21_TRUE)>0) + { + strcat(buf,"TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT22_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + strcat(buf,"TRIGADRLIST-TRIGLIST-DESTADDR="); + for (i=0;idestaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr1->destaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"TRIGADRLIST-TRIGLIST-WINTRIGLIST="); + for (i=0;iwintriglistLen;i++) + { + sprintf(tempchar,"%02x",ptr1->wintriglist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_SMSREQ_ARG(struct IS41_SMSREQ_ARG *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT1_TRUE)>0) //ElectronicSerialNumber + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //SMS_NotificationIndicator + { + strcat(buf,"SMSNOTIND="); + for (i=0;ismsnotindLen;i++) + { + sprintf(tempchar,"%02x",ptr->smsnotind[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT3_TRUE)>0) //SMS_TeleserviceIdentifier + { + strcat(buf,"SMSTID="); + for (i=0;ismstidLen;i++) + { + sprintf(tempchar,"%02x",ptr->smstid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_SMSREQ_RSP(struct IS41_SMSREQ_RSP *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //ElectronicSerialNumber + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT1_TRUE)>0) //SMS_AccessDeniedReason + { + strcat(buf,"SMSACCDEN="); + for (i=0;ismsaccdenLen;i++) + { + sprintf(tempchar,"%02x",ptr->smsaccden[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT2_TRUE)>0) //SMS_DestinationAddress + { + strcat(buf,"SMSADDR="); + for (i=0;ismsaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr->smsaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_MSINACT_ARG(struct IS41_MSINACT_ARG *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + if((flag & BIT1_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + +// optional part---> + if((flag & BIT2_TRUE)>0) + { + sprintf(tempchar,"COUNT=%02x,",ptr->count); + strcat(buf,tempchar); + } + + if((flag & BIT3_TRUE)>0) + { + sprintf(tempchar,"DEREG=%02x,",ptr->dereg); + strcat(buf,tempchar); + } + + if((flag & BIT4_TRUE)>0) //LocationAreaID + { + sprintf(tempchar,"LOCID=%02x%02x,",ptr->locid[0],ptr->locid[1]); + strcat(buf,tempchar); + } + + if((flag & BIT5_TRUE)>0) //senderin + { + strcat(buf,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ptr->senderin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_MSINACT_RSP(struct IS41_MSINACT_RSP *ptr,char *buf) +{ + buf[0] = 0; + + return 0; +} + +int debug_show_FEATREQ_ARG(struct IS41_FEATREQ_ARG *ptr,char *buf) +{ + int i; + u32 flag; + char tempchar[512]; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //Dialed Digits + { + strcat(buf,"DIGITS="); + for (i=0;idigitsLen;i++) + { + sprintf(tempchar,"%02x",ptr->digits[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT1_TRUE)>0) //esn + { + sprintf(tempchar,"ESN=%02x%02x%02x%02x,",ptr->esn[0],ptr->esn[1],ptr->esn[2],ptr->esn[3]); + strcat(buf,tempchar); + } + + if((flag & BIT2_TRUE)>0) //min + { + sprintf(tempchar,"MIN=%02x%02x%02x%02x%02x,",ptr->min[0],ptr->min[1],ptr->min[2],ptr->min[3],ptr->min[4]); + strcat(buf,tempchar); + } + +//optional + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"BILLID="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",ptr->billid[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"CPNDGTS1="); + for (i=0;icpndgts1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"CPNDGTS2="); + for (i=0;icpndgts2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPSUB="); + for (i=0;icpsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->cpsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT7_TRUE)>0) + { + strcat(buf,"CCI="); + for (i=0;icciLen;i++) + { + sprintf(tempchar,"%02x",ptr->cci[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT8_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT9_TRUE)>0) //MSCID + { + sprintf(tempchar,"MSCID=%02x%02x%02x,",ptr->mscid[0],ptr->mscid[1],ptr->mscid[2]); + strcat(buf,tempchar); + } + + if((flag & BIT10_TRUE)>0) + { + strcat(buf,"MSCIN="); + for (i=0;imscinLen;i++) + { + sprintf(tempchar,"%02x",ptr->mscin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"OTFI="); + for (i=0;iotfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->otfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT12_TRUE)>0) //pcssn + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x,",ptr->pcssn[0],ptr->pcssn[1],ptr->pcssn[2],ptr->pcssn[3],ptr->pcssn[4]); + strcat(buf,tempchar); + } + + if((flag & BIT13_TRUE)>0) //senderin + { + strcat(buf,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ptr->senderin[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT14_TRUE)>0) //transcap + { + strcat(buf,"TRANSCAP="); + for (i=0;itranscapLen;i++) + { + sprintf(tempchar,"%02x",ptr->transcap[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_FEATREQ_RSP(struct IS41_FEATREQ_RSP *ptr,char *buf) +{ + int i,triglistnum; + u32 flag,flag1; + char tempchar[512]; + IS41_PAR_TRIGGER_LIST *ptr1; + + flag = ptr->param_flag; + + buf[0] = 0; + + if((flag & BIT0_TRUE)>0) //feature result + { + sprintf(tempchar,"FEATRESULT=%02x,",ptr->featresult); + strcat(buf,tempchar); + } + +//optional + if((flag & BIT1_TRUE)>0) + { + sprintf(tempchar,"ACCDEN=%02x,",ptr->accden); + strcat(buf,tempchar); + } + if((flag & BIT2_TRUE)>0) + { + strcat(buf,"ACTCODE="); + for (i=0;iactcodeLen;i++) + { + sprintf(tempchar,"%02x",ptr->actcode[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT3_TRUE)>0) + { + strcat(buf,"ANNLIST="); + for (i=0;iannlistLen;i++) + { + sprintf(tempchar,"%02x",ptr->annlist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT4_TRUE)>0) + { + strcat(buf,"CPNDGTS1="); + for (i=0;icpndgts1Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts1[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT5_TRUE)>0) + { + strcat(buf,"CPNDGTS2="); + for (i=0;icpndgts2Len;i++) + { + sprintf(tempchar,"%02x",ptr->cpndgts2[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT6_TRUE)>0) + { + strcat(buf,"CPSUB="); + for (i=0;icpsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->cpsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT7_TRUE)>0) //Digits carrier + { + strcat(buf,"DIGITS CARRIER="); + for (i=0;idigitsCarrierLen;i++) + { + sprintf(tempchar,"%02x",ptr->digitsCarrier[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT8_TRUE)>0) //ConferenceCallingIndicator + { + strcat(buf,"CCI="); + for (i=0;icciLen;i++) + { + sprintf(tempchar,"%02x",ptr->cci[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT9_TRUE)>0) //Digits carrier + { + strcat(buf,"DIGITS="); + for (i=0;idigitsLen;i++) + { + sprintf(tempchar,"%02x",ptr->digits[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } +/* if((flag & BIT10_TRUE)>0) //display text + buf_len = AddTLV(is41_sequenceTag(IS41PAR_DISPTEXT,11),ptr->disptextLen & MAX_IS41_VARPAR_LEN_1,ptr->disptext,0x80,&asn_buf);*/ + if((flag & BIT11_TRUE)>0) + { + strcat(buf,"ACDGTS="); + for (i=0;iacdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->acdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT12_TRUE)>0) + { + strcat(buf,"ABDGTS="); + for (i=0;iabdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->abdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT13_TRUE)>0) + { + strcat(buf,"BILLDGTS="); + for (i=0;ibilldgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->billdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT14_TRUE)>0) + { + strcat(buf,"REDIND="); + for (i=0;iredindLen;i++) + { + sprintf(tempchar,"%02x",ptr->redind[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT15_TRUE)>0) + { + strcat(buf,"GRPINFO="); + for (i=0;igrpinfoLen;i++) + { + sprintf(tempchar,"%02x",ptr->grpinfo[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT16_TRUE)>0) + { + strcat(buf,"MDN="); + for (i=0;imdnLen;i++) + { + sprintf(tempchar,"%02x",ptr->mdn[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT17_TRUE)>0) + { + strcat(buf,"NATIME="); + for (i=0;inatimeLen;i++) + { + sprintf(tempchar,"%02x",ptr->natime[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT18_TRUE)>0) + { + strcat(buf,"OTFI="); + for (i=0;iotfiLen;i++) + { + sprintf(tempchar,"%02x",ptr->otfi[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT19_TRUE)>0) + { + sprintf(tempchar,"PACAIND=%02x,",ptr->pacaind); + strcat(buf,tempchar); + } + if((flag & BIT20_TRUE)>0) + { + strcat(buf,"PILOT="); + for (i=0;ipilotLen;i++) + { + sprintf(tempchar,"%02x",ptr->pilot[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT21_TRUE)>0) + { + strcat(buf,"RNDGTS="); + for (i=0;irndgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->rndgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT22_TRUE)>0) + { + strcat(buf,"RNSTRING="); + for (i=0;irnstringLen;i++) + { + sprintf(tempchar,"%02x",ptr->rnstring[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT23_TRUE)>0) + { + strcat(buf,"RSUB="); + for (i=0;irsubLen;i++) + { + sprintf(tempchar,"%02x",ptr->rsub[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag & BIT24_TRUE)>0) + { + sprintf(tempchar,"RESUMEPIC=%02x,",ptr->resumepic); + strcat(buf,tempchar); + } + if((flag & BIT25_TRUE)>0) + { + strcat(buf,"ROUTDGTS="); + for (i=0;iroutdgtsLen;i++) + { + sprintf(tempchar,"%02x",ptr->routdgts[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if ((flag & BIT26_TRUE) > 0) + { + debug_show_param_termlist(&ptr->termlist,buf); + } + if((flag & BIT27_TRUE)>0) + { + strcat(buf,"TERMTRIG="); + for (i=0;itermtrigLen;i++) + { + sprintf(tempchar,"%02x",ptr->termtrig[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + + if((flag & BIT28_TRUE)>0) //TriggerAddressList + { + triglistnum = ptr->triggerlistnum & MAX_IS41_TRIG_LIST_NUM_1; + + for (i = 0; i < triglistnum; i++) + { + ptr1 = &ptr->triggerlist[i]; + flag1 = ptr1->param_flag; + + if((flag1 & BIT0_TRUE)>0) //destinationaddress -- choice global title + { + strcat(buf,"TRIGADRLIST-TRIGLIST-DESTADDR="); + for (i=0;idestaddrLen;i++) + { + sprintf(tempchar,"%02x",ptr1->destaddr[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + if((flag1 & BIT1_TRUE)>0) //winoperationscapability + { + strcat(buf,"TRIGADRLIST-TRIGLIST-WINTRIGLIST="); + for (i=0;iwintriglistLen;i++) + { + sprintf(tempchar,"%02x",ptr1->wintriglist[i]); + strcat(buf,tempchar); + } + strcat(buf,","); + } + } + } + + if (flag > 0) + return 1; + return 0; +} + +int debug_show_AUTHREQ_ARG(IS41_AUTHREQ_ARG *AUTHREQ,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + char name[32]; + + param_flag = AUTHREQ->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",AUTHREQ->esn[0],AUTHREQ->esn[1],AUTHREQ->esn[2],AUTHREQ->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",AUTHREQ->min[0],AUTHREQ->min[1],AUTHREQ->min[2],AUTHREQ->min[3],AUTHREQ->min[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"mscid=%02x%02x%02x;",AUTHREQ->mscid[0],AUTHREQ->mscid[1],AUTHREQ->mscid[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + switch (AUTHREQ->sysacctype) + { + case ACCTYPE_REGISTRATION: + sprintf(name,"REGISTRATION"); + break; + case ACCTYPE_ORIGINATION: + sprintf(name,"ORIGINATION"); + break; + case ACCTYPE_TERMINATION: + sprintf(name,"TERMINATION"); + break; + case ACCTYPE_NOACCESS: + sprintf(name,"NO ACCESS"); + break; + case ACCTYPE_POWERDOWN: + sprintf(name,"POWER DOWN"); + break; + case ACCTYPE_SMS_PAGERESPONSE: + sprintf(name,"SMS PAGE RESPONSE"); + break; + default: + sprintf(name,"UNSPECIFIED"); + break; + } + sprintf(tempchar,"SysAccType=%s(%02x);",name,AUTHREQ->sysacctype); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + sprintf(tempchar,"SysCap=%02x;",AUTHREQ->syscap); + strcat(charOpr,tempchar); + } + if (param_flag & BIT5_TRUE) + { + sprintf(tempchar,"AuthData=%02x%02x%02x;",AUTHREQ->authdata[0],AUTHREQ->authdata[1],AUTHREQ->authdata[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT6_TRUE) + { + sprintf(tempchar,"Authr=%02x%02x%02x;",AUTHREQ->authr[0],AUTHREQ->authr[1],AUTHREQ->authr[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT7_TRUE) + { + sprintf(tempchar,"COUNT=%02d;",AUTHREQ->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT8_TRUE) + { + sprintf(tempchar,"CMODES=%02x;",AUTHREQ->cmodes); + strcat(charOpr,tempchar); + } + if (param_flag & BIT9_TRUE) + { + strcat(charOpr,"digits="); + for (i=0;iDigitsLen;i++) + { + sprintf(tempchar,"%02x",AUTHREQ->digits[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT10_TRUE) + { + sprintf(tempchar,"PCSSN=%02x%02x%02x%02x%02x;",AUTHREQ->pcssn[0],AUTHREQ->pcssn[1],AUTHREQ->pcssn[2],AUTHREQ->pcssn[3],AUTHREQ->pcssn[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT11_TRUE) + { + sprintf(tempchar,"RAND=%02x%02x%02x%02x;",AUTHREQ->rand[0],AUTHREQ->rand[1],AUTHREQ->rand[2],AUTHREQ->rand[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT12_TRUE) + { + strcat(charOpr,"senderin="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",AUTHREQ->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT13_TRUE) + { + sprintf(tempchar,"TermType=%02x;",AUTHREQ->termtyp); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_authreq_rsp(IS41_AUTHREQ_RSP *authreq,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + param_flag = authreq->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"AAV=%02x;",authreq->aav); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"AUTHU=%02x%02x%02x;",authreq->authu[0],authreq->authu[1],authreq->authu[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",authreq->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + sprintf(tempchar,"CDMAPLCM=%02x%02x%02x%02x%02x%02x;", + authreq->cdmaplcm[0],authreq->cdmaplcm[1],authreq->cdmaplcm[2],authreq->cdmaplcm[3], + authreq->cdmaplcm[4],authreq->cdmaplcm[5]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + sprintf(tempchar,"DenAcc=%02x;",authreq->denacc); + strcat(charOpr,tempchar); + } + if (param_flag & BIT5_TRUE) + { + strcat(charOpr,"RANDSSD="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",authreq->randssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT6_TRUE) + { + strcat(charOpr,"RANDU="); + for (i=0;i<3;i++) + { + sprintf(tempchar,"%02x",authreq->randu[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT7_TRUE) + { + strcat(charOpr,"SSD="); + for (i=0;i<16;i++) + { + sprintf(tempchar,"%02x",authreq->ssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT8_TRUE) + { + strcat(charOpr,"SMEKEY="); + for (i=0;i<8;i++) + { + sprintf(tempchar,"%02x",authreq->smekey[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT9_TRUE) + { + sprintf(tempchar,"NOSSD=%02x;",authreq->nossd); + strcat(charOpr,tempchar); + } + if (param_flag & BIT10_TRUE) + { + sprintf(tempchar,"UpdCount=%02x;",authreq->updcount); + strcat(charOpr,tempchar); + } + if (param_flag & BIT11_TRUE) + { + strcat(charOpr,"VPMASK="); + for (i=0;i<66;i++) + { + sprintf(tempchar,"%02x",authreq->vpmask[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_ASREPORT_ARG(IS41_ASREPORT_ARG *ASREPORT,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + param_flag = ASREPORT->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",ASREPORT->esn[0],ASREPORT->esn[1],ASREPORT->esn[2],ASREPORT->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",ASREPORT->min[0],ASREPORT->min[1],ASREPORT->min[2],ASREPORT->min[3],ASREPORT->min[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"SysCap=%02x;",ASREPORT->syscap); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + strcat(charOpr,"countrpt="); + for (i=0;iCntUpdRepLen;i++) + { + sprintf(tempchar,"%02x",ASREPORT->countrpt[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT4_TRUE) + { + strcat(charOpr,"senderin="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",ASREPORT->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag & BIT5_TRUE) + { + strcat(charOpr,"ssdurpt="); + for (i=0;iSSDUpdRepLen;i++) + { + sprintf(tempchar,"%02x",ASREPORT->ssdurpt[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag & BIT6_TRUE) + { + strcat(charOpr,"uchalrpt="); + for (i=0;iUniChaRepLen;i++) + { + sprintf(tempchar,"%02x",ASREPORT->uchalrpt[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_asreport_rsp(IS41_ASREPORT_RSP *asreport,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + param_flag = asreport->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"AAV=%02x;",asreport->aav); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"AUTHU=%02x%02x%02x;",asreport->authu[0],asreport->authu[1],asreport->authu[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",asreport->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + sprintf(tempchar,"DenAcc=%02x;",asreport->denacc); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + strcat(charOpr,"RANDSSD="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",asreport->randssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT5_TRUE) + { + strcat(charOpr,"RANDU="); + for (i=0;i<3;i++) + { + sprintf(tempchar,"%02x",asreport->randu[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT6_TRUE) + { + strcat(charOpr,"SSD="); + for (i=0;i<16;i++) + { + sprintf(tempchar,"%02x",asreport->ssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT7_TRUE) + { + sprintf(tempchar,"NOSSD=%02x;",asreport->nossd); + strcat(charOpr,tempchar); + } + if (param_flag & BIT8_TRUE) + { + sprintf(tempchar,"UpdCount=%02x;",asreport->updcount); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_BSCHALL_ARG(IS41_BSCHALL_ARG *BSCHALL,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + param_flag = BSCHALL->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",BSCHALL->esn[0],BSCHALL->esn[1],BSCHALL->esn[2],BSCHALL->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",BSCHALL->min[0],BSCHALL->min[1],BSCHALL->min[2],BSCHALL->min[3],BSCHALL->min[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"RANDBS=%02x%02x%02x%02x;",BSCHALL->randbs[0],BSCHALL->randbs[1],BSCHALL->randbs[2],BSCHALL->randbs[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + strcat(charOpr,"SENDERIN="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",BSCHALL->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_bschall_rsp(IS41_BSCHALL_RSP *bschall,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + + param_flag = bschall->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"AUTHBS=%02x%02x%02x",bschall->authbs[0],bschall->authbs[1],bschall->authbs[2]); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_AFREPORT_ARG(IS41_AFREPORT_ARG *AFREPORT,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + char name[32]; + + param_flag = AFREPORT->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",AFREPORT->esn[0],AFREPORT->esn[1],AFREPORT->esn[2],AFREPORT->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",AFREPORT->min[0],AFREPORT->min[1],AFREPORT->min[2],AFREPORT->min[3],AFREPORT->min[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"rpttyp1=%02x;",AFREPORT->rpttyp1); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + switch (AFREPORT->sysacctype) + { + case ACCTYPE_REGISTRATION: + sprintf(name,"REGISTRATION"); + break; + case ACCTYPE_ORIGINATION: + sprintf(name,"ORIGINATION"); + break; + case ACCTYPE_TERMINATION: + sprintf(name,"TERMINATION"); + break; + case ACCTYPE_NOACCESS: + sprintf(name,"NO ACCESS"); + break; + case ACCTYPE_POWERDOWN: + sprintf(name,"POWER DOWN"); + break; + case ACCTYPE_SMS_PAGERESPONSE: + sprintf(name,"SMS PAGE RESPONSE"); + break; + default: + sprintf(name,"UNSPECIFIED"); + break; + } + sprintf(tempchar,"SysAccType=%s(%02x);",name,AFREPORT->sysacctype); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + sprintf(tempchar,"SysCap=%02x;",AFREPORT->syscap); + strcat(charOpr,tempchar); + } + if (param_flag & BIT5_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",AFREPORT->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT6_TRUE) + { + sprintf(tempchar,"COUNTex=%02x;",AFREPORT->countex); + strcat(charOpr,tempchar); + } + if (param_flag & BIT7_TRUE) + { + strcat(charOpr,"mscid="); + for (i=0;i<3;i++) + { + sprintf(tempchar,"%02x",AFREPORT->mscid[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT8_TRUE) + { + sprintf(tempchar,"rpttyp2=%02x;",AFREPORT->rpttyp2); + strcat(charOpr,tempchar); + } + if (param_flag & BIT9_TRUE) + { + strcat(charOpr,"senderin="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",AFREPORT->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag) + return 1; + return 0; +} + +int debug_show_afreport_rsp(IS41_AFREPORT_RSP *afreport,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + param_flag = afreport->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"aav=%02x;",afreport->aav); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"AUTHU=%02x%02x%02x;",afreport->authu[0],afreport->authu[1],afreport->authu[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",afreport->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT3_TRUE) + { + sprintf(tempchar,"DENACC=%02x;",afreport->denacc); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + strcat(charOpr,"RANDSSD="); + for (i=0;i<8;i++) + { + sprintf(tempchar,"%02x",afreport->randssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT5_TRUE) + { + sprintf(tempchar,"RANDU=%02x%02x%02x;",afreport->randu[0],afreport->randu[1],afreport->randu[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT6_TRUE) + { + strcat(charOpr,"SSD="); + for (i=0;i<16;i++) + { + sprintf(tempchar,"%02x",afreport->ssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT7_TRUE) + { + sprintf(tempchar,"NOSSD=%02x;",afreport->nossd); + strcat(charOpr,tempchar); + } + if (param_flag & BIT8_TRUE) + { + sprintf(tempchar,"TERMTYP=%02x;",afreport->termtyp); + strcat(charOpr,tempchar); + } + if (param_flag & BIT9_TRUE) + { + sprintf(tempchar,"UPDCOUNT=%02x;",afreport->updcount); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int auc_debug_show_COUNTREQ_ARG(IS41_COUNTREQ_ARG *COUNTREQ,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + sprintf(charOpr,"[AC->HLR] COUNTREQ (Invoke)\n"); + + param_flag = COUNTREQ->param_flag; + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",COUNTREQ->esn[0],COUNTREQ->esn[1],COUNTREQ->esn[2],COUNTREQ->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",COUNTREQ->min[0],COUNTREQ->min[1],COUNTREQ->min[2],COUNTREQ->min[3],COUNTREQ->min[4]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT2_TRUE) + { + strcat(charOpr,"senderin="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",COUNTREQ->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag) + return 1; + return 0; +} + +int auc_debug_show_countreq_rsp(IS41_COUNTREQ_RSP *countreq,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + + sprintf(charOpr,"[HLR->AC] countreq (Result)\n"); + + param_flag = countreq->param_flag; + + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",countreq->count); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int auc_debug_show_AUTHDIR_ARG(IS41_AUTHDIR_ARG *AUTHDIR,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + int i; + + sprintf(charOpr,"[AC->HLR] AUTHDIR (invoke)\n"); + + param_flag = AUTHDIR->param_flag; + + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"esn=%02x%02x%02x%02x;",AUTHDIR->esn[0],AUTHDIR->esn[1],AUTHDIR->esn[2],AUTHDIR->esn[3]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT1_TRUE) + { + sprintf(tempchar,"min=%02x%02x%02x%02x%02x;",AUTHDIR->min[0],AUTHDIR->min[1],AUTHDIR->min[2],AUTHDIR->min[3],AUTHDIR->min[4]); + strcat(charOpr,tempchar); + } + + if (param_flag & BIT2_TRUE) + { + sprintf(tempchar,"AAV=%02x;",AUTHDIR->aav); + strcat(charOpr,tempchar); + } + + if (param_flag & BIT3_TRUE) + { + sprintf(tempchar,"AUTHU=%02x%02x%02x;",AUTHDIR->authu[0],AUTHDIR->authu[1],AUTHDIR->authu[2]); + strcat(charOpr,tempchar); + } + if (param_flag & BIT4_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",AUTHDIR->count); + strcat(charOpr,tempchar); + } + if (param_flag & BIT5_TRUE) + { + sprintf(tempchar,"DenAcc=%02x;",AUTHDIR->denacc); + strcat(charOpr,tempchar); + } + + if (param_flag & BIT6_TRUE) + { + sprintf(tempchar,"LocID=%02x%02x;",AUTHDIR->locid[0],AUTHDIR->locid[1]); + strcat(charOpr,tempchar); + } + + if (param_flag & BIT7_TRUE) + { + strcat(charOpr,"RANDSSD="); + for (i=0;i<7;i++) + { + sprintf(tempchar,"%02x",AUTHDIR->randssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT8_TRUE) + { + strcat(charOpr,"RANDU="); + for (i=0;i<3;i++) + { + sprintf(tempchar,"%02x",AUTHDIR->randu[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag & BIT9_TRUE) + { + strcat(charOpr,"senderin="); + for (i=0;isenderinLen;i++) + { + sprintf(tempchar,"%02x",AUTHDIR->senderin[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + + if (param_flag & BIT10_TRUE) + { + strcat(charOpr,"SSD="); + for (i=0;i<16;i++) + { + sprintf(tempchar,"%02x",AUTHDIR->ssd[i]); + strcat(charOpr,tempchar); + } + strcat(charOpr,";"); + } + if (param_flag & BIT11_TRUE) + { + sprintf(tempchar,"NOSSD=%02x;",AUTHDIR->nossd); + strcat(charOpr,tempchar); + } + if (param_flag & BIT12_TRUE) + { + sprintf(tempchar,"UpdCount=%02x;",AUTHDIR->updcount); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + +int auc_debug_show_authdir_rsp(IS41_AUTHDIR_RSP *authdir,char *charOpr) +{ + char tempchar[512]; + u32 param_flag; + + sprintf(charOpr,"[HLR->AC] authdir (Result)\n"); + + param_flag = authdir->param_flag; + + if (param_flag & BIT0_TRUE) + { + sprintf(tempchar,"COUNT=%02x;",authdir->count); + strcat(charOpr,tempchar); + } + + if (param_flag) + return 1; + return 0; +} + diff --git a/omc/plat/xapp/src/mapp/is41_init.c b/omc/plat/xapp/src/mapp/is41_init.c new file mode 100644 index 0000000..9602768 --- /dev/null +++ b/omc/plat/xapp/src/mapp/is41_init.c @@ -0,0 +1,23 @@ +/* IS41 init c file */ +/* created by daniel zhang 2004-06-18 */ +/* last modify by daniel zhang 2004-07-13 */ +/* version 1.0 */ +/* ------------------------------------ */ + +void is41_debug_setup(); +void is41_debug_timer(); + + +void init_assignFunc_pointer(); +void init_extractFunc_pointer(); +void is41_init() +{ + is41_debug_setup(); + init_assignFunc_pointer(); + init_extractFunc_pointer(); +} + +void is41_timer() +{ + is41_debug_timer(); +} diff --git a/omc/plat/xapp/src/mapp/map_LCSCode.c b/omc/plat/xapp/src/mapp/map_LCSCode.c new file mode 100644 index 0000000..205b3ff --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_LCSCode.c @@ -0,0 +1,211 @@ + #include "map_includes.h" + + +int extract_RoutingInfoForLCS_Arg(RoutingInfoForLCS_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + if (buf_len == 0) + { + mapp_log_debug("extract RoutingInfoForLCS_Arg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); /* mlc number */ + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x01; + ptr->mlcNumber[0] = len; + memcpy(ptr->mlcNumber+1,temp_buf,len); + } + else + { + mapp_log_debug("extract RoutingInfoForLCS_Arg:loss MLC number"); + return RER; + } + + if (get_tlv("1",temp_buf,&asn_buf) != -1)/* targetMs */ + { + flag |= 0x02; + len = get_tlv("1.0",temp_buf,&asn_buf); // IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ptr->targetMs.identityChoice = 0x01; + memcpy(ptr->targetMs.imsi,temp_buf,IMSI_LEN); + } + else + { + len = get_tlv("1.1",temp_buf,&asn_buf); // msisdn + if (len > 0 && len <= ISDN_LEN) + { + ptr->targetMs.identityChoice = 0x02; + ptr->targetMs.msisdn[0] = len; + memcpy(ptr->targetMs.msisdn+1,temp_buf,len); + } + else + return RER; + } + } + else + { + mapp_log_debug("extract RoutingInfoForLCS_Arg:loss TargetMs"); + return RER; + } + ptr->param_flag = flag; + return buf_len; +} + +int assign_RoutingInfoForLCS_Res(RoutingInfoForLCS_Res *ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 len; + + asn_encode(buf,&asn_buf); + flag = ptr->param_flag; + + if (flag & 0x01) /* targetMs */ + { + if (ptr->targetMs.identityChoice == 1) // IMSI + buf_len = add_tlv("0.0",IMSI_LEN,ptr->targetMs.imsi,0x80,&asn_buf); + else if (ptr->targetMs.identityChoice == 2) // msisdn + { + len = ptr->targetMs.msisdn[0]; + buf_len = add_tlv("0.1",len,ptr->targetMs.msisdn+1,0x80,&asn_buf); + } + else + return RER; + } + else + return RER; + + if (flag & 0x02)/* mscNumber */ + { + len = ptr->mscNumber[0]; + buf_len = add_tlv("1.4-1",len,ptr->mscNumber+1,0x00,&asn_buf); + } + else { + mapp_log_debug("assign RoutingInfoForLCS_Res:loss MSC NUMBER"); + return RER; + } + + return buf_len; +} + +int extract_ProvideSubscriberLocation_Arg(ProvideSubscriberLocation_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + + if (buf_len == 0) + { + mapp_log_debug("extract ProvideSubscriberLocation_Arg param len is:0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + if((len=get_tlv("16-1.0",temp_buf,&asn_buf)) > 0)/* locationType */ + { + flag |= 0x01; + ptr->locationType.locationEstimateType = temp_buf[0]; + } + else + return RER; + + if((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0)/* MLC number */ + { + flag |= 0x02; + ptr->mlcNumber[0] = len; + memcpy(ptr->mlcNumber+1,temp_buf,len); + } + else + return RER; + + if (get_tlv("2",temp_buf,&asn_buf) != -1) /* imsi */ + { + if (len == IMSI_LEN) + { + flag |= 0x04; + memcpy(ptr->imsi,temp_buf,len); + } + else + return RER; + } + + + if (get_tlv("3",temp_buf,&asn_buf) != -1) /* msisdn */ + { + flag |= 0x08; + ptr->msisdn[0] = len; + memcpy(ptr->msisdn+1,temp_buf,len); + } + + ptr->param_flag = flag; + return buf_len; +} + + +int assign_ProvideSubscriberLocation_Res(ProvideSubscriberLocation_Res *ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = ptr->param_flag; + if (flag & 0x01)/* locationEstimate */ + { + u8 locationEstimate[maxExtGeographicalInformation] = {0}; + if(ptr->locationEstimate.typeOfShape != EllipsoidPoint) /* only support EllipsoidPoint */ + return RER; + locationEstimate[0] |= ptr->locationEstimate.typeOfShape << 4; + + ptr->locationEstimate.degreesOfLatitude &= 0x7fffff; + if(ptr->locationEstimate.degreesOfLatitude >= 0) + locationEstimate[1] &= 0x00; + else + locationEstimate[1] |= 0x80; + locationEstimate[1] |= ptr->locationEstimate.degreesOfLatitude >> 16; + locationEstimate[2] = ptr->locationEstimate.degreesOfLatitude >> 8; + locationEstimate[3] = ptr->locationEstimate.degreesOfLatitude & 0xff; + + ptr->locationEstimate.degreesOfLongitude &= 0xffffff; + locationEstimate[4] = ptr->locationEstimate.degreesOfLongitude >> 16; + locationEstimate[5] = ptr->locationEstimate.degreesOfLongitude >> 8; + locationEstimate[6] = ptr->locationEstimate.degreesOfLongitude & 0xff; + + buf_len = add_tlv("4-1",7,locationEstimate,0x00,&asn_buf); + } + else { + return RER; + } + + if (flag & 0x02)/* cgi */ + { + u8 cgi[16] = {0}; + if(ptr->cgi.cgiOrLaiChoice != CgiOrSai) /* only support cgiOrSai */ + return RER; + memcpy(cgi,ptr->cgi.mccMnc,3); + memcpy(cgi+3,&ptr->cgi.lac,2); + memcpy(cgi+5,&ptr->cgi.cellId,2); + buf_len = add_tlv("6-2.0",7,cgi,0x80,&asn_buf); + } + else { + + } + + return buf_len; +} + + + + diff --git a/omc/plat/xapp/src/mapp/map_LCSCode.h b/omc/plat/xapp/src/mapp/map_LCSCode.h new file mode 100644 index 0000000..3a54ce9 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_LCSCode.h @@ -0,0 +1,130 @@ + +/***************** LCS ************** +#define AC_locationServiceGateWay 37 +#define AC_locationServiceEnquiry 38 + +#define RoutingInfoForLCS 85 +#define ProvideSubscriberLocation 83 +**************** LCS **************/ + +typedef struct _SubscriberIdentity +{ + u8 identityChoice; /*1:imsi,2:msisdn*/ + u8 msisdn[ISDN_LEN+1]; /* TBCD */ + u8 imsi[IMSI_LEN+1]; /* TBCD */ +}SubscriberIdentity; + +typedef struct _MapRoutingInfoForLCS_Arg +{ + u32 param_flag; + u8 mlcNumber[ISDN_LEN+1]; /* TBCD */ + SubscriberIdentity targetMs; + u8 user_error; + u8 provider_error; +}RoutingInfoForLCS_Arg; + +typedef struct _MapRoutingInfoForLCS_Res +{ + u32 param_flag; + SubscriberIdentity targetMs; + u8 mscNumber[ISDN_LEN+1]; /* TBCD */ + u8 user_error; + u8 provider_error; +}RoutingInfoForLCS_Res; + + +typedef enum _LocationEstimateType +{ + currentLocation = 0, + currentOrLastKnownLocation, + initialLocation, + activateDeferredLocation, + cancelDeferredLocation, + notificationVerificationOnly +}LocationEstimateType; + +typedef enum _DeferredLocationEventType +{ + msAvailable = 0, + enteringIntoArea, + leavingFromArea, + beingInsideArea, + periodicLDR +}DeferredLocationEventType; + +typedef struct _LocationType +{ + LocationEstimateType locationEstimateType; + DeferredLocationEventType deferredLocationEventType; +}LocationType; + +typedef struct _ProvideSubscriberLocation_Arg +{ + u32 param_flag; + LocationType locationType; + u8 mlcNumber[ISDN_LEN+1]; /* TBCD */ + u8 msisdn[ISDN_LEN+1]; /* TBCD */ + u8 imsi[IMSI_LEN+1]; /* TBCD */ + u8 user_error; + u8 provider_error; +}ProvideSubscriberLocation_Arg; + +typedef enum _TypeOfShape +{ + EllipsoidPoint = 0, + EllipsoidPointWithUncertaintyCircle = 1, + EllipsoidPointWithUncertaintyEllipse = 3, + Polygon = 5, + EllipsoidPointWithAltitude = 8, + EllipsoidPointWithAltitudeAndUncertaintyEllipsoid = 9, + EllipsoidArc =10 +}TypeOfShape; + + +#define maxExtGeographicalInformation 20 +typedef struct _LocationEstimate +{ + TypeOfShape typeOfShape;/* only support EllipsoidPoint */ + long degreesOfLatitude; + long degreesOfLongitude; + u8 reserve[maxExtGeographicalInformation - 7]; +}LocationEstimate; + + +typedef enum _CgiSaiOrLaiChoice +{ + CgiOrSai = 1, + LAI = 2 +}CgiSaiOrLaiChoice; + +typedef struct _CGI +{ + CgiSaiOrLaiChoice cgiOrLaiChoice; +/* +-- octet 1 bits 4321 Mobile Country Code 1st digit +-- bits 8765 Mobile Country Code 2nd digit +-- octet 2 bits 4321 Mobile Country Code 3rd digit +-- bits 8765 Mobile Network Code 3rd digit +-- or filler (1111) for 2 digit MNCs +-- octet 3 bits 4321 Mobile Network Code 1st digit +-- bits 8765 Mobile Network Code 2nd digit +-- octets 4 and 5 Location Area Code according to 3GPP TS 24.008 +-- octets 6 and 7 Cell Identity (CI) value or +-- Service Area Code (SAC) value +-- according to 3GPP TS 23.003 +*/ + u8 mccMnc[3]; /* tbcd */ + u16 lac; /* integer */ + u16 cellId; /* integer */ +}CGI; + +typedef struct _ProvideSubscriberLocation_Res +{ + u32 param_flag; + LocationEstimate locationEstimate; + CGI cgi; + u8 user_error; + u8 provider_error; +}ProvideSubscriberLocation_Res; + + diff --git a/omc/plat/xapp/src/mapp/map_acn.h b/omc/plat/xapp/src/mapp/map_acn.h new file mode 100644 index 0000000..455ef26 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_acn.h @@ -0,0 +1,68 @@ +/* MAP application context name head file */ +/* Written by Liu zhiguo 2001-12-28 */ +/* Version 1.0 (according GSM 09.02 17.3.3) */ +/* ---------------------------------------- */ +#ifndef _MAP_ACN +#define _MAP_ACN + +/* public portion */ +#define Identified_Organization 0x04 +#define ETSI 0x00 +#define MobileDomain 0x00 +#define GSM_Network 0x01 +#define AC_ID 0x00 +#define AC_Version1 0x01 +#define AC_Version2 0x02 +#define AC_Version3 0x03 +/* private portion */ +#define AC_networkLocUp 1 // network loction update +#define AC_locationCancel 2 // location cancel +#define AC_roamingNbEnquiry 3 // roaming number enquiry +#define AC_locInfoRetrieval 5 // location info retrieval +#define AC_reset 10 // reset context +#define AC_handoverControl 11 // handover control +#define AC_equipmentMngt 13 // equipment management +#define AC_infoRetrieval 14 // info retrieval +#define AC_interVlrInfoRetrieval 15 +#define AC_subscriberDataMngt 16 +#define AC_tracing 17 // tracing +#define AC_networkFunctionalSs 18 +#define AC_networkUnstructuredSs 19 +#define AC_shortMsgGateway 20 +#define AC_shortMsgMoRelay 21 +#define AC_shortMsgAlert 23 +#define AC_mwdMngt 24 +#define AC_shortMsgMtRelay 25 +#define AC_imsiRetrieval 26 +#define AC_msPurging 27 +#define AC_subsriberInfoEnquiry 28 +#define AC_anyTimeInfoEnquiry 29 +#define AC_callControlTransfer 6 +#define AC_ssInvNotify 36 // ss-InvocationNotificationContext +#define AC_sIWFSAllocation 12 // sIWFSAllocationContext +#define AC_groupCallControl 31 // group call control context +#define AC_gprsLocUp 32 // GPRS location update context +#define AC_gprsLocInfoRetrieval 33 // GPRS location info retrieval context +#define AC_failureReport 34 // failure report context +#define AC_gprsNotify 35 // GPRS notify context +#define AC_reporting 7 // reporting context +#define AC_callCompletion 8 // call completion context + +/* MAP-H application context */ +#define AC_SecurityTriplet 200 // security triplet +#define AC_SubsInter 201 // subscriber interrogate +#define AC_HLRSubsMng 202 // HLR subscriber management +#define AC_HLRPingAUC 203 // HLR ping AUC + +/* Opr,vlr,hlr ACN */ +#define OprVlrACN 210 +#define OprHlrACN 211 + +/***************** LCS **************/ +#define AC_locationServiceGateWay 37 +#define AC_locationServiceEnquiry 38 +/***************** LCS **************/ + +#define AC_Test 255 + +#endif diff --git a/omc/plat/xapp/src/mapp/map_code.h b/omc/plat/xapp/src/mapp/map_code.h new file mode 100644 index 0000000..9187b6b --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code.h @@ -0,0 +1,333 @@ +/* MAP operation and error code */ +/* written by liu zhiguo 2001-07-25 */ +/* Version 1.0 (according GSM 09.02 17.5) */ +/* ------------------------------------- */ +#ifndef _MAP_CODE +#define _MAP_CODE + +/* +++++++++++++++++ */ +/* MAP message type */ +/* +++++++++++++++++ */ +/* dialogue control portion */ +#define MAP_OPEN 0xff +#define MAP_CLOSE 0xfe +#define MAP_U_ABORT 0xfd +#define MAP_P_ABORT 0xfc +#define MAP_NOTICE 0xfb +#define MAP_DELIMITER 0xfa +#define MAP_LINK 0xef + +#define MAP_REQUEST 0x01 +#define MAP_INDICATE 0x02 +#define MAP_RESPONSE 0x03 +#define MAP_CONFIRM 0x04 + +/* ++++++++++++++++++++ */ +/* MAP operation code */ +/* ++++++++++++++++++++ */ + +/* locaion registration operation codes */ +#define UpLoc 2 // update location +#define CancelLoc 3 // cancel location +#define PurgeMS 67 // purge mobile station +#define SndIdent 55 // send identification + +/* handover operatin codes */ +#define PreHo 68 // prepare handover +#define SndEndSig 29 // send end signal +#define ProcAccSig 33 // process access signalling +#define FwdAccSig 34 // forward access signalling +#define PreSubsHo 69 // prepare subsequent handover + +/* authentication operation codes */ +#define SndAuthInfo 56 // send authentication information + +/* IMEI management operation codes */ +#define ChkIMEI 43 // check IMEI + +/* subscriber management operation codes */ +#define InsSubData 7 // insert subscriber data +#define DelSubData 8 // delete subscriber data +#define SendParam 9 // send parameters + +/* fault recovery operation codes */ +#define Reset 37 // reset +#define FwdChkSSInd 38 // forward check SS indication +#define RestoreData 57 // restore data + +/* operation and maintenance operation codes */ +#define ActvTraceMode 50 // active trace mode +#define DeactvTraceMode 51 // deactive trace mode +#define SndIMSI 58 // send IMSI + +/* call handling operation codes */ +#define SndRoutInfo 22 // send routing information +#define ProvRoamNum 4 // provide roaming number +#define ResumeCH 6 // resume call handling +#define ProvSIWFSNum 31 // provide SIWFS nunmber +#define SIWFSSigMdf 32 // SIWFS signalling modify +#define SetRepState 73 // set report state +#define StatusRep 74 // status report +#define RmtUserFree 75 // remote user free + +/* supplementary service handling operation codes */ +#define RegSS 10 // register SS +#define EraseSS 11 // erase SS +#define ActvSS 12 // activate SS +#define DeactvSS 13 // deactivate SS +#define InterSS 14 // interrogate SS +#define ProcUnstrctSSReq 59 // process unstructure SS request +#define UnstrctSSReq 60 // unstructure SS request +#define UnstrctSSNoti 61 // unstructure SS notify +#define RegPasswd 17 // register password +#define GetPasswd 18 // get password +#define RegCCEntry 76 // register CC entry +#define EraseCCEntry 77 // erase CC entry + +/* short message service operation codes */ +#define SndRoutInfoForSM 45 // send routing information for SM +#define FwdSM 46 // Forward SM V1 +#define MOFwdSM 46 // MO-forward SM +#define MTFwdSM 46 // MT-forward SM +#define MTFwdSM_v3 44 +#define RptSMDelvStat 47 // report SM delivery status +#define InfSC 63 // inform service center +#define AlrtSC 64 // alert service center +#define RdyForSM 66 // ready for SM + +/* provide subsriber info operation codes */ +#define ProvSubInfo 70 // provider subscriber information + +/* any time interrogation operation codes */ +#define AnyTimeInter 71 // any time interrogation + +/* supplementary service invocation notification operation codes */ +#define SSInvNoti 72 // SS invocation notification + +/* group call operation codes */ +#define PreGrpCall 39 // prepare group call +#define SndGrpCallEndSig 40 // send group call end signal +#define ProcGrpCallSig 41 // process group call signalling +#define FwdGrpCallSig 42 // forward group call signalling + +/* GPRS location updating operation codes */ +#define UpGprsLoc 23 // update GPRS location + +/* GPRS location information retrieval operation codes */ +#define SndRoutInfoForGprs 24 // send routing info for GPRS + +/* failure reportin operation codes */ +#define FailRep 25 // failure report + +/* GPRS notification operation codes */ +#define NoteMsPresForGprs 26 // note ms present for GPRS + +/* MAP-H operaion codes, defined by owner */ +#define SecuTrip 200 // security triplets +#define InterrSubs 201 // interrogate subscriber +#define CreateSubs 202 // create subscriber +#define DelSubs 203 // deleter subscriber +#define PingAuc 204 // HLR ping AUC + +/* +++++++++++++++++++++++++ */ +/* MAP operation error code */ +/* +++++++++++++++++++++++++ */ + +/* generic error codes */ +#define SysFail 34 // system failure +#define DataMissing 35 +#define UnexpDataVal 36 // unexpected data value +#define FaciNotSpprt 21 // facility not support +#define IncomTerm 28 // incompatible terminal +#define ResLimit 51 // resource limitation + +/* identification and numbering error codes */ +#define UnknwnSub 1 // unknown subscriber +#define NumChng 44 // number changed +#define UnknwnMSC 3 // unknown MSC +#define UnidentSub 5 // unidentified subscriber +#define UnknwnEquip 7 // unkown equipment + +/* subscription error codes */ +#define RoamNotAllow 8 // roaming not allowed +#define IllgSub 9 // illegal subscriber +#define IllgEquip 12 // illegal equipment +#define BSNotProv 10 // bearer service not provisioned +#define TSNotProv 11 // teleservice not provisioned + +/* handover error codes */ +#define NoHONumAvail 25 // no handover number available +#define SubsHOFail 26 // subsequent handover failure + +/* operation and maintenance error codes */ +#define TrcBufferFull 40 // tracing buffer full + +/* call handling error codes */ +#define NoRoamNumAvail 39 // no roaming number available +#define AbsentSub 27 // absent subscriber +#define BusySub 45 // busy subscriber +#define NoSubReply 46 // no subscriber reply +#define CallBarred 13 +#define FwdFail 47 // forwarding failing +#define OR_NotAllow 48 // OR not allowed +#define FwdViolate 14 // forwarding violate +#define CUG_Reject 15 + +/* any time interrogatin error codes */ +#define ATI_NotAllow 49 // ati not allowed + +/* group call error codes */ +#define NoGrpCallNumAvail 50 // no group call number available + +/* supplementary service error codes */ +#define IllgSSOper 16 // illegal SS operation +#define SSErrStatus 17 // SS error status +#define SSNotAvail 18 // SS not available +#define SSSubscViolate 19 // SS subscription violation +#define SSIncompat 20 // SS incompatibility +#define UnknwnAlph 71 // unknown alphabet +#define USSDBusy 72 +#define PWRegFail 37 // pw-registration failure +#define NegPWCheck 38 // negative pw-check +#define NumOfPWAttViolate 43 // number of pw-attempts violation +#define ShortTermDen 29 // short term denial +#define LongTermDen 30 // long term denial + +/* short message service error codes */ +#define SubBusyForMTSMS 31 // subscriber busy for MT-SMS +#define SMDelivFail 32 // SM-delivery failure +#define MsgWaitListFull 33 // message waiting list full +#define AbsentSubSM 6 // absent subscriber SM + +/* ++++++++++++++++++++++++++++++++ */ +/* MAP operation provider error */ +/* defined by user */ +/* ++++++++++++++++++++++++++++++++ */ +#define DupInvokeId 101 // duplicated invoke id +#define SrvNotSupport 102 // service not supported +#define MistypeParam 103 // mistyped parameter +#define ResourceLimit 104 // resource limitation +#define InitRelease 105 // initiating release +#define UnexpResFromPeer 106 // unexpected response from the peer +#define SrvCompleteFailure 107 // service completion failure +#define NoResFromPeer 108 // no response from the peer +#define InvResReceive 109 // invalid response received + +/* ++++++++++++++++++++++++++++++++ */ +/* the following codes is reserved */ +/* ++++++++++++++++++++++++++++++++ */ + +/* reserved operation codes */ +#define SndParam 9 // send parameter +#define ProcUnstrctSSData 19 // process unstructure SS data +#define PerformHo 28 // perform handover +#define PerformSubsHo 30 // perform subsequence handvoer +#define NoteInterHo 35 // note internal handover +#define NoteSubPrnt 48 // not subscriber present +#define AlrtSCWithoutRes 49 // alert service center without result +#define TraceSubAct 52 // trace subscriber activity +#define BeginSubAct 54 // beging subscriber activity + +/* reserved error codes */ +#define UnknwnBS 2 // unknowd base station +#define InvalidTBS 23 // invalid target base station +#define NoRRAvail 24 // no radio resource available + +/* MAP OPEN response result */ +#define OpenResultRefuse 0x01 +#define OpenResultAccept 0x02 + +/* MAP OPEN refuse result */ +#define ACNotSupported 0x01 +#define InvalidDesReference 0x02 // invalid destination reference +#define InvalidOrgReference 0x03 // invalid original reference +#define NoReasonGiven 0x04 +#define RemoteNodeNotReachable 0x05 +#define PotentialVerIncompat 0x06 // potential version incompatibility + +/* MAP CLOSE release method */ +#define NormalRelease 0x01 +#define PrearrangedEnd 0x02 + +/* MAP U-ABORT user reason */ +#define ResourceLimite 0x01 +#define ResourceUnavailable 0x02 +#define ApplicationCancel 0x03 +#define ProcedureError 0x04 + +/* MAP U-AOBRT diagnostic information */ +#define ShortTermProblem 0x01 +#define LongTermProblem 0x02 +#define HandoverCancel 0x03 +#define RadioChannelRelease 0x04 +#define NetworkPathRelease 0x05 +#define CallRelease 0x06 +#define AssociateProcedureFailure 0x07 +#define TandemDialogueRelease 0x08 +#define RemoteOperationFailure 0x09 + +/* MAP P-ABORT provider reason */ +#define ProviderMalfunction 0x01 +#define SupportingReleased 0x02 +#define ResourceLimitation 0x03 +#define MaintenanceActivity 0x04 +#define VersionIncompatibility 0x05 +#define AbnormalMAPDialogue 0x06 + +/* MAP P-ABORT source */ +#define MAPProblem 0x01 +#define TCProblem 0x02 +#define NetworkProblem 0x03 + +/* MAP NOTICE problem diagnostic */ +#define AbnormalEventDetect 0x01 +#define ResponseRejected 0x02 +#define AbnormalEventReceived 0x03 +#define MessageNotDelivered 0x04 + + + + + + + +/////////////////////////////////////lw add MAP V1 Modify + +#define SendParam 9 // send parameters +#define NoteSubPrnt 48 // not subscriber present +#define ProcUnstrctSSData 19 // process unstructure SS data +#define BeginSubAct 54 // beging subscriber activity +#define PerformHo 28 // perform handover +#define PerformSubsHo 30 // perform subsequence handvoer +#define NoteInterHo 35 // note internal handover +#define BeginSubAct 54 // beging subscriber activity +#define AlrtSCWithoutRes 49 // alert service center without result +#define TraceSubAct 52 // trace subscriber activity +////////////////////////////////////// + +/**** OPR VLR message ********/ +#define DetermineOprUser 128 +#define VlrUpdateLocation 129 +/**** OPR VLR message ********/ + +/**** OPR HLR message ********/ +#define CreateUserWithMsisdnImsi 130 +#define DeleteOprUser 131 +/**** OPR HLR message ********/ + +/**** IMDM VLR message ********/ +#define VlrEnquiryIMDMStatus 132 +/**** IMDM VLR message ********/ + +/***************** LCS **************/ +#define RoutingInfoForLCS 85 +#define ProvideSubscriberLocation 83 +/***************** LCS **************/ + + + + + + + +#endif diff --git a/omc/plat/xapp/src/mapp/map_code_auc.c b/omc/plat/xapp/src/mapp/map_code_auc.c new file mode 100644 index 0000000..4c8fcf2 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_auc.c @@ -0,0 +1,266 @@ +/* map coding auc service file */ +/* written by Liu Zhiguo 2002-06-03 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "map_includes.h" + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding security triplets argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_securityTriplets_arg(struct MapST_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if(flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,ptr->imsi,0x00,&asn_buf); + else + return RER; + if(flag & 0x02) //hlr_id + buf_len = add_tlv("4-2",HLRID_LEN,ptr->hlr_id,0x00,&asn_buf); + return buf_len; +} + +int extract_securityTriplets_arg(struct MapST_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_securityTriplets_arg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + len = get_tlv("4-1",temp_buf,&asn_buf); + if(len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0 ) //imsi + { + ptr->param_flag |= 0x01; + memcpy(ptr->imsi,temp_buf,len); + } + if((len=get_tlv("4-2",temp_buf,&asn_buf)) == HLRID_LEN ) //hlr_id + { + ptr->param_flag |= 0x02; + memcpy(ptr->hlr_id,temp_buf,len); + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding security triplets response */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_securityTriplets_res(struct MapST_Res *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + int ii; + char tlv1[32]; + int temp_len; + u8 temp_buf[256]; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if ((flag & 0x01) == 0) + { + mapp_log_debug("MAPP--assign_securityTriplets_res flag=0"); + return RER; + } + if (ptr->authlist.auth_len > AUTHLIST_LEN) + { + mapp_log_debug("MAPP--assign_securityTriplets_res auth_len>AUTHLIST_LEN"); + return RER; + } + for (ii = 0;ii < ptr->authlist.auth_len;ii ++) + { + temp_len = assign_authset(&ptr->authlist.auth_set[ii],temp_buf); + if (temp_len == RER) + break; + sprintf(tlv1,"16-%d",ii+1); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x20,&asn_buf); + } + return buf_len; +} + +int extract_securityTriplets_res(struct MapST_Res *ptr,u32 buf_len,u8 *buf) +{ + u8 temp_buf[256]; + char tlv1[32]; + int ii; + int len; + ASN_BUF asn_buf; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_securityTriplets_res buf_len=0"); + return ROK; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + for(ii = 0;ii < AUTHLIST_LEN;ii ++) + { + sprintf(tlv1,"16-%d",ii+1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1) + break; + if (!extract_authset(&ptr->authlist.auth_set[ii],len,temp_buf)) + break; + ptr->param_flag |= 0x01; + ptr->authlist.auth_len ++; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding interrogation subscriber argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_interrogateSubscriber_arg(struct MapIS_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if(flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,ptr->imsi,0x00,&asn_buf); + else + return RER; + if(flag & 0x02) //hlr_id + buf_len = add_tlv("4-2",HLRID_LEN,ptr->hlr_id,0x00,&asn_buf); + return buf_len; +} + +int extract_interrogateSubscriber_arg(struct MapIS_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_interrogateSubscriber_arg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + len = get_tlv("4-1",temp_buf,&asn_buf); + if(len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0 )//imsi + { + ptr->param_flag|=0x01; + memcpy(ptr->imsi,temp_buf,len); + } + else + return RER; + if((get_tlv("4-2",temp_buf,&asn_buf)) == HLRID_LEN)//hlr_id + { + ptr->param_flag |= 0x02; + memcpy(ptr->hlr_id,temp_buf,HLRID_LEN); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding create subscriber argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_createSubscriber_arg(struct MapCS_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if(flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,ptr->imsi,0x00,&asn_buf); + else + return RER; + if(flag & 0x02) //hlr_id + buf_len = add_tlv("4-2",HLRID_LEN,ptr->hlr_id,0x00,&asn_buf); + return buf_len; +} + +int extract_createSubscriber_arg(struct MapCS_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_createSubscriber_arg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + len = get_tlv("4-1",temp_buf,&asn_buf); + if(len == IMSI_LEN && (temp_buf[7]&0xf0) == 0xf0) //imsi + { + ptr->param_flag |= 0x01; + memcpy(ptr->imsi,temp_buf,len); + } + if((get_tlv("4-2",temp_buf,&asn_buf))==HLRID_LEN) //hlr_id + { + ptr->param_flag |= 0x02; + memcpy(ptr->hlr_id,temp_buf,HLRID_LEN); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding delete subscriber argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_deleteSubscriber_arg(struct MapDS_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if(flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,ptr->imsi,0x00,&asn_buf); + else + return RER; + if(flag & 0x02) //hlr_id + buf_len = add_tlv("4-2",HLRID_LEN,ptr->hlr_id,0x00,&asn_buf); + return buf_len; +} + +int extract_deleteSubscriber_arg(struct MapDS_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_createSubscriber_arg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + len = get_tlv("4-1",temp_buf,&asn_buf); + if(len == IMSI_LEN && (temp_buf[7]&0xf0) == 0xf0) //imsi + { + ptr->param_flag |= 0x01; + memcpy(ptr->imsi,temp_buf,len); + } + if((get_tlv("4-2",temp_buf,&asn_buf))==HLRID_LEN) //hlr_id + { + ptr->param_flag |= 0x02; + memcpy(ptr->hlr_id,temp_buf,HLRID_LEN); + } + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_code_ch.c b/omc/plat/xapp/src/mapp/map_code_ch.c new file mode 100644 index 0000000..f774a6e --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_ch.c @@ -0,0 +1,1775 @@ +/* mapp coding call handling c file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "map_includes.h" + +int assign_cugcheckinfo(struct CugChkInfo_struct *cci_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (cci_ptr->param_flag & 0x01) + buf_len = add_tlv("4",CUGLOCK_LEN,cci_ptr->cug_intlock,0x00,&asn_buf); + if (cci_ptr->param_flag & 0x02) + buf_len = add_null("5",0x00,&asn_buf); + return buf_len; +} + +int extract_cugcheckinfo(struct CugChkInfo_struct *cci_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + cci_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len == CUGLOCK_LEN) + { + cci_ptr->param_flag |= 0x01; + memcpy(cci_ptr->cug_intlock,temp_buf,CUGLOCK_LEN); + } + len = get_null("5",&asn_buf); + if (len != -1) + cci_ptr->param_flag |= 0x02; + return ROK; +} + +int assign_fwddata(struct FwdData_struct *fwd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 tag1=1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (fwd_ptr->param_flag & 0x01) //fwd num + { + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,fwd_ptr->fwd_num[0],fwd_ptr->fwd_num+1,0x80,&asn_buf); + } + if (fwd_ptr->param_flag & 0x02) // fwd to sub addr + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,fwd_ptr->fwd_subadd[0],fwd_ptr->fwd_subadd+1,0x80,&asn_buf); + } + if (fwd_ptr->param_flag & 0x04) //fwd option + { + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_tlv(tlv1,1,&fwd_ptr->fwd_option,0x80,&asn_buf); + } + return buf_len; +} + +int extract_fwddata(struct FwdData_struct *fwd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + fwd_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("5",temp_buf,&asn_buf); + if (len != -1 && len <= ISDN_LEN) // fwd num + { + fwd_ptr->param_flag |= 0x01; + fwd_ptr->fwd_num[0] = len; + memcpy(fwd_ptr->fwd_num+1,temp_buf,len); + } + len = get_tlv("4",temp_buf,&asn_buf); + if (len != -1 && len <= ISDNSUB_LEN) // fwd subadd + { + fwd_ptr->param_flag |= 0x02; + fwd_ptr->fwd_subadd[0] = len; + memcpy(fwd_ptr->fwd_subadd+1,temp_buf,len); + } + if (get_tlv("6",temp_buf,&asn_buf) == 1) // fwd option + { + fwd_ptr->param_flag |= 0x04; + fwd_ptr->fwd_option = temp_buf[0]; + } + return ROK; +} + +int assign_tcsi(struct TCsi_struct *tcsi_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + u8 ii; + int buf_len=0; + u8 temp_len; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (tcsi_ptr->tdpdata_list.tdpdata_len > TDPDATA_NUM) + return RER; + buf_len = add_null("16",0x20,&asn_buf); + for (ii = 0;ii < tcsi_ptr->tdpdata_list.tdpdata_len;ii ++) //o-BCSM Camel TDP Data List + { + sprintf(tlv1,"16.16-%d",ii+1); + buf_len = add_null(tlv1,0x20,&asn_buf); + sprintf(tlv1,"16.16-%d.10-1",ii+1); + buf_len = add_int(tlv1,tcsi_ptr->tdpdata_list.tdp_data[ii].det_point,0x00,&asn_buf); + sprintf(tlv1,"16.16-%d.2-2",ii+1); + buf_len = add_int(tlv1,tcsi_ptr->tdpdata_list.tdp_data[ii].service_key,0x00,&asn_buf); + sprintf(tlv1,"16.16-%d.0-3",ii+1); + temp_len = tcsi_ptr->tdpdata_list.tdp_data[ii].scf_add[0]; + buf_len = add_tlv(tlv1,temp_len,tcsi_ptr->tdpdata_list.tdp_data[ii].scf_add+1,0x80,&asn_buf); + sprintf(tlv1,"16.16-%d.1-4",ii+1); + buf_len = add_int(tlv1,tcsi_ptr->tdpdata_list.tdp_data[ii].def_hand,0x80,&asn_buf); + } + if (tcsi_ptr->param_flag & 0x02) //camel capability Handling + buf_len = add_int("0-2",tcsi_ptr->camel_caphand,0x80,&asn_buf); + return buf_len; +} + +int extract_tcsi(struct TCsi_struct *tcsi_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 ii,jj; + u8 temp_buf[256]; + u8 tlv1[32]; + + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + tcsi_ptr->tdpdata_list.tdpdata_len = 0; + for (ii = 0;ii < TDPDATA_NUM;ii ++) + { + jj = tcsi_ptr->tdpdata_list.tdpdata_len; + sprintf(tlv1,"16.16-%d",ii+1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1) + break; + sprintf(tlv1,"16.16-%d.10",ii+1); // det_point + if (get_tlv(tlv1,temp_buf,&asn_buf) != 1) + return RER; + tcsi_ptr->tdpdata_list.tdp_data[jj].det_point = temp_buf[0]; + sprintf(tlv1,"16.16-%d.2",ii+1); // service key + len = get_int(tlv1,&asn_buf); + if (len == -1) + return RER; + tcsi_ptr->tdpdata_list.tdp_data[jj].service_key = len; + sprintf(tlv1,"16.16-%d.0",ii+1); // scf address + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1 || len > ISDN_LEN) + return RER; + tcsi_ptr->tdpdata_list.tdp_data[jj].scf_add[0] = len; + memcpy(tcsi_ptr->tdpdata_list.tdp_data[jj].scf_add+1,temp_buf,len); + sprintf(tlv1,"16.16-%d.1",ii+1); // default call handling + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len != 1) + return RER; + tcsi_ptr->tdpdata_list.tdp_data[jj].def_hand = temp_buf[0]; + tcsi_ptr->tdpdata_list.tdpdata_len ++; + } + tcsi_ptr->param_flag |= 0x01; + if (get_tlv("0",temp_buf,&asn_buf) == 1) + { + tcsi_ptr->param_flag |= 0x02; + tcsi_ptr->camel_caphand = temp_buf[0]; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send routing info argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndroutinfoarg(struct MapSRI_Arg *sri_ptr,u8 *buf, u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = sri_ptr->param_flag; + if (flag & 0x01) // has MSISDN + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,sri_ptr->msisdn[0],sri_ptr->msisdn+1,0x80,&asn_buf);//add msisdn parameter + } + else + { + mapp_log_debug("send routing information loss MSISDN"); + return RER; + } + if (flag & 0x02) // has CUG check info + { + sprintf(tlv1,"1-%d",tag1++); + temp_len = assign_cugcheckinfo(&sri_ptr->chk_info,temp_buf); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x04) //has number of forwarding + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&sri_ptr->fwd_num,0x80,&asn_buf); + } + if (flag & 0x08 && ver >1) //interrogation type + { + sprintf(tlv1,"3-%d",tag1++); + temp_buf[0] = sri_ptr->inter_type; + buf_len = add_tlv(tlv1,1,temp_buf,0x80,&asn_buf); + } + if (flag & 0x10 && ver >1) //or-interrogation + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x20 && ver >1) // or-capability + { + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,1,&sri_ptr->or_cap,0x80,&asn_buf); + } + if (flag & 0x40 && ver >1)// gmsc addr + { + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_tlv(tlv1,sri_ptr->gmsc_add[0],sri_ptr->gmsc_add+1,0x80,&asn_buf); + } + if (flag & 0x80 && ver >1) // call ref num + { + sprintf(tlv1,"7-%d",tag1++); + buf_len = add_tlv(tlv1,sri_ptr->callref_num[0],sri_ptr->callref_num+1,0x80,&asn_buf); + } + if (flag & 0x100 && ver >1) // fwd reason num + { + sprintf(tlv1,"8-%d",tag1++); + temp_buf[0] = sri_ptr->fwd_reason; + buf_len = add_tlv(tlv1,1,temp_buf,0x80,&asn_buf); + } + if(flag & 0x200 && ver >1 ) //bs group + { + sprintf(tlv1,"9-%d",tag1++); + temp_len = assign_bscode(&sri_ptr->bs_group,temp_buf,0); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x400) // net info + { + sprintf(tlv1,"10-%d",tag1++); + temp_len = assign_extsiginfo(&sri_ptr->net_info,temp_buf); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x800 && ver >1) //camelInfo + { + if (sri_ptr->camel_info.param_flag & 0x01) + { + sprintf(tlv1,"11-%d.3",tag1); + buf_len = add_tlv(tlv1,2,sri_ptr->camel_info.camel_phase,0x00,&asn_buf); + } + if (sri_ptr->camel_info.param_flag & 0x02) //suppress-T-CSI + { + sprintf(tlv1,"11-%d.5",tag1); + buf_len = add_null(tlv1,0x00,&asn_buf); + } + tag1 ++; + } + if (flag & 0x1000 && ver >1) //suppression Of Announcement + { + sprintf(tlv1,"12-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x2000 && ver >1) //alerting Pattern + { + sprintf(tlv1,"14-%d",tag1++); + buf_len = add_tlv(tlv1,1,&sri_ptr->alt_pattern,0x80,&asn_buf); + } + if (flag & 0x4000 && ver >1) //ccbs-Call + { + sprintf(tlv1,"15-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x8000 && ver >1) //supported CCBS phase + { + sprintf(tlv1,"16-%d",tag1++); + buf_len = AddInteger(tlv1,sri_ptr->ccbs_phase,0x80,&asn_buf); + } + return buf_len; +} + +int extract_sndroutinfoarg(struct MapSRI_Arg *sri_ptr,u32 buf_len,u8 *buf , u8 ver) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + sri_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get MSISDN + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x01; + sri_ptr->msisdn[0] = len; + memcpy(sri_ptr->msisdn+1,temp_buf,len); + } + else + { + mapp_log_debug("extract_sndroutinfoarg:loss MSISDN"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 0) // CUG-checkInfo + { + flag |= 0x02; + extract_cugcheckinfo(&sri_ptr->chk_info,len,temp_buf); + } + + len = get_tlv("2",temp_buf,&asn_buf); //number Of Forwarding + if (len == 1) + { + sri_ptr->fwd_num = temp_buf[0]; + flag |= 0x04; + } + + if( ver > 1 ) + { + if (GetInteger("3",(int *)&sri_ptr->inter_type,0x80,&asn_buf) > 0) //interrogation type + flag |= 0x08; + if (get_null("4",&asn_buf) > 0 ) //or-Interrogation + { + flag |= 0x10; + sri_ptr->or_inter = 1; + } + len = get_tlv("5",temp_buf,&asn_buf); //or-capability + if (len == 1) + { + sri_ptr->or_cap = temp_buf[0]; + flag |= 0x20; + } + len = get_tlv("6",temp_buf,&asn_buf); //gmsc-Address + if (len > 1 && len <= ISDN_LEN) + { + flag |= 0x40; + sri_ptr->gmsc_add[0] = len; + memcpy(sri_ptr->gmsc_add+1,temp_buf,len); + } + len = get_tlv("7",temp_buf,&asn_buf); //call Reference Number + if (len > 0 && len <= CALLREF_NUM) + { + flag |= 0x80; + sri_ptr->callref_num[0] = len; + memcpy(sri_ptr->callref_num+1,temp_buf,len); + } + if (GetInteger("8",(int *)&sri_ptr->fwd_reason,0x80,&asn_buf) > 0) //forwarding Reason + flag |= 0x100; + len = get_tlv("9",temp_buf,&asn_buf); //basicServiceGroup + if (len > 0) + { + flag |= 0x200; + extract_bscode(&sri_ptr->bs_group,len,temp_buf); + } + } + + len = get_tlv("10",temp_buf,&asn_buf); //networkSignalInfo + if (len > 0) + { + flag |= 0x400; + extract_extsiginfo(&sri_ptr->net_info,len,temp_buf); + } + + if( ver > 1 ) + { + len = get_tlv("11.3",temp_buf,&asn_buf); //camelInfo=>supported camel phases + if (len != -1) + { + memcpy(sri_ptr->camel_info.camel_phase,temp_buf,3); + sri_ptr->camel_info.param_flag |= 0x01; + flag |= 0x800; + } + if (get_null("11.5", &asn_buf) >= 0) //camelInfo=>suppress-T-CSI + { + sri_ptr->camel_info.supp_tcsi = 1; + sri_ptr->camel_info.param_flag |= 0x02; + flag |= 0x800; + } + if (get_null("12", &asn_buf) >= 0) //suppression of announcement + { + sri_ptr->supp_ann = 1; + flag |= 0x1000; + } + if (get_tlv("14",temp_buf,&asn_buf) == 1) //alertingPattern + { + sri_ptr->alt_pattern = temp_buf[0]; + flag |= 0x2000; + } + if (get_null("15",&asn_buf) >= 0) //ccbs-Call + { + sri_ptr->ccbs_call = 1; + flag |= 0x4000; + } + if (get_tlv("16",temp_buf,&asn_buf) == 1) //supportedCCBS phase + { + sri_ptr->ccbs_phase = temp_buf[0]; + flag |= 0x8000; + } + } + sri_ptr->param_flag = flag; + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send routing info response */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndroutinfores(struct MapSRI_Res *sri_ptr,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + u32 flag; + u32 temp_flag; + int len=0, jj; + int buf_len = 0; + int tag1=1,tag2=1; + char tlv1[32],tlv2[32]; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + flag = sri_ptr->param_flag; + if (flag & 0x01) // has IMSI + { + if (version <= 1) + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,sri_ptr->imsi,0x00,&asn_buf); + } + else + { + sprintf(tlv1,"9-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,sri_ptr->imsi,0x80,&asn_buf); + } + } + if (flag & 0x02) // has ext routing information + { + if (sri_ptr->rout_info.choice_flag == 1) // route info + { + if (sri_ptr->rout_info.choice.rout_info.choice_flag == 1)//roam num + { + sprintf(tlv1,"4-%d",tag1); + len = sri_ptr->rout_info.choice.rout_info.choice.roam_num[0]; + buf_len = add_tlv(tlv1,len,sri_ptr->rout_info.choice.rout_info.choice.roam_num+1,0x00,&asn_buf); + } + else if (sri_ptr->rout_info.choice.rout_info.choice_flag == 2)//fwd data + { + temp_len = assign_fwddata(&sri_ptr->rout_info.choice.rout_info.choice.fwd_data,temp_buf); + sprintf(tlv1,"16-%d",tag1);//tag1,forwardingData + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x20,&asn_buf); + } + } + else if (sri_ptr->rout_info.choice_flag == 2 && version >1 ) //camel Routing Info + { + tag2 = 1; + if (sri_ptr->rout_info.choice.camel_info.param_flag & 0x01) //forwardingData + { + temp_len = assign_fwddata(&sri_ptr->rout_info.choice.camel_info.fwd_data,temp_buf); + sprintf(tlv1,"8-%d.16-%d",tag1,tag2++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x20,&asn_buf); + } + if (sri_ptr->rout_info.choice.camel_info.param_flag & 0x02) //gmscCamelSubscriptionInfo + { + sprintf(tlv1,"8-%d.0-%d",tag1,tag2); + if (sri_ptr->rout_info.choice.camel_info.subs_info.param_flag & 0x01) //t-CSI + { + temp_len = assign_tcsi(&sri_ptr->rout_info.choice.camel_info.subs_info.t_csi,temp_buf); + sprintf(tlv2,"%s.0-1",tlv1); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (sri_ptr->rout_info.choice.camel_info.subs_info.param_flag & 0x02) //o-CSI + { + temp_len = assign_ocsi(&sri_ptr->rout_info.choice.camel_info.subs_info.o_csi,temp_buf); + sprintf(tlv2,"%s.1-2",tlv1); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (sri_ptr->rout_info.choice.camel_info.subs_info.param_flag & 0x04) //o-BcsmCamelTDP-CriteriaList + { + temp_len = assign_tdpcritlist(&sri_ptr->rout_info.choice.camel_info.subs_info.ob_list,temp_buf); + sprintf(tlv2,"%s.3-3",tlv1); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x0a0,&asn_buf); + } + } + } + tag1 ++; + } + if (flag & 0x04) //cug-checkInfo + { + sprintf(tlv1,"3-%d",tag1++); + temp_len = assign_cugcheckinfo(&sri_ptr->cugchk_info,temp_buf); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if( version >1 ) + { + if (flag & 0x08) //cugSubscription Flag + { + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_null(tlv1,0x00,&asn_buf); + } + if (flag & 0x10) //subscriberInfo + { + temp_len = assign_subinfo(&sri_ptr->sub_info,temp_buf); + sprintf(tlv1,"7-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x20) //ss-List + { + if (sri_ptr->ss_list.sslist_len > SS_LEN) + { + mapp_log_debug("assign_sndroutinfores: sslist_len > SS_LEN"); + return RER; + } + for(jj = 0;jj < sri_ptr->ss_list.sslist_len;jj ++) + { + sprintf(tlv1,"1-%d.4-%d",tag1,jj+1); + buf_len = add_tlv(tlv2,1,&sri_ptr->ss_list.ss_code[jj],0x00,&asn_buf); + } + tag1 ++; + } + if (flag & 0x40) //basicService + { + temp_len = assign_bscode(&sri_ptr->bs_code,temp_buf,0); + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x80) //forwarding Interrogation Required + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x100) //vmsc-Address + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,sri_ptr->vmsc_add[0],sri_ptr->vmsc_add+1,0x80,&asn_buf); + } + if (flag & 0x200) //naea-PreferredCI + { + sprintf(tlv1,"10-%d.0",tag1++); + buf_len = add_tlv(tlv1,NAEA_LEN,sri_ptr->naea_ci.cic,0x80,&asn_buf); + } + if((flag & 0x400) == 0x400) //ccbs-Indicators + { + tag2 = 1; + temp_flag = sri_ptr->ccbs_ind.param_flag; + if (temp_flag & 0x01) //ccbs-Possible + { + sprintf(tlv1,"11-%d.0-%d",tag1,tag2++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if(temp_flag & 0x02) //kepCCBS-CalIndicator + { + sprintf(tlv1,"11-%d.1-%d",tag1,tag2++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + tag1++; + } + if((flag & 0x800) == 0x800) //mnp indicator + { + sprintf(tlv1,"13-%d",tag1++); + temp_buf[0] = sri_ptr->mnp_indicator; + buf_len = add_tlv(tlv1,1,temp_buf,0x80,&asn_buf); + } + } + return buf_len; +} + +int extract_sndroutinfores(struct MapSRI_Res *sri_ptr,u32 buf_len,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + u8 ii,jj; + int len; + int temp_len; + u8 temp_buf[256]; + u8 tag1; + char tlv1[32]; + u32 flag=0; + + sri_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + tag1 = 1; + if (version <= 1) + len = get_tlv("4-1",temp_buf,&asn_buf); + else + len = get_tlv("9",temp_buf,&asn_buf); //imsi + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + flag |= 0x01; + memcpy(sri_ptr->imsi,temp_buf,len); + tag1 ++; + } + else + mapp_log_debug("extract_sndroutinfores: no IMSI"); + sprintf(tlv1,"4-%d",tag1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len > 0) // roaming number + { + flag |= 0x02; + sri_ptr->rout_info.choice_flag = 1; + sri_ptr->rout_info.choice.rout_info.choice_flag = 1; + sri_ptr->rout_info.choice.rout_info.choice.roam_num[0] = len; + memcpy(sri_ptr->rout_info.choice.rout_info.choice.roam_num+1,temp_buf,len); + tag1 ++; + } + else + { + len = get_tlv("16",temp_buf,&asn_buf); //forwarding data + if (len != -1) + { + flag |= 0x02; + sri_ptr->rout_info.choice_flag = 1; + sri_ptr->rout_info.choice.rout_info.choice_flag = 2; + if (!extract_fwddata(&sri_ptr->rout_info.choice.rout_info.choice.fwd_data,len,temp_buf)) + return RER; + tag1 ++; + } + else if( version >1 ) + { + len = get_tlv("8",temp_buf,&asn_buf); // camelRoutingInfo + if (len != -1) + { + flag |= 0x02; + sri_ptr->rout_info.choice_flag = 2; + sri_ptr->rout_info.choice.camel_info.param_flag = 0; + temp_len = get_tlv("8.16",temp_buf,&asn_buf); // fwd data + if (temp_len != -1) + { + sri_ptr->rout_info.choice.camel_info.param_flag |= 0x01; + if (!extract_fwddata(&sri_ptr->rout_info.choice.camel_info.fwd_data,temp_len,temp_buf)) + return RER; + } + temp_len = get_tlv("8.0",temp_buf,&asn_buf); //gmscCamelSubscriptionInfo + if (temp_len != -1) + { + sri_ptr->rout_info.choice.camel_info.param_flag |= 0x02; + sri_ptr->rout_info.choice.camel_info.subs_info.param_flag = 0; + temp_len = get_tlv("8.0.0",temp_buf,&asn_buf); // t-CSI + if (temp_len != -1) + { + sri_ptr->rout_info.choice.camel_info.subs_info.param_flag |= 0x01; + if (!extract_tcsi(&sri_ptr->rout_info.choice.camel_info.subs_info.t_csi,temp_len,temp_buf)) + return RER; + } + temp_len = get_tlv("8.0.1",temp_buf,&asn_buf); // o-CSI + if (temp_len != -1) + { + sri_ptr->rout_info.choice.camel_info.subs_info.param_flag |= 0x02; + if (!extract_ocsi(&sri_ptr->rout_info.choice.camel_info.subs_info.o_csi,temp_len,temp_buf)) + return RER; + } + temp_len = get_tlv("8.0.3",temp_buf,&asn_buf); //o-BcsmCamelTDP-CrteriaList + if (temp_len != -1) + { + sri_ptr->rout_info.choice.camel_info.subs_info.param_flag |= 0x04; + if (!extract_tdpcritlist(&sri_ptr->rout_info.choice.camel_info.subs_info.ob_list,temp_len,temp_buf)) + return RER; + } + } + tag1 ++; + } + } + } + len = get_tlv("3",temp_buf,&asn_buf); //cug-CheckInfo + if (len != -1) + { + if (!extract_cugcheckinfo(&sri_ptr->cugchk_info,len,temp_buf)) + return RER; + flag |= 0x04; + tag1 ++; + } + if( version > 1 ) + { + if (get_tlv("6",temp_buf,&asn_buf) != -1) //cug Subscription flag + { + flag |= 0x08; + sri_ptr->cugsubs_flag = 1; + tag1 ++; + } + len = get_tlv("7",temp_buf,&asn_buf); //subscriber info + if (len != -1) + { + flag |= 0x10; + if (!extract_subinfo(&sri_ptr->sub_info,len,temp_buf)) + return RER; + tag1 ++; + } + if (get_tlv("1",temp_buf,&asn_buf) != -1) + { + flag |= 0x20; + sri_ptr->ss_list.sslist_len = 0; + for (ii = 0;ii < SS_LEN;ii ++) + { + jj = sri_ptr->ss_list.sslist_len; + sprintf(tlv1,"1.4-%d",ii+1); + if (get_tlv(tlv1,temp_buf,&asn_buf) != 1) + break; + sri_ptr->ss_list.ss_code[jj] = temp_buf[0]; + sri_ptr->ss_list.sslist_len ++; + } + tag1 ++; + } + len = get_tlv("5",temp_buf,&asn_buf); //basicService + if (len != -1) + { + flag |= 0x40; + if (!extract_bscode(&sri_ptr->bs_code,len,temp_buf)) + return RER; + tag1 ++; + } + sprintf(tlv1,"4-%d",tag1); + len = get_null(tlv1,&asn_buf); //forwarding Interrogation Required + if (len != -1) + { + flag |= 0x80; + tag1 ++; + } + len = get_tlv("2",temp_buf,&asn_buf); //vmsc-Address + if (len != -1 && len < ISDN_LEN) + { + flag |= 0x100; + sri_ptr->vmsc_add[0] = len; + memcpy(sri_ptr->vmsc_add+1,temp_buf,len); + tag1 ++; + } + if(get_tlv("10.0",temp_buf,&asn_buf) == NAEA_LEN) + { + flag |= 0x200; + memcpy(sri_ptr->naea_ci.cic,temp_buf,NAEA_LEN); + tag1 ++; + } + if (get_tlv("11",temp_buf,&asn_buf) != -1) //ccbs-Indicator + { + flag |= 0x400; + if (get_null("11.0",&asn_buf) > 0) //ccbs-Possible + { + sri_ptr->ccbs_ind.param_flag |= 0x01; + sri_ptr->ccbs_ind.ccbs_possible = 1; + } + if(get_null("11.1", &asn_buf) > 0) //keepCCBS-CallIndicator + { + sri_ptr->ccbs_ind.param_flag |= 0x02; + sri_ptr->ccbs_ind.ccbs_indicator = 1; + } + tag1 ++; + } + if (get_tlv("13",temp_buf,&asn_buf) == 1 ) //mnp indicator + { + flag |= 0x800; + sri_ptr->mnp_indicator = temp_buf[0]; + tag1 ++; + } + } + sri_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provider roaming num argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_provroamnumarg(MapPRN_Arg *prn_ptr, u8 *buf) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len; + int temp_len; + u8 temp_buf[256]; + int tag1=1; + char tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = prn_ptr->param_flag; + if(flag & 0x01) // imsi + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,prn_ptr->imsi,0x80,&asn_buf); + } + else + { + mapp_log_debug("Error:assign_prroamnumarg: lack imsi"); + return RER; + } + if (flag & 0x02) //msc number + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,prn_ptr->msc_num[0],prn_ptr->msc_num+1,0x80,&asn_buf); + } + else + { + mapp_log_debug("assign_prroamnumarg: lack msc number"); + return RER; + } + if (flag & 0x04) //msisdn number + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,prn_ptr->msisdn[0],prn_ptr->msisdn+1,0x80,&asn_buf); + } + if (flag & 0x08) // lmsi + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,LMSI_LEN,prn_ptr->lmsi,0x80,&asn_buf); + } + if (flag & 0x10) // bearer capability + { + temp_len = assign_extsiginfo(&prn_ptr->bearer_cap,temp_buf); + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x20) // net info + { + temp_len = assign_extsiginfo(&prn_ptr->net_info,temp_buf); + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (flag & 0x40) // suppression of announcement + { + sprintf(tlv1,"7-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x80) // gmsc address + { + sprintf(tlv1,"8-%d",tag1++); + buf_len = add_tlv(tlv1,prn_ptr->gmsc_add[0],prn_ptr->gmsc_add+1,0x80,&asn_buf); + } + if (flag & 0x100) // call reference number + { + sprintf(tlv1,"9-%d",tag1++); + buf_len = add_tlv(tlv1,prn_ptr->callref_num[0],prn_ptr->callref_num+1,0x80,&asn_buf); + } + if (flag & 0x200) // or interrogation + { + sprintf(tlv1,"10-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x400) // alert pattern + { + sprintf(tlv1,"12-%d",tag1++); + buf_len = add_tlv(tlv1,1,&prn_ptr->alt_pattern,0x80,&asn_buf); + } + if (flag & 0x800) // ccbs call + { + sprintf(tlv1,"13-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x1000) // supproted camel phase in gmsc + { + sprintf(tlv1,"14-%d",tag1++); + buf_len = add_tlv(tlv1,3,prn_ptr->camel_phase,0x80,&asn_buf); + } + return buf_len; +} + +int extract_provroamnumarg(struct MapPRN_Arg *prn_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag=0; + + prn_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + flag |= 0x01; + memcpy(prn_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract_prroamnumarg:lack imsi"); + return RER; + } + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 2 && len <= ISDN_LEN) + { + flag |= 0x02; + prn_ptr->msc_num[0] = len; + memcpy(prn_ptr->msc_num+1,temp_buf,len); + } + else + { + mapp_log_debug("extract_prroamnumarg:lack msc number"); + return RER; + } + len = get_tlv("2",temp_buf,&asn_buf); + if (len > 2 && len <= ISDN_LEN) + { + flag |= 0x04; + prn_ptr->msisdn[0] = len; + memcpy(prn_ptr->msisdn+1,temp_buf,len); + } + len = get_tlv("4",temp_buf,&asn_buf); + if (len == LMSI_LEN) + { + memcpy(prn_ptr->lmsi,temp_buf,LMSI_LEN); + flag |= 0x08; + } + len = get_tlv("5",temp_buf,&asn_buf); + if (len != -1) + { + if (!extract_extsiginfo(&prn_ptr->bearer_cap,len,temp_buf)) + return RER; + flag |= 0x10; + } + len = get_tlv("6",temp_buf,&asn_buf); + if (len != -1) + { + if (!extract_extsiginfo(&prn_ptr->net_info,len,temp_buf)) + return RER; + flag |= 0x20; + } + if (get_null("7",&asn_buf) != -1) + { + flag |= 0x40; + prn_ptr->sup_ann = 1; + } + len = get_tlv("8",temp_buf,&asn_buf); + if (len > 2 && len <= ISDN_LEN) + { + flag |= 0x80; + prn_ptr->gmsc_add[0] = len; + memcpy(prn_ptr->gmsc_add+1,temp_buf,len); + } + len = get_tlv("9",temp_buf,&asn_buf); + if (len > 0 && len <= CALLREF_NUM) + { + flag |= 0x100; + prn_ptr->callref_num[0] = len; + memcpy(prn_ptr->callref_num+1,temp_buf,len); + } + if (get_null("10",&asn_buf) != -1) + { + flag |= 0x200; + prn_ptr->or_interr = 1; + } + if (get_tlv("12",temp_buf,&asn_buf) == 1) + { + flag |= 0x400; + prn_ptr->alt_pattern = temp_buf[0]; + } + if (get_null("13",&asn_buf) != -1) + { + flag |= 0x800; + prn_ptr->ccbs_call = 1; + } + if (get_tlv("14",temp_buf,&asn_buf) == 3) + { + flag |= 0x1000; + memcpy(prn_ptr->camel_phase,temp_buf,3); + } + prn_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provider roaming num response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_provroamnumres(struct MapPRN_Res *prn_ptr, u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf, &asn_buf); + if (prn_ptr->param_flag & 0x01) // roaming number + buf_len = add_tlv("4",prn_ptr->roam_num[0],prn_ptr->roam_num+1,0x00,&asn_buf); + else + { + mapp_log_debug("assign_prroamnumRES: lack roaming number"); + return RER; + } + return buf_len; +} + +int extract_provroamnumres(struct MapPRN_Res *prn_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + prn_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len > 2) + { + prn_ptr->param_flag |= 0x01; + prn_ptr->roam_num[0] = len; + memcpy(prn_ptr->roam_num+1,temp_buf,len); + } + else + { + mapp_log_debug("extract_prroamnumres: lack roaming number"); + return RER; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding resume call handling argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_rescallhandarg(struct MapRCH_Arg *rch_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (rch_ptr->param_flag & 0x01) // call reference number + buf_len = add_tlv("0",rch_ptr->callref_num[0],rch_ptr->callref_num+1,0x80,&asn_buf); + else + return RER; + if (rch_ptr->param_flag & 0x02) // bs group + { + temp_len = assign_bscode(&rch_ptr->bs_group,temp_buf,0); + buf_len = add_tlv("1",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (rch_ptr->param_flag & 0x04) // forward data + { + temp_len = assign_fwddata(&rch_ptr->fwd_data,temp_buf); + buf_len = add_tlv("2",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (rch_ptr->param_flag & 0x08) // imsi + buf_len = add_tlv("3",IMSI_LEN,rch_ptr->imsi,0x80,&asn_buf); + else + return RER; + tag1 = 5; + if (rch_ptr->param_flag & 0x10) // cug check info + { + temp_len = assign_cugcheckinfo(&rch_ptr->cugchk_info,temp_buf); + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (rch_ptr->param_flag & 0x20) // o-csi + { + temp_len = assign_ocsi(&rch_ptr->o_csi,temp_buf); + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (rch_ptr->param_flag & 0x40) // ccbs possible + { + sprintf(tlv1,"8-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + return buf_len; +} + +int extract_rescallhandarg(struct MapRCH_Arg *rch_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + rch_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_resume call handling buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // call reference + if (len > 0 && len <= CALLREF_NUM) + { + rch_ptr->param_flag |= 0x01; + rch_ptr->callref_num[0] = len; + memcpy(rch_ptr->callref_num+1,temp_buf,len); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // bs group + if (len > 0) + { + if (!extract_bscode(&rch_ptr->bs_group,len,temp_buf)) + return RER; + rch_ptr->param_flag |= 0x02; + } + else + return RER; + len = get_tlv("2",temp_buf,&asn_buf); // forward data + if (len > 0) + { + if (!extract_fwddata(&rch_ptr->fwd_data,len,temp_buf)) + return RER; + rch_ptr->param_flag |= 0x04; + } + else + return RER; + len = get_tlv("3",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + rch_ptr->param_flag |= 0x08; + memcpy(rch_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("4",temp_buf,&asn_buf); // cug check info + if (len > 0) + { + if (!extract_cugcheckinfo(&rch_ptr->cugchk_info,len,temp_buf)) + return RER; + rch_ptr->param_flag |= 0x10; + } + len = get_tlv("5",temp_buf,&asn_buf); // o-csi + if (len > 0) + { + if (!extract_ocsi(&rch_ptr->o_csi,len,temp_buf)) + return RER; + rch_ptr->param_flag |= 0x20; + } + if (get_tlv("8",temp_buf,&asn_buf) != -1) // ccbs possible + { + rch_ptr->param_flag |= 0x40; + rch_ptr->ccbs_possible = 1; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding resume call handling response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_rescallhandres(struct MapRCH_Res *rch_ptr,u8 *buf) +{ + return 0; +} + +int extract_rescallhandres(struct MapRCH_Res *rch_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provide SIWFS number argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prvsiwfsnumarg(struct MapPSN_Arg *psn_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (psn_ptr->param_flag & 0x01) // gsm bearer capability + { + temp_len = assign_extsiginfo(&psn_ptr->gsm_bc,temp_buf); + buf_len = add_tlv("0",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (psn_ptr->param_flag & 0x02) // ISDN bearer capability + { + temp_len = assign_extsiginfo(&psn_ptr->isdn_bc,temp_buf); + buf_len = add_tlv("1",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (psn_ptr->param_flag & 0x04) // call direction + buf_len = add_tlv("2",1,&psn_ptr->call_direction,0x80,&asn_buf); + else + return RER; + if (psn_ptr->param_flag & 0x08) // b-subscriber address + buf_len = add_tlv("3",psn_ptr->bsub_add[0],psn_ptr->bsub_add+1,0x80,&asn_buf); + else + return RER; + if (psn_ptr->param_flag & 0x10) // chosen channel + { + temp_len = assign_extsiginfo(&psn_ptr->chose_chan,temp_buf); + buf_len = add_tlv("4",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + tag1 = 6; + if (psn_ptr->param_flag & 0x20) // low layer compatibility + { + temp_len = assign_extsiginfo(&psn_ptr->low_camp,temp_buf); + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (psn_ptr->param_flag & 0x40) // high layer compatibility + { + temp_len = assign_extsiginfo(&psn_ptr->high_camp,temp_buf); + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + return buf_len; +} + +int extract_prvsiwfsnumarg(struct MapPSN_Arg *psn_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psn_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_provide siwfs number buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // GSM bearer capability + if (len > 0) + { + if (!extract_extsiginfo(&psn_ptr->gsm_bc,len,temp_buf)) + return RER; + psn_ptr->param_flag |= 0x01; + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // ISDN bearer capability + if (len > 0) + { + if (!extract_extsiginfo(&psn_ptr->isdn_bc,len,temp_buf)) + return RER; + psn_ptr->param_flag |= 0x02; + } + else + return RER; + if (get_tlv("2",temp_buf,&asn_buf) == 1) // call direction + { + psn_ptr->param_flag |= 0x04; + psn_ptr->call_direction = temp_buf[0]; + } + else + return RER; + len = get_tlv("3",temp_buf,&asn_buf); // b-subscriber address + if (len > 0) + { + psn_ptr->param_flag |= 0x08; + psn_ptr->bsub_add[0] = len; + memcpy(psn_ptr->bsub_add+1,temp_buf,len); + } + else + return RER; + len = get_tlv("4",temp_buf,&asn_buf); // chosen channel + if (len > 0) + { + if (!extract_extsiginfo(&psn_ptr->chose_chan,len,temp_buf)) + return RER; + psn_ptr->param_flag |= 0x10; + } + else + return RER; + len = get_tlv("5",temp_buf,&asn_buf); // low layer compatibility + if (len > 0) + { + if (!extract_extsiginfo(&psn_ptr->low_camp,len,temp_buf)) + return RER; + psn_ptr->param_flag |= 0x20; + } + len = get_tlv("6",temp_buf,&asn_buf); // high layer compatibility + if (len > 0) + { + if (!extract_extsiginfo(&psn_ptr->high_camp,len,temp_buf)) + return RER; + psn_ptr->param_flag |= 0x40; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provide SIWFS number response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prvsiwfsnumres(struct MapPSN_Res *psn_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (psn_ptr->param_flag & 0x01) + buf_len = add_tlv("0",psn_ptr->siwfs_num[0],psn_ptr->siwfs_num+1,0x80,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_prvsiwfsnumres(struct MapPSN_Res *psn_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psn_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_provide siwfs number buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) + { + psn_ptr->param_flag |= 0x01; + psn_ptr->siwfs_num[0] = len; + memcpy(psn_ptr->siwfs_num+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding SIWFS signalling modify argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_siwfssigmodarg(struct MapSSM_Arg *ssm_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (ssm_ptr->param_flag & 0x01) // channel type + { + temp_len = assign_extsiginfo(&ssm_ptr->chan_type,temp_buf); + buf_len = add_tlv("0",temp_len,temp_buf,0x0a0,&asn_buf); + } + if (ssm_ptr->param_flag & 0x02) // chosen channel + { + temp_len = assign_extsiginfo(&ssm_ptr->chose_chan,temp_buf); + buf_len = add_tlv("1",temp_len,temp_buf,0x0a0,&asn_buf); + } + return buf_len; +} + +int extract_siwfssigmodarg(struct MapSSM_Arg *ssm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ssm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_siwfs signalling modify buf_len=0"); + return ROK; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // channel type + if (len > 0) + { + if (!extract_extsiginfo(&ssm_ptr->chan_type,len,temp_buf)) + return RER; + ssm_ptr->param_flag |= 0x01; + } + len = get_tlv("1",temp_buf,&asn_buf); // chosen channel + if (len > 0) + { + if (!extract_extsiginfo(&ssm_ptr->chose_chan,len,temp_buf)) + return RER; + ssm_ptr->param_flag |= 0x02; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding SIWFS signalling modify response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_siwfssigmodres(struct MapSSM_Res *ssm_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (ssm_ptr->param_flag & 0x01) // chosen channel + { + temp_len = assign_extsiginfo(&ssm_ptr->chose_chan,temp_buf); + buf_len = add_tlv("0",temp_len,temp_buf,0x0a0,&asn_buf); + } + return buf_len; +} + +int extract_siwfssigmodres(struct MapSSM_Res *ssm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ssm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_siwfs signalling modify buf_len=0"); + return ROK; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // chosen channel + if (len > 0) + { + if (!extract_extsiginfo(&ssm_ptr->chose_chan,len,temp_buf)) + return RER; + ssm_ptr->param_flag |= 0x01; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding set reporting state argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_setrepstatearg(struct MapSRS_Arg *srs_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (srs_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,srs_ptr->imsi,0x80,&asn_buf); + if (srs_ptr->param_flag & 0x02) // lmsi + buf_len = add_tlv("1",LMSI_LEN,srs_ptr->lmsi,0x80,&asn_buf); + if (srs_ptr->param_flag & 0x04) // ccbs monitoring + { + temp_buf[0] = srs_ptr->ccbs_monitor; + buf_len = add_tlv("2",1,temp_buf,0x80,&asn_buf); + } + return buf_len; +} + +int extract_setrepstatearg(struct MapSRS_Arg *srs_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + srs_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_set reporting state buf_len=0"); + return ROK; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + srs_ptr->param_flag |= 0x01; + memcpy(srs_ptr->imsi,temp_buf,IMSI_LEN); + } + if (get_tlv("1",temp_buf,&asn_buf) == LMSI_LEN) // get lmsi + { + srs_ptr->param_flag |= 0x02; + memcpy(srs_ptr->lmsi,temp_buf,LMSI_LEN); + } + if (get_tlv("2",temp_buf,&asn_buf) == 1) // get ccbs monitor + { + srs_ptr->param_flag |= 0x04; + srs_ptr->ccbs_monitor = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding set reporting state response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_setrepstateres(struct MapSRS_Res *srs_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (srs_ptr->param_flag & 0x01) // ccbs subscriber status + { + temp_buf[0] = srs_ptr->ccbs_stat; + buf_len = add_tlv("0",1,temp_buf,0x80,&asn_buf); + } + return buf_len; +} + +int extract_setrepstateres(struct MapSRS_Res *srs_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + srs_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_set reporting state buf_len=0"); + return ROK; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // get ccbs subscriber status + { + srs_ptr->param_flag |= 0x01; + srs_ptr->ccbs_stat = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding status report argument */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_statreparg(struct MapSR_Arg *sr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (sr_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,sr_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (sr_ptr->param_flag & 0x02) // event report data + { + if (sr_ptr->event_data.param_flag & 0x01) // ccbs subscriber status + { + temp_buf[0] = sr_ptr->event_data.ccbs_stat; + buf_len = add_tlv("1.0",1,temp_buf,0x80,&asn_buf); + } + } + if (sr_ptr->param_flag & 0x04) // call report data + { + if (sr_ptr->call_data.param_flag & 0x01) // monitor mode + { + temp_buf[0] = sr_ptr->call_data.monitor_mode; + buf_len = add_tlv("2.0",1,temp_buf,0x80,&asn_buf); + } + if (sr_ptr->call_data.param_flag & 0x02) // call outcome + { + temp_buf[0] = sr_ptr->call_data.call_outcome; + buf_len = add_tlv("2.1",1,temp_buf,0x80,&asn_buf); + } + } + return buf_len; +} + +int extract_statreparg(struct MapSR_Arg *sr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sr_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_status report buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + sr_ptr->param_flag |= 0x01; + memcpy(sr_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + if (get_tlv("1.0",temp_buf,&asn_buf) != -1) // ccbs subscriber status + { + sr_ptr->param_flag |= 0x02; + sr_ptr->event_data.param_flag |= 0x01; + sr_ptr->event_data.ccbs_stat = temp_buf[0]; + } + if (get_tlv("2.0",temp_buf,&asn_buf) != -1) // monitor mode + { + sr_ptr->param_flag |= 0x04; + sr_ptr->call_data.param_flag |= 0x01; + sr_ptr->call_data.monitor_mode = temp_buf[0]; + } + if (get_tlv("2.1",temp_buf,&asn_buf) != -1) // call outcome + { + sr_ptr->param_flag |= 0x04; + sr_ptr->call_data.param_flag |= 0x02; + sr_ptr->call_data.call_outcome = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding status report response */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_statrepres(struct MapSR_Res *sr_ptr,u8 *buf) +{ + return 0; +} + +int extract_statrepres(struct MapSR_Res *sr_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding remote user free argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_rmtuserfreearg(struct MapRUF_Arg *ruf_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (ruf_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,ruf_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (ruf_ptr->param_flag & 0x02) // call info + { + temp_len = assign_extsiginfo(&ruf_ptr->call_info,temp_buf); + buf_len = add_tlv("1",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (ruf_ptr->param_flag & 0x04) // ccbs feature + { + temp_len = assign_ccbsfeat(&ruf_ptr->ccbs_feat,temp_buf); + buf_len = add_tlv("2",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (ruf_ptr->param_flag & 0x08) // translate number + buf_len = add_tlv("3",ruf_ptr->trans_num[0],ruf_ptr->trans_num+1,0x80,&asn_buf); + tag1 = 5; + if (ruf_ptr->param_flag & 0x10) // replace number + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (ruf_ptr->param_flag & 0x20) // alert pattern + { + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,1,&ruf_ptr->alt_pattern,0x80,&asn_buf); + } + return buf_len; +} + +int extract_rmtuserfreearg(struct MapRUF_Arg *ruf_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ruf_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_remote user free buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + ruf_ptr->param_flag |= 0x01; + memcpy(ruf_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // get call info + if (len > 0) + { + if (!extract_extsiginfo(&ruf_ptr->call_info,len,temp_buf)) + return RER; + ruf_ptr->param_flag |= 0x02; + } + else + return RER; + len = get_tlv("2",temp_buf,&asn_buf); // get ccbs feature + if (len > 0) + { + if (!extract_ccbsfeat(&ruf_ptr->ccbs_feat,len,temp_buf)) + return RER; + ruf_ptr->param_flag |= 0x04; + } + else + return RER; + len = get_tlv("3",temp_buf,&asn_buf); // get tranlate number + if (len > 0 && len <= ISDN_LEN) + { + ruf_ptr->param_flag |= 0x08; + ruf_ptr->trans_num[0] = len; + memcpy(ruf_ptr->trans_num+1,temp_buf,len); + } + else + return RER; + if (get_tlv("4",temp_buf,&asn_buf) != -1) // get replace number + { + ruf_ptr->param_flag |= 0x10; + ruf_ptr->replace_num = 1; + } + if (get_tlv("5",temp_buf,&asn_buf) == 1) // get alert pattern + { + ruf_ptr->param_flag |= 0x20; + ruf_ptr->alt_pattern = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding remote user free response */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_rmtuserfreeres(struct MapRUF_Res *ruf_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (ruf_ptr->param_flag & 0x01) // ruf outcome + { + temp_buf[0] = ruf_ptr->ruf_outcome; + buf_len = add_tlv("0",1,temp_buf,0x80,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_rmtuserfreeres(struct MapRUF_Res *ruf_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + ruf_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_remote user free buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) + { + ruf_ptr->param_flag |= 0x01; + ruf_ptr->ruf_outcome = temp_buf[0]; + } + else + return RER; + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_code_dlgpdu.c b/omc/plat/xapp/src/mapp/map_code_dlgpdu.c new file mode 100644 index 0000000..fecd131 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_dlgpdu.c @@ -0,0 +1,209 @@ +/* MAP dialogue PDU coding/decoding c file */ +/* Written by Liu Zhiguo 2003-08-25 */ +/* Version: 1.0 */ +/* -------------------------------------- */ + +#include "map_includes.h" +#include "../../../tcap/src/include/tcap_head.h" +#include "../../../tcap/src/include/tcap_public.h" +#include "../../../tcap/src/include/tcap_struct.h" +#include "../xap_interfunc.h" +#include "map_dlgpdu.h" + + +static u8 MAPP_Dlgpdu[7] = {0x04,0x00,0x00,0x01,0x01,0x01,0x01}; + +u8 build_mapdlg(struct MapDlg_struct *dlg_ptr,u8 *data_buf) // build user information portion +{ + struct MapDlgOpen_struct *map_open; + struct MapDlgUAbort_struct *map_uabort; + ASN_BUF asn_buf; + u8 temp_buf[256],temp_data[256]; + int len=0,len1=0; + + asn_encode(temp_buf,&asn_buf); + switch (dlg_ptr->dlg_type) + { + case MAPDLG_OPEN: + map_open = (MapDlgOpen_struct *) &dlg_ptr->map_dlg.map_open; + if ((map_open->param_flag & 0x01)) + len1 = add_tlv("0.0",map_open->peer_ref[0],map_open->peer_ref+1,0x80,&asn_buf); + if ((map_open->param_flag & 0x02)) + len1 = add_tlv("0.1",map_open->local_ref[0],map_open->local_ref+1,0x80,&asn_buf); + break; + case MAPDLG_ACCEPT: + len1 = add_tlv("1",0,&dlg_ptr->dlg_type,0x80,&asn_buf); + break; + case MAPDLG_CLOSE: + len1 = add_tlv("2",0,&dlg_ptr->dlg_type,0x80,&asn_buf); + break; + case MAPDLG_REFUSE: + temp_data[0] = dlg_ptr->map_dlg.map_refuse.reason; + len1 = add_tlv("3.10",1,temp_data,0x00,&asn_buf); + break; + case MAPDLG_UABORT: + map_uabort = (MapDlgUAbort_struct *) &dlg_ptr->map_dlg.map_uabort; + switch (map_uabort->choice_flag) + { + case 0: + len1 = add_null("4.0",0x00,&asn_buf); + break; + case 1: + len1 = add_null("4.1",0x00,&asn_buf); + break; + case 2: + temp_data[0] = map_uabort->choice.resunavi; + len1 = add_tlv("4.2.10",1,temp_data,0x00,&asn_buf); + break; + case 3: + temp_data[0] = map_uabort->choice.appproccancel; + len1 = add_tlv("4.3.10",1,temp_data,0x00,&asn_buf); + break; + default: + break; + } + break; + case MAPDLG_PABORT: + temp_data[0] = dlg_ptr->map_dlg.map_pabort.reason; + len1 = add_tlv("5.10",1,temp_data,0x00,&asn_buf); + break; + default: + break; + } + asn_encode(data_buf,&asn_buf); + len = add_tlv("8",0,temp_data,0x20,&asn_buf); + len = add_tlv("8.6-1",7,MAPP_Dlgpdu,0x00,&asn_buf); + len = add_tlv("8.0-2",len1,temp_buf,0xa0,&asn_buf); + return len; +} + +u8 extract_mapdlg(struct MapDlg_struct *dlg_ptr,struct dlgport_struct *port_ptr) +{ + struct MapDlgOpen_struct *map_open; + struct MapDlgUAbort_struct *map_uabort; + ASN_BUF asn_buf; + u8 temp_buf[256],temp_data[256]; + int len; + + dlg_ptr->dlg_type = 0xff; + len = asn_decode(port_ptr->user_info,1,&asn_buf); + if (len != port_ptr->user_info_len) + { + xap_send_error("MAPP extract user info error"); + return 0; + } + len = get_tlv("8",temp_buf,&asn_buf); // get External tag + if (len == -1) // has nor external tag + { + xap_send_error("MAPP extract user info error"); + return 0; + } + len = get_tlv("8.6",temp_buf,&asn_buf); + if (len == 7) // get MAP dialgoue PDU + { + if (temp_buf[5] != 1 || temp_buf[6] != 1) + { + xap_send_error("MAPP extract user info error identifier"); + return 0; + } + } + len = get_tlv("8.0",temp_buf,&asn_buf); // get ASN.1 type + if (len == -1) + { + xap_send_error("MAPP extract user info error ASN.1 type"); + return 0; + } + len = asn_decode(temp_buf,1,&asn_buf); + len = get_tlv("0",temp_data,&asn_buf); // MAP_OPEN info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_OPEN; + map_open = (MapDlgOpen_struct *) &dlg_ptr->map_dlg.map_open; + map_open->param_flag = 0; + len = get_tlv("0.0",temp_data,&asn_buf); // local reference + if (len != -1) + { + map_open->param_flag |= 0x02; + map_open->local_ref[0] = len; + memcpy(map_open->local_ref+1,temp_data,len); + } + len = get_tlv("0.1",temp_data,&asn_buf); // peer reference + if (len != -1) + { + map_open->param_flag |= 0x01; + map_open->peer_ref[0] = len; + memcpy(map_open->peer_ref+1,temp_data,len); + } + return 1; + } + len = get_tlv("1",temp_data,&asn_buf); // MAP_ACCEPT info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_ACCEPT; + return 1; + } + len = get_tlv("2",temp_data,&asn_buf); // MAP_CLOSE info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_CLOSE; + return 1; + } + len = get_tlv("3",temp_data,&asn_buf); // MAP_REFUSE info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_REFUSE; + len = get_tlv("3.10",temp_data,&asn_buf); + if (len != 1) + { + xap_send_error("MAPP extract user info refuse lack reason"); + return 0; + } + dlg_ptr->map_dlg.map_refuse.param_flag = 0x01; + dlg_ptr->map_dlg.map_refuse.reason = temp_data[0]; + return 1; + } + len = get_tlv("4",temp_data,&asn_buf); // MAP_UABORT info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_UABORT; + map_uabort = (MapDlgUAbort_struct *) &dlg_ptr->map_dlg.map_uabort; + len = get_tlv("4.0",temp_data,&asn_buf); // user specific reason + if (len != -1) + map_uabort->choice_flag = 0; + len = get_tlv("4.1",temp_data,&asn_buf); // user resource limitation + if (len != -1) + map_uabort->choice_flag = 1; + len = get_tlv("4.2",temp_data,&asn_buf); // resource unabailable + if (len != -1) + { + map_uabort->choice_flag = 2; + len = get_tlv("4.2.10",temp_data,&asn_buf); + if (len == -1) + return 0; + map_uabort->choice.resunavi = temp_data[0]; + } + len = get_tlv("4.3",temp_data,&asn_buf); // APC + if (len != -1) + { + map_uabort->choice_flag = 3; + len = get_tlv("4.3.10",temp_data,&asn_buf); + if (len == -1) + return 0; + map_uabort->choice.appproccancel = temp_data[0]; + } + return 1; + } + len = get_tlv("5",temp_data,&asn_buf); // MAP_PAOBRT info + if (len != -1) + { + dlg_ptr->dlg_type = MAPDLG_PABORT; + len = get_tlv("5.10",temp_data,&asn_buf); + if (len != 1) + return 0; + dlg_ptr->map_dlg.map_pabort.param_flag = 0x01; + dlg_ptr->map_dlg.map_pabort.reason = temp_data[0]; + return 1; + } + xap_send_error("MAPP extract user info unknown type"); + return 0; +} diff --git a/omc/plat/xapp/src/mapp/map_code_ms.c b/omc/plat/xapp/src/mapp/map_code_ms.c new file mode 100644 index 0000000..5681825 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_ms.c @@ -0,0 +1,4697 @@ +/* map coding mobile service c file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "map_includes.h" + + +SCCP_ADDR *did_to_sccpAddr(u32 dialogue_id); + +int assign_sscsi(char *tag_prefix, struct SsCsi_struct *p_csi, ASN_BUF *asnbuf) +{ + char tagseq[32]; + int ii, buflen; + + sprintf(tagseq, "%s.16-1", tag_prefix); + add_null(tagseq, 0x20, asnbuf); + if(p_csi->event_list.list_len > CAMELSS_LEN) + return RER; + sprintf(tagseq, "%s.16-1.16", tag_prefix); + add_null(tagseq, 0x20, asnbuf); + for(ii = 0;ii < p_csi->event_list.list_len; ii++) + { + sprintf(tagseq, "%s.16-1.16.4-%d", tag_prefix, ii+1); + buflen = add_tlv(tagseq, 1, &p_csi->event_list.ss_code[ii], 0x00, asnbuf); + } + buflen = p_csi->scf_add[0]; + sprintf(tagseq, "%s.16-1.4-10", tag_prefix); + buflen = add_tlv(tagseq, buflen, p_csi->scf_add + 1, 0x00, asnbuf); + return buflen; +} + +int extract_sscsi(char *tag_prefix, struct SsCsi_struct *p_csi, ASN_BUF *asnbuf) +{ + char tagseq[32]; + int retval = -1, ii = 0; + + while(ii < CAMELSS_LEN) + { + sprintf(tagseq, "%s.16.16.4-%d", tag_prefix, ii); + if((retval = GetTLV(tagseq, 1, &p_csi->event_list.ss_code[ii], 0x00, asnbuf)) < 0) + break; + ii ++; + } + if(ii == 0) + return RER; + sprintf(tagseq, "%s.16.4", tag_prefix); + if((retval = GetTLV(tagseq, ISDN_LEN, p_csi->scf_add + 1, 0x00, asnbuf)) < 0) + return RER; + p_csi->scf_add[0] = retval; + return ROK; +} + +int assign_smscsi(char *tag_prefix, struct SMSCsi_struct *p_csi, ASN_BUF *asnbuf) +{ + char tagseq[32]; + int len=0, ii, buflen; + + if((p_csi->param_flag & 0x01) == 0x01) + { + if(p_csi->tdpdata_list.tdpdata_len > TDPDATA_NUM) + return -1; + for(ii = 0; ii < p_csi->tdpdata_list.tdpdata_len; ii++) //sms-BCSM Camel TDP Data List + { + sprintf(tagseq, "%s.0.16-%d", tag_prefix, ii + 1); + add_null(tagseq, 0x20, asnbuf); + sprintf(tagseq, "%s.0.16-%d.0-1", tag_prefix, ii + 1); + len = AddInteger(tagseq, p_csi->tdpdata_list.tdp_data[ii].det_point, 0x80, asnbuf); + sprintf(tagseq, "%s.0.16-%d.1-2", tag_prefix, ii + 1); + len = AddInteger(tagseq, p_csi->tdpdata_list.tdp_data[ii].service_key, 0x80, asnbuf); + if((buflen = p_csi->tdpdata_list.tdp_data[ii].scf_add[0]) > ISDN_LEN) + buflen = ISDN_LEN; + sprintf(tagseq, "%s.0.16-%d.2-3", tag_prefix, ii + 1); + len = AddTLV(tagseq, buflen, p_csi->tdpdata_list.tdp_data[ii].scf_add + 1, 0x80, asnbuf); + sprintf(tagseq, "%s.0.16-%d.3-4", tag_prefix, ii + 1); + len = AddInteger(tagseq, p_csi->tdpdata_list.tdp_data[ii].def_hand, 0x80, asnbuf); + } + } + if((p_csi->param_flag & 0x02) == 0x02) //camel capability Handling + { + sprintf(tagseq, "%s.1", tag_prefix); + len = AddInteger(tagseq, p_csi->camel_caphand, 0x80, asnbuf); + } + if((p_csi->param_flag & 0x04) == 0x04) //notificationTOCSE + { + sprintf(tagseq, "%s.3", tag_prefix); + len = add_null(tagseq, 0x80, asnbuf); + } + if((p_csi->param_flag & 0x08) == 0x08) //csiActive + { + sprintf(tagseq, "%s.4", tag_prefix); + len = add_null(tagseq, 0x80, asnbuf); + } + return len; +} + +int extract_smscsi(char *tag_prefix, struct SMSCsi_struct *p_csi, ASN_BUF *asnbuf) +{ + char tagseq[32]; + int retval = -1, ii =0 ; + + p_csi->param_flag = 0; + while(ii < TDPDATA_NUM) + { + sprintf(tagseq, "%s.0.16-%d.0", tag_prefix, ii + 1); + if((retval = GetInteger(tagseq, (int *)&p_csi->tdpdata_list.tdp_data[ii].det_point, 0x80, asnbuf)) < 0) + break; + sprintf(tagseq, "%s.0.16-%d.1", tag_prefix, ii + 1); + if((retval = GetInteger(tagseq, (int *)&p_csi->tdpdata_list.tdp_data[ii].service_key, 0x80, asnbuf)) < 0) + break; + sprintf(tagseq, "%s.0.16-%d.2", tag_prefix, ii + 1); + if((retval = GetTLV(tagseq, ISDN_LEN, p_csi->tdpdata_list.tdp_data[ii].scf_add + 1, 0x80, asnbuf)) < 0) + break; + p_csi->tdpdata_list.tdp_data[ii].scf_add[0] = retval; + sprintf(tagseq, "%s.0.16-%d.3", tag_prefix, ii + 1); + if((retval = GetInteger(tagseq, (int *)&p_csi->tdpdata_list.tdp_data[ii].def_hand, 0x80, asnbuf)) < 0) + break; + ii ++; + } + if(ii > 0) + { + p_csi->param_flag |= 0x01; + p_csi->tdpdata_list.tdpdata_len = ii; + } + //camel Capability Handling + sprintf(tagseq, "%s.1", tag_prefix); + if(GetInteger(tagseq, (int *)&p_csi->tdpdata_list.tdp_data[ii].def_hand, 0x80, asnbuf) > 0) + p_csi->param_flag |= 0x02; + //notificationTOCSE + sprintf(tagseq, "%s.3", tag_prefix); + if(get_null(tagseq, asnbuf) >= 0) + { + p_csi->param_flag |= 0x04; + p_csi->notificationToCSE = 1; + } + //csi-Active + sprintf(tagseq, "%s.4", tag_prefix); + if(get_null(tagseq, asnbuf) >= 0) + { + p_csi->param_flag |= 0x08; + p_csi->csi_Active = 1; + } + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding update loction argument */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_uplocarg(struct MapUL_Arg *ul_ptr,u8 *buf ,u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = ul_ptr->param_flag; + if (flag & 0x01) // has IMSI + buf_len = add_tlv("4-1",IMSI_LEN,ul_ptr->imsi,0x00,&asn_buf); + else + { + mapp_log_debug("update location request lack IMSI"); + return RER; + } + if ( (flag & 0x02) && ( !(flag & 0x20) || ver >1 ) ) // has not MSC number + buf_len = add_tlv("1-2",ul_ptr->msc_num[0],ul_ptr->msc_num+1,0x80,&asn_buf); + else + { + mapp_log_debug("update location request lack MSISDN"); + return RER; + } + + if (flag & 0x04) // has not VLR address + buf_len = add_tlv("4-3",ul_ptr->vlr_num[0],ul_ptr->vlr_num+1,0x00,&asn_buf); + else + { + mapp_log_debug("update location request lack VLR address"); + return RER; + } + tag1 = 4; + if (flag & 0x08) // has LMSI + { + sprintf(tlv1,"10-%d",tag1++); + buf_len = add_tlv(tlv1,LMSI_LEN,ul_ptr->lmsi,0x80,&asn_buf); + } + if (flag & 0x10) // vlr capability + { + if (ul_ptr->vlr_cap.param_flag & 0x01) // camel phase + { + sprintf(tlv1,"6-%d.0",tag1++); + buf_len = add_tlv(tlv1,3,ul_ptr->vlr_cap.camel_phase,0x80,&asn_buf); + } + } + + if( (flag & 0x20) && !(flag & 0x02) && (ver == 1) ) + buf_len = add_tlv("0-2",ul_ptr->vlr_num[0],ul_ptr->vlr_num+1,0x00,&asn_buf); + else + { + mapp_log_debug("update location request lack VLR address"); + return RER; + } + return buf_len; +} + +int extract_uplocarg(struct MapUL_Arg *ul_ptr,u32 buf_len,u8 *buf ,u8 ver) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u32 flag = 0; + + ul_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4-1",temp_buf,&asn_buf); // get imsi + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0)// get IMSI + { + flag |= 0x01; + memcpy(ul_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("update location indicate error IMSI"); + return RER; + } + len = get_tlv("0", temp_buf,&asn_buf); + if( len > 2 ) + { + flag |= 0x20; + ul_ptr->roaming_num[0] = len; + memcpy( ul_ptr->roaming_num+1,temp_buf,len); + } + else if ((len = get_tlv("1",temp_buf,&asn_buf)) > 2) // get MSC number + { + flag |= 0x02; + ul_ptr->msc_num[0] = len; + memcpy(ul_ptr->msc_num+1,temp_buf,len); + } + else + { + mapp_log_debug("update location indicate lack MSC number or roaming num"); + return RER; + } + if ((len = get_tlv("4-3",temp_buf,&asn_buf)) > 2) // get VLR number + { + flag |= 0x04; + ul_ptr->vlr_num[0] = len; + memcpy(ul_ptr->vlr_num+1,temp_buf,len); + } + else + { + mapp_log_debug("update location indicate lack VLR number"); + return RER; + } + len = get_tlv("10",temp_buf,&asn_buf); // get lmsi number + if (len == LMSI_LEN) + { + flag |= 0x08; + memcpy(ul_ptr->lmsi,temp_buf,LMSI_LEN); + } + len = get_tlv("6.0",temp_buf,&asn_buf); //get camel info + if (len != -1) + { + memcpy(ul_ptr->vlr_cap.camel_phase,temp_buf,3); + flag |= 0x10; + } + ul_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding update loction response */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_uplocres(struct MapUL_Res *ul_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ul_ptr->param_flag & 0x01) + buf_len = add_tlv("4",ul_ptr->hlr_num[0],ul_ptr->hlr_num+1,0x00,&asn_buf); + else + { + mapp_log_debug("update location response lack hlr number"); + return RER; + } + return buf_len; +} + +int extract_uplocres(struct MapUL_Res *ul_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ul_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_uplocres buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if ((len = get_tlv("4",temp_buf,&asn_buf)) > 2) // get HLR number + { + ul_ptr->param_flag |= 0x01; + ul_ptr->hlr_num[0] = len; + memcpy(ul_ptr->hlr_num+1,temp_buf,len); + } + else + { + mapp_log_debug("update location confirm lack HLR number"); + return RER; + } + return ROK; +} + + + +/* --->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MAP V1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,---*/ + + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send parameters argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_SendParaArg(struct MapSP_Arg *sendpara_ptr,u8 *buf) // lw_add +{ + ASN_BUF asn_buf; + int flag,buf_len=0; + + int temp_index; + int param_num; + + asn_encode(buf,&asn_buf); + flag = sendpara_ptr->param_flag; + //add_null("16", 0x20, &asn_buf); + buf_len = AddTLV("16",0,NULL,0x20,&asn_buf); + if( sendpara_ptr->param_flag & 0x01 ) + { + if(sendpara_ptr->sub_id.choice_flag == 1)//imsi + { + buf_len = add_tlv("16.0",IMSI_LEN,sendpara_ptr->sub_id.id_choice.imsi,0x80,&asn_buf); + } + else if(sendpara_ptr->sub_id.choice_flag == 2)//tmsi + { + + buf_len = add_tlv("16.1",TMSI_LEN,sendpara_ptr->sub_id.id_choice.tmsi,0x80,&asn_buf); + } + else + { + mapp_log_debug("sendParameter indicate subscriber id choice error");;//do report err + } + } + else + { + mapp_log_debug("sendParameter indicate lack subscriber id ");;//do report err + } + //Request Parameter List + if( sendpara_ptr->param_flag & 0x02 ) + { + char tag[16]; + param_num = sendpara_ptr->ReqPara_num; + if( sendpara_ptr->ReqPara_num > 2 ) + { + mapp_log_debug("sendParameter indicate request parameter list num error");;//do reptor_err; + param_num = 2; + } + //add_null("16", 0x20, &asn_buf); + buf_len = AddTLV("16.16",0,NULL,0x20,&asn_buf); + for( temp_index =0 ;temp_index < param_num ;temp_index ++) + { + sprintf(tag,"16.16.10-%d",temp_index+1); + buf_len = add_tlv(tag,1,(u8 *)&sendpara_ptr->ReqPara[temp_index],0x00,&asn_buf); + } + } + else + { + mapp_log_debug("sendParameter indicate lack Request Parameter List ");;//do report err + } + return buf_len; +} + + + +int extract_SendParaArg(struct MapSP_Arg *sendpara_ptr,u32 buf_len,u8 *buf) //lw_add +{ + ASN_BUF asn_buf; + int len,index; + u8 temp_buf[256]; + + sendpara_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("0-1",temp_buf,&asn_buf); // get IMSI + if (len ==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + sendpara_ptr->param_flag |= 0x01; + sendpara_ptr->sub_id.choice_flag = 0x01; + memcpy(sendpara_ptr->sub_id.id_choice.imsi,temp_buf,len); + } + + len = get_tlv("1-1",temp_buf,&asn_buf); // get TMSI + if (len == TMSI_LEN) + { + sendpara_ptr->param_flag |= 0x01; + sendpara_ptr->sub_id.choice_flag = 0x02; + memcpy(sendpara_ptr->sub_id.id_choice.tmsi,temp_buf,len); + } + + index =0 ; + while( ( len = get_tlv("16-2.10",temp_buf,&asn_buf) ) == 1 && index < 2 ) + { + memcpy( sendpara_ptr->ReqPara+index++ , temp_buf , len ); // get Request parameter + } + if( index > 0 ) + { + sendpara_ptr->param_flag |= 0x02; + sendpara_ptr->ReqPara_num = index ; + } + return ROK; +} + + + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send parameters response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_Sub_Data(Sub_data_struct *sub_data, u8 *buf ) +{ + ASN_BUF asn_buf; + int jj,kk; + u32 flag1; + u32 flag; + u32 len; + int buf_len=0; + int temp_len; + u8 temp_data[256],temp_buf[256]; + u8 tag1=1,tag2=1,tag3=1,tag4=1,tag5=1; + char tlv1[32],tlv2[32],tlv3[32],tlv4[32],tlv5[32]; + struct ExtFwdInfo_struct *fwd_ptr; + struct ExtSsData_struct *ss_ptr; + struct ExtCallBarInfo_struct *callbar_ptr; + + asn_encode(buf,&asn_buf); + flag = sub_data->param_flag; + + if (flag & 0x02) // MSISDN + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,sub_data->msisdn[0],sub_data->msisdn+1,0x80,&asn_buf); + } + if (flag & 0x04) // category + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&sub_data->category,0x80,&asn_buf); + } + if (flag & 0x08) // sub status + { + sprintf(tlv1,"3-%d",tag1++); + temp_data[0] = sub_data->sub_status; + buf_len = add_tlv(tlv1,1,temp_data,0x80,&asn_buf); + } + if (flag & 0x20) // bearer service list + { + temp_len = bearer_bittostr(sub_data->bearer_data,temp_data,0); + + if(temp_len > 0) + { + sprintf(tlv1,"4-%d",tag1++); + + for (jj = 0;jj < temp_len;jj ++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,temp_data+jj,0x00,&asn_buf); + } + } + } + if (flag & 0x40) // tele service list + { + temp_len = tele_bittostr(sub_data->tele_data,temp_data,0); + if(temp_len > 0) + { + sprintf(tlv1,"6-%d",tag1++); + for (jj = 0;jj < temp_len;jj++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,temp_data+jj,0x00,&asn_buf); + } + } + } + if (flag & 0x80) // ss info list + { + sprintf(tlv1,"7-%d",tag1++); + tag2 = 1; + if (sub_data->ss_info.param_flag & 0x01) // fwd info + { + fwd_ptr = (ExtFwdInfo_struct *) &sub_data->ss_info.fwd_info; + for (jj = 0;jj < 4;jj ++) //tag2 + { + tag3 = 1; + kk = 0x01 << jj; + if (fwd_ptr->param_flag & kk) + { + sprintf(tlv2,"%s.0-%d",tlv1,tag2++); + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); // for ss_code + buf_len = add_tlv(tlv3,1,&fwd_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.16-%d",tlv2,tag3++); + add_null(tlv3,0x20,&asn_buf); + tag4 = 1; + sprintf(tlv4,"%s.16-%d",tlv3,tag4); + add_null(tlv4,0x20,&asn_buf); + tag5 = 1; + flag1 = fwd_ptr->fwd_feat[jj].param_flag; + if (flag1 & 0x01) // bs group + { + if (fwd_ptr->fwd_feat[jj].bs_code.param_flag == 1) + { + sprintf(tlv5,"%s.2-%d",tlv4,tag5++); + if (tele_bittostr(fwd_ptr->fwd_feat[jj].bs_code.tele_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + else if(fwd_ptr->fwd_feat[jj].bs_code.param_flag == 2) + { + sprintf(tlv5,"%s.3-%d",tlv4,tag5++); + if (bearer_bittostr(fwd_ptr->fwd_feat[jj].bs_code.bearer_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + } + if (flag1 & 0x02) //ss status + { + sprintf(tlv5,"%s.4-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].ss_status,0x80,&asn_buf); + } + if (flag1 & 0x04) //fwdto_num + { + sprintf(tlv5,"%s.5-%d",tlv4,tag5++); + len = fwd_ptr->fwd_feat[jj].fwdto_num[0]; + buf_len = add_tlv(tlv5,len,fwd_ptr->fwd_feat[jj].fwdto_num+1,0x80,&asn_buf); + } + if (flag1 &0x08) //fwd opt + { + sprintf(tlv5,"%s.6-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].fwd_option,0x80,&asn_buf); + } + if (flag1 &0x10) //norc time + { + sprintf(tlv5,"%s.7-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].norc_time,0x80,&asn_buf); + } + } + } + } + if (sub_data->ss_info.param_flag & 0x02) // call bar info + { + callbar_ptr = (ExtCallBarInfo_struct *) &sub_data->ss_info.call_info; + for (jj = 0;jj < 5;jj ++) + { + kk = 0x01 << jj; + if ((callbar_ptr->param_flag & kk) != 0) + { + sprintf(tlv2,"%s.1-%d",tlv1,tag2++); + tag3 = 1; + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&callbar_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.16-%d",tlv2,tag3++); + add_null(tlv3,0x20,&asn_buf); + tag4 = 1; + sprintf(tlv4,"%s.16-%d",tlv3,tag4); + add_null(tlv4,0x20,&asn_buf); + tag5 = 1; + if (callbar_ptr->bs_code[jj].param_flag == 2) + { + sprintf(tlv5,"%s.2-%d",tlv4,tag5++); + if (bearer_bittostr(callbar_ptr->bs_code[jj].bearer_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + else if (callbar_ptr->bs_code[jj].param_flag == 1) + { + sprintf(tlv5,"%s.3-%d",tlv4,tag5++); + if (tele_bittostr(callbar_ptr->bs_code[jj].tele_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + sprintf(tlv5,"%s.4-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&callbar_ptr->ss_status[jj],0x80,&asn_buf); + } + } + } + if (sub_data->ss_info.param_flag & 0x08) // ss data + { + ss_ptr = (ExtSsData_struct *)&sub_data->ss_info.ss_data; + for(jj = 0;jj < 16;jj ++) + { + kk = 0x01 << jj; + if (ss_ptr->param_flag & kk) + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + tag3 = 1; + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&ss_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&ss_ptr->ss_status[jj],0x80,&asn_buf); + if (ss_ptr->subs_opt[jj].choice_flag == 1) + { + sprintf(tlv3,"%s.2-%d",tlv2,tag3++); + temp_buf[0] = ss_ptr->subs_opt[jj].choice.clires_opt; + buf_len = add_tlv(tlv3,1,temp_buf,0x80,&asn_buf); + } + else if (ss_ptr->subs_opt[jj].choice_flag == 2) + { + sprintf(tlv3,"%s.1-%d",tlv2,tag3++); + temp_buf[0] = ss_ptr->subs_opt[jj].choice.over_cate; + buf_len = add_tlv(tlv3,1,temp_buf,0x80,&asn_buf); + } + } + } + } + } + + if (flag & 0x10) // odb-data + { + if(sub_data->odb_data.param_flag & 0x03) + { + sprintf(tlv1,"8-%d",tag1++); + tag2 = 1; + if (sub_data->odb_data.param_flag & 0x01) // ODB general data + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + temp_buf[0] = sub_data->odb_data.odb_general >> 8; + temp_buf[1] = sub_data->odb_data.odb_general; + len = bytestrtobitstr(temp_data,temp_buf,6); + //len = bytestrtobitstr(temp_data,temp_buf,15); /* odb is 6bitstring for version1/2 */ + buf_len = add_tlv(tlv2,len,temp_data,0x00,&asn_buf); + } + if (sub_data->odb_data.param_flag & 0x02) // ODB HPLMN data + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + temp_buf[0] = sub_data->odb_data.odb_hplmn; + len = bytestrtobitstr(temp_data,temp_buf,4); + buf_len = add_tlv(tlv2,len,temp_data,0x00,&asn_buf); + } + } + } + + + if (flag & 0x100) // roaming restriction due to unsuppoerted feature + { + sprintf(tlv1,"9-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x200) // regional Subscription Data + { + if (sub_data->zc_list.list_len > ZONECODE_LEN) + return RER; + for (jj = 0;jj < sub_data->zc_list.list_len;jj ++) + { + sprintf(tlv1,"10-%d.4-%d",tag1,jj+1); + buf_len = add_tlv(tlv1,2,sub_data->zc_list.zone_code[jj],0x00,&asn_buf); + } + tag1 ++; + } + return buf_len; +} + +int extract_Sub_Data(Sub_data_struct *sub_data , u32 buf_len , u8 *buf) +{ + ASN_BUF asn_buf; + int len,jj; + int temp_len; + u32 flag=0; + u8 tag1; + char tlv2[32],tlv3[32]; + u8 temp_buf[256],temp_data[256]; + struct ExtFwdInfo_struct *fwd_ptr; + struct ExtCallBarInfo_struct *callbar_ptr; + struct ExtSsData_struct *ss_ptr; + + sub_data->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + flag |= 0x01; + memcpy(sub_data->imsi,temp_buf,len); + } + if ((len=get_tlv("1",temp_buf,&asn_buf)) > 2) + { + flag |= 0x02; + sub_data->msisdn[0] = len; + memcpy(sub_data->msisdn+1,temp_buf,len); + } + if (get_tlv("2",temp_buf,&asn_buf) > 0) + { + flag |= 0x04; + sub_data->category = temp_buf[0]; + } + if(get_tlv("3",temp_buf,&asn_buf) > 0) + { + flag |= 0x08; + sub_data->sub_status = temp_buf[0]; + } + sub_data->odb_data.param_flag = 0; + len = get_tlv("8.3-1",temp_buf,&asn_buf); //odb-data->odb->GreneralData + if (len != -1) + { + flag |= 0x10; // odb - data + sub_data->odb_data.param_flag |= 0x01; //odb general + jj = bitstrtobytestr(temp_data,temp_buf,len); + sub_data->odb_data.odb_general = bcdtou32(temp_data,jj); + } + len = get_tlv("8.3-2",temp_buf,&asn_buf); + if (len != -1) + { + flag |= 0x10; // odb - data + sub_data->odb_data.param_flag |= 0x02; // odb hplmn + jj = bitstrtobytestr(temp_data,temp_buf,len); + sub_data->odb_data.odb_hplmn = bcdtou32(temp_data,jj); + } + temp_len = 0; + for (jj = 0;jj < BSLIST_LEN;jj ++) // bearer Service List + { + sprintf(tlv2,"4.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len ++; + flag |= 0x20; + } + sub_data->bearer_data = bearer_strtobit(temp_data,temp_len); + temp_len = 0; + for (jj = 0;jj < TSLIST_LEN;jj ++) // tele Service List + { + sprintf(tlv2,"6.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len++; + flag |= 0x40; + } + sub_data->tele_data = tele_strtobit(temp_data,temp_len); + sub_data->ss_info.param_flag = 0; + tag1 = 1; + if (get_tlv("7.0",temp_buf,&asn_buf) != -1) // forwarding info + { + flag |= 0x80; // ss info + sub_data->ss_info.param_flag |= 0x01; // fwd info + fwd_ptr = (ExtFwdInfo_struct *)&sub_data->ss_info.fwd_info; + fwd_ptr->param_flag = 0; + for (jj = 0;jj < 4;jj ++) + { + fwd_ptr->fwd_feat[jj].param_flag = 0; + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 0; + sprintf(tlv2,"7.0-%d.4",tag1); // ss code + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len > 0) + { + fwd_ptr->param_flag |= (0x01 << jj); + fwd_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.0-%d.16.16",tag1); // forward feature + sprintf(tlv3,"%s.2",tlv2); // bearer code of bs code + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len > 0) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x01; + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 2; // bearer + fwd_ptr->fwd_feat[jj].bs_code.bearer_code = bearer_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.3",tlv2); // tele code of bs code + len = get_tlv(tlv3,temp_buf, &asn_buf); + if (len >= 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x01; // bs code + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 1;// tele + fwd_ptr->fwd_feat[jj].bs_code.tele_code = tele_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.4",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x02; // ss status + fwd_ptr->fwd_feat[jj].ss_status = temp_buf[0]; + } + sprintf(tlv3,"%s.5",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x04; // fwd to num + fwd_ptr->fwd_feat[jj].fwdto_num[0] = len; + memcpy(fwd_ptr->fwd_feat[jj].fwdto_num+1,temp_buf,len); + } + sprintf(tlv3,"%s.6",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x08; // fwd opt + fwd_ptr->fwd_feat[jj].fwd_option = temp_buf[0]; + } + sprintf(tlv3,"%s.7",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x10; // norc time + fwd_ptr->fwd_feat[jj].norc_time = temp_buf[0]; + } + tag1 ++; + } + } + if (get_tlv("7.1",temp_buf,&asn_buf) != -1) // call Barring Info + { + flag |= 0x80; // ss info + sub_data->ss_info.param_flag |= 0x02; // call bar info + callbar_ptr = (ExtCallBarInfo_struct *)&sub_data->ss_info.call_info; + callbar_ptr->param_flag = 0; + for (jj = 0;jj < 5;jj ++) + { + callbar_ptr->bs_code[jj].param_flag = 0; + sprintf(tlv2,"7.1-%d.4",tag1); //callbarringInfo + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + callbar_ptr->param_flag |= (0x01 << jj); // ss code + callbar_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.1-%d.16.16",tag1); + sprintf(tlv3,"%s.4",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + callbar_ptr->ss_status[jj] = temp_buf[0]; + sprintf(tlv3,"%s.2",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + callbar_ptr->bs_code[jj].param_flag = 2; // bearer + callbar_ptr->bs_code[jj].bearer_code = bearer_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.3",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + callbar_ptr->bs_code[jj].param_flag = 1; // bearer + callbar_ptr->bs_code[jj].tele_code = tele_strtobit(temp_buf,1); + } + tag1 ++; + } + } + if (get_tlv("7.3",temp_buf,&asn_buf) != -1) // ss_Data + { + flag |= 0x80; // ss info + sub_data->ss_info.param_flag |= 0x08; // ss data + ss_ptr = (ExtSsData_struct *)&sub_data->ss_info.ss_data; + ss_ptr->param_flag = 0; + for(jj = 0;jj < 16;jj ++) + { + sprintf(tlv2,"7.3-%d.4-1",tag1); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->param_flag |= (0x01 << jj); + ss_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.3-%d.4-2",tag1); //ss-status +// len = get_tlv(tlv2,temp_buf,&asn_buf); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + ss_ptr->ss_status[jj] = temp_buf[0]; + ss_ptr->subs_opt[jj].choice_flag = 0; + sprintf(tlv2,"7.3-%d.2-3",tag1); //cliRestrictionOption + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->subs_opt[jj].choice_flag = 1; // clires opt + ss_ptr->subs_opt[jj].choice.clires_opt = temp_buf[0]; + } + sprintf(tlv2,"7.3-%d.1-3",tag1); //overrideCategory + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->subs_opt[jj].choice_flag = 2; // clires opt + ss_ptr->subs_opt[jj].choice.over_cate = temp_buf[0]; + } + sprintf(tlv2,"7.3-%d.2-2",tag1); // bearer code + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len > 0) + ss_ptr->bs_code[jj].bearer_code = bearer_strtobit(temp_buf,1); + sprintf(tlv2,"7.3-%d.3",tag1); // tele code + len = get_tlv(tlv2,temp_buf, &asn_buf); + if (len >= 1) + ss_ptr->bs_code[jj].tele_code = tele_strtobit(temp_buf,1); + tag1 ++; + } + } + if (get_null("9",&asn_buf) != -1) //get roaming restriction data + { + flag |= 0x100; + sub_data->roam_feature = 1; + } + len = get_tlv("10",temp_buf,&asn_buf); //regional Subscription Data + if (len > 0) + { + flag |= 0x200; + for (jj = 0;jj < ZONECODE_LEN;jj ++) + { + sprintf(tlv2,"10.4-%d",jj+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len == 2) + memcpy(sub_data->zc_list.zone_code[jj],temp_buf,2); + else + break; + } + sub_data->zc_list.list_len = jj; + } + + sub_data->param_flag = flag; + return ROK; +} + +int assign_SendParaRes(struct MapSP_Res *sp_ptr,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0,param_num,index,temp_len; + u8 temp_buf[256]; + char tag[16]; + //char str[640]; + u8 uSubDataCount = 0 ; + + asn_encode(buf,&asn_buf); + flag = sp_ptr->param_flag; + + if (flag & 0x01) // has sentparalist + { + param_num = sp_ptr->sendparamlist_num ; + if( param_num > 6) + { + mapp_log_debug("send param response sentparalist num error, is more than 6");;//do report err + param_num = 6 ; + } + + for( index = 0 ; index < param_num ; index++ ) + { + if( sp_ptr->sendparalist[index].choice_flag == 4 ) + { + uSubDataCount++; + } + } + + if( uSubDataCount > 2) + { + mapp_log_debug("send param response sentparalist sub data is too much, may exceed the supported map message len\r\n");;//do report err + return buf_len; + } + + buf_len = add_null("16",0x20,&asn_buf); + for( index=0; index< param_num ; index++) + { + switch( sp_ptr->sendparalist[index].choice_flag ) + { + case 1: //imsi + sprintf(tag,"16.0-%d",index+1); + buf_len = add_tlv(tag,IMSI_LEN,sp_ptr->sendparalist[index].SP_Res_Choice.imsi,0x80,&asn_buf); + break; + case 2: // authlist set + sprintf(tag,"16.1-%d",index+1); + temp_len = assign_authset( (struct AuthSet_struct* )&sp_ptr->sendparalist[index].SP_Res_Choice.auth_set, temp_buf ); + buf_len = add_tlv(tag, temp_len, temp_buf, 0xa0, &asn_buf); + break; + case 4: // sub data + sprintf(tag,"16.2-%d",index+1); + memset( temp_buf ,0 ,256); + temp_len = assign_Sub_Data( &sp_ptr->sendparalist[index].SP_Res_Choice.sub_data , temp_buf ); + //Bcd2Str_Space(str, temp_buf, temp_len); + //printf("\r\nsub data code :[%d]\r\n%s\r\n",temp_len,str); + buf_len = add_tlv(tag, temp_len, temp_buf, 0xa0, &asn_buf); + break; + case 8: //ki + sprintf(tag,"16.4-%d",index+1); + buf_len = add_tlv(tag,16,sp_ptr->sendparalist[index].SP_Res_Choice.ki,0x80,&asn_buf); + break; + default: + break; + } + } + } + //Bcd2Str_Space(str, buf, buf_len); + //printf("\r\nSend para Res code :[%d]\r\n%s\r\n",buf_len,str); + return buf_len; +} + +int extract_SendParaRes ( struct MapSP_Res *sp_ptr, u32 buf_len, u8 * buf ) // lw add +{ + ASN_BUF asn_buf; + int index; + u8 temp_buf[256]; + int temp_len; + char tag[16]; + + sp_ptr->param_flag = 0; + + if( buf_len == 0 ) + return RER; + if( asn_decode_v3 ( buf, buf_len, &decErr, &asn_buf ) == -1 ) + return RER; + for ( index = 0; index < 6; index++ ) + { + + sprintf(tag,"16.0-%d",index+1); + if( ( ( temp_len = get_tlv ( tag, temp_buf, &asn_buf ) ) != -1 ) && ( ( temp_buf[IMSI_LEN - 1] & 0xf0 ) == 0xf0 ) ) + { + sp_ptr->param_flag |= 0x01; + sp_ptr->sendparamlist_num++; + sp_ptr->sendparalist[index].choice_flag = 1; + memcpy ( sp_ptr->sendparalist[index].SP_Res_Choice.imsi, temp_buf, temp_len ); + continue; + } + else + { + sprintf(tag,"16.1-%d",index+1); + if( ( temp_len = get_tlv ( tag, temp_buf, &asn_buf ) ) > 0 ) + { + sp_ptr->param_flag |= 0x01; + sp_ptr->sendparamlist_num++; + if( ( extract_authset ( ( struct AuthSet_struct * ) &sp_ptr->sendparalist[index].SP_Res_Choice.auth_set, temp_len, temp_buf ) ) != 0 ) + { + sp_ptr->sendparalist[index].choice_flag = 2; + continue; + } + } + else + { + sprintf(tag,"16.2-%d",index+1); + if( ( temp_len = get_tlv ( tag, temp_buf, &asn_buf ) ) > 0 ) + { + sp_ptr->param_flag |= 0x01; + sp_ptr->sendparamlist_num++; + if( ( extract_Sub_Data ( &sp_ptr->sendparalist[index].SP_Res_Choice.sub_data, temp_len, temp_buf ) ) != 0 ) + { + sp_ptr->sendparalist[index].choice_flag = 4; + continue; + } + } + else + { + sprintf(tag,"16.4-%d",index+1); + if( ( temp_len = get_tlv ( tag, temp_buf, &asn_buf ) ) > 0 ) + { + sp_ptr->sendparalist[index].choice_flag = 8; + memcpy ( sp_ptr->sendparalist[index].SP_Res_Choice.ki, temp_buf, temp_len ); + sp_ptr->sendparamlist_num++; + continue; + } + else + { + if( 0 == index ) + { + return RER; + } + else + { + break; + } + } + } + } + } + } + //} + return ROK; +} + + + + + + + + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding noteSubscriberPresent argument*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_NotPresentArg(struct MapNP_Arg *np_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = np_ptr->param_flag; + if (flag == 0x01) // has lmsi + { + + buf_len = add_tlv("4",IMSI_LEN,np_ptr->imsi,0x00,&asn_buf); + } + else + { + mapp_log_debug("nosubsriberpresent param flag error"); + return -1; + } + + return buf_len; +} + +int extract_NotPresentArg( struct MapNP_Arg *np_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + np_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4",temp_buf,&asn_buf); // get IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + np_ptr->param_flag = 0x01; + memcpy(np_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("nosubsriberpresent lack imsi or imsi err\r\n"); + return RER; + } + + return ROK; +} + + + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding ProcessUnstructuredSS-Data argument*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_ProcessUSSDArg(struct MapPUSSD_Arg *ussd_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = ussd_ptr->param_flag; + if (flag == 0x01) + { + + buf_len = add_tlv("4",ussd_ptr->ussd_len,ussd_ptr->ussd_data,0x00,&asn_buf); + } + else + { + mapp_log_debug("Process USSD param flag error"); + return -1; + } + + return buf_len; +} + +int extract_ProcessUSSDArg( struct MapPUSSD_Arg *ussd_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ussd_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4",temp_buf,&asn_buf); + if (len != -1) + { + ussd_ptr->param_flag = 0x01; + ussd_ptr->ussd_len = len; + memcpy(ussd_ptr->ussd_data,temp_buf,len); + } + else + { + mapp_log_debug("Process USSD lack imsi"); + return RER; + } + + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding ProcessUnstructuredSS-Data ResPonse*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_ProcessUSSDRes(struct MapPUSSD_Res *ussd_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = ussd_ptr->param_flag; + if (flag == 0x01) + { + buf_len = add_tlv("4",ussd_ptr->ussd_len,ussd_ptr->ussd_data,0x00,&asn_buf); + } + else + { + mapp_log_debug("Process USSD param flag error"); + return -1; + } + + return buf_len; +} + +int extract_ProcessUSSDRes( struct MapPUSSD_Res *ussd_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ussd_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4",temp_buf,&asn_buf); + if (len != -1) + { + ussd_ptr->param_flag = 0x01; + ussd_ptr->ussd_len = len; + memcpy(ussd_ptr->ussd_data,temp_buf,len); + } + else + { + mapp_log_debug("Process USSD lack imsi"); + return RER; + } + + return ROK; +} + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding BeginSubscriberActivity Argmnet*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_SAArg(struct MapSA_Arg *sa_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = sa_ptr->param_flag; + if (flag == 0x03) + { + buf_len = add_tlv("4-1",IMSI_LEN+1,sa_ptr->imsi,0x00,&asn_buf); + buf_len = add_tlv("4-2",9,sa_ptr->Enity_num,0x00,&asn_buf); + } + else + { + mapp_log_debug(" BeginSubscriberActivity param flag error"); + return -1; + } + + return buf_len; +} + +int extract_SAArg( struct MapSA_Arg *sa_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sa_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4-1",temp_buf,&asn_buf); + if (len == IMSI_LEN + 1) + { + sa_ptr->param_flag |= 0x01; + memcpy(sa_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("Process USSD lack imsi"); + return RER; + } + + len = get_tlv("4-2",temp_buf,&asn_buf); + if (len != -1) + { + sa_ptr->param_flag |= 0x01; + sa_ptr->enity_len = len; + memcpy(sa_ptr->Enity_num,temp_buf,len); + } + else + { + mapp_log_debug("Process USSD lack Enity_nu"); + return RER; + } + + return ROK; +} + + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding PerformHandover Argmnet*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_HOArg(struct MapHO_Arg *ho_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = ho_ptr->param_flag; + if (flag & 0x01) + { + buf_len = add_tlv("4-1",7,ho_ptr->tgt_cellID,0x00,&asn_buf); + } + else + { + mapp_log_debug(" PerformHanover lack target cell id"); + return -1; + } + + if (flag & 0x02) + { + buf_len = add_tlv("4-2",7,ho_ptr->srv_cellID,0x00,&asn_buf); + } + else + { + mapp_log_debug(" PerformHanover lack service cell id"); + return -1; + } + + if (flag & 0x04) + { + buf_len = add_tlv("4-3",10,ho_ptr->chl_type,0x00,&asn_buf); + } + else + { + mapp_log_debug(" PerformHanover lack channel type"); + return -1; + } + + if (flag & 0x08) + { + buf_len = add_tlv("4-4",2,ho_ptr->class_mark,0x00,&asn_buf); + } + else + { + mapp_log_debug(" PerformHanover lack class mark info"); + return -1; + } + + if (flag & 0x10) + { + buf_len = add_tlv("11",1,&ho_ptr->ho_priority,0x80,&asn_buf); + } + + + if (flag & 0x20) + { + buf_len = add_tlv("12",8,ho_ptr->kc,0x80,&asn_buf); + } + + + return buf_len; +} + +int extract_HOArg( struct MapHO_Arg *ho_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ho_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4-1",temp_buf,&asn_buf); + if (len == 7) + { + ho_ptr->param_flag |= 0x01; + memcpy(ho_ptr->tgt_cellID,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack target cell id"); + } + + len = get_tlv("4-2",temp_buf,&asn_buf); + if (len == 7) + { + ho_ptr->param_flag |= 0x02; + memcpy(ho_ptr->srv_cellID,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack service cell id"); + } + + len = get_tlv("4-3",temp_buf,&asn_buf); + if (len == 10) + { + ho_ptr->param_flag |= 0x04; + memcpy(ho_ptr->chl_type,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack channel type"); + } + + len = get_tlv("4-4",temp_buf,&asn_buf); + if (len == 2) + { + ho_ptr->param_flag |= 0x08; + memcpy(ho_ptr->class_mark,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack class mark info"); + } + + len = get_tlv("11",temp_buf,&asn_buf); + if (len == 1) + { + ho_ptr->param_flag |= 0x10; + memcpy(&ho_ptr->ho_priority,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack handover priority"); + } + + len = get_tlv("12",temp_buf,&asn_buf); + if (len == 8) + { + ho_ptr->param_flag |= 0x20; + memcpy(ho_ptr->kc,temp_buf,len); + } + else + { + mapp_log_debug(" PerformHanover lack kc"); + } + + return ROK; +} + + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding PerformHandover ResPonse*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_HORes(struct MapHO_Res *ho_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = ho_ptr->param_flag; + if (flag & 0x01) + { + + buf_len = add_tlv("4",9,ho_ptr->ho_num,0x00,&asn_buf); + } + else + { + mapp_log_debug("handover res lack handovber"); + return -1; + } + + if (flag & 0x02) + { + + buf_len = add_tlv("16.2",1,&ho_ptr->access_singal_info.protocol_id,0x00,&asn_buf); + buf_len = add_tlv("16.4",ho_ptr->access_singal_info.singal_info_len,ho_ptr->access_singal_info.signal_info,0x00,&asn_buf); + } + else + { + mapp_log_debug("handover res lack handovber"); + return -1; + } + + return buf_len; +} + +int extract_HORes( struct MapHO_Res *ho_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ho_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4",temp_buf,&asn_buf); + if (len != -1) + { + ho_ptr->param_flag |= 0x01; + memcpy(ho_ptr->ho_num,temp_buf,len); + } + else + { + mapp_log_debug("performhandover lack handover number"); + return RER; + } + + len = get_tlv("16",temp_buf,&asn_buf); + if (len != -1) + { + len = get_tlv("16.2",temp_buf,&asn_buf); + if( len == 1) + { + memcpy(&ho_ptr->access_singal_info.protocol_id , temp_buf ,len); + } + else + { + mapp_log_debug("performhandover lack protocol_id"); + return RER; + } + + len = get_tlv("16.4",temp_buf,&asn_buf); + if( len != -1) + { + memcpy(ho_ptr->access_singal_info.signal_info, temp_buf ,len); + ho_ptr->access_singal_info.singal_info_len= len; + } + else + { + mapp_log_debug("performhandover lack protocol_id"); + return RER; + } + } + else + { + mapp_log_debug("performhandover lack access_singal_info"); + return RER; + } + + return ROK; +} + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding PreformSubsequenceHandover Arg*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_PFSHOArg(struct MapPFSHO_Arg *psho_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + //char str[512]; + + asn_encode(buf,&asn_buf); + flag = psho_ptr->param_flag; + if (flag & 0x01) + { + buf_len = add_tlv("4-1",GCID_LEN,psho_ptr->target_id,0x00,&asn_buf); + } + else + { + mapp_log_debug("performsubsequenthandover arg lack target id"); + return -1; + } + if (flag & 0x02) + { + buf_len = add_tlv("4-2",GCID_LEN,psho_ptr->service_id,0x00,&asn_buf); + } + else + { + mapp_log_debug("performsubsequenthandover arg lack service id"); + return -1; + } + + if (flag & 0x04) + { + buf_len = add_tlv("4-3",ISDN_LEN,psho_ptr->msc_num,0x00,&asn_buf); + } + else + { + mapp_log_debug("performsubsequenthandover arg lack msc number"); + return -1; + } + + if (flag & 0x08) + { + buf_len = add_tlv("10-4",2,psho_ptr->classmark_info,0x80,&asn_buf); + } + + //Bcd2Str_Space(str, buf, buf_len); + //printf("\r\nPFSHO arg code :[%d]\r\n%s\r\n",buf_len,str); + return buf_len; +} + +int extract_PFSHOArg( struct MapPFSHO_Arg *psho_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psho_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4",temp_buf,&asn_buf); + if (len == GCID_LEN) + { + psho_ptr->param_flag |= 0x01; + memcpy( psho_ptr->target_id,temp_buf,len); + } + else + { + mapp_log_debug("performsubsequenthandover res lack target id"); + return RER; + } + + len = get_tlv("4",temp_buf,&asn_buf); + if (len == GCID_LEN) + { + psho_ptr->param_flag |= 0x02; + memcpy( psho_ptr->service_id,temp_buf,len); + } + else + { + mapp_log_debug("performsubsequenthandover res lack service id"); + return RER; + } + + len = get_tlv("4-3",temp_buf,&asn_buf); + if (len <= ISDN_LEN ) + { + psho_ptr->param_flag |= 0x04; + psho_ptr->msc_num[0] = len; + memcpy( psho_ptr->msc_num+1,temp_buf,len); + } + else + { + mapp_log_debug("performsubsequenthandover res lack msc number"); + return RER; + } + + len = get_tlv("10-4",temp_buf,&asn_buf); + if (len == 2 ) + { + psho_ptr->param_flag |= 0x08; + memcpy( psho_ptr->classmark_info,temp_buf,len); + } + else + { + mapp_log_debug("performsubsequenthandover lack msc number"); + return RER; + } + + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding PreformSubsequenceHandover res */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_PFSHORes(struct MapPFSHO_Res *psho_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (psho_ptr->param_flag & 0x01) // access_sig_info + { + temp_len = assign_extsiginfo(&psho_ptr->access_sig_info,temp_buf); + buf_len = add_tlv("16",temp_len,temp_buf,0x20,&asn_buf); + } + return buf_len; +} + +int extract_PFSHORes(struct MapPFSHO_Res *psho_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psho_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("16",temp_buf,&asn_buf); // access_sig_info + if (len != -1) + { + if (!extract_extsiginfo(&psho_ptr->access_sig_info,len,temp_buf)) + return RER; + psho_ptr->param_flag |= 0x01; + } + return ROK; +} + + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding NoteInternalHandover Arg */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_NIHOArg(struct MapNIHO_Arg *niho_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0,temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + flag = niho_ptr->param_flag; + if (flag & 0x01) + { + buf_len = add_tlv("10-1",1,&niho_ptr->ho_type,0x00,&asn_buf); + } + else + { + mapp_log_debug("NoteInternalHandover lack handover type"); + return -1; + } + if (flag & 0x02) + { + buf_len = add_tlv("1-2",GCID_LEN,niho_ptr->target_id,0x80,&asn_buf); + } + + if (flag & 0x04) + { + temp_len = assign_extsiginfo(&niho_ptr->channel_id,temp_buf); + buf_len = add_tlv("2-3",temp_len, temp_buf,0x80,&asn_buf); + } + else + { + mapp_log_debug("NoteInternalHandover lack channel id"); + return -1; + } + + //Bcd2Str_Space(temp_buf, buf, buf_len); + //printf("\r\nNIHO arg code :[%d]\r\n%s\r\n",buf_len,temp_buf); + return buf_len; +} + +int extract_NIHOArg( struct MapNIHO_Arg *niho_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + niho_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("10-1",temp_buf,&asn_buf); + if (len == 1) + { + niho_ptr->param_flag |= 0x01; + memcpy( &niho_ptr->ho_type,temp_buf,len); + } + else + { + mapp_log_debug("NoteInternalHandover lack handover type"); + return RER; + } + + len = get_tlv("1",temp_buf,&asn_buf); + if (len == GCID_LEN) + { + niho_ptr->param_flag |= 0x02; + memcpy(niho_ptr->target_id,temp_buf,len); + } + + len = get_tlv("2",temp_buf,&asn_buf); + if (len != -1 ) + { + if(!extract_extsiginfo(&niho_ptr->channel_id,len,temp_buf)) + return RER; + niho_ptr->param_flag |= 0x04; + } + + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding Tracesubscirberactivity Arg */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_TSAArg(struct MapTSA_Arg *tsa_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + + asn_encode(buf,&asn_buf); + flag = tsa_ptr->param_flag; + if (flag & 0x01) + { + buf_len = add_tlv("0",IMSI_LEN,tsa_ptr->imsi,0x80,&asn_buf); + } + + if (flag & 0x02) + { + buf_len = add_tlv("1",2,tsa_ptr->trace_ref,0x80,&asn_buf); + } + else + { + mapp_log_debug("Tracesubscirberactivity lack call reference"); + return -1; + } + + if (flag & 0x04) + { + buf_len = add_tlv("2",1,&tsa_ptr->trace_type,0x80,&asn_buf); + } + else + { + mapp_log_debug("TracesubscirberactivityTracesubscirberactivity lack call type"); + return -1; + } + + if (flag & 0x08) + { + buf_len = add_tlv("3",tsa_ptr->omc_id_len,tsa_ptr->omc_id,0x80,&asn_buf); + } + + if (flag & 0x10) + { + buf_len = add_tlv("4",3,tsa_ptr->call_ref,0x80,&asn_buf); + } + + + return buf_len; +} + +int extract_TSAArg( struct MapTSA_Arg *tsa_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + tsa_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("0",temp_buf,&asn_buf); + if (len == IMSI_LEN) + { + tsa_ptr->param_flag |= 0x01; + memcpy( &tsa_ptr->imsi,temp_buf,len); + } + + + len = get_tlv("1",temp_buf,&asn_buf); + if (len == 2) + { + tsa_ptr->param_flag |= 0x02; + memcpy(&tsa_ptr->trace_ref,temp_buf,len); + } + + len = get_tlv("2",temp_buf,&asn_buf); + if (len == 1 ) + { + tsa_ptr->param_flag |= 0x04; + memcpy(&tsa_ptr->trace_type,temp_buf,len); + } + + len = get_tlv("3",temp_buf,&asn_buf); + if (len != -1 ) + { + tsa_ptr->param_flag |= 0x08; + tsa_ptr->omc_id_len = len; + memcpy(&tsa_ptr->omc_id,temp_buf,len); + } + + len = get_tlv("4",temp_buf,&asn_buf); + if (len == 3 ) + { + tsa_ptr->param_flag |= 0x04; + memcpy(&tsa_ptr->call_ref,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding BeginSubscriberActivity Arg */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ + +int assign_BSAArg(struct MapBSA_Arg *bsa_ptr, u8 *buf) // lw add +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + + asn_encode(buf,&asn_buf); + flag = bsa_ptr->param_flag; + if (flag & 0x01) + { + buf_len = add_tlv("4-1",IMSI_LEN+1,bsa_ptr->imsi,0x00,&asn_buf); + } + + if (flag & 0x02) + { + buf_len = add_tlv("4-2",bsa_ptr->orgenty_num_len,bsa_ptr->orgenty_num,0x00,&asn_buf); + } + return buf_len; +} + +int extract_BSAArg( struct MapBSA_Arg *bsa_ptr,u32 buf_len,u8 *buf) // lw add +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + bsa_ptr->param_flag = 0; + + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + + len = get_tlv("4-1",temp_buf,&asn_buf); + if (len == IMSI_LEN+1) + { + bsa_ptr->param_flag |= 0x01; + memcpy( bsa_ptr->imsi,temp_buf,len); + } + + len = get_tlv("4-2",temp_buf,&asn_buf); + if (len != -1) + { + bsa_ptr->param_flag |= 0x02; + bsa_ptr->orgenty_num_len = len; + memcpy(&bsa_ptr->orgenty_num,temp_buf,len); + } + return ROK; +} + + +/* --->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MAP V1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,---*/ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding cancel location argument */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_cancellocarg(struct MapCL_Arg *cl_ptr,u8 *buf,u8 ver) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 temp_buf[256]; + CL_identity *id; + + asn_encode(buf,&asn_buf); + flag = cl_ptr->param_flag; + if( flag & 0x01 ) + { + id = &cl_ptr->id; + if( id->choice_flag == 1 ) + { + buf_len = add_tlv("4-1",IMSI_LEN,id->choice.imsi,0x00,&asn_buf); + } + else if( id->choice_flag == 2 ) + { + buf_len = add_null("16", 0x20, &asn_buf); + buf_len = add_tlv("16-1.4-1",IMSI_LEN,id->choice.imsi_withlmsi.imsi,0x00,&asn_buf); + buf_len = add_tlv("16-1.4-2",4,id->choice.imsi_withlmsi.lmsi,0x00,&asn_buf); + } + } + else + { + mapp_log_debug("cancellocation arg lack identity"); + return RER; + } + + + if( ver !=3 && flag & 0x02 ) + { + temp_buf[0] = cl_ptr->type; + buf_len = add_tlv("10-2",1,temp_buf,0x00,&asn_buf); + } + + return buf_len; +} + +int extract_cancellocarg(struct MapCL_Arg *cl_ptr,u32 buf_len,u8 *buf,u8 ver) +{ + ASN_BUF asn_buf; + int len1; + u8 temp_buf1[256],temp_buf2[256]; + CL_identity *id; + + cl_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if( ( get_tlv("4-1",temp_buf1,&asn_buf) == IMSI_LEN ) + && ((temp_buf1[IMSI_LEN-1]&0xf0) == 0xf0 ) ) + { + id = &cl_ptr->id; + cl_ptr->param_flag |= 0x01; + id->choice_flag = 1; + memcpy( id->choice.imsi , temp_buf1 , IMSI_LEN ); + } + else + { + if( ( get_tlv("16-1.4-1",temp_buf1,&asn_buf) == IMSI_LEN ) && ( get_tlv("16-1.4-2",temp_buf2,&asn_buf) == LMSI_LEN ) + && ((temp_buf1[IMSI_LEN-1] & 0xf0 ) == 0xf0 ) ) + { + id = &cl_ptr->id; + cl_ptr->param_flag |= 0x01; + id->choice_flag = 2; + memcpy( id->choice.imsi_withlmsi.imsi , temp_buf1 , IMSI_LEN); + memcpy( id->choice.imsi_withlmsi.lmsi , temp_buf2 ,LMSI_LEN); + } + } + + if( ver !=3 && ( len1 = get_tlv("10-2",temp_buf1,&asn_buf) ) == 1 ) + { + cl_ptr->param_flag |= 0x02; + memcpy( &cl_ptr->type,temp_buf1,len1); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding cancel location response */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_cancellocres(struct MapCL_Res *cl_ptr,u8 *buf) +{ + return 0; +} + +int extract_cancellocres(struct MapCL_Res *cl_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding purge ms argument */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_purgemsarg(struct MapPMS_Arg *pms_ptr,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + flag = pms_ptr->param_flag; + if (flag & 0x01) // IMSI + buf_len = add_tlv("4-1",IMSI_LEN,pms_ptr->imsi,0x00,&asn_buf); // add IMSI parameter + else + { + mapp_log_debug("purgeMS request lack IMSI"); + return RER; + } + tag1 = 2; + if (flag & 0x02) // VLR address + { + if (version == 2) + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,pms_ptr->vlr_num[0],pms_ptr->vlr_num+1,0,&asn_buf); + } + else + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,pms_ptr->vlr_num[0],pms_ptr->vlr_num+1,0x80,&asn_buf); + } + } + if (flag & 0x04) // sgsn address + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,pms_ptr->sgsn_num[0],pms_ptr->sgsn_num+1,0x80,&asn_buf); + } + return buf_len; +} + +int extract_purgemsarg(struct MapPMS_Arg *pms_ptr,u32 buf_len,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + pms_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_purge MS arg,buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); // get IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + pms_ptr->param_flag |= 0x01; + memcpy(pms_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("purge ms indicate error IMSI"); + return RER; + } + if (version == 2) // get VLR number + len = get_tlv("4-2",temp_buf,&asn_buf); + else + len = get_tlv("0-2",temp_buf,&asn_buf); + if (len > 2) + { + pms_ptr->param_flag |= 0x02; + pms_ptr->vlr_num[0] = len; + memcpy(pms_ptr->vlr_num+1,temp_buf,len); + } + if ((len = get_tlv("1",temp_buf,&asn_buf)) > 2) // get sgsn number + { + pms_ptr->param_flag |= 0x04; + pms_ptr->sgsn_num[0] = len; + memcpy(pms_ptr->sgsn_num+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding purge ms response */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_purgemsres(struct MapPMS_Res *pms_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (pms_ptr->param_flag & 0x01) // freeze TMSI + buf_len = add_null("0",0x80,&asn_buf); + if (pms_ptr->param_flag & 0x02) // freeze P-TMSI + buf_len = add_null("1",0x80,&asn_buf); + return buf_len; +} + +int extract_purgemsres(struct MapPMS_Res *pms_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + pms_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) > 0) // freeze TMSI + { + pms_ptr->param_flag |= 0x01; + pms_ptr->freeze_tmsi = 1; + } + if (get_tlv("1",temp_buf,&asn_buf) > 0) // freeze P-TMSI + { + pms_ptr->param_flag |= 0x02; + pms_ptr->freeze_ptmsi = 1; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send identification argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndidentarg(struct MapSI_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) // TMSI + buf_len = add_tlv("4",TMSI_LEN,ptr->tmsi,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_sndidentarg(struct MapSI_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4",temp_buf,&asn_buf) == TMSI_LEN) + { + ptr->param_flag |= 0x01; + memcpy(ptr->tmsi,temp_buf,TMSI_LEN); + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send identification response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndidentres(struct MapSI_Res *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int ii; + int temp_len; + u8 temp_buf[256]; + u8 tlv2[32]; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) // IMSI + buf_len = add_tlv("4",IMSI_LEN,ptr->imsi,0x00,&asn_buf); + else + return RER; + if (ptr->param_flag & 0x02) // auth list + { + for (ii = 0;ii < ptr->authlist.auth_len;ii ++) + { + temp_len = assign_authset(&ptr->authlist.auth_set[ii],temp_buf); + if (temp_len == RER) + break; + sprintf(tlv2,"16-%d",ii+1); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x20,&asn_buf); + } + } + return buf_len; +} + +int extract_sndidentres(struct MapSI_Res *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + int ii; + u8 tlv2[32]; + + ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ptr->param_flag |= 0x01; + memcpy(ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + for (ii = 0;ii < AUTHLIST_LEN;ii++) + { + ptr->authlist.auth_set[ii].param_flag = 0; + sprintf(tlv2,"16-%d",ii+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len <= 0) // has not data + break; + if (!extract_authset(&ptr->authlist.auth_set[ii],len,temp_buf)) + break; + ptr->param_flag |= 0x02; + ptr->authlist.auth_len++; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding update GPRS location argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_upgprslocarg(struct MapUGL_Arg *ugl_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ugl_ptr->param_flag & 0x01) // IMSI + buf_len = add_tlv("4-1",IMSI_LEN,ugl_ptr->imsi,0x00,&asn_buf); + else + return RER; + if (ugl_ptr->param_flag & 0x02) // sgsn number + buf_len = add_tlv("4-2",ugl_ptr->sgsn_num[0],ugl_ptr->sgsn_num+1,0x00,&asn_buf); + else + return RER; + if (ugl_ptr->param_flag & 0x04) // sgsn address + buf_len = add_tlv("4-3",ugl_ptr->sgsn_add[0],ugl_ptr->sgsn_add+1,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_upgprslocarg(struct MapUGL_Arg *ugl_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ugl_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4-1",temp_buf,&asn_buf); // IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ugl_ptr->param_flag |= 0x01; + memcpy(ugl_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("4-2",temp_buf,&asn_buf); // sgsn number + if (len > 0 && len <= ISDN_LEN) + { + ugl_ptr->param_flag |= 0x02; + ugl_ptr->sgsn_num[0] = len; + memcpy(ugl_ptr->sgsn_num+1,temp_buf,len); + } + else + return RER; + len = get_tlv("4-3",temp_buf,&asn_buf); // sgsn address + if (len > 0 && len <= GSN_LEN) + { + ugl_ptr->param_flag |= 0x04; + ugl_ptr->sgsn_add[0] = len; + memcpy(ugl_ptr->sgsn_add+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding update GPRS location response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_upgprslocres(struct MapUGL_Res *ugl_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ugl_ptr->param_flag & 0x01) // hlr number + buf_len = add_tlv("4",ugl_ptr->hlr_num[0],ugl_ptr->hlr_num+1,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_upgprslocres(struct MapUGL_Res *ugl_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ugl_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); // hlr number + if (len > 0 && len <= ISDN_LEN) + { + ugl_ptr->param_flag |= 0x01; + ugl_ptr->hlr_num[0] = len; + memcpy(ugl_ptr->hlr_num+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provider subscriber info argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prvsubinfoarg(struct MapPSI_Arg *psi_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (psi_ptr->param_flag & 0x01) // IMSI + buf_len = add_tlv("0",IMSI_LEN,psi_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (psi_ptr->param_flag & 0x02) // LMSI + buf_len = add_tlv("1",LMSI_LEN,psi_ptr->lmsi,0x80,&asn_buf); + if (psi_ptr->param_flag & 0x04) // request info + { + if (psi_ptr->req_info.param_flag & 0x01) // location info + buf_len = add_null("2.0",0x80,&asn_buf); + if (psi_ptr->req_info.param_flag & 0x02) // subscriber state + buf_len = add_null("2.1",0x80,&asn_buf); + } + return buf_len; +} + +int extract_prvsubinfoarg(struct MapPSI_Arg *psi_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psi_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + psi_ptr->param_flag |= 0x01; + memcpy(psi_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + if (get_tlv("1",temp_buf,&asn_buf) == LMSI_LEN) // lmsi + { + psi_ptr->param_flag |= 0x02; + memcpy(psi_ptr->lmsi,temp_buf,LMSI_LEN); + } + if (get_tlv("2.0",temp_buf,&asn_buf) != -1) // location info + { + psi_ptr->param_flag |= 0x04; + psi_ptr->req_info.param_flag |= 0x01; + psi_ptr->req_info.loc_info = 1; + } + if (get_tlv("2.1",temp_buf,&asn_buf) != -1) // subscriber state + { + psi_ptr->param_flag |= 0x04; + psi_ptr->req_info.param_flag |= 0x02; + psi_ptr->req_info.sub_state = 1; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding provider subscriber info response */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prvsubinfores(struct MapPSI_Res *psi_ptr,u8 *buf) +{ + int buf_len=0; + ASN_BUF asn_buf; + char info_str[1024]; + + if (psi_ptr->param_flag & 0x01) // subscriber info + { + buf_len = assign_subinfo(&psi_ptr->sub_info,buf); + memcpy(info_str,buf,buf_len%1024); + AsnEncode(buf,256,&asn_buf); + buf_len = AddTLV("16",buf_len,info_str,0x20,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_prvsubinfores(struct MapPSI_Res *psi_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + psi_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if ((len = get_tlv("16",temp_buf,&asn_buf)) <= 0) + { + return RER; + } + return extract_subinfo(&psi_ptr->sub_info,len,temp_buf); +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding any time interrogation argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_anytimeintarg(struct MapATI_Arg *ati_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int len; + + asn_encode(buf,&asn_buf); + if (ati_ptr->param_flag & 0x01) // subscriber ideentity + { + if (ati_ptr->sub_ident.choice_flag == 1) // IMSI + buf_len = add_tlv("0.0",IMSI_LEN,ati_ptr->sub_ident.choice.imsi,0x80,&asn_buf); + else if (ati_ptr->sub_ident.choice_flag == 2) // msisdn + { + len = ati_ptr->sub_ident.choice.msisdn[0]; + buf_len = add_tlv("0.1",len,ati_ptr->sub_ident.choice.msisdn+1,0x80,&asn_buf); + } + } + else + return RER; + if (ati_ptr->param_flag & 0x02) // request info + { + if (ati_ptr->req_info.param_flag & 0x01) // location info + buf_len = add_null("1.0",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x02) // subscriber state + buf_len = add_null("1.1",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x04) // current location + buf_len = add_null("1.3",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x08) // requested domain + buf_len = add_null("1.4",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x10) // imei + buf_len = add_null("1.6",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x20) // ms classmark + buf_len = add_null("1.5",0x80,&asn_buf); + if (ati_ptr->req_info.param_flag & 0x40) // mnp requested info + buf_len = add_null("1.7",0x80,&asn_buf); + } + else + return RER; + if (ati_ptr->param_flag & 0x04) // scf address + buf_len = add_tlv("3",ati_ptr->scf_add[0],ati_ptr->scf_add+1,0x80,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_anytimeintarg(struct MapATI_Arg *ati_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ati_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) != -1) + { + ati_ptr->param_flag |= 0x01; + len = get_tlv("0.0",temp_buf,&asn_buf); // IMSI + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ati_ptr->sub_ident.choice_flag = 0x01; + memcpy(ati_ptr->sub_ident.choice.imsi,temp_buf,IMSI_LEN); + } + else + { + len = get_tlv("0.1",temp_buf,&asn_buf); // msisdn + if (len > 0 && len <= ISDN_LEN) + { + ati_ptr->sub_ident.choice_flag = 0x02; + ati_ptr->sub_ident.choice.msisdn[0] = len; + memcpy(ati_ptr->sub_ident.choice.msisdn+1,temp_buf,len); + } + else + return RER; + } + } + else + return RER; + if (get_tlv("1",temp_buf,&asn_buf) != -1) + { + if (get_tlv("1.0",temp_buf,&asn_buf) != -1) // location info + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x01; + ati_ptr->req_info.loc_info = 1; + } + if (get_tlv("1.1",temp_buf,&asn_buf) != -1) // subscriber state + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x02; + ati_ptr->req_info.sub_state = 1; + } + if (get_tlv("1.3",temp_buf,&asn_buf) != -1) // current location + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x04; + ati_ptr->req_info.cur_location = 1; + } + if (get_tlv("1.4",temp_buf,&asn_buf) != -1) // requested domain + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x08; + ati_ptr->req_info.req_domain= 1; + } + if (get_tlv("1.6",temp_buf,&asn_buf) != -1) // imei + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x10; + ati_ptr->req_info.imei = 1; + } + if (get_tlv("1.5",temp_buf,&asn_buf) != -1) // ms classmark + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x20; + ati_ptr->req_info.ms_classmark = 1; + } + if (get_tlv("1.7",temp_buf,&asn_buf) != -1) // mnp requested info + { + ati_ptr->param_flag |= 0x02; + ati_ptr->req_info.param_flag |= 0x40; + ati_ptr->req_info.mnp_req_info = 1; + } + } + else + return RER; + len = get_tlv("3",temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) + { + ati_ptr->param_flag |= 0x04; + ati_ptr->scf_add[0] = len; + memcpy(ati_ptr->scf_add+1,temp_buf,len); + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding any time interrogate response */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_anytimeintres(struct MapATI_Res *ati_ptr,u8 *buf) +{ + int buf_len=0; + ASN_BUF asn_buf; + char info_str[1024]; + + if (ati_ptr->param_flag & 0x01) // subscriber info + { + buf_len = assign_subinfo(&ati_ptr->sub_info,buf); + memcpy(info_str,buf,buf_len%1024); + AsnEncode(buf,256,&asn_buf); + buf_len = AddTLV("16",buf_len,info_str,0x20,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_anytimeintres(struct MapATI_Res *ati_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ati_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if ((len = get_tlv("16",temp_buf,&asn_buf)) <= 0) + { + return RER; + } + + return extract_subinfo(&ati_ptr->sub_info,len,temp_buf); +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding prepare handover argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prehoarg(struct MapPHO_Arg *pho_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (pho_ptr->param_flag & 0x01) // target cell id + buf_len = add_tlv("4",GCID_LEN,pho_ptr->target_id,0x00,&asn_buf); + if (pho_ptr->param_flag & 0x02) // ho number not required + buf_len = add_null("5",0x00,&asn_buf); + if (pho_ptr->param_flag & 0x04) // bss apdu + { + temp_len = assign_extsiginfo(&pho_ptr->bss_apdu,temp_buf); + buf_len = add_tlv("16",temp_len,temp_buf,0x20,&asn_buf); + } + return buf_len; +} + +int extract_prehoarg(struct MapPHO_Arg *pho_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + pho_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4",temp_buf,&asn_buf) == GCID_LEN) // target cell id + { + pho_ptr->param_flag |= 0x01; + memcpy(pho_ptr->target_id,temp_buf,GCID_LEN); + } + if (get_tlv("5",temp_buf,&asn_buf) != -1) // ho number not required + { + pho_ptr->param_flag |= 0x02; + pho_ptr->numnot_require = 1; + } + len = get_tlv("16",temp_buf,&asn_buf); // bss apdu + if (len != -1) + { + if (!extract_extsiginfo(&pho_ptr->bss_apdu,len,temp_buf)) + return RER; + pho_ptr->param_flag |= 0x04; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding prepare handover response */ +/* ++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prehores(struct MapPHO_Res *pho_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (pho_ptr->param_flag & 0x01) // handover number + buf_len = add_tlv("4",pho_ptr->ho_num[0],pho_ptr->ho_num+1,0x00,&asn_buf); + if (pho_ptr->param_flag & 0x02) // bss apdu + { + temp_len = assign_extsiginfo(&pho_ptr->bss_apdu,temp_buf); + buf_len = add_tlv("16",temp_len,temp_buf,0x20,&asn_buf); + } + return buf_len; +} + +int extract_prehores(struct MapPHO_Res *pho_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + pho_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) // handover number + { + pho_ptr->param_flag |= 0x01; + pho_ptr->ho_num[0] = len; + memcpy(pho_ptr->ho_num+1,temp_buf,len); + } + len = get_tlv("16",temp_buf,&asn_buf); // bss apdu + if (len != -1) + { + if (!extract_extsiginfo(&pho_ptr->bss_apdu,len,temp_buf)) + return RER; + pho_ptr->param_flag |= 0x02; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send end signal argument */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndendsigarg(struct MapSES_Arg *ses_ptr,u8 *buf) +{ + + if (ses_ptr->param_flag |= 0x01) // bss apdu + return assign_extsiginfo(&ses_ptr->bss_apdu,buf); + else + return RER; +} + +int extract_sndendsigarg(struct MapSES_Arg *ses_ptr,u32 buf_len,u8 *buf) +{ + if (extract_extsiginfo(&ses_ptr->bss_apdu,buf_len,buf)) + { + ses_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding process access signalling argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prcaccsigarg(struct MapPAS_Arg *pas_ptr,u8 *buf) +{ + + if (pas_ptr->param_flag |= 0x01) // bss apdu + return assign_extsiginfo(&pas_ptr->bss_apdu,buf); + else + return RER; +} + +int extract_prcaccsigarg(struct MapPAS_Arg *pas_ptr,u32 buf_len,u8 *buf) +{ + if (extract_extsiginfo(&pas_ptr->bss_apdu,buf_len,buf)) + { + pas_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding forward access signalling argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_fwdaccsigarg(struct MapFAS_Arg *fas_ptr,u8 *buf) +{ + + if (fas_ptr->param_flag |= 0x01) // bss apdu + return assign_extsiginfo(&fas_ptr->bss_apdu,buf); + else + return RER; +} + +int extract_fwdaccsigarg(struct MapFAS_Arg *fas_ptr,u32 buf_len,u8 *buf) +{ + if (extract_extsiginfo(&fas_ptr->bss_apdu,buf_len,buf)) + { + fas_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding prepare subsequent handover argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_presubshoarg(struct MapPSHO_Arg *psho_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (psho_ptr->param_flag & 0x01) // target cell id + buf_len = add_tlv("4-1",GCID_LEN,psho_ptr->target_id,0x00,&asn_buf); + else + return RER; + if (psho_ptr->param_flag & 0x02) // target msc number + buf_len = add_tlv("4-2",psho_ptr->msc_num[0],psho_ptr->msc_num+1,0x00,&asn_buf); + else + return RER; + if (psho_ptr->param_flag & 0x04) // bss apdu + { + temp_len = assign_extsiginfo(&psho_ptr->bss_apdu,temp_buf); + buf_len = add_tlv("16",temp_len,temp_buf,0x20,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_presubshoarg(struct MapPSHO_Arg *psho_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + psho_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4-1",temp_buf,&asn_buf) == GCID_LEN) // target cell id + { + psho_ptr->param_flag |= 0x01; + memcpy(psho_ptr->target_id,temp_buf,GCID_LEN); + } + else + return RER; + len = get_tlv("4-2",temp_buf,&asn_buf); // target msc number + if (len > 0 && len <= ISDN_LEN) + { + psho_ptr->param_flag |= 0x02; + psho_ptr->msc_num[0] = len; + memcpy(psho_ptr->msc_num+1,temp_buf,len); + } + len = get_tlv("16",temp_buf,&asn_buf); // bss apdu + if (len != -1) + { + if (!extract_extsiginfo(&psho_ptr->bss_apdu,len,temp_buf)) + return RER; + psho_ptr->param_flag |= 0x04; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding prepare subsequent handover response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_presubshores(struct MapPSHO_Res *psho_ptr,u8 *buf) +{ + + if (psho_ptr->param_flag |= 0x01) // bss apdu + return assign_extsiginfo(&psho_ptr->bss_apdu,buf); + else + return RER; +} + +int extract_presubshores(struct MapPSHO_Res *psho_ptr,u32 buf_len,u8 *buf) +{ + if (extract_extsiginfo(&psho_ptr->bss_apdu,buf_len,buf)) + { + psho_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send Authentiction Info argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndauthinfoarg(struct MapSAI_Arg *sai_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf, &asn_buf); + if (sai_ptr->param_flag & 0x01) // has IMSI + buf_len = add_tlv("4",IMSI_LEN,sai_ptr->imsi,0x00,&asn_buf); + else + { + mapp_log_debug("assign sndauthinfo lack IMSI"); + return RER; + } + return buf_len; +} + +int extract_sndauthinfoarg(struct MapSAI_Arg *sai_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len=0; + u8 temp_buf[256]; + + sai_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + sai_ptr->param_flag = 0x01; + memcpy(sai_ptr->imsi,temp_buf,len); + } + else + { + mapp_log_debug("extract_sndauthinfoarg lack IMSI"); + return RER; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send Authentiction Info response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndauthinfores(struct MapSAI_Res *sai_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 ii=0; + int temp_len; + u8 temp_buf[256]; + u8 tlv2[32]; + + asn_encode(buf,&asn_buf); + if (sai_ptr->param_flag & 0x01) // has authenticate data + { + for (ii = 0;ii < sai_ptr->authlist.auth_len;ii++) + { + temp_len = assign_authset(&sai_ptr->authlist.auth_set[ii],temp_buf); + if (temp_len == RER) + break; + sprintf(tlv2,"16-%d",ii+1); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x20,&asn_buf); + } + } + return buf_len; +} + +int extract_sndauthinfores(struct MapSAI_Res *sai_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u8 ii; + u8 tlv2[32]; + + sai_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_sndauthinfores buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + sai_ptr->authlist.auth_len = 0; + for (ii = 0;ii < AUTHLIST_LEN;ii++) + { + sai_ptr->authlist.auth_set[ii].param_flag = 0; + sprintf(tlv2,"16-%d",ii+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len <= 0) // has not data + break; + if (!extract_authset(&sai_ptr->authlist.auth_set[ii],len,temp_buf)) + break; + sai_ptr->param_flag = 0x01; + sai_ptr->authlist.auth_len++; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding check IMEI argument */ +/* +++++++++++++++++++++++++++++++++++++ */ +int assign_chkimeiarg(struct MapCIMEI_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if(flag & 0x01) //imei + buf_len = add_tlv("4",IMEI_LEN,ptr->imei,0x00,&asn_buf); + return buf_len; +} + +int extract_chkimeiarg(struct MapCIMEI_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_chkimeiarg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + if((get_tlv("4",temp_buf,&asn_buf)) != IMEI_LEN) //imei + return RER; + ptr->param_flag |= 0x01; + memcpy(ptr->imei,temp_buf,IMEI_LEN); + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding check IMEI response */ +/* +++++++++++++++++++++++++++++++++++++ */ +int assign_chkimeires(struct MapCIMEI_Res *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 data; + + asn_encode(buf,&asn_buf); + if(ptr->param_flag & 0x01) + { + data = ptr->equip_status; + buf_len = add_tlv("10",1,&data,0x00,&asn_buf); + } + return buf_len; +} + +int extract_chkimeires(struct MapCIMEI_Res *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_chkimeires buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ptr->param_flag = 0; + if(get_tlv("10",temp_buf,&asn_buf) != 1) + return RER; + ptr->param_flag |= 0x01; + ptr->equip_status = temp_buf[0]; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding insert subscribe Data argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_inssubdataarg(struct MapISD_Arg *isd_ptr,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + int jj,kk; + u32 flag1; + u32 flag; + u32 len; + int buf_len=0; + int temp_len; + u8 temp_data[256],temp_buf[256]; + u8 tag1=1,tag2=1,tag3=1,tag4=1,tag5=1; + char tlv1[32],tlv2[32],tlv3[32],tlv4[32],tlv5[32]; + struct ExtFwdInfo_struct *fwd_ptr; + struct ExtSsData_struct *ss_ptr; + struct ExtCallBarInfo_struct *callbar_ptr; + struct PdpContext_struct *pdp_ptr; + + asn_encode(buf,&asn_buf); + flag = isd_ptr->param_flag; + if (flag & 0x01) // IMSI + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,IMSI_LEN,isd_ptr->imsi,0x80,&asn_buf); + } + if (flag & 0x02) // MSISDN + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,isd_ptr->msisdn[0],isd_ptr->msisdn+1,0x80,&asn_buf); + } + if (flag & 0x04) // category + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_tlv(tlv1,1,&isd_ptr->category,0x80,&asn_buf); + } + if (flag & 0x08) // sub status + { + sprintf(tlv1,"3-%d",tag1++); + temp_data[0] = isd_ptr->sub_status; + buf_len = add_tlv(tlv1,1,temp_data,0x80,&asn_buf); + } + if (flag & 0x20) // bearer service list + { + temp_len = bearer_bittostr(isd_ptr->bearer_data,temp_data,0); + + if(temp_len > 0) + { + sprintf(tlv1,"4-%d",tag1++); + + for (jj = 0;jj < temp_len;jj ++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,temp_data+jj,0x00,&asn_buf); + } + } + } + if (flag & 0x40) // tele service list + { + temp_len = tele_bittostr(isd_ptr->tele_data,temp_data,0); + if(temp_len > 0) + { + sprintf(tlv1,"6-%d",tag1++); + for (jj = 0;jj < temp_len;jj++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,temp_data+jj,0x00,&asn_buf); + } + } + } + if (flag & 0x80) // ss info list + { + sprintf(tlv1,"7-%d",tag1++); + tag2 = 1; + if (isd_ptr->ss_info.param_flag & 0x01) // fwd info + { + fwd_ptr = (ExtFwdInfo_struct *) &isd_ptr->ss_info.fwd_info; + for (jj = 0;jj < 4;jj ++) //tag2 + { + tag3 = 1; + kk = 0x01 << jj; + if (fwd_ptr->param_flag & kk) + { + sprintf(tlv2,"%s.0-%d",tlv1,tag2++); + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); // for ss_code + buf_len = add_tlv(tlv3,1,&fwd_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.16-%d",tlv2,tag3++); + add_null(tlv3,0x20,&asn_buf); + tag4 = 1; + sprintf(tlv4,"%s.16-%d",tlv3,tag4); + add_null(tlv4,0x20,&asn_buf); + tag5 = 1; + flag1 = fwd_ptr->fwd_feat[jj].param_flag; + if (flag1 & 0x01) // bs group + { + if (fwd_ptr->fwd_feat[jj].bs_code.param_flag == 1) + { + sprintf(tlv5,"%s.2-%d",tlv4,tag5++); + if (tele_bittostr(fwd_ptr->fwd_feat[jj].bs_code.tele_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + else if(fwd_ptr->fwd_feat[jj].bs_code.param_flag == 2) + { + sprintf(tlv5,"%s.3-%d",tlv4,tag5++); + if (bearer_bittostr(fwd_ptr->fwd_feat[jj].bs_code.bearer_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + } + if (flag1 & 0x02) //ss status + { + sprintf(tlv5,"%s.4-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].ss_status,0x80,&asn_buf); + } + if (flag1 & 0x04) //fwdto_num + { + sprintf(tlv5,"%s.5-%d",tlv4,tag5++); + len = fwd_ptr->fwd_feat[jj].fwdto_num[0]; + buf_len = add_tlv(tlv5,len,fwd_ptr->fwd_feat[jj].fwdto_num+1,0x80,&asn_buf); + } + if (flag1 &0x08) //fwd opt + { + sprintf(tlv5,"%s.6-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].fwd_option,0x80,&asn_buf); + } + if (flag1 &0x10) //norc time + { + sprintf(tlv5,"%s.7-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&fwd_ptr->fwd_feat[jj].norc_time,0x80,&asn_buf); + } + } + } + } + if (isd_ptr->ss_info.param_flag & 0x02) // call bar info + { + callbar_ptr = (ExtCallBarInfo_struct *) &isd_ptr->ss_info.call_info; + for (jj = 0;jj < 5;jj ++) + { + kk = 0x01 << jj; + if ((callbar_ptr->param_flag & kk) != 0) + { + sprintf(tlv2,"%s.1-%d",tlv1,tag2++); + tag3 = 1; + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&callbar_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.16-%d",tlv2,tag3++); + add_null(tlv3,0x20,&asn_buf); + tag4 = 1; + sprintf(tlv4,"%s.16-%d",tlv3,tag4); + add_null(tlv4,0x20,&asn_buf); + tag5 = 1; + if (callbar_ptr->bs_code[jj].param_flag == 2) + { + sprintf(tlv5,"%s.2-%d",tlv4,tag5++); + if (bearer_bittostr(callbar_ptr->bs_code[jj].bearer_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + else if (callbar_ptr->bs_code[jj].param_flag == 1) + { + sprintf(tlv5,"%s.3-%d",tlv4,tag5++); + if (tele_bittostr(callbar_ptr->bs_code[jj].tele_code,temp_data,1)) + buf_len = add_tlv(tlv5,1,temp_data,0x80,&asn_buf); + } + sprintf(tlv5,"%s.4-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,1,&callbar_ptr->ss_status[jj],0x80,&asn_buf); + } + } + } + if (isd_ptr->ss_info.param_flag & 0x08) // ss data + { + ss_ptr = (ExtSsData_struct *)&isd_ptr->ss_info.ss_data; + for(jj = 0;jj < 16;jj ++) + { + kk = 0x01 << jj; + if (ss_ptr->param_flag & kk) + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + tag3 = 1; + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&ss_ptr->ss_code[jj],0x00,&asn_buf); + sprintf(tlv3,"%s.4-%d",tlv2,tag3++); + buf_len = add_tlv(tlv3,1,&ss_ptr->ss_status[jj],0x80,&asn_buf); + if (ss_ptr->subs_opt[jj].choice_flag == 1) + { + sprintf(tlv3,"%s.2-%d",tlv2,tag3++); + temp_buf[0] = ss_ptr->subs_opt[jj].choice.clires_opt; + buf_len = add_tlv(tlv3,1,temp_buf,0x80,&asn_buf); + } + else if (ss_ptr->subs_opt[jj].choice_flag == 2) + { + sprintf(tlv3,"%s.1-%d",tlv2,tag3++); + temp_buf[0] = ss_ptr->subs_opt[jj].choice.over_cate; + buf_len = add_tlv(tlv3,1,temp_buf,0x80,&asn_buf); + } + } + } + } + } + + if (flag & 0x10) // odb-data + { + if(isd_ptr->odb_data.param_flag & 0x03) + { + sprintf(tlv1,"8-%d",tag1++); + tag2 = 1; + if (isd_ptr->odb_data.param_flag & 0x01) // ODB general data + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + temp_buf[0] = isd_ptr->odb_data.odb_general >> 8; + temp_buf[1] = isd_ptr->odb_data.odb_general; + if(version<3) + len = bytestrtobitstr(temp_data,temp_buf,6); + else + len = bytestrtobitstr(temp_data,temp_buf,15); + buf_len = add_tlv(tlv2,len,temp_data,0x00,&asn_buf); + } + if (isd_ptr->odb_data.param_flag & 0x02) // ODB HPLMN data + { + sprintf(tlv2,"%s.3-%d",tlv1,tag2++); + temp_buf[0] = isd_ptr->odb_data.odb_hplmn; + len = bytestrtobitstr(temp_data,temp_buf,4); + buf_len = add_tlv(tlv2,len,temp_data,0x00,&asn_buf); + } + } + } + + + if (flag & 0x100) // roaming restriction due to unsuppoerted feature + { + sprintf(tlv1,"9-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x200) // regional Subscription Data + { + if (isd_ptr->zc_list.list_len > ZONECODE_LEN) + return RER; + for (jj = 0;jj < isd_ptr->zc_list.list_len;jj ++) + { + sprintf(tlv1,"10-%d.4-%d",tag1,jj+1); + buf_len = add_tlv(tlv1,2,isd_ptr->zc_list.zone_code[jj],0x00,&asn_buf); + } + tag1 ++; + } + if (flag & 0x400) // vbs Subscription Data + { + if (isd_ptr->vbsdata_list.list_len > VBS_LEN) + return RER; + for (jj = 0;jj < isd_ptr->vbsdata_list.list_len;jj ++) + { + sprintf(tlv1,"11-%d.16-%d.4",tag1,jj+1); + buf_len = add_tlv(tlv1,3,isd_ptr->vbsdata_list.vbs_data[jj].group_id,0x00,&asn_buf); + if (isd_ptr->vbsdata_list.vbs_data[jj].param_flag & 0x02) + { + sprintf(tlv1,"11-%d.16-%d.5",tag1,jj+1); + buf_len = add_null(tlv1,0x00,&asn_buf); + } + } + tag1 ++; + } + if (flag & 0x800) // vgcs Subscription Data + { + if (isd_ptr->vgcdata_list.list_len > VGCS_LEN) + return -1; + for (jj = 0;jj < isd_ptr->vgcdata_list.list_len;jj ++) + { + sprintf(tlv1,"12-%d.16-%d.4",tag1,jj+1); + buf_len = add_tlv(tlv1,3,isd_ptr->vgcdata_list.vgc_data[jj].group_id,0x00,&asn_buf); + } + tag1 ++; + } + if (flag & 0x1000) // vlr Camel Subscription Info + { + if (isd_ptr->subs_info.param_flag & 0x01) //o-CSI + { + temp_len = assign_ocsi(&isd_ptr->subs_info.o_csi,temp_buf); + sprintf(tlv1,"13-%d.0",tag1); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (isd_ptr->subs_info.param_flag & 0x02) //ss-CSI + { + sprintf(tlv1,"13-%d.2",tag1); + buf_len = assign_sscsi(tlv1,&isd_ptr->subs_info.ss_csi,&asn_buf); + } + if (isd_ptr->subs_info.param_flag & 0x04) //O-BcsmCamelTDPCriteriaList + { + temp_len = assign_tdpcritlist(&isd_ptr->subs_info.tdp_list,temp_buf); + sprintf(tlv1,"13-%d.4",tag1); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x0a0,&asn_buf); + } + if (isd_ptr->subs_info.param_flag & 0x08) //sms-CSI + { + sprintf(tlv1,"13-%d.6",tag1); + buf_len = assign_smscsi(tlv1,&isd_ptr->subs_info.sms_csi,&asn_buf); + } + tag1 ++; + } + if (flag & 0x2000) // naea Preferred CI + { + sprintf(tlv1,"15-%d",tag1++); + buf_len = add_tlv(tlv1,NAEA_LEN,isd_ptr->naea_ci.cic,0x80,&asn_buf); + } + if (flag & 0x4000) // GPRS Subscription Data + { + if (isd_ptr->gprs_data.param_flag & 0x01) //data list include + { + sprintf(tlv1,"16-%d.5",tag1); + buf_len = add_null(tlv1,0x00,&asn_buf); + + sprintf(tlv1,"16-%d.1-2",tag1); + } + else + sprintf(tlv1,"16-%d.1",tag1); + + if (isd_ptr->gprs_data.gprs_list.list_len > PDPCONTEXT_LEN) + return RER; + + + for (jj = 0;jj < isd_ptr->gprs_data.gprs_list.list_len;jj ++) + { + sprintf(tlv2,"%s.16-%d",tlv1,jj+1); + buf_len = add_null(tlv2, 0x20, &asn_buf); + pdp_ptr = (PdpContext_struct *) &isd_ptr->gprs_data.gprs_list.pdp_context[jj]; + if (pdp_ptr->param_flag & 0x01) // pdp context id + { + sprintf(tlv2,"%s.16-%d.2",tlv1,jj+1); + buf_len = add_int(tlv2,pdp_ptr->pdpcontext_id,0x00,&asn_buf); + } + if (pdp_ptr->param_flag & 0x02) // pdp type + { + sprintf(tlv2,"%s.16-%d.16",tlv1,jj+1); + buf_len = add_tlv(tlv2,2,pdp_ptr->pdp_type,0x80,&asn_buf); + } + if (pdp_ptr->param_flag & 0x04) // pdp add + { + sprintf(tlv2,"%s.16-%d.17",tlv1,jj+1); + buf_len = add_tlv(tlv2,pdp_ptr->pdp_add[0],pdp_ptr->pdp_add+1,0x80,&asn_buf); + } + if (pdp_ptr->param_flag & 0x08) // QoS subscribed + { + sprintf(tlv2,"%s.16-%d.18",tlv1,jj+1); + buf_len = add_tlv(tlv2,3,pdp_ptr->qos_sub,0x80,&asn_buf); + } + if (pdp_ptr->param_flag & 0x10) // VPLMN address allowed + { + sprintf(tlv2,"%s.16-%d.19",tlv1,jj+1); + buf_len = add_null(tlv2,0x80,&asn_buf); + } + if (pdp_ptr->param_flag & 0x20) // apn + { + if (pdp_ptr->apn.apn_len > APN_LEN) + return RER; + sprintf(tlv2,"%s.16-%d.20",tlv1,jj+1); + buf_len = add_tlv(tlv2,pdp_ptr->apn.apn_len,pdp_ptr->apn.apn_data,0x80,&asn_buf); + } + } + tag1 ++; + } + if (flag & 0x8000) // roaming Restricted In Sgsn Due To Unsupported Feature + { + sprintf(tlv1,"23-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x10000) // network Aceess Mode + { + sprintf(tlv1,"24-%d",tag1++); + buf_len = add_int(tlv1,isd_ptr->net_mode,0x80,&asn_buf); + } + return buf_len; +} + +int extract_inssubdataarg(struct MapISD_Arg *isd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len,jj; + int temp_len; + u32 flag=0; + u8 tag1; + char tlv2[32],tlv3[32]; + u8 temp_buf[256],temp_data[256]; + struct ExtFwdInfo_struct *fwd_ptr; + struct ExtCallBarInfo_struct *callbar_ptr; + struct ExtSsData_struct *ss_ptr; + struct PdpContext_struct *pdp_ptr; + + isd_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); // get imsi + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + flag |= 0x01; + memcpy(isd_ptr->imsi,temp_buf,len); + } + if ((len=get_tlv("1",temp_buf,&asn_buf)) > 2) + { + flag |= 0x02; + isd_ptr->msisdn[0] = len; + memcpy(isd_ptr->msisdn+1,temp_buf,len); + } + if (get_tlv("2",temp_buf,&asn_buf) > 0) + { + flag |= 0x04; + isd_ptr->category = temp_buf[0]; + } + if(get_tlv("3",temp_buf,&asn_buf) > 0) + { + flag |= 0x08; + isd_ptr->sub_status = temp_buf[0]; + } + isd_ptr->odb_data.param_flag = 0; + len = get_tlv("8.3-1",temp_buf,&asn_buf); //odb-data->odb->GreneralData + if (len != -1) + { + flag |= 0x10; // odb - data + isd_ptr->odb_data.param_flag |= 0x01; //odb general + jj = bitstrtobytestr(temp_data,temp_buf,len); + isd_ptr->odb_data.odb_general = bcdtou32(temp_data,jj); + } + len = get_tlv("8.3-2",temp_buf,&asn_buf); + if (len != -1) + { + flag |= 0x10; // odb - data + isd_ptr->odb_data.param_flag |= 0x02; // odb hplmn + jj = bitstrtobytestr(temp_data,temp_buf,len); + isd_ptr->odb_data.odb_hplmn = bcdtou32(temp_data,jj); + } + temp_len = 0; + for (jj = 0;jj < BSLIST_LEN;jj ++) // bearer Service List + { + sprintf(tlv2,"4.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len ++; + flag |= 0x20; + } + isd_ptr->bearer_data = bearer_strtobit(temp_data,temp_len); + temp_len = 0; + for (jj = 0;jj < TSLIST_LEN;jj ++) // tele Service List + { + sprintf(tlv2,"6.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len++; + flag |= 0x40; + } + isd_ptr->tele_data = tele_strtobit(temp_data,temp_len); + isd_ptr->ss_info.param_flag = 0; + tag1 = 1; + if (get_tlv("7.0",temp_buf,&asn_buf) != -1) // forwarding info + { + flag |= 0x80; // ss info + isd_ptr->ss_info.param_flag |= 0x01; // fwd info + fwd_ptr = (ExtFwdInfo_struct *)&isd_ptr->ss_info.fwd_info; + fwd_ptr->param_flag = 0; + for (jj = 0;jj < 4;jj ++) + { + fwd_ptr->fwd_feat[jj].param_flag = 0; + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 0; + sprintf(tlv2,"7.0-%d.4",tag1); // ss code + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len > 0) + { + fwd_ptr->param_flag |= (0x01 << jj); + fwd_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.0-%d.16.16",tag1); // forward feature + sprintf(tlv3,"%s.2",tlv2); // bearer code of bs code + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len > 0) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x01; + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 2; // bearer + fwd_ptr->fwd_feat[jj].bs_code.bearer_code = bearer_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.3",tlv2); // tele code of bs code + len = get_tlv(tlv3,temp_buf, &asn_buf); + if (len >= 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x01; // bs code + fwd_ptr->fwd_feat[jj].bs_code.param_flag = 1;// tele + fwd_ptr->fwd_feat[jj].bs_code.tele_code = tele_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.4",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x02; // ss status + fwd_ptr->fwd_feat[jj].ss_status = temp_buf[0]; + } + sprintf(tlv3,"%s.5",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x04; // fwd to num + fwd_ptr->fwd_feat[jj].fwdto_num[0] = len; + memcpy(fwd_ptr->fwd_feat[jj].fwdto_num+1,temp_buf,len); + } + sprintf(tlv3,"%s.6",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x08; // fwd opt + fwd_ptr->fwd_feat[jj].fwd_option = temp_buf[0]; + } + sprintf(tlv3,"%s.7",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + { + fwd_ptr->fwd_feat[jj].param_flag |= 0x10; // norc time + fwd_ptr->fwd_feat[jj].norc_time = temp_buf[0]; + } + tag1 ++; + } + } + if (get_tlv("7.1",temp_buf,&asn_buf) != -1) // call Barring Info + { + flag |= 0x80; // ss info + isd_ptr->ss_info.param_flag |= 0x02; // call bar info + callbar_ptr = (ExtCallBarInfo_struct *)&isd_ptr->ss_info.call_info; + callbar_ptr->param_flag = 0; + for (jj = 0;jj < 5;jj ++) + { + callbar_ptr->bs_code[jj].param_flag = 0; + sprintf(tlv2,"7.1-%d.4",tag1); //callbarringInfo + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + callbar_ptr->param_flag |= (0x01 << jj); // ss code + callbar_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.1-%d.16.16",tag1); + sprintf(tlv3,"%s.4",tlv2); + if (get_tlv(tlv3,temp_buf,&asn_buf) == 1) + callbar_ptr->ss_status[jj] = temp_buf[0]; + sprintf(tlv3,"%s.2",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + callbar_ptr->bs_code[jj].param_flag = 2; // bearer + callbar_ptr->bs_code[jj].bearer_code = bearer_strtobit(temp_buf,1); + } + sprintf(tlv3,"%s.3",tlv2); + len = get_tlv(tlv3,temp_buf,&asn_buf); + if (len >= 1) + { + callbar_ptr->bs_code[jj].param_flag = 1; // bearer + callbar_ptr->bs_code[jj].tele_code = tele_strtobit(temp_buf,1); + } + tag1 ++; + } + } + if (get_tlv("7.3",temp_buf,&asn_buf) != -1) // ss_Data + { + flag |= 0x80; // ss info + isd_ptr->ss_info.param_flag |= 0x08; // ss data + ss_ptr = (ExtSsData_struct *)&isd_ptr->ss_info.ss_data; + ss_ptr->param_flag = 0; + for(jj = 0;jj < 16;jj ++) + { + sprintf(tlv2,"7.3-%d.4-1",tag1); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->param_flag |= (0x01 << jj); + ss_ptr->ss_code[jj] = temp_buf[0]; + } + else + break; + sprintf(tlv2,"7.3-%d.4-2",tag1); //ss-status +// len = get_tlv(tlv2,temp_buf,&asn_buf); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + ss_ptr->ss_status[jj] = temp_buf[0]; + ss_ptr->subs_opt[jj].choice_flag = 0; + sprintf(tlv2,"7.3-%d.2-3",tag1); //cliRestrictionOption + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->subs_opt[jj].choice_flag = 1; // clires opt + ss_ptr->subs_opt[jj].choice.clires_opt = temp_buf[0]; + } + sprintf(tlv2,"7.3-%d.1-3",tag1); //overrideCategory + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + ss_ptr->subs_opt[jj].choice_flag = 2; // clires opt + ss_ptr->subs_opt[jj].choice.over_cate = temp_buf[0]; + } + sprintf(tlv2,"7.3-%d.2-2",tag1); // bearer code + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len > 0) + ss_ptr->bs_code[jj].bearer_code = bearer_strtobit(temp_buf,1); + sprintf(tlv2,"7.3-%d.3",tag1); // tele code + len = get_tlv(tlv2,temp_buf, &asn_buf); + if (len >= 1) + ss_ptr->bs_code[jj].tele_code = tele_strtobit(temp_buf,1); + tag1 ++; + } + } + if (get_null("9",&asn_buf) != -1) //get roaming restriction data + { + flag |= 0x100; + isd_ptr->roam_feature = 1; + } + len = get_tlv("10",temp_buf,&asn_buf); //regional Subscription Data + if (len > 0) + { + flag |= 0x200; + for (jj = 0;jj < ZONECODE_LEN;jj ++) + { + sprintf(tlv2,"10.4-%d",jj+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len == 2) + memcpy(isd_ptr->zc_list.zone_code[jj],temp_buf,2); + else + break; + } + isd_ptr->zc_list.list_len = jj; + } + len = get_tlv("11",temp_buf,&asn_buf); //vbs Subscription Data + if (len > 0) + { + flag |= 0x400; + for (jj = 0;jj < VBS_LEN;jj ++) + { + sprintf(tlv2,"11.16-%d.4",jj+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len == 3) + { + memcpy(isd_ptr->vbsdata_list.vbs_data[jj].group_id,temp_buf,3); + isd_ptr->vbsdata_list.vbs_data[jj].param_flag |= 0x01; + } + else + break; + sprintf(tlv2,"11.16-%d.5",jj+1); + if (get_null(tlv2,&asn_buf) >= 0) + isd_ptr->vbsdata_list.vbs_data[jj].param_flag |= 0x02; + } + isd_ptr->vbsdata_list.list_len = jj; + } + len = get_tlv("12",temp_buf,&asn_buf); //vgcs Subscription Data + if (len > 0) + { + flag |= 0x800; + for (jj = 0;jj < VGCS_LEN;jj ++) + { + sprintf(tlv2,"12.16-%d.4",jj+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len == 3) + { + memcpy(isd_ptr->vgcdata_list.vgc_data[jj].group_id,temp_buf,3); + isd_ptr->vgcdata_list.vgc_data[jj].param_flag = 0x01; + } + else + break; + } + isd_ptr->vgcdata_list.list_len = jj; + } + len = get_tlv("13",temp_buf,&asn_buf); //vlr Camel Subscription Info + if (len > 0) + { + flag |= 0x1000; + isd_ptr->subs_info.param_flag = 0; + len = get_tlv("13.0",temp_buf,&asn_buf); //o-CSI + if (len != -1) + { + if (!extract_ocsi(&isd_ptr->subs_info.o_csi,len,temp_buf)) + return RER; + isd_ptr->subs_info.param_flag |= 0x01; + } + if (extract_sscsi("13.2",&isd_ptr->subs_info.ss_csi,&asn_buf) > 0) //ss-CSI + isd_ptr->subs_info.param_flag |= 0x02; + len = get_tlv("13.4",temp_buf,&asn_buf); //O-BcsmCamelTDPCriteriaList + if (len != -1) + { + if (!extract_tdpcritlist(&isd_ptr->subs_info.tdp_list,len,temp_buf)) + return RER; + isd_ptr->subs_info.param_flag |= 0x04; + } + if (extract_smscsi("13.6",&isd_ptr->subs_info.sms_csi,&asn_buf) > 0) //sms-CSI + isd_ptr->subs_info.param_flag |= 0x08; + } + if (get_tlv("15.0",temp_buf,&asn_buf) == NAEA_LEN) //naea Preferred CI + { + memcpy(isd_ptr->naea_ci.cic,temp_buf,NAEA_LEN); + flag |= 0x2000; + } + len = get_tlv("16",temp_buf,&asn_buf); //GPRS Subscription Data + if (len > 0) + { + flag |= 0x4000; + if (get_null("16.5",&asn_buf) != -1) + { + isd_ptr->gprs_data.param_flag |= 0x01; + isd_ptr->gprs_data.data_include = 1; + } + for (jj = 0;jj < PDPCONTEXT_LEN;jj ++) + { + pdp_ptr = (PdpContext_struct *) &isd_ptr->gprs_data.gprs_list.pdp_context[jj]; + pdp_ptr->param_flag = 0; + sprintf(tlv2,"16.16-%d.2",jj+1); // pdp context id + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + pdp_ptr->param_flag |= 0x01; + pdp_ptr->pdpcontext_id = temp_buf[0]; + } + else + break; + sprintf(tlv2,"16.16-%d.16",jj+1); // pdp type + if (get_tlv(tlv2,temp_buf,&asn_buf) == 2) + { + pdp_ptr->param_flag |= 0x02; + memcpy(pdp_ptr->pdp_type,temp_buf,2); + } + sprintf(tlv2,"16.16-%d.17",jj+1); // pdp address + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len != -1 && len < PDP_LEN) + { + pdp_ptr->param_flag |= 0x04; + pdp_ptr->pdp_add[0] = len; + memcpy(pdp_ptr->pdp_add+1,temp_buf,len); + } + sprintf(tlv2,"16.16-%d.18",jj+1); // QoS subscribed + if (get_tlv(tlv2,temp_buf,&asn_buf) == 3) + { + pdp_ptr->param_flag |= 0x08; + memcpy(pdp_ptr->qos_sub,temp_buf,3); + } + sprintf(tlv2,"16.16-%d.19",jj+1); // vplmn allow + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + pdp_ptr->param_flag |= 0x10; + pdp_ptr->vplmn_allow = temp_buf[0]; + } + sprintf(tlv2,"16.16-%d.20",jj+1); // apn + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len != -1 && len < APN_LEN) + { + pdp_ptr->param_flag |= 0x20; + pdp_ptr->apn.apn_len = len; + memcpy(pdp_ptr->apn.apn_data,temp_buf,len); + } + } + if (jj != 0) + isd_ptr->gprs_data.param_flag |= 0x02; + isd_ptr->gprs_data.gprs_list.list_len = jj; + } + if (get_null("23",&asn_buf) != -1)//roaming Restricted In Sgsn Due To Unsupported Feature + { + flag |= 0x8000; + isd_ptr->roamsgsn_feature = 1; + } + if (get_tlv("24",temp_buf,&asn_buf) == 1) + { + flag |= 0x10000; + isd_ptr->net_mode = temp_buf[0]; + } + isd_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding insert subscribe Data response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_inssubdatares(struct MapISD_Res *isd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int temp_len; + u8 temp_buf[256],temp_data[256]; + int flag,jj,buf_len=0; + int tag1=1; + char tlv1[32],tlv2[32]; + + asn_encode(buf,&asn_buf); + flag = isd_ptr->param_flag; + if (flag & 0x01) // tele list + { + temp_len = tele_bittostr(isd_ptr->tele_data,temp_data,0); + sprintf(tlv1,"1-%d",tag1++); + for (jj = 0;jj < temp_len;jj ++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,&temp_data[jj],0x00,&asn_buf); + } + } + if (flag & 0x02) // bearer list + { + temp_len = bearer_bittostr(isd_ptr->bearer_data,temp_data,0); + sprintf(tlv1,"2-%d",tag1++); + for (jj = 0;jj < temp_len;jj ++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,&temp_data[jj],0x00,&asn_buf); + } + } + if (flag & 0x04) // ss list + { + sprintf(tlv1,"3-%d",tag1++); + for (jj = 0;jj < isd_ptr->ss_list.sslist_len;jj ++) + { + sprintf(tlv2,"%s.4-%d",tlv1,jj+1); + buf_len = add_tlv(tlv2,1,&isd_ptr->ss_list.ss_code[jj],0x00,&asn_buf); + } + } + if (flag & 0x08) // odb data + { + sprintf(tlv1,"4-%d",tag1++); + temp_buf[0] = isd_ptr->odb_data; + temp_len = bytestrtobitstr(temp_data,temp_buf,6); + buf_len = add_tlv(tlv1,temp_len,temp_data,0x80,&asn_buf); + } + if (flag & 0x10) //subs res + { + sprintf(tlv1,"5-%d",tag1++); + temp_buf[0] = isd_ptr->subs_res; + buf_len = add_tlv(tlv1,1,temp_buf,0x80,&asn_buf); + } + if (flag & 0x20) // camel phase + { + sprintf(tlv1,"6-%d",tag1++); + buf_len = add_tlv(tlv1,3,isd_ptr->camel_phase,0x80,&asn_buf); + } + return buf_len; +} + +int extract_inssubdatares(struct MapISD_Res *isd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len,jj; + int temp_len; + u8 temp_buf[256],temp_data[256]; + u32 flag=0; + char tlv2[32]; + + isd_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + temp_len = 0; + for (jj = 0;jj < TSLIST_LEN;jj ++) // tele Service List + { + sprintf(tlv2,"1.4-%d",jj+1); + if(get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len++; + flag |= 0x01; + } + isd_ptr->tele_data = tele_strtobit(temp_data,temp_len); + temp_len = 0; + for (jj = 0;jj < BSLIST_LEN;jj ++) // bearer Service List + { + sprintf(tlv2,"2.4-%d",jj+1); + if(get_tlv(tlv2,temp_buf,&asn_buf) < 1) + break; + temp_data[jj] = temp_buf[0]; + temp_len ++; + flag |= 0x02; + } + isd_ptr->bearer_data = bearer_strtobit(temp_data,temp_len); + isd_ptr->ss_list.sslist_len = 0; + for (jj = 0;jj < SS_LEN;jj ++) // ss list + { + sprintf(tlv2,"3.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) + { + flag |= 0x04; + isd_ptr->ss_list.ss_code[jj] = temp_buf[0]; + } + else + break; + } + isd_ptr->ss_list.sslist_len = jj; + len = get_tlv("4",temp_buf,&asn_buf); //odb-data + if (len != -1) + { + flag |= 0x08; + jj = bitstrtobytestr(temp_data,temp_buf,len); + isd_ptr->odb_data = bcdtou32(temp_data,jj); + } + if (get_tlv("5",temp_buf,&asn_buf) == 1)// subs response + { + isd_ptr->subs_res = temp_buf[0]; + flag |= 0x10; + } + if (get_tlv("6",temp_buf,&asn_buf) == 3) + { + memcpy(isd_ptr->camel_phase,temp_buf,3); + flag |= 0x20; + } + isd_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding delete Subscriber Data argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_delsubdataarg(struct MapDSD_Arg *dsd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0,jj; + char tlv2[32]; + u32 flag; + int temp_len; + u8 temp_data[256]; + + flag = dsd_ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //imsi + buf_len = add_tlv("0",IMSI_LEN,dsd_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (flag & 0x02) //bs code + { + temp_len = assign_bscode(&dsd_ptr->bs_code,temp_data,0); + buf_len = add_tlv("1",temp_len,temp_data,0x80,&asn_buf); + } + if (flag & 0x04) //ss list + { + for (jj = 0;jj < dsd_ptr->ss_list.sslist_len;jj ++) + { + sprintf(tlv2,"2.4-%d",jj+1); + buf_len = add_tlv(tlv2,1,&dsd_ptr->ss_list.ss_code[jj],0x00,&asn_buf); + } + } + if (flag & 0x08) //roaming restriction due to unsupported feature + buf_len = add_null("4",0x80,&asn_buf); + if (flag & 0x10) //regional subscription identifier (zone code) + buf_len = add_tlv("5",2,dsd_ptr->regional_ident,0x80,&asn_buf); + if (flag & 0x20) //vbsGroupIndication + buf_len = add_null("7",0x80,&asn_buf); + if (flag & 0x40) //vgcGroupIndication + buf_len = add_null("8",0x80,&asn_buf); + if (flag & 0x80) //camelSubscriptionInfoWithdraw + buf_len = add_null("9",0x80,&asn_buf); + if (flag & 0x100) //gprsSubscriptionDataWithdraw + { + if (dsd_ptr->gprs_withdraw.choice_flag & 0x01) + buf_len = add_null("10.5",0x00,&asn_buf); + else if (dsd_ptr->gprs_withdraw.choice_flag & 0x02) + { + if (dsd_ptr->gprs_withdraw.choice.context_list.list_len > PDPCONTEXT_LEN) + return RER; + temp_len = dsd_ptr->gprs_withdraw.choice.context_list.list_len; + for (jj = 0;jj < temp_len;jj ++) + { + sprintf(tlv2,"10.4-%d",jj+1); + buf_len = add_int(tlv2,dsd_ptr->gprs_withdraw.choice.context_list.context_id[jj],0x00,&asn_buf); + } + } + } + if (flag & 0x200) //roaming restricted insgsn due to unsupported feature + buf_len = add_null("11",0x80,&asn_buf); + return buf_len; +} + +int extract_delsubdataarg(struct MapDSD_Arg *dsd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len,jj; + u8 temp_buf[256]; + char tlv2[32]; + + dsd_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //imsi + { + dsd_ptr->param_flag|=0x01; + memcpy(dsd_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + if ((len=get_tlv("1",temp_buf,&asn_buf)) > 0) //bs code + { + if (!extract_bscode(&dsd_ptr->bs_code,len,temp_buf)) + return RER; + dsd_ptr->param_flag |= 0x02; + } + dsd_ptr->ss_list.sslist_len = 0; + for (jj = 0;jj < SS_LEN;jj ++) //get ss list + { + sprintf(tlv2,"2.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) != 1) + break; + dsd_ptr->ss_list.sslist_len++; + dsd_ptr->ss_list.ss_code[jj] = temp_buf[0]; + dsd_ptr->param_flag|=0x04; + } + if (get_tlv("4",temp_buf,&asn_buf) != -1) //roaming restriction due to unsupported feature + { + dsd_ptr->param_flag |= 0x08; + dsd_ptr->roam_feature = 1; + } + if (get_tlv("5",temp_buf,&asn_buf) == 2) // regional subscription identifier (zone code) + { + dsd_ptr->param_flag |= 0x10; + memcpy(dsd_ptr->regional_ident,temp_buf,2); + } + if (get_tlv("7",temp_buf,&asn_buf) != -1) //vbsGroupIndication + { + dsd_ptr->param_flag |= 0x20; + dsd_ptr->vbsg_ind = 1; + } + if (get_tlv("8",temp_buf,&asn_buf) != -1) //vgcGroupIndication + { + dsd_ptr->param_flag |= 0x40; + dsd_ptr->vgcsg_ind = 1; + } + if (get_tlv("9",temp_buf,&asn_buf) != -1) //camelSubscriptionInfoWithdraw + { + dsd_ptr->param_flag |= 0x80; + dsd_ptr->camel_withdraw = 1; + } + if (get_tlv("10",temp_buf,&asn_buf) != -1) //gprsSubscriptionDataWithdraw + { + dsd_ptr->param_flag |= 0x100; + if (get_tlv("10.5",temp_buf,&asn_buf) != -1) // all GPRS data + { + dsd_ptr->gprs_withdraw.choice_flag = 0x01; + dsd_ptr->gprs_withdraw.choice.allgprs_data = 1; + } + else + { + dsd_ptr->gprs_withdraw.choice.context_list.list_len = 0; + for (jj = 0;jj < PDPCONTEXT_LEN;jj ++) + { + sprintf(tlv2,"10.4-%d",jj+1); + if (get_tlv(tlv2,temp_buf,&asn_buf) != 1) + break; + dsd_ptr->gprs_withdraw.choice.context_list.context_id[jj] = temp_buf[0]; + dsd_ptr->gprs_withdraw.choice.context_list.list_len ++; + dsd_ptr->gprs_withdraw.choice_flag = 0x02; + } + } + } + if (get_tlv("11",temp_buf,&asn_buf) != -1) //roaming restricted insgsn due to unsupported feature + { + dsd_ptr->param_flag |= 0x200; + dsd_ptr->roamsgsn_feature = 1; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding delete Subscriber Data response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_delsubdatares(struct MapDSD_Res *dsdr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[16]; + + asn_encode(buf,&asn_buf); + if (dsdr_ptr->param_flag & 0x01) + { + temp_buf[0] = dsdr_ptr->subs_res; + buf_len = add_tlv("0",1,temp_buf,0x80,&asn_buf); + } + return buf_len; +} + +int extract_delsubdatares(struct MapDSD_Res *dsdr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + dsdr_ptr->param_flag=0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) > 0) + { + dsdr_ptr->subs_res = temp_buf[0]; + dsdr_ptr->param_flag |= 0x01; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++ */ +/* encoding/decoding RESET argument */ +/* +++++++++++++++++++++++++++++++++ */ +int assign_resetarg(struct MapReset_Arg *rs_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0,ii; + u8 temp_isdn[32]; + char tlv2[32]; + + asn_encode(buf,&asn_buf); + flag = rs_ptr->param_flag; + if (flag & 0x01) // hlr num + buf_len = add_tlv("4",rs_ptr->hlr_num[0],rs_ptr->hlr_num+1,0x00,&asn_buf); + else + { + mapp_log_debug("reset lack hlr_num"); + return RER; + } + if (flag & 0x02) // hlr_list + { + for(ii = 0;ii < rs_ptr->hlr_list.list_len;ii ++) + { + buf_len = add_null("16",0x20,&asn_buf); + sprintf(tlv2,"16.4-%d",ii+1); + buf_len = add_tlv(tlv2,IMSI_LEN,rs_ptr->hlr_list.hlr_id[ii],0x00,&asn_buf); + } + } + if (flag & 0x04) //networkResource + { + temp_isdn[0] = rs_ptr->networkResource; + buf_len = add_tlv("10",1,temp_isdn,0x00,&asn_buf); + } + return buf_len; +} + +int extract_resetarg(struct MapReset_Arg *rs_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + int ii; + char tlv2[32]; + + rs_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_reset,buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); //hlr num + if(len > 2) + { + rs_ptr->param_flag |= 0x01; + rs_ptr->hlr_num[0] = len; + memcpy(rs_ptr->hlr_num+1,temp_buf,len); + } + else + { + mapp_log_debug("extract resetArg lack hlr number"); + return RER; + } + rs_ptr->hlr_list.list_len=0; + for (ii = 0;ii < HLRID_NUM;ii ++) + { + sprintf(tlv2,"16.4-%d",ii+1); + len = get_tlv(tlv2,temp_buf,&asn_buf); + if (len != IMSI_LEN) + break; + rs_ptr->param_flag |= 0x02; + memcpy(rs_ptr->hlr_list.hlr_id[ii],temp_buf,IMSI_LEN); + } + rs_ptr->hlr_list.list_len = ii; + if(get_tlv("10",temp_buf,&asn_buf) == 1) + { + rs_ptr->networkResource=temp_buf[0]; + rs_ptr->param_flag |= 0x04; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding restore Data argument */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_restdataarg(struct MapRD_Arg *rsd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (rsd_ptr->param_flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,rsd_ptr->imsi,0x00,&asn_buf); + else + return RER; + if (rsd_ptr->param_flag & 0x02) //lmsi + buf_len = add_tlv("4-2",LMSI_LEN,rsd_ptr->lmsi,0x00,&asn_buf); + if (rsd_ptr->param_flag & 0x04) // VLR capability + { + if (rsd_ptr->vlr_cap.param_flag & 0x01) // camel phase + buf_len = add_tlv("6.0",3,rsd_ptr->vlr_cap.camel_phase,0x80,&asn_buf); + } + return buf_len; +} + +int extract_restdataarg(struct MapRD_Arg *rsd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_restdataarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + rsd_ptr->param_flag = 0; + len = get_tlv("4-1",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + rsd_ptr->param_flag |= 0x01; + memcpy(rsd_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + if (get_tlv("4-2",temp_buf,&asn_buf) == LMSI_LEN) //get lmsi + { + memcpy(rsd_ptr->lmsi,temp_buf,LMSI_LEN); + rsd_ptr->param_flag |= 0x02; + } + len = get_tlv("6.0",temp_buf,&asn_buf); //get camel info + if (len != -1) + { + memcpy(rsd_ptr->vlr_cap.camel_phase,temp_buf,3); + rsd_ptr->vlr_cap.param_flag = 0x01; + rsd_ptr->param_flag |= 0x04; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding restore Data response */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_restdatares(struct MapRD_Res *rsd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (rsd_ptr->param_flag & 0x01) //hlr num + buf_len = add_tlv("4",rsd_ptr->hlr_num[0],rsd_ptr->hlr_num+1,0x00,&asn_buf); + else + return RER; + if (rsd_ptr->param_flag & 0x02) //MS not reachable + buf_len = add_null("5",0x00,&asn_buf); + return buf_len; +} + +int extract_restdatares(struct MapRD_Res *rsd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_restdatares buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + rsd_ptr->param_flag = 0; + if((len=get_tlv("4",temp_buf,&asn_buf)) > 2 )//get hlr number + { + rsd_ptr->hlr_num[0] = len; + memcpy(rsd_ptr->hlr_num+1,temp_buf,len); + rsd_ptr->param_flag|=0x01; + } + else + return RER; + if(get_tlv("5",temp_buf,&asn_buf) != -1) //get MS not reachable + { + rsd_ptr->param_flag |= 0x02; + rsd_ptr->msnot_reach = 1; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send routing info for GPRS argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndroutinfogprsarg(struct MapSRIFG_Arg *sfg_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (sfg_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,sfg_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (sfg_ptr->param_flag & 0x02) // ggsn address + buf_len = add_tlv("1",sfg_ptr->ggsn_add[0],sfg_ptr->ggsn_add+1,0x80,&asn_buf); + if (sfg_ptr->param_flag & 0x04) // ggsn number + buf_len = add_tlv("2",sfg_ptr->ggsn_num[0],sfg_ptr->ggsn_num+1,0x80,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_sndroutinfogprsarg(struct MapSRIFG_Arg *sfg_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sfg_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_sendroutinfoforgprs buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + sfg_ptr->param_flag |= 0x01; + memcpy(sfg_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 0 && len <= GSN_LEN) //get ggsn address + { + sfg_ptr->param_flag |= 0x02; + sfg_ptr->ggsn_add[0] = len; + memcpy(sfg_ptr->ggsn_add+1,temp_buf,len); + } + len = get_tlv("2",temp_buf,&asn_buf); // get ggsn number + if (len >0 && len <= ISDN_LEN) + { + sfg_ptr->param_flag |= 0x04; + sfg_ptr->ggsn_num[0] = len; + memcpy(sfg_ptr->ggsn_num+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send routing info for GPRS response */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_sndroutinfogprsres(struct MapSRIFG_Res *sfg_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (sfg_ptr->param_flag & 0x01) // sgsn address + buf_len = add_tlv("0",sfg_ptr->sgsn_add[0],sfg_ptr->sgsn_add+1,0x80,&asn_buf); + else + return RER; + if (sfg_ptr->param_flag & 0x02) // ggsn address + buf_len = add_tlv("1",sfg_ptr->ggsn_add[0],sfg_ptr->ggsn_add+1,0x80,&asn_buf); + if (sfg_ptr->param_flag & 0x04) // mobile not reachable reason + buf_len = add_tlv("2",1,&sfg_ptr->mobile_reason,0x80,&asn_buf); + return buf_len; +} + +int extract_sndroutinfogprsres(struct MapSRIFG_Res *sfg_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sfg_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_sendroutinfoforgprs res buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len > 0 && len <= GSN_LEN) + { + sfg_ptr->param_flag |= 0x01; + sfg_ptr->sgsn_add[0] = len; + memcpy(sfg_ptr->sgsn_add+1,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); + if (len > 0 && len <= GSN_LEN) //get ggsn address + { + sfg_ptr->param_flag |= 0x02; + sfg_ptr->ggsn_add[0] = len; + memcpy(sfg_ptr->ggsn_add+1,temp_buf,len); + } + if (get_tlv("2",temp_buf,&asn_buf) == 1) // get mobile not reachable reason + { + sfg_ptr->param_flag |= 0x04; + sfg_ptr->mobile_reason = temp_buf[0]; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding failure report argument */ +/* +++++++++++++++++++++++++++++++++++++++++ */ +int assign_failreportarg(struct MapFR_Arg *fr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (fr_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,fr_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (fr_ptr->param_flag & 0x02) // ggsn number + buf_len = add_tlv("1",fr_ptr->ggsn_num[0],fr_ptr->ggsn_num+1,0x80,&asn_buf); + else + return RER; + if (fr_ptr->param_flag & 0x04) // ggsn address + buf_len = add_tlv("2",fr_ptr->ggsn_add[0],fr_ptr->ggsn_add+1,0x80,&asn_buf); + return buf_len; +} + +int extract_failreportarg(struct MapFR_Arg *fr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + fr_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_failure report buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + fr_ptr->param_flag |= 0x01; + memcpy(fr_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // get ggsn number + if (len >0 && len <= ISDN_LEN) + { + fr_ptr->param_flag |= 0x02; + fr_ptr->ggsn_num[0] = len; + memcpy(fr_ptr->ggsn_num+1,temp_buf,len); + } + else + return RER; + len = get_tlv("2",temp_buf,&asn_buf); + if (len > 0 && len <= GSN_LEN) //get ggsn address + { + fr_ptr->param_flag |= 0x04; + fr_ptr->ggsn_add[0] = len; + memcpy(fr_ptr->ggsn_add+1,temp_buf,len); + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding failure report response */ +/* +++++++++++++++++++++++++++++++++++++++++ */ +int assign_failreportres(struct MapFR_Res *fr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (fr_ptr->param_flag & 0x01) // ggsn address + buf_len = add_tlv("0",fr_ptr->ggsn_add[0],fr_ptr->ggsn_add+1,0x80,&asn_buf); + return buf_len; +} + +int extract_failreportres(struct MapFR_Res *fr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + fr_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len > 0 && len <= GSN_LEN) //get ggsn address + { + fr_ptr->param_flag |= 0x01; + fr_ptr->ggsn_add[0] = len; + memcpy(fr_ptr->ggsn_add+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding note MS present for GPRS argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_notemspregprsarg(struct MapNMPFG_Arg *npg_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (npg_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,npg_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (npg_ptr->param_flag & 0x02) // sgsn address + buf_len = add_tlv("1",npg_ptr->sgsn_add[0],npg_ptr->sgsn_add+1,0x80,&asn_buf); + else + return RER; + if (npg_ptr->param_flag & 0x04) // ggsn address + buf_len = add_tlv("2",npg_ptr->ggsn_add[0],npg_ptr->ggsn_add+1,0x80,&asn_buf); + return buf_len; +} + +int extract_notemspregprsarg(struct MapNMPFG_Arg *npg_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + npg_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--note ms present for gprs buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + npg_ptr->param_flag |= 0x01; + memcpy(npg_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // get sgsn address + if (len >0 && len <= GSN_LEN) + { + npg_ptr->param_flag |= 0x02; + npg_ptr->sgsn_add[0] = len; + memcpy(npg_ptr->sgsn_add+1,temp_buf,len); + } + else + return RER; + len = get_tlv("2",temp_buf,&asn_buf); //get ggsn address + if (len > 0 && len <= GSN_LEN) + { + npg_ptr->param_flag |= 0x04; + npg_ptr->ggsn_add[0] = len; + memcpy(npg_ptr->ggsn_add+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding note MS present for GPRS response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_notemspregprsres(struct MapNMPFG_Res *npg_ptr,u8 *buf) +{ + return 0; +} + +int extract_notemspregprsres(struct MapNMPFG_Res *npg_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_code_om.c b/omc/plat/xapp/src/mapp/map_code_om.c new file mode 100644 index 0000000..49dd9f5 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_om.c @@ -0,0 +1,231 @@ +/* map coding operation & maintenance c file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* ----------------------------------------- */ + +#include "map_includes.h" + +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding activate trace mode argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_acttrcmodearg(struct MapATM_Arg *atm_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (atm_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,atm_ptr->imsi,0x80,&asn_buf); + if (atm_ptr->param_flag & 0x02) // trace reference + buf_len = add_tlv("1",2,atm_ptr->trace_ref,0x80,&asn_buf); + else + return RER; + if (atm_ptr->param_flag & 0x04) // trace type + buf_len = add_int("2",atm_ptr->trace_type,0x80,&asn_buf); + else + return RER; + if (atm_ptr->param_flag & 0x08) // omc id + buf_len = add_tlv("3",atm_ptr->omc_id[0],atm_ptr->omc_id+1,0x80,&asn_buf); + return buf_len; +} + +int extract_acttrcmodearg(struct MapATM_Arg *atm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + atm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_activate trace mode buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + atm_ptr->param_flag |= 0x01; + memcpy(atm_ptr->imsi,temp_buf,IMSI_LEN); + } + if (get_tlv("1",temp_buf,&asn_buf) == 2) + { + atm_ptr->param_flag |= 0x02; + memcpy(atm_ptr->trace_ref,temp_buf,2); + } + else + return RER; + if (get_tlv("2",temp_buf,&asn_buf) == 1) + { + atm_ptr->param_flag |= 0x04; + atm_ptr->trace_type = temp_buf[0]; + } + else + return RER; + len = get_tlv("3",temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) + { + atm_ptr->param_flag |= 0x08; + atm_ptr->omc_id[0] = len; + memcpy(atm_ptr->omc_id+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding activate trace mode response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_acttrcmoderes(struct MapATM_Res *atm_ptr,u8 *buf) +{ + return 0; +} + +int extract_acttrcmoderes(struct MapATM_Res *atm_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding deactivate trace mode argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_deacttrcmodearg(struct MapDTM_Arg *dtm_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (dtm_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,dtm_ptr->imsi,0x80,&asn_buf); + if (dtm_ptr->param_flag & 0x02) // trace reference + buf_len = add_tlv("1",2,dtm_ptr->trace_ref,0x80,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_deacttrcmodearg(struct MapDTM_Arg *dtm_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + dtm_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_deactivate trace mode buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + dtm_ptr->param_flag |= 0x01; + memcpy(dtm_ptr->imsi,temp_buf,IMSI_LEN); + } + if (get_tlv("1",temp_buf,&asn_buf) == 2) + { + dtm_ptr->param_flag |= 0x02; + memcpy(dtm_ptr->trace_ref,temp_buf,2); + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding deactivate trace mode response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_deacttrcmoderes(struct MapDTM_Res *dtm_ptr,u8 *buf) +{ + return 0; +} + +int extract_deacttrcmoderes(struct MapDTM_Res *dtm_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send IMSI argument */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_sndimsiarg(struct MapSIMSI_Arg *sim_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (sim_ptr->param_flag & 0x01) // msisdn + buf_len = add_tlv("4",sim_ptr->msisdn[0],sim_ptr->msisdn+1,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_sndimsiarg(struct MapSIMSI_Arg *sim_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sim_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_send imsi buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) + { + sim_ptr->param_flag |= 0x01; + sim_ptr->msisdn[0] = len; + memcpy(sim_ptr->msisdn+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding send IMSI response */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_sndimsires(struct MapSIMSI_Res *sim_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (sim_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("4",IMSI_LEN,sim_ptr->imsi,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_sndimsires(struct MapSIMSI_Res *sim_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sim_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_send imsi buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf); + if (len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + sim_ptr->param_flag |= 0x01; + memcpy(sim_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_code_sms.c b/omc/plat/xapp/src/mapp/map_code_sms.c new file mode 100644 index 0000000..1c4a211 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_sms.c @@ -0,0 +1,1325 @@ +/* mapp coding short message c file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* -------------------------------- */ + +#include "map_includes.h" + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding Send Routing Info For SM argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_routinfoforsmarg(struct MapRIFSM_Arg *rif_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = rif_ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //msisdn + buf_len = add_tlv("0",rif_ptr->msisdn[0],rif_ptr->msisdn+1,0x80,&asn_buf); + else + return RER; + if (flag & 0x02) //sm_rp_pri + buf_len = add_tlv("1",1,&rif_ptr->sm_rp_pri,0x80,&asn_buf); + else + return RER; + if (flag & 0x04) //service centre address + buf_len = add_tlv("2",rif_ptr->sc_add[0],rif_ptr->sc_add+1,0x80,&asn_buf); + else + return RER; + if (flag & 0x08) // gprs support indicator + buf_len = add_null("7",0x80,&asn_buf); + if (flag & 0x10) // sm-rp-mti + buf_len = add_tlv("8",1,&rif_ptr->sm_rp_mti,0x80,&asn_buf); + if (flag & 0x20) // sm-rp-smea + buf_len = add_tlv("9",rif_ptr->sm_rp_smea[0],rif_ptr->sm_rp_smea+1,0x80,&asn_buf); + return buf_len; +} + +int extract_routinfoforsmarg(struct MapRIFSM_Arg *rif_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + rif_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_routinfoforsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("0",temp_buf,&asn_buf)) > 2) //get msisdn + { + rif_ptr->msisdn[0] = len; + memcpy(rif_ptr->msisdn+1,temp_buf,len); + rif_ptr->param_flag |= 0x01; + } + else + return RER; + if(get_tlv("1",temp_buf,&asn_buf) == 1) //get sm_rp_pri + { + rif_ptr->sm_rp_pri = temp_buf[0]; + rif_ptr->param_flag |= 0x02; + } + else + return RER; + if((len=get_tlv("2",temp_buf,&asn_buf)) > 2 ) //get service centre address + { + rif_ptr->sc_add[0] = len; + memcpy(rif_ptr->sc_add+1,temp_buf,len); + rif_ptr->param_flag |= 0x04; + } + else + return RER; + if (get_tlv("7",temp_buf,&asn_buf) != -1) // gprs support indicator + { + rif_ptr->param_flag |= 0x08; + rif_ptr->gprssup_flag = 1; + } + if (get_tlv("8",temp_buf,&asn_buf) == 1) // sm-rp-mti + { + rif_ptr->param_flag |= 0x10; + rif_ptr->sm_rp_mti = temp_buf[0]; + } + len = get_tlv("9",temp_buf,&asn_buf); + if (len != -1 && len < SMEA_LEN) // sm-rp-smea + { + rif_ptr->param_flag |= 0x20; + rif_ptr->sm_rp_smea[0] =len; + memcpy(rif_ptr->sm_rp_smea+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding Send Routing Info For SM response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_routinfoforsmres(struct MapRIFSM_Res *rif_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + u32 flag; + u8 tag1; + u8 tlv1[32]; + + flag = rif_ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,rif_ptr->imsi,0x00,&asn_buf); + else + return RER; + if (flag & 0x02) //LocInfoLMSI_struct + { + tag1 = 1; + if (rif_ptr->loc_info.param_flag & 0x01) //msc_number + { + sprintf(tlv1,"0-2.1-%d",tag1++); + len = rif_ptr->loc_info.netnode_num[0]; + buf_len = add_tlv(tlv1,len,rif_ptr->loc_info.netnode_num+1,0x80,&asn_buf); + } + if (rif_ptr->loc_info.param_flag & 0x02) //lmsi + { + sprintf(tlv1,"0-2.4-%d",tag1++); + buf_len = add_tlv(tlv1,LMSI_LEN,rif_ptr->loc_info.lmsi,0x00,&asn_buf); + } + if (rif_ptr->loc_info.param_flag & 0x04) // gprs node indicator + { + sprintf(tlv1,"0-2.5-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (rif_ptr->loc_info.param_flag & 0x08) // additional number + { + if (rif_ptr->loc_info.add_num.choice_flag & 0x01) // msc number + { + sprintf(tlv1,"0-2.6-%d.0",tag1); + len = rif_ptr->loc_info.add_num.choice.msc_num[0]; + buf_len = add_tlv(tlv1,len,rif_ptr->loc_info.add_num.choice.msc_num+1,0x80,&asn_buf); + } + else + { + sprintf(tlv1,"0-2.6-%d.1",tag1); + len = rif_ptr->loc_info.add_num.choice.sgsn_num[0]; + buf_len = add_tlv(tlv1,len,rif_ptr->loc_info.add_num.choice.sgsn_num+1,0x80,&asn_buf); + } + } + } + else + return RER; + return buf_len; +} + +int extract_routinfoforsmres(struct MapRIFSM_Res *rif_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len,loop; + + rif_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_routinfoforsmres buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4",temp_buf,&asn_buf) % 9; +// if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + if (len>0) + { + if(lenimsi,temp_buf,IMSI_LEN); + rif_ptr->param_flag |= 0x01; + } + else + return RER; + if (get_tlv("0",temp_buf,&asn_buf) > 0) //get LocInfoLMSI_struct + { + rif_ptr->param_flag|=0x02; + rif_ptr->loc_info.param_flag = 0; + if((len=get_tlv("0.1",temp_buf,&asn_buf)) > 0) //msc_num + { + rif_ptr->loc_info.param_flag |= 0x01; + rif_ptr->loc_info.netnode_num[0] = len; + memcpy(rif_ptr->loc_info.netnode_num+1,temp_buf,len); + } + if(get_tlv("0.4",temp_buf,&asn_buf) == LMSI_LEN) //get lmsi + { + rif_ptr->loc_info.param_flag |= 0x02; + memcpy(rif_ptr->loc_info.lmsi,temp_buf,LMSI_LEN); + } + if (get_tlv("0.5",temp_buf,&asn_buf) != -1) // gprs node indicator + { + rif_ptr->loc_info.param_flag |= 0x04; + rif_ptr->loc_info.gprsnode_flag = 1; + } + len = get_tlv("0.6.0",temp_buf,&asn_buf); // msc number + if (len != -1 && len <= ISDN_LEN) + { + rif_ptr->loc_info.param_flag |= 0x08; + rif_ptr->loc_info.add_num.choice_flag = 1; + rif_ptr->loc_info.add_num.choice.msc_num[0] = len; + memcpy(rif_ptr->loc_info.add_num.choice.msc_num+1,temp_buf,len); + } + else + { + len = get_tlv("0.6.1",temp_buf,&asn_buf); // sgsn number + if (len != -1 && len <= ISDN_LEN) + { + rif_ptr->loc_info.param_flag |= 0x08; + rif_ptr->loc_info.add_num.choice_flag = 2; + rif_ptr->loc_info.add_num.choice.sgsn_num[0] = len; + memcpy(rif_ptr->loc_info.add_num.choice.sgsn_num+1,temp_buf,len); + } + } + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding Send Routing Info For SM V1 argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_routinfoforsm_v1_arg(struct MapRIFSMV1_Arg *rif_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = rif_ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01)//msisdn + buf_len = add_tlv("0",rif_ptr->msisdn[0],rif_ptr->msisdn+1,0x80,&asn_buf); + else + return RER; + if (flag & 0x02) //sm_rp_pri + buf_len = add_tlv("1",1,&rif_ptr->sm_rp_pri,0x80,&asn_buf); + else + return RER; + if (flag & 0x04) //service centre address + buf_len = add_tlv("2",rif_ptr->sc_add[0],rif_ptr->sc_add+1,0x80,&asn_buf); + else + return RER; + if (flag & 0x08) //tele service + buf_len = add_tlv("5",1,&rif_ptr->tele_service,0x80,&asn_buf); + + return buf_len; +} + +int extract_routinfoforsm_v1_arg(struct MapRIFSMV1_Arg *rif_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + rif_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_routinfoforsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("0",temp_buf,&asn_buf)) > 2) //get msisdn + { + rif_ptr->msisdn[0] = len; + memcpy(rif_ptr->msisdn+1,temp_buf,len); + rif_ptr->param_flag |= 0x01; + } + else + return RER; + if(get_tlv("1",temp_buf,&asn_buf) == 1) //get sm_rp_pri + { + rif_ptr->sm_rp_pri = temp_buf[0]; + rif_ptr->param_flag |= 0x02; + } + else + return RER; + if((len=get_tlv("2",temp_buf,&asn_buf)) > 2 ) //get service centre address + { + rif_ptr->sc_add[0] = len; + memcpy(rif_ptr->sc_add+1,temp_buf,len); + rif_ptr->param_flag |= 0x04; + } + else + return RER; + if (get_tlv("5",temp_buf,&asn_buf) == -1) // gprs support indicator + { + rif_ptr->param_flag |= 0x08; + memcpy( &rif_ptr->tele_service , temp_buf ,1 ); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding Send Routing Info For SM response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_routinfoforsm_v1_res(struct MapRIFSMV1_Res *rif_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + + flag = rif_ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //imsi + buf_len = add_tlv("4-1",IMSI_LEN,rif_ptr->imsi,0x00,&asn_buf); + else + return RER; + if (flag & 0x02) //LocInfoLMSI_struct_v1 + { + + if (rif_ptr->loc_info.param_flag & 0x01) //location info + { + if( rif_ptr->loc_info.choice_flag == 1) + { + buf_len = add_tlv("0-2.0-1",ISDN_LEN,rif_ptr->loc_info.choice.roaming_num,0x80,&asn_buf); + } + else if( rif_ptr->loc_info.choice_flag == 2) + { + buf_len = add_tlv("0-2.1-1",ISDN_LEN,rif_ptr->loc_info.choice.msc_num,0x80,&asn_buf); + } + } + if (rif_ptr->loc_info.param_flag & 0x02) //imsi + { + buf_len = add_tlv("0-2.4-2",IMSI_LEN,rif_ptr->loc_info.imsi,0x80,&asn_buf); + } + } + else + return RER; + + if( flag & 0x04 ) + buf_len = add_tlv("2-3",1,&rif_ptr->mwd_set,0x80,&asn_buf); + return buf_len; +} + +int extract_routinfoforsm_v1_res(struct MapRIFSMV1_Res *rif_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + rif_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_routinfoforsmres buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("4-1",temp_buf,&asn_buf) ; + if ( len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + memcpy(rif_ptr->imsi,temp_buf,IMSI_LEN); + rif_ptr->param_flag |= 0x01; + } + else + return RER; + + if (get_tlv("0",temp_buf,&asn_buf) > 0) //get LocInfoLMSI_struct + { + rif_ptr->param_flag|=0x02; + rif_ptr->loc_info.param_flag = 0; + if((len=get_tlv("0.0",temp_buf,&asn_buf)) > 0) //msc_num + { + rif_ptr->loc_info.param_flag |= 0x01; + rif_ptr->loc_info.choice_flag = 1; + memcpy(rif_ptr->loc_info.choice.roaming_num,temp_buf,len); + } + if(get_tlv("0.1",temp_buf,&asn_buf) == LMSI_LEN) //get lmsi + { + rif_ptr->loc_info.param_flag |= 0x01; + rif_ptr->loc_info.choice_flag = 2; + memcpy(rif_ptr->loc_info.choice.msc_num,temp_buf,len); + } + if (get_tlv("0.4",temp_buf,&asn_buf) == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) // gprs node indicator + { + rif_ptr->loc_info.param_flag |= 0x02; + memcpy(rif_ptr->loc_info.imsi,temp_buf,IMSI_LEN); + } + } + else + return RER; + + if( get_tlv("0",temp_buf,&asn_buf) == 1 ) + { + memcpy(&rif_ptr->mwd_set,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding forward SM Arg */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_fwdsmarg(struct MapFSM_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //sm_rp_da + { + if (ptr->sm_rp_da_choice == 1) //imsi + buf_len = add_tlv("0-1",IMSI_LEN,ptr->sm_rp_da.imsi,0x80,&asn_buf); + else if (ptr->sm_rp_da_choice == 2) //lmsi + buf_len = add_tlv("1-1",LMSI_LEN,ptr->sm_rp_da.lmsi,0x80,&asn_buf); + else if( ptr->sm_rp_da_choice == 3 ) + { + len = ptr->sm_rp_da.roaming_num[0]; + buf_len = add_tlv("3-1",len,ptr->sm_rp_da.roaming_num+1,0x80,&asn_buf); + } + else if (ptr->sm_rp_da_choice== 4) //sc_add + { + len = ptr->sm_rp_da.sc_add[0]; + buf_len = add_tlv("4-1",len,ptr->sm_rp_da.sc_add+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-2",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_fwdsmarg:loss sm_rp_da"); + return RER; + } + if (flag & 0x02) //sm_rp_oa + { + if (ptr->sm_rp_oa_choice == 1) //msisdn + { + len = ptr->sm_rp_oa.msisdn[0]; + buf_len = add_tlv("2-2",len,ptr->sm_rp_oa.msisdn+1,0x80,&asn_buf); + } + else if (ptr->sm_rp_oa_choice == 2)//sc_add + { + len = ptr->sm_rp_oa.sc_add[0]; + buf_len = add_tlv("4-2",len,ptr->sm_rp_oa.sc_add+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-2",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_fwdsmarg:loss sm_rp_oa"); + return RER; + } + if (flag & 0x04) //sm_rp_ui + { + len = ptr->sm_rp_ui_len; + buf_len = add_tlv("4-3",len,ptr->sm_rp_ui,0x00,&asn_buf); + } + else + return RER; + + if( flag & 0x05 ) + { + buf_len = add_null("5-4",0x00,&asn_buf); + } + return buf_len; +} + +int extract_fwdsmarg(struct MapFSM_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_mofwdsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); //imsi + if(len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ptr->sm_rp_da_choice = 1; + memcpy(ptr->sm_rp_da.imsi,temp_buf,IMSI_LEN); + } + else + { + if((len=get_tlv("1",temp_buf,&asn_buf)) == LMSI_LEN)//lmsi + { + ptr->sm_rp_da_choice = 2; + memcpy(ptr->sm_rp_da.lmsi,temp_buf,LMSI_LEN); + } + else + { + if((len=get_tlv("3-1",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->sm_rp_da_choice = 3; + ptr->sm_rp_da.roaming_num[0] = len; + memcpy(ptr->sm_rp_da.roaming_num+1,temp_buf,len); + } + else + { + if((len=get_tlv("4-1",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->sm_rp_da_choice = 4; + ptr->sm_rp_da.sc_add[0] = len; + memcpy(ptr->sm_rp_da.sc_add+1,temp_buf,len); + } + else + { + if (get_tlv("5-1",temp_buf,&asn_buf) != -1) // no SM-RP-DA + { + ptr->sm_rp_da_choice = 5; + ptr->sm_rp_da.noms_rp_da = 1; + } + else + return RER; + } + } + + } + } + + ptr->param_flag |= 0x01; + if ((len=get_tlv("2",temp_buf,&asn_buf)) > 0) //msisdn + { + ptr->sm_rp_oa_choice = 1; + ptr->sm_rp_oa.msisdn[0] = len; + memcpy(ptr->sm_rp_oa.msisdn+1,temp_buf,len); + } + else + { + if ((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0) //sc_add + { + ptr->sm_rp_oa_choice = 2; + ptr->sm_rp_oa.sc_add[0] = len; + memcpy(ptr->sm_rp_oa.sc_add+1,temp_buf,len); + } + else + { + if (get_tlv("5-2",temp_buf,&asn_buf) != -1) // no SM-RP-OA + { + ptr->sm_rp_oa_choice = 3; + ptr->sm_rp_oa.noms_rp_oa = 1; + } + else + return RER; + } + } + ptr->param_flag |= 0x02; + if((len=get_tlv("4-3",temp_buf,&asn_buf)) !=-1) + { + ptr->param_flag |= 0x04; + ptr->sm_rp_ui_len = len; + memcpy(ptr->sm_rp_ui,temp_buf,len); + } + + if( get_tlv("5-4" ,temp_buf,&asn_buf) == 0 ) + { + ptr->param_flag |= 0x04; + ptr->more_msgtosend = 1 ; + } + return ROK; +} + + + + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MO forward SM Arg */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_mofwdsmarg(struct MapMOFSM_Arg *ptr,u8 *buf, u8 version) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //sm_rp_da + { + if (ptr->sm_rp_da.choice_flag == 1) //imsi + buf_len = add_tlv("0-1",IMSI_LEN,ptr->sm_rp_da.choice.imsi,0x80,&asn_buf); + else if (ptr->sm_rp_da.choice_flag == 2) //lmsi + buf_len = add_tlv("1-1",LMSI_LEN,ptr->sm_rp_da.choice.lmsi,0x80,&asn_buf); + else if (ptr->sm_rp_da.choice_flag == 3) //sc_add + { + len = ptr->sm_rp_da.choice.sc_add[0]; + buf_len = add_tlv("4-1",len,ptr->sm_rp_da.choice.sc_add+1,0x80,&asn_buf); + } + else if( version <3 && ptr->sm_rp_da.choice_flag == 5 ) + { + len = ptr->sm_rp_da.choice.roaming_num[0]; + buf_len = add_tlv("3-1",len,ptr->sm_rp_da.choice.roaming_num+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-1",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_mofwdsmarg:loss sm_rp_da"); + return RER; + } + if (flag & 0x02) //sm_rp_oa + { + if (ptr->sm_rp_oa.choice_flag == 1) //msisdn + { + len = ptr->sm_rp_oa.choice.msisdn[0]; + buf_len = add_tlv("2-2",len,ptr->sm_rp_oa.choice.msisdn+1,0x80,&asn_buf); + } + else if (ptr->sm_rp_oa.choice_flag == 2)//sc_add + { + len = ptr->sm_rp_oa.choice.sc_add[0]; + buf_len = add_tlv("4-2",len,ptr->sm_rp_oa.choice.sc_add+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-2",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_mofwdsmarg:loss sm_rp_oa"); + return RER; + } + if (flag & 0x04) //sm_rp_ui + { + len = ptr->sm_rp_ui.siginfo_len; + buf_len = add_tlv("4-3",len,ptr->sm_rp_ui.signal_info,0x00,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_mofwdsmarg(struct MapMOFSM_Arg *ptr,u32 buf_len,u8 *buf,u8 version) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_mofwdsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); //imsi + if(len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ptr->sm_rp_da.choice_flag = 1; + memcpy(ptr->sm_rp_da.choice.imsi,temp_buf,IMSI_LEN); + } + else + { + if((len=get_tlv("1",temp_buf,&asn_buf)) == LMSI_LEN)//lmsi + { + ptr->sm_rp_da.choice_flag = 2; + memcpy(ptr->sm_rp_da.choice.lmsi,temp_buf,LMSI_LEN); + } + else + { + if((len=get_tlv("4-1",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->sm_rp_da.choice_flag = 3; + ptr->sm_rp_da.choice.sc_add[0] = len; + memcpy(ptr->sm_rp_da.choice.sc_add+1,temp_buf,len); + } + else + { + if( version < 3 && (len=get_tlv("3-1",temp_buf,&asn_buf)) > 0 ) //roaming_num for ver <3 + { + ptr->sm_rp_da.choice_flag =5; + ptr->sm_rp_da.choice.roaming_num[0]= len; + memcpy( ptr->sm_rp_da.choice.roaming_num+1, temp_buf,len); + } + else + { + if (get_tlv("5-1",temp_buf,&asn_buf) != -1) // no SM-RP-DA + { + ptr->sm_rp_da.choice_flag = 4; + ptr->sm_rp_da.choice.no_rpda = 1; + } + else + return RER; + } + } + } + } + ptr->param_flag |= 0x01; + if ((len=get_tlv("2",temp_buf,&asn_buf)) > 0) //msisdn + { + ptr->sm_rp_oa.choice_flag = 1; + ptr->sm_rp_oa.choice.msisdn[0] = len; + memcpy(ptr->sm_rp_oa.choice.msisdn+1,temp_buf,len); + } + else + { + if ((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0) //sc_add + { + ptr->sm_rp_oa.choice_flag = 2; + ptr->sm_rp_oa.choice.sc_add[0] = len; + memcpy(ptr->sm_rp_oa.choice.sc_add+1,temp_buf,len); + } + else + { + if (get_tlv("5-2",temp_buf,&asn_buf) != -1) // no SM-RP-OA + { + ptr->sm_rp_oa.choice_flag = 3; + ptr->sm_rp_oa.choice.no_rpoa = 1; + } + else + return RER; + } + } + ptr->param_flag |= 0x02; + if((len=get_tlv("4-3",temp_buf,&asn_buf)) !=-1 ) + { + ptr->param_flag |= 0x04; + ptr->sm_rp_ui.siginfo_len = len; + memcpy(ptr->sm_rp_ui.signal_info,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MO forward SM response */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_mofwdsmres(struct MapMOFSM_Res *ptr,u8 *buf, u8 version) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + + if(version<3) + return buf_len; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) // sm-rp-ui + { + len = ptr->sm_rp_ui.siginfo_len; + buf_len = add_tlv("4",len,ptr->sm_rp_ui.signal_info,0x00,&asn_buf); + } + return buf_len; +} + +int extract_mofwdsmres(struct MapMOFSM_Res *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("4",temp_buf,&asn_buf)) > 0) + { + ptr->param_flag |= 0x01; + ptr->sm_rp_ui.siginfo_len = len; + memcpy(ptr->sm_rp_ui.signal_info,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MT forward SM argument */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_mtfwdsmarg(struct MapMTFSM_Arg *ptr,u8 *buf,u8 MAPVer) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + u32 flag; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //sm_rp_da + { + if (ptr->sm_rp_da.choice_flag == 1) //imsi + { + len = IMSI_LEN; + if(ptr->sm_rp_da.choice.imsi[IMSI_LEN-1]== 0xff) + { + int loop; + for(loop=IMSI_LEN-1;loop>2;loop--) + { + if(ptr->sm_rp_da.choice.imsi[loop] == 0xff) + len --; + } + } + + buf_len = add_tlv("0-1", + len, + ptr->sm_rp_da.choice.imsi, + 0x80, + &asn_buf); + } + else if (ptr->sm_rp_da.choice_flag == 2) //lmsi + buf_len = add_tlv("1-1",LMSI_LEN,ptr->sm_rp_da.choice.lmsi,0x80,&asn_buf); + else if (ptr->sm_rp_da.choice_flag == 3) //sc_add + { + len = ptr->sm_rp_da.choice.sc_add[0]; + buf_len = add_tlv("4-1",len,ptr->sm_rp_da.choice.sc_add+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-1",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_mofwdsmarg:loss sm_rp_da"); + return RER; + } + if (flag & 0x02) //sm_rp_oa + { + if (ptr->sm_rp_oa.choice_flag == 1) //msisdn + { + len = ptr->sm_rp_oa.choice.msisdn[0]; + buf_len = add_tlv("2-2",len,ptr->sm_rp_oa.choice.msisdn+1,0x80,&asn_buf); + } + else if (ptr->sm_rp_oa.choice_flag == 2)//sc_add + { + len = ptr->sm_rp_oa.choice.sc_add[0]; + buf_len = add_tlv("4-2",len,ptr->sm_rp_oa.choice.sc_add+1,0x80,&asn_buf); + } + else + buf_len = add_null("5-2",0x80,&asn_buf); + } + else + { + mapp_log_debug("MAPP--assign_mofwdsmarg:loss sm_rp_oa"); + return RER; + } + if (flag & 0x04) //sm_rp_ui + { + len = ptr->sm_rp_ui.siginfo_len; + buf_len = add_tlv("4-3",len,ptr->sm_rp_ui.signal_info,0x00,&asn_buf); + } + else + return RER; + if ((flag & 0x08) && ((MAPVer==3)||(MAPVer==2))) //moremsg_flag,only MAP V3 support this + buf_len = add_null("5-4",0x00,&asn_buf); + return buf_len; +} + +int extract_mtfwdsmarg(struct MapMTFSM_Arg *ptr,u32 buf_len,u8 *buf,u8 MAPVer) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_mofwdsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); //imsi + if(len == IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) + { + ptr->sm_rp_da.choice_flag = 1; + memcpy(ptr->sm_rp_da.choice.imsi,temp_buf,IMSI_LEN); + } + else + { + if((len=get_tlv("1",temp_buf,&asn_buf)) == LMSI_LEN)//lmsi + { + ptr->sm_rp_da.choice_flag = 2; + memcpy(ptr->sm_rp_da.choice.lmsi,temp_buf,LMSI_LEN); + } + else + { + if((len=get_tlv("4-1",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->sm_rp_da.choice_flag = 3; + ptr->sm_rp_da.choice.sc_add[0] = len; + memcpy(ptr->sm_rp_da.choice.sc_add+1,temp_buf,len); + } + else + { + if (get_tlv("5-1",temp_buf,&asn_buf) != -1) // no SM-RP-DA + { + ptr->sm_rp_da.choice_flag = 4; + ptr->sm_rp_da.choice.no_rpda = 1; + } + else + return RER; + } + } + } + ptr->param_flag |= 0x01; + if ((len=get_tlv("2",temp_buf,&asn_buf)) > 0) //msisdn + { + ptr->sm_rp_oa.choice_flag = 1; + ptr->sm_rp_oa.choice.msisdn[0] = len; + memcpy(ptr->sm_rp_oa.choice.msisdn+1,temp_buf,len); + } + else + { + if ((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0) //sc_add + { + ptr->sm_rp_oa.choice_flag = 2; + ptr->sm_rp_oa.choice.sc_add[0] = len; + memcpy(ptr->sm_rp_oa.choice.sc_add+1,temp_buf,len); + } + else + { + if (get_tlv("5-2",temp_buf,&asn_buf) != -1) // no SM-RP-OA + { + ptr->sm_rp_oa.choice_flag = 3; + ptr->sm_rp_oa.choice.no_rpoa = 1; + } + else + return RER; + } + } + ptr->param_flag |= 0x02; + if((len=get_tlv("4-3",temp_buf,&asn_buf)) != -1) + { + ptr->param_flag |= 0x04; + ptr->sm_rp_ui.siginfo_len = len; + memcpy(ptr->sm_rp_ui.signal_info,temp_buf,len); + } + if (get_tlv("5-4",temp_buf,&asn_buf) != -1) + ptr->param_flag |= 0x08; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding MT forward SM response */ +/* ++++++++++++++++++++++++++++++++++++++++ */ +int assign_mtfwdsmres(struct MapMTFSM_Res *ptr,u8 *buf,u8 MAPVer) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) // sm-rp-ui + { + len = ptr->sm_rp_ui.siginfo_len; + buf_len = add_tlv("4",len,ptr->sm_rp_ui.signal_info,0x00,&asn_buf); + } + return buf_len; +} + +int extract_mtfwdsmres(struct MapMTFSM_Res *ptr,u32 buf_len,u8 *buf,u8 MAPVer) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("4",temp_buf,&asn_buf)) > 0) + { + ptr->param_flag |= 0x01; + ptr->sm_rp_ui.siginfo_len = len; + memcpy(ptr->sm_rp_ui.signal_info,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding report SM Delivery Status argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_repsmdelstatarg(struct MapRSMDS_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //msisdn + buf_len = add_tlv("4-1",ptr->msisdn[0],ptr->msisdn+1,0x00,&asn_buf); + else + { + mapp_log_debug("MAPP--assign_reportSM_DeliveryStatus_arg:loss msisdn"); + return RER; + } + if (flag & 0x02) //sc_add + buf_len = add_tlv("4-2",ptr->sc_add[0],ptr->sc_add+1,0x00,&asn_buf); + else + { + mapp_log_debug("MAPP--assign_reportSM_DeliveryStatus_arg:loss sc_add"); + return RER; + } + if (flag & 0x04) //sm_deliout + { + temp_buf[0] = ptr->sm_deliout; + buf_len = add_tlv("10-3",1,temp_buf,0x00,&asn_buf); + } + else + return RER; + tag1 = 4; + if (flag & 0x08) // absent subscriber diagnostic sm + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,1,&ptr->abssubdiagsm,0x80,&asn_buf); + } + if (flag & 0x10) // gprs support indicator + { + sprintf(tlv1,"2-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x20) // delivery outcome indicator + { + sprintf(tlv1,"3-%d",tag1++); + buf_len = add_null(tlv1,0x80,&asn_buf); + } + if (flag & 0x40) // additional sm delivery outcome + { + sprintf(tlv1,"4-%d",tag1++); + temp_buf[0] = ptr->addsm_deliout; + buf_len = add_tlv(tlv1,1,temp_buf,0x80,&asn_buf); + } + if (flag & 0x80) // additional absent subscriber diagnostic sm + { + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,1,&ptr->add_abssubdiagsm,0x80,&asn_buf); + } + return buf_len; +} + +int extract_repsmdelstatarg(struct MapRSMDS_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + u8 tag1; + u8 tlv1[32]; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_repsmdelstatarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("4-1",temp_buf,&asn_buf)) > 0)//msisdn + { + ptr->param_flag |= 0x01; + ptr->msisdn[0] = len; + memcpy(ptr->msisdn+1,temp_buf,len); + } + else + return RER; + if((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->param_flag |= 0x02; + ptr->sc_add[0] = len; + memcpy(ptr->sc_add+1,temp_buf,len); + } + else + return RER; + if(get_tlv("10",temp_buf,&asn_buf) > 0) //sm_deliout + { + ptr->param_flag |= 0x04; + ptr->sm_deliout = temp_buf[0]; + } + else + return RER; + tag1 = 4; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // absent subscriber diagnostic sm + { + ptr->param_flag |= 0x08; + ptr->abssubdiagsm = temp_buf[0]; + tag1 ++; + } + if (get_tlv("2",temp_buf,&asn_buf) != -1) // gprs support indicator + { + ptr->param_flag |= 0x10; + ptr->gprssup_flag = 1; + tag1 ++; + } + if (get_tlv("3",temp_buf,&asn_buf) != -1) // delivery outcome indicator + { + ptr->param_flag |= 0x20; + ptr->deliout_flag = 1; + tag1 ++; + } + sprintf(tlv1,"4-%d",tag1); + if (get_tlv(tlv1,temp_buf,&asn_buf) != -1) // additional sm delivery outcome + { + ptr->param_flag |= 0x40; + ptr->addsm_deliout = temp_buf[0]; + } + if (get_tlv("5",temp_buf,&asn_buf) != -1) // additional absent subscriber diagnostic sm + { + ptr->param_flag |= 0x80; + ptr->add_abssubdiagsm = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding report SM Delivery Status response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_repsmdelstatres(struct MapRSMDS_Res *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) //stored_msisdn + buf_len = add_tlv("4",ptr->stored_msisdn[0],ptr->stored_msisdn+1,0x00,&asn_buf); + return buf_len; +} + +int extract_repsmdelstatres(struct MapRSMDS_Res *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("4",temp_buf,&asn_buf)) > 0)//stored_msisdn + { + ptr->param_flag |= 0x01; + ptr->stored_msisdn[0] = len; + memcpy(ptr->stored_msisdn+1,temp_buf,len); + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding inform service Center argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_infsrvcentarg(struct MapISC_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 len; + u8 temp_buf[16],temp_data[16]; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) //stored_msisdn + buf_len = add_tlv("4-1",ptr->stored_msisdn[0],ptr->stored_msisdn+1,0x00,&asn_buf); + if (ptr->param_flag & 0x02) //mw_status + { + temp_data[0] = ptr->mw_status; + len = bytestrtobitstr(temp_buf,temp_data,6); + buf_len = add_tlv("3-2",len,temp_buf,0x00,&asn_buf); + } + return buf_len; +} + +int extract_infsrvcentarg(struct MapISC_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256],temp_data[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if((len=get_tlv("4",temp_buf,&asn_buf)) > 0)//stored_msisdn + { + ptr->param_flag |= 0x01; + ptr->stored_msisdn[0] = len; + memcpy(ptr->stored_msisdn+1,temp_buf,len); + } + if ((len = get_tlv("3",temp_buf,&asn_buf)) > 0)//mw_status + { + ptr->param_flag |= 0x02; + bitstrtobytestr(temp_data,temp_buf,len); + ptr->mw_status = temp_data[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding alert service Center argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_altsrvcentarg(struct MapASC_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ptr->param_flag & 0x01) //msisdn + buf_len = add_tlv("4-1",ptr->msisdn[0],ptr->msisdn+1,0x00,&asn_buf); + else + return RER; + if (ptr->param_flag & 0x02) //service center address + buf_len = add_tlv("4-2",ptr->sc_add[0],ptr->sc_add+1,0x00,&asn_buf); + else + return RER; + return buf_len; +} + +int extract_altsrvcentarg(struct MapASC_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_altsrvcentarg buf_len=0"); + return RER; + } + if(asn_decode_v3(buf,buf_len,&decErr,&asn_buf)==-1) + return RER; + if((len=get_tlv("4-1",temp_buf,&asn_buf)) > 0)//msisdn + { + ptr->param_flag |= 0x01; + ptr->msisdn[0] = len; + memcpy(ptr->msisdn+1,temp_buf,len); + } + else + return RER; + if((len=get_tlv("4-2",temp_buf,&asn_buf)) > 0)//sc_add + { + ptr->param_flag |= 0x02; + ptr->sc_add[0] = len; + memcpy(ptr->sc_add+1,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding ready For SM argument */ +/* +++++++++++++++++++++++++++++++++++++++ */ +int assign_rdyforsmarg(struct MapRFSM_Arg *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + u8 temp_buf[256]; + + flag = ptr->param_flag; + asn_encode(buf,&asn_buf); + if (flag & 0x01) //imsi + buf_len = add_tlv("0",IMSI_LEN,ptr->imsi,0x80,&asn_buf); + else + return RER; + if (flag & 0x02) //alert_reason + { + temp_buf[0] = ptr->alert_reason; + buf_len = add_tlv("10",1,temp_buf,0x00,&asn_buf); + } + else + return RER; + if (flag & 0x04) // alert reason indicator + buf_len = add_null("5",0x00,&asn_buf); + return buf_len; +} + +int extract_rdyforsmarg(struct MapRFSM_Arg *ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + int len; + + ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_rdyforsmarg buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if(len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0)//imsi + { + ptr->param_flag |= 0x01; + memcpy(ptr->imsi,temp_buf,len); + } + else + return RER; + if((len=get_tlv("10",temp_buf,&asn_buf)) >0)//alert_reason + { + ptr->param_flag |= 0x02; + ptr->alert_reason = temp_buf[0]; + } + else + return RER; + if (get_tlv("5",temp_buf,&asn_buf) != -1) // alert reason indicator + { + ptr->param_flag |= 0x04; + ptr->altreason_flag = 1; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding ready For SM response */ +/* +++++++++++++++++++++++++++++++++++++++ */ +int assign_rdyforsmres(struct MapRFSM_Res *ptr,u8 *buf) +{ + return 0; +} + +int extract_rdyforsmres(struct MapRFSM_Res *ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_code_ss.c b/omc/plat/xapp/src/mapp/map_code_ss.c new file mode 100644 index 0000000..b986fa9 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_code_ss.c @@ -0,0 +1,1647 @@ +/* mapp coding supplementary service c file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* ----------------------------------------- */ + +#include "map_includes.h" + +int assign_fwdfeat(struct FwdFeat_struct *fwd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + u32 flag1; + int buf_len=0; + int temp_len; + char temp_buf[256]; + + asn_encode(buf,&asn_buf); + buf_len = add_null("16",0x20,&asn_buf); + flag1 = fwd_ptr->param_flag; + if (flag1 & 0x01) // bs code + { + if (fwd_ptr->bs_code.param_flag == 1) + { + temp_len = tele_bittostr(fwd_ptr->bs_code.tele_code,temp_buf,1); + buf_len = add_tlv("16.3",temp_len,temp_buf,0x80,&asn_buf); + } + else if (fwd_ptr->bs_code.param_flag == 2) + { + temp_len = bearer_bittostr(fwd_ptr->bs_code.bearer_code,temp_buf,1); + buf_len = add_tlv("16.2",temp_len,temp_buf,0x80,&asn_buf); + } + } + else + { + temp_buf[0] = 0x10; + buf_len = add_tlv("16.3",1,temp_buf,0x80,&asn_buf); + } + + if (flag1 & 0x02) //ss status + buf_len = add_tlv("16.4",1,&fwd_ptr->ss_status,0x80,&asn_buf); + if (flag1 & 0x04) //fwdto_num + buf_len = add_tlv("16.5",fwd_ptr->fwdto_num[0],fwd_ptr->fwdto_num+1,0x80,&asn_buf); + /** + if (flag1 & 0x08) //fwdto sub addr + { + sprintf(tlv5,"%s.8-%d",tlv4,tag5++); + buf_len = add_tlv(tlv5,ISDNSUB_LEN,fwd_ptr->fwdto_subadd,0x80,&asn_buf); + } + **/ + if (flag1 & 0x08) //fwd opt + buf_len = add_tlv("16.6",1,&fwd_ptr->fwd_option,0x80,&asn_buf); + if (flag1 & 0x10) //norc time + buf_len = add_tlv("16.7",1,&fwd_ptr->norc_time,0x80,&asn_buf); + return buf_len; +} + +int extract_fwdfeat(struct FwdFeat_struct *fwd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + fwd_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("16.2",temp_buf,&asn_buf); + if (len != -1) // bearer code + { + fwd_ptr->param_flag |= 0x01; // bs code + fwd_ptr->bs_code.param_flag = 2; // bearer + fwd_ptr->bs_code.bearer_code = bearer_strtobit(temp_buf,len); + } + len = get_tlv("16.3",temp_buf,&asn_buf); + if (len != -1) // tele code + { + fwd_ptr->param_flag |= 0x01; // bs code + fwd_ptr->bs_code.param_flag = 1;// tele + fwd_ptr->bs_code.tele_code = tele_strtobit(temp_buf,len); + } + if (get_tlv("16.4",temp_buf,&asn_buf) == 1) // ss status + { + fwd_ptr->param_flag |= 0x02; // ss status + fwd_ptr->ss_status = temp_buf[0]; + } + len = get_tlv("16.5",temp_buf,&asn_buf); + if (len != -1 && len <= ISDN_LEN) + { + fwd_ptr->param_flag |= 0x04; // fwd to num + fwd_ptr->fwdto_num[0]=len; + memcpy(fwd_ptr->fwdto_num+1,temp_buf,len); + } + /** + len = get_tlv("8",temp_buf,&asn_buf); + if (len >= 1) + { + fwd_ptr->param_flag |= 0x08; // fwd to sub addr + memcpy(fwd_ptr->fwdto_subadd,temp_buf,len); + } + **/ + if (get_tlv("16.6",temp_buf,&asn_buf) == 1) // forward option + { + fwd_ptr->param_flag |= 0x08; // fwd opt + fwd_ptr->fwd_option = temp_buf[0]; + } + if (get_tlv("16.7",temp_buf,&asn_buf) == 1) // no reply condition time + { + fwd_ptr->param_flag |= 0x10; // norc time + fwd_ptr->norc_time = temp_buf[0]; + } + return ROK; +} + +int assign_ssforbscode(struct SsForBsCode_struct *BSptr, u8 *buf) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + int temp_len; + char temp_buf[256]; + + asn_encode(buf,&asn_buf); + flag = BSptr->param_flag; + if (flag & 0x01) + buf_len = add_tlv("4-1",1,&BSptr->ss_code,0x00,&asn_buf); + else + { + mapp_log_debug("MAPP--encode_ss_for_bs_code has not ss_code"); + return RER; + } + if (flag & 0x02) + { + if (BSptr->bs_code.param_flag == 2) //bearer code + { + temp_len = bearer_bittostr(BSptr->bs_code.bearer_code,temp_buf,1); + buf_len = add_tlv("2-2",temp_len,temp_buf,0x80,&asn_buf); + } + else if (BSptr->bs_code.param_flag == 1) + { + temp_len = tele_bittostr(BSptr->bs_code.tele_code,temp_buf,1); + buf_len = add_tlv("3-2",temp_len,temp_buf,0x80,&asn_buf); + } + } + return buf_len; +} + +int extract_ssforbscode(struct SsForBsCode_struct *BSptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + BSptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if(get_tlv("4",temp_buf,&asn_buf) == 1) + { + BSptr->param_flag |= 0x01; //ss code + BSptr->ss_code = temp_buf[0]; + } + else + return RER; + if ((len=get_tlv("2",temp_buf,&asn_buf)) != -1) + { + BSptr->param_flag |= 0x02;//bs code + BSptr->bs_code.param_flag = 2;//bearer + BSptr->bs_code.bearer_code = bearer_strtobit(temp_buf,len); + } + else if ((len=get_tlv("3",temp_buf,&asn_buf)) != -1) + { + BSptr->param_flag |= 0x02;//bs code + BSptr->bs_code.param_flag = 1;//tele + BSptr->bs_code.tele_code = tele_strtobit(temp_buf,len); + } + return ROK; +} + +int assign_ssinfo(struct SsInfo_struct *sf_ptr,u8 *buf) +{ + u32 flag1; + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tag2; + char tlv2[32]; + struct FwdInfo_struct *fwd_ptr; + struct SsData_struct *ss_ptr; + struct CBInfo_struct *cbinf_ptr; + + asn_encode(buf,&asn_buf); + if (sf_ptr->choice_flag == 1) //forward info, flag = 1 + { + fwd_ptr = (FwdInfo_struct*) &sf_ptr->choice.fwd_info; + if (fwd_ptr->param_flag & 0x01) // ss code + buf_len = add_tlv("0.4",1,&fwd_ptr->ss_code,0x00,&asn_buf); + if (fwd_ptr->param_flag & 0x02) // forwarding feature list + { + temp_len = assign_fwdfeat(&fwd_ptr->fwd_feat,temp_buf); + buf_len = add_tlv("0.16",temp_len,temp_buf,0x20,&asn_buf); + } + else + return RER; + } + else if (sf_ptr->choice_flag == 2) //call barring info, flag = 2 + { + cbinf_ptr = (CBInfo_struct*)&sf_ptr->choice.cb_info; + if (cbinf_ptr->param_flag & 0x01) // ss code + buf_len = add_tlv("1.4",1,&cbinf_ptr->ss_code,0x00,&asn_buf); + if (cbinf_ptr->param_flag & 0x02) // call barring feature list + { + flag1 = cbinf_ptr->cb_feat.param_flag; + if (flag1 & 0x01) // bs code + { + temp_len = assign_bscode(&cbinf_ptr->cb_feat.bs_code,temp_buf,1); + buf_len = add_null("1.16",0x20,&asn_buf); + buf_len = add_tlv("1.16.16",temp_len,temp_buf,0x20,&asn_buf); + if (flag1 & 0x02) + buf_len = add_tlv("1.16.16.4",1,&cbinf_ptr->cb_feat.ss_status,0x80,&asn_buf); + } + else if (flag1 & 0x02) //ss status + { + buf_len = add_null("1.16",0x20,&asn_buf); + buf_len = add_null("1.16.16",0x20,&asn_buf); + buf_len = add_tlv("1.16.16.4",1,&cbinf_ptr->cb_feat.ss_status,0x80,&asn_buf); + } + } + else + return RER; + } + else if (sf_ptr->choice_flag == 3) //ss data, flag = 3 + { + ss_ptr = (SsData_struct*)&sf_ptr->choice.ss_data; + tag2 = 1; + if (ss_ptr->param_flag & 0x01) //ss-code + { + sprintf(tlv2,"3.4-%d",tag2++); + buf_len = add_tlv(tlv2,1,&ss_ptr->ss_code,0x00,&asn_buf); + } + if (ss_ptr->param_flag & 0x02) //ss-status + { + sprintf(tlv2,"3.4-%d",tag2++); + buf_len = add_tlv(tlv2,1,&ss_ptr->ss_status,0x80,&asn_buf); + } + if (ss_ptr->param_flag & 0x04) //ss-subscriptionOption + { + if (ss_ptr->subs_opt.choice_flag == 1) + { + sprintf(tlv2,"3.2-%d",tag2); + temp_buf[0] = ss_ptr->subs_opt.choice.clires_opt; + buf_len = add_tlv(tlv2,1,temp_buf,0x80,&asn_buf); + } + else if (ss_ptr->subs_opt.choice_flag == 2) + { + sprintf(tlv2,"3.1-%d",tag2); + temp_buf[0] = ss_ptr->subs_opt.choice.over_cate; + buf_len = add_tlv(tlv2,1,temp_buf,0x80,&asn_buf); + } + tag2 ++; + } + if (ss_ptr->param_flag & 0x08) //basicServiceGroupList + { + temp_len = assign_bscode(&ss_ptr->bs_code,temp_buf,1); + sprintf(tlv2,"3.16-%d",tag2++); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x20,&asn_buf); + } + if (ss_ptr->param_flag & 0x10) // default priority + { + sprintf(tlv2,"3.4-%d",tag2); + buf_len = add_tlv(tlv2,1,&ss_ptr->default_prio,0x00,&asn_buf); + } + } + else + return RER; + return buf_len; +} + +int extract_ssinfo(struct SsInfo_struct *sf_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 tag2; + u8 tlv2[32]; + u8 temp_buf[256]; + struct FwdInfo_struct *fwd_ptr; + struct CBInfo_struct *cbinf_ptr; + struct SsData_struct *ss_ptr; + + sf_ptr->choice_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("decode SS info buf_len=0"); + return ROK; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return 0; + if (get_tlv("0",temp_buf,&asn_buf) > 0) //---forwardingInfo + { + sf_ptr->choice_flag = 1; + fwd_ptr = (FwdInfo_struct*) &sf_ptr->choice.fwd_info; + fwd_ptr->param_flag = 0; + fwd_ptr->fwd_feat.param_flag = 0; + if (get_tlv("0.4",temp_buf,&asn_buf) == 1) // ss code + { + fwd_ptr->param_flag |= 0x01; + fwd_ptr->ss_code = temp_buf[0]; + } + len = get_tlv("0.16",temp_buf,&asn_buf); + if (len != -1) // + { + fwd_ptr->param_flag |= 0x02; // fwd feat + if (!extract_fwdfeat(&fwd_ptr->fwd_feat,len,temp_buf)) + return RER; + } + } + else if (get_tlv("1",temp_buf,&asn_buf) > 1) //callBarringInfo + { + sf_ptr->choice_flag = 2; + cbinf_ptr = (CBInfo_struct*)&sf_ptr->choice.cb_info; + cbinf_ptr->param_flag=0; + cbinf_ptr->cb_feat.param_flag = 0; + if (get_tlv("1.4",temp_buf,&asn_buf) == 1) // ss code + { + cbinf_ptr->param_flag |= 0x01; // ss code + cbinf_ptr->ss_code = temp_buf[0]; + } + len = get_tlv("1.16",temp_buf,&asn_buf); // basic code + if (len != -1) + { + cbinf_ptr->param_flag |= 0x02; // call barring info + cbinf_ptr->cb_feat.param_flag |= 0x01; // bs code + extract_bscode(&cbinf_ptr->cb_feat.bs_code,len,temp_buf); + } + if (get_tlv("1.16.4",temp_buf,&asn_buf) == 1) // ss status + { + cbinf_ptr->param_flag |= 0x02; // call barring info + cbinf_ptr->cb_feat.param_flag |= 0x02; // ss status + cbinf_ptr->cb_feat.ss_status = temp_buf[0]; + } + } + else if (get_tlv("3",temp_buf,&asn_buf) > 1) //ss-Data + { + sf_ptr->choice_flag = 3; + ss_ptr = (SsData_struct*) &sf_ptr->choice.ss_data; + ss_ptr->param_flag = 0; + if (get_tlv("3.4-1",temp_buf,&asn_buf) == 1) // ss code + { + ss_ptr->param_flag |= 0x01; // ss code + ss_ptr->ss_code = temp_buf[0]; + } + tag2 = 2; + sprintf(tlv2,"3.4-%d",tag2); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) // ss-status + { + ss_ptr->param_flag |= 0x02; + ss_ptr->ss_status = temp_buf[0]; + tag2 ++; + } + if (get_tlv("3.2",temp_buf,&asn_buf) == 1) // cli restrction option + { + ss_ptr->param_flag |= 0x04; // subs opt + ss_ptr->subs_opt.choice_flag = 1; // clires opt + ss_ptr->subs_opt.choice.clires_opt = temp_buf[0]; + tag2 ++; + } + if (get_tlv("3.1",temp_buf,&asn_buf) == 1) // override category + { + ss_ptr->param_flag |= 0x04; // subs opt + ss_ptr->subs_opt.choice_flag = 2; // clires opt + ss_ptr->subs_opt.choice.over_cate = temp_buf[0]; + tag2 ++; + } + len = get_tlv("3.16",temp_buf,&asn_buf); // basic code + if (len != -1) + { + extract_bscode(&ss_ptr->bs_code,len,temp_buf); + ss_ptr->param_flag |= 0x08; // bs code + tag2 ++; + } + sprintf(tlv2,"3.4-%d",tag2); + if (get_tlv(tlv2,temp_buf,&asn_buf) == 1) // default priority + { + ss_ptr->param_flag |= 0x10; + ss_ptr->default_prio = temp_buf[0]; + tag2 ++; + } + } + else + return RER; + return ROK; +} + +int assign_ussdarg(struct UssdArg_struct *ussd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 tag1; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (ussd_ptr->param_flag & 0x01) // ussd scheme + buf_len = add_tlv("4-1",1,&ussd_ptr->ussd_scheme,0x00,&asn_buf); + else + return RER; + if (ussd_ptr->param_flag & 0x02) // ussd string + { + if (ussd_ptr->ussd_string.string_len > USSD_LEN) + return RER; + buf_len = add_tlv("4-2",ussd_ptr->ussd_string.string_len,ussd_ptr->ussd_string.ussd_data,0x00,&asn_buf); + } + else + return RER; + tag1 = 3; + if (ussd_ptr->param_flag & 0x04) // alert pattern + { + sprintf(tlv1,"4-%d",tag1++); + buf_len = add_tlv(tlv1,1,&ussd_ptr->alt_pattern,0x00,&asn_buf); + } + if (ussd_ptr->param_flag & 0x08) // msisdn + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,ussd_ptr->msisdn[0],ussd_ptr->msisdn+1,0x80,&asn_buf); + } + return buf_len; +} + +int extract_ussdarg(struct UssdArg_struct *ussd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ussd_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4-1",temp_buf,&asn_buf) == 1) // ussd scheme + { + ussd_ptr->param_flag |= 0x01; + ussd_ptr->ussd_scheme = temp_buf[0]; + } + else + return RER; + len = get_tlv("4-2",temp_buf,&asn_buf); // ussd data + if (len > 0 && len <= USSD_LEN) + { + ussd_ptr->param_flag |= 0x02; + ussd_ptr->ussd_string.string_len = len; + memcpy(ussd_ptr->ussd_string.ussd_data,temp_buf,len); + } + else + return RER; + if (get_tlv("4-3",temp_buf,&asn_buf) == 1) // alert pattern + { + ussd_ptr->param_flag |= 0x04; + ussd_ptr->alt_pattern = temp_buf[0]; + } + len = get_tlv("0",temp_buf,&asn_buf); // msisdn + if (len > 0 && len <= ISDN_LEN) + { + ussd_ptr->param_flag |= 0x08; + ussd_ptr->msisdn[0] = len; + memcpy(ussd_ptr->msisdn+1,temp_buf,len); + } + return ROK; +} + +int assign_ussdres(struct UssdRes_struct *ussd_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ussd_ptr->param_flag & 0x01) // ussd scheme + buf_len = add_tlv("4-1",1,&ussd_ptr->ussd_scheme,0x00,&asn_buf); + else + return RER; + if (ussd_ptr->param_flag & 0x02) // ussd string + { + if (ussd_ptr->ussd_string.string_len > USSD_LEN) + return RER; + buf_len = add_tlv("4-2",ussd_ptr->ussd_string.string_len,ussd_ptr->ussd_string.ussd_data,0x00,&asn_buf); + } + else + return RER; + return buf_len; +} + +int extract_ussdres(struct UssdRes_struct *ussd_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + ussd_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4-1",temp_buf,&asn_buf) == 1) // ussd scheme + { + ussd_ptr->param_flag |= 0x01; + ussd_ptr->ussd_scheme = temp_buf[0]; + } + else + return RER; + len = get_tlv("4-2",temp_buf,&asn_buf); // ussd data + if (len > 0 && len <= USSD_LEN) + { + ussd_ptr->param_flag |= 0x02; + ussd_ptr->ussd_string.string_len = len; + memcpy(ussd_ptr->ussd_string.ussd_data,temp_buf,len); + } + else + return RER; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register SS argument */ +/* ++++++++++++++++++++++++++++++++++++++ */ +int assign_regssarg(struct MapRSS_Arg *rss_ptr, u8 *buf) +{ + ASN_BUF asn_buf; + u32 flag; + int buf_len=0; + u8 tag1; + u8 tlv1[32]; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + flag = rss_ptr->param_flag; + if(flag & 0x01) // ss-code + buf_len = add_tlv("4-1",1,&rss_ptr->ss_code,0x00,&asn_buf); + else + { + mapp_log_debug("register SS request lack ss code"); + return RER; + } + tag1 = 2; + if(flag & 0x02) // basic service code + { + if (rss_ptr->bs_code.param_flag & 0x01) + { + sprintf(tlv1,"3-%d",tag1++); + temp_len = tele_bittostr(rss_ptr->bs_code.tele_code,temp_buf,1); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x80,&asn_buf); + } + else if (rss_ptr->bs_code.param_flag & 0x02) + { + sprintf(tlv1,"2-%d",tag1++); + temp_len = bearer_bittostr(rss_ptr->bs_code.bearer_code,temp_buf,1); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x80,&asn_buf); + } + } + if (flag & 0x04) // fwdToNum + { + sprintf(tlv1,"4-%d",tag1++); + temp_len = rss_ptr->fwdto_num[0]; + if(temp_len>ISDN_LEN) temp_len = ISDN_LEN; + buf_len = add_tlv(tlv1,temp_len,rss_ptr->fwdto_num+1,0x80,&asn_buf); + } + /** + if((flag & 0x08) != 0x08) // no fwdToSubAdr + mapp_log_debug("register SS request lack fwdToSubAdr"); + else + { + sprintf(tlv1,"6-%d",tag1++); + len = rss_ptr->fwdto_subadd[0]; + buf_len = add_tlv(tlv1,len,rss_ptr->fwdto_subadd+1,0x80,&asn_buf); + } +**/ + if (flag & 0x08) // nrc time + { + sprintf(tlv1,"5-%d",tag1++); + buf_len = add_tlv(tlv1,1,&rss_ptr->norc_time,0x80,&asn_buf); + } + if(flag & 0x10) // default prio + { + sprintf(tlv1,"7-%d",tag1++); + buf_len = add_tlv(tlv1,1,&rss_ptr->default_prio,0x80,&asn_buf); + } + return buf_len; +} + +int extract_regssarg(struct MapRSS_Arg *rss_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u32 flag=0; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + rss_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4-1",temp_buf,&asn_buf) == 1) + { + rss_ptr->ss_code = temp_buf[0]; + flag |= 0x01; + } + else + { + mapp_log_debug("extract_regssarg:lack ss_code"); + return RER; + } + tag1 = 2; + if ((len=get_tlv("2",temp_buf,&asn_buf)) != -1) + { + flag |= 0x02; + rss_ptr->bs_code.param_flag = 2; + rss_ptr->bs_code.bearer_code = bearer_strtobit(temp_buf,len); + tag1 ++; + } + if ((len=get_tlv("3",temp_buf,&asn_buf)) != -1) + { + flag |= 0x02; + rss_ptr->bs_code.param_flag = 1; + rss_ptr->bs_code.tele_code =tele_strtobit(temp_buf,len); + tag1 ++; + } + sprintf(tlv1,"4-%d",tag1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len >= 1) + { + flag |= 0x04; + if(len>ISDN_LEN) len = ISDN_LEN; + rss_ptr->fwdto_num[0] = len; + memcpy(rss_ptr->fwdto_num+1,temp_buf,len); + } + /** + sprintf(tlv1,"6-%d",tag1); + len=get_tlv(tlv1,temp_buf,&asn_buf); + if (len>=1) + { + tag1++; + mapp_log_debug("extract_regssarg: get fwdToSubAddr"); + rss_ptr->fwdto_subadd[0]=len; + memcpy(rss_ptr->fwdto_subadd+1,temp_buf,len); + flag |= 0x08; + } + **/ + if (get_tlv("5",temp_buf,&asn_buf) == 1) + { + rss_ptr->norc_time = temp_buf[0]; + flag |= 0x08; + } + if (get_tlv("7",temp_buf,&asn_buf) == 1) + { + rss_ptr->default_prio = temp_buf[0]; + flag |= 0x10; + } + rss_ptr->param_flag = flag; + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register SS response */ +/* ++++++++++++++++++++++++++++++++++++++ */ +int assign_regssres(struct MapRSS_Res *rss_ptr,u8 *buf) +{ + if (rss_ptr->param_flag & 0x01) + return assign_ssinfo(&rss_ptr->ss_info,buf); + else + return 0; +} + +int extract_regssres(struct MapRSS_Res *rss_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + rss_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + return_value = extract_ssinfo(&rss_ptr->ss_info,buf_len,buf); + if (return_value == ROK) + { + rss_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding erase SS argument */ +/* +++++++++++++++++++++++++++++++++++ */ +int assign_erassarg(struct MapESS_Arg *ess_ptr, u8 *buf) +{ + if (ess_ptr->param_flag & 0x01) + return assign_ssforbscode(&ess_ptr->ss_forbs,buf); + else + return RER; +} + +int extract_erassarg(struct MapESS_Arg *ess_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + ess_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + return_value = extract_ssforbscode(&ess_ptr->ss_forbs,buf_len,buf); + if (return_value == ROK) + { + ess_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding erase SS response */ +/* +++++++++++++++++++++++++++++++++++ */ +int assign_erassres(MapESS_Res *essr_ptr, u8 *buf) +{ + if (essr_ptr->param_flag & 0x01) + return assign_ssinfo(&essr_ptr->ss_info,buf); + else + return 0; +} + +int extract_erassres(struct MapESS_Res *essr_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + essr_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + return_value = extract_ssinfo(&essr_ptr->ss_info,buf_len,buf); + if (return_value == ROK) + { + essr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding active SS argument */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_actssarg(MapASS_Arg *ass_ptr, u8 *buf) +{ + if (ass_ptr->param_flag & 0x01) + return assign_ssforbscode(&ass_ptr->ss_forbs,buf); + else + return RER; +} + +int extract_actssarg(struct MapASS_Arg *ass_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + ass_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + return_value = extract_ssforbscode(&ass_ptr->ss_forbs,buf_len,buf); + if(return_value == ROK) + { + ass_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding active SS response */ +/* ++++++++++++++++++++++++++++++++++++ */ +int assign_actssres(MapASS_Res *assr_ptr,u8 *buf) +{ + if (assr_ptr->param_flag & 0x01) + return assign_ssinfo(&assr_ptr->ss_info,buf); + else + return 0; +} + +int extract_actssres(struct MapASS_Res *assr_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + assr_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + return_value = extract_ssinfo(&assr_ptr->ss_info,buf_len,buf); + if(return_value == ROK) + { + assr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding deactive SS argument */ +/* ++++++++++++++++++++++++++++++++++++++ */ +int assign_deactssarg(MapDASS_Arg *dss_ptr,u8 *buf) +{ + if (dss_ptr->param_flag & 0x01) + return assign_ssforbscode(&dss_ptr->ss_forbs,buf); + else + return RER; +} + +int extract_deactssarg(struct MapDASS_Arg *dss_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + dss_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + return_value = extract_ssforbscode(&dss_ptr->ss_forbs,buf_len,buf); + if(return_value == ROK) + { + dss_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding deactive SS response */ +/* ++++++++++++++++++++++++++++++++++++++ */ +int assign_deactssres(MapDASS_Res *dssr_ptr,u8 *buf) +{ + if (dssr_ptr->param_flag & 0x01) + return assign_ssinfo(&dssr_ptr->ss_info,buf); + else + return 0; +} + +int extract_deactssres(struct MapDASS_Res *dssr_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + dssr_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + return_value = extract_ssinfo(&dssr_ptr->ss_info,buf_len,buf); + if(return_value == ROK) + { + dssr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding interrogate SS argument */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_intrssarg(MapINTSS_Arg *intrss_ptr, u8 *buf) +{ + if (intrss_ptr->param_flag & 0x01) + return assign_ssforbscode(&intrss_ptr->ss_forbs,buf); + else + return RER; +} + +int extract_intrssarg(struct MapINTSS_Arg *intr_ptr,u32 buf_len,u8 *buf) +{ + int return_value; + + intr_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + return_value = extract_ssforbscode(&intr_ptr->ss_forbs,buf_len,buf); + if(return_value == ROK) + { + intr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding interrogate SS response */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_intrssres(MapINTSS_Res *intrss_ptr, u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 temp_flag; + int temp_len; + u8 tag1; + u8 tlv1[32]; + u8 temp_buf[256]; + struct GenSerInfo_struct *gen_ptr; + + asn_encode(buf, &asn_buf); + if ((intrss_ptr->param_flag & 0x01) != 0x01) // no result + { + mapp_log_debug("assign_intrssres: lack ss status"); + return RER; + } + temp_flag = intrss_ptr->result.choice_flag; + if (temp_flag == 1) //ss status + buf_len = add_tlv("0",1,&intrss_ptr->result.choice.ss_status,0x80,&asn_buf); + else if (temp_flag == 2) //basic service group list + { + temp_len = assign_bscode(&intrss_ptr->result.choice.bs_code,temp_buf,1); + buf_len = add_tlv("2",temp_len,temp_buf,0x0a0,&asn_buf); + } + else if (temp_flag == 3) // fwd feature list + { + temp_len = assign_fwdfeat(&intrss_ptr->result.choice.fwd_feat,temp_buf); + buf_len = add_tlv("3",temp_len,temp_buf,0x0a0,&asn_buf); + } + else if (temp_flag == 4) // genser_info + { + gen_ptr = (GenSerInfo_struct *) &intrss_ptr->result.choice.genser_info; + if (gen_ptr->param_flag & 0x01) // ss status + buf_len = add_tlv("4.4",1,&gen_ptr->ss_status,0x00,&asn_buf); + tag1 = 2; + if (gen_ptr->param_flag & 0x02) // clires opt + { + temp_buf[0] = gen_ptr->clires_opt; + sprintf(tlv1,"4.10-%d",tag1++); + buf_len = add_tlv(tlv1,1,temp_buf,0x00,&asn_buf); + } + if (gen_ptr->param_flag & 0x04) // max entitled priority + { + sprintf(tlv1,"4.0-%d",tag1++); + buf_len = add_tlv(tlv1,1,&gen_ptr->maxent_prio,0x00,&asn_buf); + } + if (gen_ptr->param_flag & 0x08) // default priority + { + sprintf(tlv1,"4.1-%d",tag1++); + buf_len = add_tlv(tlv1,1,&gen_ptr->default_prio,0x00,&asn_buf); + } + // empty the ccbs feature list + } + else + return RER; + return buf_len; +} + +int extract_intrssres(struct MapINTSS_Res *intrss_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + int choice_flag=0; + + intrss_ptr->param_flag = 0; + intrss_ptr->result.choice_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) + { + intrss_ptr->result.choice.ss_status = temp_buf[0]; + choice_flag = 1; + } + if ((len=get_tlv("2",temp_buf,&asn_buf)) != -1) // basic service + { + if (!extract_bscode(&intrss_ptr->result.choice.bs_code,len,temp_buf)) + return RER; + choice_flag = 2; + } + len = get_tlv("3",temp_buf,&asn_buf); //forwardingFeatureList + if (len > 0)//forwardingFeatureList + { + choice_flag = 3; + if (!extract_fwdfeat(&intrss_ptr->result.choice.fwd_feat,len,temp_buf)) + return RER; + } + if (get_tlv("4",temp_buf,&asn_buf)>0) // generic service info + { + choice_flag = 4; + intrss_ptr->result.choice.genser_info.param_flag = 0; + if (get_tlv("4.4",temp_buf,&asn_buf) == 1) // ss status + { + intrss_ptr->result.choice.genser_info.ss_status = temp_buf[0]; + intrss_ptr->result.choice.genser_info.param_flag |= 0x01; // ss status + } + if (get_tlv("4.10",temp_buf,&asn_buf) == 1) // cli restriction option + { + intrss_ptr->result.choice.genser_info.clires_opt = temp_buf[0]; + intrss_ptr->result.choice.genser_info.param_flag |= 0x02; // cilres opt + } + if (get_tlv("4.0",temp_buf,&asn_buf) == 1) // max entitled priority + { + intrss_ptr->result.choice.genser_info.maxent_prio = temp_buf[0]; + intrss_ptr->result.choice.genser_info.param_flag |= 0x04; + } + if (get_tlv("4.1",temp_buf,&asn_buf) == 1) // default priority + { + intrss_ptr->result.choice.genser_info.default_prio = temp_buf[0]; + intrss_ptr->result.choice.genser_info.param_flag |= 0x08; + } + } + if (choice_flag > 0) + { + intrss_ptr->result.choice_flag = choice_flag; + intrss_ptr->param_flag = 0x01; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding process unstructured SS request argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prcunssreqarg(struct MapPUSSR_Arg *psr_ptr,u8 *buf) +{ + if (psr_ptr->param_flag & 0x01) + return assign_ussdarg(&psr_ptr->ussd_arg,buf); + else + return RER; +} + +int extract_prcunssreqarg(struct MapPUSSR_Arg *psr_ptr,u32 buf_len,u8 *buf) +{ + if (extract_ussdarg(&psr_ptr->ussd_arg,buf_len,buf)) + { + psr_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding process unstructured SS request response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_prcunssreqres(struct MapPUSSR_Res *psr_ptr,u8 *buf) +{ + if (psr_ptr->param_flag & 0x01) + return assign_ussdres(&psr_ptr->ussd_res,buf); + else + return RER; +} + +int extract_prcunssreqres(struct MapPUSSR_Res *psr_ptr,u32 buf_len,u8 *buf) +{ + if (extract_ussdres(&psr_ptr->ussd_res,buf_len,buf)) + { + psr_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding unstructured ss request argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_unssreqarg(struct MapUSSR_Arg *usr_ptr,u8 *buf) +{ + if (usr_ptr->param_flag & 0x01) + return assign_ussdarg(&usr_ptr->ussd_arg,buf); + else + return RER; +} + +int extract_unssreqarg(struct MapUSSR_Arg *usr_ptr,u32 buf_len,u8 *buf) +{ + if (extract_ussdarg(&usr_ptr->ussd_arg,buf_len,buf)) + { + usr_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding unstructured SS request response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_unssreqres(struct MapUSSR_Res *usr_ptr,u8 *buf) +{ + if (usr_ptr->param_flag & 0x01) + return assign_ussdres(&usr_ptr->ussd_res,buf); + else + return 0; +} + +int extract_unssreqres(struct MapUSSR_Res *usr_ptr,u32 buf_len,u8 *buf) +{ + if (buf_len == 0) + return ROK; + if (extract_ussdres(&usr_ptr->ussd_res,buf_len,buf)) + { + usr_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding unstructured ss notify argument */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_unssnotarg(struct MapUSSN_Arg *usn_ptr,u8 *buf) +{ + if (usn_ptr->param_flag & 0x01) + return assign_ussdarg(&usn_ptr->ussd_arg,buf); + else + return RER; +} + +int extract_unssnotarg(struct MapUSSN_Arg *usn_ptr,u32 buf_len,u8 *buf) +{ + if (extract_ussdarg(&usn_ptr->ussd_arg,buf_len,buf)) + { + usn_ptr->param_flag = 0x01; + return ROK; + } + else + return RER; +} + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding unstructured ss notify response */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_unssnotres(struct MapUSSN_Res *usn_ptr,u8 *buf) +{ + return 0; +} + +int extract_unssnotres(struct MapUSSN_Res *usn_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register Password argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_regpswdarg(struct MapRPSS_Arg *rpw_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (rpw_ptr->param_flag & 0x01) + { + buf_len = add_tlv("4",1,&rpw_ptr->ss_code,0x00,&asn_buf); + return buf_len; + } + else + return RER; +} + +int extract_regpswdarg(struct MapRPSS_Arg *rpw_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + rpw_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return 0; + if (get_tlv("4",temp_buf,&asn_buf) == 1) + { + rpw_ptr->ss_code = temp_buf[0]; + rpw_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register Password response */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_regpswdres(struct MapRPSS_Res *rpwr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (rpwr_ptr->param_flag & 0x01) + { + buf_len = add_tlv("18",PASSWD_LEN,rpwr_ptr->passwd,0x00,&asn_buf); + return buf_len; + } + else + return RER; +} + +int extract_regpswdres(struct MapRPSS_Res *rpwr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + rpwr_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return 0; + if (get_tlv("18",temp_buf,&asn_buf) == PASSWD_LEN) + { + memcpy(rpwr_ptr->passwd,temp_buf,PASSWD_LEN); + rpwr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding get Password argument */ +/* +++++++++++++++++++++++++++++++++++++++ */ +int assign_getpswdarg(struct MapGPSS_Arg *gpw_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + char temp_buf[32]; + + asn_encode(buf,&asn_buf); + if (gpw_ptr->param_flag & 0x01) // has not + { + temp_buf[0] = gpw_ptr->gui_info; + buf_len = add_tlv("10",1,temp_buf,0x00,&asn_buf); + return buf_len; + } + else + return RER; +} + +int extract_getpswdarg(struct MapGPSS_Arg *gpw_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + gpw_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("10",temp_buf,&asn_buf) > 0) + { + gpw_ptr->gui_info = temp_buf[0]; + gpw_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding get Password response */ +/* +++++++++++++++++++++++++++++++++++++++ */ +int assign_getpswdres(struct MapGPSS_Res *rpwr_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (rpwr_ptr->param_flag & 0x01) + { + buf_len = add_tlv("18",PASSWD_LEN,rpwr_ptr->passwd,0x00,&asn_buf); + return buf_len; + } + else + return RER; +} + +int extract_getpswdres(struct MapGPSS_Res *rpwr_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + rpwr_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("18",temp_buf,&asn_buf) == PASSWD_LEN) + { + memcpy(rpwr_ptr->passwd,temp_buf,PASSWD_LEN); + rpwr_ptr->param_flag |= 0x01; + return ROK; + } + return RER; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding SS invocation notification argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_ssinvnotarg(struct MapSSIN_Arg *sin_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 ii; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (sin_ptr->param_flag & 0x01) // imsi + buf_len = add_tlv("0",IMSI_LEN,sin_ptr->imsi,0x80,&asn_buf); + else + return RER; + if (sin_ptr->param_flag & 0x02) // msisdn + buf_len = add_tlv("1",sin_ptr->msisdn[0],sin_ptr->msisdn+1,0x80,&asn_buf); + else + return RER; + if (sin_ptr->param_flag & 0x04) // ss event + buf_len = add_tlv("2",1,&sin_ptr->ss_event,0x80,&asn_buf); + else + return RER; + if (sin_ptr->param_flag & 0x08) // ss event specification + { + if (sin_ptr->event.event_len > EVENT_LEN) + return RER; + for (ii = 0;ii < sin_ptr->event.event_len;ii ++) + { + sprintf(tlv1,"3.4-%d",ii+1); + buf_len = add_tlv(tlv1,sin_ptr->event.event_spe[ii][0],sin_ptr->event.event_spe[ii]+1,0x00,&asn_buf); + } + } + return buf_len; +} + +int extract_ssinvnotarg(struct MapSSIN_Arg *sin_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u8 ii; + u8 tlv1[32]; + + sin_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_ss invocation notification buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len==IMSI_LEN && (temp_buf[IMSI_LEN-1]&0xf0) == 0xf0) //get imsi + { + sin_ptr->param_flag |= 0x01; + memcpy(sin_ptr->imsi,temp_buf,IMSI_LEN); + } + else + return RER; + len = get_tlv("1",temp_buf,&asn_buf); // get msisdn + if (len > 0 && len <= ISDN_LEN) + { + sin_ptr->param_flag |= 0x02; + sin_ptr->msisdn[0] = len; + memcpy(sin_ptr->msisdn+1,temp_buf,len); + } + else + return RER; + if (get_tlv("2",temp_buf,&asn_buf) == 1) // ss event + { + sin_ptr->param_flag |= 0x04; + sin_ptr->ss_event = temp_buf[0]; + } + else + return RER; + if (get_tlv("3",temp_buf,&asn_buf) != -1) // ss event specification + { + for (ii = 0;ii < EVENT_LEN;ii ++) + { + sprintf(tlv1,"3.4-%d",ii+1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len > 0 && len <= ISDN_LEN) + { + sin_ptr->param_flag |= 0x08; + sin_ptr->event.event_spe[ii][0] = len; + memcpy(sin_ptr->event.event_spe[ii]+1,temp_buf,len); + } + else + { + sin_ptr->event.event_len = ii; + break; + } + } + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding SS invocation notification response */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_ssinvnotres(struct MapSSIN_Res *sin_ptr,u8 *buf) +{ + return 0; +} + +int extract_ssinvnotres(struct MapSSIN_Res *sin_ptr,u32 buf_len,u8 *buf) +{ + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register CC entity argument */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_regccentarg(struct MapRCCE_Arg *rce_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256],temp_data[256]; + + asn_encode(buf,&asn_buf); + if (rce_ptr->param_flag & 0x01) // ss code + buf_len = add_tlv("0",1,&rce_ptr->ss_code,0x80,&asn_buf); + else + return RER; + if (rce_ptr->param_flag & 0x02) // CCBS data + { + if (rce_ptr->ccbs_data.param_flag & 0x01) // ccbs feature + { + temp_len = assign_ccbsfeat(&rce_ptr->ccbs_data.ccbs_feat,temp_buf); + buf_len = add_tlv("1.0",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + if (rce_ptr->ccbs_data.param_flag & 0x02) // translated B-number + { + temp_len = rce_ptr->ccbs_data.trans_num[0]; + buf_len = add_tlv("1.1",temp_len,rce_ptr->ccbs_data.trans_num+1,0x80,&asn_buf); + } + else + return RER; + if (rce_ptr->ccbs_data.param_flag & 0x04) // service indicator + { + temp_data[0] = rce_ptr->ccbs_data.ser_ind; + temp_len = bytestrtobitstr(temp_buf,temp_data,2); + buf_len = add_tlv("1.2",temp_len,temp_buf,0x80,&asn_buf); + } + if (rce_ptr->ccbs_data.param_flag & 0x08) // call info + { + temp_len = assign_extsiginfo(&rce_ptr->ccbs_data.call_info,temp_buf); + buf_len = add_tlv("1.3",temp_len,temp_buf,0x80,&asn_buf); + } + else + return RER; + if (rce_ptr->ccbs_data.param_flag & 0x10) // network signal info + { + temp_len = assign_extsiginfo(&rce_ptr->ccbs_data.net_info,temp_buf); + buf_len = add_tlv("1.4",temp_len,temp_buf,0x0a0,&asn_buf); + } + else + return RER; + } + return buf_len; +} + +int extract_regccentarg(struct MapRCCE_Arg *rce_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + int temp_len; + u8 temp_buf[256],temp_data[256]; + + rce_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_register CC entity buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // ss code + { + rce_ptr->param_flag |= 0x01; + rce_ptr->ss_code = temp_buf[0]; + } + else + return RER; + if (get_tlv("1",temp_buf,&asn_buf) != -1) // ccbs data + { + rce_ptr->param_flag |= 0x02; + len = get_tlv("1.0",temp_buf,&asn_buf); + if (len != -1) + { + if (!extract_ccbsfeat(&rce_ptr->ccbs_data.ccbs_feat,len,temp_buf)) + return RER; + rce_ptr->ccbs_data.param_flag |= 0x01; + } + else + return RER; + len = get_tlv("1.1",temp_buf,&asn_buf); // translate B-number + if (len > 0 && len <= ISDN_LEN) + { + rce_ptr->ccbs_data.param_flag |= 0x02; + rce_ptr->ccbs_data.trans_num[0] = len; + memcpy(rce_ptr->ccbs_data.trans_num+1,temp_buf,len); + } + else + return RER; + len = get_tlv("1.2",temp_buf,&asn_buf); // service indicator + if (len != -1) + { + rce_ptr->ccbs_data.param_flag |= 0x04; + temp_len = bitstrtobytestr(temp_data,temp_buf,len); + rce_ptr->ccbs_data.ser_ind = bcdtou32(temp_data,temp_len); + } + len = get_tlv("1.3",temp_buf,&asn_buf); + if (len != -1) + { + if (extract_extsiginfo(&rce_ptr->ccbs_data.call_info,len,temp_buf) != RER) + rce_ptr->ccbs_data.param_flag |= 0x08; + } + else + return RER; + len = get_tlv("1.4",temp_buf,&asn_buf); + if (len != -1) + { + if (extract_extsiginfo(&rce_ptr->ccbs_data.net_info,len,temp_buf) != RER) + rce_ptr->ccbs_data.param_flag |= 0x10; + } + else + return RER; + } + return ROK; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding register CC entity response */ +/* +++++++++++++++++++++++++++++++++++++++++++++ */ +int assign_regccentres(struct MapRCCE_Res *rce_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + + asn_encode(buf,&asn_buf); + if (rce_ptr->param_flag & 0x01) // ccbs feature + { + temp_len = assign_ccbsfeat(&rce_ptr->ccbs_feat,temp_buf); + buf_len = add_tlv("0",temp_len,temp_buf,0x0a0,&asn_buf); + } + return buf_len; +} + +int extract_regccentres(struct MapRCCE_Res *rce_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + rce_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + len = get_tlv("0",temp_buf,&asn_buf); + if (len != -1) + { + if (!extract_ccbsfeat(&rce_ptr->ccbs_feat,len,temp_buf)) + return RER; + rce_ptr->param_flag |= 0x01; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding erase CC entity argument */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_eraseccentarg(struct MapECCE_Arg *ece_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ece_ptr->param_flag & 0x01) // ss code + buf_len = add_tlv("0",1,&ece_ptr->ss_code,0x80,&asn_buf); + else + return RER; + if (ece_ptr->param_flag & 0x02) // ccbs index + buf_len = add_tlv("1",1,&ece_ptr->ccbs_index,0x80,&asn_buf); + return buf_len; +} + +int extract_eraseccentarg(struct MapECCE_Arg *ece_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + ece_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_erase CC entity buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // ss code + { + ece_ptr->param_flag |= 0x01; + ece_ptr->ss_code = temp_buf[0]; + } + else + return RER; + if (get_tlv("1",temp_buf,&asn_buf) == 1) // ccbs index + { + ece_ptr->param_flag |= 0x02; + ece_ptr->ccbs_index = temp_buf[0]; + } + return ROK; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* encoding/decoding erase CC entity response */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_eraseccentres(struct MapECCE_Res *ece_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (ece_ptr->param_flag & 0x01) // ss code + buf_len = add_tlv("0",1,&ece_ptr->ss_code,0x80,&asn_buf); + else + return RER; + if (ece_ptr->param_flag & 0x02) // ss status + buf_len = add_tlv("1",1,&ece_ptr->ss_status,0x80,&asn_buf); + return buf_len; +} + +int extract_eraseccentres(struct MapECCE_Res *ece_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + ece_ptr->param_flag = 0; + if (buf_len == 0) + { + mapp_log_debug("MAPP--extract_erase CC entity buf_len=0"); + return RER; + } + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // ss code + { + ece_ptr->param_flag |= 0x01; + ece_ptr->ss_code = temp_buf[0]; + } + else + return RER; + if (get_tlv("1",temp_buf,&asn_buf) == 1) // ss status + { + ece_ptr->param_flag |= 0x02; + ece_ptr->ss_status = temp_buf[0]; + } + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_coding.c b/omc/plat/xapp/src/mapp/map_coding.c new file mode 100644 index 0000000..24bc956 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_coding.c @@ -0,0 +1,1813 @@ +/* MAP Update Location c file */ +/* written by Liu zhiguo 2003-03-04 */ +/* version 2.0 */ +/* -------------------------------- */ + +#include "map_includes.h" +#include "../xap_interfunc.h" +#include "map_code.h" +#include "map_opr_func.h" + +int build_mapparam(struct MapOprSrv_struct *opr_ptr,u8 *buf) // build map service paramter +{ + ASN_BUF asn_buf; + u8 seq_flag=1; + int param_len = 0; + u8 info_str[1024]; + + if (opr_ptr == NULL || buf == NULL) + return RER; + switch (opr_ptr->message_type) + { +/* MAP V1--lw add */ +/* daniel */ + /* + case SendParam://sendParameters + if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_sendParameterres(&opr_ptr->msg_list.sp_res,buf); + break; + */ +/* daniel */ + case SendParam :// send parameters + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 0; + param_len = assign_SendParaArg(&opr_ptr->msg_list.sp_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_SendParaRes(&opr_ptr->msg_list.sp_res,buf); + } + break; + case NoteSubPrnt :// not subscriber present + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 0; + param_len = assign_NotPresentArg(&opr_ptr->msg_list.np_arg,buf); + } + break; + case ProcUnstrctSSData:// process unstructure SS data + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 0; + param_len = assign_ProcessUSSDArg(&opr_ptr->msg_list.pussd_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_ProcessUSSDRes(&opr_ptr->msg_list.pussd_res,buf); + } + break; + case BeginSubAct:// beging subscriber activity + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + param_len = assign_BSAArg(&opr_ptr->msg_list.bsa_arg,buf); + } + break; + case PerformHo :// perform handover + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + param_len = assign_HOArg(&opr_ptr->msg_list.ho_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 1; + param_len = assign_HORes(&opr_ptr->msg_list.ho_res,buf); + } + break; + case PerformSubsHo: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag =1; + param_len = assign_PFSHOArg(&opr_ptr->msg_list.pfsho_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 1; + param_len = assign_PFSHORes(&opr_ptr->msg_list.pfsho_res,buf); + } + break; + case NoteInterHo: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + param_len = assign_NIHOArg(&opr_ptr->msg_list.niho_arg,buf); + } + break; + case TraceSubAct: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + param_len = assign_TSAArg(&opr_ptr->msg_list.tsa_arg,buf); + } + break; + case AlrtSCWithoutRes: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_altsrvcentarg(&opr_ptr->msg_list.asc_arg,buf); + break; + /* + case BeginSubAct: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + return assign_BSAArg(&opr_ptr->msg_list.bsa_arg,buf); + } + break; + */ + case FwdSM : + //case MOFwdSM : + //case MTFwdSM : + /* + if( opr_ptr->version == 1) + { + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 1; + param_len = assign_fwdsmarg(&opr_ptr->msg_list.fsm_arg,buf); + } + } + else + */ + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_mofwdsmarg(&opr_ptr->msg_list.mofsm_arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + param_len = assign_mofwdsmres(&opr_ptr->msg_list.mofsm_res,buf,opr_ptr->version); + if(opr_ptr->version<3) + seq_flag = 0; + } + break; + case MTFwdSM_v3: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_mtfwdsmarg(&opr_ptr->msg_list.mtfsm_arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + param_len = assign_mtfwdsmres(&opr_ptr->msg_list.mtfsm_res,buf,opr_ptr->version); + if(param_len <=0) + { + seq_flag = 0; + /* older version mo fwd doesn't take any parameter */ + } + } + break; +/* MAP V1--lw add */ + // mobile service operation + case UpLoc: + if (opr_ptr->message_flag == MAP_REQUEST) + { + param_len = assign_uplocarg(&opr_ptr->msg_list.ul_arg,buf,opr_ptr->version); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + param_len = assign_uplocres(&opr_ptr->msg_list.ul_res,buf); + } + break; + case CancelLoc: + if (opr_ptr->message_flag == MAP_REQUEST) + { + param_len = assign_cancellocarg(&opr_ptr->msg_list.cl_arg,buf,opr_ptr->version); + if(opr_ptr->version != 3) + seq_flag = 0; + else + seq_flag = 2; + } + else if (opr_ptr->message_flag == MAP_RESPONSE && opr_ptr->version == 3) + param_len = assign_cancellocres(&opr_ptr->msg_list.cl_res,buf); + break; + case PurgeMS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_purgemsarg(&opr_ptr->msg_list.pms_arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_purgemsres(&opr_ptr->msg_list.pms_res,buf); + break; + case SndIdent: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 0; + param_len = assign_sndidentarg(&opr_ptr->msg_list.si_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_sndidentres(&opr_ptr->msg_list.si_res,buf); + break; + case UpGprsLoc: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_upgprslocarg(&opr_ptr->msg_list.ugl_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_upgprslocres(&opr_ptr->msg_list.ugl_res,buf); + break; + case ProvSubInfo: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_prvsubinfoarg(&opr_ptr->msg_list.psi_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_prvsubinfores(&opr_ptr->msg_list.psi_res,buf); + break; + case AnyTimeInter: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_anytimeintarg(&opr_ptr->msg_list.ati_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_anytimeintres(&opr_ptr->msg_list.ati_res,buf); + break; + case PreHo: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_prehoarg(&opr_ptr->msg_list.pho_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_prehores(&opr_ptr->msg_list.pho_res,buf); + break; + case SndEndSig: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_sndendsigarg(&opr_ptr->msg_list.ses_arg,buf); + break; + case ProcAccSig: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_prcaccsigarg(&opr_ptr->msg_list.pas_arg,buf); + break; + case FwdAccSig: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_fwdaccsigarg(&opr_ptr->msg_list.fas_arg,buf); + break; + case PreSubsHo: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_presubshoarg(&opr_ptr->msg_list.psho_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_presubshores(&opr_ptr->msg_list.psho_res,buf); + break; + case SndAuthInfo: + if (opr_ptr->message_flag == MAP_REQUEST) + { + seq_flag = 0; + param_len = assign_sndauthinfoarg(&opr_ptr->msg_list.sai_arg,buf); + } + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_sndauthinfores(&opr_ptr->msg_list.sai_res,buf); + break; + case ChkIMEI: + seq_flag = 0; + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_chkimeiarg(&opr_ptr->msg_list.cimei_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_chkimeires(&opr_ptr->msg_list.cimei_res,buf); + break; + case InsSubData: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_inssubdataarg(&opr_ptr->msg_list.isd_arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_inssubdatares(&opr_ptr->msg_list.isd_res,buf); + break; + case DelSubData: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_delsubdataarg(&opr_ptr->msg_list.dsd_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_delsubdatares(&opr_ptr->msg_list.dsd_res,buf); + break; + case Reset: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_resetarg(&opr_ptr->msg_list.reset_arg,buf); + break; + case RestoreData: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_restdataarg(&opr_ptr->msg_list.rd_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_restdatares(&opr_ptr->msg_list.rd_res,buf); + break; + case SndRoutInfoForGprs: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_sndroutinfogprsarg(&opr_ptr->msg_list.srifg_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_sndroutinfogprsres(&opr_ptr->msg_list.srifg_res,buf); + break; + case FailRep: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_failreportarg(&opr_ptr->msg_list.fr_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_failreportres(&opr_ptr->msg_list.fr_res,buf); + break; + case NoteMsPresForGprs: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_notemspregprsarg(&opr_ptr->msg_list.nmpfg_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_notemspregprsres(&opr_ptr->msg_list.nmpfg_res,buf); + break; + // operation and maintenance operations + case ActvTraceMode: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_acttrcmodearg(&opr_ptr->msg_list.atm_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_acttrcmoderes(&opr_ptr->msg_list.atm_res,buf); + break; + case DeactvTraceMode: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_deacttrcmodearg(&opr_ptr->msg_list.dtm_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_deacttrcmoderes(&opr_ptr->msg_list.dtm_res,buf); + break; + case SndIMSI: + seq_flag = 0; + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_sndimsiarg(&opr_ptr->msg_list.simsi_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_sndimsires(&opr_ptr->msg_list.simsi_res,buf); + break; + // call handling operation + case SndRoutInfo: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_sndroutinfoarg(&opr_ptr->msg_list.sri_arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + param_len = assign_sndroutinfores(&opr_ptr->msg_list.sri_res,buf,opr_ptr->version); + if(opr_ptr->version == 3) + seq_flag = 2; + } + break; + case ProvRoamNum: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_provroamnumarg(&opr_ptr->msg_list.prn_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_provroamnumres(&opr_ptr->msg_list.prn_res,buf); + break; + case ResumeCH: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_rescallhandarg(&opr_ptr->msg_list.rch_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_rescallhandres(&opr_ptr->msg_list.rch_res,buf); + break; + case ProvSIWFSNum: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_prvsiwfsnumarg(&opr_ptr->msg_list.psn_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_prvsiwfsnumres(&opr_ptr->msg_list.psn_res,buf); + break; + case SIWFSSigMdf: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_siwfssigmodarg(&opr_ptr->msg_list.ssm_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_siwfssigmodres(&opr_ptr->msg_list.ssm_res,buf); + break; + case SetRepState: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_setrepstatearg(&opr_ptr->msg_list.srs_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_setrepstateres(&opr_ptr->msg_list.srs_res,buf); + break; + case StatusRep: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_statreparg(&opr_ptr->msg_list.sr_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_statrepres(&opr_ptr->msg_list.sr_res,buf); + break; + case RmtUserFree: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_rmtuserfreearg(&opr_ptr->msg_list.ruf_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_rmtuserfreeres(&opr_ptr->msg_list.ruf_res,buf); + break; + // supplementary service operation + case RegSS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_regssarg(&opr_ptr->msg_list.rss_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_regssres(&opr_ptr->msg_list.rss_res,buf); + } + break; + case EraseSS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_erassarg(&opr_ptr->msg_list.ess_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_erassres(&opr_ptr->msg_list.ess_res,buf); + } + break; + case ActvSS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_actssarg(&opr_ptr->msg_list.ass_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_actssres(&opr_ptr->msg_list.ass_res,buf); + } + break; + case DeactvSS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_deactssarg(&opr_ptr->msg_list.dass_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag=0; + param_len = assign_deactssres(&opr_ptr->msg_list.dass_res,buf); + } + break; + case InterSS: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_intrssarg(&opr_ptr->msg_list.intss_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + { + seq_flag = 0; + param_len = assign_intrssres(&opr_ptr->msg_list.intss_res,buf); + } + break; + case ProcUnstrctSSReq: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_prcunssreqarg(&opr_ptr->msg_list.pussr_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_prcunssreqres(&opr_ptr->msg_list.pussr_res,buf); + break; + case UnstrctSSReq: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_unssreqarg(&opr_ptr->msg_list.ussr_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_unssreqres(&opr_ptr->msg_list.ussr_res,buf); + break; + case UnstrctSSNoti: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_unssnotarg(&opr_ptr->msg_list.ussn_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_unssnotres(&opr_ptr->msg_list.ussn_res,buf); + break; + case RegPasswd: + seq_flag=0; + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_regpswdarg(&opr_ptr->msg_list.rpss_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_regpswdres(&opr_ptr->msg_list.rpss_res,buf); + break; + case GetPasswd: + seq_flag=0; + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_getpswdarg(&opr_ptr->msg_list.gpss_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_getpswdres(&opr_ptr->msg_list.gpss_res,buf); + break; + case SSInvNoti: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_ssinvnotarg(&opr_ptr->msg_list.ssin_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_ssinvnotres(&opr_ptr->msg_list.ssin_res,buf); + break; + case RegCCEntry: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_regccentarg(&opr_ptr->msg_list.rcce_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_regccentres(&opr_ptr->msg_list.rcce_res,buf); + break; + case EraseCCEntry: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_eraseccentarg(&opr_ptr->msg_list.ecce_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_eraseccentres(&opr_ptr->msg_list.ecce_res,buf); + break; + // short message service operation + case SndRoutInfoForSM: + if( opr_ptr->version == 1 ) + { + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_routinfoforsm_v1_arg(&opr_ptr->msg_list.rifsm_v1_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_routinfoforsm_v1_res(&opr_ptr->msg_list.rifsm_v1_res,buf); + } + else + { + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_routinfoforsmarg(&opr_ptr->msg_list.rifsm_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_routinfoforsmres(&opr_ptr->msg_list.rifsm_res,buf); + } + break; + case RptSMDelvStat: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_repsmdelstatarg(&opr_ptr->msg_list.rsmds_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_repsmdelstatres(&opr_ptr->msg_list.rsmds_res,buf); + break; + case AlrtSC: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_altsrvcentarg(&opr_ptr->msg_list.asc_arg,buf); + break; + case InfSC: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_infsrvcentarg(&opr_ptr->msg_list.isc_arg,buf); + break; + case RdyForSM: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_rdyforsmarg(&opr_ptr->msg_list.rfsm_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_rdyforsmres(&opr_ptr->msg_list.rfsm_res,buf); + break; + /*MAP-H (AUC and HLR) */ + case SecuTrip: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_securityTriplets_arg(&opr_ptr->msg_list.st_arg,buf); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_securityTriplets_res(&opr_ptr->msg_list.st_res,buf); + break; + case InterrSubs: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_interrogateSubscriber_arg(&opr_ptr->msg_list.is_arg,buf); + break; + case CreateSubs: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_createSubscriber_arg(&opr_ptr->msg_list.cs_arg,buf); + break; + case DelSubs: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_deleteSubscriber_arg(&opr_ptr->msg_list.ds_arg,buf); + break; + /********** map opr **********/ + case DetermineOprUser: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_MapDetermineOprUserArg(&opr_ptr->msg_list.DetermineOprUser_Arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_MapDetermineOprUserRes(&opr_ptr->msg_list.DetermineOprUser_Res,buf,opr_ptr->version); + break; + case VlrUpdateLocation: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_MapVlrUpdateLocationArg(&opr_ptr->msg_list.VlrUpdateLocation_Arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_MapVlrUpdateLocationRes(&opr_ptr->msg_list.VlrUpdateLocation_Res,buf,opr_ptr->version); + break; + case CreateUserWithMsisdnImsi: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_MapCreateUserWithMsisdnImsiArg(&opr_ptr->msg_list.CreateUserWithMsisdnImsi_Arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_MapCreateUserWithMsisdnImsiRes(&opr_ptr->msg_list.CreateUserWithMsisdnImsi_Res,buf,opr_ptr->version); + break; + case DeleteOprUser: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_MapDeleteOprUserArg(&opr_ptr->msg_list.DeleteOprUser_Arg,buf,opr_ptr->version); + else if (opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_MapDeleteOprUserRes(&opr_ptr->msg_list.DeleteOprUser_Res,buf,opr_ptr->version); + break; + case VlrEnquiryIMDMStatus: + if (opr_ptr->message_flag == MAP_REQUEST) + param_len = assign_MapVlrEnquiryIMDM_Arg(&opr_ptr->msg_list.EnquiryIMDM_Arg,buf,opr_ptr->version); + else if(opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_MapVlrEnquiryIMDM_Res(&opr_ptr->msg_list.EnquiryIMDM_Res,buf,opr_ptr->version); + break; + case RoutingInfoForLCS: + if (opr_ptr->message_flag == MAP_REQUEST) + { + xap_send_error("RoutingInfoForLCS Arg is not support to assign"); + return RER; + } + else if(opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_RoutingInfoForLCS_Res(&opr_ptr->msg_list.routingInfoForLCS_Res,buf,opr_ptr->version); + break; + case ProvideSubscriberLocation: + if (opr_ptr->message_flag == MAP_REQUEST) + { + xap_send_error("ProvideSubscriberLocation Arg is not support to assign"); + return RER; + } + else if(opr_ptr->message_flag == MAP_RESPONSE) + param_len = assign_ProvideSubscriberLocation_Res(&opr_ptr->msg_list.provideSubscriberLocation_Res,buf,opr_ptr->version); + break; + /********* map opr **********/ + default: // unknown operation + xap_send_error("MAPP error:the operation is unknown:%d",opr_ptr->message_type); + return RER; + } + +// if(param_len <= 0) + if(param_len < 0) + return 0; + + switch(seq_flag) + { + case 0: + break; + case 1: + memcpy(info_str,buf,param_len%1024); + asn_encode(buf,&asn_buf); + param_len = add_tlv("16",param_len,info_str,0x20,&asn_buf); + break; + case 2: + memcpy(info_str,buf,param_len%1024); + asn_encode(buf,&asn_buf); + param_len = add_tlv("3",param_len,info_str,0xA0,&asn_buf); + break; + } + //Bcd2Str_Space(info_str, buf, param_len); + //printf("\r\nassign code :[%d] len :[%d]\r\n%s\r\n",opr_ptr->message_type,param_len,info_str); + return param_len; +} + +u8 extract_mapparam(struct MapOprSrv_struct *opr_ptr,u8 opr_code,u8 opr_flag,u32 pre_param_len,u8 *pre_param) +{ + ASN_BUF asn_buf; + u8 param[1024]; + int param_len; + //char info_str[1024]; + + asn_decode(pre_param,1,&asn_buf); + //Bcd2Str_Space(info_str, pre_param, pre_param_len); + //printf("\r\nextract code :[%d] len :[%ld]\r\n%s\r\n",opr_code,pre_param_len,info_str); + if(opr_ptr->version == 3 && ( + (opr_code == SndRoutInfo && opr_flag == MAP_CONFIRM) || + (opr_code == CancelLoc && opr_flag == MAP_INDICATE) || + (opr_code == PurgeMS && opr_flag == MAP_INDICATE))) + { + param_len = get_tlv("3",param,&asn_buf); + } + else if( !( opr_code == SendParam && opr_flag == MAP_CONFIRM )) + { + param_len = get_tlv("16",param,&asn_buf); + } + if (param_len == -1 || (opr_code == SendParam && opr_flag == MAP_CONFIRM) ) // not has sequence id + { + param_len = pre_param_len; + memcpy(param,pre_param,param_len); + } + + switch (opr_code) + { +/* ------------->>>>>>>>>>>>>. MAP V1 <<<<<<<<<<<<<<<<<--------------------*/ +/* daniel */ + /* + case SendParam: + if (opr_flag == MAP_INDICATE) + return extract_sendParameterArg(&opr_ptr->msg_list.sp_arg,param_len,param,opr_ptr->dialogue_id); + break; + */ +/* daniel */ + case SendParam :// send parameters + if (opr_flag == MAP_INDICATE) + return extract_SendParaArg(&opr_ptr->msg_list.sp_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_SendParaRes(&opr_ptr->msg_list.sp_res,param_len,param); + break; + case NoteSubPrnt :// not subscriber present + if (opr_flag == MAP_INDICATE) + return extract_NotPresentArg(&opr_ptr->msg_list.np_arg,param_len,param); + break; + case ProcUnstrctSSData:// process unstructure SS data + if (opr_flag == MAP_INDICATE) + return extract_ProcessUSSDArg(&opr_ptr->msg_list.pussd_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_ProcessUSSDRes(&opr_ptr->msg_list.pussd_res,param_len,param); + break; + case BeginSubAct:// beging subscriber activity + if (opr_flag == MAP_INDICATE) + return extract_BSAArg(&opr_ptr->msg_list.bsa_arg,param_len,param); + break; + case PerformHo :// perform handover + if (opr_flag == MAP_INDICATE) + return extract_HOArg(&opr_ptr->msg_list.ho_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_HORes(&opr_ptr->msg_list.ho_res,param_len,param); + break; + case PerformSubsHo: + if (opr_flag == MAP_INDICATE) + return extract_PFSHOArg(&opr_ptr->msg_list.pfsho_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_PFSHORes(&opr_ptr->msg_list.pfsho_res,param_len,param); + break; + case NoteInterHo: + if (opr_flag == MAP_INDICATE) + return extract_NIHOArg(&opr_ptr->msg_list.niho_arg,param_len,param); + break; + case TraceSubAct: + if (opr_flag == MAP_INDICATE) + return extract_TSAArg(&opr_ptr->msg_list.tsa_arg,param_len,param); + break; + case AlrtSCWithoutRes: + if (opr_flag == MAP_INDICATE) + return extract_altsrvcentarg(&opr_ptr->msg_list.asc_arg,param_len,param); + break; + /* + case BeginSubAct: + if (opr_flag == MAP_INDICATE) + return extract_BSAArg(&opr_ptr->msg_list.bsa_arg,param_len,param); + break; + */ +/* ------------->>>>>>>>>>>>>. MAP V1 <<<<<<<<<<<<<<<<<--------------------*/ + case UpLoc: + if (opr_flag == MAP_INDICATE) + return extract_uplocarg(&opr_ptr->msg_list.ul_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + return extract_uplocres(&opr_ptr->msg_list.ul_res,param_len,param); + break; + case CancelLoc: + if (opr_flag == MAP_INDICATE) + return extract_cancellocarg(&opr_ptr->msg_list.cl_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + return extract_cancellocres(&opr_ptr->msg_list.cl_res,param_len,param); + break; + case PurgeMS: + if (opr_flag == MAP_INDICATE) + return extract_purgemsarg(&opr_ptr->msg_list.pms_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + return extract_purgemsres(&opr_ptr->msg_list.pms_res,param_len,param); + break; + case SndIdent: + if (opr_flag == MAP_INDICATE) + return extract_sndidentarg(&opr_ptr->msg_list.si_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_sndidentres(&opr_ptr->msg_list.si_res,param_len,param); + break; + case UpGprsLoc: + if (opr_flag == MAP_INDICATE) + return extract_upgprslocarg(&opr_ptr->msg_list.ugl_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_upgprslocres(&opr_ptr->msg_list.ugl_res,param_len,param); + break; + case ProvSubInfo: + if (opr_flag == MAP_INDICATE) + return extract_prvsubinfoarg(&opr_ptr->msg_list.psi_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_prvsubinfores(&opr_ptr->msg_list.psi_res,param_len,param); + break; + case AnyTimeInter: + if (opr_flag == MAP_INDICATE) + return extract_anytimeintarg(&opr_ptr->msg_list.ati_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_anytimeintres(&opr_ptr->msg_list.ati_res,param_len,param); + break; + case PreHo: + if (opr_flag == MAP_INDICATE) + return extract_prehoarg(&opr_ptr->msg_list.pho_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_prehores(&opr_ptr->msg_list.pho_res,param_len,param); + break; + case SndEndSig: + if (opr_flag == MAP_INDICATE) + return extract_sndendsigarg(&opr_ptr->msg_list.ses_arg,param_len,param); + break; + case ProcAccSig: + if (opr_flag == MAP_INDICATE) + return extract_prcaccsigarg(&opr_ptr->msg_list.pas_arg,param_len,param); + break; + case FwdAccSig: + if (opr_flag == MAP_INDICATE) + return extract_fwdaccsigarg(&opr_ptr->msg_list.fas_arg,param_len,param); + break; + case PreSubsHo: + if (opr_flag == MAP_INDICATE) + return extract_presubshoarg(&opr_ptr->msg_list.psho_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_presubshores(&opr_ptr->msg_list.psho_res,param_len,param); + break; + case SndAuthInfo: + if (opr_flag == MAP_INDICATE) + return extract_sndauthinfoarg(&opr_ptr->msg_list.sai_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_sndauthinfores(&opr_ptr->msg_list.sai_res,param_len,param); + break; + case ChkIMEI: + if (opr_flag == MAP_INDICATE) + return extract_chkimeiarg(&opr_ptr->msg_list.cimei_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_chkimeires(&opr_ptr->msg_list.cimei_res,param_len,param); + break; + case InsSubData: + if (opr_flag == MAP_INDICATE) + return extract_inssubdataarg(&opr_ptr->msg_list.isd_arg,param_len,param); + if (opr_flag == MAP_CONFIRM) + return extract_inssubdatares(&opr_ptr->msg_list.isd_res,param_len,param); + break; + case DelSubData: + if (opr_flag == MAP_INDICATE) + return extract_delsubdataarg(&opr_ptr->msg_list.dsd_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_delsubdatares(&opr_ptr->msg_list.dsd_res,param_len,param); + break; + case Reset: + if (opr_flag == MAP_INDICATE) + return extract_resetarg(&opr_ptr->msg_list.reset_arg,param_len,param); + break; + case RestoreData: + if (opr_flag == MAP_INDICATE) + return extract_restdataarg(&opr_ptr->msg_list.rd_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_restdatares(&opr_ptr->msg_list.rd_res,param_len,param); + break; + case SndRoutInfoForGprs: + if (opr_flag == MAP_INDICATE) + return extract_sndroutinfogprsarg(&opr_ptr->msg_list.srifg_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_sndroutinfogprsres(&opr_ptr->msg_list.srifg_res,param_len,param); + break; + case FailRep: + if (opr_flag == MAP_INDICATE) + return extract_failreportarg(&opr_ptr->msg_list.fr_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_failreportres(&opr_ptr->msg_list.fr_res,param_len,param); + break; + case NoteMsPresForGprs: + if (opr_flag == MAP_INDICATE) + return extract_notemspregprsarg(&opr_ptr->msg_list.nmpfg_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_notemspregprsres(&opr_ptr->msg_list.nmpfg_res,param_len,param); + break; + case ActvTraceMode: + if (opr_flag == MAP_INDICATE) + return extract_acttrcmodearg(&opr_ptr->msg_list.atm_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_acttrcmoderes(&opr_ptr->msg_list.atm_res,param_len,param); + break; + case DeactvTraceMode: + if (opr_flag == MAP_INDICATE) + return extract_deacttrcmodearg(&opr_ptr->msg_list.dtm_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_deacttrcmoderes(&opr_ptr->msg_list.dtm_res,param_len,param); + break; + case SndIMSI: + if (opr_flag == MAP_INDICATE) + return extract_sndimsiarg(&opr_ptr->msg_list.simsi_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_sndimsires(&opr_ptr->msg_list.simsi_res,param_len,param); + break; + case SndRoutInfo: + if (opr_flag == MAP_INDICATE) + return extract_sndroutinfoarg(&opr_ptr->msg_list.sri_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + return extract_sndroutinfores(&opr_ptr->msg_list.sri_res,param_len,param,opr_ptr->version); + break; + case ProvRoamNum: + if (opr_flag == MAP_INDICATE) + return extract_provroamnumarg(&opr_ptr->msg_list.prn_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_provroamnumres(&opr_ptr->msg_list.prn_res,param_len,param); + break; + case ResumeCH: + if (opr_flag == MAP_INDICATE) + return extract_rescallhandarg(&opr_ptr->msg_list.rch_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_rescallhandres(&opr_ptr->msg_list.rch_res,param_len,param); + break; + case ProvSIWFSNum: + if (opr_flag == MAP_INDICATE) + return extract_prvsiwfsnumarg(&opr_ptr->msg_list.psn_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_prvsiwfsnumres(&opr_ptr->msg_list.psn_res,param_len,param); + break; + case SIWFSSigMdf: + if (opr_flag == MAP_INDICATE) + return extract_siwfssigmodarg(&opr_ptr->msg_list.ssm_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_siwfssigmodres(&opr_ptr->msg_list.ssm_res,param_len,param); + break; + case SetRepState: + if (opr_flag == MAP_INDICATE) + return extract_setrepstatearg(&opr_ptr->msg_list.srs_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_setrepstateres(&opr_ptr->msg_list.srs_res,param_len,param); + break; + case StatusRep: + if (opr_flag == MAP_INDICATE) + return extract_statreparg(&opr_ptr->msg_list.sr_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_statrepres(&opr_ptr->msg_list.sr_res,param_len,param); + break; + case RmtUserFree: + if (opr_flag == MAP_INDICATE) + return extract_rmtuserfreearg(&opr_ptr->msg_list.ruf_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_rmtuserfreeres(&opr_ptr->msg_list.ruf_res,param_len,param); + break; + case RegSS: + if (opr_flag == MAP_INDICATE) + return extract_regssarg(&opr_ptr->msg_list.rss_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_regssres(&opr_ptr->msg_list.rss_res,param_len,param); + break; + case EraseSS: + if (opr_flag == MAP_INDICATE) + return extract_erassarg(&opr_ptr->msg_list.ess_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_erassres(&opr_ptr->msg_list.ess_res,param_len,param); + break; + case ActvSS: + if (opr_flag == MAP_INDICATE) + return extract_actssarg(&opr_ptr->msg_list.ass_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_actssres(&opr_ptr->msg_list.ass_res,param_len,param); + break; + case DeactvSS: + if (opr_flag == MAP_INDICATE) + return extract_deactssarg(&opr_ptr->msg_list.dass_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_deactssres(&opr_ptr->msg_list.dass_res,param_len,param); + break; + case InterSS: + if (opr_flag == MAP_INDICATE) + return extract_intrssarg(&opr_ptr->msg_list.intss_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_intrssres(&opr_ptr->msg_list.intss_res,param_len,param); + break; + case ProcUnstrctSSReq: + if (opr_flag == MAP_INDICATE) + return extract_prcunssreqarg(&opr_ptr->msg_list.pussr_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_prcunssreqres(&opr_ptr->msg_list.pussr_res,param_len,param); + break; + case UnstrctSSReq: + if (opr_flag == MAP_INDICATE) + return extract_unssreqarg(&opr_ptr->msg_list.ussr_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_unssreqres(&opr_ptr->msg_list.ussr_res,param_len,param); + break; + case UnstrctSSNoti: + if (opr_flag == MAP_INDICATE) + return extract_unssnotarg(&opr_ptr->msg_list.ussn_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_unssnotres(&opr_ptr->msg_list.ussn_res,param_len,param); + break; + case RegPasswd: + if (opr_flag == MAP_INDICATE) + return extract_regpswdarg(&opr_ptr->msg_list.rpss_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_regpswdres(&opr_ptr->msg_list.rpss_res,param_len,param); + break; + case GetPasswd: + if (opr_flag == MAP_INDICATE) + return extract_getpswdarg(&opr_ptr->msg_list.gpss_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_getpswdres(&opr_ptr->msg_list.gpss_res,param_len,param); + break; + case SSInvNoti: + if (opr_flag == MAP_INDICATE) + return extract_ssinvnotarg(&opr_ptr->msg_list.ssin_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_ssinvnotres(&opr_ptr->msg_list.ssin_res,param_len,param); + break; + case RegCCEntry: + if (opr_flag == MAP_INDICATE) + return extract_regccentarg(&opr_ptr->msg_list.rcce_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_regccentres(&opr_ptr->msg_list.rcce_res,param_len,param); + break; + case EraseCCEntry: + if (opr_flag == MAP_INDICATE) + return extract_eraseccentarg(&opr_ptr->msg_list.ecce_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_eraseccentres(&opr_ptr->msg_list.ecce_res,param_len,param); + break; + case SndRoutInfoForSM: + if( opr_ptr->version == 1) + { + if (opr_flag == MAP_INDICATE) + return extract_routinfoforsm_v1_arg(&opr_ptr->msg_list.rifsm_v1_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_routinfoforsm_v1_res(&opr_ptr->msg_list.rifsm_v1_res,param_len,param); + } + else + { + if (opr_flag == MAP_INDICATE) + return extract_routinfoforsmarg(&opr_ptr->msg_list.rifsm_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_routinfoforsmres(&opr_ptr->msg_list.rifsm_res,param_len,param); + } + break; + case FwdSM: + //case MOFwdSM: + //case MTFwdSM: + if (opr_flag == MAP_INDICATE) + return extract_mofwdsmarg(&opr_ptr->msg_list.mofsm_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + { + if(opr_ptr->version<3) + return ROK; + return extract_mofwdsmres(&opr_ptr->msg_list.mofsm_res,param_len,param); + } + break; + case MTFwdSM_v3: + if (opr_flag == MAP_INDICATE) + return extract_mtfwdsmarg(&opr_ptr->msg_list.mtfsm_arg,param_len,param,opr_ptr->version); + else if (opr_flag == MAP_CONFIRM) + return extract_mtfwdsmres(&opr_ptr->msg_list.mtfsm_res,param_len,param,opr_ptr->version); + break; + case RptSMDelvStat: + if (opr_flag == MAP_INDICATE) + return extract_repsmdelstatarg(&opr_ptr->msg_list.rsmds_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_repsmdelstatres(&opr_ptr->msg_list.rsmds_res,param_len,param); + break; + case AlrtSC: + if (opr_flag == MAP_INDICATE) + return extract_altsrvcentarg(&opr_ptr->msg_list.asc_arg,param_len,param); + break; + case InfSC: + if (opr_flag == MAP_INDICATE) + return extract_infsrvcentarg(&opr_ptr->msg_list.isc_arg,param_len,param); + break; + case RdyForSM: + if (opr_flag == MAP_INDICATE) + return extract_rdyforsmarg(&opr_ptr->msg_list.rfsm_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_rdyforsmres(&opr_ptr->msg_list.rfsm_res,param_len,param); + break; + case SecuTrip: + if (opr_flag == MAP_INDICATE) + return extract_securityTriplets_arg(&opr_ptr->msg_list.st_arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_securityTriplets_res(&opr_ptr->msg_list.st_res,param_len,param); + break; + case InterrSubs: + if (opr_flag == MAP_INDICATE) + return extract_interrogateSubscriber_arg(&opr_ptr->msg_list.is_arg,param_len,param); + break; + case CreateSubs: + if (opr_flag == MAP_INDICATE) + return extract_createSubscriber_arg(&opr_ptr->msg_list.cs_arg,param_len,param); + break; + case DelSubs: + if (opr_flag == MAP_INDICATE) + return extract_deleteSubscriber_arg(&opr_ptr->msg_list.ds_arg,param_len,param); + break; + /**** map opr **********/ + case DetermineOprUser: + if (opr_flag == MAP_INDICATE) + return extract_MapDetermineOprUserArg(&opr_ptr->msg_list.DetermineOprUser_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_MapDetermineOprUserRes(&opr_ptr->msg_list.DetermineOprUser_Res,param_len,param); + break; + case VlrUpdateLocation: + if (opr_flag == MAP_INDICATE) + return extract_MapVlrUpdateLocationArg(&opr_ptr->msg_list.VlrUpdateLocation_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_MapVlrUpdateLocationRes(&opr_ptr->msg_list.VlrUpdateLocation_Res,param_len,param); + break; + case CreateUserWithMsisdnImsi: + if (opr_flag == MAP_INDICATE) + return extract_MapCreateUserWithMsisdnImsiArg(&opr_ptr->msg_list.CreateUserWithMsisdnImsi_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_MapCreateUserWithMsisdnImsiRes(&opr_ptr->msg_list.CreateUserWithMsisdnImsi_Res,param_len,param); + break; + case DeleteOprUser: + if (opr_flag == MAP_INDICATE) + return extract_MapDeleteOprUserArg(&opr_ptr->msg_list.DeleteOprUser_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_MapDeleteOprUserRes(&opr_ptr->msg_list.DeleteOprUser_Res,param_len,param); + break; + case VlrEnquiryIMDMStatus: + if (opr_flag == MAP_INDICATE) + return extract_MapVlrEnquiryIMDM_Arg(&opr_ptr->msg_list.EnquiryIMDM_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + return extract_MapVlrEnquiryIMDM_Res(&opr_ptr->msg_list.EnquiryIMDM_Res,param_len,param); + break; + case RoutingInfoForLCS: + if (opr_flag == MAP_INDICATE) + return extract_RoutingInfoForLCS_Arg(&opr_ptr->msg_list.routingInfoForLCS_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + { + xap_send_error("RoutingInfoForLCS Res is not support to extract"); + return RER; + } + break; + case ProvideSubscriberLocation: + if (opr_flag == MAP_INDICATE) + return extract_ProvideSubscriberLocation_Arg(&opr_ptr->msg_list.provideSubscriberLocation_Arg,param_len,param); + else if (opr_flag == MAP_CONFIRM) + { + xap_send_error("ProvideSubscriberLocation Res is not support to extract"); + return RER; + } + break; + /**** map opr **********/ + default: + xap_send_error("the operation is not support:%d",opr_code); + return 0; + } + return 1; +} + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* +++++ Common types +++++ */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +int assign_authset(struct AuthSet_struct *auth_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + + asn_encode(buf,&asn_buf); + if (auth_ptr->param_flag != 0x07) + return RER; + buf_len = add_tlv("4-1",RAND_LEN,auth_ptr->rand,0x00,&asn_buf); + buf_len = add_tlv("4-2",SRES_LEN,auth_ptr->sres,0x00,&asn_buf); + buf_len = add_tlv("4-3",KC_LEN,auth_ptr->kc,0x00,&asn_buf); + return buf_len; +} + +int extract_authset(struct AuthSet_struct *auth_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + u8 temp_buf[256]; + + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("4-1",temp_buf,&asn_buf) == RAND_LEN) + memcpy(auth_ptr->rand,temp_buf,RAND_LEN); + else + return RER; + if(get_tlv("4-2",temp_buf,&asn_buf) == SRES_LEN) + memcpy(auth_ptr->sres,temp_buf,SRES_LEN); + else + return RER; + if(get_tlv("4-3",temp_buf,&asn_buf) == KC_LEN) + memcpy(auth_ptr->kc,temp_buf,KC_LEN); + else + return RER; + auth_ptr->param_flag = 0x07; + return ROK; +} + +int assign_extsiginfo(struct ExtSigInfo_struct *sig_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 temp_buf[2]; + + asn_encode(buf,&asn_buf); + if (sig_ptr->param_flag & 0x01) //prt_id + { + temp_buf[0] = sig_ptr->prt_id; + buf_len = add_tlv("10-1",1,temp_buf,0x00,&asn_buf); + } + if (sig_ptr->param_flag & 0x02) //siginfo + buf_len = add_tlv("4-2",sig_ptr->siginfo.siginfo_len,sig_ptr->siginfo.signal_info,0x00,&asn_buf); + return buf_len; +} + +int extract_extsiginfo(struct ExtSigInfo_struct *sig_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + sig_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("10",temp_buf,&asn_buf) == 1) + { + sig_ptr->prt_id = temp_buf[0]; + sig_ptr->param_flag |= 0x01; + } + len = get_tlv("4",temp_buf,&asn_buf); + if (len > 0 && len < SIGNALINFO_LEN) + { + sig_ptr->siginfo.siginfo_len = len; + memcpy(sig_ptr->siginfo.signal_info,temp_buf,len); + sig_ptr->param_flag |= 0x02; + } + return ROK; +} + +int assign_bscode(struct BSCode_struct *bs_ptr,u8 *buf,u8 flag) +{ + ASN_BUF asn_buf; + int ii; + int buf_len=0; + int temp_len; + u8 temp_buf[256]; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (bs_ptr->param_flag & 0x01) + { + temp_len = tele_bittostr(bs_ptr->tele_code,temp_buf,flag); + for (ii = 0;ii < temp_len;ii ++) + { + sprintf(tlv1,"3-%d",ii+1); + buf_len = add_tlv(tlv1,1,temp_buf+ii,0x80,&asn_buf); + } + } + if (bs_ptr->param_flag & 0x02) + { + temp_len = bearer_bittostr(bs_ptr->bearer_code,temp_buf,flag); + for (ii = 0;ii < temp_len;ii ++) + { + sprintf(tlv1,"2-%d",ii+1); + buf_len = add_tlv(tlv1,1,temp_buf+ii,0x80,&asn_buf); + } + } + return buf_len; +} + +int extract_bscode(struct BSCode_struct *bs_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int ii; + u8 temp_buf[256],temp_data[256]; + u8 tlv1[32]; + + bs_ptr->param_flag = 0; + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + for (ii = 0;ii < TSLIST_LEN;ii ++) // tele + { + sprintf(tlv1,"3-%d",ii+1); + if (get_tlv(tlv1,temp_buf,&asn_buf) < 1) + { + bs_ptr->tele_code = tele_strtobit(temp_data,ii); + bs_ptr->param_flag |= 0x01; + break; + } + temp_data[ii] = temp_buf[0]; + } + for (ii = 0;ii < BSLIST_LEN;ii ++) // bearer + { + sprintf(tlv1,"2-%d",ii+1); + if (get_tlv(tlv1,temp_buf,&asn_buf) < 1) + { + bs_ptr->bearer_code = bearer_strtobit(temp_data,ii); + bs_ptr->param_flag |= 0x02; + break; + } + temp_data[ii] = temp_buf[0]; + } + return ROK; +} + +int assign_subinfo(struct SubInfo_struct *info_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u8 tag1=1,tag2; + u8 tlv1[32],tlv2[32]; + + asn_encode(buf,&asn_buf); + if (info_ptr->param_flag & 0x01) // location info + { + tag2 = 1; + if (info_ptr->loc_info.param_flag & 0x01) // age of location info + { + sprintf(tlv1,"0-%d.2-%d",tag1,tag2++); + buf_len = add_int(tlv1,info_ptr->loc_info.age_info,0x00,&asn_buf); + } + if (info_ptr->loc_info.param_flag & 0x02) // geographical info + { + sprintf(tlv1,"0-%d.0-%d",tag1,tag2++); + buf_len = add_tlv(tlv1,8,info_ptr->loc_info.geog_info,0x80,&asn_buf); + } + if (info_ptr->loc_info.param_flag & 0x04) // vlr number + { + sprintf(tlv1,"0-%d.1-%d",tag1,tag2++); + buf_len = add_tlv(tlv1,info_ptr->loc_info.vlr_num[0],info_ptr->loc_info.vlr_num+1,0x80,&asn_buf); + } + if (info_ptr->loc_info.param_flag & 0x08) // location number + { + sprintf(tlv1,"0-%d.2-%d",tag1,tag2++); + buf_len = add_tlv(tlv1,info_ptr->loc_info.loc_num[0],info_ptr->loc_info.loc_num+1,0x80,&asn_buf); + } + if (info_ptr->loc_info.param_flag & 0x10) // cell id or LAI + { + sprintf(tlv1,"0-%d.3-%d",tag1,tag2++); + if (info_ptr->loc_info.cell_lai.choice_flag == 1) // cell id + { + sprintf(tlv2,"%s.0",tlv1); + buf_len = add_tlv(tlv2,GCID_LEN,info_ptr->loc_info.cell_lai.cell_choice.cellid,0x80,&asn_buf); + } + else // lai + { + sprintf(tlv2,"%s.1",tlv1); + buf_len = add_tlv(tlv2,LAI_LEN,info_ptr->loc_info.cell_lai.cell_choice.lai,0x80,&asn_buf); + } + } + tag1 ++; + } + if (info_ptr->param_flag & 0x02) // subscriber state + { + switch (info_ptr->sub_state.choice_flag) + { + case 0x01: // assume idle + sprintf(tlv1,"1-%d.0",tag1); + buf_len = add_null(tlv1,0x80,&asn_buf); + break; + case 0x02: // camel busy + sprintf(tlv1,"1-%d.1",tag1); + buf_len = add_null(tlv1,0x80,&asn_buf); + break; + case 0x04: // net not reachable + sprintf(tlv1,"1-%d.10",tag1); + buf_len = add_int(tlv1,info_ptr->sub_state.choice.net_reason,0x00,&asn_buf); + break; + case 0x08: // not provided from vlr + sprintf(tlv1,"1-%d.2",tag1); + buf_len = add_null(tlv1,0x80,&asn_buf); + break; + default: + break; + } + } + if (info_ptr->param_flag & 0x04) // location info GPRS + { + tag1 = 3; + sprintf(tlv1,"%d",tag1); + buf_len = add_int(tlv1,info_ptr->locationInfoGPRS,0x80,&asn_buf); + } + if (info_ptr->param_flag & 0x08) // ps subscriber state + { + tag1 = 4; + sprintf(tlv1,"%d",tag1); + buf_len = add_int(tlv1,info_ptr->locationInfoGPRS,0x80,&asn_buf); + } + if (info_ptr->param_flag & 0x10) // imei + { + tag1 = 5; + sprintf(tlv1,"%d",tag1); + buf_len = add_tlv(tlv1,IMEI_LEN, + info_ptr->imei,0x80,&asn_buf); + } + if (info_ptr->param_flag & 0x20) // ms classmark + { + tag1 = 6; + sprintf(tlv1,"%d",tag1); + buf_len = add_int(tlv1,info_ptr->ms_classmark,0x80,&asn_buf); + } + if (info_ptr->param_flag & 0x40) // gprs class mark + { + tag1 = 7; + sprintf(tlv1,"%d",tag1); + buf_len = add_int(tlv1,info_ptr->gprs_ms_class,0x80,&asn_buf); + } + if (info_ptr->param_flag & 0x80) // mnp info response + { + struct MnpInfoRes *mnpInfoResPtr; + mnpInfoResPtr = &info_ptr->mnp_info_res; + tag1 = 8; + if(mnpInfoResPtr->param_flag & 0x01) + { + sprintf(tlv1,"%d.0",tag1); + buf_len = add_tlv(tlv1, + mnpInfoResPtr->routing_number[0]%(ISDN_LEN+1), + mnpInfoResPtr->routing_number+1, + 0x80, + &asn_buf); + } + if(mnpInfoResPtr->param_flag & 0x02) + { + sprintf(tlv1,"%d.1",tag1); + buf_len = add_tlv(tlv1, + IMSI_LEN, + mnpInfoResPtr->imsi, + 0x80, + &asn_buf); + } + if(mnpInfoResPtr->param_flag & 0x04) + { + sprintf(tlv1,"%d.2",tag1); + buf_len = add_tlv(tlv1, + mnpInfoResPtr->msisdn[0]%(ISDN_LEN+1), + mnpInfoResPtr->msisdn+1, + 0x80, + &asn_buf); + } + if(mnpInfoResPtr->param_flag & 0x08) + { + sprintf(tlv1,"%d.3",tag1); + buf_len = add_tlv(tlv1, + 1, + (char *)&mnpInfoResPtr->mnp_status, + 0x80, + &asn_buf); + } + } + return buf_len; +} + +int extract_subinfo(struct SubInfo_struct *info_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + u8 tag1; + u8 tlv1[32]; + + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) != -1) // location info + { + info_ptr->param_flag |= 0x01; + tag1 = 1; + len = get_int("0.2-1",&asn_buf); // age of location info + if (len != -1) + { + info_ptr->loc_info.param_flag |= 0x01; + info_ptr->loc_info.age_info = len; + tag1 ++; + } + if (get_tlv("0.0",temp_buf,&asn_buf) == 8) // geographical info + { + info_ptr->loc_info.param_flag |= 0x02; + memcpy(info_ptr->loc_info.geog_info,temp_buf,8); + tag1 ++; + } + len = get_tlv("0.1",temp_buf,&asn_buf); // vlr num + if (len != -1 && len < ISDN_LEN) + { + info_ptr->loc_info.param_flag |= 0x04; + info_ptr->loc_info.vlr_num[0] = len; + memcpy(info_ptr->loc_info.vlr_num+1,temp_buf,len); + tag1 ++; + } + sprintf(tlv1,"0.2-%d",tag1); + len = get_tlv(tlv1,temp_buf,&asn_buf); // location num + if (len != -1 && len < LOCATION_NUM) + { + info_ptr->loc_info.param_flag |= 0x08; + info_ptr->loc_info.loc_num[0] = len; + memcpy(info_ptr->loc_info.loc_num+1,temp_buf,len); + } + if (get_tlv("0.3",temp_buf,&asn_buf) != -1) // cell id or lai + { + info_ptr->loc_info.param_flag |= 0x10; + if (get_tlv("0.3.0",temp_buf,&asn_buf) == GCID_LEN) + { + info_ptr->loc_info.cell_lai.choice_flag = 1; + memcpy(info_ptr->loc_info.cell_lai.cell_choice.cellid,temp_buf,GCID_LEN); + } + else if (get_tlv("0.3.1",temp_buf,&asn_buf) == LAI_LEN) + { + info_ptr->loc_info.cell_lai.choice_flag = 2; + memcpy(info_ptr->loc_info.cell_lai.cell_choice.lai,temp_buf,LAI_LEN); + } + } + } + if (get_tlv("1",temp_buf,&asn_buf) != -1) // location info + { + info_ptr->param_flag |= 0x02; + if (get_tlv("1.0",temp_buf,&asn_buf) != -1) // assume idle + info_ptr->sub_state.choice_flag = 1; + else if (get_tlv("1.1",temp_buf,&asn_buf) != -1) // camel busy + info_ptr->sub_state.choice_flag = 2; + else if (get_tlv("1.10",temp_buf,&asn_buf) != -1) // not reachalbe reason + { + info_ptr->sub_state.choice_flag = 0x04; + info_ptr->sub_state.choice.net_reason = temp_buf[0]; + } + else if (get_tlv("1.2",temp_buf,&asn_buf) != -1) // not provided from vlr + info_ptr->sub_state.choice_flag = 0x08; + } + if(get_tlv("3",temp_buf,&asn_buf) != -1) // location info GPRS + { + info_ptr->param_flag |= 0x04; + info_ptr->locationInfoGPRS = temp_buf[0]; + } + if (get_tlv("4",temp_buf,&asn_buf) != -1) // ps subscriber state + { + info_ptr->param_flag |= 0x08; + info_ptr->ps_subscriber_state = temp_buf[0]; + } + if ((len=get_tlv("5",temp_buf,&asn_buf)) != -1) // imei + { + info_ptr->param_flag |= 0x10; + info_ptr->imei[0] = len%(IMEI_LEN+1); + memcpy(&info_ptr->imei[1],temp_buf,IMEI_LEN); + } + if (get_tlv("6",temp_buf,&asn_buf) != -1) // ms class mark + { + info_ptr->param_flag |= 0x20; + info_ptr->ms_classmark = temp_buf[0]; + } + if (get_tlv("7",temp_buf,&asn_buf) != -1) // GPRS MS cla + { + info_ptr->param_flag |= 0x40; + info_ptr->gprs_ms_class = temp_buf[0]; + } + if (get_tlv("8",temp_buf,&asn_buf) != -1) // MNP info res + { + struct MnpInfoRes *mnpInfoResPtr; + mnpInfoResPtr = &info_ptr->mnp_info_res; + info_ptr->param_flag |= 0x80; + mnpInfoResPtr->param_flag = 0x00; + if ((len=get_tlv("8.0",temp_buf,&asn_buf)) != -1) // routing number + { + mnpInfoResPtr->param_flag |= 0x01; + len %= (ISDN_LEN+1); + mnpInfoResPtr->routing_number[0] = len; + memcpy(&mnpInfoResPtr->routing_number[1], + temp_buf, + len); + } + if((len=get_tlv("8.1",temp_buf,&asn_buf)) == IMSI_LEN) + { + mnpInfoResPtr->param_flag |= 0x02; + memcpy(mnpInfoResPtr->imsi,temp_buf,IMSI_LEN); + } + if((len=get_tlv("8.2",temp_buf,&asn_buf)) != -1) + { + mnpInfoResPtr->param_flag |= 0x04; + len %= (ISDN_LEN+1); + mnpInfoResPtr->msisdn[0] = len; + memcpy(&mnpInfoResPtr->msisdn[1],temp_buf,len); + } + if((len=get_tlv("8.3",temp_buf,&asn_buf)) != -1) + { + mnpInfoResPtr->param_flag |= 0x08; + mnpInfoResPtr->mnp_status = temp_buf[0]; + } + } + return ROK; +} + +int assign_ocsi(struct OCsi_struct *ocsi_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + u8 ii; + int buf_len=0; + u8 temp_len; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (ocsi_ptr->tdpdata_list.tdpdata_len > TDPDATA_NUM) + return RER; + buf_len = add_null("16",0x20,&asn_buf); + for(ii = 0;ii < ocsi_ptr->tdpdata_list.tdpdata_len;ii ++) //o-BCSM Camel TDP Data List + { + sprintf(tlv1,"16.16-%d",ii+1); + buf_len = add_null(tlv1,0x20,&asn_buf); + sprintf(tlv1,"16.16-%d.10-1",ii+1); + buf_len = add_int(tlv1,ocsi_ptr->tdpdata_list.tdp_data[ii].det_point,0x00,&asn_buf); + sprintf(tlv1,"16.16-%d.2-2",ii+1); + buf_len = add_int(tlv1,ocsi_ptr->tdpdata_list.tdp_data[ii].service_key,0x00,&asn_buf); + sprintf(tlv1,"16.16-%d.0-3",ii+1); + temp_len = ocsi_ptr->tdpdata_list.tdp_data[ii].scf_add[0]; + buf_len = add_tlv(tlv1,temp_len,ocsi_ptr->tdpdata_list.tdp_data[ii].scf_add+1,0x80,&asn_buf); + sprintf(tlv1,"16.16-%d.1-4",ii+1); + buf_len = add_int(tlv1,ocsi_ptr->tdpdata_list.tdp_data[ii].def_hand,0x80,&asn_buf); + } + if (ocsi_ptr->param_flag & 0x02) //camel capability Handling + buf_len = add_int("0-2",ocsi_ptr->camel_caphand,0x80,&asn_buf); + return buf_len; +} + +int extract_ocsi(struct OCsi_struct *ocsi_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 ii,jj; + u8 temp_buf[256]; + u8 tlv1[32]; + + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + ocsi_ptr->tdpdata_list.tdpdata_len = 0; + for (ii = 0;ii < TDPDATA_NUM;ii ++) + { + jj = ocsi_ptr->tdpdata_list.tdpdata_len; + sprintf(tlv1,"16.16-%d",ii+1); + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1) + break; + sprintf(tlv1,"16.16-%d.10",ii+1); // det_point + if (get_tlv(tlv1,temp_buf,&asn_buf) != 1) + return RER; + ocsi_ptr->tdpdata_list.tdp_data[jj].det_point = temp_buf[0]; + sprintf(tlv1,"16.16-%d.2",ii+1); // service key + len = get_int(tlv1,&asn_buf); + if (len == -1) + return RER; + ocsi_ptr->tdpdata_list.tdp_data[jj].service_key = len; + sprintf(tlv1,"16.16-%d.0",ii+1); // scf address + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1 || len > ISDN_LEN) + return RER; + ocsi_ptr->tdpdata_list.tdp_data[jj].scf_add[0] = len; + memcpy(ocsi_ptr->tdpdata_list.tdp_data[jj].scf_add+1,temp_buf,len); + sprintf(tlv1,"16.16-%d.1",ii+1); // default call handling + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len != 1) + return RER; + ocsi_ptr->tdpdata_list.tdp_data[jj].def_hand = temp_buf[0]; + ocsi_ptr->tdpdata_list.tdpdata_len ++; + } + if (get_tlv("0",temp_buf,&asn_buf) == 1) + { + ocsi_ptr->param_flag |= 0x02; + ocsi_ptr->camel_caphand = temp_buf[0]; + } + return ROK; +} + +int assign_tdpcritlist(struct OBCritLst_struct *list_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + u8 ii,jj; + int buf_len=0; + u8 tag1,tag2; + int temp_len; + u8 temp_buf[256]; + u8 tlv1[32],tlv2[32],tlv3[32]; + struct DstNumCrit_struct *dst_ptr; + + asn_encode(buf,&asn_buf); + if (list_ptr->list_len > TDPDATA_NUM) + return RER; + for (ii = 0;ii < list_ptr->list_len;ii ++) + { + sprintf(tlv1,"16-%d",ii+1); + buf_len = add_null(tlv1,0x20,&asn_buf); + sprintf(tlv2,"%s.10-1",tlv1); + buf_len = add_int(tlv2,list_ptr->crit_data[ii].det_point,0x00,&asn_buf); + tag1 = 2; + if (list_ptr->crit_data[ii].param_flag & 0x02) // dest number criteria + { + dst_ptr = (DstNumCrit_struct *) &list_ptr->crit_data[ii].dstCriteria; + if (dst_ptr->param_flag & 0x01) // match type + { + sprintf(tlv2,"%s.0-%d.0-1",tlv1,tag1); + buf_len = add_int(tlv2,dst_ptr->match_type,0x80,&asn_buf); + } + tag2 = 2; + if (dst_ptr->param_flag & 0x02) // dest number list + { + sprintf(tlv2,"%s.0-%d.1-%d",tlv1,tag1,tag2++); + if (dst_ptr->dstnum_list.dstnum_len > MAX_DSTNUM) + return RER; + for (jj = 0;jj < dst_ptr->dstnum_list.dstnum_len;jj ++) + { + sprintf(tlv3,"%s.4-%d",tlv2,jj+1); + buf_len = add_tlv(tlv3,dst_ptr->dstnum_list.dst_num[jj][0],dst_ptr->dstnum_list.dst_num[jj]+1,0x00,&asn_buf); + } + } + if (dst_ptr->param_flag & 0x04) // dest number length list + { + sprintf(tlv2,"%s.0-%d.2-%d",tlv1,tag1,tag2++); + if (dst_ptr->dstnumlen_list.numlength_len > DSTNUM_LEN) + return RER; + for (jj = 0;jj < dst_ptr->dstnumlen_list.numlength_len;jj ++) + { + sprintf(tlv3,"%s.2-%d",tlv2,jj+1); + buf_len = add_int(tlv3,dst_ptr->dstnumlen_list.num_length[jj],0x00,&asn_buf); + } + } + tag1 ++; + } + if (list_ptr->crit_data[ii].param_flag & 0x04) // basic service criteria + { + temp_len = assign_bscode(&list_ptr->crit_data[ii].bs_code,temp_buf,0); + sprintf(tlv2,"%s.1-%d",tlv1,tag1++); + buf_len = add_tlv(tlv2,temp_len,temp_buf,0x10,&asn_buf); + } + if (list_ptr->crit_data[ii].param_flag & 0x08) // call type criteria + { + sprintf(tlv2,"%s.2-%d",tlv1,tag1++); + buf_len = add_int(tlv2,list_ptr->crit_data[ii].call_crit,0x80,&asn_buf); + } + } + return buf_len; +} + +int extract_tdpcritlist(struct OBCritLst_struct *list_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 ii,jj; + u8 aa,bb; + u8 temp_buf[256]; + u8 tlv1[32]; + struct DstNumCrit_struct *dst_ptr; + + if (buf_len == 0) + return RER; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + list_ptr->list_len = 0; + for (ii = 0;ii < TDPDATA_NUM;ii ++) + { + jj = list_ptr->list_len; + list_ptr->crit_data[jj].param_flag = 0; + sprintf(tlv1,"16-%d",ii+1); + if (get_tlv(tlv1,temp_buf,&asn_buf) == -1) + break; + sprintf(tlv1,"16-%d.10",ii+1); // detection point + if (get_tlv(tlv1,temp_buf,&asn_buf) != 1) + return RER; + list_ptr->crit_data[jj].det_point = temp_buf[0]; + list_ptr->crit_data[jj].param_flag |= 0x01; + sprintf(tlv1,"16-%d.0",ii+1); // dest criteria + if (get_tlv(tlv1,temp_buf,&asn_buf) != -1) + { + list_ptr->crit_data[jj].param_flag |= 0x02; + dst_ptr = (DstNumCrit_struct *) &list_ptr->crit_data[jj].dstCriteria; + sprintf(tlv1,"16-%d.0.0",ii+1); // match type + if (get_tlv(tlv1,temp_buf,&asn_buf) != 1) + return RER; + dst_ptr->match_type = temp_buf[0]; + dst_ptr->param_flag = 0x01; + sprintf(tlv1,"16-%d.0.1",ii+1); // dest num list + if (get_tlv(tlv1,temp_buf,&asn_buf) != -1) + { + dst_ptr->param_flag |= 0x02; + dst_ptr->dstnum_list.dstnum_len = 0; + for (aa = 0;aa < MAX_DSTNUM;aa ++) + { + bb = dst_ptr->dstnum_list.dstnum_len; + sprintf(tlv1,"16-%d.0.1.4-%d",ii+1,aa+1); // dest num list + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len == -1 || len < ISDN_LEN) + break; + dst_ptr->dstnum_list.dst_num[bb][0] = len; + memcpy(dst_ptr->dstnum_list.dst_num[bb]+1,temp_buf,len); + dst_ptr->dstnum_list.dstnum_len ++; + } + } + sprintf(tlv1,"16-%d.0.2",ii+1); // dest num length list + if (get_tlv(tlv1,temp_buf,&asn_buf) != -1) + { + dst_ptr->param_flag |= 0x04; + dst_ptr->dstnumlen_list.numlength_len = 0; + for (aa = 0;aa < DSTNUM_LEN;aa ++) + { + bb = dst_ptr->dstnumlen_list.numlength_len; + sprintf(tlv1,"16-%d.0.2.2-%d",ii+1,aa+1); // dest num list + len = get_tlv(tlv1,temp_buf,&asn_buf); + if (len != 1) + break; + dst_ptr->dstnumlen_list.num_length[bb] = temp_buf[0]; + dst_ptr->dstnumlen_list.numlength_len ++; + } + } + } + sprintf(tlv1,"16-%d.1",ii+1); // bs criteria + if ((len=get_tlv(tlv1,temp_buf,&asn_buf)) != -1) + { + if (!extract_bscode(&list_ptr->crit_data[jj].bs_code,len,temp_buf)) + return RER; + list_ptr->crit_data[jj].param_flag |= 0x04; + } + sprintf(tlv1,"16-%d.2",ii+1); // call type criteria + if (get_tlv(tlv1,temp_buf,&asn_buf) == 1) + { + list_ptr->crit_data[jj].param_flag |= 0x08; + list_ptr->crit_data[jj].call_crit = temp_buf[0]; + } + list_ptr->list_len ++; + } + return ROK; +} + +int assign_ccbsfeat(struct CcbsFeat_struct *cf_ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + int temp_len; + u8 tag1=1; + u8 temp_buf[256]; + u8 tlv1[32]; + + asn_encode(buf,&asn_buf); + if (cf_ptr->param_flag & 0x01) // ccbs index + { + sprintf(tlv1,"0-%d",tag1++); + buf_len = add_tlv(tlv1,1,&cf_ptr->ccbs_index,0x80,&asn_buf); + } + if (cf_ptr->param_flag & 0x02) // b-subscriber number + { + sprintf(tlv1,"1-%d",tag1++); + buf_len = add_tlv(tlv1,cf_ptr->bsub_num[0],cf_ptr->bsub_num+1,0x80,&asn_buf); + } + if (cf_ptr->param_flag & 0x04) // bs code + { + sprintf(tlv1,"3-%d",tag1++); + temp_len = assign_bscode(&cf_ptr->bs_code,temp_buf,0); + buf_len = add_tlv(tlv1,temp_len,temp_buf,0x80,&asn_buf); + } + return buf_len; +} + +int extract_ccbsfeat(struct CcbsFeat_struct *cf_ptr,u32 buf_len,u8 *buf) +{ + ASN_BUF asn_buf; + int len; + u8 temp_buf[256]; + + cf_ptr->param_flag = 0; + if (buf_len == 0) + return ROK; + if (asn_decode_v3(buf,buf_len,&decErr,&asn_buf) == -1) + return RER; + if (get_tlv("0",temp_buf,&asn_buf) == 1) // ccbs index + { + cf_ptr->param_flag |= 0x01; + cf_ptr->ccbs_index = temp_buf[0]; + } + len = get_tlv("1",temp_buf,&asn_buf); // b-subscriber number + if (len > 0 && len <= ISDN_LEN) + { + cf_ptr->param_flag |= 0x02; + cf_ptr->bsub_num[0] = len; + memcpy(cf_ptr->bsub_num+1,temp_buf,len); + } + len = get_tlv("3",temp_buf,&asn_buf); // bs code + if (len > 0) + { + if (!extract_bscode(&cf_ptr->bs_code,len,temp_buf)) + return RER; + cf_ptr->param_flag |= 0x04; + } + return ROK; +} diff --git a/omc/plat/xapp/src/mapp/map_coding.h b/omc/plat/xapp/src/mapp/map_coding.h new file mode 100644 index 0000000..916b667 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_coding.h @@ -0,0 +1,513 @@ +/* MAP coding head file */ +/* written by Liu Zhiguo 2003-03-04 */ +/* version 2.0 */ +/* -------------------------------- */ + +#ifndef _MAP_CODING +#define _MAP_CODING + +/* define in map_code_ms.c */ +int assign_uplocarg(struct MapUL_Arg *ul_ptr,u8 *buf,u8 ver); +int extract_uplocarg(struct MapUL_Arg *ul_ptr,u32 buf_len,u8 *buf ,u8 ver); +int assign_uplocres(struct MapUL_Res *ul_ptr,u8 *buf); +int extract_uplocres(struct MapUL_Res *ul_ptr,u32 buf_len,u8 *buf); + + +/* ------------------------>>>>>>>>>>>>>>>> MAP v1 <<<<<<<<<<<<<<<<<<<<<<<<<----------------*/ + +//int assign_sendParameterres(struct MapSP_Res *sp_ptr,u8 *buf); +//int extract_sendParameterArg(struct MapSP_Arg *sp_ptr,u32 buf_len,u8 *buf,u32 dialogue_id); + +int assign_SendParaArg(struct MapSP_Arg *sendpara_ptr,u8 *buf); +int extract_SendParaArg(struct MapSP_Arg *sendpara_ptr,u32 buf_len,u8 *buf); +int assign_SendParaRes(struct MapSP_Res *sp_ptr,u8 *buf); +int extract_SendParaRes(struct MapSP_Res *sp_ptr,u32 buf_len,u8 *buf); + +int assign_NotPresentArg(struct MapNP_Arg *np_ptr, u8 *buf); +int extract_NotPresentArg( struct MapNP_Arg *np_ptr,u32 buf_len,u8 *buf) ; + +int assign_ProcessUSSDArg(struct MapPUSSD_Arg *ussd_ptr, u8 *buf); +int extract_ProcessUSSDArg( struct MapPUSSD_Arg *ussd_ptr,u32 buf_len,u8 *buf); +int assign_ProcessUSSDRes(struct MapPUSSD_Res *ussd_ptr, u8 *buf) ; +int extract_ProcessUSSDRes( struct MapPUSSD_Res *ussd_ptr,u32 buf_len,u8 *buf); + +int assign_SAArg(struct MapSA_Arg *sa_ptr, u8 *buf) ; +int extract_SAArg( struct MapSA_Arg *sa_ptr,u32 buf_len,u8 *buf); + +int assign_HOArg(struct MapHO_Arg *ho_ptr, u8 *buf) ; +int extract_HOArg( struct MapHO_Arg *ho_ptr,u32 buf_len,u8 *buf); +int assign_HORes(struct MapHO_Res *ho_ptr, u8 *buf) ; +int extract_HORes( struct MapHO_Res *ho_ptr,u32 buf_len,u8 *buf); + +int assign_PFSHOArg(struct MapPFSHO_Arg *psho_ptr, u8 *buf); +int extract_PFSHOArg( struct MapPFSHO_Arg *psho_ptr,u32 buf_len,u8 *buf); +int assign_PFSHORes(struct MapPFSHO_Res *psho_ptr,u8 *buf); +int extract_PFSHORes(struct MapPFSHO_Res *psho_ptr,u32 buf_len,u8 *buf); + +int assign_NIHOArg(struct MapNIHO_Arg *niho_ptr, u8 *buf) ; +int extract_NIHOArg( struct MapNIHO_Arg *niho_ptr,u32 buf_len,u8 *buf); + +int assign_TSAArg(struct MapTSA_Arg *tsa_ptr, u8 *buf); +int extract_TSAArg( struct MapTSA_Arg *TSA_ptr,u32 buf_len,u8 *buf); + +int assign_BSAArg(struct MapBSA_Arg *bsa_ptr, u8 *buf); +int extract_BSAArg( struct MapBSA_Arg *bsa_ptr,u32 buf_len,u8 *buf); + + +int assign_routinfoforsm_v1_arg(struct MapRIFSMV1_Arg *rif_ptr,u8 *buf); +int extract_routinfoforsm_v1_arg(struct MapRIFSMV1_Arg *rif_ptr,u32 buf_len,u8 *buf); +int assign_routinfoforsm_v1_res(struct MapRIFSMV1_Res *rif_ptr,u8 *buf); +int extract_routinfoforsm_v1_res(struct MapRIFSMV1_Res *rif_ptr,u32 buf_len,u8 *buf); + + +int assign_fwdsmarg(struct MapFSM_Arg *ptr,u8 *buf); +int extract_fwdsmarg(struct MapFSM_Arg *ptr,u32 buf_len,u8 *buf); + +int assign_cancellocarg(struct MapCL_Arg *cl_ptr,u8 *buf,u8 ver); +int extract_cancellocarg(struct MapCL_Arg *cl_ptr,u32 buf_len,u8 *buf,u8 ver); +int assign_cancellocres(struct MapCL_Res *cl_ptr,u8 *buf); +int extract_cancellocres(struct MapCL_Res *cl_ptr,u32 buf_len,u8 *buf); +/* ------------------------>>>>>>>>>>>>>>>> MAP v1 <<<<<<<<<<<<<<<<<<<<<<<<<----------------*/ + +int assign_purgemsarg(struct MapPMS_Arg *pms_ptr,u8 *buf,u8 version); +int extract_purgemsarg(struct MapPMS_Arg *pms_ptr,u32 buf_len,u8 *buf,u8 version); +int assign_purgemsres(struct MapPMS_Res *pms_ptr,u8 *buf); +int extract_purgemsres(struct MapPMS_Res *pms_ptr,u32 buf_len,u8 *buf); + +int assign_sndidentarg(struct MapSI_Arg *ptr,u8 *buf); +int extract_sndidentarg(struct MapSI_Arg *ptr,u32 buf_len,u8 *buf); +int assign_sndidentres(struct MapSI_Res *ptr,u8 *buf); +int extract_sndidentres(struct MapSI_Res *ptr,u32 buf_len,u8 *buf); + +int assign_upgprslocarg(struct MapUGL_Arg *ugl_ptr,u8 *buf); +int extract_upgprslocarg(struct MapUGL_Arg *ugl_ptr,u32 buf_len,u8 *buf); +int assign_upgprslocres(struct MapUGL_Res *ugl_ptr,u8 *buf); +int extract_upgprslocres(struct MapUGL_Res *ugl_ptr,u32 buf_len,u8 *buf); + +int assign_prvsubinfoarg(struct MapPSI_Arg *psi_ptr,u8 *buf); +int extract_prvsubinfoarg(struct MapPSI_Arg *psi_ptr,u32 buf_len,u8 *buf); +int assign_prvsubinfores(struct MapPSI_Res *psi_ptr,u8 *buf); +int extract_prvsubinfores(struct MapPSI_Res *psi_ptr,u32 buf_len,u8 *buf); + +int assign_anytimeintarg(struct MapATI_Arg *ati_ptr,u8 *buf); +int extract_anytimeintarg(struct MapATI_Arg *ati_ptr,u32 buf_len,u8 *buf); +int assign_anytimeintres(struct MapATI_Res *ati_ptr,u8 *buf); +int extract_anytimeintres(struct MapATI_Res *ati_ptr,u32 buf_len,u8 *buf); + +int assign_prehoarg(struct MapPHO_Arg *pho_ptr,u8 *buf); +int extract_prehoarg(struct MapPHO_Arg *pho_ptr,u32 buf_len,u8 *buf); +int assign_prehores(struct MapPHO_Res *pho_ptr,u8 *buf); +int extract_prehores(struct MapPHO_Res *pho_ptr,u32 buf_len,u8 *buf); + +int assign_sndendsigarg(struct MapSES_Arg *ses_ptr,u8 *buf); +int extract_sndendsigarg(struct MapSES_Arg *ses_ptr,u32 buf_len,u8 *buf); + +int assign_prcaccsigarg(struct MapPAS_Arg *pas_ptr,u8 *buf); +int extract_prcaccsigarg(struct MapPAS_Arg *pas_ptr,u32 buf_len,u8 *buf); + +int assign_fwdaccsigarg(struct MapFAS_Arg *fas_ptr,u8 *buf); +int extract_fwdaccsigarg(struct MapFAS_Arg *fas_ptr,u32 buf_len,u8 *buf); + +int assign_presubshoarg(struct MapPSHO_Arg *psho_ptr,u8 *buf); +int extract_presubshoarg(struct MapPSHO_Arg *psho_ptr,u32 buf_len,u8 *buf); +int assign_presubshores(struct MapPSHO_Res *psho_ptr,u8 *buf); +int extract_presubshores(struct MapPSHO_Res *psho_ptr,u32 buf_len,u8 *buf); + +int assign_sndauthinfoarg(struct MapSAI_Arg *sai_ptr,u8 *buf); +int assign_sndauthinfores(struct MapSAI_Res *sai_ptr,u8 *buf); +int extract_sndauthinfoarg(struct MapSAI_Arg *sai_ptr,u32 buf_len,u8 *buf); +int extract_sndauthinfores(struct MapSAI_Res *sai_ptr,u32 buf_len,u8 *buf); + +int assign_chkimeiarg(struct MapCIMEI_Arg *ptr,u8 *buf); +int extract_chkimeiarg(struct MapCIMEI_Arg *ptr,u32 buf_len,u8 *buf); +int assign_chkimeires(struct MapCIMEI_Res *ptr,u8 *buf); +int extract_chkimeires(struct MapCIMEI_Res *ptr,u32 buf_len,u8 *buf); + +int assign_inssubdataarg(struct MapISD_Arg *isd_ptr,u8 *buf,u8 version); +int assign_inssubdatares(struct MapISD_Res *isd_ptr,u8 *buf); +int extract_inssubdataarg(struct MapISD_Arg *isd_ptr,u32 buf_len,u8 *buf); +int extract_inssubdatares(struct MapISD_Res *isd_ptr,u32 buf_len,u8 *buf); + +int assign_delsubdataarg(struct MapDSD_Arg *dsd_ptr,u8 *buf); +int extract_delsubdataarg(struct MapDSD_Arg *dsd_ptr,u32 buf_len,u8 *buf); +int assign_delsubdatares(struct MapDSD_Res *dsdr_ptr,u8 *buf); +int extract_delsubdatares(struct MapDSD_Res *dsdr_ptr,u32 buf_len,u8 *buf); + +int assign_resetarg(struct MapReset_Arg *rs_ptr,u8 *buf); +int extract_resetarg(struct MapReset_Arg *rs_ptr,u32 buf_len,u8 *buf); + +int assign_restdataarg(struct MapRD_Arg *rsd_ptr,u8 *buf); +int extract_restdataarg(struct MapRD_Arg *rsd_ptr,u32 buf_len,u8 *buf); +int assign_restdatares(struct MapRD_Res *rsd_ptr,u8 *buf); +int extract_restdatares(struct MapRD_Res *rsd_ptr,u32 buf_len,u8 *buf); + +int assign_sndroutinfogprsarg(struct MapSRIFG_Arg *sfg_ptr,u8 *buf); +int extract_sndroutinfogprsarg(struct MapSRIFG_Arg *sfg_ptr,u32 buf_len,u8 *buf); +int assign_sndroutinfogprsres(struct MapSRIFG_Res *sfg_ptr,u8 *buf); +int extract_sndroutinfogprsres(struct MapSRIFG_Res *sfg_ptr,u32 buf_len,u8 *buf); + +int assign_failreportarg(struct MapFR_Arg *fr_ptr,u8 *buf); +int extract_failreportarg(struct MapFR_Arg *fr_ptr,u32 buf_len,u8 *buf); +int assign_failreportres(struct MapFR_Res *fr_ptr,u8 *buf); +int extract_failreportres(struct MapFR_Res *fr_ptr,u32 buf_len,u8 *buf); + +int assign_notemspregprsarg(struct MapNMPFG_Arg *npg_ptr,u8 *buf); +int extract_notemspregprsarg(struct MapNMPFG_Arg *npg_ptr,u32 buf_len,u8 *buf); +int assign_notemspregprsres(struct MapNMPFG_Res *npg_ptr,u8 *buf); +int extract_notemspregprsres(struct MapNMPFG_Res *npg_ptr,u32 buf_len,u8 *buf); + +/* define in map_code_om.c */ +int assign_acttrcmodearg(struct MapATM_Arg *atm_ptr,u8 *buf); +int extract_acttrcmodearg(struct MapATM_Arg *atm_ptr,u32 buf_len,u8 *buf); +int assign_acttrcmoderes(struct MapATM_Res *atm_ptr,u8 *buf); +int extract_acttrcmoderes(struct MapATM_Res *atm_ptr,u32 buf_len,u8 *buf); + +int assign_deacttrcmodearg(struct MapDTM_Arg *dtm_ptr,u8 *buf); +int extract_deacttrcmodearg(struct MapDTM_Arg *dtm_ptr,u32 buf_len,u8 *buf); +int assign_deacttrcmoderes(struct MapDTM_Res *dtm_ptr,u8 *buf); +int extract_deacttrcmoderes(struct MapDTM_Res *dtm_ptr,u32 buf_len,u8 *buf); + +int assign_sndimsiarg(struct MapSIMSI_Arg *sim_ptr,u8 *buf); +int extract_sndimsiarg(struct MapSIMSI_Arg *sim_ptr,u32 buf_len,u8 *buf); +int assign_sndimsires(struct MapSIMSI_Res *sim_ptr,u8 *buf); +int extract_sndimsires(struct MapSIMSI_Res *sim_ptr,u32 buf_len,u8 *buf); + +/* define in map_code_ch.c */ +int assign_sndroutinfoarg(struct MapSRI_Arg *sri_ptr,u8 *buf,u8 ver); +int assign_sndroutinfores(struct MapSRI_Res *sri_ptr,u8 *buf,u8 version); +int extract_sndroutinfoarg(struct MapSRI_Arg *sri_ptr,u32 buf_len,u8 *buf,u8 ver); +int extract_sndroutinfores(struct MapSRI_Res *sri_ptr,u32 buf_len,u8 *buf,u8 version); + +int assign_provroamnumarg(struct MapPRN_Arg *prn_ptr, u8 *buf); +int assign_provroamnumres(struct MapPRN_Res *prn_ptr, u8 *buf); +int extract_provroamnumarg(struct MapPRN_Arg *prn_ptr,u32 buf_len,u8 *buf); +int extract_provroamnumres(struct MapPRN_Res *prn_ptr,u32 buf_len,u8 *buf); + +int assign_rescallhandarg(struct MapRCH_Arg *rch_ptr,u8 *buf); +int extract_rescallhandarg(struct MapRCH_Arg *rch_ptr,u32 buf_len,u8 *buf); +int assign_rescallhandres(struct MapRCH_Res *rch_ptr,u8 *buf); +int extract_rescallhandres(struct MapRCH_Res *rch_ptr,u32 buf_len,u8 *buf); + +int assign_prvsiwfsnumarg(struct MapPSN_Arg *psn_ptr,u8 *buf); +int extract_prvsiwfsnumarg(struct MapPSN_Arg *psn_ptr,u32 buf_len,u8 *buf); +int assign_prvsiwfsnumres(struct MapPSN_Res *psn_ptr,u8 *buf); +int extract_prvsiwfsnumres(struct MapPSN_Res *psn_ptr,u32 buf_len,u8 *buf); + +int assign_siwfssigmodarg(struct MapSSM_Arg *ssm_ptr,u8 *buf); +int extract_siwfssigmodarg(struct MapSSM_Arg *ssm_ptr,u32 buf_len,u8 *buf); +int assign_siwfssigmodres(struct MapSSM_Res *ssm_ptr,u8 *buf); +int extract_siwfssigmodres(struct MapSSM_Res *ssm_ptr,u32 buf_len,u8 *buf); + +int assign_setrepstatearg(struct MapSRS_Arg *srs_ptr,u8 *buf); +int extract_setrepstatearg(struct MapSRS_Arg *srs_ptr,u32 buf_len,u8 *buf); +int assign_setrepstateres(struct MapSRS_Res *srs_ptr,u8 *buf); +int extract_setrepstateres(struct MapSRS_Res *srs_ptr,u32 buf_len,u8 *buf); + +int assign_statreparg(struct MapSR_Arg *sr_ptr,u8 *buf); +int extract_statreparg(struct MapSR_Arg *sr_ptr,u32 buf_len,u8 *buf); +int assign_statrepres(struct MapSR_Res *sr_ptr,u8 *buf); +int extract_statrepres(struct MapSR_Res *sr_ptr,u32 buf_len,u8 *buf); + +int assign_rmtuserfreearg(struct MapRUF_Arg *ruf_ptr,u8 *buf); +int extract_rmtuserfreearg(struct MapRUF_Arg *ruf_ptr,u32 buf_len,u8 *buf); +int assign_rmtuserfreeres(struct MapRUF_Res *ruf_ptr,u8 *buf); +int extract_rmtuserfreeres(struct MapRUF_Res *ruf_ptr,u32 buf_len,u8 *buf); + +/* define in map_code_ss.c */ +int assign_regssarg(struct MapRSS_Arg *rss_ptr, u8 *buf); +int extract_regssarg(struct MapRSS_Arg *rss_ptr,u32 buf_len,u8 *buf); +int assign_regssres(struct MapRSS_Res *rss_ptr, u8 *buf); +int extract_regssres(struct MapRSS_Res *rss_ptr,u32 buf_len,u8 *buf); + +int assign_erassarg(struct MapESS_Arg *ess_ptr, u8 *buf); +int extract_erassarg(struct MapESS_Arg *ess_ptr,u32 buf_len,u8 *buf); +int assign_erassres(struct MapESS_Res *essr_ptr, u8 *buf); +int extract_erassres(struct MapESS_Res *essr_ptr,u32 buf_len,u8 *buf); + +int assign_actssarg(struct MapASS_Arg *ass_ptr, u8 *buf); +int extract_actssarg(struct MapASS_Arg *ass_ptr,u32 buf_len,u8 *buf); +int assign_actssres(struct MapASS_Res *assr_ptr, u8 *buf); +int extract_actssres(struct MapASS_Res *assr_ptr,u32 buf_len,u8 *buf); + +int assign_deactssarg(struct MapDASS_Arg *dss_ptr, u8 *buf); +int extract_deactssarg(struct MapDASS_Arg *dss_ptr,u32 buf_len,u8 *buf); +int assign_deactssres(struct MapDASS_Res *dssr_ptr, u8 *buf); +int extract_deactssres(struct MapDASS_Res *dssr_ptr,u32 buf_len,u8 *buf); + +int assign_intrssarg(struct MapINTSS_Arg *intrss_ptr, u8 *buf); +int extract_intrssarg(struct MapINTSS_Arg *intr_ptr,u32 buf_len,u8 *buf); +int assign_intrssres(struct MapINTSS_Res *intrss_ptr, u8 *buf); +int extract_intrssres(struct MapINTSS_Res *intrss_ptr,u32 buf_len,u8 *buf); + +int assign_prcunssreqarg(struct MapPUSSR_Arg *psr_ptr,u8 *buf); +int extract_prcunssreqarg(struct MapPUSSR_Arg *psr_ptr,u32 buf_len,u8 *buf); +int assign_prcunssreqres(struct MapPUSSR_Res *psr_ptr,u8 *buf); +int extract_prcunssreqres(struct MapPUSSR_Res *psr_ptr,u32 buf_len,u8 *buf); + +int assign_unssreqarg(struct MapUSSR_Arg *usr_ptr,u8 *buf); +int extract_unssreqarg(struct MapUSSR_Arg *usr_ptr,u32 buf_len,u8 *buf); +int assign_unssreqres(struct MapUSSR_Res *usr_ptr,u8 *buf); +int extract_unssreqres(struct MapUSSR_Res *usr_ptr,u32 buf_len,u8 *buf); + +int assign_unssnotarg(struct MapUSSN_Arg *usn_ptr,u8 *buf); +int extract_unssnotarg(struct MapUSSN_Arg *usn_ptr,u32 buf_len,u8 *buf); +int assign_unssnotres(struct MapUSSN_Res *usn_ptr,u8 *buf); +int extract_unssnotres(struct MapUSSN_Res *usn_ptr,u32 buf_len,u8 *buf); + +int assign_regpswdarg(struct MapRPSS_Arg *rpw_ptr,u8 *buf); +int extract_regpswdarg(struct MapRPSS_Arg *rpw_ptr,u32 buf_len,u8 *buf); +int assign_regpswdres(struct MapRPSS_Res *rpwr_ptr,u8 *buf); +int extract_regpswdres(struct MapRPSS_Res *rpwr_ptr,u32 buf_len,u8 *buf); + +int assign_getpswdarg(struct MapGPSS_Arg *gpw_ptr,u8 *buf); +int extract_getpswdarg(struct MapGPSS_Arg *gpw_ptr,u32 buf_len,u8 *buf); +int assign_getpswdres(struct MapGPSS_Res *rpwr_ptr,u8 *buf); +int extract_getpswdres(struct MapGPSS_Res *rpwr_ptr,u32 buf_len,u8 *buf); + +int assign_ssinvnotarg(struct MapSSIN_Arg *sin_ptr,u8 *buf); +int extract_ssinvnotarg(struct MapSSIN_Arg *sin_ptr,u32 buf_len,u8 *buf); +int assign_ssinvnotres(struct MapSSIN_Res *sin_ptr,u8 *buf); +int extract_ssinvnotres(struct MapSSIN_Res *sin_ptr,u32 buf_len,u8 *buf); + +int assign_regccentarg(struct MapRCCE_Arg *rce_ptr,u8 *buf); +int extract_regccentarg(struct MapRCCE_Arg *rce_ptr,u32 buf_len,u8 *buf); +int assign_regccentres(struct MapRCCE_Res *rce_ptr,u8 *buf); +int extract_regccentres(struct MapRCCE_Res *rce_ptr,u32 buf_len,u8 *buf); + +int assign_eraseccentarg(struct MapECCE_Arg *ece_ptr,u8 *buf); +int extract_eraseccentarg(struct MapECCE_Arg *ece_ptr,u32 buf_len,u8 *buf); +int assign_eraseccentres(struct MapECCE_Res *ece_ptr,u8 *buf); +int extract_eraseccentres(struct MapECCE_Res *ece_ptr,u32 buf_len,u8 *buf); + +/* define in map_code_sms.c */ +int assign_routinfoforsmarg(struct MapRIFSM_Arg *rif_ptr,u8 *buf); +int extract_routinfoforsmarg(struct MapRIFSM_Arg *rif_ptr,u32 buf_len,u8 *buf); +int assign_routinfoforsmres(struct MapRIFSM_Res *rif_ptr,u8 *buf); +int extract_routinfoforsmres(); + +int assign_mofwdsmarg(struct MapMOFSM_Arg *ptr,u8 *buf,u8 version); +int extract_mofwdsmarg(struct MapMOFSM_Arg *ptr,u32 buf_len,u8 *buf,u8 version); +int assign_mofwdsmres(struct MapMOFSM_Res *ptr,u8 *buf,u8 version); +int extract_mofwdsmres(struct MapMOFSM_Res *ptr,u32 buf_len,u8 *buf); + +int assign_mtfwdsmarg(struct MapMTFSM_Arg *ptr,u8 *buf,u8 MAPVer); +int extract_mtfwdsmarg(struct MapMTFSM_Arg *ptr,u32 buf_len,u8 *buf,u8 MAPVer); +int assign_mtfwdsmres(struct MapMTFSM_Res *ptr,u8 *buf,u8 MAPVer); +int extract_mtfwdsmres(struct MapMTFSM_Res *ptr,u32 buf_len,u8 *buf,u8 MAPVer); + +int assign_repsmdelstatarg(struct MapRSMDS_Arg *ptr,u8 *buf); +int extract_repsmdelstatarg(struct MapRSMDS_Arg *ptr,u32 buf_len,u8 *buf); +int assign_repsmdelstatres(struct MapRSMDS_Res *ptr,u8 *buf); +int extract_repsmdelstatres(struct MapRSMDS_Res *ptr,u32 buf_len,u8 *buf); + +int assign_infsrvcentarg(struct MapISC_Arg *ptr,u8 *buf); +int extract_infsrvcentarg(struct MapISC_Arg *ptr,u32 buf_len,u8 *buf); + +int assign_altsrvcentarg(struct MapASC_Arg *ptr,u8 *buf); +int extract_altsrvcentarg(struct MapASC_Arg *ptr,u32 buf_len,u8 *buf); + +int assign_rdyforsmarg(struct MapRFSM_Arg *ptr,u8 *buf); +int extract_rdyforsmarg(struct MapRFSM_Arg *ptr,u32 buf_len,u8 *buf); +int assign_rdyforsmres(struct MapRFSM_Res *ptr,u8 *buf); +int extract_rdyforsmres(struct MapRFSM_Res *ptr,u32 buf_len,u8 *buf); + +/* +++++++++++++++++++++++++++++ */ +/* MAP-H (with AUC) structure */ +/* +++++++++++++++++++++++++++++ */ +int assign_securityTriplets_arg(); +int extract_securityTriplets_arg(); +int assign_securityTriplets_res(); +int extract_securityTriplets_res(); + +int assign_interrogateSubscriber_arg(); +int extract_interrogateSubscriber_arg(); + +int assign_createSubscriber_arg(); +int extract_createSubscriber_arg(); + +int assign_deleteSubscriber_arg(); +int extract_deleteSubscriber_arg(); + +/* ++++++++++++ */ +/* Common types */ +/* ++++++++++++ */ +int assign_authset(struct AuthSet_struct *auth_ptr,u8 *buf); +int extract_authset(struct AuthSet_struct *auth_ptr,u32 buf_len,u8 *buf); +int assign_extsiginfo(struct ExtSigInfo_struct *sig_ptr,u8 *buf); +int extract_extsiginfo(struct ExtSigInfo_struct *sig_ptr,u32 buf_len,u8 *buf); +int assign_bscode(struct BSCode_struct *bs_ptr,u8 *buf,u8 flag); +int extract_bscode(struct BSCode_struct *bs_ptr,u32 buf_len,u8 *buf); +int assign_subinfo(struct SubInfo_struct *info_ptr,u8 *buf); +int extract_subinfo(struct SubInfo_struct *info_ptr,u32 buf_len,u8 *buf); +int assign_ocsi(struct OCsi_struct *ocsi_ptr,u8 *buf); +int extract_ocsi(struct OCsi_struct *ocsi_ptr,u32 buf_len,u8 *buf); +int assign_tdpcritlist(struct OBCritLst_struct *list_ptr,u8 *buf); +int extract_tdpcritlist(struct OBCritLst_struct *list_ptr,u32 buf_len,u8 *buf); +int assign_ccbsfeat(struct CcbsFeat_struct *cf_ptr,u8 *buf); +int extract_ccbsfeat(struct CcbsFeat_struct *cf_ptr,u32 buf_len,u8 *buf); + +/* is41 */ +int assign_is41AuthenticationDirective_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationDirective_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int extract_is41AuthenticationDirective_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationDirective_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int assign_is41AuthenticationDirectiveForward_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationFailureReport_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationFailureReport_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationRequest_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationRequest_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationStatusReport_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41AuthenticationStatusReport_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41BaseStationChallenge_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41BaseStationChallenge_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41CountRequest_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_is41CountRequest_rsp(struct MapOprSrv_struct *ptr,u8 *buf); + +int extract_is41AuthenticationDirectiveForward_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationFailureReport_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationFailureReport_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationRequest_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationRequest_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationStatusReport_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41AuthenticationStatusReport_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41BaseStationChallenge_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41BaseStationChallenge_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41CountRequest_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_is41CountRequest_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); + + +int assign_Is41SmsDeliveryBackward_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsDeliveryBackward_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsDeliveryForward_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsDeliveryForward_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsDeliveryPointToPoint_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsDeliveryPointToPoint_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsNotification_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsNotification_rsp(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsRequest_arg(struct MapOprSrv_struct *ptr,u8 *buf); +int assign_Is41SmsRequest_rsp(struct MapOprSrv_struct *ptr,u8 *buf); + +int extract_Is41SmsDeliveryBackward_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsDeliveryBackward_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsDeliveryForward_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsDeliveryForward_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsDeliveryPointToPoint_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsDeliveryPointToPoint_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsNotification_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsNotification_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsRequest_arg(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); +int extract_Is41SmsRequest_rsp(struct MapOprSrv_struct *ptr,u32 buf_len,u8 *buf); + +int assign_is41RegistrationNotification_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RegistrationNotification_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RegistrationCancellation_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RegistrationCancellation_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41LocationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41LocationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RoutingRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RoutingRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41MSInactive_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41MSInactive_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41FeatureRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41FeatureRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41QualificationDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41QualificationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41TransferToNumberRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41TransferToNumberRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RedirectionRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41RedirectionRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u8 *buf); +int assign_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u8 *buf); + +int extract_is41RegistrationNotification_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RegistrationNotification_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RegistrationCancellation_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RegistrationCancellation_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41LocationRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41LocationRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RoutingRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RoutingRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41MSInactive_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41MSInactive_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41FeatureRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41FeatureRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41QualificationDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41QualificationDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41TransferToNumberRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41TransferToNumberRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RedirectionRequest_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41RedirectionRequest_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41OriginationRequest_arg(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf); +int extract_is41OriginationRequest_rsp(struct MapOprSrv_struct *opr_ptr, u32 buf_len, u8 *buf); +int extract_is41AnalyzedInformation_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41AnalyzedInformation_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41OAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41ODisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41ODisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41TAnswer_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41TDisconnect_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41TDisconnect_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41CallControlDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41CallControlDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41SeizeResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41SeizeResource_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41ConnectResource_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41SRFDirective_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41SRFDirective_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41ShortMessageAnalyzed_arg(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); +int extract_is41ShortMessageAnalyzed_rsp(struct MapOprSrv_struct *opr_ptr,u32 buf_len,u8 *buf); + + +/***************** LCS **************/ +int assign_ProvideSubscriberLocation_Res(ProvideSubscriberLocation_Res *ptr,u8 *buf, u8 ver); +int assign_RoutingInfoForLCS_Res(RoutingInfoForLCS_Res *ptr,u8 *buf, u8 ver); +int extract_ProvideSubscriberLocation_Arg(ProvideSubscriberLocation_Arg *ptr,u32 buf_len,u8 *buf); +int extract_RoutingInfoForLCS_Arg(RoutingInfoForLCS_Arg *ptr,u32 buf_len,u8 *buf); +/***************** LCS **************/ + +//show message +int debug_show_REGNOT_ARG(struct IS41_REGNOT_ARG *ptr,char *buf); +int debug_show_REGNOT_RSP(struct IS41_REGNOT_RSP *ptr,char *buf); +int debug_show_LOCREQ_ARG(struct IS41_LOCREQ_ARG *ptr,char *buf); +int debug_show_LOCREQ_RSP(struct IS41_LOCREQ_RSP *ptr,char *buf); +int debug_show_ROUTREQ_ARG(struct IS41_ROUTREQ_ARG *ptr,char *buf); +int debug_show_ROUTREQ_RSP(struct IS41_ROUTREQ_RSP *ptr,char *buf); +int debug_show_TRANUMREQ_ARG(struct IS41_TRANUMREQ_ARG *ptr,char *buf); +int debug_show_TRANUMREQ_RSP(struct IS41_TRANUMREQ_RSP *ptr,char *buf); +int debug_show_SMSREQ_ARG(struct IS41_SMSREQ_ARG *ptr,char *buf); +int debug_show_SMSREQ_RSP(struct IS41_SMSREQ_RSP *ptr,char *buf); +int debug_show_MSINACT_ARG(struct IS41_MSINACT_ARG *ptr,char *buf); +int debug_show_MSINACT_RSP(struct IS41_MSINACT_RSP *ptr,char *buf); +int debug_show_FEATREQ_ARG(struct IS41_FEATREQ_ARG *ptr,char *buf); +int debug_show_FEATREQ_RSP(struct IS41_FEATREQ_RSP *ptr,char *buf); + +int debug_show_AUTHREQ_ARG(IS41_AUTHREQ_ARG *AUTHREQ,char *charOpr); +int debug_show_authreq_rsp(IS41_AUTHREQ_RSP *authreq,char *charOpr); +int debug_show_ASREPORT_ARG(IS41_ASREPORT_ARG *ASREPORT,char *charOpr); +int debug_show_asreport_rsp(IS41_ASREPORT_RSP *asreport,char *charOpr); +int debug_show_BSCHALL_ARG(IS41_BSCHALL_ARG *BSCHALL,char *charOpr); +int debug_show_bschall_rsp(IS41_BSCHALL_RSP *bschall,char *charOpr); +int debug_show_AFREPORT_ARG(IS41_AFREPORT_ARG *AFREPORT,char *charOpr); +int debug_show_afreport_rsp(IS41_AFREPORT_RSP *afreport,char *charOpr); +int auc_debug_show_COUNTREQ_ARG(IS41_COUNTREQ_ARG *COUNTREQ,char *charOpr); +int auc_debug_show_countreq_rsp(IS41_COUNTREQ_RSP *countreq,char *charOpr); +int auc_debug_show_AUTHDIR_ARG(IS41_AUTHDIR_ARG *AUTHDIR,char *charOpr); +int auc_debug_show_authdir_rsp(IS41_AUTHDIR_RSP *authdir,char *charOpr); +#endif diff --git a/omc/plat/xapp/src/mapp/map_const.h b/omc/plat/xapp/src/mapp/map_const.h new file mode 100644 index 0000000..e38d023 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_const.h @@ -0,0 +1,671 @@ +/* MAP const define head file */ +/* written by Liu Zhiguo 2002-01-09 */ +/* Version 1.0 */ +/* -------------------------------- */ +#ifndef _MAP_CONST +#define _MAP_CONST + +#define MAX_TCAPSEND_LEN (TCAP_PARAM_LEN-20) +#define MAX_TCAPSEND_LEN_1 (TCAP_PARAM_LEN_1-20) +#define HLR_SSN 6 +#define VLR_SSN 7 +#define MSC_SSN 8 +#define EIR_SSN 9 +#define AUC_SSN 10 +#define SMSC_SSN 11 +#define GMLC_SSN 0x91 +#define SCF_SSN 0x93 +#define SIWF_SSN 0x94 +#define SGSN_SSN 0x95 +#define GGSN_SSN 0x96 +#define SCF_SSN_USSD 0x99 +#define OPPS_SSN 33 +/* timer values definition, according GSM 09.02 14.1.2 */ +#define SmallTimer 5 +#define MediumTimer 20 +#define MLongTimer 60 +#define LongTimer 108000 + +/* Address string coding, according GSM 09.02 14.7.8 */ +/* extension indicator */ +#define ADD_NOEXT 0x80 // no extension +/* nature of address indicator */ +#define ADD_NAT_INTER 0x10 // international number +#define ADD_NAT_NATSIG 0x20 // national significant number +#define ADD_NAT_NETSPE 0x30 // network specific number +#define ADD_NAT_SUB 0x40 // subscriber number +#define ADD_NAT_ABBR 0x60 // abbreviated number +/* numbering plan indicator */ +#define ADD_PLAN_ISDN 0x01 // ISDN/Teliphony numbering plan (CCITT E.164) +#define ADD_PLAN_DATA 0x03 // data numbering plan (CCITT X.121) +#define ADD_PLAN_TELEX 0x04 // telex numbering plan (CCITT F.69) +#define ADD_PLAN_LANDM 0x06 // land mobile numbering plan (CCITT E.212) +#define ADD_PLAN_NATIONAL 0x08 // national numbering plan +#define ADD_PLAN_PRIV 0x09 //private numbering plan + +/* define the all kinds of parameter length */ +#define SSDATA_NUM 16 +#define SIGNALINFO_LEN 200 +#define ADDRESS_LEN 20 +#define ASCI_LEN 8 // ASCI call reference length +#define ISDN_LEN 9 +#define ISDNSUB_LEN 21 // ISDN subaddressing +#define IMSI_LEN 8 +#define TMSI_LEN 4 +#define IMEI_LEN 8 +#define LMSI_LEN 4 +#define HLRID_NUM 50 +#define NAEA_LEN 3 +#define GCID_LEN 7 // global cell id +#define LAI_LEN 5 +#define SMEA_LEN 12 // SM-RP-SMEA length +#define BSG_LEN 13 // basic service group length +#define CCBS_LEN 5 // CCBS requests number +#define USSD_LEN 160 // USSD string length +#define SS_LEN 30 +#define PASSWD_LEN 4 // password length +#define USSD_LEN 160 // USSD string length +#define EVENT_LEN 2 +//#define FWD_NUM 5 // forwarding number +#define CALLREF_NUM 8 // call reference number +#define TDPDATA_NUM 10 // camel TDP data number +#define MAX_DSTNUM 10 // camel destination number length +#define DSTNUM_LEN 3 // camel destination number-lengths length +#define ISDN_DIGIT 15 // ISDN address digits +#define BSCRIT_LEN 5 // camel basic service criteria length +#define LOCATION_NUM 10 // location number +#define KI_LEN 16 +#define RAND_LEN 16 +#define SRES_LEN 4 +#define KC_LEN 8 +#define AUTHLIST_LEN 5 // authenticate list length +#define GSN_LEN 17 +#define PDP_LEN 17 // PDP address length +#define APN_LEN 63 // APN length +#define PDPCONTEXT_LEN 50 // PDP context length +#define EXTBSG_LEN 32 // extent basic service group +#define BSLIST_LEN 50 // bearer service list length +#define TSLIST_LEN 20 // tele service list length +#define CUGLOCK_LEN 4 // CUG interlock length +#define CUG_LEN 10 +#define ZONECODE_LEN 10 +#define BSL_LEN 70 // basic service list +#define CAMELTDP_LEN 10 +#define VBS_LEN 50 +#define VGCS_LEN 50 +#define CAMELSS_LEN 10 // camel SS event length + +#define CALLBAR_LEN 8 +#define EMLPP_LEN 20 +#define CKSN_LEN 16 + +#define MAX_FWDNUM 5 // MAX forwarding number +#define HLRID_LEN 2 +/* ++++++++++++++++++ */ +/* teliservice codes */ +/* ++++++++++++++++++ */ +#define TS_All 0x00 // all teleservice + +#define TS_AllSTS 0x10 // all speech transmission services +#define TS_PHONY 0x11 // telephony +#define TS_EMERCALL 0x12 // emergency calls + +#define TS_AllSMS 0x20 // all short message services +#define TS_SMMTPP 0x21 // short message MT-PP +#define TS_SMMOPP 0x22 // short message MO-PP + +#define TS_AllFTS 0x60 // all facsimile transmission services +#define TS_FG3AAS 0x61 // facsimile group3 and alter speech +#define TS_AFG3 0x62 // automatic facsimile group3 +#define TS_FG4 0x63 // facsimile group4 + +#define TS_AllData 0x70 // all data teleservices +#define TS_AllEXSMS 0x80 // all teleservices expect SMS + +#define TS_AllVGCS 0x90 // all voice group call services +#define TS_VGC 0x91 // voice group call +#define TS_VBSC 0x92 // voice broadcase call + +#define TS_AllPLMN 0xd0 // all PLMN specific TS +#define TS_PLMN1 0xd1 +#define TS_PLMN2 0xd2 +#define TS_PLMN3 0xd3 +#define TS_PLMN4 0xd4 +#define TS_PLMN5 0xd5 +#define TS_PLMN6 0xd6 +#define TS_PLMN7 0xd7 +#define TS_PLMN8 0xd8 +#define TS_PLMN9 0xd9 +#define TS_PLMNa 0xda +#define TS_PLMNb 0xdb +#define TS_PLMNc 0xdc +#define TS_PLMNd 0xdd +#define TS_PLMNe 0xde +#define TS_PLMNf 0xdf + +/* ++++++++++++++++++++ */ +/* Bearer service codes */ +/* ++++++++++++++++++++ */ +#define BS_All 0x00 // all bearer service + +#define BS_AllDataCDA 0x10 // all data CDA services +#define BS_CDA300 0x11 // data CDA-300 bps +#define BS_CDA1200 0x12 // data CDA-1200 bps +#define BS_CDA7500 0x13 // data CDA-1200-7500 bps +#define BS_CDA2400 0x14 // data CDA-2400 bps +#define BS_CDA4800 0x15 // data CDA-4800 bps +#define BS_CDA9600 0x16 // data CDA-9600 bps +#define BS_CDAGNRL 0x17 // general data CDA + +#define BS_AllDataCDS 0x18 // all data CDS services +#define BS_CDS1200 0x1a // data CDS-1200 bps +#define BS_CDS2400 0x1c // data CDS-2400 bps +#define BS_CDS4800 0x1d // data CDS-4800 bps +#define BS_CDS9600 0x1e // data CDS-9600 bps +#define BS_CDSGNRL 0x1f // general data CDS + +#define BS_AllPACA 0x20 // all pad access CA services +#define BS_PACA300 0x21 // pad access CA-300 bps +#define BS_PACA1200 0x22 // pad access CA-1200 bps +#define BS_PACA7500 0x23 // pad access CA-1200-7500 bps +#define BS_PACA2400 0x24 // pad access CA-2400 bps +#define BS_PACA4800 0x25 // pad access CA-4800 bps +#define BS_PACA9600 0x26 // pad access CA-9600 bps +#define BS_PACAGNRL 0x27 // general pad access CA + +#define BS_AllDPDS 0x28 // all data PDS services +#define BS_DPDS2400 0x2c // data PDS-2400 bps +#define BS_DPDS4800 0x2d // data PDS-4800 bps +#define BS_DPDS9600 0x2e // data PDS-9600 bps +#define BS_DPDSGNRL 0x2f // general data PDS + +#define BS_AllASDCDA 0x30 // all alternate speech data CDA +#define BS_AllASDCDS 0x38 // all alternate speech data CDS +#define BS_AllASFBDCDA 0x40 // all speech followed by Data CDA +#define BS_AllASFBDCDS 0x48 // all speech followed by Data CDS + +#define BS_AllDCA 0x50 // all data circuit asynchronous +#define BS_AllAS 0x60 // all asynchronous services +#define BS_AllDCS 0x58 // all data circuit synchronous +#define BS_AllSS 0x68 // all synchronous services + +#define BS_AllPLMN 0xd0 // all PLMN specific BS +#define BS_PLMN1 0xd1 +#define BS_PLMN2 0xd2 +#define BS_PLMN3 0xd3 +#define BS_PLMN4 0xd4 +#define BS_PLMN5 0xd5 +#define BS_PLMN6 0xd6 +#define BS_PLMN7 0xd7 +#define BS_PLMN8 0xd8 +#define BS_PLMN9 0xd9 +#define BS_PLMNa 0xda +#define BS_PLMNb 0xdb +#define BS_PLMNc 0xdc +#define BS_PLMNd 0xdd +#define BS_PLMNe 0xde +#define BS_PLMNf 0xdf + +/* ++++++++++++++++++++++++++++ */ +/* supplementary service codes */ +/* ++++++++++++++++++++++++++++ */ +#define SS_All 0x00 // (reserved) +#define SS_AllIdent 0x10 // all line identification SS (reserved) +#define SS_CLIP 0x11 // calling line identification presentation +#define SS_CLIR 0x12 // calling line identification restriction +#define SS_COLP 0x13 // connected line identification presentation +#define SS_COLR 0x14 // coonected line identification restriction +#define SS_MCI 0x15 // malicious call identification (reserved) + +#define SS_AllNI 0x18 // all name identification SS +#define SS_CNAP 0x19 // calling name presentation + +#define SS_AllFwd 0x20 // all forwarding SS +#define SS_CFU 0x21 // call forwarding unconditional +#define SS_AllCFwd 0x28 // all conditional forwarding SS +#define SS_CFB 0x29 // call forwarding on mobile suscriber busy +#define SS_CFNRY 0x2a // call forwarding on no reply +#define SS_CFNRC 0x2b // call forwarding on mobile subscriber not reachable +#define SS_CD 0x24 // call deflection + +#define SS_AllCOff 0x30 // all call offering SS (reserved) +#define SS_ECT 0x31 // explicit call transfer +#define SS_MAH 0x32 // mobile access hunting (reserved) + +#define SS_AllCC 0x40 // all call completion SS (reserved) +#define SS_CW 0x41 // call waiting +#define SS_HOLD 0x42 // call hold +#define SS_CCBSA 0x43 // completion of call to busy subscribers,originating side +#define SS_CCBSB 0x44 // completion of call to busy subscribers,destination side + +#define SS_AllMP 0x50 // all multiparty SS (reserved) +#define SS_MULTIPTY 0x51 // multiparty + +#define SS_AllCOI 0x60 // all community of interest SS (reserved) +#define SS_CUG 0x61 // closed user group + +#define SS_AllCHG 0x70 // all charging SS (reserved) +#define SS_AOCI 0x71 // advice of charge information +#define SS_AOCC 0x72 // advice of charge charging + +#define SS_AllAIT 0x80 // all additional information transfer SS (reserved) +#define SS_UUS 0x81 // user to user signalling (reserved) + +#define SS_AllBar 0x90 // all barring SS +#define SS_BOC 0x91 // barring of outgoing calls +#define SS_BAOC 0x92 // barring of all outgoing calls +#define SS_BOIC 0x93 // barring of outgoing international calls +#define SS_BOICEXHC 0x94 // barring of outgoing international calls except to the home PLMN +#define SS_BIC 0x99 // barring of incoming calls +#define SS_BAIC 0x9a // barring of all incoming calls +#define SS_BICROAM 0x9b // barring of incoming calls when roaming outside home PLMN country + +#define SS_AllPLMNS 0xf0 // all PLMN specific SS +#define SS_PLMN1 0xf1 +#define SS_PLMN2 0xf2 +#define SS_PLMN3 0xf3 +#define SS_PLMN4 0xf4 +#define SS_PLMN5 0xf5 +#define SS_PLMN6 0xf6 +#define SS_PLMN7 0xf7 +#define SS_PLMN8 0xf8 +#define SS_PLMN9 0xf9 +#define SS_PLMNa 0xfa +#define SS_PLMNb 0xfb +#define SS_PLMNc 0xfc +#define SS_PLMNd 0xfd +#define SS_PLMNe 0xfe +#define SS_PLMNf 0xff + +#define SS_AllCP 0xa0 // all call priority SS (reserved) +#define SS_EMLPP 0xa1 // enhanced multilevel precedence pre-emption(EMLPP) service + +/* ++++++++++++++++++++++++ */ +/* alerting pattern codes */ +/* ++++++++++++++++++++++++ */ +#define ALT_Lev0 0x00 // alerting level 0 +#define ALT_Lev1 0x01 // alerting level 1 +#define ALT_Lev2 0x02 // alerting level 2 +#define ALT_CATE1 0x04 // alerting category 1 +#define ALT_CATE2 0x05 // alerting category 2 +#define ALT_CATE3 0x06 // alerting category 3 +#define ALT_CATE4 0x07 // alerting category 4 +#define ALT_CATE5 0x08 // alertign category 5 + +/* ++++++++++++++++++++++++ */ +/* EMLPP priority codes */ +/* ++++++++++++++++++++++++ */ +#define EMLPP_LA 0x06 // EMLPP priority level A +#define EMLPP_LB 0x05 // EMLPP priority level B +#define EMLPP_L0 0x00 // EMLPP priority level 0 +#define EMLPP_L1 0x01 // EMLPP priority level 1 +#define EMLPP_L2 0x02 // EMLPP priority level 2 +#define EMLPP_L3 0x03 // EMLPP priority level 3 +#define EMLPP_L4 0x04 // EMLPP priority level 4 + + +/* IS41 */ +#define ESN_LEN 0X04 +#define MIN_LEN 0x05 +#define BIT0_TRUE 0x01 +#define BIT1_TRUE 0x02 +#define BIT2_TRUE 0x04 +#define BIT3_TRUE 0x08 +#define BIT4_TRUE 0x10 +#define BIT5_TRUE 0x20 +#define BIT6_TRUE 0x40 +#define BIT7_TRUE 0x80 +#define BIT8_TRUE 0x100 +#define BIT9_TRUE 0x200 +#define BIT10_TRUE 0x400 +#define BIT11_TRUE 0x800 +#define BIT12_TRUE 0x1000 +#define BIT13_TRUE 0x2000 +#define BIT14_TRUE 0x4000 +#define BIT15_TRUE 0x8000 +#define BIT16_TRUE 0x10000 +#define BIT17_TRUE 0x20000 +#define BIT18_TRUE 0x40000 +#define BIT19_TRUE 0x80000 +#define BIT20_TRUE 0x100000 +#define BIT21_TRUE 0x200000 +#define BIT22_TRUE 0x400000 +#define BIT23_TRUE 0x800000 +#define BIT24_TRUE 0x1000000 +#define BIT25_TRUE 0x2000000 +#define BIT26_TRUE 0x4000000 +#define BIT27_TRUE 0x8000000 +#define BIT28_TRUE 0x10000000 +#define BIT29_TRUE 0x20000000 + +//asn.1 tag +#define IS41PAR_BILLID "1" +#define IS41PAR_SCID "2" +#define IS41PAR_TCID "3" +#define IS41PAR_DIGITS "4" +#define IS41PAR_CD "5" +#define IS41PAR_IMSCCID "6" +#define IS41PAR_ISC "7" +#define IS41PAR_MIN "8"//IMPLICIT OCTET STRING +#define IS41PAR_ESN "9"//IMPLICIT OCTET STRING +#define IS41PAR_RR "10" +#define IS41PAR_SQ "11" +#define IS41PAR_SCM "12" +#define IS41PAR_AUTHDEN "13" +#define IS41PAR_AUTHPER "14" +#define IS41PAR_ST "15" +#define IS41PAR_TS "16" +#define IS41PAR_QUALCODE "17" +#define IS41PAR_FEATRESULT "18" +#define IS41PAR_REDREASON "19" +#define IS41PAR_ACCDEN "20" +#define IS41PAR_MSCID "21" +#define IS41PAR_MYTYP "22" +#define IS41PAR_ORIGIND "23" +#define IS41PAR_TERMRES "24" +#define IS41PAR_CFI "25" +#define IS41PAR_FP "26" +#define IS41PAR_UID "27" +#define IS41PAR_TDMACD "28" +#define IS41PAR_TDMACM "29" +#define IS41PAR_HR "30" +#define IS41PAR_TDMABID "31" +#define IS41PAR_PCSSN "32" +#define IS41PAR_LOCID "33"//IMPLICIT OCTET STRING +#define IS41PAR_SYSACCTYPE "34" +#define IS41PAR_AUTHR "35" +#define IS41PAR_AUTHBS "36" +#define IS41PAR_AUTHU "37"//IMPLICIT OCTET STRING +#define IS41PAR_COUNT "38"//IMPLICIT Unsigned Integer (0..63) +#define IS41PAR_CMODES "39" +#define IS41PAR_RAND "40" +#define IS41PAR_RANDBS "41" +#define IS41PAR_RANDSSD "42"//IMPLICIT OCTET STRING +#define IS41PAR_RANDU "43"//IMPLICIT OCTET STRING +#define IS41PAR_RPTTYP "44"//IMPLICIT Unsigned Enumerated +//#define IS41PAR_RPTTYP2 "44-2"//IMPLICIT Unsigned Enumerated +#define IS41PAR_SMEKEY "45" +#define IS41PAR_SSD "46"//IMPLICIT OCTET STRING +#define IS41PAR_TERMTYP "47" +#define IS41PAR_VPMASK "48" +#define IS41PAR_SYSCAP "49" +#define IS41PAR_DENACC "50" +#define IS41PAR_UPDCOUNT "51"//IMPLICIT Unsigned Enumerated +#define IS41PAR_NOSSD "52"//IMPLICIT Unsigned Enumerated +#define IS41PAR_EXTMSCID "53" +#define IS41PAR_EXTMYTYP "54" +#define IS41PAR_CCDATA "55" +#define IS41PAR_SYSACCDATA "56" +#define IS41PAR_CANCD "57" +#define IS41PAR_BORDACC "58" +#define IS41PAR_CDMASCM "59" +#define IS41PAR_CDMASOWD "60" +#define IS41PAR_CDMATOWD "61" +#define IS41PAR_CDMACM "62" +#define IS41PAR_CDMACD "63" +#define IS41PAR_CDMASQ "64" +#define IS41PAR_CDMAPS "65" +#define IS41PAR_CDMAMPR "66" +#define IS41PAR_CDMAPLCM "67" +#define IS41PAR_CDMACC "68" +#define IS41PAR_CDMASW "69" +#define IS41PAR_MSLOC "70" +#define IS41PAR_PID "71" +#define IS41PAR_RSIGQUAL "72" +#define IS41PAR_DEREG "73" +#define IS41PAR_NAMPSCD "74" +#define IS41PAR_ALRTCODE "75" +#define IS41PAR_ANCC "76" +#define IS41PAR_AAV "77"//IMPLICIT OCTET STRING +#define IS41PAR_AUTHCAP "78" +#define IS41PAR_COUNTEx "79" +#define IS41PAR_CPNDGTS1 "80" +#define IS41PAR_CPNDGTS2 "81" +#define IS41PAR_CPNSTRG1 "82" +#define IS41PAR_CPNSTRG2 "83" +#define IS41PAR_CPSUB "84" +#define IS41PAR_CANTP "85" +#define IS41PAR_CARDGTS "86" +#define IS41PAR_DESTDGTS "87" +#define IS41PAR_REDIND "88" +#define IS41PAR_ISTERM "89" +#define IS41PAR_AVTYP "90" +#define IS41PAR_LOCTERM "91" +#define IS41PAR_MWNCOUNT "92" +#define IS41PAR_MDN "93" +#define IS41PAR_MSCIN "94" +#define IS41PAR_PSTNTERM "95" +#define IS41PAR_NATIME "96" +#define IS41PAR_OTFI "97" +#define IS41PAR_ORIGTRIG "98" +#define IS41PAR_RANDC "99" +#define IS41PAR_RNDGTS "100" +#define IS41PAR_RNSTRING "101" +#define IS41PAR_RSUB "102" +#define IS41PAR_SENDERIN "103"//IMPLICIT DigitsType +#define IS41PAR_SMSADDR "104" +#define IS41PAR_SMSBD "105" +#define IS41PAR_SMSCID "106" +#define IS41PAR_SMSDA "107" +#define IS41PAR_SMSMSGCNT "108" +#define IS41PAR_SMSNOTIND "109" +#define IS41PAR_SMSODA "110" +#define IS41PAR_SMSODS "111" +#define IS41PAR_SMSOOA "112" +#define IS41PAR_SMSOOS "113" +#define IS41PAR_SMSOA "114" +#define IS41PAR_SMSORGRES "115" +#define IS41PAR_SMSTID "116" +#define IS41PAR_SMSTERMRES "117" +#define IS41PAR_SMSMWI "118" +#define IS41PAR_TAT "119" +#define IS41PAR_TERMLIST "120" +#define IS41PAR_TERMTRMT "121" +#define IS41PAR_TERMTRIG "122" +#define IS41PAR_TRANSCAP "123" +#define IS41PAR_UCHALRPT "124" +//#define IS41PAR_RESERVED "125" +//#define IS41PAR_RESERVED "126" +//#define IS41PAR_RESERVED "127" +#define IS41PAR_ACTCODE "128" +#define IS41PAR_AR "129" +#define IS41PAR_ANNLIST "130" +#define IS41PAR_CDMACCI "131" +#define IS41PAR_CDMACCL "132" +#define IS41PAR_CDMATMI "133" +#define IS41PAR_CDMATML "134" +#define IS41PAR_CDMATMAHOI "135" +#define IS41PAR_CDMATMAHOL "136" +#define IS41PAR_CCI "137" +#define IS41PAR_COUNTRPT "138" +#define IS41PAR_DIGITCC "139"//IMPLICIT Unsigned Enumerated +#define IS41PAR_ACDGTS "140" +#define IS41PAR_ABDGTS "141" +#define IS41PAR_BILLDGTS "142" +#define IS41PAR_GEOAUTH "143" +#define IS41PAR_LEGINFO "144" +#define IS41PAR_MWNTYPE "145" +#define IS41PAR_PACAIND "146" +#define IS41PAR_PLIND "147" +#define IS41PAR_RANDVT "148" +#define IS41PAR_RESDGTS "149" +#define IS41PAR_ROUTDGTS "150" +#define IS41PAR_SR "151" +#define IS41PAR_SMSACCDEN "152" +#define IS41PAR_SMSCC "153" +#define IS41PAR_SPINIPIN "154" +#define IS41PAR_SPINITRIG "155" +#define IS41PAR_SSDURPT "156" +#define IS41PAR_TMINFO "157" +#define IS41PAR_TML "158" +#define IS41PAR_VMSPIN "159" +#define IS41PAR_VMBOX "160" +#define IS41PAR_AUTHDATA "161" +#define IS41PAR_CDEN "162" +#define IS41PAR_GRPINFO "163" +#define IS41PAR_HOS "164" +#define IS41PAR_NAMPSCM "165" +#define IS41PAR_CDMASCI "166" +#define IS41PAR_DENAUTHPER "167" +#define IS41PAR_PILOT "168" +#define IS41PAR_PILOTBID "169" +#define IS41PAR_GLOBALTITLE "261" +#define IS41PAR_RESUMEPIC "266" +#define IS41PAR_TRIGADRLIST "276" +#define IS41PAR_TRIGCAP "277" +#define IS41PAR_TRIGLIST "278" +#define IS41PAR_WINCAP "280" +#define IS41PAR_WINOPRCAP "281" +#define IS41PAR_WINTRIGLIST "283" +#define IS41PAR_DMH_SVCID "286" +//N.S0013-0 "WIN Phase 1" +#define IS41PAR_EXESCR "258" +#define IS41PAR_PSR "265" +#define IS41PAR_SCRARG "267" +#define IS41PAR_SCRNAME "268" +#define IS41PAR_SCRRESULT "269" +//#define IS41PAR_SR "274" +#define IS41PAR_TDO "275" +#define IS41PAR_TRIGERTYPE "279" +//N.S0018 "TIA/EIA-41-D Pre-Paid Charging(Revision: 1)" +#define IS41PAR_FEATIND "306" +#define IS41PAR_RELCAUSE "308" +#define IS41PAR_TOD "309" +#define IS41PAR_CALLSTATUS "310" +//N.S0009 "IMSI" +#define IS41PAR_IMSI "242" +//N.S0012 "CNAP/CNAR" +#define IS41PAR_CPNAME "243" +#define IS41PAR_DISPTEXT "244" +#define IS41PAR_RDNAME "245" +#define IS41PAR_SRVID "246" +//X.S0010 "Pre-Paid Charging Enhancements for Circuit-Switched Data and Short Message Services" +#define IS41PAR_SMSBRLEN "382" +#define IS41PAR_SMSBILLID "383" +#define IS41PAR_SMSEVENT "384" +#define IS41PAR_SMSEVENTNOT "385" +#define IS41PAR_SMSPMCNT "386" + + +//is41 operations +#define IS41OPR_HandoffMeasurementRequest 0x01 +#define IS41OPR_FacilitiesDirective 0x02 +#define IS41OPR_MobileOnChannel 0x03 +#define IS41OPR_HandoffBack 0x04 +#define IS41OPR_FacilitiesRelease 0x05 +#define IS41OPR_QualificationRequest 0x06 +#define IS41OPR_QualificationDirective 0x07 +#define IS41OPR_Blocking 0x08 +#define IS41OPR_Unblocking 0x09 +#define IS41OPR_ResetCircuit 0x0a +#define IS41OPR_TrunkTest 0x0b +#define IS41OPR_TrunkTestDisconnect 0x0c +#define IS41OPR_RegistrationNotification 0x0d +#define IS41OPR_RegistrationCancellation 0x0e +#define IS41OPR_LocationRequest 0x0f +#define IS41OPR_RoutingRequest 0x10 +#define IS41OPR_FeatureRequest 0x11 +#define IS41OPR_ServiceProfileRequest 0x12 +#define IS41OPR_ServiceProfileDirective 0x13 +#define IS41OPR_UnreliableRoamerDataDirective 0x14 +#define IS41OPR_CallDataREquest 0x15 +#define IS41OPR_MSInactive 0x16 +#define IS41OPR_TransferToNumberRequest 0x17 +#define IS41OPR_RedirectionRequest 0x18 +#define IS41OPR_HandoffToThird 0x19 +#define IS41OPR_FlashRequest 0x1a +#define IS41OPR_AuthenticationDirective 0x1b +#define IS41OPR_AuthenticationRequest 0x1c +#define IS41OPR_BaseStationChallenge 0x1d +#define IS41OPR_AuthenticationFailureReport 0x1e +#define IS41OPR_CountRequest 0x1f +#define IS41OPR_InterSystemPage 0x20 +#define IS41OPR_UnsolicitedResponse 0x21 +#define IS41OPR_BulkDeregistration 0x22 +#define IS41OPR_HandoffMeasurementRequest2 0x23 +#define IS41OPR_FacilitiesDirective2 0x24 +#define IS41OPR_HandoffBack2 0x25 +#define IS41OPR_HandoffToThird2 0x26 +#define IS41OPR_AuthenticationDirectiveForward 0x27 +#define IS41OPR_AuthenticationStatusReport 0x28 +#define IS41OPR_InformationBackward 0x29 +#define IS41OPR_InformationDirective 0x2a +#define IS41OPR_InformationForward 0x2b +#define IS41OPR_InterSystemAnswer 0x2c +#define IS41OPR_InterSystemPage2 0x2d +#define IS41OPR_InterSystemSetup 0x2e +#define IS41OPR_OriginationRequest 0x2f +#define IS41OPR_RandomVariableRequest 0x30 +#define IS41OPR_RedirectionDirective 0x31 +#define IS41OPR_RemoteUserInteractionDirective 0x32 +#define IS41OPR_SMSDeliveryBackward 0x33 +#define IS41OPR_SMSDeliveryForward 0x34 +#define IS41OPR_SMSDeliveryPointToPoint 0x35 +#define IS41OPR_SMSNotification 0x36 +#define IS41OPR_SMSRequest 0x37 +//N.S0013-0 "WIN Phase 1" +#define IS41OPR_AnalyzedInformation 64 +#define IS41OPR_ConnectionFailureReport 65 +#define IS41OPR_ConnectResource 66 +#define IS41OPR_DisconnectResource 67 +#define IS41OPR_FacilitySelectedAndAvailable 68 +#define IS41OPR_InstructionRequest 69 +#define IS41OPR_Modify 70 +#define IS41OPR_ResetTimer 71 +#define IS41OPR_Search 72 +#define IS41OPR_SeizeResource 73 +#define IS41OPR_SRFDirective 74 +#define IS41OPR_TBusy 75 +#define IS41OPR_TNoAnswer 76 +//N.S0018 "TIA/EIA-41-D Pre-Paid Charging(Revision: 1)" +#define IS41OPR_BulkDisconnection 80 +#define IS41OPR_CallControlDirective 81 +#define IS41OPR_OAnswer 82 +#define IS41OPR_ODisconnect 83 +#define IS41OPR_CallRecoveryReport 84 +#define IS41OPR_TAnswer 85 +#define IS41OPR_TDisconnect 86 +#define IS41OPR_UnreliableCallData 87 +//X.S0010-A "Pre-Paid Charging Enhancements for Circuit-Switched Data and Short Message Services" +#define IS41OPR_ShortMessageAnalyzed 105 + +// debug +#define IS41DB_DEBUG 0x01 +#define IS41DB_ENCODE 0x02 +#define IS41DB_DECODE 0x04 +#define IS41DB_FLOW 0x08 +#define IS41DB_ERR 0x10 + + +#define IS41ERR_UNRECOGNIZED_MIN 0x81 +#define IS41ERR_UNRECOGNIZED_ESN 0x82 +#define IS41ERR_MIN_HLR_MISMATCH 0x83 +#define IS41ERR_OPERATION_SEQUENCE_PROBLEM 0x84 +#define IS41ERR_RESOURCE_SHORTAGE 0x85 +#define IS41ERR_OPERATION_NOT_SUPPORTED 0x86 +#define IS41ERR_TRUNK_UNAVAILABLE 0x87 +#define IS41ERR_PARAMETER_ERROR 0x88 +#define IS41ERR_SYSTEM_FAILURE 0x89 +#define IS41ERR_UNRECOGNIZED_PARAMETER_VALUE 0x8a +#define IS41ERR_FEATURE_INACTIVE 0x8b +#define IS41ERR_MISSING_PARAMETER 0x8c + +// asn.1 +#define SET_NATIONAL "18" +#define ASN_OCTET_STRING "4" +#define ASN_INTEGER "2" +#define ASN_NULL "5" +#define ASN_ENUMERATED "10" +#define ASN_SEQUENCE "16" +#define ASN_SET "17" + +#define ISDN_LEN 9 + +#define MAX_TCAPSEND_LEN (TCAP_PARAM_LEN-20) +#define MAX_TCAPSEND_LEN_1 (TCAP_PARAM_LEN_1-20) +#define MAX_IS41_VARPAR_LEN 32 +#define MAX_IS41_VARPAR_LEN_1 31 +#define MAX_IS41_TRIG_LIST_NUM 4 +#define MAX_IS41_TRIG_LIST_NUM_1 3 + +#endif diff --git a/omc/plat/xapp/src/mapp/map_dlgpdu.h b/omc/plat/xapp/src/mapp/map_dlgpdu.h new file mode 100644 index 0000000..1168163 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_dlgpdu.h @@ -0,0 +1,104 @@ +/* MAP dialogue PDU head file */ +/* written by Liu zhiguo 2002-01-14 */ +/* Version 1.0 (according GSM 09.02 17.4) */ +/* ------------------------------------- */ +#ifndef _MAP_DLGPDU +#define _MAP_DLGPDU + +#define MAPDLG_OPEN 0x00 +#define MAPDLG_ACCEPT 0x01 +#define MAPDLG_CLOSE 0x02 +#define MAPDLG_REFUSE 0x03 +#define MAPDLG_UABORT 0x04 // user abort +#define MAPDLG_PABORT 0x05 // provider abort + +/* +++++++++++++++++++++++++ */ +/* MAP-Openinfo */ +/* +++++++++++++++++++++++++ */ +typedef struct MapDlgOpen_struct +{ + u8 param_flag; + u8 peer_ref[ISDN_LEN+1]; // peer reference + u8 local_ref[ISDN_LEN+1]; // local reference +} MapDlgOpen_struct; + +/* +++++++++++++++++++++++++ */ +/* MAP-Refuseinfo */ +/* +++++++++++++++++++++++++ */ +typedef enum MapDlgReason_enum +{ + noReasonGiven = 0, + invalidDstRef = 1, // invalid destination reference + invalidOrgRef = 2 // invalid original reference +} MapDlgReason_enum; + +typedef struct MapDlgRefuse_struct +{ + u8 param_flag; + enum MapDlgReason_enum reason; +} MapDlgRefuse_struct; + +/* +++++++++++++++++++++++++ */ +/* MAP-UserAbortinfo */ +/* +++++++++++++++++++++++++ */ +typedef enum MapDlgRUReason_enum // resource unavailable reason +{ + shortTRLimit = 0, // short term resource limitation + longTRLimit = 1 // long term resource limitation +} MapDlgRUReason_enum; + +typedef enum MapDlgPCReason_enum // procedure cancellation reason +{ + handoverCancel = 0, // hand over cancellation + radioChanRelease = 1, // radio channel release + netPathRelease = 2, // network path release + callRelease = 3, // call release + assProFailure = 4, // associated procedure failure + randomDialRelease = 5, // random dialogue release + remOperFailure = 6 // remote operation failure +} MapDlgPCReason_enum; + +typedef struct MapDlgUAbort_struct +{ + u8 choice_flag; // user abort choice + union + { + enum MapDlgRUReason_enum resunavi; // resource unavailable, choice_flag = 2 + enum MapDlgPCReason_enum appproccancel; // application procedure cancellation, choice_flag = 3 + } choice; +} MapDlgUAbort_struct; + +/* +++++++++++++++++++++++++ */ +/* MAP-UserAbortinfo */ +/* +++++++++++++++++++++++++ */ +typedef enum MapDlgPAbortReason_enum +{ + abnormaldial = 0, // abnormal dialogue + invalidPDU = 1 +} MapDlgPAbortReason_enum; + +typedef struct MapDlgPAbort_struct // MAP provider abort info +{ + u8 param_flag; + enum MapDlgPAbortReason_enum reason; +} MapDlgPAbort_struct; + +/* +++++++++++++++++++++++++ */ +/* MAP-DialoguePDU */ +/* +++++++++++++++++++++++++ */ +typedef struct MapDlg_struct +{ + u8 dlg_type; + union + { + struct MapDlgOpen_struct map_open; + struct MapDlgRefuse_struct map_refuse; + struct MapDlgUAbort_struct map_uabort; + struct MapDlgPAbort_struct map_pabort; + } map_dlg; +} MapDlg_struct; + +u8 build_mapdlg(struct MapDlg_struct *dlg_ptr,u8 *data_buf); +u8 extract_mapdlg(struct MapDlg_struct *dlg_ptr,struct dlgport_struct *port_ptr); + +#endif diff --git a/omc/plat/xapp/src/mapp/map_includes.h b/omc/plat/xapp/src/mapp/map_includes.h new file mode 100644 index 0000000..4153ab2 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_includes.h @@ -0,0 +1,24 @@ +////////////////////////////////////////////////// +//Title : map_includes.c +//Auhtor : Liu Wei +//Desc : map include headers +//Created : 2007-05-18 +//Revision : +// +//Revision : +// +////////////////////////////////////////////////// + + +#ifndef _MAP_INCLUDES_H_ +#define _MAP_INCLUDES_H_ + + +#include "../../../public/src/include/pub_include.h" +#include "../../../sccp/src/include/sccp.h" +#include "map_const.h" +#include "map_struct.h" +#include "map_coding.h" +#include "map_public.h" + +#endif diff --git a/omc/plat/xapp/src/mapp/map_opr_func.h b/omc/plat/xapp/src/mapp/map_opr_func.h new file mode 100644 index 0000000..89f0583 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_opr_func.h @@ -0,0 +1,34 @@ +/* MAP extension operation */ +/* ------------------------------------- */ +#ifndef _MAP_OPR_FUNC +#define _MAP_OPR_FUNC + +#include "map_includes.h" +#include "../xap_interfunc.h" +#include "map_code.h" + +extern int assign_MapDetermineOprUserArg(struct MapDetermineOprUser_Arg *dou_ptr,u8 *buf, u8 ver); +extern int extract_MapDetermineOprUserArg(struct MapDetermineOprUser_Arg *dou_ptr,u32 buf_len,u8 *buf); +extern int assign_MapDetermineOprUserRes(struct MapDetermineOprUser_Res *dou_ptr,u8 *buf, u8 ver); +extern int extract_MapDetermineOprUserRes(struct MapDetermineOprUser_Res *dou_ptr,u32 buf_len,u8 *buf); + +extern int assign_MapVlrUpdateLocationArg(struct MapVlrUpdateLocation_Arg *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapVlrUpdateLocationArg(struct MapVlrUpdateLocation_Arg *cuwm_ptr,u32 buf_len,u8 *buf); +extern int assign_MapVlrUpdateLocationRes(struct MapVlrUpdateLocation_Res *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapVlrUpdateLocationRes(struct MapVlrUpdateLocation_Res *cuwm_ptr,u32 buf_len,u8 *buf); + +extern int assign_MapCreateUserWithMsisdnImsiArg(struct MapCreateUserWithMsisdnImsi_Arg *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapCreateUserWithMsisdnImsiArg(struct MapCreateUserWithMsisdnImsi_Arg *cuwm_ptr,u32 buf_len,u8 *buf); +extern int assign_MapCreateUserWithMsisdnImsiRes(struct MapCreateUserWithMsisdnImsi_Res *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapCreateUserWithMsisdnImsiRes(struct MapCreateUserWithMsisdnImsi_Res *cuwm_ptr,u32 buf_len,u8 *buf); + +extern int assign_MapDeleteOprUserArg(struct MapDeleteOprUser_Arg *dou_ptr,u8 *buf, u8 ver); +extern int extract_MapDeleteOprUserArg(struct MapDeleteOprUser_Arg *dou_ptr,u32 buf_len,u8 *buf); +extern int assign_MapDeleteOprUserRes(struct MapDeleteOprUser_Res *dou_ptr,u8 *buf, u8 ver); +extern int extract_MapDeleteOprUserRes(struct MapDeleteOprUser_Res *dou_ptr,u32 buf_len,u8 *buf); + +extern int assign_MapVlrEnquiryIMDM_Arg(struct MapVlrEnquiryIMDM_Arg *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapVlrEnquiryIMDM_Arg(struct MapVlrEnquiryIMDM_Arg *cuwm_ptr,u32 buf_len,u8 *buf); +extern int assign_MapVlrEnquiryIMDM_Res(struct MapVlrEnquiryIMDM_Res *cuwm_ptr,u8 *buf, u8 ver); +extern int extract_MapVlrEnquiryIMDM_Res(struct MapVlrEnquiryIMDM_Res *cuwm_ptr,u32 buf_len,u8 *buf); +#endif diff --git a/omc/plat/xapp/src/mapp/map_public.c b/omc/plat/xapp/src/mapp/map_public.c new file mode 100644 index 0000000..9f3ef0e --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_public.c @@ -0,0 +1,1108 @@ +/* MAP public function c file */ +/* Written by Liu Zhiguo 2002-03-25 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "map_includes.h" +#include "map_code.h" + +#define MAP_CODE_DEBUG 0 +static int map_code_debug1 = 1; + +#if _SUPPORT_ANSI +extern u8 map_check_map_flag(u32 did); +#endif + +void log_doit(int errnoflag, int priority, const char *fmt, va_list ap) +{ + int errno_save; + char buf[2048]; + + errno_save = errno; //value caller might want printed + vsprintf(buf, fmt, ap); + if (errnoflag) + sprintf(buf+strlen(buf), ": %s", strerror(errno_save)); + strcat(buf, "\n"); + if (map_code_debug1) + { + fflush(stdout); + fputs(buf, stderr); + fflush(stderr); + } + else + syslog(priority, buf); + return; +} + +void mapp_log_debug(const char *fmt, ...) +{ +#if MAP_CODE_DEBUG + va_list ap; + + va_start(ap, fmt); + log_doit(0,LOG_ERR, fmt, ap); + printf(fmt, ap); + va_end(ap); + return; +#endif +} + +u8 bytestrtobitstr(u8 *bit_str,u8 *byte_str,u8 bit_len) +{ // byte string code to bit string code + u8 ii; + u8 aa,bb,cc; + u8 str_len; + u8 null_len; + + str_len = bit_len / 8; + null_len = bit_len % 8; + if (null_len != 0) + { + str_len += 2; + bit_str[0] = 8 - null_len; + } + else + { + str_len += 1; + bit_str[0] = 0; + } + memset(bit_str+1,0,str_len-1); + for (ii = 0;ii < bit_len;ii ++) + { + aa = ii / 8; + bb = str_len - aa - 1; + cc = (byte_str[aa] >> (ii % 8)) & 0x01; + bit_str[bb] |= cc << (7 - (ii % 8)); + } + return str_len; +} + +u8 bitstrtobytestr(u8 *byte_str,u8 *bit_str,u8 bit_len) +{ + u8 ii; + u8 aa,bb,cc; + u8 str_len; + u8 total_len; + + str_len = bit_len - 1; + total_len = str_len * 8 - bit_str[0]; + memset(byte_str,0,str_len); + for (ii = 0;ii < total_len;ii ++) + { + aa = ii / 8 + 1; + bb = str_len - ii / 8 - 1; + cc = (bit_str[aa] >> (7 - (ii % 8))) & 0x01; + byte_str[bb] |= cc << (ii % 8); + } + return str_len; +} + +/* transfer tele service from bit string to bcd string */ +u8 tele_bittostr(u16 tele_data,u8 *tele_str,u8 ss_flag) +{ + u8 len=0; + u16 temp_data; + + temp_data = tele_data; + if ((temp_data & 0x1ff) == 0x1ff && ss_flag) // has all tele data + { + tele_str[0] = TS_All; + return 1; // tele service list length + } + if ((temp_data & 0x7c) == 0x7c && ss_flag) + { + tele_str[len++] = TS_AllData; + temp_data &= ~0x7c; + } + if ((temp_data & 0x73) == 0x73 && ss_flag) + { + tele_str[len++] = TS_AllEXSMS; + temp_data &= ~0x73; + } + if ((temp_data & 0x03) == 0x03 && ss_flag) + { + tele_str[len++] = TS_AllSTS; + temp_data &= ~0x03; + } + if ((temp_data & 0x01) == 0x01) + { + tele_str[len++] = TS_PHONY; + temp_data &= ~0x01; + } + if ((temp_data & 0x02) == 0x02) + { + tele_str[len++] = TS_EMERCALL; + temp_data &= ~0x02; + } + if ((temp_data & 0x0c) == 0x0c && ss_flag) + { + tele_str[len++] = TS_AllSMS; + temp_data &= ~0x0c; + } + if ((temp_data & 0x04) == 0x04) + { + tele_str[len++] = TS_SMMTPP; + temp_data &= ~0x04; + } + if ((temp_data & 0x08) == 0x08) + { + tele_str[len++] = TS_SMMOPP; + temp_data &= ~0x08; + } + if ((temp_data & 0x70) == 0x70 && ss_flag) + { + tele_str[len++] = TS_AllFTS; + temp_data &= ~0x70; + } + if ((temp_data & 0x10) == 0x10) + { + tele_str[len++] = TS_FG3AAS; + temp_data &= ~0x10; + } + if ((temp_data & 0x20) == 0x20) + { + tele_str[len++] = TS_AFG3; + temp_data &= ~0x20; + } + if ((temp_data & 0x40) == 0x40) + { + tele_str[len++] = TS_FG4; + temp_data &= ~0x40; + } + if ((temp_data & 0x180) == 0x180 && ss_flag) + { + tele_str[len++] = TS_AllVGCS; + temp_data &= ~0x180; + } + if ((temp_data & 0x80) == 0x80) + { + tele_str[len++] = TS_VGC; + temp_data &= ~0x80; + } + if ((temp_data & 0x100) == 0x100) + { + tele_str[len++] = TS_VBSC; + temp_data &= ~0x100; + } + return len; +} + +/* transfer tele service from bcd string to bit string */ +u16 tele_strtobit(u8 *tele_str,u8 tele_len) +{ + u16 tele_data=0; + u8 ii; + + for (ii = 0;ii < tele_len;ii ++) + { + switch (tele_str[ii]) + { + case TS_All: + tele_data |= 0x1ff; + break; + case TS_AllSTS: + tele_data |= 0x03; + break; + case TS_PHONY: + tele_data |= 0x01; + break; + case TS_EMERCALL: + tele_data |= 0x02; + break; + case TS_AllSMS: + tele_data |= 0x0c; + break; + case TS_SMMTPP: + tele_data |= 0x04; + break; + case TS_SMMOPP: + tele_data |= 0x08; + break; + case TS_AllFTS: + tele_data |= 0x70; + break; + case TS_FG3AAS: + tele_data |= 0x10; + break; + case TS_AFG3: + tele_data |= 0x20; + break; + case TS_FG4: + tele_data |= 0x40; + break; + case TS_AllData: + tele_data |= 0x7c; + break; + case TS_AllEXSMS: + tele_data |= 0x73; + break; + case TS_AllVGCS: + tele_data |= 0x180; + break; + case TS_VGC: + tele_data |= 0x80; + break; + case TS_VBSC: + tele_data |= 0x100; + break; + default: +// tele_data = 0; + break; + } + } + return tele_data; +} + +/* tranfer bearer service from bit string to bcd string */ +u8 bearer_bittostr(u32 bearer_data, u8 *bearer_str,u8 ss_flag) +{ +// u8 ii=0,jj; + u8 len=0; + u32 temp_data; + + temp_data = bearer_data; + if ((temp_data & 0x7ffffff) == 0x7ffffff && ss_flag) + { + bearer_str[0] = BS_All; + return 1; // bearer service list length + } + if ((temp_data & 0x287f07f) == 0x287f07f && ss_flag) + { + bearer_str[len++] = BS_AllAS; + temp_data &= ~0x287f07f; + } + if ((temp_data & 0x280007f) == 0x280007f && ss_flag) + { + bearer_str[len++] = BS_AllDCA; + temp_data &= ~0x280007f; + } + if ((temp_data & 0x280007f) == 0x5780f80 && ss_flag) + { + bearer_str[len++] = BS_AllSS; + temp_data &= ~0x5780f80; + } + if ((temp_data & 0x280007f) == 0x5000f80 && ss_flag) + { + bearer_str[len++] = BS_AllDCS; + temp_data &= ~0x5000f80; + } + if ((temp_data & 0x7f) == 0x7f && ss_flag) // all data CDA + { + bearer_str[len++] = BS_AllDataCDA; + temp_data &= ~0x7f; + } + if ((temp_data & 0x01) == 0x01) + { + bearer_str[len++] = BS_CDA300; + temp_data &= ~0x01; + } + if ((temp_data & 0x02) == 0x02) + { + bearer_str[len++] = BS_CDA1200; + temp_data &= ~0x02; + } + if ((temp_data & 0x04) == 0x04) + { + bearer_str[len++] = BS_CDA7500; + temp_data &= ~0x04; + } + if ((temp_data & 0x08) == 0x08) + { + bearer_str[len++] = BS_CDA2400; + temp_data &= ~0x08; + } + if ((temp_data & 0x10) == 0x10) + { + bearer_str[len++] = BS_CDA4800; + temp_data &= ~0x10; + } + if ((temp_data & 0x20) == 0x20) + { + bearer_str[len++] = BS_CDA9600; + temp_data &= ~0x20; + } + if ((temp_data & 0x40) == 0x40) + { + bearer_str[len++] = BS_CDAGNRL; + temp_data &= ~0x40; + } + if ((temp_data & 0x800000) == 0x800000) + { + bearer_str[len++] = BS_AllASDCDA; + temp_data &= ~0x800000; + } + if ((temp_data & 0x2000000) == 0x2000000) + { + bearer_str[len++] = BS_AllASFBDCDA; + temp_data &= ~0x2000000; + } + if ((temp_data & 0x7f000) == 0x7f000 && ss_flag) // all PDA acccess CDA + { + bearer_str[len++] = BS_AllPACA; + temp_data &= ~0x7f000; + } + if ((temp_data & 0x1000) == 0x1000) + { + bearer_str[len++] = BS_PACA300; + temp_data &= ~0x1000; + } + if ((temp_data & 0x2000) == 0x2000) + { + bearer_str[len++] = BS_PACA1200; + temp_data &= ~0x2000; + } + if ((temp_data & 0x4000) == 0x4000) + { + bearer_str[len++] = BS_PACA7500; + temp_data &= ~0x4000; + } + if ((temp_data & 0x8000) == 0x8000) + { + bearer_str[len++] = BS_PACA2400; + temp_data &= ~0x8000; + } + if ((temp_data & 0x10000) == 0x10000) + { + bearer_str[len++] = BS_PACA4800; + temp_data &= ~0x10000; + } + if ((temp_data & 0x20000) == 0x20000) + { + bearer_str[len++] = BS_PACA9600; + temp_data &= ~0x20000; + } + if ((temp_data & 0x40000) == 0x40000) + { + bearer_str[len++] = BS_PACAGNRL; + temp_data &= ~0x40000; + } + if ((temp_data & 0xf80) == 0xf80 && ss_flag) // all data CDS + { + bearer_str[len++] = BS_AllDataCDS; + temp_data &= ~0xf80; + } + if ((temp_data & 0x80) == 0x80) + { + bearer_str[len++] = BS_CDS1200; + temp_data &= ~0x80; + } + if ((temp_data & 0x100) == 0x100) + { + bearer_str[len++] = BS_CDS2400; + temp_data &= ~0x100; + } + if ((temp_data & 0x200) == 0x200) + { + bearer_str[len++] = BS_CDS4800; + temp_data &= ~0x200; + } + if ((temp_data & 0x400) == 0x400) + { + bearer_str[len++] = BS_CDS9600; + temp_data &= ~0x400; + } + if ((temp_data & 0x800) == 0x800) + { + bearer_str[len++] = BS_CDSGNRL; + temp_data &= ~0x800; + } + if ((temp_data & 0x1000000) == 0x1000000) + { + bearer_str[len++] = BS_AllASDCDS; + temp_data &= ~0x1000000; + } + if ((temp_data & 0x4000000) == 0x4000000) + { + bearer_str[len++] = BS_AllASFBDCDS; + temp_data &= ~0x4000000; + } + if ((temp_data & 0x780000) == 0x780000 && ss_flag) // all PDA acccess CDS + { + bearer_str[len++] = BS_AllDPDS; + temp_data &= ~0x780000; + } + if ((temp_data & 0x80000) == 0x80000) + { + bearer_str[len++] = BS_DPDS2400; + temp_data &= ~0x80000; + } + if ((temp_data & 0x100000) == 0x100000) + { + bearer_str[len++] = BS_DPDS4800; + temp_data &= ~0x100000; + } + if ((temp_data & 0x200000) == 0x200000) + { + bearer_str[len++] = BS_DPDS9600; + temp_data &= ~0x200000; + } + if ((temp_data & 0x400000) == 0x400000) + { + bearer_str[len++] = BS_DPDSGNRL; + temp_data &= ~0x400000; + } + return len; +} + +u32 bearer_strtobit(u8 *bearer_str,u8 bearer_len) +{ + u8 ii; + u32 bearer_data=0; + + for (ii = 0;ii < bearer_len;ii ++) + { + switch (bearer_str[ii]) + { + case BS_All: + bearer_data |= 0x7ffffff; + break; + case BS_AllDataCDA: + bearer_data |= 0x7f; + break; + case BS_CDA300: + bearer_data |= 0x01; + break; + case BS_CDA1200: + bearer_data |= 0x02; + break; + case BS_CDA7500: + bearer_data |= 0x04; + break; + case BS_CDA2400: + bearer_data |= 0x08; + break; + case BS_CDA4800: + bearer_data |= 0x10; + break; + case BS_CDA9600: + bearer_data |= 0x20; + break; + case BS_CDAGNRL: + bearer_data |= 0x40; + break; + case BS_AllDataCDS: + bearer_data |= 0xf80; + break; + case BS_CDS1200: + bearer_data |= 0x80; + break; + case BS_CDS2400: + bearer_data |= 0x100; + break; + case BS_CDS4800: + bearer_data |= 0x200; + break; + case BS_CDS9600: + bearer_data |= 0x400; + break; + case BS_CDSGNRL: + bearer_data |= 0x800; + break; + case BS_AllPACA: + bearer_data |= 0x7f000; + break; + case BS_PACA300: + bearer_data |= 0x1000; + break; + case BS_PACA1200: + bearer_data |= 0x2000; + break; + case BS_PACA7500: + bearer_data |= 0x4000; + break; + case BS_PACA2400: + bearer_data |= 0x8000; + break; + case BS_PACA4800: + bearer_data |= 0x10000; + break; + case BS_PACA9600: + bearer_data |= 0x20000; + break; + case BS_PACAGNRL: + bearer_data |= 0x40000; + break; + case BS_AllDPDS: + bearer_data |= 0x780000; + break; + case BS_DPDS2400: + bearer_data |= 0x80000; + break; + case BS_DPDS4800: + bearer_data |= 0x100000; + break; + case BS_DPDS9600: + bearer_data |= 0x200000; + break; + case BS_DPDSGNRL: + bearer_data |= 0x400000; + break; + case BS_AllASDCDA: + bearer_data |= 0x800000; + break; + case BS_AllASDCDS: + bearer_data |= 0x1000000; + break; + case BS_AllASFBDCDA: + bearer_data |= 0x2000000; + break; + case BS_AllASFBDCDS: + bearer_data |= 0x4000000; + break; + default: + bearer_data = 0; + break; + } + } + return bearer_data; +} + +void get_sccpadd(struct SCCP_ADDRESS *add_ptr,u8 *data) +{ + u8 temp_len; + + add_ptr->ip = (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]; + add_ptr->DPC = (data[4]<<24) + (data[5]<<16) + (data[6]<<8) + data[7]; + add_ptr->NetID = data[8]; + add_ptr->SSN = data[9]; + add_ptr->RI = data[10]; + add_ptr->GTI = data[11]; + add_ptr->TT = data[12]; + add_ptr->NP = data[13]; + add_ptr->ES = data[14]; + add_ptr->NAI = data[15]; + add_ptr->len = data[16]; + temp_len = (data[16] + 1) / 2; + memcpy(add_ptr->GTAI,data+17,temp_len); +} + +void set_sccpadd(struct SCCP_ADDRESS *add_ptr,u8 *data) +{ + u8 temp_len; + + data[0] = add_ptr->ip >> 24; + data[1] = add_ptr->ip >> 16; + data[2] = add_ptr->ip >> 8; + data[3] = add_ptr->ip; + data[4] = add_ptr->DPC >> 24; + data[5] = add_ptr->DPC >> 16; + data[6] = add_ptr->DPC >> 8; + data[7] = add_ptr->DPC; + data[8] = add_ptr->NetID; + data[9] = add_ptr->SSN; + data[10] = add_ptr->RI; + data[11] = add_ptr->GTI; + data[12] = add_ptr->TT; + data[13] = add_ptr->NP; + data[14] = add_ptr->ES; + data[15] = add_ptr->NAI; + data[16] = add_ptr->len; + temp_len = (add_ptr->len + 1) / 2; + memcpy(data+17,add_ptr->GTAI,temp_len); +} + +u8 map_com_ftos(struct MapComSrv_struct *map_com,u8 *data_flow) +{ // common service data flow to structure + u32 aa; + u32 len; + u8 ii; + u8 delimiter_flag = 0; + struct MapOpen_Arg *open_arg; + struct MapOpen_Res *open_res; + struct MapClose_Arg *close_ptr; + struct MapUAbort_Arg *uabrt_ptr; + struct MapPAbort_Arg *pabrt_ptr; + + len = (data_flow[0] << 8) + data_flow[1]; + if (len < 9) // data flow is too short + return 0; + if ((data_flow[2] != MAP_FLAG) && + (data_flow[2] != IS41_FLAG) ) + return 0; + map_com->map_flag = data_flow[2]; + map_com->port_id = (data_flow[3] << 8) + data_flow[4]; + map_com->dialogue_id = (data_flow[6] << 8) + data_flow[7]; + map_com->message_type = data_flow[9]; + map_com->message_flag = data_flow[10]; + switch (map_com->message_type) + { + case MAP_OPEN: + if (map_com->message_flag == MAP_REQUEST || map_com->message_flag == MAP_INDICATE) + { + open_arg = (MapOpen_Arg *) &map_com->dlg_list.open_arg; + open_arg->acn_data.acn = data_flow[11]; + open_arg->acn_data.acn_ver = data_flow[12]; + get_sccpadd(&open_arg->peer_add,data_flow+13); + get_sccpadd(&open_arg->local_add,data_flow+41); + open_arg->param_flag = 0x0b; + aa = 70; + for (ii = 0;ii < 3;ii ++) + { + if (data_flow[aa] == 0x00) + break; + else if (data_flow[aa] == 0x01) // peer reference + { + len = data_flow[aa+1]; + if (len > ISDN_LEN) + return 0; + open_arg->peerref_len = len; + memcpy(open_arg->peer_reference,&data_flow[aa+2],len); + aa += len + 2; + open_arg->param_flag |= 0x04; + } + else if (data_flow[aa] == 0x02) // local reference + { + len = data_flow[aa+1]; + if (len > ISDN_LEN) + return 0; + open_arg->localref_len = len; + memcpy(open_arg->local_reference,&data_flow[aa+2],len); + aa+= len + 2; + open_arg->param_flag |= 0x10; + } + else if (data_flow[aa] == 0x03) // specific info + { + len = data_flow[aa+1]; + if (len >= MAX_SPCINFO_LEN) + return 0; + open_arg->specific_info.info_len = len; + memcpy(open_arg->specific_info.info_data,&data_flow[aa+2],len); + open_arg->param_flag |= 0x20; + aa += 2 + len; + } + else if (data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + xap_watch_dog(66); + } + } + } + else if (map_com->message_flag == MAP_RESPONSE || map_com->message_flag == MAP_CONFIRM) + { + open_res = (MapOpen_Res *) &map_com->dlg_list.open_res; + open_res->result = data_flow[11]; + open_res->param_flag = 0x08; + aa = 13; + for (ii = 0;ii < 4;ii ++) + { + if (data_flow[aa] == 0x00) + break; + else if (data_flow[aa] == 0x01) // acn + { + open_res->acn_data.acn = data_flow[aa+2]; + open_res->acn_data.acn_ver = data_flow[aa+3]; + aa += 4; + open_res->param_flag |= 0x01; + } + else if (data_flow[aa] == 0x02) // specific info + { + len = data_flow[aa+1]; + if (len >= MAX_SPCINFO_LEN) + return 0; + open_res->specific_info.info_len = len; + memcpy(open_res->specific_info.info_data,&data_flow[aa+2],len); + open_res->param_flag |= 0x02; + aa += 2 + len; + } + else if (data_flow[aa] == 0x03) // refuse reason + { + open_res->refuse_reason = data_flow[aa+2]; + open_res->param_flag |= 0x10; + aa += 3; + } + else if (data_flow[aa] == 0x04) // provider error + { + open_res->provider_error = data_flow[aa+2]; + open_res->param_flag |= 0x20; + aa += 3; + } + else if (data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + xap_watch_dog(69); + } + } + } + else + return 0; + break; + case MAP_CLOSE: + close_ptr = (MapClose_Arg *) &map_com->dlg_list.close_arg; + close_ptr->release_method = data_flow[11]; + close_ptr->param_flag = 0x01; + if (data_flow[13] == 0x01) + { + len = data_flow[14]; + if (len >= MAX_SPCINFO_LEN) + return 0; + close_ptr->specific_info.info_len = len; + memcpy(close_ptr->specific_info.info_data,&data_flow[15],len); + close_ptr->param_flag |= 0x02; + } + break; + case MAP_U_ABORT: + uabrt_ptr = (MapUAbort_Arg *) &map_com->dlg_list.uabort_arg; + uabrt_ptr->user_reason = data_flow[11]; + uabrt_ptr->param_flag = 0x01; + aa = 13; + for (ii = 0;ii < 2;ii ++) + { + if (data_flow[aa] == 0) + break; + else if (data_flow[aa] == 0x01) // diagnostic flag + { + uabrt_ptr->diag_info = data_flow[aa+2]; + uabrt_ptr->param_flag |= 0x02; + aa += 3; + } + else if (data_flow[aa] == 0x02) // specific info + { + len = data_flow[aa+1]; + if (len >= MAX_SPCINFO_LEN) + return 0; + uabrt_ptr->specific_info.info_len = len; + memcpy(uabrt_ptr->specific_info.info_data,&data_flow[aa+2],len); + uabrt_ptr->param_flag |= 0x04; + aa += 2 + len; + } + } + break; + case MAP_P_ABORT: + pabrt_ptr = (MapPAbort_Arg *) &map_com->dlg_list.pabort_arg; + pabrt_ptr->provider_reason = data_flow[11]; + pabrt_ptr->source = data_flow[12]; + pabrt_ptr->param_flag = 0x03; + break; + case MAP_NOTICE: + map_com->dlg_list.notice_arg.problem = data_flow[11]; + map_com->dlg_list.notice_arg.param_flag = 0x01; + break; + case MAP_DELIMITER: + case MAP_LINK: + break; + default: + return 0; + break; + } + if (delimiter_flag == 1) + { + xap_watch_dog(67); + return 2; + } + else + return 1; +} + +void map_com_stof(struct MapComSrv_struct *com_ptr,u8 *data_flow,u8 delimiter_flag) +{ // transfer common structure to data flow + u32 ii; + u32 len; + struct MapOpen_Arg *open_arg; + struct MapOpen_Res *open_res; + struct MapClose_Arg *close_arg; + struct MapUAbort_Arg *uabrt_arg; + +#if _SUPPORT_ANSI + if (map_check_map_flag(com_ptr->dialogue_id)) +#endif + data_flow[2] = MAP_FLAG; +#if _SUPPORT_ANSI + else + data_flow[2] = IS41_FLAG; +#endif + data_flow[3] = com_ptr->port_id >> 8; + data_flow[4] = com_ptr->port_id; + data_flow[6] = com_ptr->dialogue_id >> 8; + data_flow[7] = com_ptr->dialogue_id; + data_flow[9] = com_ptr->message_type; + data_flow[10] = com_ptr->message_flag; + ii = 11; + switch (com_ptr->message_type) + { + case MAP_OPEN: + if (com_ptr->message_flag == MAP_INDICATE || com_ptr->message_flag == MAP_REQUEST) + { + open_arg = (MapOpen_Arg *) &com_ptr->dlg_list.open_arg; + data_flow[ii++] = open_arg->acn_data.acn; + data_flow[ii++] = open_arg->acn_data.acn_ver; + set_sccpadd(&open_arg->peer_add,data_flow+ii); + ii += 28; + set_sccpadd(&open_arg->local_add,data_flow+ii); + ii += 28; + data_flow[ii++] = 1; // optional point + if ((open_arg->param_flag & 0x04)) // has peer reference address + { + data_flow[ii++] = 0x01; + len = open_arg->peerref_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,open_arg->peer_reference,len); + ii += len; + } + if ((open_arg->param_flag & 0x10)) // has local reference address + { + data_flow[ii++] = 0x02; + len = open_arg->localref_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,open_arg->local_reference,len); + ii += len; + } + if ((open_arg->param_flag & 0x20)) + { + data_flow[ii++] = 0x03; + len = open_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,open_arg->specific_info.info_data,len); + ii += len; + } + if (delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + xap_watch_dog(63); + } + data_flow[ii++] = 0x00; + } + else if (com_ptr->message_flag == MAP_RESPONSE || com_ptr->message_flag == MAP_CONFIRM) + { + open_res = (MapOpen_Res *) &com_ptr->dlg_list.open_res; + data_flow[ii++] = open_res->result; + data_flow[ii++] = 0x01; // optional point + if ((open_res->param_flag & 0x01)) // has ACN + { + data_flow[ii++] = 0x01; + data_flow[ii++] = 2; + data_flow[ii++] = open_res->acn_data.acn; + data_flow[ii++] = open_res->acn_data.acn_ver; + } + if ((open_res->param_flag & 0x02)) // has specific info + { + data_flow[ii++] = 0x02; + len = open_res->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,open_res->specific_info.info_data,len); + ii += len; + } + if ((open_res->param_flag & 0x10)) // has refuse reason + { + data_flow[ii++] = 0x03; + data_flow[ii++] = 1; + data_flow[ii++] = open_res->refuse_reason; + } + if ((open_res->param_flag & 0x20)) // has provider error + { + data_flow[ii++] = 0x04; + data_flow[ii++] = 1; + data_flow[ii++] = open_res->provider_error; + } + if (delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + } + data_flow[ii++] = 0x00; + } + break; + case MAP_CLOSE: + close_arg = (MapClose_Arg *) &com_ptr->dlg_list.close_arg; + data_flow[ii++] = close_arg->release_method; + data_flow[ii++] = 0x01; // optional point + if ((close_arg->param_flag & 0x02)) // has specific info + { + data_flow[ii++] = 0x01; + len = close_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,close_arg->specific_info.info_data,len); + ii += len; + } + data_flow[ii++] = 0x00; + break; + case MAP_U_ABORT: + uabrt_arg = (MapUAbort_Arg *) &com_ptr->dlg_list.uabort_arg; + data_flow[ii++] = uabrt_arg->user_reason; + data_flow[ii++] = 0x01; // optional point + if ((uabrt_arg->param_flag & 0x02)) + { + data_flow[ii++] = 0x01; + data_flow[ii++] = 1; + data_flow[ii++] = uabrt_arg->diag_info; + } + if ((uabrt_arg->param_flag & 0x04)) // has specific info + { + data_flow[ii++] = 0x02; + len = uabrt_arg->specific_info.info_len; + data_flow[ii++] = len; + memcpy(data_flow+ii,uabrt_arg->specific_info.info_data,len); + ii += len; + } + data_flow[ii++] = 0x00; + break; + case MAP_P_ABORT: + data_flow[ii++] = com_ptr->dlg_list.pabort_arg.provider_reason; + data_flow[ii++] = com_ptr->dlg_list.pabort_arg.source; + break; + case MAP_NOTICE: + data_flow[ii++] = com_ptr->dlg_list.notice_arg.problem; + break; + default: + break; + } + ii -= 2; + data_flow[0] = ii >> 8; + data_flow[1] = ii; +} + +u8 map_opr_ftos(struct MapOprData_struct *opr_ptr,u8 *data_flow) +{ // transfer opration data flow to structure + u32 aa; + u32 total_len,len; + u8 ii; + u8 delimiter_flag = 0; + + total_len = (data_flow[0] << 8) + data_flow[1]; + if (total_len < 10) + return 0; + if ((data_flow[2] != MAP_FLAG) && + (data_flow[2] != IS41_FLAG) ) + return 0; + opr_ptr->map_flag = data_flow[2]; + opr_ptr->port_id = (data_flow[3] << 8) + data_flow[4]; + opr_ptr->dialogue_id = (data_flow[6] << 8) + data_flow[7]; + opr_ptr->message_type = data_flow[9]; + opr_ptr->message_flag = data_flow[10]; + opr_ptr->invoke_id = data_flow[11]; + opr_ptr->param_flag = 0x1f; + opr_ptr->param_len = 0; + aa = 13; + for (ii = 0;ii < 3;ii ++) + { + if(aa>=total_len+2) + break; + + if (data_flow[aa] == 0x00) + break; + else if (data_flow[aa] == 0x01) // parameter + { + len = (data_flow[aa+1] << 8) + data_flow[aa+2]; + if (len > MAX_MAPPOPR_LEN) + return 0; + opr_ptr->param_len = len; + memcpy(opr_ptr->param,&data_flow[aa+3],len); + aa += len + 3; + opr_ptr->param_flag |= 0x20; + } + else if (data_flow[aa] == 0x02) // user error + { + opr_ptr->user_error = data_flow[aa+2]; + opr_ptr->param_flag |= 0x40; + aa += 3; + } + else if (data_flow[aa] == 0x03) // provider error + { + opr_ptr->provider_error = data_flow[aa+2]; + opr_ptr->param_flag |= 0x80; + aa += 3; + } + else if (data_flow[aa] == 0x04) // linked id + { + opr_ptr->linked_id = data_flow[aa+2]; + opr_ptr->param_flag |= 0x100; + aa += 3; + } + else if (data_flow[aa] == 0x10) + { + delimiter_flag = 1; + aa += 2; + ii = 3; + xap_watch_dog(70); + break; + } + } + if (delimiter_flag == 1) + return 2; + else + return 1; +} + +void map_opr_stof(struct MapOprData_struct *opr_ptr,u8 *data_flow,u8 delimiter_flag) +{ // transfer opration structure to data flow + u32 ii; + u32 len; + +#if _SUPPORT_ANSI + if (map_check_map_flag(opr_ptr->dialogue_id)) +#endif + data_flow[2] = MAP_FLAG; +#if _SUPPORT_ANSI + else + data_flow[2] = IS41_FLAG; +#endif + data_flow[3] = opr_ptr->port_id >> 8; + data_flow[4] = opr_ptr->port_id; + data_flow[6] = opr_ptr->dialogue_id >> 8; + data_flow[7] = opr_ptr->dialogue_id; + data_flow[9] = opr_ptr->message_type; + data_flow[10] = opr_ptr->message_flag; + data_flow[11] = opr_ptr->invoke_id; + data_flow[12] = 1; + ii = 13; + if ((opr_ptr->param_flag & 0x20)) // has component + { + data_flow[ii++] = 0x01; + len = opr_ptr->param_len; + data_flow[ii++] = len >> 8; + data_flow[ii++] = len; + memcpy(data_flow+ii,opr_ptr->param,len); + ii += len; + } + if ((opr_ptr->param_flag & 0x40)) // has user error + { + data_flow[ii++] = 0x02; + data_flow[ii++] = 1; + data_flow[ii++] = opr_ptr->user_error; + } + if ((opr_ptr->param_flag & 0x80)) // has provider error + { + data_flow[ii++] = 0x03; + data_flow[ii++] = 1; + data_flow[ii++] = opr_ptr->provider_error; + } + if ((opr_ptr->param_flag & 0x100)) // has linked id + { + data_flow[ii++] = 0x04; + data_flow[ii++] = 1; + data_flow[ii++] = opr_ptr->linked_id; + } + if (delimiter_flag == 1) + { + data_flow[ii++] = 0x10; + data_flow[ii++] = 0x00; + } + data_flow[ii++] = 0; + ii -= 2; + data_flow[0] = ii >> 8; + data_flow[1] = ii; +} + +char *is41_sequenceTag(char *tag,int sequence) +{ + static char sTag[32]; + + sprintf(sTag,"%s-%d",tag,sequence); + return sTag; +} + +int decode_Is41Parameter(char *tag,int len,BYTE *value,ASN_BUF *asn_buf) +{ + int decodeLen; + u8 temp_buf[256]; + + decodeLen = GetTLV(tag,len,temp_buf,0x80,asn_buf); + if ((decodeLen <= len) && (decodeLen > 0)) + { + memcpy(value,temp_buf,decodeLen); + return decodeLen; + } + return 0; +} diff --git a/omc/plat/xapp/src/mapp/map_public.h b/omc/plat/xapp/src/mapp/map_public.h new file mode 100644 index 0000000..bec18e4 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_public.h @@ -0,0 +1,26 @@ +/* MAP public head file */ +/* written by Liu Zhiguo 2002-03-27 */ +/* version 1.0 */ +/* -------------------------------- */ + +#ifndef _MAP_PUBLIC +#define _MAP_PUBLIC + +void mapp_log_debug(const char *fmt, ...); + +u8 bytestrtobitstr(u8 *bit_str,u8 *byte_str,u8 bit_len); +u8 bitstrtobytestr(u8 *byte_str,u8 *bit_str,u8 bit_len); +u8 tele_bittostr(u16 tele_data,u8 *tele_str,u8 ss_flag); +u16 tele_strtobit(u8 *tele_str,u8 tele_len); +u8 bearer_bittostr(u32 bearer_data, u8 *bearer_str,u8 ss_flag); +u32 bearer_strtobit(u8 *bearer_str,u8 bearer_len); +void get_sccpadd(struct SCCP_ADDRESS *add_ptr,u8 *data); +void set_sccpadd(struct SCCP_ADDRESS *add_ptr,u8 *data); +u8 map_com_ftos(struct MapComSrv_struct *map_com,u8 *data_flow); +void map_com_stof(struct MapComSrv_struct *com_ptr,u8 *data_flow,u8 delimiter_flag); +u8 map_opr_ftos(struct MapOprData_struct *opr_ptr,u8 *data_flow); +void map_opr_stof(struct MapOprData_struct *opr_ptr,u8 *data_flow,u8 delimiter_flag); + +char *is41_sequenceTag(char *tag,int sequence); + +#endif diff --git a/omc/plat/xapp/src/mapp/map_struct.h b/omc/plat/xapp/src/mapp/map_struct.h new file mode 100644 index 0000000..139dab1 --- /dev/null +++ b/omc/plat/xapp/src/mapp/map_struct.h @@ -0,0 +1,3643 @@ +/* MAP data structure head file */ +/* Written by Liu zhiguo 2003-03-04 */ +/* Version 2.0 */ +/* --------------------------------- */ + +#ifndef _MAP_STRUCT +#define _MAP_STRUCT + +#include "map_LCSCode.h" + +#define RER 0 +#define ROK 1 + +#define MAP_FLAG 0x8f +#define IS41_FLAG 0x8e +#define MAX_SPCINFO_LEN 32 // specific information length +#define MAX_MAPPOPR_LEN 1024 + +int decErr; + +/* MAP data structure. In here, ignore the extention portion */ +/* common service for MAP */ +typedef struct MapOpen_Arg // open argument +{ + u32 param_flag; + struct + { + u8 acn; + u8 acn_ver; + } acn_data; // application context name + struct SCCP_ADDRESS peer_add; + u8 peerref_len; + u8 peer_reference[ISDN_LEN+1]; + struct SCCP_ADDRESS local_add; + u8 localref_len; + u8 local_reference[ISDN_LEN+1]; + struct + { + u8 info_len; + u8 info_data[MAX_SPCINFO_LEN]; + } specific_info; +} MapOpen_Arg; + + +typedef struct map_open_arg_param{ + u32 pid; + u32 did; + u8 uDelimeterFlag; + SCCP_ADDR local_add; + SCCP_ADDR peer_add; + u8 acn; +} +MapOpenArgParam; + +typedef struct MapOpen_Res // open response +{ + u32 param_flag; + struct + { + u8 acn; + u8 acn_ver; + } acn_data; // application context name + struct + { + u8 info_len; + u8 info_data[MAX_SPCINFO_LEN]; + } specific_info; + struct SCCP_ADDRESS respond_add; + u8 result; + u8 refuse_reason; + u8 provider_error; +} MapOpen_Res; + +typedef struct MapClose_Arg // close argument +{ + u32 param_flag; + u8 release_method; + struct + { + u8 info_len; + u8 info_data[MAX_SPCINFO_LEN]; + } specific_info; +} MapClose_Arg; + +typedef struct MapUAbort_Arg // u-abort argument +{ + u32 param_flag; + u8 user_reason; + u8 diag_info; // diagnostic info + struct + { + u8 info_len; + u8 info_data[MAX_SPCINFO_LEN]; + } specific_info; +} MapUAbort_Arg; + +typedef struct MapPAbort_Arg // p-abort argument +{ + u32 param_flag; + u8 provider_reason; + u8 source; +} MapPAbort_Arg; + +typedef struct MapNotice_Arg // notice argument +{ + u32 param_flag; + u8 problem;// problem diagnostic +} MapNotice_Arg; + +typedef struct MapComSrv_struct // common service +{ + u8 map_flag;//is41 or map + u32 port_id; + u32 dialogue_id; + u8 message_type; + u8 message_flag; // distinguish REQUEST,INDICATE,RESPONSE,CONFIRM + u8 component_present; + union + { + struct MapOpen_Arg open_arg; + struct MapOpen_Res open_res; + struct MapClose_Arg close_arg; + struct MapUAbort_Arg uabort_arg; + struct MapPAbort_Arg pabort_arg; + struct MapNotice_Arg notice_arg; + } dlg_list; +} MapComSrv_struct; + +/* ************************ */ +/* MAP operation structure */ +/* ************************ */ + +/* ++++++++++++++++++++++++++++++++++++ */ +/* common data types, occording 17.7.8 */ +/* ++++++++++++++++++++++++++++++++++++ */ +typedef enum ProtocolId_enum // protocol id +{ + gsm0408 = 1, + gsm0806 = 2, + gsmBSSMAP = 3, + ets3001021 = 4 +} ProtocolId_enum; + +typedef enum NetRes_enum // network resource +{ + plmn = 0, + hlr = 1, + vlr = 2, + pvlr = 3, + ctrmsc = 4, // controlling MSC + vmsc = 5, + eir = 6, + rss = 7 +} NetRes_enum; + +typedef struct SigInfo_struct // signal information +{ + u8 siginfo_len; + u8 signal_info[SIGNALINFO_LEN]; // signal information +} SigInfo_struct; + +typedef struct ExtSigInfo_struct // external signal information +{ + u8 param_flag; + enum ProtocolId_enum prt_id; // protocol id + struct SigInfo_struct siginfo; +} ExtSigInfo_struct; // can not used in version 2 + +typedef struct SubId_struct // subscriber ID +{ + u8 choice_flag; + union + { + u8 imsi[IMSI_LEN]; // flag = 1 + u8 tmsi[TMSI_LEN]; // flag = 2 + } id_choice; +} SubId_struct; + +typedef struct NaeaPrefCi_struct // NAEA preferred CI +{ + u8 cic[NAEA_LEN]; // NAEA CIC +} NaeaPrefCi_struct; + +typedef struct CellIdLai_struct // cell id or lai +{ + u8 choice_flag; + union + { + u8 cellid[GCID_LEN]; // flag = 1 + u8 lai[LAI_LEN]; // flag = 2 + } cell_choice; +} CellIdLai_struct; + +typedef struct BSCode_struct // basic service code +{ + u8 param_flag; + u16 tele_code; + u32 bearer_code; +} BSCode_struct; + +typedef struct BS_Choice //MAP V1 Basic service +{ + u8 choice_flag; + union + { + u8 bear_service; + u8 tele_service; + } choice; +} BS_Choice; + +typedef struct EmlppInfo_struct // EMLPP info +{ + u8 param_flag; + u8 maxent_prio; // maximum entitle priority + u8 default_prio; // default priority +} EmlppInfo_struct; + +/* +++++++++++++++++++++++++++++++++++++++++ */ +/* short message structure, according 17.7.6 */ +/* +++++++++++++++++++++++++++++++++++++++++ */ +typedef enum SMDeliOutcome_enum // SM delivery outcome +{ + MemCapExceed = 0, // memory capacity exceeded + AbsSub = 1, // absent subscriber + SuccessTrans = 2 // successful transfer +} SMDeliOutcome_enum; + +typedef enum AltReason_enum // alert reason +{ + ms_present = 0, + mem_avail = 1 +} AltReason_enum; + +typedef struct AddNum_struct // additional number +{ + u8 choice_flag; + union + { + u8 msc_num[ISDN_LEN+1]; // MSC number,flag = 1 + u8 sgsn_num[ISDN_LEN+1]; // SGSN number,flag = 2 + } choice; +} AddNum_struct; + +typedef struct LocInfoLMSI_struct // location info with LMSI +{ + u8 param_flag; + u8 netnode_num[ISDN_LEN+1]; // network node number + u8 lmsi[LMSI_LEN]; + u8 gprsnode_flag; // GPRS node indicator + struct AddNum_struct add_num;// additional number +} LocInfoLMSI_struct; + +typedef struct SmRpDa_struct // SM-RP-DA +{ + u8 choice_flag; + union + { + u8 imsi[IMSI_LEN]; // flag = 1 + u8 lmsi[LMSI_LEN]; // flag = 2 + u8 sc_add[ISDN_LEN+1]; // service centre address DA, flag = 3 + u8 no_rpda; // has not SM RP DA,flag = 4 + u8 roaming_num[ISDN_LEN+1]; + } choice; +} SmRpDa_struct; + +typedef struct SmRpOa_struct // SM-RP-OA +{ + u8 choice_flag; + union + { + u8 msisdn[ISDN_LEN+1]; // flag = 1 + u8 sc_add[ISDN_LEN+1]; // service centre address DA, flag = 2 + u8 no_rpoa; // has not SM RP OA, flag = 3 + } choice; +} SmRpOa_struct; + +typedef struct MapRIFSM_Arg // routing info for SM argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; + u8 sm_rp_pri; + u8 sc_add[ISDN_LEN+1]; // service centre address + u8 gprssup_flag; // GPRS support indicator + u8 sm_rp_mti; + u8 sm_rp_smea[SMEA_LEN+1]; +} MapRIFSM_Arg; + +typedef struct MapRIFSM_Res // routing info for SM response +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + struct LocInfoLMSI_struct loc_info; // location info with lmsi + u8 user_error; + u8 provider_error; +} MapRIFSM_Res; + +typedef struct LocInfoLMSI_struct_v1 +{ + u32 param_flag; + u8 choice_flag; + union + { + u8 roaming_num[ISDN_LEN+1]; + u8 msc_num[ISDN_LEN+1]; + } choice; + u8 imsi[IMSI_LEN]; +} LocInfoLMSI_struct_v1; + +typedef struct MapRIFSMV1_Arg // routing info for SM argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; + u8 sm_rp_pri; + u8 sc_add[ISDN_LEN+1]; // service centre address + u8 tele_service; +} MapRIFSMV1_Arg; + +typedef struct MapRIFSMV1_Res // routing info for SM response +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + LocInfoLMSI_struct_v1 loc_info; // location info with lmsi + u8 mwd_set; // boolean optional + u8 user_error; + u8 provider_error; +} MapRIFSMV1_Res; + +typedef struct MapMOFSM_Arg // MO forward SM argument +{ + u32 param_flag; + struct SmRpDa_struct sm_rp_da; + struct SmRpOa_struct sm_rp_oa; + struct SigInfo_struct sm_rp_ui; +} MapMOFSM_Arg; + +typedef struct MapMOFSM_Res // MO forward SM response +{ + u32 param_flag; + struct SigInfo_struct sm_rp_ui; + u8 user_error; + u8 provider_error; +} MapMOFSM_Res; + +typedef struct MapMTFSM_Arg // MT forward SM argument +{ + u32 param_flag; + struct SmRpDa_struct sm_rp_da; + struct SmRpOa_struct sm_rp_oa; + struct SigInfo_struct sm_rp_ui; + u8 moremsg_flag; // more message to send +} MapMTFSM_Arg; + +typedef struct MapMTFSM_Res // MT forward SM response +{ + u32 param_flag; + struct SigInfo_struct sm_rp_ui; + u8 user_error; + u8 provider_error; +} MapMTFSM_Res; + +typedef struct MapFSM_Arg +{ + u32 param_flag; + union // sm_rp_da + { + u8 imsi[IMSI_LEN]; + u8 lmsi[LMSI_LEN]; + u8 roaming_num[ISDN_LEN+1]; + u8 sc_add[ISDN_LEN+1]; // service centre address + u8 noms_rp_da; + } sm_rp_da; + u8 sm_rp_da_choice; + + union //sm_rp_oa + { + u8 msisdn[ISDN_LEN]; + u8 sc_add[ISDN_LEN+1]; // service centre address + u8 noms_rp_oa; + } sm_rp_oa; + u8 sm_rp_oa_choice; + + u8 sm_rp_ui_len; + u8 sm_rp_ui[200]; //sm_rp_ui + + u8 more_msgtosend; //more_msgtosend +} MapFSM_Arg; + +typedef struct MapTSA_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 trace_ref[2]; + u8 trace_type; + u8 omc_id_len; + u8 omc_id[20]; + u8 call_ref[3]; +} MapTSA_Arg; + +typedef struct MapRSMDS_Arg // report SM delivery status argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; + u8 sc_add[ISDN_LEN+1]; // service centre address + enum SMDeliOutcome_enum sm_deliout; // sm-delivery outcome + u8 abssubdiagsm; // absent subscriber diagnostic SM + u8 gprssup_flag; // GPRS support indicator + u8 deliout_flag; // delivery outcome indicator + enum SMDeliOutcome_enum addsm_deliout; // additional sm-delivery outcome + u8 add_abssubdiagsm; // additional absent subscriber diagnostic SM +} MapRSMDS_Arg; + +typedef struct MapRSMDS_Res // report SM delivery status response +{ + u32 param_flag; + u8 stored_msisdn[ISDN_LEN+1]; // stored MSISDN + u8 user_error; + u8 provider_error; +} MapRSMDS_Res; + +typedef struct MapASC_Arg // alert service centre argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; + u8 sc_add[ISDN_LEN+1];// service center address +} MapASC_Arg; + +typedef struct MapASC_Res // alert service centre response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapASC_Res; + +typedef struct MapISC_Arg // inform service centre argument +{ + u32 param_flag; + u8 stored_msisdn[ISDN_LEN+1]; // stored MSISDN + u16 mw_status; // MW-status +} MapISC_Arg; + +typedef struct MapRFSM_Arg // ready for SM argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + enum AltReason_enum alert_reason; // alert reason + u8 altreason_flag; // alert reason indicator +} MapRFSM_Arg; + +typedef struct MapRFSM_Res // ready for SM response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapRFSM_Res; + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* supplementary service data structure, according 17.7.4 */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +typedef enum CliResOpt_enum // Cli restriction option +{ + permanent = 0, + temdefres = 1, // temporary default restricted + temdefall = 2 // temporary default allowed +} CliResOpt_enum; + +typedef enum OverCate_enum // override category +{ + overenable = 0, // override enabled + overdisable = 1 // override disabled +} OverCate_enum; + +typedef enum GuiInfo_enum // guidance info +{ + enterpw = 0, + enternewpw = 1, + enternewpw_again = 2 +} GuiInfo_enum; + +typedef struct FwdFeat_struct // forward feature +{ + u8 param_flag; + struct BSCode_struct bs_code; + u8 ss_status; + u8 fwdto_num[ISDN_LEN+1]; // forward to number + u8 fwd_option; // forward option + u8 norc_time; // no reply condition time +} FwdFeat_struct; +/* +typedef struct FwdFeat // MAP V1 forward feature +{ + u8 param_flag; + struct BS_Choice bs; + u8 ss_status; + u8 fwdto_num[ISDN_LEN+1]; // forward to number + u8 fwdto_subaddr_len; + u8 fwdto_subaddr[21]; //forward to subaddress + u8 fwd_option; // forward option + u8 norc_time; // no reply condition time +} FwdFeat; +*/ +typedef struct FwdInfo_struct //forwarding info +{ + u8 param_flag; + u8 ss_code; + struct FwdFeat_struct fwd_feat; +// struct +// { +// u8 fwdfeat_len; +// struct FwdFeat_struct fwd_feat[BSG_LEN]; +// } fwdfeat_list; +} FwdInfo_struct; + +typedef struct CBFeat_struct // call barring feature +{ + u8 param_flag; + struct BSCode_struct bs_code; + u8 ss_status; +} CBFeat_struct; + +typedef struct CBInfo_struct // call barring info +{ + u8 param_flag; + u8 ss_code; + struct CBFeat_struct cb_feat; +// struct +// { +// u8 cbfeat_len; +// struct CBFeat_struct cb_feat[BSG_LEN]; +// } cbfeat_list; +} CBInfo_struct; + +typedef struct SsSubsOpt_struct // SS subscription option +{ + u8 choice_flag; + union + { + enum CliResOpt_enum clires_opt; // cli restriction option,flag=1 + enum OverCate_enum over_cate; // override category,flag=2 + } choice; +} SsSubsOpt_struct; + +typedef struct SsData_struct // SS data +{ + u8 param_flag; + u8 ss_code; + u8 ss_status; + struct SsSubsOpt_struct subs_opt; // ss subscription option + struct BSCode_struct bs_code; // basic service code + u8 default_prio; // default priority (EMLPP priority) +} SsData_struct; + +typedef struct SsInfo_struct // SS info +{ + u8 choice_flag; + union + { + struct FwdInfo_struct fwd_info; // forward info, flag = 1 + struct CBInfo_struct cb_info; // call barring info, flag = 2 + struct SsData_struct ss_data; // ss data, flag = 3 + } choice; +} SsInfo_struct; + +typedef struct SsForBsCode_struct // SS-forBs-code +{ + u8 param_flag; + u8 ss_code; + struct BSCode_struct bs_code; +} SsForBsCode_struct; + +typedef struct CcbsFeat_struct // CCBS feature +{ + u8 param_flag; + u8 ccbs_index; // ccbs index + u8 bsub_num[ISDN_LEN+1]; // b-subscriber number +// u8 bsub_subadd[ISDNSUB_LEN]; // b-subscriber subaddress + struct BSCode_struct bs_code; // basic service group +} CcbsFeat_struct; + +typedef struct GenSerInfo_struct // generic service info +{ + u8 param_flag; + u8 ss_status; + enum CliResOpt_enum clires_opt; // Cli restriction option + u8 maxent_prio; // maximum entitle priory + u8 default_prio; // default priory + struct + { + u8 ccbs_len; + struct CcbsFeat_struct ccbs_feat[CCBS_LEN]; + } ccbs_list; +} GenSerInfo_struct; + +typedef struct UssdArg_struct // USSD Arg +{ + u8 param_flag; + u8 ussd_scheme; // USSD data coding scheme + struct + { + u8 string_len; + u8 ussd_data[USSD_LEN]; + } ussd_string; + u8 alt_pattern; // alert pattern + u8 msisdn[ISDN_LEN+1]; +} UssdArg_struct; + +typedef struct UssdRes_struct // USSD Res +{ + u8 param_flag; + u8 ussd_scheme; // USSD data coding scheme + struct + { + u8 string_len; + u8 ussd_data[USSD_LEN]; + } ussd_string; +} UssdRes_struct; + +typedef struct CcbsData_struct // CCBS data +{ + u8 param_flag; + struct CcbsFeat_struct ccbs_feat; + u8 trans_num[ISDN_LEN+1]; // translated B-number + u32 ser_ind; // service indicator + struct ExtSigInfo_struct call_info; // call info + struct ExtSigInfo_struct net_info; // network signal info +} CcbsData_struct; + +typedef struct MapRSS_Arg // register SS argument +{ + u32 param_flag; + u8 ss_code; + struct BSCode_struct bs_code; + u8 fwdto_num[ISDN_LEN+1]; // forward to number +// u8 fwdto_subadd[ISDNSUB_LEN];// forward to sub address + u8 norc_time; // no reply condition time + u8 default_prio; // default priority (EMLPP priority) +} MapRSS_Arg; + +typedef struct MapRSS_Res // register SS response (SS info) +{ + u32 param_flag; + struct SsInfo_struct ss_info; + u8 user_error; + u8 provider_error; +} MapRSS_Res; + +typedef struct MapESS_Arg // erase SS argument +{ + u32 param_flag; + struct SsForBsCode_struct ss_forbs; +} MapESS_Arg; + +typedef struct MapESS_Res // erase SS response +{ + u32 param_flag; + struct SsInfo_struct ss_info; + u8 user_error; + u8 provider_error; +} MapESS_Res; + +typedef struct MapASS_Arg // activate SS argument +{ + u32 param_flag; + struct SsForBsCode_struct ss_forbs; +} MapASS_Arg; + +typedef struct MapASS_Res // activate SS response +{ + u32 param_flag; + struct SsInfo_struct ss_info; + u8 user_error; + u8 provider_error; +} MapASS_Res; + +typedef struct MapDASS_Arg // deactivate SS argument +{ + u32 param_flag; + struct SsForBsCode_struct ss_forbs; +} MapDASS_Arg; + +typedef struct MapDASS_Res // deactivate SS response +{ + u32 param_flag; + struct SsInfo_struct ss_info; + u8 user_error; + u8 provider_error; +} MapDASS_Res; + +typedef struct MapINTSS_Arg // interrogate SS argument +{ + u32 param_flag; + struct SsForBsCode_struct ss_forbs; +} MapINTSS_Arg; + +typedef struct MapINTSS_Res // interrogate SS response +{ + u32 param_flag; + struct + { + u8 choice_flag; + union + { + u8 ss_status; // flag = 1 + struct BSCode_struct bs_code; + struct FwdFeat_struct fwd_feat; +// struct // flag = 3 +// { +// u8 fwdfeat_len; +// struct FwdFeat_struct fwd_feat[BSG_LEN]; +// } fwdfeat_list; + struct GenSerInfo_struct genser_info; // generic service info,flag=4 + } choice; + } result; + u8 user_error; + u8 provider_error; +} MapINTSS_Res; + +typedef struct MapPUSSR_Arg // process Unstructured SS request argument +{ + u32 param_flag; + struct UssdArg_struct ussd_arg; +} MapPUSSR_Arg; + +typedef struct MapPUSSR_Res // process Unstructured SS request response +{ + u32 param_flag; + struct UssdRes_struct ussd_res; + u8 user_error; + u8 provider_error; +} MapPUSSR_Res; + +typedef struct MapUSSR_Arg // Unstructured SS request argument +{ + u32 param_flag; + struct UssdArg_struct ussd_arg; +} MapUSSR_Arg; + +typedef struct MapUSSR_Res // Unstructured SS request response +{ + u32 param_flag; + struct UssdRes_struct ussd_res; + u8 user_error; + u8 provider_error; +} MapUSSR_Res; + +typedef struct MapUSSN_Arg // Unstructured SS notify argument +{ + u32 param_flag; + struct UssdArg_struct ussd_arg; +} MapUSSN_Arg; + +typedef struct MapUSSN_Res // Unstructured SS notify response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapUSSN_Res; + +typedef struct MapBSA_Arg // Begin subsriber activaty +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 orgenty_num[9]; + u8 orgenty_num_len; +} MapBSA_Arg; + +typedef struct MapRPSS_Arg // register password argument +{ + u32 param_flag; + u8 ss_code; +} MapRPSS_Arg; + +typedef struct MapRPSS_Res // register password response +{ + u32 param_flag; + u8 passwd[PASSWD_LEN]; + u8 user_error; + u8 provider_error; +} MapRPSS_Res; + +typedef struct MapGPSS_Arg // get password argument +{ + u32 param_flag; + enum GuiInfo_enum gui_info; // guidance info +} MapGPSS_Arg; + +typedef struct MapGPSS_Res // get password response +{ + u32 param_flag; + u8 passwd[PASSWD_LEN]; + u8 provider_error; +} MapGPSS_Res; + +typedef struct MapSSIN_Arg // SS invocation notificatoin argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 msisdn[ISDN_LEN+1]; + u8 ss_event; // according ss code + struct + { + u8 event_len; + u8 event_spe[EVENT_LEN][ISDN_LEN+1]; + } event; +} MapSSIN_Arg; + +typedef struct MapSSIN_Res // SS invocation notification response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapSSIN_Res; + +typedef struct MapRCCE_Arg // register CC entity argument +{ + u32 param_flag; + u8 ss_code; + struct CcbsData_struct ccbs_data; +} MapRCCE_Arg; + +typedef struct MapRCCE_Res // register CC entity response +{ + u32 param_flag; + struct CcbsFeat_struct ccbs_feat; + u8 user_error; + u8 provider_error; +} MapRCCE_Res; + +typedef struct MapECCE_Arg // erase CC entity +{ + u32 param_flag; + u8 ss_code; + u8 ccbs_index; +} MapECCE_Arg; + +typedef struct MapECCE_Res // erase CC entity +{ + u32 param_flag; + u8 ss_code; + u8 ss_status; + u8 user_error; + u8 provider_error; +} MapECCE_Res; + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* call handling sevices structure, according 17.7.3 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +typedef enum InterType_enum // interrogation type +{ + basiccall = 0, + forwarding = 1 +} InterType_enum; + +typedef enum FwdReason_enum // forwarding reason +{ + fwdnotreach = 0, + fwdbusy = 1, + noreply = 2 +} FwdReason_enum; + +typedef enum TBTriDetPnt_enum // T-Bcsm trigger detection point +{ + termattmauth = 12 // term attempt authorized +} TBTriDetPnt_enum; + +typedef enum DefCallHand_enum // default call handling +{ + continue_call = 0, + release_call = 1 +} DefCallHand_enum; + +typedef enum DefSMSHand_enum // default call handling +{ + continue_transaction = 0, + release_transaction = 1 +} DefSMSHand_enum; + +typedef enum OBTriDetPnt_enum // O-Bcsm trigger detection point +{ + collected_info = 2 +} OBTriDetPnt_enum; + +typedef enum SMSTriDetPnt_enum // O-Bcsm trigger detection point +{ + sms_CollectedInfo = 1 +} SMSTriDetPnt_enum; + +typedef enum CallTypeCrit_enum // call type criteria +{ + forwarded = 0, + notforwared = 1 +} CallTypeCrit_enum; + +typedef enum MatchType_enum // match type +{ + inhibiting = 0, + enabling = 1 +} MatchType_enum; + +typedef enum NotReachReason_enum // not reachable reason +{ + mspurged = 0, + imsidetached = 1, + restrictedarea = 2, + notregistered = 3 +} NotReachReason_enum; + +typedef enum RepState_enum // reporting state +{ + stopmonitor = 0, + startmonitor = 1 +} RepState_enum; + +typedef enum CcbsSubStat_enum // CCBS subscriber status +{ + notidle = 0, // CCBS not idle + idle = 1, // CCBS idle + ccbsnotreach = 2 // CCBS not reachable +} CcbsSubStat_enum; + +typedef enum MonMode_enum // monitor mode +{ + aside = 0, + bside = 1 +} MonMode_enum; + +typedef enum CallOut_enum // call outcome +{ + success = 0, + failure = 1, + cobusy = 2 +} CallOut_enum; + +typedef enum RUFOut_enum // RUF outcome +{ + accepted = 0, + rejected = 1, + noresfree = 2, // no response from free MS + noresbusy = 3, // no response from busy MS + udubfree = 4, // udub from free MS + udubbusy = 5 // udub from busy MS +} RUFOut_enum; + +typedef struct CugChkInfo_struct // CUG check info +{ + u8 param_flag; + u8 cug_intlock[CUGLOCK_LEN]; // CUG interlock + u8 cug_outacc; // CUG outgoing access +} CugChkInfo_struct; + +typedef struct CamelInfo_struct // camel info +{ + u8 param_flag; + u8 camel_phase[3]; // supported camel phases + u8 supp_tcsi; //(0) suppress T-CSI +} CamelInfo_struct; + +typedef struct FwdData_struct // forwarding data +{ + u8 param_flag; + u8 fwd_num[ISDN_LEN + 1]; //(0) + u8 fwd_subadd[ISDNSUB_LEN + 1]; //(1) + u8 fwd_option; //(2) forwarding option + +} FwdData_struct; + +typedef struct RoutInfo_struct // routing info +{ + u8 choice_flag; + union + { + u8 roam_num[ISDN_LEN+1]; // roaming number,flag = 1 + struct FwdData_struct fwd_data; // flag = 2 + } choice; +} RoutInfo_struct; + +typedef struct TBCTDPData_struct // T-Bcsm camel TDP data +{ + u8 param_flag; + enum TBTriDetPnt_enum det_point; // t-Bcsm trigger detection point + u32 service_key; + u8 scf_add[ISDN_LEN+1]; + enum DefCallHand_enum def_hand; // default call handling +} TBCTDPData_struct; + +typedef struct TCsi_struct // T-CSI +{ + u8 param_flag; + struct + { + u8 tdpdata_len; + struct TBCTDPData_struct tdp_data[TDPDATA_NUM]; + } tdpdata_list; + u8 camel_caphand; // camel capability handling +} TCsi_struct; + +typedef struct OBCTDPData_struct // O-Bcsm camel TDP data +{ + u8 param_flag; + enum OBTriDetPnt_enum det_point; // O-Bcsm trigger detection point + enum DefCallHand_enum def_hand; // default call handling + u8 scf_add[ISDN_LEN+1]; + u32 service_key; +} OBCTDPData_struct; + +typedef struct OCsi_struct // O-CSI +{ + u8 param_flag; + struct + { + u8 tdpdata_len; + struct OBCTDPData_struct tdp_data[TDPDATA_NUM]; + } tdpdata_list; + u8 camel_caphand; // camel capability handling +} OCsi_struct; + +typedef struct SMSCTDPData_struct // SMS camel TDP data +{ + enum SMSTriDetPnt_enum det_point; // SMS trigger detection point + enum DefSMSHand_enum def_hand; // default call handling + u8 scf_add[ISDN_LEN + 1]; + u32 service_key; +} SMSCTDPData_struct; + +typedef struct SMSCsi_struct // O-CSI +{ + u8 param_flag; + struct + { + u8 tdpdata_len; + struct SMSCTDPData_struct tdp_data[TDPDATA_NUM]; + } tdpdata_list; //(0) + u8 camel_caphand; //(1)camel capability handling + u8 notificationToCSE; //(2)notificationToCSE + u8 csi_Active; //(3)csi-Active +} SMSCsi_struct; + +typedef struct DstNumCrit_struct // destination number criteria +{ + u8 param_flag; + enum MatchType_enum match_type; + struct + { + u8 dstnum_len; + u8 dst_num[MAX_DSTNUM][ISDN_LEN+1]; + } dstnum_list; //destination number list + struct + { + u8 numlength_len; + u8 num_length[DSTNUM_LEN]; + } dstnumlen_list; +} DstNumCrit_struct; + +typedef struct OBCTDPCrit_struct // O-Bcsm camel TDP criteria +{ + u8 param_flag; + enum OBTriDetPnt_enum det_point; // O-Bcsm trigger detection point + struct DstNumCrit_struct dstCriteria; + struct BSCode_struct bs_code; + enum CallTypeCrit_enum call_crit; // call type criteria +} OBCTDPCrit_struct; + +typedef struct OBCritLst_struct +{ + u8 list_len; + struct OBCTDPCrit_struct crit_data[TDPDATA_NUM]; +}OBCritLst_struct; + +typedef struct GCSubsInfo_struct // GMSC camel subscription info +{ + u8 param_flag; + struct TCsi_struct t_csi; + struct OCsi_struct o_csi; + struct OBCritLst_struct ob_list; // O-Bcsm camel TDP criteria list +} GCSubsInfo_struct; + +typedef struct CamelRoutInfo_struct // camel routing info +{ + u8 param_flag; + struct FwdData_struct fwd_data; //(0) + struct GCSubsInfo_struct subs_info; // GMSC camel subscription info +} CamelRoutInfo_struct; + +typedef struct ExtRoutInfo_struct // extended routing info +{ + u8 choice_flag; + union + { + struct RoutInfo_struct rout_info; // flag = 1 + struct CamelRoutInfo_struct camel_info; // camel routing info,flag = 2 + } choice; +} ExtRoutInfo_struct; + +typedef struct SubState_struct // subscriber state +{// flag=1:assumeidle;flag=2:camelbusy;flag=4:netnotreachable;flag=8:notprovidfromvlr + u8 choice_flag; + union + { + enum NotReachReason_enum net_reason; + } choice; +} SubState_struct; + +typedef struct LocInfo_struct // location information +{ + u8 param_flag; + u16 age_info; // age of location information + u8 geog_info[8]; // geographical information + u8 vlr_num[ISDN_LEN+1]; + u8 loc_num[LOCATION_NUM]; // location number + struct CellIdLai_struct cell_lai; // cell id or lai +} LocInfo_struct; + +/* +typedef struct SubInfo_struct // subscriber information +{ + u8 param_flag; + struct LocInfo_struct loc_info; + struct SubState_struct sub_state; +// CapLocationInformation loc_info; //(0) location information + //<---defined in capmsg.h +// u8 sub_state_ch; +// CapSubscriberState sub_state; //(1) param_flag=1 subscriber state + //<---defined in capmsg.h +} SubInfo_struct; +*/ + +typedef enum NumberPortabilityStatus +{ + //notKnownToBePorted = 0, + //ownNumberPortedOut = 1, + //foreignNumberPortedToForeignNetwork = 2, + ownNumberNotPortedOut = 4, + foreignNumberPortedIn = 5 +}NumberPortabilityStatus; + +typedef struct MnpInfoRes +{ + u8 param_flag; + u8 routing_number[ISDN_LEN+1]; + u8 imsi[IMSI_LEN]; + u8 msisdn[ISDN_LEN+1]; + enum NumberPortabilityStatus mnp_status; +}MnpInfoRes; + + +typedef struct SubInfo_struct // subscriber information +{ + u8 param_flag; + struct LocInfo_struct loc_info; + struct SubState_struct sub_state; + u8 locationInfoGPRS; // define later + u8 ps_subscriber_state; //define later + u8 imei[IMEI_LEN]; + u8 ms_classmark; //define later + u8 gprs_ms_class; //define later + struct MnpInfoRes mnp_info_res; +// CapLocationInformation loc_info; //(0) location information +// //<---defined in capmsg.h +// // u8 sub_state_ch; +// CapSubscriberState sub_state; //(1) param_flag=1 subscriber state +// //<---defined in capmsg.h +} SubInfo_struct; + + +typedef struct CcbsInd_struct // CCBS indicator +{ + u8 param_flag; + u8 ccbs_possible; // CCBS possible + u8 ccbs_indicator; // keep CCBS call indicator +} CcbsInd_struct; + +typedef struct EveRepData_struct // event report data +{ + u8 param_flag; + enum CcbsSubStat_enum ccbs_stat; // CCBS subscriber status +} EveRepData_struct; + +typedef struct CallRepData_struct // call report data +{ + u8 param_flag; + enum MonMode_enum monitor_mode; // monitor mode + enum CallOut_enum call_outcome; // call outcome +} CallRepData_struct; + +typedef struct MapSRI_Arg // send routing info argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; //0 + struct CugChkInfo_struct chk_info; // CUG check info + u8 fwd_num; // number of forwarding + enum InterType_enum inter_type; // interrogation type + u8 or_inter; // or-interrogation + u8 or_cap; // or-capability + u8 gmsc_add[ISDN_LEN+1]; // gmsc address + u8 callref_num[CALLREF_NUM+1]; // call reference number + enum FwdReason_enum fwd_reason; // forwarding reason + struct BSCode_struct bs_group; // basic service group + struct ExtSigInfo_struct net_info; // network signal info + struct CamelInfo_struct camel_info; // camel info + u8 supp_ann; // suppression of announcement + u8 alt_pattern; // alert pattern + u8 ccbs_call; // CCBS call + u8 ccbs_phase; // supported CCBS phase +} MapSRI_Arg; + +typedef enum MNPStatus_enum +// mnp status type, for MNP looping detect, added by Pierre, 06-01-23 + { + notKnownToBePorted=0, + ownNumberPortedOut, + foreignNumberPortedToForeignNetwork, + }MNPStatus_enum; + + +typedef struct MapSRI_Res // send routing information response +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; //(0) + struct ExtRoutInfo_struct rout_info; //(1)extended routing info + struct CugChkInfo_struct cugchk_info; //(2)CUG check info + u8 cugsubs_flag; //(3)CUG subsription flag + struct SubInfo_struct sub_info; //(4)subscriber info + struct + { + u8 sslist_len; + u8 ss_code[SS_LEN]; + } ss_list; //(5) + struct BSCode_struct bs_code; + u8 fwdinter_req; // forwarding interrogate required + u8 vmsc_add[ISDN_LEN+1]; + struct NaeaPrefCi_struct naea_ci; // NAEA preferred CI + struct CcbsInd_struct ccbs_ind; // CCBS indicator + MNPStatus_enum mnp_indicator; //bit:0x800 + u8 user_error; + u8 provider_error; +} MapSRI_Res; + +typedef struct MapPRN_Arg // provide roaming number argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 msc_num[ISDN_LEN+1]; // MSC number + u8 msisdn[ISDN_LEN+1]; + u8 lmsi[LMSI_LEN]; + struct ExtSigInfo_struct bearer_cap; // gsm bearer capability + struct ExtSigInfo_struct net_info; // network signal info + u8 sup_ann; // suppression of announcement + u8 gmsc_add[ISDN_LEN+1]; // GMSC address + u8 callref_num[CALLREF_NUM+1]; // call reference number + u8 or_interr; // or-interrogation + u8 alt_pattern; // alert pattern + u8 ccbs_call; // CCBS call + u8 camel_phase[3]; // supported camel phase +} MapPRN_Arg; + +typedef struct MapPRN_Res // provider roaming number response +{ + u32 param_flag; + u8 roam_num[ISDN_LEN+1]; + u8 user_error; + u8 provider_error; +} MapPRN_Res; + +typedef struct MapRCH_Arg // resume call handling argument +{ + u32 param_flag; + u8 callref_num[CALLREF_NUM+1]; // call reference number + struct BSCode_struct bs_group; // basic service group + struct FwdData_struct fwd_data; // forwarding data + u8 imsi[IMSI_LEN]; + struct CugChkInfo_struct cugchk_info;// CUG check info + struct OCsi_struct o_csi; // o-CSI + u8 ccbs_possible; // CCBS possible +} MapRCH_Arg; + +typedef struct MapRCH_Res // resume call handling response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapRCH_Res; + +typedef struct MapPSN_Arg // provide SIWFS number argument +{ + u32 param_flag; + struct ExtSigInfo_struct gsm_bc; // GSM bearer capability + struct ExtSigInfo_struct isdn_bc; // ISDN bearer capability + u8 call_direction; // call direction + u8 bsub_add[ISDN_LEN+1]; // b-subscriber address + struct ExtSigInfo_struct chose_chan; // chosen channel + struct ExtSigInfo_struct low_camp; // low layer compatibility + struct ExtSigInfo_struct high_camp; // high layer compatibility +} MapPSN_Arg; + +typedef struct MapPSN_Res // provide SIWFS number response +{ + u32 param_flag; + u8 siwfs_num[ISDN_LEN+1]; // sIWFS number + u8 user_error; + u8 provider_error; +} MapPSN_Res; + +typedef struct MapSSM_Arg // SIWFS signalling modify argument +{ + u32 param_flag; + struct ExtSigInfo_struct chan_type; // channel type + struct ExtSigInfo_struct chose_chan; // chosen channel +} MapSSM_Arg; + +typedef struct MapSSM_Res // SIWFS signalling modify response +{ + u32 param_flag; + struct ExtSigInfo_struct chose_chan; // chosen channel + u8 user_error; + u8 provider_error; +} MapSSM_Res; + +typedef struct MapSRS_Arg // set reporting state argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 lmsi[LMSI_LEN]; + enum RepState_enum ccbs_monitor; // CCBS monitoring +} MapSRS_Arg; + +typedef struct MapSRS_Res // set reporting state response +{ + u32 param_flag; + enum CcbsSubStat_enum ccbs_stat; // CCBS subscriber status + u8 user_error; + u8 provider_error; +} MapSRS_Res; + +typedef struct MapSR_Arg // status report argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + struct EveRepData_struct event_data; // event report data + struct CallRepData_struct call_data; // call report data +} MapSR_Arg; + +typedef struct MapSR_Res // status report response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapSR_Res; + +typedef struct MapRUF_Arg // remote user free argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + struct ExtSigInfo_struct call_info; // call info + struct CcbsFeat_struct ccbs_feat; // CCBS feature + u8 trans_num[ISDN_LEN+1]; // translate number + u8 replace_num; // replace number + u8 alt_pattern; // alert pattern +} MapRUF_Arg; + +typedef struct MapRUF_Res // remote user free response +{ + u32 param_flag; + enum RUFOut_enum ruf_outcome; // RUF outcome + u8 user_error; + u8 provider_error; +} MapRUF_Res; + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* operation and maintenance data structure, according 17.7.2 */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +typedef struct MapATM_Arg // activate trace mode argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 trace_ref[2]; // trace reference + u8 trace_type; + u8 omc_id[ISDN_LEN+1];// OMC ID +} MapATM_Arg; + +typedef struct MapATM_Res // activate trace mode response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapATM_Res; + +typedef struct MapDTM_Arg // deactivate trace mode argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 trace_ref[2]; // trace reference +} MapDTM_Arg; + +typedef struct MapDTM_Res // deactivate trace maode response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapDTM_Res; + +typedef struct MapSIMSI_Arg // send IMSI argument +{ + u32 param_flag; + u8 msisdn[ISDN_LEN+1]; +} MapSIMSI_Arg; + +typedef struct MapSIMSI_Res // send IMSI response +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 user_error; + u8 provider_error; +} MapSIMSI_Res; + +/* ++++++++++++++++++++++++++++++++++++++++++ */ +/* mobile service structure, according 14.7.1 */ +/* ++++++++++++++++++++++++++++++++++++++++++ */ +typedef enum CanLocType_enum // cancel location type +{ + update = 0, // update procedure + withdraw = 1 // subscription withdraw +} CanLocType_enum; + +typedef enum EquipStatus_enum // equipment status +{ + whitelist = 0, + blacklist = 1, + greylist = 2 +} EquipStatus_enum; + +typedef enum NetAccMode_enum // network access mode +{ + mscandsgsn = 0, + onlymsc = 1, + onlysgsn = 2 +} NetAccMode_enum; + +typedef enum SubStatus_enum // subscriber status +{ + servicegrant = 0, // service granted + oprbarring = 1 // operator determined barring +} SubStatus_enum; + +typedef enum IntraCugOpt_enum // intra CUG option +{ + norestric = 0, // no CUG restriction + iccallbar = 1, // CUG ic call barring + ogcallbar = 2 // CUG og call barring +} IntraCugOpt_enum; + +typedef enum RegSubsRes_enum // regional subscription response +{ + netrestrict = 0, // network node area restricted + toomanyzc = 1, // too many zone code + zcconflict = 2, // zone code conflict + regnotsupport = 3 // regional subscription not support +} RegSubsRes_enum; + +typedef struct VlrCap_struct // VLR capability +{ + u8 param_flag; + u8 camel_phase[3]; // supported camel phase +} VlrCap_struct; + +typedef struct AuthSet_struct // authentication set +{ + u8 param_flag; + u8 rand[RAND_LEN]; + u8 sres[SRES_LEN]; + u8 kc[KC_LEN]; +} AuthSet_struct; + +/* +typedef struct ReqInfo_struct // requested info +{ + u8 param_flag; + u8 loc_info; // location information + u8 sub_state; // subscriber state +} ReqInfo_struct; +*/ +typedef struct ReqInfo_struct // requested info +{ + u8 param_flag; + u8 loc_info; // location information + u8 sub_state; // subscriber state + u8 cur_location; + u8 req_domain; + u8 imei; + u8 ms_classmark; + u8 mnp_req_info; +} ReqInfo_struct; + +typedef struct SubIdent_struct // subscriber identity +{ + u8 choice_flag; + union + { + u8 imsi[IMSI_LEN]; // flag = 1 + u8 msisdn[ISDN_LEN+1]; // flag = 2 + } choice; +} SubIdent_struct; + +typedef struct PdpContext_struct // PDP context +{ + u8 param_flag; + u8 pdpcontext_id; // PDP context ID + u8 pdp_type[2]; + u8 pdp_add[PDP_LEN+1]; // PDP address + u8 qos_sub[3]; // QOS subscribed + u8 vplmn_allow; // VPLMN address allowed + struct + { + u8 apn_len; + u8 apn_data[APN_LEN]; + } apn; +} PdpContext_struct; + +typedef struct GprsSubsData_struct // GPRS subsequent data +{ + u8 param_flag; + u8 data_include; // complete data list included + struct + { + u8 list_len; + struct PdpContext_struct pdp_context[PDPCONTEXT_LEN]; + } gprs_list; +} GprsSubsData_struct; + +typedef struct ExtFwdInfo_struct // ext forward info +{ // 0: CFU 1: CFB 2: CFNRy 3: CFNRc + u8 param_flag; // param_flag=0x01 => ss_code[0] & fwd_feat[0] + u8 ss_code[4]; + struct FwdFeat_struct fwd_feat[4]; +} ExtFwdInfo_struct; + +typedef struct ExtCallBarInfo_struct // ext call barring info +{ // 0: BAOC 1:BOIC 2:BOIC-exHPLMN 3:BAIC 4:BIC-Roam + u8 param_flag; + u8 ss_code[5]; + u8 ss_status[5]; + struct BSCode_struct bs_code[5]; +} ExtCallBarInfo_struct; + +typedef struct CugSubs_struct // CUG subscription +{ + u8 param_flag; + u16 cug_index; + u8 cug_lock[CUGLOCK_LEN]; // CUG interlock + enum IntraCugOpt_enum cug_opt;// intra CUG options + struct BSCode_struct bs_code; +} CugSubs_struct; + +typedef struct CugFeat_struct // CUG feature +{ + u8 param_flag; + struct BSCode_struct bs_code; + u16 cug_indicator; // preferntial CUG indicator + u8 cug_restric; // inter CUG restrictions +} CugFeat_struct; + +typedef struct CugInfo_struct // CUG info +{ + u8 param_flag; + struct + { + u8 list_len; + struct CugSubs_struct cug_subs[CUG_LEN]; + } subs_list; // CUG subscription list + struct + { + u8 list_len; + struct CugFeat_struct cug_feat[EXTBSG_LEN]; + } feat_list; // CUG feature list +} CugInfo_struct; + +typedef struct ExtSsData_struct // ext SS data +{// 0: CLIP 1: CLIR 2: COLP 3: COLR + u32 param_flag; + u8 ss_code[SSDATA_NUM]; + u8 ss_status[SSDATA_NUM]; + struct SsSubsOpt_struct subs_opt[SSDATA_NUM]; // ss subscription option + struct BSCode_struct bs_code[SSDATA_NUM]; +} ExtSsData_struct; + +typedef struct ExtSsInfo_struct +{ + u8 param_flag; + struct ExtFwdInfo_struct fwd_info; + struct ExtCallBarInfo_struct call_info; + struct CugInfo_struct cug_info; + struct ExtSsData_struct ss_data; +// struct EmlppInfo_struct emlpp_info; +} ExtSsInfo_struct; + +typedef struct OdbData_struct // ODB data +{ + u8 param_flag; + u32 odb_general; // ODB general data + u32 odb_hplmn; // ODB hplmn data +} OdbData_struct; + +typedef struct VGCData_struct // voice group call data +{ + u8 param_flag; + u8 group_id[3]; +} VGCData_struct; + +typedef struct VBSData_struct //voice broadcast data +{ + u8 param_flag; + u8 group_id[3]; + u8 init_entitle; // broadcast init entitlement +} VBSData_struct; + +typedef struct SsCsi_struct // SS CSI +{ + u8 param_flag; + struct + { + u8 list_len; + u8 ss_code[CAMELSS_LEN]; + } event_list; // ss event list + u8 scf_add[ISDN_LEN+1]; +} SsCsi_struct; + + + +typedef struct VCSubsInfo_struct // VLR CAMEL subscription info +{ + u8 param_flag; + struct OCsi_struct o_csi; //O-CSI + struct SsCsi_struct ss_csi; //SS-CSI + struct OBCritLst_struct tdp_list; //o-bcsm camel TDP criteria list + struct SMSCsi_struct sms_csi; // SMS-CSI +}VCSubsInfo_struct; + +typedef struct GprsSDWithdraw_struct // GPRS subscription data withdrwa +{ + u8 choice_flag; + union + { + u8 allgprs_data; // flag = 1 + struct // flag = 2 + { + u8 list_len; + u8 context_id[PDPCONTEXT_LEN]; + } context_list; // context id list + } choice; +} GprsSDWithdraw_struct; + +typedef struct MapUL_Arg // update location argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 msc_num[ISDN_LEN+1]; // MSC number + u8 vlr_num[ISDN_LEN+1]; // VLR number + u8 lmsi[LMSI_LEN]; + struct VlrCap_struct vlr_cap;// VLR capability + u8 roaming_num[ISDN_LEN+1]; +} MapUL_Arg; + +typedef struct MapUL_Res // update location response +{ + u32 param_flag; + u8 hlr_num[ISDN_LEN+1]; + u8 user_error; // bit 31, 0x80000000 + u8 provider_error; // bit 30, 0x40000000 +} MapUL_Res; + +typedef struct CL_identity +{ + u32 choice_flag; + union + { + u8 imsi[IMSI_LEN]; + struct imsi_withLmsi + { + u8 imsi[IMSI_LEN]; + u8 lmsi[4]; + } imsi_withlmsi; + } choice; +} CL_identity; + +typedef struct MapCL_Arg // cancel location argument +{ + u32 param_flag; + CL_identity id; + enum CanLocType_enum type; // cancel location type +} MapCL_Arg; + + +typedef struct MapNP_Arg //NoteSubscriberPresent argumnet +{ + u8 param_flag; + u8 imsi[IMSI_LEN]; +} MapNP_Arg; + +typedef struct MapPUSSD_Arg //ProcessUnstructuredSS-Data Response +{ + u8 param_flag; + u8 ussd_len; + u8 ussd_data[200]; +} MapPUSSD_Arg; + + + +typedef struct MapPUSSD_Res //ProcessUnstructuredSS-Data Response +{ + u8 param_flag; + u8 ussd_len; + u8 ussd_data[200]; +} MapPUSSD_Res; + + +typedef struct MapSA_Arg //BeginSubscriberActivity argumnet +{ + u8 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 enity_len; + u8 Enity_num[9]; +} MapSA_Arg; + +typedef struct MapHO_Arg //perform hand over argument +{ + u8 param_flag; + u8 tgt_cellID[7]; + u8 tgt_cellid_len; + u8 srv_cellID[7]; + u8 srv_cellid_len; + u8 chl_type[10]; + u8 chl_type_len; + u8 class_mark[2]; + u8 ho_priority; + u8 kc[8]; +} MapHO_Arg; + +typedef struct MapHO_Res //perform hand over response +{ + u8 param_flag; + u8 ho_num[9]; + u8 ho_num_len; + struct + { + u8 protocol_id; + u8 singal_info_len; + u8 signal_info[200]; + } access_singal_info; +} MapHO_Res; + + + +typedef struct MapCL_Res // cancel location response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapCL_Res; + +typedef struct MapPMS_Arg // purge MS argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 vlr_num[ISDN_LEN+1]; // VLR number + u8 sgsn_num[ISDN_LEN+1]; // SGSN number +} MapPMS_Arg; + +typedef struct MapPMS_Res // purge MS response +{ + u32 param_flag; + u8 freeze_tmsi; // freeze TMSI + u8 freeze_ptmsi; // freeze P-TMSI + u8 user_error; + u8 provider_error; +} MapPMS_Res; + +typedef struct MapSI_Arg // send identification argument +{ + u32 param_flag; + u8 tmsi[TMSI_LEN]; +} MapSI_Arg; + +typedef struct MapSI_Res // send identification response +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + struct + { + u8 auth_len; + struct AuthSet_struct auth_set[AUTHLIST_LEN]; + } authlist; + u8 provider_error; +} MapSI_Res; + +typedef struct MapUGL_Arg // update GPRS location argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 sgsn_num[ISDN_LEN+1]; // SGSN number + u8 sgsn_add[GSN_LEN+1]; // SGSN address +} MapUGL_Arg; + +typedef struct MapUGL_Res // update GPRS location response +{ + u32 param_flag; + u8 hlr_num[ISDN_LEN+1]; + u8 user_error; + u8 provider_error; +} MapUGL_Res; + +typedef struct MapPSI_Arg // provide subscriber info argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 lmsi[LMSI_LEN]; + struct ReqInfo_struct req_info;// requested info +} MapPSI_Arg; + +typedef struct MapPSI_Res // provide subscriber info response +{ + u32 param_flag; + struct SubInfo_struct sub_info;// subscriber info + u8 user_error; + u8 provider_error; +} MapPSI_Res; + +typedef struct MapATI_Arg // any time interrogation argument +{ + u32 param_flag; + struct SubIdent_struct sub_ident; // subscriber identity + struct ReqInfo_struct req_info; // requested info + u8 scf_add[ISDN_LEN+1]; // gsmSCF address +} MapATI_Arg; + +typedef struct MapATI_Res // any time interrogation response +{ + u32 param_flag; + struct SubInfo_struct sub_info; // subscriber info + u8 user_error; + u8 provider_error; +} MapATI_Res; + +typedef struct MapPHO_Arg // prepare handover argument +{ + u32 param_flag; + u8 target_id[GCID_LEN]; // target cell id + u8 numnot_require; // ho-number not required + struct ExtSigInfo_struct bss_apdu; // bss APDU +} MapPHO_Arg; + +typedef struct MapPHO_Res // prepare handover response +{ + u32 param_flag; + u8 ho_num[ISDN_LEN+1]; // handover number + struct ExtSigInfo_struct bss_apdu; // bss APDU + u8 user_error; + u8 provider_error; +} MapPHO_Res; + +typedef struct MapSES_Arg // send end signal argument +{ + u32 param_flag; + struct ExtSigInfo_struct bss_apdu; // bss APDU +} MapSES_Arg; + +typedef struct MapSES_Res // send end signal response +{ + u32 param_flag; + u8 provider_error; +} MapSES_Res; + +typedef struct MapPAS_Arg // process access signalling argument +{ + u32 param_flag; + struct ExtSigInfo_struct bss_apdu; +} MapPAS_Arg; + +typedef struct MapFAS_Arg // forward access signalling argument +{ + u32 param_flag; + struct ExtSigInfo_struct bss_apdu; +} MapFAS_Arg; + +typedef struct MapPSHO_Arg // prepare subsequent handover argument +{ + u32 param_flag; + u8 target_id[GCID_LEN]; // target cell id + u8 msc_num[ISDN_LEN+1]; // target MSC number + struct ExtSigInfo_struct bss_apdu; +} MapPSHO_Arg; + +typedef struct MapPSHO_Res // prepare subsequent handover response +{ + u32 param_flag; + struct ExtSigInfo_struct bss_apdu; + u8 user_error; + u8 provider_error; +} MapPSHO_Res; + + +typedef struct MapPFSHO_Arg // preform subsequent handover argument +{ + u32 param_flag; + u8 target_id[GCID_LEN]; // target cell id + u8 service_id[GCID_LEN]; // Serving cell id + u8 msc_num[ISDN_LEN+1]; // target MSC number + u8 classmark_info[2]; +} MapPFSHO_Arg; + +typedef struct MapPFSHO_Res // preform subsequent handover response +{ + u32 param_flag; + struct ExtSigInfo_struct access_sig_info; + u8 user_error; + u8 provider_error; +} MapPFSHO_Res; + + +typedef struct MapNIHO_Arg // preform note internal hand over +{ + u32 param_flag; + u8 ho_type; // handover type + u8 target_id[GCID_LEN]; + struct ExtSigInfo_struct channel_id; +} MapNIHO_Arg; + + + +typedef struct MapSAI_Arg // send authenticate info argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; +} MapSAI_Arg; + +typedef struct MapSAI_Res // send authenticate info response +{ + u32 param_flag; + struct + { + u8 auth_len; + struct AuthSet_struct auth_set[AUTHLIST_LEN]; + } authlist; + u8 user_error; + u8 provider_error; +} MapSAI_Res; + +typedef struct MapCIMEI_Arg // check IMEI argument +{ + u32 param_flag; + u8 imei[IMEI_LEN]; +} MapCIMEI_Arg; + +typedef struct MapCIMEI_Res // check IMEI response +{ + u32 param_flag; + enum EquipStatus_enum equip_status; // equipment status + u8 user_error; + u8 provider_error; +} MapCIMEI_Res; + +typedef struct MapISD_Arg // insert subscriber data argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; //(0) + u8 msisdn[ISDN_LEN+1]; //(1) + u8 category; //(2) + enum SubStatus_enum sub_status; //(3)subscriber status + struct OdbData_struct odb_data; //(4) + u32 bearer_data; //(5) + u16 tele_data; //(6) + struct ExtSsInfo_struct ss_info; //(7) + u8 roam_feature; //(8)roaming restriction due to unsupported feature + struct + { + u8 list_len; + u8 zone_code[ZONECODE_LEN][2]; + } zc_list; //(9):zone code list + struct + { + u8 list_len; + struct VBSData_struct vbs_data[VBS_LEN]; + } vbsdata_list; //(10):VBS data list + struct + { + u8 list_len; + struct VGCData_struct vgc_data[VGCS_LEN]; + } vgcdata_list; //(11)VGC data list + struct VCSubsInfo_struct subs_info; //(12)VLR Camel subscription info + struct NaeaPrefCi_struct naea_ci; //(13)NAEA preferred CI + struct GprsSubsData_struct gprs_data; //(14)GPRS subscription data + u8 roamsgsn_feature; //(15)roaming restricted in SGSN due to unsupported feature + enum NetAccMode_enum net_mode; //(16)network access mode +}MapISD_Arg; + +typedef struct MapISD_Res // insert subscriber data response +{ + u32 param_flag; + u16 tele_data; + u32 bearer_data; + struct + { + u8 sslist_len; + u8 ss_code[SS_LEN]; + } ss_list; // ss list + u32 odb_data; // odb general data + enum RegSubsRes_enum subs_res; // regional subscription response + u8 camel_phase[3]; // supported camel phases + u8 user_error; + u8 provider_error; +} MapISD_Res; + +typedef struct MapSP_Arg//send parameters argument +{ + u8 param_flag; + SubId_struct sub_id; + u8 ReqPara_num; + u8 ReqPara[2]; +} MapSP_Arg; + +typedef struct Sub_data_struct +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; //(0) **** unused + u8 msisdn[ISDN_LEN+1]; //(1) + u8 category; //(2) + enum SubStatus_enum sub_status; //(3)subscriber status + struct OdbData_struct odb_data; //(4) + u32 bearer_data; //(5) + u16 tele_data; //(6) + struct ExtSsInfo_struct ss_info; //(7) + u8 roam_feature; //(8)roaming restriction due to unsupported feature + struct + { + u8 list_len; + u8 zone_code[ZONECODE_LEN][2]; + } zc_list; //(9):zone code list +} Sub_data_struct; + +typedef struct SendParaList +{ + u32 choice_flag;//1=IMSI, 2=AuthenticationSet, 4==SubscriberData,8=Ki, Others:Null + union + { + u8 imsi[IMSI_LEN]; //imsi + struct AuthSet_struct auth_set; + struct Sub_data_struct sub_data; //subscriber data + u8 ki[16]; //ki + } SP_Res_Choice; +} SendParaList; + +typedef struct MapSP_Res // Send parameters response +{ + u32 param_flag; + u8 sendparamlist_num; + struct SendParaList sendparalist[6]; //sentparalist + u8 user_error; + u8 provider_error; +}MapSP_Res; + + + +typedef struct MapDSD_Arg // delete subscriber data argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + struct BSCode_struct bs_code; + struct + { + u8 sslist_len; + u8 ss_code[SS_LEN]; + } ss_list; // ss list + u8 roam_feature; // roaming restriction due to unsupported feature + u8 regional_ident[2]; // regional subscription identifier (zone code) + u8 vbsg_ind; // vbs group indication + u8 vgcsg_ind; // vgcs group indication + u8 camel_withdraw; // camel subscription info withdraw + struct GprsSDWithdraw_struct gprs_withdraw; // gprs subscription data withdraw + u8 roamsgsn_feature; // roaming restricted in SGSN due to unsupported feature +} MapDSD_Arg; + +typedef struct MapDSD_Res // delete subscriber data response +{ + u32 param_flag; + enum RegSubsRes_enum subs_res; // regional subscription response + u8 user_error; + u8 provider_error; +} MapDSD_Res; + +typedef struct MapReset_Arg // reset argument +{ + u32 param_flag; + u8 hlr_num[ISDN_LEN+1]; // hlr number + struct + { + u8 list_len; + u8 hlr_id[HLRID_NUM][IMSI_LEN]; + } hlr_list; // HLR list + u8 networkResource; +} MapReset_Arg; + +typedef struct MapRD_Arg // restore data argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 lmsi[LMSI_LEN]; + struct VlrCap_struct vlr_cap; // vlr capability +} MapRD_Arg; + +typedef struct MapRD_Res // restore data response +{ + u32 param_flag; + u8 hlr_num[ISDN_LEN+1]; + u8 msnot_reach; // MS not reachable + u8 user_error; + u8 provider_error; +} MapRD_Res; + +typedef struct MapSRIFG_Arg // send routing info for GPRS argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 ggsn_add[GSN_LEN+1]; // GGSN address + u8 ggsn_num[ISDN_LEN+1]; // GGSN number +} MapSRIFG_Arg; + +typedef struct MapSRIFG_Res // send routing info for GPRS response +{ + u32 param_flag; + u8 sgsn_add[GSN_LEN+1]; // SGSN address + u8 ggsn_add[GSN_LEN+1]; // GGSN address + u8 mobile_reason; // mobile not reachable reason + u8 user_error; + u8 provider_error; +} MapSRIFG_Res; + +typedef struct MapFR_Arg // failure report argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 ggsn_num[ISDN_LEN+1]; // GGSN number + u8 ggsn_add[GSN_LEN+1]; // GGSN address +} MapFR_Arg; + +typedef struct MapFR_Res // failure report response +{ + u32 param_flag; + u8 ggsn_add[GSN_LEN+1]; // GGSN address + u8 user_error; + u8 provider_error; +} MapFR_Res; + +typedef struct MapNMPFG_Arg // note MS present for GPRS argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 sgsn_add[GSN_LEN+1]; // SGSN address + u8 ggsn_add[GSN_LEN+1]; // GGSN address +} MapNMPFG_Arg; + +typedef struct MapNMPFG_Res // note MS present for GPRS response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapNMPFG_Res; + +/* +++++++++++++++++++++++++++++ */ +/* MAP-H (with AUC) structure */ +/* +++++++++++++++++++++++++++++ */ +typedef struct MapST_Arg // security triplets argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 hlr_id[HLRID_LEN]; +} MapST_Arg; + +typedef struct MapST_Res // security triplets response +{ + u32 param_flag; + struct + { + u8 auth_len; + struct AuthSet_struct auth_set[AUTHLIST_LEN]; + } authlist; + u8 user_error; + u8 provider_error; +} MapST_Res; + +typedef struct MapIS_Arg // interrogation subscriber argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 hlr_id[HLRID_LEN]; +} MapIS_Arg; + +typedef struct MapIS_Res // interrogation subscriber response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapIS_Res; + +typedef struct MapCS_Arg // create subscriber argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 hlr_id[HLRID_LEN]; +} MapCS_Arg; + +typedef struct MapCS_Res // create subscriber response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapCS_Res; + +typedef struct MapDS_Arg // delete subscriber argument +{ + u32 param_flag; + u8 imsi[IMSI_LEN]; + u8 hlr_id[HLRID_LEN]; +} MapDS_Arg; + +typedef struct MapDS_Res // delete subscriber response +{ + u32 param_flag; + u8 user_error; + u8 provider_error; +} MapDS_Res; + +/********** OPR *******************/ +typedef struct MapDetermineOprUser_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 imei[IMEI_LEN]; + u8 roamingRestraintFlag; +} MapDetermineOprUser_Arg; + +typedef struct MapDetermineOprUser_Res +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 imei[IMEI_LEN]; + u8 oprflag; + u8 msisdn[ISDN_LEN+1]; +} MapDetermineOprUser_Res; + +typedef struct MapVlrUpdateLocation_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 status; +} MapVlrUpdateLocation_Arg; + +typedef struct MapVlrUpdateLocation_Res +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 status; + u8 error; +} MapVlrUpdateLocation_Res; + +typedef struct MapCreateUserWithMsisdnImsi_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; + u8 imsiflag; + u8 camelflag; +} MapCreateUserWithMsisdnImsi_Arg; + +typedef struct MapCreateUserWithMsisdnImsi_Res +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; + u8 result; + u8 cause; +} MapCreateUserWithMsisdnImsi_Res; + + +typedef struct MapDeleteOprUser_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; +} MapDeleteOprUser_Arg; + +typedef struct MapDeleteOprUser_Res +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; + u8 result; + u8 cause; +} MapDeleteOprUser_Res; + +/********** OPR *******************/ +/********** IMDM *******************/ +typedef struct MapVlrEnquiryIMDM_Arg +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; + +}MapVlrEnquiryIMDM_Arg; + +typedef struct MapVlrEnquiryIMDM_Res +{ + u32 param_flag; + u8 imsi[IMSI_LEN+1]; + u8 msisdn[ISDN_LEN+1]; + u8 status; +}MapVlrEnquiryIMDM_Res; +/********** IMDM *******************/ + +/**** is41 *****/ +#define MAX_IS41POPR_LEN 1024 + +typedef struct IS41ParBearerData +{ + u32 param_flag; + u8 MessageId[3]; + u8 UserDataLen; + u8 UserData[128]; + u8 UserRespondingCode; + u8 MessageCenterTimeStamp[6]; + u8 ValidityPeriod_Absolute[6]; + u8 ValidityPeriod_Relative; + u8 DeferredDeliveryTime_Absolute[6]; + u8 DeferredDeliveryTime_Relative; + u8 PriorityIndicator; + u8 PrivacyIndicator; + u8 ReplyOption; + u8 NumberOfMessages; + u8 AlertOnMessageDelivery; + u8 LanguageIndicator; + u8 CallBackNumberLen; + u8 CallBackNumber[MAX_IS41_VARPAR_LEN]; + u8 MessageDisplayMode; + u8 MultipleEncodingUserDataLen; + u8 MultipleEncodingUserData[MAX_IS41_VARPAR_LEN]; + u8 MessageStatus; + u8 TPFailureCause; +}IS41ParBearerData; + +/**IS41 Auc operation **/ +typedef struct IS41_AUTHDIR_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + +//optional part---> + u8 aav; + u8 authu[3]; + u8 count; + u8 denacc; + u8 locid[2]; + u8 randssd[7]; + u8 randu[3]; + u8 senderinLen; + u8 senderin[32]; + u8 ssd[16]; + u8 nossd; + u8 updcount; +}IS41_AUTHDIR_ARG; + +typedef struct IS41_AUTHDIR_RSP +{ + u32 param_flag; + +//optional part---> + u8 count; +}IS41_AUTHDIR_RSP; + +typedef struct IS41AucDirectiveForward_arg +{ + u32 param_flag; + + u8 InterMSCCircuitID[2]; + u8 MobileIdentificationNumber[MIN_LEN]; + +//optional part---> + u8 AuthenticationResponseUniqueChallenge[3]; + u8 RandomVariableUniqueChallenge[3]; +}IS41AucDirectiveForward_arg; + +typedef struct IS41_AFREPORT_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 rpttyp1; + u8 sysacctype; + u8 syscap; + +//optional part---> + u8 count; + u8 countex; + u8 mscid[3]; + u8 rpttyp2; + u8 senderinLen; + u8 senderin[32]; +}IS41_AFREPORT_ARG; + +typedef struct IS41_AFREPORT_RSP +{ + u32 param_flag; + +//optional part---> + u8 aav; + u8 authu[3]; + u8 count; + u8 denacc; + u8 randssd[7]; + u8 randu[3]; + u8 ssd[16]; + u8 nossd; + u8 termtyp; + u8 updcount; + + u8 user_error; + u8 provider_error; +}IS41_AFREPORT_RSP; + +typedef struct IS41_AUTHREQ_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 mscid[3]; // serving MSC + u8 sysacctype; + u8 syscap; // serving + +// optional part---> + u8 authdata[3]; + u8 authr[3]; + u8 count; + u8 cmodes; // actual + u8 DigitsLen; + u8 digits[32]; // dialed + u8 pcssn[5]; + u8 rand[4]; + u8 senderinLen; + u8 senderin[32]; + u8 termtyp; +}IS41_AUTHREQ_ARG; + +typedef struct IS41_AUTHREQ_RSP +{ + u32 param_flag; + +//optional part--> + u8 aav; + u8 authu[3]; + u8 count; + u8 cdmaplcm[6]; + u8 denacc; + u8 randssd[7]; + u8 randu[3]; + u8 ssd[16]; + u8 smekey[8]; + u8 nossd; + u8 updcount; + u8 vpmask[66]; + + u8 user_error; + u8 provider_error; +}IS41_AUTHREQ_RSP; + +typedef struct IS41_ASREPORT_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 syscap; // serving + +//optional part---> + u8 CntUpdRepLen; + u8 countrpt[32]; + u8 senderinLen; + u8 senderin[32]; + u8 SSDUpdRepLen; + u8 ssdurpt[32]; + u8 UniChaRepLen; + u8 uchalrpt[32]; +}IS41_ASREPORT_ARG; + +typedef struct IS41_ASREPORT_RSP +{ + u32 param_flag; + +//optional part---> + u8 aav; + u8 authu[3]; + u8 count; + u8 denacc; + u8 randssd[7]; + u8 randu[3]; + u8 ssd[16]; + u8 nossd; + u8 updcount; + + u8 user_error; + u8 provider_error; +}IS41_ASREPORT_RSP; + +typedef struct IS41_BSCHALL_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 randbs[4]; + +//optional part---> + u8 senderinLen; + u8 senderin[32]; +}IS41_BSCHALL_ARG; + +typedef struct IS41_BSCHALL_RSP +{ + u32 param_flag; + + u8 authbs[3]; + + u8 user_error; + u8 provider_error; +}IS41_BSCHALL_RSP; + +typedef struct IS41_COUNTREQ_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 senderinLen; + u8 senderin[32]; +}IS41_COUNTREQ_ARG; + +typedef struct IS41_COUNTREQ_RSP +{ + u32 param_flag; + + u8 count; +}IS41_COUNTREQ_RSP; + +/* IS41 Auc operation **/ + + +/* IS41 SMSC operation **/ +typedef struct IS41_SMDBACK_ARG +{ + u32 param_flag; + + u8 imsccid[2]; + u8 min[MIN_LEN]; + u8 BearerDataLen; + u8 BearerData[256]; + u8 smstidLen; + u8 smstid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSTID + + //optional part---> + u8 esn[4]; + u8 smscidLen; + u8 smscid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCID + u8 smsdaLen; + u8 smsda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSDA + u8 smsodaLen; + u8 smsoda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODA + u8 smsodsLen; + u8 smsods[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODS + u8 smsooaLen; + u8 smsooa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOA + u8 smsoosLen; + u8 smsoos[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOS + u8 smsoaLen; + u8 smsoa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOA +}IS41_SMDBACK_ARG; + +typedef struct IS41_SMDBACK_RSP +{ + u32 param_flag; + + u8 BearerDataLen; + u8 BearerData[256]; + + u8 smsccLen; + u8 smscc[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCC +}IS41_SMDBACK_RSP; + + +typedef struct IS41_SMDFWD_ARG +{ + u32 param_flag; + + u8 imsccid[2]; + u8 min[MIN_LEN]; + + u8 BearerDataLen; + u8 BearerData[256]; + u8 smstidLen; + u8 smstid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSTID + + //optional part---> + u8 esn[4]; + u8 smscidLen; + u8 smscid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCID + u8 smsdaLen; + u8 smsda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSDA + u8 smsodaLen; + u8 smsoda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODA + u8 smsodsLen; + u8 smsods[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODS + u8 smsooaLen; + u8 smsooa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOA + u8 smsoosLen; + u8 smsoos[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOS + u8 smsoaLen; + u8 smsoa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOA +}IS41_SMDFWD_ARG; + +typedef struct IS41_SMDFWD_RSP +{ + u32 param_flag; + + u8 BearerDataLen; + u8 BearerData[256]; + u8 smsccLen; + u8 smscc[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCC +}IS41_SMDFWD_RSP; + + +typedef struct IS41_SMDPP_ARG +{ + u32 param_flag; + + u8 BearerDataLen; + u8 BearerData[256]; + u8 smstidLen; + u8 smstid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSTID + + //optional part---> + u8 esn[4]; + u8 min[MIN_LEN]; + u8 smscidLen; + u8 smscid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCID + u8 smsdaLen; + u8 smsda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSDA + u8 smsmsgcntLen; + u8 smsmsgcnt[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSMSGCNT + u8 smsnotindLen; + u8 smsnotind[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSNOTIND + + u8 smsodaLen; + u8 smsoda[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODA + u8 smsodsLen; + u8 smsods[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSODS + u8 smsooaLen; + u8 smsooa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOA + u8 smsoosLen; + u8 smsoos[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOOS + u8 smsoaLen; + u8 smsoa[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSOA +}IS41_SMDPP_ARG; + +typedef struct IS41_SMDPP_RSP +{ + u32 param_flag; + + u8 BearerDataLen; + u8 BearerData[256]; + u8 smsccLen; + u8 smscc[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSCC +}IS41_SMDPP_RSP; + +typedef struct IS41_SMSNOT_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + + //optional part---> + u8 smsaccdenLen; + u8 smsaccden[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSACCDEN + u8 smsaddrLen; + u8 smsaddr[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSADDR +}IS41_SMSNOT_ARG; + +typedef struct IS41_SMSNOT_RSP +{ + u32 param_flag; + //NULL +}IS41_SMSNOT_RSP; + +typedef struct IS41_SMSREQ_ARG +{ + u32 param_flag; + + u8 min[MIN_LEN]; + + //optional part---> + u8 esn[4]; + u8 smsnotindLen; + u8 smsnotind[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSNOTIND + u8 smstidLen; + u8 smstid[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSTID +}IS41_SMSREQ_ARG; + +typedef struct IS41_SMSREQ_RSP +{ + u32 param_flag; + + //optional part---> + u8 esn[4]; + u8 smsaccdenLen; + u8 smsaccden[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSACCDEN + u8 smsaddrLen; + u8 smsaddr[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSADDR + + u8 user_error; + u8 provider_error; +}IS41_SMSREQ_RSP; + +typedef struct IS41_PAR_TRIGGER_LIST +{ + u32 param_flag; + + u8 destaddrLen; + u8 destaddr[32]; //DestinationAddress -- choice global title + u8 wintriglistLen; + u8 wintriglist[32]; //WIN_TriggerList +}IS41_PAR_TRIGGER_LIST; + +typedef struct IS41_PAR_WIN_CAP +{ + u32 param_flag; + + u8 triggercapLen; + u8 triggercap[32]; //TriggerCapability + u8 winoprcapLen; + u8 winoprcap[32]; //WIN_OperationsCapability +}IS41_PAR_WIN_CAP; + +typedef struct IS41_PAR_PROFILE +{ + u32 param_flag; + +// optional + u8 authcapLen; + u8 authcap[32];//AuthenticationCapability,IMPLICIT OCTET STRING + u8 cfiLen; + u8 cfi[32];//CallingFeaturesIndicator,IMPLICIT OCTET STRING + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits,IMPLICIT DigitsType + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits,IMPLICIT DigitsType + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits,IMPLICIT DigitsType + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits,IMPLICIT DigitsType + u8 geoauthLen; + u8 geoauth[32];//GeographicAuthorization,IMPLICIT OCTET STRING + u8 mwncountLen; + u8 mwncount[32];//MessageWaitingNotificationCount,IMPLICIT OCTET STRING + u8 mwntypeLen; + u8 mwntype[32];//MessageWaitingNotificationType,IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 origind;//OriginationIndicator,IMPLICIT Unsigned Enumerated + u8 origtrigLen; + u8 origtrig[32];//OriginationTriggers,IMPLICIT OCTET STRING + u8 pacaind;//PACAIndicator,IMPLICIT OCTET STRING + u8 plind;//PreferredLanguageIndicator,IMPLICIT OCTET STRING + u8 resdgtsLen; + u8 resdgts[32];//RestrictionDigits,IMPLICIT DigitsType + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + u8 smsorgres;//SMS_OriginationRestrictions,IMPLICIT OCTET STRING + u8 smstermres;//SMS_TerminationRestrictions,IMPLICIT OCTET STRING + u8 spinipinLen; + u8 spinipin[32];//SPINIPIN,IMPLICIT DigitsType + u8 spinitrigLen; + u8 spinitrig[32];//SPINITriggers,IMPLICIT OCTET STRING + u8 termres;//TerminationRestrictionCode,IMPLICIT Unsigned Enumerated + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM]; //TriggerAddressList, IMPLICIT SET OF + +}IS41_PAR_PROFILE; + +typedef struct IS41_PAR_ISTERM +{ + u32 param_flag; + + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,IMPLICIT DigitsType + u8 mscid[3];//serving + +//optional + u8 accden;//AccessDeniedReason,IMPLICIT Unsigned Enumerated + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits,IMPLICIT DigitsType + u8 esn[4]; + u8 leginfoLen; + u8 leginfo[32];//LegInformation IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 min[MIN_LEN]; + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING +}IS41_PAR_ISTERM; + +typedef struct IS41_PAR_LOCTERM +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 termtrmtLen; + u8 termtrmt[32];//TerminationTreatment,IMPLICIT OCTET STRING + +//optional + u8 alrtcodeLen; + u8 alrtcode[32];//AlertCode,IMPLICIT OCTET STRING + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits,IMPLICIT DigitsType + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,IMPLICIT DigitsType + u8 leginfoLen; + u8 leginfo[32];//LegInformation IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator,IMPLICIT OCTET STRING + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 vmspinLen; + u8 vmspin[32];//VoiceMailboxPIN,IMPLICIT DigitsType + u8 vmboxLen; + u8 vmbox[32];//VoiceMailboxNumber,IMPLICIT DigitsType +}IS41_PAR_LOCTERM; + +typedef struct IS41_PAR_PSTNTERM +{ + u32 param_flag; + + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,IMPLICIT DigitsType + +//optional + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits,IMPLICIT DigitsType + u8 esn[4]; + u8 leginfoLen; + u8 leginfo[32];//LegInformation IMPLICIT OCTET STRING + u8 min[MIN_LEN]; + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING +}IS41_PAR_PSTNTERM; + +typedef struct IS41_PAR_TERMLIST +{ + u32 param_flag; + + IS41_PAR_ISTERM isterm; + IS41_PAR_LOCTERM locterm; + IS41_PAR_PSTNTERM pstnterm; +}IS41_PAR_TERMLIST; + +typedef struct IS41_REGNOT_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 mscid[3]; + u8 qualcode;//QualificationInformationCode,IMPLICIT Unsigned Enumerated + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 avtyp;//Availability Type,IMPLICIT OCTET STRING + u8 bordacc;//BorderCellAccess,IMPLICIT Unsigned Enumerated + u8 ccdata[4];//ControlChannelData,IMPLICIT OCTET STRING + u8 extmscid[4];//ExtendedMSCID,IMPLICIT OCTET STRING + u8 locid[2];//LocationAreaID,IMPLICIT OCTET STRING + u8 pcssn[5]; + u8 rsigqual;//ReceivedSignalQuality,IMPLICIT Unsigned Integer + u8 rpttyp; + u8 senderinLen; + u8 senderin[32]; + u8 smsaddrLen; + u8 smsaddr[MAX_IS41_VARPAR_LEN];//IS41PAR_SMSADDR + u8 smsmwi;//SMS_MessageWaitingIndicator null,zero length + u8 sysaccdata[5];//SystemAccessData,IMPLICIT OCTET STRING + u8 sysacctype; + u8 syscap; + u8 termtyp; + u8 transcapLen; + u8 transcap[32];//TransactionCapability,IMPLICIT OCTET STRING + IS41_PAR_WIN_CAP wincap; +}IS41_REGNOT_ARG; + +typedef struct IS41_REGNOT_RSP +{ + u32 param_flag; + + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 authden;//AuthorizationDenied,IMPLICIT Unsigned Enumerated + u8 authper[2];//AuthorizationPeriod,IMPLICIT OCTET STRING + u8 ccdata[4];//ControlChannelData,IMPLICIT OCTET STRING + u8 denauthperLen; + u8 denauthper[32];//DeniedAuthorizationPeriod,IMPLICIT OCTET STRING + u8 digitsCarrierLen; + u8 digitsCarrier[32]; // carrier + u8 digitsDestLen; + u8 digitsDest[32]; // Destination + u8 mscid[3]; // HLR + + IS41_PAR_PROFILE profile; + + u8 rsigqual;//ReceivedSignalQuality,IMPLICIT Unsigned Integer + u8 senderinLen; + u8 senderin[32]; + u8 smsmwi;//SMS_MessageWaitingIndicator null,zero length + u8 sysaccdata[5];//SystemAccessData,IMPLICIT OCTET STRING + + u8 user_error; + u8 provider_error; +}IS41_REGNOT_RSP; + +typedef struct IS41_REGCANC_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + +//optional + u8 canctyplen; + u8 canctyp[4];//Cancellation Type,IMPLICIT OCTET STRING + u8 ccdata[4];//ControlChannelData,IMPLICIT OCTET STRING + u8 rsigqual;//ReceivedSignalQuality,IMPLICIT Unsigned Integer + u8 senderinLen; + u8 senderin[32]; + u8 sysaccdata[5];//SystemAccessData,IMPLICIT OCTET STRING +}IS41_REGCANC_ARG; + +typedef struct IS41_REGCANC_RSP +{ + u32 param_flag; + +//optional + u8 count; //CallHistoryCount + u8 cancdenied; //CancellationDenied, IMPLICIT Unsigned Enumerated + u8 ccdata[4];//ControlChannelData,IMPLICIT OCTET STRING + u8 rsigqual;//ReceivedSignalQuality,IMPLICIT Unsigned Integer + u8 smsmwi;//SMS_MessageWaitingIndicator null,zero length + u8 sysaccdata[5];//SystemAccessData,IMPLICIT OCTET STRING +}IS41_REGCANC_RSP; + +typedef struct IS41_LOCREQ_ARG +{ + u32 param_flag; + + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 digitsLen; + u8 digits[32]; // originating + u8 mscid[3];//originating + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 cpndgts1Len; + u8 cpndgts1[32];//CallingPartyNumberDigits1,IMPLICIT Digits Type + u8 cpndgts2Len; + u8 cpndgts2[32];//CallingPartyNumberDigits2,IMPLICIT Digits Type + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress,IMPLICIT Subaddress + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 pcssn[5]; + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits,IMPLICIT Digits Type + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress,IMPLICIT Subaddress + u8 tat;//TerminationAccessType,IMPLICIT OCTET STRING + u8 transcapLen; + u8 transcap[32];//TransactionCapability,IMPLICIT OCTET STRING + IS41_PAR_WIN_CAP wincap; +}IS41_LOCREQ_ARG; + +typedef struct IS41_LOCREQ_RSP +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 mscid[3]; + +//optional + u8 accden;//AccessDeniedReason,IMPLICIT Unsigned Enumerated + u8 annlistLen; + u8 annlist[32];//AnnouncementList SEQUENCE OF + u8 cpnstrg1Len; + u8 cpnstrg1[32];//CallingPartyNumberString1,IMPLICIT Digits Type + u8 cpnstrg2Len; + u8 cpnstrg2[32];//CallingPartyNumberString2,IMPLICIT Digits Type + u8 digitsCarrierLen; + u8 digitsCarrier[32]; // carrier + u8 digitsDestLen; + u8 digitsDest[32]; // Destination + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits,IMPLICIT DigitsType + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits,IMPLICIT DigitsType + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits,IMPLICIT DigitsType + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator,IMPLICIT ENUMERATED + u8 grpinfoLen; + u8 grpinfo[32];//GroupInformation,IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 natimeLen; + u8 natime[32];//NoAnswerTime,IMPLICIT OCTET STRING + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator,IMPLICIT OCTET STRING + u8 pcssn[5]; + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits,IMPLICIT Digits Type + u8 rnstringLen; + u8 rnstring[32];//RedirectingNumberString,IMPLICIT Digits Type + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress,IMPLICIT Subaddress + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + IS41_PAR_TERMLIST termlist;//TerminationList,SET OF CHOICE + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM]; //TriggerAddressList, IMPLICIT SET OF + + + u8 user_error; + u8 provider_error; +}IS41_LOCREQ_RSP; + +typedef struct IS41_ROUTREQ_ARG +{ + u32 param_flag; + + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 esn[4]; + u8 min[MIN_LEN]; + u8 mscid[3];//originating MSC + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 alrtcodeLen; + u8 alrtcode[32];//AlertCode,IMPLICIT OCTET STRING + u8 cpnstrg1Len; + u8 cpnstrg1[32];//CallingPartyNumberString1,IMPLICIT Digits Type + u8 cpnstrg2Len; + u8 cpnstrg2[32];//CallingPartyNumberString2,IMPLICIT Digits Type + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress,IMPLICIT Subaddress + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,IMPLICIT DigitsType + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits,IMPLICIT DigitsType + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits,IMPLICIT DigitsType + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits,IMPLICIT DigitsType + u8 leginfoLen; + u8 leginfo[32];//LegInformation,IMPLICIT OCTET STRING + u8 locid[2]; + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 natimeLen; + u8 natime[32];//NoAnswerTime,IMPLICIT OCTET STRING + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator,IMPLICIT OCTET STRING + u8 pcssn[5]; + u8 pilotbid[7];//PilotBillingID,IMPLICIT OCTET STRING + u8 pilotLen; + u8 pilot[32];//PilotNumber,IMPLICIT DigitsType + u8 rnstringLen; + u8 rnstring[32];//RedirectingNumberString,IMPLICIT Digits Type + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress,IMPLICIT Subaddress + u8 senderinLen; + u8 senderin[32]; + u8 termtrmtLen; + u8 termtrmt[32];//TerminationTreatment,IMPLICIT OCTET STRING + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 vmboxLen; + u8 vmbox[32];//VoiceMailboxNumber,IMPLICIT DigitsType + u8 vmspinLen; + u8 vmspin[32];//VoiceMailboxPIN,IMPLICIT DigitsType +}IS41_ROUTREQ_ARG; + +typedef struct IS41_ROUTREQ_RSP +{ + u32 param_flag; + + u8 mscid[3]; + +//optional + u8 accden;//AccessDeniedReason,IMPLICIT Unsigned Enumerated + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 cden;//ConditionallyDeniedReason + u8 digitsLen; + u8 digits[32]; // dialed + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 pcssn[5]; +}IS41_ROUTREQ_RSP; + +typedef struct IS41_MSINACT_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + +//optional part---> + u8 count; + u8 dereg;//DeregistrationType,IMPLICIT Unsigned Enumerated + u8 locid[2]; + u8 senderinLen; + u8 senderin[32]; +// u8 SMS_MessageWaitingIndicator; +}IS41_MSINACT_ARG; + +typedef struct IS41_MSINACT_RSP +{ + u32 param_flag; + +}IS41_MSINACT_RSP;//empty response + +typedef struct IS41_QUALDIR_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 qualcode;//QualificationInformationCode,IMPLICIT Unsigned Enumerated + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 authden;//AuthorizationDenied,IMPLICIT Unsigned Enumerated + u8 authper[2];//AuthorizationPeriod,IMPLICIT OCTET STRING + u8 denauthperLen; + u8 denauthper[32];//DeniedAuthorizationPeriod,IMPLICIT OCTET STRING + u8 digitsCarrierLen; + u8 digitsCarrier[32];// Carrier + u8 digitsDestLen; + u8 digitsDest[32]; // Destination + u8 locid[2];//LocationAreaID + + IS41_PAR_PROFILE profile; + + u8 senderinLen; + u8 senderin[32]; +}IS41_QUALDIR_ARG; + +typedef struct IS41_QUALDIR_RSP +{ + u32 param_flag; +}IS41_QUALDIR_RSP;//empty response + +typedef struct IS41_FEATREQ_ARG +{ + u32 param_flag; + + u8 digitsLen; + u8 digits[32]; // dialed + u8 esn[4]; + u8 min[MIN_LEN]; + +//optional + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 cpndgts1Len; + u8 cpndgts1[32];//CallingPartyNumberDigits1,IMPLICIT Digits Type + u8 cpndgts2Len; + u8 cpndgts2[32];//CallingPartyNumberDigits2,IMPLICIT Digits Type + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress,IMPLICIT Subaddress + u8 cciLen; + u8 cci[32];//ConferenceCallingIndicator,IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 mscid[3]; + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator,IMPLICIT OCTET STRING + u8 pcssn[5]; + u8 senderinLen; + u8 senderin[32]; + u8 transcapLen; + u8 transcap[32];//TransactionCapability,IMPLICIT OCTET STRING +}IS41_FEATREQ_ARG; + +typedef struct IS41_FEATREQ_RSP +{ + u32 param_flag; + + u8 featresult;//FeatureResult, IMPLICIT Unsigned Enumerated + +//optional + u8 accden;//AccessDeniedReason,IMPLICIT Unsigned Enumerated + u8 actcodeLen; + u8 actcode[32];//ActionCode IMPLICIT OCTET STRING + u8 annlistLen; + u8 annlist[32];//AnnouncementList SEQUENCE OF + u8 cpndgts1Len; + u8 cpndgts1[32];//CallingPartyNumberDigits1,IMPLICIT Digits Type + u8 cpndgts2Len; + u8 cpndgts2[32];//CallingPartyNumberDigits2,IMPLICIT Digits Type + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress,IMPLICIT Subaddress + u8 digitsCarrierLen; + u8 digitsCarrier[32];// Carrier + u8 cciLen; + u8 cci[32];//ConferenceCallingIndicator,IMPLICIT OCTET STRING + u8 digitsLen; + u8 digits[32];// Dialed +/* u8 disptextLen;//do not find + u8 disptext[32];*/ + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits,IMPLICIT DigitsType + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits,IMPLICIT DigitsType + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits,IMPLICIT DigitsType + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator,IMPLICIT ENUMERATED + u8 grpinfoLen; + u8 grpinfo[32];//GroupInformation,IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 natimeLen; + u8 natime[32];//NoAnswerTime,IMPLICIT OCTET STRING + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator,IMPLICIT OCTET STRING + u8 pacaind;//PACAIndicator,IMPLICIT OCTET STRING + u8 pilotLen; + u8 pilot[32];//PilotNumber,IMPLICIT DigitsType + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits,IMPLICIT Digits Type + u8 rnstringLen; + u8 rnstring[32];//RedirectingNumberString,IMPLICIT Digits Type + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress,IMPLICIT Subaddress + u8 resumepic;//ResumePIC, IMPLICIT Unsigned Enumerated + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits,IMPLICIT Digits Type + IS41_PAR_TERMLIST termlist;//TerminationList,SET OF CHOICE + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM]; //TriggerAddressList, IMPLICIT SET OF + + u8 user_error; + u8 provider_error; + +}IS41_FEATREQ_RSP; + +typedef struct IS41_REDREQ_ARG +{ + u32 param_flag; + + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 esn[4]; + u8 min[MIN_LEN]; + u8 redreason;//RedirectionReason IMPLICIT Unsigned Enumerated + +//optional + u8 leginfoLen; + u8 leginfo[32];//LegInformation IMPLICIT OCTET STRING + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type +}IS41_REDREQ_ARG; + +typedef struct IS41_REDREQ_RSP +{ + u32 param_flag; +}IS41_REDREQ_RSP;//empty response + +typedef struct IS41_TRANUMREQ_ARG +{ + u32 param_flag; + + u8 esn[4]; + u8 min[MIN_LEN]; + u8 redreason;//RedirectionReason IMPLICIT Unsigned Enumerated + u8 mytyp;//SystemMyTypeCode,IMPLICIT Unsigned Enumerated + +//optional + u8 billid[7];//BillingID,IMPLICIT OCTET STRING + u8 grpinfoLen; + u8 grpinfo[32];//GroupInformation,IMPLICIT OCTET STRING + u8 leginfoLen; + u8 leginfo[32];//LegInformation IMPLICIT OCTET STRING + u8 mscid[3];//originating MSC + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber,IMPLICIT Digits Type + u8 pilotbid[7];//PilotBillingID,IMPLICIT OCTET STRING + u8 pilotLen; + u8 pilot[32];//PilotNumber,IMPLICIT DigitsType + u8 transcapLen; + u8 transcap[32];//TransactionCapability,IMPLICIT OCTET STRING + IS41_PAR_WIN_CAP wincap; +}IS41_TRANUMREQ_ARG; + +typedef struct IS41_TRANUMREQ_RSP +{ + u32 param_flag; + + u8 digitsLen; + u8 digits[32];// Destination + +//optional + u8 accden;//AccessDeniedReason,IMPLICIT Unsigned Enumerated + u8 actcodeLen; + u8 actcode[32];//ActionCode IMPLICIT OCTET STRING + u8 annlistLen; + u8 annlist[32];//AnnouncementList SEQUENCE OF + u8 cpnstrg1Len; + u8 cpnstrg1[32];//CallingPartyNumberString1,IMPLICIT Digits Type + u8 cpnstrg2Len; + u8 cpnstrg2[32];//CallingPartyNumberString2,IMPLICIT Digits Type + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress,IMPLICIT Subaddress + u8 digitsCarrierLen; + u8 digitsCarrier[32]; + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits,IMPLICIT DigitsType + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits,IMPLICIT DigitsType + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits,IMPLICIT DigitsType + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator,IMPLICIT ENUMERATED + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID, IMPLICIT Octet String + u8 grpinfoLen; + u8 grpinfo[32];//GroupInformation,IMPLICIT OCTET STRING + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber,IMPLICIT DigitsType + u8 natimeLen; + u8 natime[32];//NoAnswerTime,IMPLICIT OCTET STRING + u8 plind;//PreferredLanguageIndicator,IMPLICIT OCTET STRING + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits,IMPLICIT Digits Type + u8 rnstringLen; + u8 rnstring[32];//RedirectingNumberString,IMPLICIT Digits Type + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress,IMPLICIT Subaddress + IS41_PAR_TERMLIST termlist;//TerminationList,SET OF CHOICE + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers,IMPLICIT OCTET STRING + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM]; //TriggerAddressList, IMPLICIT SET OF + + u8 user_error; + u8 provider_error; +}IS41_TRANUMREQ_RSP; + +#include "win_struct.h" +/***** is41 *******/ + + +/* +++++++++++++++++++++++++++++ */ +/* the whole operation structure */ +/* +++++++++++++++++++++++++++++ */ +typedef struct MapOprSrv_struct // operation service struct +{ + u32 port_id; + u32 dialogue_id; + u8 invoke_id; + u8 message_type; + u8 message_flag; // distinguish REQUEST,INDICATE,RESPONSE,CONFIRM + u8 version; + union + { + struct MapRIFSM_Arg rifsm_arg; // routing info for SM argument + struct MapRIFSM_Res rifsm_res; // routing info for SM response + struct MapRIFSMV1_Arg rifsm_v1_arg; // routing info for SM argument + struct MapRIFSMV1_Res rifsm_v1_res; // routing info for SM response + struct MapFSM_Arg fsm_arg; // foward sm argument v1; + struct MapMOFSM_Arg mofsm_arg; // MO forward SM argument + struct MapMOFSM_Res mofsm_res; // MO forward SM response + struct MapMTFSM_Arg mtfsm_arg; // MT forward SM argument + struct MapMTFSM_Res mtfsm_res; // MT forward SM response + struct MapRSMDS_Arg rsmds_arg; // report SM delivery status argument + struct MapRSMDS_Res rsmds_res; // report SM delivery status response + struct MapASC_Arg asc_arg; // alert service centre argument + struct MapASC_Res asc_res; // alert service centre response + struct MapISC_Arg isc_arg; // inform service centre argument + struct MapRFSM_Arg rfsm_arg; // ready for SM argument + struct MapRFSM_Res rfsm_res; // ready for SM response + struct MapRSS_Arg rss_arg; // register SS argument + struct MapRSS_Res rss_res; // register SS response + struct MapESS_Arg ess_arg; // erase SS argument + struct MapESS_Res ess_res; // erase SS response + struct MapASS_Arg ass_arg; // activate SS argument + struct MapASS_Res ass_res; // activate SS response + struct MapDASS_Arg dass_arg; // deactivate SS argument + struct MapDASS_Res dass_res; // deactivate SS response + struct MapINTSS_Arg intss_arg; // interrogation SS argument + struct MapINTSS_Res intss_res; // interrogation SS response + struct MapPUSSR_Arg pussr_arg; + struct MapPUSSR_Res pussr_res; + struct MapUSSR_Arg ussr_arg; + struct MapUSSR_Res ussr_res; + struct MapUSSN_Arg ussn_arg; + struct MapUSSN_Res ussn_res; + struct MapRPSS_Arg rpss_arg; // register password argument + struct MapRPSS_Res rpss_res; // register password response + struct MapGPSS_Arg gpss_arg; // get password argument + struct MapGPSS_Res gpss_res; // get password response + struct MapSSIN_Arg ssin_arg; + struct MapSSIN_Res ssin_res; + struct MapRCCE_Arg rcce_arg; + struct MapRCCE_Res rcce_res; + struct MapECCE_Arg ecce_arg; + struct MapECCE_Res ecce_res; + struct MapSRI_Arg sri_arg; // send routing info argument + struct MapSRI_Res sri_res; // send routing info response + struct MapPRN_Arg prn_arg; // provide roaming number argument + struct MapPRN_Res prn_res; // provide roaming number response + struct MapRCH_Arg rch_arg; + struct MapRCH_Res rch_res; + struct MapPSN_Arg psn_arg; + struct MapPSN_Res psn_res; + struct MapSSM_Arg ssm_arg; + struct MapSSM_Res ssm_res; + struct MapSRS_Arg srs_arg; + struct MapSRS_Res srs_res; + struct MapSR_Arg sr_arg; + struct MapSR_Res sr_res; + struct MapRUF_Arg ruf_arg; + struct MapRUF_Res ruf_res; + struct MapATM_Arg atm_arg; // activate trace mode argument + struct MapATM_Res atm_res; // activate trace mode response + struct MapDTM_Arg dtm_arg; // deactivate trace mode argument + struct MapDTM_Res dtm_res; // deactivate trace mode response + struct MapSIMSI_Arg simsi_arg; // send IMSI argument + struct MapSIMSI_Res simsi_res; // send IMSI response + struct MapUL_Arg ul_arg; // update location argument + struct MapUL_Res ul_res; // update location response + struct MapCL_Arg cl_arg; // cancel location argument + struct MapCL_Res cl_res; // cancel location response + struct MapPMS_Arg pms_arg; // purge MS argument + struct MapPMS_Res pms_res; // purge MS response + struct MapSI_Arg si_arg; // send identification argument + struct MapSI_Res si_res; // send identification response + struct MapUGL_Arg ugl_arg; // update GPRS location argument + struct MapUGL_Res ugl_res; // update GPRS location response + struct MapPSI_Arg psi_arg; // provide subscriber info argument + struct MapPSI_Res psi_res; // provide subscriber info response + struct MapATI_Arg ati_arg; // any time interrogation argument + struct MapATI_Res ati_res; // any time interrogation response + struct MapPHO_Arg pho_arg; // prepare handover argument + struct MapPHO_Res pho_res; // prepare handover response + struct MapPFSHO_Arg pfsho_arg; // Preform Subsequence Handover + struct MapPFSHO_Res pfsho_res; // Preform Subsequence Handover + struct MapNIHO_Arg niho_arg; // NoteInternalHandover + struct MapSES_Arg ses_arg; // send end signal argument + struct MapSES_Res ses_res; // send end signal response + struct MapTSA_Arg tsa_arg; // Trace Subscriber activate + struct MapPAS_Arg pas_arg; // process access signalling argument + struct MapFAS_Arg fas_arg; // forward access signalling argument + struct MapPSHO_Arg psho_arg; // prepare subsequent handover argument + struct MapPSHO_Res psho_res; // prepare subsequent handover response + struct MapSAI_Arg sai_arg; // send authenticate info argument + struct MapSAI_Res sai_res; // send authenticate info response + struct MapCIMEI_Arg cimei_arg; // check IMEI argument + struct MapCIMEI_Res cimei_res; // check IMEI response + struct MapISD_Arg isd_arg; // insert subscriber data argument + struct MapISD_Res isd_res; // insert subscriber data response + struct MapDSD_Arg dsd_arg; // delete subscriber data argument + struct MapDSD_Res dsd_res; // delete subscriber data response + struct MapSP_Arg sp_arg; // send parameters argument + struct MapSP_Res sp_res; // send parameters respons + struct MapReset_Arg reset_arg; // reset argument + struct MapRD_Arg rd_arg; // restore data argument + struct MapRD_Res rd_res; // restore data response + struct MapSRIFG_Arg srifg_arg; // send routing info for GPRS argument + struct MapSRIFG_Res srifg_res; // send routing info for GPRS response + struct MapFR_Arg fr_arg; // failure report argument + struct MapBSA_Arg bsa_arg; // Begin subscriber activaty + struct MapFR_Res fr_res; // failure report response + struct MapNMPFG_Arg nmpfg_arg; // note MS present for GPRS argument + struct MapNMPFG_Res nmpfg_res; // note MS present for GPRS response + struct MapST_Arg st_arg; // security triplets argument + struct MapST_Res st_res; // security triplets response + struct MapIS_Arg is_arg; // interrogate subscriber argument + struct MapIS_Res is_res; // interrogate subscriber response + struct MapCS_Arg cs_arg; // create subscriber argument + struct MapCS_Res cs_res; // create subscriber response + struct MapDS_Arg ds_arg; // delete subscriber argument + struct MapDS_Res ds_res; // delete subscirber response + + + /* MAP_V1 */ + struct MapNP_Arg np_arg; //NoteSubscriberPresent argumnet + struct MapPUSSD_Arg pussd_arg; //UnstructuredSS-Data Response + struct MapPUSSD_Res pussd_res; //UnstructuredSS-Data Response + //struct MapSA_Arg sa_arg; //BeginSubscriberActivity argumnet + struct MapHO_Arg ho_arg; //perform hand over argument + struct MapHO_Res ho_res; //perform hand over response + + /* OPR */ + struct MapDetermineOprUser_Arg DetermineOprUser_Arg; + struct MapDetermineOprUser_Res DetermineOprUser_Res; + struct MapCreateUserWithMsisdnImsi_Arg CreateUserWithMsisdnImsi_Arg; + struct MapCreateUserWithMsisdnImsi_Res CreateUserWithMsisdnImsi_Res; + struct MapVlrUpdateLocation_Arg VlrUpdateLocation_Arg; + struct MapVlrUpdateLocation_Res VlrUpdateLocation_Res; + struct MapDeleteOprUser_Arg DeleteOprUser_Arg; + struct MapDeleteOprUser_Res DeleteOprUser_Res; + + /* IMDM */ + struct MapVlrEnquiryIMDM_Arg EnquiryIMDM_Arg; + struct MapVlrEnquiryIMDM_Res EnquiryIMDM_Res; + /* MAP_V1 */ + + /***************** LCS **********/ + RoutingInfoForLCS_Arg routingInfoForLCS_Arg; + RoutingInfoForLCS_Res routingInfoForLCS_Res; + ProvideSubscriberLocation_Arg provideSubscriberLocation_Arg; + ProvideSubscriberLocation_Res provideSubscriberLocation_Res; + /***************** LCS **********/ + +/******is41********/ + struct IS41_AUTHDIR_ARG authdir_arg; + struct IS41_AUTHDIR_RSP authdir_rsp; + struct IS41AucDirectiveForward_arg AUCDirForw_arg; + struct IS41_AFREPORT_ARG afreport_arg; + struct IS41_AFREPORT_RSP afreport_rsp; + struct IS41_AUTHREQ_ARG authreq_arg; + struct IS41_AUTHREQ_RSP authreq_rsp; + struct IS41_ASREPORT_ARG asreport_arg; + struct IS41_ASREPORT_RSP asreport_rsp; + struct IS41_BSCHALL_ARG bschall_arg; + struct IS41_BSCHALL_RSP bschall_rsp; + struct IS41_COUNTREQ_ARG countreq_arg; + struct IS41_COUNTREQ_RSP countreq_rsp; + + struct IS41_SMDBACK_ARG smdback_arg; + struct IS41_SMDBACK_RSP smdback_rsp; + struct IS41_SMDFWD_ARG smdfwd_arg; + struct IS41_SMDFWD_RSP smdfwd_rsp; + struct IS41_SMDPP_ARG smdpp_arg; + struct IS41_SMDPP_RSP smdpp_rsp; + struct IS41_SMSNOT_ARG smsnot_arg; + struct IS41_SMSNOT_RSP smsnot_rsp; + struct IS41_SMSREQ_ARG smsreq_arg; + struct IS41_SMSREQ_RSP smsreq_rsp; + + struct IS41_REGNOT_ARG regnot_arg; + struct IS41_REGNOT_RSP regnot_rsp; + struct IS41_REGCANC_ARG regcanc_arg; + struct IS41_REGCANC_RSP regcanc_rsp; + struct IS41_LOCREQ_ARG locreq_arg; + struct IS41_LOCREQ_RSP locreq_rsp; + struct IS41_ROUTREQ_ARG routreq_arg; + struct IS41_ROUTREQ_RSP routreq_rsp; + struct IS41_MSINACT_ARG msinact_arg; + struct IS41_MSINACT_RSP msinact_rsp; + struct IS41_QUALDIR_ARG qualdir_arg; + struct IS41_QUALDIR_RSP qualdir_rsp; + struct IS41_FEATREQ_ARG featreq_arg; + struct IS41_FEATREQ_RSP featreq_rsp; + struct IS41_REDREQ_ARG redreq_arg; + struct IS41_REDREQ_RSP redreq_rsp; + struct IS41_TRANUMREQ_ARG tranumreq_arg; + struct IS41_TRANUMREQ_RSP tranumreq_rsp; + + /******* is41 for win ******/ + struct IS41_ORREQ_ARG orreq_arg; + struct IS41_ORREQ_RSP orreq_rsp; + struct IS41_ANLYZD_ARG anlyzd_arg; + struct IS41_ANLYZD_RSP anlyzd_rsp; + struct IS41_OANSWER_ARG oanswer_arg; + struct IS41_ODISCONNECT_ARG odisconnect_arg; + struct IS41_ODISCONNECT_RSP odisconnect_rsp; + struct IS41_TANSWER_ARG tanswer_arg; + struct IS41_TDISCONNECT_ARG tdisconnect_arg; + struct IS41_TDISCONNECT_RSP tdisconnect_rsp; + struct IS41_CCDIR_ARG ccdir_arg; + struct IS41_CCDIR_RSP ccdir_rsp; + struct IS41_SEIZERES_ARG seizeres_arg; + struct IS41_SEIZERES_RSP seizeres_rsp; + struct IS41_CONNRES_ARG connres_arg; + struct IS41_SRFDIR_ARG srfdir_arg; + struct IS41_SRFDIR_RSP srfdir_rsp; + struct IS41_SM_ANLYZD_ARG smanlyzd_arg; + struct IS41_SM_ANLYZD_RSP smanlyzd_rsp; + } msg_list; +} MapOprSrv_struct; + +typedef struct MapOprData_struct +{ + u8 map_flag;//is41 or map + u32 param_flag; + u32 port_id; + u32 dialogue_id; + u8 invoke_id; + u8 message_type; + u8 message_flag; + u32 param_len; + u8 param[MAX_MAPPOPR_LEN]; + u8 user_error; + u8 provider_error; + u8 linked_id; +} MapOprData_struct; + +#endif diff --git a/omc/plat/xapp/src/mapp/win_struct.h b/omc/plat/xapp/src/mapp/win_struct.h new file mode 100644 index 0000000..8eb9b07 --- /dev/null +++ b/omc/plat/xapp/src/mapp/win_struct.h @@ -0,0 +1,477 @@ +/***************************/ +/****** WIN Parameter ******/ +/***************************/ +//N.S0009: 6.5.2.bv +typedef struct IS41_PAR_MSID { + u8 choice_flag; //0:min; 1:imsi + u8 min[MIN_LEN]; + u8 imsi[IMSI_LEN]; +} IS41_PAR_MSID; + +//N.S0013: 6.5.2.cl +typedef struct IS41_PAR_EXESCR { + u8 param_flag; + u8 scrnameLen; + u8 scrname[32]; + //optional + u8 scrargLen; + u8 scrarg[96]; +} IS41_PAR_EXESCR; + +/***************************/ +/****** WIN Operation ******/ +/***************************/ +//N.S0018: 6.4.2.30 OriginationRequest INVOKE +typedef struct IS41_ORREQ_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 + u8 digitsLen; + u8 digits[32];//Digits (Dialed) M 6.5.2.58 + u8 esn[4];//ElectronicSerialNumber M 6.5.2.63 + u8 mscid[3];//MSCID (Originating MSC) M 6.5.2.82 + IS41_PAR_MSID msid;//MSID M 6.5.2.bv k + u8 origtrigLen; + u8 origtrig[32];//OriginationTriggers M 6.5.2.90 + u8 transcapLen; + u8 transcap[32];//TransactionCapability M 6.5.2.160 + //optional + u8 cpnameLen; + u8 cpname[32];//CallingPartyName O 6.5.2.bw g, i + u8 cpndgts1Len; + u8 cpndgts1[32];//CallingPartyNumberDigits1 O 6.5.2.21 a + u8 cpndgts2Len; + u8 cpndgts2[32];//CallingPartyNumberDigits2 O 6.5.2.22 a + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress O 6.5.2.25 a + u8 locid[2];//LocationAreaID O 6.5.2.77 a, l + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 b + u8 featindLen; + u8 featind[32];//FeatureIndicator O 6.5.2.ej m + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 c + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator O 6.5.2.88 d + u8 pc_ssn[5];//PC_SSN (Originating MSC) O 6.5.2.93 e + u8 plind;//PreferredLanguageIndicator O 6.5.2.96 j + u8 senderinLen; + u8 senderin[32];//SenderIdentificationNumber O 6.5.2.116 f + u8 scellid[2];//ServingCellID O 6.5.2.117 a, n + u8 triggertype;//TriggerType O 6.5.2.dh h + IS41_PAR_WIN_CAP wincap;//WINCapability O 6.5.2.di o +} IS41_ORREQ_ARG; + +//N.S0018: 6.4.2.30 OriginationRequest RETURN RESULT +typedef struct IS41_ORREQ_RSP { + u32 param_flag; + //optional + u8 accden;//AccessDeniedReason O 6.5.2.1 a + u8 actcodeLen; + u8 actcode[32];//ActionCode O 6.5.2.2 b + u8 annlistLen; + u8 annlist[32];//AnnouncementList O 6.5.2.6 c + u8 cpnstrg1Len; + u8 cpnstrg1[32];//CallingPartyNumberString1 O 6.5.2.23 d, e + u8 cpnstrg2Len; + u8 cpnstrg2[32];//CallingPartyNumberString2 O 6.5.2.24 d, e + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress O 6.5.2.25 d, e, f + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits O 6.5.2.28 g + u8 digitsLen; + u8 digits[32];//Digits (Dialed) O 6.5.2.58 h + u8 disptextLen; + u8 disptext[32];//DisplayText O 6.5.2.bx d, e, r + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits O 6.5.2.59 i + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits O 6.5.2.60 i + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits O 6.5.2.61 i + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator O 6.5.2.62 i, j + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID O 6.5.2.ei s + u8 grpinfoLen; + u8 grpinfo[32];//GroupInformation O 6.5.2.69 k + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 i + u8 natimeLen; + u8 natime[32];//NoAnswerTime O 6.5.2.87 l + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator O 6.5.2.88 m + u8 pilotLen; + u8 pilot[32];//PilotNumber O 6.5.2.95 k + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits O 6.5.2.107 f + u8 rnstringLen; + u8 rnstring[32];//RedirectingNumberString O 6.5.2.108 d + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress O 6.5.2.109 d, e + u8 resumepic;//ResumePIC O 6.5.2.cu p + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits O 6.5.2.114 g + IS41_PAR_TERMLIST termlist;//TerminationList O 6.5.2.156 n + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers O 6.5.2.57 o //should be 6.5.2.159 + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM];//TriggerAddressList O 6.5.2.de q +} IS41_ORREQ_RSP; + +//N.S0018: 6.4.2.i AnalyzedInformation INVOKE +typedef struct IS41_ANLYZD_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 a + u8 digitsLen; + u8 digits[32];//Digits (Dialed) M 6.5.2.58 + u8 mscid[3];//MSCID (Originating) M 6.5.2.82 b + u8 transcapLen; + u8 transcap[32];//TransactionCapability M 6.5.2.160 + u8 triggertype;//TriggerType M 6.5.2.dh c + IS41_PAR_WIN_CAP wincap;//WINCapability M 6.5.2.di d + //optional + u8 cpnameLen; + u8 cpname[32];//CallingPartyName O 6.5.2.bw e, m + u8 cpndgts1Len; + u8 cpndgts1[32];//CallingPartyNumberDigits1 O 6.5.2.21 e + u8 cpndgts2Len; + u8 cpndgts2[32];//CallingPartyNumberDigits2 O 6.5.2.22 e + u8 cpsubLen; + u8 cpsub[32];//CallingPartySubaddress O 6.5.2.25 e + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits O 6.5.2.28 n, o + u8 cciLen; + u8 cci[32];//ConferenceCallingIndicator O 6.5.2.49 f + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits O 6.5.2.56 n, p + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator O 6.5.2.62 q + u8 esn[4];//ElectronicSerialNumber O 6.5.2.63 g, r + u8 featindLen; + u8 featind[32];//FeatureIndicator O 6.5.2.ej s + u8 locid[2];//LocationAreaID O 6.5.2.77 h, t + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 i + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 j + IS41_PAR_MSID msid;//MSID O 6.5.2.bv g, r + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator O 6.5.2.88 k + u8 plind;//PreferredLanguageIndicator O 6.5.2.96 + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits O 6.5.2.107 e + u8 rdnameLen; + u8 rdname[32];//RedirectingPartyName O 6.5.2.by b, m + u8 rsubLen; + u8 rsub[32];//RedirectingSubaddress O 6.5.2.109 e + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits O 6.5.2.114 n, u + u8 scellid[2];//ServingCellID O 6.5.2.117 h, v + u8 mytyp;//SystemMyTypeCode O 6.5.2.147 + u8 tat;//TerminationAccessType O 6.5.2.155 l + u8 tdo[2];//TimeDateOffset O 6.5.2.dd w + u8 tod[3];//TimeOfDay O 6.5.2.em x +} IS41_ANLYZD_ARG; + +//N.S0018: 6.4.2.i AnalyzedInformation RETURN RESULT +typedef struct IS41_ANLYZD_RSP { + u32 param_flag; + //optional + u8 accden;//AccessDeniedReason O 6.5.2.1 a + u8 actcodeLen; + u8 actcode[32];//ActionCode O 6.5.2.2 b + u8 annlistLen; + u8 annlist[32];//AnnouncementList O 6.5.2.6 c + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits O 6.5.2.28 d + u8 cciLen; + u8 cci[32];//ConferenceCallingIndicator O 6.5.2.49 e + u8 digitsLen; + u8 digits[32];//Digits (Dialed) O 6.5.2.58 f + u8 disptextLen; + u8 disptext[32];//DisplayText O 6.5.2.bx d, m + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits O 6.5.2.59 g + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits O 6.5.2.60 g + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits O 6.5.2.61 g + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator O 6.5.2.62 g, h + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID O 6.5.2.ei n + u8 natimeLen; + u8 natime[32];//NoAnswerTime O 6.5.2.87 i + u8 otfiLen; + u8 otfi[32];//OneTimeFeatureIndicator O 6.5.2.88 j + u8 rndgtsLen; + u8 rndgts[32];//RedirectingNumberDigits O 6.5.2.107 d + u8 resumepic;//ResumePIC O 6.5.2.cu k + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits O 6.5.2.114 d + IS41_PAR_TERMLIST termlist;//TerminationList O 6.5.2.156 l + u8 termtrigLen; + u8 termtrig[32];//TerminationTriggers O 6.5.2.159 d + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM];//TriggerAddressList O 6.5.2.de d, o +} IS41_ANLYZD_RSP; + +//N.S0018: 6.4.2.aa OAnswer INVOKE +typedef struct IS41_OANSWER_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 a + u8 esn[4];//ElectronicSerialNumber M 6.5.2.63 b + u8 mscid[3];//MSCID (Originating) M 6.5.2.82 c + IS41_PAR_MSID msid;//MSID M 6.5.2.bv d + u8 tdo[2];//TimeDateOffset M 6.5.2.dd e + u8 tod[3];//TimeOfDay M 6.5.2.em f + u8 triggertype;//TriggerType M 6.5.2.dh g + //optional + u8 locid[2];//LocationAreaID O 6.5.2.77 h, i + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 j + u8 featindLen; + u8 featind[32];//FeatureIndicator O 6.5.2.ej k + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 l + u8 scellid[2];//ServingCellID O 6.5.2.117 h, m + u8 mytyp;//SystemMyTypeCode O 6.5.2.147 +} IS41_OANSWER_ARG; + +//N.S0018: 6.4.2.ab ODisconnect INVOKE +typedef struct IS41_ODISCONNECT_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 a + u8 esn[4];//ElectronicSerialNumber M 6.5.2.63 b + u8 mscid[3];//MSCID (Originating) M 6.5.2.82 c + IS41_PAR_MSID msid;//MSID M 6.5.2.bv d + u8 relcause;//ReleaseCause M 6.5.2.el e + u8 tdo[2];//TimeDateOffset M 6.5.2.dd f + u8 tod[3];//TimeOfDay M 6.5.2.em g + u8 transcapLen; + u8 transcap[32];//TransactionCapability M 6.5.2.160 + IS41_PAR_WIN_CAP wincap;//WINCapability M 6.5.2.di + u8 triggertype;//TriggerType M 6.5.2.dh h + //optional + u8 locid[2];//LocationAreaID O 6.5.2.77 i, j + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 k + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 l + u8 scellid[2];//ServingCellID O 6.5.2.117 i, m + u8 mytyp;//SystemMyTypeCode O 6.5.2.147 +} IS41_ODISCONNECT_ARG; + +//N.S0018: 6.4.2.ab ODisconnect RETURN RESULT +typedef struct IS41_ODISCONNECT_RSP { + u32 param_flag; + //optional + u8 annlistLen; + u8 annlist[32];//AnnouncementList O 6.5.2.6 a + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID O 6.5.2.ei b +} IS41_ODISCONNECT_RSP; + +//N.S0018: 6.4.2.ad TAnswer INVOKE +typedef struct IS41_TANSWER_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 a + u8 esn[4];//ElectronicSerialNumber M 6.5.2.63 b + u8 mscid[3];//MSCID M 6.5.2.82 c + IS41_PAR_MSID msid;//MSID M 6.5.2.bv b + u8 tdo[2];//TimeDateOffset M 6.5.2.dd d + u8 tod[3];//TimeOfDay M 6.5.2.em e + u8 transcapLen; + u8 transcap[32];//TransactionCapability M 6.5.2.160 + u8 triggertype;//TriggerType M 6.5.2.dh f + IS41_PAR_WIN_CAP wincap;//WINCapability M 6.5.2.di + //optional + u8 locid[2];//LocationAreaID O 6.5.2.77 g, h + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 i + u8 featindLen; + u8 featind[32];//FeatureIndicator O 6.5.2.ej j + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 k + u8 scellid[2];//ServingCellID O 6.5.2.117 g, l + u8 mytyp;//SystemMyTypeCode O 6.5.2.147 + u8 tat;//TerminationAccessType O 6.5.2.155 m +} IS41_TANSWER_ARG; + +//N.S0018: 6.4.2.ae TDisconnect INVOKE +typedef struct IS41_TDISCONNECT_ARG { + u32 param_flag; + u8 billid[7];//BillingID (Originating) M 6.5.2.16 a + u8 esn[4];//ElectronicSerialNumber M 6.5.2.63 b + u8 mscid[3];//MSCID M 6.5.2.82 c + IS41_PAR_MSID msid;//MSID M 6.5.2.bv d + u8 tdo[2];//TimeDateOffset M 6.5.2.dd e + u8 tod[3];//TimeOfDay M 6.5.2.em f + u8 triggertype;//TriggerType M 6.5.2.dh g + //optional + u8 locid[2];//LocationAreaID O 6.5.2.77 h, i + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 j + u8 mscinLen; + u8 mscin[32];//MSCIdentificationNumber O 6.5.2.83 k + u8 relcause;//ReleaseCause O 6.5.2.el l + u8 scellid[2];//ServingCellID O 6.5.2.117 h, m + u8 mytyp;//SystemMyTypeCode O 6.5.2.147 +} IS41_TDISCONNECT_ARG; + +//N.S0018: 6.4.2.ae TDisconnect RETURN RESULT +typedef struct IS41_TDISCONNECT_RSP { + u32 param_flag; + //optional + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID O 6.5.2.ei a +} IS41_TDISCONNECT_RSP; + +//N.S0018: 6.4.2.z CallControlDirective INVOKE +typedef struct IS41_CCDIR_ARG { + u32 param_flag; + u8 billid[7];//BillingID M 6.5.2.16 a + u8 mscid[3];//MSCID M 6.5.2.82 b + IS41_PAR_MSID msid;//MSID M 6.5.2.bv c + //optional + u8 actcodeLen; + u8 actcode[32];//ActionCode O 6.5.2.2 d + u8 annlistLen; + u8 annlist[32];//AnnouncementList O 6.5.2.6 e + u8 disptextLen; + u8 disptext[32];//DisplayText O 6.5.2.bx f + u8 acdgtsLen; + u8 acdgts[32];//DMH_AccountCodeDigits O 6.5.2.59 g + u8 abdgtsLen; + u8 abdgts[32];//DMH_AlternateBillingDigits O 6.5.2.60 g + u8 billdgtsLen; + u8 billdgts[32];//DMH_BillingDigits O 6.5.2.61 g + u8 redindLen; + u8 redind[32];//DMH_RedirectionIndicator O 6.5.2.62 g, h + u8 esn[4];//ElectronicSerialNumber O 6.5.2.63 i, j + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 k + u8 plind;//PreferredLanguageIndicator O 6.5.2.96 l, m + IS41_PAR_TERMLIST termlist;//TerminationList O 6.5.2.156 n + u8 triggerlistnum; + IS41_PAR_TRIGGER_LIST triggerlist[MAX_IS41_TRIG_LIST_NUM];//TriggerAddressList O 6.5.2.de h +} IS41_CCDIR_ARG; + +//N.S0018: 6.4.2.z CallControlDirective RETURN RESULT +typedef struct IS41_CCDIR_RSP { + u32 param_flag; + //optional + u8 callstatusLen; + u8 callstatus[32];//CallStatus O 6.5.2.en a +} IS41_CCDIR_RSP; + +//N.S0013: 6.4.2.r SeizeResource INVOKE +typedef struct IS41_SEIZERES_ARG { + u32 param_flag; + //optional + u8 plind;//PreferredLanguageIndicator O 6.5.2.96 + u8 psrLen; + u8 psr[32];//PrivateSpecializedResource O 6.5.2.u a //should be 6.5.2.ct + u8 srLen; + u8 sr[32];//SpecializedResource O 6.5.2.dc a +} IS41_SEIZERES_ARG; + +//N.S0013: 6.4.2.r SeizeResource RETURN RESULT +typedef struct IS41_SEIZERES_RSP { + u32 param_flag; + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits M 6.5.2.56 a +} IS41_SEIZERES_RSP; + +//N.S0013: 6.4.2.k ConnectResource INVOKE +typedef struct IS41_CONNRES_ARG { + u32 param_flag; + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits M 6.5.2.56 + //optional + u8 cardgtsLen; + u8 cardgts[32];//CarrierDigits O 6.5.2.28 a + u8 routdgtsLen; + u8 routdgts[32];//RoutingDigits O 6.5.2.114 a +} IS41_CONNRES_ARG; + +//N.S0013: 6.4.2.n InstructionRequest INVOKE & RETURN RESULT +typedef struct IS41_INSTREQ_ARG { + u32 param_flag; //no parameter +} IS41_INSTREQ_ARG; + +typedef struct IS41_INSTREQ_RSP { + u32 param_flag; //no parameter +} IS41_INSTREQ_RSP; + +//N.S0018: 6.4.2.s SRFDirective INVOKE +typedef struct IS41_SRFDIR_ARG { + u32 param_flag; + //optional + u8 annlistLen; + u8 annlist[32];//AnnouncementList O 6.5.2.6 a, d + u8 dgtccLen; + u8 dgtcc[32];//DigitCollectionControl O 6.5.2.57 b + IS41_PAR_EXESCR exescr;//ExecuteScript O 6.5.2.cl c, d + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 e +} IS41_SRFDIR_ARG; + +//N.S0013: 6.4.2.s SRFDirective RETURN RESULT +typedef struct IS41_SRFDIR_RSP { + u32 param_flag; + //optional + u8 digitsLen; + u8 digits[32];//Digits (Dialed) O 6.5.2.58 a, b + u8 scrresultLen; + u8 scrresult[96];//ScriptResult O 6.5.2.cx c +} IS41_SRFDIR_RSP; + +//X.S0010: 6.4.2.ax ShortMessageAnalyzed INVOKE +typedef struct IS41_SM_ANLYZD_ARG { + u32 param_flag; + u8 sms_brlen[2];//SMS_BearerLength M 6.5.2.hn a + u8 sms_billidLen; + u8 sms_billid[32];//SMS_BillingID M 6.5.2.ho b + u8 sms_event;//SMS_Event M 6.5.2.hp c + u8 smstidLen; + u8 smstid[MAX_IS41_VARPAR_LEN];//SMS_TeleserviceIdentifier M 6.5.2.137 d + //optional + u8 esn[4];//ElectronicSerialNumber O 6.5.2.63 e, f + u8 mdnLen; + u8 mdn[32];//MobileDirectoryNumber O 6.5.2.80 e, f, g + IS41_PAR_MSID msid;//MSID O 6.5.2.bv e, f, g + u8 smscidLen; + u8 smscid[MAX_IS41_VARPAR_LEN];//SMS_ChargeIndicator O 6.5.2.126 h + u8 smsdaLen; + u8 smsda[MAX_IS41_VARPAR_LEN];//SMS_DestinationAddress O 6.5.2.127 i + u8 sms_pmcnt[4];//SMS_PendingMessageCount O 6.5.2.hr j + u8 smsodaLen; + u8 smsoda[MAX_IS41_VARPAR_LEN];//SMS_OriginalDestinationAddress O 6.5.2.131 k + u8 smsodsLen; + u8 smsods[MAX_IS41_VARPAR_LEN];//SMS_OriginalDestinationSubaddress O 6.5.2.132 l + u8 smsooaLen; + u8 smsooa[MAX_IS41_VARPAR_LEN];//SMS_OriginalOriginatingAddress O 6.5.2.133 m + u8 smsoosLen; + u8 smsoos[MAX_IS41_VARPAR_LEN];//SMS_OriginalOriginatingSubaddress O 6.5.2.134 l + u8 smsoaLen; + u8 smsoa[MAX_IS41_VARPAR_LEN];//SMS_OriginatingAddress O 6.5.2.135 n + u8 tdo[2];//TimeDateOffset O 6.5.2.dd o + u8 tod[3];//TimeOfDay O 6.5.2.em p +} IS41_SM_ANLYZD_ARG; + +//X.S0010: 6.4.2.ax ShortMessageAnalyzed RETURN RESULT +typedef struct IS41_SM_ANLYZD_RSP { + u32 param_flag; + //optional + u8 dmh_svcidLen; + u8 dmh_svcid[32];//DMH_ServiceID O 6.5.2.ei a + u8 smsbdLen; + u8 smsbd[256];//SMS_BearerData O 6.5.2.124 b + u8 smscauseLen; + u8 smscause[32];//SMS_CauseCode O 6.5.2.125 c + u8 sms_eventnotLen; + u8 sms_eventnot[32];//SMS_EventNotification O 6.5.2.hq d +} IS41_SM_ANLYZD_RSP; + + diff --git a/omc/plat/xapp/src/xap_cdmacdr.c b/omc/plat/xapp/src/xap_cdmacdr.c new file mode 100644 index 0000000..bb73e63 --- /dev/null +++ b/omc/plat/xapp/src/xap_cdmacdr.c @@ -0,0 +1,1755 @@ +/* HLR CDMA cdr coding */ +/* Created by daniel:2005-06-21 */ +/* Modify by daniel:2005-06-21 */ +/* -------------------------------- */ + +#include "../../public/src/include/asn1.h" +#include "../../public/src/include/includes.h" +#include "../../public/src/include/pub_fmt.h" +#include "../../sccp/src/include/sccp.h" +#include "./mapp/map_const.h" +#include "xap_cdmacdr.h" + +char *is41_sequenceTag(char *tag,int sequence); + +void encode_param_CallLocation(DMH_CallLocation *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + u8 temp[8]; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_HCOORD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->HcoordinateLen % 3,ptr->Hcoordinate,0x40,asn_buf); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NPANXX); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->NPANXX,0x40,asn_buf); + } + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_PLNAM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->PlaceNameLen % 20,ptr->PlaceName,0x40,asn_buf); + } + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SPNAM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),2,ptr->StateProvinceName,0x40,asn_buf); + } + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_VCOORD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->VcoordinateLen % 3,ptr->Vcoordinate,0x40,asn_buf); + } + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LATA); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->LocalAccessTransportAreaLen % 4,ptr->LocalAccessTransportArea,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_WCNTRY); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->WorldCountry,0x40,asn_buf); + } +} + +void encode_param_cnvusg(DMH_ConversationUsage *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + u8 temp[8]; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DATE); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->Date,0x40,asn_buf); + } + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RELIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->relind,0x40,asn_buf); + } + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TDO); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->tdoLen % 3,ptr->tdo,0x40,asn_buf); + } + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMOCT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numoctLen % 5,ptr->numoct,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMPKT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numpktLen % 5,ptr->numpkt,0x40,asn_buf); + } +} + +void encode_param_swid(DMH_SwitchID *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SWNO); + *buf_len = AddTLV(tag,1,&ptr->swno,0x40,asn_buf); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SID); + *buf_len = AddTLV(tag,2,ptr->sid,0x40,asn_buf); + } + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_BRI); + *buf_len = AddTLV(tag,2,ptr->bri,0x40,asn_buf); + } + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_MYTYP); + *buf_len = AddTLV(tag,1,&ptr->mytyp,0x40,asn_buf); + } +} + +void encode_param_bfpath(DMH_BeginForwardPath *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CELLID); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->cellidLen % 3,ptr->cellid,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_MODIND); + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->modind,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RCHNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,3),ptr->rchnumLen % 3,ptr->rchnum,0x40,asn_buf); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TKNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->tknumLen % 3,ptr->tknum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_achusg(DMH_AirChannelUsage *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DATE); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->Date,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_fbusg(DMH_FeatureBridgeUsage *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FBIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->fbind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RLEG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->rlegLen % 3,ptr->rleg,0x40,asn_buf); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_incusg(DMH_IncomingTrunkUsage *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TKNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->tknumLen % 3,ptr->tknum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_ogtusg(DMH_OutgoingTrunkUsage *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + *buf_len = AddTLV(tag1,0,temp,0x60,asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TKNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->tknumLen % 3,ptr->tknum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_audsub(DMH_AuditSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + u8 temp[8]; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUDSN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->audsnLen % 5,ptr->audsn,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_ACHDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->achdurLen % 5,ptr->achdur,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CNVDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->cnvdurLen % 5,ptr->cnvdur,0x40,asn_buf); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FBDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->fbdurLen % 5,ptr->fbdur,0x40,asn_buf); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_IECCDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->ieccdurLen % 5,ptr->ieccdur,0x40,asn_buf); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_INCDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->incdurLen % 5,ptr->incdur,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMACT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numactLen % 5,ptr->numact,0x40,asn_buf); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMCHRG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numchrgLen % 5,ptr->numchrg,0x40,asn_buf); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMEVT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numevtLen % 5,ptr->numevt,0x40,asn_buf); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMLEG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numlegLen % 5,ptr->numleg,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMSEG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numsegLen % 5,ptr->numseg,0x40,asn_buf); + } + + if (flag & BIT11_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_OGTDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->ogtdurLen % 5,ptr->ogtdur,0x40,asn_buf); + } + + if (flag & BIT12_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMFAL); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numfalLen % 5,ptr->numfal,0x40,asn_buf); + } + + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMORG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numorgLen % 8,ptr->numorg,0x40,asn_buf); + } + + if (flag & BIT14_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMRED); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numredLen % 5,ptr->numred,0x40,asn_buf); + } + + if (flag & BIT15_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMTRM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numtrmLen % 5,ptr->numtrm,0x40,asn_buf); + } + + if (flag & BIT16_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMAUX); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numauxLen % 5,ptr->numaux,0x40,asn_buf); + } + + if (flag & BIT17_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMOCT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numoctLen % 5,ptr->numoct,0x40,asn_buf); + } + + if (flag & BIT18_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMPKT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numpktLen % 5,ptr->numpkt,0x40,asn_buf); + } + + if (flag & BIT19_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_IWFDUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->iwfdurLen % 5,ptr->iwfdur,0x40,asn_buf); + } + + if (flag & BIT20_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FILLIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->fillind.FaultyParameter.ParameterIdentifierLen % 17,ptr->fillind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FILLIC);//FillIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->fillind.FillIndicatorCode,0x40,asn_buf); + } + + if (flag & BIT21_TRUE) + { + if (ptr->retind.param_flag & 3) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RETIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + } + + if (ptr->retind.param_flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_RICODE);//ReturnIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->retind.ReturnIndicatorCode,0x40,asn_buf); + } + if (ptr->retind.param_flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->retind.FaultyParameter.ParameterIdentifierLen % 17,ptr->retind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + } + } +} + +void encode_param_idsub(DMH_IdentitySubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_DATE,offset++); + *buf_len = AddTLV(tag,3,ptr->Date,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + if (ptr->Choice1.ChoiceFlag == 0) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_ESN,offset++); + *buf_len = AddTLV(tag,4,ptr->Choice1.esn,0x40,asn_buf); + } + else + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_IMEI,offset++); + *buf_len = AddTLV(tag,5,ptr->Choice1.imei,0x40,asn_buf); + } + } + + if (flag & BIT2_TRUE) + { + switch (ptr->Choice2.ChoiceFlag) + { + case 0: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_MIN,offset++); + *buf_len = AddTLV(tag,5,ptr->Choice2.min,0x40,asn_buf); + break; + case 1: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_IMSI,offset++); + *buf_len = AddTLV(tag,8,ptr->Choice2.imsi,0x40,asn_buf); + break; + case 2: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_NEICLNP,offset++); + *buf_len = AddTLV(tag,19,ptr->Choice2.neiclnp,0x40,asn_buf); + break; + case 3: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_NEIIP,offset++); + *buf_len = AddTLV(tag,4,ptr->Choice2.neiip,0x40,asn_buf); + break; + default: + break; + } + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_TDO,offset++); + *buf_len = AddTLV(tag,ptr->tdoLen % 3,ptr->tdo,0x40,asn_buf); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_TOD,offset++); + *buf_len = AddTLV(tag,ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT5_TRUE) + { + switch (ptr->Choice3.ChoiceFlag) + { + case 0: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_ASWID,offset++); + encode_param_swid(&ptr->Choice3.aswid,asn_buf,buf_len,tag); + break; + case 1: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_OSWID,offset++); + encode_param_swid(&ptr->Choice3.oswid,asn_buf,buf_len,tag); + break; + case 2: + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_SSWID,offset++); + encode_param_swid(&ptr->Choice3.sswid,asn_buf,buf_len,tag); + break; + default: + break; + } + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_BIN,offset++); + *buf_len = AddTLV(tag,ptr->binLen % 5,ptr->bin,0x40,asn_buf); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_HSWID,offset++); + encode_param_swid(&ptr->hswid,asn_buf,buf_len,tag); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_MDN,offset++); + *buf_len = AddTLV(tag,ptr->mdnLen % 9,ptr->mdn,0x40,asn_buf); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d-%d.%d",tag1,DMHPAR_FILLIND,offset++,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->fillind.FaultyParameter.ParameterIdentifierLen % 17,ptr->fillind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + + sprintf(tag,"%s.%d-%d.%d",tag1,DMHPAR_FILLIND,offset++,DMHPAR_FILLIC);//FillIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->fillind.FillIndicatorCode,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + { + if (ptr->retind.param_flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d.%d",tag1,DMHPAR_RETIND,offset++,DMHPAR_RICODE);//ReturnIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,1),1,&ptr->retind.ReturnIndicatorCode,0x40,asn_buf); + } + if (ptr->retind.param_flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d-%d.%d",tag1,DMHPAR_RETIND,offset++,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,2),ptr->retind.FaultyParameter.ParameterIdentifierLen % 17,ptr->retind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + } + } +} + +void encode_param_evtsub(DMH_EventSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_EVTIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->evtind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RIN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->rinLen % 5,ptr->rin,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_ASWID,offset++); + encode_param_swid(&ptr->aswid,asn_buf,buf_len,tag); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUTHCNT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->authcnt,0x40,asn_buf); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUTHDEN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->authden,0x40,asn_buf); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUTHTYP); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->authtyp,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_BIN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->binLen % 5,ptr->bin,0x40,asn_buf); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DATE); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->Date,0x40,asn_buf); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DENACC); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->denacc,0x40,asn_buf); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FEATIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->featind,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FEATOPN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->featopn,0x40,asn_buf); + } + + if (flag & BIT11_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FRIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->frind,0x40,asn_buf); + } + + if (flag & BIT12_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_OSWID,offset++); + encode_param_swid(&ptr->oswid,asn_buf,buf_len,tag); + } + + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RBIN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->rbinLen % 5,ptr->rbin,0x40,asn_buf); + } + + if (flag & BIT14_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SRT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->srt,0x40,asn_buf); + } + + if (flag & BIT15_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_SSWID,offset++); + encode_param_swid(&ptr->sswid,asn_buf,buf_len,tag); + } + + if (flag & BIT16_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TDO); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->tdoLen % 5,ptr->tdo,0x40,asn_buf); + } + + if (flag & BIT17_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT18_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FILLIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->fillind.FaultyParameter.ParameterIdentifierLen % 17,ptr->fillind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FILLIC);//FillIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->fillind.FillIndicatorCode,0x40,asn_buf); + } + + if (flag & BIT19_TRUE) + { + if (ptr->retind.param_flag & 3) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RETIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + } + + if (ptr->retind.param_flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_RICODE);//ReturnIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->retind.ReturnIndicatorCode,0x40,asn_buf); + } + if (ptr->retind.param_flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->retind.FaultyParameter.ParameterIdentifierLen % 17,ptr->retind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + } + } +} + +void encode_param_chrgsub(DMH_ChargeSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + u8 temp[8]; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGAMT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->chrgamtLen % 5,ptr->chrgamt,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->chrgind,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGTAX); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->chrgtaxLen % 5,ptr->chrgtax,0x40,asn_buf); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGTIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->chrgtind,0x40,asn_buf); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGUNIT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->chrgunit,0x40,asn_buf); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_MRPI); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->mrpi,0x40,asn_buf); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_PLNAM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->plnamLen % 21,ptr->plnam,0x40,asn_buf); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RPI); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->rpi,0x40,asn_buf); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SPNAM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),2,ptr->spnam,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TTIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->ttind,0x40,asn_buf); + } + + if (flag & BIT11_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_WCNTRY); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->wcntry,0x40,asn_buf); + } + + if (flag & BIT12_TRUE) + { + if (ptr->Choice.ChoiceFlag == 0) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->Choice.lnum,0x40,asn_buf); + } + else + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SEGNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->Choice.segnum,0x40,asn_buf); + } + } + + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGTCOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->chrgtcodLen % 3,ptr->chrgtcod,0x40,asn_buf); + } + + if (flag & BIT14_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGTTBL); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->chrgttbl,0x40,asn_buf); + } + + if (flag & BIT15_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMOCT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numoctLen % 5,ptr->numoct,0x40,asn_buf); + } + + if (flag & BIT16_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_NUMPKT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->numpktLen % 5,ptr->numpkt,0x40,asn_buf); + } + + if (flag & BIT17_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SELUSE); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->seluseLen % 101,ptr->seluse,0x40,asn_buf); + } + + if (flag & BIT18_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SUCOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->sucod,0x40,asn_buf); + } + + if (flag & BIT19_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TEXIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->texind,0x40,asn_buf); + } + + if (flag & BIT20_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FILLIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->fillind.FaultyParameter.ParameterIdentifierLen % 17,ptr->fillind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FILLIC);//FillIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->fillind.FillIndicatorCode,0x40,asn_buf); + } + + if (flag & BIT21_TRUE) + { + if (ptr->retind.param_flag & 3) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RETIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + } + + if (ptr->retind.param_flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_RICODE);//ReturnIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->retind.ReturnIndicatorCode,0x40,asn_buf); + } + if (ptr->retind.param_flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->retind.FaultyParameter.ParameterIdentifierLen % 17,ptr->retind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + } + } +} + +void encode_param_actsub(DMH_ActivitySubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_ACTIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->actind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RIN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->rinLen % 5,ptr->rin,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUTHDEN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->authden,0x40,asn_buf); + } + + if (flag & BIT3_TRUE)//BeginForwardPath, encode in the future + {} + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_BIN); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->binLen % 5,ptr->bin,0x40,asn_buf); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DATE); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),3,ptr->Date,0x40,asn_buf); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DENACC); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->denacc,0x40,asn_buf); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SRT); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->srt,0x40,asn_buf); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_SSWID,offset++); + encode_param_swid(&ptr->sswid,asn_buf,buf_len,tag); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TDO); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->tdoLen % 3,ptr->tdo,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TOD); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->todLen % 4,ptr->tod,0x40,asn_buf); + } + + if (flag & BIT11_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FILLIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->fillind.FaultyParameter.ParameterIdentifierLen % 17,ptr->fillind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_FILLIND,DMHPAR_FILLIC);//FillIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->fillind.FillIndicatorCode,0x40,asn_buf); + } + + if (flag & BIT12_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RSEG); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->rsegLen % 4,ptr->rseg,0x40,asn_buf); + } + + if (flag & BIT13_TRUE) + { + if (ptr->retind.param_flag & 3) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RETIND);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,temp,0x60,asn_buf); + } + + if (ptr->retind.param_flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_RICODE);//ReturnIndicatorCode + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->retind.ReturnIndicatorCode,0x40,asn_buf); + } + if (ptr->retind.param_flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d.%d",tag1,DMHPAR_RETIND,DMHPAR_FPARM);//FaultyParameter + *buf_len = AddTLV(is41_sequenceTag(tag,4),ptr->retind.FaultyParameter.ParameterIdentifierLen % 17,ptr->retind.FaultyParameter.ParameterIdentifier,0x40,asn_buf); + } + } +} + +void encode_param_airssub(DMH_AirSegmentSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_ACHUSG,offset++); + encode_param_achusg(&ptr->achusg,asn_buf,buf_len,tag); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_SEGNUM,offset++); + *buf_len = AddTLV(tag,1,&ptr->segnum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_falsub(DMH_FeatureActivationLegSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DIALDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->dialdgtsLen & 31,ptr->dialdgts,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->lnum,0x40,asn_buf); + } + +//optional part will be encoded in the future + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FRIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->frind,0x40,asn_buf); + } + + if (flag & BIT15_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LLIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),0,&ptr->llind,0x40,asn_buf); + } +} + +void encode_param_olsub(DMH_OriginationLegSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_BILLIND,offset++); + *buf_len = AddTLV(tag,1,&ptr->billind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_DIALDGTS,offset++); + *buf_len = AddTLV(tag,ptr->dialdgtsLen & 31,ptr->dialdgts,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_LNUM,offset++); + *buf_len = AddTLV(tag,1,&ptr->lnum,0x40,asn_buf); + } + + if (flag & BIT8_TRUE) + {//Called Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CDLOC,offset++); + encode_param_CallLocation(&ptr->CalledLocation,asn_buf,buf_len,tag); + } + + if (flag & BIT11_TRUE) + {//Calling Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CGLOC,offset++); + encode_param_CallLocation(&ptr->CallingLocation,asn_buf,buf_len,tag); + } + + if (flag & BIT14_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CNVUSG,offset++); + encode_param_cnvusg(&ptr->cnvusg,asn_buf,buf_len,tag); + } + + if (flag & BIT16_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_FBUSG,offset++); + encode_param_fbusg(&ptr->fbusg,asn_buf,buf_len,tag); + } + + if (flag & BIT19_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_LLIND,offset++); + *buf_len = AddTLV(tag,0,&ptr->llind,0x40,asn_buf); + } + if (flag & BIT20_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_OGTUSG,offset++); + encode_param_ogtusg(&ptr->ogtusg,asn_buf,buf_len,tag); + } + +//optional part will be encoded in the future +} + +void encode_param_pacasub(DMH_PACASegmentSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CELLID); + *buf_len = AddTLV(is41_sequenceTag(tag,1),ptr->cellidLen % 3,ptr->cellid,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DUR); + *buf_len = AddTLV(is41_sequenceTag(tag,2),ptr->durLen % 5,ptr->dur,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_PACAIND); + *buf_len = AddTLV(is41_sequenceTag(tag,3),1,&ptr->pacaind,0x40,asn_buf); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SEGNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,4),1,&ptr->segnum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +void encode_param_rlsub(DMH_RedirectionLegSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_BILLIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->billind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CDDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->cddgtsLen % 10,ptr->cddgts,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_INCUSG,offset++); + encode_param_incusg(&ptr->incusg,asn_buf,buf_len,tag); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->lnum,0x40,asn_buf); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_REDIND); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),1,&ptr->redind,0x40,asn_buf); + } + +//optional part will be encoded in the future + if (flag & BIT6_TRUE) + {//Called Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CDLOC,offset++); + encode_param_CallLocation(&ptr->CalledLocation,asn_buf,buf_len,tag); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CGDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->cgdgtsLen % 10,ptr->cgdgts,0x40,asn_buf); + } + + if (flag & BIT9_TRUE) + {//Calling Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CGLOC,offset++); + encode_param_CallLocation(&ptr->CallingLocation,asn_buf,buf_len,tag); + } + + if (flag & BIT12_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CNVUSG,offset++); + encode_param_cnvusg(&ptr->cnvusg,asn_buf,buf_len,tag); + } + + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_DESTDGTS); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),ptr->destdgtsLen % 10,ptr->destdgts,0x40,asn_buf); + } + + if (flag & BIT18_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_LLIND,offset++); + *buf_len = AddTLV(tag,0,&ptr->llind,0x40,asn_buf); + } + + if (flag & BIT19_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_OGTUSG,offset++); + encode_param_ogtusg(&ptr->ogtusg,asn_buf,buf_len,tag); + } +} + +void encode_param_tssub(DMH_TandemSegmentSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_OGTUSG,offset++); + encode_param_ogtusg(&ptr->ogtusg,asn_buf,buf_len,tag); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_SEGNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,offset++),4,&ptr->segnum,0x40,asn_buf); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_TSWID,offset++); + encode_param_swid(&ptr->tswid,asn_buf,buf_len,tag); + } + +//optional part will be encoded in the future +} + +void encode_param_tlsub(DMH_TerminationLegSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + u8 offset=1; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_BILLIND,offset++); + *buf_len = AddTLV(tag,1,&ptr->billind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_LNUM,offset++); + *buf_len = AddTLV(tag,1,&ptr->lnum,0x40,asn_buf); + } + +//optional part will be encoded in the future + if (flag & BIT6_TRUE) + {//Called Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CDLOC,offset++); + encode_param_CallLocation(&ptr->CalledLocation,asn_buf,buf_len,tag); + } + + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CGDGTS,offset++); + *buf_len = AddTLV(tag,ptr->cgdgtsLen,ptr->cgdgts,0x40,asn_buf); + } + + if (flag & BIT10_TRUE) + {//Calling Location + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CGLOC,offset++); + encode_param_CallLocation(&ptr->CallingLocation,asn_buf,buf_len,tag); + } + + if (flag & BIT13_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_CNVUSG,offset++); + encode_param_cnvusg(&ptr->cnvusg,asn_buf,buf_len,tag); + } + if (flag & BIT16_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_FBUSG,offset++); + encode_param_fbusg(&ptr->fbusg,asn_buf,buf_len,tag); + } + if (flag & BIT17_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_INCUSG,offset++); + encode_param_incusg(&ptr->incusg,asn_buf,buf_len,tag); + } + if (flag & BIT19_TRUE) + { + sprintf(tag,"%s.%d-%d",tag1,DMHPAR_LLIND,offset++); + *buf_len = AddTLV(tag,0,&ptr->llind,0x40,asn_buf); + } + +} + +void encode_param_auxlsub(DMH_AuxiliaryLegSubrecord *ptr,ASN_BUF *asn_buf,int *buf_len,char tag1[64]) +{ + u32 flag; + char tag[64]; + + flag = ptr->param_flag; + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_BILLIND); + *buf_len = AddTLV(is41_sequenceTag(tag,1),1,&ptr->billind,0x40,asn_buf); + } + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_LNUM); + *buf_len = AddTLV(is41_sequenceTag(tag,2),1,&ptr->lnum,0x40,asn_buf); + } + +//optional part will be encoded in the future +} + +int assign_DMHEventJacket(DMH_EventJacket *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + char tag[64]; + char tag1[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + sprintf(tag,"%d",DMHPAR_EJCKT); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_EJCKT,DMHPAR_AUDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + encode_param_audsub(&ptr->audsub,&asn_buf,&buf_len,tag); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_EJCKT,DMHPAR_IDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_idsub(&ptr->idsub,&asn_buf,&buf_len,tag); + } + + sprintf(tag1,"%d.16-%d",DMHPAR_EJCKT,offset); + buf_len = AddTLV(tag1,0,temp,0x20,&asn_buf); + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_EVTSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_evtsub(&ptr->evtsub,&asn_buf,&buf_len,tag); + } + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_chrgsub(&ptr->chrgsub,&asn_buf,&buf_len,tag); + } + + return buf_len; +} + +int assign_DMH_ActivityJacket(DMH_ActivityJacket *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + char tag[64]; + char tag1[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + sprintf(tag,"%d",DMHPAR_AJCKT); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_AJCKT,DMHPAR_AUDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_audsub(&ptr->audsub,&asn_buf,&buf_len,tag); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_AJCKT,DMHPAR_IDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_idsub(&ptr->idsub,&asn_buf,&buf_len,tag); + } + + sprintf(tag1,"%d.16-%d",DMHPAR_AJCKT,offset); + buf_len = AddTLV(tag1,0,temp,0x20,&asn_buf); + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_ACTSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_actsub(&ptr->actsub,&asn_buf,&buf_len,tag); + } + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_chrgsub(&ptr->chrgsub,&asn_buf,&buf_len,tag); + } + + return buf_len; +} + +int assign_DMH_CallJacket(DMH_CallJacket *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + char tag[64]; + char tag1[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + sprintf(tag,"%d",DMHPAR_CJCKT); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_CJCKT,DMHPAR_AUDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_audsub(&ptr->audsub,&asn_buf,&buf_len,tag); + } + if (flag & BIT1_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_CJCKT,DMHPAR_IDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_idsub(&ptr->idsub,&asn_buf,&buf_len,tag); + } + + sprintf(tag1,"%d.16-%d",DMHPAR_CJCKT,offset); + buf_len = AddTLV(tag1,0,temp,0x20,&asn_buf); + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_ACTSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_actsub(&ptr->actsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AIRSSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_airssub(&ptr->airssub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_chrgsub(&ptr->chrgsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FALSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_falsub(&ptr->falsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_OLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_olsub(&ptr->olsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT7_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_PACASUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_pacasub(&ptr->pacasub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT8_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_rlsub(&ptr->rlsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT9_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TSSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_tssub(&ptr->tssub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT10_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_tlsub(&ptr->tlsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT11_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUXLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_auxlsub(&ptr->auxlsub,&asn_buf,&buf_len,tag); + } + + return buf_len; +} + +int assign_DMH_LegJacket(DMH_LegJacket *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + char tag[64]; + char tag1[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + sprintf(tag,"%d",DMHPAR_LJCKT); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_LJCKT,DMHPAR_IDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_idsub(&ptr->idsub,&asn_buf,&buf_len,tag); + } + + sprintf(tag1,"%d.16-%d",DMHPAR_LJCKT,offset); + buf_len = AddTLV(tag1,0,temp,0x20,&asn_buf); + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_chrgsub(&ptr->chrgsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_FALSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_falsub(&ptr->falsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_OLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_olsub(&ptr->olsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_RLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_rlsub(&ptr->rlsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_tlsub(&ptr->tlsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT6_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AUXLSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_auxlsub(&ptr->auxlsub,&asn_buf,&buf_len,tag); + } + + return buf_len; +} + +int assign_DMH_SegmentJacket(DMH_SegmentJacket *ptr,u8 *buf) +{ + ASN_BUF asn_buf; + int buf_len=0; + u32 flag; + char tag[64]; + char tag1[64]; + u8 temp[8]; + u8 offset=1; + + flag = ptr->param_flag; + AsnEncode(buf,256,&asn_buf); + + sprintf(tag,"%d",DMHPAR_SJCKT); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + + if (flag & BIT0_TRUE) + { + sprintf(tag,"%d.%d-%d",DMHPAR_SJCKT,DMHPAR_IDSUB,offset++); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_idsub(&ptr->idsub,&asn_buf,&buf_len,tag); + } + + sprintf(tag1,"%d.16-%d",DMHPAR_SJCKT,offset); + buf_len = AddTLV(tag1,0,temp,0x20,&asn_buf); + + if (flag & BIT1_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_ACTSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_actsub(&ptr->actsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT2_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_AIRSSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_airssub(&ptr->airssub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT3_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_CHRGSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_chrgsub(&ptr->chrgsub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT4_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_PACASUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_pacasub(&ptr->pacasub,&asn_buf,&buf_len,tag); + } + + if (flag & BIT5_TRUE) + { + sprintf(tag,"%s.%d",tag1,DMHPAR_TSSUB); + buf_len = AddTLV(tag,0,temp,0x60,&asn_buf); + encode_param_tssub(&ptr->tssub,&asn_buf,&buf_len,tag); + } + + return buf_len; +} + + +void encode_DMH_date(u8 *date) +{ + time_t tick; + struct tm *tm_ptr; + + time(&tick); + tm_ptr = gmtime(&tick); + date[0] = tm_ptr->tm_year-84; //+1900-1984 + date[1] = tm_ptr->tm_mon+1; + date[2] = tm_ptr->tm_mday; +} + +u8 encode_DMH_TimeDateOffset(u8 *TimeDateOffset) +{ + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv, &tz); + return encode_integer(TimeDateOffset,tz.tz_minuteswest); +} + +u8 encode_DMH_TimeOfDay(u8 *TimeOfDay) +{ + struct timeval tv; + struct timezone tz; + u32 time; + + gettimeofday(&tv, &tz); + + time = (tv.tv_sec%86400)*10+tv.tv_usec/100000; + + return encode_integer(TimeOfDay, time); +} diff --git a/omc/plat/xapp/src/xap_cdmacdr.h b/omc/plat/xapp/src/xap_cdmacdr.h new file mode 100644 index 0000000..caf9611 --- /dev/null +++ b/omc/plat/xapp/src/xap_cdmacdr.h @@ -0,0 +1,898 @@ +/* HLR CDMA cdr structure */ +/* Created by daniel:2005-06-21 */ +/* Modify by daniel:2005-06-21 */ +/* -------------------------------- */ + +#define DMHPAR_ASWID 0 +#define DMHPAR_AUDSN 1 +#define DMHPAR_AUDSUB 2 +#define DMHPAR_BIN 6 +#define DMHPAR_BILLIND 7 +#define DMHPAR_CDDGTS 8 +#define DMHPAR_CDLOC 9 +#define DMHPAR_CGDGTS 10 +#define DMHPAR_CGLOC 11 +#define DMHPAR_CHRGAMT 12 +#define DMHPAR_CNVDUR 13 +#define DMHPAR_CNVUSG 14 +#define DMHPAR_DATE 15 +#define DMHPAR_DIALDGTS 16 +#define DMHPAR_DUR 17 +#define DMHPAR_IDSUB 18 +#define DMHPAR_LNUM 19 +#define DMHPAR_MODIND 20 +#define DMHPAR_OSWID 21 +#define DMHPAR_RLEG 22 +#define DMHPAR_SEGNUM 23 +#define DMHPAR_SSWID 24 +#define DMHPAR_SWNO 25 +#define DMHPAR_SID 26 +#define DMHPAR_TOD 27 +#define DMHPAR_TKNUM 29 +#define DMHPAR_ACTIND 32 +#define DMHPAR_AJCKT 33 +#define DMHPAR_ACTSUB 34 +#define DMHPAR_ACHDUR 37 +#define DMHPAR_ACHUSG 38 +#define DMHPAR_AIRSSUB 39 +#define DMHPAR_AUTHCNT 42 +#define DMHPAR_AUTHDEN 43 +#define DMHPAR_AUTHTYP 44 +#define DMHPAR_CJCKT 47 +#define DMHPAR_CELLID 49 +#define DMHPAR_CHRGIND 50 +#define DMHPAR_CHRGSUB 51 +#define DMHPAR_CHRGTAX 52 +#define DMHPAR_CHRGTIND 53 +#define DMHPAR_CHRGUNIT 54 +#define DMHPAR_DENACC 56 +#define DMHPAR_DESTDGTS 57 +#define DMHPAR_ESN 58 +#define DMHPAR_EVTIND 60 +#define DMHPAR_FPARM 61 +#define DMHPAR_FBDUR 62 +#define DMHPAR_FBIND 64 +#define DMHPAR_FBUSG 65 +#define DMHPAR_FEATIND 66 +#define DMHPAR_FEATOPN 67 +#define DMHPAR_FRIND 68 +#define DMHPAR_HCOORD 69 +#define DMHPAR_HSWID 70 +#define DMHPAR_IECCDUR 71 +#define DMHPAR_INCDUR 73 +#define DMHPAR_INCUSG 74 +#define DMHPAR_LLIND 78 +#define DMHPAR_LJCKT 81 +#define DMHPAR_MIN 84 +#define DMHPAR_MRPI 85 +#define DMHPAR_NPANXX 86 +#define DMHPAR_NUMACT 87 +#define DMHPAR_NUMCHRG 89 +#define DMHPAR_NUMEVT 90 +#define DMHPAR_NUMLEG 91 +#define DMHPAR_NUMSEG 93 +#define DMHPAR_OLSUB 94 +#define DMHPAR_OGTDUR 95 +#define DMHPAR_OGTUSG 96 +#define DMHPAR_PLNAM 97 +#define DMHPAR_RCHNUM 99 +#define DMHPAR_RPI 100 +#define DMHPAR_REDIND 101 +#define DMHPAR_RLSUB 102 +#define DMHPAR_RBIN 103 +#define DMHPAR_RELIND 104 +#define DMHPAR_RIN 106 +#define DMHPAR_SRT 109 +#define DMHPAR_SJCKT 110 +#define DMHPAR_SPNAM 112 +#define DMHPAR_TSSUB 113 +#define DMHPAR_TSWID 114 +#define DMHPAR_TLSUB 115 +#define DMHPAR_TDO 116 +#define DMHPAR_TTIND 117 +#define DMHPAR_VCOORD 118 +#define DMHPAR_BINR 128 +#define DMHPAR_BRI 129 +#define DMHPAR_EJCKT 142 +#define DMHPAR_EVTSUB 143 +#define DMHPAR_FALSUB 146 +#define DMHPAR_PACAIND 150 +#define DMHPAR_PACASUB 151 +#define DMHPAR_AUXLSUB 161 +#define DMHPAR_IMEI 165 +#define DMHPAR_IMSI 166 +#define DMHPAR_LATA 167 +#define DMHPAR_NUMOCT 168 +#define DMHPAR_NUMPKT 169 +#define DMHPAR_TEXIND 170 +#define DMHPAR_CHRGTCOD 171 +#define DMHPAR_CHRGTTBL 172 +#define DMHPAR_FILLIND 178 +#define DMHPAR_FILLIC 179 +#define DMHPAR_MDN 184 +#define DMHPAR_NEICLNP 186 +#define DMHPAR_NUMFAL 188 +#define DMHPAR_NUMRED 189 +#define DMHPAR_NUMORG 190 +#define DMHPAR_NUMTRM 191 +#define DMHPAR_SELUSE 193 +#define DMHPAR_SUCOD 194 +#define DMHPAR_MYTYP 196 +#define DMHPAR_NUMAUX 199 +#define DMHPAR_NEIIP 200 +#define DMHPAR_IWFDUR 202 +#define DMHPAR_RETIND 207 +#define DMHPAR_RICODE 208 +#define DMHPAR_RSEG 209 +#define DMHPAR_WCNTRY 214 + +#define EVTIND_authorizationGranted 1 +#define EVTIND_authorizationExpired 2 +#define EVTIND_authorizationDenied 3 +#define EVTIND_securityViolationReport 4 +#define EVTIND_inactive 5 +#define EVTIND_deregistration 6 +#define EVTIND_registrationCanceled 7 +#define EVTIND_profileUpdated 8 +#define EVTIND_qualificationUpdated 9 +#define EVTIND_terminationDeniedInvalid 10 +#define EVTIND_terminationDeniedUnassigned 11 +#define EVTIND_terminationDeniedInactive 12 +#define EVTIND_terminationDeniedUnregistered 13 +#define EVTIND_terminationDeniedNoPageResponse 14 +#define EVTIND_terminationDeniedBusy 15 +#define EVTIND_terminationDeniedSCA 16 +#define EVTIND_terminationDeniedDND 17 +#define EVTIND_terminationDeniedCD 18 +#define EVTIND_terminationDeniedCS 19 +#define EVTIND_terminationDeniedOther 20 +#define EVTIND_callDelivered 21 +#define EVTIND_callForwarded 22 +#define EVTIND_callForwardingNotification 23 +#define EVTIND_messageWaitingNotification 24 +#define EVTIND_originationDeniedNoTrunk 25 +#define EVTIND_originationDeniedUnrecognized 26 +#define EVTIND_originationDeniedCB 27 +#define EVTIND_originationDeniedOther 28 +#define EVTIND_unspecifiedHourlyEvent 29 +#define EVTIND_unspecifiedDailyEvent 30 +#define EVTIND_unspecifiedWeeklyEvent 31 +#define EVTIND_unspecifiedMonthlyEvent 32 +#define EVTIND_unspecifiedQuarterlyEvent 33 +#define EVTIND_unspecifiedSemi_annualEvent 34 +#define EVTIND_unspecifiedAnnualEvent 35 +#define EVTIND_featureAccessAttempted 36 +#define EVTIND_SMSMO 37 +#define EVTIND_SMSMT 38 +#define EVTIND_SMSNOT 39 + +#define ACTIND_unspecified 0 +#define ACTIND_locallyDeniedRegistration 1 +#define ACTIND_homeDeniedRegistration 2 +#define ACTIND_powerOnRegistration 3 +#define ACTIND_autonomousRegistration 4 +#define ACTIND_missedAutonomousRegistration 5 +#define ACTIND_movementRegistration 6 +#define ACTIND_movementDetected 7 +#define ACTIND_powerDownDeregistration 8 +#define ACTIND_pageResponse 0 +#define ACTIND_noPageResponse 10 +#define ACTIND_messageWaiting 11 +#define ACTIND_abbreviatedAlert 12 +#define ACTIND_alert 13 +#define ACTIND_alertWithInformation 14 +#define ACTIND_alertingAnswered 15 +#define ACTIND_pACARequest 16 +#define ACTIND_originationRequest 17 +#define ACTIND_flashRequestWithoutInformation 18 +#define ACTIND_flashRequestWithInformation 19 +#define ACTIND_callModeChanged 20 +#define ACTIND_lostRadioContact 21 +#define ACTIND_measurementRequest 22 +#define ACTIND_mAHORequest 23 +#define ACTIND_intraSystemHandoff 24 +#define ACTIND_interSystemHandoff 25 +#define ACTIND_powerControlProblem 26 +#define ACTIND_protocolError 27 +#define ACTIND_spuriousEmissions 28 +#define ACTIND_orderedRegistration 29 +#define ACTIND_trafficChannelRegistration 30 +#define ACTIND_dataBurst_ShortMessage 31 +#define ACTIND_featureNotification 32 +#define ACTIND_lock 33 +#define ACTIND_unlock 34 +#define ACTIND_maintenanceRequired 35 +#define ACTIND_intrasystemSoftHandoffBegin 36 +#define ACTIND_intersystemSoftHandoffBegin 37 +#define ACTIND_packetDataRegistrationOnly 38 + +#define FEATIND_callForwarding_Unconditional 1 +#define FEATIND_callForwarding_Busy 2 +#define FEATIND_callForwarding_NoAnswer 3 +#define FEATIND_callForwarding_Other 4 +#define FEATIND_callWaiting 5 +#define FEATIND_threeWayCalling 6 +#define FEATIND_callDelivery 7 +#define FEATIND_doNotDisturb 8 +#define FEATIND_conferenceCalling 9 +#define FEATIND_callTransfer 10 +#define FEATIND_callingNumberIdentificationRestriction 11 +#define FEATIND_selectiveCallAcceptance 12 +#define FEATIND_authorizationCode 13 +#define FEATIND_speedDialing 14 +#define FEATIND_adviceOfCharging 15 +#define FEATIND_voiceMail 16 +#define FEATIND_callForwardDefault 17 +#define FEATIND_callingNumberIdentificationPresentation 18 +#define FEATIND_flexibleAlerting 19 +#define FEATIND_messageWaitingNotification 20 +#define FEATIND_mobileAccessHunting 21 +#define FEATIND_passwordCallAcceptance 22 +#define FEATIND_preferredLanguageService 23 +#define FEATIND_priorityAccessAndChannelAssignment 24 +#define FEATIND_remoteFeatureControl 25 +#define FEATIND_subscriberPINAccess 26 +#define FEATIND_subscriberPINIntercept 27 +#define FEATIND_voicePrivacy 28 +#define FEATIND_shortMessageDeliveryPoint_ToPointBearer 29 +#define FEATIND_shortMessageDeliveryBroadcast 30 +#define FEATIND_cellularPagingTeleservice 31 +#define FEATIND_cellularMessagingTeleservice 32 +#define FEATIND_intersystemCall 33 +#define FEATIND_voiceMailDelete 34 +#define FEATIND_voiceMailSend 35 +#define FEATIND_voiceMailDeposit 36 +#define FEATIND_answerHold 37 +#define FEATIND_userSelectiveCallForwarding 38 + +#define FEATOPN_featureRegistration 1 +#define FEATOPN_featureDeregistration 2 +#define FEATOPN_featureActivation 3 +#define FEATOPN_featureDeactivation 4 +#define FEATOPN_featureInvocation 5 +#define FEATOPN_featurePerCallActivation 6 +#define FEATOPN_featurePerCallDeactivation 7 +#define FEATOPN_featureRegistrationAndActivation 8 +#define FEATOPN_featureInterrogation 9 +#define FEATOPN_featureTesting 10 +#define FEATOPN_screenListEditing 11 + +#define FRIND_timerExpiry 1 +#define FRIND_networkFailure 2 +#define FRIND_operationError 3 +#define FRIND_operationReject 4 +#define FRIND_unspecified 5 +#define FRIND_unsuccessful 6 +#define FRIND_successful 7 + +typedef struct DMH_CallLocation +{ + u32 param_flag; + + u8 HcoordinateLen; + u8 Hcoordinate[3]; + + u8 NPANXX[3]; + + u8 PlaceNameLen; + u8 PlaceName[20]; + + u8 StateProvinceName[2]; + + u8 VcoordinateLen; + u8 Vcoordinate[3]; + + u8 LocalAccessTransportAreaLen; + u8 LocalAccessTransportArea[4]; + + u8 WorldCountry[3]; +}DMH_CallLocation; + +typedef struct DMH_ReturnIndicator +{ + u32 param_flag; + + u8 ReturnIndicatorCode; + +//optional part + struct + { + u8 ParameterIdentifierLen; + u8 ParameterIdentifier[16]; + } FaultyParameter; + +}DMH_ReturnIndicator; + +typedef struct DMH_FillIndicator +{ + struct + { + u8 ParameterIdentifierLen; + u8 ParameterIdentifier[16]; + } FaultyParameter; + + u8 FillIndicatorCode; +}DMH_FillIndicator; + +typedef struct DMH_AuditSubrecord +{ + u32 param_flag; + + u8 audsnLen; + u8 audsn[4];//AuditSequenceNumber + +//optional part + u8 achdurLen; + u8 achdur[4];//AirChannelDuration + u8 cnvdurLen; + u8 cnvdur[4];//ConversationDuration + u8 fbdurLen; + u8 fbdur[4];//FeatureBridgeDuration + u8 ieccdurLen; + u8 ieccdur[4];//IECConnectDuration + u8 incdurLen; + u8 incdur[4];//IncomingTrunkDuration + u8 numactLen; + u8 numact[4];//NumberOfActivities + u8 numchrgLen; + u8 numchrg[4];//NumberOfCharges + u8 numevtLen; + u8 numevt[4];//NumberOfEvents + u8 numlegLen; + u8 numleg[4];//NumberOfLegs + u8 numsegLen; + u8 numseg[4];//NumberOfSegments + u8 ogtdurLen; + u8 ogtdur[4];//OutgoingTrunkDuration + u8 numfalLen; + u8 numfal[4];//NumberOfFeatureActivationLegs + u8 numorgLen; + u8 numorg[8];//NumberOfOriginationLegs + u8 numredLen; + u8 numred[4];//NumberOfRedirectionLegs + u8 numtrmLen; + u8 numtrm[4];//NumberOfTerminationLegs + u8 numauxLen; + u8 numaux[4];//NumberOfAuxiliaryLegs + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets + u8 iwfdurLen; + u8 iwfdur[4];//IWFDuration + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_AuditSubrecord; + +typedef struct DMH_SwitchID +{ + u32 param_flag; + + u8 swno;//SwitchNumber + u8 sid[2];//SystemIdentifier + u8 bri[2];//BusinessRelationIdentifier + u8 mytyp;//SystemMyTypeCode +}DMH_SwitchID; + +typedef struct DMH_IdentitySubrecord +{ + u32 param_flag; + + u8 Date[3]; + struct + { + u8 ChoiceFlag; + + u8 esn[4]; + u8 imei[5]; + } Choice1; + + struct + { + u8 ChoiceFlag; + + u8 min[5]; + u8 imsi[8]; + u8 neiclnp[19]; + u8 neiip[4]; + } Choice2; + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + + struct + { + u8 ChoiceFlag; + + DMH_SwitchID aswid;//AnchorSWID + DMH_SwitchID oswid;//OriginatingSWID + DMH_SwitchID sswid;//ServingSWID + } Choice3; + + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + + DMH_SwitchID hswid;//HomeSWID + + u8 mdnLen; + u8 mdn[8]; + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; + +}DMH_IdentitySubrecord; + +typedef struct DMH_EventSubrecord +{ + u32 param_flag; + + u8 evtind;//EventIndicator + u8 rinLen; + u8 rin[4];//ReportIdentificationNumber + +//optional part + DMH_SwitchID aswid;//AnchorSWID + + u8 authcnt;//AuthorizationCount + u8 authden;//AuthorizationDenied + u8 authtyp;//AuthorizationType + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + u8 Date[3]; + u8 denacc;//DenyAccess + u8 featind;//FeatureIndicator + u8 featopn;//FeatureOperation + u8 frind;//FeatureResultIndicator + + DMH_SwitchID oswid;//OriginatingSWID + + u8 rbinLen; + u8 rbin[4];//RelatedBillingIdentificationNumber + u8 srt;//SecurityReportType + + DMH_SwitchID sswid;//ServingSWID + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_EventSubrecord; + +typedef struct DMH_ChargeSubrecord +{ + u32 param_flag; + + u8 chrgamtLen; + u8 chrgamt[4];//ChargeAmount + u8 chrgind;//ChargeIndicator + +//optional part + u8 chrgtaxLen; + u8 chrgtax[4];//ChargeTax + u8 chrgtind;//ChargeTaxIndicator + u8 chrgunit;//ChargeUnits + u8 durLen; + u8 dur[4];//Duration + u8 mrpi;//MultipleRatePeriodIndicator,len=0 + u8 plnamLen; + u8 plnam[20];//PlaceName + u8 rpi;//RatePeriodIndicator + u8 spnam[2];//StateProvinceName + u8 ttind;//TollTariffIndicator + u8 wcntry[3];//WorldCountry + + struct + { + u8 ChoiceFlag; + + u8 lnum;//LegNumber + u8 segnum;//SegmentNumber + } Choice; + + u8 chrgtcodLen; + u8 chrgtcod[2];//ChargeTaxCode + u8 chrgttbl;//ChargeTaxTable + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets + u8 seluseLen; + u8 seluse[100];//SelectiveUse + u8 sucod;//SelectiveUseCode + u8 texind;//TaxExemptIndicator + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; +}DMH_ChargeSubrecord; + +typedef struct DMH_BeginForwardPath +{ + u32 param_flag; + + u8 cellidLen; + u8 cellid[2];//CellIdentifier + u8 modind;//ModulationIndicator + u8 rchnumLen; + u8 rchnum[2];//RadioChannelNumber + u8 tknumLen; + u8 tknum[2];//TrunkNumber + +//optional part + u8 bearind;//BearerIndicator + u8 locidLen; + u8 locid[2];//LocationAreaIdentifier + u8 radattr[2];//RadioAttributes + u8 trnsnumLen; + u8 trnsnum[2];//TransceiverNumber + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + + struct + { + u8 ChoiceFlag; + //will add encode in the future + + } Choice; + + u8 cellnamLen; + u8 cellnam[8];//CellName + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName + u8 uzLen; + u8 uz[3];//UserZoneNumber + u8 bndclsLen; + u8 bndcls[63];//BandClass + u8 freqind;//FrequencyIndicator +}DMH_BeginForwardPath;//BeginForwardPath + +typedef struct DMH_EndForwardPath +{ + u32 param_flag; +}DMH_EndForwardPath;//BeginForwardPath + +typedef struct DMH_ActivitySubrecord +{ + u32 param_flag; + + u8 actind;//ActivityIndicator + u8 rinLen; + u8 rin[4];//ReportIdentificationNumber + +//optional part + u8 authden;//AuthorizationDenied + + DMH_BeginForwardPath bfpath; + u8 binLen; + u8 bin[4];//BillingIdentificationNumber + u8 Date[3]; + u8 denacc;//DenyAccess + u8 srt;//SecurityReportType + + DMH_SwitchID sswid;//ServingSWID + + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 todLen; + u8 tod[3];//TimeOfDay + DMH_FillIndicator fillind; + u8 rsegLen; + u8 rseg[3];//RelatedSegmentNumber + DMH_ReturnIndicator retind; +}DMH_ActivitySubrecord; + +typedef struct DMH_FeatureBridgeUsage +{ + u32 param_flag; + + u8 fbind; //FeatureBridgeIndicator + u8 durLen; + u8 dur[4];//Duration + u8 rlegLen; + u8 rleg[3];//RelatedLegNumber + u8 todLen; + u8 tod[3];//TimeOfDay + +}DMH_FeatureBridgeUsage; + +typedef struct DMH_IncomingTrunkUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 tknumLen; + u8 tknum[2];//TrunkNumber + + u8 cardgts[2];//CarrierDigits + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName +}DMH_IncomingTrunkUsage; + +typedef struct DMH_OutgoingTrunkUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 tknumLen; + u8 tknum[2];//TrunkNumber + + u8 cardgts[2];//CarrierDigits + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 tkgrpLen; + u8 tkgrp[2];//TrunkGroup + u8 tgpnamLen; + u8 tgpnam[12];//TrunkGroupName +}DMH_OutgoingTrunkUsage; + +typedef struct DMH_AirChannelUsage +{ + u32 param_flag; + + DMH_BeginForwardPath bfpath; + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + u8 Date[3]; + +//optional part + DMH_EndForwardPath efpath; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset +}DMH_AirChannelUsage; + +typedef struct DMH_AirSegmentSubrecord +{ + u32 param_flag; + + DMH_AirChannelUsage achusg;//AirChannelUsage + u8 segnum;//SegmentNumber + +//optional part + struct + { + u32 param_flag; + + u8 latLen; + u8 lat[3];//Latitude + u8 LONGLen; + u8 LONG[3];//Longitude + u8 resolLen; + u8 resol[3];//Resolution + }begloc;//BeginLocation + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage + u8 lsind;//LastSegmentIndicator,len=0 + DMH_SwitchID sswid;//ServingSWID + u8 cgblind;//ChargeableIndicator + DMH_FillIndicator fillind; + DMH_ReturnIndicator retind; + +}DMH_AirSegmentSubrecord; + +typedef struct DMH_FeatureActivationLegSubrecord +{ + u32 param_flag; + + u8 dialdgtsLen; + u8 dialdgts[32];//DialedDigits + u8 lnum;//LegNumber + +//optional part will be encoded in the future + u8 frind;//FeatureResultIndicator, BIT13 + u8 llind;//LastLegIndicator, BIT15 +}DMH_FeatureActivationLegSubrecord; + +typedef struct DMH_ConversationUsage +{ + u32 param_flag; + + u8 durLen; + u8 dur[4];//Duration + u8 todLen; + u8 tod[3];//TimeOfDay + +//optional part + u8 Date[3]; + u8 relind;//ReleaseIndicator + u8 tdoLen; + u8 tdo[2];//TimeDateOffset + u8 numoctLen; + u8 numoct[4];//NumberOfOctets + u8 numpktLen; + u8 numpkt[4];//NumberOfPackets +}DMH_ConversationUsage; + +typedef struct DMH_OriginationLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 dialdgtsLen; + u8 dialdgts[32];//DialedDigits + u8 lnum;//LegNumber + + DMH_CallLocation CalledLocation;//BIT8 + + DMH_CallLocation CallingLocation;//BIT11 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT14 + DMH_FeatureBridgeUsage fbusg;//FeatureBridgeUsage,BIT16 + u8 llind;//LastLegIndicator,len=0,BIT19 + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage.BIT20 + +}DMH_OriginationLegSubrecord; + +typedef struct DMH_PACASegmentSubrecord +{ + u32 param_flag; + + u8 cellidLen; + u8 cellid[2];//CellIdentifier + u8 durLen; + u8 dur[4];//Duration + u8 pacaind;//PACAIndicator + u8 segnum;//SegmentNumber +}DMH_PACASegmentSubrecord; + +typedef struct DMH_RedirectionLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 cddgtsLen; + u8 cddgts[9];//CalledDigits + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage + u8 lnum;//LegNumber + u8 redind;//RedirectionIndicator + +//optional part + DMH_CallLocation CalledLocation;//BIT6 + + u8 cgdgtsLen; + u8 cgdgts[9];//CallingDigits, BIT8 + + DMH_CallLocation CallingLocation;//BIT9 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT12 + u8 destdgtsLen; + u8 destdgts[32];//DestinationDigits,BIT13 + u8 llind;//LastLegIndicator,len=0,BIT18 + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage.BIT19 + +}DMH_RedirectionLegSubrecord; + +typedef struct DMH_TandemSegmentSubrecord +{ + u32 param_flag; + + DMH_OutgoingTrunkUsage ogtusg;//OutgoingTrunkUsage + u8 segnum;//SegmentNumber + DMH_SwitchID tswid;//ServingSWID + +//optional part will be added in the future +}DMH_TandemSegmentSubrecord; + +typedef struct DMH_TerminationLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 lnum;//LegNumber + +//optional part + DMH_CallLocation CalledLocation;//BIT6 + + u8 cgdgtsLen; + u8 cgdgts[9];//CallingDigits,BIT9 + + DMH_CallLocation CallingLocation;//BIT10 + + DMH_ConversationUsage cnvusg;//ConversationUsage,BIT13 + DMH_FeatureBridgeUsage fbusg;//FeatureBridgeUsage,BIT16 + DMH_IncomingTrunkUsage incusg;//IncomingTrunkUsage,BIT17 + u8 llind;//LastLegIndicator,len=0,BIT19 + +}DMH_TerminationLegSubrecord; + +typedef struct DMH_AuxiliaryLegSubrecord +{ + u32 param_flag; + + u8 billind;//BillingIndicator + u8 lnum;//LegNumber +}DMH_AuxiliaryLegSubrecord; + +typedef struct DMH_EventJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + DMH_EventSubrecord evtsub; + DMH_ChargeSubrecord chrgsub; +}DMH_EventJacket; + +typedef struct DMH_ActivityJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + DMH_ActivitySubrecord actsub; + DMH_ChargeSubrecord chrgsub; +}DMH_ActivityJacket; + +typedef struct DMH_CallJacket +{ + u32 param_flag; + + DMH_AuditSubrecord audsub; + DMH_IdentitySubrecord idsub; + + DMH_ActivitySubrecord actsub; + DMH_AirSegmentSubrecord airssub; + DMH_ChargeSubrecord chrgsub; + DMH_FeatureActivationLegSubrecord falsub; + DMH_OriginationLegSubrecord olsub; + DMH_PACASegmentSubrecord pacasub; + DMH_RedirectionLegSubrecord rlsub; + DMH_TandemSegmentSubrecord tssub; + DMH_TerminationLegSubrecord tlsub; + DMH_AuxiliaryLegSubrecord auxlsub; +}DMH_CallJacket; + +typedef struct DMH_LegJacket +{ + u32 param_flag; + + DMH_IdentitySubrecord idsub; + + DMH_ChargeSubrecord chrgsub; + DMH_FeatureActivationLegSubrecord falsub; + DMH_OriginationLegSubrecord olsub; + DMH_RedirectionLegSubrecord rlsub; + DMH_TerminationLegSubrecord tlsub; + DMH_AuxiliaryLegSubrecord auxlsub; +}DMH_LegJacket; + +typedef struct DMH_SegmentJacket +{ + u32 param_flag; + + DMH_IdentitySubrecord idsub; + + DMH_ActivitySubrecord actsub; + DMH_AirSegmentSubrecord airssub; + DMH_ChargeSubrecord chrgsub; + DMH_PACASegmentSubrecord pacasub; + DMH_TandemSegmentSubrecord tssub; +}DMH_SegmentJacket; + + + +int assign_DMHEventJacket(DMH_EventJacket *ptr,u8 *buf); +int assign_DMH_ActivityJacket(DMH_ActivityJacket *ptr,u8 *buf); +int assign_DMH_CallJacket(DMH_CallJacket *ptr,u8 *buf); +int assign_DMH_LegJacket(DMH_LegJacket *ptr,u8 *buf); +int assign_DMH_SegmentJacket(DMH_SegmentJacket *ptr,u8 *buf); +void encode_DMH_date(u8 *date); +u8 encode_DMH_TimeDateOffset(u8 *TimeDateOffset); +u8 encode_DMH_TimeOfDay(u8 *TimeOfDay); + diff --git a/omc/plat/xapp/src/xap_interface.c b/omc/plat/xapp/src/xap_interface.c new file mode 100644 index 0000000..75611ec --- /dev/null +++ b/omc/plat/xapp/src/xap_interface.c @@ -0,0 +1,930 @@ +/* XAP provider interface c file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "../../public/src/include/public.h" +#include "../../public/src/include/license_id.h" +#include "../../tcap/src/include/itcap.h" +#include "../../tcap/src/include/idmanage.h" +#include "xap_provider.h" +#include "xap_monitor.h" +#include "mapp/map_public.h" +#include "capp/cap_public.h" + +int xap_mscid_to_num ( u8 * mscid, u8 ssn, u8 * num ) +{ + int i; + + for ( i = 0; i < 256; i++ ) + { + if( ( memcmp ( mscid, xap_inter_ptr->mscidToNum[i], 3 ) == 0 ) && ( xap_inter_ptr->mscidToNum[i][3] == ssn ) ) + { + memcpy ( num, xap_inter_ptr->mscidToNum[4], 10 ); + return 1; + } + } + return 0; +} + +void xap_get_mcc ( u8 * mcc ) +{ + memcpy ( mcc, xap_inter_ptr->mcc, 2 ); +} + +void xap_get_mnc ( u8 * mnc ) +{ + memcpy ( mnc, &xap_inter_ptr->mnc, 2 ); +} + +void xap_get_cc ( u8 * cc ) +{ + memcpy ( cc, xap_inter_ptr->cc, 2 ); +} + +void xap_get_ndc ( u8 * ndc ) +{ + memcpy ( ndc, xap_inter_ptr->ndc, 3 ); +} + +void xap_get_interprefix ( u8 * inter_prefix ) +{ + memcpy ( inter_prefix, xap_inter_ptr->inter_prefix, 2 ); +} + +void xap_get_nationalprefix ( u8 * national_prefix ) +{ + memcpy ( national_prefix, xap_inter_ptr->national_prefix, 2 ); +} + +void xap_get_localprefix ( u8 * local_prefix ) +{ + memcpy ( local_prefix, xap_inter_ptr->local_prefix, 2 ); +} + +int imap_reg_ssn ( u8 ssn ) +{ + u8 ii, jj; + + ii = xap_inter_ptr->regssn_len; + if( ii >= MAX_XAP_SSN ) + { + xap_send_error ( "Can not register ssn in map provider" ); + return -1; + } + for ( jj = 0; jj < ii; jj++ ) + { + if( xap_inter_ptr->reg_ssn[jj] == ssn ) + { + xap_send_error ( "ssn has registered in map provider" ); + return -1; + } + } + xap_inter_ptr->reg_ssn[ii] = ssn; + xap_inter_ptr->regssn_flag[ii] = XAP_MAP_SSN; + xap_inter_ptr->regssn_len++; + return itcap_reg_ssn ( ssn ); +} + +u8 map_check_sendcom ( u32 did ) +{ + struct xapp_vm_data *vm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->recvcom_flag == 0 ) + return 1; + return 0; +} + +u8 map_send_comdata_struct ( MapComSrv_struct * map_com ) // send map common service data +{ + u32 temp_did; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + if( xap_vm_ptr->debug_data.send_control ) + { + u8 data_flow[512]; + + map_com_stof ( map_com, data_flow, 1 ); + xap_send_error ( "[%d]Sending Com:%d in Structure", map_com->dialogue_id, map_com->message_type ); + xap_msg_display ( data_flow ); + } + + temp_did = map_com->dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + { + xap_send_error ( "[%d]Com:%d sending did error", temp_did, map_com->message_type ); + return 0; + } + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + if( ( vm_ptr->recvcom_flag == 1 ) && ( map_com->message_type != MAP_U_ABORT ) ) /* daniel change on 2005-4-29 */ + { + xap_send_error ( "[%d]Com:%d sending without permit", temp_did, map_com->message_type ); + return 0; + } + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + // if (result == 2 || map_com->message_type == MAP_DELIMITER) + psm_ptr->delimiter_flag = 1; + if( map_com->message_type != MAP_DELIMITER ) + { + memcpy ( &vm_ptr->recvcom_data, map_com, sizeof ( MapComSrv_struct ) ); + psm_ptr->msg_type = map_com->message_type; + psm_ptr->msg_flag = map_com->message_flag; + vm_ptr->recvcom_flag = 1; + xap_watch_dog(27); + } + xap_watch_dog(25); + return 1; +} + +u8 map_send_comdata ( u8 * data_flow ) // send map common service data +{ + u8 result; + u32 temp_did; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapComSrv_struct map_com; + + xap_msg_display ( data_flow ); + if( ( result = map_com_ftos ( &map_com, data_flow ) ) == 0 ) + { + xap_send_error ( "[%d]Com:%d sending translate error", map_com.dialogue_id, map_com.message_type ); + return 0; + } + temp_did = map_com.dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + { + xap_send_error ( "[%d]Com:%d sending did error", temp_did, map_com.message_type ); + return 0; + } + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + if( ( vm_ptr->recvcom_flag == 1 ) && ( map_com.message_type != MAP_U_ABORT ) ) /* daniel change on 2005-4-29 */ + { + xap_send_error ( "[%d]Com:%d sending without permit", temp_did, map_com.message_type ); + return 0; + } + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + if( result == 2 || map_com.message_type == MAP_DELIMITER ) + { + if (result == 2) + xap_watch_dog(64); + else + xap_watch_dog(65); + psm_ptr->delimiter_flag = 1; + } + if( map_com.message_type != MAP_DELIMITER ) + { + memcpy ( &vm_ptr->recvcom_data, &map_com, sizeof ( MapComSrv_struct ) ); + psm_ptr->msg_type = map_com.message_type; + psm_ptr->msg_flag = map_com.message_flag; + vm_ptr->recvcom_flag = 1; + xap_watch_dog(28); + } + xap_watch_dog(25); + return 1; +} + +u8 map_check_sendopr ( u32 did ) +{ + struct xapp_vm_data *vm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->recvopr_flag == 1 ) + return 0; + return 1; +} + +u8 map_send_oprdata ( u8 * data_flow ) // send map operation service data +{ + u8 result; + u32 temp_did; + struct xapp_vm_data *vm_ptr; + struct MapOprData_struct map_opr; + + //xap_msg_display ( data_flow ); + if( ( result = map_opr_ftos ( &map_opr, data_flow ) ) == 0 ) + { + xap_send_error ( "[%d]Opr:%d sending translate error", map_opr.dialogue_id, map_opr.message_type ); + return 0; + } + temp_did = map_opr.dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + { + xap_send_error ( "[%d]Opr:%d sending did error", temp_did, map_opr.message_type ); + return 0; + } + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + if( vm_ptr->recvopr_flag == 1 ) + { + xap_send_error ( "[%d]Opr:%d sending without permit", temp_did, map_opr.message_type ); + return 0; + } + xap_msg_display ( data_flow ); + memcpy ( &vm_ptr->recvopr_data, &map_opr, sizeof ( MapOprData_struct ) ); + if( result == 2 ) + { + vm_ptr->psm_data.delimiter_flag = 1; + xap_watch_dog(68); + } + vm_ptr->recvopr_flag = 1; + xap_watch_dog(45); + xap_watch_dog(47); + if(map_opr.message_type == SndRoutInfo) + { + if(map_opr.message_flag == 1) + { + xap_watch_dog(16); + } + else + { + xap_watch_dog(17); + } + } + else if(map_opr.message_type == ProvRoamNum) + { + if(map_opr.message_flag == 1) + { + xap_watch_dog(20); + } + else + { + xap_watch_dog(21); + } + } + return 1; +} + +u8 map_send_oprdata_struct ( MapOprData_struct * map_opr ) // send map operation service data +{ + u32 temp_did; + struct xapp_vm_data *vm_ptr; + + // struct MapOprData_struct map_opr; + + temp_did = map_opr->dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + { + xap_send_error ( "[%d]Opr:%d sending did error", temp_did, map_opr->message_type ); + return 0; + } + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + + if( xap_vm_ptr->debug_data.send_control ) + { + u8 data_flow[512]; + + map_opr_stof ( map_opr, data_flow, 1 ); + xap_send_error ( "[%d]Sending Opr:%d in Structure ", map_opr->dialogue_id, map_opr->message_type ); + xap_msg_display ( data_flow ); + } + if( vm_ptr->recvopr_flag == 1 ) + { + xap_send_error ( "[%d]Opr:%d sending without permit", temp_did, map_opr->message_type ); + return 0; + } + memcpy ( &vm_ptr->recvopr_data, map_opr, sizeof ( MapOprData_struct ) ); + // if (result == 2) + vm_ptr->psm_data.delimiter_flag = 1; + vm_ptr->recvopr_flag = 1; + xap_watch_dog(45); + xap_watch_dog(48); + if(map_opr->message_type == SndRoutInfo) + { + if(map_opr->message_flag == 1) + { + xap_watch_dog(16); + } + else + { + xap_watch_dog(17); + } + } + else if(map_opr->message_type == ProvRoamNum) + { + if(map_opr->message_flag == 1) + { + xap_watch_dog(20); + } + else + { + xap_watch_dog(21); + } + } + return 1; +} + +u8 map_get_comdata ( u8 * data_flow, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendcom_flag == 0 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + map_com_stof ( &vm_ptr->sendcom_data, data_flow, 0 ); + vm_ptr->sendcom_flag = 0; + xap_watch_dog(6); + xap_watch_dog(7); + xap_msg_display ( data_flow ); + return 1; +} + +u8 map_get_comdata_struct ( MapComSrv_struct * map_com, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendcom_flag == 0 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + memcpy ( map_com, &vm_ptr->sendcom_data, sizeof ( struct MapComSrv_struct ) ); + if( xap_vm_ptr->debug_data.send_control ) + { + u8 data_flow[512]; + + map_com_stof ( map_com, data_flow, 0 ); + xap_msg_display ( data_flow ); + } + vm_ptr->sendcom_flag = 0; + xap_watch_dog(6); + xap_watch_dog(8); + return 1; +} + +u8 map_get_open ( u8 * data_flow, u8 ssn ) +{ + u8 aa; + u8 ii; + u8 flag = 0; + u32 temp_did; + + for ( aa = 0; aa < xap_inter_ptr->regssn_len; aa++ ) + { + if( xap_inter_ptr->reg_ssn[aa] == ssn ) // find ssn + { + flag = 1; + break; + } + } + if( flag == 0 ) + { + xap_send_error ( "SSN--%d is not registerd", ssn ); + return 0; + } + ii = xap_inter_ptr->open_tail[aa]; + if( xap_inter_ptr->open_head[aa] == ii ) // empty + return 0; + temp_did = xap_inter_ptr->open_did[aa][ii]; + xap_inter_ptr->open_tail[aa] = ( ii + 1 ) % XAP_OPEN_LEN; + if( !map_get_comdata ( data_flow, temp_did ) ) + return 0; + return 1; +} + +u8 map_get_open_struct ( MapComSrv_struct * map_com, u8 ssn ) +{ + u8 aa; + u8 ii; + u8 flag = 0; + u32 temp_did; + + for ( aa = 0; aa < xap_inter_ptr->regssn_len; aa++ ) + { + if( xap_inter_ptr->reg_ssn[aa] == ssn ) // find ssn + { + flag = 1; + break; + } + } + if( flag == 0 ) + { + xap_send_error ( "SSN--%d is not registerd", ssn ); + return 0; + } + ii = xap_inter_ptr->open_tail[aa]; + if( xap_inter_ptr->open_head[aa] == ii ) // empty + return 0; + temp_did = xap_inter_ptr->open_did[aa][ii]; + xap_inter_ptr->open_tail[aa] = ( ii + 1 ) % XAP_OPEN_LEN; + if( !map_get_comdata_struct ( map_com, temp_did ) ) + return 0; + return 1; +} + +u8 map_get_oprdata ( u8 * data_flow, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendopr_flag != 1 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + map_opr_stof ( &vm_ptr->sendopr_data, data_flow, 0 ); + vm_ptr->sendopr_flag = 0; + xap_watch_dog(11); + xap_msg_display ( data_flow ); + + if(vm_ptr->sendopr_data.message_type == SndRoutInfo) + { + if(vm_ptr->sendopr_data.message_flag == 2) + { + xap_watch_dog(18); + } + else + { + xap_watch_dog(19); + } + } + else if(vm_ptr->sendopr_data.message_type == ProvRoamNum) + { + if(vm_ptr->sendopr_data.message_flag == 2) + { + xap_watch_dog(22); + } + else + { + xap_watch_dog(23); + } + } + + return 1; +} + +u8 map_get_oprdata_struct ( MapOprData_struct * map_opr, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendopr_flag != 1 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + + memcpy ( map_opr, &vm_ptr->sendopr_data, sizeof ( struct MapOprData_struct ) ); + if( xap_vm_ptr->debug_data.send_control ) + { + u8 data_flow[512]; + + map_opr_stof ( map_opr, data_flow, 0 ); + xap_msg_display ( data_flow ); + } + vm_ptr->sendopr_flag = 0; + xap_watch_dog(11); + if(vm_ptr->sendopr_data.message_type == SndRoutInfo) + { + if(vm_ptr->sendopr_data.message_flag == 2) + { + xap_watch_dog(18); + } + else + { + xap_watch_dog(19); + } + } + else if(vm_ptr->sendopr_data.message_type == ProvRoamNum) + { + if(vm_ptr->sendopr_data.message_flag == 2) + { + xap_watch_dog(22); + } + else + { + xap_watch_dog(23); + } + } + return 1; +} + +int map_get_oprType ( u32 did ) +{ + struct xapp_vm_data *vm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->psm_data.psm_state == XAP_IDLE ) + { + return -1; + } + if( ( vm_ptr->sendopr_data.message_type != 0 ) && ( vm_ptr->sendopr_flag != 0 ) ) + { + return vm_ptr->sendopr_data.message_type; + } + return 0; +} + +u32 map_get_dialogueid ( u8 ssn ) +{ + u32 did; + + if( ( did = assign_did ( ) ) == 0 ) + { + xap_send_error ( "Fail to get did(Map)" ); + return 0; + } + xap_vm_ptr->xap_data[did].psm_data.xap_flag = XAP_MAP_SSN; + xap_watch_dog(55); + return did; +} + +#if _SUPPORT_ANSI +u32 is41_get_dialogueid ( u8 ssn ) +{ + u32 did; + + if( ( did = assign_did ( ) ) == 0 ) + { + xap_send_error ( "IS41 Fail to get did(Map)" ); + return 0; + } + xap_vm_ptr->xap_data[did].psm_data.xap_flag = XAP_IS41_SSN; + xap_watch_dog(56); + return did; +} +#endif + +u8 map_get_invokeid ( u32 did ) +{ + return assign_iid ( did ); +} + +#if _SUPPORT_ANSI +u8 map_check_map_flag ( u32 did ) +{ + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + if( xap_vm_ptr->xap_data[did].psm_data.xap_flag == XAP_IS41_SSN ) + return 0; + + return 1; +} +#endif + +int icap_reg_ssn ( u8 ssn ) +{ + u8 ii, jj; + if(wxc2_get_license(LIC_CAP)<=0) + { + xap_send_error ( "Can not register ssn in cap provider:no license" ); + return -1; + } + ii = xap_inter_ptr->regssn_len; + if( ii >= MAX_XAP_SSN ) + { + xap_send_error ( "Can not register ssn in map provider" ); + return -1; + } + for ( jj = 0; jj < ii; jj++ ) + { + if( xap_inter_ptr->reg_ssn[jj] == ssn ) + { + xap_send_error ( "ssn has registered in map provider" ); + return -1; + } + } + xap_inter_ptr->reg_ssn[ii] = ssn; + xap_inter_ptr->regssn_flag[ii] = XAP_CAP_SSN; + xap_inter_ptr->regssn_len++; + return itcap_reg_ssn ( ssn ); +} + +u8 cap_check_sendcom ( u32 did ) +{ + struct xapp_vm_data *vm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->recvcom_flag == 0 ) + return 1; + return 0; +} + +u8 cap_send_comdata ( u8 * data_flow ) // send cap common service data +{ + u8 result; + u32 temp_did; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapComSrv_struct map_com; + + xap_msg_display ( data_flow ); + if( ( result = cap_com_ftos ( &map_com, data_flow ) ) == 0 ) + return 0; + temp_did = map_com.dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + if( vm_ptr->recvcom_flag == 1 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + if( result == 2 || map_com.message_type == MAP_DELIMITER ) + psm_ptr->delimiter_flag = 1; + if( map_com.message_type != MAP_DELIMITER ) + { + memcpy ( &vm_ptr->recvcom_data, &map_com, sizeof ( MapComSrv_struct ) ); + psm_ptr->msg_type = map_com.message_type; + psm_ptr->msg_flag = map_com.message_flag; + vm_ptr->recvcom_flag = 1; + xap_watch_dog(29); + } + xap_watch_dog(25); + return 1; +} + +u8 cap_check_sendopr ( u32 did ) +{ + struct xapp_vm_data *vm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->recvopr_flag == 1 ) + return 0; + return 1; +} + +u8 cap_send_oprdata ( u8 * data_flow ) // send cap operation service data +{ + u8 result; + u32 temp_did; + struct xapp_vm_data *vm_ptr; + struct MapOprData_struct map_opr; + //u8 info[1024]; + + //xap_msg_display ( data_flow ); + if( ( result = cap_opr_ftos ( &map_opr, data_flow ) ) == 0 ) + { + xap_send_error ( "errro: cap ftos failed" ); + return 0; + } + temp_did = map_opr.dialogue_id; + if( temp_did >= ( xap_vm_ptr->grantdid ) ) + { + xap_send_error ( "cap errro: did > max did" ); + return 0; + } + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[temp_did]; + if( vm_ptr->recvopr_flag == 1 ) + { + //xap_send_error("cap errro: quence full"); + return 0; + } + xap_msg_display ( data_flow ); + memcpy ( &vm_ptr->recvopr_data, &map_opr, sizeof ( MapOprData_struct ) ); + if( result == 2 ) + { + vm_ptr->psm_data.delimiter_flag = 1; + //xap_send_ascout("Delimiter Flag = YES\r\n"); + } + vm_ptr->recvopr_flag = 1; + xap_watch_dog(45); + xap_watch_dog(49); + //sprintf(info, "cap_send_oprdata: did: %ld, iid: %d, iid_state: %d\r\n", map_opr.dialogue_id, map_opr.invoke_id, xap_vm_ptr->xap_data[map_opr.dialogue_id].psm_data.opr_state[map_opr.invoke_id]); + //xap_send_ascout(info); + + return 1; +} + +u8 cap_get_comdata ( u8 * data_flow, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendcom_flag == 0 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + cap_com_stof ( &vm_ptr->sendcom_data, data_flow, 0 ); + vm_ptr->sendcom_flag = 0; + xap_watch_dog(6); + xap_watch_dog(9); + xap_msg_display ( data_flow ); + return 1; +} + +u8 cap_get_open ( u8 * data_flow, u8 ssn ) +{ + u8 aa; + u8 ii; + u8 flag = 0; + u32 temp_did; + + for ( aa = 0; aa < xap_inter_ptr->regssn_len; aa++ ) + { + if( xap_inter_ptr->reg_ssn[aa] == ssn ) // find ssn + { + flag = 1; + break; + } + } + if( flag == 0 ) + { + xap_send_error ( "SSN--%d is not registerd", ssn ); + return 0; + } + ii = xap_inter_ptr->open_tail[aa]; + if( xap_inter_ptr->open_head[aa] == ii ) // empty + return 0; + temp_did = xap_inter_ptr->open_did[aa][ii]; + xap_inter_ptr->open_tail[aa] = ( ii + 1 ) % XAP_OPEN_LEN; + if( !cap_get_comdata ( data_flow, temp_did ) ) + return 0; + return 1; +} + +u8 cap_get_oprdata ( u8 * data_flow, u32 did ) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + if( did >= ( xap_vm_ptr->grantdid ) ) + return 0; + vm_ptr = ( xapp_vm_data * ) & xap_vm_ptr->xap_data[did]; + if( vm_ptr->sendopr_flag != 1 ) + return 0; + psm_ptr = ( psmvm_data * ) & vm_ptr->psm_data; + cap_opr_stof ( &vm_ptr->sendopr_data, data_flow, 0 ); + vm_ptr->sendopr_flag = 0; + xap_watch_dog(11); + xap_msg_display ( data_flow ); + return 1; +} + +u32 cap_get_dialogueid ( u8 ssn ) +{ + u32 did; + + if( ( did = assign_did ( ) ) == 0 ) + { + xap_send_error ( "Fail to get did(Cap)" ); + return 0; + } + xap_vm_ptr->xap_data[did].psm_data.xap_flag = XAP_CAP_SSN; + xap_watch_dog(57); + return did; +} + +u8 cap_get_invokeid ( u32 did ) +{ + return assign_iid ( did ); +} + +u8 xapp_check_did_state ( u32 did ) +{ + if( xap_vm_ptr->xap_data[did].psm_data.psm_state == XAP_IDLE ) + { + return 1; + } + xap_vm_ptr->debug_data.watch_dog[108]++; + return 0; +} + +u8 xapp_check_did ( u32 did ) +{ + if( xap_vm_ptr->xap_data[did].psm_data.psm_state <= XAP_IDLE ) + { + return 1; + } + return 0; +} + +u8 map_send_oprsrv ( MapOprSrv_struct * srv_ptr, u8 DelimiterFlag, u8 * data_flow ) +{ + u32 len; + u8 buf[4096]; + MapOprData_struct data_ptr; + + data_ptr.port_id = srv_ptr->port_id; + data_ptr.dialogue_id = srv_ptr->dialogue_id; + data_ptr.invoke_id = srv_ptr->invoke_id; + data_ptr.message_type = srv_ptr->message_type; + data_ptr.message_flag = srv_ptr->message_flag; + data_ptr.param_flag = 0x1f; + len = build_mapparam ( srv_ptr, buf ); + //printf ( "map_send_oprsrv: build map param len ; %d \n", len ); + if( len < 0 || len > MAX_MAPPOPR_LEN ) + { + xap_send_error ( "map_send_oprsrv: build mapparam too long!" ); + return 0; + } + data_ptr.param_len = len; + memcpy ( data_ptr.param, buf, len ); + data_ptr.param_flag |= 0x20; + map_opr_stof ( &data_ptr, data_flow, DelimiterFlag ); + + return map_send_oprdata ( data_flow ); +} + +u8 map_send_comsrv ( MapComSrv_struct * com_ptr, u8 uDelimiterFlag, u8 * data_flow ) +{ + map_com_stof ( com_ptr, data_flow, uDelimiterFlag ); + return map_send_comdata ( data_flow ); +} + +u8 map_send_open ( MapOpenArgParam * pOpenParam, u8 * uDataFlow ) +{ + MapComSrv_struct map_com; + MapOpen_Arg *pOpenArg; + + pOpenArg = &map_com.dlg_list.open_arg; + + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_REQUEST; + map_com.port_id = pOpenParam->pid; + map_com.dialogue_id = pOpenParam->did; + memcpy ( &pOpenArg->local_add, &pOpenParam->local_add, sizeof ( SCCP_ADDR ) ); + memcpy ( &pOpenArg->peer_add, &pOpenParam->peer_add, sizeof ( SCCP_ADDR ) ); + pOpenArg->acn_data.acn = pOpenParam->acn; + pOpenArg->acn_data.acn_ver = map_get_acnver ( &pOpenParam->local_add, pOpenParam->acn ); + pOpenArg->param_flag = 0x0b; + xap_watch_dog(60); + if (pOpenParam->uDelimeterFlag != 0) + xap_watch_dog(61); + return map_send_comsrv ( &map_com, pOpenParam->uDelimeterFlag, uDataFlow ); +} + +u8 map_send_close ( u32 pid, u32 did, u8 uCloseReasion ) +{ + MapComSrv_struct map_com; + u8 uDataFlow[4096]; + + map_com.message_type = MAP_CLOSE; + map_com.message_flag = MAP_REQUEST; + map_com.port_id = pid; + map_com.dialogue_id = did; + map_com.dlg_list.close_arg.release_method = uCloseReasion; + map_com.dlg_list.close_arg.param_flag = 0x01; + + return map_send_comsrv ( &map_com, 0, uDataFlow ); + +} + +u8 map_extract_param ( MapOprSrv_struct * srv_ptr, MapOprData_struct * data_ptr, int ver ) +{ + srv_ptr->port_id = data_ptr->port_id; + srv_ptr->dialogue_id = data_ptr->dialogue_id; + srv_ptr->invoke_id = data_ptr->invoke_id; + srv_ptr->message_type = data_ptr->message_type; + srv_ptr->message_flag = data_ptr->message_flag; + srv_ptr->version = ver; +/* + if( !( data_ptr->param_flag & 0x20 ) ) // has not parameter + return 0; + //some response doesn't take any parameter, like V2 fwdMOSMSResponse... +*/ + return extract_mapparam ( srv_ptr, data_ptr->message_type, data_ptr->message_flag, data_ptr->param_len, data_ptr->param ); +} + +u8 cap_send_oprsrv ( CapArg * pCapArg, u8 DelimiterFlag, u8 * data_flow ) +{ + + u32 len; + u8 buf[4096]; + MapOprData_struct data_ptr; + + data_ptr.port_id = pCapArg->port_id; + data_ptr.dialogue_id = pCapArg->dialogue_id; + data_ptr.invoke_id = pCapArg->invoke_id; + data_ptr.message_type = pCapArg->ocode; + data_ptr.message_flag = pCapArg->message_flag; + data_ptr.param_flag = 0x1f; + len = encode_capmsg ( *pCapArg, buf, 4096 ); + //printf ( "cap_send_oprsrv: build map param len ; %d \n", len ); + if( len == 0 || len > MAX_MAPPOPR_LEN ) + { + xap_send_error ( "cap_send_oprsrv: build capparam too long!" ); + return 0; + } + data_ptr.param_len = len; + memcpy ( data_ptr.param, buf, len ); + data_ptr.param_flag |= 0x20; + cap_opr_stof ( &data_ptr, data_flow, DelimiterFlag ); + + return cap_send_oprdata ( data_flow ); +} + +u8 cap_send_comsrv ( MapComSrv_struct * com_ptr, u8 uDelimiterFlag, u8 * data_flow ) +{ + cap_com_stof ( com_ptr, data_flow, uDelimiterFlag ); + return cap_send_comdata ( data_flow ); +} + +void wxc2_trace_xapp(u32 did) +{ + if (did >= (xap_vm_ptr->grantdid)) + return; + xap_vm_ptr->debug_data.monitor_did = did; +} diff --git a/omc/plat/xapp/src/xap_interfunc.h b/omc/plat/xapp/src/xap_interfunc.h new file mode 100644 index 0000000..15c1c2a --- /dev/null +++ b/omc/plat/xapp/src/xap_interfunc.h @@ -0,0 +1,11 @@ +/* XAP interface for map/cap use head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* --------------------------------------- */ + +#ifndef _XAP_INTER_FUNC +#define _XAP_INTER_FUNC + +void xap_send_error(const char *fmt,...); + +#endif diff --git a/omc/plat/xapp/src/xap_monitor.c b/omc/plat/xapp/src/xap_monitor.c new file mode 100644 index 0000000..319f267 --- /dev/null +++ b/omc/plat/xapp/src/xap_monitor.c @@ -0,0 +1,1239 @@ +/* XAP provider monitor c file */ +/* Written by Liu Zhiguo 2003-03-13 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "xap_provider.h" +#include "capp/cap_head.h" +#include "../../snmp/src/include/snmp.h" +#include "../../snmp/src/include/macro.h" +#include "conv_prefix.h" + +#define XAP_MAX_PAGE 8 +#define XAP_MAX_LINE 22 +#define XAP_STATE_LINE 20 +#define XAP_MODULE_ID 4 +#define XAP_ID_LEN 15 +#define XAP_TITLE_LEN 16 +#define XAP_LINE_LEN 17 +#define XAP_PAGE_POINT 14 +#define XAP_LINE_POINT 15 + +#define XAP_CONF_FILE "conf/xap_sysparam.conf" +#define XAP_MSCID_CONF_FILE "conf/xap_mscid.conf" + +#define XAP_PREOBJ_LEN 11 +extern void xap_snmp_registration(); + +void xap_disp_page(u8 page); +void xap_init(); +int readConvPrefixConf(); + +extern u8 init_mappconst(); +extern u8 init_cappconst(); + +static u8 xap_status = 1; +static u8 *xap_disp_ptr; +static u32 xap_page; +static u8 xap_did[2],xap_next_did[2]; +static u8 xap_ver[] = {9,2,0}; +u32 xap_object_id[] = {1,3,6,1,4,1,1373,2,3,2,5}; +static u32 xap_status_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,1}; +static u32 xap_version_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,2}; +static u32 xap_ascin_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,3}; +static u32 xap_ascout_id[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,4}; +static u32 xap_page_title[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,5,1}; +static u32 xap_page_line[] = {1,3,6,1,4,1,1373,1,3,2,3,1,2,XAP_MODULE_ID + 2,5,2,2}; + +static char opr_type_desc[5][16] = {"??", "Req", "Ind", "Rsp", "Cnf"}; + +char map_pabort_desc[7][32] = { + "Undefined", + "ProviderMalfunction", + "SupportingReleased", + "ResourceLimitation", + "MaintenanceActivity", + "VersionIncompatibility", + "AbnormalMAPDialogue"}; +char map_uabort_desc[10][32] = { + "Undefined", + "ShortTermProblem", + "LongTermProblem", + "HandoverCancel", + "RadioChannelRelease", + "NetworkPathRelease", + "CallRelease", + "AssociateProcedureFailure", + "TandemDialogueRelease", + "RemoteOperationFailure"}; + +char tcap_pabort_desc[7][64] = { + "unrecognized message tyep", + "unrecognized transaction ID", + "badly formatted transaction portion", + "incorrect transaction portion", + "resource limitation", + "abnormal dialogue", + "no common dialogue"}; + +char tcap_uabort_desc[3][32] = { + "no given reason", + "specific reason", + "ACN not supplied"}; + +u8 xap_get_addstr(char *str,u8 *bcd,u8 bcd_len) +{ // transfer bcd code to string + u8 ii; + + BcdToAscii(str,bcd,bcd_len*2); + for (ii = 0;ii < bcd_len*2;ii ++) + { + if (str[ii] == 'e' || str[ii] == 'E') + break; + } + str[ii] = '\0'; + return ii; +} +/* str size >64 */ +void xap_get_opstr(int flag , int op, char *str) +{ + if( flag == MAP_FLAG ) + { + switch(op) + { + case UpLoc : + strcpy(str , "MAP_UPDATE_LOCATION"); + break; + case CancelLoc: + strcpy(str , "MAP_CANCEL_LOCATION"); + break; + case PurgeMS: + strcpy(str , "MAP_PURGE_MS"); + break; + case SndIdent: + strcpy(str , "MAP_SEND_IDENTIFICATION"); + break; + case PreHo: + strcpy(str , "MAP_PREPARE_HANDOVER"); + break; + case SndEndSig: + strcpy(str , "MAP_SEND_END_SIGNAL"); + break; + case ProcAccSig: + strcpy(str , "MAP_PROCESS_ACCESS_SIGNALLING"); + break; + case FwdAccSig: + strcpy(str , "MAP_FORWARD_ACCESS_SIGNALLING"); + break; + case PreSubsHo: + strcpy(str , "MAP_PREPARE_SUBSEQUENT_HANDOVER"); + break; + case SndAuthInfo: + strcpy(str , "MAP_SEND_AUTHENTICATION_INFO"); + break; + case ChkIMEI: + strcpy(str , "MAP_CHECK_IMEI"); + break; + case InsSubData: + strcpy(str , "MAP_INSERT_SUBSCRIBER_DATA"); + break; + case DelSubData: + strcpy(str , "MAP_DELETE_SUBSCRIBER_DATA"); + break; + case Reset: + strcpy(str , "MAP_RESET"); + break; + case FwdChkSSInd: + strcpy(str , "MAP_FORWARD_CHECK_SS_INDICATION"); + break; + case RestoreData: + strcpy(str , "MAP_RESTORE_DATA"); + break; + case ActvTraceMode: + strcpy(str , "MAP_ACTIVATE_TRACE_MODE"); + break; + case DeactvTraceMode: + strcpy(str , "MAP_DEACTIVATE_TRACE_MODE"); + break; + case SndIMSI: + strcpy(str , "MAP_SEND_IMSI"); + break; + case SndRoutInfo: + strcpy(str , "MAP_SEND_ROUTING_INFORMATION"); + break; + case ProvRoamNum: + strcpy(str , "MAP_PROVIDE_ROAMING_NUMBER"); + break; + case ResumeCH : + strcpy(str , "MAP_RESUME_CALL_HANDLING"); + break; + case ProvSIWFSNum : + strcpy(str , "MAP_Provide_SIWFS_Number"); + break; + case SIWFSSigMdf : + strcpy(str , "MAP_SIWFS_Signalling_Modify"); + break; + case SetRepState : + strcpy(str , "MAP_SET_REPORTING_STATE"); + break; + case StatusRep : + strcpy(str , "MAP_STATUS_REPORT"); + break; + case RmtUserFree : + strcpy(str , "MAP_REMOTE_USER_FREE"); + break; + case RegSS : + strcpy(str , "MAP_REGISTER_SS"); + break; + case EraseSS : + strcpy(str , "MAP_ERASE_SS"); + break; + case ActvSS : + strcpy(str , "MAP_ACTIVATE_SS"); + break; + case DeactvSS : + strcpy(str , "MAP_DEACTIVATE_SS"); + break; + case InterSS : + strcpy(str , "MAP_INTERROGATE_SS"); + break; + case UnstrctSSReq : + strcpy(str , "MAP_UNSTRUCTURED_SS_REQUEST"); + break; + case UnstrctSSNoti : + strcpy(str , "MAP_UNSTRUCTURED_SS_NOTIFY"); + break; + case RegPasswd : + strcpy(str , "MAP_REGISTER_PASSWORD"); + break; + case GetPasswd : + strcpy(str , "MAP_GET_PASSWORD"); + break; + case RegCCEntry : + strcpy(str , "MAP_REGISTER_CC_ENTRY"); + break; + case EraseCCEntry : + strcpy(str , "MAP_ERASE_CC_ENTRY"); + break; + case SndRoutInfoForSM : + strcpy(str , "MAP_SEND_ROUTING_INFO_FOR_SM"); + break; + case FwdSM : + strcpy(str , "MAP_FORWARD_SHORT_MESSAGE"); + break; + //case MOFwdSM : + // strcpy(str , "MAP_MO_FORWARD_SHORT_MESSAGE"); + // break; + //case MTFwdSM : + // strcpy(str , "MAP_MT_FORWARD_SHORT_MESSAGE"); + // break; + case MTFwdSM_v3 : + strcpy(str , "MAP_MT_FORWARD_SHORT_MESSAGE"); + break; + case RptSMDelvStat: + strcpy(str , "MAP_REPORT_SM_DELIVERY_STATUS"); + break; + case InfSC : + strcpy(str , "MAP_INFORM_SERVICE_CENTRE"); + break; + case AlrtSC : + strcpy(str , "MAP_ALERT_SERVICE_CENTRE"); + break; + case RdyForSM : + strcpy(str , "MAP_READY_FOR_SM"); + break; + case ProvSubInfo: + strcpy(str , "MAP_PROVIDE_SUBSCRIBER_LOCATION"); + break; + case AnyTimeInter: + strcpy(str , "MAP_ANY_TIME_INTERROGATION"); + break; + case SSInvNoti: + strcpy(str , "MAP_SS_INVOCATION_NOTIFY"); + break; + case PreGrpCall : + strcpy(str , "MAP_PREPARE_GROUP_CALL"); + break; + case SndGrpCallEndSig : + strcpy(str , "MAP_send group call end signal"); + break; + case ProcGrpCallSig : + strcpy(str , "MAP_process group call signalling"); + break; + case FwdGrpCallSig : + strcpy(str , "forward group call signalling"); + break; + case UpGprsLoc: + strcpy(str , "MAP_update GPRS location"); + break; + case SndRoutInfoForGprs : + strcpy(str , "MAP_SEND_ROUTING_INFO_FOR_GPRS"); + break; + case FailRep : + strcpy(str , "MAP_FAIL_REPORT"); + break; + case NoteMsPresForGprs : + strcpy(str , "MAP_NOTE_MS_PRESENT_FOR_GPRS"); + break; + case SendParam : + strcpy(str , "MAP_SEND_PARAMETERS"); + break; + case NoteSubPrnt: + strcpy(str , "MAP_NOTE_SUBSCRIBER_PRESENT"); + break; + case ProcUnstrctSSData : + strcpy(str , "MAP_PROCESS_UNSTRUCTURED_SS_REQUEST"); + break; + case BeginSubAct: + strcpy(str , "MAP_BEGIN_SUBSRIBER_ACTIVITY"); + break; + case PerformHo: + strcpy(str , "MAP_PERFORM_HANDOVER"); + break; + case PerformSubsHo: + strcpy(str , "MAP_PERFORM_SUBSCRIBERS_HANDOVER"); + break; + case NoteInterHo : + strcpy(str , "MAP_NOTE_INTER_HANDOVER"); + break; + case AlrtSCWithoutRes : + strcpy(str , "MAP_ALERT_SERVICE_CENTRE_WITHOUT_RESULT"); + break; + case TraceSubAct : + strcpy(str , "MAP_TRACE_SUBSRCIBER_ACTIVITY"); + break; + case SecuTrip : + strcpy(str , "MAPH_ SECURITY_TRIPLETS"); + break; + case InterrSubs: + strcpy(str , "MAPH_INTERROGATE_SUBSCRIBER"); + break; + case CreateSubs: + strcpy(str , "MAPH_CREATE_SUBSCRIBER"); + break; + case DelSubs: + strcpy(str , "MAPH_DELETER_SUBSCRIBER"); + break; + case PingAuc : + strcpy(str , "MAPH_HLR_PING_AUC"); + break; + default : + strcpy(str,"MAP_OP_UNKNOWN"); + break; + } + } + else if( flag == CAP_FLAG ) + { + + switch(op) + { + case CAP_OC_InitialDP: + strcpy(str , "CAP_InitialDP"); + break; + case CAP_OC_AssistRequestInstructions: + strcpy(str , "CAP_AssistRequestInstructions"); + break; + case CAP_OC_EstablishTemporaryConnection: + strcpy(str , "CAP_EstablishTemporaryConnection"); + break; + case CAP_OC_DisconnectForwardConnection: + strcpy(str , "CAP_DisconnectForwardConnection"); + break; + case CAP_OC_ConnectToResource: + strcpy(str , "CAP_ConnectToResource"); + break; + case CAP_OC_Connect: + strcpy(str , "CAP_Connect"); + break; + case CAP_OC_ReleaseCall: + strcpy(str , "CAP_ReleaseCall"); + break; + case CAP_OC_RequestReportBCSMEvent: + strcpy(str , "CAP_RequestReportBCSMEvent"); + break; + case CAP_OC_EventReportBCSM: + strcpy(str , "CAP_EventReportBCSM"); + break; + case CAP_OC_Continue: + strcpy(str , "CAP_Continue"); + break; + case CAP_OC_ResetTimer: + strcpy(str , "CAP_ResetTimer"); + break; + case CAP_OC_FurnishChargingInformation: + strcpy(str , "CAP_FurnishChargingInformation"); + break; + case CAP_OC_ApplyCharging: + strcpy(str , "CAP_ApplyCharging"); + break; + case CAP_OC_ApplyChargingReport: + strcpy(str , "CAP_ApplyChargingReport"); + break; + case CAP_OC_CallInformationReport: + strcpy(str , "CAP_CallInformationReport"); + break; + case CAP_OC_CallInformationRequest: + strcpy(str , "CAP_CallInformationRequest"); + break; + case CAP_OC_SendChargingInformation: + strcpy(str , "CAP_SendChargingInformation"); + break; + case CAP_OC_PlayAnnouncement: + strcpy(str , "CAP_PlayAnnouncement"); + break; + case CAP_OC_PromptAndCollectUserInformation: + strcpy(str , "CAP_PromptAndCollectUserInformation"); + break; + case CAP_OC_SpecializedResourceReport: + strcpy(str , "CAP_SpecializedResourceReport"); + break; + case CAP_OC_Cancel: + strcpy(str , "CAP_Cancel"); + break; + case CAP_OC_ActivityTest: + strcpy(str , "MCAP_OC_ActivityTest"); + break; + case CAP_OC_ApplyWarningTone: + strcpy(str , "CAP_ApplyWarningTone"); + break; + case CAP_OC_CCF_Continue: + strcpy(str , "CAP_CCF_Continue"); + break; + case CAP_OC_InitialDPSMS: + strcpy(str , "CAP_InitialDPSMS"); + break; + case CAP_OC_FurnishChargingInformationSMS: + strcpy(str , "CAP_FurnishChargingInformationSMS"); + break; + case CAP_OC_ConnectSMS: + strcpy(str , "MCAP_OC_ConnectSMS"); + break; + case CAP_OC_RequestReportSMSEvent: + strcpy(str , "CAP_RequestReportSMSEvent"); + break; + case CAP_OC_EventReportSMS: + strcpy(str , "CAP_EventReportSMS"); + break; + case CAP_OC_ContinueSMS: + strcpy(str , "CAP_ContinueSMS"); + break; + case CAP_OC_ReleaseSMS: + strcpy(str , "CAP_ReleaseSMS"); + break; + case CAP_OC_ResetTimerSMS: + strcpy(str , "CAP_ResetTimerSMS"); + break; + default : + strcpy(str,"CAP_OP_UNKNOWN"); + break; + + } + } + + +} + +void xap_read_conf(void) +{ + FILE *fp; + struct stat fileinfo; + + xap_inter_ptr->local_prefix[0] = 0xEE; + xap_inter_ptr->local_prefix[1] = 0xEE; + fp = fopen(XAP_CONF_FILE,"rb"); + if (fp == NULL) + { + printf("can not open file %s!!\n",XAP_CONF_FILE); + return; + } + fread(xap_inter_ptr->mcc,16,1,fp); + + stat(XAP_CONF_FILE,&fileinfo); + if (fileinfo.st_size != 16) + {//old version, mdc is 1 octet long + xap_inter_ptr->mnc[0] = xap_inter_ptr->mnc0; + xap_inter_ptr->mnc[1] = 0xee; + } + + fclose(fp); +} + +void xap_read_mscid_conf(void) +{ + FILE *fp; + + fp = fopen(XAP_MSCID_CONF_FILE,"rb"); + if (fp == NULL) + { + printf("can not open file %s!!\n",XAP_MSCID_CONF_FILE); + return; + } + fread(xap_inter_ptr->mscidToNum,3072,1,fp); + + fclose(fp); +} + +void xap_write_conf(void) +{ + FILE *fp; + + fp = fopen(XAP_CONF_FILE,"wb"); + if (fp == NULL) + { + printf("can not open file %s!!\n",XAP_CONF_FILE); + return; + } + fwrite(xap_inter_ptr->mcc,16,1,fp); + fclose(fp); +} + +void xap_write_mscid_conf(void) +{ + FILE *fp; + + fp = fopen(XAP_MSCID_CONF_FILE,"wb"); + if (fp == NULL) + { + printf("can not open file %s!!\n",XAP_MSCID_CONF_FILE); + return; + } + fwrite(xap_inter_ptr->mscidToNum,3072,1,fp); + fclose(fp); +} + + + +#ifdef DEBUG_TEST +void xap_send_ascout(char *asc_str) +{ + StrTrimLeftSpace(asc_str); + if( asc_str[0] == CNULL ) + { + return; + } + //printf("[XAPP]: %s",asc_str); +} +#else +void xap_send_ascout(char *asc_str) +{ + if (xap_vm_ptr->debug_data.send_control == 1) + return; + if ((strlen(asc_str) + strlen(xap_vm_ptr->debug_data.ascout_buf)) > XAP_ASCOUT_LEN/4) // buffer is full + { + xap_vm_ptr->debug_data.send_control = 1; +// strcat(xap_vm_ptr->debug_data.ascout_buf,"\r\n--\r\n"); +// strcpy(xap_vm_ptr->debug_data.ascout_buf,asc_str); + } + else + strcat(xap_vm_ptr->debug_data.ascout_buf,asc_str); +} +#endif + + +void xap_send_error(const char *fmt,...) +{ + va_list ap; + char info[1024]; + + if (xap_vm_ptr->debug_data.error_switch == 0 || xap_vm_ptr->debug_data.send_control == 1) + return; + + xap_send_ascout("\33[31m"); + va_start(ap, fmt); + vsnprintf(info, 1020, fmt, ap); + va_end(ap); + + strcat(info, "\33[37m\r\n"); + xap_send_ascout(info); +} + +void xap_msg_display(u8 *info_str) +{ + int i = 0, j = 0, linemax = 24; + u32 msg_len; + u32 did; + u8 show_str[2048]; + char name[64]; + + if (xap_vm_ptr->debug_data.send_control == 1) + return; + + did = info_str[6] * 256 + info_str[7]; + + switch(info_str[2]) + { + case MAP_FLAG: + strcpy(name,"MAP"); + if (xap_vm_ptr->debug_data.map_switch == 0 && xap_vm_ptr->debug_data.monitor_did != did) + { + if(xap_vm_ptr->debug_data.error_switch == 0 || + (info_str[9] != MAP_U_ABORT && info_str[9] != MAP_P_ABORT && info_str[9] != MAP_NOTICE)) + return; + } + if (info_str[10] == 1 || info_str[10] == 3) // message type + { + sprintf(show_str, "[%04ld]User ==> %s ", did,name); + xap_send_ascout(show_str); + } + else + { + sprintf(show_str, "[%04ld]User <== %s ", did,name); + xap_send_ascout(show_str); + } + break; + case IS41_FLAG: + sprintf(name,"IS41"); + if (xap_vm_ptr->debug_data.map_switch == 0 && xap_vm_ptr->debug_data.monitor_did != did) + { + if(xap_vm_ptr->debug_data.error_switch == 0 || + (info_str[9] != MAP_U_ABORT && info_str[9] != MAP_P_ABORT && info_str[9] != MAP_NOTICE)) + return; + } + if (info_str[10] == 1 || info_str[10] == 3) // message type + { + sprintf(show_str, "[%04ld]User ==> %s ", did,name); + xap_send_ascout(show_str); + } + else + { + sprintf(show_str, "[%04ld]User <== %s ", did,name); + xap_send_ascout(show_str); + } + break; + case CAP_FLAG: + if (xap_vm_ptr->debug_data.cap_switch == 0 && xap_vm_ptr->debug_data.monitor_did != did) + { + if(xap_vm_ptr->debug_data.error_switch == 0 || + (info_str[9] != MAP_U_ABORT && info_str[9] != MAP_P_ABORT && info_str[9] != MAP_NOTICE)) + return; + } + if (info_str[10] == 1 || info_str[10] == 3) // message type + { + sprintf(show_str, "[%04ld]User ==> CAP ", did); + xap_send_ascout(show_str); + } + else + { + sprintf(show_str, "[%04ld]User <== CAP ", did); + xap_send_ascout(show_str); + } + break; + default: + xap_send_error("[%04ld]Invalid User type:0x%02X ", did, info_str[2]); + break; + } + + switch(info_str[9]) + { + case MAP_OPEN: + if( info_str[10] < 3 ) // req or ind + { + sprintf(show_str, "Xap_Open_%s ACN = %d , Version = %d\r\n", opr_type_desc[info_str[10]%5],info_str[11],info_str[12]); + } + else if( info_str[12] == 1 && info_str[13] == 1 && info_str[14] == 2)// req or ind + { + sprintf(show_str, "Xap_Open_%s ACN = %d , Version = %d\r\n", opr_type_desc[info_str[10]%5],info_str[15],info_str[16]); + } + else + { + sprintf(show_str, "Xap_Open_%s \r\n", opr_type_desc[info_str[10]%5]); + } + xap_send_ascout(show_str); + break; + case MAP_CLOSE: + sprintf(show_str, "Xap_Close\tmethod=%d\r\n", info_str[11]); + xap_send_ascout(show_str); + break; + case MAP_U_ABORT: + xap_send_error("Xap_UAbort\tuser reason=%s", map_uabort_desc[info_str[11] % 11]); + break; + case MAP_P_ABORT: + xap_send_error("Xap_PAbort\tprovider reason=%s", map_pabort_desc[info_str[11] & 7]); + break; + case MAP_NOTICE: + xap_send_error("Xap_Notice"); + break; + case MAP_DELIMITER: + sprintf(show_str, "Xap_Delimeter\r\n"); + xap_send_ascout(show_str); + break; + case MAP_LINK: + sprintf(show_str, "Xap_Link\r\n"); + xap_send_ascout(show_str); + break; + default: + xap_get_opstr(info_str[2], info_str[9], name); + sprintf(show_str, "%s Operation-%02X(%s)\tiid=%d\r\n",name, info_str[9], opr_type_desc[info_str[10]%5], info_str[11]); + xap_send_ascout(show_str); + break; + } + + msg_len = info_str[0] * 256 + info_str[1] + 2; + if (msg_len > 300) + { + xap_send_error("Invalid Length:%d", msg_len); + msg_len = 300; + } + + while(i * 24 < msg_len) + { + if((linemax = msg_len - 24 * i) > 24) + linemax = 24; + for(j = 0; j < linemax; j ++) + { + sprintf(show_str + 3 * j, "%02X ", info_str[24 * i + j]); + } + strcat(show_str, "\r\n"); + xap_send_ascout(show_str); + i ++; + } + + xap_send_ascout("\r\n"); + +} + +void xap_dlg_display(struct CSLdlg_struct *dha_ptr) +{ + u8 dlg_flag; + + if (dha_ptr->dialogue_id != xap_vm_ptr->debug_data.monitor_did) + return; + if (dha_ptr->message_flag == REQUEST) + dlg_flag = 2; + else + dlg_flag = 1; +// tcap_disp_dlg(dha_ptr,dlg_flag); +} + +void xap_cmp_display(struct CSLcmp_struct *cha_ptr) +{ + u8 dlg_flag; + + if (cha_ptr->dialogue_id != xap_vm_ptr->debug_data.monitor_did) + return; + if (cha_ptr->message_flag == REQUEST) + dlg_flag = 2; + else + dlg_flag = 1; +// tcap_disp_cmp(cha_ptr,dlg_flag); +} + +int xap_get_response(u8 oidlen,u32 *oid,u8 *pdata,u8 *vartype) +{ + u32 ii; + int data_len = -1; + + ii = XAP_PREOBJ_LEN; + switch(oid[ii]) + { + case 1: //measure + break; + case 2: //configuration + switch(oid[ii+2]) + { + case 1: //MCC + memcpy(pdata,xap_inter_ptr->mcc,2); + data_len = 2; + *vartype = 0x44; + break; + case 2: //MNC + memcpy(pdata,&xap_inter_ptr->mnc,2); + data_len = 2; + *vartype = 0x44; + break; + case 3: //CC + memcpy(pdata,xap_inter_ptr->cc,2); + data_len = 2; + *vartype = 0x44; + break; + case 4: //NDC + memcpy(pdata,xap_inter_ptr->ndc,3); + data_len = 3; + *vartype = 0x44; + break; + case 5: //International Prefix + memcpy(pdata,xap_inter_ptr->inter_prefix,2); + data_len = 2; + *vartype = 0x44; + break; + case 6: //National Prefix + memcpy(pdata,xap_inter_ptr->national_prefix,2); + data_len = 2; + *vartype = 0x44; + break; + case 7: // monitor control flag + memcpy(pdata,xap_inter_ptr->local_prefix,2); + data_len = 2; + *vartype = 0x44; + break; + case 8: + switch(oid[ii+2]) + { + case 1: + return snmpGetConvPrefix(oidlen,oid,pdata,vartype); + break; + case 2: + return snmpGetGroupConvPrefix(oidlen,oid,pdata,vartype); + break; + } + break; + case 9: + return snmpGetCliPrefix(oidlen,oid,pdata,vartype); + break; + case 10: + memcpy(pdata,xap_inter_ptr->mscidToNum[oid[ii+2]],14); + data_len = 14; + *vartype = 4; + break; + break; + case 11: + return snmpGetPlatName(oidlen,oid,pdata,vartype); + break; + default: + break; + } + break; + case 3: //status + if (oid[ii+1] == 1) + { + memcpy(pdata,xap_ver,3); + data_len = 3; + *vartype = 4; + } + break; + default: + break; + } + return data_len; +} + +int xap_set_response(u8 oidlen,u32 *oid,u8 *pdata,u16 datalen) +{ + u32 ii; + + ii = XAP_PREOBJ_LEN; + switch(oid[ii]) + { + case 1: //measure + break; + case 2: //configuration + switch(oid[ii+1]) + { + case 1: //MCC + if (datalen != 2) + return -1; + memcpy(xap_inter_ptr->mcc,pdata,2); + return 2; + case 2: //MNC + if (datalen < 2) + return -1; + if (datalen == 2) + memcpy(xap_inter_ptr->mnc,pdata,2); + else + { + xap_inter_ptr->mnc[0] = pdata[0]; + xap_inter_ptr->mnc[1] = 0xee; + } + return 2; + case 3: //CC + if (datalen != 2) + return -1; + memcpy(xap_inter_ptr->cc,pdata,2); + return 2; + break; + case 4: //NDC + if (datalen != 3) + return -1; + memcpy(xap_inter_ptr->ndc,pdata,3); + return 3; + break; + case 5: //International Prefix + if (datalen != 2) + return -1; + memcpy(xap_inter_ptr->inter_prefix,pdata,2); + return 2; + break; + case 6: //National Prefix + if (datalen != 2) + return -1; + memcpy(xap_inter_ptr->national_prefix,pdata,2); + return 2; + break; + case 7: // debug flag control + if (datalen != 2) + return -1; + memcpy(xap_inter_ptr->local_prefix,pdata,2); + return 2; + break; + case 8: + switch(oid[ii+2]) + { + case 1: + return snmpSetConvPrefix(oidlen,oid,pdata,datalen); + break; + case 2: + return snmpSetGroupConvPrefix(oidlen,oid,pdata,datalen); + break; + } + break; + case 9: + return snmpSetCliPrefix(oidlen,oid,pdata,datalen); + break; + case 10: + if (datalen != 14) + return -1; + memcpy(xap_inter_ptr->mscidToNum[oid[ii+2]],pdata,14); + return 14; + break; + break; + case 11: + return snmpSetPlatName(oidlen,oid,pdata,datalen); + break; + default: + break; + } + break; + case 3: //status + if (oid[ii+1] == 2) // system command + { + if (pdata[0] == 0x01) // save system parameter + { + xap_write_conf(); + xap_write_mscid_conf(); + saveConvPrefix(); + return 1; + } + if ((pdata[0] & 0x02) > 0)//reload parameters and reset + { + xap_init( xap_vm_ptr->grantdid ); + } + } + break; + default: + break; + } + return -1; +} + +void xap_init_m(void) +{ + u32 str_len; + char temp_str[1024],info_str[1024]; + char *cur_time; + u8 page,ii; + + debug_set_response(XAP_ID_LEN,xap_status_id,&xap_status,1); // set status id + sprintf(info_str,"R%dV%d_%02d",xap_ver[0],xap_ver[1],xap_ver[2]); + debug_set_response(XAP_ID_LEN,xap_version_id,info_str,strlen(info_str)); // set module description + debug_set_response(XAP_ID_LEN,xap_ascin_id,xap_vm_ptr->debug_data.ascin_buf,XAP_ASCIN_LEN); + debug_set_response(XAP_ID_LEN,xap_ascout_id,xap_vm_ptr->debug_data.ascout_buf,XAP_ASCOUT_LEN); + + xap_page = 0; + memset(xap_did,0,2); + memset(xap_next_did,0,2); + xap_next_did[1] = 1; + for (page = 1;page < XAP_MAX_PAGE;page ++) + { + switch (page) + { + case 1: // system parameter + sprintf(info_str,"Page %d\t\tXAP system parameter\r\n\nVersion\r\nMCC\r\nMNC\r\nCC\r\nNDC\r\nInter prefix\r\nNational prefix\r\nRegister SSN\r\n",page); + str_len = strlen(info_str); + break; + case 2: // map provider status + sprintf(temp_str,"Dialogue ID\r\nFSM state\r\nACN\r\nTimer\r\nOperation state\r\nOperation code\r\nOperation class\r\n"); + sprintf(info_str,"Page %d\t\tMAP status\r\n\n%s\nNext Dialogue ID status\r\n\n%s",page,temp_str,temp_str); + str_len = strlen(info_str); + break; + case 3: // SCF status + sprintf(temp_str,"Dialogue ID\r\nFSM state\r\nOperation\r\nEDPs\r\nEDP_flag\r\nExpire Times\r\nTimer\r\n"); + sprintf(info_str,"Page %d\t\tSCF status\r\n\n%s\nNext Dialogue ID status\r\n\n%s",page,temp_str,temp_str); + str_len = strlen(info_str); + break; + case 4: // SSF status + sprintf(temp_str,"Dialogue ID\r\nFSM state\r\nRelationship\r\nRequest number\r\nTssf timer\r\nO-BCSM\r\nT-BCSM\r\n"); + sprintf(info_str,"Page %d\t\tSSF status\r\n\n%s\nNext Dialogue ID status\r\n\n%s",page,temp_str,temp_str); + str_len = strlen(info_str); + break; + case 5: // xap watchdog + sprintf(info_str,"Page %d\t\tWatch dog\r\n\n",page); + for (ii = 0;ii < XAP_MAX_LINE;ii ++) + { + sprintf(temp_str,"%d--%d\r\n",ii*5,ii*5+4); + strcat(info_str,temp_str); + } + str_len = strlen(info_str); + break; + default: + strcpy(info_str,"NONE\r\n"); + str_len = strlen(info_str); + break; + } + xap_page_title[XAP_PAGE_POINT] = page + 5; + debug_set_response(XAP_TITLE_LEN,xap_page_title,info_str,str_len); + xap_disp_page(page); + } + //inquire_setmsg(XAP_PREOBJ_LEN,xap_object_id,xap_set_response); + //inquire_getmsg(XAP_PREOBJ_LEN,xap_object_id,xap_get_response); + xap_snmp_registration(); + xap_read_conf(); + xap_read_mscid_conf(); + readConvPrefixConf(); + cur_time = GetAsciiTime(); + xap_vm_ptr->debug_data.start_time = GetAsciiTime(); + sprintf(info_str,"XAP init process completed. Init time is:%s\r",cur_time); + xap_send_ascout(info_str); +} + +u8 xap_disp_line(u8 page,u8 line) +{ + u8 temp_line; + u8 line_len=0; + u32 temp_did; + struct xapp_vm_data *vm_ptr; + + xap_disp_ptr = xap_ver; + switch (page) + { + case 1: // system parameter + switch (line) + { + case 0: // version + xap_disp_ptr = xap_ver; + line_len = 3; + break; + case 1: // MCC + xap_disp_ptr = xap_inter_ptr->mcc; + line_len = 2; + break; + case 2: // MNC + xap_disp_ptr = xap_inter_ptr->mnc; + line_len = 2; + break; + case 3: // CC + xap_disp_ptr = xap_inter_ptr->cc; + line_len = 2; + break; + case 4: // NDC + xap_disp_ptr = xap_inter_ptr->ndc; + line_len = 3; + break; + case 5: // international prefix + xap_disp_ptr = xap_inter_ptr->inter_prefix; + line_len = 2; + break; + case 6: // nationla prefix + xap_disp_ptr = xap_inter_ptr->national_prefix; + line_len = 2; + break; + case 7: // register ssn + xap_disp_ptr = xap_inter_ptr->reg_ssn; + line_len = MAX_XAP_SSN; + break; + default: + break; + } + break; + case 2: // show the map provider state + if (line < 10) + { + temp_did = xap_did[0] * 256 + xap_did[1]; + temp_line = line; + } + else + { + temp_did = (xap_next_did[0] * 256 + xap_next_did[1]) % (xap_vm_ptr->grantdid); + temp_line = line - 10; + } + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[temp_did]; + switch (temp_line) + { + case 0: // dialogue id + if (line < 10) + xap_disp_ptr = xap_did; + else + xap_disp_ptr = xap_next_did; + line_len = 2; + break; + case 1: // fsm state + xap_disp_ptr = &vm_ptr->psm_data.psm_state; + line_len = 2; + break; + case 2: // acn + xap_disp_ptr = &vm_ptr->psm_data.acn; + line_len = 2; + break; + case 3: // timer + xap_disp_ptr = (u8 *) &vm_ptr->psm_data.suspend_timer; + line_len = 4; + break; + case 4: // operation state + xap_disp_ptr = vm_ptr->psm_data.opr_state; + line_len = 20; + break; + case 5: // operation code + xap_disp_ptr = vm_ptr->psm_data.opr_code; + line_len = 20; + break; + case 6: // operation class + xap_disp_ptr = vm_ptr->psm_data.opr_class; + line_len = 20; + break; + default: + break; + } + break; + case 3: // show the scf provider state + break; + case 4: // show the ssf provider state + break; + case 5: + xap_disp_ptr = (u8 *) &xap_vm_ptr->debug_data.watch_dog[line*5]; + line_len = 20; + break; + default: + line_len = 0; + break; + } + return line_len; +} + +void xap_disp_page(u8 page) +{ + u8 line; + u8 line_len; + + xap_page_line[XAP_PAGE_POINT] = page + 5; + for (line = 0;line < XAP_MAX_LINE;line ++) + { + line_len = xap_disp_line(page,line); + xap_page_line[XAP_LINE_POINT] = line + 2; + debug_set_response(XAP_LINE_LEN,xap_page_line,xap_disp_ptr,line_len); + } +} + +void xap_monitor(void) +{ + u32 ii; + u8 info_str[1024],temp_str[1024]; + struct xap_debug_struct *debug_ptr; + + debug_ptr = (xap_debug_struct *) &xap_vm_ptr->debug_data; + debug_ptr->send_control = 0; + if (strlen(debug_ptr->ascin_buf) > 0) // has command + { + if (strcmp(debug_ptr->ascin_buf+1,"help") == 0) // show help info + { + sprintf(info_str,"Now the monitored module is XAP provider.\r\nVersion is R%dV%02d_%02d and start time is %s\r\n",xap_ver[0],xap_ver[1],xap_ver[2],debug_ptr->start_time); + xap_send_ascout(info_str); + xap_send_ascout("The XAP module command list:\r\n"); + xap_send_ascout("log all ---- Turn on all log items\r\n"); + xap_send_ascout("log none ---- Turn off all log items\r\n"); + xap_send_ascout("log map ---- Turn on the map log item\r\n"); + xap_send_ascout("log cap ---- Turn on the cap log item\r\n"); + xap_send_ascout("log error ---- Turn on the error log item\r\n"); + xap_send_ascout("log port [did] ---- Monitor the appointed dialogue id\r\n"); + xap_send_ascout("list parameter ---- Display the system parameter in XAP provider\r\n"); + xap_send_ascout("reset ---- Reset XAP provider\r\n"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"clear") == 0) + memset(debug_ptr->watch_dog,0,XAP_WTDOG_LEN*sizeof(u32)); + else if (strcmp(debug_ptr->ascin_buf+1,"log none") == 0) // close all switch + { + debug_ptr->error_switch = 0; + debug_ptr->map_switch = 0; + debug_ptr->cap_switch = 0; + xap_send_ascout("XAP all switch close\n\r"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log error") == 0)// open error switch + { + debug_ptr->error_switch = 1; + xap_send_ascout("XAP error switch open\n\r"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log map") == 0)// open to map switch + { + debug_ptr->map_switch = 1; + xap_send_ascout("XAP monitor map switch open\n\r"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log cap") == 0)// open to map switch + { + debug_ptr->cap_switch = 1; + xap_send_ascout("XAP monitor cap switch open\n\r"); + } + else if (strcmp(debug_ptr->ascin_buf+1,"log all") == 0)// open all switch + { + debug_ptr->error_switch = 1; + debug_ptr->map_switch = 1; + debug_ptr->cap_switch = 1; + xap_send_ascout("XAP all switch open\n\r"); + } + else if (strncmp(debug_ptr->ascin_buf+1,"did ",4) == 0) // change section page + { + ii = atol(debug_ptr->ascin_buf+5) % (xap_vm_ptr->grantdid); + xap_did[0] = ii >> 8; + xap_did[1] = ii & 0xff; + xap_next_did[0] = (ii+1) >> 8; + xap_next_did[1] = (ii+1) & 0xff; + } + else if (strncmp(debug_ptr->ascin_buf+1,"log port ",9) == 0) // monitor the did + { + ii = atol(debug_ptr->ascin_buf+10); + if (ii >= (xap_vm_ptr->grantdid)) + xap_send_ascout("The appointed dialogue id is not expected\r\n"); + else + debug_ptr->monitor_did = ii; + } + else if (strcmp(debug_ptr->ascin_buf+1,"list parameter") == 0) // diaplay system parameter + { + xap_get_addstr(temp_str,xap_inter_ptr->mcc,2); + sprintf(info_str,"The XAP provider system parameter is:\r\nMCC(Mobile Country Code): %s\r\n",temp_str); + xap_send_ascout(info_str); + xap_get_addstr(temp_str,xap_inter_ptr->mnc,2); + sprintf(info_str,"MNC(Mobile Network Code): %s\r\n",temp_str); + xap_send_ascout(info_str); + xap_get_addstr(temp_str,xap_inter_ptr->cc,2); + sprintf(info_str,"CC(Country Code): %s\r\n",temp_str); + xap_send_ascout(info_str); + xap_get_addstr(temp_str,xap_inter_ptr->ndc,3); + sprintf(info_str,"NDC(National Destination Code): %s\r\n",temp_str); + xap_send_ascout(info_str); + xap_get_addstr(temp_str,xap_inter_ptr->inter_prefix,2); + sprintf(info_str,"International prefix: %s\r\n",temp_str); + xap_send_ascout(info_str); + xap_get_addstr(temp_str,xap_inter_ptr->national_prefix,2); + sprintf(info_str,"National prefix: %s\r\n",temp_str); + xap_send_ascout(info_str); + } + else if (strcmp(debug_ptr->ascin_buf+1,"reset") == 0) // diaplay system parameter + { + //xap_init( xap_vm_ptr->grantdid ); + } + else if (strcmp(debug_ptr->ascin_buf+1,"reload acn") == 0) // diaplay system parameter + { + init_mappconst(); + init_cappconst(); + } + debug_ptr->ascin_buf[0] = '\0'; + } +/* for (ii = 1;ii < XAP_MAX_PAGE;ii ++) + xap_disp_page(ii);*/ +} + +void xap_watch_dog(u32 wd_site) +{ + if (wd_site > XAP_WTDOG_LEN) + return; + xap_vm_ptr->debug_data.watch_dog[wd_site] ++; +} + +void xap_logdebug(const char *fmt,...) +{ + va_list ap; + char info[1024]; + + va_start(ap, fmt); + vsnprintf(info, 1020, fmt, ap); + va_end(ap); + + return xap_send_ascout(info); +} diff --git a/omc/plat/xapp/src/xap_monitor.h b/omc/plat/xapp/src/xap_monitor.h new file mode 100644 index 0000000..ffa8176 --- /dev/null +++ b/omc/plat/xapp/src/xap_monitor.h @@ -0,0 +1,19 @@ +/* XAP monitor head file */ +/* Written by Liu Zhiguo 2003-03-13 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#ifndef _XAP_MONITOR +#define _XAP_MONITOR + +void xap_init_m(void); +void xap_monitor(void); + +void xap_send_error(const char *fmt,...); +void xap_msg_display(u8 *info_str); +void xap_dlg_display(struct CSLdlg_struct *dha_ptr); +void xap_cmp_display(struct CSLcmp_struct *cha_ptr); +void xap_watch_dog(u32 wd_site); +void xap_logdebug(const char *fmt,...); + +#endif diff --git a/omc/plat/xapp/src/xap_provider.c b/omc/plat/xapp/src/xap_provider.c new file mode 100644 index 0000000..547c0f0 --- /dev/null +++ b/omc/plat/xapp/src/xap_provider.c @@ -0,0 +1,3421 @@ +/* XAP provider c file */ +/* Written by Liu Zhiguo 2003-03-12 */ +/* Version 1.0 */ +/* -------------------------------- */ + + +#include "xap_provider.h" +#include "xap_monitor.h" +#include "../../tcap/src/include/itcap.h" +#include "../../tcap/src/include/idmanage.h" + + +struct xap_acn_info map_acn_buf; +struct xap_acn_info cap_acn_buf; +struct xap_opr_info map_opr_buf; +struct xap_opr_info cap_opr_buf; +struct xap_opr_info is41_opr_buf; + +extern char tcap_pabort_desc[7][64]; +extern char tcap_uabort_desc[3][32]; + +/** extern function **/ +extern void is41_init(); +#if _SUPPORT_ANSI +extern u8 map_check_map_flag(u32 did); +#endif + +u8 init_is41const(void) +{ +#if _SUPPORT_ANSI + FILE *fp,*temp_fp; + char oprfile_name[32]="conf/is41_operation.conf"; + char string[256]; + char temp[256]; + char *ch_ptr; + int ii,jj; +#endif + + is41_init();//init is41 coding + +#if _SUPPORT_ANSI + + fp = fopen(oprfile_name,"r"); // read operation code file + if (fp == NULL) + { + xap_send_error("XAPP can not open is41 operation code file %s!!\n",oprfile_name); + return 0; + } + temp_fp = fp; + while(!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"total data length=",18) == 0) // acn total length + { + strcpy(temp,(strchr(string,'=')+1)); + is41_opr_buf.buf_len = atol(temp); + if (is41_opr_buf.buf_len > XAP_OPR_NUM) + { + printf("XAPP is41 opration length is larger than expected"); + is41_opr_buf.buf_len = XAP_OPR_NUM; + return 0; + } + break; + } + } + for (ii = 0;ii < is41_opr_buf.buf_len;ii++) + { + temp_fp = fp; + while (!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"No.",3) == 0) + { + ch_ptr = strchr(string,'.') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,':')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + if (ii != (atol(temp)-1)) // not find data + continue; + ch_ptr = strchr(string,':') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + is41_opr_buf.opr_code[ii] = atol(temp); + ch_ptr = strchr(string,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(ch_ptr,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + is41_opr_buf.opr_class[ii] = atol(temp); + ch_ptr = strchr(ch_ptr,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,'\t')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + is41_opr_buf.opr_timer[ii] = atol(temp); + break; + } + } + } + fclose(fp); + +#endif + + return 1; +} + +u8 init_mappconst(void) +{ + FILE *fp,*temp_fp; + char acnfile_name[32]="conf/map_acn.conf"; + char oprfile_name[32]="conf/map_operation.conf"; + char string[256]; + char temp[256]; + char *ch_ptr; + int ii,jj; + + fp = fopen(acnfile_name,"r"); // read acn info + if (fp == NULL) + { + xap_send_error("XAPP can not open ACN file %s!!\n",acnfile_name); + return 0; + } + temp_fp = fp; + while(!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"total data length=",18) == 0) // acn total length + { + strcpy(temp,(strchr(string,'=')+1)); + map_acn_buf.buf_len = atol(temp); + if (map_acn_buf.buf_len > XAP_ACN_NUM) + { + printf("XAPP map acn length is larger than expected!!"); + map_acn_buf.buf_len = XAP_ACN_NUM; + return 0; + } + break; + } + } + for (ii = 0;ii < map_acn_buf.buf_len;ii++) + { + temp_fp = fp; + while (!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"No.",3) == 0) + { + ch_ptr = strchr(string,'.') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,':')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + if (ii != (atol(temp)-1)) // not find data + continue; + ch_ptr = strchr(string,':') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + map_acn_buf.acn[ii] = atol(temp); + ch_ptr = strchr(string,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,'\t')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + map_acn_buf.acn_ver[ii] = atol(temp); + break; + } + } + } + fclose(fp); + + fp = fopen(oprfile_name,"r"); // read operation code file + if (fp == NULL) + { + xap_send_error("XAPP can not open map operation code file %s!!\n",oprfile_name); + return 0; + } + temp_fp = fp; + while(!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"total data length=",18) == 0) // acn total length + { + strcpy(temp,(strchr(string,'=')+1)); + map_opr_buf.buf_len = atol(temp); + if (map_opr_buf.buf_len > XAP_OPR_NUM) + { + printf("XAPP map opration length is larger than expected"); + map_opr_buf.buf_len = XAP_OPR_NUM; + return 0; + } + break; + } + } + for (ii = 0;ii < map_opr_buf.buf_len;ii++) + { + temp_fp = fp; + while (!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"No.",3) == 0) + { + ch_ptr = strchr(string,'.') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,':')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + if (ii != (atol(temp)-1)) // not find data + continue; + ch_ptr = strchr(string,':') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + map_opr_buf.opr_code[ii] = atol(temp); + ch_ptr = strchr(string,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(ch_ptr,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + map_opr_buf.opr_class[ii] = atol(temp); + ch_ptr = strchr(ch_ptr,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,'\t')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + map_opr_buf.opr_timer[ii] = atol(temp); + break; + } + } + } + fclose(fp); + + return 1; +} + +u8 init_cappconst(void) +{ + FILE *fp,*temp_fp; + char acnfile_name[32]="conf/cap_acn.conf"; + char oprfile_name[32]="conf/cap_operation.conf"; + char string[256]; + char temp[256]; + char *ch_ptr; + int ii,jj; + char info_str[1024]; + + fp = fopen(acnfile_name,"r"); // read acn info + if (fp == NULL) + { + sprintf(info_str,"XAPP can not open ACN file %s!!\n",acnfile_name); + xap_send_error(info_str); + printf("%s",info_str); + return 0; + } + temp_fp = fp; + while(!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"total data length=",18) == 0) // acn total length + { + strcpy(temp,(strchr(string,'=')+1)); + cap_acn_buf.buf_len = atol(temp); + if (cap_acn_buf.buf_len > XAP_ACN_NUM) + { + printf("XAPP cap acn length is larger than expected!!"); + cap_acn_buf.buf_len = XAP_ACN_NUM; + return 0; + } + break; + } + } + for (ii = 0;ii < cap_acn_buf.buf_len;ii++) + { + temp_fp = fp; + while (!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"No.",3) == 0) + { + ch_ptr = strchr(string,'.') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,':')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + if (ii != (atol(temp)-1)) // not find data + continue; + ch_ptr = strchr(string,':') + 1; + if(ch_ptr == NULL) continue; + jj = strlen(ch_ptr) - strlen(strchr(string,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + cap_acn_buf.acn[ii] = atol(temp); + ch_ptr = strchr(string,' ') + 1; + if(ch_ptr == NULL) continue; + jj = strlen(ch_ptr) - strlen(strchr(string,'\t')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + cap_acn_buf.acn_ver[ii] = atol(temp); + break; + } + } + } + fclose(fp); + + fp = fopen(oprfile_name,"r"); // read operation code file + if (fp == NULL) + { + xap_send_error("XAPP can not open operation code file %s!!\n",oprfile_name); + return 0; + } + temp_fp = fp; + while(!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"total data length=",18) == 0) // acn total length + { + strcpy(temp,(strchr(string,'=')+1)); + cap_opr_buf.buf_len = atol(temp); + if (cap_opr_buf.buf_len > XAP_OPR_NUM) + { + printf("XAPP cap opration length is larger than expected"); + cap_opr_buf.buf_len = XAP_OPR_NUM; + return 0; + } + break; + } + } + for (ii = 0;ii < cap_opr_buf.buf_len;ii++) + { + temp_fp = fp; + while (!feof(temp_fp)) + { + fgets(string,250,temp_fp); + if (strncmp(string,"No.",3) == 0) + { + ch_ptr = strchr(string,'.') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,':')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + if (ii != (atol(temp)-1)) // not find data + continue; + ch_ptr = strchr(string,':') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + cap_opr_buf.opr_code[ii] = atol(temp); + ch_ptr = strchr(string,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(ch_ptr,' ')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + cap_opr_buf.opr_class[ii] = atol(temp); + ch_ptr = strchr(ch_ptr,' ') + 1; + jj = strlen(ch_ptr) - strlen(strchr(string,'\t')); + strncpy(temp,ch_ptr,jj); + temp[jj] = '\0'; + cap_opr_buf.opr_timer[ii] = atol(temp); + break; + } + } + } + fclose(fp); + return 1; +} + +void xap_init(int didgrant) +{ + int shm_id; + + /* xap virtue machine share memory */ + if ((shm_id = shmget(XAP_VM_KEY,sizeof(xap_vm_struct),XAP_VM_PERM|IPC_CREAT)) == -1) + { + printf("can not init xap_vm share memory1\n"); + exit(0); + } + if ((xap_vm_ptr = (xap_vm_struct *)shmat(shm_id,(char *)0,0)) == (xap_vm_struct *) -1) + { + printf("can not init xap_vm share memory2\n"); + exit(0); + } + memset(xap_vm_ptr,0,sizeof(xap_vm_struct)); + xap_vm_ptr->debug_data.ascin_buf[0] = '\0'; + xap_vm_ptr->debug_data.ascout_buf[0] = '\0'; + /* xap interface share memory */ + if ((shm_id = shmget(XAP_INTER_KEY,sizeof(xap_inter_struct),XAP_INTER_PERM|IPC_CREAT)) == -1) + { + printf("can not init xap_inter share memory1\n"); + exit(0); + } + if ((xap_inter_ptr = (xap_inter_struct *)shmat(shm_id,(char *)0,0)) == (xap_inter_struct *) -1) + { + printf("can not init xap_inter share memory2\n"); + exit(0); + } + if( didgrant <= 0 || didgrant > MAX_DIALOGUEID) + { + printf( "unexpect tcap did grant number!\r\n"); + exit(0); + } + (xap_vm_ptr->grantdid) = didgrant; + memset(xap_inter_ptr,0,sizeof(xap_inter_struct)); + memset(&map_acn_buf,0,sizeof(xap_acn_info)); + memset(&map_opr_buf,0,sizeof(xap_opr_info)); + memset(&is41_opr_buf,0,sizeof(xap_opr_info)); + if (!init_mappconst()) + xap_send_error("MAP system configure data has problem"); + memset(&cap_acn_buf,0,sizeof(xap_acn_info)); + memset(&cap_opr_buf,0,sizeof(xap_opr_info)); + if (!init_cappconst()) + xap_send_error("CAP system configure data has problem"); + if (!init_is41const()) + xap_send_error("IS41 system configure data has problem"); + xap_init_m(); +} + +void set_mapperr(struct MapOprData_struct *opr_ptr,u8 perr_flag) // set map provider error +{ + opr_ptr->param_flag |= 0x80; + opr_ptr->provider_error = perr_flag; +} + +void set_mapuerr(struct MapOprData_struct *opr_ptr,u8 uerr_flag) // set map user error +{ + opr_ptr->param_flag |= 0x40; + opr_ptr->user_error = uerr_flag; +} + +u8 check_mapuerr(struct MapOprData_struct *opr_ptr,u8 *temp_result) +{ + if (opr_ptr->message_flag != MAP_RESPONSE) + return 0; + if ((opr_ptr->param_flag & 0x40)) + { + *temp_result = opr_ptr->user_error; + return 1; + } + return 0; +} + +void get_mapuabort_reason(MapUAbort_Arg *abrt_ptr,MapDlgUAbort_struct *dlg_ptr) +{ + u32 temp_flag; + + temp_flag = 0x01; + switch (dlg_ptr->choice_flag) + { + case 0: // user specific reason + abrt_ptr->user_reason = ProcedureError; + break; + case 1: // user resource limitation + abrt_ptr->user_reason = ResourceLimite; + break; + case 2: // resource unavailable reason + temp_flag += 0x02; + abrt_ptr->user_reason = ResourceUnavailable; + if (dlg_ptr->choice.resunavi == 0) // short term resource limitation + abrt_ptr->diag_info = ShortTermProblem; + else + abrt_ptr->diag_info = LongTermProblem; + break; + case 3: // application procedure cancellation + temp_flag |= 0x02; + abrt_ptr->user_reason = ApplicationCancel; + switch (dlg_ptr->choice.appproccancel) + { + case 0: + abrt_ptr->diag_info = HandoverCancel; + break; + case 1: + abrt_ptr->diag_info = RadioChannelRelease; + break; + case 2: + abrt_ptr->diag_info = NetworkPathRelease; + break; + case 3: + abrt_ptr->diag_info = CallRelease; + break; + case 4: + abrt_ptr->diag_info = AssociateProcedureFailure; + break; + case 5: + abrt_ptr->diag_info = TandemDialogueRelease; + break; + case 6: + abrt_ptr->diag_info = RemoteOperationFailure; + break; + default: + abrt_ptr->diag_info = RemoteOperationFailure; + break; + } + break; + default: // unknown reason + abrt_ptr->user_reason = ResourceLimite; + break; + } + abrt_ptr->param_flag = temp_flag; +} + +void set_mapuabort_reason(MapDlgUAbort_struct *dlg_ptr,MapUAbort_Arg *abrt_ptr) +{ + switch (abrt_ptr->user_reason) + { + case ProcedureError: + dlg_ptr->choice_flag = 0; + break; + case ResourceLimite: + dlg_ptr->choice_flag = 1; + break; + case ResourceUnavailable: + dlg_ptr->choice_flag = 2; + if (abrt_ptr->diag_info == ShortTermProblem) + dlg_ptr->choice.resunavi = 0; + else + dlg_ptr->choice.resunavi = 1; + break; + case ApplicationCancel: + dlg_ptr->choice_flag = 3; + switch (abrt_ptr->diag_info) + { + case HandoverCancel: + dlg_ptr->choice.appproccancel = 0; + break; + case RadioChannelRelease: + dlg_ptr->choice.appproccancel = 1; + break; + case NetworkPathRelease: + dlg_ptr->choice.appproccancel = 2; + break; + case CallRelease: + dlg_ptr->choice.appproccancel = 3; + break; + case AssociateProcedureFailure: + dlg_ptr->choice.appproccancel = 4; + break; + case TandemDialogueRelease: + dlg_ptr->choice.appproccancel = 5; + break; + case RemoteOperationFailure: + dlg_ptr->choice.appproccancel = 6; + break; + default: + dlg_ptr->choice.appproccancel = 6; + break; + } + break; + default: + dlg_ptr->choice_flag = 1; + break; + } +} + +u8 get_mappabort_reason(struct TCPAbort_struct *dlg_ptr,u32 did) +{ + u8 reason=0; + +#if _SUPPORT_ANSI + if (map_check_map_flag(did))//map or cap + { +#endif + switch (dlg_ptr->pabort_reason) + { + case P_Abort_UMT: + reason = ProviderMalfunction; + break; + case P_Abort_UTID: + reason = SupportingReleased; + break; + case P_Abort_BFTP: + reason = ProviderMalfunction; + break; + case P_Abort_RL: + reason = ResourceLimitation; + break; + case P_Abort_ADLG: + reason = ProviderMalfunction; + break; + case P_Abort_NCDP: + reason = VersionIncompatibility; + break; + default: + reason = ProviderMalfunction; + break; + } +#if _SUPPORT_ANSI + } +#endif + +#if _SUPPORT_ANSI + else//is41 + { + switch (dlg_ptr->pabort_reason) + { + case P_Abort_UMT_Ansi: + reason = ProviderMalfunction; + break; + case P_Abort_UTID_Ansi: + reason = SupportingReleased; + break; + case P_Abort_BFTP_Ansi: + reason = ProviderMalfunction; + break; + case P_Abort_RL_Ansi: + reason = ResourceLimitation; + break; + default: + reason = ProviderMalfunction; + break; + } + } +#endif + return reason; +} + +u8 get_xapacn(struct psmvm_data *psm_ptr,struct dlgport_struct *dlg_ptr) +{ +/* daniel */ + switch (psm_ptr->xap_flag) + { + case XAP_MAP_SSN: + if (dlg_ptr->acn_len==0) + { + psm_ptr->acn = 0; + psm_ptr->acn_ver = AC_Version1; + return 1; + } + break; + case XAP_CAP_SSN: + if (dlg_ptr->acn_len==0) + { + psm_ptr->acn = 0; + psm_ptr->acn_ver = 0; + return 1; + } + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + psm_ptr->acn = 0; + psm_ptr->acn_ver = 0; + return 1; +#endif + default://XAP_CAP_SSN or XAP_IS41_SSN + psm_ptr->acn = 0; + psm_ptr->acn_ver = 0; + return 1; + break; + } +/* daniel */ + + +/* daniel + if (dlg_ptr->acn_len==0 && psm_ptr->xap_flag!=XAP_CAP_SSN) + { + psm_ptr->acn = 0; + psm_ptr->acn_ver = AC_Version1; + return 1; + } + daniel */ + + if (dlg_ptr->acn_len != XAP_ACN_LEN) + { + xap_send_error("MAPP receive error length ACN"); + return 0; + } + psm_ptr->acn = dlg_ptr->acn[XAP_ACN_LEN-2]; + psm_ptr->acn_ver = dlg_ptr->acn[XAP_ACN_LEN-1]; + return 1; +} + +void set_xapacn(struct dlgport_struct *dlg_ptr,struct psmvm_data *psm_ptr) +{ + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) + { + dlg_ptr->acn_len = XAP_ACN_LEN; + dlg_ptr->acn[0] = Identified_Organization; + dlg_ptr->acn[1] = ETSI; + dlg_ptr->acn[2] = MobileDomain; + dlg_ptr->acn[3] = GSM_Network; + dlg_ptr->acn[4] = AC_ID; + dlg_ptr->acn[5] = psm_ptr->acn; + dlg_ptr->acn[6] = psm_ptr->acn_ver; + } + else + {//IS41 do not has acn + dlg_ptr->acn_len = 0; +#if _SUPPORT_ANSI + dlg_ptr->confidential_info_len = 0; + dlg_ptr->security_context_len = 0; +#endif + dlg_ptr->user_info_len = 0; + } +} + +u8 get_xapacn_ver(u8 acn,u8 xap_flag) +{ + u32 ii; + + switch (xap_flag) + { + case XAP_MAP_SSN: + for (ii = 0;ii < map_acn_buf.buf_len;ii ++) + { + if (map_acn_buf.acn[ii] == acn) + return map_acn_buf.acn_ver[ii]; + } + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + return 1; +#endif + case XAP_CAP_SSN: + //printf("buflen=%d %d\n",cap_acn_buf.buf_len,cap_acn_buf.acn[0]); + for (ii = 0;ii < cap_acn_buf.buf_len;ii ++) + { + if (cap_acn_buf.acn[ii] == acn) + return cap_acn_buf.acn_ver[ii]; + } + break; + + default: + break; + } + return 0; +} + +u8 check_acname(u8 acn,u8 acn_ver,u8 xap_flag) // check if the AC is supported +{ + u8 temp_ver; + +/* daniel */ + switch (xap_flag) + { + case XAP_MAP_SSN: + if (acn_ver==AC_Version1) + { + return 0; + } + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + return 0; +#endif + case XAP_CAP_SSN: + if (acn_ver==0) + { + return 0; + } + break; + default: + if (acn_ver==AC_Version1 && acn==0) + return 0; + break; + } +/* daniel */ + +/* daniel + if (xap_flag!=XAP_CAP_SSN && acn_ver==AC_Version1 && acn==0) + return 0; + daniel */ + + temp_ver = get_xapacn_ver(acn,xap_flag); + if (temp_ver == 0 && xap_flag != XAP_CAP_SSN) + { + xap_send_error("XAP check unknown ACN :%d,%d",acn,acn_ver); + return 1; + } + if (temp_ver >= acn_ver) + return 0; + else + return 2; +} + +u8 cmp_acname(psmvm_data *psm_ptr,dlgport_struct *dlg_ptr) // compare is AC is changed +{ +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + return 1; +#endif + + if (psm_ptr->xap_flag == XAP_MAP_SSN) + { + if (psm_ptr->acn_ver == AC_Version1) + return 1; + } + + else if (psm_ptr->xap_flag == XAP_CAP_SSN) + { + if (psm_ptr->acn_ver == 0) + {//cap version 1 + return 1; + } + } + + if (dlg_ptr->acn_len != XAP_ACN_LEN) + return 0; + if (dlg_ptr->acn[XAP_ACN_LEN-1] != psm_ptr->acn_ver) + return 0; + if (dlg_ptr->acn[XAP_ACN_LEN-2] != psm_ptr->acn) + return 0; + return 1; +} + +u8 map_get_acnver(SCCP_ADDR *sccp_ptr,u8 acn) +{ + int ii; + u8 *acn_ptr; + + if (GetACNInfo(sccp_ptr,&acn_ptr)<=0) + return 2; // default version is 2 + for (ii = 0;ii < map_acn_buf.buf_len;ii ++) + { + if (map_acn_buf.acn[ii] == acn) + return acn_ptr[ii]; + } + return 2;//default version is 2 +} + +u8 map_set_acnver(SCCP_ADDR *sccp_ptr,u8 acn,u8 acn_ver) +{ // empty, need to fill later + return 0; +} + + +u8 find_oprclass(u8 opr_code,u8 xap_flag) // check operation code and find operation class +{ + u32 ii; + + switch (xap_flag) + { + case XAP_MAP_SSN: + for (ii = 0;ii < map_opr_buf.buf_len;ii++) + { + if (map_opr_buf.opr_code[ii] == opr_code) + return map_opr_buf.opr_class[ii]; // return operation class + } + xap_send_error("MAPP find unknown operation code:%d",opr_code); + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + for (ii = 0;ii < is41_opr_buf.buf_len;ii++) + { + if (is41_opr_buf.opr_code[ii] == opr_code) + return is41_opr_buf.opr_class[ii]; // return operation class + } + xap_send_error("IS41 find unknown operation code:%d",opr_code); + break; +#endif + case XAP_CAP_SSN: + for (ii = 0;ii < cap_opr_buf.buf_len;ii++) + { + if (cap_opr_buf.opr_code[ii] == opr_code) + return cap_opr_buf.opr_class[ii]; // return operation class + } + xap_send_error("CAPP find unknown operation code:%d, buf_len = %d", opr_code, cap_opr_buf.buf_len); + break; + default: + break; + } + + xap_send_error("XAPP can't find operation code: xap_flag=%d", xap_flag); + return 0; // can not find operation +} + +u32 find_oprtimer(u8 opr_code,u8 xap_flag) // find opreation timer +{ + u32 ii; + + switch (xap_flag) + { + case XAP_MAP_SSN: + for (ii = 0;ii < map_opr_buf.buf_len;ii++) + { + if (map_opr_buf.opr_code[ii] == opr_code) + return map_opr_buf.opr_timer[ii]; // return operation class + } + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + for (ii = 0;ii < is41_opr_buf.buf_len;ii++) + { + if (is41_opr_buf.opr_code[ii] == opr_code) + return is41_opr_buf.opr_timer[ii]; // return operation class + } + break; +#endif + case XAP_CAP_SSN: + for (ii = 0;ii < cap_opr_buf.buf_len;ii++) + { + if (cap_opr_buf.opr_code[ii] == opr_code) + return cap_opr_buf.opr_timer[ii]; // return operation class + } + break; + default: + break; + } + + xap_send_error("XAP find unknown operation code:%d",opr_code); + return 0; // can not find operation +} + +u8 map_check_lnkid(u8 opr_code) +{ + switch (opr_code) + { + case RegPasswd: + return 1; + break; + default: + break; + } + return 0; +} + +void set_xap_flag(u32 did,u8 ssn) +{ + int ii; + u8 flag=0; + + for (ii = 0;ii < xap_inter_ptr->regssn_len;ii ++) + { + if (xap_inter_ptr->reg_ssn[ii] == ssn) + { + flag = 1; + break; + } + } + if (flag == 0) + { + xap_send_error("Can not find SSN=%d in xap provider",ssn); + return; + } + xap_vm_ptr->xap_data[did].psm_data.xap_flag = xap_inter_ptr->regssn_flag[ii]; +} + +u8 send_SSBeginSubActy(struct MapOpen_Arg *open_ptr , struct MapOprSrv_struct *srv_ptr) +{ + struct MapOprData_struct data_ptr; + struct MapBSA_Arg *bsa; + struct TCInvoke_struct *inv_ptr; + u8 data_flow[MAX_MAPPOPR_LEN]; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct CSLcmp_struct csl_cmp; + + u8 buf[4096]; + int len; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[srv_ptr->dialogue_id]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + bsa = (struct MapBSA_Arg *)&srv_ptr->msg_list.bsa_arg; + bsa->param_flag = 0; + + if (open_ptr->param_flag & 0x04) // has peer ref + { + bsa->param_flag |= 0x01; + if(open_ptr->peerref_len == 9 ) + { + memcpy(bsa->imsi,open_ptr->peer_reference,open_ptr->peerref_len); + } + else + { + xap_send_error("XAPP peer reference lenght err while SS MAP V1"); + return 0; + } + } + + if ((open_ptr->param_flag |= 0x10)) // has local ref + { + bsa->param_flag |= 0x02; + bsa->orgenty_num_len = open_ptr->localref_len; + memcpy(bsa->orgenty_num,open_ptr->local_reference,open_ptr->localref_len); + } + + data_ptr.port_id = srv_ptr->port_id; + data_ptr.dialogue_id = srv_ptr->dialogue_id; + data_ptr.invoke_id = srv_ptr->invoke_id; + data_ptr.message_type = srv_ptr->message_type; + data_ptr.message_flag = srv_ptr->message_flag; + data_ptr.param_flag = 0x1f; + + len = build_mapparam(srv_ptr,buf); + if (len == 0 || len > MAX_MAPPOPR_LEN) + { + return 0; + } + + data_ptr.param_len = len; + memcpy(data_ptr.param,buf,len); + data_ptr.param_flag |= 0x20; + + + map_opr_stof(&data_ptr,data_flow,1); + xap_msg_display(data_flow); + /*if( !map_send_oprdata(data_flow) ) + { + return 0; + } + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[srv_ptr->dialogue_id]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + + psm_ptr->data_count += requesting_ssm(&vm_ptr->recvopr_data,SERVICE_INVOKED,1); + vm_ptr->recvopr_flag = 0; + */ + + inv_ptr = (TCInvoke_struct *) &csl_cmp.cmp_prim.tc_invoke; + csl_cmp.message_type = Invoke; + csl_cmp.message_flag = REQUEST; + csl_cmp.dialogue_id = data_ptr.dialogue_id ; + csl_cmp.invoke_id = data_ptr.invoke_id; + inv_ptr->linkedid_flag = 0; + + inv_ptr->operation_code = data_ptr.message_type; + inv_ptr->parameter_len = 0; + if ((data_ptr.param_flag & 0x20)) // has component portion + { + if (data_ptr.param_len > MAX_TCAPSEND_LEN) + { + xap_send_error("XAPP check the operation %d parameter is to long:%ld",data_ptr.message_type,data_ptr.param_len); + } + else + { + inv_ptr->parameter_len = data_ptr.param_len; + memcpy(inv_ptr->parameter,data_ptr.param,data_ptr.param_len); + } + } + if( (open_ptr->param_flag & 0x08) != 0x08 ) + { + xap_send_error("XAPP check the Open param flag do not include local add while SS MAP V1"); + return 0; + } + else + { + set_xap_flag(data_ptr.dialogue_id,open_ptr->local_add.SSN); + inv_ptr->operation_class = find_oprclass(data_ptr.message_type,psm_ptr->xap_flag); + inv_ptr->timer = find_oprtimer(data_ptr.message_type,psm_ptr->xap_flag); + psm_ptr->opr_class[csl_cmp.invoke_id] = inv_ptr->operation_class; + } + + SendTcapCmp(&csl_cmp); + xap_cmp_display(&csl_cmp); + return 1; + +} + +u8 recv_SSBeginSubActy(u32 did , struct CSLcmp_struct *csl_cmp ,struct MapOpen_Arg *open_ptr ) +{ + struct MapBSA_Arg *bsa; + struct MapOprSrv_struct srv_ptr; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + //u8 data_flow[MAX_MAPPOPR_LEN]; + struct TCInvoke_struct *inv_ptr; + struct MapOprData_struct data_ptr; + + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[did]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + if( !RecvTcapCmp(csl_cmp,did) ) + { + return 0; + } + xap_cmp_display(csl_cmp); + + if( csl_cmp->message_type != Invoke || csl_cmp->cmp_prim.tc_invoke.operation_code != BeginSubAct ) + { + return 2; + } + + //performing_ssm(&csl_cmp,SERVICE_INVOCATION_RECEIVED,0); + inv_ptr = (TCInvoke_struct *) &csl_cmp->cmp_prim.tc_invoke; + data_ptr.port_id = psm_ptr->port_id; + data_ptr.dialogue_id = csl_cmp->dialogue_id; + data_ptr.invoke_id = csl_cmp->invoke_id; + data_ptr.message_type = inv_ptr->operation_code; + data_ptr.message_flag = MAP_INDICATE; + data_ptr.param_flag = 0x1f; + data_ptr.param_len = 0; + + if (inv_ptr->parameter_len != 0) + { + data_ptr.param_len = inv_ptr->parameter_len; + memcpy(data_ptr.param,inv_ptr->parameter,inv_ptr->parameter_len); + data_ptr.param_flag |= 0x20; + } + + if( !(data_ptr.param_flag & 0x20)) // has not parameter + return -1; + + extract_mapparam(&srv_ptr, data_ptr.message_type, + data_ptr.message_flag,data_ptr.param_len,data_ptr.param); + + bsa = (struct MapBSA_Arg *)&srv_ptr.msg_list.bsa_arg; + if( bsa->param_flag != 0x03 ) + { + return -1; + } + + open_ptr->param_flag |= 0x04; + open_ptr->localref_len = IMSI_LEN + 1 ; + memcpy(open_ptr->local_reference,bsa->imsi,open_ptr->localref_len); + + open_ptr->param_flag |= 0x10; + open_ptr->peerref_len = bsa->orgenty_num_len ; + memcpy(open_ptr->peer_reference,bsa->orgenty_num,open_ptr->peerref_len); + + return 1; + +} + +u8 xap_store_open(u8 ssn,u32 did) +{ + int ii,jj; + u8 flag=0; + + for (ii = 0;ii < xap_inter_ptr->regssn_len;ii ++) + { + if (xap_inter_ptr->reg_ssn[ii] == ssn) + { + flag = 1; + break; + } + } + if (flag == 0) + { + xap_send_error("Can not find SSN=%d in xap provider",ssn); + return 0; + } + jj = xap_inter_ptr->open_head[ii]; + if (((jj + 1) % XAP_OPEN_LEN) == xap_inter_ptr->open_tail[ii]) + { + xap_send_error("XAP provider open buffer of ssn: %d has full, did: %d", ssn, did); + return 0; + } + xap_inter_ptr->open_did[ii][jj] = did; + xap_inter_ptr->open_head[ii] = (jj + 1) % XAP_OPEN_LEN; + return 1; +} + +int xapp_send_comdata(struct MapComSrv_struct *com_ptr) +{ + struct xapp_vm_data *vm_ptr; + u32 temp_did; + u8 ssn; + + temp_did = com_ptr->dialogue_id; + if (temp_did >= (xap_vm_ptr->grantdid)) + return 0; + if (com_ptr->message_type == MAP_OPEN && com_ptr->message_flag == MAP_INDICATE) + { // store data in open did buffer + xap_watch_dog(3); + ssn = com_ptr->dlg_list.open_arg.local_add.SSN; + if (!xap_store_open(ssn,temp_did)) + return 0; + } + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[temp_did]; + if (vm_ptr->sendcom_flag == 1) + return 0; + memcpy(&vm_ptr->sendcom_data,com_ptr,sizeof(MapComSrv_struct)); + vm_ptr->sendcom_flag = 1; + xap_watch_dog(5); + return 1; +} + +void xapp_send_openrefuse(u32 pid,u32 did,u8 reason) +{ + struct MapComSrv_struct map_com; + struct MapOpen_Res *mapo_ptr; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + if (did >= (xap_vm_ptr->grantdid)) + return; + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[did]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_CONFIRM; + map_com.port_id = pid; + map_com.dialogue_id = did; + mapo_ptr = (MapOpen_Res *) &map_com.dlg_list.open_res; + mapo_ptr->result = OpenResultRefuse; + mapo_ptr->refuse_reason = reason; + mapo_ptr->param_flag = 0x18; + if (reason == ACNotSupported) + { + mapo_ptr->acn_data.acn = psm_ptr->acn; + mapo_ptr->acn_data.acn_ver = psm_ptr->acn_ver; + mapo_ptr->param_flag |= 0x01; + } + xapp_send_comdata(&map_com); +} + +void xapp_send_pabort(u32 pid,u32 did,u8 reason,u8 source) +{ + struct MapComSrv_struct map_com; + struct MapPAbort_Arg *mappa_ptr; + + map_com.message_type = MAP_P_ABORT; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = pid; + map_com.dialogue_id = did; + mappa_ptr = (MapPAbort_Arg *) &map_com.dlg_list.pabort_arg; + mappa_ptr->provider_reason = reason; + mappa_ptr->source = source; + mappa_ptr->param_flag = 0x03; + xapp_send_comdata(&map_com); +} + +void xapp_send_notice(u32 pid,u32 did,u8 reason) +{ + struct MapComSrv_struct map_com; + + map_com.message_type = MAP_NOTICE; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = pid; + map_com.dialogue_id = did; + map_com.dlg_list.notice_arg.problem = reason; + map_com.dlg_list.notice_arg.param_flag = 0x01; + xapp_send_comdata(&map_com); +} + +void xapp_send_ureject(u32 did,u8 iid,u8 err_type,u8 err_code,u8 xap_flag) +{ + struct CSLcmp_struct csl_cmp; + +#if _SUPPORT_ANSI + if ((xap_flag == XAP_MAP_SSN) || + (xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = U_Reject; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = U_Reject_Ansi; +#endif + csl_cmp.message_flag = REQUEST; + csl_cmp.dialogue_id = did; + csl_cmp.invoke_id = iid; + csl_cmp.cmp_prim.tc_reject.problem_type = err_type; + csl_cmp.cmp_prim.tc_reject.problem_code = err_code; + SendTcapCmp(&csl_cmp); + xap_cmp_display(&csl_cmp); +} + +void xapp_send_uabort(u32 did,u8 reason,u8 dlg_flag,struct dlgport_struct *dlg_ptr,u8 xap_flag) +{ + struct TCUAbort_struct *uabort_ptr; + struct CSLdlg_struct csl_data; + + uabort_ptr = (TCUAbort_struct *) &csl_data.dlg_prim.tc_uabort; +#if _SUPPORT_ANSI + if ((xap_flag == XAP_MAP_SSN) || + (xap_flag == XAP_CAP_SSN)) +#endif + { + csl_data.message_type = U_Abort; + uabort_ptr->dialogue_flag = dlg_flag; + } +#if _SUPPORT_ANSI + else + { + csl_data.message_type = U_Abort_Ansi; + uabort_ptr->dialogue_flag = 0; + } +#endif + csl_data.message_flag = REQUEST; + csl_data.dialogue_id = did; + + uabort_ptr->uabort_reason = reason; + if (dlg_flag) + memcpy(&uabort_ptr->dlg_data,dlg_ptr,sizeof(dlgport_struct)); + else + uabort_ptr->dlg_data.user_info_len = 0; +#if _SUPPORT_ANSI + uabort_ptr->uabort_info_len = 0; + uabort_ptr->dlg_data.security_context_len = 0; + uabort_ptr->dlg_data.confidential_info_len = 0; +#endif + SendTcapDlg(&csl_data); + xap_dlg_display(&csl_data); +} + +u8 performing_ssm(void *data_ptr,u8 flag,u8 level) +{ // fail, return 0;success, return 1; partial data, return 2 + struct CSLcmp_struct *cmp_ptr=NULL; + struct MapOprData_struct *opr_ptr=NULL; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct TCInvoke_struct *inv_ptr; + struct CSLcmp_struct csl_cmp; + struct TCResult_struct *result_ptr; + u32 temp_did; + u8 temp_iid; + u32 temp_class; + u8 temp_result; + u8 default_len; + int param_len,param_site; +//char info_str[1024]; + + if (level == 1) + default_len = MAX_TCAPSEND_LEN_1; + else + default_len = MAX_TCAPSEND_LEN; + if (flag == SERVICE_INVOCATION_RECEIVED) + { + cmp_ptr = (CSLcmp_struct *) data_ptr; + temp_did = cmp_ptr->dialogue_id; + temp_iid = cmp_ptr->invoke_id; + } + else + { + opr_ptr = (MapOprData_struct *) data_ptr; + temp_did = opr_ptr->dialogue_id; + temp_iid = opr_ptr->invoke_id; + } + if (temp_did >= (xap_vm_ptr->grantdid)) + return 0; + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[temp_did]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + switch (psm_ptr->opr_state[temp_iid]) + { + case SSM_IDLE: + if (flag != SERVICE_INVOCATION_RECEIVED) + { + vm_ptr->recvopr_flag = 0; + xap_watch_dog(46); + xap_watch_dog(50); + return 0; + } + temp_class = psm_ptr->opr_class[temp_iid]; + inv_ptr = (TCInvoke_struct *) &cmp_ptr->cmp_prim.tc_invoke; + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.message_type = inv_ptr->operation_code; + vm_ptr->sendopr_data.message_flag = MAP_INDICATE; + vm_ptr->sendopr_data.param_flag = 0x1f; + vm_ptr->sendopr_data.param_len = 0; + if (inv_ptr->parameter_len != 0) + { + vm_ptr->sendopr_data.param_len = inv_ptr->parameter_len; + memcpy(vm_ptr->sendopr_data.param,inv_ptr->parameter,inv_ptr->parameter_len); + vm_ptr->sendopr_data.param_flag |= 0x20; + } + if (inv_ptr->linkedid_flag) + { + vm_ptr->sendopr_data.param_flag |= 0x100; + vm_ptr->sendopr_data.linked_id = inv_ptr->linked_id; + } + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + xap_watch_dog(12); + if (temp_class != OPERATION_CLASS4) + psm_ptr->opr_state[temp_iid] = SSM_WFRESPONSE; + break; + case SSM_WFRESPONSE: // wait for response + if (flag == RESPONSE_ISSUED) + { + csl_cmp.message_flag = REQUEST; + csl_cmp.dialogue_id = temp_did; + csl_cmp.invoke_id = temp_iid; + if (check_mapuerr(opr_ptr,&temp_result)) // find the user error + { + if (temp_result == ResLimit) + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = U_Reject; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = U_Reject_Ansi; +#endif + csl_cmp.cmp_prim.tc_reject.problem_type = Invoke_Problem; + csl_cmp.cmp_prim.tc_reject.problem_code = Invoke_Problem_IR; + } + else + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = U_Error; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = U_Error_Ansi; +#endif + csl_cmp.cmp_prim.tc_uerror.error_type = Local_Error_Code; + csl_cmp.cmp_prim.tc_uerror.error_code = temp_result; +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.cmp_prim.tc_uerror.parameter_len = 0; +#if _SUPPORT_ANSI + else + { + param_len = vm_ptr->recvopr_data.param_len; + csl_cmp.cmp_prim.tc_uerror.parameter_len = param_len; + memcpy(csl_cmp.cmp_prim.tc_uerror.parameter,vm_ptr->recvopr_data.param,param_len); + } +#endif + xap_send_error("XAP ==> TCAP User Error. Operation Code=%d, Error Code=%d", psm_ptr->opr_code[temp_iid], Local_Error_Code); + } + vm_ptr->recvopr_flag = 0; + xap_watch_dog(46); + xap_watch_dog(51); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + } + else + { /* +++ the linked request operation is not support +++ */ + result_ptr = (TCResult_struct *) &csl_cmp.cmp_prim.tc_result; +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + { + result_ptr->operation_domain = XAPP_PRIVATE_TCAP; + result_ptr->operation_family = XAPP_OPER_FAMILY; + } +#endif + result_ptr->operation_code = psm_ptr->opr_code[temp_iid]; + result_ptr->parameter_len = 0; + if (vm_ptr->recvopr_flag==2) // send partial data + { + param_site = vm_ptr->recvopr_site; + if (param_site+default_len >= vm_ptr->recvopr_data.param_len) // send result last + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = Result_L; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = Result_L_Ansi; +#endif + result_ptr->parameter_len = vm_ptr->recvopr_data.param_len-param_site; + memcpy(result_ptr->parameter,vm_ptr->recvopr_data.param+param_site,result_ptr->parameter_len); + result_ptr->operation_flag = 1; + vm_ptr->recvopr_site = 0; + vm_ptr->recvopr_flag = 0; // clear the recvopr flag + xap_watch_dog(46); + xap_watch_dog(52); + } + else // send result not last + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = Result_NL; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = Result_NL_Ansi; +#endif + result_ptr->parameter_len = default_len; + memcpy(result_ptr->parameter,vm_ptr->recvopr_data.param+param_site,default_len); + result_ptr->operation_flag = 1; + vm_ptr->recvopr_site += default_len; + } + } + else + { + param_len = vm_ptr->recvopr_data.param_len; + if (param_len <= default_len) // can send in one packet + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = Result_L; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = Result_L_Ansi; +#endif + result_ptr->parameter_len = param_len; + memcpy(result_ptr->parameter,vm_ptr->recvopr_data.param,param_len); + if (param_len == 0) + result_ptr->operation_flag = 0; + else + result_ptr->operation_flag = 1; + vm_ptr->recvopr_flag = 0; + xap_watch_dog(46); + xap_watch_dog(53); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + } + else // long data,need split it + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = Result_NL; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = Result_NL_Ansi; +#endif + result_ptr->parameter_len = default_len; + memcpy(result_ptr->parameter,vm_ptr->recvopr_data.param,default_len); + result_ptr->operation_flag = 1; + vm_ptr->recvopr_site = default_len; + vm_ptr->recvopr_flag = 2; + } + } + } + SendTcapCmp(&csl_cmp); + xap_cmp_display(&csl_cmp); + } + else if (flag == GUARD_TIMER) + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + else if (flag == TERMINATED) + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + default: + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + } + return 1; +} + +u8 requesting_ssm(void *data_ptr,u8 flag,u8 level) +{ + struct CSLcmp_struct *cmp_ptr=NULL; + struct MapOprData_struct *opr_ptr=NULL; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct CSLcmp_struct csl_cmp; + struct TCInvoke_struct *inv_ptr; + struct TCResult_struct *result_ptr; + struct TCReject_struct *rej_ptr; + u32 temp_did; + u8 temp_iid; + int param_len; + u8 default_len; + u8 result=0; + + + + if (flag == SERVICE_INVOKED) + { + opr_ptr = (MapOprData_struct *) data_ptr; + temp_did = opr_ptr->dialogue_id; + temp_iid = opr_ptr->invoke_id; + } + else + { + cmp_ptr = (CSLcmp_struct *) data_ptr; + temp_did = cmp_ptr->dialogue_id; + temp_iid = cmp_ptr->invoke_id; + } + + if (temp_did >= (xap_vm_ptr->grantdid)) + { + xap_send_error("requesting_ssm: temp_did >= grantdid\r\n"); + return 0; + } + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[temp_did]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + + if( psm_ptr->acn_ver == 1 ) + default_len = MAX_TCAPSEND_LEN_1; + else if (level == 1) + default_len = MAX_TCAPSEND_LEN_1; + else + default_len = MAX_TCAPSEND_LEN; + + switch (psm_ptr->opr_state[temp_iid]) + { + case SSM_IDLE: + if (flag != SERVICE_INVOKED) + { + xap_send_error("requesting_ssm: flag != INVOKED"); + return 0; + } + inv_ptr = (TCInvoke_struct *) &csl_cmp.cmp_prim.tc_invoke; +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_cmp.message_type = Invoke; +#if _SUPPORT_ANSI + else + csl_cmp.message_type = Invoke_L_Ansi; +#endif + csl_cmp.message_flag = REQUEST; + csl_cmp.dialogue_id = temp_did; + csl_cmp.invoke_id = temp_iid; + if ((opr_ptr->param_flag & 0x100)) // has linked_id + { + inv_ptr->linkedid_flag = 1; + inv_ptr->linked_id = opr_ptr->linked_id; + } + else + inv_ptr->linkedid_flag = 0; +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + { + inv_ptr->operation_domain = XAPP_PRIVATE_TCAP;//0=national,1=private + inv_ptr->operation_family = XAPP_OPER_FAMILY; + } +#endif + inv_ptr->operation_code = opr_ptr->message_type; + inv_ptr->parameter_len = 0; + if ((opr_ptr->param_flag & 0x20)) // has component portion + { + if (opr_ptr->param_len > default_len) + { + xap_send_error("XAPP check the operation %d parameter is too long:%ld",opr_ptr->message_type,opr_ptr->param_len); + } + else + { + inv_ptr->parameter_len = opr_ptr->param_len; + memcpy(inv_ptr->parameter,opr_ptr->param,opr_ptr->param_len); + } + } + inv_ptr->operation_class = find_oprclass(opr_ptr->message_type,psm_ptr->xap_flag); + inv_ptr->timer = find_oprtimer(opr_ptr->message_type,psm_ptr->xap_flag); + psm_ptr->opr_class[temp_iid] = inv_ptr->operation_class; + if (inv_ptr->operation_class != OPERATION_CLASS4) + { + psm_ptr->opr_state[temp_iid] = SSM_WFCONFIRM; + psm_ptr->opr_code[temp_iid] = opr_ptr->message_type; + } + SendTcapCmp(&csl_cmp); + xap_cmp_display(&csl_cmp); + vm_ptr->recvopr_flag = 0; + xap_watch_dog(46); + xap_watch_dog(54); + break; + case SSM_WFCONFIRM: + switch (flag) + { + case RESULT_RECEIVED: + result_ptr = (TCResult_struct *) &cmp_ptr->cmp_prim.tc_result; + param_len = result_ptr->parameter_len; + if (vm_ptr->sendopr_flag == 2) // has exist partial data + { + if (vm_ptr->sendopr_data.invoke_id == temp_iid) + { + if (param_len+vm_ptr->sendopr_data.param_flag > MAX_MAPPOPR_LEN) + { + xap_send_error("XAPP received result last data is too long"); + xapp_send_ureject(temp_did,temp_iid,Return_Result,Return_Result_MP,psm_ptr->xap_flag); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + return 0; + } + memcpy(vm_ptr->sendopr_data.param+vm_ptr->sendopr_data.param_len,result_ptr->parameter,param_len); + vm_ptr->sendopr_data.param_len += param_len; + vm_ptr->sendopr_data.param_flag |= 0x20; + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + xap_watch_dog(13); + } + else + { + xap_send_error("XAPP received result last with wrong iid"); + xapp_send_ureject(temp_did,temp_iid,Return_Result,Return_Result_RRU,psm_ptr->xap_flag); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + return 0; + } + } + else + { + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.param_flag = 0x1f; + memcpy(vm_ptr->sendopr_data.param,result_ptr->parameter,param_len); + vm_ptr->sendopr_data.param_len = param_len; + if (param_len != 0) + vm_ptr->sendopr_data.param_flag |= 0x20; + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + xap_watch_dog(14); + } + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + case PARTIAL_RESULT_RECEIVED: + result_ptr = (TCResult_struct *) &cmp_ptr->cmp_prim.tc_result; + param_len = result_ptr->parameter_len; + if (vm_ptr->sendopr_flag == 0) // has not exist partial data + { + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.param_flag = 0x1f; + memcpy(vm_ptr->sendopr_data.param,result_ptr->parameter,param_len); + vm_ptr->sendopr_data.param_len = param_len; + if (param_len != 0) + vm_ptr->sendopr_data.param_flag |= 0x20; + vm_ptr->sendopr_flag = 2; + } + else + { + if (vm_ptr->sendopr_data.invoke_id == temp_iid) + { + memcpy(vm_ptr->sendopr_data.param+vm_ptr->sendopr_data.param_len,result_ptr->parameter,param_len); + vm_ptr->sendopr_data.param_len += param_len; + vm_ptr->sendopr_flag = 2; + } + else // the buffer is used by other invoke id + { + xap_send_error("receive partial result with wrong iid"); + xapp_send_ureject(temp_did,temp_iid,Return_Result,Return_Result_RRU,psm_ptr->xap_flag); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + return 0; + } + } + break; + case NEGATIVE_RESULT_RECEIVED: + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.param_flag = 0x1f; + set_mapuerr(&vm_ptr->sendopr_data,cmp_ptr->cmp_prim.tc_uerror.error_code); // set user error + xap_send_error("XAPP <== TCAP User Error. did=%d, iid=%d, oCode=0x%02X, errCode=%d", temp_did, temp_iid, vm_ptr->sendopr_data.message_type, cmp_ptr->cmp_prim.tc_uerror.error_code); + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + xap_watch_dog(15); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + case LINKED_REQUEST_RECEIVED: + break; + case LINKED_SERVICE_INVOKED: + break; + case USER_REJECT_RECEIVED: + rej_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.param_flag = 0x1f; + if (rej_ptr->problem_code == Invoke_Problem_DIID) + result = DupInvokeId; + else if (rej_ptr->problem_code == Invoke_Problem_UO) + result = SrvNotSupport; + else + result = MistypeParam; + set_mapperr(&vm_ptr->sendopr_data,result); // set provider error + xap_send_error("XAPP <== TCAP User Reject. did=%d, iid=%d, oCode=0x%02X, Problem=%d", temp_did, temp_iid, vm_ptr->sendopr_data.message_type, rej_ptr->problem_code); + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + case PROVIDER_REJECT_RECEIVED: + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.param_flag = 0x1f; + set_mapperr(&vm_ptr->sendopr_data,UnexpResFromPeer); // set provider error + xap_send_error("XAPP <== TCAP Provider Reject. did=%d, iid=%d, oCode=0x%02X", temp_did, temp_iid, vm_ptr->sendopr_data.message_type); + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + case TIMER_EXPIRY: + switch (psm_ptr->opr_class[temp_iid]) + { + case OPERATION_CLASS1: + case OPERATION_CLASS3: + vm_ptr->sendopr_data.message_type = psm_ptr->opr_code[temp_iid]; + vm_ptr->sendopr_data.message_flag = MAP_CONFIRM; + vm_ptr->sendopr_data.port_id = psm_ptr->port_id; + vm_ptr->sendopr_data.dialogue_id = temp_did; + vm_ptr->sendopr_data.invoke_id = temp_iid; + vm_ptr->sendopr_data.param_flag = 0x1f; + set_mapperr(&vm_ptr->sendopr_data,UnexpResFromPeer); // set provider error + xap_send_error("XAPP <== TCAP Timer Expired. did=%d, iid=%d, oCode=0x%02X, Class=%d", temp_did, temp_iid, vm_ptr->sendopr_data.message_type, psm_ptr->opr_class[temp_iid]); + vm_ptr->sendopr_flag = 1; + xap_watch_dog(10); + break; + default: + break; + } + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + case TERMINATED: + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + default: + break; + } + break; + default: + psm_ptr->opr_state[temp_iid] = SSM_IDLE; + break; + } + return 1; +} + +u8 process_components(struct CSLcmp_struct *cmp_ptr,u32 proc) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct TCInvoke_struct *inv_ptr; + struct TCReject_struct *rej_ptr; + u32 temp_did; + u8 temp_iid; + u8 result_flag; + + temp_did = cmp_ptr->dialogue_id; + temp_iid = cmp_ptr->invoke_id; + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[temp_did]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + switch (cmp_ptr->message_type) + { + case Invoke: +#if _SUPPORT_ANSI + case Invoke_L_Ansi: +#endif + inv_ptr = (TCInvoke_struct *) &cmp_ptr->cmp_prim.tc_invoke; + if (inv_ptr->linkedid_flag == 0) + { + result_flag = find_oprclass(inv_ptr->operation_code,psm_ptr->xap_flag); + if (result_flag == 0) // can not find operation code + { + xap_send_error("process_components: can not find operation code"); + xapp_send_ureject(temp_did,temp_iid,Invoke_Problem,Invoke_Problem_UO,psm_ptr->xap_flag); + } + else + { + psm_ptr->opr_class[temp_iid] = result_flag; // store operation class + psm_ptr->opr_code[temp_iid] = inv_ptr->operation_code; + performing_ssm(cmp_ptr,SERVICE_INVOCATION_RECEIVED,0); + } + } + else + { + if (!check_iid(temp_did,inv_ptr->linked_id)) + { + if (psm_ptr->opr_state[inv_ptr->linked_id] != SSM_IDLE) + { + xap_send_error("receive Invoke with wrong link id"); + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + xapp_send_ureject(temp_did,inv_ptr->linked_id,Invoke_Problem,Invoke_Problem_ULID,psm_ptr->xap_flag); + } + } + else + { + if (psm_ptr->opr_class[inv_ptr->linked_id] == OPERATION_CLASS4) + requesting_ssm(cmp_ptr,LINKED_REQUEST_RECEIVED,0); + else + { + requesting_ssm(cmp_ptr,LINKED_SERVICE_INVOKED,0); + result_flag = find_oprclass(inv_ptr->operation_code,psm_ptr->xap_flag); + if (result_flag == 0) // can not find operation code + { + xap_send_error("process_components: can not find operation code 2"); + xapp_send_ureject(temp_did,temp_iid,Invoke_Problem,Invoke_Problem_UO,psm_ptr->xap_flag); + } + else + { + psm_ptr->opr_class[temp_iid] = result_flag; // store operation class + psm_ptr->opr_code[temp_iid] = inv_ptr->operation_code; + performing_ssm(cmp_ptr,SERVICE_INVOCATION_RECEIVED,0); + } + } + } + } + break; + case Result_L: +#if _SUPPORT_ANSI + case Result_L_Ansi: +#endif + if (!check_iid(temp_did,temp_iid)) + { + xap_send_error("received Result_L without correspond Invoke id"); + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + xapp_send_ureject(temp_did,temp_iid,Return_Result,Return_Result_UIID,psm_ptr->xap_flag); + } + else + requesting_ssm(cmp_ptr,RESULT_RECEIVED,0); + break; + case Result_NL: +#if _SUPPORT_ANSI + case Result_NL_Ansi: +#endif + if (!check_iid(temp_did,temp_iid)) + { + xap_send_error("received Result_NL without correspond Invoke id"); + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + xapp_send_ureject(temp_did,temp_iid,Return_Result,Return_Result_UIID,psm_ptr->xap_flag); + } + else + requesting_ssm(cmp_ptr,PARTIAL_RESULT_RECEIVED,0); + break; + case U_Error: +#if _SUPPORT_ANSI + case U_Error_Ansi: +#endif + if (!check_iid(temp_did,temp_iid)) + { + xap_send_error("received U_Error without correspond Invoke id"); + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + xapp_send_ureject(temp_did,temp_iid,Return_Error,Return_Error_UIID,psm_ptr->xap_flag); + } + else + requesting_ssm(cmp_ptr,NEGATIVE_RESULT_RECEIVED,0); + break; + case U_Reject: +#if _SUPPORT_ANSI + case U_Reject_Ansi: +#endif + rej_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + if (rej_ptr->problem_type == Invoke_Problem) + { + if (!check_iid(temp_did,temp_iid)) + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + else + requesting_ssm(cmp_ptr,USER_REJECT_RECEIVED,0); + } + else + xapp_send_notice(psm_ptr->port_id,temp_did,ResponseRejected); + break; + case R_Reject: +#if _SUPPORT_ANSI + case R_Reject_Ansi: +#endif + rej_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + if (rej_ptr->problem_type == Invoke_Problem) + { + if (!check_iid(temp_did,temp_iid)) + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventReceived); + else + requesting_ssm(cmp_ptr,PROVIDER_REJECT_RECEIVED,0); // there is not identify with protocol + } + else + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventDetect); + break; + case L_Reject: +#if _SUPPORT_ANSI + case L_Reject_Ansi: +#endif + rej_ptr = (TCReject_struct *) &cmp_ptr->cmp_prim.tc_reject; + if (rej_ptr->problem_type == Invoke_Problem) + { + if (!check_iid(temp_did,temp_iid)) + xapp_send_notice(psm_ptr->port_id,temp_did,MessageNotDelivered); + else + requesting_ssm(cmp_ptr,PROVIDER_REJECT_RECEIVED,0); + } + else + xapp_send_notice(psm_ptr->port_id,temp_did,AbnormalEventDetect); + break; + default: + break; + } + if (cmp_ptr->last_flag == 1) + return 1; + return 0; +} + +int include_dialogue(u32 proc) +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + + switch (psm_ptr->xap_flag) + { + case XAP_MAP_SSN: + if (psm_ptr->acn_ver>AC_Version1) + return 1;//map version 2 and map version 3 include dialogue portion + break; + case XAP_CAP_SSN: + if (psm_ptr->acn_ver>0) + return 1; + break; +#if _SUPPORT_ANSI + case XAP_IS41_SSN: + return 1;//is41 do not has dialogue portion +#endif + default: + break; + } + + return 0; +} + + +int wfur_program(u32 proc) // wait for user requests +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapOpen_Arg *open_ptr; + struct MapDlg_struct map_dlg; + struct MapDlgOpen_struct *dlg_open; + struct TCBegin_struct *begin_ptr; + struct CSLdlg_struct csl_data; + struct dlgport_struct tcap_dlg; + u8 ss_mapv1_flag=0; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + if (vm_ptr->recvopr_flag != 0 && !(psm_ptr->acn_ver == 1 && psm_ptr->acn == AC_networkFunctionalSs)) // has components + { + psm_ptr->data_count += requesting_ssm(&vm_ptr->recvopr_data,SERVICE_INVOKED,0); + vm_ptr->recvopr_flag = 0; + } + else + { + + if (psm_ptr->delimiter_flag == 1) + { + if (vm_ptr->recvcom_data.message_type != MAP_OPEN) // reqeust open a dialogue + { + xap_watch_dog(62); + return -1; + } + + open_ptr = (MapOpen_Arg *) &vm_ptr->recvcom_data.dlg_list.open_arg; + begin_ptr = (TCBegin_struct *) &csl_data.dlg_prim.tc_begin; + +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + csl_data.message_type = Query_WithPerm_Ansi; + else +#endif + csl_data.message_type = Begin; + begin_ptr->dialogue_flag = include_dialogue(proc); + + csl_data.message_flag = REQUEST; + csl_data.dialogue_id = proc; + + memcpy(&begin_ptr->peer_add,&open_ptr->peer_add,sizeof(SCCP_ADDR)); + memcpy(&begin_ptr->local_add,&open_ptr->local_add,sizeof(SCCP_ADDR)); + + if( psm_ptr->acn_ver == 1 && psm_ptr->acn == AC_networkFunctionalSs ) + { + if ((open_ptr->param_flag & 0x14) == 0x14 ) // has reference + { + begin_ptr->dlg_data.user_info_len = 0; + ss_mapv1_flag = 1; + } + } + else if ((open_ptr->param_flag & 0x14)) // has reference + { + map_dlg.dlg_type = MAPDLG_OPEN; + dlg_open = (MapDlgOpen_struct *) &map_dlg.map_dlg.map_open; + dlg_open->param_flag = 0; + if ((open_ptr->param_flag & 0x04) ) + { + if( open_ptr->peerref_len <= ISDN_LEN+1 ) // has peer ref + { + dlg_open->param_flag |= 0x01; + dlg_open->peer_ref[0] = open_ptr->peerref_len; + memcpy(dlg_open->peer_ref+1,open_ptr->peer_reference,open_ptr->peerref_len); + } + else + { + xap_send_error("dlg open peerref is too long :%d \r\n" , open_ptr->peerref_len ); + } + } + if ((open_ptr->param_flag |= 0x10) ) + { + if( open_ptr->localref_len <= ISDN_LEN+1) // has local ref + { + dlg_open->param_flag |= 0x02; + dlg_open->local_ref[0] = open_ptr->localref_len; + memcpy(dlg_open->local_ref+1,open_ptr->local_reference,open_ptr->localref_len); + } + else + { + xap_send_error("dlg open localref is too long :%d \r\n" , open_ptr->localref_len ); + } + } + + begin_ptr->dlg_data.user_info_len = build_mapdlg(&map_dlg,begin_ptr->dlg_data.user_info); + } + else + begin_ptr->dlg_data.user_info_len = 0; + +#if _SUPPORT_ANSI + begin_ptr->dlg_data.security_context_len = 0; + begin_ptr->dlg_data.confidential_info_len = 0; +#endif + /* ++++ not support the specific information +++ */ + if( ss_mapv1_flag ) + { + struct MapOprSrv_struct srv_ptr; + + srv_ptr.port_id = psm_ptr->port_id; + srv_ptr.dialogue_id = proc; + srv_ptr.invoke_id = map_get_invokeid(proc); + srv_ptr.message_type = BeginSubAct; + srv_ptr.message_flag = MAP_REQUEST; + + begin_ptr->dlg_data.user_info_len = 0; + send_SSBeginSubActy( open_ptr , &srv_ptr); + psm_ptr->data_count++; + if (vm_ptr->recvopr_flag != 0 && (psm_ptr->acn_ver == 1 && psm_ptr->acn == AC_networkFunctionalSs)) // has components + { + psm_ptr->data_count += requesting_ssm(&vm_ptr->recvopr_data,SERVICE_INVOKED,0); + vm_ptr->recvopr_flag = 0; + } + } + begin_ptr->component_present = psm_ptr->data_count; + psm_ptr->data_count = 0; + + if( psm_ptr->acn_ver == 1 && psm_ptr->xap_flag != XAP_CAP_SSN) + psm_ptr->acn = 0; + + set_xapacn(&begin_ptr->dlg_data,psm_ptr); + + SendTcapDlg(&csl_data); + xap_watch_dog(4); + xap_dlg_display(&csl_data); + + psm_ptr->delimiter_flag = 0; +// psm_ptr->msg_type = 0; +// psm_ptr->msg_flag = 0; +// vm_ptr->recvcom_flag = 0; + return 1; + } + else if (psm_ptr->msg_type == MAP_U_ABORT && psm_ptr->msg_flag == MAP_REQUEST) + { + tcap_dlg.acn_len = 0; + map_dlg.dlg_type = MAPDLG_UABORT; + set_mapuabort_reason(&map_dlg.map_dlg.map_uabort,&vm_ptr->recvcom_data.dlg_list.uabort_arg); + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(30); + return -1; + } + } + return 0; +} + +int wfcbi_program(u32 proc) // wait for check begin indicate +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct CSLdlg_struct *tcap_ptr; + struct TCBegin_struct *begin_ptr; + struct dlgport_struct *dlg_ptr; + struct MapDlg_struct *map_dlg; + struct MapDlgOpen_struct *dlg_open; + struct CSLcmp_struct csl_cmp; + struct MapComSrv_struct map_com; + struct MapOpen_Arg *open_ptr; + struct dlgport_struct tcap_dlg; + u8 result; + u32 temp_flag=0; + u8 mapv1_ss_flag=0; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + tcap_ptr = (CSLdlg_struct *) &vm_ptr->tcap_data; + begin_ptr = (TCBegin_struct *) &tcap_ptr->dlg_prim.tc_begin; + dlg_ptr = (dlgport_struct *) &begin_ptr->dlg_data; + map_dlg = (MapDlg_struct *) &vm_ptr->map_dlg; + switch (psm_ptr->sub_state1) + { + case 0: + if (begin_ptr->dialogue_flag == 0) + dlg_ptr->acn_len = 0; + result = get_xapacn(psm_ptr,dlg_ptr); + if( psm_ptr->acn == 0 && psm_ptr->acn_ver == AC_Version1 && begin_ptr->component_present == 0) + { + map_dlg->dlg_type = MAPDLG_PABORT; + map_dlg->map_dlg.map_pabort.reason = abnormaldial; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("wait for check begin indicate: MAP V1 operation must send TC_Begin with component!\n", psm_ptr->xap_flag, psm_ptr->acn_ver); + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + + if (result == 0) + { + map_dlg->dlg_type = MAPDLG_PABORT; + map_dlg->map_dlg.map_pabort.reason = abnormaldial; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("wait for check begin indicate: ACN not Supported. xap_flag=%d Version=%d", psm_ptr->xap_flag, psm_ptr->acn_ver); + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + else + { + if (dlg_ptr->user_info_len != 0) // include user information + { + if ((!extract_mapdlg(map_dlg,dlg_ptr)) || (map_dlg->dlg_type != MAPDLG_OPEN)) + { + map_dlg->dlg_type = MAPDLG_PABORT; + map_dlg->map_dlg.map_pabort.reason = abnormaldial; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(map_dlg,tcap_dlg.user_info); + +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("wait for check begin indicate: abnormal dialogue"); + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + else + psm_ptr->sub_state1 = 2; + } + else + { + if (psm_ptr->acn == AC_networkFunctionalSs || psm_ptr->acn == AC_networkUnstructuredSs) + { + map_dlg->dlg_type = MAPDLG_PABORT; + map_dlg->map_dlg.map_pabort.reason = abnormaldial; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("wait for check begin indicate: User information can't be absent in dialogue for AC_networkFunctionalSs"); + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + else + psm_ptr->sub_state1 = 2; + } + } + break; + case 1: // wait for init data + if (vm_ptr->sendopr_flag == 0) // can receive operation data + { + if (RecvTcapCmp(&csl_cmp,proc)) + {/* +++ do not derive the version 1 of AC +++ */ + xap_send_error("wait for check begin indicate: AC not include 2"); + xap_cmp_display(&csl_cmp); + xapp_send_uabort(proc,UABORT_NULL,0,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + } + break; + case 2: // wait for load check result1 + open_ptr = (MapOpen_Arg *) &map_com.dlg_list.open_arg; + if( psm_ptr->acn_ver == AC_Version1 && begin_ptr->component_present > 0 ) //check if map v1 SS + { + result = recv_SSBeginSubActy( proc , &csl_cmp, open_ptr ); + switch( result ) + { + case 1: + mapv1_ss_flag = 1; //map v1 ss + break; + case 2: + mapv1_ss_flag = 2; // map v1 not ss + break; + default: + map_dlg->dlg_type = MAPDLG_PABORT; + map_dlg->map_dlg.map_pabort.reason = invalidPDU; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("MAP V1 SS wait for beginSubActivity fail xap_flag=%d Version=%d", psm_ptr->xap_flag, psm_ptr->acn_ver); + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + break; + } + } + + result = check_acname(psm_ptr->acn,psm_ptr->acn_ver,psm_ptr->xap_flag); + if (result==0) // AC is supported + { + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = 0; // need deside by map user + map_com.dialogue_id = proc; + open_ptr = (MapOpen_Arg *) &map_com.dlg_list.open_arg; + open_ptr->acn_data.acn = psm_ptr->acn; + open_ptr->acn_data.acn_ver = psm_ptr->acn_ver; + temp_flag = 0x01; + memcpy(&open_ptr->peer_add,&begin_ptr->peer_add,sizeof(SCCP_ADDR)); + temp_flag |= 0x02; + memcpy(&open_ptr->local_add,&begin_ptr->local_add,sizeof(SCCP_ADDR)); + temp_flag |= 0x08; + if( mapv1_ss_flag == 1 ) + { + temp_flag |= 0x14; + } + else if (vm_ptr->map_dlg.dlg_type == MAPDLG_OPEN) // has dlg open + { + dlg_open = (MapDlgOpen_struct *) &map_dlg->map_dlg.map_open; + if (dlg_open->param_flag & 0x01) // has peer reference + { + open_ptr->peerref_len = dlg_open->peer_ref[0]; + memcpy(open_ptr->peer_reference,dlg_open->peer_ref+1,dlg_open->peer_ref[0]); + temp_flag |= 0x04; + } + if (dlg_open->param_flag & 0x02) // has local reference + { + open_ptr->localref_len = dlg_open->local_ref[0]; + memcpy(open_ptr->local_reference,dlg_open->local_ref+1,dlg_open->local_ref[0]); + temp_flag |= 0x10; + } + } + + open_ptr->param_flag = temp_flag; + map_com.component_present = begin_ptr->component_present; + if (xapp_send_comdata(&map_com)) + { + if (begin_ptr->component_present == 1) + { + psm_ptr->sub_state1 = 4; + if(mapv1_ss_flag == 2) + { + if (process_components(&csl_cmp,proc)) + psm_ptr->sub_state1 = 5; + } + } + else + psm_ptr->sub_state1 = 5; +// psm_ptr->sub_state1 = 3; + } + else + { + xap_send_error("wait for check begin indicate: xapp_send_comdata fail"); + xapp_send_uabort(proc,UABORT_NULL,0,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + } + else + { + tcap_dlg.acn_len = dlg_ptr->acn_len; + memcpy(tcap_dlg.acn,dlg_ptr->acn,dlg_ptr->acn_len); + if (result == 2) // acn version not support + tcap_dlg.acn[dlg_ptr->acn_len-1] = get_xapacn_ver(dlg_ptr->acn[dlg_ptr->acn_len-2],psm_ptr->xap_flag); + tcap_dlg.user_info_len = 0; +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xap_send_error("wait for check begin indicate: ACN not Supported. AC=%d Version=%d", psm_ptr->acn, psm_ptr->acn_ver); + xapp_send_uabort(proc,UABORT_ACNNS,1,&tcap_dlg,psm_ptr->xap_flag); + return -1; + } + break; +// case 3: // wait the link response from map user +// if (psm_ptr->msg_type == MAP_LINK) +// { +// psm_ptr->port_id = vm_ptr->recvcom_data.port_id; +// psm_ptr->msg_type = 0; +// psm_ptr->msg_flag = 0; +// vm_ptr->recvcom_flag = 0; +// if (begin_ptr->component_present == 1) +// psm_ptr->sub_state1 = 4; +// else +// psm_ptr->sub_state1 = 5; +// } +// else if (psm_ptr->msg_type == MAP_CLOSE) +// { +// xapp_send_uabort(proc,UABORT_NULL,0,&tcap_dlg,psm_ptr->xap_flag); +// return -1; +// } +// break; + case 4: // process component + if (vm_ptr->sendopr_flag != 1 && vm_ptr->sendcom_flag == 0) + { + if (RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (process_components(&csl_cmp,proc)) + psm_ptr->sub_state1 = 5; + } + } + break; + case 5: // send delimiter primitive + if (vm_ptr->sendcom_flag == 0) + { + map_com.message_type = MAP_DELIMITER; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + xapp_send_comdata(&map_com); + return 1; + } + break; + default: + psm_ptr->sub_state1 = 0; + break; + } + return 0; +} + +int dlginit_program(u32 proc) // dialogue initiated +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct CSLdlg_struct *tcap_ptr; + struct TCContinue_struct *tccon_ptr; + struct dlgport_struct *port_ptr; + struct TCEnd_struct *tcend_ptr; + struct TCUAbort_struct *tcua_ptr; + struct MapComSrv_struct map_com; + struct MapUAbort_Arg *mapua_ptr; + struct MapOpen_Res *mapo_ptr; + struct CSLdlg_struct csl_dlg; + struct CSLcmp_struct csl_cmp; + struct MapDlg_struct map_dlg; + struct dlgport_struct tcap_dlg; + u8 result; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + tcap_ptr = (CSLdlg_struct *) &vm_ptr->tcap_data; + switch (psm_ptr->sub_state1) + { + case 0: + if (vm_ptr->sendcom_flag == 0 && RecvTcapDlg(tcap_ptr,proc)) + { + xap_dlg_display(tcap_ptr); + switch (tcap_ptr->message_type) + { + case Continue: +#if _SUPPORT_ANSI + case Conversation_WithPerm_Ansi: +#endif + tccon_ptr = (TCContinue_struct *) &tcap_ptr->dlg_prim.tc_continue; + port_ptr = (dlgport_struct *) &tccon_ptr->dlg_data; + if (!cmp_acname(psm_ptr,port_ptr)) // AC changed + { + xap_send_error("XAPP <== TCAP TC-Continue(Unexpected Dlg, AC Changed), did=%d", proc); + xapp_send_pabort(psm_ptr->port_id,proc,AbnormalMAPDialogue,MAPProblem); + map_dlg.dlg_type = MAPDLG_PABORT; + map_dlg.map_dlg.map_pabort.reason = abnormaldial; // abnormal dialogue + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->sub_state1 = 5; + } + else + { + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_CONFIRM; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + mapo_ptr = (MapOpen_Res *) &map_com.dlg_list.open_res; + if (tccon_ptr->dialogue_flag == 1 && port_ptr->acn_len != 0) // has acn + { + mapo_ptr->acn_data.acn = psm_ptr->acn; + mapo_ptr->acn_data.acn_ver = psm_ptr->acn_ver; + mapo_ptr->param_flag = 0x01; // indicate thata has acn + } + else + mapo_ptr->param_flag = 0; + mapo_ptr->result = OpenResultAccept; + mapo_ptr->param_flag += 0x08; + xapp_send_comdata(&map_com); + if (tccon_ptr->component_present == 1) + psm_ptr->sub_state1 = 1; + else + return 1; + } + break; + case End: +#if _SUPPORT_ANSI + case Response_Ansi: +#endif + tcend_ptr = (TCEnd_struct *) &tcap_ptr->dlg_prim.tc_end; + port_ptr = (dlgport_struct *) &tcend_ptr->dlg_data; + if (!cmp_acname(psm_ptr,port_ptr)) // AC changed + { + xap_send_error("XAPP <== TCAP TC-End(Unexpected Dlg, AC Changed), did=%d", proc); + xapp_send_pabort(psm_ptr->port_id,proc,AbnormalMAPDialogue,MAPProblem); + psm_ptr->sub_state1 = 5; + } + else + { + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_CONFIRM; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + mapo_ptr = (MapOpen_Res *) &map_com.dlg_list.open_res; + if (tcend_ptr->dialogue_flag == 1 && port_ptr->acn_len != 0) // has acn + { + mapo_ptr->acn_data.acn = psm_ptr->acn; + mapo_ptr->acn_data.acn_ver = psm_ptr->acn_ver; + mapo_ptr->param_flag = 0x01; // indicate thata has acn + } + else + mapo_ptr->param_flag = 0; + mapo_ptr->result = OpenResultAccept; + mapo_ptr->param_flag += 0x08; + xapp_send_comdata(&map_com); + if (tcend_ptr->component_present == 1) + psm_ptr->sub_state1 = 3; + else + psm_ptr->sub_state1 = 4; + } + break; + case U_Abort: +#if _SUPPORT_ANSI + case U_Abort_Ansi: +#endif + tcua_ptr = (TCUAbort_struct *) &tcap_ptr->dlg_prim.tc_uabort; + port_ptr = (dlgport_struct *) &tcua_ptr->dlg_data; + xap_send_error("XAPP <== TCAP U_Abort did=%d Reason=%s", proc, tcap_uabort_desc[tcua_ptr->uabort_reason % 3]); + if (tcua_ptr->uabort_reason == UABORT_SPEC) + { + if (!extract_mapdlg(&map_dlg,port_ptr)) + { + xapp_send_openrefuse(psm_ptr->port_id,proc,PotentialVerIncompat); + psm_ptr->sub_state1 = 5; + } + else + { + if (map_dlg.dlg_type == MAPDLG_UABORT) + { + map_com.message_type = MAP_U_ABORT; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + mapua_ptr = (MapUAbort_Arg *) &map_com.dlg_list.uabort_arg; + get_mapuabort_reason(mapua_ptr,&map_dlg.map_dlg.map_uabort); + xapp_send_comdata(&map_com); + psm_ptr->sub_state1 = 5; + } + else if (map_dlg.dlg_type == MAPDLG_PABORT) + { + xapp_send_pabort(psm_ptr->port_id,proc,AbnormalMAPDialogue,MAPProblem); + psm_ptr->sub_state1 = 5; + } + else if (map_dlg.dlg_type == MAPDLG_REFUSE) + { + switch (map_dlg.map_dlg.map_refuse.reason) + { + case 0: // noReasonGiven + result = NoReasonGiven; + break; + case 1: // invalidDstRef + result = InvalidDesReference; + break; + case 2: // invalidOrgRef + result = InvalidOrgReference; + break; + default: + result = NoReasonGiven; + break; + } + xapp_send_openrefuse(psm_ptr->port_id,proc,result); + psm_ptr->sub_state1 = 5; + } + else + { + xapp_send_openrefuse(psm_ptr->port_id,proc,PotentialVerIncompat); + psm_ptr->sub_state1 = 5; + } + } + } + else if (tcua_ptr->uabort_reason == UABORT_ACNNS) + { + get_xapacn(psm_ptr,&tcua_ptr->dlg_data); + xapp_send_openrefuse(psm_ptr->port_id,proc,ACNotSupported); + psm_ptr->sub_state1 = 5; + } + else + { + xapp_send_openrefuse(psm_ptr->port_id, proc, NoReasonGiven); + psm_ptr->sub_state1 = 5; + } + break; + case P_Abort: +#if _SUPPORT_ANSI + case P_Abort_Ansi: +#endif + xap_send_error("XAPP <== TCAP P_Abort did=%d Reason=%s", proc, tcap_pabort_desc[tcap_ptr->dlg_prim.tc_pabort.pabort_reason & 7]); + if (tcap_ptr->dlg_prim.tc_pabort.pabort_reason == P_Abort_ITP) // incorrect transaction portion + { + xapp_send_openrefuse(psm_ptr->port_id,proc,PotentialVerIncompat); + psm_ptr->sub_state1 = 5; + } + else + { + result = get_mappabort_reason(&tcap_ptr->dlg_prim.tc_pabort,proc); + xapp_send_pabort(psm_ptr->port_id,proc,result,TCProblem); + psm_ptr->sub_state1 = 5; + } + break; + case Notice: + xap_send_error("XAPP <== TCAP Notice did=%d", proc); + xapp_send_openrefuse(psm_ptr->port_id,proc,RemoteNodeNotReachable); + psm_ptr->sub_state1 = 5; + break; + default: + break; + } + } + else + { + if (psm_ptr->msg_type == MAP_U_ABORT && psm_ptr->msg_flag == MAP_REQUEST) + { + map_dlg.dlg_type = MAPDLG_PABORT; + set_mapuabort_reason(&map_dlg.map_dlg.map_uabort,&vm_ptr->recvcom_data.dlg_list.uabort_arg); + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(31); + psm_ptr->sub_state1 = 5; + } + else if (psm_ptr->msg_type == MAP_CLOSE && psm_ptr->msg_flag == MAP_REQUEST) + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_dlg.message_type = End; +#if _SUPPORT_ANSI + else + csl_dlg.message_type = Response_Ansi; +#endif + csl_dlg.message_flag = REQUEST; + csl_dlg.dialogue_id = proc; + tcend_ptr = (TCEnd_struct *) &csl_dlg.dlg_prim.tc_end; + tcend_ptr->dialogue_flag = 0; + tcend_ptr->termination = PRE_END; + SendTcapDlg(&csl_dlg); + xap_dlg_display(&csl_dlg); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(32); + psm_ptr->sub_state1 = 5; + } + else + { + if (vm_ptr->sendcom_flag == 0 && RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (csl_cmp.message_type == L_Cancel) + { + xap_send_error("L_Cancel did=%d", proc); + xapp_send_openrefuse(psm_ptr->port_id,proc,RemoteNodeNotReachable); + } + } + } + } + break; + case 1: // continue process component + if (vm_ptr->sendopr_flag != 1 && vm_ptr->sendcom_flag == 0) + { + if (RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (process_components(&csl_cmp,proc)) + psm_ptr->sub_state1 = 2; + } + } + break; + case 2: // write delimiter + if (vm_ptr->sendcom_flag == 0) + { + map_com.message_type = MAP_DELIMITER; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + xapp_send_comdata(&map_com); + return 1; + } + break; + case 3: // end process component + if (vm_ptr->sendopr_flag != 1 && vm_ptr->sendcom_flag == 0) + { + if (RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (process_components(&csl_cmp,proc)) + psm_ptr->sub_state1 = 4; + } + } + break; + case 4: // write end indicate + if (vm_ptr->sendcom_flag == 0) + { + map_com.message_type = MAP_CLOSE; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + map_com.dlg_list.close_arg.param_flag = 0; + xapp_send_comdata(&map_com); + psm_ptr->sub_state1 = 5; + } + break; + case 5: // terminate PSM&RSM +// performing_ssm(&csl_cmp,TIMER_EXPIRY); +// requesting_ssm(&csl_cmp,TIMER_EXPIRY); + return -1; + break; + default: + psm_ptr->sub_state1 = 0; + break; + } + return 0; +} + +int dlgpend_program(u32 proc) // dialogue pending +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapOpen_Res *open_ptr; + struct MapDlg_struct map_dlg; + struct dlgport_struct tcap_dlg; + struct CSLdlg_struct csl_dlg; + struct TCEnd_struct *tcend_ptr; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + switch (psm_ptr->sub_state1) + { + case 0: + if (psm_ptr->msg_type == MAP_OPEN && psm_ptr->msg_flag == MAP_RESPONSE) + { + psm_ptr->port_id = vm_ptr->recvcom_data.port_id; + open_ptr = (MapOpen_Res *) &vm_ptr->recvcom_data.dlg_list.open_res; + if (open_ptr->result == OpenResultAccept) + {/* +++ do not know how to judge if user info include +++ */ + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(33); + return 1; + } + else + { + xap_send_error("dialogue pending: Negative OPEN_RESPONSE"); + map_dlg.dlg_type = MAPDLG_REFUSE; + map_dlg.map_dlg.map_refuse.reason = 0; // no reason given + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->sub_state1 = 1; + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(34); + } + } + else if (psm_ptr->msg_type == MAP_U_ABORT && psm_ptr->msg_flag == MAP_REQUEST) + { + map_dlg.dlg_type = MAPDLG_UABORT; + set_mapuabort_reason(&map_dlg.map_dlg.map_uabort,&vm_ptr->recvcom_data.dlg_list.uabort_arg); + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(35); + psm_ptr->sub_state1 = 1; + } + else if (psm_ptr->msg_type == MAP_CLOSE && psm_ptr->msg_flag == MAP_REQUEST) + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_dlg.message_type = End; +#if _SUPPORT_ANSI + else + csl_dlg.message_type = Response_Ansi; +#endif + csl_dlg.message_flag = REQUEST; + csl_dlg.dialogue_id = proc; + tcend_ptr = (TCEnd_struct *) &csl_dlg.dlg_prim.tc_end; + tcend_ptr->dialogue_flag = 0; + tcend_ptr->termination = PRE_END; + SendTcapDlg(&csl_dlg); + xap_dlg_display(&csl_dlg); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(36); + psm_ptr->sub_state1 = 1; + } + else if (psm_ptr->msg_type == MAP_LINK) + { + psm_ptr->port_id = vm_ptr->recvcom_data.port_id; + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(37); + } + break; + case 1: +// performing_ssm(&csl_cmp,TIMER_EXPIRY); +// requesting_ssm(&csl_cmp,TIMER_EXPIRY); + return -1; + break; + default: + psm_ptr->sub_state1 = 0; + break; + } + return 0; +} + +int dlgaccp_program(u32 proc) //dialogue accept program +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct CSLdlg_struct csl_dlg; + struct MapDlg_struct map_dlg; + struct MapClose_Arg *mapcls_ptr; + struct TCEnd_struct *tcend_ptr; + struct dlgport_struct tcap_dlg; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + switch (psm_ptr->sub_state1) + { + case 0: + if (vm_ptr->recvopr_flag != 0) + { + if (vm_ptr->recvopr_data.message_flag == MAP_REQUEST) + { + psm_ptr->data_count += requesting_ssm(&vm_ptr->recvopr_data,SERVICE_INVOKED,1); + vm_ptr->recvopr_flag = 0; + } + else if (vm_ptr->recvopr_data.message_flag == MAP_RESPONSE) + psm_ptr->data_count += performing_ssm(&vm_ptr->recvopr_data,RESPONSE_ISSUED,0); + } + else + { + if (psm_ptr->delimiter_flag == 1) + { + csl_dlg.dlg_prim.tc_continue.dialogue_flag = include_dialogue(proc); + +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + csl_dlg.message_type = Conversation_WithPerm_Ansi;//ANSI-Continue + else +#endif + csl_dlg.message_type = Continue; + + + csl_dlg.message_flag = REQUEST; + csl_dlg.dialogue_id = proc; + set_xapacn(&csl_dlg.dlg_prim.tc_continue.dlg_data,psm_ptr); + csl_dlg.dlg_prim.tc_continue.dlg_data.user_info_len = 0; +#if _SUPPORT_ANSI + csl_dlg.dlg_prim.tc_continue.dlg_data.security_context_len = 0; + csl_dlg.dlg_prim.tc_continue.dlg_data.confidential_info_len = 0; +#endif + csl_dlg.dlg_prim.tc_continue.component_present = psm_ptr->data_count; + psm_ptr->data_count = 0; + SendTcapDlg(&csl_dlg); + xap_dlg_display(&csl_dlg); + psm_ptr->delimiter_flag = 0; +// psm_ptr->msg_type = 0; +// psm_ptr->msg_flag = 0; +// vm_ptr->recvcom_flag = 0; + return 1; + } + else if (psm_ptr->msg_type == MAP_CLOSE && psm_ptr->msg_flag == MAP_REQUEST) + { + mapcls_ptr = (MapClose_Arg *) &vm_ptr->recvcom_data.dlg_list.close_arg; + tcend_ptr = (TCEnd_struct *) &csl_dlg.dlg_prim.tc_end; + + tcend_ptr->dialogue_flag = include_dialogue(proc); +#if _SUPPORT_ANSI + if (psm_ptr->xap_flag == XAP_IS41_SSN) + csl_dlg.message_type = Response_Ansi;//ANSI-End + else +#endif + csl_dlg.message_type = End; + + csl_dlg.message_flag = REQUEST; + csl_dlg.dialogue_id = proc; + + set_xapacn(&tcend_ptr->dlg_data,psm_ptr); + tcend_ptr->dlg_data.user_info_len = 0; +#ifdef _SUPPORT_ANSI + tcend_ptr->dlg_data.security_context_len = 0; + tcend_ptr->dlg_data.confidential_info_len = 0; +#endif + if (mapcls_ptr->release_method == NormalRelease) + { + tcend_ptr->termination = BASIC_END; + tcend_ptr->component_present = psm_ptr->data_count; + } + else + tcend_ptr->termination = PRE_END; + psm_ptr->data_count = 0; + SendTcapDlg(&csl_dlg); + xap_dlg_display(&csl_dlg); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(38); + psm_ptr->sub_state1 = 1; + } + else if (psm_ptr->msg_type == MAP_U_ABORT && psm_ptr->msg_flag == MAP_REQUEST) + { + map_dlg.dlg_type = MAPDLG_UABORT; + set_mapuabort_reason(&map_dlg.map_dlg.map_uabort,&vm_ptr->recvcom_data.dlg_list.uabort_arg); + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(39); + psm_ptr->sub_state1 = 1; + } + } + break; + case 1: +// performing_ssm(&csl_cmp,TIMER_EXPIRY); +// requesting_ssm(&csl_cmp,TIMER_EXPIRY); + return -1; + break; + default: + psm_ptr->sub_state1 = 0; + break; + } + return 0; +} + +int dlgestab_program(u32 proc) // dialogue established +{ + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapDlg_struct map_dlg; + struct CSLdlg_struct csl_dlg; + struct CSLdlg_struct *csl_ptr; + struct TCUAbort_struct *tcua_ptr; + struct TCEnd_struct *tcend_ptr; + struct CSLcmp_struct csl_cmp; + struct MapComSrv_struct map_com; + struct dlgport_struct tcap_dlg; + u8 result; + + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + switch (psm_ptr->sub_state1) + { + case 0: + if (vm_ptr->sendcom_flag == 0 && RecvTcapDlg(&csl_dlg,proc)) + { + switch (csl_dlg.message_type) + { + case Continue: +#if _SUPPORT_ANSI + case Conversation_WithPerm_Ansi: +#endif + if (csl_dlg.dlg_prim.tc_continue.component_present == 1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->sub_state1 = 1; + } + break; + case End: +#if _SUPPORT_ANSI + case Response_Ansi: +#endif + if (csl_dlg.dlg_prim.tc_end.component_present == 1) + psm_ptr->sub_state1 = 2; + else + psm_ptr->sub_state1 = 3; + break; + case U_Abort: +#if _SUPPORT_ANSI + case U_Abort_Ansi: +#endif + tcua_ptr = (TCUAbort_struct *) &csl_dlg.dlg_prim.tc_uabort; + xap_send_error("XAPP <== TCAP U_Abort did=%d Reason=%s", proc, tcap_uabort_desc[tcua_ptr->uabort_reason%3]); + if (extract_mapdlg(&map_dlg,&tcua_ptr->dlg_data)) // analyse user info + { + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + if (map_dlg.dlg_type == MAPDLG_UABORT) + { + map_com.message_type = MAP_U_ABORT; + get_mapuabort_reason(&map_com.dlg_list.uabort_arg,&map_dlg.map_dlg.map_uabort); + xapp_send_comdata(&map_com); + } + else if (map_dlg.dlg_type == MAPDLG_PABORT) + xapp_send_pabort(psm_ptr->port_id,proc,AbnormalMAPDialogue,TCProblem); + } + psm_ptr->sub_state1 = 4; + break; + case P_Abort: +#if _SUPPORT_ANSI + case P_Abort_Ansi: +#endif + xap_send_error("XAPP <== TCAP P_Abort did=%d Reason=%s", proc, tcap_pabort_desc[csl_dlg.dlg_prim.tc_pabort.pabort_reason & 7]); + result = get_mappabort_reason(&csl_dlg.dlg_prim.tc_pabort,proc); + xapp_send_pabort(psm_ptr->port_id,proc,result,TCProblem); + psm_ptr->sub_state1 = 4; + break; + case Notice: + xap_send_error("XAPP <== TCAP Notice did=%d", proc); + xapp_send_notice(psm_ptr->port_id,proc,csl_dlg.dlg_prim.tc_notice.report_reason); + break; + default: + break; + } + } + else + { + if (vm_ptr->sendcom_flag == 0 && vm_ptr->sendopr_flag != 1 && RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (csl_cmp.message_type == L_Cancel) + requesting_ssm(&csl_cmp,TIMER_EXPIRY,0); + } + } + if (vm_ptr->recvopr_flag != 0) + { + if (vm_ptr->recvopr_data.message_flag == MAP_REQUEST) + { + psm_ptr->data_count += requesting_ssm(&vm_ptr->recvopr_data,SERVICE_INVOKED,1); + vm_ptr->recvopr_flag = 0; + } + else if (vm_ptr->recvopr_data.message_flag == MAP_RESPONSE) + psm_ptr->data_count += performing_ssm(&vm_ptr->recvopr_data,RESPONSE_ISSUED,1); + } + else + { + if (vm_ptr->tcap_data.message_type != 0) + { + if (SendTcapDlg(&vm_ptr->tcap_data)) + { + xap_dlg_display(&vm_ptr->tcap_data); + if (vm_ptr->recvcom_flag == 1) + xap_watch_dog(41); + vm_ptr->recvcom_flag = 0; + psm_ptr->suspend_timer = 0; +#if _SUPPORT_ANSI + if (vm_ptr->tcap_data.message_type == End || vm_ptr->tcap_data.message_type == U_Abort || + vm_ptr->tcap_data.message_type == Response_Ansi || vm_ptr->tcap_data.message_type == U_Abort_Ansi) +#else + if (vm_ptr->tcap_data.message_type == End || vm_ptr->tcap_data.message_type == U_Abort) +#endif + psm_ptr->sub_state1 = 4; + vm_ptr->tcap_data.message_type = 0; + } + } + else + { + csl_ptr = (CSLdlg_struct *) &vm_ptr->tcap_data; + csl_ptr->message_flag = REQUEST; + csl_ptr->dialogue_id = proc; + if (psm_ptr->delimiter_flag == 1) + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_ptr->message_type = Continue; +#if _SUPPORT_ANSI + else + csl_ptr->message_type = Conversation_WithPerm_Ansi; +#endif + csl_ptr->dlg_prim.tc_continue.dialogue_flag = 0; + csl_ptr->dlg_prim.tc_continue.component_present = psm_ptr->data_count; + psm_ptr->data_count = 0; + psm_ptr->delimiter_flag = 0; +// psm_ptr->msg_type = 0; +// psm_ptr->msg_flag = 0; + } + else if (psm_ptr->msg_type == MAP_CLOSE) + { +#if _SUPPORT_ANSI + if ((psm_ptr->xap_flag == XAP_MAP_SSN) || + (psm_ptr->xap_flag == XAP_CAP_SSN)) +#endif + csl_ptr->message_type = End; +#if _SUPPORT_ANSI + else + csl_ptr->message_type = Response_Ansi; +#endif + tcend_ptr = (TCEnd_struct *) &csl_ptr->dlg_prim.tc_end; + tcend_ptr->dialogue_flag = 0; + if (vm_ptr->recvcom_data.dlg_list.close_arg.release_method == NormalRelease) + { + tcend_ptr->termination = BASIC_END; + tcend_ptr->component_present = psm_ptr->data_count; + } + else + tcend_ptr->termination = PRE_END; + psm_ptr->data_count = 0; + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + } + else if (psm_ptr->msg_type == MAP_U_ABORT) + { + map_dlg.dlg_type = MAPDLG_UABORT; + set_mapuabort_reason(&map_dlg.map_dlg.map_uabort,&vm_ptr->recvcom_data.dlg_list.uabort_arg); + tcap_dlg.acn_len = 0; + tcap_dlg.user_info_len = build_mapdlg(&map_dlg,tcap_dlg.user_info); +#if _SUPPORT_ANSI + tcap_dlg.security_context_len = 0; + tcap_dlg.confidential_info_len = 0; +#endif + xapp_send_uabort(proc,UABORT_SPEC,1,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + + vm_ptr->recvcom_flag = 0; + psm_ptr->suspend_timer = 0; + + psm_ptr->sub_state1 = 4; + vm_ptr->tcap_data.message_type = 0; + } + } + } + break; + case 1: // receive continue component + if (vm_ptr->sendopr_flag != 1 && vm_ptr->sendcom_flag == 0) + { + if (RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (process_components(&csl_cmp,proc)) + { + map_com.message_type = MAP_DELIMITER; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + xapp_send_comdata(&map_com); + psm_ptr->sub_state1 = 0; + } + } + } + break; + case 2: + if (vm_ptr->sendopr_flag != 1 && vm_ptr->sendcom_flag == 0) + { + if (RecvTcapCmp(&csl_cmp,proc)) + { + xap_cmp_display(&csl_cmp); + if (process_components(&csl_cmp,proc)) + psm_ptr->sub_state1 = 3; + } + } + case 3: // send end indicate + if (vm_ptr->sendcom_flag == 0) + { + map_com.message_type = MAP_CLOSE; + map_com.message_flag = MAP_INDICATE; + map_com.port_id = psm_ptr->port_id; + map_com.dialogue_id = proc; + map_com.dlg_list.close_arg.param_flag = 0; + xapp_send_comdata(&map_com); + psm_ptr->sub_state1 = 4; + } + break; + case 4: +// performing_ssm(&csl_cmp,TIMER_EXPIRY); +// requesting_ssm(&csl_cmp,TIMER_EXPIRY); + return 1; + break; + default: + psm_ptr->sub_state1 = 0; + break; + } + return 0; +} + +void xap_fsm() //called per 10ms +{ + register u32 proc; + struct xapp_vm_data *vm_ptr; + struct psmvm_data *psm_ptr; + struct MapOpen_Arg *open_ptr; + struct dlgport_struct tcap_dlg; + int result; + +/* daniel changed on 2005-4-29 */ + xap_vm_ptr->debug_data.watch_dog[0] = 0; +/* daniel changed on 2005-4-29 */ + + xap_monitor(); + for (proc = 1;proc < (xap_vm_ptr->grantdid);proc ++) + { + vm_ptr = (xapp_vm_data *) &xap_vm_ptr->xap_data[proc]; + psm_ptr = (psmvm_data *) &vm_ptr->psm_data; + +/* daniel changed on 2005-4-29 */ + if (psm_ptr->psm_state > XAP_IDLE) + { + xap_vm_ptr->debug_data.watch_dog[0]++; + } +/* daniel changed on 2005-4-29 */ + + switch (psm_ptr->psm_state) + { + case XAP_INIT: + memset(vm_ptr,0,sizeof(xapp_vm_data)); + psm_ptr->psm_state = XAP_IDLE; + break; + case XAP_IDLE: //idle; (USER)==>MAP-OPEN + if (psm_ptr->msg_type == MAP_OPEN && psm_ptr->msg_flag == MAP_REQUEST) + { + open_ptr = (MapOpen_Arg *) &vm_ptr->recvcom_data.dlg_list.open_arg; + psm_ptr->acn = open_ptr->acn_data.acn; // store acn data + psm_ptr->acn_ver = open_ptr->acn_data.acn_ver; + psm_ptr->port_id = vm_ptr->recvcom_data.port_id; + psm_ptr->msg_type = 0; + psm_ptr->msg_flag = 0; + vm_ptr->recvcom_flag = 0; + xap_watch_dog(26); + xap_watch_dog(40); + psm_ptr->psm_state = XAP_WFUR; + xap_watch_dog(1); + } + else if (psm_ptr->msg_type == 0) + { + if (vm_ptr->sendcom_flag == 0) // can send common data + { + if (RecvTcapDlg(&vm_ptr->tcap_data,proc)) + { + if (vm_ptr->tcap_data.message_type == Begin) + { + xap_watch_dog(2); + set_xap_flag(proc,vm_ptr->tcap_data.dlg_prim.tc_begin.local_add.SSN);// mark itu + psm_ptr->psm_state = XAP_WFCBI; + } +#if _SUPPORT_ANSI + else if (vm_ptr->tcap_data.message_type == Query_WithPerm_Ansi) + { + xap_watch_dog(2); + psm_ptr->xap_flag = XAP_IS41_SSN;// mark ansi + psm_ptr->psm_state = XAP_WFCBI; + } +#endif + } + } + } + else + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + break; + case XAP_WFUR: // wait for user requests: (USER)==>Request primitiv/MAP_DELIMITER + result = wfur_program(proc); + if (result == 1) + { + psm_ptr->sub_state1 = 0; + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_INITIATED; + } + else if (result == -1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("wait for user requests: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_WFCBI: // wait for check begin indicate + result = wfcbi_program(proc); + if (result == 1) // return dialogue pending + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_PENDING; + psm_ptr->sub_state1 = 0; + } + else if (result == -1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("wait for check begin indicate: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_DLG_INITIATED: //Continue<==(TCAP) + result = dlginit_program(proc); + if (result == 1) + { + vm_ptr->tcap_data.message_type = 0; + psm_ptr->sub_state1 = 0; + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_ESTABLISHED; + } + else if (result == -1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("DLG_INITIATED: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_DLG_PENDING: + result = dlgpend_program(proc); + if (result == 1) + { + psm_ptr->sub_state1 = 0; + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_ACCEPTED; + } + else if (result == -1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("DLG_PENDING: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_DLG_ACCEPTED: + result = dlgaccp_program(proc); + if (result == 1) + { + vm_ptr->tcap_data.message_type = 0; + psm_ptr->sub_state1 = 0; + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_ESTABLISHED; + } + else if (result == -1) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("DLG_ACCEPTED: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_DLG_ESTABLISHED: + if (dlgestab_program(proc)) + { + psm_ptr->suspend_timer = 0; + psm_ptr->psm_state = XAP_DLG_SUSPEND; + } + if ((psm_ptr->suspend_timer++) >= DLGPEND_TIME * XAPP_TIMERHZ) // timer is expire + { + xap_send_error("DLG_ESTABLISHED: timer expired"); + psm_ptr->psm_state = XAP_DLG_HALT; + } + break; + case XAP_DLG_SUSPEND: + if (vm_ptr->sendcom_flag == 0 && vm_ptr->sendopr_flag == 0) + psm_ptr->psm_state = XAP_INIT; + if ((psm_ptr->suspend_timer++) >= SUSPEND_TIME * XAPP_TIMERHZ/2) // timer is expire + { + psm_ptr->psm_state = XAP_INIT; + } + if(xap_vm_ptr->debug_data.monitor_did == proc) /* clear monitor flag, port0 never used */ + xap_vm_ptr->debug_data.monitor_did = 0; + break; + case XAP_DLG_HALT: + xapp_send_pabort(psm_ptr->port_id,proc,AbnormalMAPDialogue,MAPProblem); + xapp_send_uabort(proc,UABORT_NULL,0,&tcap_dlg,psm_ptr->xap_flag); + psm_ptr->psm_state = XAP_DLG_SUSPEND; + break; + default: + psm_ptr->psm_state = XAP_INIT; + break; + } + } +} + + + + + diff --git a/omc/plat/xapp/src/xap_provider.h b/omc/plat/xapp/src/xap_provider.h new file mode 100644 index 0000000..be0ebb3 --- /dev/null +++ b/omc/plat/xapp/src/xap_provider.h @@ -0,0 +1,182 @@ +/* XAP provider head file */ +/* Written by Liu Zhiguo 2003-08-26 */ +/* Version 1.0 */ +/* -------------------------------- */ + +#include "../../public/src/include/includes.h" +#include "../../public/src/include/pub_fmt.h" +#include "../../sccp/src/include/sccp.h" +#include "../../tcap/src/include/tcap_head.h" +#include "../../tcap/src/include/tcap_public.h" +#include "../../tcap/src/include/tcap_struct.h" +#include "ixap.h" +#include "mapp/map_const.h" +#include "mapp/map_public.h" +#include "mapp/map_code.h" +#include "mapp/map_coding.h" +#include "mapp/is41_code.h" +#include "mapp/map_struct.h" +#include "mapp/map_acn.h" +#include "mapp/map_dlgpdu.h" + +#ifndef _PROVIDER_H +#define _PROVIDER_H + +#define XAP_MAP_SSN 1 // ssn is used for map +#define XAP_CAP_SSN 2 // ssn is used for cap +#define XAP_IS41_SSN 3 // ssn is used for is41 + +#define XAP_VM_KEY 0xa0e00000 +#define XAP_VM_PERM 0664 +#define XAP_INTER_KEY 0xa0f00000 +#define XAP_INTER_PERM 0664 + +#define MAX_XAP_SSN 16 +#define XAP_OPEN_LEN 128 +#define XAP_ACN_LEN 7 // xap acn length +#define XAP_ACN_NUM 50 // acn buffer length +#define XAP_OPR_NUM 80 // operation length + +#define XAP_ASCIN_LEN 1024 +#define XAP_ASCOUT_LEN 4096 +#define XAP_WTDOG_LEN 256 + +#define XAP_INIT 0x00 +#define XAP_IDLE 0x01 +#define XAP_WFUR 0x02 // wait for user requests +#define XAP_WFCBI 0x03 // wait for check begin indicate +#define XAP_DLG_INITIATED 0x05 +#define XAP_DLG_PENDING 0x04 // dialogue pending +#define XAP_DLG_ACCEPTED 0x06 +#define XAP_DLG_ESTABLISHED 0x07 +#define XAP_DLG_SUSPEND 0x08 +#define XAP_DLG_HALT 0x09 + +/* the state of SSM */ +#define SSM_IDLE 0x00 +#define SSM_WFRESPONSE 0x01 // wait for response +#define SSM_WFCONFIRM 0x02 + +/* the flag of requesting map SSM */ +#define SERVICE_INVOKED 0x01 +#define RESULT_RECEIVED 0x02 +#define PARTIAL_RESULT_RECEIVED 0x03 +#define NEGATIVE_RESULT_RECEIVED 0x04 +#define LINKED_REQUEST_RECEIVED 0x05 +#define LINKED_SERVICE_INVOKED 0x06 +#define USER_REJECT_RECEIVED 0x07 +#define PROVIDER_REJECT_RECEIVED 0x08 +#define TIMER_EXPIRY 0x09 +#define TERMINATED 0x0a + +/* the flag of performing map SSM */ +#define SERVICE_INVOCATION_RECEIVED 0x01 +#define RESPONSE_ISSUED 0x02 +#define GUARD_TIMER 0x03 + +#define SUSPEND_TIME 1 +#define DLGPEND_TIME 180 +#define XAPP_TIMERHZ 100 + +#define XAPP_PRIVATE_TCAP 1 +#define XAPP_OPER_FAMILY 9 + +typedef struct xap_acn_info // store info about application context name +{ + u8 buf_len; + u8 acn[XAP_ACN_NUM]; // acn buffer + u8 acn_ver[XAP_ACN_NUM]; // acn version buffer +} xap_acn_info; + +typedef struct xap_opr_info // store info about opration code +{ + u8 buf_len; + u8 opr_code[XAP_OPR_NUM]; // operation code buffer + u8 opr_class[XAP_OPR_NUM]; // operation class buffer + u32 opr_timer[XAP_OPR_NUM]; // operation timer buffer +} xap_opr_info; + + +typedef struct xap_inter_struct // xap interface structure +{ + u8 mcc[2]; + u8 mnc0; + u8 cc[2]; + u8 ndc[3]; + u8 inter_prefix[2]; + u8 national_prefix[2]; + u8 local_prefix[2]; + u8 mnc[2];//expend mnc from 1 byte to 2 bytes + +/* mscid is special use for CDMA */ + u8 mscidToNum[256][14]; +/* mscid is special use for CDMA */ + + // define for the ssn control + u8 regssn_len; + u8 reg_ssn[MAX_XAP_SSN]; + u8 regssn_flag[MAX_XAP_SSN]; // indicate if the register SSN is MAP or CAP ssn + u8 open_head[MAX_XAP_SSN]; + u8 open_tail[MAX_XAP_SSN]; + u32 open_did[MAX_XAP_SSN][XAP_OPEN_LEN]; +} xap_inter_struct; + +typedef struct xap_debug_struct +{ + char *start_time; // time of module start + u32 monitor_did; // the dialogue id for monitored + u8 error_switch; + u8 map_switch; + u8 cap_switch; + u8 send_control; // control if can send xap message + u8 ascin_buf[XAP_ASCIN_LEN]; + u8 ascout_buf[XAP_ASCOUT_LEN]; + u32 watch_dog[XAP_WTDOG_LEN]; +} xap_debug_struct; + +typedef struct psmvm_data // xap provider state machine data +{ + u8 xap_flag; // 0: empty; 1: map primitive; 2: cap primitive + u8 psm_state; + u8 sub_state1; + u8 delimiter_flag; + u8 acn; + u8 acn_ver; + u8 msg_type; + u8 msg_flag; + u32 port_id; + u32 suspend_timer; + u8 data_count; + u8 recv_bsa_count; + u8 opr_state[MAX_INVOKEID]; + u8 opr_code[MAX_INVOKEID]; + u8 opr_class[MAX_INVOKEID]; +} psmvm_data; + +typedef struct xapp_vm_data // XAP provider virtue machine structure +{ + struct psmvm_data psm_data; + u8 recvcom_flag; // USER=>XAPP + u8 recvopr_flag; // USER=>XAPP 0: has not data 1: has data 2: has partial data + u8 sendcom_flag; // XAPP=>USER + u8 sendopr_flag; // XAPP=>USER + u32 recvopr_site; // USER=>XAPP 0: has not data 1: has data 2: has partial data + struct MapComSrv_struct recvcom_data; + struct MapOprData_struct recvopr_data; + struct MapComSrv_struct sendcom_data; + struct MapOprData_struct sendopr_data; + struct CSLdlg_struct tcap_data; + struct MapDlg_struct map_dlg; +} xapp_vm_data; + +typedef struct xap_vm_struct +{ + int grantdid; + struct xapp_vm_data xap_data[MAX_DIALOGUEID]; + struct xap_debug_struct debug_data; +} xap_vm_struct; + +struct xap_vm_struct *xap_vm_ptr; +struct xap_inter_struct *xap_inter_ptr; + +#endif diff --git a/omc/plat/xapp/ut/.copyarea.db b/omc/plat/xapp/ut/.copyarea.db new file mode 100644 index 0000000..ddcccc0 --- /dev/null +++ b/omc/plat/xapp/ut/.copyarea.db @@ -0,0 +1,5 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\ut +2 +1 +9:xapp_test|2|0|0|0|63d97774bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/ut/xapp_test/.copyarea.db b/omc/plat/xapp/ut/xapp_test/.copyarea.db new file mode 100644 index 0000000..c1d638d --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/.copyarea.db @@ -0,0 +1,12 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\ut\xapp_test +2 +8 +4:conf|2|0|0|0|663977e4bfa611dc86a4001c23e19543|0 +e:xapp_op_test.c|1|11d70a473a1|12ba2|6b3fd864|64797790bfa611dc86a4001c23e19543|0 +b:xapp_main.h|1|11d70a473df|3cc|9e541cb0|650977acbfa611dc86a4001c23e19543|0 +12:xapp_coding_test.c|1|11d70a474ca|46e2|bdb8be9e|7c497b80bfa611dc86a4001c23e19543|0 +12:xapp_coding_test.h|1|11d70a4745c|e31|a16881d6|7b197b48bfa611dc86a4001c23e19543|0 +8:Makefile|1|11d70a4740e|438|fbe93923|65a977c8bfa611dc86a4001c23e19543|0 +b:xapp_main.c|1|11d70a4749b|2c3a|e6358e92|7bb97b64bfa611dc86a4001c23e19543|0 +e:xapp_op_test.h|1|11d70a47508|3eb|4543f7b9|7ce97b9cbfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/ut/xapp_test/Makefile b/omc/plat/xapp/ut/xapp_test/Makefile new file mode 100644 index 0000000..c25b6b2 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/Makefile @@ -0,0 +1,42 @@ +# Makefile create for XAPP Test +# Create by liuwei + +cc = gcc +#CFLAG = -g -Wall -c -DVMS_UNDER_DEVELOP +CFLAG = -g -Wall -c +LIB_DIR = ../.. +XAPP_TEST_OBJ = xapp_main.o xapp_op_test.o xapp_coding_test.o + +PUBLIC_LIB = -L$(LIB_DIR)/public -lpublic +MTP3_LIB = -L$(LIB_DIR)/mtp3 -lmtp3 +DEBUG_LIB = -L$(LIB_DIR)/debug -ldebug +SNMP_LIB = -L$(LIB_DIR)/snmp -lsnmp +SCCP_LIB = -L$(LIB_DIR)/sccp -lsccp +TCAP_LIB = -L$(LIB_DIR)/tcap -ltcap +XAPP_LIB = -L$(LIB_DIR)/xapp -lxapp +IPTRANS_LIB = -L$(LIB_DIR)/iptrans -liptrans + +xapp_test: $(XAPP_TEST_OBJ) + $(cc) -o xapp_test $(XAPP_TEST_OBJ) $(DEBUG_LIB) $(IPTRANS_LIB) $(SNMP_LIB) $(MTP3_LIB) $(SCCP_LIB) $(TCAP_LIB) $(XAPP_LIB) $(PUBLIC_LIB) -lm -lz + +xapp_main.o: xapp_main.c + $(cc) $(CFLAG) xapp_main.c + +xapp_op_test.o : xapp_op_test.c + $(cc) $(CFLAG) xapp_op_test.c + +xapp_coding_test.o : xapp_coding_test.c + $(cc) $(CFLAG) xapp_coding_test.c + +run: + cd .. ; rm -f *.a + cd ../mapp;make;cd .. + cd ../capp;make;cd .. + cd .. ;make; + rm -f xapp_test ; make +clean: + cd ../ ;make clean + rm -f *.o *.a *.bak core xapp_test + +backup: + diff --git a/omc/plat/xapp/ut/xapp_test/conf/.copyarea.db b/omc/plat/xapp/ut/xapp_test/conf/.copyarea.db new file mode 100644 index 0000000..db32266 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/.copyarea.db @@ -0,0 +1,34 @@ +ClearCase CopyAreaDB|4 +vobs\r9\plat\xapp\ut\xapp_test\conf +2 +1e +9:help_page|1|11d70a47650|21d|76e388e2|69c97870bfa611dc86a4001c23e19543|0 +8:conf.rar|1|11d70a475c4|a4e|398f2d2|6769781cbfa611dc86a4001c23e19543|0 +12:cap_operation.conf|1|11d70a4799c|4ec|138764f3|73f97a14bfa611dc86a4001c23e19543|0 +c:cap_acn.conf|1|11d70a47798|f4|79044b6f|6e997934bfa611dc86a4001c23e19543|0 +10:conv_prefix.conf|1|11d70a47779|1200|4a8a0577|6d697918bfa611dc86a4001c23e19543|0 +c:map_acn.conf|1|11d70a4774a|605|8729d67f|6cc978fcbfa611dc86a4001c23e19543|0 +e:smsc_csta.conf|1|11d70a47a86|16b|27e474c8|76e97aa0bfa611dc86a4001c23e19543|0 +e:system.ini.30K|1|11d70a476ec|d4|a6f90c7e|6b9978c4bfa611dc86a4001c23e19543|0 +d:wxc2_sys.conf|1|11d70a4767f|13|32e20463|6a69788cbfa611dc86a4001c23e19543|0 +c:iptrans.conf|1|11d70a47b8f|133|afae515b|7a897b2cbfa611dc86a4001c23e19543|0 +9:menu_page|1|11d70a47595|20a|2b951fe|66d97800bfa611dc86a4001c23e19543|0 +7:profile|1|11d70a479f9|303|f498ea9e|75297a4cbfa611dc86a4001c23e19543|0 +e:.sccp.conf.swo|1|11d70a47b60|3000|a97f0912|79497b10bfa611dc86a4001c23e19543|0 +a:system.ini|1|11d70a47b32|d4|c2920d14|78b97af4bfa611dc86a4001c23e19543|0 +a:HlrSysPara|1|11d70a479ca|1c4c|4897e7b6|74897a30bfa611dc86a4001c23e19543|0 +d:smsc_sys.conf|1|11d70a47a47|56|7f8e17d8|76597a84bfa611dc86a4001c23e19543|0 +12:map_operation.conf|1|11d70a478ff|c11|26bf7744|718979c0bfa611dc86a4001c23e19543|0 +e:.sccp.conf.swp|1|11d70a47825|f000|f01a302d|70597988bfa611dc86a4001c23e19543|0 +9:sccp.conf|1|11d70a475f2|45c|70f1cec3|68097838bfa611dc86a4001c23e19543|0 +11:hlr_parambit.conf|1|11d70a47a28|5104|45018cef|75b97a68bfa611dc86a4001c23e19543|0 +f:system.ini.100k|1|11d70a4792e|d4|f4bd0e99|722979dcbfa611dc86a4001c23e19543|0 +b:ppsConf.txt|1|11d70a47621|6eb4|7ddbb6ab|68997854bfa611dc86a4001c23e19543|0 +9:mtp3.conf|1|11d70a476ae|17450|6f04775|6b0978a8bfa611dc86a4001c23e19543|0 +13:system.inimscvlrhlr|1|11d70a47b03|d4|a5640c59|78197ad8bfa611dc86a4001c23e19543|0 +d:cc_table.conf|1|11d70a477c7|1156|31d07a59|6f297950bfa611dc86a4001c23e19543|0 +12:smsc_parambit.conf|1|11d70a4796d|b14|e71da7cc|72c979f8bfa611dc86a4001c23e19543|0 +c:wxc2exit.txt|1|11d70a477f6|4a|51411549|6fc9796cbfa611dc86a4001c23e19543|0 +11:xap_sysparam.conf|1|11d70a47854|d|246d0664|70f979a4bfa611dc86a4001c23e19543|0 +e:xapp_test.conf|1|11d70a47ab5|14|26ca0352|77897abcbfa611dc86a4001c23e19543|0 +c:hae_sys.conf|1|11d70a4771b|74|a5dc1e78|6c3978e0bfa611dc86a4001c23e19543|0 diff --git a/omc/plat/xapp/ut/xapp_test/conf/.sccp.conf.swo b/omc/plat/xapp/ut/xapp_test/conf/.sccp.conf.swo new file mode 100644 index 0000000..847a816 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/.sccp.conf.swo differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/HlrSysPara b/omc/plat/xapp/ut/xapp_test/conf/HlrSysPara new file mode 100644 index 0000000..6104688 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/HlrSysPara differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/cap_acn.conf b/omc/plat/xapp/ut/xapp_test/conf/cap_acn.conf new file mode 100644 index 0000000..03de193 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/cap_acn.conf @@ -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 diff --git a/omc/plat/xapp/ut/xapp_test/conf/cap_operation.conf b/omc/plat/xapp/ut/xapp_test/conf/cap_operation.conf new file mode 100644 index 0000000..e6f21e1 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/cap_operation.conf @@ -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 diff --git a/omc/plat/xapp/ut/xapp_test/conf/cc_table.conf b/omc/plat/xapp/ut/xapp_test/conf/cc_table.conf new file mode 100644 index 0000000..72da771 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/cc_table.conf @@ -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 + diff --git a/omc/plat/xapp/ut/xapp_test/conf/conf.rar b/omc/plat/xapp/ut/xapp_test/conf/conf.rar new file mode 100644 index 0000000..310f16f Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/conf.rar differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/conv_prefix.conf b/omc/plat/xapp/ut/xapp_test/conf/conv_prefix.conf new file mode 100644 index 0000000..bcd6108 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/conv_prefix.conf differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/hae_sys.conf b/omc/plat/xapp/ut/xapp_test/conf/hae_sys.conf new file mode 100644 index 0000000..500a027 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/hae_sys.conf @@ -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; diff --git a/omc/plat/xapp/ut/xapp_test/conf/help_page b/omc/plat/xapp/ut/xapp_test/conf/help_page new file mode 100644 index 0000000..f384302 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/help_page @@ -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". + +$ diff --git a/omc/plat/xapp/ut/xapp_test/conf/hlr_parambit.conf b/omc/plat/xapp/ut/xapp_test/conf/hlr_parambit.conf new file mode 100644 index 0000000..8497c6f Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/hlr_parambit.conf differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/iptrans.conf b/omc/plat/xapp/ut/xapp_test/conf/iptrans.conf new file mode 100644 index 0000000..79ed7f0 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/iptrans.conf @@ -0,0 +1,17 @@ +#ipconfig for pps +#port=type,num,interface +#type=UDP/TCP +#num=0-6 +#interface=BUFFER/DIRECT +4950=UDP,6,DIRECT +4952=UDP,2,BUFFER +4953=UDP,3,BUFFER +4954=UDP,3,BUFFER +4955=UDP,3,BUFFER +4957=UDP,4,BUFFER +4960=UDP,3,BUFFER +4965=TCP,3,BUFFER +4969=UDP,3,BUFFER +4970=UDP,3,BUFFER +4971=UDP,2,BUFFER +4972=UDP,2,BUFFER diff --git a/omc/plat/xapp/ut/xapp_test/conf/map_acn.conf b/omc/plat/xapp/ut/xapp_test/conf/map_acn.conf new file mode 100644 index 0000000..f6167c0 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/map_acn.conf @@ -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 + diff --git a/omc/plat/xapp/ut/xapp_test/conf/map_operation.conf b/omc/plat/xapp/ut/xapp_test/conf/map_operation.conf new file mode 100644 index 0000000..a802790 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/map_operation.conf @@ -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 \ No newline at end of file diff --git a/omc/plat/xapp/ut/xapp_test/conf/menu_page b/omc/plat/xapp/ut/xapp_test/conf/menu_page new file mode 100644 index 0000000..29f6fb8 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/menu_page @@ -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 diff --git a/omc/plat/xapp/ut/xapp_test/conf/mtp3.conf b/omc/plat/xapp/ut/xapp_test/conf/mtp3.conf new file mode 100644 index 0000000..d236db3 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/mtp3.conf @@ -0,0 +1,1408 @@ +#MTP3 CONFIGURE FILE + +[SERVICE NETWORK SP LEN] +[00] + +[LOCAL SP] +[000000] [000000] [000028] [000000] +[000000] [000000] [000000] [000000] + +[LINK ATTRIBUTE] +[00.00.ea] [11.00.62] [80.10.ff] [10.00.62] +[14.00.62] [08.00.62] [4e.00.62] [80.10.ff] +[80.10.ff] [12.00.62] [80.10.ff] [0a.00.62] +[0b.00.62] [0c.00.62] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [11.01.63] [80.10.ff] [10.01.63] +[14.01.63] [08.02.63] [4f.00.63] [80.10.ff] +[80.10.ff] [12.01.63] [80.10.ff] [0a.01.63] +[0b.01.63] [0c.01.63] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] +[80.10.ff] [80.10.ff] [80.10.ff] [80.10.ff] + +[LINKSET ATTRIBUTE] +[000028.02] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] +[000000.00] [000000.00] [000000.00] [000000.00] + +[NATIONAL NETWORK SP] +[000028.00.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000008.08.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[NATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[INTERNATIONAL NETWORK SPARE SP] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] +[000000.80.80] [000000.80.80] [000000.80.80] [000000.80.80] + +[LOCAL ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 + +[INTERNATIONAL NETWORK ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[INTERNATIONAL NETWORK SPARE ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[NATIONAL NETWORK ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +010303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + +[NATIONAL NETWORK SPARE ACN] +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 +030303030202020202030302020303020303020303030303030303030303030302020202 + diff --git a/omc/plat/xapp/ut/xapp_test/conf/ppsConf.txt b/omc/plat/xapp/ut/xapp_test/conf/ppsConf.txt new file mode 100644 index 0000000..b556699 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/ppsConf.txt differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/profile b/omc/plat/xapp/ut/xapp_test/conf/profile new file mode 100644 index 0000000..de17bc9 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/profile @@ -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 diff --git a/omc/plat/xapp/ut/xapp_test/conf/sccp.conf b/omc/plat/xapp/ut/xapp_test/conf/sccp.conf new file mode 100644 index 0000000..d8397e6 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/sccp.conf @@ -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 + diff --git a/omc/plat/xapp/ut/xapp_test/conf/smsc_csta.conf b/omc/plat/xapp/ut/xapp_test/conf/smsc_csta.conf new file mode 100644 index 0000000..b38d7f7 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/smsc_csta.conf @@ -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 diff --git a/omc/plat/xapp/ut/xapp_test/conf/smsc_parambit.conf b/omc/plat/xapp/ut/xapp_test/conf/smsc_parambit.conf new file mode 100644 index 0000000..cc4473d Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/smsc_parambit.conf differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/smsc_sys.conf b/omc/plat/xapp/ut/xapp_test/conf/smsc_sys.conf new file mode 100644 index 0000000..a6081a9 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/smsc_sys.conf @@ -0,0 +1,5 @@ +#SMSC system configure file + +#IP info of SMSC +wxc2-0=172.18.98.1; +wxc2-1=172.18.99.1; diff --git a/omc/plat/xapp/ut/xapp_test/conf/system.ini b/omc/plat/xapp/ut/xapp_test/conf/system.ini new file mode 100644 index 0000000..775a1a3 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/system.ini differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/system.ini.100k b/omc/plat/xapp/ut/xapp_test/conf/system.ini.100k new file mode 100644 index 0000000..2b5124e Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/system.ini.100k differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/system.ini.30K b/omc/plat/xapp/ut/xapp_test/conf/system.ini.30K new file mode 100644 index 0000000..814c2c8 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/system.ini.30K differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/system.inimscvlrhlr b/omc/plat/xapp/ut/xapp_test/conf/system.inimscvlrhlr new file mode 100644 index 0000000..53e9e53 Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/system.inimscvlrhlr differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/wxc2_sys.conf b/omc/plat/xapp/ut/xapp_test/conf/wxc2_sys.conf new file mode 100644 index 0000000..fe6ec83 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/wxc2_sys.conf @@ -0,0 +1 @@ +pps-1=172.18.98.1; diff --git a/omc/plat/xapp/ut/xapp_test/conf/wxc2exit.txt b/omc/plat/xapp/ut/xapp_test/conf/wxc2exit.txt new file mode 100644 index 0000000..fc9e7d6 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/wxc2exit.txt @@ -0,0 +1,4 @@ +WXC2 procedure exit log + Time: Fri Nov 5 05:27:51 2004 + +Now module: MSC diff --git a/omc/plat/xapp/ut/xapp_test/conf/xap_sysparam.conf b/omc/plat/xapp/ut/xapp_test/conf/xap_sysparam.conf new file mode 100644 index 0000000..2bc914e Binary files /dev/null and b/omc/plat/xapp/ut/xapp_test/conf/xap_sysparam.conf differ diff --git a/omc/plat/xapp/ut/xapp_test/conf/xapp_test.conf b/omc/plat/xapp/ut/xapp_test/conf/xapp_test.conf new file mode 100644 index 0000000..94ea0ec --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/conf/xapp_test.conf @@ -0,0 +1,2 @@ +172.18.199.1 +2000 diff --git a/omc/plat/xapp/ut/xapp_test/xapp_coding_test.c b/omc/plat/xapp/ut/xapp_test/xapp_coding_test.c new file mode 100644 index 0000000..36baac5 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_coding_test.c @@ -0,0 +1,652 @@ +/* XAPP coding test function c file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#include "xapp_coding_test.h" +#include "xapp_main.h" + +CAP_Message CAP_Com_OpenResponse = { + {0, 16} + , + CAP_FLAG, + {0, 0, 0} + , + {0, 0, 0} + , + CAP_O_OPEN, //CAP_O_OPEN, + CAP_RESPONSE, //RESPONSE, + {2, //RESULT=accept + 1, // + 1, //acn tag + 2, //len + 50, //acn + 2, //acn version + 0,} //end flag +}; + +CAP_Message CAP_Com_End = { + {0, 12} + , + CAP_FLAG, + {0, 0, 0} + , + {0, 0, 0} + , + CAP_O_END, //CAP_O_END, + CAP_REQUEST, //REQUEST, + {1, //release method + 0, //optional part + 0,} +}; + +int bcd_hton(BYTE * netbcd, const BYTE * hostbcd, BYTE max_octet) +{ + int i; + BYTE bcd_h, bcd_l; + + for(i = 0; i < max_octet; i++) + { + if((bcd_h = hostbcd[i] >> 4) == 0x0f) + return i * 2; + else if((bcd_l = hostbcd[i] & 0x0f) == 0x0f) + { + netbcd[i] = bcd_h & 0x0f; + return i * 2 + 1; + } + else + netbcd[i] = (bcd_l << 4) | bcd_h; + } + return i * 2; +} + +/* end by "F" */ +int bcd_ntoh(BYTE * hostbcd, const BYTE * netbcd, BYTE max_octet) +{ + int i; + int bcd_h, bcd_l; + + for(i = 0; i < max_octet; i++) + { + if((bcd_h = netbcd[i] & 0x0f) == 0x0f) + { + memset(&hostbcd[i], 0xff, max_octet - i); + return i * 2; + } + else if((bcd_l = netbcd[i] >> 4) == 0x0f) + { + hostbcd[i] = (bcd_h << 4) | 0x0f; + memset(&hostbcd[i + 1], 0xff, max_octet - i - 1); + return i * 2 + 1; + } + else + { + hostbcd[i] = (bcd_h << 4) | bcd_l; + } + } + return i * 2; +} + +void isdn_aton(u8 *normal_isdn,u8 *anti_isdn) +{ + u8 ii; + u8 aa=0,bb=0; + u8 isdn_len; + + isdn_len = anti_isdn[0]; + if (isdn_len > ISDN_LEN) + isdn_len = ISDN_LEN; + normal_isdn[0] = anti_isdn[1]; + for (ii = 1;ii < isdn_len;ii ++) + { + if ((anti_isdn[ii+1] & 0x0f) >= 0x0e) + break; + aa = (anti_isdn[ii+1] & 0x0f0) >> 4; + if (aa > 0x0c) + aa = 0x0e; + bb = anti_isdn[ii+1] & 0x0f; + normal_isdn[ii] = (bb << 4) + aa; + } + for (;ii < ISDN_LEN;ii ++) + normal_isdn[ii] = 0x0ee; +} + +void imsi_aton(u8 *normal_imsi,u8 *anti_imsi) +{ // the IMSI must 15 digits + u8 ii; + u8 aa,bb=0; + + normal_imsi[0] = 0; + for (ii = 0;ii < IMSI_LEN*2;ii++) + { + if ((ii % 2) == 1) + { + aa = anti_imsi[ii/2] & 0x0f; + normal_imsi[ii/2] |= aa; + } + else + { + if (ii/2 != IMSI_LEN -1) + { + bb = anti_imsi[ii/2] & 0x0f0; + normal_imsi[ii/2+1] = bb; + } + } + } +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from normal to anti sequence */ +/* 0460022157127001 --> 64002251177200f1 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi) +{ + u8 ii; + u8 aa,bb=0; + + for (ii = 1;ii <= IMSI_LEN*2;ii++) + { + if ((ii % 2) == 1) + bb = normal_imsi[ii/2] & 0x0f; + else + { + if (ii == IMSI_LEN * 2) + aa = 0x0f0; + else + aa = normal_imsi[ii/2] & 0x0f0; + anti_imsi[ii/2-1] = aa | bb; + } + } +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from normal to ascii string */ +/* 0460022157127001 --> "460022157127001" */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void imsi_ntos(u8 *str_imsi,u8 *normal_imsi) +{ + u8 len; + u8 ii,jj; + + str_imsi[0] = (normal_imsi[0] & 0x0f) + '0'; + len = 1; + for (ii = 1;ii < IMSI_LEN;ii ++) + { + jj = (normal_imsi[ii] >> 4) & 0x0f; + str_imsi[len++] = jj + '0'; + jj = normal_imsi[ii] & 0x0f; + str_imsi[len++] = jj + '0'; + } + str_imsi[len] = '\0'; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer IMSI format from ascii string to normal */ +/* "460022157127001" --> 0460022157127001 */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void imsi_ston(u8 *normal_imsi,u8 *str_imsi) +{ + if (strlen(str_imsi) != IMSI_LEN*2-1) + return; + normal_imsi[0] = str_imsi[0] - '0'; + AsciiToBcd(normal_imsi+1,str_imsi+1,IMSI_LEN*2-2); +} +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from normal to ascii string */ +/* 918675557127001EEE --> "8675557127001" */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +void isdn_ntos(u8 *str_isdn,u8 *normal_isdn) +{ + u8 len = 0; + u8 ii,jj; + + for (ii = 1;ii < ISDN_LEN;ii ++) + { + jj = (normal_isdn[ii] >> 4) & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + jj = normal_isdn[ii] & 0x0f; + if (jj > 0x0c) + break; + str_isdn[len++] = jj + '0'; + } + str_isdn[len] = '\0'; +} + +void isdn_ntoa(u8 * anti_isdn, u8 * normal_isdn) +{ + u8 ii; + u8 aa = 0, bb = 0; + u8 len; + + anti_isdn[1] = normal_isdn[0]; // nature of address and numbering plan indicator + len = 1; + for(ii = 1; ii < ISDN_LEN; ii++) + { + if(normal_isdn[ii] == 0xee) + break; + else + { + aa = (normal_isdn[ii] & 0x0f0) >> 4; + bb = normal_isdn[ii] & 0x0f; + if(bb > 0x0c) + bb = 0x0f; + anti_isdn[ii + 1] = (bb << 4) + aa; + len++; + } + } + anti_isdn[0] = len; +} + +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* transfer ISDN format from ascii string to normal */ +/* "8675557127001" --> 918675557127001EEE */ +/* return value: 0--string has error; 1--success */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++ */ +u8 isdn_ston(u8 *normal_isdn,u8 *str_isdn) +{ + u8 ii; + u8 len; + + len = strlen(str_isdn); + if (len > ISDN_LEN*2-2) + return 0; + if ((len % 2) == 1) // odd number + { + AsciiToBcd(normal_isdn+1,str_isdn,len-1); + ii = len/2 + 1; + normal_isdn[ii] = (str_isdn[len-1] - '0') << 4; + normal_isdn[ii] |= 0x0E; + } + else + { + AsciiToBcd(normal_isdn+1,str_isdn,len); + ii = len/2; + } + memset(normal_isdn+ii+1,0xEE,ISDN_LEN-ii-1); + normal_isdn[0] = 0x91; // default value + return 1; +} + + +u8 set_gtai_isdn(u8 * gtai, u8 * isdn) +{ + u8 temp_buf[32]; + u8 ii; + u8 len; + + isdn_ntoa(temp_buf, isdn); + ii = temp_buf[0]; + memcpy(gtai, temp_buf + 2, ii - 1); + if((temp_buf[ii] & 0x0f0) == 0x0f0) + len = ii * 2 - 3; + else + len = ii * 2 - 2; + return len; +} + +void xapp_set_sccpadd(u8 ssn, u8 * gtt_num, struct SCCP_ADDRESS *sccp_add) +{ + sccp_add->DPC = 0; // set SCCP address + sccp_add->NetID = 4; + sccp_add->SSN = ssn; + sccp_add->RI = 0; + sccp_add->GTI = 0x04; + sccp_add->TT = 0; + sccp_add->NAI = 4; + sccp_add->NP = 1; // MSISDN + sccp_add->len = set_gtai_isdn(sccp_add->GTAI, gtt_num); +} + +u8 get_mapp_open(struct MapComSrv_struct *com_ptr, u8 ssn) +{ + u8 data_flow[1024]; + + if(!map_get_open(data_flow, ssn)) + return 0; + if(!map_com_ftos(com_ptr, data_flow)) + return 0; + printf("-->>: Recv OpenInd !\r\n"); + return 1; +} + +u8 send_mapp_comdata(struct MapComSrv_struct * com_ptr, u8 DelimiterFlag) +{ + u8 data_flow[1024]; + + map_com_stof(com_ptr, data_flow, DelimiterFlag); + return map_send_comdata(data_flow); +} + +u8 recv_mapp_comdata(struct MapComSrv_struct * com_ptr, u32 did) +{ + u8 data_flow[1024]; + + if(!map_get_comdata(data_flow, did)) + return 0; + if(!map_com_ftos(com_ptr, data_flow)) + return 0; + return 1; +} + +int send_mapp_oprdata(struct MapOprData_struct *opr_ptr, u8 DelimiterFlag) +{ + u8 data_flow[1024]; + + map_opr_stof(opr_ptr, data_flow, DelimiterFlag); + return map_send_oprdata(data_flow); +} + +int recv_mapp_oprdata(struct MapOprData_struct *opr_ptr, u32 did) +{ + u8 data_flow[1024]; + + if(!map_get_oprdata(data_flow, did)) + return 0; + if(!map_opr_ftos(opr_ptr, data_flow)) + return 0; + return 1; +} + +int send_mapp_open_req(WORD dialog_id) +{ + struct MapComSrv_struct map_com; + + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_REQUEST; + map_com.port_id = 0; + map_com.dialogue_id = test_xapp.did; + map_com.dlg_list.open_arg.acn_data.acn = 0; + map_com.dlg_list.open_arg.acn_data.acn_ver = 1; + memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR)); + memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR)); + map_com.dlg_list.open_arg.param_flag = 0x0b; + send_mapp_comdata(&map_com, 1); + printf("<<--: Send OpenReq !\r\n"); + return 1; +} + +int send_mapp_open_conf() +{ + struct MapComSrv_struct map_com; + struct MapOpen_Res *open_res; + + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_RESPONSE; + map_com.port_id = 0; + map_com.dialogue_id = test_xapp.did; + map_com.dlg_list.open_arg.acn_data.acn = 0; + map_com.dlg_list.open_arg.acn_data.acn_ver = 1; + memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR)); + memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR)); + open_res = (MapOpen_Res *) & map_com.dlg_list.open_res; + open_res->result = OpenResultAccept; + open_res->param_flag = 0x08; + if(send_mapp_comdata(&map_com, 1)) + { + printf("<<--: Send OpenConf !\r\n"); + return 1; + } + return 0; +} + +int send_mapp_close(WORD dialog_id) +{ + + struct MapComSrv_struct map_com; + + map_com.message_type = MAP_CLOSE; + map_com.message_flag = MAP_REQUEST; + map_com.port_id = 0; + map_com.dialogue_id = test_xapp.did; + map_com.dlg_list.open_arg.acn_data.acn_ver = 1; + memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR)); + memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR)); + map_com.dlg_list.close_arg.release_method = NormalRelease; + map_com.dlg_list.close_arg.param_flag = 0x01; + send_mapp_comdata(&map_com, 1); + printf("<<--: Send Close !\r\n"); + return 1; +} + +u8 get_capp_open(struct MapComSrv_struct * com_ptr, u8 ssn) +{ + u8 data_flow[1024]; + + if(!cap_get_open(data_flow, ssn)) + return 0; + if(!cap_com_ftos(com_ptr, data_flow)) + return 0; + printf("-->>: Recv OpenInd !\r\n"); + return 1; +} + +u8 send_capp_comdata(struct MapComSrv_struct * com_ptr, u8 DelimiterFlag) +{ + u8 data_flow[1024]; + + cap_com_stof(com_ptr, data_flow, DelimiterFlag); + return cap_send_comdata(data_flow); +} + +u8 recv_capp_comdata(struct MapComSrv_struct * com_ptr, u32 did) +{ + u8 data_flow[1024]; + + if(!cap_get_comdata(data_flow, did)) + return 0; + if(!cap_com_ftos(com_ptr, data_flow)) + return 0; + return 1; +} + +int send_capp_oprdata(struct MapOprData_struct *opr_ptr, u8 DelimiterFlag) +{ + u8 data_flow[1024]; + + cap_opr_stof(opr_ptr, data_flow, DelimiterFlag); + return cap_send_oprdata(data_flow); +} + +int recv_capp_oprdata(struct MapOprData_struct *opr_ptr, u32 did) +{ + u8 data_flow[1024]; + + if(!cap_get_oprdata(data_flow, did)) + return 0; + if(!cap_opr_ftos(opr_ptr, data_flow)) + return 0; + return 1; +} + +/* + u8 send_capp_oprdata(CAP_Message *pcapmsg , u8 len) + { + pcapmsg->msgOperaCode = test_xapp.operation_type; + pcapmsg->msgServiceCode = 0x8a; + pcapmsg->msgOperaType = MAP_REQUEST; + pcapmsg->msgContent[0] = test_xapp.invoke_id; + pcapmsg->msgContent[1] = 1; //pointer to paramter + pcapmsg->msgContent[2] = 1; //Tag of parameter + pcapmsg->msgContent[3] = 0; //length1 + pcapmsg->msgContent[4] = len; //length2 + pcapmsg->msgContent[5 + len] = 0x10; //delimiter + pcapmsg->msgContent[6 + len] = 0; + pcapmsg->msgContent[7 + len] = 0; + + pcapmsg->msgLength[0] = 0; + pcapmsg->msgLength[1] = 17 + len; + if(!cap_send_oprdata((char *)pcapmsg)) + { + return 0; + } + return 1; + } + + u8 recv_capp_oprdata(CAP_Message *capmsg , u32 did) + { + return cap_get_oprdata((unsigned char *)capmsg, did); + } + */ +int send_capp_open_req(unsigned char acn, unsigned char acn_v, unsigned short dlgid) +{ + struct MapComSrv_struct map_com; + + map_com.message_type = CAP_O_OPEN; + map_com.message_flag = CAP_REQUEST; + map_com.port_id = 0; + map_com.dialogue_id = test_xapp.did; + map_com.dlg_list.open_arg.acn_data.acn = acn; + map_com.dlg_list.open_arg.acn_data.acn_ver = 1; + memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR)); + memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR)); + map_com.dlg_list.open_arg.param_flag = 0x0b; + send_capp_comdata(&map_com, 1); + printf("<<--: Send OpenReq !\r\n"); + return 1; +} + +void send_capp_open_conf(unsigned char acn, unsigned char acn_v, unsigned short dlgid) +{ + CAP_Message capmsg; + + memcpy(&capmsg, &CAP_Com_OpenResponse, 18); + capmsg.dialogue_id[0] = dlgid >> 8; + capmsg.dialogue_id[1] = dlgid; + capmsg.msgContent[4] = acn; + capmsg.msgContent[5] = acn_v; + cap_send_comdata((unsigned char *)&capmsg); +} + +void send_capp_close(unsigned short dlgid) +{ + CAP_Message capmsg; + + memcpy(&capmsg, &CAP_Com_End, 14); + capmsg.dialogue_id[0] = dlgid >> 8; + capmsg.dialogue_id[1] = dlgid; + cap_send_comdata((unsigned char *)&capmsg); +} + +int build_xapp_msg() +{ + if(test_xapp.xapp_type) + { + int len; + struct CapArg *cap_opr; + struct MapOprData_struct *data_ptr; + u8 buf[1024]; + + cap_opr = &test_xapp.xapp.capp.cap_opr; + data_ptr = &test_xapp.xapp.capp.data_ptr; + + data_ptr->port_id = cap_opr->port_id; + data_ptr->dialogue_id = cap_opr->dialogue_id; + data_ptr->invoke_id = cap_opr->invoke_id; + data_ptr->message_type = cap_opr->ocode; + data_ptr->message_flag = cap_opr->message_flag; + data_ptr->param_flag = 0x1f; + + len = encode_capmsg(*cap_opr, buf, MAX_MAPPOPR_LEN); + if(len == 0 || len > MAX_MAPPOPR_LEN) + return 0; + data_ptr->param_len = len; + + memcpy(data_ptr->param, buf, len); + data_ptr->param_flag |= 0x20; + return len; + } + else + { + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + int len; + u8 buf[1024]; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + data_ptr->port_id = srv_ptr->port_id; + data_ptr->dialogue_id = srv_ptr->dialogue_id; + data_ptr->invoke_id = srv_ptr->invoke_id; + data_ptr->message_type = srv_ptr->message_type; + data_ptr->message_flag = srv_ptr->message_flag; + //data_ptr->linked_id =1; + data_ptr->param_flag = 0x1f; + + len = build_mapparam(srv_ptr, buf); + if(len == 0 || len > MAX_MAPPOPR_LEN) + return 0; + data_ptr->param_len = len; + + memcpy(data_ptr->param, buf, len); + data_ptr->param_flag |= 0x20; + return len; + } + return 0; +} + +int extract_xapp_msg() +{ + if(test_xapp.xapp_type) + { + int len; + struct CapArg *cap_opr; + struct MapOprData_struct *data_ptr; + + data_ptr = &test_xapp.xapp.capp.data_ptr; + cap_opr = &test_xapp.xapp.capp.cap_opr; + + cap_opr->port_id = data_ptr->port_id; + cap_opr->dialogue_id = data_ptr->dialogue_id; + cap_opr->invoke_id = data_ptr->invoke_id; + cap_opr->ocode = data_ptr->message_type; + cap_opr->message_flag = data_ptr->message_flag; + + decode_capmsg(data_ptr->param, data_ptr->param_len, cap_opr->ocode, cap_opr->message_flag, cap_opr); + return len; + } + else + { + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->port_id = data_ptr->port_id; + srv_ptr->dialogue_id = data_ptr->dialogue_id; + srv_ptr->invoke_id = data_ptr->invoke_id; + srv_ptr->message_type = data_ptr->message_type; + srv_ptr->message_flag = data_ptr->message_flag; + if(!(data_ptr->param_flag & 0x20)) // has not parameter + return RER; + extract_mapparam(srv_ptr, data_ptr->message_type, data_ptr->message_flag, data_ptr->param_len, data_ptr->param); + return ROK; + } + return RER; +} + + +void extract_sri() +{ + struct MapOprSrv_struct opr_ptr; + u8 opr_code = SndRoutInfo; + u8 opr_flag = MAP_CONFIRM; + u32 pre_param_len= 21; + u8 *pre_param; + u8 buf[256],temp_buf[256]; + u8 str[256]="A313890864009200000083F10407916857951230F7"; + + Str2Bcd( buf ,str ,pre_param_len ); + + + Bcd2Str_Space(temp_buf, str,pre_param_len); + printf("\r\nextract code :[%d] len :[%ld]\r\n%s\r\n",opr_code,pre_param_len,str); + + pre_param = (u8*)&buf; + opr_ptr.version =3; + extract_mapparam( &opr_ptr, opr_code , opr_flag , pre_param_len , pre_param ); + +} diff --git a/omc/plat/xapp/ut/xapp_test/xapp_coding_test.h b/omc/plat/xapp/ut/xapp_test/xapp_coding_test.h new file mode 100644 index 0000000..39ec0cd --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_coding_test.h @@ -0,0 +1,105 @@ +/* XAPP coding test function head file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#include "xapp_main.h" + +#ifndef _XAPP_CODING_TEST_ + +#define _XAPP_CODING_TEST_ + +struct mapp_struct +{ + struct MapOprSrv_struct map_opr; + struct MapOprData_struct data_ptr; + //struct MapOprData_struct data_ptr_bak; + struct MapComSrv_struct com_ptr; +}; + +typedef struct _CAP_Message +{ + unsigned char msgLength[2]; /* unsigned char0 is the higher part */ + unsigned char msgServiceCode; /* fixed as 0xAF */ + unsigned char port_id[3]; /* unsigned char 0 is the higher part,unsigned char 1 is the lower part ,and unsigned char 2 is reserved */ + unsigned char dialogue_id[3]; + unsigned char msgOperaCode; /* message type code ,e.g , InitialDP = 0x00 */ + unsigned char msgOperaType; /* 1/2/3/4 = request, indicate, response, confirm */ + unsigned char msgContent[CAP_CONTENT_LEN]; + /* if the message if cap operation ,then the first unsigned char of msgContent is invoke id */ +} +CAP_Message, *PCAP_Message; + +struct capp_struct +{ + struct CapArg cap_opr; + struct MapOprData_struct data_ptr; + struct MapComSrv_struct com_ptr; + //CAP_Message capmsg; +}; + +struct test_xapp_struct +{ + int sock; + u8 fsm_state; + u8 did; + u8 invoke_id; + u8 xapp_type; + u8 ms_mode; + u8 test_result; + u8 operation_type; + u8 local_ssn; + u8 peer_ssn; + u8 peer_state; + u32 wait_time; + struct SCCP_ADDRESS local_add; + struct SCCP_ADDRESS peer_add; + union + { + struct mapp_struct mapp; + struct capp_struct capp; + } + xapp; +} +test_xapp; + +enum XAPP_TEST_OP test_cmd; +int bcd_hton(BYTE * netbcd, const BYTE * hostbcd, BYTE max_octet); +int bcd_ntoh(BYTE * hostbcd, const BYTE * netbcd, BYTE max_octet); +void isdn_aton(u8 *normal_isdn,u8 *anti_isdn); +void imsi_aton(u8 *normal_imsi,u8 *anti_imsi); +void imsi_ntos(u8 *str_imsi,u8 *normal_imsi); +void imsi_ston(u8 *normal_imsi,u8 *str_imsi); +void isdn_ntos(u8 *str_isdn,u8 *normal_isdn); +void imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi); + +void isdn_ntoa(u8 * anti_isdn, u8 * normal_isdn); +u8 isdn_ston(u8 *normal_isdn,u8 *str_isdn); + +void xapp_set_sccpadd(u8 ssn, u8 * gtt_num, struct SCCP_ADDRESS *sccp_add); + +int build_xapp_msg(); +int extract_xapp_msg(); + +u8 get_mapp_open(struct MapComSrv_struct *com_ptr, u8 ssn); +u8 send_mapp_comdata(struct MapComSrv_struct *com_ptr, u8 DelimiterFlag); +u8 recv_mapp_comdata(struct MapComSrv_struct *com_ptr, u32 did); +int send_mapp_oprdata(struct MapOprData_struct *opr_ptr, u8 DelimiterFlag); +int recv_mapp_oprdata(struct MapOprData_struct *opr_ptr, u32 did); + +int send_mapp_open_req(WORD dialog_id); +int send_mapp_open_conf(); +int send_mapp_close(WORD dialog_id); + +u8 get_capp_open(struct MapComSrv_struct *com_ptr, u8 ssn); +u8 send_capp_comdata(struct MapComSrv_struct *com_ptr, u8 DelimiterFlag); +u8 recv_capp_comdata(struct MapComSrv_struct *com_ptr, u32 did); +int send_capp_oprdata(struct MapOprData_struct *opr_ptr, u8 DelimiterFlag); +int recv_capp_oprdata(struct MapOprData_struct *opr_ptr, u32 did); +int send_capp_open_req(unsigned char acn, unsigned char acn_v, unsigned short dlgid); +void send_capp_open_conf(unsigned char acn, unsigned char acn_v, unsigned short dlgid); +void send_capp_close(unsigned short dlgid); + +void extract_sri(); + +#endif diff --git a/omc/plat/xapp/ut/xapp_test/xapp_main.c b/omc/plat/xapp/ut/xapp_test/xapp_main.c new file mode 100644 index 0000000..31f7865 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_main.c @@ -0,0 +1,372 @@ +/* XAPP coding test function c file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xapp_coding_test.h" +#include "xapp_main.h" + +static int sys_timer10ms = 0; + +static char test_sync_cmd[6][32] = { + "XAPP_TEST", + "XAPP_RSP", + "XAPP_OK", + "XAPP_FAIL", + "XAPP_OK,NEXT", + "XAPP_FAIL,NEXT", +}; + +static char udp_contents = 0; + +#define SYS_IT_INTERVAL_SEC 0 +#define SYS_IT_INTERVAL_USEC (10*1000) +int remote_ip; +int test_port = 6999; +u8 time_count; + +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 Get_Peer_IP() +{ + char s[16]; + FILE *fp = NULL; + int i = 0; + char c; + + fp = fopen("./conf/sccp_test.conf", "r"); + if(fp != NULL) + { + while((c = fgetc(fp)) != EOF && c != ' ' && c != '\n' && c != '\t') + { + s[i++] = c; + if(i >= 16) + break; + } + s[i] = '\0'; + printf("Remote ip :%s\r\n", s); + remote_ip = inet_addr(s); + i = 0; + while((c = fgetc(fp)) != EOF && c != ' ' && c != '\n' && c != '\t') + { + s[i++] = c; + if(i >= 5) + break; + + } + s[i] = '\0'; + test_xapp.wait_time = strtol(s, NULL, 10); + printf("Waiting start test time :%ld\r\n", test_xapp.wait_time); + return 1; + } + return 0; +} + +void MS_mode_test() +{ + memset(&test_xapp, 0, sizeof(struct test_xapp_struct)); + //test_cmd=0; + //test_xapp.ms_mode = 0; + if(Get_Peer_IP()) + { + test_xapp.sock = get_socket(remote_ip, test_port); + } + else + { + printf("Get Peer IP Fail!\r\n"); + } +} + +void next_case() +{ + test_cmd++; + + test_xapp.test_result = 0; + test_xapp.peer_state = 0; + printf("\r\n ------------------------>> Next Case %d<<------------------ \r\n",(int )test_cmd); + if(test_cmd == XAPP_TEST_LAST_IDLE) + { + printf("\r\n\r\nTest over !\r\n\r\n"); + test_cmd = 0; + test_xapp.test_result = 7; + } +} + +void MS_test_timer() +{ + char msg[256]; + struct sockaddr_in sin_addr; + int addr_len; + u8 isdn[ISDN_LEN]; + u8 i; + char str[32]; + + sin_addr.sin_port = htons(test_port); + sin_addr.sin_addr.s_addr = remote_ip; + addr_len = sizeof(struct sockaddr_in); + udp_contents = 0; + memset(msg, 0, 256); + recvfrom(test_xapp.sock, (char *)msg, 256, 0, (struct sockaddr *)&sin_addr, &addr_len); + if(msg[0]) + { + //printf("Recv Test sycn msg :%s \r\n",msg); + for(i = 0; i <= 6; i++) + { + sprintf(str, "%s", test_sync_cmd[i]); + if(i >= 2) + sprintf(str, "%s:%d", test_sync_cmd[i], test_cmd); + if(strcmp(msg, str) == 0) + { + udp_contents = i + 1; + break; + } + } + + } + if(test_xapp.ms_mode == 0) + { + if(udp_contents == 0) + { + strcpy(msg, "XAPP_TEST"); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + } + if(udp_contents == 2) + { + test_xapp.local_ssn = 7; + test_xapp.peer_ssn = 6; + imap_reg_ssn(test_xapp.local_ssn); + AsciiToBcd(isdn, "918675557122001F", 16); + xapp_set_sccpadd(test_xapp.local_ssn, isdn, &test_xapp.local_add); + AsciiToBcd(isdn, "918675557122002F", 16); + xapp_set_sccpadd(test_xapp.peer_ssn, isdn, &test_xapp.peer_add); + printf(" XAPP Test Slave Started :%s\r\n", msg); + test_xapp.ms_mode = 2; + return; + } + else if(udp_contents == 1) + { + test_xapp.local_ssn = 6; + test_xapp.peer_ssn = 7; + imap_reg_ssn(test_xapp.local_ssn); + AsciiToBcd(isdn, "918675557122002F", 16); + xapp_set_sccpadd(test_xapp.local_ssn, isdn, &test_xapp.local_add); + AsciiToBcd(isdn, "918675557122001F", 16); + xapp_set_sccpadd(test_xapp.peer_ssn, isdn, &test_xapp.peer_add); + printf(" XAPP Test Master Started :%s\r\n", msg); + strcpy(msg, "XAPP_RSP"); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + test_xapp.ms_mode = 1; + return; + } + + } + if(test_xapp.ms_mode) + { + switch (test_xapp.test_result) + { + case 0: + + if(udp_contents == 4) + { + sprintf(msg, "XAPP_FAIL:%d,Next", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("[Test]:Fail!\r\n\r\n"); + next_case(); + return; + } + else if(udp_contents == 3) + { + printf("Peer Test OK !\r\n"); + test_xapp.peer_state = 1; + } + break; + case 1: //OK + printf("Local Test OK !\r\n"); + if(test_xapp.peer_state == 1) + { + sprintf(msg, "XAPP_OK,NEXT:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("[Test]: OK!\r\n\r\n"); + next_case(); + return; + } + sprintf(msg, "XAPP_OK:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("Send sycn msg : %s\r\n ",msg); + test_xapp.test_result = 3; + break; + case 2: + printf("Local Test Fail !\r\n"); + if(test_xapp.peer_state == 1) + { + sprintf(msg, "XAPP_FAIL,NEXT:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("[Test]:Fail!\r\n\r\n"); + next_case(); + return; + } + sprintf(msg, "XAPP_FAIL:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("Send sycn msg : %s\r\n ",msg); + test_xapp.test_result = 4; + break; + case 3: + case 4: + if( msg[0] ) + printf("udp recv pos 3:%s\r\n", msg); + if(udp_contents == 5 || udp_contents == 6) + { + (test_xapp.test_result == 3) ? printf("Peer Test OK !\r\n") : printf("Peer Test Fail !\r\n"); + (test_xapp.test_result == 3) ? printf("[Test]: OK!\r\n\r\n") : printf("[Test]: Fail!\r\n\r\n"); + next_case(); + return; + } + else if(udp_contents == 3) + { + sprintf(msg, "XAPP_OK,NEXT:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("Peer Test OK !\r\n"); + printf("[Test]: OK!\r\n\r\n"); + next_case(); + return; + } + else if(udp_contents == 4) + { + sprintf(msg, "XAPP_FAIL,NEXT:%d", test_cmd); + sendto(test_xapp.sock, (char *)msg, 32, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr)); + printf("Peer Test Fail !\r\n"); + printf("[Test]:Fail!\r\n\r\n"); + next_case(); + return; + } + break; + default: + break; + + } + + } +} + + + + +void moduleInit() +{ + //ioperm(0x27A,3,1); + MS_mode_test(); //master and slaver mode + debug_init(); + //#ifdef NEW_PLATFORM + iptrMainInit(); + /*#else + iptrans_init(); + #endif */ + mtp_shm_init(); + snmp_init(4957); + sccp_init(); + tcap_init(1024); + printf("MAP OP data size : %d\r\n,MAP OP Str size : %d\r\n",sizeof(MapOprData_struct),sizeof(MapOprSrv_struct)); + //printf("send para res size : %d \r\nProvid_SSInfo_struct : %d \r\nOdbData_struct :%d \r\n" ,sizeof(MapSP_Res), + //sizeof(Provid_SSInfo_struct),sizeof(struct OdbData_struct)); + printf("Sub_data_struct :%d ExtSsInfo_struct:%d \r\n",sizeof(Sub_data_struct),sizeof(ExtSsInfo_struct)); + printf("MapISD_Arg :%d \r\n",sizeof(MapISD_Arg)); + xap_init(1204); + extract_sri(); + printf("\r\nWating Peer test message ... \r\n"); +} + +void sysTimer_IRQ() +{ + sys_timer10ms = 1; +} + +static void SigactionSystem() +{ + struct sigaction action; + + action.sa_handler = sysTimer_IRQ; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + if(sigaction(SIGALRM, &action, NULL) < 0) + { + printf("sigactin sigalarm failed\n"); + } +} + +void SetFSMTimer() +{ + struct itimerval *ptv, tv; + + ptv = (struct itimerval *)&tv; + ptv->it_interval.tv_sec = 0; + ptv->it_interval.tv_usec = 10 * 1000; + ptv->it_value = ptv->it_interval; + setitimer(ITIMER_REAL, ptv, NULL); +} + +void moduleProc() +{ + iptrans_timer(); + snmp_timer(); + heartbeat_timer(); + mtp3_proc(); + sccp_timer(); + debug_rt(); + tcap_fsm(); + xap_fsm(); + Test_func(); + MS_test_timer(); +} + +int main() +{ + moduleInit(); + SigactionSystem(); + SetFSMTimer(); + + sys_timer10ms = 1; + while(1) + { + if(sys_timer10ms) + { + sys_timer10ms = 0; + moduleProc(); + } + if(sys_timer10ms == 0) + usleep(1); + } + return 1; +} diff --git a/omc/plat/xapp/ut/xapp_test/xapp_main.h b/omc/plat/xapp/ut/xapp_test/xapp_main.h new file mode 100644 index 0000000..ea165aa --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_main.h @@ -0,0 +1,32 @@ +/* XAPP coding test function head file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#ifndef _XAPP_MAIN_ + +#define _XAPP_MAIN_ + +#include "../../public/asn1.h" +#include "../../public/includes.h" +#include "../../iptrans/iptrans.h" +#include "../../mtp3/mtp3.h" +#include "../../snmp/snmp.h" +#include "../../sccp/sccp.h" +#include "../../tcap/tcap_public.h" +#include "../../tcap/tcap_proc.h" +#include "../../xapp/mapp/map_const.h" +#include "../../xapp/mapp/map_code.h" +#include "../../xapp/mapp/map_acn.h" +#include "../../xapp/mapp/map_struct.h" +#include "../../xapp/mapp/map_public.h" +#include "../../xapp/capp/cap_public.h" +#include "../../xapp/ixap.h" +#include "../../debug/debug.h" +#include "../../snmp/snmp.h" +#include "../../xapp/capp/cap_msg.h" +#include "../../xapp/xap_provider.h" +#include "../../xapp/conv_prefix.h" +#include "xapp_op_test.h" + +#endif diff --git a/omc/plat/xapp/ut/xapp_test/xapp_op_test.c b/omc/plat/xapp/ut/xapp_test/xapp_op_test.c new file mode 100644 index 0000000..05b9b29 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_op_test.c @@ -0,0 +1,2067 @@ +/* XAPP coding test function c file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#include "xapp_main.h" +#include "xapp_coding_test.h" +extern int xapp_test_state; + +u32 time_count2 = 0, time_count3 ,time_count4=0; + +void test_pass() +{ + if( time_count4++ >200 ) + { + time_count4 =0; + test_xapp.fsm_state = 0; + test_xapp.test_result = 1; + if( !test_xapp.xapp_type ) + send_mapp_close(test_xapp.did); + else + send_capp_close(test_xapp.did); + } +} + +void test_fail() +{ + if( time_count4++ >200 ) + { + test_xapp.fsm_state = 0; + test_xapp.test_result = 2; + if( !test_xapp.xapp_type ) + send_mapp_close(test_xapp.did); + else + send_capp_close(test_xapp.did); + } +} + +void MAPP_Test_SendPara_Proc() +{ + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapSP_Arg *sp_arg; + struct MapSP_Res *sp_res; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + u8 bcd_buf_h[ISDN_LEN * 2]; + + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + sp_arg = &srv_ptr->msg_list.sp_arg; + sp_arg->param_flag = 0x03; + sp_arg->ReqPara_num = 2; + sp_arg->ReqPara[0] = 1; + sp_arg->ReqPara[1] = 2; + sp_arg->sub_id.choice_flag = 1; + AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2); + memcpy(sp_arg->sub_id.id_choice.imsi, bcd_buf_h, IMSI_LEN); + + send_mapp_open_req(did); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send SendparaArg !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SendParam) + { + printf("-->>: Recv Sendpara Res decode err!\r\n"); + test_fail(); + + return; + } + printf("-->>:Recv Sendpara Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SendParam) + { + printf("-->>: Recv Sendpara Arg decode err!\r\n"); + test_fail(); + + return; + } + printf("-->>: Recv Sendpara Arg !\r\n"); + test_xapp.fsm_state++; + test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id; + test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + struct Sub_data_struct *sub_data; + + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + sp_res = &srv_ptr->msg_list.sp_res; + + sp_res->param_flag = 0x0f; + sp_res->sendparamlist_num = 2; + sp_res->sendparalist[0].choice_flag = 1; + memcpy(sp_res->sendparalist[0].SP_Res_Choice.imsi, "460022157127015", IMSI_LEN); + sp_res->sendparalist[1].choice_flag = 4; + + sub_data = &sp_res->sendparalist[1].SP_Res_Choice.sub_data; + sub_data->param_flag = 0xFF; + memcpy(sub_data->msisdn, "8675557127015", ISDN_LEN); + sub_data->category = 1; + sub_data->sub_status = 0; + sub_data->bearer_data= 1234; + sub_data->tele_data=12; + sub_data->zc_list.list_len = 2; + strcpy(sub_data->zc_list.zone_code[0], "HI"); + strcpy(sub_data->zc_list.zone_code[1], "OK"); + sub_data->odb_data.param_flag = 0x03; + sub_data->odb_data.odb_general = 0x1234; + sub_data->odb_data.odb_hplmn = 0xFEDC; + //sub_data->ss_info_num = 4; if 4 the map total length 192, mtp3 not support(<256) + //sub_data->ss_info_num = 2; + + sub_data->ss_info.param_flag = 1; + + sub_data->ss_info.call_info.param_flag = 0x03; + sub_data->ss_info.call_info.ss_code[0] = 4; + sub_data->ss_info.call_info.ss_code[1] = 4; + sub_data->ss_info.call_info.ss_status[0] = 2; + sub_data->ss_info.call_info.ss_status[1] = 4; + sub_data->ss_info.call_info.bs_code[0].bearer_code = 1; + sub_data->ss_info.call_info.bs_code[0].tele_code = 2; + sub_data->ss_info.call_info.bs_code[1].bearer_code = 3; + sub_data->ss_info.call_info.bs_code[1].tele_code = 4; + + /* + sub_data->ss_info[1].choice_flag = 4; + sub_data->ss_info[1].choice.cug_info.param_flag = 0x03; + sub_data->ss_info[1].choice.cug_info.feat_list.list_len = 1; + sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].param_flag = 0x07; + sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].bs.choice_flag = 1; + sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].bs.choice.bear_service = 1; + sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].cug_indicator = 1234; + sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].cug_restric = 12; + sub_data->ss_info[1].choice.cug_info.subs_list.list_len = 1; + sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].param_flag = 0x0f; + sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].bs.choice_flag = 1; + sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].bs.choice.bear_service = 1; + sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_index = 1111; + memcpy(sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_lock, "1234", 4); + sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_opt = 0; + */ + /* + sub_data->ss_info.fwd_info.param_flag = 0x01; + sub_data->ss_info.fwd_info.ss_code[0] = 1; + sub_data->ss_info.fwd_info.fwd_feat[0].param_flag = 0x3F; + sub_data->ss_info.fwd_info.fwd_feat[0].bs_code.param_flag = 1; + sub_data->ss_info.fwd_info.fwd_feat[0].bs_code.tele_code = 1; + sub_data->ss_info.fwd_info.fwd_feat[0].ss_status = 1; + memcpy(sub_data->ss_info.fwd_info.fwd_feat[0].fwdto_num+1, "8675557127016", ISDN_LEN); + sub_data->ss_info.fwd_info.fwd_feat[0].fwdto_num[0] = ISDN_LEN; + sub_data->ss_info.fwd_info.fwd_feat[0].norc_time = 1; + sub_data->ss_info.fwd_info.fwd_feat[0].fwd_option = 2; + + + sub_data->ss_info.ss_data.param_flag = 0x01; + sub_data->ss_info.ss_data.ss_code[0] = 1; + sub_data->ss_info.ss_data.ss_status[0] = 1; + sub_data->ss_info.ss_data.bs_code[0].param_flag = 3; + sub_data->ss_info.ss_data.bs_code[0].tele_code = 2; + sub_data->ss_info.ss_data.bs_code[0].bearer_code = 2; + sub_data->ss_info.ss_data.subs_opt[0].choice_flag = 1; + sub_data->ss_info.ss_data.subs_opt[0].choice.clires_opt = 2; + */ + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send SendparaRes !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } +} + +void MAPP_Test_NotSubPresent_Proc() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapNP_Arg *np_arg; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + u8 bcd_buf_h[ISDN_LEN * 2]; + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + np_arg = &srv_ptr->msg_list.np_arg; + np_arg->param_flag = 0x01; + AsciiToBcd(bcd_buf_h, "460022157127012", IMSI_LEN * 2); + memcpy(np_arg->imsi, bcd_buf_h, IMSI_LEN); + np_arg->imsi[IMSI_LEN - 1] = np_arg->imsi[IMSI_LEN - 1] | 0xf0; + + send_mapp_open_req(did); + build_xapp_msg(); + printf("<<--: Send NotSubPresent ,not need to response !\r\n"); + send_mapp_oprdata(data_ptr, 1); + test_xapp.fsm_state++; + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != NoteSubPrnt) + { + printf("-->>: Recv NotSubPresent decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv NotSubPresent ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } +} + +void MAPP_Test_ProcessUSSD_Proc() +{ + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapPUSSD_Arg *ussd_arg; + struct MapPUSSD_Res *ussd_res; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ussd_arg = &srv_ptr->msg_list.pussd_arg; + ussd_arg->ussd_len = 3; + memcpy(ussd_arg->ussd_data, "123", 3); + ussd_arg->param_flag = 1; + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send ProcessUSSD Arg!\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != ProcUnstrctSSData) + { + printf("-->>: Recv ProcessUSSD Res decode err!\r\n"); + return; + } + printf("-->>: Recv ProcessUSSD Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != ProcUnstrctSSData) + { + printf("-->>: Recv ProcessUSSD arg decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv ProcessUSSD arg !\r\n"); + test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id; + test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type; + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ussd_res = &srv_ptr->msg_list.pussd_res; + + ussd_res->ussd_len = 3; + memcpy(ussd_res->ussd_data, "123", 3); + ussd_res->param_flag = 1; + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send ProcessUSSD Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did); + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } +} + +void MAPP_Test_BeginSubActivity() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapBSA_Arg *bsa_arg; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + u8 bcd_buf_h[ISDN_LEN * 2]; + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + bsa_arg = &srv_ptr->msg_list.bsa_arg; + bsa_arg->param_flag = 0x03; + AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2); + memcpy(bsa_arg->imsi, bcd_buf_h, IMSI_LEN); + bsa_arg->orgenty_num_len = 9; + memcpy(bsa_arg->orgenty_num, "123456789", 9); + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send BegineSubActivity ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != BeginSubAct) + { + printf("-->>: Recv BegineSubActivity decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv BegineSubActivity ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + +void MAPP_Test_RegisterSS() +{ + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapRSS_Arg *regss_arg; + struct MapRSS_Res *regss_res; + struct MapComSrv_struct map_com; + /* + u8 isdn1[9] = {0x96, 0x64, 0x00, 0x22, + 0x51, 0x17 ,0x72, 0x10, 0xF5}; + u8 isdn2[9] = {0x91, 0x68, 0x57, 0x55, + 0x17, 0x22, 0x00, 0xF1}; + */ + char dst_ref[54], local_ref[54]; + u8 imsi[9] , isdn[9]; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + regss_arg = &srv_ptr->msg_list.rss_arg; + + regss_arg->param_flag = 0x1F; + regss_arg->ss_code = 0x28; + regss_arg->bs_code.param_flag = 0x01 ; + regss_arg->bs_code.tele_code = 0x0a ; + regss_arg->fwdto_num[0] = ISDN_LEN; + memcpy( regss_arg->fwdto_num+1 , "12345678", 8 ); + regss_arg->norc_time = 30 ; + regss_arg->default_prio = 20 ; + + + + map_com.message_type = MAP_OPEN; + map_com.message_flag = MAP_REQUEST; + map_com.port_id = 0; + map_com.dialogue_id = test_xapp.did; + map_com.dlg_list.open_arg.acn_data.acn = 18; + map_com.dlg_list.open_arg.acn_data.acn_ver = 1; + memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR)); + memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR)); + map_com.dlg_list.open_arg.peerref_len = IMSI_LEN+1; + map_com.dlg_list.open_arg.localref_len = ISDN_LEN; + strcpy( local_ref , "8675557127001"); + isdn_ston( isdn , local_ref); + map_com.dlg_list.open_arg.local_reference[0] = 0x91; + isdn_ntoa( (u8 *)&map_com.dlg_list.open_arg.local_reference+1 , isdn); + strcpy( dst_ref , "460022157127001"); + imsi_ston( imsi , dst_ref); + map_com.dlg_list.open_arg.peer_reference[0] = 0x96; + imsi_ntoa( (u8 *)&map_com.dlg_list.open_arg.peer_reference+1 , imsi); + map_com.dlg_list.open_arg.param_flag = 0x1F; + send_mapp_comdata(&map_com, 1); + printf("<<--: Send OpenReq !\r\n"); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send Register SS Arg!\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != RegSS) + { + printf("-->>: Recv Register SS Res decode err!\r\n"); + return; + } + printf("-->>: Recv Register SS Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + struct MapOpen_Arg *open_ptr; + + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + open_ptr = (MapOpen_Arg *) &test_xapp.xapp.mapp.com_ptr.dlg_list.open_arg; + if( (open_ptr->param_flag & 0x14) == 0x14) + { + char dst_ref[54], local_ref[54]; + u8 imsi[9] , isdn[9]; + isdn_aton( isdn , open_ptr->local_reference+1); + isdn_ntos( local_ref , isdn ); + imsi_aton( imsi , open_ptr->peer_reference+1); + imsi_ntos( dst_ref , imsi ); + printf("dst ref: %s local_ref :%s\n",dst_ref, local_ref); + + } + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != RegSS) + { + printf("-->>: Recv Register SS arg decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv Register SS arg!\r\n"); + test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id; + test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type; + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + regss_res = &srv_ptr->msg_list.rss_res; + regss_res->param_flag = 0x01; + regss_res->ss_info.choice_flag = 0x01; + regss_res->ss_info.choice.fwd_info.param_flag = 0x01; + regss_res->ss_info.choice.fwd_info.ss_code = 1; + regss_res->ss_info.choice.fwd_info.fwd_feat.param_flag = 0x3F; + regss_res->ss_info.choice.fwd_info.fwd_feat.bs_code.param_flag = 1; + regss_res->ss_info.choice.fwd_info.fwd_feat.bs_code.tele_code = 1; + regss_res->ss_info.choice.fwd_info.fwd_feat.ss_status = 1; + memcpy(regss_res->ss_info.choice.fwd_info.fwd_feat.fwdto_num+1, "8675557127016", ISDN_LEN); + regss_res->ss_info.choice.fwd_info.fwd_feat.fwdto_num[0] = ISDN_LEN; + regss_res->ss_info.choice.fwd_info.fwd_feat.norc_time = 1; + regss_res->ss_info.choice.fwd_info.fwd_feat.fwd_option = 2; + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send Register SS res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did); + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } +} + +void MAPP_Test_PeformHandOver() +{ + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapHO_Arg *ho_arg; + struct MapHO_Res *ho_res; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ho_arg = &srv_ptr->msg_list.ho_arg; + ho_arg->param_flag = 0x3F; + memcpy(ho_arg->tgt_cellID, "1234567", 7); + memcpy(ho_arg->srv_cellID, "7654321", 7); + memcpy(ho_arg->chl_type, "0123456789", 7); + memcpy(ho_arg->class_mark, "12", 2); + ho_arg->ho_priority = 1; + memcpy(ho_arg->kc, "12345678", 8); + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send PerformHandOver Arg!\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformHo) + { + printf("-->>: Recv PerformHandOver Res decode err!\r\n"); + return; + } + printf("-->>: Recv PerformHandOver Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformHo) + { + printf("-->>: Recv PerformHandOver arg decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv PerformHandOver arg!\r\n"); + test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id; + test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type; + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ho_res = &srv_ptr->msg_list.ho_res; + ho_res->ho_num_len = 9; + memcpy(ho_res->ho_num, "123456789", 9); + ho_res->access_singal_info.protocol_id = 2; + ho_res->access_singal_info.singal_info_len = 3; + memcpy(ho_res->access_singal_info.signal_info, "123", 3); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send PerformHandOver res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did); + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } +} + + + +void MAPP_Test_CancelLoc_Proc(u8 ver) +{ + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapCL_Arg *cl_arg; + struct MapCL_Res *cl_res; + + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + test_xapp.xapp_type = 0; + + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + srv_ptr->version = 3; + + cl_arg = &srv_ptr->msg_list.cl_arg; + cl_arg->param_flag = 0x03; + cl_arg->id.choice_flag = 2; + memcpy( cl_arg->id.choice.imsi_withlmsi.imsi ,"1234", IMSI_LEN); + memcpy( cl_arg->id.choice.imsi_withlmsi.lmsi , "1234",LMSI_LEN); + cl_arg->type = 1; + + send_mapp_open_req(did); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send CancelLocation !\r\n"); + test_xapp.fsm_state++; + if( ver == 1) + { + test_xapp.fsm_state = 2; + printf(" Cancellocation V1 ,need not to response !\r\n"); + } + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + u8 isok = extract_xapp_msg(); + if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CancelLoc) + { + printf("-->>: Recv CancelLocation Res decode err!\r\n"); + test_fail(); + return; + } + printf("-->>:Recv CancelLocation Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + u8 isok = extract_xapp_msg(); + if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CancelLoc) + { + printf("-->>: Recv Cancellocation Arg decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv Cancellocation Arg !\r\n"); + test_xapp.fsm_state++; + test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id; + test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type; + if( test_xapp.xapp.mapp.map_opr.version == 1) + { + test_xapp.fsm_state = 3; + printf("Cancellocation V1 ,need not to response !\r\n"); + } + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + //srv_ptr->version = 3; + + cl_res = &srv_ptr->msg_list.cl_res; + + cl_res->param_flag = 0x00; + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send SendparaRes !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } +} + + + + +void MAPP_Test_PerformSubsequenthandover() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapPFSHO_Arg *ho_arg; + struct MapPFSHO_Res *ho_res; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ho_arg = &srv_ptr->msg_list.pfsho_arg; + ho_arg->param_flag = 0x0f; + + + memcpy( ho_arg->target_id , "1234567",GCID_LEN); + memcpy( ho_arg->service_id , "1234567",GCID_LEN); + ho_arg->msc_num[0]= ISDN_LEN; + memcpy( ho_arg->msc_num+1 , "01234567" ,ISDN_LEN); + memcpy( ho_arg->classmark_info ,"12" ,2 ); + + + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send Preformsubsequent handover Arg!\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformSubsHo) + { + printf("-->>: Recv Preformsubsequent handover Res decode err!\r\n"); + test_fail(); + + return; + } + printf("-->>:Recv Preformsubsequent handover Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformSubsHo) + { + printf("-->>: Recv Preformsubsequent handover Arg decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv Preformsubsequent handover Arg\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + //srv_ptr->version = 3; + + ho_res = &srv_ptr->msg_list.pfsho_res; + + ho_res->param_flag = 1; + ho_res->access_sig_info.param_flag = 3; + ho_res->access_sig_info.prt_id =1; + ho_res->access_sig_info.siginfo.siginfo_len =2 ; + memcpy( ho_res->access_sig_info.siginfo.signal_info , "12",2); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send Preformsubsequent handover Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + + +void MAPP_Test_noteinernalhandover() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapNIHO_Arg *ho_arg; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ho_arg = &srv_ptr->msg_list.niho_arg; + ho_arg->param_flag = 0x07; + ho_arg->ho_type =1; + memcpy(ho_arg->target_id , "1234567" , GCID_LEN); + ho_arg->channel_id.param_flag = 3; + ho_arg->channel_id.prt_id =2; + ho_arg->channel_id.siginfo.siginfo_len =2; + memcpy( ho_arg->channel_id.siginfo.signal_info , "12" ,2 ); + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send noteinernalhandover ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != NoteInterHo) + { + printf("-->>: Recv noteinernalhandover decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv noteinernalhandover ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + + +void MAPP_Test_tracesubscriberactivity() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapTSA_Arg *tsa_arg; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + u8 bcd_buf_h[ISDN_LEN * 2]; + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + tsa_arg = &srv_ptr->msg_list.tsa_arg; + tsa_arg->param_flag = 0x1f; + AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2); + memcpy(tsa_arg->imsi, bcd_buf_h, IMSI_LEN); + memcpy( tsa_arg->trace_ref , "12",2); + tsa_arg->trace_type = 1; + tsa_arg->omc_id_len =2; + memcpy( tsa_arg->omc_id ,"12", 2 ); + memcpy( tsa_arg->call_ref , "123" ,3 ); + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send tracesubscriberactivity ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != TraceSubAct) + { + printf("-->>: Recv tracesubscriberactivityy decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv tracesubscriberactivity ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + +void MAPP_Test_FowardSM() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapFSM_Arg *fsm_arg; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + fsm_arg = &srv_ptr->msg_list.fsm_arg; + fsm_arg->param_flag = 0x0f; + fsm_arg->more_msgtosend =1; + fsm_arg->sm_rp_da_choice = 5; + fsm_arg->sm_rp_da.noms_rp_da =1; + + fsm_arg->sm_rp_oa_choice =1; + fsm_arg->sm_rp_oa.msisdn[0 ] = ISDN_LEN; + fsm_arg->sm_rp_oa.msisdn[0] =ISDN_LEN; + memcpy(fsm_arg->sm_rp_oa.msisdn+1 , "12345678" , ISDN_LEN ); + + fsm_arg->sm_rp_ui_len =2; + memcpy(fsm_arg->sm_rp_ui , "12",2); + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send FowardSM ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != FwdSM) + { + printf("-->>: Recv FowardSM decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv FowardSM ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + +void MAPP_Test_SendRoutinginfoforSM() +{ + + struct MapOprData_struct *data_ptr; + struct MapOprSrv_struct *srv_ptr; + struct MapRIFSMV1_Arg *ssm_arg; + struct MapRIFSMV1_Res *ssm_res; + + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = map_get_dialogueid(test_xapp.local_ssn); + if(did && map_check_sendopr(did) && map_check_sendcom(did)) + { + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + test_xapp.did = did; + srv_ptr->dialogue_id = test_xapp.did; + srv_ptr->invoke_id = map_get_invokeid(test_xapp.did); + srv_ptr->message_flag = MAP_REQUEST; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->version = 1; + srv_ptr->port_id = 0; + srv_ptr->version = 1; + + ssm_arg = &srv_ptr->msg_list.rifsm_v1_arg; + ssm_arg->param_flag = 0x0f; + ssm_arg->msisdn[0] = ISDN_LEN; + memcpy(ssm_arg->msisdn+1,"12345678", ISDN_LEN); + ssm_arg->sc_add[0]= ISDN_LEN; + memcpy(ssm_arg->sc_add+1,"12345678",ISDN_LEN); + ssm_arg->sm_rp_pri =1; + ssm_arg->tele_service =1; + + send_mapp_open_req(did); + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send sendrounting info sm arg !\r\n"); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) // wait response + { + u8 isok = extract_xapp_msg(); + if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SndRoutInfoForSM) + { + printf("-->>: Recv sendrounting info sm decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv sendrounting info sm arg !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_mapp_open_conf(); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did)) + { + if( extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SndRoutInfoForSM) + { + printf("-->>: Recv sendrounting info sm decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv sendrounting info sm arg !\r\n"); + test_xapp.fsm_state++; + } + break; + case 2: + if(map_check_sendopr(test_xapp.did)) + { + u8 bcd_buf_h[ISDN_LEN * 2]; + + test_xapp.xapp_type = 0; + data_ptr = &test_xapp.xapp.mapp.data_ptr; + srv_ptr = &test_xapp.xapp.mapp.map_opr; + + srv_ptr->invoke_id = test_xapp.invoke_id; + srv_ptr->message_flag = MAP_RESPONSE; + srv_ptr->message_type = test_xapp.operation_type; + srv_ptr->port_id = 0; + //srv_ptr->version = 3; + + ssm_res = &srv_ptr->msg_list.rifsm_v1_res; + ssm_res->param_flag = 0x03; + AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2); + memcpy(ssm_res->imsi, bcd_buf_h, IMSI_LEN); + ssm_res->loc_info.param_flag = 0x02; + memcpy(ssm_res->loc_info.imsi, bcd_buf_h, IMSI_LEN); + ssm_res->loc_info.choice_flag = 1; + ssm_res->loc_info.choice.roaming_num[0] = 8; + memcpy( ssm_res->loc_info.choice.roaming_num+1 , "87654321", 9 ); + + build_xapp_msg(); + send_mapp_oprdata(data_ptr, 1); + printf("<<--: Send sendrounting info sm Res !\r\n"); + test_xapp.fsm_state++; + } + break; + case 3: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + + } +} + + + + +void CAPP_Test_InitialDP() +{ + struct CapInitialDP *init_dp; + struct MapOprData_struct *data_ptr; + struct CapArg *cap_opr; + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = cap_get_dialogueid(test_xapp.local_ssn); + if(did && cap_check_sendopr(did) && cap_check_sendcom(did)) + { + int len; + + //pcapmsg = &test_xapp.xapp.capp.capmsg; + cap_opr = &test_xapp.xapp.capp.cap_opr; + data_ptr = &test_xapp.xapp.capp.data_ptr; + + test_xapp.xapp_type = 1; + test_xapp.did = did; + cap_opr->dialogue_id = test_xapp.did; + cap_opr->invoke_id = test_xapp.invoke_id = map_get_invokeid(did); + cap_opr->message_flag = MAP_REQUEST; + cap_opr->ocode = test_xapp.operation_type; + cap_opr->version = 0; + init_dp = &cap_opr->msg_list.initialDPArg; + + init_dp->serviceKey = 1; + init_dp->optional_flag = 0x0007; + init_dp->calledPartyNumber[0] = 4; + memcpy(&init_dp->calledPartyNumber[1], "1234", 4); + init_dp->callingPartyNumber[0] = 4; + memcpy(&init_dp->callingPartyNumber[1], "1234", 4); + init_dp->callingPartysCategory = 2; + send_capp_open_req(50, 1, did); + + len = build_xapp_msg(); + printf("<<--: Send InitialDP ,not need to response !\r\n"); + send_capp_oprdata(data_ptr, 1); + //send_capp_oprdata(pcapmsg,len); + test_xapp.fsm_state++; + /* + init_dp->serviceKey = 1; + init_dp->optional_flag = 0x947D; + memcpy( init_dp->calledPartyNumber , "46002215712701",IMSI_LEN*2); + //memcpy( init_dp->callingPartyNumber , "46002215712701",IMSI_LEN*2); + init_dp->callingPartysCategory = 2; + //memcpy( init_dp->iPSSPCapabilities ,"123",3); + memcpy( init_dp->locationNumber , "46002215712701" , IMSI_LEN*2); + memcpy( init_dp->originalCalledPartyID , "123456" , 6); + memcpy( init_dp->highLayerCompatibility , "123" , 3); + //memcpy( init_dp->additionalCallingPartyNumber , "46002215712701" , IMSI_LEN*2); + memcpy( init_dp->redirectingPartyID , "123" , 3); + //memcpy( init_dp->redirectionInformation , "123456" , 6); + memcpy( init_dp->iMSI , "46002215712701" , IMSI_LEN*2); + //init_dp->subscriberState_ch = 'a'; + init_dp->ext_basicServiceCode_ch = 'b'; + //memcpy( init_dp->callReferenceNumber , "46002215712701" , IMSI_LEN*2); + //CapBearerCapability bearerCapability; + //CapEventTypeBCSM eventTypeBCSM; + //CapSubscriberState subscriberState; + //CapLocationInformation locationInformation; + //CapExt_BasicServiceCode ext_basicServiceCode; + send_capp_open_req( test_xapp.operation_type , 1 , did ); + build_xapp_msg(); + printf("<<--: Send InitialDP ,not need to response !\r\n"); + send_capp_oprdata((u8 *)&pcapmsg->msgContent[5]); + test_xapp.fsm_state++; + */ + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_capp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_capp_open_conf(test_xapp.operation_type, 1, did); + test_xapp.fsm_state++; + } + if((time_count3++ % 100) == 13) + { + printf("Timer expired!\r\n"); + test_fail(); + return; + } + break; + case 1: + if(recv_capp_oprdata(&test_xapp.xapp.capp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CAP_OC_InitialDP) + { + printf("-->>: Recv InitialDP decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv InitialDP ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + if((time_count3++ % 100) == 13) + { + printf("Timer expired!\r\n"); + test_fail(); + return; + } + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + if((time_count3++ % 100) == 13) + { + printf("Timer expired!\r\n"); + test_fail(); + return; + } + break; + default: + break; + } + } +} + +void CAPP_Test_ActivityTest() //NULL +{ + +} + +void CAPP_Test_Connect() +{ + /* + struct CapConnect_v1 *connect; + struct MapOprData_struct *data_ptr; + struct CapArg *cap_opr; + int did; + + test_xapp.test_result = 0; + if(test_xapp.ms_mode == 1) // master + { + switch (test_xapp.fsm_state) + { + case 0: + did = cap_get_dialogueid(test_xapp.local_ssn); + if(did && cap_check_sendopr(did) && cap_check_sendcom(did)) + { + int len; + + cap_opr = &test_xapp.xapp.capp.cap_opr; + data_ptr = &test_xapp.xapp.capp.data_ptr; + + test_xapp.xapp_type = 1; + test_xapp.did = did; + cap_opr->dialogue_id = test_xapp.did; + cap_opr->invoke_id = test_xapp.invoke_id = map_get_invokeid(did); + cap_opr->message_flag = MAP_REQUEST; + cap_opr->ocode = test_xapp.operation_type; + cap_opr->version = 0; + + connect = &cap_opr->msg_list.connectArg_v1; + + connect->destinationRoutingAddress[0] = 4; + memcpy(&connect->destinationRoutingAddress[1], "1234", 4); + connect->optional_flag = 0xC3; + connect->originalCalledPartyID[0] = 4; + memcpy(&connect->originalCalledPartyID[1], "1234", 4); + connect->genericNumbers_v1_len = 1; + connect->genericNumber_v1[0][0] = 4; + memcpy(&connect->genericNumber_v1[0][1], "1234", 4); + connect->suppressionOfAnnouncement = 1; + connect->oCSIApplicable = 0; + + send_capp_open_req(50, 1, did); + + len = build_xapp_msg(); + printf("<<--: Send Connect ,not need to response !\r\n"); + send_capp_oprdata(data_ptr, 1); + test_xapp.fsm_state++; + + } + break; + case 1: + if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3) + { + test_pass(); + } + break; + default: + break; + } + } + else if(test_xapp.ms_mode == 2) // slaver + { + switch (test_xapp.fsm_state) + { + case 0: + if(get_capp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn)) + { + test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id; + send_capp_open_conf(test_xapp.operation_type, 1, did); + test_xapp.fsm_state++; + } + break; + case 1: + if(recv_capp_oprdata(&test_xapp.xapp.capp.data_ptr, test_xapp.did)) + { + if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CAP_OC_Connect) + { + printf("-->>: Recv Connect decode err!\r\n"); + test_fail(); + return; + } + printf("-->>: Recv Connect ,not need to response !\r\n"); + test_xapp.fsm_state++; + } + case 2: + if(map_check_sendcom(test_xapp.did)) + { + test_pass(); + } + break; + default: + break; + } + } + + */ +} + +void CAPP_Test_Continue() //NULL +{ + +} + +void CAPP_Test_EventReportBCSM() //==V2 +{ + +} + +void CAPP_Test_ReleaseCall() //==V2 +{ + +} + +void CAPP_Test_RequestReportBCSMEvent() //==V2 +{ + +} + +void Test_fsm() +{ + if(test_xapp.operation_type || (!test_xapp.operation_type && test_cmd == CAPP_TEST_INITDP)) + { + switch (test_xapp.operation_type) + { + + /*-------------->>>>>>>>>>>>> MAP V1 Test <<<<<<<<<<<<<<<<<<<<<-------------*/ + case SendParam: // send parameters + MAPP_Test_SendPara_Proc(); + break; + case NoteSubPrnt: // not subscriber present + MAPP_Test_NotSubPresent_Proc(); + break; + case ProcUnstrctSSData: // process unstructure SS data + MAPP_Test_ProcessUSSD_Proc(); + break; + case BeginSubAct: // beging subscriber activity + MAPP_Test_BeginSubActivity(); + break; + case PerformHo: // perform handover + MAPP_Test_PeformHandOver(); + break; + case RegSS: + MAPP_Test_RegisterSS(); + break; + case PerformSubsHo: + MAPP_Test_PerformSubsequenthandover(); + break; + case NoteInterHo: + MAPP_Test_noteinernalhandover(); + break; + case TraceSubAct: + MAPP_Test_tracesubscriberactivity(); + break; + case FwdSM: + MAPP_Test_FowardSM(); + break; + case SndRoutInfoForSM: + MAPP_Test_SendRoutinginfoforSM(); + break; + case CancelLoc: + if( test_cmd == MAPP_TEST_CANCELLOCv3 ) + MAPP_Test_CancelLoc_Proc(3); + else + MAPP_Test_CancelLoc_Proc(1); + break; + case CAP_OC_InitialDP: + CAPP_Test_InitialDP(); + break; + case CAP_OC_ActivityTest: + CAPP_Test_ActivityTest(); + break; + case CAP_OC_Connect: + CAPP_Test_Connect(); + break; + case CAP_OC_Continue: + CAPP_Test_Continue(); + break; + case CAP_OC_EventReportBCSM: + CAPP_Test_EventReportBCSM(); + break; + case CAP_OC_ReleaseCall: + CAPP_Test_ReleaseCall(); + break; + case CAP_OC_RequestReportBCSMEvent: + CAPP_Test_RequestReportBCSMEvent(); + break; + + /*-------------->>>>>>>>>>>>> MAP V1 Test <<<<<<<<<<<<<<<<<<<<<-------------*/ + default: + break; + } + } + +} + +void Test_func() +{ + if(test_xapp.ms_mode > 0 && !test_xapp.test_result && test_xapp.test_result != 7) + { + switch (test_cmd) + { + + case 0: + //printf("time_count2 :%d",time_count2); + if(test_xapp.ms_mode == 2) + { + printf("\r\n\r\nStart xapp Test ......\r\n\r\n"); + //test_cmd = MAPP_TEST_SENDPARA; + test_cmd = MAPP_TEST_REGISTERSS; + break; + } + else if((time_count2++) == test_xapp.wait_time) + { + printf("\r\n\r\nStart xapp Test ......\r\n\r\n"); + //test_cmd = MAPP_TEST_SENDPARA; + test_cmd = MAPP_TEST_REGISTERSS; + } + break; + case MAPP_TEST_SENDPARA: + //test_xapp.operation_type = NoteSubPrnt; + test_xapp.operation_type = SendParam; + break; + case MAPP_TEST_NOTSUBPRE: + test_xapp.operation_type = NoteSubPrnt; + break; + case MAPP_TEST_PROCUSSD: + test_xapp.operation_type = ProcUnstrctSSData; + break; + case MAPP_TEST_BEGINACT: + test_xapp.operation_type = BeginSubAct; + break; + case MAPP_TEST_HANDOVER: + test_xapp.operation_type = PerformHo; + break; + case MAPP_TEST_PERFORMSUBSEQUENTHANDOVER: + test_xapp.operation_type = PerformSubsHo; + break; + case MAPP_TEST_NOTEINERNALHANDOVER: + test_xapp.operation_type = NoteInterHo; + break; + case MAPP_TEST_REGISTERSS: + test_xapp.operation_type = RegSS; + break; + case MAPP_TEST_TRACESUBSCRIBERACTIVITY: + test_xapp.operation_type = TraceSubAct; + break; + case MAPP_TEST_FOWARDSM: + test_xapp.operation_type = FwdSM; + break; + case MAPP_TEST_SENDROUTINGINFOFORSM: + test_xapp.operation_type = SndRoutInfoForSM; + break; + case MAPP_TEST_CANCELLOC: + case MAPP_TEST_CANCELLOCv3: + test_xapp.operation_type = CancelLoc; + break; + case CAPP_TEST_INITDP: + test_xapp.operation_type = CAP_OC_InitialDP; + break; + + //case CAPP_TEST_ACTTEST: + // test_xapp.operation_type = CAP_OC_ActivityTest ; + // break; + case CAPP_TEST_CONNECT: + test_xapp.operation_type = CAP_OC_Connect; + break; + //case CAPP_TEST_CONTINUE: + // test_xapp.operation_type = CAP_OC_Continue; + // break; + //case CAPP_TEST_REPORTBCSM: + // test_xapp.operation_type = CAP_OC_EventReportBCSM; + // break; + //case CAPP_TEST_CALLREL: + // test_xapp.operation_type = CAP_OC_ReleaseCall; + // break; + case CAPP_TEST_REQREPORTBCSM: + test_xapp.operation_type = CAP_OC_RequestReportBCSMEvent; + break; + case XAPP_TEST_LAST_IDLE: + break; + default: + break; + } + Test_fsm(); + } + +} diff --git a/omc/plat/xapp/ut/xapp_test/xapp_op_test.h b/omc/plat/xapp/ut/xapp_test/xapp_op_test.h new file mode 100644 index 0000000..b570928 --- /dev/null +++ b/omc/plat/xapp/ut/xapp_test/xapp_op_test.h @@ -0,0 +1,39 @@ +/* XAPP coding test function head file */ +/* created by Liu Wei 2006-01-13 */ +/* Version 1.0 */ +/* ------------------------------------- */ + +#ifndef _XAPP_OP_TEST_ + +#define _XAPP_OP_TEST_ + +enum XAPP_TEST_OP +{ + MAPP_TEST_SENDPARA =1, + MAPP_TEST_NOTSUBPRE, + MAPP_TEST_PROCUSSD, + MAPP_TEST_BEGINACT, + MAPP_TEST_REGISTERSS , + MAPP_TEST_HANDOVER, + MAPP_TEST_PERFORMSUBSEQUENTHANDOVER, + MAPP_TEST_NOTEINERNALHANDOVER, + MAPP_TEST_TRACESUBSCRIBERACTIVITY, + MAPP_TEST_FOWARDSM, + MAPP_TEST_SENDROUTINGINFOFORSM, + MAPP_TEST_CANCELLOC, + MAPP_TEST_CANCELLOCv3, + CAPP_TEST_INITDP, + //CAPP_TEST_ACTTEST, + CAPP_TEST_CONNECT, + //CAPP_TEST_CONTINUE, + //CAPP_TEST_REPORTBCSM, + //CAPP_TEST_CALLREL, + CAPP_TEST_REQREPORTBCSM, + XAPP_TEST_LAST_IDLE, + + //Please add here , add behind the XAPP_TEST_LAST_IDLE + +}; + +void Test_func(); +#endif diff --git a/omc/src b/omc/src new file mode 160000 index 0000000..6cfb0c5 --- /dev/null +++ b/omc/src @@ -0,0 +1 @@ +Subproject commit 6cfb0c54e8869a5cd9fb2196d22d6f3824f250ae